erpc-sdk 0.7.0 → 0.8.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.
- checksums.yaml +4 -4
- data/README.md +125 -5
- data/lib/erpc_sdk/bridge.rb +1507 -0
- data/lib/erpc_sdk/client.rb +210 -75
- data/lib/erpc_sdk/config.rb +107 -8
- data/lib/erpc_sdk/errors.rb +100 -9
- data/lib/erpc_sdk/generated/bridge_capabilities.rb +9 -0
- data/lib/erpc_sdk/generated/swap_execution_capabilities.rb +11 -0
- data/lib/erpc_sdk/swap.rb +679 -0
- data/lib/erpc_sdk/transport.rb +69 -20
- data/lib/erpc_sdk/version.rb +1 -1
- data/lib/erpc_sdk/websocket.rb +45 -13
- data/lib/erpc_sdk.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e1e41b728c27ddf8d794aa91d44a2503204b00f6953580d0db2498d44a5b041b
|
|
4
|
+
data.tar.gz: 5dc759af0fe505cd30f6fb45cf43344687d2df1f7aff34cb4b66b8e787419e8b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 982fb52b52b3e88855eb4405aece06bf5f76518202cd990458ae9955b1796b4756cd61db2373b86072e75db60f4371d9674a4d7b4e927b7deba898a47130bc26
|
|
7
|
+
data.tar.gz: d174e090167c4a1b45a2b35f7d19dacffad5e57b5d8842fbf9335c9c4354f4df7df9c08fa83665ec9f97376f60fc4678696ac39f0e54f5499b664b9333146bed
|
data/README.md
CHANGED
|
@@ -28,6 +28,39 @@ ensure
|
|
|
28
28
|
end
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
## Dedicated RPC endpoints (introduced in 0.8.0)
|
|
32
|
+
|
|
33
|
+
Supply a full HTTP(S) JSON-RPC URL to use a customer-owned node without an
|
|
34
|
+
eRPC API key. The URL path and query are sent exactly as provided. Direct URLs
|
|
35
|
+
are final HTTP request targets; the Ruby adapter does not follow redirects.
|
|
36
|
+
Caller-owned direct endpoint overrides were introduced in `0.8.0` and require
|
|
37
|
+
that gem version when installed from a registry. The published `0.7.0` gem does
|
|
38
|
+
not include them; check the package version badge and the [latest GitHub
|
|
39
|
+
release](https://github.com/elsoul/erpc-sdk/releases/latest) for live
|
|
40
|
+
publication status.
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
config = ERPC::ClientConfig.new(
|
|
44
|
+
ethereum_rpc: ERPC::RpcEndpointConfig.new(
|
|
45
|
+
http_url: "https://node.example/rpc/customer?token=..."
|
|
46
|
+
)
|
|
47
|
+
)
|
|
48
|
+
erpc = ERPC::Client.new(config)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
An independent WebSocket URL enables subscriptions. Scoped headers apply to
|
|
52
|
+
direct HTTP requests for that RPC endpoint.
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
config = ERPC::ClientConfig.new(
|
|
56
|
+
ethereum_rpc: ERPC::RpcEndpointConfig.new(
|
|
57
|
+
http_url: "https://node.example/rpc",
|
|
58
|
+
websocket_url: "wss://ws.example/socket?token=...",
|
|
59
|
+
headers: { "authorization" => "Bearer node-token" }
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
```
|
|
63
|
+
|
|
31
64
|
## Offline token catalog
|
|
32
65
|
|
|
33
66
|
The gem bundles a generated token catalog for Ethereum, Solana, and Avalanche
|
|
@@ -62,9 +95,10 @@ README](https://github.com/elsoul/erpc-sdk/blob/main/registry/README.md).
|
|
|
62
95
|
The gem also bundles the generated token-ranking snapshot. Ranking metadata
|
|
63
96
|
uses the exact `schema_version`, `metric`, `as_of`, `content_digest`,
|
|
64
97
|
`status`, `coverage`, and `source_ids` fields from the registry, and all
|
|
65
|
-
nested values are frozen.
|
|
66
|
-
`
|
|
67
|
-
|
|
98
|
+
nested values are frozen. Read the bundled metadata for the current `status`,
|
|
99
|
+
`metric`, `as_of`, `content_digest`, and `coverage` before presenting a result
|
|
100
|
+
as current; the metadata is the source of truth for whether rows are available
|
|
101
|
+
and how much coverage they represent.
|
|
68
102
|
|
|
69
103
|
```ruby
|
|
70
104
|
rankings = ERPC::TokenRankings.list_token_rankings(
|
|
@@ -88,8 +122,8 @@ being treated as zero.
|
|
|
88
122
|
|
|
89
123
|
The source tree bundles the generated DEX deployment, pool, and native/wrapped
|
|
90
124
|
token catalog. These lookups are synchronous and offline, and the returned
|
|
91
|
-
records are frozen. The published `0.
|
|
92
|
-
|
|
125
|
+
records are frozen. The published `0.7.0` gem includes these DEX and swap
|
|
126
|
+
exports.
|
|
93
127
|
|
|
94
128
|
```ruby
|
|
95
129
|
pool = ERPC::DexCatalog.get_pool_definition("pool-0001")
|
|
@@ -144,6 +178,54 @@ quote-enabled; an otherwise valid request outside those tuples returns
|
|
|
144
178
|
Transaction building, signing, sending, route search, native wrapping, and
|
|
145
179
|
cross-chain bridging are outside this quote API.
|
|
146
180
|
|
|
181
|
+
## Unsigned swap preparation and simulation
|
|
182
|
+
|
|
183
|
+
For the reviewed Ethereum Uniswap V2 and Avalanche LFJ V1 pools, the client
|
|
184
|
+
can prepare an unsigned ERC-20-to-ERC-20 router call and simulate it against a
|
|
185
|
+
fresh RPC snapshot. The methods use the selected dedicated chain transport
|
|
186
|
+
when one is configured.
|
|
187
|
+
|
|
188
|
+
```ruby
|
|
189
|
+
request = {
|
|
190
|
+
chainId: ERPC::DexChainIDs::ETHEREUM_MAINNET,
|
|
191
|
+
poolDefinitionId: ERPC::Pools::Ethereum.fetch(:UNISWAP_V2_USDC_WETH),
|
|
192
|
+
inputTokenDeploymentId: ERPC::Tokens::Ethereum.fetch(:WETH),
|
|
193
|
+
outputTokenDeploymentId: ERPC::Tokens::Ethereum.fetch(:USDC),
|
|
194
|
+
amountIn: "1000000000000000000",
|
|
195
|
+
sender: "0x1111111111111111111111111111111111111111",
|
|
196
|
+
recipient: "0x2222222222222222222222222222222222222222",
|
|
197
|
+
slippageBps: 50,
|
|
198
|
+
deadline: (Time.now.to_i+300).to_s
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
preparation = erpc.swap.prepare_exact_input_swap(request)
|
|
202
|
+
simulation = erpc.swap.simulate_exact_input_swap(request)
|
|
203
|
+
puts preparation.fetch("minimumAmountOut")
|
|
204
|
+
puts simulation.fetch("amountOut")
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The preparation contains a chain-bound transaction envelope. Convert its
|
|
208
|
+
fields to the wallet library's native request type and convert the CAIP-2
|
|
209
|
+
`chainId` separately when that library expects a numeric network ID:
|
|
210
|
+
|
|
211
|
+
```ruby
|
|
212
|
+
envelope = preparation.fetch("transaction")
|
|
213
|
+
wallet_request = {
|
|
214
|
+
chain_id: Integer(envelope.fetch("chainId").delete_prefix("eip155:")),
|
|
215
|
+
from: envelope.fetch("from"),
|
|
216
|
+
to: envelope.fetch("to"),
|
|
217
|
+
data: envelope.fetch("data"),
|
|
218
|
+
value: envelope.fetch("value")
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
The SDK never creates approval calldata, changes allowances, signs, or sends
|
|
223
|
+
the envelope. Simulation checks the input-token allowance before calling the
|
|
224
|
+
router and validates the returned amounts. `SwapExecutionError#code` exposes
|
|
225
|
+
stable execution codes such as `SWAP_INSUFFICIENT_ALLOWANCE`,
|
|
226
|
+
`SWAP_SIMULATION_REVERTED`, and `SWAP_INVALID_SIMULATION`; transport and
|
|
227
|
+
non-revert JSON-RPC errors retain their native classes.
|
|
228
|
+
|
|
147
229
|
Both exact wire names (`getSlot`, `eth_chainId`) and idiomatic snake-case
|
|
148
230
|
aliases (`get_slot`, `eth_chain_id`) create inert requests. Network I/O starts
|
|
149
231
|
only when `send` is called. `request` restricts calls to the namespace catalog;
|
|
@@ -158,6 +240,44 @@ base64 payload with `"encoding" => "base64"` to `send_transaction` or
|
|
|
158
240
|
`simulate_transaction`; the SDK forwards the request and response unchanged.
|
|
159
241
|
See the [Solana v1 guide](https://github.com/elsoul/erpc-sdk/blob/main/packages/typescript/docs/solana-v1.md).
|
|
160
242
|
|
|
243
|
+
## Optional Mayan Swift v2 bridge (introduced in 0.8.0)
|
|
244
|
+
|
|
245
|
+
The `0.8.0` API's `MayanSwiftV2BridgeClient` is an explicit standalone adapter for the reviewed
|
|
246
|
+
issued EURC routes between Ethereum mainnet and Solana mainnet. It does not
|
|
247
|
+
attach to `ERPC::Client`, inherit eRPC credentials or headers, or make any
|
|
248
|
+
request during construction. Configure the Mayan builder and Explorer
|
|
249
|
+
endpoints separately when needed:
|
|
250
|
+
|
|
251
|
+
```ruby
|
|
252
|
+
bridge = ERPC::MayanSwiftV2BridgeClient.new(
|
|
253
|
+
builder_endpoint: "https://tx-builder.mayan.finance",
|
|
254
|
+
explorer_endpoint: "https://explorer-api.mayan.finance/v3",
|
|
255
|
+
builder_api_key: ENV.fetch("MAYAN_BUILDER_API_KEY"),
|
|
256
|
+
http_adapter: ERPC::NetHttpAdapter.new
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
quotes = bridge.quote_exact_input(
|
|
260
|
+
"sourceChainId" => ERPC::TokenChainIDs::ETHEREUM_MAINNET,
|
|
261
|
+
"destinationChainId" => ERPC::TokenChainIDs::SOLANA_MAINNET,
|
|
262
|
+
"sourceTokenDeploymentId" => "deployment-0011",
|
|
263
|
+
"destinationTokenDeploymentId" => "deployment-0013",
|
|
264
|
+
"amountIn" => "100000000",
|
|
265
|
+
"slippageBps" => 50
|
|
266
|
+
)
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
The adapter exposes `quote_exact_input`, `build_unsigned`, and `get_status`.
|
|
270
|
+
Builds return unsigned, structurally checked provider transactions and an
|
|
271
|
+
Ethereum allowance description; the SDK does not approve, sign, broadcast,
|
|
272
|
+
submit, cancel, refund, or claim settlement verification. Provider source
|
|
273
|
+
swaps use Mayan's disclosed internal USDC path (and Jupiter v6 for Solana
|
|
274
|
+
source orders), so this optional adapter is separate from the SDK's configured
|
|
275
|
+
RPC-only swap helpers. The defaults are `https://tx-builder.mayan.finance` for
|
|
276
|
+
quote/build and `https://explorer-api.mayan.finance/v3` for indexed status; set
|
|
277
|
+
`builder_endpoint` and `explorer_endpoint` to customize them. The
|
|
278
|
+
`builder_api_key` is a separate Mayan build-only key and is never an eRPC
|
|
279
|
+
credential. `BridgeError#code` provides stable secret-free errors.
|
|
280
|
+
|
|
161
281
|
## Namespaces
|
|
162
282
|
|
|
163
283
|
| Namespace | Purpose |
|