diff --git a/v1/packages/client/__tests__/client-mock.test.ts b/v1/packages/client/__tests__/client-mock.test.ts index a5739031..759317e2 100644 --- a/v1/packages/client/__tests__/client-mock.test.ts +++ b/v1/packages/client/__tests__/client-mock.test.ts @@ -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`; diff --git a/v1/packages/client/__tests__/fetcher.test.ts b/v1/packages/client/__tests__/fetcher.test.ts index 9024b229..d14387bd 100644 --- a/v1/packages/client/__tests__/fetcher.test.ts +++ b/v1/packages/client/__tests__/fetcher.test.ts @@ -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' ] }; diff --git a/v1/packages/client/jest.config.js b/v1/packages/client/jest.config.js index 057a9420..c30e500d 100644 --- a/v1/packages/client/jest.config.js +++ b/v1/packages/client/jest.config.js @@ -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: ['/setup-jest.ts'], }; diff --git a/v1/packages/client/setup-jest.ts b/v1/packages/client/setup-jest.ts new file mode 100644 index 00000000..15c6b12f --- /dev/null +++ b/v1/packages/client/setup-jest.ts @@ -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(); +}); \ No newline at end of file diff --git a/v1/packages/client/src/registry.ts b/v1/packages/client/src/registry.ts index f1205f57..6e62f83c 100644 --- a/v1/packages/client/src/registry.ts +++ b/v1/packages/client/src/registry.ts @@ -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) { diff --git a/v2/packages/client/__tests__/fetcher.test.ts b/v2/packages/client/__tests__/fetcher.test.ts index 61b28fa1..7eb020f0 100644 --- a/v2/packages/client/__tests__/fetcher.test.ts +++ b/v2/packages/client/__tests__/fetcher.test.ts @@ -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' ] }; diff --git a/v2/packages/client/setup-jest.ts b/v2/packages/client/setup-jest.ts index a2d06531..d86dade8 100644 --- a/v2/packages/client/setup-jest.ts +++ b/v2/packages/client/setup-jest.ts @@ -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', @@ -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')); }); diff --git a/v2/packages/client/src/registry.ts b/v2/packages/client/src/registry.ts index f1205f57..e68d7233 100644 --- a/v2/packages/client/src/registry.ts +++ b/v2/packages/client/src/registry.ts @@ -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) {