@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.mjs
CHANGED
@@ -31,7 +31,7 @@ var __privateMethod = (obj, member, method) => {
|
|
31
31
|
import { Address as Address3 } from "@fuel-ts/address";
|
32
32
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
33
33
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
34
|
-
import { bn as
|
34
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
35
35
|
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
36
36
|
import { clone as clone4 } from "ramda";
|
37
37
|
|
@@ -73,7 +73,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
73
73
|
// src/providers/provider.ts
|
74
74
|
import { Address as Address2 } from "@fuel-ts/address";
|
75
75
|
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
76
|
-
import { BN, bn as
|
76
|
+
import { BN, bn as bn17 } from "@fuel-ts/math";
|
77
77
|
import {
|
78
78
|
InputType as InputType7,
|
79
79
|
TransactionType as TransactionType8,
|
@@ -1712,6 +1712,15 @@ function normalizeJSON(root) {
|
|
1712
1712
|
return normalize(clone(root));
|
1713
1713
|
}
|
1714
1714
|
|
1715
|
+
// src/providers/utils/sleep.ts
|
1716
|
+
function sleep(time) {
|
1717
|
+
return new Promise((resolve) => {
|
1718
|
+
setTimeout(() => {
|
1719
|
+
resolve(true);
|
1720
|
+
}, time);
|
1721
|
+
});
|
1722
|
+
}
|
1723
|
+
|
1715
1724
|
// src/providers/utils/extract-tx-error.ts
|
1716
1725
|
import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
|
1717
1726
|
import { bn as bn6 } from "@fuel-ts/math";
|
@@ -2368,15 +2377,6 @@ var BaseTransactionRequest = class {
|
|
2368
2377
|
}
|
2369
2378
|
});
|
2370
2379
|
}
|
2371
|
-
shiftPredicateData() {
|
2372
|
-
this.inputs.forEach((input) => {
|
2373
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2374
|
-
input.predicateData = input.padPredicateData(
|
2375
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2376
|
-
);
|
2377
|
-
}
|
2378
|
-
});
|
2379
|
-
}
|
2380
2380
|
};
|
2381
2381
|
|
2382
2382
|
// src/providers/transaction-request/create-transaction-request.ts
|
@@ -2799,12 +2799,12 @@ var transactionRequestify = (obj) => {
|
|
2799
2799
|
|
2800
2800
|
// src/providers/transaction-response/transaction-response.ts
|
2801
2801
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2802
|
-
import { bn as
|
2802
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
2803
2803
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2804
2804
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2805
2805
|
|
2806
2806
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2807
|
-
import { bn as
|
2807
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
2808
2808
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2809
2809
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2810
2810
|
|
@@ -2881,43 +2881,32 @@ var calculateTXFeeForSummary = (params) => {
|
|
2881
2881
|
// src/providers/transaction-summary/operations.ts
|
2882
2882
|
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
2883
2883
|
import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
|
2884
|
-
import { bn as
|
2884
|
+
import { bn as bn13 } from "@fuel-ts/math";
|
2885
2885
|
import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2886
2886
|
|
2887
2887
|
// src/providers/transaction-summary/call.ts
|
2888
|
-
import { Interface as Interface2
|
2889
|
-
|
2890
|
-
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2888
|
+
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
2889
|
+
var getFunctionCall = ({ abi, receipt }) => {
|
2891
2890
|
const abiInterface = new Interface2(abi);
|
2892
2891
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2893
2892
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2894
2893
|
const inputs = functionFragment.jsonFn.inputs;
|
2895
|
-
|
2896
|
-
if (functionFragment.isInputDataPointer) {
|
2897
|
-
if (rawPayload) {
|
2898
|
-
const argsOffset = bn13(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2899
|
-
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2900
|
-
}
|
2901
|
-
} else {
|
2902
|
-
encodedArgs = receipt.param2.toHex();
|
2903
|
-
}
|
2894
|
+
const encodedArgs = receipt.param2.toHex();
|
2904
2895
|
let argumentsProvided;
|
2905
|
-
|
2906
|
-
|
2907
|
-
|
2908
|
-
|
2909
|
-
|
2910
|
-
|
2911
|
-
|
2912
|
-
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
2919
|
-
}, {});
|
2920
|
-
}
|
2896
|
+
const data = functionFragment.decodeArguments(encodedArgs);
|
2897
|
+
if (data) {
|
2898
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
2899
|
+
const value = data[index];
|
2900
|
+
const name = input.name;
|
2901
|
+
if (name) {
|
2902
|
+
return {
|
2903
|
+
...prev,
|
2904
|
+
// reparse to remove bn
|
2905
|
+
[name]: JSON.parse(JSON.stringify(value))
|
2906
|
+
};
|
2907
|
+
}
|
2908
|
+
return prev;
|
2909
|
+
}, {});
|
2921
2910
|
}
|
2922
2911
|
const call = {
|
2923
2912
|
functionSignature: functionFragment.signature,
|
@@ -3103,7 +3092,7 @@ var mergeAssets = (op1, op2) => {
|
|
3103
3092
|
if (!matchingAsset) {
|
3104
3093
|
return asset1;
|
3105
3094
|
}
|
3106
|
-
const mergedAmount =
|
3095
|
+
const mergedAmount = bn13(asset1.amount).add(matchingAsset.amount);
|
3107
3096
|
return { ...asset1, amount: mergedAmount };
|
3108
3097
|
});
|
3109
3098
|
return mergedAssets.concat(filteredAssets);
|
@@ -3429,7 +3418,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3429
3418
|
|
3430
3419
|
// src/providers/transaction-summary/status.ts
|
3431
3420
|
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3432
|
-
import { bn as
|
3421
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
3433
3422
|
var getTransactionStatusName = (gqlStatus) => {
|
3434
3423
|
switch (gqlStatus) {
|
3435
3424
|
case "FailureStatus":
|
@@ -3463,15 +3452,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3463
3452
|
time = gqlTransactionStatus.time;
|
3464
3453
|
blockId = gqlTransactionStatus.block.id;
|
3465
3454
|
isStatusSuccess = true;
|
3466
|
-
totalFee =
|
3467
|
-
totalGas =
|
3455
|
+
totalFee = bn14(gqlTransactionStatus.totalFee);
|
3456
|
+
totalGas = bn14(gqlTransactionStatus.totalGas);
|
3468
3457
|
break;
|
3469
3458
|
case "FailureStatus":
|
3470
3459
|
time = gqlTransactionStatus.time;
|
3471
3460
|
blockId = gqlTransactionStatus.block.id;
|
3472
3461
|
isStatusFailure = true;
|
3473
|
-
totalFee =
|
3474
|
-
totalGas =
|
3462
|
+
totalFee = bn14(gqlTransactionStatus.totalFee);
|
3463
|
+
totalGas = bn14(gqlTransactionStatus.totalGas);
|
3475
3464
|
break;
|
3476
3465
|
case "SubmittedStatus":
|
3477
3466
|
time = gqlTransactionStatus.time;
|
@@ -3521,7 +3510,7 @@ function assembleTransactionSummary(params) {
|
|
3521
3510
|
maxInputs
|
3522
3511
|
});
|
3523
3512
|
const typeName = getTransactionTypeName(transaction.type);
|
3524
|
-
const tip =
|
3513
|
+
const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3525
3514
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3526
3515
|
const fee = calculateTXFeeForSummary({
|
3527
3516
|
totalFee,
|
@@ -3592,7 +3581,7 @@ var TransactionResponse = class {
|
|
3592
3581
|
/** Current provider */
|
3593
3582
|
provider;
|
3594
3583
|
/** Gas used on the transaction */
|
3595
|
-
gasUsed =
|
3584
|
+
gasUsed = bn16(0);
|
3596
3585
|
/** The graphql Transaction with receipts object. */
|
3597
3586
|
gqlTransaction;
|
3598
3587
|
abis;
|
@@ -3760,7 +3749,6 @@ var TransactionResponse = class {
|
|
3760
3749
|
};
|
3761
3750
|
|
3762
3751
|
// src/providers/utils/auto-retry-fetch.ts
|
3763
|
-
import { sleep } from "@fuel-ts/utils";
|
3764
3752
|
function getWaitDelay(options, retryAttemptNum) {
|
3765
3753
|
const duration = options.baseDelay ?? 150;
|
3766
3754
|
switch (options.backoff) {
|
@@ -3827,47 +3815,47 @@ var processGqlChain = (chain) => {
|
|
3827
3815
|
} = consensusParameters;
|
3828
3816
|
return {
|
3829
3817
|
name,
|
3830
|
-
baseChainHeight:
|
3818
|
+
baseChainHeight: bn17(daHeight),
|
3831
3819
|
consensusParameters: {
|
3832
3820
|
version,
|
3833
|
-
chainId:
|
3821
|
+
chainId: bn17(chainId),
|
3834
3822
|
baseAssetId,
|
3835
3823
|
feeParameters: {
|
3836
3824
|
version: feeParams.version,
|
3837
|
-
gasPerByte:
|
3838
|
-
gasPriceFactor:
|
3825
|
+
gasPerByte: bn17(feeParams.gasPerByte),
|
3826
|
+
gasPriceFactor: bn17(feeParams.gasPriceFactor)
|
3839
3827
|
},
|
3840
3828
|
contractParameters: {
|
3841
3829
|
version: contractParams.version,
|
3842
|
-
contractMaxSize:
|
3843
|
-
maxStorageSlots:
|
3830
|
+
contractMaxSize: bn17(contractParams.contractMaxSize),
|
3831
|
+
maxStorageSlots: bn17(contractParams.maxStorageSlots)
|
3844
3832
|
},
|
3845
3833
|
txParameters: {
|
3846
3834
|
version: txParams.version,
|
3847
|
-
maxInputs:
|
3848
|
-
maxOutputs:
|
3849
|
-
maxWitnesses:
|
3850
|
-
maxGasPerTx:
|
3851
|
-
maxSize:
|
3852
|
-
maxBytecodeSubsections:
|
3835
|
+
maxInputs: bn17(txParams.maxInputs),
|
3836
|
+
maxOutputs: bn17(txParams.maxOutputs),
|
3837
|
+
maxWitnesses: bn17(txParams.maxWitnesses),
|
3838
|
+
maxGasPerTx: bn17(txParams.maxGasPerTx),
|
3839
|
+
maxSize: bn17(txParams.maxSize),
|
3840
|
+
maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
|
3853
3841
|
},
|
3854
3842
|
predicateParameters: {
|
3855
3843
|
version: predicateParams.version,
|
3856
|
-
maxPredicateLength:
|
3857
|
-
maxPredicateDataLength:
|
3858
|
-
maxGasPerPredicate:
|
3859
|
-
maxMessageDataLength:
|
3844
|
+
maxPredicateLength: bn17(predicateParams.maxPredicateLength),
|
3845
|
+
maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
|
3846
|
+
maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
|
3847
|
+
maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
|
3860
3848
|
},
|
3861
3849
|
scriptParameters: {
|
3862
3850
|
version: scriptParams.version,
|
3863
|
-
maxScriptLength:
|
3864
|
-
maxScriptDataLength:
|
3851
|
+
maxScriptLength: bn17(scriptParams.maxScriptLength),
|
3852
|
+
maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
|
3865
3853
|
},
|
3866
3854
|
gasCosts
|
3867
3855
|
},
|
3868
3856
|
latestBlock: {
|
3869
3857
|
id: latestBlock.id,
|
3870
|
-
height:
|
3858
|
+
height: bn17(latestBlock.height),
|
3871
3859
|
time: latestBlock.header.time,
|
3872
3860
|
transactions: latestBlock.transactions.map((i) => ({
|
3873
3861
|
id: i.id
|
@@ -4063,7 +4051,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4063
4051
|
*/
|
4064
4052
|
async getBlockNumber() {
|
4065
4053
|
const { chain } = await this.operations.getChain();
|
4066
|
-
return
|
4054
|
+
return bn17(chain.latestBlock.height, 10);
|
4067
4055
|
}
|
4068
4056
|
/**
|
4069
4057
|
* Returns the chain information.
|
@@ -4073,8 +4061,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4073
4061
|
async fetchNode() {
|
4074
4062
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
4075
4063
|
const processedNodeInfo = {
|
4076
|
-
maxDepth:
|
4077
|
-
maxTx:
|
4064
|
+
maxDepth: bn17(nodeInfo.maxDepth),
|
4065
|
+
maxTx: bn17(nodeInfo.maxTx),
|
4078
4066
|
nodeVersion: nodeInfo.nodeVersion,
|
4079
4067
|
utxoValidation: nodeInfo.utxoValidation,
|
4080
4068
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4206,7 +4194,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4206
4194
|
} = response;
|
4207
4195
|
if (inputs) {
|
4208
4196
|
inputs.forEach((input, index) => {
|
4209
|
-
if ("predicateGasUsed" in input &&
|
4197
|
+
if ("predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
|
4210
4198
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4211
4199
|
}
|
4212
4200
|
});
|
@@ -4364,12 +4352,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4364
4352
|
gasPrice = await this.estimateGasPrice(10);
|
4365
4353
|
}
|
4366
4354
|
const minFee = calculateGasFee({
|
4367
|
-
gasPrice:
|
4355
|
+
gasPrice: bn17(gasPrice),
|
4368
4356
|
gas: minGas,
|
4369
4357
|
priceFactor: gasPriceFactor,
|
4370
4358
|
tip: transactionRequest.tip
|
4371
4359
|
}).add(1);
|
4372
|
-
let gasLimit =
|
4360
|
+
let gasLimit = bn17(0);
|
4373
4361
|
if (transactionRequest.type === TransactionType8.Script) {
|
4374
4362
|
gasLimit = transactionRequest.gasLimit;
|
4375
4363
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4382,7 +4370,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4382
4370
|
}
|
4383
4371
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4384
4372
|
const maxFee = calculateGasFee({
|
4385
|
-
gasPrice:
|
4373
|
+
gasPrice: bn17(gasPrice),
|
4386
4374
|
gas: maxGas,
|
4387
4375
|
priceFactor: gasPriceFactor,
|
4388
4376
|
tip: transactionRequest.tip
|
@@ -4447,7 +4435,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4447
4435
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4448
4436
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4449
4437
|
if (isScriptTransaction) {
|
4450
|
-
txRequestClone.gasLimit =
|
4438
|
+
txRequestClone.gasLimit = bn17(0);
|
4451
4439
|
}
|
4452
4440
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4453
4441
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4468,7 +4456,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4468
4456
|
let dryRunStatus;
|
4469
4457
|
let missingContractIds = [];
|
4470
4458
|
let outputVariables = 0;
|
4471
|
-
let gasUsed =
|
4459
|
+
let gasUsed = bn17(0);
|
4472
4460
|
txRequestClone.maxFee = maxFee;
|
4473
4461
|
if (isScriptTransaction) {
|
4474
4462
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4533,10 +4521,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4533
4521
|
return coins.map((coin) => ({
|
4534
4522
|
id: coin.utxoId,
|
4535
4523
|
assetId: coin.assetId,
|
4536
|
-
amount:
|
4524
|
+
amount: bn17(coin.amount),
|
4537
4525
|
owner: Address2.fromAddressOrString(coin.owner),
|
4538
|
-
blockCreated:
|
4539
|
-
txCreatedIdx:
|
4526
|
+
blockCreated: bn17(coin.blockCreated),
|
4527
|
+
txCreatedIdx: bn17(coin.txCreatedIdx)
|
4540
4528
|
}));
|
4541
4529
|
}
|
4542
4530
|
/**
|
@@ -4573,9 +4561,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4573
4561
|
switch (coin.type) {
|
4574
4562
|
case "MessageCoin":
|
4575
4563
|
return {
|
4576
|
-
amount:
|
4564
|
+
amount: bn17(coin.amount),
|
4577
4565
|
assetId: coin.assetId,
|
4578
|
-
daHeight:
|
4566
|
+
daHeight: bn17(coin.daHeight),
|
4579
4567
|
sender: Address2.fromAddressOrString(coin.sender),
|
4580
4568
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4581
4569
|
nonce: coin.nonce
|
@@ -4583,11 +4571,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4583
4571
|
case "Coin":
|
4584
4572
|
return {
|
4585
4573
|
id: coin.utxoId,
|
4586
|
-
amount:
|
4574
|
+
amount: bn17(coin.amount),
|
4587
4575
|
assetId: coin.assetId,
|
4588
4576
|
owner: Address2.fromAddressOrString(coin.owner),
|
4589
|
-
blockCreated:
|
4590
|
-
txCreatedIdx:
|
4577
|
+
blockCreated: bn17(coin.blockCreated),
|
4578
|
+
txCreatedIdx: bn17(coin.txCreatedIdx)
|
4591
4579
|
};
|
4592
4580
|
default:
|
4593
4581
|
return null;
|
@@ -4604,13 +4592,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4604
4592
|
async getBlock(idOrHeight) {
|
4605
4593
|
let variables;
|
4606
4594
|
if (typeof idOrHeight === "number") {
|
4607
|
-
variables = { height:
|
4595
|
+
variables = { height: bn17(idOrHeight).toString(10) };
|
4608
4596
|
} else if (idOrHeight === "latest") {
|
4609
4597
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4610
4598
|
} else if (idOrHeight.length === 66) {
|
4611
4599
|
variables = { blockId: idOrHeight };
|
4612
4600
|
} else {
|
4613
|
-
variables = { blockId:
|
4601
|
+
variables = { blockId: bn17(idOrHeight).toString(10) };
|
4614
4602
|
}
|
4615
4603
|
const { block } = await this.operations.getBlock(variables);
|
4616
4604
|
if (!block) {
|
@@ -4618,7 +4606,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4618
4606
|
}
|
4619
4607
|
return {
|
4620
4608
|
id: block.id,
|
4621
|
-
height:
|
4609
|
+
height: bn17(block.height),
|
4622
4610
|
time: block.header.time,
|
4623
4611
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4624
4612
|
};
|
@@ -4633,7 +4621,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4633
4621
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4634
4622
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4635
4623
|
id: block.id,
|
4636
|
-
height:
|
4624
|
+
height: bn17(block.height),
|
4637
4625
|
time: block.header.time,
|
4638
4626
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4639
4627
|
}));
|
@@ -4648,7 +4636,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4648
4636
|
async getBlockWithTransactions(idOrHeight) {
|
4649
4637
|
let variables;
|
4650
4638
|
if (typeof idOrHeight === "number") {
|
4651
|
-
variables = { blockHeight:
|
4639
|
+
variables = { blockHeight: bn17(idOrHeight).toString(10) };
|
4652
4640
|
} else if (idOrHeight === "latest") {
|
4653
4641
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4654
4642
|
} else {
|
@@ -4660,7 +4648,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4660
4648
|
}
|
4661
4649
|
return {
|
4662
4650
|
id: block.id,
|
4663
|
-
height:
|
4651
|
+
height: bn17(block.height, 10),
|
4664
4652
|
time: block.header.time,
|
4665
4653
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4666
4654
|
transactions: block.transactions.map(
|
@@ -4709,7 +4697,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4709
4697
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4710
4698
|
asset: hexlify12(assetId)
|
4711
4699
|
});
|
4712
|
-
return
|
4700
|
+
return bn17(contractBalance.amount, 10);
|
4713
4701
|
}
|
4714
4702
|
/**
|
4715
4703
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4723,7 +4711,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4723
4711
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4724
4712
|
assetId: hexlify12(assetId)
|
4725
4713
|
});
|
4726
|
-
return
|
4714
|
+
return bn17(balance.amount, 10);
|
4727
4715
|
}
|
4728
4716
|
/**
|
4729
4717
|
* Returns balances for the given owner.
|
@@ -4741,7 +4729,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4741
4729
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4742
4730
|
return balances.map((balance) => ({
|
4743
4731
|
assetId: balance.assetId,
|
4744
|
-
amount:
|
4732
|
+
amount: bn17(balance.amount)
|
4745
4733
|
}));
|
4746
4734
|
}
|
4747
4735
|
/**
|
@@ -4763,15 +4751,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4763
4751
|
sender: message.sender,
|
4764
4752
|
recipient: message.recipient,
|
4765
4753
|
nonce: message.nonce,
|
4766
|
-
amount:
|
4754
|
+
amount: bn17(message.amount),
|
4767
4755
|
data: message.data
|
4768
4756
|
}),
|
4769
4757
|
sender: Address2.fromAddressOrString(message.sender),
|
4770
4758
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4771
4759
|
nonce: message.nonce,
|
4772
|
-
amount:
|
4760
|
+
amount: bn17(message.amount),
|
4773
4761
|
data: InputMessageCoder.decodeData(message.data),
|
4774
|
-
daHeight:
|
4762
|
+
daHeight: bn17(message.daHeight)
|
4775
4763
|
}));
|
4776
4764
|
}
|
4777
4765
|
/**
|
@@ -4824,19 +4812,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4824
4812
|
} = result.messageProof;
|
4825
4813
|
return {
|
4826
4814
|
messageProof: {
|
4827
|
-
proofIndex:
|
4815
|
+
proofIndex: bn17(messageProof.proofIndex),
|
4828
4816
|
proofSet: messageProof.proofSet
|
4829
4817
|
},
|
4830
4818
|
blockProof: {
|
4831
|
-
proofIndex:
|
4819
|
+
proofIndex: bn17(blockProof.proofIndex),
|
4832
4820
|
proofSet: blockProof.proofSet
|
4833
4821
|
},
|
4834
4822
|
messageBlockHeader: {
|
4835
4823
|
id: messageBlockHeader.id,
|
4836
|
-
daHeight:
|
4824
|
+
daHeight: bn17(messageBlockHeader.daHeight),
|
4837
4825
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4838
4826
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4839
|
-
height:
|
4827
|
+
height: bn17(messageBlockHeader.height),
|
4840
4828
|
prevRoot: messageBlockHeader.prevRoot,
|
4841
4829
|
time: messageBlockHeader.time,
|
4842
4830
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -4848,10 +4836,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4848
4836
|
},
|
4849
4837
|
commitBlockHeader: {
|
4850
4838
|
id: commitBlockHeader.id,
|
4851
|
-
daHeight:
|
4839
|
+
daHeight: bn17(commitBlockHeader.daHeight),
|
4852
4840
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4853
4841
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4854
|
-
height:
|
4842
|
+
height: bn17(commitBlockHeader.height),
|
4855
4843
|
prevRoot: commitBlockHeader.prevRoot,
|
4856
4844
|
time: commitBlockHeader.time,
|
4857
4845
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -4864,19 +4852,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4864
4852
|
sender: Address2.fromAddressOrString(sender),
|
4865
4853
|
recipient: Address2.fromAddressOrString(recipient),
|
4866
4854
|
nonce,
|
4867
|
-
amount:
|
4855
|
+
amount: bn17(amount),
|
4868
4856
|
data
|
4869
4857
|
};
|
4870
4858
|
}
|
4871
4859
|
async getLatestGasPrice() {
|
4872
4860
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4873
|
-
return
|
4861
|
+
return bn17(latestGasPrice.gasPrice);
|
4874
4862
|
}
|
4875
4863
|
async estimateGasPrice(blockHorizon) {
|
4876
4864
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4877
4865
|
blockHorizon: String(blockHorizon)
|
4878
4866
|
});
|
4879
|
-
return
|
4867
|
+
return bn17(estimateGasPrice.gasPrice);
|
4880
4868
|
}
|
4881
4869
|
/**
|
4882
4870
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4897,10 +4885,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4897
4885
|
*/
|
4898
4886
|
async produceBlocks(amount, startTime) {
|
4899
4887
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4900
|
-
blocksToProduce:
|
4888
|
+
blocksToProduce: bn17(amount).toString(10),
|
4901
4889
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4902
4890
|
});
|
4903
|
-
return
|
4891
|
+
return bn17(latestBlockHeight);
|
4904
4892
|
}
|
4905
4893
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4906
4894
|
async getTransactionResponse(transactionId) {
|
@@ -4946,7 +4934,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4946
4934
|
|
4947
4935
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4948
4936
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4949
|
-
import { bn as
|
4937
|
+
import { bn as bn18 } from "@fuel-ts/math";
|
4950
4938
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4951
4939
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4952
4940
|
async function getTransactionSummary(params) {
|
@@ -4983,8 +4971,8 @@ async function getTransactionSummary(params) {
|
|
4983
4971
|
transaction: decodedTransaction,
|
4984
4972
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4985
4973
|
gqlTransactionStatus: gqlTransaction.status,
|
4986
|
-
gasPerByte:
|
4987
|
-
gasPriceFactor:
|
4974
|
+
gasPerByte: bn18(gasPerByte),
|
4975
|
+
gasPriceFactor: bn18(gasPriceFactor),
|
4988
4976
|
abiMap,
|
4989
4977
|
maxInputs,
|
4990
4978
|
gasCosts,
|
@@ -5393,9 +5381,9 @@ var Account = class extends AbstractAccount {
|
|
5393
5381
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5394
5382
|
const fee = request.maxFee;
|
5395
5383
|
const baseAssetId = this.provider.getBaseAssetId();
|
5396
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
5384
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
|
5397
5385
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5398
|
-
amount:
|
5386
|
+
amount: bn19(fee),
|
5399
5387
|
assetId: baseAssetId,
|
5400
5388
|
coinQuantities: requiredQuantities
|
5401
5389
|
});
|
@@ -5403,7 +5391,7 @@ var Account = class extends AbstractAccount {
|
|
5403
5391
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5404
5392
|
quantitiesDict[assetId] = {
|
5405
5393
|
required: amount,
|
5406
|
-
owned:
|
5394
|
+
owned: bn19(0)
|
5407
5395
|
};
|
5408
5396
|
});
|
5409
5397
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5430,7 +5418,6 @@ var Account = class extends AbstractAccount {
|
|
5430
5418
|
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5431
5419
|
);
|
5432
5420
|
request.addResources(resources);
|
5433
|
-
request.shiftPredicateData();
|
5434
5421
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5435
5422
|
const requestToReestimate2 = clone4(request);
|
5436
5423
|
if (addedSignatures) {
|
@@ -5462,7 +5449,6 @@ var Account = class extends AbstractAccount {
|
|
5462
5449
|
}
|
5463
5450
|
fundingAttempts += 1;
|
5464
5451
|
}
|
5465
|
-
request.shiftPredicateData();
|
5466
5452
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5467
5453
|
const requestToReestimate = clone4(request);
|
5468
5454
|
if (addedSignatures) {
|
@@ -5513,7 +5499,7 @@ var Account = class extends AbstractAccount {
|
|
5513
5499
|
* @returns A promise that resolves to the transaction response.
|
5514
5500
|
*/
|
5515
5501
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5516
|
-
if (
|
5502
|
+
if (bn19(amount).lte(0)) {
|
5517
5503
|
throw new FuelError15(
|
5518
5504
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5519
5505
|
"Transfer amount must be a positive number."
|
@@ -5533,7 +5519,7 @@ var Account = class extends AbstractAccount {
|
|
5533
5519
|
* @returns A promise that resolves to the transaction response.
|
5534
5520
|
*/
|
5535
5521
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5536
|
-
if (
|
5522
|
+
if (bn19(amount).lte(0)) {
|
5537
5523
|
throw new FuelError15(
|
5538
5524
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5539
5525
|
"Transfer amount must be a positive number."
|
@@ -5543,7 +5529,7 @@ var Account = class extends AbstractAccount {
|
|
5543
5529
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5544
5530
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5545
5531
|
hexlifiedContractId: contractAddress.toB256(),
|
5546
|
-
amountToTransfer:
|
5532
|
+
amountToTransfer: bn19(amount),
|
5547
5533
|
assetId: assetIdToTransfer
|
5548
5534
|
});
|
5549
5535
|
let request = new ScriptTransactionRequest({
|
@@ -5554,7 +5540,7 @@ var Account = class extends AbstractAccount {
|
|
5554
5540
|
request.addContractInputAndOutput(contractAddress);
|
5555
5541
|
const txCost = await this.provider.getTransactionCost(request, {
|
5556
5542
|
resourcesOwner: this,
|
5557
|
-
quantitiesToContract: [{ amount:
|
5543
|
+
quantitiesToContract: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
|
5558
5544
|
});
|
5559
5545
|
request = this.validateGasLimitAndMaxFee({
|
5560
5546
|
transactionRequest: request,
|
@@ -5579,7 +5565,7 @@ var Account = class extends AbstractAccount {
|
|
5579
5565
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5580
5566
|
);
|
5581
5567
|
const amountDataArray = arrayify14(
|
5582
|
-
"0x".concat(
|
5568
|
+
"0x".concat(bn19(amount).toHex().substring(2).padStart(16, "0"))
|
5583
5569
|
);
|
5584
5570
|
const script = new Uint8Array([
|
5585
5571
|
...arrayify14(withdrawScript.bytes),
|
@@ -5589,7 +5575,7 @@ var Account = class extends AbstractAccount {
|
|
5589
5575
|
const params = { script, ...txParams };
|
5590
5576
|
const baseAssetId = this.provider.getBaseAssetId();
|
5591
5577
|
let request = new ScriptTransactionRequest(params);
|
5592
|
-
const quantitiesToContract = [{ amount:
|
5578
|
+
const quantitiesToContract = [{ amount: bn19(amount), assetId: baseAssetId }];
|
5593
5579
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5594
5580
|
request = this.validateGasLimitAndMaxFee({
|
5595
5581
|
transactionRequest: request,
|
@@ -6010,7 +5996,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6010
5996
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
6011
5997
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
6012
5998
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
6013
|
-
import { bn as
|
5999
|
+
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
6014
6000
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
6015
6001
|
|
6016
6002
|
// src/mnemonic/mnemonic.ts
|
@@ -8480,7 +8466,7 @@ var HDWallet = class {
|
|
8480
8466
|
const IR = bytes.slice(32);
|
8481
8467
|
if (privateKey) {
|
8482
8468
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8483
|
-
const ki =
|
8469
|
+
const ki = bn20(IL).add(privateKey).mod(N).toBytes(32);
|
8484
8470
|
return new HDWallet({
|
8485
8471
|
privateKey: ki,
|
8486
8472
|
chainCode: IR,
|
@@ -9159,16 +9145,9 @@ var StorageAbstract = class {
|
|
9159
9145
|
};
|
9160
9146
|
|
9161
9147
|
// src/predicate/predicate.ts
|
9162
|
-
import {
|
9163
|
-
Interface as Interface4,
|
9164
|
-
INPUT_COIN_FIXED_SIZE,
|
9165
|
-
WORD_SIZE,
|
9166
|
-
calculateVmTxMemory as calculateVmTxMemory2,
|
9167
|
-
SCRIPT_FIXED_SIZE
|
9168
|
-
} from "@fuel-ts/abi-coder";
|
9148
|
+
import { Interface as Interface4 } from "@fuel-ts/abi-coder";
|
9169
9149
|
import { Address as Address9 } from "@fuel-ts/address";
|
9170
9150
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9171
|
-
import { ByteArrayCoder } from "@fuel-ts/transactions";
|
9172
9151
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
9173
9152
|
|
9174
9153
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9226,7 +9205,6 @@ var Predicate = class extends Account {
|
|
9226
9205
|
*/
|
9227
9206
|
populateTransactionPredicateData(transactionRequestLike) {
|
9228
9207
|
const request = transactionRequestify(transactionRequestLike);
|
9229
|
-
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9230
9208
|
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
9231
9209
|
if (placeholderIndex !== -1) {
|
9232
9210
|
request.removeWitness(placeholderIndex);
|
@@ -9234,7 +9212,7 @@ var Predicate = class extends Account {
|
|
9234
9212
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9235
9213
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9236
9214
|
input.predicate = hexlify19(this.bytes);
|
9237
|
-
input.predicateData = hexlify19(this.getPredicateData(
|
9215
|
+
input.predicateData = hexlify19(this.getPredicateData());
|
9238
9216
|
input.witnessIndex = 0;
|
9239
9217
|
}
|
9240
9218
|
});
|
@@ -9260,17 +9238,12 @@ var Predicate = class extends Account {
|
|
9260
9238
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9261
9239
|
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
9262
9240
|
}
|
9263
|
-
getPredicateData(
|
9241
|
+
getPredicateData() {
|
9264
9242
|
if (!this.predicateData.length) {
|
9265
9243
|
return new Uint8Array();
|
9266
9244
|
}
|
9267
9245
|
const mainFn = this.interface?.functions.main;
|
9268
|
-
|
9269
|
-
const VM_TX_MEMORY = calculateVmTxMemory2({
|
9270
|
-
maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
|
9271
|
-
});
|
9272
|
-
const OFFSET = VM_TX_MEMORY + SCRIPT_FIXED_SIZE + INPUT_COIN_FIXED_SIZE + WORD_SIZE + paddedCode.byteLength + policiesLength * WORD_SIZE;
|
9273
|
-
return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
|
9246
|
+
return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
|
9274
9247
|
}
|
9275
9248
|
/**
|
9276
9249
|
* Processes the predicate data and returns the altered bytecode and interface.
|
@@ -9319,8 +9292,7 @@ var Predicate = class extends Account {
|
|
9319
9292
|
);
|
9320
9293
|
return resources.map((resource) => ({
|
9321
9294
|
...resource,
|
9322
|
-
predicate: hexlify19(this.bytes)
|
9323
|
-
padPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
|
9295
|
+
predicate: hexlify19(this.bytes)
|
9324
9296
|
}));
|
9325
9297
|
}
|
9326
9298
|
/**
|
@@ -10184,6 +10156,7 @@ export {
|
|
10184
10156
|
resolveGasDependentCosts,
|
10185
10157
|
resolveIconPaths,
|
10186
10158
|
returnZeroScript,
|
10159
|
+
sleep,
|
10187
10160
|
transactionRequestify,
|
10188
10161
|
urlJoin,
|
10189
10162
|
withTimeout,
|