@sentio/runtime 4.0.0-rc.7 → 4.0.0-rc.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.
@@ -10,7 +10,7 @@ import {
10
10
  locatePackageJson,
11
11
  require_lib,
12
12
  uResponseNotFound
13
- } from "./chunk-Q4CE6IMV.js";
13
+ } from "./chunk-7JGO6QCN.js";
14
14
  import {
15
15
  ExecutionConfigSchema,
16
16
  PluginManager,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentio/runtime",
3
- "version": "4.0.0-rc.7",
3
+ "version": "4.0.0-rc.8",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,10 @@
1
+ export interface RpcConfig {
2
+ Url: string
3
+ Meta?: Record<string, string>
4
+ }
5
+
1
6
  export interface ChainConfig {
2
7
  ChainID: string
3
8
  Https?: string[]
4
- ChainServer?: string
9
+ Rpc?: RpcConfig
5
10
  }
package/src/endpoints.ts CHANGED
@@ -2,15 +2,30 @@ import path from 'path'
2
2
  import fs from 'fs-extra'
3
3
  import { ChainConfig } from './chain-config.js'
4
4
 
5
+ /**
6
+ * Resolved RPC endpoint for a chain: the base URL plus optional gRPC metadata
7
+ * (key-value pairs) attached to every request, e.g. the `authority` routing key
8
+ * for the Sui gRPC client talking to the Sentio rpc-node.
9
+ */
10
+ export interface ChainRpc {
11
+ url: string
12
+ meta?: Record<string, string>
13
+ }
14
+
5
15
  export class Endpoints {
6
16
  static INSTANCE: Endpoints = new Endpoints()
7
17
 
8
18
  concurrency = 8
9
19
  priceFeedAPI = ''
10
20
 
11
- chainServer = new Map<string, string>()
21
+ chainRpc = new Map<string, ChainRpc>()
12
22
 
13
23
  batchCount = 1
24
+
25
+ /** Convenience accessor for callers that only need the endpoint URL. */
26
+ getChainRpcUrl(chainId: string): string | undefined {
27
+ return this.chainRpc.get(chainId)?.url
28
+ }
14
29
  }
15
30
 
16
31
  export function configureEndpoints(options: any) {
@@ -30,12 +45,15 @@ export function configureEndpoints(options: any) {
30
45
 
31
46
  for (const [id, config] of Object.entries(chainsConfig)) {
32
47
  const chainConfig = config as ChainConfig
33
- if (chainConfig.ChainServer) {
34
- Endpoints.INSTANCE.chainServer.set(id, chainConfig.ChainServer)
48
+ if (chainConfig.Rpc?.Url) {
49
+ Endpoints.INSTANCE.chainRpc.set(id, {
50
+ url: chainConfig.Rpc.Url,
51
+ meta: chainConfig.Rpc.Meta
52
+ })
35
53
  } else {
36
54
  const http = chainConfig.Https?.[0]
37
55
  if (http) {
38
- Endpoints.INSTANCE.chainServer.set(id, http)
56
+ Endpoints.INSTANCE.chainRpc.set(id, { url: http })
39
57
  } else {
40
58
  console.error('not valid config for chain', id)
41
59
  }
package/src/provider.ts CHANGED
@@ -30,7 +30,7 @@ export function getProvider(chainId?: EthChainId): JsonRpcProvider {
30
30
  const network = Network.from(parseInt(chainId))
31
31
  // TODO check if other key needed
32
32
 
33
- const address = Endpoints.INSTANCE.chainServer.get(chainId)
33
+ const address = Endpoints.INSTANCE.getChainRpcUrl(chainId)
34
34
  const key = network.chainId.toString() + '-' + address
35
35
 
36
36
  // console.debug(`init provider for ${chainId}, address: ${address}`)
@@ -45,7 +45,7 @@ export function getProvider(chainId?: EthChainId): JsonRpcProvider {
45
45
  'Provider not found for chain ' +
46
46
  network.chainId +
47
47
  ', configured chains: ' +
48
- [...Endpoints.INSTANCE.chainServer.keys()].join(' ')
48
+ [...Endpoints.INSTANCE.chainRpc.keys()].join(' ')
49
49
  )
50
50
  }
51
51
  // console.log(