UNPKG

aptos

Version:
1,628 lines (1,507 loc) 729 kB
import nacl from 'tweetnacl'; import EventEmitter from 'eventemitter3'; declare const APTOS_COIN = "0x1::aptos_coin::AptosCoin"; type Seq<T> = T[]; type Uint8 = number; type Uint16 = number; type Uint32 = number; type Uint64 = bigint; type Uint128 = bigint; type Uint256 = bigint; type AnyNumber = bigint | number; type Bytes = Uint8Array; declare class Serializer { private buffer; private offset; constructor(); private ensureBufferWillHandleSize; protected serialize(values: Bytes): void; private serializeWithFunction; /** * Serializes a string. UTF8 string is supported. Serializes the string's bytes length "l" first, * and then serializes "l" bytes of the string content. * * BCS layout for "string": string_length | string_content. string_length is the bytes length of * the string that is uleb128 encoded. string_length is a u32 integer. * * @example * ```ts * const serializer = new Serializer(); * serializer.serializeStr("çå∞≠¢õß∂ƒ∫"); * assert(serializer.getBytes() === new Uint8Array([24, 0xc3, 0xa7, 0xc3, 0xa5, 0xe2, 0x88, 0x9e, * 0xe2, 0x89, 0xa0, 0xc2, 0xa2, 0xc3, 0xb5, 0xc3, 0x9f, 0xe2, 0x88, 0x82, 0xc6, 0x92, 0xe2, 0x88, 0xab])); * ``` */ serializeStr(value: string): void; /** * Serializes an array of bytes. * * BCS layout for "bytes": bytes_length | bytes. bytes_length is the length of the bytes array that is * uleb128 encoded. bytes_length is a u32 integer. */ serializeBytes(value: Bytes): void; /** * Serializes an array of bytes with known length. Therefore length doesn't need to be * serialized to help deserialization. When deserializing, the number of * bytes to deserialize needs to be passed in. */ serializeFixedBytes(value: Bytes): void; /** * Serializes a boolean value. * * BCS layout for "boolean": One byte. "0x01" for True and "0x00" for False. */ serializeBool(value: boolean): void; /** * Serializes a uint8 number. * * BCS layout for "uint8": One byte. Binary format in little-endian representation. */ serializeU8(value: Uint8): void; /** * Serializes a uint16 number. * * BCS layout for "uint16": Two bytes. Binary format in little-endian representation. * @example * ```ts * const serializer = new Serializer(); * serializer.serializeU16(4660); * assert(serializer.getBytes() === new Uint8Array([0x34, 0x12])); * ``` */ serializeU16(value: Uint16): void; /** * Serializes a uint32 number. * * BCS layout for "uint32": Four bytes. Binary format in little-endian representation. * @example * ```ts * const serializer = new Serializer(); * serializer.serializeU32(305419896); * assert(serializer.getBytes() === new Uint8Array([0x78, 0x56, 0x34, 0x12])); * ``` */ serializeU32(value: Uint32): void; /** * Serializes a uint64 number. * * BCS layout for "uint64": Eight bytes. Binary format in little-endian representation. * @example * ```ts * const serializer = new Serializer(); * serializer.serializeU64(1311768467750121216); * assert(serializer.getBytes() === new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12])); * ``` */ serializeU64(value: AnyNumber): void; /** * Serializes a uint128 number. * * BCS layout for "uint128": Sixteen bytes. Binary format in little-endian representation. */ serializeU128(value: AnyNumber): void; /** * Serializes a uint256 number. * * BCS layout for "uint256": Sixteen bytes. Binary format in little-endian representation. */ serializeU256(value: AnyNumber): void; /** * Serializes a uint32 number with uleb128. * * BCS use uleb128 encoding in two cases: (1) lengths of variable-length sequences and (2) tags of enum values */ serializeU32AsUleb128(val: Uint32): void; /** * Returns the buffered bytes */ getBytes(): Bytes; } declare class Deserializer { private buffer; private offset; constructor(data: Bytes); private read; /** * Deserializes a string. UTF8 string is supported. Reads the string's bytes length "l" first, * and then reads "l" bytes of content. Decodes the byte array into a string. * * BCS layout for "string": string_length | string_content. string_length is the bytes length of * the string that is uleb128 encoded. string_length is a u32 integer. * * @example * ```ts * const deserializer = new Deserializer(new Uint8Array([24, 0xc3, 0xa7, 0xc3, 0xa5, 0xe2, 0x88, 0x9e, * 0xe2, 0x89, 0xa0, 0xc2, 0xa2, 0xc3, 0xb5, 0xc3, 0x9f, 0xe2, 0x88, 0x82, 0xc6, 0x92, 0xe2, 0x88, 0xab])); * assert(deserializer.deserializeStr() === "çå∞≠¢õß∂ƒ∫"); * ``` */ deserializeStr(): string; /** * Deserializes an array of bytes. * * BCS layout for "bytes": bytes_length | bytes. bytes_length is the length of the bytes array that is * uleb128 encoded. bytes_length is a u32 integer. */ deserializeBytes(): Bytes; /** * Deserializes an array of bytes. The number of bytes to read is already known. * */ deserializeFixedBytes(len: number): Bytes; /** * Deserializes a boolean value. * * BCS layout for "boolean": One byte. "0x01" for True and "0x00" for False. */ deserializeBool(): boolean; /** * Deserializes a uint8 number. * * BCS layout for "uint8": One byte. Binary format in little-endian representation. */ deserializeU8(): Uint8; /** * Deserializes a uint16 number. * * BCS layout for "uint16": Two bytes. Binary format in little-endian representation. * @example * ```ts * const deserializer = new Deserializer(new Uint8Array([0x34, 0x12])); * assert(deserializer.deserializeU16() === 4660); * ``` */ deserializeU16(): Uint16; /** * Deserializes a uint32 number. * * BCS layout for "uint32": Four bytes. Binary format in little-endian representation. * @example * ```ts * const deserializer = new Deserializer(new Uint8Array([0x78, 0x56, 0x34, 0x12])); * assert(deserializer.deserializeU32() === 305419896); * ``` */ deserializeU32(): Uint32; /** * Deserializes a uint64 number. * * BCS layout for "uint64": Eight bytes. Binary format in little-endian representation. * @example * ```ts * const deserializer = new Deserializer(new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12])); * assert(deserializer.deserializeU64() === 1311768467750121216); * ``` */ deserializeU64(): Uint64; /** * Deserializes a uint128 number. * * BCS layout for "uint128": Sixteen bytes. Binary format in little-endian representation. */ deserializeU128(): Uint128; /** * Deserializes a uint256 number. * * BCS layout for "uint256": Thirty-two bytes. Binary format in little-endian representation. */ deserializeU256(): Uint256; /** * Deserializes a uleb128 encoded uint32 number. * * BCS use uleb128 encoding in two cases: (1) lengths of variable-length sequences and (2) tags of enum values */ deserializeUleb128AsU32(): Uint32; } interface Serializable { serialize(serializer: Serializer): void; } /** * Serializes a vector values that are "Serializable". */ declare function serializeVector<T extends Serializable>(value: Seq<T>, serializer: Serializer): void; /** * Serializes a vector with specified item serialization function. * Very dynamic function and bypasses static typechecking. */ declare function serializeVectorWithFunc(value: any[], func: string): Bytes; /** * Deserializes a vector of values. */ declare function deserializeVector(deserializer: Deserializer, cls: any): any[]; declare function bcsToBytes<T extends Serializable>(value: T): Bytes; declare function bcsSerializeUint64(value: AnyNumber): Bytes; declare function bcsSerializeU8(value: Uint8): Bytes; declare function bcsSerializeU16(value: Uint16): Bytes; declare function bcsSerializeU32(value: Uint32): Bytes; declare function bcsSerializeU128(value: AnyNumber): Bytes; declare function bcsSerializeU256(value: AnyNumber): Bytes; declare function bcsSerializeBool(value: boolean): Bytes; declare function bcsSerializeStr(value: string): Bytes; declare function bcsSerializeBytes(value: Bytes): Bytes; declare function bcsSerializeFixedBytes(value: Bytes): Bytes; type index$2_AnyNumber = AnyNumber; type index$2_Bytes = Bytes; type index$2_Deserializer = Deserializer; declare const index$2_Deserializer: typeof Deserializer; type index$2_Seq<T> = Seq<T>; type index$2_Serializer = Serializer; declare const index$2_Serializer: typeof Serializer; type index$2_Uint128 = Uint128; type index$2_Uint16 = Uint16; type index$2_Uint256 = Uint256; type index$2_Uint32 = Uint32; type index$2_Uint64 = Uint64; type index$2_Uint8 = Uint8; declare const index$2_bcsSerializeBool: typeof bcsSerializeBool; declare const index$2_bcsSerializeBytes: typeof bcsSerializeBytes; declare const index$2_bcsSerializeFixedBytes: typeof bcsSerializeFixedBytes; declare const index$2_bcsSerializeStr: typeof bcsSerializeStr; declare const index$2_bcsSerializeU128: typeof bcsSerializeU128; declare const index$2_bcsSerializeU16: typeof bcsSerializeU16; declare const index$2_bcsSerializeU256: typeof bcsSerializeU256; declare const index$2_bcsSerializeU32: typeof bcsSerializeU32; declare const index$2_bcsSerializeU8: typeof bcsSerializeU8; declare const index$2_bcsSerializeUint64: typeof bcsSerializeUint64; declare const index$2_bcsToBytes: typeof bcsToBytes; declare const index$2_deserializeVector: typeof deserializeVector; declare const index$2_serializeVector: typeof serializeVector; declare const index$2_serializeVectorWithFunc: typeof serializeVectorWithFunc; declare namespace index$2 { export { type index$2_AnyNumber as AnyNumber, type index$2_Bytes as Bytes, index$2_Deserializer as Deserializer, type index$2_Seq as Seq, index$2_Serializer as Serializer, type index$2_Uint128 as Uint128, type index$2_Uint16 as Uint16, type index$2_Uint256 as Uint256, type index$2_Uint32 as Uint32, type index$2_Uint64 as Uint64, type index$2_Uint8 as Uint8, index$2_bcsSerializeBool as bcsSerializeBool, index$2_bcsSerializeBytes as bcsSerializeBytes, index$2_bcsSerializeFixedBytes as bcsSerializeFixedBytes, index$2_bcsSerializeStr as bcsSerializeStr, index$2_bcsSerializeU128 as bcsSerializeU128, index$2_bcsSerializeU16 as bcsSerializeU16, index$2_bcsSerializeU256 as bcsSerializeU256, index$2_bcsSerializeU32 as bcsSerializeU32, index$2_bcsSerializeU8 as bcsSerializeU8, index$2_bcsSerializeUint64 as bcsSerializeUint64, index$2_bcsToBytes as bcsToBytes, index$2_deserializeVector as deserializeVector, index$2_serializeVector as serializeVector, index$2_serializeVectorWithFunc as serializeVectorWithFunc }; } /** * A configuration object we can pass with the request to the server. * * @param TOKEN - an auth token to send with the request * @param HEADERS - extra headers we want to send with the request * @param WITH_CREDENTIALS - whether to carry cookies. By default, it is set to true and cookies will be sent */ type ClientConfig = { TOKEN?: string; HEADERS?: Record<string, string | number | boolean>; WITH_CREDENTIALS?: boolean; }; /** * The API request type * * @param url - the url to make the request to, i.e https://fullnode.aptoslabs.devnet.com/v1 * @param method - the request method "GET" | "POST" * @param endpoint (optional) - the endpoint to make the request to, i.e transactions * @param body (optional) - the body of the request * @param contentType (optional) - the content type to set the `content-type` header to, * by default is set to `application/json` * @param params (optional) - query params to add to the request * @param originMethod (optional) - the local method the request came from * @param overrides (optional) - a `ClientConfig` object type to override request data */ type AptosRequest = { url: string; method: "GET" | "POST"; endpoint?: string; body?: any; contentType?: string; params?: Record<string, string | AnyNumber | boolean | undefined>; originMethod?: string; overrides?: ClientConfig; }; /** * The API response type * * @param status - the response status. i.e 200 * @param statusText - the response message * @param data the response data * @param url the url the request was made to * @param headers the response headers * @param config (optional) - the request object * @param request (optional) - the request object */ interface AptosResponse<Req, Res> { status: number; statusText: string; data: Res; url: string; headers: any; config?: any; request?: Req; } /** * The type returned from an API error * * @param name - the error name "AptosApiError" * @param url the url the request was made to * @param status - the response status. i.e 400 * @param statusText - the response message * @param data the response data * @param request - the AptosRequest */ declare class AptosApiError extends Error { readonly url: string; readonly status: number; readonly statusText: string; readonly data: any; readonly request: AptosRequest; constructor(request: AptosRequest, response: AptosResponse<any, any>, message: string); } /** * The main function to use when doing an API request. * * @param options AptosRequest * @returns the response or AptosApiError */ declare function aptosRequest<Req, Res>(options: AptosRequest): Promise<AptosResponse<Req, Res>>; type GetRequestOptions = Omit<AptosRequest, "body" | "method">; /** * Main function to do a Get request * * @param options GetRequestOptions * @returns */ declare function get<Req, Res>(options: GetRequestOptions): Promise<AptosResponse<Req, Res>>; type PostRequestOptions = Omit<AptosRequest, "method">; /** * Main function to do a Post request * * @param options PostRequestOptions * @returns */ declare function post<Req, Res>(options: PostRequestOptions): Promise<AptosResponse<Req, Res>>; declare const NetworkToIndexerAPI: Record<string, string>; declare const NetworkToNodeAPI: Record<string, string>; declare const NodeAPIToNetwork: Record<string, string>; declare enum Network { MAINNET = "mainnet", TESTNET = "testnet", DEVNET = "devnet", LOCAL = "local" } interface CustomEndpoints { fullnodeUrl: string; indexerUrl?: string; } /** * 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$1 = string; /** * Account data * * A simplified version of the onchain Account resource */ type AccountData = { sequence_number: U64$1; 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 Signature_string_HexEncodedBytes_ = ({ type: string; } & HexEncodedBytes); type Signature = Signature_string_HexEncodedBytes_; type IndexedSignature = { index: number; signature: Signature; }; type PublicKey_string_HexEncodedBytes_ = ({ type: string; } & HexEncodedBytes); type PublicKey = PublicKey_string_HexEncodedBytes_; /** * 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 EventGuid = { creation_number: U64$1; account_address: Address; }; /** * 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; /** * An event from a transaction */ type Event = { guid: EventGuid; sequence_number: U64$1; type: MoveType; /** * The JSON representation of the event */ data: any; }; /** * 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" } /** * 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 metadata transaction * * This signifies the beginning of a block, and contains information * about the specific block */ type BlockMetadataTransaction = { version: U64$1; hash: HashValue; state_change_hash: HashValue; event_root_hash: HashValue; state_checkpoint_hash?: HashValue; gas_used: U64$1; /** * 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$1; round: U64$1; /** * 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$1; }; 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$1; hash: HashValue; state_change_hash: HashValue; event_root_hash: HashValue; state_checkpoint_hash?: HashValue; gas_used: U64$1; /** * 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); /** * 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 ModuleBundlePayload = { modules: Array<MoveModuleBytecode>; }; type TransactionPayload_ModuleBundlePayload = ({ type: string; } & ModuleBundlePayload); type 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_ModuleBundlePayload | 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$1; max_gas_amount: U64$1; gas_unit_price: U64$1; expiration_timestamp_secs: U64$1; payload: TransactionPayload$1; signature?: TransactionSignature; }; type Transaction_PendingTransaction = ({ type: string; } & PendingTransaction); /** * A state checkpoint transaction */ type StateCheckpointTransaction = { version: U64$1; hash: HashValue; state_change_hash: HashValue; event_root_hash: HashValue; state_checkpoint_hash?: HashValue; gas_used: U64$1; /** * 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$1; }; type Transaction_StateCheckpointTransaction = ({ type: string; } & StateCheckpointTransaction); /** * A transaction submitted by a user to change the state of the blockchain */ type UserTransaction$1 = { version: U64$1; hash: HashValue; state_change_hash: HashValue; event_root_hash: HashValue; state_checkpoint_hash?: HashValue; gas_used: U64$1; /** * 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$1; max_gas_amount: U64$1; gas_unit_price: U64$1; expiration_timestamp_secs: U64$1; payload: TransactionPayload$1; signature?: TransactionSignature; /** * Events generated by the transaction */ events: Array<Event>; timestamp: U64$1; }; type Transaction_UserTransaction = ({ type: string; } & UserTransaction$1); /** * Enum of the different types of transactions in Aptos */ type Transaction$1 = (Transaction_PendingTransaction | Transaction_UserTransaction | Transaction_GenesisTransaction | Transaction_BlockMetadataTransaction | Transaction_StateCheckpointTransaction); /** * A Block with or without transactions * * This contains the information about a transactions along with * associated transactions if requested */ type Block = { block_height: U64$1; block_hash: HashValue; block_timestamp: U64$1; first_version: U64$1; last_version: U64$1; /** * The transactions in the block in sequential order */ transactions?: Array<Transaction$1>; }; /** * Request to encode a submission */ type EncodeSubmissionRequest = { sender: Address; sequence_number: U64$1; max_gas_amount: U64$1; gas_unit_price: U64$1; expiration_timestamp_secs: U64$1; 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$1; ledger_version: U64$1; oldest_ledger_version: U64$1; ledger_timestamp: U64$1; node_role: RoleType; oldest_block_height: U64$1; block_height: U64$1; /** * 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$1 | 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$1; max_gas_amount: U64$1; gas_unit_price: U64$1; expiration_timestamp_secs: U64$1; 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$1; guid: EventGuid; sequence_number: U64$1; 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$1_AccountData = AccountData; type index$1_AccountSignature = AccountSignature; type index$1_AccountSignature_Ed25519Signature = AccountSignature_Ed25519Signature; type index$1_AccountSignature_MultiEd25519Signature = AccountSignature_MultiEd25519Signature; type index$1_AccountSignature_MultiKeySignature = AccountSignature_MultiKeySignature; type index$1_AccountSignature_SingleKeySignature = AccountSignature_SingleKeySignature; type index$1_Address = Address; type index$1_AptosError = AptosError; type index$1_AptosErrorCode = AptosErrorCode; declare const index$1_AptosErrorCode: typeof AptosErrorCode; type index$1_Block = Block; type index$1_BlockMetadataTransaction = BlockMetadataTransaction; type index$1_DecodedTableData = DecodedTableData; type index$1_DeleteModule = DeleteModule; type index$1_DeleteResource = DeleteResource; type index$1_DeleteTableItem = DeleteTableItem; type index$1_DeletedTableData = DeletedTableData; type index$1_DirectWriteSet = DirectWriteSet; type index$1_EncodeSubmissionRequest = EncodeSubmissionRequest; type index$1_EntryFunctionId = EntryFunctionId; type index$1_EntryFunctionPayload = EntryFunctionPayload; type index$1_Event = Event; type index$1_EventGuid = EventGuid; type index$1_FeePayerSignature = FeePayerSignature; type index$1_GasEstimation = GasEstimation; type index$1_GenesisPayload = GenesisPayload; type index$1_GenesisPayload_WriteSetPayload = GenesisPayload_WriteSetPayload; type index$1_GenesisTransaction = GenesisTransaction; type index$1_HashValue = HashValue; type index$1_HealthCheckSuccess = HealthCheckSuccess; type index$1_HexEncodedBytes = HexEncodedBytes; type index$1_IdentifierWrapper = IdentifierWrapper; type index$1_IndexResponse = IndexResponse; type index$1_IndexedSignature = IndexedSignature; type index$1_ModuleBundlePayload = ModuleBundlePayload; type index$1_MoveAbility = MoveAbility; type index$1_MoveFunction = MoveFunction; type index$1_MoveFunctionGenericTypeParam = MoveFunctionGenericTypeParam; type index$1_MoveFunctionVisibility = MoveFunctionVisibility; declare const index$1_MoveFunctionVisibility: typeof MoveFunctionVisibility; type index$1_MoveModule = MoveModule; type index$1_MoveModuleBytecode = MoveModuleBytecode; type index$1_MoveModuleId = MoveModuleId; type index$1_MoveResource = MoveResource; type index$1_MoveScriptBytecode = MoveScriptBytecode; type index$1_MoveStruct = MoveStruct; type index$1_MoveStructField = MoveStructField; type index$1_MoveStructGenericTypeParam = MoveStructGenericTypeParam; type index$1_MoveStructTag = MoveStructTag; type index$1_MoveStructValue = MoveStructValue; type index$1_MoveType = MoveType; type index$1_MoveValue = MoveValue; type index$1_MultiAgentSignature = MultiAgentSignature; type index$1_MultiKeySignature = MultiKeySignature; type index$1_MultisigPayload = MultisigPayload; type index$1_MultisigTransactionPayload = MultisigTransactionPayload; type index$1_PendingTransaction = PendingTransaction; type index$1_PublicKey = PublicKey; type index$1_PublicKey_string_HexEncodedBytes_ = PublicKey_string_HexEncodedBytes_; type index$1_RawTableItemRequest = RawTableItemRequest; type index$1_RoleType = RoleType; declare const index$1_RoleType: typeof RoleType; type index$1_ScriptPayload = ScriptPayload; type index$1_ScriptWriteSet = ScriptWriteSet; type index$1_Signature = Signature; type index$1_Signature_string_HexEncodedBytes_ = Signature_string_HexEncodedBytes_; type index$1_SingleKeySignature = SingleKeySignature; type index$1_StateCheckpointTransaction = StateCheckpointTransaction; type index$1_StateKeyWrapper = StateKeyWrapper; type index$1_SubmitTransactionRequest = SubmitTransactionRequest; type index$1_TableItemRequest = TableItemRequest; type index$1_TransactionPayload_EntryFunctionPayload = TransactionPayload_EntryFunctionPayload; type index$1_TransactionPayload_ModuleBundlePayload = TransactionPayload_ModuleBundlePayload; type index$1_TransactionPayload_MultisigPayload = TransactionPayload_MultisigPayload; type index$1_TransactionPayload_ScriptPayload = TransactionPayload_ScriptPayload; type index$1_TransactionSignature = TransactionSignature; type index$1_TransactionSignature_AccountSignature = TransactionSignature_AccountSignature; type index$1_TransactionSignature_Ed25519Signature = TransactionSignature_Ed25519Signature; type index$1_TransactionSignature_FeePayerSignature = TransactionSignature_FeePayerSignature; type index$1_TransactionSignature_MultiAgentSignature = TransactionSignature_MultiAgentSignature; type index$1_TransactionSignature_MultiEd25519Signature = TransactionSignature_MultiEd25519Signature; type index$1_Transaction_BlockMetadataTransaction = Transaction_BlockMetadataTransaction; type index$1_Transaction_GenesisTransaction = Transaction_GenesisTransaction; type index$1_Transaction_PendingTransaction = Transaction_PendingTransaction; type index$1_Transaction_StateCheckpointTransaction = Transaction_StateCheckpointTransaction; type index$1_Transaction_UserTransaction = Transaction_UserTransaction; type index$1_TransactionsBatchSingleSubmissionFailure = TransactionsBatchSingleSubmissionFailure; type index$1_TransactionsBatchSubmissionResult = TransactionsBatchSubmissionResult; type index$1_U128 = U128; type index$1_U256 = U256; type index$1_VersionedEvent = VersionedEvent; type index$1_ViewRequest = ViewRequest; type index$1_WriteModule = WriteModule; type index$1_WriteResource = WriteResource; type index$1_WriteSetChange = WriteSetChange; type index$1_WriteSetChange_DeleteModule = WriteSetChange_DeleteModule; type index$1_WriteSetChange_DeleteResource = WriteSetChange_DeleteResource; type index$1_WriteSetChange_DeleteTableItem = WriteSetChange_DeleteTableItem; type index$1_WriteSetChange_WriteModule = WriteSetChange_WriteModule; type index$1_WriteSetChange_WriteResource = WriteSetChange_WriteResource; type index$1_WriteSetChange_WriteTableItem = WriteSetChange_WriteTableItem; type index$1_WriteSetPayload = WriteSetPayload; type index$1_WriteSet_DirectWriteSet = WriteSet_DirectWriteSet; type index$1_WriteSet_ScriptWriteSet = WriteSet_ScriptWriteSet; type index$1_WriteTableItem = WriteTableItem; declare namespace index$1 { export { type index$1_AccountData as AccountData, type index$1_AccountSignature as AccountSignature, type index$1_AccountSignature_Ed25519Signature as AccountSignature_Ed25519Signature, type index$1_AccountSignature_MultiEd25519Signature as AccountSignature_MultiEd25519Signature, type index$1_AccountSignature_MultiKeySignature as AccountSignature_MultiKeySignature, type index$1_AccountSignature_SingleKeySignature as AccountSignature_SingleKeySignature, type index$1_Address as Address, type index$1_AptosError as AptosError, index$1_AptosErrorCode as AptosErrorCode, type index$1_Block as Block, type index$1_BlockMetadataTransaction as BlockMetadataTransaction, type index$1_DecodedTableData as DecodedTableData, type index$1_DeleteModule as DeleteModule, type index$1_DeleteResource as DeleteResource, type index$1_DeleteTableItem as DeleteTableItem, type index$1_DeletedTableData as DeletedTableData, type index$1_DirectWriteSet as DirectWriteSet, type Ed25519Signature$1 as Ed25519Signature, type index$1_EncodeSubmissionRequest as EncodeSubmissionRequest, type index$1_EntryFunctionId as EntryFunctionId, type index$1_EntryFunctionPayload as EntryFunctionPayload, type index$1_Event as Event, type index$1_EventGuid as EventGuid, type index$1_FeePayerSignature as FeePayerSignature, type index$1_GasEstimation as GasEstimation, type index$1_GenesisPayload as GenesisPayload, type index$1_GenesisPayload_WriteSetPayload as GenesisPayload_WriteSetPayload, type index$1_GenesisTransaction as GenesisTransaction, type index$1_HashValue as HashValue, type index$1_HealthCheckSuccess as HealthCheckSuccess, type index$1_HexEncodedBytes as HexEncodedBytes, type index$1_IdentifierWrapper as IdentifierWrapper, type index$1_IndexResponse as IndexResponse, type index$1_IndexedSignature as IndexedSignature, type index$1_ModuleBundlePayload as ModuleBundlePayload, type index$1_MoveAbility as MoveAbility, type index$1_MoveFunction as MoveFunction, type index$1_MoveFunctionGenericTypeParam as MoveFunctionGenericTypeParam, index$1_MoveFunctionVisibility as MoveFunctionVisibility, type index$1_MoveModule as MoveModule, type index$1_MoveModuleBytecode as MoveModuleBytecode, type index$1_MoveModuleId as MoveModuleId, type index$1_MoveResource as MoveResource, type index$1_MoveScriptBytecode as MoveScriptBytecode, type index$1_MoveStruct as MoveStruct, type index$1_MoveStructField as MoveStructField, type ind