From a8c35e0a3733e16f78cc51708370d7aff1d769c7 Mon Sep 17 00:00:00 2001 From: George Mitenkov Date: Thu, 10 Aug 2023 10:20:28 +0200 Subject: [PATCH] [refactoring] Remove unused genesis check from StateView (#9589) `is_genesis()` was defined in `StateView` but never used apart from a single test with `MockVM`. But the test set it to false always... Removing it to have better view interfaces. --- .../typescript/sdk_v2/src/api/account.ts | 140 ++++++++++++++++++ ecosystem/typescript/sdk_v2/src/api/aptos.ts | 4 + .../typescript/sdk_v2/src/api/aptos_config.ts | 40 +++-- .../typescript/sdk_v2/src/client/core.ts | 4 +- ecosystem/typescript/sdk_v2/src/client/get.ts | 3 +- .../typescript/sdk_v2/src/client/post.ts | 3 +- .../typescript/sdk_v2/src/client/types.ts | 44 +----- .../sdk_v2/src/core/account_address.ts | 16 +- .../typescript/sdk_v2/src/internal/account.ts | 116 +++++++++++++++ .../sdk_v2/src/types/generated/index.ts | 103 +++++++++++++ .../src/types/generated/models/AccountData.ts | 17 +++ .../generated/models/AccountSignature.ts | 17 +++ .../AccountSignature_Ed25519Signature.ts | 10 ++ .../AccountSignature_MultiEd25519Signature.ts | 10 ++ .../src/types/generated/models/Address.ts | 14 ++ .../src/types/generated/models/AptosError.ts | 22 +++ .../types/generated/models/AptosErrorCode.ts | 31 ++++ .../src/types/generated/models/Block.ts | 26 ++++ .../models/BlockMetadataTransaction.ts | 55 +++++++ .../generated/models/DecodedTableData.ts | 26 ++++ .../types/generated/models/DeleteModule.ts | 19 +++ .../types/generated/models/DeleteResource.ts | 19 +++ .../types/generated/models/DeleteTableItem.ts | 17 +++ .../generated/models/DeletedTableData.ts | 18 +++ .../types/generated/models/DirectWriteSet.ts | 12 ++ .../generated/models/Ed25519Signature.ts | 14 ++ .../models/EncodeSubmissionRequest.ts | 24 +++ .../types/generated/models/EntryFunctionId.ts | 13 ++ .../generated/models/EntryFunctionPayload.ts | 22 +++ .../src/types/generated/models/Event.ts | 21 +++ .../src/types/generated/models/EventGuid.ts | 12 ++ .../generated/models/FeePayerSignature.ts | 26 ++++ .../types/generated/models/GasEstimation.ts | 22 +++ .../types/generated/models/GenesisPayload.ts | 11 ++ .../models/GenesisPayload_WriteSetPayload.ts | 10 ++ .../generated/models/GenesisTransaction.ts | 42 ++++++ .../src/types/generated/models/HashValue.ts | 5 + .../generated/models/HealthCheckSuccess.ts | 11 ++ .../types/generated/models/HexEncodedBytes.ts | 12 ++ .../generated/models/IdentifierWrapper.ts | 5 + .../types/generated/models/IndexResponse.ts | 30 ++++ .../generated/models/ModuleBundlePayload.ts | 10 ++ .../src/types/generated/models/MoveAbility.ts | 5 + .../types/generated/models/MoveFunction.ts | 37 +++++ .../models/MoveFunctionGenericTypeParam.ts | 16 ++ .../models/MoveFunctionVisibility.ts | 12 ++ .../src/types/generated/models/MoveModule.ts | 30 ++++ .../generated/models/MoveModuleBytecode.ts | 15 ++ .../types/generated/models/MoveModuleId.ts | 15 ++ .../types/generated/models/MoveResource.ts | 15 ++ .../generated/models/MoveScriptBytecode.ts | 15 ++ .../src/types/generated/models/MoveStruct.ts | 32 ++++ .../types/generated/models/MoveStructField.ts | 15 ++ .../models/MoveStructGenericTypeParam.ts | 16 ++ .../types/generated/models/MoveStructTag.ts | 24 +++ .../types/generated/models/MoveStructValue.ts | 49 ++++++ .../src/types/generated/models/MoveType.ts | 34 +++++ .../src/types/generated/models/MoveValue.ts | 16 ++ .../generated/models/MultiAgentSignature.ts | 24 +++ .../generated/models/MultiEd25519Signature.ts | 27 ++++ .../types/generated/models/MultisigPayload.ts | 16 ++ .../models/MultisigTransactionPayload.ts | 8 + .../generated/models/PendingTransaction.ts | 24 +++ .../generated/models/RawTableItemRequest.ts | 13 ++ .../src/types/generated/models/RoleType.ts | 8 + .../types/generated/models/ScriptPayload.ts | 22 +++ .../types/generated/models/ScriptWriteSet.ts | 12 ++ .../models/StateCheckpointTransaction.ts | 34 +++++ .../types/generated/models/StateKeyWrapper.ts | 9 ++ .../models/SubmitTransactionRequest.ts | 24 +++ .../generated/models/TableItemRequest.ts | 18 +++ .../src/types/generated/models/Transaction.ts | 15 ++ .../generated/models/TransactionPayload.ts | 14 ++ ...TransactionPayload_EntryFunctionPayload.ts | 10 ++ .../TransactionPayload_ModuleBundlePayload.ts | 10 ++ .../TransactionPayload_MultisigPayload.ts | 10 ++ .../TransactionPayload_ScriptPayload.ts | 10 ++ .../generated/models/TransactionSignature.ts | 14 ++ .../TransactionSignature_Ed25519Signature.ts | 10 ++ .../TransactionSignature_FeePayerSignature.ts | 10 ++ ...ransactionSignature_MultiAgentSignature.ts | 10 ++ ...nsactionSignature_MultiEd25519Signature.ts | 10 ++ .../Transaction_BlockMetadataTransaction.ts | 10 ++ .../models/Transaction_GenesisTransaction.ts | 10 ++ .../models/Transaction_PendingTransaction.ts | 10 ++ .../Transaction_StateCheckpointTransaction.ts | 10 ++ .../models/Transaction_UserTransaction.ts | 10 ++ ...ransactionsBatchSingleSubmissionFailure.ts | 17 +++ .../TransactionsBatchSubmissionResult.ts | 18 +++ .../sdk_v2/src/types/generated/models/U128.ts | 12 ++ .../sdk_v2/src/types/generated/models/U256.ts | 12 ++ .../sdk_v2/src/types/generated/models/U64.ts | 12 ++ .../types/generated/models/UserTransaction.ts | 49 ++++++ .../types/generated/models/VersionedEvent.ts | 22 +++ .../src/types/generated/models/ViewRequest.ts | 22 +++ .../src/types/generated/models/WriteModule.ts | 19 +++ .../types/generated/models/WriteResource.ts | 19 +++ .../src/types/generated/models/WriteSet.ts | 12 ++ .../types/generated/models/WriteSetChange.ts | 16 ++ .../models/WriteSetChange_DeleteModule.ts | 10 ++ .../models/WriteSetChange_DeleteResource.ts | 10 ++ .../models/WriteSetChange_DeleteTableItem.ts | 10 ++ .../models/WriteSetChange_WriteModule.ts | 10 ++ .../models/WriteSetChange_WriteResource.ts | 10 ++ .../models/WriteSetChange_WriteTableItem.ts | 10 ++ .../types/generated/models/WriteSetPayload.ts | 13 ++ .../models/WriteSet_DirectWriteSet.ts | 10 ++ .../models/WriteSet_ScriptWriteSet.ts | 10 ++ .../types/generated/models/WriteTableItem.ts | 18 +++ .../typescript/sdk_v2/src/types/index.ts | 104 +++++++++++++ .../sdk_v2/src/utils/api-endpoints.ts | 4 +- .../typescript/sdk_v2/src/utils/const.ts | 6 + .../sdk_v2/src/utils/paginate_with_cursor.ts | 44 ++++++ .../sdk_v2/tests/e2e/api/account.test.ts | 137 +++++++++++++++++ .../sdk_v2/tests/unit/aptos_config.test.ts | 77 +++++----- 115 files changed, 2445 insertions(+), 102 deletions(-) create mode 100644 ecosystem/typescript/sdk_v2/src/api/account.ts create mode 100644 ecosystem/typescript/sdk_v2/src/internal/account.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/index.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/AccountData.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature_Ed25519Signature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature_MultiEd25519Signature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/Address.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/AptosError.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/AptosErrorCode.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/Block.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/BlockMetadataTransaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/DecodedTableData.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteModule.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteResource.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteTableItem.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/DeletedTableData.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/DirectWriteSet.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/Ed25519Signature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/EncodeSubmissionRequest.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/EntryFunctionId.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/EntryFunctionPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/Event.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/EventGuid.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/FeePayerSignature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/GasEstimation.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisPayload_WriteSetPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisTransaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/HashValue.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/HealthCheckSuccess.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/HexEncodedBytes.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/IdentifierWrapper.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/IndexResponse.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/ModuleBundlePayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveAbility.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunctionGenericTypeParam.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunctionVisibility.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModule.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModuleBytecode.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModuleId.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveResource.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveScriptBytecode.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStruct.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructField.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructGenericTypeParam.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructTag.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructValue.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveType.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MoveValue.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MultiAgentSignature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MultiEd25519Signature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MultisigPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/MultisigTransactionPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/PendingTransaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/RawTableItemRequest.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/RoleType.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/ScriptPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/ScriptWriteSet.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/StateCheckpointTransaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/StateKeyWrapper.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/SubmitTransactionRequest.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TableItemRequest.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_EntryFunctionPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_ModuleBundlePayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_MultisigPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_ScriptPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_Ed25519Signature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_FeePayerSignature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_MultiAgentSignature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_MultiEd25519Signature.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_BlockMetadataTransaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_GenesisTransaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_PendingTransaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_StateCheckpointTransaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_UserTransaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionsBatchSingleSubmissionFailure.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionsBatchSubmissionResult.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/U128.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/U256.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/U64.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/UserTransaction.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/VersionedEvent.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/ViewRequest.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteModule.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteResource.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteModule.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteResource.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteTableItem.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteModule.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteResource.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteTableItem.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetPayload.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet_DirectWriteSet.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet_ScriptWriteSet.ts create mode 100644 ecosystem/typescript/sdk_v2/src/types/generated/models/WriteTableItem.ts create mode 100644 ecosystem/typescript/sdk_v2/src/utils/paginate_with_cursor.ts create mode 100644 ecosystem/typescript/sdk_v2/tests/e2e/api/account.test.ts diff --git a/ecosystem/typescript/sdk_v2/src/api/account.ts b/ecosystem/typescript/sdk_v2/src/api/account.ts new file mode 100644 index 00000000000000..a930c63a9d990a --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/api/account.ts @@ -0,0 +1,140 @@ +import { AptosConfig } from "./aptos_config"; +import { + AccountData, + LedgerVersion, + MoveModuleBytecode, + MoveResource, + MoveResourceType, + PaginationArgs, + Transaction, + HexInput, +} from "../types"; +import { getData, getModule, getModules, getResource, getResources, getTransactions } from "../internal/account"; + +export class Account { + readonly config: AptosConfig; + + constructor(config: AptosConfig) { + this.config = config; + } + + /** + * Queries for an Aptos account given an account address + * + * @param accountAddress Aptos account address + * + * @returns The account data + * + * @example An example of the returned account + * ``` + * { + * sequence_number: "1", + * authentication_key: "0x5307b5f4bc67829097a8ba9b43dba3b88261eeccd1f709d9bde240fc100fbb69" + * } + * ``` + */ + async getData(args: { accountAddress: HexInput }): Promise { + const data = await getData({ aptosConfig: this.config, ...args }); + return data; + } + + /** + * Queries for an acount modules given an account address + * + * Note: In order to get all account modules, this function may call the API + * multiple times as it auto paginates. + * + * @param accountAddress Aptos account address + * @returns Account modules + */ + + async getModules(args: { + accountAddress: HexInput; + options?: PaginationArgs & LedgerVersion; + }): Promise { + const modules = await getModules({ aptosConfig: this.config, ...args }); + return modules; + } + + /** + * Queries for an account module given account address and module name + * + * @param accountAddress Aptos account address + * @param moduleName The name of the module + * + * @returns Account module + * + * @example An example of an account module + * ``` + * { + * bytecode: "0xa11ceb0b0600000006010002030206050807070f0d081c200", + * abi: { address: "0x1" } + * } + * ``` + */ + async getModule(args: { + accountAddress: HexInput; + moduleName: string; + options?: LedgerVersion; + }): Promise { + const module = await getModule({ aptosConfig: this.config, ...args }); + return module; + } + + /** + * Queries account transactions given an account address + * + * Note: In order to get all account transactions, this function may call the API + * multiple times as it auto paginates. + * + * @param accountAddress Aptos account address + * + * @returns The account transactions + */ + async getTransactions(args: { accountAddress: HexInput; options?: PaginationArgs }): Promise { + const transactions = await getTransactions({ aptosConfig: this.config, ...args }); + return transactions; + } + + /** + * Queries account resources given an account address + * + * Note: In order to get all account resources, this function may call the API + * multiple times as it auto paginates. + * + * @param accountAddress Aptos account address + * @returns Account resources + */ + async getResources(args: { + accountAddress: HexInput; + options?: PaginationArgs & LedgerVersion; + }): Promise { + const resources = await getResources({ aptosConfig: this.config, ...args }); + return resources; + } + + /** + * Queries account resource given account address and resource type + * + * @param accountAddress Aptos account address + * @param resourceType String representation of an on-chain Move struct type, i.e "0x1::aptos_coin::AptosCoin" + * + * @returns Account resource + * + * @example An example of an account resource + * ``` + * { + * type: "0x1::aptos_coin::AptosCoin", + * data: { value: 6 } + * } + * ``` + */ + async getResource(args: { + accountAddress: HexInput; + resourceType: MoveResourceType; + options?: LedgerVersion; + }): Promise { + const resource = await getResource({ aptosConfig: this.config, ...args }); + return resource; + } +} diff --git a/ecosystem/typescript/sdk_v2/src/api/aptos.ts b/ecosystem/typescript/sdk_v2/src/api/aptos.ts index 20939ddb80791a..17a32f99bd2982 100644 --- a/ecosystem/typescript/sdk_v2/src/api/aptos.ts +++ b/ecosystem/typescript/sdk_v2/src/api/aptos.ts @@ -1,8 +1,11 @@ +import { Account } from "./account"; import { AptosConfig } from "./aptos_config"; export class Aptos { readonly config: AptosConfig; + readonly account: Account; + /** * This class is the main entry point into Aptos's * APIs and separates functionality into different namespaces. @@ -21,5 +24,6 @@ export class Aptos { */ constructor(settings?: AptosConfig) { this.config = new AptosConfig(settings); + this.account = new Account(this.config); } } diff --git a/ecosystem/typescript/sdk_v2/src/api/aptos_config.ts b/ecosystem/typescript/sdk_v2/src/api/aptos_config.ts index 2bfd56fd929b55..3b662640b4c391 100644 --- a/ecosystem/typescript/sdk_v2/src/api/aptos_config.ts +++ b/ecosystem/typescript/sdk_v2/src/api/aptos_config.ts @@ -1,9 +1,9 @@ -import { ClientConfig } from "../client/types"; +import { AptosSettings, ClientConfig } from "../types"; import { NetworkToNodeAPI, NetworkToFaucetAPI, NetworkToIndexerAPI, Network } from "../utils/api-endpoints"; -import { DEFAULT_NETWORK } from "../utils/const"; +import { AptosApiType, DEFAULT_NETWORK } from "../utils/const"; export class AptosConfig { - readonly network?: Network; + readonly network: Network; readonly fullnode?: string; @@ -13,11 +13,33 @@ export class AptosConfig { readonly clientConfig?: ClientConfig; - constructor(config?: AptosConfig) { - this.network = config?.network ?? DEFAULT_NETWORK; - this.fullnode = config?.fullnode ?? NetworkToNodeAPI[this.network]; - this.faucet = config?.faucet ?? NetworkToFaucetAPI[this.network]; - this.indexer = config?.indexer ?? NetworkToIndexerAPI[this.network]; - this.clientConfig = config?.clientConfig ?? {}; + constructor(settings?: AptosSettings) { + this.network = settings?.network ?? DEFAULT_NETWORK; + this.fullnode = settings?.fullnode; + this.faucet = settings?.faucet; + this.indexer = settings?.indexer; + this.clientConfig = settings?.clientConfig ?? {}; + } + + getRequestUrl(apiType: AptosApiType): string { + switch (apiType) { + case AptosApiType.FULLNODE: + if (this.fullnode !== undefined) return this.fullnode; + if (this.network === Network.CUSTOM && this.fullnode === undefined) + throw new Error("Please provide a custom full node url"); + return NetworkToNodeAPI[this.network]; + case AptosApiType.FAUCET: + if (this.faucet !== undefined) return this.faucet; + if (this.network === Network.CUSTOM && this.faucet === undefined) + throw new Error("Please provide a custom faucet url"); + return NetworkToFaucetAPI[this.network]; + case AptosApiType.INDEXER: + if (this.indexer !== undefined) return this.indexer; + if (this.network === Network.CUSTOM && this.indexer === undefined) + throw new Error("Please provide a custom indexer url"); + return NetworkToIndexerAPI[this.network]; + default: + throw Error(`apiType ${apiType} is not supported`); + } } } diff --git a/ecosystem/typescript/sdk_v2/src/client/core.ts b/ecosystem/typescript/sdk_v2/src/client/core.ts index c8940ea2fcd32a..f0a46e00983c8a 100644 --- a/ecosystem/typescript/sdk_v2/src/client/core.ts +++ b/ecosystem/typescript/sdk_v2/src/client/core.ts @@ -1,6 +1,7 @@ import aptosClient from "@aptos-labs/aptos-client"; -import { AptosApiError, AptosRequest, AptosResponse, ClientConfig } from "./types"; +import { AptosApiError, AptosResponse } from "./types"; import { VERSION } from "../version"; +import { ClientConfig, AptosRequest } from "../types"; /** * Meaningful errors map @@ -69,6 +70,7 @@ export async function aptosRequest(options: AptosRequest): Promise= 200 && result.status < 300) { return result; } + const errorMessage = errors[result.status]; throw new AptosApiError(options, result, errorMessage ?? "Generic Error"); } diff --git a/ecosystem/typescript/sdk_v2/src/client/get.ts b/ecosystem/typescript/sdk_v2/src/client/get.ts index 060f906ce97225..7049909b8697da 100644 --- a/ecosystem/typescript/sdk_v2/src/client/get.ts +++ b/ecosystem/typescript/sdk_v2/src/client/get.ts @@ -1,5 +1,6 @@ -import { AptosRequest, AptosResponse } from "./types"; +import { AptosResponse } from "./types"; import { aptosRequest } from "./core"; +import { AptosRequest } from "../types"; export type GetRequestOptions = Omit; diff --git a/ecosystem/typescript/sdk_v2/src/client/post.ts b/ecosystem/typescript/sdk_v2/src/client/post.ts index 1a96fb4719dc4f..ba7f5cde79c4ae 100644 --- a/ecosystem/typescript/sdk_v2/src/client/post.ts +++ b/ecosystem/typescript/sdk_v2/src/client/post.ts @@ -1,5 +1,6 @@ +import { AptosRequest } from "../types"; import { aptosRequest } from "./core"; -import { AptosRequest, AptosResponse } from "./types"; +import { AptosResponse } from "./types"; export type PostRequestOptions = Omit; diff --git a/ecosystem/typescript/sdk_v2/src/client/types.ts b/ecosystem/typescript/sdk_v2/src/client/types.ts index 7edb37467251ad..36c9afad2a9444 100644 --- a/ecosystem/typescript/sdk_v2/src/client/types.ts +++ b/ecosystem/typescript/sdk_v2/src/client/types.ts @@ -1,41 +1,4 @@ -import { AnyNumber } from "../types"; - -/** - * 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 - */ -export type ClientConfig = { - TOKEN?: string; - HEADERS?: Record; - 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 - */ -export type AptosRequest = { - url: string; - method: "GET" | "POST"; - endpoint?: string; - body?: any; - contentType?: string; - params?: Record; - originMethod?: string; - overrides?: ClientConfig; -}; +import { AptosRequest } from "../types"; /** * The API response type @@ -90,8 +53,3 @@ export class AptosApiError extends Error { this.request = request; } } - -export interface PaginationArgs { - start?: AnyNumber; - limit?: number; -} diff --git a/ecosystem/typescript/sdk_v2/src/core/account_address.ts b/ecosystem/typescript/sdk_v2/src/core/account_address.ts index bf4776bdfab71c..4e2c72e30d5336 100644 --- a/ecosystem/typescript/sdk_v2/src/core/account_address.ts +++ b/ecosystem/typescript/sdk_v2/src/core/account_address.ts @@ -205,20 +205,18 @@ export class AccountAddress { // Check if the address is in LONG form. If it is not, this is only allowed for // special addresses, in which case we check it is in proper SHORT form. - if (args.input.length != AccountAddress.LONG_STRING_LENGTH + 2) { + if (args.input.length !== AccountAddress.LONG_STRING_LENGTH + 2) { if (!address.isSpecial()) { throw new ParsingError( - "The given hex string is not a special address, it must be represented as 0x + 64 chars.", + `The given hex string ${address} is not a special address, it must be represented as 0x + 64 chars.`, AddressInvalidReason.LONG_FORM_REQUIRED_UNLESS_SPECIAL, ); - } else { + } else if (args.input.length !== 3) { // 0x + one hex char is the only valid SHORT form for special addresses. - if (args.input.length != 3) { - throw new ParsingError( - "The given hex string is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.", - AddressInvalidReason.INVALID_PADDING_ZEROES, - ); - } + throw new ParsingError( + "The given hex string is a special address not in LONG form, it must be 0x0 to 0xf without padding zeroes.", + AddressInvalidReason.INVALID_PADDING_ZEROES, + ); } } diff --git a/ecosystem/typescript/sdk_v2/src/internal/account.ts b/ecosystem/typescript/sdk_v2/src/internal/account.ts new file mode 100644 index 00000000000000..d613106039b136 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/internal/account.ts @@ -0,0 +1,116 @@ +import { AptosConfig } from "../api/aptos_config"; +import { + AccountData, + LedgerVersion, + MoveModuleBytecode, + MoveResource, + MoveResourceType, + PaginationArgs, + Transaction, + HexInput, +} from "../types"; +import { get } from "../client"; +import { paginateWithCursor } from "../utils/paginate_with_cursor"; +import { AccountAddress } from "../core"; +import { AptosApiType } from "../utils/const"; + +export async function getData(args: { aptosConfig: AptosConfig; accountAddress: HexInput }): Promise { + const { aptosConfig, accountAddress } = args; + const { data } = await get<{}, AccountData>({ + url: aptosConfig.getRequestUrl(AptosApiType.FULLNODE), + endpoint: `accounts/${AccountAddress.fromHexInput({ input: accountAddress }).toString()}`, + originMethod: "getData", + overrides: { ...aptosConfig.clientConfig }, + }); + return data; +} + +export async function getModules(args: { + aptosConfig: AptosConfig; + accountAddress: HexInput; + options?: PaginationArgs & LedgerVersion; +}): Promise { + const { aptosConfig, accountAddress, options } = args; + const data = await paginateWithCursor<{}, MoveModuleBytecode[]>({ + url: aptosConfig.getRequestUrl(AptosApiType.FULLNODE), + endpoint: `accounts/${AccountAddress.fromHexInput({ input: accountAddress }).toString()}/modules`, + params: { ledger_version: options?.ledgerVersion, start: options?.start, limit: options?.limit ?? 1000 }, + originMethod: "getModules", + overrides: { ...aptosConfig.clientConfig }, + }); + return data; +} + +/** + * Queries for a move module given account address and module name + * + * @param accountAddress Hex-encoded 32 byte Aptos account address + * @param moduleName The name of the module + * @param query.ledgerVersion Specifies ledger version of transactions. By default latest version will be used + * @returns The move module. + */ +export async function getModule(args: { + aptosConfig: AptosConfig; + accountAddress: HexInput; + moduleName: string; + options?: LedgerVersion; +}): Promise { + const { aptosConfig, accountAddress, moduleName, options } = args; + const { data } = await get<{}, MoveModuleBytecode>({ + url: aptosConfig.getRequestUrl(AptosApiType.FULLNODE), + endpoint: `accounts/${AccountAddress.fromHexInput({ input: accountAddress }).toString()}/module/${moduleName}`, + originMethod: "getModule", + params: { ledger_version: options?.ledgerVersion }, + overrides: { ...aptosConfig.clientConfig }, + }); + return data; +} + +export async function getTransactions(args: { + aptosConfig: AptosConfig; + accountAddress: HexInput; + options?: PaginationArgs; +}): Promise { + const { aptosConfig, accountAddress, options } = args; + const data = await paginateWithCursor<{}, Transaction[]>({ + url: aptosConfig.getRequestUrl(AptosApiType.FULLNODE), + endpoint: `accounts/${AccountAddress.fromHexInput({ input: accountAddress }).toString()}/transactions`, + originMethod: "getTransactions", + params: { start: options?.start, limit: options?.limit }, + overrides: { ...aptosConfig.clientConfig }, + }); + return data; +} + +export async function getResources(args: { + aptosConfig: AptosConfig; + accountAddress: HexInput; + options?: PaginationArgs & LedgerVersion; +}): Promise { + const { aptosConfig, accountAddress, options } = args; + const data = await paginateWithCursor<{}, MoveResource[]>({ + url: aptosConfig.getRequestUrl(AptosApiType.FULLNODE), + endpoint: `accounts/${AccountAddress.fromHexInput({ input: accountAddress }).toString()}/resources`, + params: { ledger_version: options?.ledgerVersion, start: options?.start, limit: options?.limit ?? 999 }, + originMethod: "getResources", + overrides: { ...aptosConfig.clientConfig }, + }); + return data; +} + +export async function getResource(args: { + aptosConfig: AptosConfig; + accountAddress: HexInput; + resourceType: MoveResourceType; + options?: LedgerVersion; +}): Promise { + const { aptosConfig, accountAddress, resourceType, options } = args; + const { data } = await get<{}, MoveResource>({ + url: aptosConfig.getRequestUrl(AptosApiType.FULLNODE), + endpoint: `accounts/${AccountAddress.fromHexInput({ input: accountAddress }).toString()}/resource/${resourceType}`, + originMethod: "getResource", + params: { ledger_version: options?.ledgerVersion }, + overrides: { ...aptosConfig.clientConfig }, + }); + return data; +} diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/index.ts b/ecosystem/typescript/sdk_v2/src/types/generated/index.ts new file mode 100644 index 00000000000000..3b2593aebb18d3 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/index.ts @@ -0,0 +1,103 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type { AccountData } from './models/AccountData'; +export type { AccountSignature } from './models/AccountSignature'; +export type { AccountSignature_Ed25519Signature } from './models/AccountSignature_Ed25519Signature'; +export type { AccountSignature_MultiEd25519Signature } from './models/AccountSignature_MultiEd25519Signature'; +export type { Address } from './models/Address'; +export type { AptosError } from './models/AptosError'; +export { AptosErrorCode } from './models/AptosErrorCode'; +export type { Block } from './models/Block'; +export type { BlockMetadataTransaction } from './models/BlockMetadataTransaction'; +export type { DecodedTableData } from './models/DecodedTableData'; +export type { DeletedTableData } from './models/DeletedTableData'; +export type { DeleteModule } from './models/DeleteModule'; +export type { DeleteResource } from './models/DeleteResource'; +export type { DeleteTableItem } from './models/DeleteTableItem'; +export type { DirectWriteSet } from './models/DirectWriteSet'; +export type { Ed25519Signature } from './models/Ed25519Signature'; +export type { EncodeSubmissionRequest } from './models/EncodeSubmissionRequest'; +export type { EntryFunctionId } from './models/EntryFunctionId'; +export type { EntryFunctionPayload } from './models/EntryFunctionPayload'; +export type { Event } from './models/Event'; +export type { EventGuid } from './models/EventGuid'; +export type { FeePayerSignature } from './models/FeePayerSignature'; +export type { GasEstimation } from './models/GasEstimation'; +export type { GenesisPayload } from './models/GenesisPayload'; +export type { GenesisPayload_WriteSetPayload } from './models/GenesisPayload_WriteSetPayload'; +export type { GenesisTransaction } from './models/GenesisTransaction'; +export type { HashValue } from './models/HashValue'; +export type { HealthCheckSuccess } from './models/HealthCheckSuccess'; +export type { HexEncodedBytes } from './models/HexEncodedBytes'; +export type { IdentifierWrapper } from './models/IdentifierWrapper'; +export type { IndexResponse } from './models/IndexResponse'; +export type { ModuleBundlePayload } from './models/ModuleBundlePayload'; +export type { MoveAbility } from './models/MoveAbility'; +export type { MoveFunction } from './models/MoveFunction'; +export type { MoveFunctionGenericTypeParam } from './models/MoveFunctionGenericTypeParam'; +export { MoveFunctionVisibility } from './models/MoveFunctionVisibility'; +export type { MoveModule } from './models/MoveModule'; +export type { MoveModuleBytecode } from './models/MoveModuleBytecode'; +export type { MoveModuleId } from './models/MoveModuleId'; +export type { MoveResource } from './models/MoveResource'; +export type { MoveScriptBytecode } from './models/MoveScriptBytecode'; +export type { MoveStruct } from './models/MoveStruct'; +export type { MoveStructField } from './models/MoveStructField'; +export type { MoveStructGenericTypeParam } from './models/MoveStructGenericTypeParam'; +export type { MoveStructTag } from './models/MoveStructTag'; +export type { MoveStructValue } from './models/MoveStructValue'; +export type { MoveType } from './models/MoveType'; +export type { MoveValue } from './models/MoveValue'; +export type { MultiAgentSignature } from './models/MultiAgentSignature'; +export type { MultiEd25519Signature } from './models/MultiEd25519Signature'; +export type { MultisigPayload } from './models/MultisigPayload'; +export type { MultisigTransactionPayload } from './models/MultisigTransactionPayload'; +export type { PendingTransaction } from './models/PendingTransaction'; +export type { RawTableItemRequest } from './models/RawTableItemRequest'; +export { RoleType } from './models/RoleType'; +export type { ScriptPayload } from './models/ScriptPayload'; +export type { ScriptWriteSet } from './models/ScriptWriteSet'; +export type { StateCheckpointTransaction } from './models/StateCheckpointTransaction'; +export type { StateKeyWrapper } from './models/StateKeyWrapper'; +export type { SubmitTransactionRequest } from './models/SubmitTransactionRequest'; +export type { TableItemRequest } from './models/TableItemRequest'; +export type { Transaction } from './models/Transaction'; +export type { Transaction_BlockMetadataTransaction } from './models/Transaction_BlockMetadataTransaction'; +export type { Transaction_GenesisTransaction } from './models/Transaction_GenesisTransaction'; +export type { Transaction_PendingTransaction } from './models/Transaction_PendingTransaction'; +export type { Transaction_StateCheckpointTransaction } from './models/Transaction_StateCheckpointTransaction'; +export type { Transaction_UserTransaction } from './models/Transaction_UserTransaction'; +export type { TransactionPayload } from './models/TransactionPayload'; +export type { TransactionPayload_EntryFunctionPayload } from './models/TransactionPayload_EntryFunctionPayload'; +export type { TransactionPayload_ModuleBundlePayload } from './models/TransactionPayload_ModuleBundlePayload'; +export type { TransactionPayload_MultisigPayload } from './models/TransactionPayload_MultisigPayload'; +export type { TransactionPayload_ScriptPayload } from './models/TransactionPayload_ScriptPayload'; +export type { TransactionsBatchSingleSubmissionFailure } from './models/TransactionsBatchSingleSubmissionFailure'; +export type { TransactionsBatchSubmissionResult } from './models/TransactionsBatchSubmissionResult'; +export type { TransactionSignature } from './models/TransactionSignature'; +export type { TransactionSignature_Ed25519Signature } from './models/TransactionSignature_Ed25519Signature'; +export type { TransactionSignature_FeePayerSignature } from './models/TransactionSignature_FeePayerSignature'; +export type { TransactionSignature_MultiAgentSignature } from './models/TransactionSignature_MultiAgentSignature'; +export type { TransactionSignature_MultiEd25519Signature } from './models/TransactionSignature_MultiEd25519Signature'; +export type { U128 } from './models/U128'; +export type { U256 } from './models/U256'; +export type { U64 } from './models/U64'; +export type { UserTransaction } from './models/UserTransaction'; +export type { VersionedEvent } from './models/VersionedEvent'; +export type { ViewRequest } from './models/ViewRequest'; +export type { WriteModule } from './models/WriteModule'; +export type { WriteResource } from './models/WriteResource'; +export type { WriteSet } from './models/WriteSet'; +export type { WriteSet_DirectWriteSet } from './models/WriteSet_DirectWriteSet'; +export type { WriteSet_ScriptWriteSet } from './models/WriteSet_ScriptWriteSet'; +export type { WriteSetChange } from './models/WriteSetChange'; +export type { WriteSetChange_DeleteModule } from './models/WriteSetChange_DeleteModule'; +export type { WriteSetChange_DeleteResource } from './models/WriteSetChange_DeleteResource'; +export type { WriteSetChange_DeleteTableItem } from './models/WriteSetChange_DeleteTableItem'; +export type { WriteSetChange_WriteModule } from './models/WriteSetChange_WriteModule'; +export type { WriteSetChange_WriteResource } from './models/WriteSetChange_WriteResource'; +export type { WriteSetChange_WriteTableItem } from './models/WriteSetChange_WriteTableItem'; +export type { WriteSetPayload } from './models/WriteSetPayload'; +export type { WriteTableItem } from './models/WriteTableItem'; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountData.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountData.ts new file mode 100644 index 00000000000000..8df40aa857e6dc --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountData.ts @@ -0,0 +1,17 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { HexEncodedBytes } from './HexEncodedBytes'; +import type { U64 } from './U64'; + +/** + * Account data + * + * A simplified version of the onchain Account resource + */ +export type AccountData = { + sequence_number: U64; + authentication_key: HexEncodedBytes; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature.ts new file mode 100644 index 00000000000000..576d1507de68dd --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature.ts @@ -0,0 +1,17 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { AccountSignature_Ed25519Signature } from './AccountSignature_Ed25519Signature'; +import type { AccountSignature_MultiEd25519Signature } from './AccountSignature_MultiEd25519Signature'; + +/** + * 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. + */ +export type AccountSignature = (AccountSignature_Ed25519Signature | AccountSignature_MultiEd25519Signature); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature_Ed25519Signature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature_Ed25519Signature.ts new file mode 100644 index 00000000000000..3d91da519364ec --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature_Ed25519Signature.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Ed25519Signature } from './Ed25519Signature'; + +export type AccountSignature_Ed25519Signature = ({ + type: string; +} & Ed25519Signature); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature_MultiEd25519Signature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature_MultiEd25519Signature.ts new file mode 100644 index 00000000000000..11acab2ebd4101 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/AccountSignature_MultiEd25519Signature.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { MultiEd25519Signature } from './MultiEd25519Signature'; + +export type AccountSignature_MultiEd25519Signature = ({ + type: string; +} & MultiEd25519Signature); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/Address.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/Address.ts new file mode 100644 index 00000000000000..03c32f6b45d1e1 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/Address.ts @@ -0,0 +1,14 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 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. + * + */ +export type Address = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/AptosError.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/AptosError.ts new file mode 100644 index 00000000000000..ed24d55242befc --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/AptosError.ts @@ -0,0 +1,22 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { AptosErrorCode } from './AptosErrorCode'; + +/** + * This is the generic struct we use for all API errors, it contains a string + * message and an Aptos API specific error code. + */ +export 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; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/AptosErrorCode.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/AptosErrorCode.ts new file mode 100644 index 00000000000000..a20bac5d55260a --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/AptosErrorCode.ts @@ -0,0 +1,31 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * These codes provide more granular error information beyond just the HTTP + * status code of the response. + */ +export 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', +} diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/Block.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/Block.ts new file mode 100644 index 00000000000000..e6c2a57e31af2f --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/Block.ts @@ -0,0 +1,26 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { HashValue } from './HashValue'; +import type { Transaction } from './Transaction'; +import type { U64 } from './U64'; + +/** + * A Block with or without transactions + * + * This contains the information about a transactions along with + * associated transactions if requested + */ +export type Block = { + block_height: U64; + block_hash: HashValue; + block_timestamp: U64; + first_version: U64; + last_version: U64; + /** + * The transactions in the block in sequential order + */ + transactions?: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/BlockMetadataTransaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/BlockMetadataTransaction.ts new file mode 100644 index 00000000000000..9ec5828deedd94 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/BlockMetadataTransaction.ts @@ -0,0 +1,55 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { Event } from './Event'; +import type { HashValue } from './HashValue'; +import type { U64 } from './U64'; +import type { WriteSetChange } from './WriteSetChange'; + +/** + * A block metadata transaction + * + * This signifies the beginning of a block, and contains information + * about the specific block + */ +export type BlockMetadataTransaction = { + version: U64; + hash: HashValue; + state_change_hash: HashValue; + event_root_hash: HashValue; + state_checkpoint_hash?: HashValue; + gas_used: U64; + /** + * Whether the transaction was successful + */ + success: boolean; + /** + * The VM status of the transaction, can tell useful information in a failure + */ + vm_status: string; + accumulator_root_hash: HashValue; + /** + * Final state of resources changed by the transaction + */ + changes: Array; + id: HashValue; + epoch: U64; + round: U64; + /** + * The events emitted at the block creation + */ + events: Array; + /** + * Previous block votes + */ + previous_block_votes_bitvec: Array; + proposer: Address; + /** + * The indices of the proposers who failed to propose + */ + failed_proposer_indices: Array; + timestamp: U64; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/DecodedTableData.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/DecodedTableData.ts new file mode 100644 index 00000000000000..83571f4fe52870 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/DecodedTableData.ts @@ -0,0 +1,26 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Decoded table data + */ +export 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; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteModule.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteModule.ts new file mode 100644 index 00000000000000..44d49ce0ca66a7 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteModule.ts @@ -0,0 +1,19 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { MoveModuleId } from './MoveModuleId'; + +/** + * Delete a module + */ +export type DeleteModule = { + address: Address; + /** + * State key hash + */ + state_key_hash: string; + module: MoveModuleId; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteResource.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteResource.ts new file mode 100644 index 00000000000000..ff863a94910867 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteResource.ts @@ -0,0 +1,19 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { MoveStructTag } from './MoveStructTag'; + +/** + * Delete a resource + */ +export type DeleteResource = { + address: Address; + /** + * State key hash + */ + state_key_hash: string; + resource: MoveStructTag; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteTableItem.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteTableItem.ts new file mode 100644 index 00000000000000..c2655d4f5be068 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/DeleteTableItem.ts @@ -0,0 +1,17 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { DeletedTableData } from './DeletedTableData'; +import type { HexEncodedBytes } from './HexEncodedBytes'; + +/** + * Delete a table item + */ +export type DeleteTableItem = { + state_key_hash: string; + handle: HexEncodedBytes; + key: HexEncodedBytes; + data?: DeletedTableData; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/DeletedTableData.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/DeletedTableData.ts new file mode 100644 index 00000000000000..ccf4fd6e9b3cb8 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/DeletedTableData.ts @@ -0,0 +1,18 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Deleted table data + */ +export type DeletedTableData = { + /** + * Deleted key + */ + key: any; + /** + * Deleted key type + */ + key_type: string; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/DirectWriteSet.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/DirectWriteSet.ts new file mode 100644 index 00000000000000..1c09731f04fe60 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/DirectWriteSet.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Event } from './Event'; +import type { WriteSetChange } from './WriteSetChange'; + +export type DirectWriteSet = { + changes: Array; + events: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/Ed25519Signature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/Ed25519Signature.ts new file mode 100644 index 00000000000000..27686cec889c45 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/Ed25519Signature.ts @@ -0,0 +1,14 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { HexEncodedBytes } from './HexEncodedBytes'; + +/** + * A single Ed25519 signature + */ +export type Ed25519Signature = { + public_key: HexEncodedBytes; + signature: HexEncodedBytes; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/EncodeSubmissionRequest.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/EncodeSubmissionRequest.ts new file mode 100644 index 00000000000000..52e6f903e6f005 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/EncodeSubmissionRequest.ts @@ -0,0 +1,24 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { TransactionPayload } from './TransactionPayload'; +import type { U64 } from './U64'; + +/** + * Request to encode a submission + */ +export type EncodeSubmissionRequest = { + sender: Address; + sequence_number: U64; + max_gas_amount: U64; + gas_unit_price: U64; + expiration_timestamp_secs: U64; + payload: TransactionPayload; + /** + * Secondary signer accounts of the request for Multi-agent + */ + secondary_signers?: Array
; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/EntryFunctionId.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/EntryFunctionId.ts new file mode 100644 index 00000000000000..f38310d0c2a1c5 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/EntryFunctionId.ts @@ -0,0 +1,13 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 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. + * + */ +export type EntryFunctionId = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/EntryFunctionPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/EntryFunctionPayload.ts new file mode 100644 index 00000000000000..78a3ee67d866da --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/EntryFunctionPayload.ts @@ -0,0 +1,22 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { EntryFunctionId } from './EntryFunctionId'; +import type { MoveType } from './MoveType'; + +/** + * Payload which runs a single entry function + */ +export type EntryFunctionPayload = { + function: EntryFunctionId; + /** + * Type arguments of the function + */ + type_arguments: Array; + /** + * Arguments of the function + */ + arguments: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/Event.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/Event.ts new file mode 100644 index 00000000000000..a160a00cc0ddeb --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/Event.ts @@ -0,0 +1,21 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { EventGuid } from './EventGuid'; +import type { MoveType } from './MoveType'; +import type { U64 } from './U64'; + +/** + * An event from a transaction + */ +export type Event = { + guid: EventGuid; + sequence_number: U64; + type: MoveType; + /** + * The JSON representation of the event + */ + data: any; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/EventGuid.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/EventGuid.ts new file mode 100644 index 00000000000000..928ad847f5797a --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/EventGuid.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { U64 } from './U64'; + +export type EventGuid = { + creation_number: U64; + account_address: Address; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/FeePayerSignature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/FeePayerSignature.ts new file mode 100644 index 00000000000000..4f01fa13ce8e8e --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/FeePayerSignature.ts @@ -0,0 +1,26 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { AccountSignature } from './AccountSignature'; +import type { Address } from './Address'; + +/** + * Fee payer signature for fee payer transactions + * + * This allows you to have transactions across multiple accounts and with a fee payer + */ +export type FeePayerSignature = { + sender: AccountSignature; + /** + * The other involved parties' addresses + */ + secondary_signer_addresses: Array
; + /** + * The associated signatures, in the same order as the secondary addresses + */ + secondary_signers: Array; + fee_payer_address: Address; + fee_payer_signer: AccountSignature; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/GasEstimation.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/GasEstimation.ts new file mode 100644 index 00000000000000..f8ebd699311c93 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/GasEstimation.ts @@ -0,0 +1,22 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Struct holding the outputs of the estimate gas API + */ +export 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; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisPayload.ts new file mode 100644 index 00000000000000..66d653a68f2797 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisPayload.ts @@ -0,0 +1,11 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { GenesisPayload_WriteSetPayload } from './GenesisPayload_WriteSetPayload'; + +/** + * The writeset payload of the Genesis transaction + */ +export type GenesisPayload = GenesisPayload_WriteSetPayload; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisPayload_WriteSetPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisPayload_WriteSetPayload.ts new file mode 100644 index 00000000000000..a61275063a40a8 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisPayload_WriteSetPayload.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { WriteSetPayload } from './WriteSetPayload'; + +export type GenesisPayload_WriteSetPayload = ({ + type: string; +} & WriteSetPayload); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisTransaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisTransaction.ts new file mode 100644 index 00000000000000..563a8be8fce788 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/GenesisTransaction.ts @@ -0,0 +1,42 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Event } from './Event'; +import type { GenesisPayload } from './GenesisPayload'; +import type { HashValue } from './HashValue'; +import type { U64 } from './U64'; +import type { WriteSetChange } from './WriteSetChange'; + +/** + * The genesis transaction + * + * This only occurs at the genesis transaction (version 0) + */ +export type GenesisTransaction = { + version: U64; + hash: HashValue; + state_change_hash: HashValue; + event_root_hash: HashValue; + state_checkpoint_hash?: HashValue; + gas_used: U64; + /** + * Whether the transaction was successful + */ + success: boolean; + /** + * The VM status of the transaction, can tell useful information in a failure + */ + vm_status: string; + accumulator_root_hash: HashValue; + /** + * Final state of resources changed by the transaction + */ + changes: Array; + payload: GenesisPayload; + /** + * Events emitted during genesis + */ + events: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/HashValue.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/HashValue.ts new file mode 100644 index 00000000000000..a296dd84c2a4be --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/HashValue.ts @@ -0,0 +1,5 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type HashValue = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/HealthCheckSuccess.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/HealthCheckSuccess.ts new file mode 100644 index 00000000000000..ff98f0ed77d30c --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/HealthCheckSuccess.ts @@ -0,0 +1,11 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Representation of a successful healthcheck + */ +export type HealthCheckSuccess = { + message: string; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/HexEncodedBytes.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/HexEncodedBytes.ts new file mode 100644 index 00000000000000..d4a21baf0ce473 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/HexEncodedBytes.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * All bytes (Vec) 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. + * + */ +export type HexEncodedBytes = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/IdentifierWrapper.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/IdentifierWrapper.ts new file mode 100644 index 00000000000000..8bf5d9a71895a1 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/IdentifierWrapper.ts @@ -0,0 +1,5 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type IdentifierWrapper = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/IndexResponse.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/IndexResponse.ts new file mode 100644 index 00000000000000..1ca2519b1a62d6 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/IndexResponse.ts @@ -0,0 +1,30 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { RoleType } from './RoleType'; +import type { U64 } from './U64'; + +/** + * The struct holding all data returned to the client by the + * index endpoint (i.e., GET "/"). Only for responding in JSON + */ +export type IndexResponse = { + /** + * Chain ID of the current chain + */ + chain_id: number; + epoch: U64; + ledger_version: U64; + oldest_ledger_version: U64; + ledger_timestamp: U64; + node_role: RoleType; + oldest_block_height: U64; + block_height: U64; + /** + * Git hash of the build of the API endpoint. Can be used to determine the exact + * software version used by the API endpoint. + */ + git_hash?: string; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/ModuleBundlePayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/ModuleBundlePayload.ts new file mode 100644 index 00000000000000..be34a1f42ecbdf --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/ModuleBundlePayload.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { MoveModuleBytecode } from './MoveModuleBytecode'; + +export type ModuleBundlePayload = { + modules: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveAbility.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveAbility.ts new file mode 100644 index 00000000000000..311c5db9003a8d --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveAbility.ts @@ -0,0 +1,5 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type MoveAbility = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunction.ts new file mode 100644 index 00000000000000..4ce3ad729c26cd --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunction.ts @@ -0,0 +1,37 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { IdentifierWrapper } from './IdentifierWrapper'; +import type { MoveFunctionGenericTypeParam } from './MoveFunctionGenericTypeParam'; +import type { MoveFunctionVisibility } from './MoveFunctionVisibility'; +import type { MoveType } from './MoveType'; + +/** + * Move function + */ +export 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; + /** + * Parameters associated with the move function + */ + params: Array; + /** + * Return type of the function + */ + return: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunctionGenericTypeParam.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunctionGenericTypeParam.ts new file mode 100644 index 00000000000000..c0776fe5cab0cc --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunctionGenericTypeParam.ts @@ -0,0 +1,16 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { MoveAbility } from './MoveAbility'; + +/** + * Move function generic type param + */ +export type MoveFunctionGenericTypeParam = { + /** + * Move abilities tied to the generic type param and associated with the function that uses it + */ + constraints: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunctionVisibility.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunctionVisibility.ts new file mode 100644 index 00000000000000..a1684d5c847138 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveFunctionVisibility.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Move function visibility + */ +export enum MoveFunctionVisibility { + PRIVATE = 'private', + PUBLIC = 'public', + FRIEND = 'friend', +} diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModule.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModule.ts new file mode 100644 index 00000000000000..f2d127ff286149 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModule.ts @@ -0,0 +1,30 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { IdentifierWrapper } from './IdentifierWrapper'; +import type { MoveFunction } from './MoveFunction'; +import type { MoveModuleId } from './MoveModuleId'; +import type { MoveStruct } from './MoveStruct'; + +/** + * A Move module + */ +export type MoveModule = { + address: Address; + name: IdentifierWrapper; + /** + * Friends of the module + */ + friends: Array; + /** + * Public functions of the module + */ + exposed_functions: Array; + /** + * Structs of the module + */ + structs: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModuleBytecode.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModuleBytecode.ts new file mode 100644 index 00000000000000..9348d105310a5b --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModuleBytecode.ts @@ -0,0 +1,15 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { HexEncodedBytes } from './HexEncodedBytes'; +import type { MoveModule } from './MoveModule'; + +/** + * Move module bytecode along with it's ABI + */ +export type MoveModuleBytecode = { + bytecode: HexEncodedBytes; + abi?: MoveModule; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModuleId.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModuleId.ts new file mode 100644 index 00000000000000..5ad74349b690ba --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveModuleId.ts @@ -0,0 +1,15 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 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. + * + */ +export type MoveModuleId = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveResource.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveResource.ts new file mode 100644 index 00000000000000..544bfa47be0530 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveResource.ts @@ -0,0 +1,15 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { MoveStructTag } from './MoveStructTag'; +import type { MoveStructValue } from './MoveStructValue'; + +/** + * A parsed Move resource + */ +export type MoveResource = { + type: MoveStructTag; + data: MoveStructValue; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveScriptBytecode.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveScriptBytecode.ts new file mode 100644 index 00000000000000..109a6cf6bfcf06 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveScriptBytecode.ts @@ -0,0 +1,15 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { HexEncodedBytes } from './HexEncodedBytes'; +import type { MoveFunction } from './MoveFunction'; + +/** + * Move script bytecode + */ +export type MoveScriptBytecode = { + bytecode: HexEncodedBytes; + abi?: MoveFunction; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStruct.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStruct.ts new file mode 100644 index 00000000000000..74dd1d8766e6f4 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStruct.ts @@ -0,0 +1,32 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { IdentifierWrapper } from './IdentifierWrapper'; +import type { MoveAbility } from './MoveAbility'; +import type { MoveStructField } from './MoveStructField'; +import type { MoveStructGenericTypeParam } from './MoveStructGenericTypeParam'; + +/** + * A move struct + */ +export type MoveStruct = { + name: IdentifierWrapper; + /** + * Whether the struct is a native struct of Move + */ + is_native: boolean; + /** + * Abilities associated with the struct + */ + abilities: Array; + /** + * Generic types associated with the struct + */ + generic_type_params: Array; + /** + * Fields associated with the struct + */ + fields: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructField.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructField.ts new file mode 100644 index 00000000000000..3f20b0bfbb72b1 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructField.ts @@ -0,0 +1,15 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { IdentifierWrapper } from './IdentifierWrapper'; +import type { MoveType } from './MoveType'; + +/** + * Move struct field + */ +export type MoveStructField = { + name: IdentifierWrapper; + type: MoveType; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructGenericTypeParam.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructGenericTypeParam.ts new file mode 100644 index 00000000000000..5ff3317db916d5 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructGenericTypeParam.ts @@ -0,0 +1,16 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { MoveAbility } from './MoveAbility'; + +/** + * Move generic type param + */ +export type MoveStructGenericTypeParam = { + /** + * Move abilities tied to the generic type param and associated with the type that uses it + */ + constraints: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructTag.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructTag.ts new file mode 100644 index 00000000000000..254235ddd4b0a1 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructTag.ts @@ -0,0 +1,24 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 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. + * + */ +export type MoveStructTag = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructValue.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructValue.ts new file mode 100644 index 00000000000000..11d4da45739bc1 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveStructValue.ts @@ -0,0 +1,49 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 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` which is serialized into a + * HexEncodedBytes string with `0x` prefix. + * For example: + * - `vector{255, 255}` => `["255", "255"]` + * - `vector{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. + * + */ + export type MoveStructValue = { + }; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveType.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveType.ts new file mode 100644 index 00000000000000..226183770b27cb --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveType.ts @@ -0,0 +1,34 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 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` + * - `vector>` + * - `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). + * + */ +export type MoveType = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveValue.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveValue.ts new file mode 100644 index 00000000000000..899490be8b4da5 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MoveValue.ts @@ -0,0 +1,16 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { HexEncodedBytes } from './HexEncodedBytes'; +import type { MoveStructValue } from './MoveStructValue'; +import type { U128 } from './U128'; +import type { U256 } from './U256'; +import type { U64 } from './U64'; + +/** + * An enum of the possible Move value types + */ +export type MoveValue = (number | U64 | U128 | U256 | boolean | Address | Array | HexEncodedBytes | MoveStructValue | string); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MultiAgentSignature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MultiAgentSignature.ts new file mode 100644 index 00000000000000..f07b81734f79ec --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MultiAgentSignature.ts @@ -0,0 +1,24 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { AccountSignature } from './AccountSignature'; +import type { Address } from './Address'; + +/** + * Multi agent signature for multi agent transactions + * + * This allows you to have transactions across multiple accounts + */ +export type MultiAgentSignature = { + sender: AccountSignature; + /** + * The other involved parties' addresses + */ + secondary_signer_addresses: Array
; + /** + * The associated signatures, in the same order as the secondary addresses + */ + secondary_signers: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MultiEd25519Signature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MultiEd25519Signature.ts new file mode 100644 index 00000000000000..29809a29c6c05e --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MultiEd25519Signature.ts @@ -0,0 +1,27 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { HexEncodedBytes } from './HexEncodedBytes'; + +/** + * A Ed25519 multi-sig signature + * + * This allows k-of-n signing for a transaction + */ +export type MultiEd25519Signature = { + /** + * The public keys for the Ed25519 signature + */ + public_keys: Array; + /** + * Signature associated with the public keys in the same order + */ + signatures: Array; + /** + * The number of signatures required for a successful transaction + */ + threshold: number; + bitmap: HexEncodedBytes; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MultisigPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MultisigPayload.ts new file mode 100644 index 00000000000000..9100a74b3359f1 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MultisigPayload.ts @@ -0,0 +1,16 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { MultisigTransactionPayload } from './MultisigTransactionPayload'; + +/** + * A multisig transaction that allows an owner of a multisig account to execute a pre-approved + * transaction as the multisig account. + */ +export type MultisigPayload = { + multisig_address: Address; + transaction_payload?: MultisigTransactionPayload; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/MultisigTransactionPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/MultisigTransactionPayload.ts new file mode 100644 index 00000000000000..d3191b538308bd --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/MultisigTransactionPayload.ts @@ -0,0 +1,8 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { EntryFunctionPayload } from './EntryFunctionPayload'; + +export type MultisigTransactionPayload = EntryFunctionPayload; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/PendingTransaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/PendingTransaction.ts new file mode 100644 index 00000000000000..2b4ad87fd6b8d0 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/PendingTransaction.ts @@ -0,0 +1,24 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { HashValue } from './HashValue'; +import type { TransactionPayload } from './TransactionPayload'; +import type { TransactionSignature } from './TransactionSignature'; +import type { U64 } from './U64'; + +/** + * A transaction waiting in mempool + */ +export type PendingTransaction = { + hash: HashValue; + sender: Address; + sequence_number: U64; + max_gas_amount: U64; + gas_unit_price: U64; + expiration_timestamp_secs: U64; + payload: TransactionPayload; + signature?: TransactionSignature; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/RawTableItemRequest.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/RawTableItemRequest.ts new file mode 100644 index 00000000000000..e8fc0f8eccd1df --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/RawTableItemRequest.ts @@ -0,0 +1,13 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { HexEncodedBytes } from './HexEncodedBytes'; + +/** + * Table Item request for the GetTableItemRaw API + */ +export type RawTableItemRequest = { + key: HexEncodedBytes; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/RoleType.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/RoleType.ts new file mode 100644 index 00000000000000..f0b5c207d63bf2 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/RoleType.ts @@ -0,0 +1,8 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export enum RoleType { + VALIDATOR = 'validator', + FULL_NODE = 'full_node', +} diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/ScriptPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/ScriptPayload.ts new file mode 100644 index 00000000000000..52cb0a0574352a --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/ScriptPayload.ts @@ -0,0 +1,22 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { MoveScriptBytecode } from './MoveScriptBytecode'; +import type { MoveType } from './MoveType'; + +/** + * Payload which runs a script that can run multiple functions + */ +export type ScriptPayload = { + code: MoveScriptBytecode; + /** + * Type arguments of the function + */ + type_arguments: Array; + /** + * Arguments of the function + */ + arguments: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/ScriptWriteSet.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/ScriptWriteSet.ts new file mode 100644 index 00000000000000..469b780799c7a3 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/ScriptWriteSet.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { ScriptPayload } from './ScriptPayload'; + +export type ScriptWriteSet = { + execute_as: Address; + script: ScriptPayload; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/StateCheckpointTransaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/StateCheckpointTransaction.ts new file mode 100644 index 00000000000000..bfe5b5dbcd2468 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/StateCheckpointTransaction.ts @@ -0,0 +1,34 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { HashValue } from './HashValue'; +import type { U64 } from './U64'; +import type { WriteSetChange } from './WriteSetChange'; + +/** + * A state checkpoint transaction + */ +export type StateCheckpointTransaction = { + version: U64; + hash: HashValue; + state_change_hash: HashValue; + event_root_hash: HashValue; + state_checkpoint_hash?: HashValue; + gas_used: U64; + /** + * Whether the transaction was successful + */ + success: boolean; + /** + * The VM status of the transaction, can tell useful information in a failure + */ + vm_status: string; + accumulator_root_hash: HashValue; + /** + * Final state of resources changed by the transaction + */ + changes: Array; + timestamp: U64; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/StateKeyWrapper.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/StateKeyWrapper.ts new file mode 100644 index 00000000000000..d3939a43e6a778 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/StateKeyWrapper.ts @@ -0,0 +1,9 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * Representation of a StateKey as a hex string. This is used for cursor based pagination. + * + */ +export type StateKeyWrapper = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/SubmitTransactionRequest.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/SubmitTransactionRequest.ts new file mode 100644 index 00000000000000..b850d3f548e2da --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/SubmitTransactionRequest.ts @@ -0,0 +1,24 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { TransactionPayload } from './TransactionPayload'; +import type { TransactionSignature } from './TransactionSignature'; +import type { U64 } from './U64'; + +/** + * A request to submit a transaction + * + * This requires a transaction and a signature of it + */ +export type SubmitTransactionRequest = { + sender: Address; + sequence_number: U64; + max_gas_amount: U64; + gas_unit_price: U64; + expiration_timestamp_secs: U64; + payload: TransactionPayload; + signature: TransactionSignature; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TableItemRequest.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TableItemRequest.ts new file mode 100644 index 00000000000000..18b44286d51650 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TableItemRequest.ts @@ -0,0 +1,18 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { MoveType } from './MoveType'; + +/** + * Table Item request for the GetTableItem API + */ +export type TableItemRequest = { + key_type: MoveType; + value_type: MoveType; + /** + * The value of the table item's key + */ + key: any; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction.ts new file mode 100644 index 00000000000000..0d6bd99e8daa9c --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction.ts @@ -0,0 +1,15 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Transaction_BlockMetadataTransaction } from './Transaction_BlockMetadataTransaction'; +import type { Transaction_GenesisTransaction } from './Transaction_GenesisTransaction'; +import type { Transaction_PendingTransaction } from './Transaction_PendingTransaction'; +import type { Transaction_StateCheckpointTransaction } from './Transaction_StateCheckpointTransaction'; +import type { Transaction_UserTransaction } from './Transaction_UserTransaction'; + +/** + * Enum of the different types of transactions in Aptos + */ +export type Transaction = (Transaction_PendingTransaction | Transaction_UserTransaction | Transaction_GenesisTransaction | Transaction_BlockMetadataTransaction | Transaction_StateCheckpointTransaction); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload.ts new file mode 100644 index 00000000000000..0115a29749beb8 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload.ts @@ -0,0 +1,14 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { TransactionPayload_EntryFunctionPayload } from './TransactionPayload_EntryFunctionPayload'; +import type { TransactionPayload_ModuleBundlePayload } from './TransactionPayload_ModuleBundlePayload'; +import type { TransactionPayload_MultisigPayload } from './TransactionPayload_MultisigPayload'; +import type { TransactionPayload_ScriptPayload } from './TransactionPayload_ScriptPayload'; + +/** + * An enum of the possible transaction payloads + */ +export type TransactionPayload = (TransactionPayload_EntryFunctionPayload | TransactionPayload_ScriptPayload | TransactionPayload_ModuleBundlePayload | TransactionPayload_MultisigPayload); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_EntryFunctionPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_EntryFunctionPayload.ts new file mode 100644 index 00000000000000..d44e5d89a654a5 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_EntryFunctionPayload.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { EntryFunctionPayload } from './EntryFunctionPayload'; + +export type TransactionPayload_EntryFunctionPayload = ({ + type: string; +} & EntryFunctionPayload); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_ModuleBundlePayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_ModuleBundlePayload.ts new file mode 100644 index 00000000000000..0193cb9d97dc59 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_ModuleBundlePayload.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ModuleBundlePayload } from './ModuleBundlePayload'; + +export type TransactionPayload_ModuleBundlePayload = ({ + type: string; +} & ModuleBundlePayload); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_MultisigPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_MultisigPayload.ts new file mode 100644 index 00000000000000..01023dd71e6e9d --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_MultisigPayload.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { MultisigPayload } from './MultisigPayload'; + +export type TransactionPayload_MultisigPayload = ({ + type: string; +} & MultisigPayload); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_ScriptPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_ScriptPayload.ts new file mode 100644 index 00000000000000..9e7feb973092be --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionPayload_ScriptPayload.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ScriptPayload } from './ScriptPayload'; + +export type TransactionPayload_ScriptPayload = ({ + type: string; +} & ScriptPayload); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature.ts new file mode 100644 index 00000000000000..0ddc7dcc48ba22 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature.ts @@ -0,0 +1,14 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { TransactionSignature_Ed25519Signature } from './TransactionSignature_Ed25519Signature'; +import type { TransactionSignature_FeePayerSignature } from './TransactionSignature_FeePayerSignature'; +import type { TransactionSignature_MultiAgentSignature } from './TransactionSignature_MultiAgentSignature'; +import type { TransactionSignature_MultiEd25519Signature } from './TransactionSignature_MultiEd25519Signature'; + +/** + * An enum representing the different transaction signatures available + */ +export type TransactionSignature = (TransactionSignature_Ed25519Signature | TransactionSignature_MultiEd25519Signature | TransactionSignature_MultiAgentSignature | TransactionSignature_FeePayerSignature); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_Ed25519Signature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_Ed25519Signature.ts new file mode 100644 index 00000000000000..0667d1e8bb140c --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_Ed25519Signature.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Ed25519Signature } from './Ed25519Signature'; + +export type TransactionSignature_Ed25519Signature = ({ + type: string; +} & Ed25519Signature); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_FeePayerSignature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_FeePayerSignature.ts new file mode 100644 index 00000000000000..c16bc6bd71d099 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_FeePayerSignature.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { FeePayerSignature } from './FeePayerSignature'; + +export type TransactionSignature_FeePayerSignature = ({ + type: string; +} & FeePayerSignature); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_MultiAgentSignature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_MultiAgentSignature.ts new file mode 100644 index 00000000000000..e74d911d9fb63f --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_MultiAgentSignature.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { MultiAgentSignature } from './MultiAgentSignature'; + +export type TransactionSignature_MultiAgentSignature = ({ + type: string; +} & MultiAgentSignature); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_MultiEd25519Signature.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_MultiEd25519Signature.ts new file mode 100644 index 00000000000000..1f6dc58ada4952 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionSignature_MultiEd25519Signature.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { MultiEd25519Signature } from './MultiEd25519Signature'; + +export type TransactionSignature_MultiEd25519Signature = ({ + type: string; +} & MultiEd25519Signature); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_BlockMetadataTransaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_BlockMetadataTransaction.ts new file mode 100644 index 00000000000000..82067d7479ccfa --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_BlockMetadataTransaction.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { BlockMetadataTransaction } from './BlockMetadataTransaction'; + +export type Transaction_BlockMetadataTransaction = ({ + type: string; +} & BlockMetadataTransaction); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_GenesisTransaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_GenesisTransaction.ts new file mode 100644 index 00000000000000..3bb44fd02883b1 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_GenesisTransaction.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { GenesisTransaction } from './GenesisTransaction'; + +export type Transaction_GenesisTransaction = ({ + type: string; +} & GenesisTransaction); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_PendingTransaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_PendingTransaction.ts new file mode 100644 index 00000000000000..c593c76424f817 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_PendingTransaction.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { PendingTransaction } from './PendingTransaction'; + +export type Transaction_PendingTransaction = ({ + type: string; +} & PendingTransaction); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_StateCheckpointTransaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_StateCheckpointTransaction.ts new file mode 100644 index 00000000000000..90eeda7001b0f7 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_StateCheckpointTransaction.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { StateCheckpointTransaction } from './StateCheckpointTransaction'; + +export type Transaction_StateCheckpointTransaction = ({ + type: string; +} & StateCheckpointTransaction); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_UserTransaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_UserTransaction.ts new file mode 100644 index 00000000000000..8feeed7c2233c2 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/Transaction_UserTransaction.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { UserTransaction } from './UserTransaction'; + +export type Transaction_UserTransaction = ({ + type: string; +} & UserTransaction); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionsBatchSingleSubmissionFailure.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionsBatchSingleSubmissionFailure.ts new file mode 100644 index 00000000000000..98f81af611b515 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionsBatchSingleSubmissionFailure.ts @@ -0,0 +1,17 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { AptosError } from './AptosError'; + +/** + * Information telling which batch submission transactions failed + */ +export type TransactionsBatchSingleSubmissionFailure = { + error: AptosError; + /** + * The index of which transaction failed, same as submission order + */ + transaction_index: number; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionsBatchSubmissionResult.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionsBatchSubmissionResult.ts new file mode 100644 index 00000000000000..43c5d62f8dfba4 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/TransactionsBatchSubmissionResult.ts @@ -0,0 +1,18 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { TransactionsBatchSingleSubmissionFailure } from './TransactionsBatchSingleSubmissionFailure'; + +/** + * Batch transaction submission result + * + * Tells which transactions failed + */ +export type TransactionsBatchSubmissionResult = { + /** + * Summary of the failed transactions + */ + transaction_failures: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/U128.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/U128.ts new file mode 100644 index 00000000000000..d391d4afb9c242 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/U128.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 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. + * + */ +export type U128 = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/U256.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/U256.ts new file mode 100644 index 00000000000000..092d56d8eb4be8 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/U256.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 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. + * + */ +export type U256 = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/U64.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/U64.ts new file mode 100644 index 00000000000000..f8f542c609edbe --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/U64.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +/** + * 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. + * + */ +export type U64 = string; diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/UserTransaction.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/UserTransaction.ts new file mode 100644 index 00000000000000..4aa4e67a37ce34 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/UserTransaction.ts @@ -0,0 +1,49 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { Event } from './Event'; +import type { HashValue } from './HashValue'; +import type { TransactionPayload } from './TransactionPayload'; +import type { TransactionSignature } from './TransactionSignature'; +import type { U64 } from './U64'; +import type { WriteSetChange } from './WriteSetChange'; + +/** + * A transaction submitted by a user to change the state of the blockchain + */ +export type UserTransaction = { + version: U64; + hash: HashValue; + state_change_hash: HashValue; + event_root_hash: HashValue; + state_checkpoint_hash?: HashValue; + gas_used: U64; + /** + * Whether the transaction was successful + */ + success: boolean; + /** + * The VM status of the transaction, can tell useful information in a failure + */ + vm_status: string; + accumulator_root_hash: HashValue; + /** + * Final state of resources changed by the transaction + */ + changes: Array; + sender: Address; + sequence_number: U64; + max_gas_amount: U64; + gas_unit_price: U64; + expiration_timestamp_secs: U64; + payload: TransactionPayload; + signature?: TransactionSignature; + /** + * Events generated by the transaction + */ + events: Array; + timestamp: U64; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/VersionedEvent.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/VersionedEvent.ts new file mode 100644 index 00000000000000..c9934c820268f0 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/VersionedEvent.ts @@ -0,0 +1,22 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { EventGuid } from './EventGuid'; +import type { MoveType } from './MoveType'; +import type { U64 } from './U64'; + +/** + * An event from a transaction with a version + */ +export type VersionedEvent = { + version: U64; + guid: EventGuid; + sequence_number: U64; + type: MoveType; + /** + * The JSON representation of the event + */ + data: any; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/ViewRequest.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/ViewRequest.ts new file mode 100644 index 00000000000000..5fa124b8ef5fa1 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/ViewRequest.ts @@ -0,0 +1,22 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { EntryFunctionId } from './EntryFunctionId'; +import type { MoveType } from './MoveType'; + +/** + * View request for the Move View Function API + */ +export type ViewRequest = { + function: EntryFunctionId; + /** + * Type arguments of the function + */ + type_arguments: Array; + /** + * Arguments of the function + */ + arguments: Array; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteModule.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteModule.ts new file mode 100644 index 00000000000000..b032cc91361248 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteModule.ts @@ -0,0 +1,19 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { MoveModuleBytecode } from './MoveModuleBytecode'; + +/** + * Write a new module or update an existing one + */ +export type WriteModule = { + address: Address; + /** + * State key hash + */ + state_key_hash: string; + data: MoveModuleBytecode; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteResource.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteResource.ts new file mode 100644 index 00000000000000..2bccf200e8ff86 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteResource.ts @@ -0,0 +1,19 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Address } from './Address'; +import type { MoveResource } from './MoveResource'; + +/** + * Write a resource or update an existing one + */ +export type WriteResource = { + address: Address; + /** + * State key hash + */ + state_key_hash: string; + data: MoveResource; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet.ts new file mode 100644 index 00000000000000..ea06d3e6355aab --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { WriteSet_DirectWriteSet } from './WriteSet_DirectWriteSet'; +import type { WriteSet_ScriptWriteSet } from './WriteSet_ScriptWriteSet'; + +/** + * The associated writeset with a payload + */ +export type WriteSet = (WriteSet_ScriptWriteSet | WriteSet_DirectWriteSet); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange.ts new file mode 100644 index 00000000000000..dfcc2cb630bebc --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange.ts @@ -0,0 +1,16 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { WriteSetChange_DeleteModule } from './WriteSetChange_DeleteModule'; +import type { WriteSetChange_DeleteResource } from './WriteSetChange_DeleteResource'; +import type { WriteSetChange_DeleteTableItem } from './WriteSetChange_DeleteTableItem'; +import type { WriteSetChange_WriteModule } from './WriteSetChange_WriteModule'; +import type { WriteSetChange_WriteResource } from './WriteSetChange_WriteResource'; +import type { WriteSetChange_WriteTableItem } from './WriteSetChange_WriteTableItem'; + +/** + * A final state change of a transaction on a resource or module + */ +export type WriteSetChange = (WriteSetChange_DeleteModule | WriteSetChange_DeleteResource | WriteSetChange_DeleteTableItem | WriteSetChange_WriteModule | WriteSetChange_WriteResource | WriteSetChange_WriteTableItem); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteModule.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteModule.ts new file mode 100644 index 00000000000000..3c4252969f5720 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteModule.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { DeleteModule } from './DeleteModule'; + +export type WriteSetChange_DeleteModule = ({ + type: string; +} & DeleteModule); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteResource.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteResource.ts new file mode 100644 index 00000000000000..bfb9924b661a3e --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteResource.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { DeleteResource } from './DeleteResource'; + +export type WriteSetChange_DeleteResource = ({ + type: string; +} & DeleteResource); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteTableItem.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteTableItem.ts new file mode 100644 index 00000000000000..d82340222522d5 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_DeleteTableItem.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { DeleteTableItem } from './DeleteTableItem'; + +export type WriteSetChange_DeleteTableItem = ({ + type: string; +} & DeleteTableItem); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteModule.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteModule.ts new file mode 100644 index 00000000000000..924d279b8c26f6 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteModule.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { WriteModule } from './WriteModule'; + +export type WriteSetChange_WriteModule = ({ + type: string; +} & WriteModule); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteResource.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteResource.ts new file mode 100644 index 00000000000000..e7d4f6be56188d --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteResource.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { WriteResource } from './WriteResource'; + +export type WriteSetChange_WriteResource = ({ + type: string; +} & WriteResource); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteTableItem.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteTableItem.ts new file mode 100644 index 00000000000000..087c9765a7e620 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetChange_WriteTableItem.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { WriteTableItem } from './WriteTableItem'; + +export type WriteSetChange_WriteTableItem = ({ + type: string; +} & WriteTableItem); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetPayload.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetPayload.ts new file mode 100644 index 00000000000000..c15ea62f22d9cd --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSetPayload.ts @@ -0,0 +1,13 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { WriteSet } from './WriteSet'; + +/** + * A writeset payload, used only for genesis + */ +export type WriteSetPayload = { + write_set: WriteSet; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet_DirectWriteSet.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet_DirectWriteSet.ts new file mode 100644 index 00000000000000..552e98d4833a5a --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet_DirectWriteSet.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { DirectWriteSet } from './DirectWriteSet'; + +export type WriteSet_DirectWriteSet = ({ + type: string; +} & DirectWriteSet); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet_ScriptWriteSet.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet_ScriptWriteSet.ts new file mode 100644 index 00000000000000..e7304a8a8431da --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteSet_ScriptWriteSet.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { ScriptWriteSet } from './ScriptWriteSet'; + +export type WriteSet_ScriptWriteSet = ({ + type: string; +} & ScriptWriteSet); + diff --git a/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteTableItem.ts b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteTableItem.ts new file mode 100644 index 00000000000000..6fbaa2b02a3b2c --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/types/generated/models/WriteTableItem.ts @@ -0,0 +1,18 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { DecodedTableData } from './DecodedTableData'; +import type { HexEncodedBytes } from './HexEncodedBytes'; + +/** + * Change set to write a table item + */ +export type WriteTableItem = { + state_key_hash: string; + handle: HexEncodedBytes; + key: HexEncodedBytes; + value: HexEncodedBytes; + data?: DecodedTableData; +}; + diff --git a/ecosystem/typescript/sdk_v2/src/types/index.ts b/ecosystem/typescript/sdk_v2/src/types/index.ts index f1704bfd23d615..48e9ab7bdea016 100644 --- a/ecosystem/typescript/sdk_v2/src/types/index.ts +++ b/ecosystem/typescript/sdk_v2/src/types/index.ts @@ -1,2 +1,106 @@ +import { Network } from "../utils/api-endpoints"; +import { MoveFunction, MoveStruct } from "./generated"; + +export { Transaction } from "./generated"; + export type AnyNumber = number | bigint; export type HexInput = string | Uint8Array; + +export type AptosSettings = { + readonly network: Network; + + readonly fullnode?: string; + + readonly faucet?: string; + + readonly indexer?: string; + + readonly clientConfig?: ClientConfig; +}; + +/** + * + * Controls the number of results that are returned and the starting position of those results. + * @param start parameter specifies the starting position of the query result within the set of data. Default is 0. + * @param limit specifies the maximum number of items or records to return in a query result. Default is 25. + */ +export interface PaginationArgs { + start?: AnyNumber; + limit?: number; +} + +/** + * 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 + */ +export type ClientConfig = { + TOKEN?: string; + HEADERS?: Record; + 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 + */ +export type AptosRequest = { + url: string; + method: "GET" | "POST"; + endpoint?: string; + body?: any; + contentType?: string; + params?: Record; + originMethod?: string; + overrides?: ClientConfig; +}; + +export type MoveResource = { + type: MoveResourceType; + data: {}; +}; + +export type MoveResourceType = `${string}::${string}::${string}`; +export type MoveModuleId = `${string}::${string}`; + +export type AccountData = { + sequence_number: string; + authentication_key: string; +}; + +export type MoveModuleBytecode = { + bytecode: string; + abi?: MoveModule; +}; + +export type MoveModule = { + address: string; + name: string; + /** + * Friends of the module + */ + friends: Array; + /** + * Public functions of the module + */ + exposed_functions: Array; + /** + * Structs of the module + */ + structs: Array; +}; + +export type LedgerVersion = { + ledgerVersion?: AnyNumber; +}; diff --git a/ecosystem/typescript/sdk_v2/src/utils/api-endpoints.ts b/ecosystem/typescript/sdk_v2/src/utils/api-endpoints.ts index 80f13c29edff40..98cf142ed09f95 100644 --- a/ecosystem/typescript/sdk_v2/src/utils/api-endpoints.ts +++ b/ecosystem/typescript/sdk_v2/src/utils/api-endpoints.ts @@ -8,14 +8,14 @@ export const NetworkToNodeAPI: Record = { mainnet: "https://fullnode.mainnet.aptoslabs.com/v1", testnet: "https://fullnode.testnet.aptoslabs.com/v1", devnet: "https://fullnode.devnet.aptoslabs.com/v1", - local: "http://localhost:8080/v1", + local: "http://127.0.0.1:8080/v1", }; export const NetworkToFaucetAPI: Record = { mainnet: "https://faucet.mainnet.aptoslabs.com", testnet: "https://faucet.testnet.aptoslabs.com", devnet: "https://faucet.devnet.aptoslabs.com", - local: "http://localhost:8081", + local: "http://127.0.0.1:8081", }; export enum Network { diff --git a/ecosystem/typescript/sdk_v2/src/utils/const.ts b/ecosystem/typescript/sdk_v2/src/utils/const.ts index 9ab4ac01bf3c01..ff15e23303001f 100644 --- a/ecosystem/typescript/sdk_v2/src/utils/const.ts +++ b/ecosystem/typescript/sdk_v2/src/utils/const.ts @@ -1,3 +1,9 @@ import { Network } from "./api-endpoints"; export const DEFAULT_NETWORK = Network.DEVNET; + +export enum AptosApiType { + FULLNODE, + INDEXER, + FAUCET, +} diff --git a/ecosystem/typescript/sdk_v2/src/utils/paginate_with_cursor.ts b/ecosystem/typescript/sdk_v2/src/utils/paginate_with_cursor.ts new file mode 100644 index 00000000000000..8220f4b36f6b96 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/src/utils/paginate_with_cursor.ts @@ -0,0 +1,44 @@ +import { get } from "../client"; +import { ClientConfig } from "../types"; + +/// This function is a helper for paginating using a function wrapping an API +export async function paginateWithCursor, Res extends any[]>(options: { + url: string; + endpoint?: string; + body?: any; + params?: Req; + originMethod?: string; + overrides?: ClientConfig; +}): Promise { + const out = []; + let cursor: string | undefined; + const requestParams = options.params as Req & { start?: string }; + // eslint-disable-next-line no-constant-condition + while (true) { + requestParams.start = cursor; + // eslint-disable-next-line no-await-in-loop + const response = await get({ + url: options.url, + endpoint: options.endpoint, + params: requestParams, + originMethod: options.originMethod, + overrides: options.overrides, + }); + // eslint-disable-next-line no-underscore-dangle + /** + * the cursor is a "state key" from the API prespective. Client + * should not need to "care" what it represents but just use it + * to query the next chunck of data. + */ + cursor = response.headers["x-aptos-cursor"]; + // Now that we have the cursor (if any), we remove the headers before + // adding these to the output of this function. + // eslint-disable-next-line no-underscore-dangle + delete (response as any).headers; + out.push(...response.data); + if (cursor === null || cursor === undefined) { + break; + } + } + return out as any; +} diff --git a/ecosystem/typescript/sdk_v2/tests/e2e/api/account.test.ts b/ecosystem/typescript/sdk_v2/tests/e2e/api/account.test.ts new file mode 100644 index 00000000000000..524692c0adfff3 --- /dev/null +++ b/ecosystem/typescript/sdk_v2/tests/e2e/api/account.test.ts @@ -0,0 +1,137 @@ +import { Aptos, AptosConfig } from "../../../src"; +import { Network } from "../../../src/utils/api-endpoints"; + +// TODO add account getTransactions tests once sdk v2 supports faucet (which needs transaction operation support) + +describe("account api", () => { + describe("throws when account address in invalid", () => { + test("it throws with a short account address", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + expect( + async () => + await aptos.account.getData({ + accountAddress: "ca843279e3427144cead5e4d5999a3d0ca843279e3427144cead5e4d5999a3d0", + }), + ).rejects.toThrow(); + }); + + test("it throws when invalid account address", () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + expect(async () => await aptos.account.getData({ accountAddress: "0x123" })).rejects.toThrow(); + }); + }); + + describe("fetch data with acount address as string", () => { + test("it fetches account data", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + const data = await aptos.account.getData({ + accountAddress: "0x1", + }); + expect(data).toHaveProperty("sequence_number"); + expect(data.sequence_number).toBe("0"); + expect(data).toHaveProperty("authentication_key"); + expect(data.authentication_key).toBe("0x0000000000000000000000000000000000000000000000000000000000000001"); + }); + + test("it fetches account modules", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + const data = await aptos.account.getModules({ + accountAddress: "0x1", + }); + expect(data.length).toBeGreaterThan(0); + }); + + test("it fetches account module", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + const data = await aptos.account.getModule({ + accountAddress: "0x1", + moduleName: "coin", + }); + expect(data).toHaveProperty("bytecode"); + }); + + test("it fetches account resources", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + const data = await aptos.account.getResources({ + accountAddress: "0x1", + }); + expect(data.length).toBeGreaterThan(0); + }); + + test("it fetches account resource", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + const data = await aptos.account.getResource({ + accountAddress: "0x1", + resourceType: "0x1::account::Account", + }); + expect(data).toHaveProperty("type"); + }); + }); + + describe("fetch data with acount address as Uint8Array", () => { + test("it fetches account data", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + const data = await aptos.account.getData({ + accountAddress: new Uint8Array([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + ]), + }); + expect(data).toHaveProperty("sequence_number"); + expect(data.sequence_number).toBe("0"); + expect(data).toHaveProperty("authentication_key"); + expect(data.authentication_key).toBe("0x0000000000000000000000000000000000000000000000000000000000000001"); + }); + + test("it fetches account modules", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + const data = await aptos.account.getModules({ + accountAddress: new Uint8Array([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + ]), + }); + expect(data.length).toBeGreaterThan(0); + }); + + test("it fetches account module", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + const data = await aptos.account.getModule({ + accountAddress: new Uint8Array([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + ]), + moduleName: "coin", + }); + expect(data).toHaveProperty("bytecode"); + }); + + test("it fetches account resources", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + const data = await aptos.account.getResources({ + accountAddress: new Uint8Array([ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + ]), + }); + expect(data.length).toBeGreaterThan(0); + }); + + test("it fetches account resource", async () => { + const config = new AptosConfig({ network: Network.LOCAL }); + const aptos = new Aptos(config); + const data = await aptos.account.getResource({ + accountAddress: "0x1", + resourceType: "0x1::account::Account", + }); + expect(data).toHaveProperty("type"); + }); + }); +}); diff --git a/ecosystem/typescript/sdk_v2/tests/unit/aptos_config.test.ts b/ecosystem/typescript/sdk_v2/tests/unit/aptos_config.test.ts index 8e79dc2275ad06..5ae4e4a1b5f012 100644 --- a/ecosystem/typescript/sdk_v2/tests/unit/aptos_config.test.ts +++ b/ecosystem/typescript/sdk_v2/tests/unit/aptos_config.test.ts @@ -1,59 +1,64 @@ -import { Aptos, AptosConfig } from "../../src"; -import { Network } from "../../src/utils/api-endpoints"; +import { AptosConfig } from "../../src"; +import { AptosSettings } from "../../src/types"; +import { Network, NetworkToFaucetAPI, NetworkToNodeAPI, NetworkToIndexerAPI } from "../../src/utils/api-endpoints"; +import { AptosApiType } from "../../src/utils/const"; describe("aptos config", () => { - test("it should set DEVNET network if network is not provided", async () => { - const aptos = new Aptos(); - expect(aptos.config.network).toEqual("devnet"); - expect(aptos.config.fullnode).toEqual("https://fullnode.devnet.aptoslabs.com/v1"); - expect(aptos.config.faucet).toEqual("https://faucet.devnet.aptoslabs.com"); - expect(aptos.config.indexer).toEqual("https://indexer-devnet.staging.gcp.aptosdev.com/v1/graphql"); + test("it should set urls based on a local network", async () => { + const settings: AptosSettings = { + network: Network.LOCAL, + }; + const aptosConfig = new AptosConfig(settings); + expect(aptosConfig.network).toEqual("local"); + expect(aptosConfig.getRequestUrl(AptosApiType.FULLNODE)).toBe(NetworkToNodeAPI[Network.LOCAL]); + expect(aptosConfig.getRequestUrl(AptosApiType.FAUCET)).toBe(NetworkToFaucetAPI[Network.LOCAL]); + expect(aptosConfig.getRequestUrl(AptosApiType.INDEXER)).toBeUndefined(); }); - test("it should set urls based on the provided network", async () => { - const settings: AptosConfig = { + test("it should set urls based on a given network", async () => { + const settings: AptosSettings = { network: Network.TESTNET, }; - const aptos = new Aptos(settings); - expect(aptos.config.network).toEqual("testnet"); - expect(aptos.config.fullnode).toEqual("https://fullnode.testnet.aptoslabs.com/v1"); - expect(aptos.config.faucet).toEqual("https://faucet.testnet.aptoslabs.com"); - expect(aptos.config.indexer).toEqual("https://indexer-testnet.staging.gcp.aptosdev.com/v1/graphql"); + const aptosConfig = new AptosConfig(settings); + expect(aptosConfig.network).toEqual("testnet"); + expect(aptosConfig.getRequestUrl(AptosApiType.FULLNODE)).toBe(NetworkToNodeAPI[Network.TESTNET]); + expect(aptosConfig.getRequestUrl(AptosApiType.FAUCET)).toBe(NetworkToFaucetAPI[Network.TESTNET]); + expect(aptosConfig.getRequestUrl(AptosApiType.INDEXER)).toBe(NetworkToIndexerAPI[Network.TESTNET]); }); - test("it should set urls based on a local network", async () => { - const settings: AptosConfig = { - network: Network.LOCAL, + test("it should have undefined urls when network is custom and no urls provided", async () => { + const settings: AptosSettings = { + network: Network.CUSTOM, }; - const aptos = new Aptos(settings); - expect(aptos.config.network).toEqual("local"); - expect(aptos.config.fullnode).toEqual("http://localhost:8080/v1"); - expect(aptos.config.faucet).toEqual("http://localhost:8081"); - expect(aptos.config.indexer).toBeUndefined(); + const aptosConfig = new AptosConfig(settings); + expect(aptosConfig.network).toBe("custom"); + expect(aptosConfig.fullnode).toBeUndefined(); + expect(aptosConfig.faucet).toBeUndefined(); + expect(aptosConfig.indexer).toBeUndefined(); }); - test("it should have undefined urls when network is custom and no urls provided", async () => { - const settings: AptosConfig = { + test("getRequestUrl should throw when network is custom and no urls provided", async () => { + const settings: AptosSettings = { network: Network.CUSTOM, }; - const aptos = new Aptos(settings); - expect(aptos.config.network).toEqual("custom"); - expect(aptos.config.fullnode).toBeUndefined(); - expect(aptos.config.faucet).toBeUndefined(); - expect(aptos.config.indexer).toBeUndefined(); + const aptosConfig = new AptosConfig(settings); + expect(aptosConfig.network).toBe("custom"); + expect(() => aptosConfig.getRequestUrl(AptosApiType.FULLNODE)).toThrow(); + expect(() => aptosConfig.getRequestUrl(AptosApiType.FAUCET)).toThrow(); + expect(() => aptosConfig.getRequestUrl(AptosApiType.INDEXER)).toThrow(); }); test("it should set urls when network is custom and urls provided", async () => { - const settings: AptosConfig = { + const settings: AptosSettings = { network: Network.CUSTOM, fullnode: "my-fullnode-url", faucet: "my-faucet-url", indexer: "my-indexer-url", }; - const aptos = new Aptos(settings); - expect(aptos.config.network).toEqual("custom"); - expect(aptos.config.fullnode).toEqual("my-fullnode-url"); - expect(aptos.config.faucet).toEqual("my-faucet-url"); - expect(aptos.config.indexer).toEqual("my-indexer-url"); + const aptosConfig = new AptosConfig(settings); + expect(aptosConfig.network).toBe("custom"); + expect(aptosConfig.fullnode).toBe("my-fullnode-url"); + expect(aptosConfig.faucet).toBe("my-faucet-url"); + expect(aptosConfig.indexer).toBe("my-indexer-url"); }); });