@elsoul/erpc-sdk 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # `@elsoul/erpc-sdk`
2
2
 
3
3
  Official type-safe TypeScript client for [ERPC](https://erpc.global). Use one
4
- client and one API key for Solana, Ethereum, Avalanche C-Chain, price data,
4
+ client and one API key for Solana, Ethereum, Avalanche C/P/X chains, price data,
5
5
  indexed data, leader and validator data, analytics, subscriptions, and account
6
6
  information.
7
7
 
@@ -36,6 +36,117 @@ erpc.close()
36
36
  JSON-RPC method calls return pending requests. Call `.send()` to perform the
37
37
  network request.
38
38
 
39
+ ## Offline token catalog
40
+
41
+ The token catalog is bundled with the package, so lookups do not need an
42
+ `ErpcClient`, API key, or network request. Deployment IDs are opaque and the
43
+ chain aliases expose those IDs directly:
44
+
45
+ ```ts
46
+ import {
47
+ TOKEN_CHAIN_IDS,
48
+ findTokenDeploymentsBySymbol,
49
+ listTokenDeployments,
50
+ tokens,
51
+ } from '@elsoul/erpc-sdk'
52
+
53
+ const usdcByChain = {
54
+ ethereum: findTokenDeploymentsBySymbol(
55
+ TOKEN_CHAIN_IDS.ethereumMainnet,
56
+ 'USDC',
57
+ ),
58
+ solana: findTokenDeploymentsBySymbol(TOKEN_CHAIN_IDS.solanaMainnet, 'USDC'),
59
+ avalancheC: findTokenDeploymentsBySymbol(
60
+ TOKEN_CHAIN_IDS.avalancheCMainnet,
61
+ 'USDC',
62
+ ),
63
+ }
64
+
65
+ const canonicalEthereumUsdcId = tokens.ethereum.USDC
66
+ const usdDeployments = listTokenDeployments({ stableCurrency: 'USD' })
67
+ ```
68
+
69
+ The result includes every matching deployment and its status, decimals,
70
+ standard, address, and flattened asset metadata. See the
71
+ [canonical registry guide](https://github.com/elsoul/erpc-sdk/blob/main/registry/README.md)
72
+ for the source data and ID policy.
73
+
74
+ ## Offline token rankings
75
+
76
+ Ranking data is bundled as an immutable snapshot and is available without an
77
+ API key or network request:
78
+
79
+ ```ts
80
+ import {
81
+ TOKEN_CHAIN_IDS,
82
+ TOKEN_RANKINGS_METADATA,
83
+ listTokenRankings,
84
+ } from '@elsoul/erpc-sdk'
85
+
86
+ const ethereumRankings = listTokenRankings(TOKEN_CHAIN_IDS.ethereumMainnet)
87
+ console.log({ status: TOKEN_RANKINGS_METADATA.status, ethereumRankings })
88
+ ```
89
+
90
+ Rows use the reviewed ranking metric recorded in
91
+ `TOKEN_RANKINGS_METADATA`. For the native total-supply-value metric, values are
92
+ exact rational values in atomic native units. The snapshot can be unconfigured
93
+ or partial, has no current-time filtering, and does not fetch live prices or
94
+ supply data; check its metadata before presenting a ranking as current.
95
+
96
+ ## Offline DEX and pool catalog
97
+
98
+ DEX deployments, pool addresses, native/wrapped relationships, and
99
+ chain-qualified aliases are bundled as generated data. These lookups are
100
+ offline and use opaque IDs, so an Ethereum USDC address cannot be confused
101
+ with an Avalanche or Solana deployment:
102
+
103
+ The published package baseline is currently `0.6.0`. The DEX catalog and swap
104
+ exports described below are in the source tree for the unreleased `0.7.0`
105
+ line and are not part of published `0.6.0` packages yet.
106
+
107
+ ```ts
108
+ import {
109
+ DEX_CHAIN_IDS,
110
+ dexes,
111
+ findPoolDefinitionsByPair,
112
+ getNativeWrapDefinition,
113
+ pools,
114
+ tokens,
115
+ } from '@elsoul/erpc-sdk'
116
+
117
+ const ethereumPools = findPoolDefinitionsByPair(
118
+ DEX_CHAIN_IDS.ethereum,
119
+ tokens.ethereum.WETH,
120
+ tokens.ethereum.USDC,
121
+ )
122
+ const uniswap = dexes.ethereum.UNISWAP_V2
123
+ const weth = getNativeWrapDefinition(tokens.ethereum.ETH)
124
+ const pool = pools.ethereum.UNISWAP_V2_USDC_WETH
125
+ ```
126
+
127
+ The reviewed Ethereum Uniswap V2 and Avalanche LFJ legacy constant-product
128
+ pools support RPC-only exact-input quotes. Solana Orca and Raydium records are
129
+ available for lookup while their CLMM quote adapters are being added. Catalog
130
+ growth adds lookup and monitoring data; it does not implicitly add swap
131
+ eligibility:
132
+
133
+ ```ts
134
+ const quote = await erpc.swap.quoteExactInput({
135
+ chainId: DEX_CHAIN_IDS.ethereum,
136
+ poolDefinitionId: pool,
137
+ inputTokenDeploymentId: tokens.ethereum.WETH,
138
+ outputTokenDeploymentId: tokens.ethereum.USDC,
139
+ amountIn: '1000000000000000000',
140
+ })
141
+
142
+ console.log(quote.amountOut)
143
+ ```
144
+
145
+ Quotes read the configured EVM RPC at one EIP-1898 block snapshot and apply
146
+ the constant-product formula locally. The request does not build, sign,
147
+ simulate, or broadcast a transaction; route selection, slippage, bridging,
148
+ and Solana CLMM execution are separate capabilities.
149
+
39
150
  ## Namespaces
40
151
 
41
152
  | Namespace | Purpose |
@@ -50,15 +161,22 @@ network request.
50
161
  | `erpc.ethereum.subscriptions` | Ethereum WebSocket subscriptions |
51
162
  | `erpc.avalanche.rpc` | Avalanche C-Chain EVM-compatible JSON-RPC |
52
163
  | `erpc.avalanche.subscriptions` | Avalanche C-Chain WebSocket subscriptions |
164
+ | `erpc.avalanche.avax` | C-Chain AVAX atomic transaction API |
165
+ | `erpc.avalanche.xChain` | X-Chain API |
166
+ | `erpc.avalanche.pChain` | P-Chain API |
167
+ | `erpc.avalanche.proposerVm` | P-Chain proposer VM API |
168
+ | `erpc.avalanche.info` | Network upgrade information |
169
+ | `erpc.avalanche.index` | C/P/X block and X transaction indexes |
53
170
  | `erpc.price` | Price metadata, updates, and streams |
54
171
  | `erpc.account` | ERPC token balance |
55
172
  | `erpc.usage` | Masked monthly API-key usage |
56
173
 
57
174
  `avalancheEndpoint` defaults to `https://ava-rpc.erpc.global` and can be
58
175
  overridden independently from the shared `endpoint` option. The SDK uses its
59
- `/ava` HTTP route and `/ava-ws` WebSocket route. The Avalanche namespace uses
60
- the Ethereum-compatible typed catalog; use `raw` for additional C-Chain
61
- methods.
176
+ `/ava` HTTP route and `/ava-ws` WebSocket route. Native C/P/X methods use named
177
+ parameters; Index calls are routed to the required explicit chain/container
178
+ path. Native and Index batches are rejected locally. Use `raw` with an exact
179
+ wire method name for forward compatibility.
62
180
 
63
181
  ## Examples
64
182
 
@@ -73,6 +191,12 @@ const avalancheBlock = await erpc.avalanche.rpc
73
191
  .eth_getBlockByNumber('latest', false)
74
192
  .send()
75
193
 
194
+ const pChainHeight = await erpc.avalanche.pChain.getHeight().send()
195
+ const xChainHeight = await erpc.avalanche.xChain.getHeight().send()
196
+ const indexedTransaction = await erpc.avalanche.index.xChainTransactions
197
+ .getContainerByID({ id: transactionId })
198
+ .send()
199
+
76
200
  const prices = await erpc.price.getLatestPriceUpdates({
77
201
  ids: [feedId],
78
202
  parsed: true,
@@ -128,6 +252,7 @@ const result = await erpc.solana.rpc
128
252
  ## Documentation
129
253
 
130
254
  - [Complete guide](https://github.com/elsoul/erpc-sdk#readme)
255
+ - [Solana transaction v1 guide](https://github.com/elsoul/erpc-sdk/blob/main/packages/typescript/docs/solana-v1.md)
131
256
  - [Method availability](https://github.com/elsoul/erpc-sdk/blob/main/docs/METHODS.md)
132
257
  - [Roadmap](https://github.com/elsoul/erpc-sdk/blob/main/ROADMAP.md)
133
258
  - [Security policy](https://github.com/elsoul/erpc-sdk/blob/main/SECURITY.md)