@fuel-ts/account 0.0.0-rc-2217-20240503120735 → 0.0.0-rc-2224-20240503155836
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/index.global.js +449 -1266
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +155 -249
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +145 -237
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +80 -186
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/message.d.ts +2 -2
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +20 -23
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/script-transaction-request.d.ts +3 -2
- package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +3 -2
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -2
- package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +22 -0
- package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +1 -0
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/index.d.ts +1 -1
- package/dist/providers/transaction-summary/index.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts +0 -4
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/status.d.ts +1 -5
- package/dist/providers/transaction-summary/status.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +1 -6
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +5 -6
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +448 -1258
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +147 -229
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +138 -220
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +0 -20
- package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +0 -1
package/dist/test-utils.js
CHANGED
@@ -64,7 +64,7 @@ var import_utils30 = require("@fuel-ts/utils");
|
|
64
64
|
var import_address4 = require("@fuel-ts/address");
|
65
65
|
var import_errors16 = require("@fuel-ts/errors");
|
66
66
|
var import_interfaces = require("@fuel-ts/interfaces");
|
67
|
-
var
|
67
|
+
var import_math20 = require("@fuel-ts/math");
|
68
68
|
var import_utils27 = require("@fuel-ts/utils");
|
69
69
|
var import_ramda4 = require("ramda");
|
70
70
|
|
@@ -106,7 +106,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
106
106
|
// src/providers/provider.ts
|
107
107
|
var import_address3 = require("@fuel-ts/address");
|
108
108
|
var import_errors14 = require("@fuel-ts/errors");
|
109
|
-
var
|
109
|
+
var import_math16 = require("@fuel-ts/math");
|
110
110
|
var import_transactions19 = require("@fuel-ts/transactions");
|
111
111
|
var import_utils22 = require("@fuel-ts/utils");
|
112
112
|
var import_versions = require("@fuel-ts/versions");
|
@@ -167,6 +167,9 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
167
167
|
id
|
168
168
|
}
|
169
169
|
time
|
170
|
+
receipts {
|
171
|
+
...receiptFragment
|
172
|
+
}
|
170
173
|
programState {
|
171
174
|
returnType
|
172
175
|
data
|
@@ -174,15 +177,11 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
174
177
|
receipts {
|
175
178
|
...receiptFragment
|
176
179
|
}
|
177
|
-
totalGas
|
178
|
-
totalFee
|
179
180
|
}
|
180
181
|
... on FailureStatus {
|
181
182
|
block {
|
182
183
|
id
|
183
184
|
}
|
184
|
-
totalGas
|
185
|
-
totalFee
|
186
185
|
time
|
187
186
|
reason
|
188
187
|
receipts {
|
@@ -222,8 +221,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
|
|
222
221
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
223
222
|
var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
|
224
223
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
225
|
-
totalGas
|
226
|
-
totalFee
|
227
224
|
reason
|
228
225
|
programState {
|
229
226
|
returnType
|
@@ -233,8 +230,6 @@ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
|
|
233
230
|
`;
|
234
231
|
var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
|
235
232
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
236
|
-
totalGas
|
237
|
-
totalFee
|
238
233
|
programState {
|
239
234
|
returnType
|
240
235
|
data
|
@@ -370,7 +365,6 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
|
|
370
365
|
maxWitnesses
|
371
366
|
maxGasPerTx
|
372
367
|
maxSize
|
373
|
-
maxBytecodeSubsections
|
374
368
|
}
|
375
369
|
`;
|
376
370
|
var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
|
@@ -640,14 +634,6 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
|
|
640
634
|
nodeVersion
|
641
635
|
}
|
642
636
|
`;
|
643
|
-
var RelayedTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
|
644
|
-
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
645
|
-
... on RelayedTransactionFailed {
|
646
|
-
blockHeight
|
647
|
-
failure
|
648
|
-
}
|
649
|
-
}
|
650
|
-
`;
|
651
637
|
var GetVersionDocument = import_graphql_tag.default`
|
652
638
|
query getVersion {
|
653
639
|
nodeInfo {
|
@@ -877,13 +863,6 @@ var GetMessageStatusDocument = import_graphql_tag.default`
|
|
877
863
|
}
|
878
864
|
}
|
879
865
|
`;
|
880
|
-
var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
|
881
|
-
query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
|
882
|
-
relayedTransactionStatus(id: $relayedTransactionId) {
|
883
|
-
...relayedTransactionStatusFragment
|
884
|
-
}
|
885
|
-
}
|
886
|
-
${RelayedTransactionStatusFragmentFragmentDoc}`;
|
887
866
|
var DryRunDocument = import_graphql_tag.default`
|
888
867
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
889
868
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
@@ -998,9 +977,6 @@ function getSdk(requester) {
|
|
998
977
|
getMessageStatus(variables, options) {
|
999
978
|
return requester(GetMessageStatusDocument, variables, options);
|
1000
979
|
},
|
1001
|
-
getRelayedTransactionStatus(variables, options) {
|
1002
|
-
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
1003
|
-
},
|
1004
980
|
dryRun(variables, options) {
|
1005
981
|
return requester(DryRunDocument, variables, options);
|
1006
982
|
},
|
@@ -2113,11 +2089,8 @@ var BaseTransactionRequest = class {
|
|
2113
2089
|
* @hidden
|
2114
2090
|
*/
|
2115
2091
|
calculateMinGas(chainInfo) {
|
2116
|
-
const { consensusParameters } = chainInfo;
|
2117
|
-
const {
|
2118
|
-
gasCosts,
|
2119
|
-
feeParameters: { gasPerByte }
|
2120
|
-
} = consensusParameters;
|
2092
|
+
const { gasCosts, consensusParameters } = chainInfo;
|
2093
|
+
const { gasPerByte } = consensusParameters;
|
2121
2094
|
return getMinGas({
|
2122
2095
|
gasPerByte,
|
2123
2096
|
gasCosts,
|
@@ -2128,10 +2101,7 @@ var BaseTransactionRequest = class {
|
|
2128
2101
|
}
|
2129
2102
|
calculateMaxGas(chainInfo, minGas) {
|
2130
2103
|
const { consensusParameters } = chainInfo;
|
2131
|
-
const {
|
2132
|
-
feeParameters: { gasPerByte },
|
2133
|
-
txParameters: { maxGasPerTx }
|
2134
|
-
} = consensusParameters;
|
2104
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2135
2105
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2136
2106
|
(acc, wit) => acc + wit.dataLength,
|
2137
2107
|
0
|
@@ -2566,10 +2536,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2566
2536
|
}
|
2567
2537
|
calculateMaxGas(chainInfo, minGas) {
|
2568
2538
|
const { consensusParameters } = chainInfo;
|
2569
|
-
const {
|
2570
|
-
feeParameters: { gasPerByte },
|
2571
|
-
txParameters: { maxGasPerTx }
|
2572
|
-
} = consensusParameters;
|
2539
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2573
2540
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2574
2541
|
(acc, wit) => acc + wit.dataLength,
|
2575
2542
|
0
|
@@ -2673,40 +2640,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
|
2673
2640
|
|
2674
2641
|
// src/providers/transaction-response/transaction-response.ts
|
2675
2642
|
var import_errors13 = require("@fuel-ts/errors");
|
2676
|
-
var
|
2643
|
+
var import_math15 = require("@fuel-ts/math");
|
2677
2644
|
var import_transactions18 = require("@fuel-ts/transactions");
|
2678
2645
|
var import_utils20 = require("@fuel-ts/utils");
|
2679
2646
|
|
2680
2647
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2681
|
-
var
|
2648
|
+
var import_math14 = require("@fuel-ts/math");
|
2682
2649
|
var import_transactions16 = require("@fuel-ts/transactions");
|
2683
2650
|
var import_utils18 = require("@fuel-ts/utils");
|
2684
2651
|
|
2685
|
-
// src/providers/transaction-summary/calculate-
|
2652
|
+
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2686
2653
|
var import_math11 = require("@fuel-ts/math");
|
2687
2654
|
var import_transactions11 = require("@fuel-ts/transactions");
|
2688
2655
|
var import_utils16 = require("@fuel-ts/utils");
|
2689
|
-
var
|
2656
|
+
var calculateTransactionFee = (params) => {
|
2690
2657
|
const {
|
2691
2658
|
gasPrice,
|
2692
2659
|
rawPayload,
|
2693
2660
|
tip,
|
2694
|
-
totalFee,
|
2695
2661
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2696
2662
|
} = params;
|
2697
|
-
if (totalFee) {
|
2698
|
-
return totalFee;
|
2699
|
-
}
|
2700
2663
|
const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
|
2701
2664
|
const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
|
2702
2665
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2703
2666
|
const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
|
2667
|
+
if (transaction.type === import_transactions11.TransactionType.Mint) {
|
2668
|
+
return {
|
2669
|
+
fee: (0, import_math11.bn)(0),
|
2670
|
+
minFee: (0, import_math11.bn)(0),
|
2671
|
+
maxFee: (0, import_math11.bn)(0)
|
2672
|
+
};
|
2673
|
+
}
|
2704
2674
|
const { type, witnesses, inputs, policies } = transaction;
|
2705
2675
|
let metadataGas = (0, import_math11.bn)(0);
|
2706
2676
|
let gasLimit = (0, import_math11.bn)(0);
|
2707
|
-
if (type !== import_transactions11.TransactionType.Create && type !== import_transactions11.TransactionType.Script) {
|
2708
|
-
return (0, import_math11.bn)(0);
|
2709
|
-
}
|
2710
2677
|
if (type === import_transactions11.TransactionType.Create) {
|
2711
2678
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2712
2679
|
const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
@@ -2743,13 +2710,23 @@ var calculateTXFeeForSummary = (params) => {
|
|
2743
2710
|
witnessLimit,
|
2744
2711
|
maxGasPerTx
|
2745
2712
|
});
|
2713
|
+
const minFee = calculateGasFee({
|
2714
|
+
gasPrice,
|
2715
|
+
gas: minGas,
|
2716
|
+
priceFactor: gasPriceFactor,
|
2717
|
+
tip
|
2718
|
+
});
|
2746
2719
|
const maxFee = calculateGasFee({
|
2747
2720
|
gasPrice,
|
2748
2721
|
gas: maxGas,
|
2749
2722
|
priceFactor: gasPriceFactor,
|
2750
2723
|
tip
|
2751
2724
|
});
|
2752
|
-
return
|
2725
|
+
return {
|
2726
|
+
minFee,
|
2727
|
+
maxFee,
|
2728
|
+
fee: maxFee
|
2729
|
+
};
|
2753
2730
|
};
|
2754
2731
|
|
2755
2732
|
// src/providers/transaction-summary/operations.ts
|
@@ -2908,12 +2885,6 @@ function isTypeCreate(transactionType) {
|
|
2908
2885
|
function isTypeScript(transactionType) {
|
2909
2886
|
return isType(transactionType, "Script" /* Script */);
|
2910
2887
|
}
|
2911
|
-
function isTypeUpgrade(transactionType) {
|
2912
|
-
return isType(transactionType, "Upgrade" /* Upgrade */);
|
2913
|
-
}
|
2914
|
-
function isTypeUpload(transactionType) {
|
2915
|
-
return isType(transactionType, "Upload" /* Upload */);
|
2916
|
-
}
|
2917
2888
|
function getReceiptsCall(receipts) {
|
2918
2889
|
return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
|
2919
2890
|
}
|
@@ -3254,7 +3225,6 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3254
3225
|
|
3255
3226
|
// src/providers/transaction-summary/status.ts
|
3256
3227
|
var import_errors12 = require("@fuel-ts/errors");
|
3257
|
-
var import_math14 = require("@fuel-ts/math");
|
3258
3228
|
var getTransactionStatusName = (gqlStatus) => {
|
3259
3229
|
switch (gqlStatus) {
|
3260
3230
|
case "FailureStatus":
|
@@ -3276,8 +3246,6 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3276
3246
|
let time;
|
3277
3247
|
let blockId;
|
3278
3248
|
let status;
|
3279
|
-
let totalFee;
|
3280
|
-
let totalGas;
|
3281
3249
|
let isStatusFailure = false;
|
3282
3250
|
let isStatusSuccess = false;
|
3283
3251
|
let isStatusPending = false;
|
@@ -3288,15 +3256,11 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3288
3256
|
time = gqlTransactionStatus.time;
|
3289
3257
|
blockId = gqlTransactionStatus.block.id;
|
3290
3258
|
isStatusSuccess = true;
|
3291
|
-
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3292
|
-
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3293
3259
|
break;
|
3294
3260
|
case "FailureStatus":
|
3295
3261
|
time = gqlTransactionStatus.time;
|
3296
3262
|
blockId = gqlTransactionStatus.block.id;
|
3297
3263
|
isStatusFailure = true;
|
3298
|
-
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3299
|
-
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3300
3264
|
break;
|
3301
3265
|
case "SubmittedStatus":
|
3302
3266
|
time = gqlTransactionStatus.time;
|
@@ -3309,8 +3273,6 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3309
3273
|
time,
|
3310
3274
|
blockId,
|
3311
3275
|
status,
|
3312
|
-
totalFee,
|
3313
|
-
totalGas,
|
3314
3276
|
isStatusFailure,
|
3315
3277
|
isStatusSuccess,
|
3316
3278
|
isStatusPending
|
@@ -3346,10 +3308,8 @@ function assembleTransactionSummary(params) {
|
|
3346
3308
|
maxInputs
|
3347
3309
|
});
|
3348
3310
|
const typeName = getTransactionTypeName(transaction.type);
|
3349
|
-
const tip = (0,
|
3350
|
-
const {
|
3351
|
-
const fee = calculateTXFeeForSummary({
|
3352
|
-
totalFee,
|
3311
|
+
const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
|
3312
|
+
const { fee } = calculateTransactionFee({
|
3353
3313
|
gasPrice,
|
3354
3314
|
rawPayload,
|
3355
3315
|
tip,
|
@@ -3362,6 +3322,7 @@ function assembleTransactionSummary(params) {
|
|
3362
3322
|
}
|
3363
3323
|
}
|
3364
3324
|
});
|
3325
|
+
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
|
3365
3326
|
const mintedAssets = extractMintedAssetsFromReceipts(receipts);
|
3366
3327
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3367
3328
|
let date;
|
@@ -3370,7 +3331,6 @@ function assembleTransactionSummary(params) {
|
|
3370
3331
|
}
|
3371
3332
|
const transactionSummary = {
|
3372
3333
|
id,
|
3373
|
-
tip,
|
3374
3334
|
fee,
|
3375
3335
|
gasUsed,
|
3376
3336
|
operations,
|
@@ -3384,8 +3344,6 @@ function assembleTransactionSummary(params) {
|
|
3384
3344
|
isTypeMint: isTypeMint(transaction.type),
|
3385
3345
|
isTypeCreate: isTypeCreate(transaction.type),
|
3386
3346
|
isTypeScript: isTypeScript(transaction.type),
|
3387
|
-
isTypeUpgrade: isTypeUpgrade(transaction.type),
|
3388
|
-
isTypeUpload: isTypeUpload(transaction.type),
|
3389
3347
|
isStatusFailure,
|
3390
3348
|
isStatusSuccess,
|
3391
3349
|
isStatusPending,
|
@@ -3417,7 +3375,7 @@ var TransactionResponse = class {
|
|
3417
3375
|
/** Current provider */
|
3418
3376
|
provider;
|
3419
3377
|
/** Gas used on the transaction */
|
3420
|
-
gasUsed = (0,
|
3378
|
+
gasUsed = (0, import_math15.bn)(0);
|
3421
3379
|
/** The graphql Transaction with receipts object. */
|
3422
3380
|
gqlTransaction;
|
3423
3381
|
abis;
|
@@ -3502,7 +3460,7 @@ var TransactionResponse = class {
|
|
3502
3460
|
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3503
3461
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3504
3462
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3505
|
-
const maxInputs = this.provider.getChain().consensusParameters.
|
3463
|
+
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3506
3464
|
const transactionSummary = assembleTransactionSummary({
|
3507
3465
|
id: this.id,
|
3508
3466
|
receipts,
|
@@ -3638,60 +3596,33 @@ var mergeQuantities = (...coinQuantities) => {
|
|
3638
3596
|
var MAX_RETRIES = 10;
|
3639
3597
|
var processGqlChain = (chain) => {
|
3640
3598
|
const { name, daHeight, consensusParameters, latestBlock } = chain;
|
3641
|
-
const {
|
3642
|
-
contractParams,
|
3643
|
-
feeParams,
|
3644
|
-
predicateParams,
|
3645
|
-
scriptParams,
|
3646
|
-
txParams,
|
3647
|
-
gasCosts,
|
3648
|
-
baseAssetId,
|
3649
|
-
chainId,
|
3650
|
-
version
|
3651
|
-
} = consensusParameters;
|
3599
|
+
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3652
3600
|
return {
|
3653
3601
|
name,
|
3654
|
-
baseChainHeight: (0,
|
3602
|
+
baseChainHeight: (0, import_math16.bn)(daHeight),
|
3655
3603
|
consensusParameters: {
|
3656
|
-
|
3657
|
-
|
3658
|
-
|
3659
|
-
|
3660
|
-
|
3661
|
-
|
3662
|
-
|
3663
|
-
|
3664
|
-
|
3665
|
-
|
3666
|
-
|
3667
|
-
|
3668
|
-
|
3669
|
-
|
3670
|
-
|
3671
|
-
|
3672
|
-
maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
|
3673
|
-
maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
|
3674
|
-
maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
|
3675
|
-
maxSize: (0, import_math17.bn)(txParams.maxSize),
|
3676
|
-
maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
|
3677
|
-
},
|
3678
|
-
predicateParameters: {
|
3679
|
-
version: predicateParams.version,
|
3680
|
-
maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
|
3681
|
-
maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
|
3682
|
-
maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
|
3683
|
-
maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
|
3684
|
-
},
|
3685
|
-
scriptParameters: {
|
3686
|
-
version: scriptParams.version,
|
3687
|
-
maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
|
3688
|
-
maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
|
3689
|
-
},
|
3604
|
+
contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
|
3605
|
+
maxInputs: (0, import_math16.bn)(txParams.maxInputs),
|
3606
|
+
maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
|
3607
|
+
maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
|
3608
|
+
maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
|
3609
|
+
maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
|
3610
|
+
maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
|
3611
|
+
maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
|
3612
|
+
maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
|
3613
|
+
maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
|
3614
|
+
maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
|
3615
|
+
gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
|
3616
|
+
gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
|
3617
|
+
maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
|
3618
|
+
chainId: (0, import_math16.bn)(consensusParameters.chainId),
|
3619
|
+
baseAssetId: consensusParameters.baseAssetId,
|
3690
3620
|
gasCosts
|
3691
3621
|
},
|
3622
|
+
gasCosts,
|
3692
3623
|
latestBlock: {
|
3693
3624
|
id: latestBlock.id,
|
3694
|
-
height: (0,
|
3625
|
+
height: (0, import_math16.bn)(latestBlock.height),
|
3695
3626
|
time: latestBlock.header.time,
|
3696
3627
|
transactions: latestBlock.transactions.map((i) => ({
|
3697
3628
|
id: i.id
|
@@ -3785,12 +3716,7 @@ var _Provider = class {
|
|
3785
3716
|
* Returns some helpful parameters related to gas fees.
|
3786
3717
|
*/
|
3787
3718
|
getGasConfig() {
|
3788
|
-
const {
|
3789
|
-
txParameters: { maxGasPerTx },
|
3790
|
-
predicateParameters: { maxGasPerPredicate },
|
3791
|
-
feeParameters: { gasPriceFactor, gasPerByte },
|
3792
|
-
gasCosts
|
3793
|
-
} = this.getChain().consensusParameters;
|
3719
|
+
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3794
3720
|
return {
|
3795
3721
|
maxGasPerTx,
|
3796
3722
|
maxGasPerPredicate,
|
@@ -3825,9 +3751,11 @@ var _Provider = class {
|
|
3825
3751
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3826
3752
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
3827
3753
|
if (!isMajorSupported || !isMinorSupported) {
|
3828
|
-
|
3829
|
-
|
3830
|
-
|
3754
|
+
console.warn(
|
3755
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
|
3756
|
+
which is not supported by the version of the TS SDK that you are using.
|
3757
|
+
Things might or might not work as expected.
|
3758
|
+
Supported fuel-core version: ${supportedVersion}.`
|
3831
3759
|
);
|
3832
3760
|
}
|
3833
3761
|
}
|
@@ -3885,7 +3813,7 @@ var _Provider = class {
|
|
3885
3813
|
*/
|
3886
3814
|
async getBlockNumber() {
|
3887
3815
|
const { chain } = await this.operations.getChain();
|
3888
|
-
return (0,
|
3816
|
+
return (0, import_math16.bn)(chain.latestBlock.height, 10);
|
3889
3817
|
}
|
3890
3818
|
/**
|
3891
3819
|
* Returns the chain information.
|
@@ -3895,8 +3823,8 @@ var _Provider = class {
|
|
3895
3823
|
async fetchNode() {
|
3896
3824
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3897
3825
|
const processedNodeInfo = {
|
3898
|
-
maxDepth: (0,
|
3899
|
-
maxTx: (0,
|
3826
|
+
maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
|
3827
|
+
maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
|
3900
3828
|
nodeVersion: nodeInfo.nodeVersion,
|
3901
3829
|
utxoValidation: nodeInfo.utxoValidation,
|
3902
3830
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4000,9 +3928,9 @@ var _Provider = class {
|
|
4000
3928
|
encodedTransactions: encodedTransaction,
|
4001
3929
|
utxoValidation: utxoValidation || false
|
4002
3930
|
});
|
4003
|
-
const [{ receipts: rawReceipts, status
|
3931
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4004
3932
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4005
|
-
return { receipts,
|
3933
|
+
return { receipts, dryrunStatus: status };
|
4006
3934
|
}
|
4007
3935
|
/**
|
4008
3936
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -4013,7 +3941,7 @@ var _Provider = class {
|
|
4013
3941
|
async estimatePredicates(transactionRequest) {
|
4014
3942
|
const shouldEstimatePredicates = Boolean(
|
4015
3943
|
transactionRequest.inputs.find(
|
4016
|
-
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new
|
3944
|
+
(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()
|
4017
3945
|
)
|
4018
3946
|
);
|
4019
3947
|
if (!shouldEstimatePredicates) {
|
@@ -4028,7 +3956,7 @@ var _Provider = class {
|
|
4028
3956
|
} = response;
|
4029
3957
|
if (inputs) {
|
4030
3958
|
inputs.forEach((input, index) => {
|
4031
|
-
if ("predicateGasUsed" in input && (0,
|
3959
|
+
if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
|
4032
3960
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4033
3961
|
}
|
4034
3962
|
});
|
@@ -4056,7 +3984,7 @@ var _Provider = class {
|
|
4056
3984
|
let receipts = [];
|
4057
3985
|
const missingContractIds = [];
|
4058
3986
|
let outputVariables = 0;
|
4059
|
-
let
|
3987
|
+
let dryrunStatus;
|
4060
3988
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4061
3989
|
const {
|
4062
3990
|
dryRun: [{ receipts: rawReceipts, status }]
|
@@ -4065,7 +3993,7 @@ var _Provider = class {
|
|
4065
3993
|
utxoValidation: false
|
4066
3994
|
});
|
4067
3995
|
receipts = rawReceipts.map(processGqlReceipt);
|
4068
|
-
|
3996
|
+
dryrunStatus = status;
|
4069
3997
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
4070
3998
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
4071
3999
|
if (hasMissingOutputs) {
|
@@ -4087,7 +4015,7 @@ var _Provider = class {
|
|
4087
4015
|
receipts,
|
4088
4016
|
outputVariables,
|
4089
4017
|
missingContractIds,
|
4090
|
-
|
4018
|
+
dryrunStatus
|
4091
4019
|
};
|
4092
4020
|
}
|
4093
4021
|
/**
|
@@ -4105,7 +4033,7 @@ var _Provider = class {
|
|
4105
4033
|
receipts: [],
|
4106
4034
|
outputVariables: 0,
|
4107
4035
|
missingContractIds: [],
|
4108
|
-
|
4036
|
+
dryrunStatus: void 0
|
4109
4037
|
}));
|
4110
4038
|
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4111
4039
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
@@ -4130,7 +4058,7 @@ var _Provider = class {
|
|
4130
4058
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4131
4059
|
const result = results[requestIdx];
|
4132
4060
|
result.receipts = rawReceipts.map(processGqlReceipt);
|
4133
|
-
result.
|
4061
|
+
result.dryrunStatus = status;
|
4134
4062
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4135
4063
|
result.receipts
|
4136
4064
|
);
|
@@ -4167,7 +4095,7 @@ var _Provider = class {
|
|
4167
4095
|
});
|
4168
4096
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4169
4097
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4170
|
-
return { receipts,
|
4098
|
+
return { receipts, dryrunStatus: status };
|
4171
4099
|
});
|
4172
4100
|
return results;
|
4173
4101
|
}
|
@@ -4186,12 +4114,12 @@ var _Provider = class {
|
|
4186
4114
|
gasPrice = await this.estimateGasPrice(10);
|
4187
4115
|
}
|
4188
4116
|
const minFee = calculateGasFee({
|
4189
|
-
gasPrice: (0,
|
4117
|
+
gasPrice: (0, import_math16.bn)(gasPrice),
|
4190
4118
|
gas: minGas,
|
4191
4119
|
priceFactor: gasPriceFactor,
|
4192
4120
|
tip: transactionRequest.tip
|
4193
4121
|
}).add(1);
|
4194
|
-
let gasLimit = (0,
|
4122
|
+
let gasLimit = (0, import_math16.bn)(0);
|
4195
4123
|
if (transactionRequest.type === import_transactions19.TransactionType.Script) {
|
4196
4124
|
gasLimit = transactionRequest.gasLimit;
|
4197
4125
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4204,7 +4132,7 @@ var _Provider = class {
|
|
4204
4132
|
}
|
4205
4133
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4206
4134
|
const maxFee = calculateGasFee({
|
4207
|
-
gasPrice: (0,
|
4135
|
+
gasPrice: (0, import_math16.bn)(gasPrice),
|
4208
4136
|
gas: maxGas,
|
4209
4137
|
priceFactor: gasPriceFactor,
|
4210
4138
|
tip: transactionRequest.tip
|
@@ -4267,9 +4195,9 @@ var _Provider = class {
|
|
4267
4195
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4268
4196
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4269
4197
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4270
|
-
txRequestClone.maxFee = (0,
|
4198
|
+
txRequestClone.maxFee = (0, import_math16.bn)(0);
|
4271
4199
|
if (isScriptTransaction) {
|
4272
|
-
txRequestClone.gasLimit = (0,
|
4200
|
+
txRequestClone.gasLimit = (0, import_math16.bn)(0);
|
4273
4201
|
}
|
4274
4202
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4275
4203
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4286,10 +4214,9 @@ var _Provider = class {
|
|
4286
4214
|
transactionRequest: signedRequest
|
4287
4215
|
});
|
4288
4216
|
let receipts = [];
|
4289
|
-
let dryRunStatus;
|
4290
4217
|
let missingContractIds = [];
|
4291
4218
|
let outputVariables = 0;
|
4292
|
-
let gasUsed = (0,
|
4219
|
+
let gasUsed = (0, import_math16.bn)(0);
|
4293
4220
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4294
4221
|
txRequestClone.maxFee = maxFee;
|
4295
4222
|
if (isScriptTransaction) {
|
@@ -4297,7 +4224,10 @@ var _Provider = class {
|
|
4297
4224
|
if (signatureCallback) {
|
4298
4225
|
await signatureCallback(txRequestClone);
|
4299
4226
|
}
|
4300
|
-
|
4227
|
+
const result = await this.estimateTxDependencies(txRequestClone);
|
4228
|
+
receipts = result.receipts;
|
4229
|
+
outputVariables = result.outputVariables;
|
4230
|
+
missingContractIds = result.missingContractIds;
|
4301
4231
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4302
4232
|
txRequestClone.gasLimit = gasUsed;
|
4303
4233
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
@@ -4317,8 +4247,7 @@ var _Provider = class {
|
|
4317
4247
|
outputVariables,
|
4318
4248
|
missingContractIds,
|
4319
4249
|
addedSignatures,
|
4320
|
-
estimatedPredicates: txRequestClone.inputs
|
4321
|
-
dryRunStatus
|
4250
|
+
estimatedPredicates: txRequestClone.inputs
|
4322
4251
|
};
|
4323
4252
|
}
|
4324
4253
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4354,10 +4283,10 @@ var _Provider = class {
|
|
4354
4283
|
return coins.map((coin) => ({
|
4355
4284
|
id: coin.utxoId,
|
4356
4285
|
assetId: coin.assetId,
|
4357
|
-
amount: (0,
|
4286
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4358
4287
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4359
|
-
blockCreated: (0,
|
4360
|
-
txCreatedIdx: (0,
|
4288
|
+
blockCreated: (0, import_math16.bn)(coin.blockCreated),
|
4289
|
+
txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
|
4361
4290
|
}));
|
4362
4291
|
}
|
4363
4292
|
/**
|
@@ -4394,9 +4323,9 @@ var _Provider = class {
|
|
4394
4323
|
switch (coin.__typename) {
|
4395
4324
|
case "MessageCoin":
|
4396
4325
|
return {
|
4397
|
-
amount: (0,
|
4326
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4398
4327
|
assetId: coin.assetId,
|
4399
|
-
daHeight: (0,
|
4328
|
+
daHeight: (0, import_math16.bn)(coin.daHeight),
|
4400
4329
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4401
4330
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4402
4331
|
nonce: coin.nonce
|
@@ -4404,11 +4333,11 @@ var _Provider = class {
|
|
4404
4333
|
case "Coin":
|
4405
4334
|
return {
|
4406
4335
|
id: coin.utxoId,
|
4407
|
-
amount: (0,
|
4336
|
+
amount: (0, import_math16.bn)(coin.amount),
|
4408
4337
|
assetId: coin.assetId,
|
4409
4338
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4410
|
-
blockCreated: (0,
|
4411
|
-
txCreatedIdx: (0,
|
4339
|
+
blockCreated: (0, import_math16.bn)(coin.blockCreated),
|
4340
|
+
txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
|
4412
4341
|
};
|
4413
4342
|
default:
|
4414
4343
|
return null;
|
@@ -4425,13 +4354,13 @@ var _Provider = class {
|
|
4425
4354
|
async getBlock(idOrHeight) {
|
4426
4355
|
let variables;
|
4427
4356
|
if (typeof idOrHeight === "number") {
|
4428
|
-
variables = { height: (0,
|
4357
|
+
variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4429
4358
|
} else if (idOrHeight === "latest") {
|
4430
4359
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4431
4360
|
} else if (idOrHeight.length === 66) {
|
4432
4361
|
variables = { blockId: idOrHeight };
|
4433
4362
|
} else {
|
4434
|
-
variables = { blockId: (0,
|
4363
|
+
variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4435
4364
|
}
|
4436
4365
|
const { block } = await this.operations.getBlock(variables);
|
4437
4366
|
if (!block) {
|
@@ -4439,7 +4368,7 @@ var _Provider = class {
|
|
4439
4368
|
}
|
4440
4369
|
return {
|
4441
4370
|
id: block.id,
|
4442
|
-
height: (0,
|
4371
|
+
height: (0, import_math16.bn)(block.height),
|
4443
4372
|
time: block.header.time,
|
4444
4373
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4445
4374
|
};
|
@@ -4454,7 +4383,7 @@ var _Provider = class {
|
|
4454
4383
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4455
4384
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4456
4385
|
id: block.id,
|
4457
|
-
height: (0,
|
4386
|
+
height: (0, import_math16.bn)(block.height),
|
4458
4387
|
time: block.header.time,
|
4459
4388
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4460
4389
|
}));
|
@@ -4469,7 +4398,7 @@ var _Provider = class {
|
|
4469
4398
|
async getBlockWithTransactions(idOrHeight) {
|
4470
4399
|
let variables;
|
4471
4400
|
if (typeof idOrHeight === "number") {
|
4472
|
-
variables = { blockHeight: (0,
|
4401
|
+
variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
|
4473
4402
|
} else if (idOrHeight === "latest") {
|
4474
4403
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4475
4404
|
} else {
|
@@ -4481,7 +4410,7 @@ var _Provider = class {
|
|
4481
4410
|
}
|
4482
4411
|
return {
|
4483
4412
|
id: block.id,
|
4484
|
-
height: (0,
|
4413
|
+
height: (0, import_math16.bn)(block.height, 10),
|
4485
4414
|
time: block.header.time,
|
4486
4415
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4487
4416
|
transactions: block.transactions.map(
|
@@ -4530,7 +4459,7 @@ var _Provider = class {
|
|
4530
4459
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4531
4460
|
asset: (0, import_utils22.hexlify)(assetId)
|
4532
4461
|
});
|
4533
|
-
return (0,
|
4462
|
+
return (0, import_math16.bn)(contractBalance.amount, 10);
|
4534
4463
|
}
|
4535
4464
|
/**
|
4536
4465
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4544,7 +4473,7 @@ var _Provider = class {
|
|
4544
4473
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4545
4474
|
assetId: (0, import_utils22.hexlify)(assetId)
|
4546
4475
|
});
|
4547
|
-
return (0,
|
4476
|
+
return (0, import_math16.bn)(balance.amount, 10);
|
4548
4477
|
}
|
4549
4478
|
/**
|
4550
4479
|
* Returns balances for the given owner.
|
@@ -4562,7 +4491,7 @@ var _Provider = class {
|
|
4562
4491
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4563
4492
|
return balances.map((balance) => ({
|
4564
4493
|
assetId: balance.assetId,
|
4565
|
-
amount: (0,
|
4494
|
+
amount: (0, import_math16.bn)(balance.amount)
|
4566
4495
|
}));
|
4567
4496
|
}
|
4568
4497
|
/**
|
@@ -4584,15 +4513,15 @@ var _Provider = class {
|
|
4584
4513
|
sender: message.sender,
|
4585
4514
|
recipient: message.recipient,
|
4586
4515
|
nonce: message.nonce,
|
4587
|
-
amount: (0,
|
4516
|
+
amount: (0, import_math16.bn)(message.amount),
|
4588
4517
|
data: message.data
|
4589
4518
|
}),
|
4590
4519
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4591
4520
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4592
4521
|
nonce: message.nonce,
|
4593
|
-
amount: (0,
|
4522
|
+
amount: (0, import_math16.bn)(message.amount),
|
4594
4523
|
data: import_transactions19.InputMessageCoder.decodeData(message.data),
|
4595
|
-
daHeight: (0,
|
4524
|
+
daHeight: (0, import_math16.bn)(message.daHeight)
|
4596
4525
|
}));
|
4597
4526
|
}
|
4598
4527
|
/**
|
@@ -4645,59 +4574,59 @@ var _Provider = class {
|
|
4645
4574
|
} = result.messageProof;
|
4646
4575
|
return {
|
4647
4576
|
messageProof: {
|
4648
|
-
proofIndex: (0,
|
4577
|
+
proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
|
4649
4578
|
proofSet: messageProof.proofSet
|
4650
4579
|
},
|
4651
4580
|
blockProof: {
|
4652
|
-
proofIndex: (0,
|
4581
|
+
proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
|
4653
4582
|
proofSet: blockProof.proofSet
|
4654
4583
|
},
|
4655
4584
|
messageBlockHeader: {
|
4656
4585
|
id: messageBlockHeader.id,
|
4657
|
-
daHeight: (0,
|
4658
|
-
transactionsCount:
|
4586
|
+
daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
|
4587
|
+
transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
|
4659
4588
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4660
|
-
height: (0,
|
4589
|
+
height: (0, import_math16.bn)(messageBlockHeader.height),
|
4661
4590
|
prevRoot: messageBlockHeader.prevRoot,
|
4662
4591
|
time: messageBlockHeader.time,
|
4663
4592
|
applicationHash: messageBlockHeader.applicationHash,
|
4664
|
-
messageReceiptCount:
|
4593
|
+
messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
|
4665
4594
|
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4666
|
-
consensusParametersVersion:
|
4595
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4667
4596
|
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4668
|
-
stateTransitionBytecodeVersion:
|
4597
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4669
4598
|
},
|
4670
4599
|
commitBlockHeader: {
|
4671
4600
|
id: commitBlockHeader.id,
|
4672
|
-
daHeight: (0,
|
4673
|
-
transactionsCount:
|
4601
|
+
daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
|
4602
|
+
transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
|
4674
4603
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4675
|
-
height: (0,
|
4604
|
+
height: (0, import_math16.bn)(commitBlockHeader.height),
|
4676
4605
|
prevRoot: commitBlockHeader.prevRoot,
|
4677
4606
|
time: commitBlockHeader.time,
|
4678
4607
|
applicationHash: commitBlockHeader.applicationHash,
|
4679
|
-
messageReceiptCount:
|
4608
|
+
messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
|
4680
4609
|
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4681
|
-
consensusParametersVersion:
|
4610
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4682
4611
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4683
|
-
stateTransitionBytecodeVersion:
|
4612
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4684
4613
|
},
|
4685
4614
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4686
4615
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4687
4616
|
nonce,
|
4688
|
-
amount: (0,
|
4617
|
+
amount: (0, import_math16.bn)(amount),
|
4689
4618
|
data
|
4690
4619
|
};
|
4691
4620
|
}
|
4692
4621
|
async getLatestGasPrice() {
|
4693
4622
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4694
|
-
return (0,
|
4623
|
+
return (0, import_math16.bn)(latestGasPrice.gasPrice);
|
4695
4624
|
}
|
4696
4625
|
async estimateGasPrice(blockHorizon) {
|
4697
4626
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4698
4627
|
blockHorizon: String(blockHorizon)
|
4699
4628
|
});
|
4700
|
-
return (0,
|
4629
|
+
return (0, import_math16.bn)(estimateGasPrice.gasPrice);
|
4701
4630
|
}
|
4702
4631
|
/**
|
4703
4632
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4718,10 +4647,10 @@ var _Provider = class {
|
|
4718
4647
|
*/
|
4719
4648
|
async produceBlocks(amount, startTime) {
|
4720
4649
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4721
|
-
blocksToProduce: (0,
|
4650
|
+
blocksToProduce: (0, import_math16.bn)(amount).toString(10),
|
4722
4651
|
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4723
4652
|
});
|
4724
|
-
return (0,
|
4653
|
+
return (0, import_math16.bn)(latestBlockHeight);
|
4725
4654
|
}
|
4726
4655
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4727
4656
|
async getTransactionResponse(transactionId) {
|
@@ -4740,15 +4669,6 @@ var _Provider = class {
|
|
4740
4669
|
}
|
4741
4670
|
return message;
|
4742
4671
|
}
|
4743
|
-
async getRelayedTransactionStatus(relayedTransactionId) {
|
4744
|
-
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
4745
|
-
relayedTransactionId
|
4746
|
-
});
|
4747
|
-
if (!relayedTransactionStatus) {
|
4748
|
-
return null;
|
4749
|
-
}
|
4750
|
-
return relayedTransactionStatus;
|
4751
|
-
}
|
4752
4672
|
};
|
4753
4673
|
var Provider = _Provider;
|
4754
4674
|
_cacheInputs = new WeakSet();
|
@@ -4767,7 +4687,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4767
4687
|
|
4768
4688
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4769
4689
|
var import_errors15 = require("@fuel-ts/errors");
|
4770
|
-
var
|
4690
|
+
var import_math17 = require("@fuel-ts/math");
|
4771
4691
|
var import_transactions20 = require("@fuel-ts/transactions");
|
4772
4692
|
var import_utils25 = require("@fuel-ts/utils");
|
4773
4693
|
|
@@ -4817,7 +4737,7 @@ var assets = [
|
|
4817
4737
|
];
|
4818
4738
|
|
4819
4739
|
// src/providers/transaction-request/helpers.ts
|
4820
|
-
var
|
4740
|
+
var import_math18 = require("@fuel-ts/math");
|
4821
4741
|
var import_transactions21 = require("@fuel-ts/transactions");
|
4822
4742
|
var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
|
4823
4743
|
var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
|
@@ -4830,17 +4750,17 @@ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filte
|
|
4830
4750
|
return acc.add(input.amount);
|
4831
4751
|
}
|
4832
4752
|
return acc;
|
4833
|
-
}, (0,
|
4753
|
+
}, (0, import_math18.bn)(0));
|
4834
4754
|
|
4835
4755
|
// src/utils/formatTransferToContractScriptData.ts
|
4836
4756
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4837
|
-
var
|
4757
|
+
var import_math19 = require("@fuel-ts/math");
|
4838
4758
|
var import_utils26 = require("@fuel-ts/utils");
|
4839
4759
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4840
4760
|
var formatTransferToContractScriptData = (params) => {
|
4841
4761
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4842
4762
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
4843
|
-
const encoded = numberCoder.encode(new
|
4763
|
+
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
4844
4764
|
const scriptData = Uint8Array.from([
|
4845
4765
|
...(0, import_utils26.arrayify)(hexlifiedContractId),
|
4846
4766
|
...encoded,
|
@@ -5034,10 +4954,10 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5034
4954
|
async fund(request, params) {
|
5035
4955
|
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
5036
4956
|
const baseAssetId = this.provider.getBaseAssetId();
|
5037
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0,
|
4957
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
|
5038
4958
|
const txRequest = request;
|
5039
4959
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5040
|
-
amount: (0,
|
4960
|
+
amount: (0, import_math20.bn)(fee),
|
5041
4961
|
assetId: baseAssetId,
|
5042
4962
|
coinQuantities: requiredQuantities
|
5043
4963
|
});
|
@@ -5045,7 +4965,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5045
4965
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5046
4966
|
quantitiesDict[assetId] = {
|
5047
4967
|
required: amount,
|
5048
|
-
owned: (0,
|
4968
|
+
owned: (0, import_math20.bn)(0)
|
5049
4969
|
};
|
5050
4970
|
});
|
5051
4971
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5150,7 +5070,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5150
5070
|
* @returns A promise that resolves to the transaction response.
|
5151
5071
|
*/
|
5152
5072
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5153
|
-
if ((0,
|
5073
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5154
5074
|
throw new import_errors16.FuelError(
|
5155
5075
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5156
5076
|
"Transfer amount must be a positive number."
|
@@ -5170,7 +5090,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5170
5090
|
* @returns A promise that resolves to the transaction response.
|
5171
5091
|
*/
|
5172
5092
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5173
|
-
if ((0,
|
5093
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5174
5094
|
throw new import_errors16.FuelError(
|
5175
5095
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5176
5096
|
"Transfer amount must be a positive number."
|
@@ -5180,7 +5100,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5180
5100
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5181
5101
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5182
5102
|
hexlifiedContractId: contractAddress.toB256(),
|
5183
|
-
amountToTransfer: (0,
|
5103
|
+
amountToTransfer: (0, import_math20.bn)(amount),
|
5184
5104
|
assetId: assetIdToTransfer
|
5185
5105
|
});
|
5186
5106
|
const request = new ScriptTransactionRequest({
|
@@ -5191,7 +5111,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5191
5111
|
request.addContractInputAndOutput(contractAddress);
|
5192
5112
|
const txCost = await this.provider.getTransactionCost(request, {
|
5193
5113
|
resourcesOwner: this,
|
5194
|
-
quantitiesToContract: [{ amount: (0,
|
5114
|
+
quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5195
5115
|
});
|
5196
5116
|
this.validateGasLimitAndMaxFee({
|
5197
5117
|
gasUsed: txCost.gasUsed,
|
@@ -5217,7 +5137,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5217
5137
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5218
5138
|
);
|
5219
5139
|
const amountDataArray = (0, import_utils27.arrayify)(
|
5220
|
-
"0x".concat((0,
|
5140
|
+
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5221
5141
|
);
|
5222
5142
|
const script = new Uint8Array([
|
5223
5143
|
...(0, import_utils27.arrayify)(withdrawScript.bytes),
|
@@ -5227,7 +5147,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5227
5147
|
const params = { script, ...txParams };
|
5228
5148
|
const baseAssetId = this.provider.getBaseAssetId();
|
5229
5149
|
const request = new ScriptTransactionRequest(params);
|
5230
|
-
const quantitiesToContract = [{ amount: (0,
|
5150
|
+
const quantitiesToContract = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
|
5231
5151
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5232
5152
|
this.validateGasLimitAndMaxFee({
|
5233
5153
|
gasUsed: txCost.gasUsed,
|
@@ -5318,7 +5238,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5318
5238
|
var import_address5 = require("@fuel-ts/address");
|
5319
5239
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5320
5240
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5321
|
-
var
|
5241
|
+
var import_math21 = require("@fuel-ts/math");
|
5322
5242
|
var import_utils28 = require("@fuel-ts/utils");
|
5323
5243
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5324
5244
|
var Signer = class {
|
@@ -5338,7 +5258,7 @@ var Signer = class {
|
|
5338
5258
|
privateKey = `0x${privateKey}`;
|
5339
5259
|
}
|
5340
5260
|
}
|
5341
|
-
const privateKeyBytes = (0,
|
5261
|
+
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
5342
5262
|
this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
|
5343
5263
|
this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5344
5264
|
this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
@@ -5356,8 +5276,8 @@ var Signer = class {
|
|
5356
5276
|
*/
|
5357
5277
|
sign(data) {
|
5358
5278
|
const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
|
5359
|
-
const r = (0,
|
5360
|
-
const s = (0,
|
5279
|
+
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5280
|
+
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5361
5281
|
s[0] |= (signature.recovery || 0) << 7;
|
5362
5282
|
return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
|
5363
5283
|
}
|
@@ -5629,7 +5549,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5629
5549
|
// src/hdwallet/hdwallet.ts
|
5630
5550
|
var import_errors20 = require("@fuel-ts/errors");
|
5631
5551
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5632
|
-
var
|
5552
|
+
var import_math22 = require("@fuel-ts/math");
|
5633
5553
|
var import_utils34 = require("@fuel-ts/utils");
|
5634
5554
|
var import_ethers2 = require("ethers");
|
5635
5555
|
|
@@ -8089,13 +8009,13 @@ var HDWallet = class {
|
|
8089
8009
|
} else {
|
8090
8010
|
data.set((0, import_utils34.arrayify)(this.publicKey));
|
8091
8011
|
}
|
8092
|
-
data.set((0,
|
8012
|
+
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8093
8013
|
const bytes = (0, import_utils34.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
|
8094
8014
|
const IL = bytes.slice(0, 32);
|
8095
8015
|
const IR = bytes.slice(32);
|
8096
8016
|
if (privateKey) {
|
8097
8017
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8098
|
-
const ki = (0,
|
8018
|
+
const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
8099
8019
|
return new HDWallet({
|
8100
8020
|
privateKey: ki,
|
8101
8021
|
chainCode: IR,
|
@@ -8141,7 +8061,7 @@ var HDWallet = class {
|
|
8141
8061
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8142
8062
|
const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
|
8143
8063
|
const parentFingerprint = this.parentFingerprint;
|
8144
|
-
const index = (0,
|
8064
|
+
const index = (0, import_math22.toHex)(this.index, 4);
|
8145
8065
|
const chainCode = this.chainCode;
|
8146
8066
|
const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8147
8067
|
const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
@@ -8510,11 +8430,9 @@ var launchNode = async ({
|
|
8510
8430
|
const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
|
8511
8431
|
const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
|
8512
8432
|
const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
|
8513
|
-
const stateTransitionWritePath = import_path.default.join(tempDirPath, "state_transition_bytecode.wasm");
|
8514
8433
|
(0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8515
8434
|
(0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8516
8435
|
(0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8517
|
-
(0, import_fs.writeFileSync)(stateTransitionWritePath, JSON.stringify(""));
|
8518
8436
|
snapshotDirToUse = tempDirPath;
|
8519
8437
|
}
|
8520
8438
|
const child = (0, import_child_process.spawn)(
|