From c61a3c27196f1c6d11e1b236f7b4a3b70fbe23af Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Mon, 11 Dec 2023 10:02:56 -0500 Subject: [PATCH 1/3] Fix explorer url --- src/nibiru/index.ts | 4 +- src/store/chains/index.js | 172 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 src/store/chains/index.js diff --git a/src/nibiru/index.ts b/src/nibiru/index.ts index c045e14a67..81363a9c54 100644 --- a/src/nibiru/index.ts +++ b/src/nibiru/index.ts @@ -1,8 +1,8 @@ import type { LocalConfig } from '@/stores'; const PLAYGROUND_NETWORKS = 'https://networks.play.nibiru.fi/ping-pub'; -const DEV_NETWORKS = 'https://networks.testnet.nibiru.fi/ping-pub'; -const ITN_NETWORKS = 'https://networks.itn.nibiru.fi/ping-pub'; +const DEV_NETWORKS = 'https://networks.devnet.nibiru.fi/ping-pub'; +const ITN_NETWORKS = 'https://networks.testnet.nibiru.fi/ping-pub'; const MAIN_NETWORK = 'https://networks.nibiru.fi/ping-pub'; export const getNetwork = async (url: string): Promise => { diff --git a/src/store/chains/index.js b/src/store/chains/index.js new file mode 100644 index 0000000000..41f96af8ef --- /dev/null +++ b/src/store/chains/index.js @@ -0,0 +1,172 @@ +/* + * @Description: file + * @Autor: dingyiming + * @Date: 2021-11-20 15:26:27 + * @LastEditors: dingyiming + * @LastEditTime: 2021-11-20 15:33:07 + */ +import { sha256 } from '@cosmjs/crypto' +import { toHex } from '@cosmjs/encoding' + +let chains = {} +const coingecko = {} +const configs = [] + +const PLAYGROUND_NETWORKS = 'https://networks.play.nibiru.fi/ping-pub' +const DEV_NETWORKS = 'https://networks.devnet.nibiru.fi/ping-pub' +const ITN_NETWORKS = 'https://networks.testnet.nibiru.fi/ping-pub' + +try { + const testnets = await fetch(ITN_NETWORKS).then(response => response.json()) + testnets.forEach((_, i) => { + testnets[i].visible = true + }) + configs.push(...testnets) +} catch (error) { + console.log(error) +} + +try { + const devnets = await fetch(DEV_NETWORKS).then(response => response.json()) + devnets.forEach((_, i) => { + devnets[i].visible = false + }) + configs.push(...devnets) +} catch (error) { + console.log(error) +} + +try { + const playnets = await fetch(PLAYGROUND_NETWORKS).then(response => response.json()) + playnets.forEach((_, i) => { + playnets[i].visible = false + }) + configs.push(...playnets) +} catch (error) { + console.log(error) +} + +const update = {} +configs.forEach(chain => { + const c = chain + c.chain_name = String(c.chain_name).toLowerCase() + update[c.chain_name] = c + if (Array.isArray(c.assets)) { + c.assets.forEach(x => { + if (x.coingecko_id && x.coingecko_id !== '') coingecko[x.coingecko_id] = String(x.symbol).toUpperCase() + }) + } +}) + +chains = update +localStorage.setItem('chains', JSON.stringify(update)) +const selected = chains.cosmos + +const avatarcache = localStorage.getItem('avatars') + +export default { + namespaced: true, + state: { + config: chains, + selected, + avatars: avatarcache ? JSON.parse(avatarcache) : {}, + height: 0, + ibcChannels: {}, + quotes: {}, + defaultWallet: localStorage.getItem('default-wallet'), + denoms: {}, + ibcPaths: {}, + }, + getters: { + getchains: state => state.chains, + getAvatarById: state => id => state.avatars[id], + }, + mutations: { + setup_sdk_version(state, info) { + state.chains.config[info.chain_name].sdk_version = info.version + }, + select(state, args) { + state.chains.selected = state.chains.config[args.chain_name] + }, + cacheAvatar(state, args) { + state.chains.avatars[args.identity] = args.url + localStorage.setItem('avatars', JSON.stringify(state.chains.avatars)) + }, + setHeight(state, height) { + state.chains.height = height + }, + setChannels(state, { chain, channels }) { + state.chains.ibcChannels[chain] = channels + }, + setQuotes(state, quotes) { + state.quotes = quotes + }, + setDefaultWallet(state, defaultWallet) { + if (defaultWallet && defaultWallet.length > 0) { + localStorage.setItem('default-wallet', defaultWallet) + state.chains.defaultWallet = defaultWallet + } else { + state.chains.defaultWallet = null + } + }, + setIBCDenoms(state, denoms) { + state.denoms = { ...state.denoms, ...denoms } + }, + setIBCPaths(state, paths) { + state.ibcPaths = paths + }, + }, + actions: { + async getQuotes(context) { + // fetch('https://price.ping.pub/quotes').then(data => data.json()).then(data => { + // context.commit('setQuotes', data) + // }) + const keys = Object.keys(coingecko) + if (keys.length > 0) { + const currencies = 'usd,cny,eur,jpy,krw,sgd,hkd' + fetch( + `https://api.coingecko.com/api/v3/simple/price?include_24hr_change=true&vs_currencies=${currencies}&ids=${keys.join( + ',', + )}`, + ) + .then(data => data.json()) + .then(data => { + // use symbol as key instead of coingecko id + const quotes = {} + if (data && Object.keys(data)) { + Object.keys(data).forEach(k => { + quotes[coingecko[k]] = data[k] + }) + } + context.commit('setQuotes', quotes) + }) + } + }, + + async getAllIBCDenoms(context, _this) { + _this.$http.getAllIBCDenoms().then(x => { + const denomsMap = {} + const pathsMap = {} + x.denom_traces.forEach(trace => { + const hash = toHex( + sha256( + new TextEncoder().encode(`${trace.path}/${trace.base_denom}`), + ), + ) + const ibcDenom = `ibc/${hash.toUpperCase()}` + denomsMap[ibcDenom] = trace.base_denom + + const path = trace.path.split('/') + if (path.length >= 2) { + pathsMap[ibcDenom] = { + channel_id: path[path.length - 1], + port_id: path[path.length - 2], + } + } + }) + context.commit('setIBCDenoms', denomsMap) + context.commit('setIBCPaths', pathsMap) + }) + }, + }, +} From 934ad788c14d5e88391ce6fcc78f5099ae4b1d8e Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Mon, 11 Dec 2023 10:05:48 -0500 Subject: [PATCH 2/3] Odd file --- src/store/chains/index.js | 172 -------------------------------------- 1 file changed, 172 deletions(-) delete mode 100644 src/store/chains/index.js diff --git a/src/store/chains/index.js b/src/store/chains/index.js deleted file mode 100644 index 41f96af8ef..0000000000 --- a/src/store/chains/index.js +++ /dev/null @@ -1,172 +0,0 @@ -/* - * @Description: file - * @Autor: dingyiming - * @Date: 2021-11-20 15:26:27 - * @LastEditors: dingyiming - * @LastEditTime: 2021-11-20 15:33:07 - */ -import { sha256 } from '@cosmjs/crypto' -import { toHex } from '@cosmjs/encoding' - -let chains = {} -const coingecko = {} -const configs = [] - -const PLAYGROUND_NETWORKS = 'https://networks.play.nibiru.fi/ping-pub' -const DEV_NETWORKS = 'https://networks.devnet.nibiru.fi/ping-pub' -const ITN_NETWORKS = 'https://networks.testnet.nibiru.fi/ping-pub' - -try { - const testnets = await fetch(ITN_NETWORKS).then(response => response.json()) - testnets.forEach((_, i) => { - testnets[i].visible = true - }) - configs.push(...testnets) -} catch (error) { - console.log(error) -} - -try { - const devnets = await fetch(DEV_NETWORKS).then(response => response.json()) - devnets.forEach((_, i) => { - devnets[i].visible = false - }) - configs.push(...devnets) -} catch (error) { - console.log(error) -} - -try { - const playnets = await fetch(PLAYGROUND_NETWORKS).then(response => response.json()) - playnets.forEach((_, i) => { - playnets[i].visible = false - }) - configs.push(...playnets) -} catch (error) { - console.log(error) -} - -const update = {} -configs.forEach(chain => { - const c = chain - c.chain_name = String(c.chain_name).toLowerCase() - update[c.chain_name] = c - if (Array.isArray(c.assets)) { - c.assets.forEach(x => { - if (x.coingecko_id && x.coingecko_id !== '') coingecko[x.coingecko_id] = String(x.symbol).toUpperCase() - }) - } -}) - -chains = update -localStorage.setItem('chains', JSON.stringify(update)) -const selected = chains.cosmos - -const avatarcache = localStorage.getItem('avatars') - -export default { - namespaced: true, - state: { - config: chains, - selected, - avatars: avatarcache ? JSON.parse(avatarcache) : {}, - height: 0, - ibcChannels: {}, - quotes: {}, - defaultWallet: localStorage.getItem('default-wallet'), - denoms: {}, - ibcPaths: {}, - }, - getters: { - getchains: state => state.chains, - getAvatarById: state => id => state.avatars[id], - }, - mutations: { - setup_sdk_version(state, info) { - state.chains.config[info.chain_name].sdk_version = info.version - }, - select(state, args) { - state.chains.selected = state.chains.config[args.chain_name] - }, - cacheAvatar(state, args) { - state.chains.avatars[args.identity] = args.url - localStorage.setItem('avatars', JSON.stringify(state.chains.avatars)) - }, - setHeight(state, height) { - state.chains.height = height - }, - setChannels(state, { chain, channels }) { - state.chains.ibcChannels[chain] = channels - }, - setQuotes(state, quotes) { - state.quotes = quotes - }, - setDefaultWallet(state, defaultWallet) { - if (defaultWallet && defaultWallet.length > 0) { - localStorage.setItem('default-wallet', defaultWallet) - state.chains.defaultWallet = defaultWallet - } else { - state.chains.defaultWallet = null - } - }, - setIBCDenoms(state, denoms) { - state.denoms = { ...state.denoms, ...denoms } - }, - setIBCPaths(state, paths) { - state.ibcPaths = paths - }, - }, - actions: { - async getQuotes(context) { - // fetch('https://price.ping.pub/quotes').then(data => data.json()).then(data => { - // context.commit('setQuotes', data) - // }) - const keys = Object.keys(coingecko) - if (keys.length > 0) { - const currencies = 'usd,cny,eur,jpy,krw,sgd,hkd' - fetch( - `https://api.coingecko.com/api/v3/simple/price?include_24hr_change=true&vs_currencies=${currencies}&ids=${keys.join( - ',', - )}`, - ) - .then(data => data.json()) - .then(data => { - // use symbol as key instead of coingecko id - const quotes = {} - if (data && Object.keys(data)) { - Object.keys(data).forEach(k => { - quotes[coingecko[k]] = data[k] - }) - } - context.commit('setQuotes', quotes) - }) - } - }, - - async getAllIBCDenoms(context, _this) { - _this.$http.getAllIBCDenoms().then(x => { - const denomsMap = {} - const pathsMap = {} - x.denom_traces.forEach(trace => { - const hash = toHex( - sha256( - new TextEncoder().encode(`${trace.path}/${trace.base_denom}`), - ), - ) - const ibcDenom = `ibc/${hash.toUpperCase()}` - denomsMap[ibcDenom] = trace.base_denom - - const path = trace.path.split('/') - if (path.length >= 2) { - pathsMap[ibcDenom] = { - channel_id: path[path.length - 1], - port_id: path[path.length - 2], - } - } - }) - context.commit('setIBCDenoms', denomsMap) - context.commit('setIBCPaths', pathsMap) - }) - }, - }, -} From 3ad8f690a98d401e2e24f0e48b4979e3998c7003 Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Mon, 11 Dec 2023 10:11:57 -0500 Subject: [PATCH 3/3] Update CI --- .github/workflows/deploy-preview.yml | 9 +++++---- .github/workflows/deploy-prod.yml | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 1db1f35e52..ddc73c395c 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -11,8 +11,8 @@ jobs: - name: Set Node.js 16.x uses: actions/setup-node@v3 with: - node-version: 16.x - cache: "yarn" + node-version: 'lts/gallium' + cache: 'yarn' - name: Run install uses: borales/actions-yarn@v4 @@ -25,8 +25,9 @@ jobs: - uses: FirebaseExtended/action-hosting-deploy@v0 with: - repoToken: "${{ secrets.GITHUB_TOKEN }}" - firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_NIBIRU_CHAIN }}" + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NIBIRU_CHAIN }}' projectId: nibiru-chain expires: 14d target: explorer + firebaseToolsVersion: '12.9.1' diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 29939ad355..3c4bd8025f 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -14,8 +14,8 @@ jobs: - name: Set Node.js 16.x uses: actions/setup-node@v3 with: - node-version: 16.x - cache: "yarn" + node-version: 'lts/gallium' + cache: 'yarn' - name: Run install uses: borales/actions-yarn@v4 @@ -28,8 +28,9 @@ jobs: - uses: FirebaseExtended/action-hosting-deploy@v0 with: - repoToken: "${{ secrets.GITHUB_TOKEN }}" - firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_NIBIRU_CHAIN }}" + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_NIBIRU_CHAIN }}' projectId: nibiru-chain channelId: live target: explorer + firebaseToolsVersion: '12.9.1'