@fuel-ts/account 0.0.0-rc-2037-20240430170043 → 0.0.0-rc-2037-20240501112942
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 +1 -1
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +96 -49
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +226 -176
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +229 -180
- package/dist/index.mjs.map +1 -1
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts +0 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +4 -2
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +3 -3
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -3
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +1 -1
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/test-utils.global.js +91 -44
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +216 -168
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +226 -178
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/dist/test-utils.js
CHANGED
@@ -67,7 +67,7 @@ var import_utils30 = require("@fuel-ts/utils");
|
|
67
67
|
var import_address4 = require("@fuel-ts/address");
|
68
68
|
var import_errors16 = require("@fuel-ts/errors");
|
69
69
|
var import_interfaces = require("@fuel-ts/interfaces");
|
70
|
-
var
|
70
|
+
var import_math20 = require("@fuel-ts/math");
|
71
71
|
var import_utils27 = require("@fuel-ts/utils");
|
72
72
|
var import_ramda4 = require("ramda");
|
73
73
|
|
@@ -109,7 +109,7 @@ var addAmountToCoinQuantities = (params) => {
|
|
109
109
|
// src/providers/provider.ts
|
110
110
|
var import_address3 = require("@fuel-ts/address");
|
111
111
|
var import_errors14 = require("@fuel-ts/errors");
|
112
|
-
var
|
112
|
+
var import_math17 = require("@fuel-ts/math");
|
113
113
|
var import_transactions20 = require("@fuel-ts/transactions");
|
114
114
|
var import_utils22 = require("@fuel-ts/utils");
|
115
115
|
var import_versions = require("@fuel-ts/versions");
|
@@ -1276,7 +1276,7 @@ var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
|
1276
1276
|
var import_address = require("@fuel-ts/address");
|
1277
1277
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1278
1278
|
var import_crypto = require("@fuel-ts/crypto");
|
1279
|
-
var
|
1279
|
+
var import_math8 = require("@fuel-ts/math");
|
1280
1280
|
var import_transactions7 = require("@fuel-ts/transactions");
|
1281
1281
|
var import_utils9 = require("@fuel-ts/utils");
|
1282
1282
|
|
@@ -1586,7 +1586,7 @@ function calculateMetadataGasForTxScript({
|
|
1586
1586
|
}
|
1587
1587
|
var calculateGasFee = (params) => {
|
1588
1588
|
const { gas, gasPrice, priceFactor, tip } = params;
|
1589
|
-
return gas.mul(gasPrice).div(priceFactor).add(tip);
|
1589
|
+
return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
|
1590
1590
|
};
|
1591
1591
|
|
1592
1592
|
// src/providers/utils/json.ts
|
@@ -1712,10 +1712,34 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1712
1712
|
};
|
1713
1713
|
|
1714
1714
|
// src/providers/transaction-request/helpers.ts
|
1715
|
+
var import_math7 = require("@fuel-ts/math");
|
1715
1716
|
var import_transactions6 = require("@fuel-ts/transactions");
|
1716
1717
|
var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
|
1717
1718
|
var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
|
1718
1719
|
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1720
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1721
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1722
|
+
return acc.add(input.amount);
|
1723
|
+
}
|
1724
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1725
|
+
return acc.add(input.amount);
|
1726
|
+
}
|
1727
|
+
return acc;
|
1728
|
+
}, (0, import_math7.bn)(0));
|
1729
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
1730
|
+
(acc, input) => {
|
1731
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
1732
|
+
acc.utxos.push(input.id);
|
1733
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
1734
|
+
acc.messages.push(input.nonce);
|
1735
|
+
}
|
1736
|
+
return acc;
|
1737
|
+
},
|
1738
|
+
{
|
1739
|
+
utxos: [],
|
1740
|
+
messages: []
|
1741
|
+
}
|
1742
|
+
);
|
1719
1743
|
|
1720
1744
|
// src/providers/transaction-request/witness.ts
|
1721
1745
|
var import_utils8 = require("@fuel-ts/utils");
|
@@ -1757,10 +1781,10 @@ var BaseTransactionRequest = class {
|
|
1757
1781
|
outputs,
|
1758
1782
|
witnesses
|
1759
1783
|
} = {}) {
|
1760
|
-
this.tip = (0,
|
1761
|
-
this.maturity = maturity
|
1762
|
-
this.witnessLimit = witnessLimit ? (0,
|
1763
|
-
this.maxFee =
|
1784
|
+
this.tip = tip ? (0, import_math8.bn)(tip) : void 0;
|
1785
|
+
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1786
|
+
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math8.bn)(witnessLimit) : void 0;
|
1787
|
+
this.maxFee = (0, import_math8.bn)(maxFee);
|
1764
1788
|
this.inputs = inputs ?? [];
|
1765
1789
|
this.outputs = outputs ?? [];
|
1766
1790
|
this.witnesses = witnesses ?? [];
|
@@ -1768,22 +1792,21 @@ var BaseTransactionRequest = class {
|
|
1768
1792
|
static getPolicyMeta(req) {
|
1769
1793
|
let policyTypes = 0;
|
1770
1794
|
const policies = [];
|
1771
|
-
|
1795
|
+
const { tip, witnessLimit, maturity } = req;
|
1796
|
+
if ((0, import_math8.bn)(tip).gt(0)) {
|
1772
1797
|
policyTypes += import_transactions7.PolicyType.Tip;
|
1773
|
-
policies.push({ data:
|
1798
|
+
policies.push({ data: (0, import_math8.bn)(tip), type: import_transactions7.PolicyType.Tip });
|
1774
1799
|
}
|
1775
|
-
if (
|
1800
|
+
if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math8.bn)(witnessLimit).gte(0)) {
|
1776
1801
|
policyTypes += import_transactions7.PolicyType.WitnessLimit;
|
1777
|
-
policies.push({ data:
|
1802
|
+
policies.push({ data: (0, import_math8.bn)(witnessLimit), type: import_transactions7.PolicyType.WitnessLimit });
|
1778
1803
|
}
|
1779
|
-
if (
|
1804
|
+
if (maturity && maturity > 0) {
|
1780
1805
|
policyTypes += import_transactions7.PolicyType.Maturity;
|
1781
|
-
policies.push({ data:
|
1782
|
-
}
|
1783
|
-
if (req.maxFee) {
|
1784
|
-
policyTypes += import_transactions7.PolicyType.MaxFee;
|
1785
|
-
policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
|
1806
|
+
policies.push({ data: maturity, type: import_transactions7.PolicyType.Maturity });
|
1786
1807
|
}
|
1808
|
+
policyTypes += import_transactions7.PolicyType.MaxFee;
|
1809
|
+
policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
|
1787
1810
|
return {
|
1788
1811
|
policyTypes,
|
1789
1812
|
policies
|
@@ -2144,7 +2167,7 @@ var BaseTransactionRequest = class {
|
|
2144
2167
|
const assetInput = findAssetInput(assetId);
|
2145
2168
|
let usedQuantity = quantity;
|
2146
2169
|
if (assetId === baseAssetId) {
|
2147
|
-
usedQuantity = (0,
|
2170
|
+
usedQuantity = (0, import_math8.bn)("1000000000000000000");
|
2148
2171
|
}
|
2149
2172
|
if (assetInput && "assetId" in assetInput) {
|
2150
2173
|
assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
|
@@ -2156,13 +2179,13 @@ var BaseTransactionRequest = class {
|
|
2156
2179
|
amount: usedQuantity,
|
2157
2180
|
assetId,
|
2158
2181
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2159
|
-
blockCreated: (0,
|
2160
|
-
txCreatedIdx: (0,
|
2182
|
+
blockCreated: (0, import_math8.bn)(1),
|
2183
|
+
txCreatedIdx: (0, import_math8.bn)(1)
|
2161
2184
|
}
|
2162
2185
|
]);
|
2163
2186
|
}
|
2164
2187
|
};
|
2165
|
-
updateAssetInput(baseAssetId, (0,
|
2188
|
+
updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
|
2166
2189
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2167
2190
|
}
|
2168
2191
|
/**
|
@@ -2173,7 +2196,7 @@ var BaseTransactionRequest = class {
|
|
2173
2196
|
*/
|
2174
2197
|
getCoinOutputsQuantities() {
|
2175
2198
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2176
|
-
amount: (0,
|
2199
|
+
amount: (0, import_math8.bn)(amount),
|
2177
2200
|
assetId: assetId.toString()
|
2178
2201
|
}));
|
2179
2202
|
return coinsQuantities;
|
@@ -2213,7 +2236,7 @@ var BaseTransactionRequest = class {
|
|
2213
2236
|
default:
|
2214
2237
|
return;
|
2215
2238
|
}
|
2216
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0,
|
2239
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math8.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2217
2240
|
i.predicate = correspondingInput.predicate;
|
2218
2241
|
i.predicateData = correspondingInput.predicateData;
|
2219
2242
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2233,14 +2256,14 @@ var BaseTransactionRequest = class {
|
|
2233
2256
|
|
2234
2257
|
// src/providers/transaction-request/create-transaction-request.ts
|
2235
2258
|
var import_configs8 = require("@fuel-ts/address/configs");
|
2236
|
-
var
|
2259
|
+
var import_math10 = require("@fuel-ts/math");
|
2237
2260
|
var import_transactions9 = require("@fuel-ts/transactions");
|
2238
2261
|
var import_utils13 = require("@fuel-ts/utils");
|
2239
2262
|
|
2240
2263
|
// src/providers/transaction-request/hash-transaction.ts
|
2241
2264
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2242
2265
|
var import_hasher = require("@fuel-ts/hasher");
|
2243
|
-
var
|
2266
|
+
var import_math9 = require("@fuel-ts/math");
|
2244
2267
|
var import_transactions8 = require("@fuel-ts/transactions");
|
2245
2268
|
var import_utils11 = require("@fuel-ts/utils");
|
2246
2269
|
var import_ramda2 = require("ramda");
|
@@ -2257,11 +2280,11 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2257
2280
|
blockHeight: 0,
|
2258
2281
|
txIndex: 0
|
2259
2282
|
};
|
2260
|
-
inputClone.predicateGasUsed = (0,
|
2283
|
+
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
2261
2284
|
return inputClone;
|
2262
2285
|
}
|
2263
2286
|
case import_transactions8.InputType.Message: {
|
2264
|
-
inputClone.predicateGasUsed = (0,
|
2287
|
+
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
2265
2288
|
return inputClone;
|
2266
2289
|
}
|
2267
2290
|
case import_transactions8.InputType.Contract: {
|
@@ -2288,12 +2311,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2288
2311
|
return outputClone;
|
2289
2312
|
}
|
2290
2313
|
case import_transactions8.OutputType.Change: {
|
2291
|
-
outputClone.amount = (0,
|
2314
|
+
outputClone.amount = (0, import_math9.bn)(0);
|
2292
2315
|
return outputClone;
|
2293
2316
|
}
|
2294
2317
|
case import_transactions8.OutputType.Variable: {
|
2295
2318
|
outputClone.to = import_configs7.ZeroBytes32;
|
2296
|
-
outputClone.amount = (0,
|
2319
|
+
outputClone.amount = (0, import_math9.bn)(0);
|
2297
2320
|
outputClone.assetId = import_configs7.ZeroBytes32;
|
2298
2321
|
return outputClone;
|
2299
2322
|
}
|
@@ -2371,7 +2394,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2371
2394
|
type: import_transactions9.TransactionType.Create,
|
2372
2395
|
...baseTransaction,
|
2373
2396
|
bytecodeWitnessIndex,
|
2374
|
-
storageSlotsCount: (0,
|
2397
|
+
storageSlotsCount: (0, import_math10.bn)(storageSlots.length),
|
2375
2398
|
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2376
2399
|
storageSlots
|
2377
2400
|
};
|
@@ -2411,7 +2434,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2411
2434
|
}
|
2412
2435
|
metadataGas(gasCosts) {
|
2413
2436
|
return calculateMetadataGasForTxCreate({
|
2414
|
-
contractBytesSize: (0,
|
2437
|
+
contractBytesSize: (0, import_math10.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2415
2438
|
gasCosts,
|
2416
2439
|
stateRootSize: this.storageSlots.length,
|
2417
2440
|
txBytesSize: this.byteSize()
|
@@ -2423,7 +2446,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2423
2446
|
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
2424
2447
|
var import_address2 = require("@fuel-ts/address");
|
2425
2448
|
var import_configs9 = require("@fuel-ts/address/configs");
|
2426
|
-
var
|
2449
|
+
var import_math11 = require("@fuel-ts/math");
|
2427
2450
|
var import_transactions10 = require("@fuel-ts/transactions");
|
2428
2451
|
var import_utils15 = require("@fuel-ts/utils");
|
2429
2452
|
|
@@ -2477,7 +2500,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2477
2500
|
*/
|
2478
2501
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2479
2502
|
super(rest);
|
2480
|
-
this.gasLimit = (0,
|
2503
|
+
this.gasLimit = (0, import_math11.bn)(gasLimit);
|
2481
2504
|
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2482
2505
|
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2483
2506
|
this.abis = rest.abis;
|
@@ -2494,8 +2517,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2494
2517
|
type: import_transactions10.TransactionType.Script,
|
2495
2518
|
scriptGasLimit: this.gasLimit,
|
2496
2519
|
...super.getBaseTransaction(),
|
2497
|
-
scriptLength: (0,
|
2498
|
-
scriptDataLength: (0,
|
2520
|
+
scriptLength: (0, import_math11.bn)(script.length),
|
2521
|
+
scriptDataLength: (0, import_math11.bn)(scriptData.length),
|
2499
2522
|
receiptsRoot: import_configs9.ZeroBytes32,
|
2500
2523
|
script: (0, import_utils15.hexlify)(script),
|
2501
2524
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
@@ -2645,35 +2668,20 @@ var transactionRequestify = (obj) => {
|
|
2645
2668
|
}
|
2646
2669
|
}
|
2647
2670
|
};
|
2648
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2649
|
-
(acc, input) => {
|
2650
|
-
if (input.type === import_transactions11.InputType.Coin && input.owner === owner) {
|
2651
|
-
acc.utxos.push(input.id);
|
2652
|
-
}
|
2653
|
-
if (input.type === import_transactions11.InputType.Message && input.recipient === owner) {
|
2654
|
-
acc.messages.push(input.nonce);
|
2655
|
-
}
|
2656
|
-
return acc;
|
2657
|
-
},
|
2658
|
-
{
|
2659
|
-
utxos: [],
|
2660
|
-
messages: []
|
2661
|
-
}
|
2662
|
-
);
|
2663
2671
|
|
2664
2672
|
// src/providers/transaction-response/transaction-response.ts
|
2665
2673
|
var import_errors13 = require("@fuel-ts/errors");
|
2666
|
-
var
|
2674
|
+
var import_math16 = require("@fuel-ts/math");
|
2667
2675
|
var import_transactions19 = require("@fuel-ts/transactions");
|
2668
2676
|
var import_utils20 = require("@fuel-ts/utils");
|
2669
2677
|
|
2670
2678
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2671
|
-
var
|
2679
|
+
var import_math15 = require("@fuel-ts/math");
|
2672
2680
|
var import_transactions17 = require("@fuel-ts/transactions");
|
2673
2681
|
var import_utils18 = require("@fuel-ts/utils");
|
2674
2682
|
|
2675
2683
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2676
|
-
var
|
2684
|
+
var import_math12 = require("@fuel-ts/math");
|
2677
2685
|
var import_transactions12 = require("@fuel-ts/transactions");
|
2678
2686
|
var import_utils16 = require("@fuel-ts/utils");
|
2679
2687
|
var calculateTransactionFee = (params) => {
|
@@ -2683,23 +2691,23 @@ var calculateTransactionFee = (params) => {
|
|
2683
2691
|
tip,
|
2684
2692
|
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
2685
2693
|
} = params;
|
2686
|
-
const gasPerByte = (0,
|
2687
|
-
const gasPriceFactor = (0,
|
2694
|
+
const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
|
2695
|
+
const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
|
2688
2696
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2689
2697
|
const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
|
2690
2698
|
if (transaction.type === import_transactions12.TransactionType.Mint) {
|
2691
2699
|
return {
|
2692
|
-
fee: (0,
|
2693
|
-
minFee: (0,
|
2694
|
-
maxFee: (0,
|
2700
|
+
fee: (0, import_math12.bn)(0),
|
2701
|
+
minFee: (0, import_math12.bn)(0),
|
2702
|
+
maxFee: (0, import_math12.bn)(0)
|
2695
2703
|
};
|
2696
2704
|
}
|
2697
2705
|
const { type, witnesses, inputs, policies } = transaction;
|
2698
|
-
let metadataGas = (0,
|
2699
|
-
let gasLimit = (0,
|
2706
|
+
let metadataGas = (0, import_math12.bn)(0);
|
2707
|
+
let gasLimit = (0, import_math12.bn)(0);
|
2700
2708
|
if (type === import_transactions12.TransactionType.Create) {
|
2701
2709
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2702
|
-
const contractBytesSize = (0,
|
2710
|
+
const contractBytesSize = (0, import_math12.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2703
2711
|
metadataGas = calculateMetadataGasForTxCreate({
|
2704
2712
|
contractBytesSize,
|
2705
2713
|
gasCosts,
|
@@ -2718,7 +2726,7 @@ var calculateTransactionFee = (params) => {
|
|
2718
2726
|
}
|
2719
2727
|
const minGas = getMinGas({
|
2720
2728
|
gasCosts,
|
2721
|
-
gasPerByte: (0,
|
2729
|
+
gasPerByte: (0, import_math12.bn)(gasPerByte),
|
2722
2730
|
inputs,
|
2723
2731
|
metadataGas,
|
2724
2732
|
txBytesSize: transactionBytes.length
|
@@ -2755,12 +2763,12 @@ var calculateTransactionFee = (params) => {
|
|
2755
2763
|
// src/providers/transaction-summary/operations.ts
|
2756
2764
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2757
2765
|
var import_errors11 = require("@fuel-ts/errors");
|
2758
|
-
var
|
2766
|
+
var import_math14 = require("@fuel-ts/math");
|
2759
2767
|
var import_transactions15 = require("@fuel-ts/transactions");
|
2760
2768
|
|
2761
2769
|
// src/providers/transaction-summary/call.ts
|
2762
2770
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
2763
|
-
var
|
2771
|
+
var import_math13 = require("@fuel-ts/math");
|
2764
2772
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2765
2773
|
const abiInterface = new import_abi_coder4.Interface(abi);
|
2766
2774
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2769,7 +2777,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2769
2777
|
let encodedArgs;
|
2770
2778
|
if (functionFragment.isInputDataPointer) {
|
2771
2779
|
if (rawPayload) {
|
2772
|
-
const argsOffset = (0,
|
2780
|
+
const argsOffset = (0, import_math13.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2773
2781
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2774
2782
|
}
|
2775
2783
|
} else {
|
@@ -2925,7 +2933,7 @@ var mergeAssets = (op1, op2) => {
|
|
2925
2933
|
if (!matchingAsset) {
|
2926
2934
|
return asset1;
|
2927
2935
|
}
|
2928
|
-
const mergedAmount = (0,
|
2936
|
+
const mergedAmount = (0, import_math14.bn)(asset1.amount).add(matchingAsset.amount);
|
2929
2937
|
return { ...asset1, amount: mergedAmount };
|
2930
2938
|
});
|
2931
2939
|
return mergedAssets.concat(filteredAssets);
|
@@ -3331,7 +3339,7 @@ function assembleTransactionSummary(params) {
|
|
3331
3339
|
maxInputs
|
3332
3340
|
});
|
3333
3341
|
const typeName = getTransactionTypeName(transaction.type);
|
3334
|
-
const tip = (0,
|
3342
|
+
const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
3335
3343
|
const { fee } = calculateTransactionFee({
|
3336
3344
|
gasPrice,
|
3337
3345
|
rawPayload,
|
@@ -3398,7 +3406,7 @@ var TransactionResponse = class {
|
|
3398
3406
|
/** Current provider */
|
3399
3407
|
provider;
|
3400
3408
|
/** Gas used on the transaction */
|
3401
|
-
gasUsed = (0,
|
3409
|
+
gasUsed = (0, import_math16.bn)(0);
|
3402
3410
|
/** The graphql Transaction with receipts object. */
|
3403
3411
|
gqlTransaction;
|
3404
3412
|
abis;
|
@@ -3622,30 +3630,30 @@ var processGqlChain = (chain) => {
|
|
3622
3630
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3623
3631
|
return {
|
3624
3632
|
name,
|
3625
|
-
baseChainHeight: (0,
|
3633
|
+
baseChainHeight: (0, import_math17.bn)(daHeight),
|
3626
3634
|
consensusParameters: {
|
3627
|
-
contractMaxSize: (0,
|
3628
|
-
maxInputs: (0,
|
3629
|
-
maxOutputs: (0,
|
3630
|
-
maxWitnesses: (0,
|
3631
|
-
maxGasPerTx: (0,
|
3632
|
-
maxScriptLength: (0,
|
3633
|
-
maxScriptDataLength: (0,
|
3634
|
-
maxStorageSlots: (0,
|
3635
|
-
maxPredicateLength: (0,
|
3636
|
-
maxPredicateDataLength: (0,
|
3637
|
-
maxGasPerPredicate: (0,
|
3638
|
-
gasPriceFactor: (0,
|
3639
|
-
gasPerByte: (0,
|
3640
|
-
maxMessageDataLength: (0,
|
3641
|
-
chainId: (0,
|
3635
|
+
contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
|
3636
|
+
maxInputs: (0, import_math17.bn)(txParams.maxInputs),
|
3637
|
+
maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
|
3638
|
+
maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
|
3639
|
+
maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
|
3640
|
+
maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
|
3641
|
+
maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength),
|
3642
|
+
maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots),
|
3643
|
+
maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
|
3644
|
+
maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
|
3645
|
+
maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
|
3646
|
+
gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor),
|
3647
|
+
gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
|
3648
|
+
maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength),
|
3649
|
+
chainId: (0, import_math17.bn)(consensusParameters.chainId),
|
3642
3650
|
baseAssetId: consensusParameters.baseAssetId,
|
3643
3651
|
gasCosts
|
3644
3652
|
},
|
3645
3653
|
gasCosts,
|
3646
3654
|
latestBlock: {
|
3647
3655
|
id: latestBlock.id,
|
3648
|
-
height: (0,
|
3656
|
+
height: (0, import_math17.bn)(latestBlock.height),
|
3649
3657
|
time: latestBlock.header.time,
|
3650
3658
|
transactions: latestBlock.transactions.map((i) => ({
|
3651
3659
|
id: i.id
|
@@ -3788,7 +3796,18 @@ var _Provider = class {
|
|
3788
3796
|
createOperations() {
|
3789
3797
|
const fetchFn = _Provider.getFetchFn(this.options);
|
3790
3798
|
const gqlClient = new import_graphql_request.GraphQLClient(this.url, {
|
3791
|
-
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
|
3799
|
+
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
3800
|
+
responseMiddleware: (response) => {
|
3801
|
+
if ("response" in response) {
|
3802
|
+
const graphQlResponse = response.response;
|
3803
|
+
if (Array.isArray(graphQlResponse?.errors)) {
|
3804
|
+
throw new import_errors14.FuelError(
|
3805
|
+
import_errors14.FuelError.CODES.INVALID_REQUEST,
|
3806
|
+
graphQlResponse.errors.map((err) => err.message).join("\n\n")
|
3807
|
+
);
|
3808
|
+
}
|
3809
|
+
}
|
3810
|
+
}
|
3792
3811
|
});
|
3793
3812
|
const executeQuery = (query, vars) => {
|
3794
3813
|
const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
|
@@ -3823,7 +3842,7 @@ var _Provider = class {
|
|
3823
3842
|
*/
|
3824
3843
|
async getBlockNumber() {
|
3825
3844
|
const { chain } = await this.operations.getChain();
|
3826
|
-
return (0,
|
3845
|
+
return (0, import_math17.bn)(chain.latestBlock.height, 10);
|
3827
3846
|
}
|
3828
3847
|
/**
|
3829
3848
|
* Returns the chain information.
|
@@ -3833,8 +3852,8 @@ var _Provider = class {
|
|
3833
3852
|
async fetchNode() {
|
3834
3853
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3835
3854
|
const processedNodeInfo = {
|
3836
|
-
maxDepth: (0,
|
3837
|
-
maxTx: (0,
|
3855
|
+
maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
|
3856
|
+
maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
|
3838
3857
|
nodeVersion: nodeInfo.nodeVersion,
|
3839
3858
|
utxoValidation: nodeInfo.utxoValidation,
|
3840
3859
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -3951,7 +3970,7 @@ var _Provider = class {
|
|
3951
3970
|
async estimatePredicates(transactionRequest) {
|
3952
3971
|
const shouldEstimatePredicates = Boolean(
|
3953
3972
|
transactionRequest.inputs.find(
|
3954
|
-
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new
|
3973
|
+
(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()
|
3955
3974
|
)
|
3956
3975
|
);
|
3957
3976
|
if (!shouldEstimatePredicates) {
|
@@ -3966,7 +3985,7 @@ var _Provider = class {
|
|
3966
3985
|
} = response;
|
3967
3986
|
if (inputs) {
|
3968
3987
|
inputs.forEach((input, index) => {
|
3969
|
-
if ("predicateGasUsed" in input && (0,
|
3988
|
+
if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
|
3970
3989
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3971
3990
|
}
|
3972
3991
|
});
|
@@ -4124,12 +4143,12 @@ var _Provider = class {
|
|
4124
4143
|
gasPrice = await this.estimateGasPrice(10);
|
4125
4144
|
}
|
4126
4145
|
const minFee = calculateGasFee({
|
4127
|
-
gasPrice: (0,
|
4146
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4128
4147
|
gas: minGas,
|
4129
4148
|
priceFactor: gasPriceFactor,
|
4130
4149
|
tip: transactionRequest.tip
|
4131
4150
|
}).add(1);
|
4132
|
-
let gasLimit = (0,
|
4151
|
+
let gasLimit = (0, import_math17.bn)(0);
|
4133
4152
|
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4134
4153
|
gasLimit = transactionRequest.gasLimit;
|
4135
4154
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4142,7 +4161,7 @@ var _Provider = class {
|
|
4142
4161
|
}
|
4143
4162
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4144
4163
|
const maxFee = calculateGasFee({
|
4145
|
-
gasPrice: (0,
|
4164
|
+
gasPrice: (0, import_math17.bn)(gasPrice),
|
4146
4165
|
gas: maxGas,
|
4147
4166
|
priceFactor: gasPriceFactor,
|
4148
4167
|
tip: transactionRequest.tip
|
@@ -4205,9 +4224,9 @@ var _Provider = class {
|
|
4205
4224
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4206
4225
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4207
4226
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4208
|
-
txRequestClone.maxFee = (0,
|
4227
|
+
txRequestClone.maxFee = (0, import_math17.bn)(0);
|
4209
4228
|
if (isScriptTransaction) {
|
4210
|
-
txRequestClone.gasLimit = (0,
|
4229
|
+
txRequestClone.gasLimit = (0, import_math17.bn)(0);
|
4211
4230
|
}
|
4212
4231
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4213
4232
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4226,7 +4245,7 @@ var _Provider = class {
|
|
4226
4245
|
let receipts = [];
|
4227
4246
|
let missingContractIds = [];
|
4228
4247
|
let outputVariables = 0;
|
4229
|
-
let gasUsed = (0,
|
4248
|
+
let gasUsed = (0, import_math17.bn)(0);
|
4230
4249
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
4231
4250
|
txRequestClone.maxFee = maxFee;
|
4232
4251
|
if (isScriptTransaction) {
|
@@ -4293,10 +4312,10 @@ var _Provider = class {
|
|
4293
4312
|
return coins.map((coin) => ({
|
4294
4313
|
id: coin.utxoId,
|
4295
4314
|
assetId: coin.assetId,
|
4296
|
-
amount: (0,
|
4315
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4297
4316
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4298
|
-
blockCreated: (0,
|
4299
|
-
txCreatedIdx: (0,
|
4317
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4318
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4300
4319
|
}));
|
4301
4320
|
}
|
4302
4321
|
/**
|
@@ -4333,9 +4352,9 @@ var _Provider = class {
|
|
4333
4352
|
switch (coin.__typename) {
|
4334
4353
|
case "MessageCoin":
|
4335
4354
|
return {
|
4336
|
-
amount: (0,
|
4355
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4337
4356
|
assetId: coin.assetId,
|
4338
|
-
daHeight: (0,
|
4357
|
+
daHeight: (0, import_math17.bn)(coin.daHeight),
|
4339
4358
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4340
4359
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4341
4360
|
nonce: coin.nonce
|
@@ -4343,11 +4362,11 @@ var _Provider = class {
|
|
4343
4362
|
case "Coin":
|
4344
4363
|
return {
|
4345
4364
|
id: coin.utxoId,
|
4346
|
-
amount: (0,
|
4365
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4347
4366
|
assetId: coin.assetId,
|
4348
4367
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4349
|
-
blockCreated: (0,
|
4350
|
-
txCreatedIdx: (0,
|
4368
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4369
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4351
4370
|
};
|
4352
4371
|
default:
|
4353
4372
|
return null;
|
@@ -4364,13 +4383,13 @@ var _Provider = class {
|
|
4364
4383
|
async getBlock(idOrHeight) {
|
4365
4384
|
let variables;
|
4366
4385
|
if (typeof idOrHeight === "number") {
|
4367
|
-
variables = { height: (0,
|
4386
|
+
variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4368
4387
|
} else if (idOrHeight === "latest") {
|
4369
4388
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4370
4389
|
} else if (idOrHeight.length === 66) {
|
4371
4390
|
variables = { blockId: idOrHeight };
|
4372
4391
|
} else {
|
4373
|
-
variables = { blockId: (0,
|
4392
|
+
variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4374
4393
|
}
|
4375
4394
|
const { block } = await this.operations.getBlock(variables);
|
4376
4395
|
if (!block) {
|
@@ -4378,7 +4397,7 @@ var _Provider = class {
|
|
4378
4397
|
}
|
4379
4398
|
return {
|
4380
4399
|
id: block.id,
|
4381
|
-
height: (0,
|
4400
|
+
height: (0, import_math17.bn)(block.height),
|
4382
4401
|
time: block.header.time,
|
4383
4402
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4384
4403
|
};
|
@@ -4393,7 +4412,7 @@ var _Provider = class {
|
|
4393
4412
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4394
4413
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4395
4414
|
id: block.id,
|
4396
|
-
height: (0,
|
4415
|
+
height: (0, import_math17.bn)(block.height),
|
4397
4416
|
time: block.header.time,
|
4398
4417
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4399
4418
|
}));
|
@@ -4408,7 +4427,7 @@ var _Provider = class {
|
|
4408
4427
|
async getBlockWithTransactions(idOrHeight) {
|
4409
4428
|
let variables;
|
4410
4429
|
if (typeof idOrHeight === "number") {
|
4411
|
-
variables = { blockHeight: (0,
|
4430
|
+
variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
|
4412
4431
|
} else if (idOrHeight === "latest") {
|
4413
4432
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4414
4433
|
} else {
|
@@ -4420,7 +4439,7 @@ var _Provider = class {
|
|
4420
4439
|
}
|
4421
4440
|
return {
|
4422
4441
|
id: block.id,
|
4423
|
-
height: (0,
|
4442
|
+
height: (0, import_math17.bn)(block.height, 10),
|
4424
4443
|
time: block.header.time,
|
4425
4444
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4426
4445
|
transactions: block.transactions.map(
|
@@ -4469,7 +4488,7 @@ var _Provider = class {
|
|
4469
4488
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4470
4489
|
asset: (0, import_utils22.hexlify)(assetId)
|
4471
4490
|
});
|
4472
|
-
return (0,
|
4491
|
+
return (0, import_math17.bn)(contractBalance.amount, 10);
|
4473
4492
|
}
|
4474
4493
|
/**
|
4475
4494
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4483,7 +4502,7 @@ var _Provider = class {
|
|
4483
4502
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4484
4503
|
assetId: (0, import_utils22.hexlify)(assetId)
|
4485
4504
|
});
|
4486
|
-
return (0,
|
4505
|
+
return (0, import_math17.bn)(balance.amount, 10);
|
4487
4506
|
}
|
4488
4507
|
/**
|
4489
4508
|
* Returns balances for the given owner.
|
@@ -4501,7 +4520,7 @@ var _Provider = class {
|
|
4501
4520
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4502
4521
|
return balances.map((balance) => ({
|
4503
4522
|
assetId: balance.assetId,
|
4504
|
-
amount: (0,
|
4523
|
+
amount: (0, import_math17.bn)(balance.amount)
|
4505
4524
|
}));
|
4506
4525
|
}
|
4507
4526
|
/**
|
@@ -4523,15 +4542,15 @@ var _Provider = class {
|
|
4523
4542
|
sender: message.sender,
|
4524
4543
|
recipient: message.recipient,
|
4525
4544
|
nonce: message.nonce,
|
4526
|
-
amount: (0,
|
4545
|
+
amount: (0, import_math17.bn)(message.amount),
|
4527
4546
|
data: message.data
|
4528
4547
|
}),
|
4529
4548
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4530
4549
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4531
4550
|
nonce: message.nonce,
|
4532
|
-
amount: (0,
|
4551
|
+
amount: (0, import_math17.bn)(message.amount),
|
4533
4552
|
data: import_transactions20.InputMessageCoder.decodeData(message.data),
|
4534
|
-
daHeight: (0,
|
4553
|
+
daHeight: (0, import_math17.bn)(message.daHeight)
|
4535
4554
|
}));
|
4536
4555
|
}
|
4537
4556
|
/**
|
@@ -4584,23 +4603,23 @@ var _Provider = class {
|
|
4584
4603
|
} = result.messageProof;
|
4585
4604
|
return {
|
4586
4605
|
messageProof: {
|
4587
|
-
proofIndex: (0,
|
4606
|
+
proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
|
4588
4607
|
proofSet: messageProof.proofSet
|
4589
4608
|
},
|
4590
4609
|
blockProof: {
|
4591
|
-
proofIndex: (0,
|
4610
|
+
proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
|
4592
4611
|
proofSet: blockProof.proofSet
|
4593
4612
|
},
|
4594
4613
|
messageBlockHeader: {
|
4595
4614
|
id: messageBlockHeader.id,
|
4596
|
-
daHeight: (0,
|
4597
|
-
transactionsCount: (0,
|
4615
|
+
daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
|
4616
|
+
transactionsCount: (0, import_math17.bn)(messageBlockHeader.transactionsCount),
|
4598
4617
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4599
|
-
height: (0,
|
4618
|
+
height: (0, import_math17.bn)(messageBlockHeader.height),
|
4600
4619
|
prevRoot: messageBlockHeader.prevRoot,
|
4601
4620
|
time: messageBlockHeader.time,
|
4602
4621
|
applicationHash: messageBlockHeader.applicationHash,
|
4603
|
-
messageReceiptCount: (0,
|
4622
|
+
messageReceiptCount: (0, import_math17.bn)(messageBlockHeader.messageReceiptCount),
|
4604
4623
|
messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
|
4605
4624
|
consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
|
4606
4625
|
eventInboxRoot: messageBlockHeader.eventInboxRoot,
|
@@ -4608,14 +4627,14 @@ var _Provider = class {
|
|
4608
4627
|
},
|
4609
4628
|
commitBlockHeader: {
|
4610
4629
|
id: commitBlockHeader.id,
|
4611
|
-
daHeight: (0,
|
4612
|
-
transactionsCount: (0,
|
4630
|
+
daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
|
4631
|
+
transactionsCount: (0, import_math17.bn)(commitBlockHeader.transactionsCount),
|
4613
4632
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4614
|
-
height: (0,
|
4633
|
+
height: (0, import_math17.bn)(commitBlockHeader.height),
|
4615
4634
|
prevRoot: commitBlockHeader.prevRoot,
|
4616
4635
|
time: commitBlockHeader.time,
|
4617
4636
|
applicationHash: commitBlockHeader.applicationHash,
|
4618
|
-
messageReceiptCount: (0,
|
4637
|
+
messageReceiptCount: (0, import_math17.bn)(commitBlockHeader.messageReceiptCount),
|
4619
4638
|
messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
|
4620
4639
|
consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
|
4621
4640
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
@@ -4624,19 +4643,19 @@ var _Provider = class {
|
|
4624
4643
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4625
4644
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4626
4645
|
nonce,
|
4627
|
-
amount: (0,
|
4646
|
+
amount: (0, import_math17.bn)(amount),
|
4628
4647
|
data
|
4629
4648
|
};
|
4630
4649
|
}
|
4631
4650
|
async getLatestGasPrice() {
|
4632
4651
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4633
|
-
return (0,
|
4652
|
+
return (0, import_math17.bn)(latestGasPrice.gasPrice);
|
4634
4653
|
}
|
4635
4654
|
async estimateGasPrice(blockHorizon) {
|
4636
4655
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4637
4656
|
blockHorizon: String(blockHorizon)
|
4638
4657
|
});
|
4639
|
-
return (0,
|
4658
|
+
return (0, import_math17.bn)(estimateGasPrice.gasPrice);
|
4640
4659
|
}
|
4641
4660
|
/**
|
4642
4661
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4657,10 +4676,10 @@ var _Provider = class {
|
|
4657
4676
|
*/
|
4658
4677
|
async produceBlocks(amount, startTime) {
|
4659
4678
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4660
|
-
blocksToProduce: (0,
|
4679
|
+
blocksToProduce: (0, import_math17.bn)(amount).toString(10),
|
4661
4680
|
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4662
4681
|
});
|
4663
|
-
return (0,
|
4682
|
+
return (0, import_math17.bn)(latestBlockHeight);
|
4664
4683
|
}
|
4665
4684
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4666
4685
|
async getTransactionResponse(transactionId) {
|
@@ -4697,7 +4716,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4697
4716
|
|
4698
4717
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4699
4718
|
var import_errors15 = require("@fuel-ts/errors");
|
4700
|
-
var
|
4719
|
+
var import_math18 = require("@fuel-ts/math");
|
4701
4720
|
var import_transactions21 = require("@fuel-ts/transactions");
|
4702
4721
|
var import_utils25 = require("@fuel-ts/utils");
|
4703
4722
|
|
@@ -4748,13 +4767,13 @@ var assets = [
|
|
4748
4767
|
|
4749
4768
|
// src/utils/formatTransferToContractScriptData.ts
|
4750
4769
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4751
|
-
var
|
4770
|
+
var import_math19 = require("@fuel-ts/math");
|
4752
4771
|
var import_utils26 = require("@fuel-ts/utils");
|
4753
4772
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4754
4773
|
var formatTransferToContractScriptData = (params) => {
|
4755
4774
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4756
4775
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
4757
|
-
const encoded = numberCoder.encode(new
|
4776
|
+
const encoded = numberCoder.encode(new import_math19.BN(amountToTransfer).toNumber());
|
4758
4777
|
const scriptData = Uint8Array.from([
|
4759
4778
|
...(0, import_utils26.arrayify)(hexlifiedContractId),
|
4760
4779
|
...encoded,
|
@@ -4783,6 +4802,7 @@ var assembleTransferToContractScript = async (params) => {
|
|
4783
4802
|
};
|
4784
4803
|
|
4785
4804
|
// src/account.ts
|
4805
|
+
var MAX_FUNDING_ATTEMPTS = 2;
|
4786
4806
|
var Account = class extends import_interfaces.AbstractAccount {
|
4787
4807
|
/**
|
4788
4808
|
* The address associated with the account.
|
@@ -4940,16 +4960,17 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4940
4960
|
* Adds resources to the transaction enough to fund it.
|
4941
4961
|
*
|
4942
4962
|
* @param request - The transaction request.
|
4943
|
-
* @param
|
4963
|
+
* @param requiredQuantities - The coin quantities required to execute the transaction.
|
4944
4964
|
* @param fee - The estimated transaction fee.
|
4945
4965
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4946
4966
|
*/
|
4947
4967
|
async fund(request, params) {
|
4948
4968
|
const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
|
4949
4969
|
const baseAssetId = this.provider.getBaseAssetId();
|
4970
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
|
4950
4971
|
const txRequest = request;
|
4951
4972
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
4952
|
-
amount: (0,
|
4973
|
+
amount: (0, import_math20.bn)(fee),
|
4953
4974
|
assetId: baseAssetId,
|
4954
4975
|
coinQuantities: requiredQuantities
|
4955
4976
|
});
|
@@ -4957,21 +4978,17 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4957
4978
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
4958
4979
|
quantitiesDict[assetId] = {
|
4959
4980
|
required: amount,
|
4960
|
-
owned: (0,
|
4981
|
+
owned: (0, import_math20.bn)(0)
|
4961
4982
|
};
|
4962
4983
|
});
|
4963
|
-
|
4964
|
-
const
|
4965
|
-
if (!isResource) {
|
4966
|
-
return;
|
4967
|
-
}
|
4968
|
-
const isCoin2 = "owner" in input;
|
4984
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
4985
|
+
const isCoin2 = isRequestInputCoin(input);
|
4969
4986
|
const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
|
4970
4987
|
if (quantitiesDict[assetId]) {
|
4971
4988
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
|
4972
4989
|
}
|
4973
4990
|
});
|
4974
|
-
|
4991
|
+
let missingQuantities = [];
|
4975
4992
|
Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
|
4976
4993
|
if (owned.lt(required)) {
|
4977
4994
|
missingQuantities.push({
|
@@ -4980,11 +4997,42 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4980
4997
|
});
|
4981
4998
|
}
|
4982
4999
|
});
|
4983
|
-
|
4984
|
-
|
4985
|
-
|
4986
|
-
const resources = await this.getResourcesToSpend(
|
4987
|
-
|
5000
|
+
let needsToBeFunded = missingQuantities.length > 0;
|
5001
|
+
let fundingAttempts = 0;
|
5002
|
+
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5003
|
+
const resources = await this.getResourcesToSpend(
|
5004
|
+
missingQuantities,
|
5005
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5006
|
+
);
|
5007
|
+
request.addResources(resources);
|
5008
|
+
txRequest.shiftPredicateData();
|
5009
|
+
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
5010
|
+
const requestToReestimate2 = (0, import_ramda4.clone)(txRequest);
|
5011
|
+
if (addedSignatures) {
|
5012
|
+
Array.from({ length: addedSignatures }).forEach(
|
5013
|
+
() => requestToReestimate2.addEmptyWitness()
|
5014
|
+
);
|
5015
|
+
}
|
5016
|
+
const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
|
5017
|
+
transactionRequest: requestToReestimate2
|
5018
|
+
});
|
5019
|
+
const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
|
5020
|
+
request.inputs,
|
5021
|
+
baseAssetId,
|
5022
|
+
baseAssetId
|
5023
|
+
);
|
5024
|
+
const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
|
5025
|
+
if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
|
5026
|
+
needsToBeFunded = false;
|
5027
|
+
} else {
|
5028
|
+
missingQuantities = [
|
5029
|
+
{
|
5030
|
+
amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
|
5031
|
+
assetId: baseAssetId
|
5032
|
+
}
|
5033
|
+
];
|
5034
|
+
}
|
5035
|
+
fundingAttempts += 1;
|
4988
5036
|
}
|
4989
5037
|
txRequest.shiftPredicateData();
|
4990
5038
|
txRequest.updatePredicateGasUsed(estimatedPredicates);
|
@@ -5035,7 +5083,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5035
5083
|
* @returns A promise that resolves to the transaction response.
|
5036
5084
|
*/
|
5037
5085
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5038
|
-
if ((0,
|
5086
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5039
5087
|
throw new import_errors16.FuelError(
|
5040
5088
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5041
5089
|
"Transfer amount must be a positive number."
|
@@ -5055,7 +5103,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5055
5103
|
* @returns A promise that resolves to the transaction response.
|
5056
5104
|
*/
|
5057
5105
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5058
|
-
if ((0,
|
5106
|
+
if ((0, import_math20.bn)(amount).lte(0)) {
|
5059
5107
|
throw new import_errors16.FuelError(
|
5060
5108
|
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5061
5109
|
"Transfer amount must be a positive number."
|
@@ -5065,7 +5113,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5065
5113
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5066
5114
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5067
5115
|
hexlifiedContractId: contractAddress.toB256(),
|
5068
|
-
amountToTransfer: (0,
|
5116
|
+
amountToTransfer: (0, import_math20.bn)(amount),
|
5069
5117
|
assetId: assetIdToTransfer
|
5070
5118
|
});
|
5071
5119
|
const request = new ScriptTransactionRequest({
|
@@ -5076,7 +5124,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5076
5124
|
request.addContractInputAndOutput(contractAddress);
|
5077
5125
|
const txCost = await this.provider.getTransactionCost(request, {
|
5078
5126
|
resourcesOwner: this,
|
5079
|
-
quantitiesToContract: [{ amount: (0,
|
5127
|
+
quantitiesToContract: [{ amount: (0, import_math20.bn)(amount), assetId: String(assetIdToTransfer) }]
|
5080
5128
|
});
|
5081
5129
|
this.validateGasLimitAndMaxFee({
|
5082
5130
|
gasUsed: txCost.gasUsed,
|
@@ -5102,7 +5150,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5102
5150
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5103
5151
|
);
|
5104
5152
|
const amountDataArray = (0, import_utils27.arrayify)(
|
5105
|
-
"0x".concat((0,
|
5153
|
+
"0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5106
5154
|
);
|
5107
5155
|
const script = new Uint8Array([
|
5108
5156
|
...(0, import_utils27.arrayify)(withdrawScript.bytes),
|
@@ -5112,7 +5160,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5112
5160
|
const params = { script, ...txParams };
|
5113
5161
|
const baseAssetId = this.provider.getBaseAssetId();
|
5114
5162
|
const request = new ScriptTransactionRequest(params);
|
5115
|
-
const quantitiesToContract = [{ amount: (0,
|
5163
|
+
const quantitiesToContract = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
|
5116
5164
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5117
5165
|
this.validateGasLimitAndMaxFee({
|
5118
5166
|
gasUsed: txCost.gasUsed,
|
@@ -5203,7 +5251,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5203
5251
|
var import_address5 = require("@fuel-ts/address");
|
5204
5252
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5205
5253
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5206
|
-
var
|
5254
|
+
var import_math21 = require("@fuel-ts/math");
|
5207
5255
|
var import_utils28 = require("@fuel-ts/utils");
|
5208
5256
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5209
5257
|
var Signer = class {
|
@@ -5223,7 +5271,7 @@ var Signer = class {
|
|
5223
5271
|
privateKey = `0x${privateKey}`;
|
5224
5272
|
}
|
5225
5273
|
}
|
5226
|
-
const privateKeyBytes = (0,
|
5274
|
+
const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
|
5227
5275
|
this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
|
5228
5276
|
this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5229
5277
|
this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
@@ -5241,8 +5289,8 @@ var Signer = class {
|
|
5241
5289
|
*/
|
5242
5290
|
sign(data) {
|
5243
5291
|
const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
|
5244
|
-
const r = (0,
|
5245
|
-
const s = (0,
|
5292
|
+
const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5293
|
+
const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5246
5294
|
s[0] |= (signature.recovery || 0) << 7;
|
5247
5295
|
return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
|
5248
5296
|
}
|
@@ -5514,7 +5562,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
5514
5562
|
// src/hdwallet/hdwallet.ts
|
5515
5563
|
var import_errors20 = require("@fuel-ts/errors");
|
5516
5564
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5517
|
-
var
|
5565
|
+
var import_math22 = require("@fuel-ts/math");
|
5518
5566
|
var import_utils34 = require("@fuel-ts/utils");
|
5519
5567
|
var import_ethers2 = require("ethers");
|
5520
5568
|
|
@@ -7974,13 +8022,13 @@ var HDWallet = class {
|
|
7974
8022
|
} else {
|
7975
8023
|
data.set((0, import_utils34.arrayify)(this.publicKey));
|
7976
8024
|
}
|
7977
|
-
data.set((0,
|
8025
|
+
data.set((0, import_math22.toBytes)(index, 4), 33);
|
7978
8026
|
const bytes = (0, import_utils34.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
|
7979
8027
|
const IL = bytes.slice(0, 32);
|
7980
8028
|
const IR = bytes.slice(32);
|
7981
8029
|
if (privateKey) {
|
7982
8030
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7983
|
-
const ki = (0,
|
8031
|
+
const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
7984
8032
|
return new HDWallet({
|
7985
8033
|
privateKey: ki,
|
7986
8034
|
chainCode: IR,
|
@@ -8026,7 +8074,7 @@ var HDWallet = class {
|
|
8026
8074
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8027
8075
|
const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
|
8028
8076
|
const parentFingerprint = this.parentFingerprint;
|
8029
|
-
const index = (0,
|
8077
|
+
const index = (0, import_math22.toHex)(this.index, 4);
|
8030
8078
|
const chainCode = this.chainCode;
|
8031
8079
|
const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8032
8080
|
const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
@@ -8485,14 +8533,14 @@ var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
|
8485
8533
|
var import_address7 = require("@fuel-ts/address");
|
8486
8534
|
var import_configs11 = require("@fuel-ts/address/configs");
|
8487
8535
|
var import_crypto8 = require("@fuel-ts/crypto");
|
8488
|
-
var
|
8536
|
+
var import_math23 = require("@fuel-ts/math");
|
8489
8537
|
var import_transactions22 = require("@fuel-ts/transactions");
|
8490
8538
|
var import_utils36 = require("@fuel-ts/utils");
|
8491
8539
|
var generateFakeRequestInputCoin = (partial = {}) => ({
|
8492
8540
|
id: (0, import_utils36.hexlify)((0, import_crypto8.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
|
8493
8541
|
type: import_transactions22.InputType.Coin,
|
8494
8542
|
owner: (0, import_address7.getRandomB256)(),
|
8495
|
-
amount: (0,
|
8543
|
+
amount: (0, import_math23.bn)(100),
|
8496
8544
|
assetId: import_configs11.ZeroBytes32,
|
8497
8545
|
txPointer: "0x00000000000000000000000000000000",
|
8498
8546
|
witnessIndex: 0,
|
@@ -8503,7 +8551,7 @@ var generateFakeRequestInputMessage = (partial = {}) => ({
|
|
8503
8551
|
type: import_transactions22.InputType.Message,
|
8504
8552
|
sender: (0, import_address7.getRandomB256)(),
|
8505
8553
|
recipient: (0, import_address7.getRandomB256)(),
|
8506
|
-
amount: (0,
|
8554
|
+
amount: (0, import_math23.bn)(100),
|
8507
8555
|
witnessIndex: 0,
|
8508
8556
|
...partial
|
8509
8557
|
});
|