@fuel-ts/account 0.99.0 → 0.100.1
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 +9 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +7 -6
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/types/data-type.d.ts +8 -1
- package/dist/connectors/types/data-type.d.ts.map +1 -1
- package/dist/index.global.js +4164 -3454
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1125 -691
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1035 -611
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts +1 -1
- package/dist/providers/__generated__/operations.d.ts +98 -3
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +77 -11
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource-cache.d.ts +6 -4
- package/dist/providers/resource-cache.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +10 -1
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +29 -1
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary-from-serialized.d.ts +7 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary-from-serialized.d.ts.map +1 -0
- package/dist/providers/transaction-summary/call.d.ts +8 -2
- package/dist/providers/transaction-summary/call.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/index.d.ts +1 -0
- package/dist/providers/transaction-summary/index.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/receipt.d.ts +3 -2
- package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +5 -3
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/handle-gql-error-message.d.ts +0 -4
- package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
- package/dist/providers/utils/helpers.d.ts +14 -0
- package/dist/providers/utils/helpers.d.ts.map +1 -0
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts +4 -3
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/providers/utils/serialization.d.ts +35 -0
- package/dist/providers/utils/serialization.d.ts.map +1 -0
- package/dist/signer/signer.d.ts +1 -1
- package/dist/test-utils.global.js +3879 -3184
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +1002 -607
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +922 -527
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +3 -3
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/utils/predicate-script-loader-instructions.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +21 -21
package/dist/test-utils.mjs
CHANGED
@@ -397,10 +397,9 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
397
397
|
assetId = coinQuantityLike.assetId;
|
398
398
|
max = coinQuantityLike.max ?? void 0;
|
399
399
|
}
|
400
|
-
const bnAmount = bn(amount);
|
401
400
|
return {
|
402
401
|
assetId: hexlify3(assetId),
|
403
|
-
amount:
|
402
|
+
amount: bn(amount),
|
404
403
|
max: max ? bn(max) : void 0
|
405
404
|
};
|
406
405
|
};
|
@@ -417,17 +416,27 @@ var addAmountToCoinQuantities = (params) => {
|
|
417
416
|
};
|
418
417
|
|
419
418
|
// src/providers/provider.ts
|
420
|
-
import { Address as Address3 } from "@fuel-ts/address";
|
421
|
-
import { ErrorCode as ErrorCode16, FuelError as
|
422
|
-
import {
|
423
|
-
import {
|
424
|
-
import { arrayify as arrayify13, hexlify as
|
425
|
-
import { checkFuelCoreVersionCompatibility, versions } from "@fuel-ts/versions";
|
426
|
-
import { equalBytes } from "@noble/curves/abstract/utils";
|
419
|
+
import { Address as Address3, isB256 } from "@fuel-ts/address";
|
420
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError20 } from "@fuel-ts/errors";
|
421
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
422
|
+
import { InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
423
|
+
import { arrayify as arrayify13, hexlify as hexlify18, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
424
|
+
import { checkFuelCoreVersionCompatibility, gte, versions } from "@fuel-ts/versions";
|
427
425
|
import { GraphQLClient } from "graphql-request";
|
428
426
|
import gql2 from "graphql-tag";
|
429
427
|
import { clone as clone8 } from "ramda";
|
430
428
|
|
429
|
+
// src/connectors/utils/promises.ts
|
430
|
+
import { FuelError as FuelError2 } from "@fuel-ts/errors";
|
431
|
+
function deferPromise() {
|
432
|
+
const defer = {};
|
433
|
+
defer.promise = new Promise((resolve, reject) => {
|
434
|
+
defer.reject = reject;
|
435
|
+
defer.resolve = resolve;
|
436
|
+
});
|
437
|
+
return defer;
|
438
|
+
}
|
439
|
+
|
431
440
|
// src/providers/__generated__/operations.ts
|
432
441
|
import gql from "graphql-tag";
|
433
442
|
var SubmittedStatusFragmentDoc = gql`
|
@@ -1035,6 +1044,16 @@ var EstimatePredicatesDocument = gql`
|
|
1035
1044
|
}
|
1036
1045
|
}
|
1037
1046
|
${TransactionEstimatePredicatesFragmentDoc}`;
|
1047
|
+
var EstimatePredicatesAndGasPriceDocument = gql`
|
1048
|
+
query estimatePredicatesAndGasPrice($encodedTransaction: HexString!, $blockHorizon: U32!) {
|
1049
|
+
estimatePredicates(tx: $encodedTransaction) {
|
1050
|
+
...transactionEstimatePredicatesFragment
|
1051
|
+
}
|
1052
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
1053
|
+
gasPrice
|
1054
|
+
}
|
1055
|
+
}
|
1056
|
+
${TransactionEstimatePredicatesFragmentDoc}`;
|
1038
1057
|
var GetLatestBlockDocument = gql`
|
1039
1058
|
query getLatestBlock {
|
1040
1059
|
chain {
|
@@ -1150,6 +1169,13 @@ var GetBalanceDocument = gql`
|
|
1150
1169
|
}
|
1151
1170
|
}
|
1152
1171
|
`;
|
1172
|
+
var GetBalanceV2Document = gql`
|
1173
|
+
query getBalanceV2($owner: Address!, $assetId: AssetId!) {
|
1174
|
+
balance(owner: $owner, assetId: $assetId) {
|
1175
|
+
amountU128
|
1176
|
+
}
|
1177
|
+
}
|
1178
|
+
`;
|
1153
1179
|
var GetLatestGasPriceDocument = gql`
|
1154
1180
|
query getLatestGasPrice {
|
1155
1181
|
latestGasPrice {
|
@@ -1182,6 +1208,27 @@ var GetBalancesDocument = gql`
|
|
1182
1208
|
}
|
1183
1209
|
}
|
1184
1210
|
`;
|
1211
|
+
var GetBalancesV2Document = gql`
|
1212
|
+
query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
1213
|
+
balances(
|
1214
|
+
filter: $filter
|
1215
|
+
after: $after
|
1216
|
+
before: $before
|
1217
|
+
first: $first
|
1218
|
+
last: $last
|
1219
|
+
) {
|
1220
|
+
pageInfo {
|
1221
|
+
...pageInfoFragment
|
1222
|
+
}
|
1223
|
+
edges {
|
1224
|
+
node {
|
1225
|
+
assetId
|
1226
|
+
amountU128
|
1227
|
+
}
|
1228
|
+
}
|
1229
|
+
}
|
1230
|
+
}
|
1231
|
+
${PageInfoFragmentDoc}`;
|
1185
1232
|
var GetMessagesDocument = gql`
|
1186
1233
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
1187
1234
|
messages(
|
@@ -1236,6 +1283,15 @@ var GetRelayedTransactionStatusDocument = gql`
|
|
1236
1283
|
}
|
1237
1284
|
}
|
1238
1285
|
${RelayedTransactionStatusFragmentDoc}`;
|
1286
|
+
var GetAssetDetailsDocument = gql`
|
1287
|
+
query getAssetDetails($assetId: AssetId!) {
|
1288
|
+
assetDetails(id: $assetId) {
|
1289
|
+
subId
|
1290
|
+
contractId
|
1291
|
+
totalSupply
|
1292
|
+
}
|
1293
|
+
}
|
1294
|
+
`;
|
1239
1295
|
var DryRunDocument = gql`
|
1240
1296
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean, $gasPrice: U64) {
|
1241
1297
|
dryRun(
|
@@ -1336,6 +1392,9 @@ function getSdk(requester) {
|
|
1336
1392
|
estimatePredicates(variables, options) {
|
1337
1393
|
return requester(EstimatePredicatesDocument, variables, options);
|
1338
1394
|
},
|
1395
|
+
estimatePredicatesAndGasPrice(variables, options) {
|
1396
|
+
return requester(EstimatePredicatesAndGasPriceDocument, variables, options);
|
1397
|
+
},
|
1339
1398
|
getLatestBlock(variables, options) {
|
1340
1399
|
return requester(GetLatestBlockDocument, variables, options);
|
1341
1400
|
},
|
@@ -1369,6 +1428,9 @@ function getSdk(requester) {
|
|
1369
1428
|
getBalance(variables, options) {
|
1370
1429
|
return requester(GetBalanceDocument, variables, options);
|
1371
1430
|
},
|
1431
|
+
getBalanceV2(variables, options) {
|
1432
|
+
return requester(GetBalanceV2Document, variables, options);
|
1433
|
+
},
|
1372
1434
|
getLatestGasPrice(variables, options) {
|
1373
1435
|
return requester(GetLatestGasPriceDocument, variables, options);
|
1374
1436
|
},
|
@@ -1378,6 +1440,9 @@ function getSdk(requester) {
|
|
1378
1440
|
getBalances(variables, options) {
|
1379
1441
|
return requester(GetBalancesDocument, variables, options);
|
1380
1442
|
},
|
1443
|
+
getBalancesV2(variables, options) {
|
1444
|
+
return requester(GetBalancesV2Document, variables, options);
|
1445
|
+
},
|
1381
1446
|
getMessages(variables, options) {
|
1382
1447
|
return requester(GetMessagesDocument, variables, options);
|
1383
1448
|
},
|
@@ -1393,6 +1458,9 @@ function getSdk(requester) {
|
|
1393
1458
|
getRelayedTransactionStatus(variables, options) {
|
1394
1459
|
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
1395
1460
|
},
|
1461
|
+
getAssetDetails(variables, options) {
|
1462
|
+
return requester(GetAssetDetailsDocument, variables, options);
|
1463
|
+
},
|
1396
1464
|
dryRun(variables, options) {
|
1397
1465
|
return requester(DryRunDocument, variables, options);
|
1398
1466
|
},
|
@@ -1421,36 +1489,35 @@ function getSdk(requester) {
|
|
1421
1489
|
}
|
1422
1490
|
|
1423
1491
|
// src/providers/fuel-graphql-subscriber.ts
|
1424
|
-
import { ErrorCode as ErrorCode2, FuelError as
|
1492
|
+
import { ErrorCode as ErrorCode2, FuelError as FuelError4 } from "@fuel-ts/errors";
|
1425
1493
|
import { print } from "graphql";
|
1426
1494
|
|
1427
1495
|
// src/providers/utils/handle-gql-error-message.ts
|
1428
|
-
import { ErrorCode, FuelError as
|
1496
|
+
import { ErrorCode, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1429
1497
|
var mapGqlErrorMessage = (error) => {
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
default:
|
1446
|
-
return new FuelError2(ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1498
|
+
if (new RegExp("the target cannot be met due to no coins available or exceeding the \\d+ coin limit." /* NOT_ENOUGH_COINS_MAX_COINS */).test(error.message)) {
|
1499
|
+
return new FuelError3(
|
1500
|
+
ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
1501
|
+
`Insufficient funds or too many small value coins. Consider combining UTXOs.`,
|
1502
|
+
{},
|
1503
|
+
error
|
1504
|
+
);
|
1505
|
+
}
|
1506
|
+
if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
|
1507
|
+
return new FuelError3(
|
1508
|
+
ErrorCode.ASSET_NOT_FOUND,
|
1509
|
+
`Asset not found for given asset id.`,
|
1510
|
+
{},
|
1511
|
+
error
|
1512
|
+
);
|
1447
1513
|
}
|
1514
|
+
return new FuelError3(ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1448
1515
|
};
|
1449
1516
|
var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
|
1450
1517
|
if (!incompatibleNodeVersionMessage) {
|
1451
1518
|
return error;
|
1452
1519
|
}
|
1453
|
-
return new
|
1520
|
+
return new FuelError3(
|
1454
1521
|
error.code,
|
1455
1522
|
`${error.message}
|
1456
1523
|
|
@@ -1469,7 +1536,7 @@ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = fal
|
|
1469
1536
|
}
|
1470
1537
|
const errorMessage = mappedErrors.map((err) => err.message).join("\n");
|
1471
1538
|
throw mapGqlErrorWithIncompatibleNodeVersion(
|
1472
|
-
new
|
1539
|
+
new FuelError3(ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
1473
1540
|
incompatibleNodeVersionMessage
|
1474
1541
|
);
|
1475
1542
|
};
|
@@ -1520,7 +1587,7 @@ var _FuelGraphqlSubscriber = class {
|
|
1520
1587
|
try {
|
1521
1588
|
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
1522
1589
|
} catch (e) {
|
1523
|
-
throw new
|
1590
|
+
throw new FuelError4(
|
1524
1591
|
ErrorCode2.STREAM_PARSING_ERROR,
|
1525
1592
|
`Error while parsing stream data response: ${text}`
|
1526
1593
|
);
|
@@ -1544,74 +1611,16 @@ __publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
|
|
1544
1611
|
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1545
1612
|
|
1546
1613
|
// src/providers/resource-cache.ts
|
1547
|
-
import {
|
1548
|
-
import { hexlify as
|
1549
|
-
var cache = /* @__PURE__ */ new Map();
|
1550
|
-
var ResourceCache = class {
|
1551
|
-
ttl;
|
1552
|
-
constructor(ttl) {
|
1553
|
-
this.ttl = ttl;
|
1554
|
-
if (typeof ttl !== "number" || this.ttl <= 0) {
|
1555
|
-
throw new FuelError4(
|
1556
|
-
ErrorCode3.INVALID_TTL,
|
1557
|
-
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
1558
|
-
);
|
1559
|
-
}
|
1560
|
-
}
|
1561
|
-
// Add resources to the cache
|
1562
|
-
set(transactionId, resources) {
|
1563
|
-
const currentTime = Date.now();
|
1564
|
-
const existingResources = cache.get(transactionId) || {
|
1565
|
-
utxos: /* @__PURE__ */ new Set(),
|
1566
|
-
messages: /* @__PURE__ */ new Set(),
|
1567
|
-
timestamp: currentTime
|
1568
|
-
};
|
1569
|
-
resources.utxos.forEach((utxo) => existingResources.utxos.add(hexlify4(utxo)));
|
1570
|
-
resources.messages.forEach((message) => existingResources.messages.add(hexlify4(message)));
|
1571
|
-
cache.set(transactionId, existingResources);
|
1572
|
-
}
|
1573
|
-
// Remove resources from the cache for a given transaction ID
|
1574
|
-
unset(transactionId) {
|
1575
|
-
cache.delete(transactionId);
|
1576
|
-
}
|
1577
|
-
// Get all cached resources and remove expired ones
|
1578
|
-
getActiveData() {
|
1579
|
-
const allResources = { utxos: [], messages: [] };
|
1580
|
-
const currentTime = Date.now();
|
1581
|
-
cache.forEach((resource, transactionId) => {
|
1582
|
-
if (currentTime - resource.timestamp < this.ttl) {
|
1583
|
-
allResources.utxos.push(...resource.utxos);
|
1584
|
-
allResources.messages.push(...resource.messages);
|
1585
|
-
} else {
|
1586
|
-
cache.delete(transactionId);
|
1587
|
-
}
|
1588
|
-
});
|
1589
|
-
return allResources;
|
1590
|
-
}
|
1591
|
-
// Check if a UTXO ID or message nonce is already cached and not expired
|
1592
|
-
isCached(key) {
|
1593
|
-
const currentTime = Date.now();
|
1594
|
-
for (const [transactionId, resourceData] of cache.entries()) {
|
1595
|
-
if (currentTime - resourceData.timestamp > this.ttl) {
|
1596
|
-
cache.delete(transactionId);
|
1597
|
-
} else if (resourceData.utxos.has(key) || resourceData.messages.has(key)) {
|
1598
|
-
return true;
|
1599
|
-
}
|
1600
|
-
}
|
1601
|
-
return false;
|
1602
|
-
}
|
1603
|
-
clear() {
|
1604
|
-
cache.clear();
|
1605
|
-
}
|
1606
|
-
};
|
1614
|
+
import { FuelError as FuelError14, ErrorCode as ErrorCode10 } from "@fuel-ts/errors";
|
1615
|
+
import { hexlify as hexlify16 } from "@fuel-ts/utils";
|
1607
1616
|
|
1608
1617
|
// src/providers/transaction-request/input.ts
|
1609
1618
|
import { BYTES_32 as BYTES_322, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
|
1610
1619
|
import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
1611
|
-
import { ErrorCode as
|
1620
|
+
import { ErrorCode as ErrorCode3, FuelError as FuelError5 } from "@fuel-ts/errors";
|
1612
1621
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1613
1622
|
import { InputType } from "@fuel-ts/transactions";
|
1614
|
-
import { arrayify as arrayify2, hexlify as
|
1623
|
+
import { arrayify as arrayify2, hexlify as hexlify4 } from "@fuel-ts/utils";
|
1615
1624
|
var inputify = (value) => {
|
1616
1625
|
const { type } = value;
|
1617
1626
|
switch (value.type) {
|
@@ -1620,11 +1629,11 @@ var inputify = (value) => {
|
|
1620
1629
|
const predicateData = arrayify2(value.predicateData ?? "0x");
|
1621
1630
|
return {
|
1622
1631
|
type: InputType.Coin,
|
1623
|
-
txID:
|
1632
|
+
txID: hexlify4(arrayify2(value.id).slice(0, BYTES_322)),
|
1624
1633
|
outputIndex: toNumber(arrayify2(value.id).slice(BYTES_322, UTXO_ID_LEN)),
|
1625
|
-
owner:
|
1634
|
+
owner: hexlify4(value.owner),
|
1626
1635
|
amount: bn2(value.amount),
|
1627
|
-
assetId:
|
1636
|
+
assetId: hexlify4(value.assetId),
|
1628
1637
|
txPointer: {
|
1629
1638
|
blockHeight: toNumber(arrayify2(value.txPointer).slice(0, 8)),
|
1630
1639
|
txIndex: toNumber(arrayify2(value.txPointer).slice(8, 16))
|
@@ -1633,8 +1642,8 @@ var inputify = (value) => {
|
|
1633
1642
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1634
1643
|
predicateLength: bn2(predicate.length),
|
1635
1644
|
predicateDataLength: bn2(predicateData.length),
|
1636
|
-
predicate:
|
1637
|
-
predicateData:
|
1645
|
+
predicate: hexlify4(predicate),
|
1646
|
+
predicateData: hexlify4(predicateData)
|
1638
1647
|
};
|
1639
1648
|
}
|
1640
1649
|
case InputType.Contract: {
|
@@ -1648,7 +1657,7 @@ var inputify = (value) => {
|
|
1648
1657
|
blockHeight: toNumber(arrayify2(value.txPointer).slice(0, 8)),
|
1649
1658
|
txIndex: toNumber(arrayify2(value.txPointer).slice(8, 16))
|
1650
1659
|
},
|
1651
|
-
contractID:
|
1660
|
+
contractID: hexlify4(value.contractId)
|
1652
1661
|
};
|
1653
1662
|
}
|
1654
1663
|
case InputType.Message: {
|
@@ -1657,23 +1666,23 @@ var inputify = (value) => {
|
|
1657
1666
|
const data = arrayify2(value.data ?? "0x");
|
1658
1667
|
return {
|
1659
1668
|
type: InputType.Message,
|
1660
|
-
sender:
|
1661
|
-
recipient:
|
1669
|
+
sender: hexlify4(value.sender),
|
1670
|
+
recipient: hexlify4(value.recipient),
|
1662
1671
|
amount: bn2(value.amount),
|
1663
|
-
nonce:
|
1672
|
+
nonce: hexlify4(value.nonce),
|
1664
1673
|
witnessIndex: value.witnessIndex,
|
1665
1674
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1666
1675
|
predicateLength: bn2(predicate.length),
|
1667
1676
|
predicateDataLength: bn2(predicateData.length),
|
1668
|
-
predicate:
|
1669
|
-
predicateData:
|
1670
|
-
data:
|
1677
|
+
predicate: hexlify4(predicate),
|
1678
|
+
predicateData: hexlify4(predicateData),
|
1679
|
+
data: hexlify4(data),
|
1671
1680
|
dataLength: data.length
|
1672
1681
|
};
|
1673
1682
|
}
|
1674
1683
|
default: {
|
1675
1684
|
throw new FuelError5(
|
1676
|
-
|
1685
|
+
ErrorCode3.INVALID_TRANSACTION_INPUT,
|
1677
1686
|
`Invalid transaction input type: ${type}.`
|
1678
1687
|
);
|
1679
1688
|
}
|
@@ -1682,19 +1691,19 @@ var inputify = (value) => {
|
|
1682
1691
|
|
1683
1692
|
// src/providers/transaction-request/output.ts
|
1684
1693
|
import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
1685
|
-
import { ErrorCode as
|
1694
|
+
import { ErrorCode as ErrorCode4, FuelError as FuelError6 } from "@fuel-ts/errors";
|
1686
1695
|
import { bn as bn3 } from "@fuel-ts/math";
|
1687
1696
|
import { OutputType } from "@fuel-ts/transactions";
|
1688
|
-
import { hexlify as
|
1697
|
+
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
1689
1698
|
var outputify = (value) => {
|
1690
1699
|
const { type } = value;
|
1691
1700
|
switch (type) {
|
1692
1701
|
case OutputType.Coin: {
|
1693
1702
|
return {
|
1694
1703
|
type: OutputType.Coin,
|
1695
|
-
to:
|
1704
|
+
to: hexlify5(value.to),
|
1696
1705
|
amount: bn3(value.amount),
|
1697
|
-
assetId:
|
1706
|
+
assetId: hexlify5(value.assetId)
|
1698
1707
|
};
|
1699
1708
|
}
|
1700
1709
|
case OutputType.Contract: {
|
@@ -1708,9 +1717,9 @@ var outputify = (value) => {
|
|
1708
1717
|
case OutputType.Change: {
|
1709
1718
|
return {
|
1710
1719
|
type: OutputType.Change,
|
1711
|
-
to:
|
1720
|
+
to: hexlify5(value.to),
|
1712
1721
|
amount: bn3(0),
|
1713
|
-
assetId:
|
1722
|
+
assetId: hexlify5(value.assetId)
|
1714
1723
|
};
|
1715
1724
|
}
|
1716
1725
|
case OutputType.Variable: {
|
@@ -1724,13 +1733,13 @@ var outputify = (value) => {
|
|
1724
1733
|
case OutputType.ContractCreated: {
|
1725
1734
|
return {
|
1726
1735
|
type: OutputType.ContractCreated,
|
1727
|
-
contractId:
|
1728
|
-
stateRoot:
|
1736
|
+
contractId: hexlify5(value.contractId),
|
1737
|
+
stateRoot: hexlify5(value.stateRoot)
|
1729
1738
|
};
|
1730
1739
|
}
|
1731
1740
|
default: {
|
1732
1741
|
throw new FuelError6(
|
1733
|
-
|
1742
|
+
ErrorCode4.INVALID_TRANSACTION_INPUT,
|
1734
1743
|
`Invalid transaction output type: ${type}.`
|
1735
1744
|
);
|
1736
1745
|
}
|
@@ -1760,31 +1769,157 @@ var isMessageCoin = (message) => !("data" in message);
|
|
1760
1769
|
var isCoin = (resource) => "id" in resource;
|
1761
1770
|
|
1762
1771
|
// src/providers/utils/receipts.ts
|
1772
|
+
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1773
|
+
import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
|
1774
|
+
|
1775
|
+
// src/providers/utils/serialization.ts
|
1763
1776
|
import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
|
1764
|
-
import { ErrorCode as
|
1777
|
+
import { ErrorCode as ErrorCode5, FuelError as FuelError7 } from "@fuel-ts/errors";
|
1765
1778
|
import { bn as bn4 } from "@fuel-ts/math";
|
1766
1779
|
import { getMintedAssetId, InputMessageCoder, ReceiptType } from "@fuel-ts/transactions";
|
1767
|
-
import {
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1780
|
+
import { hexlify as hexlify6, arrayify as arrayify3 } from "@fuel-ts/utils";
|
1781
|
+
var deserializeChain = (chain) => {
|
1782
|
+
const { name, daHeight, consensusParameters } = chain;
|
1783
|
+
const {
|
1784
|
+
contractParams,
|
1785
|
+
feeParams,
|
1786
|
+
predicateParams,
|
1787
|
+
scriptParams,
|
1788
|
+
txParams,
|
1789
|
+
gasCosts,
|
1790
|
+
baseAssetId,
|
1791
|
+
chainId,
|
1792
|
+
version
|
1793
|
+
} = consensusParameters;
|
1794
|
+
return {
|
1795
|
+
name,
|
1796
|
+
baseChainHeight: bn4(daHeight),
|
1797
|
+
consensusParameters: {
|
1798
|
+
version,
|
1799
|
+
chainId: bn4(chainId),
|
1800
|
+
baseAssetId,
|
1801
|
+
feeParameters: {
|
1802
|
+
version: feeParams.version,
|
1803
|
+
gasPerByte: bn4(feeParams.gasPerByte),
|
1804
|
+
gasPriceFactor: bn4(feeParams.gasPriceFactor)
|
1805
|
+
},
|
1806
|
+
contractParameters: {
|
1807
|
+
version: contractParams.version,
|
1808
|
+
contractMaxSize: bn4(contractParams.contractMaxSize),
|
1809
|
+
maxStorageSlots: bn4(contractParams.maxStorageSlots)
|
1810
|
+
},
|
1811
|
+
txParameters: {
|
1812
|
+
version: txParams.version,
|
1813
|
+
maxInputs: bn4(txParams.maxInputs),
|
1814
|
+
maxOutputs: bn4(txParams.maxOutputs),
|
1815
|
+
maxWitnesses: bn4(txParams.maxWitnesses),
|
1816
|
+
maxGasPerTx: bn4(txParams.maxGasPerTx),
|
1817
|
+
maxSize: bn4(txParams.maxSize),
|
1818
|
+
maxBytecodeSubsections: bn4(txParams.maxBytecodeSubsections)
|
1819
|
+
},
|
1820
|
+
predicateParameters: {
|
1821
|
+
version: predicateParams.version,
|
1822
|
+
maxPredicateLength: bn4(predicateParams.maxPredicateLength),
|
1823
|
+
maxPredicateDataLength: bn4(predicateParams.maxPredicateDataLength),
|
1824
|
+
maxGasPerPredicate: bn4(predicateParams.maxGasPerPredicate),
|
1825
|
+
maxMessageDataLength: bn4(predicateParams.maxMessageDataLength)
|
1826
|
+
},
|
1827
|
+
scriptParameters: {
|
1828
|
+
version: scriptParams.version,
|
1829
|
+
maxScriptLength: bn4(scriptParams.maxScriptLength),
|
1830
|
+
maxScriptDataLength: bn4(scriptParams.maxScriptDataLength)
|
1831
|
+
},
|
1832
|
+
gasCosts
|
1775
1833
|
}
|
1776
|
-
|
1777
|
-
|
1834
|
+
};
|
1835
|
+
};
|
1836
|
+
var serializeChain = (chain) => {
|
1837
|
+
const { name, baseChainHeight, consensusParameters } = chain;
|
1838
|
+
const {
|
1839
|
+
contractParameters,
|
1840
|
+
feeParameters,
|
1841
|
+
predicateParameters,
|
1842
|
+
scriptParameters,
|
1843
|
+
txParameters,
|
1844
|
+
gasCosts,
|
1845
|
+
baseAssetId,
|
1846
|
+
chainId,
|
1847
|
+
version
|
1848
|
+
} = consensusParameters;
|
1849
|
+
return {
|
1850
|
+
name,
|
1851
|
+
daHeight: baseChainHeight.toString(),
|
1852
|
+
consensusParameters: {
|
1853
|
+
version,
|
1854
|
+
chainId: chainId.toString(),
|
1855
|
+
baseAssetId,
|
1856
|
+
feeParams: {
|
1857
|
+
version: feeParameters.version,
|
1858
|
+
gasPerByte: feeParameters.gasPerByte.toString(),
|
1859
|
+
gasPriceFactor: feeParameters.gasPriceFactor.toString()
|
1860
|
+
},
|
1861
|
+
contractParams: {
|
1862
|
+
version: contractParameters.version,
|
1863
|
+
contractMaxSize: contractParameters.contractMaxSize.toString(),
|
1864
|
+
maxStorageSlots: contractParameters.maxStorageSlots.toString()
|
1865
|
+
},
|
1866
|
+
txParams: {
|
1867
|
+
version: txParameters.version,
|
1868
|
+
maxInputs: txParameters.maxInputs.toString(),
|
1869
|
+
maxOutputs: txParameters.maxOutputs.toString(),
|
1870
|
+
maxWitnesses: txParameters.maxWitnesses.toString(),
|
1871
|
+
maxGasPerTx: txParameters.maxGasPerTx.toString(),
|
1872
|
+
maxSize: txParameters.maxSize.toString(),
|
1873
|
+
maxBytecodeSubsections: txParameters.maxBytecodeSubsections.toString()
|
1874
|
+
},
|
1875
|
+
predicateParams: {
|
1876
|
+
version: predicateParameters.version,
|
1877
|
+
maxPredicateLength: predicateParameters.maxPredicateLength.toString(),
|
1878
|
+
maxPredicateDataLength: predicateParameters.maxPredicateDataLength.toString(),
|
1879
|
+
maxGasPerPredicate: predicateParameters.maxGasPerPredicate.toString(),
|
1880
|
+
maxMessageDataLength: predicateParameters.maxMessageDataLength.toString()
|
1881
|
+
},
|
1882
|
+
scriptParams: {
|
1883
|
+
version: scriptParameters.version,
|
1884
|
+
maxScriptLength: scriptParameters.maxScriptLength.toString(),
|
1885
|
+
maxScriptDataLength: scriptParameters.maxScriptDataLength.toString()
|
1886
|
+
},
|
1887
|
+
gasCosts
|
1778
1888
|
}
|
1779
|
-
|
1780
|
-
|
1781
|
-
|
1782
|
-
|
1783
|
-
|
1784
|
-
|
1785
|
-
)
|
1889
|
+
};
|
1890
|
+
};
|
1891
|
+
var deserializeNodeInfo = (nodeInfo) => {
|
1892
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
1893
|
+
return {
|
1894
|
+
maxDepth: bn4(maxDepth),
|
1895
|
+
maxTx: bn4(maxTx),
|
1896
|
+
nodeVersion,
|
1897
|
+
utxoValidation,
|
1898
|
+
vmBacktrace
|
1899
|
+
};
|
1900
|
+
};
|
1901
|
+
var serializeNodeInfo = (nodeInfo) => {
|
1902
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
1903
|
+
return {
|
1904
|
+
maxDepth: maxDepth.toString(),
|
1905
|
+
maxTx: maxTx.toString(),
|
1906
|
+
nodeVersion,
|
1907
|
+
utxoValidation,
|
1908
|
+
vmBacktrace
|
1909
|
+
};
|
1910
|
+
};
|
1911
|
+
var deserializeProviderCache = (cache2) => ({
|
1912
|
+
consensusParametersTimestamp: cache2.consensusParametersTimestamp,
|
1913
|
+
chain: deserializeChain(cache2.chain),
|
1914
|
+
nodeInfo: deserializeNodeInfo(cache2.nodeInfo)
|
1915
|
+
});
|
1916
|
+
var serializeProviderCache = async (provider) => ({
|
1917
|
+
consensusParametersTimestamp: provider.consensusParametersTimestamp,
|
1918
|
+
chain: serializeChain(await provider.getChain()),
|
1919
|
+
nodeInfo: serializeNodeInfo(await provider.getNode())
|
1920
|
+
});
|
1786
1921
|
var hexOrZero = (hex) => hex || ZeroBytes323;
|
1787
|
-
|
1922
|
+
var deserializeReceipt = (receipt) => {
|
1788
1923
|
const { receiptType } = receipt;
|
1789
1924
|
switch (receiptType) {
|
1790
1925
|
case "CALL" /* Call */: {
|
@@ -1928,7 +2063,7 @@ function assembleReceiptByType(receipt) {
|
|
1928
2063
|
recipient,
|
1929
2064
|
nonce,
|
1930
2065
|
amount,
|
1931
|
-
data:
|
2066
|
+
data: hexlify6(data)
|
1932
2067
|
});
|
1933
2068
|
const receiptMessageOut = {
|
1934
2069
|
type: ReceiptType.MessageOut,
|
@@ -1974,20 +2109,39 @@ function assembleReceiptByType(receipt) {
|
|
1974
2109
|
return burnReceipt;
|
1975
2110
|
}
|
1976
2111
|
default:
|
1977
|
-
throw new FuelError7(
|
2112
|
+
throw new FuelError7(ErrorCode5.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
1978
2113
|
}
|
1979
|
-
}
|
2114
|
+
};
|
2115
|
+
|
2116
|
+
// src/providers/utils/receipts.ts
|
2117
|
+
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType2.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
2118
|
+
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType2.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
2119
|
+
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
2120
|
+
(memo, receipt) => {
|
2121
|
+
if (doesReceiptHaveMissingOutputVariables(receipt)) {
|
2122
|
+
memo.missingOutputVariables.push(receipt);
|
2123
|
+
}
|
2124
|
+
if (doesReceiptHaveMissingContractId(receipt)) {
|
2125
|
+
memo.missingOutputContractIds.push(receipt);
|
2126
|
+
}
|
2127
|
+
return memo;
|
2128
|
+
},
|
2129
|
+
{
|
2130
|
+
missingOutputVariables: [],
|
2131
|
+
missingOutputContractIds: []
|
2132
|
+
}
|
2133
|
+
);
|
1980
2134
|
|
1981
2135
|
// src/providers/utils/block-explorer.ts
|
1982
|
-
import { ErrorCode as
|
2136
|
+
import { ErrorCode as ErrorCode6, FuelError as FuelError8 } from "@fuel-ts/errors";
|
1983
2137
|
|
1984
2138
|
// src/providers/utils/gas.ts
|
1985
2139
|
import { bn as bn5 } from "@fuel-ts/math";
|
1986
|
-
import { ReceiptType as
|
2140
|
+
import { ReceiptType as ReceiptType3 } from "@fuel-ts/transactions";
|
1987
2141
|
import { arrayify as arrayify4 } from "@fuel-ts/utils";
|
1988
2142
|
var getGasUsedFromReceipts = (receipts) => {
|
1989
2143
|
const scriptResult = receipts.filter(
|
1990
|
-
(receipt) => receipt.type ===
|
2144
|
+
(receipt) => receipt.type === ReceiptType3.ScriptResult
|
1991
2145
|
);
|
1992
2146
|
const gasUsed = scriptResult.reduce((prev, receipt) => prev.add(receipt.gasUsed), bn5(0));
|
1993
2147
|
return gasUsed;
|
@@ -2120,13 +2274,13 @@ var calculateGasFee = (params) => {
|
|
2120
2274
|
};
|
2121
2275
|
|
2122
2276
|
// src/providers/utils/json.ts
|
2123
|
-
import { hexlify as
|
2277
|
+
import { hexlify as hexlify7 } from "@fuel-ts/utils";
|
2124
2278
|
import { clone } from "ramda";
|
2125
2279
|
function normalize(object) {
|
2126
2280
|
Object.keys(object).forEach((key) => {
|
2127
2281
|
switch (object[key]?.constructor.name) {
|
2128
2282
|
case "Uint8Array":
|
2129
|
-
object[key] =
|
2283
|
+
object[key] = hexlify7(object[key]);
|
2130
2284
|
break;
|
2131
2285
|
case "Array":
|
2132
2286
|
object[key] = normalize(object[key]);
|
@@ -2151,9 +2305,9 @@ function normalizeJSON(root) {
|
|
2151
2305
|
}
|
2152
2306
|
|
2153
2307
|
// src/providers/utils/extract-tx-error.ts
|
2154
|
-
import { ErrorCode as
|
2308
|
+
import { ErrorCode as ErrorCode7, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2155
2309
|
import { bn as bn6 } from "@fuel-ts/math";
|
2156
|
-
import { ReceiptType as
|
2310
|
+
import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
|
2157
2311
|
import {
|
2158
2312
|
FAILED_REQUIRE_SIGNAL,
|
2159
2313
|
FAILED_ASSERT_EQ_SIGNAL,
|
@@ -2172,7 +2326,7 @@ You can read more about this error at:
|
|
2172
2326
|
|
2173
2327
|
${PANIC_DOC_URL}#variant.${statusReason}`;
|
2174
2328
|
}
|
2175
|
-
return new FuelError9(
|
2329
|
+
return new FuelError9(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
2176
2330
|
...metadata,
|
2177
2331
|
reason: statusReason
|
2178
2332
|
});
|
@@ -2180,7 +2334,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
2180
2334
|
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
2181
2335
|
var assembleRevertError = (receipts, logs, metadata) => {
|
2182
2336
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
2183
|
-
const revertReceipt = receipts.find(({ type }) => type ===
|
2337
|
+
const revertReceipt = receipts.find(({ type }) => type === ReceiptType4.Revert);
|
2184
2338
|
let reason = "";
|
2185
2339
|
if (revertReceipt) {
|
2186
2340
|
const reasonHex = bn6(revertReceipt.val).toHex();
|
@@ -2193,15 +2347,15 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2193
2347
|
break;
|
2194
2348
|
}
|
2195
2349
|
case FAILED_ASSERT_EQ_SIGNAL: {
|
2196
|
-
const
|
2350
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
|
2197
2351
|
reason = "assert_eq";
|
2198
|
-
errorMessage = `The transaction reverted because of an "assert_eq" statement${
|
2352
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
|
2199
2353
|
break;
|
2200
2354
|
}
|
2201
2355
|
case FAILED_ASSERT_NE_SIGNAL: {
|
2202
|
-
const
|
2356
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
2203
2357
|
reason = "assert_ne";
|
2204
|
-
errorMessage = `The transaction reverted because of an "assert_ne" statement${
|
2358
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
|
2205
2359
|
break;
|
2206
2360
|
}
|
2207
2361
|
case FAILED_ASSERT_SIGNAL:
|
@@ -2209,12 +2363,12 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2209
2363
|
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
2210
2364
|
break;
|
2211
2365
|
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
|
2212
|
-
reason = "
|
2213
|
-
errorMessage = `The transaction reverted because it's missing an "
|
2366
|
+
reason = "MissingOutputVariable";
|
2367
|
+
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
2214
2368
|
break;
|
2215
2369
|
default:
|
2216
2370
|
throw new FuelError9(
|
2217
|
-
|
2371
|
+
ErrorCode7.UNKNOWN,
|
2218
2372
|
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
2219
2373
|
{
|
2220
2374
|
...metadata,
|
@@ -2223,15 +2377,15 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2223
2377
|
);
|
2224
2378
|
}
|
2225
2379
|
}
|
2226
|
-
return new FuelError9(
|
2380
|
+
return new FuelError9(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
2227
2381
|
...metadata,
|
2228
2382
|
reason
|
2229
2383
|
});
|
2230
2384
|
};
|
2231
2385
|
var extractTxError = (params) => {
|
2232
2386
|
const { receipts, statusReason, logs } = params;
|
2233
|
-
const isPanic = receipts.some(({ type }) => type ===
|
2234
|
-
const isRevert = receipts.some(({ type }) => type ===
|
2387
|
+
const isPanic = receipts.some(({ type }) => type === ReceiptType4.Panic);
|
2388
|
+
const isRevert = receipts.some(({ type }) => type === ReceiptType4.Revert);
|
2235
2389
|
const metadata = {
|
2236
2390
|
logs,
|
2237
2391
|
receipts,
|
@@ -2256,9 +2410,10 @@ var NoWitnessAtIndexError = class extends Error {
|
|
2256
2410
|
};
|
2257
2411
|
|
2258
2412
|
// src/providers/transaction-request/helpers.ts
|
2259
|
-
import { ErrorCode as
|
2413
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError10 } from "@fuel-ts/errors";
|
2260
2414
|
import { bn as bn7 } from "@fuel-ts/math";
|
2261
2415
|
import { InputType as InputType2, OutputType as OutputType2 } from "@fuel-ts/transactions";
|
2416
|
+
import { hexlify as hexlify8 } from "@fuel-ts/utils";
|
2262
2417
|
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
2263
2418
|
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
2264
2419
|
var isRequestInputMessageWithoutData = (input) => input.type === InputType2.Message && bn7(input.data).isZero();
|
@@ -2266,6 +2421,7 @@ var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequ
|
|
2266
2421
|
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
|
2267
2422
|
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
2268
2423
|
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
2424
|
+
var isPredicate = (input) => isRequestInputCoinOrMessage(input) && !!input.predicate && hexlify8(input.predicate) !== "0x";
|
2269
2425
|
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
2270
2426
|
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
2271
2427
|
return acc.add(input.amount);
|
@@ -2313,7 +2469,7 @@ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAs
|
|
2313
2469
|
"Add the relevant change outputs to the transaction to avoid burning assets.",
|
2314
2470
|
"Or enable asset burn, upon sending the transaction."
|
2315
2471
|
].join("\n");
|
2316
|
-
throw new FuelError10(
|
2472
|
+
throw new FuelError10(ErrorCode8.ASSET_BURN_DETECTED, message);
|
2317
2473
|
};
|
2318
2474
|
|
2319
2475
|
// src/providers/transaction-request/witness.ts
|
@@ -2332,6 +2488,8 @@ var BaseTransactionRequest = class {
|
|
2332
2488
|
tip;
|
2333
2489
|
/** Block until which tx cannot be included */
|
2334
2490
|
maturity;
|
2491
|
+
/** The block number after which the transaction is no longer valid. */
|
2492
|
+
expiration;
|
2335
2493
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
2336
2494
|
maxFee;
|
2337
2495
|
/** The maximum amount of witness data allowed for the transaction */
|
@@ -2342,6 +2500,12 @@ var BaseTransactionRequest = class {
|
|
2342
2500
|
outputs = [];
|
2343
2501
|
/** List of witnesses */
|
2344
2502
|
witnesses = [];
|
2503
|
+
/**
|
2504
|
+
* @hidden
|
2505
|
+
*
|
2506
|
+
* The current status of the transaction
|
2507
|
+
*/
|
2508
|
+
flag = { state: void 0, transactionId: void 0, summary: void 0 };
|
2345
2509
|
/**
|
2346
2510
|
* Constructor for initializing a base transaction request.
|
2347
2511
|
*
|
@@ -2350,6 +2514,7 @@ var BaseTransactionRequest = class {
|
|
2350
2514
|
constructor({
|
2351
2515
|
tip,
|
2352
2516
|
maturity,
|
2517
|
+
expiration,
|
2353
2518
|
maxFee,
|
2354
2519
|
witnessLimit,
|
2355
2520
|
inputs,
|
@@ -2358,6 +2523,7 @@ var BaseTransactionRequest = class {
|
|
2358
2523
|
} = {}) {
|
2359
2524
|
this.tip = tip ? bn8(tip) : void 0;
|
2360
2525
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
2526
|
+
this.expiration = expiration && expiration > 0 ? expiration : void 0;
|
2361
2527
|
this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
|
2362
2528
|
this.maxFee = bn8(maxFee);
|
2363
2529
|
this.inputs = inputs ?? [];
|
@@ -2367,7 +2533,7 @@ var BaseTransactionRequest = class {
|
|
2367
2533
|
static getPolicyMeta(req) {
|
2368
2534
|
let policyTypes = 0;
|
2369
2535
|
const policies = [];
|
2370
|
-
const { tip, witnessLimit, maturity } = req;
|
2536
|
+
const { tip, witnessLimit, maturity, expiration } = req;
|
2371
2537
|
if (bn8(tip).gt(0)) {
|
2372
2538
|
policyTypes += PolicyType.Tip;
|
2373
2539
|
policies.push({ data: bn8(tip), type: PolicyType.Tip });
|
@@ -2382,6 +2548,10 @@ var BaseTransactionRequest = class {
|
|
2382
2548
|
}
|
2383
2549
|
policyTypes += PolicyType.MaxFee;
|
2384
2550
|
policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
|
2551
|
+
if (expiration && expiration > 0) {
|
2552
|
+
policyTypes += PolicyType.Expiration;
|
2553
|
+
policies.push({ data: expiration, type: PolicyType.Expiration });
|
2554
|
+
}
|
2385
2555
|
return {
|
2386
2556
|
policyTypes,
|
2387
2557
|
policies
|
@@ -2454,8 +2624,7 @@ var BaseTransactionRequest = class {
|
|
2454
2624
|
* @returns The index of the created witness.
|
2455
2625
|
*/
|
2456
2626
|
addEmptyWitness() {
|
2457
|
-
this.addWitness(concat2([ZeroBytes324, ZeroBytes324]));
|
2458
|
-
return this.witnesses.length - 1;
|
2627
|
+
return this.addWitness(concat2([ZeroBytes324, ZeroBytes324]));
|
2459
2628
|
}
|
2460
2629
|
/**
|
2461
2630
|
* Updates the witness for a given owner and signature.
|
@@ -2825,6 +2994,21 @@ var BaseTransactionRequest = class {
|
|
2825
2994
|
byteLength() {
|
2826
2995
|
return this.toTransactionBytes().byteLength;
|
2827
2996
|
}
|
2997
|
+
/**
|
2998
|
+
* @hidden
|
2999
|
+
*
|
3000
|
+
* Used internally to update the state of a transaction request.
|
3001
|
+
*
|
3002
|
+
* @param state - The state to update.
|
3003
|
+
*/
|
3004
|
+
updateState(chainId, state, summary) {
|
3005
|
+
if (!state) {
|
3006
|
+
this.flag = { state: void 0, transactionId: void 0, summary: void 0 };
|
3007
|
+
return;
|
3008
|
+
}
|
3009
|
+
const transactionId = this.getTransactionId(chainId);
|
3010
|
+
this.flag = { state, transactionId, summary };
|
3011
|
+
}
|
2828
3012
|
};
|
2829
3013
|
|
2830
3014
|
// src/providers/transaction-request/blob-transaction-request.ts
|
@@ -3566,7 +3750,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
|
|
3566
3750
|
};
|
3567
3751
|
|
3568
3752
|
// src/providers/transaction-request/utils.ts
|
3569
|
-
import { ErrorCode as
|
3753
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError13 } from "@fuel-ts/errors";
|
3570
3754
|
import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
3571
3755
|
var transactionRequestify = (obj) => {
|
3572
3756
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
@@ -3591,7 +3775,7 @@ var transactionRequestify = (obj) => {
|
|
3591
3775
|
}
|
3592
3776
|
default: {
|
3593
3777
|
throw new FuelError13(
|
3594
|
-
|
3778
|
+
ErrorCode9.UNSUPPORTED_TRANSACTION_TYPE,
|
3595
3779
|
`Unsupported transaction type: ${type}.`
|
3596
3780
|
);
|
3597
3781
|
}
|
@@ -3600,8 +3784,99 @@ var transactionRequestify = (obj) => {
|
|
3600
3784
|
var isTransactionTypeScript = (request) => request.type === TransactionType7.Script;
|
3601
3785
|
var isTransactionTypeCreate = (request) => request.type === TransactionType7.Create;
|
3602
3786
|
|
3787
|
+
// src/providers/resource-cache.ts
|
3788
|
+
var cache = /* @__PURE__ */ new Map();
|
3789
|
+
var ResourceCache = class {
|
3790
|
+
ttl;
|
3791
|
+
constructor(ttl) {
|
3792
|
+
this.ttl = ttl;
|
3793
|
+
if (typeof ttl !== "number" || this.ttl <= 0) {
|
3794
|
+
throw new FuelError14(
|
3795
|
+
ErrorCode10.INVALID_TTL,
|
3796
|
+
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
3797
|
+
);
|
3798
|
+
}
|
3799
|
+
}
|
3800
|
+
// Add resources to the cache
|
3801
|
+
set(transactionId, inputs) {
|
3802
|
+
const transactionResourceCache = this.setupResourcesCache(inputs);
|
3803
|
+
cache.set(transactionId, transactionResourceCache);
|
3804
|
+
}
|
3805
|
+
unset(transactionId) {
|
3806
|
+
cache.delete(transactionId);
|
3807
|
+
}
|
3808
|
+
getActiveData(owner) {
|
3809
|
+
const activeData = { utxos: [], messages: [] };
|
3810
|
+
const currentTime = Date.now();
|
3811
|
+
const expired = [];
|
3812
|
+
cache.forEach((resource, transactionId) => {
|
3813
|
+
const isActive = currentTime - resource.timestamp < this.ttl;
|
3814
|
+
if (isActive) {
|
3815
|
+
const resourcesFromOwner = resource.owners.get(owner);
|
3816
|
+
if (resourcesFromOwner) {
|
3817
|
+
activeData.utxos.push(...resourcesFromOwner.utxos);
|
3818
|
+
activeData.messages.push(...resourcesFromOwner.messages);
|
3819
|
+
}
|
3820
|
+
} else {
|
3821
|
+
expired.push(transactionId);
|
3822
|
+
}
|
3823
|
+
});
|
3824
|
+
expired.forEach(this.unset);
|
3825
|
+
activeData.utxos.reverse();
|
3826
|
+
activeData.messages.reverse();
|
3827
|
+
return activeData;
|
3828
|
+
}
|
3829
|
+
isCached(owner, key) {
|
3830
|
+
const currentTime = Date.now();
|
3831
|
+
let cached = false;
|
3832
|
+
const expired = [];
|
3833
|
+
for (const [transactionId, resourceData] of cache.entries()) {
|
3834
|
+
const isActive = currentTime - resourceData.timestamp < this.ttl;
|
3835
|
+
if (isActive) {
|
3836
|
+
const resourcesFromOwner = resourceData.owners.get(owner);
|
3837
|
+
if (resourcesFromOwner?.utxos.has(key) || resourcesFromOwner?.messages.has(key)) {
|
3838
|
+
cached = true;
|
3839
|
+
break;
|
3840
|
+
}
|
3841
|
+
} else {
|
3842
|
+
expired.push(transactionId);
|
3843
|
+
}
|
3844
|
+
}
|
3845
|
+
expired.forEach(this.unset);
|
3846
|
+
return cached;
|
3847
|
+
}
|
3848
|
+
clear() {
|
3849
|
+
cache.clear();
|
3850
|
+
}
|
3851
|
+
setupResourcesCache(inputs) {
|
3852
|
+
const currentTime = Date.now();
|
3853
|
+
const transactionResourcesCache = {
|
3854
|
+
owners: /* @__PURE__ */ new Map(),
|
3855
|
+
timestamp: currentTime
|
3856
|
+
};
|
3857
|
+
inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
3858
|
+
const { owner, key, type } = this.extractResourceData(input);
|
3859
|
+
if (!transactionResourcesCache.owners.has(owner)) {
|
3860
|
+
transactionResourcesCache.owners.set(owner, { utxos: /* @__PURE__ */ new Set(), messages: /* @__PURE__ */ new Set() });
|
3861
|
+
}
|
3862
|
+
if (type === "utxo") {
|
3863
|
+
transactionResourcesCache.owners.get(owner)?.utxos.add(key);
|
3864
|
+
} else {
|
3865
|
+
transactionResourcesCache.owners.get(owner)?.messages.add(key);
|
3866
|
+
}
|
3867
|
+
});
|
3868
|
+
return transactionResourcesCache;
|
3869
|
+
}
|
3870
|
+
extractResourceData(input) {
|
3871
|
+
if (isRequestInputCoin(input)) {
|
3872
|
+
return { owner: hexlify16(input.owner), key: hexlify16(input.id), type: "utxo" };
|
3873
|
+
}
|
3874
|
+
return { owner: hexlify16(input.recipient), key: hexlify16(input.nonce), type: "message" };
|
3875
|
+
}
|
3876
|
+
};
|
3877
|
+
|
3603
3878
|
// src/providers/transaction-response/transaction-response.ts
|
3604
|
-
import { ErrorCode as ErrorCode14, FuelError as
|
3879
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError18 } from "@fuel-ts/errors";
|
3605
3880
|
import { bn as bn16 } from "@fuel-ts/math";
|
3606
3881
|
import { OutputType as OutputType8, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
3607
3882
|
import { arrayify as arrayify12, assertUnreachable } from "@fuel-ts/utils";
|
@@ -3609,7 +3884,7 @@ import { arrayify as arrayify12, assertUnreachable } from "@fuel-ts/utils";
|
|
3609
3884
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
3610
3885
|
import { bn as bn15 } from "@fuel-ts/math";
|
3611
3886
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
3612
|
-
import { DateTime, hexlify as
|
3887
|
+
import { DateTime, hexlify as hexlify17 } from "@fuel-ts/utils";
|
3613
3888
|
|
3614
3889
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
3615
3890
|
import { bn as bn12 } from "@fuel-ts/math";
|
@@ -3679,45 +3954,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
3679
3954
|
|
3680
3955
|
// src/providers/transaction-summary/operations.ts
|
3681
3956
|
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
3682
|
-
import { ErrorCode as ErrorCode12, FuelError as
|
3957
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError16 } from "@fuel-ts/errors";
|
3683
3958
|
import { bn as bn13 } from "@fuel-ts/math";
|
3684
|
-
import { ReceiptType as
|
3685
|
-
|
3686
|
-
// src/providers/transaction-summary/call.ts
|
3687
|
-
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
3688
|
-
var getFunctionCall = ({ abi, receipt }) => {
|
3689
|
-
const abiInterface = new Interface2(abi);
|
3690
|
-
const callFunctionSelector = receipt.param1.toHex(8);
|
3691
|
-
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
3692
|
-
const inputs = functionFragment.jsonFn.inputs;
|
3693
|
-
const encodedArgs = receipt.param2.toHex();
|
3694
|
-
let argumentsProvided;
|
3695
|
-
const data = functionFragment.decodeArguments(encodedArgs);
|
3696
|
-
if (data) {
|
3697
|
-
argumentsProvided = inputs.reduce((prev, input, index) => {
|
3698
|
-
const value = data[index];
|
3699
|
-
const name = input.name;
|
3700
|
-
if (name) {
|
3701
|
-
return {
|
3702
|
-
...prev,
|
3703
|
-
// reparse to remove bn
|
3704
|
-
[name]: JSON.parse(JSON.stringify(value))
|
3705
|
-
};
|
3706
|
-
}
|
3707
|
-
return prev;
|
3708
|
-
}, {});
|
3709
|
-
}
|
3710
|
-
const call = {
|
3711
|
-
functionSignature: functionFragment.signature,
|
3712
|
-
functionName: functionFragment.name,
|
3713
|
-
argumentsProvided,
|
3714
|
-
...receipt.amount?.isZero() ? {} : { amount: receipt.amount, assetId: receipt.assetId }
|
3715
|
-
};
|
3716
|
-
return call;
|
3717
|
-
};
|
3959
|
+
import { ReceiptType as ReceiptType5, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
|
3718
3960
|
|
3719
3961
|
// src/providers/transaction-summary/input.ts
|
3720
|
-
import { ErrorCode as ErrorCode11, FuelError as
|
3962
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError15 } from "@fuel-ts/errors";
|
3721
3963
|
import { BN } from "@fuel-ts/math";
|
3722
3964
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
3723
3965
|
function getInputsByTypes(inputs, types) {
|
@@ -3786,7 +4028,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3786
4028
|
return void 0;
|
3787
4029
|
}
|
3788
4030
|
if (contractInput.type !== InputType6.Contract) {
|
3789
|
-
throw new
|
4031
|
+
throw new FuelError15(
|
3790
4032
|
ErrorCode11.INVALID_TRANSACTION_INPUT,
|
3791
4033
|
`Contract input should be of type 'contract'.`
|
3792
4034
|
);
|
@@ -3840,7 +4082,7 @@ function getTransactionTypeName(transactionType) {
|
|
3840
4082
|
case TransactionType9.Upload:
|
3841
4083
|
return "Upload" /* Upload */;
|
3842
4084
|
default:
|
3843
|
-
throw new
|
4085
|
+
throw new FuelError16(
|
3844
4086
|
ErrorCode12.UNSUPPORTED_TRANSACTION_TYPE,
|
3845
4087
|
`Unsupported transaction type: ${transactionType}.`
|
3846
4088
|
);
|
@@ -3869,10 +4111,10 @@ function isTypeBlob(transactionType) {
|
|
3869
4111
|
return isType(transactionType, "Blob" /* Blob */);
|
3870
4112
|
}
|
3871
4113
|
function getReceiptsCall(receipts) {
|
3872
|
-
return getReceiptsByType(receipts,
|
4114
|
+
return getReceiptsByType(receipts, ReceiptType5.Call);
|
3873
4115
|
}
|
3874
4116
|
function getReceiptsMessageOut(receipts) {
|
3875
|
-
return getReceiptsByType(receipts,
|
4117
|
+
return getReceiptsByType(receipts, ReceiptType5.MessageOut);
|
3876
4118
|
}
|
3877
4119
|
function mergeAssets(op1, op2) {
|
3878
4120
|
const assets1 = op1.assetsSent || [];
|
@@ -3910,7 +4152,11 @@ function mergeOperations(existing, toAdd) {
|
|
3910
4152
|
return {
|
3911
4153
|
...existing,
|
3912
4154
|
assetsSent: mergeAssetsSent(existing, toAdd),
|
3913
|
-
calls: mergeCalls(existing, toAdd)
|
4155
|
+
calls: mergeCalls(existing, toAdd),
|
4156
|
+
receipts: [
|
4157
|
+
...existing.receipts || [],
|
4158
|
+
...toAdd.receipts?.filter((r) => !existing.receipts?.some((er) => er === r)) || []
|
4159
|
+
]
|
3914
4160
|
};
|
3915
4161
|
}
|
3916
4162
|
function addOperation(operations, toAdd) {
|
@@ -3947,7 +4193,8 @@ function getWithdrawFromFuelOperations({
|
|
3947
4193
|
amount: receipt.amount,
|
3948
4194
|
assetId: baseAssetId
|
3949
4195
|
}
|
3950
|
-
]
|
4196
|
+
],
|
4197
|
+
receipts: [receipt]
|
3951
4198
|
});
|
3952
4199
|
return newWithdrawFromFuelOps;
|
3953
4200
|
}
|
@@ -3957,19 +4204,12 @@ function getWithdrawFromFuelOperations({
|
|
3957
4204
|
);
|
3958
4205
|
return withdrawFromFuelOperations;
|
3959
4206
|
}
|
3960
|
-
function getContractCalls(contractInput, abiMap,
|
4207
|
+
function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
|
3961
4208
|
const abi = abiMap?.[contractInput.contractID];
|
3962
4209
|
if (!abi) {
|
3963
4210
|
return [];
|
3964
4211
|
}
|
3965
|
-
return [
|
3966
|
-
getFunctionCall({
|
3967
|
-
abi,
|
3968
|
-
receipt,
|
3969
|
-
rawPayload,
|
3970
|
-
maxInputs
|
3971
|
-
})
|
3972
|
-
];
|
4212
|
+
return [];
|
3973
4213
|
}
|
3974
4214
|
function getAssetsSent(receipt) {
|
3975
4215
|
return receipt.amount?.isZero() ? void 0 : [
|
@@ -3999,7 +4239,8 @@ function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload,
|
|
3999
4239
|
address: receipt.to
|
4000
4240
|
},
|
4001
4241
|
assetsSent: getAssetsSent(receipt),
|
4002
|
-
calls
|
4242
|
+
calls,
|
4243
|
+
receipts: [receipt]
|
4003
4244
|
}
|
4004
4245
|
];
|
4005
4246
|
}
|
@@ -4056,7 +4297,8 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
4056
4297
|
assetId: assetId.toString(),
|
4057
4298
|
amount
|
4058
4299
|
}
|
4059
|
-
]
|
4300
|
+
],
|
4301
|
+
receipts: [receipt]
|
4060
4302
|
};
|
4061
4303
|
}
|
4062
4304
|
function getTransferOperations({
|
@@ -4101,11 +4343,11 @@ function getTransferOperations({
|
|
4101
4343
|
});
|
4102
4344
|
const transferReceipts = getReceiptsByType(
|
4103
4345
|
receipts,
|
4104
|
-
|
4346
|
+
ReceiptType5.Transfer
|
4105
4347
|
);
|
4106
4348
|
const transferOutReceipts = getReceiptsByType(
|
4107
4349
|
receipts,
|
4108
|
-
|
4350
|
+
ReceiptType5.TransferOut
|
4109
4351
|
);
|
4110
4352
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
4111
4353
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -4189,12 +4431,11 @@ function getOperations({
|
|
4189
4431
|
}
|
4190
4432
|
|
4191
4433
|
// src/providers/transaction-summary/receipt.ts
|
4192
|
-
import { ReceiptType as
|
4193
|
-
var processGqlReceipt = (gqlReceipt) => assembleReceiptByType(gqlReceipt);
|
4434
|
+
import { ReceiptType as ReceiptType6 } from "@fuel-ts/transactions";
|
4194
4435
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
4195
4436
|
const mintedAssets = [];
|
4196
4437
|
receipts.forEach((receipt) => {
|
4197
|
-
if (receipt.type ===
|
4438
|
+
if (receipt.type === ReceiptType6.Mint) {
|
4198
4439
|
mintedAssets.push({
|
4199
4440
|
subId: receipt.subId,
|
4200
4441
|
contractId: receipt.contractId,
|
@@ -4208,7 +4449,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
4208
4449
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
4209
4450
|
const burnedAssets = [];
|
4210
4451
|
receipts.forEach((receipt) => {
|
4211
|
-
if (receipt.type ===
|
4452
|
+
if (receipt.type === ReceiptType6.Burn) {
|
4212
4453
|
burnedAssets.push({
|
4213
4454
|
subId: receipt.subId,
|
4214
4455
|
contractId: receipt.contractId,
|
@@ -4221,7 +4462,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
4221
4462
|
};
|
4222
4463
|
|
4223
4464
|
// src/providers/transaction-summary/status.ts
|
4224
|
-
import { ErrorCode as ErrorCode13, FuelError as
|
4465
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError17 } from "@fuel-ts/errors";
|
4225
4466
|
import { bn as bn14 } from "@fuel-ts/math";
|
4226
4467
|
var getTransactionStatusName = (gqlStatus) => {
|
4227
4468
|
switch (gqlStatus) {
|
@@ -4234,7 +4475,7 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
4234
4475
|
case "SqueezedOutStatus":
|
4235
4476
|
return "squeezedout" /* squeezedout */;
|
4236
4477
|
default:
|
4237
|
-
throw new
|
4478
|
+
throw new FuelError17(
|
4238
4479
|
ErrorCode13.INVALID_TRANSACTION_STATUS,
|
4239
4480
|
`Invalid transaction status: ${gqlStatus}.`
|
4240
4481
|
);
|
@@ -4305,7 +4546,7 @@ function assembleTransactionSummary(params) {
|
|
4305
4546
|
baseAssetId
|
4306
4547
|
} = params;
|
4307
4548
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
4308
|
-
const rawPayload =
|
4549
|
+
const rawPayload = hexlify17(transactionBytes);
|
4309
4550
|
const operations = getOperations({
|
4310
4551
|
transactionType: transaction.type,
|
4311
4552
|
inputs: transaction.inputs || [],
|
@@ -4367,15 +4608,27 @@ function assembleTransactionSummary(params) {
|
|
4367
4608
|
}
|
4368
4609
|
|
4369
4610
|
// src/providers/transaction-response/getDecodedLogs.ts
|
4370
|
-
import { Interface as
|
4371
|
-
import {
|
4611
|
+
import { Interface as Interface2, BigNumberCoder } from "@fuel-ts/abi-coder";
|
4612
|
+
import { ZeroBytes32 as ZeroBytes3210 } from "@fuel-ts/address/configs";
|
4613
|
+
import { ReceiptType as ReceiptType7 } from "@fuel-ts/transactions";
|
4372
4614
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
4615
|
+
let mainContract = "";
|
4616
|
+
if (mainAbi.programType === "contract") {
|
4617
|
+
const firstCallReceipt = receipts.find(
|
4618
|
+
(r) => r.type === ReceiptType7.Call && r.id === ZeroBytes3210
|
4619
|
+
);
|
4620
|
+
mainContract = firstCallReceipt.to;
|
4621
|
+
}
|
4373
4622
|
return receipts.reduce((logs, receipt) => {
|
4374
|
-
if (receipt.type ===
|
4375
|
-
const
|
4376
|
-
const
|
4377
|
-
|
4378
|
-
|
4623
|
+
if (receipt.type === ReceiptType7.LogData || receipt.type === ReceiptType7.Log) {
|
4624
|
+
const isLogFromMainAbi = receipt.id === ZeroBytes3210 || mainContract === receipt.id;
|
4625
|
+
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
4626
|
+
if (isDecodable) {
|
4627
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface2(mainAbi) : new Interface2(externalAbis[receipt.id]);
|
4628
|
+
const data = receipt.type === ReceiptType7.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
4629
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
4630
|
+
logs.push(decodedLog);
|
4631
|
+
}
|
4379
4632
|
}
|
4380
4633
|
return logs;
|
4381
4634
|
}, []);
|
@@ -4495,7 +4748,7 @@ var TransactionResponse = class {
|
|
4495
4748
|
switch (status?.type) {
|
4496
4749
|
case "SuccessStatus":
|
4497
4750
|
case "FailureStatus":
|
4498
|
-
return status.receipts.map(
|
4751
|
+
return status.receipts.map(deserializeReceipt);
|
4499
4752
|
default:
|
4500
4753
|
return [];
|
4501
4754
|
}
|
@@ -4580,7 +4833,7 @@ var TransactionResponse = class {
|
|
4580
4833
|
this.status = statusChange;
|
4581
4834
|
if (statusChange.type === "SqueezedOutStatus") {
|
4582
4835
|
this.unsetResourceCache();
|
4583
|
-
throw new
|
4836
|
+
throw new FuelError18(
|
4584
4837
|
ErrorCode14.TRANSACTION_SQUEEZED_OUT,
|
4585
4838
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4586
4839
|
);
|
@@ -4619,7 +4872,6 @@ var TransactionResponse = class {
|
|
4619
4872
|
const { receipts } = transactionResult;
|
4620
4873
|
const status = this.status ?? this.gqlTransaction?.status;
|
4621
4874
|
if (status?.type === "FailureStatus") {
|
4622
|
-
this.unsetResourceCache();
|
4623
4875
|
const { reason } = status;
|
4624
4876
|
throw extractTxError({
|
4625
4877
|
receipts,
|
@@ -4636,6 +4888,7 @@ var TransactionResponse = class {
|
|
4636
4888
|
*/
|
4637
4889
|
async waitForResult(contractsAbiMap) {
|
4638
4890
|
await this.waitForStatusChange();
|
4891
|
+
this.unsetResourceCache();
|
4639
4892
|
return this.assembleResult(contractsAbiMap);
|
4640
4893
|
}
|
4641
4894
|
/**
|
@@ -4688,31 +4941,47 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4688
4941
|
};
|
4689
4942
|
}
|
4690
4943
|
|
4944
|
+
// src/providers/utils/helpers.ts
|
4945
|
+
var adjustResourcesToExclude = (params) => {
|
4946
|
+
const { userInput, cached, maxInputs } = params;
|
4947
|
+
const final = { ...userInput };
|
4948
|
+
let total = final.utxos.length + final.messages.length;
|
4949
|
+
if (total >= maxInputs) {
|
4950
|
+
return final;
|
4951
|
+
}
|
4952
|
+
final.utxos = [...final.utxos, ...cached.utxos.slice(0, maxInputs - total)];
|
4953
|
+
total = final.utxos.length + final.messages.length;
|
4954
|
+
if (total < maxInputs) {
|
4955
|
+
final.messages = [...final.messages, ...cached.messages.slice(0, maxInputs - total)];
|
4956
|
+
}
|
4957
|
+
return final;
|
4958
|
+
};
|
4959
|
+
|
4691
4960
|
// src/providers/utils/validate-pagination-args.ts
|
4692
|
-
import { FuelError as
|
4961
|
+
import { FuelError as FuelError19, ErrorCode as ErrorCode15 } from "@fuel-ts/errors";
|
4693
4962
|
var validatePaginationArgs = (params) => {
|
4694
4963
|
const { paginationLimit, inputArgs = {} } = params;
|
4695
4964
|
const { first, last, after, before } = inputArgs;
|
4696
4965
|
if (after && before) {
|
4697
|
-
throw new
|
4966
|
+
throw new FuelError19(
|
4698
4967
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4699
4968
|
'Pagination arguments "after" and "before" cannot be used together'
|
4700
4969
|
);
|
4701
4970
|
}
|
4702
4971
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
4703
|
-
throw new
|
4972
|
+
throw new FuelError19(
|
4704
4973
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4705
4974
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
4706
4975
|
);
|
4707
4976
|
}
|
4708
4977
|
if (first && before) {
|
4709
|
-
throw new
|
4978
|
+
throw new FuelError19(
|
4710
4979
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4711
4980
|
'The use of pagination argument "first" with "before" is not supported'
|
4712
4981
|
);
|
4713
4982
|
}
|
4714
4983
|
if (last && after) {
|
4715
|
-
throw new
|
4984
|
+
throw new FuelError19(
|
4716
4985
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
4717
4986
|
'The use of pagination argument "last" with "after" is not supported'
|
4718
4987
|
);
|
@@ -4727,64 +4996,10 @@ var validatePaginationArgs = (params) => {
|
|
4727
4996
|
var MAX_RETRIES = 10;
|
4728
4997
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
4729
4998
|
var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
|
4999
|
+
var BALANCES_PAGE_SIZE_LIMIT = 100;
|
4730
5000
|
var BLOCKS_PAGE_SIZE_LIMIT = 5;
|
4731
5001
|
var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
|
4732
5002
|
var GAS_USED_MODIFIER = 1.2;
|
4733
|
-
var processGqlChain = (chain) => {
|
4734
|
-
const { name, daHeight, consensusParameters } = chain;
|
4735
|
-
const {
|
4736
|
-
contractParams,
|
4737
|
-
feeParams,
|
4738
|
-
predicateParams,
|
4739
|
-
scriptParams,
|
4740
|
-
txParams,
|
4741
|
-
gasCosts,
|
4742
|
-
baseAssetId,
|
4743
|
-
chainId,
|
4744
|
-
version
|
4745
|
-
} = consensusParameters;
|
4746
|
-
return {
|
4747
|
-
name,
|
4748
|
-
baseChainHeight: bn17(daHeight),
|
4749
|
-
consensusParameters: {
|
4750
|
-
version,
|
4751
|
-
chainId: bn17(chainId),
|
4752
|
-
baseAssetId,
|
4753
|
-
feeParameters: {
|
4754
|
-
version: feeParams.version,
|
4755
|
-
gasPerByte: bn17(feeParams.gasPerByte),
|
4756
|
-
gasPriceFactor: bn17(feeParams.gasPriceFactor)
|
4757
|
-
},
|
4758
|
-
contractParameters: {
|
4759
|
-
version: contractParams.version,
|
4760
|
-
contractMaxSize: bn17(contractParams.contractMaxSize),
|
4761
|
-
maxStorageSlots: bn17(contractParams.maxStorageSlots)
|
4762
|
-
},
|
4763
|
-
txParameters: {
|
4764
|
-
version: txParams.version,
|
4765
|
-
maxInputs: bn17(txParams.maxInputs),
|
4766
|
-
maxOutputs: bn17(txParams.maxOutputs),
|
4767
|
-
maxWitnesses: bn17(txParams.maxWitnesses),
|
4768
|
-
maxGasPerTx: bn17(txParams.maxGasPerTx),
|
4769
|
-
maxSize: bn17(txParams.maxSize),
|
4770
|
-
maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
|
4771
|
-
},
|
4772
|
-
predicateParameters: {
|
4773
|
-
version: predicateParams.version,
|
4774
|
-
maxPredicateLength: bn17(predicateParams.maxPredicateLength),
|
4775
|
-
maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
|
4776
|
-
maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
|
4777
|
-
maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
|
4778
|
-
},
|
4779
|
-
scriptParameters: {
|
4780
|
-
version: scriptParams.version,
|
4781
|
-
maxScriptLength: bn17(scriptParams.maxScriptLength),
|
4782
|
-
maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
|
4783
|
-
},
|
4784
|
-
gasCosts
|
4785
|
-
}
|
4786
|
-
};
|
4787
|
-
};
|
4788
5003
|
var _cacheInputs, cacheInputs_fn;
|
4789
5004
|
var _Provider = class {
|
4790
5005
|
/**
|
@@ -4806,13 +5021,19 @@ var _Provider = class {
|
|
4806
5021
|
/** @hidden */
|
4807
5022
|
__publicField(this, "urlWithoutAuth");
|
4808
5023
|
/** @hidden */
|
5024
|
+
__publicField(this, "features", {
|
5025
|
+
balancePagination: false,
|
5026
|
+
amount128: false
|
5027
|
+
});
|
5028
|
+
/** @hidden */
|
4809
5029
|
__publicField(this, "consensusParametersTimestamp");
|
4810
5030
|
__publicField(this, "options", {
|
4811
5031
|
timeout: void 0,
|
4812
5032
|
resourceCacheTTL: void 0,
|
4813
5033
|
fetch: void 0,
|
4814
5034
|
retryOptions: void 0,
|
4815
|
-
headers: void 0
|
5035
|
+
headers: void 0,
|
5036
|
+
cache: void 0
|
4816
5037
|
});
|
4817
5038
|
const { url: rawUrl, urlWithoutAuth, headers: authHeaders } = _Provider.extractBasicAuth(url);
|
4818
5039
|
this.url = rawUrl;
|
@@ -4826,7 +5047,13 @@ var _Provider = class {
|
|
4826
5047
|
headers
|
4827
5048
|
};
|
4828
5049
|
this.operations = this.createOperations();
|
4829
|
-
const { resourceCacheTTL } = this.options;
|
5050
|
+
const { resourceCacheTTL, cache: cache2 } = this.options;
|
5051
|
+
if (cache2) {
|
5052
|
+
const { consensusParametersTimestamp, chain, nodeInfo } = deserializeProviderCache(cache2);
|
5053
|
+
this.consensusParametersTimestamp = consensusParametersTimestamp;
|
5054
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
5055
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
5056
|
+
}
|
4830
5057
|
if (isDefined2(resourceCacheTTL)) {
|
4831
5058
|
if (resourceCacheTTL !== -1) {
|
4832
5059
|
this.cache = new ResourceCache(resourceCacheTTL);
|
@@ -4839,6 +5066,7 @@ var _Provider = class {
|
|
4839
5066
|
}
|
4840
5067
|
/** @hidden */
|
4841
5068
|
static clearChainAndNodeCaches() {
|
5069
|
+
_Provider.inflightFetchChainAndNodeInfoRequests = {};
|
4842
5070
|
_Provider.nodeInfoCache = {};
|
4843
5071
|
_Provider.chainInfoCache = {};
|
4844
5072
|
}
|
@@ -4867,7 +5095,7 @@ var _Provider = class {
|
|
4867
5095
|
try {
|
4868
5096
|
parsedUrl = new URL(url);
|
4869
5097
|
} catch (error) {
|
4870
|
-
throw new
|
5098
|
+
throw new FuelError20(FuelError20.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
4871
5099
|
}
|
4872
5100
|
const username = parsedUrl.username;
|
4873
5101
|
const password = parsedUrl.password;
|
@@ -4885,7 +5113,8 @@ var _Provider = class {
|
|
4885
5113
|
* Initialize Provider async stuff
|
4886
5114
|
*/
|
4887
5115
|
async init() {
|
4888
|
-
await this.fetchChainAndNodeInfo();
|
5116
|
+
const { nodeInfo } = await this.fetchChainAndNodeInfo();
|
5117
|
+
this.setupFeatures(nodeInfo.nodeVersion);
|
4889
5118
|
return this;
|
4890
5119
|
}
|
4891
5120
|
/**
|
@@ -4955,19 +5184,24 @@ var _Provider = class {
|
|
4955
5184
|
throw new Error(`Jumps to the catch block and re-fetch`);
|
4956
5185
|
}
|
4957
5186
|
} catch (_err) {
|
5187
|
+
const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5188
|
+
if (inflightRequest) {
|
5189
|
+
const now2 = await inflightRequest;
|
5190
|
+
this.consensusParametersTimestamp = now2;
|
5191
|
+
return this.fetchChainAndNodeInfo();
|
5192
|
+
}
|
5193
|
+
const { promise, resolve } = deferPromise();
|
5194
|
+
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
|
4958
5195
|
const data = await this.operations.getChainAndNodeInfo();
|
4959
|
-
nodeInfo =
|
4960
|
-
|
4961
|
-
maxTx: bn17(data.nodeInfo.maxTx),
|
4962
|
-
nodeVersion: data.nodeInfo.nodeVersion,
|
4963
|
-
utxoValidation: data.nodeInfo.utxoValidation,
|
4964
|
-
vmBacktrace: data.nodeInfo.vmBacktrace
|
4965
|
-
};
|
5196
|
+
nodeInfo = deserializeNodeInfo(data.nodeInfo);
|
5197
|
+
chain = deserializeChain(data.chain);
|
4966
5198
|
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
4967
|
-
chain = processGqlChain(data.chain);
|
4968
5199
|
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
4969
5200
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
4970
|
-
|
5201
|
+
const now = Date.now();
|
5202
|
+
this.consensusParametersTimestamp = now;
|
5203
|
+
resolve(now);
|
5204
|
+
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
4971
5205
|
}
|
4972
5206
|
return {
|
4973
5207
|
chain,
|
@@ -5042,6 +5276,15 @@ var _Provider = class {
|
|
5042
5276
|
});
|
5043
5277
|
return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
|
5044
5278
|
}
|
5279
|
+
/**
|
5280
|
+
* @hidden
|
5281
|
+
*/
|
5282
|
+
setupFeatures(nodeVersion) {
|
5283
|
+
if (gte(nodeVersion, "0.41.0")) {
|
5284
|
+
this.features.balancePagination = true;
|
5285
|
+
this.features.amount128 = true;
|
5286
|
+
}
|
5287
|
+
}
|
5045
5288
|
/**
|
5046
5289
|
* Returns the version of the connected node.
|
5047
5290
|
*
|
@@ -5073,13 +5316,7 @@ var _Provider = class {
|
|
5073
5316
|
*/
|
5074
5317
|
async fetchNode() {
|
5075
5318
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
5076
|
-
const processedNodeInfo =
|
5077
|
-
maxDepth: bn17(nodeInfo.maxDepth),
|
5078
|
-
maxTx: bn17(nodeInfo.maxTx),
|
5079
|
-
nodeVersion: nodeInfo.nodeVersion,
|
5080
|
-
utxoValidation: nodeInfo.utxoValidation,
|
5081
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
5082
|
-
};
|
5319
|
+
const processedNodeInfo = deserializeNodeInfo(nodeInfo);
|
5083
5320
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = processedNodeInfo;
|
5084
5321
|
return processedNodeInfo;
|
5085
5322
|
}
|
@@ -5090,7 +5327,7 @@ var _Provider = class {
|
|
5090
5327
|
*/
|
5091
5328
|
async fetchChain() {
|
5092
5329
|
const { chain } = await this.operations.getChain();
|
5093
|
-
const processedChain =
|
5330
|
+
const processedChain = deserializeChain(chain);
|
5094
5331
|
_Provider.chainInfoCache[this.urlWithoutAuth] = processedChain;
|
5095
5332
|
return processedChain;
|
5096
5333
|
}
|
@@ -5117,6 +5354,21 @@ var _Provider = class {
|
|
5117
5354
|
} = all;
|
5118
5355
|
return baseAssetId;
|
5119
5356
|
}
|
5357
|
+
/**
|
5358
|
+
* Retrieves the details of an asset given its ID.
|
5359
|
+
*
|
5360
|
+
* @param assetId - The unique identifier of the asset.
|
5361
|
+
* @returns A promise that resolves to an object containing the asset details.
|
5362
|
+
*/
|
5363
|
+
async getAssetDetails(assetId) {
|
5364
|
+
const { assetDetails } = await this.operations.getAssetDetails({ assetId });
|
5365
|
+
const { contractId, subId, totalSupply } = assetDetails;
|
5366
|
+
return {
|
5367
|
+
subId,
|
5368
|
+
contractId,
|
5369
|
+
totalSupply: bn17(totalSupply)
|
5370
|
+
};
|
5371
|
+
}
|
5120
5372
|
/**
|
5121
5373
|
* @hidden
|
5122
5374
|
*/
|
@@ -5127,13 +5379,13 @@ var _Provider = class {
|
|
5127
5379
|
}
|
5128
5380
|
} = await this.getChain();
|
5129
5381
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
5130
|
-
throw new
|
5382
|
+
throw new FuelError20(
|
5131
5383
|
ErrorCode16.MAX_INPUTS_EXCEEDED,
|
5132
5384
|
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
5133
5385
|
);
|
5134
5386
|
}
|
5135
5387
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
5136
|
-
throw new
|
5388
|
+
throw new FuelError20(
|
5137
5389
|
ErrorCode16.MAX_OUTPUTS_EXCEEDED,
|
5138
5390
|
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
5139
5391
|
);
|
@@ -5160,7 +5412,7 @@ var _Provider = class {
|
|
5160
5412
|
await this.estimateTxDependencies(transactionRequest);
|
5161
5413
|
}
|
5162
5414
|
await this.validateTransaction(transactionRequest);
|
5163
|
-
const encodedTransaction =
|
5415
|
+
const encodedTransaction = hexlify18(transactionRequest.toTransactionBytes());
|
5164
5416
|
let abis;
|
5165
5417
|
if (isTransactionTypeScript(transactionRequest)) {
|
5166
5418
|
abis = transactionRequest.abis;
|
@@ -5185,48 +5437,70 @@ var _Provider = class {
|
|
5185
5437
|
if (estimateTxDependencies) {
|
5186
5438
|
return this.estimateTxDependencies(transactionRequest);
|
5187
5439
|
}
|
5188
|
-
const encodedTransaction =
|
5440
|
+
const encodedTransaction = hexlify18(transactionRequest.toTransactionBytes());
|
5189
5441
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5190
5442
|
encodedTransactions: encodedTransaction,
|
5191
5443
|
utxoValidation: utxoValidation || false
|
5192
5444
|
});
|
5193
5445
|
const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
|
5194
|
-
const receipts = rawReceipts.map(
|
5446
|
+
const receipts = rawReceipts.map(deserializeReceipt);
|
5195
5447
|
return { receipts, dryRunStatus };
|
5196
5448
|
}
|
5197
5449
|
/**
|
5198
|
-
*
|
5450
|
+
* Estimates the gas usage for predicates in a transaction request.
|
5199
5451
|
*
|
5200
5452
|
* @template T - The type of the transaction request object.
|
5201
5453
|
*
|
5202
|
-
* @param transactionRequest - The transaction request
|
5203
|
-
* @returns A promise that resolves to the
|
5454
|
+
* @param transactionRequest - The transaction request to estimate predicates for.
|
5455
|
+
* @returns A promise that resolves to the updated transaction request with estimated gas usage for predicates.
|
5204
5456
|
*/
|
5205
5457
|
async estimatePredicates(transactionRequest) {
|
5206
|
-
const shouldEstimatePredicates =
|
5207
|
-
|
5208
|
-
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify13(input.predicate), arrayify13("0x")) && new BN2(input.predicateGasUsed).isZero()
|
5209
|
-
)
|
5458
|
+
const shouldEstimatePredicates = transactionRequest.inputs.some(
|
5459
|
+
(input) => isPredicate(input) && bn17(input.predicateGasUsed).isZero()
|
5210
5460
|
);
|
5211
5461
|
if (!shouldEstimatePredicates) {
|
5212
5462
|
return transactionRequest;
|
5213
5463
|
}
|
5214
|
-
const encodedTransaction =
|
5464
|
+
const encodedTransaction = hexlify18(transactionRequest.toTransactionBytes());
|
5215
5465
|
const response = await this.operations.estimatePredicates({
|
5216
5466
|
encodedTransaction
|
5217
5467
|
});
|
5218
|
-
const {
|
5219
|
-
|
5220
|
-
|
5221
|
-
|
5222
|
-
|
5223
|
-
if ("predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
|
5224
|
-
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
5225
|
-
}
|
5226
|
-
});
|
5227
|
-
}
|
5468
|
+
const { estimatePredicates } = response;
|
5469
|
+
transactionRequest = this.parseEstimatePredicatesResponse(
|
5470
|
+
transactionRequest,
|
5471
|
+
estimatePredicates
|
5472
|
+
);
|
5228
5473
|
return transactionRequest;
|
5229
5474
|
}
|
5475
|
+
/**
|
5476
|
+
* Estimates the gas price and predicates for a given transaction request and block horizon.
|
5477
|
+
*
|
5478
|
+
* @param transactionRequest - The transaction request to estimate predicates and gas price for.
|
5479
|
+
* @param blockHorizon - The block horizon to use for gas price estimation.
|
5480
|
+
* @returns A promise that resolves to an object containing the updated transaction
|
5481
|
+
* request and the estimated gas price.
|
5482
|
+
*/
|
5483
|
+
async estimatePredicatesAndGasPrice(transactionRequest, blockHorizon) {
|
5484
|
+
const shouldEstimatePredicates = transactionRequest.inputs.some(
|
5485
|
+
(input) => isPredicate(input) && bn17(input.predicateGasUsed).isZero()
|
5486
|
+
);
|
5487
|
+
if (!shouldEstimatePredicates) {
|
5488
|
+
const gasPrice2 = await this.estimateGasPrice(blockHorizon);
|
5489
|
+
return { transactionRequest, gasPrice: gasPrice2 };
|
5490
|
+
}
|
5491
|
+
const {
|
5492
|
+
estimateGasPrice: { gasPrice },
|
5493
|
+
estimatePredicates
|
5494
|
+
} = await this.operations.estimatePredicatesAndGasPrice({
|
5495
|
+
blockHorizon: String(blockHorizon),
|
5496
|
+
encodedTransaction: hexlify18(transactionRequest.toTransactionBytes())
|
5497
|
+
});
|
5498
|
+
transactionRequest = this.parseEstimatePredicatesResponse(
|
5499
|
+
transactionRequest,
|
5500
|
+
estimatePredicates
|
5501
|
+
);
|
5502
|
+
return { transactionRequest, gasPrice: bn17(gasPrice) };
|
5503
|
+
}
|
5230
5504
|
/**
|
5231
5505
|
* Will dryRun a transaction and check for missing dependencies.
|
5232
5506
|
*
|
@@ -5240,11 +5514,13 @@ var _Provider = class {
|
|
5240
5514
|
async estimateTxDependencies(transactionRequest, { gasPrice: gasPriceParam } = {}) {
|
5241
5515
|
if (isTransactionTypeCreate(transactionRequest)) {
|
5242
5516
|
return {
|
5517
|
+
rawReceipts: [],
|
5243
5518
|
receipts: [],
|
5244
5519
|
outputVariables: 0,
|
5245
5520
|
missingContractIds: []
|
5246
5521
|
};
|
5247
5522
|
}
|
5523
|
+
let rawReceipts = [];
|
5248
5524
|
let receipts = [];
|
5249
5525
|
const missingContractIds = [];
|
5250
5526
|
let outputVariables = 0;
|
@@ -5253,13 +5529,14 @@ var _Provider = class {
|
|
5253
5529
|
const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
|
5254
5530
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
5255
5531
|
const {
|
5256
|
-
dryRun: [{ receipts:
|
5532
|
+
dryRun: [{ receipts: serializedReceipts, status }]
|
5257
5533
|
} = await this.operations.dryRun({
|
5258
|
-
encodedTransactions: [
|
5534
|
+
encodedTransactions: [hexlify18(transactionRequest.toTransactionBytes())],
|
5259
5535
|
utxoValidation: false,
|
5260
5536
|
gasPrice: gasPrice.toString()
|
5261
5537
|
});
|
5262
|
-
|
5538
|
+
rawReceipts = serializedReceipts;
|
5539
|
+
receipts = serializedReceipts.map(deserializeReceipt);
|
5263
5540
|
dryRunStatus = status;
|
5264
5541
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
5265
5542
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
@@ -5280,6 +5557,7 @@ var _Provider = class {
|
|
5280
5557
|
}
|
5281
5558
|
}
|
5282
5559
|
return {
|
5560
|
+
rawReceipts,
|
5283
5561
|
receipts,
|
5284
5562
|
outputVariables,
|
5285
5563
|
missingContractIds,
|
@@ -5298,6 +5576,7 @@ var _Provider = class {
|
|
5298
5576
|
*/
|
5299
5577
|
async estimateMultipleTxDependencies(transactionRequests) {
|
5300
5578
|
const results = transactionRequests.map(() => ({
|
5579
|
+
rawReceipts: [],
|
5301
5580
|
receipts: [],
|
5302
5581
|
outputVariables: 0,
|
5303
5582
|
missingContractIds: [],
|
@@ -5307,7 +5586,7 @@ var _Provider = class {
|
|
5307
5586
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
5308
5587
|
allRequests.forEach((req, index) => {
|
5309
5588
|
if (isTransactionTypeScript(req)) {
|
5310
|
-
serializedTransactionsMap.set(index,
|
5589
|
+
serializedTransactionsMap.set(index, hexlify18(req.toTransactionBytes()));
|
5311
5590
|
}
|
5312
5591
|
});
|
5313
5592
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -5325,7 +5604,7 @@ var _Provider = class {
|
|
5325
5604
|
const requestIdx = transactionsToProcess[i];
|
5326
5605
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
5327
5606
|
const result = results[requestIdx];
|
5328
|
-
result.receipts = rawReceipts.map(
|
5607
|
+
result.receipts = rawReceipts.map(deserializeReceipt);
|
5329
5608
|
result.dryRunStatus = status;
|
5330
5609
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
5331
5610
|
result.receipts
|
@@ -5343,7 +5622,7 @@ var _Provider = class {
|
|
5343
5622
|
transactionRequest: request
|
5344
5623
|
});
|
5345
5624
|
request.maxFee = maxFee;
|
5346
|
-
serializedTransactionsMap.set(requestIdx,
|
5625
|
+
serializedTransactionsMap.set(requestIdx, hexlify18(request.toTransactionBytes()));
|
5347
5626
|
nextRoundTransactions.push(requestIdx);
|
5348
5627
|
}
|
5349
5628
|
}
|
@@ -5364,13 +5643,13 @@ var _Provider = class {
|
|
5364
5643
|
if (estimateTxDependencies) {
|
5365
5644
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
5366
5645
|
}
|
5367
|
-
const encodedTransactions = transactionRequests.map((tx) =>
|
5646
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify18(tx.toTransactionBytes()));
|
5368
5647
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5369
5648
|
encodedTransactions,
|
5370
5649
|
utxoValidation: utxoValidation || false
|
5371
5650
|
});
|
5372
5651
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
5373
|
-
const receipts = rawReceipts.map(
|
5652
|
+
const receipts = rawReceipts.map(deserializeReceipt);
|
5374
5653
|
return { receipts, dryRunStatus: status };
|
5375
5654
|
});
|
5376
5655
|
return results;
|
@@ -5464,14 +5743,14 @@ var _Provider = class {
|
|
5464
5743
|
if (estimateTxDependencies) {
|
5465
5744
|
return this.estimateTxDependencies(transactionRequest);
|
5466
5745
|
}
|
5467
|
-
const encodedTransactions = [
|
5746
|
+
const encodedTransactions = [hexlify18(transactionRequest.toTransactionBytes())];
|
5468
5747
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5469
5748
|
encodedTransactions,
|
5470
5749
|
utxoValidation: true
|
5471
5750
|
});
|
5472
5751
|
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
5473
5752
|
const { id, receipts, status } = dryRunStatus;
|
5474
|
-
const processedReceipts = receipts.map(
|
5753
|
+
const processedReceipts = receipts.map(deserializeReceipt);
|
5475
5754
|
return { id, receipts: processedReceipts, status };
|
5476
5755
|
});
|
5477
5756
|
return { receipts: callResult[0].receipts };
|
@@ -5502,14 +5781,20 @@ var _Provider = class {
|
|
5502
5781
|
await signatureCallback(signedRequest);
|
5503
5782
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
5504
5783
|
}
|
5505
|
-
|
5784
|
+
let gasPrice;
|
5785
|
+
if (gasPriceParam) {
|
5786
|
+
gasPrice = gasPriceParam;
|
5787
|
+
await this.estimatePredicates(signedRequest);
|
5788
|
+
} else {
|
5789
|
+
({ gasPrice } = await this.estimatePredicatesAndGasPrice(signedRequest, 10));
|
5790
|
+
}
|
5506
5791
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
5507
|
-
const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
|
5508
5792
|
let { maxFee, maxGas, minFee, minGas, gasLimit } = await this.estimateTxGasAndFee({
|
5509
5793
|
// Fetches and returns a gas price
|
5510
5794
|
transactionRequest: signedRequest,
|
5511
5795
|
gasPrice
|
5512
5796
|
});
|
5797
|
+
let rawReceipts = [];
|
5513
5798
|
let receipts = [];
|
5514
5799
|
let dryRunStatus;
|
5515
5800
|
let missingContractIds = [];
|
@@ -5521,7 +5806,7 @@ var _Provider = class {
|
|
5521
5806
|
if (signatureCallback) {
|
5522
5807
|
await signatureCallback(txRequestClone);
|
5523
5808
|
}
|
5524
|
-
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
|
5809
|
+
({ rawReceipts, receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
|
5525
5810
|
if (dryRunStatus && "reason" in dryRunStatus) {
|
5526
5811
|
throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
|
5527
5812
|
}
|
@@ -5534,7 +5819,12 @@ var _Provider = class {
|
|
5534
5819
|
gasPrice
|
5535
5820
|
}));
|
5536
5821
|
}
|
5822
|
+
const transactionSummary = {
|
5823
|
+
gasPrice: gasPrice.toString(),
|
5824
|
+
receipts: rawReceipts
|
5825
|
+
};
|
5537
5826
|
return {
|
5827
|
+
rawReceipts,
|
5538
5828
|
receipts,
|
5539
5829
|
gasUsed,
|
5540
5830
|
gasPrice,
|
@@ -5547,7 +5837,8 @@ var _Provider = class {
|
|
5547
5837
|
addedSignatures,
|
5548
5838
|
estimatedPredicates: txRequestClone.inputs,
|
5549
5839
|
dryRunStatus,
|
5550
|
-
updateMaxFee
|
5840
|
+
updateMaxFee,
|
5841
|
+
transactionSummary
|
5551
5842
|
};
|
5552
5843
|
}
|
5553
5844
|
/**
|
@@ -5568,7 +5859,7 @@ var _Provider = class {
|
|
5568
5859
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
5569
5860
|
inputArgs: paginationArgs
|
5570
5861
|
}),
|
5571
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId &&
|
5862
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify18(assetId) }
|
5572
5863
|
});
|
5573
5864
|
const coins = edges.map(({ node }) => ({
|
5574
5865
|
id: node.utxoId,
|
@@ -5593,23 +5884,33 @@ var _Provider = class {
|
|
5593
5884
|
*/
|
5594
5885
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
5595
5886
|
const ownerAddress = new Address3(owner);
|
5596
|
-
|
5597
|
-
messages: excludedIds?.messages?.map((nonce) =>
|
5598
|
-
utxos: excludedIds?.utxos?.map((id) =>
|
5887
|
+
let idsToExclude = {
|
5888
|
+
messages: excludedIds?.messages?.map((nonce) => hexlify18(nonce)) || [],
|
5889
|
+
utxos: excludedIds?.utxos?.map((id) => hexlify18(id)) || []
|
5599
5890
|
};
|
5600
5891
|
if (this.cache) {
|
5601
|
-
const cached = this.cache.getActiveData();
|
5602
|
-
|
5603
|
-
|
5892
|
+
const cached = this.cache.getActiveData(ownerAddress.toB256());
|
5893
|
+
if (cached.utxos.length || cached.messages.length) {
|
5894
|
+
const {
|
5895
|
+
consensusParameters: {
|
5896
|
+
txParameters: { maxInputs }
|
5897
|
+
}
|
5898
|
+
} = await this.getChain();
|
5899
|
+
idsToExclude = adjustResourcesToExclude({
|
5900
|
+
userInput: idsToExclude,
|
5901
|
+
cached,
|
5902
|
+
maxInputs: maxInputs.toNumber()
|
5903
|
+
});
|
5904
|
+
}
|
5604
5905
|
}
|
5605
5906
|
const coinsQuery = {
|
5606
5907
|
owner: ownerAddress.toB256(),
|
5607
5908
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
5608
|
-
assetId:
|
5609
|
-
amount: amount.toString(10),
|
5909
|
+
assetId: hexlify18(assetId),
|
5910
|
+
amount: (amount.eqn(0) ? bn17(1) : amount).toString(10),
|
5610
5911
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
5611
5912
|
})),
|
5612
|
-
excludedIds:
|
5913
|
+
excludedIds: idsToExclude
|
5613
5914
|
};
|
5614
5915
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
5615
5916
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
@@ -5667,7 +5968,7 @@ var _Provider = class {
|
|
5667
5968
|
} = await this.operations.getLatestBlock();
|
5668
5969
|
block = latestBlock;
|
5669
5970
|
} else {
|
5670
|
-
const isblockId = typeof idOrHeight === "string" && idOrHeight
|
5971
|
+
const isblockId = typeof idOrHeight === "string" && isB256(idOrHeight);
|
5671
5972
|
const variables = isblockId ? { blockId: idOrHeight } : { height: bn17(idOrHeight).toString(10) };
|
5672
5973
|
const response = await this.operations.getBlock(variables);
|
5673
5974
|
block = response.block;
|
@@ -5738,8 +6039,10 @@ var _Provider = class {
|
|
5738
6039
|
variables = { blockHeight: bn17(idOrHeight).toString(10) };
|
5739
6040
|
} else if (idOrHeight === "latest") {
|
5740
6041
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
5741
|
-
} else {
|
6042
|
+
} else if (typeof idOrHeight === "string" && isB256(idOrHeight)) {
|
5742
6043
|
variables = { blockId: idOrHeight };
|
6044
|
+
} else {
|
6045
|
+
variables = { blockHeight: bn17(idOrHeight).toString() };
|
5743
6046
|
}
|
5744
6047
|
const { block } = await this.operations.getBlockWithTransactions(variables);
|
5745
6048
|
if (!block) {
|
@@ -5782,7 +6085,7 @@ var _Provider = class {
|
|
5782
6085
|
0
|
5783
6086
|
)?.[0];
|
5784
6087
|
} catch (error) {
|
5785
|
-
if (error instanceof
|
6088
|
+
if (error instanceof FuelError20 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
5786
6089
|
console.warn("Unsupported transaction type encountered");
|
5787
6090
|
return null;
|
5788
6091
|
}
|
@@ -5808,7 +6111,7 @@ var _Provider = class {
|
|
5808
6111
|
try {
|
5809
6112
|
return coder.decode(arrayify13(rawPayload), 0)[0];
|
5810
6113
|
} catch (error) {
|
5811
|
-
if (error instanceof
|
6114
|
+
if (error instanceof FuelError20 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
5812
6115
|
console.warn("Unsupported transaction type encountered");
|
5813
6116
|
return null;
|
5814
6117
|
}
|
@@ -5855,7 +6158,7 @@ var _Provider = class {
|
|
5855
6158
|
async getContractBalance(contractId, assetId) {
|
5856
6159
|
const { contractBalance } = await this.operations.getContractBalance({
|
5857
6160
|
contract: new Address3(contractId).toB256(),
|
5858
|
-
asset:
|
6161
|
+
asset: hexlify18(assetId)
|
5859
6162
|
});
|
5860
6163
|
return bn17(contractBalance.amount, 10);
|
5861
6164
|
}
|
@@ -5867,11 +6170,20 @@ var _Provider = class {
|
|
5867
6170
|
* @returns A promise that resolves to the balance.
|
5868
6171
|
*/
|
5869
6172
|
async getBalance(owner, assetId) {
|
5870
|
-
const
|
5871
|
-
|
5872
|
-
|
6173
|
+
const ownerStr = new Address3(owner).toB256();
|
6174
|
+
const assetIdStr = hexlify18(assetId);
|
6175
|
+
if (!this.features.amount128) {
|
6176
|
+
const { balance: balance2 } = await this.operations.getBalance({
|
6177
|
+
owner: ownerStr,
|
6178
|
+
assetId: assetIdStr
|
6179
|
+
});
|
6180
|
+
return bn17(balance2.amount, 10);
|
6181
|
+
}
|
6182
|
+
const { balance } = await this.operations.getBalanceV2({
|
6183
|
+
owner: ownerStr,
|
6184
|
+
assetId: assetIdStr
|
5873
6185
|
});
|
5874
|
-
return bn17(balance.
|
6186
|
+
return bn17(balance.amountU128, 10);
|
5875
6187
|
}
|
5876
6188
|
/**
|
5877
6189
|
* Returns balances for the given owner.
|
@@ -5880,7 +6192,16 @@ var _Provider = class {
|
|
5880
6192
|
* @param paginationArgs - Pagination arguments (optional).
|
5881
6193
|
* @returns A promise that resolves to the balances.
|
5882
6194
|
*/
|
5883
|
-
async getBalances(owner) {
|
6195
|
+
async getBalances(owner, paginationArgs) {
|
6196
|
+
if (!this.features.balancePagination) {
|
6197
|
+
return this.getBalancesV1(owner, paginationArgs);
|
6198
|
+
}
|
6199
|
+
return this.getBalancesV2(owner, paginationArgs);
|
6200
|
+
}
|
6201
|
+
/**
|
6202
|
+
* @hidden
|
6203
|
+
*/
|
6204
|
+
async getBalancesV1(owner, _paginationArgs) {
|
5884
6205
|
const {
|
5885
6206
|
balances: { edges }
|
5886
6207
|
} = await this.operations.getBalances({
|
@@ -5897,6 +6218,25 @@ var _Provider = class {
|
|
5897
6218
|
}));
|
5898
6219
|
return { balances };
|
5899
6220
|
}
|
6221
|
+
/**
|
6222
|
+
* @hidden
|
6223
|
+
*/
|
6224
|
+
async getBalancesV2(owner, paginationArgs) {
|
6225
|
+
const {
|
6226
|
+
balances: { edges, pageInfo }
|
6227
|
+
} = await this.operations.getBalancesV2({
|
6228
|
+
...validatePaginationArgs({
|
6229
|
+
inputArgs: paginationArgs,
|
6230
|
+
paginationLimit: BALANCES_PAGE_SIZE_LIMIT
|
6231
|
+
}),
|
6232
|
+
filter: { owner: new Address3(owner).toB256() }
|
6233
|
+
});
|
6234
|
+
const balances = edges.map(({ node }) => ({
|
6235
|
+
assetId: node.assetId,
|
6236
|
+
amount: bn17(node.amountU128)
|
6237
|
+
}));
|
6238
|
+
return { balances, pageInfo };
|
6239
|
+
}
|
5900
6240
|
/**
|
5901
6241
|
* Returns message for the given address.
|
5902
6242
|
*
|
@@ -5949,7 +6289,7 @@ var _Provider = class {
|
|
5949
6289
|
nonce
|
5950
6290
|
};
|
5951
6291
|
if (commitBlockId && commitBlockHeight) {
|
5952
|
-
throw new
|
6292
|
+
throw new FuelError20(
|
5953
6293
|
ErrorCode16.INVALID_INPUT_PARAMETERS,
|
5954
6294
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5955
6295
|
);
|
@@ -5963,15 +6303,12 @@ var _Provider = class {
|
|
5963
6303
|
if (commitBlockHeight) {
|
5964
6304
|
inputObject = {
|
5965
6305
|
...inputObject,
|
5966
|
-
//
|
5967
|
-
// This should
|
6306
|
+
// Convert BN into a number string required on the query
|
6307
|
+
// This should probably be fixed on the fuel client side
|
5968
6308
|
commitBlockHeight: commitBlockHeight.toNumber().toString()
|
5969
6309
|
};
|
5970
6310
|
}
|
5971
6311
|
const result = await this.operations.getMessageProof(inputObject);
|
5972
|
-
if (!result.messageProof) {
|
5973
|
-
return null;
|
5974
|
-
}
|
5975
6312
|
const {
|
5976
6313
|
messageProof,
|
5977
6314
|
messageBlockHeader,
|
@@ -6080,16 +6417,15 @@ var _Provider = class {
|
|
6080
6417
|
* @returns A promise that resolves to the result of the check.
|
6081
6418
|
*/
|
6082
6419
|
async isUserAccount(id) {
|
6083
|
-
const
|
6084
|
-
|
6085
|
-
contractId: id,
|
6086
|
-
transactionId: id
|
6087
|
-
});
|
6088
|
-
if (contract || blob || transaction) {
|
6089
|
-
return false;
|
6090
|
-
}
|
6091
|
-
return true;
|
6420
|
+
const type = await this.getAddressType(id);
|
6421
|
+
return type === "Account";
|
6092
6422
|
}
|
6423
|
+
/**
|
6424
|
+
* Determines the type of address based on the provided ID.
|
6425
|
+
*
|
6426
|
+
* @param id - The ID to be checked.
|
6427
|
+
* @returns A promise that resolves to a string indicating the type of address.
|
6428
|
+
*/
|
6093
6429
|
async getAddressType(id) {
|
6094
6430
|
const { contract, blob, transaction } = await this.operations.isUserAccount({
|
6095
6431
|
blobId: id,
|
@@ -6105,6 +6441,13 @@ var _Provider = class {
|
|
6105
6441
|
if (transaction) {
|
6106
6442
|
return "Transaction";
|
6107
6443
|
}
|
6444
|
+
try {
|
6445
|
+
const asset = await this.getAssetDetails(id);
|
6446
|
+
if (asset) {
|
6447
|
+
return "Asset";
|
6448
|
+
}
|
6449
|
+
} catch (e) {
|
6450
|
+
}
|
6108
6451
|
return "Account";
|
6109
6452
|
}
|
6110
6453
|
/**
|
@@ -6179,6 +6522,19 @@ var _Provider = class {
|
|
6179
6522
|
statusReason: status.reason
|
6180
6523
|
});
|
6181
6524
|
}
|
6525
|
+
/**
|
6526
|
+
* @hidden
|
6527
|
+
*/
|
6528
|
+
parseEstimatePredicatesResponse(transactionRequest, { inputs }) {
|
6529
|
+
if (inputs) {
|
6530
|
+
inputs.forEach((input, i) => {
|
6531
|
+
if (input && "predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
|
6532
|
+
transactionRequest.inputs[i].predicateGasUsed = input.predicateGasUsed;
|
6533
|
+
}
|
6534
|
+
});
|
6535
|
+
}
|
6536
|
+
return transactionRequest;
|
6537
|
+
}
|
6182
6538
|
};
|
6183
6539
|
var Provider = _Provider;
|
6184
6540
|
_cacheInputs = new WeakSet();
|
@@ -6186,20 +6542,11 @@ cacheInputs_fn = function(inputs, transactionId) {
|
|
6186
6542
|
if (!this.cache) {
|
6187
6543
|
return;
|
6188
6544
|
}
|
6189
|
-
|
6190
|
-
(acc, input) => {
|
6191
|
-
if (input.type === InputType7.Coin) {
|
6192
|
-
acc.utxos.push(input.id);
|
6193
|
-
} else if (input.type === InputType7.Message) {
|
6194
|
-
acc.messages.push(input.nonce);
|
6195
|
-
}
|
6196
|
-
return acc;
|
6197
|
-
},
|
6198
|
-
{ utxos: [], messages: [] }
|
6199
|
-
);
|
6200
|
-
this.cache.set(transactionId, inputsToCache);
|
6545
|
+
this.cache.set(transactionId, inputs);
|
6201
6546
|
};
|
6202
6547
|
/** @hidden */
|
6548
|
+
__publicField(Provider, "inflightFetchChainAndNodeInfoRequests", {});
|
6549
|
+
/** @hidden */
|
6203
6550
|
__publicField(Provider, "chainInfoCache", {});
|
6204
6551
|
/** @hidden */
|
6205
6552
|
__publicField(Provider, "nodeInfoCache", {});
|
@@ -6207,14 +6554,19 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
6207
6554
|
__publicField(Provider, "incompatibleNodeVersionMessage", "");
|
6208
6555
|
|
6209
6556
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6210
|
-
import { ErrorCode as ErrorCode17, FuelError as
|
6557
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError21 } from "@fuel-ts/errors";
|
6211
6558
|
import { bn as bn18 } from "@fuel-ts/math";
|
6212
6559
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
6213
6560
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
6214
6561
|
|
6562
|
+
// src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
|
6563
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
6564
|
+
import { TransactionCoder as TransactionCoder7 } from "@fuel-ts/transactions";
|
6565
|
+
import { arrayify as arrayify15 } from "@fuel-ts/utils";
|
6566
|
+
|
6215
6567
|
// src/test-utils/test-asset-id.ts
|
6216
6568
|
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
6217
|
-
import { hexlify as
|
6569
|
+
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
6218
6570
|
var _TestAssetId = class {
|
6219
6571
|
constructor(value) {
|
6220
6572
|
this.value = value;
|
@@ -6222,7 +6574,7 @@ var _TestAssetId = class {
|
|
6222
6574
|
static random(count = 1) {
|
6223
6575
|
const assetIds = [];
|
6224
6576
|
for (let i = 0; i < count; i++) {
|
6225
|
-
assetIds.push(new _TestAssetId(
|
6577
|
+
assetIds.push(new _TestAssetId(hexlify19(randomBytes4(32))));
|
6226
6578
|
}
|
6227
6579
|
return assetIds;
|
6228
6580
|
}
|
@@ -6237,22 +6589,22 @@ __publicField(TestAssetId, "B", new _TestAssetId(
|
|
6237
6589
|
|
6238
6590
|
// src/test-utils/wallet-config.ts
|
6239
6591
|
import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
|
6240
|
-
import { FuelError as
|
6241
|
-
import { bn as
|
6242
|
-
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as
|
6592
|
+
import { FuelError as FuelError27 } from "@fuel-ts/errors";
|
6593
|
+
import { bn as bn22 } from "@fuel-ts/math";
|
6594
|
+
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify25 } from "@fuel-ts/utils";
|
6243
6595
|
|
6244
6596
|
// src/wallet/base-wallet-unlocked.ts
|
6245
6597
|
import { hashMessage } from "@fuel-ts/hasher";
|
6246
|
-
import { hexlify as
|
6598
|
+
import { hexlify as hexlify22 } from "@fuel-ts/utils";
|
6247
6599
|
|
6248
6600
|
// src/account.ts
|
6249
6601
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
6250
6602
|
import { Address as Address5 } from "@fuel-ts/address";
|
6251
6603
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
6252
|
-
import { ErrorCode as ErrorCode18, FuelError as
|
6253
|
-
import { bn as
|
6254
|
-
import { InputType as
|
6255
|
-
import { arrayify as
|
6604
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError22 } from "@fuel-ts/errors";
|
6605
|
+
import { bn as bn20 } from "@fuel-ts/math";
|
6606
|
+
import { InputType as InputType7 } from "@fuel-ts/transactions";
|
6607
|
+
import { arrayify as arrayify17, hexlify as hexlify20, isDefined as isDefined3 } from "@fuel-ts/utils";
|
6256
6608
|
import { clone as clone9 } from "ramda";
|
6257
6609
|
|
6258
6610
|
// src/providers/utils/merge-quantities.ts
|
@@ -6276,14 +6628,14 @@ var AbstractAccount = class {
|
|
6276
6628
|
// src/utils/formatTransferToContractScriptData.ts
|
6277
6629
|
import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
|
6278
6630
|
import { Address as Address4 } from "@fuel-ts/address";
|
6279
|
-
import { arrayify as
|
6631
|
+
import { arrayify as arrayify16, concat as concat4 } from "@fuel-ts/utils";
|
6280
6632
|
import * as asm from "@fuels/vm-asm";
|
6281
6633
|
var formatTransferToContractScriptData = (transferParams) => {
|
6282
6634
|
const numberCoder = new BigNumberCoder2("u64");
|
6283
6635
|
return transferParams.reduce((acc, transferParam) => {
|
6284
6636
|
const { assetId, amount, contractId } = transferParam;
|
6285
6637
|
const encoded = numberCoder.encode(amount);
|
6286
|
-
const scriptData = concat4([new Address4(contractId).toBytes(), encoded,
|
6638
|
+
const scriptData = concat4([new Address4(contractId).toBytes(), encoded, arrayify16(assetId)]);
|
6287
6639
|
return concat4([acc, scriptData]);
|
6288
6640
|
}, new Uint8Array());
|
6289
6641
|
};
|
@@ -6350,7 +6702,7 @@ var Account = class extends AbstractAccount {
|
|
6350
6702
|
*/
|
6351
6703
|
get provider() {
|
6352
6704
|
if (!this._provider) {
|
6353
|
-
throw new
|
6705
|
+
throw new FuelError22(ErrorCode18.MISSING_PROVIDER, "Provider not set");
|
6354
6706
|
}
|
6355
6707
|
return this._provider;
|
6356
6708
|
}
|
@@ -6427,12 +6779,20 @@ var Account = class extends AbstractAccount {
|
|
6427
6779
|
* @returns A promise that resolves to the funded transaction request.
|
6428
6780
|
*/
|
6429
6781
|
async fund(request, params) {
|
6430
|
-
const {
|
6782
|
+
const {
|
6783
|
+
addedSignatures,
|
6784
|
+
estimatedPredicates,
|
6785
|
+
requiredQuantities,
|
6786
|
+
updateMaxFee,
|
6787
|
+
gasPrice,
|
6788
|
+
transactionSummary
|
6789
|
+
} = params;
|
6790
|
+
const chainId = await this.provider.getChainId();
|
6431
6791
|
const fee = request.maxFee;
|
6432
6792
|
const baseAssetId = await this.provider.getBaseAssetId();
|
6433
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
6793
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn20(0);
|
6434
6794
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
6435
|
-
amount:
|
6795
|
+
amount: bn20(fee),
|
6436
6796
|
assetId: baseAssetId,
|
6437
6797
|
coinQuantities: requiredQuantities
|
6438
6798
|
});
|
@@ -6440,7 +6800,7 @@ var Account = class extends AbstractAccount {
|
|
6440
6800
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
6441
6801
|
quantitiesDict[assetId] = {
|
6442
6802
|
required: amount,
|
6443
|
-
owned:
|
6803
|
+
owned: bn20(0)
|
6444
6804
|
};
|
6445
6805
|
});
|
6446
6806
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -6501,11 +6861,12 @@ var Account = class extends AbstractAccount {
|
|
6501
6861
|
fundingAttempts += 1;
|
6502
6862
|
}
|
6503
6863
|
if (needsToBeFunded) {
|
6504
|
-
throw new
|
6505
|
-
ErrorCode18.
|
6864
|
+
throw new FuelError22(
|
6865
|
+
ErrorCode18.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
6506
6866
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6507
6867
|
);
|
6508
6868
|
}
|
6869
|
+
request.updateState(chainId, "funded", transactionSummary);
|
6509
6870
|
await this.provider.validateTransaction(request);
|
6510
6871
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6511
6872
|
const requestToReestimate = clone9(request);
|
@@ -6616,11 +6977,11 @@ var Account = class extends AbstractAccount {
|
|
6616
6977
|
const quantities = [];
|
6617
6978
|
const defaultAssetId = await this.provider.getBaseAssetId();
|
6618
6979
|
const transferParams = contractTransferParams.map((transferParam) => {
|
6619
|
-
const amount =
|
6980
|
+
const amount = bn20(transferParam.amount);
|
6620
6981
|
const contractAddress = new Address5(transferParam.contractId);
|
6621
|
-
const assetId = transferParam.assetId ?
|
6982
|
+
const assetId = transferParam.assetId ? hexlify20(transferParam.assetId) : defaultAssetId;
|
6622
6983
|
if (amount.lte(0)) {
|
6623
|
-
throw new
|
6984
|
+
throw new FuelError22(
|
6624
6985
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
6625
6986
|
"Transfer amount must be a positive number."
|
6626
6987
|
);
|
@@ -6649,21 +7010,21 @@ var Account = class extends AbstractAccount {
|
|
6649
7010
|
*/
|
6650
7011
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
6651
7012
|
const recipientAddress = new Address5(recipient);
|
6652
|
-
const recipientDataArray =
|
7013
|
+
const recipientDataArray = arrayify17(
|
6653
7014
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
6654
7015
|
);
|
6655
|
-
const amountDataArray =
|
6656
|
-
"0x".concat(
|
7016
|
+
const amountDataArray = arrayify17(
|
7017
|
+
"0x".concat(bn20(amount).toHex().substring(2).padStart(16, "0"))
|
6657
7018
|
);
|
6658
7019
|
const script = new Uint8Array([
|
6659
|
-
...
|
7020
|
+
...arrayify17(withdrawScript.bytes),
|
6660
7021
|
...recipientDataArray,
|
6661
7022
|
...amountDataArray
|
6662
7023
|
]);
|
6663
7024
|
const params = { script, ...txParams };
|
6664
7025
|
const baseAssetId = await this.provider.getBaseAssetId();
|
6665
7026
|
let request = new ScriptTransactionRequest(params);
|
6666
|
-
const quantities = [{ amount:
|
7027
|
+
const quantities = [{ amount: bn20(amount), assetId: baseAssetId }];
|
6667
7028
|
const txCost = await this.getTransactionCost(request, { quantities });
|
6668
7029
|
request = this.validateGasLimitAndMaxFee({
|
6669
7030
|
transactionRequest: request,
|
@@ -6689,9 +7050,9 @@ var Account = class extends AbstractAccount {
|
|
6689
7050
|
const baseAssetId = await this.provider.getBaseAssetId();
|
6690
7051
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6691
7052
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
6692
|
-
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount:
|
7053
|
+
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn20("100000000000000000") }];
|
6693
7054
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
6694
|
-
if (input.type ===
|
7055
|
+
if (input.type === InputType7.Coin) {
|
6695
7056
|
return input.assetId === assetId;
|
6696
7057
|
}
|
6697
7058
|
if (isRequestInputMessageWithoutData(input)) {
|
@@ -6737,7 +7098,7 @@ var Account = class extends AbstractAccount {
|
|
6737
7098
|
*/
|
6738
7099
|
async signMessage(message) {
|
6739
7100
|
if (!this._connector) {
|
6740
|
-
throw new
|
7101
|
+
throw new FuelError22(ErrorCode18.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6741
7102
|
}
|
6742
7103
|
return this._connector.signMessage(this.address.toString(), message);
|
6743
7104
|
}
|
@@ -6749,7 +7110,7 @@ var Account = class extends AbstractAccount {
|
|
6749
7110
|
*/
|
6750
7111
|
async signTransaction(transactionRequestLike) {
|
6751
7112
|
if (!this._connector) {
|
6752
|
-
throw new
|
7113
|
+
throw new FuelError22(
|
6753
7114
|
ErrorCode18.MISSING_CONNECTOR,
|
6754
7115
|
"A connector is required to sign transactions."
|
6755
7116
|
);
|
@@ -6763,16 +7124,28 @@ var Account = class extends AbstractAccount {
|
|
6763
7124
|
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
6764
7125
|
* @returns A promise that resolves to the transaction response.
|
6765
7126
|
*/
|
6766
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true,
|
7127
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, ...connectorOptions } = {}) {
|
7128
|
+
let transactionRequest = transactionRequestify(transactionRequestLike);
|
6767
7129
|
if (this._connector) {
|
6768
|
-
|
6769
|
-
|
6770
|
-
|
6771
|
-
|
6772
|
-
|
7130
|
+
const { onBeforeSend, skipCustomFee = false } = connectorOptions;
|
7131
|
+
transactionRequest = await this.prepareTransactionForSend(transactionRequest);
|
7132
|
+
const params = {
|
7133
|
+
onBeforeSend,
|
7134
|
+
skipCustomFee,
|
7135
|
+
provider: {
|
7136
|
+
url: this.provider.url,
|
7137
|
+
cache: await serializeProviderCache(this.provider)
|
7138
|
+
},
|
7139
|
+
transactionState: transactionRequest.flag.state,
|
7140
|
+
transactionSummary: await this.prepareTransactionSummary(transactionRequest)
|
7141
|
+
};
|
7142
|
+
const transaction = await this._connector.sendTransaction(
|
7143
|
+
this.address.toString(),
|
7144
|
+
transactionRequest,
|
7145
|
+
params
|
6773
7146
|
);
|
7147
|
+
return typeof transaction === "string" ? this.provider.getTransactionResponse(transaction) : transaction;
|
6774
7148
|
}
|
6775
|
-
const transactionRequest = transactionRequestify(transactionRequestLike);
|
6776
7149
|
if (estimateTxDependencies) {
|
6777
7150
|
await this.provider.estimateTxDependencies(transactionRequest);
|
6778
7151
|
}
|
@@ -6802,17 +7175,39 @@ var Account = class extends AbstractAccount {
|
|
6802
7175
|
*/
|
6803
7176
|
generateFakeResources(coins) {
|
6804
7177
|
return coins.map((coin) => ({
|
6805
|
-
id:
|
7178
|
+
id: hexlify20(randomBytes5(UTXO_ID_LEN3)),
|
6806
7179
|
owner: this.address,
|
6807
|
-
blockCreated:
|
6808
|
-
txCreatedIdx:
|
7180
|
+
blockCreated: bn20(1),
|
7181
|
+
txCreatedIdx: bn20(1),
|
6809
7182
|
...coin
|
6810
7183
|
}));
|
6811
7184
|
}
|
7185
|
+
/** @hidden */
|
7186
|
+
async prepareTransactionForSend(request) {
|
7187
|
+
const { transactionId } = request.flag;
|
7188
|
+
if (!isDefined3(transactionId)) {
|
7189
|
+
return request;
|
7190
|
+
}
|
7191
|
+
const chainId = await this.provider.getChainId();
|
7192
|
+
const currentTransactionId = request.getTransactionId(chainId);
|
7193
|
+
if (transactionId !== currentTransactionId) {
|
7194
|
+
request.updateState(chainId);
|
7195
|
+
}
|
7196
|
+
return request;
|
7197
|
+
}
|
7198
|
+
/** @hidden */
|
7199
|
+
async prepareTransactionSummary(request) {
|
7200
|
+
const chainId = await this.provider.getChainId();
|
7201
|
+
return isDefined3(request.flag.summary) ? {
|
7202
|
+
...request.flag.summary,
|
7203
|
+
id: request.getTransactionId(chainId),
|
7204
|
+
transactionBytes: hexlify20(request.toTransactionBytes())
|
7205
|
+
} : void 0;
|
7206
|
+
}
|
6812
7207
|
/** @hidden * */
|
6813
7208
|
validateTransferAmount(amount) {
|
6814
|
-
if (
|
6815
|
-
throw new
|
7209
|
+
if (bn20(amount).lte(0)) {
|
7210
|
+
throw new FuelError22(
|
6816
7211
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
6817
7212
|
"Transfer amount must be a positive number."
|
6818
7213
|
);
|
@@ -6842,7 +7237,7 @@ var Account = class extends AbstractAccount {
|
|
6842
7237
|
if (!isDefined3(setGasLimit)) {
|
6843
7238
|
request.gasLimit = gasUsed;
|
6844
7239
|
} else if (gasUsed.gt(setGasLimit)) {
|
6845
|
-
throw new
|
7240
|
+
throw new FuelError22(
|
6846
7241
|
ErrorCode18.GAS_LIMIT_TOO_LOW,
|
6847
7242
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6848
7243
|
);
|
@@ -6850,7 +7245,7 @@ var Account = class extends AbstractAccount {
|
|
6850
7245
|
if (!isDefined3(setMaxFee)) {
|
6851
7246
|
request.maxFee = maxFee;
|
6852
7247
|
} else if (maxFee.gt(setMaxFee)) {
|
6853
|
-
throw new
|
7248
|
+
throw new FuelError22(
|
6854
7249
|
ErrorCode18.MAX_FEE_TOO_LOW,
|
6855
7250
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6856
7251
|
);
|
@@ -6871,8 +7266,8 @@ import {
|
|
6871
7266
|
encryptJsonWalletData,
|
6872
7267
|
randomUUID as randomUUID2
|
6873
7268
|
} from "@fuel-ts/crypto";
|
6874
|
-
import { ErrorCode as ErrorCode19, FuelError as
|
6875
|
-
import { hexlify as
|
7269
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError23 } from "@fuel-ts/errors";
|
7270
|
+
import { hexlify as hexlify21 } from "@fuel-ts/utils";
|
6876
7271
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6877
7272
|
var DEFAULT_KDF_PARAMS_R = 8;
|
6878
7273
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -6948,13 +7343,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6948
7343
|
const macHashUint8Array = keccak256(data);
|
6949
7344
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
6950
7345
|
if (mac !== macHash) {
|
6951
|
-
throw new
|
7346
|
+
throw new FuelError23(
|
6952
7347
|
ErrorCode19.INVALID_PASSWORD,
|
6953
7348
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6954
7349
|
);
|
6955
7350
|
}
|
6956
7351
|
const buffer = await decryptJsonWalletData(ciphertextBuffer, key, ivBuffer);
|
6957
|
-
const privateKey =
|
7352
|
+
const privateKey = hexlify21(buffer);
|
6958
7353
|
return privateKey;
|
6959
7354
|
}
|
6960
7355
|
|
@@ -6999,7 +7394,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6999
7394
|
*/
|
7000
7395
|
async signMessage(message) {
|
7001
7396
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
7002
|
-
return
|
7397
|
+
return hexlify22(signedMessage);
|
7003
7398
|
}
|
7004
7399
|
/**
|
7005
7400
|
* Signs a transaction with the wallet's private key.
|
@@ -7012,7 +7407,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
7012
7407
|
const chainId = await this.provider.getChainId();
|
7013
7408
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
7014
7409
|
const signature = await this.signer().sign(hashedTransaction);
|
7015
|
-
return
|
7410
|
+
return hexlify22(signature);
|
7016
7411
|
}
|
7017
7412
|
/**
|
7018
7413
|
* Populates a transaction with the witnesses signature.
|
@@ -7084,16 +7479,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
7084
7479
|
|
7085
7480
|
// src/hdwallet/hdwallet.ts
|
7086
7481
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
7087
|
-
import { ErrorCode as ErrorCode22, FuelError as
|
7482
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError26 } from "@fuel-ts/errors";
|
7088
7483
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
7089
|
-
import { bn as
|
7090
|
-
import { arrayify as
|
7484
|
+
import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
7485
|
+
import { arrayify as arrayify20, hexlify as hexlify24, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
7091
7486
|
|
7092
7487
|
// src/mnemonic/mnemonic.ts
|
7093
7488
|
import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
7094
|
-
import { ErrorCode as ErrorCode21, FuelError as
|
7489
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError25 } from "@fuel-ts/errors";
|
7095
7490
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
7096
|
-
import { arrayify as
|
7491
|
+
import { arrayify as arrayify19, hexlify as hexlify23, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
7097
7492
|
|
7098
7493
|
// src/wordlists/words/english.ts
|
7099
7494
|
var english = [
|
@@ -9148,9 +9543,9 @@ var english = [
|
|
9148
9543
|
];
|
9149
9544
|
|
9150
9545
|
// src/mnemonic/utils.ts
|
9151
|
-
import { ErrorCode as ErrorCode20, FuelError as
|
9546
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9152
9547
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
9153
|
-
import { arrayify as
|
9548
|
+
import { arrayify as arrayify18 } from "@fuel-ts/utils";
|
9154
9549
|
function getLowerMask(bits) {
|
9155
9550
|
return (1 << bits) - 1;
|
9156
9551
|
}
|
@@ -9185,19 +9580,19 @@ function entropyToMnemonicIndices(entropy) {
|
|
9185
9580
|
}
|
9186
9581
|
}
|
9187
9582
|
const checksumBits = entropy.length / 4;
|
9188
|
-
const checksum =
|
9583
|
+
const checksum = arrayify18(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
9189
9584
|
indices[indices.length - 1] <<= checksumBits;
|
9190
9585
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
9191
9586
|
return indices;
|
9192
9587
|
}
|
9193
9588
|
function mnemonicWordsToEntropy(words, wordlist) {
|
9194
9589
|
const size = Math.ceil(11 * words.length / 8);
|
9195
|
-
const entropy =
|
9590
|
+
const entropy = arrayify18(new Uint8Array(size));
|
9196
9591
|
let offset = 0;
|
9197
9592
|
for (let i = 0; i < words.length; i += 1) {
|
9198
9593
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
9199
9594
|
if (index === -1) {
|
9200
|
-
throw new
|
9595
|
+
throw new FuelError24(
|
9201
9596
|
ErrorCode20.INVALID_MNEMONIC,
|
9202
9597
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
9203
9598
|
);
|
@@ -9212,9 +9607,9 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9212
9607
|
const entropyBits = 32 * words.length / 3;
|
9213
9608
|
const checksumBits = words.length / 3;
|
9214
9609
|
const checksumMask = getUpperMask(checksumBits);
|
9215
|
-
const checksum =
|
9610
|
+
const checksum = arrayify18(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9216
9611
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9217
|
-
throw new
|
9612
|
+
throw new FuelError24(
|
9218
9613
|
ErrorCode20.INVALID_CHECKSUM,
|
9219
9614
|
"Checksum validation failed for the provided mnemonic."
|
9220
9615
|
);
|
@@ -9229,7 +9624,7 @@ var TestnetPRV = "0x04358394";
|
|
9229
9624
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
9230
9625
|
function assertWordList(wordlist) {
|
9231
9626
|
if (wordlist.length !== 2048) {
|
9232
|
-
throw new
|
9627
|
+
throw new FuelError25(
|
9233
9628
|
ErrorCode21.INVALID_WORD_LIST,
|
9234
9629
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
9235
9630
|
);
|
@@ -9237,7 +9632,7 @@ function assertWordList(wordlist) {
|
|
9237
9632
|
}
|
9238
9633
|
function assertEntropy(entropy) {
|
9239
9634
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9240
|
-
throw new
|
9635
|
+
throw new FuelError25(
|
9241
9636
|
ErrorCode21.INVALID_ENTROPY,
|
9242
9637
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
9243
9638
|
);
|
@@ -9248,7 +9643,7 @@ function assertMnemonic(words) {
|
|
9248
9643
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
9249
9644
|
", "
|
9250
9645
|
)}] words, but got ${words.length}.`;
|
9251
|
-
throw new
|
9646
|
+
throw new FuelError25(ErrorCode21.INVALID_MNEMONIC, errorMsg);
|
9252
9647
|
}
|
9253
9648
|
}
|
9254
9649
|
var Mnemonic = class {
|
@@ -9287,7 +9682,7 @@ var Mnemonic = class {
|
|
9287
9682
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
9288
9683
|
const words = getWords(phrase);
|
9289
9684
|
assertMnemonic(words);
|
9290
|
-
return
|
9685
|
+
return hexlify23(mnemonicWordsToEntropy(words, wordlist));
|
9291
9686
|
}
|
9292
9687
|
/**
|
9293
9688
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -9295,7 +9690,7 @@ var Mnemonic = class {
|
|
9295
9690
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9296
9691
|
*/
|
9297
9692
|
static entropyToMnemonic(entropy, wordlist = english) {
|
9298
|
-
const entropyBytes =
|
9693
|
+
const entropyBytes = arrayify19(entropy);
|
9299
9694
|
assertWordList(wordlist);
|
9300
9695
|
assertEntropy(entropyBytes);
|
9301
9696
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -9364,14 +9759,14 @@ var Mnemonic = class {
|
|
9364
9759
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9365
9760
|
*/
|
9366
9761
|
static masterKeysFromSeed(seed) {
|
9367
|
-
const seedArray =
|
9762
|
+
const seedArray = arrayify19(seed);
|
9368
9763
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9369
|
-
throw new
|
9764
|
+
throw new FuelError25(
|
9370
9765
|
ErrorCode21.INVALID_SEED,
|
9371
9766
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9372
9767
|
);
|
9373
9768
|
}
|
9374
|
-
return
|
9769
|
+
return arrayify19(computeHmac("sha512", MasterSecret, seedArray));
|
9375
9770
|
}
|
9376
9771
|
/**
|
9377
9772
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -9382,7 +9777,7 @@ var Mnemonic = class {
|
|
9382
9777
|
*/
|
9383
9778
|
static seedToExtendedKey(seed, testnet = false) {
|
9384
9779
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
9385
|
-
const prefix =
|
9780
|
+
const prefix = arrayify19(testnet ? TestnetPRV : MainnetPRV);
|
9386
9781
|
const depth = "0x00";
|
9387
9782
|
const fingerprint = "0x00000000";
|
9388
9783
|
const index = "0x00000000";
|
@@ -9412,7 +9807,7 @@ var Mnemonic = class {
|
|
9412
9807
|
* @returns A randomly generated mnemonic
|
9413
9808
|
*/
|
9414
9809
|
static generate(size = 32, extraEntropy = "") {
|
9415
|
-
const entropy = extraEntropy ? sha2563(concat5([randomBytes7(size),
|
9810
|
+
const entropy = extraEntropy ? sha2563(concat5([randomBytes7(size), arrayify19(extraEntropy)])) : randomBytes7(size);
|
9416
9811
|
return Mnemonic.entropyToMnemonic(entropy);
|
9417
9812
|
}
|
9418
9813
|
};
|
@@ -9420,10 +9815,10 @@ var mnemonic_default = Mnemonic;
|
|
9420
9815
|
|
9421
9816
|
// src/hdwallet/hdwallet.ts
|
9422
9817
|
var HARDENED_INDEX = 2147483648;
|
9423
|
-
var MainnetPRV2 =
|
9424
|
-
var MainnetPUB =
|
9425
|
-
var TestnetPRV2 =
|
9426
|
-
var TestnetPUB =
|
9818
|
+
var MainnetPRV2 = hexlify24("0x0488ade4");
|
9819
|
+
var MainnetPUB = hexlify24("0x0488b21e");
|
9820
|
+
var TestnetPRV2 = hexlify24("0x04358394");
|
9821
|
+
var TestnetPUB = hexlify24("0x043587cf");
|
9427
9822
|
function base58check(data) {
|
9428
9823
|
return encodeBase582(concat6([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
9429
9824
|
}
|
@@ -9434,17 +9829,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
9434
9829
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
9435
9830
|
}
|
9436
9831
|
function isPublicExtendedKey(extendedKey) {
|
9437
|
-
return [MainnetPUB, TestnetPUB].includes(
|
9832
|
+
return [MainnetPUB, TestnetPUB].includes(hexlify24(extendedKey.slice(0, 4)));
|
9438
9833
|
}
|
9439
9834
|
function isValidExtendedKey(extendedKey) {
|
9440
9835
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
9441
|
-
|
9836
|
+
hexlify24(extendedKey.slice(0, 4))
|
9442
9837
|
);
|
9443
9838
|
}
|
9444
9839
|
function parsePath(path2, depth = 0) {
|
9445
9840
|
const components = path2.split("/");
|
9446
9841
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9447
|
-
throw new
|
9842
|
+
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
9448
9843
|
}
|
9449
9844
|
if (components[0] === "m") {
|
9450
9845
|
components.shift();
|
@@ -9456,8 +9851,8 @@ function parsePath(path2, depth = 0) {
|
|
9456
9851
|
var HDWallet = class {
|
9457
9852
|
depth = 0;
|
9458
9853
|
index = 0;
|
9459
|
-
fingerprint =
|
9460
|
-
parentFingerprint =
|
9854
|
+
fingerprint = hexlify24("0x00000000");
|
9855
|
+
parentFingerprint = hexlify24("0x00000000");
|
9461
9856
|
privateKey;
|
9462
9857
|
publicKey;
|
9463
9858
|
chainCode;
|
@@ -9469,16 +9864,16 @@ var HDWallet = class {
|
|
9469
9864
|
constructor(config) {
|
9470
9865
|
if (config.privateKey) {
|
9471
9866
|
const signer = new Signer(config.privateKey);
|
9472
|
-
this.publicKey =
|
9473
|
-
this.privateKey =
|
9867
|
+
this.publicKey = hexlify24(signer.compressedPublicKey);
|
9868
|
+
this.privateKey = hexlify24(config.privateKey);
|
9474
9869
|
} else {
|
9475
9870
|
if (!config.publicKey) {
|
9476
|
-
throw new
|
9871
|
+
throw new FuelError26(
|
9477
9872
|
ErrorCode22.HD_WALLET_ERROR,
|
9478
9873
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9479
9874
|
);
|
9480
9875
|
}
|
9481
|
-
this.publicKey =
|
9876
|
+
this.publicKey = hexlify24(config.publicKey);
|
9482
9877
|
}
|
9483
9878
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
9484
9879
|
this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
|
@@ -9497,28 +9892,28 @@ var HDWallet = class {
|
|
9497
9892
|
* @returns A new instance of HDWallet on the derived index
|
9498
9893
|
*/
|
9499
9894
|
deriveIndex(index) {
|
9500
|
-
const privateKey = this.privateKey &&
|
9501
|
-
const publicKey =
|
9502
|
-
const chainCode =
|
9895
|
+
const privateKey = this.privateKey && arrayify20(this.privateKey);
|
9896
|
+
const publicKey = arrayify20(this.publicKey);
|
9897
|
+
const chainCode = arrayify20(this.chainCode);
|
9503
9898
|
const data = new Uint8Array(37);
|
9504
9899
|
if (index & HARDENED_INDEX) {
|
9505
9900
|
if (!privateKey) {
|
9506
|
-
throw new
|
9901
|
+
throw new FuelError26(
|
9507
9902
|
ErrorCode22.HD_WALLET_ERROR,
|
9508
9903
|
"Cannot derive a hardened index without a private Key."
|
9509
9904
|
);
|
9510
9905
|
}
|
9511
9906
|
data.set(privateKey, 1);
|
9512
9907
|
} else {
|
9513
|
-
data.set(
|
9908
|
+
data.set(arrayify20(this.publicKey));
|
9514
9909
|
}
|
9515
9910
|
data.set(toBytes2(index, 4), 33);
|
9516
|
-
const bytes =
|
9911
|
+
const bytes = arrayify20(computeHmac2("sha512", chainCode, data));
|
9517
9912
|
const IL = bytes.slice(0, 32);
|
9518
9913
|
const IR = bytes.slice(32);
|
9519
9914
|
if (privateKey) {
|
9520
9915
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
9521
|
-
const ki =
|
9916
|
+
const ki = bn21(IL).add(privateKey).mod(N).toBytes(32);
|
9522
9917
|
return new HDWallet({
|
9523
9918
|
privateKey: ki,
|
9524
9919
|
chainCode: IR,
|
@@ -9527,7 +9922,7 @@ var HDWallet = class {
|
|
9527
9922
|
parentFingerprint: this.fingerprint
|
9528
9923
|
});
|
9529
9924
|
}
|
9530
|
-
const signer = new Signer(
|
9925
|
+
const signer = new Signer(hexlify24(IL));
|
9531
9926
|
const Ki = signer.addPoint(publicKey);
|
9532
9927
|
return new HDWallet({
|
9533
9928
|
publicKey: Ki,
|
@@ -9556,18 +9951,18 @@ var HDWallet = class {
|
|
9556
9951
|
*/
|
9557
9952
|
toExtendedKey(isPublic = false, testnet = false) {
|
9558
9953
|
if (this.depth >= 256) {
|
9559
|
-
throw new
|
9954
|
+
throw new FuelError26(
|
9560
9955
|
ErrorCode22.HD_WALLET_ERROR,
|
9561
9956
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9562
9957
|
);
|
9563
9958
|
}
|
9564
9959
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
9565
|
-
const depth =
|
9960
|
+
const depth = hexlify24(Uint8Array.from([this.depth]));
|
9566
9961
|
const parentFingerprint = this.parentFingerprint;
|
9567
9962
|
const index = toHex(this.index, 4);
|
9568
9963
|
const chainCode = this.chainCode;
|
9569
9964
|
const key = this.privateKey != null && !isPublic ? concat6(["0x00", this.privateKey]) : this.publicKey;
|
9570
|
-
const extendedKey =
|
9965
|
+
const extendedKey = arrayify20(concat6([prefix, depth, parentFingerprint, index, chainCode, key]));
|
9571
9966
|
return base58check(extendedKey);
|
9572
9967
|
}
|
9573
9968
|
/**
|
@@ -9579,34 +9974,34 @@ var HDWallet = class {
|
|
9579
9974
|
static fromSeed(seed) {
|
9580
9975
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
9581
9976
|
return new HDWallet({
|
9582
|
-
chainCode:
|
9583
|
-
privateKey:
|
9977
|
+
chainCode: arrayify20(masterKey.slice(32)),
|
9978
|
+
privateKey: arrayify20(masterKey.slice(0, 32))
|
9584
9979
|
});
|
9585
9980
|
}
|
9586
9981
|
static fromExtendedKey(extendedKey) {
|
9587
|
-
const decoded =
|
9588
|
-
const bytes =
|
9982
|
+
const decoded = hexlify24(toBytes2(decodeBase58(extendedKey)));
|
9983
|
+
const bytes = arrayify20(decoded);
|
9589
9984
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9590
9985
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9591
|
-
throw new
|
9986
|
+
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9592
9987
|
}
|
9593
9988
|
if (!validChecksum) {
|
9594
|
-
throw new
|
9989
|
+
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9595
9990
|
}
|
9596
9991
|
const depth = bytes[4];
|
9597
|
-
const parentFingerprint =
|
9598
|
-
const index = parseInt(
|
9599
|
-
const chainCode =
|
9992
|
+
const parentFingerprint = hexlify24(bytes.slice(5, 9));
|
9993
|
+
const index = parseInt(hexlify24(bytes.slice(9, 13)).substring(2), 16);
|
9994
|
+
const chainCode = hexlify24(bytes.slice(13, 45));
|
9600
9995
|
const key = bytes.slice(45, 78);
|
9601
9996
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9602
|
-
throw new
|
9997
|
+
throw new FuelError26(
|
9603
9998
|
ErrorCode22.HD_WALLET_ERROR,
|
9604
9999
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9605
10000
|
);
|
9606
10001
|
}
|
9607
10002
|
if (isPublicExtendedKey(bytes)) {
|
9608
10003
|
if (key[0] !== 3) {
|
9609
|
-
throw new
|
10004
|
+
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, "Invalid public extended key.");
|
9610
10005
|
}
|
9611
10006
|
return new HDWallet({
|
9612
10007
|
publicKey: key,
|
@@ -9617,7 +10012,7 @@ var HDWallet = class {
|
|
9617
10012
|
});
|
9618
10013
|
}
|
9619
10014
|
if (key[0] !== 0) {
|
9620
|
-
throw new
|
10015
|
+
throw new FuelError26(ErrorCode22.HD_WALLET_ERROR, "Invalid private extended key.");
|
9621
10016
|
}
|
9622
10017
|
return new HDWallet({
|
9623
10018
|
privateKey: key.slice(1),
|
@@ -9841,13 +10236,13 @@ var WalletsConfig = class {
|
|
9841
10236
|
assetIds.forEach((assetId) => {
|
9842
10237
|
for (let index = 0; index < coinsPerAsset; index++) {
|
9843
10238
|
coins.push({
|
9844
|
-
amount:
|
10239
|
+
amount: bn22(amountPerCoin).toString(),
|
9845
10240
|
asset_id: assetId,
|
9846
10241
|
owner: walletAddress,
|
9847
10242
|
tx_pointer_block_height: 0,
|
9848
10243
|
tx_pointer_tx_idx: 0,
|
9849
10244
|
output_index: 0,
|
9850
|
-
tx_id:
|
10245
|
+
tx_id: hexlify25(randomBytes8(32))
|
9851
10246
|
});
|
9852
10247
|
}
|
9853
10248
|
});
|
@@ -9861,26 +10256,26 @@ var WalletsConfig = class {
|
|
9861
10256
|
amountPerCoin
|
9862
10257
|
}) {
|
9863
10258
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
9864
|
-
throw new
|
9865
|
-
|
10259
|
+
throw new FuelError27(
|
10260
|
+
FuelError27.CODES.INVALID_INPUT_PARAMETERS,
|
9866
10261
|
"Number of wallets must be greater than zero."
|
9867
10262
|
);
|
9868
10263
|
}
|
9869
10264
|
if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
|
9870
|
-
throw new
|
9871
|
-
|
10265
|
+
throw new FuelError27(
|
10266
|
+
FuelError27.CODES.INVALID_INPUT_PARAMETERS,
|
9872
10267
|
"Number of assets per wallet must be greater than zero."
|
9873
10268
|
);
|
9874
10269
|
}
|
9875
10270
|
if (coinsPerAsset <= 0) {
|
9876
|
-
throw new
|
9877
|
-
|
10271
|
+
throw new FuelError27(
|
10272
|
+
FuelError27.CODES.INVALID_INPUT_PARAMETERS,
|
9878
10273
|
"Number of coins per asset must be greater than zero."
|
9879
10274
|
);
|
9880
10275
|
}
|
9881
|
-
if (
|
9882
|
-
throw new
|
9883
|
-
|
10276
|
+
if (bn22(amountPerCoin).lt(0)) {
|
10277
|
+
throw new FuelError27(
|
10278
|
+
FuelError27.CODES.INVALID_INPUT_PARAMETERS,
|
9884
10279
|
"Amount per coin must be greater than or equal to zero."
|
9885
10280
|
);
|
9886
10281
|
}
|
@@ -9954,8 +10349,8 @@ async function setupTestProviderAndWallets({
|
|
9954
10349
|
// src/test-utils/test-message.ts
|
9955
10350
|
import { Address as Address7 } from "@fuel-ts/address";
|
9956
10351
|
import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
|
9957
|
-
import { bn as
|
9958
|
-
import { hexlify as
|
10352
|
+
import { bn as bn23 } from "@fuel-ts/math";
|
10353
|
+
import { hexlify as hexlify26 } from "@fuel-ts/utils";
|
9959
10354
|
var TestMessage = class {
|
9960
10355
|
sender;
|
9961
10356
|
recipient;
|
@@ -9972,7 +10367,7 @@ var TestMessage = class {
|
|
9972
10367
|
constructor({
|
9973
10368
|
sender = Address7.fromRandom(),
|
9974
10369
|
recipient = Address7.fromRandom(),
|
9975
|
-
nonce =
|
10370
|
+
nonce = hexlify26(randomBytes9(32)),
|
9976
10371
|
amount = 1e6,
|
9977
10372
|
data = "",
|
9978
10373
|
// Will default to empty data in order to be a spendable message
|
@@ -9991,7 +10386,7 @@ var TestMessage = class {
|
|
9991
10386
|
sender: this.sender.toB256(),
|
9992
10387
|
recipient: recipient?.toB256() ?? this.recipient.toB256(),
|
9993
10388
|
nonce: this.nonce,
|
9994
|
-
amount:
|
10389
|
+
amount: bn23(this.amount).toNumber(),
|
9995
10390
|
data,
|
9996
10391
|
da_height: this.da_height
|
9997
10392
|
};
|