/** * @module index */ export declare enum TRANSACTION_TYPE { GENESIS = 1, PAYMENT = 2, ISSUE = 3, TRANSFER = 4, REISSUE = 5, BURN = 6, EXCHANGE = 7, LEASE = 8, CANCEL_LEASE = 9, ALIAS = 10, MASS_TRANSFER = 11, DATA = 12, SET_SCRIPT = 13, SPONSORSHIP = 14, SET_ASSET_SCRIPT = 15, INVOKE_SCRIPT = 16 } export declare enum DATA_FIELD_TYPE { INTEGER = "integer", BOOLEAN = "boolean", BINARY = "binary", STRING = "string" } export interface WithSender { /** * Account public key. This account will pay fee and this account's script will be executed if exists */ senderPublicKey: string; } export interface WithProofs { /** * ITransaction signatures * @minItems 0 * @maxItems 8 */ proofs: string[]; } export interface WithChainId { /** * Network byte. * E.g., * 65 is used for Acryl mainnet, 75 for Acryl testnet */ chainId: number; } export interface WithId { /** * Transaction ID. 32 bytes hash encoded as base58 string */ id: string; } export interface WithTxType { type: TRANSACTION_TYPE; } /** * This interface has common fields for all transactions * @typeparam LONG Generic type representing LONG type. Default to string | number */ export interface ITransaction extends WithProofs, WithSender { type: number; timestamp: number; fee: LONG; version: number; } /** * */ export declare type TTx = IAliasTransaction | IIssueTransaction | ITransferTransaction | IReissueTransaction | IBurnTransaction | ILeaseTransaction | IExchangeTransaction | ICancelLeaseTransaction | IMassTransferTransaction | ISetScriptTransaction | ISponsorshipTransaction | IDataTransaction | ISetAssetScriptTransaction | IInvokeScriptTransaction; /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IIssueTransaction extends ITransaction, WithChainId { type: TRANSACTION_TYPE.ISSUE; /** * @minLength 4 * @maxLength 16 */ name: string; /** * @maxLength 1000 */ description: string; decimals: number; quantity: LONG; reissuable: boolean; script?: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ISetScriptTransaction extends ITransaction, WithChainId { type: TRANSACTION_TYPE.SET_SCRIPT; /** * Compiled script encoded as base64 string */ script: string | null; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ISetAssetScriptTransaction extends ITransaction, WithChainId { type: TRANSACTION_TYPE.SET_ASSET_SCRIPT; assetId: string; /** * Compiled script encoded as base64 string */ script: string | null; } /** * Used to transfer assets from one account to another. * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ITransferTransaction extends ITransaction { type: TRANSACTION_TYPE.TRANSFER; recipient: string; amount: LONG; attachment: string; feeAssetId?: string | null; assetId?: string | null; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IMassTransferItem { recipient: string; amount: LONG; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IReissueTransaction extends ITransaction, WithChainId { type: TRANSACTION_TYPE.REISSUE; assetId: string; quantity: LONG; reissuable: boolean; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IBurnTransaction extends ITransaction, WithChainId { type: TRANSACTION_TYPE.BURN; assetId: string; quantity: LONG; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IExchangeTransaction extends ITransaction { type: TRANSACTION_TYPE.EXCHANGE; order1: IOrder; order2: IOrder; price: LONG; amount: LONG; buyMatcherFee: LONG; sellMatcherFee: LONG; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ILeaseTransaction extends ITransaction { type: TRANSACTION_TYPE.LEASE; amount: LONG; recipient: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ICancelLeaseTransaction extends ITransaction, WithChainId { type: TRANSACTION_TYPE.CANCEL_LEASE; leaseId: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used * Library requires chainId to be present in this transaction, even thought node returns json without it */ export interface IAliasTransaction extends ITransaction, WithChainId { type: TRANSACTION_TYPE.ALIAS; alias: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IMassTransferTransaction extends ITransaction { type: TRANSACTION_TYPE.MASS_TRANSFER; transfers: IMassTransferItem[]; attachment: string; assetId?: string | null; } export interface IDataEntry { key: string; type: DATA_FIELD_TYPE; value: string | number | boolean; } export interface ITypelessDataEntry { key: string; value: string | number | boolean | Uint8Array | number[]; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ISponsorshipTransaction extends ITransaction { type: TRANSACTION_TYPE.SPONSORSHIP; /** * Minimal fee amount in sponsored asset. To disable sponsorship set it to 0 */ minSponsoredAssetFee: LONG; /** * AssetID of sponsored token */ assetId: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IDataTransaction extends ITransaction { type: TRANSACTION_TYPE.DATA; data: IDataEntry[]; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IInvokeScriptPayment { assetId: string | null; amount: LONG; } export interface IInvokeScriptCall { /** * Function name */ function: string; /** * Array of function arguments. E.g.: * {type: 'integer', value: 200} or * { type: 'binary', value: 'base64:AQa3b8tH'} */ args: { type: 'binary' | 'integer' | 'boolean' | 'string'; value: string | number | boolean; }[]; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IInvokeScriptTransaction extends ITransaction, WithChainId { type: TRANSACTION_TYPE.INVOKE_SCRIPT; dApp: string; feeAssetId?: string | null; call?: IInvokeScriptCall; payment?: IInvokeScriptPayment[]; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IOrder extends WithProofs, WithSender { version?: number; orderType: 'buy' | 'sell'; assetPair: { amountAsset: string | null; priceAsset: string | null; }; price: LONG; amount: LONG; timestamp: number; expiration: number; matcherFee: number; matcherPublicKey: string; } export interface IOrderV1 extends IOrder { version: 1 | undefined; } export interface IOrderV2 extends IOrder { version: 2; } export interface IOrderV3 extends IOrder { version: 3; matcherFeeAssetId?: string | null; } export declare type TOrder = IOrderV1 | IOrderV2 | IOrderV3; /** * CancelOrder object. When this object is sent to matcher, order with 'orderId' will be canceled */ export interface ICancelOrder { sender: string; orderId: string; signature: string; hash: string; } export declare type TTxParams = IAliasParams | IBurnParams | IInvokeScriptParams | ICancelLeaseParams | IDataParams | IIssueParams | ILeaseParams | IMassTransferParams | IReissueParams | ISetAssetScriptParams | ISetScriptParams | ISponsorshipParams | ITransferParams; /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IBasicParams { /** * Transaction fee. If not set, fee will be calculated automatically */ fee?: LONG; /** * If fee is not set, this value will be added to automatically calculated fee. E.x.: * Account is scripted and 400000 fee more is required. */ additionalFee?: number; /** * If not set, public key will be derived from seed phrase. You should provide senderPublicKey in two cases: * 1. Account, from which this tx should be sent, differs from tx signer. E.g., we have smart account that requires 2 signatures. * 2. You to create tx without proof. Therefore no seed is provided. */ senderPublicKey?: string; /** * Transaction timestamp. If not set current timestamp will be used. Date.now() */ timestamp?: number; } export interface WithChainIdParam { /** * Network byte. Could be set as number or as char. * If set as char(string), charCodeAt(0) will be used. E.g., * 'A' will be converted to '65' * If not set, 65 will be used as default */ chainId?: string | number; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IAliasParams extends IBasicParams, WithChainIdParam { alias: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IBurnParams extends IBasicParams, WithChainIdParam { assetId: string; quantity: LONG; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ICancelLeaseParams extends IBasicParams, WithChainIdParam { leaseId: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IDataParams extends IBasicParams { data: Array; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IIssueParams extends IBasicParams, WithChainIdParam { /** * @minLength 4 * @maxLength 16 */ name: string; /** * @maxLength 1000 */ description: string; quantity: LONG; decimals?: number; reissuable?: boolean; script?: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ILeaseParams extends IBasicParams { recipient: string; amount: LONG; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IMassTransferParams extends IBasicParams { transfers: IMassTransferItem[]; /** * Bytearray encoded as base string */ attachment?: string; assetId?: string | null; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IOrderParams { matcherPublicKey: string; price: LONG; amount: LONG; orderType: 'buy' | 'sell'; amountAsset: string | null; priceAsset: string | null; senderPublicKey?: string; matcherFee?: number; timestamp?: number; expiration?: number; matcherFeeAssetId?: string | null; } export interface ICancelOrderParams { orderId: string; signature?: string; senderPublicKey?: string; } export interface IAuthParams { data: string; host: string; publicKey?: string; } export interface IAuth { data: string; host: string; address: string; publicKey: string; hash: string; signature: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IReissueParams extends IBasicParams, WithChainIdParam { assetId: string; quantity: LONG; reissuable: boolean; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ISetAssetScriptParams extends IBasicParams, WithChainIdParam { /** * Compiled script encoded as base64 string */ script: string; assetId: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ISetScriptParams extends IBasicParams, WithChainIdParam { /** * Compiled script encoded as base64 string */ script: string | null; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ISponsorshipParams extends IBasicParams { /** * AssetID of sponsored token */ assetId: string; /** * Minimal fee amount in sponsored asset. To disable sponsorship set it to 0 */ minSponsoredAssetFee: LONG; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface ITransferParams extends IBasicParams { /** * Can be either address(base58 encoded 24 byte address) or alias. * Alias should be used like 'alias:{chainId}:{alias}>'. E.g.: * If we have alias 'foo', and we want TESTNET transaction, recipient should be 'alias:K:foo' */ recipient: string; amount: LONG; assetId?: string | null; /** * Fee can be paid in custom token if sponsorship has been set for this token */ feeAssetId?: string | null; /** * Bytearray encoded as base58 string */ attachment?: string; } /** * @typeparam LONG Generic type representing LONG type. Default to string | number. Since javascript number more than 2 ** 53 -1 cannot be precisely represented, generic type is used */ export interface IInvokeScriptParams extends IBasicParams, WithChainIdParam { dApp: string; feeAssetId?: string | null; call?: { function: string; args?: { type: 'binary' | 'integer' | 'boolean' | 'string'; value: string | number | boolean; }[]; }; payment?: { assetId?: string | null; amount: number; }[]; }