@fuel-ts/account 0.0.0-rc-1889-20240322122653 → 0.0.0-rc-1356-20240322130951
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.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/account.d.ts +177 -0
- package/dist/account.d.ts.map +1 -0
- package/dist/configs.d.ts +2 -3
- package/dist/configs.d.ts.map +1 -0
- package/dist/connectors/fuel-connector.d.ts +188 -0
- package/dist/connectors/fuel-connector.d.ts.map +1 -0
- package/dist/connectors/fuel.d.ts +133 -0
- package/dist/connectors/fuel.d.ts.map +1 -0
- package/dist/connectors/index.d.ts +5 -0
- package/dist/connectors/index.d.ts.map +1 -0
- package/dist/connectors/types/connector-metadata.d.ts +12 -0
- package/dist/connectors/types/connector-metadata.d.ts.map +1 -0
- package/dist/connectors/types/connector-types.d.ts +34 -0
- package/dist/connectors/types/connector-types.d.ts.map +1 -0
- package/dist/connectors/types/data-type.d.ts +34 -0
- package/dist/connectors/types/data-type.d.ts.map +1 -0
- package/dist/connectors/types/events.d.ts +111 -0
- package/dist/connectors/types/events.d.ts.map +1 -0
- package/dist/connectors/types/index.d.ts +7 -0
- package/dist/connectors/types/index.d.ts.map +1 -0
- package/dist/connectors/types/local-storage.d.ts +11 -0
- package/dist/connectors/types/local-storage.d.ts.map +1 -0
- package/dist/connectors/types/target-object.d.ts +14 -0
- package/dist/connectors/types/target-object.d.ts.map +1 -0
- package/dist/connectors/utils/cache.d.ts +14 -0
- package/dist/connectors/utils/cache.d.ts.map +1 -0
- package/dist/connectors/utils/dispatch-fuel-connector-event.d.ts +7 -0
- package/dist/connectors/utils/dispatch-fuel-connector-event.d.ts.map +1 -0
- package/dist/connectors/utils/index.d.ts +4 -0
- package/dist/connectors/utils/index.d.ts.map +1 -0
- package/dist/connectors/utils/promises.d.ts +8 -0
- package/dist/connectors/utils/promises.d.ts.map +1 -0
- package/dist/hdwallet/hdwallet.d.ts +58 -0
- package/dist/hdwallet/hdwallet.d.ts.map +1 -0
- package/dist/hdwallet/index.d.ts +2 -0
- package/dist/hdwallet/index.d.ts.map +1 -0
- package/dist/index.d.ts +13 -904
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +461 -394
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +350 -314
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +251 -212
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/index.d.ts +3 -0
- package/dist/mnemonic/index.d.ts.map +1 -0
- package/dist/mnemonic/mnemonic.d.ts +85 -0
- package/dist/mnemonic/mnemonic.d.ts.map +1 -0
- package/dist/mnemonic/utils.d.ts +8 -0
- package/dist/mnemonic/utils.d.ts.map +1 -0
- package/dist/predicate/index.d.ts +3 -0
- package/dist/predicate/index.d.ts.map +1 -0
- package/dist/predicate/predicate.d.ts +94 -0
- package/dist/predicate/predicate.d.ts.map +1 -0
- package/dist/predicate/utils/getPredicateRoot.d.ts +12 -0
- package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -0
- package/dist/predicate/utils/index.d.ts +2 -0
- package/dist/predicate/utils/index.d.ts.map +1 -0
- package/dist/providers/__generated__/operations.d.ts +3477 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -0
- package/dist/providers/assets/index.d.ts +5 -0
- package/dist/providers/assets/index.d.ts.map +1 -0
- package/dist/providers/assets/types.d.ts +36 -0
- package/dist/providers/assets/types.d.ts.map +1 -0
- package/dist/providers/assets/utils/index.d.ts +4 -0
- package/dist/providers/assets/utils/index.d.ts.map +1 -0
- package/dist/providers/assets/utils/network.d.ts +33 -0
- package/dist/providers/assets/utils/network.d.ts.map +1 -0
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +14 -0
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -0
- package/dist/providers/assets/utils/url.d.ts +2 -0
- package/dist/providers/assets/utils/url.d.ts.map +1 -0
- package/dist/providers/chains.d.ts +11 -0
- package/dist/providers/chains.d.ts.map +1 -0
- package/dist/providers/coin-quantity.d.ts +21 -0
- package/dist/providers/coin-quantity.d.ts.map +1 -0
- package/dist/providers/coin.d.ts +15 -0
- package/dist/providers/coin.d.ts.map +1 -0
- package/dist/providers/fuel-graphql-subscriber.d.ts +23 -0
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -0
- package/dist/providers/index.d.ts +13 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/memory-cache.d.ts +11 -0
- package/dist/providers/memory-cache.d.ts.map +1 -0
- package/dist/providers/message.d.ts +60 -0
- package/dist/providers/message.d.ts.map +1 -0
- package/dist/providers/provider.d.ts +522 -0
- package/dist/providers/provider.d.ts.map +1 -0
- package/dist/providers/resource.d.ts +37 -0
- package/dist/providers/resource.d.ts.map +1 -0
- package/dist/providers/transaction-request/create-transaction-request.d.ts +73 -0
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/errors.d.ts +25 -0
- package/dist/providers/transaction-request/errors.d.ts.map +1 -0
- package/dist/providers/transaction-request/hash-transaction.d.ts +9 -0
- package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -0
- package/dist/providers/transaction-request/index.d.ts +10 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -0
- package/dist/providers/transaction-request/input.d.ts +59 -0
- package/dist/providers/transaction-request/input.d.ts.map +1 -0
- package/dist/providers/transaction-request/output.d.ts +39 -0
- package/dist/providers/transaction-request/output.d.ts.map +1 -0
- package/dist/providers/transaction-request/script-transaction-request.d.ts +106 -0
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/scripts.d.ts +6 -0
- package/dist/providers/transaction-request/scripts.d.ts.map +1 -0
- package/dist/providers/transaction-request/storage-slot.d.ts +10 -0
- package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -0
- package/dist/providers/transaction-request/transaction-request.d.ts +259 -0
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/types.d.ts +10 -0
- package/dist/providers/transaction-request/types.d.ts.map +1 -0
- package/dist/providers/transaction-request/utils.d.ts +4 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -0
- package/dist/providers/transaction-request/witness.d.ts +5 -0
- package/dist/providers/transaction-request/witness.d.ts.map +1 -0
- package/dist/providers/transaction-response/getDecodedLogs.d.ts +5 -0
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -0
- package/dist/providers/transaction-response/index.d.ts +3 -0
- package/dist/providers/transaction-response/index.d.ts.map +1 -0
- package/dist/providers/transaction-response/transaction-response.d.ts +106 -0
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +20 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -0
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +21 -0
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -0
- package/dist/providers/transaction-summary/call.d.ts +18 -0
- package/dist/providers/transaction-summary/call.d.ts.map +1 -0
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts +31 -0
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -0
- package/dist/providers/transaction-summary/index.d.ts +10 -0
- package/dist/providers/transaction-summary/index.d.ts.map +1 -0
- package/dist/providers/transaction-summary/input.d.ts +21 -0
- package/dist/providers/transaction-summary/input.d.ts.map +1 -0
- package/dist/providers/transaction-summary/operations.d.ts +40 -0
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -0
- package/dist/providers/transaction-summary/output.d.ts +15 -0
- package/dist/providers/transaction-summary/output.d.ts.map +1 -0
- package/dist/providers/transaction-summary/receipt.d.ts +7 -0
- package/dist/providers/transaction-summary/receipt.d.ts.map +1 -0
- package/dist/providers/transaction-summary/status.d.ts +9 -0
- package/dist/providers/transaction-summary/status.d.ts.map +1 -0
- package/dist/providers/transaction-summary/types.d.ts +146 -0
- package/dist/providers/transaction-summary/types.d.ts.map +1 -0
- package/dist/providers/utils/auto-retry-fetch.d.ts +36 -0
- package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -0
- package/dist/providers/utils/block-explorer.d.ts +14 -0
- package/dist/providers/utils/block-explorer.d.ts.map +1 -0
- package/dist/providers/utils/gas.d.ts +38 -0
- package/dist/providers/utils/gas.d.ts.map +1 -0
- package/dist/providers/utils/index.d.ts +5 -0
- package/dist/providers/utils/index.d.ts.map +1 -0
- package/dist/providers/utils/json.d.ts +7 -0
- package/dist/providers/utils/json.d.ts.map +1 -0
- package/dist/providers/utils/merge-quantities.d.ts +3 -0
- package/dist/providers/utils/merge-quantities.d.ts.map +1 -0
- package/dist/providers/utils/receipts.d.ts +10 -0
- package/dist/providers/utils/receipts.d.ts.map +1 -0
- package/dist/signer/index.d.ts +2 -0
- package/dist/signer/index.d.ts.map +1 -0
- package/dist/signer/signer.d.ts +64 -0
- package/dist/signer/signer.d.ts.map +1 -0
- package/dist/test-utils/asset-id.d.ts +9 -0
- package/dist/test-utils/asset-id.d.ts.map +1 -0
- package/dist/test-utils/generateTestWallet.d.ts +4 -0
- package/dist/test-utils/generateTestWallet.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +8 -0
- package/dist/test-utils/index.d.ts.map +1 -0
- package/dist/{test-utils.d.ts → test-utils/launchNode.d.ts} +19 -24
- package/dist/test-utils/launchNode.d.ts.map +1 -0
- package/dist/test-utils/seedTestWallet.d.ts +4 -0
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -0
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts +33 -0
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -0
- package/dist/test-utils/test-message.d.ts +28 -0
- package/dist/test-utils/test-message.d.ts.map +1 -0
- package/dist/test-utils/wallet-config.d.ts +49 -0
- package/dist/test-utils/wallet-config.d.ts.map +1 -0
- package/dist/test-utils.global.js +655 -310
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +452 -217
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +357 -124
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +14 -0
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -0
- package/dist/wallet/base-wallet-unlocked.d.ts +73 -0
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -0
- package/dist/wallet/index.d.ts +4 -0
- package/dist/wallet/index.d.ts.map +1 -0
- package/dist/wallet/keystore-wallet.d.ts +38 -0
- package/dist/wallet/keystore-wallet.d.ts.map +1 -0
- package/dist/wallet/wallet.d.ts +68 -0
- package/dist/wallet/wallet.d.ts.map +1 -0
- package/dist/wallet/wallets.d.ts +76 -0
- package/dist/wallet/wallets.d.ts.map +1 -0
- package/dist/wallet-manager/index.d.ts +6 -0
- package/dist/wallet-manager/index.d.ts.map +1 -0
- package/dist/wallet-manager/storages/memory-storage.d.ts +9 -0
- package/dist/wallet-manager/storages/memory-storage.d.ts.map +1 -0
- package/dist/wallet-manager/types.d.ts +42 -0
- package/dist/wallet-manager/types.d.ts.map +1 -0
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +29 -0
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -0
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts +29 -0
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -0
- package/dist/wallet-manager/wallet-manager.d.ts +104 -0
- package/dist/wallet-manager/wallet-manager.d.ts.map +1 -0
- package/dist/wordlists/index.d.ts +5 -0
- package/dist/wordlists/index.d.ts.map +1 -0
- package/dist/wordlists/words/english.d.ts +2 -0
- package/dist/wordlists/words/english.d.ts.map +1 -0
- package/package.json +26 -21
- package/dist/account-E9nGNf5X.d.mts +0 -3837
- package/dist/account-E9nGNf5X.d.ts +0 -3837
- package/dist/configs.d.mts +0 -3
- package/dist/index.d.mts +0 -904
- package/dist/test-utils.d.mts +0 -66
package/dist/test-utils.js
CHANGED
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
9
|
var __export = (target, all) => {
|
9
10
|
for (var name in all)
|
10
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -26,21 +27,42 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
26
27
|
mod
|
27
28
|
));
|
28
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
30
|
+
var __publicField = (obj, key, value) => {
|
31
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
32
|
+
return value;
|
33
|
+
};
|
34
|
+
var __accessCheck = (obj, member, msg) => {
|
35
|
+
if (!member.has(obj))
|
36
|
+
throw TypeError("Cannot " + msg);
|
37
|
+
};
|
38
|
+
var __privateAdd = (obj, member, value) => {
|
39
|
+
if (member.has(obj))
|
40
|
+
throw TypeError("Cannot add the same private member more than once");
|
41
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
42
|
+
};
|
43
|
+
var __privateMethod = (obj, member, method) => {
|
44
|
+
__accessCheck(obj, member, "access private method");
|
45
|
+
return method;
|
46
|
+
};
|
29
47
|
|
30
48
|
// src/test-utils/index.ts
|
31
49
|
var test_utils_exports = {};
|
32
50
|
__export(test_utils_exports, {
|
51
|
+
AssetId: () => AssetId,
|
52
|
+
TestMessage: () => TestMessage,
|
53
|
+
WalletConfig: () => WalletConfig,
|
33
54
|
generateTestWallet: () => generateTestWallet,
|
34
55
|
killNode: () => killNode,
|
35
56
|
launchNode: () => launchNode,
|
36
57
|
launchNodeAndGetWallets: () => launchNodeAndGetWallets,
|
37
|
-
seedTestWallet: () => seedTestWallet
|
58
|
+
seedTestWallet: () => seedTestWallet,
|
59
|
+
setupTestProviderAndWallets: () => setupTestProviderAndWallets
|
38
60
|
});
|
39
61
|
module.exports = __toCommonJS(test_utils_exports);
|
40
62
|
|
41
63
|
// src/wallet/base-wallet-unlocked.ts
|
42
64
|
var import_hasher3 = require("@fuel-ts/hasher");
|
43
|
-
var
|
65
|
+
var import_utils31 = require("@fuel-ts/utils");
|
44
66
|
|
45
67
|
// src/account.ts
|
46
68
|
var import_address4 = require("@fuel-ts/address");
|
@@ -48,7 +70,7 @@ var import_configs11 = require("@fuel-ts/address/configs");
|
|
48
70
|
var import_errors15 = require("@fuel-ts/errors");
|
49
71
|
var import_interfaces = require("@fuel-ts/interfaces");
|
50
72
|
var import_math17 = require("@fuel-ts/math");
|
51
|
-
var
|
73
|
+
var import_utils28 = require("@fuel-ts/utils");
|
52
74
|
|
53
75
|
// src/providers/coin-quantity.ts
|
54
76
|
var import_configs = require("@fuel-ts/address/configs");
|
@@ -91,9 +113,9 @@ var import_address3 = require("@fuel-ts/address");
|
|
91
113
|
var import_errors13 = require("@fuel-ts/errors");
|
92
114
|
var import_math14 = require("@fuel-ts/math");
|
93
115
|
var import_transactions17 = require("@fuel-ts/transactions");
|
94
|
-
var
|
116
|
+
var import_utils23 = require("@fuel-ts/utils");
|
95
117
|
var import_versions = require("@fuel-ts/versions");
|
96
|
-
var
|
118
|
+
var import_utils24 = require("@noble/curves/abstract/utils");
|
97
119
|
var import_ethers = require("ethers");
|
98
120
|
var import_graphql_request = require("graphql-request");
|
99
121
|
var import_ramda3 = require("ramda");
|
@@ -906,12 +928,11 @@ function getSdk(requester) {
|
|
906
928
|
// src/providers/fuel-graphql-subscriber.ts
|
907
929
|
var import_errors = require("@fuel-ts/errors");
|
908
930
|
var import_graphql = require("graphql");
|
909
|
-
var
|
931
|
+
var _FuelGraphqlSubscriber = class {
|
910
932
|
constructor(options) {
|
911
933
|
this.options = options;
|
912
934
|
}
|
913
935
|
stream;
|
914
|
-
static textDecoder = new TextDecoder();
|
915
936
|
async setStream() {
|
916
937
|
const { url, query, variables, fetchFn } = this.options;
|
917
938
|
const response = await fetchFn(`${url}-sub`, {
|
@@ -971,6 +992,8 @@ var FuelGraphqlSubscriber = class _FuelGraphqlSubscriber {
|
|
971
992
|
return this;
|
972
993
|
}
|
973
994
|
};
|
995
|
+
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
996
|
+
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
974
997
|
|
975
998
|
// src/providers/memory-cache.ts
|
976
999
|
var import_errors2 = require("@fuel-ts/errors");
|
@@ -1489,15 +1512,6 @@ function normalizeJSON(root) {
|
|
1489
1512
|
return normalize((0, import_ramda.clone)(root));
|
1490
1513
|
}
|
1491
1514
|
|
1492
|
-
// src/providers/utils/sleep.ts
|
1493
|
-
function sleep(time) {
|
1494
|
-
return new Promise((resolve) => {
|
1495
|
-
setTimeout(() => {
|
1496
|
-
resolve(true);
|
1497
|
-
}, time);
|
1498
|
-
});
|
1499
|
-
}
|
1500
|
-
|
1501
1515
|
// src/providers/transaction-request/errors.ts
|
1502
1516
|
var NoWitnessAtIndexError = class extends Error {
|
1503
1517
|
constructor(index) {
|
@@ -1519,7 +1533,7 @@ var witnessify = (value) => {
|
|
1519
1533
|
};
|
1520
1534
|
|
1521
1535
|
// src/providers/transaction-request/transaction-request.ts
|
1522
|
-
var BaseTransactionRequest = class
|
1536
|
+
var BaseTransactionRequest = class {
|
1523
1537
|
/** Gas price for transaction */
|
1524
1538
|
gasPrice;
|
1525
1539
|
/** Block until which tx cannot be included */
|
@@ -1589,7 +1603,7 @@ var BaseTransactionRequest = class _BaseTransactionRequest {
|
|
1589
1603
|
const inputs = this.inputs?.map(inputify) ?? [];
|
1590
1604
|
const outputs = this.outputs?.map(outputify) ?? [];
|
1591
1605
|
const witnesses = this.witnesses?.map(witnessify) ?? [];
|
1592
|
-
const { policyTypes, policies } =
|
1606
|
+
const { policyTypes, policies } = BaseTransactionRequest.getPolicyMeta(this);
|
1593
1607
|
return {
|
1594
1608
|
policyTypes,
|
1595
1609
|
inputs,
|
@@ -3127,7 +3141,7 @@ function assembleTransactionSummary(params) {
|
|
3127
3141
|
}
|
3128
3142
|
|
3129
3143
|
// src/providers/transaction-response/transaction-response.ts
|
3130
|
-
var TransactionResponse = class
|
3144
|
+
var TransactionResponse = class {
|
3131
3145
|
/** Transaction ID */
|
3132
3146
|
id;
|
3133
3147
|
/** Current provider */
|
@@ -3155,7 +3169,7 @@ var TransactionResponse = class _TransactionResponse {
|
|
3155
3169
|
* @param provider - The provider.
|
3156
3170
|
*/
|
3157
3171
|
static async create(id, provider) {
|
3158
|
-
const response = new
|
3172
|
+
const response = new TransactionResponse(id, provider);
|
3159
3173
|
await response.fetch();
|
3160
3174
|
return response;
|
3161
3175
|
}
|
@@ -3283,6 +3297,7 @@ var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
|
3283
3297
|
var import_transactions16 = require("@fuel-ts/transactions");
|
3284
3298
|
|
3285
3299
|
// src/providers/utils/auto-retry-fetch.ts
|
3300
|
+
var import_utils22 = require("@fuel-ts/utils");
|
3286
3301
|
function getWaitDelay(options, retryAttemptNum) {
|
3287
3302
|
const duration = options.baseDelay ?? 150;
|
3288
3303
|
switch (options.backoff) {
|
@@ -3312,7 +3327,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3312
3327
|
throw error;
|
3313
3328
|
}
|
3314
3329
|
const delay = getWaitDelay(options, retryNum);
|
3315
|
-
await sleep(delay);
|
3330
|
+
await (0, import_utils22.sleep)(delay);
|
3316
3331
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3317
3332
|
}
|
3318
3333
|
};
|
@@ -3370,7 +3385,8 @@ var processGqlChain = (chain) => {
|
|
3370
3385
|
}
|
3371
3386
|
};
|
3372
3387
|
};
|
3373
|
-
var
|
3388
|
+
var _cacheInputs, cacheInputs_fn;
|
3389
|
+
var _Provider = class {
|
3374
3390
|
/**
|
3375
3391
|
* Constructor to initialize a Provider.
|
3376
3392
|
*
|
@@ -3381,25 +3397,27 @@ var Provider = class _Provider {
|
|
3381
3397
|
*/
|
3382
3398
|
constructor(url, options = {}) {
|
3383
3399
|
this.url = url;
|
3400
|
+
/**
|
3401
|
+
* @hidden
|
3402
|
+
*/
|
3403
|
+
__privateAdd(this, _cacheInputs);
|
3404
|
+
__publicField(this, "operations");
|
3405
|
+
__publicField(this, "cache");
|
3406
|
+
__publicField(this, "options", {
|
3407
|
+
timeout: void 0,
|
3408
|
+
cacheUtxo: void 0,
|
3409
|
+
fetch: void 0,
|
3410
|
+
retryOptions: void 0
|
3411
|
+
});
|
3384
3412
|
this.options = { ...this.options, ...options };
|
3385
3413
|
this.url = url;
|
3386
3414
|
this.operations = this.createOperations();
|
3387
3415
|
this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
|
3388
3416
|
}
|
3389
|
-
operations;
|
3390
|
-
cache;
|
3391
3417
|
static clearChainAndNodeCaches() {
|
3392
3418
|
_Provider.nodeInfoCache = {};
|
3393
3419
|
_Provider.chainInfoCache = {};
|
3394
3420
|
}
|
3395
|
-
static chainInfoCache = {};
|
3396
|
-
static nodeInfoCache = {};
|
3397
|
-
options = {
|
3398
|
-
timeout: void 0,
|
3399
|
-
cacheUtxo: void 0,
|
3400
|
-
fetch: void 0,
|
3401
|
-
retryOptions: void 0
|
3402
|
-
};
|
3403
3421
|
static getFetchFn(options) {
|
3404
3422
|
const { retryOptions, timeout } = options;
|
3405
3423
|
return autoRetryFetch(async (...args) => {
|
@@ -3596,19 +3614,6 @@ var Provider = class _Provider {
|
|
3596
3614
|
} = this.getChain();
|
3597
3615
|
return chainId.toNumber();
|
3598
3616
|
}
|
3599
|
-
/**
|
3600
|
-
* @hidden
|
3601
|
-
*/
|
3602
|
-
#cacheInputs(inputs) {
|
3603
|
-
if (!this.cache) {
|
3604
|
-
return;
|
3605
|
-
}
|
3606
|
-
inputs.forEach((input) => {
|
3607
|
-
if (input.type === import_transactions17.InputType.Coin) {
|
3608
|
-
this.cache?.set(input.id);
|
3609
|
-
}
|
3610
|
-
});
|
3611
|
-
}
|
3612
3617
|
/**
|
3613
3618
|
* Submits a transaction to the chain to be executed.
|
3614
3619
|
*
|
@@ -3621,11 +3626,11 @@ var Provider = class _Provider {
|
|
3621
3626
|
// #region Provider-sendTransaction
|
3622
3627
|
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution = false } = {}) {
|
3623
3628
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
3624
|
-
this
|
3629
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs);
|
3625
3630
|
if (estimateTxDependencies) {
|
3626
3631
|
await this.estimateTxDependencies(transactionRequest);
|
3627
3632
|
}
|
3628
|
-
const encodedTransaction = (0,
|
3633
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3629
3634
|
if (awaitExecution) {
|
3630
3635
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3631
3636
|
for await (const { submitAndAwait } of subscription) {
|
@@ -3664,7 +3669,7 @@ var Provider = class _Provider {
|
|
3664
3669
|
if (estimateTxDependencies) {
|
3665
3670
|
return this.estimateTxDependencies(transactionRequest);
|
3666
3671
|
}
|
3667
|
-
const encodedTransaction = (0,
|
3672
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3668
3673
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3669
3674
|
encodedTransaction,
|
3670
3675
|
utxoValidation: utxoValidation || false
|
@@ -3683,13 +3688,13 @@ var Provider = class _Provider {
|
|
3683
3688
|
async estimatePredicates(transactionRequest) {
|
3684
3689
|
const shouldEstimatePredicates = Boolean(
|
3685
3690
|
transactionRequest.inputs.find(
|
3686
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
3691
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
|
3687
3692
|
)
|
3688
3693
|
);
|
3689
3694
|
if (!shouldEstimatePredicates) {
|
3690
3695
|
return transactionRequest;
|
3691
3696
|
}
|
3692
|
-
const encodedTransaction = (0,
|
3697
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3693
3698
|
const response = await this.operations.estimatePredicates({
|
3694
3699
|
encodedTransaction
|
3695
3700
|
});
|
@@ -3732,7 +3737,7 @@ var Provider = class _Provider {
|
|
3732
3737
|
let outputVariables = 0;
|
3733
3738
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
3734
3739
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3735
|
-
encodedTransaction: (0,
|
3740
|
+
encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
|
3736
3741
|
utxoValidation: false
|
3737
3742
|
});
|
3738
3743
|
receipts = gqlReceipts.map(processGqlReceipt);
|
@@ -3770,7 +3775,7 @@ var Provider = class _Provider {
|
|
3770
3775
|
if (estimateTxDependencies) {
|
3771
3776
|
return this.estimateTxDependencies(transactionRequest);
|
3772
3777
|
}
|
3773
|
-
const encodedTransaction = (0,
|
3778
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3774
3779
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3775
3780
|
encodedTransaction,
|
3776
3781
|
utxoValidation: true
|
@@ -3880,7 +3885,7 @@ var Provider = class _Provider {
|
|
3880
3885
|
const result = await this.operations.getCoins({
|
3881
3886
|
first: 10,
|
3882
3887
|
...paginationArgs,
|
3883
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
3888
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
3884
3889
|
});
|
3885
3890
|
const coins = result.coins.edges.map((edge) => edge.node);
|
3886
3891
|
return coins.map((coin) => ({
|
@@ -3904,19 +3909,19 @@ var Provider = class _Provider {
|
|
3904
3909
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
3905
3910
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
3906
3911
|
const excludeInput = {
|
3907
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
3908
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
3912
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
|
3913
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
|
3909
3914
|
};
|
3910
3915
|
if (this.cache) {
|
3911
3916
|
const uniqueUtxos = new Set(
|
3912
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
3917
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
|
3913
3918
|
);
|
3914
3919
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
3915
3920
|
}
|
3916
3921
|
const coinsQuery = {
|
3917
3922
|
owner: ownerAddress.toB256(),
|
3918
3923
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
3919
|
-
assetId: (0,
|
3924
|
+
assetId: (0, import_utils23.hexlify)(assetId),
|
3920
3925
|
amount: amount.toString(10),
|
3921
3926
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
3922
3927
|
})),
|
@@ -4019,7 +4024,7 @@ var Provider = class _Provider {
|
|
4019
4024
|
time: block.header.time,
|
4020
4025
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4021
4026
|
transactions: block.transactions.map(
|
4022
|
-
(tx) => new import_transactions17.TransactionCoder().decode((0,
|
4027
|
+
(tx) => new import_transactions17.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
|
4023
4028
|
)
|
4024
4029
|
};
|
4025
4030
|
}
|
@@ -4035,7 +4040,7 @@ var Provider = class _Provider {
|
|
4035
4040
|
return null;
|
4036
4041
|
}
|
4037
4042
|
return new import_transactions17.TransactionCoder().decode(
|
4038
|
-
(0,
|
4043
|
+
(0, import_utils23.arrayify)(transaction.rawPayload),
|
4039
4044
|
0
|
4040
4045
|
)?.[0];
|
4041
4046
|
}
|
@@ -4062,7 +4067,7 @@ var Provider = class _Provider {
|
|
4062
4067
|
async getContractBalance(contractId, assetId) {
|
4063
4068
|
const { contractBalance } = await this.operations.getContractBalance({
|
4064
4069
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4065
|
-
asset: (0,
|
4070
|
+
asset: (0, import_utils23.hexlify)(assetId)
|
4066
4071
|
});
|
4067
4072
|
return (0, import_math14.bn)(contractBalance.amount, 10);
|
4068
4073
|
}
|
@@ -4076,7 +4081,7 @@ var Provider = class _Provider {
|
|
4076
4081
|
async getBalance(owner, assetId) {
|
4077
4082
|
const { balance } = await this.operations.getBalance({
|
4078
4083
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4079
|
-
assetId: (0,
|
4084
|
+
assetId: (0, import_utils23.hexlify)(assetId)
|
4080
4085
|
});
|
4081
4086
|
return (0, import_math14.bn)(balance.amount, 10);
|
4082
4087
|
}
|
@@ -4237,7 +4242,7 @@ var Provider = class _Provider {
|
|
4237
4242
|
async produceBlocks(amount, startTime) {
|
4238
4243
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4239
4244
|
blocksToProduce: (0, import_math14.bn)(amount).toString(10),
|
4240
|
-
startTimestamp: startTime ?
|
4245
|
+
startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4241
4246
|
});
|
4242
4247
|
return (0, import_math14.bn)(latestBlockHeight);
|
4243
4248
|
}
|
@@ -4246,12 +4251,26 @@ var Provider = class _Provider {
|
|
4246
4251
|
return new TransactionResponse(transactionId, this);
|
4247
4252
|
}
|
4248
4253
|
};
|
4254
|
+
var Provider = _Provider;
|
4255
|
+
_cacheInputs = new WeakSet();
|
4256
|
+
cacheInputs_fn = function(inputs) {
|
4257
|
+
if (!this.cache) {
|
4258
|
+
return;
|
4259
|
+
}
|
4260
|
+
inputs.forEach((input) => {
|
4261
|
+
if (input.type === import_transactions17.InputType.Coin) {
|
4262
|
+
this.cache?.set(input.id);
|
4263
|
+
}
|
4264
|
+
});
|
4265
|
+
};
|
4266
|
+
__publicField(Provider, "chainInfoCache", {});
|
4267
|
+
__publicField(Provider, "nodeInfoCache", {});
|
4249
4268
|
|
4250
4269
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4251
4270
|
var import_errors14 = require("@fuel-ts/errors");
|
4252
4271
|
var import_math15 = require("@fuel-ts/math");
|
4253
4272
|
var import_transactions18 = require("@fuel-ts/transactions");
|
4254
|
-
var
|
4273
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4255
4274
|
|
4256
4275
|
// src/providers/chains.ts
|
4257
4276
|
var CHAIN_IDS = {
|
@@ -4301,16 +4320,16 @@ var assets = [
|
|
4301
4320
|
// src/utils/formatTransferToContractScriptData.ts
|
4302
4321
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
4303
4322
|
var import_math16 = require("@fuel-ts/math");
|
4304
|
-
var
|
4323
|
+
var import_utils27 = require("@fuel-ts/utils");
|
4305
4324
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4306
4325
|
var formatTransferToContractScriptData = (params) => {
|
4307
4326
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4308
4327
|
const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
|
4309
4328
|
const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
|
4310
4329
|
const scriptData = Uint8Array.from([
|
4311
|
-
...(0,
|
4330
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
4312
4331
|
...encoded,
|
4313
|
-
...(0,
|
4332
|
+
...(0, import_utils27.arrayify)(assetId)
|
4314
4333
|
]);
|
4315
4334
|
return scriptData;
|
4316
4335
|
};
|
@@ -4650,14 +4669,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4650
4669
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
4651
4670
|
const { minGasPrice } = this.provider.getGasConfig();
|
4652
4671
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
4653
|
-
const recipientDataArray = (0,
|
4672
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
4654
4673
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
4655
4674
|
);
|
4656
|
-
const amountDataArray = (0,
|
4675
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
4657
4676
|
"0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
4658
4677
|
);
|
4659
4678
|
const script = new Uint8Array([
|
4660
|
-
...(0,
|
4679
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
4661
4680
|
...recipientDataArray,
|
4662
4681
|
...amountDataArray
|
4663
4682
|
]);
|
@@ -4744,9 +4763,9 @@ var import_address5 = require("@fuel-ts/address");
|
|
4744
4763
|
var import_crypto = require("@fuel-ts/crypto");
|
4745
4764
|
var import_hasher2 = require("@fuel-ts/hasher");
|
4746
4765
|
var import_math18 = require("@fuel-ts/math");
|
4747
|
-
var
|
4766
|
+
var import_utils29 = require("@fuel-ts/utils");
|
4748
4767
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
4749
|
-
var Signer = class
|
4768
|
+
var Signer = class {
|
4750
4769
|
address;
|
4751
4770
|
publicKey;
|
4752
4771
|
compressedPublicKey;
|
@@ -4764,9 +4783,9 @@ var Signer = class _Signer {
|
|
4764
4783
|
}
|
4765
4784
|
}
|
4766
4785
|
const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
|
4767
|
-
this.privateKey = (0,
|
4768
|
-
this.publicKey = (0,
|
4769
|
-
this.compressedPublicKey = (0,
|
4786
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
4787
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
4788
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
4770
4789
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
4771
4790
|
}
|
4772
4791
|
/**
|
@@ -4780,11 +4799,11 @@ var Signer = class _Signer {
|
|
4780
4799
|
* @returns hashed signature
|
4781
4800
|
*/
|
4782
4801
|
sign(data) {
|
4783
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
4802
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
4784
4803
|
const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
4785
4804
|
const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
4786
4805
|
s[0] |= (signature.recovery || 0) << 7;
|
4787
|
-
return (0,
|
4806
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
4788
4807
|
}
|
4789
4808
|
/**
|
4790
4809
|
* Add point on the current elliptic curve
|
@@ -4793,8 +4812,8 @@ var Signer = class _Signer {
|
|
4793
4812
|
* @returns compressed point on the curve
|
4794
4813
|
*/
|
4795
4814
|
addPoint(point) {
|
4796
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4797
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4815
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
4816
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
4798
4817
|
const result = p0.add(p1);
|
4799
4818
|
return `0x${result.toHex(true)}`;
|
4800
4819
|
}
|
@@ -4806,16 +4825,16 @@ var Signer = class _Signer {
|
|
4806
4825
|
* @returns public key from signature from the
|
4807
4826
|
*/
|
4808
4827
|
static recoverPublicKey(data, signature) {
|
4809
|
-
const signedMessageBytes = (0,
|
4828
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
4810
4829
|
const r = signedMessageBytes.slice(0, 32);
|
4811
4830
|
const s = signedMessageBytes.slice(32, 64);
|
4812
4831
|
const recoveryParam = (s[0] & 128) >> 7;
|
4813
4832
|
s[0] &= 127;
|
4814
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
4833
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
4815
4834
|
recoveryParam
|
4816
4835
|
);
|
4817
|
-
const publicKey = sig.recoverPublicKey((0,
|
4818
|
-
return (0,
|
4836
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
4837
|
+
return (0, import_utils29.hexlify)(publicKey);
|
4819
4838
|
}
|
4820
4839
|
/**
|
4821
4840
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -4825,7 +4844,7 @@ var Signer = class _Signer {
|
|
4825
4844
|
* @returns Address from signature
|
4826
4845
|
*/
|
4827
4846
|
static recoverAddress(data, signature) {
|
4828
|
-
return import_address5.Address.fromPublicKey(
|
4847
|
+
return import_address5.Address.fromPublicKey(Signer.recoverPublicKey(data, signature));
|
4829
4848
|
}
|
4830
4849
|
/**
|
4831
4850
|
* Generate a random privateKey
|
@@ -4834,7 +4853,7 @@ var Signer = class _Signer {
|
|
4834
4853
|
* @returns random 32-byte hashed
|
4835
4854
|
*/
|
4836
4855
|
static generatePrivateKey(entropy) {
|
4837
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
4856
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
|
4838
4857
|
}
|
4839
4858
|
/**
|
4840
4859
|
* Extended publicKey from a compact publicKey
|
@@ -4843,8 +4862,8 @@ var Signer = class _Signer {
|
|
4843
4862
|
* @returns extended publicKey
|
4844
4863
|
*/
|
4845
4864
|
static extendPublicKey(publicKey) {
|
4846
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
4847
|
-
return (0,
|
4865
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
4866
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
4848
4867
|
}
|
4849
4868
|
};
|
4850
4869
|
|
@@ -4852,7 +4871,7 @@ var Signer = class _Signer {
|
|
4852
4871
|
var import_address6 = require("@fuel-ts/address");
|
4853
4872
|
var import_crypto2 = require("@fuel-ts/crypto");
|
4854
4873
|
var import_errors16 = require("@fuel-ts/errors");
|
4855
|
-
var
|
4874
|
+
var import_utils30 = require("@fuel-ts/utils");
|
4856
4875
|
var import_uuid = require("uuid");
|
4857
4876
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
4858
4877
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -4935,16 +4954,12 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
4935
4954
|
);
|
4936
4955
|
}
|
4937
4956
|
const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
4938
|
-
const privateKey = (0,
|
4957
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
4939
4958
|
return privateKey;
|
4940
4959
|
}
|
4941
4960
|
|
4942
4961
|
// src/wallet/base-wallet-unlocked.ts
|
4943
4962
|
var BaseWalletUnlocked = class extends Account {
|
4944
|
-
/**
|
4945
|
-
* Default HDWallet path.
|
4946
|
-
*/
|
4947
|
-
static defaultPath = "m/44'/1179993420'/0'/0/0";
|
4948
4963
|
/**
|
4949
4964
|
* A function that returns the wallet's signer.
|
4950
4965
|
*/
|
@@ -4984,7 +4999,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
4984
4999
|
*/
|
4985
5000
|
async signMessage(message) {
|
4986
5001
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
4987
|
-
return (0,
|
5002
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
4988
5003
|
}
|
4989
5004
|
/**
|
4990
5005
|
* Signs a transaction with the wallet's private key.
|
@@ -4997,7 +5012,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
4997
5012
|
const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
|
4998
5013
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
4999
5014
|
const signature = await this.signer().sign(hashedTransaction);
|
5000
|
-
return (0,
|
5015
|
+
return (0, import_utils31.hexlify)(signature);
|
5001
5016
|
}
|
5002
5017
|
/**
|
5003
5018
|
* Populates a transaction with the witnesses signature.
|
@@ -5050,19 +5065,23 @@ var BaseWalletUnlocked = class extends Account {
|
|
5050
5065
|
return encryptKeystoreWallet(this.privateKey, this.address, password);
|
5051
5066
|
}
|
5052
5067
|
};
|
5068
|
+
/**
|
5069
|
+
* Default HDWallet path.
|
5070
|
+
*/
|
5071
|
+
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5053
5072
|
|
5054
5073
|
// src/hdwallet/hdwallet.ts
|
5055
5074
|
var import_errors19 = require("@fuel-ts/errors");
|
5056
5075
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5057
5076
|
var import_math19 = require("@fuel-ts/math");
|
5058
|
-
var
|
5077
|
+
var import_utils35 = require("@fuel-ts/utils");
|
5059
5078
|
var import_ethers3 = require("ethers");
|
5060
5079
|
|
5061
5080
|
// src/mnemonic/mnemonic.ts
|
5062
5081
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5063
5082
|
var import_errors18 = require("@fuel-ts/errors");
|
5064
5083
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5065
|
-
var
|
5084
|
+
var import_utils33 = require("@fuel-ts/utils");
|
5066
5085
|
var import_ethers2 = require("ethers");
|
5067
5086
|
|
5068
5087
|
// src/wordlists/words/english.ts
|
@@ -7120,7 +7139,7 @@ var english = [
|
|
7120
7139
|
// src/mnemonic/utils.ts
|
7121
7140
|
var import_errors17 = require("@fuel-ts/errors");
|
7122
7141
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7123
|
-
var
|
7142
|
+
var import_utils32 = require("@fuel-ts/utils");
|
7124
7143
|
function toUtf8Bytes(stri) {
|
7125
7144
|
const str = stri.normalize("NFKD");
|
7126
7145
|
const result = [];
|
@@ -7187,14 +7206,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7187
7206
|
}
|
7188
7207
|
}
|
7189
7208
|
const checksumBits = entropy.length / 4;
|
7190
|
-
const checksum = (0,
|
7209
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7191
7210
|
indices[indices.length - 1] <<= checksumBits;
|
7192
7211
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7193
7212
|
return indices;
|
7194
7213
|
}
|
7195
7214
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7196
7215
|
const size = Math.ceil(11 * words.length / 8);
|
7197
|
-
const entropy = (0,
|
7216
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
7198
7217
|
let offset = 0;
|
7199
7218
|
for (let i = 0; i < words.length; i += 1) {
|
7200
7219
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7214,7 +7233,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7214
7233
|
const entropyBits = 32 * words.length / 3;
|
7215
7234
|
const checksumBits = words.length / 3;
|
7216
7235
|
const checksumMask = getUpperMask(checksumBits);
|
7217
|
-
const checksum = (0,
|
7236
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7218
7237
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7219
7238
|
throw new import_errors17.FuelError(
|
7220
7239
|
import_errors17.ErrorCode.INVALID_CHECKSUM,
|
@@ -7253,7 +7272,7 @@ function assertMnemonic(words) {
|
|
7253
7272
|
throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
7254
7273
|
}
|
7255
7274
|
}
|
7256
|
-
var Mnemonic = class
|
7275
|
+
var Mnemonic = class {
|
7257
7276
|
wordlist;
|
7258
7277
|
/**
|
7259
7278
|
*
|
@@ -7270,7 +7289,7 @@ var Mnemonic = class _Mnemonic {
|
|
7270
7289
|
* @returns Entropy hash
|
7271
7290
|
*/
|
7272
7291
|
mnemonicToEntropy(phrase) {
|
7273
|
-
return
|
7292
|
+
return Mnemonic.mnemonicToEntropy(phrase, this.wordlist);
|
7274
7293
|
}
|
7275
7294
|
/**
|
7276
7295
|
*
|
@@ -7278,7 +7297,7 @@ var Mnemonic = class _Mnemonic {
|
|
7278
7297
|
* @returns Mnemonic phrase
|
7279
7298
|
*/
|
7280
7299
|
entropyToMnemonic(entropy) {
|
7281
|
-
return
|
7300
|
+
return Mnemonic.entropyToMnemonic(entropy, this.wordlist);
|
7282
7301
|
}
|
7283
7302
|
/**
|
7284
7303
|
*
|
@@ -7289,7 +7308,7 @@ var Mnemonic = class _Mnemonic {
|
|
7289
7308
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7290
7309
|
const words = getWords(phrase);
|
7291
7310
|
assertMnemonic(words);
|
7292
|
-
return (0,
|
7311
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7293
7312
|
}
|
7294
7313
|
/**
|
7295
7314
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7297,7 +7316,7 @@ var Mnemonic = class _Mnemonic {
|
|
7297
7316
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7298
7317
|
*/
|
7299
7318
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7300
|
-
const entropyBytes = (0,
|
7319
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
7301
7320
|
assertWordList(wordlist);
|
7302
7321
|
assertEntropy(entropyBytes);
|
7303
7322
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7319,8 +7338,8 @@ var Mnemonic = class _Mnemonic {
|
|
7319
7338
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7320
7339
|
*/
|
7321
7340
|
static mnemonicToMasterKeys(phrase, passphrase = "") {
|
7322
|
-
const seed =
|
7323
|
-
return
|
7341
|
+
const seed = Mnemonic.mnemonicToSeed(phrase, passphrase);
|
7342
|
+
return Mnemonic.masterKeysFromSeed(seed);
|
7324
7343
|
}
|
7325
7344
|
/**
|
7326
7345
|
* Validates if given mnemonic is valid
|
@@ -7336,7 +7355,7 @@ var Mnemonic = class _Mnemonic {
|
|
7336
7355
|
return false;
|
7337
7356
|
}
|
7338
7357
|
while (i < words.length) {
|
7339
|
-
if (
|
7358
|
+
if (Mnemonic.binarySearch(words[i]) === false) {
|
7340
7359
|
return false;
|
7341
7360
|
}
|
7342
7361
|
i += 1;
|
@@ -7366,14 +7385,14 @@ var Mnemonic = class _Mnemonic {
|
|
7366
7385
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7367
7386
|
*/
|
7368
7387
|
static masterKeysFromSeed(seed) {
|
7369
|
-
const seedArray = (0,
|
7388
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
7370
7389
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7371
7390
|
throw new import_errors18.FuelError(
|
7372
7391
|
import_errors18.ErrorCode.INVALID_SEED,
|
7373
7392
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7374
7393
|
);
|
7375
7394
|
}
|
7376
|
-
return (0,
|
7395
|
+
return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
|
7377
7396
|
}
|
7378
7397
|
/**
|
7379
7398
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7383,23 +7402,23 @@ var Mnemonic = class _Mnemonic {
|
|
7383
7402
|
* @returns BIP-32 extended private key
|
7384
7403
|
*/
|
7385
7404
|
static seedToExtendedKey(seed, testnet = false) {
|
7386
|
-
const masterKey =
|
7387
|
-
const prefix = (0,
|
7405
|
+
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7406
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7388
7407
|
const depth = "0x00";
|
7389
7408
|
const fingerprint = "0x00000000";
|
7390
7409
|
const index = "0x00000000";
|
7391
7410
|
const chainCode = masterKey.slice(32);
|
7392
7411
|
const privateKey = masterKey.slice(0, 32);
|
7393
|
-
const extendedKey = (0,
|
7412
|
+
const extendedKey = (0, import_utils33.concat)([
|
7394
7413
|
prefix,
|
7395
7414
|
depth,
|
7396
7415
|
fingerprint,
|
7397
7416
|
index,
|
7398
7417
|
chainCode,
|
7399
|
-
(0,
|
7418
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
7400
7419
|
]);
|
7401
7420
|
const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7402
|
-
return (0, import_ethers2.encodeBase58)((0,
|
7421
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
7403
7422
|
}
|
7404
7423
|
/**
|
7405
7424
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7414,20 +7433,20 @@ var Mnemonic = class _Mnemonic {
|
|
7414
7433
|
* @returns A randomly generated mnemonic
|
7415
7434
|
*/
|
7416
7435
|
static generate(size = 32, extraEntropy = "") {
|
7417
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
7418
|
-
return
|
7436
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7437
|
+
return Mnemonic.entropyToMnemonic(entropy);
|
7419
7438
|
}
|
7420
7439
|
};
|
7421
7440
|
var mnemonic_default = Mnemonic;
|
7422
7441
|
|
7423
7442
|
// src/hdwallet/hdwallet.ts
|
7424
7443
|
var HARDENED_INDEX = 2147483648;
|
7425
|
-
var MainnetPRV2 = (0,
|
7426
|
-
var MainnetPUB = (0,
|
7427
|
-
var TestnetPRV2 = (0,
|
7428
|
-
var TestnetPUB = (0,
|
7444
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
7445
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
7446
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
7447
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
7429
7448
|
function base58check(data) {
|
7430
|
-
return (0, import_ethers3.encodeBase58)((0,
|
7449
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7431
7450
|
}
|
7432
7451
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7433
7452
|
if (isPublic) {
|
@@ -7436,11 +7455,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7436
7455
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7437
7456
|
}
|
7438
7457
|
function isPublicExtendedKey(extendedKey) {
|
7439
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
7458
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
7440
7459
|
}
|
7441
7460
|
function isValidExtendedKey(extendedKey) {
|
7442
7461
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7443
|
-
(0,
|
7462
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
7444
7463
|
);
|
7445
7464
|
}
|
7446
7465
|
function parsePath(path2, depth = 0) {
|
@@ -7455,11 +7474,11 @@ function parsePath(path2, depth = 0) {
|
|
7455
7474
|
(p) => ~p.indexOf(`'`) ? parseInt(p, 10) + HARDENED_INDEX : parseInt(p, 10)
|
7456
7475
|
);
|
7457
7476
|
}
|
7458
|
-
var HDWallet = class
|
7477
|
+
var HDWallet = class {
|
7459
7478
|
depth = 0;
|
7460
7479
|
index = 0;
|
7461
|
-
fingerprint = (0,
|
7462
|
-
parentFingerprint = (0,
|
7480
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
7481
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
7463
7482
|
privateKey;
|
7464
7483
|
publicKey;
|
7465
7484
|
chainCode;
|
@@ -7471,8 +7490,8 @@ var HDWallet = class _HDWallet {
|
|
7471
7490
|
constructor(config) {
|
7472
7491
|
if (config.privateKey) {
|
7473
7492
|
const signer = new Signer(config.privateKey);
|
7474
|
-
this.publicKey = (0,
|
7475
|
-
this.privateKey = (0,
|
7493
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
7494
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
7476
7495
|
} else {
|
7477
7496
|
if (!config.publicKey) {
|
7478
7497
|
throw new import_errors19.FuelError(
|
@@ -7480,7 +7499,7 @@ var HDWallet = class _HDWallet {
|
|
7480
7499
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7481
7500
|
);
|
7482
7501
|
}
|
7483
|
-
this.publicKey = (0,
|
7502
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
7484
7503
|
}
|
7485
7504
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
7486
7505
|
this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
@@ -7499,9 +7518,9 @@ var HDWallet = class _HDWallet {
|
|
7499
7518
|
* @returns A new instance of HDWallet on the derived index
|
7500
7519
|
*/
|
7501
7520
|
deriveIndex(index) {
|
7502
|
-
const privateKey = this.privateKey && (0,
|
7503
|
-
const publicKey = (0,
|
7504
|
-
const chainCode = (0,
|
7521
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
7522
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
7523
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
7505
7524
|
const data = new Uint8Array(37);
|
7506
7525
|
if (index & HARDENED_INDEX) {
|
7507
7526
|
if (!privateKey) {
|
@@ -7512,16 +7531,16 @@ var HDWallet = class _HDWallet {
|
|
7512
7531
|
}
|
7513
7532
|
data.set(privateKey, 1);
|
7514
7533
|
} else {
|
7515
|
-
data.set((0,
|
7534
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
7516
7535
|
}
|
7517
7536
|
data.set((0, import_math19.toBytes)(index, 4), 33);
|
7518
|
-
const bytes = (0,
|
7537
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
|
7519
7538
|
const IL = bytes.slice(0, 32);
|
7520
7539
|
const IR = bytes.slice(32);
|
7521
7540
|
if (privateKey) {
|
7522
7541
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7523
7542
|
const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
7524
|
-
return new
|
7543
|
+
return new HDWallet({
|
7525
7544
|
privateKey: ki,
|
7526
7545
|
chainCode: IR,
|
7527
7546
|
index,
|
@@ -7529,9 +7548,9 @@ var HDWallet = class _HDWallet {
|
|
7529
7548
|
parentFingerprint: this.fingerprint
|
7530
7549
|
});
|
7531
7550
|
}
|
7532
|
-
const signer = new Signer((0,
|
7551
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
7533
7552
|
const Ki = signer.addPoint(publicKey);
|
7534
|
-
return new
|
7553
|
+
return new HDWallet({
|
7535
7554
|
publicKey: Ki,
|
7536
7555
|
chainCode: IR,
|
7537
7556
|
index,
|
@@ -7564,12 +7583,12 @@ var HDWallet = class _HDWallet {
|
|
7564
7583
|
);
|
7565
7584
|
}
|
7566
7585
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
7567
|
-
const depth = (0,
|
7586
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
7568
7587
|
const parentFingerprint = this.parentFingerprint;
|
7569
7588
|
const index = (0, import_math19.toHex)(this.index, 4);
|
7570
7589
|
const chainCode = this.chainCode;
|
7571
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
7572
|
-
const extendedKey = (0,
|
7590
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
7591
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
7573
7592
|
return base58check(extendedKey);
|
7574
7593
|
}
|
7575
7594
|
/**
|
@@ -7580,14 +7599,14 @@ var HDWallet = class _HDWallet {
|
|
7580
7599
|
*/
|
7581
7600
|
static fromSeed(seed) {
|
7582
7601
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
7583
|
-
return new
|
7584
|
-
chainCode: (0,
|
7585
|
-
privateKey: (0,
|
7602
|
+
return new HDWallet({
|
7603
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
7604
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
7586
7605
|
});
|
7587
7606
|
}
|
7588
7607
|
static fromExtendedKey(extendedKey) {
|
7589
7608
|
const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
|
7590
|
-
const bytes = (0,
|
7609
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
7591
7610
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
7592
7611
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
7593
7612
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -7596,9 +7615,9 @@ var HDWallet = class _HDWallet {
|
|
7596
7615
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
7597
7616
|
}
|
7598
7617
|
const depth = bytes[4];
|
7599
|
-
const parentFingerprint = (0,
|
7600
|
-
const index = parseInt((0,
|
7601
|
-
const chainCode = (0,
|
7618
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
7619
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
7620
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
7602
7621
|
const key = bytes.slice(45, 78);
|
7603
7622
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
7604
7623
|
throw new import_errors19.FuelError(
|
@@ -7610,7 +7629,7 @@ var HDWallet = class _HDWallet {
|
|
7610
7629
|
if (key[0] !== 3) {
|
7611
7630
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
7612
7631
|
}
|
7613
|
-
return new
|
7632
|
+
return new HDWallet({
|
7614
7633
|
publicKey: key,
|
7615
7634
|
chainCode,
|
7616
7635
|
index,
|
@@ -7621,7 +7640,7 @@ var HDWallet = class _HDWallet {
|
|
7621
7640
|
if (key[0] !== 0) {
|
7622
7641
|
throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
7623
7642
|
}
|
7624
|
-
return new
|
7643
|
+
return new HDWallet({
|
7625
7644
|
privateKey: key.slice(1),
|
7626
7645
|
chainCode,
|
7627
7646
|
index,
|
@@ -7644,7 +7663,7 @@ var WalletLocked = class extends Account {
|
|
7644
7663
|
return new WalletUnlocked(privateKey, this._provider);
|
7645
7664
|
}
|
7646
7665
|
};
|
7647
|
-
var WalletUnlocked = class
|
7666
|
+
var WalletUnlocked = class extends BaseWalletUnlocked {
|
7648
7667
|
/**
|
7649
7668
|
* Locks the wallet and returns an instance of WalletLocked.
|
7650
7669
|
*
|
@@ -7662,7 +7681,7 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
|
7662
7681
|
*/
|
7663
7682
|
static generate(generateOptions) {
|
7664
7683
|
const privateKey = Signer.generatePrivateKey(generateOptions?.entropy);
|
7665
|
-
return new
|
7684
|
+
return new WalletUnlocked(privateKey, generateOptions?.provider);
|
7666
7685
|
}
|
7667
7686
|
/**
|
7668
7687
|
* Create a Wallet Unlocked from a seed.
|
@@ -7674,8 +7693,8 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
|
7674
7693
|
*/
|
7675
7694
|
static fromSeed(seed, path2, provider) {
|
7676
7695
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
7677
|
-
const childWallet = hdWallet.derivePath(path2 ||
|
7678
|
-
return new
|
7696
|
+
const childWallet = hdWallet.derivePath(path2 || WalletUnlocked.defaultPath);
|
7697
|
+
return new WalletUnlocked(childWallet.privateKey, provider);
|
7679
7698
|
}
|
7680
7699
|
/**
|
7681
7700
|
* Create a Wallet Unlocked from a mnemonic phrase.
|
@@ -7689,8 +7708,8 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
|
7689
7708
|
static fromMnemonic(mnemonic, path2, passphrase, provider) {
|
7690
7709
|
const seed = mnemonic_default.mnemonicToSeed(mnemonic, passphrase);
|
7691
7710
|
const hdWallet = hdwallet_default.fromSeed(seed);
|
7692
|
-
const childWallet = hdWallet.derivePath(path2 ||
|
7693
|
-
return new
|
7711
|
+
const childWallet = hdWallet.derivePath(path2 || WalletUnlocked.defaultPath);
|
7712
|
+
return new WalletUnlocked(childWallet.privateKey, provider);
|
7694
7713
|
}
|
7695
7714
|
/**
|
7696
7715
|
* Create a Wallet Unlocked from an extended key.
|
@@ -7701,7 +7720,7 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
|
7701
7720
|
*/
|
7702
7721
|
static fromExtendedKey(extendedKey, provider) {
|
7703
7722
|
const hdWallet = hdwallet_default.fromExtendedKey(extendedKey);
|
7704
|
-
return new
|
7723
|
+
return new WalletUnlocked(hdWallet.privateKey, provider);
|
7705
7724
|
}
|
7706
7725
|
/**
|
7707
7726
|
* Create a Wallet Unlocked from an encrypted JSON.
|
@@ -7713,7 +7732,7 @@ var WalletUnlocked = class _WalletUnlocked extends BaseWalletUnlocked {
|
|
7713
7732
|
*/
|
7714
7733
|
static async fromEncryptedJson(jsonWallet, password, provider) {
|
7715
7734
|
const privateKey = await decryptKeystoreWallet(jsonWallet, password);
|
7716
|
-
return new
|
7735
|
+
return new WalletUnlocked(privateKey, provider);
|
7717
7736
|
}
|
7718
7737
|
};
|
7719
7738
|
|
@@ -7739,50 +7758,50 @@ var Wallet = class {
|
|
7739
7758
|
static fromPrivateKey(privateKey, provider) {
|
7740
7759
|
return new WalletUnlocked(privateKey, provider);
|
7741
7760
|
}
|
7742
|
-
/**
|
7743
|
-
* Generate a new Wallet Unlocked with a random key pair.
|
7744
|
-
*
|
7745
|
-
* @param generateOptions - Options to customize the generation process (optional).
|
7746
|
-
* @returns An unlocked wallet instance.
|
7747
|
-
*/
|
7748
|
-
static generate = WalletUnlocked.generate;
|
7749
|
-
/**
|
7750
|
-
* Create a Wallet Unlocked from a seed.
|
7751
|
-
*
|
7752
|
-
* @param seed - The seed phrase.
|
7753
|
-
* @param provider - A Provider instance (optional).
|
7754
|
-
* @param path - The derivation path (optional).
|
7755
|
-
* @returns An unlocked wallet instance.
|
7756
|
-
*/
|
7757
|
-
static fromSeed = WalletUnlocked.fromSeed;
|
7758
|
-
/**
|
7759
|
-
* Create a Wallet Unlocked from a mnemonic phrase.
|
7760
|
-
*
|
7761
|
-
* @param mnemonic - The mnemonic phrase.
|
7762
|
-
* @param provider - A Provider instance (optional).
|
7763
|
-
* @param path - The derivation path (optional).
|
7764
|
-
* @param passphrase - The passphrase for the mnemonic (optional).
|
7765
|
-
* @returns An unlocked wallet instance.
|
7766
|
-
*/
|
7767
|
-
static fromMnemonic = WalletUnlocked.fromMnemonic;
|
7768
|
-
/**
|
7769
|
-
* Create a Wallet Unlocked from an extended key.
|
7770
|
-
*
|
7771
|
-
* @param extendedKey - The extended key.
|
7772
|
-
* @param provider - A Provider instance (optional).
|
7773
|
-
* @returns An unlocked wallet instance.
|
7774
|
-
*/
|
7775
|
-
static fromExtendedKey = WalletUnlocked.fromExtendedKey;
|
7776
|
-
/**
|
7777
|
-
* Create a Wallet Unlocked from an encrypted JSON.
|
7778
|
-
*
|
7779
|
-
* @param jsonWallet - The encrypted JSON keystore.
|
7780
|
-
* @param password - The password to decrypt the JSON.
|
7781
|
-
* @param provider - A Provider instance (optional).
|
7782
|
-
* @returns An unlocked wallet instance.
|
7783
|
-
*/
|
7784
|
-
static fromEncryptedJson = WalletUnlocked.fromEncryptedJson;
|
7785
7761
|
};
|
7762
|
+
/**
|
7763
|
+
* Generate a new Wallet Unlocked with a random key pair.
|
7764
|
+
*
|
7765
|
+
* @param generateOptions - Options to customize the generation process (optional).
|
7766
|
+
* @returns An unlocked wallet instance.
|
7767
|
+
*/
|
7768
|
+
__publicField(Wallet, "generate", WalletUnlocked.generate);
|
7769
|
+
/**
|
7770
|
+
* Create a Wallet Unlocked from a seed.
|
7771
|
+
*
|
7772
|
+
* @param seed - The seed phrase.
|
7773
|
+
* @param provider - A Provider instance (optional).
|
7774
|
+
* @param path - The derivation path (optional).
|
7775
|
+
* @returns An unlocked wallet instance.
|
7776
|
+
*/
|
7777
|
+
__publicField(Wallet, "fromSeed", WalletUnlocked.fromSeed);
|
7778
|
+
/**
|
7779
|
+
* Create a Wallet Unlocked from a mnemonic phrase.
|
7780
|
+
*
|
7781
|
+
* @param mnemonic - The mnemonic phrase.
|
7782
|
+
* @param provider - A Provider instance (optional).
|
7783
|
+
* @param path - The derivation path (optional).
|
7784
|
+
* @param passphrase - The passphrase for the mnemonic (optional).
|
7785
|
+
* @returns An unlocked wallet instance.
|
7786
|
+
*/
|
7787
|
+
__publicField(Wallet, "fromMnemonic", WalletUnlocked.fromMnemonic);
|
7788
|
+
/**
|
7789
|
+
* Create a Wallet Unlocked from an extended key.
|
7790
|
+
*
|
7791
|
+
* @param extendedKey - The extended key.
|
7792
|
+
* @param provider - A Provider instance (optional).
|
7793
|
+
* @returns An unlocked wallet instance.
|
7794
|
+
*/
|
7795
|
+
__publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
7796
|
+
/**
|
7797
|
+
* Create a Wallet Unlocked from an encrypted JSON.
|
7798
|
+
*
|
7799
|
+
* @param jsonWallet - The encrypted JSON keystore.
|
7800
|
+
* @param password - The password to decrypt the JSON.
|
7801
|
+
* @param provider - A Provider instance (optional).
|
7802
|
+
* @returns An unlocked wallet instance.
|
7803
|
+
*/
|
7804
|
+
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
7786
7805
|
|
7787
7806
|
// src/test-utils/seedTestWallet.ts
|
7788
7807
|
var import_crypto4 = require("@fuel-ts/crypto");
|
@@ -7814,7 +7833,7 @@ var generateTestWallet = async (provider, quantities) => {
|
|
7814
7833
|
// src/test-utils/launchNode.ts
|
7815
7834
|
var import_configs12 = require("@fuel-ts/address/configs");
|
7816
7835
|
var import_math20 = require("@fuel-ts/math");
|
7817
|
-
var
|
7836
|
+
var import_utils36 = require("@fuel-ts/utils");
|
7818
7837
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
7819
7838
|
var import_child_process = require("child_process");
|
7820
7839
|
var import_crypto5 = require("crypto");
|
@@ -7861,7 +7880,8 @@ var launchNode = async ({
|
|
7861
7880
|
useSystemFuelCore = false,
|
7862
7881
|
loggingEnabled = true,
|
7863
7882
|
debugEnabled = false,
|
7864
|
-
basePath
|
7883
|
+
basePath,
|
7884
|
+
chainConfig = import_utils36.defaultChainConfig
|
7865
7885
|
}) => (
|
7866
7886
|
// eslint-disable-next-line no-async-promise-executor
|
7867
7887
|
new Promise(async (resolve, reject) => {
|
@@ -7872,7 +7892,7 @@ var launchNode = async ({
|
|
7872
7892
|
"--poa-instant"
|
7873
7893
|
]);
|
7874
7894
|
const chainConfigPath = getFlagValueFromArgs(args, "--chain");
|
7875
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
7895
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
|
7876
7896
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
7877
7897
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
7878
7898
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
@@ -7898,17 +7918,17 @@ var launchNode = async ({
|
|
7898
7918
|
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
7899
7919
|
}
|
7900
7920
|
const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
7901
|
-
let
|
7921
|
+
let generatedChainConfig = chainConfig;
|
7902
7922
|
if (!process.env.GENESIS_SECRET) {
|
7903
7923
|
const pk = Signer.generatePrivateKey();
|
7904
7924
|
const signer = new Signer(pk);
|
7905
|
-
process.env.GENESIS_SECRET = (0,
|
7906
|
-
|
7907
|
-
...
|
7925
|
+
process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
|
7926
|
+
generatedChainConfig = {
|
7927
|
+
...generatedChainConfig,
|
7908
7928
|
initial_state: {
|
7909
|
-
...
|
7929
|
+
...generatedChainConfig.initial_state,
|
7910
7930
|
coins: [
|
7911
|
-
...
|
7931
|
+
...generatedChainConfig.initial_state.coins,
|
7912
7932
|
{
|
7913
7933
|
owner: signer.address.toHexString(),
|
7914
7934
|
amount: (0, import_math20.toHex)(1e9),
|
@@ -7918,7 +7938,7 @@ var launchNode = async ({
|
|
7918
7938
|
}
|
7919
7939
|
};
|
7920
7940
|
}
|
7921
|
-
(0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(
|
7941
|
+
(0, import_fs.writeFileSync)(tempChainConfigFilePath, JSON.stringify(generatedChainConfig), "utf8");
|
7922
7942
|
chainConfigPathToUse = tempChainConfigFilePath;
|
7923
7943
|
}
|
7924
7944
|
const child = (0, import_child_process.spawn)(
|
@@ -7956,16 +7976,21 @@ var launchNode = async ({
|
|
7956
7976
|
}
|
7957
7977
|
};
|
7958
7978
|
child.stderr.on("data", (chunk) => {
|
7959
|
-
|
7979
|
+
const text = typeof chunk === "string" ? chunk : chunk.toString();
|
7980
|
+
if (text.indexOf(graphQLStartSubstring) !== -1) {
|
7981
|
+
const rows = text.split("\n");
|
7982
|
+
const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
|
7983
|
+
const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
|
7960
7984
|
resolve({
|
7961
7985
|
cleanup: () => killNode(cleanupConfig),
|
7962
|
-
ip:
|
7963
|
-
port:
|
7986
|
+
ip: realIp,
|
7987
|
+
port: realPort,
|
7988
|
+
url: `http://${realIp}:${realPort}/graphql`,
|
7964
7989
|
chainConfigPath: chainConfigPathToUse
|
7965
7990
|
});
|
7966
7991
|
}
|
7967
|
-
if (/error/i.test(
|
7968
|
-
reject(
|
7992
|
+
if (/error/i.test(text)) {
|
7993
|
+
reject(text.toString());
|
7969
7994
|
}
|
7970
7995
|
});
|
7971
7996
|
process.on("exit", () => killNode(cleanupConfig));
|
@@ -7997,12 +8022,222 @@ var launchNodeAndGetWallets = async ({
|
|
7997
8022
|
};
|
7998
8023
|
return { wallets, stop: cleanup, provider };
|
7999
8024
|
};
|
8025
|
+
|
8026
|
+
// src/test-utils/setup-test-provider-and-wallets.ts
|
8027
|
+
var import_utils38 = require("@fuel-ts/utils");
|
8028
|
+
var import_ramda4 = require("ramda");
|
8029
|
+
|
8030
|
+
// src/test-utils/asset-id.ts
|
8031
|
+
var import_configs13 = require("@fuel-ts/address/configs");
|
8032
|
+
var import_crypto6 = require("@fuel-ts/crypto");
|
8033
|
+
var import_utils37 = require("@fuel-ts/utils");
|
8034
|
+
var _AssetId = class {
|
8035
|
+
constructor(value) {
|
8036
|
+
this.value = value;
|
8037
|
+
}
|
8038
|
+
static random() {
|
8039
|
+
return new _AssetId((0, import_utils37.hexlify)((0, import_crypto6.randomBytes)(32)));
|
8040
|
+
}
|
8041
|
+
};
|
8042
|
+
var AssetId = _AssetId;
|
8043
|
+
__publicField(AssetId, "BaseAssetId", new _AssetId(import_configs13.BaseAssetId));
|
8044
|
+
__publicField(AssetId, "A", new _AssetId(
|
8045
|
+
"0x0101010101010101010101010101010101010101010101010101010101010101"
|
8046
|
+
));
|
8047
|
+
__publicField(AssetId, "B", new _AssetId(
|
8048
|
+
"0x0202020202020202020202020202020202020202020202020202020202020202"
|
8049
|
+
));
|
8050
|
+
|
8051
|
+
// src/test-utils/wallet-config.ts
|
8052
|
+
var import_crypto7 = require("@fuel-ts/crypto");
|
8053
|
+
var import_errors20 = require("@fuel-ts/errors");
|
8054
|
+
var import_math21 = require("@fuel-ts/math");
|
8055
|
+
var WalletConfig = class {
|
8056
|
+
initialState;
|
8057
|
+
options;
|
8058
|
+
wallets;
|
8059
|
+
generateWallets = () => {
|
8060
|
+
const generatedWallets = [];
|
8061
|
+
for (let index = 1; index <= this.options.count; index++) {
|
8062
|
+
generatedWallets.push(new WalletUnlocked((0, import_crypto7.randomBytes)(32)));
|
8063
|
+
}
|
8064
|
+
return generatedWallets;
|
8065
|
+
};
|
8066
|
+
constructor(config) {
|
8067
|
+
WalletConfig.guard(config);
|
8068
|
+
this.options = config;
|
8069
|
+
const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
|
8070
|
+
this.wallets = this.generateWallets();
|
8071
|
+
this.initialState = {
|
8072
|
+
messages: WalletConfig.createMessages(this.wallets, messages),
|
8073
|
+
coins: WalletConfig.createCoins(this.wallets, assets2, coinsPerAsset, amountPerCoin)
|
8074
|
+
};
|
8075
|
+
}
|
8076
|
+
apply(chainConfig) {
|
8077
|
+
return {
|
8078
|
+
...chainConfig,
|
8079
|
+
initial_state: {
|
8080
|
+
...chainConfig?.initial_state,
|
8081
|
+
coins: this.initialState.coins.concat(chainConfig?.initial_state?.coins || []),
|
8082
|
+
messages: this.initialState.messages.concat(chainConfig?.initial_state?.messages ?? [])
|
8083
|
+
}
|
8084
|
+
};
|
8085
|
+
}
|
8086
|
+
static createMessages(wallets, messages) {
|
8087
|
+
return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
|
8088
|
+
}
|
8089
|
+
static createCoins(wallets, assets2, coinsPerAsset, amountPerCoin) {
|
8090
|
+
const coins = [];
|
8091
|
+
let assetIds = [AssetId.BaseAssetId.value];
|
8092
|
+
if (Array.isArray(assets2)) {
|
8093
|
+
assetIds = assetIds.concat(assets2.map((a) => a.value));
|
8094
|
+
} else {
|
8095
|
+
for (let index = 0; index < assets2 - 1; index++) {
|
8096
|
+
assetIds.push(AssetId.random().value);
|
8097
|
+
}
|
8098
|
+
}
|
8099
|
+
wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
|
8100
|
+
assetIds.forEach((assetId) => {
|
8101
|
+
for (let index = 0; index < coinsPerAsset; index++) {
|
8102
|
+
coins.push({
|
8103
|
+
amount: (0, import_math21.toHex)(amountPerCoin, 8),
|
8104
|
+
asset_id: assetId,
|
8105
|
+
owner: walletAddress
|
8106
|
+
});
|
8107
|
+
}
|
8108
|
+
});
|
8109
|
+
});
|
8110
|
+
return coins;
|
8111
|
+
}
|
8112
|
+
static guard({
|
8113
|
+
count: wallets,
|
8114
|
+
assets: assets2,
|
8115
|
+
coinsPerAsset,
|
8116
|
+
amountPerCoin
|
8117
|
+
}) {
|
8118
|
+
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
8119
|
+
throw new import_errors20.FuelError(
|
8120
|
+
import_errors20.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
8121
|
+
"Number of wallets must be greater than zero."
|
8122
|
+
);
|
8123
|
+
}
|
8124
|
+
if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
|
8125
|
+
throw new import_errors20.FuelError(
|
8126
|
+
import_errors20.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
8127
|
+
"Number of assets per wallet must be greater than zero."
|
8128
|
+
);
|
8129
|
+
}
|
8130
|
+
if (coinsPerAsset <= 0) {
|
8131
|
+
throw new import_errors20.FuelError(
|
8132
|
+
import_errors20.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
8133
|
+
"Number of coins per asset must be greater than zero."
|
8134
|
+
);
|
8135
|
+
}
|
8136
|
+
if (amountPerCoin <= 0) {
|
8137
|
+
throw new import_errors20.FuelError(
|
8138
|
+
import_errors20.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
8139
|
+
"Amount per coin must be greater than zero."
|
8140
|
+
);
|
8141
|
+
}
|
8142
|
+
}
|
8143
|
+
};
|
8144
|
+
|
8145
|
+
// src/test-utils/setup-test-provider-and-wallets.ts
|
8146
|
+
var defaultWalletConfigOptions = {
|
8147
|
+
count: 2,
|
8148
|
+
assets: [AssetId.A, AssetId.B],
|
8149
|
+
coinsPerAsset: 1,
|
8150
|
+
amountPerCoin: 1e10,
|
8151
|
+
messages: []
|
8152
|
+
};
|
8153
|
+
async function setupTestProviderAndWallets({
|
8154
|
+
walletConfig: walletConfigOptions = {},
|
8155
|
+
providerOptions,
|
8156
|
+
nodeOptions = {}
|
8157
|
+
} = {}) {
|
8158
|
+
Symbol.dispose ??= Symbol("Symbol.dispose");
|
8159
|
+
const walletConfig = new WalletConfig({
|
8160
|
+
...defaultWalletConfigOptions,
|
8161
|
+
...walletConfigOptions
|
8162
|
+
});
|
8163
|
+
const { cleanup, url } = await launchNode({
|
8164
|
+
...nodeOptions,
|
8165
|
+
chainConfig: (0, import_ramda4.mergeDeepRight)(import_utils38.defaultChainConfig, walletConfig.apply(nodeOptions?.chainConfig)),
|
8166
|
+
port: "0"
|
8167
|
+
});
|
8168
|
+
let provider;
|
8169
|
+
try {
|
8170
|
+
provider = await Provider.create(url, providerOptions);
|
8171
|
+
} catch (err) {
|
8172
|
+
cleanup();
|
8173
|
+
throw err;
|
8174
|
+
}
|
8175
|
+
const wallets = walletConfig.wallets;
|
8176
|
+
wallets.forEach((wallet) => {
|
8177
|
+
wallet.connect(provider);
|
8178
|
+
});
|
8179
|
+
return {
|
8180
|
+
provider,
|
8181
|
+
wallets,
|
8182
|
+
cleanup,
|
8183
|
+
[Symbol.dispose]: cleanup
|
8184
|
+
};
|
8185
|
+
}
|
8186
|
+
|
8187
|
+
// src/test-utils/test-message.ts
|
8188
|
+
var import_address7 = require("@fuel-ts/address");
|
8189
|
+
var import_crypto8 = require("@fuel-ts/crypto");
|
8190
|
+
var import_math22 = require("@fuel-ts/math");
|
8191
|
+
var import_utils39 = require("@fuel-ts/utils");
|
8192
|
+
var TestMessage = class {
|
8193
|
+
sender;
|
8194
|
+
recipient;
|
8195
|
+
nonce;
|
8196
|
+
amount;
|
8197
|
+
data;
|
8198
|
+
da_height;
|
8199
|
+
/**
|
8200
|
+
* A helper class to create messages for testing purposes.
|
8201
|
+
*
|
8202
|
+
* Used in tandem with `WalletConfig`.
|
8203
|
+
* It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
|
8204
|
+
*/
|
8205
|
+
constructor({
|
8206
|
+
sender = import_address7.Address.fromRandom(),
|
8207
|
+
recipient = import_address7.Address.fromRandom(),
|
8208
|
+
nonce = (0, import_utils39.hexlify)((0, import_crypto8.randomBytes)(32)),
|
8209
|
+
amount = 1e6,
|
8210
|
+
data = "02",
|
8211
|
+
da_height = "0x00"
|
8212
|
+
} = {}) {
|
8213
|
+
this.sender = sender;
|
8214
|
+
this.recipient = recipient;
|
8215
|
+
this.nonce = nonce;
|
8216
|
+
this.amount = amount;
|
8217
|
+
this.data = data;
|
8218
|
+
this.da_height = da_height;
|
8219
|
+
}
|
8220
|
+
toChainMessage(recipient) {
|
8221
|
+
return {
|
8222
|
+
sender: this.sender.toB256(),
|
8223
|
+
recipient: recipient?.toB256() ?? this.recipient.toB256(),
|
8224
|
+
nonce: this.nonce,
|
8225
|
+
amount: new import_math22.BN(this.amount).toHex(8),
|
8226
|
+
data: this.data,
|
8227
|
+
da_height: this.da_height
|
8228
|
+
};
|
8229
|
+
}
|
8230
|
+
};
|
8000
8231
|
// Annotate the CommonJS export names for ESM import in node:
|
8001
8232
|
0 && (module.exports = {
|
8233
|
+
AssetId,
|
8234
|
+
TestMessage,
|
8235
|
+
WalletConfig,
|
8002
8236
|
generateTestWallet,
|
8003
8237
|
killNode,
|
8004
8238
|
launchNode,
|
8005
8239
|
launchNodeAndGetWallets,
|
8006
|
-
seedTestWallet
|
8240
|
+
seedTestWallet,
|
8241
|
+
setupTestProviderAndWallets
|
8007
8242
|
});
|
8008
8243
|
//# sourceMappingURL=test-utils.js.map
|