@fuel-ts/account 0.0.0-rc-2238-20240514192918 → 0.0.0-rc-2143-20240514195947
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 +1146 -412
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +146 -116
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +144 -108
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +1 -0
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +1 -0
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +2 -0
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +1 -0
- 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/test-utils/launchNode.d.ts +4 -2
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +8731 -5778
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +134 -111
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +125 -102
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/dist/test-utils.mjs
CHANGED
@@ -26,7 +26,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
|
|
26
26
|
import { Address as Address3 } from "@fuel-ts/address";
|
27
27
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
28
28
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
29
|
-
import { bn as
|
29
|
+
import { bn as bn20 } from "@fuel-ts/math";
|
30
30
|
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
31
31
|
import { clone as clone4 } from "ramda";
|
32
32
|
|
@@ -68,7 +68,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
68
68
|
// src/providers/provider.ts
|
69
69
|
import { Address as Address2 } from "@fuel-ts/address";
|
70
70
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
71
|
-
import { BN, bn as
|
71
|
+
import { BN, bn as bn18 } from "@fuel-ts/math";
|
72
72
|
import {
|
73
73
|
InputType as InputType7,
|
74
74
|
TransactionType as TransactionType8,
|
@@ -2282,6 +2282,15 @@ var BaseTransactionRequest = class {
|
|
2282
2282
|
}
|
2283
2283
|
});
|
2284
2284
|
}
|
2285
|
+
shiftPredicateData() {
|
2286
|
+
this.inputs.forEach((input) => {
|
2287
|
+
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2288
|
+
input.predicateData = input.padPredicateData(
|
2289
|
+
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2290
|
+
);
|
2291
|
+
}
|
2292
|
+
});
|
2293
|
+
}
|
2285
2294
|
};
|
2286
2295
|
|
2287
2296
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2704,12 +2713,12 @@ var transactionRequestify = (obj) => {
|
|
2704
2713
|
|
2705
2714
|
// src/providers/transaction-response/transaction-response.ts
|
2706
2715
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2707
|
-
import { bn as
|
2716
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
2708
2717
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2709
2718
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2710
2719
|
|
2711
2720
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2712
|
-
import { bn as
|
2721
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
2713
2722
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2714
2723
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2715
2724
|
|
@@ -2786,32 +2795,43 @@ var calculateTXFeeForSummary = (params) => {
|
|
2786
2795
|
// src/providers/transaction-summary/operations.ts
|
2787
2796
|
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
2788
2797
|
import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
|
2789
|
-
import { bn as
|
2798
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2790
2799
|
import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2791
2800
|
|
2792
2801
|
// src/providers/transaction-summary/call.ts
|
2793
|
-
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
2794
|
-
|
2802
|
+
import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
|
2803
|
+
import { bn as bn13 } from "@fuel-ts/math";
|
2804
|
+
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2795
2805
|
const abiInterface = new Interface2(abi);
|
2796
2806
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2797
2807
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2798
2808
|
const inputs = functionFragment.jsonFn.inputs;
|
2799
|
-
|
2809
|
+
let encodedArgs;
|
2810
|
+
if (functionFragment.isInputDataPointer) {
|
2811
|
+
if (rawPayload) {
|
2812
|
+
const argsOffset = bn13(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2813
|
+
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2814
|
+
}
|
2815
|
+
} else {
|
2816
|
+
encodedArgs = receipt.param2.toHex();
|
2817
|
+
}
|
2800
2818
|
let argumentsProvided;
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2819
|
+
if (encodedArgs) {
|
2820
|
+
const data = functionFragment.decodeArguments(encodedArgs);
|
2821
|
+
if (data) {
|
2822
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
2823
|
+
const value = data[index];
|
2824
|
+
const name = input.name;
|
2825
|
+
if (name) {
|
2826
|
+
return {
|
2827
|
+
...prev,
|
2828
|
+
// reparse to remove bn
|
2829
|
+
[name]: JSON.parse(JSON.stringify(value))
|
2830
|
+
};
|
2831
|
+
}
|
2832
|
+
return prev;
|
2833
|
+
}, {});
|
2834
|
+
}
|
2815
2835
|
}
|
2816
2836
|
const call = {
|
2817
2837
|
functionSignature: functionFragment.signature,
|
@@ -2951,7 +2971,7 @@ var mergeAssets = (op1, op2) => {
|
|
2951
2971
|
if (!matchingAsset) {
|
2952
2972
|
return asset1;
|
2953
2973
|
}
|
2954
|
-
const mergedAmount =
|
2974
|
+
const mergedAmount = bn14(asset1.amount).add(matchingAsset.amount);
|
2955
2975
|
return { ...asset1, amount: mergedAmount };
|
2956
2976
|
});
|
2957
2977
|
return mergedAssets.concat(filteredAssets);
|
@@ -3274,7 +3294,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3274
3294
|
|
3275
3295
|
// src/providers/transaction-summary/status.ts
|
3276
3296
|
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3277
|
-
import { bn as
|
3297
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
3278
3298
|
var getTransactionStatusName = (gqlStatus) => {
|
3279
3299
|
switch (gqlStatus) {
|
3280
3300
|
case "FailureStatus":
|
@@ -3308,15 +3328,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3308
3328
|
time = gqlTransactionStatus.time;
|
3309
3329
|
blockId = gqlTransactionStatus.block.id;
|
3310
3330
|
isStatusSuccess = true;
|
3311
|
-
totalFee =
|
3312
|
-
totalGas =
|
3331
|
+
totalFee = bn15(gqlTransactionStatus.totalFee);
|
3332
|
+
totalGas = bn15(gqlTransactionStatus.totalGas);
|
3313
3333
|
break;
|
3314
3334
|
case "FailureStatus":
|
3315
3335
|
time = gqlTransactionStatus.time;
|
3316
3336
|
blockId = gqlTransactionStatus.block.id;
|
3317
3337
|
isStatusFailure = true;
|
3318
|
-
totalFee =
|
3319
|
-
totalGas =
|
3338
|
+
totalFee = bn15(gqlTransactionStatus.totalFee);
|
3339
|
+
totalGas = bn15(gqlTransactionStatus.totalGas);
|
3320
3340
|
break;
|
3321
3341
|
case "SubmittedStatus":
|
3322
3342
|
time = gqlTransactionStatus.time;
|
@@ -3366,7 +3386,7 @@ function assembleTransactionSummary(params) {
|
|
3366
3386
|
maxInputs
|
3367
3387
|
});
|
3368
3388
|
const typeName = getTransactionTypeName(transaction.type);
|
3369
|
-
const tip =
|
3389
|
+
const tip = bn16(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3370
3390
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3371
3391
|
const fee = calculateTXFeeForSummary({
|
3372
3392
|
totalFee,
|
@@ -3437,7 +3457,7 @@ var TransactionResponse = class {
|
|
3437
3457
|
/** Current provider */
|
3438
3458
|
provider;
|
3439
3459
|
/** Gas used on the transaction */
|
3440
|
-
gasUsed =
|
3460
|
+
gasUsed = bn17(0);
|
3441
3461
|
/** The graphql Transaction with receipts object. */
|
3442
3462
|
gqlTransaction;
|
3443
3463
|
abis;
|
@@ -3671,47 +3691,47 @@ var processGqlChain = (chain) => {
|
|
3671
3691
|
} = consensusParameters;
|
3672
3692
|
return {
|
3673
3693
|
name,
|
3674
|
-
baseChainHeight:
|
3694
|
+
baseChainHeight: bn18(daHeight),
|
3675
3695
|
consensusParameters: {
|
3676
3696
|
version,
|
3677
|
-
chainId:
|
3697
|
+
chainId: bn18(chainId),
|
3678
3698
|
baseAssetId,
|
3679
3699
|
feeParameters: {
|
3680
3700
|
version: feeParams.version,
|
3681
|
-
gasPerByte:
|
3682
|
-
gasPriceFactor:
|
3701
|
+
gasPerByte: bn18(feeParams.gasPerByte),
|
3702
|
+
gasPriceFactor: bn18(feeParams.gasPriceFactor)
|
3683
3703
|
},
|
3684
3704
|
contractParameters: {
|
3685
3705
|
version: contractParams.version,
|
3686
|
-
contractMaxSize:
|
3687
|
-
maxStorageSlots:
|
3706
|
+
contractMaxSize: bn18(contractParams.contractMaxSize),
|
3707
|
+
maxStorageSlots: bn18(contractParams.maxStorageSlots)
|
3688
3708
|
},
|
3689
3709
|
txParameters: {
|
3690
3710
|
version: txParams.version,
|
3691
|
-
maxInputs:
|
3692
|
-
maxOutputs:
|
3693
|
-
maxWitnesses:
|
3694
|
-
maxGasPerTx:
|
3695
|
-
maxSize:
|
3696
|
-
maxBytecodeSubsections:
|
3711
|
+
maxInputs: bn18(txParams.maxInputs),
|
3712
|
+
maxOutputs: bn18(txParams.maxOutputs),
|
3713
|
+
maxWitnesses: bn18(txParams.maxWitnesses),
|
3714
|
+
maxGasPerTx: bn18(txParams.maxGasPerTx),
|
3715
|
+
maxSize: bn18(txParams.maxSize),
|
3716
|
+
maxBytecodeSubsections: bn18(txParams.maxBytecodeSubsections)
|
3697
3717
|
},
|
3698
3718
|
predicateParameters: {
|
3699
3719
|
version: predicateParams.version,
|
3700
|
-
maxPredicateLength:
|
3701
|
-
maxPredicateDataLength:
|
3702
|
-
maxGasPerPredicate:
|
3703
|
-
maxMessageDataLength:
|
3720
|
+
maxPredicateLength: bn18(predicateParams.maxPredicateLength),
|
3721
|
+
maxPredicateDataLength: bn18(predicateParams.maxPredicateDataLength),
|
3722
|
+
maxGasPerPredicate: bn18(predicateParams.maxGasPerPredicate),
|
3723
|
+
maxMessageDataLength: bn18(predicateParams.maxMessageDataLength)
|
3704
3724
|
},
|
3705
3725
|
scriptParameters: {
|
3706
3726
|
version: scriptParams.version,
|
3707
|
-
maxScriptLength:
|
3708
|
-
maxScriptDataLength:
|
3727
|
+
maxScriptLength: bn18(scriptParams.maxScriptLength),
|
3728
|
+
maxScriptDataLength: bn18(scriptParams.maxScriptDataLength)
|
3709
3729
|
},
|
3710
3730
|
gasCosts
|
3711
3731
|
},
|
3712
3732
|
latestBlock: {
|
3713
3733
|
id: latestBlock.id,
|
3714
|
-
height:
|
3734
|
+
height: bn18(latestBlock.height),
|
3715
3735
|
time: latestBlock.header.time,
|
3716
3736
|
transactions: latestBlock.transactions.map((i) => ({
|
3717
3737
|
id: i.id
|
@@ -3907,7 +3927,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3907
3927
|
*/
|
3908
3928
|
async getBlockNumber() {
|
3909
3929
|
const { chain } = await this.operations.getChain();
|
3910
|
-
return
|
3930
|
+
return bn18(chain.latestBlock.height, 10);
|
3911
3931
|
}
|
3912
3932
|
/**
|
3913
3933
|
* Returns the chain information.
|
@@ -3917,8 +3937,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3917
3937
|
async fetchNode() {
|
3918
3938
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3919
3939
|
const processedNodeInfo = {
|
3920
|
-
maxDepth:
|
3921
|
-
maxTx:
|
3940
|
+
maxDepth: bn18(nodeInfo.maxDepth),
|
3941
|
+
maxTx: bn18(nodeInfo.maxTx),
|
3922
3942
|
nodeVersion: nodeInfo.nodeVersion,
|
3923
3943
|
utxoValidation: nodeInfo.utxoValidation,
|
3924
3944
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4050,7 +4070,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4050
4070
|
} = response;
|
4051
4071
|
if (inputs) {
|
4052
4072
|
inputs.forEach((input, index) => {
|
4053
|
-
if ("predicateGasUsed" in input &&
|
4073
|
+
if ("predicateGasUsed" in input && bn18(input.predicateGasUsed).gt(0)) {
|
4054
4074
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4055
4075
|
}
|
4056
4076
|
});
|
@@ -4208,12 +4228,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4208
4228
|
gasPrice = await this.estimateGasPrice(10);
|
4209
4229
|
}
|
4210
4230
|
const minFee = calculateGasFee({
|
4211
|
-
gasPrice:
|
4231
|
+
gasPrice: bn18(gasPrice),
|
4212
4232
|
gas: minGas,
|
4213
4233
|
priceFactor: gasPriceFactor,
|
4214
4234
|
tip: transactionRequest.tip
|
4215
4235
|
}).add(1);
|
4216
|
-
let gasLimit =
|
4236
|
+
let gasLimit = bn18(0);
|
4217
4237
|
if (transactionRequest.type === TransactionType8.Script) {
|
4218
4238
|
gasLimit = transactionRequest.gasLimit;
|
4219
4239
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4226,7 +4246,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4226
4246
|
}
|
4227
4247
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4228
4248
|
const maxFee = calculateGasFee({
|
4229
|
-
gasPrice:
|
4249
|
+
gasPrice: bn18(gasPrice),
|
4230
4250
|
gas: maxGas,
|
4231
4251
|
priceFactor: gasPriceFactor,
|
4232
4252
|
tip: transactionRequest.tip
|
@@ -4291,7 +4311,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4291
4311
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4292
4312
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4293
4313
|
if (isScriptTransaction) {
|
4294
|
-
txRequestClone.gasLimit =
|
4314
|
+
txRequestClone.gasLimit = bn18(0);
|
4295
4315
|
}
|
4296
4316
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4297
4317
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4312,7 +4332,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4312
4332
|
let dryRunStatus;
|
4313
4333
|
let missingContractIds = [];
|
4314
4334
|
let outputVariables = 0;
|
4315
|
-
let gasUsed =
|
4335
|
+
let gasUsed = bn18(0);
|
4316
4336
|
txRequestClone.maxFee = maxFee;
|
4317
4337
|
if (isScriptTransaction) {
|
4318
4338
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4377,10 +4397,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4377
4397
|
return coins.map((coin) => ({
|
4378
4398
|
id: coin.utxoId,
|
4379
4399
|
assetId: coin.assetId,
|
4380
|
-
amount:
|
4400
|
+
amount: bn18(coin.amount),
|
4381
4401
|
owner: Address2.fromAddressOrString(coin.owner),
|
4382
|
-
blockCreated:
|
4383
|
-
txCreatedIdx:
|
4402
|
+
blockCreated: bn18(coin.blockCreated),
|
4403
|
+
txCreatedIdx: bn18(coin.txCreatedIdx)
|
4384
4404
|
}));
|
4385
4405
|
}
|
4386
4406
|
/**
|
@@ -4417,9 +4437,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4417
4437
|
switch (coin.type) {
|
4418
4438
|
case "MessageCoin":
|
4419
4439
|
return {
|
4420
|
-
amount:
|
4440
|
+
amount: bn18(coin.amount),
|
4421
4441
|
assetId: coin.assetId,
|
4422
|
-
daHeight:
|
4442
|
+
daHeight: bn18(coin.daHeight),
|
4423
4443
|
sender: Address2.fromAddressOrString(coin.sender),
|
4424
4444
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4425
4445
|
nonce: coin.nonce
|
@@ -4427,11 +4447,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4427
4447
|
case "Coin":
|
4428
4448
|
return {
|
4429
4449
|
id: coin.utxoId,
|
4430
|
-
amount:
|
4450
|
+
amount: bn18(coin.amount),
|
4431
4451
|
assetId: coin.assetId,
|
4432
4452
|
owner: Address2.fromAddressOrString(coin.owner),
|
4433
|
-
blockCreated:
|
4434
|
-
txCreatedIdx:
|
4453
|
+
blockCreated: bn18(coin.blockCreated),
|
4454
|
+
txCreatedIdx: bn18(coin.txCreatedIdx)
|
4435
4455
|
};
|
4436
4456
|
default:
|
4437
4457
|
return null;
|
@@ -4448,13 +4468,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4448
4468
|
async getBlock(idOrHeight) {
|
4449
4469
|
let variables;
|
4450
4470
|
if (typeof idOrHeight === "number") {
|
4451
|
-
variables = { height:
|
4471
|
+
variables = { height: bn18(idOrHeight).toString(10) };
|
4452
4472
|
} else if (idOrHeight === "latest") {
|
4453
4473
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4454
4474
|
} else if (idOrHeight.length === 66) {
|
4455
4475
|
variables = { blockId: idOrHeight };
|
4456
4476
|
} else {
|
4457
|
-
variables = { blockId:
|
4477
|
+
variables = { blockId: bn18(idOrHeight).toString(10) };
|
4458
4478
|
}
|
4459
4479
|
const { block } = await this.operations.getBlock(variables);
|
4460
4480
|
if (!block) {
|
@@ -4462,7 +4482,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4462
4482
|
}
|
4463
4483
|
return {
|
4464
4484
|
id: block.id,
|
4465
|
-
height:
|
4485
|
+
height: bn18(block.height),
|
4466
4486
|
time: block.header.time,
|
4467
4487
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4468
4488
|
};
|
@@ -4477,7 +4497,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4477
4497
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4478
4498
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4479
4499
|
id: block.id,
|
4480
|
-
height:
|
4500
|
+
height: bn18(block.height),
|
4481
4501
|
time: block.header.time,
|
4482
4502
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4483
4503
|
}));
|
@@ -4492,7 +4512,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4492
4512
|
async getBlockWithTransactions(idOrHeight) {
|
4493
4513
|
let variables;
|
4494
4514
|
if (typeof idOrHeight === "number") {
|
4495
|
-
variables = { blockHeight:
|
4515
|
+
variables = { blockHeight: bn18(idOrHeight).toString(10) };
|
4496
4516
|
} else if (idOrHeight === "latest") {
|
4497
4517
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4498
4518
|
} else {
|
@@ -4504,7 +4524,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4504
4524
|
}
|
4505
4525
|
return {
|
4506
4526
|
id: block.id,
|
4507
|
-
height:
|
4527
|
+
height: bn18(block.height, 10),
|
4508
4528
|
time: block.header.time,
|
4509
4529
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4510
4530
|
transactions: block.transactions.map(
|
@@ -4553,7 +4573,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4553
4573
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4554
4574
|
asset: hexlify12(assetId)
|
4555
4575
|
});
|
4556
|
-
return
|
4576
|
+
return bn18(contractBalance.amount, 10);
|
4557
4577
|
}
|
4558
4578
|
/**
|
4559
4579
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4567,7 +4587,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4567
4587
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4568
4588
|
assetId: hexlify12(assetId)
|
4569
4589
|
});
|
4570
|
-
return
|
4590
|
+
return bn18(balance.amount, 10);
|
4571
4591
|
}
|
4572
4592
|
/**
|
4573
4593
|
* Returns balances for the given owner.
|
@@ -4585,7 +4605,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4585
4605
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4586
4606
|
return balances.map((balance) => ({
|
4587
4607
|
assetId: balance.assetId,
|
4588
|
-
amount:
|
4608
|
+
amount: bn18(balance.amount)
|
4589
4609
|
}));
|
4590
4610
|
}
|
4591
4611
|
/**
|
@@ -4607,15 +4627,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4607
4627
|
sender: message.sender,
|
4608
4628
|
recipient: message.recipient,
|
4609
4629
|
nonce: message.nonce,
|
4610
|
-
amount:
|
4630
|
+
amount: bn18(message.amount),
|
4611
4631
|
data: message.data
|
4612
4632
|
}),
|
4613
4633
|
sender: Address2.fromAddressOrString(message.sender),
|
4614
4634
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4615
4635
|
nonce: message.nonce,
|
4616
|
-
amount:
|
4636
|
+
amount: bn18(message.amount),
|
4617
4637
|
data: InputMessageCoder.decodeData(message.data),
|
4618
|
-
daHeight:
|
4638
|
+
daHeight: bn18(message.daHeight)
|
4619
4639
|
}));
|
4620
4640
|
}
|
4621
4641
|
/**
|
@@ -4668,19 +4688,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4668
4688
|
} = result.messageProof;
|
4669
4689
|
return {
|
4670
4690
|
messageProof: {
|
4671
|
-
proofIndex:
|
4691
|
+
proofIndex: bn18(messageProof.proofIndex),
|
4672
4692
|
proofSet: messageProof.proofSet
|
4673
4693
|
},
|
4674
4694
|
blockProof: {
|
4675
|
-
proofIndex:
|
4695
|
+
proofIndex: bn18(blockProof.proofIndex),
|
4676
4696
|
proofSet: blockProof.proofSet
|
4677
4697
|
},
|
4678
4698
|
messageBlockHeader: {
|
4679
4699
|
id: messageBlockHeader.id,
|
4680
|
-
daHeight:
|
4700
|
+
daHeight: bn18(messageBlockHeader.daHeight),
|
4681
4701
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4682
4702
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4683
|
-
height:
|
4703
|
+
height: bn18(messageBlockHeader.height),
|
4684
4704
|
prevRoot: messageBlockHeader.prevRoot,
|
4685
4705
|
time: messageBlockHeader.time,
|
4686
4706
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -4692,10 +4712,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4692
4712
|
},
|
4693
4713
|
commitBlockHeader: {
|
4694
4714
|
id: commitBlockHeader.id,
|
4695
|
-
daHeight:
|
4715
|
+
daHeight: bn18(commitBlockHeader.daHeight),
|
4696
4716
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4697
4717
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4698
|
-
height:
|
4718
|
+
height: bn18(commitBlockHeader.height),
|
4699
4719
|
prevRoot: commitBlockHeader.prevRoot,
|
4700
4720
|
time: commitBlockHeader.time,
|
4701
4721
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -4708,19 +4728,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4708
4728
|
sender: Address2.fromAddressOrString(sender),
|
4709
4729
|
recipient: Address2.fromAddressOrString(recipient),
|
4710
4730
|
nonce,
|
4711
|
-
amount:
|
4731
|
+
amount: bn18(amount),
|
4712
4732
|
data
|
4713
4733
|
};
|
4714
4734
|
}
|
4715
4735
|
async getLatestGasPrice() {
|
4716
4736
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4717
|
-
return
|
4737
|
+
return bn18(latestGasPrice.gasPrice);
|
4718
4738
|
}
|
4719
4739
|
async estimateGasPrice(blockHorizon) {
|
4720
4740
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4721
4741
|
blockHorizon: String(blockHorizon)
|
4722
4742
|
});
|
4723
|
-
return
|
4743
|
+
return bn18(estimateGasPrice.gasPrice);
|
4724
4744
|
}
|
4725
4745
|
/**
|
4726
4746
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4741,10 +4761,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4741
4761
|
*/
|
4742
4762
|
async produceBlocks(amount, startTime) {
|
4743
4763
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4744
|
-
blocksToProduce:
|
4764
|
+
blocksToProduce: bn18(amount).toString(10),
|
4745
4765
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4746
4766
|
});
|
4747
|
-
return
|
4767
|
+
return bn18(latestBlockHeight);
|
4748
4768
|
}
|
4749
4769
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4750
4770
|
async getTransactionResponse(transactionId) {
|
@@ -4790,7 +4810,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4790
4810
|
|
4791
4811
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4792
4812
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4793
|
-
import { bn as
|
4813
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
4794
4814
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4795
4815
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4796
4816
|
|
@@ -5068,9 +5088,9 @@ var Account = class extends AbstractAccount {
|
|
5068
5088
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5069
5089
|
const fee = request.maxFee;
|
5070
5090
|
const baseAssetId = this.provider.getBaseAssetId();
|
5071
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
5091
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn20(0);
|
5072
5092
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5073
|
-
amount:
|
5093
|
+
amount: bn20(fee),
|
5074
5094
|
assetId: baseAssetId,
|
5075
5095
|
coinQuantities: requiredQuantities
|
5076
5096
|
});
|
@@ -5078,7 +5098,7 @@ var Account = class extends AbstractAccount {
|
|
5078
5098
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5079
5099
|
quantitiesDict[assetId] = {
|
5080
5100
|
required: amount,
|
5081
|
-
owned:
|
5101
|
+
owned: bn20(0)
|
5082
5102
|
};
|
5083
5103
|
});
|
5084
5104
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5105,6 +5125,7 @@ var Account = class extends AbstractAccount {
|
|
5105
5125
|
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5106
5126
|
);
|
5107
5127
|
request.addResources(resources);
|
5128
|
+
request.shiftPredicateData();
|
5108
5129
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5109
5130
|
const requestToReestimate2 = clone4(request);
|
5110
5131
|
if (addedSignatures) {
|
@@ -5136,6 +5157,7 @@ var Account = class extends AbstractAccount {
|
|
5136
5157
|
}
|
5137
5158
|
fundingAttempts += 1;
|
5138
5159
|
}
|
5160
|
+
request.shiftPredicateData();
|
5139
5161
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5140
5162
|
const requestToReestimate = clone4(request);
|
5141
5163
|
if (addedSignatures) {
|
@@ -5186,7 +5208,7 @@ var Account = class extends AbstractAccount {
|
|
5186
5208
|
* @returns A promise that resolves to the transaction response.
|
5187
5209
|
*/
|
5188
5210
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5189
|
-
if (
|
5211
|
+
if (bn20(amount).lte(0)) {
|
5190
5212
|
throw new FuelError15(
|
5191
5213
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5192
5214
|
"Transfer amount must be a positive number."
|
@@ -5206,7 +5228,7 @@ var Account = class extends AbstractAccount {
|
|
5206
5228
|
* @returns A promise that resolves to the transaction response.
|
5207
5229
|
*/
|
5208
5230
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5209
|
-
if (
|
5231
|
+
if (bn20(amount).lte(0)) {
|
5210
5232
|
throw new FuelError15(
|
5211
5233
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5212
5234
|
"Transfer amount must be a positive number."
|
@@ -5216,7 +5238,7 @@ var Account = class extends AbstractAccount {
|
|
5216
5238
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5217
5239
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5218
5240
|
hexlifiedContractId: contractAddress.toB256(),
|
5219
|
-
amountToTransfer:
|
5241
|
+
amountToTransfer: bn20(amount),
|
5220
5242
|
assetId: assetIdToTransfer
|
5221
5243
|
});
|
5222
5244
|
let request = new ScriptTransactionRequest({
|
@@ -5227,7 +5249,7 @@ var Account = class extends AbstractAccount {
|
|
5227
5249
|
request.addContractInputAndOutput(contractAddress);
|
5228
5250
|
const txCost = await this.provider.getTransactionCost(request, {
|
5229
5251
|
resourcesOwner: this,
|
5230
|
-
quantitiesToContract: [{ amount:
|
5252
|
+
quantitiesToContract: [{ amount: bn20(amount), assetId: String(assetIdToTransfer) }]
|
5231
5253
|
});
|
5232
5254
|
request = this.validateGasLimitAndMaxFee({
|
5233
5255
|
transactionRequest: request,
|
@@ -5252,7 +5274,7 @@ var Account = class extends AbstractAccount {
|
|
5252
5274
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5253
5275
|
);
|
5254
5276
|
const amountDataArray = arrayify14(
|
5255
|
-
"0x".concat(
|
5277
|
+
"0x".concat(bn20(amount).toHex().substring(2).padStart(16, "0"))
|
5256
5278
|
);
|
5257
5279
|
const script = new Uint8Array([
|
5258
5280
|
...arrayify14(withdrawScript.bytes),
|
@@ -5262,7 +5284,7 @@ var Account = class extends AbstractAccount {
|
|
5262
5284
|
const params = { script, ...txParams };
|
5263
5285
|
const baseAssetId = this.provider.getBaseAssetId();
|
5264
5286
|
let request = new ScriptTransactionRequest(params);
|
5265
|
-
const quantitiesToContract = [{ amount:
|
5287
|
+
const quantitiesToContract = [{ amount: bn20(amount), assetId: baseAssetId }];
|
5266
5288
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5267
5289
|
request = this.validateGasLimitAndMaxFee({
|
5268
5290
|
transactionRequest: request,
|
@@ -5679,7 +5701,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5679
5701
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
5680
5702
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5681
5703
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5682
|
-
import { bn as
|
5704
|
+
import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5683
5705
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
5684
5706
|
|
5685
5707
|
// src/mnemonic/mnemonic.ts
|
@@ -8143,7 +8165,7 @@ var HDWallet = class {
|
|
8143
8165
|
const IR = bytes.slice(32);
|
8144
8166
|
if (privateKey) {
|
8145
8167
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8146
|
-
const ki =
|
8168
|
+
const ki = bn21(IL).add(privateKey).mod(N).toBytes(32);
|
8147
8169
|
return new HDWallet({
|
8148
8170
|
privateKey: ki,
|
8149
8171
|
chainCode: IR,
|
@@ -8484,6 +8506,7 @@ var launchNode = async ({
|
|
8484
8506
|
ip,
|
8485
8507
|
port,
|
8486
8508
|
args = [],
|
8509
|
+
fuelCorePath = void 0,
|
8487
8510
|
useSystemFuelCore = false,
|
8488
8511
|
loggingEnabled = true,
|
8489
8512
|
debugEnabled = false,
|
@@ -8504,7 +8527,7 @@ var launchNode = async ({
|
|
8504
8527
|
const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
|
8505
8528
|
const poaInstant = poaInstantFlagValue === "true" || poaInstantFlagValue === void 0;
|
8506
8529
|
const graphQLStartSubstring = "Binding GraphQL provider to";
|
8507
|
-
const binPath = findBinPath("fuels-core", __dirname);
|
8530
|
+
const binPath = fuelCorePath ?? findBinPath("fuels-core", __dirname);
|
8508
8531
|
const command = useSystemFuelCore ? "fuel-core" : binPath;
|
8509
8532
|
const ipToUse = ip || "0.0.0.0";
|
8510
8533
|
const portToUse = port || (await getPortPromise({
|