@fuel-ts/account 0.0.0-pr-2143-20240510170046 → 0.0.0-pr-2143-20240513112950
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/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +1373 -1574
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +337 -269
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +237 -176
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.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/test-utils/seedTestWallet.d.ts +1 -1
- package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
- package/dist/test-utils.global.js +1326 -1568
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +282 -269
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +192 -179
- 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.js
CHANGED
@@ -106,8 +106,8 @@ var addAmountToCoinQuantities = (params) => {
|
|
106
106
|
// src/providers/provider.ts
|
107
107
|
var import_address3 = require("@fuel-ts/address");
|
108
108
|
var import_errors14 = require("@fuel-ts/errors");
|
109
|
-
var
|
110
|
-
var
|
109
|
+
var import_math18 = require("@fuel-ts/math");
|
110
|
+
var import_transactions20 = require("@fuel-ts/transactions");
|
111
111
|
var import_utils22 = require("@fuel-ts/utils");
|
112
112
|
var import_versions = require("@fuel-ts/versions");
|
113
113
|
var import_utils23 = require("@noble/curves/abstract/utils");
|
@@ -1324,8 +1324,8 @@ var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
|
1324
1324
|
var import_address = require("@fuel-ts/address");
|
1325
1325
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1326
1326
|
var import_crypto = require("@fuel-ts/crypto");
|
1327
|
-
var
|
1328
|
-
var
|
1327
|
+
var import_math8 = require("@fuel-ts/math");
|
1328
|
+
var import_transactions7 = require("@fuel-ts/transactions");
|
1329
1329
|
var import_utils9 = require("@fuel-ts/utils");
|
1330
1330
|
|
1331
1331
|
// src/providers/resource.ts
|
@@ -1758,6 +1758,36 @@ var NoWitnessAtIndexError = class extends Error {
|
|
1758
1758
|
name = "NoWitnessAtIndexError";
|
1759
1759
|
};
|
1760
1760
|
|
1761
|
+
// src/providers/transaction-request/helpers.ts
|
1762
|
+
var import_math7 = require("@fuel-ts/math");
|
1763
|
+
var import_transactions6 = require("@fuel-ts/transactions");
|
1764
|
+
var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
|
1765
|
+
var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
|
1766
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1767
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1768
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1769
|
+
return acc.add(input.amount);
|
1770
|
+
}
|
1771
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1772
|
+
return acc.add(input.amount);
|
1773
|
+
}
|
1774
|
+
return acc;
|
1775
|
+
}, (0, import_math7.bn)(0));
|
1776
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
1777
|
+
(acc, input) => {
|
1778
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
1779
|
+
acc.utxos.push(input.id);
|
1780
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
1781
|
+
acc.messages.push(input.nonce);
|
1782
|
+
}
|
1783
|
+
return acc;
|
1784
|
+
},
|
1785
|
+
{
|
1786
|
+
utxos: [],
|
1787
|
+
messages: []
|
1788
|
+
}
|
1789
|
+
);
|
1790
|
+
|
1761
1791
|
// src/providers/transaction-request/witness.ts
|
1762
1792
|
var import_utils8 = require("@fuel-ts/utils");
|
1763
1793
|
var witnessify = (value) => {
|
@@ -1798,10 +1828,10 @@ var BaseTransactionRequest = class {
|
|
1798
1828
|
outputs,
|
1799
1829
|
witnesses
|
1800
1830
|
} = {}) {
|
1801
|
-
this.tip = tip ? (0,
|
1831
|
+
this.tip = tip ? (0, import_math8.bn)(tip) : void 0;
|
1802
1832
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1803
|
-
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0,
|
1804
|
-
this.maxFee = (0,
|
1833
|
+
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math8.bn)(witnessLimit) : void 0;
|
1834
|
+
this.maxFee = (0, import_math8.bn)(maxFee);
|
1805
1835
|
this.inputs = inputs ?? [];
|
1806
1836
|
this.outputs = outputs ?? [];
|
1807
1837
|
this.witnesses = witnesses ?? [];
|
@@ -1810,20 +1840,20 @@ var BaseTransactionRequest = class {
|
|
1810
1840
|
let policyTypes = 0;
|
1811
1841
|
const policies = [];
|
1812
1842
|
const { tip, witnessLimit, maturity } = req;
|
1813
|
-
if ((0,
|
1814
|
-
policyTypes +=
|
1815
|
-
policies.push({ data: (0,
|
1843
|
+
if ((0, import_math8.bn)(tip).gt(0)) {
|
1844
|
+
policyTypes += import_transactions7.PolicyType.Tip;
|
1845
|
+
policies.push({ data: (0, import_math8.bn)(tip), type: import_transactions7.PolicyType.Tip });
|
1816
1846
|
}
|
1817
|
-
if ((0, import_utils9.isDefined)(witnessLimit) && (0,
|
1818
|
-
policyTypes +=
|
1819
|
-
policies.push({ data: (0,
|
1847
|
+
if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math8.bn)(witnessLimit).gte(0)) {
|
1848
|
+
policyTypes += import_transactions7.PolicyType.WitnessLimit;
|
1849
|
+
policies.push({ data: (0, import_math8.bn)(witnessLimit), type: import_transactions7.PolicyType.WitnessLimit });
|
1820
1850
|
}
|
1821
1851
|
if (maturity && maturity > 0) {
|
1822
|
-
policyTypes +=
|
1823
|
-
policies.push({ data: maturity, type:
|
1852
|
+
policyTypes += import_transactions7.PolicyType.Maturity;
|
1853
|
+
policies.push({ data: maturity, type: import_transactions7.PolicyType.Maturity });
|
1824
1854
|
}
|
1825
|
-
policyTypes +=
|
1826
|
-
policies.push({ data: req.maxFee, type:
|
1855
|
+
policyTypes += import_transactions7.PolicyType.MaxFee;
|
1856
|
+
policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
|
1827
1857
|
return {
|
1828
1858
|
policyTypes,
|
1829
1859
|
policies
|
@@ -1856,7 +1886,7 @@ var BaseTransactionRequest = class {
|
|
1856
1886
|
* @returns The transaction bytes.
|
1857
1887
|
*/
|
1858
1888
|
toTransactionBytes() {
|
1859
|
-
return new
|
1889
|
+
return new import_transactions7.TransactionCoder().encode(this.toTransaction());
|
1860
1890
|
}
|
1861
1891
|
/**
|
1862
1892
|
* @hidden
|
@@ -1947,7 +1977,7 @@ var BaseTransactionRequest = class {
|
|
1947
1977
|
*/
|
1948
1978
|
getCoinInputs() {
|
1949
1979
|
return this.inputs.filter(
|
1950
|
-
(input) => input.type ===
|
1980
|
+
(input) => input.type === import_transactions7.InputType.Coin
|
1951
1981
|
);
|
1952
1982
|
}
|
1953
1983
|
/**
|
@@ -1957,7 +1987,7 @@ var BaseTransactionRequest = class {
|
|
1957
1987
|
*/
|
1958
1988
|
getCoinOutputs() {
|
1959
1989
|
return this.outputs.filter(
|
1960
|
-
(output) => output.type ===
|
1990
|
+
(output) => output.type === import_transactions7.OutputType.Coin
|
1961
1991
|
);
|
1962
1992
|
}
|
1963
1993
|
/**
|
@@ -1967,7 +1997,7 @@ var BaseTransactionRequest = class {
|
|
1967
1997
|
*/
|
1968
1998
|
getChangeOutputs() {
|
1969
1999
|
return this.outputs.filter(
|
1970
|
-
(output) => output.type ===
|
2000
|
+
(output) => output.type === import_transactions7.OutputType.Change
|
1971
2001
|
);
|
1972
2002
|
}
|
1973
2003
|
/**
|
@@ -1979,9 +2009,9 @@ var BaseTransactionRequest = class {
|
|
1979
2009
|
const ownerAddress = (0, import_address.addressify)(owner);
|
1980
2010
|
const found = this.inputs.find((input) => {
|
1981
2011
|
switch (input.type) {
|
1982
|
-
case
|
2012
|
+
case import_transactions7.InputType.Coin:
|
1983
2013
|
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
1984
|
-
case
|
2014
|
+
case import_transactions7.InputType.Message:
|
1985
2015
|
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
1986
2016
|
default:
|
1987
2017
|
return false;
|
@@ -1996,7 +2026,7 @@ var BaseTransactionRequest = class {
|
|
1996
2026
|
* @param coin - Coin resource.
|
1997
2027
|
*/
|
1998
2028
|
addCoinInput(coin) {
|
1999
|
-
const { assetId, owner, amount } = coin;
|
2029
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
2000
2030
|
let witnessIndex;
|
2001
2031
|
if (coin.predicate) {
|
2002
2032
|
witnessIndex = 0;
|
@@ -2007,13 +2037,14 @@ var BaseTransactionRequest = class {
|
|
2007
2037
|
}
|
2008
2038
|
}
|
2009
2039
|
const input = {
|
2010
|
-
|
2011
|
-
type:
|
2040
|
+
id,
|
2041
|
+
type: import_transactions7.InputType.Coin,
|
2012
2042
|
owner: owner.toB256(),
|
2013
2043
|
amount,
|
2014
2044
|
assetId,
|
2015
2045
|
txPointer: "0x00000000000000000000000000000000",
|
2016
|
-
witnessIndex
|
2046
|
+
witnessIndex,
|
2047
|
+
predicate
|
2017
2048
|
};
|
2018
2049
|
this.pushInput(input);
|
2019
2050
|
this.addChangeOutput(owner, assetId);
|
@@ -2025,7 +2056,7 @@ var BaseTransactionRequest = class {
|
|
2025
2056
|
* @param message - Message resource.
|
2026
2057
|
*/
|
2027
2058
|
addMessageInput(message) {
|
2028
|
-
const { recipient, sender, amount, assetId } = message;
|
2059
|
+
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
2029
2060
|
let witnessIndex;
|
2030
2061
|
if (message.predicate) {
|
2031
2062
|
witnessIndex = 0;
|
@@ -2036,12 +2067,13 @@ var BaseTransactionRequest = class {
|
|
2036
2067
|
}
|
2037
2068
|
}
|
2038
2069
|
const input = {
|
2039
|
-
|
2040
|
-
type:
|
2070
|
+
nonce,
|
2071
|
+
type: import_transactions7.InputType.Message,
|
2041
2072
|
sender: sender.toB256(),
|
2042
2073
|
recipient: recipient.toB256(),
|
2043
2074
|
amount,
|
2044
|
-
witnessIndex
|
2075
|
+
witnessIndex,
|
2076
|
+
predicate
|
2045
2077
|
};
|
2046
2078
|
this.pushInput(input);
|
2047
2079
|
this.addChangeOutput(recipient, assetId);
|
@@ -2081,7 +2113,7 @@ var BaseTransactionRequest = class {
|
|
2081
2113
|
*/
|
2082
2114
|
addCoinOutput(to, amount, assetId) {
|
2083
2115
|
this.pushOutput({
|
2084
|
-
type:
|
2116
|
+
type: import_transactions7.OutputType.Coin,
|
2085
2117
|
to: (0, import_address.addressify)(to).toB256(),
|
2086
2118
|
amount,
|
2087
2119
|
assetId
|
@@ -2097,7 +2129,7 @@ var BaseTransactionRequest = class {
|
|
2097
2129
|
addCoinOutputs(to, quantities) {
|
2098
2130
|
quantities.map(coinQuantityfy).forEach((quantity) => {
|
2099
2131
|
this.pushOutput({
|
2100
|
-
type:
|
2132
|
+
type: import_transactions7.OutputType.Coin,
|
2101
2133
|
to: (0, import_address.addressify)(to).toB256(),
|
2102
2134
|
amount: quantity.amount,
|
2103
2135
|
assetId: quantity.assetId
|
@@ -2117,7 +2149,7 @@ var BaseTransactionRequest = class {
|
|
2117
2149
|
);
|
2118
2150
|
if (!changeOutput) {
|
2119
2151
|
this.pushOutput({
|
2120
|
-
type:
|
2152
|
+
type: import_transactions7.OutputType.Change,
|
2121
2153
|
to: (0, import_address.addressify)(to).toB256(),
|
2122
2154
|
assetId
|
2123
2155
|
});
|
@@ -2188,7 +2220,7 @@ var BaseTransactionRequest = class {
|
|
2188
2220
|
const assetInput = findAssetInput(assetId);
|
2189
2221
|
let usedQuantity = quantity;
|
2190
2222
|
if (assetId === baseAssetId) {
|
2191
|
-
usedQuantity = (0,
|
2223
|
+
usedQuantity = (0, import_math8.bn)("1000000000000000000");
|
2192
2224
|
}
|
2193
2225
|
if (assetInput && "assetId" in assetInput) {
|
2194
2226
|
assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
|
@@ -2200,13 +2232,13 @@ var BaseTransactionRequest = class {
|
|
2200
2232
|
amount: usedQuantity,
|
2201
2233
|
assetId,
|
2202
2234
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2203
|
-
blockCreated: (0,
|
2204
|
-
txCreatedIdx: (0,
|
2235
|
+
blockCreated: (0, import_math8.bn)(1),
|
2236
|
+
txCreatedIdx: (0, import_math8.bn)(1)
|
2205
2237
|
}
|
2206
2238
|
]);
|
2207
2239
|
}
|
2208
2240
|
};
|
2209
|
-
updateAssetInput(baseAssetId, (0,
|
2241
|
+
updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
|
2210
2242
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2211
2243
|
}
|
2212
2244
|
/**
|
@@ -2217,7 +2249,7 @@ var BaseTransactionRequest = class {
|
|
2217
2249
|
*/
|
2218
2250
|
getCoinOutputsQuantities() {
|
2219
2251
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2220
|
-
amount: (0,
|
2252
|
+
amount: (0, import_math8.bn)(amount),
|
2221
2253
|
assetId: assetId.toString()
|
2222
2254
|
}));
|
2223
2255
|
return coinsQuantities;
|
@@ -2231,22 +2263,33 @@ var BaseTransactionRequest = class {
|
|
2231
2263
|
toJSON() {
|
2232
2264
|
return normalizeJSON(this);
|
2233
2265
|
}
|
2266
|
+
removeWitness(index) {
|
2267
|
+
this.witnesses.splice(index, 1);
|
2268
|
+
this.adjustWitnessIndexes(index);
|
2269
|
+
}
|
2270
|
+
adjustWitnessIndexes(removedIndex) {
|
2271
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2272
|
+
if (input.witnessIndex > removedIndex) {
|
2273
|
+
input.witnessIndex -= 1;
|
2274
|
+
}
|
2275
|
+
});
|
2276
|
+
}
|
2234
2277
|
updatePredicateGasUsed(inputs) {
|
2235
2278
|
this.inputs.forEach((i) => {
|
2236
2279
|
let correspondingInput;
|
2237
2280
|
switch (i.type) {
|
2238
|
-
case
|
2239
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2281
|
+
case import_transactions7.InputType.Coin:
|
2282
|
+
correspondingInput = inputs.find((x) => x.type === import_transactions7.InputType.Coin && x.owner === i.owner);
|
2240
2283
|
break;
|
2241
|
-
case
|
2284
|
+
case import_transactions7.InputType.Message:
|
2242
2285
|
correspondingInput = inputs.find(
|
2243
|
-
(x) => x.type ===
|
2286
|
+
(x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
|
2244
2287
|
);
|
2245
2288
|
break;
|
2246
2289
|
default:
|
2247
2290
|
return;
|
2248
2291
|
}
|
2249
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0,
|
2292
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math8.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2250
2293
|
i.predicate = correspondingInput.predicate;
|
2251
2294
|
i.predicateData = correspondingInput.predicateData;
|
2252
2295
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2266,38 +2309,38 @@ var BaseTransactionRequest = class {
|
|
2266
2309
|
|
2267
2310
|
// src/providers/transaction-request/create-transaction-request.ts
|
2268
2311
|
var import_configs8 = require("@fuel-ts/address/configs");
|
2269
|
-
var
|
2270
|
-
var
|
2312
|
+
var import_math10 = require("@fuel-ts/math");
|
2313
|
+
var import_transactions9 = require("@fuel-ts/transactions");
|
2271
2314
|
var import_utils13 = require("@fuel-ts/utils");
|
2272
2315
|
|
2273
2316
|
// src/providers/transaction-request/hash-transaction.ts
|
2274
2317
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2275
2318
|
var import_hasher = require("@fuel-ts/hasher");
|
2276
|
-
var
|
2277
|
-
var
|
2319
|
+
var import_math9 = require("@fuel-ts/math");
|
2320
|
+
var import_transactions8 = require("@fuel-ts/transactions");
|
2278
2321
|
var import_utils11 = require("@fuel-ts/utils");
|
2279
2322
|
var import_ramda2 = require("ramda");
|
2280
2323
|
function hashTransaction(transactionRequest, chainId) {
|
2281
2324
|
const transaction = transactionRequest.toTransaction();
|
2282
|
-
if (transaction.type ===
|
2325
|
+
if (transaction.type === import_transactions8.TransactionType.Script) {
|
2283
2326
|
transaction.receiptsRoot = import_configs7.ZeroBytes32;
|
2284
2327
|
}
|
2285
2328
|
transaction.inputs = transaction.inputs.map((input) => {
|
2286
2329
|
const inputClone = (0, import_ramda2.clone)(input);
|
2287
2330
|
switch (inputClone.type) {
|
2288
|
-
case
|
2331
|
+
case import_transactions8.InputType.Coin: {
|
2289
2332
|
inputClone.txPointer = {
|
2290
2333
|
blockHeight: 0,
|
2291
2334
|
txIndex: 0
|
2292
2335
|
};
|
2293
|
-
inputClone.predicateGasUsed = (0,
|
2336
|
+
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
2294
2337
|
return inputClone;
|
2295
2338
|
}
|
2296
|
-
case
|
2297
|
-
inputClone.predicateGasUsed = (0,
|
2339
|
+
case import_transactions8.InputType.Message: {
|
2340
|
+
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
2298
2341
|
return inputClone;
|
2299
2342
|
}
|
2300
|
-
case
|
2343
|
+
case import_transactions8.InputType.Contract: {
|
2301
2344
|
inputClone.txPointer = {
|
2302
2345
|
blockHeight: 0,
|
2303
2346
|
txIndex: 0
|
@@ -2315,18 +2358,18 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2315
2358
|
transaction.outputs = transaction.outputs.map((output) => {
|
2316
2359
|
const outputClone = (0, import_ramda2.clone)(output);
|
2317
2360
|
switch (outputClone.type) {
|
2318
|
-
case
|
2361
|
+
case import_transactions8.OutputType.Contract: {
|
2319
2362
|
outputClone.balanceRoot = import_configs7.ZeroBytes32;
|
2320
2363
|
outputClone.stateRoot = import_configs7.ZeroBytes32;
|
2321
2364
|
return outputClone;
|
2322
2365
|
}
|
2323
|
-
case
|
2324
|
-
outputClone.amount = (0,
|
2366
|
+
case import_transactions8.OutputType.Change: {
|
2367
|
+
outputClone.amount = (0, import_math9.bn)(0);
|
2325
2368
|
return outputClone;
|
2326
2369
|
}
|
2327
|
-
case
|
2370
|
+
case import_transactions8.OutputType.Variable: {
|
2328
2371
|
outputClone.to = import_configs7.ZeroBytes32;
|
2329
|
-
outputClone.amount = (0,
|
2372
|
+
outputClone.amount = (0, import_math9.bn)(0);
|
2330
2373
|
outputClone.assetId = import_configs7.ZeroBytes32;
|
2331
2374
|
return outputClone;
|
2332
2375
|
}
|
@@ -2337,7 +2380,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2337
2380
|
transaction.witnessesCount = 0;
|
2338
2381
|
transaction.witnesses = [];
|
2339
2382
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2340
|
-
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new
|
2383
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
|
2341
2384
|
return (0, import_hasher.sha256)(concatenatedData);
|
2342
2385
|
}
|
2343
2386
|
|
@@ -2373,7 +2416,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2373
2416
|
return new this(obj);
|
2374
2417
|
}
|
2375
2418
|
/** Type of the transaction */
|
2376
|
-
type =
|
2419
|
+
type = import_transactions9.TransactionType.Create;
|
2377
2420
|
/** Witness index of contract bytecode to create */
|
2378
2421
|
bytecodeWitnessIndex;
|
2379
2422
|
/** Salt */
|
@@ -2401,10 +2444,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2401
2444
|
const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
|
2402
2445
|
const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
|
2403
2446
|
return {
|
2404
|
-
type:
|
2447
|
+
type: import_transactions9.TransactionType.Create,
|
2405
2448
|
...baseTransaction,
|
2406
2449
|
bytecodeWitnessIndex,
|
2407
|
-
storageSlotsCount: (0,
|
2450
|
+
storageSlotsCount: (0, import_math10.bn)(storageSlots.length),
|
2408
2451
|
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2409
2452
|
storageSlots
|
2410
2453
|
};
|
@@ -2416,7 +2459,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2416
2459
|
*/
|
2417
2460
|
getContractCreatedOutputs() {
|
2418
2461
|
return this.outputs.filter(
|
2419
|
-
(output) => output.type ===
|
2462
|
+
(output) => output.type === import_transactions9.OutputType.ContractCreated
|
2420
2463
|
);
|
2421
2464
|
}
|
2422
2465
|
/**
|
@@ -2437,14 +2480,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2437
2480
|
*/
|
2438
2481
|
addContractCreatedOutput(contractId, stateRoot) {
|
2439
2482
|
this.pushOutput({
|
2440
|
-
type:
|
2483
|
+
type: import_transactions9.OutputType.ContractCreated,
|
2441
2484
|
contractId,
|
2442
2485
|
stateRoot
|
2443
2486
|
});
|
2444
2487
|
}
|
2445
2488
|
metadataGas(gasCosts) {
|
2446
2489
|
return calculateMetadataGasForTxCreate({
|
2447
|
-
contractBytesSize: (0,
|
2490
|
+
contractBytesSize: (0, import_math10.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2448
2491
|
gasCosts,
|
2449
2492
|
stateRootSize: this.storageSlots.length,
|
2450
2493
|
txBytesSize: this.byteSize()
|
@@ -2456,8 +2499,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2456
2499
|
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
2457
2500
|
var import_address2 = require("@fuel-ts/address");
|
2458
2501
|
var import_configs9 = require("@fuel-ts/address/configs");
|
2459
|
-
var
|
2460
|
-
var
|
2502
|
+
var import_math11 = require("@fuel-ts/math");
|
2503
|
+
var import_transactions10 = require("@fuel-ts/transactions");
|
2461
2504
|
var import_utils15 = require("@fuel-ts/utils");
|
2462
2505
|
|
2463
2506
|
// src/providers/transaction-request/scripts.ts
|
@@ -2495,7 +2538,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2495
2538
|
return new this(obj);
|
2496
2539
|
}
|
2497
2540
|
/** Type of the transaction */
|
2498
|
-
type =
|
2541
|
+
type = import_transactions10.TransactionType.Script;
|
2499
2542
|
/** Gas limit for transaction */
|
2500
2543
|
gasLimit;
|
2501
2544
|
/** Script to execute */
|
@@ -2510,7 +2553,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2510
2553
|
*/
|
2511
2554
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2512
2555
|
super(rest);
|
2513
|
-
this.gasLimit = (0,
|
2556
|
+
this.gasLimit = (0, import_math11.bn)(gasLimit);
|
2514
2557
|
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2515
2558
|
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2516
2559
|
this.abis = rest.abis;
|
@@ -2524,11 +2567,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2524
2567
|
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2525
2568
|
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2526
2569
|
return {
|
2527
|
-
type:
|
2570
|
+
type: import_transactions10.TransactionType.Script,
|
2528
2571
|
scriptGasLimit: this.gasLimit,
|
2529
2572
|
...super.getBaseTransaction(),
|
2530
|
-
scriptLength: (0,
|
2531
|
-
scriptDataLength: (0,
|
2573
|
+
scriptLength: (0, import_math11.bn)(script.length),
|
2574
|
+
scriptDataLength: (0, import_math11.bn)(scriptData.length),
|
2532
2575
|
receiptsRoot: import_configs9.ZeroBytes32,
|
2533
2576
|
script: (0, import_utils15.hexlify)(script),
|
2534
2577
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
@@ -2541,7 +2584,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2541
2584
|
*/
|
2542
2585
|
getContractInputs() {
|
2543
2586
|
return this.inputs.filter(
|
2544
|
-
(input) => input.type ===
|
2587
|
+
(input) => input.type === import_transactions10.InputType.Contract
|
2545
2588
|
);
|
2546
2589
|
}
|
2547
2590
|
/**
|
@@ -2551,7 +2594,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2551
2594
|
*/
|
2552
2595
|
getContractOutputs() {
|
2553
2596
|
return this.outputs.filter(
|
2554
|
-
(output) => output.type ===
|
2597
|
+
(output) => output.type === import_transactions10.OutputType.Contract
|
2555
2598
|
);
|
2556
2599
|
}
|
2557
2600
|
/**
|
@@ -2561,7 +2604,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2561
2604
|
*/
|
2562
2605
|
getVariableOutputs() {
|
2563
2606
|
return this.outputs.filter(
|
2564
|
-
(output) => output.type ===
|
2607
|
+
(output) => output.type === import_transactions10.OutputType.Variable
|
2565
2608
|
);
|
2566
2609
|
}
|
2567
2610
|
/**
|
@@ -2584,7 +2627,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2584
2627
|
let outputsNumber = numberOfVariables;
|
2585
2628
|
while (outputsNumber) {
|
2586
2629
|
this.pushOutput({
|
2587
|
-
type:
|
2630
|
+
type: import_transactions10.OutputType.Variable
|
2588
2631
|
});
|
2589
2632
|
outputsNumber -= 1;
|
2590
2633
|
}
|
@@ -2621,12 +2664,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2621
2664
|
return this;
|
2622
2665
|
}
|
2623
2666
|
const inputIndex = super.pushInput({
|
2624
|
-
type:
|
2667
|
+
type: import_transactions10.InputType.Contract,
|
2625
2668
|
contractId: contractAddress.toB256(),
|
2626
2669
|
txPointer: "0x00000000000000000000000000000000"
|
2627
2670
|
});
|
2628
2671
|
this.pushOutput({
|
2629
|
-
type:
|
2672
|
+
type: import_transactions10.OutputType.Contract,
|
2630
2673
|
inputIndex
|
2631
2674
|
});
|
2632
2675
|
return this;
|
@@ -2663,17 +2706,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2663
2706
|
|
2664
2707
|
// src/providers/transaction-request/utils.ts
|
2665
2708
|
var import_errors9 = require("@fuel-ts/errors");
|
2666
|
-
var
|
2709
|
+
var import_transactions11 = require("@fuel-ts/transactions");
|
2667
2710
|
var transactionRequestify = (obj) => {
|
2668
2711
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2669
2712
|
return obj;
|
2670
2713
|
}
|
2671
2714
|
const { type } = obj;
|
2672
2715
|
switch (obj.type) {
|
2673
|
-
case
|
2716
|
+
case import_transactions11.TransactionType.Script: {
|
2674
2717
|
return ScriptTransactionRequest.from(obj);
|
2675
2718
|
}
|
2676
|
-
case
|
2719
|
+
case import_transactions11.TransactionType.Create: {
|
2677
2720
|
return CreateTransactionRequest.from(obj);
|
2678
2721
|
}
|
2679
2722
|
default: {
|
@@ -2681,36 +2724,21 @@ var transactionRequestify = (obj) => {
|
|
2681
2724
|
}
|
2682
2725
|
}
|
2683
2726
|
};
|
2684
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2685
|
-
(acc, input) => {
|
2686
|
-
if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
|
2687
|
-
acc.utxos.push(input.id);
|
2688
|
-
}
|
2689
|
-
if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
|
2690
|
-
acc.messages.push(input.nonce);
|
2691
|
-
}
|
2692
|
-
return acc;
|
2693
|
-
},
|
2694
|
-
{
|
2695
|
-
utxos: [],
|
2696
|
-
messages: []
|
2697
|
-
}
|
2698
|
-
);
|
2699
2727
|
|
2700
2728
|
// src/providers/transaction-response/transaction-response.ts
|
2701
2729
|
var import_errors13 = require("@fuel-ts/errors");
|
2702
|
-
var
|
2703
|
-
var
|
2730
|
+
var import_math17 = require("@fuel-ts/math");
|
2731
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
2704
2732
|
var import_utils20 = require("@fuel-ts/utils");
|
2705
2733
|
|
2706
2734
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2707
|
-
var
|
2708
|
-
var
|
2735
|
+
var import_math16 = require("@fuel-ts/math");
|
2736
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
2709
2737
|
var import_utils18 = require("@fuel-ts/utils");
|
2710
2738
|
|
2711
2739
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2712
|
-
var
|
2713
|
-
var
|
2740
|
+
var import_math12 = require("@fuel-ts/math");
|
2741
|
+
var import_transactions12 = require("@fuel-ts/transactions");
|
2714
2742
|
var import_utils16 = require("@fuel-ts/utils");
|
2715
2743
|
var calculateTXFeeForSummary = (params) => {
|
2716
2744
|
const {
|
@@ -2723,19 +2751,19 @@ var calculateTXFeeForSummary = (params) => {
|
|
2723
2751
|
if (totalFee) {
|
2724
2752
|
return totalFee;
|
2725
2753
|
}
|
2726
|
-
const gasPerByte = (0,
|
2727
|
-
const gasPriceFactor = (0,
|
2754
|
+
const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
|
2755
|
+
const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
|
2728
2756
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2729
|
-
const [transaction] = new
|
2757
|
+
const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
|
2730
2758
|
const { type, witnesses, inputs, policies } = transaction;
|
2731
|
-
let metadataGas = (0,
|
2732
|
-
let gasLimit = (0,
|
2733
|
-
if (type !==
|
2734
|
-
return (0,
|
2759
|
+
let metadataGas = (0, import_math12.bn)(0);
|
2760
|
+
let gasLimit = (0, import_math12.bn)(0);
|
2761
|
+
if (type !== import_transactions12.TransactionType.Create && type !== import_transactions12.TransactionType.Script) {
|
2762
|
+
return (0, import_math12.bn)(0);
|
2735
2763
|
}
|
2736
|
-
if (type ===
|
2764
|
+
if (type === import_transactions12.TransactionType.Create) {
|
2737
2765
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2738
|
-
const contractBytesSize = (0,
|
2766
|
+
const contractBytesSize = (0, import_math12.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2739
2767
|
metadataGas = calculateMetadataGasForTxCreate({
|
2740
2768
|
contractBytesSize,
|
2741
2769
|
gasCosts,
|
@@ -2754,12 +2782,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
2754
2782
|
}
|
2755
2783
|
const minGas = getMinGas({
|
2756
2784
|
gasCosts,
|
2757
|
-
gasPerByte: (0,
|
2785
|
+
gasPerByte: (0, import_math12.bn)(gasPerByte),
|
2758
2786
|
inputs,
|
2759
2787
|
metadataGas,
|
2760
2788
|
txBytesSize: transactionBytes.length
|
2761
2789
|
});
|
2762
|
-
const witnessLimit = policies.find((policy) => policy.type ===
|
2790
|
+
const witnessLimit = policies.find((policy) => policy.type === import_transactions12.PolicyType.WitnessLimit)?.data;
|
2763
2791
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2764
2792
|
const maxGas = getMaxGas({
|
2765
2793
|
gasPerByte,
|
@@ -2781,12 +2809,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
2781
2809
|
// src/providers/transaction-summary/operations.ts
|
2782
2810
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2783
2811
|
var import_errors11 = require("@fuel-ts/errors");
|
2784
|
-
var
|
2785
|
-
var
|
2812
|
+
var import_math14 = require("@fuel-ts/math");
|
2813
|
+
var import_transactions15 = require("@fuel-ts/transactions");
|
2786
2814
|
|
2787
2815
|
// src/providers/transaction-summary/call.ts
|
2788
2816
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
2789
|
-
var
|
2817
|
+
var import_math13 = require("@fuel-ts/math");
|
2790
2818
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2791
2819
|
const abiInterface = new import_abi_coder4.Interface(abi);
|
2792
2820
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2795,7 +2823,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2795
2823
|
let encodedArgs;
|
2796
2824
|
if (functionFragment.isInputDataPointer) {
|
2797
2825
|
if (rawPayload) {
|
2798
|
-
const argsOffset = (0,
|
2826
|
+
const argsOffset = (0, import_math13.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2799
2827
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2800
2828
|
}
|
2801
2829
|
} else {
|
@@ -2830,7 +2858,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2830
2858
|
|
2831
2859
|
// src/providers/transaction-summary/input.ts
|
2832
2860
|
var import_errors10 = require("@fuel-ts/errors");
|
2833
|
-
var
|
2861
|
+
var import_transactions13 = require("@fuel-ts/transactions");
|
2834
2862
|
function getInputsByTypes(inputs, types) {
|
2835
2863
|
return inputs.filter((i) => types.includes(i.type));
|
2836
2864
|
}
|
@@ -2838,16 +2866,16 @@ function getInputsByType(inputs, type) {
|
|
2838
2866
|
return inputs.filter((i) => i.type === type);
|
2839
2867
|
}
|
2840
2868
|
function getInputsCoin(inputs) {
|
2841
|
-
return getInputsByType(inputs,
|
2869
|
+
return getInputsByType(inputs, import_transactions13.InputType.Coin);
|
2842
2870
|
}
|
2843
2871
|
function getInputsMessage(inputs) {
|
2844
|
-
return getInputsByType(inputs,
|
2872
|
+
return getInputsByType(inputs, import_transactions13.InputType.Message);
|
2845
2873
|
}
|
2846
2874
|
function getInputsCoinAndMessage(inputs) {
|
2847
|
-
return getInputsByTypes(inputs, [
|
2875
|
+
return getInputsByTypes(inputs, [import_transactions13.InputType.Coin, import_transactions13.InputType.Message]);
|
2848
2876
|
}
|
2849
2877
|
function getInputsContract(inputs) {
|
2850
|
-
return getInputsByType(inputs,
|
2878
|
+
return getInputsByType(inputs, import_transactions13.InputType.Contract);
|
2851
2879
|
}
|
2852
2880
|
function getInputFromAssetId(inputs, assetId) {
|
2853
2881
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2866,7 +2894,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2866
2894
|
if (!contractInput) {
|
2867
2895
|
return void 0;
|
2868
2896
|
}
|
2869
|
-
if (contractInput.type !==
|
2897
|
+
if (contractInput.type !== import_transactions13.InputType.Contract) {
|
2870
2898
|
throw new import_errors10.FuelError(
|
2871
2899
|
import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
|
2872
2900
|
`Contract input should be of type 'contract'.`
|
@@ -2875,31 +2903,31 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2875
2903
|
return contractInput;
|
2876
2904
|
}
|
2877
2905
|
function getInputAccountAddress(input) {
|
2878
|
-
if (input.type ===
|
2906
|
+
if (input.type === import_transactions13.InputType.Coin) {
|
2879
2907
|
return input.owner.toString();
|
2880
2908
|
}
|
2881
|
-
if (input.type ===
|
2909
|
+
if (input.type === import_transactions13.InputType.Message) {
|
2882
2910
|
return input.recipient.toString();
|
2883
2911
|
}
|
2884
2912
|
return "";
|
2885
2913
|
}
|
2886
2914
|
|
2887
2915
|
// src/providers/transaction-summary/output.ts
|
2888
|
-
var
|
2916
|
+
var import_transactions14 = require("@fuel-ts/transactions");
|
2889
2917
|
function getOutputsByType(outputs, type) {
|
2890
2918
|
return outputs.filter((o) => o.type === type);
|
2891
2919
|
}
|
2892
2920
|
function getOutputsContractCreated(outputs) {
|
2893
|
-
return getOutputsByType(outputs,
|
2921
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.ContractCreated);
|
2894
2922
|
}
|
2895
2923
|
function getOutputsCoin(outputs) {
|
2896
|
-
return getOutputsByType(outputs,
|
2924
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Coin);
|
2897
2925
|
}
|
2898
2926
|
function getOutputsChange(outputs) {
|
2899
|
-
return getOutputsByType(outputs,
|
2927
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Change);
|
2900
2928
|
}
|
2901
2929
|
function getOutputsContract(outputs) {
|
2902
|
-
return getOutputsByType(outputs,
|
2930
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Contract);
|
2903
2931
|
}
|
2904
2932
|
|
2905
2933
|
// src/providers/transaction-summary/operations.ts
|
@@ -2908,11 +2936,11 @@ function getReceiptsByType(receipts, type) {
|
|
2908
2936
|
}
|
2909
2937
|
function getTransactionTypeName(transactionType) {
|
2910
2938
|
switch (transactionType) {
|
2911
|
-
case
|
2939
|
+
case import_transactions15.TransactionType.Mint:
|
2912
2940
|
return "Mint" /* Mint */;
|
2913
|
-
case
|
2941
|
+
case import_transactions15.TransactionType.Create:
|
2914
2942
|
return "Create" /* Create */;
|
2915
|
-
case
|
2943
|
+
case import_transactions15.TransactionType.Script:
|
2916
2944
|
return "Script" /* Script */;
|
2917
2945
|
default:
|
2918
2946
|
throw new import_errors11.FuelError(
|
@@ -2941,10 +2969,10 @@ function isTypeUpload(transactionType) {
|
|
2941
2969
|
return isType(transactionType, "Upload" /* Upload */);
|
2942
2970
|
}
|
2943
2971
|
function getReceiptsCall(receipts) {
|
2944
|
-
return getReceiptsByType(receipts,
|
2972
|
+
return getReceiptsByType(receipts, import_transactions15.ReceiptType.Call);
|
2945
2973
|
}
|
2946
2974
|
function getReceiptsMessageOut(receipts) {
|
2947
|
-
return getReceiptsByType(receipts,
|
2975
|
+
return getReceiptsByType(receipts, import_transactions15.ReceiptType.MessageOut);
|
2948
2976
|
}
|
2949
2977
|
var mergeAssets = (op1, op2) => {
|
2950
2978
|
const assets1 = op1.assetsSent || [];
|
@@ -2957,7 +2985,7 @@ var mergeAssets = (op1, op2) => {
|
|
2957
2985
|
if (!matchingAsset) {
|
2958
2986
|
return asset1;
|
2959
2987
|
}
|
2960
|
-
const mergedAmount = (0,
|
2988
|
+
const mergedAmount = (0, import_math14.bn)(asset1.amount).add(matchingAsset.amount);
|
2961
2989
|
return { ...asset1, amount: mergedAmount };
|
2962
2990
|
});
|
2963
2991
|
return mergedAssets.concat(filteredAssets);
|
@@ -3140,11 +3168,11 @@ function getTransferOperations({
|
|
3140
3168
|
});
|
3141
3169
|
const transferReceipts = getReceiptsByType(
|
3142
3170
|
receipts,
|
3143
|
-
|
3171
|
+
import_transactions15.ReceiptType.Transfer
|
3144
3172
|
);
|
3145
3173
|
const transferOutReceipts = getReceiptsByType(
|
3146
3174
|
receipts,
|
3147
|
-
|
3175
|
+
import_transactions15.ReceiptType.TransferOut
|
3148
3176
|
);
|
3149
3177
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
3150
3178
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3229,17 +3257,17 @@ function getOperations({
|
|
3229
3257
|
}
|
3230
3258
|
|
3231
3259
|
// src/providers/transaction-summary/receipt.ts
|
3232
|
-
var
|
3260
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
3233
3261
|
var processGqlReceipt = (gqlReceipt) => {
|
3234
3262
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3235
3263
|
switch (receipt.type) {
|
3236
|
-
case
|
3264
|
+
case import_transactions16.ReceiptType.ReturnData: {
|
3237
3265
|
return {
|
3238
3266
|
...receipt,
|
3239
3267
|
data: gqlReceipt.data || "0x"
|
3240
3268
|
};
|
3241
3269
|
}
|
3242
|
-
case
|
3270
|
+
case import_transactions16.ReceiptType.LogData: {
|
3243
3271
|
return {
|
3244
3272
|
...receipt,
|
3245
3273
|
data: gqlReceipt.data || "0x"
|
@@ -3252,7 +3280,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3252
3280
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3253
3281
|
const mintedAssets = [];
|
3254
3282
|
receipts.forEach((receipt) => {
|
3255
|
-
if (receipt.type ===
|
3283
|
+
if (receipt.type === import_transactions16.ReceiptType.Mint) {
|
3256
3284
|
mintedAssets.push({
|
3257
3285
|
subId: receipt.subId,
|
3258
3286
|
contractId: receipt.contractId,
|
@@ -3266,7 +3294,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3266
3294
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3267
3295
|
const burnedAssets = [];
|
3268
3296
|
receipts.forEach((receipt) => {
|
3269
|
-
if (receipt.type ===
|
3297
|
+
if (receipt.type === import_transactions16.ReceiptType.Burn) {
|
3270
3298
|
burnedAssets.push({
|
3271
3299
|
subId: receipt.subId,
|
3272
3300
|
contractId: receipt.contractId,
|
@@ -3280,7 +3308,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3280
3308
|
|
3281
3309
|
// src/providers/transaction-summary/status.ts
|
3282
3310
|
var import_errors12 = require("@fuel-ts/errors");
|
3283
|
-
var
|
3311
|
+
var import_math15 = require("@fuel-ts/math");
|
3284
3312
|
var getTransactionStatusName = (gqlStatus) => {
|
3285
3313
|
switch (gqlStatus) {
|
3286
3314
|
case "FailureStatus":
|
@@ -3314,15 +3342,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3314
3342
|
time = gqlTransactionStatus.time;
|
3315
3343
|
blockId = gqlTransactionStatus.block.id;
|
3316
3344
|
isStatusSuccess = true;
|
3317
|
-
totalFee = (0,
|
3318
|
-
totalGas = (0,
|
3345
|
+
totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
|
3346
|
+
totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
|
3319
3347
|
break;
|
3320
3348
|
case "FailureStatus":
|
3321
3349
|
time = gqlTransactionStatus.time;
|
3322
3350
|
blockId = gqlTransactionStatus.block.id;
|
3323
3351
|
isStatusFailure = true;
|
3324
|
-
totalFee = (0,
|
3325
|
-
totalGas = (0,
|
3352
|
+
totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
|
3353
|
+
totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
|
3326
3354
|
break;
|
3327
3355
|
case "SubmittedStatus":
|
3328
3356
|
time = gqlTransactionStatus.time;
|
@@ -3372,7 +3400,7 @@ function assembleTransactionSummary(params) {
|
|
3372
3400
|
maxInputs
|
3373
3401
|
});
|
3374
3402
|
const typeName = getTransactionTypeName(transaction.type);
|
3375
|
-
const tip = (0,
|
3403
|
+
const tip = (0, import_math16.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
3376
3404
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3377
3405
|
const fee = calculateTXFeeForSummary({
|
3378
3406
|
totalFee,
|
@@ -3423,12 +3451,12 @@ function assembleTransactionSummary(params) {
|
|
3423
3451
|
|
3424
3452
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3425
3453
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
3426
|
-
var
|
3454
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
3427
3455
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3428
3456
|
return receipts.reduce((logs, receipt) => {
|
3429
|
-
if (receipt.type ===
|
3457
|
+
if (receipt.type === import_transactions18.ReceiptType.LogData || receipt.type === import_transactions18.ReceiptType.Log) {
|
3430
3458
|
const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
|
3431
|
-
const data = receipt.type ===
|
3459
|
+
const data = receipt.type === import_transactions18.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3432
3460
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3433
3461
|
logs.push(decodedLog);
|
3434
3462
|
}
|
@@ -3443,7 +3471,7 @@ var TransactionResponse = class {
|
|
3443
3471
|
/** Current provider */
|
3444
3472
|
provider;
|
3445
3473
|
/** Gas used on the transaction */
|
3446
|
-
gasUsed = (0,
|
3474
|
+
gasUsed = (0, import_math17.bn)(0);
|
3447
3475
|
/** The graphql Transaction with receipts object. */
|
3448
3476
|
gqlTransaction;
|
3449
3477
|
abis;
|
@@ -3501,7 +3529,7 @@ var TransactionResponse = class {
|
|
3501
3529
|
* @returns The decoded transaction.
|
3502
3530
|
*/
|
3503
3531
|
decodeTransaction(transactionWithReceipts) {
|
3504
|
-
return new
|
3532
|
+
return new import_transactions19.TransactionCoder().decode(
|
3505
3533
|
(0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
|
3506
3534
|
0
|
3507
3535
|
)?.[0];
|
@@ -3677,47 +3705,47 @@ var processGqlChain = (chain) => {
|
|
3677
3705
|
} = consensusParameters;
|
3678
3706
|
return {
|
3679
3707
|
name,
|
3680
|
-
baseChainHeight: (0,
|
3708
|
+
baseChainHeight: (0, import_math18.bn)(daHeight),
|
3681
3709
|
consensusParameters: {
|
3682
3710
|
version,
|
3683
|
-
chainId: (0,
|
3711
|
+
chainId: (0, import_math18.bn)(chainId),
|
3684
3712
|
baseAssetId,
|
3685
3713
|
feeParameters: {
|
3686
3714
|
version: feeParams.version,
|
3687
|
-
gasPerByte: (0,
|
3688
|
-
gasPriceFactor: (0,
|
3715
|
+
gasPerByte: (0, import_math18.bn)(feeParams.gasPerByte),
|
3716
|
+
gasPriceFactor: (0, import_math18.bn)(feeParams.gasPriceFactor)
|
3689
3717
|
},
|
3690
3718
|
contractParameters: {
|
3691
3719
|
version: contractParams.version,
|
3692
|
-
contractMaxSize: (0,
|
3693
|
-
maxStorageSlots: (0,
|
3720
|
+
contractMaxSize: (0, import_math18.bn)(contractParams.contractMaxSize),
|
3721
|
+
maxStorageSlots: (0, import_math18.bn)(contractParams.maxStorageSlots)
|
3694
3722
|
},
|
3695
3723
|
txParameters: {
|
3696
3724
|
version: txParams.version,
|
3697
|
-
maxInputs: (0,
|
3698
|
-
maxOutputs: (0,
|
3699
|
-
maxWitnesses: (0,
|
3700
|
-
maxGasPerTx: (0,
|
3701
|
-
maxSize: (0,
|
3702
|
-
maxBytecodeSubsections: (0,
|
3725
|
+
maxInputs: (0, import_math18.bn)(txParams.maxInputs),
|
3726
|
+
maxOutputs: (0, import_math18.bn)(txParams.maxOutputs),
|
3727
|
+
maxWitnesses: (0, import_math18.bn)(txParams.maxWitnesses),
|
3728
|
+
maxGasPerTx: (0, import_math18.bn)(txParams.maxGasPerTx),
|
3729
|
+
maxSize: (0, import_math18.bn)(txParams.maxSize),
|
3730
|
+
maxBytecodeSubsections: (0, import_math18.bn)(txParams.maxBytecodeSubsections)
|
3703
3731
|
},
|
3704
3732
|
predicateParameters: {
|
3705
3733
|
version: predicateParams.version,
|
3706
|
-
maxPredicateLength: (0,
|
3707
|
-
maxPredicateDataLength: (0,
|
3708
|
-
maxGasPerPredicate: (0,
|
3709
|
-
maxMessageDataLength: (0,
|
3734
|
+
maxPredicateLength: (0, import_math18.bn)(predicateParams.maxPredicateLength),
|
3735
|
+
maxPredicateDataLength: (0, import_math18.bn)(predicateParams.maxPredicateDataLength),
|
3736
|
+
maxGasPerPredicate: (0, import_math18.bn)(predicateParams.maxGasPerPredicate),
|
3737
|
+
maxMessageDataLength: (0, import_math18.bn)(predicateParams.maxMessageDataLength)
|
3710
3738
|
},
|
3711
3739
|
scriptParameters: {
|
3712
3740
|
version: scriptParams.version,
|
3713
|
-
maxScriptLength: (0,
|
3714
|
-
maxScriptDataLength: (0,
|
3741
|
+
maxScriptLength: (0, import_math18.bn)(scriptParams.maxScriptLength),
|
3742
|
+
maxScriptDataLength: (0, import_math18.bn)(scriptParams.maxScriptDataLength)
|
3715
3743
|
},
|
3716
3744
|
gasCosts
|
3717
3745
|
},
|
3718
3746
|
latestBlock: {
|
3719
3747
|
id: latestBlock.id,
|
3720
|
-
height: (0,
|
3748
|
+
height: (0, import_math18.bn)(latestBlock.height),
|
3721
3749
|
time: latestBlock.header.time,
|
3722
3750
|
transactions: latestBlock.transactions.map((i) => ({
|
3723
3751
|
id: i.id
|
@@ -3913,7 +3941,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3913
3941
|
*/
|
3914
3942
|
async getBlockNumber() {
|
3915
3943
|
const { chain } = await this.operations.getChain();
|
3916
|
-
return (0,
|
3944
|
+
return (0, import_math18.bn)(chain.latestBlock.height, 10);
|
3917
3945
|
}
|
3918
3946
|
/**
|
3919
3947
|
* Returns the chain information.
|
@@ -3923,8 +3951,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3923
3951
|
async fetchNode() {
|
3924
3952
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3925
3953
|
const processedNodeInfo = {
|
3926
|
-
maxDepth: (0,
|
3927
|
-
maxTx: (0,
|
3954
|
+
maxDepth: (0, import_math18.bn)(nodeInfo.maxDepth),
|
3955
|
+
maxTx: (0, import_math18.bn)(nodeInfo.maxTx),
|
3928
3956
|
nodeVersion: nodeInfo.nodeVersion,
|
3929
3957
|
utxoValidation: nodeInfo.utxoValidation,
|
3930
3958
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -3982,7 +4010,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
3982
4010
|
}
|
3983
4011
|
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
3984
4012
|
let abis;
|
3985
|
-
if (transactionRequest.type ===
|
4013
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
3986
4014
|
abis = transactionRequest.abis;
|
3987
4015
|
}
|
3988
4016
|
if (awaitExecution) {
|
@@ -4041,7 +4069,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4041
4069
|
async estimatePredicates(transactionRequest) {
|
4042
4070
|
const shouldEstimatePredicates = Boolean(
|
4043
4071
|
transactionRequest.inputs.find(
|
4044
|
-
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new
|
4072
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math18.BN(input.predicateGasUsed).isZero()
|
4045
4073
|
)
|
4046
4074
|
);
|
4047
4075
|
if (!shouldEstimatePredicates) {
|
@@ -4056,7 +4084,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4056
4084
|
} = response;
|
4057
4085
|
if (inputs) {
|
4058
4086
|
inputs.forEach((input, index) => {
|
4059
|
-
if ("predicateGasUsed" in input && (0,
|
4087
|
+
if ("predicateGasUsed" in input && (0, import_math18.bn)(input.predicateGasUsed).gt(0)) {
|
4060
4088
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4061
4089
|
}
|
4062
4090
|
});
|
@@ -4074,7 +4102,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4074
4102
|
* @returns A promise.
|
4075
4103
|
*/
|
4076
4104
|
async estimateTxDependencies(transactionRequest) {
|
4077
|
-
if (transactionRequest.type ===
|
4105
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Create) {
|
4078
4106
|
return {
|
4079
4107
|
receipts: [],
|
4080
4108
|
outputVariables: 0,
|
@@ -4138,7 +4166,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4138
4166
|
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4139
4167
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4140
4168
|
allRequests.forEach((req, index) => {
|
4141
|
-
if (req.type ===
|
4169
|
+
if (req.type === import_transactions20.TransactionType.Script) {
|
4142
4170
|
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4143
4171
|
}
|
4144
4172
|
});
|
@@ -4164,7 +4192,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4164
4192
|
);
|
4165
4193
|
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4166
4194
|
const request = allRequests[requestIdx];
|
4167
|
-
if (hasMissingOutputs && request?.type ===
|
4195
|
+
if (hasMissingOutputs && request?.type === import_transactions20.TransactionType.Script) {
|
4168
4196
|
result.outputVariables += missingOutputVariables.length;
|
4169
4197
|
request.addVariableOutputs(missingOutputVariables.length);
|
4170
4198
|
missingOutputContractIds.forEach(({ contractId }) => {
|
@@ -4214,13 +4242,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4214
4242
|
gasPrice = await this.estimateGasPrice(10);
|
4215
4243
|
}
|
4216
4244
|
const minFee = calculateGasFee({
|
4217
|
-
gasPrice: (0,
|
4245
|
+
gasPrice: (0, import_math18.bn)(gasPrice),
|
4218
4246
|
gas: minGas,
|
4219
4247
|
priceFactor: gasPriceFactor,
|
4220
4248
|
tip: transactionRequest.tip
|
4221
4249
|
}).add(1);
|
4222
|
-
let gasLimit = (0,
|
4223
|
-
if (transactionRequest.type ===
|
4250
|
+
let gasLimit = (0, import_math18.bn)(0);
|
4251
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4224
4252
|
gasLimit = transactionRequest.gasLimit;
|
4225
4253
|
if (transactionRequest.gasLimit.eq(0)) {
|
4226
4254
|
transactionRequest.gasLimit = minGas;
|
@@ -4232,7 +4260,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4232
4260
|
}
|
4233
4261
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4234
4262
|
const maxFee = calculateGasFee({
|
4235
|
-
gasPrice: (0,
|
4263
|
+
gasPrice: (0, import_math18.bn)(gasPrice),
|
4236
4264
|
gas: maxGas,
|
4237
4265
|
priceFactor: gasPriceFactor,
|
4238
4266
|
tip: transactionRequest.tip
|
@@ -4290,14 +4318,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4290
4318
|
*/
|
4291
4319
|
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
4292
4320
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4293
|
-
const isScriptTransaction = txRequestClone.type ===
|
4321
|
+
const isScriptTransaction = txRequestClone.type === import_transactions20.TransactionType.Script;
|
4294
4322
|
const baseAssetId = this.getBaseAssetId();
|
4295
4323
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4296
4324
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4297
4325
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4298
4326
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4299
4327
|
if (isScriptTransaction) {
|
4300
|
-
txRequestClone.gasLimit = (0,
|
4328
|
+
txRequestClone.gasLimit = (0, import_math18.bn)(0);
|
4301
4329
|
}
|
4302
4330
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4303
4331
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4318,7 +4346,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4318
4346
|
let dryRunStatus;
|
4319
4347
|
let missingContractIds = [];
|
4320
4348
|
let outputVariables = 0;
|
4321
|
-
let gasUsed = (0,
|
4349
|
+
let gasUsed = (0, import_math18.bn)(0);
|
4322
4350
|
txRequestClone.maxFee = maxFee;
|
4323
4351
|
if (isScriptTransaction) {
|
4324
4352
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4383,10 +4411,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4383
4411
|
return coins.map((coin) => ({
|
4384
4412
|
id: coin.utxoId,
|
4385
4413
|
assetId: coin.assetId,
|
4386
|
-
amount: (0,
|
4414
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4387
4415
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4388
|
-
blockCreated: (0,
|
4389
|
-
txCreatedIdx: (0,
|
4416
|
+
blockCreated: (0, import_math18.bn)(coin.blockCreated),
|
4417
|
+
txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
|
4390
4418
|
}));
|
4391
4419
|
}
|
4392
4420
|
/**
|
@@ -4423,9 +4451,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4423
4451
|
switch (coin.type) {
|
4424
4452
|
case "MessageCoin":
|
4425
4453
|
return {
|
4426
|
-
amount: (0,
|
4454
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4427
4455
|
assetId: coin.assetId,
|
4428
|
-
daHeight: (0,
|
4456
|
+
daHeight: (0, import_math18.bn)(coin.daHeight),
|
4429
4457
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4430
4458
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4431
4459
|
nonce: coin.nonce
|
@@ -4433,11 +4461,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4433
4461
|
case "Coin":
|
4434
4462
|
return {
|
4435
4463
|
id: coin.utxoId,
|
4436
|
-
amount: (0,
|
4464
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4437
4465
|
assetId: coin.assetId,
|
4438
4466
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4439
|
-
blockCreated: (0,
|
4440
|
-
txCreatedIdx: (0,
|
4467
|
+
blockCreated: (0, import_math18.bn)(coin.blockCreated),
|
4468
|
+
txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
|
4441
4469
|
};
|
4442
4470
|
default:
|
4443
4471
|
return null;
|
@@ -4454,13 +4482,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4454
4482
|
async getBlock(idOrHeight) {
|
4455
4483
|
let variables;
|
4456
4484
|
if (typeof idOrHeight === "number") {
|
4457
|
-
variables = { height: (0,
|
4485
|
+
variables = { height: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4458
4486
|
} else if (idOrHeight === "latest") {
|
4459
4487
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4460
4488
|
} else if (idOrHeight.length === 66) {
|
4461
4489
|
variables = { blockId: idOrHeight };
|
4462
4490
|
} else {
|
4463
|
-
variables = { blockId: (0,
|
4491
|
+
variables = { blockId: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4464
4492
|
}
|
4465
4493
|
const { block } = await this.operations.getBlock(variables);
|
4466
4494
|
if (!block) {
|
@@ -4468,7 +4496,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4468
4496
|
}
|
4469
4497
|
return {
|
4470
4498
|
id: block.id,
|
4471
|
-
height: (0,
|
4499
|
+
height: (0, import_math18.bn)(block.height),
|
4472
4500
|
time: block.header.time,
|
4473
4501
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4474
4502
|
};
|
@@ -4483,7 +4511,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4483
4511
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4484
4512
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4485
4513
|
id: block.id,
|
4486
|
-
height: (0,
|
4514
|
+
height: (0, import_math18.bn)(block.height),
|
4487
4515
|
time: block.header.time,
|
4488
4516
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4489
4517
|
}));
|
@@ -4498,7 +4526,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4498
4526
|
async getBlockWithTransactions(idOrHeight) {
|
4499
4527
|
let variables;
|
4500
4528
|
if (typeof idOrHeight === "number") {
|
4501
|
-
variables = { blockHeight: (0,
|
4529
|
+
variables = { blockHeight: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4502
4530
|
} else if (idOrHeight === "latest") {
|
4503
4531
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4504
4532
|
} else {
|
@@ -4510,11 +4538,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4510
4538
|
}
|
4511
4539
|
return {
|
4512
4540
|
id: block.id,
|
4513
|
-
height: (0,
|
4541
|
+
height: (0, import_math18.bn)(block.height, 10),
|
4514
4542
|
time: block.header.time,
|
4515
4543
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4516
4544
|
transactions: block.transactions.map(
|
4517
|
-
(tx) => new
|
4545
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4518
4546
|
)
|
4519
4547
|
};
|
4520
4548
|
}
|
@@ -4529,7 +4557,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4529
4557
|
if (!transaction) {
|
4530
4558
|
return null;
|
4531
4559
|
}
|
4532
|
-
return new
|
4560
|
+
return new import_transactions20.TransactionCoder().decode(
|
4533
4561
|
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4534
4562
|
0
|
4535
4563
|
)?.[0];
|
@@ -4559,7 +4587,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4559
4587
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4560
4588
|
asset: (0, import_utils22.hexlify)(assetId)
|
4561
4589
|
});
|
4562
|
-
return (0,
|
4590
|
+
return (0, import_math18.bn)(contractBalance.amount, 10);
|
4563
4591
|
}
|
4564
4592
|
/**
|
4565
4593
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4573,7 +4601,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4573
4601
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4574
4602
|
assetId: (0, import_utils22.hexlify)(assetId)
|
4575
4603
|
});
|
4576
|
-
return (0,
|
4604
|
+
return (0, import_math18.bn)(balance.amount, 10);
|
4577
4605
|
}
|
4578
4606
|
/**
|
4579
4607
|
* Returns balances for the given owner.
|
@@ -4591,7 +4619,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4591
4619
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4592
4620
|
return balances.map((balance) => ({
|
4593
4621
|
assetId: balance.assetId,
|
4594
|
-
amount: (0,
|
4622
|
+
amount: (0, import_math18.bn)(balance.amount)
|
4595
4623
|
}));
|
4596
4624
|
}
|
4597
4625
|
/**
|
@@ -4609,19 +4637,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4609
4637
|
});
|
4610
4638
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4611
4639
|
return messages.map((message) => ({
|
4612
|
-
messageId:
|
4640
|
+
messageId: import_transactions20.InputMessageCoder.getMessageId({
|
4613
4641
|
sender: message.sender,
|
4614
4642
|
recipient: message.recipient,
|
4615
4643
|
nonce: message.nonce,
|
4616
|
-
amount: (0,
|
4644
|
+
amount: (0, import_math18.bn)(message.amount),
|
4617
4645
|
data: message.data
|
4618
4646
|
}),
|
4619
4647
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4620
4648
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4621
4649
|
nonce: message.nonce,
|
4622
|
-
amount: (0,
|
4623
|
-
data:
|
4624
|
-
daHeight: (0,
|
4650
|
+
amount: (0, import_math18.bn)(message.amount),
|
4651
|
+
data: import_transactions20.InputMessageCoder.decodeData(message.data),
|
4652
|
+
daHeight: (0, import_math18.bn)(message.daHeight)
|
4625
4653
|
}));
|
4626
4654
|
}
|
4627
4655
|
/**
|
@@ -4674,19 +4702,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4674
4702
|
} = result.messageProof;
|
4675
4703
|
return {
|
4676
4704
|
messageProof: {
|
4677
|
-
proofIndex: (0,
|
4705
|
+
proofIndex: (0, import_math18.bn)(messageProof.proofIndex),
|
4678
4706
|
proofSet: messageProof.proofSet
|
4679
4707
|
},
|
4680
4708
|
blockProof: {
|
4681
|
-
proofIndex: (0,
|
4709
|
+
proofIndex: (0, import_math18.bn)(blockProof.proofIndex),
|
4682
4710
|
proofSet: blockProof.proofSet
|
4683
4711
|
},
|
4684
4712
|
messageBlockHeader: {
|
4685
4713
|
id: messageBlockHeader.id,
|
4686
|
-
daHeight: (0,
|
4714
|
+
daHeight: (0, import_math18.bn)(messageBlockHeader.daHeight),
|
4687
4715
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4688
4716
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4689
|
-
height: (0,
|
4717
|
+
height: (0, import_math18.bn)(messageBlockHeader.height),
|
4690
4718
|
prevRoot: messageBlockHeader.prevRoot,
|
4691
4719
|
time: messageBlockHeader.time,
|
4692
4720
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -4698,10 +4726,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4698
4726
|
},
|
4699
4727
|
commitBlockHeader: {
|
4700
4728
|
id: commitBlockHeader.id,
|
4701
|
-
daHeight: (0,
|
4729
|
+
daHeight: (0, import_math18.bn)(commitBlockHeader.daHeight),
|
4702
4730
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4703
4731
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4704
|
-
height: (0,
|
4732
|
+
height: (0, import_math18.bn)(commitBlockHeader.height),
|
4705
4733
|
prevRoot: commitBlockHeader.prevRoot,
|
4706
4734
|
time: commitBlockHeader.time,
|
4707
4735
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -4714,19 +4742,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4714
4742
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4715
4743
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4716
4744
|
nonce,
|
4717
|
-
amount: (0,
|
4745
|
+
amount: (0, import_math18.bn)(amount),
|
4718
4746
|
data
|
4719
4747
|
};
|
4720
4748
|
}
|
4721
4749
|
async getLatestGasPrice() {
|
4722
4750
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4723
|
-
return (0,
|
4751
|
+
return (0, import_math18.bn)(latestGasPrice.gasPrice);
|
4724
4752
|
}
|
4725
4753
|
async estimateGasPrice(blockHorizon) {
|
4726
4754
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4727
4755
|
blockHorizon: String(blockHorizon)
|
4728
4756
|
});
|
4729
|
-
return (0,
|
4757
|
+
return (0, import_math18.bn)(estimateGasPrice.gasPrice);
|
4730
4758
|
}
|
4731
4759
|
/**
|
4732
4760
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4747,10 +4775,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4747
4775
|
*/
|
4748
4776
|
async produceBlocks(amount, startTime) {
|
4749
4777
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4750
|
-
blocksToProduce: (0,
|
4778
|
+
blocksToProduce: (0, import_math18.bn)(amount).toString(10),
|
4751
4779
|
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4752
4780
|
});
|
4753
|
-
return (0,
|
4781
|
+
return (0, import_math18.bn)(latestBlockHeight);
|
4754
4782
|
}
|
4755
4783
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4756
4784
|
async getTransactionResponse(transactionId) {
|
@@ -4786,7 +4814,7 @@ cacheInputs_fn = function(inputs) {
|
|
4786
4814
|
return;
|
4787
4815
|
}
|
4788
4816
|
inputs.forEach((input) => {
|
4789
|
-
if (input.type ===
|
4817
|
+
if (input.type === import_transactions20.InputType.Coin) {
|
4790
4818
|
this.cache?.set(input.id);
|
4791
4819
|
}
|
4792
4820
|
});
|
@@ -4796,8 +4824,8 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
4796
4824
|
|
4797
4825
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4798
4826
|
var import_errors15 = require("@fuel-ts/errors");
|
4799
|
-
var
|
4800
|
-
var
|
4827
|
+
var import_math19 = require("@fuel-ts/math");
|
4828
|
+
var import_transactions21 = require("@fuel-ts/transactions");
|
4801
4829
|
var import_utils25 = require("@fuel-ts/utils");
|
4802
4830
|
|
4803
4831
|
// src/providers/chains.ts
|
@@ -4871,22 +4899,6 @@ var rawAssets = [
|
|
4871
4899
|
];
|
4872
4900
|
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
4873
4901
|
|
4874
|
-
// src/providers/transaction-request/helpers.ts
|
4875
|
-
var import_math19 = require("@fuel-ts/math");
|
4876
|
-
var import_transactions21 = require("@fuel-ts/transactions");
|
4877
|
-
var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
|
4878
|
-
var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
|
4879
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
4880
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
4881
|
-
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
4882
|
-
return acc.add(input.amount);
|
4883
|
-
}
|
4884
|
-
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
4885
|
-
return acc.add(input.amount);
|
4886
|
-
}
|
4887
|
-
return acc;
|
4888
|
-
}, (0, import_math19.bn)(0));
|
4889
|
-
|
4890
4902
|
// src/utils/formatTransferToContractScriptData.ts
|
4891
4903
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4892
4904
|
var import_math20 = require("@fuel-ts/math");
|
@@ -5124,7 +5136,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5124
5136
|
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5125
5137
|
const resources = await this.getResourcesToSpend(
|
5126
5138
|
missingQuantities,
|
5127
|
-
|
5139
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5128
5140
|
);
|
5129
5141
|
request.addResources(resources);
|
5130
5142
|
request.shiftPredicateData();
|
@@ -5692,18 +5704,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
5692
5704
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5693
5705
|
|
5694
5706
|
// src/hdwallet/hdwallet.ts
|
5707
|
+
var import_crypto5 = require("@fuel-ts/crypto");
|
5695
5708
|
var import_errors20 = require("@fuel-ts/errors");
|
5696
5709
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5697
5710
|
var import_math23 = require("@fuel-ts/math");
|
5698
5711
|
var import_utils35 = require("@fuel-ts/utils");
|
5699
|
-
var import_ethers2 = require("ethers");
|
5700
5712
|
|
5701
5713
|
// src/mnemonic/mnemonic.ts
|
5702
5714
|
var import_crypto4 = require("@fuel-ts/crypto");
|
5703
5715
|
var import_errors19 = require("@fuel-ts/errors");
|
5704
5716
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5705
5717
|
var import_utils33 = require("@fuel-ts/utils");
|
5706
|
-
var import_ethers = require("ethers");
|
5707
5718
|
|
5708
5719
|
// src/wordlists/words/english.ts
|
5709
5720
|
var english = [
|
@@ -7951,7 +7962,7 @@ var Mnemonic = class {
|
|
7951
7962
|
assertMnemonic(getWords(phrase));
|
7952
7963
|
const phraseBytes = toUtf8Bytes(getPhrase(phrase));
|
7953
7964
|
const salt = toUtf8Bytes(`mnemonic${passphrase}`);
|
7954
|
-
return (0,
|
7965
|
+
return (0, import_crypto4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
7955
7966
|
}
|
7956
7967
|
/**
|
7957
7968
|
* @param phrase - Mnemonic phrase composed by words from the provided wordlist
|
@@ -8013,7 +8024,7 @@ var Mnemonic = class {
|
|
8013
8024
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8014
8025
|
);
|
8015
8026
|
}
|
8016
|
-
return (0, import_utils33.arrayify)((0,
|
8027
|
+
return (0, import_utils33.arrayify)((0, import_crypto4.computeHmac)("sha512", MasterSecret, seedArray));
|
8017
8028
|
}
|
8018
8029
|
/**
|
8019
8030
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8038,8 +8049,8 @@ var Mnemonic = class {
|
|
8038
8049
|
chainCode,
|
8039
8050
|
(0, import_utils33.concat)(["0x00", privateKey])
|
8040
8051
|
]);
|
8041
|
-
const checksum = (0,
|
8042
|
-
return (0,
|
8052
|
+
const checksum = (0, import_utils33.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8053
|
+
return (0, import_utils33.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
8043
8054
|
}
|
8044
8055
|
/**
|
8045
8056
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8067,7 +8078,7 @@ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
|
8067
8078
|
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8068
8079
|
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
8069
8080
|
function base58check(data) {
|
8070
|
-
return (0,
|
8081
|
+
return (0, import_utils35.encodeBase58)((0, import_utils35.concat)([data, (0, import_utils35.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
8071
8082
|
}
|
8072
8083
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8073
8084
|
if (isPublic) {
|
@@ -8123,7 +8134,7 @@ var HDWallet = class {
|
|
8123
8134
|
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8124
8135
|
}
|
8125
8136
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8126
|
-
this.fingerprint = (0,
|
8137
|
+
this.fingerprint = (0, import_utils35.dataSlice)((0, import_crypto5.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
8127
8138
|
this.depth = config.depth || this.depth;
|
8128
8139
|
this.index = config.index || this.index;
|
8129
8140
|
this.chainCode = config.chainCode;
|
@@ -8155,7 +8166,7 @@ var HDWallet = class {
|
|
8155
8166
|
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8156
8167
|
}
|
8157
8168
|
data.set((0, import_math23.toBytes)(index, 4), 33);
|
8158
|
-
const bytes = (0, import_utils35.arrayify)((0,
|
8169
|
+
const bytes = (0, import_utils35.arrayify)((0, import_crypto5.computeHmac)("sha512", chainCode, data));
|
8159
8170
|
const IL = bytes.slice(0, 32);
|
8160
8171
|
const IR = bytes.slice(32);
|
8161
8172
|
if (privateKey) {
|
@@ -8226,7 +8237,7 @@ var HDWallet = class {
|
|
8226
8237
|
});
|
8227
8238
|
}
|
8228
8239
|
static fromExtendedKey(extendedKey) {
|
8229
|
-
const decoded = (0,
|
8240
|
+
const decoded = (0, import_utils35.hexlify)((0, import_math23.toBytes)((0, import_utils35.decodeBase58)(extendedKey)));
|
8230
8241
|
const bytes = (0, import_utils35.arrayify)(decoded);
|
8231
8242
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8232
8243
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -8425,17 +8436,19 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
|
|
8425
8436
|
__publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
8426
8437
|
|
8427
8438
|
// src/test-utils/seedTestWallet.ts
|
8428
|
-
var
|
8429
|
-
var seedTestWallet = async (wallet, quantities) => {
|
8430
|
-
const
|
8431
|
-
|
8432
|
-
|
8433
|
-
);
|
8439
|
+
var import_crypto6 = require("@fuel-ts/crypto");
|
8440
|
+
var seedTestWallet = async (wallet, quantities, utxosAmount = 1) => {
|
8441
|
+
const accountsToBeFunded = Array.isArray(wallet) ? wallet : [wallet];
|
8442
|
+
const [{ provider }] = accountsToBeFunded;
|
8443
|
+
const genesisWallet = new WalletUnlocked(process.env.GENESIS_SECRET || (0, import_crypto6.randomBytes)(32), provider);
|
8434
8444
|
const request = new ScriptTransactionRequest();
|
8435
|
-
quantities.forEach(
|
8436
|
-
|
8437
|
-
|
8438
|
-
|
8445
|
+
quantities.map(coinQuantityfy).forEach(
|
8446
|
+
({ amount, assetId }) => accountsToBeFunded.forEach(({ address }) => {
|
8447
|
+
for (let i = 0; i < utxosAmount; i++) {
|
8448
|
+
request.addCoinOutput(address, amount.div(utxosAmount), assetId);
|
8449
|
+
}
|
8450
|
+
})
|
8451
|
+
);
|
8439
8452
|
const txCost = await genesisWallet.provider.getTransactionCost(request);
|
8440
8453
|
request.gasLimit = txCost.gasUsed;
|
8441
8454
|
request.maxFee = txCost.maxFee;
|
@@ -8454,11 +8467,11 @@ var generateTestWallet = async (provider, quantities) => {
|
|
8454
8467
|
|
8455
8468
|
// src/test-utils/launchNode.ts
|
8456
8469
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
8457
|
-
var
|
8470
|
+
var import_crypto7 = require("@fuel-ts/crypto");
|
8458
8471
|
var import_utils36 = require("@fuel-ts/utils");
|
8459
8472
|
var import_cli_utils = require("@fuel-ts/utils/cli-utils");
|
8460
8473
|
var import_child_process = require("child_process");
|
8461
|
-
var
|
8474
|
+
var import_crypto8 = require("crypto");
|
8462
8475
|
var import_fs = require("fs");
|
8463
8476
|
var import_os = __toESM(require("os"));
|
8464
8477
|
var import_path = __toESM(require("path"));
|
@@ -8531,7 +8544,7 @@ var launchNode = async ({
|
|
8531
8544
|
})).toString();
|
8532
8545
|
let snapshotDirToUse;
|
8533
8546
|
const prefix = basePath || import_os.default.tmpdir();
|
8534
|
-
const suffix = basePath ? "" : (0,
|
8547
|
+
const suffix = basePath ? "" : (0, import_crypto8.randomUUID)();
|
8535
8548
|
const tempDirPath = import_path.default.join(prefix, ".fuels", suffix, "snapshotDir");
|
8536
8549
|
if (snapshotDir) {
|
8537
8550
|
snapshotDirToUse = snapshotDir;
|
@@ -8560,7 +8573,7 @@ var launchNode = async ({
|
|
8560
8573
|
const signer = new Signer(pk);
|
8561
8574
|
process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
|
8562
8575
|
stateConfigJson.coins.push({
|
8563
|
-
tx_id: (0, import_utils36.hexlify)((0,
|
8576
|
+
tx_id: (0, import_utils36.hexlify)((0, import_crypto7.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
|
8564
8577
|
owner: signer.address.toHexString(),
|
8565
8578
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8566
8579
|
amount: "18446744073709551615",
|