From bdec80b4c66322596fafa0aa7e88ef5fc03295d4 Mon Sep 17 00:00:00 2001 From: WoeOm <1015996366@qq.com> Date: Sat, 20 Feb 2021 16:00:15 +0800 Subject: [PATCH] import type from @darwinia/types (#4701) --- packages/apps-config/package.json | 1 + packages/apps-config/src/api/spec/crab.ts | 282 +----------------- packages/apps-config/src/api/spec/darwinia.ts | 268 +---------------- yarn.lock | 33 +- 4 files changed, 37 insertions(+), 547 deletions(-) diff --git a/packages/apps-config/package.json b/packages/apps-config/package.json index 9390f966c7..5237337703 100644 --- a/packages/apps-config/package.json +++ b/packages/apps-config/package.json @@ -11,6 +11,7 @@ "dependencies": { "@acala-network/type-definitions": "^0.6.2-12", "@babel/runtime": "^7.12.5", + "@darwinia/types": "^1.1.0-alpha.1", "@edgeware/node-types": "^3.3.1", "@interlay/polkabtc-types": "^0.3.4", "@laminar/type-definitions": "^0.2.0-beta.143", diff --git a/packages/apps-config/src/api/spec/crab.ts b/packages/apps-config/src/api/spec/crab.ts index 5877fba2f5..aacb8470ca 100644 --- a/packages/apps-config/src/api/spec/crab.ts +++ b/packages/apps-config/src/api/spec/crab.ts @@ -3,284 +3,6 @@ import type { OverrideBundleDefinition } from '@polkadot/types/types'; -// structs need to be in order -/* eslint-disable sort-keys */ +import { typesBundleForPolkadot } from '@darwinia/types/mix'; -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - 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', - value: 'Compact' - }, - 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]', - ParentMmrRoot: 'Hash' - }, - - 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' - }, - Signer: 'EthereumAddress', - RelayAuthorityT: { - accountId: 'AccountId', - signer: 'Signer', - stake: 'Balance', - term: 'BlockNumber' - }, - MMRRoot: 'Hash', - EcdsaAddress: 'EthereumAddress', - EcdsaMessage: 'H256', - RelayAuthoritySigner: 'EcdsaAddress', - RelayAuthorityMessage: 'EcdsaMessage', - RelayAuthoritySignature: 'EcdsaSignature', - Term: 'u32' - } - } - ] -}; - -export default definitions; +export default typesBundleForPolkadot.spec.crab as unknown as OverrideBundleDefinition; diff --git a/packages/apps-config/src/api/spec/darwinia.ts b/packages/apps-config/src/api/spec/darwinia.ts index a42fbae809..cf1bcae5fa 100644 --- a/packages/apps-config/src/api/spec/darwinia.ts +++ b/packages/apps-config/src/api/spec/darwinia.ts @@ -3,270 +3,6 @@ import type { OverrideBundleDefinition } from '@polkadot/types/types'; -// structs need to be in order -/* eslint-disable sort-keys */ +import { typesBundleForPolkadot } from '@darwinia/types/mix'; -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - 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', - value: 'Compact' - }, - 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' - }, - - 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' - } - } - } - ] -}; - -export default definitions; +export default typesBundleForPolkadot.spec.darwinia as unknown as OverrideBundleDefinition; diff --git a/yarn.lock b/yarn.lock index 32b68bed35..3d85e45d53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1304,6 +1304,15 @@ __metadata: languageName: node linkType: hard +"@babel/runtime@npm:^7.9.6": + version: 7.12.18 + resolution: "@babel/runtime@npm:7.12.18" + dependencies: + regenerator-runtime: ^0.13.4 + checksum: cb9e0c51b8e6e294ed5f52992d3fac13eb33b346760ef8eb0b3cb7542bb7c88c0297e2d878082255f91677e81e9cfcb00c38b3e55771a1ad9451647c6dd6a974 + languageName: node + linkType: hard + "@babel/template@npm:^7.12.13, @babel/template@npm:^7.3.3": version: 7.12.13 resolution: "@babel/template@npm:7.12.13" @@ -1362,6 +1371,27 @@ __metadata: languageName: node linkType: hard +"@darwinia/types-known@npm:^1.1.0-alpha.1": + version: 1.1.0-alpha.1 + resolution: "@darwinia/types-known@npm:1.1.0-alpha.1" + dependencies: + "@babel/runtime": ^7.9.6 + "@polkadot/types": 3.6.4 + "@polkadot/util": ^3.0.1 + bn.js: ^5.1.2 + checksum: 501067fe1ebece4505eb6b0fa8ea08773e757ade51a8f55bd37a5a72476e24f653f34c444b50b63f1fd793f9dbfc15664841ff5eedb67c8bb4a9fc5be91a32fb + languageName: node + linkType: hard + +"@darwinia/types@npm:^1.1.0-alpha.1": + version: 1.1.0-alpha.1 + resolution: "@darwinia/types@npm:1.1.0-alpha.1" + dependencies: + "@darwinia/types-known": ^1.1.0-alpha.1 + checksum: df8ac2ffbc7eba7c39995d8b71b4d2ef4762f2e844411f5950b370b4aa83a047a494c2e10f9f1188bcca17be180822096e2db550616dee63c8f3e1c2d3fc31e8 + languageName: node + linkType: hard + "@develar/schema-utils@npm:~2.6.5": version: 2.6.5 resolution: "@develar/schema-utils@npm:2.6.5" @@ -2326,6 +2356,7 @@ __metadata: dependencies: "@acala-network/type-definitions": ^0.6.2-12 "@babel/runtime": ^7.12.5 + "@darwinia/types": ^1.1.0-alpha.1 "@edgeware/node-types": ^3.3.1 "@interlay/polkabtc-types": ^0.3.4 "@laminar/type-definitions": ^0.2.0-beta.143 @@ -5246,7 +5277,7 @@ __metadata: languageName: node linkType: hard -"bn.js@npm:^5.0.0, bn.js@npm:^5.1.1": +"bn.js@npm:^5.0.0, bn.js@npm:^5.1.1, bn.js@npm:^5.1.2": version: 5.1.3 resolution: "bn.js@npm:5.1.3" checksum: 991c1fefb03bd69315297d454b379d5a5dd4834ab97db3ec985714f00ff7d3cc19642e1ac6bdf0d9f04946cc9f1ad26a5b497b7f4e7fa1230caf68af46fbefe6