@fuel-ts/account 0.98.0 → 0.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account.d.ts +4 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/assets/asset-api.d.ts +69 -0
- package/dist/assets/asset-api.d.ts.map +1 -0
- package/dist/assets/assets.d.ts.map +1 -0
- package/dist/{providers/assets → assets}/index.d.ts +1 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/assets/types.d.ts.map +1 -0
- package/dist/assets/utils/fuelAssetsBaseUrl.d.ts +2 -0
- package/dist/assets/utils/fuelAssetsBaseUrl.d.ts.map +1 -0
- package/dist/assets/utils/index.d.ts.map +1 -0
- package/dist/{providers/assets → assets}/utils/network.d.ts +6 -6
- package/dist/assets/utils/network.d.ts.map +1 -0
- package/dist/assets/utils/resolveIconPaths.d.ts.map +1 -0
- package/dist/assets/utils/url.d.ts.map +1 -0
- package/dist/configs.d.ts +2 -2
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +1 -1
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/types/events.d.ts +1 -1
- package/dist/connectors/types/events.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +14564 -14439
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +6423 -6303
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6461 -6347
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +28 -6
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +1 -0
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +43 -13
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -2
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/utils/handle-gql-error-message.d.ts +5 -1
- package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
- package/dist/test-utils/wallet-config.d.ts +2 -1
- package/dist/test-utils/wallet-config.d.ts.map +1 -1
- package/dist/test-utils.global.js +205 -740
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +270 -822
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +195 -747
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/deployScriptOrPredicate.d.ts.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/utils/predicate-script-loader-instructions.d.ts +36 -1
- package/dist/utils/predicate-script-loader-instructions.d.ts.map +1 -1
- package/dist/wallet/keystore-wallet.d.ts +2 -2
- package/dist/wallet/keystore-wallet.d.ts.map +1 -1
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +3 -2
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -1
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts +2 -1
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -1
- package/dist/wallet-manager/wallet-manager.d.ts +3 -3
- package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
- package/package.json +15 -16
- package/dist/providers/assets/assets.d.ts.map +0 -1
- package/dist/providers/assets/index.d.ts.map +0 -1
- package/dist/providers/assets/types.d.ts.map +0 -1
- package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts +0 -2
- package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts.map +0 -1
- package/dist/providers/assets/utils/index.d.ts.map +0 -1
- package/dist/providers/assets/utils/network.d.ts.map +0 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +0 -1
- package/dist/providers/assets/utils/url.d.ts.map +0 -1
- /package/dist/{providers/assets → assets}/assets.d.ts +0 -0
- /package/dist/{providers/assets → assets}/types.d.ts +0 -0
- /package/dist/{providers/assets → assets}/utils/index.d.ts +0 -0
- /package/dist/{providers/assets → assets}/utils/resolveIconPaths.d.ts +0 -0
- /package/dist/{providers/assets → assets}/utils/url.d.ts +0 -0
package/dist/test-utils.js
CHANGED
@@ -93,7 +93,7 @@ var Signer = class {
|
|
93
93
|
this.privateKey = (0, import_utils.hexlify)(privateKeyBytes);
|
94
94
|
this.publicKey = (0, import_utils.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
95
95
|
this.compressedPublicKey = (0, import_utils.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
|
96
|
-
this.address = import_address.Address
|
96
|
+
this.address = new import_address.Address(this.publicKey);
|
97
97
|
}
|
98
98
|
/**
|
99
99
|
* Sign data using the Signer instance
|
@@ -151,7 +151,7 @@ var Signer = class {
|
|
151
151
|
* @returns Address from signature
|
152
152
|
*/
|
153
153
|
static recoverAddress(data, signature) {
|
154
|
-
return import_address.Address
|
154
|
+
return new import_address.Address(Signer.recoverPublicKey(data, signature));
|
155
155
|
}
|
156
156
|
/**
|
157
157
|
* Generate a random privateKey
|
@@ -416,7 +416,7 @@ var launchNode = async ({
|
|
416
416
|
);
|
417
417
|
|
418
418
|
// src/test-utils/setup-test-provider-and-wallets.ts
|
419
|
-
var
|
419
|
+
var import_utils44 = require("@fuel-ts/utils");
|
420
420
|
var import_ramda10 = require("ramda");
|
421
421
|
|
422
422
|
// src/providers/coin-quantity.ts
|
@@ -1211,9 +1211,6 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
1211
1211
|
first: $first
|
1212
1212
|
last: $last
|
1213
1213
|
) {
|
1214
|
-
pageInfo {
|
1215
|
-
...pageInfoFragment
|
1216
|
-
}
|
1217
1214
|
edges {
|
1218
1215
|
node {
|
1219
1216
|
assetId
|
@@ -1222,7 +1219,7 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
1222
1219
|
}
|
1223
1220
|
}
|
1224
1221
|
}
|
1225
|
-
|
1222
|
+
`;
|
1226
1223
|
var GetMessagesDocument = import_graphql_tag.default`
|
1227
1224
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
1228
1225
|
messages(
|
@@ -1244,6 +1241,13 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
1244
1241
|
}
|
1245
1242
|
${PageInfoFragmentDoc}
|
1246
1243
|
${GetMessageFragmentDoc}`;
|
1244
|
+
var DaCompressedBlockDocument = import_graphql_tag.default`
|
1245
|
+
query daCompressedBlock($height: U32!) {
|
1246
|
+
daCompressedBlock(height: $height) {
|
1247
|
+
bytes
|
1248
|
+
}
|
1249
|
+
}
|
1250
|
+
`;
|
1247
1251
|
var GetMessageProofDocument = import_graphql_tag.default`
|
1248
1252
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
1249
1253
|
messageProof(
|
@@ -1415,6 +1419,9 @@ function getSdk(requester) {
|
|
1415
1419
|
getMessages(variables, options) {
|
1416
1420
|
return requester(GetMessagesDocument, variables, options);
|
1417
1421
|
},
|
1422
|
+
daCompressedBlock(variables, options) {
|
1423
|
+
return requester(DaCompressedBlockDocument, variables, options);
|
1424
|
+
},
|
1418
1425
|
getMessageProof(variables, options) {
|
1419
1426
|
return requester(GetMessageProofDocument, variables, options);
|
1420
1427
|
},
|
@@ -1452,8 +1459,60 @@ function getSdk(requester) {
|
|
1452
1459
|
}
|
1453
1460
|
|
1454
1461
|
// src/providers/fuel-graphql-subscriber.ts
|
1455
|
-
var
|
1462
|
+
var import_errors3 = require("@fuel-ts/errors");
|
1456
1463
|
var import_graphql = require("graphql");
|
1464
|
+
|
1465
|
+
// src/providers/utils/handle-gql-error-message.ts
|
1466
|
+
var import_errors2 = require("@fuel-ts/errors");
|
1467
|
+
var mapGqlErrorMessage = (error) => {
|
1468
|
+
switch (error.message) {
|
1469
|
+
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
1470
|
+
return new import_errors2.FuelError(
|
1471
|
+
import_errors2.ErrorCode.NOT_ENOUGH_FUNDS,
|
1472
|
+
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
1473
|
+
{},
|
1474
|
+
error
|
1475
|
+
);
|
1476
|
+
case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
|
1477
|
+
return new import_errors2.FuelError(
|
1478
|
+
import_errors2.ErrorCode.MAX_COINS_REACHED,
|
1479
|
+
"The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
|
1480
|
+
{},
|
1481
|
+
error
|
1482
|
+
);
|
1483
|
+
default:
|
1484
|
+
return new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1485
|
+
}
|
1486
|
+
};
|
1487
|
+
var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
|
1488
|
+
if (!incompatibleNodeVersionMessage) {
|
1489
|
+
return error;
|
1490
|
+
}
|
1491
|
+
return new import_errors2.FuelError(
|
1492
|
+
error.code,
|
1493
|
+
`${error.message}
|
1494
|
+
|
1495
|
+
${incompatibleNodeVersionMessage}`,
|
1496
|
+
error.metadata,
|
1497
|
+
error.rawError
|
1498
|
+
);
|
1499
|
+
};
|
1500
|
+
var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = false) => {
|
1501
|
+
if (!Array.isArray(errors)) {
|
1502
|
+
return;
|
1503
|
+
}
|
1504
|
+
const mappedErrors = errors.map(mapGqlErrorMessage);
|
1505
|
+
if (mappedErrors.length === 1) {
|
1506
|
+
throw mapGqlErrorWithIncompatibleNodeVersion(mappedErrors[0], incompatibleNodeVersionMessage);
|
1507
|
+
}
|
1508
|
+
const errorMessage = mappedErrors.map((err) => err.message).join("\n");
|
1509
|
+
throw mapGqlErrorWithIncompatibleNodeVersion(
|
1510
|
+
new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
1511
|
+
incompatibleNodeVersionMessage
|
1512
|
+
);
|
1513
|
+
};
|
1514
|
+
|
1515
|
+
// src/providers/fuel-graphql-subscriber.ts
|
1457
1516
|
var _FuelGraphqlSubscriber = class {
|
1458
1517
|
constructor(stream) {
|
1459
1518
|
this.stream = stream;
|
@@ -1481,12 +1540,7 @@ var _FuelGraphqlSubscriber = class {
|
|
1481
1540
|
while (true) {
|
1482
1541
|
if (this.events.length > 0) {
|
1483
1542
|
const { data, errors } = this.events.shift();
|
1484
|
-
|
1485
|
-
throw new import_errors2.FuelError(
|
1486
|
-
import_errors2.FuelError.CODES.INVALID_REQUEST,
|
1487
|
-
errors.map((err) => err.message).join("\n\n")
|
1488
|
-
);
|
1489
|
-
}
|
1543
|
+
assertGqlResponseHasNoErrors(errors, _FuelGraphqlSubscriber.incompatibleNodeVersionMessage);
|
1490
1544
|
return { value: data, done: false };
|
1491
1545
|
}
|
1492
1546
|
const { value, done } = await this.stream.read();
|
@@ -1504,8 +1558,8 @@ var _FuelGraphqlSubscriber = class {
|
|
1504
1558
|
try {
|
1505
1559
|
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
1506
1560
|
} catch (e) {
|
1507
|
-
throw new
|
1508
|
-
|
1561
|
+
throw new import_errors3.FuelError(
|
1562
|
+
import_errors3.ErrorCode.STREAM_PARSING_ERROR,
|
1509
1563
|
`Error while parsing stream data response: ${text}`
|
1510
1564
|
);
|
1511
1565
|
}
|
@@ -1524,10 +1578,11 @@ var _FuelGraphqlSubscriber = class {
|
|
1524
1578
|
}
|
1525
1579
|
};
|
1526
1580
|
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
1581
|
+
__publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
|
1527
1582
|
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1528
1583
|
|
1529
1584
|
// src/providers/resource-cache.ts
|
1530
|
-
var
|
1585
|
+
var import_errors4 = require("@fuel-ts/errors");
|
1531
1586
|
var import_utils4 = require("@fuel-ts/utils");
|
1532
1587
|
var cache = /* @__PURE__ */ new Map();
|
1533
1588
|
var ResourceCache = class {
|
@@ -1535,8 +1590,8 @@ var ResourceCache = class {
|
|
1535
1590
|
constructor(ttl) {
|
1536
1591
|
this.ttl = ttl;
|
1537
1592
|
if (typeof ttl !== "number" || this.ttl <= 0) {
|
1538
|
-
throw new
|
1539
|
-
|
1593
|
+
throw new import_errors4.FuelError(
|
1594
|
+
import_errors4.ErrorCode.INVALID_TTL,
|
1540
1595
|
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
1541
1596
|
);
|
1542
1597
|
}
|
@@ -1591,7 +1646,7 @@ var ResourceCache = class {
|
|
1591
1646
|
// src/providers/transaction-request/input.ts
|
1592
1647
|
var import_abi_coder2 = require("@fuel-ts/abi-coder");
|
1593
1648
|
var import_configs = require("@fuel-ts/address/configs");
|
1594
|
-
var
|
1649
|
+
var import_errors5 = require("@fuel-ts/errors");
|
1595
1650
|
var import_math3 = require("@fuel-ts/math");
|
1596
1651
|
var import_transactions = require("@fuel-ts/transactions");
|
1597
1652
|
var import_utils5 = require("@fuel-ts/utils");
|
@@ -1655,8 +1710,8 @@ var inputify = (value) => {
|
|
1655
1710
|
};
|
1656
1711
|
}
|
1657
1712
|
default: {
|
1658
|
-
throw new
|
1659
|
-
|
1713
|
+
throw new import_errors5.FuelError(
|
1714
|
+
import_errors5.ErrorCode.INVALID_TRANSACTION_INPUT,
|
1660
1715
|
`Invalid transaction input type: ${type}.`
|
1661
1716
|
);
|
1662
1717
|
}
|
@@ -1665,7 +1720,7 @@ var inputify = (value) => {
|
|
1665
1720
|
|
1666
1721
|
// src/providers/transaction-request/output.ts
|
1667
1722
|
var import_configs2 = require("@fuel-ts/address/configs");
|
1668
|
-
var
|
1723
|
+
var import_errors6 = require("@fuel-ts/errors");
|
1669
1724
|
var import_math4 = require("@fuel-ts/math");
|
1670
1725
|
var import_transactions2 = require("@fuel-ts/transactions");
|
1671
1726
|
var import_utils6 = require("@fuel-ts/utils");
|
@@ -1712,8 +1767,8 @@ var outputify = (value) => {
|
|
1712
1767
|
};
|
1713
1768
|
}
|
1714
1769
|
default: {
|
1715
|
-
throw new
|
1716
|
-
|
1770
|
+
throw new import_errors6.FuelError(
|
1771
|
+
import_errors6.ErrorCode.INVALID_TRANSACTION_INPUT,
|
1717
1772
|
`Invalid transaction output type: ${type}.`
|
1718
1773
|
);
|
1719
1774
|
}
|
@@ -1725,7 +1780,7 @@ var import_abi_coder3 = require("@fuel-ts/abi-coder");
|
|
1725
1780
|
var import_address2 = require("@fuel-ts/address");
|
1726
1781
|
var import_configs6 = require("@fuel-ts/address/configs");
|
1727
1782
|
var import_crypto3 = require("@fuel-ts/crypto");
|
1728
|
-
var
|
1783
|
+
var import_errors11 = require("@fuel-ts/errors");
|
1729
1784
|
var import_math9 = require("@fuel-ts/math");
|
1730
1785
|
var import_transactions7 = require("@fuel-ts/transactions");
|
1731
1786
|
var import_utils11 = require("@fuel-ts/utils");
|
@@ -1738,7 +1793,7 @@ var isCoin = (resource) => "id" in resource;
|
|
1738
1793
|
|
1739
1794
|
// src/providers/utils/receipts.ts
|
1740
1795
|
var import_configs3 = require("@fuel-ts/address/configs");
|
1741
|
-
var
|
1796
|
+
var import_errors7 = require("@fuel-ts/errors");
|
1742
1797
|
var import_math5 = require("@fuel-ts/math");
|
1743
1798
|
var import_transactions3 = require("@fuel-ts/transactions");
|
1744
1799
|
var import_configs4 = require("@fuel-ts/transactions/configs");
|
@@ -1951,12 +2006,12 @@ function assembleReceiptByType(receipt) {
|
|
1951
2006
|
return burnReceipt;
|
1952
2007
|
}
|
1953
2008
|
default:
|
1954
|
-
throw new
|
2009
|
+
throw new import_errors7.FuelError(import_errors7.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
1955
2010
|
}
|
1956
2011
|
}
|
1957
2012
|
|
1958
2013
|
// src/providers/utils/block-explorer.ts
|
1959
|
-
var
|
2014
|
+
var import_errors8 = require("@fuel-ts/errors");
|
1960
2015
|
|
1961
2016
|
// src/providers/utils/gas.ts
|
1962
2017
|
var import_math6 = require("@fuel-ts/math");
|
@@ -2128,7 +2183,7 @@ function normalizeJSON(root) {
|
|
2128
2183
|
}
|
2129
2184
|
|
2130
2185
|
// src/providers/utils/extract-tx-error.ts
|
2131
|
-
var
|
2186
|
+
var import_errors9 = require("@fuel-ts/errors");
|
2132
2187
|
var import_math7 = require("@fuel-ts/math");
|
2133
2188
|
var import_transactions5 = require("@fuel-ts/transactions");
|
2134
2189
|
var import_configs5 = require("@fuel-ts/transactions/configs");
|
@@ -2141,7 +2196,7 @@ You can read more about this error at:
|
|
2141
2196
|
|
2142
2197
|
${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
|
2143
2198
|
}
|
2144
|
-
return new
|
2199
|
+
return new import_errors9.FuelError(import_errors9.ErrorCode.SCRIPT_REVERTED, errorMessage, {
|
2145
2200
|
...metadata,
|
2146
2201
|
reason: statusReason
|
2147
2202
|
});
|
@@ -2182,8 +2237,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2182
2237
|
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
2183
2238
|
break;
|
2184
2239
|
default:
|
2185
|
-
throw new
|
2186
|
-
|
2240
|
+
throw new import_errors9.FuelError(
|
2241
|
+
import_errors9.ErrorCode.UNKNOWN,
|
2187
2242
|
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
2188
2243
|
{
|
2189
2244
|
...metadata,
|
@@ -2192,7 +2247,7 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2192
2247
|
);
|
2193
2248
|
}
|
2194
2249
|
}
|
2195
|
-
return new
|
2250
|
+
return new import_errors9.FuelError(import_errors9.ErrorCode.SCRIPT_REVERTED, errorMessage, {
|
2196
2251
|
...metadata,
|
2197
2252
|
reason
|
2198
2253
|
});
|
@@ -2225,7 +2280,7 @@ var NoWitnessAtIndexError = class extends Error {
|
|
2225
2280
|
};
|
2226
2281
|
|
2227
2282
|
// src/providers/transaction-request/helpers.ts
|
2228
|
-
var
|
2283
|
+
var import_errors10 = require("@fuel-ts/errors");
|
2229
2284
|
var import_math8 = require("@fuel-ts/math");
|
2230
2285
|
var import_transactions6 = require("@fuel-ts/transactions");
|
2231
2286
|
var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
|
@@ -2282,7 +2337,7 @@ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAs
|
|
2282
2337
|
"Add the relevant change outputs to the transaction to avoid burning assets.",
|
2283
2338
|
"Or enable asset burn, upon sending the transaction."
|
2284
2339
|
].join("\n");
|
2285
|
-
throw new
|
2340
|
+
throw new import_errors10.FuelError(import_errors10.ErrorCode.ASSET_BURN_DETECTED, message);
|
2286
2341
|
};
|
2287
2342
|
|
2288
2343
|
// src/providers/transaction-request/witness.ts
|
@@ -2433,7 +2488,7 @@ var BaseTransactionRequest = class {
|
|
2433
2488
|
* @param signature - The signature to update the witness with.
|
2434
2489
|
*/
|
2435
2490
|
updateWitnessByOwner(address, signature) {
|
2436
|
-
const ownerAddress = import_address2.Address
|
2491
|
+
const ownerAddress = new import_address2.Address(address);
|
2437
2492
|
const witnessIndex = this.getCoinInputWitnessIndexByOwner(ownerAddress);
|
2438
2493
|
if (typeof witnessIndex === "number") {
|
2439
2494
|
this.updateWitness(witnessIndex, signature);
|
@@ -2667,7 +2722,7 @@ var BaseTransactionRequest = class {
|
|
2667
2722
|
* @hidden
|
2668
2723
|
*/
|
2669
2724
|
metadataGas(_gasCosts) {
|
2670
|
-
throw new
|
2725
|
+
throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
|
2671
2726
|
}
|
2672
2727
|
/**
|
2673
2728
|
* @hidden
|
@@ -2784,7 +2839,7 @@ var BaseTransactionRequest = class {
|
|
2784
2839
|
this.inputs.filter(isRequestInputResource).forEach((i) => {
|
2785
2840
|
const owner = getRequestInputResourceOwner(i);
|
2786
2841
|
const correspondingInput = inputsToExtractGasUsed.find(
|
2787
|
-
(x) => isRequestInputResourceFromOwner(x, import_address2.Address
|
2842
|
+
(x) => isRequestInputResourceFromOwner(x, new import_address2.Address(String(owner)))
|
2788
2843
|
);
|
2789
2844
|
if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math9.bn)(correspondingInput.predicateGasUsed).gt(0)) {
|
2790
2845
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -3275,7 +3330,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3275
3330
|
};
|
3276
3331
|
|
3277
3332
|
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3278
|
-
var
|
3333
|
+
var import_errors13 = require("@fuel-ts/errors");
|
3279
3334
|
var import_hasher3 = require("@fuel-ts/hasher");
|
3280
3335
|
var import_transactions11 = require("@fuel-ts/transactions");
|
3281
3336
|
var import_utils19 = require("@fuel-ts/utils");
|
@@ -3379,7 +3434,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
|
3379
3434
|
}
|
3380
3435
|
};
|
3381
3436
|
} else {
|
3382
|
-
throw new
|
3437
|
+
throw new import_errors13.FuelError(import_errors13.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3383
3438
|
}
|
3384
3439
|
return {
|
3385
3440
|
type: import_transactions11.TransactionType.Upgrade,
|
@@ -3421,7 +3476,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
|
3421
3476
|
txBytesSize
|
3422
3477
|
});
|
3423
3478
|
}
|
3424
|
-
throw new
|
3479
|
+
throw new import_errors13.FuelError(import_errors13.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3425
3480
|
}
|
3426
3481
|
};
|
3427
3482
|
|
@@ -3532,7 +3587,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
|
|
3532
3587
|
};
|
3533
3588
|
|
3534
3589
|
// src/providers/transaction-request/utils.ts
|
3535
|
-
var
|
3590
|
+
var import_errors14 = require("@fuel-ts/errors");
|
3536
3591
|
var import_transactions13 = require("@fuel-ts/transactions");
|
3537
3592
|
var transactionRequestify = (obj) => {
|
3538
3593
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
@@ -3556,8 +3611,8 @@ var transactionRequestify = (obj) => {
|
|
3556
3611
|
return UploadTransactionRequest.from(obj);
|
3557
3612
|
}
|
3558
3613
|
default: {
|
3559
|
-
throw new
|
3560
|
-
|
3614
|
+
throw new import_errors14.FuelError(
|
3615
|
+
import_errors14.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3561
3616
|
`Unsupported transaction type: ${type}.`
|
3562
3617
|
);
|
3563
3618
|
}
|
@@ -3567,7 +3622,7 @@ var isTransactionTypeScript = (request) => request.type === import_transactions1
|
|
3567
3622
|
var isTransactionTypeCreate = (request) => request.type === import_transactions13.TransactionType.Create;
|
3568
3623
|
|
3569
3624
|
// src/providers/transaction-response/transaction-response.ts
|
3570
|
-
var
|
3625
|
+
var import_errors18 = require("@fuel-ts/errors");
|
3571
3626
|
var import_math18 = require("@fuel-ts/math");
|
3572
3627
|
var import_transactions21 = require("@fuel-ts/transactions");
|
3573
3628
|
var import_utils27 = require("@fuel-ts/utils");
|
@@ -3645,7 +3700,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
3645
3700
|
|
3646
3701
|
// src/providers/transaction-summary/operations.ts
|
3647
3702
|
var import_configs11 = require("@fuel-ts/address/configs");
|
3648
|
-
var
|
3703
|
+
var import_errors16 = require("@fuel-ts/errors");
|
3649
3704
|
var import_math15 = require("@fuel-ts/math");
|
3650
3705
|
var import_transactions17 = require("@fuel-ts/transactions");
|
3651
3706
|
|
@@ -3683,7 +3738,7 @@ var getFunctionCall = ({ abi, receipt }) => {
|
|
3683
3738
|
};
|
3684
3739
|
|
3685
3740
|
// src/providers/transaction-summary/input.ts
|
3686
|
-
var
|
3741
|
+
var import_errors15 = require("@fuel-ts/errors");
|
3687
3742
|
var import_math14 = require("@fuel-ts/math");
|
3688
3743
|
var import_transactions15 = require("@fuel-ts/transactions");
|
3689
3744
|
function getInputsByTypes(inputs, types) {
|
@@ -3752,8 +3807,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3752
3807
|
return void 0;
|
3753
3808
|
}
|
3754
3809
|
if (contractInput.type !== import_transactions15.InputType.Contract) {
|
3755
|
-
throw new
|
3756
|
-
|
3810
|
+
throw new import_errors15.FuelError(
|
3811
|
+
import_errors15.ErrorCode.INVALID_TRANSACTION_INPUT,
|
3757
3812
|
`Contract input should be of type 'contract'.`
|
3758
3813
|
);
|
3759
3814
|
}
|
@@ -3806,8 +3861,8 @@ function getTransactionTypeName(transactionType) {
|
|
3806
3861
|
case import_transactions17.TransactionType.Upload:
|
3807
3862
|
return "Upload" /* Upload */;
|
3808
3863
|
default:
|
3809
|
-
throw new
|
3810
|
-
|
3864
|
+
throw new import_errors16.FuelError(
|
3865
|
+
import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3811
3866
|
`Unsupported transaction type: ${transactionType}.`
|
3812
3867
|
);
|
3813
3868
|
}
|
@@ -4187,7 +4242,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
4187
4242
|
};
|
4188
4243
|
|
4189
4244
|
// src/providers/transaction-summary/status.ts
|
4190
|
-
var
|
4245
|
+
var import_errors17 = require("@fuel-ts/errors");
|
4191
4246
|
var import_math16 = require("@fuel-ts/math");
|
4192
4247
|
var getTransactionStatusName = (gqlStatus) => {
|
4193
4248
|
switch (gqlStatus) {
|
@@ -4200,8 +4255,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
4200
4255
|
case "SqueezedOutStatus":
|
4201
4256
|
return "squeezedout" /* squeezedout */;
|
4202
4257
|
default:
|
4203
|
-
throw new
|
4204
|
-
|
4258
|
+
throw new import_errors17.FuelError(
|
4259
|
+
import_errors17.ErrorCode.INVALID_TRANSACTION_STATUS,
|
4205
4260
|
`Invalid transaction status: ${gqlStatus}.`
|
4206
4261
|
);
|
4207
4262
|
}
|
@@ -4391,6 +4446,7 @@ var TransactionResponse = class {
|
|
4391
4446
|
this.provider = provider;
|
4392
4447
|
this.abis = abis;
|
4393
4448
|
this.request = typeof tx === "string" ? void 0 : tx;
|
4449
|
+
this.waitForResult = this.waitForResult.bind(this);
|
4394
4450
|
}
|
4395
4451
|
/** Transaction ID */
|
4396
4452
|
id;
|
@@ -4545,8 +4601,8 @@ var TransactionResponse = class {
|
|
4545
4601
|
this.status = statusChange;
|
4546
4602
|
if (statusChange.type === "SqueezedOutStatus") {
|
4547
4603
|
this.unsetResourceCache();
|
4548
|
-
throw new
|
4549
|
-
|
4604
|
+
throw new import_errors18.FuelError(
|
4605
|
+
import_errors18.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
4550
4606
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4551
4607
|
);
|
4552
4608
|
}
|
@@ -4653,29 +4709,6 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4653
4709
|
};
|
4654
4710
|
}
|
4655
4711
|
|
4656
|
-
// src/providers/utils/handle-gql-error-message.ts
|
4657
|
-
var import_errors18 = require("@fuel-ts/errors");
|
4658
|
-
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4659
|
-
switch (errorMessage) {
|
4660
|
-
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4661
|
-
throw new import_errors18.FuelError(
|
4662
|
-
import_errors18.ErrorCode.NOT_ENOUGH_FUNDS,
|
4663
|
-
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4664
|
-
{},
|
4665
|
-
rawError
|
4666
|
-
);
|
4667
|
-
case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
|
4668
|
-
throw new import_errors18.FuelError(
|
4669
|
-
import_errors18.ErrorCode.MAX_COINS_REACHED,
|
4670
|
-
"The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
|
4671
|
-
{},
|
4672
|
-
rawError
|
4673
|
-
);
|
4674
|
-
default:
|
4675
|
-
throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_REQUEST, errorMessage);
|
4676
|
-
}
|
4677
|
-
};
|
4678
|
-
|
4679
4712
|
// src/providers/utils/validate-pagination-args.ts
|
4680
4713
|
var import_errors19 = require("@fuel-ts/errors");
|
4681
4714
|
var validatePaginationArgs = (params) => {
|
@@ -4951,7 +4984,7 @@ var _Provider = class {
|
|
4951
4984
|
utxoValidation: data.nodeInfo.utxoValidation,
|
4952
4985
|
vmBacktrace: data.nodeInfo.vmBacktrace
|
4953
4986
|
};
|
4954
|
-
_Provider.
|
4987
|
+
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
4955
4988
|
chain = processGqlChain(data.chain);
|
4956
4989
|
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
4957
4990
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
@@ -4965,15 +4998,15 @@ var _Provider = class {
|
|
4965
4998
|
/**
|
4966
4999
|
* @hidden
|
4967
5000
|
*/
|
4968
|
-
static
|
5001
|
+
static setIncompatibleNodeVersionMessage(nodeInfo) {
|
4969
5002
|
const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
|
4970
5003
|
if (!isMajorSupported || !isMinorSupported) {
|
4971
|
-
|
4972
|
-
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion}
|
4973
|
-
|
4974
|
-
Things may not work as expected
|
4975
|
-
|
4976
|
-
|
5004
|
+
_Provider.incompatibleNodeVersionMessage = [
|
5005
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion}.`,
|
5006
|
+
`The TS SDK currently supports fuel-core version ${supportedVersion}.`,
|
5007
|
+
`Things may not work as expected.`
|
5008
|
+
].join("\n");
|
5009
|
+
FuelGraphqlSubscriber.incompatibleNodeVersionMessage = _Provider.incompatibleNodeVersionMessage;
|
4977
5010
|
}
|
4978
5011
|
}
|
4979
5012
|
/**
|
@@ -4989,11 +5022,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4989
5022
|
responseMiddleware: (response) => {
|
4990
5023
|
if ("response" in response) {
|
4991
5024
|
const graphQlResponse = response.response;
|
4992
|
-
|
4993
|
-
|
4994
|
-
|
4995
|
-
|
4996
|
-
}
|
5025
|
+
assertGqlResponseHasNoErrors(
|
5026
|
+
graphQlResponse.errors,
|
5027
|
+
_Provider.incompatibleNodeVersionMessage
|
5028
|
+
);
|
4997
5029
|
}
|
4998
5030
|
}
|
4999
5031
|
});
|
@@ -5223,9 +5255,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5223
5255
|
* `addVariableOutputs` is called on the transaction.
|
5224
5256
|
*
|
5225
5257
|
* @param transactionRequest - The transaction request object.
|
5258
|
+
* @param gasPrice - The gas price to use for the transaction, if not provided it will be fetched.
|
5226
5259
|
* @returns A promise that resolves to the estimate transaction dependencies.
|
5227
5260
|
*/
|
5228
|
-
async estimateTxDependencies(transactionRequest) {
|
5261
|
+
async estimateTxDependencies(transactionRequest, { gasPrice: gasPriceParam } = {}) {
|
5229
5262
|
if (isTransactionTypeCreate(transactionRequest)) {
|
5230
5263
|
return {
|
5231
5264
|
receipts: [],
|
@@ -5238,13 +5271,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5238
5271
|
let outputVariables = 0;
|
5239
5272
|
let dryRunStatus;
|
5240
5273
|
await this.validateTransaction(transactionRequest);
|
5274
|
+
const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
|
5241
5275
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
5242
5276
|
const {
|
5243
5277
|
dryRun: [{ receipts: rawReceipts, status }]
|
5244
5278
|
} = await this.operations.dryRun({
|
5245
5279
|
encodedTransactions: [(0, import_utils30.hexlify)(transactionRequest.toTransactionBytes())],
|
5246
5280
|
utxoValidation: false,
|
5247
|
-
gasPrice:
|
5281
|
+
gasPrice: gasPrice.toString()
|
5248
5282
|
});
|
5249
5283
|
receipts = rawReceipts.map(processGqlReceipt);
|
5250
5284
|
dryRunStatus = status;
|
@@ -5254,12 +5288,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5254
5288
|
outputVariables += missingOutputVariables.length;
|
5255
5289
|
transactionRequest.addVariableOutputs(missingOutputVariables.length);
|
5256
5290
|
missingOutputContractIds.forEach(({ contractId }) => {
|
5257
|
-
transactionRequest.addContractInputAndOutput(import_address4.Address
|
5291
|
+
transactionRequest.addContractInputAndOutput(new import_address4.Address(contractId));
|
5258
5292
|
missingContractIds.push(contractId);
|
5259
5293
|
});
|
5260
5294
|
const { maxFee } = await this.estimateTxGasAndFee({
|
5261
5295
|
transactionRequest,
|
5262
|
-
gasPrice
|
5296
|
+
gasPrice
|
5263
5297
|
});
|
5264
5298
|
transactionRequest.maxFee = maxFee;
|
5265
5299
|
} else {
|
@@ -5323,7 +5357,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5323
5357
|
result.outputVariables += missingOutputVariables.length;
|
5324
5358
|
request.addVariableOutputs(missingOutputVariables.length);
|
5325
5359
|
missingOutputContractIds.forEach(({ contractId }) => {
|
5326
|
-
request.addContractInputAndOutput(import_address4.Address
|
5360
|
+
request.addContractInputAndOutput(new import_address4.Address(contractId));
|
5327
5361
|
result.missingContractIds.push(contractId);
|
5328
5362
|
});
|
5329
5363
|
const { maxFee } = await this.estimateTxGasAndFee({
|
@@ -5389,12 +5423,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5389
5423
|
}
|
5390
5424
|
/**
|
5391
5425
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
5392
|
-
* @param
|
5426
|
+
* @param params - The parameters for estimating the transaction gas and fee.
|
5393
5427
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
5394
5428
|
*/
|
5395
5429
|
async estimateTxGasAndFee(params) {
|
5396
|
-
const { transactionRequest } = params;
|
5397
|
-
let
|
5430
|
+
const { transactionRequest, gasPrice: gasPriceParam } = params;
|
5431
|
+
let gasPrice = gasPriceParam;
|
5398
5432
|
await this.autoRefetchConfigs();
|
5399
5433
|
const chainInfo = await this.getChain();
|
5400
5434
|
const { gasPriceFactor, maxGasPerTx } = await this.getGasConfig();
|
@@ -5475,7 +5509,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5475
5509
|
*
|
5476
5510
|
* @returns A promise that resolves to the transaction cost object.
|
5477
5511
|
*/
|
5478
|
-
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
5512
|
+
async getTransactionCost(transactionRequestLike, { signatureCallback, gasPrice: gasPriceParam } = {}) {
|
5479
5513
|
const txRequestClone = (0, import_ramda8.clone)(transactionRequestify(transactionRequestLike));
|
5480
5514
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
5481
5515
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
@@ -5491,8 +5525,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5491
5525
|
}
|
5492
5526
|
await this.estimatePredicates(signedRequest);
|
5493
5527
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
5494
|
-
|
5495
|
-
|
5528
|
+
const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
|
5529
|
+
let { maxFee, maxGas, minFee, minGas, gasLimit } = await this.estimateTxGasAndFee({
|
5530
|
+
// Fetches and returns a gas price
|
5531
|
+
transactionRequest: signedRequest,
|
5532
|
+
gasPrice
|
5496
5533
|
});
|
5497
5534
|
let receipts = [];
|
5498
5535
|
let dryRunStatus;
|
@@ -5505,7 +5542,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5505
5542
|
if (signatureCallback) {
|
5506
5543
|
await signatureCallback(txRequestClone);
|
5507
5544
|
}
|
5508
|
-
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
|
5545
|
+
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
|
5509
5546
|
if (dryRunStatus && "reason" in dryRunStatus) {
|
5510
5547
|
throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
|
5511
5548
|
}
|
@@ -5513,7 +5550,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5513
5550
|
const pristineGasUsed = getGasUsedFromReceipts(receipts);
|
5514
5551
|
gasUsed = (0, import_math19.bn)(pristineGasUsed.muln(GAS_USED_MODIFIER)).max(maxGasPerTx.sub(minGas));
|
5515
5552
|
txRequestClone.gasLimit = gasUsed;
|
5516
|
-
({ maxFee, maxGas, minFee, minGas
|
5553
|
+
({ maxFee, maxGas, minFee, minGas } = await this.estimateTxGasAndFee({
|
5517
5554
|
transactionRequest: txRequestClone,
|
5518
5555
|
gasPrice
|
5519
5556
|
}));
|
@@ -5544,7 +5581,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5544
5581
|
* @returns A promise that resolves to the coins.
|
5545
5582
|
*/
|
5546
5583
|
async getCoins(owner, assetId, paginationArgs) {
|
5547
|
-
const ownerAddress = import_address4.Address
|
5584
|
+
const ownerAddress = new import_address4.Address(owner);
|
5548
5585
|
const {
|
5549
5586
|
coins: { edges, pageInfo }
|
5550
5587
|
} = await this.operations.getCoins({
|
@@ -5576,7 +5613,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5576
5613
|
* @returns A promise that resolves to the resources.
|
5577
5614
|
*/
|
5578
5615
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
5579
|
-
const ownerAddress = import_address4.Address
|
5616
|
+
const ownerAddress = new import_address4.Address(owner);
|
5580
5617
|
const excludeInput = {
|
5581
5618
|
messages: excludedIds?.messages?.map((nonce) => (0, import_utils30.hexlify)(nonce)) || [],
|
5582
5619
|
utxos: excludedIds?.utxos?.map((id) => (0, import_utils30.hexlify)(id)) || []
|
@@ -5603,8 +5640,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5603
5640
|
amount: (0, import_math19.bn)(coin.amount),
|
5604
5641
|
assetId: coin.assetId,
|
5605
5642
|
daHeight: (0, import_math19.bn)(coin.daHeight),
|
5606
|
-
sender: import_address4.Address
|
5607
|
-
recipient: import_address4.Address
|
5643
|
+
sender: new import_address4.Address(coin.sender),
|
5644
|
+
recipient: new import_address4.Address(coin.recipient),
|
5608
5645
|
nonce: coin.nonce
|
5609
5646
|
};
|
5610
5647
|
case "Coin":
|
@@ -5801,6 +5838,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5801
5838
|
}).filter((tx) => tx !== null);
|
5802
5839
|
return { transactions, pageInfo };
|
5803
5840
|
}
|
5841
|
+
/**
|
5842
|
+
* Fetches a compressed block at the specified height.
|
5843
|
+
*
|
5844
|
+
* @param height - The height of the block to fetch.
|
5845
|
+
* @returns The compressed block if available, otherwise `null`.
|
5846
|
+
*/
|
5847
|
+
async daCompressedBlock(height) {
|
5848
|
+
const { daCompressedBlock } = await this.operations.daCompressedBlock({
|
5849
|
+
height
|
5850
|
+
});
|
5851
|
+
if (!daCompressedBlock) {
|
5852
|
+
return null;
|
5853
|
+
}
|
5854
|
+
return daCompressedBlock;
|
5855
|
+
}
|
5804
5856
|
/**
|
5805
5857
|
* Get deployed contract with the given ID.
|
5806
5858
|
*
|
@@ -5823,7 +5875,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5823
5875
|
*/
|
5824
5876
|
async getContractBalance(contractId, assetId) {
|
5825
5877
|
const { contractBalance } = await this.operations.getContractBalance({
|
5826
|
-
contract: import_address4.Address
|
5878
|
+
contract: new import_address4.Address(contractId).toB256(),
|
5827
5879
|
asset: (0, import_utils30.hexlify)(assetId)
|
5828
5880
|
});
|
5829
5881
|
return (0, import_math19.bn)(contractBalance.amount, 10);
|
@@ -5837,7 +5889,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5837
5889
|
*/
|
5838
5890
|
async getBalance(owner, assetId) {
|
5839
5891
|
const { balance } = await this.operations.getBalance({
|
5840
|
-
owner: import_address4.Address
|
5892
|
+
owner: new import_address4.Address(owner).toB256(),
|
5841
5893
|
assetId: (0, import_utils30.hexlify)(assetId)
|
5842
5894
|
});
|
5843
5895
|
return (0, import_math19.bn)(balance.amount, 10);
|
@@ -5858,7 +5910,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5858
5910
|
* but the current Fuel-Core implementation does not support pagination yet.
|
5859
5911
|
*/
|
5860
5912
|
first: 1e4,
|
5861
|
-
filter: { owner: import_address4.Address
|
5913
|
+
filter: { owner: new import_address4.Address(owner).toB256() }
|
5862
5914
|
});
|
5863
5915
|
const balances = edges.map(({ node }) => ({
|
5864
5916
|
assetId: node.assetId,
|
@@ -5881,7 +5933,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5881
5933
|
inputArgs: paginationArgs,
|
5882
5934
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
|
5883
5935
|
}),
|
5884
|
-
owner: import_address4.Address
|
5936
|
+
owner: new import_address4.Address(address).toB256()
|
5885
5937
|
});
|
5886
5938
|
const messages = edges.map(({ node }) => ({
|
5887
5939
|
messageId: import_transactions22.InputMessageCoder.getMessageId({
|
@@ -5891,8 +5943,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5891
5943
|
amount: (0, import_math19.bn)(node.amount),
|
5892
5944
|
data: node.data
|
5893
5945
|
}),
|
5894
|
-
sender: import_address4.Address
|
5895
|
-
recipient: import_address4.Address
|
5946
|
+
sender: new import_address4.Address(node.sender),
|
5947
|
+
recipient: new import_address4.Address(node.recipient),
|
5896
5948
|
nonce: node.nonce,
|
5897
5949
|
amount: (0, import_math19.bn)(node.amount),
|
5898
5950
|
data: import_transactions22.InputMessageCoder.decodeData(node.data),
|
@@ -5990,8 +6042,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5990
6042
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
5991
6043
|
stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
|
5992
6044
|
},
|
5993
|
-
sender: import_address4.Address
|
5994
|
-
recipient: import_address4.Address
|
6045
|
+
sender: new import_address4.Address(sender),
|
6046
|
+
recipient: new import_address4.Address(recipient),
|
5995
6047
|
nonce,
|
5996
6048
|
amount: (0, import_math19.bn)(amount),
|
5997
6049
|
data
|
@@ -6105,8 +6157,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
6105
6157
|
amount: (0, import_math19.bn)(rawMessage.amount),
|
6106
6158
|
data: rawMessage.data
|
6107
6159
|
}),
|
6108
|
-
sender: import_address4.Address
|
6109
|
-
recipient: import_address4.Address
|
6160
|
+
sender: new import_address4.Address(rawMessage.sender),
|
6161
|
+
recipient: new import_address4.Address(rawMessage.recipient),
|
6110
6162
|
nonce,
|
6111
6163
|
amount: (0, import_math19.bn)(rawMessage.amount),
|
6112
6164
|
data: import_transactions22.InputMessageCoder.decodeData(rawMessage.data),
|
@@ -6172,6 +6224,8 @@ cacheInputs_fn = function(inputs, transactionId) {
|
|
6172
6224
|
__publicField(Provider, "chainInfoCache", {});
|
6173
6225
|
/** @hidden */
|
6174
6226
|
__publicField(Provider, "nodeInfoCache", {});
|
6227
|
+
/** @hidden */
|
6228
|
+
__publicField(Provider, "incompatibleNodeVersionMessage", "");
|
6175
6229
|
|
6176
6230
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6177
6231
|
var import_errors21 = require("@fuel-ts/errors");
|
@@ -6179,613 +6233,9 @@ var import_math20 = require("@fuel-ts/math");
|
|
6179
6233
|
var import_transactions23 = require("@fuel-ts/transactions");
|
6180
6234
|
var import_utils33 = require("@fuel-ts/utils");
|
6181
6235
|
|
6182
|
-
// src/providers/chains.ts
|
6183
|
-
var CHAIN_IDS = {
|
6184
|
-
eth: {
|
6185
|
-
mainnet: 1,
|
6186
|
-
sepolia: 11155111,
|
6187
|
-
foundry: 31337
|
6188
|
-
},
|
6189
|
-
fuel: {
|
6190
|
-
devnet: 0,
|
6191
|
-
testnet: 0,
|
6192
|
-
mainnet: 9889
|
6193
|
-
}
|
6194
|
-
};
|
6195
|
-
|
6196
|
-
// src/providers/assets/utils/url.ts
|
6197
|
-
var DELIMITER_PATH = "/";
|
6198
|
-
var trimRegex = /^\/|\/$/g;
|
6199
|
-
var trimPath = (path2 = "") => path2.replace(trimRegex, "");
|
6200
|
-
function urlJoin(baseUrl, ...paths) {
|
6201
|
-
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
6202
|
-
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
6203
|
-
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
6204
|
-
if (rootPath && hasBaseUrl) {
|
6205
|
-
allPaths.unshift("");
|
6206
|
-
}
|
6207
|
-
return allPaths.join(DELIMITER_PATH);
|
6208
|
-
}
|
6209
|
-
|
6210
|
-
// src/providers/assets/utils/resolveIconPaths.ts
|
6211
|
-
function resolveIconPaths(assets2, basePath = "./") {
|
6212
|
-
return assets2.map((asset) => ({
|
6213
|
-
...asset,
|
6214
|
-
icon: urlJoin(basePath, asset.icon)
|
6215
|
-
}));
|
6216
|
-
}
|
6217
|
-
|
6218
|
-
// src/providers/assets/utils/fuelAssetsBaseUrl.ts
|
6219
|
-
var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
|
6220
|
-
|
6221
|
-
// src/providers/assets/assets.ts
|
6222
|
-
var rawAssets = [
|
6223
|
-
{
|
6224
|
-
name: "Ethereum",
|
6225
|
-
symbol: "ETH",
|
6226
|
-
icon: "eth.svg",
|
6227
|
-
networks: [
|
6228
|
-
{
|
6229
|
-
type: "ethereum",
|
6230
|
-
chainId: CHAIN_IDS.eth.sepolia,
|
6231
|
-
decimals: 18
|
6232
|
-
},
|
6233
|
-
{
|
6234
|
-
type: "ethereum",
|
6235
|
-
chainId: CHAIN_IDS.eth.foundry,
|
6236
|
-
decimals: 18
|
6237
|
-
},
|
6238
|
-
{
|
6239
|
-
type: "ethereum",
|
6240
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6241
|
-
decimals: 18
|
6242
|
-
},
|
6243
|
-
{
|
6244
|
-
type: "fuel",
|
6245
|
-
chainId: CHAIN_IDS.fuel.devnet,
|
6246
|
-
decimals: 9,
|
6247
|
-
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6248
|
-
},
|
6249
|
-
{
|
6250
|
-
type: "fuel",
|
6251
|
-
chainId: CHAIN_IDS.fuel.testnet,
|
6252
|
-
decimals: 9,
|
6253
|
-
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6254
|
-
},
|
6255
|
-
{
|
6256
|
-
type: "fuel",
|
6257
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6258
|
-
decimals: 9,
|
6259
|
-
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6260
|
-
}
|
6261
|
-
]
|
6262
|
-
},
|
6263
|
-
{
|
6264
|
-
name: "WETH",
|
6265
|
-
symbol: "WETH",
|
6266
|
-
icon: "weth.svg",
|
6267
|
-
networks: [
|
6268
|
-
{
|
6269
|
-
type: "ethereum",
|
6270
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6271
|
-
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
6272
|
-
decimals: 18
|
6273
|
-
},
|
6274
|
-
{
|
6275
|
-
type: "fuel",
|
6276
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6277
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6278
|
-
assetId: "0xa38a5a8beeb08d95744bc7f58528073f4052b254def59eba20c99c202b5acaa3",
|
6279
|
-
decimals: 9
|
6280
|
-
}
|
6281
|
-
]
|
6282
|
-
},
|
6283
|
-
{
|
6284
|
-
name: "weETH",
|
6285
|
-
symbol: "weETH",
|
6286
|
-
icon: "weETH.webp",
|
6287
|
-
networks: [
|
6288
|
-
{
|
6289
|
-
type: "ethereum",
|
6290
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6291
|
-
address: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
|
6292
|
-
decimals: 18
|
6293
|
-
},
|
6294
|
-
{
|
6295
|
-
type: "fuel",
|
6296
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6297
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6298
|
-
assetId: "0x239ed6e12b7ce4089ee245244e3bf906999a6429c2a9a445a1e1faf56914a4ab",
|
6299
|
-
decimals: 9
|
6300
|
-
}
|
6301
|
-
]
|
6302
|
-
},
|
6303
|
-
{
|
6304
|
-
name: "rsETH",
|
6305
|
-
symbol: "rsETH",
|
6306
|
-
icon: "rsETH.webp",
|
6307
|
-
networks: [
|
6308
|
-
{
|
6309
|
-
type: "ethereum",
|
6310
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6311
|
-
address: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
|
6312
|
-
decimals: 18
|
6313
|
-
},
|
6314
|
-
{
|
6315
|
-
type: "fuel",
|
6316
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6317
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6318
|
-
assetId: "0xbae80f7fb8aa6b90d9b01ef726ec847cc4f59419c4d5f2ea88fec785d1b0e849",
|
6319
|
-
decimals: 9
|
6320
|
-
}
|
6321
|
-
]
|
6322
|
-
},
|
6323
|
-
{
|
6324
|
-
name: "rETH",
|
6325
|
-
symbol: "rETH",
|
6326
|
-
icon: "reth.svg",
|
6327
|
-
networks: [
|
6328
|
-
{
|
6329
|
-
type: "ethereum",
|
6330
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6331
|
-
address: "0xae78736cd615f374d3085123a210448e74fc6393",
|
6332
|
-
decimals: 18
|
6333
|
-
},
|
6334
|
-
{
|
6335
|
-
type: "fuel",
|
6336
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6337
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6338
|
-
assetId: "0xf3f9a0ed0ce8eac5f89d6b83e41b3848212d5b5f56108c54a205bb228ca30c16",
|
6339
|
-
decimals: 9
|
6340
|
-
}
|
6341
|
-
]
|
6342
|
-
},
|
6343
|
-
{
|
6344
|
-
name: "wbETH",
|
6345
|
-
symbol: "wbETH",
|
6346
|
-
icon: "wbeth.png",
|
6347
|
-
networks: [
|
6348
|
-
{
|
6349
|
-
type: "ethereum",
|
6350
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6351
|
-
address: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
|
6352
|
-
decimals: 18
|
6353
|
-
},
|
6354
|
-
{
|
6355
|
-
type: "fuel",
|
6356
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6357
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6358
|
-
assetId: "0x7843c74bef935e837f2bcf67b5d64ecb46dd53ff86375530b0caf3699e8ffafe",
|
6359
|
-
decimals: 9
|
6360
|
-
}
|
6361
|
-
]
|
6362
|
-
},
|
6363
|
-
{
|
6364
|
-
name: "rstETH",
|
6365
|
-
symbol: "rstETH",
|
6366
|
-
icon: "rstETH.webp",
|
6367
|
-
networks: [
|
6368
|
-
{
|
6369
|
-
type: "ethereum",
|
6370
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6371
|
-
address: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
6372
|
-
decimals: 18
|
6373
|
-
},
|
6374
|
-
{
|
6375
|
-
type: "fuel",
|
6376
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6377
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6378
|
-
assetId: "0x962792286fbc9b1d5860b4551362a12249362c21594c77abf4b3fe2bbe8d977a",
|
6379
|
-
decimals: 9
|
6380
|
-
}
|
6381
|
-
]
|
6382
|
-
},
|
6383
|
-
{
|
6384
|
-
name: "amphrETH",
|
6385
|
-
symbol: "amphrETH",
|
6386
|
-
icon: "amphrETH.png",
|
6387
|
-
networks: [
|
6388
|
-
{
|
6389
|
-
type: "ethereum",
|
6390
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6391
|
-
address: "0x5fD13359Ba15A84B76f7F87568309040176167cd",
|
6392
|
-
decimals: 18
|
6393
|
-
},
|
6394
|
-
{
|
6395
|
-
type: "fuel",
|
6396
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6397
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6398
|
-
assetId: "0x05fc623e57bd7bc1258efa8e4f62b05af5471d73df6f2c2dc11ecc81134c4f36",
|
6399
|
-
decimals: 9
|
6400
|
-
}
|
6401
|
-
]
|
6402
|
-
},
|
6403
|
-
{
|
6404
|
-
name: "Manta mBTC",
|
6405
|
-
symbol: "Manta mBTC",
|
6406
|
-
icon: "manta-mbtc.svg",
|
6407
|
-
networks: [
|
6408
|
-
{
|
6409
|
-
type: "ethereum",
|
6410
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6411
|
-
address: "0x4041381e947CFD3D483d67a25C6aa9Dc924250c5",
|
6412
|
-
decimals: 18
|
6413
|
-
},
|
6414
|
-
{
|
6415
|
-
type: "fuel",
|
6416
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6417
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6418
|
-
assetId: "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b",
|
6419
|
-
decimals: 9
|
6420
|
-
}
|
6421
|
-
]
|
6422
|
-
},
|
6423
|
-
{
|
6424
|
-
name: "Manta mETH",
|
6425
|
-
symbol: "Manta mETH",
|
6426
|
-
icon: "manta-meth.svg",
|
6427
|
-
networks: [
|
6428
|
-
{
|
6429
|
-
type: "ethereum",
|
6430
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6431
|
-
address: "0x8CdF550C04Bc9B9F10938368349C9c8051A772b6",
|
6432
|
-
decimals: 18
|
6433
|
-
},
|
6434
|
-
{
|
6435
|
-
type: "fuel",
|
6436
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6437
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6438
|
-
assetId: "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4",
|
6439
|
-
decimals: 9
|
6440
|
-
}
|
6441
|
-
]
|
6442
|
-
},
|
6443
|
-
{
|
6444
|
-
name: "Manta mUSD",
|
6445
|
-
symbol: "Manta mUSD",
|
6446
|
-
icon: "manta-musd.svg",
|
6447
|
-
networks: [
|
6448
|
-
{
|
6449
|
-
type: "ethereum",
|
6450
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6451
|
-
address: "0x3f24E1d7a973867fC2A03fE199E5502514E0e11E",
|
6452
|
-
decimals: 18
|
6453
|
-
},
|
6454
|
-
{
|
6455
|
-
type: "fuel",
|
6456
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6457
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6458
|
-
assetId: "0x89cb9401e55d49c3269654dd1cdfb0e80e57823a4a7db98ba8fc5953b120fef4",
|
6459
|
-
decimals: 9
|
6460
|
-
}
|
6461
|
-
]
|
6462
|
-
},
|
6463
|
-
{
|
6464
|
-
name: "pumpBTC",
|
6465
|
-
symbol: "pumpBTC",
|
6466
|
-
icon: "pumpbtc.webp",
|
6467
|
-
networks: [
|
6468
|
-
{
|
6469
|
-
type: "ethereum",
|
6470
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6471
|
-
address: "0xf469fbd2abcd6b9de8e169d128226c0fc90a012e",
|
6472
|
-
decimals: 8
|
6473
|
-
},
|
6474
|
-
{
|
6475
|
-
type: "fuel",
|
6476
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6477
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6478
|
-
assetId: "0x0aa5eb2bb97ca915288b653a2529355d4dc66de2b37533213f0e4aeee3d3421f",
|
6479
|
-
decimals: 8
|
6480
|
-
}
|
6481
|
-
]
|
6482
|
-
},
|
6483
|
-
{
|
6484
|
-
name: "FBTC",
|
6485
|
-
symbol: "FBTC",
|
6486
|
-
icon: "fbtc.svg",
|
6487
|
-
networks: [
|
6488
|
-
{
|
6489
|
-
type: "ethereum",
|
6490
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6491
|
-
address: "0xc96de26018a54d51c097160568752c4e3bd6c364",
|
6492
|
-
decimals: 8
|
6493
|
-
},
|
6494
|
-
{
|
6495
|
-
type: "fuel",
|
6496
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6497
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6498
|
-
assetId: "0xb5ecb0a1e08e2abbabf624ffea089df933376855f468ade35c6375b00c33996a",
|
6499
|
-
decimals: 8
|
6500
|
-
}
|
6501
|
-
]
|
6502
|
-
},
|
6503
|
-
{
|
6504
|
-
name: "SolvBTC",
|
6505
|
-
symbol: "SolvBTC",
|
6506
|
-
icon: "solvBTC.webp",
|
6507
|
-
networks: [
|
6508
|
-
{
|
6509
|
-
type: "ethereum",
|
6510
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6511
|
-
address: "0x7a56e1c57c7475ccf742a1832b028f0456652f97",
|
6512
|
-
decimals: 18
|
6513
|
-
},
|
6514
|
-
{
|
6515
|
-
type: "fuel",
|
6516
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6517
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6518
|
-
assetId: "0x1186afea9affb88809c210e13e2330b5258c2cef04bb8fff5eff372b7bd3f40f",
|
6519
|
-
decimals: 9
|
6520
|
-
}
|
6521
|
-
]
|
6522
|
-
},
|
6523
|
-
{
|
6524
|
-
name: "SolvBTC.BBN",
|
6525
|
-
symbol: "SolvBTC.BBN",
|
6526
|
-
icon: "SolvBTC.BBN.png",
|
6527
|
-
networks: [
|
6528
|
-
{
|
6529
|
-
type: "ethereum",
|
6530
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6531
|
-
address: "0xd9d920aa40f578ab794426f5c90f6c731d159def",
|
6532
|
-
decimals: 18
|
6533
|
-
},
|
6534
|
-
{
|
6535
|
-
type: "fuel",
|
6536
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6537
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6538
|
-
assetId: "0x7a4f087c957d30218223c2baaaa365355c9ca81b6ea49004cfb1590a5399216f",
|
6539
|
-
decimals: 9
|
6540
|
-
}
|
6541
|
-
]
|
6542
|
-
},
|
6543
|
-
{
|
6544
|
-
name: "Mantle mETH",
|
6545
|
-
symbol: "Mantle mETH",
|
6546
|
-
icon: "mantle-meth.svg",
|
6547
|
-
networks: [
|
6548
|
-
{
|
6549
|
-
type: "ethereum",
|
6550
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6551
|
-
address: "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa",
|
6552
|
-
decimals: 18
|
6553
|
-
},
|
6554
|
-
{
|
6555
|
-
type: "fuel",
|
6556
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6557
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6558
|
-
assetId: "0x642a5db59ec323c2f846d4d4cf3e58d78aff64accf4f8f6455ba0aa3ef000a3b",
|
6559
|
-
decimals: 9
|
6560
|
-
}
|
6561
|
-
]
|
6562
|
-
},
|
6563
|
-
{
|
6564
|
-
name: "sDAI",
|
6565
|
-
symbol: "sDAI",
|
6566
|
-
icon: "sdai.svg",
|
6567
|
-
networks: [
|
6568
|
-
{
|
6569
|
-
type: "ethereum",
|
6570
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6571
|
-
address: "0x83f20f44975d03b1b09e64809b757c47f942beea",
|
6572
|
-
decimals: 18
|
6573
|
-
},
|
6574
|
-
{
|
6575
|
-
type: "fuel",
|
6576
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6577
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6578
|
-
assetId: "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958",
|
6579
|
-
decimals: 9
|
6580
|
-
}
|
6581
|
-
]
|
6582
|
-
},
|
6583
|
-
{
|
6584
|
-
name: "USDT",
|
6585
|
-
symbol: "USDT",
|
6586
|
-
icon: "usdt.svg",
|
6587
|
-
networks: [
|
6588
|
-
{
|
6589
|
-
type: "ethereum",
|
6590
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6591
|
-
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
6592
|
-
decimals: 6
|
6593
|
-
},
|
6594
|
-
{
|
6595
|
-
type: "fuel",
|
6596
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6597
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6598
|
-
assetId: "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e",
|
6599
|
-
decimals: 6
|
6600
|
-
}
|
6601
|
-
]
|
6602
|
-
},
|
6603
|
-
{
|
6604
|
-
name: "USDC",
|
6605
|
-
symbol: "USDC",
|
6606
|
-
icon: "usdc.svg",
|
6607
|
-
networks: [
|
6608
|
-
{
|
6609
|
-
type: "ethereum",
|
6610
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6611
|
-
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
6612
|
-
decimals: 6
|
6613
|
-
},
|
6614
|
-
{
|
6615
|
-
type: "fuel",
|
6616
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6617
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6618
|
-
assetId: "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b",
|
6619
|
-
decimals: 6
|
6620
|
-
}
|
6621
|
-
]
|
6622
|
-
},
|
6623
|
-
{
|
6624
|
-
name: "USDe",
|
6625
|
-
symbol: "USDe",
|
6626
|
-
icon: "USDe.svg",
|
6627
|
-
networks: [
|
6628
|
-
{
|
6629
|
-
type: "ethereum",
|
6630
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6631
|
-
address: "0x4c9edd5852cd905f086c759e8383e09bff1e68b3",
|
6632
|
-
decimals: 18
|
6633
|
-
},
|
6634
|
-
{
|
6635
|
-
type: "fuel",
|
6636
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6637
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6638
|
-
assetId: "0xb6133b2ef9f6153eb869125d23dcf20d1e735331b5e41b15a6a7a6cec70e8651",
|
6639
|
-
decimals: 9
|
6640
|
-
}
|
6641
|
-
]
|
6642
|
-
},
|
6643
|
-
{
|
6644
|
-
name: "sUSDe",
|
6645
|
-
symbol: "sUSDe",
|
6646
|
-
icon: "sUSDe.webp",
|
6647
|
-
networks: [
|
6648
|
-
{
|
6649
|
-
type: "ethereum",
|
6650
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6651
|
-
address: "0x9d39a5de30e57443bff2a8307a4256c8797a3497",
|
6652
|
-
decimals: 18
|
6653
|
-
},
|
6654
|
-
{
|
6655
|
-
type: "fuel",
|
6656
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6657
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6658
|
-
assetId: "0xd05563025104fc36496c15c7021ad6b31034b0e89a356f4f818045d1f48808bc",
|
6659
|
-
decimals: 9
|
6660
|
-
}
|
6661
|
-
]
|
6662
|
-
},
|
6663
|
-
{
|
6664
|
-
name: "rsUSDe",
|
6665
|
-
symbol: "rsUSDe",
|
6666
|
-
icon: "rsUSDe.svg",
|
6667
|
-
networks: [
|
6668
|
-
{
|
6669
|
-
type: "ethereum",
|
6670
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6671
|
-
address: "0x82f5104b23FF2FA54C2345F821dAc9369e9E0B26",
|
6672
|
-
decimals: 18
|
6673
|
-
},
|
6674
|
-
{
|
6675
|
-
type: "fuel",
|
6676
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6677
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6678
|
-
assetId: "0x78d4522ec607f6e8efb66ea49439d1ee48623cf763f9688a8eada025def033d9",
|
6679
|
-
decimals: 9
|
6680
|
-
}
|
6681
|
-
]
|
6682
|
-
},
|
6683
|
-
{
|
6684
|
-
name: "wstETH",
|
6685
|
-
symbol: "wstETH",
|
6686
|
-
icon: "wsteth.svg",
|
6687
|
-
networks: [
|
6688
|
-
{
|
6689
|
-
type: "ethereum",
|
6690
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6691
|
-
address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
6692
|
-
decimals: 18
|
6693
|
-
},
|
6694
|
-
{
|
6695
|
-
type: "fuel",
|
6696
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6697
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6698
|
-
assetId: "0x1a7815cc9f75db5c24a5b0814bfb706bb9fe485333e98254015de8f48f84c67b",
|
6699
|
-
decimals: 9
|
6700
|
-
}
|
6701
|
-
]
|
6702
|
-
},
|
6703
|
-
{
|
6704
|
-
name: "ezETH",
|
6705
|
-
symbol: "ezETH",
|
6706
|
-
icon: "ezeth.webp",
|
6707
|
-
networks: [
|
6708
|
-
{
|
6709
|
-
type: "ethereum",
|
6710
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6711
|
-
address: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
|
6712
|
-
decimals: 18
|
6713
|
-
},
|
6714
|
-
{
|
6715
|
-
type: "fuel",
|
6716
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6717
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6718
|
-
assetId: "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0",
|
6719
|
-
decimals: 9
|
6720
|
-
}
|
6721
|
-
]
|
6722
|
-
},
|
6723
|
-
{
|
6724
|
-
name: "pzETH",
|
6725
|
-
symbol: "pzETH",
|
6726
|
-
icon: "pzETH.webp",
|
6727
|
-
networks: [
|
6728
|
-
{
|
6729
|
-
type: "ethereum",
|
6730
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6731
|
-
address: "0x8c9532a60e0e7c6bbd2b2c1303f63ace1c3e9811",
|
6732
|
-
decimals: 18
|
6733
|
-
},
|
6734
|
-
{
|
6735
|
-
type: "fuel",
|
6736
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6737
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6738
|
-
assetId: "0x1493d4ec82124de8f9b625682de69dcccda79e882b89a55a8c737b12de67bd68",
|
6739
|
-
decimals: 9
|
6740
|
-
}
|
6741
|
-
]
|
6742
|
-
},
|
6743
|
-
{
|
6744
|
-
name: "Re7LRT",
|
6745
|
-
symbol: "Re7LRT",
|
6746
|
-
icon: "Re7LRT.png",
|
6747
|
-
networks: [
|
6748
|
-
{
|
6749
|
-
type: "ethereum",
|
6750
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6751
|
-
address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a",
|
6752
|
-
decimals: 18
|
6753
|
-
},
|
6754
|
-
{
|
6755
|
-
type: "fuel",
|
6756
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6757
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6758
|
-
assetId: "0xf2fc648c23a5db24610a1cf696acc4f0f6d9a7d6028dd9944964ab23f6e35995",
|
6759
|
-
decimals: 9
|
6760
|
-
}
|
6761
|
-
]
|
6762
|
-
},
|
6763
|
-
{
|
6764
|
-
name: "steakLRT",
|
6765
|
-
symbol: "steakLRT",
|
6766
|
-
icon: "steakLRT.png",
|
6767
|
-
networks: [
|
6768
|
-
{
|
6769
|
-
type: "ethereum",
|
6770
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6771
|
-
address: "0xBEEF69Ac7870777598A04B2bd4771c71212E6aBc",
|
6772
|
-
decimals: 18
|
6773
|
-
},
|
6774
|
-
{
|
6775
|
-
type: "fuel",
|
6776
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6777
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6778
|
-
assetId: "0x4fc8ac9f101df07e2c2dec4a53c8c42c439bdbe5e36ea2d863a61ff60afafc30",
|
6779
|
-
decimals: 9
|
6780
|
-
}
|
6781
|
-
]
|
6782
|
-
}
|
6783
|
-
];
|
6784
|
-
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
6785
|
-
|
6786
6236
|
// src/test-utils/test-asset-id.ts
|
6787
6237
|
var import_crypto4 = require("@fuel-ts/crypto");
|
6788
|
-
var
|
6238
|
+
var import_utils34 = require("@fuel-ts/utils");
|
6789
6239
|
var _TestAssetId = class {
|
6790
6240
|
constructor(value) {
|
6791
6241
|
this.value = value;
|
@@ -6793,7 +6243,7 @@ var _TestAssetId = class {
|
|
6793
6243
|
static random(count = 1) {
|
6794
6244
|
const assetIds = [];
|
6795
6245
|
for (let i = 0; i < count; i++) {
|
6796
|
-
assetIds.push(new _TestAssetId((0,
|
6246
|
+
assetIds.push(new _TestAssetId((0, import_utils34.hexlify)((0, import_crypto4.randomBytes)(32))));
|
6797
6247
|
}
|
6798
6248
|
return assetIds;
|
6799
6249
|
}
|
@@ -6809,11 +6259,12 @@ __publicField(TestAssetId, "B", new _TestAssetId(
|
|
6809
6259
|
// src/test-utils/wallet-config.ts
|
6810
6260
|
var import_crypto9 = require("@fuel-ts/crypto");
|
6811
6261
|
var import_errors27 = require("@fuel-ts/errors");
|
6812
|
-
var
|
6262
|
+
var import_math23 = require("@fuel-ts/math");
|
6263
|
+
var import_utils43 = require("@fuel-ts/utils");
|
6813
6264
|
|
6814
6265
|
// src/wallet/base-wallet-unlocked.ts
|
6815
6266
|
var import_hasher4 = require("@fuel-ts/hasher");
|
6816
|
-
var
|
6267
|
+
var import_utils38 = require("@fuel-ts/utils");
|
6817
6268
|
|
6818
6269
|
// src/account.ts
|
6819
6270
|
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
@@ -6822,7 +6273,7 @@ var import_crypto5 = require("@fuel-ts/crypto");
|
|
6822
6273
|
var import_errors22 = require("@fuel-ts/errors");
|
6823
6274
|
var import_math21 = require("@fuel-ts/math");
|
6824
6275
|
var import_transactions24 = require("@fuel-ts/transactions");
|
6825
|
-
var
|
6276
|
+
var import_utils36 = require("@fuel-ts/utils");
|
6826
6277
|
var import_ramda9 = require("ramda");
|
6827
6278
|
|
6828
6279
|
// src/providers/utils/merge-quantities.ts
|
@@ -6846,19 +6297,15 @@ var AbstractAccount = class {
|
|
6846
6297
|
// src/utils/formatTransferToContractScriptData.ts
|
6847
6298
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
6848
6299
|
var import_address5 = require("@fuel-ts/address");
|
6849
|
-
var
|
6300
|
+
var import_utils35 = require("@fuel-ts/utils");
|
6850
6301
|
var asm = __toESM(require("@fuels/vm-asm"));
|
6851
6302
|
var formatTransferToContractScriptData = (transferParams) => {
|
6852
6303
|
const numberCoder = new import_abi_coder7.BigNumberCoder("u64");
|
6853
6304
|
return transferParams.reduce((acc, transferParam) => {
|
6854
6305
|
const { assetId, amount, contractId } = transferParam;
|
6855
6306
|
const encoded = numberCoder.encode(amount);
|
6856
|
-
const scriptData = (0,
|
6857
|
-
|
6858
|
-
encoded,
|
6859
|
-
(0, import_utils36.arrayify)(assetId)
|
6860
|
-
]);
|
6861
|
-
return (0, import_utils36.concat)([acc, scriptData]);
|
6307
|
+
const scriptData = (0, import_utils35.concat)([new import_address5.Address(contractId).toBytes(), encoded, (0, import_utils35.arrayify)(assetId)]);
|
6308
|
+
return (0, import_utils35.concat)([acc, scriptData]);
|
6862
6309
|
}, new Uint8Array());
|
6863
6310
|
};
|
6864
6311
|
var assembleTransferToContractScript = async (transferParams) => {
|
@@ -6867,7 +6314,7 @@ var assembleTransferToContractScript = async (transferParams) => {
|
|
6867
6314
|
let script = new Uint8Array();
|
6868
6315
|
transferParams.forEach((_, i) => {
|
6869
6316
|
const offset = (import_abi_coder7.CONTRACT_ID_LEN + import_abi_coder7.WORD_SIZE + import_abi_coder7.ASSET_ID_LEN) * i;
|
6870
|
-
script = (0,
|
6317
|
+
script = (0, import_utils35.concat)([
|
6871
6318
|
script,
|
6872
6319
|
// Load ScriptData into register 0x10.
|
6873
6320
|
asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
|
@@ -6883,7 +6330,7 @@ var assembleTransferToContractScript = async (transferParams) => {
|
|
6883
6330
|
asm.tr(17, 19, 20).to_bytes()
|
6884
6331
|
]);
|
6885
6332
|
});
|
6886
|
-
script = (0,
|
6333
|
+
script = (0, import_utils35.concat)([script, asm.ret(1).to_bytes()]);
|
6887
6334
|
return { script, scriptData };
|
6888
6335
|
};
|
6889
6336
|
|
@@ -6913,7 +6360,7 @@ var Account = class extends AbstractAccount {
|
|
6913
6360
|
super();
|
6914
6361
|
this._provider = provider;
|
6915
6362
|
this._connector = connector;
|
6916
|
-
this.address = import_address6.Address
|
6363
|
+
this.address = new import_address6.Address(address);
|
6917
6364
|
}
|
6918
6365
|
/**
|
6919
6366
|
* The provider used to interact with the network.
|
@@ -7151,7 +6598,7 @@ var Account = class extends AbstractAccount {
|
|
7151
6598
|
addTransfer(request, transferParams) {
|
7152
6599
|
const { destination, amount, assetId } = transferParams;
|
7153
6600
|
this.validateTransferAmount(amount);
|
7154
|
-
request.addCoinOutput(import_address6.Address
|
6601
|
+
request.addCoinOutput(new import_address6.Address(destination), amount, assetId);
|
7155
6602
|
return request;
|
7156
6603
|
}
|
7157
6604
|
/**
|
@@ -7191,8 +6638,8 @@ var Account = class extends AbstractAccount {
|
|
7191
6638
|
const defaultAssetId = await this.provider.getBaseAssetId();
|
7192
6639
|
const transferParams = contractTransferParams.map((transferParam) => {
|
7193
6640
|
const amount = (0, import_math21.bn)(transferParam.amount);
|
7194
|
-
const contractAddress = import_address6.Address
|
7195
|
-
const assetId = transferParam.assetId ? (0,
|
6641
|
+
const contractAddress = new import_address6.Address(transferParam.contractId);
|
6642
|
+
const assetId = transferParam.assetId ? (0, import_utils36.hexlify)(transferParam.assetId) : defaultAssetId;
|
7196
6643
|
if (amount.lte(0)) {
|
7197
6644
|
throw new import_errors22.FuelError(
|
7198
6645
|
import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
@@ -7222,15 +6669,15 @@ var Account = class extends AbstractAccount {
|
|
7222
6669
|
* @returns A promise that resolves to the transaction response.
|
7223
6670
|
*/
|
7224
6671
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
7225
|
-
const recipientAddress = import_address6.Address
|
7226
|
-
const recipientDataArray = (0,
|
6672
|
+
const recipientAddress = new import_address6.Address(recipient);
|
6673
|
+
const recipientDataArray = (0, import_utils36.arrayify)(
|
7227
6674
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
7228
6675
|
);
|
7229
|
-
const amountDataArray = (0,
|
6676
|
+
const amountDataArray = (0, import_utils36.arrayify)(
|
7230
6677
|
"0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
7231
6678
|
);
|
7232
6679
|
const script = new Uint8Array([
|
7233
|
-
...(0,
|
6680
|
+
...(0, import_utils36.arrayify)(withdrawScript.bytes),
|
7234
6681
|
...recipientDataArray,
|
7235
6682
|
...amountDataArray
|
7236
6683
|
]);
|
@@ -7258,7 +6705,7 @@ var Account = class extends AbstractAccount {
|
|
7258
6705
|
*
|
7259
6706
|
* @returns A promise that resolves to the transaction cost object.
|
7260
6707
|
*/
|
7261
|
-
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6708
|
+
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [], gasPrice } = {}) {
|
7262
6709
|
const txRequestClone = (0, import_ramda9.clone)(transactionRequestify(transactionRequestLike));
|
7263
6710
|
const baseAssetId = await this.provider.getBaseAssetId();
|
7264
6711
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
@@ -7293,7 +6740,8 @@ var Account = class extends AbstractAccount {
|
|
7293
6740
|
({ amount, assetId }) => updateAssetInput(assetId, amount)
|
7294
6741
|
);
|
7295
6742
|
const txCost = await this.provider.getTransactionCost(txRequestClone, {
|
7296
|
-
signatureCallback
|
6743
|
+
signatureCallback,
|
6744
|
+
gasPrice
|
7297
6745
|
});
|
7298
6746
|
return {
|
7299
6747
|
...txCost,
|
@@ -7375,7 +6823,7 @@ var Account = class extends AbstractAccount {
|
|
7375
6823
|
*/
|
7376
6824
|
generateFakeResources(coins) {
|
7377
6825
|
return coins.map((coin) => ({
|
7378
|
-
id: (0,
|
6826
|
+
id: (0, import_utils36.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
|
7379
6827
|
owner: this.address,
|
7380
6828
|
blockCreated: (0, import_math21.bn)(1),
|
7381
6829
|
txCreatedIdx: (0, import_math21.bn)(1),
|
@@ -7412,7 +6860,7 @@ var Account = class extends AbstractAccount {
|
|
7412
6860
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
7413
6861
|
}) {
|
7414
6862
|
const request = transactionRequestify(transactionRequest);
|
7415
|
-
if (!(0,
|
6863
|
+
if (!(0, import_utils36.isDefined)(setGasLimit)) {
|
7416
6864
|
request.gasLimit = gasUsed;
|
7417
6865
|
} else if (gasUsed.gt(setGasLimit)) {
|
7418
6866
|
throw new import_errors22.FuelError(
|
@@ -7420,7 +6868,7 @@ var Account = class extends AbstractAccount {
|
|
7420
6868
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
7421
6869
|
);
|
7422
6870
|
}
|
7423
|
-
if (!(0,
|
6871
|
+
if (!(0, import_utils36.isDefined)(setMaxFee)) {
|
7424
6872
|
request.maxFee = maxFee;
|
7425
6873
|
} else if (maxFee.gt(setMaxFee)) {
|
7426
6874
|
throw new import_errors22.FuelError(
|
@@ -7436,7 +6884,7 @@ var Account = class extends AbstractAccount {
|
|
7436
6884
|
var import_address7 = require("@fuel-ts/address");
|
7437
6885
|
var import_crypto6 = require("@fuel-ts/crypto");
|
7438
6886
|
var import_errors23 = require("@fuel-ts/errors");
|
7439
|
-
var
|
6887
|
+
var import_utils37 = require("@fuel-ts/utils");
|
7440
6888
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
7441
6889
|
var DEFAULT_KDF_PARAMS_R = 8;
|
7442
6890
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -7450,7 +6898,7 @@ var removeHexPrefix = (hexString) => {
|
|
7450
6898
|
};
|
7451
6899
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
7452
6900
|
const privateKeyBuffer = (0, import_crypto6.bufferFromString)(removeHexPrefix(privateKey), "hex");
|
7453
|
-
const ownerAddress = import_address7.Address
|
6901
|
+
const ownerAddress = new import_address7.Address(address);
|
7454
6902
|
const salt = (0, import_crypto6.randomBytes)(DEFAULT_KEY_SIZE);
|
7455
6903
|
const key = (0, import_crypto6.scrypt)({
|
7456
6904
|
password: (0, import_crypto6.bufferFromString)(password),
|
@@ -7518,7 +6966,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7518
6966
|
);
|
7519
6967
|
}
|
7520
6968
|
const buffer = await (0, import_crypto6.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
7521
|
-
const privateKey = (0,
|
6969
|
+
const privateKey = (0, import_utils37.hexlify)(buffer);
|
7522
6970
|
return privateKey;
|
7523
6971
|
}
|
7524
6972
|
|
@@ -7563,7 +7011,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
7563
7011
|
*/
|
7564
7012
|
async signMessage(message) {
|
7565
7013
|
const signedMessage = await this.signer().sign((0, import_hasher4.hashMessage)(message));
|
7566
|
-
return (0,
|
7014
|
+
return (0, import_utils38.hexlify)(signedMessage);
|
7567
7015
|
}
|
7568
7016
|
/**
|
7569
7017
|
* Signs a transaction with the wallet's private key.
|
@@ -7576,7 +7024,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
7576
7024
|
const chainId = await this.provider.getChainId();
|
7577
7025
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
7578
7026
|
const signature = await this.signer().sign(hashedTransaction);
|
7579
|
-
return (0,
|
7027
|
+
return (0, import_utils38.hexlify)(signature);
|
7580
7028
|
}
|
7581
7029
|
/**
|
7582
7030
|
* Populates a transaction with the witnesses signature.
|
@@ -7651,13 +7099,13 @@ var import_crypto8 = require("@fuel-ts/crypto");
|
|
7651
7099
|
var import_errors26 = require("@fuel-ts/errors");
|
7652
7100
|
var import_hasher7 = require("@fuel-ts/hasher");
|
7653
7101
|
var import_math22 = require("@fuel-ts/math");
|
7654
|
-
var
|
7102
|
+
var import_utils42 = require("@fuel-ts/utils");
|
7655
7103
|
|
7656
7104
|
// src/mnemonic/mnemonic.ts
|
7657
7105
|
var import_crypto7 = require("@fuel-ts/crypto");
|
7658
7106
|
var import_errors25 = require("@fuel-ts/errors");
|
7659
7107
|
var import_hasher6 = require("@fuel-ts/hasher");
|
7660
|
-
var
|
7108
|
+
var import_utils40 = require("@fuel-ts/utils");
|
7661
7109
|
|
7662
7110
|
// src/wordlists/words/english.ts
|
7663
7111
|
var english = [
|
@@ -9714,7 +9162,7 @@ var english = [
|
|
9714
9162
|
// src/mnemonic/utils.ts
|
9715
9163
|
var import_errors24 = require("@fuel-ts/errors");
|
9716
9164
|
var import_hasher5 = require("@fuel-ts/hasher");
|
9717
|
-
var
|
9165
|
+
var import_utils39 = require("@fuel-ts/utils");
|
9718
9166
|
function getLowerMask(bits) {
|
9719
9167
|
return (1 << bits) - 1;
|
9720
9168
|
}
|
@@ -9749,14 +9197,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
9749
9197
|
}
|
9750
9198
|
}
|
9751
9199
|
const checksumBits = entropy.length / 4;
|
9752
|
-
const checksum = (0,
|
9200
|
+
const checksum = (0, import_utils39.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
9753
9201
|
indices[indices.length - 1] <<= checksumBits;
|
9754
9202
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
9755
9203
|
return indices;
|
9756
9204
|
}
|
9757
9205
|
function mnemonicWordsToEntropy(words, wordlist) {
|
9758
9206
|
const size = Math.ceil(11 * words.length / 8);
|
9759
|
-
const entropy = (0,
|
9207
|
+
const entropy = (0, import_utils39.arrayify)(new Uint8Array(size));
|
9760
9208
|
let offset = 0;
|
9761
9209
|
for (let i = 0; i < words.length; i += 1) {
|
9762
9210
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -9776,7 +9224,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9776
9224
|
const entropyBits = 32 * words.length / 3;
|
9777
9225
|
const checksumBits = words.length / 3;
|
9778
9226
|
const checksumMask = getUpperMask(checksumBits);
|
9779
|
-
const checksum = (0,
|
9227
|
+
const checksum = (0, import_utils39.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9780
9228
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9781
9229
|
throw new import_errors24.FuelError(
|
9782
9230
|
import_errors24.ErrorCode.INVALID_CHECKSUM,
|
@@ -9787,7 +9235,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9787
9235
|
}
|
9788
9236
|
|
9789
9237
|
// src/mnemonic/mnemonic.ts
|
9790
|
-
var MasterSecret = (0,
|
9238
|
+
var MasterSecret = (0, import_utils40.toUtf8Bytes)("Bitcoin seed");
|
9791
9239
|
var MainnetPRV = "0x0488ade4";
|
9792
9240
|
var TestnetPRV = "0x04358394";
|
9793
9241
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
@@ -9851,7 +9299,7 @@ var Mnemonic = class {
|
|
9851
9299
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
9852
9300
|
const words = getWords(phrase);
|
9853
9301
|
assertMnemonic(words);
|
9854
|
-
return (0,
|
9302
|
+
return (0, import_utils40.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
9855
9303
|
}
|
9856
9304
|
/**
|
9857
9305
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -9859,7 +9307,7 @@ var Mnemonic = class {
|
|
9859
9307
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9860
9308
|
*/
|
9861
9309
|
static entropyToMnemonic(entropy, wordlist = english) {
|
9862
|
-
const entropyBytes = (0,
|
9310
|
+
const entropyBytes = (0, import_utils40.arrayify)(entropy);
|
9863
9311
|
assertWordList(wordlist);
|
9864
9312
|
assertEntropy(entropyBytes);
|
9865
9313
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -9871,8 +9319,8 @@ var Mnemonic = class {
|
|
9871
9319
|
*/
|
9872
9320
|
static mnemonicToSeed(phrase, passphrase = "") {
|
9873
9321
|
assertMnemonic(getWords(phrase));
|
9874
|
-
const phraseBytes = (0,
|
9875
|
-
const salt = (0,
|
9322
|
+
const phraseBytes = (0, import_utils40.toUtf8Bytes)(getPhrase(phrase));
|
9323
|
+
const salt = (0, import_utils40.toUtf8Bytes)(`mnemonic${passphrase}`);
|
9876
9324
|
return (0, import_crypto7.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
9877
9325
|
}
|
9878
9326
|
/**
|
@@ -9928,14 +9376,14 @@ var Mnemonic = class {
|
|
9928
9376
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9929
9377
|
*/
|
9930
9378
|
static masterKeysFromSeed(seed) {
|
9931
|
-
const seedArray = (0,
|
9379
|
+
const seedArray = (0, import_utils40.arrayify)(seed);
|
9932
9380
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9933
9381
|
throw new import_errors25.FuelError(
|
9934
9382
|
import_errors25.ErrorCode.INVALID_SEED,
|
9935
9383
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9936
9384
|
);
|
9937
9385
|
}
|
9938
|
-
return (0,
|
9386
|
+
return (0, import_utils40.arrayify)((0, import_crypto7.computeHmac)("sha512", MasterSecret, seedArray));
|
9939
9387
|
}
|
9940
9388
|
/**
|
9941
9389
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -9946,22 +9394,22 @@ var Mnemonic = class {
|
|
9946
9394
|
*/
|
9947
9395
|
static seedToExtendedKey(seed, testnet = false) {
|
9948
9396
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
9949
|
-
const prefix = (0,
|
9397
|
+
const prefix = (0, import_utils40.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
9950
9398
|
const depth = "0x00";
|
9951
9399
|
const fingerprint = "0x00000000";
|
9952
9400
|
const index = "0x00000000";
|
9953
9401
|
const chainCode = masterKey.slice(32);
|
9954
9402
|
const privateKey = masterKey.slice(0, 32);
|
9955
|
-
const extendedKey = (0,
|
9403
|
+
const extendedKey = (0, import_utils40.concat)([
|
9956
9404
|
prefix,
|
9957
9405
|
depth,
|
9958
9406
|
fingerprint,
|
9959
9407
|
index,
|
9960
9408
|
chainCode,
|
9961
|
-
(0,
|
9409
|
+
(0, import_utils40.concat)(["0x00", privateKey])
|
9962
9410
|
]);
|
9963
|
-
const checksum = (0,
|
9964
|
-
return (0,
|
9411
|
+
const checksum = (0, import_utils40.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
|
9412
|
+
return (0, import_utils40.encodeBase58)((0, import_utils40.concat)([extendedKey, checksum]));
|
9965
9413
|
}
|
9966
9414
|
/**
|
9967
9415
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -9976,7 +9424,7 @@ var Mnemonic = class {
|
|
9976
9424
|
* @returns A randomly generated mnemonic
|
9977
9425
|
*/
|
9978
9426
|
static generate(size = 32, extraEntropy = "") {
|
9979
|
-
const entropy = extraEntropy ? (0, import_hasher6.sha256)((0,
|
9427
|
+
const entropy = extraEntropy ? (0, import_hasher6.sha256)((0, import_utils40.concat)([(0, import_crypto7.randomBytes)(size), (0, import_utils40.arrayify)(extraEntropy)])) : (0, import_crypto7.randomBytes)(size);
|
9980
9428
|
return Mnemonic.entropyToMnemonic(entropy);
|
9981
9429
|
}
|
9982
9430
|
};
|
@@ -9984,12 +9432,12 @@ var mnemonic_default = Mnemonic;
|
|
9984
9432
|
|
9985
9433
|
// src/hdwallet/hdwallet.ts
|
9986
9434
|
var HARDENED_INDEX = 2147483648;
|
9987
|
-
var MainnetPRV2 = (0,
|
9988
|
-
var MainnetPUB = (0,
|
9989
|
-
var TestnetPRV2 = (0,
|
9990
|
-
var TestnetPUB = (0,
|
9435
|
+
var MainnetPRV2 = (0, import_utils42.hexlify)("0x0488ade4");
|
9436
|
+
var MainnetPUB = (0, import_utils42.hexlify)("0x0488b21e");
|
9437
|
+
var TestnetPRV2 = (0, import_utils42.hexlify)("0x04358394");
|
9438
|
+
var TestnetPUB = (0, import_utils42.hexlify)("0x043587cf");
|
9991
9439
|
function base58check(data) {
|
9992
|
-
return (0,
|
9440
|
+
return (0, import_utils42.encodeBase58)((0, import_utils42.concat)([data, (0, import_utils42.dataSlice)((0, import_hasher7.sha256)((0, import_hasher7.sha256)(data)), 0, 4)]));
|
9993
9441
|
}
|
9994
9442
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
9995
9443
|
if (isPublic) {
|
@@ -9998,11 +9446,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
9998
9446
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
9999
9447
|
}
|
10000
9448
|
function isPublicExtendedKey(extendedKey) {
|
10001
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
9449
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils42.hexlify)(extendedKey.slice(0, 4)));
|
10002
9450
|
}
|
10003
9451
|
function isValidExtendedKey(extendedKey) {
|
10004
9452
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
10005
|
-
(0,
|
9453
|
+
(0, import_utils42.hexlify)(extendedKey.slice(0, 4))
|
10006
9454
|
);
|
10007
9455
|
}
|
10008
9456
|
function parsePath(path2, depth = 0) {
|
@@ -10020,8 +9468,8 @@ function parsePath(path2, depth = 0) {
|
|
10020
9468
|
var HDWallet = class {
|
10021
9469
|
depth = 0;
|
10022
9470
|
index = 0;
|
10023
|
-
fingerprint = (0,
|
10024
|
-
parentFingerprint = (0,
|
9471
|
+
fingerprint = (0, import_utils42.hexlify)("0x00000000");
|
9472
|
+
parentFingerprint = (0, import_utils42.hexlify)("0x00000000");
|
10025
9473
|
privateKey;
|
10026
9474
|
publicKey;
|
10027
9475
|
chainCode;
|
@@ -10033,8 +9481,8 @@ var HDWallet = class {
|
|
10033
9481
|
constructor(config) {
|
10034
9482
|
if (config.privateKey) {
|
10035
9483
|
const signer = new Signer(config.privateKey);
|
10036
|
-
this.publicKey = (0,
|
10037
|
-
this.privateKey = (0,
|
9484
|
+
this.publicKey = (0, import_utils42.hexlify)(signer.compressedPublicKey);
|
9485
|
+
this.privateKey = (0, import_utils42.hexlify)(config.privateKey);
|
10038
9486
|
} else {
|
10039
9487
|
if (!config.publicKey) {
|
10040
9488
|
throw new import_errors26.FuelError(
|
@@ -10042,10 +9490,10 @@ var HDWallet = class {
|
|
10042
9490
|
"Both public and private Key cannot be missing. At least one should be provided."
|
10043
9491
|
);
|
10044
9492
|
}
|
10045
|
-
this.publicKey = (0,
|
9493
|
+
this.publicKey = (0, import_utils42.hexlify)(config.publicKey);
|
10046
9494
|
}
|
10047
9495
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
10048
|
-
this.fingerprint = (0,
|
9496
|
+
this.fingerprint = (0, import_utils42.dataSlice)((0, import_crypto8.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
|
10049
9497
|
this.depth = config.depth || this.depth;
|
10050
9498
|
this.index = config.index || this.index;
|
10051
9499
|
this.chainCode = config.chainCode;
|
@@ -10061,9 +9509,9 @@ var HDWallet = class {
|
|
10061
9509
|
* @returns A new instance of HDWallet on the derived index
|
10062
9510
|
*/
|
10063
9511
|
deriveIndex(index) {
|
10064
|
-
const privateKey = this.privateKey && (0,
|
10065
|
-
const publicKey = (0,
|
10066
|
-
const chainCode = (0,
|
9512
|
+
const privateKey = this.privateKey && (0, import_utils42.arrayify)(this.privateKey);
|
9513
|
+
const publicKey = (0, import_utils42.arrayify)(this.publicKey);
|
9514
|
+
const chainCode = (0, import_utils42.arrayify)(this.chainCode);
|
10067
9515
|
const data = new Uint8Array(37);
|
10068
9516
|
if (index & HARDENED_INDEX) {
|
10069
9517
|
if (!privateKey) {
|
@@ -10074,10 +9522,10 @@ var HDWallet = class {
|
|
10074
9522
|
}
|
10075
9523
|
data.set(privateKey, 1);
|
10076
9524
|
} else {
|
10077
|
-
data.set((0,
|
9525
|
+
data.set((0, import_utils42.arrayify)(this.publicKey));
|
10078
9526
|
}
|
10079
9527
|
data.set((0, import_math22.toBytes)(index, 4), 33);
|
10080
|
-
const bytes = (0,
|
9528
|
+
const bytes = (0, import_utils42.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
|
10081
9529
|
const IL = bytes.slice(0, 32);
|
10082
9530
|
const IR = bytes.slice(32);
|
10083
9531
|
if (privateKey) {
|
@@ -10091,7 +9539,7 @@ var HDWallet = class {
|
|
10091
9539
|
parentFingerprint: this.fingerprint
|
10092
9540
|
});
|
10093
9541
|
}
|
10094
|
-
const signer = new Signer((0,
|
9542
|
+
const signer = new Signer((0, import_utils42.hexlify)(IL));
|
10095
9543
|
const Ki = signer.addPoint(publicKey);
|
10096
9544
|
return new HDWallet({
|
10097
9545
|
publicKey: Ki,
|
@@ -10126,12 +9574,12 @@ var HDWallet = class {
|
|
10126
9574
|
);
|
10127
9575
|
}
|
10128
9576
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
10129
|
-
const depth = (0,
|
9577
|
+
const depth = (0, import_utils42.hexlify)(Uint8Array.from([this.depth]));
|
10130
9578
|
const parentFingerprint = this.parentFingerprint;
|
10131
9579
|
const index = (0, import_math22.toHex)(this.index, 4);
|
10132
9580
|
const chainCode = this.chainCode;
|
10133
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
10134
|
-
const extendedKey = (0,
|
9581
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils42.concat)(["0x00", this.privateKey]) : this.publicKey;
|
9582
|
+
const extendedKey = (0, import_utils42.arrayify)((0, import_utils42.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
10135
9583
|
return base58check(extendedKey);
|
10136
9584
|
}
|
10137
9585
|
/**
|
@@ -10143,13 +9591,13 @@ var HDWallet = class {
|
|
10143
9591
|
static fromSeed(seed) {
|
10144
9592
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
10145
9593
|
return new HDWallet({
|
10146
|
-
chainCode: (0,
|
10147
|
-
privateKey: (0,
|
9594
|
+
chainCode: (0, import_utils42.arrayify)(masterKey.slice(32)),
|
9595
|
+
privateKey: (0, import_utils42.arrayify)(masterKey.slice(0, 32))
|
10148
9596
|
});
|
10149
9597
|
}
|
10150
9598
|
static fromExtendedKey(extendedKey) {
|
10151
|
-
const decoded = (0,
|
10152
|
-
const bytes = (0,
|
9599
|
+
const decoded = (0, import_utils42.hexlify)((0, import_math22.toBytes)((0, import_utils42.decodeBase58)(extendedKey)));
|
9600
|
+
const bytes = (0, import_utils42.arrayify)(decoded);
|
10153
9601
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
10154
9602
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
10155
9603
|
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -10158,9 +9606,9 @@ var HDWallet = class {
|
|
10158
9606
|
throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
10159
9607
|
}
|
10160
9608
|
const depth = bytes[4];
|
10161
|
-
const parentFingerprint = (0,
|
10162
|
-
const index = parseInt((0,
|
10163
|
-
const chainCode = (0,
|
9609
|
+
const parentFingerprint = (0, import_utils42.hexlify)(bytes.slice(5, 9));
|
9610
|
+
const index = parseInt((0, import_utils42.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
9611
|
+
const chainCode = (0, import_utils42.hexlify)(bytes.slice(13, 45));
|
10164
9612
|
const key = bytes.slice(45, 78);
|
10165
9613
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
10166
9614
|
throw new import_errors26.FuelError(
|
@@ -10361,14 +9809,14 @@ var WalletsConfig = class {
|
|
10361
9809
|
constructor(baseAssetId, config) {
|
10362
9810
|
WalletsConfig.validate(config);
|
10363
9811
|
this.options = config;
|
10364
|
-
const { assets
|
9812
|
+
const { assets, coinsPerAsset, amountPerCoin, messages } = this.options;
|
10365
9813
|
this.wallets = this.generateWallets();
|
10366
9814
|
this.initialState = {
|
10367
9815
|
messages: WalletsConfig.createMessages(this.wallets, messages),
|
10368
9816
|
coins: WalletsConfig.createCoins(
|
10369
9817
|
this.wallets,
|
10370
9818
|
baseAssetId,
|
10371
|
-
|
9819
|
+
assets,
|
10372
9820
|
coinsPerAsset,
|
10373
9821
|
amountPerCoin
|
10374
9822
|
)
|
@@ -10378,7 +9826,7 @@ var WalletsConfig = class {
|
|
10378
9826
|
return {
|
10379
9827
|
...snapshotConfig,
|
10380
9828
|
stateConfig: {
|
10381
|
-
...snapshotConfig?.stateConfig ??
|
9829
|
+
...snapshotConfig?.stateConfig ?? import_utils43.defaultSnapshotConfigs.stateConfig,
|
10382
9830
|
coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
|
10383
9831
|
messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
|
10384
9832
|
}
|
@@ -10393,25 +9841,25 @@ var WalletsConfig = class {
|
|
10393
9841
|
/**
|
10394
9842
|
* Create coins for the wallets in the format that the chain expects.
|
10395
9843
|
*/
|
10396
|
-
static createCoins(wallets, baseAssetId,
|
9844
|
+
static createCoins(wallets, baseAssetId, assets, coinsPerAsset, amountPerCoin) {
|
10397
9845
|
const coins = [];
|
10398
9846
|
let assetIds = [baseAssetId];
|
10399
|
-
if (Array.isArray(
|
10400
|
-
assetIds = assetIds.concat(
|
9847
|
+
if (Array.isArray(assets)) {
|
9848
|
+
assetIds = assetIds.concat(assets.map((a) => a.value));
|
10401
9849
|
} else {
|
10402
|
-
assetIds = assetIds.concat(TestAssetId.random(
|
9850
|
+
assetIds = assetIds.concat(TestAssetId.random(assets - 1).map((a) => a.value));
|
10403
9851
|
}
|
10404
9852
|
wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
|
10405
9853
|
assetIds.forEach((assetId) => {
|
10406
9854
|
for (let index = 0; index < coinsPerAsset; index++) {
|
10407
9855
|
coins.push({
|
10408
|
-
amount: amountPerCoin,
|
9856
|
+
amount: (0, import_math23.bn)(amountPerCoin).toString(),
|
10409
9857
|
asset_id: assetId,
|
10410
9858
|
owner: walletAddress,
|
10411
9859
|
tx_pointer_block_height: 0,
|
10412
9860
|
tx_pointer_tx_idx: 0,
|
10413
9861
|
output_index: 0,
|
10414
|
-
tx_id: (0,
|
9862
|
+
tx_id: (0, import_utils43.hexlify)((0, import_crypto9.randomBytes)(32))
|
10415
9863
|
});
|
10416
9864
|
}
|
10417
9865
|
});
|
@@ -10420,7 +9868,7 @@ var WalletsConfig = class {
|
|
10420
9868
|
}
|
10421
9869
|
static validate({
|
10422
9870
|
count: wallets,
|
10423
|
-
assets
|
9871
|
+
assets,
|
10424
9872
|
coinsPerAsset,
|
10425
9873
|
amountPerCoin
|
10426
9874
|
}) {
|
@@ -10430,7 +9878,7 @@ var WalletsConfig = class {
|
|
10430
9878
|
"Number of wallets must be greater than zero."
|
10431
9879
|
);
|
10432
9880
|
}
|
10433
|
-
if (Array.isArray(
|
9881
|
+
if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
|
10434
9882
|
throw new import_errors27.FuelError(
|
10435
9883
|
import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
10436
9884
|
"Number of assets per wallet must be greater than zero."
|
@@ -10442,7 +9890,7 @@ var WalletsConfig = class {
|
|
10442
9890
|
"Number of coins per asset must be greater than zero."
|
10443
9891
|
);
|
10444
9892
|
}
|
10445
|
-
if (amountPerCoin
|
9893
|
+
if ((0, import_math23.bn)(amountPerCoin).lt(0)) {
|
10446
9894
|
throw new import_errors27.FuelError(
|
10447
9895
|
import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
10448
9896
|
"Amount per coin must be greater than or equal to zero."
|
@@ -10467,7 +9915,7 @@ async function setupTestProviderAndWallets({
|
|
10467
9915
|
} = {}) {
|
10468
9916
|
Symbol.dispose ??= Symbol("Symbol.dispose");
|
10469
9917
|
const walletsConfig = new WalletsConfig(
|
10470
|
-
nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V2?.base_asset_id ??
|
9918
|
+
nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V2?.base_asset_id ?? import_utils44.defaultSnapshotConfigs.chainConfig.consensus_parameters.V2.base_asset_id,
|
10471
9919
|
{
|
10472
9920
|
...defaultWalletConfigOptions,
|
10473
9921
|
...walletsConfigOptions
|
@@ -10477,7 +9925,7 @@ async function setupTestProviderAndWallets({
|
|
10477
9925
|
loggingEnabled: false,
|
10478
9926
|
...nodeOptions,
|
10479
9927
|
snapshotConfig: (0, import_ramda10.mergeDeepRight)(
|
10480
|
-
|
9928
|
+
import_utils44.defaultSnapshotConfigs,
|
10481
9929
|
walletsConfig.apply(nodeOptions?.snapshotConfig)
|
10482
9930
|
),
|
10483
9931
|
port: nodeOptions.port || "0"
|
@@ -10518,8 +9966,8 @@ async function setupTestProviderAndWallets({
|
|
10518
9966
|
// src/test-utils/test-message.ts
|
10519
9967
|
var import_address8 = require("@fuel-ts/address");
|
10520
9968
|
var import_crypto10 = require("@fuel-ts/crypto");
|
10521
|
-
var
|
10522
|
-
var
|
9969
|
+
var import_math24 = require("@fuel-ts/math");
|
9970
|
+
var import_utils45 = require("@fuel-ts/utils");
|
10523
9971
|
var TestMessage = class {
|
10524
9972
|
sender;
|
10525
9973
|
recipient;
|
@@ -10536,7 +9984,7 @@ var TestMessage = class {
|
|
10536
9984
|
constructor({
|
10537
9985
|
sender = import_address8.Address.fromRandom(),
|
10538
9986
|
recipient = import_address8.Address.fromRandom(),
|
10539
|
-
nonce = (0,
|
9987
|
+
nonce = (0, import_utils45.hexlify)((0, import_crypto10.randomBytes)(32)),
|
10540
9988
|
amount = 1e6,
|
10541
9989
|
data = "",
|
10542
9990
|
// Will default to empty data in order to be a spendable message
|
@@ -10555,7 +10003,7 @@ var TestMessage = class {
|
|
10555
10003
|
sender: this.sender.toB256(),
|
10556
10004
|
recipient: recipient?.toB256() ?? this.recipient.toB256(),
|
10557
10005
|
nonce: this.nonce,
|
10558
|
-
amount: (0,
|
10006
|
+
amount: (0, import_math24.bn)(this.amount).toNumber(),
|
10559
10007
|
data,
|
10560
10008
|
da_height: this.da_height
|
10561
10009
|
};
|