UNPKG

stellar-plus

Version:

beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain

322 lines (321 loc) 12.1 kB
import { SorobanTokenHandlerConstructorArgs, SorobanTokenInterface } from '../../../stellar-plus/asset/soroban-token/types'; import { AssetTypes } from '../../../stellar-plus/asset/types'; import { ContractEngine } from '../../../stellar-plus/core/contract-engine'; import { SorobanTransactionPipelineOutputSimple } from '../../../stellar-plus/core/pipelines/soroban-transaction/types'; import { SorobanSimulationInvocation, TransactionInvocation } from '../../../stellar-plus/core/types'; import { i128, u32 } from '../../../stellar-plus/types'; export declare class SorobanTokenHandler extends ContractEngine implements SorobanTokenInterface { type: AssetTypes; /** * * @args args * @param {NetworkConfig} args.networkConfig - Network to connect to * @param args.contractParameters - Contract parameters * @param {Spec=} args.contractParameters.spec - Contract specification * @param {string=} args.contractParameters.contractId - Contract ID * @param {Buffer=} args.wasm - Contract WASM file as Buffer * @param {string=} args.wasmHash - Contract WASM hash identifier * @param {Options=} args.options - Contract options * @param {SorobanTransactionPipelineOptions=} args.options.sorobanTransactionPipeline - Soroban transaction pipeline options. Allows for customizing how transaction pipeline will be executed for this contract. * * @description Create a new SorobanTokenHandler instance to interact with a Soroban Token contract. * This class is a subclass of ContractEngine and implements the Soroban token interface. * The contract spec is set to the default Soroban Token spec. When initializing the contract, the spec can be overridden with a custom spec. * The contract ID, WASM file, and WASM hash can be provided to initialize the contract with the given parameters. At least one of these parameters must be provided. * */ constructor(args: SorobanTokenHandlerConstructorArgs); /** * * @args args * @param {string} args.admin - Admin account public key * @param {u32} args.decimal - Number of decimals * @param {string} args.name - Token name * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Initialize the contract instance with the given parameters. * * @returns {Promise<SorobanTransactionPipelineOutputSimple>} */ initialize(args: { admin: string; decimal: u32; name: string; symbol: string; } & TransactionInvocation): Promise<SorobanTransactionPipelineOutputSimple>; /** * * @args args * @param {string} args.id - Account public key * @param {string} args.new_admin - New admin account public key * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Set a new admin account for the contract. * * @returns {Promise<SorobanTransactionPipelineOutputSimple>} * * @requires {args.id} to be the current admin account */ setAdmin(args: { id: string; new_admin: string; } & TransactionInvocation): Promise<SorobanTransactionPipelineOutputSimple>; /** * * @args args * @param {EnvelopeHeader} args.header - Transaction envelope header * * @description Get the admin account public key. * * @returns {Promise<string>} * */ admin(args: TransactionInvocation): Promise<string>; /** * * @args args * @param {string} args.id - Account public key * @param {boolean} args.authorize - Whether to authorize or deauthorize the account * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Authorize or deauthorize an account to interact with the contract. * * @returns {Promise<SorobanTransactionPipelineOutputSimple>} * * @requires - Authorization from the admin account */ setAuthorized(args: { id: string; authorize: boolean; } & TransactionInvocation): Promise<SorobanTransactionPipelineOutputSimple>; /** * * @args args * @param {string} args.to - Account public key * @param {i128} args.amount - Amount to mint * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Mint tokens to an account. * * @returns {Promise<SorobanTransactionPipelineOutputSimple>} * * @requires - Authorization from the admin account */ mint(args: { to: string; amount: i128; } & TransactionInvocation): Promise<SorobanTransactionPipelineOutputSimple>; /** * * @args args * @param {string} args.from - Account public key * @param {i128} args.amount - Amount to clawback * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Clawback tokens from an account. * * @returns {Promise<SorobanTransactionPipelineOutputSimple>} * * @requires - Authorization from the admin account */ clawback(args: { from: string; amount: i128; } & TransactionInvocation): Promise<SorobanTransactionPipelineOutputSimple>; /** * * @args args * @param {string} args.from - Account public key * @param {string} args.spender - Spender account public key * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Get the amount of tokens that the spender is allowed to spend on behalf of the account. * * @returns {Promise<i128>} */ allowance(args: { from: string; spender: string; } & SorobanSimulationInvocation): Promise<i128>; /** * * @args args * @param {string} args.from - Account public key * @param {string} args.spender - Spender account public key * @param {i128} args.amount - Amount to approve * @param {u32} args.expiration_ledger - Ledger number until the approval is valid * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Approve a spender to spend tokens on behalf of the account. * * @returns {Promise<SorobanTransactionPipelineOutputSimple>} */ approve(args: { from: string; spender: string; amount: i128; expiration_ledger: u32; } & TransactionInvocation): Promise<SorobanTransactionPipelineOutputSimple>; /** * * @args args * @param {string} args.id - Account public key * * @param {EnvelopeHeader} args.header - Transaction envelope header * * @description Get the balance of the account. * * @returns {Promise<i128>} */ balance(args: { id: string; } & SorobanSimulationInvocation): Promise<i128>; /** * * @args args * @param {string} args.id - Account public key * * @param {EnvelopeHeader} args.header - Transaction envelope header * * @description Get the spendable balance of the account. * * @returns {Promise<i128>} */ spendableBalance(args: { id: string; } & SorobanSimulationInvocation): Promise<i128>; /** * * @args args * @param {string} args.from - Sender public key * @param {string} args.to - Recipient account public key * @param {i128} args.amount - Amount to transfer * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Transfer tokens from the sender to the recipient. * * @returns {Promise<SorobanTransactionPipelineOutputSimple>} */ transfer(args: { from: string; to: string; amount: i128; } & TransactionInvocation): Promise<SorobanTransactionPipelineOutputSimple>; /** * * @args args * @param {string} args.spender - Spender account public key * @param {string} args.from - Sender public key * @param {string} args.to - Recipient account public key * @param {i128} args.amount - Amount to transfer * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Transfer tokens from the sender to the recipient on behalf of the spender. * * @returns {Promise<SorobanTransactionPipelineOutputSimple>} */ transferFrom(args: { spender: string; from: string; to: string; amount: i128; } & TransactionInvocation): Promise<SorobanTransactionPipelineOutputSimple>; /** * * @args args * @param {string} args.from - Account public key * @param {i128} args.amount - Amount to burn * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Burn tokens from an account. * * @returns {Promise<SorobanTransactionPipelineOutputSimple>} */ burn(args: { from: string; amount: i128; } & TransactionInvocation): Promise<SorobanTransactionPipelineOutputSimple>; /** * * @args args * @param {string} args.spender - Spender account public key * @param {string} args.from - Account public key * @param {i128} args.amount - Amount to burn * * @param {EnvelopeHeader} args.header - Transaction envelope header * @param {AccountHandler[]} args.signers - Transaction signers * @param {FeeBumpHeader=} args.feeBump - Fee bump configuration * * @description Burn tokens from an account on behalf of the spender. * * @returns {Promise<SorobanTransactionPipelineOutputSimple>} */ burnFrom(args: { spender: string; from: string; amount: i128; } & TransactionInvocation): Promise<SorobanTransactionPipelineOutputSimple>; /** * * @args args * * @param {EnvelopeHeader} args.header - Transaction envelope header * * @description Get the number of decimals. * * @returns {Promise<u32>} */ decimals(args: SorobanSimulationInvocation): Promise<u32>; /** * * @args args * * @param {EnvelopeHeader} args.header - Transaction envelope header * * @description Get the token name. * * @returns {Promise<string>} */ name(args: SorobanSimulationInvocation): Promise<string>; /** * * @args args * * @param {EnvelopeHeader} args.header - Transaction envelope header * * @description Get the token symbol. * * @returns {Promise<string>} */ symbol(args: SorobanSimulationInvocation): Promise<string>; }