@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/index.mjs
CHANGED
@@ -31,7 +31,7 @@ var __privateMethod = (obj, member, method) => {
|
|
31
31
|
import { Address as Address3 } from "@fuel-ts/address";
|
32
32
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
33
33
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
34
|
-
import { bn as
|
34
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
35
35
|
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
36
36
|
import { clone as clone4 } from "ramda";
|
37
37
|
|
@@ -73,7 +73,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
73
73
|
// src/providers/provider.ts
|
74
74
|
import { Address as Address2 } from "@fuel-ts/address";
|
75
75
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
76
|
-
import { BN, bn as
|
76
|
+
import { BN, bn as bn16 } from "@fuel-ts/math";
|
77
77
|
import {
|
78
78
|
InputType as InputType7,
|
79
79
|
TransactionType as TransactionType8,
|
@@ -139,6 +139,9 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
139
139
|
id
|
140
140
|
}
|
141
141
|
time
|
142
|
+
receipts {
|
143
|
+
...receiptFragment
|
144
|
+
}
|
142
145
|
programState {
|
143
146
|
returnType
|
144
147
|
data
|
@@ -146,15 +149,11 @@ var TransactionStatusFragmentFragmentDoc = gql`
|
|
146
149
|
receipts {
|
147
150
|
...receiptFragment
|
148
151
|
}
|
149
|
-
totalGas
|
150
|
-
totalFee
|
151
152
|
}
|
152
153
|
... on FailureStatus {
|
153
154
|
block {
|
154
155
|
id
|
155
156
|
}
|
156
|
-
totalGas
|
157
|
-
totalFee
|
158
157
|
time
|
159
158
|
reason
|
160
159
|
receipts {
|
@@ -194,8 +193,6 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
|
|
194
193
|
${InputEstimatePredicatesFragmentFragmentDoc}`;
|
195
194
|
var DryRunFailureStatusFragmentFragmentDoc = gql`
|
196
195
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
197
|
-
totalGas
|
198
|
-
totalFee
|
199
196
|
reason
|
200
197
|
programState {
|
201
198
|
returnType
|
@@ -205,8 +202,6 @@ var DryRunFailureStatusFragmentFragmentDoc = gql`
|
|
205
202
|
`;
|
206
203
|
var DryRunSuccessStatusFragmentFragmentDoc = gql`
|
207
204
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
208
|
-
totalGas
|
209
|
-
totalFee
|
210
205
|
programState {
|
211
206
|
returnType
|
212
207
|
data
|
@@ -342,7 +337,6 @@ var TxParametersFragmentFragmentDoc = gql`
|
|
342
337
|
maxWitnesses
|
343
338
|
maxGasPerTx
|
344
339
|
maxSize
|
345
|
-
maxBytecodeSubsections
|
346
340
|
}
|
347
341
|
`;
|
348
342
|
var PredicateParametersFragmentFragmentDoc = gql`
|
@@ -612,14 +606,6 @@ var NodeInfoFragmentFragmentDoc = gql`
|
|
612
606
|
nodeVersion
|
613
607
|
}
|
614
608
|
`;
|
615
|
-
var RelayedTransactionStatusFragmentFragmentDoc = gql`
|
616
|
-
fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
|
617
|
-
... on RelayedTransactionFailed {
|
618
|
-
blockHeight
|
619
|
-
failure
|
620
|
-
}
|
621
|
-
}
|
622
|
-
`;
|
623
609
|
var GetVersionDocument = gql`
|
624
610
|
query getVersion {
|
625
611
|
nodeInfo {
|
@@ -849,13 +835,6 @@ var GetMessageStatusDocument = gql`
|
|
849
835
|
}
|
850
836
|
}
|
851
837
|
`;
|
852
|
-
var GetRelayedTransactionStatusDocument = gql`
|
853
|
-
query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
|
854
|
-
relayedTransactionStatus(id: $relayedTransactionId) {
|
855
|
-
...relayedTransactionStatusFragment
|
856
|
-
}
|
857
|
-
}
|
858
|
-
${RelayedTransactionStatusFragmentFragmentDoc}`;
|
859
838
|
var DryRunDocument = gql`
|
860
839
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
|
861
840
|
dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
|
@@ -970,9 +949,6 @@ function getSdk(requester) {
|
|
970
949
|
getMessageStatus(variables, options) {
|
971
950
|
return requester(GetMessageStatusDocument, variables, options);
|
972
951
|
},
|
973
|
-
getRelayedTransactionStatus(variables, options) {
|
974
|
-
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
975
|
-
},
|
976
952
|
dryRun(variables, options) {
|
977
953
|
return requester(DryRunDocument, variables, options);
|
978
954
|
},
|
@@ -2178,11 +2154,8 @@ var BaseTransactionRequest = class {
|
|
2178
2154
|
* @hidden
|
2179
2155
|
*/
|
2180
2156
|
calculateMinGas(chainInfo) {
|
2181
|
-
const { consensusParameters } = chainInfo;
|
2182
|
-
const {
|
2183
|
-
gasCosts,
|
2184
|
-
feeParameters: { gasPerByte }
|
2185
|
-
} = consensusParameters;
|
2157
|
+
const { gasCosts, consensusParameters } = chainInfo;
|
2158
|
+
const { gasPerByte } = consensusParameters;
|
2186
2159
|
return getMinGas({
|
2187
2160
|
gasPerByte,
|
2188
2161
|
gasCosts,
|
@@ -2193,10 +2166,7 @@ var BaseTransactionRequest = class {
|
|
2193
2166
|
}
|
2194
2167
|
calculateMaxGas(chainInfo, minGas) {
|
2195
2168
|
const { consensusParameters } = chainInfo;
|
2196
|
-
const {
|
2197
|
-
feeParameters: { gasPerByte },
|
2198
|
-
txParameters: { maxGasPerTx }
|
2199
|
-
} = consensusParameters;
|
2169
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2200
2170
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2201
2171
|
(acc, wit) => acc + wit.dataLength,
|
2202
2172
|
0
|
@@ -2631,10 +2601,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2631
2601
|
}
|
2632
2602
|
calculateMaxGas(chainInfo, minGas) {
|
2633
2603
|
const { consensusParameters } = chainInfo;
|
2634
|
-
const {
|
2635
|
-
feeParameters: { gasPerByte },
|
2636
|
-
txParameters: { maxGasPerTx }
|
2637
|
-
} = consensusParameters;
|
2604
|
+
const { gasPerByte, maxGasPerTx } = consensusParameters;
|
2638
2605
|
const witnessesLength = this.toTransaction().witnesses.reduce(
|
2639
2606
|
(acc, wit) => acc + wit.dataLength,
|
2640
2607
|
0
|
@@ -2738,40 +2705,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
|
2738
2705
|
|
2739
2706
|
// src/providers/transaction-response/transaction-response.ts
|
2740
2707
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2741
|
-
import { bn as
|
2708
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2742
2709
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2743
2710
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2744
2711
|
|
2745
2712
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2746
|
-
import { bn as
|
2713
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2747
2714
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2748
2715
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2749
2716
|
|
2750
|
-
// src/providers/transaction-summary/calculate-
|
2717
|
+
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2751
2718
|
import { bn as bn11 } from "@fuel-ts/math";
|
2752
2719
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2753
2720
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2754
|
-
var
|
2721
|
+
var calculateTransactionFee = (params) => {
|
2755
2722
|
const {
|
2756
2723
|
gasPrice,
|
2757
2724
|
rawPayload,
|
2758
2725
|
tip,
|
2759
|
-
totalFee,
|
2760
2726
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2761
2727
|
} = params;
|
2762
|
-
if (totalFee) {
|
2763
|
-
return totalFee;
|
2764
|
-
}
|
2765
2728
|
const gasPerByte = bn11(feeParams.gasPerByte);
|
2766
2729
|
const gasPriceFactor = bn11(feeParams.gasPriceFactor);
|
2767
2730
|
const transactionBytes = arrayify9(rawPayload);
|
2768
2731
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2732
|
+
if (transaction.type === TransactionType6.Mint) {
|
2733
|
+
return {
|
2734
|
+
fee: bn11(0),
|
2735
|
+
minFee: bn11(0),
|
2736
|
+
maxFee: bn11(0)
|
2737
|
+
};
|
2738
|
+
}
|
2769
2739
|
const { type, witnesses, inputs, policies } = transaction;
|
2770
2740
|
let metadataGas = bn11(0);
|
2771
2741
|
let gasLimit = bn11(0);
|
2772
|
-
if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
|
2773
|
-
return bn11(0);
|
2774
|
-
}
|
2775
2742
|
if (type === TransactionType6.Create) {
|
2776
2743
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2777
2744
|
const contractBytesSize = bn11(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
@@ -2808,13 +2775,23 @@ var calculateTXFeeForSummary = (params) => {
|
|
2808
2775
|
witnessLimit,
|
2809
2776
|
maxGasPerTx
|
2810
2777
|
});
|
2778
|
+
const minFee = calculateGasFee({
|
2779
|
+
gasPrice,
|
2780
|
+
gas: minGas,
|
2781
|
+
priceFactor: gasPriceFactor,
|
2782
|
+
tip
|
2783
|
+
});
|
2811
2784
|
const maxFee = calculateGasFee({
|
2812
2785
|
gasPrice,
|
2813
2786
|
gas: maxGas,
|
2814
2787
|
priceFactor: gasPriceFactor,
|
2815
2788
|
tip
|
2816
2789
|
});
|
2817
|
-
return
|
2790
|
+
return {
|
2791
|
+
minFee,
|
2792
|
+
maxFee,
|
2793
|
+
fee: maxFee
|
2794
|
+
};
|
2818
2795
|
};
|
2819
2796
|
|
2820
2797
|
// src/providers/transaction-summary/operations.ts
|
@@ -2949,8 +2926,6 @@ var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
|
|
2949
2926
|
TransactionTypeName2["Create"] = "Create";
|
2950
2927
|
TransactionTypeName2["Mint"] = "Mint";
|
2951
2928
|
TransactionTypeName2["Script"] = "Script";
|
2952
|
-
TransactionTypeName2["Upgrade"] = "Upgrade";
|
2953
|
-
TransactionTypeName2["Upload"] = "Upload";
|
2954
2929
|
return TransactionTypeName2;
|
2955
2930
|
})(TransactionTypeName || {});
|
2956
2931
|
var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
|
@@ -3016,12 +2991,6 @@ function isTypeCreate(transactionType) {
|
|
3016
2991
|
function isTypeScript(transactionType) {
|
3017
2992
|
return isType(transactionType, "Script" /* Script */);
|
3018
2993
|
}
|
3019
|
-
function isTypeUpgrade(transactionType) {
|
3020
|
-
return isType(transactionType, "Upgrade" /* Upgrade */);
|
3021
|
-
}
|
3022
|
-
function isTypeUpload(transactionType) {
|
3023
|
-
return isType(transactionType, "Upload" /* Upload */);
|
3024
|
-
}
|
3025
2994
|
function hasSameAssetId(a) {
|
3026
2995
|
return (b) => a.assetId === b.assetId;
|
3027
2996
|
}
|
@@ -3368,7 +3337,6 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3368
3337
|
|
3369
3338
|
// src/providers/transaction-summary/status.ts
|
3370
3339
|
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3371
|
-
import { bn as bn14 } from "@fuel-ts/math";
|
3372
3340
|
var getTransactionStatusName = (gqlStatus) => {
|
3373
3341
|
switch (gqlStatus) {
|
3374
3342
|
case "FailureStatus":
|
@@ -3390,8 +3358,6 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3390
3358
|
let time;
|
3391
3359
|
let blockId;
|
3392
3360
|
let status;
|
3393
|
-
let totalFee;
|
3394
|
-
let totalGas;
|
3395
3361
|
let isStatusFailure = false;
|
3396
3362
|
let isStatusSuccess = false;
|
3397
3363
|
let isStatusPending = false;
|
@@ -3402,15 +3368,11 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3402
3368
|
time = gqlTransactionStatus.time;
|
3403
3369
|
blockId = gqlTransactionStatus.block.id;
|
3404
3370
|
isStatusSuccess = true;
|
3405
|
-
totalFee = bn14(gqlTransactionStatus.totalFee);
|
3406
|
-
totalGas = bn14(gqlTransactionStatus.totalGas);
|
3407
3371
|
break;
|
3408
3372
|
case "FailureStatus":
|
3409
3373
|
time = gqlTransactionStatus.time;
|
3410
3374
|
blockId = gqlTransactionStatus.block.id;
|
3411
3375
|
isStatusFailure = true;
|
3412
|
-
totalFee = bn14(gqlTransactionStatus.totalFee);
|
3413
|
-
totalGas = bn14(gqlTransactionStatus.totalGas);
|
3414
3376
|
break;
|
3415
3377
|
case "SubmittedStatus":
|
3416
3378
|
time = gqlTransactionStatus.time;
|
@@ -3423,8 +3385,6 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3423
3385
|
time,
|
3424
3386
|
blockId,
|
3425
3387
|
status,
|
3426
|
-
totalFee,
|
3427
|
-
totalGas,
|
3428
3388
|
isStatusFailure,
|
3429
3389
|
isStatusSuccess,
|
3430
3390
|
isStatusPending
|
@@ -3460,10 +3420,8 @@ function assembleTransactionSummary(params) {
|
|
3460
3420
|
maxInputs
|
3461
3421
|
});
|
3462
3422
|
const typeName = getTransactionTypeName(transaction.type);
|
3463
|
-
const tip =
|
3464
|
-
const {
|
3465
|
-
const fee = calculateTXFeeForSummary({
|
3466
|
-
totalFee,
|
3423
|
+
const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3424
|
+
const { fee } = calculateTransactionFee({
|
3467
3425
|
gasPrice,
|
3468
3426
|
rawPayload,
|
3469
3427
|
tip,
|
@@ -3476,6 +3434,7 @@ function assembleTransactionSummary(params) {
|
|
3476
3434
|
}
|
3477
3435
|
}
|
3478
3436
|
});
|
3437
|
+
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
|
3479
3438
|
const mintedAssets = extractMintedAssetsFromReceipts(receipts);
|
3480
3439
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3481
3440
|
let date;
|
@@ -3484,7 +3443,6 @@ function assembleTransactionSummary(params) {
|
|
3484
3443
|
}
|
3485
3444
|
const transactionSummary = {
|
3486
3445
|
id,
|
3487
|
-
tip,
|
3488
3446
|
fee,
|
3489
3447
|
gasUsed,
|
3490
3448
|
operations,
|
@@ -3498,8 +3456,6 @@ function assembleTransactionSummary(params) {
|
|
3498
3456
|
isTypeMint: isTypeMint(transaction.type),
|
3499
3457
|
isTypeCreate: isTypeCreate(transaction.type),
|
3500
3458
|
isTypeScript: isTypeScript(transaction.type),
|
3501
|
-
isTypeUpgrade: isTypeUpgrade(transaction.type),
|
3502
|
-
isTypeUpload: isTypeUpload(transaction.type),
|
3503
3459
|
isStatusFailure,
|
3504
3460
|
isStatusSuccess,
|
3505
3461
|
isStatusPending,
|
@@ -3531,7 +3487,7 @@ var TransactionResponse = class {
|
|
3531
3487
|
/** Current provider */
|
3532
3488
|
provider;
|
3533
3489
|
/** Gas used on the transaction */
|
3534
|
-
gasUsed =
|
3490
|
+
gasUsed = bn15(0);
|
3535
3491
|
/** The graphql Transaction with receipts object. */
|
3536
3492
|
gqlTransaction;
|
3537
3493
|
abis;
|
@@ -3616,7 +3572,7 @@ var TransactionResponse = class {
|
|
3616
3572
|
const receipts = txReceipts.map(processGqlReceipt) || [];
|
3617
3573
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
|
3618
3574
|
const gasPrice = await this.provider.getLatestGasPrice();
|
3619
|
-
const maxInputs = this.provider.getChain().consensusParameters.
|
3575
|
+
const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
|
3620
3576
|
const transactionSummary = assembleTransactionSummary({
|
3621
3577
|
id: this.id,
|
3622
3578
|
receipts,
|
@@ -3752,60 +3708,33 @@ var mergeQuantities = (...coinQuantities) => {
|
|
3752
3708
|
var MAX_RETRIES = 10;
|
3753
3709
|
var processGqlChain = (chain) => {
|
3754
3710
|
const { name, daHeight, consensusParameters, latestBlock } = chain;
|
3755
|
-
const {
|
3756
|
-
contractParams,
|
3757
|
-
feeParams,
|
3758
|
-
predicateParams,
|
3759
|
-
scriptParams,
|
3760
|
-
txParams,
|
3761
|
-
gasCosts,
|
3762
|
-
baseAssetId,
|
3763
|
-
chainId,
|
3764
|
-
version
|
3765
|
-
} = consensusParameters;
|
3711
|
+
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3766
3712
|
return {
|
3767
3713
|
name,
|
3768
|
-
baseChainHeight:
|
3714
|
+
baseChainHeight: bn16(daHeight),
|
3769
3715
|
consensusParameters: {
|
3770
|
-
|
3771
|
-
|
3772
|
-
|
3773
|
-
|
3774
|
-
|
3775
|
-
|
3776
|
-
|
3777
|
-
|
3778
|
-
|
3779
|
-
|
3780
|
-
|
3781
|
-
|
3782
|
-
|
3783
|
-
|
3784
|
-
|
3785
|
-
|
3786
|
-
maxOutputs: bn17(txParams.maxOutputs),
|
3787
|
-
maxWitnesses: bn17(txParams.maxWitnesses),
|
3788
|
-
maxGasPerTx: bn17(txParams.maxGasPerTx),
|
3789
|
-
maxSize: bn17(txParams.maxSize),
|
3790
|
-
maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
|
3791
|
-
},
|
3792
|
-
predicateParameters: {
|
3793
|
-
version: predicateParams.version,
|
3794
|
-
maxPredicateLength: bn17(predicateParams.maxPredicateLength),
|
3795
|
-
maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
|
3796
|
-
maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
|
3797
|
-
maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
|
3798
|
-
},
|
3799
|
-
scriptParameters: {
|
3800
|
-
version: scriptParams.version,
|
3801
|
-
maxScriptLength: bn17(scriptParams.maxScriptLength),
|
3802
|
-
maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
|
3803
|
-
},
|
3716
|
+
contractMaxSize: bn16(contractParams.contractMaxSize),
|
3717
|
+
maxInputs: bn16(txParams.maxInputs),
|
3718
|
+
maxOutputs: bn16(txParams.maxOutputs),
|
3719
|
+
maxWitnesses: bn16(txParams.maxWitnesses),
|
3720
|
+
maxGasPerTx: bn16(txParams.maxGasPerTx),
|
3721
|
+
maxScriptLength: bn16(scriptParams.maxScriptLength),
|
3722
|
+
maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
|
3723
|
+
maxStorageSlots: bn16(contractParams.maxStorageSlots),
|
3724
|
+
maxPredicateLength: bn16(predicateParams.maxPredicateLength),
|
3725
|
+
maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
|
3726
|
+
maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
|
3727
|
+
gasPriceFactor: bn16(feeParams.gasPriceFactor),
|
3728
|
+
gasPerByte: bn16(feeParams.gasPerByte),
|
3729
|
+
maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
|
3730
|
+
chainId: bn16(consensusParameters.chainId),
|
3731
|
+
baseAssetId: consensusParameters.baseAssetId,
|
3804
3732
|
gasCosts
|
3805
3733
|
},
|
3734
|
+
gasCosts,
|
3806
3735
|
latestBlock: {
|
3807
3736
|
id: latestBlock.id,
|
3808
|
-
height:
|
3737
|
+
height: bn16(latestBlock.height),
|
3809
3738
|
time: latestBlock.header.time,
|
3810
3739
|
transactions: latestBlock.transactions.map((i) => ({
|
3811
3740
|
id: i.id
|
@@ -3899,12 +3828,7 @@ var _Provider = class {
|
|
3899
3828
|
* Returns some helpful parameters related to gas fees.
|
3900
3829
|
*/
|
3901
3830
|
getGasConfig() {
|
3902
|
-
const {
|
3903
|
-
txParameters: { maxGasPerTx },
|
3904
|
-
predicateParameters: { maxGasPerPredicate },
|
3905
|
-
feeParameters: { gasPriceFactor, gasPerByte },
|
3906
|
-
gasCosts
|
3907
|
-
} = this.getChain().consensusParameters;
|
3831
|
+
const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
|
3908
3832
|
return {
|
3909
3833
|
maxGasPerTx,
|
3910
3834
|
maxGasPerPredicate,
|
@@ -3939,9 +3863,11 @@ var _Provider = class {
|
|
3939
3863
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3940
3864
|
const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
|
3941
3865
|
if (!isMajorSupported || !isMinorSupported) {
|
3942
|
-
|
3943
|
-
|
3944
|
-
|
3866
|
+
console.warn(
|
3867
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion},
|
3868
|
+
which is not supported by the version of the TS SDK that you are using.
|
3869
|
+
Things might or might not work as expected.
|
3870
|
+
Supported fuel-core version: ${supportedVersion}.`
|
3945
3871
|
);
|
3946
3872
|
}
|
3947
3873
|
}
|
@@ -3999,7 +3925,7 @@ var _Provider = class {
|
|
3999
3925
|
*/
|
4000
3926
|
async getBlockNumber() {
|
4001
3927
|
const { chain } = await this.operations.getChain();
|
4002
|
-
return
|
3928
|
+
return bn16(chain.latestBlock.height, 10);
|
4003
3929
|
}
|
4004
3930
|
/**
|
4005
3931
|
* Returns the chain information.
|
@@ -4009,8 +3935,8 @@ var _Provider = class {
|
|
4009
3935
|
async fetchNode() {
|
4010
3936
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
4011
3937
|
const processedNodeInfo = {
|
4012
|
-
maxDepth:
|
4013
|
-
maxTx:
|
3938
|
+
maxDepth: bn16(nodeInfo.maxDepth),
|
3939
|
+
maxTx: bn16(nodeInfo.maxTx),
|
4014
3940
|
nodeVersion: nodeInfo.nodeVersion,
|
4015
3941
|
utxoValidation: nodeInfo.utxoValidation,
|
4016
3942
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4114,9 +4040,9 @@ var _Provider = class {
|
|
4114
4040
|
encodedTransactions: encodedTransaction,
|
4115
4041
|
utxoValidation: utxoValidation || false
|
4116
4042
|
});
|
4117
|
-
const [{ receipts: rawReceipts, status
|
4043
|
+
const [{ receipts: rawReceipts, status }] = dryRunStatuses;
|
4118
4044
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4119
|
-
return { receipts,
|
4045
|
+
return { receipts, dryrunStatus: status };
|
4120
4046
|
}
|
4121
4047
|
/**
|
4122
4048
|
* Verifies whether enough gas is available to complete transaction.
|
@@ -4142,7 +4068,7 @@ var _Provider = class {
|
|
4142
4068
|
} = response;
|
4143
4069
|
if (inputs) {
|
4144
4070
|
inputs.forEach((input, index) => {
|
4145
|
-
if ("predicateGasUsed" in input &&
|
4071
|
+
if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
|
4146
4072
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4147
4073
|
}
|
4148
4074
|
});
|
@@ -4170,7 +4096,7 @@ var _Provider = class {
|
|
4170
4096
|
let receipts = [];
|
4171
4097
|
const missingContractIds = [];
|
4172
4098
|
let outputVariables = 0;
|
4173
|
-
let
|
4099
|
+
let dryrunStatus;
|
4174
4100
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4175
4101
|
const {
|
4176
4102
|
dryRun: [{ receipts: rawReceipts, status }]
|
@@ -4179,7 +4105,7 @@ var _Provider = class {
|
|
4179
4105
|
utxoValidation: false
|
4180
4106
|
});
|
4181
4107
|
receipts = rawReceipts.map(processGqlReceipt);
|
4182
|
-
|
4108
|
+
dryrunStatus = status;
|
4183
4109
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
4184
4110
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
4185
4111
|
if (hasMissingOutputs) {
|
@@ -4201,7 +4127,7 @@ var _Provider = class {
|
|
4201
4127
|
receipts,
|
4202
4128
|
outputVariables,
|
4203
4129
|
missingContractIds,
|
4204
|
-
|
4130
|
+
dryrunStatus
|
4205
4131
|
};
|
4206
4132
|
}
|
4207
4133
|
/**
|
@@ -4219,7 +4145,7 @@ var _Provider = class {
|
|
4219
4145
|
receipts: [],
|
4220
4146
|
outputVariables: 0,
|
4221
4147
|
missingContractIds: [],
|
4222
|
-
|
4148
|
+
dryrunStatus: void 0
|
4223
4149
|
}));
|
4224
4150
|
const allRequests = clone3(transactionRequests);
|
4225
4151
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
@@ -4244,7 +4170,7 @@ var _Provider = class {
|
|
4244
4170
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
4245
4171
|
const result = results[requestIdx];
|
4246
4172
|
result.receipts = rawReceipts.map(processGqlReceipt);
|
4247
|
-
result.
|
4173
|
+
result.dryrunStatus = status;
|
4248
4174
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
4249
4175
|
result.receipts
|
4250
4176
|
);
|
@@ -4281,7 +4207,7 @@ var _Provider = class {
|
|
4281
4207
|
});
|
4282
4208
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
4283
4209
|
const receipts = rawReceipts.map(processGqlReceipt);
|
4284
|
-
return { receipts,
|
4210
|
+
return { receipts, dryrunStatus: status };
|
4285
4211
|
});
|
4286
4212
|
return results;
|
4287
4213
|
}
|
@@ -4300,12 +4226,12 @@ var _Provider = class {
|
|
4300
4226
|
gasPrice = await this.estimateGasPrice(10);
|
4301
4227
|
}
|
4302
4228
|
const minFee = calculateGasFee({
|
4303
|
-
gasPrice:
|
4229
|
+
gasPrice: bn16(gasPrice),
|
4304
4230
|
gas: minGas,
|
4305
4231
|
priceFactor: gasPriceFactor,
|
4306
4232
|
tip: transactionRequest.tip
|
4307
4233
|
}).add(1);
|
4308
|
-
let gasLimit =
|
4234
|
+
let gasLimit = bn16(0);
|
4309
4235
|
if (transactionRequest.type === TransactionType8.Script) {
|
4310
4236
|
gasLimit = transactionRequest.gasLimit;
|
4311
4237
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4318,7 +4244,7 @@ var _Provider = class {
|
|
4318
4244
|
}
|
4319
4245
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4320
4246
|
const maxFee = calculateGasFee({
|
4321
|
-
gasPrice:
|
4247
|
+
gasPrice: bn16(gasPrice),
|
4322
4248
|
gas: maxGas,
|
4323
4249
|
priceFactor: gasPriceFactor,
|
4324
4250
|
tip: transactionRequest.tip
|
@@ -4381,9 +4307,9 @@ var _Provider = class {
|
|
4381
4307
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4382
4308
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4383
4309
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4384
|
-
txRequestClone.maxFee =
|
4310
|
+
txRequestClone.maxFee = bn16(0);
|
4385
4311
|
if (isScriptTransaction) {
|
4386
|
-
txRequestClone.gasLimit =
|
4312
|
+
txRequestClone.gasLimit = bn16(0);
|
4387
4313
|
}
|
4388
4314
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4389
4315
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4400,10 +4326,9 @@ var _Provider = class {
|
|
4400
4326
|
transactionRequest: signedRequest
|
4401
4327
|
});
|
4402
4328
|
let receipts = [];
|
4403
|
-
let dryRunStatus;
|
4404
4329
|
let missingContractIds = [];
|
4405
4330
|
let outputVariables = 0;
|
4406
|
-
let gasUsed =
|
4331
|
+
let gasUsed = bn16(0);
|
4407
4332
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4408
4333
|
txRequestClone.maxFee = maxFee;
|
4409
4334
|
if (isScriptTransaction) {
|
@@ -4411,7 +4336,10 @@ var _Provider = class {
|
|
4411
4336
|
if (signatureCallback) {
|
4412
4337
|
await signatureCallback(txRequestClone);
|
4413
4338
|
}
|
4414
|
-
|
4339
|
+
const result = await this.estimateTxDependencies(txRequestClone);
|
4340
|
+
receipts = result.receipts;
|
4341
|
+
outputVariables = result.outputVariables;
|
4342
|
+
missingContractIds = result.missingContractIds;
|
4415
4343
|
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
4416
4344
|
txRequestClone.gasLimit = gasUsed;
|
4417
4345
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
@@ -4431,8 +4359,7 @@ var _Provider = class {
|
|
4431
4359
|
outputVariables,
|
4432
4360
|
missingContractIds,
|
4433
4361
|
addedSignatures,
|
4434
|
-
estimatedPredicates: txRequestClone.inputs
|
4435
|
-
dryRunStatus
|
4362
|
+
estimatedPredicates: txRequestClone.inputs
|
4436
4363
|
};
|
4437
4364
|
}
|
4438
4365
|
async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
|
@@ -4468,10 +4395,10 @@ var _Provider = class {
|
|
4468
4395
|
return coins.map((coin) => ({
|
4469
4396
|
id: coin.utxoId,
|
4470
4397
|
assetId: coin.assetId,
|
4471
|
-
amount:
|
4398
|
+
amount: bn16(coin.amount),
|
4472
4399
|
owner: Address2.fromAddressOrString(coin.owner),
|
4473
|
-
blockCreated:
|
4474
|
-
txCreatedIdx:
|
4400
|
+
blockCreated: bn16(coin.blockCreated),
|
4401
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4475
4402
|
}));
|
4476
4403
|
}
|
4477
4404
|
/**
|
@@ -4508,9 +4435,9 @@ var _Provider = class {
|
|
4508
4435
|
switch (coin.__typename) {
|
4509
4436
|
case "MessageCoin":
|
4510
4437
|
return {
|
4511
|
-
amount:
|
4438
|
+
amount: bn16(coin.amount),
|
4512
4439
|
assetId: coin.assetId,
|
4513
|
-
daHeight:
|
4440
|
+
daHeight: bn16(coin.daHeight),
|
4514
4441
|
sender: Address2.fromAddressOrString(coin.sender),
|
4515
4442
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4516
4443
|
nonce: coin.nonce
|
@@ -4518,11 +4445,11 @@ var _Provider = class {
|
|
4518
4445
|
case "Coin":
|
4519
4446
|
return {
|
4520
4447
|
id: coin.utxoId,
|
4521
|
-
amount:
|
4448
|
+
amount: bn16(coin.amount),
|
4522
4449
|
assetId: coin.assetId,
|
4523
4450
|
owner: Address2.fromAddressOrString(coin.owner),
|
4524
|
-
blockCreated:
|
4525
|
-
txCreatedIdx:
|
4451
|
+
blockCreated: bn16(coin.blockCreated),
|
4452
|
+
txCreatedIdx: bn16(coin.txCreatedIdx)
|
4526
4453
|
};
|
4527
4454
|
default:
|
4528
4455
|
return null;
|
@@ -4539,13 +4466,13 @@ var _Provider = class {
|
|
4539
4466
|
async getBlock(idOrHeight) {
|
4540
4467
|
let variables;
|
4541
4468
|
if (typeof idOrHeight === "number") {
|
4542
|
-
variables = { height:
|
4469
|
+
variables = { height: bn16(idOrHeight).toString(10) };
|
4543
4470
|
} else if (idOrHeight === "latest") {
|
4544
4471
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4545
4472
|
} else if (idOrHeight.length === 66) {
|
4546
4473
|
variables = { blockId: idOrHeight };
|
4547
4474
|
} else {
|
4548
|
-
variables = { blockId:
|
4475
|
+
variables = { blockId: bn16(idOrHeight).toString(10) };
|
4549
4476
|
}
|
4550
4477
|
const { block } = await this.operations.getBlock(variables);
|
4551
4478
|
if (!block) {
|
@@ -4553,7 +4480,7 @@ var _Provider = class {
|
|
4553
4480
|
}
|
4554
4481
|
return {
|
4555
4482
|
id: block.id,
|
4556
|
-
height:
|
4483
|
+
height: bn16(block.height),
|
4557
4484
|
time: block.header.time,
|
4558
4485
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4559
4486
|
};
|
@@ -4568,7 +4495,7 @@ var _Provider = class {
|
|
4568
4495
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4569
4496
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4570
4497
|
id: block.id,
|
4571
|
-
height:
|
4498
|
+
height: bn16(block.height),
|
4572
4499
|
time: block.header.time,
|
4573
4500
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4574
4501
|
}));
|
@@ -4583,7 +4510,7 @@ var _Provider = class {
|
|
4583
4510
|
async getBlockWithTransactions(idOrHeight) {
|
4584
4511
|
let variables;
|
4585
4512
|
if (typeof idOrHeight === "number") {
|
4586
|
-
variables = { blockHeight:
|
4513
|
+
variables = { blockHeight: bn16(idOrHeight).toString(10) };
|
4587
4514
|
} else if (idOrHeight === "latest") {
|
4588
4515
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4589
4516
|
} else {
|
@@ -4595,7 +4522,7 @@ var _Provider = class {
|
|
4595
4522
|
}
|
4596
4523
|
return {
|
4597
4524
|
id: block.id,
|
4598
|
-
height:
|
4525
|
+
height: bn16(block.height, 10),
|
4599
4526
|
time: block.header.time,
|
4600
4527
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4601
4528
|
transactions: block.transactions.map(
|
@@ -4644,7 +4571,7 @@ var _Provider = class {
|
|
4644
4571
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4645
4572
|
asset: hexlify12(assetId)
|
4646
4573
|
});
|
4647
|
-
return
|
4574
|
+
return bn16(contractBalance.amount, 10);
|
4648
4575
|
}
|
4649
4576
|
/**
|
4650
4577
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4658,7 +4585,7 @@ var _Provider = class {
|
|
4658
4585
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4659
4586
|
assetId: hexlify12(assetId)
|
4660
4587
|
});
|
4661
|
-
return
|
4588
|
+
return bn16(balance.amount, 10);
|
4662
4589
|
}
|
4663
4590
|
/**
|
4664
4591
|
* Returns balances for the given owner.
|
@@ -4676,7 +4603,7 @@ var _Provider = class {
|
|
4676
4603
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4677
4604
|
return balances.map((balance) => ({
|
4678
4605
|
assetId: balance.assetId,
|
4679
|
-
amount:
|
4606
|
+
amount: bn16(balance.amount)
|
4680
4607
|
}));
|
4681
4608
|
}
|
4682
4609
|
/**
|
@@ -4698,15 +4625,15 @@ var _Provider = class {
|
|
4698
4625
|
sender: message.sender,
|
4699
4626
|
recipient: message.recipient,
|
4700
4627
|
nonce: message.nonce,
|
4701
|
-
amount:
|
4628
|
+
amount: bn16(message.amount),
|
4702
4629
|
data: message.data
|
4703
4630
|
}),
|
4704
4631
|
sender: Address2.fromAddressOrString(message.sender),
|
4705
4632
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4706
4633
|
nonce: message.nonce,
|
4707
|
-
amount:
|
4634
|
+
amount: bn16(message.amount),
|
4708
4635
|
data: InputMessageCoder.decodeData(message.data),
|
4709
|
-
daHeight:
|
4636
|
+
daHeight: bn16(message.daHeight)
|
4710
4637
|
}));
|
4711
4638
|
}
|
4712
4639
|
/**
|
@@ -4759,59 +4686,59 @@ var _Provider = class {
|
|
4759
4686
|
} = result.messageProof;
|
4760
4687
|
return {
|
4761
4688
|
messageProof: {
|
4762
|
-
proofIndex:
|
4689
|
+
proofIndex: bn16(messageProof.proofIndex),
|
4763
4690
|
proofSet: messageProof.proofSet
|
4764
4691
|
},
|
4765
4692
|
blockProof: {
|
4766
|
-
proofIndex:
|
4693
|
+
proofIndex: bn16(blockProof.proofIndex),
|
4767
4694
|
proofSet: blockProof.proofSet
|
4768
4695
|
},
|
4769
4696
|
messageBlockHeader: {
|
4770
4697
|
id: messageBlockHeader.id,
|
4771
|
-
daHeight:
|
4772
|
-
transactionsCount:
|
4698
|
+
daHeight: bn16(messageBlockHeader.daHeight),
|
4699
|
+
transactionsCount: bn16(messageBlockHeader.transactionsCount),
|
4773
4700
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4774
|
-
height:
|
4701
|
+
height: bn16(messageBlockHeader.height),
|
4775
4702
|
prevRoot: messageBlockHeader.prevRoot,
|
4776
4703
|
time: messageBlockHeader.time,
|
4777
4704
|
applicationHash: messageBlockHeader.applicationHash,
|
4778
|
-
messageReceiptCount:
|
4705
|
+
messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
|
4779
4706
|
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4780
|
-
consensusParametersVersion:
|
4707
|
+
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4781
4708
|
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
4782
|
-
stateTransitionBytecodeVersion:
|
4709
|
+
stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
|
4783
4710
|
},
|
4784
4711
|
commitBlockHeader: {
|
4785
4712
|
id: commitBlockHeader.id,
|
4786
|
-
daHeight:
|
4787
|
-
transactionsCount:
|
4713
|
+
daHeight: bn16(commitBlockHeader.daHeight),
|
4714
|
+
transactionsCount: bn16(commitBlockHeader.transactionsCount),
|
4788
4715
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4789
|
-
height:
|
4716
|
+
height: bn16(commitBlockHeader.height),
|
4790
4717
|
prevRoot: commitBlockHeader.prevRoot,
|
4791
4718
|
time: commitBlockHeader.time,
|
4792
4719
|
applicationHash: commitBlockHeader.applicationHash,
|
4793
|
-
messageReceiptCount:
|
4720
|
+
messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
|
4794
4721
|
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4795
|
-
consensusParametersVersion:
|
4722
|
+
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4796
4723
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
4797
|
-
stateTransitionBytecodeVersion:
|
4724
|
+
stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
|
4798
4725
|
},
|
4799
4726
|
sender: Address2.fromAddressOrString(sender),
|
4800
4727
|
recipient: Address2.fromAddressOrString(recipient),
|
4801
4728
|
nonce,
|
4802
|
-
amount:
|
4729
|
+
amount: bn16(amount),
|
4803
4730
|
data
|
4804
4731
|
};
|
4805
4732
|
}
|
4806
4733
|
async getLatestGasPrice() {
|
4807
4734
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4808
|
-
return
|
4735
|
+
return bn16(latestGasPrice.gasPrice);
|
4809
4736
|
}
|
4810
4737
|
async estimateGasPrice(blockHorizon) {
|
4811
4738
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4812
4739
|
blockHorizon: String(blockHorizon)
|
4813
4740
|
});
|
4814
|
-
return
|
4741
|
+
return bn16(estimateGasPrice.gasPrice);
|
4815
4742
|
}
|
4816
4743
|
/**
|
4817
4744
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4832,10 +4759,10 @@ var _Provider = class {
|
|
4832
4759
|
*/
|
4833
4760
|
async produceBlocks(amount, startTime) {
|
4834
4761
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4835
|
-
blocksToProduce:
|
4762
|
+
blocksToProduce: bn16(amount).toString(10),
|
4836
4763
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4837
4764
|
});
|
4838
|
-
return
|
4765
|
+
return bn16(latestBlockHeight);
|
4839
4766
|
}
|
4840
4767
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4841
4768
|
async getTransactionResponse(transactionId) {
|
@@ -4854,15 +4781,6 @@ var _Provider = class {
|
|
4854
4781
|
}
|
4855
4782
|
return message;
|
4856
4783
|
}
|
4857
|
-
async getRelayedTransactionStatus(relayedTransactionId) {
|
4858
|
-
const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
|
4859
|
-
relayedTransactionId
|
4860
|
-
});
|
4861
|
-
if (!relayedTransactionStatus) {
|
4862
|
-
return null;
|
4863
|
-
}
|
4864
|
-
return relayedTransactionStatus;
|
4865
|
-
}
|
4866
4784
|
};
|
4867
4785
|
var Provider = _Provider;
|
4868
4786
|
_cacheInputs = new WeakSet();
|
@@ -4881,7 +4799,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4881
4799
|
|
4882
4800
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4883
4801
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4884
|
-
import { bn as
|
4802
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
4885
4803
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4886
4804
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4887
4805
|
async function getTransactionSummary(params) {
|
@@ -4905,11 +4823,7 @@ async function getTransactionSummary(params) {
|
|
4905
4823
|
}
|
4906
4824
|
const receipts = txReceipts.map(processGqlReceipt);
|
4907
4825
|
const {
|
4908
|
-
consensusParameters: {
|
4909
|
-
feeParameters: { gasPerByte, gasPriceFactor },
|
4910
|
-
txParameters: { maxInputs, maxGasPerTx },
|
4911
|
-
gasCosts
|
4912
|
-
}
|
4826
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4913
4827
|
} = provider.getChain();
|
4914
4828
|
const gasPrice = await provider.getLatestGasPrice();
|
4915
4829
|
const transactionInfo = assembleTransactionSummary({
|
@@ -4918,8 +4832,8 @@ async function getTransactionSummary(params) {
|
|
4918
4832
|
transaction: decodedTransaction,
|
4919
4833
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4920
4834
|
gqlTransactionStatus: gqlTransaction.status,
|
4921
|
-
gasPerByte:
|
4922
|
-
gasPriceFactor:
|
4835
|
+
gasPerByte: bn17(gasPerByte),
|
4836
|
+
gasPriceFactor: bn17(gasPriceFactor),
|
4923
4837
|
abiMap,
|
4924
4838
|
maxInputs,
|
4925
4839
|
gasCosts,
|
@@ -4935,7 +4849,7 @@ async function getTransactionSummaryFromRequest(params) {
|
|
4935
4849
|
const { provider, transactionRequest, abiMap } = params;
|
4936
4850
|
const { receipts } = await provider.call(transactionRequest);
|
4937
4851
|
const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
|
4938
|
-
const maxInputs = provider.getChain().consensusParameters.
|
4852
|
+
const maxInputs = provider.getChain().consensusParameters.maxInputs;
|
4939
4853
|
const transaction = transactionRequest.toTransaction();
|
4940
4854
|
const transactionBytes = transactionRequest.toTransactionBytes();
|
4941
4855
|
const gasPrice = await provider.getLatestGasPrice();
|
@@ -4958,11 +4872,7 @@ async function getTransactionsSummaries(params) {
|
|
4958
4872
|
const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
|
4959
4873
|
const { edges, pageInfo } = transactionsByOwner;
|
4960
4874
|
const {
|
4961
|
-
consensusParameters: {
|
4962
|
-
feeParameters: { gasPerByte, gasPriceFactor },
|
4963
|
-
txParameters: { maxInputs, maxGasPerTx },
|
4964
|
-
gasCosts
|
4965
|
-
}
|
4875
|
+
consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
|
4966
4876
|
} = provider.getChain();
|
4967
4877
|
const gasPrice = await provider.getLatestGasPrice();
|
4968
4878
|
const transactions = edges.map((edge) => {
|
@@ -5122,7 +5032,7 @@ var assets = [
|
|
5122
5032
|
];
|
5123
5033
|
|
5124
5034
|
// src/providers/transaction-request/helpers.ts
|
5125
|
-
import { bn as
|
5035
|
+
import { bn as bn18 } from "@fuel-ts/math";
|
5126
5036
|
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
5127
5037
|
var isRequestInputCoin = (input) => input.type === InputType8.Coin;
|
5128
5038
|
var isRequestInputMessage = (input) => input.type === InputType8.Message;
|
@@ -5135,7 +5045,7 @@ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filte
|
|
5135
5045
|
return acc.add(input.amount);
|
5136
5046
|
}
|
5137
5047
|
return acc;
|
5138
|
-
},
|
5048
|
+
}, bn18(0));
|
5139
5049
|
|
5140
5050
|
// src/utils/formatTransferToContractScriptData.ts
|
5141
5051
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
@@ -5339,10 +5249,10 @@ var Account = class extends AbstractAccount {
|
|
5339
5249
|
async fund(request, params) {
|
5340
5250
|
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
5341
5251
|
const baseAssetId = this.provider.getBaseAssetId();
|
5342
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
5252
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
|
5343
5253
|
const txRequest = request;
|
5344
5254
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5345
|
-
amount:
|
5255
|
+
amount: bn19(fee),
|
5346
5256
|
assetId: baseAssetId,
|
5347
5257
|
coinQuantities: requiredQuantities
|
5348
5258
|
});
|
@@ -5350,7 +5260,7 @@ var Account = class extends AbstractAccount {
|
|
5350
5260
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5351
5261
|
quantitiesDict[assetId] = {
|
5352
5262
|
required: amount,
|
5353
|
-
owned:
|
5263
|
+
owned: bn19(0)
|
5354
5264
|
};
|
5355
5265
|
});
|
5356
5266
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5455,7 +5365,7 @@ var Account = class extends AbstractAccount {
|
|
5455
5365
|
* @returns A promise that resolves to the transaction response.
|
5456
5366
|
*/
|
5457
5367
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5458
|
-
if (
|
5368
|
+
if (bn19(amount).lte(0)) {
|
5459
5369
|
throw new FuelError15(
|
5460
5370
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5461
5371
|
"Transfer amount must be a positive number."
|
@@ -5475,7 +5385,7 @@ var Account = class extends AbstractAccount {
|
|
5475
5385
|
* @returns A promise that resolves to the transaction response.
|
5476
5386
|
*/
|
5477
5387
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5478
|
-
if (
|
5388
|
+
if (bn19(amount).lte(0)) {
|
5479
5389
|
throw new FuelError15(
|
5480
5390
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5481
5391
|
"Transfer amount must be a positive number."
|
@@ -5485,7 +5395,7 @@ var Account = class extends AbstractAccount {
|
|
5485
5395
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5486
5396
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5487
5397
|
hexlifiedContractId: contractAddress.toB256(),
|
5488
|
-
amountToTransfer:
|
5398
|
+
amountToTransfer: bn19(amount),
|
5489
5399
|
assetId: assetIdToTransfer
|
5490
5400
|
});
|
5491
5401
|
const request = new ScriptTransactionRequest({
|
@@ -5496,7 +5406,7 @@ var Account = class extends AbstractAccount {
|
|
5496
5406
|
request.addContractInputAndOutput(contractAddress);
|
5497
5407
|
const txCost = await this.provider.getTransactionCost(request, {
|
5498
5408
|
resourcesOwner: this,
|
5499
|
-
quantitiesToContract: [{ amount:
|
5409
|
+
quantitiesToContract: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
|
5500
5410
|
});
|
5501
5411
|
this.validateGasLimitAndMaxFee({
|
5502
5412
|
gasUsed: txCost.gasUsed,
|
@@ -5522,7 +5432,7 @@ var Account = class extends AbstractAccount {
|
|
5522
5432
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5523
5433
|
);
|
5524
5434
|
const amountDataArray = arrayify14(
|
5525
|
-
"0x".concat(
|
5435
|
+
"0x".concat(bn19(amount).toHex().substring(2).padStart(16, "0"))
|
5526
5436
|
);
|
5527
5437
|
const script = new Uint8Array([
|
5528
5438
|
...arrayify14(withdrawScript.bytes),
|
@@ -5532,7 +5442,7 @@ var Account = class extends AbstractAccount {
|
|
5532
5442
|
const params = { script, ...txParams };
|
5533
5443
|
const baseAssetId = this.provider.getBaseAssetId();
|
5534
5444
|
const request = new ScriptTransactionRequest(params);
|
5535
|
-
const quantitiesToContract = [{ amount:
|
5445
|
+
const quantitiesToContract = [{ amount: bn19(amount), assetId: baseAssetId }];
|
5536
5446
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5537
5447
|
this.validateGasLimitAndMaxFee({
|
5538
5448
|
gasUsed: txCost.gasUsed,
|
@@ -5946,7 +5856,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5946
5856
|
// src/hdwallet/hdwallet.ts
|
5947
5857
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5948
5858
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5949
|
-
import { bn as
|
5859
|
+
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5950
5860
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5951
5861
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5952
5862
|
|
@@ -8418,7 +8328,7 @@ var HDWallet = class {
|
|
8418
8328
|
const IR = bytes.slice(32);
|
8419
8329
|
if (privateKey) {
|
8420
8330
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8421
|
-
const ki =
|
8331
|
+
const ki = bn20(IL).add(privateKey).mod(N).toBytes(32);
|
8422
8332
|
return new HDWallet({
|
8423
8333
|
privateKey: ki,
|
8424
8334
|
chainCode: IR,
|
@@ -9200,7 +9110,7 @@ var Predicate = class extends Account {
|
|
9200
9110
|
const mainFn = this.interface?.functions.main;
|
9201
9111
|
const paddedCode = new ByteArrayCoder(this.bytes.length).encode(this.bytes);
|
9202
9112
|
const VM_TX_MEMORY = calculateVmTxMemory2({
|
9203
|
-
maxInputs: this.provider.getChain().consensusParameters.
|
9113
|
+
maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
|
9204
9114
|
});
|
9205
9115
|
const OFFSET = VM_TX_MEMORY + SCRIPT_FIXED_SIZE + INPUT_COIN_FIXED_SIZE + WORD_SIZE + paddedCode.byteLength + policiesLength * WORD_SIZE;
|
9206
9116
|
return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
|
@@ -10017,7 +9927,7 @@ export {
|
|
10017
9927
|
calculateGasFee,
|
10018
9928
|
calculateMetadataGasForTxCreate,
|
10019
9929
|
calculateMetadataGasForTxScript,
|
10020
|
-
|
9930
|
+
calculateTransactionFee,
|
10021
9931
|
coinQuantityfy,
|
10022
9932
|
deferPromise,
|
10023
9933
|
dispatchFuelConnectorEvent,
|
@@ -10077,8 +9987,6 @@ export {
|
|
10077
9987
|
isTypeCreate,
|
10078
9988
|
isTypeMint,
|
10079
9989
|
isTypeScript,
|
10080
|
-
isTypeUpgrade,
|
10081
|
-
isTypeUpload,
|
10082
9990
|
normalizeJSON,
|
10083
9991
|
outputify,
|
10084
9992
|
processGqlReceipt,
|