@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.mjs
CHANGED
@@ -26,7 +26,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
|
26
26
|
import { Address as Address3 } from "@fuel-ts/address";
|
27
27
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
28
28
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
29
|
-
import { bn as
|
29
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
30
30
|
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
31
31
|
import { clone as clone4 } from "ramda";
|
32
32
|
|
@@ -68,7 +68,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
68
68
|
// src/providers/provider.ts
|
69
69
|
import { Address as Address2 } from "@fuel-ts/address";
|
70
70
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
71
|
-
import { BN, bn as
|
71
|
+
import { BN, bn as bn16 } from "@fuel-ts/math";
|
72
72
|
import {
|
73
73
|
InputType as InputType7,
|
74
74
|
TransactionType as TransactionType8,
|
@@ -134,6 +134,9 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
134
134
|
id
|
135
135
|
}
|
136
136
|
time
|
137
|
+
receipts {
|
138
|
+
...receiptFragment
|
139
|
+
}
|
137
140
|
programState {
|
138
141
|
returnType
|
139
142
|
data
|
@@ -141,15 +144,11 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
141
144
|
receipts {
|
142
145
|
...receiptFragment
|
143
146
|
}
|
144
|
-
totalGas
|
145
|
-
totalFee
|
146
147
|
}
|
147
148
|
... on FailureStatus {
|
148
149
|
block {
|
149
150
|
id
|
150
151
|
}
|
151
|
-
totalGas
|
152
|
-
totalFee
|
153
152
|
time
|
154
153
|
reason
|
155
154
|
receipts {
|
@@ -189,8 +188,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
189
188
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
190
189
|
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
191
190
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
192
|
-
totalGas
|
193
|
-
totalFee
|
194
191
|
reason
|
195
192
|
programState {
|
196
193
|
returnType
|
@@ -200,8 +197,6 @@ var DryRunFailureStatusFragmentFragmentDoc = gql`
|
|
200
197
|
`;
|
201
198
|
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
202
199
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
203
|
-
totalGas
|
204
|
-
totalFee
|
205
200
|
programState {
|
206
201
|
returnType
|
207
202
|
data
|
@@ -337,7 +332,6 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
337
332
|
maxWitnesses
|
338
333
|
maxGasPerTx
|
339
334
|
maxSize
|
340
|
-
maxBytecodeSubsections
|
341
335
|
}
|
342
336
|
`;
|
343
337
|
var PredicateParametersFragmentFragmentDoc = gql`
|
@@ -607,14 +601,6 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
607
601
|
nodeVersion
|
608
602
|
}
|
609
603
|
`;
|
610
|
-
var RelayedTransactionStatusFragmentFragmentDoc = gql`
|
611
|
-
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
612
|
-
... on RelayedTransactionFailed {
|
613
|
-
blockHeight
|
614
|
-
failure
|
615
|
-
}
|
616
|
-
}
|
617
|
-
`;
|
618
604
|
var GetVersionDocument = gql`
|
619
605
|
query getVersion {
|
620
606
|
nodeInfo {
|
@@ -844,13 +830,6 @@ var GetMessageStatusDocument = gql`
|
|
844
830
|
}
|
845
831
|
}
|
846
832
|
`;
|
847
|
-
var GetRelayedTransactionStatusDocument = gql`
|
848
|
-
query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
|
849
|
-
relayedTransactionStatus(id: $relayedTransactionId) {
|
850
|
-
...relayedTransactionStatusFragment
|
851
|
-
}
|
852
|
-
}
|
853
|
-
${RelayedTransactionStatusFragmentFragmentDoc}`;
|
854
833
|
var DryRunDocument = gql`
|
855
834
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
856
835
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
@@ -965,9 +944,6 @@ function getSdk(requester) {
|
|
965
944
|
getMessageStatus(variables, options) {
|
966
945
|
return requester(GetMessageStatusDocument, variables, options);
|
967
946
|
},
|
968
|
-
getRelayedTransactionStatus(variables, options) {
|
969
|
-
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
970
|
-
},
|
971
947
|
dryRun(variables, options) {
|
972
948
|
return requester(DryRunDocument, variables, options);
|
973
949
|
},
|
@@ -2099,11 +2075,8 @@ var BaseTransactionRequest = class {
|
|
2099
2075
|
* @hidden
|
2100
2076
|
*/
|
2101
2077
|
calculateMinGas(chainInfo) {
|
2102
|
-
const { consensusParameters } = chainInfo;
|
2103
|
-
const {
|
2104
|
-
gasCosts,
|
2105
|
-
feeParameters: { gasPerByte }
|
2106
|
-
} = consensusParameters;
|
2078
|
+
const { gasCosts, consensusParameters } = chainInfo;
|
2079
|
+
const { gasPerByte } = consensusParameters;
|
2107
2080
|
return getMinGas({
|
2108
2081
|
gasPerByte,
|
2109
2082
|
gasCosts,
|
@@ -2114,10 +2087,7 @@ var BaseTransactionRequest = class {
|
|
2114
2087
|
}
|
2115
2088
|
calculateMaxGas(chainInfo, minGas) {
|
2116
2089
|
const { consensusParameters } = chainInfo;
|
2117
|
-
const {
|
2118
|
-
feeParameters: { gasPerByte },
|
2119
|
-
txParameters: { maxGasPerTx }
|
2120
|
-
} = consensusParameters;
|
2090
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2121
2091
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2122
2092
|
(acc, wit) => acc + wit.dataLength,
|
2123
2093
|
0
|
@@ -2552,10 +2522,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2552
2522
|
}
|
2553
2523
|
calculateMaxGas(chainInfo, minGas) {
|
2554
2524
|
const { consensusParameters } = chainInfo;
|
2555
|
-
const {
|
2556
|
-
feeParameters: { gasPerByte },
|
2557
|
-
txParameters: { maxGasPerTx }
|
2558
|
-
} = consensusParameters;
|
2525
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2559
2526
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2560
2527
|
(acc, wit) => acc + wit.dataLength,
|
2561
2528
|
0
|
@@ -2659,40 +2626,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
|
2659
2626
|
|
2660
2627
|
// src/providers/transaction-response/transaction-response.ts
|
2661
2628
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2662
|
-
import { bn as
|
2629
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2663
2630
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2664
2631
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2665
2632
|
|
2666
2633
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2667
|
-
import { bn as
|
2634
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2668
2635
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2669
2636
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2670
2637
|
|
2671
|
-
// src/providers/transaction-summary/calculate-
|
2638
|
+
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2672
2639
|
import { bn as bn11 } from "@fuel-ts/math";
|
2673
2640
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2674
2641
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2675
|
-
var
|
2642
|
+
var calculateTransactionFee = (params) => {
|
2676
2643
|
const {
|
2677
2644
|
gasPrice,
|
2678
2645
|
rawPayload,
|
2679
2646
|
tip,
|
2680
|
-
totalFee,
|
2681
2647
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2682
2648
|
} = params;
|
2683
|
-
if (totalFee) {
|
2684
|
-
return totalFee;
|
2685
|
-
}
|
2686
2649
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2687
2650
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
2688
2651
|
const transactionBytes = arrayify9(rawPayload);
|
2689
2652
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2653
|
+
if (transaction.type === TransactionType6.Mint) {
|
2654
|
+
return {
|
2655
|
+
fee: bn11(0),
|
2656
|
+
minFee: bn11(0),
|
2657
|
+
maxFee: bn11(0)
|
2658
|
+
};
|
2659
|
+
}
|
2690
2660
|
const { type, witnesses, inputs, policies } = transaction;
|
2691
2661
|
let metadataGas = bn11(0);
|
2692
2662
|
let gasLimit = bn11(0);
|
2693
|
-
if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
|
2694
|
-
return bn11(0);
|
2695
|
-
}
|
2696
2663
|
if (type === TransactionType6.Create) {
|
2697
2664
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2698
2665
|
const contractBytesSize = bn11(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
@@ -2729,13 +2696,23 @@ var calculateTXFeeForSummary = (params) => {
|
|
2729
2696
|
witnessLimit,
|
2730
2697
|
maxGasPerTx
|
2731
2698
|
});
|
2699
|
+
const minFee = calculateGasFee({
|
2700
|
+
gasPrice,
|
2701
|
+
gas: minGas,
|
2702
|
+
priceFactor: gasPriceFactor,
|
2703
|
+
tip
|
2704
|
+
});
|
2732
2705
|
const maxFee = calculateGasFee({
|
2733
2706
|
gasPrice,
|
2734
2707
|
gas: maxGas,
|
2735
2708
|
priceFactor: gasPriceFactor,
|
2736
2709
|
tip
|
2737
2710
|
});
|
2738
|
-
return
|
2711
|
+
return {
|
2712
|
+
minFee,
|
2713
|
+
maxFee,
|
2714
|
+
fee: maxFee
|
2715
|
+
};
|
2739
2716
|
};
|
2740
2717
|
|
2741
2718
|
// src/providers/transaction-summary/operations.ts
|
@@ -2894,12 +2871,6 @@ function isTypeCreate(transactionType) {
|
|
2894
2871
|
function isTypeScript(transactionType) {
|
2895
2872
|
return isType(transactionType, "Script" /* Script */);
|
2896
2873
|
}
|
2897
|
-
function isTypeUpgrade(transactionType) {
|
2898
|
-
return isType(transactionType, "Upgrade" /* Upgrade */);
|
2899
|
-
}
|
2900
|
-
function isTypeUpload(transactionType) {
|
2901
|
-
return isType(transactionType, "Upload" /* Upload */);
|
2902
|
-
}
|
2903
2874
|
function getReceiptsCall(receipts) {
|
2904
2875
|
return getReceiptsByType(receipts, ReceiptType4.Call);
|
2905
2876
|
}
|
@@ -3240,7 +3211,6 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3240
3211
|
|
3241
3212
|
// src/providers/transaction-summary/status.ts
|
3242
3213
|
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3243
|
-
import { bn as bn14 } from "@fuel-ts/math";
|
3244
3214
|
var getTransactionStatusName = (gqlStatus) => {
|
3245
3215
|
switch (gqlStatus) {
|
3246
3216
|
case "FailureStatus":
|
@@ -3262,8 +3232,6 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3262
3232
|
let time;
|
3263
3233
|
let blockId;
|
3264
3234
|
let status;
|
3265
|
-
let totalFee;
|
3266
|
-
let totalGas;
|
3267
3235
|
let isStatusFailure = false;
|
3268
3236
|
let isStatusSuccess = false;
|
3269
3237
|
let isStatusPending = false;
|
@@ -3274,15 +3242,11 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3274
3242
|
time = gqlTransactionStatus.time;
|
3275
3243
|
blockId = gqlTransactionStatus.block.id;
|
3276
3244
|
isStatusSuccess = true;
|
3277
|
-
totalFee = bn14(gqlTransactionStatus.totalFee);
|
3278
|
-
totalGas = bn14(gqlTransactionStatus.totalGas);
|
3279
3245
|
break;
|
3280
3246
|
case "FailureStatus":
|
3281
3247
|
time = gqlTransactionStatus.time;
|
3282
3248
|
blockId = gqlTransactionStatus.block.id;
|
3283
3249
|
isStatusFailure = true;
|
3284
|
-
totalFee = bn14(gqlTransactionStatus.totalFee);
|
3285
|
-
totalGas = bn14(gqlTransactionStatus.totalGas);
|
3286
3250
|
break;
|
3287
3251
|
case "SubmittedStatus":
|
3288
3252
|
time = gqlTransactionStatus.time;
|
@@ -3295,8 +3259,6 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3295
3259
|
time,
|
3296
3260
|
blockId,
|
3297
3261
|
status,
|
3298
|
-
totalFee,
|
3299
|
-
totalGas,
|
3300
3262
|
isStatusFailure,
|
3301
3263
|
isStatusSuccess,
|
3302
3264
|
isStatusPending
|
@@ -3332,10 +3294,8 @@ function assembleTransactionSummary(params) {
|
|
3332
3294
|
maxInputs
|
3333
3295
|
});
|
3334
3296
|
const typeName = getTransactionTypeName(transaction.type);
|
3335
|
-
const tip =
|
3336
|
-
const {
|
3337
|
-
const fee = calculateTXFeeForSummary({
|
3338
|
-
totalFee,
|
3297
|
+
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3298
|
+
const { fee } = calculateTransactionFee({
|
3339
3299
|
gasPrice,
|
3340
3300
|
rawPayload,
|
3341
3301
|
tip,
|
@@ -3348,6 +3308,7 @@ function assembleTransactionSummary(params) {
|
|
3348
3308
|
}
|
3349
3309
|
}
|
3350
3310
|
});
|
3311
|
+
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
|
3351
3312
|
const mintedAssets = extractMintedAssetsFromReceipts(receipts);
|
3352
3313
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3353
3314
|
let date;
|
@@ -3356,7 +3317,6 @@ function assembleTransactionSummary(params) {
|
|
3356
3317
|
}
|
3357
3318
|
const transactionSummary = {
|
3358
3319
|
id,
|
3359
|
-
tip,
|
3360
3320
|
fee,
|
3361
3321
|
gasUsed,
|
3362
3322
|
operations,
|
@@ -3370,8 +3330,6 @@ function assembleTransactionSummary(params) {
|
|
3370
3330
|
isTypeMint: isTypeMint(transaction.type),
|
3371
3331
|
isTypeCreate: isTypeCreate(transaction.type),
|
3372
3332
|
isTypeScript: isTypeScript(transaction.type),
|
3373
|
-
isTypeUpgrade: isTypeUpgrade(transaction.type),
|
3374
|
-
isTypeUpload: isTypeUpload(transaction.type),
|
3375
3333
|
isStatusFailure,
|
3376
3334
|
isStatusSuccess,
|
3377
3335
|
isStatusPending,
|
@@ -3403,7 +3361,7 @@ var TransactionResponse = class {
|
|
3403
3361
|
/** Current provider */
|
3404
3362
|
provider;
|
3405
3363
|
/** Gas used on the transaction */
|
3406
|
-
gasUsed =
|
3364
|
+
gasUsed = bn15(0);
|
3407
3365
|
/** The graphql Transaction with receipts object. */
|
3408
3366
|
gqlTransaction;
|
3409
3367
|
abis;
|
@@ -3488,7 +3446,7 @@ var TransactionResponse = class {
|
|
3488
3446
|
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3489
3447
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3490
3448
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3491
|
-
const maxInputs = this.provider.getChain().consensusParameters.
|
3449
|
+
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3492
3450
|
const transactionSummary = assembleTransactionSummary({
|
3493
3451
|
id: this.id,
|
3494
3452
|
receipts,
|
@@ -3624,60 +3582,33 @@ var mergeQuantities = (...coinQuantities) => {
|
|
3624
3582
|
var MAX_RETRIES = 10;
|
3625
3583
|
var processGqlChain = (chain) => {
|
3626
3584
|
const { name, daHeight, consensusParameters, latestBlock } = chain;
|
3627
|
-
const {
|
3628
|
-
contractParams,
|
3629
|
-
feeParams,
|
3630
|
-
predicateParams,
|
3631
|
-
scriptParams,
|
3632
|
-
txParams,
|
3633
|
-
gasCosts,
|
3634
|
-
baseAssetId,
|
3635
|
-
chainId,
|
3636
|
-
version
|
3637
|
-
} = consensusParameters;
|
3585
|
+
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3638
3586
|
return {
|
3639
3587
|
name,
|
3640
|
-
baseChainHeight:
|
3588
|
+
baseChainHeight: bn16(daHeight),
|
3641
3589
|
consensusParameters: {
|
3642
|
-
|
3643
|
-
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3649
|
-
|
3650
|
-
|
3651
|
-
|
3652
|
-
|
3653
|
-
|
3654
|
-
|
3655
|
-
|
3656
|
-
|
3657
|
-
|
3658
|
-
maxOutputs: bn17(txParams.maxOutputs),
|
3659
|
-
maxWitnesses: bn17(txParams.maxWitnesses),
|
3660
|
-
maxGasPerTx: bn17(txParams.maxGasPerTx),
|
3661
|
-
maxSize: bn17(txParams.maxSize),
|
3662
|
-
maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
|
3663
|
-
},
|
3664
|
-
predicateParameters: {
|
3665
|
-
version: predicateParams.version,
|
3666
|
-
maxPredicateLength: bn17(predicateParams.maxPredicateLength),
|
3667
|
-
maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
|
3668
|
-
maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
|
3669
|
-
maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
|
3670
|
-
},
|
3671
|
-
scriptParameters: {
|
3672
|
-
version: scriptParams.version,
|
3673
|
-
maxScriptLength: bn17(scriptParams.maxScriptLength),
|
3674
|
-
maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
|
3675
|
-
},
|
3590
|
+
contractMaxSize: bn16(contractParams.contractMaxSize),
|
3591
|
+
maxInputs: bn16(txParams.maxInputs),
|
3592
|
+
maxOutputs: bn16(txParams.maxOutputs),
|
3593
|
+
maxWitnesses: bn16(txParams.maxWitnesses),
|
3594
|
+
maxGasPerTx: bn16(txParams.maxGasPerTx),
|
3595
|
+
maxScriptLength: bn16(scriptParams.maxScriptLength),
|
3596
|
+
maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
|
3597
|
+
maxStorageSlots: bn16(contractParams.maxStorageSlots),
|
3598
|
+
maxPredicateLength: bn16(predicateParams.maxPredicateLength),
|
3599
|
+
maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
|
3600
|
+
maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
|
3601
|
+
gasPriceFactor: bn16(feeParams.gasPriceFactor),
|
3602
|
+
gasPerByte: bn16(feeParams.gasPerByte),
|
3603
|
+
maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
|
3604
|
+
chainId: bn16(consensusParameters.chainId),
|
3605
|
+
baseAssetId: consensusParameters.baseAssetId,
|
3676
3606
|
gasCosts
|
3677
3607
|
},
|
3608
|
+
gasCosts,
|
3678
3609
|
latestBlock: {
|
3679
3610
|
id: latestBlock.id,
|
3680
|
-
height:
|
3611
|
+
height: bn16(latestBlock.height),
|
3681
3612
|
time: latestBlock.header.time,
|
3682
3613
|
transactions: latestBlock.transactions.map((i) => ({
|
3683
3614
|
id: i.id
|
@@ -3771,12 +3702,7 @@ var _Provider = class {
|
|
3771
3702
|
* Returns some helpful parameters related to gas fees.
|
3772
3703
|
*/
|
3773
3704
|
getGasConfig() {
|
3774
|
-
const {
|
3775
|
-
txParameters: { maxGasPerTx },
|
3776
|
-
predicateParameters: { maxGasPerPredicate },
|
3777
|
-
feeParameters: { gasPriceFactor, gasPerByte },
|
3778
|
-
gasCosts
|
3779
|
-
} = this.getChain().consensusParameters;
|
3705
|
+
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3780
3706
|
return {
|
3781
3707
|
maxGasPerTx,
|
3782
3708
|
maxGasPerPredicate,
|
@@ -3811,9 +3737,11 @@ var _Provider = class {
|
|
3811
3737
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3812
3738
|
const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
|
3813
3739
|
if (!isMajorSupported || !isMinorSupported) {
|
3814
|
-
|
3815
|
-
|
3816
|
-
|
3740
|
+
console.warn(
|
3741
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
|
3742
|
+
which is not supported by the version of the TS SDK that you are using.
|
3743
|
+
Things might or might not work as expected.
|
3744
|
+
Supported fuel-core version: ${supportedVersion}.`
|
3817
3745
|
);
|
3818
3746
|
}
|
3819
3747
|
}
|
@@ -3871,7 +3799,7 @@ var _Provider = class {
|
|
3871
3799
|
*/
|
3872
3800
|
async getBlockNumber() {
|
3873
3801
|
const { chain } = await this.operations.getChain();
|
3874
|
-
return
|
3802
|
+
return bn16(chain.latestBlock.height, 10);
|
3875
3803
|
}
|
3876
3804
|
/**
|
3877
3805
|
* Returns the chain information.
|
@@ -3881,8 +3809,8 @@ var _Provider = class {
|
|
3881
3809
|
async fetchNode() {
|
3882
3810
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3883
3811
|
const processedNodeInfo = {
|
3884
|
-
maxDepth:
|
3885
|
-
maxTx:
|
3812
|
+
maxDepth: bn16(nodeInfo.maxDepth),
|
3813
|
+
maxTx: bn16(nodeInfo.maxTx),
|
3886
3814
|
nodeVersion: nodeInfo.nodeVersion,
|
3887
3815
|
utxoValidation: nodeInfo.utxoValidation,
|
3888
3816
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -3986,9 +3914,9 @@ var _Provider = class {
|
|
3986
3914
|
encodedTransactions: encodedTransaction,
|
3987
3915
|
utxoValidation: utxoValidation || false
|
3988
3916
|
});
|
3989
|
-
const [{ receipts: rawReceipts, status
|
3917
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
3990
3918
|
const receipts = rawReceipts.map(processGqlReceipt);
|
3991
|
-
return { receipts,
|
3919
|
+
return { receipts, dryrunStatus: status };
|
3992
3920
|
}
|
3993
3921
|
/**
|
3994
3922
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -4014,7 +3942,7 @@ var _Provider = class {
|
|
4014
3942
|
} = response;
|
4015
3943
|
if (inputs) {
|
4016
3944
|
inputs.forEach((input, index) => {
|
4017
|
-
if ("predicateGasUsed" in input &&
|
3945
|
+
if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
|
4018
3946
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4019
3947
|
}
|
4020
3948
|
});
|
@@ -4042,7 +3970,7 @@ var _Provider = class {
|
|
4042
3970
|
let receipts = [];
|
4043
3971
|
const missingContractIds = [];
|
4044
3972
|
let outputVariables = 0;
|
4045
|
-
let
|
3973
|
+
let dryrunStatus;
|
4046
3974
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4047
3975
|
const {
|
4048
3976
|
dryRun: [{ receipts: rawReceipts, status }]
|
@@ -4051,7 +3979,7 @@ var _Provider = class {
|
|
4051
3979
|
utxoValidation: false
|
4052
3980
|
});
|
4053
3981
|
receipts = rawReceipts.map(processGqlReceipt);
|
4054
|
-
|
3982
|
+
dryrunStatus = status;
|
4055
3983
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
4056
3984
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
4057
3985
|
if (hasMissingOutputs) {
|
@@ -4073,7 +4001,7 @@ var _Provider = class {
|
|
4073
4001
|
receipts,
|
4074
4002
|
outputVariables,
|
4075
4003
|
missingContractIds,
|
4076
|
-
|
4004
|
+
dryrunStatus
|
4077
4005
|
};
|
4078
4006
|
}
|
4079
4007
|
/**
|
@@ -4091,7 +4019,7 @@ var _Provider = class {
|
|
4091
4019
|
receipts: [],
|
4092
4020
|
outputVariables: 0,
|
4093
4021
|
missingContractIds: [],
|
4094
|
-
|
4022
|
+
dryrunStatus: void 0
|
4095
4023
|
}));
|
4096
4024
|
const allRequests = clone3(transactionRequests);
|
4097
4025
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
@@ -4116,7 +4044,7 @@ var _Provider = class {
|
|
4116
4044
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4117
4045
|
const result = results[requestIdx];
|
4118
4046
|
result.receipts = rawReceipts.map(processGqlReceipt);
|
4119
|
-
result.
|
4047
|
+
result.dryrunStatus = status;
|
4120
4048
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4121
4049
|
result.receipts
|
4122
4050
|
);
|
@@ -4153,7 +4081,7 @@ var _Provider = class {
|
|
4153
4081
|
});
|
4154
4082
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4155
4083
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4156
|
-
return { receipts,
|
4084
|
+
return { receipts, dryrunStatus: status };
|
4157
4085
|
});
|
4158
4086
|
return results;
|
4159
4087
|
}
|
@@ -4172,12 +4100,12 @@ var _Provider = class {
|
|
4172
4100
|
gasPrice = await this.estimateGasPrice(10);
|
4173
4101
|
}
|
4174
4102
|
const minFee = calculateGasFee({
|
4175
|
-
gasPrice:
|
4103
|
+
gasPrice: bn16(gasPrice),
|
4176
4104
|
gas: minGas,
|
4177
4105
|
priceFactor: gasPriceFactor,
|
4178
4106
|
tip: transactionRequest.tip
|
4179
4107
|
}).add(1);
|
4180
|
-
let gasLimit =
|
4108
|
+
let gasLimit = bn16(0);
|
4181
4109
|
if (transactionRequest.type === TransactionType8.Script) {
|
4182
4110
|
gasLimit = transactionRequest.gasLimit;
|
4183
4111
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4190,7 +4118,7 @@ var _Provider = class {
|
|
4190
4118
|
}
|
4191
4119
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4192
4120
|
const maxFee = calculateGasFee({
|
4193
|
-
gasPrice:
|
4121
|
+
gasPrice: bn16(gasPrice),
|
4194
4122
|
gas: maxGas,
|
4195
4123
|
priceFactor: gasPriceFactor,
|
4196
4124
|
tip: transactionRequest.tip
|
@@ -4253,9 +4181,9 @@ var _Provider = class {
|
|
4253
4181
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4254
4182
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4255
4183
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4256
|
-
txRequestClone.maxFee =
|
4184
|
+
txRequestClone.maxFee = bn16(0);
|
4257
4185
|
if (isScriptTransaction) {
|
4258
|
-
txRequestClone.gasLimit =
|
4186
|
+
txRequestClone.gasLimit = bn16(0);
|
4259
4187
|
}
|
4260
4188
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4261
4189
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4272,10 +4200,9 @@ var _Provider = class {
|
|
4272
4200
|
transactionRequest: signedRequest
|
4273
4201
|
});
|
4274
4202
|
let receipts = [];
|
4275
|
-
let dryRunStatus;
|
4276
4203
|
let missingContractIds = [];
|
4277
4204
|
let outputVariables = 0;
|
4278
|
-
let gasUsed =
|
4205
|
+
let gasUsed = bn16(0);
|
4279
4206
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4280
4207
|
txRequestClone.maxFee = maxFee;
|
4281
4208
|
if (isScriptTransaction) {
|
@@ -4283,7 +4210,10 @@ var _Provider = class {
|
|
4283
4210
|
if (signatureCallback) {
|
4284
4211
|
await signatureCallback(txRequestClone);
|
4285
4212
|
}
|
4286
|
-
|
4213
|
+
const result = await this.estimateTxDependencies(txRequestClone);
|
4214
|
+
receipts = result.receipts;
|
4215
|
+
outputVariables = result.outputVariables;
|
4216
|
+
missingContractIds = result.missingContractIds;
|
4287
4217
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4288
4218
|
txRequestClone.gasLimit = gasUsed;
|
4289
4219
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
@@ -4303,8 +4233,7 @@ var _Provider = class {
|
|
4303
4233
|
outputVariables,
|
4304
4234
|
missingContractIds,
|
4305
4235
|
addedSignatures,
|
4306
|
-
estimatedPredicates: txRequestClone.inputs
|
4307
|
-
dryRunStatus
|
4236
|
+
estimatedPredicates: txRequestClone.inputs
|
4308
4237
|
};
|
4309
4238
|
}
|
4310
4239
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4340,10 +4269,10 @@ var _Provider = class {
|
|
4340
4269
|
return coins.map((coin) => ({
|
4341
4270
|
id: coin.utxoId,
|
4342
4271
|
assetId: coin.assetId,
|
4343
|
-
amount:
|
4272
|
+
amount: bn16(coin.amount),
|
4344
4273
|
owner: Address2.fromAddressOrString(coin.owner),
|
4345
|
-
blockCreated:
|
4346
|
-
txCreatedIdx:
|
4274
|
+
blockCreated: bn16(coin.blockCreated),
|
4275
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4347
4276
|
}));
|
4348
4277
|
}
|
4349
4278
|
/**
|
@@ -4380,9 +4309,9 @@ var _Provider = class {
|
|
4380
4309
|
switch (coin.__typename) {
|
4381
4310
|
case "MessageCoin":
|
4382
4311
|
return {
|
4383
|
-
amount:
|
4312
|
+
amount: bn16(coin.amount),
|
4384
4313
|
assetId: coin.assetId,
|
4385
|
-
daHeight:
|
4314
|
+
daHeight: bn16(coin.daHeight),
|
4386
4315
|
sender: Address2.fromAddressOrString(coin.sender),
|
4387
4316
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4388
4317
|
nonce: coin.nonce
|
@@ -4390,11 +4319,11 @@ var _Provider = class {
|
|
4390
4319
|
case "Coin":
|
4391
4320
|
return {
|
4392
4321
|
id: coin.utxoId,
|
4393
|
-
amount:
|
4322
|
+
amount: bn16(coin.amount),
|
4394
4323
|
assetId: coin.assetId,
|
4395
4324
|
owner: Address2.fromAddressOrString(coin.owner),
|
4396
|
-
blockCreated:
|
4397
|
-
txCreatedIdx:
|
4325
|
+
blockCreated: bn16(coin.blockCreated),
|
4326
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4398
4327
|
};
|
4399
4328
|
default:
|
4400
4329
|
return null;
|
@@ -4411,13 +4340,13 @@ var _Provider = class {
|
|
4411
4340
|
async getBlock(idOrHeight) {
|
4412
4341
|
let variables;
|
4413
4342
|
if (typeof idOrHeight === "number") {
|
4414
|
-
variables = { height:
|
4343
|
+
variables = { height: bn16(idOrHeight).toString(10) };
|
4415
4344
|
} else if (idOrHeight === "latest") {
|
4416
4345
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4417
4346
|
} else if (idOrHeight.length === 66) {
|
4418
4347
|
variables = { blockId: idOrHeight };
|
4419
4348
|
} else {
|
4420
|
-
variables = { blockId:
|
4349
|
+
variables = { blockId: bn16(idOrHeight).toString(10) };
|
4421
4350
|
}
|
4422
4351
|
const { block } = await this.operations.getBlock(variables);
|
4423
4352
|
if (!block) {
|
@@ -4425,7 +4354,7 @@ var _Provider = class {
|
|
4425
4354
|
}
|
4426
4355
|
return {
|
4427
4356
|
id: block.id,
|
4428
|
-
height:
|
4357
|
+
height: bn16(block.height),
|
4429
4358
|
time: block.header.time,
|
4430
4359
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4431
4360
|
};
|
@@ -4440,7 +4369,7 @@ var _Provider = class {
|
|
4440
4369
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4441
4370
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4442
4371
|
id: block.id,
|
4443
|
-
height:
|
4372
|
+
height: bn16(block.height),
|
4444
4373
|
time: block.header.time,
|
4445
4374
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4446
4375
|
}));
|
@@ -4455,7 +4384,7 @@ var _Provider = class {
|
|
4455
4384
|
async getBlockWithTransactions(idOrHeight) {
|
4456
4385
|
let variables;
|
4457
4386
|
if (typeof idOrHeight === "number") {
|
4458
|
-
variables = { blockHeight:
|
4387
|
+
variables = { blockHeight: bn16(idOrHeight).toString(10) };
|
4459
4388
|
} else if (idOrHeight === "latest") {
|
4460
4389
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4461
4390
|
} else {
|
@@ -4467,7 +4396,7 @@ var _Provider = class {
|
|
4467
4396
|
}
|
4468
4397
|
return {
|
4469
4398
|
id: block.id,
|
4470
|
-
height:
|
4399
|
+
height: bn16(block.height, 10),
|
4471
4400
|
time: block.header.time,
|
4472
4401
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4473
4402
|
transactions: block.transactions.map(
|
@@ -4516,7 +4445,7 @@ var _Provider = class {
|
|
4516
4445
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4517
4446
|
asset: hexlify12(assetId)
|
4518
4447
|
});
|
4519
|
-
return
|
4448
|
+
return bn16(contractBalance.amount, 10);
|
4520
4449
|
}
|
4521
4450
|
/**
|
4522
4451
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4530,7 +4459,7 @@ var _Provider = class {
|
|
4530
4459
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4531
4460
|
assetId: hexlify12(assetId)
|
4532
4461
|
});
|
4533
|
-
return
|
4462
|
+
return bn16(balance.amount, 10);
|
4534
4463
|
}
|
4535
4464
|
/**
|
4536
4465
|
* Returns balances for the given owner.
|
@@ -4548,7 +4477,7 @@ var _Provider = class {
|
|
4548
4477
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4549
4478
|
return balances.map((balance) => ({
|
4550
4479
|
assetId: balance.assetId,
|
4551
|
-
amount:
|
4480
|
+
amount: bn16(balance.amount)
|
4552
4481
|
}));
|
4553
4482
|
}
|
4554
4483
|
/**
|
@@ -4570,15 +4499,15 @@ var _Provider = class {
|
|
4570
4499
|
sender: message.sender,
|
4571
4500
|
recipient: message.recipient,
|
4572
4501
|
nonce: message.nonce,
|
4573
|
-
amount:
|
4502
|
+
amount: bn16(message.amount),
|
4574
4503
|
data: message.data
|
4575
4504
|
}),
|
4576
4505
|
sender: Address2.fromAddressOrString(message.sender),
|
4577
4506
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4578
4507
|
nonce: message.nonce,
|
4579
|
-
amount:
|
4508
|
+
amount: bn16(message.amount),
|
4580
4509
|
data: InputMessageCoder.decodeData(message.data),
|
4581
|
-
daHeight:
|
4510
|
+
daHeight: bn16(message.daHeight)
|
4582
4511
|
}));
|
4583
4512
|
}
|
4584
4513
|
/**
|
@@ -4631,59 +4560,59 @@ var _Provider = class {
|
|
4631
4560
|
} = result.messageProof;
|
4632
4561
|
return {
|
4633
4562
|
messageProof: {
|
4634
|
-
proofIndex:
|
4563
|
+
proofIndex: bn16(messageProof.proofIndex),
|
4635
4564
|
proofSet: messageProof.proofSet
|
4636
4565
|
},
|
4637
4566
|
blockProof: {
|
4638
|
-
proofIndex:
|
4567
|
+
proofIndex: bn16(blockProof.proofIndex),
|
4639
4568
|
proofSet: blockProof.proofSet
|
4640
4569
|
},
|
4641
4570
|
messageBlockHeader: {
|
4642
4571
|
id: messageBlockHeader.id,
|
4643
|
-
daHeight:
|
4644
|
-
transactionsCount:
|
4572
|
+
daHeight: bn16(messageBlockHeader.daHeight),
|
4573
|
+
transactionsCount: bn16(messageBlockHeader.transactionsCount),
|
4645
4574
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4646
|
-
height:
|
4575
|
+
height: bn16(messageBlockHeader.height),
|
4647
4576
|
prevRoot: messageBlockHeader.prevRoot,
|
4648
4577
|
time: messageBlockHeader.time,
|
4649
4578
|
applicationHash: messageBlockHeader.applicationHash,
|
4650
|
-
messageReceiptCount:
|
4579
|
+
messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
|
4651
4580
|
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4652
|
-
consensusParametersVersion:
|
4581
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4653
4582
|
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4654
|
-
stateTransitionBytecodeVersion:
|
4583
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4655
4584
|
},
|
4656
4585
|
commitBlockHeader: {
|
4657
4586
|
id: commitBlockHeader.id,
|
4658
|
-
daHeight:
|
4659
|
-
transactionsCount:
|
4587
|
+
daHeight: bn16(commitBlockHeader.daHeight),
|
4588
|
+
transactionsCount: bn16(commitBlockHeader.transactionsCount),
|
4660
4589
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4661
|
-
height:
|
4590
|
+
height: bn16(commitBlockHeader.height),
|
4662
4591
|
prevRoot: commitBlockHeader.prevRoot,
|
4663
4592
|
time: commitBlockHeader.time,
|
4664
4593
|
applicationHash: commitBlockHeader.applicationHash,
|
4665
|
-
messageReceiptCount:
|
4594
|
+
messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
|
4666
4595
|
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4667
|
-
consensusParametersVersion:
|
4596
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4668
4597
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4669
|
-
stateTransitionBytecodeVersion:
|
4598
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4670
4599
|
},
|
4671
4600
|
sender: Address2.fromAddressOrString(sender),
|
4672
4601
|
recipient: Address2.fromAddressOrString(recipient),
|
4673
4602
|
nonce,
|
4674
|
-
amount:
|
4603
|
+
amount: bn16(amount),
|
4675
4604
|
data
|
4676
4605
|
};
|
4677
4606
|
}
|
4678
4607
|
async getLatestGasPrice() {
|
4679
4608
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4680
|
-
return
|
4609
|
+
return bn16(latestGasPrice.gasPrice);
|
4681
4610
|
}
|
4682
4611
|
async estimateGasPrice(blockHorizon) {
|
4683
4612
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4684
4613
|
blockHorizon: String(blockHorizon)
|
4685
4614
|
});
|
4686
|
-
return
|
4615
|
+
return bn16(estimateGasPrice.gasPrice);
|
4687
4616
|
}
|
4688
4617
|
/**
|
4689
4618
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4704,10 +4633,10 @@ var _Provider = class {
|
|
4704
4633
|
*/
|
4705
4634
|
async produceBlocks(amount, startTime) {
|
4706
4635
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4707
|
-
blocksToProduce:
|
4636
|
+
blocksToProduce: bn16(amount).toString(10),
|
4708
4637
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4709
4638
|
});
|
4710
|
-
return
|
4639
|
+
return bn16(latestBlockHeight);
|
4711
4640
|
}
|
4712
4641
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4713
4642
|
async getTransactionResponse(transactionId) {
|
@@ -4726,15 +4655,6 @@ var _Provider = class {
|
|
4726
4655
|
}
|
4727
4656
|
return message;
|
4728
4657
|
}
|
4729
|
-
async getRelayedTransactionStatus(relayedTransactionId) {
|
4730
|
-
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
4731
|
-
relayedTransactionId
|
4732
|
-
});
|
4733
|
-
if (!relayedTransactionStatus) {
|
4734
|
-
return null;
|
4735
|
-
}
|
4736
|
-
return relayedTransactionStatus;
|
4737
|
-
}
|
4738
4658
|
};
|
4739
4659
|
var Provider = _Provider;
|
4740
4660
|
_cacheInputs = new WeakSet();
|
@@ -4753,7 +4673,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4753
4673
|
|
4754
4674
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4755
4675
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4756
|
-
import { bn as
|
4676
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
4757
4677
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4758
4678
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4759
4679
|
|
@@ -4803,7 +4723,7 @@ var assets = [
|
|
4803
4723
|
];
|
4804
4724
|
|
4805
4725
|
// src/providers/transaction-request/helpers.ts
|
4806
|
-
import { bn as
|
4726
|
+
import { bn as bn18 } from "@fuel-ts/math";
|
4807
4727
|
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
4808
4728
|
var isRequestInputCoin = (input) => input.type === InputType8.Coin;
|
4809
4729
|
var isRequestInputMessage = (input) => input.type === InputType8.Message;
|
@@ -4816,7 +4736,7 @@ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filte
|
|
4816
4736
|
return acc.add(input.amount);
|
4817
4737
|
}
|
4818
4738
|
return acc;
|
4819
|
-
},
|
4739
|
+
}, bn18(0));
|
4820
4740
|
|
4821
4741
|
// src/utils/formatTransferToContractScriptData.ts
|
4822
4742
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
@@ -5020,10 +4940,10 @@ var Account = class extends AbstractAccount {
|
|
5020
4940
|
async fund(request, params) {
|
5021
4941
|
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
5022
4942
|
const baseAssetId = this.provider.getBaseAssetId();
|
5023
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
4943
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
|
5024
4944
|
const txRequest = request;
|
5025
4945
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5026
|
-
amount:
|
4946
|
+
amount: bn19(fee),
|
5027
4947
|
assetId: baseAssetId,
|
5028
4948
|
coinQuantities: requiredQuantities
|
5029
4949
|
});
|
@@ -5031,7 +4951,7 @@ var Account = class extends AbstractAccount {
|
|
5031
4951
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5032
4952
|
quantitiesDict[assetId] = {
|
5033
4953
|
required: amount,
|
5034
|
-
owned:
|
4954
|
+
owned: bn19(0)
|
5035
4955
|
};
|
5036
4956
|
});
|
5037
4957
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5136,7 +5056,7 @@ var Account = class extends AbstractAccount {
|
|
5136
5056
|
* @returns A promise that resolves to the transaction response.
|
5137
5057
|
*/
|
5138
5058
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5139
|
-
if (
|
5059
|
+
if (bn19(amount).lte(0)) {
|
5140
5060
|
throw new FuelError15(
|
5141
5061
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5142
5062
|
"Transfer amount must be a positive number."
|
@@ -5156,7 +5076,7 @@ var Account = class extends AbstractAccount {
|
|
5156
5076
|
* @returns A promise that resolves to the transaction response.
|
5157
5077
|
*/
|
5158
5078
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5159
|
-
if (
|
5079
|
+
if (bn19(amount).lte(0)) {
|
5160
5080
|
throw new FuelError15(
|
5161
5081
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5162
5082
|
"Transfer amount must be a positive number."
|
@@ -5166,7 +5086,7 @@ var Account = class extends AbstractAccount {
|
|
5166
5086
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5167
5087
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5168
5088
|
hexlifiedContractId: contractAddress.toB256(),
|
5169
|
-
amountToTransfer:
|
5089
|
+
amountToTransfer: bn19(amount),
|
5170
5090
|
assetId: assetIdToTransfer
|
5171
5091
|
});
|
5172
5092
|
const request = new ScriptTransactionRequest({
|
@@ -5177,7 +5097,7 @@ var Account = class extends AbstractAccount {
|
|
5177
5097
|
request.addContractInputAndOutput(contractAddress);
|
5178
5098
|
const txCost = await this.provider.getTransactionCost(request, {
|
5179
5099
|
resourcesOwner: this,
|
5180
|
-
quantitiesToContract: [{ amount:
|
5100
|
+
quantitiesToContract: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
|
5181
5101
|
});
|
5182
5102
|
this.validateGasLimitAndMaxFee({
|
5183
5103
|
gasUsed: txCost.gasUsed,
|
@@ -5203,7 +5123,7 @@ var Account = class extends AbstractAccount {
|
|
5203
5123
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5204
5124
|
);
|
5205
5125
|
const amountDataArray = arrayify14(
|
5206
|
-
"0x".concat(
|
5126
|
+
"0x".concat(bn19(amount).toHex().substring(2).padStart(16, "0"))
|
5207
5127
|
);
|
5208
5128
|
const script = new Uint8Array([
|
5209
5129
|
...arrayify14(withdrawScript.bytes),
|
@@ -5213,7 +5133,7 @@ var Account = class extends AbstractAccount {
|
|
5213
5133
|
const params = { script, ...txParams };
|
5214
5134
|
const baseAssetId = this.provider.getBaseAssetId();
|
5215
5135
|
const request = new ScriptTransactionRequest(params);
|
5216
|
-
const quantitiesToContract = [{ amount:
|
5136
|
+
const quantitiesToContract = [{ amount: bn19(amount), assetId: baseAssetId }];
|
5217
5137
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5218
5138
|
this.validateGasLimitAndMaxFee({
|
5219
5139
|
gasUsed: txCost.gasUsed,
|
@@ -5623,7 +5543,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5623
5543
|
// src/hdwallet/hdwallet.ts
|
5624
5544
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5625
5545
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5626
|
-
import { bn as
|
5546
|
+
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5627
5547
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5628
5548
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5629
5549
|
|
@@ -8089,7 +8009,7 @@ var HDWallet = class {
|
|
8089
8009
|
const IR = bytes.slice(32);
|
8090
8010
|
if (privateKey) {
|
8091
8011
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8092
|
-
const ki =
|
8012
|
+
const ki = bn20(IL).add(privateKey).mod(N).toBytes(32);
|
8093
8013
|
return new HDWallet({
|
8094
8014
|
privateKey: ki,
|
8095
8015
|
chainCode: IR,
|
@@ -8504,11 +8424,9 @@ var launchNode = async ({
|
|
8504
8424
|
const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
|
8505
8425
|
const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
|
8506
8426
|
const metadataWritePath = path.join(tempDirPath, "metadata.json");
|
8507
|
-
const stateTransitionWritePath = path.join(tempDirPath, "state_transition_bytecode.wasm");
|
8508
8427
|
writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
|
8509
8428
|
writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
|
8510
8429
|
writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
|
8511
|
-
writeFileSync(stateTransitionWritePath, JSON.stringify(""));
|
8512
8430
|
snapshotDirToUse = tempDirPath;
|
8513
8431
|
}
|
8514
8432
|
const child = spawn(
|