diff --git a/package.json b/package.json index 33565c337..97cc235d9 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,6 @@ }, "devDependencies": { "@polkadot/dev": "^0.20.12", - "@polkadot/ts": "^0.1.9" + "@polkadot/ts": "^0.1.10" } } diff --git a/packages/type-extrinsics/src/codec/encode/call.ts b/packages/type-extrinsics/src/codec/encode/call.ts index ef22f0bcc..c5f720961 100644 --- a/packages/type-extrinsics/src/codec/encode/call.ts +++ b/packages/type-extrinsics/src/codec/encode/call.ts @@ -14,7 +14,7 @@ import u8aConcat from '@polkadot/util/u8a/concat'; export default function encodeCall (publicKey: Uint8Array, nonce: number | BN, data: ExtrinsicWithIndex, version: EncodingVersions): ExtrinsicWithAccount { return u8aConcat( publicKey, - bnToU8a(nonce, sizes.Index.get(version) || defaultSizes.Index, true), + bnToU8a(nonce, sizes.AccountIndex.get(version) || defaultSizes.AccountIndex, true), data ); } diff --git a/packages/type-params/src/decode/value/index.ts b/packages/type-params/src/decode/value/index.ts index 39f5cf836..b0f8f6ab7 100644 --- a/packages/type-params/src/decode/value/index.ts +++ b/packages/type-params/src/decode/value/index.ts @@ -33,6 +33,7 @@ export default function decodeValue (decode: Decoder, type: Param$Type, input: U return bn(input, sizes.Balance); case 'BlockNumber': + case 'Gas': case 'SessionKey': case 'u64': return bn(input, 64); @@ -62,8 +63,8 @@ export default function decodeValue (decode: Decoder, type: Param$Type, input: U case 'Hash': return u8a(input, 256, 0); - case 'Index': - return bn(input, sizes.Index); + case 'AccountIndex': + return bn(input, sizes.AccountIndex); case 'KeyValue': case 'KeyValueStorage': diff --git a/packages/type-params/src/encode/param.spec.js b/packages/type-params/src/encode/param.spec.js index 75421a0c9..048ddac7e 100644 --- a/packages/type-params/src/encode/param.spec.js +++ b/packages/type-params/src/encode/param.spec.js @@ -37,7 +37,7 @@ describe('encodeParam', () => { it('encodes tuple types with actual array values', () => { expect( - encodeParam({ type: ['Balance', 'Index'] }, [3, 4]) + encodeParam({ type: ['Balance', 'AccountIndex'] }, [3, 4]) ).toEqual( new Uint8Array([ 2, 0, 0, 0, diff --git a/packages/type-params/src/encode/type/index.ts b/packages/type-params/src/encode/type/index.ts index a3404064b..88078cd77 100644 --- a/packages/type-params/src/encode/type/index.ts +++ b/packages/type-params/src/encode/type/index.ts @@ -30,6 +30,7 @@ export default function encodeType (type: Param$Type, value: any, version: Encod return bnToU8a(value, sizes.Balance.get(version) || defaultSizes.Balance, true); case 'BlockNumber': + case 'Gas': case 'SessionKey': case 'u64': return bnToU8a(value, 64, true); @@ -55,8 +56,8 @@ export default function encodeType (type: Param$Type, value: any, version: Encod case 'Signature': return u8aToU8a(value); - case 'Index': - return bnToU8a(value, sizes.Index.get(version) || defaultSizes.Balance, true); + case 'AccountIndex': + return bnToU8a(value, sizes.AccountIndex.get(version) || defaultSizes.Balance, true); case 'KeyValue': case 'KeyValueStorage': diff --git a/packages/type-params/src/sizes.ts b/packages/type-params/src/sizes.ts index 6300f4b1d..db0a82b18 100644 --- a/packages/type-params/src/sizes.ts +++ b/packages/type-params/src/sizes.ts @@ -10,12 +10,12 @@ const Balance: Map = new Map([ ['poc-1' as EncodingVersions, 64 as SizeType] ]); -const Index: Map = new Map([ - ['latest' as EncodingVersions, sizes.Index], +const AccountIndex: Map = new Map([ + ['latest' as EncodingVersions, sizes.AccountIndex], ['poc-1' as EncodingVersions, 64 as SizeType] ]); export default { - Balance, - Index + AccountIndex, + Balance }; diff --git a/packages/type-params/src/types.d.ts b/packages/type-params/src/types.d.ts index 82bd0cc33..905a2348a 100644 --- a/packages/type-params/src/types.d.ts +++ b/packages/type-params/src/types.d.ts @@ -11,10 +11,10 @@ import { MisbehaviorReport } from '@polkadot/primitives/misbehavior'; export type EncodingVersions = 'poc-1' | 'latest'; // TODO: Also update the following -// - @polkadot/storage/create/decode/index.js +// - @polkadot/storage/key/params.ts // - decode/value/index.js // - encode/type/index.js -export type Param$Type = 'AccountId' | 'Balance' | 'BlockNumber' | 'bool' | 'Bytes' | 'Call' | 'CandidateReceipt' | 'Code' | 'Digest' | 'Hash' | 'Header' | 'Index' | 'KeyValue' | 'KeyValueStorage' | 'MisbehaviorReport' | 'ParachainId' | 'PropIndex' | 'Proposal' | 'ReferendumIndex' | 'SessionKey' | 'Signature' | 'String' | 'Timestamp' | 'u32' | 'u64' | 'u128' | 'VoteIndex' | 'VoteThreshold'; +export type Param$Type = 'AccountId' | 'AccountIndex' | 'Balance' | 'BlockNumber' | 'bool' | 'Bytes' | 'Call' | 'CandidateReceipt' | 'Code' | 'Digest' | 'Gas' | 'Hash' | 'Header' | 'KeyValue' | 'KeyValueStorage' | 'MisbehaviorReport' | 'ParachainId' | 'PropIndex' | 'Proposal' | 'ReferendumIndex' | 'SessionKey' | 'Signature' | 'String' | 'Timestamp' | 'u32' | 'u64' | 'u128' | 'VoteIndex' | 'VoteThreshold'; export type Param$Type$Array = Array>>; diff --git a/packages/type-primitives/src/sizes.ts b/packages/type-primitives/src/sizes.ts index 1efe12a6c..8c9dbccc2 100644 --- a/packages/type-primitives/src/sizes.ts +++ b/packages/type-primitives/src/sizes.ts @@ -6,10 +6,10 @@ export type SizeType = 32 | 64 | 128; const Balance: SizeType = 128; const BlockNumber: SizeType = 64; -const Index: SizeType = 32; +const AccountIndex: SizeType = 32; export default { + AccountIndex, Balance, - BlockNumber, - Index + BlockNumber }; diff --git a/packages/type-storage/src/contract.ts b/packages/type-storage/src/contract.ts new file mode 100644 index 000000000..4f10c06f5 --- /dev/null +++ b/packages/type-storage/src/contract.ts @@ -0,0 +1,72 @@ +// Copyright 2017-2018 @polkadot/storage authors & contributors +// This software may be modified and distributed under the terms +// of the ISC license. See the LICENSE file for details. + +import { CreateItems, CreateItemOptions, Section } from '@polkadot/params/types'; +import { Storages, Storage$Sections } from './types'; + +import param from '@polkadot/params/param'; +import createSection from '@polkadot/params/section'; + +const contractFee: CreateItemOptions = { + description: 'The fee required to create a contract.', + key: 'con:contract_fee', + params: [], + type: 'Balance' +}; + +const callBaseFee: CreateItemOptions = { + description: 'The fee charged for a call into a contract.', + key: 'con:base_call_fee', + params: [], + type: 'Gas' +}; + +const createBaseFee: CreateItemOptions = { + description: 'The fee charged for a create of a contract.', + key: 'con:base_create_fee', + params: [], + type: 'Gas' +}; + +const gasPrice: CreateItemOptions = { + description: 'The price of one unit of gas.', + key: 'con:gas_price', + params: [], + type: 'Balance' +}; + +const maxStackDepth: CreateItemOptions = { + description: 'The maximum nesting level of a call/create stack.', + key: 'con:max_depth', + params: [], + type: 'u32' +}; + +const codeOf: CreateItemOptions = { + description: 'The code associated with an account.', + key: 'con:cod:', + params: [ + param('who', 'AccountId') + ], + type: 'Code' +}; + +export default (name: Storage$Sections): Section => + createSection(name)((createMethod: CreateItems) => ({ + description: 'Contract', + public: { + codeOf: + createMethod('codeOf')(codeOf), + contractFee: + createMethod('contractFee')(contractFee), + callBaseFee: + createMethod('callBaseFee')(callBaseFee), + createBaseFee: + createMethod('createBaseFee')(createBaseFee), + gasPrice: + createMethod('gasPrice')(gasPrice), + maxStackDepth: + createMethod('maxStackDepth')(maxStackDepth) + } + })); diff --git a/packages/type-storage/src/council.ts b/packages/type-storage/src/council.ts index 107e42cbb..a8b8d9d8a 100644 --- a/packages/type-storage/src/council.ts +++ b/packages/type-storage/src/council.ts @@ -8,22 +8,6 @@ import { Storages } from './types'; import param from '@polkadot/params/param'; import createSection from '@polkadot/params/section'; -const activeCouncil: CreateItemOptions = { - description: 'The current council', - key: 'cou:act', - params: [], - type: [['AccountId', 'BlockNumber']] -}; - -const approvalsOf: CreateItemOptions = { - description: 'The last cleared vote index that this voter was last active at', - key: 'cou:apr', - params: [ - param('who', 'AccountId') - ], - type: ['bool'] -}; - const candidacyBond: CreateItemOptions = { description: 'How much should be locked up in order to submit candidacy', key: 'cou:cbo', @@ -31,6 +15,20 @@ const candidacyBond: CreateItemOptions = { type: 'Balance' }; +const votingBond: CreateItemOptions = { + description: 'How much should be locked up in order to be able to submit votes', + key: 'cou:vbo', + params: [], + type: 'Balance' +}; + +const presentSlashPerVoter: CreateItemOptions = { + description: 'The punishment, per voter, if you provide an invalid presentation', + key: 'cou:pss', + params: [], + type: 'Balance' +}; + const carryCount: CreateItemOptions = { description: 'How many runners-up should have their approvals persist until the next vote', key: 'cou:cco', @@ -38,25 +36,11 @@ const carryCount: CreateItemOptions = { type: 'u32' }; -const candidateCount: CreateItemOptions = { - description: 'Number of candidates', - key: 'cou:cnc', +const presentationDuration: CreateItemOptions = { + description: 'How long to give each top candidate to present themselves after the vote ends', + key: 'cou:pdu', params: [], - type: 'u32' -}; - -const candidates: CreateItemOptions = { - description: 'The present candidate lis', - key: 'cou:can', - params: [], - type: ['AccountId'] -}; - -const desiredSeats: CreateItemOptions = { - description: 'The number of desired seats', - key: 'cou:sts', - params: [], - type: 'u32' + type: 'BlockNumber' }; const inactiveGracePeriod: CreateItemOptions = { @@ -66,41 +50,48 @@ const inactiveGracePeriod: CreateItemOptions = { type: 'VoteIndex' }; -const lastActiveOf: CreateItemOptions = { - description: 'The last cleared vote index that this voter was last active at', - key: 'cou:lac', - params: [ - param('who', 'AccountId') - ], +const votingPeriod: CreateItemOptions = { + description: 'How often (in blocks) to check for new votes', + key: 'cou:per', + params: [], + type: 'BlockNumber' +}; + +const termDuration: CreateItemOptions = { + description: 'How long each position is active for', + key: 'cou:trm', + params: [], + type: 'BlockNumber' +}; + +const desiredSeats: CreateItemOptions = { + description: 'The number of desired seats', + key: 'cou:sts', + params: [], + type: 'u32' +}; + +const activeCouncil: CreateItemOptions = { + description: 'The current council', + key: 'cou:act', + params: [], + type: [['AccountId', 'BlockNumber']] +}; + +const voteCount: CreateItemOptions = { + description: 'The total number of votes that have happened or are in progress', + key: 'cou:vco', + params: [], type: 'VoteIndex' }; -const leaderboard: CreateItemOptions = { - description: 'Get the leaderboard if we;re in the presentation phase', - key: 'cou:win', - params: [], - type: [['Balance', 'AccountId']] -}; - -const nextFinalise: CreateItemOptions = { - description: 'The accounts holding the seats that will become free', - key: 'cou:nxt', - params: [], - type: ['BlockNumber', 'u32', ['AccountId']] -}; - -const presentSlashPerVoter: CreateItemOptions = { - description: 'The punishment, per voter, if you provide an invalid presentation', - key: 'cou:pss', - params: [], - type: 'Balance' -}; - -const presentationDuration: CreateItemOptions = { - description: 'How long to give each top candidate to present themselves after the vote ends', - key: 'cou:pdu', - params: [], - type: 'BlockNumber' +const approvalsOf: CreateItemOptions = { + description: 'The last cleared vote index that this voter was last active at', + key: 'cou:apr', + params: [ + param('who', 'AccountId') + ], + type: ['bool'] }; const registerInfoOf: CreateItemOptions = { @@ -112,41 +103,15 @@ const registerInfoOf: CreateItemOptions = { type: [['VoteIndex', 'u32']] }; -const snapshotedStakes: CreateItemOptions = { - description: 'The balances', - key: 'cou:sss', - params: [], - type: ['Balance'] -}; - -const termDuration: CreateItemOptions = { - description: 'How long each position is active for', - key: 'cou:trm', - params: [], - type: 'BlockNumber' -}; - -const voteCount: CreateItemOptions = { - description: 'The total number of votes that have happened or are in progress', - key: 'cou:vco', - params: [], +const lastActiveOf: CreateItemOptions = { + description: 'The last cleared vote index that this voter was last active at', + key: 'cou:lac', + params: [ + param('who', 'AccountId') + ], type: 'VoteIndex' }; -const votingBond: CreateItemOptions = { - description: 'How much should be locked up in order to be able to submit votes', - key: 'cou:vbo', - params: [], - type: 'Balance' -}; - -const votingPeriod: CreateItemOptions = { - description: 'How often (in blocks) to check for new votes', - key: 'cou:per', - params: [], - type: 'BlockNumber' -}; - const voters: CreateItemOptions = { description: 'The present voter list', key: 'cou:vrs', @@ -154,6 +119,41 @@ const voters: CreateItemOptions = { type: ['AccountId'] }; +const candidates: CreateItemOptions = { + description: 'The present candidate lis', + key: 'cou:can', + params: [], + type: ['AccountId'] +}; + +const candidateCount: CreateItemOptions = { + description: 'Number of candidates', + key: 'cou:cnc', + params: [], + type: 'u32' +}; + +const nextFinalise: CreateItemOptions = { + description: 'The accounts holding the seats that will become free', + key: 'cou:nxt', + params: [], + type: ['BlockNumber', 'u32', ['AccountId']] +}; + +const snapshotedStakes: CreateItemOptions = { + description: 'The balances', + key: 'cou:sss', + params: [], + type: ['Balance'] +}; + +const leaderboard: CreateItemOptions = { + description: 'Get the leaderboard if we;re in the presentation phase', + key: 'cou:win', + params: [], + type: [['Balance', 'AccountId']] +}; + export default (name: keyof Storages): Section => createSection(name)((createMethod: CreateItems) => ({ description: 'Council', diff --git a/packages/type-storage/src/governance.ts b/packages/type-storage/src/governance.ts deleted file mode 100644 index b250192c0..000000000 --- a/packages/type-storage/src/governance.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2017-2018 @polkadot/storage authors & contributors -// This software may be modified and distributed under the terms -// of the ISC license. See the LICENSE file for details. - -import { CreateItems, CreateItemOptions, Section } from '@polkadot/params/types'; -import { Storages, Storage$Sections } from './types'; - -import param from '@polkadot/params/param'; -import createSection from '@polkadot/params/section'; - -const approvalsOf: CreateItemOptions = { - description: 'Approvals for a specific account', - isDeprecated: true, - key: 'gov:app:', - params: [ - param('who', 'AccountId') - ], - type: 'Bytes' -}; - -const approvalsRatio: CreateItemOptions = { - description: 'The apprivals ratio', - isDeprecated: true, - key: 'gov:apr', - params: [], - type: 'u32' -}; - -const currentProposal: CreateItemOptions = { - description: 'The current proposal', - isDeprecated: true, - key: 'gov:pro', - params: [], - type: 'Bytes' -}; - -export default (name: Storage$Sections): Section => - createSection(name)((createMethod: CreateItems) => ({ - description: 'Governance (deprecated)', - isDeprecated: true, - public: { - approvalsOf: - createMethod('approvalsOf')(approvalsOf), - approvalsRatio: - createMethod('approvalsRatio')(approvalsRatio), - currentProposal: - createMethod('currentProposal')(currentProposal) - } - })); diff --git a/packages/type-storage/src/index.ts b/packages/type-storage/src/index.ts index 72f51858d..17b1308e6 100644 --- a/packages/type-storage/src/index.ts +++ b/packages/type-storage/src/index.ts @@ -5,10 +5,10 @@ import { Storages } from './types'; import consensus from './consensus'; +// import contract from './contract'; import council from './council'; import councilVoting from './councilVoting'; import democracy from './democracy'; -import governance from './governance'; import parachains from './parachains'; import session from './session'; import staking from './staking'; @@ -17,10 +17,10 @@ import timestamp from './timestamp'; const storages: Storages = { consensus: consensus('consensus'), + // contract: contract('contract'), council: council('council'), councilVoting: councilVoting('councilVoting'), democracy: democracy('democracy'), - governance: governance('governance'), parachains: parachains('parachains'), session: session('session'), staking: staking('staking'), diff --git a/packages/type-storage/src/key/params.ts b/packages/type-storage/src/key/params.ts index c1f823a50..a84c239b0 100644 --- a/packages/type-storage/src/key/params.ts +++ b/packages/type-storage/src/key/params.ts @@ -34,6 +34,7 @@ export default function formatParams (params: Params, values: Storage$Key$Value[ return bnToU8a((value as BN), 128, true); case 'BlockNumber': + case 'Gas': case 'u64': return bnToU8a((value as BN), 64, true); @@ -54,8 +55,8 @@ export default function formatParams (params: Params, values: Storage$Key$Value[ case 'Signature': return u8aToU8a((value as Uint8Array)); - case 'Index': - return bnToU8a((value as BN), sizes.Index, true); + case 'AccountIndex': + return bnToU8a((value as BN), sizes.AccountIndex, true); case 'ParachainId': case 'PropIndex': diff --git a/packages/type-storage/src/session.ts b/packages/type-storage/src/session.ts index 60d27aad1..62118624a 100644 --- a/packages/type-storage/src/session.ts +++ b/packages/type-storage/src/session.ts @@ -8,6 +8,20 @@ import { Storages, Storage$Sections } from './types'; import param from '@polkadot/params/param'; import createSection from '@polkadot/params/section'; +const validators: CreateItemOptions = { + description: 'Current validators', + key: 'ses:val', + params: [], + type: ['AccountId'] +}; + +const length: CreateItemOptions = { + description: 'Current length of the session', + key: 'ses:len', + params: [], + type: 'BlockNumber' +}; + const currentIndex: CreateItemOptions = { description: 'Current index of the session', key: 'ses:ind', @@ -15,7 +29,28 @@ const currentIndex: CreateItemOptions = { type: 'BlockNumber' }; -const lastSessionChange: CreateItemOptions = { +const currentStart: CreateItemOptions = { + description: 'Timestamp when current session started', + key: 'ses:current_start', + params: [], + type: 'Timestamp' +}; + +const brokenPercentLate: CreateItemOptions = { + description: 'Percent by which the session must finish late before early-exit', + key: 'ses:broken_percent_late', + params: [], + type: 'u64' +}; + +const forcingNewSession: CreateItemOptions = { + description: 'New session is being forced is this entry exists', + key: 'ses:forcing_new_session', + params: [], + type: 'bool' +}; + +const lastLengthChange: CreateItemOptions = { description: 'Block at which the session length last changed', key: 'ses:llc', params: [], @@ -38,28 +73,20 @@ const nextLength: CreateItemOptions = { type: 'BlockNumber' }; -const length: CreateItemOptions = { - description: 'Current length of the session', - key: 'ses:len', - params: [], - type: 'BlockNumber' -}; - -const validators: CreateItemOptions = { - description: 'Current validators', - key: 'ses:val', - params: [], - type: ['AccountId'] -}; - export default (name: Storage$Sections): Section => createSection(name)((createMethod: CreateItems) => ({ description: 'Session management information', public: { + brokenPercentLate: + createMethod('brokenPercentLate')(brokenPercentLate), currentIndex: createMethod('currentIndex')(currentIndex), - lastSessionChange: - createMethod('lastSessionChange')(lastSessionChange), + currentStart: + createMethod('currentStart')(currentStart), + forcingNewSession: + createMethod('forcingNewSession')(forcingNewSession), + lastLengthChange: + createMethod('lastLengthChange')(lastLengthChange), nextKeyFor: createMethod('nextKeyFor')(nextKeyFor), nextLength: diff --git a/packages/type-storage/src/staking.ts b/packages/type-storage/src/staking.ts index 7d9c7edbb..eb4f1b4ba 100644 --- a/packages/type-storage/src/staking.ts +++ b/packages/type-storage/src/staking.ts @@ -8,6 +8,168 @@ import { Storages, Storage$Sections } from './types'; import param from '@polkadot/params/param'; import createSection from '@polkadot/params/section'; +const bondingDuration: CreateItemOptions = { + description: 'The length of the bonding duration in eras', + key: 'sta:loc', + params: [], + type: 'BlockNumber' +}; + +const validatorCount: CreateItemOptions = { + description: 'The number of validators', + key: 'sta:vac', + params: [], + type: 'u32' +}; + +const sessionsPerEra: CreateItemOptions = { + description: 'The length of a staking era in sessions', + key: 'sta:spe', + params: [], + type: 'BlockNumber' +}; + +const totalStake: CreateItemOptions = { + description: 'The total amount of stake on the system', + key: 'sta:tot', + params: [], + type: 'Balance' +}; + +const transactionBaseFee: CreateItemOptions = { + description: 'The fee to be paid for making a transaction; the base', + key: 'sta:basefee', + params: [], + type: 'Balance' +}; + +const transactionByteFee: CreateItemOptions = { + description: 'The fee to be paid for making a transaction; the per-byte portion', + key: 'sta:bytefee', + params: [], + type: 'Balance' +}; + +const existentialDeposit: CreateItemOptions = { + description: 'The minimum amount allowed to keep an account open', + key: 'sta:existential_deposit', + params: [], + type: 'Balance' +}; + +const reclaimRebate: CreateItemOptions = { + description: 'The amount credited to a destination account whose index was reclaimed', + key: 'sta:reclaim_rebate', + params: [], + type: 'Balance' +}; + +const transferFee: CreateItemOptions = { + description: 'The fee required to make a transfer', + key: 'sta:transfer_fee', + params: [], + type: 'Balance' +}; + +const creationFee: CreateItemOptions = { + description: 'The fee required to create an account', + key: 'sta:creation_fee', + params: [], + type: 'Balance' +}; + +const sessionReward: CreateItemOptions = { + description: 'Maximum reward, per validator, that is provided per acceptable session', + key: 'sta:early_era_slash', + params: [], + type: 'Balance' +}; + +const earlyEraSlash: CreateItemOptions = { + description: 'Slash, per validator that is taken per abnormal era end', + key: 'sta:early_era_slash', + params: [], + type: 'Balance' +}; + +const currentEra: CreateItemOptions = { + description: 'The current era index', + key: 'sta:era', + params: [], + type: 'BlockNumber' +}; + +const intentions: CreateItemOptions = { + description: 'All the accounts with a desire to stake', + key: 'sta:wil:', + params: [], + type: ['AccountId'] +}; + +const nominating: CreateItemOptions = { + description: 'Nominator -> nominee relationship', + key: 'sta:nominating', + params: [ + param('who', 'AccountId') + ], + type: 'AccountId' +}; + +const nominatorsFor: CreateItemOptions = { + description: 'Nominators for a particular account', + key: 'sta:nominators_for', + params: [ + param('who', 'AccountId') + ], + type: ['AccountId'] +}; + +const currentNominatorsFor: CreateItemOptions = { + description: 'Nominators for a particular account that is in action right now', + key: 'sta:current_nominators_for', + params: [ + param('who', 'AccountId') + ], + type: ['AccountId'] +}; + +const nextSessionsPerEra: CreateItemOptions = { + description: 'The next value of sessions per era', + key: 'sta:nse', + params: [], + type: 'BlockNumber' +}; + +const lastEraLengthChange: CreateItemOptions = { + description: 'The block number at which the era length last changed', + key: 'sta:lec', + params: [], + type: 'BlockNumber' +}; + +const stakeThreshold: CreateItemOptions = { + description: 'The current era stake threshold', + key: 'sta:stake_threshold', + params: [], + type: 'Balance' +}; + +const nextEnumSet: CreateItemOptions = { + description: 'The next free enumeration set', + key: 'sta:next_enum', + params: [], + type: 'AccountIndex' +}; + +const enumSet: CreateItemOptions = { + description: 'The enumeration sets', + key: 'sta:enum_set', + params: [ + param('index', 'AccountIndex') + ], + type: ['AccountId'] +}; + const freeBalanceOf: CreateItemOptions = { description: 'The balance of a given account', key: 'sta:bal:', @@ -17,6 +179,15 @@ const freeBalanceOf: CreateItemOptions = { type: 'Balance' }; +const reservedBalanceOf: CreateItemOptions = { + description: 'The amount of a given account that is reserved', + key: 'sta:lbo:', + params: [ + param('who', 'AccountId') + ], + type: 'Balance' +}; + const bondageOf: CreateItemOptions = { key: 'sta:bon:', description: 'The block at which the account becomes liquid', @@ -26,96 +197,6 @@ const bondageOf: CreateItemOptions = { type: 'Balance' }; -const codeOf: CreateItemOptions = { - key: 'sta:cod:', - description: 'The code associated with an account', - params: [ - param('who', 'AccountId') - ], - type: 'Bytes' -}; - -const transactionFee: CreateItemOptions = { - description: 'The fee to be paid for making a transaction', - key: 'sta:fee', - params: [], - type: 'Balance' -}; - -const bondingDuration: CreateItemOptions = { - description: 'The length of the bonding duration in eras', - key: 'sta:loc', - params: [], - type: 'BlockNumber' -}; - -const currentEra: CreateItemOptions = { - description: 'The current era index', - key: 'sta:era', - params: [], - type: 'BlockNumber' -}; - -const reservedBalanceOf: CreateItemOptions = { - description: 'The amount of a given account that is reserved', - key: 'sta:lbo:', - params: [ - param('who', 'AccountId') - ], - type: 'Balance' -}; - -const intentions: CreateItemOptions = { - description: 'All the accounts with a desire to stake', - key: 'sta:wil:', - params: [], - type: ['AccountId'] -}; - -const lastEraLengthChange: CreateItemOptions = { - description: 'The block number at which the era length last changed', - key: 'sta:lec', - params: [], - type: 'BlockNumber' -}; - -const nextSessionsPerEra: CreateItemOptions = { - description: 'The next value of sessions per era', - key: 'sta:nse', - params: [], - type: 'BlockNumber' -}; - -const sessionsPerEra: CreateItemOptions = { - description: 'The length of a staking era in sessions', - key: 'sta:spe', - params: [], - type: 'BlockNumber' -}; - -const storageOf: CreateItemOptions = { - description: 'The storage items associated with an account/key', - key: 'sta:sto:', - params: [ - param('who', 'AccountId') - ], - type: 'Bytes' -}; - -const totalStake: CreateItemOptions = { - description: 'The total amount of stake on the system', - key: 'sta:tot', - params: [], - type: 'Balance' -}; - -const validatorCount: CreateItemOptions = { - description: 'The number of validators', - key: 'sta:vac', - params: [], - type: 'u32' -}; - export default (name: Storage$Sections): Section => createSection(name)((createMethod: CreateItems) => ({ description: 'Staking', @@ -124,10 +205,22 @@ export default (name: Storage$Sections): Section => createMethod('freeBalanceOf')(freeBalanceOf), bondageOf: createMethod('bondageOf')(bondageOf), - codeOf: - createMethod('codeOf')(codeOf), - transactionFee: - createMethod('transactionFee')(transactionFee), + creationFee: + createMethod('creationFee')(creationFee), + currentNominatorsFor: + createMethod('currentNominatorsFor')(currentNominatorsFor), + earlyEraSlash: + createMethod('earlyEraSlash')(earlyEraSlash), + existentialDeposit: + createMethod('existentialDeposit')(existentialDeposit), + enumSet: + createMethod('enumSet')(enumSet), + transactionBaseFee: + createMethod('transactionBaseFee')(transactionBaseFee), + transactionByteFee: + createMethod('transactionByteFee')(transactionByteFee), + transferFee: + createMethod('transferFee')(transferFee), bondingDuration: createMethod('bondingDuration')(bondingDuration), currentEra: @@ -138,12 +231,22 @@ export default (name: Storage$Sections): Section => createMethod('intentions')(intentions), lastEraLengthChange: createMethod('lastEraLengthChange')(lastEraLengthChange), + nextEnumSet: + createMethod('nextEnumSet')(nextEnumSet), nextSessionsPerEra: createMethod('nextSessionsPerEra')(nextSessionsPerEra), + nominating: + createMethod('nominating')(nominating), + nominatorsFor: + createMethod('nominatorsFor')(nominatorsFor), + reclaimRebate: + createMethod('reclaimRebate')(reclaimRebate), + stakeThreshold: + createMethod('stakeThreshold')(stakeThreshold), sessionsPerEra: createMethod('sessionsPerEra')(sessionsPerEra), - storageOf: - createMethod('storageOf')(storageOf), + sessionReward: + createMethod('sessionReward')(sessionReward), totalStake: createMethod('totalStake')(totalStake), validatorCount: diff --git a/packages/type-storage/src/system.ts b/packages/type-storage/src/system.ts index dc9c6de88..957a9832d 100644 --- a/packages/type-storage/src/system.ts +++ b/packages/type-storage/src/system.ts @@ -8,6 +8,15 @@ import { Storages, Storage$Sections } from './types'; import param from '@polkadot/params/param'; import createSection from '@polkadot/params/section'; +const accountIndexOf: CreateItemOptions = { + description: 'The index of the given account', + key: 'sys:non', + params: [ + param('who', 'AccountId') + ], + type: 'AccountIndex' +}; + const blockHashAt: CreateItemOptions = { description: 'The blockHash for a specific number', key: 'sys:old', @@ -17,18 +26,11 @@ const blockHashAt: CreateItemOptions = { type: 'Hash' }; -const blockNumber: CreateItemOptions = { - description: 'The current block number being processed', - key: 'sys:num', +const extrinsicIndex: CreateItemOptions = { + description: 'The extrinsics index', + key: 'sys:xti', params: [], - type: 'BlockNumber' -}; - -const digest: CreateItemOptions = { - description: 'The digest for the current block', - key: 'sys:dig', - params: [], - type: 'Digest' + type: 'u32' }; const extrinsicData: CreateItemOptions = { @@ -40,27 +42,11 @@ const extrinsicData: CreateItemOptions = { type: 'Bytes' }; -const extrinsicIndex: CreateItemOptions = { - description: 'The extrinsics index', - key: 'sys:xti', +const blockNumber: CreateItemOptions = { + description: 'The current block number being processed', + key: 'sys:num', params: [], - type: 'u32' -}; - -const extrinsicsRoot: CreateItemOptions = { - description: 'The extrinsicsRoot for the current block', - key: 'sys:txr', - params: [], - type: 'Hash' -}; - -const accountIndexOf: CreateItemOptions = { - description: 'The index of the given account', - key: 'sys:non', - params: [ - param('who', 'AccountId') - ], - type: 'Index' + type: 'BlockNumber' }; const parentHash: CreateItemOptions = { @@ -70,13 +56,20 @@ const parentHash: CreateItemOptions = { type: 'Hash' }; -const randomSeed: CreateItemOptions = { - description: 'The random seed', - key: 'sys:rnd', +const extrinsicsRoot: CreateItemOptions = { + description: 'The extrinsicsRoot for the current block', + key: 'sys:txr', params: [], type: 'Hash' }; +const digest: CreateItemOptions = { + description: 'The digest for the current block', + key: 'sys:dig', + params: [], + type: 'Digest' +}; + export default (name: Storage$Sections): Section => createSection(name)((createMethod: CreateItems) => ({ description: 'System', @@ -96,8 +89,6 @@ export default (name: Storage$Sections): Section => accountIndexOf: createMethod('accountIndexOf')(accountIndexOf), parentHash: - createMethod('parentHash')(parentHash), - randomSeed: - createMethod('randomSeed')(randomSeed) + createMethod('parentHash')(parentHash) } })); diff --git a/packages/type-storage/src/timestamp.ts b/packages/type-storage/src/timestamp.ts index 8643e9a9f..06712d930 100644 --- a/packages/type-storage/src/timestamp.ts +++ b/packages/type-storage/src/timestamp.ts @@ -7,15 +7,22 @@ import { Storages, Storage$Sections } from './types'; import createSection from '@polkadot/params/section'; -const current: CreateItemOptions = { +const now: CreateItemOptions = { description: 'The current timestamp', key: 'tim:val', params: [], type: 'Timestamp' }; +const blockPeriod: CreateItemOptions = { + description: 'The minimum (and advised) period between blocks', + key: 'tim:block_period', + params: [], + type: 'u64' +}; + const didUpdate: CreateItemOptions = { - description: 'Did the timestamp update', + description: 'Did the timestamp update in this block', key: 'tim:did', params: [], type: 'bool' @@ -25,8 +32,10 @@ export default (name: Storage$Sections): Section => createSection(name)((createMethod: CreateItems) => ({ description: 'Timestamp related entries', public: { - current: - createMethod('current')(current), + blockPeriod: + createMethod('blockPeriod')(blockPeriod), + now: + createMethod('now')(now), didUpdate: createMethod('didUpdate')(didUpdate) } diff --git a/packages/type-storage/src/types.d.ts b/packages/type-storage/src/types.d.ts index c5a0eae87..d45c00d26 100644 --- a/packages/type-storage/src/types.d.ts +++ b/packages/type-storage/src/types.d.ts @@ -9,10 +9,10 @@ export type Storage$Key$Value = number | BN | Uint8Array | string; export type Storages = { consensus: Section, + // contract: Section, council: Section, councilVoting: Section, democracy: Section, - governance: Section, parachains: Section, session: Section, staking: Section, diff --git a/yarn.lock b/yarn.lock index 2976bcba1..45a3f58b2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -737,9 +737,9 @@ typedoc "^0.11.1" typescript "^2.9.2" -"@polkadot/ts@^0.1.9": - version "0.1.9" - resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.9.tgz#86010c5a4d63c0fb6b3e85d29db40dcf43c5d7c1" +"@polkadot/ts@^0.1.10": + version "0.1.10" + resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.10.tgz#784d460cf4b2e9b38bb1c77f9366dd01425f220d" "@types/async@^2.0.49": version "2.0.49"