@agglayer/sdk 1.0.0-beta.19 → 1.0.0-beta.8
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/README.md +199 -494
- package/dist/index.d.mts +26 -136
- package/dist/index.d.ts +26 -136
- package/dist/index.js +90 -317
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -316
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21,7 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AggLayerSDK: () => AggLayerSDK,
|
|
24
|
-
ApiError: () => ApiError,
|
|
25
24
|
SDK_MODES: () => SDK_MODES
|
|
26
25
|
});
|
|
27
26
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -39,33 +38,7 @@ var ChainRegistry = class _ChainRegistry {
|
|
|
39
38
|
}
|
|
40
39
|
return _ChainRegistry.instance;
|
|
41
40
|
}
|
|
42
|
-
// DEV: if adding new default chains, also update README.md
|
|
43
41
|
initializeDefaultChains() {
|
|
44
|
-
this.registerChain({
|
|
45
|
-
chainId: 1,
|
|
46
|
-
networkId: 0,
|
|
47
|
-
name: "Ethereum",
|
|
48
|
-
rpcUrl: "https://eth.llamarpc.com",
|
|
49
|
-
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
50
|
-
blockExplorer: { name: "Etherscan", url: "https://etherscan.io" },
|
|
51
|
-
bridgeAddress: "",
|
|
52
|
-
proofApiUrl: "https://api-gateway.polygon.technology/api/v3/proof/mainnet/",
|
|
53
|
-
isTestnet: false
|
|
54
|
-
});
|
|
55
|
-
this.registerChain({
|
|
56
|
-
chainId: 747474,
|
|
57
|
-
networkId: 20,
|
|
58
|
-
name: "Katana",
|
|
59
|
-
rpcUrl: "https://rpc.katana.network",
|
|
60
|
-
nativeCurrency: { name: "Ethereum", symbol: "ETH", decimals: 18 },
|
|
61
|
-
blockExplorer: {
|
|
62
|
-
name: "Katana Explorer",
|
|
63
|
-
url: "https://katanascan.com"
|
|
64
|
-
},
|
|
65
|
-
bridgeAddress: "",
|
|
66
|
-
proofApiUrl: "https://api-gateway.polygon.technology/api/v3/proof/mainnet/",
|
|
67
|
-
isTestnet: false
|
|
68
|
-
});
|
|
69
42
|
this.registerChain({
|
|
70
43
|
chainId: 11155111,
|
|
71
44
|
networkId: 0,
|
|
@@ -80,6 +53,20 @@ var ChainRegistry = class _ChainRegistry {
|
|
|
80
53
|
proofApiUrl: "https://api-gateway.polygon.technology/api/v3/proof/testnet/",
|
|
81
54
|
isTestnet: true
|
|
82
55
|
});
|
|
56
|
+
this.registerChain({
|
|
57
|
+
chainId: 2442,
|
|
58
|
+
networkId: 1,
|
|
59
|
+
name: "Polygon Cardona",
|
|
60
|
+
rpcUrl: "https://rpc.cardona.zkevm-rpc.com",
|
|
61
|
+
nativeCurrency: { name: "Ethereum", symbol: "ETH", decimals: 18 },
|
|
62
|
+
blockExplorer: {
|
|
63
|
+
name: "Cardona PolygonScan",
|
|
64
|
+
url: "https://cardona-zkevm.polygonscan.com"
|
|
65
|
+
},
|
|
66
|
+
bridgeAddress: "0x528e26b25a34a4A5d0dbDa1d57D318153d2ED582",
|
|
67
|
+
proofApiUrl: "https://api-gateway.polygon.technology/api/v3/proof/testnet/",
|
|
68
|
+
isTestnet: true
|
|
69
|
+
});
|
|
83
70
|
}
|
|
84
71
|
/**
|
|
85
72
|
* Register a new chain
|
|
@@ -1423,16 +1410,11 @@ var ERC20 = class extends BaseContract {
|
|
|
1423
1410
|
var import_viem6 = require("viem");
|
|
1424
1411
|
|
|
1425
1412
|
// src/constants.ts
|
|
1426
|
-
var ARC_API_BASE_URL = "https://arc-api.polygon.technology";
|
|
1427
|
-
var ARC_API_DEFAULT_TIMEOUT = 3e4;
|
|
1428
|
-
var DEFAULT_CHAINS_PER_PAGE = 100;
|
|
1429
|
-
var DEFAULT_CHAINS_WITH_TOKENS_PER_PAGE = 1;
|
|
1430
|
-
var MAX_TRANSACTIONS_PER_PAGE = 100;
|
|
1431
1413
|
var NETWORKS = {
|
|
1432
|
-
|
|
1433
|
-
|
|
1414
|
+
SEPOLIA: 11155111,
|
|
1415
|
+
CARDONA: 2442
|
|
1434
1416
|
};
|
|
1435
|
-
var DEFAULT_NETWORK = NETWORKS.
|
|
1417
|
+
var DEFAULT_NETWORK = NETWORKS.SEPOLIA;
|
|
1436
1418
|
|
|
1437
1419
|
// src/native/index.ts
|
|
1438
1420
|
var NativeClient = class {
|
|
@@ -1622,6 +1604,9 @@ var HttpClient = class {
|
|
|
1622
1604
|
signal: controller.signal
|
|
1623
1605
|
});
|
|
1624
1606
|
clearTimeout(timeoutId);
|
|
1607
|
+
if (!response.ok) {
|
|
1608
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
1609
|
+
}
|
|
1625
1610
|
let data;
|
|
1626
1611
|
const contentType = response.headers.get("content-type");
|
|
1627
1612
|
if (contentType?.includes("application/json")) {
|
|
@@ -1629,12 +1614,6 @@ var HttpClient = class {
|
|
|
1629
1614
|
} else {
|
|
1630
1615
|
data = await response.text();
|
|
1631
1616
|
}
|
|
1632
|
-
if (!response.ok) {
|
|
1633
|
-
if (contentType?.includes("application/json")) {
|
|
1634
|
-
} else {
|
|
1635
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
1636
|
-
}
|
|
1637
|
-
}
|
|
1638
1617
|
return {
|
|
1639
1618
|
data,
|
|
1640
1619
|
status: response.status,
|
|
@@ -1664,12 +1643,11 @@ var HttpClient = class {
|
|
|
1664
1643
|
continue;
|
|
1665
1644
|
}
|
|
1666
1645
|
if (Array.isArray(value)) {
|
|
1667
|
-
|
|
1668
|
-
(item
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
}
|
|
1646
|
+
value.forEach((item, index) => {
|
|
1647
|
+
if (item !== void 0 && item !== null) {
|
|
1648
|
+
result[`${fullKey}[${index}]`] = String(item);
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1673
1651
|
} else if (typeof value === "object") {
|
|
1674
1652
|
Object.assign(
|
|
1675
1653
|
result,
|
|
@@ -1699,17 +1677,16 @@ var ArcApiService = class {
|
|
|
1699
1677
|
this.httpClient = new HttpClient({ baseUrl, timeout });
|
|
1700
1678
|
}
|
|
1701
1679
|
// responsible for both chains metadata and tokens
|
|
1702
|
-
// supports limit/offset based pagination
|
|
1703
1680
|
async chains({
|
|
1704
1681
|
withSupportedTokens = false,
|
|
1705
|
-
limit =
|
|
1706
|
-
|
|
1682
|
+
limit = 20,
|
|
1683
|
+
startAfter = 0,
|
|
1707
1684
|
chainIds
|
|
1708
1685
|
} = {}) {
|
|
1709
1686
|
return this.httpClient.get("/metadata/chains", {
|
|
1710
1687
|
withSupportedTokens,
|
|
1711
1688
|
limit,
|
|
1712
|
-
|
|
1689
|
+
startAfter,
|
|
1713
1690
|
chainIds
|
|
1714
1691
|
});
|
|
1715
1692
|
}
|
|
@@ -1718,338 +1695,135 @@ var ArcApiService = class {
|
|
|
1718
1695
|
}
|
|
1719
1696
|
async buildTransaction(builtTransactionRequestBody) {
|
|
1720
1697
|
return this.httpClient.post(
|
|
1721
|
-
"/
|
|
1698
|
+
"/build-transaction",
|
|
1722
1699
|
builtTransactionRequestBody
|
|
1723
1700
|
);
|
|
1724
1701
|
}
|
|
1725
|
-
async buildClaimTransaction(sourceNetworkId, depositCount) {
|
|
1726
|
-
return this.httpClient.post("/routes/build-transaction-for-claim", {
|
|
1727
|
-
sourceNetworkId,
|
|
1728
|
-
depositCount
|
|
1729
|
-
});
|
|
1730
|
-
}
|
|
1731
|
-
// supports cursor based pagination only
|
|
1732
1702
|
async transactions(transactionsRequestQueryParams) {
|
|
1733
1703
|
return this.httpClient.get("/transactions", {
|
|
1734
1704
|
transactionsRequestQueryParams
|
|
1735
1705
|
});
|
|
1736
1706
|
}
|
|
1737
|
-
async tokenMappings(tokenMappingQueryParams) {
|
|
1738
|
-
const { tokenAddress } = tokenMappingQueryParams;
|
|
1739
|
-
return this.httpClient.get(`/token-mappings/${tokenAddress}`);
|
|
1740
|
-
}
|
|
1741
|
-
};
|
|
1742
|
-
|
|
1743
|
-
// src/core/utils/apiError.ts
|
|
1744
|
-
var ApiError = class _ApiError extends Error {
|
|
1745
|
-
constructor(errorResponse) {
|
|
1746
|
-
super(errorResponse.message);
|
|
1747
|
-
this.name = errorResponse.name;
|
|
1748
|
-
this.code = errorResponse.code;
|
|
1749
|
-
this.details = errorResponse.details;
|
|
1750
|
-
if (Error.captureStackTrace) {
|
|
1751
|
-
Error.captureStackTrace(this, _ApiError);
|
|
1752
|
-
}
|
|
1753
|
-
}
|
|
1754
|
-
/**
|
|
1755
|
-
* Create API error from error response
|
|
1756
|
-
*/
|
|
1757
|
-
static fromErrorResponse(errorResponse) {
|
|
1758
|
-
return new _ApiError(errorResponse);
|
|
1759
|
-
}
|
|
1760
|
-
/**
|
|
1761
|
-
* Create fallback error when API completely fails
|
|
1762
|
-
*/
|
|
1763
|
-
static createFallbackError(originalError, operation) {
|
|
1764
|
-
return new _ApiError({
|
|
1765
|
-
status: "error",
|
|
1766
|
-
message: `${operation} failed: ${originalError.message}`,
|
|
1767
|
-
name: "ApiConnectionError",
|
|
1768
|
-
code: 500,
|
|
1769
|
-
details: {
|
|
1770
|
-
originalError: originalError.message,
|
|
1771
|
-
operation
|
|
1772
|
-
}
|
|
1773
|
-
});
|
|
1774
|
-
}
|
|
1775
|
-
/**
|
|
1776
|
-
* Convert to plain object for serialization
|
|
1777
|
-
*/
|
|
1778
|
-
toJSON() {
|
|
1779
|
-
return {
|
|
1780
|
-
name: this.name,
|
|
1781
|
-
message: this.message,
|
|
1782
|
-
code: this.code,
|
|
1783
|
-
details: this.details
|
|
1784
|
-
};
|
|
1785
|
-
}
|
|
1786
1707
|
};
|
|
1787
1708
|
|
|
1788
1709
|
// src/core/index.ts
|
|
1789
1710
|
var CoreClient = class {
|
|
1790
1711
|
constructor(config) {
|
|
1791
|
-
this.config =
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1712
|
+
this.config = config;
|
|
1713
|
+
if (!this.config) {
|
|
1714
|
+
throw new Error("Config is required");
|
|
1715
|
+
}
|
|
1716
|
+
if (!this.config.apiBaseUrl) {
|
|
1717
|
+
throw new Error("API base URL is required");
|
|
1718
|
+
}
|
|
1796
1719
|
const { apiBaseUrl, apiTimeout } = this.config;
|
|
1797
1720
|
this.arcApiService = new ArcApiService({
|
|
1798
|
-
baseUrl: apiBaseUrl
|
|
1799
|
-
timeout: apiTimeout
|
|
1721
|
+
baseUrl: apiBaseUrl,
|
|
1722
|
+
timeout: apiTimeout ?? 3e4
|
|
1800
1723
|
});
|
|
1801
1724
|
}
|
|
1802
|
-
/**
|
|
1803
|
-
* Generic pagination helper for chains API calls (limit and offset based pagination)
|
|
1804
|
-
* Handles automatic pagination to fetch all available data
|
|
1805
|
-
* @param params - Parameters for the chains API call
|
|
1806
|
-
* @param pageSize - Number of items per page (defaults to DEFAULT_CHAINS_PER_PAGE)
|
|
1807
|
-
*/
|
|
1808
|
-
async getAllChainsPaginated(params, pageSize = DEFAULT_CHAINS_PER_PAGE) {
|
|
1809
|
-
try {
|
|
1810
|
-
const firstResponse = await this.arcApiService.chains({
|
|
1811
|
-
...params,
|
|
1812
|
-
limit: pageSize
|
|
1813
|
-
});
|
|
1814
|
-
if (firstResponse.data.status !== "success") {
|
|
1815
|
-
throw ApiError.fromErrorResponse(firstResponse.data);
|
|
1816
|
-
}
|
|
1817
|
-
const firstPageData = firstResponse.data.data;
|
|
1818
|
-
const pagination = firstResponse.data.pagination;
|
|
1819
|
-
const firstPageChains = Array.isArray(firstPageData) ? firstPageData : [];
|
|
1820
|
-
if (!pagination?.total || pagination.total <= pageSize) {
|
|
1821
|
-
return {
|
|
1822
|
-
chains: firstPageChains
|
|
1823
|
-
};
|
|
1824
|
-
}
|
|
1825
|
-
const totalPages = Math.ceil(pagination.total / pageSize);
|
|
1826
|
-
const remainingPages = totalPages - 1;
|
|
1827
|
-
if (remainingPages === 0) {
|
|
1828
|
-
return {
|
|
1829
|
-
chains: firstPageChains
|
|
1830
|
-
};
|
|
1831
|
-
}
|
|
1832
|
-
const remainingPagePromises = Array.from(
|
|
1833
|
-
{ length: remainingPages },
|
|
1834
|
-
(_, index) => {
|
|
1835
|
-
const offset = (index + 1) * pageSize;
|
|
1836
|
-
return this.arcApiService.chains({
|
|
1837
|
-
...params,
|
|
1838
|
-
limit: pageSize,
|
|
1839
|
-
offset
|
|
1840
|
-
});
|
|
1841
|
-
}
|
|
1842
|
-
);
|
|
1843
|
-
const remainingResponses = await Promise.all(remainingPagePromises);
|
|
1844
|
-
for (const response of remainingResponses) {
|
|
1845
|
-
if (response.data.status !== "success") {
|
|
1846
|
-
throw ApiError.fromErrorResponse(response.data);
|
|
1847
|
-
}
|
|
1848
|
-
}
|
|
1849
|
-
const allChains = [
|
|
1850
|
-
...firstPageChains,
|
|
1851
|
-
...remainingResponses.flatMap((response) => {
|
|
1852
|
-
if (response.data.status === "success") {
|
|
1853
|
-
return Array.isArray(response.data.data) ? response.data.data : [];
|
|
1854
|
-
}
|
|
1855
|
-
return [];
|
|
1856
|
-
})
|
|
1857
|
-
];
|
|
1858
|
-
return {
|
|
1859
|
-
chains: allChains
|
|
1860
|
-
};
|
|
1861
|
-
} catch (error) {
|
|
1862
|
-
if (error instanceof ApiError) {
|
|
1863
|
-
throw error;
|
|
1864
|
-
}
|
|
1865
|
-
throw ApiError.createFallbackError(error, "Get chains metadata");
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
1725
|
/**
|
|
1869
1726
|
* Get all chains metadata from AggLayer API
|
|
1870
|
-
* Handles pagination automatically to fetch all available chains
|
|
1871
1727
|
*/
|
|
1872
1728
|
async getAllChains() {
|
|
1873
|
-
|
|
1729
|
+
const response = await this.arcApiService.chains();
|
|
1730
|
+
if (response.data.status === "success") {
|
|
1731
|
+
return response.data.data;
|
|
1732
|
+
}
|
|
1733
|
+
throw new Error(response.data.message);
|
|
1874
1734
|
}
|
|
1875
1735
|
/**
|
|
1876
1736
|
* Get chain metadata by id from AggLayer API
|
|
1877
|
-
* Handles pagination automatically to fetch all available chain metadata
|
|
1878
1737
|
* @param ids - the ids of the chains to get metadata for
|
|
1879
1738
|
*/
|
|
1880
1739
|
async getChainMetadataByChainIds(ids) {
|
|
1881
|
-
|
|
1740
|
+
const response = await this.arcApiService.chains({ chainIds: ids });
|
|
1741
|
+
if (response.data.status === "success") {
|
|
1742
|
+
return response.data.data;
|
|
1743
|
+
}
|
|
1744
|
+
throw new Error(response.data.message);
|
|
1882
1745
|
}
|
|
1883
1746
|
/**
|
|
1884
1747
|
* Get all tokens from AggLayer API
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
);
|
|
1748
|
+
*/
|
|
1749
|
+
async getTokens() {
|
|
1750
|
+
const response = await this.arcApiService.chains({
|
|
1751
|
+
withSupportedTokens: true
|
|
1752
|
+
});
|
|
1753
|
+
if (response.data.status === "success") {
|
|
1754
|
+
return response.data.data;
|
|
1755
|
+
}
|
|
1756
|
+
throw new Error(response.data.message);
|
|
1895
1757
|
}
|
|
1896
1758
|
/**
|
|
1897
1759
|
* Get chain data and tokens by AggLayer API
|
|
1898
1760
|
* @param ids - the ids of the chains to get data and tokens for
|
|
1899
1761
|
*/
|
|
1900
1762
|
async getChainDataAndTokensByChainIds(ids) {
|
|
1901
|
-
|
|
1763
|
+
const response = await this.arcApiService.chains({
|
|
1902
1764
|
chainIds: ids,
|
|
1903
1765
|
withSupportedTokens: true
|
|
1904
1766
|
});
|
|
1767
|
+
if (response.data.status === "success") {
|
|
1768
|
+
return response.data.data;
|
|
1769
|
+
}
|
|
1770
|
+
throw new Error(response.data.message);
|
|
1905
1771
|
}
|
|
1906
1772
|
/**
|
|
1907
1773
|
* Get all routes from AggLayer API
|
|
1908
1774
|
*/
|
|
1909
1775
|
async getRoutes(routesRequestParams) {
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
return response.data.data;
|
|
1914
|
-
}
|
|
1915
|
-
throw ApiError.fromErrorResponse(response.data);
|
|
1916
|
-
} catch (error) {
|
|
1917
|
-
if (error instanceof ApiError) {
|
|
1918
|
-
throw error;
|
|
1919
|
-
}
|
|
1920
|
-
throw ApiError.createFallbackError(error, "Get routes");
|
|
1776
|
+
const response = await this.arcApiService.routes(routesRequestParams);
|
|
1777
|
+
if (response.data.status === "success") {
|
|
1778
|
+
return response.data.data;
|
|
1921
1779
|
}
|
|
1780
|
+
throw new Error(response.data.message);
|
|
1922
1781
|
}
|
|
1923
1782
|
/**
|
|
1924
|
-
*
|
|
1925
|
-
* If route has transactionRequest field, return it directly as calldata
|
|
1926
|
-
* Otherwise, call buildTransaction on route.steps[0] and return that as calldata
|
|
1783
|
+
* Build transaction from a step object
|
|
1927
1784
|
*/
|
|
1928
|
-
async
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
if (
|
|
1933
|
-
|
|
1934
|
-
new Error("Route has no steps to build transaction from"),
|
|
1935
|
-
"Get unsigned transaction"
|
|
1936
|
-
);
|
|
1937
|
-
}
|
|
1938
|
-
try {
|
|
1939
|
-
const response = await this.arcApiService.buildTransaction(
|
|
1940
|
-
route.steps[0]
|
|
1941
|
-
);
|
|
1942
|
-
if (response.data.status === "success") {
|
|
1943
|
-
return response.data.data;
|
|
1944
|
-
}
|
|
1945
|
-
throw ApiError.fromErrorResponse(response.data);
|
|
1946
|
-
} catch (error) {
|
|
1947
|
-
if (error instanceof ApiError) {
|
|
1948
|
-
throw error;
|
|
1949
|
-
}
|
|
1950
|
-
throw ApiError.createFallbackError(
|
|
1951
|
-
error,
|
|
1952
|
-
"Get unsigned transaction"
|
|
1953
|
-
);
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
/**
|
|
1957
|
-
* Get calldata for claim step
|
|
1958
|
-
* Needs to be called separately as claim step is not part of route.
|
|
1959
|
-
*
|
|
1960
|
-
* @developer Note: Do not misinterpret network ID as chain ID.
|
|
1961
|
-
*
|
|
1962
|
-
* @param sourceNetworkId - The source network ID where the transfer was initiated.
|
|
1963
|
-
* @param depositCount - The deposit count associated with the transfer.
|
|
1964
|
-
*/
|
|
1965
|
-
async getClaimUnsignedTransaction(buildClaimTxParams) {
|
|
1966
|
-
try {
|
|
1967
|
-
const response = await this.arcApiService.buildClaimTransaction(
|
|
1968
|
-
buildClaimTxParams.sourceNetworkId,
|
|
1969
|
-
buildClaimTxParams.depositCount
|
|
1970
|
-
);
|
|
1971
|
-
if (response.data.status === "success") {
|
|
1972
|
-
return response.data.data;
|
|
1973
|
-
}
|
|
1974
|
-
throw ApiError.fromErrorResponse(response.data);
|
|
1975
|
-
} catch (error) {
|
|
1976
|
-
if (error instanceof ApiError) {
|
|
1977
|
-
throw error;
|
|
1978
|
-
}
|
|
1979
|
-
throw ApiError.createFallbackError(
|
|
1980
|
-
error,
|
|
1981
|
-
"Get claim unsigned transaction"
|
|
1982
|
-
);
|
|
1785
|
+
async buildTransaction(builtTransactionRequestBody) {
|
|
1786
|
+
const response = await this.arcApiService.buildTransaction(
|
|
1787
|
+
builtTransactionRequestBody
|
|
1788
|
+
);
|
|
1789
|
+
if (response.data.status === "success") {
|
|
1790
|
+
return response.data.data;
|
|
1983
1791
|
}
|
|
1792
|
+
throw new Error(response.data.message);
|
|
1984
1793
|
}
|
|
1985
1794
|
/**
|
|
1986
1795
|
* Get all transactions via web sockets
|
|
1987
1796
|
*/
|
|
1988
1797
|
async getTransactions(transactionsRequestQueryParams) {
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
}
|
|
1995
|
-
try {
|
|
1996
|
-
const response = await this.arcApiService.transactions(
|
|
1997
|
-
transactionsRequestQueryParams
|
|
1998
|
-
);
|
|
1999
|
-
if (response.data.status === "success") {
|
|
2000
|
-
return response.data.data;
|
|
2001
|
-
}
|
|
2002
|
-
throw ApiError.fromErrorResponse(response.data);
|
|
2003
|
-
} catch (error) {
|
|
2004
|
-
if (error instanceof ApiError) {
|
|
2005
|
-
throw error;
|
|
2006
|
-
}
|
|
2007
|
-
throw ApiError.createFallbackError(error, "Get transactions");
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
/**
|
|
2011
|
-
* Get token mappings by token address
|
|
2012
|
-
* @developer Note: Do not misinterpret network ID as chain ID.
|
|
2013
|
-
*
|
|
2014
|
-
* @param tokenAddress
|
|
2015
|
-
*/
|
|
2016
|
-
async getTokenMappings(tokenMappingQueryParams) {
|
|
2017
|
-
try {
|
|
2018
|
-
const response = await this.arcApiService.tokenMappings(
|
|
2019
|
-
tokenMappingQueryParams
|
|
2020
|
-
);
|
|
2021
|
-
if (response.data.status === "success") {
|
|
2022
|
-
return response.data.data;
|
|
2023
|
-
}
|
|
2024
|
-
throw ApiError.fromErrorResponse(response.data);
|
|
2025
|
-
} catch (error) {
|
|
2026
|
-
if (error instanceof ApiError) {
|
|
2027
|
-
throw error;
|
|
2028
|
-
}
|
|
2029
|
-
throw ApiError.createFallbackError(
|
|
2030
|
-
error,
|
|
2031
|
-
"Get custom token mappings"
|
|
2032
|
-
);
|
|
1798
|
+
const response = await this.arcApiService.transactions(
|
|
1799
|
+
transactionsRequestQueryParams
|
|
1800
|
+
);
|
|
1801
|
+
if (response.data.status === "success") {
|
|
1802
|
+
return response.data.data;
|
|
2033
1803
|
}
|
|
1804
|
+
throw new Error(response.data.message);
|
|
2034
1805
|
}
|
|
2035
1806
|
};
|
|
2036
1807
|
|
|
2037
1808
|
// src/index.ts
|
|
2038
|
-
var defaultConfig = {
|
|
2039
|
-
mode: [SDK_MODES.CORE]
|
|
2040
|
-
};
|
|
2041
1809
|
var AggLayerSDK = class {
|
|
2042
|
-
constructor(config
|
|
1810
|
+
constructor(config) {
|
|
2043
1811
|
this.config = config;
|
|
2044
1812
|
if (!config.mode || config.mode && config.mode.length === 0) {
|
|
2045
1813
|
this.config.mode = ["CORE"];
|
|
2046
1814
|
}
|
|
2047
|
-
if (
|
|
2048
|
-
|
|
1815
|
+
if (config.mode.includes(SDK_MODES.CORE)) {
|
|
1816
|
+
if (!this.config.core) {
|
|
1817
|
+
throw new Error("Core config is required");
|
|
1818
|
+
}
|
|
1819
|
+
this.core = new CoreClient(this.config.core);
|
|
2049
1820
|
}
|
|
2050
1821
|
if (this.config.mode?.includes(SDK_MODES.NATIVE)) {
|
|
1822
|
+
if (!this.config.native) {
|
|
1823
|
+
throw new Error("NATIVE config is required");
|
|
1824
|
+
}
|
|
2051
1825
|
const nativeConfig = {
|
|
2052
|
-
defaultNetwork: this.config.native?.defaultNetwork
|
|
1826
|
+
defaultNetwork: this.config.native?.defaultNetwork || DEFAULT_NETWORK,
|
|
2053
1827
|
...this.config.native?.chains && {
|
|
2054
1828
|
chains: this.config.native.chains
|
|
2055
1829
|
},
|
|
@@ -2084,7 +1858,6 @@ var AggLayerSDK = class {
|
|
|
2084
1858
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2085
1859
|
0 && (module.exports = {
|
|
2086
1860
|
AggLayerSDK,
|
|
2087
|
-
ApiError,
|
|
2088
1861
|
SDK_MODES
|
|
2089
1862
|
});
|
|
2090
1863
|
//# sourceMappingURL=index.js.map
|