stellar-plus
Version:
beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain
152 lines (151 loc) • 6.76 kB
TypeScript
import { BaseInvocation, ClassicAssetHandlerConstructorArgs, ControlFlags, ClassicAssetHandler as IClassicAssetHandler } from '../../../stellar-plus/asset/classic/types';
import { AssetTypes } from '../../../stellar-plus/asset/types';
import { ClassicTransactionPipelineOutput } from '../../../stellar-plus/core/pipelines/classic-transaction/types';
export declare class ClassicAssetHandler implements IClassicAssetHandler {
code: string;
issuerPublicKey?: string;
type: AssetTypes.native | AssetTypes.credit_alphanum4 | AssetTypes.credit_alphanum12;
private issuerAccount?;
private asset;
private horizonHandler;
private classicTransactionPipeline;
/**
*
* @param {string} code - The asset code.
* @param {string | AccountHandler} issuerAccount - The issuer account. When an account handler is provided, it'll enable management functions and be used to sign transactions as the issuer.
* @param {NetworkConfig} networkConfig - The network configuration to use.
* @param {ClassicTransactionPipelineOptions} options - The options for the classic transaction pipeline.
@param {ClassicTransactionPipelineOptions} options.classicTransactionPipeline - The options for the classic transaction pipeline. These allow for custom configurations for how the transaction pipeline will operate for this asset.
*
* @description - The Classic asset handler is used for handling classic assets with user-based and management functionalities.
*
*
*/
constructor(args: ClassicAssetHandlerConstructorArgs);
/**
*
* @returns {string} The asset code.
*/
symbol(): Promise<string>;
/**
*
* @returns {number} The asset decimals.
* @description - Default for classic assets = 7.
* @todo Improve to get the actual value from the asset issuer's toml file.
*/
decimals(): Promise<number>;
/**
*
* @returns {string} The asset code.
* @todo Improve to get the actual name from the asset issuer's toml file.
*/
name(): Promise<string>;
/**
* @description - Not implemented in the current version for pure classic assets. Only available for Soroban assets.
*/
approve(): Promise<void>;
/**
*
* @param {string} id - The account id to check the balance for.
* @returns {Promise<number>} The balance of the asset for the given account.
*/
balance(id: string): Promise<number>;
/**
*
* @param {string} from - The account id to transfer the asset from.
* @param {string} to - The account id to transfer the asset to.
* @param {i128} amount - The amount of the asset to transfer.
* @param {TransactionInvocation} txInvocation - The transaction invocation object. Must include the 'From' account as a signer to authorize this transaction.
*
* @requires - The 'from' account to be set as a signer in the transaction invocation.
*
* @returns {Promise<void>}
*
* @description - Transfers the given amount of the asset from the 'from' account to the 'to' account.
*/
transfer(args: {
from: string;
to: string;
amount: number;
} & BaseInvocation): Promise<ClassicTransactionPipelineOutput>;
/**
*
* @param {string} from - The account id to burn the asset from.
* @param {number} amount - The amount of the asset to burn.
* @param {TransactionInvocation} txInvocation - The transaction invocation object. Must include the 'From' account as a signer to authorize this transaction.
*
* @requires - The 'from' account to be set as a signer in the transaction invocation.
*
* @returns {Promise<void>}
*
* @description - Burns the given amount of the asset from the 'from' account.
*/
burn(args: {
from: string;
amount: number;
} & BaseInvocation): Promise<ClassicTransactionPipelineOutput>;
/**
* @args
* @param {string} to - The account id to mint the asset to.
* @param {i128} amount - The amount of the asset to mint.
* @param {TransactionInvocation} txInvocation - The transaction invocation object spread. The Issuer account will be automatically added as a signer.
*
* @description - Mints the given amount of the asset to the 'to' account.
* @requires - The issuer account to be set in the asset.
*
* @returns {HorizonNamespace.SubmitTransactionResponse} The response from the Horizon server.
*/
mint(args: {
to: string;
amount: number;
} & BaseInvocation): Promise<ClassicTransactionPipelineOutput>;
/**
*
* @param {ControlFlags} controlFlags - The control flags to set for the asset.
* @param {TransactionInvocation} txInvocation - The transaction invocation object spread. The Issuer account will be automatically added as a signer.
*
* @requires - The issuer account to be set in the asset.
*
* @returns {ClassicTransactionPipelineOutput} The response from the Horizon server.
*/
setFlags(args: {
controlFlags: ControlFlags;
} & BaseInvocation): Promise<ClassicTransactionPipelineOutput>;
clawback(): Promise<void>;
/**
*
* @param {string} to - The account id to mint the asset to.
* @param {number} amount - The amount of the asset to mint.
* @param {TransactionInvocation} txInvocation - The transaction invocation object spread. The Issuer account will be automatically added as a signer.
*
* @requires - The issuer account to be set in the asset.
* @requires - The 'to' account to be set as a signer in the transaction invocation.
*
* @description - Mints the given amount of the asset to the 'to' account. The trustline is also set in process.
*
* @returns {HorizonNamespace.SubmitTransactionResponse} The response from the Horizon server.
*/
addTrustlineAndMint(args: {
to: string;
amount: number;
} & BaseInvocation): Promise<ClassicTransactionPipelineOutput>;
/**
*
* @param {string} to - The account id to add the trustline.
* @param {TransactionInvocation} txInvocation - The transaction invocation object spread.
*
* @requires - The 'to' account to be set as a signer in the transaction invocation.
*
* @description - Adds the trustline for the asset to the 'to' account.
*
* @returns {HorizonNamespace.SubmitTransactionResponse} The response from the Horizon server.
*/
addTrustline(args: {
to: string;
} & BaseInvocation): Promise<ClassicTransactionPipelineOutput>;
/**
*
* @description - Enforces the issuer account to be set.
*/
private requireIssuerAccount;
}