@fuel-ts/account 0.83.0 → 0.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +15 -12
- package/dist/account.d.ts +6 -6
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +1800 -1753
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +619 -414
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +520 -319
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +532 -615
- 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/message.d.ts +2 -2
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +28 -31
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts +0 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +8 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
- package/dist/providers/transaction-request/script-transaction-request.d.ts +2 -3
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -6
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +2 -1
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +20 -0
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +1 -0
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/index.d.ts +1 -1
- package/dist/providers/transaction-summary/index.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +4 -0
- package/dist/providers/transaction-summary/operations.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/status.d.ts +5 -1
- package/dist/providers/transaction-summary/status.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +11 -14
- 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 +7 -6
- 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/launchNode.d.ts.map +1 -1
- package/dist/test-utils/resources.d.ts +4 -0
- package/dist/test-utils/resources.d.ts.map +1 -0
- package/dist/test-utils/transactionRequest.d.ts +5 -0
- package/dist/test-utils/transactionRequest.d.ts.map +1 -0
- package/dist/test-utils.global.js +1826 -1756
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +609 -398
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +521 -310
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +17 -17
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +0 -22
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +0 -1
package/dist/index.js
CHANGED
@@ -108,7 +108,7 @@ __export(src_exports, {
|
|
108
108
|
calculateGasFee: () => calculateGasFee,
|
109
109
|
calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
|
110
110
|
calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
|
111
|
-
|
111
|
+
calculateTXFeeForSummary: () => calculateTXFeeForSummary,
|
112
112
|
coinQuantityfy: () => coinQuantityfy,
|
113
113
|
deferPromise: () => deferPromise,
|
114
114
|
dispatchFuelConnectorEvent: () => dispatchFuelConnectorEvent,
|
@@ -116,6 +116,7 @@ __export(src_exports, {
|
|
116
116
|
extractBurnedAssetsFromReceipts: () => extractBurnedAssetsFromReceipts,
|
117
117
|
extractMintedAssetsFromReceipts: () => extractMintedAssetsFromReceipts,
|
118
118
|
extractTxError: () => extractTxError,
|
119
|
+
fuelAssetsBaseUrl: () => fuelAssetsBaseUrl,
|
119
120
|
gasUsedByInputs: () => gasUsedByInputs,
|
120
121
|
getAssetEth: () => getAssetEth,
|
121
122
|
getAssetFuel: () => getAssetFuel,
|
@@ -168,10 +169,13 @@ __export(src_exports, {
|
|
168
169
|
isTypeCreate: () => isTypeCreate,
|
169
170
|
isTypeMint: () => isTypeMint,
|
170
171
|
isTypeScript: () => isTypeScript,
|
172
|
+
isTypeUpgrade: () => isTypeUpgrade,
|
173
|
+
isTypeUpload: () => isTypeUpload,
|
171
174
|
normalizeJSON: () => normalizeJSON,
|
172
175
|
outputify: () => outputify,
|
173
176
|
processGqlReceipt: () => processGqlReceipt,
|
174
177
|
processGraphqlStatus: () => processGraphqlStatus,
|
178
|
+
rawAssets: () => rawAssets,
|
175
179
|
resolveGasDependentCosts: () => resolveGasDependentCosts,
|
176
180
|
resolveIconPaths: () => resolveIconPaths,
|
177
181
|
returnZeroScript: () => returnZeroScript,
|
@@ -187,8 +191,8 @@ module.exports = __toCommonJS(src_exports);
|
|
187
191
|
var import_address4 = require("@fuel-ts/address");
|
188
192
|
var import_errors16 = require("@fuel-ts/errors");
|
189
193
|
var import_interfaces = require("@fuel-ts/interfaces");
|
190
|
-
var
|
191
|
-
var
|
194
|
+
var import_math21 = require("@fuel-ts/math");
|
195
|
+
var import_utils28 = require("@fuel-ts/utils");
|
192
196
|
var import_ramda4 = require("ramda");
|
193
197
|
|
194
198
|
// src/providers/coin-quantity.ts
|
@@ -229,18 +233,17 @@ var addAmountToCoinQuantities = (params) => {
|
|
229
233
|
// src/providers/provider.ts
|
230
234
|
var import_address3 = require("@fuel-ts/address");
|
231
235
|
var import_errors14 = require("@fuel-ts/errors");
|
232
|
-
var
|
236
|
+
var import_math17 = require("@fuel-ts/math");
|
233
237
|
var import_transactions19 = require("@fuel-ts/transactions");
|
234
238
|
var import_utils22 = require("@fuel-ts/utils");
|
235
239
|
var import_versions = require("@fuel-ts/versions");
|
236
240
|
var import_utils23 = require("@noble/curves/abstract/utils");
|
237
|
-
var import_ethers = require("ethers");
|
238
241
|
var import_graphql_request = require("graphql-request");
|
239
242
|
var import_ramda3 = require("ramda");
|
240
243
|
|
241
244
|
// src/providers/__generated__/operations.ts
|
242
245
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
243
|
-
var
|
246
|
+
var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
|
244
247
|
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
245
248
|
type: __typename
|
246
249
|
... on SqueezedOutStatus {
|
@@ -248,7 +251,13 @@ var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.defaul
|
|
248
251
|
}
|
249
252
|
}
|
250
253
|
`;
|
251
|
-
var
|
254
|
+
var SubmittedStatusFragmentDoc = import_graphql_tag.default`
|
255
|
+
fragment SubmittedStatusFragment on SubmittedStatus {
|
256
|
+
type: __typename
|
257
|
+
time
|
258
|
+
}
|
259
|
+
`;
|
260
|
+
var ReceiptFragmentDoc = import_graphql_tag.default`
|
252
261
|
fragment receiptFragment on Receipt {
|
253
262
|
id
|
254
263
|
pc
|
@@ -280,44 +289,65 @@ var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
|
|
280
289
|
subId
|
281
290
|
}
|
282
291
|
`;
|
283
|
-
var
|
284
|
-
fragment
|
292
|
+
var SuccessStatusFragmentDoc = import_graphql_tag.default`
|
293
|
+
fragment SuccessStatusFragment on SuccessStatus {
|
294
|
+
type: __typename
|
295
|
+
block {
|
296
|
+
id
|
297
|
+
}
|
298
|
+
time
|
299
|
+
programState {
|
300
|
+
returnType
|
301
|
+
data
|
302
|
+
}
|
303
|
+
receipts {
|
304
|
+
...receiptFragment
|
305
|
+
}
|
306
|
+
totalGas
|
307
|
+
totalFee
|
308
|
+
}
|
309
|
+
${ReceiptFragmentDoc}`;
|
310
|
+
var FailureStatusFragmentDoc = import_graphql_tag.default`
|
311
|
+
fragment FailureStatusFragment on FailureStatus {
|
312
|
+
type: __typename
|
313
|
+
block {
|
314
|
+
id
|
315
|
+
}
|
316
|
+
totalGas
|
317
|
+
totalFee
|
318
|
+
time
|
319
|
+
reason
|
320
|
+
receipts {
|
321
|
+
...receiptFragment
|
322
|
+
}
|
323
|
+
}
|
324
|
+
${ReceiptFragmentDoc}`;
|
325
|
+
var SqueezedOutStatusFragmentDoc = import_graphql_tag.default`
|
326
|
+
fragment SqueezedOutStatusFragment on SqueezedOutStatus {
|
285
327
|
type: __typename
|
328
|
+
reason
|
329
|
+
}
|
330
|
+
`;
|
331
|
+
var TransactionStatusFragmentDoc = import_graphql_tag.default`
|
332
|
+
fragment transactionStatusFragment on TransactionStatus {
|
286
333
|
... on SubmittedStatus {
|
287
|
-
|
334
|
+
...SubmittedStatusFragment
|
288
335
|
}
|
289
336
|
... on SuccessStatus {
|
290
|
-
|
291
|
-
id
|
292
|
-
}
|
293
|
-
time
|
294
|
-
receipts {
|
295
|
-
...receiptFragment
|
296
|
-
}
|
297
|
-
programState {
|
298
|
-
returnType
|
299
|
-
data
|
300
|
-
}
|
301
|
-
receipts {
|
302
|
-
...receiptFragment
|
303
|
-
}
|
337
|
+
...SuccessStatusFragment
|
304
338
|
}
|
305
339
|
... on FailureStatus {
|
306
|
-
|
307
|
-
id
|
308
|
-
}
|
309
|
-
time
|
310
|
-
reason
|
311
|
-
receipts {
|
312
|
-
...receiptFragment
|
313
|
-
}
|
340
|
+
...FailureStatusFragment
|
314
341
|
}
|
315
342
|
... on SqueezedOutStatus {
|
316
|
-
|
343
|
+
...SqueezedOutStatusFragment
|
317
344
|
}
|
318
345
|
}
|
319
|
-
${
|
320
|
-
|
346
|
+
${SubmittedStatusFragmentDoc}
|
347
|
+
${SuccessStatusFragmentDoc}
|
348
|
+
${FailureStatusFragmentDoc}
|
349
|
+
${SqueezedOutStatusFragmentDoc}`;
|
350
|
+
var TransactionFragmentDoc = import_graphql_tag.default`
|
321
351
|
fragment transactionFragment on Transaction {
|
322
352
|
id
|
323
353
|
rawPayload
|
@@ -325,8 +355,8 @@ var TransactionFragmentFragmentDoc = import_graphql_tag.default`
|
|
325
355
|
...transactionStatusFragment
|
326
356
|
}
|
327
357
|
}
|
328
|
-
${
|
329
|
-
var
|
358
|
+
${TransactionStatusFragmentDoc}`;
|
359
|
+
var InputEstimatePredicatesFragmentDoc = import_graphql_tag.default`
|
330
360
|
fragment inputEstimatePredicatesFragment on Input {
|
331
361
|
... on InputCoin {
|
332
362
|
predicateGasUsed
|
@@ -336,15 +366,17 @@ var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
|
|
336
366
|
}
|
337
367
|
}
|
338
368
|
`;
|
339
|
-
var
|
369
|
+
var TransactionEstimatePredicatesFragmentDoc = import_graphql_tag.default`
|
340
370
|
fragment transactionEstimatePredicatesFragment on Transaction {
|
341
371
|
inputs {
|
342
372
|
...inputEstimatePredicatesFragment
|
343
373
|
}
|
344
374
|
}
|
345
|
-
${
|
346
|
-
var
|
375
|
+
${InputEstimatePredicatesFragmentDoc}`;
|
376
|
+
var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
|
347
377
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
378
|
+
totalGas
|
379
|
+
totalFee
|
348
380
|
reason
|
349
381
|
programState {
|
350
382
|
returnType
|
@@ -352,15 +384,17 @@ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
352
384
|
}
|
353
385
|
}
|
354
386
|
`;
|
355
|
-
var
|
387
|
+
var DryRunSuccessStatusFragmentDoc = import_graphql_tag.default`
|
356
388
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
389
|
+
totalGas
|
390
|
+
totalFee
|
357
391
|
programState {
|
358
392
|
returnType
|
359
393
|
data
|
360
394
|
}
|
361
395
|
}
|
362
396
|
`;
|
363
|
-
var
|
397
|
+
var DryRunTransactionStatusFragmentDoc = import_graphql_tag.default`
|
364
398
|
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
365
399
|
... on DryRunFailureStatus {
|
366
400
|
...dryRunFailureStatusFragment
|
@@ -369,9 +403,9 @@ var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
369
403
|
...dryRunSuccessStatusFragment
|
370
404
|
}
|
371
405
|
}
|
372
|
-
${
|
373
|
-
${
|
374
|
-
var
|
406
|
+
${DryRunFailureStatusFragmentDoc}
|
407
|
+
${DryRunSuccessStatusFragmentDoc}`;
|
408
|
+
var DryRunTransactionExecutionStatusFragmentDoc = import_graphql_tag.default`
|
375
409
|
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
376
410
|
id
|
377
411
|
status {
|
@@ -381,11 +415,11 @@ var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.def
|
|
381
415
|
...receiptFragment
|
382
416
|
}
|
383
417
|
}
|
384
|
-
${
|
385
|
-
${
|
386
|
-
var
|
418
|
+
${DryRunTransactionStatusFragmentDoc}
|
419
|
+
${ReceiptFragmentDoc}`;
|
420
|
+
var CoinFragmentDoc = import_graphql_tag.default`
|
387
421
|
fragment coinFragment on Coin {
|
388
|
-
__typename
|
422
|
+
type: __typename
|
389
423
|
utxoId
|
390
424
|
owner
|
391
425
|
amount
|
@@ -394,9 +428,9 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
|
394
428
|
txCreatedIdx
|
395
429
|
}
|
396
430
|
`;
|
397
|
-
var
|
431
|
+
var MessageCoinFragmentDoc = import_graphql_tag.default`
|
398
432
|
fragment messageCoinFragment on MessageCoin {
|
399
|
-
__typename
|
433
|
+
type: __typename
|
400
434
|
sender
|
401
435
|
recipient
|
402
436
|
nonce
|
@@ -405,7 +439,7 @@ var MessageCoinFragmentFragmentDoc = import_graphql_tag.default`
|
|
405
439
|
daHeight
|
406
440
|
}
|
407
441
|
`;
|
408
|
-
var
|
442
|
+
var MessageFragmentDoc = import_graphql_tag.default`
|
409
443
|
fragment messageFragment on Message {
|
410
444
|
amount
|
411
445
|
sender
|
@@ -415,7 +449,7 @@ var MessageFragmentFragmentDoc = import_graphql_tag.default`
|
|
415
449
|
daHeight
|
416
450
|
}
|
417
451
|
`;
|
418
|
-
var
|
452
|
+
var MessageProofFragmentDoc = import_graphql_tag.default`
|
419
453
|
fragment messageProofFragment on MessageProof {
|
420
454
|
messageProof {
|
421
455
|
proofSet
|
@@ -462,14 +496,14 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
|
|
462
496
|
data
|
463
497
|
}
|
464
498
|
`;
|
465
|
-
var
|
499
|
+
var BalanceFragmentDoc = import_graphql_tag.default`
|
466
500
|
fragment balanceFragment on Balance {
|
467
501
|
owner
|
468
502
|
amount
|
469
503
|
assetId
|
470
504
|
}
|
471
505
|
`;
|
472
|
-
var
|
506
|
+
var BlockFragmentDoc = import_graphql_tag.default`
|
473
507
|
fragment blockFragment on Block {
|
474
508
|
id
|
475
509
|
height
|
@@ -481,7 +515,7 @@ var BlockFragmentFragmentDoc = import_graphql_tag.default`
|
|
481
515
|
}
|
482
516
|
}
|
483
517
|
`;
|
484
|
-
var
|
518
|
+
var TxParametersFragmentDoc = import_graphql_tag.default`
|
485
519
|
fragment TxParametersFragment on TxParameters {
|
486
520
|
version
|
487
521
|
maxInputs
|
@@ -489,9 +523,10 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
489
523
|
maxWitnesses
|
490
524
|
maxGasPerTx
|
491
525
|
maxSize
|
526
|
+
maxBytecodeSubsections
|
492
527
|
}
|
493
528
|
`;
|
494
|
-
var
|
529
|
+
var PredicateParametersFragmentDoc = import_graphql_tag.default`
|
495
530
|
fragment PredicateParametersFragment on PredicateParameters {
|
496
531
|
version
|
497
532
|
maxPredicateLength
|
@@ -500,41 +535,42 @@ var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
500
535
|
maxMessageDataLength
|
501
536
|
}
|
502
537
|
`;
|
503
|
-
var
|
538
|
+
var ScriptParametersFragmentDoc = import_graphql_tag.default`
|
504
539
|
fragment ScriptParametersFragment on ScriptParameters {
|
505
540
|
version
|
506
541
|
maxScriptLength
|
507
542
|
maxScriptDataLength
|
508
543
|
}
|
509
544
|
`;
|
510
|
-
var
|
545
|
+
var ContractParametersFragmentDoc = import_graphql_tag.default`
|
511
546
|
fragment ContractParametersFragment on ContractParameters {
|
512
547
|
version
|
513
548
|
contractMaxSize
|
514
549
|
maxStorageSlots
|
515
550
|
}
|
516
551
|
`;
|
517
|
-
var
|
552
|
+
var FeeParametersFragmentDoc = import_graphql_tag.default`
|
518
553
|
fragment FeeParametersFragment on FeeParameters {
|
519
554
|
version
|
520
555
|
gasPriceFactor
|
521
556
|
gasPerByte
|
522
557
|
}
|
523
558
|
`;
|
524
|
-
var
|
559
|
+
var DependentCostFragmentDoc = import_graphql_tag.default`
|
525
560
|
fragment DependentCostFragment on DependentCost {
|
526
|
-
__typename
|
527
561
|
... on LightOperation {
|
562
|
+
type: __typename
|
528
563
|
base
|
529
564
|
unitsPerGas
|
530
565
|
}
|
531
566
|
... on HeavyOperation {
|
567
|
+
type: __typename
|
532
568
|
base
|
533
569
|
gasPerUnit
|
534
570
|
}
|
535
571
|
}
|
536
572
|
`;
|
537
|
-
var
|
573
|
+
var GasCostsFragmentDoc = import_graphql_tag.default`
|
538
574
|
fragment GasCostsFragment on GasCosts {
|
539
575
|
version
|
540
576
|
add
|
@@ -690,8 +726,8 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
690
726
|
}
|
691
727
|
newStoragePerByte
|
692
728
|
}
|
693
|
-
${
|
694
|
-
var
|
729
|
+
${DependentCostFragmentDoc}`;
|
730
|
+
var ConsensusParametersFragmentDoc = import_graphql_tag.default`
|
695
731
|
fragment consensusParametersFragment on ConsensusParameters {
|
696
732
|
version
|
697
733
|
txParams {
|
@@ -715,13 +751,13 @@ var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
715
751
|
baseAssetId
|
716
752
|
chainId
|
717
753
|
}
|
718
|
-
${
|
719
|
-
${
|
720
|
-
${
|
721
|
-
${
|
722
|
-
${
|
723
|
-
${
|
724
|
-
var
|
754
|
+
${TxParametersFragmentDoc}
|
755
|
+
${PredicateParametersFragmentDoc}
|
756
|
+
${ScriptParametersFragmentDoc}
|
757
|
+
${ContractParametersFragmentDoc}
|
758
|
+
${FeeParametersFragmentDoc}
|
759
|
+
${GasCostsFragmentDoc}`;
|
760
|
+
var ChainInfoFragmentDoc = import_graphql_tag.default`
|
725
761
|
fragment chainInfoFragment on ChainInfo {
|
726
762
|
name
|
727
763
|
latestBlock {
|
@@ -732,16 +768,16 @@ var ChainInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
732
768
|
...consensusParametersFragment
|
733
769
|
}
|
734
770
|
}
|
735
|
-
${
|
736
|
-
${
|
737
|
-
var
|
771
|
+
${BlockFragmentDoc}
|
772
|
+
${ConsensusParametersFragmentDoc}`;
|
773
|
+
var ContractBalanceFragmentDoc = import_graphql_tag.default`
|
738
774
|
fragment contractBalanceFragment on ContractBalance {
|
739
775
|
contract
|
740
776
|
amount
|
741
777
|
assetId
|
742
778
|
}
|
743
779
|
`;
|
744
|
-
var
|
780
|
+
var PageInfoFragmentDoc = import_graphql_tag.default`
|
745
781
|
fragment pageInfoFragment on PageInfo {
|
746
782
|
hasPreviousPage
|
747
783
|
hasNextPage
|
@@ -749,7 +785,7 @@ var PageInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
749
785
|
endCursor
|
750
786
|
}
|
751
787
|
`;
|
752
|
-
var
|
788
|
+
var NodeInfoFragmentDoc = import_graphql_tag.default`
|
753
789
|
fragment nodeInfoFragment on NodeInfo {
|
754
790
|
utxoValidation
|
755
791
|
vmBacktrace
|
@@ -758,6 +794,14 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
758
794
|
nodeVersion
|
759
795
|
}
|
760
796
|
`;
|
797
|
+
var RelayedTransactionStatusFragmentDoc = import_graphql_tag.default`
|
798
|
+
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
799
|
+
... on RelayedTransactionFailed {
|
800
|
+
blockHeight
|
801
|
+
failure
|
802
|
+
}
|
803
|
+
}
|
804
|
+
`;
|
761
805
|
var GetVersionDocument = import_graphql_tag.default`
|
762
806
|
query getVersion {
|
763
807
|
nodeInfo {
|
@@ -771,28 +815,28 @@ var GetNodeInfoDocument = import_graphql_tag.default`
|
|
771
815
|
...nodeInfoFragment
|
772
816
|
}
|
773
817
|
}
|
774
|
-
${
|
818
|
+
${NodeInfoFragmentDoc}`;
|
775
819
|
var GetChainDocument = import_graphql_tag.default`
|
776
820
|
query getChain {
|
777
821
|
chain {
|
778
822
|
...chainInfoFragment
|
779
823
|
}
|
780
824
|
}
|
781
|
-
${
|
825
|
+
${ChainInfoFragmentDoc}`;
|
782
826
|
var GetTransactionDocument = import_graphql_tag.default`
|
783
827
|
query getTransaction($transactionId: TransactionId!) {
|
784
828
|
transaction(id: $transactionId) {
|
785
829
|
...transactionFragment
|
786
830
|
}
|
787
831
|
}
|
788
|
-
${
|
832
|
+
${TransactionFragmentDoc}`;
|
789
833
|
var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
|
790
834
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
791
835
|
transaction(id: $transactionId) {
|
792
836
|
...transactionFragment
|
793
837
|
}
|
794
838
|
}
|
795
|
-
${
|
839
|
+
${TransactionFragmentDoc}`;
|
796
840
|
var GetTransactionsDocument = import_graphql_tag.default`
|
797
841
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
798
842
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -803,7 +847,7 @@ var GetTransactionsDocument = import_graphql_tag.default`
|
|
803
847
|
}
|
804
848
|
}
|
805
849
|
}
|
806
|
-
${
|
850
|
+
${TransactionFragmentDoc}`;
|
807
851
|
var GetTransactionsByOwnerDocument = import_graphql_tag.default`
|
808
852
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
809
853
|
transactionsByOwner(
|
@@ -823,22 +867,22 @@ var GetTransactionsByOwnerDocument = import_graphql_tag.default`
|
|
823
867
|
}
|
824
868
|
}
|
825
869
|
}
|
826
|
-
${
|
827
|
-
${
|
870
|
+
${PageInfoFragmentDoc}
|
871
|
+
${TransactionFragmentDoc}`;
|
828
872
|
var EstimatePredicatesDocument = import_graphql_tag.default`
|
829
873
|
query estimatePredicates($encodedTransaction: HexString!) {
|
830
874
|
estimatePredicates(tx: $encodedTransaction) {
|
831
875
|
...transactionEstimatePredicatesFragment
|
832
876
|
}
|
833
877
|
}
|
834
|
-
${
|
878
|
+
${TransactionEstimatePredicatesFragmentDoc}`;
|
835
879
|
var GetBlockDocument = import_graphql_tag.default`
|
836
880
|
query getBlock($blockId: BlockId, $height: U32) {
|
837
881
|
block(id: $blockId, height: $height) {
|
838
882
|
...blockFragment
|
839
883
|
}
|
840
884
|
}
|
841
|
-
${
|
885
|
+
${BlockFragmentDoc}`;
|
842
886
|
var GetBlockWithTransactionsDocument = import_graphql_tag.default`
|
843
887
|
query getBlockWithTransactions($blockId: BlockId, $blockHeight: U32) {
|
844
888
|
block(id: $blockId, height: $blockHeight) {
|
@@ -848,8 +892,8 @@ var GetBlockWithTransactionsDocument = import_graphql_tag.default`
|
|
848
892
|
}
|
849
893
|
}
|
850
894
|
}
|
851
|
-
${
|
852
|
-
${
|
895
|
+
${BlockFragmentDoc}
|
896
|
+
${TransactionFragmentDoc}`;
|
853
897
|
var GetBlocksDocument = import_graphql_tag.default`
|
854
898
|
query getBlocks($after: String, $before: String, $first: Int, $last: Int) {
|
855
899
|
blocks(after: $after, before: $before, first: $first, last: $last) {
|
@@ -860,14 +904,14 @@ var GetBlocksDocument = import_graphql_tag.default`
|
|
860
904
|
}
|
861
905
|
}
|
862
906
|
}
|
863
|
-
${
|
907
|
+
${BlockFragmentDoc}`;
|
864
908
|
var GetCoinDocument = import_graphql_tag.default`
|
865
909
|
query getCoin($coinId: UtxoId!) {
|
866
910
|
coin(utxoId: $coinId) {
|
867
911
|
...coinFragment
|
868
912
|
}
|
869
913
|
}
|
870
|
-
${
|
914
|
+
${CoinFragmentDoc}`;
|
871
915
|
var GetCoinsDocument = import_graphql_tag.default`
|
872
916
|
query getCoins($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
873
917
|
coins(
|
@@ -884,7 +928,7 @@ var GetCoinsDocument = import_graphql_tag.default`
|
|
884
928
|
}
|
885
929
|
}
|
886
930
|
}
|
887
|
-
${
|
931
|
+
${CoinFragmentDoc}`;
|
888
932
|
var GetCoinsToSpendDocument = import_graphql_tag.default`
|
889
933
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
890
934
|
coinsToSpend(
|
@@ -896,8 +940,8 @@ var GetCoinsToSpendDocument = import_graphql_tag.default`
|
|
896
940
|
...messageCoinFragment
|
897
941
|
}
|
898
942
|
}
|
899
|
-
${
|
900
|
-
${
|
943
|
+
${CoinFragmentDoc}
|
944
|
+
${MessageCoinFragmentDoc}`;
|
901
945
|
var GetContractDocument = import_graphql_tag.default`
|
902
946
|
query getContract($contractId: ContractId!) {
|
903
947
|
contract(id: $contractId) {
|
@@ -912,14 +956,14 @@ var GetContractBalanceDocument = import_graphql_tag.default`
|
|
912
956
|
...contractBalanceFragment
|
913
957
|
}
|
914
958
|
}
|
915
|
-
${
|
959
|
+
${ContractBalanceFragmentDoc}`;
|
916
960
|
var GetBalanceDocument = import_graphql_tag.default`
|
917
961
|
query getBalance($owner: Address!, $assetId: AssetId!) {
|
918
962
|
balance(owner: $owner, assetId: $assetId) {
|
919
963
|
...balanceFragment
|
920
964
|
}
|
921
965
|
}
|
922
|
-
${
|
966
|
+
${BalanceFragmentDoc}`;
|
923
967
|
var GetLatestGasPriceDocument = import_graphql_tag.default`
|
924
968
|
query getLatestGasPrice {
|
925
969
|
latestGasPrice {
|
@@ -950,7 +994,7 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
950
994
|
}
|
951
995
|
}
|
952
996
|
}
|
953
|
-
${
|
997
|
+
${BalanceFragmentDoc}`;
|
954
998
|
var GetMessagesDocument = import_graphql_tag.default`
|
955
999
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
956
1000
|
messages(
|
@@ -967,7 +1011,7 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
967
1011
|
}
|
968
1012
|
}
|
969
1013
|
}
|
970
|
-
${
|
1014
|
+
${MessageFragmentDoc}`;
|
971
1015
|
var GetMessageProofDocument = import_graphql_tag.default`
|
972
1016
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
973
1017
|
messageProof(
|
@@ -979,7 +1023,7 @@ var GetMessageProofDocument = import_graphql_tag.default`
|
|
979
1023
|
...messageProofFragment
|
980
1024
|
}
|
981
1025
|
}
|
982
|
-
${
|
1026
|
+
${MessageProofFragmentDoc}`;
|
983
1027
|
var GetMessageStatusDocument = import_graphql_tag.default`
|
984
1028
|
query getMessageStatus($nonce: Nonce!) {
|
985
1029
|
messageStatus(nonce: $nonce) {
|
@@ -987,13 +1031,20 @@ var GetMessageStatusDocument = import_graphql_tag.default`
|
|
987
1031
|
}
|
988
1032
|
}
|
989
1033
|
`;
|
1034
|
+
var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
|
1035
|
+
query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
|
1036
|
+
relayedTransactionStatus(id: $relayedTransactionId) {
|
1037
|
+
...relayedTransactionStatusFragment
|
1038
|
+
}
|
1039
|
+
}
|
1040
|
+
${RelayedTransactionStatusFragmentDoc}`;
|
990
1041
|
var DryRunDocument = import_graphql_tag.default`
|
991
1042
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
992
1043
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
993
1044
|
...dryRunTransactionExecutionStatusFragment
|
994
1045
|
}
|
995
1046
|
}
|
996
|
-
${
|
1047
|
+
${DryRunTransactionExecutionStatusFragmentDoc}`;
|
997
1048
|
var SubmitDocument = import_graphql_tag.default`
|
998
1049
|
mutation submit($encodedTransaction: HexString!) {
|
999
1050
|
submit(tx: $encodedTransaction) {
|
@@ -1009,20 +1060,27 @@ var ProduceBlocksDocument = import_graphql_tag.default`
|
|
1009
1060
|
)
|
1010
1061
|
}
|
1011
1062
|
`;
|
1063
|
+
var GetMessageByNonceDocument = import_graphql_tag.default`
|
1064
|
+
query getMessageByNonce($nonce: Nonce!) {
|
1065
|
+
message(nonce: $nonce) {
|
1066
|
+
...messageFragment
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
${MessageFragmentDoc}`;
|
1012
1070
|
var SubmitAndAwaitDocument = import_graphql_tag.default`
|
1013
1071
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
1014
1072
|
submitAndAwait(tx: $encodedTransaction) {
|
1015
1073
|
...transactionStatusSubscriptionFragment
|
1016
1074
|
}
|
1017
1075
|
}
|
1018
|
-
${
|
1076
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
1019
1077
|
var StatusChangeDocument = import_graphql_tag.default`
|
1020
1078
|
subscription statusChange($transactionId: TransactionId!) {
|
1021
1079
|
statusChange(id: $transactionId) {
|
1022
1080
|
...transactionStatusSubscriptionFragment
|
1023
1081
|
}
|
1024
1082
|
}
|
1025
|
-
${
|
1083
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
1026
1084
|
function getSdk(requester) {
|
1027
1085
|
return {
|
1028
1086
|
getVersion(variables, options) {
|
@@ -1094,6 +1152,9 @@ function getSdk(requester) {
|
|
1094
1152
|
getMessageStatus(variables, options) {
|
1095
1153
|
return requester(GetMessageStatusDocument, variables, options);
|
1096
1154
|
},
|
1155
|
+
getRelayedTransactionStatus(variables, options) {
|
1156
|
+
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
1157
|
+
},
|
1097
1158
|
dryRun(variables, options) {
|
1098
1159
|
return requester(DryRunDocument, variables, options);
|
1099
1160
|
},
|
@@ -1103,6 +1164,9 @@ function getSdk(requester) {
|
|
1103
1164
|
produceBlocks(variables, options) {
|
1104
1165
|
return requester(ProduceBlocksDocument, variables, options);
|
1105
1166
|
},
|
1167
|
+
getMessageByNonce(variables, options) {
|
1168
|
+
return requester(GetMessageByNonceDocument, variables, options);
|
1169
|
+
},
|
1106
1170
|
submitAndAwait(variables, options) {
|
1107
1171
|
return requester(SubmitAndAwaitDocument, variables, options);
|
1108
1172
|
},
|
@@ -1679,10 +1743,9 @@ var getGasUsedFromReceipts = (receipts) => {
|
|
1679
1743
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
1680
1744
|
const base = (0, import_math5.bn)(gasDependentCost.base);
|
1681
1745
|
let dependentValue = (0, import_math5.bn)(0);
|
1682
|
-
if (
|
1746
|
+
if ("unitsPerGas" in gasDependentCost) {
|
1683
1747
|
dependentValue = (0, import_math5.bn)(byteSize).div((0, import_math5.bn)(gasDependentCost.unitsPerGas));
|
1684
|
-
}
|
1685
|
-
if (gasDependentCost.__typename === "HeavyOperation") {
|
1748
|
+
} else {
|
1686
1749
|
dependentValue = (0, import_math5.bn)(byteSize).mul((0, import_math5.bn)(gasDependentCost.gasPerUnit));
|
1687
1750
|
}
|
1688
1751
|
return base.add(dependentValue);
|
@@ -1759,7 +1822,7 @@ function calculateMetadataGasForTxScript({
|
|
1759
1822
|
}
|
1760
1823
|
var calculateGasFee = (params) => {
|
1761
1824
|
const { gas, gasPrice, priceFactor, tip } = params;
|
1762
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1825
|
+
return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
|
1763
1826
|
};
|
1764
1827
|
|
1765
1828
|
// src/providers/utils/json.ts
|
@@ -1936,10 +1999,10 @@ var BaseTransactionRequest = class {
|
|
1936
1999
|
outputs,
|
1937
2000
|
witnesses
|
1938
2001
|
} = {}) {
|
1939
|
-
this.tip = (0, import_math7.bn)(tip);
|
1940
|
-
this.maturity = maturity
|
1941
|
-
this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
|
1942
|
-
this.maxFee =
|
2002
|
+
this.tip = tip ? (0, import_math7.bn)(tip) : void 0;
|
2003
|
+
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
2004
|
+
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math7.bn)(witnessLimit) : void 0;
|
2005
|
+
this.maxFee = (0, import_math7.bn)(maxFee);
|
1943
2006
|
this.inputs = inputs ?? [];
|
1944
2007
|
this.outputs = outputs ?? [];
|
1945
2008
|
this.witnesses = witnesses ?? [];
|
@@ -1947,22 +2010,21 @@ var BaseTransactionRequest = class {
|
|
1947
2010
|
static getPolicyMeta(req) {
|
1948
2011
|
let policyTypes = 0;
|
1949
2012
|
const policies = [];
|
1950
|
-
|
2013
|
+
const { tip, witnessLimit, maturity } = req;
|
2014
|
+
if ((0, import_math7.bn)(tip).gt(0)) {
|
1951
2015
|
policyTypes += import_transactions6.PolicyType.Tip;
|
1952
|
-
policies.push({ data:
|
2016
|
+
policies.push({ data: (0, import_math7.bn)(tip), type: import_transactions6.PolicyType.Tip });
|
1953
2017
|
}
|
1954
|
-
if (
|
2018
|
+
if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math7.bn)(witnessLimit).gte(0)) {
|
1955
2019
|
policyTypes += import_transactions6.PolicyType.WitnessLimit;
|
1956
|
-
policies.push({ data:
|
2020
|
+
policies.push({ data: (0, import_math7.bn)(witnessLimit), type: import_transactions6.PolicyType.WitnessLimit });
|
1957
2021
|
}
|
1958
|
-
if (
|
2022
|
+
if (maturity && maturity > 0) {
|
1959
2023
|
policyTypes += import_transactions6.PolicyType.Maturity;
|
1960
|
-
policies.push({ data:
|
1961
|
-
}
|
1962
|
-
if (req.maxFee) {
|
1963
|
-
policyTypes += import_transactions6.PolicyType.MaxFee;
|
1964
|
-
policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
|
2024
|
+
policies.push({ data: maturity, type: import_transactions6.PolicyType.Maturity });
|
1965
2025
|
}
|
2026
|
+
policyTypes += import_transactions6.PolicyType.MaxFee;
|
2027
|
+
policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
|
1966
2028
|
return {
|
1967
2029
|
policyTypes,
|
1968
2030
|
policies
|
@@ -2278,8 +2340,11 @@ var BaseTransactionRequest = class {
|
|
2278
2340
|
* @hidden
|
2279
2341
|
*/
|
2280
2342
|
calculateMinGas(chainInfo) {
|
2281
|
-
const {
|
2282
|
-
const {
|
2343
|
+
const { consensusParameters } = chainInfo;
|
2344
|
+
const {
|
2345
|
+
gasCosts,
|
2346
|
+
feeParameters: { gasPerByte }
|
2347
|
+
} = consensusParameters;
|
2283
2348
|
return getMinGas({
|
2284
2349
|
gasPerByte,
|
2285
2350
|
gasCosts,
|
@@ -2290,7 +2355,10 @@ var BaseTransactionRequest = class {
|
|
2290
2355
|
}
|
2291
2356
|
calculateMaxGas(chainInfo, minGas) {
|
2292
2357
|
const { consensusParameters } = chainInfo;
|
2293
|
-
const {
|
2358
|
+
const {
|
2359
|
+
feeParameters: { gasPerByte },
|
2360
|
+
txParameters: { maxGasPerTx }
|
2361
|
+
} = consensusParameters;
|
2294
2362
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2295
2363
|
(acc, wit) => acc + wit.dataLength,
|
2296
2364
|
0
|
@@ -2725,7 +2793,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2725
2793
|
}
|
2726
2794
|
calculateMaxGas(chainInfo, minGas) {
|
2727
2795
|
const { consensusParameters } = chainInfo;
|
2728
|
-
const {
|
2796
|
+
const {
|
2797
|
+
feeParameters: { gasPerByte },
|
2798
|
+
txParameters: { maxGasPerTx }
|
2799
|
+
} = consensusParameters;
|
2729
2800
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2730
2801
|
(acc, wit) => acc + wit.dataLength,
|
2731
2802
|
0
|
@@ -2813,10 +2884,10 @@ var transactionRequestify = (obj) => {
|
|
2813
2884
|
};
|
2814
2885
|
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2815
2886
|
(acc, input) => {
|
2816
|
-
if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
|
2887
|
+
if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
|
2817
2888
|
acc.utxos.push(input.id);
|
2818
2889
|
}
|
2819
|
-
if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
|
2890
|
+
if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
|
2820
2891
|
acc.messages.push(input.nonce);
|
2821
2892
|
}
|
2822
2893
|
return acc;
|
@@ -2829,40 +2900,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
|
2829
2900
|
|
2830
2901
|
// src/providers/transaction-response/transaction-response.ts
|
2831
2902
|
var import_errors13 = require("@fuel-ts/errors");
|
2832
|
-
var
|
2903
|
+
var import_math16 = require("@fuel-ts/math");
|
2833
2904
|
var import_transactions18 = require("@fuel-ts/transactions");
|
2834
2905
|
var import_utils20 = require("@fuel-ts/utils");
|
2835
2906
|
|
2836
2907
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2837
|
-
var
|
2908
|
+
var import_math15 = require("@fuel-ts/math");
|
2838
2909
|
var import_transactions16 = require("@fuel-ts/transactions");
|
2839
2910
|
var import_utils18 = require("@fuel-ts/utils");
|
2840
2911
|
|
2841
|
-
// src/providers/transaction-summary/calculate-
|
2912
|
+
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2842
2913
|
var import_math11 = require("@fuel-ts/math");
|
2843
2914
|
var import_transactions11 = require("@fuel-ts/transactions");
|
2844
2915
|
var import_utils16 = require("@fuel-ts/utils");
|
2845
|
-
var
|
2916
|
+
var calculateTXFeeForSummary = (params) => {
|
2846
2917
|
const {
|
2847
2918
|
gasPrice,
|
2848
2919
|
rawPayload,
|
2849
2920
|
tip,
|
2921
|
+
totalFee,
|
2850
2922
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2851
2923
|
} = params;
|
2924
|
+
if (totalFee) {
|
2925
|
+
return totalFee;
|
2926
|
+
}
|
2852
2927
|
const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
|
2853
2928
|
const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
|
2854
2929
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2855
2930
|
const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
|
2856
|
-
if (transaction.type === import_transactions11.TransactionType.Mint) {
|
2857
|
-
return {
|
2858
|
-
fee: (0, import_math11.bn)(0),
|
2859
|
-
minFee: (0, import_math11.bn)(0),
|
2860
|
-
maxFee: (0, import_math11.bn)(0)
|
2861
|
-
};
|
2862
|
-
}
|
2863
2931
|
const { type, witnesses, inputs, policies } = transaction;
|
2864
2932
|
let metadataGas = (0, import_math11.bn)(0);
|
2865
2933
|
let gasLimit = (0, import_math11.bn)(0);
|
2934
|
+
if (type !== import_transactions11.TransactionType.Create && type !== import_transactions11.TransactionType.Script) {
|
2935
|
+
return (0, import_math11.bn)(0);
|
2936
|
+
}
|
2866
2937
|
if (type === import_transactions11.TransactionType.Create) {
|
2867
2938
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2868
2939
|
const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
@@ -2899,23 +2970,13 @@ var calculateTransactionFee = (params) => {
|
|
2899
2970
|
witnessLimit,
|
2900
2971
|
maxGasPerTx
|
2901
2972
|
});
|
2902
|
-
const minFee = calculateGasFee({
|
2903
|
-
gasPrice,
|
2904
|
-
gas: minGas,
|
2905
|
-
priceFactor: gasPriceFactor,
|
2906
|
-
tip
|
2907
|
-
});
|
2908
2973
|
const maxFee = calculateGasFee({
|
2909
2974
|
gasPrice,
|
2910
2975
|
gas: maxGas,
|
2911
2976
|
priceFactor: gasPriceFactor,
|
2912
2977
|
tip
|
2913
2978
|
});
|
2914
|
-
return
|
2915
|
-
minFee,
|
2916
|
-
maxFee,
|
2917
|
-
fee: maxFee
|
2918
|
-
};
|
2979
|
+
return maxFee;
|
2919
2980
|
};
|
2920
2981
|
|
2921
2982
|
// src/providers/transaction-summary/operations.ts
|
@@ -3050,6 +3111,8 @@ var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
|
|
3050
3111
|
TransactionTypeName2["Create"] = "Create";
|
3051
3112
|
TransactionTypeName2["Mint"] = "Mint";
|
3052
3113
|
TransactionTypeName2["Script"] = "Script";
|
3114
|
+
TransactionTypeName2["Upgrade"] = "Upgrade";
|
3115
|
+
TransactionTypeName2["Upload"] = "Upload";
|
3053
3116
|
return TransactionTypeName2;
|
3054
3117
|
})(TransactionTypeName || {});
|
3055
3118
|
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
@@ -3115,6 +3178,12 @@ function isTypeCreate(transactionType) {
|
|
3115
3178
|
function isTypeScript(transactionType) {
|
3116
3179
|
return isType(transactionType, "Script" /* Script */);
|
3117
3180
|
}
|
3181
|
+
function isTypeUpgrade(transactionType) {
|
3182
|
+
return isType(transactionType, "Upgrade" /* Upgrade */);
|
3183
|
+
}
|
3184
|
+
function isTypeUpload(transactionType) {
|
3185
|
+
return isType(transactionType, "Upload" /* Upload */);
|
3186
|
+
}
|
3118
3187
|
function hasSameAssetId(a) {
|
3119
3188
|
return (b) => a.assetId === b.assetId;
|
3120
3189
|
}
|
@@ -3461,6 +3530,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3461
3530
|
|
3462
3531
|
// src/providers/transaction-summary/status.ts
|
3463
3532
|
var import_errors12 = require("@fuel-ts/errors");
|
3533
|
+
var import_math14 = require("@fuel-ts/math");
|
3464
3534
|
var getTransactionStatusName = (gqlStatus) => {
|
3465
3535
|
switch (gqlStatus) {
|
3466
3536
|
case "FailureStatus":
|
@@ -3482,6 +3552,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3482
3552
|
let time;
|
3483
3553
|
let blockId;
|
3484
3554
|
let status;
|
3555
|
+
let totalFee;
|
3556
|
+
let totalGas;
|
3485
3557
|
let isStatusFailure = false;
|
3486
3558
|
let isStatusSuccess = false;
|
3487
3559
|
let isStatusPending = false;
|
@@ -3492,11 +3564,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3492
3564
|
time = gqlTransactionStatus.time;
|
3493
3565
|
blockId = gqlTransactionStatus.block.id;
|
3494
3566
|
isStatusSuccess = true;
|
3567
|
+
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3568
|
+
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3495
3569
|
break;
|
3496
3570
|
case "FailureStatus":
|
3497
3571
|
time = gqlTransactionStatus.time;
|
3498
3572
|
blockId = gqlTransactionStatus.block.id;
|
3499
3573
|
isStatusFailure = true;
|
3574
|
+
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3575
|
+
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3500
3576
|
break;
|
3501
3577
|
case "SubmittedStatus":
|
3502
3578
|
time = gqlTransactionStatus.time;
|
@@ -3509,6 +3585,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3509
3585
|
time,
|
3510
3586
|
blockId,
|
3511
3587
|
status,
|
3588
|
+
totalFee,
|
3589
|
+
totalGas,
|
3512
3590
|
isStatusFailure,
|
3513
3591
|
isStatusSuccess,
|
3514
3592
|
isStatusPending
|
@@ -3544,8 +3622,10 @@ function assembleTransactionSummary(params) {
|
|
3544
3622
|
maxInputs
|
3545
3623
|
});
|
3546
3624
|
const typeName = getTransactionTypeName(transaction.type);
|
3547
|
-
const tip = (0,
|
3548
|
-
const {
|
3625
|
+
const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
|
3626
|
+
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3627
|
+
const fee = calculateTXFeeForSummary({
|
3628
|
+
totalFee,
|
3549
3629
|
gasPrice,
|
3550
3630
|
rawPayload,
|
3551
3631
|
tip,
|
@@ -3558,7 +3638,6 @@ function assembleTransactionSummary(params) {
|
|
3558
3638
|
}
|
3559
3639
|
}
|
3560
3640
|
});
|
3561
|
-
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
|
3562
3641
|
const mintedAssets = extractMintedAssetsFromReceipts(receipts);
|
3563
3642
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3564
3643
|
let date;
|
@@ -3567,6 +3646,7 @@ function assembleTransactionSummary(params) {
|
|
3567
3646
|
}
|
3568
3647
|
const transactionSummary = {
|
3569
3648
|
id,
|
3649
|
+
tip,
|
3570
3650
|
fee,
|
3571
3651
|
gasUsed,
|
3572
3652
|
operations,
|
@@ -3580,6 +3660,8 @@ function assembleTransactionSummary(params) {
|
|
3580
3660
|
isTypeMint: isTypeMint(transaction.type),
|
3581
3661
|
isTypeCreate: isTypeCreate(transaction.type),
|
3582
3662
|
isTypeScript: isTypeScript(transaction.type),
|
3663
|
+
isTypeUpgrade: isTypeUpgrade(transaction.type),
|
3664
|
+
isTypeUpload: isTypeUpload(transaction.type),
|
3583
3665
|
isStatusFailure,
|
3584
3666
|
isStatusSuccess,
|
3585
3667
|
isStatusPending,
|
@@ -3611,7 +3693,7 @@ var TransactionResponse = class {
|
|
3611
3693
|
/** Current provider */
|
3612
3694
|
provider;
|
3613
3695
|
/** Gas used on the transaction */
|
3614
|
-
gasUsed = (0,
|
3696
|
+
gasUsed = (0, import_math16.bn)(0);
|
3615
3697
|
/** The graphql Transaction with receipts object. */
|
3616
3698
|
gqlTransaction;
|
3617
3699
|
abis;
|
@@ -3696,7 +3778,7 @@ var TransactionResponse = class {
|
|
3696
3778
|
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3697
3779
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3698
3780
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3699
|
-
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3781
|
+
const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
|
3700
3782
|
const transactionSummary = assembleTransactionSummary({
|
3701
3783
|
id: this.id,
|
3702
3784
|
receipts,
|
@@ -3832,33 +3914,60 @@ var mergeQuantities = (...coinQuantities) => {
|
|
3832
3914
|
var MAX_RETRIES = 10;
|
3833
3915
|
var processGqlChain = (chain) => {
|
3834
3916
|
const { name, daHeight, consensusParameters, latestBlock } = chain;
|
3835
|
-
const {
|
3917
|
+
const {
|
3918
|
+
contractParams,
|
3919
|
+
feeParams,
|
3920
|
+
predicateParams,
|
3921
|
+
scriptParams,
|
3922
|
+
txParams,
|
3923
|
+
gasCosts,
|
3924
|
+
baseAssetId,
|
3925
|
+
chainId,
|
3926
|
+
version
|
3927
|
+
} = consensusParameters;
|
3836
3928
|
return {
|
3837
3929
|
name,
|
3838
|
-
baseChainHeight: (0,
|
3930
|
+
baseChainHeight: (0, import_math17.bn)(daHeight),
|
3839
3931
|
consensusParameters: {
|
3840
|
-
|
3841
|
-
|
3842
|
-
|
3843
|
-
|
3844
|
-
|
3845
|
-
|
3846
|
-
|
3847
|
-
|
3848
|
-
|
3849
|
-
|
3850
|
-
|
3851
|
-
|
3852
|
-
|
3853
|
-
|
3854
|
-
|
3855
|
-
|
3932
|
+
version,
|
3933
|
+
chainId: (0, import_math17.bn)(chainId),
|
3934
|
+
baseAssetId,
|
3935
|
+
feeParameters: {
|
3936
|
+
version: feeParams.version,
|
3937
|
+
gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
|
3938
|
+
gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
|
3939
|
+
},
|
3940
|
+
contractParameters: {
|
3941
|
+
version: contractParams.version,
|
3942
|
+
contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
|
3943
|
+
maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
|
3944
|
+
},
|
3945
|
+
txParameters: {
|
3946
|
+
version: txParams.version,
|
3947
|
+
maxInputs: (0, import_math17.bn)(txParams.maxInputs),
|
3948
|
+
maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
|
3949
|
+
maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
|
3950
|
+
maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
|
3951
|
+
maxSize: (0, import_math17.bn)(txParams.maxSize),
|
3952
|
+
maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
|
3953
|
+
},
|
3954
|
+
predicateParameters: {
|
3955
|
+
version: predicateParams.version,
|
3956
|
+
maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
|
3957
|
+
maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
|
3958
|
+
maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
|
3959
|
+
maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
|
3960
|
+
},
|
3961
|
+
scriptParameters: {
|
3962
|
+
version: scriptParams.version,
|
3963
|
+
maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
|
3964
|
+
maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
|
3965
|
+
},
|
3856
3966
|
gasCosts
|
3857
3967
|
},
|
3858
|
-
gasCosts,
|
3859
3968
|
latestBlock: {
|
3860
3969
|
id: latestBlock.id,
|
3861
|
-
height: (0,
|
3970
|
+
height: (0, import_math17.bn)(latestBlock.height),
|
3862
3971
|
time: latestBlock.header.time,
|
3863
3972
|
transactions: latestBlock.transactions.map((i) => ({
|
3864
3973
|
id: i.id
|
@@ -3952,7 +4061,12 @@ var _Provider = class {
|
|
3952
4061
|
* Returns some helpful parameters related to gas fees.
|
3953
4062
|
*/
|
3954
4063
|
getGasConfig() {
|
3955
|
-
const {
|
4064
|
+
const {
|
4065
|
+
txParameters: { maxGasPerTx },
|
4066
|
+
predicateParameters: { maxGasPerPredicate },
|
4067
|
+
feeParameters: { gasPriceFactor, gasPerByte },
|
4068
|
+
gasCosts
|
4069
|
+
} = this.getChain().consensusParameters;
|
3956
4070
|
return {
|
3957
4071
|
maxGasPerTx,
|
3958
4072
|
maxGasPerPredicate,
|
@@ -3987,9 +4101,11 @@ var _Provider = class {
|
|
3987
4101
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3988
4102
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
3989
4103
|
if (!isMajorSupported || !isMinorSupported) {
|
3990
|
-
|
3991
|
-
|
3992
|
-
|
4104
|
+
console.warn(
|
4105
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
|
4106
|
+
which is not supported by the version of the TS SDK that you are using.
|
4107
|
+
Things may not work as expected.
|
4108
|
+
Supported fuel-core version: ${supportedVersion}.`
|
3993
4109
|
);
|
3994
4110
|
}
|
3995
4111
|
}
|
@@ -4001,7 +4117,18 @@ var _Provider = class {
|
|
4001
4117
|
createOperations() {
|
4002
4118
|
const fetchFn = _Provider.getFetchFn(this.options);
|
4003
4119
|
const gqlClient = new import_graphql_request.GraphQLClient(this.url, {
|
4004
|
-
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
|
4120
|
+
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4121
|
+
responseMiddleware: (response) => {
|
4122
|
+
if ("response" in response) {
|
4123
|
+
const graphQlResponse = response.response;
|
4124
|
+
if (Array.isArray(graphQlResponse?.errors)) {
|
4125
|
+
throw new import_errors14.FuelError(
|
4126
|
+
import_errors14.FuelError.CODES.INVALID_REQUEST,
|
4127
|
+
graphQlResponse.errors.map((err) => err.message).join("\n\n")
|
4128
|
+
);
|
4129
|
+
}
|
4130
|
+
}
|
4131
|
+
}
|
4005
4132
|
});
|
4006
4133
|
const executeQuery = (query, vars) => {
|
4007
4134
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
@@ -4029,21 +4156,6 @@ var _Provider = class {
|
|
4029
4156
|
} = await this.operations.getVersion();
|
4030
4157
|
return nodeVersion;
|
4031
4158
|
}
|
4032
|
-
/**
|
4033
|
-
* @hidden
|
4034
|
-
*
|
4035
|
-
* Returns the network configuration of the connected Fuel node.
|
4036
|
-
*
|
4037
|
-
* @returns A promise that resolves to the network configuration object
|
4038
|
-
*/
|
4039
|
-
async getNetwork() {
|
4040
|
-
const {
|
4041
|
-
name,
|
4042
|
-
consensusParameters: { chainId }
|
4043
|
-
} = await this.getChain();
|
4044
|
-
const network = new import_ethers.Network(name, chainId.toNumber());
|
4045
|
-
return Promise.resolve(network);
|
4046
|
-
}
|
4047
4159
|
/**
|
4048
4160
|
* Returns the block number.
|
4049
4161
|
*
|
@@ -4051,7 +4163,7 @@ var _Provider = class {
|
|
4051
4163
|
*/
|
4052
4164
|
async getBlockNumber() {
|
4053
4165
|
const { chain } = await this.operations.getChain();
|
4054
|
-
return (0,
|
4166
|
+
return (0, import_math17.bn)(chain.latestBlock.height, 10);
|
4055
4167
|
}
|
4056
4168
|
/**
|
4057
4169
|
* Returns the chain information.
|
@@ -4061,8 +4173,8 @@ var _Provider = class {
|
|
4061
4173
|
async fetchNode() {
|
4062
4174
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
4063
4175
|
const processedNodeInfo = {
|
4064
|
-
maxDepth: (0,
|
4065
|
-
maxTx: (0,
|
4176
|
+
maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
|
4177
|
+
maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
|
4066
4178
|
nodeVersion: nodeInfo.nodeVersion,
|
4067
4179
|
utxoValidation: nodeInfo.utxoValidation,
|
4068
4180
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4166,9 +4278,9 @@ var _Provider = class {
|
|
4166
4278
|
encodedTransactions: encodedTransaction,
|
4167
4279
|
utxoValidation: utxoValidation || false
|
4168
4280
|
});
|
4169
|
-
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4281
|
+
const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
|
4170
4282
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4171
|
-
return { receipts,
|
4283
|
+
return { receipts, dryRunStatus };
|
4172
4284
|
}
|
4173
4285
|
/**
|
4174
4286
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -4179,7 +4291,7 @@ var _Provider = class {
|
|
4179
4291
|
async estimatePredicates(transactionRequest) {
|
4180
4292
|
const shouldEstimatePredicates = Boolean(
|
4181
4293
|
transactionRequest.inputs.find(
|
4182
|
-
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new
|
4294
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
|
4183
4295
|
)
|
4184
4296
|
);
|
4185
4297
|
if (!shouldEstimatePredicates) {
|
@@ -4194,7 +4306,7 @@ var _Provider = class {
|
|
4194
4306
|
} = response;
|
4195
4307
|
if (inputs) {
|
4196
4308
|
inputs.forEach((input, index) => {
|
4197
|
-
if ("predicateGasUsed" in input && (0,
|
4309
|
+
if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
|
4198
4310
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4199
4311
|
}
|
4200
4312
|
});
|
@@ -4222,7 +4334,7 @@ var _Provider = class {
|
|
4222
4334
|
let receipts = [];
|
4223
4335
|
const missingContractIds = [];
|
4224
4336
|
let outputVariables = 0;
|
4225
|
-
let
|
4337
|
+
let dryRunStatus;
|
4226
4338
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4227
4339
|
const {
|
4228
4340
|
dryRun: [{ receipts: rawReceipts, status }]
|
@@ -4231,7 +4343,7 @@ var _Provider = class {
|
|
4231
4343
|
utxoValidation: false
|
4232
4344
|
});
|
4233
4345
|
receipts = rawReceipts.map(processGqlReceipt);
|
4234
|
-
|
4346
|
+
dryRunStatus = status;
|
4235
4347
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
4236
4348
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
4237
4349
|
if (hasMissingOutputs) {
|
@@ -4253,7 +4365,7 @@ var _Provider = class {
|
|
4253
4365
|
receipts,
|
4254
4366
|
outputVariables,
|
4255
4367
|
missingContractIds,
|
4256
|
-
|
4368
|
+
dryRunStatus
|
4257
4369
|
};
|
4258
4370
|
}
|
4259
4371
|
/**
|
@@ -4271,7 +4383,7 @@ var _Provider = class {
|
|
4271
4383
|
receipts: [],
|
4272
4384
|
outputVariables: 0,
|
4273
4385
|
missingContractIds: [],
|
4274
|
-
|
4386
|
+
dryRunStatus: void 0
|
4275
4387
|
}));
|
4276
4388
|
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4277
4389
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
@@ -4296,7 +4408,7 @@ var _Provider = class {
|
|
4296
4408
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4297
4409
|
const result = results[requestIdx];
|
4298
4410
|
result.receipts = rawReceipts.map(processGqlReceipt);
|
4299
|
-
result.
|
4411
|
+
result.dryRunStatus = status;
|
4300
4412
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4301
4413
|
result.receipts
|
4302
4414
|
);
|
@@ -4333,7 +4445,7 @@ var _Provider = class {
|
|
4333
4445
|
});
|
4334
4446
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4335
4447
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4336
|
-
return { receipts,
|
4448
|
+
return { receipts, dryRunStatus: status };
|
4337
4449
|
});
|
4338
4450
|
return results;
|
4339
4451
|
}
|
@@ -4352,12 +4464,12 @@ var _Provider = class {
|
|
4352
4464
|
gasPrice = await this.estimateGasPrice(10);
|
4353
4465
|
}
|
4354
4466
|
const minFee = calculateGasFee({
|
4355
|
-
gasPrice: (0,
|
4467
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4356
4468
|
gas: minGas,
|
4357
4469
|
priceFactor: gasPriceFactor,
|
4358
4470
|
tip: transactionRequest.tip
|
4359
4471
|
}).add(1);
|
4360
|
-
let gasLimit = (0,
|
4472
|
+
let gasLimit = (0, import_math17.bn)(0);
|
4361
4473
|
if (transactionRequest.type === import_transactions19.TransactionType.Script) {
|
4362
4474
|
gasLimit = transactionRequest.gasLimit;
|
4363
4475
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4370,7 +4482,7 @@ var _Provider = class {
|
|
4370
4482
|
}
|
4371
4483
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4372
4484
|
const maxFee = calculateGasFee({
|
4373
|
-
gasPrice: (0,
|
4485
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4374
4486
|
gas: maxGas,
|
4375
4487
|
priceFactor: gasPriceFactor,
|
4376
4488
|
tip: transactionRequest.tip
|
@@ -4430,12 +4542,12 @@ var _Provider = class {
|
|
4430
4542
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4431
4543
|
const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
|
4432
4544
|
const baseAssetId = this.getBaseAssetId();
|
4545
|
+
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4433
4546
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4434
4547
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4435
4548
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4436
|
-
txRequestClone.maxFee = (0, import_math16.bn)(0);
|
4437
4549
|
if (isScriptTransaction) {
|
4438
|
-
txRequestClone.gasLimit = (0,
|
4550
|
+
txRequestClone.gasLimit = (0, import_math17.bn)(0);
|
4439
4551
|
}
|
4440
4552
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4441
4553
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4448,24 +4560,22 @@ var _Provider = class {
|
|
4448
4560
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4449
4561
|
}
|
4450
4562
|
await this.estimatePredicates(signedRequest);
|
4563
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4451
4564
|
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4452
4565
|
transactionRequest: signedRequest
|
4453
4566
|
});
|
4454
4567
|
let receipts = [];
|
4568
|
+
let dryRunStatus;
|
4455
4569
|
let missingContractIds = [];
|
4456
4570
|
let outputVariables = 0;
|
4457
|
-
let gasUsed = (0,
|
4458
|
-
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4571
|
+
let gasUsed = (0, import_math17.bn)(0);
|
4459
4572
|
txRequestClone.maxFee = maxFee;
|
4460
4573
|
if (isScriptTransaction) {
|
4461
4574
|
txRequestClone.gasLimit = gasLimit;
|
4462
4575
|
if (signatureCallback) {
|
4463
4576
|
await signatureCallback(txRequestClone);
|
4464
4577
|
}
|
4465
|
-
|
4466
|
-
receipts = result.receipts;
|
4467
|
-
outputVariables = result.outputVariables;
|
4468
|
-
missingContractIds = result.missingContractIds;
|
4578
|
+
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
|
4469
4579
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4470
4580
|
txRequestClone.gasLimit = gasUsed;
|
4471
4581
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
@@ -4485,7 +4595,9 @@ var _Provider = class {
|
|
4485
4595
|
outputVariables,
|
4486
4596
|
missingContractIds,
|
4487
4597
|
addedSignatures,
|
4488
|
-
estimatedPredicates: txRequestClone.inputs
|
4598
|
+
estimatedPredicates: txRequestClone.inputs,
|
4599
|
+
dryRunStatus,
|
4600
|
+
updateMaxFee
|
4489
4601
|
};
|
4490
4602
|
}
|
4491
4603
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4521,10 +4633,10 @@ var _Provider = class {
|
|
4521
4633
|
return coins.map((coin) => ({
|
4522
4634
|
id: coin.utxoId,
|
4523
4635
|
assetId: coin.assetId,
|
4524
|
-
amount: (0,
|
4636
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4525
4637
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4526
|
-
blockCreated: (0,
|
4527
|
-
txCreatedIdx: (0,
|
4638
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4639
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4528
4640
|
}));
|
4529
4641
|
}
|
4530
4642
|
/**
|
@@ -4558,12 +4670,12 @@ var _Provider = class {
|
|
4558
4670
|
};
|
4559
4671
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
4560
4672
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
4561
|
-
switch (coin.
|
4673
|
+
switch (coin.type) {
|
4562
4674
|
case "MessageCoin":
|
4563
4675
|
return {
|
4564
|
-
amount: (0,
|
4676
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4565
4677
|
assetId: coin.assetId,
|
4566
|
-
daHeight: (0,
|
4678
|
+
daHeight: (0, import_math17.bn)(coin.daHeight),
|
4567
4679
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4568
4680
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4569
4681
|
nonce: coin.nonce
|
@@ -4571,11 +4683,11 @@ var _Provider = class {
|
|
4571
4683
|
case "Coin":
|
4572
4684
|
return {
|
4573
4685
|
id: coin.utxoId,
|
4574
|
-
amount: (0,
|
4686
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4575
4687
|
assetId: coin.assetId,
|
4576
4688
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4577
|
-
blockCreated: (0,
|
4578
|
-
txCreatedIdx: (0,
|
4689
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4690
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4579
4691
|
};
|
4580
4692
|
default:
|
4581
4693
|
return null;
|
@@ -4592,13 +4704,13 @@ var _Provider = class {
|
|
4592
4704
|
async getBlock(idOrHeight) {
|
4593
4705
|
let variables;
|
4594
4706
|
if (typeof idOrHeight === "number") {
|
4595
|
-
variables = { height: (0,
|
4707
|
+
variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4596
4708
|
} else if (idOrHeight === "latest") {
|
4597
4709
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4598
4710
|
} else if (idOrHeight.length === 66) {
|
4599
4711
|
variables = { blockId: idOrHeight };
|
4600
4712
|
} else {
|
4601
|
-
variables = { blockId: (0,
|
4713
|
+
variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4602
4714
|
}
|
4603
4715
|
const { block } = await this.operations.getBlock(variables);
|
4604
4716
|
if (!block) {
|
@@ -4606,7 +4718,7 @@ var _Provider = class {
|
|
4606
4718
|
}
|
4607
4719
|
return {
|
4608
4720
|
id: block.id,
|
4609
|
-
height: (0,
|
4721
|
+
height: (0, import_math17.bn)(block.height),
|
4610
4722
|
time: block.header.time,
|
4611
4723
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4612
4724
|
};
|
@@ -4621,7 +4733,7 @@ var _Provider = class {
|
|
4621
4733
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4622
4734
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4623
4735
|
id: block.id,
|
4624
|
-
height: (0,
|
4736
|
+
height: (0, import_math17.bn)(block.height),
|
4625
4737
|
time: block.header.time,
|
4626
4738
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4627
4739
|
}));
|
@@ -4636,7 +4748,7 @@ var _Provider = class {
|
|
4636
4748
|
async getBlockWithTransactions(idOrHeight) {
|
4637
4749
|
let variables;
|
4638
4750
|
if (typeof idOrHeight === "number") {
|
4639
|
-
variables = { blockHeight: (0,
|
4751
|
+
variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4640
4752
|
} else if (idOrHeight === "latest") {
|
4641
4753
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4642
4754
|
} else {
|
@@ -4648,7 +4760,7 @@ var _Provider = class {
|
|
4648
4760
|
}
|
4649
4761
|
return {
|
4650
4762
|
id: block.id,
|
4651
|
-
height: (0,
|
4763
|
+
height: (0, import_math17.bn)(block.height, 10),
|
4652
4764
|
time: block.header.time,
|
4653
4765
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4654
4766
|
transactions: block.transactions.map(
|
@@ -4697,7 +4809,7 @@ var _Provider = class {
|
|
4697
4809
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4698
4810
|
asset: (0, import_utils22.hexlify)(assetId)
|
4699
4811
|
});
|
4700
|
-
return (0,
|
4812
|
+
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4701
4813
|
}
|
4702
4814
|
/**
|
4703
4815
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4711,7 +4823,7 @@ var _Provider = class {
|
|
4711
4823
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4712
4824
|
assetId: (0, import_utils22.hexlify)(assetId)
|
4713
4825
|
});
|
4714
|
-
return (0,
|
4826
|
+
return (0, import_math17.bn)(balance.amount, 10);
|
4715
4827
|
}
|
4716
4828
|
/**
|
4717
4829
|
* Returns balances for the given owner.
|
@@ -4729,7 +4841,7 @@ var _Provider = class {
|
|
4729
4841
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4730
4842
|
return balances.map((balance) => ({
|
4731
4843
|
assetId: balance.assetId,
|
4732
|
-
amount: (0,
|
4844
|
+
amount: (0, import_math17.bn)(balance.amount)
|
4733
4845
|
}));
|
4734
4846
|
}
|
4735
4847
|
/**
|
@@ -4751,15 +4863,15 @@ var _Provider = class {
|
|
4751
4863
|
sender: message.sender,
|
4752
4864
|
recipient: message.recipient,
|
4753
4865
|
nonce: message.nonce,
|
4754
|
-
amount: (0,
|
4866
|
+
amount: (0, import_math17.bn)(message.amount),
|
4755
4867
|
data: message.data
|
4756
4868
|
}),
|
4757
4869
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4758
4870
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4759
4871
|
nonce: message.nonce,
|
4760
|
-
amount: (0,
|
4872
|
+
amount: (0, import_math17.bn)(message.amount),
|
4761
4873
|
data: import_transactions19.InputMessageCoder.decodeData(message.data),
|
4762
|
-
daHeight: (0,
|
4874
|
+
daHeight: (0, import_math17.bn)(message.daHeight)
|
4763
4875
|
}));
|
4764
4876
|
}
|
4765
4877
|
/**
|
@@ -4812,59 +4924,59 @@ var _Provider = class {
|
|
4812
4924
|
} = result.messageProof;
|
4813
4925
|
return {
|
4814
4926
|
messageProof: {
|
4815
|
-
proofIndex: (0,
|
4927
|
+
proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
|
4816
4928
|
proofSet: messageProof.proofSet
|
4817
4929
|
},
|
4818
4930
|
blockProof: {
|
4819
|
-
proofIndex: (0,
|
4931
|
+
proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
|
4820
4932
|
proofSet: blockProof.proofSet
|
4821
4933
|
},
|
4822
4934
|
messageBlockHeader: {
|
4823
4935
|
id: messageBlockHeader.id,
|
4824
|
-
daHeight: (0,
|
4825
|
-
transactionsCount: (
|
4936
|
+
daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
|
4937
|
+
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4826
4938
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4827
|
-
height: (0,
|
4939
|
+
height: (0, import_math17.bn)(messageBlockHeader.height),
|
4828
4940
|
prevRoot: messageBlockHeader.prevRoot,
|
4829
4941
|
time: messageBlockHeader.time,
|
4830
4942
|
applicationHash: messageBlockHeader.applicationHash,
|
4831
|
-
messageReceiptCount: (
|
4943
|
+
messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
|
4832
4944
|
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4833
|
-
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4945
|
+
consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
|
4834
4946
|
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4835
|
-
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4947
|
+
stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
|
4836
4948
|
},
|
4837
4949
|
commitBlockHeader: {
|
4838
4950
|
id: commitBlockHeader.id,
|
4839
|
-
daHeight: (0,
|
4840
|
-
transactionsCount: (
|
4951
|
+
daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
|
4952
|
+
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4841
4953
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4842
|
-
height: (0,
|
4954
|
+
height: (0, import_math17.bn)(commitBlockHeader.height),
|
4843
4955
|
prevRoot: commitBlockHeader.prevRoot,
|
4844
4956
|
time: commitBlockHeader.time,
|
4845
4957
|
applicationHash: commitBlockHeader.applicationHash,
|
4846
|
-
messageReceiptCount: (
|
4958
|
+
messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
|
4847
4959
|
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4848
|
-
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4960
|
+
consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
|
4849
4961
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4850
|
-
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4962
|
+
stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
|
4851
4963
|
},
|
4852
4964
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4853
4965
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4854
4966
|
nonce,
|
4855
|
-
amount: (0,
|
4967
|
+
amount: (0, import_math17.bn)(amount),
|
4856
4968
|
data
|
4857
4969
|
};
|
4858
4970
|
}
|
4859
4971
|
async getLatestGasPrice() {
|
4860
4972
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4861
|
-
return (0,
|
4973
|
+
return (0, import_math17.bn)(latestGasPrice.gasPrice);
|
4862
4974
|
}
|
4863
4975
|
async estimateGasPrice(blockHorizon) {
|
4864
4976
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4865
4977
|
blockHorizon: String(blockHorizon)
|
4866
4978
|
});
|
4867
|
-
return (0,
|
4979
|
+
return (0, import_math17.bn)(estimateGasPrice.gasPrice);
|
4868
4980
|
}
|
4869
4981
|
/**
|
4870
4982
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4885,15 +4997,37 @@ var _Provider = class {
|
|
4885
4997
|
*/
|
4886
4998
|
async produceBlocks(amount, startTime) {
|
4887
4999
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4888
|
-
blocksToProduce: (0,
|
5000
|
+
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
4889
5001
|
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4890
5002
|
});
|
4891
|
-
return (0,
|
5003
|
+
return (0, import_math17.bn)(latestBlockHeight);
|
4892
5004
|
}
|
4893
5005
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4894
5006
|
async getTransactionResponse(transactionId) {
|
4895
5007
|
return new TransactionResponse(transactionId, this);
|
4896
5008
|
}
|
5009
|
+
/**
|
5010
|
+
* Returns Message for given nonce.
|
5011
|
+
*
|
5012
|
+
* @param nonce - The nonce of the message to retrieve.
|
5013
|
+
* @returns A promise that resolves to the Message object.
|
5014
|
+
*/
|
5015
|
+
async getMessageByNonce(nonce) {
|
5016
|
+
const { message } = await this.operations.getMessageByNonce({ nonce });
|
5017
|
+
if (!message) {
|
5018
|
+
return null;
|
5019
|
+
}
|
5020
|
+
return message;
|
5021
|
+
}
|
5022
|
+
async getRelayedTransactionStatus(relayedTransactionId) {
|
5023
|
+
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
5024
|
+
relayedTransactionId
|
5025
|
+
});
|
5026
|
+
if (!relayedTransactionStatus) {
|
5027
|
+
return null;
|
5028
|
+
}
|
5029
|
+
return relayedTransactionStatus;
|
5030
|
+
}
|
4897
5031
|
};
|
4898
5032
|
var Provider = _Provider;
|
4899
5033
|
_cacheInputs = new WeakSet();
|
@@ -4912,7 +5046,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4912
5046
|
|
4913
5047
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4914
5048
|
var import_errors15 = require("@fuel-ts/errors");
|
4915
|
-
var
|
5049
|
+
var import_math18 = require("@fuel-ts/math");
|
4916
5050
|
var import_transactions20 = require("@fuel-ts/transactions");
|
4917
5051
|
var import_utils25 = require("@fuel-ts/utils");
|
4918
5052
|
async function getTransactionSummary(params) {
|
@@ -4936,7 +5070,11 @@ async function getTransactionSummary(params) {
|
|
4936
5070
|
}
|
4937
5071
|
const receipts = txReceipts.map(processGqlReceipt);
|
4938
5072
|
const {
|
4939
|
-
consensusParameters: {
|
5073
|
+
consensusParameters: {
|
5074
|
+
feeParameters: { gasPerByte, gasPriceFactor },
|
5075
|
+
txParameters: { maxInputs, maxGasPerTx },
|
5076
|
+
gasCosts
|
5077
|
+
}
|
4940
5078
|
} = provider.getChain();
|
4941
5079
|
const gasPrice = await provider.getLatestGasPrice();
|
4942
5080
|
const transactionInfo = assembleTransactionSummary({
|
@@ -4945,8 +5083,8 @@ async function getTransactionSummary(params) {
|
|
4945
5083
|
transaction: decodedTransaction,
|
4946
5084
|
transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
4947
5085
|
gqlTransactionStatus: gqlTransaction.status,
|
4948
|
-
gasPerByte: (0,
|
4949
|
-
gasPriceFactor: (0,
|
5086
|
+
gasPerByte: (0, import_math18.bn)(gasPerByte),
|
5087
|
+
gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
|
4950
5088
|
abiMap,
|
4951
5089
|
maxInputs,
|
4952
5090
|
gasCosts,
|
@@ -4962,7 +5100,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
4962
5100
|
const { provider, transactionRequest, abiMap } = params;
|
4963
5101
|
const { receipts } = await provider.call(transactionRequest);
|
4964
5102
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
4965
|
-
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
5103
|
+
const maxInputs = provider.getChain().consensusParameters.txParameters.maxInputs;
|
4966
5104
|
const transaction = transactionRequest.toTransaction();
|
4967
5105
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
4968
5106
|
const gasPrice = await provider.getLatestGasPrice();
|
@@ -4985,7 +5123,11 @@ async function getTransactionsSummaries(params) {
|
|
4985
5123
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
4986
5124
|
const { edges, pageInfo } = transactionsByOwner;
|
4987
5125
|
const {
|
4988
|
-
consensusParameters: {
|
5126
|
+
consensusParameters: {
|
5127
|
+
feeParameters: { gasPerByte, gasPriceFactor },
|
5128
|
+
txParameters: { maxInputs, maxGasPerTx },
|
5129
|
+
gasCosts
|
5130
|
+
}
|
4989
5131
|
} = provider.getChain();
|
4990
5132
|
const gasPrice = await provider.getLatestGasPrice();
|
4991
5133
|
const transactions = edges.map((edge) => {
|
@@ -5111,8 +5253,11 @@ function resolveIconPaths(assets2, basePath = "./") {
|
|
5111
5253
|
}));
|
5112
5254
|
}
|
5113
5255
|
|
5114
|
-
// src/providers/assets/
|
5115
|
-
var
|
5256
|
+
// src/providers/assets/utils/fuelAssetsBaseUrl.ts
|
5257
|
+
var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
|
5258
|
+
|
5259
|
+
// src/providers/assets/assets.ts
|
5260
|
+
var rawAssets = [
|
5116
5261
|
{
|
5117
5262
|
name: "Ethereum",
|
5118
5263
|
symbol: "ETH",
|
@@ -5143,20 +5288,37 @@ var assets = [
|
|
5143
5288
|
]
|
5144
5289
|
}
|
5145
5290
|
];
|
5291
|
+
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
5292
|
+
|
5293
|
+
// src/providers/transaction-request/helpers.ts
|
5294
|
+
var import_math19 = require("@fuel-ts/math");
|
5295
|
+
var import_transactions21 = require("@fuel-ts/transactions");
|
5296
|
+
var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
|
5297
|
+
var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
|
5298
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
5299
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
5300
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
5301
|
+
return acc.add(input.amount);
|
5302
|
+
}
|
5303
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
5304
|
+
return acc.add(input.amount);
|
5305
|
+
}
|
5306
|
+
return acc;
|
5307
|
+
}, (0, import_math19.bn)(0));
|
5146
5308
|
|
5147
5309
|
// src/utils/formatTransferToContractScriptData.ts
|
5148
5310
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5149
|
-
var
|
5150
|
-
var
|
5311
|
+
var import_math20 = require("@fuel-ts/math");
|
5312
|
+
var import_utils27 = require("@fuel-ts/utils");
|
5151
5313
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5152
5314
|
var formatTransferToContractScriptData = (params) => {
|
5153
5315
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5154
5316
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
5155
|
-
const encoded = numberCoder.encode(new
|
5317
|
+
const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
|
5156
5318
|
const scriptData = Uint8Array.from([
|
5157
|
-
...(0,
|
5319
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
5158
5320
|
...encoded,
|
5159
|
-
...(0,
|
5321
|
+
...(0, import_utils27.arrayify)(assetId)
|
5160
5322
|
]);
|
5161
5323
|
return scriptData;
|
5162
5324
|
};
|
@@ -5181,6 +5343,7 @@ var assembleTransferToContractScript = async (params) => {
|
|
5181
5343
|
};
|
5182
5344
|
|
5183
5345
|
// src/account.ts
|
5346
|
+
var MAX_FUNDING_ATTEMPTS = 2;
|
5184
5347
|
var Account = class extends import_interfaces.AbstractAccount {
|
5185
5348
|
/**
|
5186
5349
|
* The address associated with the account.
|
@@ -5335,19 +5498,20 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5335
5498
|
return balances;
|
5336
5499
|
}
|
5337
5500
|
/**
|
5338
|
-
*
|
5501
|
+
* Funds a transaction request by adding the necessary resources.
|
5339
5502
|
*
|
5340
|
-
* @
|
5341
|
-
* @param
|
5342
|
-
* @param
|
5343
|
-
* @returns
|
5503
|
+
* @typeParam T - The type of the TransactionRequest.
|
5504
|
+
* @param request - The transaction request to fund.
|
5505
|
+
* @param params - The estimated transaction parameters.
|
5506
|
+
* @returns The funded transaction request.
|
5344
5507
|
*/
|
5345
5508
|
async fund(request, params) {
|
5346
|
-
const { addedSignatures, estimatedPredicates,
|
5509
|
+
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5510
|
+
const fee = request.maxFee;
|
5347
5511
|
const baseAssetId = this.provider.getBaseAssetId();
|
5348
|
-
const
|
5512
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
|
5349
5513
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5350
|
-
amount: (0,
|
5514
|
+
amount: (0, import_math21.bn)(fee),
|
5351
5515
|
assetId: baseAssetId,
|
5352
5516
|
coinQuantities: requiredQuantities
|
5353
5517
|
});
|
@@ -5355,21 +5519,17 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5355
5519
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5356
5520
|
quantitiesDict[assetId] = {
|
5357
5521
|
required: amount,
|
5358
|
-
owned: (0,
|
5522
|
+
owned: (0, import_math21.bn)(0)
|
5359
5523
|
};
|
5360
5524
|
});
|
5361
|
-
|
5362
|
-
const
|
5363
|
-
if (!isResource) {
|
5364
|
-
return;
|
5365
|
-
}
|
5366
|
-
const isCoin2 = "owner" in input;
|
5525
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
5526
|
+
const isCoin2 = isRequestInputCoin(input);
|
5367
5527
|
const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
|
5368
5528
|
if (quantitiesDict[assetId]) {
|
5369
5529
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
|
5370
5530
|
}
|
5371
5531
|
});
|
5372
|
-
|
5532
|
+
let missingQuantities = [];
|
5373
5533
|
Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
|
5374
5534
|
if (owned.lt(required)) {
|
5375
5535
|
missingQuantities.push({
|
@@ -5378,23 +5538,60 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5378
5538
|
});
|
5379
5539
|
}
|
5380
5540
|
});
|
5381
|
-
|
5382
|
-
|
5383
|
-
|
5384
|
-
const resources = await this.getResourcesToSpend(
|
5385
|
-
|
5386
|
-
|
5387
|
-
|
5388
|
-
|
5389
|
-
|
5541
|
+
let needsToBeFunded = missingQuantities.length > 0;
|
5542
|
+
let fundingAttempts = 0;
|
5543
|
+
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5544
|
+
const resources = await this.getResourcesToSpend(
|
5545
|
+
missingQuantities,
|
5546
|
+
cacheTxInputsFromOwner(request.inputs, this.address)
|
5547
|
+
);
|
5548
|
+
request.addResources(resources);
|
5549
|
+
request.shiftPredicateData();
|
5550
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5551
|
+
const requestToReestimate2 = (0, import_ramda4.clone)(request);
|
5552
|
+
if (addedSignatures) {
|
5553
|
+
Array.from({ length: addedSignatures }).forEach(
|
5554
|
+
() => requestToReestimate2.addEmptyWitness()
|
5555
|
+
);
|
5556
|
+
}
|
5557
|
+
if (!updateMaxFee) {
|
5558
|
+
break;
|
5559
|
+
}
|
5560
|
+
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5561
|
+
transactionRequest: requestToReestimate2
|
5562
|
+
});
|
5563
|
+
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
5564
|
+
request.inputs,
|
5565
|
+
baseAssetId,
|
5566
|
+
baseAssetId
|
5567
|
+
);
|
5568
|
+
const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
|
5569
|
+
if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
|
5570
|
+
needsToBeFunded = false;
|
5571
|
+
} else {
|
5572
|
+
missingQuantities = [
|
5573
|
+
{
|
5574
|
+
amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
|
5575
|
+
assetId: baseAssetId
|
5576
|
+
}
|
5577
|
+
];
|
5578
|
+
}
|
5579
|
+
fundingAttempts += 1;
|
5580
|
+
}
|
5581
|
+
request.shiftPredicateData();
|
5582
|
+
request.updatePredicateGasUsed(estimatedPredicates);
|
5583
|
+
const requestToReestimate = (0, import_ramda4.clone)(request);
|
5390
5584
|
if (addedSignatures) {
|
5391
5585
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
5392
5586
|
}
|
5587
|
+
if (!updateMaxFee) {
|
5588
|
+
return request;
|
5589
|
+
}
|
5393
5590
|
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5394
5591
|
transactionRequest: requestToReestimate
|
5395
5592
|
});
|
5396
|
-
|
5397
|
-
return
|
5593
|
+
request.maxFee = maxFee;
|
5594
|
+
return request;
|
5398
5595
|
}
|
5399
5596
|
/**
|
5400
5597
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5406,20 +5603,19 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5406
5603
|
* @returns A promise that resolves to the prepared transaction request.
|
5407
5604
|
*/
|
5408
5605
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
5409
|
-
|
5606
|
+
let request = new ScriptTransactionRequest(txParams);
|
5410
5607
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5411
5608
|
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
5412
5609
|
const txCost = await this.provider.getTransactionCost(request, {
|
5413
5610
|
estimateTxDependencies: true,
|
5414
5611
|
resourcesOwner: this
|
5415
5612
|
});
|
5416
|
-
this.validateGasLimitAndMaxFee({
|
5613
|
+
request = this.validateGasLimitAndMaxFee({
|
5614
|
+
transactionRequest: request,
|
5417
5615
|
gasUsed: txCost.gasUsed,
|
5418
5616
|
maxFee: txCost.maxFee,
|
5419
5617
|
txParams
|
5420
5618
|
});
|
5421
|
-
request.gasLimit = txCost.gasUsed;
|
5422
|
-
request.maxFee = txCost.maxFee;
|
5423
5619
|
await this.fund(request, txCost);
|
5424
5620
|
return request;
|
5425
5621
|
}
|
@@ -5433,7 +5629,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5433
5629
|
* @returns A promise that resolves to the transaction response.
|
5434
5630
|
*/
|
5435
5631
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5436
|
-
if ((0,
|
5632
|
+
if ((0, import_math21.bn)(amount).lte(0)) {
|
5437
5633
|
throw new import_errors16.FuelError(
|
5438
5634
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5439
5635
|
"Transfer amount must be a positive number."
|
@@ -5453,7 +5649,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5453
5649
|
* @returns A promise that resolves to the transaction response.
|
5454
5650
|
*/
|
5455
5651
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5456
|
-
if ((0,
|
5652
|
+
if ((0, import_math21.bn)(amount).lte(0)) {
|
5457
5653
|
throw new import_errors16.FuelError(
|
5458
5654
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5459
5655
|
"Transfer amount must be a positive number."
|
@@ -5463,10 +5659,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5463
5659
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5464
5660
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5465
5661
|
hexlifiedContractId: contractAddress.toB256(),
|
5466
|
-
amountToTransfer: (0,
|
5662
|
+
amountToTransfer: (0, import_math21.bn)(amount),
|
5467
5663
|
assetId: assetIdToTransfer
|
5468
5664
|
});
|
5469
|
-
|
5665
|
+
let request = new ScriptTransactionRequest({
|
5470
5666
|
...txParams,
|
5471
5667
|
script,
|
5472
5668
|
scriptData
|
@@ -5474,15 +5670,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5474
5670
|
request.addContractInputAndOutput(contractAddress);
|
5475
5671
|
const txCost = await this.provider.getTransactionCost(request, {
|
5476
5672
|
resourcesOwner: this,
|
5477
|
-
quantitiesToContract: [{ amount: (0,
|
5673
|
+
quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5478
5674
|
});
|
5479
|
-
this.validateGasLimitAndMaxFee({
|
5675
|
+
request = this.validateGasLimitAndMaxFee({
|
5676
|
+
transactionRequest: request,
|
5480
5677
|
gasUsed: txCost.gasUsed,
|
5481
5678
|
maxFee: txCost.maxFee,
|
5482
5679
|
txParams
|
5483
5680
|
});
|
5484
|
-
request.gasLimit = txCost.gasUsed;
|
5485
|
-
request.maxFee = txCost.maxFee;
|
5486
5681
|
await this.fund(request, txCost);
|
5487
5682
|
return this.sendTransaction(request);
|
5488
5683
|
}
|
@@ -5496,29 +5691,28 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5496
5691
|
*/
|
5497
5692
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5498
5693
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5499
|
-
const recipientDataArray = (0,
|
5694
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5500
5695
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5501
5696
|
);
|
5502
|
-
const amountDataArray = (0,
|
5503
|
-
"0x".concat((0,
|
5697
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5698
|
+
"0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5504
5699
|
);
|
5505
5700
|
const script = new Uint8Array([
|
5506
|
-
...(0,
|
5701
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5507
5702
|
...recipientDataArray,
|
5508
5703
|
...amountDataArray
|
5509
5704
|
]);
|
5510
5705
|
const params = { script, ...txParams };
|
5511
5706
|
const baseAssetId = this.provider.getBaseAssetId();
|
5512
|
-
|
5513
|
-
const quantitiesToContract = [{ amount: (0,
|
5707
|
+
let request = new ScriptTransactionRequest(params);
|
5708
|
+
const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
|
5514
5709
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5515
|
-
this.validateGasLimitAndMaxFee({
|
5710
|
+
request = this.validateGasLimitAndMaxFee({
|
5711
|
+
transactionRequest: request,
|
5516
5712
|
gasUsed: txCost.gasUsed,
|
5517
5713
|
maxFee: txCost.maxFee,
|
5518
5714
|
txParams
|
5519
5715
|
});
|
5520
|
-
request.maxFee = txCost.maxFee;
|
5521
|
-
request.gasLimit = txCost.gasUsed;
|
5522
5716
|
await this.fund(request, txCost);
|
5523
5717
|
return this.sendTransaction(request);
|
5524
5718
|
}
|
@@ -5578,35 +5772,42 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5578
5772
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5579
5773
|
}
|
5580
5774
|
validateGasLimitAndMaxFee({
|
5581
|
-
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
5582
5775
|
gasUsed,
|
5583
|
-
maxFee
|
5776
|
+
maxFee,
|
5777
|
+
transactionRequest,
|
5778
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5584
5779
|
}) {
|
5585
|
-
|
5780
|
+
const request = transactionRequestify(transactionRequest);
|
5781
|
+
if (!(0, import_utils28.isDefined)(setGasLimit)) {
|
5782
|
+
request.gasLimit = gasUsed;
|
5783
|
+
} else if (gasUsed.gt(setGasLimit)) {
|
5586
5784
|
throw new import_errors16.FuelError(
|
5587
5785
|
import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
|
5588
5786
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5589
5787
|
);
|
5590
5788
|
}
|
5591
|
-
if ((0,
|
5789
|
+
if (!(0, import_utils28.isDefined)(setMaxFee)) {
|
5790
|
+
request.maxFee = maxFee;
|
5791
|
+
} else if (maxFee.gt(setMaxFee)) {
|
5592
5792
|
throw new import_errors16.FuelError(
|
5593
5793
|
import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
|
5594
5794
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
5595
5795
|
);
|
5596
5796
|
}
|
5797
|
+
return request;
|
5597
5798
|
}
|
5598
5799
|
};
|
5599
5800
|
|
5600
5801
|
// src/wallet/base-wallet-unlocked.ts
|
5601
5802
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5602
|
-
var
|
5803
|
+
var import_utils31 = require("@fuel-ts/utils");
|
5603
5804
|
|
5604
5805
|
// src/signer/signer.ts
|
5605
5806
|
var import_address5 = require("@fuel-ts/address");
|
5606
5807
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5607
5808
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5608
|
-
var
|
5609
|
-
var
|
5809
|
+
var import_math22 = require("@fuel-ts/math");
|
5810
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5610
5811
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5611
5812
|
var Signer = class {
|
5612
5813
|
address;
|
@@ -5625,10 +5826,10 @@ var Signer = class {
|
|
5625
5826
|
privateKey = `0x${privateKey}`;
|
5626
5827
|
}
|
5627
5828
|
}
|
5628
|
-
const privateKeyBytes = (0,
|
5629
|
-
this.privateKey = (0,
|
5630
|
-
this.publicKey = (0,
|
5631
|
-
this.compressedPublicKey = (0,
|
5829
|
+
const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
|
5830
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5831
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5832
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5632
5833
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5633
5834
|
}
|
5634
5835
|
/**
|
@@ -5642,11 +5843,11 @@ var Signer = class {
|
|
5642
5843
|
* @returns hashed signature
|
5643
5844
|
*/
|
5644
5845
|
sign(data) {
|
5645
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5646
|
-
const r = (0,
|
5647
|
-
const s = (0,
|
5846
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5847
|
+
const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5848
|
+
const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5648
5849
|
s[0] |= (signature.recovery || 0) << 7;
|
5649
|
-
return (0,
|
5850
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5650
5851
|
}
|
5651
5852
|
/**
|
5652
5853
|
* Add point on the current elliptic curve
|
@@ -5655,8 +5856,8 @@ var Signer = class {
|
|
5655
5856
|
* @returns compressed point on the curve
|
5656
5857
|
*/
|
5657
5858
|
addPoint(point) {
|
5658
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5659
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5859
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5860
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5660
5861
|
const result = p0.add(p1);
|
5661
5862
|
return `0x${result.toHex(true)}`;
|
5662
5863
|
}
|
@@ -5668,16 +5869,16 @@ var Signer = class {
|
|
5668
5869
|
* @returns public key from signature from the
|
5669
5870
|
*/
|
5670
5871
|
static recoverPublicKey(data, signature) {
|
5671
|
-
const signedMessageBytes = (0,
|
5872
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5672
5873
|
const r = signedMessageBytes.slice(0, 32);
|
5673
5874
|
const s = signedMessageBytes.slice(32, 64);
|
5674
5875
|
const recoveryParam = (s[0] & 128) >> 7;
|
5675
5876
|
s[0] &= 127;
|
5676
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5877
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5677
5878
|
recoveryParam
|
5678
5879
|
);
|
5679
|
-
const publicKey = sig.recoverPublicKey((0,
|
5680
|
-
return (0,
|
5880
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5881
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5681
5882
|
}
|
5682
5883
|
/**
|
5683
5884
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5696,7 +5897,7 @@ var Signer = class {
|
|
5696
5897
|
* @returns random 32-byte hashed
|
5697
5898
|
*/
|
5698
5899
|
static generatePrivateKey(entropy) {
|
5699
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5900
|
+
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);
|
5700
5901
|
}
|
5701
5902
|
/**
|
5702
5903
|
* Extended publicKey from a compact publicKey
|
@@ -5705,8 +5906,8 @@ var Signer = class {
|
|
5705
5906
|
* @returns extended publicKey
|
5706
5907
|
*/
|
5707
5908
|
static extendPublicKey(publicKey) {
|
5708
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5709
|
-
return (0,
|
5909
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5910
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5710
5911
|
}
|
5711
5912
|
};
|
5712
5913
|
|
@@ -5714,7 +5915,7 @@ var Signer = class {
|
|
5714
5915
|
var import_address6 = require("@fuel-ts/address");
|
5715
5916
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5716
5917
|
var import_errors17 = require("@fuel-ts/errors");
|
5717
|
-
var
|
5918
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5718
5919
|
var import_uuid = require("uuid");
|
5719
5920
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5720
5921
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5797,7 +5998,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5797
5998
|
);
|
5798
5999
|
}
|
5799
6000
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5800
|
-
const privateKey = (0,
|
6001
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5801
6002
|
return privateKey;
|
5802
6003
|
}
|
5803
6004
|
|
@@ -5842,7 +6043,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5842
6043
|
*/
|
5843
6044
|
async signMessage(message) {
|
5844
6045
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5845
|
-
return (0,
|
6046
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
5846
6047
|
}
|
5847
6048
|
/**
|
5848
6049
|
* Signs a transaction with the wallet's private key.
|
@@ -5855,7 +6056,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5855
6056
|
const chainId = this.provider.getChainId();
|
5856
6057
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5857
6058
|
const signature = await this.signer().sign(hashedTransaction);
|
5858
|
-
return (0,
|
6059
|
+
return (0, import_utils31.hexlify)(signature);
|
5859
6060
|
}
|
5860
6061
|
/**
|
5861
6062
|
* Populates a transaction with the witnesses signature.
|
@@ -5916,16 +6117,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5916
6117
|
// src/hdwallet/hdwallet.ts
|
5917
6118
|
var import_errors20 = require("@fuel-ts/errors");
|
5918
6119
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5919
|
-
var
|
5920
|
-
var
|
5921
|
-
var
|
6120
|
+
var import_math23 = require("@fuel-ts/math");
|
6121
|
+
var import_utils35 = require("@fuel-ts/utils");
|
6122
|
+
var import_ethers2 = require("ethers");
|
5922
6123
|
|
5923
6124
|
// src/mnemonic/mnemonic.ts
|
5924
6125
|
var import_crypto4 = require("@fuel-ts/crypto");
|
5925
6126
|
var import_errors19 = require("@fuel-ts/errors");
|
5926
6127
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5927
|
-
var
|
5928
|
-
var
|
6128
|
+
var import_utils33 = require("@fuel-ts/utils");
|
6129
|
+
var import_ethers = require("ethers");
|
5929
6130
|
|
5930
6131
|
// src/wordlists/words/english.ts
|
5931
6132
|
var english = [
|
@@ -7988,7 +8189,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
7988
8189
|
// src/mnemonic/utils.ts
|
7989
8190
|
var import_errors18 = require("@fuel-ts/errors");
|
7990
8191
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7991
|
-
var
|
8192
|
+
var import_utils32 = require("@fuel-ts/utils");
|
7992
8193
|
function toUtf8Bytes(stri) {
|
7993
8194
|
const str = stri.normalize("NFKD");
|
7994
8195
|
const result = [];
|
@@ -8055,14 +8256,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
8055
8256
|
}
|
8056
8257
|
}
|
8057
8258
|
const checksumBits = entropy.length / 4;
|
8058
|
-
const checksum = (0,
|
8259
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8059
8260
|
indices[indices.length - 1] <<= checksumBits;
|
8060
8261
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8061
8262
|
return indices;
|
8062
8263
|
}
|
8063
8264
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8064
8265
|
const size = Math.ceil(11 * words.length / 8);
|
8065
|
-
const entropy = (0,
|
8266
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
8066
8267
|
let offset = 0;
|
8067
8268
|
for (let i = 0; i < words.length; i += 1) {
|
8068
8269
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -8082,7 +8283,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8082
8283
|
const entropyBits = 32 * words.length / 3;
|
8083
8284
|
const checksumBits = words.length / 3;
|
8084
8285
|
const checksumMask = getUpperMask(checksumBits);
|
8085
|
-
const checksum = (0,
|
8286
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8086
8287
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8087
8288
|
throw new import_errors18.FuelError(
|
8088
8289
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -8157,7 +8358,7 @@ var Mnemonic = class {
|
|
8157
8358
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8158
8359
|
const words = getWords(phrase);
|
8159
8360
|
assertMnemonic(words);
|
8160
|
-
return (0,
|
8361
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8161
8362
|
}
|
8162
8363
|
/**
|
8163
8364
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8165,7 +8366,7 @@ var Mnemonic = class {
|
|
8165
8366
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8166
8367
|
*/
|
8167
8368
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8168
|
-
const entropyBytes = (0,
|
8369
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
8169
8370
|
assertWordList(wordlist);
|
8170
8371
|
assertEntropy(entropyBytes);
|
8171
8372
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8179,7 +8380,7 @@ var Mnemonic = class {
|
|
8179
8380
|
assertMnemonic(getWords(phrase));
|
8180
8381
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
8181
8382
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
8182
|
-
return (0,
|
8383
|
+
return (0, import_ethers.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
8183
8384
|
}
|
8184
8385
|
/**
|
8185
8386
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -8234,14 +8435,14 @@ var Mnemonic = class {
|
|
8234
8435
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8235
8436
|
*/
|
8236
8437
|
static masterKeysFromSeed(seed) {
|
8237
|
-
const seedArray = (0,
|
8438
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
8238
8439
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8239
8440
|
throw new import_errors19.FuelError(
|
8240
8441
|
import_errors19.ErrorCode.INVALID_SEED,
|
8241
8442
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8242
8443
|
);
|
8243
8444
|
}
|
8244
|
-
return (0,
|
8445
|
+
return (0, import_utils33.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
|
8245
8446
|
}
|
8246
8447
|
/**
|
8247
8448
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8252,22 +8453,22 @@ var Mnemonic = class {
|
|
8252
8453
|
*/
|
8253
8454
|
static seedToExtendedKey(seed, testnet = false) {
|
8254
8455
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8255
|
-
const prefix = (0,
|
8456
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8256
8457
|
const depth = "0x00";
|
8257
8458
|
const fingerprint = "0x00000000";
|
8258
8459
|
const index = "0x00000000";
|
8259
8460
|
const chainCode = masterKey.slice(32);
|
8260
8461
|
const privateKey = masterKey.slice(0, 32);
|
8261
|
-
const extendedKey = (0,
|
8462
|
+
const extendedKey = (0, import_utils33.concat)([
|
8262
8463
|
prefix,
|
8263
8464
|
depth,
|
8264
8465
|
fingerprint,
|
8265
8466
|
index,
|
8266
8467
|
chainCode,
|
8267
|
-
(0,
|
8468
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
8268
8469
|
]);
|
8269
|
-
const checksum = (0,
|
8270
|
-
return (0,
|
8470
|
+
const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8471
|
+
return (0, import_ethers.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
8271
8472
|
}
|
8272
8473
|
/**
|
8273
8474
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8282,7 +8483,7 @@ var Mnemonic = class {
|
|
8282
8483
|
* @returns A randomly generated mnemonic
|
8283
8484
|
*/
|
8284
8485
|
static generate(size = 32, extraEntropy = "") {
|
8285
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8486
|
+
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);
|
8286
8487
|
return Mnemonic.entropyToMnemonic(entropy);
|
8287
8488
|
}
|
8288
8489
|
};
|
@@ -8290,12 +8491,12 @@ var mnemonic_default = Mnemonic;
|
|
8290
8491
|
|
8291
8492
|
// src/hdwallet/hdwallet.ts
|
8292
8493
|
var HARDENED_INDEX = 2147483648;
|
8293
|
-
var MainnetPRV2 = (0,
|
8294
|
-
var MainnetPUB = (0,
|
8295
|
-
var TestnetPRV2 = (0,
|
8296
|
-
var TestnetPUB = (0,
|
8494
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
8495
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
8496
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8497
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
8297
8498
|
function base58check(data) {
|
8298
|
-
return (0,
|
8499
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers2.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
8299
8500
|
}
|
8300
8501
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8301
8502
|
if (isPublic) {
|
@@ -8304,11 +8505,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8304
8505
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8305
8506
|
}
|
8306
8507
|
function isPublicExtendedKey(extendedKey) {
|
8307
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8508
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
8308
8509
|
}
|
8309
8510
|
function isValidExtendedKey(extendedKey) {
|
8310
8511
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8311
|
-
(0,
|
8512
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
8312
8513
|
);
|
8313
8514
|
}
|
8314
8515
|
function parsePath(path, depth = 0) {
|
@@ -8326,8 +8527,8 @@ function parsePath(path, depth = 0) {
|
|
8326
8527
|
var HDWallet = class {
|
8327
8528
|
depth = 0;
|
8328
8529
|
index = 0;
|
8329
|
-
fingerprint = (0,
|
8330
|
-
parentFingerprint = (0,
|
8530
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8531
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8331
8532
|
privateKey;
|
8332
8533
|
publicKey;
|
8333
8534
|
chainCode;
|
@@ -8339,8 +8540,8 @@ var HDWallet = class {
|
|
8339
8540
|
constructor(config) {
|
8340
8541
|
if (config.privateKey) {
|
8341
8542
|
const signer = new Signer(config.privateKey);
|
8342
|
-
this.publicKey = (0,
|
8343
|
-
this.privateKey = (0,
|
8543
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
8544
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
8344
8545
|
} else {
|
8345
8546
|
if (!config.publicKey) {
|
8346
8547
|
throw new import_errors20.FuelError(
|
@@ -8348,10 +8549,10 @@ var HDWallet = class {
|
|
8348
8549
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8349
8550
|
);
|
8350
8551
|
}
|
8351
|
-
this.publicKey = (0,
|
8552
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8352
8553
|
}
|
8353
8554
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8354
|
-
this.fingerprint = (0,
|
8555
|
+
this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8355
8556
|
this.depth = config.depth || this.depth;
|
8356
8557
|
this.index = config.index || this.index;
|
8357
8558
|
this.chainCode = config.chainCode;
|
@@ -8367,9 +8568,9 @@ var HDWallet = class {
|
|
8367
8568
|
* @returns A new instance of HDWallet on the derived index
|
8368
8569
|
*/
|
8369
8570
|
deriveIndex(index) {
|
8370
|
-
const privateKey = this.privateKey && (0,
|
8371
|
-
const publicKey = (0,
|
8372
|
-
const chainCode = (0,
|
8571
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
8572
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
8573
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
8373
8574
|
const data = new Uint8Array(37);
|
8374
8575
|
if (index & HARDENED_INDEX) {
|
8375
8576
|
if (!privateKey) {
|
@@ -8380,15 +8581,15 @@ var HDWallet = class {
|
|
8380
8581
|
}
|
8381
8582
|
data.set(privateKey, 1);
|
8382
8583
|
} else {
|
8383
|
-
data.set((0,
|
8584
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8384
8585
|
}
|
8385
|
-
data.set((0,
|
8386
|
-
const bytes = (0,
|
8586
|
+
data.set((0, import_math23.toBytes)(index, 4), 33);
|
8587
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
|
8387
8588
|
const IL = bytes.slice(0, 32);
|
8388
8589
|
const IR = bytes.slice(32);
|
8389
8590
|
if (privateKey) {
|
8390
8591
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8391
|
-
const ki = (0,
|
8592
|
+
const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
8392
8593
|
return new HDWallet({
|
8393
8594
|
privateKey: ki,
|
8394
8595
|
chainCode: IR,
|
@@ -8397,7 +8598,7 @@ var HDWallet = class {
|
|
8397
8598
|
parentFingerprint: this.fingerprint
|
8398
8599
|
});
|
8399
8600
|
}
|
8400
|
-
const signer = new Signer((0,
|
8601
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
8401
8602
|
const Ki = signer.addPoint(publicKey);
|
8402
8603
|
return new HDWallet({
|
8403
8604
|
publicKey: Ki,
|
@@ -8432,12 +8633,12 @@ var HDWallet = class {
|
|
8432
8633
|
);
|
8433
8634
|
}
|
8434
8635
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8435
|
-
const depth = (0,
|
8636
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8436
8637
|
const parentFingerprint = this.parentFingerprint;
|
8437
|
-
const index = (0,
|
8638
|
+
const index = (0, import_math23.toHex)(this.index, 4);
|
8438
8639
|
const chainCode = this.chainCode;
|
8439
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8440
|
-
const extendedKey = (0,
|
8640
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8641
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8441
8642
|
return base58check(extendedKey);
|
8442
8643
|
}
|
8443
8644
|
/**
|
@@ -8449,13 +8650,13 @@ var HDWallet = class {
|
|
8449
8650
|
static fromSeed(seed) {
|
8450
8651
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8451
8652
|
return new HDWallet({
|
8452
|
-
chainCode: (0,
|
8453
|
-
privateKey: (0,
|
8653
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8654
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8454
8655
|
});
|
8455
8656
|
}
|
8456
8657
|
static fromExtendedKey(extendedKey) {
|
8457
|
-
const decoded = (0,
|
8458
|
-
const bytes = (0,
|
8658
|
+
const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
|
8659
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8459
8660
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8460
8661
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8461
8662
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8464,9 +8665,9 @@ var HDWallet = class {
|
|
8464
8665
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8465
8666
|
}
|
8466
8667
|
const depth = bytes[4];
|
8467
|
-
const parentFingerprint = (0,
|
8468
|
-
const index = parseInt((0,
|
8469
|
-
const chainCode = (0,
|
8668
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8669
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8670
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8470
8671
|
const key = bytes.slice(45, 78);
|
8471
8672
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8472
8673
|
throw new import_errors20.FuelError(
|
@@ -9070,19 +9271,19 @@ var StorageAbstract = class {
|
|
9070
9271
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
9071
9272
|
var import_address10 = require("@fuel-ts/address");
|
9072
9273
|
var import_errors25 = require("@fuel-ts/errors");
|
9073
|
-
var
|
9074
|
-
var
|
9274
|
+
var import_transactions22 = require("@fuel-ts/transactions");
|
9275
|
+
var import_utils37 = require("@fuel-ts/utils");
|
9075
9276
|
|
9076
9277
|
// src/predicate/utils/getPredicateRoot.ts
|
9077
9278
|
var import_hasher7 = require("@fuel-ts/hasher");
|
9078
9279
|
var import_merkle = require("@fuel-ts/merkle");
|
9079
|
-
var
|
9280
|
+
var import_utils36 = require("@fuel-ts/utils");
|
9080
9281
|
var getPredicateRoot = (bytecode) => {
|
9081
9282
|
const chunkSize = 16 * 1024;
|
9082
|
-
const bytes = (0,
|
9083
|
-
const chunks = (0,
|
9084
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
9085
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
9283
|
+
const bytes = (0, import_utils36.arrayify)(bytecode);
|
9284
|
+
const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
|
9285
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
|
9286
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
|
9086
9287
|
return predicateRoot;
|
9087
9288
|
};
|
9088
9289
|
|
@@ -9130,9 +9331,9 @@ var Predicate = class extends Account {
|
|
9130
9331
|
const request = transactionRequestify(transactionRequestLike);
|
9131
9332
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9132
9333
|
request.inputs?.forEach((input) => {
|
9133
|
-
if (input.type ===
|
9134
|
-
input.predicate = (0,
|
9135
|
-
input.predicateData = (0,
|
9334
|
+
if (input.type === import_transactions22.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
|
9335
|
+
input.predicate = (0, import_utils37.hexlify)(this.bytes);
|
9336
|
+
input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData(policies.length));
|
9136
9337
|
}
|
9137
9338
|
});
|
9138
9339
|
return request;
|
@@ -9162,9 +9363,9 @@ var Predicate = class extends Account {
|
|
9162
9363
|
return new Uint8Array();
|
9163
9364
|
}
|
9164
9365
|
const mainFn = this.interface?.functions.main;
|
9165
|
-
const paddedCode = new
|
9366
|
+
const paddedCode = new import_transactions22.ByteArrayCoder(this.bytes.length).encode(this.bytes);
|
9166
9367
|
const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
|
9167
|
-
maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
|
9368
|
+
maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
|
9168
9369
|
});
|
9169
9370
|
const OFFSET = VM_TX_MEMORY + import_abi_coder7.SCRIPT_FIXED_SIZE + import_abi_coder7.INPUT_COIN_FIXED_SIZE + import_abi_coder7.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder7.WORD_SIZE;
|
9170
9371
|
return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
|
@@ -9178,7 +9379,7 @@ var Predicate = class extends Account {
|
|
9178
9379
|
* @returns An object containing the new predicate bytes and interface.
|
9179
9380
|
*/
|
9180
9381
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9181
|
-
let predicateBytes = (0,
|
9382
|
+
let predicateBytes = (0, import_utils37.arrayify)(bytes);
|
9182
9383
|
let abiInterface;
|
9183
9384
|
if (jsonAbi) {
|
9184
9385
|
abiInterface = new import_abi_coder7.Interface(jsonAbi);
|
@@ -9216,8 +9417,8 @@ var Predicate = class extends Account {
|
|
9216
9417
|
);
|
9217
9418
|
return resources.map((resource) => ({
|
9218
9419
|
...resource,
|
9219
|
-
predicate: (0,
|
9220
|
-
padPredicateData: (policiesLength) => (0,
|
9420
|
+
predicate: (0, import_utils37.hexlify)(this.bytes),
|
9421
|
+
padPredicateData: (policiesLength) => (0, import_utils37.hexlify)(this.getPredicateData(policiesLength))
|
9221
9422
|
}));
|
9222
9423
|
}
|
9223
9424
|
/**
|
@@ -9982,7 +10183,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9982
10183
|
calculateGasFee,
|
9983
10184
|
calculateMetadataGasForTxCreate,
|
9984
10185
|
calculateMetadataGasForTxScript,
|
9985
|
-
|
10186
|
+
calculateTXFeeForSummary,
|
9986
10187
|
coinQuantityfy,
|
9987
10188
|
deferPromise,
|
9988
10189
|
dispatchFuelConnectorEvent,
|
@@ -9990,6 +10191,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9990
10191
|
extractBurnedAssetsFromReceipts,
|
9991
10192
|
extractMintedAssetsFromReceipts,
|
9992
10193
|
extractTxError,
|
10194
|
+
fuelAssetsBaseUrl,
|
9993
10195
|
gasUsedByInputs,
|
9994
10196
|
getAssetEth,
|
9995
10197
|
getAssetFuel,
|
@@ -10042,10 +10244,13 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10042
10244
|
isTypeCreate,
|
10043
10245
|
isTypeMint,
|
10044
10246
|
isTypeScript,
|
10247
|
+
isTypeUpgrade,
|
10248
|
+
isTypeUpload,
|
10045
10249
|
normalizeJSON,
|
10046
10250
|
outputify,
|
10047
10251
|
processGqlReceipt,
|
10048
10252
|
processGraphqlStatus,
|
10253
|
+
rawAssets,
|
10049
10254
|
resolveGasDependentCosts,
|
10050
10255
|
resolveIconPaths,
|
10051
10256
|
returnZeroScript,
|