@rhinestone/shared-configs 1.4.8 → 1.4.9

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.
@@ -1,7 +1,11 @@
1
1
  {
2
- "10": {
3
- "name": "Optimism",
4
- "settlementLayers": ["ACROSS", "ECO", "RELAY"],
2
+ "1": {
3
+ "name": "Ethereum",
4
+ "settlementLayers": [
5
+ "ACROSS",
6
+ "ECO",
7
+ "RELAY"
8
+ ],
5
9
  "tokens": [
6
10
  {
7
11
  "symbol": "ETH",
@@ -12,30 +16,34 @@
12
16
  },
13
17
  {
14
18
  "symbol": "USDC",
15
- "address": "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
19
+ "address": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
16
20
  "decimals": 6,
17
21
  "balanceSlot": 9,
18
22
  "approvalSlot": 10
19
23
  },
20
24
  {
21
25
  "symbol": "USDT",
22
- "address": "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58",
26
+ "address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
23
27
  "decimals": 6,
24
- "balanceSlot": 0,
25
- "approvalSlot": 1
28
+ "balanceSlot": 2,
29
+ "approvalSlot": 5
26
30
  },
27
31
  {
28
32
  "symbol": "WETH",
29
- "address": "0x4200000000000000000000000000000000000006",
33
+ "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
30
34
  "decimals": 18,
31
35
  "balanceSlot": 3,
32
36
  "approvalSlot": 4
33
37
  }
34
38
  ]
35
39
  },
36
- "8453": {
37
- "name": "Base",
38
- "settlementLayers": ["ACROSS", "ECO", "RELAY"],
40
+ "10": {
41
+ "name": "Optimism",
42
+ "settlementLayers": [
43
+ "ACROSS",
44
+ "ECO",
45
+ "RELAY"
46
+ ],
39
47
  "tokens": [
40
48
  {
41
49
  "symbol": "ETH",
@@ -46,16 +54,16 @@
46
54
  },
47
55
  {
48
56
  "symbol": "USDC",
49
- "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
57
+ "address": "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
50
58
  "decimals": 6,
51
59
  "balanceSlot": 9,
52
60
  "approvalSlot": 10
53
61
  },
54
62
  {
55
63
  "symbol": "USDT",
56
- "address": "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
64
+ "address": "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58",
57
65
  "decimals": 6,
58
- "balanceSlot": 51,
66
+ "balanceSlot": 0,
59
67
  "approvalSlot": 1
60
68
  },
61
69
  {
@@ -67,9 +75,60 @@
67
75
  }
68
76
  ]
69
77
  },
70
- "42161": {
71
- "name": "Arbitrum",
72
- "settlementLayers": ["ACROSS", "ECO", "RELAY"],
78
+ "137": {
79
+ "name": "Polygon",
80
+ "settlementLayers": [
81
+ "ACROSS",
82
+ "ECO",
83
+ "RELAY"
84
+ ],
85
+ "tokens": [
86
+ {
87
+ "symbol": "USDC",
88
+ "address": "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
89
+ "decimals": 6,
90
+ "balanceSlot": 9,
91
+ "approvalSlot": 10
92
+ },
93
+ {
94
+ "symbol": "USDT",
95
+ "address": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
96
+ "decimals": 6,
97
+ "balanceSlot": 0,
98
+ "approvalSlot": 1
99
+ },
100
+ {
101
+ "symbol": "WETH",
102
+ "address": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
103
+ "decimals": 18,
104
+ "balanceSlot": 3,
105
+ "approvalSlot": 1
106
+ }
107
+ ]
108
+ },
109
+ "146": {
110
+ "name": "Sonic",
111
+ "settlementLayers": [
112
+ "ECO",
113
+ "RELAY"
114
+ ],
115
+ "tokens": [
116
+ {
117
+ "symbol": "USDC",
118
+ "address": "0x29219dd400f2Bf60E5a23d13Be72B486D4038894",
119
+ "decimals": 6,
120
+ "balanceSlot": 9,
121
+ "approvalSlot": 10
122
+ }
123
+ ]
124
+ },
125
+ "1868": {
126
+ "name": "Soneium",
127
+ "settlementLayers": [
128
+ "ACROSS",
129
+ "ECO",
130
+ "RELAY"
131
+ ],
73
132
  "tokens": [
74
133
  {
75
134
  "symbol": "ETH",
@@ -80,57 +139,65 @@
80
139
  },
81
140
  {
82
141
  "symbol": "USDC",
83
- "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
142
+ "address": "0xbA9986D2381edf1DA03B0B9c1f8b00dc4AacC369",
84
143
  "decimals": 6,
85
144
  "balanceSlot": 9,
86
145
  "approvalSlot": 10
87
146
  },
88
- {
89
- "symbol": "USDT",
90
- "address": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
91
- "decimals": 6,
92
- "balanceSlot": 51,
93
- "approvalSlot": 52
94
- },
95
147
  {
96
148
  "symbol": "WETH",
97
- "address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
149
+ "address": "0x4200000000000000000000000000000000000006",
98
150
  "decimals": 18,
99
- "balanceSlot": 51,
100
- "approvalSlot": 52
151
+ "balanceSlot": 0,
152
+ "approvalSlot": 1
101
153
  }
102
154
  ]
103
155
  },
104
- "137": {
105
- "name": "Polygon",
106
- "settlementLayers": ["ACROSS", "ECO", "RELAY"],
156
+ "8453": {
157
+ "name": "Base",
158
+ "settlementLayers": [
159
+ "ACROSS",
160
+ "ECO",
161
+ "RELAY"
162
+ ],
107
163
  "tokens": [
164
+ {
165
+ "symbol": "ETH",
166
+ "address": "0x0000000000000000000000000000000000000000",
167
+ "decimals": 18,
168
+ "balanceSlot": null,
169
+ "approvalSlot": null
170
+ },
108
171
  {
109
172
  "symbol": "USDC",
110
- "address": "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
173
+ "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
111
174
  "decimals": 6,
112
175
  "balanceSlot": 9,
113
176
  "approvalSlot": 10
114
177
  },
115
178
  {
116
179
  "symbol": "USDT",
117
- "address": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
180
+ "address": "0xfde4C96c8593536E31F229EA8f37b2ADa2699bb2",
118
181
  "decimals": 6,
119
182
  "balanceSlot": 0,
120
183
  "approvalSlot": 1
121
184
  },
122
185
  {
123
186
  "symbol": "WETH",
124
- "address": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
187
+ "address": "0x4200000000000000000000000000000000000006",
125
188
  "decimals": 18,
126
189
  "balanceSlot": 3,
127
- "approvalSlot": 1
190
+ "approvalSlot": 4
128
191
  }
129
192
  ]
130
193
  },
131
- "1868": {
132
- "name": "Soneium",
133
- "settlementLayers": ["ACROSS", "ECO", "RELAY"],
194
+ "42161": {
195
+ "name": "Arbitrum",
196
+ "settlementLayers": [
197
+ "ACROSS",
198
+ "ECO",
199
+ "RELAY"
200
+ ],
134
201
  "tokens": [
135
202
  {
136
203
  "symbol": "ETH",
@@ -141,23 +208,34 @@
141
208
  },
142
209
  {
143
210
  "symbol": "USDC",
144
- "address": "0xbA9986D2381edf1DA03B0B9c1f8b00dc4AacC369",
211
+ "address": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
145
212
  "decimals": 6,
146
213
  "balanceSlot": 9,
147
214
  "approvalSlot": 10
148
215
  },
216
+ {
217
+ "symbol": "USDT",
218
+ "address": "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
219
+ "decimals": 6,
220
+ "balanceSlot": 51,
221
+ "approvalSlot": 52
222
+ },
149
223
  {
150
224
  "symbol": "WETH",
151
- "address": "0x4200000000000000000000000000000000000006",
225
+ "address": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
152
226
  "decimals": 18,
153
- "balanceSlot": 0,
154
- "approvalSlot": 1
227
+ "balanceSlot": 51,
228
+ "approvalSlot": 52
155
229
  }
156
230
  ]
157
231
  },
158
232
  "84532": {
159
233
  "name": "Base-sepolia",
160
- "settlementLayers": ["ACROSS", "ECO", "RELAY"],
234
+ "settlementLayers": [
235
+ "ACROSS",
236
+ "ECO",
237
+ "RELAY"
238
+ ],
161
239
  "tokens": [
162
240
  {
163
241
  "symbol": "ETH",
@@ -184,7 +262,11 @@
184
262
  },
185
263
  "421614": {
186
264
  "name": "Arbitrum-sepolia",
187
- "settlementLayers": ["ACROSS", "ECO", "RELAY"],
265
+ "settlementLayers": [
266
+ "ACROSS",
267
+ "ECO",
268
+ "RELAY"
269
+ ],
188
270
  "tokens": [
189
271
  {
190
272
  "symbol": "ETH",
@@ -211,7 +293,11 @@
211
293
  },
212
294
  "11155111": {
213
295
  "name": "Ethereum-sepolia",
214
- "settlementLayers": ["ACROSS", "ECO", "RELAY"],
296
+ "settlementLayers": [
297
+ "ACROSS",
298
+ "ECO",
299
+ "RELAY"
300
+ ],
215
301
  "tokens": [
216
302
  {
217
303
  "symbol": "ETH",
@@ -238,7 +324,11 @@
238
324
  },
239
325
  "11155420": {
240
326
  "name": "Optimism-sepolia",
241
- "settlementLayers": ["ACROSS", "ECO", "RELAY"],
327
+ "settlementLayers": [
328
+ "ACROSS",
329
+ "ECO",
330
+ "RELAY"
331
+ ],
242
332
  "tokens": [
243
333
  {
244
334
  "symbol": "ETH",
@@ -1,17 +1,44 @@
1
1
  {
2
- "10": {
3
- "providers": ["DRPC", "Alchemy"]
4
- },
5
- "8453": {
6
- "providers": ["DRPC", "Alchemy"]
2
+ "1": {
3
+ "providers": [
4
+ "DRPC",
5
+ "Alchemy"
6
+ ]
7
7
  },
8
- "42161": {
9
- "providers": ["DRPC", "Alchemy"]
8
+ "10": {
9
+ "providers": [
10
+ "DRPC",
11
+ "Alchemy"
12
+ ]
10
13
  },
11
14
  "137": {
12
- "providers": ["DRPC", "Alchemy"]
15
+ "providers": [
16
+ "DRPC",
17
+ "Alchemy"
18
+ ]
19
+ },
20
+ "146": {
21
+ "providers": [
22
+ "DRPC",
23
+ "Alchemy"
24
+ ]
13
25
  },
14
26
  "1868": {
15
- "providers": ["DRPC", "Alchemy"]
27
+ "providers": [
28
+ "DRPC",
29
+ "Alchemy"
30
+ ]
31
+ },
32
+ "8453": {
33
+ "providers": [
34
+ "DRPC",
35
+ "Alchemy"
36
+ ]
37
+ },
38
+ "42161": {
39
+ "providers": [
40
+ "DRPC",
41
+ "Alchemy"
42
+ ]
16
43
  }
17
44
  }
@@ -1,14 +1,22 @@
1
1
  {
2
2
  "84532": {
3
- "providers": ["DRPC"]
3
+ "providers": [
4
+ "DRPC"
5
+ ]
4
6
  },
5
7
  "421614": {
6
- "providers": ["DRPC"]
8
+ "providers": [
9
+ "DRPC"
10
+ ]
7
11
  },
8
12
  "11155111": {
9
- "providers": ["DRPC"]
13
+ "providers": [
14
+ "DRPC"
15
+ ]
10
16
  },
11
17
  "11155420": {
12
- "providers": ["DRPC"]
18
+ "providers": [
19
+ "DRPC"
20
+ ]
13
21
  }
14
22
  }
@@ -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,137 @@
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_fs_1 = require("node:fs");
7
+ const promises_1 = require("node:fs/promises");
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const viem_1 = require("viem");
10
+ const chains_1 = require("../src/chains");
11
+ const types_1 = require("../src/types");
12
+ function isZeroAddress(addr) {
13
+ return addr.toLowerCase() === '0x0000000000000000000000000000000000000000';
14
+ }
15
+ function enumNumberValues(e) {
16
+ return Object.values(e).filter((v) => typeof v === 'number');
17
+ }
18
+ const MAINNET_IDS = new Set(enumNumberValues(types_1.MainnetNetwork).map(String));
19
+ const TESTNET_IDS = new Set(enumNumberValues(types_1.TestnetNetwork).map(String));
20
+ async function readJsonIfExists(filePath) {
21
+ if (!(0, node_fs_1.existsSync)(filePath))
22
+ return null;
23
+ const buf = await (0, promises_1.readFile)(filePath, 'utf8');
24
+ return JSON.parse(buf);
25
+ }
26
+ async function fetchErc20Metadata(client, token) {
27
+ try {
28
+ const [symbol, decimals] = await Promise.all([
29
+ client.readContract({
30
+ address: token,
31
+ abi: viem_1.erc20Abi,
32
+ functionName: 'symbol',
33
+ }),
34
+ client.readContract({
35
+ address: token,
36
+ abi: viem_1.erc20Abi,
37
+ functionName: 'decimals',
38
+ }),
39
+ ]);
40
+ return { symbol, decimals };
41
+ }
42
+ catch {
43
+ return { symbol: null, decimals: null };
44
+ }
45
+ }
46
+ async function generate() {
47
+ const baseDir = node_path_1.default.resolve(process.cwd());
48
+ const configsDir = node_path_1.default.join(baseDir, 'configs');
49
+ const chainsJsonPath = node_path_1.default.join(configsDir, 'chains.json');
50
+ const mainnetsJsonPath = node_path_1.default.join(configsDir, 'mainnets.json');
51
+ const testnetsJsonPath = node_path_1.default.join(configsDir, 'testnets.json');
52
+ const cachedRegistry = (await readJsonIfExists(chainsJsonPath)) || {};
53
+ const outRegistry = {};
54
+ const outMainnets = {};
55
+ const outTestnets = {};
56
+ for (const [chainId, chainCfg] of Object.entries(chains_1.chains)) {
57
+ console.log(`Processing chain ${chainId}`);
58
+ const chain = types_1.chains.find((c) => c.id === parseInt(chainId));
59
+ if (!chain) {
60
+ console.error(`Chain ${chainId} not found in viem chains`);
61
+ continue;
62
+ }
63
+ const client = (0, viem_1.createPublicClient)({
64
+ chain,
65
+ transport: (0, viem_1.http)(),
66
+ });
67
+ const cachedChain = cachedRegistry[chainId];
68
+ const tokens = [];
69
+ for (const t of chainCfg.tokens) {
70
+ const addr = t.address;
71
+ const cachedToken = cachedChain?.tokens?.find((x) => x.address.toLowerCase() === addr.toLowerCase());
72
+ if (isZeroAddress(addr)) {
73
+ const symbol = t.symbol ?? cachedToken?.symbol ?? 'ETH';
74
+ tokens.push({
75
+ symbol,
76
+ address: addr,
77
+ decimals: 18,
78
+ balanceSlot: null,
79
+ approvalSlot: null,
80
+ });
81
+ continue;
82
+ }
83
+ if (cachedToken) {
84
+ tokens.push({
85
+ symbol: t.symbol ?? cachedToken.symbol,
86
+ address: addr,
87
+ decimals: cachedToken.decimals,
88
+ balanceSlot: cachedToken.balanceSlot,
89
+ approvalSlot: cachedToken.approvalSlot,
90
+ });
91
+ continue;
92
+ }
93
+ let symbol = t.symbol ?? 'UNKNOWN';
94
+ let decimals = 18;
95
+ if (client) {
96
+ const meta = await fetchErc20Metadata(client, addr);
97
+ if (meta.symbol)
98
+ symbol = t.symbol ?? meta.symbol;
99
+ if (meta.decimals != null)
100
+ decimals = meta.decimals;
101
+ }
102
+ const balanceSlot = t.balanceSlot;
103
+ const approvalSlot = t.approvalSlot;
104
+ console.log('token', {
105
+ symbol,
106
+ address: addr,
107
+ decimals,
108
+ balanceSlot,
109
+ approvalSlot,
110
+ });
111
+ tokens.push({
112
+ symbol,
113
+ address: addr,
114
+ decimals,
115
+ balanceSlot,
116
+ approvalSlot,
117
+ });
118
+ }
119
+ outRegistry[chainId] = {
120
+ name: chainCfg.name,
121
+ settlementLayers: chainCfg.settlementLayers,
122
+ tokens,
123
+ };
124
+ const chainItem = { providers: chainCfg.providers };
125
+ if (MAINNET_IDS.has(chainId))
126
+ outMainnets[chainId] = chainItem;
127
+ else if (TESTNET_IDS.has(chainId))
128
+ outTestnets[chainId] = chainItem;
129
+ }
130
+ await (0, promises_1.writeFile)(chainsJsonPath, JSON.stringify(outRegistry, null, 2) + '\n');
131
+ await (0, promises_1.writeFile)(mainnetsJsonPath, JSON.stringify(outMainnets, null, 2) + '\n');
132
+ await (0, promises_1.writeFile)(testnetsJsonPath, JSON.stringify(outTestnets, null, 2) + '\n');
133
+ }
134
+ generate().catch((err) => {
135
+ console.error(err);
136
+ process.exit(1);
137
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=update-sdk-dependency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-sdk-dependency.d.ts","sourceRoot":"","sources":["../../scripts/update-sdk-dependency.ts"],"names":[],"mappings":""}
@@ -0,0 +1,60 @@
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_fs_1 = require("node:fs");
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const targetName = process.env.TARGET_NAME;
9
+ const targetVersionInput = process.env.TARGET_VERSION;
10
+ if (!targetName || !targetVersionInput) {
11
+ throw new Error('TARGET_NAME and TARGET_VERSION env vars are required');
12
+ }
13
+ const targetVersion = `^${targetVersionInput}`;
14
+ function readJson(jsonPath) {
15
+ return JSON.parse((0, node_fs_1.readFileSync)(jsonPath, 'utf8'));
16
+ }
17
+ function writeJson(jsonPath, obj) {
18
+ (0, node_fs_1.writeFileSync)(jsonPath, JSON.stringify(obj, null, 2) + '\n');
19
+ }
20
+ function tryUpdatePackageJson(pkg) {
21
+ let changed = false;
22
+ for (const key of ['dependencies', 'devDependencies', 'peerDependencies']) {
23
+ const deps = pkg[key];
24
+ if (deps && targetName in deps) {
25
+ if (deps[targetName] !== targetVersion) {
26
+ deps[targetName] = targetVersion;
27
+ changed = true;
28
+ }
29
+ }
30
+ }
31
+ return changed;
32
+ }
33
+ function walkAndUpdate(startDir) {
34
+ const stack = [startDir];
35
+ while (stack.length) {
36
+ const dir = stack.pop();
37
+ const entries = (0, node_fs_1.readdirSync)(dir, { withFileTypes: true });
38
+ for (const entry of entries) {
39
+ if (entry.name === 'node_modules' || entry.name === '.git')
40
+ continue;
41
+ const fullPath = node_path_1.default.join(dir, entry.name);
42
+ if (entry.isDirectory()) {
43
+ stack.push(fullPath);
44
+ }
45
+ else if (entry.isFile() && entry.name === 'package.json') {
46
+ try {
47
+ const pkg = readJson(fullPath);
48
+ if (tryUpdatePackageJson(pkg)) {
49
+ writeJson(fullPath, pkg);
50
+ console.log('updated', fullPath);
51
+ }
52
+ }
53
+ catch {
54
+ // ignore invalid json files
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ walkAndUpdate(process.cwd());
@@ -0,0 +1,18 @@
1
+ import type { Address } from 'viem';
2
+ import type { ProviderName, SettlementLayer, SupportedChain } from './types';
3
+ interface Token {
4
+ address: Address;
5
+ symbol?: string;
6
+ balanceSlot: number | null;
7
+ approvalSlot: number | null;
8
+ }
9
+ interface Chain {
10
+ name: string;
11
+ settlementLayers: SettlementLayer[];
12
+ providers: ProviderName[];
13
+ tokens: Token[];
14
+ }
15
+ declare const chains: Record<SupportedChain, Chain>;
16
+ export { chains };
17
+ export type { Chain, Token };
18
+ //# sourceMappingURL=chains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chains.d.ts","sourceRoot":"","sources":["../../src/chains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE5E,UAAU,KAAK;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,EAAE,eAAe,EAAE,CAAA;IACnC,SAAS,EAAE,YAAY,EAAE,CAAA;IACzB,MAAM,EAAE,KAAK,EAAE,CAAA;CAChB;AAED,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,KAAK,CA0QzC,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA"}