From 616c23cc03f8eb2a5e3ca49344bad1512de19a7c Mon Sep 17 00:00:00 2001 From: Leouarz Date: Tue, 23 Jul 2024 07:16:35 +0200 Subject: [PATCH] update explorer to add mainnet endpoint, inflation params, ... --- .env | 3 --- .env-example | 3 --- .github/workflows/releaser.yml | 2 +- docker/Dockerfile | 2 +- package.json | 2 +- packages/apps-config/src/api/constants.ts | 4 +-- .../apps-config/src/api/params/inflation.ts | 3 +-- .../apps-config/src/endpoints/production.ts | 27 +++++++++---------- packages/apps-config/src/endpoints/testing.ts | 11 -------- packages/apps-config/src/variables/config.ts | 14 +++------- packages/apps/webpack.base.cjs | 2 -- patches/@polkadot+hw-ledger+12.6.2.patch | 10 ++++--- yarn.lock | 10 +++---- 13 files changed, 33 insertions(+), 60 deletions(-) diff --git a/.env b/.env index a5303d3222de..fb573b07447c 100644 --- a/.env +++ b/.env @@ -1,6 +1,3 @@ -GOLDBERG_URL= -GOLDBERG_LC= - TURING_URL= TURING_LC= diff --git a/.env-example b/.env-example index a4249407134f..c2e15ea81139 100644 --- a/.env-example +++ b/.env-example @@ -2,9 +2,6 @@ # docker run ... --env-file .env ... WS_URL=ws://localhost:9944 POLKADOT_UI_SAMPLE=42 -GOLDBERG_URL= -GOLDBERG_LC= - TURING_URL= TURING_LC= diff --git a/.github/workflows/releaser.yml b/.github/workflows/releaser.yml index 0252695698c3..43d96c21de9d 100644 --- a/.github/workflows/releaser.yml +++ b/.github/workflows/releaser.yml @@ -63,4 +63,4 @@ jobs: tags: availj/explorer:${{ steps.prepare.outputs.tag_name }} build-args: | TURING_URL=wss://turing-rpc.avail.so/ws - GOLDBERG_URL=wss://goldberg-testnet-rpc.avail.tools/ws + MAINNET_URL=wss://mainnet-rpc.avail.so/ws diff --git a/docker/Dockerfile b/docker/Dockerfile index adf8237730c8..2ab439db135d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get install --no-install-recommends -y nodejs && \ rm -rf /var/lib/apt/lists/* ARG TURING_URL -ARG GOLDBERG_URL +ARG MAINNET_URL RUN npm install yarn -g WORKDIR /apps diff --git a/package.json b/package.json index 5bd5f8309e31..7c7cc0036c43 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "test:skipped": "echo 'tests skipped'" }, "dependencies": { - "avail-js-sdk": "^0.2.12", + "avail-js-sdk": "^0.2.13", "axios": "^1.4.0", "dotenv": "^16.3.1", "patch-package": "^8.0.0", diff --git a/packages/apps-config/src/api/constants.ts b/packages/apps-config/src/api/constants.ts index 08b671270253..f6cec30eb9d6 100644 --- a/packages/apps-config/src/api/constants.ts +++ b/packages/apps-config/src/api/constants.ts @@ -39,12 +39,10 @@ export const CERE_NETWORK_GENESIS = '0x81443836a9a24caaa23f1241897d1235717535711 export const CERE_NETWORK_TESTNET_GENESIS = '0x42b9b44b4950b6c1edae543a7696caf8d0a160e9bc0424ab4ab217f7a8ba30dc'; -export const AVAIL_NETWORK_GENESIS = '0x'; // TODO-mainnet +export const AVAIL_NETWORK_GENESIS = '0xb91746b45e0346cc2f815a520b9c6cb4d5c0902af848db0a80f85932d2e8276a'; export const TURING_NETWORK_TESTNET_GENESIS = '0xd3d2f3a3495dc597434a99d7d449ebad6616db45e4e4f178f31cc6fa14378b70'; -export const GOLDBERG_NETWORK_TESTNET_GENESIS = '0x6f09966420b2608d1947ccfb0f2a362450d1fc7fd902c29b67c906eaa965a7ae'; - export const VARA_NETWORK_GENESIS = '0xfe1b4c55fd4d668101126434206571a7838a8b6b93a6d1b95d607e78e6c53763'; export const VARA_NETWORK_TESTNET_GENESIS = '0x525639f713f397dcf839bd022cd821f367ebcf179de7b9253531f8adbe5436d6'; diff --git a/packages/apps-config/src/api/params/inflation.ts b/packages/apps-config/src/api/params/inflation.ts index 65b33f011d03..c9d74f5bf1d4 100644 --- a/packages/apps-config/src/api/params/inflation.ts +++ b/packages/apps-config/src/api/params/inflation.ts @@ -3,7 +3,7 @@ import type { ApiPromise } from '@polkadot/api'; -import { AVAIL_NETWORK_GENESIS, CERE_NETWORK_GENESIS, CERE_NETWORK_TESTNET_GENESIS, DOCK_POS_TESTNET_GENESIS, GOLDBERG_NETWORK_TESTNET_GENESIS, KUSAMA_GENESIS, NEATCOIN_GENESIS, NFTMART_GENESIS, POLKADOT_GENESIS, TURING_NETWORK_TESTNET_GENESIS, VARA_NETWORK_GENESIS, VARA_NETWORK_TESTNET_GENESIS } from '../constants.js'; +import { AVAIL_NETWORK_GENESIS, CERE_NETWORK_GENESIS, CERE_NETWORK_TESTNET_GENESIS, DOCK_POS_TESTNET_GENESIS, KUSAMA_GENESIS, NEATCOIN_GENESIS, NFTMART_GENESIS, POLKADOT_GENESIS, TURING_NETWORK_TESTNET_GENESIS, VARA_NETWORK_GENESIS, VARA_NETWORK_TESTNET_GENESIS } from '../constants.js'; interface InflationParams { auctionAdjust: number; @@ -37,7 +37,6 @@ const KNOWN_PARAMS: Record = { [CERE_NETWORK_GENESIS]: CERE_NETWORK_INFLATION_PARAMS, [CERE_NETWORK_TESTNET_GENESIS]: CERE_NETWORK_INFLATION_PARAMS, [DOCK_POS_TESTNET_GENESIS]: { ...DEFAULT_PARAMS, stakeTarget: 0.75 }, - [GOLDBERG_NETWORK_TESTNET_GENESIS]: AVAIL_NETWORK_INFLATION_PARAMS, // 30% for up to 60 slots, see // https://github.com/paritytech/polkadot/blob/816cb64ea16102c6c79f6be2a917d832d98df757/runtime/kusama/src/lib.rs#L526-L527 // 75% ideal target, see diff --git a/packages/apps-config/src/endpoints/production.ts b/packages/apps-config/src/endpoints/production.ts index 674276fb6496..0d7c5e5b4595 100644 --- a/packages/apps-config/src/endpoints/production.ts +++ b/packages/apps-config/src/endpoints/production.ts @@ -3,10 +3,10 @@ import type { EndpointOption } from './types.js'; +import { nodesAvailPNG } from '../ui/logos/nodes/index.js'; // import { chains3dpassSVG, chainsAlephSVG, chainsBittensorPNG, chainsChainflipPNG, chainsCreditcoinPNG, chainsDebioSVG, chainsFragnovaPNG, chainsJurPNG, chainsLiberlandPNG, chainsLogionPNG, chainsMyriadPNG, chainsSpannerPNG, chainsVaraPNG, chainsVtbPNG } from '../ui/logos/chains/index.js'; // import { nodesAresOdysseySVG, nodesAutomataPNG, nodesCentrifugePNG, nodesCereSVG, nodesChainxSVG, nodesCompetitorsClubPNG, nodesCrownSterlingPNG, nodesCrustSVG, nodesDatahighwayPNG, nodesDockPNG, nodesEdgewareWhitePNG, nodesEfinitySVG, nodesHanyonycashPNG, nodesHumanodePNG, nodesInnovatorPNG, nodesJoystreamSVG, nodesKulupuSVG, nodesKusariSVG, nodesMathSVG, nodesMinixPNG, nodesNftmartPNG, nodesNodleSVG, nodesPolkadexSVG, nodesPolymeshSVG, nodesRiochainSVG, nodesRobonomicsSVG, nodesSherpaxPNG, nodesSoraSubstrateSVG, nodesStafiPNG, nodesSubgameSVG, nodesSubsocialSVG, nodesSwapdexSVG, nodesTernoaSVG, nodesThebifrostPNG, nodesUniartsPNG, nodesUnitnetworkPNG } from '../ui/logos/nodes/index.js'; -// import config from '../variables/config.js'; -// import { nodesAvailPNG } from '../ui/logos/nodes/index.js'; +import config from '../variables/config.js'; export * from './productionRelayKusama.js'; export * from './productionRelayPolkadot.js'; @@ -18,17 +18,16 @@ export * from './productionRelayPolkadot.js'; // providers: The actual hosted secure websocket endpoint // // IMPORTANT: Alphabetical based on text -// TODO-mainnet export const prodChains: Omit[] = [ - // { - // info: 'avail', - // providers: { - // AVAIL: config.mainnet.url - // }, - // text: 'Avail network', - // ui: { - // color: '#1B1E26', - // logo: nodesAvailPNG - // } - // }, + { + info: 'avail', + providers: { + AVAIL: config.mainnet.url + }, + text: 'Avail network', + ui: { + color: '#1B1E26', + logo: nodesAvailPNG + } + } ]; diff --git a/packages/apps-config/src/endpoints/testing.ts b/packages/apps-config/src/endpoints/testing.ts index a7de48031fdc..936a5fd39af5 100644 --- a/packages/apps-config/src/endpoints/testing.ts +++ b/packages/apps-config/src/endpoints/testing.ts @@ -28,16 +28,5 @@ export const testChains: Omit[] = [ color: '#5e6067', logo: nodesAvailPNG } - }, - { - info: 'avail', - providers: { - AVAIL: config.goldberg.url - }, - text: 'Avail Goldberg Testnet', - ui: { - color: '#5e6067', - logo: nodesAvailPNG - } } ]; diff --git a/packages/apps-config/src/variables/config.ts b/packages/apps-config/src/variables/config.ts index 8730627505fc..271f0fa1464d 100644 --- a/packages/apps-config/src/variables/config.ts +++ b/packages/apps-config/src/variables/config.ts @@ -2,27 +2,21 @@ // SPDX-License-Identifier: Apache-2.0 // eslint-disable-next-line const config: { [network: string]: { url: `wss://${string}`, lcUrl: string } } = { - goldberg: { - lcUrl: process.env.GOLDBERG_LC || 'https://api.lightclient.goldberg.avail.tools/v1', - url: process.env.GOLDBERG_URL as `wss://${string}` || 'wss://rpc-testnet.avail.tools/ws' + mainnet: { + lcUrl: process.env.MAINNET_LC || 'https://api.lightclient.mainnet.avail.tools/v1', + url: process.env.MAINNET_URL as `wss://${string}` || 'wss://mainnet-rpc.avail.so/ws' }, turing: { lcUrl: process.env.TURING_LC || 'https://api.lightclient.turing.avail.so/v1', url: process.env.TURING_URL as `wss://${string}` || 'wss://turing-rpc.avail.so/ws' } - // mainnet: { // TODO-mainnet - // lcUrl: process.env.MAINNET_LC as string || 'https://api.lightclient.mainnet.avail.tools/v1', - // url: process.env.MAINNET_URL as `wss://${string}` || 'wss://mainnet-rpc.avail.so' - // } }; export const getLCFromUrl = (apiUrl: string) => { if (apiUrl.includes('turing')) { return config.turing.lcUrl; - } else if (apiUrl.includes('goldberg') || apiUrl === 'wss://rpc-testnet.avail.tools/ws') { - return config.goldberg.lcUrl; } else { - return config.turing.lcUrl; // TODO-mainnet + return config.turing.lcUrl; } }; diff --git a/packages/apps/webpack.base.cjs b/packages/apps/webpack.base.cjs index 2fce0c33e4df..f25c13c07dcc 100644 --- a/packages/apps/webpack.base.cjs +++ b/packages/apps/webpack.base.cjs @@ -138,8 +138,6 @@ function createWebpack (context, mode = 'production') { }), new webpack.DefinePlugin({ 'process.env': { - GOLDBERG_LC: JSON.stringify(process.env.GOLDBERG_LC), - GOLDBERG_URL: JSON.stringify(process.env.GOLDBERG_URL), MAINNET_LC: JSON.stringify(process.env.MAINNET_LC), MAINNET_URL: JSON.stringify(process.env.MAINNET_URL), NODE_ENV: JSON.stringify(mode), diff --git a/patches/@polkadot+hw-ledger+12.6.2.patch b/patches/@polkadot+hw-ledger+12.6.2.patch index 8cc16cf2278d..98220142981c 100644 --- a/patches/@polkadot+hw-ledger+12.6.2.patch +++ b/patches/@polkadot+hw-ledger+12.6.2.patch @@ -1,23 +1,25 @@ diff --git a/node_modules/@polkadot/hw-ledger/cjs/defaults.js b/node_modules/@polkadot/hw-ledger/cjs/defaults.js -index 94cf3de..939134b 100644 +index 94cf3de..141b22b 100644 --- a/node_modules/@polkadot/hw-ledger/cjs/defaults.js +++ b/node_modules/@polkadot/hw-ledger/cjs/defaults.js -@@ -6,6 +6,7 @@ exports.ledgerApps = { +@@ -6,6 +6,8 @@ exports.ledgerApps = { ajuna: 'Ajuna', 'aleph-node': 'AlephZero', astar: 'Astar', ++ avail: 'Avail', + 'avail-turing': 'Avail', bifrost: 'Bifrost', 'bifrost-kusama': 'BifrostKusama', centrifuge: 'Centrifuge', diff --git a/node_modules/@polkadot/hw-ledger/defaults.js b/node_modules/@polkadot/hw-ledger/defaults.js -index 9f06432..334edfc 100644 +index 9f06432..9d913d1 100644 --- a/node_modules/@polkadot/hw-ledger/defaults.js +++ b/node_modules/@polkadot/hw-ledger/defaults.js -@@ -3,6 +3,7 @@ export const ledgerApps = { +@@ -3,6 +3,8 @@ export const ledgerApps = { ajuna: 'Ajuna', 'aleph-node': 'AlephZero', astar: 'Astar', ++ avail: 'Avail', + 'avail-turing': 'Avail', bifrost: 'Bifrost', 'bifrost-kusama': 'BifrostKusama', diff --git a/yarn.lock b/yarn.lock index cd0a0fd72746..85f0bb454b08 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5189,12 +5189,12 @@ __metadata: languageName: node linkType: hard -"avail-js-sdk@npm:^0.2.12": - version: 0.2.12 - resolution: "avail-js-sdk@npm:0.2.12" +"avail-js-sdk@npm:^0.2.13": + version: 0.2.13 + resolution: "avail-js-sdk@npm:0.2.13" dependencies: "@polkadot/api": "npm:^10.11.3" - checksum: 10/4f54f6e6244b8aba6f74b6d8e1da9553f119311e014492dfca5691a81cd826bc59eef8eead5ef5455f163b5a4381e4445b78df21093713a486090bbbc204095e + checksum: 10/f8207373f6c0d2700403cc3349241b1fb51bd74e9ae7cfb681fc5af2f487700c668c6169b43767679e1ab5095f2a4e56278b608eba8dd2bbf506761b04cc2fbb languageName: node linkType: hard @@ -14007,7 +14007,7 @@ __metadata: "@types/react-dom": "npm:^18.2.18" "@types/react-router-dom": "npm:^5.3.3" "@types/store": "npm:^2.0.5" - avail-js-sdk: "npm:^0.2.12" + avail-js-sdk: "npm:^0.2.13" axios: "npm:^1.4.0" concurrently: "npm:^8.2.2" devtron: "npm:^1.4.0"