@fuel-ts/account 0.98.0 → 0.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account.d.ts +13 -8
- package/dist/account.d.ts.map +1 -1
- package/dist/assets/asset-api.d.ts +69 -0
- package/dist/assets/asset-api.d.ts.map +1 -0
- package/dist/assets/assets.d.ts.map +1 -0
- package/dist/{providers/assets → assets}/index.d.ts +1 -0
- package/dist/assets/index.d.ts.map +1 -0
- package/dist/assets/types.d.ts.map +1 -0
- package/dist/assets/utils/fuelAssetsBaseUrl.d.ts +2 -0
- package/dist/assets/utils/fuelAssetsBaseUrl.d.ts.map +1 -0
- package/dist/assets/utils/index.d.ts.map +1 -0
- package/dist/{providers/assets → assets}/utils/network.d.ts +6 -6
- package/dist/assets/utils/network.d.ts.map +1 -0
- package/dist/assets/utils/resolveIconPaths.d.ts.map +1 -0
- package/dist/assets/utils/url.d.ts.map +1 -0
- package/dist/configs.d.ts +2 -2
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +8 -7
- 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/connectors/types/events.d.ts +1 -1
- package/dist/connectors/types/events.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.global.js +17708 -16898
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +6877 -6349
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6960 -6448
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts +1 -1
- package/dist/providers/__generated__/operations.d.ts +121 -4
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +1 -0
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/index.d.ts +0 -1
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +117 -23
- 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 +31 -3
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/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 +5 -5
- 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/wallet-config.d.ts +2 -1
- package/dist/test-utils/wallet-config.d.ts.map +1 -1
- package/dist/test-utils.global.js +4015 -3890
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +1270 -1464
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +969 -1163
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/deployScriptOrPredicate.d.ts.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 +38 -3
- package/dist/utils/predicate-script-loader-instructions.d.ts.map +1 -1
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/dist/wallet/keystore-wallet.d.ts +2 -2
- package/dist/wallet/keystore-wallet.d.ts.map +1 -1
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts +3 -2
- package/dist/wallet-manager/vaults/mnemonic-vault.d.ts.map +1 -1
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts +2 -1
- package/dist/wallet-manager/vaults/privatekey-vault.d.ts.map +1 -1
- package/dist/wallet-manager/wallet-manager.d.ts +3 -3
- package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
- package/package.json +22 -23
- package/dist/providers/assets/assets.d.ts.map +0 -1
- package/dist/providers/assets/index.d.ts.map +0 -1
- package/dist/providers/assets/types.d.ts.map +0 -1
- package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts +0 -2
- package/dist/providers/assets/utils/fuelAssetsBaseUrl.d.ts.map +0 -1
- package/dist/providers/assets/utils/index.d.ts.map +0 -1
- package/dist/providers/assets/utils/network.d.ts.map +0 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +0 -1
- package/dist/providers/assets/utils/url.d.ts.map +0 -1
- /package/dist/{providers/assets → assets}/assets.d.ts +0 -0
- /package/dist/{providers/assets → assets}/types.d.ts +0 -0
- /package/dist/{providers/assets → assets}/utils/index.d.ts +0 -0
- /package/dist/{providers/assets → assets}/utils/resolveIconPaths.d.ts +0 -0
- /package/dist/{providers/assets → assets}/utils/url.d.ts +0 -0
package/dist/test-utils.mjs
CHANGED
@@ -55,7 +55,7 @@ var Signer = class {
|
|
55
55
|
this.privateKey = hexlify(privateKeyBytes);
|
56
56
|
this.publicKey = hexlify(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
57
57
|
this.compressedPublicKey = hexlify(secp256k1.getPublicKey(privateKeyBytes, true));
|
58
|
-
this.address = Address
|
58
|
+
this.address = new Address(this.publicKey);
|
59
59
|
}
|
60
60
|
/**
|
61
61
|
* Sign data using the Signer instance
|
@@ -113,7 +113,7 @@ var Signer = class {
|
|
113
113
|
* @returns Address from signature
|
114
114
|
*/
|
115
115
|
static recoverAddress(data, signature) {
|
116
|
-
return Address
|
116
|
+
return new Address(Signer.recoverPublicKey(data, signature));
|
117
117
|
}
|
118
118
|
/**
|
119
119
|
* Generate a random privateKey
|
@@ -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,13 +416,12 @@ var addAmountToCoinQuantities = (params) => {
|
|
417
416
|
};
|
418
417
|
|
419
418
|
// src/providers/provider.ts
|
420
|
-
import { Address as Address3 } from "@fuel-ts/address";
|
419
|
+
import { Address as Address3, isB256 } from "@fuel-ts/address";
|
421
420
|
import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
|
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";
|
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";
|
@@ -1035,6 +1033,16 @@ var EstimatePredicatesDocument = gql`
|
|
1035
1033
|
}
|
1036
1034
|
}
|
1037
1035
|
${TransactionEstimatePredicatesFragmentDoc}`;
|
1036
|
+
var EstimatePredicatesAndGasPriceDocument = gql`
|
1037
|
+
query estimatePredicatesAndGasPrice($encodedTransaction: HexString!, $blockHorizon: U32!) {
|
1038
|
+
estimatePredicates(tx: $encodedTransaction) {
|
1039
|
+
...transactionEstimatePredicatesFragment
|
1040
|
+
}
|
1041
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
1042
|
+
gasPrice
|
1043
|
+
}
|
1044
|
+
}
|
1045
|
+
${TransactionEstimatePredicatesFragmentDoc}`;
|
1038
1046
|
var GetLatestBlockDocument = gql`
|
1039
1047
|
query getLatestBlock {
|
1040
1048
|
chain {
|
@@ -1150,6 +1158,13 @@ var GetBalanceDocument = gql`
|
|
1150
1158
|
}
|
1151
1159
|
}
|
1152
1160
|
`;
|
1161
|
+
var GetBalanceV2Document = gql`
|
1162
|
+
query getBalanceV2($owner: Address!, $assetId: AssetId!) {
|
1163
|
+
balance(owner: $owner, assetId: $assetId) {
|
1164
|
+
amountU128
|
1165
|
+
}
|
1166
|
+
}
|
1167
|
+
`;
|
1153
1168
|
var GetLatestGasPriceDocument = gql`
|
1154
1169
|
query getLatestGasPrice {
|
1155
1170
|
latestGasPrice {
|
@@ -1172,6 +1187,24 @@ var GetBalancesDocument = gql`
|
|
1172
1187
|
before: $before
|
1173
1188
|
first: $first
|
1174
1189
|
last: $last
|
1190
|
+
) {
|
1191
|
+
edges {
|
1192
|
+
node {
|
1193
|
+
assetId
|
1194
|
+
amount
|
1195
|
+
}
|
1196
|
+
}
|
1197
|
+
}
|
1198
|
+
}
|
1199
|
+
`;
|
1200
|
+
var GetBalancesV2Document = gql`
|
1201
|
+
query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
1202
|
+
balances(
|
1203
|
+
filter: $filter
|
1204
|
+
after: $after
|
1205
|
+
before: $before
|
1206
|
+
first: $first
|
1207
|
+
last: $last
|
1175
1208
|
) {
|
1176
1209
|
pageInfo {
|
1177
1210
|
...pageInfoFragment
|
@@ -1179,7 +1212,7 @@ var GetBalancesDocument = gql`
|
|
1179
1212
|
edges {
|
1180
1213
|
node {
|
1181
1214
|
assetId
|
1182
|
-
|
1215
|
+
amountU128
|
1183
1216
|
}
|
1184
1217
|
}
|
1185
1218
|
}
|
@@ -1206,6 +1239,13 @@ var GetMessagesDocument = gql`
|
|
1206
1239
|
}
|
1207
1240
|
${PageInfoFragmentDoc}
|
1208
1241
|
${GetMessageFragmentDoc}`;
|
1242
|
+
var DaCompressedBlockDocument = gql`
|
1243
|
+
query daCompressedBlock($height: U32!) {
|
1244
|
+
daCompressedBlock(height: $height) {
|
1245
|
+
bytes
|
1246
|
+
}
|
1247
|
+
}
|
1248
|
+
`;
|
1209
1249
|
var GetMessageProofDocument = gql`
|
1210
1250
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
1211
1251
|
messageProof(
|
@@ -1232,6 +1272,15 @@ var GetRelayedTransactionStatusDocument = gql`
|
|
1232
1272
|
}
|
1233
1273
|
}
|
1234
1274
|
${RelayedTransactionStatusFragmentDoc}`;
|
1275
|
+
var GetAssetDetailsDocument = gql`
|
1276
|
+
query getAssetDetails($assetId: AssetId!) {
|
1277
|
+
assetDetails(id: $assetId) {
|
1278
|
+
subId
|
1279
|
+
contractId
|
1280
|
+
totalSupply
|
1281
|
+
}
|
1282
|
+
}
|
1283
|
+
`;
|
1235
1284
|
var DryRunDocument = gql`
|
1236
1285
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean, $gasPrice: U64) {
|
1237
1286
|
dryRun(
|
@@ -1332,6 +1381,9 @@ function getSdk(requester) {
|
|
1332
1381
|
estimatePredicates(variables, options) {
|
1333
1382
|
return requester(EstimatePredicatesDocument, variables, options);
|
1334
1383
|
},
|
1384
|
+
estimatePredicatesAndGasPrice(variables, options) {
|
1385
|
+
return requester(EstimatePredicatesAndGasPriceDocument, variables, options);
|
1386
|
+
},
|
1335
1387
|
getLatestBlock(variables, options) {
|
1336
1388
|
return requester(GetLatestBlockDocument, variables, options);
|
1337
1389
|
},
|
@@ -1365,6 +1417,9 @@ function getSdk(requester) {
|
|
1365
1417
|
getBalance(variables, options) {
|
1366
1418
|
return requester(GetBalanceDocument, variables, options);
|
1367
1419
|
},
|
1420
|
+
getBalanceV2(variables, options) {
|
1421
|
+
return requester(GetBalanceV2Document, variables, options);
|
1422
|
+
},
|
1368
1423
|
getLatestGasPrice(variables, options) {
|
1369
1424
|
return requester(GetLatestGasPriceDocument, variables, options);
|
1370
1425
|
},
|
@@ -1374,9 +1429,15 @@ function getSdk(requester) {
|
|
1374
1429
|
getBalances(variables, options) {
|
1375
1430
|
return requester(GetBalancesDocument, variables, options);
|
1376
1431
|
},
|
1432
|
+
getBalancesV2(variables, options) {
|
1433
|
+
return requester(GetBalancesV2Document, variables, options);
|
1434
|
+
},
|
1377
1435
|
getMessages(variables, options) {
|
1378
1436
|
return requester(GetMessagesDocument, variables, options);
|
1379
1437
|
},
|
1438
|
+
daCompressedBlock(variables, options) {
|
1439
|
+
return requester(DaCompressedBlockDocument, variables, options);
|
1440
|
+
},
|
1380
1441
|
getMessageProof(variables, options) {
|
1381
1442
|
return requester(GetMessageProofDocument, variables, options);
|
1382
1443
|
},
|
@@ -1386,6 +1447,9 @@ function getSdk(requester) {
|
|
1386
1447
|
getRelayedTransactionStatus(variables, options) {
|
1387
1448
|
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
1388
1449
|
},
|
1450
|
+
getAssetDetails(variables, options) {
|
1451
|
+
return requester(GetAssetDetailsDocument, variables, options);
|
1452
|
+
},
|
1389
1453
|
dryRun(variables, options) {
|
1390
1454
|
return requester(DryRunDocument, variables, options);
|
1391
1455
|
},
|
@@ -1414,8 +1478,59 @@ function getSdk(requester) {
|
|
1414
1478
|
}
|
1415
1479
|
|
1416
1480
|
// src/providers/fuel-graphql-subscriber.ts
|
1417
|
-
import { ErrorCode, FuelError as
|
1481
|
+
import { ErrorCode as ErrorCode2, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1418
1482
|
import { print } from "graphql";
|
1483
|
+
|
1484
|
+
// src/providers/utils/handle-gql-error-message.ts
|
1485
|
+
import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
|
1486
|
+
var mapGqlErrorMessage = (error) => {
|
1487
|
+
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)) {
|
1488
|
+
return new FuelError2(
|
1489
|
+
ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
1490
|
+
`Insufficient funds or too many small value coins. Consider combining UTXOs.`,
|
1491
|
+
{},
|
1492
|
+
error
|
1493
|
+
);
|
1494
|
+
}
|
1495
|
+
if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
|
1496
|
+
return new FuelError2(
|
1497
|
+
ErrorCode.ASSET_NOT_FOUND,
|
1498
|
+
`Asset not found for given asset id.`,
|
1499
|
+
{},
|
1500
|
+
error
|
1501
|
+
);
|
1502
|
+
}
|
1503
|
+
return new FuelError2(ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1504
|
+
};
|
1505
|
+
var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
|
1506
|
+
if (!incompatibleNodeVersionMessage) {
|
1507
|
+
return error;
|
1508
|
+
}
|
1509
|
+
return new FuelError2(
|
1510
|
+
error.code,
|
1511
|
+
`${error.message}
|
1512
|
+
|
1513
|
+
${incompatibleNodeVersionMessage}`,
|
1514
|
+
error.metadata,
|
1515
|
+
error.rawError
|
1516
|
+
);
|
1517
|
+
};
|
1518
|
+
var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = false) => {
|
1519
|
+
if (!Array.isArray(errors)) {
|
1520
|
+
return;
|
1521
|
+
}
|
1522
|
+
const mappedErrors = errors.map(mapGqlErrorMessage);
|
1523
|
+
if (mappedErrors.length === 1) {
|
1524
|
+
throw mapGqlErrorWithIncompatibleNodeVersion(mappedErrors[0], incompatibleNodeVersionMessage);
|
1525
|
+
}
|
1526
|
+
const errorMessage = mappedErrors.map((err) => err.message).join("\n");
|
1527
|
+
throw mapGqlErrorWithIncompatibleNodeVersion(
|
1528
|
+
new FuelError2(ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
1529
|
+
incompatibleNodeVersionMessage
|
1530
|
+
);
|
1531
|
+
};
|
1532
|
+
|
1533
|
+
// src/providers/fuel-graphql-subscriber.ts
|
1419
1534
|
var _FuelGraphqlSubscriber = class {
|
1420
1535
|
constructor(stream) {
|
1421
1536
|
this.stream = stream;
|
@@ -1443,12 +1558,7 @@ var _FuelGraphqlSubscriber = class {
|
|
1443
1558
|
while (true) {
|
1444
1559
|
if (this.events.length > 0) {
|
1445
1560
|
const { data, errors } = this.events.shift();
|
1446
|
-
|
1447
|
-
throw new FuelError2(
|
1448
|
-
FuelError2.CODES.INVALID_REQUEST,
|
1449
|
-
errors.map((err) => err.message).join("\n\n")
|
1450
|
-
);
|
1451
|
-
}
|
1561
|
+
assertGqlResponseHasNoErrors(errors, _FuelGraphqlSubscriber.incompatibleNodeVersionMessage);
|
1452
1562
|
return { value: data, done: false };
|
1453
1563
|
}
|
1454
1564
|
const { value, done } = await this.stream.read();
|
@@ -1466,8 +1576,8 @@ var _FuelGraphqlSubscriber = class {
|
|
1466
1576
|
try {
|
1467
1577
|
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
1468
1578
|
} catch (e) {
|
1469
|
-
throw new
|
1470
|
-
|
1579
|
+
throw new FuelError3(
|
1580
|
+
ErrorCode2.STREAM_PARSING_ERROR,
|
1471
1581
|
`Error while parsing stream data response: ${text}`
|
1472
1582
|
);
|
1473
1583
|
}
|
@@ -1486,69 +1596,12 @@ var _FuelGraphqlSubscriber = class {
|
|
1486
1596
|
}
|
1487
1597
|
};
|
1488
1598
|
var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
|
1599
|
+
__publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
|
1489
1600
|
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1490
1601
|
|
1491
1602
|
// src/providers/resource-cache.ts
|
1492
|
-
import {
|
1493
|
-
import { hexlify as
|
1494
|
-
var cache = /* @__PURE__ */ new Map();
|
1495
|
-
var ResourceCache = class {
|
1496
|
-
ttl;
|
1497
|
-
constructor(ttl) {
|
1498
|
-
this.ttl = ttl;
|
1499
|
-
if (typeof ttl !== "number" || this.ttl <= 0) {
|
1500
|
-
throw new FuelError3(
|
1501
|
-
ErrorCode2.INVALID_TTL,
|
1502
|
-
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
1503
|
-
);
|
1504
|
-
}
|
1505
|
-
}
|
1506
|
-
// Add resources to the cache
|
1507
|
-
set(transactionId, resources) {
|
1508
|
-
const currentTime = Date.now();
|
1509
|
-
const existingResources = cache.get(transactionId) || {
|
1510
|
-
utxos: /* @__PURE__ */ new Set(),
|
1511
|
-
messages: /* @__PURE__ */ new Set(),
|
1512
|
-
timestamp: currentTime
|
1513
|
-
};
|
1514
|
-
resources.utxos.forEach((utxo) => existingResources.utxos.add(hexlify4(utxo)));
|
1515
|
-
resources.messages.forEach((message) => existingResources.messages.add(hexlify4(message)));
|
1516
|
-
cache.set(transactionId, existingResources);
|
1517
|
-
}
|
1518
|
-
// Remove resources from the cache for a given transaction ID
|
1519
|
-
unset(transactionId) {
|
1520
|
-
cache.delete(transactionId);
|
1521
|
-
}
|
1522
|
-
// Get all cached resources and remove expired ones
|
1523
|
-
getActiveData() {
|
1524
|
-
const allResources = { utxos: [], messages: [] };
|
1525
|
-
const currentTime = Date.now();
|
1526
|
-
cache.forEach((resource, transactionId) => {
|
1527
|
-
if (currentTime - resource.timestamp < this.ttl) {
|
1528
|
-
allResources.utxos.push(...resource.utxos);
|
1529
|
-
allResources.messages.push(...resource.messages);
|
1530
|
-
} else {
|
1531
|
-
cache.delete(transactionId);
|
1532
|
-
}
|
1533
|
-
});
|
1534
|
-
return allResources;
|
1535
|
-
}
|
1536
|
-
// Check if a UTXO ID or message nonce is already cached and not expired
|
1537
|
-
isCached(key) {
|
1538
|
-
const currentTime = Date.now();
|
1539
|
-
for (const [transactionId, resourceData] of cache.entries()) {
|
1540
|
-
if (currentTime - resourceData.timestamp > this.ttl) {
|
1541
|
-
cache.delete(transactionId);
|
1542
|
-
} else if (resourceData.utxos.has(key) || resourceData.messages.has(key)) {
|
1543
|
-
return true;
|
1544
|
-
}
|
1545
|
-
}
|
1546
|
-
return false;
|
1547
|
-
}
|
1548
|
-
clear() {
|
1549
|
-
cache.clear();
|
1550
|
-
}
|
1551
|
-
};
|
1603
|
+
import { FuelError as FuelError13, ErrorCode as ErrorCode10 } from "@fuel-ts/errors";
|
1604
|
+
import { hexlify as hexlify16 } from "@fuel-ts/utils";
|
1552
1605
|
|
1553
1606
|
// src/providers/transaction-request/input.ts
|
1554
1607
|
import { BYTES_32 as BYTES_322, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
|
@@ -1556,7 +1609,7 @@ import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
|
1556
1609
|
import { ErrorCode as ErrorCode3, FuelError as FuelError4 } from "@fuel-ts/errors";
|
1557
1610
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1558
1611
|
import { InputType } from "@fuel-ts/transactions";
|
1559
|
-
import { arrayify as arrayify2, hexlify as
|
1612
|
+
import { arrayify as arrayify2, hexlify as hexlify4 } from "@fuel-ts/utils";
|
1560
1613
|
var inputify = (value) => {
|
1561
1614
|
const { type } = value;
|
1562
1615
|
switch (value.type) {
|
@@ -1565,11 +1618,11 @@ var inputify = (value) => {
|
|
1565
1618
|
const predicateData = arrayify2(value.predicateData ?? "0x");
|
1566
1619
|
return {
|
1567
1620
|
type: InputType.Coin,
|
1568
|
-
txID:
|
1621
|
+
txID: hexlify4(arrayify2(value.id).slice(0, BYTES_322)),
|
1569
1622
|
outputIndex: toNumber(arrayify2(value.id).slice(BYTES_322, UTXO_ID_LEN)),
|
1570
|
-
owner:
|
1623
|
+
owner: hexlify4(value.owner),
|
1571
1624
|
amount: bn2(value.amount),
|
1572
|
-
assetId:
|
1625
|
+
assetId: hexlify4(value.assetId),
|
1573
1626
|
txPointer: {
|
1574
1627
|
blockHeight: toNumber(arrayify2(value.txPointer).slice(0, 8)),
|
1575
1628
|
txIndex: toNumber(arrayify2(value.txPointer).slice(8, 16))
|
@@ -1578,8 +1631,8 @@ var inputify = (value) => {
|
|
1578
1631
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1579
1632
|
predicateLength: bn2(predicate.length),
|
1580
1633
|
predicateDataLength: bn2(predicateData.length),
|
1581
|
-
predicate:
|
1582
|
-
predicateData:
|
1634
|
+
predicate: hexlify4(predicate),
|
1635
|
+
predicateData: hexlify4(predicateData)
|
1583
1636
|
};
|
1584
1637
|
}
|
1585
1638
|
case InputType.Contract: {
|
@@ -1593,7 +1646,7 @@ var inputify = (value) => {
|
|
1593
1646
|
blockHeight: toNumber(arrayify2(value.txPointer).slice(0, 8)),
|
1594
1647
|
txIndex: toNumber(arrayify2(value.txPointer).slice(8, 16))
|
1595
1648
|
},
|
1596
|
-
contractID:
|
1649
|
+
contractID: hexlify4(value.contractId)
|
1597
1650
|
};
|
1598
1651
|
}
|
1599
1652
|
case InputType.Message: {
|
@@ -1602,17 +1655,17 @@ var inputify = (value) => {
|
|
1602
1655
|
const data = arrayify2(value.data ?? "0x");
|
1603
1656
|
return {
|
1604
1657
|
type: InputType.Message,
|
1605
|
-
sender:
|
1606
|
-
recipient:
|
1658
|
+
sender: hexlify4(value.sender),
|
1659
|
+
recipient: hexlify4(value.recipient),
|
1607
1660
|
amount: bn2(value.amount),
|
1608
|
-
nonce:
|
1661
|
+
nonce: hexlify4(value.nonce),
|
1609
1662
|
witnessIndex: value.witnessIndex,
|
1610
1663
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1611
1664
|
predicateLength: bn2(predicate.length),
|
1612
1665
|
predicateDataLength: bn2(predicateData.length),
|
1613
|
-
predicate:
|
1614
|
-
predicateData:
|
1615
|
-
data:
|
1666
|
+
predicate: hexlify4(predicate),
|
1667
|
+
predicateData: hexlify4(predicateData),
|
1668
|
+
data: hexlify4(data),
|
1616
1669
|
dataLength: data.length
|
1617
1670
|
};
|
1618
1671
|
}
|
@@ -1630,16 +1683,16 @@ import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
|
1630
1683
|
import { ErrorCode as ErrorCode4, FuelError as FuelError5 } from "@fuel-ts/errors";
|
1631
1684
|
import { bn as bn3 } from "@fuel-ts/math";
|
1632
1685
|
import { OutputType } from "@fuel-ts/transactions";
|
1633
|
-
import { hexlify as
|
1686
|
+
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
1634
1687
|
var outputify = (value) => {
|
1635
1688
|
const { type } = value;
|
1636
1689
|
switch (type) {
|
1637
1690
|
case OutputType.Coin: {
|
1638
1691
|
return {
|
1639
1692
|
type: OutputType.Coin,
|
1640
|
-
to:
|
1693
|
+
to: hexlify5(value.to),
|
1641
1694
|
amount: bn3(value.amount),
|
1642
|
-
assetId:
|
1695
|
+
assetId: hexlify5(value.assetId)
|
1643
1696
|
};
|
1644
1697
|
}
|
1645
1698
|
case OutputType.Contract: {
|
@@ -1653,9 +1706,9 @@ var outputify = (value) => {
|
|
1653
1706
|
case OutputType.Change: {
|
1654
1707
|
return {
|
1655
1708
|
type: OutputType.Change,
|
1656
|
-
to:
|
1709
|
+
to: hexlify5(value.to),
|
1657
1710
|
amount: bn3(0),
|
1658
|
-
assetId:
|
1711
|
+
assetId: hexlify5(value.assetId)
|
1659
1712
|
};
|
1660
1713
|
}
|
1661
1714
|
case OutputType.Variable: {
|
@@ -1669,8 +1722,8 @@ var outputify = (value) => {
|
|
1669
1722
|
case OutputType.ContractCreated: {
|
1670
1723
|
return {
|
1671
1724
|
type: OutputType.ContractCreated,
|
1672
|
-
contractId:
|
1673
|
-
stateRoot:
|
1725
|
+
contractId: hexlify5(value.contractId),
|
1726
|
+
stateRoot: hexlify5(value.stateRoot)
|
1674
1727
|
};
|
1675
1728
|
}
|
1676
1729
|
default: {
|
@@ -1705,31 +1758,157 @@ var isMessageCoin = (message) => !("data" in message);
|
|
1705
1758
|
var isCoin = (resource) => "id" in resource;
|
1706
1759
|
|
1707
1760
|
// src/providers/utils/receipts.ts
|
1761
|
+
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
1762
|
+
import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
|
1763
|
+
|
1764
|
+
// src/providers/utils/serialization.ts
|
1708
1765
|
import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
|
1709
1766
|
import { ErrorCode as ErrorCode5, FuelError as FuelError6 } from "@fuel-ts/errors";
|
1710
1767
|
import { bn as bn4 } from "@fuel-ts/math";
|
1711
1768
|
import { getMintedAssetId, InputMessageCoder, ReceiptType } from "@fuel-ts/transactions";
|
1712
|
-
import {
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1769
|
+
import { hexlify as hexlify6, arrayify as arrayify3 } from "@fuel-ts/utils";
|
1770
|
+
var deserializeChain = (chain) => {
|
1771
|
+
const { name, daHeight, consensusParameters } = chain;
|
1772
|
+
const {
|
1773
|
+
contractParams,
|
1774
|
+
feeParams,
|
1775
|
+
predicateParams,
|
1776
|
+
scriptParams,
|
1777
|
+
txParams,
|
1778
|
+
gasCosts,
|
1779
|
+
baseAssetId,
|
1780
|
+
chainId,
|
1781
|
+
version
|
1782
|
+
} = consensusParameters;
|
1783
|
+
return {
|
1784
|
+
name,
|
1785
|
+
baseChainHeight: bn4(daHeight),
|
1786
|
+
consensusParameters: {
|
1787
|
+
version,
|
1788
|
+
chainId: bn4(chainId),
|
1789
|
+
baseAssetId,
|
1790
|
+
feeParameters: {
|
1791
|
+
version: feeParams.version,
|
1792
|
+
gasPerByte: bn4(feeParams.gasPerByte),
|
1793
|
+
gasPriceFactor: bn4(feeParams.gasPriceFactor)
|
1794
|
+
},
|
1795
|
+
contractParameters: {
|
1796
|
+
version: contractParams.version,
|
1797
|
+
contractMaxSize: bn4(contractParams.contractMaxSize),
|
1798
|
+
maxStorageSlots: bn4(contractParams.maxStorageSlots)
|
1799
|
+
},
|
1800
|
+
txParameters: {
|
1801
|
+
version: txParams.version,
|
1802
|
+
maxInputs: bn4(txParams.maxInputs),
|
1803
|
+
maxOutputs: bn4(txParams.maxOutputs),
|
1804
|
+
maxWitnesses: bn4(txParams.maxWitnesses),
|
1805
|
+
maxGasPerTx: bn4(txParams.maxGasPerTx),
|
1806
|
+
maxSize: bn4(txParams.maxSize),
|
1807
|
+
maxBytecodeSubsections: bn4(txParams.maxBytecodeSubsections)
|
1808
|
+
},
|
1809
|
+
predicateParameters: {
|
1810
|
+
version: predicateParams.version,
|
1811
|
+
maxPredicateLength: bn4(predicateParams.maxPredicateLength),
|
1812
|
+
maxPredicateDataLength: bn4(predicateParams.maxPredicateDataLength),
|
1813
|
+
maxGasPerPredicate: bn4(predicateParams.maxGasPerPredicate),
|
1814
|
+
maxMessageDataLength: bn4(predicateParams.maxMessageDataLength)
|
1815
|
+
},
|
1816
|
+
scriptParameters: {
|
1817
|
+
version: scriptParams.version,
|
1818
|
+
maxScriptLength: bn4(scriptParams.maxScriptLength),
|
1819
|
+
maxScriptDataLength: bn4(scriptParams.maxScriptDataLength)
|
1820
|
+
},
|
1821
|
+
gasCosts
|
1720
1822
|
}
|
1721
|
-
|
1722
|
-
|
1823
|
+
};
|
1824
|
+
};
|
1825
|
+
var serializeChain = (chain) => {
|
1826
|
+
const { name, baseChainHeight, consensusParameters } = chain;
|
1827
|
+
const {
|
1828
|
+
contractParameters,
|
1829
|
+
feeParameters,
|
1830
|
+
predicateParameters,
|
1831
|
+
scriptParameters,
|
1832
|
+
txParameters,
|
1833
|
+
gasCosts,
|
1834
|
+
baseAssetId,
|
1835
|
+
chainId,
|
1836
|
+
version
|
1837
|
+
} = consensusParameters;
|
1838
|
+
return {
|
1839
|
+
name,
|
1840
|
+
daHeight: baseChainHeight.toString(),
|
1841
|
+
consensusParameters: {
|
1842
|
+
version,
|
1843
|
+
chainId: chainId.toString(),
|
1844
|
+
baseAssetId,
|
1845
|
+
feeParams: {
|
1846
|
+
version: feeParameters.version,
|
1847
|
+
gasPerByte: feeParameters.gasPerByte.toString(),
|
1848
|
+
gasPriceFactor: feeParameters.gasPriceFactor.toString()
|
1849
|
+
},
|
1850
|
+
contractParams: {
|
1851
|
+
version: contractParameters.version,
|
1852
|
+
contractMaxSize: contractParameters.contractMaxSize.toString(),
|
1853
|
+
maxStorageSlots: contractParameters.maxStorageSlots.toString()
|
1854
|
+
},
|
1855
|
+
txParams: {
|
1856
|
+
version: txParameters.version,
|
1857
|
+
maxInputs: txParameters.maxInputs.toString(),
|
1858
|
+
maxOutputs: txParameters.maxOutputs.toString(),
|
1859
|
+
maxWitnesses: txParameters.maxWitnesses.toString(),
|
1860
|
+
maxGasPerTx: txParameters.maxGasPerTx.toString(),
|
1861
|
+
maxSize: txParameters.maxSize.toString(),
|
1862
|
+
maxBytecodeSubsections: txParameters.maxBytecodeSubsections.toString()
|
1863
|
+
},
|
1864
|
+
predicateParams: {
|
1865
|
+
version: predicateParameters.version,
|
1866
|
+
maxPredicateLength: predicateParameters.maxPredicateLength.toString(),
|
1867
|
+
maxPredicateDataLength: predicateParameters.maxPredicateDataLength.toString(),
|
1868
|
+
maxGasPerPredicate: predicateParameters.maxGasPerPredicate.toString(),
|
1869
|
+
maxMessageDataLength: predicateParameters.maxMessageDataLength.toString()
|
1870
|
+
},
|
1871
|
+
scriptParams: {
|
1872
|
+
version: scriptParameters.version,
|
1873
|
+
maxScriptLength: scriptParameters.maxScriptLength.toString(),
|
1874
|
+
maxScriptDataLength: scriptParameters.maxScriptDataLength.toString()
|
1875
|
+
},
|
1876
|
+
gasCosts
|
1723
1877
|
}
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
)
|
1878
|
+
};
|
1879
|
+
};
|
1880
|
+
var deserializeNodeInfo = (nodeInfo) => {
|
1881
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
1882
|
+
return {
|
1883
|
+
maxDepth: bn4(maxDepth),
|
1884
|
+
maxTx: bn4(maxTx),
|
1885
|
+
nodeVersion,
|
1886
|
+
utxoValidation,
|
1887
|
+
vmBacktrace
|
1888
|
+
};
|
1889
|
+
};
|
1890
|
+
var serializeNodeInfo = (nodeInfo) => {
|
1891
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
1892
|
+
return {
|
1893
|
+
maxDepth: maxDepth.toString(),
|
1894
|
+
maxTx: maxTx.toString(),
|
1895
|
+
nodeVersion,
|
1896
|
+
utxoValidation,
|
1897
|
+
vmBacktrace
|
1898
|
+
};
|
1899
|
+
};
|
1900
|
+
var deserializeProviderCache = (cache2) => ({
|
1901
|
+
consensusParametersTimestamp: cache2.consensusParametersTimestamp,
|
1902
|
+
chain: deserializeChain(cache2.chain),
|
1903
|
+
nodeInfo: deserializeNodeInfo(cache2.nodeInfo)
|
1904
|
+
});
|
1905
|
+
var serializeProviderCache = async (provider) => ({
|
1906
|
+
consensusParametersTimestamp: provider.consensusParametersTimestamp,
|
1907
|
+
chain: serializeChain(await provider.getChain()),
|
1908
|
+
nodeInfo: serializeNodeInfo(await provider.getNode())
|
1909
|
+
});
|
1731
1910
|
var hexOrZero = (hex) => hex || ZeroBytes323;
|
1732
|
-
|
1911
|
+
var deserializeReceipt = (receipt) => {
|
1733
1912
|
const { receiptType } = receipt;
|
1734
1913
|
switch (receiptType) {
|
1735
1914
|
case "CALL" /* Call */: {
|
@@ -1873,7 +2052,7 @@ function assembleReceiptByType(receipt) {
|
|
1873
2052
|
recipient,
|
1874
2053
|
nonce,
|
1875
2054
|
amount,
|
1876
|
-
data:
|
2055
|
+
data: hexlify6(data)
|
1877
2056
|
});
|
1878
2057
|
const receiptMessageOut = {
|
1879
2058
|
type: ReceiptType.MessageOut,
|
@@ -1921,18 +2100,37 @@ function assembleReceiptByType(receipt) {
|
|
1921
2100
|
default:
|
1922
2101
|
throw new FuelError6(ErrorCode5.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
1923
2102
|
}
|
1924
|
-
}
|
2103
|
+
};
|
2104
|
+
|
2105
|
+
// src/providers/utils/receipts.ts
|
2106
|
+
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType2.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
2107
|
+
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType2.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
2108
|
+
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
2109
|
+
(memo, receipt) => {
|
2110
|
+
if (doesReceiptHaveMissingOutputVariables(receipt)) {
|
2111
|
+
memo.missingOutputVariables.push(receipt);
|
2112
|
+
}
|
2113
|
+
if (doesReceiptHaveMissingContractId(receipt)) {
|
2114
|
+
memo.missingOutputContractIds.push(receipt);
|
2115
|
+
}
|
2116
|
+
return memo;
|
2117
|
+
},
|
2118
|
+
{
|
2119
|
+
missingOutputVariables: [],
|
2120
|
+
missingOutputContractIds: []
|
2121
|
+
}
|
2122
|
+
);
|
1925
2123
|
|
1926
2124
|
// src/providers/utils/block-explorer.ts
|
1927
2125
|
import { ErrorCode as ErrorCode6, FuelError as FuelError7 } from "@fuel-ts/errors";
|
1928
2126
|
|
1929
2127
|
// src/providers/utils/gas.ts
|
1930
2128
|
import { bn as bn5 } from "@fuel-ts/math";
|
1931
|
-
import { ReceiptType as
|
2129
|
+
import { ReceiptType as ReceiptType3 } from "@fuel-ts/transactions";
|
1932
2130
|
import { arrayify as arrayify4 } from "@fuel-ts/utils";
|
1933
2131
|
var getGasUsedFromReceipts = (receipts) => {
|
1934
2132
|
const scriptResult = receipts.filter(
|
1935
|
-
(receipt) => receipt.type ===
|
2133
|
+
(receipt) => receipt.type === ReceiptType3.ScriptResult
|
1936
2134
|
);
|
1937
2135
|
const gasUsed = scriptResult.reduce((prev, receipt) => prev.add(receipt.gasUsed), bn5(0));
|
1938
2136
|
return gasUsed;
|
@@ -2065,13 +2263,13 @@ var calculateGasFee = (params) => {
|
|
2065
2263
|
};
|
2066
2264
|
|
2067
2265
|
// src/providers/utils/json.ts
|
2068
|
-
import { hexlify as
|
2266
|
+
import { hexlify as hexlify7 } from "@fuel-ts/utils";
|
2069
2267
|
import { clone } from "ramda";
|
2070
2268
|
function normalize(object) {
|
2071
2269
|
Object.keys(object).forEach((key) => {
|
2072
2270
|
switch (object[key]?.constructor.name) {
|
2073
2271
|
case "Uint8Array":
|
2074
|
-
object[key] =
|
2272
|
+
object[key] = hexlify7(object[key]);
|
2075
2273
|
break;
|
2076
2274
|
case "Array":
|
2077
2275
|
object[key] = normalize(object[key]);
|
@@ -2098,7 +2296,7 @@ function normalizeJSON(root) {
|
|
2098
2296
|
// src/providers/utils/extract-tx-error.ts
|
2099
2297
|
import { ErrorCode as ErrorCode7, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2100
2298
|
import { bn as bn6 } from "@fuel-ts/math";
|
2101
|
-
import { ReceiptType as
|
2299
|
+
import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
|
2102
2300
|
import {
|
2103
2301
|
FAILED_REQUIRE_SIGNAL,
|
2104
2302
|
FAILED_ASSERT_EQ_SIGNAL,
|
@@ -2125,7 +2323,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
2125
2323
|
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
2126
2324
|
var assembleRevertError = (receipts, logs, metadata) => {
|
2127
2325
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
2128
|
-
const revertReceipt = receipts.find(({ type }) => type ===
|
2326
|
+
const revertReceipt = receipts.find(({ type }) => type === ReceiptType4.Revert);
|
2129
2327
|
let reason = "";
|
2130
2328
|
if (revertReceipt) {
|
2131
2329
|
const reasonHex = bn6(revertReceipt.val).toHex();
|
@@ -2138,15 +2336,15 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2138
2336
|
break;
|
2139
2337
|
}
|
2140
2338
|
case FAILED_ASSERT_EQ_SIGNAL: {
|
2141
|
-
const
|
2339
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
|
2142
2340
|
reason = "assert_eq";
|
2143
|
-
errorMessage = `The transaction reverted because of an "assert_eq" statement${
|
2341
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
|
2144
2342
|
break;
|
2145
2343
|
}
|
2146
2344
|
case FAILED_ASSERT_NE_SIGNAL: {
|
2147
|
-
const
|
2345
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
2148
2346
|
reason = "assert_ne";
|
2149
|
-
errorMessage = `The transaction reverted because of an "assert_ne" statement${
|
2347
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
|
2150
2348
|
break;
|
2151
2349
|
}
|
2152
2350
|
case FAILED_ASSERT_SIGNAL:
|
@@ -2154,8 +2352,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2154
2352
|
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
2155
2353
|
break;
|
2156
2354
|
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
|
2157
|
-
reason = "
|
2158
|
-
errorMessage = `The transaction reverted because it's missing an "
|
2355
|
+
reason = "MissingOutputVariable";
|
2356
|
+
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
2159
2357
|
break;
|
2160
2358
|
default:
|
2161
2359
|
throw new FuelError8(
|
@@ -2175,8 +2373,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2175
2373
|
};
|
2176
2374
|
var extractTxError = (params) => {
|
2177
2375
|
const { receipts, statusReason, logs } = params;
|
2178
|
-
const isPanic = receipts.some(({ type }) => type ===
|
2179
|
-
const isRevert = receipts.some(({ type }) => type ===
|
2376
|
+
const isPanic = receipts.some(({ type }) => type === ReceiptType4.Panic);
|
2377
|
+
const isRevert = receipts.some(({ type }) => type === ReceiptType4.Revert);
|
2180
2378
|
const metadata = {
|
2181
2379
|
logs,
|
2182
2380
|
receipts,
|
@@ -2204,6 +2402,7 @@ var NoWitnessAtIndexError = class extends Error {
|
|
2204
2402
|
import { ErrorCode as ErrorCode8, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2205
2403
|
import { bn as bn7 } from "@fuel-ts/math";
|
2206
2404
|
import { InputType as InputType2, OutputType as OutputType2 } from "@fuel-ts/transactions";
|
2405
|
+
import { hexlify as hexlify8 } from "@fuel-ts/utils";
|
2207
2406
|
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
2208
2407
|
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
2209
2408
|
var isRequestInputMessageWithoutData = (input) => input.type === InputType2.Message && bn7(input.data).isZero();
|
@@ -2211,6 +2410,7 @@ var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequ
|
|
2211
2410
|
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
|
2212
2411
|
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
2213
2412
|
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
2413
|
+
var isPredicate = (input) => isRequestInputCoinOrMessage(input) && !!input.predicate && hexlify8(input.predicate) !== "0x";
|
2214
2414
|
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
2215
2415
|
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
2216
2416
|
return acc.add(input.amount);
|
@@ -2277,6 +2477,8 @@ var BaseTransactionRequest = class {
|
|
2277
2477
|
tip;
|
2278
2478
|
/** Block until which tx cannot be included */
|
2279
2479
|
maturity;
|
2480
|
+
/** The block number after which the transaction is no longer valid. */
|
2481
|
+
expiration;
|
2280
2482
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
2281
2483
|
maxFee;
|
2282
2484
|
/** The maximum amount of witness data allowed for the transaction */
|
@@ -2287,6 +2489,12 @@ var BaseTransactionRequest = class {
|
|
2287
2489
|
outputs = [];
|
2288
2490
|
/** List of witnesses */
|
2289
2491
|
witnesses = [];
|
2492
|
+
/**
|
2493
|
+
* @hidden
|
2494
|
+
*
|
2495
|
+
* The current status of the transaction
|
2496
|
+
*/
|
2497
|
+
flag = { state: void 0, transactionId: void 0, summary: void 0 };
|
2290
2498
|
/**
|
2291
2499
|
* Constructor for initializing a base transaction request.
|
2292
2500
|
*
|
@@ -2295,6 +2503,7 @@ var BaseTransactionRequest = class {
|
|
2295
2503
|
constructor({
|
2296
2504
|
tip,
|
2297
2505
|
maturity,
|
2506
|
+
expiration,
|
2298
2507
|
maxFee,
|
2299
2508
|
witnessLimit,
|
2300
2509
|
inputs,
|
@@ -2303,6 +2512,7 @@ var BaseTransactionRequest = class {
|
|
2303
2512
|
} = {}) {
|
2304
2513
|
this.tip = tip ? bn8(tip) : void 0;
|
2305
2514
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
2515
|
+
this.expiration = expiration && expiration > 0 ? expiration : void 0;
|
2306
2516
|
this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
|
2307
2517
|
this.maxFee = bn8(maxFee);
|
2308
2518
|
this.inputs = inputs ?? [];
|
@@ -2312,7 +2522,7 @@ var BaseTransactionRequest = class {
|
|
2312
2522
|
static getPolicyMeta(req) {
|
2313
2523
|
let policyTypes = 0;
|
2314
2524
|
const policies = [];
|
2315
|
-
const { tip, witnessLimit, maturity } = req;
|
2525
|
+
const { tip, witnessLimit, maturity, expiration } = req;
|
2316
2526
|
if (bn8(tip).gt(0)) {
|
2317
2527
|
policyTypes += PolicyType.Tip;
|
2318
2528
|
policies.push({ data: bn8(tip), type: PolicyType.Tip });
|
@@ -2327,6 +2537,10 @@ var BaseTransactionRequest = class {
|
|
2327
2537
|
}
|
2328
2538
|
policyTypes += PolicyType.MaxFee;
|
2329
2539
|
policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
|
2540
|
+
if (expiration && expiration > 0) {
|
2541
|
+
policyTypes += PolicyType.Expiration;
|
2542
|
+
policies.push({ data: expiration, type: PolicyType.Expiration });
|
2543
|
+
}
|
2330
2544
|
return {
|
2331
2545
|
policyTypes,
|
2332
2546
|
policies
|
@@ -2399,8 +2613,7 @@ var BaseTransactionRequest = class {
|
|
2399
2613
|
* @returns The index of the created witness.
|
2400
2614
|
*/
|
2401
2615
|
addEmptyWitness() {
|
2402
|
-
this.addWitness(concat2([ZeroBytes324, ZeroBytes324]));
|
2403
|
-
return this.witnesses.length - 1;
|
2616
|
+
return this.addWitness(concat2([ZeroBytes324, ZeroBytes324]));
|
2404
2617
|
}
|
2405
2618
|
/**
|
2406
2619
|
* Updates the witness for a given owner and signature.
|
@@ -2409,7 +2622,7 @@ var BaseTransactionRequest = class {
|
|
2409
2622
|
* @param signature - The signature to update the witness with.
|
2410
2623
|
*/
|
2411
2624
|
updateWitnessByOwner(address, signature) {
|
2412
|
-
const ownerAddress = Address2
|
2625
|
+
const ownerAddress = new Address2(address);
|
2413
2626
|
const witnessIndex = this.getCoinInputWitnessIndexByOwner(ownerAddress);
|
2414
2627
|
if (typeof witnessIndex === "number") {
|
2415
2628
|
this.updateWitness(witnessIndex, signature);
|
@@ -2760,7 +2973,7 @@ var BaseTransactionRequest = class {
|
|
2760
2973
|
this.inputs.filter(isRequestInputResource).forEach((i) => {
|
2761
2974
|
const owner = getRequestInputResourceOwner(i);
|
2762
2975
|
const correspondingInput = inputsToExtractGasUsed.find(
|
2763
|
-
(x) => isRequestInputResourceFromOwner(x, Address2
|
2976
|
+
(x) => isRequestInputResourceFromOwner(x, new Address2(String(owner)))
|
2764
2977
|
);
|
2765
2978
|
if (correspondingInput && "predicateGasUsed" in correspondingInput && bn8(correspondingInput.predicateGasUsed).gt(0)) {
|
2766
2979
|
i.predicateGasUsed = correspondingInput.predicateGasUsed;
|
@@ -2770,6 +2983,21 @@ var BaseTransactionRequest = class {
|
|
2770
2983
|
byteLength() {
|
2771
2984
|
return this.toTransactionBytes().byteLength;
|
2772
2985
|
}
|
2986
|
+
/**
|
2987
|
+
* @hidden
|
2988
|
+
*
|
2989
|
+
* Used internally to update the state of a transaction request.
|
2990
|
+
*
|
2991
|
+
* @param state - The state to update.
|
2992
|
+
*/
|
2993
|
+
updateState(chainId, state, summary) {
|
2994
|
+
if (!state) {
|
2995
|
+
this.flag = { state: void 0, transactionId: void 0, summary: void 0 };
|
2996
|
+
return;
|
2997
|
+
}
|
2998
|
+
const transactionId = this.getTransactionId(chainId);
|
2999
|
+
this.flag = { state, transactionId, summary };
|
3000
|
+
}
|
2773
3001
|
};
|
2774
3002
|
|
2775
3003
|
// src/providers/transaction-request/blob-transaction-request.ts
|
@@ -3545,39 +3773,130 @@ var transactionRequestify = (obj) => {
|
|
3545
3773
|
var isTransactionTypeScript = (request) => request.type === TransactionType7.Script;
|
3546
3774
|
var isTransactionTypeCreate = (request) => request.type === TransactionType7.Create;
|
3547
3775
|
|
3548
|
-
// src/providers/
|
3549
|
-
|
3550
|
-
|
3551
|
-
|
3552
|
-
|
3553
|
-
|
3554
|
-
|
3555
|
-
|
3556
|
-
|
3557
|
-
|
3558
|
-
|
3559
|
-
|
3560
|
-
import { bn as bn12 } from "@fuel-ts/math";
|
3561
|
-
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType8 } from "@fuel-ts/transactions";
|
3562
|
-
import { arrayify as arrayify11 } from "@fuel-ts/utils";
|
3563
|
-
var calculateTXFeeForSummary = (params) => {
|
3564
|
-
const {
|
3565
|
-
gasPrice,
|
3566
|
-
rawPayload,
|
3567
|
-
tip,
|
3568
|
-
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
3569
|
-
} = params;
|
3570
|
-
const gasPerByte = bn12(feeParams.gasPerByte);
|
3571
|
-
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
3572
|
-
const transactionBytes = arrayify11(rawPayload);
|
3573
|
-
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
3574
|
-
const { type, witnesses, inputs, policies } = transaction;
|
3575
|
-
let metadataGas = bn12(0);
|
3576
|
-
let gasLimit = bn12(0);
|
3577
|
-
if (type !== TransactionType8.Create && type !== TransactionType8.Script) {
|
3578
|
-
return bn12(0);
|
3776
|
+
// src/providers/resource-cache.ts
|
3777
|
+
var cache = /* @__PURE__ */ new Map();
|
3778
|
+
var ResourceCache = class {
|
3779
|
+
ttl;
|
3780
|
+
constructor(ttl) {
|
3781
|
+
this.ttl = ttl;
|
3782
|
+
if (typeof ttl !== "number" || this.ttl <= 0) {
|
3783
|
+
throw new FuelError13(
|
3784
|
+
ErrorCode10.INVALID_TTL,
|
3785
|
+
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
3786
|
+
);
|
3787
|
+
}
|
3579
3788
|
}
|
3580
|
-
|
3789
|
+
// Add resources to the cache
|
3790
|
+
set(transactionId, inputs) {
|
3791
|
+
const transactionResourceCache = this.setupResourcesCache(inputs);
|
3792
|
+
cache.set(transactionId, transactionResourceCache);
|
3793
|
+
}
|
3794
|
+
unset(transactionId) {
|
3795
|
+
cache.delete(transactionId);
|
3796
|
+
}
|
3797
|
+
getActiveData(owner) {
|
3798
|
+
const activeData = { utxos: [], messages: [] };
|
3799
|
+
const currentTime = Date.now();
|
3800
|
+
const expired = [];
|
3801
|
+
cache.forEach((resource, transactionId) => {
|
3802
|
+
const isActive = currentTime - resource.timestamp < this.ttl;
|
3803
|
+
if (isActive) {
|
3804
|
+
const resourcesFromOwner = resource.owners.get(owner);
|
3805
|
+
if (resourcesFromOwner) {
|
3806
|
+
activeData.utxos.push(...resourcesFromOwner.utxos);
|
3807
|
+
activeData.messages.push(...resourcesFromOwner.messages);
|
3808
|
+
}
|
3809
|
+
} else {
|
3810
|
+
expired.push(transactionId);
|
3811
|
+
}
|
3812
|
+
});
|
3813
|
+
expired.forEach(this.unset);
|
3814
|
+
activeData.utxos.reverse();
|
3815
|
+
activeData.messages.reverse();
|
3816
|
+
return activeData;
|
3817
|
+
}
|
3818
|
+
isCached(owner, key) {
|
3819
|
+
const currentTime = Date.now();
|
3820
|
+
let cached = false;
|
3821
|
+
const expired = [];
|
3822
|
+
for (const [transactionId, resourceData] of cache.entries()) {
|
3823
|
+
const isActive = currentTime - resourceData.timestamp < this.ttl;
|
3824
|
+
if (isActive) {
|
3825
|
+
const resourcesFromOwner = resourceData.owners.get(owner);
|
3826
|
+
if (resourcesFromOwner?.utxos.has(key) || resourcesFromOwner?.messages.has(key)) {
|
3827
|
+
cached = true;
|
3828
|
+
break;
|
3829
|
+
}
|
3830
|
+
} else {
|
3831
|
+
expired.push(transactionId);
|
3832
|
+
}
|
3833
|
+
}
|
3834
|
+
expired.forEach(this.unset);
|
3835
|
+
return cached;
|
3836
|
+
}
|
3837
|
+
clear() {
|
3838
|
+
cache.clear();
|
3839
|
+
}
|
3840
|
+
setupResourcesCache(inputs) {
|
3841
|
+
const currentTime = Date.now();
|
3842
|
+
const transactionResourcesCache = {
|
3843
|
+
owners: /* @__PURE__ */ new Map(),
|
3844
|
+
timestamp: currentTime
|
3845
|
+
};
|
3846
|
+
inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
3847
|
+
const { owner, key, type } = this.extractResourceData(input);
|
3848
|
+
if (!transactionResourcesCache.owners.has(owner)) {
|
3849
|
+
transactionResourcesCache.owners.set(owner, { utxos: /* @__PURE__ */ new Set(), messages: /* @__PURE__ */ new Set() });
|
3850
|
+
}
|
3851
|
+
if (type === "utxo") {
|
3852
|
+
transactionResourcesCache.owners.get(owner)?.utxos.add(key);
|
3853
|
+
} else {
|
3854
|
+
transactionResourcesCache.owners.get(owner)?.messages.add(key);
|
3855
|
+
}
|
3856
|
+
});
|
3857
|
+
return transactionResourcesCache;
|
3858
|
+
}
|
3859
|
+
extractResourceData(input) {
|
3860
|
+
if (isRequestInputCoin(input)) {
|
3861
|
+
return { owner: hexlify16(input.owner), key: hexlify16(input.id), type: "utxo" };
|
3862
|
+
}
|
3863
|
+
return { owner: hexlify16(input.recipient), key: hexlify16(input.nonce), type: "message" };
|
3864
|
+
}
|
3865
|
+
};
|
3866
|
+
|
3867
|
+
// src/providers/transaction-response/transaction-response.ts
|
3868
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError17 } from "@fuel-ts/errors";
|
3869
|
+
import { bn as bn16 } from "@fuel-ts/math";
|
3870
|
+
import { OutputType as OutputType8, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
3871
|
+
import { arrayify as arrayify12, assertUnreachable } from "@fuel-ts/utils";
|
3872
|
+
|
3873
|
+
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
3874
|
+
import { bn as bn15 } from "@fuel-ts/math";
|
3875
|
+
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
3876
|
+
import { DateTime, hexlify as hexlify17 } from "@fuel-ts/utils";
|
3877
|
+
|
3878
|
+
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
3879
|
+
import { bn as bn12 } from "@fuel-ts/math";
|
3880
|
+
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType8 } from "@fuel-ts/transactions";
|
3881
|
+
import { arrayify as arrayify11 } from "@fuel-ts/utils";
|
3882
|
+
var calculateTXFeeForSummary = (params) => {
|
3883
|
+
const {
|
3884
|
+
gasPrice,
|
3885
|
+
rawPayload,
|
3886
|
+
tip,
|
3887
|
+
consensusParameters: { gasCosts, feeParams, maxGasPerTx }
|
3888
|
+
} = params;
|
3889
|
+
const gasPerByte = bn12(feeParams.gasPerByte);
|
3890
|
+
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
3891
|
+
const transactionBytes = arrayify11(rawPayload);
|
3892
|
+
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
3893
|
+
const { type, witnesses, inputs, policies } = transaction;
|
3894
|
+
let metadataGas = bn12(0);
|
3895
|
+
let gasLimit = bn12(0);
|
3896
|
+
if (type !== TransactionType8.Create && type !== TransactionType8.Script) {
|
3897
|
+
return bn12(0);
|
3898
|
+
}
|
3899
|
+
if (type === TransactionType8.Create) {
|
3581
3900
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
3582
3901
|
const contractBytesSize = bn12(arrayify11(witnesses[bytecodeWitnessIndex].data).length);
|
3583
3902
|
metadataGas = calculateMetadataGasForTxCreate({
|
@@ -3624,45 +3943,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
3624
3943
|
|
3625
3944
|
// src/providers/transaction-summary/operations.ts
|
3626
3945
|
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
3627
|
-
import { ErrorCode as
|
3946
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError15 } from "@fuel-ts/errors";
|
3628
3947
|
import { bn as bn13 } from "@fuel-ts/math";
|
3629
|
-
import { ReceiptType as
|
3630
|
-
|
3631
|
-
// src/providers/transaction-summary/call.ts
|
3632
|
-
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
3633
|
-
var getFunctionCall = ({ abi, receipt }) => {
|
3634
|
-
const abiInterface = new Interface2(abi);
|
3635
|
-
const callFunctionSelector = receipt.param1.toHex(8);
|
3636
|
-
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
3637
|
-
const inputs = functionFragment.jsonFn.inputs;
|
3638
|
-
const encodedArgs = receipt.param2.toHex();
|
3639
|
-
let argumentsProvided;
|
3640
|
-
const data = functionFragment.decodeArguments(encodedArgs);
|
3641
|
-
if (data) {
|
3642
|
-
argumentsProvided = inputs.reduce((prev, input, index) => {
|
3643
|
-
const value = data[index];
|
3644
|
-
const name = input.name;
|
3645
|
-
if (name) {
|
3646
|
-
return {
|
3647
|
-
...prev,
|
3648
|
-
// reparse to remove bn
|
3649
|
-
[name]: JSON.parse(JSON.stringify(value))
|
3650
|
-
};
|
3651
|
-
}
|
3652
|
-
return prev;
|
3653
|
-
}, {});
|
3654
|
-
}
|
3655
|
-
const call = {
|
3656
|
-
functionSignature: functionFragment.signature,
|
3657
|
-
functionName: functionFragment.name,
|
3658
|
-
argumentsProvided,
|
3659
|
-
...receipt.amount?.isZero() ? {} : { amount: receipt.amount, assetId: receipt.assetId }
|
3660
|
-
};
|
3661
|
-
return call;
|
3662
|
-
};
|
3948
|
+
import { ReceiptType as ReceiptType5, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
|
3663
3949
|
|
3664
3950
|
// src/providers/transaction-summary/input.ts
|
3665
|
-
import { ErrorCode as
|
3951
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError14 } from "@fuel-ts/errors";
|
3666
3952
|
import { BN } from "@fuel-ts/math";
|
3667
3953
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
3668
3954
|
function getInputsByTypes(inputs, types) {
|
@@ -3731,8 +4017,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3731
4017
|
return void 0;
|
3732
4018
|
}
|
3733
4019
|
if (contractInput.type !== InputType6.Contract) {
|
3734
|
-
throw new
|
3735
|
-
|
4020
|
+
throw new FuelError14(
|
4021
|
+
ErrorCode11.INVALID_TRANSACTION_INPUT,
|
3736
4022
|
`Contract input should be of type 'contract'.`
|
3737
4023
|
);
|
3738
4024
|
}
|
@@ -3785,8 +4071,8 @@ function getTransactionTypeName(transactionType) {
|
|
3785
4071
|
case TransactionType9.Upload:
|
3786
4072
|
return "Upload" /* Upload */;
|
3787
4073
|
default:
|
3788
|
-
throw new
|
3789
|
-
|
4074
|
+
throw new FuelError15(
|
4075
|
+
ErrorCode12.UNSUPPORTED_TRANSACTION_TYPE,
|
3790
4076
|
`Unsupported transaction type: ${transactionType}.`
|
3791
4077
|
);
|
3792
4078
|
}
|
@@ -3814,10 +4100,10 @@ function isTypeBlob(transactionType) {
|
|
3814
4100
|
return isType(transactionType, "Blob" /* Blob */);
|
3815
4101
|
}
|
3816
4102
|
function getReceiptsCall(receipts) {
|
3817
|
-
return getReceiptsByType(receipts,
|
4103
|
+
return getReceiptsByType(receipts, ReceiptType5.Call);
|
3818
4104
|
}
|
3819
4105
|
function getReceiptsMessageOut(receipts) {
|
3820
|
-
return getReceiptsByType(receipts,
|
4106
|
+
return getReceiptsByType(receipts, ReceiptType5.MessageOut);
|
3821
4107
|
}
|
3822
4108
|
function mergeAssets(op1, op2) {
|
3823
4109
|
const assets1 = op1.assetsSent || [];
|
@@ -3855,7 +4141,11 @@ function mergeOperations(existing, toAdd) {
|
|
3855
4141
|
return {
|
3856
4142
|
...existing,
|
3857
4143
|
assetsSent: mergeAssetsSent(existing, toAdd),
|
3858
|
-
calls: mergeCalls(existing, toAdd)
|
4144
|
+
calls: mergeCalls(existing, toAdd),
|
4145
|
+
receipts: [
|
4146
|
+
...existing.receipts || [],
|
4147
|
+
...toAdd.receipts?.filter((r) => !existing.receipts?.some((er) => er === r)) || []
|
4148
|
+
]
|
3859
4149
|
};
|
3860
4150
|
}
|
3861
4151
|
function addOperation(operations, toAdd) {
|
@@ -3892,7 +4182,8 @@ function getWithdrawFromFuelOperations({
|
|
3892
4182
|
amount: receipt.amount,
|
3893
4183
|
assetId: baseAssetId
|
3894
4184
|
}
|
3895
|
-
]
|
4185
|
+
],
|
4186
|
+
receipts: [receipt]
|
3896
4187
|
});
|
3897
4188
|
return newWithdrawFromFuelOps;
|
3898
4189
|
}
|
@@ -3902,19 +4193,12 @@ function getWithdrawFromFuelOperations({
|
|
3902
4193
|
);
|
3903
4194
|
return withdrawFromFuelOperations;
|
3904
4195
|
}
|
3905
|
-
function getContractCalls(contractInput, abiMap,
|
4196
|
+
function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
|
3906
4197
|
const abi = abiMap?.[contractInput.contractID];
|
3907
4198
|
if (!abi) {
|
3908
4199
|
return [];
|
3909
4200
|
}
|
3910
|
-
return [
|
3911
|
-
getFunctionCall({
|
3912
|
-
abi,
|
3913
|
-
receipt,
|
3914
|
-
rawPayload,
|
3915
|
-
maxInputs
|
3916
|
-
})
|
3917
|
-
];
|
4201
|
+
return [];
|
3918
4202
|
}
|
3919
4203
|
function getAssetsSent(receipt) {
|
3920
4204
|
return receipt.amount?.isZero() ? void 0 : [
|
@@ -3944,7 +4228,8 @@ function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload,
|
|
3944
4228
|
address: receipt.to
|
3945
4229
|
},
|
3946
4230
|
assetsSent: getAssetsSent(receipt),
|
3947
|
-
calls
|
4231
|
+
calls,
|
4232
|
+
receipts: [receipt]
|
3948
4233
|
}
|
3949
4234
|
];
|
3950
4235
|
}
|
@@ -4001,7 +4286,8 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
4001
4286
|
assetId: assetId.toString(),
|
4002
4287
|
amount
|
4003
4288
|
}
|
4004
|
-
]
|
4289
|
+
],
|
4290
|
+
receipts: [receipt]
|
4005
4291
|
};
|
4006
4292
|
}
|
4007
4293
|
function getTransferOperations({
|
@@ -4046,11 +4332,11 @@ function getTransferOperations({
|
|
4046
4332
|
});
|
4047
4333
|
const transferReceipts = getReceiptsByType(
|
4048
4334
|
receipts,
|
4049
|
-
|
4335
|
+
ReceiptType5.Transfer
|
4050
4336
|
);
|
4051
4337
|
const transferOutReceipts = getReceiptsByType(
|
4052
4338
|
receipts,
|
4053
|
-
|
4339
|
+
ReceiptType5.TransferOut
|
4054
4340
|
);
|
4055
4341
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
4056
4342
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -4134,12 +4420,11 @@ function getOperations({
|
|
4134
4420
|
}
|
4135
4421
|
|
4136
4422
|
// src/providers/transaction-summary/receipt.ts
|
4137
|
-
import { ReceiptType as
|
4138
|
-
var processGqlReceipt = (gqlReceipt) => assembleReceiptByType(gqlReceipt);
|
4423
|
+
import { ReceiptType as ReceiptType6 } from "@fuel-ts/transactions";
|
4139
4424
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
4140
4425
|
const mintedAssets = [];
|
4141
4426
|
receipts.forEach((receipt) => {
|
4142
|
-
if (receipt.type ===
|
4427
|
+
if (receipt.type === ReceiptType6.Mint) {
|
4143
4428
|
mintedAssets.push({
|
4144
4429
|
subId: receipt.subId,
|
4145
4430
|
contractId: receipt.contractId,
|
@@ -4153,7 +4438,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
4153
4438
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
4154
4439
|
const burnedAssets = [];
|
4155
4440
|
receipts.forEach((receipt) => {
|
4156
|
-
if (receipt.type ===
|
4441
|
+
if (receipt.type === ReceiptType6.Burn) {
|
4157
4442
|
burnedAssets.push({
|
4158
4443
|
subId: receipt.subId,
|
4159
4444
|
contractId: receipt.contractId,
|
@@ -4166,7 +4451,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
4166
4451
|
};
|
4167
4452
|
|
4168
4453
|
// src/providers/transaction-summary/status.ts
|
4169
|
-
import { ErrorCode as
|
4454
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError16 } from "@fuel-ts/errors";
|
4170
4455
|
import { bn as bn14 } from "@fuel-ts/math";
|
4171
4456
|
var getTransactionStatusName = (gqlStatus) => {
|
4172
4457
|
switch (gqlStatus) {
|
@@ -4179,8 +4464,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
4179
4464
|
case "SqueezedOutStatus":
|
4180
4465
|
return "squeezedout" /* squeezedout */;
|
4181
4466
|
default:
|
4182
|
-
throw new
|
4183
|
-
|
4467
|
+
throw new FuelError16(
|
4468
|
+
ErrorCode13.INVALID_TRANSACTION_STATUS,
|
4184
4469
|
`Invalid transaction status: ${gqlStatus}.`
|
4185
4470
|
);
|
4186
4471
|
}
|
@@ -4250,7 +4535,7 @@ function assembleTransactionSummary(params) {
|
|
4250
4535
|
baseAssetId
|
4251
4536
|
} = params;
|
4252
4537
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
4253
|
-
const rawPayload =
|
4538
|
+
const rawPayload = hexlify17(transactionBytes);
|
4254
4539
|
const operations = getOperations({
|
4255
4540
|
transactionType: transaction.type,
|
4256
4541
|
inputs: transaction.inputs || [],
|
@@ -4312,13 +4597,13 @@ function assembleTransactionSummary(params) {
|
|
4312
4597
|
}
|
4313
4598
|
|
4314
4599
|
// src/providers/transaction-response/getDecodedLogs.ts
|
4315
|
-
import { Interface as
|
4316
|
-
import { ReceiptType as
|
4600
|
+
import { Interface as Interface2, BigNumberCoder } from "@fuel-ts/abi-coder";
|
4601
|
+
import { ReceiptType as ReceiptType7 } from "@fuel-ts/transactions";
|
4317
4602
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
4318
4603
|
return receipts.reduce((logs, receipt) => {
|
4319
|
-
if (receipt.type ===
|
4320
|
-
const interfaceToUse = new
|
4321
|
-
const data = receipt.type ===
|
4604
|
+
if (receipt.type === ReceiptType7.LogData || receipt.type === ReceiptType7.Log) {
|
4605
|
+
const interfaceToUse = new Interface2(externalAbis[receipt.id] || mainAbi);
|
4606
|
+
const data = receipt.type === ReceiptType7.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
4322
4607
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
4323
4608
|
logs.push(decodedLog);
|
4324
4609
|
}
|
@@ -4370,6 +4655,7 @@ var TransactionResponse = class {
|
|
4370
4655
|
this.provider = provider;
|
4371
4656
|
this.abis = abis;
|
4372
4657
|
this.request = typeof tx === "string" ? void 0 : tx;
|
4658
|
+
this.waitForResult = this.waitForResult.bind(this);
|
4373
4659
|
}
|
4374
4660
|
/** Transaction ID */
|
4375
4661
|
id;
|
@@ -4439,7 +4725,7 @@ var TransactionResponse = class {
|
|
4439
4725
|
switch (status?.type) {
|
4440
4726
|
case "SuccessStatus":
|
4441
4727
|
case "FailureStatus":
|
4442
|
-
return status.receipts.map(
|
4728
|
+
return status.receipts.map(deserializeReceipt);
|
4443
4729
|
default:
|
4444
4730
|
return [];
|
4445
4731
|
}
|
@@ -4524,8 +4810,8 @@ var TransactionResponse = class {
|
|
4524
4810
|
this.status = statusChange;
|
4525
4811
|
if (statusChange.type === "SqueezedOutStatus") {
|
4526
4812
|
this.unsetResourceCache();
|
4527
|
-
throw new
|
4528
|
-
|
4813
|
+
throw new FuelError17(
|
4814
|
+
ErrorCode14.TRANSACTION_SQUEEZED_OUT,
|
4529
4815
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4530
4816
|
);
|
4531
4817
|
}
|
@@ -4563,7 +4849,6 @@ var TransactionResponse = class {
|
|
4563
4849
|
const { receipts } = transactionResult;
|
4564
4850
|
const status = this.status ?? this.gqlTransaction?.status;
|
4565
4851
|
if (status?.type === "FailureStatus") {
|
4566
|
-
this.unsetResourceCache();
|
4567
4852
|
const { reason } = status;
|
4568
4853
|
throw extractTxError({
|
4569
4854
|
receipts,
|
@@ -4580,6 +4865,7 @@ var TransactionResponse = class {
|
|
4580
4865
|
*/
|
4581
4866
|
async waitForResult(contractsAbiMap) {
|
4582
4867
|
await this.waitForStatusChange();
|
4868
|
+
this.unsetResourceCache();
|
4583
4869
|
return this.assembleResult(contractsAbiMap);
|
4584
4870
|
}
|
4585
4871
|
/**
|
@@ -4632,27 +4918,20 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4632
4918
|
};
|
4633
4919
|
}
|
4634
4920
|
|
4635
|
-
// src/providers/utils/
|
4636
|
-
|
4637
|
-
|
4638
|
-
|
4639
|
-
|
4640
|
-
|
4641
|
-
|
4642
|
-
|
4643
|
-
|
4644
|
-
|
4645
|
-
|
4646
|
-
|
4647
|
-
|
4648
|
-
|
4649
|
-
"The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
|
4650
|
-
{},
|
4651
|
-
rawError
|
4652
|
-
);
|
4653
|
-
default:
|
4654
|
-
throw new FuelError17(ErrorCode14.INVALID_REQUEST, errorMessage);
|
4655
|
-
}
|
4921
|
+
// src/providers/utils/helpers.ts
|
4922
|
+
var adjustResourcesToExclude = (params) => {
|
4923
|
+
const { userInput, cached, maxInputs } = params;
|
4924
|
+
const final = { ...userInput };
|
4925
|
+
let total = final.utxos.length + final.messages.length;
|
4926
|
+
if (total >= maxInputs) {
|
4927
|
+
return final;
|
4928
|
+
}
|
4929
|
+
final.utxos = [...final.utxos, ...cached.utxos.slice(0, maxInputs - total)];
|
4930
|
+
total = final.utxos.length + final.messages.length;
|
4931
|
+
if (total < maxInputs) {
|
4932
|
+
final.messages = [...final.messages, ...cached.messages.slice(0, maxInputs - total)];
|
4933
|
+
}
|
4934
|
+
return final;
|
4656
4935
|
};
|
4657
4936
|
|
4658
4937
|
// src/providers/utils/validate-pagination-args.ts
|
@@ -4694,64 +4973,10 @@ var validatePaginationArgs = (params) => {
|
|
4694
4973
|
var MAX_RETRIES = 10;
|
4695
4974
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
4696
4975
|
var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
|
4976
|
+
var BALANCES_PAGE_SIZE_LIMIT = 100;
|
4697
4977
|
var BLOCKS_PAGE_SIZE_LIMIT = 5;
|
4698
4978
|
var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
|
4699
4979
|
var GAS_USED_MODIFIER = 1.2;
|
4700
|
-
var processGqlChain = (chain) => {
|
4701
|
-
const { name, daHeight, consensusParameters } = chain;
|
4702
|
-
const {
|
4703
|
-
contractParams,
|
4704
|
-
feeParams,
|
4705
|
-
predicateParams,
|
4706
|
-
scriptParams,
|
4707
|
-
txParams,
|
4708
|
-
gasCosts,
|
4709
|
-
baseAssetId,
|
4710
|
-
chainId,
|
4711
|
-
version
|
4712
|
-
} = consensusParameters;
|
4713
|
-
return {
|
4714
|
-
name,
|
4715
|
-
baseChainHeight: bn17(daHeight),
|
4716
|
-
consensusParameters: {
|
4717
|
-
version,
|
4718
|
-
chainId: bn17(chainId),
|
4719
|
-
baseAssetId,
|
4720
|
-
feeParameters: {
|
4721
|
-
version: feeParams.version,
|
4722
|
-
gasPerByte: bn17(feeParams.gasPerByte),
|
4723
|
-
gasPriceFactor: bn17(feeParams.gasPriceFactor)
|
4724
|
-
},
|
4725
|
-
contractParameters: {
|
4726
|
-
version: contractParams.version,
|
4727
|
-
contractMaxSize: bn17(contractParams.contractMaxSize),
|
4728
|
-
maxStorageSlots: bn17(contractParams.maxStorageSlots)
|
4729
|
-
},
|
4730
|
-
txParameters: {
|
4731
|
-
version: txParams.version,
|
4732
|
-
maxInputs: bn17(txParams.maxInputs),
|
4733
|
-
maxOutputs: bn17(txParams.maxOutputs),
|
4734
|
-
maxWitnesses: bn17(txParams.maxWitnesses),
|
4735
|
-
maxGasPerTx: bn17(txParams.maxGasPerTx),
|
4736
|
-
maxSize: bn17(txParams.maxSize),
|
4737
|
-
maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
|
4738
|
-
},
|
4739
|
-
predicateParameters: {
|
4740
|
-
version: predicateParams.version,
|
4741
|
-
maxPredicateLength: bn17(predicateParams.maxPredicateLength),
|
4742
|
-
maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
|
4743
|
-
maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
|
4744
|
-
maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
|
4745
|
-
},
|
4746
|
-
scriptParameters: {
|
4747
|
-
version: scriptParams.version,
|
4748
|
-
maxScriptLength: bn17(scriptParams.maxScriptLength),
|
4749
|
-
maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
|
4750
|
-
},
|
4751
|
-
gasCosts
|
4752
|
-
}
|
4753
|
-
};
|
4754
|
-
};
|
4755
4980
|
var _cacheInputs, cacheInputs_fn;
|
4756
4981
|
var _Provider = class {
|
4757
4982
|
/**
|
@@ -4773,13 +4998,19 @@ var _Provider = class {
|
|
4773
4998
|
/** @hidden */
|
4774
4999
|
__publicField(this, "urlWithoutAuth");
|
4775
5000
|
/** @hidden */
|
5001
|
+
__publicField(this, "features", {
|
5002
|
+
balancePagination: false,
|
5003
|
+
amount128: false
|
5004
|
+
});
|
5005
|
+
/** @hidden */
|
4776
5006
|
__publicField(this, "consensusParametersTimestamp");
|
4777
5007
|
__publicField(this, "options", {
|
4778
5008
|
timeout: void 0,
|
4779
5009
|
resourceCacheTTL: void 0,
|
4780
5010
|
fetch: void 0,
|
4781
5011
|
retryOptions: void 0,
|
4782
|
-
headers: void 0
|
5012
|
+
headers: void 0,
|
5013
|
+
cache: void 0
|
4783
5014
|
});
|
4784
5015
|
const { url: rawUrl, urlWithoutAuth, headers: authHeaders } = _Provider.extractBasicAuth(url);
|
4785
5016
|
this.url = rawUrl;
|
@@ -4793,7 +5024,13 @@ var _Provider = class {
|
|
4793
5024
|
headers
|
4794
5025
|
};
|
4795
5026
|
this.operations = this.createOperations();
|
4796
|
-
const { resourceCacheTTL } = this.options;
|
5027
|
+
const { resourceCacheTTL, cache: cache2 } = this.options;
|
5028
|
+
if (cache2) {
|
5029
|
+
const { consensusParametersTimestamp, chain, nodeInfo } = deserializeProviderCache(cache2);
|
5030
|
+
this.consensusParametersTimestamp = consensusParametersTimestamp;
|
5031
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
5032
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
5033
|
+
}
|
4797
5034
|
if (isDefined2(resourceCacheTTL)) {
|
4798
5035
|
if (resourceCacheTTL !== -1) {
|
4799
5036
|
this.cache = new ResourceCache(resourceCacheTTL);
|
@@ -4852,7 +5089,8 @@ var _Provider = class {
|
|
4852
5089
|
* Initialize Provider async stuff
|
4853
5090
|
*/
|
4854
5091
|
async init() {
|
4855
|
-
await this.fetchChainAndNodeInfo();
|
5092
|
+
const { nodeInfo } = await this.fetchChainAndNodeInfo();
|
5093
|
+
this.setupFeatures(nodeInfo.nodeVersion);
|
4856
5094
|
return this;
|
4857
5095
|
}
|
4858
5096
|
/**
|
@@ -4923,15 +5161,9 @@ var _Provider = class {
|
|
4923
5161
|
}
|
4924
5162
|
} catch (_err) {
|
4925
5163
|
const data = await this.operations.getChainAndNodeInfo();
|
4926
|
-
nodeInfo =
|
4927
|
-
|
4928
|
-
|
4929
|
-
nodeVersion: data.nodeInfo.nodeVersion,
|
4930
|
-
utxoValidation: data.nodeInfo.utxoValidation,
|
4931
|
-
vmBacktrace: data.nodeInfo.vmBacktrace
|
4932
|
-
};
|
4933
|
-
_Provider.ensureClientVersionIsSupported(nodeInfo);
|
4934
|
-
chain = processGqlChain(data.chain);
|
5164
|
+
nodeInfo = deserializeNodeInfo(data.nodeInfo);
|
5165
|
+
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
5166
|
+
chain = deserializeChain(data.chain);
|
4935
5167
|
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
4936
5168
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
4937
5169
|
this.consensusParametersTimestamp = Date.now();
|
@@ -4944,15 +5176,15 @@ var _Provider = class {
|
|
4944
5176
|
/**
|
4945
5177
|
* @hidden
|
4946
5178
|
*/
|
4947
|
-
static
|
5179
|
+
static setIncompatibleNodeVersionMessage(nodeInfo) {
|
4948
5180
|
const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
|
4949
5181
|
if (!isMajorSupported || !isMinorSupported) {
|
4950
|
-
|
4951
|
-
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion}
|
4952
|
-
|
4953
|
-
Things may not work as expected
|
4954
|
-
|
4955
|
-
|
5182
|
+
_Provider.incompatibleNodeVersionMessage = [
|
5183
|
+
`The Fuel Node that you are trying to connect to is using fuel-core version ${nodeInfo.nodeVersion}.`,
|
5184
|
+
`The TS SDK currently supports fuel-core version ${supportedVersion}.`,
|
5185
|
+
`Things may not work as expected.`
|
5186
|
+
].join("\n");
|
5187
|
+
FuelGraphqlSubscriber.incompatibleNodeVersionMessage = _Provider.incompatibleNodeVersionMessage;
|
4956
5188
|
}
|
4957
5189
|
}
|
4958
5190
|
/**
|
@@ -4968,11 +5200,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4968
5200
|
responseMiddleware: (response) => {
|
4969
5201
|
if ("response" in response) {
|
4970
5202
|
const graphQlResponse = response.response;
|
4971
|
-
|
4972
|
-
|
4973
|
-
|
4974
|
-
|
4975
|
-
}
|
5203
|
+
assertGqlResponseHasNoErrors(
|
5204
|
+
graphQlResponse.errors,
|
5205
|
+
_Provider.incompatibleNodeVersionMessage
|
5206
|
+
);
|
4976
5207
|
}
|
4977
5208
|
}
|
4978
5209
|
});
|
@@ -5010,6 +5241,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5010
5241
|
});
|
5011
5242
|
return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
|
5012
5243
|
}
|
5244
|
+
/**
|
5245
|
+
* @hidden
|
5246
|
+
*/
|
5247
|
+
setupFeatures(nodeVersion) {
|
5248
|
+
if (gte(nodeVersion, "0.41.0")) {
|
5249
|
+
this.features.balancePagination = true;
|
5250
|
+
this.features.amount128 = true;
|
5251
|
+
}
|
5252
|
+
}
|
5013
5253
|
/**
|
5014
5254
|
* Returns the version of the connected node.
|
5015
5255
|
*
|
@@ -5041,13 +5281,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5041
5281
|
*/
|
5042
5282
|
async fetchNode() {
|
5043
5283
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
5044
|
-
const processedNodeInfo =
|
5045
|
-
maxDepth: bn17(nodeInfo.maxDepth),
|
5046
|
-
maxTx: bn17(nodeInfo.maxTx),
|
5047
|
-
nodeVersion: nodeInfo.nodeVersion,
|
5048
|
-
utxoValidation: nodeInfo.utxoValidation,
|
5049
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
5050
|
-
};
|
5284
|
+
const processedNodeInfo = deserializeNodeInfo(nodeInfo);
|
5051
5285
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = processedNodeInfo;
|
5052
5286
|
return processedNodeInfo;
|
5053
5287
|
}
|
@@ -5058,7 +5292,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5058
5292
|
*/
|
5059
5293
|
async fetchChain() {
|
5060
5294
|
const { chain } = await this.operations.getChain();
|
5061
|
-
const processedChain =
|
5295
|
+
const processedChain = deserializeChain(chain);
|
5062
5296
|
_Provider.chainInfoCache[this.urlWithoutAuth] = processedChain;
|
5063
5297
|
return processedChain;
|
5064
5298
|
}
|
@@ -5085,6 +5319,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5085
5319
|
} = all;
|
5086
5320
|
return baseAssetId;
|
5087
5321
|
}
|
5322
|
+
/**
|
5323
|
+
* Retrieves the details of an asset given its ID.
|
5324
|
+
*
|
5325
|
+
* @param assetId - The unique identifier of the asset.
|
5326
|
+
* @returns A promise that resolves to an object containing the asset details.
|
5327
|
+
*/
|
5328
|
+
async getAssetDetails(assetId) {
|
5329
|
+
const { assetDetails } = await this.operations.getAssetDetails({ assetId });
|
5330
|
+
const { contractId, subId, totalSupply } = assetDetails;
|
5331
|
+
return {
|
5332
|
+
subId,
|
5333
|
+
contractId,
|
5334
|
+
totalSupply: bn17(totalSupply)
|
5335
|
+
};
|
5336
|
+
}
|
5088
5337
|
/**
|
5089
5338
|
* @hidden
|
5090
5339
|
*/
|
@@ -5128,7 +5377,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5128
5377
|
await this.estimateTxDependencies(transactionRequest);
|
5129
5378
|
}
|
5130
5379
|
await this.validateTransaction(transactionRequest);
|
5131
|
-
const encodedTransaction =
|
5380
|
+
const encodedTransaction = hexlify18(transactionRequest.toTransactionBytes());
|
5132
5381
|
let abis;
|
5133
5382
|
if (isTransactionTypeScript(transactionRequest)) {
|
5134
5383
|
abis = transactionRequest.abis;
|
@@ -5153,48 +5402,70 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5153
5402
|
if (estimateTxDependencies) {
|
5154
5403
|
return this.estimateTxDependencies(transactionRequest);
|
5155
5404
|
}
|
5156
|
-
const encodedTransaction =
|
5405
|
+
const encodedTransaction = hexlify18(transactionRequest.toTransactionBytes());
|
5157
5406
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5158
5407
|
encodedTransactions: encodedTransaction,
|
5159
5408
|
utxoValidation: utxoValidation || false
|
5160
5409
|
});
|
5161
5410
|
const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
|
5162
|
-
const receipts = rawReceipts.map(
|
5411
|
+
const receipts = rawReceipts.map(deserializeReceipt);
|
5163
5412
|
return { receipts, dryRunStatus };
|
5164
5413
|
}
|
5165
5414
|
/**
|
5166
|
-
*
|
5415
|
+
* Estimates the gas usage for predicates in a transaction request.
|
5167
5416
|
*
|
5168
5417
|
* @template T - The type of the transaction request object.
|
5169
5418
|
*
|
5170
|
-
* @param transactionRequest - The transaction request
|
5171
|
-
* @returns A promise that resolves to the
|
5419
|
+
* @param transactionRequest - The transaction request to estimate predicates for.
|
5420
|
+
* @returns A promise that resolves to the updated transaction request with estimated gas usage for predicates.
|
5172
5421
|
*/
|
5173
5422
|
async estimatePredicates(transactionRequest) {
|
5174
|
-
const shouldEstimatePredicates =
|
5175
|
-
|
5176
|
-
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify13(input.predicate), arrayify13("0x")) && new BN2(input.predicateGasUsed).isZero()
|
5177
|
-
)
|
5423
|
+
const shouldEstimatePredicates = transactionRequest.inputs.some(
|
5424
|
+
(input) => isPredicate(input) && bn17(input.predicateGasUsed).isZero()
|
5178
5425
|
);
|
5179
5426
|
if (!shouldEstimatePredicates) {
|
5180
5427
|
return transactionRequest;
|
5181
5428
|
}
|
5182
|
-
const encodedTransaction =
|
5429
|
+
const encodedTransaction = hexlify18(transactionRequest.toTransactionBytes());
|
5183
5430
|
const response = await this.operations.estimatePredicates({
|
5184
5431
|
encodedTransaction
|
5185
5432
|
});
|
5186
|
-
const {
|
5187
|
-
|
5188
|
-
|
5189
|
-
|
5190
|
-
|
5191
|
-
if ("predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
|
5192
|
-
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
5193
|
-
}
|
5194
|
-
});
|
5195
|
-
}
|
5433
|
+
const { estimatePredicates } = response;
|
5434
|
+
transactionRequest = this.parseEstimatePredicatesResponse(
|
5435
|
+
transactionRequest,
|
5436
|
+
estimatePredicates
|
5437
|
+
);
|
5196
5438
|
return transactionRequest;
|
5197
5439
|
}
|
5440
|
+
/**
|
5441
|
+
* Estimates the gas price and predicates for a given transaction request and block horizon.
|
5442
|
+
*
|
5443
|
+
* @param transactionRequest - The transaction request to estimate predicates and gas price for.
|
5444
|
+
* @param blockHorizon - The block horizon to use for gas price estimation.
|
5445
|
+
* @returns A promise that resolves to an object containing the updated transaction
|
5446
|
+
* request and the estimated gas price.
|
5447
|
+
*/
|
5448
|
+
async estimatePredicatesAndGasPrice(transactionRequest, blockHorizon) {
|
5449
|
+
const shouldEstimatePredicates = transactionRequest.inputs.some(
|
5450
|
+
(input) => isPredicate(input) && bn17(input.predicateGasUsed).isZero()
|
5451
|
+
);
|
5452
|
+
if (!shouldEstimatePredicates) {
|
5453
|
+
const gasPrice2 = await this.estimateGasPrice(blockHorizon);
|
5454
|
+
return { transactionRequest, gasPrice: gasPrice2 };
|
5455
|
+
}
|
5456
|
+
const {
|
5457
|
+
estimateGasPrice: { gasPrice },
|
5458
|
+
estimatePredicates
|
5459
|
+
} = await this.operations.estimatePredicatesAndGasPrice({
|
5460
|
+
blockHorizon: String(blockHorizon),
|
5461
|
+
encodedTransaction: hexlify18(transactionRequest.toTransactionBytes())
|
5462
|
+
});
|
5463
|
+
transactionRequest = this.parseEstimatePredicatesResponse(
|
5464
|
+
transactionRequest,
|
5465
|
+
estimatePredicates
|
5466
|
+
);
|
5467
|
+
return { transactionRequest, gasPrice: bn17(gasPrice) };
|
5468
|
+
}
|
5198
5469
|
/**
|
5199
5470
|
* Will dryRun a transaction and check for missing dependencies.
|
5200
5471
|
*
|
@@ -5202,30 +5473,35 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5202
5473
|
* `addVariableOutputs` is called on the transaction.
|
5203
5474
|
*
|
5204
5475
|
* @param transactionRequest - The transaction request object.
|
5476
|
+
* @param gasPrice - The gas price to use for the transaction, if not provided it will be fetched.
|
5205
5477
|
* @returns A promise that resolves to the estimate transaction dependencies.
|
5206
5478
|
*/
|
5207
|
-
async estimateTxDependencies(transactionRequest) {
|
5479
|
+
async estimateTxDependencies(transactionRequest, { gasPrice: gasPriceParam } = {}) {
|
5208
5480
|
if (isTransactionTypeCreate(transactionRequest)) {
|
5209
5481
|
return {
|
5482
|
+
rawReceipts: [],
|
5210
5483
|
receipts: [],
|
5211
5484
|
outputVariables: 0,
|
5212
5485
|
missingContractIds: []
|
5213
5486
|
};
|
5214
5487
|
}
|
5488
|
+
let rawReceipts = [];
|
5215
5489
|
let receipts = [];
|
5216
5490
|
const missingContractIds = [];
|
5217
5491
|
let outputVariables = 0;
|
5218
5492
|
let dryRunStatus;
|
5219
5493
|
await this.validateTransaction(transactionRequest);
|
5494
|
+
const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
|
5220
5495
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
5221
5496
|
const {
|
5222
|
-
dryRun: [{ receipts:
|
5497
|
+
dryRun: [{ receipts: serializedReceipts, status }]
|
5223
5498
|
} = await this.operations.dryRun({
|
5224
|
-
encodedTransactions: [
|
5499
|
+
encodedTransactions: [hexlify18(transactionRequest.toTransactionBytes())],
|
5225
5500
|
utxoValidation: false,
|
5226
|
-
gasPrice:
|
5501
|
+
gasPrice: gasPrice.toString()
|
5227
5502
|
});
|
5228
|
-
|
5503
|
+
rawReceipts = serializedReceipts;
|
5504
|
+
receipts = serializedReceipts.map(deserializeReceipt);
|
5229
5505
|
dryRunStatus = status;
|
5230
5506
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
5231
5507
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
@@ -5233,12 +5509,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5233
5509
|
outputVariables += missingOutputVariables.length;
|
5234
5510
|
transactionRequest.addVariableOutputs(missingOutputVariables.length);
|
5235
5511
|
missingOutputContractIds.forEach(({ contractId }) => {
|
5236
|
-
transactionRequest.addContractInputAndOutput(Address3
|
5512
|
+
transactionRequest.addContractInputAndOutput(new Address3(contractId));
|
5237
5513
|
missingContractIds.push(contractId);
|
5238
5514
|
});
|
5239
5515
|
const { maxFee } = await this.estimateTxGasAndFee({
|
5240
5516
|
transactionRequest,
|
5241
|
-
gasPrice
|
5517
|
+
gasPrice
|
5242
5518
|
});
|
5243
5519
|
transactionRequest.maxFee = maxFee;
|
5244
5520
|
} else {
|
@@ -5246,6 +5522,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5246
5522
|
}
|
5247
5523
|
}
|
5248
5524
|
return {
|
5525
|
+
rawReceipts,
|
5249
5526
|
receipts,
|
5250
5527
|
outputVariables,
|
5251
5528
|
missingContractIds,
|
@@ -5264,6 +5541,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5264
5541
|
*/
|
5265
5542
|
async estimateMultipleTxDependencies(transactionRequests) {
|
5266
5543
|
const results = transactionRequests.map(() => ({
|
5544
|
+
rawReceipts: [],
|
5267
5545
|
receipts: [],
|
5268
5546
|
outputVariables: 0,
|
5269
5547
|
missingContractIds: [],
|
@@ -5273,7 +5551,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5273
5551
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
5274
5552
|
allRequests.forEach((req, index) => {
|
5275
5553
|
if (isTransactionTypeScript(req)) {
|
5276
|
-
serializedTransactionsMap.set(index,
|
5554
|
+
serializedTransactionsMap.set(index, hexlify18(req.toTransactionBytes()));
|
5277
5555
|
}
|
5278
5556
|
});
|
5279
5557
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -5291,7 +5569,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5291
5569
|
const requestIdx = transactionsToProcess[i];
|
5292
5570
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
5293
5571
|
const result = results[requestIdx];
|
5294
|
-
result.receipts = rawReceipts.map(
|
5572
|
+
result.receipts = rawReceipts.map(deserializeReceipt);
|
5295
5573
|
result.dryRunStatus = status;
|
5296
5574
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
5297
5575
|
result.receipts
|
@@ -5302,14 +5580,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5302
5580
|
result.outputVariables += missingOutputVariables.length;
|
5303
5581
|
request.addVariableOutputs(missingOutputVariables.length);
|
5304
5582
|
missingOutputContractIds.forEach(({ contractId }) => {
|
5305
|
-
request.addContractInputAndOutput(Address3
|
5583
|
+
request.addContractInputAndOutput(new Address3(contractId));
|
5306
5584
|
result.missingContractIds.push(contractId);
|
5307
5585
|
});
|
5308
5586
|
const { maxFee } = await this.estimateTxGasAndFee({
|
5309
5587
|
transactionRequest: request
|
5310
5588
|
});
|
5311
5589
|
request.maxFee = maxFee;
|
5312
|
-
serializedTransactionsMap.set(requestIdx,
|
5590
|
+
serializedTransactionsMap.set(requestIdx, hexlify18(request.toTransactionBytes()));
|
5313
5591
|
nextRoundTransactions.push(requestIdx);
|
5314
5592
|
}
|
5315
5593
|
}
|
@@ -5330,13 +5608,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5330
5608
|
if (estimateTxDependencies) {
|
5331
5609
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
5332
5610
|
}
|
5333
|
-
const encodedTransactions = transactionRequests.map((tx) =>
|
5611
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify18(tx.toTransactionBytes()));
|
5334
5612
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5335
5613
|
encodedTransactions,
|
5336
5614
|
utxoValidation: utxoValidation || false
|
5337
5615
|
});
|
5338
5616
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
5339
|
-
const receipts = rawReceipts.map(
|
5617
|
+
const receipts = rawReceipts.map(deserializeReceipt);
|
5340
5618
|
return { receipts, dryRunStatus: status };
|
5341
5619
|
});
|
5342
5620
|
return results;
|
@@ -5368,12 +5646,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5368
5646
|
}
|
5369
5647
|
/**
|
5370
5648
|
* Estimates the transaction gas and fee based on the provided transaction request.
|
5371
|
-
* @param
|
5649
|
+
* @param params - The parameters for estimating the transaction gas and fee.
|
5372
5650
|
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
5373
5651
|
*/
|
5374
5652
|
async estimateTxGasAndFee(params) {
|
5375
|
-
const { transactionRequest } = params;
|
5376
|
-
let
|
5653
|
+
const { transactionRequest, gasPrice: gasPriceParam } = params;
|
5654
|
+
let gasPrice = gasPriceParam;
|
5377
5655
|
await this.autoRefetchConfigs();
|
5378
5656
|
const chainInfo = await this.getChain();
|
5379
5657
|
const { gasPriceFactor, maxGasPerTx } = await this.getGasConfig();
|
@@ -5430,14 +5708,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5430
5708
|
if (estimateTxDependencies) {
|
5431
5709
|
return this.estimateTxDependencies(transactionRequest);
|
5432
5710
|
}
|
5433
|
-
const encodedTransactions = [
|
5711
|
+
const encodedTransactions = [hexlify18(transactionRequest.toTransactionBytes())];
|
5434
5712
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5435
5713
|
encodedTransactions,
|
5436
5714
|
utxoValidation: true
|
5437
5715
|
});
|
5438
5716
|
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
5439
5717
|
const { id, receipts, status } = dryRunStatus;
|
5440
|
-
const processedReceipts = receipts.map(
|
5718
|
+
const processedReceipts = receipts.map(deserializeReceipt);
|
5441
5719
|
return { id, receipts: processedReceipts, status };
|
5442
5720
|
});
|
5443
5721
|
return { receipts: callResult[0].receipts };
|
@@ -5454,7 +5732,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5454
5732
|
*
|
5455
5733
|
* @returns A promise that resolves to the transaction cost object.
|
5456
5734
|
*/
|
5457
|
-
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
5735
|
+
async getTransactionCost(transactionRequestLike, { signatureCallback, gasPrice: gasPriceParam } = {}) {
|
5458
5736
|
const txRequestClone = clone8(transactionRequestify(transactionRequestLike));
|
5459
5737
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
5460
5738
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
@@ -5468,11 +5746,20 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5468
5746
|
await signatureCallback(signedRequest);
|
5469
5747
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
5470
5748
|
}
|
5471
|
-
|
5749
|
+
let gasPrice;
|
5750
|
+
if (gasPriceParam) {
|
5751
|
+
gasPrice = gasPriceParam;
|
5752
|
+
await this.estimatePredicates(signedRequest);
|
5753
|
+
} else {
|
5754
|
+
({ gasPrice } = await this.estimatePredicatesAndGasPrice(signedRequest, 10));
|
5755
|
+
}
|
5472
5756
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
5473
|
-
let { maxFee, maxGas, minFee, minGas,
|
5474
|
-
|
5757
|
+
let { maxFee, maxGas, minFee, minGas, gasLimit } = await this.estimateTxGasAndFee({
|
5758
|
+
// Fetches and returns a gas price
|
5759
|
+
transactionRequest: signedRequest,
|
5760
|
+
gasPrice
|
5475
5761
|
});
|
5762
|
+
let rawReceipts = [];
|
5476
5763
|
let receipts = [];
|
5477
5764
|
let dryRunStatus;
|
5478
5765
|
let missingContractIds = [];
|
@@ -5484,7 +5771,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5484
5771
|
if (signatureCallback) {
|
5485
5772
|
await signatureCallback(txRequestClone);
|
5486
5773
|
}
|
5487
|
-
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
|
5774
|
+
({ rawReceipts, receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
|
5488
5775
|
if (dryRunStatus && "reason" in dryRunStatus) {
|
5489
5776
|
throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
|
5490
5777
|
}
|
@@ -5492,12 +5779,17 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5492
5779
|
const pristineGasUsed = getGasUsedFromReceipts(receipts);
|
5493
5780
|
gasUsed = bn17(pristineGasUsed.muln(GAS_USED_MODIFIER)).max(maxGasPerTx.sub(minGas));
|
5494
5781
|
txRequestClone.gasLimit = gasUsed;
|
5495
|
-
({ maxFee, maxGas, minFee, minGas
|
5782
|
+
({ maxFee, maxGas, minFee, minGas } = await this.estimateTxGasAndFee({
|
5496
5783
|
transactionRequest: txRequestClone,
|
5497
5784
|
gasPrice
|
5498
5785
|
}));
|
5499
5786
|
}
|
5787
|
+
const transactionSummary = {
|
5788
|
+
gasPrice: gasPrice.toString(),
|
5789
|
+
receipts: rawReceipts
|
5790
|
+
};
|
5500
5791
|
return {
|
5792
|
+
rawReceipts,
|
5501
5793
|
receipts,
|
5502
5794
|
gasUsed,
|
5503
5795
|
gasPrice,
|
@@ -5510,7 +5802,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5510
5802
|
addedSignatures,
|
5511
5803
|
estimatedPredicates: txRequestClone.inputs,
|
5512
5804
|
dryRunStatus,
|
5513
|
-
updateMaxFee
|
5805
|
+
updateMaxFee,
|
5806
|
+
transactionSummary
|
5514
5807
|
};
|
5515
5808
|
}
|
5516
5809
|
/**
|
@@ -5523,7 +5816,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5523
5816
|
* @returns A promise that resolves to the coins.
|
5524
5817
|
*/
|
5525
5818
|
async getCoins(owner, assetId, paginationArgs) {
|
5526
|
-
const ownerAddress = Address3
|
5819
|
+
const ownerAddress = new Address3(owner);
|
5527
5820
|
const {
|
5528
5821
|
coins: { edges, pageInfo }
|
5529
5822
|
} = await this.operations.getCoins({
|
@@ -5531,7 +5824,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5531
5824
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
5532
5825
|
inputArgs: paginationArgs
|
5533
5826
|
}),
|
5534
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId &&
|
5827
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify18(assetId) }
|
5535
5828
|
});
|
5536
5829
|
const coins = edges.map(({ node }) => ({
|
5537
5830
|
id: node.utxoId,
|
@@ -5555,24 +5848,34 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5555
5848
|
* @returns A promise that resolves to the resources.
|
5556
5849
|
*/
|
5557
5850
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
5558
|
-
const ownerAddress = Address3
|
5559
|
-
|
5560
|
-
messages: excludedIds?.messages?.map((nonce) =>
|
5561
|
-
utxos: excludedIds?.utxos?.map((id) =>
|
5851
|
+
const ownerAddress = new Address3(owner);
|
5852
|
+
let idsToExclude = {
|
5853
|
+
messages: excludedIds?.messages?.map((nonce) => hexlify18(nonce)) || [],
|
5854
|
+
utxos: excludedIds?.utxos?.map((id) => hexlify18(id)) || []
|
5562
5855
|
};
|
5563
5856
|
if (this.cache) {
|
5564
|
-
const cached = this.cache.getActiveData();
|
5565
|
-
|
5566
|
-
|
5857
|
+
const cached = this.cache.getActiveData(ownerAddress.toB256());
|
5858
|
+
if (cached.utxos.length || cached.messages.length) {
|
5859
|
+
const {
|
5860
|
+
consensusParameters: {
|
5861
|
+
txParameters: { maxInputs }
|
5862
|
+
}
|
5863
|
+
} = await this.getChain();
|
5864
|
+
idsToExclude = adjustResourcesToExclude({
|
5865
|
+
userInput: idsToExclude,
|
5866
|
+
cached,
|
5867
|
+
maxInputs: maxInputs.toNumber()
|
5868
|
+
});
|
5869
|
+
}
|
5567
5870
|
}
|
5568
5871
|
const coinsQuery = {
|
5569
5872
|
owner: ownerAddress.toB256(),
|
5570
5873
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
5571
|
-
assetId:
|
5572
|
-
amount: amount.toString(10),
|
5874
|
+
assetId: hexlify18(assetId),
|
5875
|
+
amount: (amount.eqn(0) ? bn17(1) : amount).toString(10),
|
5573
5876
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
5574
5877
|
})),
|
5575
|
-
excludedIds:
|
5878
|
+
excludedIds: idsToExclude
|
5576
5879
|
};
|
5577
5880
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
5578
5881
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
@@ -5582,8 +5885,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5582
5885
|
amount: bn17(coin.amount),
|
5583
5886
|
assetId: coin.assetId,
|
5584
5887
|
daHeight: bn17(coin.daHeight),
|
5585
|
-
sender: Address3
|
5586
|
-
recipient: Address3
|
5888
|
+
sender: new Address3(coin.sender),
|
5889
|
+
recipient: new Address3(coin.recipient),
|
5587
5890
|
nonce: coin.nonce
|
5588
5891
|
};
|
5589
5892
|
case "Coin":
|
@@ -5630,7 +5933,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5630
5933
|
} = await this.operations.getLatestBlock();
|
5631
5934
|
block = latestBlock;
|
5632
5935
|
} else {
|
5633
|
-
const isblockId = typeof idOrHeight === "string" && idOrHeight
|
5936
|
+
const isblockId = typeof idOrHeight === "string" && isB256(idOrHeight);
|
5634
5937
|
const variables = isblockId ? { blockId: idOrHeight } : { height: bn17(idOrHeight).toString(10) };
|
5635
5938
|
const response = await this.operations.getBlock(variables);
|
5636
5939
|
block = response.block;
|
@@ -5701,8 +6004,10 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5701
6004
|
variables = { blockHeight: bn17(idOrHeight).toString(10) };
|
5702
6005
|
} else if (idOrHeight === "latest") {
|
5703
6006
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
5704
|
-
} else {
|
6007
|
+
} else if (typeof idOrHeight === "string" && isB256(idOrHeight)) {
|
5705
6008
|
variables = { blockId: idOrHeight };
|
6009
|
+
} else {
|
6010
|
+
variables = { blockHeight: bn17(idOrHeight).toString() };
|
5706
6011
|
}
|
5707
6012
|
const { block } = await this.operations.getBlockWithTransactions(variables);
|
5708
6013
|
if (!block) {
|
@@ -5780,6 +6085,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5780
6085
|
}).filter((tx) => tx !== null);
|
5781
6086
|
return { transactions, pageInfo };
|
5782
6087
|
}
|
6088
|
+
/**
|
6089
|
+
* Fetches a compressed block at the specified height.
|
6090
|
+
*
|
6091
|
+
* @param height - The height of the block to fetch.
|
6092
|
+
* @returns The compressed block if available, otherwise `null`.
|
6093
|
+
*/
|
6094
|
+
async daCompressedBlock(height) {
|
6095
|
+
const { daCompressedBlock } = await this.operations.daCompressedBlock({
|
6096
|
+
height
|
6097
|
+
});
|
6098
|
+
if (!daCompressedBlock) {
|
6099
|
+
return null;
|
6100
|
+
}
|
6101
|
+
return daCompressedBlock;
|
6102
|
+
}
|
5783
6103
|
/**
|
5784
6104
|
* Get deployed contract with the given ID.
|
5785
6105
|
*
|
@@ -5802,8 +6122,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5802
6122
|
*/
|
5803
6123
|
async getContractBalance(contractId, assetId) {
|
5804
6124
|
const { contractBalance } = await this.operations.getContractBalance({
|
5805
|
-
contract: Address3
|
5806
|
-
asset:
|
6125
|
+
contract: new Address3(contractId).toB256(),
|
6126
|
+
asset: hexlify18(assetId)
|
5807
6127
|
});
|
5808
6128
|
return bn17(contractBalance.amount, 10);
|
5809
6129
|
}
|
@@ -5815,11 +6135,20 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5815
6135
|
* @returns A promise that resolves to the balance.
|
5816
6136
|
*/
|
5817
6137
|
async getBalance(owner, assetId) {
|
5818
|
-
const
|
5819
|
-
|
5820
|
-
|
6138
|
+
const ownerStr = new Address3(owner).toB256();
|
6139
|
+
const assetIdStr = hexlify18(assetId);
|
6140
|
+
if (!this.features.amount128) {
|
6141
|
+
const { balance: balance2 } = await this.operations.getBalance({
|
6142
|
+
owner: ownerStr,
|
6143
|
+
assetId: assetIdStr
|
6144
|
+
});
|
6145
|
+
return bn17(balance2.amount, 10);
|
6146
|
+
}
|
6147
|
+
const { balance } = await this.operations.getBalanceV2({
|
6148
|
+
owner: ownerStr,
|
6149
|
+
assetId: assetIdStr
|
5821
6150
|
});
|
5822
|
-
return bn17(balance.
|
6151
|
+
return bn17(balance.amountU128, 10);
|
5823
6152
|
}
|
5824
6153
|
/**
|
5825
6154
|
* Returns balances for the given owner.
|
@@ -5828,7 +6157,16 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5828
6157
|
* @param paginationArgs - Pagination arguments (optional).
|
5829
6158
|
* @returns A promise that resolves to the balances.
|
5830
6159
|
*/
|
5831
|
-
async getBalances(owner) {
|
6160
|
+
async getBalances(owner, paginationArgs) {
|
6161
|
+
if (!this.features.balancePagination) {
|
6162
|
+
return this.getBalancesV1(owner, paginationArgs);
|
6163
|
+
}
|
6164
|
+
return this.getBalancesV2(owner, paginationArgs);
|
6165
|
+
}
|
6166
|
+
/**
|
6167
|
+
* @hidden
|
6168
|
+
*/
|
6169
|
+
async getBalancesV1(owner, _paginationArgs) {
|
5832
6170
|
const {
|
5833
6171
|
balances: { edges }
|
5834
6172
|
} = await this.operations.getBalances({
|
@@ -5837,7 +6175,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5837
6175
|
* but the current Fuel-Core implementation does not support pagination yet.
|
5838
6176
|
*/
|
5839
6177
|
first: 1e4,
|
5840
|
-
filter: { owner: Address3
|
6178
|
+
filter: { owner: new Address3(owner).toB256() }
|
5841
6179
|
});
|
5842
6180
|
const balances = edges.map(({ node }) => ({
|
5843
6181
|
assetId: node.assetId,
|
@@ -5845,6 +6183,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5845
6183
|
}));
|
5846
6184
|
return { balances };
|
5847
6185
|
}
|
6186
|
+
/**
|
6187
|
+
* @hidden
|
6188
|
+
*/
|
6189
|
+
async getBalancesV2(owner, paginationArgs) {
|
6190
|
+
const {
|
6191
|
+
balances: { edges, pageInfo }
|
6192
|
+
} = await this.operations.getBalancesV2({
|
6193
|
+
...validatePaginationArgs({
|
6194
|
+
inputArgs: paginationArgs,
|
6195
|
+
paginationLimit: BALANCES_PAGE_SIZE_LIMIT
|
6196
|
+
}),
|
6197
|
+
filter: { owner: new Address3(owner).toB256() }
|
6198
|
+
});
|
6199
|
+
const balances = edges.map(({ node }) => ({
|
6200
|
+
assetId: node.assetId,
|
6201
|
+
amount: bn17(node.amountU128)
|
6202
|
+
}));
|
6203
|
+
return { balances, pageInfo };
|
6204
|
+
}
|
5848
6205
|
/**
|
5849
6206
|
* Returns message for the given address.
|
5850
6207
|
*
|
@@ -5860,7 +6217,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5860
6217
|
inputArgs: paginationArgs,
|
5861
6218
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
|
5862
6219
|
}),
|
5863
|
-
owner: Address3
|
6220
|
+
owner: new Address3(address).toB256()
|
5864
6221
|
});
|
5865
6222
|
const messages = edges.map(({ node }) => ({
|
5866
6223
|
messageId: InputMessageCoder2.getMessageId({
|
@@ -5870,8 +6227,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5870
6227
|
amount: bn17(node.amount),
|
5871
6228
|
data: node.data
|
5872
6229
|
}),
|
5873
|
-
sender: Address3
|
5874
|
-
recipient: Address3
|
6230
|
+
sender: new Address3(node.sender),
|
6231
|
+
recipient: new Address3(node.recipient),
|
5875
6232
|
nonce: node.nonce,
|
5876
6233
|
amount: bn17(node.amount),
|
5877
6234
|
data: InputMessageCoder2.decodeData(node.data),
|
@@ -5911,15 +6268,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5911
6268
|
if (commitBlockHeight) {
|
5912
6269
|
inputObject = {
|
5913
6270
|
...inputObject,
|
5914
|
-
//
|
5915
|
-
// This should
|
6271
|
+
// Convert BN into a number string required on the query
|
6272
|
+
// This should probably be fixed on the fuel client side
|
5916
6273
|
commitBlockHeight: commitBlockHeight.toNumber().toString()
|
5917
6274
|
};
|
5918
6275
|
}
|
5919
6276
|
const result = await this.operations.getMessageProof(inputObject);
|
5920
|
-
if (!result.messageProof) {
|
5921
|
-
return null;
|
5922
|
-
}
|
5923
6277
|
const {
|
5924
6278
|
messageProof,
|
5925
6279
|
messageBlockHeader,
|
@@ -5969,8 +6323,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5969
6323
|
eventInboxRoot: commitBlockHeader.eventInboxRoot,
|
5970
6324
|
stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
|
5971
6325
|
},
|
5972
|
-
sender: Address3
|
5973
|
-
recipient: Address3
|
6326
|
+
sender: new Address3(sender),
|
6327
|
+
recipient: new Address3(recipient),
|
5974
6328
|
nonce,
|
5975
6329
|
amount: bn17(amount),
|
5976
6330
|
data
|
@@ -6028,16 +6382,15 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
6028
6382
|
* @returns A promise that resolves to the result of the check.
|
6029
6383
|
*/
|
6030
6384
|
async isUserAccount(id) {
|
6031
|
-
const
|
6032
|
-
|
6033
|
-
contractId: id,
|
6034
|
-
transactionId: id
|
6035
|
-
});
|
6036
|
-
if (contract || blob || transaction) {
|
6037
|
-
return false;
|
6038
|
-
}
|
6039
|
-
return true;
|
6385
|
+
const type = await this.getAddressType(id);
|
6386
|
+
return type === "Account";
|
6040
6387
|
}
|
6388
|
+
/**
|
6389
|
+
* Determines the type of address based on the provided ID.
|
6390
|
+
*
|
6391
|
+
* @param id - The ID to be checked.
|
6392
|
+
* @returns A promise that resolves to a string indicating the type of address.
|
6393
|
+
*/
|
6041
6394
|
async getAddressType(id) {
|
6042
6395
|
const { contract, blob, transaction } = await this.operations.isUserAccount({
|
6043
6396
|
blobId: id,
|
@@ -6053,6 +6406,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
6053
6406
|
if (transaction) {
|
6054
6407
|
return "Transaction";
|
6055
6408
|
}
|
6409
|
+
try {
|
6410
|
+
const asset = await this.getAssetDetails(id);
|
6411
|
+
if (asset) {
|
6412
|
+
return "Asset";
|
6413
|
+
}
|
6414
|
+
} catch (e) {
|
6415
|
+
}
|
6056
6416
|
return "Account";
|
6057
6417
|
}
|
6058
6418
|
/**
|
@@ -6084,8 +6444,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
6084
6444
|
amount: bn17(rawMessage.amount),
|
6085
6445
|
data: rawMessage.data
|
6086
6446
|
}),
|
6087
|
-
sender: Address3
|
6088
|
-
recipient: Address3
|
6447
|
+
sender: new Address3(rawMessage.sender),
|
6448
|
+
recipient: new Address3(rawMessage.recipient),
|
6089
6449
|
nonce,
|
6090
6450
|
amount: bn17(rawMessage.amount),
|
6091
6451
|
data: InputMessageCoder2.decodeData(rawMessage.data),
|
@@ -6127,6 +6487,19 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
6127
6487
|
statusReason: status.reason
|
6128
6488
|
});
|
6129
6489
|
}
|
6490
|
+
/**
|
6491
|
+
* @hidden
|
6492
|
+
*/
|
6493
|
+
parseEstimatePredicatesResponse(transactionRequest, { inputs }) {
|
6494
|
+
if (inputs) {
|
6495
|
+
inputs.forEach((input, i) => {
|
6496
|
+
if (input && "predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
|
6497
|
+
transactionRequest.inputs[i].predicateGasUsed = input.predicateGasUsed;
|
6498
|
+
}
|
6499
|
+
});
|
6500
|
+
}
|
6501
|
+
return transactionRequest;
|
6502
|
+
}
|
6130
6503
|
};
|
6131
6504
|
var Provider = _Provider;
|
6132
6505
|
_cacheInputs = new WeakSet();
|
@@ -6134,23 +6507,14 @@ cacheInputs_fn = function(inputs, transactionId) {
|
|
6134
6507
|
if (!this.cache) {
|
6135
6508
|
return;
|
6136
6509
|
}
|
6137
|
-
|
6138
|
-
(acc, input) => {
|
6139
|
-
if (input.type === InputType7.Coin) {
|
6140
|
-
acc.utxos.push(input.id);
|
6141
|
-
} else if (input.type === InputType7.Message) {
|
6142
|
-
acc.messages.push(input.nonce);
|
6143
|
-
}
|
6144
|
-
return acc;
|
6145
|
-
},
|
6146
|
-
{ utxos: [], messages: [] }
|
6147
|
-
);
|
6148
|
-
this.cache.set(transactionId, inputsToCache);
|
6510
|
+
this.cache.set(transactionId, inputs);
|
6149
6511
|
};
|
6150
6512
|
/** @hidden */
|
6151
6513
|
__publicField(Provider, "chainInfoCache", {});
|
6152
6514
|
/** @hidden */
|
6153
6515
|
__publicField(Provider, "nodeInfoCache", {});
|
6516
|
+
/** @hidden */
|
6517
|
+
__publicField(Provider, "incompatibleNodeVersionMessage", "");
|
6154
6518
|
|
6155
6519
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6156
6520
|
import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
|
@@ -6158,613 +6522,14 @@ import { bn as bn18 } from "@fuel-ts/math";
|
|
6158
6522
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
6159
6523
|
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
6160
6524
|
|
6161
|
-
// src/providers/
|
6162
|
-
|
6163
|
-
|
6164
|
-
|
6165
|
-
sepolia: 11155111,
|
6166
|
-
foundry: 31337
|
6167
|
-
},
|
6168
|
-
fuel: {
|
6169
|
-
devnet: 0,
|
6170
|
-
testnet: 0,
|
6171
|
-
mainnet: 9889
|
6172
|
-
}
|
6173
|
-
};
|
6174
|
-
|
6175
|
-
// src/providers/assets/utils/url.ts
|
6176
|
-
var DELIMITER_PATH = "/";
|
6177
|
-
var trimRegex = /^\/|\/$/g;
|
6178
|
-
var trimPath = (path2 = "") => path2.replace(trimRegex, "");
|
6179
|
-
function urlJoin(baseUrl, ...paths) {
|
6180
|
-
const hasBaseUrl = baseUrl !== null && baseUrl !== void 0;
|
6181
|
-
const rootPath = baseUrl?.[0] === "/" && baseUrl.length > 1;
|
6182
|
-
const allPaths = [baseUrl, ...paths].filter(Boolean).map(trimPath);
|
6183
|
-
if (rootPath && hasBaseUrl) {
|
6184
|
-
allPaths.unshift("");
|
6185
|
-
}
|
6186
|
-
return allPaths.join(DELIMITER_PATH);
|
6187
|
-
}
|
6188
|
-
|
6189
|
-
// src/providers/assets/utils/resolveIconPaths.ts
|
6190
|
-
function resolveIconPaths(assets2, basePath = "./") {
|
6191
|
-
return assets2.map((asset) => ({
|
6192
|
-
...asset,
|
6193
|
-
icon: urlJoin(basePath, asset.icon)
|
6194
|
-
}));
|
6195
|
-
}
|
6196
|
-
|
6197
|
-
// src/providers/assets/utils/fuelAssetsBaseUrl.ts
|
6198
|
-
var fuelAssetsBaseUrl = "https://cdn.fuel.network/assets/";
|
6199
|
-
|
6200
|
-
// src/providers/assets/assets.ts
|
6201
|
-
var rawAssets = [
|
6202
|
-
{
|
6203
|
-
name: "Ethereum",
|
6204
|
-
symbol: "ETH",
|
6205
|
-
icon: "eth.svg",
|
6206
|
-
networks: [
|
6207
|
-
{
|
6208
|
-
type: "ethereum",
|
6209
|
-
chainId: CHAIN_IDS.eth.sepolia,
|
6210
|
-
decimals: 18
|
6211
|
-
},
|
6212
|
-
{
|
6213
|
-
type: "ethereum",
|
6214
|
-
chainId: CHAIN_IDS.eth.foundry,
|
6215
|
-
decimals: 18
|
6216
|
-
},
|
6217
|
-
{
|
6218
|
-
type: "ethereum",
|
6219
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6220
|
-
decimals: 18
|
6221
|
-
},
|
6222
|
-
{
|
6223
|
-
type: "fuel",
|
6224
|
-
chainId: CHAIN_IDS.fuel.devnet,
|
6225
|
-
decimals: 9,
|
6226
|
-
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6227
|
-
},
|
6228
|
-
{
|
6229
|
-
type: "fuel",
|
6230
|
-
chainId: CHAIN_IDS.fuel.testnet,
|
6231
|
-
decimals: 9,
|
6232
|
-
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6233
|
-
},
|
6234
|
-
{
|
6235
|
-
type: "fuel",
|
6236
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6237
|
-
decimals: 9,
|
6238
|
-
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6239
|
-
}
|
6240
|
-
]
|
6241
|
-
},
|
6242
|
-
{
|
6243
|
-
name: "WETH",
|
6244
|
-
symbol: "WETH",
|
6245
|
-
icon: "weth.svg",
|
6246
|
-
networks: [
|
6247
|
-
{
|
6248
|
-
type: "ethereum",
|
6249
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6250
|
-
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
6251
|
-
decimals: 18
|
6252
|
-
},
|
6253
|
-
{
|
6254
|
-
type: "fuel",
|
6255
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6256
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6257
|
-
assetId: "0xa38a5a8beeb08d95744bc7f58528073f4052b254def59eba20c99c202b5acaa3",
|
6258
|
-
decimals: 9
|
6259
|
-
}
|
6260
|
-
]
|
6261
|
-
},
|
6262
|
-
{
|
6263
|
-
name: "weETH",
|
6264
|
-
symbol: "weETH",
|
6265
|
-
icon: "weETH.webp",
|
6266
|
-
networks: [
|
6267
|
-
{
|
6268
|
-
type: "ethereum",
|
6269
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6270
|
-
address: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
|
6271
|
-
decimals: 18
|
6272
|
-
},
|
6273
|
-
{
|
6274
|
-
type: "fuel",
|
6275
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6276
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6277
|
-
assetId: "0x239ed6e12b7ce4089ee245244e3bf906999a6429c2a9a445a1e1faf56914a4ab",
|
6278
|
-
decimals: 9
|
6279
|
-
}
|
6280
|
-
]
|
6281
|
-
},
|
6282
|
-
{
|
6283
|
-
name: "rsETH",
|
6284
|
-
symbol: "rsETH",
|
6285
|
-
icon: "rsETH.webp",
|
6286
|
-
networks: [
|
6287
|
-
{
|
6288
|
-
type: "ethereum",
|
6289
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6290
|
-
address: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
|
6291
|
-
decimals: 18
|
6292
|
-
},
|
6293
|
-
{
|
6294
|
-
type: "fuel",
|
6295
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6296
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6297
|
-
assetId: "0xbae80f7fb8aa6b90d9b01ef726ec847cc4f59419c4d5f2ea88fec785d1b0e849",
|
6298
|
-
decimals: 9
|
6299
|
-
}
|
6300
|
-
]
|
6301
|
-
},
|
6302
|
-
{
|
6303
|
-
name: "rETH",
|
6304
|
-
symbol: "rETH",
|
6305
|
-
icon: "reth.svg",
|
6306
|
-
networks: [
|
6307
|
-
{
|
6308
|
-
type: "ethereum",
|
6309
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6310
|
-
address: "0xae78736cd615f374d3085123a210448e74fc6393",
|
6311
|
-
decimals: 18
|
6312
|
-
},
|
6313
|
-
{
|
6314
|
-
type: "fuel",
|
6315
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6316
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6317
|
-
assetId: "0xf3f9a0ed0ce8eac5f89d6b83e41b3848212d5b5f56108c54a205bb228ca30c16",
|
6318
|
-
decimals: 9
|
6319
|
-
}
|
6320
|
-
]
|
6321
|
-
},
|
6322
|
-
{
|
6323
|
-
name: "wbETH",
|
6324
|
-
symbol: "wbETH",
|
6325
|
-
icon: "wbeth.png",
|
6326
|
-
networks: [
|
6327
|
-
{
|
6328
|
-
type: "ethereum",
|
6329
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6330
|
-
address: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
|
6331
|
-
decimals: 18
|
6332
|
-
},
|
6333
|
-
{
|
6334
|
-
type: "fuel",
|
6335
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6336
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6337
|
-
assetId: "0x7843c74bef935e837f2bcf67b5d64ecb46dd53ff86375530b0caf3699e8ffafe",
|
6338
|
-
decimals: 9
|
6339
|
-
}
|
6340
|
-
]
|
6341
|
-
},
|
6342
|
-
{
|
6343
|
-
name: "rstETH",
|
6344
|
-
symbol: "rstETH",
|
6345
|
-
icon: "rstETH.webp",
|
6346
|
-
networks: [
|
6347
|
-
{
|
6348
|
-
type: "ethereum",
|
6349
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6350
|
-
address: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
6351
|
-
decimals: 18
|
6352
|
-
},
|
6353
|
-
{
|
6354
|
-
type: "fuel",
|
6355
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6356
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6357
|
-
assetId: "0x962792286fbc9b1d5860b4551362a12249362c21594c77abf4b3fe2bbe8d977a",
|
6358
|
-
decimals: 9
|
6359
|
-
}
|
6360
|
-
]
|
6361
|
-
},
|
6362
|
-
{
|
6363
|
-
name: "amphrETH",
|
6364
|
-
symbol: "amphrETH",
|
6365
|
-
icon: "amphrETH.png",
|
6366
|
-
networks: [
|
6367
|
-
{
|
6368
|
-
type: "ethereum",
|
6369
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6370
|
-
address: "0x5fD13359Ba15A84B76f7F87568309040176167cd",
|
6371
|
-
decimals: 18
|
6372
|
-
},
|
6373
|
-
{
|
6374
|
-
type: "fuel",
|
6375
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6376
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6377
|
-
assetId: "0x05fc623e57bd7bc1258efa8e4f62b05af5471d73df6f2c2dc11ecc81134c4f36",
|
6378
|
-
decimals: 9
|
6379
|
-
}
|
6380
|
-
]
|
6381
|
-
},
|
6382
|
-
{
|
6383
|
-
name: "Manta mBTC",
|
6384
|
-
symbol: "Manta mBTC",
|
6385
|
-
icon: "manta-mbtc.svg",
|
6386
|
-
networks: [
|
6387
|
-
{
|
6388
|
-
type: "ethereum",
|
6389
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6390
|
-
address: "0x4041381e947CFD3D483d67a25C6aa9Dc924250c5",
|
6391
|
-
decimals: 18
|
6392
|
-
},
|
6393
|
-
{
|
6394
|
-
type: "fuel",
|
6395
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6396
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6397
|
-
assetId: "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b",
|
6398
|
-
decimals: 9
|
6399
|
-
}
|
6400
|
-
]
|
6401
|
-
},
|
6402
|
-
{
|
6403
|
-
name: "Manta mETH",
|
6404
|
-
symbol: "Manta mETH",
|
6405
|
-
icon: "manta-meth.svg",
|
6406
|
-
networks: [
|
6407
|
-
{
|
6408
|
-
type: "ethereum",
|
6409
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6410
|
-
address: "0x8CdF550C04Bc9B9F10938368349C9c8051A772b6",
|
6411
|
-
decimals: 18
|
6412
|
-
},
|
6413
|
-
{
|
6414
|
-
type: "fuel",
|
6415
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6416
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6417
|
-
assetId: "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4",
|
6418
|
-
decimals: 9
|
6419
|
-
}
|
6420
|
-
]
|
6421
|
-
},
|
6422
|
-
{
|
6423
|
-
name: "Manta mUSD",
|
6424
|
-
symbol: "Manta mUSD",
|
6425
|
-
icon: "manta-musd.svg",
|
6426
|
-
networks: [
|
6427
|
-
{
|
6428
|
-
type: "ethereum",
|
6429
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6430
|
-
address: "0x3f24E1d7a973867fC2A03fE199E5502514E0e11E",
|
6431
|
-
decimals: 18
|
6432
|
-
},
|
6433
|
-
{
|
6434
|
-
type: "fuel",
|
6435
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6436
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6437
|
-
assetId: "0x89cb9401e55d49c3269654dd1cdfb0e80e57823a4a7db98ba8fc5953b120fef4",
|
6438
|
-
decimals: 9
|
6439
|
-
}
|
6440
|
-
]
|
6441
|
-
},
|
6442
|
-
{
|
6443
|
-
name: "pumpBTC",
|
6444
|
-
symbol: "pumpBTC",
|
6445
|
-
icon: "pumpbtc.webp",
|
6446
|
-
networks: [
|
6447
|
-
{
|
6448
|
-
type: "ethereum",
|
6449
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6450
|
-
address: "0xf469fbd2abcd6b9de8e169d128226c0fc90a012e",
|
6451
|
-
decimals: 8
|
6452
|
-
},
|
6453
|
-
{
|
6454
|
-
type: "fuel",
|
6455
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6456
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6457
|
-
assetId: "0x0aa5eb2bb97ca915288b653a2529355d4dc66de2b37533213f0e4aeee3d3421f",
|
6458
|
-
decimals: 8
|
6459
|
-
}
|
6460
|
-
]
|
6461
|
-
},
|
6462
|
-
{
|
6463
|
-
name: "FBTC",
|
6464
|
-
symbol: "FBTC",
|
6465
|
-
icon: "fbtc.svg",
|
6466
|
-
networks: [
|
6467
|
-
{
|
6468
|
-
type: "ethereum",
|
6469
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6470
|
-
address: "0xc96de26018a54d51c097160568752c4e3bd6c364",
|
6471
|
-
decimals: 8
|
6472
|
-
},
|
6473
|
-
{
|
6474
|
-
type: "fuel",
|
6475
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6476
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6477
|
-
assetId: "0xb5ecb0a1e08e2abbabf624ffea089df933376855f468ade35c6375b00c33996a",
|
6478
|
-
decimals: 8
|
6479
|
-
}
|
6480
|
-
]
|
6481
|
-
},
|
6482
|
-
{
|
6483
|
-
name: "SolvBTC",
|
6484
|
-
symbol: "SolvBTC",
|
6485
|
-
icon: "solvBTC.webp",
|
6486
|
-
networks: [
|
6487
|
-
{
|
6488
|
-
type: "ethereum",
|
6489
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6490
|
-
address: "0x7a56e1c57c7475ccf742a1832b028f0456652f97",
|
6491
|
-
decimals: 18
|
6492
|
-
},
|
6493
|
-
{
|
6494
|
-
type: "fuel",
|
6495
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6496
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6497
|
-
assetId: "0x1186afea9affb88809c210e13e2330b5258c2cef04bb8fff5eff372b7bd3f40f",
|
6498
|
-
decimals: 9
|
6499
|
-
}
|
6500
|
-
]
|
6501
|
-
},
|
6502
|
-
{
|
6503
|
-
name: "SolvBTC.BBN",
|
6504
|
-
symbol: "SolvBTC.BBN",
|
6505
|
-
icon: "SolvBTC.BBN.png",
|
6506
|
-
networks: [
|
6507
|
-
{
|
6508
|
-
type: "ethereum",
|
6509
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6510
|
-
address: "0xd9d920aa40f578ab794426f5c90f6c731d159def",
|
6511
|
-
decimals: 18
|
6512
|
-
},
|
6513
|
-
{
|
6514
|
-
type: "fuel",
|
6515
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6516
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6517
|
-
assetId: "0x7a4f087c957d30218223c2baaaa365355c9ca81b6ea49004cfb1590a5399216f",
|
6518
|
-
decimals: 9
|
6519
|
-
}
|
6520
|
-
]
|
6521
|
-
},
|
6522
|
-
{
|
6523
|
-
name: "Mantle mETH",
|
6524
|
-
symbol: "Mantle mETH",
|
6525
|
-
icon: "mantle-meth.svg",
|
6526
|
-
networks: [
|
6527
|
-
{
|
6528
|
-
type: "ethereum",
|
6529
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6530
|
-
address: "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa",
|
6531
|
-
decimals: 18
|
6532
|
-
},
|
6533
|
-
{
|
6534
|
-
type: "fuel",
|
6535
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6536
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6537
|
-
assetId: "0x642a5db59ec323c2f846d4d4cf3e58d78aff64accf4f8f6455ba0aa3ef000a3b",
|
6538
|
-
decimals: 9
|
6539
|
-
}
|
6540
|
-
]
|
6541
|
-
},
|
6542
|
-
{
|
6543
|
-
name: "sDAI",
|
6544
|
-
symbol: "sDAI",
|
6545
|
-
icon: "sdai.svg",
|
6546
|
-
networks: [
|
6547
|
-
{
|
6548
|
-
type: "ethereum",
|
6549
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6550
|
-
address: "0x83f20f44975d03b1b09e64809b757c47f942beea",
|
6551
|
-
decimals: 18
|
6552
|
-
},
|
6553
|
-
{
|
6554
|
-
type: "fuel",
|
6555
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6556
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6557
|
-
assetId: "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958",
|
6558
|
-
decimals: 9
|
6559
|
-
}
|
6560
|
-
]
|
6561
|
-
},
|
6562
|
-
{
|
6563
|
-
name: "USDT",
|
6564
|
-
symbol: "USDT",
|
6565
|
-
icon: "usdt.svg",
|
6566
|
-
networks: [
|
6567
|
-
{
|
6568
|
-
type: "ethereum",
|
6569
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6570
|
-
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
6571
|
-
decimals: 6
|
6572
|
-
},
|
6573
|
-
{
|
6574
|
-
type: "fuel",
|
6575
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6576
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6577
|
-
assetId: "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e",
|
6578
|
-
decimals: 6
|
6579
|
-
}
|
6580
|
-
]
|
6581
|
-
},
|
6582
|
-
{
|
6583
|
-
name: "USDC",
|
6584
|
-
symbol: "USDC",
|
6585
|
-
icon: "usdc.svg",
|
6586
|
-
networks: [
|
6587
|
-
{
|
6588
|
-
type: "ethereum",
|
6589
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6590
|
-
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
6591
|
-
decimals: 6
|
6592
|
-
},
|
6593
|
-
{
|
6594
|
-
type: "fuel",
|
6595
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6596
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6597
|
-
assetId: "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b",
|
6598
|
-
decimals: 6
|
6599
|
-
}
|
6600
|
-
]
|
6601
|
-
},
|
6602
|
-
{
|
6603
|
-
name: "USDe",
|
6604
|
-
symbol: "USDe",
|
6605
|
-
icon: "USDe.svg",
|
6606
|
-
networks: [
|
6607
|
-
{
|
6608
|
-
type: "ethereum",
|
6609
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6610
|
-
address: "0x4c9edd5852cd905f086c759e8383e09bff1e68b3",
|
6611
|
-
decimals: 18
|
6612
|
-
},
|
6613
|
-
{
|
6614
|
-
type: "fuel",
|
6615
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6616
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6617
|
-
assetId: "0xb6133b2ef9f6153eb869125d23dcf20d1e735331b5e41b15a6a7a6cec70e8651",
|
6618
|
-
decimals: 9
|
6619
|
-
}
|
6620
|
-
]
|
6621
|
-
},
|
6622
|
-
{
|
6623
|
-
name: "sUSDe",
|
6624
|
-
symbol: "sUSDe",
|
6625
|
-
icon: "sUSDe.webp",
|
6626
|
-
networks: [
|
6627
|
-
{
|
6628
|
-
type: "ethereum",
|
6629
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6630
|
-
address: "0x9d39a5de30e57443bff2a8307a4256c8797a3497",
|
6631
|
-
decimals: 18
|
6632
|
-
},
|
6633
|
-
{
|
6634
|
-
type: "fuel",
|
6635
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6636
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6637
|
-
assetId: "0xd05563025104fc36496c15c7021ad6b31034b0e89a356f4f818045d1f48808bc",
|
6638
|
-
decimals: 9
|
6639
|
-
}
|
6640
|
-
]
|
6641
|
-
},
|
6642
|
-
{
|
6643
|
-
name: "rsUSDe",
|
6644
|
-
symbol: "rsUSDe",
|
6645
|
-
icon: "rsUSDe.svg",
|
6646
|
-
networks: [
|
6647
|
-
{
|
6648
|
-
type: "ethereum",
|
6649
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6650
|
-
address: "0x82f5104b23FF2FA54C2345F821dAc9369e9E0B26",
|
6651
|
-
decimals: 18
|
6652
|
-
},
|
6653
|
-
{
|
6654
|
-
type: "fuel",
|
6655
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6656
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6657
|
-
assetId: "0x78d4522ec607f6e8efb66ea49439d1ee48623cf763f9688a8eada025def033d9",
|
6658
|
-
decimals: 9
|
6659
|
-
}
|
6660
|
-
]
|
6661
|
-
},
|
6662
|
-
{
|
6663
|
-
name: "wstETH",
|
6664
|
-
symbol: "wstETH",
|
6665
|
-
icon: "wsteth.svg",
|
6666
|
-
networks: [
|
6667
|
-
{
|
6668
|
-
type: "ethereum",
|
6669
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6670
|
-
address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
6671
|
-
decimals: 18
|
6672
|
-
},
|
6673
|
-
{
|
6674
|
-
type: "fuel",
|
6675
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6676
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6677
|
-
assetId: "0x1a7815cc9f75db5c24a5b0814bfb706bb9fe485333e98254015de8f48f84c67b",
|
6678
|
-
decimals: 9
|
6679
|
-
}
|
6680
|
-
]
|
6681
|
-
},
|
6682
|
-
{
|
6683
|
-
name: "ezETH",
|
6684
|
-
symbol: "ezETH",
|
6685
|
-
icon: "ezeth.webp",
|
6686
|
-
networks: [
|
6687
|
-
{
|
6688
|
-
type: "ethereum",
|
6689
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6690
|
-
address: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
|
6691
|
-
decimals: 18
|
6692
|
-
},
|
6693
|
-
{
|
6694
|
-
type: "fuel",
|
6695
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6696
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6697
|
-
assetId: "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0",
|
6698
|
-
decimals: 9
|
6699
|
-
}
|
6700
|
-
]
|
6701
|
-
},
|
6702
|
-
{
|
6703
|
-
name: "pzETH",
|
6704
|
-
symbol: "pzETH",
|
6705
|
-
icon: "pzETH.webp",
|
6706
|
-
networks: [
|
6707
|
-
{
|
6708
|
-
type: "ethereum",
|
6709
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6710
|
-
address: "0x8c9532a60e0e7c6bbd2b2c1303f63ace1c3e9811",
|
6711
|
-
decimals: 18
|
6712
|
-
},
|
6713
|
-
{
|
6714
|
-
type: "fuel",
|
6715
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6716
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6717
|
-
assetId: "0x1493d4ec82124de8f9b625682de69dcccda79e882b89a55a8c737b12de67bd68",
|
6718
|
-
decimals: 9
|
6719
|
-
}
|
6720
|
-
]
|
6721
|
-
},
|
6722
|
-
{
|
6723
|
-
name: "Re7LRT",
|
6724
|
-
symbol: "Re7LRT",
|
6725
|
-
icon: "Re7LRT.png",
|
6726
|
-
networks: [
|
6727
|
-
{
|
6728
|
-
type: "ethereum",
|
6729
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6730
|
-
address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a",
|
6731
|
-
decimals: 18
|
6732
|
-
},
|
6733
|
-
{
|
6734
|
-
type: "fuel",
|
6735
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6736
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6737
|
-
assetId: "0xf2fc648c23a5db24610a1cf696acc4f0f6d9a7d6028dd9944964ab23f6e35995",
|
6738
|
-
decimals: 9
|
6739
|
-
}
|
6740
|
-
]
|
6741
|
-
},
|
6742
|
-
{
|
6743
|
-
name: "steakLRT",
|
6744
|
-
symbol: "steakLRT",
|
6745
|
-
icon: "steakLRT.png",
|
6746
|
-
networks: [
|
6747
|
-
{
|
6748
|
-
type: "ethereum",
|
6749
|
-
chainId: CHAIN_IDS.eth.mainnet,
|
6750
|
-
address: "0xBEEF69Ac7870777598A04B2bd4771c71212E6aBc",
|
6751
|
-
decimals: 18
|
6752
|
-
},
|
6753
|
-
{
|
6754
|
-
type: "fuel",
|
6755
|
-
chainId: CHAIN_IDS.fuel.mainnet,
|
6756
|
-
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6757
|
-
assetId: "0x4fc8ac9f101df07e2c2dec4a53c8c42c439bdbe5e36ea2d863a61ff60afafc30",
|
6758
|
-
decimals: 9
|
6759
|
-
}
|
6760
|
-
]
|
6761
|
-
}
|
6762
|
-
];
|
6763
|
-
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
6525
|
+
// src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
|
6526
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
6527
|
+
import { TransactionCoder as TransactionCoder7 } from "@fuel-ts/transactions";
|
6528
|
+
import { arrayify as arrayify15 } from "@fuel-ts/utils";
|
6764
6529
|
|
6765
6530
|
// src/test-utils/test-asset-id.ts
|
6766
6531
|
import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
|
6767
|
-
import { hexlify as
|
6532
|
+
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
6768
6533
|
var _TestAssetId = class {
|
6769
6534
|
constructor(value) {
|
6770
6535
|
this.value = value;
|
@@ -6772,7 +6537,7 @@ var _TestAssetId = class {
|
|
6772
6537
|
static random(count = 1) {
|
6773
6538
|
const assetIds = [];
|
6774
6539
|
for (let i = 0; i < count; i++) {
|
6775
|
-
assetIds.push(new _TestAssetId(
|
6540
|
+
assetIds.push(new _TestAssetId(hexlify19(randomBytes4(32))));
|
6776
6541
|
}
|
6777
6542
|
return assetIds;
|
6778
6543
|
}
|
@@ -6788,20 +6553,21 @@ __publicField(TestAssetId, "B", new _TestAssetId(
|
|
6788
6553
|
// src/test-utils/wallet-config.ts
|
6789
6554
|
import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
|
6790
6555
|
import { FuelError as FuelError26 } from "@fuel-ts/errors";
|
6791
|
-
import {
|
6556
|
+
import { bn as bn22 } from "@fuel-ts/math";
|
6557
|
+
import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify25 } from "@fuel-ts/utils";
|
6792
6558
|
|
6793
6559
|
// src/wallet/base-wallet-unlocked.ts
|
6794
6560
|
import { hashMessage } from "@fuel-ts/hasher";
|
6795
|
-
import { hexlify as
|
6561
|
+
import { hexlify as hexlify22 } from "@fuel-ts/utils";
|
6796
6562
|
|
6797
6563
|
// src/account.ts
|
6798
6564
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
6799
6565
|
import { Address as Address5 } from "@fuel-ts/address";
|
6800
6566
|
import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
|
6801
6567
|
import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
|
6802
|
-
import { bn as
|
6803
|
-
import { InputType as
|
6804
|
-
import { arrayify as
|
6568
|
+
import { bn as bn20 } from "@fuel-ts/math";
|
6569
|
+
import { InputType as InputType7 } from "@fuel-ts/transactions";
|
6570
|
+
import { arrayify as arrayify17, hexlify as hexlify20, isDefined as isDefined3 } from "@fuel-ts/utils";
|
6805
6571
|
import { clone as clone9 } from "ramda";
|
6806
6572
|
|
6807
6573
|
// src/providers/utils/merge-quantities.ts
|
@@ -6825,18 +6591,14 @@ var AbstractAccount = class {
|
|
6825
6591
|
// src/utils/formatTransferToContractScriptData.ts
|
6826
6592
|
import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
|
6827
6593
|
import { Address as Address4 } from "@fuel-ts/address";
|
6828
|
-
import { arrayify as
|
6594
|
+
import { arrayify as arrayify16, concat as concat4 } from "@fuel-ts/utils";
|
6829
6595
|
import * as asm from "@fuels/vm-asm";
|
6830
6596
|
var formatTransferToContractScriptData = (transferParams) => {
|
6831
6597
|
const numberCoder = new BigNumberCoder2("u64");
|
6832
6598
|
return transferParams.reduce((acc, transferParam) => {
|
6833
6599
|
const { assetId, amount, contractId } = transferParam;
|
6834
6600
|
const encoded = numberCoder.encode(amount);
|
6835
|
-
const scriptData = concat4([
|
6836
|
-
Address4.fromAddressOrString(contractId).toBytes(),
|
6837
|
-
encoded,
|
6838
|
-
arrayify15(assetId)
|
6839
|
-
]);
|
6601
|
+
const scriptData = concat4([new Address4(contractId).toBytes(), encoded, arrayify16(assetId)]);
|
6840
6602
|
return concat4([acc, scriptData]);
|
6841
6603
|
}, new Uint8Array());
|
6842
6604
|
};
|
@@ -6892,7 +6654,7 @@ var Account = class extends AbstractAccount {
|
|
6892
6654
|
super();
|
6893
6655
|
this._provider = provider;
|
6894
6656
|
this._connector = connector;
|
6895
|
-
this.address = Address5
|
6657
|
+
this.address = new Address5(address);
|
6896
6658
|
}
|
6897
6659
|
/**
|
6898
6660
|
* The provider used to interact with the network.
|
@@ -6980,12 +6742,20 @@ var Account = class extends AbstractAccount {
|
|
6980
6742
|
* @returns A promise that resolves to the funded transaction request.
|
6981
6743
|
*/
|
6982
6744
|
async fund(request, params) {
|
6983
|
-
const {
|
6745
|
+
const {
|
6746
|
+
addedSignatures,
|
6747
|
+
estimatedPredicates,
|
6748
|
+
requiredQuantities,
|
6749
|
+
updateMaxFee,
|
6750
|
+
gasPrice,
|
6751
|
+
transactionSummary
|
6752
|
+
} = params;
|
6753
|
+
const chainId = await this.provider.getChainId();
|
6984
6754
|
const fee = request.maxFee;
|
6985
6755
|
const baseAssetId = await this.provider.getBaseAssetId();
|
6986
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
6756
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn20(0);
|
6987
6757
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
6988
|
-
amount:
|
6758
|
+
amount: bn20(fee),
|
6989
6759
|
assetId: baseAssetId,
|
6990
6760
|
coinQuantities: requiredQuantities
|
6991
6761
|
});
|
@@ -6993,7 +6763,7 @@ var Account = class extends AbstractAccount {
|
|
6993
6763
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
6994
6764
|
quantitiesDict[assetId] = {
|
6995
6765
|
required: amount,
|
6996
|
-
owned:
|
6766
|
+
owned: bn20(0)
|
6997
6767
|
};
|
6998
6768
|
});
|
6999
6769
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -7055,10 +6825,11 @@ var Account = class extends AbstractAccount {
|
|
7055
6825
|
}
|
7056
6826
|
if (needsToBeFunded) {
|
7057
6827
|
throw new FuelError21(
|
7058
|
-
ErrorCode18.
|
6828
|
+
ErrorCode18.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
7059
6829
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
7060
6830
|
);
|
7061
6831
|
}
|
6832
|
+
request.updateState(chainId, "funded", transactionSummary);
|
7062
6833
|
await this.provider.validateTransaction(request);
|
7063
6834
|
request.updatePredicateGasUsed(estimatedPredicates);
|
7064
6835
|
const requestToReestimate = clone9(request);
|
@@ -7130,7 +6901,7 @@ var Account = class extends AbstractAccount {
|
|
7130
6901
|
addTransfer(request, transferParams) {
|
7131
6902
|
const { destination, amount, assetId } = transferParams;
|
7132
6903
|
this.validateTransferAmount(amount);
|
7133
|
-
request.addCoinOutput(Address5
|
6904
|
+
request.addCoinOutput(new Address5(destination), amount, assetId);
|
7134
6905
|
return request;
|
7135
6906
|
}
|
7136
6907
|
/**
|
@@ -7169,9 +6940,9 @@ var Account = class extends AbstractAccount {
|
|
7169
6940
|
const quantities = [];
|
7170
6941
|
const defaultAssetId = await this.provider.getBaseAssetId();
|
7171
6942
|
const transferParams = contractTransferParams.map((transferParam) => {
|
7172
|
-
const amount =
|
7173
|
-
const contractAddress = Address5
|
7174
|
-
const assetId = transferParam.assetId ?
|
6943
|
+
const amount = bn20(transferParam.amount);
|
6944
|
+
const contractAddress = new Address5(transferParam.contractId);
|
6945
|
+
const assetId = transferParam.assetId ? hexlify20(transferParam.assetId) : defaultAssetId;
|
7175
6946
|
if (amount.lte(0)) {
|
7176
6947
|
throw new FuelError21(
|
7177
6948
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
@@ -7201,22 +6972,22 @@ var Account = class extends AbstractAccount {
|
|
7201
6972
|
* @returns A promise that resolves to the transaction response.
|
7202
6973
|
*/
|
7203
6974
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
7204
|
-
const recipientAddress = Address5
|
7205
|
-
const recipientDataArray =
|
6975
|
+
const recipientAddress = new Address5(recipient);
|
6976
|
+
const recipientDataArray = arrayify17(
|
7206
6977
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
7207
6978
|
);
|
7208
|
-
const amountDataArray =
|
7209
|
-
"0x".concat(
|
6979
|
+
const amountDataArray = arrayify17(
|
6980
|
+
"0x".concat(bn20(amount).toHex().substring(2).padStart(16, "0"))
|
7210
6981
|
);
|
7211
6982
|
const script = new Uint8Array([
|
7212
|
-
...
|
6983
|
+
...arrayify17(withdrawScript.bytes),
|
7213
6984
|
...recipientDataArray,
|
7214
6985
|
...amountDataArray
|
7215
6986
|
]);
|
7216
6987
|
const params = { script, ...txParams };
|
7217
6988
|
const baseAssetId = await this.provider.getBaseAssetId();
|
7218
6989
|
let request = new ScriptTransactionRequest(params);
|
7219
|
-
const quantities = [{ amount:
|
6990
|
+
const quantities = [{ amount: bn20(amount), assetId: baseAssetId }];
|
7220
6991
|
const txCost = await this.getTransactionCost(request, { quantities });
|
7221
6992
|
request = this.validateGasLimitAndMaxFee({
|
7222
6993
|
transactionRequest: request,
|
@@ -7237,14 +7008,14 @@ var Account = class extends AbstractAccount {
|
|
7237
7008
|
*
|
7238
7009
|
* @returns A promise that resolves to the transaction cost object.
|
7239
7010
|
*/
|
7240
|
-
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
7011
|
+
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [], gasPrice } = {}) {
|
7241
7012
|
const txRequestClone = clone9(transactionRequestify(transactionRequestLike));
|
7242
7013
|
const baseAssetId = await this.provider.getBaseAssetId();
|
7243
7014
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
7244
7015
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
7245
|
-
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount:
|
7016
|
+
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn20("100000000000000000") }];
|
7246
7017
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
7247
|
-
if (input.type ===
|
7018
|
+
if (input.type === InputType7.Coin) {
|
7248
7019
|
return input.assetId === assetId;
|
7249
7020
|
}
|
7250
7021
|
if (isRequestInputMessageWithoutData(input)) {
|
@@ -7272,7 +7043,8 @@ var Account = class extends AbstractAccount {
|
|
7272
7043
|
({ amount, assetId }) => updateAssetInput(assetId, amount)
|
7273
7044
|
);
|
7274
7045
|
const txCost = await this.provider.getTransactionCost(txRequestClone, {
|
7275
|
-
signatureCallback
|
7046
|
+
signatureCallback,
|
7047
|
+
gasPrice
|
7276
7048
|
});
|
7277
7049
|
return {
|
7278
7050
|
...txCost,
|
@@ -7315,16 +7087,28 @@ var Account = class extends AbstractAccount {
|
|
7315
7087
|
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
7316
7088
|
* @returns A promise that resolves to the transaction response.
|
7317
7089
|
*/
|
7318
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true,
|
7090
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, ...connectorOptions } = {}) {
|
7091
|
+
let transactionRequest = transactionRequestify(transactionRequestLike);
|
7319
7092
|
if (this._connector) {
|
7320
|
-
|
7321
|
-
|
7322
|
-
|
7323
|
-
|
7324
|
-
|
7093
|
+
const { onBeforeSend, skipCustomFee = false } = connectorOptions;
|
7094
|
+
transactionRequest = await this.prepareTransactionForSend(transactionRequest);
|
7095
|
+
const params = {
|
7096
|
+
onBeforeSend,
|
7097
|
+
skipCustomFee,
|
7098
|
+
provider: {
|
7099
|
+
url: this.provider.url,
|
7100
|
+
cache: await serializeProviderCache(this.provider)
|
7101
|
+
},
|
7102
|
+
transactionState: transactionRequest.flag.state,
|
7103
|
+
transactionSummary: await this.prepareTransactionSummary(transactionRequest)
|
7104
|
+
};
|
7105
|
+
const transaction = await this._connector.sendTransaction(
|
7106
|
+
this.address.toString(),
|
7107
|
+
transactionRequest,
|
7108
|
+
params
|
7325
7109
|
);
|
7110
|
+
return typeof transaction === "string" ? this.provider.getTransactionResponse(transaction) : transaction;
|
7326
7111
|
}
|
7327
|
-
const transactionRequest = transactionRequestify(transactionRequestLike);
|
7328
7112
|
if (estimateTxDependencies) {
|
7329
7113
|
await this.provider.estimateTxDependencies(transactionRequest);
|
7330
7114
|
}
|
@@ -7354,16 +7138,38 @@ var Account = class extends AbstractAccount {
|
|
7354
7138
|
*/
|
7355
7139
|
generateFakeResources(coins) {
|
7356
7140
|
return coins.map((coin) => ({
|
7357
|
-
id:
|
7141
|
+
id: hexlify20(randomBytes5(UTXO_ID_LEN3)),
|
7358
7142
|
owner: this.address,
|
7359
|
-
blockCreated:
|
7360
|
-
txCreatedIdx:
|
7143
|
+
blockCreated: bn20(1),
|
7144
|
+
txCreatedIdx: bn20(1),
|
7361
7145
|
...coin
|
7362
7146
|
}));
|
7363
7147
|
}
|
7148
|
+
/** @hidden */
|
7149
|
+
async prepareTransactionForSend(request) {
|
7150
|
+
const { transactionId } = request.flag;
|
7151
|
+
if (!isDefined3(transactionId)) {
|
7152
|
+
return request;
|
7153
|
+
}
|
7154
|
+
const chainId = await this.provider.getChainId();
|
7155
|
+
const currentTransactionId = request.getTransactionId(chainId);
|
7156
|
+
if (transactionId !== currentTransactionId) {
|
7157
|
+
request.updateState(chainId);
|
7158
|
+
}
|
7159
|
+
return request;
|
7160
|
+
}
|
7161
|
+
/** @hidden */
|
7162
|
+
async prepareTransactionSummary(request) {
|
7163
|
+
const chainId = await this.provider.getChainId();
|
7164
|
+
return isDefined3(request.flag.summary) ? {
|
7165
|
+
...request.flag.summary,
|
7166
|
+
id: request.getTransactionId(chainId),
|
7167
|
+
transactionBytes: hexlify20(request.toTransactionBytes())
|
7168
|
+
} : void 0;
|
7169
|
+
}
|
7364
7170
|
/** @hidden * */
|
7365
7171
|
validateTransferAmount(amount) {
|
7366
|
-
if (
|
7172
|
+
if (bn20(amount).lte(0)) {
|
7367
7173
|
throw new FuelError21(
|
7368
7174
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
7369
7175
|
"Transfer amount must be a positive number."
|
@@ -7424,7 +7230,7 @@ import {
|
|
7424
7230
|
randomUUID as randomUUID2
|
7425
7231
|
} from "@fuel-ts/crypto";
|
7426
7232
|
import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
|
7427
|
-
import { hexlify as
|
7233
|
+
import { hexlify as hexlify21 } from "@fuel-ts/utils";
|
7428
7234
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
7429
7235
|
var DEFAULT_KDF_PARAMS_R = 8;
|
7430
7236
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -7438,7 +7244,7 @@ var removeHexPrefix = (hexString) => {
|
|
7438
7244
|
};
|
7439
7245
|
async function encryptKeystoreWallet(privateKey, address, password) {
|
7440
7246
|
const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
|
7441
|
-
const ownerAddress = Address6
|
7247
|
+
const ownerAddress = new Address6(address);
|
7442
7248
|
const salt = randomBytes6(DEFAULT_KEY_SIZE);
|
7443
7249
|
const key = scrypt({
|
7444
7250
|
password: bufferFromString(password),
|
@@ -7506,7 +7312,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7506
7312
|
);
|
7507
7313
|
}
|
7508
7314
|
const buffer = await decryptJsonWalletData(ciphertextBuffer, key, ivBuffer);
|
7509
|
-
const privateKey =
|
7315
|
+
const privateKey = hexlify21(buffer);
|
7510
7316
|
return privateKey;
|
7511
7317
|
}
|
7512
7318
|
|
@@ -7551,7 +7357,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
7551
7357
|
*/
|
7552
7358
|
async signMessage(message) {
|
7553
7359
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
7554
|
-
return
|
7360
|
+
return hexlify22(signedMessage);
|
7555
7361
|
}
|
7556
7362
|
/**
|
7557
7363
|
* Signs a transaction with the wallet's private key.
|
@@ -7564,7 +7370,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
7564
7370
|
const chainId = await this.provider.getChainId();
|
7565
7371
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
7566
7372
|
const signature = await this.signer().sign(hashedTransaction);
|
7567
|
-
return
|
7373
|
+
return hexlify22(signature);
|
7568
7374
|
}
|
7569
7375
|
/**
|
7570
7376
|
* Populates a transaction with the witnesses signature.
|
@@ -7638,14 +7444,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
7638
7444
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
7639
7445
|
import { ErrorCode as ErrorCode22, FuelError as FuelError25 } from "@fuel-ts/errors";
|
7640
7446
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
7641
|
-
import { bn as
|
7642
|
-
import { arrayify as
|
7447
|
+
import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
7448
|
+
import { arrayify as arrayify20, hexlify as hexlify24, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
7643
7449
|
|
7644
7450
|
// src/mnemonic/mnemonic.ts
|
7645
7451
|
import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
7646
7452
|
import { ErrorCode as ErrorCode21, FuelError as FuelError24 } from "@fuel-ts/errors";
|
7647
7453
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
7648
|
-
import { arrayify as
|
7454
|
+
import { arrayify as arrayify19, hexlify as hexlify23, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
7649
7455
|
|
7650
7456
|
// src/wordlists/words/english.ts
|
7651
7457
|
var english = [
|
@@ -9702,7 +9508,7 @@ var english = [
|
|
9702
9508
|
// src/mnemonic/utils.ts
|
9703
9509
|
import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
|
9704
9510
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
9705
|
-
import { arrayify as
|
9511
|
+
import { arrayify as arrayify18 } from "@fuel-ts/utils";
|
9706
9512
|
function getLowerMask(bits) {
|
9707
9513
|
return (1 << bits) - 1;
|
9708
9514
|
}
|
@@ -9737,14 +9543,14 @@ function entropyToMnemonicIndices(entropy) {
|
|
9737
9543
|
}
|
9738
9544
|
}
|
9739
9545
|
const checksumBits = entropy.length / 4;
|
9740
|
-
const checksum =
|
9546
|
+
const checksum = arrayify18(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
9741
9547
|
indices[indices.length - 1] <<= checksumBits;
|
9742
9548
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
9743
9549
|
return indices;
|
9744
9550
|
}
|
9745
9551
|
function mnemonicWordsToEntropy(words, wordlist) {
|
9746
9552
|
const size = Math.ceil(11 * words.length / 8);
|
9747
|
-
const entropy =
|
9553
|
+
const entropy = arrayify18(new Uint8Array(size));
|
9748
9554
|
let offset = 0;
|
9749
9555
|
for (let i = 0; i < words.length; i += 1) {
|
9750
9556
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
@@ -9764,7 +9570,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9764
9570
|
const entropyBits = 32 * words.length / 3;
|
9765
9571
|
const checksumBits = words.length / 3;
|
9766
9572
|
const checksumMask = getUpperMask(checksumBits);
|
9767
|
-
const checksum =
|
9573
|
+
const checksum = arrayify18(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9768
9574
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9769
9575
|
throw new FuelError23(
|
9770
9576
|
ErrorCode20.INVALID_CHECKSUM,
|
@@ -9839,7 +9645,7 @@ var Mnemonic = class {
|
|
9839
9645
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
9840
9646
|
const words = getWords(phrase);
|
9841
9647
|
assertMnemonic(words);
|
9842
|
-
return
|
9648
|
+
return hexlify23(mnemonicWordsToEntropy(words, wordlist));
|
9843
9649
|
}
|
9844
9650
|
/**
|
9845
9651
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -9847,7 +9653,7 @@ var Mnemonic = class {
|
|
9847
9653
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9848
9654
|
*/
|
9849
9655
|
static entropyToMnemonic(entropy, wordlist = english) {
|
9850
|
-
const entropyBytes =
|
9656
|
+
const entropyBytes = arrayify19(entropy);
|
9851
9657
|
assertWordList(wordlist);
|
9852
9658
|
assertEntropy(entropyBytes);
|
9853
9659
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -9916,14 +9722,14 @@ var Mnemonic = class {
|
|
9916
9722
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9917
9723
|
*/
|
9918
9724
|
static masterKeysFromSeed(seed) {
|
9919
|
-
const seedArray =
|
9725
|
+
const seedArray = arrayify19(seed);
|
9920
9726
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9921
9727
|
throw new FuelError24(
|
9922
9728
|
ErrorCode21.INVALID_SEED,
|
9923
9729
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9924
9730
|
);
|
9925
9731
|
}
|
9926
|
-
return
|
9732
|
+
return arrayify19(computeHmac("sha512", MasterSecret, seedArray));
|
9927
9733
|
}
|
9928
9734
|
/**
|
9929
9735
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -9934,7 +9740,7 @@ var Mnemonic = class {
|
|
9934
9740
|
*/
|
9935
9741
|
static seedToExtendedKey(seed, testnet = false) {
|
9936
9742
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
9937
|
-
const prefix =
|
9743
|
+
const prefix = arrayify19(testnet ? TestnetPRV : MainnetPRV);
|
9938
9744
|
const depth = "0x00";
|
9939
9745
|
const fingerprint = "0x00000000";
|
9940
9746
|
const index = "0x00000000";
|
@@ -9964,7 +9770,7 @@ var Mnemonic = class {
|
|
9964
9770
|
* @returns A randomly generated mnemonic
|
9965
9771
|
*/
|
9966
9772
|
static generate(size = 32, extraEntropy = "") {
|
9967
|
-
const entropy = extraEntropy ? sha2563(concat5([randomBytes7(size),
|
9773
|
+
const entropy = extraEntropy ? sha2563(concat5([randomBytes7(size), arrayify19(extraEntropy)])) : randomBytes7(size);
|
9968
9774
|
return Mnemonic.entropyToMnemonic(entropy);
|
9969
9775
|
}
|
9970
9776
|
};
|
@@ -9972,10 +9778,10 @@ var mnemonic_default = Mnemonic;
|
|
9972
9778
|
|
9973
9779
|
// src/hdwallet/hdwallet.ts
|
9974
9780
|
var HARDENED_INDEX = 2147483648;
|
9975
|
-
var MainnetPRV2 =
|
9976
|
-
var MainnetPUB =
|
9977
|
-
var TestnetPRV2 =
|
9978
|
-
var TestnetPUB =
|
9781
|
+
var MainnetPRV2 = hexlify24("0x0488ade4");
|
9782
|
+
var MainnetPUB = hexlify24("0x0488b21e");
|
9783
|
+
var TestnetPRV2 = hexlify24("0x04358394");
|
9784
|
+
var TestnetPUB = hexlify24("0x043587cf");
|
9979
9785
|
function base58check(data) {
|
9980
9786
|
return encodeBase582(concat6([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
9981
9787
|
}
|
@@ -9986,11 +9792,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
9986
9792
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
9987
9793
|
}
|
9988
9794
|
function isPublicExtendedKey(extendedKey) {
|
9989
|
-
return [MainnetPUB, TestnetPUB].includes(
|
9795
|
+
return [MainnetPUB, TestnetPUB].includes(hexlify24(extendedKey.slice(0, 4)));
|
9990
9796
|
}
|
9991
9797
|
function isValidExtendedKey(extendedKey) {
|
9992
9798
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
9993
|
-
|
9799
|
+
hexlify24(extendedKey.slice(0, 4))
|
9994
9800
|
);
|
9995
9801
|
}
|
9996
9802
|
function parsePath(path2, depth = 0) {
|
@@ -10008,8 +9814,8 @@ function parsePath(path2, depth = 0) {
|
|
10008
9814
|
var HDWallet = class {
|
10009
9815
|
depth = 0;
|
10010
9816
|
index = 0;
|
10011
|
-
fingerprint =
|
10012
|
-
parentFingerprint =
|
9817
|
+
fingerprint = hexlify24("0x00000000");
|
9818
|
+
parentFingerprint = hexlify24("0x00000000");
|
10013
9819
|
privateKey;
|
10014
9820
|
publicKey;
|
10015
9821
|
chainCode;
|
@@ -10021,8 +9827,8 @@ var HDWallet = class {
|
|
10021
9827
|
constructor(config) {
|
10022
9828
|
if (config.privateKey) {
|
10023
9829
|
const signer = new Signer(config.privateKey);
|
10024
|
-
this.publicKey =
|
10025
|
-
this.privateKey =
|
9830
|
+
this.publicKey = hexlify24(signer.compressedPublicKey);
|
9831
|
+
this.privateKey = hexlify24(config.privateKey);
|
10026
9832
|
} else {
|
10027
9833
|
if (!config.publicKey) {
|
10028
9834
|
throw new FuelError25(
|
@@ -10030,7 +9836,7 @@ var HDWallet = class {
|
|
10030
9836
|
"Both public and private Key cannot be missing. At least one should be provided."
|
10031
9837
|
);
|
10032
9838
|
}
|
10033
|
-
this.publicKey =
|
9839
|
+
this.publicKey = hexlify24(config.publicKey);
|
10034
9840
|
}
|
10035
9841
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
10036
9842
|
this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
|
@@ -10049,9 +9855,9 @@ var HDWallet = class {
|
|
10049
9855
|
* @returns A new instance of HDWallet on the derived index
|
10050
9856
|
*/
|
10051
9857
|
deriveIndex(index) {
|
10052
|
-
const privateKey = this.privateKey &&
|
10053
|
-
const publicKey =
|
10054
|
-
const chainCode =
|
9858
|
+
const privateKey = this.privateKey && arrayify20(this.privateKey);
|
9859
|
+
const publicKey = arrayify20(this.publicKey);
|
9860
|
+
const chainCode = arrayify20(this.chainCode);
|
10055
9861
|
const data = new Uint8Array(37);
|
10056
9862
|
if (index & HARDENED_INDEX) {
|
10057
9863
|
if (!privateKey) {
|
@@ -10062,15 +9868,15 @@ var HDWallet = class {
|
|
10062
9868
|
}
|
10063
9869
|
data.set(privateKey, 1);
|
10064
9870
|
} else {
|
10065
|
-
data.set(
|
9871
|
+
data.set(arrayify20(this.publicKey));
|
10066
9872
|
}
|
10067
9873
|
data.set(toBytes2(index, 4), 33);
|
10068
|
-
const bytes =
|
9874
|
+
const bytes = arrayify20(computeHmac2("sha512", chainCode, data));
|
10069
9875
|
const IL = bytes.slice(0, 32);
|
10070
9876
|
const IR = bytes.slice(32);
|
10071
9877
|
if (privateKey) {
|
10072
9878
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
10073
|
-
const ki =
|
9879
|
+
const ki = bn21(IL).add(privateKey).mod(N).toBytes(32);
|
10074
9880
|
return new HDWallet({
|
10075
9881
|
privateKey: ki,
|
10076
9882
|
chainCode: IR,
|
@@ -10079,7 +9885,7 @@ var HDWallet = class {
|
|
10079
9885
|
parentFingerprint: this.fingerprint
|
10080
9886
|
});
|
10081
9887
|
}
|
10082
|
-
const signer = new Signer(
|
9888
|
+
const signer = new Signer(hexlify24(IL));
|
10083
9889
|
const Ki = signer.addPoint(publicKey);
|
10084
9890
|
return new HDWallet({
|
10085
9891
|
publicKey: Ki,
|
@@ -10114,12 +9920,12 @@ var HDWallet = class {
|
|
10114
9920
|
);
|
10115
9921
|
}
|
10116
9922
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
10117
|
-
const depth =
|
9923
|
+
const depth = hexlify24(Uint8Array.from([this.depth]));
|
10118
9924
|
const parentFingerprint = this.parentFingerprint;
|
10119
9925
|
const index = toHex(this.index, 4);
|
10120
9926
|
const chainCode = this.chainCode;
|
10121
9927
|
const key = this.privateKey != null && !isPublic ? concat6(["0x00", this.privateKey]) : this.publicKey;
|
10122
|
-
const extendedKey =
|
9928
|
+
const extendedKey = arrayify20(concat6([prefix, depth, parentFingerprint, index, chainCode, key]));
|
10123
9929
|
return base58check(extendedKey);
|
10124
9930
|
}
|
10125
9931
|
/**
|
@@ -10131,13 +9937,13 @@ var HDWallet = class {
|
|
10131
9937
|
static fromSeed(seed) {
|
10132
9938
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
10133
9939
|
return new HDWallet({
|
10134
|
-
chainCode:
|
10135
|
-
privateKey:
|
9940
|
+
chainCode: arrayify20(masterKey.slice(32)),
|
9941
|
+
privateKey: arrayify20(masterKey.slice(0, 32))
|
10136
9942
|
});
|
10137
9943
|
}
|
10138
9944
|
static fromExtendedKey(extendedKey) {
|
10139
|
-
const decoded =
|
10140
|
-
const bytes =
|
9945
|
+
const decoded = hexlify24(toBytes2(decodeBase58(extendedKey)));
|
9946
|
+
const bytes = arrayify20(decoded);
|
10141
9947
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
10142
9948
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
10143
9949
|
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
@@ -10146,9 +9952,9 @@ var HDWallet = class {
|
|
10146
9952
|
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
10147
9953
|
}
|
10148
9954
|
const depth = bytes[4];
|
10149
|
-
const parentFingerprint =
|
10150
|
-
const index = parseInt(
|
10151
|
-
const chainCode =
|
9955
|
+
const parentFingerprint = hexlify24(bytes.slice(5, 9));
|
9956
|
+
const index = parseInt(hexlify24(bytes.slice(9, 13)).substring(2), 16);
|
9957
|
+
const chainCode = hexlify24(bytes.slice(13, 45));
|
10152
9958
|
const key = bytes.slice(45, 78);
|
10153
9959
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
10154
9960
|
throw new FuelError25(
|
@@ -10349,14 +10155,14 @@ var WalletsConfig = class {
|
|
10349
10155
|
constructor(baseAssetId, config) {
|
10350
10156
|
WalletsConfig.validate(config);
|
10351
10157
|
this.options = config;
|
10352
|
-
const { assets
|
10158
|
+
const { assets, coinsPerAsset, amountPerCoin, messages } = this.options;
|
10353
10159
|
this.wallets = this.generateWallets();
|
10354
10160
|
this.initialState = {
|
10355
10161
|
messages: WalletsConfig.createMessages(this.wallets, messages),
|
10356
10162
|
coins: WalletsConfig.createCoins(
|
10357
10163
|
this.wallets,
|
10358
10164
|
baseAssetId,
|
10359
|
-
|
10165
|
+
assets,
|
10360
10166
|
coinsPerAsset,
|
10361
10167
|
amountPerCoin
|
10362
10168
|
)
|
@@ -10381,25 +10187,25 @@ var WalletsConfig = class {
|
|
10381
10187
|
/**
|
10382
10188
|
* Create coins for the wallets in the format that the chain expects.
|
10383
10189
|
*/
|
10384
|
-
static createCoins(wallets, baseAssetId,
|
10190
|
+
static createCoins(wallets, baseAssetId, assets, coinsPerAsset, amountPerCoin) {
|
10385
10191
|
const coins = [];
|
10386
10192
|
let assetIds = [baseAssetId];
|
10387
|
-
if (Array.isArray(
|
10388
|
-
assetIds = assetIds.concat(
|
10193
|
+
if (Array.isArray(assets)) {
|
10194
|
+
assetIds = assetIds.concat(assets.map((a) => a.value));
|
10389
10195
|
} else {
|
10390
|
-
assetIds = assetIds.concat(TestAssetId.random(
|
10196
|
+
assetIds = assetIds.concat(TestAssetId.random(assets - 1).map((a) => a.value));
|
10391
10197
|
}
|
10392
10198
|
wallets.map((wallet) => wallet.address.toHexString()).forEach((walletAddress) => {
|
10393
10199
|
assetIds.forEach((assetId) => {
|
10394
10200
|
for (let index = 0; index < coinsPerAsset; index++) {
|
10395
10201
|
coins.push({
|
10396
|
-
amount: amountPerCoin,
|
10202
|
+
amount: bn22(amountPerCoin).toString(),
|
10397
10203
|
asset_id: assetId,
|
10398
10204
|
owner: walletAddress,
|
10399
10205
|
tx_pointer_block_height: 0,
|
10400
10206
|
tx_pointer_tx_idx: 0,
|
10401
10207
|
output_index: 0,
|
10402
|
-
tx_id:
|
10208
|
+
tx_id: hexlify25(randomBytes8(32))
|
10403
10209
|
});
|
10404
10210
|
}
|
10405
10211
|
});
|
@@ -10408,7 +10214,7 @@ var WalletsConfig = class {
|
|
10408
10214
|
}
|
10409
10215
|
static validate({
|
10410
10216
|
count: wallets,
|
10411
|
-
assets
|
10217
|
+
assets,
|
10412
10218
|
coinsPerAsset,
|
10413
10219
|
amountPerCoin
|
10414
10220
|
}) {
|
@@ -10418,7 +10224,7 @@ var WalletsConfig = class {
|
|
10418
10224
|
"Number of wallets must be greater than zero."
|
10419
10225
|
);
|
10420
10226
|
}
|
10421
|
-
if (Array.isArray(
|
10227
|
+
if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
|
10422
10228
|
throw new FuelError26(
|
10423
10229
|
FuelError26.CODES.INVALID_INPUT_PARAMETERS,
|
10424
10230
|
"Number of assets per wallet must be greater than zero."
|
@@ -10430,7 +10236,7 @@ var WalletsConfig = class {
|
|
10430
10236
|
"Number of coins per asset must be greater than zero."
|
10431
10237
|
);
|
10432
10238
|
}
|
10433
|
-
if (amountPerCoin
|
10239
|
+
if (bn22(amountPerCoin).lt(0)) {
|
10434
10240
|
throw new FuelError26(
|
10435
10241
|
FuelError26.CODES.INVALID_INPUT_PARAMETERS,
|
10436
10242
|
"Amount per coin must be greater than or equal to zero."
|
@@ -10506,8 +10312,8 @@ async function setupTestProviderAndWallets({
|
|
10506
10312
|
// src/test-utils/test-message.ts
|
10507
10313
|
import { Address as Address7 } from "@fuel-ts/address";
|
10508
10314
|
import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
|
10509
|
-
import { bn as
|
10510
|
-
import { hexlify as
|
10315
|
+
import { bn as bn23 } from "@fuel-ts/math";
|
10316
|
+
import { hexlify as hexlify26 } from "@fuel-ts/utils";
|
10511
10317
|
var TestMessage = class {
|
10512
10318
|
sender;
|
10513
10319
|
recipient;
|
@@ -10524,7 +10330,7 @@ var TestMessage = class {
|
|
10524
10330
|
constructor({
|
10525
10331
|
sender = Address7.fromRandom(),
|
10526
10332
|
recipient = Address7.fromRandom(),
|
10527
|
-
nonce =
|
10333
|
+
nonce = hexlify26(randomBytes9(32)),
|
10528
10334
|
amount = 1e6,
|
10529
10335
|
data = "",
|
10530
10336
|
// Will default to empty data in order to be a spendable message
|
@@ -10543,7 +10349,7 @@ var TestMessage = class {
|
|
10543
10349
|
sender: this.sender.toB256(),
|
10544
10350
|
recipient: recipient?.toB256() ?? this.recipient.toB256(),
|
10545
10351
|
nonce: this.nonce,
|
10546
|
-
amount:
|
10352
|
+
amount: bn23(this.amount).toNumber(),
|
10547
10353
|
data,
|
10548
10354
|
da_height: this.da_height
|
10549
10355
|
};
|