@aptos-labs/ts-sdk 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +144 -0
  3. package/dist/browser/index.global.js +410 -0
  4. package/dist/browser/index.global.js.map +1 -0
  5. package/dist/cjs/index.d.ts +4965 -0
  6. package/dist/cjs/index.js +4762 -0
  7. package/dist/cjs/index.js.map +1 -0
  8. package/dist/esm/index.d.ts +4965 -0
  9. package/dist/esm/index.mjs +4645 -0
  10. package/dist/esm/index.mjs.map +1 -0
  11. package/dist/types/index.d.ts +1247 -0
  12. package/dist/types/index.js +151 -0
  13. package/dist/types/index.js.map +1 -0
  14. package/package.json +79 -0
  15. package/src/api/account.ts +360 -0
  16. package/src/api/aptos.ts +103 -0
  17. package/src/api/aptosConfig.ts +77 -0
  18. package/src/api/coin.ts +39 -0
  19. package/src/api/digitalAsset.ts +192 -0
  20. package/src/api/event.ts +78 -0
  21. package/src/api/faucet.ts +30 -0
  22. package/src/api/fungibleAsset.ts +82 -0
  23. package/src/api/general.ts +188 -0
  24. package/src/api/index.ts +5 -0
  25. package/src/api/staking.ts +58 -0
  26. package/src/api/transaction.ts +135 -0
  27. package/src/api/transactionSubmission.ts +168 -0
  28. package/src/bcs/consts.ts +12 -0
  29. package/src/bcs/deserializer.ts +248 -0
  30. package/src/bcs/index.ts +9 -0
  31. package/src/bcs/serializable/entryFunctionBytes.ts +61 -0
  32. package/src/bcs/serializable/fixedBytes.ts +65 -0
  33. package/src/bcs/serializable/movePrimitives.ts +211 -0
  34. package/src/bcs/serializable/moveStructs.ts +462 -0
  35. package/src/bcs/serializer.ts +353 -0
  36. package/src/client/core.ts +106 -0
  37. package/src/client/get.ts +109 -0
  38. package/src/client/index.ts +7 -0
  39. package/src/client/post.ts +90 -0
  40. package/src/client/types.ts +58 -0
  41. package/src/core/account.ts +180 -0
  42. package/src/core/accountAddress.ts +407 -0
  43. package/src/core/authenticationKey.ts +102 -0
  44. package/src/core/common.ts +40 -0
  45. package/src/core/crypto/asymmetricCrypto.ts +77 -0
  46. package/src/core/crypto/ed25519.ts +224 -0
  47. package/src/core/crypto/index.ts +7 -0
  48. package/src/core/crypto/multiEd25519.ts +251 -0
  49. package/src/core/crypto/secp256k1.ts +227 -0
  50. package/src/core/hex.ts +177 -0
  51. package/src/core/index.ts +9 -0
  52. package/src/index.ts +12 -0
  53. package/src/internal/account.ts +484 -0
  54. package/src/internal/coin.ts +32 -0
  55. package/src/internal/digitalAsset.ts +302 -0
  56. package/src/internal/event.ts +88 -0
  57. package/src/internal/faucet.ts +41 -0
  58. package/src/internal/fungibleAsset.ts +114 -0
  59. package/src/internal/general.ts +160 -0
  60. package/src/internal/queries/TokenActivitiesFieldsFragment.graphql +17 -0
  61. package/src/internal/queries/currentTokenOwnershipFieldsFragment.graphql +45 -0
  62. package/src/internal/queries/getAccountCoinCount.graphql +7 -0
  63. package/src/internal/queries/getAccountCoinsData.graphql +32 -0
  64. package/src/internal/queries/getAccountCollectionsWithOwnedTokens.graphql +33 -0
  65. package/src/internal/queries/getAccountOwnedObjects.graphql +16 -0
  66. package/src/internal/queries/getAccountOwnedTokens.graphql +11 -0
  67. package/src/internal/queries/getAccountOwnedTokensByTokenData.graphql +11 -0
  68. package/src/internal/queries/getAccountOwnedTokensFromCollectionAddress.graphql +11 -0
  69. package/src/internal/queries/getAccountTokensCount.graphql +7 -0
  70. package/src/internal/queries/getAccountTransactionsCount.graphql +7 -0
  71. package/src/internal/queries/getChainTopUserTransactions.graphql +5 -0
  72. package/src/internal/queries/getCollectionData.graphql +20 -0
  73. package/src/internal/queries/getCurrentFungibleAssetBalances.graphql +17 -0
  74. package/src/internal/queries/getDelegatedStakingActivities.graphql +12 -0
  75. package/src/internal/queries/getEvents.graphql +12 -0
  76. package/src/internal/queries/getFungibleAssetActivities.graphql +20 -0
  77. package/src/internal/queries/getFungibleAssetMetadata.graphql +16 -0
  78. package/src/internal/queries/getNumberOfDelegatorsQuery.graphql +9 -0
  79. package/src/internal/queries/getProcessorStatus.graphql +7 -0
  80. package/src/internal/queries/getTokenActivity.graphql +11 -0
  81. package/src/internal/queries/getTokenCurrentOwner.graphql +11 -0
  82. package/src/internal/queries/getTokenData.graphql +38 -0
  83. package/src/internal/staking.ts +68 -0
  84. package/src/internal/transaction.ts +245 -0
  85. package/src/internal/transactionSubmission.ts +162 -0
  86. package/src/transactions/authenticator/account.ts +121 -0
  87. package/src/transactions/authenticator/transaction.ts +222 -0
  88. package/src/transactions/instances/chainId.ts +26 -0
  89. package/src/transactions/instances/identifier.ts +28 -0
  90. package/src/transactions/instances/index.ts +9 -0
  91. package/src/transactions/instances/moduleId.ts +53 -0
  92. package/src/transactions/instances/rawTransaction.ts +199 -0
  93. package/src/transactions/instances/signedTransaction.ts +43 -0
  94. package/src/transactions/instances/transactionArgument.ts +37 -0
  95. package/src/transactions/instances/transactionPayload.ts +407 -0
  96. package/src/transactions/transaction_builder/transaction_builder.ts +541 -0
  97. package/src/transactions/typeTag/typeTag.ts +487 -0
  98. package/src/transactions/types.ts +262 -0
  99. package/src/types/codegen.yaml +33 -0
  100. package/src/types/generated/operations.ts +623 -0
  101. package/src/types/generated/queries.ts +737 -0
  102. package/src/types/generated/types.ts +10387 -0
  103. package/src/types/index.ts +944 -0
  104. package/src/types/indexer.ts +93 -0
  105. package/src/utils/apiEndpoints.ts +36 -0
  106. package/src/utils/const.ts +51 -0
  107. package/src/utils/hdKey.ts +113 -0
  108. package/src/utils/helpers.ts +12 -0
  109. package/src/utils/memoize.ts +68 -0
  110. package/src/version.ts +9 -0
@@ -0,0 +1,262 @@
1
+ // Copyright © Aptos Foundation
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { AptosConfig } from "../api/aptosConfig";
5
+ import { MoveObject, MoveOption, MoveString, MoveVector } from "../bcs/serializable/moveStructs";
6
+ import { Bool, U128, U16, U256, U32, U64, U8 } from "../bcs/serializable/movePrimitives";
7
+ import { FixedBytes } from "../bcs/serializable/fixedBytes";
8
+ import { AccountAddress } from "../core";
9
+ import { PublicKey } from "../core/crypto/asymmetricCrypto";
10
+ import {
11
+ MultiAgentRawTransaction,
12
+ FeePayerRawTransaction,
13
+ RawTransaction,
14
+ TransactionPayloadEntryFunction,
15
+ TransactionPayloadMultisig,
16
+ TransactionPayloadScript,
17
+ } from "./instances";
18
+ import { AnyNumber, HexInput, MoveStructType } from "../types";
19
+ import { TypeTag } from "./typeTag/typeTag";
20
+
21
+ export type EntryFunctionArgumentTypes =
22
+ | Bool
23
+ | U8
24
+ | U16
25
+ | U32
26
+ | U64
27
+ | U128
28
+ | U256
29
+ | AccountAddress
30
+ | MoveObject
31
+ | MoveVector<EntryFunctionArgumentTypes>
32
+ | MoveOption<EntryFunctionArgumentTypes>
33
+ | MoveString
34
+ | FixedBytes;
35
+ export type ScriptFunctionArgumentTypes =
36
+ | Bool
37
+ | U8
38
+ | U16
39
+ | U32
40
+ | U64
41
+ | U128
42
+ | U256
43
+ | AccountAddress
44
+ | MoveObject
45
+ | MoveVector<U8>
46
+ | MoveString
47
+ | FixedBytes;
48
+
49
+ /**
50
+ * Type that holds all raw transaction instances Aptos SDK supports
51
+ */
52
+ export type AnyRawTransactionInstance = RawTransaction | MultiAgentRawTransaction | FeePayerRawTransaction;
53
+
54
+ // TRANSACTION GENERATION TYPES //
55
+
56
+ /**
57
+ * Optional options to set when generating a transaction
58
+ */
59
+ export type GenerateTransactionOptions = {
60
+ maxGasAmount?: AnyNumber;
61
+ gasUnitPrice?: AnyNumber;
62
+ expireTimestamp?: AnyNumber;
63
+ accountSequenceNumber?: AnyNumber;
64
+ };
65
+
66
+ /**
67
+ * The generated transaction payload type that was produces from `generateTransactionPayload()` function.
68
+ */
69
+ export type TransactionPayload =
70
+ | TransactionPayloadEntryFunction
71
+ | TransactionPayloadScript
72
+ | TransactionPayloadMultisig;
73
+
74
+ /**
75
+ * Unified type for the data needed to generate a transaction payload of types:
76
+ * Entry Function | Script | Multi Sig
77
+ */
78
+ export type GenerateTransactionPayloadData = EntryFunctionData | ScriptData | MultiSigData;
79
+
80
+ /**
81
+ * The data needed to generate an Entry Function payload
82
+ */
83
+ export type EntryFunctionData = {
84
+ function: MoveStructType;
85
+ typeArguments?: Array<TypeTag>;
86
+ arguments: Array<EntryFunctionArgumentTypes>;
87
+ };
88
+
89
+ /**
90
+ * The data needed to generate a Multi Sig payload
91
+ */
92
+ export type MultiSigData = {
93
+ multisigAddress: AccountAddress;
94
+ } & EntryFunctionData;
95
+
96
+ /**
97
+ * The data needed to generate a Script payload
98
+ */
99
+ export type ScriptData = {
100
+ bytecode: HexInput;
101
+ typeArguments?: Array<TypeTag>;
102
+ arguments: Array<ScriptFunctionArgumentTypes>;
103
+ };
104
+
105
+ /**
106
+ * Interface of the arguments to generate a single signer transaction.
107
+ * Used to provide to `generateTransaction()` method in the transaction builder flow
108
+ */
109
+ export interface GenerateSingleSignerRawTransactionArgs {
110
+ aptosConfig: AptosConfig;
111
+ sender: HexInput;
112
+ payload: TransactionPayload;
113
+ feePayerAddress?: undefined;
114
+ secondarySignerAddresses?: undefined;
115
+ options?: GenerateTransactionOptions;
116
+ }
117
+
118
+ /**
119
+ * Interface of the arguments to generate a fee payer transaction.
120
+ * Used to provide to `generateTransaction()` method in the transaction builder flow
121
+ */
122
+ export interface GenerateFeePayerRawTransactionArgs {
123
+ aptosConfig: AptosConfig;
124
+ sender: HexInput;
125
+ payload: TransactionPayload;
126
+ feePayerAddress: HexInput;
127
+ secondarySignerAddresses?: HexInput[];
128
+ options?: GenerateTransactionOptions;
129
+ }
130
+
131
+ /**
132
+ * Interface of the arguments to generate a multi-agent transaction.
133
+ * Used to provide to `generateTransaction()` method in the transaction builder flow
134
+ */
135
+ export interface GenerateMultiAgentRawTransactionArgs {
136
+ aptosConfig: AptosConfig;
137
+ sender: HexInput;
138
+ payload: TransactionPayload;
139
+ secondarySignerAddresses: HexInput[];
140
+ feePayerAddress?: undefined;
141
+ options?: GenerateTransactionOptions;
142
+ }
143
+
144
+ /**
145
+ * Unified type that holds all the interfaces to generate different transaction types
146
+ */
147
+ export type GenerateRawTransactionArgs =
148
+ | GenerateSingleSignerRawTransactionArgs
149
+ | GenerateFeePayerRawTransactionArgs
150
+ | GenerateMultiAgentRawTransactionArgs;
151
+
152
+ /**
153
+ * Interface that holds the return data when generating a single signer transaction
154
+ *
155
+ * @param rawTransaction a bcs serialized raw transaction
156
+ */
157
+ export interface SingleSignerTransaction {
158
+ rawTransaction: Uint8Array;
159
+ feePayerAddress?: undefined;
160
+ secondarySignerAddresses?: undefined;
161
+ }
162
+
163
+ /**
164
+ * Interface that holds the return data when generating a fee payer transaction
165
+ *
166
+ * @param rawTransaction a bcs serialized raw transaction
167
+ * @param secondarySignerAddresses optional. secondary signer addresses for multi-agent transaction
168
+ * @param feePayerAddress fee payer address for a fee payer transaction (aka Sponsored Transaction)
169
+ */
170
+ export interface FeePayerTransaction {
171
+ rawTransaction: Uint8Array;
172
+ feePayerAddress: AccountAddress;
173
+ secondarySignerAddresses?: AccountAddress[];
174
+ }
175
+
176
+ /**
177
+ * Interface that holds the return data when generating a multi-agent transaction.
178
+ *
179
+ * @param rawTransaction a bcs serialized raw transaction
180
+ * @param secondarySignerAddresses secondary signer addresses for multi-agent transaction
181
+ */
182
+ export interface MultiAgentTransaction {
183
+ rawTransaction: Uint8Array;
184
+ secondarySignerAddresses: AccountAddress[];
185
+ feePayerAddress?: undefined;
186
+ }
187
+
188
+ /**
189
+ * Unified type that holds all the return interfaces when generating different transaction types
190
+ */
191
+ export type AnyRawTransaction = SingleSignerTransaction | FeePayerTransaction | MultiAgentTransaction;
192
+
193
+ // TRANSACTION SIMULATION TYPES //
194
+
195
+ export type SimulateTransactionData = {
196
+ /**
197
+ * The transaction to simulate, probably generated by `generateTransaction()`
198
+ */
199
+ transaction: AnyRawTransaction;
200
+ /**
201
+ * For a single signer transaction
202
+ */
203
+ signerPublicKey: PublicKey;
204
+ /**
205
+ * For a fee payer or multi-agent transaction that requires additional signers in
206
+ */
207
+ secondarySignersPublicKeys?: Array<PublicKey>;
208
+ /**
209
+ * For a fee payer transaction (aka Sponsored Transaction)
210
+ */
211
+ feePayerPublicKey?: PublicKey;
212
+ options?: SimulateTransactionOptions;
213
+ };
214
+
215
+ export type SimulateTransactionOptions = {
216
+ estimateGasUnitPrice?: boolean;
217
+ estimateMaxGasAmount?: boolean;
218
+ estimatePrioritizedGasUnitPrice?: boolean;
219
+ };
220
+
221
+ // USER INPUT TYPES //
222
+
223
+ /**
224
+ * Interface that holds the user data input when generating a single signer transaction
225
+ */
226
+ export interface GenerateSingleSignerRawTransactionInput {
227
+ sender: HexInput;
228
+ feePayerAddress?: undefined;
229
+ secondarySignerAddresses?: undefined;
230
+ options?: GenerateTransactionOptions;
231
+ data: GenerateTransactionPayloadData;
232
+ }
233
+
234
+ /**
235
+ * Interface that holds the user data input when generating a fee payer transaction
236
+ */
237
+ export interface GenerateFeePayerRawTransactionInput {
238
+ sender: HexInput;
239
+ feePayerAddress: HexInput;
240
+ secondarySignerAddresses?: HexInput[];
241
+ options?: GenerateTransactionOptions;
242
+ data: GenerateTransactionPayloadData;
243
+ }
244
+
245
+ /**
246
+ * Interface that holds the user data input when generating a multi-agent transaction
247
+ */
248
+ export interface GenerateMultiAgentRawTransactionInput {
249
+ sender: HexInput;
250
+ secondarySignerAddresses: HexInput[];
251
+ feePayerAddress?: undefined;
252
+ options?: GenerateTransactionOptions;
253
+ data: GenerateTransactionPayloadData;
254
+ }
255
+
256
+ /**
257
+ * Unified type that holds all the user data input interfaces when generating different transaction types
258
+ */
259
+ export type GenerateTransactionInput =
260
+ | GenerateMultiAgentRawTransactionInput
261
+ | GenerateFeePayerRawTransactionInput
262
+ | GenerateSingleSignerRawTransactionInput;
@@ -0,0 +1,33 @@
1
+ overwrite: true
2
+ documents: src/internal/queries/**/*.graphql
3
+ schema: https://indexer.mainnet.aptoslabs.com/v1/graphql
4
+ generates:
5
+ src/types/generated/types.ts:
6
+ plugins:
7
+ - typescript
8
+ config:
9
+ skipTypename: true
10
+ namingConvention:
11
+ transformUnderscore: true
12
+ src/types/generated/operations.ts:
13
+ preset: import-types-preset
14
+ presetConfig:
15
+ typesPath: ./types
16
+ plugins:
17
+ - typescript-operations
18
+ config:
19
+ skipTypename: true
20
+ namingConvention:
21
+ transformUnderscore: true
22
+ src/types/generated/queries.ts:
23
+ preset: import-types-preset
24
+ presetConfig:
25
+ typesPath: ./operations
26
+ plugins:
27
+ - typescript-graphql-request
28
+ config:
29
+ documentMode: string
30
+ documentVariableSuffix: ""
31
+ skipTypename: true
32
+ namingConvention:
33
+ transformUnderscore: true