@fuel-ts/account 0.0.0-rc-1895-20240404023124 → 0.0.0-rc-1976-20240404063407
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/index.global.js +63 -182
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +513 -578
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +286 -356
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts +2 -2
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +7 -0
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +5 -2
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/utils/index.d.ts +0 -1
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +65 -183
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +479 -537
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +260 -326
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
- package/dist/providers/utils/extract-tx-error.d.ts +0 -36
- package/dist/providers/utils/extract-tx-error.d.ts.map +0 -1
package/dist/index.mjs
CHANGED
@@ -29,14 +29,12 @@ var __privateMethod = (obj, member, method) => {
|
|
29
29
|
|
30
30
|
// src/account.ts
|
31
31
|
import { Address as Address3 } from "@fuel-ts/address";
|
32
|
-
import {
|
33
|
-
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
32
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
|
34
33
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
35
|
-
import { bn as
|
34
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
36
35
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
37
36
|
|
38
37
|
// src/providers/coin-quantity.ts
|
39
|
-
import { BaseAssetId } from "@fuel-ts/address/configs";
|
40
38
|
import { bn } from "@fuel-ts/math";
|
41
39
|
import { hexlify } from "@fuel-ts/utils";
|
42
40
|
var coinQuantityfy = (coinQuantityLike) => {
|
@@ -45,11 +43,11 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
45
43
|
let max2;
|
46
44
|
if (Array.isArray(coinQuantityLike)) {
|
47
45
|
amount = coinQuantityLike[0];
|
48
|
-
assetId = coinQuantityLike[1]
|
49
|
-
max2 = coinQuantityLike[2]
|
46
|
+
assetId = coinQuantityLike[1];
|
47
|
+
max2 = coinQuantityLike[2];
|
50
48
|
} else {
|
51
49
|
amount = coinQuantityLike.amount;
|
52
|
-
assetId = coinQuantityLike.assetId
|
50
|
+
assetId = coinQuantityLike.assetId;
|
53
51
|
max2 = coinQuantityLike.max ?? void 0;
|
54
52
|
}
|
55
53
|
const bnAmount = bn(amount);
|
@@ -73,8 +71,8 @@ var addAmountToAsset = (params) => {
|
|
73
71
|
|
74
72
|
// src/providers/provider.ts
|
75
73
|
import { Address as Address2 } from "@fuel-ts/address";
|
76
|
-
import { ErrorCode as
|
77
|
-
import { BN, bn as
|
74
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
|
75
|
+
import { BN, bn as bn14, max } from "@fuel-ts/math";
|
78
76
|
import {
|
79
77
|
InputType as InputType6,
|
80
78
|
TransactionType as TransactionType8,
|
@@ -1156,8 +1154,8 @@ var outputify = (value) => {
|
|
1156
1154
|
|
1157
1155
|
// src/providers/transaction-request/transaction-request.ts
|
1158
1156
|
import { Address, addressify } from "@fuel-ts/address";
|
1159
|
-
import {
|
1160
|
-
import { bn as
|
1157
|
+
import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
|
1158
|
+
import { bn as bn6 } from "@fuel-ts/math";
|
1161
1159
|
import {
|
1162
1160
|
PolicyType,
|
1163
1161
|
TransactionCoder,
|
@@ -1562,86 +1560,6 @@ function sleep(time) {
|
|
1562
1560
|
});
|
1563
1561
|
}
|
1564
1562
|
|
1565
|
-
// src/providers/utils/extract-tx-error.ts
|
1566
|
-
import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
|
1567
|
-
import { bn as bn6 } from "@fuel-ts/math";
|
1568
|
-
import { ReceiptType as ReceiptType3 } from "@fuel-ts/transactions";
|
1569
|
-
import {
|
1570
|
-
FAILED_REQUIRE_SIGNAL,
|
1571
|
-
FAILED_ASSERT_EQ_SIGNAL,
|
1572
|
-
FAILED_ASSERT_NE_SIGNAL,
|
1573
|
-
FAILED_ASSERT_SIGNAL,
|
1574
|
-
FAILED_TRANSFER_TO_ADDRESS_SIGNAL as FAILED_TRANSFER_TO_ADDRESS_SIGNAL2,
|
1575
|
-
PANIC_REASONS,
|
1576
|
-
PANIC_DOC_URL
|
1577
|
-
} from "@fuel-ts/transactions/configs";
|
1578
|
-
var assemblePanicError = (status) => {
|
1579
|
-
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
1580
|
-
const reason = status.reason;
|
1581
|
-
if (PANIC_REASONS.includes(status.reason)) {
|
1582
|
-
errorMessage = `${errorMessage}
|
1583
|
-
|
1584
|
-
You can read more about this error at:
|
1585
|
-
|
1586
|
-
${PANIC_DOC_URL}#variant.${status.reason}`;
|
1587
|
-
}
|
1588
|
-
return { errorMessage, reason };
|
1589
|
-
};
|
1590
|
-
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
1591
|
-
var assembleRevertError = (receipts, logs) => {
|
1592
|
-
let errorMessage = "The transaction reverted with an unknown reason.";
|
1593
|
-
const revertReceipt = receipts.find(({ type }) => type === ReceiptType3.Revert);
|
1594
|
-
let reason = "";
|
1595
|
-
if (revertReceipt) {
|
1596
|
-
const reasonHex = bn6(revertReceipt.val).toHex();
|
1597
|
-
switch (reasonHex) {
|
1598
|
-
case FAILED_REQUIRE_SIGNAL: {
|
1599
|
-
reason = "require";
|
1600
|
-
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
|
1601
|
-
break;
|
1602
|
-
}
|
1603
|
-
case FAILED_ASSERT_EQ_SIGNAL: {
|
1604
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1605
|
-
reason = "assert_eq";
|
1606
|
-
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
1607
|
-
break;
|
1608
|
-
}
|
1609
|
-
case FAILED_ASSERT_NE_SIGNAL: {
|
1610
|
-
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1611
|
-
reason = "assert_ne";
|
1612
|
-
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
1613
|
-
break;
|
1614
|
-
}
|
1615
|
-
case FAILED_ASSERT_SIGNAL:
|
1616
|
-
reason = "assert";
|
1617
|
-
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
1618
|
-
break;
|
1619
|
-
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
|
1620
|
-
reason = "MissingOutputChange";
|
1621
|
-
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
1622
|
-
break;
|
1623
|
-
default:
|
1624
|
-
reason = "unknown";
|
1625
|
-
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
1626
|
-
}
|
1627
|
-
}
|
1628
|
-
return { errorMessage, reason };
|
1629
|
-
};
|
1630
|
-
var extractTxError = (params) => {
|
1631
|
-
const { receipts, status, logs } = params;
|
1632
|
-
const isPanic = receipts.some(({ type }) => type === ReceiptType3.Panic);
|
1633
|
-
const isRevert = receipts.some(({ type }) => type === ReceiptType3.Revert);
|
1634
|
-
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
1635
|
-
const metadata = {
|
1636
|
-
logs,
|
1637
|
-
receipts,
|
1638
|
-
panic: isPanic,
|
1639
|
-
revert: isRevert,
|
1640
|
-
reason
|
1641
|
-
};
|
1642
|
-
return new FuelError7(ErrorCode7.SCRIPT_REVERTED, errorMessage, metadata);
|
1643
|
-
};
|
1644
|
-
|
1645
1563
|
// src/providers/transaction-request/errors.ts
|
1646
1564
|
var ChangeOutputCollisionError = class extends Error {
|
1647
1565
|
name = "ChangeOutputCollisionError";
|
@@ -1690,6 +1608,8 @@ var BaseTransactionRequest = class {
|
|
1690
1608
|
outputs = [];
|
1691
1609
|
/** List of witnesses */
|
1692
1610
|
witnesses = [];
|
1611
|
+
/** Base asset ID - should be fetched from the chain */
|
1612
|
+
baseAssetId = ZeroBytes324;
|
1693
1613
|
/**
|
1694
1614
|
* Constructor for initializing a base transaction request.
|
1695
1615
|
*
|
@@ -1702,15 +1622,17 @@ var BaseTransactionRequest = class {
|
|
1702
1622
|
witnessLimit,
|
1703
1623
|
inputs,
|
1704
1624
|
outputs,
|
1705
|
-
witnesses
|
1625
|
+
witnesses,
|
1626
|
+
baseAssetId
|
1706
1627
|
} = {}) {
|
1707
|
-
this.gasPrice =
|
1628
|
+
this.gasPrice = bn6(gasPrice);
|
1708
1629
|
this.maturity = maturity ?? 0;
|
1709
|
-
this.witnessLimit = witnessLimit ?
|
1710
|
-
this.maxFee = maxFee ?
|
1630
|
+
this.witnessLimit = witnessLimit ? bn6(witnessLimit) : void 0;
|
1631
|
+
this.maxFee = maxFee ? bn6(maxFee) : void 0;
|
1711
1632
|
this.inputs = inputs ?? [];
|
1712
1633
|
this.outputs = outputs ?? [];
|
1713
1634
|
this.witnesses = witnesses ?? [];
|
1635
|
+
this.baseAssetId = baseAssetId ?? ZeroBytes324;
|
1714
1636
|
}
|
1715
1637
|
static getPolicyMeta(req) {
|
1716
1638
|
let policyTypes = 0;
|
@@ -1935,11 +1857,9 @@ var BaseTransactionRequest = class {
|
|
1935
1857
|
*
|
1936
1858
|
* @param message - Message resource.
|
1937
1859
|
* @param predicate - Predicate bytes.
|
1938
|
-
* @param predicateData - Predicate data bytes.
|
1939
1860
|
*/
|
1940
1861
|
addMessageInput(message, predicate) {
|
1941
1862
|
const { recipient, sender, amount } = message;
|
1942
|
-
const assetId = BaseAssetId2;
|
1943
1863
|
let witnessIndex;
|
1944
1864
|
if (predicate) {
|
1945
1865
|
witnessIndex = 0;
|
@@ -1960,7 +1880,7 @@ var BaseTransactionRequest = class {
|
|
1960
1880
|
predicateData: predicate?.predicateDataBytes
|
1961
1881
|
};
|
1962
1882
|
this.pushInput(input);
|
1963
|
-
this.addChangeOutput(recipient,
|
1883
|
+
this.addChangeOutput(recipient, this.baseAssetId);
|
1964
1884
|
}
|
1965
1885
|
/**
|
1966
1886
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -2021,12 +1941,12 @@ var BaseTransactionRequest = class {
|
|
2021
1941
|
* @param amount - Amount of coin.
|
2022
1942
|
* @param assetId - Asset ID of coin.
|
2023
1943
|
*/
|
2024
|
-
addCoinOutput(to, amount, assetId
|
1944
|
+
addCoinOutput(to, amount, assetId) {
|
2025
1945
|
this.pushOutput({
|
2026
1946
|
type: OutputType2.Coin,
|
2027
1947
|
to: addressify(to).toB256(),
|
2028
1948
|
amount,
|
2029
|
-
assetId
|
1949
|
+
assetId: assetId ?? this.baseAssetId
|
2030
1950
|
});
|
2031
1951
|
return this;
|
2032
1952
|
}
|
@@ -2053,7 +1973,7 @@ var BaseTransactionRequest = class {
|
|
2053
1973
|
* @param to - Address of the owner.
|
2054
1974
|
* @param assetId - Asset ID of coin.
|
2055
1975
|
*/
|
2056
|
-
addChangeOutput(to, assetId
|
1976
|
+
addChangeOutput(to, assetId) {
|
2057
1977
|
const changeOutput = this.getChangeOutputs().find(
|
2058
1978
|
(output) => hexlify7(output.assetId) === assetId
|
2059
1979
|
);
|
@@ -2061,7 +1981,7 @@ var BaseTransactionRequest = class {
|
|
2061
1981
|
this.pushOutput({
|
2062
1982
|
type: OutputType2.Change,
|
2063
1983
|
to: addressify(to).toB256(),
|
2064
|
-
assetId
|
1984
|
+
assetId: assetId ?? this.baseAssetId
|
2065
1985
|
});
|
2066
1986
|
}
|
2067
1987
|
}
|
@@ -2137,13 +2057,13 @@ var BaseTransactionRequest = class {
|
|
2137
2057
|
assetId,
|
2138
2058
|
owner: resourcesOwner || Address.fromRandom(),
|
2139
2059
|
maturity: 0,
|
2140
|
-
blockCreated:
|
2141
|
-
txCreatedIdx:
|
2060
|
+
blockCreated: bn6(1),
|
2061
|
+
txCreatedIdx: bn6(1)
|
2142
2062
|
}
|
2143
2063
|
]);
|
2144
2064
|
}
|
2145
2065
|
};
|
2146
|
-
updateAssetInput(
|
2066
|
+
updateAssetInput(this.baseAssetId, bn6(1e11));
|
2147
2067
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2148
2068
|
}
|
2149
2069
|
/**
|
@@ -2154,7 +2074,7 @@ var BaseTransactionRequest = class {
|
|
2154
2074
|
*/
|
2155
2075
|
getCoinOutputsQuantities() {
|
2156
2076
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2157
|
-
amount:
|
2077
|
+
amount: bn6(amount),
|
2158
2078
|
assetId: assetId.toString()
|
2159
2079
|
}));
|
2160
2080
|
return coinsQuantities;
|
@@ -2183,7 +2103,7 @@ var BaseTransactionRequest = class {
|
|
2183
2103
|
default:
|
2184
2104
|
return;
|
2185
2105
|
}
|
2186
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput &&
|
2106
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn6(correspondingInput.predicateGasUsed).gt(0)) {
|
2187
2107
|
i.predicate = correspondingInput.predicate;
|
2188
2108
|
i.predicateData = correspondingInput.predicateData;
|
2189
2109
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2194,14 +2114,14 @@ var BaseTransactionRequest = class {
|
|
2194
2114
|
|
2195
2115
|
// src/providers/transaction-request/create-transaction-request.ts
|
2196
2116
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2197
|
-
import { bn as
|
2117
|
+
import { bn as bn8 } from "@fuel-ts/math";
|
2198
2118
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2199
2119
|
import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2200
2120
|
|
2201
2121
|
// src/providers/transaction-request/hash-transaction.ts
|
2202
2122
|
import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
|
2203
2123
|
import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
|
2204
|
-
import { bn as
|
2124
|
+
import { bn as bn7 } from "@fuel-ts/math";
|
2205
2125
|
import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
|
2206
2126
|
import { concat as concat2 } from "@fuel-ts/utils";
|
2207
2127
|
import { clone as clone2 } from "ramda";
|
@@ -2218,11 +2138,11 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2218
2138
|
blockHeight: 0,
|
2219
2139
|
txIndex: 0
|
2220
2140
|
};
|
2221
|
-
inputClone.predicateGasUsed =
|
2141
|
+
inputClone.predicateGasUsed = bn7(0);
|
2222
2142
|
return inputClone;
|
2223
2143
|
}
|
2224
2144
|
case InputType3.Message: {
|
2225
|
-
inputClone.predicateGasUsed =
|
2145
|
+
inputClone.predicateGasUsed = bn7(0);
|
2226
2146
|
return inputClone;
|
2227
2147
|
}
|
2228
2148
|
case InputType3.Contract: {
|
@@ -2249,12 +2169,12 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2249
2169
|
return outputClone;
|
2250
2170
|
}
|
2251
2171
|
case OutputType3.Change: {
|
2252
|
-
outputClone.amount =
|
2172
|
+
outputClone.amount = bn7(0);
|
2253
2173
|
return outputClone;
|
2254
2174
|
}
|
2255
2175
|
case OutputType3.Variable: {
|
2256
2176
|
outputClone.to = ZeroBytes325;
|
2257
|
-
outputClone.amount =
|
2177
|
+
outputClone.amount = bn7(0);
|
2258
2178
|
outputClone.assetId = ZeroBytes325;
|
2259
2179
|
return outputClone;
|
2260
2180
|
}
|
@@ -2378,7 +2298,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2378
2298
|
}
|
2379
2299
|
metadataGas(gasCosts) {
|
2380
2300
|
return calculateMetadataGasForTxCreate({
|
2381
|
-
contractBytesSize:
|
2301
|
+
contractBytesSize: bn8(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2382
2302
|
gasCosts,
|
2383
2303
|
stateRootSize: this.storageSlots.length,
|
2384
2304
|
txBytesSize: this.byteSize()
|
@@ -2390,7 +2310,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2390
2310
|
import { Interface } from "@fuel-ts/abi-coder";
|
2391
2311
|
import { addressify as addressify2 } from "@fuel-ts/address";
|
2392
2312
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2393
|
-
import { bn as
|
2313
|
+
import { bn as bn9 } from "@fuel-ts/math";
|
2394
2314
|
import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2395
2315
|
import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2396
2316
|
|
@@ -2444,7 +2364,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2444
2364
|
*/
|
2445
2365
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2446
2366
|
super(rest);
|
2447
|
-
this.gasLimit =
|
2367
|
+
this.gasLimit = bn9(gasLimit);
|
2448
2368
|
this.script = arrayify8(script ?? returnZeroScript.bytes);
|
2449
2369
|
this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
|
2450
2370
|
this.abis = rest.abis;
|
@@ -2592,7 +2512,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2592
2512
|
};
|
2593
2513
|
|
2594
2514
|
// src/providers/transaction-request/utils.ts
|
2595
|
-
import { ErrorCode as
|
2515
|
+
import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
|
2596
2516
|
import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
|
2597
2517
|
var transactionRequestify = (obj) => {
|
2598
2518
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
@@ -2607,14 +2527,14 @@ var transactionRequestify = (obj) => {
|
|
2607
2527
|
return CreateTransactionRequest.from(obj);
|
2608
2528
|
}
|
2609
2529
|
default: {
|
2610
|
-
throw new
|
2530
|
+
throw new FuelError7(ErrorCode7.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
|
2611
2531
|
}
|
2612
2532
|
}
|
2613
2533
|
};
|
2614
2534
|
|
2615
2535
|
// src/providers/transaction-response/transaction-response.ts
|
2616
|
-
import { ErrorCode as
|
2617
|
-
import { bn as
|
2536
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
|
2537
|
+
import { bn as bn13 } from "@fuel-ts/math";
|
2618
2538
|
import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
|
2619
2539
|
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
2620
2540
|
|
@@ -2622,7 +2542,7 @@ import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
|
2622
2542
|
import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2623
2543
|
|
2624
2544
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2625
|
-
import { bn as
|
2545
|
+
import { bn as bn10 } from "@fuel-ts/math";
|
2626
2546
|
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
2627
2547
|
import { arrayify as arrayify9 } from "@fuel-ts/utils";
|
2628
2548
|
var calculateTransactionFee = (params) => {
|
@@ -2631,24 +2551,24 @@ var calculateTransactionFee = (params) => {
|
|
2631
2551
|
rawPayload,
|
2632
2552
|
consensusParameters: { gasCosts, feeParams }
|
2633
2553
|
} = params;
|
2634
|
-
const gasPerByte =
|
2635
|
-
const gasPriceFactor =
|
2554
|
+
const gasPerByte = bn10(feeParams.gasPerByte);
|
2555
|
+
const gasPriceFactor = bn10(feeParams.gasPriceFactor);
|
2636
2556
|
const transactionBytes = arrayify9(rawPayload);
|
2637
2557
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
2638
2558
|
if (transaction.type === TransactionType6.Mint) {
|
2639
2559
|
return {
|
2640
|
-
fee:
|
2641
|
-
minFee:
|
2642
|
-
maxFee:
|
2643
|
-
feeFromGasUsed:
|
2560
|
+
fee: bn10(0),
|
2561
|
+
minFee: bn10(0),
|
2562
|
+
maxFee: bn10(0),
|
2563
|
+
feeFromGasUsed: bn10(0)
|
2644
2564
|
};
|
2645
2565
|
}
|
2646
2566
|
const { type, witnesses, inputs, policies } = transaction;
|
2647
|
-
let metadataGas =
|
2648
|
-
let gasLimit =
|
2567
|
+
let metadataGas = bn10(0);
|
2568
|
+
let gasLimit = bn10(0);
|
2649
2569
|
if (type === TransactionType6.Create) {
|
2650
2570
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2651
|
-
const contractBytesSize =
|
2571
|
+
const contractBytesSize = bn10(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
|
2652
2572
|
metadataGas = calculateMetadataGasForTxCreate({
|
2653
2573
|
contractBytesSize,
|
2654
2574
|
gasCosts,
|
@@ -2667,12 +2587,12 @@ var calculateTransactionFee = (params) => {
|
|
2667
2587
|
}
|
2668
2588
|
const minGas = getMinGas({
|
2669
2589
|
gasCosts,
|
2670
|
-
gasPerByte:
|
2590
|
+
gasPerByte: bn10(gasPerByte),
|
2671
2591
|
inputs,
|
2672
2592
|
metadataGas,
|
2673
2593
|
txBytesSize: transactionBytes.length
|
2674
2594
|
});
|
2675
|
-
const gasPrice =
|
2595
|
+
const gasPrice = bn10(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
|
2676
2596
|
const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
|
2677
2597
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2678
2598
|
const maxGas = getMaxGas({
|
@@ -2696,13 +2616,13 @@ var calculateTransactionFee = (params) => {
|
|
2696
2616
|
|
2697
2617
|
// src/providers/transaction-summary/operations.ts
|
2698
2618
|
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
2699
|
-
import { ErrorCode as
|
2700
|
-
import { bn as
|
2701
|
-
import { ReceiptType as
|
2619
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2620
|
+
import { bn as bn12 } from "@fuel-ts/math";
|
2621
|
+
import { ReceiptType as ReceiptType3, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2702
2622
|
|
2703
2623
|
// src/providers/transaction-summary/call.ts
|
2704
2624
|
import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
|
2705
|
-
import { bn as
|
2625
|
+
import { bn as bn11 } from "@fuel-ts/math";
|
2706
2626
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2707
2627
|
const abiInterface = new Interface2(abi);
|
2708
2628
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2711,7 +2631,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2711
2631
|
let encodedArgs;
|
2712
2632
|
if (functionFragment.isInputDataPointer) {
|
2713
2633
|
if (rawPayload) {
|
2714
|
-
const argsOffset =
|
2634
|
+
const argsOffset = bn11(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2715
2635
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2716
2636
|
}
|
2717
2637
|
} else {
|
@@ -2745,7 +2665,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2745
2665
|
};
|
2746
2666
|
|
2747
2667
|
// src/providers/transaction-summary/input.ts
|
2748
|
-
import { ErrorCode as
|
2668
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2749
2669
|
import { InputType as InputType5 } from "@fuel-ts/transactions";
|
2750
2670
|
function getInputsByTypes(inputs, types) {
|
2751
2671
|
return inputs.filter((i) => types.includes(i.type));
|
@@ -2783,8 +2703,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2783
2703
|
return void 0;
|
2784
2704
|
}
|
2785
2705
|
if (contractInput.type !== InputType5.Contract) {
|
2786
|
-
throw new
|
2787
|
-
|
2706
|
+
throw new FuelError8(
|
2707
|
+
ErrorCode8.INVALID_TRANSACTION_INPUT,
|
2788
2708
|
`Contract input should be of type 'contract'.`
|
2789
2709
|
);
|
2790
2710
|
}
|
@@ -2872,8 +2792,8 @@ function getTransactionTypeName(transactionType) {
|
|
2872
2792
|
case TransactionType7.Script:
|
2873
2793
|
return "Script" /* Script */;
|
2874
2794
|
default:
|
2875
|
-
throw new
|
2876
|
-
|
2795
|
+
throw new FuelError9(
|
2796
|
+
ErrorCode9.INVALID_TRANSACTION_TYPE,
|
2877
2797
|
`Invalid transaction type: ${transactionType}.`
|
2878
2798
|
);
|
2879
2799
|
}
|
@@ -2895,10 +2815,10 @@ function hasSameAssetId(a) {
|
|
2895
2815
|
return (b) => a.assetId === b.assetId;
|
2896
2816
|
}
|
2897
2817
|
function getReceiptsCall(receipts) {
|
2898
|
-
return getReceiptsByType(receipts,
|
2818
|
+
return getReceiptsByType(receipts, ReceiptType3.Call);
|
2899
2819
|
}
|
2900
2820
|
function getReceiptsMessageOut(receipts) {
|
2901
|
-
return getReceiptsByType(receipts,
|
2821
|
+
return getReceiptsByType(receipts, ReceiptType3.MessageOut);
|
2902
2822
|
}
|
2903
2823
|
var mergeAssets = (op1, op2) => {
|
2904
2824
|
const assets1 = op1.assetsSent || [];
|
@@ -2911,7 +2831,7 @@ var mergeAssets = (op1, op2) => {
|
|
2911
2831
|
if (!matchingAsset) {
|
2912
2832
|
return asset1;
|
2913
2833
|
}
|
2914
|
-
const mergedAmount =
|
2834
|
+
const mergedAmount = bn12(asset1.amount).add(matchingAsset.amount);
|
2915
2835
|
return { ...asset1, amount: mergedAmount };
|
2916
2836
|
});
|
2917
2837
|
return mergedAssets.concat(filteredAssets);
|
@@ -2937,7 +2857,7 @@ function addOperation(operations, toAdd) {
|
|
2937
2857
|
return allOperations;
|
2938
2858
|
}
|
2939
2859
|
function getReceiptsTransferOut(receipts) {
|
2940
|
-
return getReceiptsByType(receipts,
|
2860
|
+
return getReceiptsByType(receipts, ReceiptType3.TransferOut);
|
2941
2861
|
}
|
2942
2862
|
function getWithdrawFromFuelOperations({
|
2943
2863
|
inputs,
|
@@ -3097,11 +3017,11 @@ function getTransferOperations({
|
|
3097
3017
|
});
|
3098
3018
|
const transferReceipts = getReceiptsByType(
|
3099
3019
|
receipts,
|
3100
|
-
|
3020
|
+
ReceiptType3.Transfer
|
3101
3021
|
);
|
3102
3022
|
const transferOutReceipts = getReceiptsByType(
|
3103
3023
|
receipts,
|
3104
|
-
|
3024
|
+
ReceiptType3.TransferOut
|
3105
3025
|
);
|
3106
3026
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
3107
3027
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3186,17 +3106,17 @@ function getOperations({
|
|
3186
3106
|
}
|
3187
3107
|
|
3188
3108
|
// src/providers/transaction-summary/receipt.ts
|
3189
|
-
import { ReceiptType as
|
3109
|
+
import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
|
3190
3110
|
var processGqlReceipt = (gqlReceipt) => {
|
3191
3111
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3192
3112
|
switch (receipt.type) {
|
3193
|
-
case
|
3113
|
+
case ReceiptType4.ReturnData: {
|
3194
3114
|
return {
|
3195
3115
|
...receipt,
|
3196
3116
|
data: gqlReceipt.data || "0x"
|
3197
3117
|
};
|
3198
3118
|
}
|
3199
|
-
case
|
3119
|
+
case ReceiptType4.LogData: {
|
3200
3120
|
return {
|
3201
3121
|
...receipt,
|
3202
3122
|
data: gqlReceipt.data || "0x"
|
@@ -3209,7 +3129,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3209
3129
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3210
3130
|
const mintedAssets = [];
|
3211
3131
|
receipts.forEach((receipt) => {
|
3212
|
-
if (receipt.type ===
|
3132
|
+
if (receipt.type === ReceiptType4.Mint) {
|
3213
3133
|
mintedAssets.push({
|
3214
3134
|
subId: receipt.subId,
|
3215
3135
|
contractId: receipt.contractId,
|
@@ -3223,7 +3143,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3223
3143
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3224
3144
|
const burnedAssets = [];
|
3225
3145
|
receipts.forEach((receipt) => {
|
3226
|
-
if (receipt.type ===
|
3146
|
+
if (receipt.type === ReceiptType4.Burn) {
|
3227
3147
|
burnedAssets.push({
|
3228
3148
|
subId: receipt.subId,
|
3229
3149
|
contractId: receipt.contractId,
|
@@ -3236,7 +3156,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3236
3156
|
};
|
3237
3157
|
|
3238
3158
|
// src/providers/transaction-summary/status.ts
|
3239
|
-
import { ErrorCode as
|
3159
|
+
import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
|
3240
3160
|
var getTransactionStatusName = (gqlStatus) => {
|
3241
3161
|
switch (gqlStatus) {
|
3242
3162
|
case "FailureStatus":
|
@@ -3248,8 +3168,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3248
3168
|
case "SqueezedOutStatus":
|
3249
3169
|
return "squeezedout" /* squeezedout */;
|
3250
3170
|
default:
|
3251
|
-
throw new
|
3252
|
-
|
3171
|
+
throw new FuelError10(
|
3172
|
+
ErrorCode10.INVALID_TRANSACTION_STATUS,
|
3253
3173
|
`Invalid transaction status: ${gqlStatus}.`
|
3254
3174
|
);
|
3255
3175
|
}
|
@@ -3362,12 +3282,12 @@ function assembleTransactionSummary(params) {
|
|
3362
3282
|
|
3363
3283
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3364
3284
|
import { Interface as Interface3, BigNumberCoder } from "@fuel-ts/abi-coder";
|
3365
|
-
import { ReceiptType as
|
3285
|
+
import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
|
3366
3286
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3367
3287
|
return receipts.reduce((logs, receipt) => {
|
3368
|
-
if (receipt.type ===
|
3288
|
+
if (receipt.type === ReceiptType5.LogData || receipt.type === ReceiptType5.Log) {
|
3369
3289
|
const interfaceToUse = new Interface3(externalAbis[receipt.id] || mainAbi);
|
3370
|
-
const data = receipt.type ===
|
3290
|
+
const data = receipt.type === ReceiptType5.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3371
3291
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3372
3292
|
logs.push(decodedLog);
|
3373
3293
|
}
|
@@ -3382,7 +3302,7 @@ var TransactionResponse = class {
|
|
3382
3302
|
/** Current provider */
|
3383
3303
|
provider;
|
3384
3304
|
/** Gas used on the transaction */
|
3385
|
-
gasUsed =
|
3305
|
+
gasUsed = bn13(0);
|
3386
3306
|
/** The graphql Transaction with receipts object. */
|
3387
3307
|
gqlTransaction;
|
3388
3308
|
abis;
|
@@ -3487,8 +3407,8 @@ var TransactionResponse = class {
|
|
3487
3407
|
});
|
3488
3408
|
for await (const { statusChange } of subscription) {
|
3489
3409
|
if (statusChange.type === "SqueezedOutStatus") {
|
3490
|
-
throw new
|
3491
|
-
|
3410
|
+
throw new FuelError11(
|
3411
|
+
ErrorCode11.TRANSACTION_SQUEEZED_OUT,
|
3492
3412
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
3493
3413
|
);
|
3494
3414
|
}
|
@@ -3510,26 +3430,14 @@ var TransactionResponse = class {
|
|
3510
3430
|
gqlTransaction: this.gqlTransaction,
|
3511
3431
|
...transactionSummary
|
3512
3432
|
};
|
3513
|
-
let logs = [];
|
3514
3433
|
if (this.abis) {
|
3515
|
-
logs = getDecodedLogs(
|
3434
|
+
const logs = getDecodedLogs(
|
3516
3435
|
transactionSummary.receipts,
|
3517
3436
|
this.abis.main,
|
3518
3437
|
this.abis.otherContractsAbis
|
3519
3438
|
);
|
3520
3439
|
transactionResult.logs = logs;
|
3521
3440
|
}
|
3522
|
-
if (transactionResult.isStatusFailure) {
|
3523
|
-
const {
|
3524
|
-
receipts,
|
3525
|
-
gqlTransaction: { status }
|
3526
|
-
} = transactionResult;
|
3527
|
-
throw extractTxError({
|
3528
|
-
receipts,
|
3529
|
-
status,
|
3530
|
-
logs
|
3531
|
-
});
|
3532
|
-
}
|
3533
3441
|
return transactionResult;
|
3534
3442
|
}
|
3535
3443
|
/**
|
@@ -3538,7 +3446,14 @@ var TransactionResponse = class {
|
|
3538
3446
|
* @param contractsAbiMap - The contracts ABI map.
|
3539
3447
|
*/
|
3540
3448
|
async wait(contractsAbiMap) {
|
3541
|
-
|
3449
|
+
const result = await this.waitForResult(contractsAbiMap);
|
3450
|
+
if (result.isStatusFailure) {
|
3451
|
+
throw new FuelError11(
|
3452
|
+
ErrorCode11.TRANSACTION_FAILED,
|
3453
|
+
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
3454
|
+
);
|
3455
|
+
}
|
3456
|
+
return result;
|
3542
3457
|
}
|
3543
3458
|
};
|
3544
3459
|
|
@@ -3600,29 +3515,30 @@ var processGqlChain = (chain) => {
|
|
3600
3515
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3601
3516
|
return {
|
3602
3517
|
name,
|
3603
|
-
baseChainHeight:
|
3518
|
+
baseChainHeight: bn14(daHeight),
|
3604
3519
|
consensusParameters: {
|
3605
|
-
contractMaxSize:
|
3606
|
-
maxInputs:
|
3607
|
-
maxOutputs:
|
3608
|
-
maxWitnesses:
|
3609
|
-
maxGasPerTx:
|
3610
|
-
maxScriptLength:
|
3611
|
-
maxScriptDataLength:
|
3612
|
-
maxStorageSlots:
|
3613
|
-
maxPredicateLength:
|
3614
|
-
maxPredicateDataLength:
|
3615
|
-
maxGasPerPredicate:
|
3616
|
-
gasPriceFactor:
|
3617
|
-
gasPerByte:
|
3618
|
-
maxMessageDataLength:
|
3619
|
-
chainId:
|
3520
|
+
contractMaxSize: bn14(contractParams.contractMaxSize),
|
3521
|
+
maxInputs: bn14(txParams.maxInputs),
|
3522
|
+
maxOutputs: bn14(txParams.maxOutputs),
|
3523
|
+
maxWitnesses: bn14(txParams.maxWitnesses),
|
3524
|
+
maxGasPerTx: bn14(txParams.maxGasPerTx),
|
3525
|
+
maxScriptLength: bn14(scriptParams.maxScriptLength),
|
3526
|
+
maxScriptDataLength: bn14(scriptParams.maxScriptDataLength),
|
3527
|
+
maxStorageSlots: bn14(contractParams.maxStorageSlots),
|
3528
|
+
maxPredicateLength: bn14(predicateParams.maxPredicateLength),
|
3529
|
+
maxPredicateDataLength: bn14(predicateParams.maxPredicateDataLength),
|
3530
|
+
maxGasPerPredicate: bn14(predicateParams.maxGasPerPredicate),
|
3531
|
+
gasPriceFactor: bn14(feeParams.gasPriceFactor),
|
3532
|
+
gasPerByte: bn14(feeParams.gasPerByte),
|
3533
|
+
maxMessageDataLength: bn14(predicateParams.maxMessageDataLength),
|
3534
|
+
chainId: bn14(consensusParameters.chainId),
|
3535
|
+
baseAssetId: consensusParameters.baseAssetId,
|
3620
3536
|
gasCosts
|
3621
3537
|
},
|
3622
3538
|
gasCosts,
|
3623
3539
|
latestBlock: {
|
3624
3540
|
id: latestBlock.id,
|
3625
|
-
height:
|
3541
|
+
height: bn14(latestBlock.header.height),
|
3626
3542
|
time: latestBlock.header.time,
|
3627
3543
|
transactions: latestBlock.transactions.map((i) => ({
|
3628
3544
|
id: i.id
|
@@ -3692,8 +3608,8 @@ var _Provider = class {
|
|
3692
3608
|
getChain() {
|
3693
3609
|
const chain = _Provider.chainInfoCache[this.url];
|
3694
3610
|
if (!chain) {
|
3695
|
-
throw new
|
3696
|
-
|
3611
|
+
throw new FuelError12(
|
3612
|
+
ErrorCode12.CHAIN_INFO_CACHE_EMPTY,
|
3697
3613
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
3698
3614
|
);
|
3699
3615
|
}
|
@@ -3705,8 +3621,8 @@ var _Provider = class {
|
|
3705
3621
|
getNode() {
|
3706
3622
|
const node = _Provider.nodeInfoCache[this.url];
|
3707
3623
|
if (!node) {
|
3708
|
-
throw new
|
3709
|
-
|
3624
|
+
throw new FuelError12(
|
3625
|
+
ErrorCode12.NODE_INFO_CACHE_EMPTY,
|
3710
3626
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
3711
3627
|
);
|
3712
3628
|
}
|
@@ -3753,8 +3669,8 @@ var _Provider = class {
|
|
3753
3669
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3754
3670
|
const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
|
3755
3671
|
if (!isMajorSupported || !isMinorSupported) {
|
3756
|
-
throw new
|
3757
|
-
|
3672
|
+
throw new FuelError12(
|
3673
|
+
FuelError12.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
|
3758
3674
|
`Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
|
3759
3675
|
);
|
3760
3676
|
}
|
@@ -3817,7 +3733,7 @@ var _Provider = class {
|
|
3817
3733
|
*/
|
3818
3734
|
async getBlockNumber() {
|
3819
3735
|
const { chain } = await this.operations.getChain();
|
3820
|
-
return
|
3736
|
+
return bn14(chain.latestBlock.header.height, 10);
|
3821
3737
|
}
|
3822
3738
|
/**
|
3823
3739
|
* Returns the chain information.
|
@@ -3827,9 +3743,9 @@ var _Provider = class {
|
|
3827
3743
|
async fetchNode() {
|
3828
3744
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3829
3745
|
const processedNodeInfo = {
|
3830
|
-
maxDepth:
|
3831
|
-
maxTx:
|
3832
|
-
minGasPrice:
|
3746
|
+
maxDepth: bn14(nodeInfo.maxDepth),
|
3747
|
+
maxTx: bn14(nodeInfo.maxTx),
|
3748
|
+
minGasPrice: bn14(nodeInfo.minGasPrice),
|
3833
3749
|
nodeVersion: nodeInfo.nodeVersion,
|
3834
3750
|
utxoValidation: nodeInfo.utxoValidation,
|
3835
3751
|
vmBacktrace: nodeInfo.vmBacktrace,
|
@@ -3859,6 +3775,17 @@ var _Provider = class {
|
|
3859
3775
|
} = this.getChain();
|
3860
3776
|
return chainId.toNumber();
|
3861
3777
|
}
|
3778
|
+
/**
|
3779
|
+
* Returns the base asset ID
|
3780
|
+
*
|
3781
|
+
* @returns A promise that resolves to the base asset ID
|
3782
|
+
*/
|
3783
|
+
getBaseAssetId() {
|
3784
|
+
const {
|
3785
|
+
consensusParameters: { baseAssetId }
|
3786
|
+
} = this.getChain();
|
3787
|
+
return baseAssetId;
|
3788
|
+
}
|
3862
3789
|
/**
|
3863
3790
|
* Submits a transaction to the chain to be executed.
|
3864
3791
|
*
|
@@ -3884,8 +3811,8 @@ var _Provider = class {
|
|
3884
3811
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3885
3812
|
for await (const { submitAndAwait } of subscription) {
|
3886
3813
|
if (submitAndAwait.type === "SqueezedOutStatus") {
|
3887
|
-
throw new
|
3888
|
-
|
3814
|
+
throw new FuelError12(
|
3815
|
+
ErrorCode12.TRANSACTION_SQUEEZED_OUT,
|
3889
3816
|
`Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
|
3890
3817
|
);
|
3891
3818
|
}
|
@@ -3952,7 +3879,7 @@ var _Provider = class {
|
|
3952
3879
|
} = response;
|
3953
3880
|
if (inputs) {
|
3954
3881
|
inputs.forEach((input, index) => {
|
3955
|
-
if ("predicateGasUsed" in input &&
|
3882
|
+
if ("predicateGasUsed" in input && bn14(input.predicateGasUsed).gt(0)) {
|
3956
3883
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
3957
3884
|
}
|
3958
3885
|
});
|
@@ -4065,7 +3992,7 @@ var _Provider = class {
|
|
4065
3992
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4066
3993
|
if (estimatePredicates) {
|
4067
3994
|
if (isScriptTransaction) {
|
4068
|
-
txRequestClone.gasLimit =
|
3995
|
+
txRequestClone.gasLimit = bn14(0);
|
4069
3996
|
}
|
4070
3997
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4071
3998
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4081,8 +4008,8 @@ var _Provider = class {
|
|
4081
4008
|
let missingContractIds = [];
|
4082
4009
|
let outputVariables = 0;
|
4083
4010
|
if (isScriptTransaction && estimateTxDependencies) {
|
4084
|
-
txRequestClone.gasPrice =
|
4085
|
-
txRequestClone.gasLimit =
|
4011
|
+
txRequestClone.gasPrice = bn14(0);
|
4012
|
+
txRequestClone.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
4086
4013
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4087
4014
|
receipts = result.receipts;
|
4088
4015
|
outputVariables = result.outputVariables;
|
@@ -4144,11 +4071,11 @@ var _Provider = class {
|
|
4144
4071
|
return coins.map((coin) => ({
|
4145
4072
|
id: coin.utxoId,
|
4146
4073
|
assetId: coin.assetId,
|
4147
|
-
amount:
|
4074
|
+
amount: bn14(coin.amount),
|
4148
4075
|
owner: Address2.fromAddressOrString(coin.owner),
|
4149
|
-
maturity:
|
4150
|
-
blockCreated:
|
4151
|
-
txCreatedIdx:
|
4076
|
+
maturity: bn14(coin.maturity).toNumber(),
|
4077
|
+
blockCreated: bn14(coin.blockCreated),
|
4078
|
+
txCreatedIdx: bn14(coin.txCreatedIdx)
|
4152
4079
|
}));
|
4153
4080
|
}
|
4154
4081
|
/**
|
@@ -4185,9 +4112,9 @@ var _Provider = class {
|
|
4185
4112
|
switch (coin.__typename) {
|
4186
4113
|
case "MessageCoin":
|
4187
4114
|
return {
|
4188
|
-
amount:
|
4115
|
+
amount: bn14(coin.amount),
|
4189
4116
|
assetId: coin.assetId,
|
4190
|
-
daHeight:
|
4117
|
+
daHeight: bn14(coin.daHeight),
|
4191
4118
|
sender: Address2.fromAddressOrString(coin.sender),
|
4192
4119
|
recipient: Address2.fromAddressOrString(coin.recipient),
|
4193
4120
|
nonce: coin.nonce
|
@@ -4195,12 +4122,12 @@ var _Provider = class {
|
|
4195
4122
|
case "Coin":
|
4196
4123
|
return {
|
4197
4124
|
id: coin.utxoId,
|
4198
|
-
amount:
|
4125
|
+
amount: bn14(coin.amount),
|
4199
4126
|
assetId: coin.assetId,
|
4200
4127
|
owner: Address2.fromAddressOrString(coin.owner),
|
4201
|
-
maturity:
|
4202
|
-
blockCreated:
|
4203
|
-
txCreatedIdx:
|
4128
|
+
maturity: bn14(coin.maturity).toNumber(),
|
4129
|
+
blockCreated: bn14(coin.blockCreated),
|
4130
|
+
txCreatedIdx: bn14(coin.txCreatedIdx)
|
4204
4131
|
};
|
4205
4132
|
default:
|
4206
4133
|
return null;
|
@@ -4217,13 +4144,13 @@ var _Provider = class {
|
|
4217
4144
|
async getBlock(idOrHeight) {
|
4218
4145
|
let variables;
|
4219
4146
|
if (typeof idOrHeight === "number") {
|
4220
|
-
variables = { height:
|
4147
|
+
variables = { height: bn14(idOrHeight).toString(10) };
|
4221
4148
|
} else if (idOrHeight === "latest") {
|
4222
4149
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4223
4150
|
} else if (idOrHeight.length === 66) {
|
4224
4151
|
variables = { blockId: idOrHeight };
|
4225
4152
|
} else {
|
4226
|
-
variables = { blockId:
|
4153
|
+
variables = { blockId: bn14(idOrHeight).toString(10) };
|
4227
4154
|
}
|
4228
4155
|
const { block } = await this.operations.getBlock(variables);
|
4229
4156
|
if (!block) {
|
@@ -4231,7 +4158,7 @@ var _Provider = class {
|
|
4231
4158
|
}
|
4232
4159
|
return {
|
4233
4160
|
id: block.id,
|
4234
|
-
height:
|
4161
|
+
height: bn14(block.header.height),
|
4235
4162
|
time: block.header.time,
|
4236
4163
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4237
4164
|
};
|
@@ -4246,7 +4173,7 @@ var _Provider = class {
|
|
4246
4173
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4247
4174
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4248
4175
|
id: block.id,
|
4249
|
-
height:
|
4176
|
+
height: bn14(block.header.height),
|
4250
4177
|
time: block.header.time,
|
4251
4178
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4252
4179
|
}));
|
@@ -4261,7 +4188,7 @@ var _Provider = class {
|
|
4261
4188
|
async getBlockWithTransactions(idOrHeight) {
|
4262
4189
|
let variables;
|
4263
4190
|
if (typeof idOrHeight === "number") {
|
4264
|
-
variables = { blockHeight:
|
4191
|
+
variables = { blockHeight: bn14(idOrHeight).toString(10) };
|
4265
4192
|
} else if (idOrHeight === "latest") {
|
4266
4193
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4267
4194
|
} else {
|
@@ -4273,7 +4200,7 @@ var _Provider = class {
|
|
4273
4200
|
}
|
4274
4201
|
return {
|
4275
4202
|
id: block.id,
|
4276
|
-
height:
|
4203
|
+
height: bn14(block.header.height, 10),
|
4277
4204
|
time: block.header.time,
|
4278
4205
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4279
4206
|
transactions: block.transactions.map(
|
@@ -4322,7 +4249,7 @@ var _Provider = class {
|
|
4322
4249
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
4323
4250
|
asset: hexlify12(assetId)
|
4324
4251
|
});
|
4325
|
-
return
|
4252
|
+
return bn14(contractBalance.amount, 10);
|
4326
4253
|
}
|
4327
4254
|
/**
|
4328
4255
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4336,7 +4263,7 @@ var _Provider = class {
|
|
4336
4263
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
4337
4264
|
assetId: hexlify12(assetId)
|
4338
4265
|
});
|
4339
|
-
return
|
4266
|
+
return bn14(balance.amount, 10);
|
4340
4267
|
}
|
4341
4268
|
/**
|
4342
4269
|
* Returns balances for the given owner.
|
@@ -4354,7 +4281,7 @@ var _Provider = class {
|
|
4354
4281
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4355
4282
|
return balances.map((balance) => ({
|
4356
4283
|
assetId: balance.assetId,
|
4357
|
-
amount:
|
4284
|
+
amount: bn14(balance.amount)
|
4358
4285
|
}));
|
4359
4286
|
}
|
4360
4287
|
/**
|
@@ -4376,15 +4303,15 @@ var _Provider = class {
|
|
4376
4303
|
sender: message.sender,
|
4377
4304
|
recipient: message.recipient,
|
4378
4305
|
nonce: message.nonce,
|
4379
|
-
amount:
|
4306
|
+
amount: bn14(message.amount),
|
4380
4307
|
data: message.data
|
4381
4308
|
}),
|
4382
4309
|
sender: Address2.fromAddressOrString(message.sender),
|
4383
4310
|
recipient: Address2.fromAddressOrString(message.recipient),
|
4384
4311
|
nonce: message.nonce,
|
4385
|
-
amount:
|
4312
|
+
amount: bn14(message.amount),
|
4386
4313
|
data: InputMessageCoder.decodeData(message.data),
|
4387
|
-
daHeight:
|
4314
|
+
daHeight: bn14(message.daHeight)
|
4388
4315
|
}));
|
4389
4316
|
}
|
4390
4317
|
/**
|
@@ -4402,8 +4329,8 @@ var _Provider = class {
|
|
4402
4329
|
nonce
|
4403
4330
|
};
|
4404
4331
|
if (commitBlockId && commitBlockHeight) {
|
4405
|
-
throw new
|
4406
|
-
|
4332
|
+
throw new FuelError12(
|
4333
|
+
ErrorCode12.INVALID_INPUT_PARAMETERS,
|
4407
4334
|
"commitBlockId and commitBlockHeight cannot be used together"
|
4408
4335
|
);
|
4409
4336
|
}
|
@@ -4437,41 +4364,41 @@ var _Provider = class {
|
|
4437
4364
|
} = result.messageProof;
|
4438
4365
|
return {
|
4439
4366
|
messageProof: {
|
4440
|
-
proofIndex:
|
4367
|
+
proofIndex: bn14(messageProof.proofIndex),
|
4441
4368
|
proofSet: messageProof.proofSet
|
4442
4369
|
},
|
4443
4370
|
blockProof: {
|
4444
|
-
proofIndex:
|
4371
|
+
proofIndex: bn14(blockProof.proofIndex),
|
4445
4372
|
proofSet: blockProof.proofSet
|
4446
4373
|
},
|
4447
4374
|
messageBlockHeader: {
|
4448
4375
|
id: messageBlockHeader.id,
|
4449
|
-
daHeight:
|
4450
|
-
transactionsCount:
|
4376
|
+
daHeight: bn14(messageBlockHeader.daHeight),
|
4377
|
+
transactionsCount: bn14(messageBlockHeader.transactionsCount),
|
4451
4378
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4452
|
-
height:
|
4379
|
+
height: bn14(messageBlockHeader.height),
|
4453
4380
|
prevRoot: messageBlockHeader.prevRoot,
|
4454
4381
|
time: messageBlockHeader.time,
|
4455
4382
|
applicationHash: messageBlockHeader.applicationHash,
|
4456
4383
|
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4457
|
-
messageReceiptCount:
|
4384
|
+
messageReceiptCount: bn14(messageBlockHeader.messageReceiptCount)
|
4458
4385
|
},
|
4459
4386
|
commitBlockHeader: {
|
4460
4387
|
id: commitBlockHeader.id,
|
4461
|
-
daHeight:
|
4462
|
-
transactionsCount:
|
4388
|
+
daHeight: bn14(commitBlockHeader.daHeight),
|
4389
|
+
transactionsCount: bn14(commitBlockHeader.transactionsCount),
|
4463
4390
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4464
|
-
height:
|
4391
|
+
height: bn14(commitBlockHeader.height),
|
4465
4392
|
prevRoot: commitBlockHeader.prevRoot,
|
4466
4393
|
time: commitBlockHeader.time,
|
4467
4394
|
applicationHash: commitBlockHeader.applicationHash,
|
4468
4395
|
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4469
|
-
messageReceiptCount:
|
4396
|
+
messageReceiptCount: bn14(commitBlockHeader.messageReceiptCount)
|
4470
4397
|
},
|
4471
4398
|
sender: Address2.fromAddressOrString(sender),
|
4472
4399
|
recipient: Address2.fromAddressOrString(recipient),
|
4473
4400
|
nonce,
|
4474
|
-
amount:
|
4401
|
+
amount: bn14(amount),
|
4475
4402
|
data
|
4476
4403
|
};
|
4477
4404
|
}
|
@@ -4494,10 +4421,10 @@ var _Provider = class {
|
|
4494
4421
|
*/
|
4495
4422
|
async produceBlocks(amount, startTime) {
|
4496
4423
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4497
|
-
blocksToProduce:
|
4424
|
+
blocksToProduce: bn14(amount).toString(10),
|
4498
4425
|
startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4499
4426
|
});
|
4500
|
-
return
|
4427
|
+
return bn14(latestBlockHeight);
|
4501
4428
|
}
|
4502
4429
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4503
4430
|
async getTransactionResponse(transactionId) {
|
@@ -4520,8 +4447,8 @@ __publicField(Provider, "chainInfoCache", {});
|
|
4520
4447
|
__publicField(Provider, "nodeInfoCache", {});
|
4521
4448
|
|
4522
4449
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4523
|
-
import { ErrorCode as
|
4524
|
-
import { bn as
|
4450
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
|
4451
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
4525
4452
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
4526
4453
|
import { arrayify as arrayify12 } from "@fuel-ts/utils";
|
4527
4454
|
async function getTransactionSummary(params) {
|
@@ -4530,8 +4457,8 @@ async function getTransactionSummary(params) {
|
|
4530
4457
|
transactionId: id
|
4531
4458
|
});
|
4532
4459
|
if (!gqlTransaction) {
|
4533
|
-
throw new
|
4534
|
-
|
4460
|
+
throw new FuelError13(
|
4461
|
+
ErrorCode13.TRANSACTION_NOT_FOUND,
|
4535
4462
|
`Transaction not found for given id: ${id}.`
|
4536
4463
|
);
|
4537
4464
|
}
|
@@ -4549,8 +4476,8 @@ async function getTransactionSummary(params) {
|
|
4549
4476
|
transaction: decodedTransaction,
|
4550
4477
|
transactionBytes: arrayify12(gqlTransaction.rawPayload),
|
4551
4478
|
gqlTransactionStatus: gqlTransaction.status,
|
4552
|
-
gasPerByte:
|
4553
|
-
gasPriceFactor:
|
4479
|
+
gasPerByte: bn15(gasPerByte),
|
4480
|
+
gasPriceFactor: bn15(gasPriceFactor),
|
4554
4481
|
abiMap,
|
4555
4482
|
maxInputs,
|
4556
4483
|
gasCosts
|
@@ -4804,7 +4731,7 @@ var Account = class extends AbstractAccount {
|
|
4804
4731
|
*/
|
4805
4732
|
get provider() {
|
4806
4733
|
if (!this._provider) {
|
4807
|
-
throw new
|
4734
|
+
throw new FuelError14(ErrorCode14.MISSING_PROVIDER, "Provider not set");
|
4808
4735
|
}
|
4809
4736
|
return this._provider;
|
4810
4737
|
}
|
@@ -4856,8 +4783,8 @@ var Account = class extends AbstractAccount {
|
|
4856
4783
|
if (!hasNextPage) {
|
4857
4784
|
break;
|
4858
4785
|
}
|
4859
|
-
throw new
|
4860
|
-
|
4786
|
+
throw new FuelError14(
|
4787
|
+
ErrorCode14.NOT_SUPPORTED,
|
4861
4788
|
`Wallets containing more than ${pageSize} coins exceed the current supported limit.`
|
4862
4789
|
);
|
4863
4790
|
}
|
@@ -4882,8 +4809,8 @@ var Account = class extends AbstractAccount {
|
|
4882
4809
|
if (!hasNextPage) {
|
4883
4810
|
break;
|
4884
4811
|
}
|
4885
|
-
throw new
|
4886
|
-
|
4812
|
+
throw new FuelError14(
|
4813
|
+
ErrorCode14.NOT_SUPPORTED,
|
4887
4814
|
`Wallets containing more than ${pageSize} messages exceed the current supported limit.`
|
4888
4815
|
);
|
4889
4816
|
}
|
@@ -4895,8 +4822,9 @@ var Account = class extends AbstractAccount {
|
|
4895
4822
|
* @param assetId - The asset ID to check the balance for.
|
4896
4823
|
* @returns A promise that resolves to the balance amount.
|
4897
4824
|
*/
|
4898
|
-
async getBalance(assetId
|
4899
|
-
const
|
4825
|
+
async getBalance(assetId) {
|
4826
|
+
const assetIdToFetch = assetId ?? this.provider.getBaseAssetId();
|
4827
|
+
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
4900
4828
|
return amount;
|
4901
4829
|
}
|
4902
4830
|
/**
|
@@ -4918,8 +4846,8 @@ var Account = class extends AbstractAccount {
|
|
4918
4846
|
if (!hasNextPage) {
|
4919
4847
|
break;
|
4920
4848
|
}
|
4921
|
-
throw new
|
4922
|
-
|
4849
|
+
throw new FuelError14(
|
4850
|
+
ErrorCode14.NOT_SUPPORTED,
|
4923
4851
|
`Wallets containing more than ${pageSize} balances exceed the current supported limit.`
|
4924
4852
|
);
|
4925
4853
|
}
|
@@ -4934,16 +4862,17 @@ var Account = class extends AbstractAccount {
|
|
4934
4862
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4935
4863
|
*/
|
4936
4864
|
async fund(request, coinQuantities, fee) {
|
4865
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
4937
4866
|
const updatedQuantities = addAmountToAsset({
|
4938
|
-
amount:
|
4939
|
-
assetId:
|
4867
|
+
amount: bn16(fee),
|
4868
|
+
assetId: baseAssetId,
|
4940
4869
|
coinQuantities
|
4941
4870
|
});
|
4942
4871
|
const quantitiesDict = {};
|
4943
4872
|
updatedQuantities.forEach(({ amount, assetId }) => {
|
4944
4873
|
quantitiesDict[assetId] = {
|
4945
4874
|
required: amount,
|
4946
|
-
owned:
|
4875
|
+
owned: bn16(0)
|
4947
4876
|
};
|
4948
4877
|
});
|
4949
4878
|
const cachedUtxos = [];
|
@@ -4956,12 +4885,12 @@ var Account = class extends AbstractAccount {
|
|
4956
4885
|
if (isCoin2) {
|
4957
4886
|
const assetId = String(input.assetId);
|
4958
4887
|
if (input.owner === owner && quantitiesDict[assetId]) {
|
4959
|
-
const amount =
|
4888
|
+
const amount = bn16(input.amount);
|
4960
4889
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
4961
4890
|
cachedUtxos.push(input.id);
|
4962
4891
|
}
|
4963
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
4964
|
-
quantitiesDict[
|
4892
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[baseAssetId]) {
|
4893
|
+
quantitiesDict[baseAssetId].owned = quantitiesDict[baseAssetId].owned.add(input.amount);
|
4965
4894
|
cachedMessages.push(input.nonce);
|
4966
4895
|
}
|
4967
4896
|
}
|
@@ -4993,17 +4922,18 @@ var Account = class extends AbstractAccount {
|
|
4993
4922
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
4994
4923
|
* @returns A promise that resolves to the prepared transaction request.
|
4995
4924
|
*/
|
4996
|
-
async createTransfer(destination, amount, assetId
|
4925
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
4997
4926
|
const { minGasPrice } = this.provider.getGasConfig();
|
4927
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4998
4928
|
const params = { gasPrice: minGasPrice, ...txParams };
|
4999
4929
|
const request = new ScriptTransactionRequest(params);
|
5000
|
-
request.addCoinOutput(Address3.fromAddressOrString(destination), amount,
|
4930
|
+
request.addCoinOutput(Address3.fromAddressOrString(destination), amount, assetIdToTransfer);
|
5001
4931
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
5002
4932
|
estimateTxDependencies: true,
|
5003
4933
|
resourcesOwner: this
|
5004
4934
|
});
|
5005
|
-
request.gasPrice =
|
5006
|
-
request.gasLimit =
|
4935
|
+
request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
|
4936
|
+
request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
|
5007
4937
|
this.validateGas({
|
5008
4938
|
gasUsed,
|
5009
4939
|
gasPrice: request.gasPrice,
|
@@ -5023,14 +4953,15 @@ var Account = class extends AbstractAccount {
|
|
5023
4953
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
5024
4954
|
* @returns A promise that resolves to the transaction response.
|
5025
4955
|
*/
|
5026
|
-
async transfer(destination, amount, assetId
|
5027
|
-
if (
|
5028
|
-
throw new
|
5029
|
-
|
4956
|
+
async transfer(destination, amount, assetId, txParams = {}) {
|
4957
|
+
if (bn16(amount).lte(0)) {
|
4958
|
+
throw new FuelError14(
|
4959
|
+
ErrorCode14.INVALID_TRANSFER_AMOUNT,
|
5030
4960
|
"Transfer amount must be a positive number."
|
5031
4961
|
);
|
5032
4962
|
}
|
5033
|
-
const
|
4963
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
4964
|
+
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
5034
4965
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
5035
4966
|
}
|
5036
4967
|
/**
|
@@ -5042,20 +4973,21 @@ var Account = class extends AbstractAccount {
|
|
5042
4973
|
* @param txParams - The optional transaction parameters.
|
5043
4974
|
* @returns A promise that resolves to the transaction response.
|
5044
4975
|
*/
|
5045
|
-
async transferToContract(contractId, amount, assetId
|
5046
|
-
if (
|
5047
|
-
throw new
|
5048
|
-
|
4976
|
+
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
4977
|
+
if (bn16(amount).lte(0)) {
|
4978
|
+
throw new FuelError14(
|
4979
|
+
ErrorCode14.INVALID_TRANSFER_AMOUNT,
|
5049
4980
|
"Transfer amount must be a positive number."
|
5050
4981
|
);
|
5051
4982
|
}
|
5052
4983
|
const contractAddress = Address3.fromAddressOrString(contractId);
|
5053
4984
|
const { minGasPrice } = this.provider.getGasConfig();
|
4985
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5054
4986
|
const params = { gasPrice: minGasPrice, ...txParams };
|
5055
4987
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5056
4988
|
hexlifiedContractId: contractAddress.toB256(),
|
5057
|
-
amountToTransfer:
|
5058
|
-
assetId
|
4989
|
+
amountToTransfer: bn16(amount),
|
4990
|
+
assetId: assetIdToTransfer
|
5059
4991
|
});
|
5060
4992
|
const request = new ScriptTransactionRequest({
|
5061
4993
|
...params,
|
@@ -5065,9 +4997,9 @@ var Account = class extends AbstractAccount {
|
|
5065
4997
|
request.addContractInputAndOutput(contractAddress);
|
5066
4998
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
5067
4999
|
request,
|
5068
|
-
[{ amount:
|
5000
|
+
[{ amount: bn16(amount), assetId: String(assetIdToTransfer) }]
|
5069
5001
|
);
|
5070
|
-
request.gasLimit =
|
5002
|
+
request.gasLimit = bn16(params.gasLimit ?? gasUsed);
|
5071
5003
|
this.validateGas({
|
5072
5004
|
gasUsed,
|
5073
5005
|
gasPrice: request.gasPrice,
|
@@ -5087,12 +5019,13 @@ var Account = class extends AbstractAccount {
|
|
5087
5019
|
*/
|
5088
5020
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5089
5021
|
const { minGasPrice } = this.provider.getGasConfig();
|
5022
|
+
const baseAssetId = this.provider.getBaseAssetId();
|
5090
5023
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
5091
5024
|
const recipientDataArray = arrayify14(
|
5092
5025
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5093
5026
|
);
|
5094
5027
|
const amountDataArray = arrayify14(
|
5095
|
-
"0x".concat(
|
5028
|
+
"0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
|
5096
5029
|
);
|
5097
5030
|
const script = new Uint8Array([
|
5098
5031
|
...arrayify14(withdrawScript.bytes),
|
@@ -5101,12 +5034,12 @@ var Account = class extends AbstractAccount {
|
|
5101
5034
|
]);
|
5102
5035
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
5103
5036
|
const request = new ScriptTransactionRequest(params);
|
5104
|
-
const forwardingQuantities = [{ amount:
|
5037
|
+
const forwardingQuantities = [{ amount: bn16(amount), assetId: baseAssetId }];
|
5105
5038
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
5106
5039
|
request,
|
5107
5040
|
forwardingQuantities
|
5108
5041
|
);
|
5109
|
-
request.gasLimit =
|
5042
|
+
request.gasLimit = bn16(params.gasLimit ?? gasUsed);
|
5110
5043
|
this.validateGas({
|
5111
5044
|
gasUsed,
|
5112
5045
|
gasPrice: request.gasPrice,
|
@@ -5118,7 +5051,7 @@ var Account = class extends AbstractAccount {
|
|
5118
5051
|
}
|
5119
5052
|
async signMessage(message) {
|
5120
5053
|
if (!this._connector) {
|
5121
|
-
throw new
|
5054
|
+
throw new FuelError14(ErrorCode14.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
5122
5055
|
}
|
5123
5056
|
return this._connector.signMessage(this.address.toString(), message);
|
5124
5057
|
}
|
@@ -5130,8 +5063,8 @@ var Account = class extends AbstractAccount {
|
|
5130
5063
|
*/
|
5131
5064
|
async signTransaction(transactionRequestLike) {
|
5132
5065
|
if (!this._connector) {
|
5133
|
-
throw new
|
5134
|
-
|
5066
|
+
throw new FuelError14(
|
5067
|
+
ErrorCode14.MISSING_CONNECTOR,
|
5135
5068
|
"A connector is required to sign transactions."
|
5136
5069
|
);
|
5137
5070
|
}
|
@@ -5178,14 +5111,14 @@ var Account = class extends AbstractAccount {
|
|
5178
5111
|
minGasPrice
|
5179
5112
|
}) {
|
5180
5113
|
if (minGasPrice.gt(gasPrice)) {
|
5181
|
-
throw new
|
5182
|
-
|
5114
|
+
throw new FuelError14(
|
5115
|
+
ErrorCode14.GAS_PRICE_TOO_LOW,
|
5183
5116
|
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
5184
5117
|
);
|
5185
5118
|
}
|
5186
5119
|
if (gasUsed.gt(gasLimit)) {
|
5187
|
-
throw new
|
5188
|
-
|
5120
|
+
throw new FuelError14(
|
5121
|
+
ErrorCode14.GAS_LIMIT_TOO_LOW,
|
5189
5122
|
`Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
|
5190
5123
|
);
|
5191
5124
|
}
|
@@ -5316,7 +5249,7 @@ import {
|
|
5316
5249
|
decryptJsonWalletData,
|
5317
5250
|
encryptJsonWalletData
|
5318
5251
|
} from "@fuel-ts/crypto";
|
5319
|
-
import { ErrorCode as
|
5252
|
+
import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
|
5320
5253
|
import { hexlify as hexlify14 } from "@fuel-ts/utils";
|
5321
5254
|
import { v4 as uuidv4 } from "uuid";
|
5322
5255
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
@@ -5394,8 +5327,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5394
5327
|
const macHashUint8Array = keccak256(data);
|
5395
5328
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
5396
5329
|
if (mac !== macHash) {
|
5397
|
-
throw new
|
5398
|
-
|
5330
|
+
throw new FuelError15(
|
5331
|
+
ErrorCode15.INVALID_PASSWORD,
|
5399
5332
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
5400
5333
|
);
|
5401
5334
|
}
|
@@ -5517,15 +5450,15 @@ var BaseWalletUnlocked = class extends Account {
|
|
5517
5450
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5518
5451
|
|
5519
5452
|
// src/hdwallet/hdwallet.ts
|
5520
|
-
import { ErrorCode as
|
5453
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
|
5521
5454
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
5522
|
-
import { bn as
|
5455
|
+
import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
5523
5456
|
import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
|
5524
5457
|
import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
|
5525
5458
|
|
5526
5459
|
// src/mnemonic/mnemonic.ts
|
5527
5460
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
5528
|
-
import { ErrorCode as
|
5461
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
|
5529
5462
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
5530
5463
|
import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
|
5531
5464
|
import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
|
@@ -7589,7 +7522,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
7589
7522
|
})(Language || {});
|
7590
7523
|
|
7591
7524
|
// src/mnemonic/utils.ts
|
7592
|
-
import { ErrorCode as
|
7525
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
|
7593
7526
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
7594
7527
|
import { arrayify as arrayify16 } from "@fuel-ts/utils";
|
7595
7528
|
function toUtf8Bytes(stri) {
|
@@ -7606,8 +7539,8 @@ function toUtf8Bytes(stri) {
|
|
7606
7539
|
i += 1;
|
7607
7540
|
const c2 = str.charCodeAt(i);
|
7608
7541
|
if (i >= str.length || (c2 & 64512) !== 56320) {
|
7609
|
-
throw new
|
7610
|
-
|
7542
|
+
throw new FuelError16(
|
7543
|
+
ErrorCode16.INVALID_INPUT_PARAMETERS,
|
7611
7544
|
"Invalid UTF-8 in the input string."
|
7612
7545
|
);
|
7613
7546
|
}
|
@@ -7670,8 +7603,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7670
7603
|
for (let i = 0; i < words.length; i += 1) {
|
7671
7604
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
7672
7605
|
if (index === -1) {
|
7673
|
-
throw new
|
7674
|
-
|
7606
|
+
throw new FuelError16(
|
7607
|
+
ErrorCode16.INVALID_MNEMONIC,
|
7675
7608
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
7676
7609
|
);
|
7677
7610
|
}
|
@@ -7687,8 +7620,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7687
7620
|
const checksumMask = getUpperMask(checksumBits);
|
7688
7621
|
const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7689
7622
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7690
|
-
throw new
|
7691
|
-
|
7623
|
+
throw new FuelError16(
|
7624
|
+
ErrorCode16.INVALID_CHECKSUM,
|
7692
7625
|
"Checksum validation failed for the provided mnemonic."
|
7693
7626
|
);
|
7694
7627
|
}
|
@@ -7702,16 +7635,16 @@ var TestnetPRV = "0x04358394";
|
|
7702
7635
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
7703
7636
|
function assertWordList(wordlist) {
|
7704
7637
|
if (wordlist.length !== 2048) {
|
7705
|
-
throw new
|
7706
|
-
|
7638
|
+
throw new FuelError17(
|
7639
|
+
ErrorCode17.INVALID_WORD_LIST,
|
7707
7640
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
7708
7641
|
);
|
7709
7642
|
}
|
7710
7643
|
}
|
7711
7644
|
function assertEntropy(entropy) {
|
7712
7645
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
7713
|
-
throw new
|
7714
|
-
|
7646
|
+
throw new FuelError17(
|
7647
|
+
ErrorCode17.INVALID_ENTROPY,
|
7715
7648
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
7716
7649
|
);
|
7717
7650
|
}
|
@@ -7721,7 +7654,7 @@ function assertMnemonic(words) {
|
|
7721
7654
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
7722
7655
|
", "
|
7723
7656
|
)}] words, but got ${words.length}.`;
|
7724
|
-
throw new
|
7657
|
+
throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
|
7725
7658
|
}
|
7726
7659
|
}
|
7727
7660
|
var Mnemonic = class {
|
@@ -7839,8 +7772,8 @@ var Mnemonic = class {
|
|
7839
7772
|
static masterKeysFromSeed(seed) {
|
7840
7773
|
const seedArray = arrayify17(seed);
|
7841
7774
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7842
|
-
throw new
|
7843
|
-
|
7775
|
+
throw new FuelError17(
|
7776
|
+
ErrorCode17.INVALID_SEED,
|
7844
7777
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7845
7778
|
);
|
7846
7779
|
}
|
@@ -7917,7 +7850,7 @@ function isValidExtendedKey(extendedKey) {
|
|
7917
7850
|
function parsePath(path, depth = 0) {
|
7918
7851
|
const components = path.split("/");
|
7919
7852
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
7920
|
-
throw new
|
7853
|
+
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, `invalid path - ${path}`);
|
7921
7854
|
}
|
7922
7855
|
if (components[0] === "m") {
|
7923
7856
|
components.shift();
|
@@ -7946,8 +7879,8 @@ var HDWallet = class {
|
|
7946
7879
|
this.privateKey = hexlify17(config.privateKey);
|
7947
7880
|
} else {
|
7948
7881
|
if (!config.publicKey) {
|
7949
|
-
throw new
|
7950
|
-
|
7882
|
+
throw new FuelError18(
|
7883
|
+
ErrorCode18.HD_WALLET_ERROR,
|
7951
7884
|
"Both public and private Key cannot be missing. At least one should be provided."
|
7952
7885
|
);
|
7953
7886
|
}
|
@@ -7976,8 +7909,8 @@ var HDWallet = class {
|
|
7976
7909
|
const data = new Uint8Array(37);
|
7977
7910
|
if (index & HARDENED_INDEX) {
|
7978
7911
|
if (!privateKey) {
|
7979
|
-
throw new
|
7980
|
-
|
7912
|
+
throw new FuelError18(
|
7913
|
+
ErrorCode18.HD_WALLET_ERROR,
|
7981
7914
|
"Cannot derive a hardened index without a private Key."
|
7982
7915
|
);
|
7983
7916
|
}
|
@@ -7991,7 +7924,7 @@ var HDWallet = class {
|
|
7991
7924
|
const IR = bytes.slice(32);
|
7992
7925
|
if (privateKey) {
|
7993
7926
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
7994
|
-
const ki =
|
7927
|
+
const ki = bn17(IL).add(privateKey).mod(N).toBytes(32);
|
7995
7928
|
return new HDWallet({
|
7996
7929
|
privateKey: ki,
|
7997
7930
|
chainCode: IR,
|
@@ -8029,8 +7962,8 @@ var HDWallet = class {
|
|
8029
7962
|
*/
|
8030
7963
|
toExtendedKey(isPublic = false, testnet = false) {
|
8031
7964
|
if (this.depth >= 256) {
|
8032
|
-
throw new
|
8033
|
-
|
7965
|
+
throw new FuelError18(
|
7966
|
+
ErrorCode18.HD_WALLET_ERROR,
|
8034
7967
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
8035
7968
|
);
|
8036
7969
|
}
|
@@ -8061,10 +7994,10 @@ var HDWallet = class {
|
|
8061
7994
|
const bytes = arrayify18(decoded);
|
8062
7995
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8063
7996
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8064
|
-
throw new
|
7997
|
+
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
8065
7998
|
}
|
8066
7999
|
if (!validChecksum) {
|
8067
|
-
throw new
|
8000
|
+
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8068
8001
|
}
|
8069
8002
|
const depth = bytes[4];
|
8070
8003
|
const parentFingerprint = hexlify17(bytes.slice(5, 9));
|
@@ -8072,14 +8005,14 @@ var HDWallet = class {
|
|
8072
8005
|
const chainCode = hexlify17(bytes.slice(13, 45));
|
8073
8006
|
const key = bytes.slice(45, 78);
|
8074
8007
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8075
|
-
throw new
|
8076
|
-
|
8008
|
+
throw new FuelError18(
|
8009
|
+
ErrorCode18.HD_WALLET_ERROR,
|
8077
8010
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
8078
8011
|
);
|
8079
8012
|
}
|
8080
8013
|
if (isPublicExtendedKey(bytes)) {
|
8081
8014
|
if (key[0] !== 3) {
|
8082
|
-
throw new
|
8015
|
+
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
|
8083
8016
|
}
|
8084
8017
|
return new HDWallet({
|
8085
8018
|
publicKey: key,
|
@@ -8090,7 +8023,7 @@ var HDWallet = class {
|
|
8090
8023
|
});
|
8091
8024
|
}
|
8092
8025
|
if (key[0] !== 0) {
|
8093
|
-
throw new
|
8026
|
+
throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
|
8094
8027
|
}
|
8095
8028
|
return new HDWallet({
|
8096
8029
|
privateKey: key.slice(1),
|
@@ -8258,7 +8191,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
8258
8191
|
// src/wallet-manager/wallet-manager.ts
|
8259
8192
|
import { Address as Address8 } from "@fuel-ts/address";
|
8260
8193
|
import { encrypt, decrypt } from "@fuel-ts/crypto";
|
8261
|
-
import { ErrorCode as
|
8194
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError21 } from "@fuel-ts/errors";
|
8262
8195
|
import { EventEmitter } from "events";
|
8263
8196
|
|
8264
8197
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -8281,7 +8214,7 @@ var MemoryStorage = class {
|
|
8281
8214
|
|
8282
8215
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
8283
8216
|
import { Address as Address6 } from "@fuel-ts/address";
|
8284
|
-
import { ErrorCode as
|
8217
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
|
8285
8218
|
var _secret;
|
8286
8219
|
var MnemonicVault = class {
|
8287
8220
|
constructor(options) {
|
@@ -8337,8 +8270,8 @@ var MnemonicVault = class {
|
|
8337
8270
|
}
|
8338
8271
|
numberOfAccounts += 1;
|
8339
8272
|
} while (numberOfAccounts < this.numberOfAccounts);
|
8340
|
-
throw new
|
8341
|
-
|
8273
|
+
throw new FuelError19(
|
8274
|
+
ErrorCode19.WALLET_MANAGER_ERROR,
|
8342
8275
|
`Account with address '${address}' not found in derived wallets.`
|
8343
8276
|
);
|
8344
8277
|
}
|
@@ -8352,7 +8285,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
8352
8285
|
|
8353
8286
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
8354
8287
|
import { Address as Address7 } from "@fuel-ts/address";
|
8355
|
-
import { ErrorCode as
|
8288
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError20 } from "@fuel-ts/errors";
|
8356
8289
|
var _privateKeys;
|
8357
8290
|
var PrivateKeyVault = class {
|
8358
8291
|
/**
|
@@ -8393,8 +8326,8 @@ var PrivateKeyVault = class {
|
|
8393
8326
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
8394
8327
|
);
|
8395
8328
|
if (!privateKey) {
|
8396
|
-
throw new
|
8397
|
-
|
8329
|
+
throw new FuelError20(
|
8330
|
+
ErrorCode20.WALLET_MANAGER_ERROR,
|
8398
8331
|
`No private key found for address '${address}'.`
|
8399
8332
|
);
|
8400
8333
|
}
|
@@ -8418,7 +8351,7 @@ var ERROR_MESSAGES = {
|
|
8418
8351
|
};
|
8419
8352
|
function assert(condition, message) {
|
8420
8353
|
if (!condition) {
|
8421
|
-
throw new
|
8354
|
+
throw new FuelError21(ErrorCode21.WALLET_MANAGER_ERROR, message);
|
8422
8355
|
}
|
8423
8356
|
}
|
8424
8357
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -8644,25 +8577,25 @@ deserializeVaults_fn = function(vaults) {
|
|
8644
8577
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
8645
8578
|
|
8646
8579
|
// src/wallet-manager/types.ts
|
8647
|
-
import { ErrorCode as
|
8580
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError22 } from "@fuel-ts/errors";
|
8648
8581
|
var Vault = class {
|
8649
8582
|
constructor(_options) {
|
8650
|
-
throw new
|
8583
|
+
throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
|
8651
8584
|
}
|
8652
8585
|
serialize() {
|
8653
|
-
throw new
|
8586
|
+
throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
|
8654
8587
|
}
|
8655
8588
|
getAccounts() {
|
8656
|
-
throw new
|
8589
|
+
throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
|
8657
8590
|
}
|
8658
8591
|
addAccount() {
|
8659
|
-
throw new
|
8592
|
+
throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
|
8660
8593
|
}
|
8661
8594
|
exportAccount(_address) {
|
8662
|
-
throw new
|
8595
|
+
throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
|
8663
8596
|
}
|
8664
8597
|
getWallet(_address) {
|
8665
|
-
throw new
|
8598
|
+
throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
|
8666
8599
|
}
|
8667
8600
|
};
|
8668
8601
|
__publicField(Vault, "type");
|
@@ -8678,8 +8611,7 @@ import {
|
|
8678
8611
|
SCRIPT_FIXED_SIZE
|
8679
8612
|
} from "@fuel-ts/abi-coder";
|
8680
8613
|
import { Address as Address9 } from "@fuel-ts/address";
|
8681
|
-
import {
|
8682
|
-
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8614
|
+
import { ErrorCode as ErrorCode23, FuelError as FuelError23 } from "@fuel-ts/errors";
|
8683
8615
|
import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
|
8684
8616
|
import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
|
8685
8617
|
|
@@ -8757,8 +8689,9 @@ var Predicate = class extends Account {
|
|
8757
8689
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
8758
8690
|
* @returns A promise that resolves to the prepared transaction request.
|
8759
8691
|
*/
|
8760
|
-
async createTransfer(destination, amount, assetId
|
8761
|
-
const
|
8692
|
+
async createTransfer(destination, amount, assetId, txParams = {}) {
|
8693
|
+
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
8694
|
+
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
8762
8695
|
return this.populateTransactionPredicateData(request);
|
8763
8696
|
}
|
8764
8697
|
/**
|
@@ -8807,8 +8740,8 @@ var Predicate = class extends Account {
|
|
8807
8740
|
if (jsonAbi) {
|
8808
8741
|
abiInterface = new Interface4(jsonAbi);
|
8809
8742
|
if (abiInterface.functions.main === void 0) {
|
8810
|
-
throw new
|
8811
|
-
|
8743
|
+
throw new FuelError23(
|
8744
|
+
ErrorCode23.ABI_MAIN_METHOD_MISSING,
|
8812
8745
|
'Cannot use ABI without "main" function.'
|
8813
8746
|
);
|
8814
8747
|
}
|
@@ -8853,8 +8786,8 @@ var Predicate = class extends Account {
|
|
8853
8786
|
mutatedBytes.set(encoded, offset);
|
8854
8787
|
});
|
8855
8788
|
} catch (err) {
|
8856
|
-
throw new
|
8857
|
-
|
8789
|
+
throw new FuelError23(
|
8790
|
+
ErrorCode23.INVALID_CONFIGURABLE_CONSTANTS,
|
8858
8791
|
`Error setting configurable constants: ${err.message}.`
|
8859
8792
|
);
|
8860
8793
|
}
|
@@ -8863,7 +8796,7 @@ var Predicate = class extends Account {
|
|
8863
8796
|
};
|
8864
8797
|
|
8865
8798
|
// src/connectors/fuel.ts
|
8866
|
-
import { ErrorCode as
|
8799
|
+
import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
|
8867
8800
|
|
8868
8801
|
// src/connectors/fuel-connector.ts
|
8869
8802
|
import { EventEmitter as EventEmitter2 } from "events";
|
@@ -9496,7 +9429,7 @@ var _Fuel = class extends FuelConnector {
|
|
9496
9429
|
const currentNetwork = await this.currentNetwork();
|
9497
9430
|
provider = await Provider.create(currentNetwork.url);
|
9498
9431
|
} else {
|
9499
|
-
throw new
|
9432
|
+
throw new FuelError24(ErrorCode24.INVALID_PROVIDER, "Provider is not valid.");
|
9500
9433
|
}
|
9501
9434
|
return provider;
|
9502
9435
|
}
|
@@ -9575,9 +9508,7 @@ export {
|
|
9575
9508
|
WalletUnlocked,
|
9576
9509
|
addAmountToAsset,
|
9577
9510
|
addOperation,
|
9578
|
-
assemblePanicError,
|
9579
9511
|
assembleReceiptByType,
|
9580
|
-
assembleRevertError,
|
9581
9512
|
assembleTransactionSummary,
|
9582
9513
|
assets,
|
9583
9514
|
buildBlockExplorerUrl,
|
@@ -9592,7 +9523,6 @@ export {
|
|
9592
9523
|
english,
|
9593
9524
|
extractBurnedAssetsFromReceipts,
|
9594
9525
|
extractMintedAssetsFromReceipts,
|
9595
|
-
extractTxError,
|
9596
9526
|
gasUsedByInputs,
|
9597
9527
|
getAssetEth,
|
9598
9528
|
getAssetFuel,
|