@elsoul/erpc-sdk 0.7.0 → 0.8.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/README.md CHANGED
@@ -1,9 +1,10 @@
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/P/X chains, price data,
4
+ client and an 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
- information.
6
+ information. Caller-owned direct endpoints can be selected for Solana,
7
+ Ethereum, and Avalanche C-Chain JSON-RPC.
7
8
 
8
9
  ## Install
9
10
 
@@ -36,6 +37,59 @@ erpc.close()
36
37
  JSON-RPC method calls return pending requests. Call `.send()` to perform the
37
38
  network request.
38
39
 
40
+ ## Direct RPC endpoints (introduced in 0.8.0)
41
+
42
+ Caller-owned direct endpoint overrides were introduced in `0.8.0` and require
43
+ that package when installed from a registry. The `0.7.0` package does not
44
+ include this API; check the package version badge and the [latest GitHub
45
+ release](https://github.com/elsoul/erpc-sdk/releases/latest) for live
46
+ publication status.
47
+
48
+ Use a caller-owned endpoint without an eRPC API key by supplying at least one
49
+ chain override. The HTTP URL is the complete JSON-RPC request target, so its
50
+ path and query are preserved:
51
+
52
+ ```ts
53
+ const erpc = createErpcClient({
54
+ ethereumRpc: {
55
+ httpUrl: 'https://node.example/customer/path?region=eu',
56
+ },
57
+ })
58
+
59
+ const chainId = await erpc.ethereum.rpc.eth_chainId().send()
60
+ ```
61
+
62
+ The configured HTTP URL is treated as the final target. Redirect responses are
63
+ returned as HTTP errors, and no redirected request is made.
64
+
65
+ Direct HTTP requests use `credentials: 'omit'`, so ambient browser cookies and
66
+ authentication are not sent implicitly. Add authentication explicitly through
67
+ the endpoint's scoped headers when needed.
68
+
69
+ Provide an independent WebSocket URL and headers when the node requires them:
70
+
71
+ ```ts
72
+ import type { RpcEndpointConfig } from '@elsoul/erpc-sdk'
73
+
74
+ const ethereumRpc: RpcEndpointConfig = {
75
+ httpUrl: 'https://node.example/rpc',
76
+ webSocketUrl: 'wss://node.example/socket',
77
+ headers: {
78
+ authorization: 'Bearer node-token',
79
+ },
80
+ }
81
+
82
+ const erpc = createErpcClient({
83
+ ethereumRpc,
84
+ })
85
+ ```
86
+
87
+ `solanaRpc`, `ethereumRpc`, and `avalancheCRpc` select direct Solana, Ethereum,
88
+ and Avalanche C-Chain JSON-RPC transports. Without an API key, non-overridden
89
+ chains and ERPC REST, native, and index services fail locally. The
90
+ `RpcEndpointConfig.headers` field applies to direct HTTP requests only; those
91
+ headers are never sent on WSS connections.
92
+
39
93
  ## Offline token catalog
40
94
 
41
95
  The token catalog is bundled with the package, so lookups do not need an
@@ -100,9 +154,9 @@ chain-qualified aliases are bundled as generated data. These lookups are
100
154
  offline and use opaque IDs, so an Ethereum USDC address cannot be confused
101
155
  with an Avalanche or Solana deployment:
102
156
 
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.
157
+ The reviewed DEX catalog and swap exports were introduced in `0.7.0`.
158
+ Unsigned EVM preparation and simulation below were introduced in `0.8.0` and
159
+ require that package.
106
160
 
107
161
  ```ts
108
162
  import {
@@ -147,6 +201,101 @@ the constant-product formula locally. The request does not build, sign,
147
201
  simulate, or broadcast a transaction; route selection, slippage, bridging,
148
202
  and Solana CLMM execution are separate capabilities.
149
203
 
204
+ The two reviewed EVM pools also support unsigned ERC-20 exact-input
205
+ preparation and RPC simulation:
206
+
207
+ ```ts
208
+ const request = {
209
+ chainId: DEX_CHAIN_IDS.ethereum,
210
+ poolDefinitionId: 'pool-0001',
211
+ inputTokenDeploymentId: tokens.ethereum.WETH,
212
+ outputTokenDeploymentId: tokens.ethereum.USDC,
213
+ amountIn: '1000000000000000000',
214
+ sender: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
215
+ recipient: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
216
+ slippageBps: 50,
217
+ deadline: String(Math.floor(Date.now()/1000)+300),
218
+ }
219
+
220
+ const prepared = await erpc.swap.prepareExactInputSwap(request)
221
+
222
+ const simulation = await erpc.swap.simulateExactInputSwap(request)
223
+ ```
224
+
225
+ Preparation performs a fresh quote, validates the reviewed router and wrapped
226
+ native deployment, and returns an immutable chain-bound unsigned transaction
227
+ envelope. It does not create approval calldata, sign, send, or fill wallet
228
+ fields. When a wallet API needs a raw transaction object, explicitly convert
229
+ the envelope, for example:
230
+
231
+ ```ts
232
+ const { chainId: _chainId, kind: _kind, ...walletTransaction } =
233
+ prepared.transaction
234
+ await wallet.sendTransaction(walletTransaction)
235
+ ```
236
+
237
+ Use the `simulation` result to inspect the canonical allowance and router
238
+ amounts before asking the caller's wallet to manage allowance, signing, or
239
+ broadcasting. The simulation call itself is read-only and uses only the
240
+ configured RPC transport.
241
+
242
+ ## Optional Mayan Swift v2 bridge (introduced in 0.8.0)
243
+
244
+ The `0.8.0` API adds the Mayan Swift v2 client as an explicit standalone adapter
245
+ for the reviewed
246
+ issued EURC routes between Ethereum and Solana. It is not attached to the
247
+ default `ErpcClient`; construct it separately when the external provider and
248
+ its solver, relayer, and explorer dependencies are acceptable:
249
+
250
+ ```ts
251
+ import {
252
+ createMayanSwiftV2BridgeClient,
253
+ TOKEN_CHAIN_IDS,
254
+ } from '@elsoul/erpc-sdk'
255
+
256
+ const mayan = createMayanSwiftV2BridgeClient({
257
+ builderEndpoint: 'https://tx-builder.mayan.finance',
258
+ explorerEndpoint: 'https://explorer-api.mayan.finance/v3',
259
+ builderApiKey: 'provider-key',
260
+ })
261
+ const quotes = await mayan.quoteExactInput({
262
+ sourceChainId: TOKEN_CHAIN_IDS.ethereumMainnet,
263
+ destinationChainId: TOKEN_CHAIN_IDS.solanaMainnet,
264
+ sourceTokenDeploymentId: 'deployment-0011',
265
+ destinationTokenDeploymentId: 'deployment-0013',
266
+ amountIn: '1000000',
267
+ slippageBps: 50,
268
+ })
269
+ ```
270
+
271
+ The adapter posts the exact route request to Mayan's `/quote`, preserves the
272
+ provider-signed quote text, and can build a structurally checked unsigned
273
+ source transaction with `buildUnsigned`. It does not verify the provider
274
+ signature locally or prove settlement, and it does not sign, approve, submit,
275
+ refund, or broadcast transactions. For an EVM build, convert the returned
276
+ chain-bound envelope before passing fields to a wallet API:
277
+
278
+ ```ts
279
+ const built = await mayan.buildUnsigned({
280
+ quote: quotes[0],
281
+ swapperAddress: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
282
+ destinationAddress: '11111111111111111111111111111111',
283
+ })
284
+ if (built.transaction.kind === 'evm-unsigned-transaction') {
285
+ const { chainId: _chainId, kind: _kind, ...walletTransaction } =
286
+ built.transaction
287
+ await wallet.sendTransaction(walletTransaction)
288
+ }
289
+ ```
290
+
291
+ `builderEndpoint` and `explorerEndpoint` default to
292
+ `https://tx-builder.mayan.finance` and `https://explorer-api.mayan.finance/v3`;
293
+ set them to caller-approved base URLs to customize the provider endpoints.
294
+ `getStatus` reads the indexed status endpoint and reports the provider assertion
295
+ as unverified local settlement state. `builderApiKey` is a separate Mayan
296
+ build-only key sent only to `/build`; quote and status calls do not receive it,
297
+ and no eRPC credential is forwarded.
298
+
150
299
  ## Namespaces
151
300
 
152
301
  | Namespace | Purpose |