@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/index.mjs
CHANGED
@@ -31,12 +31,12 @@ var __privateMethod = (obj, member, method) => {
|
|
31
31
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
32
32
|
import { Address as Address3 } from "@fuel-ts/address";
|
33
33
|
import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
|
34
|
-
import { ErrorCode as ErrorCode16, FuelError as
|
34
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError18 } from "@fuel-ts/errors";
|
35
35
|
import { AbstractAccount } from "@fuel-ts/interfaces";
|
36
36
|
import { bn as bn19 } from "@fuel-ts/math";
|
37
37
|
import { InputType as InputType8 } from "@fuel-ts/transactions";
|
38
|
-
import { arrayify as
|
39
|
-
import { clone as
|
38
|
+
import { arrayify as arrayify15, hexlify as hexlify16, isDefined as isDefined3 } from "@fuel-ts/utils";
|
39
|
+
import { clone as clone9 } from "ramda";
|
40
40
|
|
41
41
|
// src/providers/coin-quantity.ts
|
42
42
|
import { bn } from "@fuel-ts/math";
|
@@ -75,15 +75,15 @@ var addAmountToCoinQuantities = (params) => {
|
|
75
75
|
|
76
76
|
// src/providers/provider.ts
|
77
77
|
import { Address as Address2 } from "@fuel-ts/address";
|
78
|
-
import { ErrorCode as ErrorCode14, FuelError as
|
78
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError16 } from "@fuel-ts/errors";
|
79
79
|
import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
|
80
|
-
import { InputType as InputType7, InputMessageCoder, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
81
|
-
import { arrayify as
|
80
|
+
import { InputType as InputType7, InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
81
|
+
import { arrayify as arrayify12, hexlify as hexlify15, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
82
82
|
import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
|
83
83
|
import { equalBytes } from "@noble/curves/abstract/utils";
|
84
84
|
import { GraphQLClient } from "graphql-request";
|
85
85
|
import gql2 from "graphql-tag";
|
86
|
-
import { clone as
|
86
|
+
import { clone as clone8 } from "ramda";
|
87
87
|
|
88
88
|
// src/providers/__generated__/operations.ts
|
89
89
|
import gql from "graphql-tag";
|
@@ -1031,6 +1031,13 @@ var SubmitAndAwaitDocument = gql`
|
|
1031
1031
|
}
|
1032
1032
|
}
|
1033
1033
|
${TransactionStatusSubscriptionFragmentDoc}`;
|
1034
|
+
var SubmitAndAwaitStatusDocument = gql`
|
1035
|
+
subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
|
1036
|
+
submitAndAwaitStatus(tx: $encodedTransaction) {
|
1037
|
+
...transactionStatusSubscriptionFragment
|
1038
|
+
}
|
1039
|
+
}
|
1040
|
+
${TransactionStatusSubscriptionFragmentDoc}`;
|
1034
1041
|
var StatusChangeDocument = gql`
|
1035
1042
|
subscription statusChange($transactionId: TransactionId!) {
|
1036
1043
|
statusChange(id: $transactionId) {
|
@@ -1127,6 +1134,9 @@ function getSdk(requester) {
|
|
1127
1134
|
submitAndAwait(variables, options) {
|
1128
1135
|
return requester(SubmitAndAwaitDocument, variables, options);
|
1129
1136
|
},
|
1137
|
+
submitAndAwaitStatus(variables, options) {
|
1138
|
+
return requester(SubmitAndAwaitStatusDocument, variables, options);
|
1139
|
+
},
|
1130
1140
|
statusChange(variables, options) {
|
1131
1141
|
return requester(StatusChangeDocument, variables, options);
|
1132
1142
|
}
|
@@ -1153,7 +1163,9 @@ var _FuelGraphqlSubscriber = class {
|
|
1153
1163
|
Accept: "text/event-stream"
|
1154
1164
|
}
|
1155
1165
|
});
|
1156
|
-
|
1166
|
+
const [errorReader, resultReader] = response.body.tee().map((stream) => stream.getReader());
|
1167
|
+
await new _FuelGraphqlSubscriber(errorReader).next();
|
1168
|
+
return new _FuelGraphqlSubscriber(resultReader);
|
1157
1169
|
}
|
1158
1170
|
events = [];
|
1159
1171
|
parsingLeftover = "";
|
@@ -1196,10 +1208,8 @@ var _FuelGraphqlSubscriber = class {
|
|
1196
1208
|
/**
|
1197
1209
|
* Gets called when `break` is called in a `for-await-of` loop.
|
1198
1210
|
*/
|
1199
|
-
|
1200
|
-
|
1201
|
-
this.stream.releaseLock();
|
1202
|
-
return { done: true, value: void 0 };
|
1211
|
+
return() {
|
1212
|
+
return Promise.resolve({ done: true, value: void 0 });
|
1203
1213
|
}
|
1204
1214
|
[Symbol.asyncIterator]() {
|
1205
1215
|
return this;
|
@@ -1416,7 +1426,7 @@ import {
|
|
1416
1426
|
OutputType as OutputType2,
|
1417
1427
|
TransactionType
|
1418
1428
|
} from "@fuel-ts/transactions";
|
1419
|
-
import { concat, hexlify as
|
1429
|
+
import { concat, hexlify as hexlify8, isDefined } from "@fuel-ts/utils";
|
1420
1430
|
|
1421
1431
|
// src/providers/message.ts
|
1422
1432
|
var isMessageCoin = (message) => !("data" in message);
|
@@ -1431,14 +1441,9 @@ var isMessage = (resource) => "recipient" in resource;
|
|
1431
1441
|
import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
|
1432
1442
|
import { ErrorCode as ErrorCode5, FuelError as FuelError5 } from "@fuel-ts/errors";
|
1433
1443
|
import { bn as bn4 } from "@fuel-ts/math";
|
1434
|
-
import {
|
1435
|
-
ReceiptBurnCoder,
|
1436
|
-
ReceiptMessageOutCoder,
|
1437
|
-
ReceiptMintCoder,
|
1438
|
-
ReceiptType
|
1439
|
-
} from "@fuel-ts/transactions";
|
1444
|
+
import { getMintedAssetId, InputMessageCoder, ReceiptType } from "@fuel-ts/transactions";
|
1440
1445
|
import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
|
1441
|
-
import { arrayify as arrayify2 } from "@fuel-ts/utils";
|
1446
|
+
import { arrayify as arrayify2, hexlify as hexlify5 } from "@fuel-ts/utils";
|
1442
1447
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
1443
1448
|
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
1444
1449
|
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
@@ -1584,12 +1589,12 @@ function assembleReceiptByType(receipt) {
|
|
1584
1589
|
const amount = bn4(receipt.amount);
|
1585
1590
|
const data = receipt.data ? arrayify2(receipt.data) : Uint8Array.from([]);
|
1586
1591
|
const digest = hexOrZero(receipt.digest);
|
1587
|
-
const messageId =
|
1592
|
+
const messageId = InputMessageCoder.getMessageId({
|
1588
1593
|
sender,
|
1589
1594
|
recipient,
|
1590
1595
|
nonce,
|
1591
1596
|
amount,
|
1592
|
-
data
|
1597
|
+
data: hexlify5(data)
|
1593
1598
|
});
|
1594
1599
|
const receiptMessageOut = {
|
1595
1600
|
type: ReceiptType.MessageOut,
|
@@ -1606,7 +1611,7 @@ function assembleReceiptByType(receipt) {
|
|
1606
1611
|
case "MINT" /* Mint */: {
|
1607
1612
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1608
1613
|
const subId = hexOrZero(receipt.subId);
|
1609
|
-
const assetId =
|
1614
|
+
const assetId = getMintedAssetId(contractId, subId);
|
1610
1615
|
const mintReceipt = {
|
1611
1616
|
type: ReceiptType.Mint,
|
1612
1617
|
subId,
|
@@ -1621,7 +1626,7 @@ function assembleReceiptByType(receipt) {
|
|
1621
1626
|
case "BURN" /* Burn */: {
|
1622
1627
|
const contractId = hexOrZero(receipt.id || receipt.contractId);
|
1623
1628
|
const subId = hexOrZero(receipt.subId);
|
1624
|
-
const assetId =
|
1629
|
+
const assetId = getMintedAssetId(contractId, subId);
|
1625
1630
|
const burnReceipt = {
|
1626
1631
|
type: ReceiptType.Burn,
|
1627
1632
|
subId,
|
@@ -1640,7 +1645,7 @@ function assembleReceiptByType(receipt) {
|
|
1640
1645
|
|
1641
1646
|
// src/providers/utils/block-explorer.ts
|
1642
1647
|
import { ErrorCode as ErrorCode6, FuelError as FuelError6 } from "@fuel-ts/errors";
|
1643
|
-
var DEFAULT_BLOCK_EXPLORER_URL = "https://
|
1648
|
+
var DEFAULT_BLOCK_EXPLORER_URL = "https://app.fuel.network";
|
1644
1649
|
var getPathFromInput = (key, value) => {
|
1645
1650
|
const pathMap = {
|
1646
1651
|
address: `address`,
|
@@ -1800,19 +1805,52 @@ function calculateMetadataGasForTxBlob({
|
|
1800
1805
|
const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
|
1801
1806
|
return txId.add(blobLen);
|
1802
1807
|
}
|
1808
|
+
function calculateMetadataGasForTxUpgrade({
|
1809
|
+
gasCosts,
|
1810
|
+
txBytesSize,
|
1811
|
+
consensusSize
|
1812
|
+
}) {
|
1813
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1814
|
+
if (consensusSize) {
|
1815
|
+
const consensusLen = resolveGasDependentCosts(consensusSize, gasCosts.s256);
|
1816
|
+
txId.add(consensusLen);
|
1817
|
+
}
|
1818
|
+
return txId;
|
1819
|
+
}
|
1820
|
+
function calculateMetadataGasForTxUpload({
|
1821
|
+
gasCosts,
|
1822
|
+
txBytesSize,
|
1823
|
+
subsectionSize,
|
1824
|
+
subsectionsSize
|
1825
|
+
}) {
|
1826
|
+
const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
|
1827
|
+
const subsectionLen = resolveGasDependentCosts(subsectionSize, gasCosts.s256);
|
1828
|
+
txId.add(subsectionLen);
|
1829
|
+
const subsectionsLen = resolveGasDependentCosts(subsectionsSize, gasCosts.stateRoot);
|
1830
|
+
txId.add(subsectionsLen);
|
1831
|
+
return txId;
|
1832
|
+
}
|
1833
|
+
function calculateMinGasForTxUpload({
|
1834
|
+
gasCosts,
|
1835
|
+
baseMinGas,
|
1836
|
+
subsectionSize
|
1837
|
+
}) {
|
1838
|
+
const additionalStoragePerByte = bn5(gasCosts.newStoragePerByte).mul(subsectionSize);
|
1839
|
+
return bn5(baseMinGas).add(additionalStoragePerByte);
|
1840
|
+
}
|
1803
1841
|
var calculateGasFee = (params) => {
|
1804
1842
|
const { gas, gasPrice, priceFactor, tip } = params;
|
1805
1843
|
return gas.mul(gasPrice).div(priceFactor).add(bn5(tip));
|
1806
1844
|
};
|
1807
1845
|
|
1808
1846
|
// src/providers/utils/json.ts
|
1809
|
-
import { hexlify as
|
1847
|
+
import { hexlify as hexlify6 } from "@fuel-ts/utils";
|
1810
1848
|
import { clone } from "ramda";
|
1811
1849
|
function normalize(object) {
|
1812
1850
|
Object.keys(object).forEach((key) => {
|
1813
1851
|
switch (object[key]?.constructor.name) {
|
1814
1852
|
case "Uint8Array":
|
1815
|
-
object[key] =
|
1853
|
+
object[key] = hexlify6(object[key]);
|
1816
1854
|
break;
|
1817
1855
|
case "Array":
|
1818
1856
|
object[key] = normalize(object[key]);
|
@@ -2002,11 +2040,11 @@ var cacheRequestInputsResourcesFromOwner = (inputs, owner) => inputs.reduce(
|
|
2002
2040
|
);
|
2003
2041
|
|
2004
2042
|
// src/providers/transaction-request/witness.ts
|
2005
|
-
import { arrayify as arrayify4, hexlify as
|
2043
|
+
import { arrayify as arrayify4, hexlify as hexlify7 } from "@fuel-ts/utils";
|
2006
2044
|
var witnessify = (value) => {
|
2007
2045
|
const data = arrayify4(value);
|
2008
2046
|
return {
|
2009
|
-
data:
|
2047
|
+
data: hexlify7(data),
|
2010
2048
|
dataLength: data.length
|
2011
2049
|
};
|
2012
2050
|
};
|
@@ -2223,9 +2261,9 @@ var BaseTransactionRequest = class {
|
|
2223
2261
|
const found = this.inputs.find((input) => {
|
2224
2262
|
switch (input.type) {
|
2225
2263
|
case InputType3.Coin:
|
2226
|
-
return
|
2264
|
+
return hexlify8(input.owner) === ownerAddress.toB256();
|
2227
2265
|
case InputType3.Message:
|
2228
|
-
return
|
2266
|
+
return hexlify8(input.recipient) === ownerAddress.toB256();
|
2229
2267
|
default:
|
2230
2268
|
return false;
|
2231
2269
|
}
|
@@ -2363,7 +2401,7 @@ var BaseTransactionRequest = class {
|
|
2363
2401
|
*/
|
2364
2402
|
addChangeOutput(to, assetId) {
|
2365
2403
|
const changeOutput = this.getChangeOutputs().find(
|
2366
|
-
(output) =>
|
2404
|
+
(output) => hexlify8(output.assetId) === assetId
|
2367
2405
|
);
|
2368
2406
|
if (!changeOutput) {
|
2369
2407
|
this.pushOutput({
|
@@ -2443,12 +2481,12 @@ var BaseTransactionRequest = class {
|
|
2443
2481
|
usedQuantity = bn8("1000000000000000000");
|
2444
2482
|
}
|
2445
2483
|
if (assetInput && "assetId" in assetInput) {
|
2446
|
-
assetInput.id =
|
2484
|
+
assetInput.id = hexlify8(randomBytes(UTXO_ID_LEN2));
|
2447
2485
|
assetInput.amount = usedQuantity;
|
2448
2486
|
} else {
|
2449
2487
|
this.addResources([
|
2450
2488
|
{
|
2451
|
-
id:
|
2489
|
+
id: hexlify8(randomBytes(UTXO_ID_LEN2)),
|
2452
2490
|
amount: usedQuantity,
|
2453
2491
|
assetId,
|
2454
2492
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -2651,11 +2689,11 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
|
|
2651
2689
|
import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
|
2652
2690
|
import { bn as bn10 } from "@fuel-ts/math";
|
2653
2691
|
import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
|
2654
|
-
import { arrayify as arrayify6, hexlify as
|
2692
|
+
import { arrayify as arrayify6, hexlify as hexlify10 } from "@fuel-ts/utils";
|
2655
2693
|
import { clone as clone4 } from "ramda";
|
2656
2694
|
|
2657
2695
|
// src/providers/transaction-request/storage-slot.ts
|
2658
|
-
import { arrayify as arrayify5, hexlify as
|
2696
|
+
import { arrayify as arrayify5, hexlify as hexlify9 } from "@fuel-ts/utils";
|
2659
2697
|
var getStorageValue = (value) => {
|
2660
2698
|
const v = new Uint8Array(32);
|
2661
2699
|
v.set(arrayify5(value));
|
@@ -2672,8 +2710,8 @@ var storageSlotify = (storageSlot) => {
|
|
2672
2710
|
value = storageSlot.value;
|
2673
2711
|
}
|
2674
2712
|
return {
|
2675
|
-
key:
|
2676
|
-
value:
|
2713
|
+
key: hexlify9(key),
|
2714
|
+
value: hexlify9(getStorageValue(value))
|
2677
2715
|
};
|
2678
2716
|
};
|
2679
2717
|
|
@@ -2698,7 +2736,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2698
2736
|
constructor({ bytecodeWitnessIndex, salt, storageSlots, ...rest }) {
|
2699
2737
|
super(rest);
|
2700
2738
|
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
2701
|
-
this.salt =
|
2739
|
+
this.salt = hexlify10(salt ?? ZeroBytes326);
|
2702
2740
|
this.storageSlots = [...storageSlots ?? []];
|
2703
2741
|
}
|
2704
2742
|
/**
|
@@ -2715,7 +2753,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
|
|
2715
2753
|
...baseTransaction,
|
2716
2754
|
bytecodeWitnessIndex,
|
2717
2755
|
storageSlotsCount: bn10(storageSlots.length),
|
2718
|
-
salt: this.salt ?
|
2756
|
+
salt: this.salt ? hexlify10(this.salt) : ZeroBytes326,
|
2719
2757
|
storageSlots
|
2720
2758
|
};
|
2721
2759
|
}
|
@@ -2768,7 +2806,7 @@ import { addressify as addressify2 } from "@fuel-ts/address";
|
|
2768
2806
|
import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
|
2769
2807
|
import { bn as bn11 } from "@fuel-ts/math";
|
2770
2808
|
import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
|
2771
|
-
import { arrayify as arrayify8, hexlify as
|
2809
|
+
import { arrayify as arrayify8, hexlify as hexlify11 } from "@fuel-ts/utils";
|
2772
2810
|
import { clone as clone5 } from "ramda";
|
2773
2811
|
|
2774
2812
|
// src/providers/transaction-request/scripts.ts
|
@@ -2838,8 +2876,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2838
2876
|
scriptLength: bn11(script.length),
|
2839
2877
|
scriptDataLength: bn11(scriptData.length),
|
2840
2878
|
receiptsRoot: ZeroBytes327,
|
2841
|
-
script:
|
2842
|
-
scriptData:
|
2879
|
+
script: hexlify11(script),
|
2880
|
+
scriptData: hexlify11(scriptData)
|
2843
2881
|
};
|
2844
2882
|
}
|
2845
2883
|
/**
|
@@ -2976,51 +3014,319 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
|
|
2976
3014
|
}
|
2977
3015
|
};
|
2978
3016
|
|
3017
|
+
// src/providers/transaction-request/upgrade-transaction-request.ts
|
3018
|
+
import { FuelError as FuelError9 } from "@fuel-ts/errors";
|
3019
|
+
import { hash } from "@fuel-ts/hasher";
|
3020
|
+
import {
|
3021
|
+
TransactionType as TransactionType5,
|
3022
|
+
UpgradePurposeTypeEnum
|
3023
|
+
} from "@fuel-ts/transactions";
|
3024
|
+
import { hexlify as hexlify12 } from "@fuel-ts/utils";
|
3025
|
+
import { clone as clone6 } from "ramda";
|
3026
|
+
var UpgradeTransactionRequest = class extends BaseTransactionRequest {
|
3027
|
+
static from(obj) {
|
3028
|
+
if (obj instanceof UpgradeTransactionRequest) {
|
3029
|
+
return obj;
|
3030
|
+
}
|
3031
|
+
return new this(clone6(obj));
|
3032
|
+
}
|
3033
|
+
/** The type of transaction */
|
3034
|
+
type = TransactionType5.Upgrade;
|
3035
|
+
/** The upgrade purpose */
|
3036
|
+
upgradePurpose;
|
3037
|
+
/** Witness index of consensus */
|
3038
|
+
bytecodeWitnessIndex;
|
3039
|
+
/**
|
3040
|
+
* Creates an instance `UpgradeTransactionRequest`.
|
3041
|
+
*
|
3042
|
+
* @param upgradeTransactionRequestLike - The initial values for the instance
|
3043
|
+
*/
|
3044
|
+
constructor({
|
3045
|
+
upgradePurpose,
|
3046
|
+
bytecodeWitnessIndex,
|
3047
|
+
...rest
|
3048
|
+
} = {}) {
|
3049
|
+
super(rest);
|
3050
|
+
this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
|
3051
|
+
this.upgradePurpose = upgradePurpose ?? {
|
3052
|
+
type: UpgradePurposeTypeEnum.ConsensusParameters,
|
3053
|
+
checksum: "0x"
|
3054
|
+
};
|
3055
|
+
}
|
3056
|
+
/**
|
3057
|
+
* Adds a consensus parameters upgrade purpose.
|
3058
|
+
*
|
3059
|
+
* @param consensus - The consensus bytecode.
|
3060
|
+
*
|
3061
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3062
|
+
*/
|
3063
|
+
addConsensusParametersUpgradePurpose(consensus) {
|
3064
|
+
this.bytecodeWitnessIndex = this.addWitness(consensus);
|
3065
|
+
this.upgradePurpose = {
|
3066
|
+
type: UpgradePurposeTypeEnum.ConsensusParameters,
|
3067
|
+
checksum: hash(consensus)
|
3068
|
+
};
|
3069
|
+
return this;
|
3070
|
+
}
|
3071
|
+
/**
|
3072
|
+
* Adds a state transition upgrade purpose.
|
3073
|
+
*
|
3074
|
+
* @param bytecodeRoot - The Merkle root of the state transition.
|
3075
|
+
*
|
3076
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3077
|
+
*/
|
3078
|
+
addStateTransitionUpgradePurpose(bytecodeRoot) {
|
3079
|
+
this.upgradePurpose = {
|
3080
|
+
type: UpgradePurposeTypeEnum.StateTransition,
|
3081
|
+
data: hexlify12(bytecodeRoot)
|
3082
|
+
};
|
3083
|
+
return this;
|
3084
|
+
}
|
3085
|
+
/**
|
3086
|
+
* Adds an upgrade purpose.
|
3087
|
+
*
|
3088
|
+
* @param type - The upgrade purpose type.
|
3089
|
+
* @param data - The bytecode or merkle root of upgrade purpose
|
3090
|
+
*
|
3091
|
+
* @returns - The current instance of `UpgradeTransactionRequest`.
|
3092
|
+
*/
|
3093
|
+
addUpgradePurpose(type, data) {
|
3094
|
+
if (type === UpgradePurposeTypeEnum.ConsensusParameters) {
|
3095
|
+
this.addConsensusParametersUpgradePurpose(data);
|
3096
|
+
}
|
3097
|
+
if (type === UpgradePurposeTypeEnum.StateTransition) {
|
3098
|
+
this.addStateTransitionUpgradePurpose(data);
|
3099
|
+
}
|
3100
|
+
return this;
|
3101
|
+
}
|
3102
|
+
/**
|
3103
|
+
* Converts the transaction request to a `TransactionUpgrade`.
|
3104
|
+
*
|
3105
|
+
* @returns The transaction create object.
|
3106
|
+
*/
|
3107
|
+
toTransaction() {
|
3108
|
+
let upgradePurpose;
|
3109
|
+
if (this.upgradePurpose.type === UpgradePurposeTypeEnum.ConsensusParameters) {
|
3110
|
+
upgradePurpose = {
|
3111
|
+
type: UpgradePurposeTypeEnum.ConsensusParameters,
|
3112
|
+
data: {
|
3113
|
+
witnessIndex: this.bytecodeWitnessIndex,
|
3114
|
+
checksum: this.upgradePurpose.checksum
|
3115
|
+
}
|
3116
|
+
};
|
3117
|
+
} else if (this.upgradePurpose.type === UpgradePurposeTypeEnum.StateTransition) {
|
3118
|
+
upgradePurpose = {
|
3119
|
+
type: UpgradePurposeTypeEnum.StateTransition,
|
3120
|
+
data: {
|
3121
|
+
bytecodeRoot: hexlify12(this.upgradePurpose.data)
|
3122
|
+
}
|
3123
|
+
};
|
3124
|
+
} else {
|
3125
|
+
throw new FuelError9(FuelError9.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3126
|
+
}
|
3127
|
+
return {
|
3128
|
+
type: TransactionType5.Upgrade,
|
3129
|
+
...super.getBaseTransaction(),
|
3130
|
+
upgradePurpose
|
3131
|
+
};
|
3132
|
+
}
|
3133
|
+
/**
|
3134
|
+
* Gets the Transaction ID by hashing the transaction
|
3135
|
+
*
|
3136
|
+
* @param chainId - The chain ID.
|
3137
|
+
*
|
3138
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
3139
|
+
*/
|
3140
|
+
getTransactionId(chainId) {
|
3141
|
+
return hashTransaction(this, chainId);
|
3142
|
+
}
|
3143
|
+
/**
|
3144
|
+
* Calculates the metadata gas cost for an upgrade transaction.
|
3145
|
+
*
|
3146
|
+
* @param gasCosts - gas costs passed from the chain.
|
3147
|
+
*
|
3148
|
+
* @returns metadata gas cost for the upgrade transaction.
|
3149
|
+
*/
|
3150
|
+
metadataGas(gasCosts) {
|
3151
|
+
const txBytesSize = this.byteSize();
|
3152
|
+
if (this.upgradePurpose.type === UpgradePurposeTypeEnum.ConsensusParameters) {
|
3153
|
+
const witnessIndex = this.bytecodeWitnessIndex;
|
3154
|
+
const consensusSize = this.witnesses[witnessIndex].length;
|
3155
|
+
return calculateMetadataGasForTxUpgrade({
|
3156
|
+
gasCosts,
|
3157
|
+
txBytesSize,
|
3158
|
+
consensusSize
|
3159
|
+
});
|
3160
|
+
}
|
3161
|
+
if (this.upgradePurpose.type === UpgradePurposeTypeEnum.StateTransition) {
|
3162
|
+
return calculateMetadataGasForTxUpgrade({
|
3163
|
+
gasCosts,
|
3164
|
+
txBytesSize
|
3165
|
+
});
|
3166
|
+
}
|
3167
|
+
throw new FuelError9(FuelError9.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
|
3168
|
+
}
|
3169
|
+
};
|
3170
|
+
|
3171
|
+
// src/providers/transaction-request/upload-transaction-request.ts
|
3172
|
+
import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
|
3173
|
+
import { TransactionType as TransactionType6 } from "@fuel-ts/transactions";
|
3174
|
+
import { arrayify as arrayify9, hexlify as hexlify13 } from "@fuel-ts/utils";
|
3175
|
+
import { clone as clone7 } from "ramda";
|
3176
|
+
var UploadTransactionRequest = class extends BaseTransactionRequest {
|
3177
|
+
static from(obj) {
|
3178
|
+
if (obj instanceof UploadTransactionRequest) {
|
3179
|
+
return obj;
|
3180
|
+
}
|
3181
|
+
return new this(clone7(obj));
|
3182
|
+
}
|
3183
|
+
/** Type of the transaction */
|
3184
|
+
type = TransactionType6.Upload;
|
3185
|
+
/** The witness index of the subsection of the bytecode. */
|
3186
|
+
witnessIndex;
|
3187
|
+
/** The subsection data. */
|
3188
|
+
subsection;
|
3189
|
+
/**
|
3190
|
+
* Creates an instance `UploadTransactionRequest`.
|
3191
|
+
*
|
3192
|
+
* @param uploadTransactionRequestLike - The initial values for the instance
|
3193
|
+
*/
|
3194
|
+
constructor({ witnessIndex, subsection, ...rest } = {}) {
|
3195
|
+
super(rest);
|
3196
|
+
this.witnessIndex = witnessIndex ?? 0;
|
3197
|
+
this.subsection = subsection ?? {
|
3198
|
+
proofSet: [],
|
3199
|
+
root: ZeroBytes328,
|
3200
|
+
subsectionIndex: 0,
|
3201
|
+
subsectionsNumber: 0
|
3202
|
+
};
|
3203
|
+
}
|
3204
|
+
/**
|
3205
|
+
* Adds the subsection.
|
3206
|
+
*
|
3207
|
+
* @param subsection - The subsection data.
|
3208
|
+
*/
|
3209
|
+
addSubsection(subsection) {
|
3210
|
+
const { subsection: subsectionBytecode, ...rest } = subsection;
|
3211
|
+
this.subsection = rest;
|
3212
|
+
this.witnessIndex = this.addWitness(subsectionBytecode);
|
3213
|
+
}
|
3214
|
+
/**
|
3215
|
+
* Gets the Transaction Request by hashing the transaction.
|
3216
|
+
*
|
3217
|
+
* @param chainId - The chain ID.
|
3218
|
+
*
|
3219
|
+
* @returns - A hash of the transaction, which is the transaction ID.
|
3220
|
+
*/
|
3221
|
+
getTransactionId(chainId) {
|
3222
|
+
return hashTransaction(this, chainId);
|
3223
|
+
}
|
3224
|
+
/**
|
3225
|
+
* Converts the transaction request to a `TransactionUpload`.
|
3226
|
+
*
|
3227
|
+
* @returns The transaction create object.
|
3228
|
+
*/
|
3229
|
+
toTransaction() {
|
3230
|
+
const baseTransaction = this.getBaseTransaction();
|
3231
|
+
const { subsectionIndex, subsectionsNumber, root, proofSet } = this.subsection;
|
3232
|
+
return {
|
3233
|
+
type: TransactionType6.Upload,
|
3234
|
+
...baseTransaction,
|
3235
|
+
subsectionIndex,
|
3236
|
+
subsectionsNumber,
|
3237
|
+
root: hexlify13(root),
|
3238
|
+
proofSet: proofSet.map(hexlify13),
|
3239
|
+
witnessIndex: this.witnessIndex,
|
3240
|
+
proofSetCount: proofSet.length
|
3241
|
+
};
|
3242
|
+
}
|
3243
|
+
/**
|
3244
|
+
* Calculates the metadata gas cost for an upload transaction.
|
3245
|
+
*
|
3246
|
+
* @param gasCosts - gas costs passed from the chain.
|
3247
|
+
*
|
3248
|
+
* @returns metadata gas cost for the upload transaction.
|
3249
|
+
*/
|
3250
|
+
metadataGas(gasCosts) {
|
3251
|
+
return calculateMetadataGasForTxUpload({
|
3252
|
+
gasCosts,
|
3253
|
+
txBytesSize: this.byteSize(),
|
3254
|
+
subsectionSize: arrayify9(this.witnesses[this.witnessIndex]).length,
|
3255
|
+
subsectionsSize: this.subsection.subsectionsNumber
|
3256
|
+
});
|
3257
|
+
}
|
3258
|
+
/**
|
3259
|
+
* Calculates the minimum gas for an upload transaction.
|
3260
|
+
*
|
3261
|
+
* @param chainInfo - The chain information.
|
3262
|
+
*
|
3263
|
+
* @returns the minimum gas for the upload transaction
|
3264
|
+
*/
|
3265
|
+
calculateMinGas(chainInfo) {
|
3266
|
+
const minGas = super.calculateMinGas(chainInfo);
|
3267
|
+
const { gasCosts } = chainInfo.consensusParameters;
|
3268
|
+
const bytecode = this.witnesses[this.witnessIndex] ?? ZeroBytes328;
|
3269
|
+
return calculateMinGasForTxUpload({
|
3270
|
+
gasCosts,
|
3271
|
+
baseMinGas: minGas.toNumber(),
|
3272
|
+
subsectionSize: arrayify9(bytecode).length
|
3273
|
+
});
|
3274
|
+
}
|
3275
|
+
};
|
3276
|
+
|
2979
3277
|
// src/providers/transaction-request/utils.ts
|
2980
|
-
import { ErrorCode as ErrorCode8, FuelError as
|
2981
|
-
import { TransactionType as
|
3278
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError10 } from "@fuel-ts/errors";
|
3279
|
+
import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
2982
3280
|
var transactionRequestify = (obj) => {
|
2983
|
-
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest) {
|
3281
|
+
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
2984
3282
|
return obj;
|
2985
3283
|
}
|
2986
3284
|
const { type } = obj;
|
2987
3285
|
switch (obj.type) {
|
2988
|
-
case
|
3286
|
+
case TransactionType7.Script: {
|
2989
3287
|
return ScriptTransactionRequest.from(obj);
|
2990
3288
|
}
|
2991
|
-
case
|
3289
|
+
case TransactionType7.Create: {
|
2992
3290
|
return CreateTransactionRequest.from(obj);
|
2993
3291
|
}
|
2994
|
-
case
|
3292
|
+
case TransactionType7.Blob: {
|
2995
3293
|
return BlobTransactionRequest.from(obj);
|
2996
3294
|
}
|
3295
|
+
case TransactionType7.Upgrade: {
|
3296
|
+
return UpgradeTransactionRequest.from(obj);
|
3297
|
+
}
|
3298
|
+
case TransactionType7.Upload: {
|
3299
|
+
return UploadTransactionRequest.from(obj);
|
3300
|
+
}
|
2997
3301
|
default: {
|
2998
|
-
throw new
|
3302
|
+
throw new FuelError10(
|
2999
3303
|
ErrorCode8.UNSUPPORTED_TRANSACTION_TYPE,
|
3000
3304
|
`Unsupported transaction type: ${type}.`
|
3001
3305
|
);
|
3002
3306
|
}
|
3003
3307
|
}
|
3004
3308
|
};
|
3005
|
-
var isTransactionTypeScript = (request) => request.type ===
|
3006
|
-
var isTransactionTypeCreate = (request) => request.type ===
|
3007
|
-
var isTransactionTypeBlob = (request) => request.type ===
|
3309
|
+
var isTransactionTypeScript = (request) => request.type === TransactionType7.Script;
|
3310
|
+
var isTransactionTypeCreate = (request) => request.type === TransactionType7.Create;
|
3311
|
+
var isTransactionTypeBlob = (request) => request.type === TransactionType7.Blob;
|
3312
|
+
var isTransactionTypeUpgrade = (request) => request.type === TransactionType7.Upgrade;
|
3313
|
+
var isTransactionTypeUpload = (request) => request.type === TransactionType7.Upload;
|
3008
3314
|
|
3009
3315
|
// src/providers/transaction-response/transaction-response.ts
|
3010
|
-
import { ErrorCode as ErrorCode12, FuelError as
|
3316
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError14 } from "@fuel-ts/errors";
|
3011
3317
|
import { bn as bn16 } from "@fuel-ts/math";
|
3012
3318
|
import { OutputType as OutputType7, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
3013
|
-
import { arrayify as
|
3319
|
+
import { arrayify as arrayify11, assertUnreachable } from "@fuel-ts/utils";
|
3014
3320
|
|
3015
3321
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
3016
3322
|
import { bn as bn15 } from "@fuel-ts/math";
|
3017
3323
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
3018
|
-
import { DateTime, hexlify as
|
3324
|
+
import { DateTime, hexlify as hexlify14 } from "@fuel-ts/utils";
|
3019
3325
|
|
3020
3326
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
3021
3327
|
import { bn as bn12 } from "@fuel-ts/math";
|
3022
|
-
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as
|
3023
|
-
import { arrayify as
|
3328
|
+
import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType8 } from "@fuel-ts/transactions";
|
3329
|
+
import { arrayify as arrayify10 } from "@fuel-ts/utils";
|
3024
3330
|
var calculateTXFeeForSummary = (params) => {
|
3025
3331
|
const {
|
3026
3332
|
gasPrice,
|
@@ -3034,17 +3340,17 @@ var calculateTXFeeForSummary = (params) => {
|
|
3034
3340
|
}
|
3035
3341
|
const gasPerByte = bn12(feeParams.gasPerByte);
|
3036
3342
|
const gasPriceFactor = bn12(feeParams.gasPriceFactor);
|
3037
|
-
const transactionBytes =
|
3343
|
+
const transactionBytes = arrayify10(rawPayload);
|
3038
3344
|
const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
|
3039
3345
|
const { type, witnesses, inputs, policies } = transaction;
|
3040
3346
|
let metadataGas = bn12(0);
|
3041
3347
|
let gasLimit = bn12(0);
|
3042
|
-
if (type !==
|
3348
|
+
if (type !== TransactionType8.Create && type !== TransactionType8.Script) {
|
3043
3349
|
return bn12(0);
|
3044
3350
|
}
|
3045
|
-
if (type ===
|
3351
|
+
if (type === TransactionType8.Create) {
|
3046
3352
|
const { bytecodeWitnessIndex, storageSlots } = transaction;
|
3047
|
-
const contractBytesSize = bn12(
|
3353
|
+
const contractBytesSize = bn12(arrayify10(witnesses[bytecodeWitnessIndex].data).length);
|
3048
3354
|
metadataGas = calculateMetadataGasForTxCreate({
|
3049
3355
|
contractBytesSize,
|
3050
3356
|
gasCosts,
|
@@ -3088,10 +3394,10 @@ var calculateTXFeeForSummary = (params) => {
|
|
3088
3394
|
};
|
3089
3395
|
|
3090
3396
|
// src/providers/transaction-summary/operations.ts
|
3091
|
-
import { ZeroBytes32 as
|
3092
|
-
import { ErrorCode as ErrorCode10, FuelError as
|
3397
|
+
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
3398
|
+
import { ErrorCode as ErrorCode10, FuelError as FuelError12 } from "@fuel-ts/errors";
|
3093
3399
|
import { bn as bn13 } from "@fuel-ts/math";
|
3094
|
-
import { ReceiptType as ReceiptType4, TransactionType as
|
3400
|
+
import { ReceiptType as ReceiptType4, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
|
3095
3401
|
|
3096
3402
|
// src/providers/transaction-summary/call.ts
|
3097
3403
|
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
@@ -3127,7 +3433,7 @@ var getFunctionCall = ({ abi, receipt }) => {
|
|
3127
3433
|
};
|
3128
3434
|
|
3129
3435
|
// src/providers/transaction-summary/input.ts
|
3130
|
-
import { ErrorCode as ErrorCode9, FuelError as
|
3436
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError11 } from "@fuel-ts/errors";
|
3131
3437
|
import { BN } from "@fuel-ts/math";
|
3132
3438
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
3133
3439
|
function getInputsByTypes(inputs, types) {
|
@@ -3196,7 +3502,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
3196
3502
|
return void 0;
|
3197
3503
|
}
|
3198
3504
|
if (contractInput.type !== InputType6.Contract) {
|
3199
|
-
throw new
|
3505
|
+
throw new FuelError11(
|
3200
3506
|
ErrorCode9.INVALID_TRANSACTION_INPUT,
|
3201
3507
|
`Contract input should be of type 'contract'.`
|
3202
3508
|
);
|
@@ -3281,16 +3587,20 @@ function getReceiptsByType(receipts, type) {
|
|
3281
3587
|
}
|
3282
3588
|
function getTransactionTypeName(transactionType) {
|
3283
3589
|
switch (transactionType) {
|
3284
|
-
case
|
3590
|
+
case TransactionType9.Mint:
|
3285
3591
|
return "Mint" /* Mint */;
|
3286
|
-
case
|
3592
|
+
case TransactionType9.Create:
|
3287
3593
|
return "Create" /* Create */;
|
3288
|
-
case
|
3594
|
+
case TransactionType9.Script:
|
3289
3595
|
return "Script" /* Script */;
|
3290
|
-
case
|
3596
|
+
case TransactionType9.Blob:
|
3291
3597
|
return "Blob" /* Blob */;
|
3598
|
+
case TransactionType9.Upgrade:
|
3599
|
+
return "Upgrade" /* Upgrade */;
|
3600
|
+
case TransactionType9.Upload:
|
3601
|
+
return "Upload" /* Upload */;
|
3292
3602
|
default:
|
3293
|
-
throw new
|
3603
|
+
throw new FuelError12(
|
3294
3604
|
ErrorCode10.UNSUPPORTED_TRANSACTION_TYPE,
|
3295
3605
|
`Unsupported transaction type: ${transactionType}.`
|
3296
3606
|
);
|
@@ -3436,7 +3746,7 @@ function getAssetsSent(receipt) {
|
|
3436
3746
|
];
|
3437
3747
|
}
|
3438
3748
|
function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
|
3439
|
-
const assetId = receipt.assetId ===
|
3749
|
+
const assetId = receipt.assetId === ZeroBytes329 ? baseAssetId : receipt.assetId;
|
3440
3750
|
const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
|
3441
3751
|
if (!input) {
|
3442
3752
|
return [];
|
@@ -3492,7 +3802,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
3492
3802
|
const { to: toAddress, assetId, amount } = receipt;
|
3493
3803
|
let { from: fromAddress } = receipt;
|
3494
3804
|
const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
|
3495
|
-
if (
|
3805
|
+
if (ZeroBytes329 === fromAddress) {
|
3496
3806
|
const change = changeOutputs.find((output) => output.assetId === assetId);
|
3497
3807
|
fromAddress = change?.to || fromAddress;
|
3498
3808
|
}
|
@@ -3695,7 +4005,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
3695
4005
|
};
|
3696
4006
|
|
3697
4007
|
// src/providers/transaction-summary/status.ts
|
3698
|
-
import { ErrorCode as ErrorCode11, FuelError as
|
4008
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError13 } from "@fuel-ts/errors";
|
3699
4009
|
import { bn as bn14 } from "@fuel-ts/math";
|
3700
4010
|
var getTransactionStatusName = (gqlStatus) => {
|
3701
4011
|
switch (gqlStatus) {
|
@@ -3708,7 +4018,7 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
3708
4018
|
case "SqueezedOutStatus":
|
3709
4019
|
return "squeezedout" /* squeezedout */;
|
3710
4020
|
default:
|
3711
|
-
throw new
|
4021
|
+
throw new FuelError13(
|
3712
4022
|
ErrorCode11.INVALID_TRANSACTION_STATUS,
|
3713
4023
|
`Invalid transaction status: ${gqlStatus}.`
|
3714
4024
|
);
|
@@ -3778,7 +4088,7 @@ function assembleTransactionSummary(params) {
|
|
3778
4088
|
baseAssetId
|
3779
4089
|
} = params;
|
3780
4090
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
3781
|
-
const rawPayload =
|
4091
|
+
const rawPayload = hexlify14(transactionBytes);
|
3782
4092
|
const operations = getOperations({
|
3783
4093
|
transactionType: transaction.type,
|
3784
4094
|
inputs: transaction.inputs || [],
|
@@ -3887,29 +4197,30 @@ function mapGqlOutputsToTxOutputs(outputs) {
|
|
3887
4197
|
});
|
3888
4198
|
}
|
3889
4199
|
var TransactionResponse = class {
|
3890
|
-
/** Transaction ID */
|
3891
|
-
id;
|
3892
|
-
/** Current provider */
|
3893
|
-
provider;
|
3894
|
-
/** Gas used on the transaction */
|
3895
|
-
gasUsed = bn16(0);
|
3896
|
-
/** The graphql Transaction with receipts object. */
|
3897
|
-
gqlTransaction;
|
3898
|
-
request;
|
3899
|
-
status;
|
3900
|
-
abis;
|
3901
4200
|
/**
|
3902
4201
|
* Constructor for `TransactionResponse`.
|
3903
4202
|
*
|
3904
4203
|
* @param tx - The transaction ID or TransactionRequest.
|
3905
4204
|
* @param provider - The provider.
|
3906
4205
|
*/
|
3907
|
-
constructor(tx, provider, abis) {
|
4206
|
+
constructor(tx, provider, abis, submitTxSubscription) {
|
4207
|
+
this.submitTxSubscription = submitTxSubscription;
|
3908
4208
|
this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
|
3909
4209
|
this.provider = provider;
|
3910
4210
|
this.abis = abis;
|
3911
4211
|
this.request = typeof tx === "string" ? void 0 : tx;
|
3912
4212
|
}
|
4213
|
+
/** Transaction ID */
|
4214
|
+
id;
|
4215
|
+
/** Current provider */
|
4216
|
+
provider;
|
4217
|
+
/** Gas used on the transaction */
|
4218
|
+
gasUsed = bn16(0);
|
4219
|
+
/** The graphql Transaction with receipts object. */
|
4220
|
+
gqlTransaction;
|
4221
|
+
request;
|
4222
|
+
status;
|
4223
|
+
abis;
|
3913
4224
|
/**
|
3914
4225
|
* Async constructor for `TransactionResponse`. This method can be used to create
|
3915
4226
|
* an instance of `TransactionResponse` and wait for the transaction to be fetched
|
@@ -3958,7 +4269,7 @@ var TransactionResponse = class {
|
|
3958
4269
|
const gqlTransaction = this.gqlTransaction ?? await this.fetch();
|
3959
4270
|
return {
|
3960
4271
|
tx: this.decodeTransaction(gqlTransaction),
|
3961
|
-
bytes:
|
4272
|
+
bytes: arrayify11(gqlTransaction.rawPayload)
|
3962
4273
|
};
|
3963
4274
|
}
|
3964
4275
|
getReceipts() {
|
@@ -4003,7 +4314,7 @@ var TransactionResponse = class {
|
|
4003
4314
|
*/
|
4004
4315
|
decodeTransaction(transactionWithReceipts) {
|
4005
4316
|
return new TransactionCoder4().decode(
|
4006
|
-
|
4317
|
+
arrayify11(transactionWithReceipts.rawPayload),
|
4007
4318
|
0
|
4008
4319
|
)?.[0];
|
4009
4320
|
}
|
@@ -4042,14 +4353,15 @@ var TransactionResponse = class {
|
|
4042
4353
|
if (status && status !== "SubmittedStatus") {
|
4043
4354
|
return;
|
4044
4355
|
}
|
4045
|
-
const subscription = await this.provider.operations.statusChange({
|
4356
|
+
const subscription = this.submitTxSubscription ?? await this.provider.operations.statusChange({
|
4046
4357
|
transactionId: this.id
|
4047
4358
|
});
|
4048
|
-
for await (const
|
4359
|
+
for await (const sub of subscription) {
|
4360
|
+
const statusChange = "statusChange" in sub ? sub.statusChange : sub.submitAndAwaitStatus;
|
4049
4361
|
this.status = statusChange;
|
4050
4362
|
if (statusChange.type === "SqueezedOutStatus") {
|
4051
4363
|
this.unsetResourceCache();
|
4052
|
-
throw new
|
4364
|
+
throw new FuelError14(
|
4053
4365
|
ErrorCode12.TRANSACTION_SQUEEZED_OUT,
|
4054
4366
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
4055
4367
|
);
|
@@ -4158,18 +4470,18 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
4158
4470
|
}
|
4159
4471
|
|
4160
4472
|
// src/providers/utils/handle-gql-error-message.ts
|
4161
|
-
import { ErrorCode as ErrorCode13, FuelError as
|
4473
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError15 } from "@fuel-ts/errors";
|
4162
4474
|
var handleGqlErrorMessage = (errorMessage, rawError) => {
|
4163
4475
|
switch (errorMessage) {
|
4164
4476
|
case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
|
4165
|
-
throw new
|
4477
|
+
throw new FuelError15(
|
4166
4478
|
ErrorCode13.NOT_ENOUGH_FUNDS,
|
4167
4479
|
`The account(s) sending the transaction don't have enough funds to cover the transaction.`,
|
4168
4480
|
{},
|
4169
4481
|
rawError
|
4170
4482
|
);
|
4171
4483
|
default:
|
4172
|
-
throw new
|
4484
|
+
throw new FuelError15(ErrorCode13.INVALID_REQUEST, errorMessage);
|
4173
4485
|
}
|
4174
4486
|
};
|
4175
4487
|
|
@@ -4251,21 +4563,31 @@ var _Provider = class {
|
|
4251
4563
|
* @hidden
|
4252
4564
|
*/
|
4253
4565
|
constructor(url, options = {}) {
|
4254
|
-
this.url = url;
|
4255
4566
|
/**
|
4256
4567
|
* @hidden
|
4257
4568
|
*/
|
4258
4569
|
__privateAdd(this, _cacheInputs);
|
4259
4570
|
__publicField(this, "operations");
|
4260
4571
|
__publicField(this, "cache");
|
4572
|
+
/** @hidden */
|
4573
|
+
__publicField(this, "url");
|
4574
|
+
/** @hidden */
|
4575
|
+
__publicField(this, "urlWithoutAuth");
|
4261
4576
|
__publicField(this, "options", {
|
4262
4577
|
timeout: void 0,
|
4263
4578
|
resourceCacheTTL: void 0,
|
4264
4579
|
fetch: void 0,
|
4265
|
-
retryOptions: void 0
|
4580
|
+
retryOptions: void 0,
|
4581
|
+
headers: void 0
|
4266
4582
|
});
|
4583
|
+
const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
|
4584
|
+
this.url = rawUrl;
|
4585
|
+
this.urlWithoutAuth = urlWithoutAuth;
|
4267
4586
|
this.options = { ...this.options, ...options };
|
4268
4587
|
this.url = url;
|
4588
|
+
if (headers) {
|
4589
|
+
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4590
|
+
}
|
4269
4591
|
this.operations = this.createOperations();
|
4270
4592
|
const { resourceCacheTTL } = this.options;
|
4271
4593
|
if (isDefined2(resourceCacheTTL)) {
|
@@ -4287,12 +4609,16 @@ var _Provider = class {
|
|
4287
4609
|
* @hidden
|
4288
4610
|
*/
|
4289
4611
|
static getFetchFn(options) {
|
4290
|
-
const { retryOptions, timeout } = options;
|
4612
|
+
const { retryOptions, timeout, headers } = options;
|
4291
4613
|
return autoRetryFetch(async (...args) => {
|
4292
4614
|
const url = args[0];
|
4293
4615
|
const request = args[1];
|
4294
4616
|
const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
|
4295
|
-
let fullRequest = {
|
4617
|
+
let fullRequest = {
|
4618
|
+
...request,
|
4619
|
+
signal,
|
4620
|
+
headers: { ...request?.headers, ...headers }
|
4621
|
+
};
|
4296
4622
|
if (options.requestMiddleware) {
|
4297
4623
|
fullRequest = await options.requestMiddleware(fullRequest);
|
4298
4624
|
}
|
@@ -4300,15 +4626,23 @@ var _Provider = class {
|
|
4300
4626
|
}, retryOptions);
|
4301
4627
|
}
|
4302
4628
|
static extractBasicAuth(url) {
|
4303
|
-
|
4629
|
+
let parsedUrl;
|
4630
|
+
try {
|
4631
|
+
parsedUrl = new URL(url);
|
4632
|
+
} catch (error) {
|
4633
|
+
throw new FuelError16(FuelError16.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
4634
|
+
}
|
4304
4635
|
const username = parsedUrl.username;
|
4305
4636
|
const password = parsedUrl.password;
|
4306
|
-
const
|
4637
|
+
const urlWithoutAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
|
4307
4638
|
if (!(username && password)) {
|
4308
|
-
return { url,
|
4639
|
+
return { url, urlWithoutAuth: url, headers: void 0 };
|
4309
4640
|
}
|
4310
|
-
|
4311
|
-
|
4641
|
+
return {
|
4642
|
+
url,
|
4643
|
+
urlWithoutAuth,
|
4644
|
+
headers: { Authorization: `Basic ${btoa(`${username}:${password}`)}` }
|
4645
|
+
};
|
4312
4646
|
}
|
4313
4647
|
/**
|
4314
4648
|
* Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
|
@@ -4319,17 +4653,7 @@ var _Provider = class {
|
|
4319
4653
|
* @returns A promise that resolves to a Provider instance.
|
4320
4654
|
*/
|
4321
4655
|
static async create(url, options = {}) {
|
4322
|
-
const
|
4323
|
-
const provider = new _Provider(urlToUse, {
|
4324
|
-
...options,
|
4325
|
-
requestMiddleware: async (request) => {
|
4326
|
-
if (auth) {
|
4327
|
-
request.headers ??= {};
|
4328
|
-
request.headers.Authorization = auth;
|
4329
|
-
}
|
4330
|
-
return options.requestMiddleware?.(request) ?? request;
|
4331
|
-
}
|
4332
|
-
});
|
4656
|
+
const provider = new _Provider(url, options);
|
4333
4657
|
await provider.fetchChainAndNodeInfo();
|
4334
4658
|
return provider;
|
4335
4659
|
}
|
@@ -4339,9 +4663,9 @@ var _Provider = class {
|
|
4339
4663
|
* @returns the chain information configuration.
|
4340
4664
|
*/
|
4341
4665
|
getChain() {
|
4342
|
-
const chain = _Provider.chainInfoCache[this.
|
4666
|
+
const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
|
4343
4667
|
if (!chain) {
|
4344
|
-
throw new
|
4668
|
+
throw new FuelError16(
|
4345
4669
|
ErrorCode14.CHAIN_INFO_CACHE_EMPTY,
|
4346
4670
|
"Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4347
4671
|
);
|
@@ -4354,9 +4678,9 @@ var _Provider = class {
|
|
4354
4678
|
* @returns the node information configuration.
|
4355
4679
|
*/
|
4356
4680
|
getNode() {
|
4357
|
-
const node = _Provider.nodeInfoCache[this.
|
4681
|
+
const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
|
4358
4682
|
if (!node) {
|
4359
|
-
throw new
|
4683
|
+
throw new FuelError16(
|
4360
4684
|
ErrorCode14.NODE_INFO_CACHE_EMPTY,
|
4361
4685
|
"Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
|
4362
4686
|
);
|
@@ -4388,8 +4712,11 @@ var _Provider = class {
|
|
4388
4712
|
* @param options - Additional options for the provider.
|
4389
4713
|
*/
|
4390
4714
|
async connect(url, options) {
|
4391
|
-
|
4715
|
+
const { url: rawUrl, urlWithoutAuth, headers } = _Provider.extractBasicAuth(url);
|
4716
|
+
this.url = rawUrl;
|
4717
|
+
this.urlWithoutAuth = urlWithoutAuth;
|
4392
4718
|
this.options = options ?? this.options;
|
4719
|
+
this.options = { ...this.options, headers: { ...this.options.headers, ...headers } };
|
4393
4720
|
this.operations = this.createOperations();
|
4394
4721
|
await this.fetchChainAndNodeInfo();
|
4395
4722
|
}
|
@@ -4429,7 +4756,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4429
4756
|
*/
|
4430
4757
|
createOperations() {
|
4431
4758
|
const fetchFn = _Provider.getFetchFn(this.options);
|
4432
|
-
const gqlClient = new GraphQLClient(this.
|
4759
|
+
const gqlClient = new GraphQLClient(this.urlWithoutAuth, {
|
4433
4760
|
fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4434
4761
|
responseMiddleware: (response) => {
|
4435
4762
|
if ("response" in response) {
|
@@ -4447,7 +4774,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4447
4774
|
const isSubscription = opDefinition?.operation === "subscription";
|
4448
4775
|
if (isSubscription) {
|
4449
4776
|
return FuelGraphqlSubscriber.create({
|
4450
|
-
url: this.
|
4777
|
+
url: this.urlWithoutAuth,
|
4451
4778
|
query,
|
4452
4779
|
fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
|
4453
4780
|
variables: vars
|
@@ -4510,7 +4837,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4510
4837
|
utxoValidation: nodeInfo.utxoValidation,
|
4511
4838
|
vmBacktrace: nodeInfo.vmBacktrace
|
4512
4839
|
};
|
4513
|
-
_Provider.nodeInfoCache[this.
|
4840
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = processedNodeInfo;
|
4514
4841
|
return processedNodeInfo;
|
4515
4842
|
}
|
4516
4843
|
/**
|
@@ -4521,7 +4848,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4521
4848
|
async fetchChain() {
|
4522
4849
|
const { chain } = await this.operations.getChain();
|
4523
4850
|
const processedChain = processGqlChain(chain);
|
4524
|
-
_Provider.chainInfoCache[this.
|
4851
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = processedChain;
|
4525
4852
|
return processedChain;
|
4526
4853
|
}
|
4527
4854
|
/**
|
@@ -4549,13 +4876,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4549
4876
|
validateTransaction(tx, consensusParameters) {
|
4550
4877
|
const { maxOutputs, maxInputs } = consensusParameters.txParameters;
|
4551
4878
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
4552
|
-
throw new
|
4879
|
+
throw new FuelError16(
|
4553
4880
|
ErrorCode14.MAX_INPUTS_EXCEEDED,
|
4554
4881
|
"The transaction exceeds the maximum allowed number of inputs."
|
4555
4882
|
);
|
4556
4883
|
}
|
4557
4884
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
4558
|
-
throw new
|
4885
|
+
throw new FuelError16(
|
4559
4886
|
ErrorCode14.MAX_OUTPUTS_EXCEEDED,
|
4560
4887
|
"The transaction exceeds the maximum allowed number of outputs."
|
4561
4888
|
);
|
@@ -4578,16 +4905,14 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4578
4905
|
}
|
4579
4906
|
const { consensusParameters } = this.getChain();
|
4580
4907
|
this.validateTransaction(transactionRequest, consensusParameters);
|
4581
|
-
const encodedTransaction =
|
4908
|
+
const encodedTransaction = hexlify15(transactionRequest.toTransactionBytes());
|
4582
4909
|
let abis;
|
4583
4910
|
if (isTransactionTypeScript(transactionRequest)) {
|
4584
4911
|
abis = transactionRequest.abis;
|
4585
4912
|
}
|
4586
|
-
const {
|
4587
|
-
|
4588
|
-
|
4589
|
-
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
|
4590
|
-
return new TransactionResponse(transactionRequest, this, abis);
|
4913
|
+
const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
|
4914
|
+
__privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
|
4915
|
+
return new TransactionResponse(transactionRequest, this, abis, subscription);
|
4591
4916
|
}
|
4592
4917
|
/**
|
4593
4918
|
* Executes a transaction without actually submitting it to the chain.
|
@@ -4604,7 +4929,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4604
4929
|
if (estimateTxDependencies) {
|
4605
4930
|
return this.estimateTxDependencies(transactionRequest);
|
4606
4931
|
}
|
4607
|
-
const encodedTransaction =
|
4932
|
+
const encodedTransaction = hexlify15(transactionRequest.toTransactionBytes());
|
4608
4933
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4609
4934
|
encodedTransactions: encodedTransaction,
|
4610
4935
|
utxoValidation: utxoValidation || false
|
@@ -4624,13 +4949,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4624
4949
|
async estimatePredicates(transactionRequest) {
|
4625
4950
|
const shouldEstimatePredicates = Boolean(
|
4626
4951
|
transactionRequest.inputs.find(
|
4627
|
-
(input) => "predicate" in input && input.predicate && !equalBytes(
|
4952
|
+
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify12(input.predicate), arrayify12("0x")) && new BN2(input.predicateGasUsed).isZero()
|
4628
4953
|
)
|
4629
4954
|
);
|
4630
4955
|
if (!shouldEstimatePredicates) {
|
4631
4956
|
return transactionRequest;
|
4632
4957
|
}
|
4633
|
-
const encodedTransaction =
|
4958
|
+
const encodedTransaction = hexlify15(transactionRequest.toTransactionBytes());
|
4634
4959
|
const response = await this.operations.estimatePredicates({
|
4635
4960
|
encodedTransaction
|
4636
4961
|
});
|
@@ -4671,7 +4996,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4671
4996
|
const {
|
4672
4997
|
dryRun: [{ receipts: rawReceipts, status }]
|
4673
4998
|
} = await this.operations.dryRun({
|
4674
|
-
encodedTransactions: [
|
4999
|
+
encodedTransactions: [hexlify15(transactionRequest.toTransactionBytes())],
|
4675
5000
|
utxoValidation: false
|
4676
5001
|
});
|
4677
5002
|
receipts = rawReceipts.map(processGqlReceipt);
|
@@ -4717,11 +5042,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4717
5042
|
missingContractIds: [],
|
4718
5043
|
dryRunStatus: void 0
|
4719
5044
|
}));
|
4720
|
-
const allRequests =
|
5045
|
+
const allRequests = clone8(transactionRequests);
|
4721
5046
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
4722
5047
|
allRequests.forEach((req, index) => {
|
4723
5048
|
if (isTransactionTypeScript(req)) {
|
4724
|
-
serializedTransactionsMap.set(index,
|
5049
|
+
serializedTransactionsMap.set(index, hexlify15(req.toTransactionBytes()));
|
4725
5050
|
}
|
4726
5051
|
});
|
4727
5052
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -4757,7 +5082,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4757
5082
|
transactionRequest: request
|
4758
5083
|
});
|
4759
5084
|
request.maxFee = maxFee;
|
4760
|
-
serializedTransactionsMap.set(requestIdx,
|
5085
|
+
serializedTransactionsMap.set(requestIdx, hexlify15(request.toTransactionBytes()));
|
4761
5086
|
nextRoundTransactions.push(requestIdx);
|
4762
5087
|
}
|
4763
5088
|
}
|
@@ -4778,7 +5103,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4778
5103
|
if (estimateTxDependencies) {
|
4779
5104
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
4780
5105
|
}
|
4781
|
-
const encodedTransactions = transactionRequests.map((tx) =>
|
5106
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify15(tx.toTransactionBytes()));
|
4782
5107
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4783
5108
|
encodedTransactions,
|
4784
5109
|
utxoValidation: utxoValidation || false
|
@@ -4852,7 +5177,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4852
5177
|
if (estimateTxDependencies) {
|
4853
5178
|
return this.estimateTxDependencies(transactionRequest);
|
4854
5179
|
}
|
4855
|
-
const encodedTransactions = [
|
5180
|
+
const encodedTransactions = [hexlify15(transactionRequest.toTransactionBytes())];
|
4856
5181
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
4857
5182
|
encodedTransactions,
|
4858
5183
|
utxoValidation: true
|
@@ -4877,13 +5202,13 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4877
5202
|
* @returns A promise that resolves to the transaction cost object.
|
4878
5203
|
*/
|
4879
5204
|
async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
|
4880
|
-
const txRequestClone =
|
5205
|
+
const txRequestClone = clone8(transactionRequestify(transactionRequestLike));
|
4881
5206
|
const updateMaxFee = txRequestClone.maxFee.eq(0);
|
4882
5207
|
const isScriptTransaction = isTransactionTypeScript(txRequestClone);
|
4883
5208
|
if (isScriptTransaction) {
|
4884
5209
|
txRequestClone.gasLimit = bn17(0);
|
4885
5210
|
}
|
4886
|
-
const signedRequest =
|
5211
|
+
const signedRequest = clone8(txRequestClone);
|
4887
5212
|
let addedSignatures = 0;
|
4888
5213
|
if (signatureCallback && isTransactionTypeScript(signedRequest)) {
|
4889
5214
|
const lengthBefore = signedRequest.witnesses.length;
|
@@ -4951,7 +5276,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4951
5276
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
4952
5277
|
inputArgs: paginationArgs
|
4953
5278
|
}),
|
4954
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId &&
|
5279
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify15(assetId) }
|
4955
5280
|
});
|
4956
5281
|
const coins = edges.map(({ node }) => ({
|
4957
5282
|
id: node.utxoId,
|
@@ -4977,8 +5302,8 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4977
5302
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
4978
5303
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4979
5304
|
const excludeInput = {
|
4980
|
-
messages: excludedIds?.messages?.map((nonce) =>
|
4981
|
-
utxos: excludedIds?.utxos?.map((id) =>
|
5305
|
+
messages: excludedIds?.messages?.map((nonce) => hexlify15(nonce)) || [],
|
5306
|
+
utxos: excludedIds?.utxos?.map((id) => hexlify15(id)) || []
|
4982
5307
|
};
|
4983
5308
|
if (this.cache) {
|
4984
5309
|
const cached = this.cache.getActiveData();
|
@@ -4988,7 +5313,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4988
5313
|
const coinsQuery = {
|
4989
5314
|
owner: ownerAddress.toB256(),
|
4990
5315
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
4991
|
-
assetId:
|
5316
|
+
assetId: hexlify15(assetId),
|
4992
5317
|
amount: amount.toString(10),
|
4993
5318
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
4994
5319
|
})),
|
@@ -5143,7 +5468,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5143
5468
|
},
|
5144
5469
|
transactionIds: block.transactions.map((tx) => tx.id),
|
5145
5470
|
transactions: block.transactions.map(
|
5146
|
-
(tx) => new TransactionCoder5().decode(
|
5471
|
+
(tx) => new TransactionCoder5().decode(arrayify12(tx.rawPayload), 0)?.[0]
|
5147
5472
|
)
|
5148
5473
|
};
|
5149
5474
|
}
|
@@ -5160,11 +5485,11 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5160
5485
|
}
|
5161
5486
|
try {
|
5162
5487
|
return new TransactionCoder5().decode(
|
5163
|
-
|
5488
|
+
arrayify12(transaction.rawPayload),
|
5164
5489
|
0
|
5165
5490
|
)?.[0];
|
5166
5491
|
} catch (error) {
|
5167
|
-
if (error instanceof
|
5492
|
+
if (error instanceof FuelError16 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
|
5168
5493
|
console.warn("Unsupported transaction type encountered");
|
5169
5494
|
return null;
|
5170
5495
|
}
|
@@ -5183,9 +5508,9 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5183
5508
|
const coder = new TransactionCoder5();
|
5184
5509
|
const transactions = edges.map(({ node: { rawPayload } }) => {
|
5185
5510
|
try {
|
5186
|
-
return coder.decode(
|
5511
|
+
return coder.decode(arrayify12(rawPayload), 0)[0];
|
5187
5512
|
} catch (error) {
|
5188
|
-
if (error instanceof
|
5513
|
+
if (error instanceof FuelError16 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
|
5189
5514
|
console.warn("Unsupported transaction type encountered");
|
5190
5515
|
return null;
|
5191
5516
|
}
|
@@ -5217,7 +5542,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5217
5542
|
async getContractBalance(contractId, assetId) {
|
5218
5543
|
const { contractBalance } = await this.operations.getContractBalance({
|
5219
5544
|
contract: Address2.fromAddressOrString(contractId).toB256(),
|
5220
|
-
asset:
|
5545
|
+
asset: hexlify15(assetId)
|
5221
5546
|
});
|
5222
5547
|
return bn17(contractBalance.amount, 10);
|
5223
5548
|
}
|
@@ -5231,7 +5556,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5231
5556
|
async getBalance(owner, assetId) {
|
5232
5557
|
const { balance } = await this.operations.getBalance({
|
5233
5558
|
owner: Address2.fromAddressOrString(owner).toB256(),
|
5234
|
-
assetId:
|
5559
|
+
assetId: hexlify15(assetId)
|
5235
5560
|
});
|
5236
5561
|
return bn17(balance.amount, 10);
|
5237
5562
|
}
|
@@ -5277,7 +5602,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5277
5602
|
owner: Address2.fromAddressOrString(address).toB256()
|
5278
5603
|
});
|
5279
5604
|
const messages = edges.map(({ node }) => ({
|
5280
|
-
messageId:
|
5605
|
+
messageId: InputMessageCoder2.getMessageId({
|
5281
5606
|
sender: node.sender,
|
5282
5607
|
recipient: node.recipient,
|
5283
5608
|
nonce: node.nonce,
|
@@ -5288,7 +5613,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5288
5613
|
recipient: Address2.fromAddressOrString(node.recipient),
|
5289
5614
|
nonce: node.nonce,
|
5290
5615
|
amount: bn17(node.amount),
|
5291
|
-
data:
|
5616
|
+
data: InputMessageCoder2.decodeData(node.data),
|
5292
5617
|
daHeight: bn17(node.daHeight)
|
5293
5618
|
}));
|
5294
5619
|
return {
|
@@ -5311,7 +5636,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5311
5636
|
nonce
|
5312
5637
|
};
|
5313
5638
|
if (commitBlockId && commitBlockHeight) {
|
5314
|
-
throw new
|
5639
|
+
throw new FuelError16(
|
5315
5640
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5316
5641
|
"commitBlockId and commitBlockHeight cannot be used together"
|
5317
5642
|
);
|
@@ -5457,7 +5782,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5457
5782
|
return null;
|
5458
5783
|
}
|
5459
5784
|
const message = {
|
5460
|
-
messageId:
|
5785
|
+
messageId: InputMessageCoder2.getMessageId({
|
5461
5786
|
sender: rawMessage.sender,
|
5462
5787
|
recipient: rawMessage.recipient,
|
5463
5788
|
nonce: rawMessage.nonce,
|
@@ -5468,7 +5793,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5468
5793
|
recipient: Address2.fromAddressOrString(rawMessage.recipient),
|
5469
5794
|
nonce: rawMessage.nonce,
|
5470
5795
|
amount: bn17(rawMessage.amount),
|
5471
|
-
data:
|
5796
|
+
data: InputMessageCoder2.decodeData(rawMessage.data),
|
5472
5797
|
daHeight: bn17(rawMessage.daHeight)
|
5473
5798
|
};
|
5474
5799
|
return message;
|
@@ -5495,25 +5820,25 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5495
5820
|
const { paginationLimit, inputArgs = {} } = params;
|
5496
5821
|
const { first, last, after, before } = inputArgs;
|
5497
5822
|
if (after && before) {
|
5498
|
-
throw new
|
5823
|
+
throw new FuelError16(
|
5499
5824
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5500
5825
|
'Pagination arguments "after" and "before" cannot be used together'
|
5501
5826
|
);
|
5502
5827
|
}
|
5503
5828
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5504
|
-
throw new
|
5829
|
+
throw new FuelError16(
|
5505
5830
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5506
5831
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5507
5832
|
);
|
5508
5833
|
}
|
5509
5834
|
if (first && before) {
|
5510
|
-
throw new
|
5835
|
+
throw new FuelError16(
|
5511
5836
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5512
5837
|
'The use of pagination argument "first" with "before" is not supported'
|
5513
5838
|
);
|
5514
5839
|
}
|
5515
5840
|
if (last && after) {
|
5516
|
-
throw new
|
5841
|
+
throw new FuelError16(
|
5517
5842
|
ErrorCode14.INVALID_INPUT_PARAMETERS,
|
5518
5843
|
'The use of pagination argument "last" with "after" is not supported'
|
5519
5844
|
);
|
@@ -5568,23 +5893,23 @@ __publicField(Provider, "chainInfoCache", {});
|
|
5568
5893
|
__publicField(Provider, "nodeInfoCache", {});
|
5569
5894
|
|
5570
5895
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
5571
|
-
import { ErrorCode as ErrorCode15, FuelError as
|
5896
|
+
import { ErrorCode as ErrorCode15, FuelError as FuelError17 } from "@fuel-ts/errors";
|
5572
5897
|
import { bn as bn18 } from "@fuel-ts/math";
|
5573
5898
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
5574
|
-
import { arrayify as
|
5899
|
+
import { arrayify as arrayify13 } from "@fuel-ts/utils";
|
5575
5900
|
async function getTransactionSummary(params) {
|
5576
5901
|
const { id, provider, abiMap } = params;
|
5577
5902
|
const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
|
5578
5903
|
transactionId: id
|
5579
5904
|
});
|
5580
5905
|
if (!gqlTransaction) {
|
5581
|
-
throw new
|
5906
|
+
throw new FuelError17(
|
5582
5907
|
ErrorCode15.TRANSACTION_NOT_FOUND,
|
5583
5908
|
`Transaction not found for given id: ${id}.`
|
5584
5909
|
);
|
5585
5910
|
}
|
5586
5911
|
const [decodedTransaction] = new TransactionCoder6().decode(
|
5587
|
-
|
5912
|
+
arrayify13(gqlTransaction.rawPayload),
|
5588
5913
|
0
|
5589
5914
|
);
|
5590
5915
|
let txReceipts = [];
|
@@ -5605,7 +5930,7 @@ async function getTransactionSummary(params) {
|
|
5605
5930
|
id: gqlTransaction.id,
|
5606
5931
|
receipts,
|
5607
5932
|
transaction: decodedTransaction,
|
5608
|
-
transactionBytes:
|
5933
|
+
transactionBytes: arrayify13(gqlTransaction.rawPayload),
|
5609
5934
|
gqlTransactionStatus: gqlTransaction.status,
|
5610
5935
|
gasPerByte: bn18(gasPerByte),
|
5611
5936
|
gasPriceFactor: bn18(gasPriceFactor),
|
@@ -5661,7 +5986,7 @@ async function getTransactionsSummaries(params) {
|
|
5661
5986
|
const transactions = edges.map((edge) => {
|
5662
5987
|
const { node: gqlTransaction } = edge;
|
5663
5988
|
const { id, rawPayload, status } = gqlTransaction;
|
5664
|
-
const [decodedTransaction] = new TransactionCoder6().decode(
|
5989
|
+
const [decodedTransaction] = new TransactionCoder6().decode(arrayify13(rawPayload), 0);
|
5665
5990
|
let txReceipts = [];
|
5666
5991
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
5667
5992
|
txReceipts = gqlTransaction.status.receipts;
|
@@ -5671,7 +5996,7 @@ async function getTransactionsSummaries(params) {
|
|
5671
5996
|
id,
|
5672
5997
|
receipts,
|
5673
5998
|
transaction: decodedTransaction,
|
5674
|
-
transactionBytes:
|
5999
|
+
transactionBytes: arrayify13(rawPayload),
|
5675
6000
|
gqlTransactionStatus: status,
|
5676
6001
|
abiMap,
|
5677
6002
|
gasPerByte,
|
@@ -5696,12 +6021,14 @@ async function getTransactionsSummaries(params) {
|
|
5696
6021
|
// src/providers/chains.ts
|
5697
6022
|
var CHAIN_IDS = {
|
5698
6023
|
eth: {
|
6024
|
+
mainnet: 1,
|
5699
6025
|
sepolia: 11155111,
|
5700
6026
|
foundry: 31337
|
5701
6027
|
},
|
5702
6028
|
fuel: {
|
5703
6029
|
devnet: 0,
|
5704
|
-
testnet: 0
|
6030
|
+
testnet: 0,
|
6031
|
+
mainnet: 9889
|
5705
6032
|
}
|
5706
6033
|
};
|
5707
6034
|
|
@@ -5801,6 +6128,11 @@ var rawAssets = [
|
|
5801
6128
|
chainId: CHAIN_IDS.eth.foundry,
|
5802
6129
|
decimals: 18
|
5803
6130
|
},
|
6131
|
+
{
|
6132
|
+
type: "ethereum",
|
6133
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6134
|
+
decimals: 18
|
6135
|
+
},
|
5804
6136
|
{
|
5805
6137
|
type: "fuel",
|
5806
6138
|
chainId: CHAIN_IDS.fuel.devnet,
|
@@ -5812,48 +6144,613 @@ var rawAssets = [
|
|
5812
6144
|
chainId: CHAIN_IDS.fuel.testnet,
|
5813
6145
|
decimals: 9,
|
5814
6146
|
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
6147
|
+
},
|
6148
|
+
{
|
6149
|
+
type: "fuel",
|
6150
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6151
|
+
decimals: 9,
|
6152
|
+
assetId: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
|
5815
6153
|
}
|
5816
6154
|
]
|
5817
|
-
}
|
5818
|
-
|
5819
|
-
|
5820
|
-
|
5821
|
-
|
5822
|
-
|
5823
|
-
|
5824
|
-
|
5825
|
-
|
5826
|
-
|
5827
|
-
|
5828
|
-
|
5829
|
-
|
5830
|
-
|
5831
|
-
|
5832
|
-
|
5833
|
-
|
5834
|
-
|
5835
|
-
|
5836
|
-
|
5837
|
-
|
5838
|
-
|
5839
|
-
|
5840
|
-
|
5841
|
-
|
5842
|
-
|
5843
|
-
|
5844
|
-
|
5845
|
-
|
5846
|
-
|
5847
|
-
|
5848
|
-
|
5849
|
-
|
5850
|
-
|
5851
|
-
|
5852
|
-
|
5853
|
-
|
5854
|
-
|
5855
|
-
|
5856
|
-
|
6155
|
+
},
|
6156
|
+
{
|
6157
|
+
name: "WETH",
|
6158
|
+
symbol: "WETH",
|
6159
|
+
icon: "weth.svg",
|
6160
|
+
networks: [
|
6161
|
+
{
|
6162
|
+
type: "ethereum",
|
6163
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6164
|
+
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
6165
|
+
decimals: 18
|
6166
|
+
},
|
6167
|
+
{
|
6168
|
+
type: "fuel",
|
6169
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6170
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6171
|
+
assetId: "0xa38a5a8beeb08d95744bc7f58528073f4052b254def59eba20c99c202b5acaa3",
|
6172
|
+
decimals: 18
|
6173
|
+
}
|
6174
|
+
]
|
6175
|
+
},
|
6176
|
+
{
|
6177
|
+
name: "weETH",
|
6178
|
+
symbol: "weETH",
|
6179
|
+
icon: "weETH.webp",
|
6180
|
+
networks: [
|
6181
|
+
{
|
6182
|
+
type: "ethereum",
|
6183
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6184
|
+
address: "0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee",
|
6185
|
+
decimals: 18
|
6186
|
+
},
|
6187
|
+
{
|
6188
|
+
type: "fuel",
|
6189
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6190
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6191
|
+
assetId: "0x239ed6e12b7ce4089ee245244e3bf906999a6429c2a9a445a1e1faf56914a4ab",
|
6192
|
+
decimals: 18
|
6193
|
+
}
|
6194
|
+
]
|
6195
|
+
},
|
6196
|
+
{
|
6197
|
+
name: "rsETH",
|
6198
|
+
symbol: "rsETH",
|
6199
|
+
icon: "rsETH.webp",
|
6200
|
+
networks: [
|
6201
|
+
{
|
6202
|
+
type: "ethereum",
|
6203
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6204
|
+
address: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
|
6205
|
+
decimals: 18
|
6206
|
+
},
|
6207
|
+
{
|
6208
|
+
type: "fuel",
|
6209
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6210
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6211
|
+
assetId: "0xbae80f7fb8aa6b90d9b01ef726ec847cc4f59419c4d5f2ea88fec785d1b0e849",
|
6212
|
+
decimals: 18
|
6213
|
+
}
|
6214
|
+
]
|
6215
|
+
},
|
6216
|
+
{
|
6217
|
+
name: "rETH",
|
6218
|
+
symbol: "rETH",
|
6219
|
+
icon: "reth.svg",
|
6220
|
+
networks: [
|
6221
|
+
{
|
6222
|
+
type: "ethereum",
|
6223
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6224
|
+
address: "0xae78736cd615f374d3085123a210448e74fc6393",
|
6225
|
+
decimals: 18
|
6226
|
+
},
|
6227
|
+
{
|
6228
|
+
type: "fuel",
|
6229
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6230
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6231
|
+
assetId: "0xf3f9a0ed0ce8eac5f89d6b83e41b3848212d5b5f56108c54a205bb228ca30c16",
|
6232
|
+
decimals: 18
|
6233
|
+
}
|
6234
|
+
]
|
6235
|
+
},
|
6236
|
+
{
|
6237
|
+
name: "wbETH",
|
6238
|
+
symbol: "wbETH",
|
6239
|
+
icon: "wbeth.png",
|
6240
|
+
networks: [
|
6241
|
+
{
|
6242
|
+
type: "ethereum",
|
6243
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6244
|
+
address: "0xa2E3356610840701BDf5611a53974510Ae27E2e1",
|
6245
|
+
decimals: 18
|
6246
|
+
},
|
6247
|
+
{
|
6248
|
+
type: "fuel",
|
6249
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6250
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6251
|
+
assetId: "0x7843c74bef935e837f2bcf67b5d64ecb46dd53ff86375530b0caf3699e8ffafe",
|
6252
|
+
decimals: 18
|
6253
|
+
}
|
6254
|
+
]
|
6255
|
+
},
|
6256
|
+
{
|
6257
|
+
name: "rstETH",
|
6258
|
+
symbol: "rstETH",
|
6259
|
+
icon: "rstETH.webp",
|
6260
|
+
networks: [
|
6261
|
+
{
|
6262
|
+
type: "ethereum",
|
6263
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6264
|
+
address: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
6265
|
+
decimals: 18
|
6266
|
+
},
|
6267
|
+
{
|
6268
|
+
type: "fuel",
|
6269
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6270
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6271
|
+
assetId: "0x962792286fbc9b1d5860b4551362a12249362c21594c77abf4b3fe2bbe8d977a",
|
6272
|
+
decimals: 18
|
6273
|
+
}
|
6274
|
+
]
|
6275
|
+
},
|
6276
|
+
{
|
6277
|
+
name: "amphrETH",
|
6278
|
+
symbol: "amphrETH",
|
6279
|
+
icon: "amphrETH.png",
|
6280
|
+
networks: [
|
6281
|
+
{
|
6282
|
+
type: "ethereum",
|
6283
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6284
|
+
address: "0x5fD13359Ba15A84B76f7F87568309040176167cd",
|
6285
|
+
decimals: 18
|
6286
|
+
},
|
6287
|
+
{
|
6288
|
+
type: "fuel",
|
6289
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6290
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6291
|
+
assetId: "0x05fc623e57bd7bc1258efa8e4f62b05af5471d73df6f2c2dc11ecc81134c4f36",
|
6292
|
+
decimals: 18
|
6293
|
+
}
|
6294
|
+
]
|
6295
|
+
},
|
6296
|
+
{
|
6297
|
+
name: "Manta mBTC",
|
6298
|
+
symbol: "Manta mBTC",
|
6299
|
+
icon: "manta-mbtc.svg",
|
6300
|
+
networks: [
|
6301
|
+
{
|
6302
|
+
type: "ethereum",
|
6303
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6304
|
+
address: "0x4041381e947CFD3D483d67a25C6aa9Dc924250c5",
|
6305
|
+
decimals: 18
|
6306
|
+
},
|
6307
|
+
{
|
6308
|
+
type: "fuel",
|
6309
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6310
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6311
|
+
assetId: "0xaf3111a248ff7a3238cdeea845bb2d43cf3835f1f6b8c9d28360728b55b9ce5b",
|
6312
|
+
decimals: 18
|
6313
|
+
}
|
6314
|
+
]
|
6315
|
+
},
|
6316
|
+
{
|
6317
|
+
name: "Manta mETH",
|
6318
|
+
symbol: "Manta mETH",
|
6319
|
+
icon: "manta-meth.svg",
|
6320
|
+
networks: [
|
6321
|
+
{
|
6322
|
+
type: "ethereum",
|
6323
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6324
|
+
address: "0x8CdF550C04Bc9B9F10938368349C9c8051A772b6",
|
6325
|
+
decimals: 18
|
6326
|
+
},
|
6327
|
+
{
|
6328
|
+
type: "fuel",
|
6329
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6330
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6331
|
+
assetId: "0xafd219f513317b1750783c6581f55530d6cf189a5863fd18bd1b3ffcec1714b4",
|
6332
|
+
decimals: 18
|
6333
|
+
}
|
6334
|
+
]
|
6335
|
+
},
|
6336
|
+
{
|
6337
|
+
name: "Manta mUSD",
|
6338
|
+
symbol: "Manta mUSD",
|
6339
|
+
icon: "manta-musd.svg",
|
6340
|
+
networks: [
|
6341
|
+
{
|
6342
|
+
type: "ethereum",
|
6343
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6344
|
+
address: "0x3f24E1d7a973867fC2A03fE199E5502514E0e11E",
|
6345
|
+
decimals: 18
|
6346
|
+
},
|
6347
|
+
{
|
6348
|
+
type: "fuel",
|
6349
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6350
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6351
|
+
assetId: "0x89cb9401e55d49c3269654dd1cdfb0e80e57823a4a7db98ba8fc5953b120fef4",
|
6352
|
+
decimals: 18
|
6353
|
+
}
|
6354
|
+
]
|
6355
|
+
},
|
6356
|
+
{
|
6357
|
+
name: "pumpBTC",
|
6358
|
+
symbol: "pumpBTC",
|
6359
|
+
icon: "pumpbtc.webp",
|
6360
|
+
networks: [
|
6361
|
+
{
|
6362
|
+
type: "ethereum",
|
6363
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6364
|
+
address: "0xf469fbd2abcd6b9de8e169d128226c0fc90a012e",
|
6365
|
+
decimals: 8
|
6366
|
+
},
|
6367
|
+
{
|
6368
|
+
type: "fuel",
|
6369
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6370
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6371
|
+
assetId: "0x0aa5eb2bb97ca915288b653a2529355d4dc66de2b37533213f0e4aeee3d3421f",
|
6372
|
+
decimals: 8
|
6373
|
+
}
|
6374
|
+
]
|
6375
|
+
},
|
6376
|
+
{
|
6377
|
+
name: "FBTC",
|
6378
|
+
symbol: "FBTC",
|
6379
|
+
icon: "fbtc.svg",
|
6380
|
+
networks: [
|
6381
|
+
{
|
6382
|
+
type: "ethereum",
|
6383
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6384
|
+
address: "0xc96de26018a54d51c097160568752c4e3bd6c364",
|
6385
|
+
decimals: 8
|
6386
|
+
},
|
6387
|
+
{
|
6388
|
+
type: "fuel",
|
6389
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6390
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6391
|
+
assetId: "0xb5ecb0a1e08e2abbabf624ffea089df933376855f468ade35c6375b00c33996a",
|
6392
|
+
decimals: 8
|
6393
|
+
}
|
6394
|
+
]
|
6395
|
+
},
|
6396
|
+
{
|
6397
|
+
name: "SolvBTC",
|
6398
|
+
symbol: "SolvBTC",
|
6399
|
+
icon: "solvBTC.webp",
|
6400
|
+
networks: [
|
6401
|
+
{
|
6402
|
+
type: "ethereum",
|
6403
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6404
|
+
address: "0x7a56e1c57c7475ccf742a1832b028f0456652f97",
|
6405
|
+
decimals: 18
|
6406
|
+
},
|
6407
|
+
{
|
6408
|
+
type: "fuel",
|
6409
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6410
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6411
|
+
assetId: "0x1186afea9affb88809c210e13e2330b5258c2cef04bb8fff5eff372b7bd3f40f",
|
6412
|
+
decimals: 18
|
6413
|
+
}
|
6414
|
+
]
|
6415
|
+
},
|
6416
|
+
{
|
6417
|
+
name: "SolvBTC.BBN",
|
6418
|
+
symbol: "SolvBTC.BBN",
|
6419
|
+
icon: "SolvBTC.BBN.png",
|
6420
|
+
networks: [
|
6421
|
+
{
|
6422
|
+
type: "ethereum",
|
6423
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6424
|
+
address: "0xd9d920aa40f578ab794426f5c90f6c731d159def",
|
6425
|
+
decimals: 18
|
6426
|
+
},
|
6427
|
+
{
|
6428
|
+
type: "fuel",
|
6429
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6430
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6431
|
+
assetId: "0x7a4f087c957d30218223c2baaaa365355c9ca81b6ea49004cfb1590a5399216f",
|
6432
|
+
decimals: 18
|
6433
|
+
}
|
6434
|
+
]
|
6435
|
+
},
|
6436
|
+
{
|
6437
|
+
name: "Mantle mETH",
|
6438
|
+
symbol: "Mantle mETH",
|
6439
|
+
icon: "mantle-meth.svg",
|
6440
|
+
networks: [
|
6441
|
+
{
|
6442
|
+
type: "ethereum",
|
6443
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6444
|
+
address: "0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa",
|
6445
|
+
decimals: 18
|
6446
|
+
},
|
6447
|
+
{
|
6448
|
+
type: "fuel",
|
6449
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6450
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6451
|
+
assetId: "0x642a5db59ec323c2f846d4d4cf3e58d78aff64accf4f8f6455ba0aa3ef000a3b",
|
6452
|
+
decimals: 18
|
6453
|
+
}
|
6454
|
+
]
|
6455
|
+
},
|
6456
|
+
{
|
6457
|
+
name: "sDAI",
|
6458
|
+
symbol: "sDAI",
|
6459
|
+
icon: "sdai.svg",
|
6460
|
+
networks: [
|
6461
|
+
{
|
6462
|
+
type: "ethereum",
|
6463
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6464
|
+
address: "0x83f20f44975d03b1b09e64809b757c47f942beea",
|
6465
|
+
decimals: 18
|
6466
|
+
},
|
6467
|
+
{
|
6468
|
+
type: "fuel",
|
6469
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6470
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6471
|
+
assetId: "0x9e46f919fbf978f3cad7cd34cca982d5613af63ff8aab6c379e4faa179552958",
|
6472
|
+
decimals: 18
|
6473
|
+
}
|
6474
|
+
]
|
6475
|
+
},
|
6476
|
+
{
|
6477
|
+
name: "USDT",
|
6478
|
+
symbol: "USDT",
|
6479
|
+
icon: "usdt.svg",
|
6480
|
+
networks: [
|
6481
|
+
{
|
6482
|
+
type: "ethereum",
|
6483
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6484
|
+
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
6485
|
+
decimals: 6
|
6486
|
+
},
|
6487
|
+
{
|
6488
|
+
type: "fuel",
|
6489
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6490
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6491
|
+
assetId: "0xa0265fb5c32f6e8db3197af3c7eb05c48ae373605b8165b6f4a51c5b0ba4812e",
|
6492
|
+
decimals: 6
|
6493
|
+
}
|
6494
|
+
]
|
6495
|
+
},
|
6496
|
+
{
|
6497
|
+
name: "USDC",
|
6498
|
+
symbol: "USDC",
|
6499
|
+
icon: "usdc.svg",
|
6500
|
+
networks: [
|
6501
|
+
{
|
6502
|
+
type: "ethereum",
|
6503
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6504
|
+
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
6505
|
+
decimals: 6
|
6506
|
+
},
|
6507
|
+
{
|
6508
|
+
type: "fuel",
|
6509
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6510
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6511
|
+
assetId: "0x286c479da40dc953bddc3bb4c453b608bba2e0ac483b077bd475174115395e6b",
|
6512
|
+
decimals: 6
|
6513
|
+
}
|
6514
|
+
]
|
6515
|
+
},
|
6516
|
+
{
|
6517
|
+
name: "USDe",
|
6518
|
+
symbol: "USDe",
|
6519
|
+
icon: "USDe.svg",
|
6520
|
+
networks: [
|
6521
|
+
{
|
6522
|
+
type: "ethereum",
|
6523
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6524
|
+
address: "0x4c9edd5852cd905f086c759e8383e09bff1e68b3",
|
6525
|
+
decimals: 18
|
6526
|
+
},
|
6527
|
+
{
|
6528
|
+
type: "ethereum",
|
6529
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6530
|
+
address: "0xc6387efad0f184a90b34f397c3d6fd63135ef790",
|
6531
|
+
decimals: 18
|
6532
|
+
},
|
6533
|
+
{
|
6534
|
+
type: "fuel",
|
6535
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6536
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6537
|
+
assetId: "0xb6133b2ef9f6153eb869125d23dcf20d1e735331b5e41b15a6a7a6cec70e8651",
|
6538
|
+
decimals: 18
|
6539
|
+
},
|
6540
|
+
{
|
6541
|
+
type: "fuel",
|
6542
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6543
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6544
|
+
assetId: "0xf5c6d72d0f2c782fa47d8e228c198a08654e9fc66ca60ad85902b1d09046a7ab",
|
6545
|
+
decimals: 18
|
6546
|
+
}
|
6547
|
+
]
|
6548
|
+
},
|
6549
|
+
{
|
6550
|
+
name: "sUSDe",
|
6551
|
+
symbol: "sUSDe",
|
6552
|
+
icon: "sUSDe.webp",
|
6553
|
+
networks: [
|
6554
|
+
{
|
6555
|
+
type: "ethereum",
|
6556
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6557
|
+
address: "0x9d39a5de30e57443bff2a8307a4256c8797a3497",
|
6558
|
+
decimals: 18
|
6559
|
+
},
|
6560
|
+
{
|
6561
|
+
type: "ethereum",
|
6562
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6563
|
+
address: "0xb8f4f4eafc1d2a3c0a4d519bbf1114c311cc9b1b",
|
6564
|
+
decimals: 18
|
6565
|
+
},
|
6566
|
+
{
|
6567
|
+
type: "fuel",
|
6568
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6569
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6570
|
+
assetId: "0xd05563025104fc36496c15c7021ad6b31034b0e89a356f4f818045d1f48808bc",
|
6571
|
+
decimals: 18
|
6572
|
+
},
|
6573
|
+
{
|
6574
|
+
type: "fuel",
|
6575
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6576
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6577
|
+
assetId: "0xa86e37d385c08beddbb02c8260f9ec535d484c8ea908fc19d4e6dc8d5141fb2e",
|
6578
|
+
decimals: 18
|
6579
|
+
}
|
6580
|
+
]
|
6581
|
+
},
|
6582
|
+
{
|
6583
|
+
name: "rsUSDe",
|
6584
|
+
symbol: "rsUSDe",
|
6585
|
+
icon: "rsUSDe.svg",
|
6586
|
+
networks: [
|
6587
|
+
{
|
6588
|
+
type: "ethereum",
|
6589
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6590
|
+
address: "0x82f5104b23FF2FA54C2345F821dAc9369e9E0B26",
|
6591
|
+
decimals: 18
|
6592
|
+
},
|
6593
|
+
{
|
6594
|
+
type: "fuel",
|
6595
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6596
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6597
|
+
assetId: "0x78d4522ec607f6e8efb66ea49439d1ee48623cf763f9688a8eada025def033d9",
|
6598
|
+
decimals: 18
|
6599
|
+
}
|
6600
|
+
]
|
6601
|
+
},
|
6602
|
+
{
|
6603
|
+
name: "wstETH",
|
6604
|
+
symbol: "wstETH",
|
6605
|
+
icon: "wsteth.svg",
|
6606
|
+
networks: [
|
6607
|
+
{
|
6608
|
+
type: "ethereum",
|
6609
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6610
|
+
address: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0",
|
6611
|
+
decimals: 18
|
6612
|
+
},
|
6613
|
+
{
|
6614
|
+
type: "ethereum",
|
6615
|
+
chainId: CHAIN_IDS.eth.sepolia,
|
6616
|
+
address: "0xB82381A3fBD3FaFA77B3a7bE693342618240067b",
|
6617
|
+
decimals: 18
|
6618
|
+
},
|
6619
|
+
{
|
6620
|
+
type: "fuel",
|
6621
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6622
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6623
|
+
assetId: "0x1a7815cc9f75db5c24a5b0814bfb706bb9fe485333e98254015de8f48f84c67b",
|
6624
|
+
decimals: 18
|
6625
|
+
},
|
6626
|
+
{
|
6627
|
+
type: "fuel",
|
6628
|
+
chainId: CHAIN_IDS.fuel.testnet,
|
6629
|
+
contractId: "0xC6387efAD0F184a90B34f397C3d6Fd63135ef790",
|
6630
|
+
assetId: "0x4c467e3fd4f32179e1aad3b92ebbdaa6ff6aeda5b8da5f8e64e96405eb52a7f5",
|
6631
|
+
decimals: 18
|
6632
|
+
}
|
6633
|
+
]
|
6634
|
+
},
|
6635
|
+
{
|
6636
|
+
name: "ezETH",
|
6637
|
+
symbol: "ezETH",
|
6638
|
+
icon: "ezeth.webp",
|
6639
|
+
networks: [
|
6640
|
+
{
|
6641
|
+
type: "ethereum",
|
6642
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6643
|
+
address: "0xbf5495Efe5DB9ce00f80364C8B423567e58d2110",
|
6644
|
+
decimals: 18
|
6645
|
+
},
|
6646
|
+
{
|
6647
|
+
type: "fuel",
|
6648
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6649
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6650
|
+
assetId: "0x91b3559edb2619cde8ffb2aa7b3c3be97efd794ea46700db7092abeee62281b0",
|
6651
|
+
decimals: 18
|
6652
|
+
}
|
6653
|
+
]
|
6654
|
+
},
|
6655
|
+
{
|
6656
|
+
name: "pzETH",
|
6657
|
+
symbol: "pzETH",
|
6658
|
+
icon: "pzETH.webp",
|
6659
|
+
networks: [
|
6660
|
+
{
|
6661
|
+
type: "ethereum",
|
6662
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6663
|
+
address: "0x8c9532a60e0e7c6bbd2b2c1303f63ace1c3e9811",
|
6664
|
+
decimals: 18
|
6665
|
+
},
|
6666
|
+
{
|
6667
|
+
type: "fuel",
|
6668
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6669
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6670
|
+
assetId: "0x1493d4ec82124de8f9b625682de69dcccda79e882b89a55a8c737b12de67bd68",
|
6671
|
+
decimals: 18
|
6672
|
+
}
|
6673
|
+
]
|
6674
|
+
},
|
6675
|
+
{
|
6676
|
+
name: "Re7LRT",
|
6677
|
+
symbol: "Re7LRT",
|
6678
|
+
icon: "Re7LRT.png",
|
6679
|
+
networks: [
|
6680
|
+
{
|
6681
|
+
type: "ethereum",
|
6682
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6683
|
+
address: "0x84631c0d0081FDe56DeB72F6DE77abBbF6A9f93a",
|
6684
|
+
decimals: 18
|
6685
|
+
},
|
6686
|
+
{
|
6687
|
+
type: "fuel",
|
6688
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6689
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6690
|
+
assetId: "0xf2fc648c23a5db24610a1cf696acc4f0f6d9a7d6028dd9944964ab23f6e35995",
|
6691
|
+
decimals: 18
|
6692
|
+
}
|
6693
|
+
]
|
6694
|
+
},
|
6695
|
+
{
|
6696
|
+
name: "steakLRT",
|
6697
|
+
symbol: "steakLRT",
|
6698
|
+
icon: "steakLRT.png",
|
6699
|
+
networks: [
|
6700
|
+
{
|
6701
|
+
type: "ethereum",
|
6702
|
+
chainId: CHAIN_IDS.eth.mainnet,
|
6703
|
+
address: "0xBEEF69Ac7870777598A04B2bd4771c71212E6aBc",
|
6704
|
+
decimals: 18
|
6705
|
+
},
|
6706
|
+
{
|
6707
|
+
type: "fuel",
|
6708
|
+
chainId: CHAIN_IDS.fuel.mainnet,
|
6709
|
+
contractId: "0x4ea6ccef1215d9479f1024dff70fc055ca538215d2c8c348beddffd54583d0e8",
|
6710
|
+
assetId: "0x4fc8ac9f101df07e2c2dec4a53c8c42c439bdbe5e36ea2d863a61ff60afafc30",
|
6711
|
+
decimals: 18
|
6712
|
+
}
|
6713
|
+
]
|
6714
|
+
}
|
6715
|
+
];
|
6716
|
+
var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
|
6717
|
+
|
6718
|
+
// src/providers/utils/merge-quantities.ts
|
6719
|
+
var mergeQuantities = (...coinQuantities) => {
|
6720
|
+
const resultMap = {};
|
6721
|
+
function addToMap({ amount, assetId }) {
|
6722
|
+
if (resultMap[assetId]) {
|
6723
|
+
resultMap[assetId] = resultMap[assetId].add(amount);
|
6724
|
+
} else {
|
6725
|
+
resultMap[assetId] = amount;
|
6726
|
+
}
|
6727
|
+
}
|
6728
|
+
coinQuantities.forEach((arr) => arr.forEach(addToMap));
|
6729
|
+
return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
|
6730
|
+
};
|
6731
|
+
|
6732
|
+
// src/utils/formatTransferToContractScriptData.ts
|
6733
|
+
import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
|
6734
|
+
import { BN as BN3 } from "@fuel-ts/math";
|
6735
|
+
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
6736
|
+
import * as asm from "@fuels/vm-asm";
|
6737
|
+
var formatTransferToContractScriptData = (params) => {
|
6738
|
+
const { assetId, amountToTransfer, hexlifiedContractId } = params;
|
6739
|
+
const numberCoder = new BigNumberCoder2("u64");
|
6740
|
+
const encoded = numberCoder.encode(new BN3(amountToTransfer).toNumber());
|
6741
|
+
const scriptData = Uint8Array.from([
|
6742
|
+
...arrayify14(hexlifiedContractId),
|
6743
|
+
...encoded,
|
6744
|
+
...arrayify14(assetId)
|
6745
|
+
]);
|
6746
|
+
return scriptData;
|
6747
|
+
};
|
6748
|
+
var assembleTransferToContractScript = async (params) => {
|
6749
|
+
const scriptData = formatTransferToContractScriptData(params);
|
6750
|
+
await asm.initWasm();
|
6751
|
+
const gtf2 = asm.gtf(16, 0, asm.GTFArgs.ScriptData);
|
6752
|
+
const addi2 = asm.addi(17, 16, 32);
|
6753
|
+
const lw2 = asm.lw(18, 17, 0);
|
5857
6754
|
const addi22 = asm.addi(19, 17, 8);
|
5858
6755
|
const tr2 = asm.tr(16, 18, 19);
|
5859
6756
|
const ret2 = asm.ret(1);
|
@@ -5905,7 +6802,7 @@ var Account = class extends AbstractAccount {
|
|
5905
6802
|
*/
|
5906
6803
|
get provider() {
|
5907
6804
|
if (!this._provider) {
|
5908
|
-
throw new
|
6805
|
+
throw new FuelError18(ErrorCode16.MISSING_PROVIDER, "Provider not set");
|
5909
6806
|
}
|
5910
6807
|
return this._provider;
|
5911
6808
|
}
|
@@ -6023,7 +6920,7 @@ var Account = class extends AbstractAccount {
|
|
6023
6920
|
);
|
6024
6921
|
request.addResources(resources);
|
6025
6922
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6026
|
-
const requestToReestimate2 =
|
6923
|
+
const requestToReestimate2 = clone9(request);
|
6027
6924
|
if (addedSignatures) {
|
6028
6925
|
Array.from({ length: addedSignatures }).forEach(
|
6029
6926
|
() => requestToReestimate2.addEmptyWitness()
|
@@ -6056,13 +6953,13 @@ var Account = class extends AbstractAccount {
|
|
6056
6953
|
fundingAttempts += 1;
|
6057
6954
|
}
|
6058
6955
|
if (needsToBeFunded) {
|
6059
|
-
throw new
|
6956
|
+
throw new FuelError18(
|
6060
6957
|
ErrorCode16.NOT_ENOUGH_FUNDS,
|
6061
6958
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
6062
6959
|
);
|
6063
6960
|
}
|
6064
6961
|
request.updatePredicateGasUsed(estimatedPredicates);
|
6065
|
-
const requestToReestimate =
|
6962
|
+
const requestToReestimate = clone9(request);
|
6066
6963
|
if (addedSignatures) {
|
6067
6964
|
Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
|
6068
6965
|
}
|
@@ -6162,7 +7059,7 @@ var Account = class extends AbstractAccount {
|
|
6162
7059
|
*/
|
6163
7060
|
async transferToContract(contractId, amount, assetId, txParams = {}) {
|
6164
7061
|
if (bn19(amount).lte(0)) {
|
6165
|
-
throw new
|
7062
|
+
throw new FuelError18(
|
6166
7063
|
ErrorCode16.INVALID_TRANSFER_AMOUNT,
|
6167
7064
|
"Transfer amount must be a positive number."
|
6168
7065
|
);
|
@@ -6202,14 +7099,14 @@ var Account = class extends AbstractAccount {
|
|
6202
7099
|
*/
|
6203
7100
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
6204
7101
|
const recipientAddress = Address3.fromAddressOrString(recipient);
|
6205
|
-
const recipientDataArray =
|
7102
|
+
const recipientDataArray = arrayify15(
|
6206
7103
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
6207
7104
|
);
|
6208
|
-
const amountDataArray =
|
7105
|
+
const amountDataArray = arrayify15(
|
6209
7106
|
"0x".concat(bn19(amount).toHex().substring(2).padStart(16, "0"))
|
6210
7107
|
);
|
6211
7108
|
const script = new Uint8Array([
|
6212
|
-
...
|
7109
|
+
...arrayify15(withdrawScript.bytes),
|
6213
7110
|
...recipientDataArray,
|
6214
7111
|
...amountDataArray
|
6215
7112
|
]);
|
@@ -6238,7 +7135,7 @@ var Account = class extends AbstractAccount {
|
|
6238
7135
|
* @returns A promise that resolves to the transaction cost object.
|
6239
7136
|
*/
|
6240
7137
|
async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
|
6241
|
-
const txRequestClone =
|
7138
|
+
const txRequestClone = clone9(transactionRequestify(transactionRequestLike));
|
6242
7139
|
const baseAssetId = this.provider.getBaseAssetId();
|
6243
7140
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
6244
7141
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
@@ -6289,7 +7186,7 @@ var Account = class extends AbstractAccount {
|
|
6289
7186
|
*/
|
6290
7187
|
async signMessage(message) {
|
6291
7188
|
if (!this._connector) {
|
6292
|
-
throw new
|
7189
|
+
throw new FuelError18(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
6293
7190
|
}
|
6294
7191
|
return this._connector.signMessage(this.address.toString(), message);
|
6295
7192
|
}
|
@@ -6301,7 +7198,7 @@ var Account = class extends AbstractAccount {
|
|
6301
7198
|
*/
|
6302
7199
|
async signTransaction(transactionRequestLike) {
|
6303
7200
|
if (!this._connector) {
|
6304
|
-
throw new
|
7201
|
+
throw new FuelError18(
|
6305
7202
|
ErrorCode16.MISSING_CONNECTOR,
|
6306
7203
|
"A connector is required to sign transactions."
|
6307
7204
|
);
|
@@ -6351,7 +7248,7 @@ var Account = class extends AbstractAccount {
|
|
6351
7248
|
*/
|
6352
7249
|
generateFakeResources(coins) {
|
6353
7250
|
return coins.map((coin) => ({
|
6354
|
-
id:
|
7251
|
+
id: hexlify16(randomBytes2(UTXO_ID_LEN3)),
|
6355
7252
|
owner: this.address,
|
6356
7253
|
blockCreated: bn19(1),
|
6357
7254
|
txCreatedIdx: bn19(1),
|
@@ -6361,7 +7258,7 @@ var Account = class extends AbstractAccount {
|
|
6361
7258
|
/** @hidden * */
|
6362
7259
|
validateTransferAmount(amount) {
|
6363
7260
|
if (bn19(amount).lte(0)) {
|
6364
|
-
throw new
|
7261
|
+
throw new FuelError18(
|
6365
7262
|
ErrorCode16.INVALID_TRANSFER_AMOUNT,
|
6366
7263
|
"Transfer amount must be a positive number."
|
6367
7264
|
);
|
@@ -6391,7 +7288,7 @@ var Account = class extends AbstractAccount {
|
|
6391
7288
|
if (!isDefined3(setGasLimit)) {
|
6392
7289
|
request.gasLimit = gasUsed;
|
6393
7290
|
} else if (gasUsed.gt(setGasLimit)) {
|
6394
|
-
throw new
|
7291
|
+
throw new FuelError18(
|
6395
7292
|
ErrorCode16.GAS_LIMIT_TOO_LOW,
|
6396
7293
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
6397
7294
|
);
|
@@ -6399,7 +7296,7 @@ var Account = class extends AbstractAccount {
|
|
6399
7296
|
if (!isDefined3(setMaxFee)) {
|
6400
7297
|
request.maxFee = maxFee;
|
6401
7298
|
} else if (maxFee.gt(setMaxFee)) {
|
6402
|
-
throw new
|
7299
|
+
throw new FuelError18(
|
6403
7300
|
ErrorCode16.MAX_FEE_TOO_LOW,
|
6404
7301
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
6405
7302
|
);
|
@@ -6410,14 +7307,14 @@ var Account = class extends AbstractAccount {
|
|
6410
7307
|
|
6411
7308
|
// src/wallet/base-wallet-unlocked.ts
|
6412
7309
|
import { hashMessage } from "@fuel-ts/hasher";
|
6413
|
-
import { hexlify as
|
7310
|
+
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
6414
7311
|
|
6415
7312
|
// src/signer/signer.ts
|
6416
7313
|
import { Address as Address4 } from "@fuel-ts/address";
|
6417
7314
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
6418
|
-
import { hash } from "@fuel-ts/hasher";
|
7315
|
+
import { hash as hash2 } from "@fuel-ts/hasher";
|
6419
7316
|
import { toBytes } from "@fuel-ts/math";
|
6420
|
-
import { hexlify as
|
7317
|
+
import { hexlify as hexlify17, concat as concat3, arrayify as arrayify16 } from "@fuel-ts/utils";
|
6421
7318
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
6422
7319
|
var Signer = class {
|
6423
7320
|
address;
|
@@ -6437,9 +7334,9 @@ var Signer = class {
|
|
6437
7334
|
}
|
6438
7335
|
}
|
6439
7336
|
const privateKeyBytes = toBytes(privateKey, 32);
|
6440
|
-
this.privateKey =
|
6441
|
-
this.publicKey =
|
6442
|
-
this.compressedPublicKey =
|
7337
|
+
this.privateKey = hexlify17(privateKeyBytes);
|
7338
|
+
this.publicKey = hexlify17(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
7339
|
+
this.compressedPublicKey = hexlify17(secp256k1.getPublicKey(privateKeyBytes, true));
|
6443
7340
|
this.address = Address4.fromPublicKey(this.publicKey);
|
6444
7341
|
}
|
6445
7342
|
/**
|
@@ -6453,11 +7350,11 @@ var Signer = class {
|
|
6453
7350
|
* @returns hashed signature
|
6454
7351
|
*/
|
6455
7352
|
sign(data) {
|
6456
|
-
const signature = secp256k1.sign(
|
7353
|
+
const signature = secp256k1.sign(arrayify16(data), arrayify16(this.privateKey));
|
6457
7354
|
const r = toBytes(`0x${signature.r.toString(16)}`, 32);
|
6458
7355
|
const s = toBytes(`0x${signature.s.toString(16)}`, 32);
|
6459
7356
|
s[0] |= (signature.recovery || 0) << 7;
|
6460
|
-
return
|
7357
|
+
return hexlify17(concat3([r, s]));
|
6461
7358
|
}
|
6462
7359
|
/**
|
6463
7360
|
* Add point on the current elliptic curve
|
@@ -6466,8 +7363,8 @@ var Signer = class {
|
|
6466
7363
|
* @returns compressed point on the curve
|
6467
7364
|
*/
|
6468
7365
|
addPoint(point) {
|
6469
|
-
const p0 = secp256k1.ProjectivePoint.fromHex(
|
6470
|
-
const p1 = secp256k1.ProjectivePoint.fromHex(
|
7366
|
+
const p0 = secp256k1.ProjectivePoint.fromHex(arrayify16(this.compressedPublicKey));
|
7367
|
+
const p1 = secp256k1.ProjectivePoint.fromHex(arrayify16(point));
|
6471
7368
|
const result = p0.add(p1);
|
6472
7369
|
return `0x${result.toHex(true)}`;
|
6473
7370
|
}
|
@@ -6479,16 +7376,16 @@ var Signer = class {
|
|
6479
7376
|
* @returns public key from signature from the
|
6480
7377
|
*/
|
6481
7378
|
static recoverPublicKey(data, signature) {
|
6482
|
-
const signedMessageBytes =
|
7379
|
+
const signedMessageBytes = arrayify16(signature);
|
6483
7380
|
const r = signedMessageBytes.slice(0, 32);
|
6484
7381
|
const s = signedMessageBytes.slice(32, 64);
|
6485
7382
|
const recoveryParam = (s[0] & 128) >> 7;
|
6486
7383
|
s[0] &= 127;
|
6487
|
-
const sig = new secp256k1.Signature(BigInt(
|
7384
|
+
const sig = new secp256k1.Signature(BigInt(hexlify17(r)), BigInt(hexlify17(s))).addRecoveryBit(
|
6488
7385
|
recoveryParam
|
6489
7386
|
);
|
6490
|
-
const publicKey = sig.recoverPublicKey(
|
6491
|
-
return
|
7387
|
+
const publicKey = sig.recoverPublicKey(arrayify16(data)).toRawBytes(false).slice(1);
|
7388
|
+
return hexlify17(publicKey);
|
6492
7389
|
}
|
6493
7390
|
/**
|
6494
7391
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -6507,7 +7404,7 @@ var Signer = class {
|
|
6507
7404
|
* @returns random 32-byte hashed
|
6508
7405
|
*/
|
6509
7406
|
static generatePrivateKey(entropy) {
|
6510
|
-
return entropy ?
|
7407
|
+
return entropy ? hash2(concat3([randomBytes3(32), arrayify16(entropy)])) : randomBytes3(32);
|
6511
7408
|
}
|
6512
7409
|
/**
|
6513
7410
|
* Extended publicKey from a compact publicKey
|
@@ -6516,8 +7413,8 @@ var Signer = class {
|
|
6516
7413
|
* @returns extended publicKey
|
6517
7414
|
*/
|
6518
7415
|
static extendPublicKey(publicKey) {
|
6519
|
-
const point = secp256k1.ProjectivePoint.fromHex(
|
6520
|
-
return
|
7416
|
+
const point = secp256k1.ProjectivePoint.fromHex(arrayify16(publicKey));
|
7417
|
+
return hexlify17(point.toRawBytes(false).slice(1));
|
6521
7418
|
}
|
6522
7419
|
};
|
6523
7420
|
|
@@ -6533,8 +7430,8 @@ import {
|
|
6533
7430
|
encryptJsonWalletData,
|
6534
7431
|
randomUUID
|
6535
7432
|
} from "@fuel-ts/crypto";
|
6536
|
-
import { ErrorCode as ErrorCode17, FuelError as
|
6537
|
-
import { hexlify as
|
7433
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError19 } from "@fuel-ts/errors";
|
7434
|
+
import { hexlify as hexlify18 } from "@fuel-ts/utils";
|
6538
7435
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
6539
7436
|
var DEFAULT_KDF_PARAMS_R = 8;
|
6540
7437
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -6610,13 +7507,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
6610
7507
|
const macHashUint8Array = keccak256(data);
|
6611
7508
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
6612
7509
|
if (mac !== macHash) {
|
6613
|
-
throw new
|
7510
|
+
throw new FuelError19(
|
6614
7511
|
ErrorCode17.INVALID_PASSWORD,
|
6615
7512
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
6616
7513
|
);
|
6617
7514
|
}
|
6618
7515
|
const buffer = await decryptJsonWalletData(ciphertextBuffer, key, ivBuffer);
|
6619
|
-
const privateKey =
|
7516
|
+
const privateKey = hexlify18(buffer);
|
6620
7517
|
return privateKey;
|
6621
7518
|
}
|
6622
7519
|
|
@@ -6661,7 +7558,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6661
7558
|
*/
|
6662
7559
|
async signMessage(message) {
|
6663
7560
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
6664
|
-
return
|
7561
|
+
return hexlify19(signedMessage);
|
6665
7562
|
}
|
6666
7563
|
/**
|
6667
7564
|
* Signs a transaction with the wallet's private key.
|
@@ -6674,7 +7571,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
6674
7571
|
const chainId = this.provider.getChainId();
|
6675
7572
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
6676
7573
|
const signature = await this.signer().sign(hashedTransaction);
|
6677
|
-
return
|
7574
|
+
return hexlify19(signature);
|
6678
7575
|
}
|
6679
7576
|
/**
|
6680
7577
|
* Populates a transaction with the witnesses signature.
|
@@ -6741,16 +7638,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
6741
7638
|
|
6742
7639
|
// src/hdwallet/hdwallet.ts
|
6743
7640
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
6744
|
-
import { ErrorCode as ErrorCode20, FuelError as
|
7641
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError22 } from "@fuel-ts/errors";
|
6745
7642
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
6746
7643
|
import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
6747
|
-
import { arrayify as
|
7644
|
+
import { arrayify as arrayify19, hexlify as hexlify21, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
6748
7645
|
|
6749
7646
|
// src/mnemonic/mnemonic.ts
|
6750
7647
|
import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
6751
|
-
import { ErrorCode as ErrorCode19, FuelError as
|
7648
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
|
6752
7649
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
6753
|
-
import { arrayify as
|
7650
|
+
import { arrayify as arrayify18, hexlify as hexlify20, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
6754
7651
|
|
6755
7652
|
// src/wordlists/words/english.ts
|
6756
7653
|
var english = [
|
@@ -8811,9 +9708,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
8811
9708
|
})(Language || {});
|
8812
9709
|
|
8813
9710
|
// src/mnemonic/utils.ts
|
8814
|
-
import { ErrorCode as ErrorCode18, FuelError as
|
9711
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
|
8815
9712
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
8816
|
-
import { arrayify as
|
9713
|
+
import { arrayify as arrayify17 } from "@fuel-ts/utils";
|
8817
9714
|
function getLowerMask(bits) {
|
8818
9715
|
return (1 << bits) - 1;
|
8819
9716
|
}
|
@@ -8848,19 +9745,19 @@ function entropyToMnemonicIndices(entropy) {
|
|
8848
9745
|
}
|
8849
9746
|
}
|
8850
9747
|
const checksumBits = entropy.length / 4;
|
8851
|
-
const checksum =
|
9748
|
+
const checksum = arrayify17(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
8852
9749
|
indices[indices.length - 1] <<= checksumBits;
|
8853
9750
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
8854
9751
|
return indices;
|
8855
9752
|
}
|
8856
9753
|
function mnemonicWordsToEntropy(words, wordlist) {
|
8857
9754
|
const size = Math.ceil(11 * words.length / 8);
|
8858
|
-
const entropy =
|
9755
|
+
const entropy = arrayify17(new Uint8Array(size));
|
8859
9756
|
let offset = 0;
|
8860
9757
|
for (let i = 0; i < words.length; i += 1) {
|
8861
9758
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
8862
9759
|
if (index === -1) {
|
8863
|
-
throw new
|
9760
|
+
throw new FuelError20(
|
8864
9761
|
ErrorCode18.INVALID_MNEMONIC,
|
8865
9762
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
8866
9763
|
);
|
@@ -8875,9 +9772,9 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
8875
9772
|
const entropyBits = 32 * words.length / 3;
|
8876
9773
|
const checksumBits = words.length / 3;
|
8877
9774
|
const checksumMask = getUpperMask(checksumBits);
|
8878
|
-
const checksum =
|
9775
|
+
const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
8879
9776
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
8880
|
-
throw new
|
9777
|
+
throw new FuelError20(
|
8881
9778
|
ErrorCode18.INVALID_CHECKSUM,
|
8882
9779
|
"Checksum validation failed for the provided mnemonic."
|
8883
9780
|
);
|
@@ -8892,7 +9789,7 @@ var TestnetPRV = "0x04358394";
|
|
8892
9789
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
8893
9790
|
function assertWordList(wordlist) {
|
8894
9791
|
if (wordlist.length !== 2048) {
|
8895
|
-
throw new
|
9792
|
+
throw new FuelError21(
|
8896
9793
|
ErrorCode19.INVALID_WORD_LIST,
|
8897
9794
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
8898
9795
|
);
|
@@ -8900,7 +9797,7 @@ function assertWordList(wordlist) {
|
|
8900
9797
|
}
|
8901
9798
|
function assertEntropy(entropy) {
|
8902
9799
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
8903
|
-
throw new
|
9800
|
+
throw new FuelError21(
|
8904
9801
|
ErrorCode19.INVALID_ENTROPY,
|
8905
9802
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
8906
9803
|
);
|
@@ -8911,7 +9808,7 @@ function assertMnemonic(words) {
|
|
8911
9808
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
8912
9809
|
", "
|
8913
9810
|
)}] words, but got ${words.length}.`;
|
8914
|
-
throw new
|
9811
|
+
throw new FuelError21(ErrorCode19.INVALID_MNEMONIC, errorMsg);
|
8915
9812
|
}
|
8916
9813
|
}
|
8917
9814
|
var Mnemonic = class {
|
@@ -8950,7 +9847,7 @@ var Mnemonic = class {
|
|
8950
9847
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
8951
9848
|
const words = getWords(phrase);
|
8952
9849
|
assertMnemonic(words);
|
8953
|
-
return
|
9850
|
+
return hexlify20(mnemonicWordsToEntropy(words, wordlist));
|
8954
9851
|
}
|
8955
9852
|
/**
|
8956
9853
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -8958,7 +9855,7 @@ var Mnemonic = class {
|
|
8958
9855
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
8959
9856
|
*/
|
8960
9857
|
static entropyToMnemonic(entropy, wordlist = english) {
|
8961
|
-
const entropyBytes =
|
9858
|
+
const entropyBytes = arrayify18(entropy);
|
8962
9859
|
assertWordList(wordlist);
|
8963
9860
|
assertEntropy(entropyBytes);
|
8964
9861
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -9027,14 +9924,14 @@ var Mnemonic = class {
|
|
9027
9924
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9028
9925
|
*/
|
9029
9926
|
static masterKeysFromSeed(seed) {
|
9030
|
-
const seedArray =
|
9927
|
+
const seedArray = arrayify18(seed);
|
9031
9928
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
9032
|
-
throw new
|
9929
|
+
throw new FuelError21(
|
9033
9930
|
ErrorCode19.INVALID_SEED,
|
9034
9931
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
9035
9932
|
);
|
9036
9933
|
}
|
9037
|
-
return
|
9934
|
+
return arrayify18(computeHmac("sha512", MasterSecret, seedArray));
|
9038
9935
|
}
|
9039
9936
|
/**
|
9040
9937
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -9045,7 +9942,7 @@ var Mnemonic = class {
|
|
9045
9942
|
*/
|
9046
9943
|
static seedToExtendedKey(seed, testnet = false) {
|
9047
9944
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
9048
|
-
const prefix =
|
9945
|
+
const prefix = arrayify18(testnet ? TestnetPRV : MainnetPRV);
|
9049
9946
|
const depth = "0x00";
|
9050
9947
|
const fingerprint = "0x00000000";
|
9051
9948
|
const index = "0x00000000";
|
@@ -9075,7 +9972,7 @@ var Mnemonic = class {
|
|
9075
9972
|
* @returns A randomly generated mnemonic
|
9076
9973
|
*/
|
9077
9974
|
static generate(size = 32, extraEntropy = "") {
|
9078
|
-
const entropy = extraEntropy ? sha2563(concat4([randomBytes5(size),
|
9975
|
+
const entropy = extraEntropy ? sha2563(concat4([randomBytes5(size), arrayify18(extraEntropy)])) : randomBytes5(size);
|
9079
9976
|
return Mnemonic.entropyToMnemonic(entropy);
|
9080
9977
|
}
|
9081
9978
|
};
|
@@ -9083,10 +9980,10 @@ var mnemonic_default = Mnemonic;
|
|
9083
9980
|
|
9084
9981
|
// src/hdwallet/hdwallet.ts
|
9085
9982
|
var HARDENED_INDEX = 2147483648;
|
9086
|
-
var MainnetPRV2 =
|
9087
|
-
var MainnetPUB =
|
9088
|
-
var TestnetPRV2 =
|
9089
|
-
var TestnetPUB =
|
9983
|
+
var MainnetPRV2 = hexlify21("0x0488ade4");
|
9984
|
+
var MainnetPUB = hexlify21("0x0488b21e");
|
9985
|
+
var TestnetPRV2 = hexlify21("0x04358394");
|
9986
|
+
var TestnetPUB = hexlify21("0x043587cf");
|
9090
9987
|
function base58check(data) {
|
9091
9988
|
return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
9092
9989
|
}
|
@@ -9097,17 +9994,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
9097
9994
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
9098
9995
|
}
|
9099
9996
|
function isPublicExtendedKey(extendedKey) {
|
9100
|
-
return [MainnetPUB, TestnetPUB].includes(
|
9997
|
+
return [MainnetPUB, TestnetPUB].includes(hexlify21(extendedKey.slice(0, 4)));
|
9101
9998
|
}
|
9102
9999
|
function isValidExtendedKey(extendedKey) {
|
9103
10000
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
9104
|
-
|
10001
|
+
hexlify21(extendedKey.slice(0, 4))
|
9105
10002
|
);
|
9106
10003
|
}
|
9107
10004
|
function parsePath(path, depth = 0) {
|
9108
10005
|
const components = path.split("/");
|
9109
10006
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
9110
|
-
throw new
|
10007
|
+
throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path}`);
|
9111
10008
|
}
|
9112
10009
|
if (components[0] === "m") {
|
9113
10010
|
components.shift();
|
@@ -9119,8 +10016,8 @@ function parsePath(path, depth = 0) {
|
|
9119
10016
|
var HDWallet = class {
|
9120
10017
|
depth = 0;
|
9121
10018
|
index = 0;
|
9122
|
-
fingerprint =
|
9123
|
-
parentFingerprint =
|
10019
|
+
fingerprint = hexlify21("0x00000000");
|
10020
|
+
parentFingerprint = hexlify21("0x00000000");
|
9124
10021
|
privateKey;
|
9125
10022
|
publicKey;
|
9126
10023
|
chainCode;
|
@@ -9132,16 +10029,16 @@ var HDWallet = class {
|
|
9132
10029
|
constructor(config) {
|
9133
10030
|
if (config.privateKey) {
|
9134
10031
|
const signer = new Signer(config.privateKey);
|
9135
|
-
this.publicKey =
|
9136
|
-
this.privateKey =
|
10032
|
+
this.publicKey = hexlify21(signer.compressedPublicKey);
|
10033
|
+
this.privateKey = hexlify21(config.privateKey);
|
9137
10034
|
} else {
|
9138
10035
|
if (!config.publicKey) {
|
9139
|
-
throw new
|
10036
|
+
throw new FuelError22(
|
9140
10037
|
ErrorCode20.HD_WALLET_ERROR,
|
9141
10038
|
"Both public and private Key cannot be missing. At least one should be provided."
|
9142
10039
|
);
|
9143
10040
|
}
|
9144
|
-
this.publicKey =
|
10041
|
+
this.publicKey = hexlify21(config.publicKey);
|
9145
10042
|
}
|
9146
10043
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
9147
10044
|
this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
|
@@ -9160,23 +10057,23 @@ var HDWallet = class {
|
|
9160
10057
|
* @returns A new instance of HDWallet on the derived index
|
9161
10058
|
*/
|
9162
10059
|
deriveIndex(index) {
|
9163
|
-
const privateKey = this.privateKey &&
|
9164
|
-
const publicKey =
|
9165
|
-
const chainCode =
|
10060
|
+
const privateKey = this.privateKey && arrayify19(this.privateKey);
|
10061
|
+
const publicKey = arrayify19(this.publicKey);
|
10062
|
+
const chainCode = arrayify19(this.chainCode);
|
9166
10063
|
const data = new Uint8Array(37);
|
9167
10064
|
if (index & HARDENED_INDEX) {
|
9168
10065
|
if (!privateKey) {
|
9169
|
-
throw new
|
10066
|
+
throw new FuelError22(
|
9170
10067
|
ErrorCode20.HD_WALLET_ERROR,
|
9171
10068
|
"Cannot derive a hardened index without a private Key."
|
9172
10069
|
);
|
9173
10070
|
}
|
9174
10071
|
data.set(privateKey, 1);
|
9175
10072
|
} else {
|
9176
|
-
data.set(
|
10073
|
+
data.set(arrayify19(this.publicKey));
|
9177
10074
|
}
|
9178
10075
|
data.set(toBytes2(index, 4), 33);
|
9179
|
-
const bytes =
|
10076
|
+
const bytes = arrayify19(computeHmac2("sha512", chainCode, data));
|
9180
10077
|
const IL = bytes.slice(0, 32);
|
9181
10078
|
const IR = bytes.slice(32);
|
9182
10079
|
if (privateKey) {
|
@@ -9190,7 +10087,7 @@ var HDWallet = class {
|
|
9190
10087
|
parentFingerprint: this.fingerprint
|
9191
10088
|
});
|
9192
10089
|
}
|
9193
|
-
const signer = new Signer(
|
10090
|
+
const signer = new Signer(hexlify21(IL));
|
9194
10091
|
const Ki = signer.addPoint(publicKey);
|
9195
10092
|
return new HDWallet({
|
9196
10093
|
publicKey: Ki,
|
@@ -9219,18 +10116,18 @@ var HDWallet = class {
|
|
9219
10116
|
*/
|
9220
10117
|
toExtendedKey(isPublic = false, testnet = false) {
|
9221
10118
|
if (this.depth >= 256) {
|
9222
|
-
throw new
|
10119
|
+
throw new FuelError22(
|
9223
10120
|
ErrorCode20.HD_WALLET_ERROR,
|
9224
10121
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
9225
10122
|
);
|
9226
10123
|
}
|
9227
10124
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
9228
|
-
const depth =
|
10125
|
+
const depth = hexlify21(Uint8Array.from([this.depth]));
|
9229
10126
|
const parentFingerprint = this.parentFingerprint;
|
9230
10127
|
const index = toHex(this.index, 4);
|
9231
10128
|
const chainCode = this.chainCode;
|
9232
10129
|
const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
|
9233
|
-
const extendedKey =
|
10130
|
+
const extendedKey = arrayify19(concat5([prefix, depth, parentFingerprint, index, chainCode, key]));
|
9234
10131
|
return base58check(extendedKey);
|
9235
10132
|
}
|
9236
10133
|
/**
|
@@ -9242,34 +10139,34 @@ var HDWallet = class {
|
|
9242
10139
|
static fromSeed(seed) {
|
9243
10140
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
9244
10141
|
return new HDWallet({
|
9245
|
-
chainCode:
|
9246
|
-
privateKey:
|
10142
|
+
chainCode: arrayify19(masterKey.slice(32)),
|
10143
|
+
privateKey: arrayify19(masterKey.slice(0, 32))
|
9247
10144
|
});
|
9248
10145
|
}
|
9249
10146
|
static fromExtendedKey(extendedKey) {
|
9250
|
-
const decoded =
|
9251
|
-
const bytes =
|
10147
|
+
const decoded = hexlify21(toBytes2(decodeBase58(extendedKey)));
|
10148
|
+
const bytes = arrayify19(decoded);
|
9252
10149
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
9253
10150
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
9254
|
-
throw new
|
10151
|
+
throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
9255
10152
|
}
|
9256
10153
|
if (!validChecksum) {
|
9257
|
-
throw new
|
10154
|
+
throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
9258
10155
|
}
|
9259
10156
|
const depth = bytes[4];
|
9260
|
-
const parentFingerprint =
|
9261
|
-
const index = parseInt(
|
9262
|
-
const chainCode =
|
10157
|
+
const parentFingerprint = hexlify21(bytes.slice(5, 9));
|
10158
|
+
const index = parseInt(hexlify21(bytes.slice(9, 13)).substring(2), 16);
|
10159
|
+
const chainCode = hexlify21(bytes.slice(13, 45));
|
9263
10160
|
const key = bytes.slice(45, 78);
|
9264
10161
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
9265
|
-
throw new
|
10162
|
+
throw new FuelError22(
|
9266
10163
|
ErrorCode20.HD_WALLET_ERROR,
|
9267
10164
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
9268
10165
|
);
|
9269
10166
|
}
|
9270
10167
|
if (isPublicExtendedKey(bytes)) {
|
9271
10168
|
if (key[0] !== 3) {
|
9272
|
-
throw new
|
10169
|
+
throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
|
9273
10170
|
}
|
9274
10171
|
return new HDWallet({
|
9275
10172
|
publicKey: key,
|
@@ -9280,7 +10177,7 @@ var HDWallet = class {
|
|
9280
10177
|
});
|
9281
10178
|
}
|
9282
10179
|
if (key[0] !== 0) {
|
9283
|
-
throw new
|
10180
|
+
throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
|
9284
10181
|
}
|
9285
10182
|
return new HDWallet({
|
9286
10183
|
privateKey: key.slice(1),
|
@@ -9448,7 +10345,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
9448
10345
|
// src/wallet-manager/wallet-manager.ts
|
9449
10346
|
import { Address as Address8 } from "@fuel-ts/address";
|
9450
10347
|
import { encrypt, decrypt } from "@fuel-ts/crypto";
|
9451
|
-
import { ErrorCode as ErrorCode23, FuelError as
|
10348
|
+
import { ErrorCode as ErrorCode23, FuelError as FuelError25 } from "@fuel-ts/errors";
|
9452
10349
|
import { EventEmitter } from "events";
|
9453
10350
|
|
9454
10351
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -9471,7 +10368,7 @@ var MemoryStorage = class {
|
|
9471
10368
|
|
9472
10369
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
9473
10370
|
import { Address as Address6 } from "@fuel-ts/address";
|
9474
|
-
import { ErrorCode as ErrorCode21, FuelError as
|
10371
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError23 } from "@fuel-ts/errors";
|
9475
10372
|
var _secret;
|
9476
10373
|
var MnemonicVault = class {
|
9477
10374
|
constructor(options) {
|
@@ -9527,7 +10424,7 @@ var MnemonicVault = class {
|
|
9527
10424
|
}
|
9528
10425
|
numberOfAccounts += 1;
|
9529
10426
|
} while (numberOfAccounts < this.numberOfAccounts);
|
9530
|
-
throw new
|
10427
|
+
throw new FuelError23(
|
9531
10428
|
ErrorCode21.WALLET_MANAGER_ERROR,
|
9532
10429
|
`Account with address '${address}' not found in derived wallets.`
|
9533
10430
|
);
|
@@ -9542,7 +10439,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
9542
10439
|
|
9543
10440
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
9544
10441
|
import { Address as Address7 } from "@fuel-ts/address";
|
9545
|
-
import { ErrorCode as ErrorCode22, FuelError as
|
10442
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError24 } from "@fuel-ts/errors";
|
9546
10443
|
var _privateKeys;
|
9547
10444
|
var PrivateKeyVault = class {
|
9548
10445
|
/**
|
@@ -9583,7 +10480,7 @@ var PrivateKeyVault = class {
|
|
9583
10480
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
9584
10481
|
);
|
9585
10482
|
if (!privateKey) {
|
9586
|
-
throw new
|
10483
|
+
throw new FuelError24(
|
9587
10484
|
ErrorCode22.WALLET_MANAGER_ERROR,
|
9588
10485
|
`No private key found for address '${address}'.`
|
9589
10486
|
);
|
@@ -9608,7 +10505,7 @@ var ERROR_MESSAGES = {
|
|
9608
10505
|
};
|
9609
10506
|
function assert(condition, message) {
|
9610
10507
|
if (!condition) {
|
9611
|
-
throw new
|
10508
|
+
throw new FuelError25(ErrorCode23.WALLET_MANAGER_ERROR, message);
|
9612
10509
|
}
|
9613
10510
|
}
|
9614
10511
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -9834,25 +10731,25 @@ deserializeVaults_fn = function(vaults) {
|
|
9834
10731
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
9835
10732
|
|
9836
10733
|
// src/wallet-manager/types.ts
|
9837
|
-
import { ErrorCode as ErrorCode24, FuelError as
|
10734
|
+
import { ErrorCode as ErrorCode24, FuelError as FuelError26 } from "@fuel-ts/errors";
|
9838
10735
|
var Vault = class {
|
9839
10736
|
constructor(_options) {
|
9840
|
-
throw new
|
10737
|
+
throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9841
10738
|
}
|
9842
10739
|
serialize() {
|
9843
|
-
throw new
|
10740
|
+
throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9844
10741
|
}
|
9845
10742
|
getAccounts() {
|
9846
|
-
throw new
|
10743
|
+
throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9847
10744
|
}
|
9848
10745
|
addAccount() {
|
9849
|
-
throw new
|
10746
|
+
throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9850
10747
|
}
|
9851
10748
|
exportAccount(_address) {
|
9852
|
-
throw new
|
10749
|
+
throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9853
10750
|
}
|
9854
10751
|
getWallet(_address) {
|
9855
|
-
throw new
|
10752
|
+
throw new FuelError26(ErrorCode24.NOT_IMPLEMENTED, "Not implemented.");
|
9856
10753
|
}
|
9857
10754
|
};
|
9858
10755
|
__publicField(Vault, "type");
|
@@ -9862,19 +10759,19 @@ var StorageAbstract = class {
|
|
9862
10759
|
// src/predicate/predicate.ts
|
9863
10760
|
import { Interface as Interface4 } from "@fuel-ts/abi-coder";
|
9864
10761
|
import { Address as Address9 } from "@fuel-ts/address";
|
9865
|
-
import { ErrorCode as ErrorCode25, FuelError as
|
9866
|
-
import { arrayify as
|
10762
|
+
import { ErrorCode as ErrorCode25, FuelError as FuelError27 } from "@fuel-ts/errors";
|
10763
|
+
import { arrayify as arrayify21, hexlify as hexlify23 } from "@fuel-ts/utils";
|
9867
10764
|
|
9868
10765
|
// src/predicate/utils/getPredicateRoot.ts
|
9869
|
-
import { hash as
|
10766
|
+
import { hash as hash3 } from "@fuel-ts/hasher";
|
9870
10767
|
import { calcRoot } from "@fuel-ts/merkle";
|
9871
|
-
import { chunkAndPadBytes, hexlify as
|
10768
|
+
import { chunkAndPadBytes, hexlify as hexlify22, concat as concat6, arrayify as arrayify20 } from "@fuel-ts/utils";
|
9872
10769
|
var getPredicateRoot = (bytecode) => {
|
9873
10770
|
const chunkSize = 16 * 1024;
|
9874
|
-
const bytes =
|
10771
|
+
const bytes = arrayify20(bytecode);
|
9875
10772
|
const chunks = chunkAndPadBytes(bytes, chunkSize);
|
9876
|
-
const codeRoot = calcRoot(chunks.map((c) =>
|
9877
|
-
const predicateRoot =
|
10773
|
+
const codeRoot = calcRoot(chunks.map((c) => hexlify22(c)));
|
10774
|
+
const predicateRoot = hash3(concat6(["0x4655454C", codeRoot]));
|
9878
10775
|
return predicateRoot;
|
9879
10776
|
};
|
9880
10777
|
|
@@ -9926,8 +10823,8 @@ var Predicate = class extends Account {
|
|
9926
10823
|
}
|
9927
10824
|
request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
9928
10825
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
9929
|
-
input.predicate =
|
9930
|
-
input.predicateData =
|
10826
|
+
input.predicate = hexlify23(this.bytes);
|
10827
|
+
input.predicateData = hexlify23(this.getPredicateData());
|
9931
10828
|
input.witnessIndex = 0;
|
9932
10829
|
}
|
9933
10830
|
});
|
@@ -9969,12 +10866,12 @@ var Predicate = class extends Account {
|
|
9969
10866
|
* @returns An object containing the new predicate bytes and interface.
|
9970
10867
|
*/
|
9971
10868
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
9972
|
-
let predicateBytes =
|
10869
|
+
let predicateBytes = arrayify21(bytes);
|
9973
10870
|
let abiInterface;
|
9974
10871
|
if (jsonAbi) {
|
9975
10872
|
abiInterface = new Interface4(jsonAbi);
|
9976
10873
|
if (abiInterface.functions.main === void 0) {
|
9977
|
-
throw new
|
10874
|
+
throw new FuelError27(
|
9978
10875
|
ErrorCode25.ABI_MAIN_METHOD_MISSING,
|
9979
10876
|
'Cannot use ABI without "main" function.'
|
9980
10877
|
);
|
@@ -10007,8 +10904,8 @@ var Predicate = class extends Account {
|
|
10007
10904
|
);
|
10008
10905
|
return resources.map((resource) => ({
|
10009
10906
|
...resource,
|
10010
|
-
predicate:
|
10011
|
-
predicateData:
|
10907
|
+
predicate: hexlify23(this.bytes),
|
10908
|
+
predicateData: hexlify23(this.getPredicateData())
|
10012
10909
|
}));
|
10013
10910
|
}
|
10014
10911
|
/**
|
@@ -10020,8 +10917,8 @@ var Predicate = class extends Account {
|
|
10020
10917
|
generateFakeResources(coins) {
|
10021
10918
|
return super.generateFakeResources(coins).map((coin) => ({
|
10022
10919
|
...coin,
|
10023
|
-
predicate:
|
10024
|
-
predicateData:
|
10920
|
+
predicate: hexlify23(this.bytes),
|
10921
|
+
predicateData: hexlify23(this.getPredicateData())
|
10025
10922
|
}));
|
10026
10923
|
}
|
10027
10924
|
/**
|
@@ -10036,20 +10933,20 @@ var Predicate = class extends Account {
|
|
10036
10933
|
const mutatedBytes = bytes;
|
10037
10934
|
try {
|
10038
10935
|
if (!abiInterface) {
|
10039
|
-
throw new
|
10936
|
+
throw new FuelError27(
|
10040
10937
|
ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
|
10041
10938
|
"Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
|
10042
10939
|
);
|
10043
10940
|
}
|
10044
10941
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
10045
|
-
throw new
|
10942
|
+
throw new FuelError27(
|
10046
10943
|
ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
|
10047
10944
|
"Predicate has no configurable constants to be set"
|
10048
10945
|
);
|
10049
10946
|
}
|
10050
10947
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
10051
10948
|
if (!abiInterface?.configurables[key]) {
|
10052
|
-
throw new
|
10949
|
+
throw new FuelError27(
|
10053
10950
|
ErrorCode25.CONFIGURABLE_NOT_FOUND,
|
10054
10951
|
`No configurable constant named '${key}' found in the Predicate`
|
10055
10952
|
);
|
@@ -10059,7 +10956,7 @@ var Predicate = class extends Account {
|
|
10059
10956
|
mutatedBytes.set(encoded, offset);
|
10060
10957
|
});
|
10061
10958
|
} catch (err) {
|
10062
|
-
throw new
|
10959
|
+
throw new FuelError27(
|
10063
10960
|
ErrorCode25.INVALID_CONFIGURABLE_CONSTANTS,
|
10064
10961
|
`Error setting configurable constants: ${err.message}.`
|
10065
10962
|
);
|
@@ -10091,10 +10988,10 @@ var Predicate = class extends Account {
|
|
10091
10988
|
};
|
10092
10989
|
|
10093
10990
|
// src/connectors/fuel.ts
|
10094
|
-
import { ErrorCode as ErrorCode26, FuelError as
|
10991
|
+
import { ErrorCode as ErrorCode26, FuelError as FuelError30 } from "@fuel-ts/errors";
|
10095
10992
|
|
10096
10993
|
// src/connectors/fuel-connector.ts
|
10097
|
-
import { FuelError as
|
10994
|
+
import { FuelError as FuelError28 } from "@fuel-ts/errors";
|
10098
10995
|
import { EventEmitter as EventEmitter2 } from "events";
|
10099
10996
|
|
10100
10997
|
// src/connectors/types/connector-types.ts
|
@@ -10168,7 +11065,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10168
11065
|
* @returns Always true.
|
10169
11066
|
*/
|
10170
11067
|
async ping() {
|
10171
|
-
throw new
|
11068
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10172
11069
|
}
|
10173
11070
|
/**
|
10174
11071
|
* Should return the current version of the connector
|
@@ -10177,7 +11074,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10177
11074
|
* @returns boolean - connection status.
|
10178
11075
|
*/
|
10179
11076
|
async version() {
|
10180
|
-
throw new
|
11077
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10181
11078
|
}
|
10182
11079
|
/**
|
10183
11080
|
* Should return true if the connector is connected
|
@@ -10186,7 +11083,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10186
11083
|
* @returns The connection status.
|
10187
11084
|
*/
|
10188
11085
|
async isConnected() {
|
10189
|
-
throw new
|
11086
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10190
11087
|
}
|
10191
11088
|
/**
|
10192
11089
|
* Should return all the accounts authorized for the
|
@@ -10195,7 +11092,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10195
11092
|
* @returns The accounts addresses strings
|
10196
11093
|
*/
|
10197
11094
|
async accounts() {
|
10198
|
-
throw new
|
11095
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10199
11096
|
}
|
10200
11097
|
/**
|
10201
11098
|
* Should start the connection process and return
|
@@ -10207,7 +11104,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10207
11104
|
* @returns boolean - connection status.
|
10208
11105
|
*/
|
10209
11106
|
async connect() {
|
10210
|
-
throw new
|
11107
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10211
11108
|
}
|
10212
11109
|
/**
|
10213
11110
|
* Should disconnect the current connection and
|
@@ -10217,7 +11114,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10217
11114
|
* @returns The connection status.
|
10218
11115
|
*/
|
10219
11116
|
async disconnect() {
|
10220
|
-
throw new
|
11117
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10221
11118
|
}
|
10222
11119
|
/**
|
10223
11120
|
* Should start the sign message process and return
|
@@ -10229,7 +11126,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10229
11126
|
* @returns Message signature
|
10230
11127
|
*/
|
10231
11128
|
async signMessage(_address, _message) {
|
10232
|
-
throw new
|
11129
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10233
11130
|
}
|
10234
11131
|
/**
|
10235
11132
|
* Should start the sign transaction process and return
|
@@ -10241,7 +11138,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10241
11138
|
* @returns Transaction signature
|
10242
11139
|
*/
|
10243
11140
|
async signTransaction(_address, _transaction) {
|
10244
|
-
throw new
|
11141
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10245
11142
|
}
|
10246
11143
|
/**
|
10247
11144
|
* Should start the send transaction process and return
|
@@ -10257,7 +11154,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10257
11154
|
* @returns The transaction id
|
10258
11155
|
*/
|
10259
11156
|
async sendTransaction(_address, _transaction) {
|
10260
|
-
throw new
|
11157
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10261
11158
|
}
|
10262
11159
|
/**
|
10263
11160
|
* Should return the current account selected inside the connector, if the account
|
@@ -10268,7 +11165,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10268
11165
|
* @returns The current account selected otherwise null.
|
10269
11166
|
*/
|
10270
11167
|
async currentAccount() {
|
10271
|
-
throw new
|
11168
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10272
11169
|
}
|
10273
11170
|
/**
|
10274
11171
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -10282,7 +11179,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10282
11179
|
* @returns True if the asset was added successfully
|
10283
11180
|
*/
|
10284
11181
|
async addAssets(_assets) {
|
10285
|
-
throw new
|
11182
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10286
11183
|
}
|
10287
11184
|
/**
|
10288
11185
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -10296,7 +11193,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10296
11193
|
* @returns True if the asset was added successfully
|
10297
11194
|
*/
|
10298
11195
|
async addAsset(_asset) {
|
10299
|
-
throw new
|
11196
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10300
11197
|
}
|
10301
11198
|
/**
|
10302
11199
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -10304,7 +11201,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10304
11201
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
10305
11202
|
*/
|
10306
11203
|
async assets() {
|
10307
|
-
throw new
|
11204
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10308
11205
|
}
|
10309
11206
|
/**
|
10310
11207
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -10315,7 +11212,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10315
11212
|
* @returns Return true if the network was added successfully
|
10316
11213
|
*/
|
10317
11214
|
async addNetwork(_networkUrl) {
|
10318
|
-
throw new
|
11215
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10319
11216
|
}
|
10320
11217
|
/**
|
10321
11218
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -10326,7 +11223,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10326
11223
|
* @returns Return true if the network was added successfully
|
10327
11224
|
*/
|
10328
11225
|
async selectNetwork(_network) {
|
10329
|
-
throw new
|
11226
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10330
11227
|
}
|
10331
11228
|
/**
|
10332
11229
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -10334,7 +11231,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10334
11231
|
* @returns Return all the networks added to the connector.
|
10335
11232
|
*/
|
10336
11233
|
async networks() {
|
10337
|
-
throw new
|
11234
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10338
11235
|
}
|
10339
11236
|
/**
|
10340
11237
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -10342,7 +11239,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10342
11239
|
* @returns Return the current network selected inside the connector.
|
10343
11240
|
*/
|
10344
11241
|
async currentNetwork() {
|
10345
|
-
throw new
|
11242
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10346
11243
|
}
|
10347
11244
|
/**
|
10348
11245
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -10352,7 +11249,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10352
11249
|
* @returns Return true if the ABI was added successfully.
|
10353
11250
|
*/
|
10354
11251
|
async addABI(_contractId, _abi) {
|
10355
|
-
throw new
|
11252
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10356
11253
|
}
|
10357
11254
|
/**
|
10358
11255
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10361,7 +11258,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10361
11258
|
* @returns The ABI if it exists, otherwise return null.
|
10362
11259
|
*/
|
10363
11260
|
async getABI(_id) {
|
10364
|
-
throw new
|
11261
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10365
11262
|
}
|
10366
11263
|
/**
|
10367
11264
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -10370,7 +11267,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
10370
11267
|
* @returns Returns true if the abi exists or false if not.
|
10371
11268
|
*/
|
10372
11269
|
async hasABI(_id) {
|
10373
|
-
throw new
|
11270
|
+
throw new FuelError28(FuelError28.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
10374
11271
|
}
|
10375
11272
|
/**
|
10376
11273
|
* Event listener for the connector.
|
@@ -10414,7 +11311,7 @@ function dispatchFuelConnectorEvent(connector) {
|
|
10414
11311
|
}
|
10415
11312
|
|
10416
11313
|
// src/connectors/utils/promises.ts
|
10417
|
-
import { FuelError as
|
11314
|
+
import { FuelError as FuelError29 } from "@fuel-ts/errors";
|
10418
11315
|
function deferPromise() {
|
10419
11316
|
const defer = {};
|
10420
11317
|
defer.promise = new Promise((resolve, reject) => {
|
@@ -10426,7 +11323,7 @@ function deferPromise() {
|
|
10426
11323
|
async function withTimeout(promise, timeout = 1050) {
|
10427
11324
|
const timeoutPromise = new Promise((resolve, reject) => {
|
10428
11325
|
setTimeout(() => {
|
10429
|
-
reject(new
|
11326
|
+
reject(new FuelError29(FuelError29.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
10430
11327
|
}, timeout);
|
10431
11328
|
});
|
10432
11329
|
return Promise.race([timeoutPromise, promise]);
|
@@ -10460,7 +11357,7 @@ var _Fuel = class extends FuelConnector {
|
|
10460
11357
|
await this.setDefaultConnector();
|
10461
11358
|
this._targetUnsubscribe = this.setupConnectorListener();
|
10462
11359
|
} catch (error) {
|
10463
|
-
throw new
|
11360
|
+
throw new FuelError30(ErrorCode26.INVALID_PROVIDER, "Error initializing Fuel Connector");
|
10464
11361
|
}
|
10465
11362
|
}
|
10466
11363
|
async init() {
|
@@ -10526,7 +11423,7 @@ var _Fuel = class extends FuelConnector {
|
|
10526
11423
|
const hasConnector = await this.hasConnector();
|
10527
11424
|
await this.pingConnector();
|
10528
11425
|
if (!this._currentConnector || !hasConnector) {
|
10529
|
-
throw new
|
11426
|
+
throw new FuelError30(
|
10530
11427
|
ErrorCode26.MISSING_CONNECTOR,
|
10531
11428
|
`No connector selected for calling ${method}. Use hasConnector before executing other methods.`
|
10532
11429
|
);
|
@@ -10591,7 +11488,7 @@ var _Fuel = class extends FuelConnector {
|
|
10591
11488
|
cacheTime: PING_CACHE_TIME
|
10592
11489
|
})();
|
10593
11490
|
} catch {
|
10594
|
-
throw new
|
11491
|
+
throw new FuelError30(ErrorCode26.INVALID_PROVIDER, "Current connector is not available.");
|
10595
11492
|
}
|
10596
11493
|
}
|
10597
11494
|
/**
|
@@ -10740,7 +11637,7 @@ var _Fuel = class extends FuelConnector {
|
|
10740
11637
|
const currentNetwork = await this.currentNetwork();
|
10741
11638
|
provider = await Provider.create(currentNetwork.url);
|
10742
11639
|
} else {
|
10743
|
-
throw new
|
11640
|
+
throw new FuelError30(ErrorCode26.INVALID_PROVIDER, "Provider is not valid.");
|
10744
11641
|
}
|
10745
11642
|
return provider;
|
10746
11643
|
}
|
@@ -10816,6 +11713,8 @@ export {
|
|
10816
11713
|
TransactionStatus,
|
10817
11714
|
TransactionType,
|
10818
11715
|
TransactionTypeName,
|
11716
|
+
UpgradeTransactionRequest,
|
11717
|
+
UploadTransactionRequest,
|
10819
11718
|
Vault,
|
10820
11719
|
Wallet,
|
10821
11720
|
WalletLocked,
|
@@ -10837,6 +11736,9 @@ export {
|
|
10837
11736
|
calculateMetadataGasForTxBlob,
|
10838
11737
|
calculateMetadataGasForTxCreate,
|
10839
11738
|
calculateMetadataGasForTxScript,
|
11739
|
+
calculateMetadataGasForTxUpgrade,
|
11740
|
+
calculateMetadataGasForTxUpload,
|
11741
|
+
calculateMinGasForTxUpload,
|
10840
11742
|
calculateTXFeeForSummary,
|
10841
11743
|
coinQuantityfy,
|
10842
11744
|
deferPromise,
|
@@ -10907,6 +11809,8 @@ export {
|
|
10907
11809
|
isTransactionTypeBlob,
|
10908
11810
|
isTransactionTypeCreate,
|
10909
11811
|
isTransactionTypeScript,
|
11812
|
+
isTransactionTypeUpgrade,
|
11813
|
+
isTransactionTypeUpload,
|
10910
11814
|
isType,
|
10911
11815
|
isTypeBlob,
|
10912
11816
|
isTypeCreate,
|