@aptos-labs/ts-sdk 0.0.1 → 0.0.3
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/README.md +32 -24
- package/dist/browser/index.global.js +25 -25
- package/dist/browser/index.global.js.map +1 -1
- package/dist/cjs/index.d.ts +809 -184
- package/dist/cjs/index.js +1458 -616
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.d.ts +809 -184
- package/dist/esm/index.mjs +1388 -614
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +72 -25
- package/dist/types/index.js +28 -3
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/account.ts +2 -2
- package/src/api/coin.ts +5 -5
- package/src/api/digitalAsset.ts +5 -5
- package/src/api/event.ts +2 -2
- package/src/api/faucet.ts +7 -3
- package/src/api/transactionSubmission.ts +24 -24
- package/src/bcs/serializable/fixedBytes.ts +1 -1
- package/src/bcs/serializable/moveStructs.ts +16 -36
- package/src/core/account.ts +12 -8
- package/src/core/accountAddress.ts +4 -2
- package/src/core/authenticationKey.ts +24 -2
- package/src/core/crypto/anyPublicKey.ts +14 -18
- package/src/core/crypto/ed25519.ts +6 -0
- package/src/core/crypto/index.ts +1 -0
- package/src/core/crypto/multiKey.ts +122 -0
- package/src/core/crypto/secp256k1.ts +2 -0
- package/src/index.ts +1 -2
- package/src/internal/account.ts +5 -5
- package/src/internal/coin.ts +8 -8
- package/src/internal/digitalAsset.ts +7 -7
- package/src/internal/event.ts +2 -2
- package/src/internal/faucet.ts +9 -5
- package/src/internal/transactionSubmission.ts +40 -15
- package/src/transactions/authenticator/account.ts +39 -0
- package/src/transactions/authenticator/index.ts +5 -0
- package/src/transactions/authenticator/transaction.ts +6 -6
- package/src/transactions/index.ts +9 -0
- package/src/transactions/instances/index.ts +1 -0
- package/src/transactions/instances/transactionPayload.ts +13 -8
- package/src/transactions/transactionBuilder/helpers.ts +99 -0
- package/src/transactions/transactionBuilder/index.ts +6 -0
- package/src/transactions/transactionBuilder/remoteAbi.ts +339 -0
- package/src/transactions/{transaction_builder/transaction_builder.ts → transactionBuilder/transactionBuilder.ts} +149 -68
- package/src/transactions/typeTag/index.ts +385 -0
- package/src/transactions/typeTag/parser.ts +21 -8
- package/src/transactions/types.ts +87 -46
- package/src/types/index.ts +18 -16
- package/src/transactions/typeTag/typeTag.ts +0 -487
package/dist/cjs/index.js
CHANGED
|
@@ -38,32 +38,47 @@ __export(src_exports, {
|
|
|
38
38
|
APTOS_PATH_REGEX: () => APTOS_PATH_REGEX,
|
|
39
39
|
Account: () => Account,
|
|
40
40
|
AccountAddress: () => AccountAddress,
|
|
41
|
+
AccountAuthenticator: () => AccountAuthenticator,
|
|
42
|
+
AccountAuthenticatorEd25519: () => AccountAuthenticatorEd25519,
|
|
43
|
+
AccountAuthenticatorMultiEd25519: () => AccountAuthenticatorMultiEd25519,
|
|
44
|
+
AccountAuthenticatorMultiKey: () => AccountAuthenticatorMultiKey,
|
|
45
|
+
AccountAuthenticatorSingleKey: () => AccountAuthenticatorSingleKey,
|
|
41
46
|
AccountAuthenticatorVariant: () => AccountAuthenticatorVariant,
|
|
42
47
|
AddressInvalidReason: () => AddressInvalidReason,
|
|
48
|
+
AnyPublicKeyVariant: () => AnyPublicKeyVariant,
|
|
49
|
+
AnySignatureVariant: () => AnySignatureVariant,
|
|
43
50
|
Aptos: () => Aptos,
|
|
44
51
|
AptosApiError: () => AptosApiError,
|
|
45
52
|
AptosConfig: () => AptosConfig,
|
|
46
53
|
AuthenticationKey: () => AuthenticationKey,
|
|
47
54
|
Bool: () => Bool,
|
|
55
|
+
ChainId: () => ChainId,
|
|
48
56
|
DeriveScheme: () => DeriveScheme,
|
|
49
57
|
Deserializer: () => Deserializer,
|
|
50
58
|
Ed25519PrivateKey: () => Ed25519PrivateKey,
|
|
51
59
|
Ed25519PublicKey: () => Ed25519PublicKey,
|
|
52
60
|
Ed25519Signature: () => Ed25519Signature,
|
|
61
|
+
EntryFunction: () => EntryFunction,
|
|
53
62
|
EntryFunctionBytes: () => EntryFunctionBytes,
|
|
63
|
+
FeePayerRawTransaction: () => FeePayerRawTransaction,
|
|
54
64
|
FixedBytes: () => FixedBytes,
|
|
55
65
|
Hex: () => Hex,
|
|
56
66
|
HexInvalidReason: () => HexInvalidReason,
|
|
67
|
+
Identifier: () => Identifier,
|
|
57
68
|
KeyType: () => KeyType,
|
|
58
69
|
MimeType: () => MimeType,
|
|
70
|
+
ModuleId: () => ModuleId,
|
|
59
71
|
MoveAbility: () => MoveAbility,
|
|
60
72
|
MoveFunctionVisibility: () => MoveFunctionVisibility,
|
|
61
|
-
MoveObject: () => MoveObject,
|
|
62
73
|
MoveOption: () => MoveOption,
|
|
63
74
|
MoveString: () => MoveString,
|
|
64
75
|
MoveVector: () => MoveVector,
|
|
76
|
+
MultiAgentRawTransaction: () => MultiAgentRawTransaction,
|
|
65
77
|
MultiEd25519PublicKey: () => MultiEd25519PublicKey,
|
|
66
78
|
MultiEd25519Signature: () => MultiEd25519Signature,
|
|
79
|
+
MultiKey: () => MultiKey,
|
|
80
|
+
MultiSig: () => MultiSig,
|
|
81
|
+
MultisigTransactionPayload: () => MultisigTransactionPayload,
|
|
67
82
|
Network: () => Network,
|
|
68
83
|
NetworkToChainId: () => NetworkToChainId,
|
|
69
84
|
NetworkToFaucetAPI: () => NetworkToFaucetAPI,
|
|
@@ -72,7 +87,10 @@ __export(src_exports, {
|
|
|
72
87
|
ParsingError: () => ParsingError,
|
|
73
88
|
PrivateKey: () => PrivateKey,
|
|
74
89
|
PublicKey: () => PublicKey,
|
|
90
|
+
RawTransaction: () => RawTransaction,
|
|
91
|
+
RawTransactionWithData: () => RawTransactionWithData,
|
|
75
92
|
RoleType: () => RoleType,
|
|
93
|
+
Script: () => Script,
|
|
76
94
|
ScriptTransactionArgumentVariants: () => ScriptTransactionArgumentVariants,
|
|
77
95
|
Secp256k1PrivateKey: () => Secp256k1PrivateKey,
|
|
78
96
|
Secp256k1PublicKey: () => Secp256k1PublicKey,
|
|
@@ -80,17 +98,31 @@ __export(src_exports, {
|
|
|
80
98
|
Serializable: () => Serializable,
|
|
81
99
|
Serializer: () => Serializer,
|
|
82
100
|
Signature: () => Signature,
|
|
101
|
+
SignedTransaction: () => SignedTransaction,
|
|
83
102
|
SigningScheme: () => SigningScheme,
|
|
103
|
+
SigningSchemeInput: () => SigningSchemeInput,
|
|
84
104
|
StructTag: () => StructTag,
|
|
105
|
+
TransactionAuthenticator: () => TransactionAuthenticator,
|
|
106
|
+
TransactionAuthenticatorEd25519: () => TransactionAuthenticatorEd25519,
|
|
107
|
+
TransactionAuthenticatorFeePayer: () => TransactionAuthenticatorFeePayer,
|
|
108
|
+
TransactionAuthenticatorMultiAgent: () => TransactionAuthenticatorMultiAgent,
|
|
109
|
+
TransactionAuthenticatorMultiEd25519: () => TransactionAuthenticatorMultiEd25519,
|
|
110
|
+
TransactionAuthenticatorSingleSender: () => TransactionAuthenticatorSingleSender,
|
|
85
111
|
TransactionAuthenticatorVariant: () => TransactionAuthenticatorVariant,
|
|
112
|
+
TransactionPayload: () => TransactionPayload,
|
|
113
|
+
TransactionPayloadEntryFunction: () => TransactionPayloadEntryFunction,
|
|
114
|
+
TransactionPayloadMultisig: () => TransactionPayloadMultisig,
|
|
115
|
+
TransactionPayloadScript: () => TransactionPayloadScript,
|
|
86
116
|
TransactionPayloadVariants: () => TransactionPayloadVariants,
|
|
87
117
|
TransactionResponseType: () => TransactionResponseType,
|
|
88
118
|
TransactionVariants: () => TransactionVariants,
|
|
89
119
|
TypeTag: () => TypeTag,
|
|
90
120
|
TypeTagAddress: () => TypeTagAddress,
|
|
91
121
|
TypeTagBool: () => TypeTagBool,
|
|
92
|
-
|
|
122
|
+
TypeTagGeneric: () => TypeTagGeneric,
|
|
93
123
|
TypeTagParserError: () => TypeTagParserError,
|
|
124
|
+
TypeTagParserErrorType: () => TypeTagParserErrorType,
|
|
125
|
+
TypeTagReference: () => TypeTagReference,
|
|
94
126
|
TypeTagSigner: () => TypeTagSigner,
|
|
95
127
|
TypeTagStruct: () => TypeTagStruct,
|
|
96
128
|
TypeTagU128: () => TypeTagU128,
|
|
@@ -107,22 +139,58 @@ __export(src_exports, {
|
|
|
107
139
|
U32: () => U32,
|
|
108
140
|
U64: () => U64,
|
|
109
141
|
U8: () => U8,
|
|
142
|
+
aptosCoinStructTag: () => aptosCoinStructTag,
|
|
110
143
|
aptosRequest: () => aptosRequest,
|
|
144
|
+
buildTransaction: () => buildTransaction,
|
|
145
|
+
convertArgument: () => convertArgument,
|
|
111
146
|
derivePrivateKeyFromMnemonic: () => derivePrivateKeyFromMnemonic,
|
|
147
|
+
deriveTransactionType: () => deriveTransactionType,
|
|
148
|
+
deserializeFromScriptArgument: () => deserializeFromScriptArgument,
|
|
112
149
|
ensureBoolean: () => ensureBoolean,
|
|
150
|
+
fetchEntryFunctionAbi: () => fetchEntryFunctionAbi,
|
|
151
|
+
findFirstNonSignerArg: () => findFirstNonSignerArg,
|
|
152
|
+
generateMultiSignersSignedTransaction: () => generateMultiSignersSignedTransaction,
|
|
153
|
+
generateRawTransaction: () => generateRawTransaction,
|
|
154
|
+
generateSignedTransaction: () => generateSignedTransaction,
|
|
155
|
+
generateSignedTransactionForSimulation: () => generateSignedTransactionForSimulation,
|
|
156
|
+
generateTransactionPayload: () => generateTransactionPayload,
|
|
157
|
+
generateTransactionPayloadWithABI: () => generateTransactionPayloadWithABI,
|
|
113
158
|
get: () => get,
|
|
114
159
|
getAptosFullNode: () => getAptosFullNode,
|
|
160
|
+
getAuthenticatorForSimulation: () => getAuthenticatorForSimulation,
|
|
161
|
+
getFunctionParts: () => getFunctionParts,
|
|
162
|
+
getSigningMessage: () => getSigningMessage,
|
|
163
|
+
isBcsAddress: () => isBcsAddress,
|
|
164
|
+
isBcsBool: () => isBcsBool,
|
|
165
|
+
isBcsFixedBytes: () => isBcsFixedBytes,
|
|
166
|
+
isBcsString: () => isBcsString,
|
|
167
|
+
isBcsU128: () => isBcsU128,
|
|
168
|
+
isBcsU16: () => isBcsU16,
|
|
169
|
+
isBcsU256: () => isBcsU256,
|
|
170
|
+
isBcsU32: () => isBcsU32,
|
|
171
|
+
isBcsU64: () => isBcsU64,
|
|
172
|
+
isBcsU8: () => isBcsU8,
|
|
173
|
+
isBool: () => isBool,
|
|
174
|
+
isLargeNumber: () => isLargeNumber,
|
|
175
|
+
isNull: () => isNull,
|
|
176
|
+
isNumber: () => isNumber,
|
|
177
|
+
isScriptDataInput: () => isScriptDataInput,
|
|
178
|
+
isString: () => isString,
|
|
115
179
|
isValidPath: () => isValidPath,
|
|
116
180
|
objectStructTag: () => objectStructTag,
|
|
117
181
|
optionStructTag: () => optionStructTag,
|
|
118
182
|
outOfRangeErrorMessage: () => outOfRangeErrorMessage,
|
|
119
183
|
paginateWithCursor: () => paginateWithCursor,
|
|
184
|
+
parseTypeTag: () => parseTypeTag,
|
|
120
185
|
post: () => post,
|
|
121
186
|
postAptosFaucet: () => postAptosFaucet,
|
|
122
187
|
postAptosFullNode: () => postAptosFullNode,
|
|
123
188
|
postAptosIndexer: () => postAptosIndexer,
|
|
124
189
|
request: () => request,
|
|
190
|
+
sign: () => sign,
|
|
191
|
+
standardizeTypeTags: () => standardizeTypeTags,
|
|
125
192
|
stringStructTag: () => stringStructTag,
|
|
193
|
+
throwTypeMismatch: () => throwTypeMismatch,
|
|
126
194
|
validateNumberInRange: () => validateNumberInRange
|
|
127
195
|
});
|
|
128
196
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -141,7 +209,7 @@ var AptosApiError = class extends Error {
|
|
|
141
209
|
};
|
|
142
210
|
|
|
143
211
|
// src/version.ts
|
|
144
|
-
var VERSION = "
|
|
212
|
+
var VERSION = "2.0.0";
|
|
145
213
|
|
|
146
214
|
// src/types/index.ts
|
|
147
215
|
var MimeType = /* @__PURE__ */ ((MimeType2) => {
|
|
@@ -162,6 +230,8 @@ var TypeTagVariants = /* @__PURE__ */ ((TypeTagVariants2) => {
|
|
|
162
230
|
TypeTagVariants2[TypeTagVariants2["U16"] = 8] = "U16";
|
|
163
231
|
TypeTagVariants2[TypeTagVariants2["U32"] = 9] = "U32";
|
|
164
232
|
TypeTagVariants2[TypeTagVariants2["U256"] = 10] = "U256";
|
|
233
|
+
TypeTagVariants2[TypeTagVariants2["Reference"] = 254] = "Reference";
|
|
234
|
+
TypeTagVariants2[TypeTagVariants2["Generic"] = 255] = "Generic";
|
|
165
235
|
return TypeTagVariants2;
|
|
166
236
|
})(TypeTagVariants || {});
|
|
167
237
|
var ScriptTransactionArgumentVariants = /* @__PURE__ */ ((ScriptTransactionArgumentVariants2) => {
|
|
@@ -192,15 +262,26 @@ var TransactionAuthenticatorVariant = /* @__PURE__ */ ((TransactionAuthenticator
|
|
|
192
262
|
TransactionAuthenticatorVariant2[TransactionAuthenticatorVariant2["MultiEd25519"] = 1] = "MultiEd25519";
|
|
193
263
|
TransactionAuthenticatorVariant2[TransactionAuthenticatorVariant2["MultiAgent"] = 2] = "MultiAgent";
|
|
194
264
|
TransactionAuthenticatorVariant2[TransactionAuthenticatorVariant2["FeePayer"] = 3] = "FeePayer";
|
|
195
|
-
TransactionAuthenticatorVariant2[TransactionAuthenticatorVariant2["
|
|
265
|
+
TransactionAuthenticatorVariant2[TransactionAuthenticatorVariant2["SingleSender"] = 4] = "SingleSender";
|
|
196
266
|
return TransactionAuthenticatorVariant2;
|
|
197
267
|
})(TransactionAuthenticatorVariant || {});
|
|
198
268
|
var AccountAuthenticatorVariant = /* @__PURE__ */ ((AccountAuthenticatorVariant2) => {
|
|
199
269
|
AccountAuthenticatorVariant2[AccountAuthenticatorVariant2["Ed25519"] = 0] = "Ed25519";
|
|
200
270
|
AccountAuthenticatorVariant2[AccountAuthenticatorVariant2["MultiEd25519"] = 1] = "MultiEd25519";
|
|
201
|
-
AccountAuthenticatorVariant2[AccountAuthenticatorVariant2["
|
|
271
|
+
AccountAuthenticatorVariant2[AccountAuthenticatorVariant2["SingleKey"] = 2] = "SingleKey";
|
|
272
|
+
AccountAuthenticatorVariant2[AccountAuthenticatorVariant2["MultiKey"] = 3] = "MultiKey";
|
|
202
273
|
return AccountAuthenticatorVariant2;
|
|
203
274
|
})(AccountAuthenticatorVariant || {});
|
|
275
|
+
var AnyPublicKeyVariant = /* @__PURE__ */ ((AnyPublicKeyVariant2) => {
|
|
276
|
+
AnyPublicKeyVariant2[AnyPublicKeyVariant2["Ed25519"] = 0] = "Ed25519";
|
|
277
|
+
AnyPublicKeyVariant2[AnyPublicKeyVariant2["Secp256k1"] = 1] = "Secp256k1";
|
|
278
|
+
return AnyPublicKeyVariant2;
|
|
279
|
+
})(AnyPublicKeyVariant || {});
|
|
280
|
+
var AnySignatureVariant = /* @__PURE__ */ ((AnySignatureVariant2) => {
|
|
281
|
+
AnySignatureVariant2[AnySignatureVariant2["Ed25519"] = 0] = "Ed25519";
|
|
282
|
+
AnySignatureVariant2[AnySignatureVariant2["Secp256k1"] = 1] = "Secp256k1";
|
|
283
|
+
return AnySignatureVariant2;
|
|
284
|
+
})(AnySignatureVariant || {});
|
|
204
285
|
var TransactionResponseType = /* @__PURE__ */ ((TransactionResponseType2) => {
|
|
205
286
|
TransactionResponseType2["Pending"] = "pending_transaction";
|
|
206
287
|
TransactionResponseType2["User"] = "user_transaction";
|
|
@@ -230,9 +311,15 @@ var RoleType = /* @__PURE__ */ ((RoleType2) => {
|
|
|
230
311
|
var SigningScheme = /* @__PURE__ */ ((SigningScheme2) => {
|
|
231
312
|
SigningScheme2[SigningScheme2["Ed25519"] = 0] = "Ed25519";
|
|
232
313
|
SigningScheme2[SigningScheme2["MultiEd25519"] = 1] = "MultiEd25519";
|
|
233
|
-
SigningScheme2[SigningScheme2["
|
|
314
|
+
SigningScheme2[SigningScheme2["SingleKey"] = 2] = "SingleKey";
|
|
315
|
+
SigningScheme2[SigningScheme2["MultiKey"] = 3] = "MultiKey";
|
|
234
316
|
return SigningScheme2;
|
|
235
317
|
})(SigningScheme || {});
|
|
318
|
+
var SigningSchemeInput = /* @__PURE__ */ ((SigningSchemeInput2) => {
|
|
319
|
+
SigningSchemeInput2[SigningSchemeInput2["Ed25519"] = 0] = "Ed25519";
|
|
320
|
+
SigningSchemeInput2[SigningSchemeInput2["Secp256k1Ecdsa"] = 2] = "Secp256k1Ecdsa";
|
|
321
|
+
return SigningSchemeInput2;
|
|
322
|
+
})(SigningSchemeInput || {});
|
|
236
323
|
var DeriveScheme = /* @__PURE__ */ ((DeriveScheme2) => {
|
|
237
324
|
DeriveScheme2[DeriveScheme2["DeriveAuid"] = 251] = "DeriveAuid";
|
|
238
325
|
DeriveScheme2[DeriveScheme2["DeriveObjectAddressFromObject"] = 252] = "DeriveObjectAddressFromObject";
|
|
@@ -287,14 +374,15 @@ async function aptosRequest(options, aptosConfig) {
|
|
|
287
374
|
url: fullUrl
|
|
288
375
|
};
|
|
289
376
|
if (aptosConfig.isIndexerRequest(url)) {
|
|
290
|
-
|
|
377
|
+
const indexerResponse = result.data;
|
|
378
|
+
if (indexerResponse.errors) {
|
|
291
379
|
throw new AptosApiError(
|
|
292
380
|
options,
|
|
293
381
|
result,
|
|
294
|
-
(_a =
|
|
382
|
+
(_a = indexerResponse.errors[0].message) != null ? _a : `Unhandled Error ${response.status} : ${response.statusText}`
|
|
295
383
|
);
|
|
296
384
|
}
|
|
297
|
-
result.data =
|
|
385
|
+
result.data = indexerResponse.data;
|
|
298
386
|
}
|
|
299
387
|
if (result.status >= 200 && result.status < 300) {
|
|
300
388
|
return result;
|
|
@@ -362,7 +450,7 @@ async function get(options) {
|
|
|
362
450
|
acceptType: acceptType == null ? void 0 : acceptType.valueOf(),
|
|
363
451
|
params,
|
|
364
452
|
overrides: {
|
|
365
|
-
...aptosConfig,
|
|
453
|
+
...aptosConfig.clientConfig,
|
|
366
454
|
...overrides
|
|
367
455
|
}
|
|
368
456
|
},
|
|
@@ -410,7 +498,7 @@ async function post(options) {
|
|
|
410
498
|
acceptType: acceptType == null ? void 0 : acceptType.valueOf(),
|
|
411
499
|
params,
|
|
412
500
|
overrides: {
|
|
413
|
-
...aptosConfig,
|
|
501
|
+
...aptosConfig.clientConfig,
|
|
414
502
|
...overrides
|
|
415
503
|
}
|
|
416
504
|
},
|
|
@@ -809,6 +897,7 @@ var _AccountAddress = class extends Serializable {
|
|
|
809
897
|
var AccountAddress = _AccountAddress;
|
|
810
898
|
AccountAddress.LENGTH = 32;
|
|
811
899
|
AccountAddress.LONG_STRING_LENGTH = 64;
|
|
900
|
+
AccountAddress.ZERO = _AccountAddress.fromString("0x0");
|
|
812
901
|
AccountAddress.ONE = _AccountAddress.fromString("0x1");
|
|
813
902
|
AccountAddress.TWO = _AccountAddress.fromString("0x2");
|
|
814
903
|
AccountAddress.THREE = _AccountAddress.fromString("0x3");
|
|
@@ -1237,29 +1326,6 @@ var MoveOption = class extends Serializable {
|
|
|
1237
1326
|
return new MoveOption(vector.values[0]);
|
|
1238
1327
|
}
|
|
1239
1328
|
};
|
|
1240
|
-
var MoveObject = class extends Serializable {
|
|
1241
|
-
constructor(value) {
|
|
1242
|
-
super();
|
|
1243
|
-
if (value instanceof AccountAddress) {
|
|
1244
|
-
this.value = value;
|
|
1245
|
-
} else {
|
|
1246
|
-
this.value = AccountAddress.fromHexInputRelaxed(value);
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
serialize(serializer) {
|
|
1250
|
-
serializer.serialize(this.value);
|
|
1251
|
-
}
|
|
1252
|
-
serializeForEntryFunction(serializer) {
|
|
1253
|
-
this.value.serializeForEntryFunction(serializer);
|
|
1254
|
-
}
|
|
1255
|
-
serializeForScriptFunction(serializer) {
|
|
1256
|
-
this.value.serializeForScriptFunction(serializer);
|
|
1257
|
-
}
|
|
1258
|
-
static deserialize(deserializer) {
|
|
1259
|
-
const address = deserializer.deserialize(AccountAddress);
|
|
1260
|
-
return new MoveObject(address);
|
|
1261
|
-
}
|
|
1262
|
-
};
|
|
1263
1329
|
|
|
1264
1330
|
// src/core/crypto/asymmetricCrypto.ts
|
|
1265
1331
|
var PublicKey = class extends Serializable {
|
|
@@ -1298,6 +1364,10 @@ var _Ed25519PublicKey = class extends PublicKey {
|
|
|
1298
1364
|
const bytes = deserializer.deserializeBytes();
|
|
1299
1365
|
return new _Ed25519PublicKey(bytes);
|
|
1300
1366
|
}
|
|
1367
|
+
static load(deserializer) {
|
|
1368
|
+
const bytes = deserializer.deserializeBytes();
|
|
1369
|
+
return new _Ed25519PublicKey(bytes);
|
|
1370
|
+
}
|
|
1301
1371
|
};
|
|
1302
1372
|
var Ed25519PublicKey = _Ed25519PublicKey;
|
|
1303
1373
|
Ed25519PublicKey.LENGTH = 32;
|
|
@@ -1361,6 +1431,10 @@ var _Ed25519Signature = class extends Signature {
|
|
|
1361
1431
|
const bytes = deserializer.deserializeBytes();
|
|
1362
1432
|
return new _Ed25519Signature(bytes);
|
|
1363
1433
|
}
|
|
1434
|
+
static load(deserializer) {
|
|
1435
|
+
const bytes = deserializer.deserializeBytes();
|
|
1436
|
+
return new _Ed25519Signature(bytes);
|
|
1437
|
+
}
|
|
1364
1438
|
};
|
|
1365
1439
|
var Ed25519Signature = _Ed25519Signature;
|
|
1366
1440
|
Ed25519Signature.LENGTH = 64;
|
|
@@ -1511,6 +1585,10 @@ var _Secp256k1PublicKey = class extends PublicKey {
|
|
|
1511
1585
|
const bytes = deserializer.deserializeBytes();
|
|
1512
1586
|
return new _Secp256k1PublicKey(bytes);
|
|
1513
1587
|
}
|
|
1588
|
+
static load(deserializer) {
|
|
1589
|
+
const bytes = deserializer.deserializeBytes();
|
|
1590
|
+
return new _Secp256k1PublicKey(bytes);
|
|
1591
|
+
}
|
|
1514
1592
|
};
|
|
1515
1593
|
var Secp256k1PublicKey = _Secp256k1PublicKey;
|
|
1516
1594
|
Secp256k1PublicKey.LENGTH = 65;
|
|
@@ -1558,7 +1636,7 @@ var _Secp256k1Signature = class extends Signature {
|
|
|
1558
1636
|
super();
|
|
1559
1637
|
const hex = Hex.fromHexInput(hexInput);
|
|
1560
1638
|
if (hex.toUint8Array().length !== _Secp256k1Signature.LENGTH) {
|
|
1561
|
-
throw new Error(`Signature length should be ${_Secp256k1Signature.LENGTH}`);
|
|
1639
|
+
throw new Error(`Signature length should be ${_Secp256k1Signature.LENGTH}, recieved ${hex.toUint8Array().length}`);
|
|
1562
1640
|
}
|
|
1563
1641
|
this.data = hex;
|
|
1564
1642
|
}
|
|
@@ -1575,13 +1653,122 @@ var _Secp256k1Signature = class extends Signature {
|
|
|
1575
1653
|
const hex = deserializer.deserializeBytes();
|
|
1576
1654
|
return new _Secp256k1Signature(hex);
|
|
1577
1655
|
}
|
|
1656
|
+
static load(deserializer) {
|
|
1657
|
+
const bytes = deserializer.deserializeBytes();
|
|
1658
|
+
return new _Secp256k1Signature(bytes);
|
|
1659
|
+
}
|
|
1578
1660
|
};
|
|
1579
1661
|
var Secp256k1Signature = _Secp256k1Signature;
|
|
1580
1662
|
Secp256k1Signature.LENGTH = 64;
|
|
1581
1663
|
|
|
1664
|
+
// src/core/crypto/anyPublicKey.ts
|
|
1665
|
+
var AnyPublicKey = class extends PublicKey {
|
|
1666
|
+
constructor(publicKey) {
|
|
1667
|
+
super();
|
|
1668
|
+
this.publicKey = publicKey;
|
|
1669
|
+
}
|
|
1670
|
+
toUint8Array() {
|
|
1671
|
+
return this.publicKey.toUint8Array();
|
|
1672
|
+
}
|
|
1673
|
+
toString() {
|
|
1674
|
+
return this.publicKey.toString();
|
|
1675
|
+
}
|
|
1676
|
+
verifySignature(args) {
|
|
1677
|
+
const { message, signature } = args;
|
|
1678
|
+
return this.publicKey.verifySignature({ message, signature });
|
|
1679
|
+
}
|
|
1680
|
+
serialize(serializer) {
|
|
1681
|
+
if (this.publicKey instanceof Ed25519PublicKey) {
|
|
1682
|
+
serializer.serializeU32AsUleb128(0 /* Ed25519 */);
|
|
1683
|
+
this.publicKey.serialize(serializer);
|
|
1684
|
+
} else if (this.publicKey instanceof Secp256k1PublicKey) {
|
|
1685
|
+
serializer.serializeU32AsUleb128(1 /* Secp256k1 */);
|
|
1686
|
+
this.publicKey.serialize(serializer);
|
|
1687
|
+
} else {
|
|
1688
|
+
throw new Error("Unknown public key type");
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
static deserialize(deserializer) {
|
|
1692
|
+
const index = deserializer.deserializeUleb128AsU32();
|
|
1693
|
+
switch (index) {
|
|
1694
|
+
case 0 /* Ed25519 */:
|
|
1695
|
+
return new AnyPublicKey(Ed25519PublicKey.load(deserializer));
|
|
1696
|
+
case 1 /* Secp256k1 */:
|
|
1697
|
+
return new AnyPublicKey(Secp256k1PublicKey.load(deserializer));
|
|
1698
|
+
default:
|
|
1699
|
+
throw new Error(`Unknown variant index for AnyPublicKey: ${index}`);
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
|
|
1704
|
+
// src/core/crypto/multiKey.ts
|
|
1705
|
+
var MultiKey = class extends PublicKey {
|
|
1706
|
+
constructor(args) {
|
|
1707
|
+
super();
|
|
1708
|
+
const { publicKeys, signaturesRequired } = args;
|
|
1709
|
+
if (signaturesRequired < 1) {
|
|
1710
|
+
throw new Error("The number of required signatures needs to be greater then 0");
|
|
1711
|
+
}
|
|
1712
|
+
if (publicKeys.length < signaturesRequired) {
|
|
1713
|
+
throw new Error(
|
|
1714
|
+
`Provided ${publicKeys.length} public keys is smaller than the ${signaturesRequired} required signatures`
|
|
1715
|
+
);
|
|
1716
|
+
}
|
|
1717
|
+
const keys = [];
|
|
1718
|
+
publicKeys.forEach((publicKey) => {
|
|
1719
|
+
if (publicKey instanceof AnyPublicKey) {
|
|
1720
|
+
keys.push(publicKey);
|
|
1721
|
+
} else {
|
|
1722
|
+
keys.push(new AnyPublicKey(publicKey));
|
|
1723
|
+
}
|
|
1724
|
+
});
|
|
1725
|
+
this.publicKeys = keys;
|
|
1726
|
+
this.signaturesRequired = signaturesRequired;
|
|
1727
|
+
}
|
|
1728
|
+
toUint8Array() {
|
|
1729
|
+
return this.bcsToBytes();
|
|
1730
|
+
}
|
|
1731
|
+
createBitmap(args) {
|
|
1732
|
+
const { bits } = args;
|
|
1733
|
+
const firstBitInByte = 128;
|
|
1734
|
+
const bitmap = new Uint8Array([0, 0, 0, 0]);
|
|
1735
|
+
const dupCheckSet = /* @__PURE__ */ new Set();
|
|
1736
|
+
bits.forEach((bit, idx) => {
|
|
1737
|
+
if (idx + 1 > this.publicKeys.length) {
|
|
1738
|
+
throw new Error(`Signature index ${idx + 1} is out of public keys range, ${this.publicKeys.length}.`);
|
|
1739
|
+
}
|
|
1740
|
+
if (dupCheckSet.has(bit)) {
|
|
1741
|
+
throw new Error(`Duplicate bit ${bit} detected.`);
|
|
1742
|
+
}
|
|
1743
|
+
dupCheckSet.add(bit);
|
|
1744
|
+
const byteOffset = Math.floor(bit / 8);
|
|
1745
|
+
let byte = bitmap[byteOffset];
|
|
1746
|
+
byte |= firstBitInByte >> bit % 8;
|
|
1747
|
+
bitmap[byteOffset] = byte;
|
|
1748
|
+
});
|
|
1749
|
+
return bitmap;
|
|
1750
|
+
}
|
|
1751
|
+
toString() {
|
|
1752
|
+
return Hex.fromHexInput(this.toUint8Array()).toString();
|
|
1753
|
+
}
|
|
1754
|
+
verifySignature(args) {
|
|
1755
|
+
throw new Error("not implemented");
|
|
1756
|
+
}
|
|
1757
|
+
serialize(serializer) {
|
|
1758
|
+
serializer.serializeVector(this.publicKeys);
|
|
1759
|
+
serializer.serializeU8(this.signaturesRequired);
|
|
1760
|
+
}
|
|
1761
|
+
static deserialize(deserializer) {
|
|
1762
|
+
const keys = deserializer.deserializeVector(AnyPublicKey);
|
|
1763
|
+
const signaturesRequired = deserializer.deserializeU8();
|
|
1764
|
+
return new MultiKey({ publicKeys: keys, signaturesRequired });
|
|
1765
|
+
}
|
|
1766
|
+
};
|
|
1767
|
+
|
|
1582
1768
|
// src/core/authenticationKey.ts
|
|
1583
|
-
var _AuthenticationKey = class {
|
|
1769
|
+
var _AuthenticationKey = class extends Serializable {
|
|
1584
1770
|
constructor(args) {
|
|
1771
|
+
super();
|
|
1585
1772
|
const { data } = args;
|
|
1586
1773
|
const hex = Hex.fromHexInput(data);
|
|
1587
1774
|
if (hex.toUint8Array().length !== _AuthenticationKey.LENGTH) {
|
|
@@ -1589,21 +1776,43 @@ var _AuthenticationKey = class {
|
|
|
1589
1776
|
}
|
|
1590
1777
|
this.data = hex;
|
|
1591
1778
|
}
|
|
1779
|
+
serialize(serializer) {
|
|
1780
|
+
serializer.serializeFixedBytes(this.data.toUint8Array());
|
|
1781
|
+
}
|
|
1782
|
+
static deserialize(deserializer) {
|
|
1783
|
+
const bytes = deserializer.deserializeFixedBytes(_AuthenticationKey.LENGTH);
|
|
1784
|
+
return new _AuthenticationKey({ data: bytes });
|
|
1785
|
+
}
|
|
1592
1786
|
toString() {
|
|
1593
1787
|
return this.data.toString();
|
|
1594
1788
|
}
|
|
1595
1789
|
toUint8Array() {
|
|
1596
1790
|
return this.data.toUint8Array();
|
|
1597
1791
|
}
|
|
1598
|
-
static
|
|
1599
|
-
const {
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1792
|
+
static fromPublicKeyAndScheme(args) {
|
|
1793
|
+
const { publicKey, scheme } = args;
|
|
1794
|
+
let authKeyBytes;
|
|
1795
|
+
switch (scheme) {
|
|
1796
|
+
case 3 /* MultiKey */:
|
|
1797
|
+
case 2 /* SingleKey */: {
|
|
1798
|
+
const singleKeyBytes = publicKey.bcsToBytes();
|
|
1799
|
+
authKeyBytes = new Uint8Array([...singleKeyBytes, scheme]);
|
|
1800
|
+
break;
|
|
1801
|
+
}
|
|
1802
|
+
case 0 /* Ed25519 */:
|
|
1803
|
+
case 1 /* MultiEd25519 */: {
|
|
1804
|
+
const ed25519PublicKeyBytes = publicKey.toUint8Array();
|
|
1805
|
+
const inputBytes = Hex.fromHexInput(ed25519PublicKeyBytes).toUint8Array();
|
|
1806
|
+
authKeyBytes = new Uint8Array([...inputBytes, scheme]);
|
|
1807
|
+
break;
|
|
1808
|
+
}
|
|
1809
|
+
default:
|
|
1810
|
+
throw new Error(`Scheme ${scheme} is not supported`);
|
|
1811
|
+
}
|
|
1604
1812
|
const hash = import_sha32.sha3_256.create();
|
|
1605
1813
|
hash.update(authKeyBytes);
|
|
1606
|
-
|
|
1814
|
+
const hashDigest = hash.digest();
|
|
1815
|
+
return new _AuthenticationKey({ data: hashDigest });
|
|
1607
1816
|
}
|
|
1608
1817
|
static fromPublicKey(args) {
|
|
1609
1818
|
const { publicKey } = args;
|
|
@@ -1612,13 +1821,14 @@ var _AuthenticationKey = class {
|
|
|
1612
1821
|
scheme = 0 /* Ed25519 */.valueOf();
|
|
1613
1822
|
} else if (publicKey instanceof MultiEd25519PublicKey) {
|
|
1614
1823
|
scheme = 1 /* MultiEd25519 */.valueOf();
|
|
1615
|
-
} else if (publicKey instanceof
|
|
1616
|
-
scheme = 2 /*
|
|
1824
|
+
} else if (publicKey instanceof AnyPublicKey) {
|
|
1825
|
+
scheme = 2 /* SingleKey */.valueOf();
|
|
1826
|
+
} else if (publicKey instanceof MultiKey) {
|
|
1827
|
+
scheme = 3 /* MultiKey */.valueOf();
|
|
1617
1828
|
} else {
|
|
1618
1829
|
throw new Error("No supported authentication scheme for public key");
|
|
1619
1830
|
}
|
|
1620
|
-
|
|
1621
|
-
return _AuthenticationKey.fromBytesAndScheme({ bytes: pubKeyBytes, scheme });
|
|
1831
|
+
return _AuthenticationKey.fromPublicKeyAndScheme({ publicKey, scheme });
|
|
1622
1832
|
}
|
|
1623
1833
|
derivedAddress() {
|
|
1624
1834
|
return new AccountAddress({ data: this.data.toUint8Array() });
|
|
@@ -1676,50 +1886,58 @@ var derivePrivateKeyFromMnemonic = (keyType, path, seedPhrase, offset = HARDENED
|
|
|
1676
1886
|
// src/core/account.ts
|
|
1677
1887
|
var Account = class {
|
|
1678
1888
|
constructor(args) {
|
|
1679
|
-
const { privateKey, address } = args;
|
|
1889
|
+
const { privateKey, address, legacy } = args;
|
|
1680
1890
|
this.publicKey = privateKey.publicKey();
|
|
1681
1891
|
if (this.publicKey instanceof Ed25519PublicKey) {
|
|
1682
|
-
|
|
1892
|
+
if (legacy) {
|
|
1893
|
+
this.signingScheme = 0 /* Ed25519 */;
|
|
1894
|
+
} else {
|
|
1895
|
+
this.publicKey = new AnyPublicKey(this.publicKey);
|
|
1896
|
+
this.signingScheme = 2 /* SingleKey */;
|
|
1897
|
+
}
|
|
1683
1898
|
} else if (this.publicKey instanceof MultiEd25519PublicKey) {
|
|
1684
1899
|
this.signingScheme = 1 /* MultiEd25519 */;
|
|
1685
1900
|
} else if (this.publicKey instanceof Secp256k1PublicKey) {
|
|
1686
|
-
this.
|
|
1901
|
+
this.publicKey = new AnyPublicKey(this.publicKey);
|
|
1902
|
+
this.signingScheme = 2 /* SingleKey */;
|
|
1687
1903
|
} else {
|
|
1688
1904
|
throw new Error("Can not create new Account, unsupported public key type");
|
|
1689
1905
|
}
|
|
1690
1906
|
this.privateKey = privateKey;
|
|
1691
1907
|
this.accountAddress = address;
|
|
1692
1908
|
}
|
|
1693
|
-
static generate(
|
|
1909
|
+
static generate(args) {
|
|
1694
1910
|
let privateKey;
|
|
1695
|
-
switch (scheme) {
|
|
1911
|
+
switch (args == null ? void 0 : args.scheme) {
|
|
1696
1912
|
case 2 /* Secp256k1Ecdsa */:
|
|
1697
1913
|
privateKey = Secp256k1PrivateKey.generate();
|
|
1698
1914
|
break;
|
|
1699
1915
|
default:
|
|
1700
1916
|
privateKey = Ed25519PrivateKey.generate();
|
|
1701
1917
|
}
|
|
1918
|
+
let publicKey = privateKey.publicKey();
|
|
1919
|
+
if (!(args == null ? void 0 : args.legacy)) {
|
|
1920
|
+
publicKey = new AnyPublicKey(privateKey.publicKey());
|
|
1921
|
+
}
|
|
1702
1922
|
const address = new AccountAddress({
|
|
1703
1923
|
data: Account.authKey({
|
|
1704
|
-
publicKey
|
|
1924
|
+
publicKey
|
|
1705
1925
|
}).toUint8Array()
|
|
1706
1926
|
});
|
|
1707
|
-
return new Account({ privateKey, address });
|
|
1708
|
-
}
|
|
1709
|
-
static fromPrivateKey(privateKey) {
|
|
1710
|
-
const publicKey = privateKey.publicKey();
|
|
1711
|
-
const authKey = Account.authKey({ publicKey });
|
|
1712
|
-
const address = new AccountAddress({ data: authKey.toUint8Array() });
|
|
1713
|
-
return Account.fromPrivateKeyAndAddress({ privateKey, address });
|
|
1927
|
+
return new Account({ privateKey, address, legacy: args == null ? void 0 : args.legacy });
|
|
1714
1928
|
}
|
|
1715
1929
|
static fromPrivateKeyAndAddress(args) {
|
|
1716
|
-
|
|
1930
|
+
const { privateKey, address, legacy } = args;
|
|
1931
|
+
return new Account({ privateKey, address, legacy });
|
|
1717
1932
|
}
|
|
1718
1933
|
static fromDerivationPath(args) {
|
|
1719
1934
|
const { path, mnemonic } = args;
|
|
1720
1935
|
const { key } = derivePrivateKeyFromMnemonic("ed25519 seed" /* ED25519 */, path, mnemonic);
|
|
1721
1936
|
const privateKey = new Ed25519PrivateKey(key);
|
|
1722
|
-
|
|
1937
|
+
const publicKey = privateKey.publicKey();
|
|
1938
|
+
const authKey = Account.authKey({ publicKey });
|
|
1939
|
+
const address = new AccountAddress({ data: authKey.toUint8Array() });
|
|
1940
|
+
return new Account({ privateKey, address, legacy: true });
|
|
1723
1941
|
}
|
|
1724
1942
|
static authKey(args) {
|
|
1725
1943
|
const { publicKey } = args;
|
|
@@ -2216,7 +2434,7 @@ async function view(args) {
|
|
|
2216
2434
|
body: {
|
|
2217
2435
|
function: payload.function,
|
|
2218
2436
|
type_arguments: (_a = payload.typeArguments) != null ? _a : [],
|
|
2219
|
-
arguments: (_b = payload.
|
|
2437
|
+
arguments: (_b = payload.functionArguments) != null ? _b : []
|
|
2220
2438
|
}
|
|
2221
2439
|
});
|
|
2222
2440
|
return data;
|
|
@@ -2354,7 +2572,7 @@ async function getResource(args) {
|
|
|
2354
2572
|
path: `accounts/${AccountAddress.fromHexInput(accountAddress).toString()}/resource/${resourceType}`,
|
|
2355
2573
|
params: { ledger_version: options == null ? void 0 : options.ledgerVersion }
|
|
2356
2574
|
});
|
|
2357
|
-
return data;
|
|
2575
|
+
return data.data;
|
|
2358
2576
|
}
|
|
2359
2577
|
async function lookupOriginalAccountAddress(args) {
|
|
2360
2578
|
const { aptosConfig, authenticationKey, options } = args;
|
|
@@ -2366,7 +2584,7 @@ async function lookupOriginalAccountAddress(args) {
|
|
|
2366
2584
|
});
|
|
2367
2585
|
const {
|
|
2368
2586
|
address_map: { handle }
|
|
2369
|
-
} = resource
|
|
2587
|
+
} = resource;
|
|
2370
2588
|
try {
|
|
2371
2589
|
const originalAddress = await getTableItem({
|
|
2372
2590
|
aptosConfig,
|
|
@@ -2572,6 +2790,55 @@ async function getAccountOwnedObjects(args) {
|
|
|
2572
2790
|
});
|
|
2573
2791
|
return data.current_objects;
|
|
2574
2792
|
}
|
|
2793
|
+
async function deriveAccountFromPrivateKey(args) {
|
|
2794
|
+
const { aptosConfig, privateKey } = args;
|
|
2795
|
+
const publicKey = new AnyPublicKey(privateKey.publicKey());
|
|
2796
|
+
if (privateKey instanceof Secp256k1PrivateKey) {
|
|
2797
|
+
const authKey = AuthenticationKey.fromPublicKeyAndScheme({ publicKey, scheme: 2 /* SingleKey */ });
|
|
2798
|
+
const address = new AccountAddress({ data: authKey.toUint8Array() });
|
|
2799
|
+
return Account.fromPrivateKeyAndAddress({ privateKey, address });
|
|
2800
|
+
}
|
|
2801
|
+
if (privateKey instanceof Ed25519PrivateKey) {
|
|
2802
|
+
const SingleSenderTransactionAuthenticatorAuthKey = AuthenticationKey.fromPublicKeyAndScheme({
|
|
2803
|
+
publicKey,
|
|
2804
|
+
scheme: 2 /* SingleKey */
|
|
2805
|
+
});
|
|
2806
|
+
const isSingleSenderTransactionAuthenticator = await isAccountExist({
|
|
2807
|
+
authKey: SingleSenderTransactionAuthenticatorAuthKey,
|
|
2808
|
+
aptosConfig
|
|
2809
|
+
});
|
|
2810
|
+
if (isSingleSenderTransactionAuthenticator) {
|
|
2811
|
+
const address = new AccountAddress({ data: SingleSenderTransactionAuthenticatorAuthKey.toUint8Array() });
|
|
2812
|
+
return Account.fromPrivateKeyAndAddress({ privateKey, address });
|
|
2813
|
+
}
|
|
2814
|
+
const legacyAuthKey = AuthenticationKey.fromPublicKeyAndScheme({ publicKey, scheme: 0 /* Ed25519 */ });
|
|
2815
|
+
const isLegacyEd25519 = await isAccountExist({ authKey: legacyAuthKey, aptosConfig });
|
|
2816
|
+
if (isLegacyEd25519) {
|
|
2817
|
+
const address = new AccountAddress({ data: legacyAuthKey.toUint8Array() });
|
|
2818
|
+
return Account.fromPrivateKeyAndAddress({ privateKey, address, legacy: true });
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
throw new Error(`Can't derive account from private key ${privateKey}`);
|
|
2822
|
+
}
|
|
2823
|
+
async function isAccountExist(args) {
|
|
2824
|
+
const { aptosConfig, authKey } = args;
|
|
2825
|
+
const accountAddress = await lookupOriginalAccountAddress({
|
|
2826
|
+
aptosConfig,
|
|
2827
|
+
authenticationKey: authKey.toString()
|
|
2828
|
+
});
|
|
2829
|
+
try {
|
|
2830
|
+
await getInfo({
|
|
2831
|
+
aptosConfig,
|
|
2832
|
+
accountAddress: accountAddress.toString()
|
|
2833
|
+
});
|
|
2834
|
+
return true;
|
|
2835
|
+
} catch (error) {
|
|
2836
|
+
if (error.status === 404) {
|
|
2837
|
+
return false;
|
|
2838
|
+
}
|
|
2839
|
+
throw new Error(`Error while looking for an account info ${accountAddress.toString()}`);
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2575
2842
|
|
|
2576
2843
|
// src/api/account.ts
|
|
2577
2844
|
var Account2 = class {
|
|
@@ -2647,6 +2914,9 @@ var Account2 = class {
|
|
|
2647
2914
|
...args
|
|
2648
2915
|
});
|
|
2649
2916
|
}
|
|
2917
|
+
async deriveAccountFromPrivateKey(args) {
|
|
2918
|
+
return deriveAccountFromPrivateKey({ aptosConfig: this.config, ...args });
|
|
2919
|
+
}
|
|
2650
2920
|
};
|
|
2651
2921
|
|
|
2652
2922
|
// src/api/aptosConfig.ts
|
|
@@ -2690,445 +2960,105 @@ var AptosConfig = class {
|
|
|
2690
2960
|
}
|
|
2691
2961
|
};
|
|
2692
2962
|
|
|
2693
|
-
// src/transactions/
|
|
2694
|
-
var
|
|
2695
|
-
|
|
2963
|
+
// src/transactions/transactionBuilder/transactionBuilder.ts
|
|
2964
|
+
var import_sha33 = require("@noble/hashes/sha3");
|
|
2965
|
+
|
|
2966
|
+
// src/core/crypto/anySignature.ts
|
|
2967
|
+
var AnySignature = class extends Signature {
|
|
2968
|
+
constructor(signature) {
|
|
2696
2969
|
super();
|
|
2697
|
-
this.
|
|
2970
|
+
this.signature = signature;
|
|
2698
2971
|
}
|
|
2699
|
-
|
|
2700
|
-
|
|
2972
|
+
toUint8Array() {
|
|
2973
|
+
return this.signature.toUint8Array();
|
|
2701
2974
|
}
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2975
|
+
toString() {
|
|
2976
|
+
return this.signature.toString();
|
|
2977
|
+
}
|
|
2978
|
+
serialize(serializer) {
|
|
2979
|
+
if (this.signature instanceof Ed25519Signature) {
|
|
2980
|
+
serializer.serializeU32AsUleb128(0 /* Ed25519 */);
|
|
2981
|
+
this.signature.serialize(serializer);
|
|
2982
|
+
} else if (this.signature instanceof Secp256k1Signature) {
|
|
2983
|
+
serializer.serializeU32AsUleb128(1 /* Secp256k1 */);
|
|
2984
|
+
this.signature.serialize(serializer);
|
|
2985
|
+
} else {
|
|
2986
|
+
throw new Error("Unknown signature type");
|
|
2987
|
+
}
|
|
2705
2988
|
}
|
|
2706
|
-
};
|
|
2707
|
-
|
|
2708
|
-
// src/transactions/typeTag/typeTag.ts
|
|
2709
|
-
var TypeTag = class extends Serializable {
|
|
2710
2989
|
static deserialize(deserializer) {
|
|
2711
2990
|
const index = deserializer.deserializeUleb128AsU32();
|
|
2712
2991
|
switch (index) {
|
|
2713
|
-
case 0 /*
|
|
2714
|
-
return
|
|
2715
|
-
case 1 /*
|
|
2716
|
-
return
|
|
2717
|
-
case 2 /* U64 */:
|
|
2718
|
-
return TypeTagU64.load(deserializer);
|
|
2719
|
-
case 3 /* U128 */:
|
|
2720
|
-
return TypeTagU128.load(deserializer);
|
|
2721
|
-
case 4 /* Address */:
|
|
2722
|
-
return TypeTagAddress.load(deserializer);
|
|
2723
|
-
case 5 /* Signer */:
|
|
2724
|
-
return TypeTagSigner.load(deserializer);
|
|
2725
|
-
case 6 /* Vector */:
|
|
2726
|
-
return TypeTagVector.load(deserializer);
|
|
2727
|
-
case 7 /* Struct */:
|
|
2728
|
-
return TypeTagStruct.load(deserializer);
|
|
2729
|
-
case 8 /* U16 */:
|
|
2730
|
-
return TypeTagU16.load(deserializer);
|
|
2731
|
-
case 9 /* U32 */:
|
|
2732
|
-
return TypeTagU32.load(deserializer);
|
|
2733
|
-
case 10 /* U256 */:
|
|
2734
|
-
return TypeTagU256.load(deserializer);
|
|
2992
|
+
case 0 /* Ed25519 */:
|
|
2993
|
+
return new AnySignature(Ed25519Signature.load(deserializer));
|
|
2994
|
+
case 1 /* Secp256k1 */:
|
|
2995
|
+
return new AnySignature(Secp256k1Signature.load(deserializer));
|
|
2735
2996
|
default:
|
|
2736
|
-
throw new Error(`Unknown variant index for
|
|
2997
|
+
throw new Error(`Unknown variant index for AnySignature: ${index}`);
|
|
2737
2998
|
}
|
|
2738
2999
|
}
|
|
2739
3000
|
};
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
}
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
}
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
}
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
};
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
}
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
return new TypeTagAddress();
|
|
2802
|
-
}
|
|
2803
|
-
};
|
|
2804
|
-
var TypeTagSigner = class extends TypeTag {
|
|
2805
|
-
serialize(serializer) {
|
|
2806
|
-
serializer.serializeU32AsUleb128(5 /* Signer */);
|
|
2807
|
-
}
|
|
2808
|
-
static load(_deserializer) {
|
|
2809
|
-
return new TypeTagSigner();
|
|
2810
|
-
}
|
|
2811
|
-
};
|
|
2812
|
-
var TypeTagVector = class extends TypeTag {
|
|
2813
|
-
constructor(value) {
|
|
2814
|
-
super();
|
|
2815
|
-
this.value = value;
|
|
2816
|
-
}
|
|
2817
|
-
serialize(serializer) {
|
|
2818
|
-
serializer.serializeU32AsUleb128(6 /* Vector */);
|
|
2819
|
-
this.value.serialize(serializer);
|
|
2820
|
-
}
|
|
2821
|
-
static load(deserializer) {
|
|
2822
|
-
const value = TypeTag.deserialize(deserializer);
|
|
2823
|
-
return new TypeTagVector(value);
|
|
2824
|
-
}
|
|
2825
|
-
};
|
|
2826
|
-
var TypeTagStruct = class extends TypeTag {
|
|
2827
|
-
constructor(value) {
|
|
2828
|
-
super();
|
|
2829
|
-
this.value = value;
|
|
2830
|
-
}
|
|
2831
|
-
serialize(serializer) {
|
|
2832
|
-
serializer.serializeU32AsUleb128(7 /* Struct */);
|
|
2833
|
-
this.value.serialize(serializer);
|
|
2834
|
-
}
|
|
2835
|
-
static load(deserializer) {
|
|
2836
|
-
const value = StructTag.deserialize(deserializer);
|
|
2837
|
-
return new TypeTagStruct(value);
|
|
2838
|
-
}
|
|
2839
|
-
isStringTypeTag() {
|
|
2840
|
-
return this.value.module_name.identifier === "string" && this.value.name.identifier === "String" && this.value.address.toString() === AccountAddress.ONE.toString();
|
|
2841
|
-
}
|
|
2842
|
-
};
|
|
2843
|
-
var StructTag = class extends Serializable {
|
|
2844
|
-
constructor(address, module_name, name, type_args) {
|
|
2845
|
-
super();
|
|
2846
|
-
this.address = address;
|
|
2847
|
-
this.module_name = module_name;
|
|
2848
|
-
this.name = name;
|
|
2849
|
-
this.type_args = type_args;
|
|
2850
|
-
}
|
|
2851
|
-
static fromString(structTag) {
|
|
2852
|
-
const typeTagStruct = new TypeTagParser(structTag).parseTypeTag();
|
|
2853
|
-
return new StructTag(
|
|
2854
|
-
typeTagStruct.value.address,
|
|
2855
|
-
typeTagStruct.value.module_name,
|
|
2856
|
-
typeTagStruct.value.name,
|
|
2857
|
-
typeTagStruct.value.type_args
|
|
2858
|
-
);
|
|
2859
|
-
}
|
|
2860
|
-
serialize(serializer) {
|
|
2861
|
-
serializer.serialize(this.address);
|
|
2862
|
-
serializer.serialize(this.module_name);
|
|
2863
|
-
serializer.serialize(this.name);
|
|
2864
|
-
serializer.serializeVector(this.type_args);
|
|
2865
|
-
}
|
|
2866
|
-
static deserialize(deserializer) {
|
|
2867
|
-
const address = AccountAddress.deserialize(deserializer);
|
|
2868
|
-
const moduleName = Identifier.deserialize(deserializer);
|
|
2869
|
-
const name = Identifier.deserialize(deserializer);
|
|
2870
|
-
const typeArgs = deserializer.deserializeVector(TypeTag);
|
|
2871
|
-
return new StructTag(address, moduleName, name, typeArgs);
|
|
2872
|
-
}
|
|
2873
|
-
};
|
|
2874
|
-
var stringStructTag = () => new StructTag(AccountAddress.ONE, new Identifier("string"), new Identifier("String"), []);
|
|
2875
|
-
function optionStructTag(typeArg) {
|
|
2876
|
-
return new StructTag(AccountAddress.ONE, new Identifier("option"), new Identifier("Option"), [typeArg]);
|
|
2877
|
-
}
|
|
2878
|
-
function objectStructTag(typeArg) {
|
|
2879
|
-
return new StructTag(AccountAddress.ONE, new Identifier("object"), new Identifier("Object"), [typeArg]);
|
|
2880
|
-
}
|
|
2881
|
-
var TypeTagParser = class {
|
|
2882
|
-
constructor(tagStr, typeTags) {
|
|
2883
|
-
this.typeTags = [];
|
|
2884
|
-
this.tokens = tokenize(tagStr);
|
|
2885
|
-
this.typeTags = typeTags || [];
|
|
2886
|
-
}
|
|
2887
|
-
consume(targetToken) {
|
|
2888
|
-
const token = this.tokens.shift();
|
|
2889
|
-
if (!token || token[1] !== targetToken) {
|
|
2890
|
-
bail("Invalid type tag.");
|
|
2891
|
-
}
|
|
2892
|
-
}
|
|
2893
|
-
consumeWholeGeneric() {
|
|
2894
|
-
this.consume("<");
|
|
2895
|
-
while (this.tokens[0][1] !== ">") {
|
|
2896
|
-
if (this.tokens[0][1] === "<") {
|
|
2897
|
-
this.consumeWholeGeneric();
|
|
2898
|
-
} else {
|
|
2899
|
-
this.tokens.shift();
|
|
2900
|
-
}
|
|
2901
|
-
}
|
|
2902
|
-
this.consume(">");
|
|
2903
|
-
}
|
|
2904
|
-
parseCommaList(endToken, allowTrailingComma) {
|
|
2905
|
-
const res = [];
|
|
2906
|
-
if (this.tokens.length <= 0) {
|
|
2907
|
-
bail("Invalid type tag.");
|
|
2908
|
-
}
|
|
2909
|
-
while (this.tokens[0][1] !== endToken) {
|
|
2910
|
-
res.push(this.parseTypeTag());
|
|
2911
|
-
if (this.tokens.length > 0 && this.tokens[0][1] === endToken) {
|
|
2912
|
-
break;
|
|
2913
|
-
}
|
|
2914
|
-
this.consume(",");
|
|
2915
|
-
if (this.tokens.length > 0 && this.tokens[0][1] === endToken && allowTrailingComma) {
|
|
2916
|
-
break;
|
|
2917
|
-
}
|
|
2918
|
-
if (this.tokens.length <= 0) {
|
|
2919
|
-
bail("Invalid type tag.");
|
|
2920
|
-
}
|
|
2921
|
-
}
|
|
2922
|
-
return res;
|
|
2923
|
-
}
|
|
2924
|
-
parseTypeTag() {
|
|
2925
|
-
if (this.tokens.length === 0) {
|
|
2926
|
-
bail("Invalid type tag.");
|
|
2927
|
-
}
|
|
2928
|
-
const [tokenTy, tokenVal] = this.tokens.shift();
|
|
2929
|
-
if (tokenVal === "u8") {
|
|
2930
|
-
return new TypeTagU8();
|
|
2931
|
-
}
|
|
2932
|
-
if (tokenVal === "u16") {
|
|
2933
|
-
return new TypeTagU16();
|
|
2934
|
-
}
|
|
2935
|
-
if (tokenVal === "u32") {
|
|
2936
|
-
return new TypeTagU32();
|
|
2937
|
-
}
|
|
2938
|
-
if (tokenVal === "u64") {
|
|
2939
|
-
return new TypeTagU64();
|
|
2940
|
-
}
|
|
2941
|
-
if (tokenVal === "u128") {
|
|
2942
|
-
return new TypeTagU128();
|
|
2943
|
-
}
|
|
2944
|
-
if (tokenVal === "u256") {
|
|
2945
|
-
return new TypeTagU256();
|
|
2946
|
-
}
|
|
2947
|
-
if (tokenVal === "bool") {
|
|
2948
|
-
return new TypeTagBool();
|
|
2949
|
-
}
|
|
2950
|
-
if (tokenVal === "address") {
|
|
2951
|
-
return new TypeTagAddress();
|
|
2952
|
-
}
|
|
2953
|
-
if (tokenVal === "vector") {
|
|
2954
|
-
this.consume("<");
|
|
2955
|
-
const res = this.parseTypeTag();
|
|
2956
|
-
this.consume(">");
|
|
2957
|
-
return new TypeTagVector(res);
|
|
2958
|
-
}
|
|
2959
|
-
if (tokenVal === "string") {
|
|
2960
|
-
return new TypeTagStruct(stringStructTag());
|
|
2961
|
-
}
|
|
2962
|
-
if (tokenTy === "IDENT" && (tokenVal.startsWith("0x") || tokenVal.startsWith("0X"))) {
|
|
2963
|
-
const address = AccountAddress.fromHexInput(tokenVal);
|
|
2964
|
-
this.consume("::");
|
|
2965
|
-
const [moduleTokenTy, module2] = this.tokens.shift();
|
|
2966
|
-
if (moduleTokenTy !== "IDENT") {
|
|
2967
|
-
bail("Invalid type tag.");
|
|
2968
|
-
}
|
|
2969
|
-
this.consume("::");
|
|
2970
|
-
const [nameTokenTy, name] = this.tokens.shift();
|
|
2971
|
-
if (nameTokenTy !== "IDENT") {
|
|
2972
|
-
bail("Invalid type tag.");
|
|
2973
|
-
}
|
|
2974
|
-
if (AccountAddress.ONE.toString() === address.toString() && module2 === "object" && name === "Object") {
|
|
2975
|
-
this.consumeWholeGeneric();
|
|
2976
|
-
return new TypeTagAddress();
|
|
2977
|
-
}
|
|
2978
|
-
let tyTags = [];
|
|
2979
|
-
if (this.tokens.length > 0 && this.tokens[0][1] === "<") {
|
|
2980
|
-
this.consume("<");
|
|
2981
|
-
tyTags = this.parseCommaList(">", true);
|
|
2982
|
-
this.consume(">");
|
|
2983
|
-
}
|
|
2984
|
-
const structTag = new StructTag(address, new Identifier(module2), new Identifier(name), tyTags);
|
|
2985
|
-
return new TypeTagStruct(structTag);
|
|
2986
|
-
}
|
|
2987
|
-
if (tokenTy === "GENERIC") {
|
|
2988
|
-
if (this.typeTags.length === 0) {
|
|
2989
|
-
bail("Can't convert generic type since no typeTags were specified.");
|
|
2990
|
-
}
|
|
2991
|
-
const idx = parseInt(tokenVal.substring(1), 10);
|
|
2992
|
-
return new TypeTagParser(this.typeTags[idx]).parseTypeTag();
|
|
2993
|
-
}
|
|
2994
|
-
throw new Error("Invalid type tag.");
|
|
2995
|
-
}
|
|
2996
|
-
};
|
|
2997
|
-
var TypeTagParserError = class extends Error {
|
|
2998
|
-
constructor(message) {
|
|
2999
|
-
super(message);
|
|
3000
|
-
this.name = "TypeTagParserError";
|
|
3001
|
-
}
|
|
3002
|
-
};
|
|
3003
|
-
function tokenize(tagStr) {
|
|
3004
|
-
let pos = 0;
|
|
3005
|
-
const tokens = [];
|
|
3006
|
-
while (pos < tagStr.length) {
|
|
3007
|
-
const [token, size] = nextToken(tagStr, pos);
|
|
3008
|
-
if (token[0] !== "SPACE") {
|
|
3009
|
-
tokens.push(token);
|
|
3010
|
-
}
|
|
3011
|
-
pos += size;
|
|
3012
|
-
}
|
|
3013
|
-
return tokens;
|
|
3014
|
-
}
|
|
3015
|
-
function bail(message) {
|
|
3016
|
-
throw new TypeTagParserError(message);
|
|
3017
|
-
}
|
|
3018
|
-
function isWhiteSpace(c) {
|
|
3019
|
-
return !!c.match(/\s/);
|
|
3020
|
-
}
|
|
3021
|
-
function isValidAlphabetic(c) {
|
|
3022
|
-
return !!c.match(/[_A-Za-z0-9]/g);
|
|
3023
|
-
}
|
|
3024
|
-
function isGeneric(c) {
|
|
3025
|
-
return !!c.match(/T\d+/g);
|
|
3026
|
-
}
|
|
3027
|
-
function nextToken(tagStr, pos) {
|
|
3028
|
-
const c = tagStr[pos];
|
|
3029
|
-
if (c === ":") {
|
|
3030
|
-
if (tagStr.slice(pos, pos + 2) === "::") {
|
|
3031
|
-
return [["COLON", "::"], 2];
|
|
3032
|
-
}
|
|
3033
|
-
bail("Unrecognized token.");
|
|
3034
|
-
} else if (c === "<") {
|
|
3035
|
-
return [["LT", "<"], 1];
|
|
3036
|
-
} else if (c === ">") {
|
|
3037
|
-
return [["GT", ">"], 1];
|
|
3038
|
-
} else if (c === ",") {
|
|
3039
|
-
return [["COMMA", ","], 1];
|
|
3040
|
-
} else if (isWhiteSpace(c)) {
|
|
3041
|
-
let res = "";
|
|
3042
|
-
for (let i = pos; i < tagStr.length; i += 1) {
|
|
3043
|
-
const char = tagStr[i];
|
|
3044
|
-
if (isWhiteSpace(char)) {
|
|
3045
|
-
res = `${res}${char}`;
|
|
3046
|
-
} else {
|
|
3047
|
-
break;
|
|
3048
|
-
}
|
|
3049
|
-
}
|
|
3050
|
-
return [["SPACE", res], res.length];
|
|
3051
|
-
} else if (isValidAlphabetic(c)) {
|
|
3052
|
-
let res = "";
|
|
3053
|
-
for (let i = pos; i < tagStr.length; i += 1) {
|
|
3054
|
-
const char = tagStr[i];
|
|
3055
|
-
if (isValidAlphabetic(char)) {
|
|
3056
|
-
res = `${res}${char}`;
|
|
3057
|
-
} else {
|
|
3058
|
-
break;
|
|
3059
|
-
}
|
|
3060
|
-
}
|
|
3061
|
-
if (isGeneric(res)) {
|
|
3062
|
-
return [["GENERIC", res], res.length];
|
|
3063
|
-
}
|
|
3064
|
-
return [["IDENT", res], res.length];
|
|
3065
|
-
}
|
|
3066
|
-
throw new Error("Unrecognized token.");
|
|
3067
|
-
}
|
|
3068
|
-
|
|
3069
|
-
// src/transactions/transaction_builder/transaction_builder.ts
|
|
3070
|
-
var import_sha33 = require("@noble/hashes/sha3");
|
|
3071
|
-
|
|
3072
|
-
// src/utils/helpers.ts
|
|
3073
|
-
async function sleep(timeMs) {
|
|
3074
|
-
return new Promise((resolve) => {
|
|
3075
|
-
setTimeout(resolve, timeMs);
|
|
3076
|
-
});
|
|
3077
|
-
}
|
|
3078
|
-
|
|
3079
|
-
// src/internal/transaction.ts
|
|
3080
|
-
async function getTransactions2(args) {
|
|
3081
|
-
const { aptosConfig, options } = args;
|
|
3082
|
-
return paginateWithCursor({
|
|
3083
|
-
aptosConfig,
|
|
3084
|
-
originMethod: "getTransactions",
|
|
3085
|
-
path: "transactions",
|
|
3086
|
-
params: { start: options == null ? void 0 : options.offset, limit: options == null ? void 0 : options.limit }
|
|
3087
|
-
});
|
|
3088
|
-
}
|
|
3089
|
-
async function getGasPriceEstimation(args) {
|
|
3090
|
-
const { aptosConfig } = args;
|
|
3091
|
-
return memoizeAsync(
|
|
3092
|
-
async () => {
|
|
3093
|
-
const { data } = await getAptosFullNode({
|
|
3094
|
-
aptosConfig,
|
|
3095
|
-
originMethod: "getGasPriceEstimation",
|
|
3096
|
-
path: "estimate_gas_price"
|
|
3097
|
-
});
|
|
3098
|
-
return data;
|
|
3099
|
-
},
|
|
3100
|
-
`gas-price-${aptosConfig.network}`,
|
|
3101
|
-
1e3 * 60 * 5
|
|
3102
|
-
)();
|
|
3103
|
-
}
|
|
3104
|
-
async function getTransactionByVersion(args) {
|
|
3105
|
-
const { aptosConfig, ledgerVersion } = args;
|
|
3106
|
-
const { data } = await getAptosFullNode({
|
|
3107
|
-
aptosConfig,
|
|
3108
|
-
originMethod: "getTransactionByVersion",
|
|
3109
|
-
path: `transactions/by_version/${ledgerVersion}`
|
|
3110
|
-
});
|
|
3111
|
-
return data;
|
|
3112
|
-
}
|
|
3113
|
-
async function getTransactionByHash(args) {
|
|
3114
|
-
const { aptosConfig, transactionHash } = args;
|
|
3115
|
-
const { data } = await getAptosFullNode({
|
|
3116
|
-
aptosConfig,
|
|
3117
|
-
path: `transactions/by_hash/${transactionHash}`,
|
|
3118
|
-
originMethod: "getTransactionByHash"
|
|
3119
|
-
});
|
|
3120
|
-
return data;
|
|
3121
|
-
}
|
|
3122
|
-
async function isTransactionPending(args) {
|
|
3123
|
-
const { aptosConfig, transactionHash } = args;
|
|
3124
|
-
try {
|
|
3125
|
-
const transaction = await getTransactionByHash({ aptosConfig, transactionHash });
|
|
3126
|
-
return transaction.type === "pending_transaction" /* Pending */;
|
|
3127
|
-
} catch (e) {
|
|
3128
|
-
if ((e == null ? void 0 : e.status) === 404) {
|
|
3129
|
-
return true;
|
|
3130
|
-
}
|
|
3131
|
-
throw e;
|
|
3001
|
+
|
|
3002
|
+
// src/utils/helpers.ts
|
|
3003
|
+
async function sleep(timeMs) {
|
|
3004
|
+
return new Promise((resolve) => {
|
|
3005
|
+
setTimeout(resolve, timeMs);
|
|
3006
|
+
});
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
// src/internal/transaction.ts
|
|
3010
|
+
async function getTransactions2(args) {
|
|
3011
|
+
const { aptosConfig, options } = args;
|
|
3012
|
+
return paginateWithCursor({
|
|
3013
|
+
aptosConfig,
|
|
3014
|
+
originMethod: "getTransactions",
|
|
3015
|
+
path: "transactions",
|
|
3016
|
+
params: { start: options == null ? void 0 : options.offset, limit: options == null ? void 0 : options.limit }
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
3019
|
+
async function getGasPriceEstimation(args) {
|
|
3020
|
+
const { aptosConfig } = args;
|
|
3021
|
+
return memoizeAsync(
|
|
3022
|
+
async () => {
|
|
3023
|
+
const { data } = await getAptosFullNode({
|
|
3024
|
+
aptosConfig,
|
|
3025
|
+
originMethod: "getGasPriceEstimation",
|
|
3026
|
+
path: "estimate_gas_price"
|
|
3027
|
+
});
|
|
3028
|
+
return data;
|
|
3029
|
+
},
|
|
3030
|
+
`gas-price-${aptosConfig.network}`,
|
|
3031
|
+
1e3 * 60 * 5
|
|
3032
|
+
)();
|
|
3033
|
+
}
|
|
3034
|
+
async function getTransactionByVersion(args) {
|
|
3035
|
+
const { aptosConfig, ledgerVersion } = args;
|
|
3036
|
+
const { data } = await getAptosFullNode({
|
|
3037
|
+
aptosConfig,
|
|
3038
|
+
originMethod: "getTransactionByVersion",
|
|
3039
|
+
path: `transactions/by_version/${ledgerVersion}`
|
|
3040
|
+
});
|
|
3041
|
+
return data;
|
|
3042
|
+
}
|
|
3043
|
+
async function getTransactionByHash(args) {
|
|
3044
|
+
const { aptosConfig, transactionHash } = args;
|
|
3045
|
+
const { data } = await getAptosFullNode({
|
|
3046
|
+
aptosConfig,
|
|
3047
|
+
path: `transactions/by_hash/${transactionHash}`,
|
|
3048
|
+
originMethod: "getTransactionByHash"
|
|
3049
|
+
});
|
|
3050
|
+
return data;
|
|
3051
|
+
}
|
|
3052
|
+
async function isTransactionPending(args) {
|
|
3053
|
+
const { aptosConfig, transactionHash } = args;
|
|
3054
|
+
try {
|
|
3055
|
+
const transaction = await getTransactionByHash({ aptosConfig, transactionHash });
|
|
3056
|
+
return transaction.type === "pending_transaction" /* Pending */;
|
|
3057
|
+
} catch (e) {
|
|
3058
|
+
if ((e == null ? void 0 : e.status) === 404) {
|
|
3059
|
+
return true;
|
|
3060
|
+
}
|
|
3061
|
+
throw e;
|
|
3132
3062
|
}
|
|
3133
3063
|
}
|
|
3134
3064
|
async function waitForTransaction(args) {
|
|
@@ -3243,8 +3173,10 @@ var AccountAuthenticator = class extends Serializable {
|
|
|
3243
3173
|
return AccountAuthenticatorEd25519.load(deserializer);
|
|
3244
3174
|
case 1 /* MultiEd25519 */:
|
|
3245
3175
|
return AccountAuthenticatorMultiEd25519.load(deserializer);
|
|
3246
|
-
case 2 /*
|
|
3247
|
-
return
|
|
3176
|
+
case 2 /* SingleKey */:
|
|
3177
|
+
return AccountAuthenticatorSingleKey.load(deserializer);
|
|
3178
|
+
case 3 /* MultiKey */:
|
|
3179
|
+
return AccountAuthenticatorMultiKey.load(deserializer);
|
|
3248
3180
|
default:
|
|
3249
3181
|
throw new Error(`Unknown variant index for AccountAuthenticator: ${index}`);
|
|
3250
3182
|
}
|
|
@@ -3284,26 +3216,46 @@ var AccountAuthenticatorMultiEd25519 = class extends AccountAuthenticator {
|
|
|
3284
3216
|
return new AccountAuthenticatorMultiEd25519(public_key, signature);
|
|
3285
3217
|
}
|
|
3286
3218
|
};
|
|
3287
|
-
var
|
|
3219
|
+
var AccountAuthenticatorSingleKey = class extends AccountAuthenticator {
|
|
3288
3220
|
constructor(public_key, signature) {
|
|
3289
3221
|
super();
|
|
3290
3222
|
this.public_key = public_key;
|
|
3291
3223
|
this.signature = signature;
|
|
3292
3224
|
}
|
|
3293
3225
|
serialize(serializer) {
|
|
3294
|
-
serializer.serializeU32AsUleb128(2 /*
|
|
3226
|
+
serializer.serializeU32AsUleb128(2 /* SingleKey */);
|
|
3295
3227
|
this.public_key.serialize(serializer);
|
|
3296
3228
|
this.signature.serialize(serializer);
|
|
3297
3229
|
}
|
|
3298
3230
|
static load(deserializer) {
|
|
3299
|
-
const public_key =
|
|
3300
|
-
const signature =
|
|
3301
|
-
return new
|
|
3231
|
+
const public_key = AnyPublicKey.deserialize(deserializer);
|
|
3232
|
+
const signature = AnySignature.deserialize(deserializer);
|
|
3233
|
+
return new AccountAuthenticatorSingleKey(public_key, signature);
|
|
3234
|
+
}
|
|
3235
|
+
};
|
|
3236
|
+
var AccountAuthenticatorMultiKey = class extends AccountAuthenticator {
|
|
3237
|
+
constructor(public_keys, signatures, signatures_bitmap) {
|
|
3238
|
+
super();
|
|
3239
|
+
this.public_keys = public_keys;
|
|
3240
|
+
this.signatures = signatures;
|
|
3241
|
+
this.signatures_bitmap = signatures_bitmap;
|
|
3242
|
+
}
|
|
3243
|
+
serialize(serializer) {
|
|
3244
|
+
serializer.serializeU32AsUleb128(3 /* MultiKey */);
|
|
3245
|
+
this.public_keys.serialize(serializer);
|
|
3246
|
+
serializer.serializeVector(this.signatures);
|
|
3247
|
+
serializer.serializeBytes(this.signatures_bitmap);
|
|
3248
|
+
}
|
|
3249
|
+
static load(deserializer) {
|
|
3250
|
+
const public_keys = MultiKey.deserialize(deserializer);
|
|
3251
|
+
const signatures = deserializer.deserializeVector(AnySignature);
|
|
3252
|
+
const signatures_bitmap = deserializer.deserializeBytes();
|
|
3253
|
+
return new AccountAuthenticatorMultiKey(public_keys, signatures, signatures_bitmap);
|
|
3302
3254
|
}
|
|
3303
3255
|
};
|
|
3304
3256
|
|
|
3305
3257
|
// src/transactions/authenticator/transaction.ts
|
|
3306
|
-
var TransactionAuthenticator = class {
|
|
3258
|
+
var TransactionAuthenticator = class extends Serializable {
|
|
3307
3259
|
static deserialize(deserializer) {
|
|
3308
3260
|
const index = deserializer.deserializeUleb128AsU32();
|
|
3309
3261
|
switch (index) {
|
|
@@ -3315,8 +3267,8 @@ var TransactionAuthenticator = class {
|
|
|
3315
3267
|
return TransactionAuthenticatorMultiAgent.load(deserializer);
|
|
3316
3268
|
case 3 /* FeePayer */:
|
|
3317
3269
|
return TransactionAuthenticatorFeePayer.load(deserializer);
|
|
3318
|
-
case 4 /*
|
|
3319
|
-
return
|
|
3270
|
+
case 4 /* SingleSender */:
|
|
3271
|
+
return TransactionAuthenticatorSingleSender.load(deserializer);
|
|
3320
3272
|
default:
|
|
3321
3273
|
throw new Error(`Unknown variant index for TransactionAuthenticator: ${index}`);
|
|
3322
3274
|
}
|
|
@@ -3402,63 +3354,362 @@ var TransactionAuthenticatorFeePayer = class extends TransactionAuthenticator {
|
|
|
3402
3354
|
return new TransactionAuthenticatorFeePayer(sender, secondary_signer_addresses, secondary_signers, fee_payer);
|
|
3403
3355
|
}
|
|
3404
3356
|
};
|
|
3405
|
-
var
|
|
3406
|
-
constructor(
|
|
3357
|
+
var TransactionAuthenticatorSingleSender = class extends TransactionAuthenticator {
|
|
3358
|
+
constructor(sender) {
|
|
3359
|
+
super();
|
|
3360
|
+
this.sender = sender;
|
|
3361
|
+
}
|
|
3362
|
+
serialize(serializer) {
|
|
3363
|
+
serializer.serializeU32AsUleb128(4 /* SingleSender */);
|
|
3364
|
+
this.sender.serialize(serializer);
|
|
3365
|
+
}
|
|
3366
|
+
static load(deserializer) {
|
|
3367
|
+
const sender = AccountAuthenticator.deserialize(deserializer);
|
|
3368
|
+
return new TransactionAuthenticatorSingleSender(sender);
|
|
3369
|
+
}
|
|
3370
|
+
};
|
|
3371
|
+
|
|
3372
|
+
// src/transactions/instances/chainId.ts
|
|
3373
|
+
var ChainId = class extends Serializable {
|
|
3374
|
+
constructor(chainId) {
|
|
3375
|
+
super();
|
|
3376
|
+
this.chainId = chainId;
|
|
3377
|
+
}
|
|
3378
|
+
serialize(serializer) {
|
|
3379
|
+
serializer.serializeU8(this.chainId);
|
|
3380
|
+
}
|
|
3381
|
+
static deserialize(deserializer) {
|
|
3382
|
+
const chainId = deserializer.deserializeU8();
|
|
3383
|
+
return new ChainId(chainId);
|
|
3384
|
+
}
|
|
3385
|
+
};
|
|
3386
|
+
|
|
3387
|
+
// src/transactions/instances/identifier.ts
|
|
3388
|
+
var Identifier = class extends Serializable {
|
|
3389
|
+
constructor(identifier) {
|
|
3390
|
+
super();
|
|
3391
|
+
this.identifier = identifier;
|
|
3392
|
+
}
|
|
3393
|
+
serialize(serializer) {
|
|
3394
|
+
serializer.serializeStr(this.identifier);
|
|
3395
|
+
}
|
|
3396
|
+
static deserialize(deserializer) {
|
|
3397
|
+
const identifier = deserializer.deserializeStr();
|
|
3398
|
+
return new Identifier(identifier);
|
|
3399
|
+
}
|
|
3400
|
+
};
|
|
3401
|
+
|
|
3402
|
+
// src/transactions/instances/moduleId.ts
|
|
3403
|
+
var ModuleId = class extends Serializable {
|
|
3404
|
+
constructor(address, name) {
|
|
3405
|
+
super();
|
|
3406
|
+
this.address = address;
|
|
3407
|
+
this.name = name;
|
|
3408
|
+
}
|
|
3409
|
+
static fromStr(moduleId) {
|
|
3410
|
+
const parts = moduleId.split("::");
|
|
3411
|
+
if (parts.length !== 2) {
|
|
3412
|
+
throw new Error("Invalid module id.");
|
|
3413
|
+
}
|
|
3414
|
+
return new ModuleId(AccountAddress.fromString(parts[0]), new Identifier(parts[1]));
|
|
3415
|
+
}
|
|
3416
|
+
serialize(serializer) {
|
|
3417
|
+
this.address.serialize(serializer);
|
|
3418
|
+
this.name.serialize(serializer);
|
|
3419
|
+
}
|
|
3420
|
+
static deserialize(deserializer) {
|
|
3421
|
+
const address = AccountAddress.deserialize(deserializer);
|
|
3422
|
+
const name = Identifier.deserialize(deserializer);
|
|
3423
|
+
return new ModuleId(address, name);
|
|
3424
|
+
}
|
|
3425
|
+
};
|
|
3426
|
+
|
|
3427
|
+
// src/transactions/typeTag/index.ts
|
|
3428
|
+
var TypeTag = class extends Serializable {
|
|
3429
|
+
static deserialize(deserializer) {
|
|
3430
|
+
const index = deserializer.deserializeUleb128AsU32();
|
|
3431
|
+
switch (index) {
|
|
3432
|
+
case 0 /* Bool */:
|
|
3433
|
+
return TypeTagBool.load(deserializer);
|
|
3434
|
+
case 1 /* U8 */:
|
|
3435
|
+
return TypeTagU8.load(deserializer);
|
|
3436
|
+
case 2 /* U64 */:
|
|
3437
|
+
return TypeTagU64.load(deserializer);
|
|
3438
|
+
case 3 /* U128 */:
|
|
3439
|
+
return TypeTagU128.load(deserializer);
|
|
3440
|
+
case 4 /* Address */:
|
|
3441
|
+
return TypeTagAddress.load(deserializer);
|
|
3442
|
+
case 5 /* Signer */:
|
|
3443
|
+
return TypeTagSigner.load(deserializer);
|
|
3444
|
+
case 6 /* Vector */:
|
|
3445
|
+
return TypeTagVector.load(deserializer);
|
|
3446
|
+
case 7 /* Struct */:
|
|
3447
|
+
return TypeTagStruct.load(deserializer);
|
|
3448
|
+
case 8 /* U16 */:
|
|
3449
|
+
return TypeTagU16.load(deserializer);
|
|
3450
|
+
case 9 /* U32 */:
|
|
3451
|
+
return TypeTagU32.load(deserializer);
|
|
3452
|
+
case 10 /* U256 */:
|
|
3453
|
+
return TypeTagU256.load(deserializer);
|
|
3454
|
+
case 255 /* Generic */:
|
|
3455
|
+
return TypeTagGeneric.load(deserializer);
|
|
3456
|
+
default:
|
|
3457
|
+
throw new Error(`Unknown variant index for TypeTag: ${index}`);
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
isBool() {
|
|
3461
|
+
return this instanceof TypeTagBool;
|
|
3462
|
+
}
|
|
3463
|
+
isAddress() {
|
|
3464
|
+
return this instanceof TypeTagAddress;
|
|
3465
|
+
}
|
|
3466
|
+
isGeneric() {
|
|
3467
|
+
return this instanceof TypeTagGeneric;
|
|
3468
|
+
}
|
|
3469
|
+
isSigner() {
|
|
3470
|
+
return this instanceof TypeTagSigner;
|
|
3471
|
+
}
|
|
3472
|
+
isVector() {
|
|
3473
|
+
return this instanceof TypeTagVector;
|
|
3474
|
+
}
|
|
3475
|
+
isStruct() {
|
|
3476
|
+
return this instanceof TypeTagStruct;
|
|
3477
|
+
}
|
|
3478
|
+
isU8() {
|
|
3479
|
+
return this instanceof TypeTagU8;
|
|
3480
|
+
}
|
|
3481
|
+
isU16() {
|
|
3482
|
+
return this instanceof TypeTagU16;
|
|
3483
|
+
}
|
|
3484
|
+
isU32() {
|
|
3485
|
+
return this instanceof TypeTagU32;
|
|
3486
|
+
}
|
|
3487
|
+
isU64() {
|
|
3488
|
+
return this instanceof TypeTagU64;
|
|
3489
|
+
}
|
|
3490
|
+
isU128() {
|
|
3491
|
+
return this instanceof TypeTagU128;
|
|
3492
|
+
}
|
|
3493
|
+
isU256() {
|
|
3494
|
+
return this instanceof TypeTagU256;
|
|
3495
|
+
}
|
|
3496
|
+
};
|
|
3497
|
+
var TypeTagBool = class extends TypeTag {
|
|
3498
|
+
toString() {
|
|
3499
|
+
return "bool";
|
|
3500
|
+
}
|
|
3501
|
+
serialize(serializer) {
|
|
3502
|
+
serializer.serializeU32AsUleb128(0 /* Bool */);
|
|
3503
|
+
}
|
|
3504
|
+
static load(_deserializer) {
|
|
3505
|
+
return new TypeTagBool();
|
|
3506
|
+
}
|
|
3507
|
+
};
|
|
3508
|
+
var TypeTagU8 = class extends TypeTag {
|
|
3509
|
+
toString() {
|
|
3510
|
+
return "u8";
|
|
3511
|
+
}
|
|
3512
|
+
serialize(serializer) {
|
|
3513
|
+
serializer.serializeU32AsUleb128(1 /* U8 */);
|
|
3514
|
+
}
|
|
3515
|
+
static load(_deserializer) {
|
|
3516
|
+
return new TypeTagU8();
|
|
3517
|
+
}
|
|
3518
|
+
};
|
|
3519
|
+
var TypeTagU16 = class extends TypeTag {
|
|
3520
|
+
toString() {
|
|
3521
|
+
return "u16";
|
|
3522
|
+
}
|
|
3523
|
+
serialize(serializer) {
|
|
3524
|
+
serializer.serializeU32AsUleb128(8 /* U16 */);
|
|
3525
|
+
}
|
|
3526
|
+
static load(_deserializer) {
|
|
3527
|
+
return new TypeTagU16();
|
|
3528
|
+
}
|
|
3529
|
+
};
|
|
3530
|
+
var TypeTagU32 = class extends TypeTag {
|
|
3531
|
+
toString() {
|
|
3532
|
+
return "u32";
|
|
3533
|
+
}
|
|
3534
|
+
serialize(serializer) {
|
|
3535
|
+
serializer.serializeU32AsUleb128(9 /* U32 */);
|
|
3536
|
+
}
|
|
3537
|
+
static load(_deserializer) {
|
|
3538
|
+
return new TypeTagU32();
|
|
3539
|
+
}
|
|
3540
|
+
};
|
|
3541
|
+
var TypeTagU64 = class extends TypeTag {
|
|
3542
|
+
toString() {
|
|
3543
|
+
return "u64";
|
|
3544
|
+
}
|
|
3545
|
+
serialize(serializer) {
|
|
3546
|
+
serializer.serializeU32AsUleb128(2 /* U64 */);
|
|
3547
|
+
}
|
|
3548
|
+
static load(_deserializer) {
|
|
3549
|
+
return new TypeTagU64();
|
|
3550
|
+
}
|
|
3551
|
+
};
|
|
3552
|
+
var TypeTagU128 = class extends TypeTag {
|
|
3553
|
+
toString() {
|
|
3554
|
+
return "u128";
|
|
3555
|
+
}
|
|
3556
|
+
serialize(serializer) {
|
|
3557
|
+
serializer.serializeU32AsUleb128(3 /* U128 */);
|
|
3558
|
+
}
|
|
3559
|
+
static load(_deserializer) {
|
|
3560
|
+
return new TypeTagU128();
|
|
3561
|
+
}
|
|
3562
|
+
};
|
|
3563
|
+
var TypeTagU256 = class extends TypeTag {
|
|
3564
|
+
toString() {
|
|
3565
|
+
return "u256";
|
|
3566
|
+
}
|
|
3567
|
+
serialize(serializer) {
|
|
3568
|
+
serializer.serializeU32AsUleb128(10 /* U256 */);
|
|
3569
|
+
}
|
|
3570
|
+
static load(_deserializer) {
|
|
3571
|
+
return new TypeTagU256();
|
|
3572
|
+
}
|
|
3573
|
+
};
|
|
3574
|
+
var TypeTagAddress = class extends TypeTag {
|
|
3575
|
+
toString() {
|
|
3576
|
+
return "address";
|
|
3577
|
+
}
|
|
3578
|
+
serialize(serializer) {
|
|
3579
|
+
serializer.serializeU32AsUleb128(4 /* Address */);
|
|
3580
|
+
}
|
|
3581
|
+
static load(_deserializer) {
|
|
3582
|
+
return new TypeTagAddress();
|
|
3583
|
+
}
|
|
3584
|
+
};
|
|
3585
|
+
var TypeTagSigner = class extends TypeTag {
|
|
3586
|
+
toString() {
|
|
3587
|
+
return "signer";
|
|
3588
|
+
}
|
|
3589
|
+
serialize(serializer) {
|
|
3590
|
+
serializer.serializeU32AsUleb128(5 /* Signer */);
|
|
3591
|
+
}
|
|
3592
|
+
static load(_deserializer) {
|
|
3593
|
+
return new TypeTagSigner();
|
|
3594
|
+
}
|
|
3595
|
+
};
|
|
3596
|
+
var TypeTagReference = class extends TypeTag {
|
|
3597
|
+
constructor(value) {
|
|
3598
|
+
super();
|
|
3599
|
+
this.value = value;
|
|
3600
|
+
}
|
|
3601
|
+
toString() {
|
|
3602
|
+
return `&${this.value.toString()}`;
|
|
3603
|
+
}
|
|
3604
|
+
serialize(serializer) {
|
|
3605
|
+
serializer.serializeU32AsUleb128(254 /* Reference */);
|
|
3606
|
+
}
|
|
3607
|
+
static load(deserializer) {
|
|
3608
|
+
const value = TypeTag.deserialize(deserializer);
|
|
3609
|
+
return new TypeTagReference(value);
|
|
3610
|
+
}
|
|
3611
|
+
};
|
|
3612
|
+
var TypeTagGeneric = class extends TypeTag {
|
|
3613
|
+
constructor(value) {
|
|
3614
|
+
super();
|
|
3615
|
+
this.value = value;
|
|
3616
|
+
}
|
|
3617
|
+
toString() {
|
|
3618
|
+
return `T${this.value}`;
|
|
3619
|
+
}
|
|
3620
|
+
serialize(serializer) {
|
|
3621
|
+
serializer.serializeU32AsUleb128(255 /* Generic */);
|
|
3622
|
+
serializer.serializeU32(this.value);
|
|
3623
|
+
}
|
|
3624
|
+
static load(deserializer) {
|
|
3625
|
+
const value = deserializer.deserializeU32();
|
|
3626
|
+
return new TypeTagGeneric(value);
|
|
3627
|
+
}
|
|
3628
|
+
};
|
|
3629
|
+
var TypeTagVector = class extends TypeTag {
|
|
3630
|
+
constructor(value) {
|
|
3631
|
+
super();
|
|
3632
|
+
this.value = value;
|
|
3633
|
+
}
|
|
3634
|
+
toString() {
|
|
3635
|
+
return `vector<${this.value.toString()}>`;
|
|
3636
|
+
}
|
|
3637
|
+
serialize(serializer) {
|
|
3638
|
+
serializer.serializeU32AsUleb128(6 /* Vector */);
|
|
3639
|
+
this.value.serialize(serializer);
|
|
3640
|
+
}
|
|
3641
|
+
static load(deserializer) {
|
|
3642
|
+
const value = TypeTag.deserialize(deserializer);
|
|
3643
|
+
return new TypeTagVector(value);
|
|
3644
|
+
}
|
|
3645
|
+
};
|
|
3646
|
+
var TypeTagStruct = class extends TypeTag {
|
|
3647
|
+
constructor(value) {
|
|
3407
3648
|
super();
|
|
3408
|
-
this.
|
|
3409
|
-
|
|
3649
|
+
this.value = value;
|
|
3650
|
+
}
|
|
3651
|
+
toString() {
|
|
3652
|
+
let typePredicate = "";
|
|
3653
|
+
if (this.value.type_args.length > 0) {
|
|
3654
|
+
typePredicate = `<${this.value.type_args.map((typeArg) => typeArg.toString()).join(", ")}>`;
|
|
3655
|
+
}
|
|
3656
|
+
return `${this.value.address.toString()}::${this.value.module_name.identifier}::${this.value.name.identifier}${typePredicate}`;
|
|
3410
3657
|
}
|
|
3411
3658
|
serialize(serializer) {
|
|
3412
|
-
serializer.serializeU32AsUleb128(
|
|
3413
|
-
this.
|
|
3414
|
-
this.signature.serialize(serializer);
|
|
3659
|
+
serializer.serializeU32AsUleb128(7 /* Struct */);
|
|
3660
|
+
this.value.serialize(serializer);
|
|
3415
3661
|
}
|
|
3416
3662
|
static load(deserializer) {
|
|
3417
|
-
const
|
|
3418
|
-
|
|
3419
|
-
return new TransactionAuthenticatorSecp256k1(public_key, signature);
|
|
3663
|
+
const value = StructTag.deserialize(deserializer);
|
|
3664
|
+
return new TypeTagStruct(value);
|
|
3420
3665
|
}
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
// src/transactions/instances/chainId.ts
|
|
3424
|
-
var ChainId = class extends Serializable {
|
|
3425
|
-
constructor(chainId) {
|
|
3426
|
-
super();
|
|
3427
|
-
this.chainId = chainId;
|
|
3666
|
+
isTypeTag(address, moduleName, structName) {
|
|
3667
|
+
return this.value.module_name.identifier === moduleName && this.value.name.identifier === structName && this.value.address.equals(address);
|
|
3428
3668
|
}
|
|
3429
|
-
|
|
3430
|
-
|
|
3669
|
+
isString() {
|
|
3670
|
+
return this.isTypeTag(AccountAddress.ONE, "string", "String");
|
|
3431
3671
|
}
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3672
|
+
isOption() {
|
|
3673
|
+
return this.isTypeTag(AccountAddress.ONE, "option", "Option");
|
|
3674
|
+
}
|
|
3675
|
+
isObject() {
|
|
3676
|
+
return this.isTypeTag(AccountAddress.ONE, "object", "Object");
|
|
3435
3677
|
}
|
|
3436
3678
|
};
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
var ModuleId = class extends Serializable {
|
|
3440
|
-
constructor(address, name) {
|
|
3679
|
+
var StructTag = class extends Serializable {
|
|
3680
|
+
constructor(address, module_name, name, type_args) {
|
|
3441
3681
|
super();
|
|
3442
3682
|
this.address = address;
|
|
3683
|
+
this.module_name = module_name;
|
|
3443
3684
|
this.name = name;
|
|
3444
|
-
|
|
3445
|
-
static fromStr(moduleId) {
|
|
3446
|
-
const parts = moduleId.split("::");
|
|
3447
|
-
if (parts.length !== 2) {
|
|
3448
|
-
throw new Error("Invalid module id.");
|
|
3449
|
-
}
|
|
3450
|
-
return new ModuleId(AccountAddress.fromString(parts[0]), new Identifier(parts[1]));
|
|
3685
|
+
this.type_args = type_args;
|
|
3451
3686
|
}
|
|
3452
3687
|
serialize(serializer) {
|
|
3453
|
-
this.address
|
|
3454
|
-
|
|
3688
|
+
serializer.serialize(this.address);
|
|
3689
|
+
serializer.serialize(this.module_name);
|
|
3690
|
+
serializer.serialize(this.name);
|
|
3691
|
+
serializer.serializeVector(this.type_args);
|
|
3455
3692
|
}
|
|
3456
3693
|
static deserialize(deserializer) {
|
|
3457
3694
|
const address = AccountAddress.deserialize(deserializer);
|
|
3695
|
+
const moduleName = Identifier.deserialize(deserializer);
|
|
3458
3696
|
const name = Identifier.deserialize(deserializer);
|
|
3459
|
-
|
|
3697
|
+
const typeArgs = deserializer.deserializeVector(TypeTag);
|
|
3698
|
+
return new StructTag(address, moduleName, name, typeArgs);
|
|
3460
3699
|
}
|
|
3461
3700
|
};
|
|
3701
|
+
function aptosCoinStructTag() {
|
|
3702
|
+
return new StructTag(AccountAddress.ONE, new Identifier("aptos_coin"), new Identifier("AptosCoin"), []);
|
|
3703
|
+
}
|
|
3704
|
+
function stringStructTag() {
|
|
3705
|
+
return new StructTag(AccountAddress.ONE, new Identifier("string"), new Identifier("String"), []);
|
|
3706
|
+
}
|
|
3707
|
+
function optionStructTag(typeArg) {
|
|
3708
|
+
return new StructTag(AccountAddress.ONE, new Identifier("option"), new Identifier("Option"), [typeArg]);
|
|
3709
|
+
}
|
|
3710
|
+
function objectStructTag(typeArg) {
|
|
3711
|
+
return new StructTag(AccountAddress.ONE, new Identifier("object"), new Identifier("Object"), [typeArg]);
|
|
3712
|
+
}
|
|
3462
3713
|
|
|
3463
3714
|
// src/transactions/instances/transactionPayload.ts
|
|
3464
3715
|
function deserializeFromScriptArgument(deserializer) {
|
|
@@ -3621,12 +3872,12 @@ var MultiSig = class {
|
|
|
3621
3872
|
const payloadPresent = deserializer.deserializeBool();
|
|
3622
3873
|
let transaction_payload;
|
|
3623
3874
|
if (payloadPresent) {
|
|
3624
|
-
transaction_payload =
|
|
3875
|
+
transaction_payload = MultisigTransactionPayload.deserialize(deserializer);
|
|
3625
3876
|
}
|
|
3626
3877
|
return new MultiSig(multisig_address, transaction_payload);
|
|
3627
3878
|
}
|
|
3628
3879
|
};
|
|
3629
|
-
var
|
|
3880
|
+
var MultisigTransactionPayload = class {
|
|
3630
3881
|
constructor(transaction_payload) {
|
|
3631
3882
|
this.transaction_payload = transaction_payload;
|
|
3632
3883
|
}
|
|
@@ -3636,7 +3887,7 @@ var MultiSigTransactionPayload = class {
|
|
|
3636
3887
|
}
|
|
3637
3888
|
static deserialize(deserializer) {
|
|
3638
3889
|
deserializer.deserializeUleb128AsU32();
|
|
3639
|
-
return new
|
|
3890
|
+
return new MultisigTransactionPayload(EntryFunction.deserialize(deserializer));
|
|
3640
3891
|
}
|
|
3641
3892
|
};
|
|
3642
3893
|
|
|
@@ -3749,38 +4000,535 @@ var SignedTransaction = class extends Serializable {
|
|
|
3749
4000
|
}
|
|
3750
4001
|
};
|
|
3751
4002
|
|
|
3752
|
-
// src/transactions/
|
|
3753
|
-
function
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
4003
|
+
// src/transactions/typeTag/parser.ts
|
|
4004
|
+
function isValidIdentifier(str) {
|
|
4005
|
+
return !!str.match(/^[_a-zA-Z0-9]+$/);
|
|
4006
|
+
}
|
|
4007
|
+
function isValidWhitespaceCharacter(char) {
|
|
4008
|
+
return !!char.match(/\s/);
|
|
4009
|
+
}
|
|
4010
|
+
function consumeWhitespace(tagStr, pos) {
|
|
4011
|
+
let i = pos;
|
|
4012
|
+
for (; i < tagStr.length; i += 1) {
|
|
4013
|
+
const innerChar = tagStr[i];
|
|
4014
|
+
if (!isValidWhitespaceCharacter(innerChar)) {
|
|
4015
|
+
break;
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
4018
|
+
return i;
|
|
4019
|
+
}
|
|
4020
|
+
var TypeTagParserErrorType = /* @__PURE__ */ ((TypeTagParserErrorType2) => {
|
|
4021
|
+
TypeTagParserErrorType2["InvalidTypeTag"] = "unknown type";
|
|
4022
|
+
TypeTagParserErrorType2["UnexpectedTypeArgumentClose"] = "unexpected '>'";
|
|
4023
|
+
TypeTagParserErrorType2["UnexpectedWhitespaceCharacter"] = "unexpected whitespace character";
|
|
4024
|
+
TypeTagParserErrorType2["UnexpectedComma"] = "unexpected ','";
|
|
4025
|
+
TypeTagParserErrorType2["TypeArgumentCountMismatch"] = "type argument count doesn't match expected amount";
|
|
4026
|
+
TypeTagParserErrorType2["MissingTypeArgumentClose"] = "no matching '>' for '<'";
|
|
4027
|
+
TypeTagParserErrorType2["UnexpectedPrimitiveTypeArguments"] = "primitive types not expected to have type arguments";
|
|
4028
|
+
TypeTagParserErrorType2["UnexpectedVectorTypeArgumentCount"] = "vector type expected to have exactly one type argument";
|
|
4029
|
+
TypeTagParserErrorType2["UnexpectedStructFormat"] = "unexpected struct format, must be of the form 0xaddress::module_name::struct_name";
|
|
4030
|
+
TypeTagParserErrorType2["InvalidModuleNameCharacter"] = "module name must only contain alphanumeric or '_' characters";
|
|
4031
|
+
TypeTagParserErrorType2["InvalidStructNameCharacter"] = "struct name must only contain alphanumeric or '_' characters";
|
|
4032
|
+
return TypeTagParserErrorType2;
|
|
4033
|
+
})(TypeTagParserErrorType || {});
|
|
4034
|
+
var TypeTagParserError = class extends Error {
|
|
4035
|
+
constructor(typeTagStr, invalidReason) {
|
|
4036
|
+
super(`Failed to parse typeTag '${typeTagStr}', ${invalidReason}`);
|
|
4037
|
+
}
|
|
4038
|
+
};
|
|
4039
|
+
function parseTypeTag(typeStr, options) {
|
|
4040
|
+
var _a;
|
|
4041
|
+
const allowGenerics = (_a = options == null ? void 0 : options.allowGenerics) != null ? _a : false;
|
|
4042
|
+
const saved = [];
|
|
4043
|
+
let innerTypes = [];
|
|
4044
|
+
let curTypes = [];
|
|
4045
|
+
let cur = 0;
|
|
4046
|
+
let currentStr = "";
|
|
4047
|
+
let expectedTypes = 1;
|
|
4048
|
+
while (cur < typeStr.length) {
|
|
4049
|
+
const char = typeStr[cur];
|
|
4050
|
+
if (char === "<") {
|
|
4051
|
+
saved.push({
|
|
4052
|
+
savedExpectedTypes: expectedTypes,
|
|
4053
|
+
savedStr: currentStr,
|
|
4054
|
+
savedTypes: curTypes
|
|
4055
|
+
});
|
|
4056
|
+
currentStr = "";
|
|
4057
|
+
curTypes = [];
|
|
4058
|
+
expectedTypes = 1;
|
|
4059
|
+
} else if (char === ">") {
|
|
4060
|
+
if (currentStr !== "") {
|
|
4061
|
+
const newType = parseTypeTagInner(currentStr, innerTypes, allowGenerics);
|
|
4062
|
+
curTypes.push(newType);
|
|
4063
|
+
}
|
|
4064
|
+
const savedPop = saved.pop();
|
|
4065
|
+
if (savedPop === void 0) {
|
|
4066
|
+
throw new TypeTagParserError(typeStr, "unexpected '>'" /* UnexpectedTypeArgumentClose */);
|
|
4067
|
+
}
|
|
4068
|
+
if (expectedTypes !== curTypes.length) {
|
|
4069
|
+
throw new TypeTagParserError(typeStr, "type argument count doesn't match expected amount" /* TypeArgumentCountMismatch */);
|
|
4070
|
+
}
|
|
4071
|
+
const { savedStr, savedTypes, savedExpectedTypes } = savedPop;
|
|
4072
|
+
innerTypes = curTypes;
|
|
4073
|
+
curTypes = savedTypes;
|
|
4074
|
+
currentStr = savedStr;
|
|
4075
|
+
expectedTypes = savedExpectedTypes;
|
|
4076
|
+
} else if (char === ",") {
|
|
4077
|
+
if (currentStr.length !== 0) {
|
|
4078
|
+
const newType = parseTypeTagInner(currentStr, innerTypes, allowGenerics);
|
|
4079
|
+
innerTypes = [];
|
|
4080
|
+
curTypes.push(newType);
|
|
4081
|
+
currentStr = "";
|
|
4082
|
+
expectedTypes += 1;
|
|
4083
|
+
}
|
|
4084
|
+
} else if (isValidWhitespaceCharacter(char)) {
|
|
4085
|
+
let parsedTypeTag = false;
|
|
4086
|
+
if (currentStr.length !== 0) {
|
|
4087
|
+
const newType = parseTypeTagInner(currentStr, innerTypes, allowGenerics);
|
|
4088
|
+
innerTypes = [];
|
|
4089
|
+
curTypes.push(newType);
|
|
4090
|
+
currentStr = "";
|
|
4091
|
+
parsedTypeTag = true;
|
|
4092
|
+
}
|
|
4093
|
+
cur = consumeWhitespace(typeStr, cur);
|
|
4094
|
+
const nextChar = typeStr[cur];
|
|
4095
|
+
if (cur < typeStr.length && parsedTypeTag && nextChar !== "," && nextChar !== ">") {
|
|
4096
|
+
throw new TypeTagParserError(typeStr, "unexpected whitespace character" /* UnexpectedWhitespaceCharacter */);
|
|
4097
|
+
}
|
|
4098
|
+
continue;
|
|
4099
|
+
} else {
|
|
4100
|
+
currentStr += char;
|
|
4101
|
+
}
|
|
4102
|
+
cur += 1;
|
|
4103
|
+
}
|
|
4104
|
+
if (saved.length > 0) {
|
|
4105
|
+
throw new TypeTagParserError(typeStr, "no matching '>' for '<'" /* MissingTypeArgumentClose */);
|
|
4106
|
+
}
|
|
4107
|
+
switch (curTypes.length) {
|
|
4108
|
+
case 0:
|
|
4109
|
+
return parseTypeTagInner(currentStr, innerTypes, allowGenerics);
|
|
4110
|
+
case 1:
|
|
4111
|
+
if (currentStr === "") {
|
|
4112
|
+
return curTypes[0];
|
|
4113
|
+
}
|
|
4114
|
+
throw new TypeTagParserError(typeStr, "unexpected ','" /* UnexpectedComma */);
|
|
4115
|
+
default:
|
|
4116
|
+
throw new TypeTagParserError(typeStr, "unexpected whitespace character" /* UnexpectedWhitespaceCharacter */);
|
|
4117
|
+
}
|
|
4118
|
+
}
|
|
4119
|
+
function parseTypeTagInner(str, types, allowGenerics) {
|
|
4120
|
+
switch (str) {
|
|
4121
|
+
case "&signer":
|
|
4122
|
+
if (types.length > 0) {
|
|
4123
|
+
throw new TypeTagParserError(str, "primitive types not expected to have type arguments" /* UnexpectedPrimitiveTypeArguments */);
|
|
4124
|
+
}
|
|
4125
|
+
return new TypeTagReference(new TypeTagSigner());
|
|
4126
|
+
case "signer":
|
|
4127
|
+
if (types.length > 0) {
|
|
4128
|
+
throw new TypeTagParserError(str, "primitive types not expected to have type arguments" /* UnexpectedPrimitiveTypeArguments */);
|
|
4129
|
+
}
|
|
4130
|
+
return new TypeTagSigner();
|
|
4131
|
+
case "bool":
|
|
4132
|
+
if (types.length > 0) {
|
|
4133
|
+
throw new TypeTagParserError(str, "primitive types not expected to have type arguments" /* UnexpectedPrimitiveTypeArguments */);
|
|
4134
|
+
}
|
|
4135
|
+
return new TypeTagBool();
|
|
4136
|
+
case "address":
|
|
4137
|
+
if (types.length > 0) {
|
|
4138
|
+
throw new TypeTagParserError(str, "primitive types not expected to have type arguments" /* UnexpectedPrimitiveTypeArguments */);
|
|
4139
|
+
}
|
|
4140
|
+
return new TypeTagAddress();
|
|
4141
|
+
case "u8":
|
|
4142
|
+
if (types.length > 0) {
|
|
4143
|
+
throw new TypeTagParserError(str, "primitive types not expected to have type arguments" /* UnexpectedPrimitiveTypeArguments */);
|
|
4144
|
+
}
|
|
4145
|
+
return new TypeTagU8();
|
|
4146
|
+
case "u16":
|
|
4147
|
+
if (types.length > 0) {
|
|
4148
|
+
throw new TypeTagParserError(str, "primitive types not expected to have type arguments" /* UnexpectedPrimitiveTypeArguments */);
|
|
4149
|
+
}
|
|
4150
|
+
return new TypeTagU16();
|
|
4151
|
+
case "u32":
|
|
4152
|
+
if (types.length > 0) {
|
|
4153
|
+
throw new TypeTagParserError(str, "primitive types not expected to have type arguments" /* UnexpectedPrimitiveTypeArguments */);
|
|
4154
|
+
}
|
|
4155
|
+
return new TypeTagU32();
|
|
4156
|
+
case "u64":
|
|
4157
|
+
if (types.length > 0) {
|
|
4158
|
+
throw new TypeTagParserError(str, "primitive types not expected to have type arguments" /* UnexpectedPrimitiveTypeArguments */);
|
|
4159
|
+
}
|
|
4160
|
+
return new TypeTagU64();
|
|
4161
|
+
case "u128":
|
|
4162
|
+
if (types.length > 0) {
|
|
4163
|
+
throw new TypeTagParserError(str, "primitive types not expected to have type arguments" /* UnexpectedPrimitiveTypeArguments */);
|
|
4164
|
+
}
|
|
4165
|
+
return new TypeTagU128();
|
|
4166
|
+
case "u256":
|
|
4167
|
+
if (types.length > 0) {
|
|
4168
|
+
throw new TypeTagParserError(str, "primitive types not expected to have type arguments" /* UnexpectedPrimitiveTypeArguments */);
|
|
4169
|
+
}
|
|
4170
|
+
return new TypeTagU256();
|
|
4171
|
+
case "vector":
|
|
4172
|
+
if (types.length !== 1) {
|
|
4173
|
+
throw new TypeTagParserError(str, "vector type expected to have exactly one type argument" /* UnexpectedVectorTypeArgumentCount */);
|
|
4174
|
+
}
|
|
4175
|
+
return new TypeTagVector(types[0]);
|
|
4176
|
+
default:
|
|
4177
|
+
if (allowGenerics && str.match(/^T[0-9]+$/)) {
|
|
4178
|
+
return new TypeTagGeneric(Number(str.split("T")[1]));
|
|
4179
|
+
}
|
|
4180
|
+
if (!str.match(/.*:.*/)) {
|
|
4181
|
+
throw new TypeTagParserError(str, "unknown type" /* InvalidTypeTag */);
|
|
4182
|
+
}
|
|
4183
|
+
const structParts = str.split("::");
|
|
4184
|
+
if (structParts.length !== 3) {
|
|
4185
|
+
throw new TypeTagParserError(str, "unexpected struct format, must be of the form 0xaddress::module_name::struct_name" /* UnexpectedStructFormat */);
|
|
4186
|
+
}
|
|
4187
|
+
if (!isValidIdentifier(structParts[1])) {
|
|
4188
|
+
throw new TypeTagParserError(str, "module name must only contain alphanumeric or '_' characters" /* InvalidModuleNameCharacter */);
|
|
4189
|
+
}
|
|
4190
|
+
if (!isValidIdentifier(structParts[2])) {
|
|
4191
|
+
throw new TypeTagParserError(str, "struct name must only contain alphanumeric or '_' characters" /* InvalidStructNameCharacter */);
|
|
4192
|
+
}
|
|
4193
|
+
return new TypeTagStruct(
|
|
4194
|
+
new StructTag(
|
|
4195
|
+
AccountAddress.fromString(structParts[0]),
|
|
4196
|
+
new Identifier(structParts[1]),
|
|
4197
|
+
new Identifier(structParts[2]),
|
|
4198
|
+
types
|
|
4199
|
+
)
|
|
4200
|
+
);
|
|
4201
|
+
}
|
|
4202
|
+
}
|
|
4203
|
+
|
|
4204
|
+
// src/transactions/transactionBuilder/helpers.ts
|
|
4205
|
+
function isBool(arg) {
|
|
4206
|
+
return typeof arg === "boolean";
|
|
4207
|
+
}
|
|
4208
|
+
function isString(arg) {
|
|
4209
|
+
return typeof arg === "string";
|
|
4210
|
+
}
|
|
4211
|
+
function isNumber(arg) {
|
|
4212
|
+
return typeof arg === "number";
|
|
4213
|
+
}
|
|
4214
|
+
function isLargeNumber(arg) {
|
|
4215
|
+
return typeof arg === "number" || typeof arg === "bigint" || typeof arg === "string";
|
|
4216
|
+
}
|
|
4217
|
+
function isNull(arg) {
|
|
4218
|
+
return arg === null || arg === void 0;
|
|
4219
|
+
}
|
|
4220
|
+
function isBcsBool(arg) {
|
|
4221
|
+
return arg instanceof Bool;
|
|
4222
|
+
}
|
|
4223
|
+
function isBcsAddress(arg) {
|
|
4224
|
+
return arg instanceof AccountAddress;
|
|
4225
|
+
}
|
|
4226
|
+
function isBcsString(arg) {
|
|
4227
|
+
return arg instanceof MoveString;
|
|
4228
|
+
}
|
|
4229
|
+
function isBcsFixedBytes(arg) {
|
|
4230
|
+
return arg instanceof FixedBytes;
|
|
4231
|
+
}
|
|
4232
|
+
function isBcsU8(arg) {
|
|
4233
|
+
return arg instanceof U8;
|
|
4234
|
+
}
|
|
4235
|
+
function isBcsU16(arg) {
|
|
4236
|
+
return arg instanceof U16;
|
|
4237
|
+
}
|
|
4238
|
+
function isBcsU32(arg) {
|
|
4239
|
+
return arg instanceof U32;
|
|
4240
|
+
}
|
|
4241
|
+
function isBcsU64(arg) {
|
|
4242
|
+
return arg instanceof U64;
|
|
4243
|
+
}
|
|
4244
|
+
function isBcsU128(arg) {
|
|
4245
|
+
return arg instanceof U128;
|
|
4246
|
+
}
|
|
4247
|
+
function isBcsU256(arg) {
|
|
4248
|
+
return arg instanceof U256;
|
|
4249
|
+
}
|
|
4250
|
+
function isScriptDataInput(arg) {
|
|
4251
|
+
return "bytecode" in arg;
|
|
4252
|
+
}
|
|
4253
|
+
function throwTypeMismatch(expectedType, position) {
|
|
4254
|
+
throw new Error(`Type mismatch for argument ${position}, expected '${expectedType}'`);
|
|
4255
|
+
}
|
|
4256
|
+
function findFirstNonSignerArg(functionAbi) {
|
|
4257
|
+
return functionAbi.params.findIndex((param) => param !== "signer" && param !== "&signer");
|
|
4258
|
+
}
|
|
4259
|
+
function getFunctionParts(functionArg) {
|
|
4260
|
+
const funcNameParts = functionArg.split("::");
|
|
4261
|
+
if (funcNameParts.length !== 3) {
|
|
4262
|
+
throw new Error(`Invalid function ${functionArg}`);
|
|
4263
|
+
}
|
|
4264
|
+
const moduleAddress = funcNameParts[0];
|
|
4265
|
+
const moduleName = funcNameParts[1];
|
|
4266
|
+
const functionName = funcNameParts[2];
|
|
4267
|
+
return { moduleAddress, moduleName, functionName };
|
|
4268
|
+
}
|
|
4269
|
+
|
|
4270
|
+
// src/transactions/transactionBuilder/remoteAbi.ts
|
|
4271
|
+
function standardizeTypeTags(typeArguments) {
|
|
4272
|
+
var _a;
|
|
4273
|
+
return (_a = typeArguments == null ? void 0 : typeArguments.map((typeArg) => {
|
|
4274
|
+
if (isString(typeArg)) {
|
|
4275
|
+
return parseTypeTag(typeArg);
|
|
4276
|
+
}
|
|
4277
|
+
return typeArg;
|
|
4278
|
+
})) != null ? _a : [];
|
|
4279
|
+
}
|
|
4280
|
+
async function fetchEntryFunctionAbi(moduleAddress, moduleName, functionName, aptosConfig) {
|
|
4281
|
+
var _a;
|
|
4282
|
+
const module2 = await getModule({ aptosConfig, accountAddress: moduleAddress, moduleName });
|
|
4283
|
+
const functionAbi = (_a = module2.abi) == null ? void 0 : _a.exposed_functions.find((func) => func.name === functionName);
|
|
4284
|
+
if (!functionAbi) {
|
|
4285
|
+
throw new Error(`Could not find entry function ABI for '${moduleAddress}::${moduleName}::${functionName}'`);
|
|
4286
|
+
}
|
|
4287
|
+
if (!functionAbi.is_entry) {
|
|
4288
|
+
throw new Error(`'${moduleAddress}::${moduleName}::${functionName}' is not an entry function`);
|
|
4289
|
+
}
|
|
4290
|
+
const first = findFirstNonSignerArg(functionAbi);
|
|
4291
|
+
const params = [];
|
|
4292
|
+
for (let i = first; i < functionAbi.params.length; i += 1) {
|
|
4293
|
+
params.push(parseTypeTag(functionAbi.params[i], { allowGenerics: true }));
|
|
4294
|
+
}
|
|
4295
|
+
return {
|
|
4296
|
+
typeParameters: functionAbi.generic_type_params,
|
|
4297
|
+
parameters: params
|
|
4298
|
+
};
|
|
4299
|
+
}
|
|
4300
|
+
function convertArgument(functionName, functionAbi, arg, position, genericTypeParams) {
|
|
4301
|
+
if (position >= functionAbi.parameters.length) {
|
|
4302
|
+
throw new Error(`Too many arguments for '${functionName}', expected ${functionAbi.parameters.length}`);
|
|
4303
|
+
}
|
|
4304
|
+
if (isBcsBool(arg) || isBcsU8(arg) || isBcsU16(arg) || isBcsU32(arg) || isBcsU64(arg) || isBcsU128(arg) || isBcsU256(arg) || isBcsAddress(arg) || isBcsString(arg) || isBcsFixedBytes(arg) || arg instanceof MoveVector || arg instanceof MoveOption) {
|
|
4305
|
+
checkType(functionAbi, arg, position);
|
|
4306
|
+
return arg;
|
|
4307
|
+
}
|
|
4308
|
+
return parseArg(arg, functionAbi.parameters[position], position, genericTypeParams);
|
|
4309
|
+
}
|
|
4310
|
+
function parseArg(arg, param, position, genericTypeParams) {
|
|
4311
|
+
if (param.isBool()) {
|
|
4312
|
+
if (isBool(arg)) {
|
|
4313
|
+
return new Bool(arg);
|
|
4314
|
+
}
|
|
4315
|
+
throwTypeMismatch("boolean", position);
|
|
4316
|
+
}
|
|
4317
|
+
if (param.isAddress()) {
|
|
4318
|
+
if (isString(arg)) {
|
|
4319
|
+
return AccountAddress.fromString(arg);
|
|
4320
|
+
}
|
|
4321
|
+
throwTypeMismatch("string", position);
|
|
4322
|
+
}
|
|
4323
|
+
if (param.isU8()) {
|
|
4324
|
+
if (isNumber(arg)) {
|
|
4325
|
+
return new U8(arg);
|
|
4326
|
+
}
|
|
4327
|
+
throwTypeMismatch("number", position);
|
|
4328
|
+
}
|
|
4329
|
+
if (param.isU16()) {
|
|
4330
|
+
if (isNumber(arg)) {
|
|
4331
|
+
return new U16(arg);
|
|
4332
|
+
}
|
|
4333
|
+
throwTypeMismatch("number", position);
|
|
4334
|
+
}
|
|
4335
|
+
if (param.isU32()) {
|
|
4336
|
+
if (isNumber(arg)) {
|
|
4337
|
+
return new U32(arg);
|
|
4338
|
+
}
|
|
4339
|
+
throwTypeMismatch("number", position);
|
|
4340
|
+
}
|
|
4341
|
+
if (param.isU64()) {
|
|
4342
|
+
if (isLargeNumber(arg)) {
|
|
4343
|
+
return new U64(BigInt(arg));
|
|
4344
|
+
}
|
|
4345
|
+
throwTypeMismatch("bigint | number | string", position);
|
|
4346
|
+
}
|
|
4347
|
+
if (param.isU128()) {
|
|
4348
|
+
if (isLargeNumber(arg)) {
|
|
4349
|
+
return new U128(BigInt(arg));
|
|
4350
|
+
}
|
|
4351
|
+
throwTypeMismatch("bigint | number | string", position);
|
|
4352
|
+
}
|
|
4353
|
+
if (param.isU256()) {
|
|
4354
|
+
if (isLargeNumber(arg)) {
|
|
4355
|
+
return new U256(BigInt(arg));
|
|
4356
|
+
}
|
|
4357
|
+
throwTypeMismatch("bigint | number | string", position);
|
|
4358
|
+
}
|
|
4359
|
+
if (param.isGeneric()) {
|
|
4360
|
+
const genericIndex = param.value;
|
|
4361
|
+
if (genericIndex < 0 || genericIndex >= genericTypeParams.length) {
|
|
4362
|
+
throw new Error(`Generic argument ${param.toString()} is invalid for argument ${position}`);
|
|
4363
|
+
}
|
|
4364
|
+
parseArg(arg, genericTypeParams[genericIndex], position, genericTypeParams);
|
|
4365
|
+
}
|
|
4366
|
+
if (param.isVector()) {
|
|
4367
|
+
if (param.value.isU8() && isString(arg)) {
|
|
4368
|
+
return MoveVector.U8(Hex.fromHexInput(arg).toUint8Array());
|
|
4369
|
+
}
|
|
4370
|
+
if (Array.isArray(arg)) {
|
|
4371
|
+
return new MoveVector(arg.map((item) => parseArg(item, param.value, position, genericTypeParams)));
|
|
4372
|
+
}
|
|
4373
|
+
throw new Error(`Type mismatch for argument ${position}, type '${param.toString()}'`);
|
|
4374
|
+
}
|
|
4375
|
+
if (param.isStruct()) {
|
|
4376
|
+
if (param.isString()) {
|
|
4377
|
+
if (isString(arg)) {
|
|
4378
|
+
return new MoveString(arg);
|
|
4379
|
+
}
|
|
4380
|
+
throwTypeMismatch("string", position);
|
|
4381
|
+
}
|
|
4382
|
+
if (param.isObject()) {
|
|
4383
|
+
if (isString(arg)) {
|
|
4384
|
+
return AccountAddress.fromString(arg);
|
|
4385
|
+
}
|
|
4386
|
+
throwTypeMismatch("string", position);
|
|
4387
|
+
}
|
|
4388
|
+
if (param.isOption()) {
|
|
4389
|
+
if (isNull(arg)) {
|
|
4390
|
+
return new MoveOption(null);
|
|
4391
|
+
}
|
|
4392
|
+
return new MoveOption(parseArg(arg, param.value.type_args[0], position, genericTypeParams));
|
|
4393
|
+
}
|
|
4394
|
+
throw new Error(`Unsupported struct input type for argument ${position}, type '${param.toString()}'`);
|
|
4395
|
+
}
|
|
4396
|
+
throw new Error(`Type mismatch for argument ${position}, type '${param.toString()}'`);
|
|
4397
|
+
}
|
|
4398
|
+
function checkType(functionAbi, arg, position) {
|
|
4399
|
+
const param = functionAbi.parameters[position];
|
|
4400
|
+
if (param.isBool()) {
|
|
4401
|
+
if (isBcsBool(arg)) {
|
|
4402
|
+
return;
|
|
4403
|
+
}
|
|
4404
|
+
throwTypeMismatch("Bool", position);
|
|
4405
|
+
}
|
|
4406
|
+
if (param.isAddress()) {
|
|
4407
|
+
if (isBcsAddress(arg)) {
|
|
4408
|
+
return;
|
|
4409
|
+
}
|
|
4410
|
+
throwTypeMismatch("AccountAddress", position);
|
|
4411
|
+
}
|
|
4412
|
+
if (param.isU8()) {
|
|
4413
|
+
if (isBcsU8(arg)) {
|
|
4414
|
+
return;
|
|
4415
|
+
}
|
|
4416
|
+
throwTypeMismatch("U8", position);
|
|
4417
|
+
}
|
|
4418
|
+
if (param.isU16()) {
|
|
4419
|
+
if (isBcsU16(arg)) {
|
|
4420
|
+
return;
|
|
4421
|
+
}
|
|
4422
|
+
throwTypeMismatch("U16", position);
|
|
4423
|
+
}
|
|
4424
|
+
if (param.isU32()) {
|
|
4425
|
+
if (isBcsU32(arg)) {
|
|
4426
|
+
return;
|
|
4427
|
+
}
|
|
4428
|
+
throwTypeMismatch("U32", position);
|
|
4429
|
+
}
|
|
4430
|
+
if (param.isU64()) {
|
|
4431
|
+
if (isBcsU64(arg)) {
|
|
4432
|
+
return;
|
|
4433
|
+
}
|
|
4434
|
+
throwTypeMismatch("U64", position);
|
|
4435
|
+
}
|
|
4436
|
+
if (param.isU128()) {
|
|
4437
|
+
if (isBcsU128(arg)) {
|
|
4438
|
+
return;
|
|
4439
|
+
}
|
|
4440
|
+
throwTypeMismatch("U128", position);
|
|
4441
|
+
}
|
|
4442
|
+
if (param.isU256()) {
|
|
4443
|
+
if (isBcsU256(arg)) {
|
|
4444
|
+
return;
|
|
4445
|
+
}
|
|
4446
|
+
throwTypeMismatch("U256", position);
|
|
4447
|
+
}
|
|
4448
|
+
if (param.isVector()) {
|
|
4449
|
+
if (arg instanceof MoveVector) {
|
|
4450
|
+
return;
|
|
4451
|
+
}
|
|
4452
|
+
throwTypeMismatch("MoveVector", position);
|
|
4453
|
+
}
|
|
4454
|
+
if (param instanceof TypeTagStruct) {
|
|
4455
|
+
if (param.isString()) {
|
|
4456
|
+
if (isBcsString(arg)) {
|
|
4457
|
+
return;
|
|
4458
|
+
}
|
|
4459
|
+
throwTypeMismatch("MoveString", position);
|
|
4460
|
+
}
|
|
4461
|
+
if (param.isObject()) {
|
|
4462
|
+
if (isBcsAddress(arg)) {
|
|
4463
|
+
return;
|
|
4464
|
+
}
|
|
4465
|
+
throwTypeMismatch("AccountAddress", position);
|
|
4466
|
+
}
|
|
4467
|
+
if (param.isOption()) {
|
|
4468
|
+
if (arg instanceof MoveOption) {
|
|
4469
|
+
return;
|
|
4470
|
+
}
|
|
4471
|
+
throwTypeMismatch("MoveOption", position);
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
throw new Error(`Type mismatch for argument ${position}, expected '${param.toString()}'`);
|
|
4475
|
+
}
|
|
4476
|
+
|
|
4477
|
+
// src/transactions/transactionBuilder/transactionBuilder.ts
|
|
4478
|
+
async function generateTransactionPayload(args) {
|
|
4479
|
+
if (isScriptDataInput(args)) {
|
|
4480
|
+
return generateTransactionPayloadScript(args);
|
|
4481
|
+
}
|
|
4482
|
+
const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function);
|
|
4483
|
+
const functionAbi = await memoizeAsync(
|
|
4484
|
+
async () => fetchEntryFunctionAbi(moduleAddress, moduleName, functionName, args.aptosConfig),
|
|
4485
|
+
`entry-function-${args.aptosConfig.network}-${moduleAddress}-${moduleName}-${functionName}`,
|
|
4486
|
+
1e3 * 60 * 5
|
|
4487
|
+
)();
|
|
4488
|
+
return generateTransactionPayloadWithABI(args, functionAbi);
|
|
4489
|
+
}
|
|
4490
|
+
function generateTransactionPayloadWithABI(args, functionAbi) {
|
|
4491
|
+
if (isScriptDataInput(args)) {
|
|
4492
|
+
return generateTransactionPayloadScript(args);
|
|
4493
|
+
}
|
|
4494
|
+
const { moduleAddress, moduleName, functionName } = getFunctionParts(args.function);
|
|
4495
|
+
const typeArguments = standardizeTypeTags(args.typeArguments);
|
|
4496
|
+
if (typeArguments.length !== functionAbi.typeParameters.length) {
|
|
4497
|
+
throw new Error(
|
|
4498
|
+
`Type argument count mismatch, expected ${functionAbi.typeParameters.length}, received ${typeArguments.length}`
|
|
4499
|
+
);
|
|
4500
|
+
}
|
|
4501
|
+
const functionArguments = args.functionArguments.map(
|
|
4502
|
+
(arg, i) => convertArgument(args.function, functionAbi, arg, i, typeArguments)
|
|
4503
|
+
);
|
|
4504
|
+
if (functionArguments.length !== functionAbi.parameters.length) {
|
|
4505
|
+
throw new Error(
|
|
4506
|
+
`Too few arguments for '${moduleAddress}::${moduleName}::${functionName}', expected ${functionAbi.parameters.length} but got ${functionArguments.length}`
|
|
3758
4507
|
);
|
|
3759
4508
|
}
|
|
4509
|
+
const entryFunctionPayload = EntryFunction.build(
|
|
4510
|
+
`${moduleAddress}::${moduleName}`,
|
|
4511
|
+
functionName,
|
|
4512
|
+
typeArguments,
|
|
4513
|
+
functionArguments
|
|
4514
|
+
);
|
|
3760
4515
|
if ("multisigAddress" in args) {
|
|
3761
|
-
|
|
4516
|
+
let multisigAddress;
|
|
4517
|
+
if (typeof args.multisigAddress === "string") {
|
|
4518
|
+
multisigAddress = AccountAddress.fromString(args.multisigAddress);
|
|
4519
|
+
} else {
|
|
4520
|
+
multisigAddress = args.multisigAddress;
|
|
4521
|
+
}
|
|
3762
4522
|
return new TransactionPayloadMultisig(
|
|
3763
|
-
new MultiSig(
|
|
3764
|
-
args.multisigAddress,
|
|
3765
|
-
new MultiSigTransactionPayload(
|
|
3766
|
-
EntryFunction.build(
|
|
3767
|
-
`${funcNameParts2[0]}::${funcNameParts2[1]}`,
|
|
3768
|
-
funcNameParts2[2],
|
|
3769
|
-
(_b = args.typeArguments) != null ? _b : [],
|
|
3770
|
-
args.arguments
|
|
3771
|
-
)
|
|
3772
|
-
)
|
|
3773
|
-
)
|
|
4523
|
+
new MultiSig(multisigAddress, new MultisigTransactionPayload(entryFunctionPayload))
|
|
3774
4524
|
);
|
|
3775
4525
|
}
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
args.arguments
|
|
3783
|
-
)
|
|
4526
|
+
return new TransactionPayloadEntryFunction(entryFunctionPayload);
|
|
4527
|
+
}
|
|
4528
|
+
function generateTransactionPayloadScript(args) {
|
|
4529
|
+
var _a;
|
|
4530
|
+
return new TransactionPayloadScript(
|
|
4531
|
+
new Script(Hex.fromHexInput(args.bytecode).toUint8Array(), (_a = args.typeArguments) != null ? _a : [], args.functionArguments)
|
|
3784
4532
|
);
|
|
3785
4533
|
}
|
|
3786
4534
|
async function generateRawTransaction(args) {
|
|
@@ -3886,26 +4634,25 @@ function generateSignedTransactionForSimulation(args) {
|
|
|
3886
4634
|
accountAuthenticator.public_key,
|
|
3887
4635
|
accountAuthenticator.signature
|
|
3888
4636
|
);
|
|
3889
|
-
} else if (accountAuthenticator instanceof
|
|
3890
|
-
transactionAuthenticator = new
|
|
3891
|
-
accountAuthenticator.public_key,
|
|
3892
|
-
accountAuthenticator.signature
|
|
3893
|
-
);
|
|
4637
|
+
} else if (accountAuthenticator instanceof AccountAuthenticatorSingleKey) {
|
|
4638
|
+
transactionAuthenticator = new TransactionAuthenticatorSingleSender(accountAuthenticator);
|
|
3894
4639
|
} else {
|
|
3895
4640
|
throw new Error("Invalid public key");
|
|
3896
4641
|
}
|
|
3897
4642
|
return new SignedTransaction(deserializedTransaction, transactionAuthenticator).bcsToBytes();
|
|
3898
4643
|
}
|
|
3899
4644
|
function getAuthenticatorForSimulation(publicKey) {
|
|
3900
|
-
if (publicKey instanceof
|
|
3901
|
-
|
|
3902
|
-
new
|
|
3903
|
-
|
|
3904
|
-
)
|
|
4645
|
+
if (publicKey instanceof AnyPublicKey) {
|
|
4646
|
+
if (publicKey.publicKey instanceof Ed25519PublicKey) {
|
|
4647
|
+
return new AccountAuthenticatorSingleKey(publicKey, new AnySignature(new Ed25519Signature(new Uint8Array(64))));
|
|
4648
|
+
}
|
|
4649
|
+
if (publicKey.publicKey instanceof Secp256k1PublicKey) {
|
|
4650
|
+
return new AccountAuthenticatorSingleKey(publicKey, new AnySignature(new Secp256k1Signature(new Uint8Array(64))));
|
|
4651
|
+
}
|
|
3905
4652
|
}
|
|
3906
|
-
return new
|
|
3907
|
-
new
|
|
3908
|
-
new
|
|
4653
|
+
return new AccountAuthenticatorEd25519(
|
|
4654
|
+
new Ed25519PublicKey(publicKey.toUint8Array()),
|
|
4655
|
+
new Ed25519Signature(new Uint8Array(64))
|
|
3909
4656
|
);
|
|
3910
4657
|
}
|
|
3911
4658
|
function sign(args) {
|
|
@@ -3919,11 +4666,8 @@ function sign(args) {
|
|
|
3919
4666
|
new Ed25519PublicKey(signer.publicKey.toUint8Array()),
|
|
3920
4667
|
new Ed25519Signature(signerSignature.toUint8Array())
|
|
3921
4668
|
);
|
|
3922
|
-
case 2 /*
|
|
3923
|
-
return new
|
|
3924
|
-
new Secp256k1PublicKey(signer.publicKey.toUint8Array()),
|
|
3925
|
-
new Secp256k1Signature(signerSignature.toUint8Array())
|
|
3926
|
-
);
|
|
4669
|
+
case 2 /* SingleKey */:
|
|
4670
|
+
return new AccountAuthenticatorSingleKey(signer.publicKey, new AnySignature(signerSignature));
|
|
3927
4671
|
default:
|
|
3928
4672
|
throw new Error(`Cannot sign transaction, signing scheme ${signer.signingScheme} not supported`);
|
|
3929
4673
|
}
|
|
@@ -3938,24 +4682,19 @@ function generateSignedTransaction(args) {
|
|
|
3938
4682
|
secondarySignerAuthenticators
|
|
3939
4683
|
);
|
|
3940
4684
|
}
|
|
3941
|
-
|
|
3942
|
-
const accountAuthenticator = AccountAuthenticator.deserialize(deserializer);
|
|
3943
|
-
if (accountAuthenticator instanceof AccountAuthenticatorEd25519) {
|
|
4685
|
+
if (senderAuthenticator instanceof AccountAuthenticatorEd25519) {
|
|
3944
4686
|
const transactionAuthenticator = new TransactionAuthenticatorEd25519(
|
|
3945
|
-
|
|
3946
|
-
|
|
4687
|
+
senderAuthenticator.public_key,
|
|
4688
|
+
senderAuthenticator.signature
|
|
3947
4689
|
);
|
|
3948
4690
|
return new SignedTransaction(transactionToSubmit, transactionAuthenticator).bcsToBytes();
|
|
3949
4691
|
}
|
|
3950
|
-
if (
|
|
3951
|
-
const transactionAuthenticator = new
|
|
3952
|
-
accountAuthenticator.public_key,
|
|
3953
|
-
accountAuthenticator.signature
|
|
3954
|
-
);
|
|
4692
|
+
if (senderAuthenticator instanceof AccountAuthenticatorSingleKey || senderAuthenticator instanceof AccountAuthenticatorMultiKey) {
|
|
4693
|
+
const transactionAuthenticator = new TransactionAuthenticatorSingleSender(senderAuthenticator);
|
|
3955
4694
|
return new SignedTransaction(transactionToSubmit, transactionAuthenticator).bcsToBytes();
|
|
3956
4695
|
}
|
|
3957
4696
|
throw new Error(
|
|
3958
|
-
`Cannot generate a signed transaction, ${
|
|
4697
|
+
`Cannot generate a signed transaction, ${senderAuthenticator} is not a supported account authentication scheme`
|
|
3959
4698
|
);
|
|
3960
4699
|
}
|
|
3961
4700
|
function deriveTransactionType(transaction) {
|
|
@@ -4031,7 +4770,26 @@ function getSigningMessage(rawTxn) {
|
|
|
4031
4770
|
// src/internal/transactionSubmission.ts
|
|
4032
4771
|
async function generateTransaction(args) {
|
|
4033
4772
|
const { aptosConfig, sender, data, options, secondarySignerAddresses, feePayerAddress } = args;
|
|
4034
|
-
|
|
4773
|
+
let generateTransactionPayloadData;
|
|
4774
|
+
if ("bytecode" in data) {
|
|
4775
|
+
generateTransactionPayloadData = data;
|
|
4776
|
+
} else if ("multisigAddress" in data) {
|
|
4777
|
+
generateTransactionPayloadData = {
|
|
4778
|
+
aptosConfig,
|
|
4779
|
+
multisigAddress: data.multisigAddress,
|
|
4780
|
+
function: data.function,
|
|
4781
|
+
functionArguments: data.functionArguments,
|
|
4782
|
+
typeArguments: data.typeArguments
|
|
4783
|
+
};
|
|
4784
|
+
} else {
|
|
4785
|
+
generateTransactionPayloadData = {
|
|
4786
|
+
aptosConfig,
|
|
4787
|
+
function: data.function,
|
|
4788
|
+
functionArguments: data.functionArguments,
|
|
4789
|
+
typeArguments: data.typeArguments
|
|
4790
|
+
};
|
|
4791
|
+
}
|
|
4792
|
+
const payload = await generateTransactionPayload(generateTransactionPayloadData);
|
|
4035
4793
|
return buildTransaction({
|
|
4036
4794
|
aptosConfig,
|
|
4037
4795
|
sender,
|
|
@@ -4090,14 +4848,15 @@ async function signAndSubmitTransaction(args) {
|
|
|
4090
4848
|
senderAuthenticator: authenticator
|
|
4091
4849
|
});
|
|
4092
4850
|
}
|
|
4093
|
-
async function
|
|
4094
|
-
const { aptosConfig, account, metadataBytes,
|
|
4851
|
+
async function publicPackageTransaction(args) {
|
|
4852
|
+
const { aptosConfig, account, metadataBytes, moduleBytecode, options } = args;
|
|
4853
|
+
const totalByteCode = moduleBytecode.map((bytecode) => MoveVector.U8(bytecode));
|
|
4095
4854
|
const transaction = await generateTransaction({
|
|
4096
4855
|
aptosConfig,
|
|
4097
4856
|
sender: account,
|
|
4098
4857
|
data: {
|
|
4099
4858
|
function: "0x1::code::publish_package_txn",
|
|
4100
|
-
|
|
4859
|
+
functionArguments: [MoveVector.U8(metadataBytes), new MoveVector(totalByteCode)]
|
|
4101
4860
|
},
|
|
4102
4861
|
options
|
|
4103
4862
|
});
|
|
@@ -4113,8 +4872,8 @@ async function transferCoinTransaction(args) {
|
|
|
4113
4872
|
sender: sender.accountAddress.toString(),
|
|
4114
4873
|
data: {
|
|
4115
4874
|
function: "0x1::aptos_account::transfer_coins",
|
|
4116
|
-
typeArguments: [
|
|
4117
|
-
|
|
4875
|
+
typeArguments: [parseTypeTag(coinStructType)],
|
|
4876
|
+
functionArguments: [AccountAddress.fromHexInput(recipient), new U64(amount)]
|
|
4118
4877
|
},
|
|
4119
4878
|
options
|
|
4120
4879
|
});
|
|
@@ -4139,7 +4898,7 @@ async function mintTokenTransaction(args) {
|
|
|
4139
4898
|
sender: creator.accountAddress.toString(),
|
|
4140
4899
|
data: {
|
|
4141
4900
|
function: "0x4::aptos_token::mint",
|
|
4142
|
-
|
|
4901
|
+
functionArguments: [
|
|
4143
4902
|
new MoveString(args.collection),
|
|
4144
4903
|
new MoveString(args.description),
|
|
4145
4904
|
new MoveString(args.name),
|
|
@@ -4241,7 +5000,7 @@ async function createCollectionTransaction(args) {
|
|
|
4241
5000
|
sender: creator.accountAddress.toString(),
|
|
4242
5001
|
data: {
|
|
4243
5002
|
function: "0x4::aptos_token::create_collection",
|
|
4244
|
-
|
|
5003
|
+
functionArguments: [
|
|
4245
5004
|
new MoveString(args.description),
|
|
4246
5005
|
new U64((_a = args.maxSupply) != null ? _a : MAX_U64_BIG_INT),
|
|
4247
5006
|
new MoveString(args.name),
|
|
@@ -4285,9 +5044,6 @@ async function getCollectionData(args) {
|
|
|
4285
5044
|
query: graphqlQuery,
|
|
4286
5045
|
originMethod: "getCollectionData"
|
|
4287
5046
|
});
|
|
4288
|
-
if (data.current_collections_v2.length === 0) {
|
|
4289
|
-
throw Error("Collection not found");
|
|
4290
|
-
}
|
|
4291
5047
|
return data.current_collections_v2[0];
|
|
4292
5048
|
}
|
|
4293
5049
|
async function getCollectionId(args) {
|
|
@@ -4387,9 +5143,8 @@ var Event = class {
|
|
|
4387
5143
|
|
|
4388
5144
|
// src/internal/faucet.ts
|
|
4389
5145
|
async function fundAccount(args) {
|
|
4390
|
-
|
|
4391
|
-
const
|
|
4392
|
-
const timeoutSecs = (_a = args.timeoutSecs) != null ? _a : DEFAULT_TXN_TIMEOUT_SEC;
|
|
5146
|
+
const { aptosConfig, accountAddress, amount, options } = args;
|
|
5147
|
+
const timeout = (options == null ? void 0 : options.timeoutSecs) || DEFAULT_TXN_TIMEOUT_SEC;
|
|
4393
5148
|
const { data } = await postAptosFaucet({
|
|
4394
5149
|
aptosConfig,
|
|
4395
5150
|
path: "fund",
|
|
@@ -4400,7 +5155,15 @@ async function fundAccount(args) {
|
|
|
4400
5155
|
originMethod: "fundAccount"
|
|
4401
5156
|
});
|
|
4402
5157
|
const txnHash = data.txn_hashes[0];
|
|
4403
|
-
await waitForTransaction({
|
|
5158
|
+
await waitForTransaction({
|
|
5159
|
+
aptosConfig,
|
|
5160
|
+
transactionHash: txnHash,
|
|
5161
|
+
options: {
|
|
5162
|
+
timeoutSecs: timeout,
|
|
5163
|
+
checkSuccess: options == null ? void 0 : options.checkSuccess,
|
|
5164
|
+
indexerVersionCheck: options == null ? void 0 : options.indexerVersionCheck
|
|
5165
|
+
}
|
|
5166
|
+
});
|
|
4404
5167
|
return txnHash;
|
|
4405
5168
|
}
|
|
4406
5169
|
|
|
@@ -4478,6 +5241,17 @@ var FungibleAsset = class {
|
|
|
4478
5241
|
async getFungibleAssetMetadata(args) {
|
|
4479
5242
|
return getFungibleAssetMetadata({ aptosConfig: this.config, ...args });
|
|
4480
5243
|
}
|
|
5244
|
+
async getFungibleAssetMetadataByAssetType(assetType) {
|
|
5245
|
+
const data = await getFungibleAssetMetadata({
|
|
5246
|
+
aptosConfig: this.config,
|
|
5247
|
+
options: {
|
|
5248
|
+
where: {
|
|
5249
|
+
asset_type: { _eq: assetType }
|
|
5250
|
+
}
|
|
5251
|
+
}
|
|
5252
|
+
});
|
|
5253
|
+
return data[0];
|
|
5254
|
+
}
|
|
4481
5255
|
async getFungibleAssetActivities(args) {
|
|
4482
5256
|
return getFungibleAssetActivities({ aptosConfig: this.config, ...args });
|
|
4483
5257
|
}
|
|
@@ -4652,8 +5426,8 @@ var TransactionSubmission = class {
|
|
|
4652
5426
|
transaction
|
|
4653
5427
|
});
|
|
4654
5428
|
}
|
|
4655
|
-
async
|
|
4656
|
-
return
|
|
5429
|
+
async publishPackageTransaction(args) {
|
|
5430
|
+
return publicPackageTransaction({ aptosConfig: this.config, ...args });
|
|
4657
5431
|
}
|
|
4658
5432
|
};
|
|
4659
5433
|
|
|
@@ -4699,32 +5473,47 @@ applyMixin(Aptos, TransactionSubmission, "transactionSubmission");
|
|
|
4699
5473
|
APTOS_PATH_REGEX,
|
|
4700
5474
|
Account,
|
|
4701
5475
|
AccountAddress,
|
|
5476
|
+
AccountAuthenticator,
|
|
5477
|
+
AccountAuthenticatorEd25519,
|
|
5478
|
+
AccountAuthenticatorMultiEd25519,
|
|
5479
|
+
AccountAuthenticatorMultiKey,
|
|
5480
|
+
AccountAuthenticatorSingleKey,
|
|
4702
5481
|
AccountAuthenticatorVariant,
|
|
4703
5482
|
AddressInvalidReason,
|
|
5483
|
+
AnyPublicKeyVariant,
|
|
5484
|
+
AnySignatureVariant,
|
|
4704
5485
|
Aptos,
|
|
4705
5486
|
AptosApiError,
|
|
4706
5487
|
AptosConfig,
|
|
4707
5488
|
AuthenticationKey,
|
|
4708
5489
|
Bool,
|
|
5490
|
+
ChainId,
|
|
4709
5491
|
DeriveScheme,
|
|
4710
5492
|
Deserializer,
|
|
4711
5493
|
Ed25519PrivateKey,
|
|
4712
5494
|
Ed25519PublicKey,
|
|
4713
5495
|
Ed25519Signature,
|
|
5496
|
+
EntryFunction,
|
|
4714
5497
|
EntryFunctionBytes,
|
|
5498
|
+
FeePayerRawTransaction,
|
|
4715
5499
|
FixedBytes,
|
|
4716
5500
|
Hex,
|
|
4717
5501
|
HexInvalidReason,
|
|
5502
|
+
Identifier,
|
|
4718
5503
|
KeyType,
|
|
4719
5504
|
MimeType,
|
|
5505
|
+
ModuleId,
|
|
4720
5506
|
MoveAbility,
|
|
4721
5507
|
MoveFunctionVisibility,
|
|
4722
|
-
MoveObject,
|
|
4723
5508
|
MoveOption,
|
|
4724
5509
|
MoveString,
|
|
4725
5510
|
MoveVector,
|
|
5511
|
+
MultiAgentRawTransaction,
|
|
4726
5512
|
MultiEd25519PublicKey,
|
|
4727
5513
|
MultiEd25519Signature,
|
|
5514
|
+
MultiKey,
|
|
5515
|
+
MultiSig,
|
|
5516
|
+
MultisigTransactionPayload,
|
|
4728
5517
|
Network,
|
|
4729
5518
|
NetworkToChainId,
|
|
4730
5519
|
NetworkToFaucetAPI,
|
|
@@ -4733,7 +5522,10 @@ applyMixin(Aptos, TransactionSubmission, "transactionSubmission");
|
|
|
4733
5522
|
ParsingError,
|
|
4734
5523
|
PrivateKey,
|
|
4735
5524
|
PublicKey,
|
|
5525
|
+
RawTransaction,
|
|
5526
|
+
RawTransactionWithData,
|
|
4736
5527
|
RoleType,
|
|
5528
|
+
Script,
|
|
4737
5529
|
ScriptTransactionArgumentVariants,
|
|
4738
5530
|
Secp256k1PrivateKey,
|
|
4739
5531
|
Secp256k1PublicKey,
|
|
@@ -4741,17 +5533,31 @@ applyMixin(Aptos, TransactionSubmission, "transactionSubmission");
|
|
|
4741
5533
|
Serializable,
|
|
4742
5534
|
Serializer,
|
|
4743
5535
|
Signature,
|
|
5536
|
+
SignedTransaction,
|
|
4744
5537
|
SigningScheme,
|
|
5538
|
+
SigningSchemeInput,
|
|
4745
5539
|
StructTag,
|
|
5540
|
+
TransactionAuthenticator,
|
|
5541
|
+
TransactionAuthenticatorEd25519,
|
|
5542
|
+
TransactionAuthenticatorFeePayer,
|
|
5543
|
+
TransactionAuthenticatorMultiAgent,
|
|
5544
|
+
TransactionAuthenticatorMultiEd25519,
|
|
5545
|
+
TransactionAuthenticatorSingleSender,
|
|
4746
5546
|
TransactionAuthenticatorVariant,
|
|
5547
|
+
TransactionPayload,
|
|
5548
|
+
TransactionPayloadEntryFunction,
|
|
5549
|
+
TransactionPayloadMultisig,
|
|
5550
|
+
TransactionPayloadScript,
|
|
4747
5551
|
TransactionPayloadVariants,
|
|
4748
5552
|
TransactionResponseType,
|
|
4749
5553
|
TransactionVariants,
|
|
4750
5554
|
TypeTag,
|
|
4751
5555
|
TypeTagAddress,
|
|
4752
5556
|
TypeTagBool,
|
|
4753
|
-
|
|
5557
|
+
TypeTagGeneric,
|
|
4754
5558
|
TypeTagParserError,
|
|
5559
|
+
TypeTagParserErrorType,
|
|
5560
|
+
TypeTagReference,
|
|
4755
5561
|
TypeTagSigner,
|
|
4756
5562
|
TypeTagStruct,
|
|
4757
5563
|
TypeTagU128,
|
|
@@ -4768,22 +5574,58 @@ applyMixin(Aptos, TransactionSubmission, "transactionSubmission");
|
|
|
4768
5574
|
U32,
|
|
4769
5575
|
U64,
|
|
4770
5576
|
U8,
|
|
5577
|
+
aptosCoinStructTag,
|
|
4771
5578
|
aptosRequest,
|
|
5579
|
+
buildTransaction,
|
|
5580
|
+
convertArgument,
|
|
4772
5581
|
derivePrivateKeyFromMnemonic,
|
|
5582
|
+
deriveTransactionType,
|
|
5583
|
+
deserializeFromScriptArgument,
|
|
4773
5584
|
ensureBoolean,
|
|
5585
|
+
fetchEntryFunctionAbi,
|
|
5586
|
+
findFirstNonSignerArg,
|
|
5587
|
+
generateMultiSignersSignedTransaction,
|
|
5588
|
+
generateRawTransaction,
|
|
5589
|
+
generateSignedTransaction,
|
|
5590
|
+
generateSignedTransactionForSimulation,
|
|
5591
|
+
generateTransactionPayload,
|
|
5592
|
+
generateTransactionPayloadWithABI,
|
|
4774
5593
|
get,
|
|
4775
5594
|
getAptosFullNode,
|
|
5595
|
+
getAuthenticatorForSimulation,
|
|
5596
|
+
getFunctionParts,
|
|
5597
|
+
getSigningMessage,
|
|
5598
|
+
isBcsAddress,
|
|
5599
|
+
isBcsBool,
|
|
5600
|
+
isBcsFixedBytes,
|
|
5601
|
+
isBcsString,
|
|
5602
|
+
isBcsU128,
|
|
5603
|
+
isBcsU16,
|
|
5604
|
+
isBcsU256,
|
|
5605
|
+
isBcsU32,
|
|
5606
|
+
isBcsU64,
|
|
5607
|
+
isBcsU8,
|
|
5608
|
+
isBool,
|
|
5609
|
+
isLargeNumber,
|
|
5610
|
+
isNull,
|
|
5611
|
+
isNumber,
|
|
5612
|
+
isScriptDataInput,
|
|
5613
|
+
isString,
|
|
4776
5614
|
isValidPath,
|
|
4777
5615
|
objectStructTag,
|
|
4778
5616
|
optionStructTag,
|
|
4779
5617
|
outOfRangeErrorMessage,
|
|
4780
5618
|
paginateWithCursor,
|
|
5619
|
+
parseTypeTag,
|
|
4781
5620
|
post,
|
|
4782
5621
|
postAptosFaucet,
|
|
4783
5622
|
postAptosFullNode,
|
|
4784
5623
|
postAptosIndexer,
|
|
4785
5624
|
request,
|
|
5625
|
+
sign,
|
|
5626
|
+
standardizeTypeTags,
|
|
4786
5627
|
stringStructTag,
|
|
5628
|
+
throwTypeMismatch,
|
|
4787
5629
|
validateNumberInRange
|
|
4788
5630
|
});
|
|
4789
5631
|
//# sourceMappingURL=index.js.map
|