@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.
- package/lib/{chunk-Q4CE6IMV.js → chunk-7JGO6QCN.js} +12 -5
- package/lib/{chunk-Q4CE6IMV.js.map → chunk-7JGO6QCN.js.map} +1 -1
- package/lib/index.d.ts +18 -3
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/processor-runner.js +1 -1
- package/package.json +1 -1
- package/src/chain-config.ts +6 -1
- package/src/endpoints.ts +22 -4
- package/src/provider.ts +2 -2
package/lib/processor-runner.js
CHANGED
package/package.json
CHANGED
package/src/chain-config.ts
CHANGED
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
|
-
|
|
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.
|
|
34
|
-
Endpoints.INSTANCE.
|
|
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.
|
|
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.
|
|
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.
|
|
48
|
+
[...Endpoints.INSTANCE.chainRpc.keys()].join(' ')
|
|
49
49
|
)
|
|
50
50
|
}
|
|
51
51
|
// console.log(
|