UNPKG

supra-l1-sdk-core

Version:

Core of the Supra-L1-SDK

1,542 lines (1,413 loc) 111 kB
import nacl from 'tweetnacl'; /** * All bytes (Vec<u8>) data is represented as hex-encoded string prefixed with `0x` and fulfilled with * two hex digits per byte. * * Unlike the `Address` type, HexEncodedBytes will not trim any zeros. * */ type HexEncodedBytes = string; /** * A string containing a 64-bit unsigned integer. * * We represent u64 values as a string to ensure compatibility with languages such * as JavaScript that do not parse u64s in JSON natively. * */ type U64 = string; /** * Account data * * A simplified version of the onchain Account resource */ type AccountData = { sequence_number: U64; authentication_key: HexEncodedBytes; }; /** * A single Ed25519 signature */ type Ed25519Signature$1 = { public_key: HexEncodedBytes; signature: HexEncodedBytes; }; type AccountSignature_Ed25519Signature = ({ type: string; } & Ed25519Signature$1); /** * A Ed25519 multi-sig signature * * This allows k-of-n signing for a transaction */ type MultiEd25519Signature$1 = { /** * The public keys for the Ed25519 signature */ public_keys: Array<HexEncodedBytes>; /** * Signature associated with the public keys in the same order */ signatures: Array<HexEncodedBytes>; /** * The number of signatures required for a successful transaction */ threshold: number; bitmap: HexEncodedBytes; }; type AccountSignature_MultiEd25519Signature = ({ type: string; } & MultiEd25519Signature$1); type Ed25519 = { value: HexEncodedBytes; }; type Signature_Ed25519 = ({ type: string; } & Ed25519); type Keyless = { value: HexEncodedBytes; }; type Signature_Keyless = ({ type: string; } & Keyless); type Secp256k1Ecdsa = { value: HexEncodedBytes; }; type Signature_Secp256k1Ecdsa = ({ type: string; } & Secp256k1Ecdsa); type WebAuthn = { value: HexEncodedBytes; }; type Signature_WebAuthn = ({ type: string; } & WebAuthn); type Signature = (Signature_Ed25519 | Signature_Secp256k1Ecdsa | Signature_WebAuthn | Signature_Keyless); type IndexedSignature = { index: number; signature: Signature; }; type PublicKey_Ed25519 = ({ type: string; } & Ed25519); type PublicKey_Keyless = ({ type: string; } & Keyless); type PublicKey_Secp256k1Ecdsa = ({ type: string; } & Secp256k1Ecdsa); type Secp256r1Ecdsa = { value: HexEncodedBytes; }; type PublicKey_Secp256r1Ecdsa = ({ type: string; } & Secp256r1Ecdsa); type PublicKey = (PublicKey_Ed25519 | PublicKey_Secp256k1Ecdsa | PublicKey_Secp256r1Ecdsa | PublicKey_Keyless); /** * A multi key signature */ type MultiKeySignature = { public_keys: Array<PublicKey>; signatures: Array<IndexedSignature>; signatures_required: number; }; type AccountSignature_MultiKeySignature = ({ type: string; } & MultiKeySignature); /** * A single key signature */ type SingleKeySignature = { public_key: PublicKey; signature: Signature; }; type AccountSignature_SingleKeySignature = ({ type: string; } & SingleKeySignature); /** * Account signature scheme * * The account signature scheme allows you to have two types of accounts: * * 1. A single Ed25519 key account, one private key * 2. A k-of-n multi-Ed25519 key account, multiple private keys, such that k-of-n must sign a transaction. * 3. A single Secp256k1Ecdsa key account, one private key */ type AccountSignature = (AccountSignature_Ed25519Signature | AccountSignature_MultiEd25519Signature | AccountSignature_SingleKeySignature | AccountSignature_MultiKeySignature); /** * A hex encoded 32 byte Aptos account address. * * This is represented in a string as a 64 character hex string, sometimes * shortened by stripping leading 0s, and adding a 0x. * * For example, address 0x0000000000000000000000000000000000000000000000000000000000000001 is represented as 0x1. * */ type Address = string; /** * These codes provide more granular error information beyond just the HTTP * status code of the response. */ declare enum AptosErrorCode { ACCOUNT_NOT_FOUND = "account_not_found", RESOURCE_NOT_FOUND = "resource_not_found", MODULE_NOT_FOUND = "module_not_found", STRUCT_FIELD_NOT_FOUND = "struct_field_not_found", VERSION_NOT_FOUND = "version_not_found", TRANSACTION_NOT_FOUND = "transaction_not_found", TABLE_ITEM_NOT_FOUND = "table_item_not_found", BLOCK_NOT_FOUND = "block_not_found", STATE_VALUE_NOT_FOUND = "state_value_not_found", VERSION_PRUNED = "version_pruned", BLOCK_PRUNED = "block_pruned", INVALID_INPUT = "invalid_input", INVALID_TRANSACTION_UPDATE = "invalid_transaction_update", SEQUENCE_NUMBER_TOO_OLD = "sequence_number_too_old", VM_ERROR = "vm_error", HEALTH_CHECK_FAILED = "health_check_failed", MEMPOOL_IS_FULL = "mempool_is_full", INTERNAL_ERROR = "internal_error", WEB_FRAMEWORK_ERROR = "web_framework_error", BCS_NOT_SUPPORTED = "bcs_not_supported", API_DISABLED = "api_disabled" } /** * This is the generic struct we use for all API errors, it contains a string * message and an Aptos API specific error code. */ type AptosError = { /** * A message describing the error */ message: string; error_code: AptosErrorCode; /** * A code providing VM error details when submitting transactions to the VM */ vm_error_code?: number; }; type HashValue = string; type BlockEndInfo = { block_gas_limit_reached: boolean; block_output_limit_reached: boolean; block_effective_block_gas_units: number; block_approx_output_size: number; }; /** * Move module id is a string representation of Move module. * * Format: `{address}::{module name}` * * `address` should be hex-encoded 32 byte account address that is prefixed with `0x`. * * Module name is case-sensitive. * */ type MoveModuleId = string; /** * Delete a module */ type DeleteModule = { address: Address; /** * State key hash */ state_key_hash: string; module: MoveModuleId; }; type WriteSetChange_DeleteModule = ({ type: string; } & DeleteModule); /** * String representation of a MoveStructTag (on-chain Move struct type). This exists so you * can specify MoveStructTags as path / query parameters, e.g. for get_events_by_event_handle. * * It is a combination of: * 1. `move_module_address`, `module_name` and `struct_name`, all joined by `::` * 2. `struct generic type parameters` joined by `, ` * * Examples: * * `0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>` * * `0x1::account::Account` * * Note: * 1. Empty chars should be ignored when comparing 2 struct tag ids. * 2. When used in an URL path, should be encoded by url-encoding (AKA percent-encoding). * * See [doc](https://aptos.dev/concepts/accounts) for more details. * */ type MoveStructTag = string; /** * Delete a resource */ type DeleteResource = { address: Address; /** * State key hash */ state_key_hash: string; resource: MoveStructTag; }; type WriteSetChange_DeleteResource = ({ type: string; } & DeleteResource); /** * Deleted table data */ type DeletedTableData = { /** * Deleted key */ key: any; /** * Deleted key type */ key_type: string; }; /** * Delete a table item */ type DeleteTableItem = { state_key_hash: string; handle: HexEncodedBytes; key: HexEncodedBytes; data?: DeletedTableData; }; type WriteSetChange_DeleteTableItem = ({ type: string; } & DeleteTableItem); type IdentifierWrapper = string; type MoveAbility = string; /** * Move function generic type param */ type MoveFunctionGenericTypeParam = { /** * Move abilities tied to the generic type param and associated with the function that uses it */ constraints: Array<MoveAbility>; }; /** * Move function visibility */ declare enum MoveFunctionVisibility { PRIVATE = "private", PUBLIC = "public", FRIEND = "friend" } /** * String representation of an on-chain Move type tag that is exposed in transaction payload. * Values: * - bool * - u8 * - u16 * - u32 * - u64 * - u128 * - u256 * - address * - signer * - vector: `vector<{non-reference MoveTypeId}>` * - struct: `{address}::{module_name}::{struct_name}::<{generic types}>` * * Vector type value examples: * - `vector<u8>` * - `vector<vector<u64>>` * - `vector<0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin>>` * * Struct type value examples: * - `0x1::coin::CoinStore<0x1::aptos_coin::AptosCoin> * - `0x1::account::Account` * * Note: * 1. Empty chars should be ignored when comparing 2 struct tag ids. * 2. When used in an URL path, should be encoded by url-encoding (AKA percent-encoding). * */ type MoveType = string; /** * Move function */ type MoveFunction = { name: IdentifierWrapper; visibility: MoveFunctionVisibility; /** * Whether the function can be called as an entry function directly in a transaction */ is_entry: boolean; /** * Whether the function is a view function or not */ is_view: boolean; /** * Generic type params associated with the Move function */ generic_type_params: Array<MoveFunctionGenericTypeParam>; /** * Parameters associated with the move function */ params: Array<MoveType>; /** * Return type of the function */ return: Array<MoveType>; }; /** * Move struct field */ type MoveStructField = { name: IdentifierWrapper; type: MoveType; }; /** * Move generic type param */ type MoveStructGenericTypeParam = { /** * Move abilities tied to the generic type param and associated with the type that uses it */ constraints: Array<MoveAbility>; }; /** * A move struct */ type MoveStruct = { name: IdentifierWrapper; /** * Whether the struct is a native struct of Move */ is_native: boolean; /** * Abilities associated with the struct */ abilities: Array<MoveAbility>; /** * Generic types associated with the struct */ generic_type_params: Array<MoveStructGenericTypeParam>; /** * Fields associated with the struct */ fields: Array<MoveStructField>; }; /** * A Move module */ type MoveModule = { address: Address; name: IdentifierWrapper; /** * Friends of the module */ friends: Array<MoveModuleId>; /** * Public functions of the module */ exposed_functions: Array<MoveFunction>; /** * Structs of the module */ structs: Array<MoveStruct>; }; /** * Move module bytecode along with it's ABI */ type MoveModuleBytecode = { bytecode: HexEncodedBytes; abi?: MoveModule; }; /** * Write a new module or update an existing one */ type WriteModule = { address: Address; /** * State key hash */ state_key_hash: string; data: MoveModuleBytecode; }; type WriteSetChange_WriteModule = ({ type: string; } & WriteModule); /** * This is a JSON representation of some data within an account resource. More specifically, * it is a map of strings to arbitrary JSON values / objects, where the keys are top level * fields within the given resource. * * To clarify, you might query for 0x1::account::Account and see the example data. * * Move `bool` type value is serialized into `boolean`. * * Move `u8`, `u16` and `u32` type value is serialized into `integer`. * * Move `u64`, `u128` and `u256` type value is serialized into `string`. * * Move `address` type value (32 byte Aptos account address) is serialized into a HexEncodedBytes string. * For example: * - `0x1` * - `0x1668f6be25668c1a17cd8caf6b8d2f25` * * Move `vector` type value is serialized into `array`, except `vector<u8>` which is serialized into a * HexEncodedBytes string with `0x` prefix. * For example: * - `vector<u64>{255, 255}` => `["255", "255"]` * - `vector<u8>{255, 255}` => `0xffff` * * Move `struct` type value is serialized into `object` that looks like this (except some Move stdlib types, see the following section): * ```json * { * field1_name: field1_value, * field2_name: field2_value, * ...... * } * ``` * * For example: * `{ "created": "0xa550c18", "role_id": "0" }` * * **Special serialization for Move stdlib types**: * - [0x1::string::String](https://github.com/aptos-labs/aptos-core/blob/main/language/move-stdlib/docs/ascii.md) * is serialized into `string`. For example, struct value `0x1::string::String{bytes: b"Hello World!"}` * is serialized as `"Hello World!"` in JSON. * */ type MoveStructValue = {}; /** * A parsed Move resource */ type MoveResource = { type: MoveStructTag; data: MoveStructValue; }; /** * Write a resource or update an existing one */ type WriteResource = { address: Address; /** * State key hash */ state_key_hash: string; data: MoveResource; }; type WriteSetChange_WriteResource = ({ type: string; } & WriteResource); /** * Decoded table data */ type DecodedTableData = { /** * Key of table in JSON */ key: any; /** * Type of key */ key_type: string; /** * Value of table in JSON */ value: any; /** * Type of value */ value_type: string; }; /** * Change set to write a table item */ type WriteTableItem = { state_key_hash: string; handle: HexEncodedBytes; key: HexEncodedBytes; value: HexEncodedBytes; data?: DecodedTableData; }; type WriteSetChange_WriteTableItem = ({ type: string; } & WriteTableItem); /** * A final state change of a transaction on a resource or module */ type WriteSetChange = (WriteSetChange_DeleteModule | WriteSetChange_DeleteResource | WriteSetChange_DeleteTableItem | WriteSetChange_WriteModule | WriteSetChange_WriteResource | WriteSetChange_WriteTableItem); /** * A block epilogue transaction */ type BlockEpilogueTransaction = { version: U64; hash: HashValue; state_change_hash: HashValue; event_root_hash: HashValue; state_checkpoint_hash?: HashValue; gas_used: U64; /** * Whether the transaction was successful */ success: boolean; /** * The VM status of the transaction, can tell useful information in a failure */ vm_status: string; accumulator_root_hash: HashValue; /** * Final state of resources changed by the transaction */ changes: Array<WriteSetChange>; timestamp: U64; block_end_info?: BlockEndInfo; }; type Transaction_BlockEpilogueTransaction = ({ type: string; } & BlockEpilogueTransaction); type EventGuid = { creation_number: U64; account_address: Address; }; /** * An event from a transaction */ type Event = { guid: EventGuid; sequence_number: U64; type: MoveType; /** * The JSON representation of the event */ data: any; }; /** * A block metadata transaction * * This signifies the beginning of a block, and contains information * about the specific block */ type BlockMetadataTransaction = { version: U64; hash: HashValue; state_change_hash: HashValue; event_root_hash: HashValue; state_checkpoint_hash?: HashValue; gas_used: U64; /** * Whether the transaction was successful */ success: boolean; /** * The VM status of the transaction, can tell useful information in a failure */ vm_status: string; accumulator_root_hash: HashValue; /** * Final state of resources changed by the transaction */ changes: Array<WriteSetChange>; id: HashValue; epoch: U64; round: U64; /** * The events emitted at the block creation */ events: Array<Event>; /** * Previous block votes */ previous_block_votes_bitvec: Array<number>; proposer: Address; /** * The indices of the proposers who failed to propose */ failed_proposer_indices: Array<number>; timestamp: U64; }; type Transaction_BlockMetadataTransaction = ({ type: string; } & BlockMetadataTransaction); type DirectWriteSet = { changes: Array<WriteSetChange>; events: Array<Event>; }; type WriteSet_DirectWriteSet = ({ type: string; } & DirectWriteSet); /** * Move script bytecode */ type MoveScriptBytecode = { bytecode: HexEncodedBytes; abi?: MoveFunction; }; /** * Payload which runs a script that can run multiple functions */ type ScriptPayload = { code: MoveScriptBytecode; /** * Type arguments of the function */ type_arguments: Array<MoveType>; /** * Arguments of the function */ arguments: Array<any>; }; type ScriptWriteSet = { execute_as: Address; script: ScriptPayload; }; type WriteSet_ScriptWriteSet = ({ type: string; } & ScriptWriteSet); /** * The associated writeset with a payload */ type WriteSet$1 = (WriteSet_ScriptWriteSet | WriteSet_DirectWriteSet); /** * A writeset payload, used only for genesis */ type WriteSetPayload = { write_set: WriteSet$1; }; type GenesisPayload_WriteSetPayload = ({ type: string; } & WriteSetPayload); /** * The writeset payload of the Genesis transaction */ type GenesisPayload = GenesisPayload_WriteSetPayload; /** * The genesis transaction * * This only occurs at the genesis transaction (version 0) */ type GenesisTransaction = { version: U64; hash: HashValue; state_change_hash: HashValue; event_root_hash: HashValue; state_checkpoint_hash?: HashValue; gas_used: U64; /** * Whether the transaction was successful */ success: boolean; /** * The VM status of the transaction, can tell useful information in a failure */ vm_status: string; accumulator_root_hash: HashValue; /** * Final state of resources changed by the transaction */ changes: Array<WriteSetChange>; payload: GenesisPayload; /** * Events emitted during genesis */ events: Array<Event>; }; type Transaction_GenesisTransaction = ({ type: string; } & GenesisTransaction); type DeprecatedModuleBundlePayload = {}; type TransactionPayload_DeprecatedModuleBundlePayload = ({ type: string; } & DeprecatedModuleBundlePayload); /** * Entry function id is string representation of a entry function defined on-chain. * * Format: `{address}::{module name}::{function name}` * * Both `module name` and `function name` are case-sensitive. * */ type EntryFunctionId = string; /** * Payload which runs a single entry function */ type EntryFunctionPayload = { function: EntryFunctionId; /** * Type arguments of the function */ type_arguments: Array<MoveType>; /** * Arguments of the function */ arguments: Array<any>; }; type TransactionPayload_EntryFunctionPayload = ({ type: string; } & EntryFunctionPayload); type MultisigTransactionPayload_EntryFunctionPayload = ({ type: string; } & EntryFunctionPayload); type MultisigTransactionPayload = MultisigTransactionPayload_EntryFunctionPayload; /** * A multisig transaction that allows an owner of a multisig account to execute a pre-approved * transaction as the multisig account. */ type MultisigPayload = { multisig_address: Address; transaction_payload?: MultisigTransactionPayload; }; type TransactionPayload_MultisigPayload = ({ type: string; } & MultisigPayload); type TransactionPayload_ScriptPayload = ({ type: string; } & ScriptPayload); /** * An enum of the possible transaction payloads */ type TransactionPayload$1 = (TransactionPayload_EntryFunctionPayload | TransactionPayload_ScriptPayload | TransactionPayload_DeprecatedModuleBundlePayload | TransactionPayload_MultisigPayload); type TransactionSignature_AccountSignature = ({ type: string; } & AccountSignature); type TransactionSignature_Ed25519Signature = ({ type: string; } & Ed25519Signature$1); /** * Fee payer signature for fee payer transactions * * This allows you to have transactions across multiple accounts and with a fee payer */ type FeePayerSignature = { sender: AccountSignature; /** * The other involved parties' addresses */ secondary_signer_addresses: Array<Address>; /** * The associated signatures, in the same order as the secondary addresses */ secondary_signers: Array<AccountSignature>; fee_payer_address: Address; fee_payer_signer: AccountSignature; }; type TransactionSignature_FeePayerSignature = ({ type: string; } & FeePayerSignature); /** * Multi agent signature for multi agent transactions * * This allows you to have transactions across multiple accounts */ type MultiAgentSignature = { sender: AccountSignature; /** * The other involved parties' addresses */ secondary_signer_addresses: Array<Address>; /** * The associated signatures, in the same order as the secondary addresses */ secondary_signers: Array<AccountSignature>; }; type TransactionSignature_MultiAgentSignature = ({ type: string; } & MultiAgentSignature); type TransactionSignature_MultiEd25519Signature = ({ type: string; } & MultiEd25519Signature$1); /** * An enum representing the different transaction signatures available */ type TransactionSignature = (TransactionSignature_Ed25519Signature | TransactionSignature_MultiEd25519Signature | TransactionSignature_MultiAgentSignature | TransactionSignature_FeePayerSignature | TransactionSignature_AccountSignature); /** * A transaction waiting in mempool */ type PendingTransaction = { hash: HashValue; sender: Address; sequence_number: U64; max_gas_amount: U64; gas_unit_price: U64; expiration_timestamp_secs: U64; payload: TransactionPayload$1; signature?: TransactionSignature; }; type Transaction_PendingTransaction = ({ type: string; } & PendingTransaction); /** * A state checkpoint transaction */ type StateCheckpointTransaction = { version: U64; hash: HashValue; state_change_hash: HashValue; event_root_hash: HashValue; state_checkpoint_hash?: HashValue; gas_used: U64; /** * Whether the transaction was successful */ success: boolean; /** * The VM status of the transaction, can tell useful information in a failure */ vm_status: string; accumulator_root_hash: HashValue; /** * Final state of resources changed by the transaction */ changes: Array<WriteSetChange>; timestamp: U64; }; type Transaction_StateCheckpointTransaction = ({ type: string; } & StateCheckpointTransaction); /** * A transaction submitted by a user to change the state of the blockchain */ type UserTransaction$1 = { version: U64; hash: HashValue; state_change_hash: HashValue; event_root_hash: HashValue; state_checkpoint_hash?: HashValue; gas_used: U64; /** * Whether the transaction was successful */ success: boolean; /** * The VM status of the transaction, can tell useful information in a failure */ vm_status: string; accumulator_root_hash: HashValue; /** * Final state of resources changed by the transaction */ changes: Array<WriteSetChange>; sender: Address; sequence_number: U64; max_gas_amount: U64; gas_unit_price: U64; expiration_timestamp_secs: U64; payload: TransactionPayload$1; signature?: TransactionSignature; /** * Events generated by the transaction */ events: Array<Event>; timestamp: U64; }; type Transaction_UserTransaction = ({ type: string; } & UserTransaction$1); type ValidatorTransaction = { version: U64; hash: HashValue; state_change_hash: HashValue; event_root_hash: HashValue; state_checkpoint_hash?: HashValue; gas_used: U64; /** * Whether the transaction was successful */ success: boolean; /** * The VM status of the transaction, can tell useful information in a failure */ vm_status: string; accumulator_root_hash: HashValue; /** * Final state of resources changed by the transaction */ changes: Array<WriteSetChange>; events: Array<Event>; timestamp: U64; }; type Transaction_ValidatorTransaction = ({ type: string; } & ValidatorTransaction); /** * Enum of the different types of transactions in Aptos */ type Transaction$1 = (Transaction_PendingTransaction | Transaction_UserTransaction | Transaction_GenesisTransaction | Transaction_BlockMetadataTransaction | Transaction_StateCheckpointTransaction | Transaction_BlockEpilogueTransaction | Transaction_ValidatorTransaction); /** * A Block with or without transactions * * This contains the information about a transactions along with * associated transactions if requested */ type Block = { block_height: U64; block_hash: HashValue; block_timestamp: U64; first_version: U64; last_version: U64; /** * The transactions in the block in sequential order */ transactions?: Array<Transaction$1>; }; /** * Request to encode a submission */ type EncodeSubmissionRequest = { sender: Address; sequence_number: U64; max_gas_amount: U64; gas_unit_price: U64; expiration_timestamp_secs: U64; payload: TransactionPayload$1; /** * Secondary signer accounts of the request for Multi-agent */ secondary_signers?: Array<Address>; }; /** * Struct holding the outputs of the estimate gas API */ type GasEstimation = { /** * The deprioritized estimate for the gas unit price */ deprioritized_gas_estimate?: number; /** * The current estimate for the gas unit price */ gas_estimate: number; /** * The prioritized estimate for the gas unit price */ prioritized_gas_estimate?: number; }; /** * Representation of a successful healthcheck */ type HealthCheckSuccess = { message: string; }; declare enum RoleType { VALIDATOR = "validator", FULL_NODE = "full_node" } /** * The struct holding all data returned to the client by the * index endpoint (i.e., GET "/"). Only for responding in JSON */ type IndexResponse = { /** * Chain ID of the current chain */ chain_id: number; epoch: U64; ledger_version: U64; oldest_ledger_version: U64; ledger_timestamp: U64; node_role: RoleType; oldest_block_height: U64; block_height: U64; /** * Git hash of the build of the API endpoint. Can be used to determine the exact * software version used by the API endpoint. */ git_hash?: string; }; /** * A string containing a 128-bit unsigned integer. * * We represent u128 values as a string to ensure compatibility with languages such * as JavaScript that do not parse u128s in JSON natively. * */ type U128 = string; /** * A string containing a 256-bit unsigned integer. * * We represent u256 values as a string to ensure compatibility with languages such * as JavaScript that do not parse u256s in JSON natively. * */ type U256 = string; /** * An enum of the possible Move value types */ type MoveValue = (number | U64 | U128 | U256 | boolean | Address | Array<MoveValue> | HexEncodedBytes | MoveStructValue | string); /** * Table Item request for the GetTableItemRaw API */ type RawTableItemRequest = { key: HexEncodedBytes; }; /** * Representation of a StateKey as a hex string. This is used for cursor based pagination. * */ type StateKeyWrapper = string; /** * A request to submit a transaction * * This requires a transaction and a signature of it */ type SubmitTransactionRequest = { sender: Address; sequence_number: U64; max_gas_amount: U64; gas_unit_price: U64; expiration_timestamp_secs: U64; payload: TransactionPayload$1; signature: TransactionSignature; }; /** * Table Item request for the GetTableItem API */ type TableItemRequest = { key_type: MoveType; value_type: MoveType; /** * The value of the table item's key */ key: any; }; /** * Information telling which batch submission transactions failed */ type TransactionsBatchSingleSubmissionFailure = { error: AptosError; /** * The index of which transaction failed, same as submission order */ transaction_index: number; }; /** * Batch transaction submission result * * Tells which transactions failed */ type TransactionsBatchSubmissionResult = { /** * Summary of the failed transactions */ transaction_failures: Array<TransactionsBatchSingleSubmissionFailure>; }; /** * An event from a transaction with a version */ type VersionedEvent = { version: U64; guid: EventGuid; sequence_number: U64; type: MoveType; /** * The JSON representation of the event */ data: any; }; /** * View request for the Move View Function API */ type ViewRequest = { function: EntryFunctionId; /** * Type arguments of the function */ type_arguments: Array<MoveType>; /** * Arguments of the function */ arguments: Array<any>; }; type index$2_AccountData = AccountData; type index$2_AccountSignature = AccountSignature; type index$2_AccountSignature_Ed25519Signature = AccountSignature_Ed25519Signature; type index$2_AccountSignature_MultiEd25519Signature = AccountSignature_MultiEd25519Signature; type index$2_AccountSignature_MultiKeySignature = AccountSignature_MultiKeySignature; type index$2_AccountSignature_SingleKeySignature = AccountSignature_SingleKeySignature; type index$2_Address = Address; type index$2_AptosError = AptosError; type index$2_AptosErrorCode = AptosErrorCode; declare const index$2_AptosErrorCode: typeof AptosErrorCode; type index$2_Block = Block; type index$2_BlockEndInfo = BlockEndInfo; type index$2_BlockEpilogueTransaction = BlockEpilogueTransaction; type index$2_BlockMetadataTransaction = BlockMetadataTransaction; type index$2_DecodedTableData = DecodedTableData; type index$2_DeleteModule = DeleteModule; type index$2_DeleteResource = DeleteResource; type index$2_DeleteTableItem = DeleteTableItem; type index$2_DeletedTableData = DeletedTableData; type index$2_DeprecatedModuleBundlePayload = DeprecatedModuleBundlePayload; type index$2_DirectWriteSet = DirectWriteSet; type index$2_Ed25519 = Ed25519; type index$2_EncodeSubmissionRequest = EncodeSubmissionRequest; type index$2_EntryFunctionId = EntryFunctionId; type index$2_EntryFunctionPayload = EntryFunctionPayload; type index$2_Event = Event; type index$2_EventGuid = EventGuid; type index$2_FeePayerSignature = FeePayerSignature; type index$2_GasEstimation = GasEstimation; type index$2_GenesisPayload = GenesisPayload; type index$2_GenesisPayload_WriteSetPayload = GenesisPayload_WriteSetPayload; type index$2_GenesisTransaction = GenesisTransaction; type index$2_HashValue = HashValue; type index$2_HealthCheckSuccess = HealthCheckSuccess; type index$2_HexEncodedBytes = HexEncodedBytes; type index$2_IdentifierWrapper = IdentifierWrapper; type index$2_IndexResponse = IndexResponse; type index$2_IndexedSignature = IndexedSignature; type index$2_Keyless = Keyless; type index$2_MoveAbility = MoveAbility; type index$2_MoveFunction = MoveFunction; type index$2_MoveFunctionGenericTypeParam = MoveFunctionGenericTypeParam; type index$2_MoveFunctionVisibility = MoveFunctionVisibility; declare const index$2_MoveFunctionVisibility: typeof MoveFunctionVisibility; type index$2_MoveModule = MoveModule; type index$2_MoveModuleBytecode = MoveModuleBytecode; type index$2_MoveModuleId = MoveModuleId; type index$2_MoveResource = MoveResource; type index$2_MoveScriptBytecode = MoveScriptBytecode; type index$2_MoveStruct = MoveStruct; type index$2_MoveStructField = MoveStructField; type index$2_MoveStructGenericTypeParam = MoveStructGenericTypeParam; type index$2_MoveStructTag = MoveStructTag; type index$2_MoveStructValue = MoveStructValue; type index$2_MoveType = MoveType; type index$2_MoveValue = MoveValue; type index$2_MultiAgentSignature = MultiAgentSignature; type index$2_MultiKeySignature = MultiKeySignature; type index$2_MultisigPayload = MultisigPayload; type index$2_MultisigTransactionPayload = MultisigTransactionPayload; type index$2_MultisigTransactionPayload_EntryFunctionPayload = MultisigTransactionPayload_EntryFunctionPayload; type index$2_PendingTransaction = PendingTransaction; type index$2_PublicKey = PublicKey; type index$2_PublicKey_Ed25519 = PublicKey_Ed25519; type index$2_PublicKey_Keyless = PublicKey_Keyless; type index$2_PublicKey_Secp256k1Ecdsa = PublicKey_Secp256k1Ecdsa; type index$2_PublicKey_Secp256r1Ecdsa = PublicKey_Secp256r1Ecdsa; type index$2_RawTableItemRequest = RawTableItemRequest; type index$2_RoleType = RoleType; declare const index$2_RoleType: typeof RoleType; type index$2_ScriptPayload = ScriptPayload; type index$2_ScriptWriteSet = ScriptWriteSet; type index$2_Secp256k1Ecdsa = Secp256k1Ecdsa; type index$2_Secp256r1Ecdsa = Secp256r1Ecdsa; type index$2_Signature = Signature; type index$2_Signature_Ed25519 = Signature_Ed25519; type index$2_Signature_Keyless = Signature_Keyless; type index$2_Signature_Secp256k1Ecdsa = Signature_Secp256k1Ecdsa; type index$2_Signature_WebAuthn = Signature_WebAuthn; type index$2_SingleKeySignature = SingleKeySignature; type index$2_StateCheckpointTransaction = StateCheckpointTransaction; type index$2_StateKeyWrapper = StateKeyWrapper; type index$2_SubmitTransactionRequest = SubmitTransactionRequest; type index$2_TableItemRequest = TableItemRequest; type index$2_TransactionPayload_DeprecatedModuleBundlePayload = TransactionPayload_DeprecatedModuleBundlePayload; type index$2_TransactionPayload_EntryFunctionPayload = TransactionPayload_EntryFunctionPayload; type index$2_TransactionPayload_MultisigPayload = TransactionPayload_MultisigPayload; type index$2_TransactionPayload_ScriptPayload = TransactionPayload_ScriptPayload; type index$2_TransactionSignature = TransactionSignature; type index$2_TransactionSignature_AccountSignature = TransactionSignature_AccountSignature; type index$2_TransactionSignature_Ed25519Signature = TransactionSignature_Ed25519Signature; type index$2_TransactionSignature_FeePayerSignature = TransactionSignature_FeePayerSignature; type index$2_TransactionSignature_MultiAgentSignature = TransactionSignature_MultiAgentSignature; type index$2_TransactionSignature_MultiEd25519Signature = TransactionSignature_MultiEd25519Signature; type index$2_Transaction_BlockEpilogueTransaction = Transaction_BlockEpilogueTransaction; type index$2_Transaction_BlockMetadataTransaction = Transaction_BlockMetadataTransaction; type index$2_Transaction_GenesisTransaction = Transaction_GenesisTransaction; type index$2_Transaction_PendingTransaction = Transaction_PendingTransaction; type index$2_Transaction_StateCheckpointTransaction = Transaction_StateCheckpointTransaction; type index$2_Transaction_UserTransaction = Transaction_UserTransaction; type index$2_Transaction_ValidatorTransaction = Transaction_ValidatorTransaction; type index$2_TransactionsBatchSingleSubmissionFailure = TransactionsBatchSingleSubmissionFailure; type index$2_TransactionsBatchSubmissionResult = TransactionsBatchSubmissionResult; type index$2_U128 = U128; type index$2_U256 = U256; type index$2_U64 = U64; type index$2_ValidatorTransaction = ValidatorTransaction; type index$2_VersionedEvent = VersionedEvent; type index$2_ViewRequest = ViewRequest; type index$2_WebAuthn = WebAuthn; type index$2_WriteModule = WriteModule; type index$2_WriteResource = WriteResource; type index$2_WriteSetChange = WriteSetChange; type index$2_WriteSetChange_DeleteModule = WriteSetChange_DeleteModule; type index$2_WriteSetChange_DeleteResource = WriteSetChange_DeleteResource; type index$2_WriteSetChange_DeleteTableItem = WriteSetChange_DeleteTableItem; type index$2_WriteSetChange_WriteModule = WriteSetChange_WriteModule; type index$2_WriteSetChange_WriteResource = WriteSetChange_WriteResource; type index$2_WriteSetChange_WriteTableItem = WriteSetChange_WriteTableItem; type index$2_WriteSetPayload = WriteSetPayload; type index$2_WriteSet_DirectWriteSet = WriteSet_DirectWriteSet; type index$2_WriteSet_ScriptWriteSet = WriteSet_ScriptWriteSet; type index$2_WriteTableItem = WriteTableItem; declare namespace index$2 { export { type index$2_AccountData as AccountData, type index$2_AccountSignature as AccountSignature, type index$2_AccountSignature_Ed25519Signature as AccountSignature_Ed25519Signature, type index$2_AccountSignature_MultiEd25519Signature as AccountSignature_MultiEd25519Signature, type index$2_AccountSignature_MultiKeySignature as AccountSignature_MultiKeySignature, type index$2_AccountSignature_SingleKeySignature as AccountSignature_SingleKeySignature, type index$2_Address as Address, type index$2_AptosError as AptosError, index$2_AptosErrorCode as AptosErrorCode, type index$2_Block as Block, type index$2_BlockEndInfo as BlockEndInfo, type index$2_BlockEpilogueTransaction as BlockEpilogueTransaction, type index$2_BlockMetadataTransaction as BlockMetadataTransaction, type index$2_DecodedTableData as DecodedTableData, type index$2_DeleteModule as DeleteModule, type index$2_DeleteResource as DeleteResource, type index$2_DeleteTableItem as DeleteTableItem, type index$2_DeletedTableData as DeletedTableData, type index$2_DeprecatedModuleBundlePayload as DeprecatedModuleBundlePayload, type index$2_DirectWriteSet as DirectWriteSet, type index$2_Ed25519 as Ed25519, type Ed25519Signature$1 as Ed25519Signature, type index$2_EncodeSubmissionRequest as EncodeSubmissionRequest, type index$2_EntryFunctionId as EntryFunctionId, type index$2_EntryFunctionPayload as EntryFunctionPayload, type index$2_Event as Event, type index$2_EventGuid as EventGuid, type index$2_FeePayerSignature as FeePayerSignature, type index$2_GasEstimation as GasEstimation, type index$2_GenesisPayload as GenesisPayload, type index$2_GenesisPayload_WriteSetPayload as GenesisPayload_WriteSetPayload, type index$2_GenesisTransaction as GenesisTransaction, type index$2_HashValue as HashValue, type index$2_HealthCheckSuccess as HealthCheckSuccess, type index$2_HexEncodedBytes as HexEncodedBytes, type index$2_IdentifierWrapper as IdentifierWrapper, type index$2_IndexResponse as IndexResponse, type index$2_IndexedSignature as IndexedSignature, type index$2_Keyless as Keyless, type index$2_MoveAbility as MoveAbility, type index$2_MoveFunction as MoveFunction, type index$2_MoveFunctionGenericTypeParam as MoveFunctionGenericTypeParam, index$2_MoveFunctionVisibility as MoveFunctionVisibility, type index$2_MoveModule as MoveModule, type index$2_MoveModuleBytecode as MoveModuleBytecode, type index$2_MoveModuleId as MoveModuleId, type index$2_MoveResource as MoveResource, type index$2_MoveScriptBytecode as MoveScriptBytecode, type index$2_MoveStruct as MoveStruct, type index$2_MoveStructField as MoveStructField, type index$2_MoveStructGenericTypeParam as MoveStructGenericTypeParam, type index$2_MoveStructTag as MoveStructTag, type index$2_MoveStructValue as MoveStructValue, type index$2_MoveType as MoveType, type index$2_MoveValue as MoveValue, type index$2_MultiAgentSignature as MultiAgentSignature, type MultiEd25519Signature$1 as MultiEd25519Signature, type index$2_MultiKeySignature as MultiKeySignature, type index$2_MultisigPayload as MultisigPayload, type index$2_MultisigTransactionPayload as MultisigTransactionPayload, type index$2_MultisigTransactionPayload_EntryFunctionPayload as MultisigTransactionPayload_EntryFunctionPayload, type index$2_PendingTransaction as PendingTransaction, type index$2_PublicKey as PublicKey, type index$2_PublicKey_Ed25519 as PublicKey_Ed25519, type index$2_PublicKey_Keyless as PublicKey_Keyless, type index$2_PublicKey_Secp256k1Ecdsa as PublicKey_Secp256k1Ecdsa, type index$2_PublicKey_Secp256r1Ecdsa as PublicKey_Secp256r1Ecdsa, type index$2_RawTableItemRequest as RawTableItemRequest, index$2_RoleType as RoleType, type index$2_ScriptPayload as ScriptPayload, type index$2_ScriptWriteSet as ScriptWriteSet, type index$2_Secp256k1Ecdsa as Secp256k1Ecdsa, type index$2_Secp256r1Ecdsa as Secp256r1Ecdsa, type index$2_Signature as Signature, type index$2_Signature_Ed25519 as Signature_Ed25519, type index$2_Signature_Keyless as Signature_Keyless, type index$2_Signature_Secp256k1Ecdsa as Signature_Secp256k1Ecdsa, type index$2_Signature_WebAuthn as Signature_WebAuthn, type index$2_SingleKeySignature as SingleKeySignature, type index$2_StateCheckpointTransaction as StateCheckpointTransaction, type index$2_StateKeyWrapper as StateKeyWrapper, type index$2_SubmitTransactionRequest as SubmitTransactionRequest, type index$2_TableItemRequest as TableItemRequest, type Transaction$1 as Transaction, type TransactionPayload$1 as TransactionPayload, type index$2_TransactionPayload_DeprecatedModuleBundlePayload as TransactionPayload_DeprecatedModuleBundlePayload, type index$2_TransactionPayload_EntryFunctionPayload as TransactionPayload_EntryFunctionPayload, type index$2_TransactionPayload_MultisigPayload as TransactionPayload_MultisigPayload, type index$2_TransactionPayload_ScriptPayload as TransactionPayload_ScriptPayload, type index$2_TransactionSignature as TransactionSignature, type index$2_TransactionSignature_AccountSignature as TransactionSignature_AccountSignature, type index$2_TransactionSignature_Ed25519Signature as TransactionSignature_Ed25519Signature, type index$2_TransactionSignature_FeePayerSignature as TransactionSignature_FeePayerSignature, type index$2_TransactionSignature_MultiAgentSignature as TransactionSignature_MultiAgentSignature, type index$2_TransactionSignature_MultiEd25519Signature as TransactionSignature_MultiEd25519Signature, type index$2_Transaction_BlockEpilogueTransaction as Transaction_BlockEpilogueTransaction, type index$2_Transaction_BlockMetadataTransaction as Transaction_BlockMetadataTransaction, type index$2_Transaction_GenesisTransaction as Transaction_GenesisTransaction, type index$2_Transaction_PendingTransaction as Transaction_PendingTransaction, type index$2_Transaction_StateCheckpointTransaction as Transaction_StateCheckpointTransaction, type index$2_Transaction_UserTransaction as Transaction_UserTransaction, type index$2_Transaction_ValidatorTransaction as Transaction_ValidatorTransaction, type index$2_TransactionsBatchSingleSubmissionFailure as TransactionsBatchSingleSubmissionFailure, type index$2_TransactionsBatchSubmissionResult as TransactionsBatchSubmissionResult, type index$2_U128 as U128, type index$2_U256 as U256, type index$2_U64 as U64, type UserTransaction$1 as UserTransaction, type index$2_ValidatorTransaction as ValidatorTransaction, type index$2_VersionedEvent as VersionedEvent, type index$2_ViewRequest as ViewRequest, type index$2_WebAuthn as WebAuthn, type index$2_WriteModule as WriteModule, type index$2_WriteResource as WriteResource, type WriteSet$1 as WriteSet, type index$2_WriteSetChange as WriteSetChange, type index$2_WriteSetChange_DeleteModule as WriteSetChange_DeleteModule, type index$2_WriteSetChange_DeleteResource as WriteSetChange_DeleteResource, type index$2_WriteSetChange_DeleteTableItem as WriteSetChange_DeleteTableItem, type index$2_WriteSetChange_WriteModule as WriteSetChange_WriteModule, type index$2_WriteSetChange_WriteResource as WriteSetChange_WriteResource, type index$2_WriteSetChange_WriteTableItem as WriteSetChange_WriteTableItem, type index$2_WriteSetPayload as WriteSetPayload, type index$2_WriteSet_DirectWriteSet as WriteSet_DirectWriteSet, type index$2_WriteSet_ScriptWriteSet as WriteSet_ScriptWriteSet, type index$2_WriteTableItem as WriteTableItem }; } type MaybeHexString = HexString | string | HexEncodedBytes; /** * A util class for working with hex strings. * Hex strings are strings that are prefixed with `0x` */ declare class HexString { private readonly hexString; /** * Creates new hex string from Buffer * @param buffer A buffer to convert * @returns New HexString */ static fromBuffer(buffer: Uint8Array): HexString; /** * Creates new hex string from Uint8Array * @param arr Uint8Array to convert * @returns New HexString */ static fromUint8Array(arr: Uint8Array): HexString; /** * Ensures `hexString` is instance of `HexString` class * @param hexString String to check * @returns New HexString if `hexString` is regular string or `hexString` if it is HexString instance * @example * ``` * const regularString = "string"; * const hexString = new HexString("string"); // "0xstring" * HexString.ensure(regularString); // "0xstring" * HexString.ensure(hexString); // "0xstring" * ``` */ static ensure(hexString: MaybeHexString): HexString; /** * Creates new HexString instance from regular string. If specified string already starts with "0x" prefix, * it will not add another one * @param hexString String to convert * @example * ``` * const string = "string"; * new HexString(string); // "0xstring" * ``` */ constructor(hexString: string | HexEncodedBytes); /** * Getter for inner hexString * @returns Inner hex string */ hex(): string; /** * Getter for inner hexString without prefix * @returns Inner hex string without prefix * @example * ``` * const hexString = new HexString("string"); // "0xstring" * hexString.noPrefix(); // "string" * ``` */ noPrefix(): string; /** * Overrides default `toString` method * @returns Inner hex string */ toString(): string; /** * Trimmes extra zeroes in the begining of a string * @returns Inner hexString without leading zeroes * @example * ``` * new HexString("0x000000string").toShortString(); // result = "0xstring" * ``` */ toShortString(): string; /** * Converts hex string to a Uint8Array * @returns Uint8Array from inner hexString without prefix */ toUint8Array(): Uint8Array; } interface SupraAccountObject { address?: HexEncodedBytes; publicKeyHex?: HexEncodedBytes; privateKeyHex: HexEncodedBytes; } /** * Class for creating and managing Supra account */ declare class SupraAccount { /** * A private key and public key, associated with the given account */ readonly signingKey: nacl.SignKeyPair; /** * Address associated with the given account */ private readonly accountAddress; static fromSupraAccountObject(obj: SupraAccountObject): SupraAccount; /** * Check's if the derive path is valid */ static isValidPath(path: string): boolean; /** * Creates new account with bip44 path and mnemonics, * @param path. (e.g. m/44'/637'/0'/0'/0') * Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki} * @param mnemonics. * @returns SupraAccount */ static fromDerivePath(path: string, mnemonics: string): SupraAccount; /** * Creates new account instance. Constructor allows passing in an address, * to handle account key rotation, where auth_key != public_key * @param privateKeyBytes Private key from which account key pair will be generated. * If not specified, new key pair is going to be created. * @param address Account address (e.g. 0xe8012714cd17606cee7188a2a365eef3fe760be598750678c8c5954eb548a591). * If not specified, a new one will be generated from public key */ constructor(privateKeyBytes?: Uint8Array | undefined, address?: MaybeHexString); /** * This is the key by which Supra account is referenced. * It is the 32-byte of the SHA-3 256 cryptographic hash * of the public key(s) concatenated with a signature scheme identifier byte * @returns Address associated with the given account */ address(): HexString; /** * This key enables account owners to rotate their private key(s) * associated with the account without changing the address that hosts their account. * @returns Authentication key for the associated account */ authKey(): HexString; /** * Takes source address and seeds and returns the resource account address * @param sourceAddress Address used to derive the resource account * @param seed The seed bytes * @returns The resource account address */ static getResourceAccountAddress(sourceAddress: MaybeHexString, seed: Uint8Array): HexString; /** * Takes creator address and collection name and returns the collection id hash. * Collection id hash are generated as sha256 hash of (`creator_address::collection_name`) * * @param creatorAddress Collection creator address * @param collectionName The collection name * @returns The collection id hash */ static getCollectionID(creatorAddress: MaybeHexString, collectionName: string): HexString; /** * This key is generated with Ed25519 scheme. * Public key is used to check a signature of transaction, signed by given account * @returns The public key for the associated account */ pubKey(): HexString; /** * Signs specified `buffer` with account's private key * @param buffer A buffer to sign * @returns A signature HexString */ signBuffer(buffer: Uint8Array): HexString; /** * Signs specified `hexString` with account's private key * @param hexString A regular string or HexString to sign * @returns A signature HexString */ signHexString(hexString: MaybeHexString): HexString; /** * Verifies the signature of the message with the public key of the account * @param message a signed message * @param signature the signature of the message */ verifySignature(message: MaybeHexString, signature: MaybeHexString): boolean; /** * Derives account address, pu