import { ChainId, Item, NFT, Order, Trade } from '@dcl/schemas'; import { ContractData } from 'decentraland-transactions'; import { Credit } from '../modules/credits/types'; export type CreditsData = { value: string; expiresAt: number; salt: string; }; export type UseCreditsArgs = { credits: { value: string; expiresAt: number; salt: string; }[]; creditsSignatures: string[]; externalCall: { target: string; selector: string; data: string; expiresAt: number; salt: string; }; customExternalCallSignature: string; maxUncreditedValue: string | number; maxCreditedValue: string | number; }; export type ExternalCallParams = { target: string; selector: string; data: string; expiresAt: number; salt: string; }; export type CollectionManagerItem = [rarity: string, price: string, beneficiary: string, metadata: string]; export type CollectionManagerCreateCollectionArgs = [ forwarder: string, factory: string, salt: string, name: string, symbol: string, baseURI: string, creator: string, items: CollectionManagerItem[] ]; export declare class CreditsService { /** * Prepares common credits data and gets the CreditsManager contract * @param credits - The user's credits * @param chainId - The chain ID * @returns Object containing the contract, creditsData, and creditsSignatures */ private prepareCreditsData; /** * Prepares the external call parameters * @param params - The external call parameters * @returns The external call object */ private prepareExternalCall; /** * Calculates how much the user needs to pay with MANA after credits are applied * @param price - Total price in wei * @param credits - Prepared credits data * @returns The amount user needs to pay with MANA (0 if credits cover everything) */ private calculateMaxUncreditedValue; /** * Executes the useCredits transaction * @param contract - The CreditsManager contract * @param creditsData - The prepared credits data * @param creditsSignatures - The prepared credits signatures * @param externalCall - The external call object * @param maxCreditedValue - The maximum amount of MANA that can be credited * @returns The transaction hash */ private executeUseCredits; prepareCreditsCollectionStore(item: Item, walletAddress: string, credits: Credit[]): { contract: ContractData; creditsData: CreditsData[]; creditsSignatures: string[]; externalCall: ExternalCallParams; maxUncreditedValue: string; maxCreditedValue: string; }; /** * Use credits for buying items from the CollectionStore * @param item - The item to buy * @param walletAddress - The user's wallet address * @param credits - The user's credits * @returns The transaction hash */ useCreditsCollectionStore(item: Item, walletAddress: string, credits: Credit[]): Promise; prepareCreditsMarketplace(trade: Trade, walletAddress: string, credits: Credit[]): { contract: ContractData; creditsData: CreditsData[]; creditsSignatures: string[]; externalCall: ExternalCallParams; maxUncreditedValue: string; maxCreditedValue: string; }; /** * Use credits for buying NFTs from the Marketplace (using trades) * @param trade - The trade to accept * @param walletAddress - The user's wallet address * @param credits - The user's credits * @returns The transaction hash */ useCreditsMarketplace(trade: Trade, walletAddress: string, credits: Credit[]): Promise; prepareCreditsLegacyMarketplace(nft: NFT, order: Order, credits: Credit[]): { contract: ContractData; creditsData: CreditsData[]; creditsSignatures: string[]; externalCall: ExternalCallParams; maxUncreditedValue: string; maxCreditedValue: string; }; /** * Use credits for buying NFTs from the Legacy Marketplace * @param nft - The NFT to buy * @param order - The order to execute * @param credits - The user's credits * @returns The transaction hash */ useCreditsLegacyMarketplace(nft: NFT, order: Order, credits: Credit[]): Promise; /** * Helper method to get the price of a trade * @param trade - The trade to get the price from * @returns The trade price */ private getTradePrice; prepareCreditsCollectionManager(credits: Credit[], chainId: ChainId | string | number, collectionManagerArgs: CollectionManagerCreateCollectionArgs, totalPrice: string): { contract: ContractData; creditsData: CreditsData[]; creditsSignatures: string[]; externalCall: ExternalCallParams; maxUncreditedValue: string; maxCreditedValue: string; }; /** * Use credits for publishing collections via CollectionManager * @param walletAddress - The user's wallet address * @param credits - The user's credits * @param chainId - The chain ID * @param collectionManagerArgs - Arguments for the createCollection function * @param totalPrice - Total price in wei to pay for publishing * @param creditsServerUrl - URL of the credits server * @returns The transaction hash */ useCreditsCollectionManager(walletAddress: string, credits: Credit[], chainId: ChainId | string | number, collectionManagerArgs: CollectionManagerCreateCollectionArgs, totalPrice: string, creditsServerUrl: string): Promise; private executeUseCreditsWithSignature; /** * Use credits with a custom external call (e.g., CORAL cross-chain transactions) * This is a generic method that can be used for any external call that needs credits * @param price - The total price in wei * @param credits - The user's credits * @param chainId - The chain ID where CreditsManager lives * @param externalCall - External call parameters (target, selector, data, etc.) * @param customExternalCallSignature - Signature of the external call (from backend) * @returns The transaction hash */ useCreditsWithExternalCall(price: string, credits: Credit[], chainId: ChainId | string | number, externalCall: ExternalCallParams, customExternalCallSignature: string): Promise; }