Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/fetcher urls #175

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion v1/packages/client/__tests__/client-mock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import nock from 'nock';
import { ChainRegistryClient } from '../src/registry';
import { assets, chains } from '../test-utils';

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


function nockByChainName(chainName: string) {
const chainDataPath = `/cosmos/chain-registry/master/${chainName}/chain.json`;
Expand Down
12 changes: 6 additions & 6 deletions v1/packages/client/__tests__/fetcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ describe('Test fetcher', () => {
beforeAll((done) => {
const options: ChainRegistryFetcherOptions = {
urls: [
'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/assetlist.json',
'https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/assetlist.json',
'https://raw.githubusercontent.com/cosmos/chain-registry/master/secretnetwork/assetlist.json',
'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/juno-osmosis.json',
'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json'
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/osmosis/chain.json',
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/osmosis/assetlist.json',
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/juno/assetlist.json',
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/secretnetwork/assetlist.json',
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/_IBC/juno-osmosis.json',
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original/_IBC/osmosis-secretnetwork.json'
]
};

Expand Down
3 changes: 2 additions & 1 deletion v1/packages/client/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ module.exports = {
transformIgnorePatterns: [`/node_modules/*`],
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
modulePathIgnorePatterns: ['dist/*']
modulePathIgnorePatterns: ['dist/*'],
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
};
50 changes: 50 additions & 0 deletions v1/packages/client/setup-jest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import nock from 'nock';

import { assets, chains, ibc } from './test-utils';

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

beforeAll(() => {
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/assetlist.json',
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/assetlist.json',
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/secretnetwork/assetlist.json',
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/juno-osmosis.json',
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json'
nock(baseUrl)
.get('/osmosis/chain.json')
.reply(200, chains.find(c => c.chain_name === 'osmosis'));
nock(baseUrl)
.get('/osmosis/assetlist.json')
.reply(200, assets.find(c => c.chain_name === 'osmosis'));

nock(baseUrl)
.get('/stargaze/chain.json')
.reply(200, chains.find(c => c.chain_name === 'stargaze'));
nock(baseUrl)
.get('/stargaze/assetlist.json')
.reply(200, assets.find(c => c.chain_name === 'stargaze'));

nock(baseUrl)
.get('/juno/chain.json')
.reply(200, chains.find(c => c.chain_name === 'juno'));
nock(baseUrl)
.get('/juno/assetlist.json')
.reply(200, assets.find(c => c.chain_name === 'juno'));

nock(baseUrl)
.get('/secretnetwork/assetlist.json')
.reply(200, assets.find(c => c.chain_name === 'secretnetwork'));

nock(baseUrl)
.get('/_IBC/juno-osmosis.json')
.reply(200, ibc.find(i => i.chain_1.chain_name === 'juno' && i.chain_2.chain_name==='osmosis'));
nock(baseUrl)
.get('/_IBC/osmosis-secretnetwork.json')
.reply(200, ibc.find(i => i.chain_1.chain_name === 'osmosis' && i.chain_2.chain_name==='secretnetwork'));
});


afterAll(() => {
nock.restore();
});
2 changes: 1 addition & 1 deletion v1/packages/client/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface ChainRegistryClientOptions
export class ChainRegistryClient extends ChainRegistryFetcher {
protected _options: ChainRegistryClientOptions = {
chainNames: [],
baseUrl: 'https://raw.githubusercontent.com/cosmos/chain-registry/master'
baseUrl: 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original'
};

constructor(options: ChainRegistryClientOptions) {
Expand Down
12 changes: 6 additions & 6 deletions v2/packages/client/__tests__/fetcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe('Test fetcher', () => {
beforeAll(async () => {
const options: ChainRegistryFetcherOptions = {
urls: [
'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/assetlist.json',
'https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/assetlist.json',
'https://raw.githubusercontent.com/cosmos/chain-registry/master/secretnetwork/assetlist.json',
'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/juno-osmosis.json',
'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json'
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/osmosis/chain.json',
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/osmosis/assetlist.json',
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/juno/assetlist.json',
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/secretnetwork/assetlist.json',
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/_IBC/juno-osmosis.json',
'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full/_IBC/osmosis-secretnetwork.json'
]
};

Expand Down
21 changes: 10 additions & 11 deletions v2/packages/client/setup-jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import nock from 'nock';

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

const baseUrl = 'https://raw.githubusercontent.com';

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

beforeAll(() => {
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
Expand All @@ -13,35 +12,35 @@ beforeAll(() => {
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/juno-osmosis.json',
// 'https://raw.githubusercontent.com/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json'
nock(baseUrl)
.get('/cosmos/chain-registry/master/osmosis/chain.json')
.get('/osmosis/chain.json')
.reply(200, chains.find(c => c.chainName === 'osmosis'));
nock(baseUrl)
.get('/cosmos/chain-registry/master/osmosis/assetlist.json')
.get('/osmosis/assetlist.json')
.reply(200, assetLists.find(c => c.chainName === 'osmosis'));

nock(baseUrl)
.get('/cosmos/chain-registry/master/stargaze/chain.json')
.get('/stargaze/chain.json')
.reply(200, chains.find(c => c.chainName === 'stargaze'));
nock(baseUrl)
.get('/cosmos/chain-registry/master/stargaze/assetlist.json')
.get('/stargaze/assetlist.json')
.reply(200, assetLists.find(c => c.chainName === 'stargaze'));

nock(baseUrl)
.get('/cosmos/chain-registry/master/juno/chain.json')
.get('/juno/chain.json')
.reply(200, chains.find(c => c.chainName === 'juno'));
nock(baseUrl)
.get('/cosmos/chain-registry/master/juno/assetlist.json')
.get('/juno/assetlist.json')
.reply(200, assetLists.find(c => c.chainName === 'juno'));

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

nock(baseUrl)
.get('/cosmos/chain-registry/master/_IBC/juno-osmosis.json')
.get('/_IBC/juno-osmosis.json')
.reply(200, ibc.find(i => i.chain1.chainName === 'juno' && i.chain2.chainName==='osmosis'));
nock(baseUrl)
.get('/cosmos/chain-registry/master/_IBC/osmosis-secretnetwork.json')
.get('/_IBC/osmosis-secretnetwork.json')
.reply(200, ibc.find(i => i.chain1.chainName === 'osmosis' && i.chain2.chainName==='secretnetwork'));
});

Expand Down
2 changes: 1 addition & 1 deletion v2/packages/client/src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface ChainRegistryClientOptions
export class ChainRegistryClient extends ChainRegistryFetcher {
protected _options: ChainRegistryClientOptions = {
chainNames: [],
baseUrl: 'https://raw.githubusercontent.com/cosmos/chain-registry/master'
baseUrl: 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full'
};

constructor(options: ChainRegistryClientOptions) {
Expand Down
Loading