UNPKG

@layerzerolabs/lz-aptos-sdk-v1

Version:

Aptos SDK for LayerZero

1,309 lines (1,295 loc) 187 kB
import * as aptos from 'aptos'; import { HexString } from 'aptos'; import { Environment, Stage } from '@layerzerolabs/lz-definitions'; import BN from 'bn.js'; import { types } from '@layerzerolabs/lz-movevm-sdk-v2'; /** * Interface representing the channel type. */ interface ChannelType { /** * The outbound nonce. */ outbound_nonce: string; /** * The inbound nonce. */ inbound_nonce: string; /** * The payload hashes. */ payload_hashs: { handle: string; }; } /** * Class representing a channel. */ declare class Channel { private sdk; /** * The module name. */ readonly module: string; /** * Creates an instance of the Channel class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); /** * Gets outbound events. * * @param {bigint} start - The start index. * @param {number} limit - The limit of events to retrieve. * @returns {Promise<aptos.Types.Event[]>} A promise that resolves to an array of events. */ getOutboundEvents(start: bigint, limit: number): Promise<aptos.Types.Event[]>; /** * Gets inbound events. * * @param {bigint} start - The start index. * @param {number} limit - The limit of events to retrieve. * @returns {Promise<aptos.Types.Event[]>} A promise that resolves to an array of events. */ getInboundEvents(start: bigint, limit: number): Promise<aptos.Types.Event[]>; /** * Gets receive events. * * @param {bigint} start - The start index. * @param {number} limit - The limit of events to retrieve. * @returns {Promise<aptos.Types.Event[]>} A promise that resolves to an array of events. */ getReceiveEvents(start: bigint, limit: number): Promise<aptos.Types.Event[]>; /** * Gets the channel state. * * @param {aptos.MaybeHexString} uaAddress - The user address. * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {aptos.BCS.Bytes} remoteAddress - The remote address. * @param {Object} [query] - The query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<ChannelType>} A promise that resolves to the channel state. */ getChannelState(uaAddress: aptos.MaybeHexString, remoteChainId: aptos.BCS.Uint16, remoteAddress: aptos.BCS.Bytes, query?: { ledgerVersion?: bigint | number; }): Promise<ChannelType>; /** * Gets the outbound nonce. * * @param {aptos.MaybeHexString} uaAddress - The user address. * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {aptos.BCS.Bytes} remoteAddress - The remote address. * @param {Object} [query] - The query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<aptos.BCS.Uint64>} A promise that resolves to the outbound nonce. */ getOutboundNonce(uaAddress: aptos.MaybeHexString, remoteChainId: aptos.BCS.Uint16, remoteAddress: aptos.BCS.Bytes, query?: { ledgerVersion?: bigint | number; }): Promise<aptos.BCS.Uint64>; /** * Gets the inbound nonce. * * @param {aptos.MaybeHexString} uaAddress - The user address. * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {aptos.BCS.Bytes} remoteAddress - The remote address. * @param {Object} [query] - The query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<aptos.BCS.Uint64>} A promise that resolves to the inbound nonce. */ getInboundNonce(uaAddress: aptos.MaybeHexString, remoteChainId: aptos.BCS.Uint16, remoteAddress: aptos.BCS.Bytes, query?: { ledgerVersion?: bigint | number; }): Promise<aptos.BCS.Uint64>; /** * Gets the payload hash. * * @param {aptos.MaybeHexString} uaAddress - The user address. * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {aptos.BCS.Bytes} remoteAddress - The remote address. * @param {aptos.BCS.Uint64} nonce - The nonce. * @param {Object} [query] - The query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<string>} A promise that resolves to the payload hash. */ getPayloadHash(uaAddress: aptos.MaybeHexString, remoteChainId: aptos.BCS.Uint16, remoteAddress: aptos.BCS.Bytes, nonce: aptos.BCS.Uint64, query?: { ledgerVersion?: bigint | number; }): Promise<string>; /** * Checks if the proof is delivered. * * @param {aptos.MaybeHexString} uaAddress - The user address. * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {aptos.BCS.Bytes} remoteAddress - The remote address. * @param {aptos.BCS.Uint64} nonce - The nonce. * @param {Object} [query] - The query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<boolean>} A promise that resolves to true if the proof is delivered, false otherwise. */ isProofDelivered(uaAddress: aptos.MaybeHexString, remoteChainId: aptos.BCS.Uint16, remoteAddress: aptos.BCS.Bytes, nonce: aptos.BCS.Uint64, query?: { ledgerVersion?: bigint | number; }): Promise<boolean>; } /** * Consistent with aptos_std::type_info::TypeInfo */ interface TypeInfo { /** * The account address. */ account_address: string; /** * The module name. */ module_name: string; /** * The struct name. */ struct_name: string; } /** * Extends {@link TypeInfo} */ interface TypeInfoEx extends TypeInfo { /** * A value in `account_address::module_name::struct_name` format. */ type: string; } /** * Interface representing coin information. */ interface CoinInfo { /** * The name of the coin. */ name: string; /** * The symbol of the coin. */ symbol: string; /** * The number of decimals the coin uses. */ decimals: number; /** * The total supply of the coin. */ supply: bigint; } /** * Extends {@link CoinInfo} */ interface CoinInfoEx extends CoinInfo { /** * The type of the coin. */ type: string; } /** * Interface representing coin information resource. */ interface CoinInfoResource { /** * The type of the resource. */ type: string; /** * The data of the resource. */ data: { /** * The number of decimals the coin uses. */ decimals: number; /** * The name of the coin. */ name: string; /** * The supply of the coin. */ supply: { vec: [{ integer: { vec: [{ value: string; }]; }; }]; }; /** * The symbol of the coin. */ symbol: string; }; } /** * Interface representing ULN configuration type. */ interface UlnConfigType { /** * The number of inbound confirmations. */ inbound_confirmations: aptos.BCS.Uint64 | aptos.BCS.Uint32; /** * The oracle address. */ oracle: string; /** * The number of outbound confirmations. */ outbound_confirmations: aptos.BCS.Uint64 | aptos.BCS.Uint32; /** * The relayer address. */ relayer: string; } /** * Interface representing a packet. */ interface Packet { /** * The nonce of the packet. */ nonce: string | aptos.BCS.Uint64; /** * The source chain ID. */ src_chain_id: string | aptos.BCS.Uint16; /** * The source address. */ src_address: Buffer; /** * The destination chain ID. */ dst_chain_id: string | aptos.BCS.Uint16; /** * The destination address. */ dst_address: Buffer; /** * The payload of the packet. */ payload: Buffer; } /** * Interface representing ULN signer fee. */ interface UlnSignerFee { /** * The base fee. */ base_fee: aptos.BCS.Uint64; /** * The fee per byte. */ fee_per_byte: aptos.BCS.Uint64; } /** * Interface representing the ULN configuration. */ interface UlnConfig$1 { /** * The number of confirmations. */ confirmations: aptos.BCS.Uint64; /** * The optional DVN threshold. */ optionalDVNThreshold: aptos.BCS.Uint32; /** * The required DVNs. */ requiredDVNs: string[]; /** * The optional DVNs. */ optionalDVNs: string[]; /** * Whether to use the default for confirmations. */ useDefaultForConfirmations: boolean; /** * Whether to use the default for required DVNs. */ useDefaultForRequiredDVNs: boolean; /** * Whether to use the default for optional DVNs. */ useDefaultForOptionalDVNs: boolean; } /** * Use to parse the ULN configuration response from the contract method, * Everyone who needs to use the ULN configuration should use @see UlnConfig instead of this. */ interface UlnConfigResponse { confirmations: bigint; optional_dvn_threshold: number; required_dvns: string[]; optional_dvns: string[]; use_default_for_confirmations: boolean; use_default_for_required_dvns: boolean; use_default_for_optional_dvns: boolean; } /** * Interface representing the executor configuration. */ interface ExecutorConfig$1 { /** * The maximum message size. */ maxMessageSize: aptos.BCS.Uint32; /** * The executor address. */ executorAddress: string; } /** * Use to parse the Executor configuration response from the contract method, * Everyone who needs to use the Executor configuration should use @see ExecutorConfig instead of this. */ interface ExecutorConfigResponse { max_message_size: number; executor_address: string; } type index$3_CoinInfo = CoinInfo; type index$3_CoinInfoEx = CoinInfoEx; type index$3_CoinInfoResource = CoinInfoResource; type index$3_ExecutorConfigResponse = ExecutorConfigResponse; type index$3_Packet = Packet; type index$3_TypeInfo = TypeInfo; type index$3_TypeInfoEx = TypeInfoEx; type index$3_UlnConfigResponse = UlnConfigResponse; type index$3_UlnConfigType = UlnConfigType; type index$3_UlnSignerFee = UlnSignerFee; declare namespace index$3 { export type { index$3_CoinInfo as CoinInfo, index$3_CoinInfoEx as CoinInfoEx, index$3_CoinInfoResource as CoinInfoResource, ExecutorConfig$1 as ExecutorConfig, index$3_ExecutorConfigResponse as ExecutorConfigResponse, index$3_Packet as Packet, index$3_TypeInfo as TypeInfo, index$3_TypeInfoEx as TypeInfoEx, UlnConfig$1 as UlnConfig, index$3_UlnConfigResponse as UlnConfigResponse, index$3_UlnConfigType as UlnConfigType, index$3_UlnSignerFee as UlnSignerFee }; } /** * Class representing an endpoint. */ declare class Endpoint { private sdk; /** * The module name. */ readonly module: string; /** * The module name with namespace. */ readonly moduleName: string; /** * The view module name. */ readonly viewModule: string; /** * The view module name for uln301. */ readonly viewUln301Module: string; /** * Creates an instance of the Endpoint class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); /** * Initializes the endpoint. * * @param {aptos.AptosAccount} signer - The signer account. * @param {aptos.BCS.Uint16} localChainId - The local chain ID. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ initialize(signer: aptos.AptosAccount, localChainId: aptos.BCS.Uint16): Promise<aptos.Types.Transaction>; /** * Gets the local chain ID. * * @returns {Promise<aptos.BCS.Uint64 | undefined>} A promise that resolves to the local chain ID or undefined if not found. */ getLocalChainId(): Promise<aptos.BCS.Uint64 | undefined>; /** * Gets the UA type information. * * @param {aptos.MaybeHexString} uaAddress - The UA address. * @returns {Promise<TypeInfoEx>} A promise that resolves to the type information. */ getUATypeInfo(uaAddress: aptos.MaybeHexString): Promise<TypeInfoEx>; /** * Gets the oracle fee. * * @param {aptos.MaybeHexString} oracleAddr - The oracle address. * @param {aptos.BCS.Uint16} dstChainId - The destination chain ID. * @returns {Promise<aptos.BCS.Uint64>} A promise that resolves to the oracle fee. */ getOracleFee(oracleAddr: aptos.MaybeHexString, dstChainId: aptos.BCS.Uint16): Promise<aptos.BCS.Uint64>; /** * Gets the register events. * * @param {bigint} start - The start index. * @param {number} limit - The limit of events to fetch. * @returns {Promise<aptos.Types.Event[]>} A promise that resolves to an array of events. */ getRegisterEvents(start: bigint, limit: number): Promise<aptos.Types.Event[]>; /** * Quotes the fee. * * @param {aptos.MaybeHexString} uaAddress - The UA address. * @param {aptos.BCS.Uint16} dstChainId - The destination chain ID. * @param {aptos.BCS.Bytes} adapterParams - The adapter parameters. * @param {number} payloadSize - The payload size. * @param {Object} [query] - The query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @param {aptos.BCS.Bytes} [msglibParams] - The msglib parameters. * @returns {Promise<{ nativeFee: aptos.BCS.Uint64; zroFee: aptos.BCS.Uint64 }>} A promise that resolves to the quoted fee. */ quoteFee(uaAddress: aptos.MaybeHexString, dstChainId: aptos.BCS.Uint16, adapterParams: aptos.BCS.Bytes, payloadSize: number, msglibParams?: aptos.BCS.Bytes, payInZro?: boolean, query?: { ledgerVersion?: bigint | number; }): Promise<{ nativeFee: aptos.BCS.Uint64; zroFee: aptos.BCS.Uint64; }>; /** * Checks if a message is verifiable. * * @param {string} packetHeaderBytes - The packet header bytes. * @param {string} payloadHash - The payload hash. * @returns {Promise<aptos.BCS.Uint8>} A promise that resolves to the verifiable state. */ verifiable(packetHeaderBytes: string, payloadHash: string): Promise<aptos.BCS.Uint8>; /** * Checks if a message is executable. * * @param {aptos.BCS.Uint32} srcEid - The source endpoint ID. * @param {aptos.BCS.Bytes} sender - The sender. * @param {aptos.BCS.Uint64} nonce - The nonce. * @param {aptos.MaybeHexString} receiver - The receiver. * @returns {Promise<aptos.BCS.Uint8>} A promise that resolves to the executable state. */ executable(srcEid: aptos.BCS.Uint32, sender: aptos.BCS.Bytes, nonce: aptos.BCS.Uint64, receiver: aptos.MaybeHexString): Promise<aptos.BCS.Uint8>; /** * Gets the send msglib. * * @param {aptos.MaybeHexString} uaAddress - The UA address. * @param {aptos.BCS.Uint16} chainId - The chain ID. * @returns {Promise<[aptos.BCS.Uint64, aptos.BCS.Uint8]>} A promise that resolves to the send msglib. */ getSendMsglib(uaAddress: aptos.MaybeHexString, chainId: aptos.BCS.Uint16): Promise<[aptos.BCS.Uint64, aptos.BCS.Uint8]>; /** * Gets the receive msglib. * * @param {aptos.MaybeHexString} uaAddress - The UA address. * @param {aptos.BCS.Uint16} chainId - The chain ID. * @returns {Promise<[aptos.BCS.Uint64, aptos.BCS.Uint8]>} A promise that resolves to the receive msglib. */ getReceiveMsglib(uaAddress: aptos.MaybeHexString, chainId: aptos.BCS.Uint16): Promise<[aptos.BCS.Uint64, aptos.BCS.Uint8]>; /** * Creates a payload for registering an executor. * * @param {string} executorType - The executor type. * @returns {aptos.Types.EntryFunctionPayload} The payload. */ registerExecutorPayload(executorType: string): aptos.Types.EntryFunctionPayload; /** * Registers an executor. * * @param {aptos.AptosAccount} signer - The signer account. * @param {string} executorType - The executor type. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ registerExecutor(signer: aptos.AptosAccount, executorType: string): Promise<aptos.Types.Transaction>; /** * Gets the executor capability. * * @param {string} [version='1'] - The version. * @returns {Promise<string | undefined>} A promise that resolves to the executor capability or undefined if not found. */ getExecutorCap(version?: string): Promise<string | undefined>; } /** * Interface representing the fee configuration. */ interface Fee { /** * The airdrop amount cap. */ airdropAmtCap: aptos.BCS.Uint64; /** * The price ratio. */ priceRatio: aptos.BCS.Uint64; /** * The gas price. */ gasPrice: aptos.BCS.Uint64; } /** * Class representing an Executor. */ declare class Executor { private sdk; readonly module: string; readonly moduleName: string; readonly type: string; /** * Creates an instance of the Executor class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); /** * Creates the payload for setting the default adapter parameters. * * @param {aptos.BCS.Uint16} dstChainId - The destination chain ID. * @param {aptos.BCS.Bytes} adapterParams - The adapter parameters. * @returns {aptos.Types.EntryFunctionPayload} The payload for setting the default adapter parameters. */ setDefaultAdapterParamsPayload(dstChainId: aptos.BCS.Uint16, adapterParams: aptos.BCS.Bytes): aptos.Types.EntryFunctionPayload; /** * Sets the default adapter parameters. * * @param {aptos.AptosAccount} signer - The signer account. * @param {aptos.BCS.Uint16} dstChainId - The destination chain ID. * @param {aptos.BCS.Bytes} adapterParams - The adapter parameters. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ setDefaultAdapterParams(signer: aptos.AptosAccount, dstChainId: aptos.BCS.Uint16, adapterParams: aptos.BCS.Bytes): Promise<aptos.Types.Transaction>; /** * Gets the default adapter parameters for a given chain ID. * * @param {aptos.BCS.Uint16} chainId - The chain ID. * @returns {Promise<aptos.BCS.Bytes>} A promise that resolves to the default adapter parameters. * @throws {Error} If the LayerZero account is undefined. */ getDefaultAdapterParams(chainId: aptos.BCS.Uint16): Promise<aptos.BCS.Bytes>; /** * Checks if an address is registered. * * @param {aptos.MaybeHexString} address - The address to check. * @returns {Promise<boolean>} A promise that resolves to true if the address is registered, false otherwise. */ isRegistered(address: aptos.MaybeHexString): Promise<boolean>; /** * Creates the payload for registering an executor. * * @returns {aptos.Types.EntryFunctionPayload} The payload for registering an executor. */ registerPayload(): aptos.Types.EntryFunctionPayload; /** * Registers an executor. * * @param {aptos.AptosAccount} signer - The signer account. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ register(signer: aptos.AptosAccount): Promise<aptos.Types.Transaction>; /** * Creates the payload for setting the fee. * * @param {aptos.BCS.Uint16} dstChainId - The destination chain ID. * @param {Fee} config - The fee configuration. * @returns {aptos.Types.EntryFunctionPayload} The payload for setting the fee. */ setFeePayload(dstChainId: aptos.BCS.Uint16, config: Fee): aptos.Types.EntryFunctionPayload; /** * Sets the fee. * * @param {aptos.AptosAccount} signer - The signer account. * @param {aptos.BCS.Uint16} dstChainId - The destination chain ID. * @param {Fee} config - The fee configuration. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ setFee(signer: aptos.AptosAccount, dstChainId: aptos.BCS.Uint16, config: Fee): Promise<aptos.Types.Transaction>; /** * Gets the fee configuration for a given executor and chain ID. * * @param {aptos.MaybeHexString} executor - The executor address. * @param {aptos.BCS.Uint16} chainId - The chain ID. * @param {object} [query] - The query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<Fee>} A promise that resolves to the fee configuration. * @throws {Error} If an error occurs while fetching the fee configuration. */ getFee(executor: aptos.MaybeHexString, chainId: aptos.BCS.Uint16, query?: { ledgerVersion?: bigint | number; }): Promise<Fee>; /** * Creates the payload for airdropping tokens. * * @param {aptos.BCS.Uint16} srcChainId - The source chain ID. * @param {aptos.BCS.Bytes} guid - The GUID. * @param {aptos.MaybeHexString} receiver - The receiver address. * @param {aptos.BCS.Uint64 | aptos.BCS.Uint32} amount - The amount to airdrop. * @returns {aptos.Types.EntryFunctionPayload} The payload for airdropping tokens. */ airdropPayload(srcChainId: aptos.BCS.Uint16, guid: aptos.BCS.Bytes, receiver: aptos.MaybeHexString, amount: aptos.BCS.Uint64 | aptos.BCS.Uint32): aptos.Types.EntryFunctionPayload; /** * Airdrops tokens. * * @param {aptos.AptosAccount} signer - The signer account. * @param {aptos.BCS.Uint16} srcChainId - The source chain ID. * @param {aptos.BCS.Bytes} guid - The GUID. * @param {aptos.MaybeHexString} receiver - The receiver address. * @param {aptos.BCS.Uint64 | aptos.BCS.Uint32} amount - The amount to airdrop. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ airdrop(signer: aptos.AptosAccount, srcChainId: aptos.BCS.Uint16, guid: aptos.BCS.Bytes, receiver: aptos.MaybeHexString, amount: aptos.BCS.Uint64 | aptos.BCS.Uint32): Promise<aptos.Types.Transaction>; /** * Checks if a GUID has been airdropped to a receiver. * * @param {aptos.BCS.Bytes} guid - The GUID. * @param {aptos.MaybeHexString} receiver - The receiver address. * @returns {Promise<boolean>} A promise that resolves to true if the GUID has been airdropped, false otherwise. * @throws {Error} If the LayerZero account is undefined. */ isAirdropped(guid: aptos.BCS.Bytes, receiver: aptos.MaybeHexString): Promise<boolean>; /** * Quotes the fee for a given executor, destination chain ID, and adapter parameters. * * @param {aptos.MaybeHexString} executor - The executor address. * @param {aptos.BCS.Uint16} dstChainId - The destination chain ID. * @param {aptos.BCS.Bytes} adapterParams - The adapter parameters. * @param {object} [query] - The query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<aptos.BCS.Uint64>} A promise that resolves to the quoted fee. */ quoteFee(executor: aptos.MaybeHexString, dstChainId: aptos.BCS.Uint16, adapterParams: aptos.BCS.Bytes, query?: { ledgerVersion?: bigint | number; }): Promise<aptos.BCS.Uint64>; /** * Builds the default adapter parameters. * * @param {aptos.BCS.Uint64 | aptos.BCS.Uint32} uaGas - The user application gas. * @returns {aptos.BCS.Bytes} The default adapter parameters. */ buildDefaultAdapterParams(uaGas: aptos.BCS.Uint64 | aptos.BCS.Uint32): aptos.BCS.Bytes; /** * Builds the airdrop adapter parameters. * * @param {aptos.BCS.Uint64 | aptos.BCS.Uint32} uaGas - The user application gas. * @param {aptos.BCS.Uint64 | aptos.BCS.Uint32} airdropAmount - The airdrop amount. * @param {string} airdropAddress - The airdrop address. * @returns {aptos.BCS.Bytes} The airdrop adapter parameters. */ buildAirdropAdapterParams(uaGas: aptos.BCS.Uint64 | aptos.BCS.Uint32, airdropAmount: aptos.BCS.Uint64 | aptos.BCS.Uint32, airdropAddress: string): aptos.BCS.Bytes; /** * Decodes the adapter parameters. * * txType 1 * bytes [2 8 ] * fields [txType extraGas] * txType 2 * bytes [2 8 8 unfixed ] * fields [txType extraGas airdropAmt airdropAddress] * * @param {aptos.BCS.Bytes} adapterParams - The adapter parameters. * @returns {[aptos.BCS.Uint16, aptos.BCS.Uint64, aptos.BCS.Uint64, string]} The decoded adapter parameters. * @throws {Error} If the adapter parameters are invalid. */ decodeAdapterParams(adapterParams: aptos.BCS.Bytes): [aptos.BCS.Uint16, aptos.BCS.Uint64, aptos.BCS.Uint64, string]; /** * Rebuilds a compiled script to query type arguments for the lz_receive function. * * @param {Packet} packet - The packet. * @returns {Promise<string>} A promise that resolves to the rebuilt script bytecode. * @throws {Error} If the executor_ext account is undefined. */ rebuildTypeArgsScript(packet: Packet): Promise<string>; /** * Executes compiled script on chain to get type arguments for lz_receive function. * * @param {Packet} packet - The packet. * @returns {Promise<string[]>} A promise that resolves to the type arguments. * @throws {Error} If the sdk accounts layerzero_apps_pubkey is undefined. */ getLzReceiveTypeArguments(packet: Packet): Promise<string[]>; /** * Gets lz_receive_types arguments by view function (tagged with #[view]). * 1. Tries UA::${module}::lz_receive_types, if failed, then * 2. Tries UA::lz_receive::lz_receive_types by convention. * * @param {Packet} packet - The packet. * @param {string} [ledger_version] - The ledger version. * @returns {Promise<[string[], TypeInfoEx]>} A promise that resolves to the type arguments and TypeInfoEx. * @throws {Error} If the lz_receive_types arguments cannot be retrieved. */ getLzReceiveTypeArgumentsView(packet: Packet, ledger_version?: string): Promise<[string[], TypeInfoEx]>; /** * Gets the payload for the lz_receive function. * * @param {string[]} type_arguments - The type arguments. * @param {Packet} packet - The packet. * @param {TypeInfo} [uaTypeInfo] - The TypeInfo. * @returns {Promise<aptos.Types.EntryFunctionPayload>} A promise that resolves to the payload. */ getLzReceivePayload(type_arguments: string[], packet: Packet, uaTypeInfo?: TypeInfo): Promise<aptos.Types.EntryFunctionPayload>; /** * Executes the lz_receive function. * * @param {aptos.AptosAccount} signer - The signer account. * @param {string[]} type_arguments - The type arguments. * @param {Packet} packet - The packet. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ lzReceive(signer: aptos.AptosAccount, type_arguments: string[], packet: Packet): Promise<aptos.Types.Transaction>; /** * Auto-detects lz_receive_types and calls lz_receive. * * @param {aptos.AptosAccount} signer - The signer account. * @param {Packet} packet - The packet. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ lzReceiveNew(signer: aptos.AptosAccount, packet: Packet): Promise<aptos.Types.Transaction>; /** * Gets the short request event type. * * @returns {string} The short request event type. */ getShortRequestEventType(): string; } /** * Class representing the executor configuration. */ declare class ExecutorConfig { private sdk; /** * The module name. */ readonly module: string; /** * Creates an instance of the ExecutorConfig class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); /** * Gets the default executor for a given remote chain ID. * * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @returns {Promise<[string, aptos.BCS.Uint64]>} A promise that resolves to the executor and version. * @throws {Error} If the SDK accounts layerzero is undefined. */ getDefaultExecutor(remoteChainId: aptos.BCS.Uint16): Promise<[string, aptos.BCS.Uint64]>; /** * Gets the executor for a given user address and remote chain ID. * * @param {aptos.MaybeHexString} uaAddress - The user address. * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {Object} [query] - Optional query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<[string, aptos.BCS.Uint64]>} A promise that resolves to the executor and version. */ getExecutor(uaAddress: aptos.MaybeHexString, remoteChainId: aptos.BCS.Uint16, query?: { ledgerVersion?: bigint | number; }): Promise<[string, aptos.BCS.Uint64]>; /** * Creates a payload for setting the default executor. * * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {aptos.BCS.Uint8} version - The version. * @param {aptos.MaybeHexString} executor - The executor address. * @returns {aptos.Types.EntryFunctionPayload} The payload. */ setDefaultExecutorPayload(remoteChainId: aptos.BCS.Uint16, version: aptos.BCS.Uint8, executor: aptos.MaybeHexString): aptos.Types.EntryFunctionPayload; } declare class ExecutorV2 { private sdk; /** * The module name. */ readonly module: string; readonly type: string; /** * Creates an instance of the UlnReceive class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); quoteFee(uaAddress: string, executorAddress: string, dstChainId: bigint, adapterParams: Uint8Array): Promise<aptos.BCS.Uint64>; } declare class MsgLib { private sdk; /** * The module name. */ readonly module: string; readonly routingModule: string; /** * Creates an instance of the MsgLib class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); createInitPayload(): Promise<aptos.Types.EntryFunctionPayload>; init(signer: aptos.AptosAccount): Promise<aptos.Types.Transaction>; createSyncVersionPayload(uaAddress: string, chainId: aptos.BCS.Uint64): Promise<aptos.Types.EntryFunctionPayload>; syncVersion(signer: aptos.AptosAccount, uaAddress: string, chainId: aptos.BCS.Uint64): Promise<aptos.Types.Transaction>; /** * Checks if the module is initialized. * * @returns {Promise<boolean>} A promise that resolves to true if the module is initialized, false otherwise. */ isInitialize(): Promise<boolean>; isVersionSynced(uaAddress: string, chainId: aptos.BCS.Uint64): Promise<boolean>; } /** * Class representing message library authorization. */ declare class MsgLibAuth { private sdk; /** * The module name. */ readonly module: string; /** * The module name string. */ readonly moduleName: string; /** * Creates an instance of the MsgLibAuth class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); /** * Checks if a message library receive address is allowed. * * @param {string} msglibReceive - The message library receive address. * @returns {Promise<boolean>} A promise that resolves to true if allowed, false otherwise. * @throws Will throw an error if sdk accounts msglib_auth is undefined. */ isAllowed(msglibReceive: string): Promise<boolean>; /** * Creates a payload to deny a message library receive address. * * @param {string} msglibReceive - The message library receive address. * @returns {aptos.Types.EntryFunctionPayload} The payload. */ denyPayload(msglibReceive: string): aptos.Types.EntryFunctionPayload; /** * Creates a payload to allow a message library receive address. * * @param {string} msglibReceive - The message library receive address. * @returns {aptos.Types.EntryFunctionPayload} The payload. */ allowPayload(msglibReceive: string): aptos.Types.EntryFunctionPayload; /** * Allows a message library receive address. * * @param {aptos.AptosAccount} signer - The signer account. * @param {string} msglibReceive - The message library receive address. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ allow(signer: aptos.AptosAccount, msglibReceive: string): Promise<aptos.Types.Transaction>; } /** * Class representing the MsgLibConfig module. */ declare class MsgLibConfig { private sdk; /** * The module path. */ readonly module: string; /** * The module name. */ readonly moduleName: string; /** * The semver module path. */ readonly semverModule: string; /** * Creates an instance of the MsgLibConfig class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); /** * Gets the default send message library version for a remote chain. * * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @returns {Promise<{ major: aptos.BCS.Uint64; minor: aptos.BCS.Uint8 }>} A promise that resolves to the version. * @throws Will throw an error if the SDK accounts layerzero is undefined. */ getDefaultSendMsgLib(remoteChainId: aptos.BCS.Uint16): Promise<{ major: aptos.BCS.Uint64; minor: aptos.BCS.Uint8; }>; /** * Gets the default receive message library version for a remote chain. * * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @returns {Promise<{ major: aptos.BCS.Uint64; minor: aptos.BCS.Uint8 }>} A promise that resolves to the version. * @throws Will throw an error if the SDK accounts layerzero is undefined. */ getDefaultReceiveMsgLib(remoteChainId: aptos.BCS.Uint16): Promise<{ major: aptos.BCS.Uint64; minor: aptos.BCS.Uint8; }>; /** * Creates a payload for setting the default send message library version. * * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {aptos.BCS.Uint64} major - The major version. * @param {aptos.BCS.Uint8} minor - The minor version. * @returns {aptos.Types.EntryFunctionPayload} The payload. */ setDefaultSendMsgLibPayload(remoteChainId: aptos.BCS.Uint16, major: aptos.BCS.Uint64, minor: aptos.BCS.Uint8): aptos.Types.EntryFunctionPayload; /** * Creates a payload for setting the default receive message library version. * * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {aptos.BCS.Uint64} major - The major version. * @param {aptos.BCS.Uint8} minor - The minor version. * @returns {aptos.Types.EntryFunctionPayload} The payload. */ setDefaultReceiveMsgLibPayload(remoteChainId: aptos.BCS.Uint16, major: aptos.BCS.Uint64, minor: aptos.BCS.Uint8): aptos.Types.EntryFunctionPayload; } /** * Class representing the MsgLibV1_0 module. */ declare class MsgLibV1_0 { private sdk; /** * The module name. */ readonly module: string; /** * Creates an instance of the MsgLibV1_0 class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); } /** * Class representing packet events. */ declare class PacketEvent { private sdk; /** * The module name. */ readonly module: string; /** * The outbound event type. */ readonly OutboundEventType: string; /** * The inbound event type. */ readonly InboundEventType: string; /** * Creates an instance of the PacketEvent class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); /** * Returns an array of VersionedEvent objects for inbound events. * * @param {bigint} start - The start index of the events, starting from 0. * @param {number} limit - The maximum number of events to return. * @returns {Promise<aptos.Types.VersionedEvent[]>} An array of VersionedEvent objects. * @throws {Error} If sdk accounts layerzero is undefined. * @example * [ * { * "version": "2527457", * "guid": { * "creation_number": "7", * "account_address": "0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90" * }, * "sequence_number": "0", * "type": "0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90::packet_event::InboundEvent", * "data": { * "packet": { * "dst_address": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa", * "dst_chain_id": "108", * "nonce": "1", * "payload": "0x00000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4857203756ea4273c43f583acd5b7a72aa168098da3fb9ffe4f6505515aae8fc9b0000000002faf080", * "src_address": "0x50002cdfe7ccb0c41f519c6eb0653158d11cd907", * "src_chain_id": "101" * } * } * }, * { * "version": "2617627", * "guid": { * "creation_number": "7", * "account_address": "0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90" * }, * "sequence_number": "1", * "type": "0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90::packet_event::InboundEvent", * "data": { * "packet": { * "dst_address": "0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa", * "dst_chain_id": "108", * "nonce": "2", * "payload": "0x00000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7495f9f30a60c7cda8a60937b4281d00d8730596409820bbf59b2674624c76d9b00000000000f4240", * "src_address": "0x50002cdfe7ccb0c41f519c6eb0653158d11cd907", * "src_chain_id": "101" * } * } * } * ] */ getInboundEvents(start: bigint, limit: number): Promise<aptos.Types.VersionedEvent[]>; /** * Returns the count of inbound events. * * @returns {Promise<number>} The count of inbound events. * @throws {Error} If sdk accounts layerzero is undefined. */ getInboundEventCount(): Promise<number>; /** * Returns an array of VersionedEvent objects for outbound events. * * @param {bigint} start - The start index of the events, starting from 0. * @param {number} limit - The maximum number of events to return. * @returns {Promise<aptos.Types.VersionedEvent[]>} An array of VersionedEvent objects. * @throws {Error} If sdk accounts layerzero is undefined. * @example * [ * { * version: '3290647', * guid: { * creation_number: '8', * account_address: '0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90' * }, * sequence_number: '0', * type: '0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90::packet_event::OutboundEvent', * data: { * encoded_packet: '0x0000000000000001006cf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa006f86bb63148d17d445ed5398ef26aa05bf76dd5b59010000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c316070000000000000000000000003a983ffaa79e2d12ef94b50f68346a4b9c653a9a00000000001e848000' * } * }, * { * version: '3308828', * guid: { * creation_number: '8', * account_address: '0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90' * }, * sequence_number: '1', * type: '0x54ad3d30af77b60d939ae356e6606de9a4da67583f02b962d2d3f2e481484e90::packet_event::OutboundEvent', * data: { * encoded_packet: '0x0000000000000001006cf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa006aa5972eee0c9b5bbb89a5b16d1d65f94c9ef25166010000000000000000000000009702230a8ea53601f5cd2dc00fdbc13d4df4a8c700000000000000000000000015028e41c7ed391674505f6ea1213045571564e4000000000000006400' * } * } * ] */ getOutboundEvents(start: bigint, limit: number): Promise<aptos.Types.VersionedEvent[]>; /** * Returns the count of outbound events. * * @returns {Promise<number>} The count of outbound events. * @throws {Error} If sdk accounts layerzero is undefined. */ getOutboundEventCount(): Promise<number>; } declare class UlnConfig { private sdk; /** * Oracle type identifier. */ TYPE_ORACLE: number; /** * Relayer type identifier. */ TYPE_RELAYER: number; /** * Inbound confirmations type identifier. */ TYPE_INBOUND_CONFIRMATIONS: number; /** * Outbound confirmations type identifier. */ TYPE_OUTBOUND_CONFIRMATIONS: number; /** * The module name. */ readonly module: string; /** * The module name with namespace. */ readonly moduleName: string; /** * Creates an instance of the UlnConfig class. * * @param {SDK} sdk - The SDK instance. */ constructor(sdk: SDK); /** * Creates a payload for setting the default app configuration. * * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {UlnConfigType} config - The configuration. * @returns {aptos.Types.EntryFunctionPayload} The payload. */ setDefaultAppConfigPayload(remoteChainId: aptos.BCS.Uint16, config: UlnConfigType): aptos.Types.EntryFunctionPayload; /** * Sets the default app configuration. * * @param {aptos.AptosAccount} signer - The signer account. * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {UlnConfigType} config - The configuration. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ setDefaultAppConfig(signer: aptos.AptosAccount, remoteChainId: aptos.BCS.Uint16, config: UlnConfigType): Promise<aptos.Types.Transaction>; /** * Creates a payload for setting the chain address size. * * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {aptos.BCS.Uint8} addressSize - The address size. * @returns {aptos.Types.EntryFunctionPayload} The payload. */ setChainAddressSizePayload(remoteChainId: aptos.BCS.Uint16, addressSize: aptos.BCS.Uint8): aptos.Types.EntryFunctionPayload; /** * Sets the chain address size. * * @param {aptos.AptosAccount} signer - The signer account. * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {aptos.BCS.Uint8} addressSize - The address size. * @returns {Promise<aptos.Types.Transaction>} A promise that resolves to the transaction. */ setChainAddressSize(signer: aptos.AptosAccount, remoteChainId: aptos.BCS.Uint16, addressSize: aptos.BCS.Uint8): Promise<aptos.Types.Transaction>; /** * Gets the chain address size for a given remote chain ID. * * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @returns {Promise<aptos.BCS.Uint8>} A promise that resolves to the address size. * @throws {Error} If the SDK accounts layerzero is undefined. */ getChainAddressSize(remoteChainId: aptos.BCS.Uint16): Promise<aptos.BCS.Uint8>; /** * Gets the default app configuration for a given remote chain ID. * * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {object} [query] - Optional query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<UlnConfigType>} A promise that resolves to the configuration. * @throws {Error} If the SDK accounts layerzero is undefined. */ getDefaultAppConfig(remoteChainId: aptos.BCS.Uint16, query?: { ledgerVersion?: bigint | number; }): Promise<UlnConfigType>; /** * Gets the app configuration for a given user address and remote chain ID. * * @param {aptos.MaybeHexString} uaAddress - The user address. * @param {aptos.BCS.Uint16} remoteChainId - The remote chain ID. * @param {object} [query] - Optional query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<UlnConfigType>} A promise that resolves to the configuration. * @throws {Error} If the SDK accounts layerzero is undefined. */ getAppConfig(uaAddress: aptos.MaybeHexString, remoteChainId: aptos.BCS.Uint16, query?: { ledgerVersion?: bigint | number; }): Promise<UlnConfigType>; /** * Merges the given configuration with the default configuration. * * @param {UlnConfigType} config - The configuration. * @param {UlnConfigType} defaultConfig - The default configuration. * @returns {UlnConfigType} The merged configuration. */ private mergeConfig; /** * Quotes the fee for a given user address, destination chain ID, and payload size. * * @param {aptos.MaybeHexString} uaAddress - The user address. * @param {aptos.BCS.Uint16} dstChainId - The destination chain ID. * @param {number} payloadSize - The payload size. * @param {object} [query] - Optional query parameters. * @param {bigint | number} [query.ledgerVersion] - The ledger version. * @returns {Promise<aptos.BCS.Uint64>} A promise that resolves to the fee. * @throws {Error} If the SDK accounts layerzero is undefined. */ quoteFee(uaAddress: aptos.MaybeHexString, dstChainId: aptos.BCS.Uint16, payloadSize: number, query?: { ledgerVersion?: bigint | number; }): Promise<aptos.BCS.Uint64>; } /** * The zero address in hex string format. */ declare const ZERO_ADDRESS_HEX: string; /** * The zero address in byte array format. */ declare const ZERO_ADDRESS_BYTES: Uint8Array; /** * The gas limit safety basis points. */ declare const GAS_LIMIT_SAFETY_BPS = 2000; /** * Encodes a packet into a buffer. * * @param {Packet} packet - The packet to encode. * @returns {Buffer} The encoded packet. */ declare function encodePacket(packet: Packet): Buffer; /** * Computes the GUID for a packet. * * @param {Packet} packet - The packet. * @returns {string} The computed GUID. */ declare function computeGuid(packet: Packet): string; type GetAddressSizeOfChainFunc = (chainId: number) => Promise<number>; /** * decode the packet generated on the Aptos chain only, it assumes that the size of the source address is 32 * * @param {Buffer} buf - The buffer containing the encoded packet. * @param {number | GetAddressSizeOfChainFunc} getAddressSizeOfChain - A number or a function to return the size of the destination address. * @returns {Promise<Packet>} The decoded packet. */ declare function decodePacket(buf: Buffer, getAddressSizeOfChain: number | GetAddressSizeOfChainFunc): Promise<Packet>; /** * Decodes an encoded packet string. * * @param {string} encodedPacket - The encoded packet string. * @param {number} dstAddressSize - The size of the destination address. * @returns {Promise<Packet>} The decoded packet. */ declare function decodePacketString(encodedPacket: string, dstAddressSize: number): Promise<Packet>; /** * Computes the SHA3-256 hash of a buffer. * * @param {Buffer} buf - The buffer to hash. * @returns {string} The hash of the buffer. */ declare function hashBuffer(buf: Buffer): string; /** * Computes the hash of a packet. * * @param {Packet} packet - The packet to hash. * @returns {string} The hash of the packet. */ declare function hashPacket(packet: Packet): string; /** * Rebuilds a packet from an event. * * @param {aptos.Types.Event} event - The event. * @param {GetAddressSizeOfChainFunc | number} getAddressSizeOfChain - A function or number to get the address size of the chain. * @returns {Promise<Packet>} The rebuilt packet. */ declare function rebuildPacketFromEvent(event: aptos.Types.Event, getAddressSizeOfChain: GetAddressSizeOfChainFunc | number): Promise<Packet>; /** * Generates a multisig public key and address. * * @param {Uint8Array[]} publicKeys - The public keys. * @param {number} threshold - The threshold. * @returns {Promise<[aptos.TxnBuilderTypes.MultiEd25519PublicKey, string]>} The multisig public key and address. */ declare function generateMultisig(publicKeys: Uint8Array[], threshold: number): Promise<[aptos.TxnBuilderTypes.MultiEd25519PublicKey, string]>; /** * Signs a BCS transaction with multiple signatures. * * @param {aptos.TxnBuilderTypes.MultiEd25519PublicKey} pubkey - The multisig public key. * @param {aptos.TxnBuilderTypes.RawTransaction} rawTx - The raw transaction. * @param {aptos.HexString[]} signatures - The signatures. * @param {number[]} bitmap - The bitmap. * @returns {aptos.BCS.Bytes} The signed BCS transaction. */ declare function multiSigSignedBCSTxn(pubkey: aptos.TxnBuilderTypes.MultiEd25519PublicKey, rawTx: aptos.TxnBuilderTypes.RawTransaction, signatures: aptos.HexString[], bitmap: number[]): aptos.BCS.Bytes; /** * Ensures the full address format. * * @param {string | aptos.H