From 5a4530cf10e97eeeb26111bd086df9effbe214c2 Mon Sep 17 00:00:00 2001 From: pan Date: Wed, 21 Jul 2021 21:35:24 +0800 Subject: [PATCH] update Bifrost types (#5852) * update Bifrost types * Update packages/apps-config/package.json Co-authored-by: Jaco * Update yarn.lock Co-authored-by: Jaco * Update yarn.lock Co-authored-by: Jaco Co-authored-by: Jaco --- packages/apps-config/package.json | 1 + .../src/api/spec/bifrost-asgard.ts | 108 +----------- .../src/api/spec/bifrost-parachain.ts | 108 +----------- packages/apps-config/src/api/spec/bifrost.ts | 163 +----------------- yarn.lock | 10 ++ 5 files changed, 17 insertions(+), 373 deletions(-) diff --git a/packages/apps-config/package.json b/packages/apps-config/package.json index 8f01e4db00..b2b634d49a 100644 --- a/packages/apps-config/package.json +++ b/packages/apps-config/package.json @@ -9,6 +9,7 @@ "dependencies": { "@acala-network/type-definitions": "1.0.2-2", "@babel/runtime": "^7.14.6", + "@bifrost-finance/type-definitions": "1.1.59", "@crustio/type-definitions": "0.0.10", "@darwinia/types": "1.1.5", "@digitalnative/type-definitions": "1.1.9", diff --git a/packages/apps-config/src/api/spec/bifrost-asgard.ts b/packages/apps-config/src/api/spec/bifrost-asgard.ts index 57aaf61ab6..fb9e7662c7 100644 --- a/packages/apps-config/src/api/spec/bifrost-asgard.ts +++ b/packages/apps-config/src/api/spec/bifrost-asgard.ts @@ -1,110 +1,6 @@ // Copyright 2017-2021 @polkadot/apps-config authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { OverrideBundleDefinition } from '@polkadot/types/types'; +import { typesBundleForPolkadot } from '@bifrost-finance/type-definitions'; -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - TokenSymbol: { - _enum: { - ASG: 0, - aUSD: 2, - DOT: 3, - KSM: 4, - ETH: 5 - } - }, - CurrencyId: { - _enum: { - Token: 'TokenSymbol', - VToken: 'TokenSymbol', - Native: 'TokenSymbol', - Stable: 'TokenSymbol', - VSToken: 'TokenSymbol', - VSBond: '(TokenSymbol, ParaId, LeasePeriod, LeasePeriod)' - } - }, - CurrencyIdOf: 'CurrencyId', - TAssetBalance: 'Balance', - AmountOf: 'i128', - StorageVersion: 'Releases', - ShareWeight: 'Balance', - OrmlAccountData: { - free: 'Balance', - reserved: 'Balance', - frozen: 'Balance' - }, - BancorPool: { - currency_id: 'CurrencyId', - token_pool: 'Balance', - vstoken_pool: 'Balance', - token_base_supply: 'Balance', - vstoken_base_supply: 'Balance' - }, - PalletBalanceOf: 'Balance', - BlockNumberFor: 'BlockNumber', - NumberOrHex: { - _enum: { - Number: 'u64', - Hex: 'U256' - } - }, - IsExtended: 'bool', - SystemPalletId: 'PalletId', - RewardRecord: { - account_id: 'AccountId', - record_amount: 'Balance' - }, - MaxLocksOf: 'u32', - VestingInfo: { - locked: 'Balance', - per_block: 'Balance', - starting_block: 'BlockNumber' - }, - OrderId: 'u64', - OrderInfo: { - owner: 'AccountIdOf', - currency_sold: 'CurrencyIdOf', - amount_sold: 'BalanceOf', - currency_expected: 'CurrencyIdOf', - amount_expected: 'BalanceOf', - order_id: 'OrderId', - order_state: 'OrderState' - }, - OrderState: { - _enum: [ - 'InTrade', - 'Revoked', - 'Clinchd' - ] - }, - ZenlinkAssetId: { - chain_id: 'u32', - asset_type: 'u8', - asset_index: 'u32' - }, - ZenlinkAssetBalance: 'u128', - PairInfo: { - asset0: 'ZenlinkAssetId', - asset1: 'ZenlinkAssetId', - account: 'AccountId', - totalLiquidity: 'ZenlinkAssetBalance', - holdingLiquidity: 'ZenlinkAssetBalance', - reserve0: 'ZenlinkAssetBalance', - reserve1: 'ZenlinkAssetBalance', - lpAssetId: 'ZenlinkAssetId' - } - } - - } - ] -}; - -export default definitions; +export default typesBundleForPolkadot.spec.bifrost; diff --git a/packages/apps-config/src/api/spec/bifrost-parachain.ts b/packages/apps-config/src/api/spec/bifrost-parachain.ts index 57aaf61ab6..fb9e7662c7 100644 --- a/packages/apps-config/src/api/spec/bifrost-parachain.ts +++ b/packages/apps-config/src/api/spec/bifrost-parachain.ts @@ -1,110 +1,6 @@ // Copyright 2017-2021 @polkadot/apps-config authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { OverrideBundleDefinition } from '@polkadot/types/types'; +import { typesBundleForPolkadot } from '@bifrost-finance/type-definitions'; -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - TokenSymbol: { - _enum: { - ASG: 0, - aUSD: 2, - DOT: 3, - KSM: 4, - ETH: 5 - } - }, - CurrencyId: { - _enum: { - Token: 'TokenSymbol', - VToken: 'TokenSymbol', - Native: 'TokenSymbol', - Stable: 'TokenSymbol', - VSToken: 'TokenSymbol', - VSBond: '(TokenSymbol, ParaId, LeasePeriod, LeasePeriod)' - } - }, - CurrencyIdOf: 'CurrencyId', - TAssetBalance: 'Balance', - AmountOf: 'i128', - StorageVersion: 'Releases', - ShareWeight: 'Balance', - OrmlAccountData: { - free: 'Balance', - reserved: 'Balance', - frozen: 'Balance' - }, - BancorPool: { - currency_id: 'CurrencyId', - token_pool: 'Balance', - vstoken_pool: 'Balance', - token_base_supply: 'Balance', - vstoken_base_supply: 'Balance' - }, - PalletBalanceOf: 'Balance', - BlockNumberFor: 'BlockNumber', - NumberOrHex: { - _enum: { - Number: 'u64', - Hex: 'U256' - } - }, - IsExtended: 'bool', - SystemPalletId: 'PalletId', - RewardRecord: { - account_id: 'AccountId', - record_amount: 'Balance' - }, - MaxLocksOf: 'u32', - VestingInfo: { - locked: 'Balance', - per_block: 'Balance', - starting_block: 'BlockNumber' - }, - OrderId: 'u64', - OrderInfo: { - owner: 'AccountIdOf', - currency_sold: 'CurrencyIdOf', - amount_sold: 'BalanceOf', - currency_expected: 'CurrencyIdOf', - amount_expected: 'BalanceOf', - order_id: 'OrderId', - order_state: 'OrderState' - }, - OrderState: { - _enum: [ - 'InTrade', - 'Revoked', - 'Clinchd' - ] - }, - ZenlinkAssetId: { - chain_id: 'u32', - asset_type: 'u8', - asset_index: 'u32' - }, - ZenlinkAssetBalance: 'u128', - PairInfo: { - asset0: 'ZenlinkAssetId', - asset1: 'ZenlinkAssetId', - account: 'AccountId', - totalLiquidity: 'ZenlinkAssetBalance', - holdingLiquidity: 'ZenlinkAssetBalance', - reserve0: 'ZenlinkAssetBalance', - reserve1: 'ZenlinkAssetBalance', - lpAssetId: 'ZenlinkAssetId' - } - } - - } - ] -}; - -export default definitions; +export default typesBundleForPolkadot.spec.bifrost; diff --git a/packages/apps-config/src/api/spec/bifrost.ts b/packages/apps-config/src/api/spec/bifrost.ts index b463ec1e86..fb9e7662c7 100644 --- a/packages/apps-config/src/api/spec/bifrost.ts +++ b/packages/apps-config/src/api/spec/bifrost.ts @@ -1,165 +1,6 @@ // Copyright 2017-2021 @polkadot/apps-config authors & contributors // SPDX-License-Identifier: Apache-2.0 -import type { OverrideBundleDefinition } from '@polkadot/types/types'; +import { typesBundleForPolkadot } from '@bifrost-finance/type-definitions'; -// structs need to be in order -/* eslint-disable sort-keys */ - -const definitions: OverrideBundleDefinition = { - types: [ - { - // on all versions - minmax: [0, undefined], - types: { - Token: { symbol: 'Vec', precision: 'u16', totalSupply: 'u128' }, - VersionId: 'u32', - Action: { - account: 'AccountName', - name: 'ActionName', - authorization: 'Vec', - data: 'Vec' - }, - IostAction: { contract: 'Vec', action_name: 'Vec', data: 'Vec' }, - PermissionLevel: { actor: 'AccountName', permission: 'PermissionName' }, - PermissionName: 'u64', - ActionReceipt: { - receiver: 'AccountName', - act_digest: 'Checksum256', - global_sequence: 'u64', - recv_sequence: 'u64', - auth_sequence: 'FlatMap', - code_sequence: 'UnsignedInt', - abi_sequence: 'UnsignedInt' - }, - Checksum256: '([u8;32])', - BlockchainType: { _enum: ['BIFROST', 'EOS', 'IOST'] }, - Precision: 'u32', - BridgeAssetSymbol: { - blockchain: 'BlockchainType', - symbol: 'Vec', - precision: 'Precision' - }, - ProducerSchedule: { version: 'u32', producers: 'Vec' }, - ProducerKey: { producer_name: 'AccountName', block_signing_key: 'PublicKey' }, - AccountName: 'u64', - ActionName: 'u64', - PublicKey: { type_: 'UnsignedInt', data: '[u8;33]' }, - UnsignedInt: 'u32', - Signature: { type_: 'UnsignedInt', data: '[u8;65]' }, - SignedBlockHeader: { block_header: 'BlockHeader', producer_signature: 'Signature' }, - BlockHeader: { - timestamp: 'BlockTimestamp', - producer: 'AccountName', - confirmed: 'u16', - previous: 'Checksum256', - transaction_mroot: 'Checksum256', - action_mroot: 'Checksum256', - schedule_version: 'u32', - new_producers: 'Option', - header_extensions: 'Vec' - }, - BlockTimestamp: '(u32)', - Extension: '(u16, Vec)', - IncrementalMerkle: { _node_count: 'u64', _active_nodes: 'Checksum256Array' }, - Checksum256Array: 'Vec', - FlatMap: { map: 'Vec<(ActionName, u64)>' }, - TxSig: { signature: 'Vec', author: 'AccountId' }, - MultiSig: { signatures: 'Vec', threshold: 'u8' }, - MultiSigTx: { - chain_id: 'Vec', - raw_tx: 'Vec', - multi_sig: 'MultiSig', - action: 'Action', - from: 'AccountId', - token_symbol: 'TokenSymbol' - }, - Sent: { tx_id: 'Vec', from: 'AccountId', token_symbol: 'TokenSymbol' }, - Succeeded: { tx_id: 'Vec' }, - Failed: { tx_id: 'Vec', reason: 'Vec' }, - TxOut: { - _enum: { - Initialized: 'MultiSigTx', - Created: 'MultiSigTx', - SignComplete: 'MultiSigTx', - Sent: 'Sent', - Succeeded: 'Succeeded', - Failed: 'Failed' - } - }, - RewardRecord: { account_id: 'AccountId', record_amount: 'Balance' }, - ConvertPrice: 'u128', - RatePerBlock: 'u64', - Fee: 'u64', - PoolId: 'u32', - Nonce: 'u32', - PoolDetails: { owner: 'AccountId', swap_fee_rate: 'Fee', active: 'bool' }, - PoolCreateTokenDetails: { - token_id: 'TokenSymbol', - token_balance: 'Balance', - token_weight: 'PoolWeight' - }, - TokenPool: 'Balance', - VTokenPool: 'Balance', - InVariantPool: 'Balance', - TokenSymbol: { - _enum: [ - 'aUSD', 'DOT', - 'vDOT', 'KSM', - 'vKSM', 'EOS', - 'vEOS', 'IOST', - 'vIOST' - ] - }, - TransactionStatus: { - _enum: [ - 'Initialized', - 'Created', - 'SignComplete', - 'Sent', - 'Succeeded', - 'Failed' - ] - }, - Cost: 'u128', - Income: 'u128', - Price: 'u64', - AccountAsset: { - balance: 'Balance', - locked: 'Balance', - available: 'Balance', - cost: 'Cost', - income: 'Income' - }, - SpecIndex: 'u32', - RequestIdentifier: 'u64', - DataVersion: 'u64', - ConvertPool: { - token_pool: 'Balance', - vtoken_pool: 'Balance', - current_reward: 'Balance', - pending_reward: 'Balance' - }, - ProducerAuthoritySchedule: { version: 'u32', producers: 'Vec' }, - ProducerAuthority: { producer_name: 'ActionName', authority: 'BlockSigningAuthority' }, - BlockSigningAuthority: '(UnsignedInt, BlockSigningAuthorityV0)', - BlockSigningAuthorityV0: { threshold: 'u32', keys: 'Vec' }, - KeyWeight: { key: 'PublicKey', weight: 'u16' }, - InvariantValue: 'Balance', - PoolWeight: 'Balance', - AssetConfig: { redeem_duration: 'BlockNumber', min_reward_per_block: 'Balance' }, - ProxyValidatorRegister: { - last_block: 'BlockNumber', - deposit: 'Balance', - need: 'Balance', - staking: 'Balance', - reward_per_block: 'Balance', - validator_address: 'Vec' - }, - BlockNumber: 'u32' - } - } - ] -}; - -export default definitions; +export default typesBundleForPolkadot.spec.bifrost; diff --git a/yarn.lock b/yarn.lock index 97145e4cbf..7c6b6acbad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1450,6 +1450,15 @@ __metadata: languageName: node linkType: hard +"@bifrost-finance/type-definitions@npm:1.1.59": + version: 1.1.59 + resolution: "@bifrost-finance/type-definitions@npm:1.1.59" + dependencies: + "@open-web3/orml-type-definitions": ^0.9.4-7 + checksum: cb7632eb26c2611fbf5b004ad325588105e707ec3bb3b2da73d89a46655748bc2122a1d9aed4047a863a892e51fcde27feb62a27d23ba620a077b7aee559101f + languageName: node + linkType: hard + "@crustio/crust-pin@npm:^0.0.1": version: 0.0.1 resolution: "@crustio/crust-pin@npm:0.0.1" @@ -2566,6 +2575,7 @@ __metadata: dependencies: "@acala-network/type-definitions": 1.0.2-2 "@babel/runtime": ^7.14.6 + "@bifrost-finance/type-definitions": 1.1.59 "@crustio/type-definitions": 0.0.10 "@darwinia/types": 1.1.5 "@digitalnative/type-definitions": 1.1.9