@fuel-ts/account 0.85.0 → 0.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/account.d.ts.map +1 -1
- package/dist/hdwallet/hdwallet.d.ts.map +1 -1
- package/dist/index.global.js +1694 -2854
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +304 -298
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +194 -201
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts.map +1 -1
- package/dist/mnemonic/utils.d.ts +0 -1
- package/dist/mnemonic/utils.d.ts.map +1 -1
- package/dist/predicate/predicate.d.ts +9 -2
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +0 -1
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +0 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/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/input.d.ts +0 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -1
- 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/transaction-summary/call.d.ts +1 -1
- package/dist/providers/transaction-summary/call.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 +1422 -2616
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +247 -288
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +147 -188
- 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/index.mjs
CHANGED
@@ -31,7 +31,7 @@ var __privateMethod = (obj, member, method) => {
|
|
31
31
|
import { Address as Address3 } from "@fuel-ts/address";
|
32
32
|
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
33
33
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
34
|
-
import { bn as
|
34
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
35
35
|
import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
|
36
36
|
import { clone as clone4 } from "ramda";
|
37
37
|
|
@@ -1296,11 +1296,11 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
|
|
1296
1296
|
import { Address, addressify } from "@fuel-ts/address";
|
1297
1297
|
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1298
1298
|
import { randomBytes } from "@fuel-ts/crypto";
|
1299
|
-
import { bn as
|
1299
|
+
import { bn as bn8 } from "@fuel-ts/math";
|
1300
1300
|
import {
|
1301
1301
|
PolicyType,
|
1302
1302
|
TransactionCoder,
|
1303
|
-
InputType as
|
1303
|
+
InputType as InputType3,
|
1304
1304
|
OutputType as OutputType2,
|
1305
1305
|
TransactionType
|
1306
1306
|
} from "@fuel-ts/transactions";
|
@@ -1823,6 +1823,52 @@ var NoWitnessByOwnerError = class extends Error {
|
|
1823
1823
|
name = "NoWitnessByOwnerError";
|
1824
1824
|
};
|
1825
1825
|
|
1826
|
+
// src/providers/transaction-request/helpers.ts
|
1827
|
+
import { bn as bn7 } from "@fuel-ts/math";
|
1828
|
+
import { InputType as InputType2 } from "@fuel-ts/transactions";
|
1829
|
+
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
1830
|
+
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
1831
|
+
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
1832
|
+
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
1833
|
+
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
1834
|
+
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
1835
|
+
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
1836
|
+
return acc.add(input.amount);
|
1837
|
+
}
|
1838
|
+
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
1839
|
+
return acc.add(input.amount);
|
1840
|
+
}
|
1841
|
+
return acc;
|
1842
|
+
}, bn7(0));
|
1843
|
+
var cacheRequestInputsResources = (inputs) => inputs.filter(isRequestInputResource).reduce(
|
1844
|
+
(cache2, input) => {
|
1845
|
+
if (isRequestInputCoin(input)) {
|
1846
|
+
cache2.utxos.push(input.id);
|
1847
|
+
} else {
|
1848
|
+
cache2.messages.push(input.nonce);
|
1849
|
+
}
|
1850
|
+
return cache2;
|
1851
|
+
},
|
1852
|
+
{
|
1853
|
+
utxos: [],
|
1854
|
+
messages: []
|
1855
|
+
}
|
1856
|
+
);
|
1857
|
+
var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
1858
|
+
(acc, input) => {
|
1859
|
+
if (isRequestInputCoin(input) && input.owner === owner.toB256()) {
|
1860
|
+
acc.utxos.push(input.id);
|
1861
|
+
} else if (isRequestInputMessage(input) && input.recipient === owner.toB256()) {
|
1862
|
+
acc.messages.push(input.nonce);
|
1863
|
+
}
|
1864
|
+
return acc;
|
1865
|
+
},
|
1866
|
+
{
|
1867
|
+
utxos: [],
|
1868
|
+
messages: []
|
1869
|
+
}
|
1870
|
+
);
|
1871
|
+
|
1826
1872
|
// src/providers/transaction-request/witness.ts
|
1827
1873
|
import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
|
1828
1874
|
var witnessify = (value) => {
|
@@ -1863,10 +1909,10 @@ var BaseTransactionRequest = class {
|
|
1863
1909
|
outputs,
|
1864
1910
|
witnesses
|
1865
1911
|
} = {}) {
|
1866
|
-
this.tip = tip ?
|
1912
|
+
this.tip = tip ? bn8(tip) : void 0;
|
1867
1913
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
1868
|
-
this.witnessLimit = isDefined(witnessLimit) ?
|
1869
|
-
this.maxFee =
|
1914
|
+
this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
|
1915
|
+
this.maxFee = bn8(maxFee);
|
1870
1916
|
this.inputs = inputs ?? [];
|
1871
1917
|
this.outputs = outputs ?? [];
|
1872
1918
|
this.witnesses = witnesses ?? [];
|
@@ -1875,13 +1921,13 @@ var BaseTransactionRequest = class {
|
|
1875
1921
|
let policyTypes = 0;
|
1876
1922
|
const policies = [];
|
1877
1923
|
const { tip, witnessLimit, maturity } = req;
|
1878
|
-
if (
|
1924
|
+
if (bn8(tip).gt(0)) {
|
1879
1925
|
policyTypes += PolicyType.Tip;
|
1880
|
-
policies.push({ data:
|
1926
|
+
policies.push({ data: bn8(tip), type: PolicyType.Tip });
|
1881
1927
|
}
|
1882
|
-
if (isDefined(witnessLimit) &&
|
1928
|
+
if (isDefined(witnessLimit) && bn8(witnessLimit).gte(0)) {
|
1883
1929
|
policyTypes += PolicyType.WitnessLimit;
|
1884
|
-
policies.push({ data:
|
1930
|
+
policies.push({ data: bn8(witnessLimit), type: PolicyType.WitnessLimit });
|
1885
1931
|
}
|
1886
1932
|
if (maturity && maturity > 0) {
|
1887
1933
|
policyTypes += PolicyType.Maturity;
|
@@ -2012,7 +2058,7 @@ var BaseTransactionRequest = class {
|
|
2012
2058
|
*/
|
2013
2059
|
getCoinInputs() {
|
2014
2060
|
return this.inputs.filter(
|
2015
|
-
(input) => input.type ===
|
2061
|
+
(input) => input.type === InputType3.Coin
|
2016
2062
|
);
|
2017
2063
|
}
|
2018
2064
|
/**
|
@@ -2044,9 +2090,9 @@ var BaseTransactionRequest = class {
|
|
2044
2090
|
const ownerAddress = addressify(owner);
|
2045
2091
|
const found = this.inputs.find((input) => {
|
2046
2092
|
switch (input.type) {
|
2047
|
-
case
|
2093
|
+
case InputType3.Coin:
|
2048
2094
|
return hexlify7(input.owner) === ownerAddress.toB256();
|
2049
|
-
case
|
2095
|
+
case InputType3.Message:
|
2050
2096
|
return hexlify7(input.recipient) === ownerAddress.toB256();
|
2051
2097
|
default:
|
2052
2098
|
return false;
|
@@ -2061,7 +2107,7 @@ var BaseTransactionRequest = class {
|
|
2061
2107
|
* @param coin - Coin resource.
|
2062
2108
|
*/
|
2063
2109
|
addCoinInput(coin) {
|
2064
|
-
const { assetId, owner, amount } = coin;
|
2110
|
+
const { assetId, owner, amount, id, predicate } = coin;
|
2065
2111
|
let witnessIndex;
|
2066
2112
|
if (coin.predicate) {
|
2067
2113
|
witnessIndex = 0;
|
@@ -2072,13 +2118,14 @@ var BaseTransactionRequest = class {
|
|
2072
2118
|
}
|
2073
2119
|
}
|
2074
2120
|
const input = {
|
2075
|
-
|
2076
|
-
type:
|
2121
|
+
id,
|
2122
|
+
type: InputType3.Coin,
|
2077
2123
|
owner: owner.toB256(),
|
2078
2124
|
amount,
|
2079
2125
|
assetId,
|
2080
2126
|
txPointer: "0x00000000000000000000000000000000",
|
2081
|
-
witnessIndex
|
2127
|
+
witnessIndex,
|
2128
|
+
predicate
|
2082
2129
|
};
|
2083
2130
|
this.pushInput(input);
|
2084
2131
|
this.addChangeOutput(owner, assetId);
|
@@ -2090,7 +2137,7 @@ var BaseTransactionRequest = class {
|
|
2090
2137
|
* @param message - Message resource.
|
2091
2138
|
*/
|
2092
2139
|
addMessageInput(message) {
|
2093
|
-
const { recipient, sender, amount, assetId } = message;
|
2140
|
+
const { recipient, sender, amount, predicate, nonce, assetId } = message;
|
2094
2141
|
let witnessIndex;
|
2095
2142
|
if (message.predicate) {
|
2096
2143
|
witnessIndex = 0;
|
@@ -2101,12 +2148,13 @@ var BaseTransactionRequest = class {
|
|
2101
2148
|
}
|
2102
2149
|
}
|
2103
2150
|
const input = {
|
2104
|
-
|
2105
|
-
type:
|
2151
|
+
nonce,
|
2152
|
+
type: InputType3.Message,
|
2106
2153
|
sender: sender.toB256(),
|
2107
2154
|
recipient: recipient.toB256(),
|
2108
2155
|
amount,
|
2109
|
-
witnessIndex
|
2156
|
+
witnessIndex,
|
2157
|
+
predicate
|
2110
2158
|
};
|
2111
2159
|
this.pushInput(input);
|
2112
2160
|
this.addChangeOutput(recipient, assetId);
|
@@ -2253,7 +2301,7 @@ var BaseTransactionRequest = class {
|
|
2253
2301
|
const assetInput = findAssetInput(assetId);
|
2254
2302
|
let usedQuantity = quantity;
|
2255
2303
|
if (assetId === baseAssetId) {
|
2256
|
-
usedQuantity =
|
2304
|
+
usedQuantity = bn8("1000000000000000000");
|
2257
2305
|
}
|
2258
2306
|
if (assetInput && "assetId" in assetInput) {
|
2259
2307
|
assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
|
@@ -2265,13 +2313,13 @@ var BaseTransactionRequest = class {
|
|
2265
2313
|
amount: usedQuantity,
|
2266
2314
|
assetId,
|
2267
2315
|
owner: resourcesOwner || Address.fromRandom(),
|
2268
|
-
blockCreated:
|
2269
|
-
txCreatedIdx:
|
2316
|
+
blockCreated: bn8(1),
|
2317
|
+
txCreatedIdx: bn8(1)
|
2270
2318
|
}
|
2271
2319
|
]);
|
2272
2320
|
}
|
2273
2321
|
};
|
2274
|
-
updateAssetInput(baseAssetId,
|
2322
|
+
updateAssetInput(baseAssetId, bn8(1e11));
|
2275
2323
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2276
2324
|
}
|
2277
2325
|
/**
|
@@ -2282,7 +2330,7 @@ var BaseTransactionRequest = class {
|
|
2282
2330
|
*/
|
2283
2331
|
getCoinOutputsQuantities() {
|
2284
2332
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2285
|
-
amount:
|
2333
|
+
amount: bn8(amount),
|
2286
2334
|
assetId: assetId.toString()
|
2287
2335
|
}));
|
2288
2336
|
return coinsQuantities;
|
@@ -2296,50 +2344,52 @@ var BaseTransactionRequest = class {
|
|
2296
2344
|
toJSON() {
|
2297
2345
|
return normalizeJSON(this);
|
2298
2346
|
}
|
2347
|
+
removeWitness(index) {
|
2348
|
+
this.witnesses.splice(index, 1);
|
2349
|
+
this.adjustWitnessIndexes(index);
|
2350
|
+
}
|
2351
|
+
adjustWitnessIndexes(removedIndex) {
|
2352
|
+
this.inputs.filter(isRequestInputResource).forEach((input) => {
|
2353
|
+
if (input.witnessIndex > removedIndex) {
|
2354
|
+
input.witnessIndex -= 1;
|
2355
|
+
}
|
2356
|
+
});
|
2357
|
+
}
|
2299
2358
|
updatePredicateGasUsed(inputs) {
|
2300
2359
|
this.inputs.forEach((i) => {
|
2301
2360
|
let correspondingInput;
|
2302
2361
|
switch (i.type) {
|
2303
|
-
case
|
2304
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2362
|
+
case InputType3.Coin:
|
2363
|
+
correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
|
2305
2364
|
break;
|
2306
|
-
case
|
2365
|
+
case InputType3.Message:
|
2307
2366
|
correspondingInput = inputs.find(
|
2308
|
-
(x) => x.type ===
|
2367
|
+
(x) => x.type === InputType3.Message && x.sender === i.sender
|
2309
2368
|
);
|
2310
2369
|
break;
|
2311
2370
|
default:
|
2312
2371
|
return;
|
2313
2372
|
}
|
2314
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput &&
|
2373
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
|
2315
2374
|
i.predicate = correspondingInput.predicate;
|
2316
2375
|
i.predicateData = correspondingInput.predicateData;
|
2317
2376
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
2318
2377
|
}
|
2319
2378
|
});
|
2320
2379
|
}
|
2321
|
-
shiftPredicateData() {
|
2322
|
-
this.inputs.forEach((input) => {
|
2323
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
2324
|
-
input.predicateData = input.padPredicateData(
|
2325
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
2326
|
-
);
|
2327
|
-
}
|
2328
|
-
});
|
2329
|
-
}
|
2330
2380
|
};
|
2331
2381
|
|
2332
2382
|
// src/providers/transaction-request/create-transaction-request.ts
|
2333
2383
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2334
|
-
import { bn as
|
2384
|
+
import { bn as bn10 } from "@fuel-ts/math";
|
2335
2385
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2336
2386
|
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2337
2387
|
|
2338
2388
|
// src/providers/transaction-request/hash-transaction.ts
|
2339
2389
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2340
2390
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2341
|
-
import { bn as
|
2342
|
-
import { TransactionType as TransactionType2, InputType as
|
2391
|
+
import { bn as bn9 } from "@fuel-ts/math";
|
2392
|
+
import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2343
2393
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2344
2394
|
import { clone as clone2 } from "ramda";
|
2345
2395
|
function hashTransaction(transactionRequest, chainId) {
|
@@ -2350,19 +2400,19 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2350
2400
|
transaction.inputs = transaction.inputs.map((input) => {
|
2351
2401
|
const inputClone = clone2(input);
|
2352
2402
|
switch (inputClone.type) {
|
2353
|
-
case
|
2403
|
+
case InputType4.Coin: {
|
2354
2404
|
inputClone.txPointer = {
|
2355
2405
|
blockHeight: 0,
|
2356
2406
|
txIndex: 0
|
2357
2407
|
};
|
2358
|
-
inputClone.predicateGasUsed =
|
2408
|
+
inputClone.predicateGasUsed = bn9(0);
|
2359
2409
|
return inputClone;
|
2360
2410
|
}
|
2361
|
-
case
|
2362
|
-
inputClone.predicateGasUsed =
|
2411
|
+
case InputType4.Message: {
|
2412
|
+
inputClone.predicateGasUsed = bn9(0);
|
2363
2413
|
return inputClone;
|
2364
2414
|
}
|
2365
|
-
case
|
2415
|
+
case InputType4.Contract: {
|
2366
2416
|
inputClone.txPointer = {
|
2367
2417
|
blockHeight: 0,
|
2368
2418
|
txIndex: 0
|
@@ -2386,12 +2436,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2386
2436
|
return outputClone;
|
2387
2437
|
}
|
2388
2438
|
case OutputType3.Change: {
|
2389
|
-
outputClone.amount =
|
2439
|
+
outputClone.amount = bn9(0);
|
2390
2440
|
return outputClone;
|
2391
2441
|
}
|
2392
2442
|
case OutputType3.Variable: {
|
2393
2443
|
outputClone.to = ZeroBytes325;
|
2394
|
-
outputClone.amount =
|
2444
|
+
outputClone.amount = bn9(0);
|
2395
2445
|
outputClone.assetId = ZeroBytes325;
|
2396
2446
|
return outputClone;
|
2397
2447
|
}
|
@@ -2469,7 +2519,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2469
2519
|
type: TransactionType3.Create,
|
2470
2520
|
...baseTransaction,
|
2471
2521
|
bytecodeWitnessIndex,
|
2472
|
-
storageSlotsCount:
|
2522
|
+
storageSlotsCount: bn10(storageSlots.length),
|
2473
2523
|
salt: this.salt ? hexlify9(this.salt) : ZeroBytes326,
|
2474
2524
|
storageSlots
|
2475
2525
|
};
|
@@ -2509,7 +2559,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2509
2559
|
}
|
2510
2560
|
metadataGas(gasCosts) {
|
2511
2561
|
return calculateMetadataGasForTxCreate({
|
2512
|
-
contractBytesSize:
|
2562
|
+
contractBytesSize: bn10(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2513
2563
|
gasCosts,
|
2514
2564
|
stateRootSize: this.storageSlots.length,
|
2515
2565
|
txBytesSize: this.byteSize()
|
@@ -2521,8 +2571,8 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2521
2571
|
import { Interface } from "@fuel-ts/abi-coder";
|
2522
2572
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2523
2573
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2524
|
-
import { bn as
|
2525
|
-
import { InputType as
|
2574
|
+
import { bn as bn11 } from "@fuel-ts/math";
|
2575
|
+
import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2526
2576
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2527
2577
|
|
2528
2578
|
// src/providers/transaction-request/scripts.ts
|
@@ -2575,7 +2625,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2575
2625
|
*/
|
2576
2626
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2577
2627
|
super(rest);
|
2578
|
-
this.gasLimit =
|
2628
|
+
this.gasLimit = bn11(gasLimit);
|
2579
2629
|
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
2580
2630
|
this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
|
2581
2631
|
this.abis = rest.abis;
|
@@ -2592,8 +2642,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2592
2642
|
type: TransactionType4.Script,
|
2593
2643
|
scriptGasLimit: this.gasLimit,
|
2594
2644
|
...super.getBaseTransaction(),
|
2595
|
-
scriptLength:
|
2596
|
-
scriptDataLength:
|
2645
|
+
scriptLength: bn11(script.length),
|
2646
|
+
scriptDataLength: bn11(scriptData.length),
|
2597
2647
|
receiptsRoot: ZeroBytes327,
|
2598
2648
|
script: hexlify10(script),
|
2599
2649
|
scriptData: hexlify10(scriptData)
|
@@ -2606,7 +2656,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2606
2656
|
*/
|
2607
2657
|
getContractInputs() {
|
2608
2658
|
return this.inputs.filter(
|
2609
|
-
(input) => input.type ===
|
2659
|
+
(input) => input.type === InputType5.Contract
|
2610
2660
|
);
|
2611
2661
|
}
|
2612
2662
|
/**
|
@@ -2686,7 +2736,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2686
2736
|
return this;
|
2687
2737
|
}
|
2688
2738
|
const inputIndex = super.pushInput({
|
2689
|
-
type:
|
2739
|
+
type: InputType5.Contract,
|
2690
2740
|
contractId: contractAddress.toB256(),
|
2691
2741
|
txPointer: "0x00000000000000000000000000000000"
|
2692
2742
|
});
|
@@ -2728,7 +2778,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2728
2778
|
|
2729
2779
|
// src/providers/transaction-request/utils.ts
|
2730
2780
|
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2731
|
-
import { TransactionType as TransactionType5
|
2781
|
+
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2732
2782
|
var transactionRequestify = (obj) => {
|
2733
2783
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2734
2784
|
return obj;
|
@@ -2746,21 +2796,6 @@ var transactionRequestify = (obj) => {
|
|
2746
2796
|
}
|
2747
2797
|
}
|
2748
2798
|
};
|
2749
|
-
var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
|
2750
|
-
(acc, input) => {
|
2751
|
-
if (input.type === InputType5.Coin && input.owner === owner.toB256()) {
|
2752
|
-
acc.utxos.push(input.id);
|
2753
|
-
}
|
2754
|
-
if (input.type === InputType5.Message && input.recipient === owner.toB256()) {
|
2755
|
-
acc.messages.push(input.nonce);
|
2756
|
-
}
|
2757
|
-
return acc;
|
2758
|
-
},
|
2759
|
-
{
|
2760
|
-
utxos: [],
|
2761
|
-
messages: []
|
2762
|
-
}
|
2763
|
-
);
|
2764
2799
|
|
2765
2800
|
// src/providers/transaction-response/transaction-response.ts
|
2766
2801
|
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
@@ -2774,7 +2809,7 @@ import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
|
2774
2809
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2775
2810
|
|
2776
2811
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
2777
|
-
import { bn as
|
2812
|
+
import { bn as bn12 } from "@fuel-ts/math";
|
2778
2813
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2779
2814
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2780
2815
|
var calculateTXFeeForSummary = (params) => {
|
@@ -2788,19 +2823,19 @@ var calculateTXFeeForSummary = (params) => {
|
|
2788
2823
|
if (totalFee) {
|
2789
2824
|
return totalFee;
|
2790
2825
|
}
|
2791
|
-
const gasPerByte =
|
2792
|
-
const gasPriceFactor =
|
2826
|
+
const gasPerByte = bn12(feeParams.gasPerByte);
|
2827
|
+
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
2793
2828
|
const transactionBytes = arrayify9(rawPayload);
|
2794
2829
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2795
2830
|
const { type, witnesses, inputs, policies } = transaction;
|
2796
|
-
let metadataGas =
|
2797
|
-
let gasLimit =
|
2831
|
+
let metadataGas = bn12(0);
|
2832
|
+
let gasLimit = bn12(0);
|
2798
2833
|
if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
|
2799
|
-
return
|
2834
|
+
return bn12(0);
|
2800
2835
|
}
|
2801
2836
|
if (type === TransactionType6.Create) {
|
2802
2837
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2803
|
-
const contractBytesSize =
|
2838
|
+
const contractBytesSize = bn12(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
2804
2839
|
metadataGas = calculateMetadataGasForTxCreate({
|
2805
2840
|
contractBytesSize,
|
2806
2841
|
gasCosts,
|
@@ -2819,7 +2854,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
2819
2854
|
}
|
2820
2855
|
const minGas = getMinGas({
|
2821
2856
|
gasCosts,
|
2822
|
-
gasPerByte:
|
2857
|
+
gasPerByte: bn12(gasPerByte),
|
2823
2858
|
inputs,
|
2824
2859
|
metadataGas,
|
2825
2860
|
txBytesSize: transactionBytes.length
|
@@ -2850,39 +2885,28 @@ import { bn as bn13 } from "@fuel-ts/math";
|
|
2850
2885
|
import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2851
2886
|
|
2852
2887
|
// src/providers/transaction-summary/call.ts
|
2853
|
-
import { Interface as Interface2
|
2854
|
-
|
2855
|
-
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2888
|
+
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
2889
|
+
var getFunctionCall = ({ abi, receipt }) => {
|
2856
2890
|
const abiInterface = new Interface2(abi);
|
2857
2891
|
const callFunctionSelector = receipt.param1.toHex(8);
|
2858
2892
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
2859
2893
|
const inputs = functionFragment.jsonFn.inputs;
|
2860
|
-
|
2861
|
-
if (functionFragment.isInputDataPointer) {
|
2862
|
-
if (rawPayload) {
|
2863
|
-
const argsOffset = bn12(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2864
|
-
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2865
|
-
}
|
2866
|
-
} else {
|
2867
|
-
encodedArgs = receipt.param2.toHex();
|
2868
|
-
}
|
2894
|
+
const encodedArgs = receipt.param2.toHex();
|
2869
2895
|
let argumentsProvided;
|
2870
|
-
|
2871
|
-
|
2872
|
-
|
2873
|
-
|
2874
|
-
|
2875
|
-
|
2876
|
-
|
2877
|
-
|
2878
|
-
|
2879
|
-
|
2880
|
-
|
2881
|
-
|
2882
|
-
|
2883
|
-
|
2884
|
-
}, {});
|
2885
|
-
}
|
2896
|
+
const data = functionFragment.decodeArguments(encodedArgs);
|
2897
|
+
if (data) {
|
2898
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
2899
|
+
const value = data[index];
|
2900
|
+
const name = input.name;
|
2901
|
+
if (name) {
|
2902
|
+
return {
|
2903
|
+
...prev,
|
2904
|
+
// reparse to remove bn
|
2905
|
+
[name]: JSON.parse(JSON.stringify(value))
|
2906
|
+
};
|
2907
|
+
}
|
2908
|
+
return prev;
|
2909
|
+
}, {});
|
2886
2910
|
}
|
2887
2911
|
const call = {
|
2888
2912
|
functionSignature: functionFragment.signature,
|
@@ -5154,22 +5178,6 @@ var rawAssets = [
|
|
5154
5178
|
];
|
5155
5179
|
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
5156
5180
|
|
5157
|
-
// src/providers/transaction-request/helpers.ts
|
5158
|
-
import { bn as bn19 } from "@fuel-ts/math";
|
5159
|
-
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
5160
|
-
var isRequestInputCoin = (input) => input.type === InputType8.Coin;
|
5161
|
-
var isRequestInputMessage = (input) => input.type === InputType8.Message;
|
5162
|
-
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
|
5163
|
-
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
5164
|
-
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
5165
|
-
return acc.add(input.amount);
|
5166
|
-
}
|
5167
|
-
if (isRequestInputMessage(input) && assetId === baseAsset) {
|
5168
|
-
return acc.add(input.amount);
|
5169
|
-
}
|
5170
|
-
return acc;
|
5171
|
-
}, bn19(0));
|
5172
|
-
|
5173
5181
|
// src/utils/formatTransferToContractScriptData.ts
|
5174
5182
|
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
5175
5183
|
import { BN as BN2 } from "@fuel-ts/math";
|
@@ -5373,9 +5381,9 @@ var Account = class extends AbstractAccount {
|
|
5373
5381
|
const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
|
5374
5382
|
const fee = request.maxFee;
|
5375
5383
|
const baseAssetId = this.provider.getBaseAssetId();
|
5376
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
5384
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
|
5377
5385
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
5378
|
-
amount:
|
5386
|
+
amount: bn19(fee),
|
5379
5387
|
assetId: baseAssetId,
|
5380
5388
|
coinQuantities: requiredQuantities
|
5381
5389
|
});
|
@@ -5383,7 +5391,7 @@ var Account = class extends AbstractAccount {
|
|
5383
5391
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
5384
5392
|
quantitiesDict[assetId] = {
|
5385
5393
|
required: amount,
|
5386
|
-
owned:
|
5394
|
+
owned: bn19(0)
|
5387
5395
|
};
|
5388
5396
|
});
|
5389
5397
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -5407,10 +5415,9 @@ var Account = class extends AbstractAccount {
|
|
5407
5415
|
while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
|
5408
5416
|
const resources = await this.getResourcesToSpend(
|
5409
5417
|
missingQuantities,
|
5410
|
-
|
5418
|
+
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
5411
5419
|
);
|
5412
5420
|
request.addResources(resources);
|
5413
|
-
request.shiftPredicateData();
|
5414
5421
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5415
5422
|
const requestToReestimate2 = clone4(request);
|
5416
5423
|
if (addedSignatures) {
|
@@ -5442,7 +5449,6 @@ var Account = class extends AbstractAccount {
|
|
5442
5449
|
}
|
5443
5450
|
fundingAttempts += 1;
|
5444
5451
|
}
|
5445
|
-
request.shiftPredicateData();
|
5446
5452
|
request.updatePredicateGasUsed(estimatedPredicates);
|
5447
5453
|
const requestToReestimate = clone4(request);
|
5448
5454
|
if (addedSignatures) {
|
@@ -5493,7 +5499,7 @@ var Account = class extends AbstractAccount {
|
|
5493
5499
|
* @returns A promise that resolves to the transaction response.
|
5494
5500
|
*/
|
5495
5501
|
async transfer(destination, amount, assetId, txParams = {}) {
|
5496
|
-
if (
|
5502
|
+
if (bn19(amount).lte(0)) {
|
5497
5503
|
throw new FuelError15(
|
5498
5504
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5499
5505
|
"Transfer amount must be a positive number."
|
@@ -5513,7 +5519,7 @@ var Account = class extends AbstractAccount {
|
|
5513
5519
|
* @returns A promise that resolves to the transaction response.
|
5514
5520
|
*/
|
5515
5521
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5516
|
-
if (
|
5522
|
+
if (bn19(amount).lte(0)) {
|
5517
5523
|
throw new FuelError15(
|
5518
5524
|
ErrorCode15.INVALID_TRANSFER_AMOUNT,
|
5519
5525
|
"Transfer amount must be a positive number."
|
@@ -5523,7 +5529,7 @@ var Account = class extends AbstractAccount {
|
|
5523
5529
|
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5524
5530
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5525
5531
|
hexlifiedContractId: contractAddress.toB256(),
|
5526
|
-
amountToTransfer:
|
5532
|
+
amountToTransfer: bn19(amount),
|
5527
5533
|
assetId: assetIdToTransfer
|
5528
5534
|
});
|
5529
5535
|
let request = new ScriptTransactionRequest({
|
@@ -5534,7 +5540,7 @@ var Account = class extends AbstractAccount {
|
|
5534
5540
|
request.addContractInputAndOutput(contractAddress);
|
5535
5541
|
const txCost = await this.provider.getTransactionCost(request, {
|
5536
5542
|
resourcesOwner: this,
|
5537
|
-
quantitiesToContract: [{ amount:
|
5543
|
+
quantitiesToContract: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
|
5538
5544
|
});
|
5539
5545
|
request = this.validateGasLimitAndMaxFee({
|
5540
5546
|
transactionRequest: request,
|
@@ -5559,7 +5565,7 @@ var Account = class extends AbstractAccount {
|
|
5559
5565
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5560
5566
|
);
|
5561
5567
|
const amountDataArray = arrayify14(
|
5562
|
-
"0x".concat(
|
5568
|
+
"0x".concat(bn19(amount).toHex().substring(2).padStart(16, "0"))
|
5563
5569
|
);
|
5564
5570
|
const script = new Uint8Array([
|
5565
5571
|
...arrayify14(withdrawScript.bytes),
|
@@ -5569,7 +5575,7 @@ var Account = class extends AbstractAccount {
|
|
5569
5575
|
const params = { script, ...txParams };
|
5570
5576
|
const baseAssetId = this.provider.getBaseAssetId();
|
5571
5577
|
let request = new ScriptTransactionRequest(params);
|
5572
|
-
const quantitiesToContract = [{ amount:
|
5578
|
+
const quantitiesToContract = [{ amount: bn19(amount), assetId: baseAssetId }];
|
5573
5579
|
const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
|
5574
5580
|
request = this.validateGasLimitAndMaxFee({
|
5575
5581
|
transactionRequest: request,
|
@@ -5987,18 +5993,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
5987
5993
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5988
5994
|
|
5989
5995
|
// src/hdwallet/hdwallet.ts
|
5996
|
+
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
5990
5997
|
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
5991
5998
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5992
|
-
import { bn as
|
5993
|
-
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5994
|
-
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5999
|
+
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
6000
|
+
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
5995
6001
|
|
5996
6002
|
// src/mnemonic/mnemonic.ts
|
5997
|
-
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
6003
|
+
import { randomBytes as randomBytes4, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
5998
6004
|
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5999
6005
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
6000
|
-
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
6001
|
-
import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
|
6006
|
+
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
6002
6007
|
|
6003
6008
|
// src/wordlists/words/english.ts
|
6004
6009
|
var english = [
|
@@ -8062,38 +8067,6 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8062
8067
|
import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
|
8063
8068
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
8064
8069
|
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
8065
|
-
function toUtf8Bytes(stri) {
|
8066
|
-
const str = stri.normalize("NFKD");
|
8067
|
-
const result = [];
|
8068
|
-
for (let i = 0; i < str.length; i += 1) {
|
8069
|
-
const c = str.charCodeAt(i);
|
8070
|
-
if (c < 128) {
|
8071
|
-
result.push(c);
|
8072
|
-
} else if (c < 2048) {
|
8073
|
-
result.push(c >> 6 | 192);
|
8074
|
-
result.push(c & 63 | 128);
|
8075
|
-
} else if ((c & 64512) === 55296) {
|
8076
|
-
i += 1;
|
8077
|
-
const c2 = str.charCodeAt(i);
|
8078
|
-
if (i >= str.length || (c2 & 64512) !== 56320) {
|
8079
|
-
throw new FuelError17(
|
8080
|
-
ErrorCode17.INVALID_INPUT_PARAMETERS,
|
8081
|
-
"Invalid UTF-8 in the input string."
|
8082
|
-
);
|
8083
|
-
}
|
8084
|
-
const pair = 65536 + ((c & 1023) << 10) + (c2 & 1023);
|
8085
|
-
result.push(pair >> 18 | 240);
|
8086
|
-
result.push(pair >> 12 & 63 | 128);
|
8087
|
-
result.push(pair >> 6 & 63 | 128);
|
8088
|
-
result.push(pair & 63 | 128);
|
8089
|
-
} else {
|
8090
|
-
result.push(c >> 12 | 224);
|
8091
|
-
result.push(c >> 6 & 63 | 128);
|
8092
|
-
result.push(c & 63 | 128);
|
8093
|
-
}
|
8094
|
-
}
|
8095
|
-
return Uint8Array.from(result);
|
8096
|
-
}
|
8097
8070
|
function getLowerMask(bits) {
|
8098
8071
|
return (1 << bits) - 1;
|
8099
8072
|
}
|
@@ -8461,7 +8434,7 @@ var HDWallet = class {
|
|
8461
8434
|
const IR = bytes.slice(32);
|
8462
8435
|
if (privateKey) {
|
8463
8436
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8464
|
-
const ki =
|
8437
|
+
const ki = bn20(IL).add(privateKey).mod(N).toBytes(32);
|
8465
8438
|
return new HDWallet({
|
8466
8439
|
privateKey: ki,
|
8467
8440
|
chainCode: IR,
|
@@ -8527,7 +8500,7 @@ var HDWallet = class {
|
|
8527
8500
|
});
|
8528
8501
|
}
|
8529
8502
|
static fromExtendedKey(extendedKey) {
|
8530
|
-
const decoded =
|
8503
|
+
const decoded = hexlify17(toBytes2(decodeBase58(extendedKey)));
|
8531
8504
|
const bytes = arrayify18(decoded);
|
8532
8505
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8533
8506
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
@@ -9140,16 +9113,9 @@ var StorageAbstract = class {
|
|
9140
9113
|
};
|
9141
9114
|
|
9142
9115
|
// src/predicate/predicate.ts
|
9143
|
-
import {
|
9144
|
-
Interface as Interface4,
|
9145
|
-
INPUT_COIN_FIXED_SIZE,
|
9146
|
-
WORD_SIZE,
|
9147
|
-
calculateVmTxMemory as calculateVmTxMemory2,
|
9148
|
-
SCRIPT_FIXED_SIZE
|
9149
|
-
} from "@fuel-ts/abi-coder";
|
9116
|
+
import { Interface as Interface4 } from "@fuel-ts/abi-coder";
|
9150
9117
|
import { Address as Address9 } from "@fuel-ts/address";
|
9151
9118
|
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9152
|
-
import { ByteArrayCoder, InputType as InputType9 } from "@fuel-ts/transactions";
|
9153
9119
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
9154
9120
|
|
9155
9121
|
// src/predicate/utils/getPredicateRoot.ts
|
@@ -9207,11 +9173,15 @@ var Predicate = class extends Account {
|
|
9207
9173
|
*/
|
9208
9174
|
populateTransactionPredicateData(transactionRequestLike) {
|
9209
9175
|
const request = transactionRequestify(transactionRequestLike);
|
9210
|
-
const
|
9211
|
-
|
9212
|
-
|
9176
|
+
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
9177
|
+
if (placeholderIndex !== -1) {
|
9178
|
+
request.removeWitness(placeholderIndex);
|
9179
|
+
}
|
9180
|
+
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
9181
|
+
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9213
9182
|
input.predicate = hexlify19(this.bytes);
|
9214
|
-
input.predicateData = hexlify19(this.getPredicateData(
|
9183
|
+
input.predicateData = hexlify19(this.getPredicateData());
|
9184
|
+
input.witnessIndex = 0;
|
9215
9185
|
}
|
9216
9186
|
});
|
9217
9187
|
return request;
|
@@ -9236,17 +9206,12 @@ var Predicate = class extends Account {
|
|
9236
9206
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
9237
9207
|
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
9238
9208
|
}
|
9239
|
-
getPredicateData(
|
9209
|
+
getPredicateData() {
|
9240
9210
|
if (!this.predicateData.length) {
|
9241
9211
|
return new Uint8Array();
|
9242
9212
|
}
|
9243
9213
|
const mainFn = this.interface?.functions.main;
|
9244
|
-
|
9245
|
-
const VM_TX_MEMORY = calculateVmTxMemory2({
|
9246
|
-
maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
|
9247
|
-
});
|
9248
|
-
const OFFSET = VM_TX_MEMORY + SCRIPT_FIXED_SIZE + INPUT_COIN_FIXED_SIZE + WORD_SIZE + paddedCode.byteLength + policiesLength * WORD_SIZE;
|
9249
|
-
return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
|
9214
|
+
return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
|
9250
9215
|
}
|
9251
9216
|
/**
|
9252
9217
|
* Processes the predicate data and returns the altered bytecode and interface.
|
@@ -9295,8 +9260,7 @@ var Predicate = class extends Account {
|
|
9295
9260
|
);
|
9296
9261
|
return resources.map((resource) => ({
|
9297
9262
|
...resource,
|
9298
|
-
predicate: hexlify19(this.bytes)
|
9299
|
-
padPredicateData: (policiesLength) => hexlify19(this.getPredicateData(policiesLength))
|
9263
|
+
predicate: hexlify19(this.bytes)
|
9300
9264
|
}));
|
9301
9265
|
}
|
9302
9266
|
/**
|
@@ -9334,6 +9298,28 @@ var Predicate = class extends Account {
|
|
9334
9298
|
}
|
9335
9299
|
return mutatedBytes;
|
9336
9300
|
}
|
9301
|
+
/**
|
9302
|
+
* Returns the index of the witness placeholder that was added to this predicate.
|
9303
|
+
* If no witness placeholder was added, it returns -1.
|
9304
|
+
* @param request - The transaction request.
|
9305
|
+
* @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
|
9306
|
+
*/
|
9307
|
+
getIndexFromPlaceholderWitness(request) {
|
9308
|
+
const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
|
9309
|
+
let index = -1;
|
9310
|
+
const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
|
9311
|
+
if (hasEmptyPredicateInputs) {
|
9312
|
+
index = hasEmptyPredicateInputs.witnessIndex;
|
9313
|
+
const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
|
9314
|
+
if (!allInputsAreEmpty) {
|
9315
|
+
const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
|
9316
|
+
if (wasFilledInputAddedFirst) {
|
9317
|
+
index = -1;
|
9318
|
+
}
|
9319
|
+
}
|
9320
|
+
}
|
9321
|
+
return index;
|
9322
|
+
}
|
9337
9323
|
};
|
9338
9324
|
|
9339
9325
|
// src/connectors/fuel.ts
|
@@ -10056,7 +10042,8 @@ export {
|
|
10056
10042
|
assets,
|
10057
10043
|
buildBlockExplorerUrl,
|
10058
10044
|
cacheFor,
|
10059
|
-
|
10045
|
+
cacheRequestInputsResources,
|
10046
|
+
cacheRequestInputsResourcesFromOwner,
|
10060
10047
|
calculateGasFee,
|
10061
10048
|
calculateMetadataGasForTxCreate,
|
10062
10049
|
calculateMetadataGasForTxScript,
|
@@ -10070,6 +10057,7 @@ export {
|
|
10070
10057
|
extractTxError,
|
10071
10058
|
fuelAssetsBaseUrl,
|
10072
10059
|
gasUsedByInputs,
|
10060
|
+
getAssetAmountInRequestInputs,
|
10073
10061
|
getAssetEth,
|
10074
10062
|
getAssetFuel,
|
10075
10063
|
getAssetNetwork,
|
@@ -10104,6 +10092,7 @@ export {
|
|
10104
10092
|
getReceiptsMessageOut,
|
10105
10093
|
getReceiptsTransferOut,
|
10106
10094
|
getReceiptsWithMissingData,
|
10095
|
+
getRequestInputResourceOwner,
|
10107
10096
|
getTransactionStatusName,
|
10108
10097
|
getTransactionSummary,
|
10109
10098
|
getTransactionSummaryFromRequest,
|
@@ -10117,6 +10106,10 @@ export {
|
|
10117
10106
|
isMessage,
|
10118
10107
|
isRawCoin,
|
10119
10108
|
isRawMessage,
|
10109
|
+
isRequestInputCoin,
|
10110
|
+
isRequestInputMessage,
|
10111
|
+
isRequestInputResource,
|
10112
|
+
isRequestInputResourceFromOwner,
|
10120
10113
|
isType,
|
10121
10114
|
isTypeCreate,
|
10122
10115
|
isTypeMint,
|