@fuel-ts/account 0.0.0-rc-2241-20240508114911 → 0.0.0-rc-2037-20240508123129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/index.global.js +197 -168
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +430 -387
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +337 -301
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +9 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +552 -346
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +10 -4
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +4 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -0
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -4
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-summary/receipt.d.ts +2 -2
- package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +13 -5
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +2 -2
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts +2 -2
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/test-utils/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +163 -175
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +373 -385
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +292 -304
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +15 -15
package/dist/index.js
CHANGED
@@ -88,7 +88,7 @@ __export(src_exports, {
|
|
88
88
|
StorageAbstract: () => StorageAbstract,
|
89
89
|
TransactionResponse: () => TransactionResponse,
|
90
90
|
TransactionStatus: () => TransactionStatus,
|
91
|
-
TransactionType: () =>
|
91
|
+
TransactionType: () => import_transactions7.TransactionType,
|
92
92
|
TransactionTypeName: () => TransactionTypeName,
|
93
93
|
Vault: () => Vault,
|
94
94
|
Wallet: () => Wallet,
|
@@ -104,7 +104,8 @@ __export(src_exports, {
|
|
104
104
|
assets: () => assets,
|
105
105
|
buildBlockExplorerUrl: () => buildBlockExplorerUrl,
|
106
106
|
cacheFor: () => cacheFor,
|
107
|
-
|
107
|
+
cacheRequestInputsResources: () => cacheRequestInputsResources,
|
108
|
+
cacheRequestInputsResourcesFromOwner: () => cacheRequestInputsResourcesFromOwner,
|
108
109
|
calculateGasFee: () => calculateGasFee,
|
109
110
|
calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
|
110
111
|
calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
|
@@ -117,6 +118,7 @@ __export(src_exports, {
|
|
117
118
|
extractMintedAssetsFromReceipts: () => extractMintedAssetsFromReceipts,
|
118
119
|
extractTxError: () => extractTxError,
|
119
120
|
gasUsedByInputs: () => gasUsedByInputs,
|
121
|
+
getAssetAmountInRequestInputs: () => getAssetAmountInRequestInputs,
|
120
122
|
getAssetEth: () => getAssetEth,
|
121
123
|
getAssetFuel: () => getAssetFuel,
|
122
124
|
getAssetNetwork: () => getAssetNetwork,
|
@@ -151,6 +153,7 @@ __export(src_exports, {
|
|
151
153
|
getReceiptsMessageOut: () => getReceiptsMessageOut,
|
152
154
|
getReceiptsTransferOut: () => getReceiptsTransferOut,
|
153
155
|
getReceiptsWithMissingData: () => getReceiptsWithMissingData,
|
156
|
+
getRequestInputResourceOwner: () => getRequestInputResourceOwner,
|
154
157
|
getTransactionStatusName: () => getTransactionStatusName,
|
155
158
|
getTransactionSummary: () => getTransactionSummary,
|
156
159
|
getTransactionSummaryFromRequest: () => getTransactionSummaryFromRequest,
|
@@ -164,6 +167,10 @@ __export(src_exports, {
|
|
164
167
|
isMessage: () => isMessage,
|
165
168
|
isRawCoin: () => isRawCoin,
|
166
169
|
isRawMessage: () => isRawMessage,
|
170
|
+
isRequestInputCoin: () => isRequestInputCoin,
|
171
|
+
isRequestInputMessage: () => isRequestInputMessage,
|
172
|
+
isRequestInputResource: () => isRequestInputResource,
|
173
|
+
isRequestInputResourceFromOwner: () => isRequestInputResourceFromOwner,
|
167
174
|
isType: () => isType,
|
168
175
|
isTypeCreate: () => isTypeCreate,
|
169
176
|
isTypeMint: () => isTypeMint,
|
@@ -231,8 +238,8 @@ var addAmountToCoinQuantities = (params) => {
|
|
231
238
|
// src/providers/provider.ts
|
232
239
|
var import_address3 = require("@fuel-ts/address");
|
233
240
|
var import_errors14 = require("@fuel-ts/errors");
|
234
|
-
var
|
235
|
-
var
|
241
|
+
var import_math18 = require("@fuel-ts/math");
|
242
|
+
var import_transactions20 = require("@fuel-ts/transactions");
|
236
243
|
var import_utils22 = require("@fuel-ts/utils");
|
237
244
|
var import_versions = require("@fuel-ts/versions");
|
238
245
|
var import_utils23 = require("@noble/curves/abstract/utils");
|
@@ -241,7 +248,7 @@ var import_ramda3 = require("ramda");
|
|
241
248
|
|
242
249
|
// src/providers/__generated__/operations.ts
|
243
250
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
244
|
-
var
|
251
|
+
var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.default`
|
245
252
|
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
246
253
|
type: __typename
|
247
254
|
... on SqueezedOutStatus {
|
@@ -249,13 +256,7 @@ var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
|
|
249
256
|
}
|
250
257
|
}
|
251
258
|
`;
|
252
|
-
var
|
253
|
-
fragment SubmittedStatusFragment on SubmittedStatus {
|
254
|
-
type: __typename
|
255
|
-
time
|
256
|
-
}
|
257
|
-
`;
|
258
|
-
var ReceiptFragmentDoc = import_graphql_tag.default`
|
259
|
+
var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
|
259
260
|
fragment receiptFragment on Receipt {
|
260
261
|
id
|
261
262
|
pc
|
@@ -287,65 +288,45 @@ var ReceiptFragmentDoc = import_graphql_tag.default`
|
|
287
288
|
subId
|
288
289
|
}
|
289
290
|
`;
|
290
|
-
var
|
291
|
-
fragment SuccessStatusFragment on SuccessStatus {
|
292
|
-
type: __typename
|
293
|
-
block {
|
294
|
-
id
|
295
|
-
}
|
296
|
-
time
|
297
|
-
programState {
|
298
|
-
returnType
|
299
|
-
data
|
300
|
-
}
|
301
|
-
receipts {
|
302
|
-
...receiptFragment
|
303
|
-
}
|
304
|
-
totalGas
|
305
|
-
totalFee
|
306
|
-
}
|
307
|
-
${ReceiptFragmentDoc}`;
|
308
|
-
var FailureStatusFragmentDoc = import_graphql_tag.default`
|
309
|
-
fragment FailureStatusFragment on FailureStatus {
|
310
|
-
type: __typename
|
311
|
-
block {
|
312
|
-
id
|
313
|
-
}
|
314
|
-
totalGas
|
315
|
-
totalFee
|
316
|
-
time
|
317
|
-
reason
|
318
|
-
receipts {
|
319
|
-
...receiptFragment
|
320
|
-
}
|
321
|
-
}
|
322
|
-
${ReceiptFragmentDoc}`;
|
323
|
-
var SqueezedOutStatusFragmentDoc = import_graphql_tag.default`
|
324
|
-
fragment SqueezedOutStatusFragment on SqueezedOutStatus {
|
325
|
-
type: __typename
|
326
|
-
reason
|
327
|
-
}
|
328
|
-
`;
|
329
|
-
var TransactionStatusFragmentDoc = import_graphql_tag.default`
|
291
|
+
var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
330
292
|
fragment transactionStatusFragment on TransactionStatus {
|
293
|
+
type: __typename
|
331
294
|
... on SubmittedStatus {
|
332
|
-
|
295
|
+
time
|
333
296
|
}
|
334
297
|
... on SuccessStatus {
|
335
|
-
|
298
|
+
block {
|
299
|
+
id
|
300
|
+
}
|
301
|
+
time
|
302
|
+
programState {
|
303
|
+
returnType
|
304
|
+
data
|
305
|
+
}
|
306
|
+
receipts {
|
307
|
+
...receiptFragment
|
308
|
+
}
|
309
|
+
totalGas
|
310
|
+
totalFee
|
336
311
|
}
|
337
312
|
... on FailureStatus {
|
338
|
-
|
313
|
+
block {
|
314
|
+
id
|
315
|
+
}
|
316
|
+
totalGas
|
317
|
+
totalFee
|
318
|
+
time
|
319
|
+
reason
|
320
|
+
receipts {
|
321
|
+
...receiptFragment
|
322
|
+
}
|
339
323
|
}
|
340
324
|
... on SqueezedOutStatus {
|
341
|
-
|
325
|
+
reason
|
342
326
|
}
|
343
327
|
}
|
344
|
-
${
|
345
|
-
|
346
|
-
${FailureStatusFragmentDoc}
|
347
|
-
${SqueezedOutStatusFragmentDoc}`;
|
348
|
-
var TransactionFragmentDoc = import_graphql_tag.default`
|
328
|
+
${ReceiptFragmentFragmentDoc}`;
|
329
|
+
var TransactionFragmentFragmentDoc = import_graphql_tag.default`
|
349
330
|
fragment transactionFragment on Transaction {
|
350
331
|
id
|
351
332
|
rawPayload
|
@@ -353,8 +334,8 @@ var TransactionFragmentDoc = import_graphql_tag.default`
|
|
353
334
|
...transactionStatusFragment
|
354
335
|
}
|
355
336
|
}
|
356
|
-
${
|
357
|
-
var
|
337
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
338
|
+
var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
|
358
339
|
fragment inputEstimatePredicatesFragment on Input {
|
359
340
|
... on InputCoin {
|
360
341
|
predicateGasUsed
|
@@ -364,14 +345,14 @@ var InputEstimatePredicatesFragmentDoc = import_graphql_tag.default`
|
|
364
345
|
}
|
365
346
|
}
|
366
347
|
`;
|
367
|
-
var
|
348
|
+
var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
|
368
349
|
fragment transactionEstimatePredicatesFragment on Transaction {
|
369
350
|
inputs {
|
370
351
|
...inputEstimatePredicatesFragment
|
371
352
|
}
|
372
353
|
}
|
373
|
-
${
|
374
|
-
var
|
354
|
+
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
355
|
+
var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
|
375
356
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
376
357
|
totalGas
|
377
358
|
totalFee
|
@@ -382,7 +363,7 @@ var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
|
|
382
363
|
}
|
383
364
|
}
|
384
365
|
`;
|
385
|
-
var
|
366
|
+
var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
|
386
367
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
387
368
|
totalGas
|
388
369
|
totalFee
|
@@ -392,7 +373,7 @@ var DryRunSuccessStatusFragmentDoc = import_graphql_tag.default`
|
|
392
373
|
}
|
393
374
|
}
|
394
375
|
`;
|
395
|
-
var
|
376
|
+
var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
396
377
|
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
397
378
|
... on DryRunFailureStatus {
|
398
379
|
...dryRunFailureStatusFragment
|
@@ -401,9 +382,9 @@ var DryRunTransactionStatusFragmentDoc = import_graphql_tag.default`
|
|
401
382
|
...dryRunSuccessStatusFragment
|
402
383
|
}
|
403
384
|
}
|
404
|
-
${
|
405
|
-
${
|
406
|
-
var
|
385
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
386
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
387
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
407
388
|
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
408
389
|
id
|
409
390
|
status {
|
@@ -413,11 +394,11 @@ var DryRunTransactionExecutionStatusFragmentDoc = import_graphql_tag.default`
|
|
413
394
|
...receiptFragment
|
414
395
|
}
|
415
396
|
}
|
416
|
-
${
|
417
|
-
${
|
418
|
-
var
|
397
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
398
|
+
${ReceiptFragmentFragmentDoc}`;
|
399
|
+
var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
419
400
|
fragment coinFragment on Coin {
|
420
|
-
|
401
|
+
__typename
|
421
402
|
utxoId
|
422
403
|
owner
|
423
404
|
amount
|
@@ -426,9 +407,9 @@ var CoinFragmentDoc = import_graphql_tag.default`
|
|
426
407
|
txCreatedIdx
|
427
408
|
}
|
428
409
|
`;
|
429
|
-
var
|
410
|
+
var MessageCoinFragmentFragmentDoc = import_graphql_tag.default`
|
430
411
|
fragment messageCoinFragment on MessageCoin {
|
431
|
-
|
412
|
+
__typename
|
432
413
|
sender
|
433
414
|
recipient
|
434
415
|
nonce
|
@@ -437,7 +418,7 @@ var MessageCoinFragmentDoc = import_graphql_tag.default`
|
|
437
418
|
daHeight
|
438
419
|
}
|
439
420
|
`;
|
440
|
-
var
|
421
|
+
var MessageFragmentFragmentDoc = import_graphql_tag.default`
|
441
422
|
fragment messageFragment on Message {
|
442
423
|
amount
|
443
424
|
sender
|
@@ -447,7 +428,7 @@ var MessageFragmentDoc = import_graphql_tag.default`
|
|
447
428
|
daHeight
|
448
429
|
}
|
449
430
|
`;
|
450
|
-
var
|
431
|
+
var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
|
451
432
|
fragment messageProofFragment on MessageProof {
|
452
433
|
messageProof {
|
453
434
|
proofSet
|
@@ -494,14 +475,14 @@ var MessageProofFragmentDoc = import_graphql_tag.default`
|
|
494
475
|
data
|
495
476
|
}
|
496
477
|
`;
|
497
|
-
var
|
478
|
+
var BalanceFragmentFragmentDoc = import_graphql_tag.default`
|
498
479
|
fragment balanceFragment on Balance {
|
499
480
|
owner
|
500
481
|
amount
|
501
482
|
assetId
|
502
483
|
}
|
503
484
|
`;
|
504
|
-
var
|
485
|
+
var BlockFragmentFragmentDoc = import_graphql_tag.default`
|
505
486
|
fragment blockFragment on Block {
|
506
487
|
id
|
507
488
|
height
|
@@ -513,7 +494,7 @@ var BlockFragmentDoc = import_graphql_tag.default`
|
|
513
494
|
}
|
514
495
|
}
|
515
496
|
`;
|
516
|
-
var
|
497
|
+
var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
|
517
498
|
fragment TxParametersFragment on TxParameters {
|
518
499
|
version
|
519
500
|
maxInputs
|
@@ -524,7 +505,7 @@ var TxParametersFragmentDoc = import_graphql_tag.default`
|
|
524
505
|
maxBytecodeSubsections
|
525
506
|
}
|
526
507
|
`;
|
527
|
-
var
|
508
|
+
var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
|
528
509
|
fragment PredicateParametersFragment on PredicateParameters {
|
529
510
|
version
|
530
511
|
maxPredicateLength
|
@@ -533,42 +514,41 @@ var PredicateParametersFragmentDoc = import_graphql_tag.default`
|
|
533
514
|
maxMessageDataLength
|
534
515
|
}
|
535
516
|
`;
|
536
|
-
var
|
517
|
+
var ScriptParametersFragmentFragmentDoc = import_graphql_tag.default`
|
537
518
|
fragment ScriptParametersFragment on ScriptParameters {
|
538
519
|
version
|
539
520
|
maxScriptLength
|
540
521
|
maxScriptDataLength
|
541
522
|
}
|
542
523
|
`;
|
543
|
-
var
|
524
|
+
var ContractParametersFragmentFragmentDoc = import_graphql_tag.default`
|
544
525
|
fragment ContractParametersFragment on ContractParameters {
|
545
526
|
version
|
546
527
|
contractMaxSize
|
547
528
|
maxStorageSlots
|
548
529
|
}
|
549
530
|
`;
|
550
|
-
var
|
531
|
+
var FeeParametersFragmentFragmentDoc = import_graphql_tag.default`
|
551
532
|
fragment FeeParametersFragment on FeeParameters {
|
552
533
|
version
|
553
534
|
gasPriceFactor
|
554
535
|
gasPerByte
|
555
536
|
}
|
556
537
|
`;
|
557
|
-
var
|
538
|
+
var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
|
558
539
|
fragment DependentCostFragment on DependentCost {
|
540
|
+
__typename
|
559
541
|
... on LightOperation {
|
560
|
-
type: __typename
|
561
542
|
base
|
562
543
|
unitsPerGas
|
563
544
|
}
|
564
545
|
... on HeavyOperation {
|
565
|
-
type: __typename
|
566
546
|
base
|
567
547
|
gasPerUnit
|
568
548
|
}
|
569
549
|
}
|
570
550
|
`;
|
571
|
-
var
|
551
|
+
var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
572
552
|
fragment GasCostsFragment on GasCosts {
|
573
553
|
version
|
574
554
|
add
|
@@ -724,8 +704,8 @@ var GasCostsFragmentDoc = import_graphql_tag.default`
|
|
724
704
|
}
|
725
705
|
newStoragePerByte
|
726
706
|
}
|
727
|
-
${
|
728
|
-
var
|
707
|
+
${DependentCostFragmentFragmentDoc}`;
|
708
|
+
var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
|
729
709
|
fragment consensusParametersFragment on ConsensusParameters {
|
730
710
|
version
|
731
711
|
txParams {
|
@@ -749,13 +729,13 @@ var ConsensusParametersFragmentDoc = import_graphql_tag.default`
|
|
749
729
|
baseAssetId
|
750
730
|
chainId
|
751
731
|
}
|
752
|
-
${
|
753
|
-
${
|
754
|
-
${
|
755
|
-
${
|
756
|
-
${
|
757
|
-
${
|
758
|
-
var
|
732
|
+
${TxParametersFragmentFragmentDoc}
|
733
|
+
${PredicateParametersFragmentFragmentDoc}
|
734
|
+
${ScriptParametersFragmentFragmentDoc}
|
735
|
+
${ContractParametersFragmentFragmentDoc}
|
736
|
+
${FeeParametersFragmentFragmentDoc}
|
737
|
+
${GasCostsFragmentFragmentDoc}`;
|
738
|
+
var ChainInfoFragmentFragmentDoc = import_graphql_tag.default`
|
759
739
|
fragment chainInfoFragment on ChainInfo {
|
760
740
|
name
|
761
741
|
latestBlock {
|
@@ -766,16 +746,16 @@ var ChainInfoFragmentDoc = import_graphql_tag.default`
|
|
766
746
|
...consensusParametersFragment
|
767
747
|
}
|
768
748
|
}
|
769
|
-
${
|
770
|
-
${
|
771
|
-
var
|
749
|
+
${BlockFragmentFragmentDoc}
|
750
|
+
${ConsensusParametersFragmentFragmentDoc}`;
|
751
|
+
var ContractBalanceFragmentFragmentDoc = import_graphql_tag.default`
|
772
752
|
fragment contractBalanceFragment on ContractBalance {
|
773
753
|
contract
|
774
754
|
amount
|
775
755
|
assetId
|
776
756
|
}
|
777
757
|
`;
|
778
|
-
var
|
758
|
+
var PageInfoFragmentFragmentDoc = import_graphql_tag.default`
|
779
759
|
fragment pageInfoFragment on PageInfo {
|
780
760
|
hasPreviousPage
|
781
761
|
hasNextPage
|
@@ -783,7 +763,7 @@ var PageInfoFragmentDoc = import_graphql_tag.default`
|
|
783
763
|
endCursor
|
784
764
|
}
|
785
765
|
`;
|
786
|
-
var
|
766
|
+
var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
|
787
767
|
fragment nodeInfoFragment on NodeInfo {
|
788
768
|
utxoValidation
|
789
769
|
vmBacktrace
|
@@ -792,7 +772,7 @@ var NodeInfoFragmentDoc = import_graphql_tag.default`
|
|
792
772
|
nodeVersion
|
793
773
|
}
|
794
774
|
`;
|
795
|
-
var
|
775
|
+
var RelayedTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
796
776
|
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
797
777
|
... on RelayedTransactionFailed {
|
798
778
|
blockHeight
|
@@ -813,28 +793,28 @@ var GetNodeInfoDocument = import_graphql_tag.default`
|
|
813
793
|
...nodeInfoFragment
|
814
794
|
}
|
815
795
|
}
|
816
|
-
${
|
796
|
+
${NodeInfoFragmentFragmentDoc}`;
|
817
797
|
var GetChainDocument = import_graphql_tag.default`
|
818
798
|
query getChain {
|
819
799
|
chain {
|
820
800
|
...chainInfoFragment
|
821
801
|
}
|
822
802
|
}
|
823
|
-
${
|
803
|
+
${ChainInfoFragmentFragmentDoc}`;
|
824
804
|
var GetTransactionDocument = import_graphql_tag.default`
|
825
805
|
query getTransaction($transactionId: TransactionId!) {
|
826
806
|
transaction(id: $transactionId) {
|
827
807
|
...transactionFragment
|
828
808
|
}
|
829
809
|
}
|
830
|
-
${
|
810
|
+
${TransactionFragmentFragmentDoc}`;
|
831
811
|
var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
|
832
812
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
833
813
|
transaction(id: $transactionId) {
|
834
814
|
...transactionFragment
|
835
815
|
}
|
836
816
|
}
|
837
|
-
${
|
817
|
+
${TransactionFragmentFragmentDoc}`;
|
838
818
|
var GetTransactionsDocument = import_graphql_tag.default`
|
839
819
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
840
820
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -845,7 +825,7 @@ var GetTransactionsDocument = import_graphql_tag.default`
|
|
845
825
|
}
|
846
826
|
}
|
847
827
|
}
|
848
|
-
${
|
828
|
+
${TransactionFragmentFragmentDoc}`;
|
849
829
|
var GetTransactionsByOwnerDocument = import_graphql_tag.default`
|
850
830
|
query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
851
831
|
transactionsByOwner(
|
@@ -865,22 +845,22 @@ var GetTransactionsByOwnerDocument = import_graphql_tag.default`
|
|
865
845
|
}
|
866
846
|
}
|
867
847
|
}
|
868
|
-
${
|
869
|
-
${
|
848
|
+
${PageInfoFragmentFragmentDoc}
|
849
|
+
${TransactionFragmentFragmentDoc}`;
|
870
850
|
var EstimatePredicatesDocument = import_graphql_tag.default`
|
871
851
|
query estimatePredicates($encodedTransaction: HexString!) {
|
872
852
|
estimatePredicates(tx: $encodedTransaction) {
|
873
853
|
...transactionEstimatePredicatesFragment
|
874
854
|
}
|
875
855
|
}
|
876
|
-
${
|
856
|
+
${TransactionEstimatePredicatesFragmentFragmentDoc}`;
|
877
857
|
var GetBlockDocument = import_graphql_tag.default`
|
878
858
|
query getBlock($blockId: BlockId, $height: U32) {
|
879
859
|
block(id: $blockId, height: $height) {
|
880
860
|
...blockFragment
|
881
861
|
}
|
882
862
|
}
|
883
|
-
${
|
863
|
+
${BlockFragmentFragmentDoc}`;
|
884
864
|
var GetBlockWithTransactionsDocument = import_graphql_tag.default`
|
885
865
|
query getBlockWithTransactions($blockId: BlockId, $blockHeight: U32) {
|
886
866
|
block(id: $blockId, height: $blockHeight) {
|
@@ -890,8 +870,8 @@ var GetBlockWithTransactionsDocument = import_graphql_tag.default`
|
|
890
870
|
}
|
891
871
|
}
|
892
872
|
}
|
893
|
-
${
|
894
|
-
${
|
873
|
+
${BlockFragmentFragmentDoc}
|
874
|
+
${TransactionFragmentFragmentDoc}`;
|
895
875
|
var GetBlocksDocument = import_graphql_tag.default`
|
896
876
|
query getBlocks($after: String, $before: String, $first: Int, $last: Int) {
|
897
877
|
blocks(after: $after, before: $before, first: $first, last: $last) {
|
@@ -902,14 +882,14 @@ var GetBlocksDocument = import_graphql_tag.default`
|
|
902
882
|
}
|
903
883
|
}
|
904
884
|
}
|
905
|
-
${
|
885
|
+
${BlockFragmentFragmentDoc}`;
|
906
886
|
var GetCoinDocument = import_graphql_tag.default`
|
907
887
|
query getCoin($coinId: UtxoId!) {
|
908
888
|
coin(utxoId: $coinId) {
|
909
889
|
...coinFragment
|
910
890
|
}
|
911
891
|
}
|
912
|
-
${
|
892
|
+
${CoinFragmentFragmentDoc}`;
|
913
893
|
var GetCoinsDocument = import_graphql_tag.default`
|
914
894
|
query getCoins($filter: CoinFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
915
895
|
coins(
|
@@ -926,7 +906,7 @@ var GetCoinsDocument = import_graphql_tag.default`
|
|
926
906
|
}
|
927
907
|
}
|
928
908
|
}
|
929
|
-
${
|
909
|
+
${CoinFragmentFragmentDoc}`;
|
930
910
|
var GetCoinsToSpendDocument = import_graphql_tag.default`
|
931
911
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
932
912
|
coinsToSpend(
|
@@ -938,8 +918,8 @@ var GetCoinsToSpendDocument = import_graphql_tag.default`
|
|
938
918
|
...messageCoinFragment
|
939
919
|
}
|
940
920
|
}
|
941
|
-
${
|
942
|
-
${
|
921
|
+
${CoinFragmentFragmentDoc}
|
922
|
+
${MessageCoinFragmentFragmentDoc}`;
|
943
923
|
var GetContractDocument = import_graphql_tag.default`
|
944
924
|
query getContract($contractId: ContractId!) {
|
945
925
|
contract(id: $contractId) {
|
@@ -954,14 +934,14 @@ var GetContractBalanceDocument = import_graphql_tag.default`
|
|
954
934
|
...contractBalanceFragment
|
955
935
|
}
|
956
936
|
}
|
957
|
-
${
|
937
|
+
${ContractBalanceFragmentFragmentDoc}`;
|
958
938
|
var GetBalanceDocument = import_graphql_tag.default`
|
959
939
|
query getBalance($owner: Address!, $assetId: AssetId!) {
|
960
940
|
balance(owner: $owner, assetId: $assetId) {
|
961
941
|
...balanceFragment
|
962
942
|
}
|
963
943
|
}
|
964
|
-
${
|
944
|
+
${BalanceFragmentFragmentDoc}`;
|
965
945
|
var GetLatestGasPriceDocument = import_graphql_tag.default`
|
966
946
|
query getLatestGasPrice {
|
967
947
|
latestGasPrice {
|
@@ -992,7 +972,7 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
992
972
|
}
|
993
973
|
}
|
994
974
|
}
|
995
|
-
${
|
975
|
+
${BalanceFragmentFragmentDoc}`;
|
996
976
|
var GetMessagesDocument = import_graphql_tag.default`
|
997
977
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
998
978
|
messages(
|
@@ -1009,7 +989,7 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
1009
989
|
}
|
1010
990
|
}
|
1011
991
|
}
|
1012
|
-
${
|
992
|
+
${MessageFragmentFragmentDoc}`;
|
1013
993
|
var GetMessageProofDocument = import_graphql_tag.default`
|
1014
994
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
1015
995
|
messageProof(
|
@@ -1021,7 +1001,7 @@ var GetMessageProofDocument = import_graphql_tag.default`
|
|
1021
1001
|
...messageProofFragment
|
1022
1002
|
}
|
1023
1003
|
}
|
1024
|
-
${
|
1004
|
+
${MessageProofFragmentFragmentDoc}`;
|
1025
1005
|
var GetMessageStatusDocument = import_graphql_tag.default`
|
1026
1006
|
query getMessageStatus($nonce: Nonce!) {
|
1027
1007
|
messageStatus(nonce: $nonce) {
|
@@ -1035,14 +1015,14 @@ var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
|
|
1035
1015
|
...relayedTransactionStatusFragment
|
1036
1016
|
}
|
1037
1017
|
}
|
1038
|
-
${
|
1018
|
+
${RelayedTransactionStatusFragmentFragmentDoc}`;
|
1039
1019
|
var DryRunDocument = import_graphql_tag.default`
|
1040
1020
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
1041
1021
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
1042
1022
|
...dryRunTransactionExecutionStatusFragment
|
1043
1023
|
}
|
1044
1024
|
}
|
1045
|
-
${
|
1025
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
1046
1026
|
var SubmitDocument = import_graphql_tag.default`
|
1047
1027
|
mutation submit($encodedTransaction: HexString!) {
|
1048
1028
|
submit(tx: $encodedTransaction) {
|
@@ -1064,21 +1044,21 @@ var GetMessageByNonceDocument = import_graphql_tag.default`
|
|
1064
1044
|
...messageFragment
|
1065
1045
|
}
|
1066
1046
|
}
|
1067
|
-
${
|
1047
|
+
${MessageFragmentFragmentDoc}`;
|
1068
1048
|
var SubmitAndAwaitDocument = import_graphql_tag.default`
|
1069
1049
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
1070
1050
|
submitAndAwait(tx: $encodedTransaction) {
|
1071
1051
|
...transactionStatusSubscriptionFragment
|
1072
1052
|
}
|
1073
1053
|
}
|
1074
|
-
${
|
1054
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
1075
1055
|
var StatusChangeDocument = import_graphql_tag.default`
|
1076
1056
|
subscription statusChange($transactionId: TransactionId!) {
|
1077
1057
|
statusChange(id: $transactionId) {
|
1078
1058
|
...transactionStatusSubscriptionFragment
|
1079
1059
|
}
|
1080
1060
|
}
|
1081
|
-
${
|
1061
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
1082
1062
|
function getSdk(requester) {
|
1083
1063
|
return {
|
1084
1064
|
getVersion(variables, options) {
|
@@ -1449,8 +1429,8 @@ var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
|
1449
1429
|
var import_address = require("@fuel-ts/address");
|
1450
1430
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1451
1431
|
var import_crypto = require("@fuel-ts/crypto");
|
1452
|
-
var
|
1453
|
-
var
|
1432
|
+
var import_math8 = require("@fuel-ts/math");
|
1433
|
+
var import_transactions7 = require("@fuel-ts/transactions");
|
1454
1434
|
var import_utils9 = require("@fuel-ts/utils");
|
1455
1435
|
|
1456
1436
|
// src/providers/resource.ts
|
@@ -1741,9 +1721,10 @@ var getGasUsedFromReceipts = (receipts) => {
|
|
1741
1721
|
function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
1742
1722
|
const base = (0, import_math5.bn)(gasDependentCost.base);
|
1743
1723
|
let dependentValue = (0, import_math5.bn)(0);
|
1744
|
-
if ("
|
1724
|
+
if (gasDependentCost.__typename === "LightOperation") {
|
1745
1725
|
dependentValue = (0, import_math5.bn)(byteSize).div((0, import_math5.bn)(gasDependentCost.unitsPerGas));
|
1746
|
-
}
|
1726
|
+
}
|
1727
|
+
if (gasDependentCost.__typename === "HeavyOperation") {
|
1747
1728
|
dependentValue = (0, import_math5.bn)(byteSize).mul((0, import_math5.bn)(gasDependentCost.gasPerUnit));
|
1748
1729
|
}
|
1749
1730
|
return base.add(dependentValue);
|
@@ -1957,6 +1938,52 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1957
1938
|
name = "NoWitnessByOwnerError";
|
1958
1939
|
};
|
1959
1940
|
|
1941
|
+
// src/providers/transaction-request/helpers.ts
|
1942
|
+
var import_math7 = require("@fuel-ts/math");
|
1943
|
+
var import_transactions6 = require("@fuel-ts/transactions");
|
1944
|
+
var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
|
1945
|
+
var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
|
1946
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1947
|
+
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
1948
|
+
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
1949
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1950
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1951
|
+
return acc.add(input.amount);
|
1952
|
+
}
|
1953
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1954
|
+
return acc.add(input.amount);
|
1955
|
+
}
|
1956
|
+
return acc;
|
1957
|
+
}, (0, import_math7.bn)(0));
|
1958
|
+
var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
|
1959
|
+
(cache2, input) => {
|
1960
|
+
if (isRequestInputCoin(input)) {
|
1961
|
+
cache2.utxos.push(input.id);
|
1962
|
+
} else {
|
1963
|
+
cache2.messages.push(input.nonce);
|
1964
|
+
}
|
1965
|
+
return cache2;
|
1966
|
+
},
|
1967
|
+
{
|
1968
|
+
utxos: [],
|
1969
|
+
messages: []
|
1970
|
+
}
|
1971
|
+
);
|
1972
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
1973
|
+
(acc, input) => {
|
1974
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
1975
|
+
acc.utxos.push(input.id);
|
1976
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
1977
|
+
acc.messages.push(input.nonce);
|
1978
|
+
}
|
1979
|
+
return acc;
|
1980
|
+
},
|
1981
|
+
{
|
1982
|
+
utxos: [],
|
1983
|
+
messages: []
|
1984
|
+
}
|
1985
|
+
);
|
1986
|
+
|
1960
1987
|
// src/providers/transaction-request/witness.ts
|
1961
1988
|
var import_utils8 = require("@fuel-ts/utils");
|
1962
1989
|
var witnessify = (value) => {
|
@@ -1997,10 +2024,10 @@ var BaseTransactionRequest = class {
|
|
1997
2024
|
outputs,
|
1998
2025
|
witnesses
|
1999
2026
|
} = {}) {
|
2000
|
-
this.tip = tip ? (0,
|
2027
|
+
this.tip = tip ? (0, import_math8.bn)(tip) : void 0;
|
2001
2028
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
2002
|
-
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0,
|
2003
|
-
this.maxFee = (0,
|
2029
|
+
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math8.bn)(witnessLimit) : void 0;
|
2030
|
+
this.maxFee = (0, import_math8.bn)(maxFee);
|
2004
2031
|
this.inputs = inputs ?? [];
|
2005
2032
|
this.outputs = outputs ?? [];
|
2006
2033
|
this.witnesses = witnesses ?? [];
|
@@ -2009,20 +2036,20 @@ var BaseTransactionRequest = class {
|
|
2009
2036
|
let policyTypes = 0;
|
2010
2037
|
const policies = [];
|
2011
2038
|
const { tip, witnessLimit, maturity } = req;
|
2012
|
-
if ((0,
|
2013
|
-
policyTypes +=
|
2014
|
-
policies.push({ data: (0,
|
2039
|
+
if ((0, import_math8.bn)(tip).gt(0)) {
|
2040
|
+
policyTypes += import_transactions7.PolicyType.Tip;
|
2041
|
+
policies.push({ data: (0, import_math8.bn)(tip), type: import_transactions7.PolicyType.Tip });
|
2015
2042
|
}
|
2016
|
-
if ((0, import_utils9.isDefined)(witnessLimit) && (0,
|
2017
|
-
policyTypes +=
|
2018
|
-
policies.push({ data: (0,
|
2043
|
+
if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math8.bn)(witnessLimit).gte(0)) {
|
2044
|
+
policyTypes += import_transactions7.PolicyType.WitnessLimit;
|
2045
|
+
policies.push({ data: (0, import_math8.bn)(witnessLimit), type: import_transactions7.PolicyType.WitnessLimit });
|
2019
2046
|
}
|
2020
2047
|
if (maturity && maturity > 0) {
|
2021
|
-
policyTypes +=
|
2022
|
-
policies.push({ data: maturity, type:
|
2048
|
+
policyTypes += import_transactions7.PolicyType.Maturity;
|
2049
|
+
policies.push({ data: maturity, type: import_transactions7.PolicyType.Maturity });
|
2023
2050
|
}
|
2024
|
-
policyTypes +=
|
2025
|
-
policies.push({ data: req.maxFee, type:
|
2051
|
+
policyTypes += import_transactions7.PolicyType.MaxFee;
|
2052
|
+
policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
|
2026
2053
|
return {
|
2027
2054
|
policyTypes,
|
2028
2055
|
policies
|
@@ -2055,7 +2082,7 @@ var BaseTransactionRequest = class {
|
|
2055
2082
|
* @returns The transaction bytes.
|
2056
2083
|
*/
|
2057
2084
|
toTransactionBytes() {
|
2058
|
-
return new
|
2085
|
+
return new import_transactions7.TransactionCoder().encode(this.toTransaction());
|
2059
2086
|
}
|
2060
2087
|
/**
|
2061
2088
|
* @hidden
|
@@ -2146,7 +2173,7 @@ var BaseTransactionRequest = class {
|
|
2146
2173
|
*/
|
2147
2174
|
getCoinInputs() {
|
2148
2175
|
return this.inputs.filter(
|
2149
|
-
(input) => input.type ===
|
2176
|
+
(input) => input.type === import_transactions7.InputType.Coin
|
2150
2177
|
);
|
2151
2178
|
}
|
2152
2179
|
/**
|
@@ -2156,7 +2183,7 @@ var BaseTransactionRequest = class {
|
|
2156
2183
|
*/
|
2157
2184
|
getCoinOutputs() {
|
2158
2185
|
return this.outputs.filter(
|
2159
|
-
(output) => output.type ===
|
2186
|
+
(output) => output.type === import_transactions7.OutputType.Coin
|
2160
2187
|
);
|
2161
2188
|
}
|
2162
2189
|
/**
|
@@ -2166,7 +2193,7 @@ var BaseTransactionRequest = class {
|
|
2166
2193
|
*/
|
2167
2194
|
getChangeOutputs() {
|
2168
2195
|
return this.outputs.filter(
|
2169
|
-
(output) => output.type ===
|
2196
|
+
(output) => output.type === import_transactions7.OutputType.Change
|
2170
2197
|
);
|
2171
2198
|
}
|
2172
2199
|
/**
|
@@ -2178,9 +2205,9 @@ var BaseTransactionRequest = class {
|
|
2178
2205
|
const ownerAddress = (0, import_address.addressify)(owner);
|
2179
2206
|
const found = this.inputs.find((input) => {
|
2180
2207
|
switch (input.type) {
|
2181
|
-
case
|
2208
|
+
case import_transactions7.InputType.Coin:
|
2182
2209
|
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
2183
|
-
case
|
2210
|
+
case import_transactions7.InputType.Message:
|
2184
2211
|
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
2185
2212
|
default:
|
2186
2213
|
return false;
|
@@ -2195,7 +2222,7 @@ var BaseTransactionRequest = class {
|
|
2195
2222
|
* @param coin - Coin resource.
|
2196
2223
|
*/
|
2197
2224
|
addCoinInput(coin) {
|
2198
|
-
const { assetId, owner, amount } = coin;
|
2225
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
2199
2226
|
let witnessIndex;
|
2200
2227
|
if (coin.predicate) {
|
2201
2228
|
witnessIndex = 0;
|
@@ -2206,13 +2233,14 @@ var BaseTransactionRequest = class {
|
|
2206
2233
|
}
|
2207
2234
|
}
|
2208
2235
|
const input = {
|
2209
|
-
|
2210
|
-
type:
|
2236
|
+
id,
|
2237
|
+
type: import_transactions7.InputType.Coin,
|
2211
2238
|
owner: owner.toB256(),
|
2212
2239
|
amount,
|
2213
2240
|
assetId,
|
2214
2241
|
txPointer: "0x00000000000000000000000000000000",
|
2215
|
-
witnessIndex
|
2242
|
+
witnessIndex,
|
2243
|
+
predicate
|
2216
2244
|
};
|
2217
2245
|
this.pushInput(input);
|
2218
2246
|
this.addChangeOutput(owner, assetId);
|
@@ -2224,7 +2252,7 @@ var BaseTransactionRequest = class {
|
|
2224
2252
|
* @param message - Message resource.
|
2225
2253
|
*/
|
2226
2254
|
addMessageInput(message) {
|
2227
|
-
const { recipient, sender, amount, assetId } = message;
|
2255
|
+
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
2228
2256
|
let witnessIndex;
|
2229
2257
|
if (message.predicate) {
|
2230
2258
|
witnessIndex = 0;
|
@@ -2235,12 +2263,13 @@ var BaseTransactionRequest = class {
|
|
2235
2263
|
}
|
2236
2264
|
}
|
2237
2265
|
const input = {
|
2238
|
-
|
2239
|
-
type:
|
2266
|
+
nonce,
|
2267
|
+
type: import_transactions7.InputType.Message,
|
2240
2268
|
sender: sender.toB256(),
|
2241
2269
|
recipient: recipient.toB256(),
|
2242
2270
|
amount,
|
2243
|
-
witnessIndex
|
2271
|
+
witnessIndex,
|
2272
|
+
predicate
|
2244
2273
|
};
|
2245
2274
|
this.pushInput(input);
|
2246
2275
|
this.addChangeOutput(recipient, assetId);
|
@@ -2280,7 +2309,7 @@ var BaseTransactionRequest = class {
|
|
2280
2309
|
*/
|
2281
2310
|
addCoinOutput(to, amount, assetId) {
|
2282
2311
|
this.pushOutput({
|
2283
|
-
type:
|
2312
|
+
type: import_transactions7.OutputType.Coin,
|
2284
2313
|
to: (0, import_address.addressify)(to).toB256(),
|
2285
2314
|
amount,
|
2286
2315
|
assetId
|
@@ -2296,7 +2325,7 @@ var BaseTransactionRequest = class {
|
|
2296
2325
|
addCoinOutputs(to, quantities) {
|
2297
2326
|
quantities.map(coinQuantityfy).forEach((quantity) => {
|
2298
2327
|
this.pushOutput({
|
2299
|
-
type:
|
2328
|
+
type: import_transactions7.OutputType.Coin,
|
2300
2329
|
to: (0, import_address.addressify)(to).toB256(),
|
2301
2330
|
amount: quantity.amount,
|
2302
2331
|
assetId: quantity.assetId
|
@@ -2316,7 +2345,7 @@ var BaseTransactionRequest = class {
|
|
2316
2345
|
);
|
2317
2346
|
if (!changeOutput) {
|
2318
2347
|
this.pushOutput({
|
2319
|
-
type:
|
2348
|
+
type: import_transactions7.OutputType.Change,
|
2320
2349
|
to: (0, import_address.addressify)(to).toB256(),
|
2321
2350
|
assetId
|
2322
2351
|
});
|
@@ -2387,7 +2416,7 @@ var BaseTransactionRequest = class {
|
|
2387
2416
|
const assetInput = findAssetInput(assetId);
|
2388
2417
|
let usedQuantity = quantity;
|
2389
2418
|
if (assetId === baseAssetId) {
|
2390
|
-
usedQuantity = (0,
|
2419
|
+
usedQuantity = (0, import_math8.bn)("1000000000000000000");
|
2391
2420
|
}
|
2392
2421
|
if (assetInput && "assetId" in assetInput) {
|
2393
2422
|
assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
|
@@ -2399,13 +2428,13 @@ var BaseTransactionRequest = class {
|
|
2399
2428
|
amount: usedQuantity,
|
2400
2429
|
assetId,
|
2401
2430
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2402
|
-
blockCreated: (0,
|
2403
|
-
txCreatedIdx: (0,
|
2431
|
+
blockCreated: (0, import_math8.bn)(1),
|
2432
|
+
txCreatedIdx: (0, import_math8.bn)(1)
|
2404
2433
|
}
|
2405
2434
|
]);
|
2406
2435
|
}
|
2407
2436
|
};
|
2408
|
-
updateAssetInput(baseAssetId, (0,
|
2437
|
+
updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
|
2409
2438
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2410
2439
|
}
|
2411
2440
|
/**
|
@@ -2416,7 +2445,7 @@ var BaseTransactionRequest = class {
|
|
2416
2445
|
*/
|
2417
2446
|
getCoinOutputsQuantities() {
|
2418
2447
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2419
|
-
amount: (0,
|
2448
|
+
amount: (0, import_math8.bn)(amount),
|
2420
2449
|
assetId: assetId.toString()
|
2421
2450
|
}));
|
2422
2451
|
return coinsQuantities;
|
@@ -2430,22 +2459,33 @@ var BaseTransactionRequest = class {
|
|
2430
2459
|
toJSON() {
|
2431
2460
|
return normalizeJSON(this);
|
2432
2461
|
}
|
2462
|
+
removeWitness(index) {
|
2463
|
+
this.witnesses.splice(index, 1);
|
2464
|
+
this.adjustWitnessIndexes(index);
|
2465
|
+
}
|
2466
|
+
adjustWitnessIndexes(removedIndex) {
|
2467
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2468
|
+
if (input.witnessIndex > removedIndex) {
|
2469
|
+
input.witnessIndex -= 1;
|
2470
|
+
}
|
2471
|
+
});
|
2472
|
+
}
|
2433
2473
|
updatePredicateGasUsed(inputs) {
|
2434
2474
|
this.inputs.forEach((i) => {
|
2435
2475
|
let correspondingInput;
|
2436
2476
|
switch (i.type) {
|
2437
|
-
case
|
2438
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2477
|
+
case import_transactions7.InputType.Coin:
|
2478
|
+
correspondingInput = inputs.find((x) => x.type === import_transactions7.InputType.Coin && x.owner === i.owner);
|
2439
2479
|
break;
|
2440
|
-
case
|
2480
|
+
case import_transactions7.InputType.Message:
|
2441
2481
|
correspondingInput = inputs.find(
|
2442
|
-
(x) => x.type ===
|
2482
|
+
(x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
|
2443
2483
|
);
|
2444
2484
|
break;
|
2445
2485
|
default:
|
2446
2486
|
return;
|
2447
2487
|
}
|
2448
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0,
|
2488
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math8.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2449
2489
|
i.predicate = correspondingInput.predicate;
|
2450
2490
|
i.predicateData = correspondingInput.predicateData;
|
2451
2491
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2465,38 +2505,38 @@ var BaseTransactionRequest = class {
|
|
2465
2505
|
|
2466
2506
|
// src/providers/transaction-request/create-transaction-request.ts
|
2467
2507
|
var import_configs8 = require("@fuel-ts/address/configs");
|
2468
|
-
var
|
2469
|
-
var
|
2508
|
+
var import_math10 = require("@fuel-ts/math");
|
2509
|
+
var import_transactions9 = require("@fuel-ts/transactions");
|
2470
2510
|
var import_utils13 = require("@fuel-ts/utils");
|
2471
2511
|
|
2472
2512
|
// src/providers/transaction-request/hash-transaction.ts
|
2473
2513
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2474
2514
|
var import_hasher = require("@fuel-ts/hasher");
|
2475
|
-
var
|
2476
|
-
var
|
2515
|
+
var import_math9 = require("@fuel-ts/math");
|
2516
|
+
var import_transactions8 = require("@fuel-ts/transactions");
|
2477
2517
|
var import_utils11 = require("@fuel-ts/utils");
|
2478
2518
|
var import_ramda2 = require("ramda");
|
2479
2519
|
function hashTransaction(transactionRequest, chainId) {
|
2480
2520
|
const transaction = transactionRequest.toTransaction();
|
2481
|
-
if (transaction.type ===
|
2521
|
+
if (transaction.type === import_transactions8.TransactionType.Script) {
|
2482
2522
|
transaction.receiptsRoot = import_configs7.ZeroBytes32;
|
2483
2523
|
}
|
2484
2524
|
transaction.inputs = transaction.inputs.map((input) => {
|
2485
2525
|
const inputClone = (0, import_ramda2.clone)(input);
|
2486
2526
|
switch (inputClone.type) {
|
2487
|
-
case
|
2527
|
+
case import_transactions8.InputType.Coin: {
|
2488
2528
|
inputClone.txPointer = {
|
2489
2529
|
blockHeight: 0,
|
2490
2530
|
txIndex: 0
|
2491
2531
|
};
|
2492
|
-
inputClone.predicateGasUsed = (0,
|
2532
|
+
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
2493
2533
|
return inputClone;
|
2494
2534
|
}
|
2495
|
-
case
|
2496
|
-
inputClone.predicateGasUsed = (0,
|
2535
|
+
case import_transactions8.InputType.Message: {
|
2536
|
+
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
2497
2537
|
return inputClone;
|
2498
2538
|
}
|
2499
|
-
case
|
2539
|
+
case import_transactions8.InputType.Contract: {
|
2500
2540
|
inputClone.txPointer = {
|
2501
2541
|
blockHeight: 0,
|
2502
2542
|
txIndex: 0
|
@@ -2514,18 +2554,18 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2514
2554
|
transaction.outputs = transaction.outputs.map((output) => {
|
2515
2555
|
const outputClone = (0, import_ramda2.clone)(output);
|
2516
2556
|
switch (outputClone.type) {
|
2517
|
-
case
|
2557
|
+
case import_transactions8.OutputType.Contract: {
|
2518
2558
|
outputClone.balanceRoot = import_configs7.ZeroBytes32;
|
2519
2559
|
outputClone.stateRoot = import_configs7.ZeroBytes32;
|
2520
2560
|
return outputClone;
|
2521
2561
|
}
|
2522
|
-
case
|
2523
|
-
outputClone.amount = (0,
|
2562
|
+
case import_transactions8.OutputType.Change: {
|
2563
|
+
outputClone.amount = (0, import_math9.bn)(0);
|
2524
2564
|
return outputClone;
|
2525
2565
|
}
|
2526
|
-
case
|
2566
|
+
case import_transactions8.OutputType.Variable: {
|
2527
2567
|
outputClone.to = import_configs7.ZeroBytes32;
|
2528
|
-
outputClone.amount = (0,
|
2568
|
+
outputClone.amount = (0, import_math9.bn)(0);
|
2529
2569
|
outputClone.assetId = import_configs7.ZeroBytes32;
|
2530
2570
|
return outputClone;
|
2531
2571
|
}
|
@@ -2536,7 +2576,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2536
2576
|
transaction.witnessesCount = 0;
|
2537
2577
|
transaction.witnesses = [];
|
2538
2578
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2539
|
-
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new
|
2579
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
|
2540
2580
|
return (0, import_hasher.sha256)(concatenatedData);
|
2541
2581
|
}
|
2542
2582
|
|
@@ -2572,7 +2612,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2572
2612
|
return new this(obj);
|
2573
2613
|
}
|
2574
2614
|
/** Type of the transaction */
|
2575
|
-
type =
|
2615
|
+
type = import_transactions9.TransactionType.Create;
|
2576
2616
|
/** Witness index of contract bytecode to create */
|
2577
2617
|
bytecodeWitnessIndex;
|
2578
2618
|
/** Salt */
|
@@ -2600,10 +2640,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2600
2640
|
const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
|
2601
2641
|
const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
|
2602
2642
|
return {
|
2603
|
-
type:
|
2643
|
+
type: import_transactions9.TransactionType.Create,
|
2604
2644
|
...baseTransaction,
|
2605
2645
|
bytecodeWitnessIndex,
|
2606
|
-
storageSlotsCount: (0,
|
2646
|
+
storageSlotsCount: (0, import_math10.bn)(storageSlots.length),
|
2607
2647
|
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2608
2648
|
storageSlots
|
2609
2649
|
};
|
@@ -2615,7 +2655,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2615
2655
|
*/
|
2616
2656
|
getContractCreatedOutputs() {
|
2617
2657
|
return this.outputs.filter(
|
2618
|
-
(output) => output.type ===
|
2658
|
+
(output) => output.type === import_transactions9.OutputType.ContractCreated
|
2619
2659
|
);
|
2620
2660
|
}
|
2621
2661
|
/**
|
@@ -2636,14 +2676,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2636
2676
|
*/
|
2637
2677
|
addContractCreatedOutput(contractId, stateRoot) {
|
2638
2678
|
this.pushOutput({
|
2639
|
-
type:
|
2679
|
+
type: import_transactions9.OutputType.ContractCreated,
|
2640
2680
|
contractId,
|
2641
2681
|
stateRoot
|
2642
2682
|
});
|
2643
2683
|
}
|
2644
2684
|
metadataGas(gasCosts) {
|
2645
2685
|
return calculateMetadataGasForTxCreate({
|
2646
|
-
contractBytesSize: (0,
|
2686
|
+
contractBytesSize: (0, import_math10.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2647
2687
|
gasCosts,
|
2648
2688
|
stateRootSize: this.storageSlots.length,
|
2649
2689
|
txBytesSize: this.byteSize()
|
@@ -2655,8 +2695,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2655
2695
|
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
2656
2696
|
var import_address2 = require("@fuel-ts/address");
|
2657
2697
|
var import_configs9 = require("@fuel-ts/address/configs");
|
2658
|
-
var
|
2659
|
-
var
|
2698
|
+
var import_math11 = require("@fuel-ts/math");
|
2699
|
+
var import_transactions10 = require("@fuel-ts/transactions");
|
2660
2700
|
var import_utils15 = require("@fuel-ts/utils");
|
2661
2701
|
|
2662
2702
|
// src/providers/transaction-request/scripts.ts
|
@@ -2694,7 +2734,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2694
2734
|
return new this(obj);
|
2695
2735
|
}
|
2696
2736
|
/** Type of the transaction */
|
2697
|
-
type =
|
2737
|
+
type = import_transactions10.TransactionType.Script;
|
2698
2738
|
/** Gas limit for transaction */
|
2699
2739
|
gasLimit;
|
2700
2740
|
/** Script to execute */
|
@@ -2709,7 +2749,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2709
2749
|
*/
|
2710
2750
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2711
2751
|
super(rest);
|
2712
|
-
this.gasLimit = (0,
|
2752
|
+
this.gasLimit = (0, import_math11.bn)(gasLimit);
|
2713
2753
|
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2714
2754
|
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2715
2755
|
this.abis = rest.abis;
|
@@ -2723,11 +2763,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2723
2763
|
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2724
2764
|
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2725
2765
|
return {
|
2726
|
-
type:
|
2766
|
+
type: import_transactions10.TransactionType.Script,
|
2727
2767
|
scriptGasLimit: this.gasLimit,
|
2728
2768
|
...super.getBaseTransaction(),
|
2729
|
-
scriptLength: (0,
|
2730
|
-
scriptDataLength: (0,
|
2769
|
+
scriptLength: (0, import_math11.bn)(script.length),
|
2770
|
+
scriptDataLength: (0, import_math11.bn)(scriptData.length),
|
2731
2771
|
receiptsRoot: import_configs9.ZeroBytes32,
|
2732
2772
|
script: (0, import_utils15.hexlify)(script),
|
2733
2773
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
@@ -2740,7 +2780,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2740
2780
|
*/
|
2741
2781
|
getContractInputs() {
|
2742
2782
|
return this.inputs.filter(
|
2743
|
-
(input) => input.type ===
|
2783
|
+
(input) => input.type === import_transactions10.InputType.Contract
|
2744
2784
|
);
|
2745
2785
|
}
|
2746
2786
|
/**
|
@@ -2750,7 +2790,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2750
2790
|
*/
|
2751
2791
|
getContractOutputs() {
|
2752
2792
|
return this.outputs.filter(
|
2753
|
-
(output) => output.type ===
|
2793
|
+
(output) => output.type === import_transactions10.OutputType.Contract
|
2754
2794
|
);
|
2755
2795
|
}
|
2756
2796
|
/**
|
@@ -2760,7 +2800,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2760
2800
|
*/
|
2761
2801
|
getVariableOutputs() {
|
2762
2802
|
return this.outputs.filter(
|
2763
|
-
(output) => output.type ===
|
2803
|
+
(output) => output.type === import_transactions10.OutputType.Variable
|
2764
2804
|
);
|
2765
2805
|
}
|
2766
2806
|
/**
|
@@ -2783,7 +2823,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2783
2823
|
let outputsNumber = numberOfVariables;
|
2784
2824
|
while (outputsNumber) {
|
2785
2825
|
this.pushOutput({
|
2786
|
-
type:
|
2826
|
+
type: import_transactions10.OutputType.Variable
|
2787
2827
|
});
|
2788
2828
|
outputsNumber -= 1;
|
2789
2829
|
}
|
@@ -2820,12 +2860,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2820
2860
|
return this;
|
2821
2861
|
}
|
2822
2862
|
const inputIndex = super.pushInput({
|
2823
|
-
type:
|
2863
|
+
type: import_transactions10.InputType.Contract,
|
2824
2864
|
contractId: contractAddress.toB256(),
|
2825
2865
|
txPointer: "0x00000000000000000000000000000000"
|
2826
2866
|
});
|
2827
2867
|
this.pushOutput({
|
2828
|
-
type:
|
2868
|
+
type: import_transactions10.OutputType.Contract,
|
2829
2869
|
inputIndex
|
2830
2870
|
});
|
2831
2871
|
return this;
|
@@ -2862,17 +2902,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2862
2902
|
|
2863
2903
|
// src/providers/transaction-request/utils.ts
|
2864
2904
|
var import_errors9 = require("@fuel-ts/errors");
|
2865
|
-
var
|
2905
|
+
var import_transactions11 = require("@fuel-ts/transactions");
|
2866
2906
|
var transactionRequestify = (obj) => {
|
2867
2907
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2868
2908
|
return obj;
|
2869
2909
|
}
|
2870
2910
|
const { type } = obj;
|
2871
2911
|
switch (obj.type) {
|
2872
|
-
case
|
2912
|
+
case import_transactions11.TransactionType.Script: {
|
2873
2913
|
return ScriptTransactionRequest.from(obj);
|
2874
2914
|
}
|
2875
|
-
case
|
2915
|
+
case import_transactions11.TransactionType.Create: {
|
2876
2916
|
return CreateTransactionRequest.from(obj);
|
2877
2917
|
}
|
2878
2918
|
default: {
|
@@ -2880,36 +2920,21 @@ var transactionRequestify = (obj) => {
|
|
2880
2920
|
}
|
2881
2921
|
}
|
2882
2922
|
};
|
2883
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2884
|
-
(acc, input) => {
|
2885
|
-
if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
|
2886
|
-
acc.utxos.push(input.id);
|
2887
|
-
}
|
2888
|
-
if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
|
2889
|
-
acc.messages.push(input.nonce);
|
2890
|
-
}
|
2891
|
-
return acc;
|
2892
|
-
},
|
2893
|
-
{
|
2894
|
-
utxos: [],
|
2895
|
-
messages: []
|
2896
|
-
}
|
2897
|
-
);
|
2898
2923
|
|
2899
2924
|
// src/providers/transaction-response/transaction-response.ts
|
2900
2925
|
var import_errors13 = require("@fuel-ts/errors");
|
2901
|
-
var
|
2902
|
-
var
|
2926
|
+
var import_math17 = require("@fuel-ts/math");
|
2927
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
2903
2928
|
var import_utils20 = require("@fuel-ts/utils");
|
2904
2929
|
|
2905
2930
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2906
|
-
var
|
2907
|
-
var
|
2931
|
+
var import_math16 = require("@fuel-ts/math");
|
2932
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
2908
2933
|
var import_utils18 = require("@fuel-ts/utils");
|
2909
2934
|
|
2910
2935
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2911
|
-
var
|
2912
|
-
var
|
2936
|
+
var import_math12 = require("@fuel-ts/math");
|
2937
|
+
var import_transactions12 = require("@fuel-ts/transactions");
|
2913
2938
|
var import_utils16 = require("@fuel-ts/utils");
|
2914
2939
|
var calculateTXFeeForSummary = (params) => {
|
2915
2940
|
const {
|
@@ -2922,19 +2947,19 @@ var calculateTXFeeForSummary = (params) => {
|
|
2922
2947
|
if (totalFee) {
|
2923
2948
|
return totalFee;
|
2924
2949
|
}
|
2925
|
-
const gasPerByte = (0,
|
2926
|
-
const gasPriceFactor = (0,
|
2950
|
+
const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
|
2951
|
+
const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
|
2927
2952
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2928
|
-
const [transaction] = new
|
2953
|
+
const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
|
2929
2954
|
const { type, witnesses, inputs, policies } = transaction;
|
2930
|
-
let metadataGas = (0,
|
2931
|
-
let gasLimit = (0,
|
2932
|
-
if (type !==
|
2933
|
-
return (0,
|
2955
|
+
let metadataGas = (0, import_math12.bn)(0);
|
2956
|
+
let gasLimit = (0, import_math12.bn)(0);
|
2957
|
+
if (type !== import_transactions12.TransactionType.Create && type !== import_transactions12.TransactionType.Script) {
|
2958
|
+
return (0, import_math12.bn)(0);
|
2934
2959
|
}
|
2935
|
-
if (type ===
|
2960
|
+
if (type === import_transactions12.TransactionType.Create) {
|
2936
2961
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2937
|
-
const contractBytesSize = (0,
|
2962
|
+
const contractBytesSize = (0, import_math12.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2938
2963
|
metadataGas = calculateMetadataGasForTxCreate({
|
2939
2964
|
contractBytesSize,
|
2940
2965
|
gasCosts,
|
@@ -2953,12 +2978,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
2953
2978
|
}
|
2954
2979
|
const minGas = getMinGas({
|
2955
2980
|
gasCosts,
|
2956
|
-
gasPerByte: (0,
|
2981
|
+
gasPerByte: (0, import_math12.bn)(gasPerByte),
|
2957
2982
|
inputs,
|
2958
2983
|
metadataGas,
|
2959
2984
|
txBytesSize: transactionBytes.length
|
2960
2985
|
});
|
2961
|
-
const witnessLimit = policies.find((policy) => policy.type ===
|
2986
|
+
const witnessLimit = policies.find((policy) => policy.type === import_transactions12.PolicyType.WitnessLimit)?.data;
|
2962
2987
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2963
2988
|
const maxGas = getMaxGas({
|
2964
2989
|
gasPerByte,
|
@@ -2980,12 +3005,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
2980
3005
|
// src/providers/transaction-summary/operations.ts
|
2981
3006
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2982
3007
|
var import_errors11 = require("@fuel-ts/errors");
|
2983
|
-
var
|
2984
|
-
var
|
3008
|
+
var import_math14 = require("@fuel-ts/math");
|
3009
|
+
var import_transactions15 = require("@fuel-ts/transactions");
|
2985
3010
|
|
2986
3011
|
// src/providers/transaction-summary/call.ts
|
2987
3012
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
2988
|
-
var
|
3013
|
+
var import_math13 = require("@fuel-ts/math");
|
2989
3014
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2990
3015
|
const abiInterface = new import_abi_coder4.Interface(abi);
|
2991
3016
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2994,7 +3019,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2994
3019
|
let encodedArgs;
|
2995
3020
|
if (functionFragment.isInputDataPointer) {
|
2996
3021
|
if (rawPayload) {
|
2997
|
-
const argsOffset = (0,
|
3022
|
+
const argsOffset = (0, import_math13.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2998
3023
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2999
3024
|
}
|
3000
3025
|
} else {
|
@@ -3029,7 +3054,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
3029
3054
|
|
3030
3055
|
// src/providers/transaction-summary/input.ts
|
3031
3056
|
var import_errors10 = require("@fuel-ts/errors");
|
3032
|
-
var
|
3057
|
+
var import_transactions13 = require("@fuel-ts/transactions");
|
3033
3058
|
function getInputsByTypes(inputs, types) {
|
3034
3059
|
return inputs.filter((i) => types.includes(i.type));
|
3035
3060
|
}
|
@@ -3037,16 +3062,16 @@ function getInputsByType(inputs, type) {
|
|
3037
3062
|
return inputs.filter((i) => i.type === type);
|
3038
3063
|
}
|
3039
3064
|
function getInputsCoin(inputs) {
|
3040
|
-
return getInputsByType(inputs,
|
3065
|
+
return getInputsByType(inputs, import_transactions13.InputType.Coin);
|
3041
3066
|
}
|
3042
3067
|
function getInputsMessage(inputs) {
|
3043
|
-
return getInputsByType(inputs,
|
3068
|
+
return getInputsByType(inputs, import_transactions13.InputType.Message);
|
3044
3069
|
}
|
3045
3070
|
function getInputsCoinAndMessage(inputs) {
|
3046
|
-
return getInputsByTypes(inputs, [
|
3071
|
+
return getInputsByTypes(inputs, [import_transactions13.InputType.Coin, import_transactions13.InputType.Message]);
|
3047
3072
|
}
|
3048
3073
|
function getInputsContract(inputs) {
|
3049
|
-
return getInputsByType(inputs,
|
3074
|
+
return getInputsByType(inputs, import_transactions13.InputType.Contract);
|
3050
3075
|
}
|
3051
3076
|
function getInputFromAssetId(inputs, assetId) {
|
3052
3077
|
const coinInputs = getInputsCoin(inputs);
|
@@ -3065,7 +3090,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3065
3090
|
if (!contractInput) {
|
3066
3091
|
return void 0;
|
3067
3092
|
}
|
3068
|
-
if (contractInput.type !==
|
3093
|
+
if (contractInput.type !== import_transactions13.InputType.Contract) {
|
3069
3094
|
throw new import_errors10.FuelError(
|
3070
3095
|
import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
|
3071
3096
|
`Contract input should be of type 'contract'.`
|
@@ -3074,34 +3099,34 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3074
3099
|
return contractInput;
|
3075
3100
|
}
|
3076
3101
|
function getInputAccountAddress(input) {
|
3077
|
-
if (input.type ===
|
3102
|
+
if (input.type === import_transactions13.InputType.Coin) {
|
3078
3103
|
return input.owner.toString();
|
3079
3104
|
}
|
3080
|
-
if (input.type ===
|
3105
|
+
if (input.type === import_transactions13.InputType.Message) {
|
3081
3106
|
return input.recipient.toString();
|
3082
3107
|
}
|
3083
3108
|
return "";
|
3084
3109
|
}
|
3085
3110
|
|
3086
3111
|
// src/providers/transaction-summary/output.ts
|
3087
|
-
var
|
3112
|
+
var import_transactions14 = require("@fuel-ts/transactions");
|
3088
3113
|
function getOutputsByType(outputs, type) {
|
3089
3114
|
return outputs.filter((o) => o.type === type);
|
3090
3115
|
}
|
3091
3116
|
function getOutputsContractCreated(outputs) {
|
3092
|
-
return getOutputsByType(outputs,
|
3117
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.ContractCreated);
|
3093
3118
|
}
|
3094
3119
|
function getOutputsCoin(outputs) {
|
3095
|
-
return getOutputsByType(outputs,
|
3120
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Coin);
|
3096
3121
|
}
|
3097
3122
|
function getOutputsChange(outputs) {
|
3098
|
-
return getOutputsByType(outputs,
|
3123
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Change);
|
3099
3124
|
}
|
3100
3125
|
function getOutputsContract(outputs) {
|
3101
|
-
return getOutputsByType(outputs,
|
3126
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Contract);
|
3102
3127
|
}
|
3103
3128
|
function getOutputsVariable(outputs) {
|
3104
|
-
return getOutputsByType(outputs,
|
3129
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Variable);
|
3105
3130
|
}
|
3106
3131
|
|
3107
3132
|
// src/providers/transaction-summary/types.ts
|
@@ -3150,11 +3175,11 @@ function getReceiptsByType(receipts, type) {
|
|
3150
3175
|
}
|
3151
3176
|
function getTransactionTypeName(transactionType) {
|
3152
3177
|
switch (transactionType) {
|
3153
|
-
case
|
3178
|
+
case import_transactions15.TransactionType.Mint:
|
3154
3179
|
return "Mint" /* Mint */;
|
3155
|
-
case
|
3180
|
+
case import_transactions15.TransactionType.Create:
|
3156
3181
|
return "Create" /* Create */;
|
3157
|
-
case
|
3182
|
+
case import_transactions15.TransactionType.Script:
|
3158
3183
|
return "Script" /* Script */;
|
3159
3184
|
default:
|
3160
3185
|
throw new import_errors11.FuelError(
|
@@ -3186,10 +3211,10 @@ function hasSameAssetId(a) {
|
|
3186
3211
|
return (b) => a.assetId === b.assetId;
|
3187
3212
|
}
|
3188
3213
|
function getReceiptsCall(receipts) {
|
3189
|
-
return getReceiptsByType(receipts,
|
3214
|
+
return getReceiptsByType(receipts, import_transactions15.ReceiptType.Call);
|
3190
3215
|
}
|
3191
3216
|
function getReceiptsMessageOut(receipts) {
|
3192
|
-
return getReceiptsByType(receipts,
|
3217
|
+
return getReceiptsByType(receipts, import_transactions15.ReceiptType.MessageOut);
|
3193
3218
|
}
|
3194
3219
|
var mergeAssets = (op1, op2) => {
|
3195
3220
|
const assets1 = op1.assetsSent || [];
|
@@ -3202,7 +3227,7 @@ var mergeAssets = (op1, op2) => {
|
|
3202
3227
|
if (!matchingAsset) {
|
3203
3228
|
return asset1;
|
3204
3229
|
}
|
3205
|
-
const mergedAmount = (0,
|
3230
|
+
const mergedAmount = (0, import_math14.bn)(asset1.amount).add(matchingAsset.amount);
|
3206
3231
|
return { ...asset1, amount: mergedAmount };
|
3207
3232
|
});
|
3208
3233
|
return mergedAssets.concat(filteredAssets);
|
@@ -3228,7 +3253,7 @@ function addOperation(operations, toAdd) {
|
|
3228
3253
|
return allOperations;
|
3229
3254
|
}
|
3230
3255
|
function getReceiptsTransferOut(receipts) {
|
3231
|
-
return getReceiptsByType(receipts,
|
3256
|
+
return getReceiptsByType(receipts, import_transactions15.ReceiptType.TransferOut);
|
3232
3257
|
}
|
3233
3258
|
function getWithdrawFromFuelOperations({
|
3234
3259
|
inputs,
|
@@ -3388,11 +3413,11 @@ function getTransferOperations({
|
|
3388
3413
|
});
|
3389
3414
|
const transferReceipts = getReceiptsByType(
|
3390
3415
|
receipts,
|
3391
|
-
|
3416
|
+
import_transactions15.ReceiptType.Transfer
|
3392
3417
|
);
|
3393
3418
|
const transferOutReceipts = getReceiptsByType(
|
3394
3419
|
receipts,
|
3395
|
-
|
3420
|
+
import_transactions15.ReceiptType.TransferOut
|
3396
3421
|
);
|
3397
3422
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
3398
3423
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3477,17 +3502,17 @@ function getOperations({
|
|
3477
3502
|
}
|
3478
3503
|
|
3479
3504
|
// src/providers/transaction-summary/receipt.ts
|
3480
|
-
var
|
3505
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
3481
3506
|
var processGqlReceipt = (gqlReceipt) => {
|
3482
3507
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3483
3508
|
switch (receipt.type) {
|
3484
|
-
case
|
3509
|
+
case import_transactions16.ReceiptType.ReturnData: {
|
3485
3510
|
return {
|
3486
3511
|
...receipt,
|
3487
3512
|
data: gqlReceipt.data || "0x"
|
3488
3513
|
};
|
3489
3514
|
}
|
3490
|
-
case
|
3515
|
+
case import_transactions16.ReceiptType.LogData: {
|
3491
3516
|
return {
|
3492
3517
|
...receipt,
|
3493
3518
|
data: gqlReceipt.data || "0x"
|
@@ -3500,7 +3525,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3500
3525
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3501
3526
|
const mintedAssets = [];
|
3502
3527
|
receipts.forEach((receipt) => {
|
3503
|
-
if (receipt.type ===
|
3528
|
+
if (receipt.type === import_transactions16.ReceiptType.Mint) {
|
3504
3529
|
mintedAssets.push({
|
3505
3530
|
subId: receipt.subId,
|
3506
3531
|
contractId: receipt.contractId,
|
@@ -3514,7 +3539,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3514
3539
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3515
3540
|
const burnedAssets = [];
|
3516
3541
|
receipts.forEach((receipt) => {
|
3517
|
-
if (receipt.type ===
|
3542
|
+
if (receipt.type === import_transactions16.ReceiptType.Burn) {
|
3518
3543
|
burnedAssets.push({
|
3519
3544
|
subId: receipt.subId,
|
3520
3545
|
contractId: receipt.contractId,
|
@@ -3528,7 +3553,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3528
3553
|
|
3529
3554
|
// src/providers/transaction-summary/status.ts
|
3530
3555
|
var import_errors12 = require("@fuel-ts/errors");
|
3531
|
-
var
|
3556
|
+
var import_math15 = require("@fuel-ts/math");
|
3532
3557
|
var getTransactionStatusName = (gqlStatus) => {
|
3533
3558
|
switch (gqlStatus) {
|
3534
3559
|
case "FailureStatus":
|
@@ -3562,15 +3587,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3562
3587
|
time = gqlTransactionStatus.time;
|
3563
3588
|
blockId = gqlTransactionStatus.block.id;
|
3564
3589
|
isStatusSuccess = true;
|
3565
|
-
totalFee = (0,
|
3566
|
-
totalGas = (0,
|
3590
|
+
totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
|
3591
|
+
totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
|
3567
3592
|
break;
|
3568
3593
|
case "FailureStatus":
|
3569
3594
|
time = gqlTransactionStatus.time;
|
3570
3595
|
blockId = gqlTransactionStatus.block.id;
|
3571
3596
|
isStatusFailure = true;
|
3572
|
-
totalFee = (0,
|
3573
|
-
totalGas = (0,
|
3597
|
+
totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
|
3598
|
+
totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
|
3574
3599
|
break;
|
3575
3600
|
case "SubmittedStatus":
|
3576
3601
|
time = gqlTransactionStatus.time;
|
@@ -3620,7 +3645,7 @@ function assembleTransactionSummary(params) {
|
|
3620
3645
|
maxInputs
|
3621
3646
|
});
|
3622
3647
|
const typeName = getTransactionTypeName(transaction.type);
|
3623
|
-
const tip = (0,
|
3648
|
+
const tip = (0, import_math16.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
3624
3649
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3625
3650
|
const fee = calculateTXFeeForSummary({
|
3626
3651
|
totalFee,
|
@@ -3671,12 +3696,12 @@ function assembleTransactionSummary(params) {
|
|
3671
3696
|
|
3672
3697
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3673
3698
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
3674
|
-
var
|
3699
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
3675
3700
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3676
3701
|
return receipts.reduce((logs, receipt) => {
|
3677
|
-
if (receipt.type ===
|
3702
|
+
if (receipt.type === import_transactions18.ReceiptType.LogData || receipt.type === import_transactions18.ReceiptType.Log) {
|
3678
3703
|
const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
|
3679
|
-
const data = receipt.type ===
|
3704
|
+
const data = receipt.type === import_transactions18.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3680
3705
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3681
3706
|
logs.push(decodedLog);
|
3682
3707
|
}
|
@@ -3691,7 +3716,7 @@ var TransactionResponse = class {
|
|
3691
3716
|
/** Current provider */
|
3692
3717
|
provider;
|
3693
3718
|
/** Gas used on the transaction */
|
3694
|
-
gasUsed = (0,
|
3719
|
+
gasUsed = (0, import_math17.bn)(0);
|
3695
3720
|
/** The graphql Transaction with receipts object. */
|
3696
3721
|
gqlTransaction;
|
3697
3722
|
abis;
|
@@ -3749,7 +3774,7 @@ var TransactionResponse = class {
|
|
3749
3774
|
* @returns The decoded transaction.
|
3750
3775
|
*/
|
3751
3776
|
decodeTransaction(transactionWithReceipts) {
|
3752
|
-
return new
|
3777
|
+
return new import_transactions19.TransactionCoder().decode(
|
3753
3778
|
(0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
|
3754
3779
|
0
|
3755
3780
|
)?.[0];
|
@@ -3925,47 +3950,47 @@ var processGqlChain = (chain) => {
|
|
3925
3950
|
} = consensusParameters;
|
3926
3951
|
return {
|
3927
3952
|
name,
|
3928
|
-
baseChainHeight: (0,
|
3953
|
+
baseChainHeight: (0, import_math18.bn)(daHeight),
|
3929
3954
|
consensusParameters: {
|
3930
3955
|
version,
|
3931
|
-
chainId: (0,
|
3956
|
+
chainId: (0, import_math18.bn)(chainId),
|
3932
3957
|
baseAssetId,
|
3933
3958
|
feeParameters: {
|
3934
3959
|
version: feeParams.version,
|
3935
|
-
gasPerByte: (0,
|
3936
|
-
gasPriceFactor: (0,
|
3960
|
+
gasPerByte: (0, import_math18.bn)(feeParams.gasPerByte),
|
3961
|
+
gasPriceFactor: (0, import_math18.bn)(feeParams.gasPriceFactor)
|
3937
3962
|
},
|
3938
3963
|
contractParameters: {
|
3939
3964
|
version: contractParams.version,
|
3940
|
-
contractMaxSize: (0,
|
3941
|
-
maxStorageSlots: (0,
|
3965
|
+
contractMaxSize: (0, import_math18.bn)(contractParams.contractMaxSize),
|
3966
|
+
maxStorageSlots: (0, import_math18.bn)(contractParams.maxStorageSlots)
|
3942
3967
|
},
|
3943
3968
|
txParameters: {
|
3944
3969
|
version: txParams.version,
|
3945
|
-
maxInputs: (0,
|
3946
|
-
maxOutputs: (0,
|
3947
|
-
maxWitnesses: (0,
|
3948
|
-
maxGasPerTx: (0,
|
3949
|
-
maxSize: (0,
|
3950
|
-
maxBytecodeSubsections: (0,
|
3970
|
+
maxInputs: (0, import_math18.bn)(txParams.maxInputs),
|
3971
|
+
maxOutputs: (0, import_math18.bn)(txParams.maxOutputs),
|
3972
|
+
maxWitnesses: (0, import_math18.bn)(txParams.maxWitnesses),
|
3973
|
+
maxGasPerTx: (0, import_math18.bn)(txParams.maxGasPerTx),
|
3974
|
+
maxSize: (0, import_math18.bn)(txParams.maxSize),
|
3975
|
+
maxBytecodeSubsections: (0, import_math18.bn)(txParams.maxBytecodeSubsections)
|
3951
3976
|
},
|
3952
3977
|
predicateParameters: {
|
3953
3978
|
version: predicateParams.version,
|
3954
|
-
maxPredicateLength: (0,
|
3955
|
-
maxPredicateDataLength: (0,
|
3956
|
-
maxGasPerPredicate: (0,
|
3957
|
-
maxMessageDataLength: (0,
|
3979
|
+
maxPredicateLength: (0, import_math18.bn)(predicateParams.maxPredicateLength),
|
3980
|
+
maxPredicateDataLength: (0, import_math18.bn)(predicateParams.maxPredicateDataLength),
|
3981
|
+
maxGasPerPredicate: (0, import_math18.bn)(predicateParams.maxGasPerPredicate),
|
3982
|
+
maxMessageDataLength: (0, import_math18.bn)(predicateParams.maxMessageDataLength)
|
3958
3983
|
},
|
3959
3984
|
scriptParameters: {
|
3960
3985
|
version: scriptParams.version,
|
3961
|
-
maxScriptLength: (0,
|
3962
|
-
maxScriptDataLength: (0,
|
3986
|
+
maxScriptLength: (0, import_math18.bn)(scriptParams.maxScriptLength),
|
3987
|
+
maxScriptDataLength: (0, import_math18.bn)(scriptParams.maxScriptDataLength)
|
3963
3988
|
},
|
3964
3989
|
gasCosts
|
3965
3990
|
},
|
3966
3991
|
latestBlock: {
|
3967
3992
|
id: latestBlock.id,
|
3968
|
-
height: (0,
|
3993
|
+
height: (0, import_math18.bn)(latestBlock.height),
|
3969
3994
|
time: latestBlock.header.time,
|
3970
3995
|
transactions: latestBlock.transactions.map((i) => ({
|
3971
3996
|
id: i.id
|
@@ -4161,7 +4186,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4161
4186
|
*/
|
4162
4187
|
async getBlockNumber() {
|
4163
4188
|
const { chain } = await this.operations.getChain();
|
4164
|
-
return (0,
|
4189
|
+
return (0, import_math18.bn)(chain.latestBlock.height, 10);
|
4165
4190
|
}
|
4166
4191
|
/**
|
4167
4192
|
* Returns the chain information.
|
@@ -4171,8 +4196,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4171
4196
|
async fetchNode() {
|
4172
4197
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
4173
4198
|
const processedNodeInfo = {
|
4174
|
-
maxDepth: (0,
|
4175
|
-
maxTx: (0,
|
4199
|
+
maxDepth: (0, import_math18.bn)(nodeInfo.maxDepth),
|
4200
|
+
maxTx: (0, import_math18.bn)(nodeInfo.maxTx),
|
4176
4201
|
nodeVersion: nodeInfo.nodeVersion,
|
4177
4202
|
utxoValidation: nodeInfo.utxoValidation,
|
4178
4203
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4230,7 +4255,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4230
4255
|
}
|
4231
4256
|
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4232
4257
|
let abis;
|
4233
|
-
if (transactionRequest.type ===
|
4258
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4234
4259
|
abis = transactionRequest.abis;
|
4235
4260
|
}
|
4236
4261
|
if (awaitExecution) {
|
@@ -4289,7 +4314,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4289
4314
|
async estimatePredicates(transactionRequest) {
|
4290
4315
|
const shouldEstimatePredicates = Boolean(
|
4291
4316
|
transactionRequest.inputs.find(
|
4292
|
-
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new
|
4317
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math18.BN(input.predicateGasUsed).isZero()
|
4293
4318
|
)
|
4294
4319
|
);
|
4295
4320
|
if (!shouldEstimatePredicates) {
|
@@ -4304,7 +4329,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4304
4329
|
} = response;
|
4305
4330
|
if (inputs) {
|
4306
4331
|
inputs.forEach((input, index) => {
|
4307
|
-
if ("predicateGasUsed" in input && (0,
|
4332
|
+
if ("predicateGasUsed" in input && (0, import_math18.bn)(input.predicateGasUsed).gt(0)) {
|
4308
4333
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4309
4334
|
}
|
4310
4335
|
});
|
@@ -4322,7 +4347,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4322
4347
|
* @returns A promise.
|
4323
4348
|
*/
|
4324
4349
|
async estimateTxDependencies(transactionRequest) {
|
4325
|
-
if (transactionRequest.type ===
|
4350
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Create) {
|
4326
4351
|
return {
|
4327
4352
|
receipts: [],
|
4328
4353
|
outputVariables: 0,
|
@@ -4386,7 +4411,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4386
4411
|
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4387
4412
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4388
4413
|
allRequests.forEach((req, index) => {
|
4389
|
-
if (req.type ===
|
4414
|
+
if (req.type === import_transactions20.TransactionType.Script) {
|
4390
4415
|
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4391
4416
|
}
|
4392
4417
|
});
|
@@ -4412,7 +4437,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4412
4437
|
);
|
4413
4438
|
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4414
4439
|
const request = allRequests[requestIdx];
|
4415
|
-
if (hasMissingOutputs && request?.type ===
|
4440
|
+
if (hasMissingOutputs && request?.type === import_transactions20.TransactionType.Script) {
|
4416
4441
|
result.outputVariables += missingOutputVariables.length;
|
4417
4442
|
request.addVariableOutputs(missingOutputVariables.length);
|
4418
4443
|
missingOutputContractIds.forEach(({ contractId }) => {
|
@@ -4462,13 +4487,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4462
4487
|
gasPrice = await this.estimateGasPrice(10);
|
4463
4488
|
}
|
4464
4489
|
const minFee = calculateGasFee({
|
4465
|
-
gasPrice: (0,
|
4490
|
+
gasPrice: (0, import_math18.bn)(gasPrice),
|
4466
4491
|
gas: minGas,
|
4467
4492
|
priceFactor: gasPriceFactor,
|
4468
4493
|
tip: transactionRequest.tip
|
4469
4494
|
}).add(1);
|
4470
|
-
let gasLimit = (0,
|
4471
|
-
if (transactionRequest.type ===
|
4495
|
+
let gasLimit = (0, import_math18.bn)(0);
|
4496
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4472
4497
|
gasLimit = transactionRequest.gasLimit;
|
4473
4498
|
if (transactionRequest.gasLimit.eq(0)) {
|
4474
4499
|
transactionRequest.gasLimit = minGas;
|
@@ -4480,7 +4505,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4480
4505
|
}
|
4481
4506
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4482
4507
|
const maxFee = calculateGasFee({
|
4483
|
-
gasPrice: (0,
|
4508
|
+
gasPrice: (0, import_math18.bn)(gasPrice),
|
4484
4509
|
gas: maxGas,
|
4485
4510
|
priceFactor: gasPriceFactor,
|
4486
4511
|
tip: transactionRequest.tip
|
@@ -4538,14 +4563,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4538
4563
|
*/
|
4539
4564
|
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
4540
4565
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4541
|
-
const isScriptTransaction = txRequestClone.type ===
|
4566
|
+
const isScriptTransaction = txRequestClone.type === import_transactions20.TransactionType.Script;
|
4542
4567
|
const baseAssetId = this.getBaseAssetId();
|
4543
4568
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4544
4569
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4545
4570
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4546
|
-
txRequestClone.maxFee = (0,
|
4571
|
+
txRequestClone.maxFee = (0, import_math18.bn)(0);
|
4547
4572
|
if (isScriptTransaction) {
|
4548
|
-
txRequestClone.gasLimit = (0,
|
4573
|
+
txRequestClone.gasLimit = (0, import_math18.bn)(0);
|
4549
4574
|
}
|
4550
4575
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4551
4576
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4565,7 +4590,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4565
4590
|
let dryRunStatus;
|
4566
4591
|
let missingContractIds = [];
|
4567
4592
|
let outputVariables = 0;
|
4568
|
-
let gasUsed = (0,
|
4593
|
+
let gasUsed = (0, import_math18.bn)(0);
|
4569
4594
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4570
4595
|
txRequestClone.maxFee = maxFee;
|
4571
4596
|
if (isScriptTransaction) {
|
@@ -4630,10 +4655,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4630
4655
|
return coins.map((coin) => ({
|
4631
4656
|
id: coin.utxoId,
|
4632
4657
|
assetId: coin.assetId,
|
4633
|
-
amount: (0,
|
4658
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4634
4659
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4635
|
-
blockCreated: (0,
|
4636
|
-
txCreatedIdx: (0,
|
4660
|
+
blockCreated: (0, import_math18.bn)(coin.blockCreated),
|
4661
|
+
txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
|
4637
4662
|
}));
|
4638
4663
|
}
|
4639
4664
|
/**
|
@@ -4667,12 +4692,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4667
4692
|
};
|
4668
4693
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
4669
4694
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
4670
|
-
switch (coin.
|
4695
|
+
switch (coin.__typename) {
|
4671
4696
|
case "MessageCoin":
|
4672
4697
|
return {
|
4673
|
-
amount: (0,
|
4698
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4674
4699
|
assetId: coin.assetId,
|
4675
|
-
daHeight: (0,
|
4700
|
+
daHeight: (0, import_math18.bn)(coin.daHeight),
|
4676
4701
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4677
4702
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4678
4703
|
nonce: coin.nonce
|
@@ -4680,11 +4705,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4680
4705
|
case "Coin":
|
4681
4706
|
return {
|
4682
4707
|
id: coin.utxoId,
|
4683
|
-
amount: (0,
|
4708
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4684
4709
|
assetId: coin.assetId,
|
4685
4710
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4686
|
-
blockCreated: (0,
|
4687
|
-
txCreatedIdx: (0,
|
4711
|
+
blockCreated: (0, import_math18.bn)(coin.blockCreated),
|
4712
|
+
txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
|
4688
4713
|
};
|
4689
4714
|
default:
|
4690
4715
|
return null;
|
@@ -4701,13 +4726,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4701
4726
|
async getBlock(idOrHeight) {
|
4702
4727
|
let variables;
|
4703
4728
|
if (typeof idOrHeight === "number") {
|
4704
|
-
variables = { height: (0,
|
4729
|
+
variables = { height: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4705
4730
|
} else if (idOrHeight === "latest") {
|
4706
4731
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4707
4732
|
} else if (idOrHeight.length === 66) {
|
4708
4733
|
variables = { blockId: idOrHeight };
|
4709
4734
|
} else {
|
4710
|
-
variables = { blockId: (0,
|
4735
|
+
variables = { blockId: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4711
4736
|
}
|
4712
4737
|
const { block } = await this.operations.getBlock(variables);
|
4713
4738
|
if (!block) {
|
@@ -4715,7 +4740,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4715
4740
|
}
|
4716
4741
|
return {
|
4717
4742
|
id: block.id,
|
4718
|
-
height: (0,
|
4743
|
+
height: (0, import_math18.bn)(block.height),
|
4719
4744
|
time: block.header.time,
|
4720
4745
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4721
4746
|
};
|
@@ -4730,7 +4755,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4730
4755
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4731
4756
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4732
4757
|
id: block.id,
|
4733
|
-
height: (0,
|
4758
|
+
height: (0, import_math18.bn)(block.height),
|
4734
4759
|
time: block.header.time,
|
4735
4760
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4736
4761
|
}));
|
@@ -4745,7 +4770,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4745
4770
|
async getBlockWithTransactions(idOrHeight) {
|
4746
4771
|
let variables;
|
4747
4772
|
if (typeof idOrHeight === "number") {
|
4748
|
-
variables = { blockHeight: (0,
|
4773
|
+
variables = { blockHeight: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4749
4774
|
} else if (idOrHeight === "latest") {
|
4750
4775
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4751
4776
|
} else {
|
@@ -4757,11 +4782,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4757
4782
|
}
|
4758
4783
|
return {
|
4759
4784
|
id: block.id,
|
4760
|
-
height: (0,
|
4785
|
+
height: (0, import_math18.bn)(block.height, 10),
|
4761
4786
|
time: block.header.time,
|
4762
4787
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4763
4788
|
transactions: block.transactions.map(
|
4764
|
-
(tx) => new
|
4789
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4765
4790
|
)
|
4766
4791
|
};
|
4767
4792
|
}
|
@@ -4776,7 +4801,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4776
4801
|
if (!transaction) {
|
4777
4802
|
return null;
|
4778
4803
|
}
|
4779
|
-
return new
|
4804
|
+
return new import_transactions20.TransactionCoder().decode(
|
4780
4805
|
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4781
4806
|
0
|
4782
4807
|
)?.[0];
|
@@ -4806,7 +4831,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4806
4831
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4807
4832
|
asset: (0, import_utils22.hexlify)(assetId)
|
4808
4833
|
});
|
4809
|
-
return (0,
|
4834
|
+
return (0, import_math18.bn)(contractBalance.amount, 10);
|
4810
4835
|
}
|
4811
4836
|
/**
|
4812
4837
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4820,7 +4845,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4820
4845
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4821
4846
|
assetId: (0, import_utils22.hexlify)(assetId)
|
4822
4847
|
});
|
4823
|
-
return (0,
|
4848
|
+
return (0, import_math18.bn)(balance.amount, 10);
|
4824
4849
|
}
|
4825
4850
|
/**
|
4826
4851
|
* Returns balances for the given owner.
|
@@ -4838,7 +4863,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4838
4863
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4839
4864
|
return balances.map((balance) => ({
|
4840
4865
|
assetId: balance.assetId,
|
4841
|
-
amount: (0,
|
4866
|
+
amount: (0, import_math18.bn)(balance.amount)
|
4842
4867
|
}));
|
4843
4868
|
}
|
4844
4869
|
/**
|
@@ -4856,19 +4881,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4856
4881
|
});
|
4857
4882
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4858
4883
|
return messages.map((message) => ({
|
4859
|
-
messageId:
|
4884
|
+
messageId: import_transactions20.InputMessageCoder.getMessageId({
|
4860
4885
|
sender: message.sender,
|
4861
4886
|
recipient: message.recipient,
|
4862
4887
|
nonce: message.nonce,
|
4863
|
-
amount: (0,
|
4888
|
+
amount: (0, import_math18.bn)(message.amount),
|
4864
4889
|
data: message.data
|
4865
4890
|
}),
|
4866
4891
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4867
4892
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4868
4893
|
nonce: message.nonce,
|
4869
|
-
amount: (0,
|
4870
|
-
data:
|
4871
|
-
daHeight: (0,
|
4894
|
+
amount: (0, import_math18.bn)(message.amount),
|
4895
|
+
data: import_transactions20.InputMessageCoder.decodeData(message.data),
|
4896
|
+
daHeight: (0, import_math18.bn)(message.daHeight)
|
4872
4897
|
}));
|
4873
4898
|
}
|
4874
4899
|
/**
|
@@ -4921,19 +4946,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4921
4946
|
} = result.messageProof;
|
4922
4947
|
return {
|
4923
4948
|
messageProof: {
|
4924
|
-
proofIndex: (0,
|
4949
|
+
proofIndex: (0, import_math18.bn)(messageProof.proofIndex),
|
4925
4950
|
proofSet: messageProof.proofSet
|
4926
4951
|
},
|
4927
4952
|
blockProof: {
|
4928
|
-
proofIndex: (0,
|
4953
|
+
proofIndex: (0, import_math18.bn)(blockProof.proofIndex),
|
4929
4954
|
proofSet: blockProof.proofSet
|
4930
4955
|
},
|
4931
4956
|
messageBlockHeader: {
|
4932
4957
|
id: messageBlockHeader.id,
|
4933
|
-
daHeight: (0,
|
4958
|
+
daHeight: (0, import_math18.bn)(messageBlockHeader.daHeight),
|
4934
4959
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4935
4960
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4936
|
-
height: (0,
|
4961
|
+
height: (0, import_math18.bn)(messageBlockHeader.height),
|
4937
4962
|
prevRoot: messageBlockHeader.prevRoot,
|
4938
4963
|
time: messageBlockHeader.time,
|
4939
4964
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -4945,10 +4970,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4945
4970
|
},
|
4946
4971
|
commitBlockHeader: {
|
4947
4972
|
id: commitBlockHeader.id,
|
4948
|
-
daHeight: (0,
|
4973
|
+
daHeight: (0, import_math18.bn)(commitBlockHeader.daHeight),
|
4949
4974
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4950
4975
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4951
|
-
height: (0,
|
4976
|
+
height: (0, import_math18.bn)(commitBlockHeader.height),
|
4952
4977
|
prevRoot: commitBlockHeader.prevRoot,
|
4953
4978
|
time: commitBlockHeader.time,
|
4954
4979
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -4961,19 +4986,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4961
4986
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4962
4987
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4963
4988
|
nonce,
|
4964
|
-
amount: (0,
|
4989
|
+
amount: (0, import_math18.bn)(amount),
|
4965
4990
|
data
|
4966
4991
|
};
|
4967
4992
|
}
|
4968
4993
|
async getLatestGasPrice() {
|
4969
4994
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4970
|
-
return (0,
|
4995
|
+
return (0, import_math18.bn)(latestGasPrice.gasPrice);
|
4971
4996
|
}
|
4972
4997
|
async estimateGasPrice(blockHorizon) {
|
4973
4998
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4974
4999
|
blockHorizon: String(blockHorizon)
|
4975
5000
|
});
|
4976
|
-
return (0,
|
5001
|
+
return (0, import_math18.bn)(estimateGasPrice.gasPrice);
|
4977
5002
|
}
|
4978
5003
|
/**
|
4979
5004
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4994,10 +5019,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4994
5019
|
*/
|
4995
5020
|
async produceBlocks(amount, startTime) {
|
4996
5021
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4997
|
-
blocksToProduce: (0,
|
5022
|
+
blocksToProduce: (0, import_math18.bn)(amount).toString(10),
|
4998
5023
|
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4999
5024
|
});
|
5000
|
-
return (0,
|
5025
|
+
return (0, import_math18.bn)(latestBlockHeight);
|
5001
5026
|
}
|
5002
5027
|
// eslint-disable-next-line @typescript-eslint/require-await
|
5003
5028
|
async getTransactionResponse(transactionId) {
|
@@ -5033,7 +5058,7 @@ cacheInputs_fn = function(inputs) {
|
|
5033
5058
|
return;
|
5034
5059
|
}
|
5035
5060
|
inputs.forEach((input) => {
|
5036
|
-
if (input.type ===
|
5061
|
+
if (input.type === import_transactions20.InputType.Coin) {
|
5037
5062
|
this.cache?.set(input.id);
|
5038
5063
|
}
|
5039
5064
|
});
|
@@ -5043,8 +5068,8 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
5043
5068
|
|
5044
5069
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5045
5070
|
var import_errors15 = require("@fuel-ts/errors");
|
5046
|
-
var
|
5047
|
-
var
|
5071
|
+
var import_math19 = require("@fuel-ts/math");
|
5072
|
+
var import_transactions21 = require("@fuel-ts/transactions");
|
5048
5073
|
var import_utils25 = require("@fuel-ts/utils");
|
5049
5074
|
async function getTransactionSummary(params) {
|
5050
5075
|
const { id, provider, abiMap } = params;
|
@@ -5057,7 +5082,7 @@ async function getTransactionSummary(params) {
|
|
5057
5082
|
`Transaction not found for given id: ${id}.`
|
5058
5083
|
);
|
5059
5084
|
}
|
5060
|
-
const [decodedTransaction] = new
|
5085
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
|
5061
5086
|
(0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5062
5087
|
0
|
5063
5088
|
);
|
@@ -5080,8 +5105,8 @@ async function getTransactionSummary(params) {
|
|
5080
5105
|
transaction: decodedTransaction,
|
5081
5106
|
transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5082
5107
|
gqlTransactionStatus: gqlTransaction.status,
|
5083
|
-
gasPerByte: (0,
|
5084
|
-
gasPriceFactor: (0,
|
5108
|
+
gasPerByte: (0, import_math19.bn)(gasPerByte),
|
5109
|
+
gasPriceFactor: (0, import_math19.bn)(gasPriceFactor),
|
5085
5110
|
abiMap,
|
5086
5111
|
maxInputs,
|
5087
5112
|
gasCosts,
|
@@ -5130,7 +5155,7 @@ async function getTransactionsSummaries(params) {
|
|
5130
5155
|
const transactions = edges.map((edge) => {
|
5131
5156
|
const { node: gqlTransaction } = edge;
|
5132
5157
|
const { id, rawPayload, status } = gqlTransaction;
|
5133
|
-
const [decodedTransaction] = new
|
5158
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
|
5134
5159
|
let txReceipts = [];
|
5135
5160
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5136
5161
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5283,22 +5308,6 @@ var assets = [
|
|
5283
5308
|
}
|
5284
5309
|
];
|
5285
5310
|
|
5286
|
-
// src/providers/transaction-request/helpers.ts
|
5287
|
-
var import_math19 = require("@fuel-ts/math");
|
5288
|
-
var import_transactions21 = require("@fuel-ts/transactions");
|
5289
|
-
var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
|
5290
|
-
var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
|
5291
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
5292
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
5293
|
-
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
5294
|
-
return acc.add(input.amount);
|
5295
|
-
}
|
5296
|
-
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
5297
|
-
return acc.add(input.amount);
|
5298
|
-
}
|
5299
|
-
return acc;
|
5300
|
-
}, (0, import_math19.bn)(0));
|
5301
|
-
|
5302
5311
|
// src/utils/formatTransferToContractScriptData.ts
|
5303
5312
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5304
5313
|
var import_math20 = require("@fuel-ts/math");
|
@@ -5536,7 +5545,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5536
5545
|
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5537
5546
|
const resources = await this.getResourcesToSpend(
|
5538
5547
|
missingQuantities,
|
5539
|
-
|
5548
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5540
5549
|
);
|
5541
5550
|
request.addResources(resources);
|
5542
5551
|
txRequest.shiftPredicateData();
|
@@ -9313,10 +9322,15 @@ var Predicate = class extends Account {
|
|
9313
9322
|
populateTransactionPredicateData(transactionRequestLike) {
|
9314
9323
|
const request = transactionRequestify(transactionRequestLike);
|
9315
9324
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9316
|
-
|
9317
|
-
|
9325
|
+
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
9326
|
+
if (placeholderIndex !== -1) {
|
9327
|
+
request.removeWitness(placeholderIndex);
|
9328
|
+
}
|
9329
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9330
|
+
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9318
9331
|
input.predicate = (0, import_utils36.hexlify)(this.bytes);
|
9319
9332
|
input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
|
9333
|
+
input.witnessIndex = 0;
|
9320
9334
|
}
|
9321
9335
|
});
|
9322
9336
|
return request;
|
@@ -9439,6 +9453,28 @@ var Predicate = class extends Account {
|
|
9439
9453
|
}
|
9440
9454
|
return mutatedBytes;
|
9441
9455
|
}
|
9456
|
+
/**
|
9457
|
+
* Returns the index of the witness placeholder that was added to this predicate.
|
9458
|
+
* If no witness placeholder was added, it returns -1.
|
9459
|
+
* @param request - The transaction request.
|
9460
|
+
* @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
|
9461
|
+
*/
|
9462
|
+
getIndexFromPlaceholderWitness(request) {
|
9463
|
+
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
9464
|
+
let index = -1;
|
9465
|
+
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
9466
|
+
if (hasEmptyPredicateInputs) {
|
9467
|
+
index = hasEmptyPredicateInputs.witnessIndex;
|
9468
|
+
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
9469
|
+
if (!allInputsAreEmpty) {
|
9470
|
+
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
9471
|
+
if (wasFilledInputAddedFirst) {
|
9472
|
+
index = -1;
|
9473
|
+
}
|
9474
|
+
}
|
9475
|
+
}
|
9476
|
+
return index;
|
9477
|
+
}
|
9442
9478
|
};
|
9443
9479
|
|
9444
9480
|
// src/connectors/fuel.ts
|
@@ -10162,7 +10198,8 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10162
10198
|
assets,
|
10163
10199
|
buildBlockExplorerUrl,
|
10164
10200
|
cacheFor,
|
10165
|
-
|
10201
|
+
cacheRequestInputsResources,
|
10202
|
+
cacheRequestInputsResourcesFromOwner,
|
10166
10203
|
calculateGasFee,
|
10167
10204
|
calculateMetadataGasForTxCreate,
|
10168
10205
|
calculateMetadataGasForTxScript,
|
@@ -10175,6 +10212,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10175
10212
|
extractMintedAssetsFromReceipts,
|
10176
10213
|
extractTxError,
|
10177
10214
|
gasUsedByInputs,
|
10215
|
+
getAssetAmountInRequestInputs,
|
10178
10216
|
getAssetEth,
|
10179
10217
|
getAssetFuel,
|
10180
10218
|
getAssetNetwork,
|
@@ -10209,6 +10247,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10209
10247
|
getReceiptsMessageOut,
|
10210
10248
|
getReceiptsTransferOut,
|
10211
10249
|
getReceiptsWithMissingData,
|
10250
|
+
getRequestInputResourceOwner,
|
10212
10251
|
getTransactionStatusName,
|
10213
10252
|
getTransactionSummary,
|
10214
10253
|
getTransactionSummaryFromRequest,
|
@@ -10222,6 +10261,10 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10222
10261
|
isMessage,
|
10223
10262
|
isRawCoin,
|
10224
10263
|
isRawMessage,
|
10264
|
+
isRequestInputCoin,
|
10265
|
+
isRequestInputMessage,
|
10266
|
+
isRequestInputResource,
|
10267
|
+
isRequestInputResourceFromOwner,
|
10225
10268
|
isType,
|
10226
10269
|
isTypeCreate,
|
10227
10270
|
isTypeMint,
|