Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert all specs to type bundles #4646

Merged
merged 9 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/apps-config/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Copyright 2017-2021 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { OverrideBundleType } from '@polkadot/types/types';

import typesChain from './chain';
import typesSpec from './spec';
import specVersioned from './specVersioned';
import spec from './spec';

export * from './constants';
export * from './params';

export function getChainTypes (specName: string, chainName: string): Record<string, string | Record<string, unknown>> {
export function getChainTypes (_specName: string, chainName: string): Record<string, string | Record<string, unknown>> {
return {
...(typesSpec[specName as keyof typeof typesSpec] || {}),
...(typesChain[chainName as keyof typeof typesChain] || {})
};
}

export const typesBundle = { spec: specVersioned };
export const typesBundle: OverrideBundleType = { spec };

export { typesChain, typesSpec };
export { typesChain };
18 changes: 15 additions & 3 deletions packages/apps-config/src/api/spec/ares-parachain.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
// Copyright 2017-2021 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { OverrideBundleDefinition } from '@polkadot/types/types';

// structs need to be in order
/* eslint-disable sort-keys */

export default {
Address: 'AccountId',
LookupSource: 'AccountId'
const definitions: OverrideBundleDefinition = {
types: [
{
// on all versions
minmax: [0, undefined],
types: {
Address: 'AccountId',
LookupSource: 'AccountId'
}
}
]
};

export default definitions;
304 changes: 159 additions & 145 deletions packages/apps-config/src/api/spec/bifrost.ts
Original file line number Diff line number Diff line change
@@ -1,151 +1,165 @@
// Copyright 2017-2021 @polkadot/apps-config authors & contributors
// SPDX-License-Identifier: Apache-2.0

import type { OverrideBundleDefinition } from '@polkadot/types/types';

// structs need to be in order
/* eslint-disable sort-keys */
export default {
Token: { symbol: 'Vec<u8>', precision: 'u16', totalSupply: 'u128' },
VersionId: 'u32',
Action: {
account: 'AccountName',
name: 'ActionName',
authorization: 'Vec<PermissionLevel>',
data: 'Vec<u8>'
},
IostAction: { contract: 'Vec<u8>', action_name: 'Vec<u8>', data: 'Vec<u8>' },
PermissionLevel: { actor: 'AccountName', permission: 'PermissionName' },
PermissionName: 'u64',
ActionReceipt: {
receiver: 'AccountName',
act_digest: 'Checksum256',
global_sequence: 'u64',
recv_sequence: 'u64',
auth_sequence: 'FlatMap<AccountName, u64>',
code_sequence: 'UnsignedInt',
abi_sequence: 'UnsignedInt'
},
Checksum256: '([u8;32])',
BlockchainType: { _enum: ['BIFROST', 'EOS', 'IOST'] },
Precision: 'u32',
BridgeAssetSymbol: {
blockchain: 'BlockchainType',
symbol: 'Vec<u8>',
precision: 'Precision'
},
ProducerSchedule: { version: 'u32', producers: 'Vec<ProducerKey>' },
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<ProducerSchedule>',
header_extensions: 'Vec<Extension>'
},
BlockTimestamp: '(u32)',
Extension: '(u16, Vec<u8>)',
IncrementalMerkle: { _node_count: 'u64', _active_nodes: 'Checksum256Array' },
Checksum256Array: 'Vec<Checksum256>',
FlatMap: { map: 'Vec<(ActionName, u64)>' },
TxSig: { signature: 'Vec<u8>', author: 'AccountId' },
MultiSig: { signatures: 'Vec<TxSig>', threshold: 'u8' },
MultiSigTx: {
chain_id: 'Vec<u8>',
raw_tx: 'Vec<u8>',
multi_sig: 'MultiSig',
action: 'Action',
from: 'AccountId',
token_symbol: 'TokenSymbol'
},
Sent: { tx_id: 'Vec<u8>', from: 'AccountId', token_symbol: 'TokenSymbol' },
Succeeded: { tx_id: 'Vec<u8>' },
Failed: { tx_id: 'Vec<u8>', reason: 'Vec<u8>' },
TxOut: {
_enum: {
Initialized: 'MultiSigTx',
Created: 'MultiSigTx',
SignComplete: 'MultiSigTx',
Sent: 'Sent',
Succeeded: 'Succeeded',
Failed: 'Failed'

const definitions: OverrideBundleDefinition = {
types: [
{
// on all versions
minmax: [0, undefined],
types: {
Token: { symbol: 'Vec<u8>', precision: 'u16', totalSupply: 'u128' },
VersionId: 'u32',
Action: {
account: 'AccountName',
name: 'ActionName',
authorization: 'Vec<PermissionLevel>',
data: 'Vec<u8>'
},
IostAction: { contract: 'Vec<u8>', action_name: 'Vec<u8>', data: 'Vec<u8>' },
PermissionLevel: { actor: 'AccountName', permission: 'PermissionName' },
PermissionName: 'u64',
ActionReceipt: {
receiver: 'AccountName',
act_digest: 'Checksum256',
global_sequence: 'u64',
recv_sequence: 'u64',
auth_sequence: 'FlatMap<AccountName, u64>',
code_sequence: 'UnsignedInt',
abi_sequence: 'UnsignedInt'
},
Checksum256: '([u8;32])',
BlockchainType: { _enum: ['BIFROST', 'EOS', 'IOST'] },
Precision: 'u32',
BridgeAssetSymbol: {
blockchain: 'BlockchainType',
symbol: 'Vec<u8>',
precision: 'Precision'
},
ProducerSchedule: { version: 'u32', producers: 'Vec<ProducerKey>' },
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<ProducerSchedule>',
header_extensions: 'Vec<Extension>'
},
BlockTimestamp: '(u32)',
Extension: '(u16, Vec<u8>)',
IncrementalMerkle: { _node_count: 'u64', _active_nodes: 'Checksum256Array' },
Checksum256Array: 'Vec<Checksum256>',
FlatMap: { map: 'Vec<(ActionName, u64)>' },
TxSig: { signature: 'Vec<u8>', author: 'AccountId' },
MultiSig: { signatures: 'Vec<TxSig>', threshold: 'u8' },
MultiSigTx: {
chain_id: 'Vec<u8>',
raw_tx: 'Vec<u8>',
multi_sig: 'MultiSig',
action: 'Action',
from: 'AccountId',
token_symbol: 'TokenSymbol'
},
Sent: { tx_id: 'Vec<u8>', from: 'AccountId', token_symbol: 'TokenSymbol' },
Succeeded: { tx_id: 'Vec<u8>' },
Failed: { tx_id: 'Vec<u8>', reason: 'Vec<u8>' },
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>' },
ProducerAuthority: { producer_name: 'ActionName', authority: 'BlockSigningAuthority' },
BlockSigningAuthority: '(UnsignedInt, BlockSigningAuthorityV0)',
BlockSigningAuthorityV0: { threshold: 'u32', keys: 'Vec<KeyWeight>' },
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<u8>'
},
BlockNumber: 'u32'
}
}
},
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>' },
ProducerAuthority: { producer_name: 'ActionName', authority: 'BlockSigningAuthority' },
BlockSigningAuthority: '(UnsignedInt, BlockSigningAuthorityV0)',
BlockSigningAuthorityV0: { threshold: 'u32', keys: 'Vec<KeyWeight>' },
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<u8>'
},
BlockNumber: 'u32'
]
};

export default definitions;
Loading