@fuel-ts/account 0.0.0-pr-2143-20240514195938 → 0.0.0-pr-2328-20240517121917
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/account.d.ts.map +1 -1
- package/dist/configs.d.ts +1 -1
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -1
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +5 -5
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +3 -3
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +627 -1542
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +153 -197
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -193
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts +0 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +8 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +0 -1
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +0 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +4 -1
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +0 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +0 -1
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/call.d.ts +1 -1
- package/dist/providers/transaction-summary/call.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +2 -4
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +2 -4
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +734 -3868
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +147 -184
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +136 -173
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/dist/test-utils.js
CHANGED
@@ -64,7 +64,7 @@ var import_utils31 = require("@fuel-ts/utils");
|
|
64
64
|
var import_address4 = require("@fuel-ts/address");
|
65
65
|
var import_errors16 = require("@fuel-ts/errors");
|
66
66
|
var import_interfaces = require("@fuel-ts/interfaces");
|
67
|
-
var
|
67
|
+
var import_math20 = require("@fuel-ts/math");
|
68
68
|
var import_utils28 = require("@fuel-ts/utils");
|
69
69
|
var import_ramda4 = require("ramda");
|
70
70
|
|
@@ -106,7 +106,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
106
106
|
// src/providers/provider.ts
|
107
107
|
var import_address3 = require("@fuel-ts/address");
|
108
108
|
var import_errors14 = require("@fuel-ts/errors");
|
109
|
-
var
|
109
|
+
var import_math17 = require("@fuel-ts/math");
|
110
110
|
var import_transactions20 = require("@fuel-ts/transactions");
|
111
111
|
var import_utils22 = require("@fuel-ts/utils");
|
112
112
|
var import_versions = require("@fuel-ts/versions");
|
@@ -248,6 +248,7 @@ var TransactionEstimatePredicatesFragmentDoc = import_graphql_tag.default`
|
|
248
248
|
${InputEstimatePredicatesFragmentDoc}`;
|
249
249
|
var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
|
250
250
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
251
|
+
type: __typename
|
251
252
|
totalGas
|
252
253
|
totalFee
|
253
254
|
reason
|
@@ -259,6 +260,7 @@ var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
|
|
259
260
|
`;
|
260
261
|
var DryRunSuccessStatusFragmentDoc = import_graphql_tag.default`
|
261
262
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
263
|
+
type: __typename
|
262
264
|
totalGas
|
263
265
|
totalFee
|
264
266
|
programState {
|
@@ -1681,17 +1683,16 @@ var import_errors7 = require("@fuel-ts/errors");
|
|
1681
1683
|
var import_math6 = require("@fuel-ts/math");
|
1682
1684
|
var import_transactions5 = require("@fuel-ts/transactions");
|
1683
1685
|
var import_configs5 = require("@fuel-ts/transactions/configs");
|
1684
|
-
var assemblePanicError = (
|
1685
|
-
let errorMessage = `The transaction reverted with reason: "${
|
1686
|
-
|
1687
|
-
if (import_configs5.PANIC_REASONS.includes(status.reason)) {
|
1686
|
+
var assemblePanicError = (statusReason) => {
|
1687
|
+
let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
|
1688
|
+
if (import_configs5.PANIC_REASONS.includes(statusReason)) {
|
1688
1689
|
errorMessage = `${errorMessage}
|
1689
1690
|
|
1690
1691
|
You can read more about this error at:
|
1691
1692
|
|
1692
|
-
${import_configs5.PANIC_DOC_URL}#variant.${
|
1693
|
+
${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
|
1693
1694
|
}
|
1694
|
-
return { errorMessage, reason };
|
1695
|
+
return { errorMessage, reason: statusReason };
|
1695
1696
|
};
|
1696
1697
|
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
1697
1698
|
var assembleRevertError = (receipts, logs) => {
|
@@ -1734,10 +1735,10 @@ var assembleRevertError = (receipts, logs) => {
|
|
1734
1735
|
return { errorMessage, reason };
|
1735
1736
|
};
|
1736
1737
|
var extractTxError = (params) => {
|
1737
|
-
const { receipts,
|
1738
|
+
const { receipts, statusReason, logs } = params;
|
1738
1739
|
const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
|
1739
1740
|
const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
|
1740
|
-
const { errorMessage, reason } =
|
1741
|
+
const { errorMessage, reason } = isPanic ? assemblePanicError(statusReason) : assembleRevertError(receipts, logs);
|
1741
1742
|
const metadata = {
|
1742
1743
|
logs,
|
1743
1744
|
receipts,
|
@@ -2296,15 +2297,6 @@ var BaseTransactionRequest = class {
|
|
2296
2297
|
}
|
2297
2298
|
});
|
2298
2299
|
}
|
2299
|
-
shiftPredicateData() {
|
2300
|
-
this.inputs.forEach((input) => {
|
2301
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2302
|
-
input.predicateData = input.padPredicateData(
|
2303
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2304
|
-
);
|
2305
|
-
}
|
2306
|
-
});
|
2307
|
-
}
|
2308
2300
|
};
|
2309
2301
|
|
2310
2302
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2727,12 +2719,12 @@ var transactionRequestify = (obj) => {
|
|
2727
2719
|
|
2728
2720
|
// src/providers/transaction-response/transaction-response.ts
|
2729
2721
|
var import_errors13 = require("@fuel-ts/errors");
|
2730
|
-
var
|
2722
|
+
var import_math16 = require("@fuel-ts/math");
|
2731
2723
|
var import_transactions19 = require("@fuel-ts/transactions");
|
2732
2724
|
var import_utils20 = require("@fuel-ts/utils");
|
2733
2725
|
|
2734
2726
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2735
|
-
var
|
2727
|
+
var import_math15 = require("@fuel-ts/math");
|
2736
2728
|
var import_transactions17 = require("@fuel-ts/transactions");
|
2737
2729
|
var import_utils18 = require("@fuel-ts/utils");
|
2738
2730
|
|
@@ -2809,43 +2801,32 @@ var calculateTXFeeForSummary = (params) => {
|
|
2809
2801
|
// src/providers/transaction-summary/operations.ts
|
2810
2802
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2811
2803
|
var import_errors11 = require("@fuel-ts/errors");
|
2812
|
-
var
|
2804
|
+
var import_math13 = require("@fuel-ts/math");
|
2813
2805
|
var import_transactions15 = require("@fuel-ts/transactions");
|
2814
2806
|
|
2815
2807
|
// src/providers/transaction-summary/call.ts
|
2816
2808
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
2817
|
-
var
|
2818
|
-
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2809
|
+
var getFunctionCall = ({ abi, receipt }) => {
|
2819
2810
|
const abiInterface = new import_abi_coder4.Interface(abi);
|
2820
2811
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2821
2812
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2822
2813
|
const inputs = functionFragment.jsonFn.inputs;
|
2823
|
-
|
2824
|
-
if (functionFragment.isInputDataPointer) {
|
2825
|
-
if (rawPayload) {
|
2826
|
-
const argsOffset = (0, import_math13.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2827
|
-
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2828
|
-
}
|
2829
|
-
} else {
|
2830
|
-
encodedArgs = receipt.param2.toHex();
|
2831
|
-
}
|
2814
|
+
const encodedArgs = receipt.param2.toHex();
|
2832
2815
|
let argumentsProvided;
|
2833
|
-
|
2834
|
-
|
2835
|
-
|
2836
|
-
|
2837
|
-
|
2838
|
-
|
2839
|
-
|
2840
|
-
|
2841
|
-
|
2842
|
-
|
2843
|
-
|
2844
|
-
|
2845
|
-
|
2846
|
-
|
2847
|
-
}, {});
|
2848
|
-
}
|
2816
|
+
const data = functionFragment.decodeArguments(encodedArgs);
|
2817
|
+
if (data) {
|
2818
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
2819
|
+
const value = data[index];
|
2820
|
+
const name = input.name;
|
2821
|
+
if (name) {
|
2822
|
+
return {
|
2823
|
+
...prev,
|
2824
|
+
// reparse to remove bn
|
2825
|
+
[name]: JSON.parse(JSON.stringify(value))
|
2826
|
+
};
|
2827
|
+
}
|
2828
|
+
return prev;
|
2829
|
+
}, {});
|
2849
2830
|
}
|
2850
2831
|
const call = {
|
2851
2832
|
functionSignature: functionFragment.signature,
|
@@ -2985,7 +2966,7 @@ var mergeAssets = (op1, op2) => {
|
|
2985
2966
|
if (!matchingAsset) {
|
2986
2967
|
return asset1;
|
2987
2968
|
}
|
2988
|
-
const mergedAmount = (0,
|
2969
|
+
const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
|
2989
2970
|
return { ...asset1, amount: mergedAmount };
|
2990
2971
|
});
|
2991
2972
|
return mergedAssets.concat(filteredAssets);
|
@@ -3308,7 +3289,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3308
3289
|
|
3309
3290
|
// src/providers/transaction-summary/status.ts
|
3310
3291
|
var import_errors12 = require("@fuel-ts/errors");
|
3311
|
-
var
|
3292
|
+
var import_math14 = require("@fuel-ts/math");
|
3312
3293
|
var getTransactionStatusName = (gqlStatus) => {
|
3313
3294
|
switch (gqlStatus) {
|
3314
3295
|
case "FailureStatus":
|
@@ -3342,15 +3323,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3342
3323
|
time = gqlTransactionStatus.time;
|
3343
3324
|
blockId = gqlTransactionStatus.block.id;
|
3344
3325
|
isStatusSuccess = true;
|
3345
|
-
totalFee = (0,
|
3346
|
-
totalGas = (0,
|
3326
|
+
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3327
|
+
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3347
3328
|
break;
|
3348
3329
|
case "FailureStatus":
|
3349
3330
|
time = gqlTransactionStatus.time;
|
3350
3331
|
blockId = gqlTransactionStatus.block.id;
|
3351
3332
|
isStatusFailure = true;
|
3352
|
-
totalFee = (0,
|
3353
|
-
totalGas = (0,
|
3333
|
+
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3334
|
+
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3354
3335
|
break;
|
3355
3336
|
case "SubmittedStatus":
|
3356
3337
|
time = gqlTransactionStatus.time;
|
@@ -3400,7 +3381,7 @@ function assembleTransactionSummary(params) {
|
|
3400
3381
|
maxInputs
|
3401
3382
|
});
|
3402
3383
|
const typeName = getTransactionTypeName(transaction.type);
|
3403
|
-
const tip = (0,
|
3384
|
+
const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
3404
3385
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3405
3386
|
const fee = calculateTXFeeForSummary({
|
3406
3387
|
totalFee,
|
@@ -3471,7 +3452,7 @@ var TransactionResponse = class {
|
|
3471
3452
|
/** Current provider */
|
3472
3453
|
provider;
|
3473
3454
|
/** Gas used on the transaction */
|
3474
|
-
gasUsed = (0,
|
3455
|
+
gasUsed = (0, import_math16.bn)(0);
|
3475
3456
|
/** The graphql Transaction with receipts object. */
|
3476
3457
|
gqlTransaction;
|
3477
3458
|
abis;
|
@@ -3615,14 +3596,12 @@ var TransactionResponse = class {
|
|
3615
3596
|
);
|
3616
3597
|
transactionResult.logs = logs;
|
3617
3598
|
}
|
3618
|
-
|
3619
|
-
|
3620
|
-
|
3621
|
-
gqlTransaction: { status }
|
3622
|
-
} = transactionResult;
|
3599
|
+
const { gqlTransaction, receipts } = transactionResult;
|
3600
|
+
if (gqlTransaction.status?.type === "FailureStatus") {
|
3601
|
+
const { reason } = gqlTransaction.status;
|
3623
3602
|
throw extractTxError({
|
3624
3603
|
receipts,
|
3625
|
-
|
3604
|
+
statusReason: reason,
|
3626
3605
|
logs
|
3627
3606
|
});
|
3628
3607
|
}
|
@@ -3705,47 +3684,47 @@ var processGqlChain = (chain) => {
|
|
3705
3684
|
} = consensusParameters;
|
3706
3685
|
return {
|
3707
3686
|
name,
|
3708
|
-
baseChainHeight: (0,
|
3687
|
+
baseChainHeight: (0, import_math17.bn)(daHeight),
|
3709
3688
|
consensusParameters: {
|
3710
3689
|
version,
|
3711
|
-
chainId: (0,
|
3690
|
+
chainId: (0, import_math17.bn)(chainId),
|
3712
3691
|
baseAssetId,
|
3713
3692
|
feeParameters: {
|
3714
3693
|
version: feeParams.version,
|
3715
|
-
gasPerByte: (0,
|
3716
|
-
gasPriceFactor: (0,
|
3694
|
+
gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
|
3695
|
+
gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
|
3717
3696
|
},
|
3718
3697
|
contractParameters: {
|
3719
3698
|
version: contractParams.version,
|
3720
|
-
contractMaxSize: (0,
|
3721
|
-
maxStorageSlots: (0,
|
3699
|
+
contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
|
3700
|
+
maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
|
3722
3701
|
},
|
3723
3702
|
txParameters: {
|
3724
3703
|
version: txParams.version,
|
3725
|
-
maxInputs: (0,
|
3726
|
-
maxOutputs: (0,
|
3727
|
-
maxWitnesses: (0,
|
3728
|
-
maxGasPerTx: (0,
|
3729
|
-
maxSize: (0,
|
3730
|
-
maxBytecodeSubsections: (0,
|
3704
|
+
maxInputs: (0, import_math17.bn)(txParams.maxInputs),
|
3705
|
+
maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
|
3706
|
+
maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
|
3707
|
+
maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
|
3708
|
+
maxSize: (0, import_math17.bn)(txParams.maxSize),
|
3709
|
+
maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
|
3731
3710
|
},
|
3732
3711
|
predicateParameters: {
|
3733
3712
|
version: predicateParams.version,
|
3734
|
-
maxPredicateLength: (0,
|
3735
|
-
maxPredicateDataLength: (0,
|
3736
|
-
maxGasPerPredicate: (0,
|
3737
|
-
maxMessageDataLength: (0,
|
3713
|
+
maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
|
3714
|
+
maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
|
3715
|
+
maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
|
3716
|
+
maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
|
3738
3717
|
},
|
3739
3718
|
scriptParameters: {
|
3740
3719
|
version: scriptParams.version,
|
3741
|
-
maxScriptLength: (0,
|
3742
|
-
maxScriptDataLength: (0,
|
3720
|
+
maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
|
3721
|
+
maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
|
3743
3722
|
},
|
3744
3723
|
gasCosts
|
3745
3724
|
},
|
3746
3725
|
latestBlock: {
|
3747
3726
|
id: latestBlock.id,
|
3748
|
-
height: (0,
|
3727
|
+
height: (0, import_math17.bn)(latestBlock.height),
|
3749
3728
|
time: latestBlock.header.time,
|
3750
3729
|
transactions: latestBlock.transactions.map((i) => ({
|
3751
3730
|
id: i.id
|
@@ -3941,7 +3920,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3941
3920
|
*/
|
3942
3921
|
async getBlockNumber() {
|
3943
3922
|
const { chain } = await this.operations.getChain();
|
3944
|
-
return (0,
|
3923
|
+
return (0, import_math17.bn)(chain.latestBlock.height, 10);
|
3945
3924
|
}
|
3946
3925
|
/**
|
3947
3926
|
* Returns the chain information.
|
@@ -3951,8 +3930,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3951
3930
|
async fetchNode() {
|
3952
3931
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3953
3932
|
const processedNodeInfo = {
|
3954
|
-
maxDepth: (0,
|
3955
|
-
maxTx: (0,
|
3933
|
+
maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
|
3934
|
+
maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
|
3956
3935
|
nodeVersion: nodeInfo.nodeVersion,
|
3957
3936
|
utxoValidation: nodeInfo.utxoValidation,
|
3958
3937
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4069,7 +4048,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4069
4048
|
async estimatePredicates(transactionRequest) {
|
4070
4049
|
const shouldEstimatePredicates = Boolean(
|
4071
4050
|
transactionRequest.inputs.find(
|
4072
|
-
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new
|
4051
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
|
4073
4052
|
)
|
4074
4053
|
);
|
4075
4054
|
if (!shouldEstimatePredicates) {
|
@@ -4084,7 +4063,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4084
4063
|
} = response;
|
4085
4064
|
if (inputs) {
|
4086
4065
|
inputs.forEach((input, index) => {
|
4087
|
-
if ("predicateGasUsed" in input && (0,
|
4066
|
+
if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
|
4088
4067
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4089
4068
|
}
|
4090
4069
|
});
|
@@ -4242,12 +4221,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4242
4221
|
gasPrice = await this.estimateGasPrice(10);
|
4243
4222
|
}
|
4244
4223
|
const minFee = calculateGasFee({
|
4245
|
-
gasPrice: (0,
|
4224
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4246
4225
|
gas: minGas,
|
4247
4226
|
priceFactor: gasPriceFactor,
|
4248
4227
|
tip: transactionRequest.tip
|
4249
4228
|
}).add(1);
|
4250
|
-
let gasLimit = (0,
|
4229
|
+
let gasLimit = (0, import_math17.bn)(0);
|
4251
4230
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4252
4231
|
gasLimit = transactionRequest.gasLimit;
|
4253
4232
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4260,7 +4239,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4260
4239
|
}
|
4261
4240
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4262
4241
|
const maxFee = calculateGasFee({
|
4263
|
-
gasPrice: (0,
|
4242
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4264
4243
|
gas: maxGas,
|
4265
4244
|
priceFactor: gasPriceFactor,
|
4266
4245
|
tip: transactionRequest.tip
|
@@ -4325,7 +4304,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4325
4304
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4326
4305
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4327
4306
|
if (isScriptTransaction) {
|
4328
|
-
txRequestClone.gasLimit = (0,
|
4307
|
+
txRequestClone.gasLimit = (0, import_math17.bn)(0);
|
4329
4308
|
}
|
4330
4309
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4331
4310
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4346,7 +4325,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4346
4325
|
let dryRunStatus;
|
4347
4326
|
let missingContractIds = [];
|
4348
4327
|
let outputVariables = 0;
|
4349
|
-
let gasUsed = (0,
|
4328
|
+
let gasUsed = (0, import_math17.bn)(0);
|
4350
4329
|
txRequestClone.maxFee = maxFee;
|
4351
4330
|
if (isScriptTransaction) {
|
4352
4331
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4354,7 +4333,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4354
4333
|
await signatureCallback(txRequestClone);
|
4355
4334
|
}
|
4356
4335
|
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
|
4357
|
-
|
4336
|
+
if (dryRunStatus && "reason" in dryRunStatus) {
|
4337
|
+
throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
|
4338
|
+
}
|
4339
|
+
gasUsed = getGasUsedFromReceipts(receipts);
|
4358
4340
|
txRequestClone.gasLimit = gasUsed;
|
4359
4341
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4360
4342
|
transactionRequest: txRequestClone,
|
@@ -4411,10 +4393,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4411
4393
|
return coins.map((coin) => ({
|
4412
4394
|
id: coin.utxoId,
|
4413
4395
|
assetId: coin.assetId,
|
4414
|
-
amount: (0,
|
4396
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4415
4397
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4416
|
-
blockCreated: (0,
|
4417
|
-
txCreatedIdx: (0,
|
4398
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4399
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4418
4400
|
}));
|
4419
4401
|
}
|
4420
4402
|
/**
|
@@ -4451,9 +4433,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4451
4433
|
switch (coin.type) {
|
4452
4434
|
case "MessageCoin":
|
4453
4435
|
return {
|
4454
|
-
amount: (0,
|
4436
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4455
4437
|
assetId: coin.assetId,
|
4456
|
-
daHeight: (0,
|
4438
|
+
daHeight: (0, import_math17.bn)(coin.daHeight),
|
4457
4439
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4458
4440
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4459
4441
|
nonce: coin.nonce
|
@@ -4461,11 +4443,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4461
4443
|
case "Coin":
|
4462
4444
|
return {
|
4463
4445
|
id: coin.utxoId,
|
4464
|
-
amount: (0,
|
4446
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4465
4447
|
assetId: coin.assetId,
|
4466
4448
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4467
|
-
blockCreated: (0,
|
4468
|
-
txCreatedIdx: (0,
|
4449
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4450
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4469
4451
|
};
|
4470
4452
|
default:
|
4471
4453
|
return null;
|
@@ -4482,13 +4464,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4482
4464
|
async getBlock(idOrHeight) {
|
4483
4465
|
let variables;
|
4484
4466
|
if (typeof idOrHeight === "number") {
|
4485
|
-
variables = { height: (0,
|
4467
|
+
variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4486
4468
|
} else if (idOrHeight === "latest") {
|
4487
4469
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4488
4470
|
} else if (idOrHeight.length === 66) {
|
4489
4471
|
variables = { blockId: idOrHeight };
|
4490
4472
|
} else {
|
4491
|
-
variables = { blockId: (0,
|
4473
|
+
variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4492
4474
|
}
|
4493
4475
|
const { block } = await this.operations.getBlock(variables);
|
4494
4476
|
if (!block) {
|
@@ -4496,7 +4478,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4496
4478
|
}
|
4497
4479
|
return {
|
4498
4480
|
id: block.id,
|
4499
|
-
height: (0,
|
4481
|
+
height: (0, import_math17.bn)(block.height),
|
4500
4482
|
time: block.header.time,
|
4501
4483
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4502
4484
|
};
|
@@ -4511,7 +4493,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4511
4493
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4512
4494
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4513
4495
|
id: block.id,
|
4514
|
-
height: (0,
|
4496
|
+
height: (0, import_math17.bn)(block.height),
|
4515
4497
|
time: block.header.time,
|
4516
4498
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4517
4499
|
}));
|
@@ -4526,7 +4508,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4526
4508
|
async getBlockWithTransactions(idOrHeight) {
|
4527
4509
|
let variables;
|
4528
4510
|
if (typeof idOrHeight === "number") {
|
4529
|
-
variables = { blockHeight: (0,
|
4511
|
+
variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4530
4512
|
} else if (idOrHeight === "latest") {
|
4531
4513
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4532
4514
|
} else {
|
@@ -4538,7 +4520,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4538
4520
|
}
|
4539
4521
|
return {
|
4540
4522
|
id: block.id,
|
4541
|
-
height: (0,
|
4523
|
+
height: (0, import_math17.bn)(block.height, 10),
|
4542
4524
|
time: block.header.time,
|
4543
4525
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4544
4526
|
transactions: block.transactions.map(
|
@@ -4587,7 +4569,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4587
4569
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4588
4570
|
asset: (0, import_utils22.hexlify)(assetId)
|
4589
4571
|
});
|
4590
|
-
return (0,
|
4572
|
+
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4591
4573
|
}
|
4592
4574
|
/**
|
4593
4575
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4601,7 +4583,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4601
4583
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4602
4584
|
assetId: (0, import_utils22.hexlify)(assetId)
|
4603
4585
|
});
|
4604
|
-
return (0,
|
4586
|
+
return (0, import_math17.bn)(balance.amount, 10);
|
4605
4587
|
}
|
4606
4588
|
/**
|
4607
4589
|
* Returns balances for the given owner.
|
@@ -4619,7 +4601,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4619
4601
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4620
4602
|
return balances.map((balance) => ({
|
4621
4603
|
assetId: balance.assetId,
|
4622
|
-
amount: (0,
|
4604
|
+
amount: (0, import_math17.bn)(balance.amount)
|
4623
4605
|
}));
|
4624
4606
|
}
|
4625
4607
|
/**
|
@@ -4641,15 +4623,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4641
4623
|
sender: message.sender,
|
4642
4624
|
recipient: message.recipient,
|
4643
4625
|
nonce: message.nonce,
|
4644
|
-
amount: (0,
|
4626
|
+
amount: (0, import_math17.bn)(message.amount),
|
4645
4627
|
data: message.data
|
4646
4628
|
}),
|
4647
4629
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4648
4630
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4649
4631
|
nonce: message.nonce,
|
4650
|
-
amount: (0,
|
4632
|
+
amount: (0, import_math17.bn)(message.amount),
|
4651
4633
|
data: import_transactions20.InputMessageCoder.decodeData(message.data),
|
4652
|
-
daHeight: (0,
|
4634
|
+
daHeight: (0, import_math17.bn)(message.daHeight)
|
4653
4635
|
}));
|
4654
4636
|
}
|
4655
4637
|
/**
|
@@ -4702,19 +4684,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4702
4684
|
} = result.messageProof;
|
4703
4685
|
return {
|
4704
4686
|
messageProof: {
|
4705
|
-
proofIndex: (0,
|
4687
|
+
proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
|
4706
4688
|
proofSet: messageProof.proofSet
|
4707
4689
|
},
|
4708
4690
|
blockProof: {
|
4709
|
-
proofIndex: (0,
|
4691
|
+
proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
|
4710
4692
|
proofSet: blockProof.proofSet
|
4711
4693
|
},
|
4712
4694
|
messageBlockHeader: {
|
4713
4695
|
id: messageBlockHeader.id,
|
4714
|
-
daHeight: (0,
|
4696
|
+
daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
|
4715
4697
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4716
4698
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4717
|
-
height: (0,
|
4699
|
+
height: (0, import_math17.bn)(messageBlockHeader.height),
|
4718
4700
|
prevRoot: messageBlockHeader.prevRoot,
|
4719
4701
|
time: messageBlockHeader.time,
|
4720
4702
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -4726,10 +4708,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4726
4708
|
},
|
4727
4709
|
commitBlockHeader: {
|
4728
4710
|
id: commitBlockHeader.id,
|
4729
|
-
daHeight: (0,
|
4711
|
+
daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
|
4730
4712
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4731
4713
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4732
|
-
height: (0,
|
4714
|
+
height: (0, import_math17.bn)(commitBlockHeader.height),
|
4733
4715
|
prevRoot: commitBlockHeader.prevRoot,
|
4734
4716
|
time: commitBlockHeader.time,
|
4735
4717
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -4742,19 +4724,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4742
4724
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4743
4725
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4744
4726
|
nonce,
|
4745
|
-
amount: (0,
|
4727
|
+
amount: (0, import_math17.bn)(amount),
|
4746
4728
|
data
|
4747
4729
|
};
|
4748
4730
|
}
|
4749
4731
|
async getLatestGasPrice() {
|
4750
4732
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4751
|
-
return (0,
|
4733
|
+
return (0, import_math17.bn)(latestGasPrice.gasPrice);
|
4752
4734
|
}
|
4753
4735
|
async estimateGasPrice(blockHorizon) {
|
4754
4736
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4755
4737
|
blockHorizon: String(blockHorizon)
|
4756
4738
|
});
|
4757
|
-
return (0,
|
4739
|
+
return (0, import_math17.bn)(estimateGasPrice.gasPrice);
|
4758
4740
|
}
|
4759
4741
|
/**
|
4760
4742
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4775,10 +4757,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4775
4757
|
*/
|
4776
4758
|
async produceBlocks(amount, startTime) {
|
4777
4759
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4778
|
-
blocksToProduce: (0,
|
4760
|
+
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
4779
4761
|
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4780
4762
|
});
|
4781
|
-
return (0,
|
4763
|
+
return (0, import_math17.bn)(latestBlockHeight);
|
4782
4764
|
}
|
4783
4765
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4784
4766
|
async getTransactionResponse(transactionId) {
|
@@ -4806,6 +4788,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4806
4788
|
}
|
4807
4789
|
return relayedTransactionStatus;
|
4808
4790
|
}
|
4791
|
+
extractDryRunError(transactionRequest, receipts, dryRunStatus) {
|
4792
|
+
const status = dryRunStatus;
|
4793
|
+
let logs = [];
|
4794
|
+
if (transactionRequest.abis) {
|
4795
|
+
logs = getDecodedLogs(
|
4796
|
+
receipts,
|
4797
|
+
transactionRequest.abis.main,
|
4798
|
+
transactionRequest.abis.otherContractsAbis
|
4799
|
+
);
|
4800
|
+
}
|
4801
|
+
return extractTxError({
|
4802
|
+
logs,
|
4803
|
+
receipts,
|
4804
|
+
statusReason: status.reason
|
4805
|
+
});
|
4806
|
+
}
|
4809
4807
|
};
|
4810
4808
|
var Provider = _Provider;
|
4811
4809
|
_cacheInputs = new WeakSet();
|
@@ -4824,7 +4822,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4824
4822
|
|
4825
4823
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4826
4824
|
var import_errors15 = require("@fuel-ts/errors");
|
4827
|
-
var
|
4825
|
+
var import_math18 = require("@fuel-ts/math");
|
4828
4826
|
var import_transactions21 = require("@fuel-ts/transactions");
|
4829
4827
|
var import_utils25 = require("@fuel-ts/utils");
|
4830
4828
|
|
@@ -4901,13 +4899,13 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
4901
4899
|
|
4902
4900
|
// src/utils/formatTransferToContractScriptData.ts
|
4903
4901
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4904
|
-
var
|
4902
|
+
var import_math19 = require("@fuel-ts/math");
|
4905
4903
|
var import_utils27 = require("@fuel-ts/utils");
|
4906
4904
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4907
4905
|
var formatTransferToContractScriptData = (params) => {
|
4908
4906
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4909
4907
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
4910
|
-
const encoded = numberCoder.encode(new
|
4908
|
+
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
4911
4909
|
const scriptData = Uint8Array.from([
|
4912
4910
|
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
4913
4911
|
...encoded,
|
@@ -5102,9 +5100,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5102
5100
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5103
5101
|
const fee = request.maxFee;
|
5104
5102
|
const baseAssetId = this.provider.getBaseAssetId();
|
5105
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0,
|
5103
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
|
5106
5104
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5107
|
-
amount: (0,
|
5105
|
+
amount: (0, import_math20.bn)(fee),
|
5108
5106
|
assetId: baseAssetId,
|
5109
5107
|
coinQuantities: requiredQuantities
|
5110
5108
|
});
|
@@ -5112,7 +5110,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5112
5110
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5113
5111
|
quantitiesDict[assetId] = {
|
5114
5112
|
required: amount,
|
5115
|
-
owned: (0,
|
5113
|
+
owned: (0, import_math20.bn)(0)
|
5116
5114
|
};
|
5117
5115
|
});
|
5118
5116
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5139,7 +5137,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5139
5137
|
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5140
5138
|
);
|
5141
5139
|
request.addResources(resources);
|
5142
|
-
request.shiftPredicateData();
|
5143
5140
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5144
5141
|
const requestToReestimate2 = (0, import_ramda4.clone)(request);
|
5145
5142
|
if (addedSignatures) {
|
@@ -5171,7 +5168,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5171
5168
|
}
|
5172
5169
|
fundingAttempts += 1;
|
5173
5170
|
}
|
5174
|
-
request.shiftPredicateData();
|
5175
5171
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5176
5172
|
const requestToReestimate = (0, import_ramda4.clone)(request);
|
5177
5173
|
if (addedSignatures) {
|
@@ -5222,7 +5218,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5222
5218
|
* @returns A promise that resolves to the transaction response.
|
5223
5219
|
*/
|
5224
5220
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5225
|
-
if ((0,
|
5221
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5226
5222
|
throw new import_errors16.FuelError(
|
5227
5223
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5228
5224
|
"Transfer amount must be a positive number."
|
@@ -5242,7 +5238,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5242
5238
|
* @returns A promise that resolves to the transaction response.
|
5243
5239
|
*/
|
5244
5240
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5245
|
-
if ((0,
|
5241
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5246
5242
|
throw new import_errors16.FuelError(
|
5247
5243
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5248
5244
|
"Transfer amount must be a positive number."
|
@@ -5252,7 +5248,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5252
5248
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5253
5249
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5254
5250
|
hexlifiedContractId: contractAddress.toB256(),
|
5255
|
-
amountToTransfer: (0,
|
5251
|
+
amountToTransfer: (0, import_math20.bn)(amount),
|
5256
5252
|
assetId: assetIdToTransfer
|
5257
5253
|
});
|
5258
5254
|
let request = new ScriptTransactionRequest({
|
@@ -5263,7 +5259,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5263
5259
|
request.addContractInputAndOutput(contractAddress);
|
5264
5260
|
const txCost = await this.provider.getTransactionCost(request, {
|
5265
5261
|
resourcesOwner: this,
|
5266
|
-
quantitiesToContract: [{ amount: (0,
|
5262
|
+
quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5267
5263
|
});
|
5268
5264
|
request = this.validateGasLimitAndMaxFee({
|
5269
5265
|
transactionRequest: request,
|
@@ -5288,7 +5284,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5288
5284
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5289
5285
|
);
|
5290
5286
|
const amountDataArray = (0, import_utils28.arrayify)(
|
5291
|
-
"0x".concat((0,
|
5287
|
+
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5292
5288
|
);
|
5293
5289
|
const script = new Uint8Array([
|
5294
5290
|
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
@@ -5298,7 +5294,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5298
5294
|
const params = { script, ...txParams };
|
5299
5295
|
const baseAssetId = this.provider.getBaseAssetId();
|
5300
5296
|
let request = new ScriptTransactionRequest(params);
|
5301
|
-
const quantitiesToContract = [{ amount: (0,
|
5297
|
+
const quantitiesToContract = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
|
5302
5298
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5303
5299
|
request = this.validateGasLimitAndMaxFee({
|
5304
5300
|
transactionRequest: request,
|
@@ -5395,7 +5391,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5395
5391
|
var import_address5 = require("@fuel-ts/address");
|
5396
5392
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5397
5393
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5398
|
-
var
|
5394
|
+
var import_math21 = require("@fuel-ts/math");
|
5399
5395
|
var import_utils29 = require("@fuel-ts/utils");
|
5400
5396
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5401
5397
|
var Signer = class {
|
@@ -5415,7 +5411,7 @@ var Signer = class {
|
|
5415
5411
|
privateKey = `0x${privateKey}`;
|
5416
5412
|
}
|
5417
5413
|
}
|
5418
|
-
const privateKeyBytes = (0,
|
5414
|
+
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
5419
5415
|
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5420
5416
|
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5421
5417
|
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
@@ -5433,8 +5429,8 @@ var Signer = class {
|
|
5433
5429
|
*/
|
5434
5430
|
sign(data) {
|
5435
5431
|
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5436
|
-
const r = (0,
|
5437
|
-
const s = (0,
|
5432
|
+
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5433
|
+
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5438
5434
|
s[0] |= (signature.recovery || 0) << 7;
|
5439
5435
|
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5440
5436
|
}
|
@@ -5707,7 +5703,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5707
5703
|
var import_crypto5 = require("@fuel-ts/crypto");
|
5708
5704
|
var import_errors20 = require("@fuel-ts/errors");
|
5709
5705
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5710
|
-
var
|
5706
|
+
var import_math22 = require("@fuel-ts/math");
|
5711
5707
|
var import_utils35 = require("@fuel-ts/utils");
|
5712
5708
|
|
5713
5709
|
// src/mnemonic/mnemonic.ts
|
@@ -7772,38 +7768,6 @@ var english = [
|
|
7772
7768
|
var import_errors18 = require("@fuel-ts/errors");
|
7773
7769
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7774
7770
|
var import_utils32 = require("@fuel-ts/utils");
|
7775
|
-
function toUtf8Bytes(stri) {
|
7776
|
-
const str = stri.normalize("NFKD");
|
7777
|
-
const result = [];
|
7778
|
-
for (let i = 0; i < str.length; i += 1) {
|
7779
|
-
const c = str.charCodeAt(i);
|
7780
|
-
if (c < 128) {
|
7781
|
-
result.push(c);
|
7782
|
-
} else if (c < 2048) {
|
7783
|
-
result.push(c >> 6 | 192);
|
7784
|
-
result.push(c & 63 | 128);
|
7785
|
-
} else if ((c & 64512) === 55296) {
|
7786
|
-
i += 1;
|
7787
|
-
const c2 = str.charCodeAt(i);
|
7788
|
-
if (i >= str.length || (c2 & 64512) !== 56320) {
|
7789
|
-
throw new import_errors18.FuelError(
|
7790
|
-
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
7791
|
-
"Invalid UTF-8 in the input string."
|
7792
|
-
);
|
7793
|
-
}
|
7794
|
-
const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
|
7795
|
-
result.push(pair >> 18 | 240);
|
7796
|
-
result.push(pair >> 12 & 63 | 128);
|
7797
|
-
result.push(pair >> 6 & 63 | 128);
|
7798
|
-
result.push(pair & 63 | 128);
|
7799
|
-
} else {
|
7800
|
-
result.push(c >> 12 | 224);
|
7801
|
-
result.push(c >> 6 & 63 | 128);
|
7802
|
-
result.push(c & 63 | 128);
|
7803
|
-
}
|
7804
|
-
}
|
7805
|
-
return Uint8Array.from(result);
|
7806
|
-
}
|
7807
7771
|
function getLowerMask(bits) {
|
7808
7772
|
return (1 << bits) - 1;
|
7809
7773
|
}
|
@@ -7876,7 +7840,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7876
7840
|
}
|
7877
7841
|
|
7878
7842
|
// src/mnemonic/mnemonic.ts
|
7879
|
-
var MasterSecret = toUtf8Bytes("Bitcoin seed");
|
7843
|
+
var MasterSecret = (0, import_utils33.toUtf8Bytes)("Bitcoin seed");
|
7880
7844
|
var MainnetPRV = "0x0488ade4";
|
7881
7845
|
var TestnetPRV = "0x04358394";
|
7882
7846
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
@@ -7960,8 +7924,8 @@ var Mnemonic = class {
|
|
7960
7924
|
*/
|
7961
7925
|
static mnemonicToSeed(phrase, passphrase = "") {
|
7962
7926
|
assertMnemonic(getWords(phrase));
|
7963
|
-
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7964
|
-
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7927
|
+
const phraseBytes = (0, import_utils33.toUtf8Bytes)(getPhrase(phrase));
|
7928
|
+
const salt = (0, import_utils33.toUtf8Bytes)(`mnemonic${passphrase}`);
|
7965
7929
|
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7966
7930
|
}
|
7967
7931
|
/**
|
@@ -8165,13 +8129,13 @@ var HDWallet = class {
|
|
8165
8129
|
} else {
|
8166
8130
|
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8167
8131
|
}
|
8168
|
-
data.set((0,
|
8132
|
+
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8169
8133
|
const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8170
8134
|
const IL = bytes.slice(0, 32);
|
8171
8135
|
const IR = bytes.slice(32);
|
8172
8136
|
if (privateKey) {
|
8173
8137
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8174
|
-
const ki = (0,
|
8138
|
+
const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
8175
8139
|
return new HDWallet({
|
8176
8140
|
privateKey: ki,
|
8177
8141
|
chainCode: IR,
|
@@ -8217,7 +8181,7 @@ var HDWallet = class {
|
|
8217
8181
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8218
8182
|
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8219
8183
|
const parentFingerprint = this.parentFingerprint;
|
8220
|
-
const index = (0,
|
8184
|
+
const index = (0, import_math22.toHex)(this.index, 4);
|
8221
8185
|
const chainCode = this.chainCode;
|
8222
8186
|
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8223
8187
|
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
@@ -8237,7 +8201,7 @@ var HDWallet = class {
|
|
8237
8201
|
});
|
8238
8202
|
}
|
8239
8203
|
static fromExtendedKey(extendedKey) {
|
8240
|
-
const decoded = (0, import_utils35.hexlify)((0,
|
8204
|
+
const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
|
8241
8205
|
const bytes = (0, import_utils35.arrayify)(decoded);
|
8242
8206
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8243
8207
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -8512,7 +8476,6 @@ var launchNode = async ({
|
|
8512
8476
|
ip,
|
8513
8477
|
port,
|
8514
8478
|
args = [],
|
8515
|
-
fuelCorePath = void 0,
|
8516
8479
|
useSystemFuelCore = false,
|
8517
8480
|
loggingEnabled = true,
|
8518
8481
|
debugEnabled = false,
|
@@ -8533,7 +8496,7 @@ var launchNode = async ({
|
|
8533
8496
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
8534
8497
|
const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
|
8535
8498
|
const graphQLStartSubstring = "Binding GraphQL provider to";
|
8536
|
-
const binPath =
|
8499
|
+
const binPath = (0, import_cli_utils.findBinPath)("fuels-core", __dirname);
|
8537
8500
|
const command = useSystemFuelCore ? "fuel-core" : binPath;
|
8538
8501
|
const ipToUse = ip || "0.0.0.0";
|
8539
8502
|
const portToUse = port || (await (0, import_portfinder.getPortPromise)({
|