@rhinestone/shared-configs 1.0.0-alpha.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.
@@ -0,0 +1,69 @@
1
+ {
2
+ "Alchemy": {
3
+ "chain_mapping": {
4
+ "1": "eth-mainnet",
5
+ "10": "opt-mainnet",
6
+ "100": "gnosis-mainnet",
7
+ "137": "polygon-mainnet",
8
+ "146": "sonic-mainnet",
9
+ "1868": "soneium-mainnet",
10
+ "8453": "base-mainnet",
11
+ "9745": "plasma-mainnet",
12
+ "9746": "plasma-testnet",
13
+ "42161": "arb-mainnet",
14
+ "84532": "base-sepolia",
15
+ "421614": "arb-sepolia",
16
+ "11155111": "eth-sepolia",
17
+ "11155420": "opt-sepolia"
18
+ },
19
+ "url_template": "https://{{chain_param}}.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
20
+ },
21
+ "DRPC": {
22
+ "chain_mapping": {
23
+ "1": "ethereum",
24
+ "10": "optimism",
25
+ "100": "gnosis",
26
+ "137": "polygon",
27
+ "146": "sonic",
28
+ "1868": "soneium",
29
+ "8453": "base",
30
+ "9745": "plasma",
31
+ "9746": "plasma-testnet",
32
+ "42161": "arbitrum",
33
+ "84532": "base-sepolia",
34
+ "421614": "arbitrum-sepolia",
35
+ "11155111": "sepolia",
36
+ "11155420": "optimism-sepolia"
37
+ },
38
+ "url_template": "https://lb.drpc.org/ogrpc?network={{chain_param}}&dkey=${DRPC_API_KEY}"
39
+ },
40
+ "eRPC": {
41
+ "chain_mapping": {
42
+ "1": "1",
43
+ "10": "10",
44
+ "100": "100",
45
+ "137": "137",
46
+ "146": "146",
47
+ "1868": "1868",
48
+ "8453": "8453",
49
+ "9745": "9745",
50
+ "9746": "9746",
51
+ "42161": "42161",
52
+ "84532": "84532",
53
+ "421614": "421614",
54
+ "11155111": "11155111",
55
+ "11155420": "11155420"
56
+ },
57
+ "url_template": "https://v1.orchestrator.rhinestone.dev/rpc-proxy/main/evm/{{chain_param}}"
58
+ },
59
+ "local-rpc": {
60
+ "chain_mapping": {
61
+ "1": "30001",
62
+ "137": "30004",
63
+ "146": "30005",
64
+ "8453": "30003",
65
+ "42161": "30002"
66
+ },
67
+ "url_template": "http://localhost:{{chain_param}}"
68
+ }
69
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "9746": {
3
+ "providers": [
4
+ "Alchemy"
5
+ ]
6
+ },
7
+ "84532": {
8
+ "providers": [
9
+ "DRPC"
10
+ ]
11
+ },
12
+ "421614": {
13
+ "providers": [
14
+ "DRPC"
15
+ ]
16
+ },
17
+ "11155111": {
18
+ "providers": [
19
+ "DRPC"
20
+ ]
21
+ },
22
+ "11155420": {
23
+ "providers": [
24
+ "DRPC"
25
+ ]
26
+ }
27
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../scripts/generate.ts"],"names":[],"mappings":""}
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const node_child_process_1 = require("node:child_process");
7
+ const node_fs_1 = require("node:fs");
8
+ const promises_1 = require("node:fs/promises");
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ function renderEnum(name, values) {
11
+ const lines = Object.entries(values).map(([key, value]) => ` ${key} = "${value}",`);
12
+ return `export enum ${name} {\n${lines.join('\n')}\n}\n`;
13
+ }
14
+ function renderNetworkEnum(name, entries) {
15
+ const lines = entries.map((entry) => ` ${entry.enumKey} = ${entry.viemChain}.id,`);
16
+ return `enum ${name} {\n${lines.join('\n')}\n}\n`;
17
+ }
18
+ function renderNetworks(networks) {
19
+ const imports = [];
20
+ const seen = new Set();
21
+ const addImport = (name) => {
22
+ if (!seen.has(name)) {
23
+ seen.add(name);
24
+ imports.push(name);
25
+ }
26
+ };
27
+ for (const entry of [...networks.mainnets, ...networks.testnets]) {
28
+ addImport(entry.viemChain);
29
+ }
30
+ const mainnetChains = networks.mainnets.map((entry) => entry.viemChain);
31
+ const testnetChains = networks.testnets.map((entry) => entry.viemChain);
32
+ const opStackLines = [];
33
+ for (const entry of networks.mainnets) {
34
+ if (entry.opStackKey) {
35
+ opStackLines.push(` MAINNET_${entry.opStackKey} = ${entry.viemChain}.id,`);
36
+ }
37
+ }
38
+ for (const entry of networks.testnets) {
39
+ if (entry.opStackKey) {
40
+ opStackLines.push(` TESTNET_${entry.opStackKey} = ${entry.viemChain}.id,`);
41
+ }
42
+ }
43
+ return [
44
+ '// Auto-generated by scripts/generate.ts. Do not edit manually.',
45
+ 'import {',
46
+ ...imports.map((name) => ` ${name},`),
47
+ '} from "viem/chains";',
48
+ '',
49
+ `const mainnetChains = [${mainnetChains.join(', ')}];`,
50
+ `const testnetChains = [${testnetChains.join(', ')}];`,
51
+ 'const chains = [...mainnetChains, ...testnetChains];',
52
+ '',
53
+ renderNetworkEnum('MainnetNetwork', networks.mainnets).trimEnd(),
54
+ '',
55
+ renderNetworkEnum('TestnetNetwork', networks.testnets).trimEnd(),
56
+ '',
57
+ `enum OPStackChains {\n${opStackLines.join('\n')}\n}\n`.trimEnd(),
58
+ '',
59
+ 'export {',
60
+ ' mainnetChains,',
61
+ ' testnetChains,',
62
+ ' chains,',
63
+ ' MainnetNetwork,',
64
+ ' TestnetNetwork,',
65
+ ' OPStackChains,',
66
+ '};',
67
+ ].join('\n');
68
+ }
69
+ function renderChains(chainRegistry, mainnets, testnets) {
70
+ const providersByChain = {
71
+ ...mainnets,
72
+ ...testnets,
73
+ };
74
+ const chains = {};
75
+ for (const [chainId, chainCfg] of Object.entries(chainRegistry)) {
76
+ const providers = providersByChain[chainId]?.providers ?? [];
77
+ chains[chainId] = {
78
+ ...chainCfg,
79
+ providers,
80
+ };
81
+ }
82
+ return [
83
+ '// Auto-generated by scripts/generate.ts. Do not edit manually.',
84
+ 'import type { Address } from "viem";',
85
+ 'import type { ProviderName, SettlementLayer, SupportedChain, SwapQuoter } from "./types";',
86
+ '',
87
+ 'interface Token {',
88
+ ' address: Address;',
89
+ ' symbol?: string;',
90
+ ' decimals?: number;',
91
+ ' balanceSlot: number | null;',
92
+ ' approvalSlot: number | null;',
93
+ ' supportsMultichain: boolean;',
94
+ '}',
95
+ '',
96
+ 'interface Chain {',
97
+ ' name: string;',
98
+ ' settlementLayers: SettlementLayer[];',
99
+ ' providers: ProviderName[];',
100
+ ' swapQuoters: SwapQuoter[];',
101
+ ' tokens: Token[];',
102
+ '}',
103
+ '',
104
+ `const chains: Record<SupportedChain, Chain> = ${JSON.stringify(chains, null, 2)};`,
105
+ '',
106
+ 'export { chains };',
107
+ 'export type { Chain, Token };',
108
+ ].join('\n');
109
+ }
110
+ function runJsonnet(yeetRoot) {
111
+ const jsonnetFile = node_path_1.default.join('config', 'shared-configs.jsonnet');
112
+ const jsonnetEth = node_path_1.default.join(yeetRoot, 'bin', 'jsonnet-eth');
113
+ let output = '';
114
+ if ((0, node_fs_1.existsSync)(jsonnetEth)) {
115
+ output = (0, node_child_process_1.execFileSync)(jsonnetEth, [jsonnetFile], {
116
+ cwd: yeetRoot,
117
+ encoding: 'utf8',
118
+ });
119
+ }
120
+ else {
121
+ output = (0, node_child_process_1.execFileSync)('go', ['run', './cmd/jsonnet-eth', jsonnetFile], {
122
+ cwd: yeetRoot,
123
+ encoding: 'utf8',
124
+ });
125
+ }
126
+ return JSON.parse(output);
127
+ }
128
+ async function generate() {
129
+ const sharedConfigsRoot = node_path_1.default.resolve(process.cwd());
130
+ const yeetRoot = node_path_1.default.resolve(sharedConfigsRoot, '..');
131
+ const configsDir = node_path_1.default.join(sharedConfigsRoot, 'configs');
132
+ const generatedDir = node_path_1.default.join(sharedConfigsRoot, 'src', 'generated');
133
+ const output = runJsonnet(yeetRoot);
134
+ await (0, promises_1.mkdir)(configsDir, { recursive: true });
135
+ await (0, promises_1.mkdir)(generatedDir, { recursive: true });
136
+ await (0, promises_1.writeFile)(node_path_1.default.join(configsDir, 'chains.json'), `${JSON.stringify(output.chains, null, 2)}\n`);
137
+ await (0, promises_1.writeFile)(node_path_1.default.join(configsDir, 'mainnets.json'), `${JSON.stringify(output.mainnets, null, 2)}\n`);
138
+ await (0, promises_1.writeFile)(node_path_1.default.join(configsDir, 'testnets.json'), `${JSON.stringify(output.testnets, null, 2)}\n`);
139
+ await (0, promises_1.writeFile)(node_path_1.default.join(configsDir, 'providers.json'), `${JSON.stringify(output.providers, null, 2)}\n`);
140
+ await (0, promises_1.writeFile)(node_path_1.default.join(configsDir, 'oft.json'), `${JSON.stringify(output.oft, null, 2)}\n`);
141
+ await (0, promises_1.writeFile)(node_path_1.default.join(sharedConfigsRoot, 'src', 'chains.ts'), `${renderChains(output.chains, output.mainnets, output.testnets)}\n`);
142
+ const tokensTs = [
143
+ '// Auto-generated by scripts/generate.ts. Do not edit manually.',
144
+ renderEnum('EquivalentTokens', output.equivalentTokens),
145
+ renderEnum('WrappedNativeTokens', output.wrappedNativeTokens),
146
+ ].join('\n');
147
+ await (0, promises_1.writeFile)(node_path_1.default.join(generatedDir, 'tokens.ts'), `${tokensTs}\n`);
148
+ await (0, promises_1.writeFile)(node_path_1.default.join(generatedDir, 'networks.ts'), `${renderNetworks(output.networks)}\n`);
149
+ }
150
+ generate().catch((err) => {
151
+ console.error(err);
152
+ process.exit(1);
153
+ });
@@ -0,0 +1,21 @@
1
+ import type { Address } from "viem";
2
+ import type { ProviderName, SettlementLayer, SupportedChain, SwapQuoter } from "./types";
3
+ interface Token {
4
+ address: Address;
5
+ symbol?: string;
6
+ decimals?: number;
7
+ balanceSlot: number | null;
8
+ approvalSlot: number | null;
9
+ supportsMultichain: boolean;
10
+ }
11
+ interface Chain {
12
+ name: string;
13
+ settlementLayers: SettlementLayer[];
14
+ providers: ProviderName[];
15
+ swapQuoters: SwapQuoter[];
16
+ tokens: Token[];
17
+ }
18
+ declare const chains: Record<SupportedChain, Chain>;
19
+ export { chains };
20
+ export type { Chain, Token };
21
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEzF,UAAU,KAAK;IACb,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,KAAK,CAkmBzC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC"}