@fuel-ts/account 0.99.0 → 0.100.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account.d.ts +9 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/connectors/fuel-connector.d.ts +7 -6
- package/dist/connectors/fuel-connector.d.ts.map +1 -1
- package/dist/connectors/types/data-type.d.ts +8 -1
- package/dist/connectors/types/data-type.d.ts.map +1 -1
- package/dist/index.global.js +4164 -3454
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +1125 -691
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1035 -611
- package/dist/index.mjs.map +1 -1
- package/dist/mnemonic/mnemonic.d.ts +1 -1
- package/dist/providers/__generated__/operations.d.ts +98 -3
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/coin-quantity.d.ts.map +1 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +77 -11
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/resource-cache.d.ts +6 -4
- package/dist/providers/resource-cache.d.ts.map +1 -1
- package/dist/providers/transaction-request/helpers.d.ts +10 -1
- package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +29 -1
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/transaction-summary/assemble-transaction-summary-from-serialized.d.ts +7 -0
- package/dist/providers/transaction-summary/assemble-transaction-summary-from-serialized.d.ts.map +1 -0
- package/dist/providers/transaction-summary/call.d.ts +8 -2
- package/dist/providers/transaction-summary/call.d.ts.map +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts +1 -1
- package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
- package/dist/providers/transaction-summary/index.d.ts +1 -0
- package/dist/providers/transaction-summary/index.d.ts.map +1 -1
- package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
- package/dist/providers/transaction-summary/receipt.d.ts +3 -2
- package/dist/providers/transaction-summary/receipt.d.ts.map +1 -1
- package/dist/providers/transaction-summary/types.d.ts +5 -3
- package/dist/providers/transaction-summary/types.d.ts.map +1 -1
- package/dist/providers/utils/handle-gql-error-message.d.ts +0 -4
- package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
- package/dist/providers/utils/helpers.d.ts +14 -0
- package/dist/providers/utils/helpers.d.ts.map +1 -0
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/providers/utils/receipts.d.ts +4 -3
- package/dist/providers/utils/receipts.d.ts.map +1 -1
- package/dist/providers/utils/serialization.d.ts +35 -0
- package/dist/providers/utils/serialization.d.ts.map +1 -0
- package/dist/signer/signer.d.ts +1 -1
- package/dist/test-utils.global.js +3879 -3184
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +1002 -607
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +922 -527
- package/dist/test-utils.mjs.map +1 -1
- package/dist/utils/formatTransferToContractScriptData.d.ts +3 -3
- package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
- package/dist/utils/predicate-script-loader-instructions.d.ts +2 -2
- package/dist/wallet/base-wallet-unlocked.d.ts +2 -1
- package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
- package/package.json +21 -21
package/dist/index.mjs
CHANGED
@@ -731,10 +731,10 @@ var getAssetsByOwner = async (opts) => {
|
|
731
731
|
import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
|
732
732
|
import { Address as Address4 } from "@fuel-ts/address";
|
733
733
|
import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
|
734
|
-
import { ErrorCode as ErrorCode18, FuelError as
|
735
|
-
import { bn as
|
736
|
-
import { InputType as
|
737
|
-
import { arrayify as
|
734
|
+
import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
|
735
|
+
import { bn as bn20 } from "@fuel-ts/math";
|
736
|
+
import { InputType as InputType7 } from "@fuel-ts/transactions";
|
737
|
+
import { arrayify as arrayify16, hexlify as hexlify17, isDefined as isDefined3 } from "@fuel-ts/utils";
|
738
738
|
import { clone as clone9 } from "ramda";
|
739
739
|
|
740
740
|
// src/providers/coin-quantity.ts
|
@@ -753,10 +753,9 @@ var coinQuantityfy = (coinQuantityLike) => {
|
|
753
753
|
assetId = coinQuantityLike.assetId;
|
754
754
|
max = coinQuantityLike.max ?? void 0;
|
755
755
|
}
|
756
|
-
const bnAmount = bn(amount);
|
757
756
|
return {
|
758
757
|
assetId: hexlify(assetId),
|
759
|
-
amount:
|
758
|
+
amount: bn(amount),
|
760
759
|
max: max ? bn(max) : void 0
|
761
760
|
};
|
762
761
|
};
|
@@ -773,17 +772,35 @@ var addAmountToCoinQuantities = (params) => {
|
|
773
772
|
};
|
774
773
|
|
775
774
|
// src/providers/provider.ts
|
776
|
-
import { Address as Address2 } from "@fuel-ts/address";
|
777
|
-
import { ErrorCode as ErrorCode16, FuelError as
|
778
|
-
import {
|
779
|
-
import {
|
780
|
-
import { arrayify as arrayify12, hexlify as
|
781
|
-
import { checkFuelCoreVersionCompatibility, versions } from "@fuel-ts/versions";
|
782
|
-
import { equalBytes } from "@noble/curves/abstract/utils";
|
775
|
+
import { Address as Address2, isB256 } from "@fuel-ts/address";
|
776
|
+
import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
|
777
|
+
import { bn as bn17 } from "@fuel-ts/math";
|
778
|
+
import { InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
|
779
|
+
import { arrayify as arrayify12, hexlify as hexlify16, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
|
780
|
+
import { checkFuelCoreVersionCompatibility, gte, versions } from "@fuel-ts/versions";
|
783
781
|
import { GraphQLClient } from "graphql-request";
|
784
782
|
import gql2 from "graphql-tag";
|
785
783
|
import { clone as clone8 } from "ramda";
|
786
784
|
|
785
|
+
// src/connectors/utils/promises.ts
|
786
|
+
import { FuelError } from "@fuel-ts/errors";
|
787
|
+
function deferPromise() {
|
788
|
+
const defer = {};
|
789
|
+
defer.promise = new Promise((resolve, reject) => {
|
790
|
+
defer.reject = reject;
|
791
|
+
defer.resolve = resolve;
|
792
|
+
});
|
793
|
+
return defer;
|
794
|
+
}
|
795
|
+
async function withTimeout(promise, timeout = 1050) {
|
796
|
+
const timeoutPromise = new Promise((resolve, reject) => {
|
797
|
+
setTimeout(() => {
|
798
|
+
reject(new FuelError(FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
799
|
+
}, timeout);
|
800
|
+
});
|
801
|
+
return Promise.race([timeoutPromise, promise]);
|
802
|
+
}
|
803
|
+
|
787
804
|
// src/providers/__generated__/operations.ts
|
788
805
|
import gql from "graphql-tag";
|
789
806
|
var SubmittedStatusFragmentDoc = gql`
|
@@ -1391,6 +1408,16 @@ var EstimatePredicatesDocument = gql`
|
|
1391
1408
|
}
|
1392
1409
|
}
|
1393
1410
|
${TransactionEstimatePredicatesFragmentDoc}`;
|
1411
|
+
var EstimatePredicatesAndGasPriceDocument = gql`
|
1412
|
+
query estimatePredicatesAndGasPrice($encodedTransaction: HexString!, $blockHorizon: U32!) {
|
1413
|
+
estimatePredicates(tx: $encodedTransaction) {
|
1414
|
+
...transactionEstimatePredicatesFragment
|
1415
|
+
}
|
1416
|
+
estimateGasPrice(blockHorizon: $blockHorizon) {
|
1417
|
+
gasPrice
|
1418
|
+
}
|
1419
|
+
}
|
1420
|
+
${TransactionEstimatePredicatesFragmentDoc}`;
|
1394
1421
|
var GetLatestBlockDocument = gql`
|
1395
1422
|
query getLatestBlock {
|
1396
1423
|
chain {
|
@@ -1506,6 +1533,13 @@ var GetBalanceDocument = gql`
|
|
1506
1533
|
}
|
1507
1534
|
}
|
1508
1535
|
`;
|
1536
|
+
var GetBalanceV2Document = gql`
|
1537
|
+
query getBalanceV2($owner: Address!, $assetId: AssetId!) {
|
1538
|
+
balance(owner: $owner, assetId: $assetId) {
|
1539
|
+
amountU128
|
1540
|
+
}
|
1541
|
+
}
|
1542
|
+
`;
|
1509
1543
|
var GetLatestGasPriceDocument = gql`
|
1510
1544
|
query getLatestGasPrice {
|
1511
1545
|
latestGasPrice {
|
@@ -1538,6 +1572,27 @@ var GetBalancesDocument = gql`
|
|
1538
1572
|
}
|
1539
1573
|
}
|
1540
1574
|
`;
|
1575
|
+
var GetBalancesV2Document = gql`
|
1576
|
+
query getBalancesV2($filter: BalanceFilterInput!, $after: String, $before: String, $first: Int, $last: Int) {
|
1577
|
+
balances(
|
1578
|
+
filter: $filter
|
1579
|
+
after: $after
|
1580
|
+
before: $before
|
1581
|
+
first: $first
|
1582
|
+
last: $last
|
1583
|
+
) {
|
1584
|
+
pageInfo {
|
1585
|
+
...pageInfoFragment
|
1586
|
+
}
|
1587
|
+
edges {
|
1588
|
+
node {
|
1589
|
+
assetId
|
1590
|
+
amountU128
|
1591
|
+
}
|
1592
|
+
}
|
1593
|
+
}
|
1594
|
+
}
|
1595
|
+
${PageInfoFragmentDoc}`;
|
1541
1596
|
var GetMessagesDocument = gql`
|
1542
1597
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
1543
1598
|
messages(
|
@@ -1592,6 +1647,15 @@ var GetRelayedTransactionStatusDocument = gql`
|
|
1592
1647
|
}
|
1593
1648
|
}
|
1594
1649
|
${RelayedTransactionStatusFragmentDoc}`;
|
1650
|
+
var GetAssetDetailsDocument = gql`
|
1651
|
+
query getAssetDetails($assetId: AssetId!) {
|
1652
|
+
assetDetails(id: $assetId) {
|
1653
|
+
subId
|
1654
|
+
contractId
|
1655
|
+
totalSupply
|
1656
|
+
}
|
1657
|
+
}
|
1658
|
+
`;
|
1595
1659
|
var DryRunDocument = gql`
|
1596
1660
|
mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean, $gasPrice: U64) {
|
1597
1661
|
dryRun(
|
@@ -1692,6 +1756,9 @@ function getSdk(requester) {
|
|
1692
1756
|
estimatePredicates(variables, options) {
|
1693
1757
|
return requester(EstimatePredicatesDocument, variables, options);
|
1694
1758
|
},
|
1759
|
+
estimatePredicatesAndGasPrice(variables, options) {
|
1760
|
+
return requester(EstimatePredicatesAndGasPriceDocument, variables, options);
|
1761
|
+
},
|
1695
1762
|
getLatestBlock(variables, options) {
|
1696
1763
|
return requester(GetLatestBlockDocument, variables, options);
|
1697
1764
|
},
|
@@ -1725,6 +1792,9 @@ function getSdk(requester) {
|
|
1725
1792
|
getBalance(variables, options) {
|
1726
1793
|
return requester(GetBalanceDocument, variables, options);
|
1727
1794
|
},
|
1795
|
+
getBalanceV2(variables, options) {
|
1796
|
+
return requester(GetBalanceV2Document, variables, options);
|
1797
|
+
},
|
1728
1798
|
getLatestGasPrice(variables, options) {
|
1729
1799
|
return requester(GetLatestGasPriceDocument, variables, options);
|
1730
1800
|
},
|
@@ -1734,6 +1804,9 @@ function getSdk(requester) {
|
|
1734
1804
|
getBalances(variables, options) {
|
1735
1805
|
return requester(GetBalancesDocument, variables, options);
|
1736
1806
|
},
|
1807
|
+
getBalancesV2(variables, options) {
|
1808
|
+
return requester(GetBalancesV2Document, variables, options);
|
1809
|
+
},
|
1737
1810
|
getMessages(variables, options) {
|
1738
1811
|
return requester(GetMessagesDocument, variables, options);
|
1739
1812
|
},
|
@@ -1749,6 +1822,9 @@ function getSdk(requester) {
|
|
1749
1822
|
getRelayedTransactionStatus(variables, options) {
|
1750
1823
|
return requester(GetRelayedTransactionStatusDocument, variables, options);
|
1751
1824
|
},
|
1825
|
+
getAssetDetails(variables, options) {
|
1826
|
+
return requester(GetAssetDetailsDocument, variables, options);
|
1827
|
+
},
|
1752
1828
|
dryRun(variables, options) {
|
1753
1829
|
return requester(DryRunDocument, variables, options);
|
1754
1830
|
},
|
@@ -1777,36 +1853,35 @@ function getSdk(requester) {
|
|
1777
1853
|
}
|
1778
1854
|
|
1779
1855
|
// src/providers/fuel-graphql-subscriber.ts
|
1780
|
-
import { ErrorCode as ErrorCode2, FuelError as
|
1856
|
+
import { ErrorCode as ErrorCode2, FuelError as FuelError3 } from "@fuel-ts/errors";
|
1781
1857
|
import { print } from "graphql";
|
1782
1858
|
|
1783
1859
|
// src/providers/utils/handle-gql-error-message.ts
|
1784
|
-
import { ErrorCode, FuelError } from "@fuel-ts/errors";
|
1860
|
+
import { ErrorCode, FuelError as FuelError2 } from "@fuel-ts/errors";
|
1785
1861
|
var mapGqlErrorMessage = (error) => {
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
|
1801
|
-
default:
|
1802
|
-
return new FuelError(ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1862
|
+
if (new RegExp("the target cannot be met due to no coins available or exceeding the \\d+ coin limit." /* NOT_ENOUGH_COINS_MAX_COINS */).test(error.message)) {
|
1863
|
+
return new FuelError2(
|
1864
|
+
ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
1865
|
+
`Insufficient funds or too many small value coins. Consider combining UTXOs.`,
|
1866
|
+
{},
|
1867
|
+
error
|
1868
|
+
);
|
1869
|
+
}
|
1870
|
+
if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
|
1871
|
+
return new FuelError2(
|
1872
|
+
ErrorCode.ASSET_NOT_FOUND,
|
1873
|
+
`Asset not found for given asset id.`,
|
1874
|
+
{},
|
1875
|
+
error
|
1876
|
+
);
|
1803
1877
|
}
|
1878
|
+
return new FuelError2(ErrorCode.INVALID_REQUEST, error.message, {}, error);
|
1804
1879
|
};
|
1805
1880
|
var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
|
1806
1881
|
if (!incompatibleNodeVersionMessage) {
|
1807
1882
|
return error;
|
1808
1883
|
}
|
1809
|
-
return new
|
1884
|
+
return new FuelError2(
|
1810
1885
|
error.code,
|
1811
1886
|
`${error.message}
|
1812
1887
|
|
@@ -1825,7 +1900,7 @@ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = fal
|
|
1825
1900
|
}
|
1826
1901
|
const errorMessage = mappedErrors.map((err) => err.message).join("\n");
|
1827
1902
|
throw mapGqlErrorWithIncompatibleNodeVersion(
|
1828
|
-
new
|
1903
|
+
new FuelError2(ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
|
1829
1904
|
incompatibleNodeVersionMessage
|
1830
1905
|
);
|
1831
1906
|
};
|
@@ -1876,7 +1951,7 @@ var _FuelGraphqlSubscriber = class {
|
|
1876
1951
|
try {
|
1877
1952
|
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
1878
1953
|
} catch (e) {
|
1879
|
-
throw new
|
1954
|
+
throw new FuelError3(
|
1880
1955
|
ErrorCode2.STREAM_PARSING_ERROR,
|
1881
1956
|
`Error while parsing stream data response: ${text}`
|
1882
1957
|
);
|
@@ -1900,74 +1975,16 @@ __publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
|
|
1900
1975
|
__publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
|
1901
1976
|
|
1902
1977
|
// src/providers/resource-cache.ts
|
1903
|
-
import {
|
1904
|
-
import { hexlify as
|
1905
|
-
var cache = /* @__PURE__ */ new Map();
|
1906
|
-
var ResourceCache = class {
|
1907
|
-
ttl;
|
1908
|
-
constructor(ttl) {
|
1909
|
-
this.ttl = ttl;
|
1910
|
-
if (typeof ttl !== "number" || this.ttl <= 0) {
|
1911
|
-
throw new FuelError3(
|
1912
|
-
ErrorCode3.INVALID_TTL,
|
1913
|
-
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
1914
|
-
);
|
1915
|
-
}
|
1916
|
-
}
|
1917
|
-
// Add resources to the cache
|
1918
|
-
set(transactionId, resources) {
|
1919
|
-
const currentTime = Date.now();
|
1920
|
-
const existingResources = cache.get(transactionId) || {
|
1921
|
-
utxos: /* @__PURE__ */ new Set(),
|
1922
|
-
messages: /* @__PURE__ */ new Set(),
|
1923
|
-
timestamp: currentTime
|
1924
|
-
};
|
1925
|
-
resources.utxos.forEach((utxo) => existingResources.utxos.add(hexlify2(utxo)));
|
1926
|
-
resources.messages.forEach((message) => existingResources.messages.add(hexlify2(message)));
|
1927
|
-
cache.set(transactionId, existingResources);
|
1928
|
-
}
|
1929
|
-
// Remove resources from the cache for a given transaction ID
|
1930
|
-
unset(transactionId) {
|
1931
|
-
cache.delete(transactionId);
|
1932
|
-
}
|
1933
|
-
// Get all cached resources and remove expired ones
|
1934
|
-
getActiveData() {
|
1935
|
-
const allResources = { utxos: [], messages: [] };
|
1936
|
-
const currentTime = Date.now();
|
1937
|
-
cache.forEach((resource, transactionId) => {
|
1938
|
-
if (currentTime - resource.timestamp < this.ttl) {
|
1939
|
-
allResources.utxos.push(...resource.utxos);
|
1940
|
-
allResources.messages.push(...resource.messages);
|
1941
|
-
} else {
|
1942
|
-
cache.delete(transactionId);
|
1943
|
-
}
|
1944
|
-
});
|
1945
|
-
return allResources;
|
1946
|
-
}
|
1947
|
-
// Check if a UTXO ID or message nonce is already cached and not expired
|
1948
|
-
isCached(key) {
|
1949
|
-
const currentTime = Date.now();
|
1950
|
-
for (const [transactionId, resourceData] of cache.entries()) {
|
1951
|
-
if (currentTime - resourceData.timestamp > this.ttl) {
|
1952
|
-
cache.delete(transactionId);
|
1953
|
-
} else if (resourceData.utxos.has(key) || resourceData.messages.has(key)) {
|
1954
|
-
return true;
|
1955
|
-
}
|
1956
|
-
}
|
1957
|
-
return false;
|
1958
|
-
}
|
1959
|
-
clear() {
|
1960
|
-
cache.clear();
|
1961
|
-
}
|
1962
|
-
};
|
1978
|
+
import { FuelError as FuelError13, ErrorCode as ErrorCode10 } from "@fuel-ts/errors";
|
1979
|
+
import { hexlify as hexlify14 } from "@fuel-ts/utils";
|
1963
1980
|
|
1964
1981
|
// src/providers/transaction-request/input.ts
|
1965
1982
|
import { BYTES_32, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
|
1966
1983
|
import { ZeroBytes32 } from "@fuel-ts/address/configs";
|
1967
|
-
import { ErrorCode as
|
1984
|
+
import { ErrorCode as ErrorCode3, FuelError as FuelError4 } from "@fuel-ts/errors";
|
1968
1985
|
import { bn as bn2, toNumber } from "@fuel-ts/math";
|
1969
1986
|
import { InputType } from "@fuel-ts/transactions";
|
1970
|
-
import { arrayify, hexlify as
|
1987
|
+
import { arrayify, hexlify as hexlify2 } from "@fuel-ts/utils";
|
1971
1988
|
var inputify = (value) => {
|
1972
1989
|
const { type } = value;
|
1973
1990
|
switch (value.type) {
|
@@ -1976,11 +1993,11 @@ var inputify = (value) => {
|
|
1976
1993
|
const predicateData = arrayify(value.predicateData ?? "0x");
|
1977
1994
|
return {
|
1978
1995
|
type: InputType.Coin,
|
1979
|
-
txID:
|
1996
|
+
txID: hexlify2(arrayify(value.id).slice(0, BYTES_32)),
|
1980
1997
|
outputIndex: toNumber(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
|
1981
|
-
owner:
|
1998
|
+
owner: hexlify2(value.owner),
|
1982
1999
|
amount: bn2(value.amount),
|
1983
|
-
assetId:
|
2000
|
+
assetId: hexlify2(value.assetId),
|
1984
2001
|
txPointer: {
|
1985
2002
|
blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
|
1986
2003
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
@@ -1989,8 +2006,8 @@ var inputify = (value) => {
|
|
1989
2006
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
1990
2007
|
predicateLength: bn2(predicate.length),
|
1991
2008
|
predicateDataLength: bn2(predicateData.length),
|
1992
|
-
predicate:
|
1993
|
-
predicateData:
|
2009
|
+
predicate: hexlify2(predicate),
|
2010
|
+
predicateData: hexlify2(predicateData)
|
1994
2011
|
};
|
1995
2012
|
}
|
1996
2013
|
case InputType.Contract: {
|
@@ -2004,7 +2021,7 @@ var inputify = (value) => {
|
|
2004
2021
|
blockHeight: toNumber(arrayify(value.txPointer).slice(0, 8)),
|
2005
2022
|
txIndex: toNumber(arrayify(value.txPointer).slice(8, 16))
|
2006
2023
|
},
|
2007
|
-
contractID:
|
2024
|
+
contractID: hexlify2(value.contractId)
|
2008
2025
|
};
|
2009
2026
|
}
|
2010
2027
|
case InputType.Message: {
|
@@ -2013,23 +2030,23 @@ var inputify = (value) => {
|
|
2013
2030
|
const data = arrayify(value.data ?? "0x");
|
2014
2031
|
return {
|
2015
2032
|
type: InputType.Message,
|
2016
|
-
sender:
|
2017
|
-
recipient:
|
2033
|
+
sender: hexlify2(value.sender),
|
2034
|
+
recipient: hexlify2(value.recipient),
|
2018
2035
|
amount: bn2(value.amount),
|
2019
|
-
nonce:
|
2036
|
+
nonce: hexlify2(value.nonce),
|
2020
2037
|
witnessIndex: value.witnessIndex,
|
2021
2038
|
predicateGasUsed: bn2(value.predicateGasUsed),
|
2022
2039
|
predicateLength: bn2(predicate.length),
|
2023
2040
|
predicateDataLength: bn2(predicateData.length),
|
2024
|
-
predicate:
|
2025
|
-
predicateData:
|
2026
|
-
data:
|
2041
|
+
predicate: hexlify2(predicate),
|
2042
|
+
predicateData: hexlify2(predicateData),
|
2043
|
+
data: hexlify2(data),
|
2027
2044
|
dataLength: data.length
|
2028
2045
|
};
|
2029
2046
|
}
|
2030
2047
|
default: {
|
2031
2048
|
throw new FuelError4(
|
2032
|
-
|
2049
|
+
ErrorCode3.INVALID_TRANSACTION_INPUT,
|
2033
2050
|
`Invalid transaction input type: ${type}.`
|
2034
2051
|
);
|
2035
2052
|
}
|
@@ -2038,19 +2055,19 @@ var inputify = (value) => {
|
|
2038
2055
|
|
2039
2056
|
// src/providers/transaction-request/output.ts
|
2040
2057
|
import { ZeroBytes32 as ZeroBytes322 } from "@fuel-ts/address/configs";
|
2041
|
-
import { ErrorCode as
|
2058
|
+
import { ErrorCode as ErrorCode4, FuelError as FuelError5 } from "@fuel-ts/errors";
|
2042
2059
|
import { bn as bn3 } from "@fuel-ts/math";
|
2043
2060
|
import { OutputType } from "@fuel-ts/transactions";
|
2044
|
-
import { hexlify as
|
2061
|
+
import { hexlify as hexlify3 } from "@fuel-ts/utils";
|
2045
2062
|
var outputify = (value) => {
|
2046
2063
|
const { type } = value;
|
2047
2064
|
switch (type) {
|
2048
2065
|
case OutputType.Coin: {
|
2049
2066
|
return {
|
2050
2067
|
type: OutputType.Coin,
|
2051
|
-
to:
|
2068
|
+
to: hexlify3(value.to),
|
2052
2069
|
amount: bn3(value.amount),
|
2053
|
-
assetId:
|
2070
|
+
assetId: hexlify3(value.assetId)
|
2054
2071
|
};
|
2055
2072
|
}
|
2056
2073
|
case OutputType.Contract: {
|
@@ -2064,9 +2081,9 @@ var outputify = (value) => {
|
|
2064
2081
|
case OutputType.Change: {
|
2065
2082
|
return {
|
2066
2083
|
type: OutputType.Change,
|
2067
|
-
to:
|
2084
|
+
to: hexlify3(value.to),
|
2068
2085
|
amount: bn3(0),
|
2069
|
-
assetId:
|
2086
|
+
assetId: hexlify3(value.assetId)
|
2070
2087
|
};
|
2071
2088
|
}
|
2072
2089
|
case OutputType.Variable: {
|
@@ -2080,13 +2097,13 @@ var outputify = (value) => {
|
|
2080
2097
|
case OutputType.ContractCreated: {
|
2081
2098
|
return {
|
2082
2099
|
type: OutputType.ContractCreated,
|
2083
|
-
contractId:
|
2084
|
-
stateRoot:
|
2100
|
+
contractId: hexlify3(value.contractId),
|
2101
|
+
stateRoot: hexlify3(value.stateRoot)
|
2085
2102
|
};
|
2086
2103
|
}
|
2087
2104
|
default: {
|
2088
2105
|
throw new FuelError5(
|
2089
|
-
|
2106
|
+
ErrorCode4.INVALID_TRANSACTION_INPUT,
|
2090
2107
|
`Invalid transaction output type: ${type}.`
|
2091
2108
|
);
|
2092
2109
|
}
|
@@ -2119,31 +2136,157 @@ var isCoin = (resource) => "id" in resource;
|
|
2119
2136
|
var isMessage = (resource) => "recipient" in resource;
|
2120
2137
|
|
2121
2138
|
// src/providers/utils/receipts.ts
|
2139
|
+
import { ReceiptType as ReceiptType2 } from "@fuel-ts/transactions";
|
2140
|
+
import { FAILED_TRANSFER_TO_ADDRESS_SIGNAL } from "@fuel-ts/transactions/configs";
|
2141
|
+
|
2142
|
+
// src/providers/utils/serialization.ts
|
2122
2143
|
import { ZeroBytes32 as ZeroBytes323 } from "@fuel-ts/address/configs";
|
2123
|
-
import { ErrorCode as
|
2144
|
+
import { ErrorCode as ErrorCode5, FuelError as FuelError6 } from "@fuel-ts/errors";
|
2124
2145
|
import { bn as bn4 } from "@fuel-ts/math";
|
2125
2146
|
import { getMintedAssetId, InputMessageCoder, ReceiptType } from "@fuel-ts/transactions";
|
2126
|
-
import {
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2147
|
+
import { hexlify as hexlify4, arrayify as arrayify2 } from "@fuel-ts/utils";
|
2148
|
+
var deserializeChain = (chain) => {
|
2149
|
+
const { name, daHeight, consensusParameters } = chain;
|
2150
|
+
const {
|
2151
|
+
contractParams,
|
2152
|
+
feeParams,
|
2153
|
+
predicateParams,
|
2154
|
+
scriptParams,
|
2155
|
+
txParams,
|
2156
|
+
gasCosts,
|
2157
|
+
baseAssetId,
|
2158
|
+
chainId,
|
2159
|
+
version
|
2160
|
+
} = consensusParameters;
|
2161
|
+
return {
|
2162
|
+
name,
|
2163
|
+
baseChainHeight: bn4(daHeight),
|
2164
|
+
consensusParameters: {
|
2165
|
+
version,
|
2166
|
+
chainId: bn4(chainId),
|
2167
|
+
baseAssetId,
|
2168
|
+
feeParameters: {
|
2169
|
+
version: feeParams.version,
|
2170
|
+
gasPerByte: bn4(feeParams.gasPerByte),
|
2171
|
+
gasPriceFactor: bn4(feeParams.gasPriceFactor)
|
2172
|
+
},
|
2173
|
+
contractParameters: {
|
2174
|
+
version: contractParams.version,
|
2175
|
+
contractMaxSize: bn4(contractParams.contractMaxSize),
|
2176
|
+
maxStorageSlots: bn4(contractParams.maxStorageSlots)
|
2177
|
+
},
|
2178
|
+
txParameters: {
|
2179
|
+
version: txParams.version,
|
2180
|
+
maxInputs: bn4(txParams.maxInputs),
|
2181
|
+
maxOutputs: bn4(txParams.maxOutputs),
|
2182
|
+
maxWitnesses: bn4(txParams.maxWitnesses),
|
2183
|
+
maxGasPerTx: bn4(txParams.maxGasPerTx),
|
2184
|
+
maxSize: bn4(txParams.maxSize),
|
2185
|
+
maxBytecodeSubsections: bn4(txParams.maxBytecodeSubsections)
|
2186
|
+
},
|
2187
|
+
predicateParameters: {
|
2188
|
+
version: predicateParams.version,
|
2189
|
+
maxPredicateLength: bn4(predicateParams.maxPredicateLength),
|
2190
|
+
maxPredicateDataLength: bn4(predicateParams.maxPredicateDataLength),
|
2191
|
+
maxGasPerPredicate: bn4(predicateParams.maxGasPerPredicate),
|
2192
|
+
maxMessageDataLength: bn4(predicateParams.maxMessageDataLength)
|
2193
|
+
},
|
2194
|
+
scriptParameters: {
|
2195
|
+
version: scriptParams.version,
|
2196
|
+
maxScriptLength: bn4(scriptParams.maxScriptLength),
|
2197
|
+
maxScriptDataLength: bn4(scriptParams.maxScriptDataLength)
|
2198
|
+
},
|
2199
|
+
gasCosts
|
2134
2200
|
}
|
2135
|
-
|
2136
|
-
|
2201
|
+
};
|
2202
|
+
};
|
2203
|
+
var serializeChain = (chain) => {
|
2204
|
+
const { name, baseChainHeight, consensusParameters } = chain;
|
2205
|
+
const {
|
2206
|
+
contractParameters,
|
2207
|
+
feeParameters,
|
2208
|
+
predicateParameters,
|
2209
|
+
scriptParameters,
|
2210
|
+
txParameters,
|
2211
|
+
gasCosts,
|
2212
|
+
baseAssetId,
|
2213
|
+
chainId,
|
2214
|
+
version
|
2215
|
+
} = consensusParameters;
|
2216
|
+
return {
|
2217
|
+
name,
|
2218
|
+
daHeight: baseChainHeight.toString(),
|
2219
|
+
consensusParameters: {
|
2220
|
+
version,
|
2221
|
+
chainId: chainId.toString(),
|
2222
|
+
baseAssetId,
|
2223
|
+
feeParams: {
|
2224
|
+
version: feeParameters.version,
|
2225
|
+
gasPerByte: feeParameters.gasPerByte.toString(),
|
2226
|
+
gasPriceFactor: feeParameters.gasPriceFactor.toString()
|
2227
|
+
},
|
2228
|
+
contractParams: {
|
2229
|
+
version: contractParameters.version,
|
2230
|
+
contractMaxSize: contractParameters.contractMaxSize.toString(),
|
2231
|
+
maxStorageSlots: contractParameters.maxStorageSlots.toString()
|
2232
|
+
},
|
2233
|
+
txParams: {
|
2234
|
+
version: txParameters.version,
|
2235
|
+
maxInputs: txParameters.maxInputs.toString(),
|
2236
|
+
maxOutputs: txParameters.maxOutputs.toString(),
|
2237
|
+
maxWitnesses: txParameters.maxWitnesses.toString(),
|
2238
|
+
maxGasPerTx: txParameters.maxGasPerTx.toString(),
|
2239
|
+
maxSize: txParameters.maxSize.toString(),
|
2240
|
+
maxBytecodeSubsections: txParameters.maxBytecodeSubsections.toString()
|
2241
|
+
},
|
2242
|
+
predicateParams: {
|
2243
|
+
version: predicateParameters.version,
|
2244
|
+
maxPredicateLength: predicateParameters.maxPredicateLength.toString(),
|
2245
|
+
maxPredicateDataLength: predicateParameters.maxPredicateDataLength.toString(),
|
2246
|
+
maxGasPerPredicate: predicateParameters.maxGasPerPredicate.toString(),
|
2247
|
+
maxMessageDataLength: predicateParameters.maxMessageDataLength.toString()
|
2248
|
+
},
|
2249
|
+
scriptParams: {
|
2250
|
+
version: scriptParameters.version,
|
2251
|
+
maxScriptLength: scriptParameters.maxScriptLength.toString(),
|
2252
|
+
maxScriptDataLength: scriptParameters.maxScriptDataLength.toString()
|
2253
|
+
},
|
2254
|
+
gasCosts
|
2137
2255
|
}
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
)
|
2256
|
+
};
|
2257
|
+
};
|
2258
|
+
var deserializeNodeInfo = (nodeInfo) => {
|
2259
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
2260
|
+
return {
|
2261
|
+
maxDepth: bn4(maxDepth),
|
2262
|
+
maxTx: bn4(maxTx),
|
2263
|
+
nodeVersion,
|
2264
|
+
utxoValidation,
|
2265
|
+
vmBacktrace
|
2266
|
+
};
|
2267
|
+
};
|
2268
|
+
var serializeNodeInfo = (nodeInfo) => {
|
2269
|
+
const { maxDepth, maxTx, nodeVersion, utxoValidation, vmBacktrace } = nodeInfo;
|
2270
|
+
return {
|
2271
|
+
maxDepth: maxDepth.toString(),
|
2272
|
+
maxTx: maxTx.toString(),
|
2273
|
+
nodeVersion,
|
2274
|
+
utxoValidation,
|
2275
|
+
vmBacktrace
|
2276
|
+
};
|
2277
|
+
};
|
2278
|
+
var deserializeProviderCache = (cache2) => ({
|
2279
|
+
consensusParametersTimestamp: cache2.consensusParametersTimestamp,
|
2280
|
+
chain: deserializeChain(cache2.chain),
|
2281
|
+
nodeInfo: deserializeNodeInfo(cache2.nodeInfo)
|
2282
|
+
});
|
2283
|
+
var serializeProviderCache = async (provider) => ({
|
2284
|
+
consensusParametersTimestamp: provider.consensusParametersTimestamp,
|
2285
|
+
chain: serializeChain(await provider.getChain()),
|
2286
|
+
nodeInfo: serializeNodeInfo(await provider.getNode())
|
2287
|
+
});
|
2145
2288
|
var hexOrZero = (hex) => hex || ZeroBytes323;
|
2146
|
-
|
2289
|
+
var deserializeReceipt = (receipt) => {
|
2147
2290
|
const { receiptType } = receipt;
|
2148
2291
|
switch (receiptType) {
|
2149
2292
|
case "CALL" /* Call */: {
|
@@ -2287,7 +2430,7 @@ function assembleReceiptByType(receipt) {
|
|
2287
2430
|
recipient,
|
2288
2431
|
nonce,
|
2289
2432
|
amount,
|
2290
|
-
data:
|
2433
|
+
data: hexlify4(data)
|
2291
2434
|
});
|
2292
2435
|
const receiptMessageOut = {
|
2293
2436
|
type: ReceiptType.MessageOut,
|
@@ -2333,12 +2476,32 @@ function assembleReceiptByType(receipt) {
|
|
2333
2476
|
return burnReceipt;
|
2334
2477
|
}
|
2335
2478
|
default:
|
2336
|
-
throw new FuelError6(
|
2479
|
+
throw new FuelError6(ErrorCode5.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
|
2337
2480
|
}
|
2338
|
-
}
|
2481
|
+
};
|
2482
|
+
|
2483
|
+
// src/providers/utils/receipts.ts
|
2484
|
+
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType2.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
2485
|
+
var doesReceiptHaveMissingContractId = (receipt) => receipt.type === ReceiptType2.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
|
2486
|
+
var getReceiptsWithMissingData = (receipts) => receipts.reduce(
|
2487
|
+
(memo, receipt) => {
|
2488
|
+
if (doesReceiptHaveMissingOutputVariables(receipt)) {
|
2489
|
+
memo.missingOutputVariables.push(receipt);
|
2490
|
+
}
|
2491
|
+
if (doesReceiptHaveMissingContractId(receipt)) {
|
2492
|
+
memo.missingOutputContractIds.push(receipt);
|
2493
|
+
}
|
2494
|
+
return memo;
|
2495
|
+
},
|
2496
|
+
{
|
2497
|
+
missingOutputVariables: [],
|
2498
|
+
missingOutputContractIds: []
|
2499
|
+
}
|
2500
|
+
);
|
2501
|
+
var assembleReceiptByType = (gqlReceipt) => deserializeReceipt(gqlReceipt);
|
2339
2502
|
|
2340
2503
|
// src/providers/utils/block-explorer.ts
|
2341
|
-
import { ErrorCode as
|
2504
|
+
import { ErrorCode as ErrorCode6, FuelError as FuelError7 } from "@fuel-ts/errors";
|
2342
2505
|
var DEFAULT_BLOCK_EXPLORER_URL = "https://app.fuel.network";
|
2343
2506
|
var getPathFromInput = (key, value) => {
|
2344
2507
|
const pathMap = {
|
@@ -2373,14 +2536,14 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
2373
2536
|
const hasAnyDefinedValues = definedValues.length > 0;
|
2374
2537
|
if (definedValues.length > 1) {
|
2375
2538
|
throw new FuelError7(
|
2376
|
-
|
2539
|
+
ErrorCode6.ERROR_BUILDING_BLOCK_EXPLORER_URL,
|
2377
2540
|
`Only one of the following can be passed in to buildBlockExplorerUrl: ${customInputParams.map((param) => param.key).join(", ")}.`
|
2378
2541
|
);
|
2379
2542
|
}
|
2380
2543
|
if (path && definedValues.length > 0) {
|
2381
2544
|
const inputKeys = customInputParams.map(({ key }) => key).join(", ");
|
2382
2545
|
throw new FuelError7(
|
2383
|
-
|
2546
|
+
ErrorCode6.ERROR_BUILDING_BLOCK_EXPLORER_URL,
|
2384
2547
|
`You cannot pass in a path to 'buildBlockExplorerUrl' along with any of the following: ${inputKeys}.`
|
2385
2548
|
);
|
2386
2549
|
}
|
@@ -2401,11 +2564,11 @@ var buildBlockExplorerUrl = (options = {}) => {
|
|
2401
2564
|
|
2402
2565
|
// src/providers/utils/gas.ts
|
2403
2566
|
import { bn as bn5 } from "@fuel-ts/math";
|
2404
|
-
import { ReceiptType as
|
2567
|
+
import { ReceiptType as ReceiptType3 } from "@fuel-ts/transactions";
|
2405
2568
|
import { arrayify as arrayify3 } from "@fuel-ts/utils";
|
2406
2569
|
var getGasUsedFromReceipts = (receipts) => {
|
2407
2570
|
const scriptResult = receipts.filter(
|
2408
|
-
(receipt) => receipt.type ===
|
2571
|
+
(receipt) => receipt.type === ReceiptType3.ScriptResult
|
2409
2572
|
);
|
2410
2573
|
const gasUsed = scriptResult.reduce((prev, receipt) => prev.add(receipt.gasUsed), bn5(0));
|
2411
2574
|
return gasUsed;
|
@@ -2538,13 +2701,13 @@ var calculateGasFee = (params) => {
|
|
2538
2701
|
};
|
2539
2702
|
|
2540
2703
|
// src/providers/utils/json.ts
|
2541
|
-
import { hexlify as
|
2704
|
+
import { hexlify as hexlify5 } from "@fuel-ts/utils";
|
2542
2705
|
import { clone } from "ramda";
|
2543
2706
|
function normalize(object) {
|
2544
2707
|
Object.keys(object).forEach((key) => {
|
2545
2708
|
switch (object[key]?.constructor.name) {
|
2546
2709
|
case "Uint8Array":
|
2547
|
-
object[key] =
|
2710
|
+
object[key] = hexlify5(object[key]);
|
2548
2711
|
break;
|
2549
2712
|
case "Array":
|
2550
2713
|
object[key] = normalize(object[key]);
|
@@ -2569,9 +2732,9 @@ function normalizeJSON(root) {
|
|
2569
2732
|
}
|
2570
2733
|
|
2571
2734
|
// src/providers/utils/extract-tx-error.ts
|
2572
|
-
import { ErrorCode as
|
2735
|
+
import { ErrorCode as ErrorCode7, FuelError as FuelError8 } from "@fuel-ts/errors";
|
2573
2736
|
import { bn as bn6 } from "@fuel-ts/math";
|
2574
|
-
import { ReceiptType as
|
2737
|
+
import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
|
2575
2738
|
import {
|
2576
2739
|
FAILED_REQUIRE_SIGNAL,
|
2577
2740
|
FAILED_ASSERT_EQ_SIGNAL,
|
@@ -2590,7 +2753,7 @@ You can read more about this error at:
|
|
2590
2753
|
|
2591
2754
|
${PANIC_DOC_URL}#variant.${statusReason}`;
|
2592
2755
|
}
|
2593
|
-
return new FuelError8(
|
2756
|
+
return new FuelError8(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
2594
2757
|
...metadata,
|
2595
2758
|
reason: statusReason
|
2596
2759
|
});
|
@@ -2598,7 +2761,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
|
|
2598
2761
|
var stringify = (obj) => JSON.stringify(obj, null, 2);
|
2599
2762
|
var assembleRevertError = (receipts, logs, metadata) => {
|
2600
2763
|
let errorMessage = "The transaction reverted with an unknown reason.";
|
2601
|
-
const revertReceipt = receipts.find(({ type }) => type ===
|
2764
|
+
const revertReceipt = receipts.find(({ type }) => type === ReceiptType4.Revert);
|
2602
2765
|
let reason = "";
|
2603
2766
|
if (revertReceipt) {
|
2604
2767
|
const reasonHex = bn6(revertReceipt.val).toHex();
|
@@ -2611,15 +2774,15 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2611
2774
|
break;
|
2612
2775
|
}
|
2613
2776
|
case FAILED_ASSERT_EQ_SIGNAL: {
|
2614
|
-
const
|
2777
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
|
2615
2778
|
reason = "assert_eq";
|
2616
|
-
errorMessage = `The transaction reverted because of an "assert_eq" statement${
|
2779
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${suffix}`;
|
2617
2780
|
break;
|
2618
2781
|
}
|
2619
2782
|
case FAILED_ASSERT_NE_SIGNAL: {
|
2620
|
-
const
|
2783
|
+
const suffix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
|
2621
2784
|
reason = "assert_ne";
|
2622
|
-
errorMessage = `The transaction reverted because of an "assert_ne" statement${
|
2785
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${suffix}`;
|
2623
2786
|
break;
|
2624
2787
|
}
|
2625
2788
|
case FAILED_ASSERT_SIGNAL:
|
@@ -2627,12 +2790,12 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2627
2790
|
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
2628
2791
|
break;
|
2629
2792
|
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
|
2630
|
-
reason = "
|
2631
|
-
errorMessage = `The transaction reverted because it's missing an "
|
2793
|
+
reason = "MissingOutputVariable";
|
2794
|
+
errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
|
2632
2795
|
break;
|
2633
2796
|
default:
|
2634
2797
|
throw new FuelError8(
|
2635
|
-
|
2798
|
+
ErrorCode7.UNKNOWN,
|
2636
2799
|
`The transaction reverted with an unknown reason: ${revertReceipt.val}`,
|
2637
2800
|
{
|
2638
2801
|
...metadata,
|
@@ -2641,15 +2804,15 @@ var assembleRevertError = (receipts, logs, metadata) => {
|
|
2641
2804
|
);
|
2642
2805
|
}
|
2643
2806
|
}
|
2644
|
-
return new FuelError8(
|
2807
|
+
return new FuelError8(ErrorCode7.SCRIPT_REVERTED, errorMessage, {
|
2645
2808
|
...metadata,
|
2646
2809
|
reason
|
2647
2810
|
});
|
2648
2811
|
};
|
2649
2812
|
var extractTxError = (params) => {
|
2650
2813
|
const { receipts, statusReason, logs } = params;
|
2651
|
-
const isPanic = receipts.some(({ type }) => type ===
|
2652
|
-
const isRevert = receipts.some(({ type }) => type ===
|
2814
|
+
const isPanic = receipts.some(({ type }) => type === ReceiptType4.Panic);
|
2815
|
+
const isRevert = receipts.some(({ type }) => type === ReceiptType4.Revert);
|
2653
2816
|
const metadata = {
|
2654
2817
|
logs,
|
2655
2818
|
receipts,
|
@@ -2686,9 +2849,10 @@ var NoWitnessByOwnerError = class extends Error {
|
|
2686
2849
|
};
|
2687
2850
|
|
2688
2851
|
// src/providers/transaction-request/helpers.ts
|
2689
|
-
import { ErrorCode as
|
2852
|
+
import { ErrorCode as ErrorCode8, FuelError as FuelError9 } from "@fuel-ts/errors";
|
2690
2853
|
import { bn as bn7 } from "@fuel-ts/math";
|
2691
2854
|
import { InputType as InputType2, OutputType as OutputType2 } from "@fuel-ts/transactions";
|
2855
|
+
import { hexlify as hexlify6 } from "@fuel-ts/utils";
|
2692
2856
|
var isRequestInputCoin = (input) => input.type === InputType2.Coin;
|
2693
2857
|
var isRequestInputMessage = (input) => input.type === InputType2.Message;
|
2694
2858
|
var isRequestInputMessageWithoutData = (input) => input.type === InputType2.Message && bn7(input.data).isZero();
|
@@ -2696,6 +2860,7 @@ var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequ
|
|
2696
2860
|
var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
|
2697
2861
|
var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
|
2698
2862
|
var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
|
2863
|
+
var isPredicate = (input) => isRequestInputCoinOrMessage(input) && !!input.predicate && hexlify6(input.predicate) !== "0x";
|
2699
2864
|
var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
|
2700
2865
|
if (isRequestInputCoin(input) && input.assetId === assetId) {
|
2701
2866
|
return acc.add(input.amount);
|
@@ -2757,7 +2922,7 @@ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAs
|
|
2757
2922
|
"Add the relevant change outputs to the transaction to avoid burning assets.",
|
2758
2923
|
"Or enable asset burn, upon sending the transaction."
|
2759
2924
|
].join("\n");
|
2760
|
-
throw new FuelError9(
|
2925
|
+
throw new FuelError9(ErrorCode8.ASSET_BURN_DETECTED, message);
|
2761
2926
|
};
|
2762
2927
|
|
2763
2928
|
// src/providers/transaction-request/witness.ts
|
@@ -2776,6 +2941,8 @@ var BaseTransactionRequest = class {
|
|
2776
2941
|
tip;
|
2777
2942
|
/** Block until which tx cannot be included */
|
2778
2943
|
maturity;
|
2944
|
+
/** The block number after which the transaction is no longer valid. */
|
2945
|
+
expiration;
|
2779
2946
|
/** The maximum fee payable by this transaction using BASE_ASSET. */
|
2780
2947
|
maxFee;
|
2781
2948
|
/** The maximum amount of witness data allowed for the transaction */
|
@@ -2786,6 +2953,12 @@ var BaseTransactionRequest = class {
|
|
2786
2953
|
outputs = [];
|
2787
2954
|
/** List of witnesses */
|
2788
2955
|
witnesses = [];
|
2956
|
+
/**
|
2957
|
+
* @hidden
|
2958
|
+
*
|
2959
|
+
* The current status of the transaction
|
2960
|
+
*/
|
2961
|
+
flag = { state: void 0, transactionId: void 0, summary: void 0 };
|
2789
2962
|
/**
|
2790
2963
|
* Constructor for initializing a base transaction request.
|
2791
2964
|
*
|
@@ -2794,6 +2967,7 @@ var BaseTransactionRequest = class {
|
|
2794
2967
|
constructor({
|
2795
2968
|
tip,
|
2796
2969
|
maturity,
|
2970
|
+
expiration,
|
2797
2971
|
maxFee,
|
2798
2972
|
witnessLimit,
|
2799
2973
|
inputs,
|
@@ -2802,6 +2976,7 @@ var BaseTransactionRequest = class {
|
|
2802
2976
|
} = {}) {
|
2803
2977
|
this.tip = tip ? bn8(tip) : void 0;
|
2804
2978
|
this.maturity = maturity && maturity > 0 ? maturity : void 0;
|
2979
|
+
this.expiration = expiration && expiration > 0 ? expiration : void 0;
|
2805
2980
|
this.witnessLimit = isDefined(witnessLimit) ? bn8(witnessLimit) : void 0;
|
2806
2981
|
this.maxFee = bn8(maxFee);
|
2807
2982
|
this.inputs = inputs ?? [];
|
@@ -2811,7 +2986,7 @@ var BaseTransactionRequest = class {
|
|
2811
2986
|
static getPolicyMeta(req) {
|
2812
2987
|
let policyTypes = 0;
|
2813
2988
|
const policies = [];
|
2814
|
-
const { tip, witnessLimit, maturity } = req;
|
2989
|
+
const { tip, witnessLimit, maturity, expiration } = req;
|
2815
2990
|
if (bn8(tip).gt(0)) {
|
2816
2991
|
policyTypes += PolicyType.Tip;
|
2817
2992
|
policies.push({ data: bn8(tip), type: PolicyType.Tip });
|
@@ -2826,6 +3001,10 @@ var BaseTransactionRequest = class {
|
|
2826
3001
|
}
|
2827
3002
|
policyTypes += PolicyType.MaxFee;
|
2828
3003
|
policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
|
3004
|
+
if (expiration && expiration > 0) {
|
3005
|
+
policyTypes += PolicyType.Expiration;
|
3006
|
+
policies.push({ data: expiration, type: PolicyType.Expiration });
|
3007
|
+
}
|
2829
3008
|
return {
|
2830
3009
|
policyTypes,
|
2831
3010
|
policies
|
@@ -2898,8 +3077,7 @@ var BaseTransactionRequest = class {
|
|
2898
3077
|
* @returns The index of the created witness.
|
2899
3078
|
*/
|
2900
3079
|
addEmptyWitness() {
|
2901
|
-
this.addWitness(concat([ZeroBytes324, ZeroBytes324]));
|
2902
|
-
return this.witnesses.length - 1;
|
3080
|
+
return this.addWitness(concat([ZeroBytes324, ZeroBytes324]));
|
2903
3081
|
}
|
2904
3082
|
/**
|
2905
3083
|
* Updates the witness for a given owner and signature.
|
@@ -3269,6 +3447,21 @@ var BaseTransactionRequest = class {
|
|
3269
3447
|
byteLength() {
|
3270
3448
|
return this.toTransactionBytes().byteLength;
|
3271
3449
|
}
|
3450
|
+
/**
|
3451
|
+
* @hidden
|
3452
|
+
*
|
3453
|
+
* Used internally to update the state of a transaction request.
|
3454
|
+
*
|
3455
|
+
* @param state - The state to update.
|
3456
|
+
*/
|
3457
|
+
updateState(chainId, state, summary) {
|
3458
|
+
if (!state) {
|
3459
|
+
this.flag = { state: void 0, transactionId: void 0, summary: void 0 };
|
3460
|
+
return;
|
3461
|
+
}
|
3462
|
+
const transactionId = this.getTransactionId(chainId);
|
3463
|
+
this.flag = { state, transactionId, summary };
|
3464
|
+
}
|
3272
3465
|
};
|
3273
3466
|
|
3274
3467
|
// src/providers/transaction-request/blob-transaction-request.ts
|
@@ -4014,7 +4207,7 @@ var AbstractScriptRequest = class {
|
|
4014
4207
|
};
|
4015
4208
|
|
4016
4209
|
// src/providers/transaction-request/utils.ts
|
4017
|
-
import { ErrorCode as
|
4210
|
+
import { ErrorCode as ErrorCode9, FuelError as FuelError12 } from "@fuel-ts/errors";
|
4018
4211
|
import { TransactionType as TransactionType7 } from "@fuel-ts/transactions";
|
4019
4212
|
var transactionRequestify = (obj) => {
|
4020
4213
|
if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
|
@@ -4039,7 +4232,7 @@ var transactionRequestify = (obj) => {
|
|
4039
4232
|
}
|
4040
4233
|
default: {
|
4041
4234
|
throw new FuelError12(
|
4042
|
-
|
4235
|
+
ErrorCode9.UNSUPPORTED_TRANSACTION_TYPE,
|
4043
4236
|
`Unsupported transaction type: ${type}.`
|
4044
4237
|
);
|
4045
4238
|
}
|
@@ -4051,8 +4244,99 @@ var isTransactionTypeBlob = (request2) => request2.type === TransactionType7.Blo
|
|
4051
4244
|
var isTransactionTypeUpgrade = (request2) => request2.type === TransactionType7.Upgrade;
|
4052
4245
|
var isTransactionTypeUpload = (request2) => request2.type === TransactionType7.Upload;
|
4053
4246
|
|
4247
|
+
// src/providers/resource-cache.ts
|
4248
|
+
var cache = /* @__PURE__ */ new Map();
|
4249
|
+
var ResourceCache = class {
|
4250
|
+
ttl;
|
4251
|
+
constructor(ttl) {
|
4252
|
+
this.ttl = ttl;
|
4253
|
+
if (typeof ttl !== "number" || this.ttl <= 0) {
|
4254
|
+
throw new FuelError13(
|
4255
|
+
ErrorCode10.INVALID_TTL,
|
4256
|
+
`Invalid TTL: ${this.ttl}. Use a value greater than zero.`
|
4257
|
+
);
|
4258
|
+
}
|
4259
|
+
}
|
4260
|
+
// Add resources to the cache
|
4261
|
+
set(transactionId, inputs) {
|
4262
|
+
const transactionResourceCache = this.setupResourcesCache(inputs);
|
4263
|
+
cache.set(transactionId, transactionResourceCache);
|
4264
|
+
}
|
4265
|
+
unset(transactionId) {
|
4266
|
+
cache.delete(transactionId);
|
4267
|
+
}
|
4268
|
+
getActiveData(owner) {
|
4269
|
+
const activeData = { utxos: [], messages: [] };
|
4270
|
+
const currentTime = Date.now();
|
4271
|
+
const expired = [];
|
4272
|
+
cache.forEach((resource, transactionId) => {
|
4273
|
+
const isActive = currentTime - resource.timestamp < this.ttl;
|
4274
|
+
if (isActive) {
|
4275
|
+
const resourcesFromOwner = resource.owners.get(owner);
|
4276
|
+
if (resourcesFromOwner) {
|
4277
|
+
activeData.utxos.push(...resourcesFromOwner.utxos);
|
4278
|
+
activeData.messages.push(...resourcesFromOwner.messages);
|
4279
|
+
}
|
4280
|
+
} else {
|
4281
|
+
expired.push(transactionId);
|
4282
|
+
}
|
4283
|
+
});
|
4284
|
+
expired.forEach(this.unset);
|
4285
|
+
activeData.utxos.reverse();
|
4286
|
+
activeData.messages.reverse();
|
4287
|
+
return activeData;
|
4288
|
+
}
|
4289
|
+
isCached(owner, key) {
|
4290
|
+
const currentTime = Date.now();
|
4291
|
+
let cached = false;
|
4292
|
+
const expired = [];
|
4293
|
+
for (const [transactionId, resourceData] of cache.entries()) {
|
4294
|
+
const isActive = currentTime - resourceData.timestamp < this.ttl;
|
4295
|
+
if (isActive) {
|
4296
|
+
const resourcesFromOwner = resourceData.owners.get(owner);
|
4297
|
+
if (resourcesFromOwner?.utxos.has(key) || resourcesFromOwner?.messages.has(key)) {
|
4298
|
+
cached = true;
|
4299
|
+
break;
|
4300
|
+
}
|
4301
|
+
} else {
|
4302
|
+
expired.push(transactionId);
|
4303
|
+
}
|
4304
|
+
}
|
4305
|
+
expired.forEach(this.unset);
|
4306
|
+
return cached;
|
4307
|
+
}
|
4308
|
+
clear() {
|
4309
|
+
cache.clear();
|
4310
|
+
}
|
4311
|
+
setupResourcesCache(inputs) {
|
4312
|
+
const currentTime = Date.now();
|
4313
|
+
const transactionResourcesCache = {
|
4314
|
+
owners: /* @__PURE__ */ new Map(),
|
4315
|
+
timestamp: currentTime
|
4316
|
+
};
|
4317
|
+
inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
4318
|
+
const { owner, key, type } = this.extractResourceData(input);
|
4319
|
+
if (!transactionResourcesCache.owners.has(owner)) {
|
4320
|
+
transactionResourcesCache.owners.set(owner, { utxos: /* @__PURE__ */ new Set(), messages: /* @__PURE__ */ new Set() });
|
4321
|
+
}
|
4322
|
+
if (type === "utxo") {
|
4323
|
+
transactionResourcesCache.owners.get(owner)?.utxos.add(key);
|
4324
|
+
} else {
|
4325
|
+
transactionResourcesCache.owners.get(owner)?.messages.add(key);
|
4326
|
+
}
|
4327
|
+
});
|
4328
|
+
return transactionResourcesCache;
|
4329
|
+
}
|
4330
|
+
extractResourceData(input) {
|
4331
|
+
if (isRequestInputCoin(input)) {
|
4332
|
+
return { owner: hexlify14(input.owner), key: hexlify14(input.id), type: "utxo" };
|
4333
|
+
}
|
4334
|
+
return { owner: hexlify14(input.recipient), key: hexlify14(input.nonce), type: "message" };
|
4335
|
+
}
|
4336
|
+
};
|
4337
|
+
|
4054
4338
|
// src/providers/transaction-response/transaction-response.ts
|
4055
|
-
import { ErrorCode as ErrorCode14, FuelError as
|
4339
|
+
import { ErrorCode as ErrorCode14, FuelError as FuelError17 } from "@fuel-ts/errors";
|
4056
4340
|
import { bn as bn16 } from "@fuel-ts/math";
|
4057
4341
|
import { OutputType as OutputType8, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
|
4058
4342
|
import { arrayify as arrayify11, assertUnreachable } from "@fuel-ts/utils";
|
@@ -4060,7 +4344,7 @@ import { arrayify as arrayify11, assertUnreachable } from "@fuel-ts/utils";
|
|
4060
4344
|
// src/providers/transaction-summary/assemble-transaction-summary.ts
|
4061
4345
|
import { bn as bn15 } from "@fuel-ts/math";
|
4062
4346
|
import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
|
4063
|
-
import { DateTime, hexlify as
|
4347
|
+
import { DateTime, hexlify as hexlify15 } from "@fuel-ts/utils";
|
4064
4348
|
|
4065
4349
|
// src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
|
4066
4350
|
import { bn as bn12 } from "@fuel-ts/math";
|
@@ -4130,45 +4414,12 @@ var calculateTXFeeForSummary = (params) => {
|
|
4130
4414
|
|
4131
4415
|
// src/providers/transaction-summary/operations.ts
|
4132
4416
|
import { ZeroBytes32 as ZeroBytes329 } from "@fuel-ts/address/configs";
|
4133
|
-
import { ErrorCode as ErrorCode12, FuelError as
|
4417
|
+
import { ErrorCode as ErrorCode12, FuelError as FuelError15 } from "@fuel-ts/errors";
|
4134
4418
|
import { bn as bn13 } from "@fuel-ts/math";
|
4135
|
-
import { ReceiptType as
|
4136
|
-
|
4137
|
-
// src/providers/transaction-summary/call.ts
|
4138
|
-
import { Interface as Interface2 } from "@fuel-ts/abi-coder";
|
4139
|
-
var getFunctionCall = ({ abi, receipt }) => {
|
4140
|
-
const abiInterface = new Interface2(abi);
|
4141
|
-
const callFunctionSelector = receipt.param1.toHex(8);
|
4142
|
-
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
4143
|
-
const inputs = functionFragment.jsonFn.inputs;
|
4144
|
-
const encodedArgs = receipt.param2.toHex();
|
4145
|
-
let argumentsProvided;
|
4146
|
-
const data = functionFragment.decodeArguments(encodedArgs);
|
4147
|
-
if (data) {
|
4148
|
-
argumentsProvided = inputs.reduce((prev, input, index) => {
|
4149
|
-
const value = data[index];
|
4150
|
-
const name = input.name;
|
4151
|
-
if (name) {
|
4152
|
-
return {
|
4153
|
-
...prev,
|
4154
|
-
// reparse to remove bn
|
4155
|
-
[name]: JSON.parse(JSON.stringify(value))
|
4156
|
-
};
|
4157
|
-
}
|
4158
|
-
return prev;
|
4159
|
-
}, {});
|
4160
|
-
}
|
4161
|
-
const call = {
|
4162
|
-
functionSignature: functionFragment.signature,
|
4163
|
-
functionName: functionFragment.name,
|
4164
|
-
argumentsProvided,
|
4165
|
-
...receipt.amount?.isZero() ? {} : { amount: receipt.amount, assetId: receipt.assetId }
|
4166
|
-
};
|
4167
|
-
return call;
|
4168
|
-
};
|
4419
|
+
import { ReceiptType as ReceiptType5, TransactionType as TransactionType9 } from "@fuel-ts/transactions";
|
4169
4420
|
|
4170
4421
|
// src/providers/transaction-summary/input.ts
|
4171
|
-
import { ErrorCode as ErrorCode11, FuelError as
|
4422
|
+
import { ErrorCode as ErrorCode11, FuelError as FuelError14 } from "@fuel-ts/errors";
|
4172
4423
|
import { BN } from "@fuel-ts/math";
|
4173
4424
|
import { InputType as InputType6 } from "@fuel-ts/transactions";
|
4174
4425
|
function getInputsByTypes(inputs, types) {
|
@@ -4237,7 +4488,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
|
|
4237
4488
|
return void 0;
|
4238
4489
|
}
|
4239
4490
|
if (contractInput.type !== InputType6.Contract) {
|
4240
|
-
throw new
|
4491
|
+
throw new FuelError14(
|
4241
4492
|
ErrorCode11.INVALID_TRANSACTION_INPUT,
|
4242
4493
|
`Contract input should be of type 'contract'.`
|
4243
4494
|
);
|
@@ -4331,7 +4582,7 @@ function getTransactionTypeName(transactionType) {
|
|
4331
4582
|
case TransactionType9.Upload:
|
4332
4583
|
return "Upload" /* Upload */;
|
4333
4584
|
default:
|
4334
|
-
throw new
|
4585
|
+
throw new FuelError15(
|
4335
4586
|
ErrorCode12.UNSUPPORTED_TRANSACTION_TYPE,
|
4336
4587
|
`Unsupported transaction type: ${transactionType}.`
|
4337
4588
|
);
|
@@ -4363,10 +4614,10 @@ function hasSameAssetId(a) {
|
|
4363
4614
|
return (b) => a.assetId === b.assetId;
|
4364
4615
|
}
|
4365
4616
|
function getReceiptsCall(receipts) {
|
4366
|
-
return getReceiptsByType(receipts,
|
4617
|
+
return getReceiptsByType(receipts, ReceiptType5.Call);
|
4367
4618
|
}
|
4368
4619
|
function getReceiptsMessageOut(receipts) {
|
4369
|
-
return getReceiptsByType(receipts,
|
4620
|
+
return getReceiptsByType(receipts, ReceiptType5.MessageOut);
|
4370
4621
|
}
|
4371
4622
|
function mergeAssets(op1, op2) {
|
4372
4623
|
const assets1 = op1.assetsSent || [];
|
@@ -4404,7 +4655,11 @@ function mergeOperations(existing, toAdd) {
|
|
4404
4655
|
return {
|
4405
4656
|
...existing,
|
4406
4657
|
assetsSent: mergeAssetsSent(existing, toAdd),
|
4407
|
-
calls: mergeCalls(existing, toAdd)
|
4658
|
+
calls: mergeCalls(existing, toAdd),
|
4659
|
+
receipts: [
|
4660
|
+
...existing.receipts || [],
|
4661
|
+
...toAdd.receipts?.filter((r) => !existing.receipts?.some((er) => er === r)) || []
|
4662
|
+
]
|
4408
4663
|
};
|
4409
4664
|
}
|
4410
4665
|
function addOperation(operations, toAdd) {
|
@@ -4415,7 +4670,7 @@ function addOperation(operations, toAdd) {
|
|
4415
4670
|
return operations.map((op, index) => index === existingIndex ? mergeOperations(op, toAdd) : op);
|
4416
4671
|
}
|
4417
4672
|
function getReceiptsTransferOut(receipts) {
|
4418
|
-
return getReceiptsByType(receipts,
|
4673
|
+
return getReceiptsByType(receipts, ReceiptType5.TransferOut);
|
4419
4674
|
}
|
4420
4675
|
function getWithdrawFromFuelOperations({
|
4421
4676
|
inputs,
|
@@ -4444,7 +4699,8 @@ function getWithdrawFromFuelOperations({
|
|
4444
4699
|
amount: receipt.amount,
|
4445
4700
|
assetId: baseAssetId
|
4446
4701
|
}
|
4447
|
-
]
|
4702
|
+
],
|
4703
|
+
receipts: [receipt]
|
4448
4704
|
});
|
4449
4705
|
return newWithdrawFromFuelOps;
|
4450
4706
|
}
|
@@ -4454,19 +4710,12 @@ function getWithdrawFromFuelOperations({
|
|
4454
4710
|
);
|
4455
4711
|
return withdrawFromFuelOperations;
|
4456
4712
|
}
|
4457
|
-
function getContractCalls(contractInput, abiMap,
|
4713
|
+
function getContractCalls(contractInput, abiMap, _receipt, _rawPayload, _maxInputs) {
|
4458
4714
|
const abi = abiMap?.[contractInput.contractID];
|
4459
4715
|
if (!abi) {
|
4460
4716
|
return [];
|
4461
4717
|
}
|
4462
|
-
return [
|
4463
|
-
getFunctionCall({
|
4464
|
-
abi,
|
4465
|
-
receipt,
|
4466
|
-
rawPayload,
|
4467
|
-
maxInputs
|
4468
|
-
})
|
4469
|
-
];
|
4718
|
+
return [];
|
4470
4719
|
}
|
4471
4720
|
function getAssetsSent(receipt) {
|
4472
4721
|
return receipt.amount?.isZero() ? void 0 : [
|
@@ -4496,7 +4745,8 @@ function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload,
|
|
4496
4745
|
address: receipt.to
|
4497
4746
|
},
|
4498
4747
|
assetsSent: getAssetsSent(receipt),
|
4499
|
-
calls
|
4748
|
+
calls,
|
4749
|
+
receipts: [receipt]
|
4500
4750
|
}
|
4501
4751
|
];
|
4502
4752
|
}
|
@@ -4553,7 +4803,8 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
|
|
4553
4803
|
assetId: assetId.toString(),
|
4554
4804
|
amount
|
4555
4805
|
}
|
4556
|
-
]
|
4806
|
+
],
|
4807
|
+
receipts: [receipt]
|
4557
4808
|
};
|
4558
4809
|
}
|
4559
4810
|
function getTransferOperations({
|
@@ -4598,11 +4849,11 @@ function getTransferOperations({
|
|
4598
4849
|
});
|
4599
4850
|
const transferReceipts = getReceiptsByType(
|
4600
4851
|
receipts,
|
4601
|
-
|
4852
|
+
ReceiptType5.Transfer
|
4602
4853
|
);
|
4603
4854
|
const transferOutReceipts = getReceiptsByType(
|
4604
4855
|
receipts,
|
4605
|
-
|
4856
|
+
ReceiptType5.TransferOut
|
4606
4857
|
);
|
4607
4858
|
[...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
|
4608
4859
|
const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
|
@@ -4686,12 +4937,12 @@ function getOperations({
|
|
4686
4937
|
}
|
4687
4938
|
|
4688
4939
|
// src/providers/transaction-summary/receipt.ts
|
4689
|
-
import { ReceiptType as
|
4690
|
-
var processGqlReceipt = (gqlReceipt) =>
|
4940
|
+
import { ReceiptType as ReceiptType6 } from "@fuel-ts/transactions";
|
4941
|
+
var processGqlReceipt = (gqlReceipt) => deserializeReceipt(gqlReceipt);
|
4691
4942
|
var extractMintedAssetsFromReceipts = (receipts) => {
|
4692
4943
|
const mintedAssets = [];
|
4693
4944
|
receipts.forEach((receipt) => {
|
4694
|
-
if (receipt.type ===
|
4945
|
+
if (receipt.type === ReceiptType6.Mint) {
|
4695
4946
|
mintedAssets.push({
|
4696
4947
|
subId: receipt.subId,
|
4697
4948
|
contractId: receipt.contractId,
|
@@ -4705,7 +4956,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
|
|
4705
4956
|
var extractBurnedAssetsFromReceipts = (receipts) => {
|
4706
4957
|
const burnedAssets = [];
|
4707
4958
|
receipts.forEach((receipt) => {
|
4708
|
-
if (receipt.type ===
|
4959
|
+
if (receipt.type === ReceiptType6.Burn) {
|
4709
4960
|
burnedAssets.push({
|
4710
4961
|
subId: receipt.subId,
|
4711
4962
|
contractId: receipt.contractId,
|
@@ -4718,7 +4969,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
|
|
4718
4969
|
};
|
4719
4970
|
|
4720
4971
|
// src/providers/transaction-summary/status.ts
|
4721
|
-
import { ErrorCode as ErrorCode13, FuelError as
|
4972
|
+
import { ErrorCode as ErrorCode13, FuelError as FuelError16 } from "@fuel-ts/errors";
|
4722
4973
|
import { bn as bn14 } from "@fuel-ts/math";
|
4723
4974
|
var getTransactionStatusName = (gqlStatus) => {
|
4724
4975
|
switch (gqlStatus) {
|
@@ -4731,7 +4982,7 @@ var getTransactionStatusName = (gqlStatus) => {
|
|
4731
4982
|
case "SqueezedOutStatus":
|
4732
4983
|
return "squeezedout" /* squeezedout */;
|
4733
4984
|
default:
|
4734
|
-
throw new
|
4985
|
+
throw new FuelError16(
|
4735
4986
|
ErrorCode13.INVALID_TRANSACTION_STATUS,
|
4736
4987
|
`Invalid transaction status: ${gqlStatus}.`
|
4737
4988
|
);
|
@@ -4802,7 +5053,7 @@ function assembleTransactionSummary(params) {
|
|
4802
5053
|
baseAssetId
|
4803
5054
|
} = params;
|
4804
5055
|
const gasUsed = getGasUsedFromReceipts(receipts);
|
4805
|
-
const rawPayload =
|
5056
|
+
const rawPayload = hexlify15(transactionBytes);
|
4806
5057
|
const operations = getOperations({
|
4807
5058
|
transactionType: transaction.type,
|
4808
5059
|
inputs: transaction.inputs || [],
|
@@ -4864,15 +5115,27 @@ function assembleTransactionSummary(params) {
|
|
4864
5115
|
}
|
4865
5116
|
|
4866
5117
|
// src/providers/transaction-response/getDecodedLogs.ts
|
4867
|
-
import { Interface as
|
4868
|
-
import {
|
5118
|
+
import { Interface as Interface2, BigNumberCoder } from "@fuel-ts/abi-coder";
|
5119
|
+
import { ZeroBytes32 as ZeroBytes3210 } from "@fuel-ts/address/configs";
|
5120
|
+
import { ReceiptType as ReceiptType7 } from "@fuel-ts/transactions";
|
4869
5121
|
function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
|
5122
|
+
let mainContract = "";
|
5123
|
+
if (mainAbi.programType === "contract") {
|
5124
|
+
const firstCallReceipt = receipts.find(
|
5125
|
+
(r) => r.type === ReceiptType7.Call && r.id === ZeroBytes3210
|
5126
|
+
);
|
5127
|
+
mainContract = firstCallReceipt.to;
|
5128
|
+
}
|
4870
5129
|
return receipts.reduce((logs, receipt) => {
|
4871
|
-
if (receipt.type ===
|
4872
|
-
const
|
4873
|
-
const
|
4874
|
-
|
4875
|
-
|
5130
|
+
if (receipt.type === ReceiptType7.LogData || receipt.type === ReceiptType7.Log) {
|
5131
|
+
const isLogFromMainAbi = receipt.id === ZeroBytes3210 || mainContract === receipt.id;
|
5132
|
+
const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
|
5133
|
+
if (isDecodable) {
|
5134
|
+
const interfaceToUse = isLogFromMainAbi ? new Interface2(mainAbi) : new Interface2(externalAbis[receipt.id]);
|
5135
|
+
const data = receipt.type === ReceiptType7.Log ? new BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
|
5136
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
|
5137
|
+
logs.push(decodedLog);
|
5138
|
+
}
|
4876
5139
|
}
|
4877
5140
|
return logs;
|
4878
5141
|
}, []);
|
@@ -4992,7 +5255,7 @@ var TransactionResponse = class {
|
|
4992
5255
|
switch (status?.type) {
|
4993
5256
|
case "SuccessStatus":
|
4994
5257
|
case "FailureStatus":
|
4995
|
-
return status.receipts.map(
|
5258
|
+
return status.receipts.map(deserializeReceipt);
|
4996
5259
|
default:
|
4997
5260
|
return [];
|
4998
5261
|
}
|
@@ -5077,7 +5340,7 @@ var TransactionResponse = class {
|
|
5077
5340
|
this.status = statusChange;
|
5078
5341
|
if (statusChange.type === "SqueezedOutStatus") {
|
5079
5342
|
this.unsetResourceCache();
|
5080
|
-
throw new
|
5343
|
+
throw new FuelError17(
|
5081
5344
|
ErrorCode14.TRANSACTION_SQUEEZED_OUT,
|
5082
5345
|
`Transaction Squeezed Out with reason: ${statusChange.reason}`
|
5083
5346
|
);
|
@@ -5116,7 +5379,6 @@ var TransactionResponse = class {
|
|
5116
5379
|
const { receipts } = transactionResult;
|
5117
5380
|
const status = this.status ?? this.gqlTransaction?.status;
|
5118
5381
|
if (status?.type === "FailureStatus") {
|
5119
|
-
this.unsetResourceCache();
|
5120
5382
|
const { reason } = status;
|
5121
5383
|
throw extractTxError({
|
5122
5384
|
receipts,
|
@@ -5133,6 +5395,7 @@ var TransactionResponse = class {
|
|
5133
5395
|
*/
|
5134
5396
|
async waitForResult(contractsAbiMap) {
|
5135
5397
|
await this.waitForStatusChange();
|
5398
|
+
this.unsetResourceCache();
|
5136
5399
|
return this.assembleResult(contractsAbiMap);
|
5137
5400
|
}
|
5138
5401
|
/**
|
@@ -5185,31 +5448,47 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
|
|
5185
5448
|
};
|
5186
5449
|
}
|
5187
5450
|
|
5451
|
+
// src/providers/utils/helpers.ts
|
5452
|
+
var adjustResourcesToExclude = (params) => {
|
5453
|
+
const { userInput, cached, maxInputs } = params;
|
5454
|
+
const final = { ...userInput };
|
5455
|
+
let total = final.utxos.length + final.messages.length;
|
5456
|
+
if (total >= maxInputs) {
|
5457
|
+
return final;
|
5458
|
+
}
|
5459
|
+
final.utxos = [...final.utxos, ...cached.utxos.slice(0, maxInputs - total)];
|
5460
|
+
total = final.utxos.length + final.messages.length;
|
5461
|
+
if (total < maxInputs) {
|
5462
|
+
final.messages = [...final.messages, ...cached.messages.slice(0, maxInputs - total)];
|
5463
|
+
}
|
5464
|
+
return final;
|
5465
|
+
};
|
5466
|
+
|
5188
5467
|
// src/providers/utils/validate-pagination-args.ts
|
5189
|
-
import { FuelError as
|
5468
|
+
import { FuelError as FuelError18, ErrorCode as ErrorCode15 } from "@fuel-ts/errors";
|
5190
5469
|
var validatePaginationArgs = (params) => {
|
5191
5470
|
const { paginationLimit, inputArgs = {} } = params;
|
5192
5471
|
const { first, last, after, before } = inputArgs;
|
5193
5472
|
if (after && before) {
|
5194
|
-
throw new
|
5473
|
+
throw new FuelError18(
|
5195
5474
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5196
5475
|
'Pagination arguments "after" and "before" cannot be used together'
|
5197
5476
|
);
|
5198
5477
|
}
|
5199
5478
|
if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
|
5200
|
-
throw new
|
5479
|
+
throw new FuelError18(
|
5201
5480
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5202
5481
|
`Pagination limit for this query cannot exceed ${paginationLimit} items`
|
5203
5482
|
);
|
5204
5483
|
}
|
5205
5484
|
if (first && before) {
|
5206
|
-
throw new
|
5485
|
+
throw new FuelError18(
|
5207
5486
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5208
5487
|
'The use of pagination argument "first" with "before" is not supported'
|
5209
5488
|
);
|
5210
5489
|
}
|
5211
5490
|
if (last && after) {
|
5212
|
-
throw new
|
5491
|
+
throw new FuelError18(
|
5213
5492
|
ErrorCode15.INVALID_INPUT_PARAMETERS,
|
5214
5493
|
'The use of pagination argument "last" with "after" is not supported'
|
5215
5494
|
);
|
@@ -5224,64 +5503,10 @@ var validatePaginationArgs = (params) => {
|
|
5224
5503
|
var MAX_RETRIES = 10;
|
5225
5504
|
var RESOURCES_PAGE_SIZE_LIMIT = 512;
|
5226
5505
|
var TRANSACTIONS_PAGE_SIZE_LIMIT = 60;
|
5506
|
+
var BALANCES_PAGE_SIZE_LIMIT = 100;
|
5227
5507
|
var BLOCKS_PAGE_SIZE_LIMIT = 5;
|
5228
5508
|
var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
|
5229
5509
|
var GAS_USED_MODIFIER = 1.2;
|
5230
|
-
var processGqlChain = (chain) => {
|
5231
|
-
const { name, daHeight, consensusParameters } = chain;
|
5232
|
-
const {
|
5233
|
-
contractParams,
|
5234
|
-
feeParams,
|
5235
|
-
predicateParams,
|
5236
|
-
scriptParams,
|
5237
|
-
txParams,
|
5238
|
-
gasCosts,
|
5239
|
-
baseAssetId,
|
5240
|
-
chainId,
|
5241
|
-
version
|
5242
|
-
} = consensusParameters;
|
5243
|
-
return {
|
5244
|
-
name,
|
5245
|
-
baseChainHeight: bn17(daHeight),
|
5246
|
-
consensusParameters: {
|
5247
|
-
version,
|
5248
|
-
chainId: bn17(chainId),
|
5249
|
-
baseAssetId,
|
5250
|
-
feeParameters: {
|
5251
|
-
version: feeParams.version,
|
5252
|
-
gasPerByte: bn17(feeParams.gasPerByte),
|
5253
|
-
gasPriceFactor: bn17(feeParams.gasPriceFactor)
|
5254
|
-
},
|
5255
|
-
contractParameters: {
|
5256
|
-
version: contractParams.version,
|
5257
|
-
contractMaxSize: bn17(contractParams.contractMaxSize),
|
5258
|
-
maxStorageSlots: bn17(contractParams.maxStorageSlots)
|
5259
|
-
},
|
5260
|
-
txParameters: {
|
5261
|
-
version: txParams.version,
|
5262
|
-
maxInputs: bn17(txParams.maxInputs),
|
5263
|
-
maxOutputs: bn17(txParams.maxOutputs),
|
5264
|
-
maxWitnesses: bn17(txParams.maxWitnesses),
|
5265
|
-
maxGasPerTx: bn17(txParams.maxGasPerTx),
|
5266
|
-
maxSize: bn17(txParams.maxSize),
|
5267
|
-
maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
|
5268
|
-
},
|
5269
|
-
predicateParameters: {
|
5270
|
-
version: predicateParams.version,
|
5271
|
-
maxPredicateLength: bn17(predicateParams.maxPredicateLength),
|
5272
|
-
maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
|
5273
|
-
maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
|
5274
|
-
maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
|
5275
|
-
},
|
5276
|
-
scriptParameters: {
|
5277
|
-
version: scriptParams.version,
|
5278
|
-
maxScriptLength: bn17(scriptParams.maxScriptLength),
|
5279
|
-
maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
|
5280
|
-
},
|
5281
|
-
gasCosts
|
5282
|
-
}
|
5283
|
-
};
|
5284
|
-
};
|
5285
5510
|
var _cacheInputs, cacheInputs_fn;
|
5286
5511
|
var _Provider = class {
|
5287
5512
|
/**
|
@@ -5303,13 +5528,19 @@ var _Provider = class {
|
|
5303
5528
|
/** @hidden */
|
5304
5529
|
__publicField(this, "urlWithoutAuth");
|
5305
5530
|
/** @hidden */
|
5531
|
+
__publicField(this, "features", {
|
5532
|
+
balancePagination: false,
|
5533
|
+
amount128: false
|
5534
|
+
});
|
5535
|
+
/** @hidden */
|
5306
5536
|
__publicField(this, "consensusParametersTimestamp");
|
5307
5537
|
__publicField(this, "options", {
|
5308
5538
|
timeout: void 0,
|
5309
5539
|
resourceCacheTTL: void 0,
|
5310
5540
|
fetch: void 0,
|
5311
5541
|
retryOptions: void 0,
|
5312
|
-
headers: void 0
|
5542
|
+
headers: void 0,
|
5543
|
+
cache: void 0
|
5313
5544
|
});
|
5314
5545
|
const { url: rawUrl, urlWithoutAuth, headers: authHeaders } = _Provider.extractBasicAuth(url);
|
5315
5546
|
this.url = rawUrl;
|
@@ -5323,7 +5554,13 @@ var _Provider = class {
|
|
5323
5554
|
headers
|
5324
5555
|
};
|
5325
5556
|
this.operations = this.createOperations();
|
5326
|
-
const { resourceCacheTTL } = this.options;
|
5557
|
+
const { resourceCacheTTL, cache: cache2 } = this.options;
|
5558
|
+
if (cache2) {
|
5559
|
+
const { consensusParametersTimestamp, chain, nodeInfo } = deserializeProviderCache(cache2);
|
5560
|
+
this.consensusParametersTimestamp = consensusParametersTimestamp;
|
5561
|
+
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
5562
|
+
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
5563
|
+
}
|
5327
5564
|
if (isDefined2(resourceCacheTTL)) {
|
5328
5565
|
if (resourceCacheTTL !== -1) {
|
5329
5566
|
this.cache = new ResourceCache(resourceCacheTTL);
|
@@ -5336,6 +5573,7 @@ var _Provider = class {
|
|
5336
5573
|
}
|
5337
5574
|
/** @hidden */
|
5338
5575
|
static clearChainAndNodeCaches() {
|
5576
|
+
_Provider.inflightFetchChainAndNodeInfoRequests = {};
|
5339
5577
|
_Provider.nodeInfoCache = {};
|
5340
5578
|
_Provider.chainInfoCache = {};
|
5341
5579
|
}
|
@@ -5364,7 +5602,7 @@ var _Provider = class {
|
|
5364
5602
|
try {
|
5365
5603
|
parsedUrl = new URL(url);
|
5366
5604
|
} catch (error) {
|
5367
|
-
throw new
|
5605
|
+
throw new FuelError19(FuelError19.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
|
5368
5606
|
}
|
5369
5607
|
const username = parsedUrl.username;
|
5370
5608
|
const password = parsedUrl.password;
|
@@ -5382,7 +5620,8 @@ var _Provider = class {
|
|
5382
5620
|
* Initialize Provider async stuff
|
5383
5621
|
*/
|
5384
5622
|
async init() {
|
5385
|
-
await this.fetchChainAndNodeInfo();
|
5623
|
+
const { nodeInfo } = await this.fetchChainAndNodeInfo();
|
5624
|
+
this.setupFeatures(nodeInfo.nodeVersion);
|
5386
5625
|
return this;
|
5387
5626
|
}
|
5388
5627
|
/**
|
@@ -5452,19 +5691,24 @@ var _Provider = class {
|
|
5452
5691
|
throw new Error(`Jumps to the catch block and re-fetch`);
|
5453
5692
|
}
|
5454
5693
|
} catch (_err) {
|
5694
|
+
const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5695
|
+
if (inflightRequest) {
|
5696
|
+
const now2 = await inflightRequest;
|
5697
|
+
this.consensusParametersTimestamp = now2;
|
5698
|
+
return this.fetchChainAndNodeInfo();
|
5699
|
+
}
|
5700
|
+
const { promise, resolve } = deferPromise();
|
5701
|
+
_Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
|
5455
5702
|
const data = await this.operations.getChainAndNodeInfo();
|
5456
|
-
nodeInfo =
|
5457
|
-
|
5458
|
-
maxTx: bn17(data.nodeInfo.maxTx),
|
5459
|
-
nodeVersion: data.nodeInfo.nodeVersion,
|
5460
|
-
utxoValidation: data.nodeInfo.utxoValidation,
|
5461
|
-
vmBacktrace: data.nodeInfo.vmBacktrace
|
5462
|
-
};
|
5703
|
+
nodeInfo = deserializeNodeInfo(data.nodeInfo);
|
5704
|
+
chain = deserializeChain(data.chain);
|
5463
5705
|
_Provider.setIncompatibleNodeVersionMessage(nodeInfo);
|
5464
|
-
chain = processGqlChain(data.chain);
|
5465
5706
|
_Provider.chainInfoCache[this.urlWithoutAuth] = chain;
|
5466
5707
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
|
5467
|
-
|
5708
|
+
const now = Date.now();
|
5709
|
+
this.consensusParametersTimestamp = now;
|
5710
|
+
resolve(now);
|
5711
|
+
delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
|
5468
5712
|
}
|
5469
5713
|
return {
|
5470
5714
|
chain,
|
@@ -5539,6 +5783,15 @@ var _Provider = class {
|
|
5539
5783
|
});
|
5540
5784
|
return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
|
5541
5785
|
}
|
5786
|
+
/**
|
5787
|
+
* @hidden
|
5788
|
+
*/
|
5789
|
+
setupFeatures(nodeVersion) {
|
5790
|
+
if (gte(nodeVersion, "0.41.0")) {
|
5791
|
+
this.features.balancePagination = true;
|
5792
|
+
this.features.amount128 = true;
|
5793
|
+
}
|
5794
|
+
}
|
5542
5795
|
/**
|
5543
5796
|
* Returns the version of the connected node.
|
5544
5797
|
*
|
@@ -5570,13 +5823,7 @@ var _Provider = class {
|
|
5570
5823
|
*/
|
5571
5824
|
async fetchNode() {
|
5572
5825
|
const { nodeInfo } = await this.operations.getNodeInfo();
|
5573
|
-
const processedNodeInfo =
|
5574
|
-
maxDepth: bn17(nodeInfo.maxDepth),
|
5575
|
-
maxTx: bn17(nodeInfo.maxTx),
|
5576
|
-
nodeVersion: nodeInfo.nodeVersion,
|
5577
|
-
utxoValidation: nodeInfo.utxoValidation,
|
5578
|
-
vmBacktrace: nodeInfo.vmBacktrace
|
5579
|
-
};
|
5826
|
+
const processedNodeInfo = deserializeNodeInfo(nodeInfo);
|
5580
5827
|
_Provider.nodeInfoCache[this.urlWithoutAuth] = processedNodeInfo;
|
5581
5828
|
return processedNodeInfo;
|
5582
5829
|
}
|
@@ -5587,7 +5834,7 @@ var _Provider = class {
|
|
5587
5834
|
*/
|
5588
5835
|
async fetchChain() {
|
5589
5836
|
const { chain } = await this.operations.getChain();
|
5590
|
-
const processedChain =
|
5837
|
+
const processedChain = deserializeChain(chain);
|
5591
5838
|
_Provider.chainInfoCache[this.urlWithoutAuth] = processedChain;
|
5592
5839
|
return processedChain;
|
5593
5840
|
}
|
@@ -5614,6 +5861,21 @@ var _Provider = class {
|
|
5614
5861
|
} = all;
|
5615
5862
|
return baseAssetId;
|
5616
5863
|
}
|
5864
|
+
/**
|
5865
|
+
* Retrieves the details of an asset given its ID.
|
5866
|
+
*
|
5867
|
+
* @param assetId - The unique identifier of the asset.
|
5868
|
+
* @returns A promise that resolves to an object containing the asset details.
|
5869
|
+
*/
|
5870
|
+
async getAssetDetails(assetId) {
|
5871
|
+
const { assetDetails } = await this.operations.getAssetDetails({ assetId });
|
5872
|
+
const { contractId, subId, totalSupply } = assetDetails;
|
5873
|
+
return {
|
5874
|
+
subId,
|
5875
|
+
contractId,
|
5876
|
+
totalSupply: bn17(totalSupply)
|
5877
|
+
};
|
5878
|
+
}
|
5617
5879
|
/**
|
5618
5880
|
* @hidden
|
5619
5881
|
*/
|
@@ -5624,13 +5886,13 @@ var _Provider = class {
|
|
5624
5886
|
}
|
5625
5887
|
} = await this.getChain();
|
5626
5888
|
if (bn17(tx.inputs.length).gt(maxInputs)) {
|
5627
|
-
throw new
|
5889
|
+
throw new FuelError19(
|
5628
5890
|
ErrorCode16.MAX_INPUTS_EXCEEDED,
|
5629
5891
|
`The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
|
5630
5892
|
);
|
5631
5893
|
}
|
5632
5894
|
if (bn17(tx.outputs.length).gt(maxOutputs)) {
|
5633
|
-
throw new
|
5895
|
+
throw new FuelError19(
|
5634
5896
|
ErrorCode16.MAX_OUTPUTS_EXCEEDED,
|
5635
5897
|
`The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
|
5636
5898
|
);
|
@@ -5657,7 +5919,7 @@ var _Provider = class {
|
|
5657
5919
|
await this.estimateTxDependencies(transactionRequest);
|
5658
5920
|
}
|
5659
5921
|
await this.validateTransaction(transactionRequest);
|
5660
|
-
const encodedTransaction =
|
5922
|
+
const encodedTransaction = hexlify16(transactionRequest.toTransactionBytes());
|
5661
5923
|
let abis;
|
5662
5924
|
if (isTransactionTypeScript(transactionRequest)) {
|
5663
5925
|
abis = transactionRequest.abis;
|
@@ -5682,48 +5944,70 @@ var _Provider = class {
|
|
5682
5944
|
if (estimateTxDependencies) {
|
5683
5945
|
return this.estimateTxDependencies(transactionRequest);
|
5684
5946
|
}
|
5685
|
-
const encodedTransaction =
|
5947
|
+
const encodedTransaction = hexlify16(transactionRequest.toTransactionBytes());
|
5686
5948
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5687
5949
|
encodedTransactions: encodedTransaction,
|
5688
5950
|
utxoValidation: utxoValidation || false
|
5689
5951
|
});
|
5690
5952
|
const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
|
5691
|
-
const receipts = rawReceipts.map(
|
5953
|
+
const receipts = rawReceipts.map(deserializeReceipt);
|
5692
5954
|
return { receipts, dryRunStatus };
|
5693
5955
|
}
|
5694
5956
|
/**
|
5695
|
-
*
|
5957
|
+
* Estimates the gas usage for predicates in a transaction request.
|
5696
5958
|
*
|
5697
5959
|
* @template T - The type of the transaction request object.
|
5698
5960
|
*
|
5699
|
-
* @param transactionRequest - The transaction request
|
5700
|
-
* @returns A promise that resolves to the
|
5961
|
+
* @param transactionRequest - The transaction request to estimate predicates for.
|
5962
|
+
* @returns A promise that resolves to the updated transaction request with estimated gas usage for predicates.
|
5701
5963
|
*/
|
5702
5964
|
async estimatePredicates(transactionRequest) {
|
5703
|
-
const shouldEstimatePredicates =
|
5704
|
-
|
5705
|
-
(input) => "predicate" in input && input.predicate && !equalBytes(arrayify12(input.predicate), arrayify12("0x")) && new BN2(input.predicateGasUsed).isZero()
|
5706
|
-
)
|
5965
|
+
const shouldEstimatePredicates = transactionRequest.inputs.some(
|
5966
|
+
(input) => isPredicate(input) && bn17(input.predicateGasUsed).isZero()
|
5707
5967
|
);
|
5708
5968
|
if (!shouldEstimatePredicates) {
|
5709
5969
|
return transactionRequest;
|
5710
5970
|
}
|
5711
|
-
const encodedTransaction =
|
5971
|
+
const encodedTransaction = hexlify16(transactionRequest.toTransactionBytes());
|
5712
5972
|
const response = await this.operations.estimatePredicates({
|
5713
5973
|
encodedTransaction
|
5714
5974
|
});
|
5715
|
-
const {
|
5716
|
-
|
5717
|
-
|
5718
|
-
|
5719
|
-
|
5720
|
-
if ("predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
|
5721
|
-
transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
|
5722
|
-
}
|
5723
|
-
});
|
5724
|
-
}
|
5975
|
+
const { estimatePredicates } = response;
|
5976
|
+
transactionRequest = this.parseEstimatePredicatesResponse(
|
5977
|
+
transactionRequest,
|
5978
|
+
estimatePredicates
|
5979
|
+
);
|
5725
5980
|
return transactionRequest;
|
5726
5981
|
}
|
5982
|
+
/**
|
5983
|
+
* Estimates the gas price and predicates for a given transaction request and block horizon.
|
5984
|
+
*
|
5985
|
+
* @param transactionRequest - The transaction request to estimate predicates and gas price for.
|
5986
|
+
* @param blockHorizon - The block horizon to use for gas price estimation.
|
5987
|
+
* @returns A promise that resolves to an object containing the updated transaction
|
5988
|
+
* request and the estimated gas price.
|
5989
|
+
*/
|
5990
|
+
async estimatePredicatesAndGasPrice(transactionRequest, blockHorizon) {
|
5991
|
+
const shouldEstimatePredicates = transactionRequest.inputs.some(
|
5992
|
+
(input) => isPredicate(input) && bn17(input.predicateGasUsed).isZero()
|
5993
|
+
);
|
5994
|
+
if (!shouldEstimatePredicates) {
|
5995
|
+
const gasPrice2 = await this.estimateGasPrice(blockHorizon);
|
5996
|
+
return { transactionRequest, gasPrice: gasPrice2 };
|
5997
|
+
}
|
5998
|
+
const {
|
5999
|
+
estimateGasPrice: { gasPrice },
|
6000
|
+
estimatePredicates
|
6001
|
+
} = await this.operations.estimatePredicatesAndGasPrice({
|
6002
|
+
blockHorizon: String(blockHorizon),
|
6003
|
+
encodedTransaction: hexlify16(transactionRequest.toTransactionBytes())
|
6004
|
+
});
|
6005
|
+
transactionRequest = this.parseEstimatePredicatesResponse(
|
6006
|
+
transactionRequest,
|
6007
|
+
estimatePredicates
|
6008
|
+
);
|
6009
|
+
return { transactionRequest, gasPrice: bn17(gasPrice) };
|
6010
|
+
}
|
5727
6011
|
/**
|
5728
6012
|
* Will dryRun a transaction and check for missing dependencies.
|
5729
6013
|
*
|
@@ -5737,11 +6021,13 @@ var _Provider = class {
|
|
5737
6021
|
async estimateTxDependencies(transactionRequest, { gasPrice: gasPriceParam } = {}) {
|
5738
6022
|
if (isTransactionTypeCreate(transactionRequest)) {
|
5739
6023
|
return {
|
6024
|
+
rawReceipts: [],
|
5740
6025
|
receipts: [],
|
5741
6026
|
outputVariables: 0,
|
5742
6027
|
missingContractIds: []
|
5743
6028
|
};
|
5744
6029
|
}
|
6030
|
+
let rawReceipts = [];
|
5745
6031
|
let receipts = [];
|
5746
6032
|
const missingContractIds = [];
|
5747
6033
|
let outputVariables = 0;
|
@@ -5750,13 +6036,14 @@ var _Provider = class {
|
|
5750
6036
|
const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
|
5751
6037
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
5752
6038
|
const {
|
5753
|
-
dryRun: [{ receipts:
|
6039
|
+
dryRun: [{ receipts: serializedReceipts, status }]
|
5754
6040
|
} = await this.operations.dryRun({
|
5755
|
-
encodedTransactions: [
|
6041
|
+
encodedTransactions: [hexlify16(transactionRequest.toTransactionBytes())],
|
5756
6042
|
utxoValidation: false,
|
5757
6043
|
gasPrice: gasPrice.toString()
|
5758
6044
|
});
|
5759
|
-
|
6045
|
+
rawReceipts = serializedReceipts;
|
6046
|
+
receipts = serializedReceipts.map(deserializeReceipt);
|
5760
6047
|
dryRunStatus = status;
|
5761
6048
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
|
5762
6049
|
const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
|
@@ -5777,6 +6064,7 @@ var _Provider = class {
|
|
5777
6064
|
}
|
5778
6065
|
}
|
5779
6066
|
return {
|
6067
|
+
rawReceipts,
|
5780
6068
|
receipts,
|
5781
6069
|
outputVariables,
|
5782
6070
|
missingContractIds,
|
@@ -5795,6 +6083,7 @@ var _Provider = class {
|
|
5795
6083
|
*/
|
5796
6084
|
async estimateMultipleTxDependencies(transactionRequests) {
|
5797
6085
|
const results = transactionRequests.map(() => ({
|
6086
|
+
rawReceipts: [],
|
5798
6087
|
receipts: [],
|
5799
6088
|
outputVariables: 0,
|
5800
6089
|
missingContractIds: [],
|
@@ -5804,7 +6093,7 @@ var _Provider = class {
|
|
5804
6093
|
const serializedTransactionsMap = /* @__PURE__ */ new Map();
|
5805
6094
|
allRequests.forEach((req, index) => {
|
5806
6095
|
if (isTransactionTypeScript(req)) {
|
5807
|
-
serializedTransactionsMap.set(index,
|
6096
|
+
serializedTransactionsMap.set(index, hexlify16(req.toTransactionBytes()));
|
5808
6097
|
}
|
5809
6098
|
});
|
5810
6099
|
let transactionsToProcess = Array.from(serializedTransactionsMap.keys());
|
@@ -5822,7 +6111,7 @@ var _Provider = class {
|
|
5822
6111
|
const requestIdx = transactionsToProcess[i];
|
5823
6112
|
const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
|
5824
6113
|
const result = results[requestIdx];
|
5825
|
-
result.receipts = rawReceipts.map(
|
6114
|
+
result.receipts = rawReceipts.map(deserializeReceipt);
|
5826
6115
|
result.dryRunStatus = status;
|
5827
6116
|
const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
|
5828
6117
|
result.receipts
|
@@ -5840,7 +6129,7 @@ var _Provider = class {
|
|
5840
6129
|
transactionRequest: request2
|
5841
6130
|
});
|
5842
6131
|
request2.maxFee = maxFee;
|
5843
|
-
serializedTransactionsMap.set(requestIdx,
|
6132
|
+
serializedTransactionsMap.set(requestIdx, hexlify16(request2.toTransactionBytes()));
|
5844
6133
|
nextRoundTransactions.push(requestIdx);
|
5845
6134
|
}
|
5846
6135
|
}
|
@@ -5861,13 +6150,13 @@ var _Provider = class {
|
|
5861
6150
|
if (estimateTxDependencies) {
|
5862
6151
|
return this.estimateMultipleTxDependencies(transactionRequests);
|
5863
6152
|
}
|
5864
|
-
const encodedTransactions = transactionRequests.map((tx) =>
|
6153
|
+
const encodedTransactions = transactionRequests.map((tx) => hexlify16(tx.toTransactionBytes()));
|
5865
6154
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5866
6155
|
encodedTransactions,
|
5867
6156
|
utxoValidation: utxoValidation || false
|
5868
6157
|
});
|
5869
6158
|
const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
|
5870
|
-
const receipts = rawReceipts.map(
|
6159
|
+
const receipts = rawReceipts.map(deserializeReceipt);
|
5871
6160
|
return { receipts, dryRunStatus: status };
|
5872
6161
|
});
|
5873
6162
|
return results;
|
@@ -5961,14 +6250,14 @@ var _Provider = class {
|
|
5961
6250
|
if (estimateTxDependencies) {
|
5962
6251
|
return this.estimateTxDependencies(transactionRequest);
|
5963
6252
|
}
|
5964
|
-
const encodedTransactions = [
|
6253
|
+
const encodedTransactions = [hexlify16(transactionRequest.toTransactionBytes())];
|
5965
6254
|
const { dryRun: dryRunStatuses } = await this.operations.dryRun({
|
5966
6255
|
encodedTransactions,
|
5967
6256
|
utxoValidation: true
|
5968
6257
|
});
|
5969
6258
|
const callResult = dryRunStatuses.map((dryRunStatus) => {
|
5970
6259
|
const { id, receipts, status } = dryRunStatus;
|
5971
|
-
const processedReceipts = receipts.map(
|
6260
|
+
const processedReceipts = receipts.map(deserializeReceipt);
|
5972
6261
|
return { id, receipts: processedReceipts, status };
|
5973
6262
|
});
|
5974
6263
|
return { receipts: callResult[0].receipts };
|
@@ -5999,14 +6288,20 @@ var _Provider = class {
|
|
5999
6288
|
await signatureCallback(signedRequest);
|
6000
6289
|
addedSignatures = signedRequest.witnesses.length - lengthBefore;
|
6001
6290
|
}
|
6002
|
-
|
6291
|
+
let gasPrice;
|
6292
|
+
if (gasPriceParam) {
|
6293
|
+
gasPrice = gasPriceParam;
|
6294
|
+
await this.estimatePredicates(signedRequest);
|
6295
|
+
} else {
|
6296
|
+
({ gasPrice } = await this.estimatePredicatesAndGasPrice(signedRequest, 10));
|
6297
|
+
}
|
6003
6298
|
txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
|
6004
|
-
const gasPrice = gasPriceParam ?? await this.estimateGasPrice(10);
|
6005
6299
|
let { maxFee, maxGas, minFee, minGas, gasLimit } = await this.estimateTxGasAndFee({
|
6006
6300
|
// Fetches and returns a gas price
|
6007
6301
|
transactionRequest: signedRequest,
|
6008
6302
|
gasPrice
|
6009
6303
|
});
|
6304
|
+
let rawReceipts = [];
|
6010
6305
|
let receipts = [];
|
6011
6306
|
let dryRunStatus;
|
6012
6307
|
let missingContractIds = [];
|
@@ -6018,7 +6313,7 @@ var _Provider = class {
|
|
6018
6313
|
if (signatureCallback) {
|
6019
6314
|
await signatureCallback(txRequestClone);
|
6020
6315
|
}
|
6021
|
-
({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
|
6316
|
+
({ rawReceipts, receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone, { gasPrice }));
|
6022
6317
|
if (dryRunStatus && "reason" in dryRunStatus) {
|
6023
6318
|
throw this.extractDryRunError(txRequestClone, receipts, dryRunStatus);
|
6024
6319
|
}
|
@@ -6031,7 +6326,12 @@ var _Provider = class {
|
|
6031
6326
|
gasPrice
|
6032
6327
|
}));
|
6033
6328
|
}
|
6329
|
+
const transactionSummary = {
|
6330
|
+
gasPrice: gasPrice.toString(),
|
6331
|
+
receipts: rawReceipts
|
6332
|
+
};
|
6034
6333
|
return {
|
6334
|
+
rawReceipts,
|
6035
6335
|
receipts,
|
6036
6336
|
gasUsed,
|
6037
6337
|
gasPrice,
|
@@ -6044,7 +6344,8 @@ var _Provider = class {
|
|
6044
6344
|
addedSignatures,
|
6045
6345
|
estimatedPredicates: txRequestClone.inputs,
|
6046
6346
|
dryRunStatus,
|
6047
|
-
updateMaxFee
|
6347
|
+
updateMaxFee,
|
6348
|
+
transactionSummary
|
6048
6349
|
};
|
6049
6350
|
}
|
6050
6351
|
/**
|
@@ -6065,7 +6366,7 @@ var _Provider = class {
|
|
6065
6366
|
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
|
6066
6367
|
inputArgs: paginationArgs
|
6067
6368
|
}),
|
6068
|
-
filter: { owner: ownerAddress.toB256(), assetId: assetId &&
|
6369
|
+
filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify16(assetId) }
|
6069
6370
|
});
|
6070
6371
|
const coins = edges.map(({ node }) => ({
|
6071
6372
|
id: node.utxoId,
|
@@ -6090,23 +6391,33 @@ var _Provider = class {
|
|
6090
6391
|
*/
|
6091
6392
|
async getResourcesToSpend(owner, quantities, excludedIds) {
|
6092
6393
|
const ownerAddress = new Address2(owner);
|
6093
|
-
|
6094
|
-
messages: excludedIds?.messages?.map((nonce) =>
|
6095
|
-
utxos: excludedIds?.utxos?.map((id) =>
|
6394
|
+
let idsToExclude = {
|
6395
|
+
messages: excludedIds?.messages?.map((nonce) => hexlify16(nonce)) || [],
|
6396
|
+
utxos: excludedIds?.utxos?.map((id) => hexlify16(id)) || []
|
6096
6397
|
};
|
6097
6398
|
if (this.cache) {
|
6098
|
-
const cached = this.cache.getActiveData();
|
6099
|
-
|
6100
|
-
|
6399
|
+
const cached = this.cache.getActiveData(ownerAddress.toB256());
|
6400
|
+
if (cached.utxos.length || cached.messages.length) {
|
6401
|
+
const {
|
6402
|
+
consensusParameters: {
|
6403
|
+
txParameters: { maxInputs }
|
6404
|
+
}
|
6405
|
+
} = await this.getChain();
|
6406
|
+
idsToExclude = adjustResourcesToExclude({
|
6407
|
+
userInput: idsToExclude,
|
6408
|
+
cached,
|
6409
|
+
maxInputs: maxInputs.toNumber()
|
6410
|
+
});
|
6411
|
+
}
|
6101
6412
|
}
|
6102
6413
|
const coinsQuery = {
|
6103
6414
|
owner: ownerAddress.toB256(),
|
6104
6415
|
queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
|
6105
|
-
assetId:
|
6106
|
-
amount: amount.toString(10),
|
6416
|
+
assetId: hexlify16(assetId),
|
6417
|
+
amount: (amount.eqn(0) ? bn17(1) : amount).toString(10),
|
6107
6418
|
max: maxPerAsset ? maxPerAsset.toString(10) : void 0
|
6108
6419
|
})),
|
6109
|
-
excludedIds:
|
6420
|
+
excludedIds: idsToExclude
|
6110
6421
|
};
|
6111
6422
|
const result = await this.operations.getCoinsToSpend(coinsQuery);
|
6112
6423
|
const coins = result.coinsToSpend.flat().map((coin) => {
|
@@ -6164,7 +6475,7 @@ var _Provider = class {
|
|
6164
6475
|
} = await this.operations.getLatestBlock();
|
6165
6476
|
block = latestBlock;
|
6166
6477
|
} else {
|
6167
|
-
const isblockId = typeof idOrHeight === "string" && idOrHeight
|
6478
|
+
const isblockId = typeof idOrHeight === "string" && isB256(idOrHeight);
|
6168
6479
|
const variables = isblockId ? { blockId: idOrHeight } : { height: bn17(idOrHeight).toString(10) };
|
6169
6480
|
const response = await this.operations.getBlock(variables);
|
6170
6481
|
block = response.block;
|
@@ -6235,8 +6546,10 @@ var _Provider = class {
|
|
6235
6546
|
variables = { blockHeight: bn17(idOrHeight).toString(10) };
|
6236
6547
|
} else if (idOrHeight === "latest") {
|
6237
6548
|
variables = { blockHeight: (await this.getBlockNumber()).toString() };
|
6238
|
-
} else {
|
6549
|
+
} else if (typeof idOrHeight === "string" && isB256(idOrHeight)) {
|
6239
6550
|
variables = { blockId: idOrHeight };
|
6551
|
+
} else {
|
6552
|
+
variables = { blockHeight: bn17(idOrHeight).toString() };
|
6240
6553
|
}
|
6241
6554
|
const { block } = await this.operations.getBlockWithTransactions(variables);
|
6242
6555
|
if (!block) {
|
@@ -6279,7 +6592,7 @@ var _Provider = class {
|
|
6279
6592
|
0
|
6280
6593
|
)?.[0];
|
6281
6594
|
} catch (error) {
|
6282
|
-
if (error instanceof
|
6595
|
+
if (error instanceof FuelError19 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
6283
6596
|
console.warn("Unsupported transaction type encountered");
|
6284
6597
|
return null;
|
6285
6598
|
}
|
@@ -6305,7 +6618,7 @@ var _Provider = class {
|
|
6305
6618
|
try {
|
6306
6619
|
return coder.decode(arrayify12(rawPayload), 0)[0];
|
6307
6620
|
} catch (error) {
|
6308
|
-
if (error instanceof
|
6621
|
+
if (error instanceof FuelError19 && error.code === ErrorCode16.UNSUPPORTED_TRANSACTION_TYPE) {
|
6309
6622
|
console.warn("Unsupported transaction type encountered");
|
6310
6623
|
return null;
|
6311
6624
|
}
|
@@ -6352,7 +6665,7 @@ var _Provider = class {
|
|
6352
6665
|
async getContractBalance(contractId, assetId) {
|
6353
6666
|
const { contractBalance } = await this.operations.getContractBalance({
|
6354
6667
|
contract: new Address2(contractId).toB256(),
|
6355
|
-
asset:
|
6668
|
+
asset: hexlify16(assetId)
|
6356
6669
|
});
|
6357
6670
|
return bn17(contractBalance.amount, 10);
|
6358
6671
|
}
|
@@ -6364,11 +6677,20 @@ var _Provider = class {
|
|
6364
6677
|
* @returns A promise that resolves to the balance.
|
6365
6678
|
*/
|
6366
6679
|
async getBalance(owner, assetId) {
|
6367
|
-
const
|
6368
|
-
|
6369
|
-
|
6680
|
+
const ownerStr = new Address2(owner).toB256();
|
6681
|
+
const assetIdStr = hexlify16(assetId);
|
6682
|
+
if (!this.features.amount128) {
|
6683
|
+
const { balance: balance2 } = await this.operations.getBalance({
|
6684
|
+
owner: ownerStr,
|
6685
|
+
assetId: assetIdStr
|
6686
|
+
});
|
6687
|
+
return bn17(balance2.amount, 10);
|
6688
|
+
}
|
6689
|
+
const { balance } = await this.operations.getBalanceV2({
|
6690
|
+
owner: ownerStr,
|
6691
|
+
assetId: assetIdStr
|
6370
6692
|
});
|
6371
|
-
return bn17(balance.
|
6693
|
+
return bn17(balance.amountU128, 10);
|
6372
6694
|
}
|
6373
6695
|
/**
|
6374
6696
|
* Returns balances for the given owner.
|
@@ -6377,7 +6699,16 @@ var _Provider = class {
|
|
6377
6699
|
* @param paginationArgs - Pagination arguments (optional).
|
6378
6700
|
* @returns A promise that resolves to the balances.
|
6379
6701
|
*/
|
6380
|
-
async getBalances(owner) {
|
6702
|
+
async getBalances(owner, paginationArgs) {
|
6703
|
+
if (!this.features.balancePagination) {
|
6704
|
+
return this.getBalancesV1(owner, paginationArgs);
|
6705
|
+
}
|
6706
|
+
return this.getBalancesV2(owner, paginationArgs);
|
6707
|
+
}
|
6708
|
+
/**
|
6709
|
+
* @hidden
|
6710
|
+
*/
|
6711
|
+
async getBalancesV1(owner, _paginationArgs) {
|
6381
6712
|
const {
|
6382
6713
|
balances: { edges }
|
6383
6714
|
} = await this.operations.getBalances({
|
@@ -6394,6 +6725,25 @@ var _Provider = class {
|
|
6394
6725
|
}));
|
6395
6726
|
return { balances };
|
6396
6727
|
}
|
6728
|
+
/**
|
6729
|
+
* @hidden
|
6730
|
+
*/
|
6731
|
+
async getBalancesV2(owner, paginationArgs) {
|
6732
|
+
const {
|
6733
|
+
balances: { edges, pageInfo }
|
6734
|
+
} = await this.operations.getBalancesV2({
|
6735
|
+
...validatePaginationArgs({
|
6736
|
+
inputArgs: paginationArgs,
|
6737
|
+
paginationLimit: BALANCES_PAGE_SIZE_LIMIT
|
6738
|
+
}),
|
6739
|
+
filter: { owner: new Address2(owner).toB256() }
|
6740
|
+
});
|
6741
|
+
const balances = edges.map(({ node }) => ({
|
6742
|
+
assetId: node.assetId,
|
6743
|
+
amount: bn17(node.amountU128)
|
6744
|
+
}));
|
6745
|
+
return { balances, pageInfo };
|
6746
|
+
}
|
6397
6747
|
/**
|
6398
6748
|
* Returns message for the given address.
|
6399
6749
|
*
|
@@ -6446,7 +6796,7 @@ var _Provider = class {
|
|
6446
6796
|
nonce
|
6447
6797
|
};
|
6448
6798
|
if (commitBlockId && commitBlockHeight) {
|
6449
|
-
throw new
|
6799
|
+
throw new FuelError19(
|
6450
6800
|
ErrorCode16.INVALID_INPUT_PARAMETERS,
|
6451
6801
|
"commitBlockId and commitBlockHeight cannot be used together"
|
6452
6802
|
);
|
@@ -6460,15 +6810,12 @@ var _Provider = class {
|
|
6460
6810
|
if (commitBlockHeight) {
|
6461
6811
|
inputObject = {
|
6462
6812
|
...inputObject,
|
6463
|
-
//
|
6464
|
-
// This should
|
6813
|
+
// Convert BN into a number string required on the query
|
6814
|
+
// This should probably be fixed on the fuel client side
|
6465
6815
|
commitBlockHeight: commitBlockHeight.toNumber().toString()
|
6466
6816
|
};
|
6467
6817
|
}
|
6468
6818
|
const result = await this.operations.getMessageProof(inputObject);
|
6469
|
-
if (!result.messageProof) {
|
6470
|
-
return null;
|
6471
|
-
}
|
6472
6819
|
const {
|
6473
6820
|
messageProof,
|
6474
6821
|
messageBlockHeader,
|
@@ -6577,16 +6924,15 @@ var _Provider = class {
|
|
6577
6924
|
* @returns A promise that resolves to the result of the check.
|
6578
6925
|
*/
|
6579
6926
|
async isUserAccount(id) {
|
6580
|
-
const
|
6581
|
-
|
6582
|
-
contractId: id,
|
6583
|
-
transactionId: id
|
6584
|
-
});
|
6585
|
-
if (contract || blob || transaction) {
|
6586
|
-
return false;
|
6587
|
-
}
|
6588
|
-
return true;
|
6927
|
+
const type = await this.getAddressType(id);
|
6928
|
+
return type === "Account";
|
6589
6929
|
}
|
6930
|
+
/**
|
6931
|
+
* Determines the type of address based on the provided ID.
|
6932
|
+
*
|
6933
|
+
* @param id - The ID to be checked.
|
6934
|
+
* @returns A promise that resolves to a string indicating the type of address.
|
6935
|
+
*/
|
6590
6936
|
async getAddressType(id) {
|
6591
6937
|
const { contract, blob, transaction } = await this.operations.isUserAccount({
|
6592
6938
|
blobId: id,
|
@@ -6602,6 +6948,13 @@ var _Provider = class {
|
|
6602
6948
|
if (transaction) {
|
6603
6949
|
return "Transaction";
|
6604
6950
|
}
|
6951
|
+
try {
|
6952
|
+
const asset = await this.getAssetDetails(id);
|
6953
|
+
if (asset) {
|
6954
|
+
return "Asset";
|
6955
|
+
}
|
6956
|
+
} catch (e) {
|
6957
|
+
}
|
6605
6958
|
return "Account";
|
6606
6959
|
}
|
6607
6960
|
/**
|
@@ -6676,6 +7029,19 @@ var _Provider = class {
|
|
6676
7029
|
statusReason: status.reason
|
6677
7030
|
});
|
6678
7031
|
}
|
7032
|
+
/**
|
7033
|
+
* @hidden
|
7034
|
+
*/
|
7035
|
+
parseEstimatePredicatesResponse(transactionRequest, { inputs }) {
|
7036
|
+
if (inputs) {
|
7037
|
+
inputs.forEach((input, i) => {
|
7038
|
+
if (input && "predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
|
7039
|
+
transactionRequest.inputs[i].predicateGasUsed = input.predicateGasUsed;
|
7040
|
+
}
|
7041
|
+
});
|
7042
|
+
}
|
7043
|
+
return transactionRequest;
|
7044
|
+
}
|
6679
7045
|
};
|
6680
7046
|
var Provider = _Provider;
|
6681
7047
|
_cacheInputs = new WeakSet();
|
@@ -6683,20 +7049,11 @@ cacheInputs_fn = function(inputs, transactionId) {
|
|
6683
7049
|
if (!this.cache) {
|
6684
7050
|
return;
|
6685
7051
|
}
|
6686
|
-
|
6687
|
-
(acc, input) => {
|
6688
|
-
if (input.type === InputType7.Coin) {
|
6689
|
-
acc.utxos.push(input.id);
|
6690
|
-
} else if (input.type === InputType7.Message) {
|
6691
|
-
acc.messages.push(input.nonce);
|
6692
|
-
}
|
6693
|
-
return acc;
|
6694
|
-
},
|
6695
|
-
{ utxos: [], messages: [] }
|
6696
|
-
);
|
6697
|
-
this.cache.set(transactionId, inputsToCache);
|
7052
|
+
this.cache.set(transactionId, inputs);
|
6698
7053
|
};
|
6699
7054
|
/** @hidden */
|
7055
|
+
__publicField(Provider, "inflightFetchChainAndNodeInfoRequests", {});
|
7056
|
+
/** @hidden */
|
6700
7057
|
__publicField(Provider, "chainInfoCache", {});
|
6701
7058
|
/** @hidden */
|
6702
7059
|
__publicField(Provider, "nodeInfoCache", {});
|
@@ -6704,7 +7061,7 @@ __publicField(Provider, "nodeInfoCache", {});
|
|
6704
7061
|
__publicField(Provider, "incompatibleNodeVersionMessage", "");
|
6705
7062
|
|
6706
7063
|
// src/providers/transaction-summary/get-transaction-summary.ts
|
6707
|
-
import { ErrorCode as ErrorCode17, FuelError as
|
7064
|
+
import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
|
6708
7065
|
import { bn as bn18 } from "@fuel-ts/math";
|
6709
7066
|
import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
|
6710
7067
|
import { arrayify as arrayify13 } from "@fuel-ts/utils";
|
@@ -6714,7 +7071,7 @@ async function getTransactionSummary(params) {
|
|
6714
7071
|
transactionId: id
|
6715
7072
|
});
|
6716
7073
|
if (!gqlTransaction) {
|
6717
|
-
throw new
|
7074
|
+
throw new FuelError20(
|
6718
7075
|
ErrorCode17.TRANSACTION_NOT_FOUND,
|
6719
7076
|
`Transaction not found for given id: ${id}.`
|
6720
7077
|
);
|
@@ -6727,7 +7084,7 @@ async function getTransactionSummary(params) {
|
|
6727
7084
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
6728
7085
|
txReceipts = gqlTransaction.status.receipts;
|
6729
7086
|
}
|
6730
|
-
const receipts = txReceipts.map(
|
7087
|
+
const receipts = txReceipts.map(deserializeReceipt);
|
6731
7088
|
const {
|
6732
7089
|
consensusParameters: {
|
6733
7090
|
feeParameters: { gasPerByte, gasPriceFactor },
|
@@ -6811,7 +7168,7 @@ async function getTransactionsSummaries(params) {
|
|
6811
7168
|
if (gqlTransaction?.status && "receipts" in gqlTransaction.status) {
|
6812
7169
|
txReceipts = gqlTransaction.status.receipts;
|
6813
7170
|
}
|
6814
|
-
const receipts = txReceipts.map(
|
7171
|
+
const receipts = txReceipts.map(deserializeReceipt);
|
6815
7172
|
const transactionSummary = assembleTransactionSummary({
|
6816
7173
|
id,
|
6817
7174
|
receipts,
|
@@ -6838,6 +7195,39 @@ async function getTransactionsSummaries(params) {
|
|
6838
7195
|
};
|
6839
7196
|
}
|
6840
7197
|
|
7198
|
+
// src/providers/transaction-summary/assemble-transaction-summary-from-serialized.ts
|
7199
|
+
import { bn as bn19 } from "@fuel-ts/math";
|
7200
|
+
import { TransactionCoder as TransactionCoder7 } from "@fuel-ts/transactions";
|
7201
|
+
import { arrayify as arrayify14 } from "@fuel-ts/utils";
|
7202
|
+
var assembleTransactionSummaryFromJson = async (opts) => {
|
7203
|
+
const { provider, transactionSummary } = opts;
|
7204
|
+
const { id, transactionBytes, gasPrice, receipts } = transactionSummary;
|
7205
|
+
const {
|
7206
|
+
consensusParameters: {
|
7207
|
+
baseAssetId,
|
7208
|
+
txParameters: { maxInputs, maxGasPerTx },
|
7209
|
+
feeParameters: { gasPriceFactor, gasPerByte },
|
7210
|
+
gasCosts
|
7211
|
+
}
|
7212
|
+
} = await provider.getChain();
|
7213
|
+
const deserializedTransactionBytes = arrayify14(transactionBytes);
|
7214
|
+
const [transaction] = new TransactionCoder7().decode(deserializedTransactionBytes, 0);
|
7215
|
+
return assembleTransactionSummary({
|
7216
|
+
id,
|
7217
|
+
transaction,
|
7218
|
+
transactionBytes: deserializedTransactionBytes,
|
7219
|
+
receipts: receipts.map(deserializeReceipt),
|
7220
|
+
gasPrice: bn19(gasPrice),
|
7221
|
+
// From chain
|
7222
|
+
baseAssetId,
|
7223
|
+
maxInputs,
|
7224
|
+
gasCosts,
|
7225
|
+
maxGasPerTx,
|
7226
|
+
gasPerByte,
|
7227
|
+
gasPriceFactor
|
7228
|
+
});
|
7229
|
+
};
|
7230
|
+
|
6841
7231
|
// src/providers/utils/merge-quantities.ts
|
6842
7232
|
var mergeQuantities = (...coinQuantities) => {
|
6843
7233
|
const resultMap = {};
|
@@ -6859,14 +7249,14 @@ var AbstractAccount = class {
|
|
6859
7249
|
// src/utils/formatTransferToContractScriptData.ts
|
6860
7250
|
import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
|
6861
7251
|
import { Address as Address3 } from "@fuel-ts/address";
|
6862
|
-
import { arrayify as
|
7252
|
+
import { arrayify as arrayify15, concat as concat3 } from "@fuel-ts/utils";
|
6863
7253
|
import * as asm from "@fuels/vm-asm";
|
6864
7254
|
var formatTransferToContractScriptData = (transferParams) => {
|
6865
7255
|
const numberCoder = new BigNumberCoder2("u64");
|
6866
7256
|
return transferParams.reduce((acc, transferParam) => {
|
6867
7257
|
const { assetId, amount, contractId } = transferParam;
|
6868
7258
|
const encoded = numberCoder.encode(amount);
|
6869
|
-
const scriptData = concat3([new Address3(contractId).toBytes(), encoded,
|
7259
|
+
const scriptData = concat3([new Address3(contractId).toBytes(), encoded, arrayify15(assetId)]);
|
6870
7260
|
return concat3([acc, scriptData]);
|
6871
7261
|
}, new Uint8Array());
|
6872
7262
|
};
|
@@ -6933,7 +7323,7 @@ var Account = class extends AbstractAccount {
|
|
6933
7323
|
*/
|
6934
7324
|
get provider() {
|
6935
7325
|
if (!this._provider) {
|
6936
|
-
throw new
|
7326
|
+
throw new FuelError21(ErrorCode18.MISSING_PROVIDER, "Provider not set");
|
6937
7327
|
}
|
6938
7328
|
return this._provider;
|
6939
7329
|
}
|
@@ -7010,12 +7400,20 @@ var Account = class extends AbstractAccount {
|
|
7010
7400
|
* @returns A promise that resolves to the funded transaction request.
|
7011
7401
|
*/
|
7012
7402
|
async fund(request2, params) {
|
7013
|
-
const {
|
7403
|
+
const {
|
7404
|
+
addedSignatures,
|
7405
|
+
estimatedPredicates,
|
7406
|
+
requiredQuantities,
|
7407
|
+
updateMaxFee,
|
7408
|
+
gasPrice,
|
7409
|
+
transactionSummary
|
7410
|
+
} = params;
|
7411
|
+
const chainId = await this.provider.getChainId();
|
7014
7412
|
const fee = request2.maxFee;
|
7015
7413
|
const baseAssetId = await this.provider.getBaseAssetId();
|
7016
|
-
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount ||
|
7414
|
+
const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn20(0);
|
7017
7415
|
const requiredQuantitiesWithFee = addAmountToCoinQuantities({
|
7018
|
-
amount:
|
7416
|
+
amount: bn20(fee),
|
7019
7417
|
assetId: baseAssetId,
|
7020
7418
|
coinQuantities: requiredQuantities
|
7021
7419
|
});
|
@@ -7023,7 +7421,7 @@ var Account = class extends AbstractAccount {
|
|
7023
7421
|
requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
|
7024
7422
|
quantitiesDict[assetId] = {
|
7025
7423
|
required: amount,
|
7026
|
-
owned:
|
7424
|
+
owned: bn20(0)
|
7027
7425
|
};
|
7028
7426
|
});
|
7029
7427
|
request2.inputs.filter(isRequestInputResource).forEach((input) => {
|
@@ -7084,11 +7482,12 @@ var Account = class extends AbstractAccount {
|
|
7084
7482
|
fundingAttempts += 1;
|
7085
7483
|
}
|
7086
7484
|
if (needsToBeFunded) {
|
7087
|
-
throw new
|
7088
|
-
ErrorCode18.
|
7485
|
+
throw new FuelError21(
|
7486
|
+
ErrorCode18.INSUFFICIENT_FUNDS_OR_MAX_COINS,
|
7089
7487
|
`The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
|
7090
7488
|
);
|
7091
7489
|
}
|
7490
|
+
request2.updateState(chainId, "funded", transactionSummary);
|
7092
7491
|
await this.provider.validateTransaction(request2);
|
7093
7492
|
request2.updatePredicateGasUsed(estimatedPredicates);
|
7094
7493
|
const requestToReestimate = clone9(request2);
|
@@ -7199,11 +7598,11 @@ var Account = class extends AbstractAccount {
|
|
7199
7598
|
const quantities = [];
|
7200
7599
|
const defaultAssetId = await this.provider.getBaseAssetId();
|
7201
7600
|
const transferParams = contractTransferParams.map((transferParam) => {
|
7202
|
-
const amount =
|
7601
|
+
const amount = bn20(transferParam.amount);
|
7203
7602
|
const contractAddress = new Address4(transferParam.contractId);
|
7204
|
-
const assetId = transferParam.assetId ?
|
7603
|
+
const assetId = transferParam.assetId ? hexlify17(transferParam.assetId) : defaultAssetId;
|
7205
7604
|
if (amount.lte(0)) {
|
7206
|
-
throw new
|
7605
|
+
throw new FuelError21(
|
7207
7606
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
7208
7607
|
"Transfer amount must be a positive number."
|
7209
7608
|
);
|
@@ -7232,21 +7631,21 @@ var Account = class extends AbstractAccount {
|
|
7232
7631
|
*/
|
7233
7632
|
async withdrawToBaseLayer(recipient, amount, txParams = {}) {
|
7234
7633
|
const recipientAddress = new Address4(recipient);
|
7235
|
-
const recipientDataArray =
|
7634
|
+
const recipientDataArray = arrayify16(
|
7236
7635
|
"0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
|
7237
7636
|
);
|
7238
|
-
const amountDataArray =
|
7239
|
-
"0x".concat(
|
7637
|
+
const amountDataArray = arrayify16(
|
7638
|
+
"0x".concat(bn20(amount).toHex().substring(2).padStart(16, "0"))
|
7240
7639
|
);
|
7241
7640
|
const script = new Uint8Array([
|
7242
|
-
...
|
7641
|
+
...arrayify16(withdrawScript.bytes),
|
7243
7642
|
...recipientDataArray,
|
7244
7643
|
...amountDataArray
|
7245
7644
|
]);
|
7246
7645
|
const params = { script, ...txParams };
|
7247
7646
|
const baseAssetId = await this.provider.getBaseAssetId();
|
7248
7647
|
let request2 = new ScriptTransactionRequest(params);
|
7249
|
-
const quantities = [{ amount:
|
7648
|
+
const quantities = [{ amount: bn20(amount), assetId: baseAssetId }];
|
7250
7649
|
const txCost = await this.getTransactionCost(request2, { quantities });
|
7251
7650
|
request2 = this.validateGasLimitAndMaxFee({
|
7252
7651
|
transactionRequest: request2,
|
@@ -7272,9 +7671,9 @@ var Account = class extends AbstractAccount {
|
|
7272
7671
|
const baseAssetId = await this.provider.getBaseAssetId();
|
7273
7672
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
7274
7673
|
const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
|
7275
|
-
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount:
|
7674
|
+
const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn20("100000000000000000") }];
|
7276
7675
|
const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
|
7277
|
-
if (input.type ===
|
7676
|
+
if (input.type === InputType7.Coin) {
|
7278
7677
|
return input.assetId === assetId;
|
7279
7678
|
}
|
7280
7679
|
if (isRequestInputMessageWithoutData(input)) {
|
@@ -7320,7 +7719,7 @@ var Account = class extends AbstractAccount {
|
|
7320
7719
|
*/
|
7321
7720
|
async signMessage(message) {
|
7322
7721
|
if (!this._connector) {
|
7323
|
-
throw new
|
7722
|
+
throw new FuelError21(ErrorCode18.MISSING_CONNECTOR, "A connector is required to sign messages.");
|
7324
7723
|
}
|
7325
7724
|
return this._connector.signMessage(this.address.toString(), message);
|
7326
7725
|
}
|
@@ -7332,7 +7731,7 @@ var Account = class extends AbstractAccount {
|
|
7332
7731
|
*/
|
7333
7732
|
async signTransaction(transactionRequestLike) {
|
7334
7733
|
if (!this._connector) {
|
7335
|
-
throw new
|
7734
|
+
throw new FuelError21(
|
7336
7735
|
ErrorCode18.MISSING_CONNECTOR,
|
7337
7736
|
"A connector is required to sign transactions."
|
7338
7737
|
);
|
@@ -7346,16 +7745,28 @@ var Account = class extends AbstractAccount {
|
|
7346
7745
|
* @param sendTransactionParams - The provider send transaction parameters (optional).
|
7347
7746
|
* @returns A promise that resolves to the transaction response.
|
7348
7747
|
*/
|
7349
|
-
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true,
|
7748
|
+
async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, ...connectorOptions } = {}) {
|
7749
|
+
let transactionRequest = transactionRequestify(transactionRequestLike);
|
7350
7750
|
if (this._connector) {
|
7351
|
-
|
7352
|
-
|
7353
|
-
|
7354
|
-
|
7355
|
-
|
7751
|
+
const { onBeforeSend, skipCustomFee = false } = connectorOptions;
|
7752
|
+
transactionRequest = await this.prepareTransactionForSend(transactionRequest);
|
7753
|
+
const params = {
|
7754
|
+
onBeforeSend,
|
7755
|
+
skipCustomFee,
|
7756
|
+
provider: {
|
7757
|
+
url: this.provider.url,
|
7758
|
+
cache: await serializeProviderCache(this.provider)
|
7759
|
+
},
|
7760
|
+
transactionState: transactionRequest.flag.state,
|
7761
|
+
transactionSummary: await this.prepareTransactionSummary(transactionRequest)
|
7762
|
+
};
|
7763
|
+
const transaction = await this._connector.sendTransaction(
|
7764
|
+
this.address.toString(),
|
7765
|
+
transactionRequest,
|
7766
|
+
params
|
7356
7767
|
);
|
7768
|
+
return typeof transaction === "string" ? this.provider.getTransactionResponse(transaction) : transaction;
|
7357
7769
|
}
|
7358
|
-
const transactionRequest = transactionRequestify(transactionRequestLike);
|
7359
7770
|
if (estimateTxDependencies) {
|
7360
7771
|
await this.provider.estimateTxDependencies(transactionRequest);
|
7361
7772
|
}
|
@@ -7385,17 +7796,39 @@ var Account = class extends AbstractAccount {
|
|
7385
7796
|
*/
|
7386
7797
|
generateFakeResources(coins) {
|
7387
7798
|
return coins.map((coin) => ({
|
7388
|
-
id:
|
7799
|
+
id: hexlify17(randomBytes2(UTXO_ID_LEN3)),
|
7389
7800
|
owner: this.address,
|
7390
|
-
blockCreated:
|
7391
|
-
txCreatedIdx:
|
7801
|
+
blockCreated: bn20(1),
|
7802
|
+
txCreatedIdx: bn20(1),
|
7392
7803
|
...coin
|
7393
7804
|
}));
|
7394
7805
|
}
|
7806
|
+
/** @hidden */
|
7807
|
+
async prepareTransactionForSend(request2) {
|
7808
|
+
const { transactionId } = request2.flag;
|
7809
|
+
if (!isDefined3(transactionId)) {
|
7810
|
+
return request2;
|
7811
|
+
}
|
7812
|
+
const chainId = await this.provider.getChainId();
|
7813
|
+
const currentTransactionId = request2.getTransactionId(chainId);
|
7814
|
+
if (transactionId !== currentTransactionId) {
|
7815
|
+
request2.updateState(chainId);
|
7816
|
+
}
|
7817
|
+
return request2;
|
7818
|
+
}
|
7819
|
+
/** @hidden */
|
7820
|
+
async prepareTransactionSummary(request2) {
|
7821
|
+
const chainId = await this.provider.getChainId();
|
7822
|
+
return isDefined3(request2.flag.summary) ? {
|
7823
|
+
...request2.flag.summary,
|
7824
|
+
id: request2.getTransactionId(chainId),
|
7825
|
+
transactionBytes: hexlify17(request2.toTransactionBytes())
|
7826
|
+
} : void 0;
|
7827
|
+
}
|
7395
7828
|
/** @hidden * */
|
7396
7829
|
validateTransferAmount(amount) {
|
7397
|
-
if (
|
7398
|
-
throw new
|
7830
|
+
if (bn20(amount).lte(0)) {
|
7831
|
+
throw new FuelError21(
|
7399
7832
|
ErrorCode18.INVALID_TRANSFER_AMOUNT,
|
7400
7833
|
"Transfer amount must be a positive number."
|
7401
7834
|
);
|
@@ -7425,7 +7858,7 @@ var Account = class extends AbstractAccount {
|
|
7425
7858
|
if (!isDefined3(setGasLimit)) {
|
7426
7859
|
request2.gasLimit = gasUsed;
|
7427
7860
|
} else if (gasUsed.gt(setGasLimit)) {
|
7428
|
-
throw new
|
7861
|
+
throw new FuelError21(
|
7429
7862
|
ErrorCode18.GAS_LIMIT_TOO_LOW,
|
7430
7863
|
`Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
|
7431
7864
|
);
|
@@ -7433,7 +7866,7 @@ var Account = class extends AbstractAccount {
|
|
7433
7866
|
if (!isDefined3(setMaxFee)) {
|
7434
7867
|
request2.maxFee = maxFee;
|
7435
7868
|
} else if (maxFee.gt(setMaxFee)) {
|
7436
|
-
throw new
|
7869
|
+
throw new FuelError21(
|
7437
7870
|
ErrorCode18.MAX_FEE_TOO_LOW,
|
7438
7871
|
`Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
|
7439
7872
|
);
|
@@ -7444,14 +7877,14 @@ var Account = class extends AbstractAccount {
|
|
7444
7877
|
|
7445
7878
|
// src/wallet/base-wallet-unlocked.ts
|
7446
7879
|
import { hashMessage } from "@fuel-ts/hasher";
|
7447
|
-
import { hexlify as
|
7880
|
+
import { hexlify as hexlify20 } from "@fuel-ts/utils";
|
7448
7881
|
|
7449
7882
|
// src/signer/signer.ts
|
7450
7883
|
import { Address as Address5 } from "@fuel-ts/address";
|
7451
7884
|
import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
|
7452
7885
|
import { hash as hash2 } from "@fuel-ts/hasher";
|
7453
7886
|
import { toBytes } from "@fuel-ts/math";
|
7454
|
-
import { hexlify as
|
7887
|
+
import { hexlify as hexlify18, concat as concat4, arrayify as arrayify17 } from "@fuel-ts/utils";
|
7455
7888
|
import { secp256k1 } from "@noble/curves/secp256k1";
|
7456
7889
|
var Signer = class {
|
7457
7890
|
address;
|
@@ -7471,9 +7904,9 @@ var Signer = class {
|
|
7471
7904
|
}
|
7472
7905
|
}
|
7473
7906
|
const privateKeyBytes = toBytes(privateKey, 32);
|
7474
|
-
this.privateKey =
|
7475
|
-
this.publicKey =
|
7476
|
-
this.compressedPublicKey =
|
7907
|
+
this.privateKey = hexlify18(privateKeyBytes);
|
7908
|
+
this.publicKey = hexlify18(secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
|
7909
|
+
this.compressedPublicKey = hexlify18(secp256k1.getPublicKey(privateKeyBytes, true));
|
7477
7910
|
this.address = new Address5(this.publicKey);
|
7478
7911
|
}
|
7479
7912
|
/**
|
@@ -7487,11 +7920,11 @@ var Signer = class {
|
|
7487
7920
|
* @returns hashed signature
|
7488
7921
|
*/
|
7489
7922
|
sign(data) {
|
7490
|
-
const signature = secp256k1.sign(
|
7923
|
+
const signature = secp256k1.sign(arrayify17(data), arrayify17(this.privateKey));
|
7491
7924
|
const r = toBytes(`0x${signature.r.toString(16)}`, 32);
|
7492
7925
|
const s = toBytes(`0x${signature.s.toString(16)}`, 32);
|
7493
7926
|
s[0] |= (signature.recovery || 0) << 7;
|
7494
|
-
return
|
7927
|
+
return hexlify18(concat4([r, s]));
|
7495
7928
|
}
|
7496
7929
|
/**
|
7497
7930
|
* Add point on the current elliptic curve
|
@@ -7500,8 +7933,8 @@ var Signer = class {
|
|
7500
7933
|
* @returns compressed point on the curve
|
7501
7934
|
*/
|
7502
7935
|
addPoint(point) {
|
7503
|
-
const p0 = secp256k1.ProjectivePoint.fromHex(
|
7504
|
-
const p1 = secp256k1.ProjectivePoint.fromHex(
|
7936
|
+
const p0 = secp256k1.ProjectivePoint.fromHex(arrayify17(this.compressedPublicKey));
|
7937
|
+
const p1 = secp256k1.ProjectivePoint.fromHex(arrayify17(point));
|
7505
7938
|
const result = p0.add(p1);
|
7506
7939
|
return `0x${result.toHex(true)}`;
|
7507
7940
|
}
|
@@ -7513,16 +7946,16 @@ var Signer = class {
|
|
7513
7946
|
* @returns public key from signature from the
|
7514
7947
|
*/
|
7515
7948
|
static recoverPublicKey(data, signature) {
|
7516
|
-
const signedMessageBytes =
|
7949
|
+
const signedMessageBytes = arrayify17(signature);
|
7517
7950
|
const r = signedMessageBytes.slice(0, 32);
|
7518
7951
|
const s = signedMessageBytes.slice(32, 64);
|
7519
7952
|
const recoveryParam = (s[0] & 128) >> 7;
|
7520
7953
|
s[0] &= 127;
|
7521
|
-
const sig = new secp256k1.Signature(BigInt(
|
7954
|
+
const sig = new secp256k1.Signature(BigInt(hexlify18(r)), BigInt(hexlify18(s))).addRecoveryBit(
|
7522
7955
|
recoveryParam
|
7523
7956
|
);
|
7524
|
-
const publicKey = sig.recoverPublicKey(
|
7525
|
-
return
|
7957
|
+
const publicKey = sig.recoverPublicKey(arrayify17(data)).toRawBytes(false).slice(1);
|
7958
|
+
return hexlify18(publicKey);
|
7526
7959
|
}
|
7527
7960
|
/**
|
7528
7961
|
* Recover the address from a signature performed with [`sign`](#sign).
|
@@ -7541,7 +7974,7 @@ var Signer = class {
|
|
7541
7974
|
* @returns random 32-byte hashed
|
7542
7975
|
*/
|
7543
7976
|
static generatePrivateKey(entropy) {
|
7544
|
-
return entropy ? hash2(concat4([randomBytes3(32),
|
7977
|
+
return entropy ? hash2(concat4([randomBytes3(32), arrayify17(entropy)])) : randomBytes3(32);
|
7545
7978
|
}
|
7546
7979
|
/**
|
7547
7980
|
* Extended publicKey from a compact publicKey
|
@@ -7550,8 +7983,8 @@ var Signer = class {
|
|
7550
7983
|
* @returns extended publicKey
|
7551
7984
|
*/
|
7552
7985
|
static extendPublicKey(publicKey) {
|
7553
|
-
const point = secp256k1.ProjectivePoint.fromHex(
|
7554
|
-
return
|
7986
|
+
const point = secp256k1.ProjectivePoint.fromHex(arrayify17(publicKey));
|
7987
|
+
return hexlify18(point.toRawBytes(false).slice(1));
|
7555
7988
|
}
|
7556
7989
|
};
|
7557
7990
|
|
@@ -7567,8 +8000,8 @@ import {
|
|
7567
8000
|
encryptJsonWalletData,
|
7568
8001
|
randomUUID
|
7569
8002
|
} from "@fuel-ts/crypto";
|
7570
|
-
import { ErrorCode as ErrorCode19, FuelError as
|
7571
|
-
import { hexlify as
|
8003
|
+
import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
|
8004
|
+
import { hexlify as hexlify19 } from "@fuel-ts/utils";
|
7572
8005
|
var DEFAULT_KDF_PARAMS_LOG_N = 13;
|
7573
8006
|
var DEFAULT_KDF_PARAMS_R = 8;
|
7574
8007
|
var DEFAULT_KDF_PARAMS_P = 1;
|
@@ -7644,13 +8077,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
|
|
7644
8077
|
const macHashUint8Array = keccak256(data);
|
7645
8078
|
const macHash = stringFromBuffer(macHashUint8Array, "hex");
|
7646
8079
|
if (mac !== macHash) {
|
7647
|
-
throw new
|
8080
|
+
throw new FuelError22(
|
7648
8081
|
ErrorCode19.INVALID_PASSWORD,
|
7649
8082
|
"Failed to decrypt the keystore wallet, the provided password is incorrect."
|
7650
8083
|
);
|
7651
8084
|
}
|
7652
8085
|
const buffer = await decryptJsonWalletData(ciphertextBuffer, key, ivBuffer);
|
7653
|
-
const privateKey =
|
8086
|
+
const privateKey = hexlify19(buffer);
|
7654
8087
|
return privateKey;
|
7655
8088
|
}
|
7656
8089
|
|
@@ -7695,7 +8128,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
7695
8128
|
*/
|
7696
8129
|
async signMessage(message) {
|
7697
8130
|
const signedMessage = await this.signer().sign(hashMessage(message));
|
7698
|
-
return
|
8131
|
+
return hexlify20(signedMessage);
|
7699
8132
|
}
|
7700
8133
|
/**
|
7701
8134
|
* Signs a transaction with the wallet's private key.
|
@@ -7708,7 +8141,7 @@ var BaseWalletUnlocked = class extends Account {
|
|
7708
8141
|
const chainId = await this.provider.getChainId();
|
7709
8142
|
const hashedTransaction = transactionRequest.getTransactionId(chainId);
|
7710
8143
|
const signature = await this.signer().sign(hashedTransaction);
|
7711
|
-
return
|
8144
|
+
return hexlify20(signature);
|
7712
8145
|
}
|
7713
8146
|
/**
|
7714
8147
|
* Populates a transaction with the witnesses signature.
|
@@ -7780,16 +8213,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
|
|
7780
8213
|
|
7781
8214
|
// src/hdwallet/hdwallet.ts
|
7782
8215
|
import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
|
7783
|
-
import { ErrorCode as ErrorCode22, FuelError as
|
8216
|
+
import { ErrorCode as ErrorCode22, FuelError as FuelError25 } from "@fuel-ts/errors";
|
7784
8217
|
import { sha256 as sha2564 } from "@fuel-ts/hasher";
|
7785
|
-
import { bn as
|
7786
|
-
import { arrayify as
|
8218
|
+
import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
|
8219
|
+
import { arrayify as arrayify20, hexlify as hexlify22, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
|
7787
8220
|
|
7788
8221
|
// src/mnemonic/mnemonic.ts
|
7789
8222
|
import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
|
7790
|
-
import { ErrorCode as ErrorCode21, FuelError as
|
8223
|
+
import { ErrorCode as ErrorCode21, FuelError as FuelError24 } from "@fuel-ts/errors";
|
7791
8224
|
import { sha256 as sha2563 } from "@fuel-ts/hasher";
|
7792
|
-
import { arrayify as
|
8225
|
+
import { arrayify as arrayify19, hexlify as hexlify21, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
|
7793
8226
|
|
7794
8227
|
// src/wordlists/words/english.ts
|
7795
8228
|
var english = [
|
@@ -9850,9 +10283,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
|
|
9850
10283
|
})(Language || {});
|
9851
10284
|
|
9852
10285
|
// src/mnemonic/utils.ts
|
9853
|
-
import { ErrorCode as ErrorCode20, FuelError as
|
10286
|
+
import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
|
9854
10287
|
import { sha256 as sha2562 } from "@fuel-ts/hasher";
|
9855
|
-
import { arrayify as
|
10288
|
+
import { arrayify as arrayify18 } from "@fuel-ts/utils";
|
9856
10289
|
function getLowerMask(bits) {
|
9857
10290
|
return (1 << bits) - 1;
|
9858
10291
|
}
|
@@ -9887,19 +10320,19 @@ function entropyToMnemonicIndices(entropy) {
|
|
9887
10320
|
}
|
9888
10321
|
}
|
9889
10322
|
const checksumBits = entropy.length / 4;
|
9890
|
-
const checksum =
|
10323
|
+
const checksum = arrayify18(sha2562(entropy))[0] & getUpperMask(checksumBits);
|
9891
10324
|
indices[indices.length - 1] <<= checksumBits;
|
9892
10325
|
indices[indices.length - 1] |= checksum >> 8 - checksumBits;
|
9893
10326
|
return indices;
|
9894
10327
|
}
|
9895
10328
|
function mnemonicWordsToEntropy(words, wordlist) {
|
9896
10329
|
const size = Math.ceil(11 * words.length / 8);
|
9897
|
-
const entropy =
|
10330
|
+
const entropy = arrayify18(new Uint8Array(size));
|
9898
10331
|
let offset = 0;
|
9899
10332
|
for (let i = 0; i < words.length; i += 1) {
|
9900
10333
|
const index = wordlist.indexOf(words[i].normalize("NFKD"));
|
9901
10334
|
if (index === -1) {
|
9902
|
-
throw new
|
10335
|
+
throw new FuelError23(
|
9903
10336
|
ErrorCode20.INVALID_MNEMONIC,
|
9904
10337
|
`Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
|
9905
10338
|
);
|
@@ -9914,9 +10347,9 @@ function mnemonicWordsToEntropy(words, wordlist) {
|
|
9914
10347
|
const entropyBits = 32 * words.length / 3;
|
9915
10348
|
const checksumBits = words.length / 3;
|
9916
10349
|
const checksumMask = getUpperMask(checksumBits);
|
9917
|
-
const checksum =
|
10350
|
+
const checksum = arrayify18(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
|
9918
10351
|
if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
|
9919
|
-
throw new
|
10352
|
+
throw new FuelError23(
|
9920
10353
|
ErrorCode20.INVALID_CHECKSUM,
|
9921
10354
|
"Checksum validation failed for the provided mnemonic."
|
9922
10355
|
);
|
@@ -9931,7 +10364,7 @@ var TestnetPRV = "0x04358394";
|
|
9931
10364
|
var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
|
9932
10365
|
function assertWordList(wordlist) {
|
9933
10366
|
if (wordlist.length !== 2048) {
|
9934
|
-
throw new
|
10367
|
+
throw new FuelError24(
|
9935
10368
|
ErrorCode21.INVALID_WORD_LIST,
|
9936
10369
|
`Expected word list length of 2048, but got ${wordlist.length}.`
|
9937
10370
|
);
|
@@ -9939,7 +10372,7 @@ function assertWordList(wordlist) {
|
|
9939
10372
|
}
|
9940
10373
|
function assertEntropy(entropy) {
|
9941
10374
|
if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
|
9942
|
-
throw new
|
10375
|
+
throw new FuelError24(
|
9943
10376
|
ErrorCode21.INVALID_ENTROPY,
|
9944
10377
|
`Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
|
9945
10378
|
);
|
@@ -9950,7 +10383,7 @@ function assertMnemonic(words) {
|
|
9950
10383
|
const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
|
9951
10384
|
", "
|
9952
10385
|
)}] words, but got ${words.length}.`;
|
9953
|
-
throw new
|
10386
|
+
throw new FuelError24(ErrorCode21.INVALID_MNEMONIC, errorMsg);
|
9954
10387
|
}
|
9955
10388
|
}
|
9956
10389
|
var Mnemonic = class {
|
@@ -9989,7 +10422,7 @@ var Mnemonic = class {
|
|
9989
10422
|
static mnemonicToEntropy(phrase, wordlist = english) {
|
9990
10423
|
const words = getWords(phrase);
|
9991
10424
|
assertMnemonic(words);
|
9992
|
-
return
|
10425
|
+
return hexlify21(mnemonicWordsToEntropy(words, wordlist));
|
9993
10426
|
}
|
9994
10427
|
/**
|
9995
10428
|
* @param entropy - Entropy source to the mnemonic phrase.
|
@@ -9997,7 +10430,7 @@ var Mnemonic = class {
|
|
9997
10430
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
9998
10431
|
*/
|
9999
10432
|
static entropyToMnemonic(entropy, wordlist = english) {
|
10000
|
-
const entropyBytes =
|
10433
|
+
const entropyBytes = arrayify19(entropy);
|
10001
10434
|
assertWordList(wordlist);
|
10002
10435
|
assertEntropy(entropyBytes);
|
10003
10436
|
return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
|
@@ -10066,14 +10499,14 @@ var Mnemonic = class {
|
|
10066
10499
|
* @returns 64-byte array contains privateKey and chainCode as described on BIP39
|
10067
10500
|
*/
|
10068
10501
|
static masterKeysFromSeed(seed) {
|
10069
|
-
const seedArray =
|
10502
|
+
const seedArray = arrayify19(seed);
|
10070
10503
|
if (seedArray.length < 16 || seedArray.length > 64) {
|
10071
|
-
throw new
|
10504
|
+
throw new FuelError24(
|
10072
10505
|
ErrorCode21.INVALID_SEED,
|
10073
10506
|
`Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
|
10074
10507
|
);
|
10075
10508
|
}
|
10076
|
-
return
|
10509
|
+
return arrayify19(computeHmac("sha512", MasterSecret, seedArray));
|
10077
10510
|
}
|
10078
10511
|
/**
|
10079
10512
|
* Get the extendKey as defined on BIP-32 from the provided seed
|
@@ -10084,7 +10517,7 @@ var Mnemonic = class {
|
|
10084
10517
|
*/
|
10085
10518
|
static seedToExtendedKey(seed, testnet = false) {
|
10086
10519
|
const masterKey = Mnemonic.masterKeysFromSeed(seed);
|
10087
|
-
const prefix =
|
10520
|
+
const prefix = arrayify19(testnet ? TestnetPRV : MainnetPRV);
|
10088
10521
|
const depth = "0x00";
|
10089
10522
|
const fingerprint = "0x00000000";
|
10090
10523
|
const index = "0x00000000";
|
@@ -10114,7 +10547,7 @@ var Mnemonic = class {
|
|
10114
10547
|
* @returns A randomly generated mnemonic
|
10115
10548
|
*/
|
10116
10549
|
static generate(size = 32, extraEntropy = "") {
|
10117
|
-
const entropy = extraEntropy ? sha2563(concat5([randomBytes5(size),
|
10550
|
+
const entropy = extraEntropy ? sha2563(concat5([randomBytes5(size), arrayify19(extraEntropy)])) : randomBytes5(size);
|
10118
10551
|
return Mnemonic.entropyToMnemonic(entropy);
|
10119
10552
|
}
|
10120
10553
|
};
|
@@ -10122,10 +10555,10 @@ var mnemonic_default = Mnemonic;
|
|
10122
10555
|
|
10123
10556
|
// src/hdwallet/hdwallet.ts
|
10124
10557
|
var HARDENED_INDEX = 2147483648;
|
10125
|
-
var MainnetPRV2 =
|
10126
|
-
var MainnetPUB =
|
10127
|
-
var TestnetPRV2 =
|
10128
|
-
var TestnetPUB =
|
10558
|
+
var MainnetPRV2 = hexlify22("0x0488ade4");
|
10559
|
+
var MainnetPUB = hexlify22("0x0488b21e");
|
10560
|
+
var TestnetPRV2 = hexlify22("0x04358394");
|
10561
|
+
var TestnetPUB = hexlify22("0x043587cf");
|
10129
10562
|
function base58check(data) {
|
10130
10563
|
return encodeBase582(concat6([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
|
10131
10564
|
}
|
@@ -10136,17 +10569,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
|
|
10136
10569
|
return testnet ? TestnetPRV2 : MainnetPRV2;
|
10137
10570
|
}
|
10138
10571
|
function isPublicExtendedKey(extendedKey) {
|
10139
|
-
return [MainnetPUB, TestnetPUB].includes(
|
10572
|
+
return [MainnetPUB, TestnetPUB].includes(hexlify22(extendedKey.slice(0, 4)));
|
10140
10573
|
}
|
10141
10574
|
function isValidExtendedKey(extendedKey) {
|
10142
10575
|
return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
|
10143
|
-
|
10576
|
+
hexlify22(extendedKey.slice(0, 4))
|
10144
10577
|
);
|
10145
10578
|
}
|
10146
10579
|
function parsePath(path, depth = 0) {
|
10147
10580
|
const components = path.split("/");
|
10148
10581
|
if (components.length === 0 || components[0] === "m" && depth !== 0) {
|
10149
|
-
throw new
|
10582
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, `invalid path - ${path}`);
|
10150
10583
|
}
|
10151
10584
|
if (components[0] === "m") {
|
10152
10585
|
components.shift();
|
@@ -10158,8 +10591,8 @@ function parsePath(path, depth = 0) {
|
|
10158
10591
|
var HDWallet = class {
|
10159
10592
|
depth = 0;
|
10160
10593
|
index = 0;
|
10161
|
-
fingerprint =
|
10162
|
-
parentFingerprint =
|
10594
|
+
fingerprint = hexlify22("0x00000000");
|
10595
|
+
parentFingerprint = hexlify22("0x00000000");
|
10163
10596
|
privateKey;
|
10164
10597
|
publicKey;
|
10165
10598
|
chainCode;
|
@@ -10171,16 +10604,16 @@ var HDWallet = class {
|
|
10171
10604
|
constructor(config) {
|
10172
10605
|
if (config.privateKey) {
|
10173
10606
|
const signer = new Signer(config.privateKey);
|
10174
|
-
this.publicKey =
|
10175
|
-
this.privateKey =
|
10607
|
+
this.publicKey = hexlify22(signer.compressedPublicKey);
|
10608
|
+
this.privateKey = hexlify22(config.privateKey);
|
10176
10609
|
} else {
|
10177
10610
|
if (!config.publicKey) {
|
10178
|
-
throw new
|
10611
|
+
throw new FuelError25(
|
10179
10612
|
ErrorCode22.HD_WALLET_ERROR,
|
10180
10613
|
"Both public and private Key cannot be missing. At least one should be provided."
|
10181
10614
|
);
|
10182
10615
|
}
|
10183
|
-
this.publicKey =
|
10616
|
+
this.publicKey = hexlify22(config.publicKey);
|
10184
10617
|
}
|
10185
10618
|
this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
|
10186
10619
|
this.fingerprint = dataSlice2(ripemd160(sha2564(this.publicKey)), 0, 4);
|
@@ -10199,28 +10632,28 @@ var HDWallet = class {
|
|
10199
10632
|
* @returns A new instance of HDWallet on the derived index
|
10200
10633
|
*/
|
10201
10634
|
deriveIndex(index) {
|
10202
|
-
const privateKey = this.privateKey &&
|
10203
|
-
const publicKey =
|
10204
|
-
const chainCode =
|
10635
|
+
const privateKey = this.privateKey && arrayify20(this.privateKey);
|
10636
|
+
const publicKey = arrayify20(this.publicKey);
|
10637
|
+
const chainCode = arrayify20(this.chainCode);
|
10205
10638
|
const data = new Uint8Array(37);
|
10206
10639
|
if (index & HARDENED_INDEX) {
|
10207
10640
|
if (!privateKey) {
|
10208
|
-
throw new
|
10641
|
+
throw new FuelError25(
|
10209
10642
|
ErrorCode22.HD_WALLET_ERROR,
|
10210
10643
|
"Cannot derive a hardened index without a private Key."
|
10211
10644
|
);
|
10212
10645
|
}
|
10213
10646
|
data.set(privateKey, 1);
|
10214
10647
|
} else {
|
10215
|
-
data.set(
|
10648
|
+
data.set(arrayify20(this.publicKey));
|
10216
10649
|
}
|
10217
10650
|
data.set(toBytes2(index, 4), 33);
|
10218
|
-
const bytes =
|
10651
|
+
const bytes = arrayify20(computeHmac2("sha512", chainCode, data));
|
10219
10652
|
const IL = bytes.slice(0, 32);
|
10220
10653
|
const IR = bytes.slice(32);
|
10221
10654
|
if (privateKey) {
|
10222
10655
|
const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
|
10223
|
-
const ki =
|
10656
|
+
const ki = bn21(IL).add(privateKey).mod(N).toBytes(32);
|
10224
10657
|
return new HDWallet({
|
10225
10658
|
privateKey: ki,
|
10226
10659
|
chainCode: IR,
|
@@ -10229,7 +10662,7 @@ var HDWallet = class {
|
|
10229
10662
|
parentFingerprint: this.fingerprint
|
10230
10663
|
});
|
10231
10664
|
}
|
10232
|
-
const signer = new Signer(
|
10665
|
+
const signer = new Signer(hexlify22(IL));
|
10233
10666
|
const Ki = signer.addPoint(publicKey);
|
10234
10667
|
return new HDWallet({
|
10235
10668
|
publicKey: Ki,
|
@@ -10258,18 +10691,18 @@ var HDWallet = class {
|
|
10258
10691
|
*/
|
10259
10692
|
toExtendedKey(isPublic = false, testnet = false) {
|
10260
10693
|
if (this.depth >= 256) {
|
10261
|
-
throw new
|
10694
|
+
throw new FuelError25(
|
10262
10695
|
ErrorCode22.HD_WALLET_ERROR,
|
10263
10696
|
`Exceeded max depth of 255. Current depth: ${this.depth}.`
|
10264
10697
|
);
|
10265
10698
|
}
|
10266
10699
|
const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
|
10267
|
-
const depth =
|
10700
|
+
const depth = hexlify22(Uint8Array.from([this.depth]));
|
10268
10701
|
const parentFingerprint = this.parentFingerprint;
|
10269
10702
|
const index = toHex(this.index, 4);
|
10270
10703
|
const chainCode = this.chainCode;
|
10271
10704
|
const key = this.privateKey != null && !isPublic ? concat6(["0x00", this.privateKey]) : this.publicKey;
|
10272
|
-
const extendedKey =
|
10705
|
+
const extendedKey = arrayify20(concat6([prefix, depth, parentFingerprint, index, chainCode, key]));
|
10273
10706
|
return base58check(extendedKey);
|
10274
10707
|
}
|
10275
10708
|
/**
|
@@ -10281,34 +10714,34 @@ var HDWallet = class {
|
|
10281
10714
|
static fromSeed(seed) {
|
10282
10715
|
const masterKey = mnemonic_default.masterKeysFromSeed(seed);
|
10283
10716
|
return new HDWallet({
|
10284
|
-
chainCode:
|
10285
|
-
privateKey:
|
10717
|
+
chainCode: arrayify20(masterKey.slice(32)),
|
10718
|
+
privateKey: arrayify20(masterKey.slice(0, 32))
|
10286
10719
|
});
|
10287
10720
|
}
|
10288
10721
|
static fromExtendedKey(extendedKey) {
|
10289
|
-
const decoded =
|
10290
|
-
const bytes =
|
10722
|
+
const decoded = hexlify22(toBytes2(decodeBase58(extendedKey)));
|
10723
|
+
const bytes = arrayify20(decoded);
|
10291
10724
|
const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
|
10292
10725
|
if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
|
10293
|
-
throw new
|
10726
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
|
10294
10727
|
}
|
10295
10728
|
if (!validChecksum) {
|
10296
|
-
throw new
|
10729
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
|
10297
10730
|
}
|
10298
10731
|
const depth = bytes[4];
|
10299
|
-
const parentFingerprint =
|
10300
|
-
const index = parseInt(
|
10301
|
-
const chainCode =
|
10732
|
+
const parentFingerprint = hexlify22(bytes.slice(5, 9));
|
10733
|
+
const index = parseInt(hexlify22(bytes.slice(9, 13)).substring(2), 16);
|
10734
|
+
const chainCode = hexlify22(bytes.slice(13, 45));
|
10302
10735
|
const key = bytes.slice(45, 78);
|
10303
10736
|
if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
|
10304
|
-
throw new
|
10737
|
+
throw new FuelError25(
|
10305
10738
|
ErrorCode22.HD_WALLET_ERROR,
|
10306
10739
|
"Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
|
10307
10740
|
);
|
10308
10741
|
}
|
10309
10742
|
if (isPublicExtendedKey(bytes)) {
|
10310
10743
|
if (key[0] !== 3) {
|
10311
|
-
throw new
|
10744
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Invalid public extended key.");
|
10312
10745
|
}
|
10313
10746
|
return new HDWallet({
|
10314
10747
|
publicKey: key,
|
@@ -10319,7 +10752,7 @@ var HDWallet = class {
|
|
10319
10752
|
});
|
10320
10753
|
}
|
10321
10754
|
if (key[0] !== 0) {
|
10322
|
-
throw new
|
10755
|
+
throw new FuelError25(ErrorCode22.HD_WALLET_ERROR, "Invalid private extended key.");
|
10323
10756
|
}
|
10324
10757
|
return new HDWallet({
|
10325
10758
|
privateKey: key.slice(1),
|
@@ -10487,7 +10920,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
|
|
10487
10920
|
// src/wallet-manager/wallet-manager.ts
|
10488
10921
|
import { Address as Address9 } from "@fuel-ts/address";
|
10489
10922
|
import { encrypt, decrypt } from "@fuel-ts/crypto";
|
10490
|
-
import { ErrorCode as ErrorCode25, FuelError as
|
10923
|
+
import { ErrorCode as ErrorCode25, FuelError as FuelError28 } from "@fuel-ts/errors";
|
10491
10924
|
import { EventEmitter } from "events";
|
10492
10925
|
|
10493
10926
|
// src/wallet-manager/storages/memory-storage.ts
|
@@ -10510,7 +10943,7 @@ var MemoryStorage = class {
|
|
10510
10943
|
|
10511
10944
|
// src/wallet-manager/vaults/mnemonic-vault.ts
|
10512
10945
|
import { Address as Address7 } from "@fuel-ts/address";
|
10513
|
-
import { ErrorCode as ErrorCode23, FuelError as
|
10946
|
+
import { ErrorCode as ErrorCode23, FuelError as FuelError26 } from "@fuel-ts/errors";
|
10514
10947
|
var _secret;
|
10515
10948
|
var MnemonicVault = class {
|
10516
10949
|
constructor(options) {
|
@@ -10566,7 +10999,7 @@ var MnemonicVault = class {
|
|
10566
10999
|
}
|
10567
11000
|
numberOfAccounts += 1;
|
10568
11001
|
} while (numberOfAccounts < this.numberOfAccounts);
|
10569
|
-
throw new
|
11002
|
+
throw new FuelError26(
|
10570
11003
|
ErrorCode23.WALLET_MANAGER_ERROR,
|
10571
11004
|
`Account with address '${address}' not found in derived wallets.`
|
10572
11005
|
);
|
@@ -10581,7 +11014,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
|
|
10581
11014
|
|
10582
11015
|
// src/wallet-manager/vaults/privatekey-vault.ts
|
10583
11016
|
import { Address as Address8 } from "@fuel-ts/address";
|
10584
|
-
import { ErrorCode as ErrorCode24, FuelError as
|
11017
|
+
import { ErrorCode as ErrorCode24, FuelError as FuelError27 } from "@fuel-ts/errors";
|
10585
11018
|
var _privateKeys;
|
10586
11019
|
var PrivateKeyVault = class {
|
10587
11020
|
/**
|
@@ -10622,7 +11055,7 @@ var PrivateKeyVault = class {
|
|
10622
11055
|
(pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
|
10623
11056
|
);
|
10624
11057
|
if (!privateKey) {
|
10625
|
-
throw new
|
11058
|
+
throw new FuelError27(
|
10626
11059
|
ErrorCode24.WALLET_MANAGER_ERROR,
|
10627
11060
|
`No private key found for address '${address}'.`
|
10628
11061
|
);
|
@@ -10647,7 +11080,7 @@ var ERROR_MESSAGES = {
|
|
10647
11080
|
};
|
10648
11081
|
function assert(condition, message) {
|
10649
11082
|
if (!condition) {
|
10650
|
-
throw new
|
11083
|
+
throw new FuelError28(ErrorCode25.WALLET_MANAGER_ERROR, message);
|
10651
11084
|
}
|
10652
11085
|
}
|
10653
11086
|
var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
|
@@ -10873,25 +11306,25 @@ deserializeVaults_fn = function(vaults) {
|
|
10873
11306
|
__publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
|
10874
11307
|
|
10875
11308
|
// src/wallet-manager/types.ts
|
10876
|
-
import { ErrorCode as ErrorCode26, FuelError as
|
11309
|
+
import { ErrorCode as ErrorCode26, FuelError as FuelError29 } from "@fuel-ts/errors";
|
10877
11310
|
var Vault = class {
|
10878
11311
|
constructor(_options) {
|
10879
|
-
throw new
|
11312
|
+
throw new FuelError29(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
10880
11313
|
}
|
10881
11314
|
serialize() {
|
10882
|
-
throw new
|
11315
|
+
throw new FuelError29(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
10883
11316
|
}
|
10884
11317
|
getAccounts() {
|
10885
|
-
throw new
|
11318
|
+
throw new FuelError29(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
10886
11319
|
}
|
10887
11320
|
addAccount() {
|
10888
|
-
throw new
|
11321
|
+
throw new FuelError29(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
10889
11322
|
}
|
10890
11323
|
exportAccount(_address) {
|
10891
|
-
throw new
|
11324
|
+
throw new FuelError29(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
10892
11325
|
}
|
10893
11326
|
getWallet(_address) {
|
10894
|
-
throw new
|
11327
|
+
throw new FuelError29(ErrorCode26.NOT_IMPLEMENTED, "Not implemented.");
|
10895
11328
|
}
|
10896
11329
|
};
|
10897
11330
|
__publicField(Vault, "type");
|
@@ -10899,15 +11332,15 @@ var StorageAbstract = class {
|
|
10899
11332
|
};
|
10900
11333
|
|
10901
11334
|
// src/predicate/predicate.ts
|
10902
|
-
import { Interface as
|
11335
|
+
import { Interface as Interface3 } from "@fuel-ts/abi-coder";
|
10903
11336
|
import { Address as Address10 } from "@fuel-ts/address";
|
10904
|
-
import { ErrorCode as ErrorCode28, FuelError as
|
10905
|
-
import { arrayify as
|
11337
|
+
import { ErrorCode as ErrorCode28, FuelError as FuelError31 } from "@fuel-ts/errors";
|
11338
|
+
import { arrayify as arrayify23, hexlify as hexlify24 } from "@fuel-ts/utils";
|
10906
11339
|
|
10907
11340
|
// src/utils/deployScriptOrPredicate.ts
|
10908
|
-
import { FuelError as
|
10909
|
-
import { bn as
|
10910
|
-
import { arrayify as
|
11341
|
+
import { FuelError as FuelError30, ErrorCode as ErrorCode27 } from "@fuel-ts/errors";
|
11342
|
+
import { bn as bn22 } from "@fuel-ts/math";
|
11343
|
+
import { arrayify as arrayify21 } from "@fuel-ts/utils";
|
10911
11344
|
|
10912
11345
|
// src/utils/predicate-script-loader-instructions.ts
|
10913
11346
|
import { BigNumberCoder as BigNumberCoder3 } from "@fuel-ts/abi-coder";
|
@@ -11054,7 +11487,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
|
|
11054
11487
|
|
11055
11488
|
// src/utils/deployScriptOrPredicate.ts
|
11056
11489
|
async function fundBlobTx(deployer, blobTxRequest) {
|
11057
|
-
let totalCost =
|
11490
|
+
let totalCost = bn22(0);
|
11058
11491
|
const chainInfo = await deployer.provider.getChain();
|
11059
11492
|
const gasPrice = await deployer.provider.estimateGasPrice(10);
|
11060
11493
|
const priceFactor = chainInfo.consensusParameters.feeParameters.gasPriceFactor;
|
@@ -11067,7 +11500,7 @@ async function fundBlobTx(deployer, blobTxRequest) {
|
|
11067
11500
|
}).add(1);
|
11068
11501
|
totalCost = totalCost.add(minFee);
|
11069
11502
|
if (totalCost.gt(await deployer.getBalance())) {
|
11070
|
-
throw new
|
11503
|
+
throw new FuelError30(ErrorCode27.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
|
11071
11504
|
}
|
11072
11505
|
const txCost = await deployer.getTransactionCost(blobTxRequest);
|
11073
11506
|
blobTxRequest.maxFee = txCost.maxFee;
|
@@ -11087,8 +11520,8 @@ async function deployScriptOrPredicate({
|
|
11087
11520
|
abi,
|
11088
11521
|
loaderInstanceCallback
|
11089
11522
|
}) {
|
11090
|
-
const blobId = getBytecodeId(
|
11091
|
-
const configurableOffset = getBytecodeConfigurableOffset(
|
11523
|
+
const blobId = getBytecodeId(arrayify21(bytecode));
|
11524
|
+
const configurableOffset = getBytecodeConfigurableOffset(arrayify21(bytecode));
|
11092
11525
|
const byteCodeWithoutConfigurableSection = bytecode.slice(0, configurableOffset);
|
11093
11526
|
const blobTxRequest = new BlobTransactionRequest({
|
11094
11527
|
blobId,
|
@@ -11096,8 +11529,8 @@ async function deployScriptOrPredicate({
|
|
11096
11529
|
witnesses: [byteCodeWithoutConfigurableSection]
|
11097
11530
|
});
|
11098
11531
|
const { loaderBytecode, blobOffset } = getPredicateScriptLoaderInstructions(
|
11099
|
-
|
11100
|
-
|
11532
|
+
arrayify21(bytecode),
|
11533
|
+
arrayify21(blobId)
|
11101
11534
|
);
|
11102
11535
|
const newConfigurableOffsetDiff = byteCodeWithoutConfigurableSection.length - (blobOffset || 0);
|
11103
11536
|
const newAbi = adjustConfigurableOffsets(abi, newConfigurableOffsetDiff);
|
@@ -11118,7 +11551,7 @@ async function deployScriptOrPredicate({
|
|
11118
11551
|
throw new Error();
|
11119
11552
|
}
|
11120
11553
|
} catch (err) {
|
11121
|
-
throw new
|
11554
|
+
throw new FuelError30(ErrorCode27.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
|
11122
11555
|
}
|
11123
11556
|
return loaderInstance;
|
11124
11557
|
};
|
@@ -11131,12 +11564,12 @@ async function deployScriptOrPredicate({
|
|
11131
11564
|
// src/predicate/utils/getPredicateRoot.ts
|
11132
11565
|
import { hash as hash3 } from "@fuel-ts/hasher";
|
11133
11566
|
import { calcRoot } from "@fuel-ts/merkle";
|
11134
|
-
import { chunkAndPadBytes, hexlify as
|
11567
|
+
import { chunkAndPadBytes, hexlify as hexlify23, concat as concat8, arrayify as arrayify22 } from "@fuel-ts/utils";
|
11135
11568
|
var getPredicateRoot = (bytecode) => {
|
11136
11569
|
const chunkSize = 16 * 1024;
|
11137
|
-
const bytes =
|
11570
|
+
const bytes = arrayify22(bytecode);
|
11138
11571
|
const chunks = chunkAndPadBytes(bytes, chunkSize);
|
11139
|
-
const codeRoot = calcRoot(chunks.map((c) =>
|
11572
|
+
const codeRoot = calcRoot(chunks.map((c) => hexlify23(c)));
|
11140
11573
|
const predicateRoot = hash3(concat8(["0x4655454C", codeRoot]));
|
11141
11574
|
return predicateRoot;
|
11142
11575
|
};
|
@@ -11171,7 +11604,7 @@ var Predicate = class extends Account {
|
|
11171
11604
|
);
|
11172
11605
|
const address = new Address10(getPredicateRoot(predicateBytes));
|
11173
11606
|
super(address, provider);
|
11174
|
-
this.initialBytecode =
|
11607
|
+
this.initialBytecode = arrayify23(bytecode);
|
11175
11608
|
this.bytes = predicateBytes;
|
11176
11609
|
this.interface = predicateInterface;
|
11177
11610
|
this.configurableConstants = configurableConstants;
|
@@ -11193,8 +11626,8 @@ var Predicate = class extends Account {
|
|
11193
11626
|
}
|
11194
11627
|
request2.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
|
11195
11628
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
11196
|
-
input.predicate =
|
11197
|
-
input.predicateData =
|
11629
|
+
input.predicate = hexlify24(this.bytes);
|
11630
|
+
input.predicateData = hexlify24(this.getPredicateData());
|
11198
11631
|
input.witnessIndex = 0;
|
11199
11632
|
}
|
11200
11633
|
});
|
@@ -11250,10 +11683,10 @@ var Predicate = class extends Account {
|
|
11250
11683
|
* @returns An object containing the new predicate bytes and interface.
|
11251
11684
|
*/
|
11252
11685
|
static processPredicateData(bytes, jsonAbi, configurableConstants) {
|
11253
|
-
let predicateBytes =
|
11254
|
-
const abiInterface = new
|
11686
|
+
let predicateBytes = arrayify23(bytes);
|
11687
|
+
const abiInterface = new Interface3(jsonAbi);
|
11255
11688
|
if (abiInterface.functions.main === void 0) {
|
11256
|
-
throw new
|
11689
|
+
throw new FuelError31(
|
11257
11690
|
ErrorCode28.ABI_MAIN_METHOD_MISSING,
|
11258
11691
|
'Cannot use ABI without "main" function.'
|
11259
11692
|
);
|
@@ -11285,8 +11718,8 @@ var Predicate = class extends Account {
|
|
11285
11718
|
);
|
11286
11719
|
return resources.map((resource) => ({
|
11287
11720
|
...resource,
|
11288
|
-
predicate:
|
11289
|
-
predicateData:
|
11721
|
+
predicate: hexlify24(this.bytes),
|
11722
|
+
predicateData: hexlify24(this.getPredicateData())
|
11290
11723
|
}));
|
11291
11724
|
}
|
11292
11725
|
/**
|
@@ -11298,8 +11731,8 @@ var Predicate = class extends Account {
|
|
11298
11731
|
generateFakeResources(coins) {
|
11299
11732
|
return super.generateFakeResources(coins).map((coin) => ({
|
11300
11733
|
...coin,
|
11301
|
-
predicate:
|
11302
|
-
predicateData:
|
11734
|
+
predicate: hexlify24(this.bytes),
|
11735
|
+
predicateData: hexlify24(this.getPredicateData())
|
11303
11736
|
}));
|
11304
11737
|
}
|
11305
11738
|
/**
|
@@ -11314,14 +11747,14 @@ var Predicate = class extends Account {
|
|
11314
11747
|
const mutatedBytes = bytes;
|
11315
11748
|
try {
|
11316
11749
|
if (Object.keys(abiInterface.configurables).length === 0) {
|
11317
|
-
throw new
|
11750
|
+
throw new FuelError31(
|
11318
11751
|
ErrorCode28.INVALID_CONFIGURABLE_CONSTANTS,
|
11319
11752
|
"Predicate has no configurable constants to be set"
|
11320
11753
|
);
|
11321
11754
|
}
|
11322
11755
|
Object.entries(configurableConstants).forEach(([key, value]) => {
|
11323
11756
|
if (!abiInterface?.configurables[key]) {
|
11324
|
-
throw new
|
11757
|
+
throw new FuelError31(
|
11325
11758
|
ErrorCode28.CONFIGURABLE_NOT_FOUND,
|
11326
11759
|
`No configurable constant named '${key}' found in the Predicate`
|
11327
11760
|
);
|
@@ -11331,7 +11764,7 @@ var Predicate = class extends Account {
|
|
11331
11764
|
mutatedBytes.set(encoded, offset);
|
11332
11765
|
});
|
11333
11766
|
} catch (err) {
|
11334
|
-
throw new
|
11767
|
+
throw new FuelError31(
|
11335
11768
|
ErrorCode28.INVALID_CONFIGURABLE_CONSTANTS,
|
11336
11769
|
`Error setting configurable constants: ${err.message}.`
|
11337
11770
|
);
|
@@ -11388,7 +11821,7 @@ var Predicate = class extends Account {
|
|
11388
11821
|
import { ErrorCode as ErrorCode29, FuelError as FuelError33 } from "@fuel-ts/errors";
|
11389
11822
|
|
11390
11823
|
// src/connectors/fuel-connector.ts
|
11391
|
-
import { FuelError as
|
11824
|
+
import { FuelError as FuelError32 } from "@fuel-ts/errors";
|
11392
11825
|
import { EventEmitter as EventEmitter2 } from "events";
|
11393
11826
|
|
11394
11827
|
// src/connectors/types/connector-types.ts
|
@@ -11463,7 +11896,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11463
11896
|
* @returns Always true.
|
11464
11897
|
*/
|
11465
11898
|
async ping() {
|
11466
|
-
throw new
|
11899
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11467
11900
|
}
|
11468
11901
|
/**
|
11469
11902
|
* Should return the current version of the connector
|
@@ -11472,7 +11905,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11472
11905
|
* @returns boolean - connection status.
|
11473
11906
|
*/
|
11474
11907
|
async version() {
|
11475
|
-
throw new
|
11908
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11476
11909
|
}
|
11477
11910
|
/**
|
11478
11911
|
* Should return true if the connector is connected
|
@@ -11481,7 +11914,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11481
11914
|
* @returns The connection status.
|
11482
11915
|
*/
|
11483
11916
|
async isConnected() {
|
11484
|
-
throw new
|
11917
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11485
11918
|
}
|
11486
11919
|
/**
|
11487
11920
|
* Should return all the accounts authorized for the
|
@@ -11490,7 +11923,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11490
11923
|
* @returns The accounts addresses strings
|
11491
11924
|
*/
|
11492
11925
|
async accounts() {
|
11493
|
-
throw new
|
11926
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11494
11927
|
}
|
11495
11928
|
/**
|
11496
11929
|
* Should start the connection process and return
|
@@ -11502,7 +11935,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11502
11935
|
* @returns boolean - connection status.
|
11503
11936
|
*/
|
11504
11937
|
async connect() {
|
11505
|
-
throw new
|
11938
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11506
11939
|
}
|
11507
11940
|
/**
|
11508
11941
|
* Should disconnect the current connection and
|
@@ -11512,7 +11945,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11512
11945
|
* @returns The connection status.
|
11513
11946
|
*/
|
11514
11947
|
async disconnect() {
|
11515
|
-
throw new
|
11948
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11516
11949
|
}
|
11517
11950
|
/**
|
11518
11951
|
* Should start the sign message process and return
|
@@ -11524,7 +11957,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11524
11957
|
* @returns Message signature
|
11525
11958
|
*/
|
11526
11959
|
async signMessage(_address, _message) {
|
11527
|
-
throw new
|
11960
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11528
11961
|
}
|
11529
11962
|
/**
|
11530
11963
|
* Should start the sign transaction process and return
|
@@ -11536,7 +11969,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11536
11969
|
* @returns Transaction signature
|
11537
11970
|
*/
|
11538
11971
|
async signTransaction(_address, _transaction) {
|
11539
|
-
throw new
|
11972
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11540
11973
|
}
|
11541
11974
|
/**
|
11542
11975
|
* Should start the send transaction process and return
|
@@ -11549,10 +11982,10 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11549
11982
|
* @param address - The address to sign the transaction
|
11550
11983
|
* @param transaction - The transaction to send
|
11551
11984
|
* @param params - Optional parameters to send the transaction
|
11552
|
-
* @returns The transaction id
|
11985
|
+
* @returns The transaction id or transaction response
|
11553
11986
|
*/
|
11554
11987
|
async sendTransaction(_address, _transaction, _params) {
|
11555
|
-
throw new
|
11988
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11556
11989
|
}
|
11557
11990
|
/**
|
11558
11991
|
* Should return the current account selected inside the connector, if the account
|
@@ -11563,7 +11996,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11563
11996
|
* @returns The current account selected otherwise null.
|
11564
11997
|
*/
|
11565
11998
|
async currentAccount() {
|
11566
|
-
throw new
|
11999
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11567
12000
|
}
|
11568
12001
|
/**
|
11569
12002
|
* Should add the assets metadata to the connector and return true if the asset
|
@@ -11577,7 +12010,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11577
12010
|
* @returns True if the asset was added successfully
|
11578
12011
|
*/
|
11579
12012
|
async addAssets(_assets) {
|
11580
|
-
throw new
|
12013
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11581
12014
|
}
|
11582
12015
|
/**
|
11583
12016
|
* Should add the asset metadata to the connector and return true if the asset
|
@@ -11591,7 +12024,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11591
12024
|
* @returns True if the asset was added successfully
|
11592
12025
|
*/
|
11593
12026
|
async addAsset(_asset) {
|
11594
|
-
throw new
|
12027
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11595
12028
|
}
|
11596
12029
|
/**
|
11597
12030
|
* Should return all the assets added to the connector. If a connection is already established.
|
@@ -11599,7 +12032,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11599
12032
|
* @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
|
11600
12033
|
*/
|
11601
12034
|
async assets() {
|
11602
|
-
throw new
|
12035
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11603
12036
|
}
|
11604
12037
|
/**
|
11605
12038
|
* Should start the add network process and return true if the network was added successfully.
|
@@ -11610,7 +12043,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11610
12043
|
* @returns Return true if the network was added successfully
|
11611
12044
|
*/
|
11612
12045
|
async addNetwork(_networkUrl) {
|
11613
|
-
throw new
|
12046
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11614
12047
|
}
|
11615
12048
|
/**
|
11616
12049
|
* Should start the select network process and return true if the network has change successfully.
|
@@ -11621,7 +12054,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11621
12054
|
* @returns Return true if the network was added successfully
|
11622
12055
|
*/
|
11623
12056
|
async selectNetwork(_network) {
|
11624
|
-
throw new
|
12057
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11625
12058
|
}
|
11626
12059
|
/**
|
11627
12060
|
* Should return all the networks available from the connector. If the connection is already established.
|
@@ -11629,7 +12062,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11629
12062
|
* @returns Return all the networks added to the connector.
|
11630
12063
|
*/
|
11631
12064
|
async networks() {
|
11632
|
-
throw new
|
12065
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11633
12066
|
}
|
11634
12067
|
/**
|
11635
12068
|
* Should return the current network selected inside the connector. Even if the connection is not established.
|
@@ -11637,7 +12070,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11637
12070
|
* @returns Return the current network selected inside the connector.
|
11638
12071
|
*/
|
11639
12072
|
async currentNetwork() {
|
11640
|
-
throw new
|
12073
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11641
12074
|
}
|
11642
12075
|
/**
|
11643
12076
|
* Should add the ABI to the connector and return true if the ABI was added successfully.
|
@@ -11647,7 +12080,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11647
12080
|
* @returns Return true if the ABI was added successfully.
|
11648
12081
|
*/
|
11649
12082
|
async addABI(_contractId, _abi) {
|
11650
|
-
throw new
|
12083
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11651
12084
|
}
|
11652
12085
|
/**
|
11653
12086
|
* Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
|
@@ -11656,7 +12089,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11656
12089
|
* @returns The ABI if it exists, otherwise return null.
|
11657
12090
|
*/
|
11658
12091
|
async getABI(_id) {
|
11659
|
-
throw new
|
12092
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11660
12093
|
}
|
11661
12094
|
/**
|
11662
12095
|
* Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
|
@@ -11665,7 +12098,7 @@ var FuelConnector = class extends EventEmitter2 {
|
|
11665
12098
|
* @returns Returns true if the abi exists or false if not.
|
11666
12099
|
*/
|
11667
12100
|
async hasABI(_id) {
|
11668
|
-
throw new
|
12101
|
+
throw new FuelError32(FuelError32.CODES.NOT_IMPLEMENTED, "Method not implemented.");
|
11669
12102
|
}
|
11670
12103
|
/**
|
11671
12104
|
* Event listener for the connector.
|
@@ -11708,25 +12141,6 @@ function dispatchFuelConnectorEvent(connector) {
|
|
11708
12141
|
);
|
11709
12142
|
}
|
11710
12143
|
|
11711
|
-
// src/connectors/utils/promises.ts
|
11712
|
-
import { FuelError as FuelError32 } from "@fuel-ts/errors";
|
11713
|
-
function deferPromise() {
|
11714
|
-
const defer = {};
|
11715
|
-
defer.promise = new Promise((resolve, reject) => {
|
11716
|
-
defer.reject = reject;
|
11717
|
-
defer.resolve = resolve;
|
11718
|
-
});
|
11719
|
-
return defer;
|
11720
|
-
}
|
11721
|
-
async function withTimeout(promise, timeout = 1050) {
|
11722
|
-
const timeoutPromise = new Promise((resolve, reject) => {
|
11723
|
-
setTimeout(() => {
|
11724
|
-
reject(new FuelError32(FuelError32.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
|
11725
|
-
}, timeout);
|
11726
|
-
});
|
11727
|
-
return Promise.race([timeoutPromise, promise]);
|
11728
|
-
}
|
11729
|
-
|
11730
12144
|
// src/connectors/fuel.ts
|
11731
12145
|
var HAS_CONNECTOR_TIMEOUT = 2e3;
|
11732
12146
|
var PING_CACHE_TIME = 5e3;
|
@@ -12079,6 +12493,7 @@ export {
|
|
12079
12493
|
AbstractScriptRequest,
|
12080
12494
|
Account,
|
12081
12495
|
AddressType,
|
12496
|
+
BALANCES_PAGE_SIZE_LIMIT,
|
12082
12497
|
BLOCKS_PAGE_SIZE_LIMIT,
|
12083
12498
|
BaseTransactionRequest,
|
12084
12499
|
BaseWalletUnlocked,
|
@@ -12130,6 +12545,7 @@ export {
|
|
12130
12545
|
assembleReceiptByType,
|
12131
12546
|
assembleRevertError,
|
12132
12547
|
assembleTransactionSummary,
|
12548
|
+
assembleTransactionSummaryFromJson,
|
12133
12549
|
assets,
|
12134
12550
|
buildBlockExplorerUrl,
|
12135
12551
|
cacheFor,
|
@@ -12146,6 +12562,10 @@ export {
|
|
12146
12562
|
coinQuantityfy,
|
12147
12563
|
deferPromise,
|
12148
12564
|
deployScriptOrPredicate,
|
12565
|
+
deserializeChain,
|
12566
|
+
deserializeNodeInfo,
|
12567
|
+
deserializeProviderCache,
|
12568
|
+
deserializeReceipt,
|
12149
12569
|
dispatchFuelConnectorEvent,
|
12150
12570
|
english,
|
12151
12571
|
extractBurnedAssetsFromReceipts,
|
@@ -12210,6 +12630,7 @@ export {
|
|
12210
12630
|
isInputCoin,
|
12211
12631
|
isMessage,
|
12212
12632
|
isMessageCoin,
|
12633
|
+
isPredicate,
|
12213
12634
|
isRawCoin,
|
12214
12635
|
isRawMessage,
|
12215
12636
|
isRequestInputCoin,
|
@@ -12238,6 +12659,9 @@ export {
|
|
12238
12659
|
resolveGasDependentCosts,
|
12239
12660
|
resolveIconPaths,
|
12240
12661
|
returnZeroScript,
|
12662
|
+
serializeChain,
|
12663
|
+
serializeNodeInfo,
|
12664
|
+
serializeProviderCache,
|
12241
12665
|
transactionRequestify,
|
12242
12666
|
urlJoin,
|
12243
12667
|
validateTransactionForAssetBurn,
|