Skip to content

Commit f83136b

Browse files
authored
Merge pull request #175 from cosmology-tech/feat/fetcher-urls
Feat/fetcher urls
2 parents 03ea0f3 + e13455a commit f83136b

File tree

8 files changed

+78
-27
lines changed

8 files changed

+78
-27
lines changed

v1/packages/client/__tests__/client-mock.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import nock from 'nock';
33
import { ChainRegistryClient } from '../src/registry';
44
import { assets, chains } from '../test-utils';
55

6-
const baseUrl = 'https://raw.githubusercontent.com';
6+
const baseUrl = 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original';
7+
78

89
function nockByChainName(chainName: string) {
910
const chainDataPath = `/cosmos/chain-registry/master/${chainName}/chain.json`;

v1/packages/client/__tests__/fetcher.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ describe('Test fetcher', () => {
1010
beforeAll((done) => {
1111
const options: ChainRegistryFetcherOptions = {
1212
urls: [
13-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
14-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/assetlist.json',
15-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/assetlist.json',
16-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/secretnetwork/assetlist.json',
17-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/juno-osmosis.json',
18-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json'
13+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/osmosis/chain.json',
14+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/osmosis/assetlist.json',
15+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/juno/assetlist.json',
16+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/secretnetwork/assetlist.json',
17+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/_IBC/juno-osmosis.json',
18+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/_IBC/osmosis-secretnetwork.json'
1919
]
2020
};
2121

v1/packages/client/jest.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ module.exports = {
1414
transformIgnorePatterns: [`/node_modules/*`],
1515
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
1616
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
17-
modulePathIgnorePatterns: ['dist/*']
17+
modulePathIgnorePatterns: ['dist/*'],
18+
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
1819
};

v1/packages/client/setup-jest.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import nock from 'nock';
2+
3+
import { assets, chains, ibc } from './test-utils';
4+
5+
const baseUrl = 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original';
6+
7+
beforeAll(() => {
8+
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
9+
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/assetlist.json',
10+
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/assetlist.json',
11+
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/secretnetwork/assetlist.json',
12+
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/juno-osmosis.json',
13+
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json'
14+
nock(baseUrl)
15+
.get('/osmosis/chain.json')
16+
.reply(200, chains.find(c => c.chain_name === 'osmosis'));
17+
nock(baseUrl)
18+
.get('/osmosis/assetlist.json')
19+
.reply(200, assets.find(c => c.chain_name === 'osmosis'));
20+
21+
nock(baseUrl)
22+
.get('/stargaze/chain.json')
23+
.reply(200, chains.find(c => c.chain_name === 'stargaze'));
24+
nock(baseUrl)
25+
.get('/stargaze/assetlist.json')
26+
.reply(200, assets.find(c => c.chain_name === 'stargaze'));
27+
28+
nock(baseUrl)
29+
.get('/juno/chain.json')
30+
.reply(200, chains.find(c => c.chain_name === 'juno'));
31+
nock(baseUrl)
32+
.get('/juno/assetlist.json')
33+
.reply(200, assets.find(c => c.chain_name === 'juno'));
34+
35+
nock(baseUrl)
36+
.get('/secretnetwork/assetlist.json')
37+
.reply(200, assets.find(c => c.chain_name === 'secretnetwork'));
38+
39+
nock(baseUrl)
40+
.get('/_IBC/juno-osmosis.json')
41+
.reply(200, ibc.find(i => i.chain_1.chain_name === 'juno' && i.chain_2.chain_name==='osmosis'));
42+
nock(baseUrl)
43+
.get('/_IBC/osmosis-secretnetwork.json')
44+
.reply(200, ibc.find(i => i.chain_1.chain_name === 'osmosis' && i.chain_2.chain_name==='secretnetwork'));
45+
});
46+
47+
48+
afterAll(() => {
49+
nock.restore();
50+
});

v1/packages/client/src/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface ChainRegistryClientOptions
1212
export class ChainRegistryClient extends ChainRegistryFetcher {
1313
protected _options: ChainRegistryClientOptions = {
1414
chainNames: [],
15-
baseUrl: 'https://raw.githubusercontent.com/cosmos/chain-registry/master'
15+
baseUrl: 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original'
1616
};
1717

1818
constructor(options: ChainRegistryClientOptions) {

v2/packages/client/__tests__/fetcher.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ describe('Test fetcher', () => {
88
beforeAll(async () => {
99
const options: ChainRegistryFetcherOptions = {
1010
urls: [
11-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
12-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/assetlist.json',
13-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/assetlist.json',
14-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/secretnetwork/assetlist.json',
15-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/juno-osmosis.json',
16-
'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json'
11+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/osmosis/chain.json',
12+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/osmosis/assetlist.json',
13+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/juno/assetlist.json',
14+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/secretnetwork/assetlist.json',
15+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/_IBC/juno-osmosis.json',
16+
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/_IBC/osmosis-secretnetwork.json'
1717
]
1818
};
1919

v2/packages/client/setup-jest.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import nock from 'nock';
22

33
import { assetLists, chains, ibc } from './test-utils';
44

5-
const baseUrl = 'https://raw.githubusercontent.com';
6-
5+
const baseUrl = 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full';
76

87
beforeAll(() => {
98
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
@@ -13,35 +12,35 @@ beforeAll(() => {
1312
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/juno-osmosis.json',
1413
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json'
1514
nock(baseUrl)
16-
.get('/cosmos/chain-registry/master/osmosis/chain.json')
15+
.get('/osmosis/chain.json')
1716
.reply(200, chains.find(c => c.chainName === 'osmosis'));
1817
nock(baseUrl)
19-
.get('/cosmos/chain-registry/master/osmosis/assetlist.json')
18+
.get('/osmosis/assetlist.json')
2019
.reply(200, assetLists.find(c => c.chainName === 'osmosis'));
2120

2221
nock(baseUrl)
23-
.get('/cosmos/chain-registry/master/stargaze/chain.json')
22+
.get('/stargaze/chain.json')
2423
.reply(200, chains.find(c => c.chainName === 'stargaze'));
2524
nock(baseUrl)
26-
.get('/cosmos/chain-registry/master/stargaze/assetlist.json')
25+
.get('/stargaze/assetlist.json')
2726
.reply(200, assetLists.find(c => c.chainName === 'stargaze'));
2827

2928
nock(baseUrl)
30-
.get('/cosmos/chain-registry/master/juno/chain.json')
29+
.get('/juno/chain.json')
3130
.reply(200, chains.find(c => c.chainName === 'juno'));
3231
nock(baseUrl)
33-
.get('/cosmos/chain-registry/master/juno/assetlist.json')
32+
.get('/juno/assetlist.json')
3433
.reply(200, assetLists.find(c => c.chainName === 'juno'));
3534

3635
nock(baseUrl)
37-
.get('/cosmos/chain-registry/master/secretnetwork/assetlist.json')
36+
.get('/secretnetwork/assetlist.json')
3837
.reply(200, assetLists.find(c => c.chainName === 'secretnetwork'));
3938

4039
nock(baseUrl)
41-
.get('/cosmos/chain-registry/master/_IBC/juno-osmosis.json')
40+
.get('/_IBC/juno-osmosis.json')
4241
.reply(200, ibc.find(i => i.chain1.chainName === 'juno' && i.chain2.chainName==='osmosis'));
4342
nock(baseUrl)
44-
.get('/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json')
43+
.get('/_IBC/osmosis-secretnetwork.json')
4544
.reply(200, ibc.find(i => i.chain1.chainName === 'osmosis' && i.chain2.chainName==='secretnetwork'));
4645
});
4746

v2/packages/client/src/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export interface ChainRegistryClientOptions
1212
export class ChainRegistryClient extends ChainRegistryFetcher {
1313
protected _options: ChainRegistryClientOptions = {
1414
chainNames: [],
15-
baseUrl: 'https://raw.githubusercontent.com/cosmos/chain-registry/master'
15+
baseUrl: 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full'
1616
};
1717

1818
constructor(options: ChainRegistryClientOptions) {

0 commit comments

Comments
 (0)