@hyperlane-xyz/registry 1.0.2 → 1.0.3
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/dist/core/chains.d.ts +42 -0
- package/dist/core/chains.js +73 -0
- package/dist/index.d.ts +4 -42
- package/dist/index.js +3 -73
- package/dist/registry/BaseRegistry.d.ts +20 -0
- package/dist/registry/BaseRegistry.js +19 -0
- package/dist/registry/GithubRegistry.d.ts +25 -0
- package/dist/registry/GithubRegistry.js +98 -0
- package/dist/registry/IRegistry.d.ts +19 -0
- package/dist/registry/IRegistry.js +1 -0
- package/package.json +4 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A list of chains managed by the Hyperlane core team.
|
|
3
|
+
* Hyperlane can be deployed permissionlessly to any chain but for
|
|
4
|
+
* convenience the core team maintains some deployments.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum CoreChain {
|
|
7
|
+
alfajores = "alfajores",
|
|
8
|
+
ancient8 = "ancient8",
|
|
9
|
+
arbitrum = "arbitrum",
|
|
10
|
+
avalanche = "avalanche",
|
|
11
|
+
base = "base",
|
|
12
|
+
bsc = "bsc",
|
|
13
|
+
bsctestnet = "bsctestnet",
|
|
14
|
+
celo = "celo",
|
|
15
|
+
chiado = "chiado",
|
|
16
|
+
ethereum = "ethereum",
|
|
17
|
+
fuji = "fuji",
|
|
18
|
+
gnosis = "gnosis",
|
|
19
|
+
inevm = "inevm",
|
|
20
|
+
injective = "injective",
|
|
21
|
+
mantapacific = "mantapacific",
|
|
22
|
+
moonbeam = "moonbeam",
|
|
23
|
+
nautilus = "nautilus",
|
|
24
|
+
neutron = "neutron",
|
|
25
|
+
optimism = "optimism",
|
|
26
|
+
plumetestnet = "plumetestnet",
|
|
27
|
+
polygon = "polygon",
|
|
28
|
+
polygonzkevm = "polygonzkevm",
|
|
29
|
+
proteustestnet = "proteustestnet",
|
|
30
|
+
scroll = "scroll",
|
|
31
|
+
scrollsepolia = "scrollsepolia",
|
|
32
|
+
sepolia = "sepolia",
|
|
33
|
+
solana = "solana",
|
|
34
|
+
solanadevnet = "solanadevnet",
|
|
35
|
+
solanatestnet = "solanatestnet",
|
|
36
|
+
eclipsetestnet = "eclipsetestnet",
|
|
37
|
+
viction = "viction"
|
|
38
|
+
}
|
|
39
|
+
export type CoreChainName = keyof typeof CoreChain;
|
|
40
|
+
export declare const CoreMainnets: Array<CoreChainName>;
|
|
41
|
+
export declare const CoreTestnets: Array<CoreChainName>;
|
|
42
|
+
export declare const CoreChains: Array<CoreChainName>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A list of chains managed by the Hyperlane core team.
|
|
3
|
+
* Hyperlane can be deployed permissionlessly to any chain but for
|
|
4
|
+
* convenience the core team maintains some deployments.
|
|
5
|
+
*/
|
|
6
|
+
export var CoreChain;
|
|
7
|
+
(function (CoreChain) {
|
|
8
|
+
CoreChain["alfajores"] = "alfajores";
|
|
9
|
+
CoreChain["ancient8"] = "ancient8";
|
|
10
|
+
CoreChain["arbitrum"] = "arbitrum";
|
|
11
|
+
CoreChain["avalanche"] = "avalanche";
|
|
12
|
+
CoreChain["base"] = "base";
|
|
13
|
+
CoreChain["bsc"] = "bsc";
|
|
14
|
+
CoreChain["bsctestnet"] = "bsctestnet";
|
|
15
|
+
CoreChain["celo"] = "celo";
|
|
16
|
+
CoreChain["chiado"] = "chiado";
|
|
17
|
+
CoreChain["ethereum"] = "ethereum";
|
|
18
|
+
CoreChain["fuji"] = "fuji";
|
|
19
|
+
CoreChain["gnosis"] = "gnosis";
|
|
20
|
+
CoreChain["inevm"] = "inevm";
|
|
21
|
+
CoreChain["injective"] = "injective";
|
|
22
|
+
CoreChain["mantapacific"] = "mantapacific";
|
|
23
|
+
CoreChain["moonbeam"] = "moonbeam";
|
|
24
|
+
CoreChain["nautilus"] = "nautilus";
|
|
25
|
+
CoreChain["neutron"] = "neutron";
|
|
26
|
+
CoreChain["optimism"] = "optimism";
|
|
27
|
+
CoreChain["plumetestnet"] = "plumetestnet";
|
|
28
|
+
CoreChain["polygon"] = "polygon";
|
|
29
|
+
CoreChain["polygonzkevm"] = "polygonzkevm";
|
|
30
|
+
CoreChain["proteustestnet"] = "proteustestnet";
|
|
31
|
+
CoreChain["scroll"] = "scroll";
|
|
32
|
+
CoreChain["scrollsepolia"] = "scrollsepolia";
|
|
33
|
+
CoreChain["sepolia"] = "sepolia";
|
|
34
|
+
CoreChain["solana"] = "solana";
|
|
35
|
+
CoreChain["solanadevnet"] = "solanadevnet";
|
|
36
|
+
CoreChain["solanatestnet"] = "solanatestnet";
|
|
37
|
+
CoreChain["eclipsetestnet"] = "eclipsetestnet";
|
|
38
|
+
CoreChain["viction"] = "viction";
|
|
39
|
+
})(CoreChain || (CoreChain = {}));
|
|
40
|
+
export const CoreMainnets = [
|
|
41
|
+
CoreChain.arbitrum,
|
|
42
|
+
CoreChain.ancient8,
|
|
43
|
+
CoreChain.avalanche,
|
|
44
|
+
CoreChain.bsc,
|
|
45
|
+
CoreChain.celo,
|
|
46
|
+
CoreChain.ethereum,
|
|
47
|
+
CoreChain.neutron,
|
|
48
|
+
CoreChain.mantapacific,
|
|
49
|
+
CoreChain.moonbeam,
|
|
50
|
+
CoreChain.optimism,
|
|
51
|
+
CoreChain.polygon,
|
|
52
|
+
CoreChain.gnosis,
|
|
53
|
+
CoreChain.base,
|
|
54
|
+
CoreChain.scroll,
|
|
55
|
+
CoreChain.polygonzkevm,
|
|
56
|
+
CoreChain.injective,
|
|
57
|
+
CoreChain.inevm,
|
|
58
|
+
CoreChain.viction,
|
|
59
|
+
// CoreChains.solana,
|
|
60
|
+
];
|
|
61
|
+
export const CoreTestnets = [
|
|
62
|
+
CoreChain.alfajores,
|
|
63
|
+
CoreChain.bsctestnet,
|
|
64
|
+
CoreChain.chiado,
|
|
65
|
+
CoreChain.fuji,
|
|
66
|
+
CoreChain.plumetestnet,
|
|
67
|
+
CoreChain.scrollsepolia,
|
|
68
|
+
CoreChain.sepolia,
|
|
69
|
+
CoreChain.solanadevnet,
|
|
70
|
+
CoreChain.solanatestnet,
|
|
71
|
+
CoreChain.eclipsetestnet,
|
|
72
|
+
];
|
|
73
|
+
export const CoreChains = [...CoreMainnets, ...CoreTestnets];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,45 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
export declare enum CoreChain {
|
|
7
|
-
alfajores = "alfajores",
|
|
8
|
-
ancient8 = "ancient8",
|
|
9
|
-
arbitrum = "arbitrum",
|
|
10
|
-
avalanche = "avalanche",
|
|
11
|
-
base = "base",
|
|
12
|
-
bsc = "bsc",
|
|
13
|
-
bsctestnet = "bsctestnet",
|
|
14
|
-
celo = "celo",
|
|
15
|
-
chiado = "chiado",
|
|
16
|
-
ethereum = "ethereum",
|
|
17
|
-
fuji = "fuji",
|
|
18
|
-
gnosis = "gnosis",
|
|
19
|
-
inevm = "inevm",
|
|
20
|
-
injective = "injective",
|
|
21
|
-
mantapacific = "mantapacific",
|
|
22
|
-
moonbeam = "moonbeam",
|
|
23
|
-
nautilus = "nautilus",
|
|
24
|
-
neutron = "neutron",
|
|
25
|
-
optimism = "optimism",
|
|
26
|
-
plumetestnet = "plumetestnet",
|
|
27
|
-
polygon = "polygon",
|
|
28
|
-
polygonzkevm = "polygonzkevm",
|
|
29
|
-
proteustestnet = "proteustestnet",
|
|
30
|
-
scroll = "scroll",
|
|
31
|
-
scrollsepolia = "scrollsepolia",
|
|
32
|
-
sepolia = "sepolia",
|
|
33
|
-
solana = "solana",
|
|
34
|
-
solanadevnet = "solanadevnet",
|
|
35
|
-
solanatestnet = "solanatestnet",
|
|
36
|
-
eclipsetestnet = "eclipsetestnet",
|
|
37
|
-
viction = "viction"
|
|
38
|
-
}
|
|
39
|
-
export type CoreChainName = keyof typeof CoreChain;
|
|
40
|
-
export declare const CoreMainnets: Array<CoreChainName>;
|
|
41
|
-
export declare const CoreTestnets: Array<CoreChainName>;
|
|
42
|
-
export declare const CoreChains: Array<CoreChainName>;
|
|
1
|
+
export { CoreChain, CoreChainName, CoreChains, CoreMainnets, CoreTestnets } from './core/chains.js';
|
|
2
|
+
export { BaseRegistry } from './registry/BaseRegistry.js';
|
|
3
|
+
export { GithubRegistry, GithubRegistryOptions } from './registry/GithubRegistry.js';
|
|
4
|
+
export { ChainAddresses, ChainFiles, IRegistry, RegistryContent } from './registry/IRegistry.js';
|
|
43
5
|
export { chainMetadata } from './chainMetadata.js';
|
|
44
6
|
export { coreChainMetadata } from './coreChainMetadata.js';
|
|
45
7
|
export { chainAddresses } from './chainAddresses.js';
|
package/dist/index.js
CHANGED
|
@@ -1,76 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* convenience the core team maintains some deployments.
|
|
5
|
-
*/
|
|
6
|
-
export var CoreChain;
|
|
7
|
-
(function (CoreChain) {
|
|
8
|
-
CoreChain["alfajores"] = "alfajores";
|
|
9
|
-
CoreChain["ancient8"] = "ancient8";
|
|
10
|
-
CoreChain["arbitrum"] = "arbitrum";
|
|
11
|
-
CoreChain["avalanche"] = "avalanche";
|
|
12
|
-
CoreChain["base"] = "base";
|
|
13
|
-
CoreChain["bsc"] = "bsc";
|
|
14
|
-
CoreChain["bsctestnet"] = "bsctestnet";
|
|
15
|
-
CoreChain["celo"] = "celo";
|
|
16
|
-
CoreChain["chiado"] = "chiado";
|
|
17
|
-
CoreChain["ethereum"] = "ethereum";
|
|
18
|
-
CoreChain["fuji"] = "fuji";
|
|
19
|
-
CoreChain["gnosis"] = "gnosis";
|
|
20
|
-
CoreChain["inevm"] = "inevm";
|
|
21
|
-
CoreChain["injective"] = "injective";
|
|
22
|
-
CoreChain["mantapacific"] = "mantapacific";
|
|
23
|
-
CoreChain["moonbeam"] = "moonbeam";
|
|
24
|
-
CoreChain["nautilus"] = "nautilus";
|
|
25
|
-
CoreChain["neutron"] = "neutron";
|
|
26
|
-
CoreChain["optimism"] = "optimism";
|
|
27
|
-
CoreChain["plumetestnet"] = "plumetestnet";
|
|
28
|
-
CoreChain["polygon"] = "polygon";
|
|
29
|
-
CoreChain["polygonzkevm"] = "polygonzkevm";
|
|
30
|
-
CoreChain["proteustestnet"] = "proteustestnet";
|
|
31
|
-
CoreChain["scroll"] = "scroll";
|
|
32
|
-
CoreChain["scrollsepolia"] = "scrollsepolia";
|
|
33
|
-
CoreChain["sepolia"] = "sepolia";
|
|
34
|
-
CoreChain["solana"] = "solana";
|
|
35
|
-
CoreChain["solanadevnet"] = "solanadevnet";
|
|
36
|
-
CoreChain["solanatestnet"] = "solanatestnet";
|
|
37
|
-
CoreChain["eclipsetestnet"] = "eclipsetestnet";
|
|
38
|
-
CoreChain["viction"] = "viction";
|
|
39
|
-
})(CoreChain || (CoreChain = {}));
|
|
40
|
-
export const CoreMainnets = [
|
|
41
|
-
CoreChain.arbitrum,
|
|
42
|
-
CoreChain.ancient8,
|
|
43
|
-
CoreChain.avalanche,
|
|
44
|
-
CoreChain.bsc,
|
|
45
|
-
CoreChain.celo,
|
|
46
|
-
CoreChain.ethereum,
|
|
47
|
-
CoreChain.neutron,
|
|
48
|
-
CoreChain.mantapacific,
|
|
49
|
-
CoreChain.moonbeam,
|
|
50
|
-
CoreChain.optimism,
|
|
51
|
-
CoreChain.polygon,
|
|
52
|
-
CoreChain.gnosis,
|
|
53
|
-
CoreChain.base,
|
|
54
|
-
CoreChain.scroll,
|
|
55
|
-
CoreChain.polygonzkevm,
|
|
56
|
-
CoreChain.injective,
|
|
57
|
-
CoreChain.inevm,
|
|
58
|
-
CoreChain.viction,
|
|
59
|
-
// CoreChains.solana,
|
|
60
|
-
];
|
|
61
|
-
export const CoreTestnets = [
|
|
62
|
-
CoreChain.alfajores,
|
|
63
|
-
CoreChain.bsctestnet,
|
|
64
|
-
CoreChain.chiado,
|
|
65
|
-
CoreChain.fuji,
|
|
66
|
-
CoreChain.plumetestnet,
|
|
67
|
-
CoreChain.scrollsepolia,
|
|
68
|
-
CoreChain.sepolia,
|
|
69
|
-
CoreChain.solanadevnet,
|
|
70
|
-
CoreChain.solanatestnet,
|
|
71
|
-
CoreChain.eclipsetestnet,
|
|
72
|
-
];
|
|
73
|
-
export const CoreChains = [...CoreMainnets, ...CoreTestnets];
|
|
1
|
+
export { CoreChain, CoreChains, CoreMainnets, CoreTestnets } from './core/chains.js';
|
|
2
|
+
export { BaseRegistry } from './registry/BaseRegistry.js';
|
|
3
|
+
export { GithubRegistry } from './registry/GithubRegistry.js';
|
|
74
4
|
export { chainMetadata } from './chainMetadata.js';
|
|
75
5
|
export { coreChainMetadata } from './coreChainMetadata.js';
|
|
76
6
|
export { chainAddresses } from './chainAddresses.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Logger } from 'pino';
|
|
2
|
+
import type { ChainMap, ChainMetadata, ChainName } from '@hyperlane-xyz/sdk';
|
|
3
|
+
import type { ChainAddresses, IRegistry, RegistryContent } from './IRegistry.js';
|
|
4
|
+
export declare abstract class BaseRegistry implements IRegistry {
|
|
5
|
+
protected readonly logger: Logger;
|
|
6
|
+
protected listContentCache?: RegistryContent;
|
|
7
|
+
protected metadataCache?: ChainMap<ChainMetadata>;
|
|
8
|
+
protected addressCache?: ChainMap<ChainAddresses>;
|
|
9
|
+
constructor({ logger }: {
|
|
10
|
+
logger?: Logger;
|
|
11
|
+
});
|
|
12
|
+
protected getChainsPath(): string;
|
|
13
|
+
protected getWarpArtifactsPath(): string;
|
|
14
|
+
abstract listRegistryContent(): Promise<RegistryContent>;
|
|
15
|
+
abstract getChains(): Promise<Array<ChainName>>;
|
|
16
|
+
abstract getMetadata(): Promise<ChainMap<ChainMetadata>>;
|
|
17
|
+
abstract getChainMetadata(chainName: ChainName): Promise<ChainMetadata | null>;
|
|
18
|
+
abstract getAddresses(): Promise<ChainMap<ChainAddresses>>;
|
|
19
|
+
abstract getChainAddresses(chainName: ChainName): Promise<ChainAddresses | null>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export class BaseRegistry {
|
|
2
|
+
logger;
|
|
3
|
+
// Caches
|
|
4
|
+
listContentCache;
|
|
5
|
+
metadataCache;
|
|
6
|
+
addressCache;
|
|
7
|
+
constructor({ logger }) {
|
|
8
|
+
// @ts-ignore forcing in to avoid a @hyperlane-xyz/utils
|
|
9
|
+
// dependency here, which could bloat consumer bundles
|
|
10
|
+
// unnecessarily (e.g. they just want metadata)
|
|
11
|
+
this.logger = logger || console;
|
|
12
|
+
}
|
|
13
|
+
getChainsPath() {
|
|
14
|
+
return 'chains';
|
|
15
|
+
}
|
|
16
|
+
getWarpArtifactsPath() {
|
|
17
|
+
return 'deployments/warp_routes';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Logger } from 'pino';
|
|
2
|
+
import type { ChainMap, ChainMetadata, ChainName } from '@hyperlane-xyz/sdk';
|
|
3
|
+
import { BaseRegistry } from './BaseRegistry.js';
|
|
4
|
+
import type { ChainAddresses, IRegistry, RegistryContent } from './IRegistry.js';
|
|
5
|
+
export interface GithubRegistryOptions {
|
|
6
|
+
url?: string;
|
|
7
|
+
branch?: string;
|
|
8
|
+
authToken?: string;
|
|
9
|
+
logger?: Logger;
|
|
10
|
+
}
|
|
11
|
+
export declare class GithubRegistry extends BaseRegistry implements IRegistry {
|
|
12
|
+
readonly url: URL;
|
|
13
|
+
readonly branch: string;
|
|
14
|
+
readonly repoOwner: string;
|
|
15
|
+
readonly repoName: string;
|
|
16
|
+
constructor(options?: GithubRegistryOptions);
|
|
17
|
+
listRegistryContent(): Promise<RegistryContent>;
|
|
18
|
+
getChains(): Promise<Array<ChainName>>;
|
|
19
|
+
getMetadata(): Promise<ChainMap<ChainMetadata>>;
|
|
20
|
+
getChainMetadata(chainName: ChainName): Promise<ChainMetadata>;
|
|
21
|
+
getAddresses(): Promise<ChainMap<ChainAddresses>>;
|
|
22
|
+
getChainAddresses(chainName: ChainName): Promise<ChainAddresses>;
|
|
23
|
+
protected getRawContentUrl(path: string): string;
|
|
24
|
+
protected fetch(url: string): Promise<Response>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { parse } from 'yaml';
|
|
2
|
+
import { BaseRegistry } from './BaseRegistry.js';
|
|
3
|
+
const DEFAULT_REGISTRY = 'https://github.com/hyperlane-xyz/hyperlane-registry';
|
|
4
|
+
const CHAIN_FILE_REGEX = /chains\/([a-z]+)\/([a-z]+)\.yaml/;
|
|
5
|
+
export class GithubRegistry extends BaseRegistry {
|
|
6
|
+
url;
|
|
7
|
+
branch;
|
|
8
|
+
repoOwner;
|
|
9
|
+
repoName;
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
super({ logger: options.logger });
|
|
12
|
+
this.url = new URL(options.url ?? DEFAULT_REGISTRY);
|
|
13
|
+
this.branch = options.branch ?? 'main';
|
|
14
|
+
const pathSegments = this.url.pathname.split('/');
|
|
15
|
+
if (pathSegments.length < 2)
|
|
16
|
+
throw new Error('Invalid github url');
|
|
17
|
+
this.repoOwner = pathSegments.at(-2);
|
|
18
|
+
this.repoName = pathSegments.at(-1);
|
|
19
|
+
}
|
|
20
|
+
async listRegistryContent() {
|
|
21
|
+
if (this.listContentCache)
|
|
22
|
+
return this.listContentCache;
|
|
23
|
+
// This uses the tree API instead of the simpler directory list API because it
|
|
24
|
+
// allows us to get a full view of all files in one request.
|
|
25
|
+
const apiUrl = `https://api.github.com/repos/${this.repoOwner}/${this.repoName}/git/trees/${this.branch}?recursive=true`;
|
|
26
|
+
const response = await this.fetch(apiUrl);
|
|
27
|
+
const result = await response.json();
|
|
28
|
+
const tree = result.tree;
|
|
29
|
+
const chainPath = this.getChainsPath();
|
|
30
|
+
const chains = {};
|
|
31
|
+
for (const node of tree) {
|
|
32
|
+
if (CHAIN_FILE_REGEX.test(node.path)) {
|
|
33
|
+
const [_, chainName, fileName] = node.path.match(CHAIN_FILE_REGEX);
|
|
34
|
+
chains[chainName] ??= {};
|
|
35
|
+
// @ts-ignore allow dynamic key assignment
|
|
36
|
+
chains[chainName][fileName] = this.getRawContentUrl(`${chainPath}/${chainName}/${fileName}.yaml`);
|
|
37
|
+
}
|
|
38
|
+
// TODO add handling for deployment artifact files here too
|
|
39
|
+
}
|
|
40
|
+
return (this.listContentCache = { chains, deployments: {} });
|
|
41
|
+
}
|
|
42
|
+
async getChains() {
|
|
43
|
+
const repoContents = await this.listRegistryContent();
|
|
44
|
+
return Object.keys(repoContents.chains);
|
|
45
|
+
}
|
|
46
|
+
async getMetadata() {
|
|
47
|
+
if (this.metadataCache)
|
|
48
|
+
return this.metadataCache;
|
|
49
|
+
const chainMetadata = {};
|
|
50
|
+
const repoContents = await this.listRegistryContent();
|
|
51
|
+
for (const [chainName, chainFiles] of Object.entries(repoContents.chains)) {
|
|
52
|
+
if (!chainFiles.metadata)
|
|
53
|
+
continue;
|
|
54
|
+
const response = await this.fetch(chainFiles.metadata);
|
|
55
|
+
const metadata = parse(await response.text());
|
|
56
|
+
chainMetadata[chainName] = metadata;
|
|
57
|
+
}
|
|
58
|
+
return (this.metadataCache = chainMetadata);
|
|
59
|
+
}
|
|
60
|
+
async getChainMetadata(chainName) {
|
|
61
|
+
if (this.metadataCache?.[chainName])
|
|
62
|
+
return this.metadataCache[chainName];
|
|
63
|
+
const url = this.getRawContentUrl(`${this.getChainsPath()}/${chainName}/metadata.yaml`);
|
|
64
|
+
const response = await this.fetch(url);
|
|
65
|
+
return parse(await response.text());
|
|
66
|
+
}
|
|
67
|
+
async getAddresses() {
|
|
68
|
+
if (this.addressCache)
|
|
69
|
+
return this.addressCache;
|
|
70
|
+
const chainAddresses = {};
|
|
71
|
+
const repoContents = await this.listRegistryContent();
|
|
72
|
+
for (const [chainName, chainFiles] of Object.entries(repoContents.chains)) {
|
|
73
|
+
if (!chainFiles.addresses)
|
|
74
|
+
continue;
|
|
75
|
+
const response = await this.fetch(chainFiles.addresses);
|
|
76
|
+
const addresses = parse(await response.text());
|
|
77
|
+
chainAddresses[chainName] = addresses;
|
|
78
|
+
}
|
|
79
|
+
return (this.addressCache = chainAddresses);
|
|
80
|
+
}
|
|
81
|
+
async getChainAddresses(chainName) {
|
|
82
|
+
if (this.addressCache?.[chainName])
|
|
83
|
+
return this.addressCache[chainName];
|
|
84
|
+
const url = this.getRawContentUrl(`${this.getChainsPath()}/${chainName}/addresses.yaml`);
|
|
85
|
+
const response = await this.fetch(url);
|
|
86
|
+
return parse(await response.text());
|
|
87
|
+
}
|
|
88
|
+
getRawContentUrl(path) {
|
|
89
|
+
return `https://raw.githubusercontent.com/${this.repoOwner}/${this.repoName}/${this.branch}/${path}`;
|
|
90
|
+
}
|
|
91
|
+
async fetch(url) {
|
|
92
|
+
this.logger.debug(`Fetching from github: ${url}`);
|
|
93
|
+
const response = await fetch(url);
|
|
94
|
+
if (!response.ok)
|
|
95
|
+
throw new Error(`Failed to fetch from github: ${response.status} ${response.statusText}`);
|
|
96
|
+
return response;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Address } from '@hyperlane-xyz/utils';
|
|
2
|
+
import type { ChainMap, ChainMetadata, ChainName } from '@hyperlane-xyz/sdk';
|
|
3
|
+
export interface ChainFiles {
|
|
4
|
+
metadata?: string;
|
|
5
|
+
addresses?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface RegistryContent {
|
|
8
|
+
chains: ChainMap<ChainFiles>;
|
|
9
|
+
deployments: {};
|
|
10
|
+
}
|
|
11
|
+
export type ChainAddresses = Record<string, Address>;
|
|
12
|
+
export interface IRegistry {
|
|
13
|
+
listRegistryContent(): Promise<RegistryContent>;
|
|
14
|
+
getChains(): Promise<Array<ChainName>>;
|
|
15
|
+
getMetadata(): Promise<ChainMap<ChainMetadata>>;
|
|
16
|
+
getChainMetadata(chainName: ChainName): Promise<ChainMetadata | null>;
|
|
17
|
+
getAddresses(): Promise<ChainMap<ChainAddresses>>;
|
|
18
|
+
getChainAddresses(chainName: ChainName): Promise<ChainAddresses | null>;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperlane-xyz/registry",
|
|
3
3
|
"description": "A collection of configs, artifacts, and schemas for Hyperlane",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"yaml": "^2"
|
|
7
|
+
},
|
|
5
8
|
"devDependencies": {
|
|
6
9
|
"@changesets/cli": "^2.26.2",
|
|
7
10
|
"@hyperlane-xyz/sdk": "3.10.0",
|
|
@@ -14,7 +17,6 @@
|
|
|
14
17
|
"prettier": "^2.8.8",
|
|
15
18
|
"tsx": "^4.7.1",
|
|
16
19
|
"typescript": "5.3.3",
|
|
17
|
-
"yaml": "^2.3.1",
|
|
18
20
|
"zod": "^3.21.2",
|
|
19
21
|
"zod-to-json-schema": "^3.22.5"
|
|
20
22
|
},
|