From 0c2e8fcb8b37374e9c37d68e579f9e33034815f2 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Wed, 13 Nov 2024 17:28:26 -0800 Subject: [PATCH 1/4] URLs --- v1/packages/client/src/registry.ts | 2 +- v2/packages/client/src/registry.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v1/packages/client/src/registry.ts b/v1/packages/client/src/registry.ts index f1205f57d..574a53713 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/src/registry.ts b/v2/packages/client/src/registry.ts index f1205f57d..21569d5bc 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) { From c6d6ada0592bbb29725385fbc6b9429db911b6f4 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Wed, 13 Nov 2024 17:30:46 -0800 Subject: [PATCH 2/4] update fetchers --- v1/packages/client/src/registry.ts | 2 +- v2/packages/client/src/registry.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/v1/packages/client/src/registry.ts b/v1/packages/client/src/registry.ts index 574a53713..6e62f83c1 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/chain-registry/chain-registry/main/registries/original/' + baseUrl: 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/original' }; constructor(options: ChainRegistryClientOptions) { diff --git a/v2/packages/client/src/registry.ts b/v2/packages/client/src/registry.ts index 21569d5bc..e68d7233b 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/chain-registry/chain-registry/main/registries/full/' + baseUrl: 'https://raw.githubusercontent.com/chain-registry/chain-registry/main/registries/full' }; constructor(options: ChainRegistryClientOptions) { From 43523c842530ffef002cfa65eee97b149eeca476 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Wed, 13 Nov 2024 17:38:04 -0800 Subject: [PATCH 3/4] nocks --- .../client/__tests__/client-mock.test.ts | 3 ++- v2/packages/client/setup-jest.ts | 21 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/v1/packages/client/__tests__/client-mock.test.ts b/v1/packages/client/__tests__/client-mock.test.ts index a57390315..759317e2e 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/v2/packages/client/setup-jest.ts b/v2/packages/client/setup-jest.ts index a2d065315..d86dade8f 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')); }); From e13455ad09edb5a3cd88e527b02de491db724bfe Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Wed, 13 Nov 2024 17:54:46 -0800 Subject: [PATCH 4/4] nock --- v1/packages/client/__tests__/fetcher.test.ts | 12 ++--- v1/packages/client/jest.config.js | 3 +- v1/packages/client/setup-jest.ts | 50 ++++++++++++++++++++ v2/packages/client/__tests__/fetcher.test.ts | 12 ++--- 4 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 v1/packages/client/setup-jest.ts diff --git a/v1/packages/client/__tests__/fetcher.test.ts b/v1/packages/client/__tests__/fetcher.test.ts index 9024b229c..d14387bd2 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 057a9420e..c30e500d0 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 000000000..15c6b12f3 --- /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/v2/packages/client/__tests__/fetcher.test.ts b/v2/packages/client/__tests__/fetcher.test.ts index 61b28fa1c..7eb020f0b 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' ] };