@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.js
CHANGED
@@ -88,7 +88,7 @@ __export(src_exports, {
|
|
88
88
|
StorageAbstract: () => StorageAbstract,
|
89
89
|
TransactionResponse: () => TransactionResponse,
|
90
90
|
TransactionStatus: () => TransactionStatus,
|
91
|
-
TransactionType: () =>
|
91
|
+
TransactionType: () => import_transactions7.TransactionType,
|
92
92
|
TransactionTypeName: () => TransactionTypeName,
|
93
93
|
Vault: () => Vault,
|
94
94
|
Wallet: () => Wallet,
|
@@ -104,7 +104,8 @@ __export(src_exports, {
|
|
104
104
|
assets: () => assets,
|
105
105
|
buildBlockExplorerUrl: () => buildBlockExplorerUrl,
|
106
106
|
cacheFor: () => cacheFor,
|
107
|
-
|
107
|
+
cacheRequestInputsResources: () => cacheRequestInputsResources,
|
108
|
+
cacheRequestInputsResourcesFromOwner: () => cacheRequestInputsResourcesFromOwner,
|
108
109
|
calculateGasFee: () => calculateGasFee,
|
109
110
|
calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
|
110
111
|
calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
|
@@ -118,6 +119,7 @@ __export(src_exports, {
|
|
118
119
|
extractTxError: () => extractTxError,
|
119
120
|
fuelAssetsBaseUrl: () => fuelAssetsBaseUrl,
|
120
121
|
gasUsedByInputs: () => gasUsedByInputs,
|
122
|
+
getAssetAmountInRequestInputs: () => getAssetAmountInRequestInputs,
|
121
123
|
getAssetEth: () => getAssetEth,
|
122
124
|
getAssetFuel: () => getAssetFuel,
|
123
125
|
getAssetNetwork: () => getAssetNetwork,
|
@@ -152,6 +154,7 @@ __export(src_exports, {
|
|
152
154
|
getReceiptsMessageOut: () => getReceiptsMessageOut,
|
153
155
|
getReceiptsTransferOut: () => getReceiptsTransferOut,
|
154
156
|
getReceiptsWithMissingData: () => getReceiptsWithMissingData,
|
157
|
+
getRequestInputResourceOwner: () => getRequestInputResourceOwner,
|
155
158
|
getTransactionStatusName: () => getTransactionStatusName,
|
156
159
|
getTransactionSummary: () => getTransactionSummary,
|
157
160
|
getTransactionSummaryFromRequest: () => getTransactionSummaryFromRequest,
|
@@ -165,6 +168,10 @@ __export(src_exports, {
|
|
165
168
|
isMessage: () => isMessage,
|
166
169
|
isRawCoin: () => isRawCoin,
|
167
170
|
isRawMessage: () => isRawMessage,
|
171
|
+
isRequestInputCoin: () => isRequestInputCoin,
|
172
|
+
isRequestInputMessage: () => isRequestInputMessage,
|
173
|
+
isRequestInputResource: () => isRequestInputResource,
|
174
|
+
isRequestInputResourceFromOwner: () => isRequestInputResourceFromOwner,
|
168
175
|
isType: () => isType,
|
169
176
|
isTypeCreate: () => isTypeCreate,
|
170
177
|
isTypeMint: () => isTypeMint,
|
@@ -179,6 +186,7 @@ __export(src_exports, {
|
|
179
186
|
resolveGasDependentCosts: () => resolveGasDependentCosts,
|
180
187
|
resolveIconPaths: () => resolveIconPaths,
|
181
188
|
returnZeroScript: () => returnZeroScript,
|
189
|
+
sleep: () => sleep,
|
182
190
|
transactionRequestify: () => transactionRequestify,
|
183
191
|
urlJoin: () => urlJoin,
|
184
192
|
withTimeout: () => withTimeout,
|
@@ -191,7 +199,7 @@ var import_address4 = require("@fuel-ts/address");
|
|
191
199
|
var import_errors16 = require("@fuel-ts/errors");
|
192
200
|
var import_interfaces = require("@fuel-ts/interfaces");
|
193
201
|
var import_math21 = require("@fuel-ts/math");
|
194
|
-
var
|
202
|
+
var import_utils28 = require("@fuel-ts/utils");
|
195
203
|
var import_ramda4 = require("ramda");
|
196
204
|
|
197
205
|
// src/providers/coin-quantity.ts
|
@@ -232,11 +240,11 @@ var addAmountToCoinQuantities = (params) => {
|
|
232
240
|
// src/providers/provider.ts
|
233
241
|
var import_address3 = require("@fuel-ts/address");
|
234
242
|
var import_errors14 = require("@fuel-ts/errors");
|
235
|
-
var
|
236
|
-
var
|
237
|
-
var
|
243
|
+
var import_math18 = require("@fuel-ts/math");
|
244
|
+
var import_transactions20 = require("@fuel-ts/transactions");
|
245
|
+
var import_utils22 = require("@fuel-ts/utils");
|
238
246
|
var import_versions = require("@fuel-ts/versions");
|
239
|
-
var
|
247
|
+
var import_utils23 = require("@noble/curves/abstract/utils");
|
240
248
|
var import_graphql_request = require("graphql-request");
|
241
249
|
var import_ramda3 = require("ramda");
|
242
250
|
|
@@ -1450,8 +1458,8 @@ var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
|
1450
1458
|
var import_address = require("@fuel-ts/address");
|
1451
1459
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1452
1460
|
var import_crypto = require("@fuel-ts/crypto");
|
1453
|
-
var
|
1454
|
-
var
|
1461
|
+
var import_math8 = require("@fuel-ts/math");
|
1462
|
+
var import_transactions7 = require("@fuel-ts/transactions");
|
1455
1463
|
var import_utils9 = require("@fuel-ts/utils");
|
1456
1464
|
|
1457
1465
|
// src/providers/resource.ts
|
@@ -1855,6 +1863,15 @@ function normalizeJSON(root) {
|
|
1855
1863
|
return normalize((0, import_ramda.clone)(root));
|
1856
1864
|
}
|
1857
1865
|
|
1866
|
+
// src/providers/utils/sleep.ts
|
1867
|
+
function sleep(time) {
|
1868
|
+
return new Promise((resolve) => {
|
1869
|
+
setTimeout(() => {
|
1870
|
+
resolve(true);
|
1871
|
+
}, time);
|
1872
|
+
});
|
1873
|
+
}
|
1874
|
+
|
1858
1875
|
// src/providers/utils/extract-tx-error.ts
|
1859
1876
|
var import_errors7 = require("@fuel-ts/errors");
|
1860
1877
|
var import_math6 = require("@fuel-ts/math");
|
@@ -1949,6 +1966,52 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1949
1966
|
name = "NoWitnessByOwnerError";
|
1950
1967
|
};
|
1951
1968
|
|
1969
|
+
// src/providers/transaction-request/helpers.ts
|
1970
|
+
var import_math7 = require("@fuel-ts/math");
|
1971
|
+
var import_transactions6 = require("@fuel-ts/transactions");
|
1972
|
+
var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
|
1973
|
+
var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
|
1974
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1975
|
+
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
1976
|
+
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
1977
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1978
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1979
|
+
return acc.add(input.amount);
|
1980
|
+
}
|
1981
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1982
|
+
return acc.add(input.amount);
|
1983
|
+
}
|
1984
|
+
return acc;
|
1985
|
+
}, (0, import_math7.bn)(0));
|
1986
|
+
var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
|
1987
|
+
(cache2, input) => {
|
1988
|
+
if (isRequestInputCoin(input)) {
|
1989
|
+
cache2.utxos.push(input.id);
|
1990
|
+
} else {
|
1991
|
+
cache2.messages.push(input.nonce);
|
1992
|
+
}
|
1993
|
+
return cache2;
|
1994
|
+
},
|
1995
|
+
{
|
1996
|
+
utxos: [],
|
1997
|
+
messages: []
|
1998
|
+
}
|
1999
|
+
);
|
2000
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
2001
|
+
(acc, input) => {
|
2002
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
2003
|
+
acc.utxos.push(input.id);
|
2004
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
2005
|
+
acc.messages.push(input.nonce);
|
2006
|
+
}
|
2007
|
+
return acc;
|
2008
|
+
},
|
2009
|
+
{
|
2010
|
+
utxos: [],
|
2011
|
+
messages: []
|
2012
|
+
}
|
2013
|
+
);
|
2014
|
+
|
1952
2015
|
// src/providers/transaction-request/witness.ts
|
1953
2016
|
var import_utils8 = require("@fuel-ts/utils");
|
1954
2017
|
var witnessify = (value) => {
|
@@ -1989,10 +2052,10 @@ var BaseTransactionRequest = class {
|
|
1989
2052
|
outputs,
|
1990
2053
|
witnesses
|
1991
2054
|
} = {}) {
|
1992
|
-
this.tip = tip ? (0,
|
2055
|
+
this.tip = tip ? (0, import_math8.bn)(tip) : void 0;
|
1993
2056
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1994
|
-
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0,
|
1995
|
-
this.maxFee = (0,
|
2057
|
+
this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math8.bn)(witnessLimit) : void 0;
|
2058
|
+
this.maxFee = (0, import_math8.bn)(maxFee);
|
1996
2059
|
this.inputs = inputs ?? [];
|
1997
2060
|
this.outputs = outputs ?? [];
|
1998
2061
|
this.witnesses = witnesses ?? [];
|
@@ -2001,20 +2064,20 @@ var BaseTransactionRequest = class {
|
|
2001
2064
|
let policyTypes = 0;
|
2002
2065
|
const policies = [];
|
2003
2066
|
const { tip, witnessLimit, maturity } = req;
|
2004
|
-
if ((0,
|
2005
|
-
policyTypes +=
|
2006
|
-
policies.push({ data: (0,
|
2067
|
+
if ((0, import_math8.bn)(tip).gt(0)) {
|
2068
|
+
policyTypes += import_transactions7.PolicyType.Tip;
|
2069
|
+
policies.push({ data: (0, import_math8.bn)(tip), type: import_transactions7.PolicyType.Tip });
|
2007
2070
|
}
|
2008
|
-
if ((0, import_utils9.isDefined)(witnessLimit) && (0,
|
2009
|
-
policyTypes +=
|
2010
|
-
policies.push({ data: (0,
|
2071
|
+
if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math8.bn)(witnessLimit).gte(0)) {
|
2072
|
+
policyTypes += import_transactions7.PolicyType.WitnessLimit;
|
2073
|
+
policies.push({ data: (0, import_math8.bn)(witnessLimit), type: import_transactions7.PolicyType.WitnessLimit });
|
2011
2074
|
}
|
2012
2075
|
if (maturity && maturity > 0) {
|
2013
|
-
policyTypes +=
|
2014
|
-
policies.push({ data: maturity, type:
|
2076
|
+
policyTypes += import_transactions7.PolicyType.Maturity;
|
2077
|
+
policies.push({ data: maturity, type: import_transactions7.PolicyType.Maturity });
|
2015
2078
|
}
|
2016
|
-
policyTypes +=
|
2017
|
-
policies.push({ data: req.maxFee, type:
|
2079
|
+
policyTypes += import_transactions7.PolicyType.MaxFee;
|
2080
|
+
policies.push({ data: req.maxFee, type: import_transactions7.PolicyType.MaxFee });
|
2018
2081
|
return {
|
2019
2082
|
policyTypes,
|
2020
2083
|
policies
|
@@ -2047,7 +2110,7 @@ var BaseTransactionRequest = class {
|
|
2047
2110
|
* @returns The transaction bytes.
|
2048
2111
|
*/
|
2049
2112
|
toTransactionBytes() {
|
2050
|
-
return new
|
2113
|
+
return new import_transactions7.TransactionCoder().encode(this.toTransaction());
|
2051
2114
|
}
|
2052
2115
|
/**
|
2053
2116
|
* @hidden
|
@@ -2138,7 +2201,7 @@ var BaseTransactionRequest = class {
|
|
2138
2201
|
*/
|
2139
2202
|
getCoinInputs() {
|
2140
2203
|
return this.inputs.filter(
|
2141
|
-
(input) => input.type ===
|
2204
|
+
(input) => input.type === import_transactions7.InputType.Coin
|
2142
2205
|
);
|
2143
2206
|
}
|
2144
2207
|
/**
|
@@ -2148,7 +2211,7 @@ var BaseTransactionRequest = class {
|
|
2148
2211
|
*/
|
2149
2212
|
getCoinOutputs() {
|
2150
2213
|
return this.outputs.filter(
|
2151
|
-
(output) => output.type ===
|
2214
|
+
(output) => output.type === import_transactions7.OutputType.Coin
|
2152
2215
|
);
|
2153
2216
|
}
|
2154
2217
|
/**
|
@@ -2158,7 +2221,7 @@ var BaseTransactionRequest = class {
|
|
2158
2221
|
*/
|
2159
2222
|
getChangeOutputs() {
|
2160
2223
|
return this.outputs.filter(
|
2161
|
-
(output) => output.type ===
|
2224
|
+
(output) => output.type === import_transactions7.OutputType.Change
|
2162
2225
|
);
|
2163
2226
|
}
|
2164
2227
|
/**
|
@@ -2170,9 +2233,9 @@ var BaseTransactionRequest = class {
|
|
2170
2233
|
const ownerAddress = (0, import_address.addressify)(owner);
|
2171
2234
|
const found = this.inputs.find((input) => {
|
2172
2235
|
switch (input.type) {
|
2173
|
-
case
|
2236
|
+
case import_transactions7.InputType.Coin:
|
2174
2237
|
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
2175
|
-
case
|
2238
|
+
case import_transactions7.InputType.Message:
|
2176
2239
|
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
2177
2240
|
default:
|
2178
2241
|
return false;
|
@@ -2187,7 +2250,7 @@ var BaseTransactionRequest = class {
|
|
2187
2250
|
* @param coin - Coin resource.
|
2188
2251
|
*/
|
2189
2252
|
addCoinInput(coin) {
|
2190
|
-
const { assetId, owner, amount } = coin;
|
2253
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
2191
2254
|
let witnessIndex;
|
2192
2255
|
if (coin.predicate) {
|
2193
2256
|
witnessIndex = 0;
|
@@ -2198,13 +2261,14 @@ var BaseTransactionRequest = class {
|
|
2198
2261
|
}
|
2199
2262
|
}
|
2200
2263
|
const input = {
|
2201
|
-
|
2202
|
-
type:
|
2264
|
+
id,
|
2265
|
+
type: import_transactions7.InputType.Coin,
|
2203
2266
|
owner: owner.toB256(),
|
2204
2267
|
amount,
|
2205
2268
|
assetId,
|
2206
2269
|
txPointer: "0x00000000000000000000000000000000",
|
2207
|
-
witnessIndex
|
2270
|
+
witnessIndex,
|
2271
|
+
predicate
|
2208
2272
|
};
|
2209
2273
|
this.pushInput(input);
|
2210
2274
|
this.addChangeOutput(owner, assetId);
|
@@ -2216,7 +2280,7 @@ var BaseTransactionRequest = class {
|
|
2216
2280
|
* @param message - Message resource.
|
2217
2281
|
*/
|
2218
2282
|
addMessageInput(message) {
|
2219
|
-
const { recipient, sender, amount, assetId } = message;
|
2283
|
+
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
2220
2284
|
let witnessIndex;
|
2221
2285
|
if (message.predicate) {
|
2222
2286
|
witnessIndex = 0;
|
@@ -2227,12 +2291,13 @@ var BaseTransactionRequest = class {
|
|
2227
2291
|
}
|
2228
2292
|
}
|
2229
2293
|
const input = {
|
2230
|
-
|
2231
|
-
type:
|
2294
|
+
nonce,
|
2295
|
+
type: import_transactions7.InputType.Message,
|
2232
2296
|
sender: sender.toB256(),
|
2233
2297
|
recipient: recipient.toB256(),
|
2234
2298
|
amount,
|
2235
|
-
witnessIndex
|
2299
|
+
witnessIndex,
|
2300
|
+
predicate
|
2236
2301
|
};
|
2237
2302
|
this.pushInput(input);
|
2238
2303
|
this.addChangeOutput(recipient, assetId);
|
@@ -2272,7 +2337,7 @@ var BaseTransactionRequest = class {
|
|
2272
2337
|
*/
|
2273
2338
|
addCoinOutput(to, amount, assetId) {
|
2274
2339
|
this.pushOutput({
|
2275
|
-
type:
|
2340
|
+
type: import_transactions7.OutputType.Coin,
|
2276
2341
|
to: (0, import_address.addressify)(to).toB256(),
|
2277
2342
|
amount,
|
2278
2343
|
assetId
|
@@ -2288,7 +2353,7 @@ var BaseTransactionRequest = class {
|
|
2288
2353
|
addCoinOutputs(to, quantities) {
|
2289
2354
|
quantities.map(coinQuantityfy).forEach((quantity) => {
|
2290
2355
|
this.pushOutput({
|
2291
|
-
type:
|
2356
|
+
type: import_transactions7.OutputType.Coin,
|
2292
2357
|
to: (0, import_address.addressify)(to).toB256(),
|
2293
2358
|
amount: quantity.amount,
|
2294
2359
|
assetId: quantity.assetId
|
@@ -2308,7 +2373,7 @@ var BaseTransactionRequest = class {
|
|
2308
2373
|
);
|
2309
2374
|
if (!changeOutput) {
|
2310
2375
|
this.pushOutput({
|
2311
|
-
type:
|
2376
|
+
type: import_transactions7.OutputType.Change,
|
2312
2377
|
to: (0, import_address.addressify)(to).toB256(),
|
2313
2378
|
assetId
|
2314
2379
|
});
|
@@ -2379,7 +2444,7 @@ var BaseTransactionRequest = class {
|
|
2379
2444
|
const assetInput = findAssetInput(assetId);
|
2380
2445
|
let usedQuantity = quantity;
|
2381
2446
|
if (assetId === baseAssetId) {
|
2382
|
-
usedQuantity = (0,
|
2447
|
+
usedQuantity = (0, import_math8.bn)("1000000000000000000");
|
2383
2448
|
}
|
2384
2449
|
if (assetInput && "assetId" in assetInput) {
|
2385
2450
|
assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
|
@@ -2391,13 +2456,13 @@ var BaseTransactionRequest = class {
|
|
2391
2456
|
amount: usedQuantity,
|
2392
2457
|
assetId,
|
2393
2458
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2394
|
-
blockCreated: (0,
|
2395
|
-
txCreatedIdx: (0,
|
2459
|
+
blockCreated: (0, import_math8.bn)(1),
|
2460
|
+
txCreatedIdx: (0, import_math8.bn)(1)
|
2396
2461
|
}
|
2397
2462
|
]);
|
2398
2463
|
}
|
2399
2464
|
};
|
2400
|
-
updateAssetInput(baseAssetId, (0,
|
2465
|
+
updateAssetInput(baseAssetId, (0, import_math8.bn)(1e11));
|
2401
2466
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2402
2467
|
}
|
2403
2468
|
/**
|
@@ -2408,7 +2473,7 @@ var BaseTransactionRequest = class {
|
|
2408
2473
|
*/
|
2409
2474
|
getCoinOutputsQuantities() {
|
2410
2475
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2411
|
-
amount: (0,
|
2476
|
+
amount: (0, import_math8.bn)(amount),
|
2412
2477
|
assetId: assetId.toString()
|
2413
2478
|
}));
|
2414
2479
|
return coinsQuantities;
|
@@ -2422,22 +2487,33 @@ var BaseTransactionRequest = class {
|
|
2422
2487
|
toJSON() {
|
2423
2488
|
return normalizeJSON(this);
|
2424
2489
|
}
|
2490
|
+
removeWitness(index) {
|
2491
|
+
this.witnesses.splice(index, 1);
|
2492
|
+
this.adjustWitnessIndexes(index);
|
2493
|
+
}
|
2494
|
+
adjustWitnessIndexes(removedIndex) {
|
2495
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2496
|
+
if (input.witnessIndex > removedIndex) {
|
2497
|
+
input.witnessIndex -= 1;
|
2498
|
+
}
|
2499
|
+
});
|
2500
|
+
}
|
2425
2501
|
updatePredicateGasUsed(inputs) {
|
2426
2502
|
this.inputs.forEach((i) => {
|
2427
2503
|
let correspondingInput;
|
2428
2504
|
switch (i.type) {
|
2429
|
-
case
|
2430
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2505
|
+
case import_transactions7.InputType.Coin:
|
2506
|
+
correspondingInput = inputs.find((x) => x.type === import_transactions7.InputType.Coin && x.owner === i.owner);
|
2431
2507
|
break;
|
2432
|
-
case
|
2508
|
+
case import_transactions7.InputType.Message:
|
2433
2509
|
correspondingInput = inputs.find(
|
2434
|
-
(x) => x.type ===
|
2510
|
+
(x) => x.type === import_transactions7.InputType.Message && x.sender === i.sender
|
2435
2511
|
);
|
2436
2512
|
break;
|
2437
2513
|
default:
|
2438
2514
|
return;
|
2439
2515
|
}
|
2440
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0,
|
2516
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math8.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2441
2517
|
i.predicate = correspondingInput.predicate;
|
2442
2518
|
i.predicateData = correspondingInput.predicateData;
|
2443
2519
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2457,38 +2533,38 @@ var BaseTransactionRequest = class {
|
|
2457
2533
|
|
2458
2534
|
// src/providers/transaction-request/create-transaction-request.ts
|
2459
2535
|
var import_configs8 = require("@fuel-ts/address/configs");
|
2460
|
-
var
|
2461
|
-
var
|
2536
|
+
var import_math10 = require("@fuel-ts/math");
|
2537
|
+
var import_transactions9 = require("@fuel-ts/transactions");
|
2462
2538
|
var import_utils13 = require("@fuel-ts/utils");
|
2463
2539
|
|
2464
2540
|
// src/providers/transaction-request/hash-transaction.ts
|
2465
2541
|
var import_configs7 = require("@fuel-ts/address/configs");
|
2466
2542
|
var import_hasher = require("@fuel-ts/hasher");
|
2467
|
-
var
|
2468
|
-
var
|
2543
|
+
var import_math9 = require("@fuel-ts/math");
|
2544
|
+
var import_transactions8 = require("@fuel-ts/transactions");
|
2469
2545
|
var import_utils11 = require("@fuel-ts/utils");
|
2470
2546
|
var import_ramda2 = require("ramda");
|
2471
2547
|
function hashTransaction(transactionRequest, chainId) {
|
2472
2548
|
const transaction = transactionRequest.toTransaction();
|
2473
|
-
if (transaction.type ===
|
2549
|
+
if (transaction.type === import_transactions8.TransactionType.Script) {
|
2474
2550
|
transaction.receiptsRoot = import_configs7.ZeroBytes32;
|
2475
2551
|
}
|
2476
2552
|
transaction.inputs = transaction.inputs.map((input) => {
|
2477
2553
|
const inputClone = (0, import_ramda2.clone)(input);
|
2478
2554
|
switch (inputClone.type) {
|
2479
|
-
case
|
2555
|
+
case import_transactions8.InputType.Coin: {
|
2480
2556
|
inputClone.txPointer = {
|
2481
2557
|
blockHeight: 0,
|
2482
2558
|
txIndex: 0
|
2483
2559
|
};
|
2484
|
-
inputClone.predicateGasUsed = (0,
|
2560
|
+
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
2485
2561
|
return inputClone;
|
2486
2562
|
}
|
2487
|
-
case
|
2488
|
-
inputClone.predicateGasUsed = (0,
|
2563
|
+
case import_transactions8.InputType.Message: {
|
2564
|
+
inputClone.predicateGasUsed = (0, import_math9.bn)(0);
|
2489
2565
|
return inputClone;
|
2490
2566
|
}
|
2491
|
-
case
|
2567
|
+
case import_transactions8.InputType.Contract: {
|
2492
2568
|
inputClone.txPointer = {
|
2493
2569
|
blockHeight: 0,
|
2494
2570
|
txIndex: 0
|
@@ -2506,18 +2582,18 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2506
2582
|
transaction.outputs = transaction.outputs.map((output) => {
|
2507
2583
|
const outputClone = (0, import_ramda2.clone)(output);
|
2508
2584
|
switch (outputClone.type) {
|
2509
|
-
case
|
2585
|
+
case import_transactions8.OutputType.Contract: {
|
2510
2586
|
outputClone.balanceRoot = import_configs7.ZeroBytes32;
|
2511
2587
|
outputClone.stateRoot = import_configs7.ZeroBytes32;
|
2512
2588
|
return outputClone;
|
2513
2589
|
}
|
2514
|
-
case
|
2515
|
-
outputClone.amount = (0,
|
2590
|
+
case import_transactions8.OutputType.Change: {
|
2591
|
+
outputClone.amount = (0, import_math9.bn)(0);
|
2516
2592
|
return outputClone;
|
2517
2593
|
}
|
2518
|
-
case
|
2594
|
+
case import_transactions8.OutputType.Variable: {
|
2519
2595
|
outputClone.to = import_configs7.ZeroBytes32;
|
2520
|
-
outputClone.amount = (0,
|
2596
|
+
outputClone.amount = (0, import_math9.bn)(0);
|
2521
2597
|
outputClone.assetId = import_configs7.ZeroBytes32;
|
2522
2598
|
return outputClone;
|
2523
2599
|
}
|
@@ -2528,7 +2604,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2528
2604
|
transaction.witnessesCount = 0;
|
2529
2605
|
transaction.witnesses = [];
|
2530
2606
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2531
|
-
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new
|
2607
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions8.TransactionCoder().encode(transaction)]);
|
2532
2608
|
return (0, import_hasher.sha256)(concatenatedData);
|
2533
2609
|
}
|
2534
2610
|
|
@@ -2564,7 +2640,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2564
2640
|
return new this(obj);
|
2565
2641
|
}
|
2566
2642
|
/** Type of the transaction */
|
2567
|
-
type =
|
2643
|
+
type = import_transactions9.TransactionType.Create;
|
2568
2644
|
/** Witness index of contract bytecode to create */
|
2569
2645
|
bytecodeWitnessIndex;
|
2570
2646
|
/** Salt */
|
@@ -2592,10 +2668,10 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2592
2668
|
const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
|
2593
2669
|
const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
|
2594
2670
|
return {
|
2595
|
-
type:
|
2671
|
+
type: import_transactions9.TransactionType.Create,
|
2596
2672
|
...baseTransaction,
|
2597
2673
|
bytecodeWitnessIndex,
|
2598
|
-
storageSlotsCount: (0,
|
2674
|
+
storageSlotsCount: (0, import_math10.bn)(storageSlots.length),
|
2599
2675
|
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
|
2600
2676
|
storageSlots
|
2601
2677
|
};
|
@@ -2607,7 +2683,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2607
2683
|
*/
|
2608
2684
|
getContractCreatedOutputs() {
|
2609
2685
|
return this.outputs.filter(
|
2610
|
-
(output) => output.type ===
|
2686
|
+
(output) => output.type === import_transactions9.OutputType.ContractCreated
|
2611
2687
|
);
|
2612
2688
|
}
|
2613
2689
|
/**
|
@@ -2628,14 +2704,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2628
2704
|
*/
|
2629
2705
|
addContractCreatedOutput(contractId, stateRoot) {
|
2630
2706
|
this.pushOutput({
|
2631
|
-
type:
|
2707
|
+
type: import_transactions9.OutputType.ContractCreated,
|
2632
2708
|
contractId,
|
2633
2709
|
stateRoot
|
2634
2710
|
});
|
2635
2711
|
}
|
2636
2712
|
metadataGas(gasCosts) {
|
2637
2713
|
return calculateMetadataGasForTxCreate({
|
2638
|
-
contractBytesSize: (0,
|
2714
|
+
contractBytesSize: (0, import_math10.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2639
2715
|
gasCosts,
|
2640
2716
|
stateRootSize: this.storageSlots.length,
|
2641
2717
|
txBytesSize: this.byteSize()
|
@@ -2647,8 +2723,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2647
2723
|
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
2648
2724
|
var import_address2 = require("@fuel-ts/address");
|
2649
2725
|
var import_configs9 = require("@fuel-ts/address/configs");
|
2650
|
-
var
|
2651
|
-
var
|
2726
|
+
var import_math11 = require("@fuel-ts/math");
|
2727
|
+
var import_transactions10 = require("@fuel-ts/transactions");
|
2652
2728
|
var import_utils15 = require("@fuel-ts/utils");
|
2653
2729
|
|
2654
2730
|
// src/providers/transaction-request/scripts.ts
|
@@ -2686,7 +2762,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2686
2762
|
return new this(obj);
|
2687
2763
|
}
|
2688
2764
|
/** Type of the transaction */
|
2689
|
-
type =
|
2765
|
+
type = import_transactions10.TransactionType.Script;
|
2690
2766
|
/** Gas limit for transaction */
|
2691
2767
|
gasLimit;
|
2692
2768
|
/** Script to execute */
|
@@ -2701,7 +2777,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2701
2777
|
*/
|
2702
2778
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2703
2779
|
super(rest);
|
2704
|
-
this.gasLimit = (0,
|
2780
|
+
this.gasLimit = (0, import_math11.bn)(gasLimit);
|
2705
2781
|
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2706
2782
|
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2707
2783
|
this.abis = rest.abis;
|
@@ -2715,11 +2791,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2715
2791
|
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2716
2792
|
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2717
2793
|
return {
|
2718
|
-
type:
|
2794
|
+
type: import_transactions10.TransactionType.Script,
|
2719
2795
|
scriptGasLimit: this.gasLimit,
|
2720
2796
|
...super.getBaseTransaction(),
|
2721
|
-
scriptLength: (0,
|
2722
|
-
scriptDataLength: (0,
|
2797
|
+
scriptLength: (0, import_math11.bn)(script.length),
|
2798
|
+
scriptDataLength: (0, import_math11.bn)(scriptData.length),
|
2723
2799
|
receiptsRoot: import_configs9.ZeroBytes32,
|
2724
2800
|
script: (0, import_utils15.hexlify)(script),
|
2725
2801
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
@@ -2732,7 +2808,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2732
2808
|
*/
|
2733
2809
|
getContractInputs() {
|
2734
2810
|
return this.inputs.filter(
|
2735
|
-
(input) => input.type ===
|
2811
|
+
(input) => input.type === import_transactions10.InputType.Contract
|
2736
2812
|
);
|
2737
2813
|
}
|
2738
2814
|
/**
|
@@ -2742,7 +2818,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2742
2818
|
*/
|
2743
2819
|
getContractOutputs() {
|
2744
2820
|
return this.outputs.filter(
|
2745
|
-
(output) => output.type ===
|
2821
|
+
(output) => output.type === import_transactions10.OutputType.Contract
|
2746
2822
|
);
|
2747
2823
|
}
|
2748
2824
|
/**
|
@@ -2752,7 +2828,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2752
2828
|
*/
|
2753
2829
|
getVariableOutputs() {
|
2754
2830
|
return this.outputs.filter(
|
2755
|
-
(output) => output.type ===
|
2831
|
+
(output) => output.type === import_transactions10.OutputType.Variable
|
2756
2832
|
);
|
2757
2833
|
}
|
2758
2834
|
/**
|
@@ -2775,7 +2851,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2775
2851
|
let outputsNumber = numberOfVariables;
|
2776
2852
|
while (outputsNumber) {
|
2777
2853
|
this.pushOutput({
|
2778
|
-
type:
|
2854
|
+
type: import_transactions10.OutputType.Variable
|
2779
2855
|
});
|
2780
2856
|
outputsNumber -= 1;
|
2781
2857
|
}
|
@@ -2812,12 +2888,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2812
2888
|
return this;
|
2813
2889
|
}
|
2814
2890
|
const inputIndex = super.pushInput({
|
2815
|
-
type:
|
2891
|
+
type: import_transactions10.InputType.Contract,
|
2816
2892
|
contractId: contractAddress.toB256(),
|
2817
2893
|
txPointer: "0x00000000000000000000000000000000"
|
2818
2894
|
});
|
2819
2895
|
this.pushOutput({
|
2820
|
-
type:
|
2896
|
+
type: import_transactions10.OutputType.Contract,
|
2821
2897
|
inputIndex
|
2822
2898
|
});
|
2823
2899
|
return this;
|
@@ -2854,17 +2930,17 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2854
2930
|
|
2855
2931
|
// src/providers/transaction-request/utils.ts
|
2856
2932
|
var import_errors9 = require("@fuel-ts/errors");
|
2857
|
-
var
|
2933
|
+
var import_transactions11 = require("@fuel-ts/transactions");
|
2858
2934
|
var transactionRequestify = (obj) => {
|
2859
2935
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2860
2936
|
return obj;
|
2861
2937
|
}
|
2862
2938
|
const { type } = obj;
|
2863
2939
|
switch (obj.type) {
|
2864
|
-
case
|
2940
|
+
case import_transactions11.TransactionType.Script: {
|
2865
2941
|
return ScriptTransactionRequest.from(obj);
|
2866
2942
|
}
|
2867
|
-
case
|
2943
|
+
case import_transactions11.TransactionType.Create: {
|
2868
2944
|
return CreateTransactionRequest.from(obj);
|
2869
2945
|
}
|
2870
2946
|
default: {
|
@@ -2872,36 +2948,21 @@ var transactionRequestify = (obj) => {
|
|
2872
2948
|
}
|
2873
2949
|
}
|
2874
2950
|
};
|
2875
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2876
|
-
(acc, input) => {
|
2877
|
-
if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
|
2878
|
-
acc.utxos.push(input.id);
|
2879
|
-
}
|
2880
|
-
if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
|
2881
|
-
acc.messages.push(input.nonce);
|
2882
|
-
}
|
2883
|
-
return acc;
|
2884
|
-
},
|
2885
|
-
{
|
2886
|
-
utxos: [],
|
2887
|
-
messages: []
|
2888
|
-
}
|
2889
|
-
);
|
2890
2951
|
|
2891
2952
|
// src/providers/transaction-response/transaction-response.ts
|
2892
2953
|
var import_errors13 = require("@fuel-ts/errors");
|
2893
|
-
var
|
2894
|
-
var
|
2954
|
+
var import_math17 = require("@fuel-ts/math");
|
2955
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
2895
2956
|
var import_utils20 = require("@fuel-ts/utils");
|
2896
2957
|
|
2897
2958
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2898
|
-
var
|
2899
|
-
var
|
2959
|
+
var import_math16 = require("@fuel-ts/math");
|
2960
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
2900
2961
|
var import_utils18 = require("@fuel-ts/utils");
|
2901
2962
|
|
2902
2963
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2903
|
-
var
|
2904
|
-
var
|
2964
|
+
var import_math12 = require("@fuel-ts/math");
|
2965
|
+
var import_transactions12 = require("@fuel-ts/transactions");
|
2905
2966
|
var import_utils16 = require("@fuel-ts/utils");
|
2906
2967
|
var calculateTXFeeForSummary = (params) => {
|
2907
2968
|
const {
|
@@ -2914,19 +2975,19 @@ var calculateTXFeeForSummary = (params) => {
|
|
2914
2975
|
if (totalFee) {
|
2915
2976
|
return totalFee;
|
2916
2977
|
}
|
2917
|
-
const gasPerByte = (0,
|
2918
|
-
const gasPriceFactor = (0,
|
2978
|
+
const gasPerByte = (0, import_math12.bn)(feeParams.gasPerByte);
|
2979
|
+
const gasPriceFactor = (0, import_math12.bn)(feeParams.gasPriceFactor);
|
2919
2980
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2920
|
-
const [transaction] = new
|
2981
|
+
const [transaction] = new import_transactions12.TransactionCoder().decode(transactionBytes, 0);
|
2921
2982
|
const { type, witnesses, inputs, policies } = transaction;
|
2922
|
-
let metadataGas = (0,
|
2923
|
-
let gasLimit = (0,
|
2924
|
-
if (type !==
|
2925
|
-
return (0,
|
2983
|
+
let metadataGas = (0, import_math12.bn)(0);
|
2984
|
+
let gasLimit = (0, import_math12.bn)(0);
|
2985
|
+
if (type !== import_transactions12.TransactionType.Create && type !== import_transactions12.TransactionType.Script) {
|
2986
|
+
return (0, import_math12.bn)(0);
|
2926
2987
|
}
|
2927
|
-
if (type ===
|
2988
|
+
if (type === import_transactions12.TransactionType.Create) {
|
2928
2989
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2929
|
-
const contractBytesSize = (0,
|
2990
|
+
const contractBytesSize = (0, import_math12.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2930
2991
|
metadataGas = calculateMetadataGasForTxCreate({
|
2931
2992
|
contractBytesSize,
|
2932
2993
|
gasCosts,
|
@@ -2945,12 +3006,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
2945
3006
|
}
|
2946
3007
|
const minGas = getMinGas({
|
2947
3008
|
gasCosts,
|
2948
|
-
gasPerByte: (0,
|
3009
|
+
gasPerByte: (0, import_math12.bn)(gasPerByte),
|
2949
3010
|
inputs,
|
2950
3011
|
metadataGas,
|
2951
3012
|
txBytesSize: transactionBytes.length
|
2952
3013
|
});
|
2953
|
-
const witnessLimit = policies.find((policy) => policy.type ===
|
3014
|
+
const witnessLimit = policies.find((policy) => policy.type === import_transactions12.PolicyType.WitnessLimit)?.data;
|
2954
3015
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2955
3016
|
const maxGas = getMaxGas({
|
2956
3017
|
gasPerByte,
|
@@ -2972,12 +3033,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
2972
3033
|
// src/providers/transaction-summary/operations.ts
|
2973
3034
|
var import_configs10 = require("@fuel-ts/address/configs");
|
2974
3035
|
var import_errors11 = require("@fuel-ts/errors");
|
2975
|
-
var
|
2976
|
-
var
|
3036
|
+
var import_math14 = require("@fuel-ts/math");
|
3037
|
+
var import_transactions15 = require("@fuel-ts/transactions");
|
2977
3038
|
|
2978
3039
|
// src/providers/transaction-summary/call.ts
|
2979
3040
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
2980
|
-
var
|
3041
|
+
var import_math13 = require("@fuel-ts/math");
|
2981
3042
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2982
3043
|
const abiInterface = new import_abi_coder4.Interface(abi);
|
2983
3044
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2986,7 +3047,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2986
3047
|
let encodedArgs;
|
2987
3048
|
if (functionFragment.isInputDataPointer) {
|
2988
3049
|
if (rawPayload) {
|
2989
|
-
const argsOffset = (0,
|
3050
|
+
const argsOffset = (0, import_math13.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2990
3051
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2991
3052
|
}
|
2992
3053
|
} else {
|
@@ -3021,7 +3082,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
3021
3082
|
|
3022
3083
|
// src/providers/transaction-summary/input.ts
|
3023
3084
|
var import_errors10 = require("@fuel-ts/errors");
|
3024
|
-
var
|
3085
|
+
var import_transactions13 = require("@fuel-ts/transactions");
|
3025
3086
|
function getInputsByTypes(inputs, types) {
|
3026
3087
|
return inputs.filter((i) => types.includes(i.type));
|
3027
3088
|
}
|
@@ -3029,16 +3090,16 @@ function getInputsByType(inputs, type) {
|
|
3029
3090
|
return inputs.filter((i) => i.type === type);
|
3030
3091
|
}
|
3031
3092
|
function getInputsCoin(inputs) {
|
3032
|
-
return getInputsByType(inputs,
|
3093
|
+
return getInputsByType(inputs, import_transactions13.InputType.Coin);
|
3033
3094
|
}
|
3034
3095
|
function getInputsMessage(inputs) {
|
3035
|
-
return getInputsByType(inputs,
|
3096
|
+
return getInputsByType(inputs, import_transactions13.InputType.Message);
|
3036
3097
|
}
|
3037
3098
|
function getInputsCoinAndMessage(inputs) {
|
3038
|
-
return getInputsByTypes(inputs, [
|
3099
|
+
return getInputsByTypes(inputs, [import_transactions13.InputType.Coin, import_transactions13.InputType.Message]);
|
3039
3100
|
}
|
3040
3101
|
function getInputsContract(inputs) {
|
3041
|
-
return getInputsByType(inputs,
|
3102
|
+
return getInputsByType(inputs, import_transactions13.InputType.Contract);
|
3042
3103
|
}
|
3043
3104
|
function getInputFromAssetId(inputs, assetId) {
|
3044
3105
|
const coinInputs = getInputsCoin(inputs);
|
@@ -3057,7 +3118,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3057
3118
|
if (!contractInput) {
|
3058
3119
|
return void 0;
|
3059
3120
|
}
|
3060
|
-
if (contractInput.type !==
|
3121
|
+
if (contractInput.type !== import_transactions13.InputType.Contract) {
|
3061
3122
|
throw new import_errors10.FuelError(
|
3062
3123
|
import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
|
3063
3124
|
`Contract input should be of type 'contract'.`
|
@@ -3066,34 +3127,34 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3066
3127
|
return contractInput;
|
3067
3128
|
}
|
3068
3129
|
function getInputAccountAddress(input) {
|
3069
|
-
if (input.type ===
|
3130
|
+
if (input.type === import_transactions13.InputType.Coin) {
|
3070
3131
|
return input.owner.toString();
|
3071
3132
|
}
|
3072
|
-
if (input.type ===
|
3133
|
+
if (input.type === import_transactions13.InputType.Message) {
|
3073
3134
|
return input.recipient.toString();
|
3074
3135
|
}
|
3075
3136
|
return "";
|
3076
3137
|
}
|
3077
3138
|
|
3078
3139
|
// src/providers/transaction-summary/output.ts
|
3079
|
-
var
|
3140
|
+
var import_transactions14 = require("@fuel-ts/transactions");
|
3080
3141
|
function getOutputsByType(outputs, type) {
|
3081
3142
|
return outputs.filter((o) => o.type === type);
|
3082
3143
|
}
|
3083
3144
|
function getOutputsContractCreated(outputs) {
|
3084
|
-
return getOutputsByType(outputs,
|
3145
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.ContractCreated);
|
3085
3146
|
}
|
3086
3147
|
function getOutputsCoin(outputs) {
|
3087
|
-
return getOutputsByType(outputs,
|
3148
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Coin);
|
3088
3149
|
}
|
3089
3150
|
function getOutputsChange(outputs) {
|
3090
|
-
return getOutputsByType(outputs,
|
3151
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Change);
|
3091
3152
|
}
|
3092
3153
|
function getOutputsContract(outputs) {
|
3093
|
-
return getOutputsByType(outputs,
|
3154
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Contract);
|
3094
3155
|
}
|
3095
3156
|
function getOutputsVariable(outputs) {
|
3096
|
-
return getOutputsByType(outputs,
|
3157
|
+
return getOutputsByType(outputs, import_transactions14.OutputType.Variable);
|
3097
3158
|
}
|
3098
3159
|
|
3099
3160
|
// src/providers/transaction-summary/types.ts
|
@@ -3142,11 +3203,11 @@ function getReceiptsByType(receipts, type) {
|
|
3142
3203
|
}
|
3143
3204
|
function getTransactionTypeName(transactionType) {
|
3144
3205
|
switch (transactionType) {
|
3145
|
-
case
|
3206
|
+
case import_transactions15.TransactionType.Mint:
|
3146
3207
|
return "Mint" /* Mint */;
|
3147
|
-
case
|
3208
|
+
case import_transactions15.TransactionType.Create:
|
3148
3209
|
return "Create" /* Create */;
|
3149
|
-
case
|
3210
|
+
case import_transactions15.TransactionType.Script:
|
3150
3211
|
return "Script" /* Script */;
|
3151
3212
|
default:
|
3152
3213
|
throw new import_errors11.FuelError(
|
@@ -3178,10 +3239,10 @@ function hasSameAssetId(a) {
|
|
3178
3239
|
return (b) => a.assetId === b.assetId;
|
3179
3240
|
}
|
3180
3241
|
function getReceiptsCall(receipts) {
|
3181
|
-
return getReceiptsByType(receipts,
|
3242
|
+
return getReceiptsByType(receipts, import_transactions15.ReceiptType.Call);
|
3182
3243
|
}
|
3183
3244
|
function getReceiptsMessageOut(receipts) {
|
3184
|
-
return getReceiptsByType(receipts,
|
3245
|
+
return getReceiptsByType(receipts, import_transactions15.ReceiptType.MessageOut);
|
3185
3246
|
}
|
3186
3247
|
var mergeAssets = (op1, op2) => {
|
3187
3248
|
const assets1 = op1.assetsSent || [];
|
@@ -3194,7 +3255,7 @@ var mergeAssets = (op1, op2) => {
|
|
3194
3255
|
if (!matchingAsset) {
|
3195
3256
|
return asset1;
|
3196
3257
|
}
|
3197
|
-
const mergedAmount = (0,
|
3258
|
+
const mergedAmount = (0, import_math14.bn)(asset1.amount).add(matchingAsset.amount);
|
3198
3259
|
return { ...asset1, amount: mergedAmount };
|
3199
3260
|
});
|
3200
3261
|
return mergedAssets.concat(filteredAssets);
|
@@ -3220,7 +3281,7 @@ function addOperation(operations, toAdd) {
|
|
3220
3281
|
return allOperations;
|
3221
3282
|
}
|
3222
3283
|
function getReceiptsTransferOut(receipts) {
|
3223
|
-
return getReceiptsByType(receipts,
|
3284
|
+
return getReceiptsByType(receipts, import_transactions15.ReceiptType.TransferOut);
|
3224
3285
|
}
|
3225
3286
|
function getWithdrawFromFuelOperations({
|
3226
3287
|
inputs,
|
@@ -3380,11 +3441,11 @@ function getTransferOperations({
|
|
3380
3441
|
});
|
3381
3442
|
const transferReceipts = getReceiptsByType(
|
3382
3443
|
receipts,
|
3383
|
-
|
3444
|
+
import_transactions15.ReceiptType.Transfer
|
3384
3445
|
);
|
3385
3446
|
const transferOutReceipts = getReceiptsByType(
|
3386
3447
|
receipts,
|
3387
|
-
|
3448
|
+
import_transactions15.ReceiptType.TransferOut
|
3388
3449
|
);
|
3389
3450
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
3390
3451
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3469,17 +3530,17 @@ function getOperations({
|
|
3469
3530
|
}
|
3470
3531
|
|
3471
3532
|
// src/providers/transaction-summary/receipt.ts
|
3472
|
-
var
|
3533
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
3473
3534
|
var processGqlReceipt = (gqlReceipt) => {
|
3474
3535
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3475
3536
|
switch (receipt.type) {
|
3476
|
-
case
|
3537
|
+
case import_transactions16.ReceiptType.ReturnData: {
|
3477
3538
|
return {
|
3478
3539
|
...receipt,
|
3479
3540
|
data: gqlReceipt.data || "0x"
|
3480
3541
|
};
|
3481
3542
|
}
|
3482
|
-
case
|
3543
|
+
case import_transactions16.ReceiptType.LogData: {
|
3483
3544
|
return {
|
3484
3545
|
...receipt,
|
3485
3546
|
data: gqlReceipt.data || "0x"
|
@@ -3492,7 +3553,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3492
3553
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3493
3554
|
const mintedAssets = [];
|
3494
3555
|
receipts.forEach((receipt) => {
|
3495
|
-
if (receipt.type ===
|
3556
|
+
if (receipt.type === import_transactions16.ReceiptType.Mint) {
|
3496
3557
|
mintedAssets.push({
|
3497
3558
|
subId: receipt.subId,
|
3498
3559
|
contractId: receipt.contractId,
|
@@ -3506,7 +3567,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3506
3567
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3507
3568
|
const burnedAssets = [];
|
3508
3569
|
receipts.forEach((receipt) => {
|
3509
|
-
if (receipt.type ===
|
3570
|
+
if (receipt.type === import_transactions16.ReceiptType.Burn) {
|
3510
3571
|
burnedAssets.push({
|
3511
3572
|
subId: receipt.subId,
|
3512
3573
|
contractId: receipt.contractId,
|
@@ -3520,7 +3581,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3520
3581
|
|
3521
3582
|
// src/providers/transaction-summary/status.ts
|
3522
3583
|
var import_errors12 = require("@fuel-ts/errors");
|
3523
|
-
var
|
3584
|
+
var import_math15 = require("@fuel-ts/math");
|
3524
3585
|
var getTransactionStatusName = (gqlStatus) => {
|
3525
3586
|
switch (gqlStatus) {
|
3526
3587
|
case "FailureStatus":
|
@@ -3554,15 +3615,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
|
|
3554
3615
|
time = gqlTransactionStatus.time;
|
3555
3616
|
blockId = gqlTransactionStatus.block.id;
|
3556
3617
|
isStatusSuccess = true;
|
3557
|
-
totalFee = (0,
|
3558
|
-
totalGas = (0,
|
3618
|
+
totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
|
3619
|
+
totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
|
3559
3620
|
break;
|
3560
3621
|
case "FailureStatus":
|
3561
3622
|
time = gqlTransactionStatus.time;
|
3562
3623
|
blockId = gqlTransactionStatus.block.id;
|
3563
3624
|
isStatusFailure = true;
|
3564
|
-
totalFee = (0,
|
3565
|
-
totalGas = (0,
|
3625
|
+
totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
|
3626
|
+
totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
|
3566
3627
|
break;
|
3567
3628
|
case "SubmittedStatus":
|
3568
3629
|
time = gqlTransactionStatus.time;
|
@@ -3612,7 +3673,7 @@ function assembleTransactionSummary(params) {
|
|
3612
3673
|
maxInputs
|
3613
3674
|
});
|
3614
3675
|
const typeName = getTransactionTypeName(transaction.type);
|
3615
|
-
const tip = (0,
|
3676
|
+
const tip = (0, import_math16.bn)(transaction.policies?.find((policy) => policy.type === import_transactions17.PolicyType.Tip)?.data);
|
3616
3677
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3617
3678
|
const fee = calculateTXFeeForSummary({
|
3618
3679
|
totalFee,
|
@@ -3663,12 +3724,12 @@ function assembleTransactionSummary(params) {
|
|
3663
3724
|
|
3664
3725
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3665
3726
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
3666
|
-
var
|
3727
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
3667
3728
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3668
3729
|
return receipts.reduce((logs, receipt) => {
|
3669
|
-
if (receipt.type ===
|
3730
|
+
if (receipt.type === import_transactions18.ReceiptType.LogData || receipt.type === import_transactions18.ReceiptType.Log) {
|
3670
3731
|
const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
|
3671
|
-
const data = receipt.type ===
|
3732
|
+
const data = receipt.type === import_transactions18.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3672
3733
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3673
3734
|
logs.push(decodedLog);
|
3674
3735
|
}
|
@@ -3683,7 +3744,7 @@ var TransactionResponse = class {
|
|
3683
3744
|
/** Current provider */
|
3684
3745
|
provider;
|
3685
3746
|
/** Gas used on the transaction */
|
3686
|
-
gasUsed = (0,
|
3747
|
+
gasUsed = (0, import_math17.bn)(0);
|
3687
3748
|
/** The graphql Transaction with receipts object. */
|
3688
3749
|
gqlTransaction;
|
3689
3750
|
abis;
|
@@ -3741,7 +3802,7 @@ var TransactionResponse = class {
|
|
3741
3802
|
* @returns The decoded transaction.
|
3742
3803
|
*/
|
3743
3804
|
decodeTransaction(transactionWithReceipts) {
|
3744
|
-
return new
|
3805
|
+
return new import_transactions19.TransactionCoder().decode(
|
3745
3806
|
(0, import_utils20.arrayify)(transactionWithReceipts.rawPayload),
|
3746
3807
|
0
|
3747
3808
|
)?.[0];
|
@@ -3851,7 +3912,6 @@ var TransactionResponse = class {
|
|
3851
3912
|
};
|
3852
3913
|
|
3853
3914
|
// src/providers/utils/auto-retry-fetch.ts
|
3854
|
-
var import_utils22 = require("@fuel-ts/utils");
|
3855
3915
|
function getWaitDelay(options, retryAttemptNum) {
|
3856
3916
|
const duration = options.baseDelay ?? 150;
|
3857
3917
|
switch (options.backoff) {
|
@@ -3881,7 +3941,7 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
3881
3941
|
throw error;
|
3882
3942
|
}
|
3883
3943
|
const delay = getWaitDelay(options, retryNum);
|
3884
|
-
await
|
3944
|
+
await sleep(delay);
|
3885
3945
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
3886
3946
|
}
|
3887
3947
|
};
|
@@ -3918,47 +3978,47 @@ var processGqlChain = (chain) => {
|
|
3918
3978
|
} = consensusParameters;
|
3919
3979
|
return {
|
3920
3980
|
name,
|
3921
|
-
baseChainHeight: (0,
|
3981
|
+
baseChainHeight: (0, import_math18.bn)(daHeight),
|
3922
3982
|
consensusParameters: {
|
3923
3983
|
version,
|
3924
|
-
chainId: (0,
|
3984
|
+
chainId: (0, import_math18.bn)(chainId),
|
3925
3985
|
baseAssetId,
|
3926
3986
|
feeParameters: {
|
3927
3987
|
version: feeParams.version,
|
3928
|
-
gasPerByte: (0,
|
3929
|
-
gasPriceFactor: (0,
|
3988
|
+
gasPerByte: (0, import_math18.bn)(feeParams.gasPerByte),
|
3989
|
+
gasPriceFactor: (0, import_math18.bn)(feeParams.gasPriceFactor)
|
3930
3990
|
},
|
3931
3991
|
contractParameters: {
|
3932
3992
|
version: contractParams.version,
|
3933
|
-
contractMaxSize: (0,
|
3934
|
-
maxStorageSlots: (0,
|
3993
|
+
contractMaxSize: (0, import_math18.bn)(contractParams.contractMaxSize),
|
3994
|
+
maxStorageSlots: (0, import_math18.bn)(contractParams.maxStorageSlots)
|
3935
3995
|
},
|
3936
3996
|
txParameters: {
|
3937
3997
|
version: txParams.version,
|
3938
|
-
maxInputs: (0,
|
3939
|
-
maxOutputs: (0,
|
3940
|
-
maxWitnesses: (0,
|
3941
|
-
maxGasPerTx: (0,
|
3942
|
-
maxSize: (0,
|
3943
|
-
maxBytecodeSubsections: (0,
|
3998
|
+
maxInputs: (0, import_math18.bn)(txParams.maxInputs),
|
3999
|
+
maxOutputs: (0, import_math18.bn)(txParams.maxOutputs),
|
4000
|
+
maxWitnesses: (0, import_math18.bn)(txParams.maxWitnesses),
|
4001
|
+
maxGasPerTx: (0, import_math18.bn)(txParams.maxGasPerTx),
|
4002
|
+
maxSize: (0, import_math18.bn)(txParams.maxSize),
|
4003
|
+
maxBytecodeSubsections: (0, import_math18.bn)(txParams.maxBytecodeSubsections)
|
3944
4004
|
},
|
3945
4005
|
predicateParameters: {
|
3946
4006
|
version: predicateParams.version,
|
3947
|
-
maxPredicateLength: (0,
|
3948
|
-
maxPredicateDataLength: (0,
|
3949
|
-
maxGasPerPredicate: (0,
|
3950
|
-
maxMessageDataLength: (0,
|
4007
|
+
maxPredicateLength: (0, import_math18.bn)(predicateParams.maxPredicateLength),
|
4008
|
+
maxPredicateDataLength: (0, import_math18.bn)(predicateParams.maxPredicateDataLength),
|
4009
|
+
maxGasPerPredicate: (0, import_math18.bn)(predicateParams.maxGasPerPredicate),
|
4010
|
+
maxMessageDataLength: (0, import_math18.bn)(predicateParams.maxMessageDataLength)
|
3951
4011
|
},
|
3952
4012
|
scriptParameters: {
|
3953
4013
|
version: scriptParams.version,
|
3954
|
-
maxScriptLength: (0,
|
3955
|
-
maxScriptDataLength: (0,
|
4014
|
+
maxScriptLength: (0, import_math18.bn)(scriptParams.maxScriptLength),
|
4015
|
+
maxScriptDataLength: (0, import_math18.bn)(scriptParams.maxScriptDataLength)
|
3956
4016
|
},
|
3957
4017
|
gasCosts
|
3958
4018
|
},
|
3959
4019
|
latestBlock: {
|
3960
4020
|
id: latestBlock.id,
|
3961
|
-
height: (0,
|
4021
|
+
height: (0, import_math18.bn)(latestBlock.height),
|
3962
4022
|
time: latestBlock.header.time,
|
3963
4023
|
transactions: latestBlock.transactions.map((i) => ({
|
3964
4024
|
id: i.id
|
@@ -4154,7 +4214,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4154
4214
|
*/
|
4155
4215
|
async getBlockNumber() {
|
4156
4216
|
const { chain } = await this.operations.getChain();
|
4157
|
-
return (0,
|
4217
|
+
return (0, import_math18.bn)(chain.latestBlock.height, 10);
|
4158
4218
|
}
|
4159
4219
|
/**
|
4160
4220
|
* Returns the chain information.
|
@@ -4164,8 +4224,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4164
4224
|
async fetchNode() {
|
4165
4225
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
4166
4226
|
const processedNodeInfo = {
|
4167
|
-
maxDepth: (0,
|
4168
|
-
maxTx: (0,
|
4227
|
+
maxDepth: (0, import_math18.bn)(nodeInfo.maxDepth),
|
4228
|
+
maxTx: (0, import_math18.bn)(nodeInfo.maxTx),
|
4169
4229
|
nodeVersion: nodeInfo.nodeVersion,
|
4170
4230
|
utxoValidation: nodeInfo.utxoValidation,
|
4171
4231
|
vmBacktrace: nodeInfo.vmBacktrace
|
@@ -4221,9 +4281,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4221
4281
|
if (estimateTxDependencies) {
|
4222
4282
|
await this.estimateTxDependencies(transactionRequest);
|
4223
4283
|
}
|
4224
|
-
const encodedTransaction = (0,
|
4284
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4225
4285
|
let abis;
|
4226
|
-
if (transactionRequest.type ===
|
4286
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4227
4287
|
abis = transactionRequest.abis;
|
4228
4288
|
}
|
4229
4289
|
if (awaitExecution) {
|
@@ -4264,7 +4324,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4264
4324
|
if (estimateTxDependencies) {
|
4265
4325
|
return this.estimateTxDependencies(transactionRequest);
|
4266
4326
|
}
|
4267
|
-
const encodedTransaction = (0,
|
4327
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4268
4328
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4269
4329
|
encodedTransactions: encodedTransaction,
|
4270
4330
|
utxoValidation: utxoValidation || false
|
@@ -4282,13 +4342,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4282
4342
|
async estimatePredicates(transactionRequest) {
|
4283
4343
|
const shouldEstimatePredicates = Boolean(
|
4284
4344
|
transactionRequest.inputs.find(
|
4285
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4345
|
+
(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()
|
4286
4346
|
)
|
4287
4347
|
);
|
4288
4348
|
if (!shouldEstimatePredicates) {
|
4289
4349
|
return transactionRequest;
|
4290
4350
|
}
|
4291
|
-
const encodedTransaction = (0,
|
4351
|
+
const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
|
4292
4352
|
const response = await this.operations.estimatePredicates({
|
4293
4353
|
encodedTransaction
|
4294
4354
|
});
|
@@ -4297,7 +4357,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4297
4357
|
} = response;
|
4298
4358
|
if (inputs) {
|
4299
4359
|
inputs.forEach((input, index) => {
|
4300
|
-
if ("predicateGasUsed" in input && (0,
|
4360
|
+
if ("predicateGasUsed" in input && (0, import_math18.bn)(input.predicateGasUsed).gt(0)) {
|
4301
4361
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4302
4362
|
}
|
4303
4363
|
});
|
@@ -4315,7 +4375,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4315
4375
|
* @returns A promise.
|
4316
4376
|
*/
|
4317
4377
|
async estimateTxDependencies(transactionRequest) {
|
4318
|
-
if (transactionRequest.type ===
|
4378
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Create) {
|
4319
4379
|
return {
|
4320
4380
|
receipts: [],
|
4321
4381
|
outputVariables: 0,
|
@@ -4330,7 +4390,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4330
4390
|
const {
|
4331
4391
|
dryRun: [{ receipts: rawReceipts, status }]
|
4332
4392
|
} = await this.operations.dryRun({
|
4333
|
-
encodedTransactions: [(0,
|
4393
|
+
encodedTransactions: [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())],
|
4334
4394
|
utxoValidation: false
|
4335
4395
|
});
|
4336
4396
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4379,8 +4439,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4379
4439
|
const allRequests = (0, import_ramda3.clone)(transactionRequests);
|
4380
4440
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4381
4441
|
allRequests.forEach((req, index) => {
|
4382
|
-
if (req.type ===
|
4383
|
-
serializedTransactionsMap.set(index, (0,
|
4442
|
+
if (req.type === import_transactions20.TransactionType.Script) {
|
4443
|
+
serializedTransactionsMap.set(index, (0, import_utils22.hexlify)(req.toTransactionBytes()));
|
4384
4444
|
}
|
4385
4445
|
});
|
4386
4446
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4405,7 +4465,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4405
4465
|
);
|
4406
4466
|
const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
|
4407
4467
|
const request = allRequests[requestIdx];
|
4408
|
-
if (hasMissingOutputs && request?.type ===
|
4468
|
+
if (hasMissingOutputs && request?.type === import_transactions20.TransactionType.Script) {
|
4409
4469
|
result.outputVariables += missingOutputVariables.length;
|
4410
4470
|
request.addVariableOutputs(missingOutputVariables.length);
|
4411
4471
|
missingOutputContractIds.forEach(({ contractId }) => {
|
@@ -4416,7 +4476,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4416
4476
|
transactionRequest: request
|
4417
4477
|
});
|
4418
4478
|
request.maxFee = maxFee;
|
4419
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
4479
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils22.hexlify)(request.toTransactionBytes()));
|
4420
4480
|
nextRoundTransactions.push(requestIdx);
|
4421
4481
|
}
|
4422
4482
|
}
|
@@ -4429,7 +4489,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4429
4489
|
if (estimateTxDependencies) {
|
4430
4490
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4431
4491
|
}
|
4432
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
4492
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils22.hexlify)(tx.toTransactionBytes()));
|
4433
4493
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4434
4494
|
encodedTransactions,
|
4435
4495
|
utxoValidation: utxoValidation || false
|
@@ -4455,13 +4515,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4455
4515
|
gasPrice = await this.estimateGasPrice(10);
|
4456
4516
|
}
|
4457
4517
|
const minFee = calculateGasFee({
|
4458
|
-
gasPrice: (0,
|
4518
|
+
gasPrice: (0, import_math18.bn)(gasPrice),
|
4459
4519
|
gas: minGas,
|
4460
4520
|
priceFactor: gasPriceFactor,
|
4461
4521
|
tip: transactionRequest.tip
|
4462
4522
|
}).add(1);
|
4463
|
-
let gasLimit = (0,
|
4464
|
-
if (transactionRequest.type ===
|
4523
|
+
let gasLimit = (0, import_math18.bn)(0);
|
4524
|
+
if (transactionRequest.type === import_transactions20.TransactionType.Script) {
|
4465
4525
|
gasLimit = transactionRequest.gasLimit;
|
4466
4526
|
if (transactionRequest.gasLimit.eq(0)) {
|
4467
4527
|
transactionRequest.gasLimit = minGas;
|
@@ -4473,7 +4533,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4473
4533
|
}
|
4474
4534
|
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
4475
4535
|
const maxFee = calculateGasFee({
|
4476
|
-
gasPrice: (0,
|
4536
|
+
gasPrice: (0, import_math18.bn)(gasPrice),
|
4477
4537
|
gas: maxGas,
|
4478
4538
|
priceFactor: gasPriceFactor,
|
4479
4539
|
tip: transactionRequest.tip
|
@@ -4502,7 +4562,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4502
4562
|
if (estimateTxDependencies) {
|
4503
4563
|
return this.estimateTxDependencies(transactionRequest);
|
4504
4564
|
}
|
4505
|
-
const encodedTransactions = [(0,
|
4565
|
+
const encodedTransactions = [(0, import_utils22.hexlify)(transactionRequest.toTransactionBytes())];
|
4506
4566
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4507
4567
|
encodedTransactions,
|
4508
4568
|
utxoValidation: true
|
@@ -4531,14 +4591,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4531
4591
|
*/
|
4532
4592
|
async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
|
4533
4593
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4534
|
-
const isScriptTransaction = txRequestClone.type ===
|
4594
|
+
const isScriptTransaction = txRequestClone.type === import_transactions20.TransactionType.Script;
|
4535
4595
|
const baseAssetId = this.getBaseAssetId();
|
4536
4596
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4537
4597
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4538
4598
|
const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
|
4539
4599
|
txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
|
4540
4600
|
if (isScriptTransaction) {
|
4541
|
-
txRequestClone.gasLimit = (0,
|
4601
|
+
txRequestClone.gasLimit = (0, import_math18.bn)(0);
|
4542
4602
|
}
|
4543
4603
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4544
4604
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4559,7 +4619,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4559
4619
|
let dryRunStatus;
|
4560
4620
|
let missingContractIds = [];
|
4561
4621
|
let outputVariables = 0;
|
4562
|
-
let gasUsed = (0,
|
4622
|
+
let gasUsed = (0, import_math18.bn)(0);
|
4563
4623
|
txRequestClone.maxFee = maxFee;
|
4564
4624
|
if (isScriptTransaction) {
|
4565
4625
|
txRequestClone.gasLimit = gasLimit;
|
@@ -4618,16 +4678,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4618
4678
|
const result = await this.operations.getCoins({
|
4619
4679
|
first: 10,
|
4620
4680
|
...paginationArgs,
|
4621
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4681
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
|
4622
4682
|
});
|
4623
4683
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4624
4684
|
return coins.map((coin) => ({
|
4625
4685
|
id: coin.utxoId,
|
4626
4686
|
assetId: coin.assetId,
|
4627
|
-
amount: (0,
|
4687
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4628
4688
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4629
|
-
blockCreated: (0,
|
4630
|
-
txCreatedIdx: (0,
|
4689
|
+
blockCreated: (0, import_math18.bn)(coin.blockCreated),
|
4690
|
+
txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
|
4631
4691
|
}));
|
4632
4692
|
}
|
4633
4693
|
/**
|
@@ -4641,19 +4701,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4641
4701
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4642
4702
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4643
4703
|
const excludeInput = {
|
4644
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4645
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4704
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
|
4705
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
|
4646
4706
|
};
|
4647
4707
|
if (this.cache) {
|
4648
4708
|
const uniqueUtxos = new Set(
|
4649
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4709
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
|
4650
4710
|
);
|
4651
4711
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4652
4712
|
}
|
4653
4713
|
const coinsQuery = {
|
4654
4714
|
owner: ownerAddress.toB256(),
|
4655
4715
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4656
|
-
assetId: (0,
|
4716
|
+
assetId: (0, import_utils22.hexlify)(assetId),
|
4657
4717
|
amount: amount.toString(10),
|
4658
4718
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4659
4719
|
})),
|
@@ -4664,9 +4724,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4664
4724
|
switch (coin.type) {
|
4665
4725
|
case "MessageCoin":
|
4666
4726
|
return {
|
4667
|
-
amount: (0,
|
4727
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4668
4728
|
assetId: coin.assetId,
|
4669
|
-
daHeight: (0,
|
4729
|
+
daHeight: (0, import_math18.bn)(coin.daHeight),
|
4670
4730
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4671
4731
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4672
4732
|
nonce: coin.nonce
|
@@ -4674,11 +4734,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4674
4734
|
case "Coin":
|
4675
4735
|
return {
|
4676
4736
|
id: coin.utxoId,
|
4677
|
-
amount: (0,
|
4737
|
+
amount: (0, import_math18.bn)(coin.amount),
|
4678
4738
|
assetId: coin.assetId,
|
4679
4739
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4680
|
-
blockCreated: (0,
|
4681
|
-
txCreatedIdx: (0,
|
4740
|
+
blockCreated: (0, import_math18.bn)(coin.blockCreated),
|
4741
|
+
txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
|
4682
4742
|
};
|
4683
4743
|
default:
|
4684
4744
|
return null;
|
@@ -4695,13 +4755,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4695
4755
|
async getBlock(idOrHeight) {
|
4696
4756
|
let variables;
|
4697
4757
|
if (typeof idOrHeight === "number") {
|
4698
|
-
variables = { height: (0,
|
4758
|
+
variables = { height: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4699
4759
|
} else if (idOrHeight === "latest") {
|
4700
4760
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4701
4761
|
} else if (idOrHeight.length === 66) {
|
4702
4762
|
variables = { blockId: idOrHeight };
|
4703
4763
|
} else {
|
4704
|
-
variables = { blockId: (0,
|
4764
|
+
variables = { blockId: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4705
4765
|
}
|
4706
4766
|
const { block } = await this.operations.getBlock(variables);
|
4707
4767
|
if (!block) {
|
@@ -4709,7 +4769,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4709
4769
|
}
|
4710
4770
|
return {
|
4711
4771
|
id: block.id,
|
4712
|
-
height: (0,
|
4772
|
+
height: (0, import_math18.bn)(block.height),
|
4713
4773
|
time: block.header.time,
|
4714
4774
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4715
4775
|
};
|
@@ -4724,7 +4784,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4724
4784
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4725
4785
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4726
4786
|
id: block.id,
|
4727
|
-
height: (0,
|
4787
|
+
height: (0, import_math18.bn)(block.height),
|
4728
4788
|
time: block.header.time,
|
4729
4789
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4730
4790
|
}));
|
@@ -4739,7 +4799,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4739
4799
|
async getBlockWithTransactions(idOrHeight) {
|
4740
4800
|
let variables;
|
4741
4801
|
if (typeof idOrHeight === "number") {
|
4742
|
-
variables = { blockHeight: (0,
|
4802
|
+
variables = { blockHeight: (0, import_math18.bn)(idOrHeight).toString(10) };
|
4743
4803
|
} else if (idOrHeight === "latest") {
|
4744
4804
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4745
4805
|
} else {
|
@@ -4751,11 +4811,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4751
4811
|
}
|
4752
4812
|
return {
|
4753
4813
|
id: block.id,
|
4754
|
-
height: (0,
|
4814
|
+
height: (0, import_math18.bn)(block.height, 10),
|
4755
4815
|
time: block.header.time,
|
4756
4816
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4757
4817
|
transactions: block.transactions.map(
|
4758
|
-
(tx) => new
|
4818
|
+
(tx) => new import_transactions20.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
|
4759
4819
|
)
|
4760
4820
|
};
|
4761
4821
|
}
|
@@ -4770,8 +4830,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4770
4830
|
if (!transaction) {
|
4771
4831
|
return null;
|
4772
4832
|
}
|
4773
|
-
return new
|
4774
|
-
(0,
|
4833
|
+
return new import_transactions20.TransactionCoder().decode(
|
4834
|
+
(0, import_utils22.arrayify)(transaction.rawPayload),
|
4775
4835
|
0
|
4776
4836
|
)?.[0];
|
4777
4837
|
}
|
@@ -4798,9 +4858,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4798
4858
|
async getContractBalance(contractId, assetId) {
|
4799
4859
|
const { contractBalance } = await this.operations.getContractBalance({
|
4800
4860
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4801
|
-
asset: (0,
|
4861
|
+
asset: (0, import_utils22.hexlify)(assetId)
|
4802
4862
|
});
|
4803
|
-
return (0,
|
4863
|
+
return (0, import_math18.bn)(contractBalance.amount, 10);
|
4804
4864
|
}
|
4805
4865
|
/**
|
4806
4866
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4812,9 +4872,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4812
4872
|
async getBalance(owner, assetId) {
|
4813
4873
|
const { balance } = await this.operations.getBalance({
|
4814
4874
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4815
|
-
assetId: (0,
|
4875
|
+
assetId: (0, import_utils22.hexlify)(assetId)
|
4816
4876
|
});
|
4817
|
-
return (0,
|
4877
|
+
return (0, import_math18.bn)(balance.amount, 10);
|
4818
4878
|
}
|
4819
4879
|
/**
|
4820
4880
|
* Returns balances for the given owner.
|
@@ -4832,7 +4892,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4832
4892
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4833
4893
|
return balances.map((balance) => ({
|
4834
4894
|
assetId: balance.assetId,
|
4835
|
-
amount: (0,
|
4895
|
+
amount: (0, import_math18.bn)(balance.amount)
|
4836
4896
|
}));
|
4837
4897
|
}
|
4838
4898
|
/**
|
@@ -4850,19 +4910,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4850
4910
|
});
|
4851
4911
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4852
4912
|
return messages.map((message) => ({
|
4853
|
-
messageId:
|
4913
|
+
messageId: import_transactions20.InputMessageCoder.getMessageId({
|
4854
4914
|
sender: message.sender,
|
4855
4915
|
recipient: message.recipient,
|
4856
4916
|
nonce: message.nonce,
|
4857
|
-
amount: (0,
|
4917
|
+
amount: (0, import_math18.bn)(message.amount),
|
4858
4918
|
data: message.data
|
4859
4919
|
}),
|
4860
4920
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4861
4921
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4862
4922
|
nonce: message.nonce,
|
4863
|
-
amount: (0,
|
4864
|
-
data:
|
4865
|
-
daHeight: (0,
|
4923
|
+
amount: (0, import_math18.bn)(message.amount),
|
4924
|
+
data: import_transactions20.InputMessageCoder.decodeData(message.data),
|
4925
|
+
daHeight: (0, import_math18.bn)(message.daHeight)
|
4866
4926
|
}));
|
4867
4927
|
}
|
4868
4928
|
/**
|
@@ -4915,19 +4975,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4915
4975
|
} = result.messageProof;
|
4916
4976
|
return {
|
4917
4977
|
messageProof: {
|
4918
|
-
proofIndex: (0,
|
4978
|
+
proofIndex: (0, import_math18.bn)(messageProof.proofIndex),
|
4919
4979
|
proofSet: messageProof.proofSet
|
4920
4980
|
},
|
4921
4981
|
blockProof: {
|
4922
|
-
proofIndex: (0,
|
4982
|
+
proofIndex: (0, import_math18.bn)(blockProof.proofIndex),
|
4923
4983
|
proofSet: blockProof.proofSet
|
4924
4984
|
},
|
4925
4985
|
messageBlockHeader: {
|
4926
4986
|
id: messageBlockHeader.id,
|
4927
|
-
daHeight: (0,
|
4987
|
+
daHeight: (0, import_math18.bn)(messageBlockHeader.daHeight),
|
4928
4988
|
transactionsCount: Number(messageBlockHeader.transactionsCount),
|
4929
4989
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4930
|
-
height: (0,
|
4990
|
+
height: (0, import_math18.bn)(messageBlockHeader.height),
|
4931
4991
|
prevRoot: messageBlockHeader.prevRoot,
|
4932
4992
|
time: messageBlockHeader.time,
|
4933
4993
|
applicationHash: messageBlockHeader.applicationHash,
|
@@ -4939,10 +4999,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4939
4999
|
},
|
4940
5000
|
commitBlockHeader: {
|
4941
5001
|
id: commitBlockHeader.id,
|
4942
|
-
daHeight: (0,
|
5002
|
+
daHeight: (0, import_math18.bn)(commitBlockHeader.daHeight),
|
4943
5003
|
transactionsCount: Number(commitBlockHeader.transactionsCount),
|
4944
5004
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4945
|
-
height: (0,
|
5005
|
+
height: (0, import_math18.bn)(commitBlockHeader.height),
|
4946
5006
|
prevRoot: commitBlockHeader.prevRoot,
|
4947
5007
|
time: commitBlockHeader.time,
|
4948
5008
|
applicationHash: commitBlockHeader.applicationHash,
|
@@ -4955,19 +5015,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4955
5015
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4956
5016
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4957
5017
|
nonce,
|
4958
|
-
amount: (0,
|
5018
|
+
amount: (0, import_math18.bn)(amount),
|
4959
5019
|
data
|
4960
5020
|
};
|
4961
5021
|
}
|
4962
5022
|
async getLatestGasPrice() {
|
4963
5023
|
const { latestGasPrice } = await this.operations.getLatestGasPrice();
|
4964
|
-
return (0,
|
5024
|
+
return (0, import_math18.bn)(latestGasPrice.gasPrice);
|
4965
5025
|
}
|
4966
5026
|
async estimateGasPrice(blockHorizon) {
|
4967
5027
|
const { estimateGasPrice } = await this.operations.estimateGasPrice({
|
4968
5028
|
blockHorizon: String(blockHorizon)
|
4969
5029
|
});
|
4970
|
-
return (0,
|
5030
|
+
return (0, import_math18.bn)(estimateGasPrice.gasPrice);
|
4971
5031
|
}
|
4972
5032
|
/**
|
4973
5033
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4988,10 +5048,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4988
5048
|
*/
|
4989
5049
|
async produceBlocks(amount, startTime) {
|
4990
5050
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4991
|
-
blocksToProduce: (0,
|
4992
|
-
startTimestamp: startTime ?
|
5051
|
+
blocksToProduce: (0, import_math18.bn)(amount).toString(10),
|
5052
|
+
startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4993
5053
|
});
|
4994
|
-
return (0,
|
5054
|
+
return (0, import_math18.bn)(latestBlockHeight);
|
4995
5055
|
}
|
4996
5056
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4997
5057
|
async getTransactionResponse(transactionId) {
|
@@ -5027,7 +5087,7 @@ cacheInputs_fn = function(inputs) {
|
|
5027
5087
|
return;
|
5028
5088
|
}
|
5029
5089
|
inputs.forEach((input) => {
|
5030
|
-
if (input.type ===
|
5090
|
+
if (input.type === import_transactions20.InputType.Coin) {
|
5031
5091
|
this.cache?.set(input.id);
|
5032
5092
|
}
|
5033
5093
|
});
|
@@ -5037,9 +5097,9 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
5037
5097
|
|
5038
5098
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5039
5099
|
var import_errors15 = require("@fuel-ts/errors");
|
5040
|
-
var
|
5041
|
-
var
|
5042
|
-
var
|
5100
|
+
var import_math19 = require("@fuel-ts/math");
|
5101
|
+
var import_transactions21 = require("@fuel-ts/transactions");
|
5102
|
+
var import_utils25 = require("@fuel-ts/utils");
|
5043
5103
|
async function getTransactionSummary(params) {
|
5044
5104
|
const { id, provider, abiMap } = params;
|
5045
5105
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
@@ -5051,8 +5111,8 @@ async function getTransactionSummary(params) {
|
|
5051
5111
|
`Transaction not found for given id: ${id}.`
|
5052
5112
|
);
|
5053
5113
|
}
|
5054
|
-
const [decodedTransaction] = new
|
5055
|
-
(0,
|
5114
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode(
|
5115
|
+
(0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5056
5116
|
0
|
5057
5117
|
);
|
5058
5118
|
let txReceipts = [];
|
@@ -5072,10 +5132,10 @@ async function getTransactionSummary(params) {
|
|
5072
5132
|
id: gqlTransaction.id,
|
5073
5133
|
receipts,
|
5074
5134
|
transaction: decodedTransaction,
|
5075
|
-
transactionBytes: (0,
|
5135
|
+
transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
|
5076
5136
|
gqlTransactionStatus: gqlTransaction.status,
|
5077
|
-
gasPerByte: (0,
|
5078
|
-
gasPriceFactor: (0,
|
5137
|
+
gasPerByte: (0, import_math19.bn)(gasPerByte),
|
5138
|
+
gasPriceFactor: (0, import_math19.bn)(gasPriceFactor),
|
5079
5139
|
abiMap,
|
5080
5140
|
maxInputs,
|
5081
5141
|
gasCosts,
|
@@ -5124,7 +5184,7 @@ async function getTransactionsSummaries(params) {
|
|
5124
5184
|
const transactions = edges.map((edge) => {
|
5125
5185
|
const { node: gqlTransaction } = edge;
|
5126
5186
|
const { id, rawPayload, status } = gqlTransaction;
|
5127
|
-
const [decodedTransaction] = new
|
5187
|
+
const [decodedTransaction] = new import_transactions21.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
|
5128
5188
|
let txReceipts = [];
|
5129
5189
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5130
5190
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5134,7 +5194,7 @@ async function getTransactionsSummaries(params) {
|
|
5134
5194
|
id,
|
5135
5195
|
receipts,
|
5136
5196
|
transaction: decodedTransaction,
|
5137
|
-
transactionBytes: (0,
|
5197
|
+
transactionBytes: (0, import_utils25.arrayify)(rawPayload),
|
5138
5198
|
gqlTransactionStatus: status,
|
5139
5199
|
abiMap,
|
5140
5200
|
gasPerByte,
|
@@ -5281,35 +5341,19 @@ var rawAssets = [
|
|
5281
5341
|
];
|
5282
5342
|
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
5283
5343
|
|
5284
|
-
// src/providers/transaction-request/helpers.ts
|
5285
|
-
var import_math19 = require("@fuel-ts/math");
|
5286
|
-
var import_transactions21 = require("@fuel-ts/transactions");
|
5287
|
-
var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
|
5288
|
-
var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
|
5289
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
5290
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
5291
|
-
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
5292
|
-
return acc.add(input.amount);
|
5293
|
-
}
|
5294
|
-
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
5295
|
-
return acc.add(input.amount);
|
5296
|
-
}
|
5297
|
-
return acc;
|
5298
|
-
}, (0, import_math19.bn)(0));
|
5299
|
-
|
5300
5344
|
// src/utils/formatTransferToContractScriptData.ts
|
5301
5345
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
5302
5346
|
var import_math20 = require("@fuel-ts/math");
|
5303
|
-
var
|
5347
|
+
var import_utils27 = require("@fuel-ts/utils");
|
5304
5348
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5305
5349
|
var formatTransferToContractScriptData = (params) => {
|
5306
5350
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5307
5351
|
const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
|
5308
5352
|
const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
|
5309
5353
|
const scriptData = Uint8Array.from([
|
5310
|
-
...(0,
|
5354
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
5311
5355
|
...encoded,
|
5312
|
-
...(0,
|
5356
|
+
...(0, import_utils27.arrayify)(assetId)
|
5313
5357
|
]);
|
5314
5358
|
return scriptData;
|
5315
5359
|
};
|
@@ -5534,7 +5578,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5534
5578
|
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5535
5579
|
const resources = await this.getResourcesToSpend(
|
5536
5580
|
missingQuantities,
|
5537
|
-
|
5581
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5538
5582
|
);
|
5539
5583
|
request.addResources(resources);
|
5540
5584
|
request.shiftPredicateData();
|
@@ -5682,14 +5726,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5682
5726
|
*/
|
5683
5727
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5684
5728
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5685
|
-
const recipientDataArray = (0,
|
5729
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5686
5730
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5687
5731
|
);
|
5688
|
-
const amountDataArray = (0,
|
5732
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5689
5733
|
"0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5690
5734
|
);
|
5691
5735
|
const script = new Uint8Array([
|
5692
|
-
...(0,
|
5736
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5693
5737
|
...recipientDataArray,
|
5694
5738
|
...amountDataArray
|
5695
5739
|
]);
|
@@ -5769,7 +5813,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5769
5813
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
5770
5814
|
}) {
|
5771
5815
|
const request = transactionRequestify(transactionRequest);
|
5772
|
-
if (!(0,
|
5816
|
+
if (!(0, import_utils28.isDefined)(setGasLimit)) {
|
5773
5817
|
request.gasLimit = gasUsed;
|
5774
5818
|
} else if (gasUsed.gt(setGasLimit)) {
|
5775
5819
|
throw new import_errors16.FuelError(
|
@@ -5777,7 +5821,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5777
5821
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
5778
5822
|
);
|
5779
5823
|
}
|
5780
|
-
if (!(0,
|
5824
|
+
if (!(0, import_utils28.isDefined)(setMaxFee)) {
|
5781
5825
|
request.maxFee = maxFee;
|
5782
5826
|
} else if (maxFee.gt(setMaxFee)) {
|
5783
5827
|
throw new import_errors16.FuelError(
|
@@ -5791,14 +5835,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5791
5835
|
|
5792
5836
|
// src/wallet/base-wallet-unlocked.ts
|
5793
5837
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5794
|
-
var
|
5838
|
+
var import_utils31 = require("@fuel-ts/utils");
|
5795
5839
|
|
5796
5840
|
// src/signer/signer.ts
|
5797
5841
|
var import_address5 = require("@fuel-ts/address");
|
5798
5842
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5799
5843
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5800
5844
|
var import_math22 = require("@fuel-ts/math");
|
5801
|
-
var
|
5845
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5802
5846
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5803
5847
|
var Signer = class {
|
5804
5848
|
address;
|
@@ -5818,9 +5862,9 @@ var Signer = class {
|
|
5818
5862
|
}
|
5819
5863
|
}
|
5820
5864
|
const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
|
5821
|
-
this.privateKey = (0,
|
5822
|
-
this.publicKey = (0,
|
5823
|
-
this.compressedPublicKey = (0,
|
5865
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5866
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5867
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5824
5868
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5825
5869
|
}
|
5826
5870
|
/**
|
@@ -5834,11 +5878,11 @@ var Signer = class {
|
|
5834
5878
|
* @returns hashed signature
|
5835
5879
|
*/
|
5836
5880
|
sign(data) {
|
5837
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5881
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5838
5882
|
const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5839
5883
|
const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5840
5884
|
s[0] |= (signature.recovery || 0) << 7;
|
5841
|
-
return (0,
|
5885
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5842
5886
|
}
|
5843
5887
|
/**
|
5844
5888
|
* Add point on the current elliptic curve
|
@@ -5847,8 +5891,8 @@ var Signer = class {
|
|
5847
5891
|
* @returns compressed point on the curve
|
5848
5892
|
*/
|
5849
5893
|
addPoint(point) {
|
5850
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5851
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5894
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5895
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5852
5896
|
const result = p0.add(p1);
|
5853
5897
|
return `0x${result.toHex(true)}`;
|
5854
5898
|
}
|
@@ -5860,16 +5904,16 @@ var Signer = class {
|
|
5860
5904
|
* @returns public key from signature from the
|
5861
5905
|
*/
|
5862
5906
|
static recoverPublicKey(data, signature) {
|
5863
|
-
const signedMessageBytes = (0,
|
5907
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5864
5908
|
const r = signedMessageBytes.slice(0, 32);
|
5865
5909
|
const s = signedMessageBytes.slice(32, 64);
|
5866
5910
|
const recoveryParam = (s[0] & 128) >> 7;
|
5867
5911
|
s[0] &= 127;
|
5868
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5912
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5869
5913
|
recoveryParam
|
5870
5914
|
);
|
5871
|
-
const publicKey = sig.recoverPublicKey((0,
|
5872
|
-
return (0,
|
5915
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5916
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5873
5917
|
}
|
5874
5918
|
/**
|
5875
5919
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5888,7 +5932,7 @@ var Signer = class {
|
|
5888
5932
|
* @returns random 32-byte hashed
|
5889
5933
|
*/
|
5890
5934
|
static generatePrivateKey(entropy) {
|
5891
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5935
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
|
5892
5936
|
}
|
5893
5937
|
/**
|
5894
5938
|
* Extended publicKey from a compact publicKey
|
@@ -5897,8 +5941,8 @@ var Signer = class {
|
|
5897
5941
|
* @returns extended publicKey
|
5898
5942
|
*/
|
5899
5943
|
static extendPublicKey(publicKey) {
|
5900
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5901
|
-
return (0,
|
5944
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5945
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5902
5946
|
}
|
5903
5947
|
};
|
5904
5948
|
|
@@ -5906,7 +5950,7 @@ var Signer = class {
|
|
5906
5950
|
var import_address6 = require("@fuel-ts/address");
|
5907
5951
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5908
5952
|
var import_errors17 = require("@fuel-ts/errors");
|
5909
|
-
var
|
5953
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5910
5954
|
var import_uuid = require("uuid");
|
5911
5955
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5912
5956
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5989,7 +6033,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5989
6033
|
);
|
5990
6034
|
}
|
5991
6035
|
const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5992
|
-
const privateKey = (0,
|
6036
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5993
6037
|
return privateKey;
|
5994
6038
|
}
|
5995
6039
|
|
@@ -6034,7 +6078,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6034
6078
|
*/
|
6035
6079
|
async signMessage(message) {
|
6036
6080
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
6037
|
-
return (0,
|
6081
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
6038
6082
|
}
|
6039
6083
|
/**
|
6040
6084
|
* Signs a transaction with the wallet's private key.
|
@@ -6047,7 +6091,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6047
6091
|
const chainId = this.provider.getChainId();
|
6048
6092
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6049
6093
|
const signature = await this.signer().sign(hashedTransaction);
|
6050
|
-
return (0,
|
6094
|
+
return (0, import_utils31.hexlify)(signature);
|
6051
6095
|
}
|
6052
6096
|
/**
|
6053
6097
|
* Populates a transaction with the witnesses signature.
|
@@ -6109,14 +6153,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6109
6153
|
var import_errors20 = require("@fuel-ts/errors");
|
6110
6154
|
var import_hasher6 = require("@fuel-ts/hasher");
|
6111
6155
|
var import_math23 = require("@fuel-ts/math");
|
6112
|
-
var
|
6156
|
+
var import_utils35 = require("@fuel-ts/utils");
|
6113
6157
|
var import_ethers2 = require("ethers");
|
6114
6158
|
|
6115
6159
|
// src/mnemonic/mnemonic.ts
|
6116
6160
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6117
6161
|
var import_errors19 = require("@fuel-ts/errors");
|
6118
6162
|
var import_hasher5 = require("@fuel-ts/hasher");
|
6119
|
-
var
|
6163
|
+
var import_utils33 = require("@fuel-ts/utils");
|
6120
6164
|
var import_ethers = require("ethers");
|
6121
6165
|
|
6122
6166
|
// src/wordlists/words/english.ts
|
@@ -8180,7 +8224,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8180
8224
|
// src/mnemonic/utils.ts
|
8181
8225
|
var import_errors18 = require("@fuel-ts/errors");
|
8182
8226
|
var import_hasher4 = require("@fuel-ts/hasher");
|
8183
|
-
var
|
8227
|
+
var import_utils32 = require("@fuel-ts/utils");
|
8184
8228
|
function toUtf8Bytes(stri) {
|
8185
8229
|
const str = stri.normalize("NFKD");
|
8186
8230
|
const result = [];
|
@@ -8247,14 +8291,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
8247
8291
|
}
|
8248
8292
|
}
|
8249
8293
|
const checksumBits = entropy.length / 4;
|
8250
|
-
const checksum = (0,
|
8294
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8251
8295
|
indices[indices.length - 1] <<= checksumBits;
|
8252
8296
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8253
8297
|
return indices;
|
8254
8298
|
}
|
8255
8299
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8256
8300
|
const size = Math.ceil(11 * words.length / 8);
|
8257
|
-
const entropy = (0,
|
8301
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
8258
8302
|
let offset = 0;
|
8259
8303
|
for (let i = 0; i < words.length; i += 1) {
|
8260
8304
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -8274,7 +8318,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8274
8318
|
const entropyBits = 32 * words.length / 3;
|
8275
8319
|
const checksumBits = words.length / 3;
|
8276
8320
|
const checksumMask = getUpperMask(checksumBits);
|
8277
|
-
const checksum = (0,
|
8321
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8278
8322
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8279
8323
|
throw new import_errors18.FuelError(
|
8280
8324
|
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
@@ -8349,7 +8393,7 @@ var Mnemonic = class {
|
|
8349
8393
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8350
8394
|
const words = getWords(phrase);
|
8351
8395
|
assertMnemonic(words);
|
8352
|
-
return (0,
|
8396
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8353
8397
|
}
|
8354
8398
|
/**
|
8355
8399
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8357,7 +8401,7 @@ var Mnemonic = class {
|
|
8357
8401
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8358
8402
|
*/
|
8359
8403
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8360
|
-
const entropyBytes = (0,
|
8404
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
8361
8405
|
assertWordList(wordlist);
|
8362
8406
|
assertEntropy(entropyBytes);
|
8363
8407
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8426,14 +8470,14 @@ var Mnemonic = class {
|
|
8426
8470
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8427
8471
|
*/
|
8428
8472
|
static masterKeysFromSeed(seed) {
|
8429
|
-
const seedArray = (0,
|
8473
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
8430
8474
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8431
8475
|
throw new import_errors19.FuelError(
|
8432
8476
|
import_errors19.ErrorCode.INVALID_SEED,
|
8433
8477
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8434
8478
|
);
|
8435
8479
|
}
|
8436
|
-
return (0,
|
8480
|
+
return (0, import_utils33.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
|
8437
8481
|
}
|
8438
8482
|
/**
|
8439
8483
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8444,22 +8488,22 @@ var Mnemonic = class {
|
|
8444
8488
|
*/
|
8445
8489
|
static seedToExtendedKey(seed, testnet = false) {
|
8446
8490
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8447
|
-
const prefix = (0,
|
8491
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8448
8492
|
const depth = "0x00";
|
8449
8493
|
const fingerprint = "0x00000000";
|
8450
8494
|
const index = "0x00000000";
|
8451
8495
|
const chainCode = masterKey.slice(32);
|
8452
8496
|
const privateKey = masterKey.slice(0, 32);
|
8453
|
-
const extendedKey = (0,
|
8497
|
+
const extendedKey = (0, import_utils33.concat)([
|
8454
8498
|
prefix,
|
8455
8499
|
depth,
|
8456
8500
|
fingerprint,
|
8457
8501
|
index,
|
8458
8502
|
chainCode,
|
8459
|
-
(0,
|
8503
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
8460
8504
|
]);
|
8461
8505
|
const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
8462
|
-
return (0, import_ethers.encodeBase58)((0,
|
8506
|
+
return (0, import_ethers.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
8463
8507
|
}
|
8464
8508
|
/**
|
8465
8509
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8474,7 +8518,7 @@ var Mnemonic = class {
|
|
8474
8518
|
* @returns A randomly generated mnemonic
|
8475
8519
|
*/
|
8476
8520
|
static generate(size = 32, extraEntropy = "") {
|
8477
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8521
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
|
8478
8522
|
return Mnemonic.entropyToMnemonic(entropy);
|
8479
8523
|
}
|
8480
8524
|
};
|
@@ -8482,12 +8526,12 @@ var mnemonic_default = Mnemonic;
|
|
8482
8526
|
|
8483
8527
|
// src/hdwallet/hdwallet.ts
|
8484
8528
|
var HARDENED_INDEX = 2147483648;
|
8485
|
-
var MainnetPRV2 = (0,
|
8486
|
-
var MainnetPUB = (0,
|
8487
|
-
var TestnetPRV2 = (0,
|
8488
|
-
var TestnetPUB = (0,
|
8529
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
8530
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
8531
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8532
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
8489
8533
|
function base58check(data) {
|
8490
|
-
return (0, import_ethers2.encodeBase58)((0,
|
8534
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers2.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
8491
8535
|
}
|
8492
8536
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
8493
8537
|
if (isPublic) {
|
@@ -8496,11 +8540,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
8496
8540
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
8497
8541
|
}
|
8498
8542
|
function isPublicExtendedKey(extendedKey) {
|
8499
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8543
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
8500
8544
|
}
|
8501
8545
|
function isValidExtendedKey(extendedKey) {
|
8502
8546
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
8503
|
-
(0,
|
8547
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
8504
8548
|
);
|
8505
8549
|
}
|
8506
8550
|
function parsePath(path, depth = 0) {
|
@@ -8518,8 +8562,8 @@ function parsePath(path, depth = 0) {
|
|
8518
8562
|
var HDWallet = class {
|
8519
8563
|
depth = 0;
|
8520
8564
|
index = 0;
|
8521
|
-
fingerprint = (0,
|
8522
|
-
parentFingerprint = (0,
|
8565
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8566
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8523
8567
|
privateKey;
|
8524
8568
|
publicKey;
|
8525
8569
|
chainCode;
|
@@ -8531,8 +8575,8 @@ var HDWallet = class {
|
|
8531
8575
|
constructor(config) {
|
8532
8576
|
if (config.privateKey) {
|
8533
8577
|
const signer = new Signer(config.privateKey);
|
8534
|
-
this.publicKey = (0,
|
8535
|
-
this.privateKey = (0,
|
8578
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
8579
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
8536
8580
|
} else {
|
8537
8581
|
if (!config.publicKey) {
|
8538
8582
|
throw new import_errors20.FuelError(
|
@@ -8540,7 +8584,7 @@ var HDWallet = class {
|
|
8540
8584
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8541
8585
|
);
|
8542
8586
|
}
|
8543
|
-
this.publicKey = (0,
|
8587
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8544
8588
|
}
|
8545
8589
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8546
8590
|
this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
@@ -8559,9 +8603,9 @@ var HDWallet = class {
|
|
8559
8603
|
* @returns A new instance of HDWallet on the derived index
|
8560
8604
|
*/
|
8561
8605
|
deriveIndex(index) {
|
8562
|
-
const privateKey = this.privateKey && (0,
|
8563
|
-
const publicKey = (0,
|
8564
|
-
const chainCode = (0,
|
8606
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
8607
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
8608
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
8565
8609
|
const data = new Uint8Array(37);
|
8566
8610
|
if (index & HARDENED_INDEX) {
|
8567
8611
|
if (!privateKey) {
|
@@ -8572,10 +8616,10 @@ var HDWallet = class {
|
|
8572
8616
|
}
|
8573
8617
|
data.set(privateKey, 1);
|
8574
8618
|
} else {
|
8575
|
-
data.set((0,
|
8619
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8576
8620
|
}
|
8577
8621
|
data.set((0, import_math23.toBytes)(index, 4), 33);
|
8578
|
-
const bytes = (0,
|
8622
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
|
8579
8623
|
const IL = bytes.slice(0, 32);
|
8580
8624
|
const IR = bytes.slice(32);
|
8581
8625
|
if (privateKey) {
|
@@ -8589,7 +8633,7 @@ var HDWallet = class {
|
|
8589
8633
|
parentFingerprint: this.fingerprint
|
8590
8634
|
});
|
8591
8635
|
}
|
8592
|
-
const signer = new Signer((0,
|
8636
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
8593
8637
|
const Ki = signer.addPoint(publicKey);
|
8594
8638
|
return new HDWallet({
|
8595
8639
|
publicKey: Ki,
|
@@ -8624,12 +8668,12 @@ var HDWallet = class {
|
|
8624
8668
|
);
|
8625
8669
|
}
|
8626
8670
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8627
|
-
const depth = (0,
|
8671
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8628
8672
|
const parentFingerprint = this.parentFingerprint;
|
8629
8673
|
const index = (0, import_math23.toHex)(this.index, 4);
|
8630
8674
|
const chainCode = this.chainCode;
|
8631
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8632
|
-
const extendedKey = (0,
|
8675
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8676
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8633
8677
|
return base58check(extendedKey);
|
8634
8678
|
}
|
8635
8679
|
/**
|
@@ -8641,13 +8685,13 @@ var HDWallet = class {
|
|
8641
8685
|
static fromSeed(seed) {
|
8642
8686
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8643
8687
|
return new HDWallet({
|
8644
|
-
chainCode: (0,
|
8645
|
-
privateKey: (0,
|
8688
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8689
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8646
8690
|
});
|
8647
8691
|
}
|
8648
8692
|
static fromExtendedKey(extendedKey) {
|
8649
8693
|
const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
|
8650
|
-
const bytes = (0,
|
8694
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8651
8695
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8652
8696
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8653
8697
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -8656,9 +8700,9 @@ var HDWallet = class {
|
|
8656
8700
|
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8657
8701
|
}
|
8658
8702
|
const depth = bytes[4];
|
8659
|
-
const parentFingerprint = (0,
|
8660
|
-
const index = parseInt((0,
|
8661
|
-
const chainCode = (0,
|
8703
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8704
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8705
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8662
8706
|
const key = bytes.slice(45, 78);
|
8663
8707
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8664
8708
|
throw new import_errors20.FuelError(
|
@@ -9263,18 +9307,18 @@ var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
|
9263
9307
|
var import_address10 = require("@fuel-ts/address");
|
9264
9308
|
var import_errors25 = require("@fuel-ts/errors");
|
9265
9309
|
var import_transactions22 = require("@fuel-ts/transactions");
|
9266
|
-
var
|
9310
|
+
var import_utils37 = require("@fuel-ts/utils");
|
9267
9311
|
|
9268
9312
|
// src/predicate/utils/getPredicateRoot.ts
|
9269
9313
|
var import_hasher7 = require("@fuel-ts/hasher");
|
9270
9314
|
var import_merkle = require("@fuel-ts/merkle");
|
9271
|
-
var
|
9315
|
+
var import_utils36 = require("@fuel-ts/utils");
|
9272
9316
|
var getPredicateRoot = (bytecode) => {
|
9273
9317
|
const chunkSize = 16 * 1024;
|
9274
|
-
const bytes = (0,
|
9275
|
-
const chunks = (0,
|
9276
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
9277
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
9318
|
+
const bytes = (0, import_utils36.arrayify)(bytecode);
|
9319
|
+
const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
|
9320
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
|
9321
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
|
9278
9322
|
return predicateRoot;
|
9279
9323
|
};
|
9280
9324
|
|
@@ -9321,10 +9365,15 @@ var Predicate = class extends Account {
|
|
9321
9365
|
populateTransactionPredicateData(transactionRequestLike) {
|
9322
9366
|
const request = transactionRequestify(transactionRequestLike);
|
9323
9367
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
9324
|
-
|
9325
|
-
|
9326
|
-
|
9327
|
-
|
9368
|
+
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
9369
|
+
if (placeholderIndex !== -1) {
|
9370
|
+
request.removeWitness(placeholderIndex);
|
9371
|
+
}
|
9372
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9373
|
+
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9374
|
+
input.predicate = (0, import_utils37.hexlify)(this.bytes);
|
9375
|
+
input.predicateData = (0, import_utils37.hexlify)(this.getPredicateData(policies.length));
|
9376
|
+
input.witnessIndex = 0;
|
9328
9377
|
}
|
9329
9378
|
});
|
9330
9379
|
return request;
|
@@ -9370,7 +9419,7 @@ var Predicate = class extends Account {
|
|
9370
9419
|
* @returns An object containing the new predicate bytes and interface.
|
9371
9420
|
*/
|
9372
9421
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9373
|
-
let predicateBytes = (0,
|
9422
|
+
let predicateBytes = (0, import_utils37.arrayify)(bytes);
|
9374
9423
|
let abiInterface;
|
9375
9424
|
if (jsonAbi) {
|
9376
9425
|
abiInterface = new import_abi_coder7.Interface(jsonAbi);
|
@@ -9408,8 +9457,8 @@ var Predicate = class extends Account {
|
|
9408
9457
|
);
|
9409
9458
|
return resources.map((resource) => ({
|
9410
9459
|
...resource,
|
9411
|
-
predicate: (0,
|
9412
|
-
padPredicateData: (policiesLength) => (0,
|
9460
|
+
predicate: (0, import_utils37.hexlify)(this.bytes),
|
9461
|
+
padPredicateData: (policiesLength) => (0, import_utils37.hexlify)(this.getPredicateData(policiesLength))
|
9413
9462
|
}));
|
9414
9463
|
}
|
9415
9464
|
/**
|
@@ -9447,6 +9496,28 @@ var Predicate = class extends Account {
|
|
9447
9496
|
}
|
9448
9497
|
return mutatedBytes;
|
9449
9498
|
}
|
9499
|
+
/**
|
9500
|
+
* Returns the index of the witness placeholder that was added to this predicate.
|
9501
|
+
* If no witness placeholder was added, it returns -1.
|
9502
|
+
* @param request - The transaction request.
|
9503
|
+
* @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
|
9504
|
+
*/
|
9505
|
+
getIndexFromPlaceholderWitness(request) {
|
9506
|
+
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
9507
|
+
let index = -1;
|
9508
|
+
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
9509
|
+
if (hasEmptyPredicateInputs) {
|
9510
|
+
index = hasEmptyPredicateInputs.witnessIndex;
|
9511
|
+
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
9512
|
+
if (!allInputsAreEmpty) {
|
9513
|
+
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
9514
|
+
if (wasFilledInputAddedFirst) {
|
9515
|
+
index = -1;
|
9516
|
+
}
|
9517
|
+
}
|
9518
|
+
}
|
9519
|
+
return index;
|
9520
|
+
}
|
9450
9521
|
};
|
9451
9522
|
|
9452
9523
|
// src/connectors/fuel.ts
|
@@ -10170,7 +10241,8 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10170
10241
|
assets,
|
10171
10242
|
buildBlockExplorerUrl,
|
10172
10243
|
cacheFor,
|
10173
|
-
|
10244
|
+
cacheRequestInputsResources,
|
10245
|
+
cacheRequestInputsResourcesFromOwner,
|
10174
10246
|
calculateGasFee,
|
10175
10247
|
calculateMetadataGasForTxCreate,
|
10176
10248
|
calculateMetadataGasForTxScript,
|
@@ -10184,6 +10256,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10184
10256
|
extractTxError,
|
10185
10257
|
fuelAssetsBaseUrl,
|
10186
10258
|
gasUsedByInputs,
|
10259
|
+
getAssetAmountInRequestInputs,
|
10187
10260
|
getAssetEth,
|
10188
10261
|
getAssetFuel,
|
10189
10262
|
getAssetNetwork,
|
@@ -10218,6 +10291,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10218
10291
|
getReceiptsMessageOut,
|
10219
10292
|
getReceiptsTransferOut,
|
10220
10293
|
getReceiptsWithMissingData,
|
10294
|
+
getRequestInputResourceOwner,
|
10221
10295
|
getTransactionStatusName,
|
10222
10296
|
getTransactionSummary,
|
10223
10297
|
getTransactionSummaryFromRequest,
|
@@ -10231,6 +10305,10 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10231
10305
|
isMessage,
|
10232
10306
|
isRawCoin,
|
10233
10307
|
isRawMessage,
|
10308
|
+
isRequestInputCoin,
|
10309
|
+
isRequestInputMessage,
|
10310
|
+
isRequestInputResource,
|
10311
|
+
isRequestInputResourceFromOwner,
|
10234
10312
|
isType,
|
10235
10313
|
isTypeCreate,
|
10236
10314
|
isTypeMint,
|
@@ -10245,6 +10323,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
10245
10323
|
resolveGasDependentCosts,
|
10246
10324
|
resolveIconPaths,
|
10247
10325
|
returnZeroScript,
|
10326
|
+
sleep,
|
10248
10327
|
transactionRequestify,
|
10249
10328
|
urlJoin,
|
10250
10329
|
withTimeout,
|