@fuel-ts/account 0.84.0 → 0.86.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/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +1878 -2996
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +565 -512
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +380 -342
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts +0 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/predicate.d.ts +9 -2
- package/dist/predicate/predicate.d.ts.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/coin.d.ts +0 -1
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +0 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +6 -10
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +4 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +0 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -1
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -4
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-summary/call.d.ts +1 -1
- package/dist/providers/transaction-summary/call.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/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +1628 -2758
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +523 -499
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +353 -329
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +15 -16
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
|
-
var
|
68
|
-
var
|
67
|
+
var import_math20 = require("@fuel-ts/math");
|
68
|
+
var import_utils28 = require("@fuel-ts/utils");
|
69
69
|
var import_ramda4 = require("ramda");
|
70
70
|
|
71
71
|
// src/providers/coin-quantity.ts
|
@@ -107,7 +107,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
107
107
|
var import_address3 = require("@fuel-ts/address");
|
108
108
|
var import_errors14 = require("@fuel-ts/errors");
|
109
109
|
var import_math17 = require("@fuel-ts/math");
|
110
|
-
var
|
110
|
+
var import_transactions20 = require("@fuel-ts/transactions");
|
111
111
|
var import_utils22 = require("@fuel-ts/utils");
|
112
112
|
var import_versions = require("@fuel-ts/versions");
|
113
113
|
var import_utils23 = require("@noble/curves/abstract/utils");
|
@@ -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 {
|
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 {
|
161
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) {
|
@@ -1297,8 +1324,8 @@ var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
|
1297
1324
|
var import_address = require("@fuel-ts/address");
|
1298
1325
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1299
1326
|
var import_crypto = require("@fuel-ts/crypto");
|
1300
|
-
var
|
1301
|
-
var
|
1327
|
+
var import_math8 = require("@fuel-ts/math");
|
1328
|
+
var import_transactions7 = require("@fuel-ts/transactions");
|
1302
1329
|
var import_utils9 = require("@fuel-ts/utils");
|
1303
1330
|
|
1304
1331
|
// src/providers/resource.ts
|
@@ -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);
|
@@ -1732,6 +1758,36 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1732
1758
|
name = "NoWitnessAtIndexError";
|
1733
1759
|
};
|
1734
1760
|
|
1761
|
+
// src/providers/transaction-request/helpers.ts
|
1762
|
+
var import_math7 = require("@fuel-ts/math");
|
1763
|
+
var import_transactions6 = require("@fuel-ts/transactions");
|
1764
|
+
var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
|
1765
|
+
var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
|
1766
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1767
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1768
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1769
|
+
return acc.add(input.amount);
|
1770
|
+
}
|
1771
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1772
|
+
return acc.add(input.amount);
|
1773
|
+
}
|
1774
|
+
return acc;
|
1775
|
+
}, (0, import_math7.bn)(0));
|
1776
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
1777
|
+
(acc, input) => {
|
1778
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
1779
|
+
acc.utxos.push(input.id);
|
1780
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
1781
|
+
acc.messages.push(input.nonce);
|
1782
|
+
}
|
1783
|
+
return acc;
|
1784
|
+
},
|
1785
|
+
{
|
1786
|
+
utxos: [],
|
1787
|
+
messages: []
|
1788
|
+
}
|
1789
|
+
);
|
1790
|
+
|
1735
1791
|
// src/providers/transaction-request/witness.ts
|
1736
1792
|
var import_utils8 = require("@fuel-ts/utils");
|
1737
1793
|
var witnessify = (value) => {
|
@@ -1772,10 +1828,10 @@ var BaseTransactionRequest = class {
|
|
1772
1828
|
outputs,
|
1773
1829
|
witnesses
|
1774
1830
|
} = {}) {
|
1775
|
-
this.tip = tip ? (0,
|
1831
|
+
this.tip = tip ? (0, import_math8.bn)(tip) : void 0;
|
1776
1832
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1777
|
-
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0,
|
1778
|
-
this.maxFee = (0,
|
1833
|
+
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math8.bn)(witnessLimit) : void 0;
|
1834
|
+
this.maxFee = (0, import_math8.bn)(maxFee);
|
1779
1835
|
this.inputs = inputs ?? [];
|
1780
1836
|
this.outputs = outputs ?? [];
|
1781
1837
|
this.witnesses = witnesses ?? [];
|
@@ -1784,20 +1840,20 @@ var BaseTransactionRequest = class {
|
|
1784
1840
|
let policyTypes = 0;
|
1785
1841
|
const policies = [];
|
1786
1842
|
const { tip, witnessLimit, maturity } = req;
|
1787
|
-
if ((0,
|
1788
|
-
policyTypes +=
|
1789
|
-
policies.push({ data: (0,
|
1843
|
+
if ((0, import_math8.bn)(tip).gt(0)) {
|
1844
|
+
policyTypes += import_transactions7.PolicyType.Tip;
|
1845
|
+
policies.push({ data: (0, import_math8.bn)(tip), type: import_transactions7.PolicyType.Tip });
|
1790
1846
|
}
|
1791
|
-
if ((0, import_utils9.isDefined)(witnessLimit) && (0,
|
1792
|
-
policyTypes +=
|
1793
|
-
policies.push({ data: (0,
|
1847
|
+
if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math8.bn)(witnessLimit).gte(0)) {
|
1848
|
+
policyTypes += import_transactions7.PolicyType.WitnessLimit;
|
1849
|
+
policies.push({ data: (0, import_math8.bn)(witnessLimit), type: import_transactions7.PolicyType.WitnessLimit });
|
1794
1850
|
}
|
1795
1851
|
if (maturity && maturity > 0) {
|
1796
|
-
policyTypes +=
|
1797
|
-
policies.push({ data: maturity, type:
|
1852
|
+
policyTypes += import_transactions7.PolicyType.Maturity;
|
1853
|
+
policies.push({ data: maturity, type: import_transactions7.PolicyType.Maturity });
|
1798
1854
|
}
|
1799
|
-
policyTypes +=
|
1800
|
-
policies.push({ data: req.maxFee, type:
|
1855
|
+
policyTypes += import_transactions7.PolicyType.MaxFee;
|
1856
|
+
policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
|
1801
1857
|
return {
|
1802
1858
|
policyTypes,
|
1803
1859
|
policies
|
@@ -1830,7 +1886,7 @@ var BaseTransactionRequest = class {
|
|
1830
1886
|
* @returns The transaction bytes.
|
1831
1887
|
*/
|
1832
1888
|
toTransactionBytes() {
|
1833
|
-
return new
|
1889
|
+
return new import_transactions7.TransactionCoder().encode(this.toTransaction());
|
1834
1890
|
}
|
1835
1891
|
/**
|
1836
1892
|
* @hidden
|
@@ -1921,7 +1977,7 @@ var BaseTransactionRequest = class {
|
|
1921
1977
|
*/
|
1922
1978
|
getCoinInputs() {
|
1923
1979
|
return this.inputs.filter(
|
1924
|
-
(input) => input.type ===
|
1980
|
+
(input) => input.type === import_transactions7.InputType.Coin
|
1925
1981
|
);
|
1926
1982
|
}
|
1927
1983
|
/**
|
@@ -1931,7 +1987,7 @@ var BaseTransactionRequest = class {
|
|
1931
1987
|
*/
|
1932
1988
|
getCoinOutputs() {
|
1933
1989
|
return this.outputs.filter(
|
1934
|
-
(output) => output.type ===
|
1990
|
+
(output) => output.type === import_transactions7.OutputType.Coin
|
1935
1991
|
);
|
1936
1992
|
}
|
1937
1993
|
/**
|
@@ -1941,7 +1997,7 @@ var BaseTransactionRequest = class {
|
|
1941
1997
|
*/
|
1942
1998
|
getChangeOutputs() {
|
1943
1999
|
return this.outputs.filter(
|
1944
|
-
(output) => output.type ===
|
2000
|
+
(output) => output.type === import_transactions7.OutputType.Change
|
1945
2001
|
);
|
1946
2002
|
}
|
1947
2003
|
/**
|
@@ -1953,9 +2009,9 @@ var BaseTransactionRequest = class {
|
|
1953
2009
|
const ownerAddress = (0, import_address.addressify)(owner);
|
1954
2010
|
const found = this.inputs.find((input) => {
|
1955
2011
|
switch (input.type) {
|
1956
|
-
case
|
2012
|
+
case import_transactions7.InputType.Coin:
|
1957
2013
|
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
1958
|
-
case
|
2014
|
+
case import_transactions7.InputType.Message:
|
1959
2015
|
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
1960
2016
|
default:
|
1961
2017
|
return false;
|
@@ -1970,7 +2026,7 @@ var BaseTransactionRequest = class {
|
|
1970
2026
|
* @param coin - Coin resource.
|
1971
2027
|
*/
|
1972
2028
|
addCoinInput(coin) {
|
1973
|
-
const { assetId, owner, amount } = coin;
|
2029
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
1974
2030
|
let witnessIndex;
|
1975
2031
|
if (coin.predicate) {
|
1976
2032
|
witnessIndex = 0;
|
@@ -1981,13 +2037,14 @@ var BaseTransactionRequest = class {
|
|
1981
2037
|
}
|
1982
2038
|
}
|
1983
2039
|
const input = {
|
1984
|
-
|
1985
|
-
type:
|
2040
|
+
id,
|
2041
|
+
type: import_transactions7.InputType.Coin,
|
1986
2042
|
owner: owner.toB256(),
|
1987
2043
|
amount,
|
1988
2044
|
assetId,
|
1989
2045
|
txPointer: "0x00000000000000000000000000000000",
|
1990
|
-
witnessIndex
|
2046
|
+
witnessIndex,
|
2047
|
+
predicate
|
1991
2048
|
};
|
1992
2049
|
this.pushInput(input);
|
1993
2050
|
this.addChangeOutput(owner, assetId);
|
@@ -1999,7 +2056,7 @@ var BaseTransactionRequest = class {
|
|
1999
2056
|
* @param message - Message resource.
|
2000
2057
|
*/
|
2001
2058
|
addMessageInput(message) {
|
2002
|
-
const { recipient, sender, amount, assetId } = message;
|
2059
|
+
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
2003
2060
|
let witnessIndex;
|
2004
2061
|
if (message.predicate) {
|
2005
2062
|
witnessIndex = 0;
|
@@ -2010,12 +2067,13 @@ var BaseTransactionRequest = class {
|
|
2010
2067
|
}
|
2011
2068
|
}
|
2012
2069
|
const input = {
|
2013
|
-
|
2014
|
-
type:
|
2070
|
+
nonce,
|
2071
|
+
type: import_transactions7.InputType.Message,
|
2015
2072
|
sender: sender.toB256(),
|
2016
2073
|
recipient: recipient.toB256(),
|
2017
2074
|
amount,
|
2018
|
-
witnessIndex
|
2075
|
+
witnessIndex,
|
2076
|
+
predicate
|
2019
2077
|
};
|
2020
2078
|
this.pushInput(input);
|
2021
2079
|
this.addChangeOutput(recipient, assetId);
|
@@ -2055,7 +2113,7 @@ var BaseTransactionRequest = class {
|
|
2055
2113
|
*/
|
2056
2114
|
addCoinOutput(to, amount, assetId) {
|
2057
2115
|
this.pushOutput({
|
2058
|
-
type:
|
2116
|
+
type: import_transactions7.OutputType.Coin,
|
2059
2117
|
to: (0, import_address.addressify)(to).toB256(),
|
2060
2118
|
amount,
|
2061
2119
|
assetId
|
@@ -2071,7 +2129,7 @@ var BaseTransactionRequest = class {
|
|
2071
2129
|
addCoinOutputs(to, quantities) {
|
2072
2130
|
quantities.map(coinQuantityfy).forEach((quantity) => {
|
2073
2131
|
this.pushOutput({
|
2074
|
-
type:
|
2132
|
+
type: import_transactions7.OutputType.Coin,
|
2075
2133
|
to: (0, import_address.addressify)(to).toB256(),
|
2076
2134
|
amount: quantity.amount,
|
2077
2135
|
assetId: quantity.assetId
|
@@ -2091,7 +2149,7 @@ var BaseTransactionRequest = class {
|
|
2091
2149
|
);
|
2092
2150
|
if (!changeOutput) {
|
2093
2151
|
this.pushOutput({
|
2094
|
-
type:
|
2152
|
+
type: import_transactions7.OutputType.Change,
|
2095
2153
|
to: (0, import_address.addressify)(to).toB256(),
|
2096
2154
|
assetId
|
2097
2155
|
});
|
@@ -2162,7 +2220,7 @@ var BaseTransactionRequest = class {
|
|
2162
2220
|
const assetInput = findAssetInput(assetId);
|
2163
2221
|
let usedQuantity = quantity;
|
2164
2222
|
if (assetId === baseAssetId) {
|
2165
|
-
usedQuantity = (0,
|
2223
|
+
usedQuantity = (0, import_math8.bn)("1000000000000000000");
|
2166
2224
|
}
|
2167
2225
|
if (assetInput && "assetId" in assetInput) {
|
2168
2226
|
assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
|
@@ -2174,13 +2232,13 @@ var BaseTransactionRequest = class {
|
|
2174
2232
|
amount: usedQuantity,
|
2175
2233
|
assetId,
|
2176
2234
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2177
|
-
blockCreated: (0,
|
2178
|
-
txCreatedIdx: (0,
|
2235
|
+
blockCreated: (0, import_math8.bn)(1),
|
2236
|
+
txCreatedIdx: (0, import_math8.bn)(1)
|
2179
2237
|
}
|
2180
2238
|
]);
|
2181
2239
|
}
|
2182
2240
|
};
|
2183
|
-
updateAssetInput(baseAssetId, (0,
|
2241
|
+
updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
|
2184
2242
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2185
2243
|
}
|
2186
2244
|
/**
|
@@ -2191,7 +2249,7 @@ var BaseTransactionRequest = class {
|
|
2191
2249
|
*/
|
2192
2250
|
getCoinOutputsQuantities() {
|
2193
2251
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2194
|
-
amount: (0,
|
2252
|
+
amount: (0, import_math8.bn)(amount),
|
2195
2253
|
assetId: assetId.toString()
|
2196
2254
|
}));
|
2197
2255
|
return coinsQuantities;
|
@@ -2205,73 +2263,75 @@ var BaseTransactionRequest = class {
|
|
2205
2263
|
toJSON() {
|
2206
2264
|
return normalizeJSON(this);
|
2207
2265
|
}
|
2266
|
+
removeWitness(index) {
|
2267
|
+
this.witnesses.splice(index, 1);
|
2268
|
+
this.adjustWitnessIndexes(index);
|
2269
|
+
}
|
2270
|
+
adjustWitnessIndexes(removedIndex) {
|
2271
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2272
|
+
if (input.witnessIndex > removedIndex) {
|
2273
|
+
input.witnessIndex -= 1;
|
2274
|
+
}
|
2275
|
+
});
|
2276
|
+
}
|
2208
2277
|
updatePredicateGasUsed(inputs) {
|
2209
2278
|
this.inputs.forEach((i) => {
|
2210
2279
|
let correspondingInput;
|
2211
2280
|
switch (i.type) {
|
2212
|
-
case
|
2213
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2281
|
+
case import_transactions7.InputType.Coin:
|
2282
|
+
correspondingInput = inputs.find((x) => x.type === import_transactions7.InputType.Coin && x.owner === i.owner);
|
2214
2283
|
break;
|
2215
|
-
case
|
2284
|
+
case import_transactions7.InputType.Message:
|
2216
2285
|
correspondingInput = inputs.find(
|
2217
|
-
(x) => x.type ===
|
2286
|
+
(x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
|
2218
2287
|
);
|
2219
2288
|
break;
|
2220
2289
|
default:
|
2221
2290
|
return;
|
2222
2291
|
}
|
2223
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0,
|
2292
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math8.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2224
2293
|
i.predicate = correspondingInput.predicate;
|
2225
2294
|
i.predicateData = correspondingInput.predicateData;
|
2226
2295
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
2227
2296
|
}
|
2228
2297
|
});
|
2229
2298
|
}
|
2230
|
-
shiftPredicateData() {
|
2231
|
-
this.inputs.forEach((input) => {
|
2232
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2233
|
-
input.predicateData = input.padPredicateData(
|
2234
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2235
|
-
);
|
2236
|
-
}
|
2237
|
-
});
|
2238
|
-
}
|
2239
2299
|
};
|
2240
2300
|
|
2241
2301
|
// src/providers/transaction-request/create-transaction-request.ts
|
2242
2302
|
var import_configs8 = require("@fuel-ts/address/configs");
|
2243
|
-
var
|
2244
|
-
var
|
2303
|
+
var import_math10 = require("@fuel-ts/math");
|
2304
|
+
var import_transactions9 = require("@fuel-ts/transactions");
|
2245
2305
|
var import_utils13 = require("@fuel-ts/utils");
|
2246
2306
|
|
2247
2307
|
// src/providers/transaction-request/hash-transaction.ts
|
2248
2308
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2249
2309
|
var import_hasher = require("@fuel-ts/hasher");
|
2250
|
-
var
|
2251
|
-
var
|
2310
|
+
var import_math9 = require("@fuel-ts/math");
|
2311
|
+
var import_transactions8 = require("@fuel-ts/transactions");
|
2252
2312
|
var import_utils11 = require("@fuel-ts/utils");
|
2253
2313
|
var import_ramda2 = require("ramda");
|
2254
2314
|
function hashTransaction(transactionRequest, chainId) {
|
2255
2315
|
const transaction = transactionRequest.toTransaction();
|
2256
|
-
if (transaction.type ===
|
2316
|
+
if (transaction.type === import_transactions8.TransactionType.Script) {
|
2257
2317
|
transaction.receiptsRoot = import_configs7.ZeroBytes32;
|
2258
2318
|
}
|
2259
2319
|
transaction.inputs = transaction.inputs.map((input) => {
|
2260
2320
|
const inputClone = (0, import_ramda2.clone)(input);
|
2261
2321
|
switch (inputClone.type) {
|
2262
|
-
case
|
2322
|
+
case import_transactions8.InputType.Coin: {
|
2263
2323
|
inputClone.txPointer = {
|
2264
2324
|
blockHeight: 0,
|
2265
2325
|
txIndex: 0
|
2266
2326
|
};
|
2267
|
-
inputClone.predicateGasUsed = (0,
|
2327
|
+
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
2268
2328
|
return inputClone;
|
2269
2329
|
}
|
2270
|
-
case
|
2271
|
-
inputClone.predicateGasUsed = (0,
|
2330
|
+
case import_transactions8.InputType.Message: {
|
2331
|
+
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
2272
2332
|
return inputClone;
|
2273
2333
|
}
|
2274
|
-
case
|
2334
|
+
case import_transactions8.InputType.Contract: {
|
2275
2335
|
inputClone.txPointer = {
|
2276
2336
|
blockHeight: 0,
|
2277
2337
|
txIndex: 0
|
@@ -2289,18 +2349,18 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2289
2349
|
transaction.outputs = transaction.outputs.map((output) => {
|
2290
2350
|
const outputClone = (0, import_ramda2.clone)(output);
|
2291
2351
|
switch (outputClone.type) {
|
2292
|
-
case
|
2352
|
+
case import_transactions8.OutputType.Contract: {
|
2293
2353
|
outputClone.balanceRoot = import_configs7.ZeroBytes32;
|
2294
2354
|
outputClone.stateRoot = import_configs7.ZeroBytes32;
|
2295
2355
|
return outputClone;
|
2296
2356
|
}
|
2297
|
-
case
|
2298
|
-
outputClone.amount = (0,
|
2357
|
+
case import_transactions8.OutputType.Change: {
|
2358
|
+
outputClone.amount = (0, import_math9.bn)(0);
|
2299
2359
|
return outputClone;
|
2300
2360
|
}
|
2301
|
-
case
|
2361
|
+
case import_transactions8.OutputType.Variable: {
|
2302
2362
|
outputClone.to = import_configs7.ZeroBytes32;
|
2303
|
-
outputClone.amount = (0,
|
2363
|
+
outputClone.amount = (0, import_math9.bn)(0);
|
2304
2364
|
outputClone.assetId = import_configs7.ZeroBytes32;
|
2305
2365
|
return outputClone;
|
2306
2366
|
}
|
@@ -2311,7 +2371,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2311
2371
|
transaction.witnessesCount = 0;
|
2312
2372
|
transaction.witnesses = [];
|
2313
2373
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2314
|
-
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new
|
2374
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
|
2315
2375
|
return (0, import_hasher.sha256)(concatenatedData);
|
2316
2376
|
}
|
2317
2377
|
|
@@ -2347,7 +2407,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2347
2407
|
return new this(obj);
|
2348
2408
|
}
|
2349
2409
|
/** Type of the transaction */
|
2350
|
-
type =
|
2410
|
+
type = import_transactions9.TransactionType.Create;
|
2351
2411
|
/** Witness index of contract bytecode to create */
|
2352
2412
|
bytecodeWitnessIndex;
|
2353
2413
|
/** Salt */
|
@@ -2375,10 +2435,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2375
2435
|
const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
|
2376
2436
|
const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
|
2377
2437
|
return {
|
2378
|
-
type:
|
2438
|
+
type: import_transactions9.TransactionType.Create,
|
2379
2439
|
...baseTransaction,
|
2380
2440
|
bytecodeWitnessIndex,
|
2381
|
-
storageSlotsCount: (0,
|
2441
|
+
storageSlotsCount: (0, import_math10.bn)(storageSlots.length),
|
2382
2442
|
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2383
2443
|
storageSlots
|
2384
2444
|
};
|
@@ -2390,7 +2450,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2390
2450
|
*/
|
2391
2451
|
getContractCreatedOutputs() {
|
2392
2452
|
return this.outputs.filter(
|
2393
|
-
(output) => output.type ===
|
2453
|
+
(output) => output.type === import_transactions9.OutputType.ContractCreated
|
2394
2454
|
);
|
2395
2455
|
}
|
2396
2456
|
/**
|
@@ -2411,14 +2471,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2411
2471
|
*/
|
2412
2472
|
addContractCreatedOutput(contractId, stateRoot) {
|
2413
2473
|
this.pushOutput({
|
2414
|
-
type:
|
2474
|
+
type: import_transactions9.OutputType.ContractCreated,
|
2415
2475
|
contractId,
|
2416
2476
|
stateRoot
|
2417
2477
|
});
|
2418
2478
|
}
|
2419
2479
|
metadataGas(gasCosts) {
|
2420
2480
|
return calculateMetadataGasForTxCreate({
|
2421
|
-
contractBytesSize: (0,
|
2481
|
+
contractBytesSize: (0, import_math10.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2422
2482
|
gasCosts,
|
2423
2483
|
stateRootSize: this.storageSlots.length,
|
2424
2484
|
txBytesSize: this.byteSize()
|
@@ -2430,8 +2490,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2430
2490
|
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
2431
2491
|
var import_address2 = require("@fuel-ts/address");
|
2432
2492
|
var import_configs9 = require("@fuel-ts/address/configs");
|
2433
|
-
var
|
2434
|
-
var
|
2493
|
+
var import_math11 = require("@fuel-ts/math");
|
2494
|
+
var import_transactions10 = require("@fuel-ts/transactions");
|
2435
2495
|
var import_utils15 = require("@fuel-ts/utils");
|
2436
2496
|
|
2437
2497
|
// src/providers/transaction-request/scripts.ts
|
@@ -2469,7 +2529,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2469
2529
|
return new this(obj);
|
2470
2530
|
}
|
2471
2531
|
/** Type of the transaction */
|
2472
|
-
type =
|
2532
|
+
type = import_transactions10.TransactionType.Script;
|
2473
2533
|
/** Gas limit for transaction */
|
2474
2534
|
gasLimit;
|
2475
2535
|
/** Script to execute */
|
@@ -2484,7 +2544,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2484
2544
|
*/
|
2485
2545
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2486
2546
|
super(rest);
|
2487
|
-
this.gasLimit = (0,
|
2547
|
+
this.gasLimit = (0, import_math11.bn)(gasLimit);
|
2488
2548
|
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2489
2549
|
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2490
2550
|
this.abis = rest.abis;
|
@@ -2498,11 +2558,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2498
2558
|
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2499
2559
|
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2500
2560
|
return {
|
2501
|
-
type:
|
2561
|
+
type: import_transactions10.TransactionType.Script,
|
2502
2562
|
scriptGasLimit: this.gasLimit,
|
2503
2563
|
...super.getBaseTransaction(),
|
2504
|
-
scriptLength: (0,
|
2505
|
-
scriptDataLength: (0,
|
2564
|
+
scriptLength: (0, import_math11.bn)(script.length),
|
2565
|
+
scriptDataLength: (0, import_math11.bn)(scriptData.length),
|
2506
2566
|
receiptsRoot: import_configs9.ZeroBytes32,
|
2507
2567
|
script: (0, import_utils15.hexlify)(script),
|
2508
2568
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
@@ -2515,7 +2575,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2515
2575
|
*/
|
2516
2576
|
getContractInputs() {
|
2517
2577
|
return this.inputs.filter(
|
2518
|
-
(input) => input.type ===
|
2578
|
+
(input) => input.type === import_transactions10.InputType.Contract
|
2519
2579
|
);
|
2520
2580
|
}
|
2521
2581
|
/**
|
@@ -2525,7 +2585,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2525
2585
|
*/
|
2526
2586
|
getContractOutputs() {
|
2527
2587
|
return this.outputs.filter(
|
2528
|
-
(output) => output.type ===
|
2588
|
+
(output) => output.type === import_transactions10.OutputType.Contract
|
2529
2589
|
);
|
2530
2590
|
}
|
2531
2591
|
/**
|
@@ -2535,7 +2595,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2535
2595
|
*/
|
2536
2596
|
getVariableOutputs() {
|
2537
2597
|
return this.outputs.filter(
|
2538
|
-
(output) => output.type ===
|
2598
|
+
(output) => output.type === import_transactions10.OutputType.Variable
|
2539
2599
|
);
|
2540
2600
|
}
|
2541
2601
|
/**
|
@@ -2558,7 +2618,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2558
2618
|
let outputsNumber = numberOfVariables;
|
2559
2619
|
while (outputsNumber) {
|
2560
2620
|
this.pushOutput({
|
2561
|
-
type:
|
2621
|
+
type: import_transactions10.OutputType.Variable
|
2562
2622
|
});
|
2563
2623
|
outputsNumber -= 1;
|
2564
2624
|
}
|
@@ -2595,12 +2655,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2595
2655
|
return this;
|
2596
2656
|
}
|
2597
2657
|
const inputIndex = super.pushInput({
|
2598
|
-
type:
|
2658
|
+
type: import_transactions10.InputType.Contract,
|
2599
2659
|
contractId: contractAddress.toB256(),
|
2600
2660
|
txPointer: "0x00000000000000000000000000000000"
|
2601
2661
|
});
|
2602
2662
|
this.pushOutput({
|
2603
|
-
type:
|
2663
|
+
type: import_transactions10.OutputType.Contract,
|
2604
2664
|
inputIndex
|
2605
2665
|
});
|
2606
2666
|
return this;
|
@@ -2637,17 +2697,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2637
2697
|
|
2638
2698
|
// src/providers/transaction-request/utils.ts
|
2639
2699
|
var import_errors9 = require("@fuel-ts/errors");
|
2640
|
-
var
|
2700
|
+
var import_transactions11 = require("@fuel-ts/transactions");
|
2641
2701
|
var transactionRequestify = (obj) => {
|
2642
2702
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2643
2703
|
return obj;
|
2644
2704
|
}
|
2645
2705
|
const { type } = obj;
|
2646
2706
|
switch (obj.type) {
|
2647
|
-
case
|
2707
|
+
case import_transactions11.TransactionType.Script: {
|
2648
2708
|
return ScriptTransactionRequest.from(obj);
|
2649
2709
|
}
|
2650
|
-
case
|
2710
|
+
case import_transactions11.TransactionType.Create: {
|
2651
2711
|
return CreateTransactionRequest.from(obj);
|
2652
2712
|
}
|
2653
2713
|
default: {
|
@@ -2655,36 +2715,21 @@ var transactionRequestify = (obj) => {
|
|
2655
2715
|
}
|
2656
2716
|
}
|
2657
2717
|
};
|
2658
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2659
|
-
(acc, input) => {
|
2660
|
-
if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
|
2661
|
-
acc.utxos.push(input.id);
|
2662
|
-
}
|
2663
|
-
if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
|
2664
|
-
acc.messages.push(input.nonce);
|
2665
|
-
}
|
2666
|
-
return acc;
|
2667
|
-
},
|
2668
|
-
{
|
2669
|
-
utxos: [],
|
2670
|
-
messages: []
|
2671
|
-
}
|
2672
|
-
);
|
2673
2718
|
|
2674
2719
|
// src/providers/transaction-response/transaction-response.ts
|
2675
2720
|
var import_errors13 = require("@fuel-ts/errors");
|
2676
2721
|
var import_math16 = require("@fuel-ts/math");
|
2677
|
-
var
|
2722
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
2678
2723
|
var import_utils20 = require("@fuel-ts/utils");
|
2679
2724
|
|
2680
2725
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2681
2726
|
var import_math15 = require("@fuel-ts/math");
|
2682
|
-
var
|
2727
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
2683
2728
|
var import_utils18 = require("@fuel-ts/utils");
|
2684
2729
|
|
2685
2730
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2686
|
-
var
|
2687
|
-
var
|
2731
|
+
var import_math12 = require("@fuel-ts/math");
|
2732
|
+
var import_transactions12 = require("@fuel-ts/transactions");
|
2688
2733
|
var import_utils16 = require("@fuel-ts/utils");
|
2689
2734
|
var calculateTXFeeForSummary = (params) => {
|
2690
2735
|
const {
|
@@ -2697,19 +2742,19 @@ var calculateTXFeeForSummary = (params) => {
|
|
2697
2742
|
if (totalFee) {
|
2698
2743
|
return totalFee;
|
2699
2744
|
}
|
2700
|
-
const gasPerByte = (0,
|
2701
|
-
const gasPriceFactor = (0,
|
2745
|
+
const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
|
2746
|
+
const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
|
2702
2747
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2703
|
-
const [transaction] = new
|
2748
|
+
const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
|
2704
2749
|
const { type, witnesses, inputs, policies } = transaction;
|
2705
|
-
let metadataGas = (0,
|
2706
|
-
let gasLimit = (0,
|
2707
|
-
if (type !==
|
2708
|
-
return (0,
|
2750
|
+
let metadataGas = (0, import_math12.bn)(0);
|
2751
|
+
let gasLimit = (0, import_math12.bn)(0);
|
2752
|
+
if (type !== import_transactions12.TransactionType.Create && type !== import_transactions12.TransactionType.Script) {
|
2753
|
+
return (0, import_math12.bn)(0);
|
2709
2754
|
}
|
2710
|
-
if (type ===
|
2755
|
+
if (type === import_transactions12.TransactionType.Create) {
|
2711
2756
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2712
|
-
const contractBytesSize = (0,
|
2757
|
+
const contractBytesSize = (0, import_math12.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2713
2758
|
metadataGas = calculateMetadataGasForTxCreate({
|
2714
2759
|
contractBytesSize,
|
2715
2760
|
gasCosts,
|
@@ -2728,12 +2773,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
2728
2773
|
}
|
2729
2774
|
const minGas = getMinGas({
|
2730
2775
|
gasCosts,
|
2731
|
-
gasPerByte: (0,
|
2776
|
+
gasPerByte: (0, import_math12.bn)(gasPerByte),
|
2732
2777
|
inputs,
|
2733
2778
|
metadataGas,
|
2734
2779
|
txBytesSize: transactionBytes.length
|
2735
2780
|
});
|
2736
|
-
const witnessLimit = policies.find((policy) => policy.type ===
|
2781
|
+
const witnessLimit = policies.find((policy) => policy.type === import_transactions12.PolicyType.WitnessLimit)?.data;
|
2737
2782
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2738
2783
|
const maxGas = getMaxGas({
|
2739
2784
|
gasPerByte,
|
@@ -2756,42 +2801,31 @@ var calculateTXFeeForSummary = (params) => {
|
|
2756
2801
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2757
2802
|
var import_errors11 = require("@fuel-ts/errors");
|
2758
2803
|
var import_math13 = require("@fuel-ts/math");
|
2759
|
-
var
|
2804
|
+
var import_transactions15 = require("@fuel-ts/transactions");
|
2760
2805
|
|
2761
2806
|
// src/providers/transaction-summary/call.ts
|
2762
2807
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
2763
|
-
var
|
2764
|
-
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2808
|
+
var getFunctionCall = ({ abi, receipt }) => {
|
2765
2809
|
const abiInterface = new import_abi_coder4.Interface(abi);
|
2766
2810
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2767
2811
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2768
2812
|
const inputs = functionFragment.jsonFn.inputs;
|
2769
|
-
|
2770
|
-
if (functionFragment.isInputDataPointer) {
|
2771
|
-
if (rawPayload) {
|
2772
|
-
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2773
|
-
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2774
|
-
}
|
2775
|
-
} else {
|
2776
|
-
encodedArgs = receipt.param2.toHex();
|
2777
|
-
}
|
2813
|
+
const encodedArgs = receipt.param2.toHex();
|
2778
2814
|
let argumentsProvided;
|
2779
|
-
|
2780
|
-
|
2781
|
-
|
2782
|
-
|
2783
|
-
|
2784
|
-
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
|
2793
|
-
}, {});
|
2794
|
-
}
|
2815
|
+
const data = functionFragment.decodeArguments(encodedArgs);
|
2816
|
+
if (data) {
|
2817
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
2818
|
+
const value = data[index];
|
2819
|
+
const name = input.name;
|
2820
|
+
if (name) {
|
2821
|
+
return {
|
2822
|
+
...prev,
|
2823
|
+
// reparse to remove bn
|
2824
|
+
[name]: JSON.parse(JSON.stringify(value))
|
2825
|
+
};
|
2826
|
+
}
|
2827
|
+
return prev;
|
2828
|
+
}, {});
|
2795
2829
|
}
|
2796
2830
|
const call = {
|
2797
2831
|
functionSignature: functionFragment.signature,
|
@@ -2804,7 +2838,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2804
2838
|
|
2805
2839
|
// src/providers/transaction-summary/input.ts
|
2806
2840
|
var import_errors10 = require("@fuel-ts/errors");
|
2807
|
-
var
|
2841
|
+
var import_transactions13 = require("@fuel-ts/transactions");
|
2808
2842
|
function getInputsByTypes(inputs, types) {
|
2809
2843
|
return inputs.filter((i) => types.includes(i.type));
|
2810
2844
|
}
|
@@ -2812,16 +2846,16 @@ function getInputsByType(inputs, type) {
|
|
2812
2846
|
return inputs.filter((i) => i.type === type);
|
2813
2847
|
}
|
2814
2848
|
function getInputsCoin(inputs) {
|
2815
|
-
return getInputsByType(inputs,
|
2849
|
+
return getInputsByType(inputs, import_transactions13.InputType.Coin);
|
2816
2850
|
}
|
2817
2851
|
function getInputsMessage(inputs) {
|
2818
|
-
return getInputsByType(inputs,
|
2852
|
+
return getInputsByType(inputs, import_transactions13.InputType.Message);
|
2819
2853
|
}
|
2820
2854
|
function getInputsCoinAndMessage(inputs) {
|
2821
|
-
return getInputsByTypes(inputs, [
|
2855
|
+
return getInputsByTypes(inputs, [import_transactions13.InputType.Coin, import_transactions13.InputType.Message]);
|
2822
2856
|
}
|
2823
2857
|
function getInputsContract(inputs) {
|
2824
|
-
return getInputsByType(inputs,
|
2858
|
+
return getInputsByType(inputs, import_transactions13.InputType.Contract);
|
2825
2859
|
}
|
2826
2860
|
function getInputFromAssetId(inputs, assetId) {
|
2827
2861
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2840,7 +2874,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2840
2874
|
if (!contractInput) {
|
2841
2875
|
return void 0;
|
2842
2876
|
}
|
2843
|
-
if (contractInput.type !==
|
2877
|
+
if (contractInput.type !== import_transactions13.InputType.Contract) {
|
2844
2878
|
throw new import_errors10.FuelError(
|
2845
2879
|
import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
|
2846
2880
|
`Contract input should be of type 'contract'.`
|
@@ -2849,31 +2883,31 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2849
2883
|
return contractInput;
|
2850
2884
|
}
|
2851
2885
|
function getInputAccountAddress(input) {
|
2852
|
-
if (input.type ===
|
2886
|
+
if (input.type === import_transactions13.InputType.Coin) {
|
2853
2887
|
return input.owner.toString();
|
2854
2888
|
}
|
2855
|
-
if (input.type ===
|
2889
|
+
if (input.type === import_transactions13.InputType.Message) {
|
2856
2890
|
return input.recipient.toString();
|
2857
2891
|
}
|
2858
2892
|
return "";
|
2859
2893
|
}
|
2860
2894
|
|
2861
2895
|
// src/providers/transaction-summary/output.ts
|
2862
|
-
var
|
2896
|
+
var import_transactions14 = require("@fuel-ts/transactions");
|
2863
2897
|
function getOutputsByType(outputs, type) {
|
2864
2898
|
return outputs.filter((o) => o.type === type);
|
2865
2899
|
}
|
2866
2900
|
function getOutputsContractCreated(outputs) {
|
2867
|
-
return getOutputsByType(outputs,
|
2901
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.ContractCreated);
|
2868
2902
|
}
|
2869
2903
|
function getOutputsCoin(outputs) {
|
2870
|
-
return getOutputsByType(outputs,
|
2904
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Coin);
|
2871
2905
|
}
|
2872
2906
|
function getOutputsChange(outputs) {
|
2873
|
-
return getOutputsByType(outputs,
|
2907
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Change);
|
2874
2908
|
}
|
2875
2909
|
function getOutputsContract(outputs) {
|
2876
|
-
return getOutputsByType(outputs,
|
2910
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Contract);
|
2877
2911
|
}
|
2878
2912
|
|
2879
2913
|
// src/providers/transaction-summary/operations.ts
|
@@ -2882,11 +2916,11 @@ function getReceiptsByType(receipts, type) {
|
|
2882
2916
|
}
|
2883
2917
|
function getTransactionTypeName(transactionType) {
|
2884
2918
|
switch (transactionType) {
|
2885
|
-
case
|
2919
|
+
case import_transactions15.TransactionType.Mint:
|
2886
2920
|
return "Mint" /* Mint */;
|
2887
|
-
case
|
2921
|
+
case import_transactions15.TransactionType.Create:
|
2888
2922
|
return "Create" /* Create */;
|
2889
|
-
case
|
2923
|
+
case import_transactions15.TransactionType.Script:
|
2890
2924
|
return "Script" /* Script */;
|
2891
2925
|
default:
|
2892
2926
|
throw new import_errors11.FuelError(
|
@@ -2915,10 +2949,10 @@ function isTypeUpload(transactionType) {
|
|
2915
2949
|
return isType(transactionType, "Upload" /* Upload */);
|
2916
2950
|
}
|
2917
2951
|
function getReceiptsCall(receipts) {
|
2918
|
-
return getReceiptsByType(receipts,
|
2952
|
+
return getReceiptsByType(receipts, import_transactions15.ReceiptType.Call);
|
2919
2953
|
}
|
2920
2954
|
function getReceiptsMessageOut(receipts) {
|
2921
|
-
return getReceiptsByType(receipts,
|
2955
|
+
return getReceiptsByType(receipts, import_transactions15.ReceiptType.MessageOut);
|
2922
2956
|
}
|
2923
2957
|
var mergeAssets = (op1, op2) => {
|
2924
2958
|
const assets1 = op1.assetsSent || [];
|
@@ -3114,11 +3148,11 @@ function getTransferOperations({
|
|
3114
3148
|
});
|
3115
3149
|
const transferReceipts = getReceiptsByType(
|
3116
3150
|
receipts,
|
3117
|
-
|
3151
|
+
import_transactions15.ReceiptType.Transfer
|
3118
3152
|
);
|
3119
3153
|
const transferOutReceipts = getReceiptsByType(
|
3120
3154
|
receipts,
|
3121
|
-
|
3155
|
+
import_transactions15.ReceiptType.TransferOut
|
3122
3156
|
);
|
3123
3157
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
3124
3158
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3203,17 +3237,17 @@ function getOperations({
|
|
3203
3237
|
}
|
3204
3238
|
|
3205
3239
|
// src/providers/transaction-summary/receipt.ts
|
3206
|
-
var
|
3240
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
3207
3241
|
var processGqlReceipt = (gqlReceipt) => {
|
3208
3242
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3209
3243
|
switch (receipt.type) {
|
3210
|
-
case
|
3244
|
+
case import_transactions16.ReceiptType.ReturnData: {
|
3211
3245
|
return {
|
3212
3246
|
...receipt,
|
3213
3247
|
data: gqlReceipt.data || "0x"
|
3214
3248
|
};
|
3215
3249
|
}
|
3216
|
-
case
|
3250
|
+
case import_transactions16.ReceiptType.LogData: {
|
3217
3251
|
return {
|
3218
3252
|
...receipt,
|
3219
3253
|
data: gqlReceipt.data || "0x"
|
@@ -3226,7 +3260,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3226
3260
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3227
3261
|
const mintedAssets = [];
|
3228
3262
|
receipts.forEach((receipt) => {
|
3229
|
-
if (receipt.type ===
|
3263
|
+
if (receipt.type === import_transactions16.ReceiptType.Mint) {
|
3230
3264
|
mintedAssets.push({
|
3231
3265
|
subId: receipt.subId,
|
3232
3266
|
contractId: receipt.contractId,
|
@@ -3240,7 +3274,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3240
3274
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3241
3275
|
const burnedAssets = [];
|
3242
3276
|
receipts.forEach((receipt) => {
|
3243
|
-
if (receipt.type ===
|
3277
|
+
if (receipt.type === import_transactions16.ReceiptType.Burn) {
|
3244
3278
|
burnedAssets.push({
|
3245
3279
|
subId: receipt.subId,
|
3246
3280
|
contractId: receipt.contractId,
|
@@ -3346,7 +3380,7 @@ function assembleTransactionSummary(params) {
|
|
3346
3380
|
maxInputs
|
3347
3381
|
});
|
3348
3382
|
const typeName = getTransactionTypeName(transaction.type);
|
3349
|
-
const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type ===
|
3383
|
+
const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
3350
3384
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3351
3385
|
const fee = calculateTXFeeForSummary({
|
3352
3386
|
totalFee,
|
@@ -3397,12 +3431,12 @@ function assembleTransactionSummary(params) {
|
|
3397
3431
|
|
3398
3432
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3399
3433
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
3400
|
-
var
|
3434
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
3401
3435
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3402
3436
|
return receipts.reduce((logs, receipt) => {
|
3403
|
-
if (receipt.type ===
|
3437
|
+
if (receipt.type === import_transactions18.ReceiptType.LogData || receipt.type === import_transactions18.ReceiptType.Log) {
|
3404
3438
|
const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
|
3405
|
-
const data = receipt.type ===
|
3439
|
+
const data = receipt.type === import_transactions18.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3406
3440
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3407
3441
|
logs.push(decodedLog);
|
3408
3442
|
}
|
@@ -3475,7 +3509,7 @@ var TransactionResponse = class {
|
|
3475
3509
|
* @returns The decoded transaction.
|
3476
3510
|
*/
|
3477
3511
|
decodeTransaction(transactionWithReceipts) {
|
3478
|
-
return new
|
3512
|
+
return new import_transactions19.TransactionCoder().decode(
|
3479
3513
|
(0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
|
3480
3514
|
0
|
3481
3515
|
)?.[0];
|
@@ -3825,9 +3859,11 @@ var _Provider = class {
|
|
3825
3859
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3826
3860
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
3827
3861
|
if (!isMajorSupported || !isMinorSupported) {
|
3828
|
-
|
3829
|
-
|
3830
|
-
|
3862
|
+
console.warn(
|
3863
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
|
3864
|
+
which is not supported by the version of the TS SDK that you are using.
|
3865
|
+
Things may not work as expected.
|
3866
|
+
Supported fuel-core version: ${supportedVersion}.`
|
3831
3867
|
);
|
3832
3868
|
}
|
3833
3869
|
}
|
@@ -3954,7 +3990,7 @@ var _Provider = class {
|
|
3954
3990
|
}
|
3955
3991
|
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3956
3992
|
let abis;
|
3957
|
-
if (transactionRequest.type ===
|
3993
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
3958
3994
|
abis = transactionRequest.abis;
|
3959
3995
|
}
|
3960
3996
|
if (awaitExecution) {
|
@@ -4046,7 +4082,7 @@ var _Provider = class {
|
|
4046
4082
|
* @returns A promise.
|
4047
4083
|
*/
|
4048
4084
|
async estimateTxDependencies(transactionRequest) {
|
4049
|
-
if (transactionRequest.type ===
|
4085
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Create) {
|
4050
4086
|
return {
|
4051
4087
|
receipts: [],
|
4052
4088
|
outputVariables: 0,
|
@@ -4110,7 +4146,7 @@ var _Provider = class {
|
|
4110
4146
|
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4111
4147
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4112
4148
|
allRequests.forEach((req, index) => {
|
4113
|
-
if (req.type ===
|
4149
|
+
if (req.type === import_transactions20.TransactionType.Script) {
|
4114
4150
|
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4115
4151
|
}
|
4116
4152
|
});
|
@@ -4136,7 +4172,7 @@ var _Provider = class {
|
|
4136
4172
|
);
|
4137
4173
|
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4138
4174
|
const request = allRequests[requestIdx];
|
4139
|
-
if (hasMissingOutputs && request?.type ===
|
4175
|
+
if (hasMissingOutputs && request?.type === import_transactions20.TransactionType.Script) {
|
4140
4176
|
result.outputVariables += missingOutputVariables.length;
|
4141
4177
|
request.addVariableOutputs(missingOutputVariables.length);
|
4142
4178
|
missingOutputContractIds.forEach(({ contractId }) => {
|
@@ -4192,7 +4228,7 @@ var _Provider = class {
|
|
4192
4228
|
tip: transactionRequest.tip
|
4193
4229
|
}).add(1);
|
4194
4230
|
let gasLimit = (0, import_math17.bn)(0);
|
4195
|
-
if (transactionRequest.type ===
|
4231
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4196
4232
|
gasLimit = transactionRequest.gasLimit;
|
4197
4233
|
if (transactionRequest.gasLimit.eq(0)) {
|
4198
4234
|
transactionRequest.gasLimit = minGas;
|
@@ -4262,12 +4298,12 @@ var _Provider = class {
|
|
4262
4298
|
*/
|
4263
4299
|
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
4264
4300
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4265
|
-
const isScriptTransaction = txRequestClone.type ===
|
4301
|
+
const isScriptTransaction = txRequestClone.type === import_transactions20.TransactionType.Script;
|
4266
4302
|
const baseAssetId = this.getBaseAssetId();
|
4303
|
+
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4267
4304
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4268
4305
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4269
4306
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4270
|
-
txRequestClone.maxFee = (0, import_math17.bn)(0);
|
4271
4307
|
if (isScriptTransaction) {
|
4272
4308
|
txRequestClone.gasLimit = (0, import_math17.bn)(0);
|
4273
4309
|
}
|
@@ -4282,6 +4318,7 @@ var _Provider = class {
|
|
4282
4318
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4283
4319
|
}
|
4284
4320
|
await this.estimatePredicates(signedRequest);
|
4321
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4285
4322
|
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4286
4323
|
transactionRequest: signedRequest
|
4287
4324
|
});
|
@@ -4290,7 +4327,6 @@ var _Provider = class {
|
|
4290
4327
|
let missingContractIds = [];
|
4291
4328
|
let outputVariables = 0;
|
4292
4329
|
let gasUsed = (0, import_math17.bn)(0);
|
4293
|
-
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4294
4330
|
txRequestClone.maxFee = maxFee;
|
4295
4331
|
if (isScriptTransaction) {
|
4296
4332
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4318,7 +4354,8 @@ var _Provider = class {
|
|
4318
4354
|
missingContractIds,
|
4319
4355
|
addedSignatures,
|
4320
4356
|
estimatedPredicates: txRequestClone.inputs,
|
4321
|
-
dryRunStatus
|
4357
|
+
dryRunStatus,
|
4358
|
+
updateMaxFee
|
4322
4359
|
};
|
4323
4360
|
}
|
4324
4361
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4391,7 +4428,7 @@ var _Provider = class {
|
|
4391
4428
|
};
|
4392
4429
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
4393
4430
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
4394
|
-
switch (coin.
|
4431
|
+
switch (coin.type) {
|
4395
4432
|
case "MessageCoin":
|
4396
4433
|
return {
|
4397
4434
|
amount: (0, import_math17.bn)(coin.amount),
|
@@ -4485,7 +4522,7 @@ var _Provider = class {
|
|
4485
4522
|
time: block.header.time,
|
4486
4523
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4487
4524
|
transactions: block.transactions.map(
|
4488
|
-
(tx) => new
|
4525
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4489
4526
|
)
|
4490
4527
|
};
|
4491
4528
|
}
|
@@ -4500,7 +4537,7 @@ var _Provider = class {
|
|
4500
4537
|
if (!transaction) {
|
4501
4538
|
return null;
|
4502
4539
|
}
|
4503
|
-
return new
|
4540
|
+
return new import_transactions20.TransactionCoder().decode(
|
4504
4541
|
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4505
4542
|
0
|
4506
4543
|
)?.[0];
|
@@ -4580,7 +4617,7 @@ var _Provider = class {
|
|
4580
4617
|
});
|
4581
4618
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4582
4619
|
return messages.map((message) => ({
|
4583
|
-
messageId:
|
4620
|
+
messageId: import_transactions20.InputMessageCoder.getMessageId({
|
4584
4621
|
sender: message.sender,
|
4585
4622
|
recipient: message.recipient,
|
4586
4623
|
nonce: message.nonce,
|
@@ -4591,7 +4628,7 @@ var _Provider = class {
|
|
4591
4628
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4592
4629
|
nonce: message.nonce,
|
4593
4630
|
amount: (0, import_math17.bn)(message.amount),
|
4594
|
-
data:
|
4631
|
+
data: import_transactions20.InputMessageCoder.decodeData(message.data),
|
4595
4632
|
daHeight: (0, import_math17.bn)(message.daHeight)
|
4596
4633
|
}));
|
4597
4634
|
}
|
@@ -4757,7 +4794,7 @@ cacheInputs_fn = function(inputs) {
|
|
4757
4794
|
return;
|
4758
4795
|
}
|
4759
4796
|
inputs.forEach((input) => {
|
4760
|
-
if (input.type ===
|
4797
|
+
if (input.type === import_transactions20.InputType.Coin) {
|
4761
4798
|
this.cache?.set(input.id);
|
4762
4799
|
}
|
4763
4800
|
});
|
@@ -4768,7 +4805,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4768
4805
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4769
4806
|
var import_errors15 = require("@fuel-ts/errors");
|
4770
4807
|
var import_math18 = require("@fuel-ts/math");
|
4771
|
-
var
|
4808
|
+
var import_transactions21 = require("@fuel-ts/transactions");
|
4772
4809
|
var import_utils25 = require("@fuel-ts/utils");
|
4773
4810
|
|
4774
4811
|
// src/providers/chains.ts
|
@@ -4783,8 +4820,33 @@ var CHAIN_IDS = {
|
|
4783
4820
|
}
|
4784
4821
|
};
|
4785
4822
|
|
4786
|
-
// src/providers/assets/
|
4787
|
-
var
|
4823
|
+
// src/providers/assets/utils/url.ts
|
4824
|
+
var DELIMITER_PATH = "/";
|
4825
|
+
var trimRegex = /^\/|\/$/g;
|
4826
|
+
var trimPath = (path2 = "") => path2.replace(trimRegex, "");
|
4827
|
+
function urlJoin(baseUrl, ...paths) {
|
4828
|
+
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
4829
|
+
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
4830
|
+
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
4831
|
+
if (rootPath && hasBaseUrl) {
|
4832
|
+
allPaths.unshift("");
|
4833
|
+
}
|
4834
|
+
return allPaths.join(DELIMITER_PATH);
|
4835
|
+
}
|
4836
|
+
|
4837
|
+
// src/providers/assets/utils/resolveIconPaths.ts
|
4838
|
+
function resolveIconPaths(assets2, basePath = "./") {
|
4839
|
+
return assets2.map((asset) => ({
|
4840
|
+
...asset,
|
4841
|
+
icon: urlJoin(basePath, asset.icon)
|
4842
|
+
}));
|
4843
|
+
}
|
4844
|
+
|
4845
|
+
// src/providers/assets/utils/fuelAssetsBaseUrl.ts
|
4846
|
+
var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
|
4847
|
+
|
4848
|
+
// src/providers/assets/assets.ts
|
4849
|
+
var rawAssets = [
|
4788
4850
|
{
|
4789
4851
|
name: "Ethereum",
|
4790
4852
|
symbol: "ETH",
|
@@ -4815,36 +4877,21 @@ var assets = [
|
|
4815
4877
|
]
|
4816
4878
|
}
|
4817
4879
|
];
|
4818
|
-
|
4819
|
-
// src/providers/transaction-request/helpers.ts
|
4820
|
-
var import_math19 = require("@fuel-ts/math");
|
4821
|
-
var import_transactions21 = require("@fuel-ts/transactions");
|
4822
|
-
var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
|
4823
|
-
var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
|
4824
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
4825
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
4826
|
-
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
4827
|
-
return acc.add(input.amount);
|
4828
|
-
}
|
4829
|
-
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
4830
|
-
return acc.add(input.amount);
|
4831
|
-
}
|
4832
|
-
return acc;
|
4833
|
-
}, (0, import_math19.bn)(0));
|
4880
|
+
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
4834
4881
|
|
4835
4882
|
// src/utils/formatTransferToContractScriptData.ts
|
4836
4883
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4837
|
-
var
|
4838
|
-
var
|
4884
|
+
var import_math19 = require("@fuel-ts/math");
|
4885
|
+
var import_utils27 = require("@fuel-ts/utils");
|
4839
4886
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4840
4887
|
var formatTransferToContractScriptData = (params) => {
|
4841
4888
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4842
4889
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
4843
|
-
const encoded = numberCoder.encode(new
|
4890
|
+
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
4844
4891
|
const scriptData = Uint8Array.from([
|
4845
|
-
...(0,
|
4892
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
4846
4893
|
...encoded,
|
4847
|
-
...(0,
|
4894
|
+
...(0, import_utils27.arrayify)(assetId)
|
4848
4895
|
]);
|
4849
4896
|
return scriptData;
|
4850
4897
|
};
|
@@ -5024,20 +5071,20 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5024
5071
|
return balances;
|
5025
5072
|
}
|
5026
5073
|
/**
|
5027
|
-
*
|
5074
|
+
* Funds a transaction request by adding the necessary resources.
|
5028
5075
|
*
|
5029
|
-
* @
|
5030
|
-
* @param
|
5031
|
-
* @param
|
5032
|
-
* @returns
|
5076
|
+
* @typeParam T - The type of the TransactionRequest.
|
5077
|
+
* @param request - The transaction request to fund.
|
5078
|
+
* @param params - The estimated transaction parameters.
|
5079
|
+
* @returns The funded transaction request.
|
5033
5080
|
*/
|
5034
5081
|
async fund(request, params) {
|
5035
|
-
const { addedSignatures, estimatedPredicates,
|
5082
|
+
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5083
|
+
const fee = request.maxFee;
|
5036
5084
|
const baseAssetId = this.provider.getBaseAssetId();
|
5037
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0,
|
5038
|
-
const txRequest = request;
|
5085
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
|
5039
5086
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5040
|
-
amount: (0,
|
5087
|
+
amount: (0, import_math20.bn)(fee),
|
5041
5088
|
assetId: baseAssetId,
|
5042
5089
|
coinQuantities: requiredQuantities
|
5043
5090
|
});
|
@@ -5045,7 +5092,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5045
5092
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5046
5093
|
quantitiesDict[assetId] = {
|
5047
5094
|
required: amount,
|
5048
|
-
owned: (0,
|
5095
|
+
owned: (0, import_math20.bn)(0)
|
5049
5096
|
};
|
5050
5097
|
});
|
5051
5098
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5069,17 +5116,19 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5069
5116
|
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5070
5117
|
const resources = await this.getResourcesToSpend(
|
5071
5118
|
missingQuantities,
|
5072
|
-
|
5119
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5073
5120
|
);
|
5074
5121
|
request.addResources(resources);
|
5075
|
-
|
5076
|
-
|
5077
|
-
const requestToReestimate2 = (0, import_ramda4.clone)(txRequest);
|
5122
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5123
|
+
const requestToReestimate2 = (0, import_ramda4.clone)(request);
|
5078
5124
|
if (addedSignatures) {
|
5079
5125
|
Array.from({ length: addedSignatures }).forEach(
|
5080
5126
|
() => requestToReestimate2.addEmptyWitness()
|
5081
5127
|
);
|
5082
5128
|
}
|
5129
|
+
if (!updateMaxFee) {
|
5130
|
+
break;
|
5131
|
+
}
|
5083
5132
|
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5084
5133
|
transactionRequest: requestToReestimate2
|
5085
5134
|
});
|
@@ -5101,17 +5150,19 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5101
5150
|
}
|
5102
5151
|
fundingAttempts += 1;
|
5103
5152
|
}
|
5104
|
-
|
5105
|
-
|
5106
|
-
const requestToReestimate = (0, import_ramda4.clone)(txRequest);
|
5153
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5154
|
+
const requestToReestimate = (0, import_ramda4.clone)(request);
|
5107
5155
|
if (addedSignatures) {
|
5108
5156
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
5109
5157
|
}
|
5158
|
+
if (!updateMaxFee) {
|
5159
|
+
return request;
|
5160
|
+
}
|
5110
5161
|
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5111
5162
|
transactionRequest: requestToReestimate
|
5112
5163
|
});
|
5113
|
-
|
5114
|
-
return
|
5164
|
+
request.maxFee = maxFee;
|
5165
|
+
return request;
|
5115
5166
|
}
|
5116
5167
|
/**
|
5117
5168
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5123,20 +5174,19 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5123
5174
|
* @returns A promise that resolves to the prepared transaction request.
|
5124
5175
|
*/
|
5125
5176
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
5126
|
-
|
5177
|
+
let request = new ScriptTransactionRequest(txParams);
|
5127
5178
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5128
5179
|
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
5129
5180
|
const txCost = await this.provider.getTransactionCost(request, {
|
5130
5181
|
estimateTxDependencies: true,
|
5131
5182
|
resourcesOwner: this
|
5132
5183
|
});
|
5133
|
-
this.validateGasLimitAndMaxFee({
|
5184
|
+
request = this.validateGasLimitAndMaxFee({
|
5185
|
+
transactionRequest: request,
|
5134
5186
|
gasUsed: txCost.gasUsed,
|
5135
5187
|
maxFee: txCost.maxFee,
|
5136
5188
|
txParams
|
5137
5189
|
});
|
5138
|
-
request.gasLimit = txCost.gasUsed;
|
5139
|
-
request.maxFee = txCost.maxFee;
|
5140
5190
|
await this.fund(request, txCost);
|
5141
5191
|
return request;
|
5142
5192
|
}
|
@@ -5150,7 +5200,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5150
5200
|
* @returns A promise that resolves to the transaction response.
|
5151
5201
|
*/
|
5152
5202
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5153
|
-
if ((0,
|
5203
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5154
5204
|
throw new import_errors16.FuelError(
|
5155
5205
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5156
5206
|
"Transfer amount must be a positive number."
|
@@ -5170,7 +5220,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5170
5220
|
* @returns A promise that resolves to the transaction response.
|
5171
5221
|
*/
|
5172
5222
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5173
|
-
if ((0,
|
5223
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5174
5224
|
throw new import_errors16.FuelError(
|
5175
5225
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5176
5226
|
"Transfer amount must be a positive number."
|
@@ -5180,10 +5230,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5180
5230
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5181
5231
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5182
5232
|
hexlifiedContractId: contractAddress.toB256(),
|
5183
|
-
amountToTransfer: (0,
|
5233
|
+
amountToTransfer: (0, import_math20.bn)(amount),
|
5184
5234
|
assetId: assetIdToTransfer
|
5185
5235
|
});
|
5186
|
-
|
5236
|
+
let request = new ScriptTransactionRequest({
|
5187
5237
|
...txParams,
|
5188
5238
|
script,
|
5189
5239
|
scriptData
|
@@ -5191,15 +5241,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5191
5241
|
request.addContractInputAndOutput(contractAddress);
|
5192
5242
|
const txCost = await this.provider.getTransactionCost(request, {
|
5193
5243
|
resourcesOwner: this,
|
5194
|
-
quantitiesToContract: [{ amount: (0,
|
5244
|
+
quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5195
5245
|
});
|
5196
|
-
this.validateGasLimitAndMaxFee({
|
5246
|
+
request = this.validateGasLimitAndMaxFee({
|
5247
|
+
transactionRequest: request,
|
5197
5248
|
gasUsed: txCost.gasUsed,
|
5198
5249
|
maxFee: txCost.maxFee,
|
5199
5250
|
txParams
|
5200
5251
|
});
|
5201
|
-
request.gasLimit = txCost.gasUsed;
|
5202
|
-
request.maxFee = txCost.maxFee;
|
5203
5252
|
await this.fund(request, txCost);
|
5204
5253
|
return this.sendTransaction(request);
|
5205
5254
|
}
|
@@ -5213,29 +5262,28 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5213
5262
|
*/
|
5214
5263
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5215
5264
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5216
|
-
const recipientDataArray = (0,
|
5265
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5217
5266
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5218
5267
|
);
|
5219
|
-
const amountDataArray = (0,
|
5220
|
-
"0x".concat((0,
|
5268
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5269
|
+
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5221
5270
|
);
|
5222
5271
|
const script = new Uint8Array([
|
5223
|
-
...(0,
|
5272
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5224
5273
|
...recipientDataArray,
|
5225
5274
|
...amountDataArray
|
5226
5275
|
]);
|
5227
5276
|
const params = { script, ...txParams };
|
5228
5277
|
const baseAssetId = this.provider.getBaseAssetId();
|
5229
|
-
|
5230
|
-
const quantitiesToContract = [{ amount: (0,
|
5278
|
+
let request = new ScriptTransactionRequest(params);
|
5279
|
+
const quantitiesToContract = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
|
5231
5280
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5232
|
-
this.validateGasLimitAndMaxFee({
|
5281
|
+
request = this.validateGasLimitAndMaxFee({
|
5282
|
+
transactionRequest: request,
|
5233
5283
|
gasUsed: txCost.gasUsed,
|
5234
5284
|
maxFee: txCost.maxFee,
|
5235
5285
|
txParams
|
5236
5286
|
});
|
5237
|
-
request.maxFee = txCost.maxFee;
|
5238
|
-
request.gasLimit = txCost.gasUsed;
|
5239
5287
|
await this.fund(request, txCost);
|
5240
5288
|
return this.sendTransaction(request);
|
5241
5289
|
}
|
@@ -5295,22 +5343,29 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5295
5343
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5296
5344
|
}
|
5297
5345
|
validateGasLimitAndMaxFee({
|
5298
|
-
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
5299
5346
|
gasUsed,
|
5300
|
-
maxFee
|
5347
|
+
maxFee,
|
5348
|
+
transactionRequest,
|
5349
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5301
5350
|
}) {
|
5302
|
-
|
5351
|
+
const request = transactionRequestify(transactionRequest);
|
5352
|
+
if (!(0, import_utils28.isDefined)(setGasLimit)) {
|
5353
|
+
request.gasLimit = gasUsed;
|
5354
|
+
} else if (gasUsed.gt(setGasLimit)) {
|
5303
5355
|
throw new import_errors16.FuelError(
|
5304
5356
|
import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
|
5305
5357
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5306
5358
|
);
|
5307
5359
|
}
|
5308
|
-
if ((0,
|
5360
|
+
if (!(0, import_utils28.isDefined)(setMaxFee)) {
|
5361
|
+
request.maxFee = maxFee;
|
5362
|
+
} else if (maxFee.gt(setMaxFee)) {
|
5309
5363
|
throw new import_errors16.FuelError(
|
5310
5364
|
import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
|
5311
5365
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
5312
5366
|
);
|
5313
5367
|
}
|
5368
|
+
return request;
|
5314
5369
|
}
|
5315
5370
|
};
|
5316
5371
|
|
@@ -5318,8 +5373,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5318
5373
|
var import_address5 = require("@fuel-ts/address");
|
5319
5374
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5320
5375
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5321
|
-
var
|
5322
|
-
var
|
5376
|
+
var import_math21 = require("@fuel-ts/math");
|
5377
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5323
5378
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5324
5379
|
var Signer = class {
|
5325
5380
|
address;
|
@@ -5338,10 +5393,10 @@ var Signer = class {
|
|
5338
5393
|
privateKey = `0x${privateKey}`;
|
5339
5394
|
}
|
5340
5395
|
}
|
5341
|
-
const privateKeyBytes = (0,
|
5342
|
-
this.privateKey = (0,
|
5343
|
-
this.publicKey = (0,
|
5344
|
-
this.compressedPublicKey = (0,
|
5396
|
+
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
5397
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5398
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5399
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5345
5400
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5346
5401
|
}
|
5347
5402
|
/**
|
@@ -5355,11 +5410,11 @@ var Signer = class {
|
|
5355
5410
|
* @returns hashed signature
|
5356
5411
|
*/
|
5357
5412
|
sign(data) {
|
5358
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5359
|
-
const r = (0,
|
5360
|
-
const s = (0,
|
5413
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5414
|
+
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5415
|
+
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5361
5416
|
s[0] |= (signature.recovery || 0) << 7;
|
5362
|
-
return (0,
|
5417
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5363
5418
|
}
|
5364
5419
|
/**
|
5365
5420
|
* Add point on the current elliptic curve
|
@@ -5368,8 +5423,8 @@ var Signer = class {
|
|
5368
5423
|
* @returns compressed point on the curve
|
5369
5424
|
*/
|
5370
5425
|
addPoint(point) {
|
5371
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5372
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5426
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5427
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5373
5428
|
const result = p0.add(p1);
|
5374
5429
|
return `0x${result.toHex(true)}`;
|
5375
5430
|
}
|
@@ -5381,16 +5436,16 @@ var Signer = class {
|
|
5381
5436
|
* @returns public key from signature from the
|
5382
5437
|
*/
|
5383
5438
|
static recoverPublicKey(data, signature) {
|
5384
|
-
const signedMessageBytes = (0,
|
5439
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5385
5440
|
const r = signedMessageBytes.slice(0, 32);
|
5386
5441
|
const s = signedMessageBytes.slice(32, 64);
|
5387
5442
|
const recoveryParam = (s[0] & 128) >> 7;
|
5388
5443
|
s[0] &= 127;
|
5389
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5444
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5390
5445
|
recoveryParam
|
5391
5446
|
);
|
5392
|
-
const publicKey = sig.recoverPublicKey((0,
|
5393
|
-
return (0,
|
5447
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5448
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5394
5449
|
}
|
5395
5450
|
/**
|
5396
5451
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5409,7 +5464,7 @@ var Signer = class {
|
|
5409
5464
|
* @returns random 32-byte hashed
|
5410
5465
|
*/
|
5411
5466
|
static generatePrivateKey(entropy) {
|
5412
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5467
|
+
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
5468
|
}
|
5414
5469
|
/**
|
5415
5470
|
* Extended publicKey from a compact publicKey
|
@@ -5418,8 +5473,8 @@ var Signer = class {
|
|
5418
5473
|
* @returns extended publicKey
|
5419
5474
|
*/
|
5420
5475
|
static extendPublicKey(publicKey) {
|
5421
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5422
|
-
return (0,
|
5476
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5477
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5423
5478
|
}
|
5424
5479
|
};
|
5425
5480
|
|
@@ -5427,7 +5482,7 @@ var Signer = class {
|
|
5427
5482
|
var import_address6 = require("@fuel-ts/address");
|
5428
5483
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5429
5484
|
var import_errors17 = require("@fuel-ts/errors");
|
5430
|
-
var
|
5485
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5431
5486
|
var import_uuid = require("uuid");
|
5432
5487
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5433
5488
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5510,7 +5565,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5510
5565
|
);
|
5511
5566
|
}
|
5512
5567
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5513
|
-
const privateKey = (0,
|
5568
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5514
5569
|
return privateKey;
|
5515
5570
|
}
|
5516
5571
|
|
@@ -5555,7 +5610,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5555
5610
|
*/
|
5556
5611
|
async signMessage(message) {
|
5557
5612
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5558
|
-
return (0,
|
5613
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
5559
5614
|
}
|
5560
5615
|
/**
|
5561
5616
|
* Signs a transaction with the wallet's private key.
|
@@ -5568,7 +5623,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5568
5623
|
const chainId = this.provider.getChainId();
|
5569
5624
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5570
5625
|
const signature = await this.signer().sign(hashedTransaction);
|
5571
|
-
return (0,
|
5626
|
+
return (0, import_utils31.hexlify)(signature);
|
5572
5627
|
}
|
5573
5628
|
/**
|
5574
5629
|
* Populates a transaction with the witnesses signature.
|
@@ -5627,18 +5682,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
5627
5682
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5628
5683
|
|
5629
5684
|
// src/hdwallet/hdwallet.ts
|
5685
|
+
var import_crypto5 = require("@fuel-ts/crypto");
|
5630
5686
|
var import_errors20 = require("@fuel-ts/errors");
|
5631
5687
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5632
|
-
var
|
5633
|
-
var
|
5634
|
-
var import_ethers2 = require("ethers");
|
5688
|
+
var import_math22 = require("@fuel-ts/math");
|
5689
|
+
var import_utils35 = require("@fuel-ts/utils");
|
5635
5690
|
|
5636
5691
|
// src/mnemonic/mnemonic.ts
|
5637
5692
|
var import_crypto4 = require("@fuel-ts/crypto");
|
5638
5693
|
var import_errors19 = require("@fuel-ts/errors");
|
5639
5694
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5640
|
-
var
|
5641
|
-
var import_ethers = require("ethers");
|
5695
|
+
var import_utils33 = require("@fuel-ts/utils");
|
5642
5696
|
|
5643
5697
|
// src/wordlists/words/english.ts
|
5644
5698
|
var english = [
|
@@ -7695,39 +7749,7 @@ var english = [
|
|
7695
7749
|
// src/mnemonic/utils.ts
|
7696
7750
|
var import_errors18 = require("@fuel-ts/errors");
|
7697
7751
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7698
|
-
var
|
7699
|
-
function toUtf8Bytes(stri) {
|
7700
|
-
const str = stri.normalize("NFKD");
|
7701
|
-
const result = [];
|
7702
|
-
for (let i = 0; i < str.length; i += 1) {
|
7703
|
-
const c = str.charCodeAt(i);
|
7704
|
-
if (c < 128) {
|
7705
|
-
result.push(c);
|
7706
|
-
} else if (c < 2048) {
|
7707
|
-
result.push(c >> 6 | 192);
|
7708
|
-
result.push(c & 63 | 128);
|
7709
|
-
} else if ((c & 64512) === 55296) {
|
7710
|
-
i += 1;
|
7711
|
-
const c2 = str.charCodeAt(i);
|
7712
|
-
if (i >= str.length || (c2 & 64512) !== 56320) {
|
7713
|
-
throw new import_errors18.FuelError(
|
7714
|
-
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
7715
|
-
"Invalid UTF-8 in the input string."
|
7716
|
-
);
|
7717
|
-
}
|
7718
|
-
const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
|
7719
|
-
result.push(pair >> 18 | 240);
|
7720
|
-
result.push(pair >> 12 & 63 | 128);
|
7721
|
-
result.push(pair >> 6 & 63 | 128);
|
7722
|
-
result.push(pair & 63 | 128);
|
7723
|
-
} else {
|
7724
|
-
result.push(c >> 12 | 224);
|
7725
|
-
result.push(c >> 6 & 63 | 128);
|
7726
|
-
result.push(c & 63 | 128);
|
7727
|
-
}
|
7728
|
-
}
|
7729
|
-
return Uint8Array.from(result);
|
7730
|
-
}
|
7752
|
+
var import_utils32 = require("@fuel-ts/utils");
|
7731
7753
|
function getLowerMask(bits) {
|
7732
7754
|
return (1 << bits) - 1;
|
7733
7755
|
}
|
@@ -7762,14 +7784,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7762
7784
|
}
|
7763
7785
|
}
|
7764
7786
|
const checksumBits = entropy.length / 4;
|
7765
|
-
const checksum = (0,
|
7787
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7766
7788
|
indices[indices.length - 1] <<= checksumBits;
|
7767
7789
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7768
7790
|
return indices;
|
7769
7791
|
}
|
7770
7792
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7771
7793
|
const size = Math.ceil(11 * words.length / 8);
|
7772
|
-
const entropy = (0,
|
7794
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
7773
7795
|
let offset = 0;
|
7774
7796
|
for (let i = 0; i < words.length; i += 1) {
|
7775
7797
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7789,7 +7811,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7789
7811
|
const entropyBits = 32 * words.length / 3;
|
7790
7812
|
const checksumBits = words.length / 3;
|
7791
7813
|
const checksumMask = getUpperMask(checksumBits);
|
7792
|
-
const checksum = (0,
|
7814
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7793
7815
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7794
7816
|
throw new import_errors18.FuelError(
|
7795
7817
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -7800,7 +7822,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7800
7822
|
}
|
7801
7823
|
|
7802
7824
|
// src/mnemonic/mnemonic.ts
|
7803
|
-
var MasterSecret = toUtf8Bytes("Bitcoin seed");
|
7825
|
+
var MasterSecret = (0, import_utils33.toUtf8Bytes)("Bitcoin seed");
|
7804
7826
|
var MainnetPRV = "0x0488ade4";
|
7805
7827
|
var TestnetPRV = "0x04358394";
|
7806
7828
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
@@ -7864,7 +7886,7 @@ var Mnemonic = class {
|
|
7864
7886
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7865
7887
|
const words = getWords(phrase);
|
7866
7888
|
assertMnemonic(words);
|
7867
|
-
return (0,
|
7889
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7868
7890
|
}
|
7869
7891
|
/**
|
7870
7892
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7872,7 +7894,7 @@ var Mnemonic = class {
|
|
7872
7894
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7873
7895
|
*/
|
7874
7896
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7875
|
-
const entropyBytes = (0,
|
7897
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
7876
7898
|
assertWordList(wordlist);
|
7877
7899
|
assertEntropy(entropyBytes);
|
7878
7900
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7884,9 +7906,9 @@ var Mnemonic = class {
|
|
7884
7906
|
*/
|
7885
7907
|
static mnemonicToSeed(phrase, passphrase = "") {
|
7886
7908
|
assertMnemonic(getWords(phrase));
|
7887
|
-
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7888
|
-
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7889
|
-
return (0,
|
7909
|
+
const phraseBytes = (0, import_utils33.toUtf8Bytes)(getPhrase(phrase));
|
7910
|
+
const salt = (0, import_utils33.toUtf8Bytes)(`mnemonic${passphrase}`);
|
7911
|
+
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7890
7912
|
}
|
7891
7913
|
/**
|
7892
7914
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7941,14 +7963,14 @@ var Mnemonic = class {
|
|
7941
7963
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7942
7964
|
*/
|
7943
7965
|
static masterKeysFromSeed(seed) {
|
7944
|
-
const seedArray = (0,
|
7966
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
7945
7967
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7946
7968
|
throw new import_errors19.FuelError(
|
7947
7969
|
import_errors19.ErrorCode.INVALID_SEED,
|
7948
7970
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7949
7971
|
);
|
7950
7972
|
}
|
7951
|
-
return (0,
|
7973
|
+
return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
|
7952
7974
|
}
|
7953
7975
|
/**
|
7954
7976
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7959,22 +7981,22 @@ var Mnemonic = class {
|
|
7959
7981
|
*/
|
7960
7982
|
static seedToExtendedKey(seed, testnet = false) {
|
7961
7983
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7962
|
-
const prefix = (0,
|
7984
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7963
7985
|
const depth = "0x00";
|
7964
7986
|
const fingerprint = "0x00000000";
|
7965
7987
|
const index = "0x00000000";
|
7966
7988
|
const chainCode = masterKey.slice(32);
|
7967
7989
|
const privateKey = masterKey.slice(0, 32);
|
7968
|
-
const extendedKey = (0,
|
7990
|
+
const extendedKey = (0, import_utils33.concat)([
|
7969
7991
|
prefix,
|
7970
7992
|
depth,
|
7971
7993
|
fingerprint,
|
7972
7994
|
index,
|
7973
7995
|
chainCode,
|
7974
|
-
(0,
|
7996
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
7975
7997
|
]);
|
7976
|
-
const checksum = (0,
|
7977
|
-
return (0,
|
7998
|
+
const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7999
|
+
return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
7978
8000
|
}
|
7979
8001
|
/**
|
7980
8002
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7989,7 +8011,7 @@ var Mnemonic = class {
|
|
7989
8011
|
* @returns A randomly generated mnemonic
|
7990
8012
|
*/
|
7991
8013
|
static generate(size = 32, extraEntropy = "") {
|
7992
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8014
|
+
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
8015
|
return Mnemonic.entropyToMnemonic(entropy);
|
7994
8016
|
}
|
7995
8017
|
};
|
@@ -7997,12 +8019,12 @@ var mnemonic_default = Mnemonic;
|
|
7997
8019
|
|
7998
8020
|
// src/hdwallet/hdwallet.ts
|
7999
8021
|
var HARDENED_INDEX = 2147483648;
|
8000
|
-
var MainnetPRV2 = (0,
|
8001
|
-
var MainnetPUB = (0,
|
8002
|
-
var TestnetPRV2 = (0,
|
8003
|
-
var TestnetPUB = (0,
|
8022
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
8023
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
8024
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8025
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
8004
8026
|
function base58check(data) {
|
8005
|
-
return (0,
|
8027
|
+
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)]));
|
8006
8028
|
}
|
8007
8029
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8008
8030
|
if (isPublic) {
|
@@ -8011,11 +8033,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8011
8033
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8012
8034
|
}
|
8013
8035
|
function isPublicExtendedKey(extendedKey) {
|
8014
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8036
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
8015
8037
|
}
|
8016
8038
|
function isValidExtendedKey(extendedKey) {
|
8017
8039
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8018
|
-
(0,
|
8040
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
8019
8041
|
);
|
8020
8042
|
}
|
8021
8043
|
function parsePath(path2, depth = 0) {
|
@@ -8033,8 +8055,8 @@ function parsePath(path2, depth = 0) {
|
|
8033
8055
|
var HDWallet = class {
|
8034
8056
|
depth = 0;
|
8035
8057
|
index = 0;
|
8036
|
-
fingerprint = (0,
|
8037
|
-
parentFingerprint = (0,
|
8058
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8059
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8038
8060
|
privateKey;
|
8039
8061
|
publicKey;
|
8040
8062
|
chainCode;
|
@@ -8046,8 +8068,8 @@ var HDWallet = class {
|
|
8046
8068
|
constructor(config) {
|
8047
8069
|
if (config.privateKey) {
|
8048
8070
|
const signer = new Signer(config.privateKey);
|
8049
|
-
this.publicKey = (0,
|
8050
|
-
this.privateKey = (0,
|
8071
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
8072
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
8051
8073
|
} else {
|
8052
8074
|
if (!config.publicKey) {
|
8053
8075
|
throw new import_errors20.FuelError(
|
@@ -8055,10 +8077,10 @@ var HDWallet = class {
|
|
8055
8077
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8056
8078
|
);
|
8057
8079
|
}
|
8058
|
-
this.publicKey = (0,
|
8080
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8059
8081
|
}
|
8060
8082
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8061
|
-
this.fingerprint = (0,
|
8083
|
+
this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8062
8084
|
this.depth = config.depth || this.depth;
|
8063
8085
|
this.index = config.index || this.index;
|
8064
8086
|
this.chainCode = config.chainCode;
|
@@ -8074,9 +8096,9 @@ var HDWallet = class {
|
|
8074
8096
|
* @returns A new instance of HDWallet on the derived index
|
8075
8097
|
*/
|
8076
8098
|
deriveIndex(index) {
|
8077
|
-
const privateKey = this.privateKey && (0,
|
8078
|
-
const publicKey = (0,
|
8079
|
-
const chainCode = (0,
|
8099
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
8100
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
8101
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
8080
8102
|
const data = new Uint8Array(37);
|
8081
8103
|
if (index & HARDENED_INDEX) {
|
8082
8104
|
if (!privateKey) {
|
@@ -8087,15 +8109,15 @@ var HDWallet = class {
|
|
8087
8109
|
}
|
8088
8110
|
data.set(privateKey, 1);
|
8089
8111
|
} else {
|
8090
|
-
data.set((0,
|
8112
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8091
8113
|
}
|
8092
|
-
data.set((0,
|
8093
|
-
const bytes = (0,
|
8114
|
+
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8115
|
+
const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8094
8116
|
const IL = bytes.slice(0, 32);
|
8095
8117
|
const IR = bytes.slice(32);
|
8096
8118
|
if (privateKey) {
|
8097
8119
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8098
|
-
const ki = (0,
|
8120
|
+
const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
8099
8121
|
return new HDWallet({
|
8100
8122
|
privateKey: ki,
|
8101
8123
|
chainCode: IR,
|
@@ -8104,7 +8126,7 @@ var HDWallet = class {
|
|
8104
8126
|
parentFingerprint: this.fingerprint
|
8105
8127
|
});
|
8106
8128
|
}
|
8107
|
-
const signer = new Signer((0,
|
8129
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
8108
8130
|
const Ki = signer.addPoint(publicKey);
|
8109
8131
|
return new HDWallet({
|
8110
8132
|
publicKey: Ki,
|
@@ -8139,12 +8161,12 @@ var HDWallet = class {
|
|
8139
8161
|
);
|
8140
8162
|
}
|
8141
8163
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8142
|
-
const depth = (0,
|
8164
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8143
8165
|
const parentFingerprint = this.parentFingerprint;
|
8144
|
-
const index = (0,
|
8166
|
+
const index = (0, import_math22.toHex)(this.index, 4);
|
8145
8167
|
const chainCode = this.chainCode;
|
8146
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8147
|
-
const extendedKey = (0,
|
8168
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8169
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8148
8170
|
return base58check(extendedKey);
|
8149
8171
|
}
|
8150
8172
|
/**
|
@@ -8156,13 +8178,13 @@ var HDWallet = class {
|
|
8156
8178
|
static fromSeed(seed) {
|
8157
8179
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8158
8180
|
return new HDWallet({
|
8159
|
-
chainCode: (0,
|
8160
|
-
privateKey: (0,
|
8181
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8182
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8161
8183
|
});
|
8162
8184
|
}
|
8163
8185
|
static fromExtendedKey(extendedKey) {
|
8164
|
-
const decoded = (0,
|
8165
|
-
const bytes = (0,
|
8186
|
+
const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
|
8187
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8166
8188
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8167
8189
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8168
8190
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8171,9 +8193,9 @@ var HDWallet = class {
|
|
8171
8193
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8172
8194
|
}
|
8173
8195
|
const depth = bytes[4];
|
8174
|
-
const parentFingerprint = (0,
|
8175
|
-
const index = parseInt((0,
|
8176
|
-
const chainCode = (0,
|
8196
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8197
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8198
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8177
8199
|
const key = bytes.slice(45, 78);
|
8178
8200
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8179
8201
|
throw new import_errors20.FuelError(
|
@@ -8360,17 +8382,19 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
|
8360
8382
|
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
8361
8383
|
|
8362
8384
|
// src/test-utils/seedTestWallet.ts
|
8363
|
-
var
|
8364
|
-
var seedTestWallet = async (wallet, quantities) => {
|
8365
|
-
const
|
8366
|
-
|
8367
|
-
|
8368
|
-
);
|
8385
|
+
var import_crypto6 = require("@fuel-ts/crypto");
|
8386
|
+
var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
|
8387
|
+
const accountsToBeFunded = Array.isArray(wallet) ? wallet : [wallet];
|
8388
|
+
const [{ provider }] = accountsToBeFunded;
|
8389
|
+
const genesisWallet = new WalletUnlocked(process.env.GENESIS_SECRET || (0, import_crypto6.randomBytes)(32), provider);
|
8369
8390
|
const request = new ScriptTransactionRequest();
|
8370
|
-
quantities.forEach(
|
8371
|
-
|
8372
|
-
|
8373
|
-
|
8391
|
+
quantities.map(coinQuantityfy).forEach(
|
8392
|
+
({ amount, assetId }) => accountsToBeFunded.forEach(({ address }) => {
|
8393
|
+
for (let i = 0; i < utxosAmount; i++) {
|
8394
|
+
request.addCoinOutput(address, amount.div(utxosAmount), assetId);
|
8395
|
+
}
|
8396
|
+
})
|
8397
|
+
);
|
8374
8398
|
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
8375
8399
|
request.gasLimit = txCost.gasUsed;
|
8376
8400
|
request.maxFee = txCost.maxFee;
|
@@ -8389,11 +8413,11 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8389
8413
|
|
8390
8414
|
// src/test-utils/launchNode.ts
|
8391
8415
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
8392
|
-
var
|
8393
|
-
var
|
8416
|
+
var import_crypto7 = require("@fuel-ts/crypto");
|
8417
|
+
var import_utils36 = require("@fuel-ts/utils");
|
8394
8418
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
8395
8419
|
var import_child_process = require("child_process");
|
8396
|
-
var
|
8420
|
+
var import_crypto8 = require("crypto");
|
8397
8421
|
var import_fs = require("fs");
|
8398
8422
|
var import_os = __toESM(require("os"));
|
8399
8423
|
var import_path = __toESM(require("path"));
|
@@ -8448,7 +8472,7 @@ var launchNode = async ({
|
|
8448
8472
|
"--poa-instant"
|
8449
8473
|
]);
|
8450
8474
|
const snapshotDir = getFlagValueFromArgs(args, "--snapshot");
|
8451
|
-
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") ||
|
8475
|
+
const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
|
8452
8476
|
const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
|
8453
8477
|
const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
|
8454
8478
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
@@ -8465,7 +8489,7 @@ var launchNode = async ({
|
|
8465
8489
|
})).toString();
|
8466
8490
|
let snapshotDirToUse;
|
8467
8491
|
const prefix = basePath || import_os.default.tmpdir();
|
8468
|
-
const suffix = basePath ? "" : (0,
|
8492
|
+
const suffix = basePath ? "" : (0, import_crypto8.randomUUID)();
|
8469
8493
|
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "snapshotDir");
|
8470
8494
|
if (snapshotDir) {
|
8471
8495
|
snapshotDirToUse = snapshotDir;
|
@@ -8473,8 +8497,8 @@ var launchNode = async ({
|
|
8473
8497
|
if (!(0, import_fs.existsSync)(tempDirPath)) {
|
8474
8498
|
(0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
|
8475
8499
|
}
|
8476
|
-
let { stateConfigJson } =
|
8477
|
-
const { chainConfigJson, metadataJson } =
|
8500
|
+
let { stateConfigJson } = import_utils36.defaultSnapshotConfigs;
|
8501
|
+
const { chainConfigJson, metadataJson } = import_utils36.defaultSnapshotConfigs;
|
8478
8502
|
stateConfigJson = {
|
8479
8503
|
...stateConfigJson,
|
8480
8504
|
coins: [
|
@@ -8492,9 +8516,9 @@ var launchNode = async ({
|
|
8492
8516
|
if (!process.env.GENESIS_SECRET) {
|
8493
8517
|
const pk = Signer.generatePrivateKey();
|
8494
8518
|
const signer = new Signer(pk);
|
8495
|
-
process.env.GENESIS_SECRET = (0,
|
8519
|
+
process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
|
8496
8520
|
stateConfigJson.coins.push({
|
8497
|
-
tx_id: (0,
|
8521
|
+
tx_id: (0, import_utils36.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
|
8498
8522
|
owner: signer.address.toHexString(),
|
8499
8523
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8500
8524
|
amount: "18446744073709551615",
|