@fuel-ts/account 0.0.0-rc-1976-20240403225009 → 0.0.0-rc-1895-20240404023124
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 +171 -63
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +578 -513
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +356 -286
- 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 +0 -7
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -5
- 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/extract-tx-error.d.ts +36 -0
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
- package/dist/providers/utils/index.d.ts +1 -0
- 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 +172 -65
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +537 -479
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +326 -260
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.js
CHANGED
@@ -88,7 +88,7 @@ __export(src_exports, {
|
|
88
88
|
StorageAbstract: () => StorageAbstract,
|
89
89
|
TransactionResponse: () => TransactionResponse,
|
90
90
|
TransactionStatus: () => TransactionStatus,
|
91
|
-
TransactionType: () =>
|
91
|
+
TransactionType: () => import_transactions6.TransactionType,
|
92
92
|
TransactionTypeName: () => TransactionTypeName,
|
93
93
|
Vault: () => Vault,
|
94
94
|
Wallet: () => Wallet,
|
@@ -97,7 +97,9 @@ __export(src_exports, {
|
|
97
97
|
WalletUnlocked: () => WalletUnlocked,
|
98
98
|
addAmountToAsset: () => addAmountToAsset,
|
99
99
|
addOperation: () => addOperation,
|
100
|
+
assemblePanicError: () => assemblePanicError,
|
100
101
|
assembleReceiptByType: () => assembleReceiptByType,
|
102
|
+
assembleRevertError: () => assembleRevertError,
|
101
103
|
assembleTransactionSummary: () => assembleTransactionSummary,
|
102
104
|
assets: () => assets,
|
103
105
|
buildBlockExplorerUrl: () => buildBlockExplorerUrl,
|
@@ -112,6 +114,7 @@ __export(src_exports, {
|
|
112
114
|
english: () => english,
|
113
115
|
extractBurnedAssetsFromReceipts: () => extractBurnedAssetsFromReceipts,
|
114
116
|
extractMintedAssetsFromReceipts: () => extractMintedAssetsFromReceipts,
|
117
|
+
extractTxError: () => extractTxError,
|
115
118
|
gasUsedByInputs: () => gasUsedByInputs,
|
116
119
|
getAssetEth: () => getAssetEth,
|
117
120
|
getAssetFuel: () => getAssetFuel,
|
@@ -181,12 +184,14 @@ module.exports = __toCommonJS(src_exports);
|
|
181
184
|
|
182
185
|
// src/account.ts
|
183
186
|
var import_address4 = require("@fuel-ts/address");
|
184
|
-
var
|
187
|
+
var import_configs12 = require("@fuel-ts/address/configs");
|
188
|
+
var import_errors16 = require("@fuel-ts/errors");
|
185
189
|
var import_interfaces = require("@fuel-ts/interfaces");
|
186
|
-
var
|
187
|
-
var
|
190
|
+
var import_math18 = require("@fuel-ts/math");
|
191
|
+
var import_utils28 = require("@fuel-ts/utils");
|
188
192
|
|
189
193
|
// src/providers/coin-quantity.ts
|
194
|
+
var import_configs = require("@fuel-ts/address/configs");
|
190
195
|
var import_math = require("@fuel-ts/math");
|
191
196
|
var import_utils = require("@fuel-ts/utils");
|
192
197
|
var coinQuantityfy = (coinQuantityLike) => {
|
@@ -195,11 +200,11 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
195
200
|
let max2;
|
196
201
|
if (Array.isArray(coinQuantityLike)) {
|
197
202
|
amount = coinQuantityLike[0];
|
198
|
-
assetId = coinQuantityLike[1];
|
199
|
-
max2 = coinQuantityLike[2];
|
203
|
+
assetId = coinQuantityLike[1] ?? import_configs.BaseAssetId;
|
204
|
+
max2 = coinQuantityLike[2] ?? void 0;
|
200
205
|
} else {
|
201
206
|
amount = coinQuantityLike.amount;
|
202
|
-
assetId = coinQuantityLike.assetId;
|
207
|
+
assetId = coinQuantityLike.assetId ?? import_configs.BaseAssetId;
|
203
208
|
max2 = coinQuantityLike.max ?? void 0;
|
204
209
|
}
|
205
210
|
const bnAmount = (0, import_math.bn)(amount);
|
@@ -223,12 +228,12 @@ var addAmountToAsset = (params) => {
|
|
223
228
|
|
224
229
|
// src/providers/provider.ts
|
225
230
|
var import_address3 = require("@fuel-ts/address");
|
226
|
-
var
|
227
|
-
var
|
228
|
-
var
|
229
|
-
var
|
231
|
+
var import_errors14 = require("@fuel-ts/errors");
|
232
|
+
var import_math15 = require("@fuel-ts/math");
|
233
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
234
|
+
var import_utils23 = require("@fuel-ts/utils");
|
230
235
|
var import_versions = require("@fuel-ts/versions");
|
231
|
-
var
|
236
|
+
var import_utils24 = require("@noble/curves/abstract/utils");
|
232
237
|
var import_ethers = require("ethers");
|
233
238
|
var import_graphql_request = require("graphql-request");
|
234
239
|
var import_ramda3 = require("ramda");
|
@@ -1168,7 +1173,7 @@ var MemoryCache = class {
|
|
1168
1173
|
};
|
1169
1174
|
|
1170
1175
|
// src/providers/transaction-request/input.ts
|
1171
|
-
var
|
1176
|
+
var import_configs2 = require("@fuel-ts/address/configs");
|
1172
1177
|
var import_errors3 = require("@fuel-ts/errors");
|
1173
1178
|
var import_math2 = require("@fuel-ts/math");
|
1174
1179
|
var import_transactions = require("@fuel-ts/transactions");
|
@@ -1202,10 +1207,10 @@ var inputify = (value) => {
|
|
1202
1207
|
case import_transactions.InputType.Contract: {
|
1203
1208
|
return {
|
1204
1209
|
type: import_transactions.InputType.Contract,
|
1205
|
-
txID:
|
1210
|
+
txID: import_configs2.ZeroBytes32,
|
1206
1211
|
outputIndex: 0,
|
1207
|
-
balanceRoot:
|
1208
|
-
stateRoot:
|
1212
|
+
balanceRoot: import_configs2.ZeroBytes32,
|
1213
|
+
stateRoot: import_configs2.ZeroBytes32,
|
1209
1214
|
txPointer: {
|
1210
1215
|
blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
|
1211
1216
|
txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
|
@@ -1243,7 +1248,7 @@ var inputify = (value) => {
|
|
1243
1248
|
};
|
1244
1249
|
|
1245
1250
|
// src/providers/transaction-request/output.ts
|
1246
|
-
var
|
1251
|
+
var import_configs3 = require("@fuel-ts/address/configs");
|
1247
1252
|
var import_errors4 = require("@fuel-ts/errors");
|
1248
1253
|
var import_math3 = require("@fuel-ts/math");
|
1249
1254
|
var import_transactions2 = require("@fuel-ts/transactions");
|
@@ -1263,8 +1268,8 @@ var outputify = (value) => {
|
|
1263
1268
|
return {
|
1264
1269
|
type: import_transactions2.OutputType.Contract,
|
1265
1270
|
inputIndex: value.inputIndex,
|
1266
|
-
balanceRoot:
|
1267
|
-
stateRoot:
|
1271
|
+
balanceRoot: import_configs3.ZeroBytes32,
|
1272
|
+
stateRoot: import_configs3.ZeroBytes32
|
1268
1273
|
};
|
1269
1274
|
}
|
1270
1275
|
case import_transactions2.OutputType.Change: {
|
@@ -1278,9 +1283,9 @@ var outputify = (value) => {
|
|
1278
1283
|
case import_transactions2.OutputType.Variable: {
|
1279
1284
|
return {
|
1280
1285
|
type: import_transactions2.OutputType.Variable,
|
1281
|
-
to:
|
1286
|
+
to: import_configs3.ZeroBytes32,
|
1282
1287
|
amount: (0, import_math3.bn)(0),
|
1283
|
-
assetId:
|
1288
|
+
assetId: import_configs3.ZeroBytes32
|
1284
1289
|
};
|
1285
1290
|
}
|
1286
1291
|
case import_transactions2.OutputType.ContractCreated: {
|
@@ -1301,9 +1306,9 @@ var outputify = (value) => {
|
|
1301
1306
|
|
1302
1307
|
// src/providers/transaction-request/transaction-request.ts
|
1303
1308
|
var import_address = require("@fuel-ts/address");
|
1304
|
-
var
|
1305
|
-
var
|
1306
|
-
var
|
1309
|
+
var import_configs7 = require("@fuel-ts/address/configs");
|
1310
|
+
var import_math7 = require("@fuel-ts/math");
|
1311
|
+
var import_transactions6 = require("@fuel-ts/transactions");
|
1307
1312
|
var import_utils9 = require("@fuel-ts/utils");
|
1308
1313
|
|
1309
1314
|
// src/providers/resource.ts
|
@@ -1313,13 +1318,13 @@ var isCoin = (resource) => "id" in resource;
|
|
1313
1318
|
var isMessage = (resource) => "recipient" in resource;
|
1314
1319
|
|
1315
1320
|
// src/providers/utils/receipts.ts
|
1316
|
-
var
|
1321
|
+
var import_configs4 = require("@fuel-ts/address/configs");
|
1317
1322
|
var import_errors5 = require("@fuel-ts/errors");
|
1318
1323
|
var import_math4 = require("@fuel-ts/math");
|
1319
1324
|
var import_transactions3 = require("@fuel-ts/transactions");
|
1320
|
-
var
|
1325
|
+
var import_configs5 = require("@fuel-ts/transactions/configs");
|
1321
1326
|
var import_utils5 = require("@fuel-ts/utils");
|
1322
|
-
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") ===
|
1327
|
+
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1323
1328
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1324
1329
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
1325
1330
|
(memo, receipt) => {
|
@@ -1336,7 +1341,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
|
1336
1341
|
missingOutputContractIds: []
|
1337
1342
|
}
|
1338
1343
|
);
|
1339
|
-
var hexOrZero = (hex) => hex ||
|
1344
|
+
var hexOrZero = (hex) => hex || import_configs4.ZeroBytes32;
|
1340
1345
|
function assembleReceiptByType(receipt) {
|
1341
1346
|
const { receiptType } = receipt;
|
1342
1347
|
switch (receiptType) {
|
@@ -1696,6 +1701,78 @@ function sleep(time) {
|
|
1696
1701
|
});
|
1697
1702
|
}
|
1698
1703
|
|
1704
|
+
// src/providers/utils/extract-tx-error.ts
|
1705
|
+
var import_errors7 = require("@fuel-ts/errors");
|
1706
|
+
var import_math6 = require("@fuel-ts/math");
|
1707
|
+
var import_transactions5 = require("@fuel-ts/transactions");
|
1708
|
+
var import_configs6 = require("@fuel-ts/transactions/configs");
|
1709
|
+
var assemblePanicError = (status) => {
|
1710
|
+
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
1711
|
+
const reason = status.reason;
|
1712
|
+
if (import_configs6.PANIC_REASONS.includes(status.reason)) {
|
1713
|
+
errorMessage = `${errorMessage}
|
1714
|
+
|
1715
|
+
You can read more about this error at:
|
1716
|
+
|
1717
|
+
${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
|
1718
|
+
}
|
1719
|
+
return { errorMessage, reason };
|
1720
|
+
};
|
1721
|
+
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
1722
|
+
var assembleRevertError = (receipts, logs) => {
|
1723
|
+
let errorMessage = "The transaction reverted with an unknown reason.";
|
1724
|
+
const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
|
1725
|
+
let reason = "";
|
1726
|
+
if (revertReceipt) {
|
1727
|
+
const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
|
1728
|
+
switch (reasonHex) {
|
1729
|
+
case import_configs6.FAILED_REQUIRE_SIGNAL: {
|
1730
|
+
reason = "require";
|
1731
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
|
1732
|
+
break;
|
1733
|
+
}
|
1734
|
+
case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
|
1735
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1736
|
+
reason = "assert_eq";
|
1737
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
1738
|
+
break;
|
1739
|
+
}
|
1740
|
+
case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
|
1741
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
|
1742
|
+
reason = "assert_ne";
|
1743
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
1744
|
+
break;
|
1745
|
+
}
|
1746
|
+
case import_configs6.FAILED_ASSERT_SIGNAL:
|
1747
|
+
reason = "assert";
|
1748
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
1749
|
+
break;
|
1750
|
+
case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
1751
|
+
reason = "MissingOutputChange";
|
1752
|
+
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
1753
|
+
break;
|
1754
|
+
default:
|
1755
|
+
reason = "unknown";
|
1756
|
+
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
1757
|
+
}
|
1758
|
+
}
|
1759
|
+
return { errorMessage, reason };
|
1760
|
+
};
|
1761
|
+
var extractTxError = (params) => {
|
1762
|
+
const { receipts, status, logs } = params;
|
1763
|
+
const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
|
1764
|
+
const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
|
1765
|
+
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
1766
|
+
const metadata = {
|
1767
|
+
logs,
|
1768
|
+
receipts,
|
1769
|
+
panic: isPanic,
|
1770
|
+
revert: isRevert,
|
1771
|
+
reason
|
1772
|
+
};
|
1773
|
+
return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
|
1774
|
+
};
|
1775
|
+
|
1699
1776
|
// src/providers/transaction-request/errors.ts
|
1700
1777
|
var ChangeOutputCollisionError = class extends Error {
|
1701
1778
|
name = "ChangeOutputCollisionError";
|
@@ -1744,8 +1821,6 @@ var BaseTransactionRequest = class {
|
|
1744
1821
|
outputs = [];
|
1745
1822
|
/** List of witnesses */
|
1746
1823
|
witnesses = [];
|
1747
|
-
/** Base asset ID - should be fetched from the chain */
|
1748
|
-
baseAssetId = import_configs5.ZeroBytes32;
|
1749
1824
|
/**
|
1750
1825
|
* Constructor for initializing a base transaction request.
|
1751
1826
|
*
|
@@ -1758,36 +1833,34 @@ var BaseTransactionRequest = class {
|
|
1758
1833
|
witnessLimit,
|
1759
1834
|
inputs,
|
1760
1835
|
outputs,
|
1761
|
-
witnesses
|
1762
|
-
baseAssetId
|
1836
|
+
witnesses
|
1763
1837
|
} = {}) {
|
1764
|
-
this.gasPrice = (0,
|
1838
|
+
this.gasPrice = (0, import_math7.bn)(gasPrice);
|
1765
1839
|
this.maturity = maturity ?? 0;
|
1766
|
-
this.witnessLimit = witnessLimit ? (0,
|
1767
|
-
this.maxFee = maxFee ? (0,
|
1840
|
+
this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
|
1841
|
+
this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
|
1768
1842
|
this.inputs = inputs ?? [];
|
1769
1843
|
this.outputs = outputs ?? [];
|
1770
1844
|
this.witnesses = witnesses ?? [];
|
1771
|
-
this.baseAssetId = baseAssetId ?? import_configs5.ZeroBytes32;
|
1772
1845
|
}
|
1773
1846
|
static getPolicyMeta(req) {
|
1774
1847
|
let policyTypes = 0;
|
1775
1848
|
const policies = [];
|
1776
1849
|
if (req.gasPrice) {
|
1777
|
-
policyTypes +=
|
1778
|
-
policies.push({ data: req.gasPrice, type:
|
1850
|
+
policyTypes += import_transactions6.PolicyType.GasPrice;
|
1851
|
+
policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
|
1779
1852
|
}
|
1780
1853
|
if (req.witnessLimit) {
|
1781
|
-
policyTypes +=
|
1782
|
-
policies.push({ data: req.witnessLimit, type:
|
1854
|
+
policyTypes += import_transactions6.PolicyType.WitnessLimit;
|
1855
|
+
policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
|
1783
1856
|
}
|
1784
1857
|
if (req.maturity > 0) {
|
1785
|
-
policyTypes +=
|
1786
|
-
policies.push({ data: req.maturity, type:
|
1858
|
+
policyTypes += import_transactions6.PolicyType.Maturity;
|
1859
|
+
policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
|
1787
1860
|
}
|
1788
1861
|
if (req.maxFee) {
|
1789
|
-
policyTypes +=
|
1790
|
-
policies.push({ data: req.maxFee, type:
|
1862
|
+
policyTypes += import_transactions6.PolicyType.MaxFee;
|
1863
|
+
policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
|
1791
1864
|
}
|
1792
1865
|
return {
|
1793
1866
|
policyTypes,
|
@@ -1821,7 +1894,7 @@ var BaseTransactionRequest = class {
|
|
1821
1894
|
* @returns The transaction bytes.
|
1822
1895
|
*/
|
1823
1896
|
toTransactionBytes() {
|
1824
|
-
return new
|
1897
|
+
return new import_transactions6.TransactionCoder().encode(this.toTransaction());
|
1825
1898
|
}
|
1826
1899
|
/**
|
1827
1900
|
* @hidden
|
@@ -1861,7 +1934,7 @@ var BaseTransactionRequest = class {
|
|
1861
1934
|
* @returns The index of the created witness.
|
1862
1935
|
*/
|
1863
1936
|
addEmptyWitness() {
|
1864
|
-
this.addWitness((0, import_utils9.concat)([
|
1937
|
+
this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
|
1865
1938
|
return this.witnesses.length - 1;
|
1866
1939
|
}
|
1867
1940
|
/**
|
@@ -1912,7 +1985,7 @@ var BaseTransactionRequest = class {
|
|
1912
1985
|
*/
|
1913
1986
|
getCoinInputs() {
|
1914
1987
|
return this.inputs.filter(
|
1915
|
-
(input) => input.type ===
|
1988
|
+
(input) => input.type === import_transactions6.InputType.Coin
|
1916
1989
|
);
|
1917
1990
|
}
|
1918
1991
|
/**
|
@@ -1922,7 +1995,7 @@ var BaseTransactionRequest = class {
|
|
1922
1995
|
*/
|
1923
1996
|
getCoinOutputs() {
|
1924
1997
|
return this.outputs.filter(
|
1925
|
-
(output) => output.type ===
|
1998
|
+
(output) => output.type === import_transactions6.OutputType.Coin
|
1926
1999
|
);
|
1927
2000
|
}
|
1928
2001
|
/**
|
@@ -1932,7 +2005,7 @@ var BaseTransactionRequest = class {
|
|
1932
2005
|
*/
|
1933
2006
|
getChangeOutputs() {
|
1934
2007
|
return this.outputs.filter(
|
1935
|
-
(output) => output.type ===
|
2008
|
+
(output) => output.type === import_transactions6.OutputType.Change
|
1936
2009
|
);
|
1937
2010
|
}
|
1938
2011
|
/**
|
@@ -1944,9 +2017,9 @@ var BaseTransactionRequest = class {
|
|
1944
2017
|
const ownerAddress = (0, import_address.addressify)(owner);
|
1945
2018
|
const found = this.inputs.find((input) => {
|
1946
2019
|
switch (input.type) {
|
1947
|
-
case
|
2020
|
+
case import_transactions6.InputType.Coin:
|
1948
2021
|
return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
|
1949
|
-
case
|
2022
|
+
case import_transactions6.InputType.Message:
|
1950
2023
|
return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
|
1951
2024
|
default:
|
1952
2025
|
return false;
|
@@ -1975,7 +2048,7 @@ var BaseTransactionRequest = class {
|
|
1975
2048
|
}
|
1976
2049
|
const input = {
|
1977
2050
|
...coin,
|
1978
|
-
type:
|
2051
|
+
type: import_transactions6.InputType.Coin,
|
1979
2052
|
owner: owner.toB256(),
|
1980
2053
|
amount,
|
1981
2054
|
assetId,
|
@@ -1993,9 +2066,11 @@ var BaseTransactionRequest = class {
|
|
1993
2066
|
*
|
1994
2067
|
* @param message - Message resource.
|
1995
2068
|
* @param predicate - Predicate bytes.
|
2069
|
+
* @param predicateData - Predicate data bytes.
|
1996
2070
|
*/
|
1997
2071
|
addMessageInput(message, predicate) {
|
1998
2072
|
const { recipient, sender, amount } = message;
|
2073
|
+
const assetId = import_configs7.BaseAssetId;
|
1999
2074
|
let witnessIndex;
|
2000
2075
|
if (predicate) {
|
2001
2076
|
witnessIndex = 0;
|
@@ -2007,7 +2082,7 @@ var BaseTransactionRequest = class {
|
|
2007
2082
|
}
|
2008
2083
|
const input = {
|
2009
2084
|
...message,
|
2010
|
-
type:
|
2085
|
+
type: import_transactions6.InputType.Message,
|
2011
2086
|
sender: sender.toB256(),
|
2012
2087
|
recipient: recipient.toB256(),
|
2013
2088
|
amount,
|
@@ -2016,7 +2091,7 @@ var BaseTransactionRequest = class {
|
|
2016
2091
|
predicateData: predicate?.predicateDataBytes
|
2017
2092
|
};
|
2018
2093
|
this.pushInput(input);
|
2019
|
-
this.addChangeOutput(recipient,
|
2094
|
+
this.addChangeOutput(recipient, assetId);
|
2020
2095
|
}
|
2021
2096
|
/**
|
2022
2097
|
* Adds a single resource to the transaction by adding a coin/message input and a
|
@@ -2077,12 +2152,12 @@ var BaseTransactionRequest = class {
|
|
2077
2152
|
* @param amount - Amount of coin.
|
2078
2153
|
* @param assetId - Asset ID of coin.
|
2079
2154
|
*/
|
2080
|
-
addCoinOutput(to, amount, assetId) {
|
2155
|
+
addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
|
2081
2156
|
this.pushOutput({
|
2082
|
-
type:
|
2157
|
+
type: import_transactions6.OutputType.Coin,
|
2083
2158
|
to: (0, import_address.addressify)(to).toB256(),
|
2084
2159
|
amount,
|
2085
|
-
assetId
|
2160
|
+
assetId
|
2086
2161
|
});
|
2087
2162
|
return this;
|
2088
2163
|
}
|
@@ -2095,7 +2170,7 @@ var BaseTransactionRequest = class {
|
|
2095
2170
|
addCoinOutputs(to, quantities) {
|
2096
2171
|
quantities.map(coinQuantityfy).forEach((quantity) => {
|
2097
2172
|
this.pushOutput({
|
2098
|
-
type:
|
2173
|
+
type: import_transactions6.OutputType.Coin,
|
2099
2174
|
to: (0, import_address.addressify)(to).toB256(),
|
2100
2175
|
amount: quantity.amount,
|
2101
2176
|
assetId: quantity.assetId
|
@@ -2109,15 +2184,15 @@ var BaseTransactionRequest = class {
|
|
2109
2184
|
* @param to - Address of the owner.
|
2110
2185
|
* @param assetId - Asset ID of coin.
|
2111
2186
|
*/
|
2112
|
-
addChangeOutput(to, assetId) {
|
2187
|
+
addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
|
2113
2188
|
const changeOutput = this.getChangeOutputs().find(
|
2114
2189
|
(output) => (0, import_utils9.hexlify)(output.assetId) === assetId
|
2115
2190
|
);
|
2116
2191
|
if (!changeOutput) {
|
2117
2192
|
this.pushOutput({
|
2118
|
-
type:
|
2193
|
+
type: import_transactions6.OutputType.Change,
|
2119
2194
|
to: (0, import_address.addressify)(to).toB256(),
|
2120
|
-
assetId
|
2195
|
+
assetId
|
2121
2196
|
});
|
2122
2197
|
}
|
2123
2198
|
}
|
@@ -2171,7 +2246,7 @@ var BaseTransactionRequest = class {
|
|
2171
2246
|
let idCounter = 0;
|
2172
2247
|
const generateId = () => {
|
2173
2248
|
const counterString = String(idCounter++);
|
2174
|
-
const id =
|
2249
|
+
const id = import_configs7.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
2175
2250
|
return id;
|
2176
2251
|
};
|
2177
2252
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
@@ -2193,13 +2268,13 @@ var BaseTransactionRequest = class {
|
|
2193
2268
|
assetId,
|
2194
2269
|
owner: resourcesOwner || import_address.Address.fromRandom(),
|
2195
2270
|
maturity: 0,
|
2196
|
-
blockCreated: (0,
|
2197
|
-
txCreatedIdx: (0,
|
2271
|
+
blockCreated: (0, import_math7.bn)(1),
|
2272
|
+
txCreatedIdx: (0, import_math7.bn)(1)
|
2198
2273
|
}
|
2199
2274
|
]);
|
2200
2275
|
}
|
2201
2276
|
};
|
2202
|
-
updateAssetInput(
|
2277
|
+
updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
|
2203
2278
|
quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
|
2204
2279
|
}
|
2205
2280
|
/**
|
@@ -2210,7 +2285,7 @@ var BaseTransactionRequest = class {
|
|
2210
2285
|
*/
|
2211
2286
|
getCoinOutputsQuantities() {
|
2212
2287
|
const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
|
2213
|
-
amount: (0,
|
2288
|
+
amount: (0, import_math7.bn)(amount),
|
2214
2289
|
assetId: assetId.toString()
|
2215
2290
|
}));
|
2216
2291
|
return coinsQuantities;
|
@@ -2228,18 +2303,18 @@ var BaseTransactionRequest = class {
|
|
2228
2303
|
this.inputs.forEach((i) => {
|
2229
2304
|
let correspondingInput;
|
2230
2305
|
switch (i.type) {
|
2231
|
-
case
|
2232
|
-
correspondingInput = inputs.find((x) => x.type ===
|
2306
|
+
case import_transactions6.InputType.Coin:
|
2307
|
+
correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
|
2233
2308
|
break;
|
2234
|
-
case
|
2309
|
+
case import_transactions6.InputType.Message:
|
2235
2310
|
correspondingInput = inputs.find(
|
2236
|
-
(x) => x.type ===
|
2311
|
+
(x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
|
2237
2312
|
);
|
2238
2313
|
break;
|
2239
2314
|
default:
|
2240
2315
|
return;
|
2241
2316
|
}
|
2242
|
-
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0,
|
2317
|
+
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2243
2318
|
i.predicate = correspondingInput.predicate;
|
2244
2319
|
i.predicateData = correspondingInput.predicateData;
|
2245
2320
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2249,47 +2324,47 @@ var BaseTransactionRequest = class {
|
|
2249
2324
|
};
|
2250
2325
|
|
2251
2326
|
// src/providers/transaction-request/create-transaction-request.ts
|
2252
|
-
var
|
2253
|
-
var
|
2254
|
-
var
|
2327
|
+
var import_configs9 = require("@fuel-ts/address/configs");
|
2328
|
+
var import_math9 = require("@fuel-ts/math");
|
2329
|
+
var import_transactions8 = require("@fuel-ts/transactions");
|
2255
2330
|
var import_utils13 = require("@fuel-ts/utils");
|
2256
2331
|
|
2257
2332
|
// src/providers/transaction-request/hash-transaction.ts
|
2258
|
-
var
|
2333
|
+
var import_configs8 = require("@fuel-ts/address/configs");
|
2259
2334
|
var import_hasher = require("@fuel-ts/hasher");
|
2260
|
-
var
|
2261
|
-
var
|
2335
|
+
var import_math8 = require("@fuel-ts/math");
|
2336
|
+
var import_transactions7 = require("@fuel-ts/transactions");
|
2262
2337
|
var import_utils11 = require("@fuel-ts/utils");
|
2263
2338
|
var import_ramda2 = require("ramda");
|
2264
2339
|
function hashTransaction(transactionRequest, chainId) {
|
2265
2340
|
const transaction = transactionRequest.toTransaction();
|
2266
|
-
if (transaction.type ===
|
2267
|
-
transaction.receiptsRoot =
|
2341
|
+
if (transaction.type === import_transactions7.TransactionType.Script) {
|
2342
|
+
transaction.receiptsRoot = import_configs8.ZeroBytes32;
|
2268
2343
|
}
|
2269
2344
|
transaction.inputs = transaction.inputs.map((input) => {
|
2270
2345
|
const inputClone = (0, import_ramda2.clone)(input);
|
2271
2346
|
switch (inputClone.type) {
|
2272
|
-
case
|
2347
|
+
case import_transactions7.InputType.Coin: {
|
2273
2348
|
inputClone.txPointer = {
|
2274
2349
|
blockHeight: 0,
|
2275
2350
|
txIndex: 0
|
2276
2351
|
};
|
2277
|
-
inputClone.predicateGasUsed = (0,
|
2352
|
+
inputClone.predicateGasUsed = (0, import_math8.bn)(0);
|
2278
2353
|
return inputClone;
|
2279
2354
|
}
|
2280
|
-
case
|
2281
|
-
inputClone.predicateGasUsed = (0,
|
2355
|
+
case import_transactions7.InputType.Message: {
|
2356
|
+
inputClone.predicateGasUsed = (0, import_math8.bn)(0);
|
2282
2357
|
return inputClone;
|
2283
2358
|
}
|
2284
|
-
case
|
2359
|
+
case import_transactions7.InputType.Contract: {
|
2285
2360
|
inputClone.txPointer = {
|
2286
2361
|
blockHeight: 0,
|
2287
2362
|
txIndex: 0
|
2288
2363
|
};
|
2289
|
-
inputClone.txID =
|
2364
|
+
inputClone.txID = import_configs8.ZeroBytes32;
|
2290
2365
|
inputClone.outputIndex = 0;
|
2291
|
-
inputClone.balanceRoot =
|
2292
|
-
inputClone.stateRoot =
|
2366
|
+
inputClone.balanceRoot = import_configs8.ZeroBytes32;
|
2367
|
+
inputClone.stateRoot = import_configs8.ZeroBytes32;
|
2293
2368
|
return inputClone;
|
2294
2369
|
}
|
2295
2370
|
default:
|
@@ -2299,19 +2374,19 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2299
2374
|
transaction.outputs = transaction.outputs.map((output) => {
|
2300
2375
|
const outputClone = (0, import_ramda2.clone)(output);
|
2301
2376
|
switch (outputClone.type) {
|
2302
|
-
case
|
2303
|
-
outputClone.balanceRoot =
|
2304
|
-
outputClone.stateRoot =
|
2377
|
+
case import_transactions7.OutputType.Contract: {
|
2378
|
+
outputClone.balanceRoot = import_configs8.ZeroBytes32;
|
2379
|
+
outputClone.stateRoot = import_configs8.ZeroBytes32;
|
2305
2380
|
return outputClone;
|
2306
2381
|
}
|
2307
|
-
case
|
2308
|
-
outputClone.amount = (0,
|
2382
|
+
case import_transactions7.OutputType.Change: {
|
2383
|
+
outputClone.amount = (0, import_math8.bn)(0);
|
2309
2384
|
return outputClone;
|
2310
2385
|
}
|
2311
|
-
case
|
2312
|
-
outputClone.to =
|
2313
|
-
outputClone.amount = (0,
|
2314
|
-
outputClone.assetId =
|
2386
|
+
case import_transactions7.OutputType.Variable: {
|
2387
|
+
outputClone.to = import_configs8.ZeroBytes32;
|
2388
|
+
outputClone.amount = (0, import_math8.bn)(0);
|
2389
|
+
outputClone.assetId = import_configs8.ZeroBytes32;
|
2315
2390
|
return outputClone;
|
2316
2391
|
}
|
2317
2392
|
default:
|
@@ -2321,7 +2396,7 @@ function hashTransaction(transactionRequest, chainId) {
|
|
2321
2396
|
transaction.witnessesCount = 0;
|
2322
2397
|
transaction.witnesses = [];
|
2323
2398
|
const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
|
2324
|
-
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new
|
2399
|
+
const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
|
2325
2400
|
return (0, import_hasher.sha256)(concatenatedData);
|
2326
2401
|
}
|
2327
2402
|
|
@@ -2357,7 +2432,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2357
2432
|
return new this(obj);
|
2358
2433
|
}
|
2359
2434
|
/** Type of the transaction */
|
2360
|
-
type =
|
2435
|
+
type = import_transactions8.TransactionType.Create;
|
2361
2436
|
/** Witness index of contract bytecode to create */
|
2362
2437
|
bytecodeWitnessIndex;
|
2363
2438
|
/** Salt */
|
@@ -2377,7 +2452,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2377
2452
|
} = {}) {
|
2378
2453
|
super(rest);
|
2379
2454
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2380
|
-
this.salt = (0, import_utils13.hexlify)(salt ??
|
2455
|
+
this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
|
2381
2456
|
this.storageSlots = [...storageSlots ?? []];
|
2382
2457
|
}
|
2383
2458
|
/**
|
@@ -2390,12 +2465,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2390
2465
|
const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
|
2391
2466
|
const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
|
2392
2467
|
return {
|
2393
|
-
type:
|
2468
|
+
type: import_transactions8.TransactionType.Create,
|
2394
2469
|
...baseTransaction,
|
2395
2470
|
bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
|
2396
2471
|
bytecodeWitnessIndex,
|
2397
2472
|
storageSlotsCount: storageSlots.length,
|
2398
|
-
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) :
|
2473
|
+
salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
|
2399
2474
|
storageSlots
|
2400
2475
|
};
|
2401
2476
|
}
|
@@ -2406,7 +2481,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2406
2481
|
*/
|
2407
2482
|
getContractCreatedOutputs() {
|
2408
2483
|
return this.outputs.filter(
|
2409
|
-
(output) => output.type ===
|
2484
|
+
(output) => output.type === import_transactions8.OutputType.ContractCreated
|
2410
2485
|
);
|
2411
2486
|
}
|
2412
2487
|
/**
|
@@ -2427,14 +2502,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2427
2502
|
*/
|
2428
2503
|
addContractCreatedOutput(contractId, stateRoot) {
|
2429
2504
|
this.pushOutput({
|
2430
|
-
type:
|
2505
|
+
type: import_transactions8.OutputType.ContractCreated,
|
2431
2506
|
contractId,
|
2432
2507
|
stateRoot
|
2433
2508
|
});
|
2434
2509
|
}
|
2435
2510
|
metadataGas(gasCosts) {
|
2436
2511
|
return calculateMetadataGasForTxCreate({
|
2437
|
-
contractBytesSize: (0,
|
2512
|
+
contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
|
2438
2513
|
gasCosts,
|
2439
2514
|
stateRootSize: this.storageSlots.length,
|
2440
2515
|
txBytesSize: this.byteSize()
|
@@ -2445,9 +2520,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2445
2520
|
// src/providers/transaction-request/script-transaction-request.ts
|
2446
2521
|
var import_abi_coder = require("@fuel-ts/abi-coder");
|
2447
2522
|
var import_address2 = require("@fuel-ts/address");
|
2448
|
-
var
|
2449
|
-
var
|
2450
|
-
var
|
2523
|
+
var import_configs10 = require("@fuel-ts/address/configs");
|
2524
|
+
var import_math10 = require("@fuel-ts/math");
|
2525
|
+
var import_transactions9 = require("@fuel-ts/transactions");
|
2451
2526
|
var import_utils15 = require("@fuel-ts/utils");
|
2452
2527
|
|
2453
2528
|
// src/providers/transaction-request/scripts.ts
|
@@ -2485,7 +2560,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2485
2560
|
return new this(obj);
|
2486
2561
|
}
|
2487
2562
|
/** Type of the transaction */
|
2488
|
-
type =
|
2563
|
+
type = import_transactions9.TransactionType.Script;
|
2489
2564
|
/** Gas limit for transaction */
|
2490
2565
|
gasLimit;
|
2491
2566
|
/** Script to execute */
|
@@ -2500,7 +2575,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2500
2575
|
*/
|
2501
2576
|
constructor({ script, scriptData, gasLimit, ...rest } = {}) {
|
2502
2577
|
super(rest);
|
2503
|
-
this.gasLimit = (0,
|
2578
|
+
this.gasLimit = (0, import_math10.bn)(gasLimit);
|
2504
2579
|
this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
|
2505
2580
|
this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
|
2506
2581
|
this.abis = rest.abis;
|
@@ -2514,12 +2589,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2514
2589
|
const script = (0, import_utils15.arrayify)(this.script ?? "0x");
|
2515
2590
|
const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
|
2516
2591
|
return {
|
2517
|
-
type:
|
2592
|
+
type: import_transactions9.TransactionType.Script,
|
2518
2593
|
scriptGasLimit: this.gasLimit,
|
2519
2594
|
...super.getBaseTransaction(),
|
2520
2595
|
scriptLength: script.length,
|
2521
2596
|
scriptDataLength: scriptData.length,
|
2522
|
-
receiptsRoot:
|
2597
|
+
receiptsRoot: import_configs10.ZeroBytes32,
|
2523
2598
|
script: (0, import_utils15.hexlify)(script),
|
2524
2599
|
scriptData: (0, import_utils15.hexlify)(scriptData)
|
2525
2600
|
};
|
@@ -2531,7 +2606,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2531
2606
|
*/
|
2532
2607
|
getContractInputs() {
|
2533
2608
|
return this.inputs.filter(
|
2534
|
-
(input) => input.type ===
|
2609
|
+
(input) => input.type === import_transactions9.InputType.Contract
|
2535
2610
|
);
|
2536
2611
|
}
|
2537
2612
|
/**
|
@@ -2541,7 +2616,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2541
2616
|
*/
|
2542
2617
|
getContractOutputs() {
|
2543
2618
|
return this.outputs.filter(
|
2544
|
-
(output) => output.type ===
|
2619
|
+
(output) => output.type === import_transactions9.OutputType.Contract
|
2545
2620
|
);
|
2546
2621
|
}
|
2547
2622
|
/**
|
@@ -2551,7 +2626,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2551
2626
|
*/
|
2552
2627
|
getVariableOutputs() {
|
2553
2628
|
return this.outputs.filter(
|
2554
|
-
(output) => output.type ===
|
2629
|
+
(output) => output.type === import_transactions9.OutputType.Variable
|
2555
2630
|
);
|
2556
2631
|
}
|
2557
2632
|
/**
|
@@ -2574,7 +2649,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2574
2649
|
let outputsNumber = numberOfVariables;
|
2575
2650
|
while (outputsNumber) {
|
2576
2651
|
this.pushOutput({
|
2577
|
-
type:
|
2652
|
+
type: import_transactions9.OutputType.Variable
|
2578
2653
|
});
|
2579
2654
|
outputsNumber -= 1;
|
2580
2655
|
}
|
@@ -2607,12 +2682,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2607
2682
|
return this;
|
2608
2683
|
}
|
2609
2684
|
const inputIndex = super.pushInput({
|
2610
|
-
type:
|
2685
|
+
type: import_transactions9.InputType.Contract,
|
2611
2686
|
contractId: contractAddress.toB256(),
|
2612
2687
|
txPointer: "0x00000000000000000000000000000000"
|
2613
2688
|
});
|
2614
2689
|
this.pushOutput({
|
2615
|
-
type:
|
2690
|
+
type: import_transactions9.OutputType.Contract,
|
2616
2691
|
inputIndex
|
2617
2692
|
});
|
2618
2693
|
return this;
|
@@ -2648,38 +2723,38 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2648
2723
|
};
|
2649
2724
|
|
2650
2725
|
// src/providers/transaction-request/utils.ts
|
2651
|
-
var
|
2652
|
-
var
|
2726
|
+
var import_errors9 = require("@fuel-ts/errors");
|
2727
|
+
var import_transactions10 = require("@fuel-ts/transactions");
|
2653
2728
|
var transactionRequestify = (obj) => {
|
2654
2729
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
|
2655
2730
|
return obj;
|
2656
2731
|
}
|
2657
2732
|
const { type } = obj;
|
2658
2733
|
switch (obj.type) {
|
2659
|
-
case
|
2734
|
+
case import_transactions10.TransactionType.Script: {
|
2660
2735
|
return ScriptTransactionRequest.from(obj);
|
2661
2736
|
}
|
2662
|
-
case
|
2737
|
+
case import_transactions10.TransactionType.Create: {
|
2663
2738
|
return CreateTransactionRequest.from(obj);
|
2664
2739
|
}
|
2665
2740
|
default: {
|
2666
|
-
throw new
|
2741
|
+
throw new import_errors9.FuelError(import_errors9.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
|
2667
2742
|
}
|
2668
2743
|
}
|
2669
2744
|
};
|
2670
2745
|
|
2671
2746
|
// src/providers/transaction-response/transaction-response.ts
|
2672
|
-
var
|
2673
|
-
var
|
2674
|
-
var
|
2747
|
+
var import_errors13 = require("@fuel-ts/errors");
|
2748
|
+
var import_math14 = require("@fuel-ts/math");
|
2749
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
2675
2750
|
var import_utils21 = require("@fuel-ts/utils");
|
2676
2751
|
|
2677
2752
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
2678
2753
|
var import_utils19 = require("@fuel-ts/utils");
|
2679
2754
|
|
2680
2755
|
// src/providers/transaction-summary/calculate-transaction-fee.ts
|
2681
|
-
var
|
2682
|
-
var
|
2756
|
+
var import_math11 = require("@fuel-ts/math");
|
2757
|
+
var import_transactions11 = require("@fuel-ts/transactions");
|
2683
2758
|
var import_utils16 = require("@fuel-ts/utils");
|
2684
2759
|
var calculateTransactionFee = (params) => {
|
2685
2760
|
const {
|
@@ -2687,24 +2762,24 @@ var calculateTransactionFee = (params) => {
|
|
2687
2762
|
rawPayload,
|
2688
2763
|
consensusParameters: { gasCosts, feeParams }
|
2689
2764
|
} = params;
|
2690
|
-
const gasPerByte = (0,
|
2691
|
-
const gasPriceFactor = (0,
|
2765
|
+
const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
|
2766
|
+
const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
|
2692
2767
|
const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
|
2693
|
-
const [transaction] = new
|
2694
|
-
if (transaction.type ===
|
2768
|
+
const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
|
2769
|
+
if (transaction.type === import_transactions11.TransactionType.Mint) {
|
2695
2770
|
return {
|
2696
|
-
fee: (0,
|
2697
|
-
minFee: (0,
|
2698
|
-
maxFee: (0,
|
2699
|
-
feeFromGasUsed: (0,
|
2771
|
+
fee: (0, import_math11.bn)(0),
|
2772
|
+
minFee: (0, import_math11.bn)(0),
|
2773
|
+
maxFee: (0, import_math11.bn)(0),
|
2774
|
+
feeFromGasUsed: (0, import_math11.bn)(0)
|
2700
2775
|
};
|
2701
2776
|
}
|
2702
2777
|
const { type, witnesses, inputs, policies } = transaction;
|
2703
|
-
let metadataGas = (0,
|
2704
|
-
let gasLimit = (0,
|
2705
|
-
if (type ===
|
2778
|
+
let metadataGas = (0, import_math11.bn)(0);
|
2779
|
+
let gasLimit = (0, import_math11.bn)(0);
|
2780
|
+
if (type === import_transactions11.TransactionType.Create) {
|
2706
2781
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
2707
|
-
const contractBytesSize = (0,
|
2782
|
+
const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
2708
2783
|
metadataGas = calculateMetadataGasForTxCreate({
|
2709
2784
|
contractBytesSize,
|
2710
2785
|
gasCosts,
|
@@ -2723,13 +2798,13 @@ var calculateTransactionFee = (params) => {
|
|
2723
2798
|
}
|
2724
2799
|
const minGas = getMinGas({
|
2725
2800
|
gasCosts,
|
2726
|
-
gasPerByte: (0,
|
2801
|
+
gasPerByte: (0, import_math11.bn)(gasPerByte),
|
2727
2802
|
inputs,
|
2728
2803
|
metadataGas,
|
2729
2804
|
txBytesSize: transactionBytes.length
|
2730
2805
|
});
|
2731
|
-
const gasPrice = (0,
|
2732
|
-
const witnessLimit = policies.find((policy) => policy.type ===
|
2806
|
+
const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
|
2807
|
+
const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
|
2733
2808
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
2734
2809
|
const maxGas = getMaxGas({
|
2735
2810
|
gasPerByte,
|
@@ -2751,14 +2826,14 @@ var calculateTransactionFee = (params) => {
|
|
2751
2826
|
};
|
2752
2827
|
|
2753
2828
|
// src/providers/transaction-summary/operations.ts
|
2754
|
-
var
|
2755
|
-
var
|
2756
|
-
var
|
2757
|
-
var
|
2829
|
+
var import_configs11 = require("@fuel-ts/address/configs");
|
2830
|
+
var import_errors11 = require("@fuel-ts/errors");
|
2831
|
+
var import_math13 = require("@fuel-ts/math");
|
2832
|
+
var import_transactions14 = require("@fuel-ts/transactions");
|
2758
2833
|
|
2759
2834
|
// src/providers/transaction-summary/call.ts
|
2760
2835
|
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
2761
|
-
var
|
2836
|
+
var import_math12 = require("@fuel-ts/math");
|
2762
2837
|
var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
2763
2838
|
const abiInterface = new import_abi_coder2.Interface(abi);
|
2764
2839
|
const callFunctionSelector = receipt.param1.toHex(8);
|
@@ -2767,7 +2842,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2767
2842
|
let encodedArgs;
|
2768
2843
|
if (functionFragment.isInputDataPointer) {
|
2769
2844
|
if (rawPayload) {
|
2770
|
-
const argsOffset = (0,
|
2845
|
+
const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
|
2771
2846
|
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
2772
2847
|
}
|
2773
2848
|
} else {
|
@@ -2801,8 +2876,8 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
|
|
2801
2876
|
};
|
2802
2877
|
|
2803
2878
|
// src/providers/transaction-summary/input.ts
|
2804
|
-
var
|
2805
|
-
var
|
2879
|
+
var import_errors10 = require("@fuel-ts/errors");
|
2880
|
+
var import_transactions12 = require("@fuel-ts/transactions");
|
2806
2881
|
function getInputsByTypes(inputs, types) {
|
2807
2882
|
return inputs.filter((i) => types.includes(i.type));
|
2808
2883
|
}
|
@@ -2810,16 +2885,16 @@ function getInputsByType(inputs, type) {
|
|
2810
2885
|
return inputs.filter((i) => i.type === type);
|
2811
2886
|
}
|
2812
2887
|
function getInputsCoin(inputs) {
|
2813
|
-
return getInputsByType(inputs,
|
2888
|
+
return getInputsByType(inputs, import_transactions12.InputType.Coin);
|
2814
2889
|
}
|
2815
2890
|
function getInputsMessage(inputs) {
|
2816
|
-
return getInputsByType(inputs,
|
2891
|
+
return getInputsByType(inputs, import_transactions12.InputType.Message);
|
2817
2892
|
}
|
2818
2893
|
function getInputsCoinAndMessage(inputs) {
|
2819
|
-
return getInputsByTypes(inputs, [
|
2894
|
+
return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
|
2820
2895
|
}
|
2821
2896
|
function getInputsContract(inputs) {
|
2822
|
-
return getInputsByType(inputs,
|
2897
|
+
return getInputsByType(inputs, import_transactions12.InputType.Contract);
|
2823
2898
|
}
|
2824
2899
|
function getInputFromAssetId(inputs, assetId) {
|
2825
2900
|
const coinInputs = getInputsCoin(inputs);
|
@@ -2838,43 +2913,43 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
2838
2913
|
if (!contractInput) {
|
2839
2914
|
return void 0;
|
2840
2915
|
}
|
2841
|
-
if (contractInput.type !==
|
2842
|
-
throw new
|
2843
|
-
|
2916
|
+
if (contractInput.type !== import_transactions12.InputType.Contract) {
|
2917
|
+
throw new import_errors10.FuelError(
|
2918
|
+
import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
|
2844
2919
|
`Contract input should be of type 'contract'.`
|
2845
2920
|
);
|
2846
2921
|
}
|
2847
2922
|
return contractInput;
|
2848
2923
|
}
|
2849
2924
|
function getInputAccountAddress(input) {
|
2850
|
-
if (input.type ===
|
2925
|
+
if (input.type === import_transactions12.InputType.Coin) {
|
2851
2926
|
return input.owner.toString();
|
2852
2927
|
}
|
2853
|
-
if (input.type ===
|
2928
|
+
if (input.type === import_transactions12.InputType.Message) {
|
2854
2929
|
return input.recipient.toString();
|
2855
2930
|
}
|
2856
2931
|
return "";
|
2857
2932
|
}
|
2858
2933
|
|
2859
2934
|
// src/providers/transaction-summary/output.ts
|
2860
|
-
var
|
2935
|
+
var import_transactions13 = require("@fuel-ts/transactions");
|
2861
2936
|
function getOutputsByType(outputs, type) {
|
2862
2937
|
return outputs.filter((o) => o.type === type);
|
2863
2938
|
}
|
2864
2939
|
function getOutputsContractCreated(outputs) {
|
2865
|
-
return getOutputsByType(outputs,
|
2940
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
|
2866
2941
|
}
|
2867
2942
|
function getOutputsCoin(outputs) {
|
2868
|
-
return getOutputsByType(outputs,
|
2943
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
|
2869
2944
|
}
|
2870
2945
|
function getOutputsChange(outputs) {
|
2871
|
-
return getOutputsByType(outputs,
|
2946
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.Change);
|
2872
2947
|
}
|
2873
2948
|
function getOutputsContract(outputs) {
|
2874
|
-
return getOutputsByType(outputs,
|
2949
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
|
2875
2950
|
}
|
2876
2951
|
function getOutputsVariable(outputs) {
|
2877
|
-
return getOutputsByType(outputs,
|
2952
|
+
return getOutputsByType(outputs, import_transactions13.OutputType.Variable);
|
2878
2953
|
}
|
2879
2954
|
|
2880
2955
|
// src/providers/transaction-summary/types.ts
|
@@ -2921,15 +2996,15 @@ function getReceiptsByType(receipts, type) {
|
|
2921
2996
|
}
|
2922
2997
|
function getTransactionTypeName(transactionType) {
|
2923
2998
|
switch (transactionType) {
|
2924
|
-
case
|
2999
|
+
case import_transactions14.TransactionType.Mint:
|
2925
3000
|
return "Mint" /* Mint */;
|
2926
|
-
case
|
3001
|
+
case import_transactions14.TransactionType.Create:
|
2927
3002
|
return "Create" /* Create */;
|
2928
|
-
case
|
3003
|
+
case import_transactions14.TransactionType.Script:
|
2929
3004
|
return "Script" /* Script */;
|
2930
3005
|
default:
|
2931
|
-
throw new
|
2932
|
-
|
3006
|
+
throw new import_errors11.FuelError(
|
3007
|
+
import_errors11.ErrorCode.INVALID_TRANSACTION_TYPE,
|
2933
3008
|
`Invalid transaction type: ${transactionType}.`
|
2934
3009
|
);
|
2935
3010
|
}
|
@@ -2951,10 +3026,10 @@ function hasSameAssetId(a) {
|
|
2951
3026
|
return (b) => a.assetId === b.assetId;
|
2952
3027
|
}
|
2953
3028
|
function getReceiptsCall(receipts) {
|
2954
|
-
return getReceiptsByType(receipts,
|
3029
|
+
return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
|
2955
3030
|
}
|
2956
3031
|
function getReceiptsMessageOut(receipts) {
|
2957
|
-
return getReceiptsByType(receipts,
|
3032
|
+
return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
|
2958
3033
|
}
|
2959
3034
|
var mergeAssets = (op1, op2) => {
|
2960
3035
|
const assets1 = op1.assetsSent || [];
|
@@ -2967,7 +3042,7 @@ var mergeAssets = (op1, op2) => {
|
|
2967
3042
|
if (!matchingAsset) {
|
2968
3043
|
return asset1;
|
2969
3044
|
}
|
2970
|
-
const mergedAmount = (0,
|
3045
|
+
const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
|
2971
3046
|
return { ...asset1, amount: mergedAmount };
|
2972
3047
|
});
|
2973
3048
|
return mergedAssets.concat(filteredAssets);
|
@@ -2993,7 +3068,7 @@ function addOperation(operations, toAdd) {
|
|
2993
3068
|
return allOperations;
|
2994
3069
|
}
|
2995
3070
|
function getReceiptsTransferOut(receipts) {
|
2996
|
-
return getReceiptsByType(receipts,
|
3071
|
+
return getReceiptsByType(receipts, import_transactions14.ReceiptType.TransferOut);
|
2997
3072
|
}
|
2998
3073
|
function getWithdrawFromFuelOperations({
|
2999
3074
|
inputs,
|
@@ -3096,7 +3171,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
3096
3171
|
const { to: toAddress, assetId, amount } = receipt;
|
3097
3172
|
let { from: fromAddress } = receipt;
|
3098
3173
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3099
|
-
if (
|
3174
|
+
if (import_configs11.ZeroBytes32 === fromAddress) {
|
3100
3175
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
3101
3176
|
fromAddress = change?.to || fromAddress;
|
3102
3177
|
}
|
@@ -3153,11 +3228,11 @@ function getTransferOperations({
|
|
3153
3228
|
});
|
3154
3229
|
const transferReceipts = getReceiptsByType(
|
3155
3230
|
receipts,
|
3156
|
-
|
3231
|
+
import_transactions14.ReceiptType.Transfer
|
3157
3232
|
);
|
3158
3233
|
const transferOutReceipts = getReceiptsByType(
|
3159
3234
|
receipts,
|
3160
|
-
|
3235
|
+
import_transactions14.ReceiptType.TransferOut
|
3161
3236
|
);
|
3162
3237
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
3163
3238
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3242,17 +3317,17 @@ function getOperations({
|
|
3242
3317
|
}
|
3243
3318
|
|
3244
3319
|
// src/providers/transaction-summary/receipt.ts
|
3245
|
-
var
|
3320
|
+
var import_transactions15 = require("@fuel-ts/transactions");
|
3246
3321
|
var processGqlReceipt = (gqlReceipt) => {
|
3247
3322
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3248
3323
|
switch (receipt.type) {
|
3249
|
-
case
|
3324
|
+
case import_transactions15.ReceiptType.ReturnData: {
|
3250
3325
|
return {
|
3251
3326
|
...receipt,
|
3252
3327
|
data: gqlReceipt.data || "0x"
|
3253
3328
|
};
|
3254
3329
|
}
|
3255
|
-
case
|
3330
|
+
case import_transactions15.ReceiptType.LogData: {
|
3256
3331
|
return {
|
3257
3332
|
...receipt,
|
3258
3333
|
data: gqlReceipt.data || "0x"
|
@@ -3265,7 +3340,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3265
3340
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3266
3341
|
const mintedAssets = [];
|
3267
3342
|
receipts.forEach((receipt) => {
|
3268
|
-
if (receipt.type ===
|
3343
|
+
if (receipt.type === import_transactions15.ReceiptType.Mint) {
|
3269
3344
|
mintedAssets.push({
|
3270
3345
|
subId: receipt.subId,
|
3271
3346
|
contractId: receipt.contractId,
|
@@ -3279,7 +3354,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3279
3354
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3280
3355
|
const burnedAssets = [];
|
3281
3356
|
receipts.forEach((receipt) => {
|
3282
|
-
if (receipt.type ===
|
3357
|
+
if (receipt.type === import_transactions15.ReceiptType.Burn) {
|
3283
3358
|
burnedAssets.push({
|
3284
3359
|
subId: receipt.subId,
|
3285
3360
|
contractId: receipt.contractId,
|
@@ -3292,7 +3367,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3292
3367
|
};
|
3293
3368
|
|
3294
3369
|
// src/providers/transaction-summary/status.ts
|
3295
|
-
var
|
3370
|
+
var import_errors12 = require("@fuel-ts/errors");
|
3296
3371
|
var getTransactionStatusName = (gqlStatus) => {
|
3297
3372
|
switch (gqlStatus) {
|
3298
3373
|
case "FailureStatus":
|
@@ -3304,8 +3379,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3304
3379
|
case "SqueezedOutStatus":
|
3305
3380
|
return "squeezedout" /* squeezedout */;
|
3306
3381
|
default:
|
3307
|
-
throw new
|
3308
|
-
|
3382
|
+
throw new import_errors12.FuelError(
|
3383
|
+
import_errors12.ErrorCode.INVALID_TRANSACTION_STATUS,
|
3309
3384
|
`Invalid transaction status: ${gqlStatus}.`
|
3310
3385
|
);
|
3311
3386
|
}
|
@@ -3418,12 +3493,12 @@ function assembleTransactionSummary(params) {
|
|
3418
3493
|
|
3419
3494
|
// src/providers/transaction-response/getDecodedLogs.ts
|
3420
3495
|
var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
3421
|
-
var
|
3496
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
3422
3497
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
3423
3498
|
return receipts.reduce((logs, receipt) => {
|
3424
|
-
if (receipt.type ===
|
3499
|
+
if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
|
3425
3500
|
const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
|
3426
|
-
const data = receipt.type ===
|
3501
|
+
const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
3427
3502
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
|
3428
3503
|
logs.push(decodedLog);
|
3429
3504
|
}
|
@@ -3438,7 +3513,7 @@ var TransactionResponse = class {
|
|
3438
3513
|
/** Current provider */
|
3439
3514
|
provider;
|
3440
3515
|
/** Gas used on the transaction */
|
3441
|
-
gasUsed = (0,
|
3516
|
+
gasUsed = (0, import_math14.bn)(0);
|
3442
3517
|
/** The graphql Transaction with receipts object. */
|
3443
3518
|
gqlTransaction;
|
3444
3519
|
abis;
|
@@ -3496,7 +3571,7 @@ var TransactionResponse = class {
|
|
3496
3571
|
* @returns The decoded transaction.
|
3497
3572
|
*/
|
3498
3573
|
decodeTransaction(transactionWithReceipts) {
|
3499
|
-
return new
|
3574
|
+
return new import_transactions17.TransactionCoder().decode(
|
3500
3575
|
(0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
|
3501
3576
|
0
|
3502
3577
|
)?.[0];
|
@@ -3543,8 +3618,8 @@ var TransactionResponse = class {
|
|
3543
3618
|
});
|
3544
3619
|
for await (const { statusChange } of subscription) {
|
3545
3620
|
if (statusChange.type === "SqueezedOutStatus") {
|
3546
|
-
throw new
|
3547
|
-
|
3621
|
+
throw new import_errors13.FuelError(
|
3622
|
+
import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
3548
3623
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
3549
3624
|
);
|
3550
3625
|
}
|
@@ -3566,14 +3641,26 @@ var TransactionResponse = class {
|
|
3566
3641
|
gqlTransaction: this.gqlTransaction,
|
3567
3642
|
...transactionSummary
|
3568
3643
|
};
|
3644
|
+
let logs = [];
|
3569
3645
|
if (this.abis) {
|
3570
|
-
|
3646
|
+
logs = getDecodedLogs(
|
3571
3647
|
transactionSummary.receipts,
|
3572
3648
|
this.abis.main,
|
3573
3649
|
this.abis.otherContractsAbis
|
3574
3650
|
);
|
3575
3651
|
transactionResult.logs = logs;
|
3576
3652
|
}
|
3653
|
+
if (transactionResult.isStatusFailure) {
|
3654
|
+
const {
|
3655
|
+
receipts,
|
3656
|
+
gqlTransaction: { status }
|
3657
|
+
} = transactionResult;
|
3658
|
+
throw extractTxError({
|
3659
|
+
receipts,
|
3660
|
+
status,
|
3661
|
+
logs
|
3662
|
+
});
|
3663
|
+
}
|
3577
3664
|
return transactionResult;
|
3578
3665
|
}
|
3579
3666
|
/**
|
@@ -3582,14 +3669,7 @@ var TransactionResponse = class {
|
|
3582
3669
|
* @param contractsAbiMap - The contracts ABI map.
|
3583
3670
|
*/
|
3584
3671
|
async wait(contractsAbiMap) {
|
3585
|
-
|
3586
|
-
if (result.isStatusFailure) {
|
3587
|
-
throw new import_errors12.FuelError(
|
3588
|
-
import_errors12.ErrorCode.TRANSACTION_FAILED,
|
3589
|
-
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
3590
|
-
);
|
3591
|
-
}
|
3592
|
-
return result;
|
3672
|
+
return this.waitForResult(contractsAbiMap);
|
3593
3673
|
}
|
3594
3674
|
};
|
3595
3675
|
|
@@ -3651,30 +3731,29 @@ var processGqlChain = (chain) => {
|
|
3651
3731
|
const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
|
3652
3732
|
return {
|
3653
3733
|
name,
|
3654
|
-
baseChainHeight: (0,
|
3734
|
+
baseChainHeight: (0, import_math15.bn)(daHeight),
|
3655
3735
|
consensusParameters: {
|
3656
|
-
contractMaxSize: (0,
|
3657
|
-
maxInputs: (0,
|
3658
|
-
maxOutputs: (0,
|
3659
|
-
maxWitnesses: (0,
|
3660
|
-
maxGasPerTx: (0,
|
3661
|
-
maxScriptLength: (0,
|
3662
|
-
maxScriptDataLength: (0,
|
3663
|
-
maxStorageSlots: (0,
|
3664
|
-
maxPredicateLength: (0,
|
3665
|
-
maxPredicateDataLength: (0,
|
3666
|
-
maxGasPerPredicate: (0,
|
3667
|
-
gasPriceFactor: (0,
|
3668
|
-
gasPerByte: (0,
|
3669
|
-
maxMessageDataLength: (0,
|
3670
|
-
chainId: (0,
|
3671
|
-
baseAssetId: consensusParameters.baseAssetId,
|
3736
|
+
contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
|
3737
|
+
maxInputs: (0, import_math15.bn)(txParams.maxInputs),
|
3738
|
+
maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
|
3739
|
+
maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
|
3740
|
+
maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
|
3741
|
+
maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
|
3742
|
+
maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
|
3743
|
+
maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
|
3744
|
+
maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
|
3745
|
+
maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
|
3746
|
+
maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
|
3747
|
+
gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
|
3748
|
+
gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
|
3749
|
+
maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
|
3750
|
+
chainId: (0, import_math15.bn)(consensusParameters.chainId),
|
3672
3751
|
gasCosts
|
3673
3752
|
},
|
3674
3753
|
gasCosts,
|
3675
3754
|
latestBlock: {
|
3676
3755
|
id: latestBlock.id,
|
3677
|
-
height: (0,
|
3756
|
+
height: (0, import_math15.bn)(latestBlock.header.height),
|
3678
3757
|
time: latestBlock.header.time,
|
3679
3758
|
transactions: latestBlock.transactions.map((i) => ({
|
3680
3759
|
id: i.id
|
@@ -3744,8 +3823,8 @@ var _Provider = class {
|
|
3744
3823
|
getChain() {
|
3745
3824
|
const chain = _Provider.chainInfoCache[this.url];
|
3746
3825
|
if (!chain) {
|
3747
|
-
throw new
|
3748
|
-
|
3826
|
+
throw new import_errors14.FuelError(
|
3827
|
+
import_errors14.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
|
3749
3828
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
3750
3829
|
);
|
3751
3830
|
}
|
@@ -3757,8 +3836,8 @@ var _Provider = class {
|
|
3757
3836
|
getNode() {
|
3758
3837
|
const node = _Provider.nodeInfoCache[this.url];
|
3759
3838
|
if (!node) {
|
3760
|
-
throw new
|
3761
|
-
|
3839
|
+
throw new import_errors14.FuelError(
|
3840
|
+
import_errors14.ErrorCode.NODE_INFO_CACHE_EMPTY,
|
3762
3841
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
3763
3842
|
);
|
3764
3843
|
}
|
@@ -3805,8 +3884,8 @@ var _Provider = class {
|
|
3805
3884
|
static ensureClientVersionIsSupported(nodeInfo) {
|
3806
3885
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
3807
3886
|
if (!isMajorSupported || !isMinorSupported) {
|
3808
|
-
throw new
|
3809
|
-
|
3887
|
+
throw new import_errors14.FuelError(
|
3888
|
+
import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
|
3810
3889
|
`Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
|
3811
3890
|
);
|
3812
3891
|
}
|
@@ -3869,7 +3948,7 @@ var _Provider = class {
|
|
3869
3948
|
*/
|
3870
3949
|
async getBlockNumber() {
|
3871
3950
|
const { chain } = await this.operations.getChain();
|
3872
|
-
return (0,
|
3951
|
+
return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
|
3873
3952
|
}
|
3874
3953
|
/**
|
3875
3954
|
* Returns the chain information.
|
@@ -3879,9 +3958,9 @@ var _Provider = class {
|
|
3879
3958
|
async fetchNode() {
|
3880
3959
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
3881
3960
|
const processedNodeInfo = {
|
3882
|
-
maxDepth: (0,
|
3883
|
-
maxTx: (0,
|
3884
|
-
minGasPrice: (0,
|
3961
|
+
maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
|
3962
|
+
maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
|
3963
|
+
minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
|
3885
3964
|
nodeVersion: nodeInfo.nodeVersion,
|
3886
3965
|
utxoValidation: nodeInfo.utxoValidation,
|
3887
3966
|
vmBacktrace: nodeInfo.vmBacktrace,
|
@@ -3911,17 +3990,6 @@ var _Provider = class {
|
|
3911
3990
|
} = this.getChain();
|
3912
3991
|
return chainId.toNumber();
|
3913
3992
|
}
|
3914
|
-
/**
|
3915
|
-
* Returns the base asset ID
|
3916
|
-
*
|
3917
|
-
* @returns A promise that resolves to the base asset ID
|
3918
|
-
*/
|
3919
|
-
getBaseAssetId() {
|
3920
|
-
const {
|
3921
|
-
consensusParameters: { baseAssetId }
|
3922
|
-
} = this.getChain();
|
3923
|
-
return baseAssetId;
|
3924
|
-
}
|
3925
3993
|
/**
|
3926
3994
|
* Submits a transaction to the chain to be executed.
|
3927
3995
|
*
|
@@ -3938,17 +4006,17 @@ var _Provider = class {
|
|
3938
4006
|
if (estimateTxDependencies) {
|
3939
4007
|
await this.estimateTxDependencies(transactionRequest);
|
3940
4008
|
}
|
3941
|
-
const encodedTransaction = (0,
|
4009
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3942
4010
|
let abis;
|
3943
|
-
if (transactionRequest.type ===
|
4011
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Script) {
|
3944
4012
|
abis = transactionRequest.abis;
|
3945
4013
|
}
|
3946
4014
|
if (awaitExecution) {
|
3947
4015
|
const subscription = this.operations.submitAndAwait({ encodedTransaction });
|
3948
4016
|
for await (const { submitAndAwait } of subscription) {
|
3949
4017
|
if (submitAndAwait.type === "SqueezedOutStatus") {
|
3950
|
-
throw new
|
3951
|
-
|
4018
|
+
throw new import_errors14.FuelError(
|
4019
|
+
import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
3952
4020
|
`Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
|
3953
4021
|
);
|
3954
4022
|
}
|
@@ -3981,7 +4049,7 @@ var _Provider = class {
|
|
3981
4049
|
if (estimateTxDependencies) {
|
3982
4050
|
return this.estimateTxDependencies(transactionRequest);
|
3983
4051
|
}
|
3984
|
-
const encodedTransaction = (0,
|
4052
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
3985
4053
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
3986
4054
|
encodedTransaction,
|
3987
4055
|
utxoValidation: utxoValidation || false
|
@@ -4000,13 +4068,13 @@ var _Provider = class {
|
|
4000
4068
|
async estimatePredicates(transactionRequest) {
|
4001
4069
|
const shouldEstimatePredicates = Boolean(
|
4002
4070
|
transactionRequest.inputs.find(
|
4003
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
4071
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math15.BN(input.predicateGasUsed).isZero()
|
4004
4072
|
)
|
4005
4073
|
);
|
4006
4074
|
if (!shouldEstimatePredicates) {
|
4007
4075
|
return transactionRequest;
|
4008
4076
|
}
|
4009
|
-
const encodedTransaction = (0,
|
4077
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4010
4078
|
const response = await this.operations.estimatePredicates({
|
4011
4079
|
encodedTransaction
|
4012
4080
|
});
|
@@ -4015,7 +4083,7 @@ var _Provider = class {
|
|
4015
4083
|
} = response;
|
4016
4084
|
if (inputs) {
|
4017
4085
|
inputs.forEach((input, index) => {
|
4018
|
-
if ("predicateGasUsed" in input && (0,
|
4086
|
+
if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
|
4019
4087
|
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
4020
4088
|
}
|
4021
4089
|
});
|
@@ -4036,7 +4104,7 @@ var _Provider = class {
|
|
4036
4104
|
* @returns A promise.
|
4037
4105
|
*/
|
4038
4106
|
async estimateTxDependencies(transactionRequest) {
|
4039
|
-
if (transactionRequest.type ===
|
4107
|
+
if (transactionRequest.type === import_transactions18.TransactionType.Create) {
|
4040
4108
|
return {
|
4041
4109
|
receipts: [],
|
4042
4110
|
outputVariables: 0,
|
@@ -4049,7 +4117,7 @@ var _Provider = class {
|
|
4049
4117
|
let outputVariables = 0;
|
4050
4118
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
4051
4119
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
4052
|
-
encodedTransaction: (0,
|
4120
|
+
encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
|
4053
4121
|
utxoValidation: false
|
4054
4122
|
});
|
4055
4123
|
receipts = gqlReceipts.map(processGqlReceipt);
|
@@ -4087,7 +4155,7 @@ var _Provider = class {
|
|
4087
4155
|
if (estimateTxDependencies) {
|
4088
4156
|
return this.estimateTxDependencies(transactionRequest);
|
4089
4157
|
}
|
4090
|
-
const encodedTransaction = (0,
|
4158
|
+
const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
|
4091
4159
|
const { dryRun: gqlReceipts } = await this.operations.dryRun({
|
4092
4160
|
encodedTransaction,
|
4093
4161
|
utxoValidation: true
|
@@ -4121,14 +4189,14 @@ var _Provider = class {
|
|
4121
4189
|
const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
|
4122
4190
|
const chainInfo = this.getChain();
|
4123
4191
|
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
4124
|
-
const gasPrice = (0,
|
4125
|
-
const isScriptTransaction = txRequestClone.type ===
|
4192
|
+
const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
|
4193
|
+
const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
|
4126
4194
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
4127
4195
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
4128
4196
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
4129
4197
|
if (estimatePredicates) {
|
4130
4198
|
if (isScriptTransaction) {
|
4131
|
-
txRequestClone.gasLimit = (0,
|
4199
|
+
txRequestClone.gasLimit = (0, import_math15.bn)(0);
|
4132
4200
|
}
|
4133
4201
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
4134
4202
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
@@ -4144,8 +4212,8 @@ var _Provider = class {
|
|
4144
4212
|
let missingContractIds = [];
|
4145
4213
|
let outputVariables = 0;
|
4146
4214
|
if (isScriptTransaction && estimateTxDependencies) {
|
4147
|
-
txRequestClone.gasPrice = (0,
|
4148
|
-
txRequestClone.gasLimit = (0,
|
4215
|
+
txRequestClone.gasPrice = (0, import_math15.bn)(0);
|
4216
|
+
txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
4149
4217
|
const result = await this.estimateTxDependencies(txRequestClone);
|
4150
4218
|
receipts = result.receipts;
|
4151
4219
|
outputVariables = result.outputVariables;
|
@@ -4201,17 +4269,17 @@ var _Provider = class {
|
|
4201
4269
|
const result = await this.operations.getCoins({
|
4202
4270
|
first: 10,
|
4203
4271
|
...paginationArgs,
|
4204
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
4272
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
4205
4273
|
});
|
4206
4274
|
const coins = result.coins.edges.map((edge) => edge.node);
|
4207
4275
|
return coins.map((coin) => ({
|
4208
4276
|
id: coin.utxoId,
|
4209
4277
|
assetId: coin.assetId,
|
4210
|
-
amount: (0,
|
4278
|
+
amount: (0, import_math15.bn)(coin.amount),
|
4211
4279
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4212
|
-
maturity: (0,
|
4213
|
-
blockCreated: (0,
|
4214
|
-
txCreatedIdx: (0,
|
4280
|
+
maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
|
4281
|
+
blockCreated: (0, import_math15.bn)(coin.blockCreated),
|
4282
|
+
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
4215
4283
|
}));
|
4216
4284
|
}
|
4217
4285
|
/**
|
@@ -4225,19 +4293,19 @@ var _Provider = class {
|
|
4225
4293
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4226
4294
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4227
4295
|
const excludeInput = {
|
4228
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
4229
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
4296
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
|
4297
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
|
4230
4298
|
};
|
4231
4299
|
if (this.cache) {
|
4232
4300
|
const uniqueUtxos = new Set(
|
4233
|
-
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0,
|
4301
|
+
excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
|
4234
4302
|
);
|
4235
4303
|
excludeInput.utxos = Array.from(uniqueUtxos);
|
4236
4304
|
}
|
4237
4305
|
const coinsQuery = {
|
4238
4306
|
owner: ownerAddress.toB256(),
|
4239
4307
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4240
|
-
assetId: (0,
|
4308
|
+
assetId: (0, import_utils23.hexlify)(assetId),
|
4241
4309
|
amount: amount.toString(10),
|
4242
4310
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4243
4311
|
})),
|
@@ -4248,9 +4316,9 @@ var _Provider = class {
|
|
4248
4316
|
switch (coin.__typename) {
|
4249
4317
|
case "MessageCoin":
|
4250
4318
|
return {
|
4251
|
-
amount: (0,
|
4319
|
+
amount: (0, import_math15.bn)(coin.amount),
|
4252
4320
|
assetId: coin.assetId,
|
4253
|
-
daHeight: (0,
|
4321
|
+
daHeight: (0, import_math15.bn)(coin.daHeight),
|
4254
4322
|
sender: import_address3.Address.fromAddressOrString(coin.sender),
|
4255
4323
|
recipient: import_address3.Address.fromAddressOrString(coin.recipient),
|
4256
4324
|
nonce: coin.nonce
|
@@ -4258,12 +4326,12 @@ var _Provider = class {
|
|
4258
4326
|
case "Coin":
|
4259
4327
|
return {
|
4260
4328
|
id: coin.utxoId,
|
4261
|
-
amount: (0,
|
4329
|
+
amount: (0, import_math15.bn)(coin.amount),
|
4262
4330
|
assetId: coin.assetId,
|
4263
4331
|
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4264
|
-
maturity: (0,
|
4265
|
-
blockCreated: (0,
|
4266
|
-
txCreatedIdx: (0,
|
4332
|
+
maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
|
4333
|
+
blockCreated: (0, import_math15.bn)(coin.blockCreated),
|
4334
|
+
txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
|
4267
4335
|
};
|
4268
4336
|
default:
|
4269
4337
|
return null;
|
@@ -4280,13 +4348,13 @@ var _Provider = class {
|
|
4280
4348
|
async getBlock(idOrHeight) {
|
4281
4349
|
let variables;
|
4282
4350
|
if (typeof idOrHeight === "number") {
|
4283
|
-
variables = { height: (0,
|
4351
|
+
variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
|
4284
4352
|
} else if (idOrHeight === "latest") {
|
4285
4353
|
variables = { height: (await this.getBlockNumber()).toString(10) };
|
4286
4354
|
} else if (idOrHeight.length === 66) {
|
4287
4355
|
variables = { blockId: idOrHeight };
|
4288
4356
|
} else {
|
4289
|
-
variables = { blockId: (0,
|
4357
|
+
variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
|
4290
4358
|
}
|
4291
4359
|
const { block } = await this.operations.getBlock(variables);
|
4292
4360
|
if (!block) {
|
@@ -4294,7 +4362,7 @@ var _Provider = class {
|
|
4294
4362
|
}
|
4295
4363
|
return {
|
4296
4364
|
id: block.id,
|
4297
|
-
height: (0,
|
4365
|
+
height: (0, import_math15.bn)(block.header.height),
|
4298
4366
|
time: block.header.time,
|
4299
4367
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4300
4368
|
};
|
@@ -4309,7 +4377,7 @@ var _Provider = class {
|
|
4309
4377
|
const { blocks: fetchedData } = await this.operations.getBlocks(params);
|
4310
4378
|
const blocks = fetchedData.edges.map(({ node: block }) => ({
|
4311
4379
|
id: block.id,
|
4312
|
-
height: (0,
|
4380
|
+
height: (0, import_math15.bn)(block.header.height),
|
4313
4381
|
time: block.header.time,
|
4314
4382
|
transactionIds: block.transactions.map((tx) => tx.id)
|
4315
4383
|
}));
|
@@ -4324,7 +4392,7 @@ var _Provider = class {
|
|
4324
4392
|
async getBlockWithTransactions(idOrHeight) {
|
4325
4393
|
let variables;
|
4326
4394
|
if (typeof idOrHeight === "number") {
|
4327
|
-
variables = { blockHeight: (0,
|
4395
|
+
variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
|
4328
4396
|
} else if (idOrHeight === "latest") {
|
4329
4397
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
4330
4398
|
} else {
|
@@ -4336,11 +4404,11 @@ var _Provider = class {
|
|
4336
4404
|
}
|
4337
4405
|
return {
|
4338
4406
|
id: block.id,
|
4339
|
-
height: (0,
|
4407
|
+
height: (0, import_math15.bn)(block.header.height, 10),
|
4340
4408
|
time: block.header.time,
|
4341
4409
|
transactionIds: block.transactions.map((tx) => tx.id),
|
4342
4410
|
transactions: block.transactions.map(
|
4343
|
-
(tx) => new
|
4411
|
+
(tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
|
4344
4412
|
)
|
4345
4413
|
};
|
4346
4414
|
}
|
@@ -4355,8 +4423,8 @@ var _Provider = class {
|
|
4355
4423
|
if (!transaction) {
|
4356
4424
|
return null;
|
4357
4425
|
}
|
4358
|
-
return new
|
4359
|
-
(0,
|
4426
|
+
return new import_transactions18.TransactionCoder().decode(
|
4427
|
+
(0, import_utils23.arrayify)(transaction.rawPayload),
|
4360
4428
|
0
|
4361
4429
|
)?.[0];
|
4362
4430
|
}
|
@@ -4383,9 +4451,9 @@ var _Provider = class {
|
|
4383
4451
|
async getContractBalance(contractId, assetId) {
|
4384
4452
|
const { contractBalance } = await this.operations.getContractBalance({
|
4385
4453
|
contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
|
4386
|
-
asset: (0,
|
4454
|
+
asset: (0, import_utils23.hexlify)(assetId)
|
4387
4455
|
});
|
4388
|
-
return (0,
|
4456
|
+
return (0, import_math15.bn)(contractBalance.amount, 10);
|
4389
4457
|
}
|
4390
4458
|
/**
|
4391
4459
|
* Returns the balance for the given owner for the given asset ID.
|
@@ -4397,9 +4465,9 @@ var _Provider = class {
|
|
4397
4465
|
async getBalance(owner, assetId) {
|
4398
4466
|
const { balance } = await this.operations.getBalance({
|
4399
4467
|
owner: import_address3.Address.fromAddressOrString(owner).toB256(),
|
4400
|
-
assetId: (0,
|
4468
|
+
assetId: (0, import_utils23.hexlify)(assetId)
|
4401
4469
|
});
|
4402
|
-
return (0,
|
4470
|
+
return (0, import_math15.bn)(balance.amount, 10);
|
4403
4471
|
}
|
4404
4472
|
/**
|
4405
4473
|
* Returns balances for the given owner.
|
@@ -4417,7 +4485,7 @@ var _Provider = class {
|
|
4417
4485
|
const balances = result.balances.edges.map((edge) => edge.node);
|
4418
4486
|
return balances.map((balance) => ({
|
4419
4487
|
assetId: balance.assetId,
|
4420
|
-
amount: (0,
|
4488
|
+
amount: (0, import_math15.bn)(balance.amount)
|
4421
4489
|
}));
|
4422
4490
|
}
|
4423
4491
|
/**
|
@@ -4435,19 +4503,19 @@ var _Provider = class {
|
|
4435
4503
|
});
|
4436
4504
|
const messages = result.messages.edges.map((edge) => edge.node);
|
4437
4505
|
return messages.map((message) => ({
|
4438
|
-
messageId:
|
4506
|
+
messageId: import_transactions18.InputMessageCoder.getMessageId({
|
4439
4507
|
sender: message.sender,
|
4440
4508
|
recipient: message.recipient,
|
4441
4509
|
nonce: message.nonce,
|
4442
|
-
amount: (0,
|
4510
|
+
amount: (0, import_math15.bn)(message.amount),
|
4443
4511
|
data: message.data
|
4444
4512
|
}),
|
4445
4513
|
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4446
4514
|
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4447
4515
|
nonce: message.nonce,
|
4448
|
-
amount: (0,
|
4449
|
-
data:
|
4450
|
-
daHeight: (0,
|
4516
|
+
amount: (0, import_math15.bn)(message.amount),
|
4517
|
+
data: import_transactions18.InputMessageCoder.decodeData(message.data),
|
4518
|
+
daHeight: (0, import_math15.bn)(message.daHeight)
|
4451
4519
|
}));
|
4452
4520
|
}
|
4453
4521
|
/**
|
@@ -4465,8 +4533,8 @@ var _Provider = class {
|
|
4465
4533
|
nonce
|
4466
4534
|
};
|
4467
4535
|
if (commitBlockId && commitBlockHeight) {
|
4468
|
-
throw new
|
4469
|
-
|
4536
|
+
throw new import_errors14.FuelError(
|
4537
|
+
import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4470
4538
|
"commitBlockId and commitBlockHeight cannot be used together"
|
4471
4539
|
);
|
4472
4540
|
}
|
@@ -4500,41 +4568,41 @@ var _Provider = class {
|
|
4500
4568
|
} = result.messageProof;
|
4501
4569
|
return {
|
4502
4570
|
messageProof: {
|
4503
|
-
proofIndex: (0,
|
4571
|
+
proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
|
4504
4572
|
proofSet: messageProof.proofSet
|
4505
4573
|
},
|
4506
4574
|
blockProof: {
|
4507
|
-
proofIndex: (0,
|
4575
|
+
proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
|
4508
4576
|
proofSet: blockProof.proofSet
|
4509
4577
|
},
|
4510
4578
|
messageBlockHeader: {
|
4511
4579
|
id: messageBlockHeader.id,
|
4512
|
-
daHeight: (0,
|
4513
|
-
transactionsCount: (0,
|
4580
|
+
daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
|
4581
|
+
transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
|
4514
4582
|
transactionsRoot: messageBlockHeader.transactionsRoot,
|
4515
|
-
height: (0,
|
4583
|
+
height: (0, import_math15.bn)(messageBlockHeader.height),
|
4516
4584
|
prevRoot: messageBlockHeader.prevRoot,
|
4517
4585
|
time: messageBlockHeader.time,
|
4518
4586
|
applicationHash: messageBlockHeader.applicationHash,
|
4519
4587
|
messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
|
4520
|
-
messageReceiptCount: (0,
|
4588
|
+
messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
|
4521
4589
|
},
|
4522
4590
|
commitBlockHeader: {
|
4523
4591
|
id: commitBlockHeader.id,
|
4524
|
-
daHeight: (0,
|
4525
|
-
transactionsCount: (0,
|
4592
|
+
daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
|
4593
|
+
transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
|
4526
4594
|
transactionsRoot: commitBlockHeader.transactionsRoot,
|
4527
|
-
height: (0,
|
4595
|
+
height: (0, import_math15.bn)(commitBlockHeader.height),
|
4528
4596
|
prevRoot: commitBlockHeader.prevRoot,
|
4529
4597
|
time: commitBlockHeader.time,
|
4530
4598
|
applicationHash: commitBlockHeader.applicationHash,
|
4531
4599
|
messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
|
4532
|
-
messageReceiptCount: (0,
|
4600
|
+
messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
|
4533
4601
|
},
|
4534
4602
|
sender: import_address3.Address.fromAddressOrString(sender),
|
4535
4603
|
recipient: import_address3.Address.fromAddressOrString(recipient),
|
4536
4604
|
nonce,
|
4537
|
-
amount: (0,
|
4605
|
+
amount: (0, import_math15.bn)(amount),
|
4538
4606
|
data
|
4539
4607
|
};
|
4540
4608
|
}
|
@@ -4557,10 +4625,10 @@ var _Provider = class {
|
|
4557
4625
|
*/
|
4558
4626
|
async produceBlocks(amount, startTime) {
|
4559
4627
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
4560
|
-
blocksToProduce: (0,
|
4561
|
-
startTimestamp: startTime ?
|
4628
|
+
blocksToProduce: (0, import_math15.bn)(amount).toString(10),
|
4629
|
+
startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
4562
4630
|
});
|
4563
|
-
return (0,
|
4631
|
+
return (0, import_math15.bn)(latestBlockHeight);
|
4564
4632
|
}
|
4565
4633
|
// eslint-disable-next-line @typescript-eslint/require-await
|
4566
4634
|
async getTransactionResponse(transactionId) {
|
@@ -4574,7 +4642,7 @@ cacheInputs_fn = function(inputs) {
|
|
4574
4642
|
return;
|
4575
4643
|
}
|
4576
4644
|
inputs.forEach((input) => {
|
4577
|
-
if (input.type ===
|
4645
|
+
if (input.type === import_transactions18.InputType.Coin) {
|
4578
4646
|
this.cache?.set(input.id);
|
4579
4647
|
}
|
4580
4648
|
});
|
@@ -4583,23 +4651,23 @@ __publicField(Provider, "chainInfoCache", {});
|
|
4583
4651
|
__publicField(Provider, "nodeInfoCache", {});
|
4584
4652
|
|
4585
4653
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
4586
|
-
var
|
4587
|
-
var
|
4588
|
-
var
|
4589
|
-
var
|
4654
|
+
var import_errors15 = require("@fuel-ts/errors");
|
4655
|
+
var import_math16 = require("@fuel-ts/math");
|
4656
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
4657
|
+
var import_utils26 = require("@fuel-ts/utils");
|
4590
4658
|
async function getTransactionSummary(params) {
|
4591
4659
|
const { id, provider, abiMap } = params;
|
4592
4660
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
4593
4661
|
transactionId: id
|
4594
4662
|
});
|
4595
4663
|
if (!gqlTransaction) {
|
4596
|
-
throw new
|
4597
|
-
|
4664
|
+
throw new import_errors15.FuelError(
|
4665
|
+
import_errors15.ErrorCode.TRANSACTION_NOT_FOUND,
|
4598
4666
|
`Transaction not found for given id: ${id}.`
|
4599
4667
|
);
|
4600
4668
|
}
|
4601
|
-
const [decodedTransaction] = new
|
4602
|
-
(0,
|
4669
|
+
const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
|
4670
|
+
(0, import_utils26.arrayify)(gqlTransaction.rawPayload),
|
4603
4671
|
0
|
4604
4672
|
);
|
4605
4673
|
const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
|
@@ -4610,10 +4678,10 @@ async function getTransactionSummary(params) {
|
|
4610
4678
|
id: gqlTransaction.id,
|
4611
4679
|
receipts,
|
4612
4680
|
transaction: decodedTransaction,
|
4613
|
-
transactionBytes: (0,
|
4681
|
+
transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
|
4614
4682
|
gqlTransactionStatus: gqlTransaction.status,
|
4615
|
-
gasPerByte: (0,
|
4616
|
-
gasPriceFactor: (0,
|
4683
|
+
gasPerByte: (0, import_math16.bn)(gasPerByte),
|
4684
|
+
gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
|
4617
4685
|
abiMap,
|
4618
4686
|
maxInputs,
|
4619
4687
|
gasCosts
|
@@ -4652,13 +4720,13 @@ async function getTransactionsSummaries(params) {
|
|
4652
4720
|
const transactions = edges.map((edge) => {
|
4653
4721
|
const { node: gqlTransaction } = edge;
|
4654
4722
|
const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
|
4655
|
-
const [decodedTransaction] = new
|
4723
|
+
const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
|
4656
4724
|
const receipts = gqlReceipts?.map(processGqlReceipt) || [];
|
4657
4725
|
const transactionSummary = assembleTransactionSummary({
|
4658
4726
|
id,
|
4659
4727
|
receipts,
|
4660
4728
|
transaction: decodedTransaction,
|
4661
|
-
transactionBytes: (0,
|
4729
|
+
transactionBytes: (0, import_utils26.arrayify)(rawPayload),
|
4662
4730
|
gqlTransactionStatus: status,
|
4663
4731
|
abiMap,
|
4664
4732
|
gasPerByte,
|
@@ -4801,17 +4869,17 @@ var assets = [
|
|
4801
4869
|
|
4802
4870
|
// src/utils/formatTransferToContractScriptData.ts
|
4803
4871
|
var import_abi_coder4 = require("@fuel-ts/abi-coder");
|
4804
|
-
var
|
4805
|
-
var
|
4872
|
+
var import_math17 = require("@fuel-ts/math");
|
4873
|
+
var import_utils27 = require("@fuel-ts/utils");
|
4806
4874
|
var asm = __toESM(require("@fuels/vm-asm"));
|
4807
4875
|
var formatTransferToContractScriptData = (params) => {
|
4808
4876
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
4809
4877
|
const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
|
4810
|
-
const encoded = numberCoder.encode(new
|
4878
|
+
const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
|
4811
4879
|
const scriptData = Uint8Array.from([
|
4812
|
-
...(0,
|
4880
|
+
...(0, import_utils27.arrayify)(hexlifiedContractId),
|
4813
4881
|
...encoded,
|
4814
|
-
...(0,
|
4882
|
+
...(0, import_utils27.arrayify)(assetId)
|
4815
4883
|
]);
|
4816
4884
|
return scriptData;
|
4817
4885
|
};
|
@@ -4867,7 +4935,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4867
4935
|
*/
|
4868
4936
|
get provider() {
|
4869
4937
|
if (!this._provider) {
|
4870
|
-
throw new
|
4938
|
+
throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
4871
4939
|
}
|
4872
4940
|
return this._provider;
|
4873
4941
|
}
|
@@ -4919,8 +4987,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4919
4987
|
if (!hasNextPage) {
|
4920
4988
|
break;
|
4921
4989
|
}
|
4922
|
-
throw new
|
4923
|
-
|
4990
|
+
throw new import_errors16.FuelError(
|
4991
|
+
import_errors16.ErrorCode.NOT_SUPPORTED,
|
4924
4992
|
`Wallets containing more than ${pageSize} coins exceed the current supported limit.`
|
4925
4993
|
);
|
4926
4994
|
}
|
@@ -4945,8 +5013,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4945
5013
|
if (!hasNextPage) {
|
4946
5014
|
break;
|
4947
5015
|
}
|
4948
|
-
throw new
|
4949
|
-
|
5016
|
+
throw new import_errors16.FuelError(
|
5017
|
+
import_errors16.ErrorCode.NOT_SUPPORTED,
|
4950
5018
|
`Wallets containing more than ${pageSize} messages exceed the current supported limit.`
|
4951
5019
|
);
|
4952
5020
|
}
|
@@ -4958,9 +5026,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4958
5026
|
* @param assetId - The asset ID to check the balance for.
|
4959
5027
|
* @returns A promise that resolves to the balance amount.
|
4960
5028
|
*/
|
4961
|
-
async getBalance(assetId) {
|
4962
|
-
const
|
4963
|
-
const amount = await this.provider.getBalance(this.address, assetIdToFetch);
|
5029
|
+
async getBalance(assetId = import_configs12.BaseAssetId) {
|
5030
|
+
const amount = await this.provider.getBalance(this.address, assetId);
|
4964
5031
|
return amount;
|
4965
5032
|
}
|
4966
5033
|
/**
|
@@ -4982,8 +5049,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4982
5049
|
if (!hasNextPage) {
|
4983
5050
|
break;
|
4984
5051
|
}
|
4985
|
-
throw new
|
4986
|
-
|
5052
|
+
throw new import_errors16.FuelError(
|
5053
|
+
import_errors16.ErrorCode.NOT_SUPPORTED,
|
4987
5054
|
`Wallets containing more than ${pageSize} balances exceed the current supported limit.`
|
4988
5055
|
);
|
4989
5056
|
}
|
@@ -4998,17 +5065,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
4998
5065
|
* @returns A promise that resolves when the resources are added to the transaction.
|
4999
5066
|
*/
|
5000
5067
|
async fund(request, coinQuantities, fee) {
|
5001
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
5002
5068
|
const updatedQuantities = addAmountToAsset({
|
5003
|
-
amount: (0,
|
5004
|
-
assetId:
|
5069
|
+
amount: (0, import_math18.bn)(fee),
|
5070
|
+
assetId: import_configs12.BaseAssetId,
|
5005
5071
|
coinQuantities
|
5006
5072
|
});
|
5007
5073
|
const quantitiesDict = {};
|
5008
5074
|
updatedQuantities.forEach(({ amount, assetId }) => {
|
5009
5075
|
quantitiesDict[assetId] = {
|
5010
5076
|
required: amount,
|
5011
|
-
owned: (0,
|
5077
|
+
owned: (0, import_math18.bn)(0)
|
5012
5078
|
};
|
5013
5079
|
});
|
5014
5080
|
const cachedUtxos = [];
|
@@ -5021,12 +5087,12 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5021
5087
|
if (isCoin2) {
|
5022
5088
|
const assetId = String(input.assetId);
|
5023
5089
|
if (input.owner === owner && quantitiesDict[assetId]) {
|
5024
|
-
const amount = (0,
|
5090
|
+
const amount = (0, import_math18.bn)(input.amount);
|
5025
5091
|
quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
|
5026
5092
|
cachedUtxos.push(input.id);
|
5027
5093
|
}
|
5028
|
-
} else if (input.recipient === owner && input.amount && quantitiesDict[
|
5029
|
-
quantitiesDict[
|
5094
|
+
} else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
|
5095
|
+
quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
|
5030
5096
|
cachedMessages.push(input.nonce);
|
5031
5097
|
}
|
5032
5098
|
}
|
@@ -5058,18 +5124,17 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5058
5124
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
5059
5125
|
* @returns A promise that resolves to the prepared transaction request.
|
5060
5126
|
*/
|
5061
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
5127
|
+
async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
5062
5128
|
const { minGasPrice } = this.provider.getGasConfig();
|
5063
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5064
5129
|
const params = { gasPrice: minGasPrice, ...txParams };
|
5065
5130
|
const request = new ScriptTransactionRequest(params);
|
5066
|
-
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount,
|
5131
|
+
request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
|
5067
5132
|
const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
|
5068
5133
|
estimateTxDependencies: true,
|
5069
5134
|
resourcesOwner: this
|
5070
5135
|
});
|
5071
|
-
request.gasPrice = (0,
|
5072
|
-
request.gasLimit = (0,
|
5136
|
+
request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
|
5137
|
+
request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
|
5073
5138
|
this.validateGas({
|
5074
5139
|
gasUsed,
|
5075
5140
|
gasPrice: request.gasPrice,
|
@@ -5089,15 +5154,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5089
5154
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
5090
5155
|
* @returns A promise that resolves to the transaction response.
|
5091
5156
|
*/
|
5092
|
-
async transfer(destination, amount, assetId, txParams = {}) {
|
5093
|
-
if ((0,
|
5094
|
-
throw new
|
5095
|
-
|
5157
|
+
async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
5158
|
+
if ((0, import_math18.bn)(amount).lte(0)) {
|
5159
|
+
throw new import_errors16.FuelError(
|
5160
|
+
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5096
5161
|
"Transfer amount must be a positive number."
|
5097
5162
|
);
|
5098
5163
|
}
|
5099
|
-
const
|
5100
|
-
const request = await this.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
5164
|
+
const request = await this.createTransfer(destination, amount, assetId, txParams);
|
5101
5165
|
return this.sendTransaction(request, { estimateTxDependencies: false });
|
5102
5166
|
}
|
5103
5167
|
/**
|
@@ -5109,21 +5173,20 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5109
5173
|
* @param txParams - The optional transaction parameters.
|
5110
5174
|
* @returns A promise that resolves to the transaction response.
|
5111
5175
|
*/
|
5112
|
-
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
5113
|
-
if ((0,
|
5114
|
-
throw new
|
5115
|
-
|
5176
|
+
async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
|
5177
|
+
if ((0, import_math18.bn)(amount).lte(0)) {
|
5178
|
+
throw new import_errors16.FuelError(
|
5179
|
+
import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
5116
5180
|
"Transfer amount must be a positive number."
|
5117
5181
|
);
|
5118
5182
|
}
|
5119
5183
|
const contractAddress = import_address4.Address.fromAddressOrString(contractId);
|
5120
5184
|
const { minGasPrice } = this.provider.getGasConfig();
|
5121
|
-
const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
|
5122
5185
|
const params = { gasPrice: minGasPrice, ...txParams };
|
5123
5186
|
const { script, scriptData } = await assembleTransferToContractScript({
|
5124
5187
|
hexlifiedContractId: contractAddress.toB256(),
|
5125
|
-
amountToTransfer: (0,
|
5126
|
-
assetId
|
5188
|
+
amountToTransfer: (0, import_math18.bn)(amount),
|
5189
|
+
assetId
|
5127
5190
|
});
|
5128
5191
|
const request = new ScriptTransactionRequest({
|
5129
5192
|
...params,
|
@@ -5133,9 +5196,9 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5133
5196
|
request.addContractInputAndOutput(contractAddress);
|
5134
5197
|
const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
|
5135
5198
|
request,
|
5136
|
-
[{ amount: (0,
|
5199
|
+
[{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
|
5137
5200
|
);
|
5138
|
-
request.gasLimit = (0,
|
5201
|
+
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
5139
5202
|
this.validateGas({
|
5140
5203
|
gasUsed,
|
5141
5204
|
gasPrice: request.gasPrice,
|
@@ -5155,27 +5218,26 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5155
5218
|
*/
|
5156
5219
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
5157
5220
|
const { minGasPrice } = this.provider.getGasConfig();
|
5158
|
-
const baseAssetId = this.provider.getBaseAssetId();
|
5159
5221
|
const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
|
5160
|
-
const recipientDataArray = (0,
|
5222
|
+
const recipientDataArray = (0, import_utils28.arrayify)(
|
5161
5223
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
5162
5224
|
);
|
5163
|
-
const amountDataArray = (0,
|
5164
|
-
"0x".concat((0,
|
5225
|
+
const amountDataArray = (0, import_utils28.arrayify)(
|
5226
|
+
"0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
5165
5227
|
);
|
5166
5228
|
const script = new Uint8Array([
|
5167
|
-
...(0,
|
5229
|
+
...(0, import_utils28.arrayify)(withdrawScript.bytes),
|
5168
5230
|
...recipientDataArray,
|
5169
5231
|
...amountDataArray
|
5170
5232
|
]);
|
5171
5233
|
const params = { script, gasPrice: minGasPrice, ...txParams };
|
5172
5234
|
const request = new ScriptTransactionRequest(params);
|
5173
|
-
const forwardingQuantities = [{ amount: (0,
|
5235
|
+
const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
|
5174
5236
|
const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
|
5175
5237
|
request,
|
5176
5238
|
forwardingQuantities
|
5177
5239
|
);
|
5178
|
-
request.gasLimit = (0,
|
5240
|
+
request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
|
5179
5241
|
this.validateGas({
|
5180
5242
|
gasUsed,
|
5181
5243
|
gasPrice: request.gasPrice,
|
@@ -5187,7 +5249,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5187
5249
|
}
|
5188
5250
|
async signMessage(message) {
|
5189
5251
|
if (!this._connector) {
|
5190
|
-
throw new
|
5252
|
+
throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
5191
5253
|
}
|
5192
5254
|
return this._connector.signMessage(this.address.toString(), message);
|
5193
5255
|
}
|
@@ -5199,8 +5261,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5199
5261
|
*/
|
5200
5262
|
async signTransaction(transactionRequestLike) {
|
5201
5263
|
if (!this._connector) {
|
5202
|
-
throw new
|
5203
|
-
|
5264
|
+
throw new import_errors16.FuelError(
|
5265
|
+
import_errors16.ErrorCode.MISSING_CONNECTOR,
|
5204
5266
|
"A connector is required to sign transactions."
|
5205
5267
|
);
|
5206
5268
|
}
|
@@ -5247,14 +5309,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5247
5309
|
minGasPrice
|
5248
5310
|
}) {
|
5249
5311
|
if (minGasPrice.gt(gasPrice)) {
|
5250
|
-
throw new
|
5251
|
-
|
5312
|
+
throw new import_errors16.FuelError(
|
5313
|
+
import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
|
5252
5314
|
`Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
|
5253
5315
|
);
|
5254
5316
|
}
|
5255
5317
|
if (gasUsed.gt(gasLimit)) {
|
5256
|
-
throw new
|
5257
|
-
|
5318
|
+
throw new import_errors16.FuelError(
|
5319
|
+
import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
|
5258
5320
|
`Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
|
5259
5321
|
);
|
5260
5322
|
}
|
@@ -5263,14 +5325,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5263
5325
|
|
5264
5326
|
// src/wallet/base-wallet-unlocked.ts
|
5265
5327
|
var import_hasher3 = require("@fuel-ts/hasher");
|
5266
|
-
var
|
5328
|
+
var import_utils31 = require("@fuel-ts/utils");
|
5267
5329
|
|
5268
5330
|
// src/signer/signer.ts
|
5269
5331
|
var import_address5 = require("@fuel-ts/address");
|
5270
5332
|
var import_crypto = require("@fuel-ts/crypto");
|
5271
5333
|
var import_hasher2 = require("@fuel-ts/hasher");
|
5272
|
-
var
|
5273
|
-
var
|
5334
|
+
var import_math19 = require("@fuel-ts/math");
|
5335
|
+
var import_utils29 = require("@fuel-ts/utils");
|
5274
5336
|
var import_secp256k1 = require("@noble/curves/secp256k1");
|
5275
5337
|
var Signer = class {
|
5276
5338
|
address;
|
@@ -5289,10 +5351,10 @@ var Signer = class {
|
|
5289
5351
|
privateKey = `0x${privateKey}`;
|
5290
5352
|
}
|
5291
5353
|
}
|
5292
|
-
const privateKeyBytes = (0,
|
5293
|
-
this.privateKey = (0,
|
5294
|
-
this.publicKey = (0,
|
5295
|
-
this.compressedPublicKey = (0,
|
5354
|
+
const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
|
5355
|
+
this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
|
5356
|
+
this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
5357
|
+
this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
5296
5358
|
this.address = import_address5.Address.fromPublicKey(this.publicKey);
|
5297
5359
|
}
|
5298
5360
|
/**
|
@@ -5306,11 +5368,11 @@ var Signer = class {
|
|
5306
5368
|
* @returns hashed signature
|
5307
5369
|
*/
|
5308
5370
|
sign(data) {
|
5309
|
-
const signature = import_secp256k1.secp256k1.sign((0,
|
5310
|
-
const r = (0,
|
5311
|
-
const s = (0,
|
5371
|
+
const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
|
5372
|
+
const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
|
5373
|
+
const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
|
5312
5374
|
s[0] |= (signature.recovery || 0) << 7;
|
5313
|
-
return (0,
|
5375
|
+
return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
|
5314
5376
|
}
|
5315
5377
|
/**
|
5316
5378
|
* Add point on the current elliptic curve
|
@@ -5319,8 +5381,8 @@ var Signer = class {
|
|
5319
5381
|
* @returns compressed point on the curve
|
5320
5382
|
*/
|
5321
5383
|
addPoint(point) {
|
5322
|
-
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5323
|
-
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5384
|
+
const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
|
5385
|
+
const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
|
5324
5386
|
const result = p0.add(p1);
|
5325
5387
|
return `0x${result.toHex(true)}`;
|
5326
5388
|
}
|
@@ -5332,16 +5394,16 @@ var Signer = class {
|
|
5332
5394
|
* @returns public key from signature from the
|
5333
5395
|
*/
|
5334
5396
|
static recoverPublicKey(data, signature) {
|
5335
|
-
const signedMessageBytes = (0,
|
5397
|
+
const signedMessageBytes = (0, import_utils29.arrayify)(signature);
|
5336
5398
|
const r = signedMessageBytes.slice(0, 32);
|
5337
5399
|
const s = signedMessageBytes.slice(32, 64);
|
5338
5400
|
const recoveryParam = (s[0] & 128) >> 7;
|
5339
5401
|
s[0] &= 127;
|
5340
|
-
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0,
|
5402
|
+
const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
|
5341
5403
|
recoveryParam
|
5342
5404
|
);
|
5343
|
-
const publicKey = sig.recoverPublicKey((0,
|
5344
|
-
return (0,
|
5405
|
+
const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
|
5406
|
+
return (0, import_utils29.hexlify)(publicKey);
|
5345
5407
|
}
|
5346
5408
|
/**
|
5347
5409
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -5360,7 +5422,7 @@ var Signer = class {
|
|
5360
5422
|
* @returns random 32-byte hashed
|
5361
5423
|
*/
|
5362
5424
|
static generatePrivateKey(entropy) {
|
5363
|
-
return entropy ? (0, import_hasher2.hash)((0,
|
5425
|
+
return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
|
5364
5426
|
}
|
5365
5427
|
/**
|
5366
5428
|
* Extended publicKey from a compact publicKey
|
@@ -5369,16 +5431,16 @@ var Signer = class {
|
|
5369
5431
|
* @returns extended publicKey
|
5370
5432
|
*/
|
5371
5433
|
static extendPublicKey(publicKey) {
|
5372
|
-
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0,
|
5373
|
-
return (0,
|
5434
|
+
const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
|
5435
|
+
return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
|
5374
5436
|
}
|
5375
5437
|
};
|
5376
5438
|
|
5377
5439
|
// src/wallet/keystore-wallet.ts
|
5378
5440
|
var import_address6 = require("@fuel-ts/address");
|
5379
5441
|
var import_crypto2 = require("@fuel-ts/crypto");
|
5380
|
-
var
|
5381
|
-
var
|
5442
|
+
var import_errors17 = require("@fuel-ts/errors");
|
5443
|
+
var import_utils30 = require("@fuel-ts/utils");
|
5382
5444
|
var import_uuid = require("uuid");
|
5383
5445
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
5384
5446
|
var DEFAULT_KDF_PARAMS_R = 8;
|
@@ -5455,13 +5517,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
5455
5517
|
const macHashUint8Array = (0, import_crypto2.keccak256)(data);
|
5456
5518
|
const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
|
5457
5519
|
if (mac !== macHash) {
|
5458
|
-
throw new
|
5459
|
-
|
5520
|
+
throw new import_errors17.FuelError(
|
5521
|
+
import_errors17.ErrorCode.INVALID_PASSWORD,
|
5460
5522
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
5461
5523
|
);
|
5462
5524
|
}
|
5463
5525
|
const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
5464
|
-
const privateKey = (0,
|
5526
|
+
const privateKey = (0, import_utils30.hexlify)(buffer);
|
5465
5527
|
return privateKey;
|
5466
5528
|
}
|
5467
5529
|
|
@@ -5506,7 +5568,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5506
5568
|
*/
|
5507
5569
|
async signMessage(message) {
|
5508
5570
|
const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
|
5509
|
-
return (0,
|
5571
|
+
return (0, import_utils31.hexlify)(signedMessage);
|
5510
5572
|
}
|
5511
5573
|
/**
|
5512
5574
|
* Signs a transaction with the wallet's private key.
|
@@ -5519,7 +5581,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
5519
5581
|
const chainId = this.provider.getChainId();
|
5520
5582
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
5521
5583
|
const signature = await this.signer().sign(hashedTransaction);
|
5522
|
-
return (0,
|
5584
|
+
return (0, import_utils31.hexlify)(signature);
|
5523
5585
|
}
|
5524
5586
|
/**
|
5525
5587
|
* Populates a transaction with the witnesses signature.
|
@@ -5578,17 +5640,17 @@ var BaseWalletUnlocked = class extends Account {
|
|
5578
5640
|
__publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
5579
5641
|
|
5580
5642
|
// src/hdwallet/hdwallet.ts
|
5581
|
-
var
|
5643
|
+
var import_errors20 = require("@fuel-ts/errors");
|
5582
5644
|
var import_hasher6 = require("@fuel-ts/hasher");
|
5583
|
-
var
|
5584
|
-
var
|
5645
|
+
var import_math20 = require("@fuel-ts/math");
|
5646
|
+
var import_utils35 = require("@fuel-ts/utils");
|
5585
5647
|
var import_ethers3 = require("ethers");
|
5586
5648
|
|
5587
5649
|
// src/mnemonic/mnemonic.ts
|
5588
5650
|
var import_crypto3 = require("@fuel-ts/crypto");
|
5589
|
-
var
|
5651
|
+
var import_errors19 = require("@fuel-ts/errors");
|
5590
5652
|
var import_hasher5 = require("@fuel-ts/hasher");
|
5591
|
-
var
|
5653
|
+
var import_utils33 = require("@fuel-ts/utils");
|
5592
5654
|
var import_ethers2 = require("ethers");
|
5593
5655
|
|
5594
5656
|
// src/wordlists/words/english.ts
|
@@ -7650,9 +7712,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
7650
7712
|
})(Language || {});
|
7651
7713
|
|
7652
7714
|
// src/mnemonic/utils.ts
|
7653
|
-
var
|
7715
|
+
var import_errors18 = require("@fuel-ts/errors");
|
7654
7716
|
var import_hasher4 = require("@fuel-ts/hasher");
|
7655
|
-
var
|
7717
|
+
var import_utils32 = require("@fuel-ts/utils");
|
7656
7718
|
function toUtf8Bytes(stri) {
|
7657
7719
|
const str = stri.normalize("NFKD");
|
7658
7720
|
const result = [];
|
@@ -7667,8 +7729,8 @@ function toUtf8Bytes(stri) {
|
|
7667
7729
|
i += 1;
|
7668
7730
|
const c2 = str.charCodeAt(i);
|
7669
7731
|
if (i >= str.length || (c2 & 64512) !== 56320) {
|
7670
|
-
throw new
|
7671
|
-
|
7732
|
+
throw new import_errors18.FuelError(
|
7733
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
7672
7734
|
"Invalid UTF-8 in the input string."
|
7673
7735
|
);
|
7674
7736
|
}
|
@@ -7719,20 +7781,20 @@ function entropyToMnemonicIndices(entropy) {
|
|
7719
7781
|
}
|
7720
7782
|
}
|
7721
7783
|
const checksumBits = entropy.length / 4;
|
7722
|
-
const checksum = (0,
|
7784
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
7723
7785
|
indices[indices.length - 1] <<= checksumBits;
|
7724
7786
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
7725
7787
|
return indices;
|
7726
7788
|
}
|
7727
7789
|
function mnemonicWordsToEntropy(words, wordlist) {
|
7728
7790
|
const size = Math.ceil(11 * words.length / 8);
|
7729
|
-
const entropy = (0,
|
7791
|
+
const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
|
7730
7792
|
let offset = 0;
|
7731
7793
|
for (let i = 0; i < words.length; i += 1) {
|
7732
7794
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
7733
7795
|
if (index === -1) {
|
7734
|
-
throw new
|
7735
|
-
|
7796
|
+
throw new import_errors18.FuelError(
|
7797
|
+
import_errors18.ErrorCode.INVALID_MNEMONIC,
|
7736
7798
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
7737
7799
|
);
|
7738
7800
|
}
|
@@ -7746,10 +7808,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
7746
7808
|
const entropyBits = 32 * words.length / 3;
|
7747
7809
|
const checksumBits = words.length / 3;
|
7748
7810
|
const checksumMask = getUpperMask(checksumBits);
|
7749
|
-
const checksum = (0,
|
7811
|
+
const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
7750
7812
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
7751
|
-
throw new
|
7752
|
-
|
7813
|
+
throw new import_errors18.FuelError(
|
7814
|
+
import_errors18.ErrorCode.INVALID_CHECKSUM,
|
7753
7815
|
"Checksum validation failed for the provided mnemonic."
|
7754
7816
|
);
|
7755
7817
|
}
|
@@ -7763,16 +7825,16 @@ var TestnetPRV = "0x04358394";
|
|
7763
7825
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
7764
7826
|
function assertWordList(wordlist) {
|
7765
7827
|
if (wordlist.length !== 2048) {
|
7766
|
-
throw new
|
7767
|
-
|
7828
|
+
throw new import_errors19.FuelError(
|
7829
|
+
import_errors19.ErrorCode.INVALID_WORD_LIST,
|
7768
7830
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
7769
7831
|
);
|
7770
7832
|
}
|
7771
7833
|
}
|
7772
7834
|
function assertEntropy(entropy) {
|
7773
7835
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
7774
|
-
throw new
|
7775
|
-
|
7836
|
+
throw new import_errors19.FuelError(
|
7837
|
+
import_errors19.ErrorCode.INVALID_ENTROPY,
|
7776
7838
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
7777
7839
|
);
|
7778
7840
|
}
|
@@ -7782,7 +7844,7 @@ function assertMnemonic(words) {
|
|
7782
7844
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
7783
7845
|
", "
|
7784
7846
|
)}] words, but got ${words.length}.`;
|
7785
|
-
throw new
|
7847
|
+
throw new import_errors19.FuelError(import_errors19.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
7786
7848
|
}
|
7787
7849
|
}
|
7788
7850
|
var Mnemonic = class {
|
@@ -7821,7 +7883,7 @@ var Mnemonic = class {
|
|
7821
7883
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
7822
7884
|
const words = getWords(phrase);
|
7823
7885
|
assertMnemonic(words);
|
7824
|
-
return (0,
|
7886
|
+
return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
7825
7887
|
}
|
7826
7888
|
/**
|
7827
7889
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -7829,7 +7891,7 @@ var Mnemonic = class {
|
|
7829
7891
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7830
7892
|
*/
|
7831
7893
|
static entropyToMnemonic(entropy, wordlist = english) {
|
7832
|
-
const entropyBytes = (0,
|
7894
|
+
const entropyBytes = (0, import_utils33.arrayify)(entropy);
|
7833
7895
|
assertWordList(wordlist);
|
7834
7896
|
assertEntropy(entropyBytes);
|
7835
7897
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -7898,14 +7960,14 @@ var Mnemonic = class {
|
|
7898
7960
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
7899
7961
|
*/
|
7900
7962
|
static masterKeysFromSeed(seed) {
|
7901
|
-
const seedArray = (0,
|
7963
|
+
const seedArray = (0, import_utils33.arrayify)(seed);
|
7902
7964
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
7903
|
-
throw new
|
7904
|
-
|
7965
|
+
throw new import_errors19.FuelError(
|
7966
|
+
import_errors19.ErrorCode.INVALID_SEED,
|
7905
7967
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
7906
7968
|
);
|
7907
7969
|
}
|
7908
|
-
return (0,
|
7970
|
+
return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
|
7909
7971
|
}
|
7910
7972
|
/**
|
7911
7973
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -7916,22 +7978,22 @@ var Mnemonic = class {
|
|
7916
7978
|
*/
|
7917
7979
|
static seedToExtendedKey(seed, testnet = false) {
|
7918
7980
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
7919
|
-
const prefix = (0,
|
7981
|
+
const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
7920
7982
|
const depth = "0x00";
|
7921
7983
|
const fingerprint = "0x00000000";
|
7922
7984
|
const index = "0x00000000";
|
7923
7985
|
const chainCode = masterKey.slice(32);
|
7924
7986
|
const privateKey = masterKey.slice(0, 32);
|
7925
|
-
const extendedKey = (0,
|
7987
|
+
const extendedKey = (0, import_utils33.concat)([
|
7926
7988
|
prefix,
|
7927
7989
|
depth,
|
7928
7990
|
fingerprint,
|
7929
7991
|
index,
|
7930
7992
|
chainCode,
|
7931
|
-
(0,
|
7993
|
+
(0, import_utils33.concat)(["0x00", privateKey])
|
7932
7994
|
]);
|
7933
7995
|
const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
|
7934
|
-
return (0, import_ethers2.encodeBase58)((0,
|
7996
|
+
return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
|
7935
7997
|
}
|
7936
7998
|
/**
|
7937
7999
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -7946,7 +8008,7 @@ var Mnemonic = class {
|
|
7946
8008
|
* @returns A randomly generated mnemonic
|
7947
8009
|
*/
|
7948
8010
|
static generate(size = 32, extraEntropy = "") {
|
7949
|
-
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0,
|
8011
|
+
const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
|
7950
8012
|
return Mnemonic.entropyToMnemonic(entropy);
|
7951
8013
|
}
|
7952
8014
|
};
|
@@ -7954,12 +8016,12 @@ var mnemonic_default = Mnemonic;
|
|
7954
8016
|
|
7955
8017
|
// src/hdwallet/hdwallet.ts
|
7956
8018
|
var HARDENED_INDEX = 2147483648;
|
7957
|
-
var MainnetPRV2 = (0,
|
7958
|
-
var MainnetPUB = (0,
|
7959
|
-
var TestnetPRV2 = (0,
|
7960
|
-
var TestnetPUB = (0,
|
8019
|
+
var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
|
8020
|
+
var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
|
8021
|
+
var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
|
8022
|
+
var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
|
7961
8023
|
function base58check(data) {
|
7962
|
-
return (0, import_ethers3.encodeBase58)((0,
|
8024
|
+
return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
|
7963
8025
|
}
|
7964
8026
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
7965
8027
|
if (isPublic) {
|
@@ -7968,17 +8030,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
7968
8030
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
7969
8031
|
}
|
7970
8032
|
function isPublicExtendedKey(extendedKey) {
|
7971
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
8033
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
|
7972
8034
|
}
|
7973
8035
|
function isValidExtendedKey(extendedKey) {
|
7974
8036
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
7975
|
-
(0,
|
8037
|
+
(0, import_utils35.hexlify)(extendedKey.slice(0, 4))
|
7976
8038
|
);
|
7977
8039
|
}
|
7978
8040
|
function parsePath(path, depth = 0) {
|
7979
8041
|
const components = path.split("/");
|
7980
8042
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
7981
|
-
throw new
|
8043
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
|
7982
8044
|
}
|
7983
8045
|
if (components[0] === "m") {
|
7984
8046
|
components.shift();
|
@@ -7990,8 +8052,8 @@ function parsePath(path, depth = 0) {
|
|
7990
8052
|
var HDWallet = class {
|
7991
8053
|
depth = 0;
|
7992
8054
|
index = 0;
|
7993
|
-
fingerprint = (0,
|
7994
|
-
parentFingerprint = (0,
|
8055
|
+
fingerprint = (0, import_utils35.hexlify)("0x00000000");
|
8056
|
+
parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
|
7995
8057
|
privateKey;
|
7996
8058
|
publicKey;
|
7997
8059
|
chainCode;
|
@@ -8003,16 +8065,16 @@ var HDWallet = class {
|
|
8003
8065
|
constructor(config) {
|
8004
8066
|
if (config.privateKey) {
|
8005
8067
|
const signer = new Signer(config.privateKey);
|
8006
|
-
this.publicKey = (0,
|
8007
|
-
this.privateKey = (0,
|
8068
|
+
this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
|
8069
|
+
this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
|
8008
8070
|
} else {
|
8009
8071
|
if (!config.publicKey) {
|
8010
|
-
throw new
|
8011
|
-
|
8072
|
+
throw new import_errors20.FuelError(
|
8073
|
+
import_errors20.ErrorCode.HD_WALLET_ERROR,
|
8012
8074
|
"Both public and private Key cannot be missing. At least one should be provided."
|
8013
8075
|
);
|
8014
8076
|
}
|
8015
|
-
this.publicKey = (0,
|
8077
|
+
this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
|
8016
8078
|
}
|
8017
8079
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
8018
8080
|
this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
|
@@ -8031,28 +8093,28 @@ var HDWallet = class {
|
|
8031
8093
|
* @returns A new instance of HDWallet on the derived index
|
8032
8094
|
*/
|
8033
8095
|
deriveIndex(index) {
|
8034
|
-
const privateKey = this.privateKey && (0,
|
8035
|
-
const publicKey = (0,
|
8036
|
-
const chainCode = (0,
|
8096
|
+
const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
|
8097
|
+
const publicKey = (0, import_utils35.arrayify)(this.publicKey);
|
8098
|
+
const chainCode = (0, import_utils35.arrayify)(this.chainCode);
|
8037
8099
|
const data = new Uint8Array(37);
|
8038
8100
|
if (index & HARDENED_INDEX) {
|
8039
8101
|
if (!privateKey) {
|
8040
|
-
throw new
|
8041
|
-
|
8102
|
+
throw new import_errors20.FuelError(
|
8103
|
+
import_errors20.ErrorCode.HD_WALLET_ERROR,
|
8042
8104
|
"Cannot derive a hardened index without a private Key."
|
8043
8105
|
);
|
8044
8106
|
}
|
8045
8107
|
data.set(privateKey, 1);
|
8046
8108
|
} else {
|
8047
|
-
data.set((0,
|
8109
|
+
data.set((0, import_utils35.arrayify)(this.publicKey));
|
8048
8110
|
}
|
8049
|
-
data.set((0,
|
8050
|
-
const bytes = (0,
|
8111
|
+
data.set((0, import_math20.toBytes)(index, 4), 33);
|
8112
|
+
const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
|
8051
8113
|
const IL = bytes.slice(0, 32);
|
8052
8114
|
const IR = bytes.slice(32);
|
8053
8115
|
if (privateKey) {
|
8054
8116
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
8055
|
-
const ki = (0,
|
8117
|
+
const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
|
8056
8118
|
return new HDWallet({
|
8057
8119
|
privateKey: ki,
|
8058
8120
|
chainCode: IR,
|
@@ -8061,7 +8123,7 @@ var HDWallet = class {
|
|
8061
8123
|
parentFingerprint: this.fingerprint
|
8062
8124
|
});
|
8063
8125
|
}
|
8064
|
-
const signer = new Signer((0,
|
8126
|
+
const signer = new Signer((0, import_utils35.hexlify)(IL));
|
8065
8127
|
const Ki = signer.addPoint(publicKey);
|
8066
8128
|
return new HDWallet({
|
8067
8129
|
publicKey: Ki,
|
@@ -8090,18 +8152,18 @@ var HDWallet = class {
|
|
8090
8152
|
*/
|
8091
8153
|
toExtendedKey(isPublic = false, testnet = false) {
|
8092
8154
|
if (this.depth >= 256) {
|
8093
|
-
throw new
|
8094
|
-
|
8155
|
+
throw new import_errors20.FuelError(
|
8156
|
+
import_errors20.ErrorCode.HD_WALLET_ERROR,
|
8095
8157
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
8096
8158
|
);
|
8097
8159
|
}
|
8098
8160
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
8099
|
-
const depth = (0,
|
8161
|
+
const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
|
8100
8162
|
const parentFingerprint = this.parentFingerprint;
|
8101
|
-
const index = (0,
|
8163
|
+
const index = (0, import_math20.toHex)(this.index, 4);
|
8102
8164
|
const chainCode = this.chainCode;
|
8103
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
8104
|
-
const extendedKey = (0,
|
8165
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
|
8166
|
+
const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
8105
8167
|
return base58check(extendedKey);
|
8106
8168
|
}
|
8107
8169
|
/**
|
@@ -8113,34 +8175,34 @@ var HDWallet = class {
|
|
8113
8175
|
static fromSeed(seed) {
|
8114
8176
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
8115
8177
|
return new HDWallet({
|
8116
|
-
chainCode: (0,
|
8117
|
-
privateKey: (0,
|
8178
|
+
chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
|
8179
|
+
privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
|
8118
8180
|
});
|
8119
8181
|
}
|
8120
8182
|
static fromExtendedKey(extendedKey) {
|
8121
8183
|
const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
|
8122
|
-
const bytes = (0,
|
8184
|
+
const bytes = (0, import_utils35.arrayify)(decoded);
|
8123
8185
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
8124
8186
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
8125
|
-
throw new
|
8187
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
8126
8188
|
}
|
8127
8189
|
if (!validChecksum) {
|
8128
|
-
throw new
|
8190
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
8129
8191
|
}
|
8130
8192
|
const depth = bytes[4];
|
8131
|
-
const parentFingerprint = (0,
|
8132
|
-
const index = parseInt((0,
|
8133
|
-
const chainCode = (0,
|
8193
|
+
const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
|
8194
|
+
const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
8195
|
+
const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
|
8134
8196
|
const key = bytes.slice(45, 78);
|
8135
8197
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
8136
|
-
throw new
|
8137
|
-
|
8198
|
+
throw new import_errors20.FuelError(
|
8199
|
+
import_errors20.ErrorCode.HD_WALLET_ERROR,
|
8138
8200
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
8139
8201
|
);
|
8140
8202
|
}
|
8141
8203
|
if (isPublicExtendedKey(bytes)) {
|
8142
8204
|
if (key[0] !== 3) {
|
8143
|
-
throw new
|
8205
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
8144
8206
|
}
|
8145
8207
|
return new HDWallet({
|
8146
8208
|
publicKey: key,
|
@@ -8151,7 +8213,7 @@ var HDWallet = class {
|
|
8151
8213
|
});
|
8152
8214
|
}
|
8153
8215
|
if (key[0] !== 0) {
|
8154
|
-
throw new
|
8216
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
8155
8217
|
}
|
8156
8218
|
return new HDWallet({
|
8157
8219
|
privateKey: key.slice(1),
|
@@ -8319,7 +8381,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
8319
8381
|
// src/wallet-manager/wallet-manager.ts
|
8320
8382
|
var import_address9 = require("@fuel-ts/address");
|
8321
8383
|
var import_crypto4 = require("@fuel-ts/crypto");
|
8322
|
-
var
|
8384
|
+
var import_errors23 = require("@fuel-ts/errors");
|
8323
8385
|
var import_events = require("events");
|
8324
8386
|
|
8325
8387
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -8342,7 +8404,7 @@ var MemoryStorage = class {
|
|
8342
8404
|
|
8343
8405
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
8344
8406
|
var import_address7 = require("@fuel-ts/address");
|
8345
|
-
var
|
8407
|
+
var import_errors21 = require("@fuel-ts/errors");
|
8346
8408
|
var _secret;
|
8347
8409
|
var MnemonicVault = class {
|
8348
8410
|
constructor(options) {
|
@@ -8398,8 +8460,8 @@ var MnemonicVault = class {
|
|
8398
8460
|
}
|
8399
8461
|
numberOfAccounts += 1;
|
8400
8462
|
} while (numberOfAccounts < this.numberOfAccounts);
|
8401
|
-
throw new
|
8402
|
-
|
8463
|
+
throw new import_errors21.FuelError(
|
8464
|
+
import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
|
8403
8465
|
`Account with address '${address}' not found in derived wallets.`
|
8404
8466
|
);
|
8405
8467
|
}
|
@@ -8413,7 +8475,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
8413
8475
|
|
8414
8476
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
8415
8477
|
var import_address8 = require("@fuel-ts/address");
|
8416
|
-
var
|
8478
|
+
var import_errors22 = require("@fuel-ts/errors");
|
8417
8479
|
var _privateKeys;
|
8418
8480
|
var PrivateKeyVault = class {
|
8419
8481
|
/**
|
@@ -8454,8 +8516,8 @@ var PrivateKeyVault = class {
|
|
8454
8516
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
8455
8517
|
);
|
8456
8518
|
if (!privateKey) {
|
8457
|
-
throw new
|
8458
|
-
|
8519
|
+
throw new import_errors22.FuelError(
|
8520
|
+
import_errors22.ErrorCode.WALLET_MANAGER_ERROR,
|
8459
8521
|
`No private key found for address '${address}'.`
|
8460
8522
|
);
|
8461
8523
|
}
|
@@ -8479,7 +8541,7 @@ var ERROR_MESSAGES = {
|
|
8479
8541
|
};
|
8480
8542
|
function assert(condition, message) {
|
8481
8543
|
if (!condition) {
|
8482
|
-
throw new
|
8544
|
+
throw new import_errors23.FuelError(import_errors23.ErrorCode.WALLET_MANAGER_ERROR, message);
|
8483
8545
|
}
|
8484
8546
|
}
|
8485
8547
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -8705,25 +8767,25 @@ deserializeVaults_fn = function(vaults) {
|
|
8705
8767
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
8706
8768
|
|
8707
8769
|
// src/wallet-manager/types.ts
|
8708
|
-
var
|
8770
|
+
var import_errors24 = require("@fuel-ts/errors");
|
8709
8771
|
var Vault = class {
|
8710
8772
|
constructor(_options) {
|
8711
|
-
throw new
|
8773
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
8712
8774
|
}
|
8713
8775
|
serialize() {
|
8714
|
-
throw new
|
8776
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
8715
8777
|
}
|
8716
8778
|
getAccounts() {
|
8717
|
-
throw new
|
8779
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
8718
8780
|
}
|
8719
8781
|
addAccount() {
|
8720
|
-
throw new
|
8782
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
8721
8783
|
}
|
8722
8784
|
exportAccount(_address) {
|
8723
|
-
throw new
|
8785
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
8724
8786
|
}
|
8725
8787
|
getWallet(_address) {
|
8726
|
-
throw new
|
8788
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
|
8727
8789
|
}
|
8728
8790
|
};
|
8729
8791
|
__publicField(Vault, "type");
|
@@ -8733,20 +8795,21 @@ var StorageAbstract = class {
|
|
8733
8795
|
// src/predicate/predicate.ts
|
8734
8796
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
8735
8797
|
var import_address10 = require("@fuel-ts/address");
|
8736
|
-
var
|
8737
|
-
var
|
8738
|
-
var
|
8798
|
+
var import_configs13 = require("@fuel-ts/address/configs");
|
8799
|
+
var import_errors25 = require("@fuel-ts/errors");
|
8800
|
+
var import_transactions20 = require("@fuel-ts/transactions");
|
8801
|
+
var import_utils37 = require("@fuel-ts/utils");
|
8739
8802
|
|
8740
8803
|
// src/predicate/utils/getPredicateRoot.ts
|
8741
8804
|
var import_hasher7 = require("@fuel-ts/hasher");
|
8742
8805
|
var import_merkle = require("@fuel-ts/merkle");
|
8743
|
-
var
|
8806
|
+
var import_utils36 = require("@fuel-ts/utils");
|
8744
8807
|
var getPredicateRoot = (bytecode) => {
|
8745
8808
|
const chunkSize = 16 * 1024;
|
8746
|
-
const bytes = (0,
|
8747
|
-
const chunks = (0,
|
8748
|
-
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0,
|
8749
|
-
const predicateRoot = (0, import_hasher7.hash)((0,
|
8809
|
+
const bytes = (0, import_utils36.arrayify)(bytecode);
|
8810
|
+
const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
|
8811
|
+
const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
|
8812
|
+
const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
|
8750
8813
|
return predicateRoot;
|
8751
8814
|
};
|
8752
8815
|
|
@@ -8795,7 +8858,7 @@ var Predicate = class extends Account {
|
|
8795
8858
|
const request = transactionRequestify(transactionRequestLike);
|
8796
8859
|
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
8797
8860
|
request.inputs?.forEach((input) => {
|
8798
|
-
if (input.type ===
|
8861
|
+
if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
|
8799
8862
|
input.predicate = this.bytes;
|
8800
8863
|
input.predicateData = this.getPredicateData(policies.length);
|
8801
8864
|
}
|
@@ -8811,9 +8874,8 @@ var Predicate = class extends Account {
|
|
8811
8874
|
* @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
|
8812
8875
|
* @returns A promise that resolves to the prepared transaction request.
|
8813
8876
|
*/
|
8814
|
-
async createTransfer(destination, amount, assetId, txParams = {}) {
|
8815
|
-
const
|
8816
|
-
const request = await super.createTransfer(destination, amount, assetIdToTransfer, txParams);
|
8877
|
+
async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
|
8878
|
+
const request = await super.createTransfer(destination, amount, assetId, txParams);
|
8817
8879
|
return this.populateTransactionPredicateData(request);
|
8818
8880
|
}
|
8819
8881
|
/**
|
@@ -8841,7 +8903,7 @@ var Predicate = class extends Account {
|
|
8841
8903
|
return new Uint8Array();
|
8842
8904
|
}
|
8843
8905
|
const mainFn = this.interface?.functions.main;
|
8844
|
-
const paddedCode = new
|
8906
|
+
const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
|
8845
8907
|
const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
|
8846
8908
|
maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
|
8847
8909
|
});
|
@@ -8857,13 +8919,13 @@ var Predicate = class extends Account {
|
|
8857
8919
|
* @returns An object containing the new predicate bytes and interface.
|
8858
8920
|
*/
|
8859
8921
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
8860
|
-
let predicateBytes = (0,
|
8922
|
+
let predicateBytes = (0, import_utils37.arrayify)(bytes);
|
8861
8923
|
let abiInterface;
|
8862
8924
|
if (jsonAbi) {
|
8863
8925
|
abiInterface = new import_abi_coder5.Interface(jsonAbi);
|
8864
8926
|
if (abiInterface.functions.main === void 0) {
|
8865
|
-
throw new
|
8866
|
-
|
8927
|
+
throw new import_errors25.FuelError(
|
8928
|
+
import_errors25.ErrorCode.ABI_MAIN_METHOD_MISSING,
|
8867
8929
|
'Cannot use ABI without "main" function.'
|
8868
8930
|
);
|
8869
8931
|
}
|
@@ -8908,8 +8970,8 @@ var Predicate = class extends Account {
|
|
8908
8970
|
mutatedBytes.set(encoded, offset);
|
8909
8971
|
});
|
8910
8972
|
} catch (err) {
|
8911
|
-
throw new
|
8912
|
-
|
8973
|
+
throw new import_errors25.FuelError(
|
8974
|
+
import_errors25.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
|
8913
8975
|
`Error setting configurable constants: ${err.message}.`
|
8914
8976
|
);
|
8915
8977
|
}
|
@@ -8918,7 +8980,7 @@ var Predicate = class extends Account {
|
|
8918
8980
|
};
|
8919
8981
|
|
8920
8982
|
// src/connectors/fuel.ts
|
8921
|
-
var
|
8983
|
+
var import_errors26 = require("@fuel-ts/errors");
|
8922
8984
|
|
8923
8985
|
// src/connectors/fuel-connector.ts
|
8924
8986
|
var import_events2 = require("events");
|
@@ -9551,7 +9613,7 @@ var _Fuel = class extends FuelConnector {
|
|
9551
9613
|
const currentNetwork = await this.currentNetwork();
|
9552
9614
|
provider = await Provider.create(currentNetwork.url);
|
9553
9615
|
} else {
|
9554
|
-
throw new
|
9616
|
+
throw new import_errors26.FuelError(import_errors26.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
|
9555
9617
|
}
|
9556
9618
|
return provider;
|
9557
9619
|
}
|
@@ -9631,7 +9693,9 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9631
9693
|
WalletUnlocked,
|
9632
9694
|
addAmountToAsset,
|
9633
9695
|
addOperation,
|
9696
|
+
assemblePanicError,
|
9634
9697
|
assembleReceiptByType,
|
9698
|
+
assembleRevertError,
|
9635
9699
|
assembleTransactionSummary,
|
9636
9700
|
assets,
|
9637
9701
|
buildBlockExplorerUrl,
|
@@ -9646,6 +9710,7 @@ __publicField(Fuel, "defaultConfig", {});
|
|
9646
9710
|
english,
|
9647
9711
|
extractBurnedAssetsFromReceipts,
|
9648
9712
|
extractMintedAssetsFromReceipts,
|
9713
|
+
extractTxError,
|
9649
9714
|
gasUsedByInputs,
|
9650
9715
|
getAssetEth,
|
9651
9716
|
getAssetFuel,
|