From 51c8a70b0d5c7be5474af0f00cf6b885fb335bb6 Mon Sep 17 00:00:00 2001 From: WoeOm <1015996366@qq.com> Date: Tue, 10 Nov 2020 18:23:06 +0800 Subject: [PATCH] Add Darwinia Network (#4003) * update crab types * lint * Add darwinia mainnet * Update crab types --- packages/apps-config/src/api/spec/crab.ts | 160 ++++++----- packages/apps-config/src/api/spec/darwinia.ts | 267 ++++++++++++++++++ packages/apps-config/src/api/spec/index.ts | 2 + .../apps-config/src/settings/endpoints.ts | 6 + packages/apps-config/src/ui/colors.ts | 4 +- packages/apps-config/src/ui/logos/index.ts | 5 +- .../src/ui/logos/nodes/darwinia.svg | 18 ++ .../apps/public/locales/en/apps-config.json | 1 + 8 files changed, 398 insertions(+), 65 deletions(-) create mode 100644 packages/apps-config/src/api/spec/darwinia.ts create mode 100644 packages/apps-config/src/ui/logos/nodes/darwinia.svg diff --git a/packages/apps-config/src/api/spec/crab.ts b/packages/apps-config/src/api/spec/crab.ts index 46b606ef1d..b75b9caab1 100644 --- a/packages/apps-config/src/api/spec/crab.ts +++ b/packages/apps-config/src/api/spec/crab.ts @@ -10,8 +10,8 @@ export default { BalanceInfo: 'Null', BalanceLock: { id: 'LockIdentifier', - lock_for: 'LockFor', - lock_reasons: 'LockReasons', + lockFor: 'LockFor', + LockReasons: 'Reasons', amount: 'Balance', reasons: 'Reasons' }, @@ -25,28 +25,25 @@ export default { amount: 'Balance' }, StakingLock: { - staking_amount: 'Balance', + stakingAmount: 'Balance', unbondings: 'Vec' }, - LockReasons: { - _enum: { - Fee: null, - Misc: null, - All: null - } + Reasons: { + _enum: ['Fee', 'Misc', 'All'] }, Unbonding: { amount: 'Balance', - until: 'BlockNumber' + moment: 'BlockNumber' }, AccountData: { free: 'Balance', reserved: 'Balance', - free_kton: 'Balance', - reserved_kton: 'Balance', - misc_frozen: 'Balance', - fee_frozen: 'Balance' + freeKton: 'Balance', + reservedKton: 'Balance', + miscFrozen: 'Balance', + feeFrozen: 'Balance' }, + RingBalance: 'Balance', KtonBalance: 'Balance', TsInMs: 'u64', @@ -60,37 +57,38 @@ export default { }, StakingLedgerT: { stash: 'AccountId', - active_ring: 'Compact', - active_deposit_ring: 'Compact', - active_kton: 'Compact', - deposit_items: 'Vec', - ring_staking_lock: 'StakingLock', - kton_staking_lock: 'StakingLock', - claimed_rewards: 'Vec', + activeRing: 'Compact', + activeDepositRing: 'Compact', + activeKton: 'Compact', + depositItems: 'Vec', + ringStakingLock: 'StakingLock', + ktonStakingLock: 'StakingLock', + claimedRewards: 'Vec', total: 'Compact', active: 'Compact', unlocking: 'Vec' }, TimeDepositItem: { value: 'Compact', - start_time: 'Compact', - expire_time: 'Compact' + startTime: 'Compact', + expireTime: 'Compact' }, ExposureT: { - own_ring_balance: 'Compact', - own_kton_balance: 'Compact', - own_power: 'Power', - total_power: 'Power', + ownRingBalance: 'Compact', + ownKtonBalance: 'Compact', + ownPower: 'Power', + totalPower: 'Power', others: 'Vec' }, + Exposure: 'ExposureT', IndividualExposure: { who: 'AccountId', - ring_balance: 'Compact', - kton_balance: 'Compact', + ringBalance: 'Compact', + ktonBalance: 'Compact', power: 'Power' }, ElectionResultT: { - elected_stashes: 'Vec', + electedStashes: 'Vec', exposures: 'Vec<(AccountId, ExposureT)>', compute: 'ElectionCompute' }, @@ -100,7 +98,7 @@ export default { }, SpanRecord: { slashed: 'RKT', - paid_out: 'RKT' + paidOut: 'RKT' }, UnappliedSlash: { validator: 'AccountId', @@ -109,15 +107,18 @@ export default { reporters: 'Vec', payout: 'RKT' }, + TreasuryProposal: { proposer: 'AccountId', beneficiary: 'AccountId', - ring_value: 'Balance', - kton_value: 'Balance', - ring_bond: 'Balance', - kton_bond: 'Balance' + ringValue: 'Balance', + ktonValue: 'Balance', + ringBond: 'Balance', + ktonBond: 'Balance' }, + MappedRing: 'u128', + EthereumTransactionIndex: '(H256, u64)', EthereumBlockNumber: 'u64', EthereumHeader: { @@ -141,15 +142,19 @@ export default { Bloom: '[u8; 256; Bloom]', H128: '[u8; 16; H128]', EthashProof: { - dag_nodes: '(H512, H512)', + dagNodes: '(H512, H512)', proof: 'Vec' }, EthereumReceipt: { - gas_used: 'U256', - log_bloom: 'Bloom', + gasUsed: 'U256', + logBloom: 'Bloom', logs: 'Vec', outcome: 'TransactionOutcome' }, + + LogEntry: {}, + TransactionOutcome: {}, + EthereumNetworkType: { _enum: { Mainnet: null, @@ -165,22 +170,23 @@ export default { EthereumReceiptProof: { index: 'u64', proof: 'Bytes', - header_hash: 'H256' + headerHash: 'H256' }, EthereumReceiptProofThing: '(EthereumHeader, EthereumReceiptProof, MMRProof)', MMRProof: { - member_leaf_index: 'u64', - last_leaf_index: 'u64', + memberLeafIndex: 'u64', + lastLeafIndex: 'u64', proof: 'Vec' }, EthereumRelayHeaderParcel: { header: 'EthereumHeader', - mmr_root: 'H256' + mmrRoot: 'H256' }, EthereumRelayProofs: { - ethash_proof: 'Vec', - mmr_proof: 'Vec' + ethashProof: 'Vec', + mmrProof: 'Vec' }, + OtherSignature: { _enum: { Eth: 'EcdsaSignature', @@ -188,31 +194,37 @@ export default { } }, EcdsaSignature: '[u8; 65; EcdsaSignature]', + TronAddress: 'EthereumAddress', OtherAddress: { _enum: { - Eth: '[u8; 20; EthereumAddress]', - Tron: '[u8; 20; TronAddress]' + Eth: 'EthereumAddress', + Tron: 'TronAddress' } }, AddressT: '[u8; 20; AddressT]', + MerkleMountainRangeRootLog: { prefix: '[u8; 4; Prefix]', - mmr_root: 'Hash' + mmrRoot: 'Hash' }, - RelayHeaderId: 'u64', - RelayHeaderParcel: 'EthereumRelayHeaderParcel', - RelayProofs: 'Vec', - RelayAffirmationId: { - relay_header_id: 'Vec', - round: 'u32', - index: 'u32' + + ChainProperties: { + ss58Format: 'Option', + tokenDecimals: 'Option', + tokenSymbol: 'Option', + ktonTokenDecimals: 'Option', + ktonTokenSymbol: 'Option' }, - RelayAffirmationT: { - relayer: 'AccountId', - relay_header_parcels: 'Vec', - bond: 'Balance', - maybe_extended_relay_affirmation_id: 'Option>', - verified: 'bool' + + AccountInfo: { + nonce: 'Index', + refcount: 'RefCount', + data: 'AccountData' + }, + ProxyDefinition: { + delegate: 'AccountId', + proxyType: 'ProxyType', + delay: 'BlockNumber' }, ProxyType: { _enum: { @@ -224,10 +236,32 @@ export default { EthereumBridge: null } }, - BalancesRuntimeDispatchInfo: { - usable_balance: 'Balance' + ProxyAnnouncement: { + real: 'AccountId', + callHash: 'Hash', + height: 'BlockNumber' }, - StakingRuntimeDispatchInfo: { + Announcement: 'ProxyAnnouncement', + RelayHeaderId: 'EthereumBlockNumber', + RelayHeaderParcel: 'EthereumRelayHeaderParcel', + RelayProofs: 'EthereumRelayProofs', + RelayAffirmationId: { + relayHeaderId: 'EthereumBlockNumber', + round: 'u32', + index: 'u32' + }, + RelayAffirmationT: { + relayer: 'AccountId', + relayHeaderParcels: 'EthereumRelayHeaderParcel', + bond: 'Balance', + maybeExtendedRelayAffirmationId: 'Option', + verified: 'bool' + }, + RelayVotingState: { + ayes: 'Vec', + nays: 'Vec' + }, + PowerOf: { power: 'Power' } }; diff --git a/packages/apps-config/src/api/spec/darwinia.ts b/packages/apps-config/src/api/spec/darwinia.ts new file mode 100644 index 0000000000..b75b9caab1 --- /dev/null +++ b/packages/apps-config/src/api/spec/darwinia.ts @@ -0,0 +1,267 @@ +// Copyright 2017-2020 @polkadot/apps-config authors & contributors +// SPDX-License-Identifier: Apache-2.0 + +// structs need to be in order +/* eslint-disable sort-keys */ + +export default { + Address: 'AccountId', + LookupSource: 'AccountId', + BalanceInfo: 'Null', + BalanceLock: { + id: 'LockIdentifier', + lockFor: 'LockFor', + LockReasons: 'Reasons', + amount: 'Balance', + reasons: 'Reasons' + }, + LockFor: { + _enum: { + Common: 'Common', + Staking: 'StakingLock' + } + }, + Common: { + amount: 'Balance' + }, + StakingLock: { + stakingAmount: 'Balance', + unbondings: 'Vec' + }, + Reasons: { + _enum: ['Fee', 'Misc', 'All'] + }, + Unbonding: { + amount: 'Balance', + moment: 'BlockNumber' + }, + AccountData: { + free: 'Balance', + reserved: 'Balance', + freeKton: 'Balance', + reservedKton: 'Balance', + miscFrozen: 'Balance', + feeFrozen: 'Balance' + }, + + RingBalance: 'Balance', + KtonBalance: 'Balance', + TsInMs: 'u64', + Power: 'u32', + DepositId: 'U256', + StakingBalanceT: { + _enum: { + RingBalance: 'Balance', + KtonBalance: 'Balance' + } + }, + StakingLedgerT: { + stash: 'AccountId', + activeRing: 'Compact', + activeDepositRing: 'Compact', + activeKton: 'Compact', + depositItems: 'Vec', + ringStakingLock: 'StakingLock', + ktonStakingLock: 'StakingLock', + claimedRewards: 'Vec', + total: 'Compact', + active: 'Compact', + unlocking: 'Vec' + }, + TimeDepositItem: { + value: 'Compact', + startTime: 'Compact', + expireTime: 'Compact' + }, + ExposureT: { + ownRingBalance: 'Compact', + ownKtonBalance: 'Compact', + ownPower: 'Power', + totalPower: 'Power', + others: 'Vec' + }, + Exposure: 'ExposureT', + IndividualExposure: { + who: 'AccountId', + ringBalance: 'Compact', + ktonBalance: 'Compact', + power: 'Power' + }, + ElectionResultT: { + electedStashes: 'Vec', + exposures: 'Vec<(AccountId, ExposureT)>', + compute: 'ElectionCompute' + }, + RKT: { + r: 'Balance', + k: 'Balance' + }, + SpanRecord: { + slashed: 'RKT', + paidOut: 'RKT' + }, + UnappliedSlash: { + validator: 'AccountId', + own: 'RKT', + others: 'Vec<(AccountId, RKT)>', + reporters: 'Vec', + payout: 'RKT' + }, + + TreasuryProposal: { + proposer: 'AccountId', + beneficiary: 'AccountId', + ringValue: 'Balance', + ktonValue: 'Balance', + ringBond: 'Balance', + ktonBond: 'Balance' + }, + + MappedRing: 'u128', + + EthereumTransactionIndex: '(H256, u64)', + EthereumBlockNumber: 'u64', + EthereumHeader: { + parent_hash: 'H256', + timestamp: 'u64', + number: 'EthereumBlockNumber', + author: 'EthereumAddress', + transactions_root: 'H256', + uncles_hash: 'H256', + extra_data: 'Bytes', + state_root: 'H256', + receipts_root: 'H256', + log_bloom: 'Bloom', + gas_used: 'U256', + gas_limit: 'U256', + difficulty: 'U256', + seal: 'Vec', + hash: 'Option' + }, + EthereumAddress: 'H160', + Bloom: '[u8; 256; Bloom]', + H128: '[u8; 16; H128]', + EthashProof: { + dagNodes: '(H512, H512)', + proof: 'Vec' + }, + EthereumReceipt: { + gasUsed: 'U256', + logBloom: 'Bloom', + logs: 'Vec', + outcome: 'TransactionOutcome' + }, + + LogEntry: {}, + TransactionOutcome: {}, + + EthereumNetworkType: { + _enum: { + Mainnet: null, + Ropsten: null + } + }, + RedeemFor: { + _enum: { + Token: null, + Deposit: null + } + }, + EthereumReceiptProof: { + index: 'u64', + proof: 'Bytes', + headerHash: 'H256' + }, + EthereumReceiptProofThing: '(EthereumHeader, EthereumReceiptProof, MMRProof)', + MMRProof: { + memberLeafIndex: 'u64', + lastLeafIndex: 'u64', + proof: 'Vec' + }, + EthereumRelayHeaderParcel: { + header: 'EthereumHeader', + mmrRoot: 'H256' + }, + EthereumRelayProofs: { + ethashProof: 'Vec', + mmrProof: 'Vec' + }, + + OtherSignature: { + _enum: { + Eth: 'EcdsaSignature', + Tron: 'EcdsaSignature' + } + }, + EcdsaSignature: '[u8; 65; EcdsaSignature]', + TronAddress: 'EthereumAddress', + OtherAddress: { + _enum: { + Eth: 'EthereumAddress', + Tron: 'TronAddress' + } + }, + AddressT: '[u8; 20; AddressT]', + + MerkleMountainRangeRootLog: { + prefix: '[u8; 4; Prefix]', + mmrRoot: 'Hash' + }, + + ChainProperties: { + ss58Format: 'Option', + tokenDecimals: 'Option', + tokenSymbol: 'Option', + ktonTokenDecimals: 'Option', + ktonTokenSymbol: 'Option' + }, + + AccountInfo: { + nonce: 'Index', + refcount: 'RefCount', + data: 'AccountData' + }, + ProxyDefinition: { + delegate: 'AccountId', + proxyType: 'ProxyType', + delay: 'BlockNumber' + }, + ProxyType: { + _enum: { + Any: null, + NonTransfer: null, + Governance: null, + Staking: null, + IdentityJudgement: null, + EthereumBridge: null + } + }, + ProxyAnnouncement: { + real: 'AccountId', + callHash: 'Hash', + height: 'BlockNumber' + }, + Announcement: 'ProxyAnnouncement', + RelayHeaderId: 'EthereumBlockNumber', + RelayHeaderParcel: 'EthereumRelayHeaderParcel', + RelayProofs: 'EthereumRelayProofs', + RelayAffirmationId: { + relayHeaderId: 'EthereumBlockNumber', + round: 'u32', + index: 'u32' + }, + RelayAffirmationT: { + relayer: 'AccountId', + relayHeaderParcels: 'EthereumRelayHeaderParcel', + bond: 'Balance', + maybeExtendedRelayAffirmationId: 'Option', + verified: 'bool' + }, + RelayVotingState: { + ayes: 'Vec', + nays: 'Vec' + }, + PowerOf: { + power: 'Power' + } +}; diff --git a/packages/apps-config/src/api/spec/index.ts b/packages/apps-config/src/api/spec/index.ts index 97d692f62c..ccd72f7e6d 100644 --- a/packages/apps-config/src/api/spec/index.ts +++ b/packages/apps-config/src/api/spec/index.ts @@ -6,6 +6,7 @@ import canvas from './canvas'; import centrifugeChain from './centrifuge-chain'; import crab from './crab'; import crust from './crust'; +import darwinia from './darwinia'; import darwiniaParachain from './darwinia-parachain'; import dock from './dock'; import testPara from './cumulus-test-parachain'; @@ -27,6 +28,7 @@ import subsocial from './subsocial'; // mapping from specName in state.getRuntimeVersion export default { Crab: crab, + Darwinia: darwinia, Equilibrium: equilibrium, bifrost: bifrost, canvas, diff --git a/packages/apps-config/src/settings/endpoints.ts b/packages/apps-config/src/settings/endpoints.ts index ab609f74d2..6ab8ee07d5 100644 --- a/packages/apps-config/src/settings/endpoints.ts +++ b/packages/apps-config/src/settings/endpoints.ts @@ -109,6 +109,12 @@ function createLiveNetworks (t: TFunction): LinkOption[] { textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Darwinia Network' } }), value: 'wss://crab.darwinia.network' }, + { + info: 'darwinia', + text: t('rpc.darwinia', 'Darwinia', { ns: 'apps-config' }), + textBy: t('rpc.hosted.by', 'hosted by {{host}}', { ns: 'apps-config', replace: { host: 'Darwinia Network' } }), + value: 'wss://cc1.darwinia.network' + }, { info: 'dock-mainnet', text: t('rpc.dock-mainnet', 'Dock Mainnet', { ns: 'apps-config' }), diff --git a/packages/apps-config/src/ui/colors.ts b/packages/apps-config/src/ui/colors.ts index a5418666ef..8bdecf370e 100644 --- a/packages/apps-config/src/ui/colors.ts +++ b/packages/apps-config/src/ui/colors.ts @@ -8,6 +8,7 @@ const emptyColor = '#99999'; // alphabetical const chainCrab = '#7C30DD'; const chainCrust = '#ff8812'; +const chainDarwinia = 'linear-gradient(-45deg, #FE3876 0%, #7C30DD 71%, #3A30DD 100%)'; const chainHanonycash = '#0099CC'; const chainKulupu = '#003366'; const chainPhala = '#4dc56a'; @@ -39,8 +40,9 @@ const nodeSubsocial = '#b9018c'; // alphabetical const chainColors: Record = [ ['acala mandala pc1', chainRoccoAcala], - ['Crab', chainCrab], + ['Darwinia Crab', chainCrab], ['crust maxwell cc2', chainCrust], + ['darwinia cc1', chainDarwinia], ['darwinia parachain', chainRoccoDarwinia], ['hanonycash', chainHanonycash], ['Kulupu', chainKulupu], diff --git a/packages/apps-config/src/ui/logos/index.ts b/packages/apps-config/src/ui/logos/index.ts index d0a6e05d65..ddce1acc83 100644 --- a/packages/apps-config/src/ui/logos/index.ts +++ b/packages/apps-config/src/ui/logos/index.ts @@ -60,6 +60,7 @@ import emptyLogo from './empty.svg'; // NOTE: this matches up with RPC system.chain // alphabetical const chainLogos: Record = [ + ['darwinia crab', nodeCrab], ['Dusty', chainDusty], ['Kusama', chainKusama], // new name after CC3 ['Kusama CC1', chainKusama], @@ -84,8 +85,9 @@ const nodeLogos: Record = [ ['Canvas Node', nodeCanvas], ['centrifuge chain', nodeCentrifuge], ['Centrifuge Chain Node', nodeCentrifuge], - ['crab', nodeCrab], + ['darwinia crab', nodeCrab], ['crust node', nodeCrust], + ['darwinia', nodeDarwinia], ['darwinia parachain', nodeDarwinia], ['Dock Full Node', nodeDockMainnet], ['Edgeware Node', nodeEdgeware], @@ -124,6 +126,7 @@ const namedLogos: Record = { centrifuge: nodeCentrifuge, crab: nodeCrab, crust: nodeCrust, + darwinia: nodeDarwinia, 'dock-mainnet': nodeDockMainnet, 'dock-testnet': nodeDockTestnet, dusty: chainDusty, diff --git a/packages/apps-config/src/ui/logos/nodes/darwinia.svg b/packages/apps-config/src/ui/logos/nodes/darwinia.svg new file mode 100644 index 0000000000..99ff6fb476 --- /dev/null +++ b/packages/apps-config/src/ui/logos/nodes/darwinia.svg @@ -0,0 +1,18 @@ + + + + 编组 + + + + + + + + + + + + + + diff --git a/packages/apps/public/locales/en/apps-config.json b/packages/apps/public/locales/en/apps-config.json index fc86a427c1..1a02ebc1a6 100644 --- a/packages/apps/public/locales/en/apps-config.json +++ b/packages/apps/public/locales/en/apps-config.json @@ -10,6 +10,7 @@ "rpc.crust.network": "Crust Maxwell CC2", "rpc.custom": "Custom environment", "rpc.custom.entry": "Custom", + "rpc.darwinia": "Darwinia", "rpc.datahighway.harbour": "Harbour", "rpc.dock-mainnet": "Dock Mainnet", "rpc.dock-testnet": "Dock Testnet",