UNPKG

aptos

Version:
1 lines 960 kB
{"version":3,"sources":["../src/account/aptos_account.ts","../src/utils/hd-key.ts","../src/version.ts","../src/utils/misc.ts","../src/utils/memoize-decorator.ts","../src/client/core.ts","../src/client/types.ts","../src/client/get.ts","../src/client/post.ts","../src/utils/pagination_helpers.ts","../src/utils/api-endpoints.ts","../src/utils/hex_string.ts","../src/aptos_types/index.ts","../src/bcs/index.ts","../src/bcs/consts.ts","../src/bcs/serializer.ts","../src/bcs/deserializer.ts","../src/bcs/helper.ts","../src/aptos_types/transaction.ts","../src/aptos_types/account_address.ts","../src/aptos_types/ed25519.ts","../src/aptos_types/multi_ed25519.ts","../src/aptos_types/authenticator.ts","../src/aptos_types/identifier.ts","../src/aptos_types/type_tag.ts","../src/aptos_types/abi.ts","../src/aptos_types/authentication_key.ts","../src/aptos_types/rotation_proof_challenge.ts","../src/indexer/generated/queries.ts","../src/transaction_builder/builder.ts","../src/transaction_builder/builder_utils.ts","../src/providers/aptos_client.ts","../src/providers/indexer.ts","../src/providers/provider.ts","../src/utils/property_map_serde.ts","../src/aptos_types/token_types.ts","../src/plugins/token_client.ts","../src/plugins/fungible_asset_client.ts","../src/plugins/aptos_token.ts","../src/plugins/coin_client.ts","../src/plugins/faucet_client.ts","../src/plugins/ans_client.ts","../src/transactions/account_sequence_number.ts","../src/transactions/transaction_worker.ts","../src/transactions/async_queue.ts","../src/generated/index.ts","../src/generated/models/AptosErrorCode.ts","../src/generated/models/MoveFunctionVisibility.ts","../src/generated/models/RoleType.ts","../src/indexer/generated/types.ts"],"sourcesContent":["// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport nacl from \"tweetnacl\";\nimport * as bip39 from \"@scure/bip39\";\nimport { bytesToHex } from \"@noble/hashes/utils\";\nimport { sha256 } from \"@noble/hashes/sha256\";\nimport { sha3_256 as sha3Hash } from \"@noble/hashes/sha3\";\nimport { derivePath } from \"../utils/hd-key\";\nimport { HexString, MaybeHexString, Memoize } from \"../utils\";\nimport * as Gen from \"../generated/index\";\nimport { AccountAddress, AuthenticationKey, Ed25519PublicKey } from \"../aptos_types\";\nimport { bcsToBytes } from \"../bcs\";\n\nexport interface AptosAccountObject {\n address?: Gen.HexEncodedBytes;\n publicKeyHex?: Gen.HexEncodedBytes;\n privateKeyHex: Gen.HexEncodedBytes;\n}\n\n/**\n * Class for creating and managing Aptos account\n */\nexport class AptosAccount {\n /**\n * A private key and public key, associated with the given account\n */\n readonly signingKey: nacl.SignKeyPair;\n\n /**\n * Address associated with the given account\n */\n private readonly accountAddress: HexString;\n\n static fromAptosAccountObject(obj: AptosAccountObject): AptosAccount {\n return new AptosAccount(HexString.ensure(obj.privateKeyHex).toUint8Array(), obj.address);\n }\n\n /**\n * Check's if the derive path is valid\n */\n static isValidPath(path: string): boolean {\n return /^m\\/44'\\/637'\\/[0-9]+'\\/[0-9]+'\\/[0-9]+'+$/.test(path);\n }\n\n /**\n * Creates new account with bip44 path and mnemonics,\n * @param path. (e.g. m/44'/637'/0'/0'/0')\n * Detailed description: {@link https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki}\n * @param mnemonics.\n * @returns AptosAccount\n */\n static fromDerivePath(path: string, mnemonics: string): AptosAccount {\n if (!AptosAccount.isValidPath(path)) {\n throw new Error(\"Invalid derivation path\");\n }\n\n const normalizeMnemonics = mnemonics\n .trim()\n .split(/\\s+/)\n .map((part) => part.toLowerCase())\n .join(\" \");\n\n const { key } = derivePath(path, bytesToHex(bip39.mnemonicToSeedSync(normalizeMnemonics)));\n\n return new AptosAccount(key);\n }\n\n /**\n * Creates new account instance. Constructor allows passing in an address,\n * to handle account key rotation, where auth_key != public_key\n * @param privateKeyBytes Private key from which account key pair will be generated.\n * If not specified, new key pair is going to be created.\n * @param address Account address (e.g. 0xe8012714cd17606cee7188a2a365eef3fe760be598750678c8c5954eb548a591).\n * If not specified, a new one will be generated from public key\n */\n constructor(privateKeyBytes?: Uint8Array | undefined, address?: MaybeHexString) {\n if (privateKeyBytes) {\n this.signingKey = nacl.sign.keyPair.fromSeed(privateKeyBytes.slice(0, 32));\n } else {\n this.signingKey = nacl.sign.keyPair();\n }\n this.accountAddress = HexString.ensure(address || this.authKey().hex());\n }\n\n /**\n * This is the key by which Aptos account is referenced.\n * It is the 32-byte of the SHA-3 256 cryptographic hash\n * of the public key(s) concatenated with a signature scheme identifier byte\n * @returns Address associated with the given account\n */\n address(): HexString {\n return this.accountAddress;\n }\n\n /**\n * This key enables account owners to rotate their private key(s)\n * associated with the account without changing the address that hosts their account.\n * See here for more info: {@link https://aptos.dev/concepts/accounts#single-signer-authentication}\n * @returns Authentication key for the associated account\n */\n @Memoize()\n authKey(): HexString {\n const pubKey = new Ed25519PublicKey(this.signingKey.publicKey);\n const authKey = AuthenticationKey.fromEd25519PublicKey(pubKey);\n return authKey.derivedAddress();\n }\n\n /**\n * Takes source address and seeds and returns the resource account address\n * @param sourceAddress Address used to derive the resource account\n * @param seed The seed bytes\n * @returns The resource account address\n */\n static getResourceAccountAddress(sourceAddress: MaybeHexString, seed: Uint8Array): HexString {\n const source = bcsToBytes(AccountAddress.fromHex(sourceAddress));\n\n const bytes = new Uint8Array([...source, ...seed, AuthenticationKey.DERIVE_RESOURCE_ACCOUNT_SCHEME]);\n\n const hash = sha3Hash.create();\n hash.update(bytes);\n\n return HexString.fromUint8Array(hash.digest());\n }\n\n /**\n * Takes creator address and collection name and returns the collection id hash.\n * Collection id hash are generated as sha256 hash of (`creator_address::collection_name`)\n *\n * @param creatorAddress Collection creator address\n * @param collectionName The collection name\n * @returns The collection id hash\n */\n static getCollectionID(creatorAddress: MaybeHexString, collectionName: string): HexString {\n const seed = new TextEncoder().encode(`${creatorAddress}::${collectionName}`);\n const hash = sha256.create();\n hash.update(seed);\n return HexString.fromUint8Array(hash.digest());\n }\n\n /**\n * This key is generated with Ed25519 scheme.\n * Public key is used to check a signature of transaction, signed by given account\n * @returns The public key for the associated account\n */\n pubKey(): HexString {\n return HexString.fromUint8Array(this.signingKey.publicKey);\n }\n\n /**\n * Signs specified `buffer` with account's private key\n * @param buffer A buffer to sign\n * @returns A signature HexString\n */\n signBuffer(buffer: Uint8Array): HexString {\n const signature = nacl.sign.detached(buffer, this.signingKey.secretKey);\n return HexString.fromUint8Array(signature);\n }\n\n /**\n * Signs specified `hexString` with account's private key\n * @param hexString A regular string or HexString to sign\n * @returns A signature HexString\n */\n signHexString(hexString: MaybeHexString): HexString {\n const toSign = HexString.ensure(hexString).toUint8Array();\n return this.signBuffer(toSign);\n }\n\n /**\n * Verifies the signature of the message with the public key of the account\n * @param message a signed message\n * @param signature the signature of the message\n */\n verifySignature(message: MaybeHexString, signature: MaybeHexString): boolean {\n const rawMessage = HexString.ensure(message).toUint8Array();\n const rawSignature = HexString.ensure(signature).toUint8Array();\n return nacl.sign.detached.verify(rawMessage, rawSignature, this.signingKey.publicKey);\n }\n\n /**\n * Derives account address, public key and private key\n * @returns AptosAccountObject instance.\n * @example An example of the returned AptosAccountObject object\n * ```\n * {\n * address: \"0xe8012714cd17606cee7188a2a365eef3fe760be598750678c8c5954eb548a591\",\n * publicKeyHex: \"0xf56d8524faf79fbc0f48c13aeed3b0ce5dd376b4db93b8130a107c0a5e04ba04\",\n * privateKeyHex: `0x009c9f7c992a06cfafe916f125d8adb7a395fca243e264a8e56a4b3e6accf940\n * d2b11e9ece3049ce60e3c7b4a1c58aebfa9298e29a30a58a67f1998646135204`\n * }\n * ```\n */\n toPrivateKeyObject(): AptosAccountObject {\n return {\n address: this.address().hex(),\n publicKeyHex: this.pubKey().hex(),\n privateKeyHex: HexString.fromUint8Array(this.signingKey.secretKey.slice(0, 32)).hex(),\n };\n }\n}\n\n// Returns an account address as a HexString given either an AptosAccount or a MaybeHexString.\nexport function getAddressFromAccountOrAddress(accountOrAddress: AptosAccount | MaybeHexString): HexString {\n return accountOrAddress instanceof AptosAccount ? accountOrAddress.address() : HexString.ensure(accountOrAddress);\n}\n","import nacl from \"tweetnacl\";\nimport { hmac } from \"@noble/hashes/hmac\";\nimport { sha512 } from \"@noble/hashes/sha512\";\nimport { hexToBytes } from \"@noble/hashes/utils\";\n\nexport type Keys = {\n key: Uint8Array;\n chainCode: Uint8Array;\n};\n\nconst pathRegex = /^m(\\/[0-9]+')+$/;\n\nconst replaceDerive = (val: string): string => val.replace(\"'\", \"\");\n\nconst HMAC_KEY = \"ed25519 seed\";\nconst HARDENED_OFFSET = 0x80000000;\n\nexport const getMasterKeyFromSeed = (seed: string): Keys => {\n const h = hmac.create(sha512, HMAC_KEY);\n const I = h.update(hexToBytes(seed)).digest();\n const IL = I.slice(0, 32);\n const IR = I.slice(32);\n return {\n key: IL,\n chainCode: IR,\n };\n};\n\nexport const CKDPriv = ({ key, chainCode }: Keys, index: number): Keys => {\n const buffer = new ArrayBuffer(4);\n new DataView(buffer).setUint32(0, index);\n const indexBytes = new Uint8Array(buffer);\n const zero = new Uint8Array([0]);\n const data = new Uint8Array([...zero, ...key, ...indexBytes]);\n\n const I = hmac.create(sha512, chainCode).update(data).digest();\n const IL = I.slice(0, 32);\n const IR = I.slice(32);\n return {\n key: IL,\n chainCode: IR,\n };\n};\n\nexport const getPublicKey = (privateKey: Uint8Array, withZeroByte = true): Uint8Array => {\n const keyPair = nacl.sign.keyPair.fromSeed(privateKey);\n const signPk = keyPair.secretKey.subarray(32);\n const zero = new Uint8Array([0]);\n return withZeroByte ? new Uint8Array([...zero, ...signPk]) : signPk;\n};\n\nexport const isValidPath = (path: string): boolean => {\n if (!pathRegex.test(path)) {\n return false;\n }\n return !path\n .split(\"/\")\n .slice(1)\n .map(replaceDerive)\n .some(Number.isNaN as any);\n};\n\nexport const derivePath = (path: string, seed: string, offset = HARDENED_OFFSET): Keys => {\n if (!isValidPath(path)) {\n throw new Error(\"Invalid derivation path\");\n }\n\n const { key, chainCode } = getMasterKeyFromSeed(seed);\n const segments = path\n .split(\"/\")\n .slice(1)\n .map(replaceDerive)\n .map((el) => parseInt(el, 10));\n\n return segments.reduce((parentKeys, segment) => CKDPriv(parentKeys, segment + offset), { key, chainCode });\n};\n","// hardcoded for now, we would want to have it injected dynamically\nexport const VERSION = \"1.21.0\";\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { VERSION } from \"../version\";\n\nexport async function sleep(timeMs: number): Promise<null> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeMs);\n });\n}\n\nexport const DEFAULT_VERSION_PATH_BASE = \"/v1\";\n\nexport function fixNodeUrl(nodeUrl: string): string {\n let out = `${nodeUrl}`;\n if (out.endsWith(\"/\")) {\n out = out.substring(0, out.length - 1);\n }\n if (!out.endsWith(DEFAULT_VERSION_PATH_BASE)) {\n out = `${out}${DEFAULT_VERSION_PATH_BASE}`;\n }\n return out;\n}\n\nexport const DEFAULT_MAX_GAS_AMOUNT = 200000;\n// Transaction expire timestamp\nexport const DEFAULT_TXN_EXP_SEC_FROM_NOW = 20;\n// How long does SDK wait for txn to finish\nexport const DEFAULT_TXN_TIMEOUT_SEC = 20;\nexport const APTOS_COIN = \"0x1::aptos_coin::AptosCoin\";\n\nexport const CUSTOM_REQUEST_HEADER = { \"x-aptos-client\": `aptos-ts-sdk/${VERSION}` };\n","/**\n * Credits to https://github.com/darrylhodgins/typescript-memoize\n */\n\n/* eslint-disable no-param-reassign */\n/* eslint-disable no-restricted-syntax */\n\ninterface MemoizeArgs {\n // ttl in milliseconds for cached items. After `ttlMs`, cached items are evicted automatically. If no `ttlMs`\n // is provided, cached items won't get auto-evicted.\n ttlMs?: number;\n // produces the cache key based on `args`.\n hashFunction?: boolean | ((...args: any[]) => any);\n // cached items can be taged with `tags`. `tags` can be used to evict cached items\n tags?: string[];\n}\n\nexport function Memoize(args?: MemoizeArgs | MemoizeArgs[\"hashFunction\"]) {\n let hashFunction: MemoizeArgs[\"hashFunction\"];\n let ttlMs: MemoizeArgs[\"ttlMs\"];\n let tags: MemoizeArgs[\"tags\"];\n\n if (typeof args === \"object\") {\n hashFunction = args.hashFunction;\n ttlMs = args.ttlMs;\n tags = args.tags;\n } else {\n hashFunction = args;\n }\n\n return (target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => {\n if (descriptor.value != null) {\n descriptor.value = getNewFunction(descriptor.value, hashFunction, ttlMs, tags);\n } else if (descriptor.get != null) {\n descriptor.get = getNewFunction(descriptor.get, hashFunction, ttlMs, tags);\n } else {\n throw new Error(\"Only put a Memoize() decorator on a method or get accessor.\");\n }\n };\n}\n\nexport function MemoizeExpiring(ttlMs: number, hashFunction?: MemoizeArgs[\"hashFunction\"]) {\n return Memoize({\n ttlMs,\n hashFunction,\n });\n}\n\nconst clearCacheTagsMap: Map<string, Map<any, any>[]> = new Map();\n\nexport function clear(tags: string[]): number {\n const cleared: Set<Map<any, any>> = new Set();\n for (const tag of tags) {\n const maps = clearCacheTagsMap.get(tag);\n if (maps) {\n for (const mp of maps) {\n if (!cleared.has(mp)) {\n mp.clear();\n cleared.add(mp);\n }\n }\n }\n }\n return cleared.size;\n}\n\nfunction getNewFunction(\n originalMethod: () => void,\n hashFunction?: MemoizeArgs[\"hashFunction\"],\n ttlMs: number = 0,\n tags?: MemoizeArgs[\"tags\"],\n) {\n const propMapName = Symbol(\"__memoized_map__\");\n\n // The function returned here gets called instead of originalMethod.\n // eslint-disable-next-line func-names\n return function (...args: any[]) {\n let returnedValue: any;\n\n // @ts-ignore\n const that: any = this;\n\n // Get or create map\n // eslint-disable-next-line no-prototype-builtins\n if (!that.hasOwnProperty(propMapName)) {\n Object.defineProperty(that, propMapName, {\n configurable: false,\n enumerable: false,\n writable: false,\n value: new Map<any, any>(),\n });\n }\n const myMap: Map<any, any> = that[propMapName];\n\n if (Array.isArray(tags)) {\n for (const tag of tags) {\n if (clearCacheTagsMap.has(tag)) {\n clearCacheTagsMap.get(tag)!.push(myMap);\n } else {\n clearCacheTagsMap.set(tag, [myMap]);\n }\n }\n }\n\n if (hashFunction || args.length > 0 || ttlMs > 0) {\n let hashKey: any;\n\n // If true is passed as first parameter, will automatically use every argument, passed to string\n if (hashFunction === true) {\n hashKey = args.map((a) => a.toString()).join(\"!\");\n } else if (hashFunction) {\n hashKey = hashFunction.apply(that, args);\n } else {\n // eslint-disable-next-line prefer-destructuring\n hashKey = args[0];\n }\n\n const timestampKey = `${hashKey}__timestamp`;\n let isExpired: boolean = false;\n if (ttlMs > 0) {\n if (!myMap.has(timestampKey)) {\n // \"Expired\" since it was never called before\n isExpired = true;\n } else {\n const timestamp = myMap.get(timestampKey);\n isExpired = Date.now() - timestamp > ttlMs;\n }\n }\n\n if (myMap.has(hashKey) && !isExpired) {\n returnedValue = myMap.get(hashKey);\n } else {\n returnedValue = originalMethod.apply(that, args as any);\n myMap.set(hashKey, returnedValue);\n if (ttlMs > 0) {\n myMap.set(timestampKey, Date.now());\n }\n }\n } else {\n const hashKey = that;\n if (myMap.has(hashKey)) {\n returnedValue = myMap.get(hashKey);\n } else {\n returnedValue = originalMethod.apply(that, args as any);\n myMap.set(hashKey, returnedValue);\n }\n }\n\n return returnedValue;\n };\n}\n","import aptosClient from \"@aptos-labs/aptos-client\";\nimport { AptosApiError, AptosRequest, AptosResponse, ClientConfig } from \"./types\";\nimport { VERSION } from \"../version\";\n\n/**\n * Meaningful errors map\n */\nconst errors: Record<number, string> = {\n 400: \"Bad Request\",\n 401: \"Unauthorized\",\n 403: \"Forbidden\",\n 404: \"Not Found\",\n 429: \"Too Many Requests\",\n 500: \"Internal Server Error\",\n 502: \"Bad Gateway\",\n 503: \"Service Unavailable\",\n};\n\n/**\n * Given a url and method, sends the request with axios and\n * returns the response.\n */\nasync function request<Req, Res>(\n url: string,\n method: \"GET\" | \"POST\",\n body?: Req,\n contentType?: string,\n params?: any,\n overrides?: ClientConfig,\n): Promise<any> {\n const headers: Record<string, string | string[] | undefined> = {\n ...overrides?.HEADERS,\n \"x-aptos-client\": `aptos-ts-sdk/${VERSION}`,\n \"content-type\": contentType ?? \"application/json\",\n };\n\n if (overrides?.TOKEN) {\n headers.Authorization = `Bearer ${overrides?.TOKEN}`;\n }\n\n /**\n * make a call using the @aptos-labs/aptos-client package\n * {@link https://www.npmjs.com/package/@aptos-labs/aptos-client}\n */\n const response = await aptosClient<Res>({ url, method, body, params, headers, overrides });\n return response;\n}\n\n/**\n * The main function to use when doing an API request.\n *\n * @param options AptosRequest\n * @returns the response or AptosApiError\n */\nexport async function aptosRequest<Req, Res>(options: AptosRequest): Promise<AptosResponse<Req, Res>> {\n const { url, endpoint, method, body, contentType, params, overrides } = options;\n const fullEndpoint = `${url}/${endpoint ?? \"\"}`;\n const response = await request<Req, Res>(fullEndpoint, method, body, contentType, params, overrides);\n\n const result: AptosResponse<Req, Res> = {\n status: response.status,\n statusText: response.statusText!,\n data: response.data,\n headers: response.headers,\n config: response.config,\n url: fullEndpoint,\n };\n\n if (result.status >= 200 && result.status < 300) {\n return result;\n }\n const errorMessage = errors[result.status];\n throw new AptosApiError(options, result, errorMessage ?? \"Generic Error\");\n}\n","import { AnyNumber } from \"../bcs\";\n\n/**\n * A configuration object we can pass with the request to the server.\n *\n * @param TOKEN - an auth token to send with the request\n * @param HEADERS - extra headers we want to send with the request\n * @param WITH_CREDENTIALS - whether to carry cookies. By default, it is set to true and cookies will be sent\n */\nexport type ClientConfig = {\n TOKEN?: string;\n HEADERS?: Record<string, string | number | boolean>;\n WITH_CREDENTIALS?: boolean;\n};\n\n/**\n * The API request type\n *\n * @param url - the url to make the request to, i.e https://fullnode.aptoslabs.devnet.com/v1\n * @param method - the request method \"GET\" | \"POST\"\n * @param endpoint (optional) - the endpoint to make the request to, i.e transactions\n * @param body (optional) - the body of the request\n * @param contentType (optional) - the content type to set the `content-type` header to,\n * by default is set to `application/json`\n * @param params (optional) - query params to add to the request\n * @param originMethod (optional) - the local method the request came from\n * @param overrides (optional) - a `ClientConfig` object type to override request data\n */\nexport type AptosRequest = {\n url: string;\n method: \"GET\" | \"POST\";\n endpoint?: string;\n body?: any;\n contentType?: string;\n params?: Record<string, string | AnyNumber | boolean | undefined>;\n originMethod?: string;\n overrides?: ClientConfig;\n};\n\n/**\n * The API response type\n *\n * @param status - the response status. i.e 200\n * @param statusText - the response message\n * @param data the response data\n * @param url the url the request was made to\n * @param headers the response headers\n * @param config (optional) - the request object\n * @param request (optional) - the request object\n */\nexport interface AptosResponse<Req, Res> {\n status: number;\n statusText: string;\n data: Res;\n url: string;\n headers: any;\n config?: any;\n request?: Req;\n}\n\n/**\n * The type returned from an API error\n *\n * @param name - the error name \"AptosApiError\"\n * @param url the url the request was made to\n * @param status - the response status. i.e 400\n * @param statusText - the response message\n * @param data the response data\n * @param request - the AptosRequest\n */\nexport class AptosApiError extends Error {\n readonly url: string;\n\n readonly status: number;\n\n readonly statusText: string;\n\n readonly data: any;\n\n readonly request: AptosRequest;\n\n constructor(request: AptosRequest, response: AptosResponse<any, any>, message: string) {\n super(message);\n\n this.name = \"AptosApiError\";\n this.url = response.url;\n this.status = response.status;\n this.statusText = response.statusText;\n this.data = response.data;\n this.request = request;\n }\n}\n","import { aptosRequest } from \"./core\";\nimport { AptosRequest, AptosResponse } from \"./types\";\n\nexport type GetRequestOptions = Omit<AptosRequest, \"body\" | \"method\">;\n\n/**\n * Main function to do a Get request\n *\n * @param options GetRequestOptions\n * @returns\n */\nexport async function get<Req, Res>(options: GetRequestOptions): Promise<AptosResponse<Req, Res>> {\n const response: AptosResponse<Req, Res> = await aptosRequest<Req, Res>({ ...options, method: \"GET\" });\n return response;\n}\n","import { aptosRequest } from \"./core\";\nimport { AptosRequest, AptosResponse } from \"./types\";\n\nexport type PostRequestOptions = Omit<AptosRequest, \"method\">;\n\n/**\n * Main function to do a Post request\n *\n * @param options PostRequestOptions\n * @returns\n */\nexport async function post<Req, Res>(options: PostRequestOptions): Promise<AptosResponse<Req, Res>> {\n const response: AptosResponse<Req, Res> = await aptosRequest<Req, Res>({ ...options, method: \"POST\" });\n return response;\n}\n","import { ClientConfig, get } from \"../client\";\n\n/// This function is a helper for paginating using a function wrapping an API\nexport async function paginateWithCursor<Req extends Record<string, any>, Res extends any[]>(options: {\n url: string;\n endpoint?: string;\n body?: any;\n params?: Req;\n originMethod?: string;\n overrides?: ClientConfig;\n}): Promise<Res> {\n const out = [];\n let cursor: string | undefined;\n const requestParams = options.params as Req & { start?: string };\n // eslint-disable-next-line no-constant-condition\n while (true) {\n requestParams.start = cursor;\n // eslint-disable-next-line no-await-in-loop\n const response = await get<Req, Res>({\n url: options.url,\n endpoint: options.endpoint,\n params: requestParams,\n originMethod: options.originMethod,\n overrides: options.overrides,\n });\n // eslint-disable-next-line no-underscore-dangle\n /**\n * the cursor is a \"state key\" from the API prespective. Client\n * should not need to \"care\" what it represents but just use it\n * to query the next chunck of data.\n */\n cursor = response.headers[\"x-aptos-cursor\"];\n // Now that we have the cursor (if any), we remove the headers before\n // adding these to the output of this function.\n // eslint-disable-next-line no-underscore-dangle\n delete (response as any).headers;\n out.push(...response.data);\n if (cursor === null || cursor === undefined) {\n break;\n }\n }\n return out as any;\n}\n","export const NetworkToIndexerAPI: Record<string, string> = {\n mainnet: \"https://indexer.mainnet.aptoslabs.com/v1/graphql\",\n testnet: \"https://indexer-testnet.staging.gcp.aptosdev.com/v1/graphql\",\n devnet: \"https://indexer-devnet.staging.gcp.aptosdev.com/v1/graphql\",\n local: \"http://127.0.0.1:8090/v1/graphql\",\n};\n\nexport const NetworkToNodeAPI: Record<string, string> = {\n mainnet: \"https://fullnode.mainnet.aptoslabs.com/v1\",\n testnet: \"https://fullnode.testnet.aptoslabs.com/v1\",\n devnet: \"https://fullnode.devnet.aptoslabs.com/v1\",\n local: \"http://127.0.0.1:8080/v1\",\n};\n\nexport const NodeAPIToNetwork: Record<string, string> = {\n \"https://fullnode.mainnet.aptoslabs.com/v1\": \"mainnet\",\n \"https://fullnode.testnet.aptoslabs.com/v1\": \"testnet\",\n \"https://fullnode.devnet.aptoslabs.com/v1\": \"devnet\",\n \"http://127.0.0.1:8080/v1\": \"local\",\n};\n\nexport enum Network {\n MAINNET = \"mainnet\",\n TESTNET = \"testnet\",\n DEVNET = \"devnet\",\n LOCAL = \"local\",\n}\n\nexport interface CustomEndpoints {\n fullnodeUrl: string;\n indexerUrl?: string;\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bytesToHex, hexToBytes } from \"@noble/hashes/utils\";\nimport { HexEncodedBytes } from \"../generated\";\n\n// eslint-disable-next-line no-use-before-define\nexport type MaybeHexString = HexString | string | HexEncodedBytes;\n\n/**\n * A util class for working with hex strings.\n * Hex strings are strings that are prefixed with `0x`\n */\nexport class HexString {\n /// We want to make sure this hexString has the `0x` hex prefix\n private readonly hexString: string;\n\n /**\n * Creates new hex string from Buffer\n * @param buffer A buffer to convert\n * @returns New HexString\n */\n static fromBuffer(buffer: Uint8Array): HexString {\n return HexString.fromUint8Array(buffer);\n }\n\n /**\n * Creates new hex string from Uint8Array\n * @param arr Uint8Array to convert\n * @returns New HexString\n */\n static fromUint8Array(arr: Uint8Array): HexString {\n return new HexString(bytesToHex(arr));\n }\n\n /**\n * Ensures `hexString` is instance of `HexString` class\n * @param hexString String to check\n * @returns New HexString if `hexString` is regular string or `hexString` if it is HexString instance\n * @example\n * ```\n * const regularString = \"string\";\n * const hexString = new HexString(\"string\"); // \"0xstring\"\n * HexString.ensure(regularString); // \"0xstring\"\n * HexString.ensure(hexString); // \"0xstring\"\n * ```\n */\n static ensure(hexString: MaybeHexString): HexString {\n if (typeof hexString === \"string\") {\n return new HexString(hexString);\n }\n return hexString;\n }\n\n /**\n * Creates new HexString instance from regular string. If specified string already starts with \"0x\" prefix,\n * it will not add another one\n * @param hexString String to convert\n * @example\n * ```\n * const string = \"string\";\n * new HexString(string); // \"0xstring\"\n * ```\n */\n constructor(hexString: string | HexEncodedBytes) {\n if (hexString.startsWith(\"0x\")) {\n this.hexString = hexString;\n } else {\n this.hexString = `0x${hexString}`;\n }\n }\n\n /**\n * Getter for inner hexString\n * @returns Inner hex string\n */\n hex(): string {\n return this.hexString;\n }\n\n /**\n * Getter for inner hexString without prefix\n * @returns Inner hex string without prefix\n * @example\n * ```\n * const hexString = new HexString(\"string\"); // \"0xstring\"\n * hexString.noPrefix(); // \"string\"\n * ```\n */\n noPrefix(): string {\n return this.hexString.slice(2);\n }\n\n /**\n * Overrides default `toString` method\n * @returns Inner hex string\n */\n toString(): string {\n return this.hex();\n }\n\n /**\n * Trimmes extra zeroes in the begining of a string\n * @returns Inner hexString without leading zeroes\n * @example\n * ```\n * new HexString(\"0x000000string\").toShortString(); // result = \"0xstring\"\n * ```\n */\n toShortString(): string {\n const trimmed = this.hexString.replace(/^0x0*/, \"\");\n return `0x${trimmed}`;\n }\n\n /**\n * Converts hex string to a Uint8Array\n * @returns Uint8Array from inner hexString without prefix\n */\n toUint8Array(): Uint8Array {\n return Uint8Array.from(hexToBytes(this.noPrefix()));\n }\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from \"./abi\";\nexport * from \"./account_address\";\nexport * from \"./authenticator\";\nexport * from \"./transaction\";\nexport * from \"./type_tag\";\nexport * from \"./identifier\";\nexport * from \"./ed25519\";\nexport * from \"./multi_ed25519\";\nexport * from \"./authentication_key\";\nexport * from \"./rotation_proof_challenge\";\n\nexport type SigningMessage = Uint8Array;\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from \"./types\";\nexport * from \"./serializer\";\nexport * from \"./deserializer\";\nexport * from \"./helper\";\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Uint128, Uint16, Uint32, Uint64, Uint8, Uint256 } from \"./types\";\n\n// Upper bound values for uint8, uint16, uint64 and uint128\nexport const MAX_U8_NUMBER: Uint8 = 2 ** 8 - 1;\nexport const MAX_U16_NUMBER: Uint16 = 2 ** 16 - 1;\nexport const MAX_U32_NUMBER: Uint32 = 2 ** 32 - 1;\nexport const MAX_U64_BIG_INT: Uint64 = BigInt(2 ** 64) - BigInt(1);\nexport const MAX_U128_BIG_INT: Uint128 = BigInt(2 ** 128) - BigInt(1);\nexport const MAX_U256_BIG_INT: Uint256 = BigInt(2 ** 256) - BigInt(1);\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable no-bitwise */\nimport {\n MAX_U128_BIG_INT,\n MAX_U16_NUMBER,\n MAX_U32_NUMBER,\n MAX_U64_BIG_INT,\n MAX_U8_NUMBER,\n MAX_U256_BIG_INT,\n} from \"./consts\";\nimport { AnyNumber, Bytes, Uint16, Uint32, Uint8 } from \"./types\";\n\nexport class Serializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\n\n constructor() {\n this.buffer = new ArrayBuffer(64);\n this.offset = 0;\n }\n\n private ensureBufferWillHandleSize(bytes: number) {\n while (this.buffer.byteLength < this.offset + bytes) {\n const newBuffer = new ArrayBuffer(this.buffer.byteLength * 2);\n new Uint8Array(newBuffer).set(new Uint8Array(this.buffer));\n this.buffer = newBuffer;\n }\n }\n\n protected serialize(values: Bytes) {\n this.ensureBufferWillHandleSize(values.length);\n new Uint8Array(this.buffer, this.offset).set(values);\n this.offset += values.length;\n }\n\n private serializeWithFunction(\n fn: (byteOffset: number, value: number, littleEndian?: boolean) => void,\n bytesLength: number,\n value: number,\n ) {\n this.ensureBufferWillHandleSize(bytesLength);\n const dv = new DataView(this.buffer, this.offset);\n fn.apply(dv, [0, value, true]);\n this.offset += bytesLength;\n }\n\n /**\n * Serializes a string. UTF8 string is supported. Serializes the string's bytes length \"l\" first,\n * and then serializes \"l\" bytes of the string content.\n *\n * BCS layout for \"string\": string_length | string_content. string_length is the bytes length of\n * the string that is uleb128 encoded. string_length is a u32 integer.\n *\n * @example\n * ```ts\n * const serializer = new Serializer();\n * serializer.serializeStr(\"çå∞≠¢õß∂ƒ∫\");\n * assert(serializer.getBytes() === new Uint8Array([24, 0xc3, 0xa7, 0xc3, 0xa5, 0xe2, 0x88, 0x9e,\n * 0xe2, 0x89, 0xa0, 0xc2, 0xa2, 0xc3, 0xb5, 0xc3, 0x9f, 0xe2, 0x88, 0x82, 0xc6, 0x92, 0xe2, 0x88, 0xab]));\n * ```\n */\n serializeStr(value: string): void {\n const textEncoder = new TextEncoder();\n this.serializeBytes(textEncoder.encode(value));\n }\n\n /**\n * Serializes an array of bytes.\n *\n * BCS layout for \"bytes\": bytes_length | bytes. bytes_length is the length of the bytes array that is\n * uleb128 encoded. bytes_length is a u32 integer.\n */\n serializeBytes(value: Bytes): void {\n this.serializeU32AsUleb128(value.length);\n this.serialize(value);\n }\n\n /**\n * Serializes an array of bytes with known length. Therefore length doesn't need to be\n * serialized to help deserialization. When deserializing, the number of\n * bytes to deserialize needs to be passed in.\n */\n serializeFixedBytes(value: Bytes): void {\n this.serialize(value);\n }\n\n /**\n * Serializes a boolean value.\n *\n * BCS layout for \"boolean\": One byte. \"0x01\" for True and \"0x00\" for False.\n */\n serializeBool(value: boolean): void {\n if (typeof value !== \"boolean\") {\n throw new Error(\"Value needs to be a boolean\");\n }\n const byteValue = value ? 1 : 0;\n this.serialize(new Uint8Array([byteValue]));\n }\n\n /**\n * Serializes a uint8 number.\n *\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n */\n @checkNumberRange(0, MAX_U8_NUMBER)\n serializeU8(value: Uint8): void {\n this.serialize(new Uint8Array([value]));\n }\n\n /**\n * Serializes a uint16 number.\n *\n * BCS layout for \"uint16\": Two bytes. Binary format in little-endian representation.\n * @example\n * ```ts\n * const serializer = new Serializer();\n * serializer.serializeU16(4660);\n * assert(serializer.getBytes() === new Uint8Array([0x34, 0x12]));\n * ```\n */\n @checkNumberRange(0, MAX_U16_NUMBER)\n serializeU16(value: Uint16): void {\n this.serializeWithFunction(DataView.prototype.setUint16, 2, value);\n }\n\n /**\n * Serializes a uint32 number.\n *\n * BCS layout for \"uint32\": Four bytes. Binary format in little-endian representation.\n * @example\n * ```ts\n * const serializer = new Serializer();\n * serializer.serializeU32(305419896);\n * assert(serializer.getBytes() === new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * ```\n */\n @checkNumberRange(0, MAX_U32_NUMBER)\n serializeU32(value: Uint32): void {\n this.serializeWithFunction(DataView.prototype.setUint32, 4, value);\n }\n\n /**\n * Serializes a uint64 number.\n *\n * BCS layout for \"uint64\": Eight bytes. Binary format in little-endian representation.\n * @example\n * ```ts\n * const serializer = new Serializer();\n * serializer.serializeU64(1311768467750121216);\n * assert(serializer.getBytes() === new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * ```\n */\n @checkNumberRange(BigInt(0), MAX_U64_BIG_INT)\n serializeU64(value: AnyNumber): void {\n const low = BigInt(value.toString()) & BigInt(MAX_U32_NUMBER);\n const high = BigInt(value.toString()) >> BigInt(32);\n\n // write little endian number\n this.serializeU32(Number(low));\n this.serializeU32(Number(high));\n }\n\n /**\n * Serializes a uint128 number.\n *\n * BCS layout for \"uint128\": Sixteen bytes. Binary format in little-endian representation.\n */\n @checkNumberRange(BigInt(0), MAX_U128_BIG_INT)\n serializeU128(value: AnyNumber): void {\n const low = BigInt(value.toString()) & MAX_U64_BIG_INT;\n const high = BigInt(value.toString()) >> BigInt(64);\n\n // write little endian number\n this.serializeU64(low);\n this.serializeU64(high);\n }\n\n /**\n * Serializes a uint256 number.\n *\n * BCS layout for \"uint256\": Sixteen bytes. Binary format in little-endian representation.\n */\n @checkNumberRange(BigInt(0), MAX_U256_BIG_INT)\n serializeU256(value: AnyNumber): void {\n const low = BigInt(value.toString()) & MAX_U128_BIG_INT;\n const high = BigInt(value.toString()) >> BigInt(128);\n\n // write little endian number\n this.serializeU128(low);\n this.serializeU128(high);\n }\n\n /**\n * Serializes a uint32 number with uleb128.\n *\n * BCS use uleb128 encoding in two cases: (1) lengths of variable-length sequences and (2) tags of enum values\n */\n @checkNumberRange(0, MAX_U32_NUMBER)\n serializeU32AsUleb128(val: Uint32): void {\n let value = val;\n const valueArray = [];\n while (value >>> 7 !== 0) {\n valueArray.push((value & 0x7f) | 0x80);\n value >>>= 7;\n }\n valueArray.push(value);\n this.serialize(new Uint8Array(valueArray));\n }\n\n /**\n * Returns the buffered bytes\n */\n getBytes(): Bytes {\n return new Uint8Array(this.buffer).slice(0, this.offset);\n }\n}\n\n/**\n * Creates a decorator to make sure the arg value of the decorated function is within a range.\n * @param minValue The arg value of decorated function must >= minValue\n * @param maxValue The arg value of decorated function must <= maxValue\n * @param message Error message\n */\nfunction checkNumberRange<T extends AnyNumber>(minValue: T, maxValue: T, message?: string) {\n return (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => {\n const childFunction = descriptor.value;\n // eslint-disable-next-line no-param-reassign\n descriptor.value = function deco(value: AnyNumber) {\n const valueBigInt = BigInt(value.toString());\n if (valueBigInt > BigInt(maxValue.toString()) || valueBigInt < BigInt(minValue.toString())) {\n throw new Error(message || \"Value is out of range\");\n }\n childFunction.apply(this, [value]);\n };\n return descriptor;\n };\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable no-bitwise */\nimport { MAX_U32_NUMBER } from \"./consts\";\nimport { Bytes, Uint128, Uint16, Uint256, Uint32, Uint64, Uint8 } from \"./types\";\n\nexport class Deserializer {\n private buffer: ArrayBuffer;\n\n private offset: number;\n\n constructor(data: Bytes) {\n // copies data to prevent outside mutation of buffer.\n this.buffer = new ArrayBuffer(data.length);\n new Uint8Array(this.buffer).set(data, 0);\n this.offset = 0;\n }\n\n private read(length: number): ArrayBuffer {\n if (this.offset + length > this.buffer.byteLength) {\n throw new Error(\"Reached to the end of buffer\");\n }\n\n const bytes = this.buffer.slice(this.offset, this.offset + length);\n this.offset += length;\n return bytes;\n }\n\n /**\n * Deserializes a string. UTF8 string is supported. Reads the string's bytes length \"l\" first,\n * and then reads \"l\" bytes of content. Decodes the byte array into a string.\n *\n * BCS layout for \"string\": string_length | string_content. string_length is the bytes length of\n * the string that is uleb128 encoded. string_length is a u32 integer.\n *\n * @example\n * ```ts\n * const deserializer = new Deserializer(new Uint8Array([24, 0xc3, 0xa7, 0xc3, 0xa5, 0xe2, 0x88, 0x9e,\n * 0xe2, 0x89, 0xa0, 0xc2, 0xa2, 0xc3, 0xb5, 0xc3, 0x9f, 0xe2, 0x88, 0x82, 0xc6, 0x92, 0xe2, 0x88, 0xab]));\n * assert(deserializer.deserializeStr() === \"çå∞≠¢õß∂ƒ∫\");\n * ```\n */\n deserializeStr(): string {\n const value = this.deserializeBytes();\n const textDecoder = new TextDecoder();\n return textDecoder.decode(value);\n }\n\n /**\n * Deserializes an array of bytes.\n *\n * BCS layout for \"bytes\": bytes_length | bytes. bytes_length is the length of the bytes array that is\n * uleb128 encoded. bytes_length is a u32 integer.\n */\n deserializeBytes(): Bytes {\n const len = this.deserializeUleb128AsU32();\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes an array of bytes. The number of bytes to read is already known.\n *\n */\n deserializeFixedBytes(len: number): Bytes {\n return new Uint8Array(this.read(len));\n }\n\n /**\n * Deserializes a boolean value.\n *\n * BCS layout for \"boolean\": One byte. \"0x01\" for True and \"0x00\" for False.\n */\n deserializeBool(): boolean {\n const bool = new Uint8Array(this.read(1))[0];\n if (bool !== 1 && bool !== 0) {\n throw new Error(\"Invalid boolean value\");\n }\n return bool === 1;\n }\n\n /**\n * Deserializes a uint8 number.\n *\n * BCS layout for \"uint8\": One byte. Binary format in little-endian representation.\n */\n deserializeU8(): Uint8 {\n return new DataView(this.read(1)).getUint8(0);\n }\n\n /**\n * Deserializes a uint16 number.\n *\n * BCS layout for \"uint16\": Two bytes. Binary format in little-endian representation.\n * @example\n * ```ts\n * const deserializer = new Deserializer(new Uint8Array([0x34, 0x12]));\n * assert(deserializer.deserializeU16() === 4660);\n * ```\n */\n deserializeU16(): Uint16 {\n return new DataView(this.read(2)).getUint16(0, true);\n }\n\n /**\n * Deserializes a uint32 number.\n *\n * BCS layout for \"uint32\": Four bytes. Binary format in little-endian representation.\n * @example\n * ```ts\n * const deserializer = new Deserializer(new Uint8Array([0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU32() === 305419896);\n * ```\n */\n deserializeU32(): Uint32 {\n return new DataView(this.read(4)).getUint32(0, true);\n }\n\n /**\n * Deserializes a uint64 number.\n *\n * BCS layout for \"uint64\": Eight bytes. Binary format in little-endian representation.\n * @example\n * ```ts\n * const deserializer = new Deserializer(new Uint8Array([0x00, 0xEF, 0xCD, 0xAB, 0x78, 0x56, 0x34, 0x12]));\n * assert(deserializer.deserializeU64() === 1311768467750121216);\n * ```\n */\n deserializeU64(): Uint64 {\n const low = this.deserializeU32();\n const high = this.deserializeU32();\n\n // combine the two 32-bit values and return (little endian)\n return BigInt((BigInt(high) << BigInt(32)) | BigInt(low));\n }\n\n /**\n * Deserializes a uint128 number.\n *\n * BCS layout for \"uint128\": Sixteen bytes. Binary format in little-endian representation.\n */\n deserializeU128(): Uint128 {\n const low = this.deserializeU64();\n const high = this.deserializeU64();\n\n // combine the two 64-bit values and return (little endian)\n return BigInt((high << BigInt(64)) | low);\n }\n\n /**\n * Deserializes a uint256 number.\n *\n * BCS layout for \"uint256\": Thirty-two bytes. Binary format in little-endian representation.\n */\n deserializeU256(): Uint256 {\n const low = this.deserializeU128();\n const high = this.deserializeU128();\n\n // combine the two 128-bit values and return (little endian)\n return BigInt((high << BigInt(128)) | low);\n }\n\n /**\n * Deserializes a uleb128 encoded uint32 number.\n *\n * BCS use uleb128 encoding in two cases: (1) lengths of variable-length sequences and (2) tags of enum values\n */\n deserializeUleb128AsU32(): Uint32 {\n let value: bigint = BigInt(0);\n let shift = 0;\n\n while (value < MAX_U32_NUMBER) {\n const byte = this.deserializeU8();\n value |= BigInt(byte & 0x7f) << BigInt(shift);\n\n if ((byte & 0x80) === 0) {\n break;\n }\n shift += 7;\n }\n\n if (value > MAX_U32_NUMBER) {\n throw new Error(\"Overflow while parsing uleb128-encoded uint32 value\");\n }\n\n return Number(value);\n }\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\nimport { Deserializer } from \"./deserializer\";\nimport { Serializer } from \"./serializer\";\nimport { AnyNumber, Bytes, Seq, Uint16, Uint32, Uint8 } from \"./types\";\n\ninterface Serializable {\n serialize(serializer: Serializer): void;\n}\n\n/**\n * Serializes a vector values that are \"Serializable\".\n */\nexport function serializeVector<T extends Serializable>(value: Seq<T>, serializer: Serializer): void {\n serializer.serializeU32AsUleb128(value.length);\n value.forEach((item: T) => {\n item.serialize(serializer);\n });\n}\n\n/**\n * Serializes a vector with specified item serialization function.\n * Very dynamic function and bypasses static typechecking.\n */\nexport function serializeVectorWithFunc(value: any[], func: string): Bytes {\n const serializer = new Serializer();\n serializer.serializeU32AsUleb128(value.length);\n const f = (serializer as any)[func];\n value.forEach((item) => {\n f.call(serializer, item);\n });\n return serializer.getBytes();\n}\n\n/**\n * Deserializes a vector of values.\n */\nexport function deserializeVector(deserializer: Deserializer, cls: any): any[] {\n const length = deserializer.deserializeUleb128AsU32();\n const list: Seq<typeof cls> = [];\n for (let i = 0; i < length; i += 1) {\n list.push(cls.deserialize(deserializer));\n }\n return list;\n}\n\nexport function bcsToBytes<T extends Serializable>(value: T): Bytes {\n const serializer = new Serializer();\n value.serialize(serializer);\n return serializer.getBytes();\n}\n\nexport function bcsSerializeUint64(value: AnyNumber): Bytes {\n const serializer = new Serializer();\n serializer.serializeU64(value);\n return serializer.getBytes();\n}\n\nexport function bcsSerializeU8(value: Uint8): Bytes {\n const serializer = new Serializer();\n serializer.serializeU8(value);\n return serializer.getBytes();\n}\n\nexport function bcsSerializeU16(value: Uint16): Bytes {\n const serializer = new Serializer();\n serializer.serializeU16(value);\n return serializer.getBytes();\n}\n\nexport function bcsSerializeU32(value: Uint32): Bytes {\n const serializer = new Serializer();\n serializer.serializeU32(value);\n return serializer.getBytes();\n}\n\nexport function bcsSerializeU128(value: AnyNumber): Bytes {\n const serializer = new Serializer();\n serializer.serializeU128(value);\n return serializer.getBytes();\n}\n\nexport function bcsSerializeU256(value: AnyNumber): Bytes {\n const serializer = new Serializer();\n serializer.serializeU256(value);\n return serializer.getBytes();\n}\n\nexport function bcsSerializeBool(value: boolean): Bytes {\n const serializer = new Serializer();\n serializer.serializeBool(value);\n return serializer.getBytes();\n}\n\nexport function bcsSerializeStr(value: string): Bytes {\n const serializer = new Serializer();\n serializer.serializeStr(value);\n return serializer.getBytes();\n}\n\nexport function bcsSerializeBytes(value: Bytes): Bytes {\n const serializer = new Serializer();\n serializer.serializeBytes(value);\n return serializer.getBytes();\n}\n\nexport function bcsSerializeFixedBytes(value: Bytes): Bytes {\n const serializer = new Serializer();\n serializer.serializeFixedBytes(value);\n return serializer.getBytes();\n}\n","// Copyright © Aptos Foundation\n// SPDX-License-Identifier: Apache-2.0\n\n/* eslint-disable @typescript-eslint/naming-convention */\n/* eslint-disable class-methods-use-this */\n/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable max-classes-per-file */\nimport { sha3_256 as sha3Hash } from \"@noble/hashes/sha3\";\nimport { HexString } from \"../utils\";\nimport {\n Deserializer,\n Serializer,\n Uint64,\n Bytes,\n Seq,\n Uint8,\n Uint128,\n deserializeVector,\n serializeVector,\n bcsToBytes,\n Uint16,\n Uint256,\n} from \"../bcs\";\nimport { AccountAuthenticator, TransactionAuthenticator, TransactionAuthenticatorMultiAgent } from \"./authenticator\";\nimport { Identifier } from \"./identifier\";\nimport { TypeTag } from \"./type_tag\";\nimport { AccountAddress } from \"./account_address\";\n\nexport class RawTransaction {\n /**\n * RawTransactions contain the metadata and payloads that can be submitted to Aptos chain for execution.\n * RawTransactions must be signed before Aptos chain can execute them.\n *\n * @param sender Account address of the sender.\n * @param sequence_number Sequence number of this transaction. This must match the sequence number stored in\n * the sender's account at the time the transaction executes.\n * @param payload Instructions for the Aptos Blockchain, including publishing a module,\n * execute a entry function or execute a script payload.\n * @param max_gas_amount Maximum total gas to spend for this transaction. The account must have more\n * than this gas or the transaction will be discarded during validation.\n * @param gas_unit_price Price to be paid per gas unit.\n * @param expiration_timestamp_secs The blockchain timestamp at which the blockchain would discard this transaction.\n * @param chain_id The chain ID of the blockchain that this transaction is intended to be run on.\n */\n constructor(\n public readonly sender: AccountAddress,\n public readonly sequence_number: Uint64,\n public readonly payload: TransactionPayload,\n public readonly max_gas_amount: Uint64,\n public readonly gas_unit_price: Uint64,\n public readonly expiration_timestamp_secs: Uint64,\n public reado