@fuel-ts/account 0.0.0-rc-1356-20240510142347 → 0.0.0-rc-2037-20240510174704
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/index.global.js +102 -45
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +442 -363
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +242 -171
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +9 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +1 -1
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +4 -0
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/index.d.ts +1 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -0
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/utils.d.ts +0 -4
- package/dist/providers/transaction-request/utils.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/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +126 -432
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +427 -642
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +252 -463
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts.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
@@ -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 bn18 } from "@fuel-ts/math";
|
77
77
|
import {
|
78
78
|
InputType as InputType7,
|
79
79
|
TransactionType as TransactionType8,
|
@@ -1296,11 +1296,11 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
1296
1296
|
import { Address, addressify } from "@fuel-ts/address";
|
1297
1297
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1298
1298
|
import { randomBytes } from "@fuel-ts/crypto";
|
1299
|
-
import { bn as
|
1299
|
+
import { bn as bn8 } from "@fuel-ts/math";
|
1300
1300
|
import {
|
1301
1301
|
PolicyType,
|
1302
1302
|
TransactionCoder,
|
1303
|
-
InputType as
|
1303
|
+
InputType as InputType3,
|
1304
1304
|
OutputType as OutputType2,
|
1305
1305
|
TransactionType
|
1306
1306
|
} from "@fuel-ts/transactions";
|
@@ -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";
|
@@ -1814,6 +1823,52 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1814
1823
|
name = "NoWitnessByOwnerError";
|
1815
1824
|
};
|
1816
1825
|
|
1826
|
+
// src/providers/transaction-request/helpers.ts
|
1827
|
+
import { bn as bn7 } from "@fuel-ts/math";
|
1828
|
+
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1829
|
+
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1830
|
+
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1831
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1832
|
+
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
1833
|
+
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
1834
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1835
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1836
|
+
return acc.add(input.amount);
|
1837
|
+
}
|
1838
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1839
|
+
return acc.add(input.amount);
|
1840
|
+
}
|
1841
|
+
return acc;
|
1842
|
+
}, bn7(0));
|
1843
|
+
var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
|
1844
|
+
(cache2, input) => {
|
1845
|
+
if (isRequestInputCoin(input)) {
|
1846
|
+
cache2.utxos.push(input.id);
|
1847
|
+
} else {
|
1848
|
+
cache2.messages.push(input.nonce);
|
1849
|
+
}
|
1850
|
+
return cache2;
|
1851
|
+
},
|
1852
|
+
{
|
1853
|
+
utxos: [],
|
1854
|
+
messages: []
|
1855
|
+
}
|
1856
|
+
);
|
1857
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
1858
|
+
(acc, input) => {
|
1859
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
1860
|
+
acc.utxos.push(input.id);
|
1861
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
1862
|
+
acc.messages.push(input.nonce);
|
1863
|
+
}
|
1864
|
+
return acc;
|
1865
|
+
},
|
1866
|
+
{
|
1867
|
+
utxos: [],
|
1868
|
+
messages: []
|
1869
|
+
}
|
1870
|
+
);
|
1871
|
+
|
1817
1872
|
// src/providers/transaction-request/witness.ts
|
1818
1873
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1819
1874
|
var witnessify = (value) => {
|
@@ -1854,10 +1909,10 @@ var BaseTransactionRequest = class {
|
|
1854
1909
|
outputs,
|
1855
1910
|
witnesses
|
1856
1911
|
} = {}) {
|
1857
|
-
this.tip = tip ?
|
1912
|
+
this.tip = tip ? bn8(tip) : void 0;
|
1858
1913
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1859
|
-
this.witnessLimit = isDefined(witnessLimit) ?
|
1860
|
-
this.maxFee =
|
1914
|
+
this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
|
1915
|
+
this.maxFee = bn8(maxFee);
|
1861
1916
|
this.inputs = inputs ?? [];
|
1862
1917
|
this.outputs = outputs ?? [];
|
1863
1918
|
this.witnesses = witnesses ?? [];
|
@@ -1866,13 +1921,13 @@ var BaseTransactionRequest = class {
|
|
1866
1921
|
let policyTypes = 0;
|
1867
1922
|
const policies = [];
|
1868
1923
|
const { tip, witnessLimit, maturity } = req;
|
1869
|
-
if (
|
1924
|
+
if (bn8(tip).gt(0)) {
|
1870
1925
|
policyTypes += PolicyType.Tip;
|
1871
|
-
policies.push({ data:
|
1926
|
+
policies.push({ data: bn8(tip), type: PolicyType.Tip });
|
1872
1927
|
}
|
1873
|
-
if (isDefined(witnessLimit) &&
|
1928
|
+
if (isDefined(witnessLimit) && bn8(witnessLimit).gte(0)) {
|
1874
1929
|
policyTypes += PolicyType.WitnessLimit;
|
1875
|
-
policies.push({ data:
|
1930
|
+
policies.push({ data: bn8(witnessLimit), type: PolicyType.WitnessLimit });
|
1876
1931
|
}
|
1877
1932
|
if (maturity && maturity > 0) {
|
1878
1933
|
policyTypes += PolicyType.Maturity;
|
@@ -2003,7 +2058,7 @@ var BaseTransactionRequest = class {
|
|
2003
2058
|
*/
|
2004
2059
|
getCoinInputs() {
|
2005
2060
|
return this.inputs.filter(
|
2006
|
-
(input) => input.type ===
|
2061
|
+
(input) => input.type === InputType3.Coin
|
2007
2062
|
);
|
2008
2063
|
}
|
2009
2064
|
/**
|
@@ -2035,9 +2090,9 @@ var BaseTransactionRequest = class {
|
|
2035
2090
|
const ownerAddress = addressify(owner);
|
2036
2091
|
const found = this.inputs.find((input) => {
|
2037
2092
|
switch (input.type) {
|
2038
|
-
case
|
2093
|
+
case InputType3.Coin:
|
2039
2094
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
2040
|
-
case
|
2095
|
+
case InputType3.Message:
|
2041
2096
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
2042
2097
|
default:
|
2043
2098
|
return false;
|
@@ -2052,7 +2107,7 @@ var BaseTransactionRequest = class {
|
|
2052
2107
|
* @param coin - Coin resource.
|
2053
2108
|
*/
|
2054
2109
|
addCoinInput(coin) {
|
2055
|
-
const { assetId, owner, amount } = coin;
|
2110
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
2056
2111
|
let witnessIndex;
|
2057
2112
|
if (coin.predicate) {
|
2058
2113
|
witnessIndex = 0;
|
@@ -2063,13 +2118,14 @@ var BaseTransactionRequest = class {
|
|
2063
2118
|
}
|
2064
2119
|
}
|
2065
2120
|
const input = {
|
2066
|
-
|
2067
|
-
type:
|
2121
|
+
id,
|
2122
|
+
type: InputType3.Coin,
|
2068
2123
|
owner: owner.toB256(),
|
2069
2124
|
amount,
|
2070
2125
|
assetId,
|
2071
2126
|
txPointer: "0x00000000000000000000000000000000",
|
2072
|
-
witnessIndex
|
2127
|
+
witnessIndex,
|
2128
|
+
predicate
|
2073
2129
|
};
|
2074
2130
|
this.pushInput(input);
|
2075
2131
|
this.addChangeOutput(owner, assetId);
|
@@ -2081,7 +2137,7 @@ var BaseTransactionRequest = class {
|
|
2081
2137
|
* @param message - Message resource.
|
2082
2138
|
*/
|
2083
2139
|
addMessageInput(message) {
|
2084
|
-
const { recipient, sender, amount, assetId } = message;
|
2140
|
+
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
2085
2141
|
let witnessIndex;
|
2086
2142
|
if (message.predicate) {
|
2087
2143
|
witnessIndex = 0;
|
@@ -2092,12 +2148,13 @@ var BaseTransactionRequest = class {
|
|
2092
2148
|
}
|
2093
2149
|
}
|
2094
2150
|
const input = {
|
2095
|
-
|
2096
|
-
type:
|
2151
|
+
nonce,
|
2152
|
+
type: InputType3.Message,
|
2097
2153
|
sender: sender.toB256(),
|
2098
2154
|
recipient: recipient.toB256(),
|
2099
2155
|
amount,
|
2100
|
-
witnessIndex
|
2156
|
+
witnessIndex,
|
2157
|
+
predicate
|
2101
2158
|
};
|
2102
2159
|
this.pushInput(input);
|
2103
2160
|
this.addChangeOutput(recipient, assetId);
|
@@ -2244,7 +2301,7 @@ var BaseTransactionRequest = class {
|
|
2244
2301
|
const assetInput = findAssetInput(assetId);
|
2245
2302
|
let usedQuantity = quantity;
|
2246
2303
|
if (assetId === baseAssetId) {
|
2247
|
-
usedQuantity =
|
2304
|
+
usedQuantity = bn8("1000000000000000000");
|
2248
2305
|
}
|
2249
2306
|
if (assetInput && "assetId" in assetInput) {
|
2250
2307
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
@@ -2256,13 +2313,13 @@ var BaseTransactionRequest = class {
|
|
2256
2313
|
amount: usedQuantity,
|
2257
2314
|
assetId,
|
2258
2315
|
owner: resourcesOwner || Address.fromRandom(),
|
2259
|
-
blockCreated:
|
2260
|
-
txCreatedIdx:
|
2316
|
+
blockCreated: bn8(1),
|
2317
|
+
txCreatedIdx: bn8(1)
|
2261
2318
|
}
|
2262
2319
|
]);
|
2263
2320
|
}
|
2264
2321
|
};
|
2265
|
-
updateAssetInput(baseAssetId,
|
2322
|
+
updateAssetInput(baseAssetId, bn8(1e11));
|
2266
2323
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2267
2324
|
}
|
2268
2325
|
/**
|
@@ -2273,7 +2330,7 @@ var BaseTransactionRequest = class {
|
|
2273
2330
|
*/
|
2274
2331
|
getCoinOutputsQuantities() {
|
2275
2332
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2276
|
-
amount:
|
2333
|
+
amount: bn8(amount),
|
2277
2334
|
assetId: assetId.toString()
|
2278
2335
|
}));
|
2279
2336
|
return coinsQuantities;
|
@@ -2287,22 +2344,33 @@ var BaseTransactionRequest = class {
|
|
2287
2344
|
toJSON() {
|
2288
2345
|
return normalizeJSON(this);
|
2289
2346
|
}
|
2347
|
+
removeWitness(index) {
|
2348
|
+
this.witnesses.splice(index, 1);
|
2349
|
+
this.adjustWitnessIndexes(index);
|
2350
|
+
}
|
2351
|
+
adjustWitnessIndexes(removedIndex) {
|
2352
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2353
|
+
if (input.witnessIndex > removedIndex) {
|
2354
|
+
input.witnessIndex -= 1;
|
2355
|
+
}
|
2356
|
+
});
|
2357
|
+
}
|
2290
2358
|
updatePredicateGasUsed(inputs) {
|
2291
2359
|
this.inputs.forEach((i) => {
|
2292
2360
|
let correspondingInput;
|
2293
2361
|
switch (i.type) {
|
2294
|
-
case
|
2295
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2362
|
+
case InputType3.Coin:
|
2363
|
+
correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
|
2296
2364
|
break;
|
2297
|
-
case
|
2365
|
+
case InputType3.Message:
|
2298
2366
|
correspondingInput = inputs.find(
|
2299
|
-
(x) => x.type ===
|
2367
|
+
(x) => x.type === InputType3.Message && x.sender === i.sender
|
2300
2368
|
);
|
2301
2369
|
break;
|
2302
2370
|
default:
|
2303
2371
|
return;
|
2304
2372
|
}
|
2305
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput &&
|
2373
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
|
2306
2374
|
i.predicate = correspondingInput.predicate;
|
2307
2375
|
i.predicateData = correspondingInput.predicateData;
|
2308
2376
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2322,15 +2390,15 @@ var BaseTransactionRequest = class {
|
|
2322
2390
|
|
2323
2391
|
// src/providers/transaction-request/create-transaction-request.ts
|
2324
2392
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2325
|
-
import { bn as
|
2393
|
+
import { bn as bn10 } from "@fuel-ts/math";
|
2326
2394
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2327
2395
|
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2328
2396
|
|
2329
2397
|
// src/providers/transaction-request/hash-transaction.ts
|
2330
2398
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2331
2399
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2332
|
-
import { bn as
|
2333
|
-
import { TransactionType as TransactionType2, InputType as
|
2400
|
+
import { bn as bn9 } from "@fuel-ts/math";
|
2401
|
+
import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2334
2402
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2335
2403
|
import { clone as clone2 } from "ramda";
|
2336
2404
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2341,19 +2409,19 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2341
2409
|
transaction.inputs = transaction.inputs.map((input) => {
|
2342
2410
|
const inputClone = clone2(input);
|
2343
2411
|
switch (inputClone.type) {
|
2344
|
-
case
|
2412
|
+
case InputType4.Coin: {
|
2345
2413
|
inputClone.txPointer = {
|
2346
2414
|
blockHeight: 0,
|
2347
2415
|
txIndex: 0
|
2348
2416
|
};
|
2349
|
-
inputClone.predicateGasUsed =
|
2417
|
+
inputClone.predicateGasUsed = bn9(0);
|
2350
2418
|
return inputClone;
|
2351
2419
|
}
|
2352
|
-
case
|
2353
|
-
inputClone.predicateGasUsed =
|
2420
|
+
case InputType4.Message: {
|
2421
|
+
inputClone.predicateGasUsed = bn9(0);
|
2354
2422
|
return inputClone;
|
2355
2423
|
}
|
2356
|
-
case
|
2424
|
+
case InputType4.Contract: {
|
2357
2425
|
inputClone.txPointer = {
|
2358
2426
|
blockHeight: 0,
|
2359
2427
|
txIndex: 0
|
@@ -2377,12 +2445,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2377
2445
|
return outputClone;
|
2378
2446
|
}
|
2379
2447
|
case OutputType3.Change: {
|
2380
|
-
outputClone.amount =
|
2448
|
+
outputClone.amount = bn9(0);
|
2381
2449
|
return outputClone;
|
2382
2450
|
}
|
2383
2451
|
case OutputType3.Variable: {
|
2384
2452
|
outputClone.to = ZeroBytes325;
|
2385
|
-
outputClone.amount =
|
2453
|
+
outputClone.amount = bn9(0);
|
2386
2454
|
outputClone.assetId = ZeroBytes325;
|
2387
2455
|
return outputClone;
|
2388
2456
|
}
|
@@ -2460,7 +2528,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2460
2528
|
type: TransactionType3.Create,
|
2461
2529
|
...baseTransaction,
|
2462
2530
|
bytecodeWitnessIndex,
|
2463
|
-
storageSlotsCount:
|
2531
|
+
storageSlotsCount: bn10(storageSlots.length),
|
2464
2532
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2465
2533
|
storageSlots
|
2466
2534
|
};
|
@@ -2500,7 +2568,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2500
2568
|
}
|
2501
2569
|
metadataGas(gasCosts) {
|
2502
2570
|
return calculateMetadataGasForTxCreate({
|
2503
|
-
contractBytesSize:
|
2571
|
+
contractBytesSize: bn10(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2504
2572
|
gasCosts,
|
2505
2573
|
stateRootSize: this.storageSlots.length,
|
2506
2574
|
txBytesSize: this.byteSize()
|
@@ -2512,8 +2580,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2512
2580
|
import { Interface } from "@fuel-ts/abi-coder";
|
2513
2581
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2514
2582
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2515
|
-
import { bn as
|
2516
|
-
import { InputType as
|
2583
|
+
import { bn as bn11 } from "@fuel-ts/math";
|
2584
|
+
import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2517
2585
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2518
2586
|
|
2519
2587
|
// src/providers/transaction-request/scripts.ts
|
@@ -2566,7 +2634,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2566
2634
|
*/
|
2567
2635
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2568
2636
|
super(rest);
|
2569
|
-
this.gasLimit =
|
2637
|
+
this.gasLimit = bn11(gasLimit);
|
2570
2638
|
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
2571
2639
|
this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
|
2572
2640
|
this.abis = rest.abis;
|
@@ -2583,8 +2651,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2583
2651
|
type: TransactionType4.Script,
|
2584
2652
|
scriptGasLimit: this.gasLimit,
|
2585
2653
|
...super.getBaseTransaction(),
|
2586
|
-
scriptLength:
|
2587
|
-
scriptDataLength:
|
2654
|
+
scriptLength: bn11(script.length),
|
2655
|
+
scriptDataLength: bn11(scriptData.length),
|
2588
2656
|
receiptsRoot: ZeroBytes327,
|
2589
2657
|
script: hexlify10(script),
|
2590
2658
|
scriptData: hexlify10(scriptData)
|
@@ -2597,7 +2665,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2597
2665
|
*/
|
2598
2666
|
getContractInputs() {
|
2599
2667
|
return this.inputs.filter(
|
2600
|
-
(input) => input.type ===
|
2668
|
+
(input) => input.type === InputType5.Contract
|
2601
2669
|
);
|
2602
2670
|
}
|
2603
2671
|
/**
|
@@ -2677,7 +2745,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2677
2745
|
return this;
|
2678
2746
|
}
|
2679
2747
|
const inputIndex = super.pushInput({
|
2680
|
-
type:
|
2748
|
+
type: InputType5.Contract,
|
2681
2749
|
contractId: contractAddress.toB256(),
|
2682
2750
|
txPointer: "0x00000000000000000000000000000000"
|
2683
2751
|
});
|
@@ -2719,7 +2787,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2719
2787
|
|
2720
2788
|
// src/providers/transaction-request/utils.ts
|
2721
2789
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2722
|
-
import { TransactionType as TransactionType5
|
2790
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2723
2791
|
var transactionRequestify = (obj) => {
|
2724
2792
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2725
2793
|
return obj;
|
@@ -2737,35 +2805,20 @@ var transactionRequestify = (obj) => {
|
|
2737
2805
|
}
|
2738
2806
|
}
|
2739
2807
|
};
|
2740
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2741
|
-
(acc, input) => {
|
2742
|
-
if (input.type === InputType5.Coin && input.owner === owner.toB256()) {
|
2743
|
-
acc.utxos.push(input.id);
|
2744
|
-
}
|
2745
|
-
if (input.type === InputType5.Message && input.recipient === owner.toB256()) {
|
2746
|
-
acc.messages.push(input.nonce);
|
2747
|
-
}
|
2748
|
-
return acc;
|
2749
|
-
},
|
2750
|
-
{
|
2751
|
-
utxos: [],
|
2752
|
-
messages: []
|
2753
|
-
}
|
2754
|
-
);
|
2755
2808
|
|
2756
2809
|
// src/providers/transaction-response/transaction-response.ts
|
2757
2810
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
2758
|
-
import { bn as
|
2811
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
2759
2812
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2760
2813
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2761
2814
|
|
2762
2815
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2763
|
-
import { bn as
|
2816
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
2764
2817
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
2765
2818
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2766
2819
|
|
2767
2820
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2768
|
-
import { bn as
|
2821
|
+
import { bn as bn12 } from "@fuel-ts/math";
|
2769
2822
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2770
2823
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2771
2824
|
var calculateTXFeeForSummary = (params) => {
|
@@ -2779,19 +2832,19 @@ var calculateTXFeeForSummary = (params) => {
|
|
2779
2832
|
if (totalFee) {
|
2780
2833
|
return totalFee;
|
2781
2834
|
}
|
2782
|
-
const gasPerByte =
|
2783
|
-
const gasPriceFactor =
|
2835
|
+
const gasPerByte = bn12(feeParams.gasPerByte);
|
2836
|
+
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
2784
2837
|
const transactionBytes = arrayify9(rawPayload);
|
2785
2838
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2786
2839
|
const { type, witnesses, inputs, policies } = transaction;
|
2787
|
-
let metadataGas =
|
2788
|
-
let gasLimit =
|
2840
|
+
let metadataGas = bn12(0);
|
2841
|
+
let gasLimit = bn12(0);
|
2789
2842
|
if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
|
2790
|
-
return
|
2843
|
+
return bn12(0);
|
2791
2844
|
}
|
2792
2845
|
if (type === TransactionType6.Create) {
|
2793
2846
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2794
|
-
const contractBytesSize =
|
2847
|
+
const contractBytesSize = bn12(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
2795
2848
|
metadataGas = calculateMetadataGasForTxCreate({
|
2796
2849
|
contractBytesSize,
|
2797
2850
|
gasCosts,
|
@@ -2810,7 +2863,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
2810
2863
|
}
|
2811
2864
|
const minGas = getMinGas({
|
2812
2865
|
gasCosts,
|
2813
|
-
gasPerByte:
|
2866
|
+
gasPerByte: bn12(gasPerByte),
|
2814
2867
|
inputs,
|
2815
2868
|
metadataGas,
|
2816
2869
|
txBytesSize: transactionBytes.length
|
@@ -2837,12 +2890,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
2837
2890
|
// src/providers/transaction-summary/operations.ts
|
2838
2891
|
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
2839
2892
|
import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
|
2840
|
-
import { bn as
|
2893
|
+
import { bn as bn14 } from "@fuel-ts/math";
|
2841
2894
|
import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2842
2895
|
|
2843
2896
|
// src/providers/transaction-summary/call.ts
|
2844
2897
|
import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
|
2845
|
-
import { bn as
|
2898
|
+
import { bn as bn13 } from "@fuel-ts/math";
|
2846
2899
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2847
2900
|
const abiInterface = new Interface2(abi);
|
2848
2901
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2851,7 +2904,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2851
2904
|
let encodedArgs;
|
2852
2905
|
if (functionFragment.isInputDataPointer) {
|
2853
2906
|
if (rawPayload) {
|
2854
|
-
const argsOffset =
|
2907
|
+
const argsOffset = bn13(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2855
2908
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2856
2909
|
}
|
2857
2910
|
} else {
|
@@ -3059,7 +3112,7 @@ var mergeAssets = (op1, op2) => {
|
|
3059
3112
|
if (!matchingAsset) {
|
3060
3113
|
return asset1;
|
3061
3114
|
}
|
3062
|
-
const mergedAmount =
|
3115
|
+
const mergedAmount = bn14(asset1.amount).add(matchingAsset.amount);
|
3063
3116
|
return { ...asset1, amount: mergedAmount };
|
3064
3117
|
});
|
3065
3118
|
return mergedAssets.concat(filteredAssets);
|
@@ -3385,7 +3438,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3385
3438
|
|
3386
3439
|
// src/providers/transaction-summary/status.ts
|
3387
3440
|
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3388
|
-
import { bn as
|
3441
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
3389
3442
|
var getTransactionStatusName = (gqlStatus) => {
|
3390
3443
|
switch (gqlStatus) {
|
3391
3444
|
case "FailureStatus":
|
@@ -3419,15 +3472,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3419
3472
|
time = gqlTransactionStatus.time;
|
3420
3473
|
blockId = gqlTransactionStatus.block.id;
|
3421
3474
|
isStatusSuccess = true;
|
3422
|
-
totalFee =
|
3423
|
-
totalGas =
|
3475
|
+
totalFee = bn15(gqlTransactionStatus.totalFee);
|
3476
|
+
totalGas = bn15(gqlTransactionStatus.totalGas);
|
3424
3477
|
break;
|
3425
3478
|
case "FailureStatus":
|
3426
3479
|
time = gqlTransactionStatus.time;
|
3427
3480
|
blockId = gqlTransactionStatus.block.id;
|
3428
3481
|
isStatusFailure = true;
|
3429
|
-
totalFee =
|
3430
|
-
totalGas =
|
3482
|
+
totalFee = bn15(gqlTransactionStatus.totalFee);
|
3483
|
+
totalGas = bn15(gqlTransactionStatus.totalGas);
|
3431
3484
|
break;
|
3432
3485
|
case "SubmittedStatus":
|
3433
3486
|
time = gqlTransactionStatus.time;
|
@@ -3477,7 +3530,7 @@ function assembleTransactionSummary(params) {
|
|
3477
3530
|
maxInputs
|
3478
3531
|
});
|
3479
3532
|
const typeName = getTransactionTypeName(transaction.type);
|
3480
|
-
const tip =
|
3533
|
+
const tip = bn16(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
|
3481
3534
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3482
3535
|
const fee = calculateTXFeeForSummary({
|
3483
3536
|
totalFee,
|
@@ -3548,7 +3601,7 @@ var TransactionResponse = class {
|
|
3548
3601
|
/** Current provider */
|
3549
3602
|
provider;
|
3550
3603
|
/** Gas used on the transaction */
|
3551
|
-
gasUsed =
|
3604
|
+
gasUsed = bn17(0);
|
3552
3605
|
/** The graphql Transaction with receipts object. */
|
3553
3606
|
gqlTransaction;
|
3554
3607
|
abis;
|
@@ -3716,7 +3769,6 @@ var TransactionResponse = class {
|
|
3716
3769
|
};
|
3717
3770
|
|
3718
3771
|
// src/providers/utils/auto-retry-fetch.ts
|
3719
|
-
import { sleep } from "@fuel-ts/utils";
|
3720
3772
|
function getWaitDelay(options, retryAttemptNum) {
|
3721
3773
|
const duration = options.baseDelay ?? 150;
|
3722
3774
|
switch (options.backoff) {
|
@@ -3783,47 +3835,47 @@ var processGqlChain = (chain) => {
|
|
3783
3835
|
} = consensusParameters;
|
3784
3836
|
return {
|
3785
3837
|
name,
|
3786
|
-
baseChainHeight:
|
3838
|
+
baseChainHeight: bn18(daHeight),
|
3787
3839
|
consensusParameters: {
|
3788
3840
|
version,
|
3789
|
-
chainId:
|
3841
|
+
chainId: bn18(chainId),
|
3790
3842
|
baseAssetId,
|
3791
3843
|
feeParameters: {
|
3792
3844
|
version: feeParams.version,
|
3793
|
-
gasPerByte:
|
3794
|
-
gasPriceFactor:
|
3845
|
+
gasPerByte: bn18(feeParams.gasPerByte),
|
3846
|
+
gasPriceFactor: bn18(feeParams.gasPriceFactor)
|
3795
3847
|
},
|
3796
3848
|
contractParameters: {
|
3797
3849
|
version: contractParams.version,
|
3798
|
-
contractMaxSize:
|
3799
|
-
maxStorageSlots:
|
3850
|
+
contractMaxSize: bn18(contractParams.contractMaxSize),
|
3851
|
+
maxStorageSlots: bn18(contractParams.maxStorageSlots)
|
3800
3852
|
},
|
3801
3853
|
txParameters: {
|
3802
3854
|
version: txParams.version,
|
3803
|
-
maxInputs:
|
3804
|
-
maxOutputs:
|
3805
|
-
maxWitnesses:
|
3806
|
-
maxGasPerTx:
|
3807
|
-
maxSize:
|
3808
|
-
maxBytecodeSubsections:
|
3855
|
+
maxInputs: bn18(txParams.maxInputs),
|
3856
|
+
maxOutputs: bn18(txParams.maxOutputs),
|
3857
|
+
maxWitnesses: bn18(txParams.maxWitnesses),
|
3858
|
+
maxGasPerTx: bn18(txParams.maxGasPerTx),
|
3859
|
+
maxSize: bn18(txParams.maxSize),
|
3860
|
+
maxBytecodeSubsections: bn18(txParams.maxBytecodeSubsections)
|
3809
3861
|
},
|
3810
3862
|
predicateParameters: {
|
3811
3863
|
version: predicateParams.version,
|
3812
|
-
maxPredicateLength:
|
3813
|
-
maxPredicateDataLength:
|
3814
|
-
maxGasPerPredicate:
|
3815
|
-
maxMessageDataLength:
|
3864
|
+
maxPredicateLength: bn18(predicateParams.maxPredicateLength),
|
3865
|
+
maxPredicateDataLength: bn18(predicateParams.maxPredicateDataLength),
|
3866
|
+
maxGasPerPredicate: bn18(predicateParams.maxGasPerPredicate),
|
3867
|
+
maxMessageDataLength: bn18(predicateParams.maxMessageDataLength)
|
3816
3868
|
},
|
3817
3869
|
scriptParameters: {
|
3818
3870
|
version: scriptParams.version,
|
3819
|
-
maxScriptLength:
|
3820
|
-
maxScriptDataLength:
|
3871
|
+
maxScriptLength: bn18(scriptParams.maxScriptLength),
|
3872
|
+
maxScriptDataLength: bn18(scriptParams.maxScriptDataLength)
|
3821
3873
|
},
|
3822
3874
|
gasCosts
|
3823
3875
|
},
|
3824
3876
|
latestBlock: {
|
3825
3877
|
id: latestBlock.id,
|
3826
|
-
height:
|
3878
|
+
height: bn18(latestBlock.height),
|
3827
3879
|
time: latestBlock.header.time,
|
3828
3880
|
transactions: latestBlock.transactions.map((i) => ({
|
3829
3881
|
id: i.id
|
@@ -4019,7 +4071,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4019
4071
|
*/
|
4020
4072
|
async getBlockNumber() {
|
4021
4073
|
const { chain } = await this.operations.getChain();
|
4022
|
-
return
|
4074
|
+
return bn18(chain.latestBlock.height, 10);
|
4023
4075
|
}
|
4024
4076
|
/**
|
4025
4077
|
* Returns the chain information.
|
@@ -4029,8 +4081,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4029
4081
|
async fetchNode() {
|
4030
4082
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
4031
4083
|
const processedNodeInfo = {
|
4032
|
-
maxDepth:
|
4033
|
-
maxTx:
|
4084
|
+
maxDepth: bn18(nodeInfo.maxDepth),
|
4085
|
+
maxTx: bn18(nodeInfo.maxTx),
|
4034
4086
|
nodeVersion: nodeInfo.nodeVersion,
|
4035
4087
|
utxoValidation: nodeInfo.utxoValidation,
|
4036
4088
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4162,7 +4214,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4162
4214
|
} = response;
|
4163
4215
|
if (inputs) {
|
4164
4216
|
inputs.forEach((input, index) => {
|
4165
|
-
if ("predicateGasUsed" in input &&
|
4217
|
+
if ("predicateGasUsed" in input && bn18(input.predicateGasUsed).gt(0)) {
|
4166
4218
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4167
4219
|
}
|
4168
4220
|
});
|
@@ -4320,12 +4372,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4320
4372
|
gasPrice = await this.estimateGasPrice(10);
|
4321
4373
|
}
|
4322
4374
|
const minFee = calculateGasFee({
|
4323
|
-
gasPrice:
|
4375
|
+
gasPrice: bn18(gasPrice),
|
4324
4376
|
gas: minGas,
|
4325
4377
|
priceFactor: gasPriceFactor,
|
4326
4378
|
tip: transactionRequest.tip
|
4327
4379
|
}).add(1);
|
4328
|
-
let gasLimit =
|
4380
|
+
let gasLimit = bn18(0);
|
4329
4381
|
if (transactionRequest.type === TransactionType8.Script) {
|
4330
4382
|
gasLimit = transactionRequest.gasLimit;
|
4331
4383
|
if (transactionRequest.gasLimit.eq(0)) {
|
@@ -4338,7 +4390,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4338
4390
|
}
|
4339
4391
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4340
4392
|
const maxFee = calculateGasFee({
|
4341
|
-
gasPrice:
|
4393
|
+
gasPrice: bn18(gasPrice),
|
4342
4394
|
gas: maxGas,
|
4343
4395
|
priceFactor: gasPriceFactor,
|
4344
4396
|
tip: transactionRequest.tip
|
@@ -4403,7 +4455,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4403
4455
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4404
4456
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4405
4457
|
if (isScriptTransaction) {
|
4406
|
-
txRequestClone.gasLimit =
|
4458
|
+
txRequestClone.gasLimit = bn18(0);
|
4407
4459
|
}
|
4408
4460
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4409
4461
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4424,7 +4476,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4424
4476
|
let dryRunStatus;
|
4425
4477
|
let missingContractIds = [];
|
4426
4478
|
let outputVariables = 0;
|
4427
|
-
let gasUsed =
|
4479
|
+
let gasUsed = bn18(0);
|
4428
4480
|
txRequestClone.maxFee = maxFee;
|
4429
4481
|
if (isScriptTransaction) {
|
4430
4482
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4489,10 +4541,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4489
4541
|
return coins.map((coin) => ({
|
4490
4542
|
id: coin.utxoId,
|
4491
4543
|
assetId: coin.assetId,
|
4492
|
-
amount:
|
4544
|
+
amount: bn18(coin.amount),
|
4493
4545
|
owner: Address2.fromAddressOrString(coin.owner),
|
4494
|
-
blockCreated:
|
4495
|
-
txCreatedIdx:
|
4546
|
+
blockCreated: bn18(coin.blockCreated),
|
4547
|
+
txCreatedIdx: bn18(coin.txCreatedIdx)
|
4496
4548
|
}));
|
4497
4549
|
}
|
4498
4550
|
/**
|
@@ -4529,9 +4581,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4529
4581
|
switch (coin.type) {
|
4530
4582
|
case "MessageCoin":
|
4531
4583
|
return {
|
4532
|
-
amount:
|
4584
|
+
amount: bn18(coin.amount),
|
4533
4585
|
assetId: coin.assetId,
|
4534
|
-
daHeight:
|
4586
|
+
daHeight: bn18(coin.daHeight),
|
4535
4587
|
sender: Address2.fromAddressOrString(coin.sender),
|
4536
4588
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4537
4589
|
nonce: coin.nonce
|
@@ -4539,11 +4591,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4539
4591
|
case "Coin":
|
4540
4592
|
return {
|
4541
4593
|
id: coin.utxoId,
|
4542
|
-
amount:
|
4594
|
+
amount: bn18(coin.amount),
|
4543
4595
|
assetId: coin.assetId,
|
4544
4596
|
owner: Address2.fromAddressOrString(coin.owner),
|
4545
|
-
blockCreated:
|
4546
|
-
txCreatedIdx:
|
4597
|
+
blockCreated: bn18(coin.blockCreated),
|
4598
|
+
txCreatedIdx: bn18(coin.txCreatedIdx)
|
4547
4599
|
};
|
4548
4600
|
default:
|
4549
4601
|
return null;
|
@@ -4560,13 +4612,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4560
4612
|
async getBlock(idOrHeight) {
|
4561
4613
|
let variables;
|
4562
4614
|
if (typeof idOrHeight === "number") {
|
4563
|
-
variables = { height:
|
4615
|
+
variables = { height: bn18(idOrHeight).toString(10) };
|
4564
4616
|
} else if (idOrHeight === "latest") {
|
4565
4617
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4566
4618
|
} else if (idOrHeight.length === 66) {
|
4567
4619
|
variables = { blockId: idOrHeight };
|
4568
4620
|
} else {
|
4569
|
-
variables = { blockId:
|
4621
|
+
variables = { blockId: bn18(idOrHeight).toString(10) };
|
4570
4622
|
}
|
4571
4623
|
const { block } = await this.operations.getBlock(variables);
|
4572
4624
|
if (!block) {
|
@@ -4574,7 +4626,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4574
4626
|
}
|
4575
4627
|
return {
|
4576
4628
|
id: block.id,
|
4577
|
-
height:
|
4629
|
+
height: bn18(block.height),
|
4578
4630
|
time: block.header.time,
|
4579
4631
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4580
4632
|
};
|
@@ -4589,7 +4641,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4589
4641
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4590
4642
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4591
4643
|
id: block.id,
|
4592
|
-
height:
|
4644
|
+
height: bn18(block.height),
|
4593
4645
|
time: block.header.time,
|
4594
4646
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4595
4647
|
}));
|
@@ -4604,7 +4656,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4604
4656
|
async getBlockWithTransactions(idOrHeight) {
|
4605
4657
|
let variables;
|
4606
4658
|
if (typeof idOrHeight === "number") {
|
4607
|
-
variables = { blockHeight:
|
4659
|
+
variables = { blockHeight: bn18(idOrHeight).toString(10) };
|
4608
4660
|
} else if (idOrHeight === "latest") {
|
4609
4661
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4610
4662
|
} else {
|
@@ -4616,7 +4668,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4616
4668
|
}
|
4617
4669
|
return {
|
4618
4670
|
id: block.id,
|
4619
|
-
height:
|
4671
|
+
height: bn18(block.height, 10),
|
4620
4672
|
time: block.header.time,
|
4621
4673
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4622
4674
|
transactions: block.transactions.map(
|
@@ -4665,7 +4717,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4665
4717
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4666
4718
|
asset: hexlify12(assetId)
|
4667
4719
|
});
|
4668
|
-
return
|
4720
|
+
return bn18(contractBalance.amount, 10);
|
4669
4721
|
}
|
4670
4722
|
/**
|
4671
4723
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4679,7 +4731,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4679
4731
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4680
4732
|
assetId: hexlify12(assetId)
|
4681
4733
|
});
|
4682
|
-
return
|
4734
|
+
return bn18(balance.amount, 10);
|
4683
4735
|
}
|
4684
4736
|
/**
|
4685
4737
|
* Returns balances for the given owner.
|
@@ -4697,7 +4749,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4697
4749
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4698
4750
|
return balances.map((balance) => ({
|
4699
4751
|
assetId: balance.assetId,
|
4700
|
-
amount:
|
4752
|
+
amount: bn18(balance.amount)
|
4701
4753
|
}));
|
4702
4754
|
}
|
4703
4755
|
/**
|
@@ -4719,15 +4771,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4719
4771
|
sender: message.sender,
|
4720
4772
|
recipient: message.recipient,
|
4721
4773
|
nonce: message.nonce,
|
4722
|
-
amount:
|
4774
|
+
amount: bn18(message.amount),
|
4723
4775
|
data: message.data
|
4724
4776
|
}),
|
4725
4777
|
sender: Address2.fromAddressOrString(message.sender),
|
4726
4778
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4727
4779
|
nonce: message.nonce,
|
4728
|
-
amount:
|
4780
|
+
amount: bn18(message.amount),
|
4729
4781
|
data: InputMessageCoder.decodeData(message.data),
|
4730
|
-
daHeight:
|
4782
|
+
daHeight: bn18(message.daHeight)
|
4731
4783
|
}));
|
4732
4784
|
}
|
4733
4785
|
/**
|
@@ -4780,19 +4832,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4780
4832
|
} = result.messageProof;
|
4781
4833
|
return {
|
4782
4834
|
messageProof: {
|
4783
|
-
proofIndex:
|
4835
|
+
proofIndex: bn18(messageProof.proofIndex),
|
4784
4836
|
proofSet: messageProof.proofSet
|
4785
4837
|
},
|
4786
4838
|
blockProof: {
|
4787
|
-
proofIndex:
|
4839
|
+
proofIndex: bn18(blockProof.proofIndex),
|
4788
4840
|
proofSet: blockProof.proofSet
|
4789
4841
|
},
|
4790
4842
|
messageBlockHeader: {
|
4791
4843
|
id: messageBlockHeader.id,
|
4792
|
-
daHeight:
|
4844
|
+
daHeight: bn18(messageBlockHeader.daHeight),
|
4793
4845
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4794
4846
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4795
|
-
height:
|
4847
|
+
height: bn18(messageBlockHeader.height),
|
4796
4848
|
prevRoot: messageBlockHeader.prevRoot,
|
4797
4849
|
time: messageBlockHeader.time,
|
4798
4850
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -4804,10 +4856,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4804
4856
|
},
|
4805
4857
|
commitBlockHeader: {
|
4806
4858
|
id: commitBlockHeader.id,
|
4807
|
-
daHeight:
|
4859
|
+
daHeight: bn18(commitBlockHeader.daHeight),
|
4808
4860
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4809
4861
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4810
|
-
height:
|
4862
|
+
height: bn18(commitBlockHeader.height),
|
4811
4863
|
prevRoot: commitBlockHeader.prevRoot,
|
4812
4864
|
time: commitBlockHeader.time,
|
4813
4865
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -4820,19 +4872,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4820
4872
|
sender: Address2.fromAddressOrString(sender),
|
4821
4873
|
recipient: Address2.fromAddressOrString(recipient),
|
4822
4874
|
nonce,
|
4823
|
-
amount:
|
4875
|
+
amount: bn18(amount),
|
4824
4876
|
data
|
4825
4877
|
};
|
4826
4878
|
}
|
4827
4879
|
async getLatestGasPrice() {
|
4828
4880
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4829
|
-
return
|
4881
|
+
return bn18(latestGasPrice.gasPrice);
|
4830
4882
|
}
|
4831
4883
|
async estimateGasPrice(blockHorizon) {
|
4832
4884
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4833
4885
|
blockHorizon: String(blockHorizon)
|
4834
4886
|
});
|
4835
|
-
return
|
4887
|
+
return bn18(estimateGasPrice.gasPrice);
|
4836
4888
|
}
|
4837
4889
|
/**
|
4838
4890
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4853,10 +4905,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4853
4905
|
*/
|
4854
4906
|
async produceBlocks(amount, startTime) {
|
4855
4907
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4856
|
-
blocksToProduce:
|
4908
|
+
blocksToProduce: bn18(amount).toString(10),
|
4857
4909
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4858
4910
|
});
|
4859
|
-
return
|
4911
|
+
return bn18(latestBlockHeight);
|
4860
4912
|
}
|
4861
4913
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4862
4914
|
async getTransactionResponse(transactionId) {
|
@@ -4902,7 +4954,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4902
4954
|
|
4903
4955
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4904
4956
|
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4905
|
-
import { bn as
|
4957
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
4906
4958
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4907
4959
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4908
4960
|
async function getTransactionSummary(params) {
|
@@ -4939,8 +4991,8 @@ async function getTransactionSummary(params) {
|
|
4939
4991
|
transaction: decodedTransaction,
|
4940
4992
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4941
4993
|
gqlTransactionStatus: gqlTransaction.status,
|
4942
|
-
gasPerByte:
|
4943
|
-
gasPriceFactor:
|
4994
|
+
gasPerByte: bn19(gasPerByte),
|
4995
|
+
gasPriceFactor: bn19(gasPriceFactor),
|
4944
4996
|
abiMap,
|
4945
4997
|
maxInputs,
|
4946
4998
|
gasCosts,
|
@@ -5146,22 +5198,6 @@ var rawAssets = [
|
|
5146
5198
|
];
|
5147
5199
|
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
5148
5200
|
|
5149
|
-
// src/providers/transaction-request/helpers.ts
|
5150
|
-
import { bn as bn19 } from "@fuel-ts/math";
|
5151
|
-
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
5152
|
-
var isRequestInputCoin = (input) => input.type === InputType8.Coin;
|
5153
|
-
var isRequestInputMessage = (input) => input.type === InputType8.Message;
|
5154
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
5155
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
5156
|
-
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
5157
|
-
return acc.add(input.amount);
|
5158
|
-
}
|
5159
|
-
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
5160
|
-
return acc.add(input.amount);
|
5161
|
-
}
|
5162
|
-
return acc;
|
5163
|
-
}, bn19(0));
|
5164
|
-
|
5165
5201
|
// src/utils/formatTransferToContractScriptData.ts
|
5166
5202
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
5167
5203
|
import { BN as BN2 } from "@fuel-ts/math";
|
@@ -5399,7 +5435,7 @@ var Account = class extends AbstractAccount {
|
|
5399
5435
|
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5400
5436
|
const resources = await this.getResourcesToSpend(
|
5401
5437
|
missingQuantities,
|
5402
|
-
|
5438
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5403
5439
|
);
|
5404
5440
|
request.addResources(resources);
|
5405
5441
|
request.shiftPredicateData();
|
@@ -9141,7 +9177,7 @@ import {
|
|
9141
9177
|
} from "@fuel-ts/abi-coder";
|
9142
9178
|
import { Address as Address9 } from "@fuel-ts/address";
|
9143
9179
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9144
|
-
import { ByteArrayCoder
|
9180
|
+
import { ByteArrayCoder } from "@fuel-ts/transactions";
|
9145
9181
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
9146
9182
|
|
9147
9183
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9200,10 +9236,15 @@ var Predicate = class extends Account {
|
|
9200
9236
|
populateTransactionPredicateData(transactionRequestLike) {
|
9201
9237
|
const request = transactionRequestify(transactionRequestLike);
|
9202
9238
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9203
|
-
|
9204
|
-
|
9239
|
+
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
9240
|
+
if (placeholderIndex !== -1) {
|
9241
|
+
request.removeWitness(placeholderIndex);
|
9242
|
+
}
|
9243
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9244
|
+
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9205
9245
|
input.predicate = hexlify19(this.bytes);
|
9206
9246
|
input.predicateData = hexlify19(this.getPredicateData(policies.length));
|
9247
|
+
input.witnessIndex = 0;
|
9207
9248
|
}
|
9208
9249
|
});
|
9209
9250
|
return request;
|
@@ -9326,6 +9367,28 @@ var Predicate = class extends Account {
|
|
9326
9367
|
}
|
9327
9368
|
return mutatedBytes;
|
9328
9369
|
}
|
9370
|
+
/**
|
9371
|
+
* Returns the index of the witness placeholder that was added to this predicate.
|
9372
|
+
* If no witness placeholder was added, it returns -1.
|
9373
|
+
* @param request - The transaction request.
|
9374
|
+
* @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
|
9375
|
+
*/
|
9376
|
+
getIndexFromPlaceholderWitness(request) {
|
9377
|
+
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
9378
|
+
let index = -1;
|
9379
|
+
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
9380
|
+
if (hasEmptyPredicateInputs) {
|
9381
|
+
index = hasEmptyPredicateInputs.witnessIndex;
|
9382
|
+
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
9383
|
+
if (!allInputsAreEmpty) {
|
9384
|
+
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
9385
|
+
if (wasFilledInputAddedFirst) {
|
9386
|
+
index = -1;
|
9387
|
+
}
|
9388
|
+
}
|
9389
|
+
}
|
9390
|
+
return index;
|
9391
|
+
}
|
9329
9392
|
};
|
9330
9393
|
|
9331
9394
|
// src/connectors/fuel.ts
|
@@ -10048,7 +10111,8 @@ export {
|
|
10048
10111
|
assets,
|
10049
10112
|
buildBlockExplorerUrl,
|
10050
10113
|
cacheFor,
|
10051
|
-
|
10114
|
+
cacheRequestInputsResources,
|
10115
|
+
cacheRequestInputsResourcesFromOwner,
|
10052
10116
|
calculateGasFee,
|
10053
10117
|
calculateMetadataGasForTxCreate,
|
10054
10118
|
calculateMetadataGasForTxScript,
|
@@ -10062,6 +10126,7 @@ export {
|
|
10062
10126
|
extractTxError,
|
10063
10127
|
fuelAssetsBaseUrl,
|
10064
10128
|
gasUsedByInputs,
|
10129
|
+
getAssetAmountInRequestInputs,
|
10065
10130
|
getAssetEth,
|
10066
10131
|
getAssetFuel,
|
10067
10132
|
getAssetNetwork,
|
@@ -10096,6 +10161,7 @@ export {
|
|
10096
10161
|
getReceiptsMessageOut,
|
10097
10162
|
getReceiptsTransferOut,
|
10098
10163
|
getReceiptsWithMissingData,
|
10164
|
+
getRequestInputResourceOwner,
|
10099
10165
|
getTransactionStatusName,
|
10100
10166
|
getTransactionSummary,
|
10101
10167
|
getTransactionSummaryFromRequest,
|
@@ -10109,6 +10175,10 @@ export {
|
|
10109
10175
|
isMessage,
|
10110
10176
|
isRawCoin,
|
10111
10177
|
isRawMessage,
|
10178
|
+
isRequestInputCoin,
|
10179
|
+
isRequestInputMessage,
|
10180
|
+
isRequestInputResource,
|
10181
|
+
isRequestInputResourceFromOwner,
|
10112
10182
|
isType,
|
10113
10183
|
isTypeCreate,
|
10114
10184
|
isTypeMint,
|
@@ -10123,6 +10193,7 @@ export {
|
|
10123
10193
|
resolveGasDependentCosts,
|
10124
10194
|
resolveIconPaths,
|
10125
10195
|
returnZeroScript,
|
10196
|
+
sleep,
|
10126
10197
|
transactionRequestify,
|
10127
10198
|
urlJoin,
|
10128
10199
|
withTimeout,
|