@fuel-ts/account 0.84.0 → 0.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/account.d.ts +6 -6
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +188 -146
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +271 -224
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +188 -143
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +346 -552
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/assets.d.ts +9 -0
- package/dist/providers/assets/assets.d.ts.map +1 -0
- package/dist/providers/assets/index.d.ts +1 -2
- package/dist/providers/assets/index.d.ts.map +1 -1
- package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts +2 -0
- package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts.map +1 -0
- package/dist/providers/assets/utils/index.d.ts +1 -0
- package/dist/providers/assets/utils/index.d.ts.map +1 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +5 -9
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-summary/receipt.d.ts +2 -2
- package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +5 -13
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +2 -2
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts +2 -2
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/test-utils.global.js +210 -146
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +283 -218
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +208 -143
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/dist/test-utils.js
CHANGED
@@ -58,14 +58,14 @@ module.exports = __toCommonJS(test_utils_exports);
|
|
58
58
|
|
59
59
|
// src/wallet/base-wallet-unlocked.ts
|
60
60
|
var import_hasher3 = require("@fuel-ts/hasher");
|
61
|
-
var
|
61
|
+
var import_utils31 = require("@fuel-ts/utils");
|
62
62
|
|
63
63
|
// src/account.ts
|
64
64
|
var import_address4 = require("@fuel-ts/address");
|
65
65
|
var import_errors16 = require("@fuel-ts/errors");
|
66
66
|
var import_interfaces = require("@fuel-ts/interfaces");
|
67
67
|
var import_math21 = require("@fuel-ts/math");
|
68
|
-
var
|
68
|
+
var import_utils28 = require("@fuel-ts/utils");
|
69
69
|
var import_ramda4 = require("ramda");
|
70
70
|
|
71
71
|
// src/providers/coin-quantity.ts
|
@@ -116,7 +116,7 @@ var import_ramda3 = require("ramda");
|
|
116
116
|
|
117
117
|
// src/providers/__generated__/operations.ts
|
118
118
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
119
|
-
var
|
119
|
+
var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
|
120
120
|
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
121
121
|
type: __typename
|
122
122
|
... on SqueezedOutStatus {
|
@@ -124,7 +124,13 @@ var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.defaul
|
|
124
124
|
}
|
125
125
|
}
|
126
126
|
`;
|
127
|
-
var
|
127
|
+
var SubmittedStatusFragmentDoc = import_graphql_tag.default`
|
128
|
+
fragment SubmittedStatusFragment on SubmittedStatus {
|
129
|
+
type: __typename
|
130
|
+
time
|
131
|
+
}
|
132
|
+
`;
|
133
|
+
var ReceiptFragmentDoc = import_graphql_tag.default`
|
128
134
|
fragment receiptFragment on Receipt {
|
129
135
|
id
|
130
136
|
pc
|
@@ -156,45 +162,65 @@ var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
|
|
156
162
|
subId
|
157
163
|
}
|
158
164
|
`;
|
159
|
-
var
|
160
|
-
fragment
|
165
|
+
var SuccessStatusFragmentDoc = import_graphql_tag.default`
|
166
|
+
fragment SuccessStatusFragment on SuccessStatus {
|
161
167
|
type: __typename
|
168
|
+
block {
|
169
|
+
id
|
170
|
+
}
|
171
|
+
time
|
172
|
+
programState {
|
173
|
+
returnType
|
174
|
+
data
|
175
|
+
}
|
176
|
+
receipts {
|
177
|
+
...receiptFragment
|
178
|
+
}
|
179
|
+
totalGas
|
180
|
+
totalFee
|
181
|
+
}
|
182
|
+
${ReceiptFragmentDoc}`;
|
183
|
+
var FailureStatusFragmentDoc = import_graphql_tag.default`
|
184
|
+
fragment FailureStatusFragment on FailureStatus {
|
185
|
+
type: __typename
|
186
|
+
block {
|
187
|
+
id
|
188
|
+
}
|
189
|
+
totalGas
|
190
|
+
totalFee
|
191
|
+
time
|
192
|
+
reason
|
193
|
+
receipts {
|
194
|
+
...receiptFragment
|
195
|
+
}
|
196
|
+
}
|
197
|
+
${ReceiptFragmentDoc}`;
|
198
|
+
var SqueezedOutStatusFragmentDoc = import_graphql_tag.default`
|
199
|
+
fragment SqueezedOutStatusFragment on SqueezedOutStatus {
|
200
|
+
type: __typename
|
201
|
+
reason
|
202
|
+
}
|
203
|
+
`;
|
204
|
+
var TransactionStatusFragmentDoc = import_graphql_tag.default`
|
205
|
+
fragment transactionStatusFragment on TransactionStatus {
|
162
206
|
... on SubmittedStatus {
|
163
|
-
|
207
|
+
...SubmittedStatusFragment
|
164
208
|
}
|
165
209
|
... on SuccessStatus {
|
166
|
-
|
167
|
-
id
|
168
|
-
}
|
169
|
-
time
|
170
|
-
programState {
|
171
|
-
returnType
|
172
|
-
data
|
173
|
-
}
|
174
|
-
receipts {
|
175
|
-
...receiptFragment
|
176
|
-
}
|
177
|
-
totalGas
|
178
|
-
totalFee
|
210
|
+
...SuccessStatusFragment
|
179
211
|
}
|
180
212
|
... on FailureStatus {
|
181
|
-
|
182
|
-
id
|
183
|
-
}
|
184
|
-
totalGas
|
185
|
-
totalFee
|
186
|
-
time
|
187
|
-
reason
|
188
|
-
receipts {
|
189
|
-
...receiptFragment
|
190
|
-
}
|
213
|
+
...FailureStatusFragment
|
191
214
|
}
|
192
215
|
... on SqueezedOutStatus {
|
193
|
-
|
216
|
+
...SqueezedOutStatusFragment
|
194
217
|
}
|
195
218
|
}
|
196
|
-
${
|
197
|
-
|
219
|
+
${SubmittedStatusFragmentDoc}
|
220
|
+
${SuccessStatusFragmentDoc}
|
221
|
+
${FailureStatusFragmentDoc}
|
222
|
+
${SqueezedOutStatusFragmentDoc}`;
|
223
|
+
var TransactionFragmentDoc = import_graphql_tag.default`
|
198
224
|
fragment transactionFragment on Transaction {
|
199
225
|
id
|
200
226
|
rawPayload
|
@@ -202,8 +228,8 @@ var TransactionFragmentFragmentDoc = import_graphql_tag.default`
|
|
202
228
|
...transactionStatusFragment
|
203
229
|
}
|
204
230
|
}
|
205
|
-
${
|
206
|
-
var
|
231
|
+
${TransactionStatusFragmentDoc}`;
|
232
|
+
var InputEstimatePredicatesFragmentDoc = import_graphql_tag.default`
|
207
233
|
fragment inputEstimatePredicatesFragment on Input {
|
208
234
|
... on InputCoin {
|
209
235
|
predicateGasUsed
|
@@ -213,14 +239,14 @@ var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
|
|
213
239
|
}
|
214
240
|
}
|
215
241
|
`;
|
216
|
-
var
|
242
|
+
var TransactionEstimatePredicatesFragmentDoc = import_graphql_tag.default`
|
217
243
|
fragment transactionEstimatePredicatesFragment on Transaction {
|
218
244
|
inputs {
|
219
245
|
...inputEstimatePredicatesFragment
|
220
246
|
}
|
221
247
|
}
|
222
|
-
${
|
223
|
-
var
|
248
|
+
${InputEstimatePredicatesFragmentDoc}`;
|
249
|
+
var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
|
224
250
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
225
251
|
totalGas
|
226
252
|
totalFee
|
@@ -231,7 +257,7 @@ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
231
257
|
}
|
232
258
|
}
|
233
259
|
`;
|
234
|
-
var
|
260
|
+
var DryRunSuccessStatusFragmentDoc = import_graphql_tag.default`
|
235
261
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
236
262
|
totalGas
|
237
263
|
totalFee
|
@@ -241,7 +267,7 @@ var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
241
267
|
}
|
242
268
|
}
|
243
269
|
`;
|
244
|
-
var
|
270
|
+
var DryRunTransactionStatusFragmentDoc = import_graphql_tag.default`
|
245
271
|
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
246
272
|
... on DryRunFailureStatus {
|
247
273
|
...dryRunFailureStatusFragment
|
@@ -250,9 +276,9 @@ var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
250
276
|
...dryRunSuccessStatusFragment
|
251
277
|
}
|
252
278
|
}
|
253
|
-
${
|
254
|
-
${
|
255
|
-
var
|
279
|
+
${DryRunFailureStatusFragmentDoc}
|
280
|
+
${DryRunSuccessStatusFragmentDoc}`;
|
281
|
+
var DryRunTransactionExecutionStatusFragmentDoc = import_graphql_tag.default`
|
256
282
|
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
257
283
|
id
|
258
284
|
status {
|
@@ -262,11 +288,11 @@ var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.def
|
|
262
288
|
...receiptFragment
|
263
289
|
}
|
264
290
|
}
|
265
|
-
${
|
266
|
-
${
|
267
|
-
var
|
291
|
+
${DryRunTransactionStatusFragmentDoc}
|
292
|
+
${ReceiptFragmentDoc}`;
|
293
|
+
var CoinFragmentDoc = import_graphql_tag.default`
|
268
294
|
fragment coinFragment on Coin {
|
269
|
-
__typename
|
295
|
+
type: __typename
|
270
296
|
utxoId
|
271
297
|
owner
|
272
298
|
amount
|
@@ -275,9 +301,9 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
|
275
301
|
txCreatedIdx
|
276
302
|
}
|
277
303
|
`;
|
278
|
-
var
|
304
|
+
var MessageCoinFragmentDoc = import_graphql_tag.default`
|
279
305
|
fragment messageCoinFragment on MessageCoin {
|
280
|
-
__typename
|
306
|
+
type: __typename
|
281
307
|
sender
|
282
308
|
recipient
|
283
309
|
nonce
|
@@ -286,7 +312,7 @@ var MessageCoinFragmentFragmentDoc = import_graphql_tag.default`
|
|
286
312
|
daHeight
|
287
313
|
}
|
288
314
|
`;
|
289
|
-
var
|
315
|
+
var MessageFragmentDoc = import_graphql_tag.default`
|
290
316
|
fragment messageFragment on Message {
|
291
317
|
amount
|
292
318
|
sender
|
@@ -296,7 +322,7 @@ var MessageFragmentFragmentDoc = import_graphql_tag.default`
|
|
296
322
|
daHeight
|
297
323
|
}
|
298
324
|
`;
|
299
|
-
var
|
325
|
+
var MessageProofFragmentDoc = import_graphql_tag.default`
|
300
326
|
fragment messageProofFragment on MessageProof {
|
301
327
|
messageProof {
|
302
328
|
proofSet
|
@@ -343,14 +369,14 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
|
|
343
369
|
data
|
344
370
|
}
|
345
371
|
`;
|
346
|
-
var
|
372
|
+
var BalanceFragmentDoc = import_graphql_tag.default`
|
347
373
|
fragment balanceFragment on Balance {
|
348
374
|
owner
|
349
375
|
amount
|
350
376
|
assetId
|
351
377
|
}
|
352
378
|
`;
|
353
|
-
var
|
379
|
+
var BlockFragmentDoc = import_graphql_tag.default`
|
354
380
|
fragment blockFragment on Block {
|
355
381
|
id
|
356
382
|
height
|
@@ -362,7 +388,7 @@ var BlockFragmentFragmentDoc = import_graphql_tag.default`
|
|
362
388
|
}
|
363
389
|
}
|
364
390
|
`;
|
365
|
-
var
|
391
|
+
var TxParametersFragmentDoc = import_graphql_tag.default`
|
366
392
|
fragment TxParametersFragment on TxParameters {
|
367
393
|
version
|
368
394
|
maxInputs
|
@@ -373,7 +399,7 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
373
399
|
maxBytecodeSubsections
|
374
400
|
}
|
375
401
|
`;
|
376
|
-
var
|
402
|
+
var PredicateParametersFragmentDoc = import_graphql_tag.default`
|
377
403
|
fragment PredicateParametersFragment on PredicateParameters {
|
378
404
|
version
|
379
405
|
maxPredicateLength
|
@@ -382,41 +408,42 @@ var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
382
408
|
maxMessageDataLength
|
383
409
|
}
|
384
410
|
`;
|
385
|
-
var
|
411
|
+
var ScriptParametersFragmentDoc = import_graphql_tag.default`
|
386
412
|
fragment ScriptParametersFragment on ScriptParameters {
|
387
413
|
version
|
388
414
|
maxScriptLength
|
389
415
|
maxScriptDataLength
|
390
416
|
}
|
391
417
|
`;
|
392
|
-
var
|
418
|
+
var ContractParametersFragmentDoc = import_graphql_tag.default`
|
393
419
|
fragment ContractParametersFragment on ContractParameters {
|
394
420
|
version
|
395
421
|
contractMaxSize
|
396
422
|
maxStorageSlots
|
397
423
|
}
|
398
424
|
`;
|
399
|
-
var
|
425
|
+
var FeeParametersFragmentDoc = import_graphql_tag.default`
|
400
426
|
fragment FeeParametersFragment on FeeParameters {
|
401
427
|
version
|
402
428
|
gasPriceFactor
|
403
429
|
gasPerByte
|
404
430
|
}
|
405
431
|
`;
|
406
|
-
var
|
432
|
+
var DependentCostFragmentDoc = import_graphql_tag.default`
|
407
433
|
fragment DependentCostFragment on DependentCost {
|
408
|
-
__typename
|
409
434
|
... on LightOperation {
|
435
|
+
type: __typename
|
410
436
|
base
|
411
437
|
unitsPerGas
|
412
438
|
}
|
413
439
|
... on HeavyOperation {
|
440
|
+
type: __typename
|
414
441
|
base
|
415
442
|
gasPerUnit
|
416
443
|
}
|
417
444
|
}
|
418
445
|
`;
|
419
|
-
var
|
446
|
+
var GasCostsFragmentDoc = import_graphql_tag.default`
|
420
447
|
fragment GasCostsFragment on GasCosts {
|
421
448
|
version
|
422
449
|
add
|
@@ -572,8 +599,8 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
572
599
|
}
|
573
600
|
newStoragePerByte
|
574
601
|
}
|
575
|
-
${
|
576
|
-
var
|
602
|
+
${DependentCostFragmentDoc}`;
|
603
|
+
var ConsensusParametersFragmentDoc = import_graphql_tag.default`
|
577
604
|
fragment consensusParametersFragment on ConsensusParameters {
|
578
605
|
version
|
579
606
|
txParams {
|
@@ -597,13 +624,13 @@ var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
597
624
|
baseAssetId
|
598
625
|
chainId
|
599
626
|
}
|
600
|
-
${
|
601
|
-
${
|
602
|
-
${
|
603
|
-
${
|
604
|
-
${
|
605
|
-
${
|
606
|
-
var
|
627
|
+
${TxParametersFragmentDoc}
|
628
|
+
${PredicateParametersFragmentDoc}
|
629
|
+
${ScriptParametersFragmentDoc}
|
630
|
+
${ContractParametersFragmentDoc}
|
631
|
+
${FeeParametersFragmentDoc}
|
632
|
+
${GasCostsFragmentDoc}`;
|
633
|
+
var ChainInfoFragmentDoc = import_graphql_tag.default`
|
607
634
|
fragment chainInfoFragment on ChainInfo {
|
608
635
|
name
|
609
636
|
latestBlock {
|
@@ -614,16 +641,16 @@ var ChainInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
614
641
|
...consensusParametersFragment
|
615
642
|
}
|
616
643
|
}
|
617
|
-
${
|
618
|
-
${
|
619
|
-
var
|
644
|
+
${BlockFragmentDoc}
|
645
|
+
${ConsensusParametersFragmentDoc}`;
|
646
|
+
var ContractBalanceFragmentDoc = import_graphql_tag.default`
|
620
647
|
fragment contractBalanceFragment on ContractBalance {
|
621
648
|
contract
|
622
649
|
amount
|
623
650
|
assetId
|
624
651
|
}
|
625
652
|
`;
|
626
|
-
var
|
653
|
+
var PageInfoFragmentDoc = import_graphql_tag.default`
|
627
654
|
fragment pageInfoFragment on PageInfo {
|
628
655
|
hasPreviousPage
|
629
656
|
hasNextPage
|
@@ -631,7 +658,7 @@ var PageInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
631
658
|
endCursor
|
632
659
|
}
|
633
660
|
`;
|
634
|
-
var
|
661
|
+
var NodeInfoFragmentDoc = import_graphql_tag.default`
|
635
662
|
fragment nodeInfoFragment on NodeInfo {
|
636
663
|
utxoValidation
|
637
664
|
vmBacktrace
|
@@ -640,7 +667,7 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
640
667
|
nodeVersion
|
641
668
|
}
|
642
669
|
`;
|
643
|
-
var
|
670
|
+
var RelayedTransactionStatusFragmentDoc = import_graphql_tag.default`
|
644
671
|
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
645
672
|
... on RelayedTransactionFailed {
|
646
673
|
blockHeight
|
@@ -661,28 +688,28 @@ var GetNodeInfoDocument = import_graphql_tag.default`
|
|
661
688
|
...nodeInfoFragment
|
662
689
|
}
|
663
690
|
}
|
664
|
-
${
|
691
|
+
${NodeInfoFragmentDoc}`;
|
665
692
|
var GetChainDocument = import_graphql_tag.default`
|
666
693
|
query getChain {
|
667
694
|
chain {
|
668
695
|
...chainInfoFragment
|
669
696
|
}
|
670
697
|
}
|
671
|
-
${
|
698
|
+
${ChainInfoFragmentDoc}`;
|
672
699
|
var GetTransactionDocument = import_graphql_tag.default`
|
673
700
|
query getTransaction($transactionId: TransactionId!) {
|
674
701
|
transaction(id: $transactionId) {
|
675
702
|
...transactionFragment
|
676
703
|
}
|
677
704
|
}
|
678
|
-
${
|
705
|
+
${TransactionFragmentDoc}`;
|
679
706
|
var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
|
680
707
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
681
708
|
transaction(id: $transactionId) {
|
682
709
|
...transactionFragment
|
683
710
|
}
|
684
711
|
}
|
685
|
-
${
|
712
|
+
${TransactionFragmentDoc}`;
|
686
713
|
var GetTransactionsDocument = import_graphql_tag.default`
|
687
714
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
688
715
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -693,7 +720,7 @@ var GetTransactionsDocument = import_graphql_tag.default`
|
|
693
720
|
}
|
694
721
|
}
|
695
722
|
}
|
696
|
-
${
|
723
|
+
${TransactionFragmentDoc}`;
|
697
724
|
var GetTransactionsByOwnerDocument = import_graphql_tag.default`
|
698
725
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
699
726
|
transactionsByOwner(
|
@@ -713,22 +740,22 @@ var GetTransactionsByOwnerDocument = import_graphql_tag.default`
|
|
713
740
|
}
|
714
741
|
}
|
715
742
|
}
|
716
|
-
${
|
717
|
-
${
|
743
|
+
${PageInfoFragmentDoc}
|
744
|
+
${TransactionFragmentDoc}`;
|
718
745
|
var EstimatePredicatesDocument = import_graphql_tag.default`
|
719
746
|
query estimatePredicates($encodedTransaction: HexString!) {
|
720
747
|
estimatePredicates(tx: $encodedTransaction) {
|
721
748
|
...transactionEstimatePredicatesFragment
|
722
749
|
}
|
723
750
|
}
|
724
|
-
${
|
751
|
+
${TransactionEstimatePredicatesFragmentDoc}`;
|
725
752
|
var GetBlockDocument = import_graphql_tag.default`
|
726
753
|
query getBlock($blockId: BlockId, $height: U32) {
|
727
754
|
block(id: $blockId, height: $height) {
|
728
755
|
...blockFragment
|
729
756
|
}
|
730
757
|
}
|
731
|
-
${
|
758
|
+
${BlockFragmentDoc}`;
|
732
759
|
var GetBlockWithTransactionsDocument = import_graphql_tag.default`
|
733
760
|
query getBlockWithTransactions($blockId: BlockId, $blockHeight: U32) {
|
734
761
|
block(id: $blockId, height: $blockHeight) {
|
@@ -738,8 +765,8 @@ var GetBlockWithTransactionsDocument = import_graphql_tag.default`
|
|
738
765
|
}
|
739
766
|
}
|
740
767
|
}
|
741
|
-
${
|
742
|
-
${
|
768
|
+
${BlockFragmentDoc}
|
769
|
+
${TransactionFragmentDoc}`;
|
743
770
|
var GetBlocksDocument = import_graphql_tag.default`
|
744
771
|
query getBlocks($after: String, $before: String, $first: Int, $last: Int) {
|
745
772
|
blocks(after: $after, before: $before, first: $first, last: $last) {
|
@@ -750,14 +777,14 @@ var GetBlocksDocument = import_graphql_tag.default`
|
|
750
777
|
}
|
751
778
|
}
|
752
779
|
}
|
753
|
-
${
|
780
|
+
${BlockFragmentDoc}`;
|
754
781
|
var GetCoinDocument = import_graphql_tag.default`
|
755
782
|
query getCoin($coinId: UtxoId!) {
|
756
783
|
coin(utxoId: $coinId) {
|
757
784
|
...coinFragment
|
758
785
|
}
|
759
786
|
}
|
760
|
-
${
|
787
|
+
${CoinFragmentDoc}`;
|
761
788
|
var GetCoinsDocument = import_graphql_tag.default`
|
762
789
|
query getCoins($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
763
790
|
coins(
|
@@ -774,7 +801,7 @@ var GetCoinsDocument = import_graphql_tag.default`
|
|
774
801
|
}
|
775
802
|
}
|
776
803
|
}
|
777
|
-
${
|
804
|
+
${CoinFragmentDoc}`;
|
778
805
|
var GetCoinsToSpendDocument = import_graphql_tag.default`
|
779
806
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
780
807
|
coinsToSpend(
|
@@ -786,8 +813,8 @@ var GetCoinsToSpendDocument = import_graphql_tag.default`
|
|
786
813
|
...messageCoinFragment
|
787
814
|
}
|
788
815
|
}
|
789
|
-
${
|
790
|
-
${
|
816
|
+
${CoinFragmentDoc}
|
817
|
+
${MessageCoinFragmentDoc}`;
|
791
818
|
var GetContractDocument = import_graphql_tag.default`
|
792
819
|
query getContract($contractId: ContractId!) {
|
793
820
|
contract(id: $contractId) {
|
@@ -802,14 +829,14 @@ var GetContractBalanceDocument = import_graphql_tag.default`
|
|
802
829
|
...contractBalanceFragment
|
803
830
|
}
|
804
831
|
}
|
805
|
-
${
|
832
|
+
${ContractBalanceFragmentDoc}`;
|
806
833
|
var GetBalanceDocument = import_graphql_tag.default`
|
807
834
|
query getBalance($owner: Address!, $assetId: AssetId!) {
|
808
835
|
balance(owner: $owner, assetId: $assetId) {
|
809
836
|
...balanceFragment
|
810
837
|
}
|
811
838
|
}
|
812
|
-
${
|
839
|
+
${BalanceFragmentDoc}`;
|
813
840
|
var GetLatestGasPriceDocument = import_graphql_tag.default`
|
814
841
|
query getLatestGasPrice {
|
815
842
|
latestGasPrice {
|
@@ -840,7 +867,7 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
840
867
|
}
|
841
868
|
}
|
842
869
|
}
|
843
|
-
${
|
870
|
+
${BalanceFragmentDoc}`;
|
844
871
|
var GetMessagesDocument = import_graphql_tag.default`
|
845
872
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
846
873
|
messages(
|
@@ -857,7 +884,7 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
857
884
|
}
|
858
885
|
}
|
859
886
|
}
|
860
|
-
${
|
887
|
+
${MessageFragmentDoc}`;
|
861
888
|
var GetMessageProofDocument = import_graphql_tag.default`
|
862
889
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
863
890
|
messageProof(
|
@@ -869,7 +896,7 @@ var GetMessageProofDocument = import_graphql_tag.default`
|
|
869
896
|
...messageProofFragment
|
870
897
|
}
|
871
898
|
}
|
872
|
-
${
|
899
|
+
${MessageProofFragmentDoc}`;
|
873
900
|
var GetMessageStatusDocument = import_graphql_tag.default`
|
874
901
|
query getMessageStatus($nonce: Nonce!) {
|
875
902
|
messageStatus(nonce: $nonce) {
|
@@ -883,14 +910,14 @@ var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
|
|
883
910
|
...relayedTransactionStatusFragment
|
884
911
|
}
|
885
912
|
}
|
886
|
-
${
|
913
|
+
${RelayedTransactionStatusFragmentDoc}`;
|
887
914
|
var DryRunDocument = import_graphql_tag.default`
|
888
915
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
889
916
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
890
917
|
...dryRunTransactionExecutionStatusFragment
|
891
918
|
}
|
892
919
|
}
|
893
|
-
${
|
920
|
+
${DryRunTransactionExecutionStatusFragmentDoc}`;
|
894
921
|
var SubmitDocument = import_graphql_tag.default`
|
895
922
|
mutation submit($encodedTransaction: HexString!) {
|
896
923
|
submit(tx: $encodedTransaction) {
|
@@ -912,21 +939,21 @@ var GetMessageByNonceDocument = import_graphql_tag.default`
|
|
912
939
|
...messageFragment
|
913
940
|
}
|
914
941
|
}
|
915
|
-
${
|
942
|
+
${MessageFragmentDoc}`;
|
916
943
|
var SubmitAndAwaitDocument = import_graphql_tag.default`
|
917
944
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
918
945
|
submitAndAwait(tx: $encodedTransaction) {
|
919
946
|
...transactionStatusSubscriptionFragment
|
920
947
|
}
|
921
948
|
}
|
922
|
-
${
|
949
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
923
950
|
var StatusChangeDocument = import_graphql_tag.default`
|
924
951
|
subscription statusChange($transactionId: TransactionId!) {
|
925
952
|
statusChange(id: $transactionId) {
|
926
953
|
...transactionStatusSubscriptionFragment
|
927
954
|
}
|
928
955
|
}
|
929
|
-
${
|
956
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
930
957
|
function getSdk(requester) {
|
931
958
|
return {
|
932
959
|
getVersion(variables, options) {
|
@@ -1527,10 +1554,9 @@ var getGasUsedFromReceipts = (receipts) => {
|
|
1527
1554
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
1528
1555
|
const base = (0, import_math5.bn)(gasDependentCost.base);
|
1529
1556
|
let dependentValue = (0, import_math5.bn)(0);
|
1530
|
-
if (
|
1557
|
+
if ("unitsPerGas" in gasDependentCost) {
|
1531
1558
|
dependentValue = (0, import_math5.bn)(byteSize).div((0, import_math5.bn)(gasDependentCost.unitsPerGas));
|
1532
|
-
}
|
1533
|
-
if (gasDependentCost.__typename === "HeavyOperation") {
|
1559
|
+
} else {
|
1534
1560
|
dependentValue = (0, import_math5.bn)(byteSize).mul((0, import_math5.bn)(gasDependentCost.gasPerUnit));
|
1535
1561
|
}
|
1536
1562
|
return base.add(dependentValue);
|
@@ -3825,9 +3851,11 @@ var _Provider = class {
|
|
3825
3851
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3826
3852
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
3827
3853
|
if (!isMajorSupported || !isMinorSupported) {
|
3828
|
-
|
3829
|
-
|
3830
|
-
|
3854
|
+
console.warn(
|
3855
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
|
3856
|
+
which is not supported by the version of the TS SDK that you are using.
|
3857
|
+
Things may not work as expected.
|
3858
|
+
Supported fuel-core version: ${supportedVersion}.`
|
3831
3859
|
);
|
3832
3860
|
}
|
3833
3861
|
}
|
@@ -4264,10 +4292,10 @@ var _Provider = class {
|
|
4264
4292
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4265
4293
|
const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
|
4266
4294
|
const baseAssetId = this.getBaseAssetId();
|
4295
|
+
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4267
4296
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4268
4297
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4269
4298
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4270
|
-
txRequestClone.maxFee = (0, import_math17.bn)(0);
|
4271
4299
|
if (isScriptTransaction) {
|
4272
4300
|
txRequestClone.gasLimit = (0, import_math17.bn)(0);
|
4273
4301
|
}
|
@@ -4282,6 +4310,7 @@ var _Provider = class {
|
|
4282
4310
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4283
4311
|
}
|
4284
4312
|
await this.estimatePredicates(signedRequest);
|
4313
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4285
4314
|
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4286
4315
|
transactionRequest: signedRequest
|
4287
4316
|
});
|
@@ -4290,7 +4319,6 @@ var _Provider = class {
|
|
4290
4319
|
let missingContractIds = [];
|
4291
4320
|
let outputVariables = 0;
|
4292
4321
|
let gasUsed = (0, import_math17.bn)(0);
|
4293
|
-
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4294
4322
|
txRequestClone.maxFee = maxFee;
|
4295
4323
|
if (isScriptTransaction) {
|
4296
4324
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4318,7 +4346,8 @@ var _Provider = class {
|
|
4318
4346
|
missingContractIds,
|
4319
4347
|
addedSignatures,
|
4320
4348
|
estimatedPredicates: txRequestClone.inputs,
|
4321
|
-
dryRunStatus
|
4349
|
+
dryRunStatus,
|
4350
|
+
updateMaxFee
|
4322
4351
|
};
|
4323
4352
|
}
|
4324
4353
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4391,7 +4420,7 @@ var _Provider = class {
|
|
4391
4420
|
};
|
4392
4421
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
4393
4422
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
4394
|
-
switch (coin.
|
4423
|
+
switch (coin.type) {
|
4395
4424
|
case "MessageCoin":
|
4396
4425
|
return {
|
4397
4426
|
amount: (0, import_math17.bn)(coin.amount),
|
@@ -4783,8 +4812,33 @@ var CHAIN_IDS = {
|
|
4783
4812
|
}
|
4784
4813
|
};
|
4785
4814
|
|
4786
|
-
// src/providers/assets/
|
4787
|
-
var
|
4815
|
+
// src/providers/assets/utils/url.ts
|
4816
|
+
var DELIMITER_PATH = "/";
|
4817
|
+
var trimRegex = /^\/|\/$/g;
|
4818
|
+
var trimPath = (path2 = "") => path2.replace(trimRegex, "");
|
4819
|
+
function urlJoin(baseUrl, ...paths) {
|
4820
|
+
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
4821
|
+
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
4822
|
+
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
4823
|
+
if (rootPath && hasBaseUrl) {
|
4824
|
+
allPaths.unshift("");
|
4825
|
+
}
|
4826
|
+
return allPaths.join(DELIMITER_PATH);
|
4827
|
+
}
|
4828
|
+
|
4829
|
+
// src/providers/assets/utils/resolveIconPaths.ts
|
4830
|
+
function resolveIconPaths(assets2, basePath = "./") {
|
4831
|
+
return assets2.map((asset) => ({
|
4832
|
+
...asset,
|
4833
|
+
icon: urlJoin(basePath, asset.icon)
|
4834
|
+
}));
|
4835
|
+
}
|
4836
|
+
|
4837
|
+
// src/providers/assets/utils/fuelAssetsBaseUrl.ts
|
4838
|
+
var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
|
4839
|
+
|
4840
|
+
// src/providers/assets/assets.ts
|
4841
|
+
var rawAssets = [
|
4788
4842
|
{
|
4789
4843
|
name: "Ethereum",
|
4790
4844
|
symbol: "ETH",
|
@@ -4815,6 +4869,7 @@ var assets = [
|
|
4815
4869
|
]
|
4816
4870
|
}
|
4817
4871
|
];
|
4872
|
+
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
4818
4873
|
|
4819
4874
|
// src/providers/transaction-request/helpers.ts
|
4820
4875
|
var import_math19 = require("@fuel-ts/math");
|
@@ -4835,16 +4890,16 @@ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filte
|
|
4835
4890
|
// src/utils/formatTransferToContractScriptData.ts
|
4836
4891
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4837
4892
|
var import_math20 = require("@fuel-ts/math");
|
4838
|
-
var
|
4893
|
+
var import_utils27 = require("@fuel-ts/utils");
|
4839
4894
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4840
4895
|
var formatTransferToContractScriptData = (params) => {
|
4841
4896
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4842
4897
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
4843
4898
|
const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
|
4844
4899
|
const scriptData = Uint8Array.from([
|
4845
|
-
...(0,
|
4900
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
4846
4901
|
...encoded,
|
4847
|
-
...(0,
|
4902
|
+
...(0, import_utils27.arrayify)(assetId)
|
4848
4903
|
]);
|
4849
4904
|
return scriptData;
|
4850
4905
|
};
|
@@ -5024,18 +5079,18 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5024
5079
|
return balances;
|
5025
5080
|
}
|
5026
5081
|
/**
|
5027
|
-
*
|
5082
|
+
* Funds a transaction request by adding the necessary resources.
|
5028
5083
|
*
|
5029
|
-
* @
|
5030
|
-
* @param
|
5031
|
-
* @param
|
5032
|
-
* @returns
|
5084
|
+
* @typeParam T - The type of the TransactionRequest.
|
5085
|
+
* @param request - The transaction request to fund.
|
5086
|
+
* @param params - The estimated transaction parameters.
|
5087
|
+
* @returns The funded transaction request.
|
5033
5088
|
*/
|
5034
5089
|
async fund(request, params) {
|
5035
|
-
const { addedSignatures, estimatedPredicates,
|
5090
|
+
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5091
|
+
const fee = request.maxFee;
|
5036
5092
|
const baseAssetId = this.provider.getBaseAssetId();
|
5037
5093
|
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
|
5038
|
-
const txRequest = request;
|
5039
5094
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5040
5095
|
amount: (0, import_math21.bn)(fee),
|
5041
5096
|
assetId: baseAssetId,
|
@@ -5072,14 +5127,17 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5072
5127
|
cacheTxInputsFromOwner(request.inputs, this.address)
|
5073
5128
|
);
|
5074
5129
|
request.addResources(resources);
|
5075
|
-
|
5076
|
-
|
5077
|
-
const requestToReestimate2 = (0, import_ramda4.clone)(
|
5130
|
+
request.shiftPredicateData();
|
5131
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5132
|
+
const requestToReestimate2 = (0, import_ramda4.clone)(request);
|
5078
5133
|
if (addedSignatures) {
|
5079
5134
|
Array.from({ length: addedSignatures }).forEach(
|
5080
5135
|
() => requestToReestimate2.addEmptyWitness()
|
5081
5136
|
);
|
5082
5137
|
}
|
5138
|
+
if (!updateMaxFee) {
|
5139
|
+
break;
|
5140
|
+
}
|
5083
5141
|
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5084
5142
|
transactionRequest: requestToReestimate2
|
5085
5143
|
});
|
@@ -5101,17 +5159,20 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5101
5159
|
}
|
5102
5160
|
fundingAttempts += 1;
|
5103
5161
|
}
|
5104
|
-
|
5105
|
-
|
5106
|
-
const requestToReestimate = (0, import_ramda4.clone)(
|
5162
|
+
request.shiftPredicateData();
|
5163
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5164
|
+
const requestToReestimate = (0, import_ramda4.clone)(request);
|
5107
5165
|
if (addedSignatures) {
|
5108
5166
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
5109
5167
|
}
|
5168
|
+
if (!updateMaxFee) {
|
5169
|
+
return request;
|
5170
|
+
}
|
5110
5171
|
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5111
5172
|
transactionRequest: requestToReestimate
|
5112
5173
|
});
|
5113
|
-
|
5114
|
-
return
|
5174
|
+
request.maxFee = maxFee;
|
5175
|
+
return request;
|
5115
5176
|
}
|
5116
5177
|
/**
|
5117
5178
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5123,20 +5184,19 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5123
5184
|
* @returns A promise that resolves to the prepared transaction request.
|
5124
5185
|
*/
|
5125
5186
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
5126
|
-
|
5187
|
+
let request = new ScriptTransactionRequest(txParams);
|
5127
5188
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5128
5189
|
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
5129
5190
|
const txCost = await this.provider.getTransactionCost(request, {
|
5130
5191
|
estimateTxDependencies: true,
|
5131
5192
|
resourcesOwner: this
|
5132
5193
|
});
|
5133
|
-
this.validateGasLimitAndMaxFee({
|
5194
|
+
request = this.validateGasLimitAndMaxFee({
|
5195
|
+
transactionRequest: request,
|
5134
5196
|
gasUsed: txCost.gasUsed,
|
5135
5197
|
maxFee: txCost.maxFee,
|
5136
5198
|
txParams
|
5137
5199
|
});
|
5138
|
-
request.gasLimit = txCost.gasUsed;
|
5139
|
-
request.maxFee = txCost.maxFee;
|
5140
5200
|
await this.fund(request, txCost);
|
5141
5201
|
return request;
|
5142
5202
|
}
|
@@ -5183,7 +5243,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5183
5243
|
amountToTransfer: (0, import_math21.bn)(amount),
|
5184
5244
|
assetId: assetIdToTransfer
|
5185
5245
|
});
|
5186
|
-
|
5246
|
+
let request = new ScriptTransactionRequest({
|
5187
5247
|
...txParams,
|
5188
5248
|
script,
|
5189
5249
|
scriptData
|
@@ -5193,13 +5253,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5193
5253
|
resourcesOwner: this,
|
5194
5254
|
quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5195
5255
|
});
|
5196
|
-
this.validateGasLimitAndMaxFee({
|
5256
|
+
request = this.validateGasLimitAndMaxFee({
|
5257
|
+
transactionRequest: request,
|
5197
5258
|
gasUsed: txCost.gasUsed,
|
5198
5259
|
maxFee: txCost.maxFee,
|
5199
5260
|
txParams
|
5200
5261
|
});
|
5201
|
-
request.gasLimit = txCost.gasUsed;
|
5202
|
-
request.maxFee = txCost.maxFee;
|
5203
5262
|
await this.fund(request, txCost);
|
5204
5263
|
return this.sendTransaction(request);
|
5205
5264
|
}
|
@@ -5213,29 +5272,28 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5213
5272
|
*/
|
5214
5273
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5215
5274
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5216
|
-
const recipientDataArray = (0,
|
5275
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5217
5276
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5218
5277
|
);
|
5219
|
-
const amountDataArray = (0,
|
5278
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5220
5279
|
"0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5221
5280
|
);
|
5222
5281
|
const script = new Uint8Array([
|
5223
|
-
...(0,
|
5282
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5224
5283
|
...recipientDataArray,
|
5225
5284
|
...amountDataArray
|
5226
5285
|
]);
|
5227
5286
|
const params = { script, ...txParams };
|
5228
5287
|
const baseAssetId = this.provider.getBaseAssetId();
|
5229
|
-
|
5288
|
+
let request = new ScriptTransactionRequest(params);
|
5230
5289
|
const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
|
5231
5290
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5232
|
-
this.validateGasLimitAndMaxFee({
|
5291
|
+
request = this.validateGasLimitAndMaxFee({
|
5292
|
+
transactionRequest: request,
|
5233
5293
|
gasUsed: txCost.gasUsed,
|
5234
5294
|
maxFee: txCost.maxFee,
|
5235
5295
|
txParams
|
5236
5296
|
});
|
5237
|
-
request.maxFee = txCost.maxFee;
|
5238
|
-
request.gasLimit = txCost.gasUsed;
|
5239
5297
|
await this.fund(request, txCost);
|
5240
5298
|
return this.sendTransaction(request);
|
5241
5299
|
}
|
@@ -5295,22 +5353,29 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5295
5353
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5296
5354
|
}
|
5297
5355
|
validateGasLimitAndMaxFee({
|
5298
|
-
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
5299
5356
|
gasUsed,
|
5300
|
-
maxFee
|
5357
|
+
maxFee,
|
5358
|
+
transactionRequest,
|
5359
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5301
5360
|
}) {
|
5302
|
-
|
5361
|
+
const request = transactionRequestify(transactionRequest);
|
5362
|
+
if (!(0, import_utils28.isDefined)(setGasLimit)) {
|
5363
|
+
request.gasLimit = gasUsed;
|
5364
|
+
} else if (gasUsed.gt(setGasLimit)) {
|
5303
5365
|
throw new import_errors16.FuelError(
|
5304
5366
|
import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
|
5305
5367
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5306
5368
|
);
|
5307
5369
|
}
|
5308
|
-
if ((0,
|
5370
|
+
if (!(0, import_utils28.isDefined)(setMaxFee)) {
|
5371
|
+
request.maxFee = maxFee;
|
5372
|
+
} else if (maxFee.gt(setMaxFee)) {
|
5309
5373
|
throw new import_errors16.FuelError(
|
5310
5374
|
import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
|
5311
5375
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
5312
5376
|
);
|
5313
5377
|
}
|
5378
|
+
return request;
|
5314
5379
|
}
|
5315
5380
|
};
|
5316
5381
|
|
@@ -5319,7 +5384,7 @@ var import_address5 = require("@fuel-ts/address");
|
|
5319
5384
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5320
5385
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5321
5386
|
var import_math22 = require("@fuel-ts/math");
|
5322
|
-
var
|
5387
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5323
5388
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5324
5389
|
var Signer = class {
|
5325
5390
|
address;
|
@@ -5339,9 +5404,9 @@ var Signer = class {
|
|
5339
5404
|
}
|
5340
5405
|
}
|
5341
5406
|
const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
|
5342
|
-
this.privateKey = (0,
|
5343
|
-
this.publicKey = (0,
|
5344
|
-
this.compressedPublicKey = (0,
|
5407
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5408
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5409
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5345
5410
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5346
5411
|
}
|
5347
5412
|
/**
|
@@ -5355,11 +5420,11 @@ var Signer = class {
|
|
5355
5420
|
* @returns hashed signature
|
5356
5421
|
*/
|
5357
5422
|
sign(data) {
|
5358
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5423
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5359
5424
|
const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5360
5425
|
const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5361
5426
|
s[0] |= (signature.recovery || 0) << 7;
|
5362
|
-
return (0,
|
5427
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5363
5428
|
}
|
5364
5429
|
/**
|
5365
5430
|
* Add point on the current elliptic curve
|
@@ -5368,8 +5433,8 @@ var Signer = class {
|
|
5368
5433
|
* @returns compressed point on the curve
|
5369
5434
|
*/
|
5370
5435
|
addPoint(point) {
|
5371
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5372
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5436
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5437
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5373
5438
|
const result = p0.add(p1);
|
5374
5439
|
return `0x${result.toHex(true)}`;
|
5375
5440
|
}
|
@@ -5381,16 +5446,16 @@ var Signer = class {
|
|
5381
5446
|
* @returns public key from signature from the
|
5382
5447
|
*/
|
5383
5448
|
static recoverPublicKey(data, signature) {
|
5384
|
-
const signedMessageBytes = (0,
|
5449
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5385
5450
|
const r = signedMessageBytes.slice(0, 32);
|
5386
5451
|
const s = signedMessageBytes.slice(32, 64);
|
5387
5452
|
const recoveryParam = (s[0] & 128) >> 7;
|
5388
5453
|
s[0] &= 127;
|
5389
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5454
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5390
5455
|
recoveryParam
|
5391
5456
|
);
|
5392
|
-
const publicKey = sig.recoverPublicKey((0,
|
5393
|
-
return (0,
|
5457
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5458
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5394
5459
|
}
|
5395
5460
|
/**
|
5396
5461
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5409,7 +5474,7 @@ var Signer = class {
|
|
5409
5474
|
* @returns random 32-byte hashed
|
5410
5475
|
*/
|
5411
5476
|
static generatePrivateKey(entropy) {
|
5412
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5477
|
+
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);
|
5413
5478
|
}
|
5414
5479
|
/**
|
5415
5480
|
* Extended publicKey from a compact publicKey
|
@@ -5418,8 +5483,8 @@ var Signer = class {
|
|
5418
5483
|
* @returns extended publicKey
|
5419
5484
|
*/
|
5420
5485
|
static extendPublicKey(publicKey) {
|
5421
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5422
|
-
return (0,
|
5486
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5487
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5423
5488
|
}
|
5424
5489
|
};
|
5425
5490
|
|
@@ -5427,7 +5492,7 @@ var Signer = class {
|
|
5427
5492
|
var import_address6 = require("@fuel-ts/address");
|
5428
5493
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5429
5494
|
var import_errors17 = require("@fuel-ts/errors");
|
5430
|
-
var
|
5495
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5431
5496
|
var import_uuid = require("uuid");
|
5432
5497
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5433
5498
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5510,7 +5575,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5510
5575
|
);
|
5511
5576
|
}
|
5512
5577
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5513
|
-
const privateKey = (0,
|
5578
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5514
5579
|
return privateKey;
|
5515
5580
|
}
|
5516
5581
|
|
@@ -5555,7 +5620,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5555
5620
|
*/
|
5556
5621
|
async signMessage(message) {
|
5557
5622
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5558
|
-
return (0,
|
5623
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
5559
5624
|
}
|
5560
5625
|
/**
|
5561
5626
|
* Signs a transaction with the wallet's private key.
|
@@ -5568,7 +5633,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5568
5633
|
const chainId = this.provider.getChainId();
|
5569
5634
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5570
5635
|
const signature = await this.signer().sign(hashedTransaction);
|
5571
|
-
return (0,
|
5636
|
+
return (0, import_utils31.hexlify)(signature);
|
5572
5637
|
}
|
5573
5638
|
/**
|
5574
5639
|
* Populates a transaction with the witnesses signature.
|
@@ -5630,14 +5695,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5630
5695
|
var import_errors20 = require("@fuel-ts/errors");
|
5631
5696
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5632
5697
|
var import_math23 = require("@fuel-ts/math");
|
5633
|
-
var
|
5698
|
+
var import_utils35 = require("@fuel-ts/utils");
|
5634
5699
|
var import_ethers2 = require("ethers");
|
5635
5700
|
|
5636
5701
|
// src/mnemonic/mnemonic.ts
|
5637
5702
|
var import_crypto4 = require("@fuel-ts/crypto");
|
5638
5703
|
var import_errors19 = require("@fuel-ts/errors");
|
5639
5704
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5640
|
-
var
|
5705
|
+
var import_utils33 = require("@fuel-ts/utils");
|
5641
5706
|
var import_ethers = require("ethers");
|
5642
5707
|
|
5643
5708
|
// src/wordlists/words/english.ts
|
@@ -7695,7 +7760,7 @@ var english = [
|
|
7695
7760
|
// src/mnemonic/utils.ts
|
7696
7761
|
var import_errors18 = require("@fuel-ts/errors");
|
7697
7762
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7698
|
-
var
|
7763
|
+
var import_utils32 = require("@fuel-ts/utils");
|
7699
7764
|
function toUtf8Bytes(stri) {
|
7700
7765
|
const str = stri.normalize("NFKD");
|
7701
7766
|
const result = [];
|
@@ -7762,14 +7827,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7762
7827
|
}
|
7763
7828
|
}
|
7764
7829
|
const checksumBits = entropy.length / 4;
|
7765
|
-
const checksum = (0,
|
7830
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7766
7831
|
indices[indices.length - 1] <<= checksumBits;
|
7767
7832
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7768
7833
|
return indices;
|
7769
7834
|
}
|
7770
7835
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7771
7836
|
const size = Math.ceil(11 * words.length / 8);
|
7772
|
-
const entropy = (0,
|
7837
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
7773
7838
|
let offset = 0;
|
7774
7839
|
for (let i = 0; i < words.length; i += 1) {
|
7775
7840
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7789,7 +7854,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7789
7854
|
const entropyBits = 32 * words.length / 3;
|
7790
7855
|
const checksumBits = words.length / 3;
|
7791
7856
|
const checksumMask = getUpperMask(checksumBits);
|
7792
|
-
const checksum = (0,
|
7857
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7793
7858
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7794
7859
|
throw new import_errors18.FuelError(
|
7795
7860
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -7864,7 +7929,7 @@ var Mnemonic = class {
|
|
7864
7929
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7865
7930
|
const words = getWords(phrase);
|
7866
7931
|
assertMnemonic(words);
|
7867
|
-
return (0,
|
7932
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7868
7933
|
}
|
7869
7934
|
/**
|
7870
7935
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7872,7 +7937,7 @@ var Mnemonic = class {
|
|
7872
7937
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7873
7938
|
*/
|
7874
7939
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7875
|
-
const entropyBytes = (0,
|
7940
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
7876
7941
|
assertWordList(wordlist);
|
7877
7942
|
assertEntropy(entropyBytes);
|
7878
7943
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7941,14 +8006,14 @@ var Mnemonic = class {
|
|
7941
8006
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7942
8007
|
*/
|
7943
8008
|
static masterKeysFromSeed(seed) {
|
7944
|
-
const seedArray = (0,
|
8009
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
7945
8010
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7946
8011
|
throw new import_errors19.FuelError(
|
7947
8012
|
import_errors19.ErrorCode.INVALID_SEED,
|
7948
8013
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7949
8014
|
);
|
7950
8015
|
}
|
7951
|
-
return (0,
|
8016
|
+
return (0, import_utils33.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
|
7952
8017
|
}
|
7953
8018
|
/**
|
7954
8019
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7959,22 +8024,22 @@ var Mnemonic = class {
|
|
7959
8024
|
*/
|
7960
8025
|
static seedToExtendedKey(seed, testnet = false) {
|
7961
8026
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7962
|
-
const prefix = (0,
|
8027
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7963
8028
|
const depth = "0x00";
|
7964
8029
|
const fingerprint = "0x00000000";
|
7965
8030
|
const index = "0x00000000";
|
7966
8031
|
const chainCode = masterKey.slice(32);
|
7967
8032
|
const privateKey = masterKey.slice(0, 32);
|
7968
|
-
const extendedKey = (0,
|
8033
|
+
const extendedKey = (0, import_utils33.concat)([
|
7969
8034
|
prefix,
|
7970
8035
|
depth,
|
7971
8036
|
fingerprint,
|
7972
8037
|
index,
|
7973
8038
|
chainCode,
|
7974
|
-
(0,
|
8039
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
7975
8040
|
]);
|
7976
8041
|
const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7977
|
-
return (0, import_ethers.encodeBase58)((0,
|
8042
|
+
return (0, import_ethers.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
7978
8043
|
}
|
7979
8044
|
/**
|
7980
8045
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7989,7 +8054,7 @@ var Mnemonic = class {
|
|
7989
8054
|
* @returns A randomly generated mnemonic
|
7990
8055
|
*/
|
7991
8056
|
static generate(size = 32, extraEntropy = "") {
|
7992
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8057
|
+
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);
|
7993
8058
|
return Mnemonic.entropyToMnemonic(entropy);
|
7994
8059
|
}
|
7995
8060
|
};
|
@@ -7997,12 +8062,12 @@ var mnemonic_default = Mnemonic;
|
|
7997
8062
|
|
7998
8063
|
// src/hdwallet/hdwallet.ts
|
7999
8064
|
var HARDENED_INDEX = 2147483648;
|
8000
|
-
var MainnetPRV2 = (0,
|
8001
|
-
var MainnetPUB = (0,
|
8002
|
-
var TestnetPRV2 = (0,
|
8003
|
-
var TestnetPUB = (0,
|
8065
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
8066
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
8067
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8068
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
8004
8069
|
function base58check(data) {
|
8005
|
-
return (0, import_ethers2.encodeBase58)((0,
|
8070
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers2.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
8006
8071
|
}
|
8007
8072
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8008
8073
|
if (isPublic) {
|
@@ -8011,11 +8076,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8011
8076
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8012
8077
|
}
|
8013
8078
|
function isPublicExtendedKey(extendedKey) {
|
8014
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8079
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
8015
8080
|
}
|
8016
8081
|
function isValidExtendedKey(extendedKey) {
|
8017
8082
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8018
|
-
(0,
|
8083
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
8019
8084
|
);
|
8020
8085
|
}
|
8021
8086
|
function parsePath(path2, depth = 0) {
|
@@ -8033,8 +8098,8 @@ function parsePath(path2, depth = 0) {
|
|
8033
8098
|
var HDWallet = class {
|
8034
8099
|
depth = 0;
|
8035
8100
|
index = 0;
|
8036
|
-
fingerprint = (0,
|
8037
|
-
parentFingerprint = (0,
|
8101
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8102
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8038
8103
|
privateKey;
|
8039
8104
|
publicKey;
|
8040
8105
|
chainCode;
|
@@ -8046,8 +8111,8 @@ var HDWallet = class {
|
|
8046
8111
|
constructor(config) {
|
8047
8112
|
if (config.privateKey) {
|
8048
8113
|
const signer = new Signer(config.privateKey);
|
8049
|
-
this.publicKey = (0,
|
8050
|
-
this.privateKey = (0,
|
8114
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
8115
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
8051
8116
|
} else {
|
8052
8117
|
if (!config.publicKey) {
|
8053
8118
|
throw new import_errors20.FuelError(
|
@@ -8055,7 +8120,7 @@ var HDWallet = class {
|
|
8055
8120
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8056
8121
|
);
|
8057
8122
|
}
|
8058
|
-
this.publicKey = (0,
|
8123
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8059
8124
|
}
|
8060
8125
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8061
8126
|
this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
@@ -8074,9 +8139,9 @@ var HDWallet = class {
|
|
8074
8139
|
* @returns A new instance of HDWallet on the derived index
|
8075
8140
|
*/
|
8076
8141
|
deriveIndex(index) {
|
8077
|
-
const privateKey = this.privateKey && (0,
|
8078
|
-
const publicKey = (0,
|
8079
|
-
const chainCode = (0,
|
8142
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
8143
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
8144
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
8080
8145
|
const data = new Uint8Array(37);
|
8081
8146
|
if (index & HARDENED_INDEX) {
|
8082
8147
|
if (!privateKey) {
|
@@ -8087,10 +8152,10 @@ var HDWallet = class {
|
|
8087
8152
|
}
|
8088
8153
|
data.set(privateKey, 1);
|
8089
8154
|
} else {
|
8090
|
-
data.set((0,
|
8155
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8091
8156
|
}
|
8092
8157
|
data.set((0, import_math23.toBytes)(index, 4), 33);
|
8093
|
-
const bytes = (0,
|
8158
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
|
8094
8159
|
const IL = bytes.slice(0, 32);
|
8095
8160
|
const IR = bytes.slice(32);
|
8096
8161
|
if (privateKey) {
|
@@ -8104,7 +8169,7 @@ var HDWallet = class {
|
|
8104
8169
|
parentFingerprint: this.fingerprint
|
8105
8170
|
});
|
8106
8171
|
}
|
8107
|
-
const signer = new Signer((0,
|
8172
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
8108
8173
|
const Ki = signer.addPoint(publicKey);
|
8109
8174
|
return new HDWallet({
|
8110
8175
|
publicKey: Ki,
|
@@ -8139,12 +8204,12 @@ var HDWallet = class {
|
|
8139
8204
|
);
|
8140
8205
|
}
|
8141
8206
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8142
|
-
const depth = (0,
|
8207
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8143
8208
|
const parentFingerprint = this.parentFingerprint;
|
8144
8209
|
const index = (0, import_math23.toHex)(this.index, 4);
|
8145
8210
|
const chainCode = this.chainCode;
|
8146
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8147
|
-
const extendedKey = (0,
|
8211
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8212
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8148
8213
|
return base58check(extendedKey);
|
8149
8214
|
}
|
8150
8215
|
/**
|
@@ -8156,13 +8221,13 @@ var HDWallet = class {
|
|
8156
8221
|
static fromSeed(seed) {
|
8157
8222
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8158
8223
|
return new HDWallet({
|
8159
|
-
chainCode: (0,
|
8160
|
-
privateKey: (0,
|
8224
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8225
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8161
8226
|
});
|
8162
8227
|
}
|
8163
8228
|
static fromExtendedKey(extendedKey) {
|
8164
8229
|
const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
|
8165
|
-
const bytes = (0,
|
8230
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8166
8231
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8167
8232
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8168
8233
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8171,9 +8236,9 @@ var HDWallet = class {
|
|
8171
8236
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8172
8237
|
}
|
8173
8238
|
const depth = bytes[4];
|
8174
|
-
const parentFingerprint = (0,
|
8175
|
-
const index = parseInt((0,
|
8176
|
-
const chainCode = (0,
|
8239
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8240
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8241
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8177
8242
|
const key = bytes.slice(45, 78);
|
8178
8243
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8179
8244
|
throw new import_errors20.FuelError(
|
@@ -8390,7 +8455,7 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8390
8455
|
// src/test-utils/launchNode.ts
|
8391
8456
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
8392
8457
|
var import_crypto6 = require("@fuel-ts/crypto");
|
8393
|
-
var
|
8458
|
+
var import_utils36 = require("@fuel-ts/utils");
|
8394
8459
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
8395
8460
|
var import_child_process = require("child_process");
|
8396
8461
|
var import_crypto7 = require("crypto");
|
@@ -8448,7 +8513,7 @@ var launchNode = async ({
|
|
8448
8513
|
"--poa-instant"
|
8449
8514
|
]);
|
8450
8515
|
const snapshotDir = getFlagValueFromArgs(args, "--snapshot");
|
8451
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
8516
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
|
8452
8517
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8453
8518
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
8454
8519
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
@@ -8473,8 +8538,8 @@ var launchNode = async ({
|
|
8473
8538
|
if (!(0, import_fs.existsSync)(tempDirPath)) {
|
8474
8539
|
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
8475
8540
|
}
|
8476
|
-
let { stateConfigJson } =
|
8477
|
-
const { chainConfigJson, metadataJson } =
|
8541
|
+
let { stateConfigJson } = import_utils36.defaultSnapshotConfigs;
|
8542
|
+
const { chainConfigJson, metadataJson } = import_utils36.defaultSnapshotConfigs;
|
8478
8543
|
stateConfigJson = {
|
8479
8544
|
...stateConfigJson,
|
8480
8545
|
coins: [
|
@@ -8492,9 +8557,9 @@ var launchNode = async ({
|
|
8492
8557
|
if (!process.env.GENESIS_SECRET) {
|
8493
8558
|
const pk = Signer.generatePrivateKey();
|
8494
8559
|
const signer = new Signer(pk);
|
8495
|
-
process.env.GENESIS_SECRET = (0,
|
8560
|
+
process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
|
8496
8561
|
stateConfigJson.coins.push({
|
8497
|
-
tx_id: (0,
|
8562
|
+
tx_id: (0, import_utils36.hexlify)((0, import_crypto6.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
|
8498
8563
|
owner: signer.address.toHexString(),
|
8499
8564
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8500
8565
|
amount: "18446744073709551615",
|