erpc-sdk 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0b83f0a7e0881001a42033b8c7116ea6407f1e024cd258e9cf7df546eb0d875
4
- data.tar.gz: 48a8098b1739371b431ba2e534644002647ffff6fa4c57889cf0723ffeecfdc1
3
+ metadata.gz: 4f52f98e6f0df7cf416a17a3db62fe29b2182da2f4888eb0fd02293402c1a664
4
+ data.tar.gz: 9d25c259f339edfd2c4c2e5080a7a6befd00cb587f2281ab9297ea71f83c974c
5
5
  SHA512:
6
- metadata.gz: 6badad47dbad416e9cea863d849de82beefd7fbf9448acce21b9a146ebf4f13e1260aad6591b94bd33a71f21cb832640a66bb3767c8a40f3785ab2629d9f1a1c
7
- data.tar.gz: d9c6f52fbfc4ca654e8540640a50dc6fdda24773d6bb3ed54752cd8d6ba99fdf33db19a92522acdef95c5761aa9d4e702ff024f773fd2fff06196c523504eab3
6
+ metadata.gz: 70db8d372a797587c54a69992689c533ae20204a8c215c0637753524c19e47465935deaf1cec231161eb6ed1a50a2f044a084f84b1e281cabff1fe7a14bcb6ba
7
+ data.tar.gz: f505d87463f95c0ac66c4d9789045dc92cd25765d3ed2d55538f4497d7894f1f599f020afd47f22627085df07f425cfef066911c3879d643ddd0739b39f52027
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # ERPC SDK for Ruby
2
2
 
3
- Synchronous Ruby client for ERPC. It covers standard Solana and Ethereum
4
- JSON-RPC, indexed data, analytics, WebSocket subscriptions, price REST and
5
- server-sent events, account usage, and scoped Cloud reads.
3
+ Synchronous Ruby client for ERPC. It covers standard Solana, Ethereum, and
4
+ Avalanche C-Chain JSON-RPC, indexed data, analytics, WebSocket subscriptions,
5
+ price REST and server-sent events, account usage, and scoped Cloud reads.
6
6
 
7
7
  ```bash
8
8
  gem install erpc-sdk
@@ -21,7 +21,8 @@ begin
21
21
 
22
22
  slot = erpc.solana.rpc.get_slot.send
23
23
  chain_id = erpc.ethereum.rpc.eth_chain_id.send
24
- puts({ slot: slot, chain_id: chain_id })
24
+ avalanche_chain_id = erpc.avalanche.rpc.eth_chain_id.send
25
+ puts({ slot: slot, chain_id: chain_id, avalanche_chain_id: avalanche_chain_id })
25
26
  ensure
26
27
  erpc&.close
27
28
  end
@@ -44,10 +45,17 @@ only when `send` is called. `request` restricts calls to the namespace catalog;
44
45
  | `erpc.solana.subscriptions` | Enhanced WebSocket subscriptions |
45
46
  | `erpc.ethereum.rpc` | Standard Ethereum JSON-RPC |
46
47
  | `erpc.ethereum.subscriptions` | Ethereum WebSocket subscriptions |
48
+ | `erpc.avalanche.rpc` | Avalanche C-Chain EVM-compatible JSON-RPC |
49
+ | `erpc.avalanche.subscriptions` | Avalanche C-Chain WebSocket subscriptions |
47
50
  | `erpc.price` | Price metadata, updates, and SSE streams |
48
51
  | `erpc.account` | Token balance |
49
52
  | `erpc.usage` | Masked monthly API-key usage |
50
53
 
54
+ `avalanche_endpoint` defaults to `https://ava-rpc.erpc.global` and can be
55
+ overridden independently. The SDK uses its `/ava` HTTP route and `/ava-ws`
56
+ WebSocket route. The Avalanche namespace uses the Ethereum-compatible typed
57
+ catalog; use `raw` for additional C-Chain methods.
58
+
51
59
  ## Intact batches
52
60
 
53
61
  ```ruby
@@ -74,7 +82,7 @@ end
74
82
  ```
75
83
 
76
84
  Subscriptions use a lazy persistent WebSocket connection. `unsubscribe` is
77
- idempotent, and `close` closes both network subscription transports.
85
+ idempotent, and `close` closes all network subscription transports.
78
86
 
79
87
  ## Cloud reads
80
88
 
@@ -3,9 +3,10 @@
3
3
  module ERPC
4
4
  SolanaClient = Struct.new(:rpc, :das, :history, :leaders, :analytics, :subscriptions, keyword_init: true)
5
5
  EthereumClient = Struct.new(:rpc, :subscriptions, keyword_init: true)
6
+ AvalancheClient = Struct.new(:rpc, :subscriptions, keyword_init: true)
6
7
 
7
8
  class Client
8
- attr_reader :solana, :ethereum, :price, :account, :usage
9
+ attr_reader :solana, :ethereum, :avalanche, :price, :account, :usage
9
10
 
10
11
  def initialize(config, http_adapter: nil, websocket_factory: nil)
11
12
  adapter = http_adapter || NetHttpAdapter.new
@@ -23,6 +24,13 @@ module ERPC
23
24
  timeout: config.timeout,
24
25
  adapter: adapter
25
26
  )
27
+ avalanche_transport = HttpJsonRpcTransport.new(
28
+ api_key: config.api_key,
29
+ endpoint: URLs.with_path(config.avalanche_endpoint, "/ava"),
30
+ headers: config.headers,
31
+ timeout: config.timeout,
32
+ adapter: adapter
33
+ )
26
34
  solana_ws = WebSocketJsonRpcTransport.new(
27
35
  URLs.websocket(config.endpoint, config.api_key),
28
36
  config.api_key,
@@ -35,6 +43,12 @@ module ERPC
35
43
  config.timeout,
36
44
  connection_factory: websocket_factory
37
45
  )
46
+ avalanche_ws = WebSocketJsonRpcTransport.new(
47
+ URLs.websocket(config.avalanche_endpoint, config.api_key, "/ava-ws"),
48
+ config.api_key,
49
+ config.timeout,
50
+ connection_factory: websocket_factory
51
+ )
38
52
 
39
53
  @solana = SolanaClient.new(
40
54
  rpc: RpcNamespace.new(
@@ -62,6 +76,10 @@ module ERPC
62
76
  rpc: RpcNamespace.new(ethereum_transport, ETHEREUM_RPC_METHODS, parameter_mode: :positional),
63
77
  subscriptions: EthereumSubscriptions.new(ethereum_ws)
64
78
  )
79
+ @avalanche = AvalancheClient.new(
80
+ rpc: RpcNamespace.new(avalanche_transport, ETHEREUM_RPC_METHODS, parameter_mode: :positional),
81
+ subscriptions: EthereumSubscriptions.new(avalanche_ws)
82
+ )
65
83
  @price = PriceClient.new(
66
84
  RestTransport.new(
67
85
  credential: config.api_key,
@@ -98,6 +116,7 @@ module ERPC
98
116
  @closed = true
99
117
  solana.subscriptions.close
100
118
  ethereum.subscriptions.close
119
+ avalanche.subscriptions.close
101
120
  nil
102
121
  end
103
122
  end
@@ -4,6 +4,7 @@ require "uri"
4
4
 
5
5
  module ERPC
6
6
  DEFAULT_ENDPOINT = "https://edge.erpc.global"
7
+ DEFAULT_AVALANCHE_ENDPOINT = "https://ava-rpc.erpc.global"
7
8
  DEFAULT_ACCOUNT_ENDPOINT = "https://solana-rpc.erpc.global"
8
9
  DEFAULT_USER_ENDPOINT = "https://user-api.erpc.global"
9
10
  DEFAULT_TIMEOUT = 30.0
@@ -56,15 +57,17 @@ module ERPC
56
57
  end
57
58
 
58
59
  class ClientConfig
59
- attr_reader :api_key, :endpoint, :account_endpoint, :user_endpoint, :headers, :timeout
60
+ attr_reader :api_key, :endpoint, :account_endpoint, :user_endpoint, :headers, :timeout, :avalanche_endpoint
60
61
 
61
62
  def initialize(api_key:, endpoint: DEFAULT_ENDPOINT, account_endpoint: DEFAULT_ACCOUNT_ENDPOINT,
62
- user_endpoint: DEFAULT_USER_ENDPOINT, headers: {}, timeout: DEFAULT_TIMEOUT)
63
+ user_endpoint: DEFAULT_USER_ENDPOINT, headers: {}, timeout: DEFAULT_TIMEOUT,
64
+ avalanche_endpoint: DEFAULT_AVALANCHE_ENDPOINT)
63
65
  @api_key = api_key.to_s.strip
64
66
  raise ConfigError, "api_key must not be empty" if @api_key.empty?
65
67
  raise ConfigError, "timeout must be positive" unless timeout.is_a?(Numeric) && timeout.finite? && timeout.positive?
66
68
 
67
69
  @endpoint = URLs.normalize_endpoint(endpoint)
70
+ @avalanche_endpoint = URLs.normalize_endpoint(avalanche_endpoint)
68
71
  @account_endpoint = URLs.normalize_endpoint(account_endpoint)
69
72
  @user_endpoint = URLs.normalize_endpoint(user_endpoint)
70
73
  @headers = headers.to_h.transform_keys(&:to_s).transform_values(&:to_s).freeze
@@ -73,6 +76,7 @@ module ERPC
73
76
 
74
77
  def inspect
75
78
  "#<#{self.class} api_key=[REDACTED] endpoint=#{endpoint.inspect} " \
79
+ "avalanche_endpoint=#{avalanche_endpoint.inspect} " \
76
80
  "account_endpoint=#{account_endpoint.inspect} user_endpoint=#{user_endpoint.inspect} " \
77
81
  "header_names=#{headers.keys.inspect} timeout=#{timeout.inspect}>"
78
82
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ERPC
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erpc-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ELSOUL LABO B.V.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-29 00:00:00.000000000 Z
11
+ date: 2026-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -50,8 +50,8 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '14'
53
- description: Ruby client for ERPC JSON-RPC, REST, streams, subscriptions, and Cloud
54
- reads.
53
+ description: Ruby client for ERPC Solana, Ethereum, and Avalanche RPC, REST, streams,
54
+ subscriptions, and Cloud reads.
55
55
  email:
56
56
  executables: []
57
57
  extensions: []
@@ -96,5 +96,5 @@ requirements: []
96
96
  rubygems_version: 3.3.27
97
97
  signing_key:
98
98
  specification_version: 4
99
- summary: Ruby SDK for ERPC
99
+ summary: Multi-network Ruby SDK for ERPC
100
100
  test_files: []