@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,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
|