@fuel-ts/account 0.0.0-rc-1356-20240514125020 → 0.0.0-rc-2238-20240514153703
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/index.global.js +432 -1164
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +234 -254
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -145
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.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/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-summary/call.d.ts +1 -1
- package/dist/providers/transaction-summary/call.d.ts.map +1 -1
- package/dist/providers/utils/auto-retry-fetch.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/providers/utils/sleep.d.ts +3 -0
- package/dist/providers/utils/sleep.d.ts.map +1 -0
- package/dist/test-utils/index.d.ts +0 -4
- package/dist/test-utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +1 -8
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +428 -1475
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +272 -523
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +166 -413
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -16
- package/dist/test-utils/asset-id.d.ts +0 -8
- package/dist/test-utils/asset-id.d.ts.map +0 -1
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts +0 -33
- package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +0 -1
- package/dist/test-utils/test-message.d.ts +0 -28
- package/dist/test-utils/test-message.d.ts.map +0 -1
- package/dist/test-utils/wallet-config.d.ts +0 -49
- package/dist/test-utils/wallet-config.d.ts.map +0 -1
package/dist/index.js
CHANGED
@@ -186,6 +186,7 @@ __export(src_exports, {
|
|
186
186
|
resolveGasDependentCosts: () => resolveGasDependentCosts,
|
187
187
|
resolveIconPaths: () => resolveIconPaths,
|
188
188
|
returnZeroScript: () => returnZeroScript,
|
189
|
+
sleep: () => sleep,
|
189
190
|
transactionRequestify: () => transactionRequestify,
|
190
191
|
urlJoin: () => urlJoin,
|
191
192
|
withTimeout: () => withTimeout,
|
@@ -197,8 +198,8 @@ module.exports = __toCommonJS(src_exports);
|
|
197
198
|
var import_address4 = require("@fuel-ts/address");
|
198
199
|
var import_errors16 = require("@fuel-ts/errors");
|
199
200
|
var import_interfaces = require("@fuel-ts/interfaces");
|
200
|
-
var
|
201
|
-
var
|
201
|
+
var import_math20 = require("@fuel-ts/math");
|
202
|
+
var import_utils28 = require("@fuel-ts/utils");
|
202
203
|
var import_ramda4 = require("ramda");
|
203
204
|
|
204
205
|
// src/providers/coin-quantity.ts
|
@@ -239,11 +240,11 @@ var addAmountToCoinQuantities = (params) => {
|
|
239
240
|
// src/providers/provider.ts
|
240
241
|
var import_address3 = require("@fuel-ts/address");
|
241
242
|
var import_errors14 = require("@fuel-ts/errors");
|
242
|
-
var
|
243
|
+
var import_math17 = require("@fuel-ts/math");
|
243
244
|
var import_transactions20 = require("@fuel-ts/transactions");
|
244
|
-
var
|
245
|
+
var import_utils22 = require("@fuel-ts/utils");
|
245
246
|
var import_versions = require("@fuel-ts/versions");
|
246
|
-
var
|
247
|
+
var import_utils23 = require("@noble/curves/abstract/utils");
|
247
248
|
var import_graphql_request = require("graphql-request");
|
248
249
|
var import_ramda3 = require("ramda");
|
249
250
|
|
@@ -1862,6 +1863,15 @@ function normalizeJSON(root) {
|
|
1862
1863
|
return normalize((0, import_ramda.clone)(root));
|
1863
1864
|
}
|
1864
1865
|
|
1866
|
+
// src/providers/utils/sleep.ts
|
1867
|
+
function sleep(time) {
|
1868
|
+
return new Promise((resolve) => {
|
1869
|
+
setTimeout(() => {
|
1870
|
+
resolve(true);
|
1871
|
+
}, time);
|
1872
|
+
});
|
1873
|
+
}
|
1874
|
+
|
1865
1875
|
// src/providers/utils/extract-tx-error.ts
|
1866
1876
|
var import_errors7 = require("@fuel-ts/errors");
|
1867
1877
|
var import_math6 = require("@fuel-ts/math");
|
@@ -2510,15 +2520,6 @@ var BaseTransactionRequest = class {
|
|
2510
2520
|
}
|
2511
2521
|
});
|
2512
2522
|
}
|
2513
|
-
shiftPredicateData() {
|
2514
|
-
this.inputs.forEach((input) => {
|
2515
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2516
|
-
input.predicateData = input.padPredicateData(
|
2517
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2518
|
-
);
|
2519
|
-
}
|
2520
|
-
});
|
2521
|
-
}
|
2522
2523
|
};
|
2523
2524
|
|
2524
2525
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2941,12 +2942,12 @@ var transactionRequestify = (obj) => {
|
|
2941
2942
|
|
2942
2943
|
// src/providers/transaction-response/transaction-response.ts
|
2943
2944
|
var import_errors13 = require("@fuel-ts/errors");
|
2944
|
-
var
|
2945
|
+
var import_math16 = require("@fuel-ts/math");
|
2945
2946
|
var import_transactions19 = require("@fuel-ts/transactions");
|
2946
2947
|
var import_utils20 = require("@fuel-ts/utils");
|
2947
2948
|
|
2948
2949
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2949
|
-
var
|
2950
|
+
var import_math15 = require("@fuel-ts/math");
|
2950
2951
|
var import_transactions17 = require("@fuel-ts/transactions");
|
2951
2952
|
var import_utils18 = require("@fuel-ts/utils");
|
2952
2953
|
|
@@ -3023,43 +3024,32 @@ var calculateTXFeeForSummary = (params) => {
|
|
3023
3024
|
// src/providers/transaction-summary/operations.ts
|
3024
3025
|
var import_configs10 = require("@fuel-ts/address/configs");
|
3025
3026
|
var import_errors11 = require("@fuel-ts/errors");
|
3026
|
-
var
|
3027
|
+
var import_math13 = require("@fuel-ts/math");
|
3027
3028
|
var import_transactions15 = require("@fuel-ts/transactions");
|
3028
3029
|
|
3029
3030
|
// src/providers/transaction-summary/call.ts
|
3030
3031
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
3031
|
-
var
|
3032
|
-
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
3032
|
+
var getFunctionCall = ({ abi, receipt }) => {
|
3033
3033
|
const abiInterface = new import_abi_coder4.Interface(abi);
|
3034
3034
|
const callFunctionSelector = receipt.param1.toHex(8);
|
3035
3035
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
3036
3036
|
const inputs = functionFragment.jsonFn.inputs;
|
3037
|
-
|
3038
|
-
if (functionFragment.isInputDataPointer) {
|
3039
|
-
if (rawPayload) {
|
3040
|
-
const argsOffset = (0, import_math13.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
3041
|
-
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
3042
|
-
}
|
3043
|
-
} else {
|
3044
|
-
encodedArgs = receipt.param2.toHex();
|
3045
|
-
}
|
3037
|
+
const encodedArgs = receipt.param2.toHex();
|
3046
3038
|
let argumentsProvided;
|
3047
|
-
|
3048
|
-
|
3049
|
-
|
3050
|
-
|
3051
|
-
|
3052
|
-
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
}, {});
|
3062
|
-
}
|
3039
|
+
const data = functionFragment.decodeArguments(encodedArgs);
|
3040
|
+
if (data) {
|
3041
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
3042
|
+
const value = data[index];
|
3043
|
+
const name = input.name;
|
3044
|
+
if (name) {
|
3045
|
+
return {
|
3046
|
+
...prev,
|
3047
|
+
// reparse to remove bn
|
3048
|
+
[name]: JSON.parse(JSON.stringify(value))
|
3049
|
+
};
|
3050
|
+
}
|
3051
|
+
return prev;
|
3052
|
+
}, {});
|
3063
3053
|
}
|
3064
3054
|
const call = {
|
3065
3055
|
functionSignature: functionFragment.signature,
|
@@ -3245,7 +3235,7 @@ var mergeAssets = (op1, op2) => {
|
|
3245
3235
|
if (!matchingAsset) {
|
3246
3236
|
return asset1;
|
3247
3237
|
}
|
3248
|
-
const mergedAmount = (0,
|
3238
|
+
const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
|
3249
3239
|
return { ...asset1, amount: mergedAmount };
|
3250
3240
|
});
|
3251
3241
|
return mergedAssets.concat(filteredAssets);
|
@@ -3571,7 +3561,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3571
3561
|
|
3572
3562
|
// src/providers/transaction-summary/status.ts
|
3573
3563
|
var import_errors12 = require("@fuel-ts/errors");
|
3574
|
-
var
|
3564
|
+
var import_math14 = require("@fuel-ts/math");
|
3575
3565
|
var getTransactionStatusName = (gqlStatus) => {
|
3576
3566
|
switch (gqlStatus) {
|
3577
3567
|
case "FailureStatus":
|
@@ -3605,15 +3595,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3605
3595
|
time = gqlTransactionStatus.time;
|
3606
3596
|
blockId = gqlTransactionStatus.block.id;
|
3607
3597
|
isStatusSuccess = true;
|
3608
|
-
totalFee = (0,
|
3609
|
-
totalGas = (0,
|
3598
|
+
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3599
|
+
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3610
3600
|
break;
|
3611
3601
|
case "FailureStatus":
|
3612
3602
|
time = gqlTransactionStatus.time;
|
3613
3603
|
blockId = gqlTransactionStatus.block.id;
|
3614
3604
|
isStatusFailure = true;
|
3615
|
-
totalFee = (0,
|
3616
|
-
totalGas = (0,
|
3605
|
+
totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
|
3606
|
+
totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
|
3617
3607
|
break;
|
3618
3608
|
case "SubmittedStatus":
|
3619
3609
|
time = gqlTransactionStatus.time;
|
@@ -3663,7 +3653,7 @@ function assembleTransactionSummary(params) {
|
|
3663
3653
|
maxInputs
|
3664
3654
|
});
|
3665
3655
|
const typeName = getTransactionTypeName(transaction.type);
|
3666
|
-
const tip = (0,
|
3656
|
+
const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
3667
3657
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3668
3658
|
const fee = calculateTXFeeForSummary({
|
3669
3659
|
totalFee,
|
@@ -3734,7 +3724,7 @@ var TransactionResponse = class {
|
|
3734
3724
|
/** Current provider */
|
3735
3725
|
provider;
|
3736
3726
|
/** Gas used on the transaction */
|
3737
|
-
gasUsed = (0,
|
3727
|
+
gasUsed = (0, import_math16.bn)(0);
|
3738
3728
|
/** The graphql Transaction with receipts object. */
|
3739
3729
|
gqlTransaction;
|
3740
3730
|
abis;
|
@@ -3902,7 +3892,6 @@ var TransactionResponse = class {
|
|
3902
3892
|
};
|
3903
3893
|
|
3904
3894
|
// src/providers/utils/auto-retry-fetch.ts
|
3905
|
-
var import_utils22 = require("@fuel-ts/utils");
|
3906
3895
|
function getWaitDelay(options, retryAttemptNum) {
|
3907
3896
|
const duration = options.baseDelay ?? 150;
|
3908
3897
|
switch (options.backoff) {
|
@@ -3932,7 +3921,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3932
3921
|
throw error;
|
3933
3922
|
}
|
3934
3923
|
const delay = getWaitDelay(options, retryNum);
|
3935
|
-
await
|
3924
|
+
await sleep(delay);
|
3936
3925
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3937
3926
|
}
|
3938
3927
|
};
|
@@ -3969,47 +3958,47 @@ var processGqlChain = (chain) => {
|
|
3969
3958
|
} = consensusParameters;
|
3970
3959
|
return {
|
3971
3960
|
name,
|
3972
|
-
baseChainHeight: (0,
|
3961
|
+
baseChainHeight: (0, import_math17.bn)(daHeight),
|
3973
3962
|
consensusParameters: {
|
3974
3963
|
version,
|
3975
|
-
chainId: (0,
|
3964
|
+
chainId: (0, import_math17.bn)(chainId),
|
3976
3965
|
baseAssetId,
|
3977
3966
|
feeParameters: {
|
3978
3967
|
version: feeParams.version,
|
3979
|
-
gasPerByte: (0,
|
3980
|
-
gasPriceFactor: (0,
|
3968
|
+
gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
|
3969
|
+
gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
|
3981
3970
|
},
|
3982
3971
|
contractParameters: {
|
3983
3972
|
version: contractParams.version,
|
3984
|
-
contractMaxSize: (0,
|
3985
|
-
maxStorageSlots: (0,
|
3973
|
+
contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
|
3974
|
+
maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
|
3986
3975
|
},
|
3987
3976
|
txParameters: {
|
3988
3977
|
version: txParams.version,
|
3989
|
-
maxInputs: (0,
|
3990
|
-
maxOutputs: (0,
|
3991
|
-
maxWitnesses: (0,
|
3992
|
-
maxGasPerTx: (0,
|
3993
|
-
maxSize: (0,
|
3994
|
-
maxBytecodeSubsections: (0,
|
3978
|
+
maxInputs: (0, import_math17.bn)(txParams.maxInputs),
|
3979
|
+
maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
|
3980
|
+
maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
|
3981
|
+
maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
|
3982
|
+
maxSize: (0, import_math17.bn)(txParams.maxSize),
|
3983
|
+
maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
|
3995
3984
|
},
|
3996
3985
|
predicateParameters: {
|
3997
3986
|
version: predicateParams.version,
|
3998
|
-
maxPredicateLength: (0,
|
3999
|
-
maxPredicateDataLength: (0,
|
4000
|
-
maxGasPerPredicate: (0,
|
4001
|
-
maxMessageDataLength: (0,
|
3987
|
+
maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
|
3988
|
+
maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
|
3989
|
+
maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
|
3990
|
+
maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
|
4002
3991
|
},
|
4003
3992
|
scriptParameters: {
|
4004
3993
|
version: scriptParams.version,
|
4005
|
-
maxScriptLength: (0,
|
4006
|
-
maxScriptDataLength: (0,
|
3994
|
+
maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
|
3995
|
+
maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
|
4007
3996
|
},
|
4008
3997
|
gasCosts
|
4009
3998
|
},
|
4010
3999
|
latestBlock: {
|
4011
4000
|
id: latestBlock.id,
|
4012
|
-
height: (0,
|
4001
|
+
height: (0, import_math17.bn)(latestBlock.height),
|
4013
4002
|
time: latestBlock.header.time,
|
4014
4003
|
transactions: latestBlock.transactions.map((i) => ({
|
4015
4004
|
id: i.id
|
@@ -4205,7 +4194,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4205
4194
|
*/
|
4206
4195
|
async getBlockNumber() {
|
4207
4196
|
const { chain } = await this.operations.getChain();
|
4208
|
-
return (0,
|
4197
|
+
return (0, import_math17.bn)(chain.latestBlock.height, 10);
|
4209
4198
|
}
|
4210
4199
|
/**
|
4211
4200
|
* Returns the chain information.
|
@@ -4215,8 +4204,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4215
4204
|
async fetchNode() {
|
4216
4205
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
4217
4206
|
const processedNodeInfo = {
|
4218
|
-
maxDepth: (0,
|
4219
|
-
maxTx: (0,
|
4207
|
+
maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
|
4208
|
+
maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
|
4220
4209
|
nodeVersion: nodeInfo.nodeVersion,
|
4221
4210
|
utxoValidation: nodeInfo.utxoValidation,
|
4222
4211
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4272,7 +4261,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4272
4261
|
if (estimateTxDependencies) {
|
4273
4262
|
await this.estimateTxDependencies(transactionRequest);
|
4274
4263
|
}
|
4275
|
-
const encodedTransaction = (0,
|
4264
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4276
4265
|
let abis;
|
4277
4266
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4278
4267
|
abis = transactionRequest.abis;
|
@@ -4315,7 +4304,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4315
4304
|
if (estimateTxDependencies) {
|
4316
4305
|
return this.estimateTxDependencies(transactionRequest);
|
4317
4306
|
}
|
4318
|
-
const encodedTransaction = (0,
|
4307
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4319
4308
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4320
4309
|
encodedTransactions: encodedTransaction,
|
4321
4310
|
utxoValidation: utxoValidation || false
|
@@ -4333,13 +4322,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4333
4322
|
async estimatePredicates(transactionRequest) {
|
4334
4323
|
const shouldEstimatePredicates = Boolean(
|
4335
4324
|
transactionRequest.inputs.find(
|
4336
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4325
|
+
(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()
|
4337
4326
|
)
|
4338
4327
|
);
|
4339
4328
|
if (!shouldEstimatePredicates) {
|
4340
4329
|
return transactionRequest;
|
4341
4330
|
}
|
4342
|
-
const encodedTransaction = (0,
|
4331
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4343
4332
|
const response = await this.operations.estimatePredicates({
|
4344
4333
|
encodedTransaction
|
4345
4334
|
});
|
@@ -4348,7 +4337,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4348
4337
|
} = response;
|
4349
4338
|
if (inputs) {
|
4350
4339
|
inputs.forEach((input, index) => {
|
4351
|
-
if ("predicateGasUsed" in input && (0,
|
4340
|
+
if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
|
4352
4341
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4353
4342
|
}
|
4354
4343
|
});
|
@@ -4381,7 +4370,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4381
4370
|
const {
|
4382
4371
|
dryRun: [{ receipts: rawReceipts, status }]
|
4383
4372
|
} = await this.operations.dryRun({
|
4384
|
-
encodedTransactions: [(0,
|
4373
|
+
encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
|
4385
4374
|
utxoValidation: false
|
4386
4375
|
});
|
4387
4376
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4431,7 +4420,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4431
4420
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4432
4421
|
allRequests.forEach((req, index) => {
|
4433
4422
|
if (req.type === import_transactions20.TransactionType.Script) {
|
4434
|
-
serializedTransactionsMap.set(index, (0,
|
4423
|
+
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4435
4424
|
}
|
4436
4425
|
});
|
4437
4426
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4467,7 +4456,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4467
4456
|
transactionRequest: request
|
4468
4457
|
});
|
4469
4458
|
request.maxFee = maxFee;
|
4470
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
4459
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
|
4471
4460
|
nextRoundTransactions.push(requestIdx);
|
4472
4461
|
}
|
4473
4462
|
}
|
@@ -4480,7 +4469,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4480
4469
|
if (estimateTxDependencies) {
|
4481
4470
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4482
4471
|
}
|
4483
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
4472
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
|
4484
4473
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4485
4474
|
encodedTransactions,
|
4486
4475
|
utxoValidation: utxoValidation || false
|
@@ -4506,12 +4495,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4506
4495
|
gasPrice = await this.estimateGasPrice(10);
|
4507
4496
|
}
|
4508
4497
|
const minFee = calculateGasFee({
|
4509
|
-
gasPrice: (0,
|
4498
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4510
4499
|
gas: minGas,
|
4511
4500
|
priceFactor: gasPriceFactor,
|
4512
4501
|
tip: transactionRequest.tip
|
4513
4502
|
}).add(1);
|
4514
|
-
let gasLimit = (0,
|
4503
|
+
let gasLimit = (0, import_math17.bn)(0);
|
4515
4504
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4516
4505
|
gasLimit = transactionRequest.gasLimit;
|
4517
4506
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4524,7 +4513,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4524
4513
|
}
|
4525
4514
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4526
4515
|
const maxFee = calculateGasFee({
|
4527
|
-
gasPrice: (0,
|
4516
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4528
4517
|
gas: maxGas,
|
4529
4518
|
priceFactor: gasPriceFactor,
|
4530
4519
|
tip: transactionRequest.tip
|
@@ -4553,7 +4542,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4553
4542
|
if (estimateTxDependencies) {
|
4554
4543
|
return this.estimateTxDependencies(transactionRequest);
|
4555
4544
|
}
|
4556
|
-
const encodedTransactions = [(0,
|
4545
|
+
const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
|
4557
4546
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4558
4547
|
encodedTransactions,
|
4559
4548
|
utxoValidation: true
|
@@ -4589,7 +4578,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4589
4578
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4590
4579
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4591
4580
|
if (isScriptTransaction) {
|
4592
|
-
txRequestClone.gasLimit = (0,
|
4581
|
+
txRequestClone.gasLimit = (0, import_math17.bn)(0);
|
4593
4582
|
}
|
4594
4583
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4595
4584
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4610,7 +4599,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4610
4599
|
let dryRunStatus;
|
4611
4600
|
let missingContractIds = [];
|
4612
4601
|
let outputVariables = 0;
|
4613
|
-
let gasUsed = (0,
|
4602
|
+
let gasUsed = (0, import_math17.bn)(0);
|
4614
4603
|
txRequestClone.maxFee = maxFee;
|
4615
4604
|
if (isScriptTransaction) {
|
4616
4605
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4669,16 +4658,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4669
4658
|
const result = await this.operations.getCoins({
|
4670
4659
|
first: 10,
|
4671
4660
|
...paginationArgs,
|
4672
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4661
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4673
4662
|
});
|
4674
4663
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4675
4664
|
return coins.map((coin) => ({
|
4676
4665
|
id: coin.utxoId,
|
4677
4666
|
assetId: coin.assetId,
|
4678
|
-
amount: (0,
|
4667
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4679
4668
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4680
|
-
blockCreated: (0,
|
4681
|
-
txCreatedIdx: (0,
|
4669
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4670
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4682
4671
|
}));
|
4683
4672
|
}
|
4684
4673
|
/**
|
@@ -4692,19 +4681,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4692
4681
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4693
4682
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4694
4683
|
const excludeInput = {
|
4695
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4696
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4684
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
4685
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4697
4686
|
};
|
4698
4687
|
if (this.cache) {
|
4699
4688
|
const uniqueUtxos = new Set(
|
4700
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4689
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4701
4690
|
);
|
4702
4691
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4703
4692
|
}
|
4704
4693
|
const coinsQuery = {
|
4705
4694
|
owner: ownerAddress.toB256(),
|
4706
4695
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4707
|
-
assetId: (0,
|
4696
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4708
4697
|
amount: amount.toString(10),
|
4709
4698
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4710
4699
|
})),
|
@@ -4715,9 +4704,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4715
4704
|
switch (coin.type) {
|
4716
4705
|
case "MessageCoin":
|
4717
4706
|
return {
|
4718
|
-
amount: (0,
|
4707
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4719
4708
|
assetId: coin.assetId,
|
4720
|
-
daHeight: (0,
|
4709
|
+
daHeight: (0, import_math17.bn)(coin.daHeight),
|
4721
4710
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4722
4711
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4723
4712
|
nonce: coin.nonce
|
@@ -4725,11 +4714,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4725
4714
|
case "Coin":
|
4726
4715
|
return {
|
4727
4716
|
id: coin.utxoId,
|
4728
|
-
amount: (0,
|
4717
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4729
4718
|
assetId: coin.assetId,
|
4730
4719
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4731
|
-
blockCreated: (0,
|
4732
|
-
txCreatedIdx: (0,
|
4720
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4721
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4733
4722
|
};
|
4734
4723
|
default:
|
4735
4724
|
return null;
|
@@ -4746,13 +4735,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4746
4735
|
async getBlock(idOrHeight) {
|
4747
4736
|
let variables;
|
4748
4737
|
if (typeof idOrHeight === "number") {
|
4749
|
-
variables = { height: (0,
|
4738
|
+
variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4750
4739
|
} else if (idOrHeight === "latest") {
|
4751
4740
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4752
4741
|
} else if (idOrHeight.length === 66) {
|
4753
4742
|
variables = { blockId: idOrHeight };
|
4754
4743
|
} else {
|
4755
|
-
variables = { blockId: (0,
|
4744
|
+
variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4756
4745
|
}
|
4757
4746
|
const { block } = await this.operations.getBlock(variables);
|
4758
4747
|
if (!block) {
|
@@ -4760,7 +4749,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4760
4749
|
}
|
4761
4750
|
return {
|
4762
4751
|
id: block.id,
|
4763
|
-
height: (0,
|
4752
|
+
height: (0, import_math17.bn)(block.height),
|
4764
4753
|
time: block.header.time,
|
4765
4754
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4766
4755
|
};
|
@@ -4775,7 +4764,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4775
4764
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4776
4765
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4777
4766
|
id: block.id,
|
4778
|
-
height: (0,
|
4767
|
+
height: (0, import_math17.bn)(block.height),
|
4779
4768
|
time: block.header.time,
|
4780
4769
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4781
4770
|
}));
|
@@ -4790,7 +4779,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4790
4779
|
async getBlockWithTransactions(idOrHeight) {
|
4791
4780
|
let variables;
|
4792
4781
|
if (typeof idOrHeight === "number") {
|
4793
|
-
variables = { blockHeight: (0,
|
4782
|
+
variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4794
4783
|
} else if (idOrHeight === "latest") {
|
4795
4784
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4796
4785
|
} else {
|
@@ -4802,11 +4791,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4802
4791
|
}
|
4803
4792
|
return {
|
4804
4793
|
id: block.id,
|
4805
|
-
height: (0,
|
4794
|
+
height: (0, import_math17.bn)(block.height, 10),
|
4806
4795
|
time: block.header.time,
|
4807
4796
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4808
4797
|
transactions: block.transactions.map(
|
4809
|
-
(tx) => new import_transactions20.TransactionCoder().decode((0,
|
4798
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4810
4799
|
)
|
4811
4800
|
};
|
4812
4801
|
}
|
@@ -4822,7 +4811,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4822
4811
|
return null;
|
4823
4812
|
}
|
4824
4813
|
return new import_transactions20.TransactionCoder().decode(
|
4825
|
-
(0,
|
4814
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4826
4815
|
0
|
4827
4816
|
)?.[0];
|
4828
4817
|
}
|
@@ -4849,9 +4838,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4849
4838
|
async getContractBalance(contractId, assetId) {
|
4850
4839
|
const { contractBalance } = await this.operations.getContractBalance({
|
4851
4840
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4852
|
-
asset: (0,
|
4841
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4853
4842
|
});
|
4854
|
-
return (0,
|
4843
|
+
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4855
4844
|
}
|
4856
4845
|
/**
|
4857
4846
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4863,9 +4852,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4863
4852
|
async getBalance(owner, assetId) {
|
4864
4853
|
const { balance } = await this.operations.getBalance({
|
4865
4854
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4866
|
-
assetId: (0,
|
4855
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4867
4856
|
});
|
4868
|
-
return (0,
|
4857
|
+
return (0, import_math17.bn)(balance.amount, 10);
|
4869
4858
|
}
|
4870
4859
|
/**
|
4871
4860
|
* Returns balances for the given owner.
|
@@ -4883,7 +4872,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4883
4872
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4884
4873
|
return balances.map((balance) => ({
|
4885
4874
|
assetId: balance.assetId,
|
4886
|
-
amount: (0,
|
4875
|
+
amount: (0, import_math17.bn)(balance.amount)
|
4887
4876
|
}));
|
4888
4877
|
}
|
4889
4878
|
/**
|
@@ -4905,15 +4894,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4905
4894
|
sender: message.sender,
|
4906
4895
|
recipient: message.recipient,
|
4907
4896
|
nonce: message.nonce,
|
4908
|
-
amount: (0,
|
4897
|
+
amount: (0, import_math17.bn)(message.amount),
|
4909
4898
|
data: message.data
|
4910
4899
|
}),
|
4911
4900
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4912
4901
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4913
4902
|
nonce: message.nonce,
|
4914
|
-
amount: (0,
|
4903
|
+
amount: (0, import_math17.bn)(message.amount),
|
4915
4904
|
data: import_transactions20.InputMessageCoder.decodeData(message.data),
|
4916
|
-
daHeight: (0,
|
4905
|
+
daHeight: (0, import_math17.bn)(message.daHeight)
|
4917
4906
|
}));
|
4918
4907
|
}
|
4919
4908
|
/**
|
@@ -4966,19 +4955,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4966
4955
|
} = result.messageProof;
|
4967
4956
|
return {
|
4968
4957
|
messageProof: {
|
4969
|
-
proofIndex: (0,
|
4958
|
+
proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
|
4970
4959
|
proofSet: messageProof.proofSet
|
4971
4960
|
},
|
4972
4961
|
blockProof: {
|
4973
|
-
proofIndex: (0,
|
4962
|
+
proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
|
4974
4963
|
proofSet: blockProof.proofSet
|
4975
4964
|
},
|
4976
4965
|
messageBlockHeader: {
|
4977
4966
|
id: messageBlockHeader.id,
|
4978
|
-
daHeight: (0,
|
4967
|
+
daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
|
4979
4968
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4980
4969
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4981
|
-
height: (0,
|
4970
|
+
height: (0, import_math17.bn)(messageBlockHeader.height),
|
4982
4971
|
prevRoot: messageBlockHeader.prevRoot,
|
4983
4972
|
time: messageBlockHeader.time,
|
4984
4973
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -4990,10 +4979,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4990
4979
|
},
|
4991
4980
|
commitBlockHeader: {
|
4992
4981
|
id: commitBlockHeader.id,
|
4993
|
-
daHeight: (0,
|
4982
|
+
daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
|
4994
4983
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4995
4984
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4996
|
-
height: (0,
|
4985
|
+
height: (0, import_math17.bn)(commitBlockHeader.height),
|
4997
4986
|
prevRoot: commitBlockHeader.prevRoot,
|
4998
4987
|
time: commitBlockHeader.time,
|
4999
4988
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -5006,19 +4995,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5006
4995
|
sender: import_address3.Address.fromAddressOrString(sender),
|
5007
4996
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
5008
4997
|
nonce,
|
5009
|
-
amount: (0,
|
4998
|
+
amount: (0, import_math17.bn)(amount),
|
5010
4999
|
data
|
5011
5000
|
};
|
5012
5001
|
}
|
5013
5002
|
async getLatestGasPrice() {
|
5014
5003
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
5015
|
-
return (0,
|
5004
|
+
return (0, import_math17.bn)(latestGasPrice.gasPrice);
|
5016
5005
|
}
|
5017
5006
|
async estimateGasPrice(blockHorizon) {
|
5018
5007
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
5019
5008
|
blockHorizon: String(blockHorizon)
|
5020
5009
|
});
|
5021
|
-
return (0,
|
5010
|
+
return (0, import_math17.bn)(estimateGasPrice.gasPrice);
|
5022
5011
|
}
|
5023
5012
|
/**
|
5024
5013
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -5039,10 +5028,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5039
5028
|
*/
|
5040
5029
|
async produceBlocks(amount, startTime) {
|
5041
5030
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
5042
|
-
blocksToProduce: (0,
|
5043
|
-
startTimestamp: startTime ?
|
5031
|
+
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
5032
|
+
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
5044
5033
|
});
|
5045
|
-
return (0,
|
5034
|
+
return (0, import_math17.bn)(latestBlockHeight);
|
5046
5035
|
}
|
5047
5036
|
// eslint-disable-next-line @typescript-eslint/require-await
|
5048
5037
|
async getTransactionResponse(transactionId) {
|
@@ -5088,9 +5077,9 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
5088
5077
|
|
5089
5078
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5090
5079
|
var import_errors15 = require("@fuel-ts/errors");
|
5091
|
-
var
|
5080
|
+
var import_math18 = require("@fuel-ts/math");
|
5092
5081
|
var import_transactions21 = require("@fuel-ts/transactions");
|
5093
|
-
var
|
5082
|
+
var import_utils25 = require("@fuel-ts/utils");
|
5094
5083
|
async function getTransactionSummary(params) {
|
5095
5084
|
const { id, provider, abiMap } = params;
|
5096
5085
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -5103,7 +5092,7 @@ async function getTransactionSummary(params) {
|
|
5103
5092
|
);
|
5104
5093
|
}
|
5105
5094
|
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
|
5106
|
-
(0,
|
5095
|
+
(0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5107
5096
|
0
|
5108
5097
|
);
|
5109
5098
|
let txReceipts = [];
|
@@ -5123,10 +5112,10 @@ async function getTransactionSummary(params) {
|
|
5123
5112
|
id: gqlTransaction.id,
|
5124
5113
|
receipts,
|
5125
5114
|
transaction: decodedTransaction,
|
5126
|
-
transactionBytes: (0,
|
5115
|
+
transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5127
5116
|
gqlTransactionStatus: gqlTransaction.status,
|
5128
|
-
gasPerByte: (0,
|
5129
|
-
gasPriceFactor: (0,
|
5117
|
+
gasPerByte: (0, import_math18.bn)(gasPerByte),
|
5118
|
+
gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
|
5130
5119
|
abiMap,
|
5131
5120
|
maxInputs,
|
5132
5121
|
gasCosts,
|
@@ -5175,7 +5164,7 @@ async function getTransactionsSummaries(params) {
|
|
5175
5164
|
const transactions = edges.map((edge) => {
|
5176
5165
|
const { node: gqlTransaction } = edge;
|
5177
5166
|
const { id, rawPayload, status } = gqlTransaction;
|
5178
|
-
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0,
|
5167
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
|
5179
5168
|
let txReceipts = [];
|
5180
5169
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5181
5170
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5185,7 +5174,7 @@ async function getTransactionsSummaries(params) {
|
|
5185
5174
|
id,
|
5186
5175
|
receipts,
|
5187
5176
|
transaction: decodedTransaction,
|
5188
|
-
transactionBytes: (0,
|
5177
|
+
transactionBytes: (0, import_utils25.arrayify)(rawPayload),
|
5189
5178
|
gqlTransactionStatus: status,
|
5190
5179
|
abiMap,
|
5191
5180
|
gasPerByte,
|
@@ -5334,17 +5323,17 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
5334
5323
|
|
5335
5324
|
// src/utils/formatTransferToContractScriptData.ts
|
5336
5325
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5337
|
-
var
|
5338
|
-
var
|
5326
|
+
var import_math19 = require("@fuel-ts/math");
|
5327
|
+
var import_utils27 = require("@fuel-ts/utils");
|
5339
5328
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5340
5329
|
var formatTransferToContractScriptData = (params) => {
|
5341
5330
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5342
5331
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
5343
|
-
const encoded = numberCoder.encode(new
|
5332
|
+
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
5344
5333
|
const scriptData = Uint8Array.from([
|
5345
|
-
...(0,
|
5334
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
5346
5335
|
...encoded,
|
5347
|
-
...(0,
|
5336
|
+
...(0, import_utils27.arrayify)(assetId)
|
5348
5337
|
]);
|
5349
5338
|
return scriptData;
|
5350
5339
|
};
|
@@ -5535,9 +5524,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5535
5524
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5536
5525
|
const fee = request.maxFee;
|
5537
5526
|
const baseAssetId = this.provider.getBaseAssetId();
|
5538
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0,
|
5527
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
|
5539
5528
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5540
|
-
amount: (0,
|
5529
|
+
amount: (0, import_math20.bn)(fee),
|
5541
5530
|
assetId: baseAssetId,
|
5542
5531
|
coinQuantities: requiredQuantities
|
5543
5532
|
});
|
@@ -5545,7 +5534,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5545
5534
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5546
5535
|
quantitiesDict[assetId] = {
|
5547
5536
|
required: amount,
|
5548
|
-
owned: (0,
|
5537
|
+
owned: (0, import_math20.bn)(0)
|
5549
5538
|
};
|
5550
5539
|
});
|
5551
5540
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5572,7 +5561,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5572
5561
|
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5573
5562
|
);
|
5574
5563
|
request.addResources(resources);
|
5575
|
-
request.shiftPredicateData();
|
5576
5564
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5577
5565
|
const requestToReestimate2 = (0, import_ramda4.clone)(request);
|
5578
5566
|
if (addedSignatures) {
|
@@ -5604,7 +5592,6 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5604
5592
|
}
|
5605
5593
|
fundingAttempts += 1;
|
5606
5594
|
}
|
5607
|
-
request.shiftPredicateData();
|
5608
5595
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5609
5596
|
const requestToReestimate = (0, import_ramda4.clone)(request);
|
5610
5597
|
if (addedSignatures) {
|
@@ -5655,7 +5642,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5655
5642
|
* @returns A promise that resolves to the transaction response.
|
5656
5643
|
*/
|
5657
5644
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5658
|
-
if ((0,
|
5645
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5659
5646
|
throw new import_errors16.FuelError(
|
5660
5647
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5661
5648
|
"Transfer amount must be a positive number."
|
@@ -5675,7 +5662,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5675
5662
|
* @returns A promise that resolves to the transaction response.
|
5676
5663
|
*/
|
5677
5664
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5678
|
-
if ((0,
|
5665
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5679
5666
|
throw new import_errors16.FuelError(
|
5680
5667
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5681
5668
|
"Transfer amount must be a positive number."
|
@@ -5685,7 +5672,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5685
5672
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5686
5673
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5687
5674
|
hexlifiedContractId: contractAddress.toB256(),
|
5688
|
-
amountToTransfer: (0,
|
5675
|
+
amountToTransfer: (0, import_math20.bn)(amount),
|
5689
5676
|
assetId: assetIdToTransfer
|
5690
5677
|
});
|
5691
5678
|
let request = new ScriptTransactionRequest({
|
@@ -5696,7 +5683,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5696
5683
|
request.addContractInputAndOutput(contractAddress);
|
5697
5684
|
const txCost = await this.provider.getTransactionCost(request, {
|
5698
5685
|
resourcesOwner: this,
|
5699
|
-
quantitiesToContract: [{ amount: (0,
|
5686
|
+
quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5700
5687
|
});
|
5701
5688
|
request = this.validateGasLimitAndMaxFee({
|
5702
5689
|
transactionRequest: request,
|
@@ -5717,21 +5704,21 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5717
5704
|
*/
|
5718
5705
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5719
5706
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5720
|
-
const recipientDataArray = (0,
|
5707
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5721
5708
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5722
5709
|
);
|
5723
|
-
const amountDataArray = (0,
|
5724
|
-
"0x".concat((0,
|
5710
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5711
|
+
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5725
5712
|
);
|
5726
5713
|
const script = new Uint8Array([
|
5727
|
-
...(0,
|
5714
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5728
5715
|
...recipientDataArray,
|
5729
5716
|
...amountDataArray
|
5730
5717
|
]);
|
5731
5718
|
const params = { script, ...txParams };
|
5732
5719
|
const baseAssetId = this.provider.getBaseAssetId();
|
5733
5720
|
let request = new ScriptTransactionRequest(params);
|
5734
|
-
const quantitiesToContract = [{ amount: (0,
|
5721
|
+
const quantitiesToContract = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
|
5735
5722
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5736
5723
|
request = this.validateGasLimitAndMaxFee({
|
5737
5724
|
transactionRequest: request,
|
@@ -5804,7 +5791,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5804
5791
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5805
5792
|
}) {
|
5806
5793
|
const request = transactionRequestify(transactionRequest);
|
5807
|
-
if (!(0,
|
5794
|
+
if (!(0, import_utils28.isDefined)(setGasLimit)) {
|
5808
5795
|
request.gasLimit = gasUsed;
|
5809
5796
|
} else if (gasUsed.gt(setGasLimit)) {
|
5810
5797
|
throw new import_errors16.FuelError(
|
@@ -5812,7 +5799,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5812
5799
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5813
5800
|
);
|
5814
5801
|
}
|
5815
|
-
if (!(0,
|
5802
|
+
if (!(0, import_utils28.isDefined)(setMaxFee)) {
|
5816
5803
|
request.maxFee = maxFee;
|
5817
5804
|
} else if (maxFee.gt(setMaxFee)) {
|
5818
5805
|
throw new import_errors16.FuelError(
|
@@ -5826,14 +5813,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5826
5813
|
|
5827
5814
|
// src/wallet/base-wallet-unlocked.ts
|
5828
5815
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5829
|
-
var
|
5816
|
+
var import_utils31 = require("@fuel-ts/utils");
|
5830
5817
|
|
5831
5818
|
// src/signer/signer.ts
|
5832
5819
|
var import_address5 = require("@fuel-ts/address");
|
5833
5820
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5834
5821
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5835
|
-
var
|
5836
|
-
var
|
5822
|
+
var import_math21 = require("@fuel-ts/math");
|
5823
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5837
5824
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5838
5825
|
var Signer = class {
|
5839
5826
|
address;
|
@@ -5852,10 +5839,10 @@ var Signer = class {
|
|
5852
5839
|
privateKey = `0x${privateKey}`;
|
5853
5840
|
}
|
5854
5841
|
}
|
5855
|
-
const privateKeyBytes = (0,
|
5856
|
-
this.privateKey = (0,
|
5857
|
-
this.publicKey = (0,
|
5858
|
-
this.compressedPublicKey = (0,
|
5842
|
+
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
5843
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5844
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5845
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5859
5846
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5860
5847
|
}
|
5861
5848
|
/**
|
@@ -5869,11 +5856,11 @@ var Signer = class {
|
|
5869
5856
|
* @returns hashed signature
|
5870
5857
|
*/
|
5871
5858
|
sign(data) {
|
5872
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5873
|
-
const r = (0,
|
5874
|
-
const s = (0,
|
5859
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5860
|
+
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5861
|
+
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5875
5862
|
s[0] |= (signature.recovery || 0) << 7;
|
5876
|
-
return (0,
|
5863
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5877
5864
|
}
|
5878
5865
|
/**
|
5879
5866
|
* Add point on the current elliptic curve
|
@@ -5882,8 +5869,8 @@ var Signer = class {
|
|
5882
5869
|
* @returns compressed point on the curve
|
5883
5870
|
*/
|
5884
5871
|
addPoint(point) {
|
5885
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5886
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5872
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5873
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5887
5874
|
const result = p0.add(p1);
|
5888
5875
|
return `0x${result.toHex(true)}`;
|
5889
5876
|
}
|
@@ -5895,16 +5882,16 @@ var Signer = class {
|
|
5895
5882
|
* @returns public key from signature from the
|
5896
5883
|
*/
|
5897
5884
|
static recoverPublicKey(data, signature) {
|
5898
|
-
const signedMessageBytes = (0,
|
5885
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5899
5886
|
const r = signedMessageBytes.slice(0, 32);
|
5900
5887
|
const s = signedMessageBytes.slice(32, 64);
|
5901
5888
|
const recoveryParam = (s[0] & 128) >> 7;
|
5902
5889
|
s[0] &= 127;
|
5903
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5890
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5904
5891
|
recoveryParam
|
5905
5892
|
);
|
5906
|
-
const publicKey = sig.recoverPublicKey((0,
|
5907
|
-
return (0,
|
5893
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5894
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5908
5895
|
}
|
5909
5896
|
/**
|
5910
5897
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5923,7 +5910,7 @@ var Signer = class {
|
|
5923
5910
|
* @returns random 32-byte hashed
|
5924
5911
|
*/
|
5925
5912
|
static generatePrivateKey(entropy) {
|
5926
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5913
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
|
5927
5914
|
}
|
5928
5915
|
/**
|
5929
5916
|
* Extended publicKey from a compact publicKey
|
@@ -5932,8 +5919,8 @@ var Signer = class {
|
|
5932
5919
|
* @returns extended publicKey
|
5933
5920
|
*/
|
5934
5921
|
static extendPublicKey(publicKey) {
|
5935
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5936
|
-
return (0,
|
5922
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5923
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5937
5924
|
}
|
5938
5925
|
};
|
5939
5926
|
|
@@ -5941,7 +5928,7 @@ var Signer = class {
|
|
5941
5928
|
var import_address6 = require("@fuel-ts/address");
|
5942
5929
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5943
5930
|
var import_errors17 = require("@fuel-ts/errors");
|
5944
|
-
var
|
5931
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5945
5932
|
var import_uuid = require("uuid");
|
5946
5933
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5947
5934
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -6024,7 +6011,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6024
6011
|
);
|
6025
6012
|
}
|
6026
6013
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
6027
|
-
const privateKey = (0,
|
6014
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
6028
6015
|
return privateKey;
|
6029
6016
|
}
|
6030
6017
|
|
@@ -6069,7 +6056,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6069
6056
|
*/
|
6070
6057
|
async signMessage(message) {
|
6071
6058
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
6072
|
-
return (0,
|
6059
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
6073
6060
|
}
|
6074
6061
|
/**
|
6075
6062
|
* Signs a transaction with the wallet's private key.
|
@@ -6082,7 +6069,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6082
6069
|
const chainId = this.provider.getChainId();
|
6083
6070
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6084
6071
|
const signature = await this.signer().sign(hashedTransaction);
|
6085
|
-
return (0,
|
6072
|
+
return (0, import_utils31.hexlify)(signature);
|
6086
6073
|
}
|
6087
6074
|
/**
|
6088
6075
|
* Populates a transaction with the witnesses signature.
|
@@ -6144,14 +6131,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6144
6131
|
var import_crypto5 = require("@fuel-ts/crypto");
|
6145
6132
|
var import_errors20 = require("@fuel-ts/errors");
|
6146
6133
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6147
|
-
var
|
6148
|
-
var
|
6134
|
+
var import_math22 = require("@fuel-ts/math");
|
6135
|
+
var import_utils35 = require("@fuel-ts/utils");
|
6149
6136
|
|
6150
6137
|
// src/mnemonic/mnemonic.ts
|
6151
6138
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6152
6139
|
var import_errors19 = require("@fuel-ts/errors");
|
6153
6140
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6154
|
-
var
|
6141
|
+
var import_utils33 = require("@fuel-ts/utils");
|
6155
6142
|
|
6156
6143
|
// src/wordlists/words/english.ts
|
6157
6144
|
var english = [
|
@@ -8214,7 +8201,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8214
8201
|
// src/mnemonic/utils.ts
|
8215
8202
|
var import_errors18 = require("@fuel-ts/errors");
|
8216
8203
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8217
|
-
var
|
8204
|
+
var import_utils32 = require("@fuel-ts/utils");
|
8218
8205
|
function toUtf8Bytes(stri) {
|
8219
8206
|
const str = stri.normalize("NFKD");
|
8220
8207
|
const result = [];
|
@@ -8281,14 +8268,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
8281
8268
|
}
|
8282
8269
|
}
|
8283
8270
|
const checksumBits = entropy.length / 4;
|
8284
|
-
const checksum = (0,
|
8271
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8285
8272
|
indices[indices.length - 1] <<= checksumBits;
|
8286
8273
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8287
8274
|
return indices;
|
8288
8275
|
}
|
8289
8276
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8290
8277
|
const size = Math.ceil(11 * words.length / 8);
|
8291
|
-
const entropy = (0,
|
8278
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
8292
8279
|
let offset = 0;
|
8293
8280
|
for (let i = 0; i < words.length; i += 1) {
|
8294
8281
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -8308,7 +8295,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8308
8295
|
const entropyBits = 32 * words.length / 3;
|
8309
8296
|
const checksumBits = words.length / 3;
|
8310
8297
|
const checksumMask = getUpperMask(checksumBits);
|
8311
|
-
const checksum = (0,
|
8298
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8312
8299
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8313
8300
|
throw new import_errors18.FuelError(
|
8314
8301
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -8383,7 +8370,7 @@ var Mnemonic = class {
|
|
8383
8370
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8384
8371
|
const words = getWords(phrase);
|
8385
8372
|
assertMnemonic(words);
|
8386
|
-
return (0,
|
8373
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8387
8374
|
}
|
8388
8375
|
/**
|
8389
8376
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8391,7 +8378,7 @@ var Mnemonic = class {
|
|
8391
8378
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8392
8379
|
*/
|
8393
8380
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8394
|
-
const entropyBytes = (0,
|
8381
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
8395
8382
|
assertWordList(wordlist);
|
8396
8383
|
assertEntropy(entropyBytes);
|
8397
8384
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8460,14 +8447,14 @@ var Mnemonic = class {
|
|
8460
8447
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8461
8448
|
*/
|
8462
8449
|
static masterKeysFromSeed(seed) {
|
8463
|
-
const seedArray = (0,
|
8450
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
8464
8451
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8465
8452
|
throw new import_errors19.FuelError(
|
8466
8453
|
import_errors19.ErrorCode.INVALID_SEED,
|
8467
8454
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8468
8455
|
);
|
8469
8456
|
}
|
8470
|
-
return (0,
|
8457
|
+
return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
|
8471
8458
|
}
|
8472
8459
|
/**
|
8473
8460
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8478,22 +8465,22 @@ var Mnemonic = class {
|
|
8478
8465
|
*/
|
8479
8466
|
static seedToExtendedKey(seed, testnet = false) {
|
8480
8467
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8481
|
-
const prefix = (0,
|
8468
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8482
8469
|
const depth = "0x00";
|
8483
8470
|
const fingerprint = "0x00000000";
|
8484
8471
|
const index = "0x00000000";
|
8485
8472
|
const chainCode = masterKey.slice(32);
|
8486
8473
|
const privateKey = masterKey.slice(0, 32);
|
8487
|
-
const extendedKey = (0,
|
8474
|
+
const extendedKey = (0, import_utils33.concat)([
|
8488
8475
|
prefix,
|
8489
8476
|
depth,
|
8490
8477
|
fingerprint,
|
8491
8478
|
index,
|
8492
8479
|
chainCode,
|
8493
|
-
(0,
|
8480
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
8494
8481
|
]);
|
8495
|
-
const checksum = (0,
|
8496
|
-
return (0,
|
8482
|
+
const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8483
|
+
return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
8497
8484
|
}
|
8498
8485
|
/**
|
8499
8486
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8508,7 +8495,7 @@ var Mnemonic = class {
|
|
8508
8495
|
* @returns A randomly generated mnemonic
|
8509
8496
|
*/
|
8510
8497
|
static generate(size = 32, extraEntropy = "") {
|
8511
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8498
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
|
8512
8499
|
return Mnemonic.entropyToMnemonic(entropy);
|
8513
8500
|
}
|
8514
8501
|
};
|
@@ -8516,12 +8503,12 @@ var mnemonic_default = Mnemonic;
|
|
8516
8503
|
|
8517
8504
|
// src/hdwallet/hdwallet.ts
|
8518
8505
|
var HARDENED_INDEX = 2147483648;
|
8519
|
-
var MainnetPRV2 = (0,
|
8520
|
-
var MainnetPUB = (0,
|
8521
|
-
var TestnetPRV2 = (0,
|
8522
|
-
var TestnetPUB = (0,
|
8506
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
8507
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
8508
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8509
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
8523
8510
|
function base58check(data) {
|
8524
|
-
return (0,
|
8511
|
+
return (0, import_utils35.encodeBase58)((0, import_utils35.concat)([data, (0, import_utils35.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
8525
8512
|
}
|
8526
8513
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8527
8514
|
if (isPublic) {
|
@@ -8530,11 +8517,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8530
8517
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8531
8518
|
}
|
8532
8519
|
function isPublicExtendedKey(extendedKey) {
|
8533
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8520
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
8534
8521
|
}
|
8535
8522
|
function isValidExtendedKey(extendedKey) {
|
8536
8523
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8537
|
-
(0,
|
8524
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
8538
8525
|
);
|
8539
8526
|
}
|
8540
8527
|
function parsePath(path, depth = 0) {
|
@@ -8552,8 +8539,8 @@ function parsePath(path, depth = 0) {
|
|
8552
8539
|
var HDWallet = class {
|
8553
8540
|
depth = 0;
|
8554
8541
|
index = 0;
|
8555
|
-
fingerprint = (0,
|
8556
|
-
parentFingerprint = (0,
|
8542
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8543
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8557
8544
|
privateKey;
|
8558
8545
|
publicKey;
|
8559
8546
|
chainCode;
|
@@ -8565,8 +8552,8 @@ var HDWallet = class {
|
|
8565
8552
|
constructor(config) {
|
8566
8553
|
if (config.privateKey) {
|
8567
8554
|
const signer = new Signer(config.privateKey);
|
8568
|
-
this.publicKey = (0,
|
8569
|
-
this.privateKey = (0,
|
8555
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
8556
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
8570
8557
|
} else {
|
8571
8558
|
if (!config.publicKey) {
|
8572
8559
|
throw new import_errors20.FuelError(
|
@@ -8574,10 +8561,10 @@ var HDWallet = class {
|
|
8574
8561
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8575
8562
|
);
|
8576
8563
|
}
|
8577
|
-
this.publicKey = (0,
|
8564
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8578
8565
|
}
|
8579
8566
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8580
|
-
this.fingerprint = (0,
|
8567
|
+
this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8581
8568
|
this.depth = config.depth || this.depth;
|
8582
8569
|
this.index = config.index || this.index;
|
8583
8570
|
this.chainCode = config.chainCode;
|
@@ -8593,9 +8580,9 @@ var HDWallet = class {
|
|
8593
8580
|
* @returns A new instance of HDWallet on the derived index
|
8594
8581
|
*/
|
8595
8582
|
deriveIndex(index) {
|
8596
|
-
const privateKey = this.privateKey && (0,
|
8597
|
-
const publicKey = (0,
|
8598
|
-
const chainCode = (0,
|
8583
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
8584
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
8585
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
8599
8586
|
const data = new Uint8Array(37);
|
8600
8587
|
if (index & HARDENED_INDEX) {
|
8601
8588
|
if (!privateKey) {
|
@@ -8606,15 +8593,15 @@ var HDWallet = class {
|
|
8606
8593
|
}
|
8607
8594
|
data.set(privateKey, 1);
|
8608
8595
|
} else {
|
8609
|
-
data.set((0,
|
8596
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8610
8597
|
}
|
8611
|
-
data.set((0,
|
8612
|
-
const bytes = (0,
|
8598
|
+
data.set((0, import_math22.toBytes)(index, 4), 33);
|
8599
|
+
const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8613
8600
|
const IL = bytes.slice(0, 32);
|
8614
8601
|
const IR = bytes.slice(32);
|
8615
8602
|
if (privateKey) {
|
8616
8603
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8617
|
-
const ki = (0,
|
8604
|
+
const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
8618
8605
|
return new HDWallet({
|
8619
8606
|
privateKey: ki,
|
8620
8607
|
chainCode: IR,
|
@@ -8623,7 +8610,7 @@ var HDWallet = class {
|
|
8623
8610
|
parentFingerprint: this.fingerprint
|
8624
8611
|
});
|
8625
8612
|
}
|
8626
|
-
const signer = new Signer((0,
|
8613
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
8627
8614
|
const Ki = signer.addPoint(publicKey);
|
8628
8615
|
return new HDWallet({
|
8629
8616
|
publicKey: Ki,
|
@@ -8658,12 +8645,12 @@ var HDWallet = class {
|
|
8658
8645
|
);
|
8659
8646
|
}
|
8660
8647
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8661
|
-
const depth = (0,
|
8648
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8662
8649
|
const parentFingerprint = this.parentFingerprint;
|
8663
|
-
const index = (0,
|
8650
|
+
const index = (0, import_math22.toHex)(this.index, 4);
|
8664
8651
|
const chainCode = this.chainCode;
|
8665
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8666
|
-
const extendedKey = (0,
|
8652
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8653
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8667
8654
|
return base58check(extendedKey);
|
8668
8655
|
}
|
8669
8656
|
/**
|
@@ -8675,13 +8662,13 @@ var HDWallet = class {
|
|
8675
8662
|
static fromSeed(seed) {
|
8676
8663
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8677
8664
|
return new HDWallet({
|
8678
|
-
chainCode: (0,
|
8679
|
-
privateKey: (0,
|
8665
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8666
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8680
8667
|
});
|
8681
8668
|
}
|
8682
8669
|
static fromExtendedKey(extendedKey) {
|
8683
|
-
const decoded = (0,
|
8684
|
-
const bytes = (0,
|
8670
|
+
const decoded = (0, import_utils35.hexlify)((0, import_math22.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
|
8671
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8685
8672
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8686
8673
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8687
8674
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8690,9 +8677,9 @@ var HDWallet = class {
|
|
8690
8677
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8691
8678
|
}
|
8692
8679
|
const depth = bytes[4];
|
8693
|
-
const parentFingerprint = (0,
|
8694
|
-
const index = parseInt((0,
|
8695
|
-
const chainCode = (0,
|
8680
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8681
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8682
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8696
8683
|
const key = bytes.slice(45, 78);
|
8697
8684
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8698
8685
|
throw new import_errors20.FuelError(
|
@@ -9296,19 +9283,18 @@ var StorageAbstract = class {
|
|
9296
9283
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
9297
9284
|
var import_address10 = require("@fuel-ts/address");
|
9298
9285
|
var import_errors25 = require("@fuel-ts/errors");
|
9299
|
-
var
|
9300
|
-
var import_utils38 = require("@fuel-ts/utils");
|
9286
|
+
var import_utils37 = require("@fuel-ts/utils");
|
9301
9287
|
|
9302
9288
|
// src/predicate/utils/getPredicateRoot.ts
|
9303
9289
|
var import_hasher7 = require("@fuel-ts/hasher");
|
9304
9290
|
var import_merkle = require("@fuel-ts/merkle");
|
9305
|
-
var
|
9291
|
+
var import_utils36 = require("@fuel-ts/utils");
|
9306
9292
|
var getPredicateRoot = (bytecode) => {
|
9307
9293
|
const chunkSize = 16 * 1024;
|
9308
|
-
const bytes = (0,
|
9309
|
-
const chunks = (0,
|
9310
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
9311
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
9294
|
+
const bytes = (0, import_utils36.arrayify)(bytecode);
|
9295
|
+
const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
|
9296
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
|
9297
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
|
9312
9298
|
return predicateRoot;
|
9313
9299
|
};
|
9314
9300
|
|
@@ -9354,15 +9340,14 @@ var Predicate = class extends Account {
|
|
9354
9340
|
*/
|
9355
9341
|
populateTransactionPredicateData(transactionRequestLike) {
|
9356
9342
|
const request = transactionRequestify(transactionRequestLike);
|
9357
|
-
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9358
9343
|
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
9359
9344
|
if (placeholderIndex !== -1) {
|
9360
9345
|
request.removeWitness(placeholderIndex);
|
9361
9346
|
}
|
9362
9347
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9363
9348
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9364
|
-
input.predicate = (0,
|
9365
|
-
input.predicateData = (0,
|
9349
|
+
input.predicate = (0, import_utils37.hexlify)(this.bytes);
|
9350
|
+
input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData());
|
9366
9351
|
input.witnessIndex = 0;
|
9367
9352
|
}
|
9368
9353
|
});
|
@@ -9388,17 +9373,12 @@ var Predicate = class extends Account {
|
|
9388
9373
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9389
9374
|
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
9390
9375
|
}
|
9391
|
-
getPredicateData(
|
9376
|
+
getPredicateData() {
|
9392
9377
|
if (!this.predicateData.length) {
|
9393
9378
|
return new Uint8Array();
|
9394
9379
|
}
|
9395
9380
|
const mainFn = this.interface?.functions.main;
|
9396
|
-
|
9397
|
-
const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
|
9398
|
-
maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
|
9399
|
-
});
|
9400
|
-
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;
|
9401
|
-
return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
|
9381
|
+
return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
|
9402
9382
|
}
|
9403
9383
|
/**
|
9404
9384
|
* Processes the predicate data and returns the altered bytecode and interface.
|
@@ -9409,7 +9389,7 @@ var Predicate = class extends Account {
|
|
9409
9389
|
* @returns An object containing the new predicate bytes and interface.
|
9410
9390
|
*/
|
9411
9391
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9412
|
-
let predicateBytes = (0,
|
9392
|
+
let predicateBytes = (0, import_utils37.arrayify)(bytes);
|
9413
9393
|
let abiInterface;
|
9414
9394
|
if (jsonAbi) {
|
9415
9395
|
abiInterface = new import_abi_coder7.Interface(jsonAbi);
|
@@ -9447,8 +9427,7 @@ var Predicate = class extends Account {
|
|
9447
9427
|
);
|
9448
9428
|
return resources.map((resource) => ({
|
9449
9429
|
...resource,
|
9450
|
-
predicate: (0,
|
9451
|
-
padPredicateData: (policiesLength) => (0, import_utils38.hexlify)(this.getPredicateData(policiesLength))
|
9430
|
+
predicate: (0, import_utils37.hexlify)(this.bytes)
|
9452
9431
|
}));
|
9453
9432
|
}
|
9454
9433
|
/**
|
@@ -10313,6 +10292,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10313
10292
|
resolveGasDependentCosts,
|
10314
10293
|
resolveIconPaths,
|
10315
10294
|
returnZeroScript,
|
10295
|
+
sleep,
|
10316
10296
|
transactionRequestify,
|
10317
10297
|
urlJoin,
|
10318
10298
|
withTimeout,
|