@fuel-ts/account 0.0.0-rc-1356-20240520140225 → 0.0.0-rc-2143-20240520152005
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/index.global.js +9 -7
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +125 -115
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -1
- package/dist/index.mjs.map +1 -1
- package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/providers/utils/sleep.d.ts +3 -0
- package/dist/providers/utils/sleep.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +0 -4
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +3 -10
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +122 -465
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +169 -407
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +67 -301
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -16
- package/dist/test-utils/asset-id.d.ts +0 -8
- package/dist/test-utils/asset-id.d.ts.map +0 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts +0 -33
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +0 -1
- package/dist/test-utils/test-message.d.ts +0 -29
- package/dist/test-utils/test-message.d.ts.map +0 -1
- package/dist/test-utils/wallet-config.d.ts +0 -55
- package/dist/test-utils/wallet-config.d.ts.map +0 -1
package/dist/test-utils.js
CHANGED
@@ -48,28 +48,24 @@ var __privateMethod = (obj, member, method) => {
|
|
48
48
|
// src/test-utils/index.ts
|
49
49
|
var test_utils_exports = {};
|
50
50
|
__export(test_utils_exports, {
|
51
|
-
AssetId: () => AssetId,
|
52
|
-
TestMessage: () => TestMessage,
|
53
|
-
WalletConfig: () => WalletConfig,
|
54
51
|
generateTestWallet: () => generateTestWallet,
|
55
52
|
killNode: () => killNode,
|
56
53
|
launchNode: () => launchNode,
|
57
54
|
launchNodeAndGetWallets: () => launchNodeAndGetWallets,
|
58
|
-
seedTestWallet: () => seedTestWallet
|
59
|
-
setupTestProviderAndWallets: () => setupTestProviderAndWallets
|
55
|
+
seedTestWallet: () => seedTestWallet
|
60
56
|
});
|
61
57
|
module.exports = __toCommonJS(test_utils_exports);
|
62
58
|
|
63
59
|
// src/wallet/base-wallet-unlocked.ts
|
64
60
|
var import_hasher3 = require("@fuel-ts/hasher");
|
65
|
-
var
|
61
|
+
var import_utils31 = require("@fuel-ts/utils");
|
66
62
|
|
67
63
|
// src/account.ts
|
68
64
|
var import_address4 = require("@fuel-ts/address");
|
69
65
|
var import_errors16 = require("@fuel-ts/errors");
|
70
66
|
var import_interfaces = require("@fuel-ts/interfaces");
|
71
67
|
var import_math20 = require("@fuel-ts/math");
|
72
|
-
var
|
68
|
+
var import_utils28 = require("@fuel-ts/utils");
|
73
69
|
var import_ramda4 = require("ramda");
|
74
70
|
|
75
71
|
// src/providers/coin-quantity.ts
|
@@ -112,9 +108,9 @@ var import_address3 = require("@fuel-ts/address");
|
|
112
108
|
var import_errors14 = require("@fuel-ts/errors");
|
113
109
|
var import_math17 = require("@fuel-ts/math");
|
114
110
|
var import_transactions20 = require("@fuel-ts/transactions");
|
115
|
-
var
|
111
|
+
var import_utils22 = require("@fuel-ts/utils");
|
116
112
|
var import_versions = require("@fuel-ts/versions");
|
117
|
-
var
|
113
|
+
var import_utils23 = require("@noble/curves/abstract/utils");
|
118
114
|
var import_graphql_request = require("graphql-request");
|
119
115
|
var import_ramda3 = require("ramda");
|
120
116
|
|
@@ -1673,6 +1669,15 @@ function normalizeJSON(root) {
|
|
1673
1669
|
return normalize((0, import_ramda.clone)(root));
|
1674
1670
|
}
|
1675
1671
|
|
1672
|
+
// src/providers/utils/sleep.ts
|
1673
|
+
function sleep(time) {
|
1674
|
+
return new Promise((resolve) => {
|
1675
|
+
setTimeout(() => {
|
1676
|
+
resolve(true);
|
1677
|
+
}, time);
|
1678
|
+
});
|
1679
|
+
}
|
1680
|
+
|
1676
1681
|
// src/providers/utils/extract-tx-error.ts
|
1677
1682
|
var import_errors7 = require("@fuel-ts/errors");
|
1678
1683
|
var import_math6 = require("@fuel-ts/math");
|
@@ -3613,7 +3618,6 @@ var TransactionResponse = class {
|
|
3613
3618
|
};
|
3614
3619
|
|
3615
3620
|
// src/providers/utils/auto-retry-fetch.ts
|
3616
|
-
var import_utils22 = require("@fuel-ts/utils");
|
3617
3621
|
function getWaitDelay(options, retryAttemptNum) {
|
3618
3622
|
const duration = options.baseDelay ?? 150;
|
3619
3623
|
switch (options.backoff) {
|
@@ -3643,7 +3647,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3643
3647
|
throw error;
|
3644
3648
|
}
|
3645
3649
|
const delay = getWaitDelay(options, retryNum);
|
3646
|
-
await
|
3650
|
+
await sleep(delay);
|
3647
3651
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3648
3652
|
}
|
3649
3653
|
};
|
@@ -3983,7 +3987,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3983
3987
|
if (estimateTxDependencies) {
|
3984
3988
|
await this.estimateTxDependencies(transactionRequest);
|
3985
3989
|
}
|
3986
|
-
const encodedTransaction = (0,
|
3990
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3987
3991
|
let abis;
|
3988
3992
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
3989
3993
|
abis = transactionRequest.abis;
|
@@ -4026,7 +4030,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4026
4030
|
if (estimateTxDependencies) {
|
4027
4031
|
return this.estimateTxDependencies(transactionRequest);
|
4028
4032
|
}
|
4029
|
-
const encodedTransaction = (0,
|
4033
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4030
4034
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4031
4035
|
encodedTransactions: encodedTransaction,
|
4032
4036
|
utxoValidation: utxoValidation || false
|
@@ -4044,13 +4048,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4044
4048
|
async estimatePredicates(transactionRequest) {
|
4045
4049
|
const shouldEstimatePredicates = Boolean(
|
4046
4050
|
transactionRequest.inputs.find(
|
4047
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4051
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
|
4048
4052
|
)
|
4049
4053
|
);
|
4050
4054
|
if (!shouldEstimatePredicates) {
|
4051
4055
|
return transactionRequest;
|
4052
4056
|
}
|
4053
|
-
const encodedTransaction = (0,
|
4057
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4054
4058
|
const response = await this.operations.estimatePredicates({
|
4055
4059
|
encodedTransaction
|
4056
4060
|
});
|
@@ -4092,7 +4096,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4092
4096
|
const {
|
4093
4097
|
dryRun: [{ receipts: rawReceipts, status }]
|
4094
4098
|
} = await this.operations.dryRun({
|
4095
|
-
encodedTransactions: [(0,
|
4099
|
+
encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
|
4096
4100
|
utxoValidation: false
|
4097
4101
|
});
|
4098
4102
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4142,7 +4146,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4142
4146
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4143
4147
|
allRequests.forEach((req, index) => {
|
4144
4148
|
if (req.type === import_transactions20.TransactionType.Script) {
|
4145
|
-
serializedTransactionsMap.set(index, (0,
|
4149
|
+
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4146
4150
|
}
|
4147
4151
|
});
|
4148
4152
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4178,7 +4182,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4178
4182
|
transactionRequest: request
|
4179
4183
|
});
|
4180
4184
|
request.maxFee = maxFee;
|
4181
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
4185
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
|
4182
4186
|
nextRoundTransactions.push(requestIdx);
|
4183
4187
|
}
|
4184
4188
|
}
|
@@ -4191,7 +4195,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4191
4195
|
if (estimateTxDependencies) {
|
4192
4196
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4193
4197
|
}
|
4194
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
4198
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
|
4195
4199
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4196
4200
|
encodedTransactions,
|
4197
4201
|
utxoValidation: utxoValidation || false
|
@@ -4264,7 +4268,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4264
4268
|
if (estimateTxDependencies) {
|
4265
4269
|
return this.estimateTxDependencies(transactionRequest);
|
4266
4270
|
}
|
4267
|
-
const encodedTransactions = [(0,
|
4271
|
+
const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
|
4268
4272
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4269
4273
|
encodedTransactions,
|
4270
4274
|
utxoValidation: true
|
@@ -4383,7 +4387,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4383
4387
|
const result = await this.operations.getCoins({
|
4384
4388
|
first: 10,
|
4385
4389
|
...paginationArgs,
|
4386
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4390
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4387
4391
|
});
|
4388
4392
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4389
4393
|
return coins.map((coin) => ({
|
@@ -4406,19 +4410,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4406
4410
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4407
4411
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4408
4412
|
const excludeInput = {
|
4409
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4410
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4413
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
4414
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4411
4415
|
};
|
4412
4416
|
if (this.cache) {
|
4413
4417
|
const uniqueUtxos = new Set(
|
4414
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4418
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4415
4419
|
);
|
4416
4420
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4417
4421
|
}
|
4418
4422
|
const coinsQuery = {
|
4419
4423
|
owner: ownerAddress.toB256(),
|
4420
4424
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4421
|
-
assetId: (0,
|
4425
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4422
4426
|
amount: amount.toString(10),
|
4423
4427
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4424
4428
|
})),
|
@@ -4520,7 +4524,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4520
4524
|
time: block.header.time,
|
4521
4525
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4522
4526
|
transactions: block.transactions.map(
|
4523
|
-
(tx) => new import_transactions20.TransactionCoder().decode((0,
|
4527
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4524
4528
|
)
|
4525
4529
|
};
|
4526
4530
|
}
|
@@ -4536,7 +4540,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4536
4540
|
return null;
|
4537
4541
|
}
|
4538
4542
|
return new import_transactions20.TransactionCoder().decode(
|
4539
|
-
(0,
|
4543
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4540
4544
|
0
|
4541
4545
|
)?.[0];
|
4542
4546
|
}
|
@@ -4563,7 +4567,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4563
4567
|
async getContractBalance(contractId, assetId) {
|
4564
4568
|
const { contractBalance } = await this.operations.getContractBalance({
|
4565
4569
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4566
|
-
asset: (0,
|
4570
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4567
4571
|
});
|
4568
4572
|
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4569
4573
|
}
|
@@ -4577,7 +4581,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4577
4581
|
async getBalance(owner, assetId) {
|
4578
4582
|
const { balance } = await this.operations.getBalance({
|
4579
4583
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4580
|
-
assetId: (0,
|
4584
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4581
4585
|
});
|
4582
4586
|
return (0, import_math17.bn)(balance.amount, 10);
|
4583
4587
|
}
|
@@ -4754,7 +4758,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4754
4758
|
async produceBlocks(amount, startTime) {
|
4755
4759
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4756
4760
|
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
4757
|
-
startTimestamp: startTime ?
|
4761
|
+
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4758
4762
|
});
|
4759
4763
|
return (0, import_math17.bn)(latestBlockHeight);
|
4760
4764
|
}
|
@@ -4820,7 +4824,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4820
4824
|
var import_errors15 = require("@fuel-ts/errors");
|
4821
4825
|
var import_math18 = require("@fuel-ts/math");
|
4822
4826
|
var import_transactions21 = require("@fuel-ts/transactions");
|
4823
|
-
var
|
4827
|
+
var import_utils25 = require("@fuel-ts/utils");
|
4824
4828
|
|
4825
4829
|
// src/providers/chains.ts
|
4826
4830
|
var CHAIN_IDS = {
|
@@ -4896,16 +4900,16 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
4896
4900
|
// src/utils/formatTransferToContractScriptData.ts
|
4897
4901
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4898
4902
|
var import_math19 = require("@fuel-ts/math");
|
4899
|
-
var
|
4903
|
+
var import_utils27 = require("@fuel-ts/utils");
|
4900
4904
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4901
4905
|
var formatTransferToContractScriptData = (params) => {
|
4902
4906
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4903
4907
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
4904
4908
|
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
4905
4909
|
const scriptData = Uint8Array.from([
|
4906
|
-
...(0,
|
4910
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
4907
4911
|
...encoded,
|
4908
|
-
...(0,
|
4912
|
+
...(0, import_utils27.arrayify)(assetId)
|
4909
4913
|
]);
|
4910
4914
|
return scriptData;
|
4911
4915
|
};
|
@@ -5276,14 +5280,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5276
5280
|
*/
|
5277
5281
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5278
5282
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5279
|
-
const recipientDataArray = (0,
|
5283
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5280
5284
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5281
5285
|
);
|
5282
|
-
const amountDataArray = (0,
|
5286
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5283
5287
|
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5284
5288
|
);
|
5285
5289
|
const script = new Uint8Array([
|
5286
|
-
...(0,
|
5290
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5287
5291
|
...recipientDataArray,
|
5288
5292
|
...amountDataArray
|
5289
5293
|
]);
|
@@ -5363,7 +5367,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5363
5367
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5364
5368
|
}) {
|
5365
5369
|
const request = transactionRequestify(transactionRequest);
|
5366
|
-
if (!(0,
|
5370
|
+
if (!(0, import_utils28.isDefined)(setGasLimit)) {
|
5367
5371
|
request.gasLimit = gasUsed;
|
5368
5372
|
} else if (gasUsed.gt(setGasLimit)) {
|
5369
5373
|
throw new import_errors16.FuelError(
|
@@ -5371,7 +5375,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5371
5375
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5372
5376
|
);
|
5373
5377
|
}
|
5374
|
-
if (!(0,
|
5378
|
+
if (!(0, import_utils28.isDefined)(setMaxFee)) {
|
5375
5379
|
request.maxFee = maxFee;
|
5376
5380
|
} else if (maxFee.gt(setMaxFee)) {
|
5377
5381
|
throw new import_errors16.FuelError(
|
@@ -5388,7 +5392,7 @@ var import_address5 = require("@fuel-ts/address");
|
|
5388
5392
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5389
5393
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5390
5394
|
var import_math21 = require("@fuel-ts/math");
|
5391
|
-
var
|
5395
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5392
5396
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5393
5397
|
var Signer = class {
|
5394
5398
|
address;
|
@@ -5408,9 +5412,9 @@ var Signer = class {
|
|
5408
5412
|
}
|
5409
5413
|
}
|
5410
5414
|
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
5411
|
-
this.privateKey = (0,
|
5412
|
-
this.publicKey = (0,
|
5413
|
-
this.compressedPublicKey = (0,
|
5415
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5416
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5417
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5414
5418
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5415
5419
|
}
|
5416
5420
|
/**
|
@@ -5424,11 +5428,11 @@ var Signer = class {
|
|
5424
5428
|
* @returns hashed signature
|
5425
5429
|
*/
|
5426
5430
|
sign(data) {
|
5427
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5431
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5428
5432
|
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5429
5433
|
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5430
5434
|
s[0] |= (signature.recovery || 0) << 7;
|
5431
|
-
return (0,
|
5435
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5432
5436
|
}
|
5433
5437
|
/**
|
5434
5438
|
* Add point on the current elliptic curve
|
@@ -5437,8 +5441,8 @@ var Signer = class {
|
|
5437
5441
|
* @returns compressed point on the curve
|
5438
5442
|
*/
|
5439
5443
|
addPoint(point) {
|
5440
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5441
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5444
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5445
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5442
5446
|
const result = p0.add(p1);
|
5443
5447
|
return `0x${result.toHex(true)}`;
|
5444
5448
|
}
|
@@ -5450,16 +5454,16 @@ var Signer = class {
|
|
5450
5454
|
* @returns public key from signature from the
|
5451
5455
|
*/
|
5452
5456
|
static recoverPublicKey(data, signature) {
|
5453
|
-
const signedMessageBytes = (0,
|
5457
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5454
5458
|
const r = signedMessageBytes.slice(0, 32);
|
5455
5459
|
const s = signedMessageBytes.slice(32, 64);
|
5456
5460
|
const recoveryParam = (s[0] & 128) >> 7;
|
5457
5461
|
s[0] &= 127;
|
5458
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5462
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5459
5463
|
recoveryParam
|
5460
5464
|
);
|
5461
|
-
const publicKey = sig.recoverPublicKey((0,
|
5462
|
-
return (0,
|
5465
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5466
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5463
5467
|
}
|
5464
5468
|
/**
|
5465
5469
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5478,7 +5482,7 @@ var Signer = class {
|
|
5478
5482
|
* @returns random 32-byte hashed
|
5479
5483
|
*/
|
5480
5484
|
static generatePrivateKey(entropy) {
|
5481
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5485
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
|
5482
5486
|
}
|
5483
5487
|
/**
|
5484
5488
|
* Extended publicKey from a compact publicKey
|
@@ -5487,8 +5491,8 @@ var Signer = class {
|
|
5487
5491
|
* @returns extended publicKey
|
5488
5492
|
*/
|
5489
5493
|
static extendPublicKey(publicKey) {
|
5490
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5491
|
-
return (0,
|
5494
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5495
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5492
5496
|
}
|
5493
5497
|
};
|
5494
5498
|
|
@@ -5496,7 +5500,7 @@ var Signer = class {
|
|
5496
5500
|
var import_address6 = require("@fuel-ts/address");
|
5497
5501
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5498
5502
|
var import_errors17 = require("@fuel-ts/errors");
|
5499
|
-
var
|
5503
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5500
5504
|
var import_uuid = require("uuid");
|
5501
5505
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5502
5506
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5579,7 +5583,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5579
5583
|
);
|
5580
5584
|
}
|
5581
5585
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5582
|
-
const privateKey = (0,
|
5586
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5583
5587
|
return privateKey;
|
5584
5588
|
}
|
5585
5589
|
|
@@ -5624,7 +5628,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5624
5628
|
*/
|
5625
5629
|
async signMessage(message) {
|
5626
5630
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5627
|
-
return (0,
|
5631
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
5628
5632
|
}
|
5629
5633
|
/**
|
5630
5634
|
* Signs a transaction with the wallet's private key.
|
@@ -5637,7 +5641,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5637
5641
|
const chainId = this.provider.getChainId();
|
5638
5642
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5639
5643
|
const signature = await this.signer().sign(hashedTransaction);
|
5640
|
-
return (0,
|
5644
|
+
return (0, import_utils31.hexlify)(signature);
|
5641
5645
|
}
|
5642
5646
|
/**
|
5643
5647
|
* Populates a transaction with the witnesses signature.
|
@@ -5700,13 +5704,13 @@ var import_crypto5 = require("@fuel-ts/crypto");
|
|
5700
5704
|
var import_errors20 = require("@fuel-ts/errors");
|
5701
5705
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5702
5706
|
var import_math22 = require("@fuel-ts/math");
|
5703
|
-
var
|
5707
|
+
var import_utils35 = require("@fuel-ts/utils");
|
5704
5708
|
|
5705
5709
|
// src/mnemonic/mnemonic.ts
|
5706
5710
|
var import_crypto4 = require("@fuel-ts/crypto");
|
5707
5711
|
var import_errors19 = require("@fuel-ts/errors");
|
5708
5712
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5709
|
-
var
|
5713
|
+
var import_utils33 = require("@fuel-ts/utils");
|
5710
5714
|
|
5711
5715
|
// src/wordlists/words/english.ts
|
5712
5716
|
var english = [
|
@@ -7763,7 +7767,7 @@ var english = [
|
|
7763
7767
|
// src/mnemonic/utils.ts
|
7764
7768
|
var import_errors18 = require("@fuel-ts/errors");
|
7765
7769
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7766
|
-
var
|
7770
|
+
var import_utils32 = require("@fuel-ts/utils");
|
7767
7771
|
function getLowerMask(bits) {
|
7768
7772
|
return (1 << bits) - 1;
|
7769
7773
|
}
|
@@ -7798,14 +7802,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7798
7802
|
}
|
7799
7803
|
}
|
7800
7804
|
const checksumBits = entropy.length / 4;
|
7801
|
-
const checksum = (0,
|
7805
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7802
7806
|
indices[indices.length - 1] <<= checksumBits;
|
7803
7807
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7804
7808
|
return indices;
|
7805
7809
|
}
|
7806
7810
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7807
7811
|
const size = Math.ceil(11 * words.length / 8);
|
7808
|
-
const entropy = (0,
|
7812
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
7809
7813
|
let offset = 0;
|
7810
7814
|
for (let i = 0; i < words.length; i += 1) {
|
7811
7815
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7825,7 +7829,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7825
7829
|
const entropyBits = 32 * words.length / 3;
|
7826
7830
|
const checksumBits = words.length / 3;
|
7827
7831
|
const checksumMask = getUpperMask(checksumBits);
|
7828
|
-
const checksum = (0,
|
7832
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7829
7833
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7830
7834
|
throw new import_errors18.FuelError(
|
7831
7835
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -7836,7 +7840,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7836
7840
|
}
|
7837
7841
|
|
7838
7842
|
// src/mnemonic/mnemonic.ts
|
7839
|
-
var MasterSecret = (0,
|
7843
|
+
var MasterSecret = (0, import_utils33.toUtf8Bytes)("Bitcoin seed");
|
7840
7844
|
var MainnetPRV = "0x0488ade4";
|
7841
7845
|
var TestnetPRV = "0x04358394";
|
7842
7846
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
@@ -7900,7 +7904,7 @@ var Mnemonic = class {
|
|
7900
7904
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7901
7905
|
const words = getWords(phrase);
|
7902
7906
|
assertMnemonic(words);
|
7903
|
-
return (0,
|
7907
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7904
7908
|
}
|
7905
7909
|
/**
|
7906
7910
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7908,7 +7912,7 @@ var Mnemonic = class {
|
|
7908
7912
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7909
7913
|
*/
|
7910
7914
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7911
|
-
const entropyBytes = (0,
|
7915
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
7912
7916
|
assertWordList(wordlist);
|
7913
7917
|
assertEntropy(entropyBytes);
|
7914
7918
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7920,8 +7924,8 @@ var Mnemonic = class {
|
|
7920
7924
|
*/
|
7921
7925
|
static mnemonicToSeed(phrase, passphrase = "") {
|
7922
7926
|
assertMnemonic(getWords(phrase));
|
7923
|
-
const phraseBytes = (0,
|
7924
|
-
const salt = (0,
|
7927
|
+
const phraseBytes = (0, import_utils33.toUtf8Bytes)(getPhrase(phrase));
|
7928
|
+
const salt = (0, import_utils33.toUtf8Bytes)(`mnemonic${passphrase}`);
|
7925
7929
|
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7926
7930
|
}
|
7927
7931
|
/**
|
@@ -7977,14 +7981,14 @@ var Mnemonic = class {
|
|
7977
7981
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7978
7982
|
*/
|
7979
7983
|
static masterKeysFromSeed(seed) {
|
7980
|
-
const seedArray = (0,
|
7984
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
7981
7985
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7982
7986
|
throw new import_errors19.FuelError(
|
7983
7987
|
import_errors19.ErrorCode.INVALID_SEED,
|
7984
7988
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7985
7989
|
);
|
7986
7990
|
}
|
7987
|
-
return (0,
|
7991
|
+
return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
|
7988
7992
|
}
|
7989
7993
|
/**
|
7990
7994
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7995,22 +7999,22 @@ var Mnemonic = class {
|
|
7995
7999
|
*/
|
7996
8000
|
static seedToExtendedKey(seed, testnet = false) {
|
7997
8001
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7998
|
-
const prefix = (0,
|
8002
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7999
8003
|
const depth = "0x00";
|
8000
8004
|
const fingerprint = "0x00000000";
|
8001
8005
|
const index = "0x00000000";
|
8002
8006
|
const chainCode = masterKey.slice(32);
|
8003
8007
|
const privateKey = masterKey.slice(0, 32);
|
8004
|
-
const extendedKey = (0,
|
8008
|
+
const extendedKey = (0, import_utils33.concat)([
|
8005
8009
|
prefix,
|
8006
8010
|
depth,
|
8007
8011
|
fingerprint,
|
8008
8012
|
index,
|
8009
8013
|
chainCode,
|
8010
|
-
(0,
|
8014
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
8011
8015
|
]);
|
8012
|
-
const checksum = (0,
|
8013
|
-
return (0,
|
8016
|
+
const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8017
|
+
return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
8014
8018
|
}
|
8015
8019
|
/**
|
8016
8020
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8025,7 +8029,7 @@ var Mnemonic = class {
|
|
8025
8029
|
* @returns A randomly generated mnemonic
|
8026
8030
|
*/
|
8027
8031
|
static generate(size = 32, extraEntropy = "") {
|
8028
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8032
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
|
8029
8033
|
return Mnemonic.entropyToMnemonic(entropy);
|
8030
8034
|
}
|
8031
8035
|
};
|
@@ -8033,12 +8037,12 @@ var mnemonic_default = Mnemonic;
|
|
8033
8037
|
|
8034
8038
|
// src/hdwallet/hdwallet.ts
|
8035
8039
|
var HARDENED_INDEX = 2147483648;
|
8036
|
-
var MainnetPRV2 = (0,
|
8037
|
-
var MainnetPUB = (0,
|
8038
|
-
var TestnetPRV2 = (0,
|
8039
|
-
var TestnetPUB = (0,
|
8040
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
8041
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
8042
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8043
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
8040
8044
|
function base58check(data) {
|
8041
|
-
return (0,
|
8045
|
+
return (0, import_utils35.encodeBase58)((0, import_utils35.concat)([data, (0, import_utils35.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
8042
8046
|
}
|
8043
8047
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8044
8048
|
if (isPublic) {
|
@@ -8047,11 +8051,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8047
8051
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8048
8052
|
}
|
8049
8053
|
function isPublicExtendedKey(extendedKey) {
|
8050
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8054
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
8051
8055
|
}
|
8052
8056
|
function isValidExtendedKey(extendedKey) {
|
8053
8057
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8054
|
-
(0,
|
8058
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
8055
8059
|
);
|
8056
8060
|
}
|
8057
8061
|
function parsePath(path2, depth = 0) {
|
@@ -8069,8 +8073,8 @@ function parsePath(path2, depth = 0) {
|
|
8069
8073
|
var HDWallet = class {
|
8070
8074
|
depth = 0;
|
8071
8075
|
index = 0;
|
8072
|
-
fingerprint = (0,
|
8073
|
-
parentFingerprint = (0,
|
8076
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8077
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8074
8078
|
privateKey;
|
8075
8079
|
publicKey;
|
8076
8080
|
chainCode;
|
@@ -8082,8 +8086,8 @@ var HDWallet = class {
|
|
8082
8086
|
constructor(config) {
|
8083
8087
|
if (config.privateKey) {
|
8084
8088
|
const signer = new Signer(config.privateKey);
|
8085
|
-
this.publicKey = (0,
|
8086
|
-
this.privateKey = (0,
|
8089
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
8090
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
8087
8091
|
} else {
|
8088
8092
|
if (!config.publicKey) {
|
8089
8093
|
throw new import_errors20.FuelError(
|
@@ -8091,10 +8095,10 @@ var HDWallet = class {
|
|
8091
8095
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8092
8096
|
);
|
8093
8097
|
}
|
8094
|
-
this.publicKey = (0,
|
8098
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8095
8099
|
}
|
8096
8100
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8097
|
-
this.fingerprint = (0,
|
8101
|
+
this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8098
8102
|
this.depth = config.depth || this.depth;
|
8099
8103
|
this.index = config.index || this.index;
|
8100
8104
|
this.chainCode = config.chainCode;
|
@@ -8110,9 +8114,9 @@ var HDWallet = class {
|
|
8110
8114
|
* @returns A new instance of HDWallet on the derived index
|
8111
8115
|
*/
|
8112
8116
|
deriveIndex(index) {
|
8113
|
-
const privateKey = this.privateKey && (0,
|
8114
|
-
const publicKey = (0,
|
8115
|
-
const chainCode = (0,
|
8117
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
8118
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
8119
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
8116
8120
|
const data = new Uint8Array(37);
|
8117
8121
|
if (index & HARDENED_INDEX) {
|
8118
8122
|
if (!privateKey) {
|
@@ -8123,10 +8127,10 @@ var HDWallet = class {
|
|
8123
8127
|
}
|
8124
8128
|
data.set(privateKey, 1);
|
8125
8129
|
} else {
|
8126
|
-
data.set((0,
|
8130
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8127
8131
|
}
|
8128
8132
|
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8129
|
-
const bytes = (0,
|
8133
|
+
const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8130
8134
|
const IL = bytes.slice(0, 32);
|
8131
8135
|
const IR = bytes.slice(32);
|
8132
8136
|
if (privateKey) {
|
@@ -8140,7 +8144,7 @@ var HDWallet = class {
|
|
8140
8144
|
parentFingerprint: this.fingerprint
|
8141
8145
|
});
|
8142
8146
|
}
|
8143
|
-
const signer = new Signer((0,
|
8147
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
8144
8148
|
const Ki = signer.addPoint(publicKey);
|
8145
8149
|
return new HDWallet({
|
8146
8150
|
publicKey: Ki,
|
@@ -8175,12 +8179,12 @@ var HDWallet = class {
|
|
8175
8179
|
);
|
8176
8180
|
}
|
8177
8181
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8178
|
-
const depth = (0,
|
8182
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8179
8183
|
const parentFingerprint = this.parentFingerprint;
|
8180
8184
|
const index = (0, import_math22.toHex)(this.index, 4);
|
8181
8185
|
const chainCode = this.chainCode;
|
8182
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8183
|
-
const extendedKey = (0,
|
8186
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8187
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8184
8188
|
return base58check(extendedKey);
|
8185
8189
|
}
|
8186
8190
|
/**
|
@@ -8192,13 +8196,13 @@ var HDWallet = class {
|
|
8192
8196
|
static fromSeed(seed) {
|
8193
8197
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8194
8198
|
return new HDWallet({
|
8195
|
-
chainCode: (0,
|
8196
|
-
privateKey: (0,
|
8199
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8200
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8197
8201
|
});
|
8198
8202
|
}
|
8199
8203
|
static fromExtendedKey(extendedKey) {
|
8200
|
-
const decoded = (0,
|
8201
|
-
const bytes = (0,
|
8204
|
+
const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
|
8205
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8202
8206
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8203
8207
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8204
8208
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8207,9 +8211,9 @@ var HDWallet = class {
|
|
8207
8211
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8208
8212
|
}
|
8209
8213
|
const depth = bytes[4];
|
8210
|
-
const parentFingerprint = (0,
|
8211
|
-
const index = parseInt((0,
|
8212
|
-
const chainCode = (0,
|
8214
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8215
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8216
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8213
8217
|
const key = bytes.slice(45, 78);
|
8214
8218
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8215
8219
|
throw new import_errors20.FuelError(
|
@@ -8428,8 +8432,7 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8428
8432
|
// src/test-utils/launchNode.ts
|
8429
8433
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
8430
8434
|
var import_crypto7 = require("@fuel-ts/crypto");
|
8431
|
-
var
|
8432
|
-
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
8435
|
+
var import_utils36 = require("@fuel-ts/utils");
|
8433
8436
|
var import_child_process = require("child_process");
|
8434
8437
|
var import_crypto8 = require("crypto");
|
8435
8438
|
var import_fs = require("fs");
|
@@ -8468,49 +8471,14 @@ var killNode = (params) => {
|
|
8468
8471
|
}
|
8469
8472
|
}
|
8470
8473
|
};
|
8471
|
-
function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
|
8472
|
-
const defaultCoins = import_utils37.defaultSnapshotConfigs.stateConfig.coins.map((coin) => ({
|
8473
|
-
...coin,
|
8474
|
-
amount: "18446744073709551615"
|
8475
|
-
}));
|
8476
|
-
const defaultMessages = import_utils37.defaultSnapshotConfigs.stateConfig.messages.map((message) => ({
|
8477
|
-
...message,
|
8478
|
-
amount: "18446744073709551615"
|
8479
|
-
}));
|
8480
|
-
const coins = defaultCoins.concat(stateConfig.coins.map((coin) => ({ ...coin, amount: coin.amount.toString() }))).filter((coin, index, self) => self.findIndex((c) => c.tx_id === coin.tx_id) === index);
|
8481
|
-
const messages = defaultMessages.concat(stateConfig.messages.map((msg) => ({ ...msg, amount: msg.amount.toString() }))).filter((msg, index, self) => self.findIndex((m) => m.nonce === msg.nonce) === index);
|
8482
|
-
if (!process.env.GENESIS_SECRET) {
|
8483
|
-
const pk = Signer.generatePrivateKey();
|
8484
|
-
const signer = new Signer(pk);
|
8485
|
-
process.env.GENESIS_SECRET = (0, import_utils37.hexlify)(pk);
|
8486
|
-
coins.push({
|
8487
|
-
tx_id: (0, import_utils37.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
|
8488
|
-
owner: signer.address.toHexString(),
|
8489
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8490
|
-
amount: "18446744073709551615",
|
8491
|
-
asset_id: chainConfig.consensus_parameters.V1.base_asset_id,
|
8492
|
-
output_index: 0,
|
8493
|
-
tx_pointer_block_height: 0,
|
8494
|
-
tx_pointer_tx_idx: 0
|
8495
|
-
});
|
8496
|
-
}
|
8497
|
-
const json = JSON.stringify({
|
8498
|
-
...stateConfig,
|
8499
|
-
coins,
|
8500
|
-
messages
|
8501
|
-
});
|
8502
|
-
const regexMakeNumber = /("amount":)"(\d+)"/gm;
|
8503
|
-
return json.replace(regexMakeNumber, "$1$2");
|
8504
|
-
}
|
8505
8474
|
var launchNode = async ({
|
8506
8475
|
ip,
|
8507
8476
|
port,
|
8508
8477
|
args = [],
|
8509
|
-
|
8478
|
+
fuelCorePath = process.env.FUEL_CORE_PATH ?? void 0,
|
8510
8479
|
loggingEnabled = true,
|
8511
8480
|
debugEnabled = false,
|
8512
|
-
basePath
|
8513
|
-
snapshotConfig = import_utils37.defaultSnapshotConfigs
|
8481
|
+
basePath
|
8514
8482
|
}) => (
|
8515
8483
|
// eslint-disable-next-line no-async-promise-executor
|
8516
8484
|
new Promise(async (resolve, reject) => {
|
@@ -8521,14 +8489,13 @@ var launchNode = async ({
|
|
8521
8489
|
"--poa-instant"
|
8522
8490
|
]);
|
8523
8491
|
const snapshotDir = getFlagValueFromArgs(args, "--snapshot");
|
8524
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
8492
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
|
8525
8493
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8526
8494
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
8527
8495
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
8528
8496
|
const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
|
8529
8497
|
const graphQLStartSubstring = "Binding GraphQL provider to";
|
8530
|
-
const
|
8531
|
-
const command = useSystemFuelCore ? "fuel-core" : binPath;
|
8498
|
+
const command = fuelCorePath ?? "fuel-core";
|
8532
8499
|
const ipToUse = ip || "0.0.0.0";
|
8533
8500
|
const portToUse = port || (await (0, import_portfinder.getPortPromise)({
|
8534
8501
|
port: 4e3,
|
@@ -8539,23 +8506,56 @@ var launchNode = async ({
|
|
8539
8506
|
let snapshotDirToUse;
|
8540
8507
|
const prefix = basePath || import_os.default.tmpdir();
|
8541
8508
|
const suffix = basePath ? "" : (0, import_crypto8.randomUUID)();
|
8542
|
-
const
|
8509
|
+
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "snapshotDir");
|
8543
8510
|
if (snapshotDir) {
|
8544
8511
|
snapshotDirToUse = snapshotDir;
|
8545
8512
|
} else {
|
8546
|
-
if (!(0, import_fs.existsSync)(
|
8547
|
-
(0, import_fs.mkdirSync)(
|
8513
|
+
if (!(0, import_fs.existsSync)(tempDirPath)) {
|
8514
|
+
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
8515
|
+
}
|
8516
|
+
let { stateConfigJson } = import_utils36.defaultSnapshotConfigs;
|
8517
|
+
const { chainConfigJson, metadataJson } = import_utils36.defaultSnapshotConfigs;
|
8518
|
+
stateConfigJson = {
|
8519
|
+
...stateConfigJson,
|
8520
|
+
coins: [
|
8521
|
+
...stateConfigJson.coins.map((coin) => ({
|
8522
|
+
...coin,
|
8523
|
+
amount: "18446744073709551615"
|
8524
|
+
}))
|
8525
|
+
],
|
8526
|
+
messages: stateConfigJson.messages.map((message) => ({
|
8527
|
+
...message,
|
8528
|
+
amount: "18446744073709551615"
|
8529
|
+
}))
|
8530
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8531
|
+
};
|
8532
|
+
if (!process.env.GENESIS_SECRET) {
|
8533
|
+
const pk = Signer.generatePrivateKey();
|
8534
|
+
const signer = new Signer(pk);
|
8535
|
+
process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
|
8536
|
+
stateConfigJson.coins.push({
|
8537
|
+
tx_id: (0, import_utils36.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
|
8538
|
+
owner: signer.address.toHexString(),
|
8539
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8540
|
+
amount: "18446744073709551615",
|
8541
|
+
asset_id: chainConfigJson.consensus_parameters.V1.base_asset_id,
|
8542
|
+
output_index: 0,
|
8543
|
+
tx_pointer_block_height: 0,
|
8544
|
+
tx_pointer_tx_idx: 0
|
8545
|
+
});
|
8548
8546
|
}
|
8549
|
-
|
8550
|
-
const
|
8551
|
-
|
8552
|
-
const
|
8553
|
-
const
|
8554
|
-
|
8555
|
-
|
8556
|
-
(0, import_fs.writeFileSync)(
|
8557
|
-
(0, import_fs.writeFileSync)(
|
8558
|
-
|
8547
|
+
let fixedStateConfigJSON = JSON.stringify(stateConfigJson);
|
8548
|
+
const regexMakeNumber = /("amount":)"(\d+)"/gm;
|
8549
|
+
fixedStateConfigJSON = fixedStateConfigJSON.replace(regexMakeNumber, "$1$2");
|
8550
|
+
const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
8551
|
+
const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
|
8552
|
+
const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
|
8553
|
+
const stateTransitionWritePath = import_path.default.join(tempDirPath, "state_transition_bytecode.wasm");
|
8554
|
+
(0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8555
|
+
(0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8556
|
+
(0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8557
|
+
(0, import_fs.writeFileSync)(stateTransitionWritePath, JSON.stringify(""));
|
8558
|
+
snapshotDirToUse = tempDirPath;
|
8559
8559
|
}
|
8560
8560
|
const child = (0, import_child_process.spawn)(
|
8561
8561
|
command,
|
@@ -8563,7 +8563,7 @@ var launchNode = async ({
|
|
8563
8563
|
"run",
|
8564
8564
|
["--ip", ipToUse],
|
8565
8565
|
["--port", portToUse],
|
8566
|
-
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path",
|
8566
|
+
useInMemoryDb ? ["--db-type", "in-memory"] : ["--db-path", tempDirPath],
|
8567
8567
|
["--min-gas-price", "1"],
|
8568
8568
|
poaInstant ? ["--poa-instant", "true"] : [],
|
8569
8569
|
["--consensus-key", consensusKey],
|
@@ -8585,28 +8585,23 @@ var launchNode = async ({
|
|
8585
8585
|
}
|
8586
8586
|
const cleanupConfig = {
|
8587
8587
|
child,
|
8588
|
-
configPath:
|
8588
|
+
configPath: tempDirPath,
|
8589
8589
|
killFn: import_tree_kill.default,
|
8590
8590
|
state: {
|
8591
8591
|
isDead: false
|
8592
8592
|
}
|
8593
8593
|
};
|
8594
8594
|
child.stderr.on("data", (chunk) => {
|
8595
|
-
|
8596
|
-
if (text.indexOf(graphQLStartSubstring) !== -1) {
|
8597
|
-
const rows = text.split("\n");
|
8598
|
-
const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
|
8599
|
-
const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
|
8595
|
+
if (chunk.indexOf(graphQLStartSubstring) !== -1) {
|
8600
8596
|
resolve({
|
8601
8597
|
cleanup: () => killNode(cleanupConfig),
|
8602
|
-
ip:
|
8603
|
-
port:
|
8604
|
-
url: `http://${realIp}:${realPort}/v1/graphql`,
|
8598
|
+
ip: ipToUse,
|
8599
|
+
port: portToUse,
|
8605
8600
|
snapshotDir: snapshotDirToUse
|
8606
8601
|
});
|
8607
8602
|
}
|
8608
|
-
if (/error/i.test(
|
8609
|
-
reject(
|
8603
|
+
if (/error/i.test(chunk)) {
|
8604
|
+
reject(chunk.toString());
|
8610
8605
|
}
|
8611
8606
|
});
|
8612
8607
|
process.on("exit", () => killNode(cleanupConfig));
|
@@ -8639,245 +8634,12 @@ var launchNodeAndGetWallets = async ({
|
|
8639
8634
|
};
|
8640
8635
|
return { wallets, stop: cleanup, provider };
|
8641
8636
|
};
|
8642
|
-
|
8643
|
-
// src/test-utils/setup-test-provider-and-wallets.ts
|
8644
|
-
var import_utils40 = require("@fuel-ts/utils");
|
8645
|
-
var import_ramda5 = require("ramda");
|
8646
|
-
|
8647
|
-
// src/test-utils/asset-id.ts
|
8648
|
-
var import_crypto9 = require("@fuel-ts/crypto");
|
8649
|
-
var import_utils38 = require("@fuel-ts/utils");
|
8650
|
-
var _AssetId = class {
|
8651
|
-
constructor(value) {
|
8652
|
-
this.value = value;
|
8653
|
-
}
|
8654
|
-
static random(count = 1) {
|
8655
|
-
const assetIds = [];
|
8656
|
-
for (let i = 0; i < count; i++) {
|
8657
|
-
assetIds.push(new _AssetId((0, import_utils38.hexlify)((0, import_crypto9.randomBytes)(32))));
|
8658
|
-
}
|
8659
|
-
return assetIds;
|
8660
|
-
}
|
8661
|
-
};
|
8662
|
-
var AssetId = _AssetId;
|
8663
|
-
__publicField(AssetId, "A", new _AssetId(
|
8664
|
-
"0x0101010101010101010101010101010101010101010101010101010101010101"
|
8665
|
-
));
|
8666
|
-
__publicField(AssetId, "B", new _AssetId(
|
8667
|
-
"0x0202020202020202020202020202020202020202020202020202020202020202"
|
8668
|
-
));
|
8669
|
-
|
8670
|
-
// src/test-utils/wallet-config.ts
|
8671
|
-
var import_crypto10 = require("@fuel-ts/crypto");
|
8672
|
-
var import_errors21 = require("@fuel-ts/errors");
|
8673
|
-
var import_utils39 = require("@fuel-ts/utils");
|
8674
|
-
var WalletConfig = class {
|
8675
|
-
initialState;
|
8676
|
-
options;
|
8677
|
-
wallets;
|
8678
|
-
generateWallets = () => {
|
8679
|
-
const generatedWallets = [];
|
8680
|
-
for (let index = 1; index <= this.options.count; index++) {
|
8681
|
-
generatedWallets.push(new WalletUnlocked((0, import_crypto10.randomBytes)(32)));
|
8682
|
-
}
|
8683
|
-
return generatedWallets;
|
8684
|
-
};
|
8685
|
-
constructor(baseAssetId, config) {
|
8686
|
-
WalletConfig.validate(config);
|
8687
|
-
this.options = config;
|
8688
|
-
const { assets: assets2, coinsPerAsset, amountPerCoin, messages } = this.options;
|
8689
|
-
this.wallets = this.generateWallets();
|
8690
|
-
this.initialState = {
|
8691
|
-
messages: WalletConfig.createMessages(this.wallets, messages),
|
8692
|
-
coins: WalletConfig.createCoins(
|
8693
|
-
this.wallets,
|
8694
|
-
baseAssetId,
|
8695
|
-
assets2,
|
8696
|
-
coinsPerAsset,
|
8697
|
-
amountPerCoin
|
8698
|
-
)
|
8699
|
-
};
|
8700
|
-
}
|
8701
|
-
apply(snapshotConfig) {
|
8702
|
-
return {
|
8703
|
-
...snapshotConfig,
|
8704
|
-
stateConfig: {
|
8705
|
-
...snapshotConfig?.stateConfig ?? import_utils39.defaultSnapshotConfigs.stateConfig,
|
8706
|
-
coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
|
8707
|
-
messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
|
8708
|
-
}
|
8709
|
-
};
|
8710
|
-
}
|
8711
|
-
/**
|
8712
|
-
* Create messages for the wallets in the format that the chain expects.
|
8713
|
-
*/
|
8714
|
-
static createMessages(wallets, messages) {
|
8715
|
-
return messages.map((msg) => wallets.map((wallet) => msg.toChainMessage(wallet.address))).flatMap((x) => x);
|
8716
|
-
}
|
8717
|
-
/**
|
8718
|
-
* Create coins for the wallets in the format that the chain expects.
|
8719
|
-
*/
|
8720
|
-
static createCoins(wallets, baseAssetId, assets2, coinsPerAsset, amountPerCoin) {
|
8721
|
-
const coins = [];
|
8722
|
-
let assetIds = [baseAssetId];
|
8723
|
-
if (Array.isArray(assets2)) {
|
8724
|
-
assetIds = assetIds.concat(assets2.map((a) => a.value));
|
8725
|
-
} else {
|
8726
|
-
assetIds.concat(AssetId.random(assets2).map((a) => a.value));
|
8727
|
-
}
|
8728
|
-
wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
|
8729
|
-
assetIds.forEach((assetId) => {
|
8730
|
-
for (let index = 0; index < coinsPerAsset; index++) {
|
8731
|
-
coins.push({
|
8732
|
-
amount: amountPerCoin,
|
8733
|
-
asset_id: assetId,
|
8734
|
-
owner: walletAddress,
|
8735
|
-
tx_pointer_block_height: 0,
|
8736
|
-
tx_pointer_tx_idx: 0,
|
8737
|
-
output_index: 0,
|
8738
|
-
tx_id: (0, import_utils39.hexlify)((0, import_crypto10.randomBytes)(32))
|
8739
|
-
});
|
8740
|
-
}
|
8741
|
-
});
|
8742
|
-
});
|
8743
|
-
return coins;
|
8744
|
-
}
|
8745
|
-
static validate({
|
8746
|
-
count: wallets,
|
8747
|
-
assets: assets2,
|
8748
|
-
coinsPerAsset,
|
8749
|
-
amountPerCoin
|
8750
|
-
}) {
|
8751
|
-
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
8752
|
-
throw new import_errors21.FuelError(
|
8753
|
-
import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
8754
|
-
"Number of wallets must be greater than zero."
|
8755
|
-
);
|
8756
|
-
}
|
8757
|
-
if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
|
8758
|
-
throw new import_errors21.FuelError(
|
8759
|
-
import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
8760
|
-
"Number of assets per wallet must be greater than zero."
|
8761
|
-
);
|
8762
|
-
}
|
8763
|
-
if (coinsPerAsset <= 0) {
|
8764
|
-
throw new import_errors21.FuelError(
|
8765
|
-
import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
8766
|
-
"Number of coins per asset must be greater than zero."
|
8767
|
-
);
|
8768
|
-
}
|
8769
|
-
if (amountPerCoin <= 0) {
|
8770
|
-
throw new import_errors21.FuelError(
|
8771
|
-
import_errors21.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
8772
|
-
"Amount per coin must be greater than zero."
|
8773
|
-
);
|
8774
|
-
}
|
8775
|
-
}
|
8776
|
-
};
|
8777
|
-
|
8778
|
-
// src/test-utils/setup-test-provider-and-wallets.ts
|
8779
|
-
var defaultWalletConfigOptions = {
|
8780
|
-
count: 2,
|
8781
|
-
assets: [AssetId.A, AssetId.B],
|
8782
|
-
coinsPerAsset: 1,
|
8783
|
-
amountPerCoin: 1e10,
|
8784
|
-
messages: []
|
8785
|
-
};
|
8786
|
-
async function setupTestProviderAndWallets({
|
8787
|
-
walletConfig: walletConfigOptions = {},
|
8788
|
-
providerOptions,
|
8789
|
-
nodeOptions = {}
|
8790
|
-
} = {}) {
|
8791
|
-
Symbol.dispose ??= Symbol("Symbol.dispose");
|
8792
|
-
const walletConfig = new WalletConfig(
|
8793
|
-
nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ?? import_utils40.defaultSnapshotConfigs.chainConfig.consensus_parameters.V1.base_asset_id,
|
8794
|
-
{
|
8795
|
-
...defaultWalletConfigOptions,
|
8796
|
-
...walletConfigOptions
|
8797
|
-
}
|
8798
|
-
);
|
8799
|
-
const { cleanup, url } = await launchNode({
|
8800
|
-
loggingEnabled: false,
|
8801
|
-
...nodeOptions,
|
8802
|
-
snapshotConfig: (0, import_ramda5.mergeDeepRight)(
|
8803
|
-
import_utils40.defaultSnapshotConfigs,
|
8804
|
-
walletConfig.apply(nodeOptions?.snapshotConfig)
|
8805
|
-
),
|
8806
|
-
port: "0"
|
8807
|
-
});
|
8808
|
-
let provider;
|
8809
|
-
try {
|
8810
|
-
provider = await Provider.create(url, providerOptions);
|
8811
|
-
} catch (err) {
|
8812
|
-
cleanup();
|
8813
|
-
throw err;
|
8814
|
-
}
|
8815
|
-
const wallets = walletConfig.wallets;
|
8816
|
-
wallets.forEach((wallet) => {
|
8817
|
-
wallet.connect(provider);
|
8818
|
-
});
|
8819
|
-
return {
|
8820
|
-
provider,
|
8821
|
-
wallets,
|
8822
|
-
cleanup,
|
8823
|
-
[Symbol.dispose]: cleanup
|
8824
|
-
};
|
8825
|
-
}
|
8826
|
-
|
8827
|
-
// src/test-utils/test-message.ts
|
8828
|
-
var import_address7 = require("@fuel-ts/address");
|
8829
|
-
var import_crypto11 = require("@fuel-ts/crypto");
|
8830
|
-
var import_math23 = require("@fuel-ts/math");
|
8831
|
-
var import_utils41 = require("@fuel-ts/utils");
|
8832
|
-
var TestMessage = class {
|
8833
|
-
sender;
|
8834
|
-
recipient;
|
8835
|
-
nonce;
|
8836
|
-
amount;
|
8837
|
-
data;
|
8838
|
-
da_height;
|
8839
|
-
/**
|
8840
|
-
* A helper class to create messages for testing purposes.
|
8841
|
-
*
|
8842
|
-
* Used in tandem with `WalletConfig`.
|
8843
|
-
* It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
|
8844
|
-
*/
|
8845
|
-
constructor({
|
8846
|
-
sender = import_address7.Address.fromRandom(),
|
8847
|
-
recipient = import_address7.Address.fromRandom(),
|
8848
|
-
nonce = (0, import_utils41.hexlify)((0, import_crypto11.randomBytes)(32)),
|
8849
|
-
amount = 1e6,
|
8850
|
-
data = "02",
|
8851
|
-
da_height = 0
|
8852
|
-
} = {}) {
|
8853
|
-
this.sender = sender;
|
8854
|
-
this.recipient = recipient;
|
8855
|
-
this.nonce = nonce;
|
8856
|
-
this.amount = amount;
|
8857
|
-
this.data = data;
|
8858
|
-
this.da_height = da_height;
|
8859
|
-
}
|
8860
|
-
toChainMessage(recipient) {
|
8861
|
-
return {
|
8862
|
-
sender: this.sender.toB256(),
|
8863
|
-
recipient: recipient?.toB256() ?? this.recipient.toB256(),
|
8864
|
-
nonce: this.nonce,
|
8865
|
-
amount: (0, import_math23.bn)(this.amount).toNumber(),
|
8866
|
-
data: this.data,
|
8867
|
-
da_height: this.da_height
|
8868
|
-
};
|
8869
|
-
}
|
8870
|
-
};
|
8871
8637
|
// Annotate the CommonJS export names for ESM import in node:
|
8872
8638
|
0 && (module.exports = {
|
8873
|
-
AssetId,
|
8874
|
-
TestMessage,
|
8875
|
-
WalletConfig,
|
8876
8639
|
generateTestWallet,
|
8877
8640
|
killNode,
|
8878
8641
|
launchNode,
|
8879
8642
|
launchNodeAndGetWallets,
|
8880
|
-
seedTestWallet
|
8881
|
-
setupTestProviderAndWallets
|
8643
|
+
seedTestWallet
|
8882
8644
|
});
|
8883
8645
|
//# sourceMappingURL=test-utils.js.map
|