From fe3a4f18947620b14ba958d03a775f38c00eb610 Mon Sep 17 00:00:00 2001 From: Yashiro <51014425+yuhui1208@users.noreply.github.com> Date: Fri, 6 Aug 2021 18:49:35 +0800 Subject: [PATCH] Add crust mainnet endpoint (#5929) * Add crust mainnet endpoint * Fix lint * Fix * Fix test * Fix lint --- .../src/api/chain/crust-maxwell.ts | 103 ++++++++++++++++++ packages/apps-config/src/api/chain/index.ts | 5 +- .../apps-config/src/endpoints/production.ts | 7 ++ packages/apps-config/src/endpoints/testing.ts | 2 +- packages/apps-config/src/ui/colors.ts | 4 +- packages/apps-config/src/ui/logos/index.ts | 4 + .../src/ui/logos/nodes/crust-maxwell.svg | 28 +++++ .../apps-config/src/ui/logos/nodes/crust.svg | 44 +++----- 8 files changed, 168 insertions(+), 29 deletions(-) create mode 100644 packages/apps-config/src/api/chain/crust-maxwell.ts create mode 100644 packages/apps-config/src/ui/logos/nodes/crust-maxwell.svg diff --git a/packages/apps-config/src/api/chain/crust-maxwell.ts b/packages/apps-config/src/api/chain/crust-maxwell.ts new file mode 100644 index 0000000000..55cd334a9d --- /dev/null +++ b/packages/apps-config/src/api/chain/crust-maxwell.ts @@ -0,0 +1,103 @@ +// Copyright 2017-2021 @polkadot/apps-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// structs need to be in order +/* eslint-disable sort-keys */ + +export default { + AccountInfo: 'AccountInfoWithProviders', + Address: 'AccountId', + AddressInfo: 'Vec', + LookupSource: 'AccountId', + EraBenefits: { + total_benefits: 'Balance', + total_funds: 'Balance', + used_benefits: 'Balance', + active_era: 'EraIndex' + }, + FeeReductionBenefit: { + funds: 'Balance', + total_fee_reduction_count: 'u32', + used_fee_reduction_quota: 'Balance', + used_fee_reduction_count: 'u32', + refreshed_at: 'EraIndex' + }, + CsmBalance: 'Balance', + CsmBalanceOf: 'Balance', + ETHAddress: 'Vec', + EthereumTxHash: 'H256', + CSMLedger: { + total: 'Compact', + active: 'Compact', + unlocking: 'Vec>' + }, + CSMUnlockChunk: { + value: 'Compact', + bn: 'Compact' + }, + FileInfo: { + file_size: 'u64', + expired_on: 'BlockNumber', + calculated_at: 'BlockNumber', + amount: 'Balance', + prepaid: 'Balance', + reported_replica_count: 'u32', + replicas: 'Vec>' + }, + MerchantLedger: { + reward: 'Balance', + collateral: 'Balance' + }, + Releases: { + _enum: ['V1_0_0', 'V2_0_0'] + }, + Replica: { + who: 'AccountId', + valid_at: 'BlockNumber', + anchor: 'SworkerAnchor', + is_reported: 'bool' + }, + Status: { + _enum: ['Free', 'Reserved'] + }, + UsedInfo: { + used_size: 'u64', + reported_group_count: 'u32', + groups: 'BTreeMap' + }, + Guarantee: { + targets: 'Vec>', + total: 'Compact', + submitted_in: 'EraIndex', + suppressed: 'bool' + }, + ValidatorPrefs: { + guarantee_fee: 'Compact' + }, + IASSig: 'Vec', + Identity: { + anchor: 'SworkerAnchor', + punishment_deadline: 'u64', + group: 'Option' + }, + ISVBody: 'Vec', + MerkleRoot: 'Vec', + ReportSlot: 'u64', + PKInfo: { + code: 'SworkerCode', + anchor: 'Option' + }, + SworkerAnchor: 'Vec', + SworkerCert: 'Vec', + SworkerCode: 'Vec', + SworkerPubKey: 'Vec', + SworkerSignature: 'Vec', + WorkReport: { + report_slot: 'u64', + used: 'u64', + free: 'u64', + reported_files_size: 'u64', + reported_srd_root: 'MerkleRoot', + reported_files_root: 'MerkleRoot' + } +}; diff --git a/packages/apps-config/src/api/chain/index.ts b/packages/apps-config/src/api/chain/index.ts index fdfb52b903..e04209f873 100644 --- a/packages/apps-config/src/api/chain/index.ts +++ b/packages/apps-config/src/api/chain/index.ts @@ -3,7 +3,10 @@ import { typesChain } from '@phala/typedefs'; +import CrustMaxwell from './crust-maxwell'; + // alphabetical, based on the actual displayed name export default { - ...typesChain + ...typesChain, + 'Crust Maxwell': CrustMaxwell }; diff --git a/packages/apps-config/src/endpoints/production.ts b/packages/apps-config/src/endpoints/production.ts index 96ed37f916..b8b68d40ba 100644 --- a/packages/apps-config/src/endpoints/production.ts +++ b/packages/apps-config/src/endpoints/production.ts @@ -33,6 +33,13 @@ export function createProduction (t: TFunction, firstOnly?: boolean): LinkOption 'Patract Elara': 'wss://chainx.elara.patract.io' } }, + { + info: 'crust', + text: t('rpc.prod.crust', 'Crust Network', { ns: 'apps-config' }), + providers: { + 'Crust Network': 'wss://rpc.crust.network' + } + }, { info: 'darwinia', text: t('rpc.prod.darwinia', 'Darwinia', { ns: 'apps-config' }), diff --git a/packages/apps-config/src/endpoints/testing.ts b/packages/apps-config/src/endpoints/testing.ts index 595febee91..d1201d5fcc 100644 --- a/packages/apps-config/src/endpoints/testing.ts +++ b/packages/apps-config/src/endpoints/testing.ts @@ -76,7 +76,7 @@ export function createTesting (t: TFunction, firstOnly?: boolean): LinkOption[] } }, { - info: 'crust', + info: 'Crust Maxwell', text: t('rpc.test.crust.network', 'Crust Maxwell', { ns: 'apps-config' }), providers: { 'Crust Network': 'wss://api.crust.network/', diff --git a/packages/apps-config/src/ui/colors.ts b/packages/apps-config/src/ui/colors.ts index 5553ab5135..693ee398cd 100644 --- a/packages/apps-config/src/ui/colors.ts +++ b/packages/apps-config/src/ui/colors.ts @@ -19,6 +19,7 @@ const chainBitCountry = '#191a2e'; const chainBeastEave = '#900048'; const chainCrab = '#7C30DD'; const chainCrust = '#ff8812'; +const chainCrustMaxwell = '#2E333B'; const chainClover = 'linear-gradient(to right, #52ad75, #7cc773)'; const chainChainx = '#F6C94A'; const chainDarwinia = 'linear-gradient(-45deg, #FE3876 0%, #7C30DD 71%, #3A30DD 100%)'; @@ -169,7 +170,8 @@ export const chainColors: Record = Object.entries({ 'Bit.Country Tewai Chain': chainBitCountry, ChainX: chainChainx, Clover: chainClover, - 'crust maxwell': chainCrust, + crust: chainCrust, + 'crust maxwell': chainCrustMaxwell, 'Crust PC1': chainCrust, 'darwinia cc1': chainDarwinia, 'Darwinia Crab': chainCrab, diff --git a/packages/apps-config/src/ui/logos/index.ts b/packages/apps-config/src/ui/logos/index.ts index 7272d06723..3017f40e4d 100644 --- a/packages/apps-config/src/ui/logos/index.ts +++ b/packages/apps-config/src/ui/logos/index.ts @@ -46,6 +46,7 @@ import nodeChainx from './nodes/chainx.svg'; import nodeClover from './nodes/clover.svg'; import nodeCrab from './nodes/crab.svg'; import nodeCrust from './nodes/crust.svg'; +import nodeCrustMaxwell from './nodes/crust-maxwell.svg'; import nodeDarwinia from './nodes/darwinia.png'; import nodeDataHighway from './nodes/datahighway.png'; import nodeDockMainnet from './nodes/dock-mainnet.png'; @@ -141,6 +142,7 @@ export const chainLogos = Object.entries({ 'Bifrost Asgard CC4': nodeBifrost, ChainX: nodeChainx, 'Charcoal Testnet': nodeCentrifuge, + 'Crust Maxwell': nodeCrustMaxwell, 'Crust PC1': nodeCrust, 'darwinia crab': nodeCrab, 'Darwinia Crab PC2': nodeCrab, @@ -269,6 +271,7 @@ export const nodeLogos = Object.entries({ 'Clover Node': nodeClover, crust: nodeCrust, 'Crust Collator': nodeCrust, + 'Crust Maxwell': nodeCrustMaxwell, darwinia: nodeDarwinia, 'darwinia crab': nodeCrab, 'darwinia parachain': nodeDarwinia, @@ -419,6 +422,7 @@ export const namedLogos: Record = { crab: nodeCrab, crab_redirect: nodeCrab, crust: nodeCrust, + 'Crust Maxwell': nodeCrustMaxwell, darwinia: nodeDarwinia, datahighway: nodeDataHighway, 'dock-mainnet': nodeDockMainnet, diff --git a/packages/apps-config/src/ui/logos/nodes/crust-maxwell.svg b/packages/apps-config/src/ui/logos/nodes/crust-maxwell.svg new file mode 100644 index 0000000000..67a6240399 --- /dev/null +++ b/packages/apps-config/src/ui/logos/nodes/crust-maxwell.svg @@ -0,0 +1,28 @@ + + + + +ziyuan 1 + + + + + + + + + + + + + + diff --git a/packages/apps-config/src/ui/logos/nodes/crust.svg b/packages/apps-config/src/ui/logos/nodes/crust.svg index 504a0dc126..45e2331778 100644 --- a/packages/apps-config/src/ui/logos/nodes/crust.svg +++ b/packages/apps-config/src/ui/logos/nodes/crust.svg @@ -1,26 +1,18 @@ - - - group - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + +ziyuan 1 + + + +