@fuel-ts/account 0.94.4 → 0.94.6
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/configs.d.ts +6 -0
- package/dist/configs.d.ts.map +1 -1
- 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 +3 -4
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/types/data-type.d.ts +7 -0
- package/dist/connectors/types/data-type.d.ts.map +1 -1
- package/dist/connectors/types/local-storage.d.ts +0 -1
- package/dist/connectors/types/local-storage.d.ts.map +1 -1
- package/dist/index.global.js +1659 -1135
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1329 -416
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1271 -367
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +169 -0
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/assets.d.ts +1 -1
- package/dist/providers/assets/assets.d.ts.map +1 -1
- package/dist/providers/assets/utils/network.d.ts.map +1 -1
- package/dist/providers/assets/utils/resolveIconPaths.d.ts +1 -1
- package/dist/providers/chains.d.ts +2 -0
- package/dist/providers/chains.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +0 -2
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +17 -4
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/index.d.ts +2 -0
- package/dist/providers/transaction-request/index.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +2 -2
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-request/types.d.ts +8 -2
- package/dist/providers/transaction-request/types.d.ts.map +1 -1
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts +87 -0
- package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/upload-transaction-request.d.ts +82 -0
- package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -0
- package/dist/providers/transaction-request/utils.d.ts +6 -0
- package/dist/providers/transaction-request/utils.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts +3 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/input.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/output.d.ts.map +1 -1
- package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
- package/dist/providers/utils/gas.d.ts +16 -0
- package/dist/providers/utils/gas.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils/resources.d.ts.map +1 -1
- package/dist/test-utils/transactionRequest.d.ts.map +1 -1
- package/dist/test-utils.global.js +1653 -1131
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +1238 -341
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +1195 -300
- package/dist/test-utils.mjs.map +1 -1
- package/dist/wallet-manager/wallet-manager.d.ts +0 -1
- package/dist/wallet-manager/wallet-manager.d.ts.map +1 -1
- package/package.json +18 -17
package/dist/test-utils.js
CHANGED
@@ -374,8 +374,8 @@ var launchNode = async ({
|
|
374
374
|
);
|
375
375
|
|
376
376
|
// src/test-utils/setup-test-provider-and-wallets.ts
|
377
|
-
var
|
378
|
-
var
|
377
|
+
var import_utils45 = require("@fuel-ts/utils");
|
378
|
+
var import_ramda10 = require("ramda");
|
379
379
|
|
380
380
|
// src/providers/coin-quantity.ts
|
381
381
|
var import_math2 = require("@fuel-ts/math");
|
@@ -414,15 +414,15 @@ var addAmountToCoinQuantities = (params) => {
|
|
414
414
|
|
415
415
|
// src/providers/provider.ts
|
416
416
|
var import_address4 = require("@fuel-ts/address");
|
417
|
-
var
|
417
|
+
var import_errors18 = require("@fuel-ts/errors");
|
418
418
|
var import_math19 = require("@fuel-ts/math");
|
419
|
-
var
|
420
|
-
var
|
419
|
+
var import_transactions22 = require("@fuel-ts/transactions");
|
420
|
+
var import_utils30 = require("@fuel-ts/utils");
|
421
421
|
var import_versions = require("@fuel-ts/versions");
|
422
|
-
var
|
422
|
+
var import_utils31 = require("@noble/curves/abstract/utils");
|
423
423
|
var import_graphql_request = require("graphql-request");
|
424
424
|
var import_graphql_tag2 = __toESM(require("graphql-tag"));
|
425
|
-
var
|
425
|
+
var import_ramda8 = require("ramda");
|
426
426
|
|
427
427
|
// src/providers/__generated__/operations.ts
|
428
428
|
var import_graphql_tag = __toESM(require("graphql-tag"));
|
@@ -1370,6 +1370,13 @@ var SubmitAndAwaitDocument = import_graphql_tag.default`
|
|
1370
1370
|
}
|
1371
1371
|
}
|
1372
1372
|
${TransactionStatusSubscriptionFragmentDoc}`;
|
1373
|
+
var SubmitAndAwaitStatusDocument = import_graphql_tag.default`
|
1374
|
+
subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
|
1375
|
+
submitAndAwaitStatus(tx: $encodedTransaction) {
|
1376
|
+
...transactionStatusSubscriptionFragment
|
1377
|
+
}
|
1378
|
+
}
|
1379
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
1373
1380
|
var StatusChangeDocument = import_graphql_tag.default`
|
1374
1381
|
subscription statusChange($transactionId: TransactionId!) {
|
1375
1382
|
statusChange(id: $transactionId) {
|
@@ -1466,6 +1473,9 @@ function getSdk(requester) {
|
|
1466
1473
|
submitAndAwait(variables, options) {
|
1467
1474
|
return requester(SubmitAndAwaitDocument, variables, options);
|
1468
1475
|
},
|
1476
|
+
submitAndAwaitStatus(variables, options) {
|
1477
|
+
return requester(SubmitAndAwaitStatusDocument, variables, options);
|
1478
|
+
},
|
1469
1479
|
statusChange(variables, options) {
|
1470
1480
|
return requester(StatusChangeDocument, variables, options);
|
1471
1481
|
}
|
@@ -1492,7 +1502,9 @@ var _FuelGraphqlSubscriber = class {
|
|
1492
1502
|
Accept: "text/event-stream"
|
1493
1503
|
}
|
1494
1504
|
});
|
1495
|
-
|
1505
|
+
const [errorReader, resultReader] = response.body.tee().map((stream) => stream.getReader());
|
1506
|
+
await new _FuelGraphqlSubscriber(errorReader).next();
|
1507
|
+
return new _FuelGraphqlSubscriber(resultReader);
|
1496
1508
|
}
|
1497
1509
|
events = [];
|
1498
1510
|
parsingLeftover = "";
|
@@ -1535,10 +1547,8 @@ var _FuelGraphqlSubscriber = class {
|
|
1535
1547
|
/**
|
1536
1548
|
* Gets called when `break` is called in a `for-await-of` loop.
|
1537
1549
|
*/
|
1538
|
-
|
1539
|
-
|
1540
|
-
this.stream.releaseLock();
|
1541
|
-
return { done: true, value: void 0 };
|
1550
|
+
return() {
|
1551
|
+
return Promise.resolve({ done: true, value: void 0 });
|
1542
1552
|
}
|
1543
1553
|
[Symbol.asyncIterator]() {
|
1544
1554
|
return this;
|
@@ -1909,12 +1919,12 @@ function assembleReceiptByType(receipt) {
|
|
1909
1919
|
const amount = (0, import_math5.bn)(receipt.amount);
|
1910
1920
|
const data = receipt.data ? (0, import_utils7.arrayify)(receipt.data) : Uint8Array.from([]);
|
1911
1921
|
const digest = hexOrZero(receipt.digest);
|
1912
|
-
const messageId = import_transactions3.
|
1922
|
+
const messageId = import_transactions3.InputMessageCoder.getMessageId({
|
1913
1923
|
sender,
|
1914
1924
|
recipient,
|
1915
1925
|
nonce,
|
1916
1926
|
amount,
|
1917
|
-
data
|
1927
|
+
data: (0, import_utils7.hexlify)(data)
|
1918
1928
|
});
|
1919
1929
|
const receiptMessageOut = {
|
1920
1930
|
type: import_transactions3.ReceiptType.MessageOut,
|
@@ -1931,7 +1941,7 @@ function assembleReceiptByType(receipt) {
|
|
1931
1941
|
case "MINT" /* Mint */: {
|
1932
1942
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1933
1943
|
const subId = hexOrZero(receipt.subId);
|
1934
|
-
const assetId = import_transactions3.
|
1944
|
+
const assetId = (0, import_transactions3.getMintedAssetId)(contractId, subId);
|
1935
1945
|
const mintReceipt = {
|
1936
1946
|
type: import_transactions3.ReceiptType.Mint,
|
1937
1947
|
subId,
|
@@ -1946,7 +1956,7 @@ function assembleReceiptByType(receipt) {
|
|
1946
1956
|
case "BURN" /* Burn */: {
|
1947
1957
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1948
1958
|
const subId = hexOrZero(receipt.subId);
|
1949
|
-
const assetId = import_transactions3.
|
1959
|
+
const assetId = (0, import_transactions3.getMintedAssetId)(contractId, subId);
|
1950
1960
|
const burnReceipt = {
|
1951
1961
|
type: import_transactions3.ReceiptType.Burn,
|
1952
1962
|
subId,
|
@@ -2066,6 +2076,39 @@ function calculateMetadataGasForTxBlob({
|
|
2066
2076
|
const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
|
2067
2077
|
return txId.add(blobLen);
|
2068
2078
|
}
|
2079
|
+
function calculateMetadataGasForTxUpgrade({
|
2080
|
+
gasCosts,
|
2081
|
+
txBytesSize,
|
2082
|
+
consensusSize
|
2083
|
+
}) {
|
2084
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
2085
|
+
if (consensusSize) {
|
2086
|
+
const consensusLen = resolveGasDependentCosts(consensusSize, gasCosts.s256);
|
2087
|
+
txId.add(consensusLen);
|
2088
|
+
}
|
2089
|
+
return txId;
|
2090
|
+
}
|
2091
|
+
function calculateMetadataGasForTxUpload({
|
2092
|
+
gasCosts,
|
2093
|
+
txBytesSize,
|
2094
|
+
subsectionSize,
|
2095
|
+
subsectionsSize
|
2096
|
+
}) {
|
2097
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
2098
|
+
const subsectionLen = resolveGasDependentCosts(subsectionSize, gasCosts.s256);
|
2099
|
+
txId.add(subsectionLen);
|
2100
|
+
const subsectionsLen = resolveGasDependentCosts(subsectionsSize, gasCosts.stateRoot);
|
2101
|
+
txId.add(subsectionsLen);
|
2102
|
+
return txId;
|
2103
|
+
}
|
2104
|
+
function calculateMinGasForTxUpload({
|
2105
|
+
gasCosts,
|
2106
|
+
baseMinGas,
|
2107
|
+
subsectionSize
|
2108
|
+
}) {
|
2109
|
+
const additionalStoragePerByte = (0, import_math6.bn)(gasCosts.newStoragePerByte).mul(subsectionSize);
|
2110
|
+
return (0, import_math6.bn)(baseMinGas).add(additionalStoragePerByte);
|
2111
|
+
}
|
2069
2112
|
var calculateGasFee = (params) => {
|
2070
2113
|
const { gas, gasPrice, priceFactor, tip } = params;
|
2071
2114
|
return gas.mul(gasPrice).div(priceFactor).add((0, import_math6.bn)(tip));
|
@@ -3208,50 +3251,313 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
3208
3251
|
}
|
3209
3252
|
};
|
3210
3253
|
|
3211
|
-
// src/providers/transaction-request/
|
3254
|
+
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3212
3255
|
var import_errors11 = require("@fuel-ts/errors");
|
3256
|
+
var import_hasher3 = require("@fuel-ts/hasher");
|
3213
3257
|
var import_transactions11 = require("@fuel-ts/transactions");
|
3258
|
+
var import_utils19 = require("@fuel-ts/utils");
|
3259
|
+
var import_ramda6 = require("ramda");
|
3260
|
+
var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
3261
|
+
static from(obj) {
|
3262
|
+
if (obj instanceof UpgradeTransactionRequest) {
|
3263
|
+
return obj;
|
3264
|
+
}
|
3265
|
+
return new this((0, import_ramda6.clone)(obj));
|
3266
|
+
}
|
3267
|
+
/** The type of transaction */
|
3268
|
+
type = import_transactions11.TransactionType.Upgrade;
|
3269
|
+
/** The upgrade purpose */
|
3270
|
+
upgradePurpose;
|
3271
|
+
/** Witness index of consensus */
|
3272
|
+
bytecodeWitnessIndex;
|
3273
|
+
/**
|
3274
|
+
* Creates an instance `UpgradeTransactionRequest`.
|
3275
|
+
*
|
3276
|
+
* @param upgradeTransactionRequestLike - The initial values for the instance
|
3277
|
+
*/
|
3278
|
+
constructor({
|
3279
|
+
upgradePurpose,
|
3280
|
+
bytecodeWitnessIndex,
|
3281
|
+
...rest
|
3282
|
+
} = {}) {
|
3283
|
+
super(rest);
|
3284
|
+
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
3285
|
+
this.upgradePurpose = upgradePurpose ?? {
|
3286
|
+
type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
|
3287
|
+
checksum: "0x"
|
3288
|
+
};
|
3289
|
+
}
|
3290
|
+
/**
|
3291
|
+
* Adds a consensus parameters upgrade purpose.
|
3292
|
+
*
|
3293
|
+
* @param consensus - The consensus bytecode.
|
3294
|
+
*
|
3295
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3296
|
+
*/
|
3297
|
+
addConsensusParametersUpgradePurpose(consensus) {
|
3298
|
+
this.bytecodeWitnessIndex = this.addWitness(consensus);
|
3299
|
+
this.upgradePurpose = {
|
3300
|
+
type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
|
3301
|
+
checksum: (0, import_hasher3.hash)(consensus)
|
3302
|
+
};
|
3303
|
+
return this;
|
3304
|
+
}
|
3305
|
+
/**
|
3306
|
+
* Adds a state transition upgrade purpose.
|
3307
|
+
*
|
3308
|
+
* @param bytecodeRoot - The Merkle root of the state transition.
|
3309
|
+
*
|
3310
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3311
|
+
*/
|
3312
|
+
addStateTransitionUpgradePurpose(bytecodeRoot) {
|
3313
|
+
this.upgradePurpose = {
|
3314
|
+
type: import_transactions11.UpgradePurposeTypeEnum.StateTransition,
|
3315
|
+
data: (0, import_utils19.hexlify)(bytecodeRoot)
|
3316
|
+
};
|
3317
|
+
return this;
|
3318
|
+
}
|
3319
|
+
/**
|
3320
|
+
* Adds an upgrade purpose.
|
3321
|
+
*
|
3322
|
+
* @param type - The upgrade purpose type.
|
3323
|
+
* @param data - The bytecode or merkle root of upgrade purpose
|
3324
|
+
*
|
3325
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3326
|
+
*/
|
3327
|
+
addUpgradePurpose(type, data) {
|
3328
|
+
if (type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
|
3329
|
+
this.addConsensusParametersUpgradePurpose(data);
|
3330
|
+
}
|
3331
|
+
if (type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
|
3332
|
+
this.addStateTransitionUpgradePurpose(data);
|
3333
|
+
}
|
3334
|
+
return this;
|
3335
|
+
}
|
3336
|
+
/**
|
3337
|
+
* Converts the transaction request to a `TransactionUpgrade`.
|
3338
|
+
*
|
3339
|
+
* @returns The transaction create object.
|
3340
|
+
*/
|
3341
|
+
toTransaction() {
|
3342
|
+
let upgradePurpose;
|
3343
|
+
if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
|
3344
|
+
upgradePurpose = {
|
3345
|
+
type: import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters,
|
3346
|
+
data: {
|
3347
|
+
witnessIndex: this.bytecodeWitnessIndex,
|
3348
|
+
checksum: this.upgradePurpose.checksum
|
3349
|
+
}
|
3350
|
+
};
|
3351
|
+
} else if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
|
3352
|
+
upgradePurpose = {
|
3353
|
+
type: import_transactions11.UpgradePurposeTypeEnum.StateTransition,
|
3354
|
+
data: {
|
3355
|
+
bytecodeRoot: (0, import_utils19.hexlify)(this.upgradePurpose.data)
|
3356
|
+
}
|
3357
|
+
};
|
3358
|
+
} else {
|
3359
|
+
throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3360
|
+
}
|
3361
|
+
return {
|
3362
|
+
type: import_transactions11.TransactionType.Upgrade,
|
3363
|
+
...super.getBaseTransaction(),
|
3364
|
+
upgradePurpose
|
3365
|
+
};
|
3366
|
+
}
|
3367
|
+
/**
|
3368
|
+
* Gets the Transaction ID by hashing the transaction
|
3369
|
+
*
|
3370
|
+
* @param chainId - The chain ID.
|
3371
|
+
*
|
3372
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
3373
|
+
*/
|
3374
|
+
getTransactionId(chainId) {
|
3375
|
+
return hashTransaction(this, chainId);
|
3376
|
+
}
|
3377
|
+
/**
|
3378
|
+
* Calculates the metadata gas cost for an upgrade transaction.
|
3379
|
+
*
|
3380
|
+
* @param gasCosts - gas costs passed from the chain.
|
3381
|
+
*
|
3382
|
+
* @returns metadata gas cost for the upgrade transaction.
|
3383
|
+
*/
|
3384
|
+
metadataGas(gasCosts) {
|
3385
|
+
const txBytesSize = this.byteSize();
|
3386
|
+
if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.ConsensusParameters) {
|
3387
|
+
const witnessIndex = this.bytecodeWitnessIndex;
|
3388
|
+
const consensusSize = this.witnesses[witnessIndex].length;
|
3389
|
+
return calculateMetadataGasForTxUpgrade({
|
3390
|
+
gasCosts,
|
3391
|
+
txBytesSize,
|
3392
|
+
consensusSize
|
3393
|
+
});
|
3394
|
+
}
|
3395
|
+
if (this.upgradePurpose.type === import_transactions11.UpgradePurposeTypeEnum.StateTransition) {
|
3396
|
+
return calculateMetadataGasForTxUpgrade({
|
3397
|
+
gasCosts,
|
3398
|
+
txBytesSize
|
3399
|
+
});
|
3400
|
+
}
|
3401
|
+
throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3402
|
+
}
|
3403
|
+
};
|
3404
|
+
|
3405
|
+
// src/providers/transaction-request/upload-transaction-request.ts
|
3406
|
+
var import_configs10 = require("@fuel-ts/address/configs");
|
3407
|
+
var import_transactions12 = require("@fuel-ts/transactions");
|
3408
|
+
var import_utils21 = require("@fuel-ts/utils");
|
3409
|
+
var import_ramda7 = require("ramda");
|
3410
|
+
var UploadTransactionRequest = class extends BaseTransactionRequest {
|
3411
|
+
static from(obj) {
|
3412
|
+
if (obj instanceof UploadTransactionRequest) {
|
3413
|
+
return obj;
|
3414
|
+
}
|
3415
|
+
return new this((0, import_ramda7.clone)(obj));
|
3416
|
+
}
|
3417
|
+
/** Type of the transaction */
|
3418
|
+
type = import_transactions12.TransactionType.Upload;
|
3419
|
+
/** The witness index of the subsection of the bytecode. */
|
3420
|
+
witnessIndex;
|
3421
|
+
/** The subsection data. */
|
3422
|
+
subsection;
|
3423
|
+
/**
|
3424
|
+
* Creates an instance `UploadTransactionRequest`.
|
3425
|
+
*
|
3426
|
+
* @param uploadTransactionRequestLike - The initial values for the instance
|
3427
|
+
*/
|
3428
|
+
constructor({ witnessIndex, subsection, ...rest } = {}) {
|
3429
|
+
super(rest);
|
3430
|
+
this.witnessIndex = witnessIndex ?? 0;
|
3431
|
+
this.subsection = subsection ?? {
|
3432
|
+
proofSet: [],
|
3433
|
+
root: import_configs10.ZeroBytes32,
|
3434
|
+
subsectionIndex: 0,
|
3435
|
+
subsectionsNumber: 0
|
3436
|
+
};
|
3437
|
+
}
|
3438
|
+
/**
|
3439
|
+
* Adds the subsection.
|
3440
|
+
*
|
3441
|
+
* @param subsection - The subsection data.
|
3442
|
+
*/
|
3443
|
+
addSubsection(subsection) {
|
3444
|
+
const { subsection: subsectionBytecode, ...rest } = subsection;
|
3445
|
+
this.subsection = rest;
|
3446
|
+
this.witnessIndex = this.addWitness(subsectionBytecode);
|
3447
|
+
}
|
3448
|
+
/**
|
3449
|
+
* Gets the Transaction Request by hashing the transaction.
|
3450
|
+
*
|
3451
|
+
* @param chainId - The chain ID.
|
3452
|
+
*
|
3453
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
3454
|
+
*/
|
3455
|
+
getTransactionId(chainId) {
|
3456
|
+
return hashTransaction(this, chainId);
|
3457
|
+
}
|
3458
|
+
/**
|
3459
|
+
* Converts the transaction request to a `TransactionUpload`.
|
3460
|
+
*
|
3461
|
+
* @returns The transaction create object.
|
3462
|
+
*/
|
3463
|
+
toTransaction() {
|
3464
|
+
const baseTransaction = this.getBaseTransaction();
|
3465
|
+
const { subsectionIndex, subsectionsNumber, root, proofSet } = this.subsection;
|
3466
|
+
return {
|
3467
|
+
type: import_transactions12.TransactionType.Upload,
|
3468
|
+
...baseTransaction,
|
3469
|
+
subsectionIndex,
|
3470
|
+
subsectionsNumber,
|
3471
|
+
root: (0, import_utils21.hexlify)(root),
|
3472
|
+
proofSet: proofSet.map(import_utils21.hexlify),
|
3473
|
+
witnessIndex: this.witnessIndex,
|
3474
|
+
proofSetCount: proofSet.length
|
3475
|
+
};
|
3476
|
+
}
|
3477
|
+
/**
|
3478
|
+
* Calculates the metadata gas cost for an upload transaction.
|
3479
|
+
*
|
3480
|
+
* @param gasCosts - gas costs passed from the chain.
|
3481
|
+
*
|
3482
|
+
* @returns metadata gas cost for the upload transaction.
|
3483
|
+
*/
|
3484
|
+
metadataGas(gasCosts) {
|
3485
|
+
return calculateMetadataGasForTxUpload({
|
3486
|
+
gasCosts,
|
3487
|
+
txBytesSize: this.byteSize(),
|
3488
|
+
subsectionSize: (0, import_utils21.arrayify)(this.witnesses[this.witnessIndex]).length,
|
3489
|
+
subsectionsSize: this.subsection.subsectionsNumber
|
3490
|
+
});
|
3491
|
+
}
|
3492
|
+
/**
|
3493
|
+
* Calculates the minimum gas for an upload transaction.
|
3494
|
+
*
|
3495
|
+
* @param chainInfo - The chain information.
|
3496
|
+
*
|
3497
|
+
* @returns the minimum gas for the upload transaction
|
3498
|
+
*/
|
3499
|
+
calculateMinGas(chainInfo) {
|
3500
|
+
const minGas = super.calculateMinGas(chainInfo);
|
3501
|
+
const { gasCosts } = chainInfo.consensusParameters;
|
3502
|
+
const bytecode = this.witnesses[this.witnessIndex] ?? import_configs10.ZeroBytes32;
|
3503
|
+
return calculateMinGasForTxUpload({
|
3504
|
+
gasCosts,
|
3505
|
+
baseMinGas: minGas.toNumber(),
|
3506
|
+
subsectionSize: (0, import_utils21.arrayify)(bytecode).length
|
3507
|
+
});
|
3508
|
+
}
|
3509
|
+
};
|
3510
|
+
|
3511
|
+
// src/providers/transaction-request/utils.ts
|
3512
|
+
var import_errors12 = require("@fuel-ts/errors");
|
3513
|
+
var import_transactions13 = require("@fuel-ts/transactions");
|
3214
3514
|
var transactionRequestify = (obj) => {
|
3215
|
-
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest) {
|
3515
|
+
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
3216
3516
|
return obj;
|
3217
3517
|
}
|
3218
3518
|
const { type } = obj;
|
3219
3519
|
switch (obj.type) {
|
3220
|
-
case
|
3520
|
+
case import_transactions13.TransactionType.Script: {
|
3221
3521
|
return ScriptTransactionRequest.from(obj);
|
3222
3522
|
}
|
3223
|
-
case
|
3523
|
+
case import_transactions13.TransactionType.Create: {
|
3224
3524
|
return CreateTransactionRequest.from(obj);
|
3225
3525
|
}
|
3226
|
-
case
|
3526
|
+
case import_transactions13.TransactionType.Blob: {
|
3227
3527
|
return BlobTransactionRequest.from(obj);
|
3228
3528
|
}
|
3529
|
+
case import_transactions13.TransactionType.Upgrade: {
|
3530
|
+
return UpgradeTransactionRequest.from(obj);
|
3531
|
+
}
|
3532
|
+
case import_transactions13.TransactionType.Upload: {
|
3533
|
+
return UploadTransactionRequest.from(obj);
|
3534
|
+
}
|
3229
3535
|
default: {
|
3230
|
-
throw new
|
3231
|
-
|
3536
|
+
throw new import_errors12.FuelError(
|
3537
|
+
import_errors12.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3232
3538
|
`Unsupported transaction type: ${type}.`
|
3233
3539
|
);
|
3234
3540
|
}
|
3235
3541
|
}
|
3236
3542
|
};
|
3237
|
-
var isTransactionTypeScript = (request) => request.type ===
|
3238
|
-
var isTransactionTypeCreate = (request) => request.type ===
|
3543
|
+
var isTransactionTypeScript = (request) => request.type === import_transactions13.TransactionType.Script;
|
3544
|
+
var isTransactionTypeCreate = (request) => request.type === import_transactions13.TransactionType.Create;
|
3239
3545
|
|
3240
3546
|
// src/providers/transaction-response/transaction-response.ts
|
3241
|
-
var
|
3547
|
+
var import_errors16 = require("@fuel-ts/errors");
|
3242
3548
|
var import_math18 = require("@fuel-ts/math");
|
3243
|
-
var
|
3244
|
-
var
|
3549
|
+
var import_transactions21 = require("@fuel-ts/transactions");
|
3550
|
+
var import_utils27 = require("@fuel-ts/utils");
|
3245
3551
|
|
3246
3552
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
3247
3553
|
var import_math17 = require("@fuel-ts/math");
|
3248
|
-
var
|
3249
|
-
var
|
3554
|
+
var import_transactions19 = require("@fuel-ts/transactions");
|
3555
|
+
var import_utils25 = require("@fuel-ts/utils");
|
3250
3556
|
|
3251
3557
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
3252
3558
|
var import_math13 = require("@fuel-ts/math");
|
3253
|
-
var
|
3254
|
-
var
|
3559
|
+
var import_transactions14 = require("@fuel-ts/transactions");
|
3560
|
+
var import_utils23 = require("@fuel-ts/utils");
|
3255
3561
|
var calculateTXFeeForSummary = (params) => {
|
3256
3562
|
const {
|
3257
3563
|
gasPrice,
|
@@ -3265,17 +3571,17 @@ var calculateTXFeeForSummary = (params) => {
|
|
3265
3571
|
}
|
3266
3572
|
const gasPerByte = (0, import_math13.bn)(feeParams.gasPerByte);
|
3267
3573
|
const gasPriceFactor = (0, import_math13.bn)(feeParams.gasPriceFactor);
|
3268
|
-
const transactionBytes = (0,
|
3269
|
-
const [transaction] = new
|
3574
|
+
const transactionBytes = (0, import_utils23.arrayify)(rawPayload);
|
3575
|
+
const [transaction] = new import_transactions14.TransactionCoder().decode(transactionBytes, 0);
|
3270
3576
|
const { type, witnesses, inputs, policies } = transaction;
|
3271
3577
|
let metadataGas = (0, import_math13.bn)(0);
|
3272
3578
|
let gasLimit = (0, import_math13.bn)(0);
|
3273
|
-
if (type !==
|
3579
|
+
if (type !== import_transactions14.TransactionType.Create && type !== import_transactions14.TransactionType.Script) {
|
3274
3580
|
return (0, import_math13.bn)(0);
|
3275
3581
|
}
|
3276
|
-
if (type ===
|
3582
|
+
if (type === import_transactions14.TransactionType.Create) {
|
3277
3583
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
3278
|
-
const contractBytesSize = (0, import_math13.bn)((0,
|
3584
|
+
const contractBytesSize = (0, import_math13.bn)((0, import_utils23.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
|
3279
3585
|
metadataGas = calculateMetadataGasForTxCreate({
|
3280
3586
|
contractBytesSize,
|
3281
3587
|
gasCosts,
|
@@ -3299,7 +3605,7 @@ var calculateTXFeeForSummary = (params) => {
|
|
3299
3605
|
metadataGas,
|
3300
3606
|
txBytesSize: transactionBytes.length
|
3301
3607
|
});
|
3302
|
-
const witnessLimit = policies.find((policy) => policy.type ===
|
3608
|
+
const witnessLimit = policies.find((policy) => policy.type === import_transactions14.PolicyType.WitnessLimit)?.data;
|
3303
3609
|
const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
|
3304
3610
|
const maxGas = getMaxGas({
|
3305
3611
|
gasPerByte,
|
@@ -3319,10 +3625,10 @@ var calculateTXFeeForSummary = (params) => {
|
|
3319
3625
|
};
|
3320
3626
|
|
3321
3627
|
// src/providers/transaction-summary/operations.ts
|
3322
|
-
var
|
3323
|
-
var
|
3628
|
+
var import_configs11 = require("@fuel-ts/address/configs");
|
3629
|
+
var import_errors14 = require("@fuel-ts/errors");
|
3324
3630
|
var import_math15 = require("@fuel-ts/math");
|
3325
|
-
var
|
3631
|
+
var import_transactions17 = require("@fuel-ts/transactions");
|
3326
3632
|
|
3327
3633
|
// src/providers/transaction-summary/call.ts
|
3328
3634
|
var import_abi_coder5 = require("@fuel-ts/abi-coder");
|
@@ -3358,9 +3664,9 @@ var getFunctionCall = ({ abi, receipt }) => {
|
|
3358
3664
|
};
|
3359
3665
|
|
3360
3666
|
// src/providers/transaction-summary/input.ts
|
3361
|
-
var
|
3667
|
+
var import_errors13 = require("@fuel-ts/errors");
|
3362
3668
|
var import_math14 = require("@fuel-ts/math");
|
3363
|
-
var
|
3669
|
+
var import_transactions15 = require("@fuel-ts/transactions");
|
3364
3670
|
function getInputsByTypes(inputs, types) {
|
3365
3671
|
return inputs.filter((i) => types.includes(i.type));
|
3366
3672
|
}
|
@@ -3368,19 +3674,19 @@ function getInputsByType(inputs, type) {
|
|
3368
3674
|
return inputs.filter((i) => i.type === type);
|
3369
3675
|
}
|
3370
3676
|
function getInputsCoin(inputs) {
|
3371
|
-
return getInputsByType(inputs,
|
3677
|
+
return getInputsByType(inputs, import_transactions15.InputType.Coin);
|
3372
3678
|
}
|
3373
3679
|
function getInputsMessage(inputs) {
|
3374
|
-
return getInputsByType(inputs,
|
3680
|
+
return getInputsByType(inputs, import_transactions15.InputType.Message);
|
3375
3681
|
}
|
3376
3682
|
function getInputsCoinAndMessage(inputs) {
|
3377
|
-
return getInputsByTypes(inputs, [
|
3683
|
+
return getInputsByTypes(inputs, [import_transactions15.InputType.Coin, import_transactions15.InputType.Message]);
|
3378
3684
|
}
|
3379
3685
|
function isInputCoin(input) {
|
3380
|
-
return input.type ===
|
3686
|
+
return input.type === import_transactions15.InputType.Coin;
|
3381
3687
|
}
|
3382
3688
|
function getInputsContract(inputs) {
|
3383
|
-
return getInputsByType(inputs,
|
3689
|
+
return getInputsByType(inputs, import_transactions15.InputType.Contract);
|
3384
3690
|
}
|
3385
3691
|
function findCoinInput(inputs, assetId) {
|
3386
3692
|
const coinInputs = getInputsCoin(inputs);
|
@@ -3426,40 +3732,40 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3426
3732
|
if (!contractInput) {
|
3427
3733
|
return void 0;
|
3428
3734
|
}
|
3429
|
-
if (contractInput.type !==
|
3430
|
-
throw new
|
3431
|
-
|
3735
|
+
if (contractInput.type !== import_transactions15.InputType.Contract) {
|
3736
|
+
throw new import_errors13.FuelError(
|
3737
|
+
import_errors13.ErrorCode.INVALID_TRANSACTION_INPUT,
|
3432
3738
|
`Contract input should be of type 'contract'.`
|
3433
3739
|
);
|
3434
3740
|
}
|
3435
3741
|
return contractInput;
|
3436
3742
|
}
|
3437
3743
|
function getInputAccountAddress(input) {
|
3438
|
-
if (input.type ===
|
3744
|
+
if (input.type === import_transactions15.InputType.Coin) {
|
3439
3745
|
return input.owner.toString();
|
3440
3746
|
}
|
3441
|
-
if (input.type ===
|
3747
|
+
if (input.type === import_transactions15.InputType.Message) {
|
3442
3748
|
return input.recipient.toString();
|
3443
3749
|
}
|
3444
3750
|
return "";
|
3445
3751
|
}
|
3446
3752
|
|
3447
3753
|
// src/providers/transaction-summary/output.ts
|
3448
|
-
var
|
3754
|
+
var import_transactions16 = require("@fuel-ts/transactions");
|
3449
3755
|
function getOutputsByType(outputs, type) {
|
3450
3756
|
return outputs.filter((o) => o.type === type);
|
3451
3757
|
}
|
3452
3758
|
function getOutputsContractCreated(outputs) {
|
3453
|
-
return getOutputsByType(outputs,
|
3759
|
+
return getOutputsByType(outputs, import_transactions16.OutputType.ContractCreated);
|
3454
3760
|
}
|
3455
3761
|
function getOutputsCoin(outputs) {
|
3456
|
-
return getOutputsByType(outputs,
|
3762
|
+
return getOutputsByType(outputs, import_transactions16.OutputType.Coin);
|
3457
3763
|
}
|
3458
3764
|
function getOutputsChange(outputs) {
|
3459
|
-
return getOutputsByType(outputs,
|
3765
|
+
return getOutputsByType(outputs, import_transactions16.OutputType.Change);
|
3460
3766
|
}
|
3461
3767
|
function getOutputsContract(outputs) {
|
3462
|
-
return getOutputsByType(outputs,
|
3768
|
+
return getOutputsByType(outputs, import_transactions16.OutputType.Contract);
|
3463
3769
|
}
|
3464
3770
|
|
3465
3771
|
// src/providers/transaction-summary/operations.ts
|
@@ -3468,17 +3774,21 @@ function getReceiptsByType(receipts, type) {
|
|
3468
3774
|
}
|
3469
3775
|
function getTransactionTypeName(transactionType) {
|
3470
3776
|
switch (transactionType) {
|
3471
|
-
case
|
3777
|
+
case import_transactions17.TransactionType.Mint:
|
3472
3778
|
return "Mint" /* Mint */;
|
3473
|
-
case
|
3779
|
+
case import_transactions17.TransactionType.Create:
|
3474
3780
|
return "Create" /* Create */;
|
3475
|
-
case
|
3781
|
+
case import_transactions17.TransactionType.Script:
|
3476
3782
|
return "Script" /* Script */;
|
3477
|
-
case
|
3783
|
+
case import_transactions17.TransactionType.Blob:
|
3478
3784
|
return "Blob" /* Blob */;
|
3785
|
+
case import_transactions17.TransactionType.Upgrade:
|
3786
|
+
return "Upgrade" /* Upgrade */;
|
3787
|
+
case import_transactions17.TransactionType.Upload:
|
3788
|
+
return "Upload" /* Upload */;
|
3479
3789
|
default:
|
3480
|
-
throw new
|
3481
|
-
|
3790
|
+
throw new import_errors14.FuelError(
|
3791
|
+
import_errors14.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
|
3482
3792
|
`Unsupported transaction type: ${transactionType}.`
|
3483
3793
|
);
|
3484
3794
|
}
|
@@ -3506,10 +3816,10 @@ function isTypeBlob(transactionType) {
|
|
3506
3816
|
return isType(transactionType, "Blob" /* Blob */);
|
3507
3817
|
}
|
3508
3818
|
function getReceiptsCall(receipts) {
|
3509
|
-
return getReceiptsByType(receipts,
|
3819
|
+
return getReceiptsByType(receipts, import_transactions17.ReceiptType.Call);
|
3510
3820
|
}
|
3511
3821
|
function getReceiptsMessageOut(receipts) {
|
3512
|
-
return getReceiptsByType(receipts,
|
3822
|
+
return getReceiptsByType(receipts, import_transactions17.ReceiptType.MessageOut);
|
3513
3823
|
}
|
3514
3824
|
function mergeAssets(op1, op2) {
|
3515
3825
|
const assets1 = op1.assetsSent || [];
|
@@ -3617,7 +3927,7 @@ function getAssetsSent(receipt) {
|
|
3617
3927
|
];
|
3618
3928
|
}
|
3619
3929
|
function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
|
3620
|
-
const assetId = receipt.assetId ===
|
3930
|
+
const assetId = receipt.assetId === import_configs11.ZeroBytes32 ? baseAssetId : receipt.assetId;
|
3621
3931
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
3622
3932
|
if (!input) {
|
3623
3933
|
return [];
|
@@ -3673,7 +3983,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
3673
3983
|
const { to: toAddress, assetId, amount } = receipt;
|
3674
3984
|
let { from: fromAddress } = receipt;
|
3675
3985
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3676
|
-
if (
|
3986
|
+
if (import_configs11.ZeroBytes32 === fromAddress) {
|
3677
3987
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
3678
3988
|
fromAddress = change?.to || fromAddress;
|
3679
3989
|
}
|
@@ -3738,11 +4048,11 @@ function getTransferOperations({
|
|
3738
4048
|
});
|
3739
4049
|
const transferReceipts = getReceiptsByType(
|
3740
4050
|
receipts,
|
3741
|
-
|
4051
|
+
import_transactions17.ReceiptType.Transfer
|
3742
4052
|
);
|
3743
4053
|
const transferOutReceipts = getReceiptsByType(
|
3744
4054
|
receipts,
|
3745
|
-
|
4055
|
+
import_transactions17.ReceiptType.TransferOut
|
3746
4056
|
);
|
3747
4057
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
3748
4058
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -3826,17 +4136,17 @@ function getOperations({
|
|
3826
4136
|
}
|
3827
4137
|
|
3828
4138
|
// src/providers/transaction-summary/receipt.ts
|
3829
|
-
var
|
4139
|
+
var import_transactions18 = require("@fuel-ts/transactions");
|
3830
4140
|
var processGqlReceipt = (gqlReceipt) => {
|
3831
4141
|
const receipt = assembleReceiptByType(gqlReceipt);
|
3832
4142
|
switch (receipt.type) {
|
3833
|
-
case
|
4143
|
+
case import_transactions18.ReceiptType.ReturnData: {
|
3834
4144
|
return {
|
3835
4145
|
...receipt,
|
3836
4146
|
data: gqlReceipt.data || "0x"
|
3837
4147
|
};
|
3838
4148
|
}
|
3839
|
-
case
|
4149
|
+
case import_transactions18.ReceiptType.LogData: {
|
3840
4150
|
return {
|
3841
4151
|
...receipt,
|
3842
4152
|
data: gqlReceipt.data || "0x"
|
@@ -3849,7 +4159,7 @@ var processGqlReceipt = (gqlReceipt) => {
|
|
3849
4159
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
3850
4160
|
const mintedAssets = [];
|
3851
4161
|
receipts.forEach((receipt) => {
|
3852
|
-
if (receipt.type ===
|
4162
|
+
if (receipt.type === import_transactions18.ReceiptType.Mint) {
|
3853
4163
|
mintedAssets.push({
|
3854
4164
|
subId: receipt.subId,
|
3855
4165
|
contractId: receipt.contractId,
|
@@ -3863,7 +4173,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
3863
4173
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
3864
4174
|
const burnedAssets = [];
|
3865
4175
|
receipts.forEach((receipt) => {
|
3866
|
-
if (receipt.type ===
|
4176
|
+
if (receipt.type === import_transactions18.ReceiptType.Burn) {
|
3867
4177
|
burnedAssets.push({
|
3868
4178
|
subId: receipt.subId,
|
3869
4179
|
contractId: receipt.contractId,
|
@@ -3876,7 +4186,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3876
4186
|
};
|
3877
4187
|
|
3878
4188
|
// src/providers/transaction-summary/status.ts
|
3879
|
-
var
|
4189
|
+
var import_errors15 = require("@fuel-ts/errors");
|
3880
4190
|
var import_math16 = require("@fuel-ts/math");
|
3881
4191
|
var getTransactionStatusName = (gqlStatus) => {
|
3882
4192
|
switch (gqlStatus) {
|
@@ -3889,8 +4199,8 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3889
4199
|
case "SqueezedOutStatus":
|
3890
4200
|
return "squeezedout" /* squeezedout */;
|
3891
4201
|
default:
|
3892
|
-
throw new
|
3893
|
-
|
4202
|
+
throw new import_errors15.FuelError(
|
4203
|
+
import_errors15.ErrorCode.INVALID_TRANSACTION_STATUS,
|
3894
4204
|
`Invalid transaction status: ${gqlStatus}.`
|
3895
4205
|
);
|
3896
4206
|
}
|
@@ -3959,7 +4269,7 @@ function assembleTransactionSummary(params) {
|
|
3959
4269
|
baseAssetId
|
3960
4270
|
} = params;
|
3961
4271
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3962
|
-
const rawPayload = (0,
|
4272
|
+
const rawPayload = (0, import_utils25.hexlify)(transactionBytes);
|
3963
4273
|
const operations = getOperations({
|
3964
4274
|
transactionType: transaction.type,
|
3965
4275
|
inputs: transaction.inputs || [],
|
@@ -3971,7 +4281,7 @@ function assembleTransactionSummary(params) {
|
|
3971
4281
|
baseAssetId
|
3972
4282
|
});
|
3973
4283
|
const typeName = getTransactionTypeName(transaction.type);
|
3974
|
-
const tip = (0, import_math17.bn)(transaction.policies?.find((policy) => policy.type ===
|
4284
|
+
const tip = (0, import_math17.bn)(transaction.policies?.find((policy) => policy.type === import_transactions19.PolicyType.Tip)?.data);
|
3975
4285
|
const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
|
3976
4286
|
const fee = calculateTXFeeForSummary({
|
3977
4287
|
totalFee,
|
@@ -3991,7 +4301,7 @@ function assembleTransactionSummary(params) {
|
|
3991
4301
|
const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
|
3992
4302
|
let date;
|
3993
4303
|
if (time) {
|
3994
|
-
date =
|
4304
|
+
date = import_utils25.DateTime.fromTai64(time);
|
3995
4305
|
}
|
3996
4306
|
const transactionSummary = {
|
3997
4307
|
id,
|
@@ -4023,12 +4333,12 @@ function assembleTransactionSummary(params) {
|
|
4023
4333
|
|
4024
4334
|
// src/providers/transaction-response/getDecodedLogs.ts
|
4025
4335
|
var import_abi_coder6 = require("@fuel-ts/abi-coder");
|
4026
|
-
var
|
4336
|
+
var import_transactions20 = require("@fuel-ts/transactions");
|
4027
4337
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
4028
4338
|
return receipts.reduce((logs, receipt) => {
|
4029
|
-
if (receipt.type ===
|
4339
|
+
if (receipt.type === import_transactions20.ReceiptType.LogData || receipt.type === import_transactions20.ReceiptType.Log) {
|
4030
4340
|
const interfaceToUse = new import_abi_coder6.Interface(externalAbis[receipt.id] || mainAbi);
|
4031
|
-
const data = receipt.type ===
|
4341
|
+
const data = receipt.type === import_transactions20.ReceiptType.Log ? new import_abi_coder6.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
|
4032
4342
|
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toString());
|
4033
4343
|
logs.push(decodedLog);
|
4034
4344
|
}
|
@@ -4042,55 +4352,56 @@ function mapGqlOutputsToTxOutputs(outputs) {
|
|
4042
4352
|
const obj = "amount" in o ? { ...o, amount: (0, import_math18.bn)(o.amount) } : o;
|
4043
4353
|
switch (obj.type) {
|
4044
4354
|
case "CoinOutput":
|
4045
|
-
return { ...obj, type:
|
4355
|
+
return { ...obj, type: import_transactions21.OutputType.Coin };
|
4046
4356
|
case "ContractOutput":
|
4047
4357
|
return {
|
4048
4358
|
...obj,
|
4049
|
-
type:
|
4359
|
+
type: import_transactions21.OutputType.Contract,
|
4050
4360
|
inputIndex: parseInt(obj.inputIndex, 10)
|
4051
4361
|
};
|
4052
4362
|
case "ChangeOutput":
|
4053
4363
|
return {
|
4054
4364
|
...obj,
|
4055
|
-
type:
|
4365
|
+
type: import_transactions21.OutputType.Change
|
4056
4366
|
};
|
4057
4367
|
case "VariableOutput":
|
4058
|
-
return { ...obj, type:
|
4368
|
+
return { ...obj, type: import_transactions21.OutputType.Variable };
|
4059
4369
|
case "ContractCreated":
|
4060
4370
|
return {
|
4061
4371
|
...obj,
|
4062
|
-
type:
|
4372
|
+
type: import_transactions21.OutputType.ContractCreated,
|
4063
4373
|
contractId: obj.contract
|
4064
4374
|
};
|
4065
4375
|
default:
|
4066
|
-
return (0,
|
4376
|
+
return (0, import_utils27.assertUnreachable)(obj);
|
4067
4377
|
}
|
4068
4378
|
});
|
4069
4379
|
}
|
4070
4380
|
var TransactionResponse = class {
|
4071
|
-
/** Transaction ID */
|
4072
|
-
id;
|
4073
|
-
/** Current provider */
|
4074
|
-
provider;
|
4075
|
-
/** Gas used on the transaction */
|
4076
|
-
gasUsed = (0, import_math18.bn)(0);
|
4077
|
-
/** The graphql Transaction with receipts object. */
|
4078
|
-
gqlTransaction;
|
4079
|
-
request;
|
4080
|
-
status;
|
4081
|
-
abis;
|
4082
4381
|
/**
|
4083
4382
|
* Constructor for `TransactionResponse`.
|
4084
4383
|
*
|
4085
4384
|
* @param tx - The transaction ID or TransactionRequest.
|
4086
4385
|
* @param provider - The provider.
|
4087
4386
|
*/
|
4088
|
-
constructor(tx, provider, abis) {
|
4387
|
+
constructor(tx, provider, abis, submitTxSubscription) {
|
4388
|
+
this.submitTxSubscription = submitTxSubscription;
|
4089
4389
|
this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
|
4090
4390
|
this.provider = provider;
|
4091
4391
|
this.abis = abis;
|
4092
4392
|
this.request = typeof tx === "string" ? void 0 : tx;
|
4093
4393
|
}
|
4394
|
+
/** Transaction ID */
|
4395
|
+
id;
|
4396
|
+
/** Current provider */
|
4397
|
+
provider;
|
4398
|
+
/** Gas used on the transaction */
|
4399
|
+
gasUsed = (0, import_math18.bn)(0);
|
4400
|
+
/** The graphql Transaction with receipts object. */
|
4401
|
+
gqlTransaction;
|
4402
|
+
request;
|
4403
|
+
status;
|
4404
|
+
abis;
|
4094
4405
|
/**
|
4095
4406
|
* Async constructor for `TransactionResponse`. This method can be used to create
|
4096
4407
|
* an instance of `TransactionResponse` and wait for the transaction to be fetched
|
@@ -4116,7 +4427,7 @@ var TransactionResponse = class {
|
|
4116
4427
|
const correspondingInput = status.transaction.inputs?.[idx];
|
4117
4428
|
return {
|
4118
4429
|
...input,
|
4119
|
-
txPointer:
|
4430
|
+
txPointer: import_transactions21.TxPointerCoder.decodeFromGqlScalar(correspondingInput.txPointer)
|
4120
4431
|
};
|
4121
4432
|
}
|
4122
4433
|
return input;
|
@@ -4139,7 +4450,7 @@ var TransactionResponse = class {
|
|
4139
4450
|
const gqlTransaction = this.gqlTransaction ?? await this.fetch();
|
4140
4451
|
return {
|
4141
4452
|
tx: this.decodeTransaction(gqlTransaction),
|
4142
|
-
bytes: (0,
|
4453
|
+
bytes: (0, import_utils27.arrayify)(gqlTransaction.rawPayload)
|
4143
4454
|
};
|
4144
4455
|
}
|
4145
4456
|
getReceipts() {
|
@@ -4183,8 +4494,8 @@ var TransactionResponse = class {
|
|
4183
4494
|
* @returns The decoded transaction.
|
4184
4495
|
*/
|
4185
4496
|
decodeTransaction(transactionWithReceipts) {
|
4186
|
-
return new
|
4187
|
-
(0,
|
4497
|
+
return new import_transactions21.TransactionCoder().decode(
|
4498
|
+
(0, import_utils27.arrayify)(transactionWithReceipts.rawPayload),
|
4188
4499
|
0
|
4189
4500
|
)?.[0];
|
4190
4501
|
}
|
@@ -4223,15 +4534,16 @@ var TransactionResponse = class {
|
|
4223
4534
|
if (status && status !== "SubmittedStatus") {
|
4224
4535
|
return;
|
4225
4536
|
}
|
4226
|
-
const subscription = await this.provider.operations.statusChange({
|
4537
|
+
const subscription = this.submitTxSubscription ?? await this.provider.operations.statusChange({
|
4227
4538
|
transactionId: this.id
|
4228
4539
|
});
|
4229
|
-
for await (const
|
4540
|
+
for await (const sub of subscription) {
|
4541
|
+
const statusChange = "statusChange" in sub ? sub.statusChange : sub.submitAndAwaitStatus;
|
4230
4542
|
this.status = statusChange;
|
4231
4543
|
if (statusChange.type === "SqueezedOutStatus") {
|
4232
4544
|
this.unsetResourceCache();
|
4233
|
-
throw new
|
4234
|
-
|
4545
|
+
throw new import_errors16.FuelError(
|
4546
|
+
import_errors16.ErrorCode.TRANSACTION_SQUEEZED_OUT,
|
4235
4547
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4236
4548
|
);
|
4237
4549
|
}
|
@@ -4302,7 +4614,7 @@ var TransactionResponse = class {
|
|
4302
4614
|
};
|
4303
4615
|
|
4304
4616
|
// src/providers/utils/auto-retry-fetch.ts
|
4305
|
-
var
|
4617
|
+
var import_utils29 = require("@fuel-ts/utils");
|
4306
4618
|
function getWaitDelay(options, retryAttemptNum) {
|
4307
4619
|
const duration = options.baseDelay ?? 150;
|
4308
4620
|
switch (options.backoff) {
|
@@ -4332,25 +4644,25 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4332
4644
|
throw error;
|
4333
4645
|
}
|
4334
4646
|
const delay = getWaitDelay(options, retryNum);
|
4335
|
-
await (0,
|
4647
|
+
await (0, import_utils29.sleep)(delay);
|
4336
4648
|
return autoRetryFetch(fetchFn, options, retryNum)(...args);
|
4337
4649
|
}
|
4338
4650
|
};
|
4339
4651
|
}
|
4340
4652
|
|
4341
4653
|
// src/providers/utils/handle-gql-error-message.ts
|
4342
|
-
var
|
4654
|
+
var import_errors17 = require("@fuel-ts/errors");
|
4343
4655
|
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4344
4656
|
switch (errorMessage) {
|
4345
4657
|
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4346
|
-
throw new
|
4347
|
-
|
4658
|
+
throw new import_errors17.FuelError(
|
4659
|
+
import_errors17.ErrorCode.NOT_ENOUGH_FUNDS,
|
4348
4660
|
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4349
4661
|
{},
|
4350
4662
|
rawError
|
4351
4663
|
);
|
4352
4664
|
default:
|
4353
|
-
throw new
|
4665
|
+
throw new import_errors17.FuelError(import_errors17.ErrorCode.INVALID_REQUEST, errorMessage);
|
4354
4666
|
}
|
4355
4667
|
};
|
4356
4668
|
|
@@ -4432,24 +4744,34 @@ var _Provider = class {
|
|
4432
4744
|
* @hidden
|
4433
4745
|
*/
|
4434
4746
|
constructor(url, options = {}) {
|
4435
|
-
this.url = url;
|
4436
4747
|
/**
|
4437
4748
|
* @hidden
|
4438
4749
|
*/
|
4439
4750
|
__privateAdd(this, _cacheInputs);
|
4440
4751
|
__publicField(this, "operations");
|
4441
4752
|
__publicField(this, "cache");
|
4753
|
+
/** @hidden */
|
4754
|
+
__publicField(this, "url");
|
4755
|
+
/** @hidden */
|
4756
|
+
__publicField(this, "urlWithoutAuth");
|
4442
4757
|
__publicField(this, "options", {
|
4443
4758
|
timeout: void 0,
|
4444
4759
|
resourceCacheTTL: void 0,
|
4445
4760
|
fetch: void 0,
|
4446
|
-
retryOptions: void 0
|
4761
|
+
retryOptions: void 0,
|
4762
|
+
headers: void 0
|
4447
4763
|
});
|
4764
|
+
const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
|
4765
|
+
this.url = rawUrl;
|
4766
|
+
this.urlWithoutAuth = urlWithoutAuth;
|
4448
4767
|
this.options = { ...this.options, ...options };
|
4449
4768
|
this.url = url;
|
4769
|
+
if (headers) {
|
4770
|
+
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4771
|
+
}
|
4450
4772
|
this.operations = this.createOperations();
|
4451
4773
|
const { resourceCacheTTL } = this.options;
|
4452
|
-
if ((0,
|
4774
|
+
if ((0, import_utils30.isDefined)(resourceCacheTTL)) {
|
4453
4775
|
if (resourceCacheTTL !== -1) {
|
4454
4776
|
this.cache = new ResourceCache(resourceCacheTTL);
|
4455
4777
|
} else {
|
@@ -4468,12 +4790,16 @@ var _Provider = class {
|
|
4468
4790
|
* @hidden
|
4469
4791
|
*/
|
4470
4792
|
static getFetchFn(options) {
|
4471
|
-
const { retryOptions, timeout } = options;
|
4793
|
+
const { retryOptions, timeout, headers } = options;
|
4472
4794
|
return autoRetryFetch(async (...args) => {
|
4473
4795
|
const url = args[0];
|
4474
4796
|
const request = args[1];
|
4475
4797
|
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
4476
|
-
let fullRequest = {
|
4798
|
+
let fullRequest = {
|
4799
|
+
...request,
|
4800
|
+
signal,
|
4801
|
+
headers: { ...request?.headers, ...headers }
|
4802
|
+
};
|
4477
4803
|
if (options.requestMiddleware) {
|
4478
4804
|
fullRequest = await options.requestMiddleware(fullRequest);
|
4479
4805
|
}
|
@@ -4481,15 +4807,23 @@ var _Provider = class {
|
|
4481
4807
|
}, retryOptions);
|
4482
4808
|
}
|
4483
4809
|
static extractBasicAuth(url) {
|
4484
|
-
|
4810
|
+
let parsedUrl;
|
4811
|
+
try {
|
4812
|
+
parsedUrl = new URL(url);
|
4813
|
+
} catch (error) {
|
4814
|
+
throw new import_errors18.FuelError(import_errors18.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
4815
|
+
}
|
4485
4816
|
const username = parsedUrl.username;
|
4486
4817
|
const password = parsedUrl.password;
|
4487
|
-
const
|
4818
|
+
const urlWithoutAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
|
4488
4819
|
if (!(username && password)) {
|
4489
|
-
return { url,
|
4820
|
+
return { url, urlWithoutAuth: url, headers: void 0 };
|
4490
4821
|
}
|
4491
|
-
|
4492
|
-
|
4822
|
+
return {
|
4823
|
+
url,
|
4824
|
+
urlWithoutAuth,
|
4825
|
+
headers: { Authorization: `Basic ${btoa(`${username}:${password}`)}` }
|
4826
|
+
};
|
4493
4827
|
}
|
4494
4828
|
/**
|
4495
4829
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
@@ -4500,17 +4834,7 @@ var _Provider = class {
|
|
4500
4834
|
* @returns A promise that resolves to a Provider instance.
|
4501
4835
|
*/
|
4502
4836
|
static async create(url, options = {}) {
|
4503
|
-
const
|
4504
|
-
const provider = new _Provider(urlToUse, {
|
4505
|
-
...options,
|
4506
|
-
requestMiddleware: async (request) => {
|
4507
|
-
if (auth) {
|
4508
|
-
request.headers ??= {};
|
4509
|
-
request.headers.Authorization = auth;
|
4510
|
-
}
|
4511
|
-
return options.requestMiddleware?.(request) ?? request;
|
4512
|
-
}
|
4513
|
-
});
|
4837
|
+
const provider = new _Provider(url, options);
|
4514
4838
|
await provider.fetchChainAndNodeInfo();
|
4515
4839
|
return provider;
|
4516
4840
|
}
|
@@ -4520,10 +4844,10 @@ var _Provider = class {
|
|
4520
4844
|
* @returns the chain information configuration.
|
4521
4845
|
*/
|
4522
4846
|
getChain() {
|
4523
|
-
const chain = _Provider.chainInfoCache[this.
|
4847
|
+
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
4524
4848
|
if (!chain) {
|
4525
|
-
throw new
|
4526
|
-
|
4849
|
+
throw new import_errors18.FuelError(
|
4850
|
+
import_errors18.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
|
4527
4851
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4528
4852
|
);
|
4529
4853
|
}
|
@@ -4535,10 +4859,10 @@ var _Provider = class {
|
|
4535
4859
|
* @returns the node information configuration.
|
4536
4860
|
*/
|
4537
4861
|
getNode() {
|
4538
|
-
const node = _Provider.nodeInfoCache[this.
|
4862
|
+
const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4539
4863
|
if (!node) {
|
4540
|
-
throw new
|
4541
|
-
|
4864
|
+
throw new import_errors18.FuelError(
|
4865
|
+
import_errors18.ErrorCode.NODE_INFO_CACHE_EMPTY,
|
4542
4866
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4543
4867
|
);
|
4544
4868
|
}
|
@@ -4569,8 +4893,11 @@ var _Provider = class {
|
|
4569
4893
|
* @param options - Additional options for the provider.
|
4570
4894
|
*/
|
4571
4895
|
async connect(url, options) {
|
4572
|
-
|
4896
|
+
const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
|
4897
|
+
this.url = rawUrl;
|
4898
|
+
this.urlWithoutAuth = urlWithoutAuth;
|
4573
4899
|
this.options = options ?? this.options;
|
4900
|
+
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4574
4901
|
this.operations = this.createOperations();
|
4575
4902
|
await this.fetchChainAndNodeInfo();
|
4576
4903
|
}
|
@@ -4610,7 +4937,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4610
4937
|
*/
|
4611
4938
|
createOperations() {
|
4612
4939
|
const fetchFn = _Provider.getFetchFn(this.options);
|
4613
|
-
const gqlClient = new import_graphql_request.GraphQLClient(this.
|
4940
|
+
const gqlClient = new import_graphql_request.GraphQLClient(this.urlWithoutAuth, {
|
4614
4941
|
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4615
4942
|
responseMiddleware: (response) => {
|
4616
4943
|
if ("response" in response) {
|
@@ -4628,7 +4955,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4628
4955
|
const isSubscription = opDefinition?.operation === "subscription";
|
4629
4956
|
if (isSubscription) {
|
4630
4957
|
return FuelGraphqlSubscriber.create({
|
4631
|
-
url: this.
|
4958
|
+
url: this.urlWithoutAuth,
|
4632
4959
|
query,
|
4633
4960
|
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4634
4961
|
variables: vars
|
@@ -4691,7 +5018,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4691
5018
|
utxoValidation: nodeInfo.utxoValidation,
|
4692
5019
|
vmBacktrace: nodeInfo.vmBacktrace
|
4693
5020
|
};
|
4694
|
-
_Provider.nodeInfoCache[this.
|
5021
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = processedNodeInfo;
|
4695
5022
|
return processedNodeInfo;
|
4696
5023
|
}
|
4697
5024
|
/**
|
@@ -4702,7 +5029,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4702
5029
|
async fetchChain() {
|
4703
5030
|
const { chain } = await this.operations.getChain();
|
4704
5031
|
const processedChain = processGqlChain(chain);
|
4705
|
-
_Provider.chainInfoCache[this.
|
5032
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = processedChain;
|
4706
5033
|
return processedChain;
|
4707
5034
|
}
|
4708
5035
|
/**
|
@@ -4730,14 +5057,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4730
5057
|
validateTransaction(tx, consensusParameters) {
|
4731
5058
|
const { maxOutputs, maxInputs } = consensusParameters.txParameters;
|
4732
5059
|
if ((0, import_math19.bn)(tx.inputs.length).gt(maxInputs)) {
|
4733
|
-
throw new
|
4734
|
-
|
5060
|
+
throw new import_errors18.FuelError(
|
5061
|
+
import_errors18.ErrorCode.MAX_INPUTS_EXCEEDED,
|
4735
5062
|
"The transaction exceeds the maximum allowed number of inputs."
|
4736
5063
|
);
|
4737
5064
|
}
|
4738
5065
|
if ((0, import_math19.bn)(tx.outputs.length).gt(maxOutputs)) {
|
4739
|
-
throw new
|
4740
|
-
|
5066
|
+
throw new import_errors18.FuelError(
|
5067
|
+
import_errors18.ErrorCode.MAX_OUTPUTS_EXCEEDED,
|
4741
5068
|
"The transaction exceeds the maximum allowed number of outputs."
|
4742
5069
|
);
|
4743
5070
|
}
|
@@ -4759,16 +5086,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4759
5086
|
}
|
4760
5087
|
const { consensusParameters } = this.getChain();
|
4761
5088
|
this.validateTransaction(transactionRequest, consensusParameters);
|
4762
|
-
const encodedTransaction = (0,
|
5089
|
+
const encodedTransaction = (0, import_utils30.hexlify)(transactionRequest.toTransactionBytes());
|
4763
5090
|
let abis;
|
4764
5091
|
if (isTransactionTypeScript(transactionRequest)) {
|
4765
5092
|
abis = transactionRequest.abis;
|
4766
5093
|
}
|
4767
|
-
const {
|
4768
|
-
|
4769
|
-
|
4770
|
-
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
|
4771
|
-
return new TransactionResponse(transactionRequest, this, abis);
|
5094
|
+
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
5095
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
|
5096
|
+
return new TransactionResponse(transactionRequest, this, abis, subscription);
|
4772
5097
|
}
|
4773
5098
|
/**
|
4774
5099
|
* Executes a transaction without actually submitting it to the chain.
|
@@ -4785,7 +5110,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4785
5110
|
if (estimateTxDependencies) {
|
4786
5111
|
return this.estimateTxDependencies(transactionRequest);
|
4787
5112
|
}
|
4788
|
-
const encodedTransaction = (0,
|
5113
|
+
const encodedTransaction = (0, import_utils30.hexlify)(transactionRequest.toTransactionBytes());
|
4789
5114
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4790
5115
|
encodedTransactions: encodedTransaction,
|
4791
5116
|
utxoValidation: utxoValidation || false
|
@@ -4805,13 +5130,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4805
5130
|
async estimatePredicates(transactionRequest) {
|
4806
5131
|
const shouldEstimatePredicates = Boolean(
|
4807
5132
|
transactionRequest.inputs.find(
|
4808
|
-
(input) => "predicate" in input && input.predicate && !(0,
|
5133
|
+
(input) => "predicate" in input && input.predicate && !(0, import_utils31.equalBytes)((0, import_utils30.arrayify)(input.predicate), (0, import_utils30.arrayify)("0x")) && new import_math19.BN(input.predicateGasUsed).isZero()
|
4809
5134
|
)
|
4810
5135
|
);
|
4811
5136
|
if (!shouldEstimatePredicates) {
|
4812
5137
|
return transactionRequest;
|
4813
5138
|
}
|
4814
|
-
const encodedTransaction = (0,
|
5139
|
+
const encodedTransaction = (0, import_utils30.hexlify)(transactionRequest.toTransactionBytes());
|
4815
5140
|
const response = await this.operations.estimatePredicates({
|
4816
5141
|
encodedTransaction
|
4817
5142
|
});
|
@@ -4852,7 +5177,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4852
5177
|
const {
|
4853
5178
|
dryRun: [{ receipts: rawReceipts, status }]
|
4854
5179
|
} = await this.operations.dryRun({
|
4855
|
-
encodedTransactions: [(0,
|
5180
|
+
encodedTransactions: [(0, import_utils30.hexlify)(transactionRequest.toTransactionBytes())],
|
4856
5181
|
utxoValidation: false
|
4857
5182
|
});
|
4858
5183
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4898,11 +5223,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4898
5223
|
missingContractIds: [],
|
4899
5224
|
dryRunStatus: void 0
|
4900
5225
|
}));
|
4901
|
-
const allRequests = (0,
|
5226
|
+
const allRequests = (0, import_ramda8.clone)(transactionRequests);
|
4902
5227
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4903
5228
|
allRequests.forEach((req, index) => {
|
4904
5229
|
if (isTransactionTypeScript(req)) {
|
4905
|
-
serializedTransactionsMap.set(index, (0,
|
5230
|
+
serializedTransactionsMap.set(index, (0, import_utils30.hexlify)(req.toTransactionBytes()));
|
4906
5231
|
}
|
4907
5232
|
});
|
4908
5233
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4938,7 +5263,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4938
5263
|
transactionRequest: request
|
4939
5264
|
});
|
4940
5265
|
request.maxFee = maxFee;
|
4941
|
-
serializedTransactionsMap.set(requestIdx, (0,
|
5266
|
+
serializedTransactionsMap.set(requestIdx, (0, import_utils30.hexlify)(request.toTransactionBytes()));
|
4942
5267
|
nextRoundTransactions.push(requestIdx);
|
4943
5268
|
}
|
4944
5269
|
}
|
@@ -4959,7 +5284,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4959
5284
|
if (estimateTxDependencies) {
|
4960
5285
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4961
5286
|
}
|
4962
|
-
const encodedTransactions = transactionRequests.map((tx) => (0,
|
5287
|
+
const encodedTransactions = transactionRequests.map((tx) => (0, import_utils30.hexlify)(tx.toTransactionBytes()));
|
4963
5288
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4964
5289
|
encodedTransactions,
|
4965
5290
|
utxoValidation: utxoValidation || false
|
@@ -5033,7 +5358,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5033
5358
|
if (estimateTxDependencies) {
|
5034
5359
|
return this.estimateTxDependencies(transactionRequest);
|
5035
5360
|
}
|
5036
|
-
const encodedTransactions = [(0,
|
5361
|
+
const encodedTransactions = [(0, import_utils30.hexlify)(transactionRequest.toTransactionBytes())];
|
5037
5362
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5038
5363
|
encodedTransactions,
|
5039
5364
|
utxoValidation: true
|
@@ -5058,13 +5383,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5058
5383
|
* @returns A promise that resolves to the transaction cost object.
|
5059
5384
|
*/
|
5060
5385
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
5061
|
-
const txRequestClone = (0,
|
5386
|
+
const txRequestClone = (0, import_ramda8.clone)(transactionRequestify(transactionRequestLike));
|
5062
5387
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
5063
5388
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
5064
5389
|
if (isScriptTransaction) {
|
5065
5390
|
txRequestClone.gasLimit = (0, import_math19.bn)(0);
|
5066
5391
|
}
|
5067
|
-
const signedRequest = (0,
|
5392
|
+
const signedRequest = (0, import_ramda8.clone)(txRequestClone);
|
5068
5393
|
let addedSignatures = 0;
|
5069
5394
|
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
5070
5395
|
const lengthBefore = signedRequest.witnesses.length;
|
@@ -5132,7 +5457,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5132
5457
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
5133
5458
|
inputArgs: paginationArgs
|
5134
5459
|
}),
|
5135
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0,
|
5460
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils30.hexlify)(assetId) }
|
5136
5461
|
});
|
5137
5462
|
const coins = edges.map(({ node }) => ({
|
5138
5463
|
id: node.utxoId,
|
@@ -5158,8 +5483,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5158
5483
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
5159
5484
|
const ownerAddress = import_address4.Address.fromAddressOrString(owner);
|
5160
5485
|
const excludeInput = {
|
5161
|
-
messages: excludedIds?.messages?.map((nonce) => (0,
|
5162
|
-
utxos: excludedIds?.utxos?.map((id) => (0,
|
5486
|
+
messages: excludedIds?.messages?.map((nonce) => (0, import_utils30.hexlify)(nonce)) || [],
|
5487
|
+
utxos: excludedIds?.utxos?.map((id) => (0, import_utils30.hexlify)(id)) || []
|
5163
5488
|
};
|
5164
5489
|
if (this.cache) {
|
5165
5490
|
const cached = this.cache.getActiveData();
|
@@ -5169,7 +5494,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5169
5494
|
const coinsQuery = {
|
5170
5495
|
owner: ownerAddress.toB256(),
|
5171
5496
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
5172
|
-
assetId: (0,
|
5497
|
+
assetId: (0, import_utils30.hexlify)(assetId),
|
5173
5498
|
amount: amount.toString(10),
|
5174
5499
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
5175
5500
|
})),
|
@@ -5324,7 +5649,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5324
5649
|
},
|
5325
5650
|
transactionIds: block.transactions.map((tx) => tx.id),
|
5326
5651
|
transactions: block.transactions.map(
|
5327
|
-
(tx) => new
|
5652
|
+
(tx) => new import_transactions22.TransactionCoder().decode((0, import_utils30.arrayify)(tx.rawPayload), 0)?.[0]
|
5328
5653
|
)
|
5329
5654
|
};
|
5330
5655
|
}
|
@@ -5340,12 +5665,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5340
5665
|
return null;
|
5341
5666
|
}
|
5342
5667
|
try {
|
5343
|
-
return new
|
5344
|
-
(0,
|
5668
|
+
return new import_transactions22.TransactionCoder().decode(
|
5669
|
+
(0, import_utils30.arrayify)(transaction.rawPayload),
|
5345
5670
|
0
|
5346
5671
|
)?.[0];
|
5347
5672
|
} catch (error) {
|
5348
|
-
if (error instanceof
|
5673
|
+
if (error instanceof import_errors18.FuelError && error.code === import_errors18.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5349
5674
|
console.warn("Unsupported transaction type encountered");
|
5350
5675
|
return null;
|
5351
5676
|
}
|
@@ -5361,12 +5686,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5361
5686
|
const {
|
5362
5687
|
transactions: { edges, pageInfo }
|
5363
5688
|
} = await this.operations.getTransactions(paginationArgs);
|
5364
|
-
const coder = new
|
5689
|
+
const coder = new import_transactions22.TransactionCoder();
|
5365
5690
|
const transactions = edges.map(({ node: { rawPayload } }) => {
|
5366
5691
|
try {
|
5367
|
-
return coder.decode((0,
|
5692
|
+
return coder.decode((0, import_utils30.arrayify)(rawPayload), 0)[0];
|
5368
5693
|
} catch (error) {
|
5369
|
-
if (error instanceof
|
5694
|
+
if (error instanceof import_errors18.FuelError && error.code === import_errors18.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
|
5370
5695
|
console.warn("Unsupported transaction type encountered");
|
5371
5696
|
return null;
|
5372
5697
|
}
|
@@ -5398,7 +5723,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5398
5723
|
async getContractBalance(contractId, assetId) {
|
5399
5724
|
const { contractBalance } = await this.operations.getContractBalance({
|
5400
5725
|
contract: import_address4.Address.fromAddressOrString(contractId).toB256(),
|
5401
|
-
asset: (0,
|
5726
|
+
asset: (0, import_utils30.hexlify)(assetId)
|
5402
5727
|
});
|
5403
5728
|
return (0, import_math19.bn)(contractBalance.amount, 10);
|
5404
5729
|
}
|
@@ -5412,7 +5737,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5412
5737
|
async getBalance(owner, assetId) {
|
5413
5738
|
const { balance } = await this.operations.getBalance({
|
5414
5739
|
owner: import_address4.Address.fromAddressOrString(owner).toB256(),
|
5415
|
-
assetId: (0,
|
5740
|
+
assetId: (0, import_utils30.hexlify)(assetId)
|
5416
5741
|
});
|
5417
5742
|
return (0, import_math19.bn)(balance.amount, 10);
|
5418
5743
|
}
|
@@ -5458,7 +5783,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5458
5783
|
owner: import_address4.Address.fromAddressOrString(address).toB256()
|
5459
5784
|
});
|
5460
5785
|
const messages = edges.map(({ node }) => ({
|
5461
|
-
messageId:
|
5786
|
+
messageId: import_transactions22.InputMessageCoder.getMessageId({
|
5462
5787
|
sender: node.sender,
|
5463
5788
|
recipient: node.recipient,
|
5464
5789
|
nonce: node.nonce,
|
@@ -5469,7 +5794,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5469
5794
|
recipient: import_address4.Address.fromAddressOrString(node.recipient),
|
5470
5795
|
nonce: node.nonce,
|
5471
5796
|
amount: (0, import_math19.bn)(node.amount),
|
5472
|
-
data:
|
5797
|
+
data: import_transactions22.InputMessageCoder.decodeData(node.data),
|
5473
5798
|
daHeight: (0, import_math19.bn)(node.daHeight)
|
5474
5799
|
}));
|
5475
5800
|
return {
|
@@ -5492,8 +5817,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5492
5817
|
nonce
|
5493
5818
|
};
|
5494
5819
|
if (commitBlockId && commitBlockHeight) {
|
5495
|
-
throw new
|
5496
|
-
|
5820
|
+
throw new import_errors18.FuelError(
|
5821
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5497
5822
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5498
5823
|
);
|
5499
5824
|
}
|
@@ -5612,7 +5937,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5612
5937
|
async produceBlocks(amount, startTime) {
|
5613
5938
|
const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
|
5614
5939
|
blocksToProduce: (0, import_math19.bn)(amount).toString(10),
|
5615
|
-
startTimestamp: startTime ?
|
5940
|
+
startTimestamp: startTime ? import_utils30.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
|
5616
5941
|
});
|
5617
5942
|
return (0, import_math19.bn)(latestBlockHeight);
|
5618
5943
|
}
|
@@ -5638,7 +5963,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5638
5963
|
return null;
|
5639
5964
|
}
|
5640
5965
|
const message = {
|
5641
|
-
messageId:
|
5966
|
+
messageId: import_transactions22.InputMessageCoder.getMessageId({
|
5642
5967
|
sender: rawMessage.sender,
|
5643
5968
|
recipient: rawMessage.recipient,
|
5644
5969
|
nonce: rawMessage.nonce,
|
@@ -5649,7 +5974,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5649
5974
|
recipient: import_address4.Address.fromAddressOrString(rawMessage.recipient),
|
5650
5975
|
nonce: rawMessage.nonce,
|
5651
5976
|
amount: (0, import_math19.bn)(rawMessage.amount),
|
5652
|
-
data:
|
5977
|
+
data: import_transactions22.InputMessageCoder.decodeData(rawMessage.data),
|
5653
5978
|
daHeight: (0, import_math19.bn)(rawMessage.daHeight)
|
5654
5979
|
};
|
5655
5980
|
return message;
|
@@ -5676,26 +6001,26 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5676
6001
|
const { paginationLimit, inputArgs = {} } = params;
|
5677
6002
|
const { first, last, after, before } = inputArgs;
|
5678
6003
|
if (after && before) {
|
5679
|
-
throw new
|
5680
|
-
|
6004
|
+
throw new import_errors18.FuelError(
|
6005
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5681
6006
|
'Pagination arguments "after" and "before" cannot be used together'
|
5682
6007
|
);
|
5683
6008
|
}
|
5684
6009
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5685
|
-
throw new
|
5686
|
-
|
6010
|
+
throw new import_errors18.FuelError(
|
6011
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5687
6012
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5688
6013
|
);
|
5689
6014
|
}
|
5690
6015
|
if (first && before) {
|
5691
|
-
throw new
|
5692
|
-
|
6016
|
+
throw new import_errors18.FuelError(
|
6017
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5693
6018
|
'The use of pagination argument "first" with "before" is not supported'
|
5694
6019
|
);
|
5695
6020
|
}
|
5696
6021
|
if (last && after) {
|
5697
|
-
throw new
|
5698
|
-
|
6022
|
+
throw new import_errors18.FuelError(
|
6023
|
+
import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5699
6024
|
'The use of pagination argument "last" with "after" is not supported'
|
5700
6025
|
);
|
5701
6026
|
}
|
@@ -5732,9 +6057,9 @@ cacheInputs_fn = function(inputs, transactionId) {
|
|
5732
6057
|
}
|
5733
6058
|
const inputsToCache = inputs.reduce(
|
5734
6059
|
(acc, input) => {
|
5735
|
-
if (input.type ===
|
6060
|
+
if (input.type === import_transactions22.InputType.Coin) {
|
5736
6061
|
acc.utxos.push(input.id);
|
5737
|
-
} else if (input.type ===
|
6062
|
+
} else if (input.type === import_transactions22.InputType.Message) {
|
5738
6063
|
acc.messages.push(input.nonce);
|
5739
6064
|
}
|
5740
6065
|
return acc;
|
@@ -5749,20 +6074,22 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5749
6074
|
__publicField(Provider, "nodeInfoCache", {});
|
5750
6075
|
|
5751
6076
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5752
|
-
var
|
6077
|
+
var import_errors19 = require("@fuel-ts/errors");
|
5753
6078
|
var import_math20 = require("@fuel-ts/math");
|
5754
|
-
var
|
5755
|
-
var
|
6079
|
+
var import_transactions23 = require("@fuel-ts/transactions");
|
6080
|
+
var import_utils33 = require("@fuel-ts/utils");
|
5756
6081
|
|
5757
6082
|
// src/providers/chains.ts
|
5758
6083
|
var CHAIN_IDS = {
|
5759
6084
|
eth: {
|
6085
|
+
mainnet: 1,
|
5760
6086
|
sepolia: 11155111,
|
5761
6087
|
foundry: 31337
|
5762
6088
|
},
|
5763
6089
|
fuel: {
|
5764
6090
|
devnet: 0,
|
5765
|
-
testnet: 0
|
6091
|
+
testnet: 0,
|
6092
|
+
mainnet: 9889
|
5766
6093
|
}
|
5767
6094
|
};
|
5768
6095
|
|
@@ -5808,6 +6135,11 @@ var rawAssets = [
|
|
5808
6135
|
chainId: CHAIN_IDS.eth.foundry,
|
5809
6136
|
decimals: 18
|
5810
6137
|
},
|
6138
|
+
{
|
6139
|
+
type: "ethereum",
|
6140
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6141
|
+
decimals: 18
|
6142
|
+
},
|
5811
6143
|
{
|
5812
6144
|
type: "fuel",
|
5813
6145
|
chainId: CHAIN_IDS.fuel.devnet,
|
@@ -5819,6 +6151,571 @@ var rawAssets = [
|
|
5819
6151
|
chainId: CHAIN_IDS.fuel.testnet,
|
5820
6152
|
decimals: 9,
|
5821
6153
|
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6154
|
+
},
|
6155
|
+
{
|
6156
|
+
type: "fuel",
|
6157
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6158
|
+
decimals: 9,
|
6159
|
+
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6160
|
+
}
|
6161
|
+
]
|
6162
|
+
},
|
6163
|
+
{
|
6164
|
+
name: "WETH",
|
6165
|
+
symbol: "WETH",
|
6166
|
+
icon: "weth.svg",
|
6167
|
+
networks: [
|
6168
|
+
{
|
6169
|
+
type: "ethereum",
|
6170
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6171
|
+
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
6172
|
+
decimals: 18
|
6173
|
+
},
|
6174
|
+
{
|
6175
|
+
type: "fuel",
|
6176
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6177
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6178
|
+
assetId: "0xa38a5a8beeb08d95744bc7f58528073f4052b254def59eba20c99c202b5acaa3",
|
6179
|
+
decimals: 18
|
6180
|
+
}
|
6181
|
+
]
|
6182
|
+
},
|
6183
|
+
{
|
6184
|
+
name: "weETH",
|
6185
|
+
symbol: "weETH",
|
6186
|
+
icon: "weETH.webp",
|
6187
|
+
networks: [
|
6188
|
+
{
|
6189
|
+
type: "ethereum",
|
6190
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6191
|
+
address: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
|
6192
|
+
decimals: 18
|
6193
|
+
},
|
6194
|
+
{
|
6195
|
+
type: "fuel",
|
6196
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6197
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6198
|
+
assetId: "0x239ed6e12b7ce4089ee245244e3bf906999a6429c2a9a445a1e1faf56914a4ab",
|
6199
|
+
decimals: 18
|
6200
|
+
}
|
6201
|
+
]
|
6202
|
+
},
|
6203
|
+
{
|
6204
|
+
name: "rsETH",
|
6205
|
+
symbol: "rsETH",
|
6206
|
+
icon: "rsETH.webp",
|
6207
|
+
networks: [
|
6208
|
+
{
|
6209
|
+
type: "ethereum",
|
6210
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6211
|
+
address: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
|
6212
|
+
decimals: 18
|
6213
|
+
},
|
6214
|
+
{
|
6215
|
+
type: "fuel",
|
6216
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6217
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6218
|
+
assetId: "0xbae80f7fb8aa6b90d9b01ef726ec847cc4f59419c4d5f2ea88fec785d1b0e849",
|
6219
|
+
decimals: 18
|
6220
|
+
}
|
6221
|
+
]
|
6222
|
+
},
|
6223
|
+
{
|
6224
|
+
name: "rETH",
|
6225
|
+
symbol: "rETH",
|
6226
|
+
icon: "reth.svg",
|
6227
|
+
networks: [
|
6228
|
+
{
|
6229
|
+
type: "ethereum",
|
6230
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6231
|
+
address: "0xae78736cd615f374d3085123a210448e74fc6393",
|
6232
|
+
decimals: 18
|
6233
|
+
},
|
6234
|
+
{
|
6235
|
+
type: "fuel",
|
6236
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6237
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6238
|
+
assetId: "0xf3f9a0ed0ce8eac5f89d6b83e41b3848212d5b5f56108c54a205bb228ca30c16",
|
6239
|
+
decimals: 18
|
6240
|
+
}
|
6241
|
+
]
|
6242
|
+
},
|
6243
|
+
{
|
6244
|
+
name: "wbETH",
|
6245
|
+
symbol: "wbETH",
|
6246
|
+
icon: "wbeth.png",
|
6247
|
+
networks: [
|
6248
|
+
{
|
6249
|
+
type: "ethereum",
|
6250
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6251
|
+
address: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
|
6252
|
+
decimals: 18
|
6253
|
+
},
|
6254
|
+
{
|
6255
|
+
type: "fuel",
|
6256
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6257
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6258
|
+
assetId: "0x7843c74bef935e837f2bcf67b5d64ecb46dd53ff86375530b0caf3699e8ffafe",
|
6259
|
+
decimals: 18
|
6260
|
+
}
|
6261
|
+
]
|
6262
|
+
},
|
6263
|
+
{
|
6264
|
+
name: "rstETH",
|
6265
|
+
symbol: "rstETH",
|
6266
|
+
icon: "rstETH.webp",
|
6267
|
+
networks: [
|
6268
|
+
{
|
6269
|
+
type: "ethereum",
|
6270
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6271
|
+
address: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
6272
|
+
decimals: 18
|
6273
|
+
},
|
6274
|
+
{
|
6275
|
+
type: "fuel",
|
6276
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6277
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6278
|
+
assetId: "0x962792286fbc9b1d5860b4551362a12249362c21594c77abf4b3fe2bbe8d977a",
|
6279
|
+
decimals: 18
|
6280
|
+
}
|
6281
|
+
]
|
6282
|
+
},
|
6283
|
+
{
|
6284
|
+
name: "amphrETH",
|
6285
|
+
symbol: "amphrETH",
|
6286
|
+
icon: "amphrETH.png",
|
6287
|
+
networks: [
|
6288
|
+
{
|
6289
|
+
type: "ethereum",
|
6290
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6291
|
+
address: "0x5fD13359Ba15A84B76f7F87568309040176167cd",
|
6292
|
+
decimals: 18
|
6293
|
+
},
|
6294
|
+
{
|
6295
|
+
type: "fuel",
|
6296
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6297
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6298
|
+
assetId: "0x05fc623e57bd7bc1258efa8e4f62b05af5471d73df6f2c2dc11ecc81134c4f36",
|
6299
|
+
decimals: 18
|
6300
|
+
}
|
6301
|
+
]
|
6302
|
+
},
|
6303
|
+
{
|
6304
|
+
name: "Manta mBTC",
|
6305
|
+
symbol: "Manta mBTC",
|
6306
|
+
icon: "manta-mbtc.svg",
|
6307
|
+
networks: [
|
6308
|
+
{
|
6309
|
+
type: "ethereum",
|
6310
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6311
|
+
address: "0x4041381e947CFD3D483d67a25C6aa9Dc924250c5",
|
6312
|
+
decimals: 18
|
6313
|
+
},
|
6314
|
+
{
|
6315
|
+
type: "fuel",
|
6316
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6317
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6318
|
+
assetId: "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b",
|
6319
|
+
decimals: 18
|
6320
|
+
}
|
6321
|
+
]
|
6322
|
+
},
|
6323
|
+
{
|
6324
|
+
name: "Manta mETH",
|
6325
|
+
symbol: "Manta mETH",
|
6326
|
+
icon: "manta-meth.svg",
|
6327
|
+
networks: [
|
6328
|
+
{
|
6329
|
+
type: "ethereum",
|
6330
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6331
|
+
address: "0x8CdF550C04Bc9B9F10938368349C9c8051A772b6",
|
6332
|
+
decimals: 18
|
6333
|
+
},
|
6334
|
+
{
|
6335
|
+
type: "fuel",
|
6336
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6337
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6338
|
+
assetId: "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4",
|
6339
|
+
decimals: 18
|
6340
|
+
}
|
6341
|
+
]
|
6342
|
+
},
|
6343
|
+
{
|
6344
|
+
name: "Manta mUSD",
|
6345
|
+
symbol: "Manta mUSD",
|
6346
|
+
icon: "manta-musd.svg",
|
6347
|
+
networks: [
|
6348
|
+
{
|
6349
|
+
type: "ethereum",
|
6350
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6351
|
+
address: "0x3f24E1d7a973867fC2A03fE199E5502514E0e11E",
|
6352
|
+
decimals: 18
|
6353
|
+
},
|
6354
|
+
{
|
6355
|
+
type: "fuel",
|
6356
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6357
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6358
|
+
assetId: "0x89cb9401e55d49c3269654dd1cdfb0e80e57823a4a7db98ba8fc5953b120fef4",
|
6359
|
+
decimals: 18
|
6360
|
+
}
|
6361
|
+
]
|
6362
|
+
},
|
6363
|
+
{
|
6364
|
+
name: "pumpBTC",
|
6365
|
+
symbol: "pumpBTC",
|
6366
|
+
icon: "pumpbtc.webp",
|
6367
|
+
networks: [
|
6368
|
+
{
|
6369
|
+
type: "ethereum",
|
6370
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6371
|
+
address: "0xf469fbd2abcd6b9de8e169d128226c0fc90a012e",
|
6372
|
+
decimals: 8
|
6373
|
+
},
|
6374
|
+
{
|
6375
|
+
type: "fuel",
|
6376
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6377
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6378
|
+
assetId: "0x0aa5eb2bb97ca915288b653a2529355d4dc66de2b37533213f0e4aeee3d3421f",
|
6379
|
+
decimals: 8
|
6380
|
+
}
|
6381
|
+
]
|
6382
|
+
},
|
6383
|
+
{
|
6384
|
+
name: "FBTC",
|
6385
|
+
symbol: "FBTC",
|
6386
|
+
icon: "fbtc.svg",
|
6387
|
+
networks: [
|
6388
|
+
{
|
6389
|
+
type: "ethereum",
|
6390
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6391
|
+
address: "0xc96de26018a54d51c097160568752c4e3bd6c364",
|
6392
|
+
decimals: 8
|
6393
|
+
},
|
6394
|
+
{
|
6395
|
+
type: "fuel",
|
6396
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6397
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6398
|
+
assetId: "0xb5ecb0a1e08e2abbabf624ffea089df933376855f468ade35c6375b00c33996a",
|
6399
|
+
decimals: 8
|
6400
|
+
}
|
6401
|
+
]
|
6402
|
+
},
|
6403
|
+
{
|
6404
|
+
name: "SolvBTC",
|
6405
|
+
symbol: "SolvBTC",
|
6406
|
+
icon: "solvBTC.webp",
|
6407
|
+
networks: [
|
6408
|
+
{
|
6409
|
+
type: "ethereum",
|
6410
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6411
|
+
address: "0x7a56e1c57c7475ccf742a1832b028f0456652f97",
|
6412
|
+
decimals: 18
|
6413
|
+
},
|
6414
|
+
{
|
6415
|
+
type: "fuel",
|
6416
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6417
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6418
|
+
assetId: "0x1186afea9affb88809c210e13e2330b5258c2cef04bb8fff5eff372b7bd3f40f",
|
6419
|
+
decimals: 18
|
6420
|
+
}
|
6421
|
+
]
|
6422
|
+
},
|
6423
|
+
{
|
6424
|
+
name: "SolvBTC.BBN",
|
6425
|
+
symbol: "SolvBTC.BBN",
|
6426
|
+
icon: "SolvBTC.BBN.png",
|
6427
|
+
networks: [
|
6428
|
+
{
|
6429
|
+
type: "ethereum",
|
6430
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6431
|
+
address: "0xd9d920aa40f578ab794426f5c90f6c731d159def",
|
6432
|
+
decimals: 18
|
6433
|
+
},
|
6434
|
+
{
|
6435
|
+
type: "fuel",
|
6436
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6437
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6438
|
+
assetId: "0x7a4f087c957d30218223c2baaaa365355c9ca81b6ea49004cfb1590a5399216f",
|
6439
|
+
decimals: 18
|
6440
|
+
}
|
6441
|
+
]
|
6442
|
+
},
|
6443
|
+
{
|
6444
|
+
name: "Mantle mETH",
|
6445
|
+
symbol: "Mantle mETH",
|
6446
|
+
icon: "mantle-meth.svg",
|
6447
|
+
networks: [
|
6448
|
+
{
|
6449
|
+
type: "ethereum",
|
6450
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6451
|
+
address: "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa",
|
6452
|
+
decimals: 18
|
6453
|
+
},
|
6454
|
+
{
|
6455
|
+
type: "fuel",
|
6456
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6457
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6458
|
+
assetId: "0x642a5db59ec323c2f846d4d4cf3e58d78aff64accf4f8f6455ba0aa3ef000a3b",
|
6459
|
+
decimals: 18
|
6460
|
+
}
|
6461
|
+
]
|
6462
|
+
},
|
6463
|
+
{
|
6464
|
+
name: "sDAI",
|
6465
|
+
symbol: "sDAI",
|
6466
|
+
icon: "sdai.svg",
|
6467
|
+
networks: [
|
6468
|
+
{
|
6469
|
+
type: "ethereum",
|
6470
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6471
|
+
address: "0x83f20f44975d03b1b09e64809b757c47f942beea",
|
6472
|
+
decimals: 18
|
6473
|
+
},
|
6474
|
+
{
|
6475
|
+
type: "fuel",
|
6476
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6477
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6478
|
+
assetId: "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958",
|
6479
|
+
decimals: 18
|
6480
|
+
}
|
6481
|
+
]
|
6482
|
+
},
|
6483
|
+
{
|
6484
|
+
name: "USDT",
|
6485
|
+
symbol: "USDT",
|
6486
|
+
icon: "usdt.svg",
|
6487
|
+
networks: [
|
6488
|
+
{
|
6489
|
+
type: "ethereum",
|
6490
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6491
|
+
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
6492
|
+
decimals: 6
|
6493
|
+
},
|
6494
|
+
{
|
6495
|
+
type: "fuel",
|
6496
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6497
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6498
|
+
assetId: "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e",
|
6499
|
+
decimals: 6
|
6500
|
+
}
|
6501
|
+
]
|
6502
|
+
},
|
6503
|
+
{
|
6504
|
+
name: "USDC",
|
6505
|
+
symbol: "USDC",
|
6506
|
+
icon: "usdc.svg",
|
6507
|
+
networks: [
|
6508
|
+
{
|
6509
|
+
type: "ethereum",
|
6510
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6511
|
+
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
6512
|
+
decimals: 6
|
6513
|
+
},
|
6514
|
+
{
|
6515
|
+
type: "fuel",
|
6516
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6517
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6518
|
+
assetId: "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b",
|
6519
|
+
decimals: 6
|
6520
|
+
}
|
6521
|
+
]
|
6522
|
+
},
|
6523
|
+
{
|
6524
|
+
name: "USDe",
|
6525
|
+
symbol: "USDe",
|
6526
|
+
icon: "USDe.svg",
|
6527
|
+
networks: [
|
6528
|
+
{
|
6529
|
+
type: "ethereum",
|
6530
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6531
|
+
address: "0x4c9edd5852cd905f086c759e8383e09bff1e68b3",
|
6532
|
+
decimals: 18
|
6533
|
+
},
|
6534
|
+
{
|
6535
|
+
type: "ethereum",
|
6536
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6537
|
+
address: "0xc6387efad0f184a90b34f397c3d6fd63135ef790",
|
6538
|
+
decimals: 18
|
6539
|
+
},
|
6540
|
+
{
|
6541
|
+
type: "fuel",
|
6542
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6543
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6544
|
+
assetId: "0xb6133b2ef9f6153eb869125d23dcf20d1e735331b5e41b15a6a7a6cec70e8651",
|
6545
|
+
decimals: 18
|
6546
|
+
},
|
6547
|
+
{
|
6548
|
+
type: "fuel",
|
6549
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6550
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6551
|
+
assetId: "0xf5c6d72d0f2c782fa47d8e228c198a08654e9fc66ca60ad85902b1d09046a7ab",
|
6552
|
+
decimals: 18
|
6553
|
+
}
|
6554
|
+
]
|
6555
|
+
},
|
6556
|
+
{
|
6557
|
+
name: "sUSDe",
|
6558
|
+
symbol: "sUSDe",
|
6559
|
+
icon: "sUSDe.webp",
|
6560
|
+
networks: [
|
6561
|
+
{
|
6562
|
+
type: "ethereum",
|
6563
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6564
|
+
address: "0x9d39a5de30e57443bff2a8307a4256c8797a3497",
|
6565
|
+
decimals: 18
|
6566
|
+
},
|
6567
|
+
{
|
6568
|
+
type: "ethereum",
|
6569
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6570
|
+
address: "0xb8f4f4eafc1d2a3c0a4d519bbf1114c311cc9b1b",
|
6571
|
+
decimals: 18
|
6572
|
+
},
|
6573
|
+
{
|
6574
|
+
type: "fuel",
|
6575
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6576
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6577
|
+
assetId: "0xd05563025104fc36496c15c7021ad6b31034b0e89a356f4f818045d1f48808bc",
|
6578
|
+
decimals: 18
|
6579
|
+
},
|
6580
|
+
{
|
6581
|
+
type: "fuel",
|
6582
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6583
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6584
|
+
assetId: "0xa86e37d385c08beddbb02c8260f9ec535d484c8ea908fc19d4e6dc8d5141fb2e",
|
6585
|
+
decimals: 18
|
6586
|
+
}
|
6587
|
+
]
|
6588
|
+
},
|
6589
|
+
{
|
6590
|
+
name: "rsUSDe",
|
6591
|
+
symbol: "rsUSDe",
|
6592
|
+
icon: "rsUSDe.svg",
|
6593
|
+
networks: [
|
6594
|
+
{
|
6595
|
+
type: "ethereum",
|
6596
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6597
|
+
address: "0x82f5104b23FF2FA54C2345F821dAc9369e9E0B26",
|
6598
|
+
decimals: 18
|
6599
|
+
},
|
6600
|
+
{
|
6601
|
+
type: "fuel",
|
6602
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6603
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6604
|
+
assetId: "0x78d4522ec607f6e8efb66ea49439d1ee48623cf763f9688a8eada025def033d9",
|
6605
|
+
decimals: 18
|
6606
|
+
}
|
6607
|
+
]
|
6608
|
+
},
|
6609
|
+
{
|
6610
|
+
name: "wstETH",
|
6611
|
+
symbol: "wstETH",
|
6612
|
+
icon: "wsteth.svg",
|
6613
|
+
networks: [
|
6614
|
+
{
|
6615
|
+
type: "ethereum",
|
6616
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6617
|
+
address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
6618
|
+
decimals: 18
|
6619
|
+
},
|
6620
|
+
{
|
6621
|
+
type: "ethereum",
|
6622
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6623
|
+
address: "0xB82381A3fBD3FaFA77B3a7bE693342618240067b",
|
6624
|
+
decimals: 18
|
6625
|
+
},
|
6626
|
+
{
|
6627
|
+
type: "fuel",
|
6628
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6629
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6630
|
+
assetId: "0x1a7815cc9f75db5c24a5b0814bfb706bb9fe485333e98254015de8f48f84c67b",
|
6631
|
+
decimals: 18
|
6632
|
+
},
|
6633
|
+
{
|
6634
|
+
type: "fuel",
|
6635
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6636
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6637
|
+
assetId: "0x4c467e3fd4f32179e1aad3b92ebbdaa6ff6aeda5b8da5f8e64e96405eb52a7f5",
|
6638
|
+
decimals: 18
|
6639
|
+
}
|
6640
|
+
]
|
6641
|
+
},
|
6642
|
+
{
|
6643
|
+
name: "ezETH",
|
6644
|
+
symbol: "ezETH",
|
6645
|
+
icon: "ezeth.webp",
|
6646
|
+
networks: [
|
6647
|
+
{
|
6648
|
+
type: "ethereum",
|
6649
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6650
|
+
address: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
|
6651
|
+
decimals: 18
|
6652
|
+
},
|
6653
|
+
{
|
6654
|
+
type: "fuel",
|
6655
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6656
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6657
|
+
assetId: "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0",
|
6658
|
+
decimals: 18
|
6659
|
+
}
|
6660
|
+
]
|
6661
|
+
},
|
6662
|
+
{
|
6663
|
+
name: "pzETH",
|
6664
|
+
symbol: "pzETH",
|
6665
|
+
icon: "pzETH.webp",
|
6666
|
+
networks: [
|
6667
|
+
{
|
6668
|
+
type: "ethereum",
|
6669
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6670
|
+
address: "0x8c9532a60e0e7c6bbd2b2c1303f63ace1c3e9811",
|
6671
|
+
decimals: 18
|
6672
|
+
},
|
6673
|
+
{
|
6674
|
+
type: "fuel",
|
6675
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6676
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6677
|
+
assetId: "0x1493d4ec82124de8f9b625682de69dcccda79e882b89a55a8c737b12de67bd68",
|
6678
|
+
decimals: 18
|
6679
|
+
}
|
6680
|
+
]
|
6681
|
+
},
|
6682
|
+
{
|
6683
|
+
name: "Re7LRT",
|
6684
|
+
symbol: "Re7LRT",
|
6685
|
+
icon: "Re7LRT.png",
|
6686
|
+
networks: [
|
6687
|
+
{
|
6688
|
+
type: "ethereum",
|
6689
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6690
|
+
address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a",
|
6691
|
+
decimals: 18
|
6692
|
+
},
|
6693
|
+
{
|
6694
|
+
type: "fuel",
|
6695
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6696
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6697
|
+
assetId: "0xf2fc648c23a5db24610a1cf696acc4f0f6d9a7d6028dd9944964ab23f6e35995",
|
6698
|
+
decimals: 18
|
6699
|
+
}
|
6700
|
+
]
|
6701
|
+
},
|
6702
|
+
{
|
6703
|
+
name: "steakLRT",
|
6704
|
+
symbol: "steakLRT",
|
6705
|
+
icon: "steakLRT.png",
|
6706
|
+
networks: [
|
6707
|
+
{
|
6708
|
+
type: "ethereum",
|
6709
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6710
|
+
address: "0xBEEF69Ac7870777598A04B2bd4771c71212E6aBc",
|
6711
|
+
decimals: 18
|
6712
|
+
},
|
6713
|
+
{
|
6714
|
+
type: "fuel",
|
6715
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6716
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6717
|
+
assetId: "0x4fc8ac9f101df07e2c2dec4a53c8c42c439bdbe5e36ea2d863a61ff60afafc30",
|
6718
|
+
decimals: 18
|
5822
6719
|
}
|
5823
6720
|
]
|
5824
6721
|
}
|
@@ -5827,7 +6724,7 @@ var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
|
5827
6724
|
|
5828
6725
|
// src/test-utils/test-asset-id.ts
|
5829
6726
|
var import_crypto4 = require("@fuel-ts/crypto");
|
5830
|
-
var
|
6727
|
+
var import_utils35 = require("@fuel-ts/utils");
|
5831
6728
|
var _TestAssetId = class {
|
5832
6729
|
constructor(value) {
|
5833
6730
|
this.value = value;
|
@@ -5835,7 +6732,7 @@ var _TestAssetId = class {
|
|
5835
6732
|
static random(count = 1) {
|
5836
6733
|
const assetIds = [];
|
5837
6734
|
for (let i = 0; i < count; i++) {
|
5838
|
-
assetIds.push(new _TestAssetId((0,
|
6735
|
+
assetIds.push(new _TestAssetId((0, import_utils35.hexlify)((0, import_crypto4.randomBytes)(32))));
|
5839
6736
|
}
|
5840
6737
|
return assetIds;
|
5841
6738
|
}
|
@@ -5850,23 +6747,23 @@ __publicField(TestAssetId, "B", new _TestAssetId(
|
|
5850
6747
|
|
5851
6748
|
// src/test-utils/wallet-config.ts
|
5852
6749
|
var import_crypto9 = require("@fuel-ts/crypto");
|
5853
|
-
var
|
5854
|
-
var
|
6750
|
+
var import_errors25 = require("@fuel-ts/errors");
|
6751
|
+
var import_utils44 = require("@fuel-ts/utils");
|
5855
6752
|
|
5856
6753
|
// src/wallet/base-wallet-unlocked.ts
|
5857
|
-
var
|
5858
|
-
var
|
6754
|
+
var import_hasher4 = require("@fuel-ts/hasher");
|
6755
|
+
var import_utils39 = require("@fuel-ts/utils");
|
5859
6756
|
|
5860
6757
|
// src/account.ts
|
5861
6758
|
var import_abi_coder8 = require("@fuel-ts/abi-coder");
|
5862
6759
|
var import_address5 = require("@fuel-ts/address");
|
5863
6760
|
var import_crypto5 = require("@fuel-ts/crypto");
|
5864
|
-
var
|
6761
|
+
var import_errors20 = require("@fuel-ts/errors");
|
5865
6762
|
var import_interfaces = require("@fuel-ts/interfaces");
|
5866
6763
|
var import_math22 = require("@fuel-ts/math");
|
5867
|
-
var
|
5868
|
-
var
|
5869
|
-
var
|
6764
|
+
var import_transactions24 = require("@fuel-ts/transactions");
|
6765
|
+
var import_utils37 = require("@fuel-ts/utils");
|
6766
|
+
var import_ramda9 = require("ramda");
|
5870
6767
|
|
5871
6768
|
// src/providers/utils/merge-quantities.ts
|
5872
6769
|
var mergeQuantities = (...coinQuantities) => {
|
@@ -5885,16 +6782,16 @@ var mergeQuantities = (...coinQuantities) => {
|
|
5885
6782
|
// src/utils/formatTransferToContractScriptData.ts
|
5886
6783
|
var import_abi_coder7 = require("@fuel-ts/abi-coder");
|
5887
6784
|
var import_math21 = require("@fuel-ts/math");
|
5888
|
-
var
|
6785
|
+
var import_utils36 = require("@fuel-ts/utils");
|
5889
6786
|
var asm = __toESM(require("@fuels/vm-asm"));
|
5890
6787
|
var formatTransferToContractScriptData = (params) => {
|
5891
6788
|
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
5892
6789
|
const numberCoder = new import_abi_coder7.BigNumberCoder("u64");
|
5893
6790
|
const encoded = numberCoder.encode(new import_math21.BN(amountToTransfer).toNumber());
|
5894
6791
|
const scriptData = Uint8Array.from([
|
5895
|
-
...(0,
|
6792
|
+
...(0, import_utils36.arrayify)(hexlifiedContractId),
|
5896
6793
|
...encoded,
|
5897
|
-
...(0,
|
6794
|
+
...(0, import_utils36.arrayify)(assetId)
|
5898
6795
|
]);
|
5899
6796
|
return scriptData;
|
5900
6797
|
};
|
@@ -5955,7 +6852,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5955
6852
|
*/
|
5956
6853
|
get provider() {
|
5957
6854
|
if (!this._provider) {
|
5958
|
-
throw new
|
6855
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.MISSING_PROVIDER, "Provider not set");
|
5959
6856
|
}
|
5960
6857
|
return this._provider;
|
5961
6858
|
}
|
@@ -6073,7 +6970,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6073
6970
|
);
|
6074
6971
|
request.addResources(resources);
|
6075
6972
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6076
|
-
const requestToReestimate2 = (0,
|
6973
|
+
const requestToReestimate2 = (0, import_ramda9.clone)(request);
|
6077
6974
|
if (addedSignatures) {
|
6078
6975
|
Array.from({ length: addedSignatures }).forEach(
|
6079
6976
|
() => requestToReestimate2.addEmptyWitness()
|
@@ -6106,13 +7003,13 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6106
7003
|
fundingAttempts += 1;
|
6107
7004
|
}
|
6108
7005
|
if (needsToBeFunded) {
|
6109
|
-
throw new
|
6110
|
-
|
7006
|
+
throw new import_errors20.FuelError(
|
7007
|
+
import_errors20.ErrorCode.NOT_ENOUGH_FUNDS,
|
6111
7008
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6112
7009
|
);
|
6113
7010
|
}
|
6114
7011
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6115
|
-
const requestToReestimate = (0,
|
7012
|
+
const requestToReestimate = (0, import_ramda9.clone)(request);
|
6116
7013
|
if (addedSignatures) {
|
6117
7014
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
6118
7015
|
}
|
@@ -6212,8 +7109,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6212
7109
|
*/
|
6213
7110
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6214
7111
|
if ((0, import_math22.bn)(amount).lte(0)) {
|
6215
|
-
throw new
|
6216
|
-
|
7112
|
+
throw new import_errors20.FuelError(
|
7113
|
+
import_errors20.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6217
7114
|
"Transfer amount must be a positive number."
|
6218
7115
|
);
|
6219
7116
|
}
|
@@ -6252,14 +7149,14 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6252
7149
|
*/
|
6253
7150
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
6254
7151
|
const recipientAddress = import_address5.Address.fromAddressOrString(recipient);
|
6255
|
-
const recipientDataArray = (0,
|
7152
|
+
const recipientDataArray = (0, import_utils37.arrayify)(
|
6256
7153
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
6257
7154
|
);
|
6258
|
-
const amountDataArray = (0,
|
7155
|
+
const amountDataArray = (0, import_utils37.arrayify)(
|
6259
7156
|
"0x".concat((0, import_math22.bn)(amount).toHex().substring(2).padStart(16, "0"))
|
6260
7157
|
);
|
6261
7158
|
const script = new Uint8Array([
|
6262
|
-
...(0,
|
7159
|
+
...(0, import_utils37.arrayify)(withdrawScript.bytes),
|
6263
7160
|
...recipientDataArray,
|
6264
7161
|
...amountDataArray
|
6265
7162
|
]);
|
@@ -6288,13 +7185,13 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6288
7185
|
* @returns A promise that resolves to the transaction cost object.
|
6289
7186
|
*/
|
6290
7187
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6291
|
-
const txRequestClone = (0,
|
7188
|
+
const txRequestClone = (0, import_ramda9.clone)(transactionRequestify(transactionRequestLike));
|
6292
7189
|
const baseAssetId = this.provider.getBaseAssetId();
|
6293
7190
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6294
7191
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
6295
7192
|
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math22.bn)("100000000000000000") }];
|
6296
7193
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
6297
|
-
if (input.type ===
|
7194
|
+
if (input.type === import_transactions24.InputType.Coin) {
|
6298
7195
|
return input.assetId === assetId;
|
6299
7196
|
}
|
6300
7197
|
if (isRequestInputMessageWithoutData(input)) {
|
@@ -6339,7 +7236,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6339
7236
|
*/
|
6340
7237
|
async signMessage(message) {
|
6341
7238
|
if (!this._connector) {
|
6342
|
-
throw new
|
7239
|
+
throw new import_errors20.FuelError(import_errors20.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6343
7240
|
}
|
6344
7241
|
return this._connector.signMessage(this.address.toString(), message);
|
6345
7242
|
}
|
@@ -6351,8 +7248,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6351
7248
|
*/
|
6352
7249
|
async signTransaction(transactionRequestLike) {
|
6353
7250
|
if (!this._connector) {
|
6354
|
-
throw new
|
6355
|
-
|
7251
|
+
throw new import_errors20.FuelError(
|
7252
|
+
import_errors20.ErrorCode.MISSING_CONNECTOR,
|
6356
7253
|
"A connector is required to sign transactions."
|
6357
7254
|
);
|
6358
7255
|
}
|
@@ -6401,7 +7298,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6401
7298
|
*/
|
6402
7299
|
generateFakeResources(coins) {
|
6403
7300
|
return coins.map((coin) => ({
|
6404
|
-
id: (0,
|
7301
|
+
id: (0, import_utils37.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
|
6405
7302
|
owner: this.address,
|
6406
7303
|
blockCreated: (0, import_math22.bn)(1),
|
6407
7304
|
txCreatedIdx: (0, import_math22.bn)(1),
|
@@ -6411,8 +7308,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6411
7308
|
/** @hidden * */
|
6412
7309
|
validateTransferAmount(amount) {
|
6413
7310
|
if ((0, import_math22.bn)(amount).lte(0)) {
|
6414
|
-
throw new
|
6415
|
-
|
7311
|
+
throw new import_errors20.FuelError(
|
7312
|
+
import_errors20.ErrorCode.INVALID_TRANSFER_AMOUNT,
|
6416
7313
|
"Transfer amount must be a positive number."
|
6417
7314
|
);
|
6418
7315
|
}
|
@@ -6438,19 +7335,19 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6438
7335
|
txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
|
6439
7336
|
}) {
|
6440
7337
|
const request = transactionRequestify(transactionRequest);
|
6441
|
-
if (!(0,
|
7338
|
+
if (!(0, import_utils37.isDefined)(setGasLimit)) {
|
6442
7339
|
request.gasLimit = gasUsed;
|
6443
7340
|
} else if (gasUsed.gt(setGasLimit)) {
|
6444
|
-
throw new
|
6445
|
-
|
7341
|
+
throw new import_errors20.FuelError(
|
7342
|
+
import_errors20.ErrorCode.GAS_LIMIT_TOO_LOW,
|
6446
7343
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6447
7344
|
);
|
6448
7345
|
}
|
6449
|
-
if (!(0,
|
7346
|
+
if (!(0, import_utils37.isDefined)(setMaxFee)) {
|
6450
7347
|
request.maxFee = maxFee;
|
6451
7348
|
} else if (maxFee.gt(setMaxFee)) {
|
6452
|
-
throw new
|
6453
|
-
|
7349
|
+
throw new import_errors20.FuelError(
|
7350
|
+
import_errors20.ErrorCode.MAX_FEE_TOO_LOW,
|
6454
7351
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6455
7352
|
);
|
6456
7353
|
}
|
@@ -6461,8 +7358,8 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
6461
7358
|
// src/wallet/keystore-wallet.ts
|
6462
7359
|
var import_address6 = require("@fuel-ts/address");
|
6463
7360
|
var import_crypto6 = require("@fuel-ts/crypto");
|
6464
|
-
var
|
6465
|
-
var
|
7361
|
+
var import_errors21 = require("@fuel-ts/errors");
|
7362
|
+
var import_utils38 = require("@fuel-ts/utils");
|
6466
7363
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6467
7364
|
var DEFAULT_KDF_PARAMS_R = 8;
|
6468
7365
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -6538,13 +7435,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6538
7435
|
const macHashUint8Array = (0, import_crypto6.keccak256)(data);
|
6539
7436
|
const macHash = (0, import_crypto6.stringFromBuffer)(macHashUint8Array, "hex");
|
6540
7437
|
if (mac !== macHash) {
|
6541
|
-
throw new
|
6542
|
-
|
7438
|
+
throw new import_errors21.FuelError(
|
7439
|
+
import_errors21.ErrorCode.INVALID_PASSWORD,
|
6543
7440
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6544
7441
|
);
|
6545
7442
|
}
|
6546
7443
|
const buffer = await (0, import_crypto6.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
|
6547
|
-
const privateKey = (0,
|
7444
|
+
const privateKey = (0, import_utils38.hexlify)(buffer);
|
6548
7445
|
return privateKey;
|
6549
7446
|
}
|
6550
7447
|
|
@@ -6588,8 +7485,8 @@ var BaseWalletUnlocked = class extends Account {
|
|
6588
7485
|
* @returns A promise that resolves to the signature as a ECDSA 64 bytes string.
|
6589
7486
|
*/
|
6590
7487
|
async signMessage(message) {
|
6591
|
-
const signedMessage = await this.signer().sign((0,
|
6592
|
-
return (0,
|
7488
|
+
const signedMessage = await this.signer().sign((0, import_hasher4.hashMessage)(message));
|
7489
|
+
return (0, import_utils39.hexlify)(signedMessage);
|
6593
7490
|
}
|
6594
7491
|
/**
|
6595
7492
|
* Signs a transaction with the wallet's private key.
|
@@ -6602,7 +7499,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6602
7499
|
const chainId = this.provider.getChainId();
|
6603
7500
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6604
7501
|
const signature = await this.signer().sign(hashedTransaction);
|
6605
|
-
return (0,
|
7502
|
+
return (0, import_utils39.hexlify)(signature);
|
6606
7503
|
}
|
6607
7504
|
/**
|
6608
7505
|
* Populates a transaction with the witnesses signature.
|
@@ -6669,16 +7566,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6669
7566
|
|
6670
7567
|
// src/hdwallet/hdwallet.ts
|
6671
7568
|
var import_crypto8 = require("@fuel-ts/crypto");
|
6672
|
-
var
|
6673
|
-
var
|
7569
|
+
var import_errors24 = require("@fuel-ts/errors");
|
7570
|
+
var import_hasher7 = require("@fuel-ts/hasher");
|
6674
7571
|
var import_math23 = require("@fuel-ts/math");
|
6675
|
-
var
|
7572
|
+
var import_utils43 = require("@fuel-ts/utils");
|
6676
7573
|
|
6677
7574
|
// src/mnemonic/mnemonic.ts
|
6678
7575
|
var import_crypto7 = require("@fuel-ts/crypto");
|
6679
|
-
var
|
6680
|
-
var
|
6681
|
-
var
|
7576
|
+
var import_errors23 = require("@fuel-ts/errors");
|
7577
|
+
var import_hasher6 = require("@fuel-ts/hasher");
|
7578
|
+
var import_utils41 = require("@fuel-ts/utils");
|
6682
7579
|
|
6683
7580
|
// src/wordlists/words/english.ts
|
6684
7581
|
var english = [
|
@@ -8733,9 +9630,9 @@ var english = [
|
|
8733
9630
|
];
|
8734
9631
|
|
8735
9632
|
// src/mnemonic/utils.ts
|
8736
|
-
var
|
8737
|
-
var
|
8738
|
-
var
|
9633
|
+
var import_errors22 = require("@fuel-ts/errors");
|
9634
|
+
var import_hasher5 = require("@fuel-ts/hasher");
|
9635
|
+
var import_utils40 = require("@fuel-ts/utils");
|
8739
9636
|
function getLowerMask(bits) {
|
8740
9637
|
return (1 << bits) - 1;
|
8741
9638
|
}
|
@@ -8770,20 +9667,20 @@ function entropyToMnemonicIndices(entropy) {
|
|
8770
9667
|
}
|
8771
9668
|
}
|
8772
9669
|
const checksumBits = entropy.length / 4;
|
8773
|
-
const checksum = (0,
|
9670
|
+
const checksum = (0, import_utils40.arrayify)((0, import_hasher5.sha256)(entropy))[0] & getUpperMask(checksumBits);
|
8774
9671
|
indices[indices.length - 1] <<= checksumBits;
|
8775
9672
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8776
9673
|
return indices;
|
8777
9674
|
}
|
8778
9675
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8779
9676
|
const size = Math.ceil(11 * words.length / 8);
|
8780
|
-
const entropy = (0,
|
9677
|
+
const entropy = (0, import_utils40.arrayify)(new Uint8Array(size));
|
8781
9678
|
let offset = 0;
|
8782
9679
|
for (let i = 0; i < words.length; i += 1) {
|
8783
9680
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8784
9681
|
if (index === -1) {
|
8785
|
-
throw new
|
8786
|
-
|
9682
|
+
throw new import_errors22.FuelError(
|
9683
|
+
import_errors22.ErrorCode.INVALID_MNEMONIC,
|
8787
9684
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8788
9685
|
);
|
8789
9686
|
}
|
@@ -8797,10 +9694,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8797
9694
|
const entropyBits = 32 * words.length / 3;
|
8798
9695
|
const checksumBits = words.length / 3;
|
8799
9696
|
const checksumMask = getUpperMask(checksumBits);
|
8800
|
-
const checksum = (0,
|
9697
|
+
const checksum = (0, import_utils40.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8801
9698
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8802
|
-
throw new
|
8803
|
-
|
9699
|
+
throw new import_errors22.FuelError(
|
9700
|
+
import_errors22.ErrorCode.INVALID_CHECKSUM,
|
8804
9701
|
"Checksum validation failed for the provided mnemonic."
|
8805
9702
|
);
|
8806
9703
|
}
|
@@ -8808,22 +9705,22 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8808
9705
|
}
|
8809
9706
|
|
8810
9707
|
// src/mnemonic/mnemonic.ts
|
8811
|
-
var MasterSecret = (0,
|
9708
|
+
var MasterSecret = (0, import_utils41.toUtf8Bytes)("Bitcoin seed");
|
8812
9709
|
var MainnetPRV = "0x0488ade4";
|
8813
9710
|
var TestnetPRV = "0x04358394";
|
8814
9711
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8815
9712
|
function assertWordList(wordlist) {
|
8816
9713
|
if (wordlist.length !== 2048) {
|
8817
|
-
throw new
|
8818
|
-
|
9714
|
+
throw new import_errors23.FuelError(
|
9715
|
+
import_errors23.ErrorCode.INVALID_WORD_LIST,
|
8819
9716
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8820
9717
|
);
|
8821
9718
|
}
|
8822
9719
|
}
|
8823
9720
|
function assertEntropy(entropy) {
|
8824
9721
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8825
|
-
throw new
|
8826
|
-
|
9722
|
+
throw new import_errors23.FuelError(
|
9723
|
+
import_errors23.ErrorCode.INVALID_ENTROPY,
|
8827
9724
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8828
9725
|
);
|
8829
9726
|
}
|
@@ -8833,7 +9730,7 @@ function assertMnemonic(words) {
|
|
8833
9730
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8834
9731
|
", "
|
8835
9732
|
)}] words, but got ${words.length}.`;
|
8836
|
-
throw new
|
9733
|
+
throw new import_errors23.FuelError(import_errors23.ErrorCode.INVALID_MNEMONIC, errorMsg);
|
8837
9734
|
}
|
8838
9735
|
}
|
8839
9736
|
var Mnemonic = class {
|
@@ -8872,7 +9769,7 @@ var Mnemonic = class {
|
|
8872
9769
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8873
9770
|
const words = getWords(phrase);
|
8874
9771
|
assertMnemonic(words);
|
8875
|
-
return (0,
|
9772
|
+
return (0, import_utils41.hexlify)(mnemonicWordsToEntropy(words, wordlist));
|
8876
9773
|
}
|
8877
9774
|
/**
|
8878
9775
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8880,7 +9777,7 @@ var Mnemonic = class {
|
|
8880
9777
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8881
9778
|
*/
|
8882
9779
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8883
|
-
const entropyBytes = (0,
|
9780
|
+
const entropyBytes = (0, import_utils41.arrayify)(entropy);
|
8884
9781
|
assertWordList(wordlist);
|
8885
9782
|
assertEntropy(entropyBytes);
|
8886
9783
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -8892,8 +9789,8 @@ var Mnemonic = class {
|
|
8892
9789
|
*/
|
8893
9790
|
static mnemonicToSeed(phrase, passphrase = "") {
|
8894
9791
|
assertMnemonic(getWords(phrase));
|
8895
|
-
const phraseBytes = (0,
|
8896
|
-
const salt = (0,
|
9792
|
+
const phraseBytes = (0, import_utils41.toUtf8Bytes)(getPhrase(phrase));
|
9793
|
+
const salt = (0, import_utils41.toUtf8Bytes)(`mnemonic${passphrase}`);
|
8897
9794
|
return (0, import_crypto7.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
|
8898
9795
|
}
|
8899
9796
|
/**
|
@@ -8949,14 +9846,14 @@ var Mnemonic = class {
|
|
8949
9846
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8950
9847
|
*/
|
8951
9848
|
static masterKeysFromSeed(seed) {
|
8952
|
-
const seedArray = (0,
|
9849
|
+
const seedArray = (0, import_utils41.arrayify)(seed);
|
8953
9850
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
8954
|
-
throw new
|
8955
|
-
|
9851
|
+
throw new import_errors23.FuelError(
|
9852
|
+
import_errors23.ErrorCode.INVALID_SEED,
|
8956
9853
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
8957
9854
|
);
|
8958
9855
|
}
|
8959
|
-
return (0,
|
9856
|
+
return (0, import_utils41.arrayify)((0, import_crypto7.computeHmac)("sha512", MasterSecret, seedArray));
|
8960
9857
|
}
|
8961
9858
|
/**
|
8962
9859
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -8967,22 +9864,22 @@ var Mnemonic = class {
|
|
8967
9864
|
*/
|
8968
9865
|
static seedToExtendedKey(seed, testnet = false) {
|
8969
9866
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
8970
|
-
const prefix = (0,
|
9867
|
+
const prefix = (0, import_utils41.arrayify)(testnet ? TestnetPRV : MainnetPRV);
|
8971
9868
|
const depth = "0x00";
|
8972
9869
|
const fingerprint = "0x00000000";
|
8973
9870
|
const index = "0x00000000";
|
8974
9871
|
const chainCode = masterKey.slice(32);
|
8975
9872
|
const privateKey = masterKey.slice(0, 32);
|
8976
|
-
const extendedKey = (0,
|
9873
|
+
const extendedKey = (0, import_utils41.concat)([
|
8977
9874
|
prefix,
|
8978
9875
|
depth,
|
8979
9876
|
fingerprint,
|
8980
9877
|
index,
|
8981
9878
|
chainCode,
|
8982
|
-
(0,
|
9879
|
+
(0, import_utils41.concat)(["0x00", privateKey])
|
8983
9880
|
]);
|
8984
|
-
const checksum = (0,
|
8985
|
-
return (0,
|
9881
|
+
const checksum = (0, import_utils41.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(extendedKey)), 0, 4);
|
9882
|
+
return (0, import_utils41.encodeBase58)((0, import_utils41.concat)([extendedKey, checksum]));
|
8986
9883
|
}
|
8987
9884
|
/**
|
8988
9885
|
* Create a new mnemonic using a randomly generated number as entropy.
|
@@ -8997,7 +9894,7 @@ var Mnemonic = class {
|
|
8997
9894
|
* @returns A randomly generated mnemonic
|
8998
9895
|
*/
|
8999
9896
|
static generate(size = 32, extraEntropy = "") {
|
9000
|
-
const entropy = extraEntropy ? (0,
|
9897
|
+
const entropy = extraEntropy ? (0, import_hasher6.sha256)((0, import_utils41.concat)([(0, import_crypto7.randomBytes)(size), (0, import_utils41.arrayify)(extraEntropy)])) : (0, import_crypto7.randomBytes)(size);
|
9001
9898
|
return Mnemonic.entropyToMnemonic(entropy);
|
9002
9899
|
}
|
9003
9900
|
};
|
@@ -9005,12 +9902,12 @@ var mnemonic_default = Mnemonic;
|
|
9005
9902
|
|
9006
9903
|
// src/hdwallet/hdwallet.ts
|
9007
9904
|
var HARDENED_INDEX = 2147483648;
|
9008
|
-
var MainnetPRV2 = (0,
|
9009
|
-
var MainnetPUB = (0,
|
9010
|
-
var TestnetPRV2 = (0,
|
9011
|
-
var TestnetPUB = (0,
|
9905
|
+
var MainnetPRV2 = (0, import_utils43.hexlify)("0x0488ade4");
|
9906
|
+
var MainnetPUB = (0, import_utils43.hexlify)("0x0488b21e");
|
9907
|
+
var TestnetPRV2 = (0, import_utils43.hexlify)("0x04358394");
|
9908
|
+
var TestnetPUB = (0, import_utils43.hexlify)("0x043587cf");
|
9012
9909
|
function base58check(data) {
|
9013
|
-
return (0,
|
9910
|
+
return (0, import_utils43.encodeBase58)((0, import_utils43.concat)([data, (0, import_utils43.dataSlice)((0, import_hasher7.sha256)((0, import_hasher7.sha256)(data)), 0, 4)]));
|
9014
9911
|
}
|
9015
9912
|
function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
9016
9913
|
if (isPublic) {
|
@@ -9019,17 +9916,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
9019
9916
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
9020
9917
|
}
|
9021
9918
|
function isPublicExtendedKey(extendedKey) {
|
9022
|
-
return [MainnetPUB, TestnetPUB].includes((0,
|
9919
|
+
return [MainnetPUB, TestnetPUB].includes((0, import_utils43.hexlify)(extendedKey.slice(0, 4)));
|
9023
9920
|
}
|
9024
9921
|
function isValidExtendedKey(extendedKey) {
|
9025
9922
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
9026
|
-
(0,
|
9923
|
+
(0, import_utils43.hexlify)(extendedKey.slice(0, 4))
|
9027
9924
|
);
|
9028
9925
|
}
|
9029
9926
|
function parsePath(path2, depth = 0) {
|
9030
9927
|
const components = path2.split("/");
|
9031
9928
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9032
|
-
throw new
|
9929
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
|
9033
9930
|
}
|
9034
9931
|
if (components[0] === "m") {
|
9035
9932
|
components.shift();
|
@@ -9041,8 +9938,8 @@ function parsePath(path2, depth = 0) {
|
|
9041
9938
|
var HDWallet = class {
|
9042
9939
|
depth = 0;
|
9043
9940
|
index = 0;
|
9044
|
-
fingerprint = (0,
|
9045
|
-
parentFingerprint = (0,
|
9941
|
+
fingerprint = (0, import_utils43.hexlify)("0x00000000");
|
9942
|
+
parentFingerprint = (0, import_utils43.hexlify)("0x00000000");
|
9046
9943
|
privateKey;
|
9047
9944
|
publicKey;
|
9048
9945
|
chainCode;
|
@@ -9054,19 +9951,19 @@ var HDWallet = class {
|
|
9054
9951
|
constructor(config) {
|
9055
9952
|
if (config.privateKey) {
|
9056
9953
|
const signer = new Signer(config.privateKey);
|
9057
|
-
this.publicKey = (0,
|
9058
|
-
this.privateKey = (0,
|
9954
|
+
this.publicKey = (0, import_utils43.hexlify)(signer.compressedPublicKey);
|
9955
|
+
this.privateKey = (0, import_utils43.hexlify)(config.privateKey);
|
9059
9956
|
} else {
|
9060
9957
|
if (!config.publicKey) {
|
9061
|
-
throw new
|
9062
|
-
|
9958
|
+
throw new import_errors24.FuelError(
|
9959
|
+
import_errors24.ErrorCode.HD_WALLET_ERROR,
|
9063
9960
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9064
9961
|
);
|
9065
9962
|
}
|
9066
|
-
this.publicKey = (0,
|
9963
|
+
this.publicKey = (0, import_utils43.hexlify)(config.publicKey);
|
9067
9964
|
}
|
9068
9965
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
9069
|
-
this.fingerprint = (0,
|
9966
|
+
this.fingerprint = (0, import_utils43.dataSlice)((0, import_crypto8.ripemd160)((0, import_hasher7.sha256)(this.publicKey)), 0, 4);
|
9070
9967
|
this.depth = config.depth || this.depth;
|
9071
9968
|
this.index = config.index || this.index;
|
9072
9969
|
this.chainCode = config.chainCode;
|
@@ -9082,23 +9979,23 @@ var HDWallet = class {
|
|
9082
9979
|
* @returns A new instance of HDWallet on the derived index
|
9083
9980
|
*/
|
9084
9981
|
deriveIndex(index) {
|
9085
|
-
const privateKey = this.privateKey && (0,
|
9086
|
-
const publicKey = (0,
|
9087
|
-
const chainCode = (0,
|
9982
|
+
const privateKey = this.privateKey && (0, import_utils43.arrayify)(this.privateKey);
|
9983
|
+
const publicKey = (0, import_utils43.arrayify)(this.publicKey);
|
9984
|
+
const chainCode = (0, import_utils43.arrayify)(this.chainCode);
|
9088
9985
|
const data = new Uint8Array(37);
|
9089
9986
|
if (index & HARDENED_INDEX) {
|
9090
9987
|
if (!privateKey) {
|
9091
|
-
throw new
|
9092
|
-
|
9988
|
+
throw new import_errors24.FuelError(
|
9989
|
+
import_errors24.ErrorCode.HD_WALLET_ERROR,
|
9093
9990
|
"Cannot derive a hardened index without a private Key."
|
9094
9991
|
);
|
9095
9992
|
}
|
9096
9993
|
data.set(privateKey, 1);
|
9097
9994
|
} else {
|
9098
|
-
data.set((0,
|
9995
|
+
data.set((0, import_utils43.arrayify)(this.publicKey));
|
9099
9996
|
}
|
9100
9997
|
data.set((0, import_math23.toBytes)(index, 4), 33);
|
9101
|
-
const bytes = (0,
|
9998
|
+
const bytes = (0, import_utils43.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
|
9102
9999
|
const IL = bytes.slice(0, 32);
|
9103
10000
|
const IR = bytes.slice(32);
|
9104
10001
|
if (privateKey) {
|
@@ -9112,7 +10009,7 @@ var HDWallet = class {
|
|
9112
10009
|
parentFingerprint: this.fingerprint
|
9113
10010
|
});
|
9114
10011
|
}
|
9115
|
-
const signer = new Signer((0,
|
10012
|
+
const signer = new Signer((0, import_utils43.hexlify)(IL));
|
9116
10013
|
const Ki = signer.addPoint(publicKey);
|
9117
10014
|
return new HDWallet({
|
9118
10015
|
publicKey: Ki,
|
@@ -9141,18 +10038,18 @@ var HDWallet = class {
|
|
9141
10038
|
*/
|
9142
10039
|
toExtendedKey(isPublic = false, testnet = false) {
|
9143
10040
|
if (this.depth >= 256) {
|
9144
|
-
throw new
|
9145
|
-
|
10041
|
+
throw new import_errors24.FuelError(
|
10042
|
+
import_errors24.ErrorCode.HD_WALLET_ERROR,
|
9146
10043
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9147
10044
|
);
|
9148
10045
|
}
|
9149
10046
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
9150
|
-
const depth = (0,
|
10047
|
+
const depth = (0, import_utils43.hexlify)(Uint8Array.from([this.depth]));
|
9151
10048
|
const parentFingerprint = this.parentFingerprint;
|
9152
10049
|
const index = (0, import_math23.toHex)(this.index, 4);
|
9153
10050
|
const chainCode = this.chainCode;
|
9154
|
-
const key = this.privateKey != null && !isPublic ? (0,
|
9155
|
-
const extendedKey = (0,
|
10051
|
+
const key = this.privateKey != null && !isPublic ? (0, import_utils43.concat)(["0x00", this.privateKey]) : this.publicKey;
|
10052
|
+
const extendedKey = (0, import_utils43.arrayify)((0, import_utils43.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
|
9156
10053
|
return base58check(extendedKey);
|
9157
10054
|
}
|
9158
10055
|
/**
|
@@ -9164,34 +10061,34 @@ var HDWallet = class {
|
|
9164
10061
|
static fromSeed(seed) {
|
9165
10062
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
9166
10063
|
return new HDWallet({
|
9167
|
-
chainCode: (0,
|
9168
|
-
privateKey: (0,
|
10064
|
+
chainCode: (0, import_utils43.arrayify)(masterKey.slice(32)),
|
10065
|
+
privateKey: (0, import_utils43.arrayify)(masterKey.slice(0, 32))
|
9169
10066
|
});
|
9170
10067
|
}
|
9171
10068
|
static fromExtendedKey(extendedKey) {
|
9172
|
-
const decoded = (0,
|
9173
|
-
const bytes = (0,
|
10069
|
+
const decoded = (0, import_utils43.hexlify)((0, import_math23.toBytes)((0, import_utils43.decodeBase58)(extendedKey)));
|
10070
|
+
const bytes = (0, import_utils43.arrayify)(decoded);
|
9174
10071
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9175
10072
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9176
|
-
throw new
|
10073
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9177
10074
|
}
|
9178
10075
|
if (!validChecksum) {
|
9179
|
-
throw new
|
10076
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9180
10077
|
}
|
9181
10078
|
const depth = bytes[4];
|
9182
|
-
const parentFingerprint = (0,
|
9183
|
-
const index = parseInt((0,
|
9184
|
-
const chainCode = (0,
|
10079
|
+
const parentFingerprint = (0, import_utils43.hexlify)(bytes.slice(5, 9));
|
10080
|
+
const index = parseInt((0, import_utils43.hexlify)(bytes.slice(9, 13)).substring(2), 16);
|
10081
|
+
const chainCode = (0, import_utils43.hexlify)(bytes.slice(13, 45));
|
9185
10082
|
const key = bytes.slice(45, 78);
|
9186
10083
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9187
|
-
throw new
|
9188
|
-
|
10084
|
+
throw new import_errors24.FuelError(
|
10085
|
+
import_errors24.ErrorCode.HD_WALLET_ERROR,
|
9189
10086
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9190
10087
|
);
|
9191
10088
|
}
|
9192
10089
|
if (isPublicExtendedKey(bytes)) {
|
9193
10090
|
if (key[0] !== 3) {
|
9194
|
-
throw new
|
10091
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
|
9195
10092
|
}
|
9196
10093
|
return new HDWallet({
|
9197
10094
|
publicKey: key,
|
@@ -9202,7 +10099,7 @@ var HDWallet = class {
|
|
9202
10099
|
});
|
9203
10100
|
}
|
9204
10101
|
if (key[0] !== 0) {
|
9205
|
-
throw new
|
10102
|
+
throw new import_errors24.FuelError(import_errors24.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
|
9206
10103
|
}
|
9207
10104
|
return new HDWallet({
|
9208
10105
|
privateKey: key.slice(1),
|
@@ -9399,7 +10296,7 @@ var WalletsConfig = class {
|
|
9399
10296
|
return {
|
9400
10297
|
...snapshotConfig,
|
9401
10298
|
stateConfig: {
|
9402
|
-
...snapshotConfig?.stateConfig ??
|
10299
|
+
...snapshotConfig?.stateConfig ?? import_utils44.defaultSnapshotConfigs.stateConfig,
|
9403
10300
|
coins: this.initialState.coins.concat(snapshotConfig?.stateConfig?.coins || []),
|
9404
10301
|
messages: this.initialState.messages.concat(snapshotConfig?.stateConfig?.messages ?? [])
|
9405
10302
|
}
|
@@ -9432,7 +10329,7 @@ var WalletsConfig = class {
|
|
9432
10329
|
tx_pointer_block_height: 0,
|
9433
10330
|
tx_pointer_tx_idx: 0,
|
9434
10331
|
output_index: 0,
|
9435
|
-
tx_id: (0,
|
10332
|
+
tx_id: (0, import_utils44.hexlify)((0, import_crypto9.randomBytes)(32))
|
9436
10333
|
});
|
9437
10334
|
}
|
9438
10335
|
});
|
@@ -9446,26 +10343,26 @@ var WalletsConfig = class {
|
|
9446
10343
|
amountPerCoin
|
9447
10344
|
}) {
|
9448
10345
|
if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
|
9449
|
-
throw new
|
9450
|
-
|
10346
|
+
throw new import_errors25.FuelError(
|
10347
|
+
import_errors25.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
9451
10348
|
"Number of wallets must be greater than zero."
|
9452
10349
|
);
|
9453
10350
|
}
|
9454
10351
|
if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
|
9455
|
-
throw new
|
9456
|
-
|
10352
|
+
throw new import_errors25.FuelError(
|
10353
|
+
import_errors25.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
9457
10354
|
"Number of assets per wallet must be greater than zero."
|
9458
10355
|
);
|
9459
10356
|
}
|
9460
10357
|
if (coinsPerAsset <= 0) {
|
9461
|
-
throw new
|
9462
|
-
|
10358
|
+
throw new import_errors25.FuelError(
|
10359
|
+
import_errors25.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
9463
10360
|
"Number of coins per asset must be greater than zero."
|
9464
10361
|
);
|
9465
10362
|
}
|
9466
10363
|
if (amountPerCoin < 0) {
|
9467
|
-
throw new
|
9468
|
-
|
10364
|
+
throw new import_errors25.FuelError(
|
10365
|
+
import_errors25.FuelError.CODES.INVALID_INPUT_PARAMETERS,
|
9469
10366
|
"Amount per coin must be greater than or equal to zero."
|
9470
10367
|
);
|
9471
10368
|
}
|
@@ -9488,7 +10385,7 @@ async function setupTestProviderAndWallets({
|
|
9488
10385
|
} = {}) {
|
9489
10386
|
Symbol.dispose ??= Symbol("Symbol.dispose");
|
9490
10387
|
const walletsConfig = new WalletsConfig(
|
9491
|
-
nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ??
|
10388
|
+
nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ?? import_utils45.defaultSnapshotConfigs.chainConfig.consensus_parameters.V1.base_asset_id,
|
9492
10389
|
{
|
9493
10390
|
...defaultWalletConfigOptions,
|
9494
10391
|
...walletsConfigOptions
|
@@ -9497,8 +10394,8 @@ async function setupTestProviderAndWallets({
|
|
9497
10394
|
const launchNodeOptions = {
|
9498
10395
|
loggingEnabled: false,
|
9499
10396
|
...nodeOptions,
|
9500
|
-
snapshotConfig: (0,
|
9501
|
-
|
10397
|
+
snapshotConfig: (0, import_ramda10.mergeDeepRight)(
|
10398
|
+
import_utils45.defaultSnapshotConfigs,
|
9502
10399
|
walletsConfig.apply(nodeOptions?.snapshotConfig)
|
9503
10400
|
),
|
9504
10401
|
port: nodeOptions.port || "0"
|
@@ -9539,7 +10436,7 @@ async function setupTestProviderAndWallets({
|
|
9539
10436
|
var import_address7 = require("@fuel-ts/address");
|
9540
10437
|
var import_crypto10 = require("@fuel-ts/crypto");
|
9541
10438
|
var import_math24 = require("@fuel-ts/math");
|
9542
|
-
var
|
10439
|
+
var import_utils46 = require("@fuel-ts/utils");
|
9543
10440
|
var TestMessage = class {
|
9544
10441
|
sender;
|
9545
10442
|
recipient;
|
@@ -9556,7 +10453,7 @@ var TestMessage = class {
|
|
9556
10453
|
constructor({
|
9557
10454
|
sender = import_address7.Address.fromRandom(),
|
9558
10455
|
recipient = import_address7.Address.fromRandom(),
|
9559
|
-
nonce = (0,
|
10456
|
+
nonce = (0, import_utils46.hexlify)((0, import_crypto10.randomBytes)(32)),
|
9560
10457
|
amount = 1e6,
|
9561
10458
|
data = "",
|
9562
10459
|
// Will default to empty data in order to be a spendable message
|