import { CISContract, ContractDryRun } from '../GenericContract.js'; import { ConcordiumGRPCClient } from '../grpc/GRPCClient.js'; import { AccountSigner } from '../signHelpers.js'; import type { HexString, InvokeContractResult } from '../types.js'; import * as BlockHash from '../types/BlockHash.js'; import * as ContractAddress from '../types/ContractAddress.js'; import * as ContractName from '../types/ContractName.js'; import * as TransactionHash from '../types/TransactionHash.js'; import { CIS2 } from './util.js'; type Views = 'balanceOf' | 'operatorOf' | 'tokenMetadata'; type Updates = 'transfer' | 'updateOperator'; /** * Contains methods for performing dry-run invocations of update instructions on CIS-2 smart contracts. */ declare class CIS2DryRun extends ContractDryRun { /** * Performs a dry-run invocation of "transfer" on a corresponding {@link CIS2Contract} instance * * @param {CIS2.Address} sender - Address of the sender of the transfer. * @param {CIS2.Transfer | CIS2.Transfer[]} transfer(s) - The transfer object(s). * @param {BlockHash.Type} [blockHash] - The hash of the block to perform the invocation of. Defaults to the latest finalized block on chain. * * @returns {InvokeContractResult} the contract invocation result, which includes whether or not the invocation succeeded along with the energy spent. */ transfer(sender: CIS2.Address, transfer: CIS2.Transfer, blockHash?: BlockHash.Type): Promise; transfer(sender: CIS2.Address, transfers: CIS2.Transfer[], blockHash?: BlockHash.Type): Promise; /** * Performs a dry-run invocation of "updateOperator" on a corresponding {@link CIS2Contract} instance * * @param {CIS2.Address} owner - Address of the owner of the address to perform the update on. * @param {CIS2.UpdateOperator | CIS2.UpdateOperator[]} update(s) - The update object(s). * @param {BlockHash.Type} [blockHash] - The hash of the block to perform the invocation of. Defaults to the latest finalized block on chain. * * @returns {InvokeContractResult} the contract invocation result, which includes whether or not the invocation succeeded along with the energy spent. */ updateOperator(owner: CIS2.Address, update: CIS2.UpdateOperator, blockHash?: BlockHash.Type): Promise; updateOperator(owner: CIS2.Address, updates: CIS2.UpdateOperator[], blockHash?: BlockHash.Type): Promise; } /** * Contains methods for performing operations on CIS-2 smart contracts. */ export declare class CIS2Contract extends CISContract { schema: Record<'transfer' | 'updateOperator', string>; protected makeDryRunInstance(grpcClient: ConcordiumGRPCClient, contractAddress: ContractAddress.Type, contractName: ContractName.Type): CIS2DryRun; /** * Creates a new `CIS2Contract` instance by querying the node for the necessary information through the supplied `grpcClient`. * * @param {ConcordiumGRPCClient} grpcClient - The client used for contract invocations and updates. * @param {ContractAddress.Type} contractAddress - Address of the contract instance. * * @throws If `InstanceInfo` could not be received for the contract, if the contract does not support the CIS-2 standard, * or if the contract name could not be parsed from the information received from the node. */ static create(grpcClient: ConcordiumGRPCClient, contractAddress: ContractAddress.Type): Promise; /** * Creates a CIS-2 "transfer" update transaction containing a single transfer. * This is particularly useful if you need the parts required for a wallet to submit the transaction. * * @param {CIS2.CreateTransactionMetadata} metadata - Metadata needed for the transaction creation. * @param {CIS2.Transfer} transfer - The transfer object specifying the details of the transfer. * * @throws If the transaction could not be created successfully. * * @returns {CIS2.UpdateTransaction} An object containing the parts of the transaction needed for submission. */ createTransfer(metadata: CIS2.CreateTransactionMetadata, transfer: CIS2.Transfer): CIS2.UpdateTransaction; /** * Creates a CIS-2 "transfer" update transaction containing a list transfers. * This is particularly useful if you need the parts required for a wallet to submit the transaction. * * @param {CIS2.CreateTransactionMetadata} metadata - Metadata needed for the transaction creation. * @param {CIS2.Transfer[]} transfers - A list of transfer objects, each specifying the details of a transfer. * * @throws If the transaction could not be created successfully. * * @returns {CIS2.UpdateTransaction} An object containing the parts of the transaction needed for submission. */ createTransfer(metadata: CIS2.CreateTransactionMetadata, transfers: CIS2.Transfer[]): CIS2.UpdateTransaction; createTransfer(metadata: CIS2.CreateTransactionMetadata, transfers: CIS2.Transfer | CIS2.Transfer[]): CIS2.UpdateTransaction; /** * Sends a CIS-2 "transfer" update transaction containing a single transfer. * * @param {CIS2.TransactionMetadata} metadata - Metadata needed for the transaction. * @param {CIS2.Transfer} transfer - The transfer object specifying the details of the transfer. * @param {AccountSigner} signer - To be used for signing the transaction sent to the node. * * @throws If the update could not be invoked successfully. * * @returns {Promise} The transaction hash of the update transaction */ transfer(metadata: CIS2.TransactionMetadata, transfer: CIS2.Transfer, signer: AccountSigner): Promise; /** * Sends a CIS-2 "transfer" update transaction containing a list transfers. * * @param {CIS2.TransactionMetadata} metadata - Metadata needed for the transaction. * @param {CIS2.Transfer[]} transfers - A list of transfer objects, each specifying the details of a transfer. * @param {AccountSigner} signer - To be used for signing the transaction sent to the node. * * @throws If the update could not be invoked successfully. * * @returns {Promise} The transaction hash of the update transaction */ transfer(metadata: CIS2.TransactionMetadata, transfers: CIS2.Transfer[], signer: AccountSigner): Promise; /** * Creates a CIS-2 "operatorOf" update transaction containing a single operator update instruction. * This is particularly useful if you need the parts required for a wallet to submit the transaction. * * @param {CIS2.CreateTransactionMetadata} metadata - Metadata needed for the transaction creation. * @param {CIS2.UpdateOperator} update - The update instruction object specifying the details of the update. * * @throws If the transaction could not be created successfully. * * @returns {CIS2.UpdateTransaction} An object containing the parts of the transaction needed for submission. */ createUpdateOperator(metadata: CIS2.CreateTransactionMetadata, update: CIS2.UpdateOperator): CIS2.UpdateTransaction; /** * Creates a CIS-2 "operatorOf" update transaction containing a list of operator update instructions. * This is particularly useful if you need the parts required for a wallet to submit the transaction. * * @param {CIS2.CreateTransactionMetadata} metadata - Metadata needed for the transaction creation. * @param {CIS2.UpdateOperator[]} updates - A list of update instruction objects, each specifying the details of an update. * * @throws If the transaction could not be created successfully. * * @returns {CIS2.UpdateTransaction} An object containing the parts of the transaction needed for submission. */ createUpdateOperator(metadata: CIS2.CreateTransactionMetadata, updates: CIS2.UpdateOperator[]): CIS2.UpdateTransaction; createUpdateOperator(metadata: CIS2.CreateTransactionMetadata, updates: CIS2.UpdateOperator | CIS2.UpdateOperator[]): CIS2.UpdateTransaction; /** * Sends a CIS-2 "operatorOf" update transaction containing a single operator update instruction. * * @param {CIS2.TransactionMetadata} metadata - Metadata needed for the transaction. * @param {CIS2.UpdateOperator} update - The update instruction object specifying the details of the update. * @param {AccountSigner} signer - To be used for signing the transaction sent to the node. * * @throws If the update could not be invoked successfully. * * @returns {Promise} The transaction hash of the update transaction */ updateOperator(metadata: CIS2.TransactionMetadata, update: CIS2.UpdateOperator, signer: AccountSigner): Promise; /** * Sends a CIS-2 "operatorOf" update transaction containing a list of operator update instructions. * * @param {CIS2.TransactionMetadata} metadata - Metadata needed for the transaction. * @param {CIS2.UpdateOperator[]} updates - A list of update instruction objects, each specifying the details of an update. * @param {AccountSigner} signer - To be used for signing the transaction sent to the node. * * @throws If the update could not be invoked successfully. * * @returns {Promise} The transaction hash of the update transaction */ updateOperator(metadata: CIS2.TransactionMetadata, updates: CIS2.UpdateOperator[], signer: AccountSigner): Promise; /** * Invokes CIS-2 "balanceOf" with a single query. * * @param {CIS2.BalanceOfQuery} query - The query object specifying the details of the query. * @param {BlockHash.Type} [blockHash] - The hash of the block to perform the query at. Defaults to the latest finalized block. * * @throws If the query could not be invoked successfully. * * @returns {bigint} The balance corresponding to the query. */ balanceOf(query: CIS2.BalanceOfQuery, blockHash?: BlockHash.Type): Promise; /** * Invokes CIS-2 "balanceOf" with a list of queries. * * @param {CIS2.BalanceOfQuery[]} queries - A list of query objects, each specifying the details of a query. * @param {BlockHash.Type} [blockHash] - The hash of the block to perform the query at. Defaults to the latest finalized block. * * @throws If the query could not be invoked successfully. * * @returns {bigint[]} A list of balances corresponding to and ordered by the list of queries. */ balanceOf(queries: CIS2.BalanceOfQuery[], blockHash?: BlockHash.Type): Promise; /** * Invokes CIS-2 "operatorOf" with a single query. * * @param {CIS2.OperatorOfQuery} query - The query object specifying the details of the query. * @param {BlockHash.Type} [blockHash] - The hash of the block to perform the query at. Defaults to the latest finalized block. * * @throws If the query could not be invoked successfully. * * @returns {boolean} Whether the specified address is an operator of the specified owner. */ operatorOf(query: CIS2.OperatorOfQuery, blockHash?: BlockHash.Type): Promise; /** * Invokes CIS-2 "operatorOf" with a list of queries. * * @param {CIS2.OperatorOfQuery[]} queries - A list of query objects, each specifying the details of a query. * @param {BlockHash.Type} [blockHash] - The hash of the block to perform the query at. Defaults to the latest finalized block. * * @throws If the query could not be invoked successfully. * * @returns {boolean[]} As list of boolean results, each detailing whether the specified address is an operator of the specified owner for the corresponding query. * The list is ordered by the corresponding query. */ operatorOf(queries: CIS2.OperatorOfQuery[], blockHash?: BlockHash.Type): Promise; /** * Invokes CIS-2 "tokenMetadata" with a single token ID. * * @param {HexString} tokenId - The ID of the token to get the metadata URL for. * @param {BlockHash.Type} [blockHash] - The hash of the block to perform the query at. Defaults to the latest finalized block. * * @throws If the query could not be invoked successfully. * * @returns {CIS2.MetadataUrl} An object containing the URL of the token metadata. */ tokenMetadata(tokenId: HexString, blockHash?: BlockHash.Type): Promise; /** * Invokes CIS-2 "tokenMetadata" with a list of token ID's. * * @param {HexString[]} tokenIds - A list of ID's of the tokens to get metadata URL's for. * @param {BlockHash.Type} [blockHash] - The hash of the block to perform the query at. Defaults to the latest finalized block. * * @throws If the query could not be invoked successfully. * * @returns {CIS2.MetadataUrl[]} A list of objects containing URL's for token metadata for the corresponding token. * The list is ordered by the token ID's given by `tokenIds` input parameter. */ tokenMetadata(tokenIds: HexString[], blockHash?: BlockHash.Type): Promise; } export {};