@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.
- package/LICENSE +201 -0
- package/README.md +144 -0
- package/dist/browser/index.global.js +410 -0
- package/dist/browser/index.global.js.map +1 -0
- package/dist/cjs/index.d.ts +4965 -0
- package/dist/cjs/index.js +4762 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/esm/index.d.ts +4965 -0
- package/dist/esm/index.mjs +4645 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/types/index.d.ts +1247 -0
- package/dist/types/index.js +151 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +79 -0
- package/src/api/account.ts +360 -0
- package/src/api/aptos.ts +103 -0
- package/src/api/aptosConfig.ts +77 -0
- package/src/api/coin.ts +39 -0
- package/src/api/digitalAsset.ts +192 -0
- package/src/api/event.ts +78 -0
- package/src/api/faucet.ts +30 -0
- package/src/api/fungibleAsset.ts +82 -0
- package/src/api/general.ts +188 -0
- package/src/api/index.ts +5 -0
- package/src/api/staking.ts +58 -0
- package/src/api/transaction.ts +135 -0
- package/src/api/transactionSubmission.ts +168 -0
- package/src/bcs/consts.ts +12 -0
- package/src/bcs/deserializer.ts +248 -0
- package/src/bcs/index.ts +9 -0
- package/src/bcs/serializable/entryFunctionBytes.ts +61 -0
- package/src/bcs/serializable/fixedBytes.ts +65 -0
- package/src/bcs/serializable/movePrimitives.ts +211 -0
- package/src/bcs/serializable/moveStructs.ts +462 -0
- package/src/bcs/serializer.ts +353 -0
- package/src/client/core.ts +106 -0
- package/src/client/get.ts +109 -0
- package/src/client/index.ts +7 -0
- package/src/client/post.ts +90 -0
- package/src/client/types.ts +58 -0
- package/src/core/account.ts +180 -0
- package/src/core/accountAddress.ts +407 -0
- package/src/core/authenticationKey.ts +102 -0
- package/src/core/common.ts +40 -0
- package/src/core/crypto/asymmetricCrypto.ts +77 -0
- package/src/core/crypto/ed25519.ts +224 -0
- package/src/core/crypto/index.ts +7 -0
- package/src/core/crypto/multiEd25519.ts +251 -0
- package/src/core/crypto/secp256k1.ts +227 -0
- package/src/core/hex.ts +177 -0
- package/src/core/index.ts +9 -0
- package/src/index.ts +12 -0
- package/src/internal/account.ts +484 -0
- package/src/internal/coin.ts +32 -0
- package/src/internal/digitalAsset.ts +302 -0
- package/src/internal/event.ts +88 -0
- package/src/internal/faucet.ts +41 -0
- package/src/internal/fungibleAsset.ts +114 -0
- package/src/internal/general.ts +160 -0
- package/src/internal/queries/TokenActivitiesFieldsFragment.graphql +17 -0
- package/src/internal/queries/currentTokenOwnershipFieldsFragment.graphql +45 -0
- package/src/internal/queries/getAccountCoinCount.graphql +7 -0
- package/src/internal/queries/getAccountCoinsData.graphql +32 -0
- package/src/internal/queries/getAccountCollectionsWithOwnedTokens.graphql +33 -0
- package/src/internal/queries/getAccountOwnedObjects.graphql +16 -0
- package/src/internal/queries/getAccountOwnedTokens.graphql +11 -0
- package/src/internal/queries/getAccountOwnedTokensByTokenData.graphql +11 -0
- package/src/internal/queries/getAccountOwnedTokensFromCollectionAddress.graphql +11 -0
- package/src/internal/queries/getAccountTokensCount.graphql +7 -0
- package/src/internal/queries/getAccountTransactionsCount.graphql +7 -0
- package/src/internal/queries/getChainTopUserTransactions.graphql +5 -0
- package/src/internal/queries/getCollectionData.graphql +20 -0
- package/src/internal/queries/getCurrentFungibleAssetBalances.graphql +17 -0
- package/src/internal/queries/getDelegatedStakingActivities.graphql +12 -0
- package/src/internal/queries/getEvents.graphql +12 -0
- package/src/internal/queries/getFungibleAssetActivities.graphql +20 -0
- package/src/internal/queries/getFungibleAssetMetadata.graphql +16 -0
- package/src/internal/queries/getNumberOfDelegatorsQuery.graphql +9 -0
- package/src/internal/queries/getProcessorStatus.graphql +7 -0
- package/src/internal/queries/getTokenActivity.graphql +11 -0
- package/src/internal/queries/getTokenCurrentOwner.graphql +11 -0
- package/src/internal/queries/getTokenData.graphql +38 -0
- package/src/internal/staking.ts +68 -0
- package/src/internal/transaction.ts +245 -0
- package/src/internal/transactionSubmission.ts +162 -0
- package/src/transactions/authenticator/account.ts +121 -0
- package/src/transactions/authenticator/transaction.ts +222 -0
- package/src/transactions/instances/chainId.ts +26 -0
- package/src/transactions/instances/identifier.ts +28 -0
- package/src/transactions/instances/index.ts +9 -0
- package/src/transactions/instances/moduleId.ts +53 -0
- package/src/transactions/instances/rawTransaction.ts +199 -0
- package/src/transactions/instances/signedTransaction.ts +43 -0
- package/src/transactions/instances/transactionArgument.ts +37 -0
- package/src/transactions/instances/transactionPayload.ts +407 -0
- package/src/transactions/transaction_builder/transaction_builder.ts +541 -0
- package/src/transactions/typeTag/typeTag.ts +487 -0
- package/src/transactions/types.ts +262 -0
- package/src/types/codegen.yaml +33 -0
- package/src/types/generated/operations.ts +623 -0
- package/src/types/generated/queries.ts +737 -0
- package/src/types/generated/types.ts +10387 -0
- package/src/types/index.ts +944 -0
- package/src/types/indexer.ts +93 -0
- package/src/utils/apiEndpoints.ts +36 -0
- package/src/utils/const.ts +51 -0
- package/src/utils/hdKey.ts +113 -0
- package/src/utils/helpers.ts +12 -0
- package/src/utils/memoize.ts +68 -0
- package/src/version.ts +9 -0
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
// Copyright © Aptos Foundation
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { Network } from "../utils/apiEndpoints";
|
|
5
|
+
|
|
6
|
+
export * from "./indexer";
|
|
7
|
+
|
|
8
|
+
export enum MimeType {
|
|
9
|
+
/**
|
|
10
|
+
* JSON representation, used for transaction submission and accept type JSON output
|
|
11
|
+
*/
|
|
12
|
+
JSON = "application/json",
|
|
13
|
+
/**
|
|
14
|
+
* BCS representation, used for accept type BCS output
|
|
15
|
+
*/
|
|
16
|
+
BCS = "application/x-bcs",
|
|
17
|
+
/**
|
|
18
|
+
* BCS representation, used for transaction submission in BCS input
|
|
19
|
+
*/
|
|
20
|
+
BCS_SIGNED_TRANSACTION = "application/x.aptos.signed_transaction+bcs",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Hex data as input to a function
|
|
25
|
+
*/
|
|
26
|
+
export type HexInput = string | Uint8Array;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Script transaction arguments enum as they are represented in Rust
|
|
30
|
+
* {@link https://github.com/aptos-labs/aptos-core/blob/main/third_party/move/move-core/types/src/language_storage.rs#L27}
|
|
31
|
+
*/
|
|
32
|
+
export enum TypeTagVariants {
|
|
33
|
+
Bool = 0,
|
|
34
|
+
U8 = 1,
|
|
35
|
+
U64 = 2,
|
|
36
|
+
U128 = 3,
|
|
37
|
+
Address = 4,
|
|
38
|
+
Signer = 5,
|
|
39
|
+
Vector = 6,
|
|
40
|
+
Struct = 7,
|
|
41
|
+
U16 = 8,
|
|
42
|
+
U32 = 9,
|
|
43
|
+
U256 = 10,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Script transaction arguments enum as they are represented in Rust
|
|
48
|
+
* {@link https://github.com/aptos-labs/aptos-core/blob/main/third_party/move/move-core/types/src/transaction_argument.rs#L11}
|
|
49
|
+
*/
|
|
50
|
+
export enum ScriptTransactionArgumentVariants {
|
|
51
|
+
U8 = 0,
|
|
52
|
+
U64 = 1,
|
|
53
|
+
U128 = 2,
|
|
54
|
+
Address = 3,
|
|
55
|
+
U8Vector = 4,
|
|
56
|
+
Bool = 5,
|
|
57
|
+
U16 = 6,
|
|
58
|
+
U32 = 7,
|
|
59
|
+
U256 = 8,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Transaction payload enum as they are represented in Rust
|
|
64
|
+
* {@link https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/mod.rs#L478}
|
|
65
|
+
*/
|
|
66
|
+
export enum TransactionPayloadVariants {
|
|
67
|
+
Script = 0,
|
|
68
|
+
EntryFunction = 2,
|
|
69
|
+
Multisig = 3,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Transaction variants enum as they are represented in Rust
|
|
74
|
+
* {@link https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/mod.rs#L440}
|
|
75
|
+
*/
|
|
76
|
+
export enum TransactionVariants {
|
|
77
|
+
MultiAgentTransaction = 0,
|
|
78
|
+
FeePayerTransaction = 1,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Transaction Authenticator enum as they are represented in Rust
|
|
83
|
+
* {@link https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/authenticator.rs#L44}
|
|
84
|
+
*/
|
|
85
|
+
export enum TransactionAuthenticatorVariant {
|
|
86
|
+
Ed25519 = 0,
|
|
87
|
+
MultiEd25519 = 1,
|
|
88
|
+
MultiAgent = 2,
|
|
89
|
+
FeePayer = 3,
|
|
90
|
+
Secp256k1Ecdsa = 4,
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Transaction Authenticator enum as they are represented in Rust
|
|
95
|
+
* {@link https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/authenticator.rs#L414}
|
|
96
|
+
*/
|
|
97
|
+
export enum AccountAuthenticatorVariant {
|
|
98
|
+
Ed25519 = 0,
|
|
99
|
+
MultiEd25519 = 1,
|
|
100
|
+
Secp256k1 = 2,
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* BCS types
|
|
105
|
+
*/
|
|
106
|
+
export type Uint8 = number;
|
|
107
|
+
export type Uint16 = number;
|
|
108
|
+
export type Uint32 = number;
|
|
109
|
+
export type Uint64 = bigint;
|
|
110
|
+
export type Uint128 = bigint;
|
|
111
|
+
export type Uint256 = bigint;
|
|
112
|
+
export type AnyNumber = number | bigint;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Set of configuration options that can be provided when initializing the SDK.
|
|
116
|
+
* The purpose of these options is to configure various aspects of the SDK's
|
|
117
|
+
* behavior and interaction with the Aptos network
|
|
118
|
+
*/
|
|
119
|
+
export type AptosSettings = {
|
|
120
|
+
readonly network: Network;
|
|
121
|
+
|
|
122
|
+
readonly fullnode?: string;
|
|
123
|
+
|
|
124
|
+
readonly faucet?: string;
|
|
125
|
+
|
|
126
|
+
readonly indexer?: string;
|
|
127
|
+
|
|
128
|
+
readonly clientConfig?: ClientConfig;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
* Controls the number of results that are returned and the starting position of those results.
|
|
134
|
+
* @param offset parameter specifies the starting position of the query result within the set of data. Default is 0.
|
|
135
|
+
* @param limit specifies the maximum number of items or records to return in a query result. Default is 25.
|
|
136
|
+
*/
|
|
137
|
+
export interface PaginationArgs {
|
|
138
|
+
offset?: AnyNumber;
|
|
139
|
+
limit?: number;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* QUERY TYPES
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A configuration object we can pass with the request to the server.
|
|
148
|
+
*
|
|
149
|
+
* @param TOKEN - an auth token to send with the request
|
|
150
|
+
* @param HEADERS - extra headers we want to send with the request
|
|
151
|
+
* @param WITH_CREDENTIALS - whether to carry cookies. By default, it is set to true and cookies will be sent
|
|
152
|
+
*/
|
|
153
|
+
export type ClientConfig = {
|
|
154
|
+
TOKEN?: string;
|
|
155
|
+
HEADERS?: Record<string, string | number | boolean>;
|
|
156
|
+
WITH_CREDENTIALS?: boolean;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* The API request type
|
|
161
|
+
*
|
|
162
|
+
* @param url - the url to make the request to, i.e https://fullnode.aptoslabs.devnet.com/v1
|
|
163
|
+
* @param method - the request method "GET" | "POST"
|
|
164
|
+
* @param endpoint (optional) - the endpoint to make the request to, i.e transactions
|
|
165
|
+
* @param body (optional) - the body of the request
|
|
166
|
+
* @param contentType (optional) - the content type to set the `content-type` header to,
|
|
167
|
+
* by default is set to `application/json`
|
|
168
|
+
* @param params (optional) - query params to add to the request
|
|
169
|
+
* @param originMethod (optional) - the local method the request came from
|
|
170
|
+
* @param overrides (optional) - a `ClientConfig` object type to override request data
|
|
171
|
+
*/
|
|
172
|
+
export type AptosRequest = {
|
|
173
|
+
url: string;
|
|
174
|
+
method: "GET" | "POST";
|
|
175
|
+
path?: string;
|
|
176
|
+
body?: any;
|
|
177
|
+
contentType?: string;
|
|
178
|
+
acceptType?: string;
|
|
179
|
+
params?: Record<string, string | AnyNumber | boolean | undefined>;
|
|
180
|
+
originMethod?: string;
|
|
181
|
+
overrides?: ClientConfig;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Specifies ledger version of transactions. By default latest version will be used
|
|
186
|
+
*/
|
|
187
|
+
export type LedgerVersion = {
|
|
188
|
+
ledgerVersion?: AnyNumber;
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* RESPONSE TYPES
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Type holding the outputs of the estimate gas API
|
|
197
|
+
*/
|
|
198
|
+
export type GasEstimation = {
|
|
199
|
+
/**
|
|
200
|
+
* The deprioritized estimate for the gas unit price
|
|
201
|
+
*/
|
|
202
|
+
deprioritized_gas_estimate?: number;
|
|
203
|
+
/**
|
|
204
|
+
* The current estimate for the gas unit price
|
|
205
|
+
*/
|
|
206
|
+
gas_estimate: number;
|
|
207
|
+
/**
|
|
208
|
+
* The prioritized estimate for the gas unit price
|
|
209
|
+
*/
|
|
210
|
+
prioritized_gas_estimate?: number;
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export type MoveResource = {
|
|
214
|
+
type: MoveResourceType;
|
|
215
|
+
data: {};
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export type AccountData = {
|
|
219
|
+
sequence_number: string;
|
|
220
|
+
authentication_key: string;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export type MoveModuleBytecode = {
|
|
224
|
+
bytecode: string;
|
|
225
|
+
abi?: MoveModule;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* TRANSACTION TYPES
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
export enum TransactionResponseType {
|
|
233
|
+
Pending = "pending_transaction",
|
|
234
|
+
User = "user_transaction",
|
|
235
|
+
Genesis = "genesis_transaction",
|
|
236
|
+
BlockMetadata = "block_metadata_transaction",
|
|
237
|
+
StateCheckpoint = "state_checkpoint_transaction",
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export type TransactionResponse =
|
|
241
|
+
| PendingTransactionResponse
|
|
242
|
+
| UserTransactionResponse
|
|
243
|
+
| GenesisTransactionResponse
|
|
244
|
+
| BlockMetadataTransactionResponse
|
|
245
|
+
| StateCheckpointTransactionResponse;
|
|
246
|
+
|
|
247
|
+
export type PendingTransactionResponse = {
|
|
248
|
+
type: TransactionResponseType.Pending;
|
|
249
|
+
hash: string;
|
|
250
|
+
sender: string;
|
|
251
|
+
sequence_number: string;
|
|
252
|
+
max_gas_amount: string;
|
|
253
|
+
gas_unit_price: string;
|
|
254
|
+
expiration_timestamp_secs: string;
|
|
255
|
+
payload: TransactionPayloadResponse;
|
|
256
|
+
signature?: TransactionSignature;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
export type UserTransactionResponse = {
|
|
260
|
+
type: TransactionResponseType.User;
|
|
261
|
+
version: string;
|
|
262
|
+
hash: string;
|
|
263
|
+
state_change_hash: string;
|
|
264
|
+
event_root_hash: string;
|
|
265
|
+
state_checkpoint_hash?: string;
|
|
266
|
+
gas_used: string;
|
|
267
|
+
/**
|
|
268
|
+
* Whether the transaction was successful
|
|
269
|
+
*/
|
|
270
|
+
success: boolean;
|
|
271
|
+
/**
|
|
272
|
+
* The VM status of the transaction, can tell useful information in a failure
|
|
273
|
+
*/
|
|
274
|
+
vm_status: string;
|
|
275
|
+
accumulator_root_hash: string;
|
|
276
|
+
/**
|
|
277
|
+
* Final state of resources changed by the transaction
|
|
278
|
+
*/
|
|
279
|
+
changes: Array<WriteSetChange>;
|
|
280
|
+
sender: string;
|
|
281
|
+
sequence_number: string;
|
|
282
|
+
max_gas_amount: string;
|
|
283
|
+
gas_unit_price: string;
|
|
284
|
+
expiration_timestamp_secs: string;
|
|
285
|
+
payload: TransactionPayloadResponse;
|
|
286
|
+
signature?: TransactionSignature;
|
|
287
|
+
/**
|
|
288
|
+
* Events generated by the transaction
|
|
289
|
+
*/
|
|
290
|
+
events: Array<Event>;
|
|
291
|
+
timestamp: string;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export type GenesisTransactionResponse = {
|
|
295
|
+
type: TransactionResponseType.Genesis;
|
|
296
|
+
version: string;
|
|
297
|
+
hash: string;
|
|
298
|
+
state_change_hash: string;
|
|
299
|
+
event_root_hash: string;
|
|
300
|
+
state_checkpoint_hash?: string;
|
|
301
|
+
gas_used: string;
|
|
302
|
+
/**
|
|
303
|
+
* Whether the transaction was successful
|
|
304
|
+
*/
|
|
305
|
+
success: boolean;
|
|
306
|
+
/**
|
|
307
|
+
* The VM status of the transaction, can tell useful information in a failure
|
|
308
|
+
*/
|
|
309
|
+
vm_status: string;
|
|
310
|
+
accumulator_root_hash: string;
|
|
311
|
+
/**
|
|
312
|
+
* Final state of resources changed by the transaction
|
|
313
|
+
*/
|
|
314
|
+
changes: Array<WriteSetChange>;
|
|
315
|
+
payload: GenesisPayload;
|
|
316
|
+
/**
|
|
317
|
+
* Events emitted during genesis
|
|
318
|
+
*/
|
|
319
|
+
events: Array<Event>;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export type BlockMetadataTransactionResponse = {
|
|
323
|
+
type: TransactionResponseType.BlockMetadata;
|
|
324
|
+
version: string;
|
|
325
|
+
hash: string;
|
|
326
|
+
state_change_hash: string;
|
|
327
|
+
event_root_hash: string;
|
|
328
|
+
state_checkpoint_hash?: string;
|
|
329
|
+
gas_used: string;
|
|
330
|
+
/**
|
|
331
|
+
* Whether the transaction was successful
|
|
332
|
+
*/
|
|
333
|
+
success: boolean;
|
|
334
|
+
/**
|
|
335
|
+
* The VM status of the transaction, can tell useful information in a failure
|
|
336
|
+
*/
|
|
337
|
+
vm_status: string;
|
|
338
|
+
accumulator_root_hash: string;
|
|
339
|
+
/**
|
|
340
|
+
* Final state of resources changed by the transaction
|
|
341
|
+
*/
|
|
342
|
+
changes: Array<WriteSetChange>;
|
|
343
|
+
id: string;
|
|
344
|
+
epoch: string;
|
|
345
|
+
round: string;
|
|
346
|
+
/**
|
|
347
|
+
* The events emitted at the block creation
|
|
348
|
+
*/
|
|
349
|
+
events: Array<Event>;
|
|
350
|
+
/**
|
|
351
|
+
* Previous block votes
|
|
352
|
+
*/
|
|
353
|
+
previous_block_votes_bitvec: Array<number>;
|
|
354
|
+
proposer: string;
|
|
355
|
+
/**
|
|
356
|
+
* The indices of the proposers who failed to propose
|
|
357
|
+
*/
|
|
358
|
+
failed_proposer_indices: Array<number>;
|
|
359
|
+
timestamp: string;
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
export type StateCheckpointTransactionResponse = {
|
|
363
|
+
type: TransactionResponseType.StateCheckpoint;
|
|
364
|
+
version: string;
|
|
365
|
+
hash: string;
|
|
366
|
+
state_change_hash: string;
|
|
367
|
+
event_root_hash: string;
|
|
368
|
+
state_checkpoint_hash?: string;
|
|
369
|
+
gas_used: string;
|
|
370
|
+
/**
|
|
371
|
+
* Whether the transaction was successful
|
|
372
|
+
*/
|
|
373
|
+
success: boolean;
|
|
374
|
+
/**
|
|
375
|
+
* The VM status of the transaction, can tell useful information in a failure
|
|
376
|
+
*/
|
|
377
|
+
vm_status: string;
|
|
378
|
+
accumulator_root_hash: string;
|
|
379
|
+
/**
|
|
380
|
+
* Final state of resources changed by the transaction
|
|
381
|
+
*/
|
|
382
|
+
changes: Array<WriteSetChange>;
|
|
383
|
+
timestamp: string;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* WRITESET CHANGE TYPES
|
|
388
|
+
*/
|
|
389
|
+
|
|
390
|
+
export type WriteSetChange =
|
|
391
|
+
| WriteSetChangeDeleteModule
|
|
392
|
+
| WriteSetChangeDeleteResource
|
|
393
|
+
| WriteSetChangeDeleteTableItem
|
|
394
|
+
| WriteSetChangeWriteModule
|
|
395
|
+
| WriteSetChangeWriteResource
|
|
396
|
+
| WriteSetChangeWriteTableItem;
|
|
397
|
+
|
|
398
|
+
export type WriteSetChangeDeleteModule = {
|
|
399
|
+
type: string;
|
|
400
|
+
address: string;
|
|
401
|
+
/**
|
|
402
|
+
* State key hash
|
|
403
|
+
*/
|
|
404
|
+
state_key_hash: string;
|
|
405
|
+
module: MoveModuleId;
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export type WriteSetChangeDeleteResource = {
|
|
409
|
+
type: string;
|
|
410
|
+
address: string;
|
|
411
|
+
state_key_hash: string;
|
|
412
|
+
resource: string;
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
export type WriteSetChangeDeleteTableItem = {
|
|
416
|
+
type: string;
|
|
417
|
+
state_key_hash: string;
|
|
418
|
+
handle: string;
|
|
419
|
+
key: string;
|
|
420
|
+
data?: DeletedTableData;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
export type WriteSetChangeWriteModule = {
|
|
424
|
+
type: string;
|
|
425
|
+
address: string;
|
|
426
|
+
state_key_hash: string;
|
|
427
|
+
data: MoveModuleBytecode;
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
export type WriteSetChangeWriteResource = {
|
|
431
|
+
type: string;
|
|
432
|
+
address: string;
|
|
433
|
+
state_key_hash: string;
|
|
434
|
+
data: MoveResource;
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
export type WriteSetChangeWriteTableItem = {
|
|
438
|
+
type: string;
|
|
439
|
+
state_key_hash: string;
|
|
440
|
+
handle: string;
|
|
441
|
+
key: string;
|
|
442
|
+
value: string;
|
|
443
|
+
data?: DecodedTableData;
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
export type DecodedTableData = {
|
|
447
|
+
/**
|
|
448
|
+
* Key of table in JSON
|
|
449
|
+
*/
|
|
450
|
+
key: any;
|
|
451
|
+
/**
|
|
452
|
+
* Type of key
|
|
453
|
+
*/
|
|
454
|
+
key_type: string;
|
|
455
|
+
/**
|
|
456
|
+
* Value of table in JSON
|
|
457
|
+
*/
|
|
458
|
+
value: any;
|
|
459
|
+
/**
|
|
460
|
+
* Type of value
|
|
461
|
+
*/
|
|
462
|
+
value_type: string;
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Deleted table data
|
|
467
|
+
*/
|
|
468
|
+
export type DeletedTableData = {
|
|
469
|
+
/**
|
|
470
|
+
* Deleted key
|
|
471
|
+
*/
|
|
472
|
+
key: any;
|
|
473
|
+
/**
|
|
474
|
+
* Deleted key type
|
|
475
|
+
*/
|
|
476
|
+
key_type: string;
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
export type TransactionPayloadResponse = EntryFunctionPayloadResponse | ScriptPayloadResponse | MultisigPayloadResponse;
|
|
480
|
+
|
|
481
|
+
export type EntryFunctionPayloadResponse = {
|
|
482
|
+
type: string;
|
|
483
|
+
function: MoveResourceType;
|
|
484
|
+
/**
|
|
485
|
+
* Type arguments of the function
|
|
486
|
+
*/
|
|
487
|
+
type_arguments: Array<string>;
|
|
488
|
+
/**
|
|
489
|
+
* Arguments of the function
|
|
490
|
+
*/
|
|
491
|
+
arguments: Array<any>;
|
|
492
|
+
};
|
|
493
|
+
|
|
494
|
+
export type ScriptPayloadResponse = {
|
|
495
|
+
type: string;
|
|
496
|
+
code: MoveScriptBytecode;
|
|
497
|
+
/**
|
|
498
|
+
* Type arguments of the function
|
|
499
|
+
*/
|
|
500
|
+
type_arguments: Array<string>;
|
|
501
|
+
/**
|
|
502
|
+
* Arguments of the function
|
|
503
|
+
*/
|
|
504
|
+
arguments: Array<any>;
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
export type MultisigPayloadResponse = {
|
|
508
|
+
type: string;
|
|
509
|
+
multisig_address: string;
|
|
510
|
+
transaction_payload?: EntryFunctionPayloadResponse;
|
|
511
|
+
};
|
|
512
|
+
|
|
513
|
+
export type GenesisPayload = {
|
|
514
|
+
type: string;
|
|
515
|
+
write_set: WriteSet;
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Move script bytecode
|
|
520
|
+
*/
|
|
521
|
+
export type MoveScriptBytecode = {
|
|
522
|
+
bytecode: string;
|
|
523
|
+
abi?: MoveFunction;
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* These are the JSON representations of transaction signatures returned from the node API.
|
|
528
|
+
*/
|
|
529
|
+
export type TransactionSignature =
|
|
530
|
+
| TransactionEd25519Signature
|
|
531
|
+
| TransactionSecp256k1Signature
|
|
532
|
+
| TransactionMultiEd25519Signature
|
|
533
|
+
| TransactionMultiAgentSignature
|
|
534
|
+
| TransactionFeePayerSignature;
|
|
535
|
+
|
|
536
|
+
export type TransactionEd25519Signature = {
|
|
537
|
+
type: string;
|
|
538
|
+
public_key: string;
|
|
539
|
+
signature: "ed25519_signature";
|
|
540
|
+
};
|
|
541
|
+
|
|
542
|
+
export type TransactionSecp256k1Signature = {
|
|
543
|
+
type: string;
|
|
544
|
+
public_key: string;
|
|
545
|
+
signature: "secp256k1_ecdsa_signature";
|
|
546
|
+
};
|
|
547
|
+
|
|
548
|
+
export type TransactionMultiEd25519Signature = {
|
|
549
|
+
type: "multi_ed25519_signature";
|
|
550
|
+
/**
|
|
551
|
+
* The public keys for the Ed25519 signature
|
|
552
|
+
*/
|
|
553
|
+
public_keys: Array<string>;
|
|
554
|
+
/**
|
|
555
|
+
* Signature associated with the public keys in the same order
|
|
556
|
+
*/
|
|
557
|
+
signatures: Array<string>;
|
|
558
|
+
/**
|
|
559
|
+
* The number of signatures required for a successful transaction
|
|
560
|
+
*/
|
|
561
|
+
threshold: number;
|
|
562
|
+
bitmap: string;
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
export type TransactionMultiAgentSignature = {
|
|
566
|
+
type: "multi_agent_signature";
|
|
567
|
+
sender: AccountSignature;
|
|
568
|
+
/**
|
|
569
|
+
* The other involved parties' addresses
|
|
570
|
+
*/
|
|
571
|
+
secondary_signer_addresses: Array<string>;
|
|
572
|
+
/**
|
|
573
|
+
* The associated signatures, in the same order as the secondary addresses
|
|
574
|
+
*/
|
|
575
|
+
secondary_signers: Array<AccountSignature>;
|
|
576
|
+
};
|
|
577
|
+
|
|
578
|
+
export type TransactionFeePayerSignature = {
|
|
579
|
+
type: "fee_payer_signature";
|
|
580
|
+
sender: AccountSignature;
|
|
581
|
+
/**
|
|
582
|
+
* The other involved parties' addresses
|
|
583
|
+
*/
|
|
584
|
+
secondary_signer_addresses: Array<string>;
|
|
585
|
+
/**
|
|
586
|
+
* The associated signatures, in the same order as the secondary addresses
|
|
587
|
+
*/
|
|
588
|
+
secondary_signers: Array<AccountSignature>;
|
|
589
|
+
fee_payer_address: string;
|
|
590
|
+
fee_payer_signer: AccountSignature;
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* The union of all single account signatures.
|
|
595
|
+
*/
|
|
596
|
+
export type AccountSignature = AccountEd25519Signature | AccountSecp256k1Signature | AccountMultiEd25519Signature;
|
|
597
|
+
|
|
598
|
+
export type AccountEd25519Signature = TransactionEd25519Signature;
|
|
599
|
+
|
|
600
|
+
export type AccountSecp256k1Signature = TransactionSecp256k1Signature;
|
|
601
|
+
|
|
602
|
+
export type AccountMultiEd25519Signature = TransactionMultiEd25519Signature;
|
|
603
|
+
|
|
604
|
+
export type WriteSet = ScriptWriteSet | DirectWriteSet;
|
|
605
|
+
|
|
606
|
+
export type ScriptWriteSet = {
|
|
607
|
+
type: string;
|
|
608
|
+
execute_as: string;
|
|
609
|
+
script: ScriptPayloadResponse;
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
export type DirectWriteSet = {
|
|
613
|
+
type: string;
|
|
614
|
+
changes: Array<WriteSetChange>;
|
|
615
|
+
events: Array<Event>;
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
export type EventGuid = {
|
|
619
|
+
creation_number: string;
|
|
620
|
+
account_address: string;
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
export type Event = {
|
|
624
|
+
guid: EventGuid;
|
|
625
|
+
sequence_number: string;
|
|
626
|
+
type: string;
|
|
627
|
+
/**
|
|
628
|
+
* The JSON representation of the event
|
|
629
|
+
*/
|
|
630
|
+
data: any;
|
|
631
|
+
};
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Map of Move types to local TypeScript types
|
|
635
|
+
*/
|
|
636
|
+
export type MoveUint8Type = number;
|
|
637
|
+
export type MoveUint16Type = number;
|
|
638
|
+
export type MoveUint32Type = number;
|
|
639
|
+
export type MoveUint64Type = string;
|
|
640
|
+
export type MoveUint128Type = string;
|
|
641
|
+
export type MoveUint256Type = string;
|
|
642
|
+
export type MoveAddressType = `0x${string}`;
|
|
643
|
+
export type MoveObjectType = `0x${string}`;
|
|
644
|
+
export type MoveStructType = `0x${string}::${string}::${string}`;
|
|
645
|
+
export type MoveOptionType = MoveType | null | undefined;
|
|
646
|
+
/**
|
|
647
|
+
* String representation of a on-chain Move struct type.
|
|
648
|
+
*/
|
|
649
|
+
export type MoveResourceType = `${string}::${string}::${string}`;
|
|
650
|
+
|
|
651
|
+
export type MoveType =
|
|
652
|
+
| boolean
|
|
653
|
+
| string
|
|
654
|
+
| MoveUint8Type
|
|
655
|
+
| MoveUint16Type
|
|
656
|
+
| MoveUint32Type
|
|
657
|
+
| MoveUint64Type
|
|
658
|
+
| MoveUint128Type
|
|
659
|
+
| MoveUint256Type
|
|
660
|
+
| MoveAddressType
|
|
661
|
+
| MoveObjectType
|
|
662
|
+
| MoveStructType
|
|
663
|
+
| Array<MoveType>;
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Possible Move values acceptable by move functions (entry, view)
|
|
667
|
+
*
|
|
668
|
+
* Map of a Move value to the corresponding TypeScript value
|
|
669
|
+
*
|
|
670
|
+
* `Bool -> boolean`
|
|
671
|
+
*
|
|
672
|
+
* `u8, u16, u32 -> number`
|
|
673
|
+
*
|
|
674
|
+
* `u64, u128, u256 -> string`
|
|
675
|
+
*
|
|
676
|
+
* `String -> string`
|
|
677
|
+
*
|
|
678
|
+
* `Address -> 0x${string}`
|
|
679
|
+
*
|
|
680
|
+
* `Struct - 0x${string}::${string}::${string}`
|
|
681
|
+
*
|
|
682
|
+
* `Object -> 0x${string}`
|
|
683
|
+
*
|
|
684
|
+
* `Vector -> Array<MoveValue>`
|
|
685
|
+
*
|
|
686
|
+
* `Option -> MoveValue | null | undefined`
|
|
687
|
+
*/
|
|
688
|
+
export type MoveValue =
|
|
689
|
+
| boolean
|
|
690
|
+
| string
|
|
691
|
+
| MoveUint8Type
|
|
692
|
+
| MoveUint16Type
|
|
693
|
+
| MoveUint32Type
|
|
694
|
+
| MoveUint64Type
|
|
695
|
+
| MoveUint128Type
|
|
696
|
+
| MoveUint256Type
|
|
697
|
+
| MoveAddressType
|
|
698
|
+
| MoveObjectType
|
|
699
|
+
| MoveStructType
|
|
700
|
+
| MoveOptionType
|
|
701
|
+
| Array<MoveValue>;
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Move module id is a string representation of Move module.
|
|
705
|
+
* Module name is case-sensitive.
|
|
706
|
+
*/
|
|
707
|
+
export type MoveModuleId = `${string}::${string}`;
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Move function visibility
|
|
711
|
+
*/
|
|
712
|
+
export enum MoveFunctionVisibility {
|
|
713
|
+
PRIVATE = "private",
|
|
714
|
+
PUBLIC = "public",
|
|
715
|
+
FRIEND = "friend",
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Move function ability
|
|
720
|
+
*/
|
|
721
|
+
export enum MoveAbility {
|
|
722
|
+
STORE = "store",
|
|
723
|
+
DROP = "drop",
|
|
724
|
+
KEY = "key",
|
|
725
|
+
COPY = "copy",
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Move abilities tied to the generic type param and associated with the function that uses it
|
|
730
|
+
*/
|
|
731
|
+
export type MoveFunctionGenericTypeParam = {
|
|
732
|
+
constraints: Array<MoveAbility>;
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
/**
|
|
736
|
+
* Move struct field
|
|
737
|
+
*/
|
|
738
|
+
export type MoveStructField = {
|
|
739
|
+
name: string;
|
|
740
|
+
type: string;
|
|
741
|
+
};
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* A Move module
|
|
745
|
+
*/
|
|
746
|
+
export type MoveModule = {
|
|
747
|
+
address: string;
|
|
748
|
+
name: string;
|
|
749
|
+
/**
|
|
750
|
+
* Friends of the module
|
|
751
|
+
*/
|
|
752
|
+
friends: Array<MoveModuleId>;
|
|
753
|
+
/**
|
|
754
|
+
* Public functions of the module
|
|
755
|
+
*/
|
|
756
|
+
exposed_functions: Array<MoveFunction>;
|
|
757
|
+
/**
|
|
758
|
+
* Structs of the module
|
|
759
|
+
*/
|
|
760
|
+
structs: Array<MoveStruct>;
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* A move struct
|
|
765
|
+
*/
|
|
766
|
+
export type MoveStruct = {
|
|
767
|
+
name: string;
|
|
768
|
+
/**
|
|
769
|
+
* Whether the struct is a native struct of Move
|
|
770
|
+
*/
|
|
771
|
+
is_native: boolean;
|
|
772
|
+
/**
|
|
773
|
+
* Abilities associated with the struct
|
|
774
|
+
*/
|
|
775
|
+
abilities: Array<MoveAbility>;
|
|
776
|
+
/**
|
|
777
|
+
* Generic types associated with the struct
|
|
778
|
+
*/
|
|
779
|
+
generic_type_params: Array<MoveFunctionGenericTypeParam>;
|
|
780
|
+
/**
|
|
781
|
+
* Fields associated with the struct
|
|
782
|
+
*/
|
|
783
|
+
fields: Array<MoveStructField>;
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
/**
|
|
787
|
+
* Move function
|
|
788
|
+
*/
|
|
789
|
+
export type MoveFunction = {
|
|
790
|
+
name: string;
|
|
791
|
+
visibility: MoveFunctionVisibility;
|
|
792
|
+
/**
|
|
793
|
+
* Whether the function can be called as an entry function directly in a transaction
|
|
794
|
+
*/
|
|
795
|
+
is_entry: boolean;
|
|
796
|
+
/**
|
|
797
|
+
* Whether the function is a view function or not
|
|
798
|
+
*/
|
|
799
|
+
is_view: boolean;
|
|
800
|
+
/**
|
|
801
|
+
* Generic type params associated with the Move function
|
|
802
|
+
*/
|
|
803
|
+
generic_type_params: Array<MoveFunctionGenericTypeParam>;
|
|
804
|
+
/**
|
|
805
|
+
* Parameters associated with the move function
|
|
806
|
+
*/
|
|
807
|
+
params: Array<string>;
|
|
808
|
+
/**
|
|
809
|
+
* Return type of the function
|
|
810
|
+
*/
|
|
811
|
+
return: Array<string>;
|
|
812
|
+
};
|
|
813
|
+
|
|
814
|
+
export enum RoleType {
|
|
815
|
+
VALIDATOR = "validator",
|
|
816
|
+
FULL_NODE = "full_node",
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
export type LedgerInfo = {
|
|
820
|
+
/**
|
|
821
|
+
* Chain ID of the current chain
|
|
822
|
+
*/
|
|
823
|
+
chain_id: number;
|
|
824
|
+
epoch: string;
|
|
825
|
+
ledger_version: string;
|
|
826
|
+
oldest_ledger_version: string;
|
|
827
|
+
ledger_timestamp: string;
|
|
828
|
+
node_role: RoleType;
|
|
829
|
+
oldest_block_height: string;
|
|
830
|
+
block_height: string;
|
|
831
|
+
/**
|
|
832
|
+
* Git hash of the build of the API endpoint. Can be used to determine the exact
|
|
833
|
+
* software version used by the API endpoint.
|
|
834
|
+
*/
|
|
835
|
+
git_hash?: string;
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
/**
|
|
839
|
+
* A Block type
|
|
840
|
+
*/
|
|
841
|
+
export type Block = {
|
|
842
|
+
block_height: string;
|
|
843
|
+
block_hash: `0x${string}`;
|
|
844
|
+
block_timestamp: string;
|
|
845
|
+
first_version: string;
|
|
846
|
+
last_version: string;
|
|
847
|
+
/**
|
|
848
|
+
* The transactions in the block in sequential order
|
|
849
|
+
*/
|
|
850
|
+
transactions?: Array<TransactionResponse>;
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* The data needed to generate a View Request payload
|
|
855
|
+
*/
|
|
856
|
+
export type ViewRequestData = {
|
|
857
|
+
function: MoveStructType;
|
|
858
|
+
typeArguments?: Array<MoveResourceType>;
|
|
859
|
+
arguments?: Array<MoveValue>;
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
// REQUEST TYPES
|
|
863
|
+
|
|
864
|
+
/**
|
|
865
|
+
* View request for the Move view function API
|
|
866
|
+
*
|
|
867
|
+
* `type MoveResourceType = ${string}::${string}::${string}`;
|
|
868
|
+
*/
|
|
869
|
+
export type ViewRequest = {
|
|
870
|
+
function: MoveResourceType;
|
|
871
|
+
/**
|
|
872
|
+
* Type arguments of the function
|
|
873
|
+
*/
|
|
874
|
+
type_arguments: Array<MoveResourceType>;
|
|
875
|
+
/**
|
|
876
|
+
* Arguments of the function
|
|
877
|
+
*/
|
|
878
|
+
arguments: Array<MoveValue>;
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Table Item request for the GetTableItem API
|
|
883
|
+
*/
|
|
884
|
+
export type TableItemRequest = {
|
|
885
|
+
key_type: MoveValue;
|
|
886
|
+
value_type: MoveValue;
|
|
887
|
+
/**
|
|
888
|
+
* The value of the table item's key
|
|
889
|
+
*/
|
|
890
|
+
key: any;
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
* A list of Authentication Key schemes that are supported by Aptos.
|
|
895
|
+
*
|
|
896
|
+
* They are combinations of signing schemes and derive schemes.
|
|
897
|
+
*/
|
|
898
|
+
export type AuthenticationKeyScheme = SigningScheme | DeriveScheme;
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* A list of signing schemes that are supported by Aptos.
|
|
902
|
+
*
|
|
903
|
+
* https://github.com/aptos-labs/aptos-core/blob/main/types/src/transaction/authenticator.rs#L375-L378
|
|
904
|
+
*/
|
|
905
|
+
export enum SigningScheme {
|
|
906
|
+
/**
|
|
907
|
+
* For Ed25519PublicKey
|
|
908
|
+
*/
|
|
909
|
+
Ed25519 = 0,
|
|
910
|
+
/**
|
|
911
|
+
* For MultiEd25519PublicKey
|
|
912
|
+
*/
|
|
913
|
+
MultiEd25519 = 1,
|
|
914
|
+
/**
|
|
915
|
+
* For Secp256k1 ecdsa
|
|
916
|
+
*/
|
|
917
|
+
Secp256k1Ecdsa = 2,
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* Scheme used for deriving account addresses from other data
|
|
922
|
+
*/
|
|
923
|
+
export enum DeriveScheme {
|
|
924
|
+
/**
|
|
925
|
+
* Derives an address using an AUID, used for objects
|
|
926
|
+
*/
|
|
927
|
+
DeriveAuid = 251,
|
|
928
|
+
/**
|
|
929
|
+
* Derives an address from another object address
|
|
930
|
+
*/
|
|
931
|
+
DeriveObjectAddressFromObject = 252,
|
|
932
|
+
/**
|
|
933
|
+
* Derives an address from a GUID, used for objects
|
|
934
|
+
*/
|
|
935
|
+
DeriveObjectAddressFromGuid = 253,
|
|
936
|
+
/**
|
|
937
|
+
* Derives an address from seed bytes, used for named objects
|
|
938
|
+
*/
|
|
939
|
+
DeriveObjectAddressFromSeed = 254,
|
|
940
|
+
/**
|
|
941
|
+
* Derives an address from seed bytes, used for resource accounts
|
|
942
|
+
*/
|
|
943
|
+
DeriveResourceAccountAddress = 255,
|
|
944
|
+
}
|