@fuel-ts/account 0.0.0-rc-2152-20240425194419 → 0.0.0-rc-2021-20240425202957
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/README.md +1 -1
- package/dist/account.d.ts +7 -6
- package/dist/account.d.ts.map +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +1818 -696
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +796 -545
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +671 -421
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +12 -24
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +810 -359
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +4 -2
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +7 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +46 -27
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +8 -28
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +3 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +3 -2
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +8 -2
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +2544 -1193
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +782 -536
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +669 -423
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +16 -16
package/dist/index.js
CHANGED
@@ -95,7 +95,7 @@ __export(src_exports, {
|
|
95
95
|
WalletLocked: () => WalletLocked,
|
96
96
|
WalletManager: () => WalletManager,
|
97
97
|
WalletUnlocked: () => WalletUnlocked,
|
98
|
-
|
98
|
+
addAmountToCoinQuantities: () => addAmountToCoinQuantities,
|
99
99
|
addOperation: () => addOperation,
|
100
100
|
assemblePanicError: () => assemblePanicError,
|
101
101
|
assembleReceiptByType: () => assembleReceiptByType,
|
@@ -104,9 +104,10 @@ __export(src_exports, {
|
|
104
104
|
assets: () => assets,
|
105
105
|
buildBlockExplorerUrl: () => buildBlockExplorerUrl,
|
106
106
|
cacheFor: () => cacheFor,
|
107
|
+
cacheTxInputsFromOwner: () => cacheTxInputsFromOwner,
|
108
|
+
calculateGasFee: () => calculateGasFee,
|
107
109
|
calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
|
108
110
|
calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
|
109
|
-
calculatePriceWithFactor: () => calculatePriceWithFactor,
|
110
111
|
calculateTransactionFee: () => calculateTransactionFee,
|
111
112
|
coinQuantityfy: () => coinQuantityfy,
|
112
113
|
deferPromise: () => deferPromise,
|
@@ -186,8 +187,9 @@ module.exports = __toCommonJS(src_exports);
|
|
186
187
|
var import_address4 = require("@fuel-ts/address");
|
187
188
|
var import_errors16 = require("@fuel-ts/errors");
|
188
189
|
var import_interfaces = require("@fuel-ts/interfaces");
|
189
|
-
var
|
190
|
-
var
|
190
|
+
var import_math19 = require("@fuel-ts/math");
|
191
|
+
var import_utils27 = require("@fuel-ts/utils");
|
192
|
+
var import_ramda4 = require("ramda");
|
191
193
|
|
192
194
|
// src/providers/coin-quantity.ts
|
193
195
|
var import_math = require("@fuel-ts/math");
|
@@ -195,24 +197,24 @@ var import_utils = require("@fuel-ts/utils");
|
|
195
197
|
var coinQuantityfy = (coinQuantityLike) => {
|
196
198
|
let assetId;
|
197
199
|
let amount;
|
198
|
-
let
|
200
|
+
let max;
|
199
201
|
if (Array.isArray(coinQuantityLike)) {
|
200
202
|
amount = coinQuantityLike[0];
|
201
203
|
assetId = coinQuantityLike[1];
|
202
|
-
|
204
|
+
max = coinQuantityLike[2] ?? void 0;
|
203
205
|
} else {
|
204
206
|
amount = coinQuantityLike.amount;
|
205
207
|
assetId = coinQuantityLike.assetId;
|
206
|
-
|
208
|
+
max = coinQuantityLike.max ?? void 0;
|
207
209
|
}
|
208
210
|
const bnAmount = (0, import_math.bn)(amount);
|
209
211
|
return {
|
210
212
|
assetId: (0, import_utils.hexlify)(assetId),
|
211
213
|
amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
|
212
|
-
max:
|
214
|
+
max: max ? (0, import_math.bn)(max) : void 0
|
213
215
|
};
|
214
216
|
};
|
215
|
-
var
|
217
|
+
var addAmountToCoinQuantities = (params) => {
|
216
218
|
const { amount, assetId } = params;
|
217
219
|
const coinQuantities = [...params.coinQuantities];
|
218
220
|
const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
|
@@ -227,26 +229,31 @@ var addAmountToAsset = (params) => {
|
|
227
229
|
// src/providers/provider.ts
|
228
230
|
var import_address3 = require("@fuel-ts/address");
|
229
231
|
var import_errors14 = require("@fuel-ts/errors");
|
230
|
-
var
|
231
|
-
var
|
232
|
-
var
|
232
|
+
var import_math16 = require("@fuel-ts/math");
|
233
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
234
|
+
var import_utils22 = require("@fuel-ts/utils");
|
233
235
|
var import_versions = require("@fuel-ts/versions");
|
234
|
-
var
|
236
|
+
var import_utils23 = require("@noble/curves/abstract/utils");
|
237
|
+
var import_ethers = require("ethers");
|
235
238
|
var import_graphql_request = require("graphql-request");
|
236
239
|
var import_ramda3 = require("ramda");
|
237
240
|
|
238
241
|
// src/providers/__generated__/operations.ts
|
239
242
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
243
|
+
var TransactionStatusSubscriptionFragmentFragmentDoc = import_graphql_tag.default`
|
244
|
+
fragment transactionStatusSubscriptionFragment on TransactionStatus {
|
245
|
+
type: __typename
|
246
|
+
... on SqueezedOutStatus {
|
247
|
+
reason
|
248
|
+
}
|
249
|
+
}
|
250
|
+
`;
|
240
251
|
var ReceiptFragmentFragmentDoc = import_graphql_tag.default`
|
241
252
|
fragment receiptFragment on Receipt {
|
242
|
-
|
243
|
-
id
|
244
|
-
}
|
253
|
+
id
|
245
254
|
pc
|
246
255
|
is
|
247
|
-
to
|
248
|
-
id
|
249
|
-
}
|
256
|
+
to
|
250
257
|
toAddress
|
251
258
|
amount
|
252
259
|
assetId
|
@@ -284,10 +291,16 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
284
291
|
id
|
285
292
|
}
|
286
293
|
time
|
294
|
+
receipts {
|
295
|
+
...receiptFragment
|
296
|
+
}
|
287
297
|
programState {
|
288
298
|
returnType
|
289
299
|
data
|
290
300
|
}
|
301
|
+
receipts {
|
302
|
+
...receiptFragment
|
303
|
+
}
|
291
304
|
}
|
292
305
|
... on FailureStatus {
|
293
306
|
block {
|
@@ -295,26 +308,24 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
295
308
|
}
|
296
309
|
time
|
297
310
|
reason
|
311
|
+
receipts {
|
312
|
+
...receiptFragment
|
313
|
+
}
|
298
314
|
}
|
299
315
|
... on SqueezedOutStatus {
|
300
316
|
reason
|
301
317
|
}
|
302
318
|
}
|
303
|
-
`;
|
319
|
+
${ReceiptFragmentFragmentDoc}`;
|
304
320
|
var TransactionFragmentFragmentDoc = import_graphql_tag.default`
|
305
321
|
fragment transactionFragment on Transaction {
|
306
322
|
id
|
307
323
|
rawPayload
|
308
|
-
gasPrice
|
309
|
-
receipts {
|
310
|
-
...receiptFragment
|
311
|
-
}
|
312
324
|
status {
|
313
325
|
...transactionStatusFragment
|
314
326
|
}
|
315
327
|
}
|
316
|
-
${
|
317
|
-
${TransactionStatusFragmentFragmentDoc}`;
|
328
|
+
${TransactionStatusFragmentFragmentDoc}`;
|
318
329
|
var InputEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.default`
|
319
330
|
fragment inputEstimatePredicatesFragment on Input {
|
320
331
|
... on InputCoin {
|
@@ -332,6 +343,46 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
|
|
332
343
|
}
|
333
344
|
}
|
334
345
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
346
|
+
var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
|
347
|
+
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
348
|
+
reason
|
349
|
+
programState {
|
350
|
+
returnType
|
351
|
+
data
|
352
|
+
}
|
353
|
+
}
|
354
|
+
`;
|
355
|
+
var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
|
356
|
+
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
357
|
+
programState {
|
358
|
+
returnType
|
359
|
+
data
|
360
|
+
}
|
361
|
+
}
|
362
|
+
`;
|
363
|
+
var DryRunTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
364
|
+
fragment dryRunTransactionStatusFragment on DryRunTransactionStatus {
|
365
|
+
... on DryRunFailureStatus {
|
366
|
+
...dryRunFailureStatusFragment
|
367
|
+
}
|
368
|
+
... on DryRunSuccessStatus {
|
369
|
+
...dryRunSuccessStatusFragment
|
370
|
+
}
|
371
|
+
}
|
372
|
+
${DryRunFailureStatusFragmentFragmentDoc}
|
373
|
+
${DryRunSuccessStatusFragmentFragmentDoc}`;
|
374
|
+
var DryRunTransactionExecutionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
375
|
+
fragment dryRunTransactionExecutionStatusFragment on DryRunTransactionExecutionStatus {
|
376
|
+
id
|
377
|
+
status {
|
378
|
+
...dryRunTransactionStatusFragment
|
379
|
+
}
|
380
|
+
receipts {
|
381
|
+
...receiptFragment
|
382
|
+
}
|
383
|
+
}
|
384
|
+
${DryRunTransactionStatusFragmentFragmentDoc}
|
385
|
+
${ReceiptFragmentFragmentDoc}`;
|
335
386
|
var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
336
387
|
fragment coinFragment on Coin {
|
337
388
|
__typename
|
@@ -339,7 +390,6 @@ var CoinFragmentFragmentDoc = import_graphql_tag.default`
|
|
339
390
|
owner
|
340
391
|
amount
|
341
392
|
assetId
|
342
|
-
maturity
|
343
393
|
blockCreated
|
344
394
|
txCreatedIdx
|
345
395
|
}
|
@@ -378,26 +428,32 @@ var MessageProofFragmentFragmentDoc = import_graphql_tag.default`
|
|
378
428
|
messageBlockHeader {
|
379
429
|
id
|
380
430
|
daHeight
|
431
|
+
consensusParametersVersion
|
432
|
+
stateTransitionBytecodeVersion
|
381
433
|
transactionsCount
|
434
|
+
messageReceiptCount
|
382
435
|
transactionsRoot
|
436
|
+
messageOutboxRoot
|
437
|
+
eventInboxRoot
|
383
438
|
height
|
384
439
|
prevRoot
|
385
440
|
time
|
386
441
|
applicationHash
|
387
|
-
messageReceiptRoot
|
388
|
-
messageReceiptCount
|
389
442
|
}
|
390
443
|
commitBlockHeader {
|
391
444
|
id
|
392
445
|
daHeight
|
446
|
+
consensusParametersVersion
|
447
|
+
stateTransitionBytecodeVersion
|
393
448
|
transactionsCount
|
449
|
+
messageReceiptCount
|
394
450
|
transactionsRoot
|
451
|
+
messageOutboxRoot
|
452
|
+
eventInboxRoot
|
395
453
|
height
|
396
454
|
prevRoot
|
397
455
|
time
|
398
456
|
applicationHash
|
399
|
-
messageReceiptRoot
|
400
|
-
messageReceiptCount
|
401
457
|
}
|
402
458
|
sender
|
403
459
|
recipient
|
@@ -416,8 +472,8 @@ var BalanceFragmentFragmentDoc = import_graphql_tag.default`
|
|
416
472
|
var BlockFragmentFragmentDoc = import_graphql_tag.default`
|
417
473
|
fragment blockFragment on Block {
|
418
474
|
id
|
475
|
+
height
|
419
476
|
header {
|
420
|
-
height
|
421
477
|
time
|
422
478
|
}
|
423
479
|
transactions {
|
@@ -427,6 +483,7 @@ var BlockFragmentFragmentDoc = import_graphql_tag.default`
|
|
427
483
|
`;
|
428
484
|
var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
|
429
485
|
fragment TxParametersFragment on TxParameters {
|
486
|
+
version
|
430
487
|
maxInputs
|
431
488
|
maxOutputs
|
432
489
|
maxWitnesses
|
@@ -436,6 +493,7 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
436
493
|
`;
|
437
494
|
var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
|
438
495
|
fragment PredicateParametersFragment on PredicateParameters {
|
496
|
+
version
|
439
497
|
maxPredicateLength
|
440
498
|
maxPredicateDataLength
|
441
499
|
maxGasPerPredicate
|
@@ -444,18 +502,21 @@ var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
444
502
|
`;
|
445
503
|
var ScriptParametersFragmentFragmentDoc = import_graphql_tag.default`
|
446
504
|
fragment ScriptParametersFragment on ScriptParameters {
|
505
|
+
version
|
447
506
|
maxScriptLength
|
448
507
|
maxScriptDataLength
|
449
508
|
}
|
450
509
|
`;
|
451
510
|
var ContractParametersFragmentFragmentDoc = import_graphql_tag.default`
|
452
511
|
fragment ContractParametersFragment on ContractParameters {
|
512
|
+
version
|
453
513
|
contractMaxSize
|
454
514
|
maxStorageSlots
|
455
515
|
}
|
456
516
|
`;
|
457
517
|
var FeeParametersFragmentFragmentDoc = import_graphql_tag.default`
|
458
518
|
fragment FeeParametersFragment on FeeParameters {
|
519
|
+
version
|
459
520
|
gasPriceFactor
|
460
521
|
gasPerByte
|
461
522
|
}
|
@@ -475,6 +536,7 @@ var DependentCostFragmentFragmentDoc = import_graphql_tag.default`
|
|
475
536
|
`;
|
476
537
|
var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
477
538
|
fragment GasCostsFragment on GasCosts {
|
539
|
+
version
|
478
540
|
add
|
479
541
|
addi
|
480
542
|
aloc
|
@@ -487,7 +549,6 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
487
549
|
cb
|
488
550
|
cfei
|
489
551
|
cfsi
|
490
|
-
croo
|
491
552
|
div
|
492
553
|
divi
|
493
554
|
ecr1
|
@@ -570,6 +631,9 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
570
631
|
ccp {
|
571
632
|
...DependentCostFragment
|
572
633
|
}
|
634
|
+
croo {
|
635
|
+
...DependentCostFragment
|
636
|
+
}
|
573
637
|
csiz {
|
574
638
|
...DependentCostFragment
|
575
639
|
}
|
@@ -629,6 +693,7 @@ var GasCostsFragmentFragmentDoc = import_graphql_tag.default`
|
|
629
693
|
${DependentCostFragmentFragmentDoc}`;
|
630
694
|
var ConsensusParametersFragmentFragmentDoc = import_graphql_tag.default`
|
631
695
|
fragment consensusParametersFragment on ConsensusParameters {
|
696
|
+
version
|
632
697
|
txParams {
|
633
698
|
...TxParametersFragment
|
634
699
|
}
|
@@ -688,18 +753,9 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
688
753
|
fragment nodeInfoFragment on NodeInfo {
|
689
754
|
utxoValidation
|
690
755
|
vmBacktrace
|
691
|
-
minGasPrice
|
692
756
|
maxTx
|
693
757
|
maxDepth
|
694
758
|
nodeVersion
|
695
|
-
peers {
|
696
|
-
id
|
697
|
-
addresses
|
698
|
-
clientVersion
|
699
|
-
blockHeight
|
700
|
-
lastHeartbeatMs
|
701
|
-
appScore
|
702
|
-
}
|
703
759
|
}
|
704
760
|
`;
|
705
761
|
var GetVersionDocument = import_graphql_tag.default`
|
@@ -734,13 +790,9 @@ var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
|
|
734
790
|
query getTransactionWithReceipts($transactionId: TransactionId!) {
|
735
791
|
transaction(id: $transactionId) {
|
736
792
|
...transactionFragment
|
737
|
-
receipts {
|
738
|
-
...receiptFragment
|
739
|
-
}
|
740
793
|
}
|
741
794
|
}
|
742
|
-
${TransactionFragmentFragmentDoc}
|
743
|
-
${ReceiptFragmentFragmentDoc}`;
|
795
|
+
${TransactionFragmentFragmentDoc}`;
|
744
796
|
var GetTransactionsDocument = import_graphql_tag.default`
|
745
797
|
query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
|
746
798
|
transactions(after: $after, before: $before, first: $first, last: $last) {
|
@@ -868,6 +920,20 @@ var GetBalanceDocument = import_graphql_tag.default`
|
|
868
920
|
}
|
869
921
|
}
|
870
922
|
${BalanceFragmentFragmentDoc}`;
|
923
|
+
var GetLatestGasPriceDocument = import_graphql_tag.default`
|
924
|
+
query getLatestGasPrice {
|
925
|
+
latestGasPrice {
|
926
|
+
gasPrice
|
927
|
+
}
|
928
|
+
}
|
929
|
+
`;
|
930
|
+
var EstimateGasPriceDocument = import_graphql_tag.default`
|
931
|
+
query estimateGasPrice($blockHorizon: U32!) {
|
932
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
933
|
+
gasPrice
|
934
|
+
}
|
935
|
+
}
|
936
|
+
`;
|
871
937
|
var GetBalancesDocument = import_graphql_tag.default`
|
872
938
|
query getBalances($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
873
939
|
balances(
|
@@ -922,12 +988,12 @@ var GetMessageStatusDocument = import_graphql_tag.default`
|
|
922
988
|
}
|
923
989
|
`;
|
924
990
|
var DryRunDocument = import_graphql_tag.default`
|
925
|
-
mutation dryRun($
|
926
|
-
dryRun(
|
927
|
-
...
|
991
|
+
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
992
|
+
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
993
|
+
...dryRunTransactionExecutionStatusFragment
|
928
994
|
}
|
929
995
|
}
|
930
|
-
${
|
996
|
+
${DryRunTransactionExecutionStatusFragmentFragmentDoc}`;
|
931
997
|
var SubmitDocument = import_graphql_tag.default`
|
932
998
|
mutation submit($encodedTransaction: HexString!) {
|
933
999
|
submit(tx: $encodedTransaction) {
|
@@ -946,17 +1012,17 @@ var ProduceBlocksDocument = import_graphql_tag.default`
|
|
946
1012
|
var SubmitAndAwaitDocument = import_graphql_tag.default`
|
947
1013
|
subscription submitAndAwait($encodedTransaction: HexString!) {
|
948
1014
|
submitAndAwait(tx: $encodedTransaction) {
|
949
|
-
...
|
1015
|
+
...transactionStatusSubscriptionFragment
|
950
1016
|
}
|
951
1017
|
}
|
952
|
-
${
|
1018
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
953
1019
|
var StatusChangeDocument = import_graphql_tag.default`
|
954
1020
|
subscription statusChange($transactionId: TransactionId!) {
|
955
1021
|
statusChange(id: $transactionId) {
|
956
|
-
...
|
1022
|
+
...transactionStatusSubscriptionFragment
|
957
1023
|
}
|
958
1024
|
}
|
959
|
-
${
|
1025
|
+
${TransactionStatusSubscriptionFragmentFragmentDoc}`;
|
960
1026
|
function getSdk(requester) {
|
961
1027
|
return {
|
962
1028
|
getVersion(variables, options) {
|
@@ -1010,6 +1076,12 @@ function getSdk(requester) {
|
|
1010
1076
|
getBalance(variables, options) {
|
1011
1077
|
return requester(GetBalanceDocument, variables, options);
|
1012
1078
|
},
|
1079
|
+
getLatestGasPrice(variables, options) {
|
1080
|
+
return requester(GetLatestGasPriceDocument, variables, options);
|
1081
|
+
},
|
1082
|
+
estimateGasPrice(variables, options) {
|
1083
|
+
return requester(EstimateGasPriceDocument, variables, options);
|
1084
|
+
},
|
1013
1085
|
getBalances(variables, options) {
|
1014
1086
|
return requester(GetBalancesDocument, variables, options);
|
1015
1087
|
},
|
@@ -1203,10 +1275,9 @@ var inputify = (value) => {
|
|
1203
1275
|
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
1204
1276
|
},
|
1205
1277
|
witnessIndex: value.witnessIndex,
|
1206
|
-
maturity: value.maturity ?? 0,
|
1207
1278
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1208
|
-
predicateLength: predicate.length,
|
1209
|
-
predicateDataLength: predicateData.length,
|
1279
|
+
predicateLength: (0, import_math2.bn)(predicate.length),
|
1280
|
+
predicateDataLength: (0, import_math2.bn)(predicateData.length),
|
1210
1281
|
predicate: (0, import_utils3.hexlify)(predicate),
|
1211
1282
|
predicateData: (0, import_utils3.hexlify)(predicateData)
|
1212
1283
|
};
|
@@ -1237,8 +1308,8 @@ var inputify = (value) => {
|
|
1237
1308
|
nonce: (0, import_utils3.hexlify)(value.nonce),
|
1238
1309
|
witnessIndex: value.witnessIndex,
|
1239
1310
|
predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
|
1240
|
-
predicateLength: predicate.length,
|
1241
|
-
predicateDataLength: predicateData.length,
|
1311
|
+
predicateLength: (0, import_math2.bn)(predicate.length),
|
1312
|
+
predicateDataLength: (0, import_math2.bn)(predicateData.length),
|
1242
1313
|
predicate: (0, import_utils3.hexlify)(predicate),
|
1243
1314
|
predicateData: (0, import_utils3.hexlify)(predicateData),
|
1244
1315
|
data: (0, import_utils3.hexlify)(data),
|
@@ -1357,8 +1428,8 @@ function assembleReceiptByType(receipt) {
|
|
1357
1428
|
case "CALL" /* Call */: {
|
1358
1429
|
const callReceipt = {
|
1359
1430
|
type: import_transactions3.ReceiptType.Call,
|
1360
|
-
from: hexOrZero(receipt.
|
1361
|
-
to: hexOrZero(receipt?.to
|
1431
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1432
|
+
to: hexOrZero(receipt?.to),
|
1362
1433
|
amount: (0, import_math4.bn)(receipt.amount),
|
1363
1434
|
assetId: hexOrZero(receipt.assetId),
|
1364
1435
|
gas: (0, import_math4.bn)(receipt.gas),
|
@@ -1372,7 +1443,7 @@ function assembleReceiptByType(receipt) {
|
|
1372
1443
|
case "RETURN" /* Return */: {
|
1373
1444
|
const returnReceipt = {
|
1374
1445
|
type: import_transactions3.ReceiptType.Return,
|
1375
|
-
id: hexOrZero(receipt.
|
1446
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1376
1447
|
val: (0, import_math4.bn)(receipt.val),
|
1377
1448
|
pc: (0, import_math4.bn)(receipt.pc),
|
1378
1449
|
is: (0, import_math4.bn)(receipt.is)
|
@@ -1382,7 +1453,7 @@ function assembleReceiptByType(receipt) {
|
|
1382
1453
|
case "RETURN_DATA" /* ReturnData */: {
|
1383
1454
|
const returnDataReceipt = {
|
1384
1455
|
type: import_transactions3.ReceiptType.ReturnData,
|
1385
|
-
id: hexOrZero(receipt.
|
1456
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1386
1457
|
ptr: (0, import_math4.bn)(receipt.ptr),
|
1387
1458
|
len: (0, import_math4.bn)(receipt.len),
|
1388
1459
|
digest: hexOrZero(receipt.digest),
|
@@ -1394,7 +1465,7 @@ function assembleReceiptByType(receipt) {
|
|
1394
1465
|
case "PANIC" /* Panic */: {
|
1395
1466
|
const panicReceipt = {
|
1396
1467
|
type: import_transactions3.ReceiptType.Panic,
|
1397
|
-
id: hexOrZero(receipt.
|
1468
|
+
id: hexOrZero(receipt.id),
|
1398
1469
|
reason: (0, import_math4.bn)(receipt.reason),
|
1399
1470
|
pc: (0, import_math4.bn)(receipt.pc),
|
1400
1471
|
is: (0, import_math4.bn)(receipt.is),
|
@@ -1405,7 +1476,7 @@ function assembleReceiptByType(receipt) {
|
|
1405
1476
|
case "REVERT" /* Revert */: {
|
1406
1477
|
const revertReceipt = {
|
1407
1478
|
type: import_transactions3.ReceiptType.Revert,
|
1408
|
-
id: hexOrZero(receipt.
|
1479
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1409
1480
|
val: (0, import_math4.bn)(receipt.ra),
|
1410
1481
|
pc: (0, import_math4.bn)(receipt.pc),
|
1411
1482
|
is: (0, import_math4.bn)(receipt.is)
|
@@ -1415,7 +1486,7 @@ function assembleReceiptByType(receipt) {
|
|
1415
1486
|
case "LOG" /* Log */: {
|
1416
1487
|
const logReceipt = {
|
1417
1488
|
type: import_transactions3.ReceiptType.Log,
|
1418
|
-
id: hexOrZero(receipt.
|
1489
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1419
1490
|
val0: (0, import_math4.bn)(receipt.ra),
|
1420
1491
|
val1: (0, import_math4.bn)(receipt.rb),
|
1421
1492
|
val2: (0, import_math4.bn)(receipt.rc),
|
@@ -1428,7 +1499,7 @@ function assembleReceiptByType(receipt) {
|
|
1428
1499
|
case "LOG_DATA" /* LogData */: {
|
1429
1500
|
const logDataReceipt = {
|
1430
1501
|
type: import_transactions3.ReceiptType.LogData,
|
1431
|
-
id: hexOrZero(receipt.
|
1502
|
+
id: hexOrZero(receipt.id || receipt.contractId),
|
1432
1503
|
val0: (0, import_math4.bn)(receipt.ra),
|
1433
1504
|
val1: (0, import_math4.bn)(receipt.rb),
|
1434
1505
|
ptr: (0, import_math4.bn)(receipt.ptr),
|
@@ -1442,8 +1513,8 @@ function assembleReceiptByType(receipt) {
|
|
1442
1513
|
case "TRANSFER" /* Transfer */: {
|
1443
1514
|
const transferReceipt = {
|
1444
1515
|
type: import_transactions3.ReceiptType.Transfer,
|
1445
|
-
from: hexOrZero(receipt.
|
1446
|
-
to: hexOrZero(receipt.toAddress || receipt?.to
|
1516
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1517
|
+
to: hexOrZero(receipt.toAddress || receipt?.to),
|
1447
1518
|
amount: (0, import_math4.bn)(receipt.amount),
|
1448
1519
|
assetId: hexOrZero(receipt.assetId),
|
1449
1520
|
pc: (0, import_math4.bn)(receipt.pc),
|
@@ -1454,8 +1525,8 @@ function assembleReceiptByType(receipt) {
|
|
1454
1525
|
case "TRANSFER_OUT" /* TransferOut */: {
|
1455
1526
|
const transferOutReceipt = {
|
1456
1527
|
type: import_transactions3.ReceiptType.TransferOut,
|
1457
|
-
from: hexOrZero(receipt.
|
1458
|
-
to: hexOrZero(receipt.toAddress || receipt.to
|
1528
|
+
from: hexOrZero(receipt.id || receipt.contractId),
|
1529
|
+
to: hexOrZero(receipt.toAddress || receipt.to),
|
1459
1530
|
amount: (0, import_math4.bn)(receipt.amount),
|
1460
1531
|
assetId: hexOrZero(receipt.assetId),
|
1461
1532
|
pc: (0, import_math4.bn)(receipt.pc),
|
@@ -1498,7 +1569,7 @@ function assembleReceiptByType(receipt) {
|
|
1498
1569
|
return receiptMessageOut;
|
1499
1570
|
}
|
1500
1571
|
case "MINT" /* Mint */: {
|
1501
|
-
const contractId = hexOrZero(receipt.
|
1572
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1502
1573
|
const subId = hexOrZero(receipt.subId);
|
1503
1574
|
const assetId = import_transactions3.ReceiptMintCoder.getAssetId(contractId, subId);
|
1504
1575
|
const mintReceipt = {
|
@@ -1513,7 +1584,7 @@ function assembleReceiptByType(receipt) {
|
|
1513
1584
|
return mintReceipt;
|
1514
1585
|
}
|
1515
1586
|
case "BURN" /* Burn */: {
|
1516
|
-
const contractId = hexOrZero(receipt.
|
1587
|
+
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1517
1588
|
const subId = hexOrZero(receipt.subId);
|
1518
1589
|
const assetId = import_transactions3.ReceiptBurnCoder.getAssetId(contractId, subId);
|
1519
1590
|
const burnReceipt = {
|
@@ -1598,7 +1669,6 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
1598
1669
|
var import_math5 = require("@fuel-ts/math");
|
1599
1670
|
var import_transactions4 = require("@fuel-ts/transactions");
|
1600
1671
|
var import_utils6 = require("@fuel-ts/utils");
|
1601
|
-
var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
|
1602
1672
|
var getGasUsedFromReceipts = (receipts) => {
|
1603
1673
|
const scriptResult = receipts.filter(
|
1604
1674
|
(receipt) => receipt.type === import_transactions4.ReceiptType.ScriptResult
|
@@ -1619,18 +1689,28 @@ function resolveGasDependentCosts(byteSize, gasDependentCost) {
|
|
1619
1689
|
}
|
1620
1690
|
function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
|
1621
1691
|
const witnessCache = [];
|
1622
|
-
const
|
1692
|
+
const chargeableInputs = inputs.filter((input) => {
|
1693
|
+
const isCoinOrMessage = "owner" in input || "sender" in input;
|
1694
|
+
if (isCoinOrMessage) {
|
1695
|
+
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1696
|
+
return true;
|
1697
|
+
}
|
1698
|
+
if (!witnessCache.includes(input.witnessIndex)) {
|
1699
|
+
witnessCache.push(input.witnessIndex);
|
1700
|
+
return true;
|
1701
|
+
}
|
1702
|
+
}
|
1703
|
+
return false;
|
1704
|
+
});
|
1705
|
+
const vmInitializationCost = resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization);
|
1706
|
+
const totalGas = chargeableInputs.reduce((total, input) => {
|
1623
1707
|
if ("predicate" in input && input.predicate && input.predicate !== "0x") {
|
1624
1708
|
return total.add(
|
1625
|
-
|
1709
|
+
vmInitializationCost.add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
|
1626
1710
|
);
|
1627
1711
|
}
|
1628
|
-
|
1629
|
-
|
1630
|
-
return total.add(gasCosts.ecr1);
|
1631
|
-
}
|
1632
|
-
return total;
|
1633
|
-
}, (0, import_math5.bn)());
|
1712
|
+
return total.add(gasCosts.ecr1);
|
1713
|
+
}, (0, import_math5.bn)(0));
|
1634
1714
|
return totalGas;
|
1635
1715
|
}
|
1636
1716
|
function getMinGas(params) {
|
@@ -1642,12 +1722,20 @@ function getMinGas(params) {
|
|
1642
1722
|
return minGas;
|
1643
1723
|
}
|
1644
1724
|
function getMaxGas(params) {
|
1645
|
-
const {
|
1725
|
+
const {
|
1726
|
+
gasPerByte,
|
1727
|
+
witnessesLength,
|
1728
|
+
witnessLimit,
|
1729
|
+
minGas,
|
1730
|
+
gasLimit = (0, import_math5.bn)(0),
|
1731
|
+
maxGasPerTx
|
1732
|
+
} = params;
|
1646
1733
|
let remainingAllowedWitnessGas = (0, import_math5.bn)(0);
|
1647
1734
|
if (witnessLimit?.gt(0) && witnessLimit.gte(witnessesLength)) {
|
1648
1735
|
remainingAllowedWitnessGas = (0, import_math5.bn)(witnessLimit).sub(witnessesLength).mul(gasPerByte);
|
1649
1736
|
}
|
1650
|
-
|
1737
|
+
const maxGas = remainingAllowedWitnessGas.add(minGas).add(gasLimit);
|
1738
|
+
return maxGas.gte(maxGasPerTx) ? maxGasPerTx : maxGas;
|
1651
1739
|
}
|
1652
1740
|
function calculateMetadataGasForTxCreate({
|
1653
1741
|
gasCosts,
|
@@ -1669,6 +1757,10 @@ function calculateMetadataGasForTxScript({
|
|
1669
1757
|
}) {
|
1670
1758
|
return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1671
1759
|
}
|
1760
|
+
var calculateGasFee = (params) => {
|
1761
|
+
const { gas, gasPrice, priceFactor, tip } = params;
|
1762
|
+
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1763
|
+
};
|
1672
1764
|
|
1673
1765
|
// src/providers/utils/json.ts
|
1674
1766
|
var import_utils7 = require("@fuel-ts/utils");
|
@@ -1817,7 +1909,7 @@ var witnessify = (value) => {
|
|
1817
1909
|
// src/providers/transaction-request/transaction-request.ts
|
1818
1910
|
var BaseTransactionRequest = class {
|
1819
1911
|
/** Gas price for transaction */
|
1820
|
-
|
1912
|
+
tip;
|
1821
1913
|
/** Block until which tx cannot be included */
|
1822
1914
|
maturity;
|
1823
1915
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
@@ -1836,7 +1928,7 @@ var BaseTransactionRequest = class {
|
|
1836
1928
|
* @param baseTransactionRequest - Optional object containing properties to initialize the transaction request.
|
1837
1929
|
*/
|
1838
1930
|
constructor({
|
1839
|
-
|
1931
|
+
tip,
|
1840
1932
|
maturity,
|
1841
1933
|
maxFee,
|
1842
1934
|
witnessLimit,
|
@@ -1844,7 +1936,7 @@ var BaseTransactionRequest = class {
|
|
1844
1936
|
outputs,
|
1845
1937
|
witnesses
|
1846
1938
|
} = {}) {
|
1847
|
-
this.
|
1939
|
+
this.tip = (0, import_math7.bn)(tip);
|
1848
1940
|
this.maturity = maturity ?? 0;
|
1849
1941
|
this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
|
1850
1942
|
this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
|
@@ -1855,9 +1947,9 @@ var BaseTransactionRequest = class {
|
|
1855
1947
|
static getPolicyMeta(req) {
|
1856
1948
|
let policyTypes = 0;
|
1857
1949
|
const policies = [];
|
1858
|
-
if (req.
|
1859
|
-
policyTypes += import_transactions6.PolicyType.
|
1860
|
-
policies.push({ data: req.
|
1950
|
+
if (req.tip) {
|
1951
|
+
policyTypes += import_transactions6.PolicyType.Tip;
|
1952
|
+
policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
|
1861
1953
|
}
|
1862
1954
|
if (req.witnessLimit) {
|
1863
1955
|
policyTypes += import_transactions6.PolicyType.WitnessLimit;
|
@@ -2041,13 +2133,11 @@ var BaseTransactionRequest = class {
|
|
2041
2133
|
* assetId, if one it was not added yet.
|
2042
2134
|
*
|
2043
2135
|
* @param coin - Coin resource.
|
2044
|
-
* @param predicate - Predicate bytes.
|
2045
|
-
* @param predicateData - Predicate data bytes.
|
2046
2136
|
*/
|
2047
|
-
addCoinInput(coin
|
2137
|
+
addCoinInput(coin) {
|
2048
2138
|
const { assetId, owner, amount } = coin;
|
2049
2139
|
let witnessIndex;
|
2050
|
-
if (predicate) {
|
2140
|
+
if (coin.predicate) {
|
2051
2141
|
witnessIndex = 0;
|
2052
2142
|
} else {
|
2053
2143
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
|
@@ -2062,8 +2152,7 @@ var BaseTransactionRequest = class {
|
|
2062
2152
|
amount,
|
2063
2153
|
assetId,
|
2064
2154
|
txPointer: "0x00000000000000000000000000000000",
|
2065
|
-
witnessIndex
|
2066
|
-
predicate: predicate?.bytes
|
2155
|
+
witnessIndex
|
2067
2156
|
};
|
2068
2157
|
this.pushInput(input);
|
2069
2158
|
this.addChangeOutput(owner, assetId);
|
@@ -2073,12 +2162,11 @@ var BaseTransactionRequest = class {
|
|
2073
2162
|
* asset against the message
|
2074
2163
|
*
|
2075
2164
|
* @param message - Message resource.
|
2076
|
-
* @param predicate - Predicate bytes.
|
2077
2165
|
*/
|
2078
|
-
addMessageInput(message
|
2166
|
+
addMessageInput(message) {
|
2079
2167
|
const { recipient, sender, amount, assetId } = message;
|
2080
2168
|
let witnessIndex;
|
2081
|
-
if (predicate) {
|
2169
|
+
if (message.predicate) {
|
2082
2170
|
witnessIndex = 0;
|
2083
2171
|
} else {
|
2084
2172
|
witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
|
@@ -2092,8 +2180,7 @@ var BaseTransactionRequest = class {
|
|
2092
2180
|
sender: sender.toB256(),
|
2093
2181
|
recipient: recipient.toB256(),
|
2094
2182
|
amount,
|
2095
|
-
witnessIndex
|
2096
|
-
predicate: predicate?.bytes
|
2183
|
+
witnessIndex
|
2097
2184
|
};
|
2098
2185
|
this.pushInput(input);
|
2099
2186
|
this.addChangeOutput(recipient, assetId);
|
@@ -2124,32 +2211,6 @@ var BaseTransactionRequest = class {
|
|
2124
2211
|
resources.forEach((resource) => this.addResource(resource));
|
2125
2212
|
return this;
|
2126
2213
|
}
|
2127
|
-
/**
|
2128
|
-
* Adds multiple resources to the transaction by adding coin/message inputs and change
|
2129
|
-
* outputs from the related assetIds.
|
2130
|
-
*
|
2131
|
-
* @param resources - The resources to add.
|
2132
|
-
* @returns This transaction.
|
2133
|
-
*/
|
2134
|
-
addPredicateResource(resource, predicate) {
|
2135
|
-
if (isCoin(resource)) {
|
2136
|
-
this.addCoinInput(resource, predicate);
|
2137
|
-
} else {
|
2138
|
-
this.addMessageInput(resource, predicate);
|
2139
|
-
}
|
2140
|
-
return this;
|
2141
|
-
}
|
2142
|
-
/**
|
2143
|
-
* Adds multiple predicate coin/message inputs to the transaction and change outputs
|
2144
|
-
* from the related assetIds.
|
2145
|
-
*
|
2146
|
-
* @param resources - The resources to add.
|
2147
|
-
* @returns This transaction.
|
2148
|
-
*/
|
2149
|
-
addPredicateResources(resources, predicate) {
|
2150
|
-
resources.forEach((resource) => this.addPredicateResource(resource, predicate));
|
2151
|
-
return this;
|
2152
|
-
}
|
2153
2214
|
/**
|
2154
2215
|
* Adds a coin output to the transaction.
|
2155
2216
|
*
|
@@ -2229,7 +2290,7 @@ var BaseTransactionRequest = class {
|
|
2229
2290
|
}
|
2230
2291
|
calculateMaxGas(chainInfo, minGas) {
|
2231
2292
|
const { consensusParameters } = chainInfo;
|
2232
|
-
const { gasPerByte } = consensusParameters;
|
2293
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2233
2294
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2234
2295
|
(acc, wit) => acc + wit.dataLength,
|
2235
2296
|
0
|
@@ -2238,7 +2299,8 @@ var BaseTransactionRequest = class {
|
|
2238
2299
|
gasPerByte,
|
2239
2300
|
minGas,
|
2240
2301
|
witnessesLength,
|
2241
|
-
witnessLimit: this.witnessLimit
|
2302
|
+
witnessLimit: this.witnessLimit,
|
2303
|
+
maxGasPerTx
|
2242
2304
|
});
|
2243
2305
|
}
|
2244
2306
|
/**
|
@@ -2257,17 +2319,20 @@ var BaseTransactionRequest = class {
|
|
2257
2319
|
});
|
2258
2320
|
const updateAssetInput = (assetId, quantity) => {
|
2259
2321
|
const assetInput = findAssetInput(assetId);
|
2322
|
+
let usedQuantity = quantity;
|
2323
|
+
if (assetId === baseAssetId) {
|
2324
|
+
usedQuantity = (0, import_math7.bn)("1000000000000000000");
|
2325
|
+
}
|
2260
2326
|
if (assetInput && "assetId" in assetInput) {
|
2261
2327
|
assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
|
2262
|
-
assetInput.amount =
|
2328
|
+
assetInput.amount = usedQuantity;
|
2263
2329
|
} else {
|
2264
2330
|
this.addResources([
|
2265
2331
|
{
|
2266
2332
|
id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
|
2267
|
-
amount:
|
2333
|
+
amount: usedQuantity,
|
2268
2334
|
assetId,
|
2269
2335
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2270
|
-
maturity: 0,
|
2271
2336
|
blockCreated: (0, import_math7.bn)(1),
|
2272
2337
|
txCreatedIdx: (0, import_math7.bn)(1)
|
2273
2338
|
}
|
@@ -2299,7 +2364,7 @@ var BaseTransactionRequest = class {
|
|
2299
2364
|
toJSON() {
|
2300
2365
|
return normalizeJSON(this);
|
2301
2366
|
}
|
2302
|
-
|
2367
|
+
updatePredicateGasUsed(inputs) {
|
2303
2368
|
this.inputs.forEach((i) => {
|
2304
2369
|
let correspondingInput;
|
2305
2370
|
switch (i.type) {
|
@@ -2321,6 +2386,15 @@ var BaseTransactionRequest = class {
|
|
2321
2386
|
}
|
2322
2387
|
});
|
2323
2388
|
}
|
2389
|
+
shiftPredicateData() {
|
2390
|
+
this.inputs.forEach((input) => {
|
2391
|
+
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2392
|
+
input.predicateData = input.padPredicateData(
|
2393
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2394
|
+
);
|
2395
|
+
}
|
2396
|
+
});
|
2397
|
+
}
|
2324
2398
|
};
|
2325
2399
|
|
2326
2400
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2462,9 +2536,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2462
2536
|
return {
|
2463
2537
|
type: import_transactions8.TransactionType.Create,
|
2464
2538
|
...baseTransaction,
|
2465
|
-
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2466
2539
|
bytecodeWitnessIndex,
|
2467
|
-
storageSlotsCount: storageSlots.length,
|
2540
|
+
storageSlotsCount: (0, import_math9.bn)(storageSlots.length),
|
2468
2541
|
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2469
2542
|
storageSlots
|
2470
2543
|
};
|
@@ -2587,8 +2660,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2587
2660
|
type: import_transactions9.TransactionType.Script,
|
2588
2661
|
scriptGasLimit: this.gasLimit,
|
2589
2662
|
...super.getBaseTransaction(),
|
2590
|
-
scriptLength: script.length,
|
2591
|
-
scriptDataLength: scriptData.length,
|
2663
|
+
scriptLength: (0, import_math10.bn)(script.length),
|
2664
|
+
scriptDataLength: (0, import_math10.bn)(scriptData.length),
|
2592
2665
|
receiptsRoot: import_configs9.ZeroBytes32,
|
2593
2666
|
script: (0, import_utils15.hexlify)(script),
|
2594
2667
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
@@ -2652,7 +2725,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2652
2725
|
}
|
2653
2726
|
calculateMaxGas(chainInfo, minGas) {
|
2654
2727
|
const { consensusParameters } = chainInfo;
|
2655
|
-
const { gasPerByte } = consensusParameters;
|
2728
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2656
2729
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2657
2730
|
(acc, wit) => acc + wit.dataLength,
|
2658
2731
|
0
|
@@ -2662,7 +2735,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2662
2735
|
minGas,
|
2663
2736
|
witnessesLength,
|
2664
2737
|
witnessLimit: this.witnessLimit,
|
2665
|
-
gasLimit: this.gasLimit
|
2738
|
+
gasLimit: this.gasLimit,
|
2739
|
+
maxGasPerTx
|
2666
2740
|
});
|
2667
2741
|
}
|
2668
2742
|
/**
|
@@ -2737,15 +2811,32 @@ var transactionRequestify = (obj) => {
|
|
2737
2811
|
}
|
2738
2812
|
}
|
2739
2813
|
};
|
2814
|
+
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2815
|
+
(acc, input) => {
|
2816
|
+
if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
|
2817
|
+
acc.utxos.push(input.id);
|
2818
|
+
}
|
2819
|
+
if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
|
2820
|
+
acc.messages.push(input.nonce);
|
2821
|
+
}
|
2822
|
+
return acc;
|
2823
|
+
},
|
2824
|
+
{
|
2825
|
+
utxos: [],
|
2826
|
+
messages: []
|
2827
|
+
}
|
2828
|
+
);
|
2740
2829
|
|
2741
2830
|
// src/providers/transaction-response/transaction-response.ts
|
2742
2831
|
var import_errors13 = require("@fuel-ts/errors");
|
2743
|
-
var
|
2744
|
-
var
|
2745
|
-
var
|
2832
|
+
var import_math15 = require("@fuel-ts/math");
|
2833
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
2834
|
+
var import_utils20 = require("@fuel-ts/utils");
|
2746
2835
|
|
2747
2836
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2748
|
-
var
|
2837
|
+
var import_math14 = require("@fuel-ts/math");
|
2838
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
2839
|
+
var import_utils18 = require("@fuel-ts/utils");
|
2749
2840
|
|
2750
2841
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2751
2842
|
var import_math11 = require("@fuel-ts/math");
|
@@ -2753,9 +2844,10 @@ var import_transactions11 = require("@fuel-ts/transactions");
|
|
2753
2844
|
var import_utils16 = require("@fuel-ts/utils");
|
2754
2845
|
var calculateTransactionFee = (params) => {
|
2755
2846
|
const {
|
2756
|
-
|
2847
|
+
gasPrice,
|
2757
2848
|
rawPayload,
|
2758
|
-
|
2849
|
+
tip,
|
2850
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2759
2851
|
} = params;
|
2760
2852
|
const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
|
2761
2853
|
const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
|
@@ -2765,8 +2857,7 @@ var calculateTransactionFee = (params) => {
|
|
2765
2857
|
return {
|
2766
2858
|
fee: (0, import_math11.bn)(0),
|
2767
2859
|
minFee: (0, import_math11.bn)(0),
|
2768
|
-
maxFee: (0, import_math11.bn)(0)
|
2769
|
-
feeFromGasUsed: (0, import_math11.bn)(0)
|
2860
|
+
maxFee: (0, import_math11.bn)(0)
|
2770
2861
|
};
|
2771
2862
|
}
|
2772
2863
|
const { type, witnesses, inputs, policies } = transaction;
|
@@ -2798,7 +2889,6 @@ var calculateTransactionFee = (params) => {
|
|
2798
2889
|
metadataGas,
|
2799
2890
|
txBytesSize: transactionBytes.length
|
2800
2891
|
});
|
2801
|
-
const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
|
2802
2892
|
const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
|
2803
2893
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2804
2894
|
const maxGas = getMaxGas({
|
@@ -2806,17 +2896,25 @@ var calculateTransactionFee = (params) => {
|
|
2806
2896
|
minGas,
|
2807
2897
|
witnessesLength,
|
2808
2898
|
gasLimit,
|
2809
|
-
witnessLimit
|
2899
|
+
witnessLimit,
|
2900
|
+
maxGasPerTx
|
2901
|
+
});
|
2902
|
+
const minFee = calculateGasFee({
|
2903
|
+
gasPrice,
|
2904
|
+
gas: minGas,
|
2905
|
+
priceFactor: gasPriceFactor,
|
2906
|
+
tip
|
2907
|
+
});
|
2908
|
+
const maxFee = calculateGasFee({
|
2909
|
+
gasPrice,
|
2910
|
+
gas: maxGas,
|
2911
|
+
priceFactor: gasPriceFactor,
|
2912
|
+
tip
|
2810
2913
|
});
|
2811
|
-
const feeFromGasUsed = calculatePriceWithFactor(gasUsed, gasPrice, gasPriceFactor);
|
2812
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor);
|
2813
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor);
|
2814
|
-
const fee = minFee.add(feeFromGasUsed);
|
2815
2914
|
return {
|
2816
|
-
fee,
|
2817
2915
|
minFee,
|
2818
2916
|
maxFee,
|
2819
|
-
|
2917
|
+
fee: maxFee
|
2820
2918
|
};
|
2821
2919
|
};
|
2822
2920
|
|
@@ -3430,10 +3528,12 @@ function assembleTransactionSummary(params) {
|
|
3430
3528
|
gqlTransactionStatus,
|
3431
3529
|
abiMap = {},
|
3432
3530
|
maxInputs,
|
3433
|
-
gasCosts
|
3531
|
+
gasCosts,
|
3532
|
+
maxGasPerTx,
|
3533
|
+
gasPrice
|
3434
3534
|
} = params;
|
3435
3535
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3436
|
-
const rawPayload = (0,
|
3536
|
+
const rawPayload = (0, import_utils18.hexlify)(transactionBytes);
|
3437
3537
|
const operations = getOperations({
|
3438
3538
|
transactionType: transaction.type,
|
3439
3539
|
inputs: transaction.inputs || [],
|
@@ -3444,11 +3544,14 @@ function assembleTransactionSummary(params) {
|
|
3444
3544
|
maxInputs
|
3445
3545
|
});
|
3446
3546
|
const typeName = getTransactionTypeName(transaction.type);
|
3547
|
+
const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
|
3447
3548
|
const { fee } = calculateTransactionFee({
|
3448
|
-
|
3549
|
+
gasPrice,
|
3449
3550
|
rawPayload,
|
3551
|
+
tip,
|
3450
3552
|
consensusParameters: {
|
3451
3553
|
gasCosts,
|
3554
|
+
maxGasPerTx,
|
3452
3555
|
feeParams: {
|
3453
3556
|
gasPerByte,
|
3454
3557
|
gasPriceFactor
|
@@ -3460,7 +3563,7 @@ function assembleTransactionSummary(params) {
|
|
3460
3563
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3461
3564
|
let date;
|
3462
3565
|
if (time) {
|
3463
|
-
date =
|
3566
|
+
date = import_utils18.DateTime.fromTai64(time);
|
3464
3567
|
}
|
3465
3568
|
const transactionSummary = {
|
3466
3569
|
id,
|
@@ -3488,12 +3591,12 @@ function assembleTransactionSummary(params) {
|
|
3488
3591
|
|
3489
3592
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3490
3593
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
3491
|
-
var
|
3594
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
3492
3595
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3493
3596
|
return receipts.reduce((logs, receipt) => {
|
3494
|
-
if (receipt.type ===
|
3597
|
+
if (receipt.type === import_transactions17.ReceiptType.LogData || receipt.type === import_transactions17.ReceiptType.Log) {
|
3495
3598
|
const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
|
3496
|
-
const data = receipt.type ===
|
3599
|
+
const data = receipt.type === import_transactions17.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3497
3600
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3498
3601
|
logs.push(decodedLog);
|
3499
3602
|
}
|
@@ -3508,7 +3611,7 @@ var TransactionResponse = class {
|
|
3508
3611
|
/** Current provider */
|
3509
3612
|
provider;
|
3510
3613
|
/** Gas used on the transaction */
|
3511
|
-
gasUsed = (0,
|
3614
|
+
gasUsed = (0, import_math15.bn)(0);
|
3512
3615
|
/** The graphql Transaction with receipts object. */
|
3513
3616
|
gqlTransaction;
|
3514
3617
|
abis;
|
@@ -3566,8 +3669,8 @@ var TransactionResponse = class {
|
|
3566
3669
|
* @returns The decoded transaction.
|
3567
3670
|
*/
|
3568
3671
|
decodeTransaction(transactionWithReceipts) {
|
3569
|
-
return new
|
3570
|
-
(0,
|
3672
|
+
return new import_transactions18.TransactionCoder().decode(
|
3673
|
+
(0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
|
3571
3674
|
0
|
3572
3675
|
)?.[0];
|
3573
3676
|
}
|
@@ -3586,20 +3689,27 @@ var TransactionResponse = class {
|
|
3586
3689
|
const decodedTransaction = this.decodeTransaction(
|
3587
3690
|
transaction
|
3588
3691
|
);
|
3589
|
-
|
3590
|
-
|
3692
|
+
let txReceipts = [];
|
3693
|
+
if (transaction?.status && "receipts" in transaction.status) {
|
3694
|
+
txReceipts = transaction.status.receipts;
|
3695
|
+
}
|
3696
|
+
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3697
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3698
|
+
const gasPrice = await this.provider.getLatestGasPrice();
|
3591
3699
|
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3592
3700
|
const transactionSummary = assembleTransactionSummary({
|
3593
3701
|
id: this.id,
|
3594
3702
|
receipts,
|
3595
3703
|
transaction: decodedTransaction,
|
3596
|
-
transactionBytes: (0,
|
3704
|
+
transactionBytes: (0, import_utils20.arrayify)(transaction.rawPayload),
|
3597
3705
|
gqlTransactionStatus: transaction.status,
|
3598
3706
|
gasPerByte,
|
3599
3707
|
gasPriceFactor,
|
3600
3708
|
abiMap: contractsAbiMap,
|
3601
3709
|
maxInputs,
|
3602
|
-
gasCosts
|
3710
|
+
gasCosts,
|
3711
|
+
maxGasPerTx,
|
3712
|
+
gasPrice
|
3603
3713
|
});
|
3604
3714
|
return transactionSummary;
|
3605
3715
|
}
|
@@ -3725,30 +3835,30 @@ var processGqlChain = (chain) => {
|
|
3725
3835
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3726
3836
|
return {
|
3727
3837
|
name,
|
3728
|
-
baseChainHeight: (0,
|
3838
|
+
baseChainHeight: (0, import_math16.bn)(daHeight),
|
3729
3839
|
consensusParameters: {
|
3730
|
-
contractMaxSize: (0,
|
3731
|
-
maxInputs: (0,
|
3732
|
-
maxOutputs: (0,
|
3733
|
-
maxWitnesses: (0,
|
3734
|
-
maxGasPerTx: (0,
|
3735
|
-
maxScriptLength: (0,
|
3736
|
-
maxScriptDataLength: (0,
|
3737
|
-
maxStorageSlots: (0,
|
3738
|
-
maxPredicateLength: (0,
|
3739
|
-
maxPredicateDataLength: (0,
|
3740
|
-
maxGasPerPredicate: (0,
|
3741
|
-
gasPriceFactor: (0,
|
3742
|
-
gasPerByte: (0,
|
3743
|
-
maxMessageDataLength: (0,
|
3744
|
-
chainId: (0,
|
3840
|
+
contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
|
3841
|
+
maxInputs: (0, import_math16.bn)(txParams.maxInputs),
|
3842
|
+
maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
|
3843
|
+
maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
|
3844
|
+
maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
|
3845
|
+
maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
|
3846
|
+
maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
|
3847
|
+
maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
|
3848
|
+
maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
|
3849
|
+
maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
|
3850
|
+
maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
|
3851
|
+
gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
|
3852
|
+
gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
|
3853
|
+
maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
|
3854
|
+
chainId: (0, import_math16.bn)(consensusParameters.chainId),
|
3745
3855
|
baseAssetId: consensusParameters.baseAssetId,
|
3746
3856
|
gasCosts
|
3747
3857
|
},
|
3748
3858
|
gasCosts,
|
3749
3859
|
latestBlock: {
|
3750
3860
|
id: latestBlock.id,
|
3751
|
-
height: (0,
|
3861
|
+
height: (0, import_math16.bn)(latestBlock.height),
|
3752
3862
|
time: latestBlock.header.time,
|
3753
3863
|
transactions: latestBlock.transactions.map((i) => ({
|
3754
3864
|
id: i.id
|
@@ -3842,10 +3952,8 @@ var _Provider = class {
|
|
3842
3952
|
* Returns some helpful parameters related to gas fees.
|
3843
3953
|
*/
|
3844
3954
|
getGasConfig() {
|
3845
|
-
const { minGasPrice } = this.getNode();
|
3846
3955
|
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3847
3956
|
return {
|
3848
|
-
minGasPrice,
|
3849
3957
|
maxGasPerTx,
|
3850
3958
|
maxGasPerPredicate,
|
3851
3959
|
gasPriceFactor,
|
@@ -3921,6 +4029,21 @@ var _Provider = class {
|
|
3921
4029
|
} = await this.operations.getVersion();
|
3922
4030
|
return nodeVersion;
|
3923
4031
|
}
|
4032
|
+
/**
|
4033
|
+
* @hidden
|
4034
|
+
*
|
4035
|
+
* Returns the network configuration of the connected Fuel node.
|
4036
|
+
*
|
4037
|
+
* @returns A promise that resolves to the network configuration object
|
4038
|
+
*/
|
4039
|
+
async getNetwork() {
|
4040
|
+
const {
|
4041
|
+
name,
|
4042
|
+
consensusParameters: { chainId }
|
4043
|
+
} = await this.getChain();
|
4044
|
+
const network = new import_ethers.Network(name, chainId.toNumber());
|
4045
|
+
return Promise.resolve(network);
|
4046
|
+
}
|
3924
4047
|
/**
|
3925
4048
|
* Returns the block number.
|
3926
4049
|
*
|
@@ -3928,7 +4051,7 @@ var _Provider = class {
|
|
3928
4051
|
*/
|
3929
4052
|
async getBlockNumber() {
|
3930
4053
|
const { chain } = await this.operations.getChain();
|
3931
|
-
return (0,
|
4054
|
+
return (0, import_math16.bn)(chain.latestBlock.height, 10);
|
3932
4055
|
}
|
3933
4056
|
/**
|
3934
4057
|
* Returns the chain information.
|
@@ -3938,13 +4061,11 @@ var _Provider = class {
|
|
3938
4061
|
async fetchNode() {
|
3939
4062
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3940
4063
|
const processedNodeInfo = {
|
3941
|
-
maxDepth: (0,
|
3942
|
-
maxTx: (0,
|
3943
|
-
minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
|
4064
|
+
maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
|
4065
|
+
maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
|
3944
4066
|
nodeVersion: nodeInfo.nodeVersion,
|
3945
4067
|
utxoValidation: nodeInfo.utxoValidation,
|
3946
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
3947
|
-
peers: nodeInfo.peers
|
4068
|
+
vmBacktrace: nodeInfo.vmBacktrace
|
3948
4069
|
};
|
3949
4070
|
_Provider.nodeInfoCache[this.url] = processedNodeInfo;
|
3950
4071
|
return processedNodeInfo;
|
@@ -3997,9 +4118,9 @@ var _Provider = class {
|
|
3997
4118
|
if (estimateTxDependencies) {
|
3998
4119
|
await this.estimateTxDependencies(transactionRequest);
|
3999
4120
|
}
|
4000
|
-
const encodedTransaction = (0,
|
4121
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4001
4122
|
let abis;
|
4002
|
-
if (transactionRequest.type ===
|
4123
|
+
if (transactionRequest.type === import_transactions19.TransactionType.Script) {
|
4003
4124
|
abis = transactionRequest.abis;
|
4004
4125
|
}
|
4005
4126
|
if (awaitExecution) {
|
@@ -4040,15 +4161,14 @@ var _Provider = class {
|
|
4040
4161
|
if (estimateTxDependencies) {
|
4041
4162
|
return this.estimateTxDependencies(transactionRequest);
|
4042
4163
|
}
|
4043
|
-
const encodedTransaction = (0,
|
4044
|
-
const { dryRun:
|
4045
|
-
encodedTransaction,
|
4164
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4165
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4166
|
+
encodedTransactions: encodedTransaction,
|
4046
4167
|
utxoValidation: utxoValidation || false
|
4047
4168
|
});
|
4048
|
-
const receipts =
|
4049
|
-
|
4050
|
-
|
4051
|
-
};
|
4169
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4170
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4171
|
+
return { receipts, dryrunStatus: status };
|
4052
4172
|
}
|
4053
4173
|
/**
|
4054
4174
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -4059,13 +4179,13 @@ var _Provider = class {
|
|
4059
4179
|
async estimatePredicates(transactionRequest) {
|
4060
4180
|
const shouldEstimatePredicates = Boolean(
|
4061
4181
|
transactionRequest.inputs.find(
|
4062
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4182
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math16.BN(input.predicateGasUsed).isZero()
|
4063
4183
|
)
|
4064
4184
|
);
|
4065
4185
|
if (!shouldEstimatePredicates) {
|
4066
4186
|
return transactionRequest;
|
4067
4187
|
}
|
4068
|
-
const encodedTransaction = (0,
|
4188
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4069
4189
|
const response = await this.operations.estimatePredicates({
|
4070
4190
|
encodedTransaction
|
4071
4191
|
});
|
@@ -4074,7 +4194,7 @@ var _Provider = class {
|
|
4074
4194
|
} = response;
|
4075
4195
|
if (inputs) {
|
4076
4196
|
inputs.forEach((input, index) => {
|
4077
|
-
if ("predicateGasUsed" in input && (0,
|
4197
|
+
if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
|
4078
4198
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4079
4199
|
}
|
4080
4200
|
});
|
@@ -4087,31 +4207,31 @@ var _Provider = class {
|
|
4087
4207
|
* If there are missing variable outputs,
|
4088
4208
|
* `addVariableOutputs` is called on the transaction.
|
4089
4209
|
*
|
4090
|
-
* @privateRemarks
|
4091
|
-
* TODO: Investigate support for missing contract IDs
|
4092
|
-
* TODO: Add support for missing output messages
|
4093
4210
|
*
|
4094
4211
|
* @param transactionRequest - The transaction request object.
|
4095
4212
|
* @returns A promise.
|
4096
4213
|
*/
|
4097
4214
|
async estimateTxDependencies(transactionRequest) {
|
4098
|
-
if (transactionRequest.type ===
|
4215
|
+
if (transactionRequest.type === import_transactions19.TransactionType.Create) {
|
4099
4216
|
return {
|
4100
4217
|
receipts: [],
|
4101
4218
|
outputVariables: 0,
|
4102
4219
|
missingContractIds: []
|
4103
4220
|
};
|
4104
4221
|
}
|
4105
|
-
await this.estimatePredicates(transactionRequest);
|
4106
4222
|
let receipts = [];
|
4107
4223
|
const missingContractIds = [];
|
4108
4224
|
let outputVariables = 0;
|
4225
|
+
let dryrunStatus;
|
4109
4226
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4110
|
-
const {
|
4111
|
-
|
4227
|
+
const {
|
4228
|
+
dryRun: [{ receipts: rawReceipts, status }]
|
4229
|
+
} = await this.operations.dryRun({
|
4230
|
+
encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
|
4112
4231
|
utxoValidation: false
|
4113
4232
|
});
|
4114
|
-
receipts =
|
4233
|
+
receipts = rawReceipts.map(processGqlReceipt);
|
4234
|
+
dryrunStatus = status;
|
4115
4235
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
4116
4236
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
4117
4237
|
if (hasMissingOutputs) {
|
@@ -4121,6 +4241,10 @@ var _Provider = class {
|
|
4121
4241
|
transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
|
4122
4242
|
missingContractIds.push(contractId);
|
4123
4243
|
});
|
4244
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4245
|
+
transactionRequest
|
4246
|
+
});
|
4247
|
+
transactionRequest.maxFee = maxFee;
|
4124
4248
|
} else {
|
4125
4249
|
break;
|
4126
4250
|
}
|
@@ -4128,37 +4252,136 @@ var _Provider = class {
|
|
4128
4252
|
return {
|
4129
4253
|
receipts,
|
4130
4254
|
outputVariables,
|
4131
|
-
missingContractIds
|
4255
|
+
missingContractIds,
|
4256
|
+
dryrunStatus
|
4132
4257
|
};
|
4133
4258
|
}
|
4259
|
+
/**
|
4260
|
+
* Dry runs multiple transactions and checks for missing dependencies in batches.
|
4261
|
+
*
|
4262
|
+
* Transactions are dry run in batches. After each dry run, transactions requiring
|
4263
|
+
* further modifications are identified. The method iteratively updates these transactions
|
4264
|
+
* and performs subsequent dry runs until all dependencies for each transaction are satisfied.
|
4265
|
+
*
|
4266
|
+
* @param transactionRequests - Array of transaction request objects.
|
4267
|
+
* @returns A promise that resolves to an array of results for each transaction.
|
4268
|
+
*/
|
4269
|
+
async estimateMultipleTxDependencies(transactionRequests) {
|
4270
|
+
const results = transactionRequests.map(() => ({
|
4271
|
+
receipts: [],
|
4272
|
+
outputVariables: 0,
|
4273
|
+
missingContractIds: [],
|
4274
|
+
dryrunStatus: void 0
|
4275
|
+
}));
|
4276
|
+
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4277
|
+
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4278
|
+
allRequests.forEach((req, index) => {
|
4279
|
+
if (req.type === import_transactions19.TransactionType.Script) {
|
4280
|
+
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4281
|
+
}
|
4282
|
+
});
|
4283
|
+
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
4284
|
+
let attempt = 0;
|
4285
|
+
while (transactionsToProcess.length > 0 && attempt < MAX_RETRIES) {
|
4286
|
+
const encodedTransactions = transactionsToProcess.map(
|
4287
|
+
(index) => serializedTransactionsMap.get(index)
|
4288
|
+
);
|
4289
|
+
const dryRunResults = await this.operations.dryRun({
|
4290
|
+
encodedTransactions,
|
4291
|
+
utxoValidation: false
|
4292
|
+
});
|
4293
|
+
const nextRoundTransactions = [];
|
4294
|
+
for (let i = 0; i < dryRunResults.dryRun.length; i++) {
|
4295
|
+
const requestIdx = transactionsToProcess[i];
|
4296
|
+
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4297
|
+
const result = results[requestIdx];
|
4298
|
+
result.receipts = rawReceipts.map(processGqlReceipt);
|
4299
|
+
result.dryrunStatus = status;
|
4300
|
+
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4301
|
+
result.receipts
|
4302
|
+
);
|
4303
|
+
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4304
|
+
const request = allRequests[requestIdx];
|
4305
|
+
if (hasMissingOutputs && request?.type === import_transactions19.TransactionType.Script) {
|
4306
|
+
result.outputVariables += missingOutputVariables.length;
|
4307
|
+
request.addVariableOutputs(missingOutputVariables.length);
|
4308
|
+
missingOutputContractIds.forEach(({ contractId }) => {
|
4309
|
+
request.addContractInputAndOutput(import_address3.Address.fromString(contractId));
|
4310
|
+
result.missingContractIds.push(contractId);
|
4311
|
+
});
|
4312
|
+
const { maxFee } = await this.estimateTxGasAndFee({
|
4313
|
+
transactionRequest: request
|
4314
|
+
});
|
4315
|
+
request.maxFee = maxFee;
|
4316
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
|
4317
|
+
nextRoundTransactions.push(requestIdx);
|
4318
|
+
}
|
4319
|
+
}
|
4320
|
+
transactionsToProcess = nextRoundTransactions;
|
4321
|
+
attempt += 1;
|
4322
|
+
}
|
4323
|
+
return results;
|
4324
|
+
}
|
4325
|
+
async dryRunMultipleTransactions(transactionRequests, { utxoValidation, estimateTxDependencies = true } = {}) {
|
4326
|
+
if (estimateTxDependencies) {
|
4327
|
+
return this.estimateMultipleTxDependencies(transactionRequests);
|
4328
|
+
}
|
4329
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
|
4330
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4331
|
+
encodedTransactions,
|
4332
|
+
utxoValidation: utxoValidation || false
|
4333
|
+
});
|
4334
|
+
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4335
|
+
const receipts = rawReceipts.map(processGqlReceipt);
|
4336
|
+
return { receipts, dryrunStatus: status };
|
4337
|
+
});
|
4338
|
+
return results;
|
4339
|
+
}
|
4134
4340
|
/**
|
4135
4341
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
4136
4342
|
* @param transactionRequest - The transaction request object.
|
4137
4343
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
4138
4344
|
*/
|
4139
|
-
estimateTxGasAndFee(params) {
|
4345
|
+
async estimateTxGasAndFee(params) {
|
4140
4346
|
const { transactionRequest } = params;
|
4141
|
-
|
4347
|
+
let { gasPrice } = params;
|
4142
4348
|
const chainInfo = this.getChain();
|
4143
|
-
const
|
4144
|
-
transactionRequest.gasPrice = gasPrice;
|
4349
|
+
const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
|
4145
4350
|
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
4146
|
-
|
4147
|
-
|
4351
|
+
if (!gasPrice) {
|
4352
|
+
gasPrice = await this.estimateGasPrice(10);
|
4353
|
+
}
|
4354
|
+
const minFee = calculateGasFee({
|
4355
|
+
gasPrice: (0, import_math16.bn)(gasPrice),
|
4356
|
+
gas: minGas,
|
4357
|
+
priceFactor: gasPriceFactor,
|
4358
|
+
tip: transactionRequest.tip
|
4359
|
+
}).add(1);
|
4360
|
+
let gasLimit = (0, import_math16.bn)(0);
|
4361
|
+
if (transactionRequest.type === import_transactions19.TransactionType.Script) {
|
4362
|
+
gasLimit = transactionRequest.gasLimit;
|
4148
4363
|
if (transactionRequest.gasLimit.eq(0)) {
|
4149
4364
|
transactionRequest.gasLimit = minGas;
|
4150
4365
|
transactionRequest.gasLimit = maxGasPerTx.sub(
|
4151
4366
|
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
4152
4367
|
);
|
4368
|
+
gasLimit = transactionRequest.gasLimit;
|
4153
4369
|
}
|
4154
4370
|
}
|
4155
4371
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4156
|
-
const maxFee =
|
4372
|
+
const maxFee = calculateGasFee({
|
4373
|
+
gasPrice: (0, import_math16.bn)(gasPrice),
|
4374
|
+
gas: maxGas,
|
4375
|
+
priceFactor: gasPriceFactor,
|
4376
|
+
tip: transactionRequest.tip
|
4377
|
+
}).add(1);
|
4157
4378
|
return {
|
4158
4379
|
minGas,
|
4159
4380
|
minFee,
|
4160
4381
|
maxGas,
|
4161
|
-
maxFee
|
4382
|
+
maxFee,
|
4383
|
+
gasPrice,
|
4384
|
+
gasLimit
|
4162
4385
|
};
|
4163
4386
|
}
|
4164
4387
|
/**
|
@@ -4176,15 +4399,17 @@ var _Provider = class {
|
|
4176
4399
|
if (estimateTxDependencies) {
|
4177
4400
|
return this.estimateTxDependencies(transactionRequest);
|
4178
4401
|
}
|
4179
|
-
const
|
4180
|
-
const { dryRun:
|
4181
|
-
|
4402
|
+
const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
|
4403
|
+
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4404
|
+
encodedTransactions,
|
4182
4405
|
utxoValidation: true
|
4183
4406
|
});
|
4184
|
-
const
|
4185
|
-
|
4186
|
-
receipts
|
4187
|
-
|
4407
|
+
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
4408
|
+
const { id, receipts, status } = dryRunStatus;
|
4409
|
+
const processedReceipts = receipts.map(processGqlReceipt);
|
4410
|
+
return { id, receipts: processedReceipts, status };
|
4411
|
+
});
|
4412
|
+
return { receipts: callResult[0].receipts };
|
4188
4413
|
}
|
4189
4414
|
/**
|
4190
4415
|
* Returns a transaction cost to enable user
|
@@ -4201,78 +4426,80 @@ var _Provider = class {
|
|
4201
4426
|
* @param tolerance - The tolerance to add on top of the gasUsed.
|
4202
4427
|
* @returns A promise that resolves to the transaction cost object.
|
4203
4428
|
*/
|
4204
|
-
async getTransactionCost(transactionRequestLike,
|
4205
|
-
estimateTxDependencies = true,
|
4206
|
-
estimatePredicates = true,
|
4207
|
-
resourcesOwner,
|
4208
|
-
signatureCallback
|
4209
|
-
} = {}) {
|
4429
|
+
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
4210
4430
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4211
|
-
const
|
4212
|
-
const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
4213
|
-
const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
|
4431
|
+
const isScriptTransaction = txRequestClone.type === import_transactions19.TransactionType.Script;
|
4214
4432
|
const baseAssetId = this.getBaseAssetId();
|
4215
4433
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4216
|
-
const allQuantities = mergeQuantities(coinOutputsQuantities,
|
4434
|
+
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4217
4435
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4436
|
+
txRequestClone.maxFee = (0, import_math16.bn)(0);
|
4218
4437
|
if (isScriptTransaction) {
|
4219
|
-
txRequestClone.gasLimit = (0,
|
4438
|
+
txRequestClone.gasLimit = (0, import_math16.bn)(0);
|
4220
4439
|
}
|
4221
|
-
if (
|
4222
|
-
|
4223
|
-
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4224
|
-
}
|
4225
|
-
await this.estimatePredicates(txRequestClone);
|
4440
|
+
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4441
|
+
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
4226
4442
|
}
|
4443
|
+
const signedRequest = (0, import_ramda3.clone)(txRequestClone);
|
4444
|
+
let addedSignatures = 0;
|
4227
4445
|
if (signatureCallback && isScriptTransaction) {
|
4228
|
-
|
4446
|
+
const lengthBefore = signedRequest.witnesses.length;
|
4447
|
+
await signatureCallback(signedRequest);
|
4448
|
+
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
4229
4449
|
}
|
4230
|
-
|
4231
|
-
|
4450
|
+
await this.estimatePredicates(signedRequest);
|
4451
|
+
let { maxFee, maxGas, minFee, minGas, gasPrice, gasLimit } = await this.estimateTxGasAndFee({
|
4452
|
+
transactionRequest: signedRequest
|
4232
4453
|
});
|
4233
4454
|
let receipts = [];
|
4234
4455
|
let missingContractIds = [];
|
4235
4456
|
let outputVariables = 0;
|
4236
|
-
let gasUsed = (0,
|
4237
|
-
|
4238
|
-
|
4457
|
+
let gasUsed = (0, import_math16.bn)(0);
|
4458
|
+
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4459
|
+
txRequestClone.maxFee = maxFee;
|
4460
|
+
if (isScriptTransaction) {
|
4461
|
+
txRequestClone.gasLimit = gasLimit;
|
4462
|
+
if (signatureCallback) {
|
4463
|
+
await signatureCallback(txRequestClone);
|
4464
|
+
}
|
4239
4465
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4240
4466
|
receipts = result.receipts;
|
4241
4467
|
outputVariables = result.outputVariables;
|
4242
4468
|
missingContractIds = result.missingContractIds;
|
4243
4469
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4244
4470
|
txRequestClone.gasLimit = gasUsed;
|
4245
|
-
|
4246
|
-
|
4247
|
-
|
4471
|
+
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4472
|
+
transactionRequest: txRequestClone,
|
4473
|
+
gasPrice
|
4248
4474
|
}));
|
4249
4475
|
}
|
4250
4476
|
return {
|
4251
4477
|
requiredQuantities: allQuantities,
|
4252
4478
|
receipts,
|
4253
4479
|
gasUsed,
|
4254
|
-
|
4255
|
-
gasPrice: setGasPrice,
|
4480
|
+
gasPrice,
|
4256
4481
|
minGas,
|
4257
4482
|
maxGas,
|
4258
4483
|
minFee,
|
4259
4484
|
maxFee,
|
4260
|
-
estimatedInputs: txRequestClone.inputs,
|
4261
4485
|
outputVariables,
|
4262
|
-
missingContractIds
|
4486
|
+
missingContractIds,
|
4487
|
+
addedSignatures,
|
4488
|
+
estimatedPredicates: txRequestClone.inputs
|
4263
4489
|
};
|
4264
4490
|
}
|
4265
|
-
async getResourcesForTransaction(owner, transactionRequestLike,
|
4491
|
+
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
4266
4492
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4267
4493
|
const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
|
4268
|
-
const transactionCost = await this.getTransactionCost(transactionRequest,
|
4494
|
+
const transactionCost = await this.getTransactionCost(transactionRequest, {
|
4495
|
+
quantitiesToContract
|
4496
|
+
});
|
4269
4497
|
transactionRequest.addResources(
|
4270
4498
|
await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
|
4271
4499
|
);
|
4272
|
-
const { requiredQuantities, ...txCost } = await this.getTransactionCost(
|
4273
|
-
|
4274
|
-
|
4275
|
-
);
|
4500
|
+
const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
|
4501
|
+
quantitiesToContract
|
4502
|
+
});
|
4276
4503
|
const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
|
4277
4504
|
return {
|
4278
4505
|
resources,
|
@@ -4288,17 +4515,16 @@ var _Provider = class {
|
|
4288
4515
|
const result = await this.operations.getCoins({
|
4289
4516
|
first: 10,
|
4290
4517
|
...paginationArgs,
|
4291
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4518
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4292
4519
|
});
|
4293
4520
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4294
4521
|
return coins.map((coin) => ({
|
4295
4522
|
id: coin.utxoId,
|
4296
4523
|
assetId: coin.assetId,
|
4297
|
-
amount: (0,
|
4524
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4298
4525
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4299
|
-
|
4300
|
-
|
4301
|
-
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
4526
|
+
blockCreated: (0, import_math16.bn)(coin.blockCreated),
|
4527
|
+
txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
|
4302
4528
|
}));
|
4303
4529
|
}
|
4304
4530
|
/**
|
@@ -4312,19 +4538,19 @@ var _Provider = class {
|
|
4312
4538
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4313
4539
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4314
4540
|
const excludeInput = {
|
4315
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4316
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4541
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
4542
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4317
4543
|
};
|
4318
4544
|
if (this.cache) {
|
4319
4545
|
const uniqueUtxos = new Set(
|
4320
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4546
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4321
4547
|
);
|
4322
4548
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4323
4549
|
}
|
4324
4550
|
const coinsQuery = {
|
4325
4551
|
owner: ownerAddress.toB256(),
|
4326
4552
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4327
|
-
assetId: (0,
|
4553
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4328
4554
|
amount: amount.toString(10),
|
4329
4555
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4330
4556
|
})),
|
@@ -4335,9 +4561,9 @@ var _Provider = class {
|
|
4335
4561
|
switch (coin.__typename) {
|
4336
4562
|
case "MessageCoin":
|
4337
4563
|
return {
|
4338
|
-
amount: (0,
|
4564
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4339
4565
|
assetId: coin.assetId,
|
4340
|
-
daHeight: (0,
|
4566
|
+
daHeight: (0, import_math16.bn)(coin.daHeight),
|
4341
4567
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4342
4568
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4343
4569
|
nonce: coin.nonce
|
@@ -4345,12 +4571,11 @@ var _Provider = class {
|
|
4345
4571
|
case "Coin":
|
4346
4572
|
return {
|
4347
4573
|
id: coin.utxoId,
|
4348
|
-
amount: (0,
|
4574
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4349
4575
|
assetId: coin.assetId,
|
4350
4576
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4351
|
-
|
4352
|
-
|
4353
|
-
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
4577
|
+
blockCreated: (0, import_math16.bn)(coin.blockCreated),
|
4578
|
+
txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
|
4354
4579
|
};
|
4355
4580
|
default:
|
4356
4581
|
return null;
|
@@ -4367,13 +4592,13 @@ var _Provider = class {
|
|
4367
4592
|
async getBlock(idOrHeight) {
|
4368
4593
|
let variables;
|
4369
4594
|
if (typeof idOrHeight === "number") {
|
4370
|
-
variables = { height: (0,
|
4595
|
+
variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4371
4596
|
} else if (idOrHeight === "latest") {
|
4372
4597
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4373
4598
|
} else if (idOrHeight.length === 66) {
|
4374
4599
|
variables = { blockId: idOrHeight };
|
4375
4600
|
} else {
|
4376
|
-
variables = { blockId: (0,
|
4601
|
+
variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4377
4602
|
}
|
4378
4603
|
const { block } = await this.operations.getBlock(variables);
|
4379
4604
|
if (!block) {
|
@@ -4381,7 +4606,7 @@ var _Provider = class {
|
|
4381
4606
|
}
|
4382
4607
|
return {
|
4383
4608
|
id: block.id,
|
4384
|
-
height: (0,
|
4609
|
+
height: (0, import_math16.bn)(block.height),
|
4385
4610
|
time: block.header.time,
|
4386
4611
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4387
4612
|
};
|
@@ -4396,7 +4621,7 @@ var _Provider = class {
|
|
4396
4621
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4397
4622
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4398
4623
|
id: block.id,
|
4399
|
-
height: (0,
|
4624
|
+
height: (0, import_math16.bn)(block.height),
|
4400
4625
|
time: block.header.time,
|
4401
4626
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4402
4627
|
}));
|
@@ -4411,7 +4636,7 @@ var _Provider = class {
|
|
4411
4636
|
async getBlockWithTransactions(idOrHeight) {
|
4412
4637
|
let variables;
|
4413
4638
|
if (typeof idOrHeight === "number") {
|
4414
|
-
variables = { blockHeight: (0,
|
4639
|
+
variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4415
4640
|
} else if (idOrHeight === "latest") {
|
4416
4641
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4417
4642
|
} else {
|
@@ -4423,11 +4648,11 @@ var _Provider = class {
|
|
4423
4648
|
}
|
4424
4649
|
return {
|
4425
4650
|
id: block.id,
|
4426
|
-
height: (0,
|
4651
|
+
height: (0, import_math16.bn)(block.height, 10),
|
4427
4652
|
time: block.header.time,
|
4428
4653
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4429
4654
|
transactions: block.transactions.map(
|
4430
|
-
(tx) => new
|
4655
|
+
(tx) => new import_transactions19.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4431
4656
|
)
|
4432
4657
|
};
|
4433
4658
|
}
|
@@ -4442,8 +4667,8 @@ var _Provider = class {
|
|
4442
4667
|
if (!transaction) {
|
4443
4668
|
return null;
|
4444
4669
|
}
|
4445
|
-
return new
|
4446
|
-
(0,
|
4670
|
+
return new import_transactions19.TransactionCoder().decode(
|
4671
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4447
4672
|
0
|
4448
4673
|
)?.[0];
|
4449
4674
|
}
|
@@ -4470,9 +4695,9 @@ var _Provider = class {
|
|
4470
4695
|
async getContractBalance(contractId, assetId) {
|
4471
4696
|
const { contractBalance } = await this.operations.getContractBalance({
|
4472
4697
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4473
|
-
asset: (0,
|
4698
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4474
4699
|
});
|
4475
|
-
return (0,
|
4700
|
+
return (0, import_math16.bn)(contractBalance.amount, 10);
|
4476
4701
|
}
|
4477
4702
|
/**
|
4478
4703
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4484,9 +4709,9 @@ var _Provider = class {
|
|
4484
4709
|
async getBalance(owner, assetId) {
|
4485
4710
|
const { balance } = await this.operations.getBalance({
|
4486
4711
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4487
|
-
assetId: (0,
|
4712
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4488
4713
|
});
|
4489
|
-
return (0,
|
4714
|
+
return (0, import_math16.bn)(balance.amount, 10);
|
4490
4715
|
}
|
4491
4716
|
/**
|
4492
4717
|
* Returns balances for the given owner.
|
@@ -4504,7 +4729,7 @@ var _Provider = class {
|
|
4504
4729
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4505
4730
|
return balances.map((balance) => ({
|
4506
4731
|
assetId: balance.assetId,
|
4507
|
-
amount: (0,
|
4732
|
+
amount: (0, import_math16.bn)(balance.amount)
|
4508
4733
|
}));
|
4509
4734
|
}
|
4510
4735
|
/**
|
@@ -4522,19 +4747,19 @@ var _Provider = class {
|
|
4522
4747
|
});
|
4523
4748
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4524
4749
|
return messages.map((message) => ({
|
4525
|
-
messageId:
|
4750
|
+
messageId: import_transactions19.InputMessageCoder.getMessageId({
|
4526
4751
|
sender: message.sender,
|
4527
4752
|
recipient: message.recipient,
|
4528
4753
|
nonce: message.nonce,
|
4529
|
-
amount: (0,
|
4754
|
+
amount: (0, import_math16.bn)(message.amount),
|
4530
4755
|
data: message.data
|
4531
4756
|
}),
|
4532
4757
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4533
4758
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4534
4759
|
nonce: message.nonce,
|
4535
|
-
amount: (0,
|
4536
|
-
data:
|
4537
|
-
daHeight: (0,
|
4760
|
+
amount: (0, import_math16.bn)(message.amount),
|
4761
|
+
data: import_transactions19.InputMessageCoder.decodeData(message.data),
|
4762
|
+
daHeight: (0, import_math16.bn)(message.daHeight)
|
4538
4763
|
}));
|
4539
4764
|
}
|
4540
4765
|
/**
|
@@ -4587,44 +4812,60 @@ var _Provider = class {
|
|
4587
4812
|
} = result.messageProof;
|
4588
4813
|
return {
|
4589
4814
|
messageProof: {
|
4590
|
-
proofIndex: (0,
|
4815
|
+
proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
|
4591
4816
|
proofSet: messageProof.proofSet
|
4592
4817
|
},
|
4593
4818
|
blockProof: {
|
4594
|
-
proofIndex: (0,
|
4819
|
+
proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
|
4595
4820
|
proofSet: blockProof.proofSet
|
4596
4821
|
},
|
4597
4822
|
messageBlockHeader: {
|
4598
4823
|
id: messageBlockHeader.id,
|
4599
|
-
daHeight: (0,
|
4600
|
-
transactionsCount: (0,
|
4824
|
+
daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
|
4825
|
+
transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
|
4601
4826
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4602
|
-
height: (0,
|
4827
|
+
height: (0, import_math16.bn)(messageBlockHeader.height),
|
4603
4828
|
prevRoot: messageBlockHeader.prevRoot,
|
4604
4829
|
time: messageBlockHeader.time,
|
4605
4830
|
applicationHash: messageBlockHeader.applicationHash,
|
4606
|
-
|
4607
|
-
|
4831
|
+
messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
|
4832
|
+
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4833
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4834
|
+
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4835
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4608
4836
|
},
|
4609
4837
|
commitBlockHeader: {
|
4610
4838
|
id: commitBlockHeader.id,
|
4611
|
-
daHeight: (0,
|
4612
|
-
transactionsCount: (0,
|
4839
|
+
daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
|
4840
|
+
transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
|
4613
4841
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4614
|
-
height: (0,
|
4842
|
+
height: (0, import_math16.bn)(commitBlockHeader.height),
|
4615
4843
|
prevRoot: commitBlockHeader.prevRoot,
|
4616
4844
|
time: commitBlockHeader.time,
|
4617
4845
|
applicationHash: commitBlockHeader.applicationHash,
|
4618
|
-
|
4619
|
-
|
4846
|
+
messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
|
4847
|
+
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4848
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4849
|
+
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4850
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4620
4851
|
},
|
4621
4852
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4622
4853
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4623
4854
|
nonce,
|
4624
|
-
amount: (0,
|
4855
|
+
amount: (0, import_math16.bn)(amount),
|
4625
4856
|
data
|
4626
4857
|
};
|
4627
4858
|
}
|
4859
|
+
async getLatestGasPrice() {
|
4860
|
+
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4861
|
+
return (0, import_math16.bn)(latestGasPrice.gasPrice);
|
4862
|
+
}
|
4863
|
+
async estimateGasPrice(blockHorizon) {
|
4864
|
+
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4865
|
+
blockHorizon: String(blockHorizon)
|
4866
|
+
});
|
4867
|
+
return (0, import_math16.bn)(estimateGasPrice.gasPrice);
|
4868
|
+
}
|
4628
4869
|
/**
|
4629
4870
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
4630
4871
|
*
|
@@ -4644,10 +4885,10 @@ var _Provider = class {
|
|
4644
4885
|
*/
|
4645
4886
|
async produceBlocks(amount, startTime) {
|
4646
4887
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4647
|
-
blocksToProduce: (0,
|
4648
|
-
startTimestamp: startTime ?
|
4888
|
+
blocksToProduce: (0, import_math16.bn)(amount).toString(10),
|
4889
|
+
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4649
4890
|
});
|
4650
|
-
return (0,
|
4891
|
+
return (0, import_math16.bn)(latestBlockHeight);
|
4651
4892
|
}
|
4652
4893
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4653
4894
|
async getTransactionResponse(transactionId) {
|
@@ -4661,7 +4902,7 @@ cacheInputs_fn = function(inputs) {
|
|
4661
4902
|
return;
|
4662
4903
|
}
|
4663
4904
|
inputs.forEach((input) => {
|
4664
|
-
if (input.type ===
|
4905
|
+
if (input.type === import_transactions19.InputType.Coin) {
|
4665
4906
|
this.cache?.set(input.id);
|
4666
4907
|
}
|
4667
4908
|
});
|
@@ -4671,9 +4912,9 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4671
4912
|
|
4672
4913
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4673
4914
|
var import_errors15 = require("@fuel-ts/errors");
|
4674
|
-
var
|
4675
|
-
var
|
4676
|
-
var
|
4915
|
+
var import_math17 = require("@fuel-ts/math");
|
4916
|
+
var import_transactions20 = require("@fuel-ts/transactions");
|
4917
|
+
var import_utils25 = require("@fuel-ts/utils");
|
4677
4918
|
async function getTransactionSummary(params) {
|
4678
4919
|
const { id, provider, abiMap } = params;
|
4679
4920
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -4685,25 +4926,32 @@ async function getTransactionSummary(params) {
|
|
4685
4926
|
`Transaction not found for given id: ${id}.`
|
4686
4927
|
);
|
4687
4928
|
}
|
4688
|
-
const [decodedTransaction] = new
|
4689
|
-
(0,
|
4929
|
+
const [decodedTransaction] = new import_transactions20.TransactionCoder().decode(
|
4930
|
+
(0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
4690
4931
|
0
|
4691
4932
|
);
|
4692
|
-
|
4933
|
+
let txReceipts = [];
|
4934
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4935
|
+
txReceipts = gqlTransaction.status.receipts;
|
4936
|
+
}
|
4937
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
4693
4938
|
const {
|
4694
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4939
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4695
4940
|
} = provider.getChain();
|
4941
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4696
4942
|
const transactionInfo = assembleTransactionSummary({
|
4697
4943
|
id: gqlTransaction.id,
|
4698
4944
|
receipts,
|
4699
4945
|
transaction: decodedTransaction,
|
4700
|
-
transactionBytes: (0,
|
4946
|
+
transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
4701
4947
|
gqlTransactionStatus: gqlTransaction.status,
|
4702
|
-
gasPerByte: (0,
|
4703
|
-
gasPriceFactor: (0,
|
4948
|
+
gasPerByte: (0, import_math17.bn)(gasPerByte),
|
4949
|
+
gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
|
4704
4950
|
abiMap,
|
4705
4951
|
maxInputs,
|
4706
|
-
gasCosts
|
4952
|
+
gasCosts,
|
4953
|
+
maxGasPerTx,
|
4954
|
+
gasPrice
|
4707
4955
|
});
|
4708
4956
|
return {
|
4709
4957
|
gqlTransaction,
|
@@ -4713,10 +4961,11 @@ async function getTransactionSummary(params) {
|
|
4713
4961
|
async function getTransactionSummaryFromRequest(params) {
|
4714
4962
|
const { provider, transactionRequest, abiMap } = params;
|
4715
4963
|
const { receipts } = await provider.call(transactionRequest);
|
4716
|
-
const { gasPerByte, gasPriceFactor, gasCosts } = provider.getGasConfig();
|
4964
|
+
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
4717
4965
|
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
4718
4966
|
const transaction = transactionRequest.toTransaction();
|
4719
4967
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
4968
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4720
4969
|
const transactionSummary = assembleTransactionSummary({
|
4721
4970
|
receipts,
|
4722
4971
|
transaction,
|
@@ -4725,7 +4974,9 @@ async function getTransactionSummaryFromRequest(params) {
|
|
4725
4974
|
gasPerByte,
|
4726
4975
|
gasPriceFactor,
|
4727
4976
|
maxInputs,
|
4728
|
-
gasCosts
|
4977
|
+
gasCosts,
|
4978
|
+
maxGasPerTx,
|
4979
|
+
gasPrice
|
4729
4980
|
});
|
4730
4981
|
return transactionSummary;
|
4731
4982
|
}
|
@@ -4734,24 +4985,31 @@ async function getTransactionsSummaries(params) {
|
|
4734
4985
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
4735
4986
|
const { edges, pageInfo } = transactionsByOwner;
|
4736
4987
|
const {
|
4737
|
-
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts }
|
4988
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4738
4989
|
} = provider.getChain();
|
4990
|
+
const gasPrice = await provider.getLatestGasPrice();
|
4739
4991
|
const transactions = edges.map((edge) => {
|
4740
4992
|
const { node: gqlTransaction } = edge;
|
4741
|
-
const { id, rawPayload,
|
4742
|
-
const [decodedTransaction] = new
|
4743
|
-
|
4993
|
+
const { id, rawPayload, status } = gqlTransaction;
|
4994
|
+
const [decodedTransaction] = new import_transactions20.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
|
4995
|
+
let txReceipts = [];
|
4996
|
+
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
4997
|
+
txReceipts = gqlTransaction.status.receipts;
|
4998
|
+
}
|
4999
|
+
const receipts = txReceipts.map(processGqlReceipt);
|
4744
5000
|
const transactionSummary = assembleTransactionSummary({
|
4745
5001
|
id,
|
4746
5002
|
receipts,
|
4747
5003
|
transaction: decodedTransaction,
|
4748
|
-
transactionBytes: (0,
|
5004
|
+
transactionBytes: (0, import_utils25.arrayify)(rawPayload),
|
4749
5005
|
gqlTransactionStatus: status,
|
4750
5006
|
abiMap,
|
4751
5007
|
gasPerByte,
|
4752
5008
|
gasPriceFactor,
|
4753
5009
|
maxInputs,
|
4754
|
-
gasCosts
|
5010
|
+
gasCosts,
|
5011
|
+
maxGasPerTx,
|
5012
|
+
gasPrice
|
4755
5013
|
});
|
4756
5014
|
const output = {
|
4757
5015
|
gqlTransaction,
|
@@ -4888,17 +5146,17 @@ var assets = [
|
|
4888
5146
|
|
4889
5147
|
// src/utils/formatTransferToContractScriptData.ts
|
4890
5148
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4891
|
-
var
|
4892
|
-
var
|
5149
|
+
var import_math18 = require("@fuel-ts/math");
|
5150
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4893
5151
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4894
5152
|
var formatTransferToContractScriptData = (params) => {
|
4895
5153
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4896
5154
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
4897
|
-
const encoded = numberCoder.encode(new
|
5155
|
+
const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
|
4898
5156
|
const scriptData = Uint8Array.from([
|
4899
|
-
...(0,
|
5157
|
+
...(0, import_utils26.arrayify)(hexlifiedContractId),
|
4900
5158
|
...encoded,
|
4901
|
-
...(0,
|
5159
|
+
...(0, import_utils26.arrayify)(assetId)
|
4902
5160
|
]);
|
4903
5161
|
return scriptData;
|
4904
5162
|
};
|
@@ -5084,38 +5342,31 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5084
5342
|
* @param fee - The estimated transaction fee.
|
5085
5343
|
* @returns A promise that resolves when the resources are added to the transaction.
|
5086
5344
|
*/
|
5087
|
-
async fund(request,
|
5345
|
+
async fund(request, params) {
|
5346
|
+
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
5088
5347
|
const baseAssetId = this.provider.getBaseAssetId();
|
5089
|
-
const
|
5090
|
-
|
5348
|
+
const txRequest = request;
|
5349
|
+
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5350
|
+
amount: (0, import_math19.bn)(fee),
|
5091
5351
|
assetId: baseAssetId,
|
5092
|
-
coinQuantities
|
5352
|
+
coinQuantities: requiredQuantities
|
5093
5353
|
});
|
5094
5354
|
const quantitiesDict = {};
|
5095
|
-
|
5355
|
+
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5096
5356
|
quantitiesDict[assetId] = {
|
5097
5357
|
required: amount,
|
5098
|
-
owned: (0,
|
5358
|
+
owned: (0, import_math19.bn)(0)
|
5099
5359
|
};
|
5100
5360
|
});
|
5101
|
-
|
5102
|
-
const cachedMessages = [];
|
5103
|
-
const owner = this.address.toB256();
|
5104
|
-
request.inputs.forEach((input) => {
|
5361
|
+
txRequest.inputs.forEach((input) => {
|
5105
5362
|
const isResource = "amount" in input;
|
5106
|
-
if (isResource) {
|
5107
|
-
|
5108
|
-
|
5109
|
-
|
5110
|
-
|
5111
|
-
|
5112
|
-
|
5113
|
-
cachedUtxos.push(input.id);
|
5114
|
-
}
|
5115
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
5116
|
-
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
5117
|
-
cachedMessages.push(input.nonce);
|
5118
|
-
}
|
5363
|
+
if (!isResource) {
|
5364
|
+
return;
|
5365
|
+
}
|
5366
|
+
const isCoin2 = "owner" in input;
|
5367
|
+
const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
|
5368
|
+
if (quantitiesDict[assetId]) {
|
5369
|
+
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
|
5119
5370
|
}
|
5120
5371
|
});
|
5121
5372
|
const missingQuantities = [];
|
@@ -5129,12 +5380,21 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5129
5380
|
});
|
5130
5381
|
const needsToBeFunded = missingQuantities.length;
|
5131
5382
|
if (needsToBeFunded) {
|
5132
|
-
const
|
5133
|
-
|
5134
|
-
|
5135
|
-
|
5136
|
-
|
5137
|
-
|
5383
|
+
const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
|
5384
|
+
const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
|
5385
|
+
txRequest.addResources(resources);
|
5386
|
+
}
|
5387
|
+
txRequest.shiftPredicateData();
|
5388
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
5389
|
+
const requestToReestimate = (0, import_ramda4.clone)(txRequest);
|
5390
|
+
if (addedSignatures) {
|
5391
|
+
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
5392
|
+
}
|
5393
|
+
const { maxFee } = await this.provider.estimateTxGasAndFee({
|
5394
|
+
transactionRequest: requestToReestimate
|
5395
|
+
});
|
5396
|
+
txRequest.maxFee = maxFee;
|
5397
|
+
return txRequest;
|
5138
5398
|
}
|
5139
5399
|
/**
|
5140
5400
|
* A helper that creates a transfer transaction request and returns it.
|
@@ -5142,29 +5402,25 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5142
5402
|
* @param destination - The address of the destination.
|
5143
5403
|
* @param amount - The amount of coins to transfer.
|
5144
5404
|
* @param assetId - The asset ID of the coins to transfer.
|
5145
|
-
* @param txParams - The transaction parameters (gasLimit,
|
5405
|
+
* @param txParams - The transaction parameters (gasLimit, tip, maturity, maxFee, witnessLimit).
|
5146
5406
|
* @returns A promise that resolves to the prepared transaction request.
|
5147
5407
|
*/
|
5148
5408
|
async createTransfer(destination, amount, assetId, txParams = {}) {
|
5149
|
-
const
|
5409
|
+
const request = new ScriptTransactionRequest(txParams);
|
5150
5410
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5151
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
5152
|
-
const request = new ScriptTransactionRequest(params);
|
5153
5411
|
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetIdToTransfer);
|
5154
|
-
const
|
5412
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5155
5413
|
estimateTxDependencies: true,
|
5156
5414
|
resourcesOwner: this
|
5157
5415
|
});
|
5158
|
-
|
5159
|
-
|
5160
|
-
|
5161
|
-
|
5162
|
-
gasPrice: request.gasPrice,
|
5163
|
-
gasLimit: request.gasLimit,
|
5164
|
-
minGasPrice
|
5416
|
+
this.validateGasLimitAndMaxFee({
|
5417
|
+
gasUsed: txCost.gasUsed,
|
5418
|
+
maxFee: txCost.maxFee,
|
5419
|
+
txParams
|
5165
5420
|
});
|
5166
|
-
|
5167
|
-
request.
|
5421
|
+
request.gasLimit = txCost.gasUsed;
|
5422
|
+
request.maxFee = txCost.maxFee;
|
5423
|
+
await this.fund(request, txCost);
|
5168
5424
|
return request;
|
5169
5425
|
}
|
5170
5426
|
/**
|
@@ -5173,11 +5429,11 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5173
5429
|
* @param destination - The address of the destination.
|
5174
5430
|
* @param amount - The amount of coins to transfer.
|
5175
5431
|
* @param assetId - The asset ID of the coins to transfer.
|
5176
|
-
* @param txParams - The transaction parameters (gasLimit,
|
5432
|
+
* @param txParams - The transaction parameters (gasLimit, maturity).
|
5177
5433
|
* @returns A promise that resolves to the transaction response.
|
5178
5434
|
*/
|
5179
5435
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5180
|
-
if ((0,
|
5436
|
+
if ((0, import_math19.bn)(amount).lte(0)) {
|
5181
5437
|
throw new import_errors16.FuelError(
|
5182
5438
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5183
5439
|
"Transfer amount must be a positive number."
|
@@ -5197,39 +5453,37 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5197
5453
|
* @returns A promise that resolves to the transaction response.
|
5198
5454
|
*/
|
5199
5455
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5200
|
-
if ((0,
|
5456
|
+
if ((0, import_math19.bn)(amount).lte(0)) {
|
5201
5457
|
throw new import_errors16.FuelError(
|
5202
5458
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5203
5459
|
"Transfer amount must be a positive number."
|
5204
5460
|
);
|
5205
5461
|
}
|
5206
5462
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
5207
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
5208
5463
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5209
|
-
const params = { gasPrice: minGasPrice, ...txParams };
|
5210
5464
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5211
5465
|
hexlifiedContractId: contractAddress.toB256(),
|
5212
|
-
amountToTransfer: (0,
|
5466
|
+
amountToTransfer: (0, import_math19.bn)(amount),
|
5213
5467
|
assetId: assetIdToTransfer
|
5214
5468
|
});
|
5215
5469
|
const request = new ScriptTransactionRequest({
|
5216
|
-
...
|
5470
|
+
...txParams,
|
5217
5471
|
script,
|
5218
5472
|
scriptData
|
5219
5473
|
});
|
5220
5474
|
request.addContractInputAndOutput(contractAddress);
|
5221
|
-
const
|
5222
|
-
|
5223
|
-
[{ amount: (0,
|
5224
|
-
);
|
5225
|
-
|
5226
|
-
|
5227
|
-
|
5228
|
-
|
5229
|
-
gasLimit: request.gasLimit,
|
5230
|
-
minGasPrice
|
5475
|
+
const txCost = await this.provider.getTransactionCost(request, {
|
5476
|
+
resourcesOwner: this,
|
5477
|
+
quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5478
|
+
});
|
5479
|
+
this.validateGasLimitAndMaxFee({
|
5480
|
+
gasUsed: txCost.gasUsed,
|
5481
|
+
maxFee: txCost.maxFee,
|
5482
|
+
txParams
|
5231
5483
|
});
|
5232
|
-
|
5484
|
+
request.gasLimit = txCost.gasUsed;
|
5485
|
+
request.maxFee = txCost.maxFee;
|
5486
|
+
await this.fund(request, txCost);
|
5233
5487
|
return this.sendTransaction(request);
|
5234
5488
|
}
|
5235
5489
|
/**
|
@@ -5241,39 +5495,31 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5241
5495
|
* @returns A promise that resolves to the transaction response.
|
5242
5496
|
*/
|
5243
5497
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5244
|
-
const { minGasPrice } = this.provider.getGasConfig();
|
5245
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
5246
5498
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5247
|
-
const recipientDataArray = (0,
|
5499
|
+
const recipientDataArray = (0, import_utils27.arrayify)(
|
5248
5500
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5249
5501
|
);
|
5250
|
-
const amountDataArray = (0,
|
5251
|
-
"0x".concat((0,
|
5502
|
+
const amountDataArray = (0, import_utils27.arrayify)(
|
5503
|
+
"0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5252
5504
|
);
|
5253
5505
|
const script = new Uint8Array([
|
5254
|
-
...(0,
|
5506
|
+
...(0, import_utils27.arrayify)(withdrawScript.bytes),
|
5255
5507
|
...recipientDataArray,
|
5256
5508
|
...amountDataArray
|
5257
5509
|
]);
|
5258
|
-
const params = {
|
5259
|
-
|
5260
|
-
gasPrice: minGasPrice,
|
5261
|
-
...txParams
|
5262
|
-
};
|
5510
|
+
const params = { script, ...txParams };
|
5511
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5263
5512
|
const request = new ScriptTransactionRequest(params);
|
5264
|
-
const
|
5265
|
-
const
|
5266
|
-
|
5267
|
-
|
5268
|
-
|
5269
|
-
|
5270
|
-
this.validateGas({
|
5271
|
-
gasUsed,
|
5272
|
-
gasPrice: request.gasPrice,
|
5273
|
-
gasLimit: request.gasLimit,
|
5274
|
-
minGasPrice
|
5513
|
+
const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: baseAssetId }];
|
5514
|
+
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5515
|
+
this.validateGasLimitAndMaxFee({
|
5516
|
+
gasUsed: txCost.gasUsed,
|
5517
|
+
maxFee: txCost.maxFee,
|
5518
|
+
txParams
|
5275
5519
|
});
|
5276
|
-
|
5520
|
+
request.maxFee = txCost.maxFee;
|
5521
|
+
request.gasLimit = txCost.gasUsed;
|
5522
|
+
await this.fund(request, txCost);
|
5277
5523
|
return this.sendTransaction(request);
|
5278
5524
|
}
|
5279
5525
|
async signMessage(message) {
|
@@ -5331,22 +5577,21 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5331
5577
|
}
|
5332
5578
|
return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
|
5333
5579
|
}
|
5334
|
-
|
5580
|
+
validateGasLimitAndMaxFee({
|
5581
|
+
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee },
|
5335
5582
|
gasUsed,
|
5336
|
-
|
5337
|
-
gasLimit,
|
5338
|
-
minGasPrice
|
5583
|
+
maxFee
|
5339
5584
|
}) {
|
5340
|
-
if (
|
5585
|
+
if ((0, import_utils27.isDefined)(setGasLimit) && gasUsed.gt(setGasLimit)) {
|
5341
5586
|
throw new import_errors16.FuelError(
|
5342
|
-
import_errors16.ErrorCode.
|
5343
|
-
`Gas
|
5587
|
+
import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
|
5588
|
+
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5344
5589
|
);
|
5345
5590
|
}
|
5346
|
-
if (
|
5591
|
+
if ((0, import_utils27.isDefined)(setMaxFee) && maxFee.gt(setMaxFee)) {
|
5347
5592
|
throw new import_errors16.FuelError(
|
5348
|
-
import_errors16.ErrorCode.
|
5349
|
-
`
|
5593
|
+
import_errors16.ErrorCode.MAX_FEE_TOO_LOW,
|
5594
|
+
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
5350
5595
|
);
|
5351
5596
|
}
|
5352
5597
|
}
|
@@ -5354,14 +5599,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5354
5599
|
|
5355
5600
|
// src/wallet/base-wallet-unlocked.ts
|
5356
5601
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5357
|
-
var
|
5602
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5358
5603
|
|
5359
5604
|
// src/signer/signer.ts
|
5360
5605
|
var import_address5 = require("@fuel-ts/address");
|
5361
5606
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5362
5607
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5363
|
-
var
|
5364
|
-
var
|
5608
|
+
var import_math20 = require("@fuel-ts/math");
|
5609
|
+
var import_utils28 = require("@fuel-ts/utils");
|
5365
5610
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5366
5611
|
var Signer = class {
|
5367
5612
|
address;
|
@@ -5380,10 +5625,10 @@ var Signer = class {
|
|
5380
5625
|
privateKey = `0x${privateKey}`;
|
5381
5626
|
}
|
5382
5627
|
}
|
5383
|
-
const privateKeyBytes = (0,
|
5384
|
-
this.privateKey = (0,
|
5385
|
-
this.publicKey = (0,
|
5386
|
-
this.compressedPublicKey = (0,
|
5628
|
+
const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
|
5629
|
+
this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
|
5630
|
+
this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5631
|
+
this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5387
5632
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5388
5633
|
}
|
5389
5634
|
/**
|
@@ -5397,11 +5642,11 @@ var Signer = class {
|
|
5397
5642
|
* @returns hashed signature
|
5398
5643
|
*/
|
5399
5644
|
sign(data) {
|
5400
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5401
|
-
const r = (0,
|
5402
|
-
const s = (0,
|
5645
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
|
5646
|
+
const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5647
|
+
const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5403
5648
|
s[0] |= (signature.recovery || 0) << 7;
|
5404
|
-
return (0,
|
5649
|
+
return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
|
5405
5650
|
}
|
5406
5651
|
/**
|
5407
5652
|
* Add point on the current elliptic curve
|
@@ -5410,8 +5655,8 @@ var Signer = class {
|
|
5410
5655
|
* @returns compressed point on the curve
|
5411
5656
|
*/
|
5412
5657
|
addPoint(point) {
|
5413
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5414
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5658
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
|
5659
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
|
5415
5660
|
const result = p0.add(p1);
|
5416
5661
|
return `0x${result.toHex(true)}`;
|
5417
5662
|
}
|
@@ -5423,16 +5668,16 @@ var Signer = class {
|
|
5423
5668
|
* @returns public key from signature from the
|
5424
5669
|
*/
|
5425
5670
|
static recoverPublicKey(data, signature) {
|
5426
|
-
const signedMessageBytes = (0,
|
5671
|
+
const signedMessageBytes = (0, import_utils28.arrayify)(signature);
|
5427
5672
|
const r = signedMessageBytes.slice(0, 32);
|
5428
5673
|
const s = signedMessageBytes.slice(32, 64);
|
5429
5674
|
const recoveryParam = (s[0] & 128) >> 7;
|
5430
5675
|
s[0] &= 127;
|
5431
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5676
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
|
5432
5677
|
recoveryParam
|
5433
5678
|
);
|
5434
|
-
const publicKey = sig.recoverPublicKey((0,
|
5435
|
-
return (0,
|
5679
|
+
const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
|
5680
|
+
return (0, import_utils28.hexlify)(publicKey);
|
5436
5681
|
}
|
5437
5682
|
/**
|
5438
5683
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5451,7 +5696,7 @@ var Signer = class {
|
|
5451
5696
|
* @returns random 32-byte hashed
|
5452
5697
|
*/
|
5453
5698
|
static generatePrivateKey(entropy) {
|
5454
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5699
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
|
5455
5700
|
}
|
5456
5701
|
/**
|
5457
5702
|
* Extended publicKey from a compact publicKey
|
@@ -5460,8 +5705,8 @@ var Signer = class {
|
|
5460
5705
|
* @returns extended publicKey
|
5461
5706
|
*/
|
5462
5707
|
static extendPublicKey(publicKey) {
|
5463
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5464
|
-
return (0,
|
5708
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
|
5709
|
+
return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
|
5465
5710
|
}
|
5466
5711
|
};
|
5467
5712
|
|
@@ -5469,7 +5714,7 @@ var Signer = class {
|
|
5469
5714
|
var import_address6 = require("@fuel-ts/address");
|
5470
5715
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5471
5716
|
var import_errors17 = require("@fuel-ts/errors");
|
5472
|
-
var
|
5717
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5473
5718
|
var import_uuid = require("uuid");
|
5474
5719
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5475
5720
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5552,7 +5797,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5552
5797
|
);
|
5553
5798
|
}
|
5554
5799
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5555
|
-
const privateKey = (0,
|
5800
|
+
const privateKey = (0, import_utils29.hexlify)(buffer);
|
5556
5801
|
return privateKey;
|
5557
5802
|
}
|
5558
5803
|
|
@@ -5597,7 +5842,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5597
5842
|
*/
|
5598
5843
|
async signMessage(message) {
|
5599
5844
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5600
|
-
return (0,
|
5845
|
+
return (0, import_utils30.hexlify)(signedMessage);
|
5601
5846
|
}
|
5602
5847
|
/**
|
5603
5848
|
* Signs a transaction with the wallet's private key.
|
@@ -5610,7 +5855,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5610
5855
|
const chainId = this.provider.getChainId();
|
5611
5856
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5612
5857
|
const signature = await this.signer().sign(hashedTransaction);
|
5613
|
-
return (0,
|
5858
|
+
return (0, import_utils30.hexlify)(signature);
|
5614
5859
|
}
|
5615
5860
|
/**
|
5616
5861
|
* Populates a transaction with the witnesses signature.
|
@@ -5630,7 +5875,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5630
5875
|
* @param transactionRequestLike - The transaction request to send.
|
5631
5876
|
* @returns A promise that resolves to the TransactionResponse object.
|
5632
5877
|
*/
|
5633
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies =
|
5878
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
|
5634
5879
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
5635
5880
|
if (estimateTxDependencies) {
|
5636
5881
|
await this.provider.estimateTxDependencies(transactionRequest);
|
@@ -5671,16 +5916,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5671
5916
|
// src/hdwallet/hdwallet.ts
|
5672
5917
|
var import_errors20 = require("@fuel-ts/errors");
|
5673
5918
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5674
|
-
var
|
5675
|
-
var
|
5676
|
-
var
|
5919
|
+
var import_math21 = require("@fuel-ts/math");
|
5920
|
+
var import_utils34 = require("@fuel-ts/utils");
|
5921
|
+
var import_ethers3 = require("ethers");
|
5677
5922
|
|
5678
5923
|
// src/mnemonic/mnemonic.ts
|
5679
5924
|
var import_crypto4 = require("@fuel-ts/crypto");
|
5680
5925
|
var import_errors19 = require("@fuel-ts/errors");
|
5681
5926
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5682
|
-
var
|
5683
|
-
var
|
5927
|
+
var import_utils32 = require("@fuel-ts/utils");
|
5928
|
+
var import_ethers2 = require("ethers");
|
5684
5929
|
|
5685
5930
|
// src/wordlists/words/english.ts
|
5686
5931
|
var english = [
|
@@ -7743,7 +7988,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
7743
7988
|
// src/mnemonic/utils.ts
|
7744
7989
|
var import_errors18 = require("@fuel-ts/errors");
|
7745
7990
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7746
|
-
var
|
7991
|
+
var import_utils31 = require("@fuel-ts/utils");
|
7747
7992
|
function toUtf8Bytes(stri) {
|
7748
7993
|
const str = stri.normalize("NFKD");
|
7749
7994
|
const result = [];
|
@@ -7810,14 +8055,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
7810
8055
|
}
|
7811
8056
|
}
|
7812
8057
|
const checksumBits = entropy.length / 4;
|
7813
|
-
const checksum = (0,
|
8058
|
+
const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7814
8059
|
indices[indices.length - 1] <<= checksumBits;
|
7815
8060
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7816
8061
|
return indices;
|
7817
8062
|
}
|
7818
8063
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7819
8064
|
const size = Math.ceil(11 * words.length / 8);
|
7820
|
-
const entropy = (0,
|
8065
|
+
const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
|
7821
8066
|
let offset = 0;
|
7822
8067
|
for (let i = 0; i < words.length; i += 1) {
|
7823
8068
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -7837,7 +8082,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7837
8082
|
const entropyBits = 32 * words.length / 3;
|
7838
8083
|
const checksumBits = words.length / 3;
|
7839
8084
|
const checksumMask = getUpperMask(checksumBits);
|
7840
|
-
const checksum = (0,
|
8085
|
+
const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7841
8086
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7842
8087
|
throw new import_errors18.FuelError(
|
7843
8088
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -7912,7 +8157,7 @@ var Mnemonic = class {
|
|
7912
8157
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7913
8158
|
const words = getWords(phrase);
|
7914
8159
|
assertMnemonic(words);
|
7915
|
-
return (0,
|
8160
|
+
return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7916
8161
|
}
|
7917
8162
|
/**
|
7918
8163
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7920,7 +8165,7 @@ var Mnemonic = class {
|
|
7920
8165
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7921
8166
|
*/
|
7922
8167
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7923
|
-
const entropyBytes = (0,
|
8168
|
+
const entropyBytes = (0, import_utils32.arrayify)(entropy);
|
7924
8169
|
assertWordList(wordlist);
|
7925
8170
|
assertEntropy(entropyBytes);
|
7926
8171
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7934,7 +8179,7 @@ var Mnemonic = class {
|
|
7934
8179
|
assertMnemonic(getWords(phrase));
|
7935
8180
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7936
8181
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7937
|
-
return (0,
|
8182
|
+
return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7938
8183
|
}
|
7939
8184
|
/**
|
7940
8185
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -7989,14 +8234,14 @@ var Mnemonic = class {
|
|
7989
8234
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7990
8235
|
*/
|
7991
8236
|
static masterKeysFromSeed(seed) {
|
7992
|
-
const seedArray = (0,
|
8237
|
+
const seedArray = (0, import_utils32.arrayify)(seed);
|
7993
8238
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7994
8239
|
throw new import_errors19.FuelError(
|
7995
8240
|
import_errors19.ErrorCode.INVALID_SEED,
|
7996
8241
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7997
8242
|
);
|
7998
8243
|
}
|
7999
|
-
return (0,
|
8244
|
+
return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
|
8000
8245
|
}
|
8001
8246
|
/**
|
8002
8247
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8007,22 +8252,22 @@ var Mnemonic = class {
|
|
8007
8252
|
*/
|
8008
8253
|
static seedToExtendedKey(seed, testnet = false) {
|
8009
8254
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8010
|
-
const prefix = (0,
|
8255
|
+
const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8011
8256
|
const depth = "0x00";
|
8012
8257
|
const fingerprint = "0x00000000";
|
8013
8258
|
const index = "0x00000000";
|
8014
8259
|
const chainCode = masterKey.slice(32);
|
8015
8260
|
const privateKey = masterKey.slice(0, 32);
|
8016
|
-
const extendedKey = (0,
|
8261
|
+
const extendedKey = (0, import_utils32.concat)([
|
8017
8262
|
prefix,
|
8018
8263
|
depth,
|
8019
8264
|
fingerprint,
|
8020
8265
|
index,
|
8021
8266
|
chainCode,
|
8022
|
-
(0,
|
8267
|
+
(0, import_utils32.concat)(["0x00", privateKey])
|
8023
8268
|
]);
|
8024
|
-
const checksum = (0,
|
8025
|
-
return (0,
|
8269
|
+
const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8270
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
|
8026
8271
|
}
|
8027
8272
|
/**
|
8028
8273
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8037,7 +8282,7 @@ var Mnemonic = class {
|
|
8037
8282
|
* @returns A randomly generated mnemonic
|
8038
8283
|
*/
|
8039
8284
|
static generate(size = 32, extraEntropy = "") {
|
8040
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8285
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
|
8041
8286
|
return Mnemonic.entropyToMnemonic(entropy);
|
8042
8287
|
}
|
8043
8288
|
};
|
@@ -8045,12 +8290,12 @@ var mnemonic_default = Mnemonic;
|
|
8045
8290
|
|
8046
8291
|
// src/hdwallet/hdwallet.ts
|
8047
8292
|
var HARDENED_INDEX = 2147483648;
|
8048
|
-
var MainnetPRV2 = (0,
|
8049
|
-
var MainnetPUB = (0,
|
8050
|
-
var TestnetPRV2 = (0,
|
8051
|
-
var TestnetPUB = (0,
|
8293
|
+
var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
|
8294
|
+
var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
|
8295
|
+
var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
|
8296
|
+
var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
|
8052
8297
|
function base58check(data) {
|
8053
|
-
return (0,
|
8298
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
8054
8299
|
}
|
8055
8300
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8056
8301
|
if (isPublic) {
|
@@ -8059,11 +8304,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8059
8304
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8060
8305
|
}
|
8061
8306
|
function isPublicExtendedKey(extendedKey) {
|
8062
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8307
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
|
8063
8308
|
}
|
8064
8309
|
function isValidExtendedKey(extendedKey) {
|
8065
8310
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8066
|
-
(0,
|
8311
|
+
(0, import_utils34.hexlify)(extendedKey.slice(0, 4))
|
8067
8312
|
);
|
8068
8313
|
}
|
8069
8314
|
function parsePath(path, depth = 0) {
|
@@ -8081,8 +8326,8 @@ function parsePath(path, depth = 0) {
|
|
8081
8326
|
var HDWallet = class {
|
8082
8327
|
depth = 0;
|
8083
8328
|
index = 0;
|
8084
|
-
fingerprint = (0,
|
8085
|
-
parentFingerprint = (0,
|
8329
|
+
fingerprint = (0, import_utils34.hexlify)("0x00000000");
|
8330
|
+
parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
|
8086
8331
|
privateKey;
|
8087
8332
|
publicKey;
|
8088
8333
|
chainCode;
|
@@ -8094,8 +8339,8 @@ var HDWallet = class {
|
|
8094
8339
|
constructor(config) {
|
8095
8340
|
if (config.privateKey) {
|
8096
8341
|
const signer = new Signer(config.privateKey);
|
8097
|
-
this.publicKey = (0,
|
8098
|
-
this.privateKey = (0,
|
8342
|
+
this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
|
8343
|
+
this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
|
8099
8344
|
} else {
|
8100
8345
|
if (!config.publicKey) {
|
8101
8346
|
throw new import_errors20.FuelError(
|
@@ -8103,10 +8348,10 @@ var HDWallet = class {
|
|
8103
8348
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8104
8349
|
);
|
8105
8350
|
}
|
8106
|
-
this.publicKey = (0,
|
8351
|
+
this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
|
8107
8352
|
}
|
8108
8353
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8109
|
-
this.fingerprint = (0,
|
8354
|
+
this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8110
8355
|
this.depth = config.depth || this.depth;
|
8111
8356
|
this.index = config.index || this.index;
|
8112
8357
|
this.chainCode = config.chainCode;
|
@@ -8122,9 +8367,9 @@ var HDWallet = class {
|
|
8122
8367
|
* @returns A new instance of HDWallet on the derived index
|
8123
8368
|
*/
|
8124
8369
|
deriveIndex(index) {
|
8125
|
-
const privateKey = this.privateKey && (0,
|
8126
|
-
const publicKey = (0,
|
8127
|
-
const chainCode = (0,
|
8370
|
+
const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
|
8371
|
+
const publicKey = (0, import_utils34.arrayify)(this.publicKey);
|
8372
|
+
const chainCode = (0, import_utils34.arrayify)(this.chainCode);
|
8128
8373
|
const data = new Uint8Array(37);
|
8129
8374
|
if (index & HARDENED_INDEX) {
|
8130
8375
|
if (!privateKey) {
|
@@ -8135,15 +8380,15 @@ var HDWallet = class {
|
|
8135
8380
|
}
|
8136
8381
|
data.set(privateKey, 1);
|
8137
8382
|
} else {
|
8138
|
-
data.set((0,
|
8383
|
+
data.set((0, import_utils34.arrayify)(this.publicKey));
|
8139
8384
|
}
|
8140
|
-
data.set((0,
|
8141
|
-
const bytes = (0,
|
8385
|
+
data.set((0, import_math21.toBytes)(index, 4), 33);
|
8386
|
+
const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
|
8142
8387
|
const IL = bytes.slice(0, 32);
|
8143
8388
|
const IR = bytes.slice(32);
|
8144
8389
|
if (privateKey) {
|
8145
8390
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8146
|
-
const ki = (0,
|
8391
|
+
const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
8147
8392
|
return new HDWallet({
|
8148
8393
|
privateKey: ki,
|
8149
8394
|
chainCode: IR,
|
@@ -8152,7 +8397,7 @@ var HDWallet = class {
|
|
8152
8397
|
parentFingerprint: this.fingerprint
|
8153
8398
|
});
|
8154
8399
|
}
|
8155
|
-
const signer = new Signer((0,
|
8400
|
+
const signer = new Signer((0, import_utils34.hexlify)(IL));
|
8156
8401
|
const Ki = signer.addPoint(publicKey);
|
8157
8402
|
return new HDWallet({
|
8158
8403
|
publicKey: Ki,
|
@@ -8187,12 +8432,12 @@ var HDWallet = class {
|
|
8187
8432
|
);
|
8188
8433
|
}
|
8189
8434
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8190
|
-
const depth = (0,
|
8435
|
+
const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
|
8191
8436
|
const parentFingerprint = this.parentFingerprint;
|
8192
|
-
const index = (0,
|
8437
|
+
const index = (0, import_math21.toHex)(this.index, 4);
|
8193
8438
|
const chainCode = this.chainCode;
|
8194
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8195
|
-
const extendedKey = (0,
|
8439
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8440
|
+
const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8196
8441
|
return base58check(extendedKey);
|
8197
8442
|
}
|
8198
8443
|
/**
|
@@ -8204,13 +8449,13 @@ var HDWallet = class {
|
|
8204
8449
|
static fromSeed(seed) {
|
8205
8450
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8206
8451
|
return new HDWallet({
|
8207
|
-
chainCode: (0,
|
8208
|
-
privateKey: (0,
|
8452
|
+
chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
|
8453
|
+
privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
|
8209
8454
|
});
|
8210
8455
|
}
|
8211
8456
|
static fromExtendedKey(extendedKey) {
|
8212
|
-
const decoded = (0,
|
8213
|
-
const bytes = (0,
|
8457
|
+
const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
|
8458
|
+
const bytes = (0, import_utils34.arrayify)(decoded);
|
8214
8459
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8215
8460
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8216
8461
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8219,9 +8464,9 @@ var HDWallet = class {
|
|
8219
8464
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8220
8465
|
}
|
8221
8466
|
const depth = bytes[4];
|
8222
|
-
const parentFingerprint = (0,
|
8223
|
-
const index = parseInt((0,
|
8224
|
-
const chainCode = (0,
|
8467
|
+
const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
|
8468
|
+
const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8469
|
+
const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
|
8225
8470
|
const key = bytes.slice(45, 78);
|
8226
8471
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8227
8472
|
throw new import_errors20.FuelError(
|
@@ -8825,19 +9070,19 @@ var StorageAbstract = class {
|
|
8825
9070
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
8826
9071
|
var import_address10 = require("@fuel-ts/address");
|
8827
9072
|
var import_errors25 = require("@fuel-ts/errors");
|
8828
|
-
var
|
8829
|
-
var
|
9073
|
+
var import_transactions21 = require("@fuel-ts/transactions");
|
9074
|
+
var import_utils36 = require("@fuel-ts/utils");
|
8830
9075
|
|
8831
9076
|
// src/predicate/utils/getPredicateRoot.ts
|
8832
9077
|
var import_hasher7 = require("@fuel-ts/hasher");
|
8833
9078
|
var import_merkle = require("@fuel-ts/merkle");
|
8834
|
-
var
|
9079
|
+
var import_utils35 = require("@fuel-ts/utils");
|
8835
9080
|
var getPredicateRoot = (bytecode) => {
|
8836
9081
|
const chunkSize = 16 * 1024;
|
8837
|
-
const bytes = (0,
|
8838
|
-
const chunks = (0,
|
8839
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
8840
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
9082
|
+
const bytes = (0, import_utils35.arrayify)(bytecode);
|
9083
|
+
const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
|
9084
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
|
9085
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
|
8841
9086
|
return predicateRoot;
|
8842
9087
|
};
|
8843
9088
|
|
@@ -8885,36 +9130,22 @@ var Predicate = class extends Account {
|
|
8885
9130
|
const request = transactionRequestify(transactionRequestLike);
|
8886
9131
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8887
9132
|
request.inputs?.forEach((input) => {
|
8888
|
-
if (input.type ===
|
8889
|
-
input.predicate = this.bytes;
|
8890
|
-
input.predicateData = this.getPredicateData(policies.length);
|
9133
|
+
if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
|
9134
|
+
input.predicate = (0, import_utils36.hexlify)(this.bytes);
|
9135
|
+
input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
|
8891
9136
|
}
|
8892
9137
|
});
|
8893
9138
|
return request;
|
8894
9139
|
}
|
8895
|
-
/**
|
8896
|
-
* A helper that creates a transfer transaction request and returns it.
|
8897
|
-
*
|
8898
|
-
* @param destination - The address of the destination.
|
8899
|
-
* @param amount - The amount of coins to transfer.
|
8900
|
-
* @param assetId - The asset ID of the coins to transfer.
|
8901
|
-
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
8902
|
-
* @returns A promise that resolves to the prepared transaction request.
|
8903
|
-
*/
|
8904
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
8905
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
8906
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
8907
|
-
return this.populateTransactionPredicateData(request);
|
8908
|
-
}
|
8909
9140
|
/**
|
8910
9141
|
* Sends a transaction with the populated predicate data.
|
8911
9142
|
*
|
8912
9143
|
* @param transactionRequestLike - The transaction request-like object.
|
8913
9144
|
* @returns A promise that resolves to the transaction response.
|
8914
9145
|
*/
|
8915
|
-
sendTransaction(transactionRequestLike
|
8916
|
-
const transactionRequest =
|
8917
|
-
return super.sendTransaction(transactionRequest,
|
9146
|
+
sendTransaction(transactionRequestLike) {
|
9147
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9148
|
+
return super.sendTransaction(transactionRequest, { estimateTxDependencies: false });
|
8918
9149
|
}
|
8919
9150
|
/**
|
8920
9151
|
* Simulates a transaction with the populated predicate data.
|
@@ -8923,15 +9154,15 @@ var Predicate = class extends Account {
|
|
8923
9154
|
* @returns A promise that resolves to the call result.
|
8924
9155
|
*/
|
8925
9156
|
simulateTransaction(transactionRequestLike) {
|
8926
|
-
const transactionRequest =
|
8927
|
-
return super.simulateTransaction(transactionRequest);
|
9157
|
+
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9158
|
+
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
8928
9159
|
}
|
8929
9160
|
getPredicateData(policiesLength) {
|
8930
9161
|
if (!this.predicateData.length) {
|
8931
9162
|
return new Uint8Array();
|
8932
9163
|
}
|
8933
9164
|
const mainFn = this.interface?.functions.main;
|
8934
|
-
const paddedCode = new
|
9165
|
+
const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
|
8935
9166
|
const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
|
8936
9167
|
maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
|
8937
9168
|
});
|
@@ -8947,7 +9178,7 @@ var Predicate = class extends Account {
|
|
8947
9178
|
* @returns An object containing the new predicate bytes and interface.
|
8948
9179
|
*/
|
8949
9180
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
8950
|
-
let predicateBytes = (0,
|
9181
|
+
let predicateBytes = (0, import_utils36.arrayify)(bytes);
|
8951
9182
|
let abiInterface;
|
8952
9183
|
if (jsonAbi) {
|
8953
9184
|
abiInterface = new import_abi_coder7.Interface(jsonAbi);
|
@@ -8970,6 +9201,25 @@ var Predicate = class extends Account {
|
|
8970
9201
|
predicateInterface: abiInterface
|
8971
9202
|
};
|
8972
9203
|
}
|
9204
|
+
/**
|
9205
|
+
* Retrieves resources satisfying the spend query for the account.
|
9206
|
+
*
|
9207
|
+
* @param quantities - IDs of coins to exclude.
|
9208
|
+
* @param excludedIds - IDs of resources to be excluded from the query.
|
9209
|
+
* @returns A promise that resolves to an array of Resources.
|
9210
|
+
*/
|
9211
|
+
async getResourcesToSpend(quantities, excludedIds) {
|
9212
|
+
const resources = await this.provider.getResourcesToSpend(
|
9213
|
+
this.address,
|
9214
|
+
quantities,
|
9215
|
+
excludedIds
|
9216
|
+
);
|
9217
|
+
return resources.map((resource) => ({
|
9218
|
+
...resource,
|
9219
|
+
predicate: (0, import_utils36.hexlify)(this.bytes),
|
9220
|
+
padPredicateData: (policiesLength) => (0, import_utils36.hexlify)(this.getPredicateData(policiesLength))
|
9221
|
+
}));
|
9222
|
+
}
|
8973
9223
|
/**
|
8974
9224
|
* Sets the configurable constants for the predicate.
|
8975
9225
|
*
|
@@ -9719,7 +9969,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9719
9969
|
WalletLocked,
|
9720
9970
|
WalletManager,
|
9721
9971
|
WalletUnlocked,
|
9722
|
-
|
9972
|
+
addAmountToCoinQuantities,
|
9723
9973
|
addOperation,
|
9724
9974
|
assemblePanicError,
|
9725
9975
|
assembleReceiptByType,
|
@@ -9728,9 +9978,10 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9728
9978
|
assets,
|
9729
9979
|
buildBlockExplorerUrl,
|
9730
9980
|
cacheFor,
|
9981
|
+
cacheTxInputsFromOwner,
|
9982
|
+
calculateGasFee,
|
9731
9983
|
calculateMetadataGasForTxCreate,
|
9732
9984
|
calculateMetadataGasForTxScript,
|
9733
|
-
calculatePriceWithFactor,
|
9734
9985
|
calculateTransactionFee,
|
9735
9986
|
coinQuantityfy,
|
9736
9987
|
deferPromise,
|