@fuel-ts/account 0.0.0-pr-2143-20240514173839 → 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/index.js
CHANGED
@@ -198,7 +198,7 @@ module.exports = __toCommonJS(src_exports);
|
|
198
198
|
var import_address4 = require("@fuel-ts/address");
|
199
199
|
var import_errors16 = require("@fuel-ts/errors");
|
200
200
|
var import_interfaces = require("@fuel-ts/interfaces");
|
201
|
-
var
|
201
|
+
var import_math20 = require("@fuel-ts/math");
|
202
202
|
var import_utils28 = require("@fuel-ts/utils");
|
203
203
|
var import_ramda4 = require("ramda");
|
204
204
|
|
@@ -240,7 +240,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
240
240
|
// src/providers/provider.ts
|
241
241
|
var import_address3 = require("@fuel-ts/address");
|
242
242
|
var import_errors14 = require("@fuel-ts/errors");
|
243
|
-
var
|
243
|
+
var import_math17 = require("@fuel-ts/math");
|
244
244
|
var import_transactions20 = require("@fuel-ts/transactions");
|
245
245
|
var import_utils22 = require("@fuel-ts/utils");
|
246
246
|
var import_versions = require("@fuel-ts/versions");
|
@@ -382,6 +382,7 @@ var TransactionEstimatePredicatesFragmentDoc = import_graphql_tag.default`
|
|
382
382
|
${InputEstimatePredicatesFragmentDoc}`;
|
383
383
|
var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
|
384
384
|
fragment dryRunFailureStatusFragment on DryRunFailureStatus {
|
385
|
+
type: __typename
|
385
386
|
totalGas
|
386
387
|
totalFee
|
387
388
|
reason
|
@@ -393,6 +394,7 @@ var DryRunFailureStatusFragmentDoc = import_graphql_tag.default`
|
|
393
394
|
`;
|
394
395
|
var DryRunSuccessStatusFragmentDoc = import_graphql_tag.default`
|
395
396
|
fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
|
397
|
+
type: __typename
|
396
398
|
totalGas
|
397
399
|
totalFee
|
398
400
|
programState {
|
@@ -1877,17 +1879,16 @@ var import_errors7 = require("@fuel-ts/errors");
|
|
1877
1879
|
var import_math6 = require("@fuel-ts/math");
|
1878
1880
|
var import_transactions5 = require("@fuel-ts/transactions");
|
1879
1881
|
var import_configs5 = require("@fuel-ts/transactions/configs");
|
1880
|
-
var assemblePanicError = (
|
1881
|
-
let errorMessage = `The transaction reverted with reason: "${
|
1882
|
-
|
1883
|
-
if (import_configs5.PANIC_REASONS.includes(status.reason)) {
|
1882
|
+
var assemblePanicError = (statusReason) => {
|
1883
|
+
let errorMessage = `The transaction reverted with reason: "${statusReason}".`;
|
1884
|
+
if (import_configs5.PANIC_REASONS.includes(statusReason)) {
|
1884
1885
|
errorMessage = `${errorMessage}
|
1885
1886
|
|
1886
1887
|
You can read more about this error at:
|
1887
1888
|
|
1888
|
-
${import_configs5.PANIC_DOC_URL}#variant.${
|
1889
|
+
${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
|
1889
1890
|
}
|
1890
|
-
return { errorMessage, reason };
|
1891
|
+
return { errorMessage, reason: statusReason };
|
1891
1892
|
};
|
1892
1893
|
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
1893
1894
|
var assembleRevertError = (receipts, logs) => {
|
@@ -1930,10 +1931,10 @@ var assembleRevertError = (receipts, logs) => {
|
|
1930
1931
|
return { errorMessage, reason };
|
1931
1932
|
};
|
1932
1933
|
var extractTxError = (params) => {
|
1933
|
-
const { receipts,
|
1934
|
+
const { receipts, statusReason, logs } = params;
|
1934
1935
|
const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
|
1935
1936
|
const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
|
1936
|
-
const { errorMessage, reason } =
|
1937
|
+
const { errorMessage, reason } = isPanic ? assemblePanicError(statusReason) : assembleRevertError(receipts, logs);
|
1937
1938
|
const metadata = {
|
1938
1939
|
logs,
|
1939
1940
|
receipts,
|
@@ -2520,15 +2521,6 @@ var BaseTransactionRequest = class {
|
|
2520
2521
|
}
|
2521
2522
|
});
|
2522
2523
|
}
|
2523
|
-
shiftPredicateData() {
|
2524
|
-
this.inputs.forEach((input) => {
|
2525
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2526
|
-
input.predicateData = input.padPredicateData(
|
2527
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2528
|
-
);
|
2529
|
-
}
|
2530
|
-
});
|
2531
|
-
}
|
2532
2524
|
};
|
2533
2525
|
|
2534
2526
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2951,12 +2943,12 @@ var transactionRequestify = (obj) => {
|
|
2951
2943
|
|
2952
2944
|
// src/providers/transaction-response/transaction-response.ts
|
2953
2945
|
var import_errors13 = require("@fuel-ts/errors");
|
2954
|
-
var
|
2946
|
+
var import_math16 = require("@fuel-ts/math");
|
2955
2947
|
var import_transactions19 = require("@fuel-ts/transactions");
|
2956
2948
|
var import_utils20 = require("@fuel-ts/utils");
|
2957
2949
|
|
2958
2950
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2959
|
-
var
|
2951
|
+
var import_math15 = require("@fuel-ts/math");
|
2960
2952
|
var import_transactions17 = require("@fuel-ts/transactions");
|
2961
2953
|
var import_utils18 = require("@fuel-ts/utils");
|
2962
2954
|
|
@@ -3033,43 +3025,32 @@ var calculateTXFeeForSummary = (params) => {
|
|
3033
3025
|
// src/providers/transaction-summary/operations.ts
|
3034
3026
|
var import_configs10 = require("@fuel-ts/address/configs");
|
3035
3027
|
var import_errors11 = require("@fuel-ts/errors");
|
3036
|
-
var
|
3028
|
+
var import_math13 = require("@fuel-ts/math");
|
3037
3029
|
var import_transactions15 = require("@fuel-ts/transactions");
|
3038
3030
|
|
3039
3031
|
// src/providers/transaction-summary/call.ts
|
3040
3032
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
3041
|
-
var
|
3042
|
-
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
3033
|
+
var getFunctionCall = ({ abi, receipt }) => {
|
3043
3034
|
const abiInterface = new import_abi_coder4.Interface(abi);
|
3044
3035
|
const callFunctionSelector = receipt.param1.toHex(8);
|
3045
3036
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
3046
3037
|
const inputs = functionFragment.jsonFn.inputs;
|
3047
|
-
|
3048
|
-
if (functionFragment.isInputDataPointer) {
|
3049
|
-
if (rawPayload) {
|
3050
|
-
const argsOffset = (0, import_math13.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
3051
|
-
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
3052
|
-
}
|
3053
|
-
} else {
|
3054
|
-
encodedArgs = receipt.param2.toHex();
|
3055
|
-
}
|
3038
|
+
const encodedArgs = receipt.param2.toHex();
|
3056
3039
|
let argumentsProvided;
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
|
3063
|
-
|
3064
|
-
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
3068
|
-
|
3069
|
-
|
3070
|
-
|
3071
|
-
}, {});
|
3072
|
-
}
|
3040
|
+
const data = functionFragment.decodeArguments(encodedArgs);
|
3041
|
+
if (data) {
|
3042
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
3043
|
+
const value = data[index];
|
3044
|
+
const name = input.name;
|
3045
|
+
if (name) {
|
3046
|
+
return {
|
3047
|
+
...prev,
|
3048
|
+
// reparse to remove bn
|
3049
|
+
[name]: JSON.parse(JSON.stringify(value))
|
3050
|
+
};
|
3051
|
+
}
|
3052
|
+
return prev;
|
3053
|
+
}, {});
|
3073
3054
|
}
|
3074
3055
|
const call = {
|
3075
3056
|
functionSignature: functionFragment.signature,
|
@@ -3255,7 +3236,7 @@ var mergeAssets = (op1, op2) => {
|
|
3255
3236
|
if (!matchingAsset) {
|
3256
3237
|
return asset1;
|
3257
3238
|
}
|
3258
|
-
const mergedAmount = (0,
|
3239
|
+
const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
|
3259
3240
|
return { ...asset1, amount: mergedAmount };
|
3260
3241
|
});
|
3261
3242
|
return mergedAssets.concat(filteredAssets);
|
@@ -3581,7 +3562,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3581
3562
|
|
3582
3563
|
// src/providers/transaction-summary/status.ts
|
3583
3564
|
var import_errors12 = require("@fuel-ts/errors");
|
3584
|
-
var
|
3565
|
+
var import_math14 = require("@fuel-ts/math");
|
3585
3566
|
var getTransactionStatusName = (gqlStatus) => {
|
3586
3567
|
switch (gqlStatus) {
|
3587
3568
|
case "FailureStatus":
|
@@ -3615,15 +3596,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3615
3596
|
time = gqlTransactionStatus.time;
|
3616
3597
|
blockId = gqlTransactionStatus.block.id;
|
3617
3598
|
isStatusSuccess = true;
|
3618
|
-
totalFee = (0,
|
3619
|
-
totalGas = (0,
|
3599
|
+
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3600
|
+
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3620
3601
|
break;
|
3621
3602
|
case "FailureStatus":
|
3622
3603
|
time = gqlTransactionStatus.time;
|
3623
3604
|
blockId = gqlTransactionStatus.block.id;
|
3624
3605
|
isStatusFailure = true;
|
3625
|
-
totalFee = (0,
|
3626
|
-
totalGas = (0,
|
3606
|
+
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3607
|
+
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3627
3608
|
break;
|
3628
3609
|
case "SubmittedStatus":
|
3629
3610
|
time = gqlTransactionStatus.time;
|
@@ -3673,7 +3654,7 @@ function assembleTransactionSummary(params) {
|
|
3673
3654
|
maxInputs
|
3674
3655
|
});
|
3675
3656
|
const typeName = getTransactionTypeName(transaction.type);
|
3676
|
-
const tip = (0,
|
3657
|
+
const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
3677
3658
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3678
3659
|
const fee = calculateTXFeeForSummary({
|
3679
3660
|
totalFee,
|
@@ -3744,7 +3725,7 @@ var TransactionResponse = class {
|
|
3744
3725
|
/** Current provider */
|
3745
3726
|
provider;
|
3746
3727
|
/** Gas used on the transaction */
|
3747
|
-
gasUsed = (0,
|
3728
|
+
gasUsed = (0, import_math16.bn)(0);
|
3748
3729
|
/** The graphql Transaction with receipts object. */
|
3749
3730
|
gqlTransaction;
|
3750
3731
|
abis;
|
@@ -3888,14 +3869,12 @@ var TransactionResponse = class {
|
|
3888
3869
|
);
|
3889
3870
|
transactionResult.logs = logs;
|
3890
3871
|
}
|
3891
|
-
|
3892
|
-
|
3893
|
-
|
3894
|
-
gqlTransaction: { status }
|
3895
|
-
} = transactionResult;
|
3872
|
+
const { gqlTransaction, receipts } = transactionResult;
|
3873
|
+
if (gqlTransaction.status?.type === "FailureStatus") {
|
3874
|
+
const { reason } = gqlTransaction.status;
|
3896
3875
|
throw extractTxError({
|
3897
3876
|
receipts,
|
3898
|
-
|
3877
|
+
statusReason: reason,
|
3899
3878
|
logs
|
3900
3879
|
});
|
3901
3880
|
}
|
@@ -3978,47 +3957,47 @@ var processGqlChain = (chain) => {
|
|
3978
3957
|
} = consensusParameters;
|
3979
3958
|
return {
|
3980
3959
|
name,
|
3981
|
-
baseChainHeight: (0,
|
3960
|
+
baseChainHeight: (0, import_math17.bn)(daHeight),
|
3982
3961
|
consensusParameters: {
|
3983
3962
|
version,
|
3984
|
-
chainId: (0,
|
3963
|
+
chainId: (0, import_math17.bn)(chainId),
|
3985
3964
|
baseAssetId,
|
3986
3965
|
feeParameters: {
|
3987
3966
|
version: feeParams.version,
|
3988
|
-
gasPerByte: (0,
|
3989
|
-
gasPriceFactor: (0,
|
3967
|
+
gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
|
3968
|
+
gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
|
3990
3969
|
},
|
3991
3970
|
contractParameters: {
|
3992
3971
|
version: contractParams.version,
|
3993
|
-
contractMaxSize: (0,
|
3994
|
-
maxStorageSlots: (0,
|
3972
|
+
contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
|
3973
|
+
maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
|
3995
3974
|
},
|
3996
3975
|
txParameters: {
|
3997
3976
|
version: txParams.version,
|
3998
|
-
maxInputs: (0,
|
3999
|
-
maxOutputs: (0,
|
4000
|
-
maxWitnesses: (0,
|
4001
|
-
maxGasPerTx: (0,
|
4002
|
-
maxSize: (0,
|
4003
|
-
maxBytecodeSubsections: (0,
|
3977
|
+
maxInputs: (0, import_math17.bn)(txParams.maxInputs),
|
3978
|
+
maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
|
3979
|
+
maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
|
3980
|
+
maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
|
3981
|
+
maxSize: (0, import_math17.bn)(txParams.maxSize),
|
3982
|
+
maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
|
4004
3983
|
},
|
4005
3984
|
predicateParameters: {
|
4006
3985
|
version: predicateParams.version,
|
4007
|
-
maxPredicateLength: (0,
|
4008
|
-
maxPredicateDataLength: (0,
|
4009
|
-
maxGasPerPredicate: (0,
|
4010
|
-
maxMessageDataLength: (0,
|
3986
|
+
maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
|
3987
|
+
maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
|
3988
|
+
maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
|
3989
|
+
maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
|
4011
3990
|
},
|
4012
3991
|
scriptParameters: {
|
4013
3992
|
version: scriptParams.version,
|
4014
|
-
maxScriptLength: (0,
|
4015
|
-
maxScriptDataLength: (0,
|
3993
|
+
maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
|
3994
|
+
maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
|
4016
3995
|
},
|
4017
3996
|
gasCosts
|
4018
3997
|
},
|
4019
3998
|
latestBlock: {
|
4020
3999
|
id: latestBlock.id,
|
4021
|
-
height: (0,
|
4000
|
+
height: (0, import_math17.bn)(latestBlock.height),
|
4022
4001
|
time: latestBlock.header.time,
|
4023
4002
|
transactions: latestBlock.transactions.map((i) => ({
|
4024
4003
|
id: i.id
|
@@ -4214,7 +4193,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4214
4193
|
*/
|
4215
4194
|
async getBlockNumber() {
|
4216
4195
|
const { chain } = await this.operations.getChain();
|
4217
|
-
return (0,
|
4196
|
+
return (0, import_math17.bn)(chain.latestBlock.height, 10);
|
4218
4197
|
}
|
4219
4198
|
/**
|
4220
4199
|
* Returns the chain information.
|
@@ -4224,8 +4203,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4224
4203
|
async fetchNode() {
|
4225
4204
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
4226
4205
|
const processedNodeInfo = {
|
4227
|
-
maxDepth: (0,
|
4228
|
-
maxTx: (0,
|
4206
|
+
maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
|
4207
|
+
maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
|
4229
4208
|
nodeVersion: nodeInfo.nodeVersion,
|
4230
4209
|
utxoValidation: nodeInfo.utxoValidation,
|
4231
4210
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4342,7 +4321,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4342
4321
|
async estimatePredicates(transactionRequest) {
|
4343
4322
|
const shouldEstimatePredicates = Boolean(
|
4344
4323
|
transactionRequest.inputs.find(
|
4345
|
-
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new
|
4324
|
+
(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()
|
4346
4325
|
)
|
4347
4326
|
);
|
4348
4327
|
if (!shouldEstimatePredicates) {
|
@@ -4357,7 +4336,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4357
4336
|
} = response;
|
4358
4337
|
if (inputs) {
|
4359
4338
|
inputs.forEach((input, index) => {
|
4360
|
-
if ("predicateGasUsed" in input && (0,
|
4339
|
+
if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
|
4361
4340
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4362
4341
|
}
|
4363
4342
|
});
|
@@ -4515,12 +4494,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4515
4494
|
gasPrice = await this.estimateGasPrice(10);
|
4516
4495
|
}
|
4517
4496
|
const minFee = calculateGasFee({
|
4518
|
-
gasPrice: (0,
|
4497
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4519
4498
|
gas: minGas,
|
4520
4499
|
priceFactor: gasPriceFactor,
|
4521
4500
|
tip: transactionRequest.tip
|
4522
4501
|
}).add(1);
|
4523
|
-
let gasLimit = (0,
|
4502
|
+
let gasLimit = (0, import_math17.bn)(0);
|
4524
4503
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4525
4504
|
gasLimit = transactionRequest.gasLimit;
|
4526
4505
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4533,7 +4512,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4533
4512
|
}
|
4534
4513
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4535
4514
|
const maxFee = calculateGasFee({
|
4536
|
-
gasPrice: (0,
|
4515
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4537
4516
|
gas: maxGas,
|
4538
4517
|
priceFactor: gasPriceFactor,
|
4539
4518
|
tip: transactionRequest.tip
|
@@ -4598,7 +4577,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4598
4577
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4599
4578
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4600
4579
|
if (isScriptTransaction) {
|
4601
|
-
txRequestClone.gasLimit = (0,
|
4580
|
+
txRequestClone.gasLimit = (0, import_math17.bn)(0);
|
4602
4581
|
}
|
4603
4582
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4604
4583
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4619,7 +4598,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4619
4598
|
let dryRunStatus;
|
4620
4599
|
let missingContractIds = [];
|
4621
4600
|
let outputVariables = 0;
|
4622
|
-
let gasUsed = (0,
|
4601
|
+
let gasUsed = (0, import_math17.bn)(0);
|
4623
4602
|
txRequestClone.maxFee = maxFee;
|
4624
4603
|
if (isScriptTransaction) {
|
4625
4604
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4627,7 +4606,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4627
4606
|
await signatureCallback(txRequestClone);
|
4628
4607
|
}
|
4629
4608
|
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
|
4630
|
-
|
4609
|
+
if (dryRunStatus && "reason" in dryRunStatus) {
|
4610
|
+
throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
|
4611
|
+
}
|
4612
|
+
gasUsed = getGasUsedFromReceipts(receipts);
|
4631
4613
|
txRequestClone.gasLimit = gasUsed;
|
4632
4614
|
({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
|
4633
4615
|
transactionRequest: txRequestClone,
|
@@ -4684,10 +4666,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4684
4666
|
return coins.map((coin) => ({
|
4685
4667
|
id: coin.utxoId,
|
4686
4668
|
assetId: coin.assetId,
|
4687
|
-
amount: (0,
|
4669
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4688
4670
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4689
|
-
blockCreated: (0,
|
4690
|
-
txCreatedIdx: (0,
|
4671
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4672
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4691
4673
|
}));
|
4692
4674
|
}
|
4693
4675
|
/**
|
@@ -4724,9 +4706,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4724
4706
|
switch (coin.type) {
|
4725
4707
|
case "MessageCoin":
|
4726
4708
|
return {
|
4727
|
-
amount: (0,
|
4709
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4728
4710
|
assetId: coin.assetId,
|
4729
|
-
daHeight: (0,
|
4711
|
+
daHeight: (0, import_math17.bn)(coin.daHeight),
|
4730
4712
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4731
4713
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4732
4714
|
nonce: coin.nonce
|
@@ -4734,11 +4716,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4734
4716
|
case "Coin":
|
4735
4717
|
return {
|
4736
4718
|
id: coin.utxoId,
|
4737
|
-
amount: (0,
|
4719
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4738
4720
|
assetId: coin.assetId,
|
4739
4721
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4740
|
-
blockCreated: (0,
|
4741
|
-
txCreatedIdx: (0,
|
4722
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4723
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4742
4724
|
};
|
4743
4725
|
default:
|
4744
4726
|
return null;
|
@@ -4755,13 +4737,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4755
4737
|
async getBlock(idOrHeight) {
|
4756
4738
|
let variables;
|
4757
4739
|
if (typeof idOrHeight === "number") {
|
4758
|
-
variables = { height: (0,
|
4740
|
+
variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4759
4741
|
} else if (idOrHeight === "latest") {
|
4760
4742
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4761
4743
|
} else if (idOrHeight.length === 66) {
|
4762
4744
|
variables = { blockId: idOrHeight };
|
4763
4745
|
} else {
|
4764
|
-
variables = { blockId: (0,
|
4746
|
+
variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4765
4747
|
}
|
4766
4748
|
const { block } = await this.operations.getBlock(variables);
|
4767
4749
|
if (!block) {
|
@@ -4769,7 +4751,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4769
4751
|
}
|
4770
4752
|
return {
|
4771
4753
|
id: block.id,
|
4772
|
-
height: (0,
|
4754
|
+
height: (0, import_math17.bn)(block.height),
|
4773
4755
|
time: block.header.time,
|
4774
4756
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4775
4757
|
};
|
@@ -4784,7 +4766,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4784
4766
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4785
4767
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4786
4768
|
id: block.id,
|
4787
|
-
height: (0,
|
4769
|
+
height: (0, import_math17.bn)(block.height),
|
4788
4770
|
time: block.header.time,
|
4789
4771
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4790
4772
|
}));
|
@@ -4799,7 +4781,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4799
4781
|
async getBlockWithTransactions(idOrHeight) {
|
4800
4782
|
let variables;
|
4801
4783
|
if (typeof idOrHeight === "number") {
|
4802
|
-
variables = { blockHeight: (0,
|
4784
|
+
variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4803
4785
|
} else if (idOrHeight === "latest") {
|
4804
4786
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4805
4787
|
} else {
|
@@ -4811,7 +4793,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4811
4793
|
}
|
4812
4794
|
return {
|
4813
4795
|
id: block.id,
|
4814
|
-
height: (0,
|
4796
|
+
height: (0, import_math17.bn)(block.height, 10),
|
4815
4797
|
time: block.header.time,
|
4816
4798
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4817
4799
|
transactions: block.transactions.map(
|
@@ -4860,7 +4842,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4860
4842
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4861
4843
|
asset: (0, import_utils22.hexlify)(assetId)
|
4862
4844
|
});
|
4863
|
-
return (0,
|
4845
|
+
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4864
4846
|
}
|
4865
4847
|
/**
|
4866
4848
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4874,7 +4856,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4874
4856
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4875
4857
|
assetId: (0, import_utils22.hexlify)(assetId)
|
4876
4858
|
});
|
4877
|
-
return (0,
|
4859
|
+
return (0, import_math17.bn)(balance.amount, 10);
|
4878
4860
|
}
|
4879
4861
|
/**
|
4880
4862
|
* Returns balances for the given owner.
|
@@ -4892,7 +4874,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4892
4874
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4893
4875
|
return balances.map((balance) => ({
|
4894
4876
|
assetId: balance.assetId,
|
4895
|
-
amount: (0,
|
4877
|
+
amount: (0, import_math17.bn)(balance.amount)
|
4896
4878
|
}));
|
4897
4879
|
}
|
4898
4880
|
/**
|
@@ -4914,15 +4896,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4914
4896
|
sender: message.sender,
|
4915
4897
|
recipient: message.recipient,
|
4916
4898
|
nonce: message.nonce,
|
4917
|
-
amount: (0,
|
4899
|
+
amount: (0, import_math17.bn)(message.amount),
|
4918
4900
|
data: message.data
|
4919
4901
|
}),
|
4920
4902
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4921
4903
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4922
4904
|
nonce: message.nonce,
|
4923
|
-
amount: (0,
|
4905
|
+
amount: (0, import_math17.bn)(message.amount),
|
4924
4906
|
data: import_transactions20.InputMessageCoder.decodeData(message.data),
|
4925
|
-
daHeight: (0,
|
4907
|
+
daHeight: (0, import_math17.bn)(message.daHeight)
|
4926
4908
|
}));
|
4927
4909
|
}
|
4928
4910
|
/**
|
@@ -4975,19 +4957,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4975
4957
|
} = result.messageProof;
|
4976
4958
|
return {
|
4977
4959
|
messageProof: {
|
4978
|
-
proofIndex: (0,
|
4960
|
+
proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
|
4979
4961
|
proofSet: messageProof.proofSet
|
4980
4962
|
},
|
4981
4963
|
blockProof: {
|
4982
|
-
proofIndex: (0,
|
4964
|
+
proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
|
4983
4965
|
proofSet: blockProof.proofSet
|
4984
4966
|
},
|
4985
4967
|
messageBlockHeader: {
|
4986
4968
|
id: messageBlockHeader.id,
|
4987
|
-
daHeight: (0,
|
4969
|
+
daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
|
4988
4970
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4989
4971
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4990
|
-
height: (0,
|
4972
|
+
height: (0, import_math17.bn)(messageBlockHeader.height),
|
4991
4973
|
prevRoot: messageBlockHeader.prevRoot,
|
4992
4974
|
time: messageBlockHeader.time,
|
4993
4975
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -4999,10 +4981,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4999
4981
|
},
|
5000
4982
|
commitBlockHeader: {
|
5001
4983
|
id: commitBlockHeader.id,
|
5002
|
-
daHeight: (0,
|
4984
|
+
daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
|
5003
4985
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
5004
4986
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
5005
|
-
height: (0,
|
4987
|
+
height: (0, import_math17.bn)(commitBlockHeader.height),
|
5006
4988
|
prevRoot: commitBlockHeader.prevRoot,
|
5007
4989
|
time: commitBlockHeader.time,
|
5008
4990
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -5015,19 +4997,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5015
4997
|
sender: import_address3.Address.fromAddressOrString(sender),
|
5016
4998
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
5017
4999
|
nonce,
|
5018
|
-
amount: (0,
|
5000
|
+
amount: (0, import_math17.bn)(amount),
|
5019
5001
|
data
|
5020
5002
|
};
|
5021
5003
|
}
|
5022
5004
|
async getLatestGasPrice() {
|
5023
5005
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
5024
|
-
return (0,
|
5006
|
+
return (0, import_math17.bn)(latestGasPrice.gasPrice);
|
5025
5007
|
}
|
5026
5008
|
async estimateGasPrice(blockHorizon) {
|
5027
5009
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
5028
5010
|
blockHorizon: String(blockHorizon)
|
5029
5011
|
});
|
5030
|
-
return (0,
|
5012
|
+
return (0, import_math17.bn)(estimateGasPrice.gasPrice);
|
5031
5013
|
}
|
5032
5014
|
/**
|
5033
5015
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -5048,10 +5030,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5048
5030
|
*/
|
5049
5031
|
async produceBlocks(amount, startTime) {
|
5050
5032
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
5051
|
-
blocksToProduce: (0,
|
5033
|
+
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
5052
5034
|
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
5053
5035
|
});
|
5054
|
-
return (0,
|
5036
|
+
return (0, import_math17.bn)(latestBlockHeight);
|
5055
5037
|
}
|
5056
5038
|
// eslint-disable-next-line @typescript-eslint/require-await
|
5057
5039
|
async getTransactionResponse(transactionId) {
|
@@ -5079,6 +5061,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5079
5061
|
}
|
5080
5062
|
return relayedTransactionStatus;
|
5081
5063
|
}
|
5064
|
+
extractDryRunError(transactionRequest, receipts, dryRunStatus) {
|
5065
|
+
const status = dryRunStatus;
|
5066
|
+
let logs = [];
|
5067
|
+
if (transactionRequest.abis) {
|
5068
|
+
logs = getDecodedLogs(
|
5069
|
+
receipts,
|
5070
|
+
transactionRequest.abis.main,
|
5071
|
+
transactionRequest.abis.otherContractsAbis
|
5072
|
+
);
|
5073
|
+
}
|
5074
|
+
return extractTxError({
|
5075
|
+
logs,
|
5076
|
+
receipts,
|
5077
|
+
statusReason: status.reason
|
5078
|
+
});
|
5079
|
+
}
|
5082
5080
|
};
|
5083
5081
|
var Provider = _Provider;
|
5084
5082
|
_cacheInputs = new WeakSet();
|
@@ -5097,7 +5095,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
5097
5095
|
|
5098
5096
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5099
5097
|
var import_errors15 = require("@fuel-ts/errors");
|
5100
|
-
var
|
5098
|
+
var import_math18 = require("@fuel-ts/math");
|
5101
5099
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5102
5100
|
var import_utils25 = require("@fuel-ts/utils");
|
5103
5101
|
async function getTransactionSummary(params) {
|
@@ -5134,8 +5132,8 @@ async function getTransactionSummary(params) {
|
|
5134
5132
|
transaction: decodedTransaction,
|
5135
5133
|
transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5136
5134
|
gqlTransactionStatus: gqlTransaction.status,
|
5137
|
-
gasPerByte: (0,
|
5138
|
-
gasPriceFactor: (0,
|
5135
|
+
gasPerByte: (0, import_math18.bn)(gasPerByte),
|
5136
|
+
gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
|
5139
5137
|
abiMap,
|
5140
5138
|
maxInputs,
|
5141
5139
|
gasCosts,
|
@@ -5234,7 +5232,7 @@ var getDefaultChainId = (networkType) => {
|
|
5234
5232
|
return CHAIN_IDS.eth.sepolia;
|
5235
5233
|
}
|
5236
5234
|
if (networkType === "fuel") {
|
5237
|
-
return CHAIN_IDS.fuel.
|
5235
|
+
return CHAIN_IDS.fuel.devnet;
|
5238
5236
|
}
|
5239
5237
|
return void 0;
|
5240
5238
|
};
|
@@ -5343,13 +5341,13 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
5343
5341
|
|
5344
5342
|
// src/utils/formatTransferToContractScriptData.ts
|
5345
5343
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5346
|
-
var
|
5344
|
+
var import_math19 = require("@fuel-ts/math");
|
5347
5345
|
var import_utils27 = require("@fuel-ts/utils");
|
5348
5346
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5349
5347
|
var formatTransferToContractScriptData = (params) => {
|
5350
5348
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5351
5349
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
5352
|
-
const encoded = numberCoder.encode(new
|
5350
|
+
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
5353
5351
|
const scriptData = Uint8Array.from([
|
5354
5352
|
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
5355
5353
|
...encoded,
|
@@ -5544,9 +5542,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5544
5542
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5545
5543
|
const fee = request.maxFee;
|
5546
5544
|
const baseAssetId = this.provider.getBaseAssetId();
|
5547
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0,
|
5545
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
|
5548
5546
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5549
|
-
amount: (0,
|
5547
|
+
amount: (0, import_math20.bn)(fee),
|
5550
5548
|
assetId: baseAssetId,
|
5551
5549
|
coinQuantities: requiredQuantities
|
5552
5550
|
});
|
@@ -5554,7 +5552,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5554
5552
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5555
5553
|
quantitiesDict[assetId] = {
|
5556
5554
|
required: amount,
|
5557
|
-
owned: (0,
|
5555
|
+
owned: (0, import_math20.bn)(0)
|
5558
5556
|
};
|
5559
5557
|
});
|
5560
5558
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5581,7 +5579,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5581
5579
|
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5582
5580
|
);
|
5583
5581
|
request.addResources(resources);
|
5584
|
-
request.shiftPredicateData();
|
5585
5582
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5586
5583
|
const requestToReestimate2 = (0, import_ramda4.clone)(request);
|
5587
5584
|
if (addedSignatures) {
|
@@ -5613,7 +5610,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5613
5610
|
}
|
5614
5611
|
fundingAttempts += 1;
|
5615
5612
|
}
|
5616
|
-
request.shiftPredicateData();
|
5617
5613
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5618
5614
|
const requestToReestimate = (0, import_ramda4.clone)(request);
|
5619
5615
|
if (addedSignatures) {
|
@@ -5664,7 +5660,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5664
5660
|
* @returns A promise that resolves to the transaction response.
|
5665
5661
|
*/
|
5666
5662
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5667
|
-
if ((0,
|
5663
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5668
5664
|
throw new import_errors16.FuelError(
|
5669
5665
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5670
5666
|
"Transfer amount must be a positive number."
|
@@ -5684,7 +5680,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5684
5680
|
* @returns A promise that resolves to the transaction response.
|
5685
5681
|
*/
|
5686
5682
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5687
|
-
if ((0,
|
5683
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5688
5684
|
throw new import_errors16.FuelError(
|
5689
5685
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5690
5686
|
"Transfer amount must be a positive number."
|
@@ -5694,7 +5690,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5694
5690
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5695
5691
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5696
5692
|
hexlifiedContractId: contractAddress.toB256(),
|
5697
|
-
amountToTransfer: (0,
|
5693
|
+
amountToTransfer: (0, import_math20.bn)(amount),
|
5698
5694
|
assetId: assetIdToTransfer
|
5699
5695
|
});
|
5700
5696
|
let request = new ScriptTransactionRequest({
|
@@ -5705,7 +5701,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5705
5701
|
request.addContractInputAndOutput(contractAddress);
|
5706
5702
|
const txCost = await this.provider.getTransactionCost(request, {
|
5707
5703
|
resourcesOwner: this,
|
5708
|
-
quantitiesToContract: [{ amount: (0,
|
5704
|
+
quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5709
5705
|
});
|
5710
5706
|
request = this.validateGasLimitAndMaxFee({
|
5711
5707
|
transactionRequest: request,
|
@@ -5730,7 +5726,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5730
5726
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5731
5727
|
);
|
5732
5728
|
const amountDataArray = (0, import_utils28.arrayify)(
|
5733
|
-
"0x".concat((0,
|
5729
|
+
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5734
5730
|
);
|
5735
5731
|
const script = new Uint8Array([
|
5736
5732
|
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
@@ -5740,7 +5736,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5740
5736
|
const params = { script, ...txParams };
|
5741
5737
|
const baseAssetId = this.provider.getBaseAssetId();
|
5742
5738
|
let request = new ScriptTransactionRequest(params);
|
5743
|
-
const quantitiesToContract = [{ amount: (0,
|
5739
|
+
const quantitiesToContract = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
|
5744
5740
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5745
5741
|
request = this.validateGasLimitAndMaxFee({
|
5746
5742
|
transactionRequest: request,
|
@@ -5841,7 +5837,7 @@ var import_utils31 = require("@fuel-ts/utils");
|
|
5841
5837
|
var import_address5 = require("@fuel-ts/address");
|
5842
5838
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5843
5839
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5844
|
-
var
|
5840
|
+
var import_math21 = require("@fuel-ts/math");
|
5845
5841
|
var import_utils29 = require("@fuel-ts/utils");
|
5846
5842
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5847
5843
|
var Signer = class {
|
@@ -5861,7 +5857,7 @@ var Signer = class {
|
|
5861
5857
|
privateKey = `0x${privateKey}`;
|
5862
5858
|
}
|
5863
5859
|
}
|
5864
|
-
const privateKeyBytes = (0,
|
5860
|
+
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
5865
5861
|
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5866
5862
|
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5867
5863
|
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
@@ -5879,8 +5875,8 @@ var Signer = class {
|
|
5879
5875
|
*/
|
5880
5876
|
sign(data) {
|
5881
5877
|
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5882
|
-
const r = (0,
|
5883
|
-
const s = (0,
|
5878
|
+
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5879
|
+
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5884
5880
|
s[0] |= (signature.recovery || 0) << 7;
|
5885
5881
|
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5886
5882
|
}
|
@@ -6153,7 +6149,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6153
6149
|
var import_crypto5 = require("@fuel-ts/crypto");
|
6154
6150
|
var import_errors20 = require("@fuel-ts/errors");
|
6155
6151
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6156
|
-
var
|
6152
|
+
var import_math22 = require("@fuel-ts/math");
|
6157
6153
|
var import_utils35 = require("@fuel-ts/utils");
|
6158
6154
|
|
6159
6155
|
// src/mnemonic/mnemonic.ts
|
@@ -8224,38 +8220,6 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8224
8220
|
var import_errors18 = require("@fuel-ts/errors");
|
8225
8221
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8226
8222
|
var import_utils32 = require("@fuel-ts/utils");
|
8227
|
-
function toUtf8Bytes(stri) {
|
8228
|
-
const str = stri.normalize("NFKD");
|
8229
|
-
const result = [];
|
8230
|
-
for (let i = 0; i < str.length; i += 1) {
|
8231
|
-
const c = str.charCodeAt(i);
|
8232
|
-
if (c < 128) {
|
8233
|
-
result.push(c);
|
8234
|
-
} else if (c < 2048) {
|
8235
|
-
result.push(c >> 6 | 192);
|
8236
|
-
result.push(c & 63 | 128);
|
8237
|
-
} else if ((c & 64512) === 55296) {
|
8238
|
-
i += 1;
|
8239
|
-
const c2 = str.charCodeAt(i);
|
8240
|
-
if (i >= str.length || (c2 & 64512) !== 56320) {
|
8241
|
-
throw new import_errors18.FuelError(
|
8242
|
-
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
8243
|
-
"Invalid UTF-8 in the input string."
|
8244
|
-
);
|
8245
|
-
}
|
8246
|
-
const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
|
8247
|
-
result.push(pair >> 18 | 240);
|
8248
|
-
result.push(pair >> 12 & 63 | 128);
|
8249
|
-
result.push(pair >> 6 & 63 | 128);
|
8250
|
-
result.push(pair & 63 | 128);
|
8251
|
-
} else {
|
8252
|
-
result.push(c >> 12 | 224);
|
8253
|
-
result.push(c >> 6 & 63 | 128);
|
8254
|
-
result.push(c & 63 | 128);
|
8255
|
-
}
|
8256
|
-
}
|
8257
|
-
return Uint8Array.from(result);
|
8258
|
-
}
|
8259
8223
|
function getLowerMask(bits) {
|
8260
8224
|
return (1 << bits) - 1;
|
8261
8225
|
}
|
@@ -8328,7 +8292,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8328
8292
|
}
|
8329
8293
|
|
8330
8294
|
// src/mnemonic/mnemonic.ts
|
8331
|
-
var MasterSecret = toUtf8Bytes("Bitcoin seed");
|
8295
|
+
var MasterSecret = (0, import_utils33.toUtf8Bytes)("Bitcoin seed");
|
8332
8296
|
var MainnetPRV = "0x0488ade4";
|
8333
8297
|
var TestnetPRV = "0x04358394";
|
8334
8298
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
@@ -8412,8 +8376,8 @@ var Mnemonic = class {
|
|
8412
8376
|
*/
|
8413
8377
|
static mnemonicToSeed(phrase, passphrase = "") {
|
8414
8378
|
assertMnemonic(getWords(phrase));
|
8415
|
-
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
8416
|
-
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
8379
|
+
const phraseBytes = (0, import_utils33.toUtf8Bytes)(getPhrase(phrase));
|
8380
|
+
const salt = (0, import_utils33.toUtf8Bytes)(`mnemonic${passphrase}`);
|
8417
8381
|
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
8418
8382
|
}
|
8419
8383
|
/**
|
@@ -8617,13 +8581,13 @@ var HDWallet = class {
|
|
8617
8581
|
} else {
|
8618
8582
|
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8619
8583
|
}
|
8620
|
-
data.set((0,
|
8584
|
+
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8621
8585
|
const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8622
8586
|
const IL = bytes.slice(0, 32);
|
8623
8587
|
const IR = bytes.slice(32);
|
8624
8588
|
if (privateKey) {
|
8625
8589
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8626
|
-
const ki = (0,
|
8590
|
+
const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
8627
8591
|
return new HDWallet({
|
8628
8592
|
privateKey: ki,
|
8629
8593
|
chainCode: IR,
|
@@ -8669,7 +8633,7 @@ var HDWallet = class {
|
|
8669
8633
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8670
8634
|
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8671
8635
|
const parentFingerprint = this.parentFingerprint;
|
8672
|
-
const index = (0,
|
8636
|
+
const index = (0, import_math22.toHex)(this.index, 4);
|
8673
8637
|
const chainCode = this.chainCode;
|
8674
8638
|
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8675
8639
|
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
@@ -8689,7 +8653,7 @@ var HDWallet = class {
|
|
8689
8653
|
});
|
8690
8654
|
}
|
8691
8655
|
static fromExtendedKey(extendedKey) {
|
8692
|
-
const decoded = (0, import_utils35.hexlify)((0,
|
8656
|
+
const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
|
8693
8657
|
const bytes = (0, import_utils35.arrayify)(decoded);
|
8694
8658
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8695
8659
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -9305,7 +9269,6 @@ var StorageAbstract = class {
|
|
9305
9269
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
9306
9270
|
var import_address10 = require("@fuel-ts/address");
|
9307
9271
|
var import_errors25 = require("@fuel-ts/errors");
|
9308
|
-
var import_transactions22 = require("@fuel-ts/transactions");
|
9309
9272
|
var import_utils37 = require("@fuel-ts/utils");
|
9310
9273
|
|
9311
9274
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9363,7 +9326,6 @@ var Predicate = class extends Account {
|
|
9363
9326
|
*/
|
9364
9327
|
populateTransactionPredicateData(transactionRequestLike) {
|
9365
9328
|
const request = transactionRequestify(transactionRequestLike);
|
9366
|
-
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9367
9329
|
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
9368
9330
|
if (placeholderIndex !== -1) {
|
9369
9331
|
request.removeWitness(placeholderIndex);
|
@@ -9371,7 +9333,7 @@ var Predicate = class extends Account {
|
|
9371
9333
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9372
9334
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9373
9335
|
input.predicate = (0, import_utils37.hexlify)(this.bytes);
|
9374
|
-
input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData(
|
9336
|
+
input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData());
|
9375
9337
|
input.witnessIndex = 0;
|
9376
9338
|
}
|
9377
9339
|
});
|
@@ -9397,17 +9359,12 @@ var Predicate = class extends Account {
|
|
9397
9359
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9398
9360
|
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
9399
9361
|
}
|
9400
|
-
getPredicateData(
|
9362
|
+
getPredicateData() {
|
9401
9363
|
if (!this.predicateData.length) {
|
9402
9364
|
return new Uint8Array();
|
9403
9365
|
}
|
9404
9366
|
const mainFn = this.interface?.functions.main;
|
9405
|
-
|
9406
|
-
const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
|
9407
|
-
maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
|
9408
|
-
});
|
9409
|
-
const OFFSET = VM_TX_MEMORY + import_abi_coder7.SCRIPT_FIXED_SIZE + import_abi_coder7.INPUT_COIN_FIXED_SIZE + import_abi_coder7.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder7.WORD_SIZE;
|
9410
|
-
return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
|
9367
|
+
return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
|
9411
9368
|
}
|
9412
9369
|
/**
|
9413
9370
|
* Processes the predicate data and returns the altered bytecode and interface.
|
@@ -9456,8 +9413,7 @@ var Predicate = class extends Account {
|
|
9456
9413
|
);
|
9457
9414
|
return resources.map((resource) => ({
|
9458
9415
|
...resource,
|
9459
|
-
predicate: (0, import_utils37.hexlify)(this.bytes)
|
9460
|
-
padPredicateData: (policiesLength) => (0, import_utils37.hexlify)(this.getPredicateData(policiesLength))
|
9416
|
+
predicate: (0, import_utils37.hexlify)(this.bytes)
|
9461
9417
|
}));
|
9462
9418
|
}
|
9463
9419
|
/**
|