Import type-* from common repo (#125)

* Import type-* from common repo

* Update links

* Fix lint links (package index)
This commit is contained in:
Jaco Greeff
2018-08-11 11:14:20 +02:00
committed by GitHub
parent 2cd40a2b97
commit ad968ec794
191 changed files with 6071 additions and 94 deletions
+15
View File
@@ -0,0 +1,15 @@
ISC License (ISC)
Copyright 2017-2018 @polkadot/storage authors & contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
+13
View File
@@ -0,0 +1,13 @@
[![polkadotjs](https://img.shields.io/badge/polkadot-js-orange.svg?style=flat-square)](https://polkadot.js.org)
![isc](https://img.shields.io/badge/license-ISC-lightgrey.svg?style=flat-square)
[![style](https://img.shields.io/badge/code%20style-semistandard-lightgrey.svg?style=flat-square)](https://github.com/Flet/semistandard)
[![npm](https://img.shields.io/npm/v/@polkadot/storage.svg?style=flat-square)](https://www.npmjs.com/package/@polkadot/storage)
[![travis](https://img.shields.io/travis/polkadot-js/api.svg?style=flat-square)](https://travis-ci.org/polkadot-js/api)
[![maintainability](https://img.shields.io/codeclimate/maintainability/polkadot-js/api.svg?style=flat-square)](https://codeclimate.com/github/polkadot-js/api/maintainability)
[![coverage](https://img.shields.io/coveralls/polkadot-js/api.svg?style=flat-square)](https://coveralls.io/github/polkadot-js/api?branch=master)
[![dependency](https://david-dm.org/polkadot-js/api.svg?style=flat-square&path=packages/type-storage)](https://david-dm.org/polkadot-js/api?path=packages/type-storage)
[![devDependency](https://david-dm.org/polkadot-js/api/dev-status.svg?style=flat-square&path=packages/type-storage)](https://david-dm.org/polkadot-js/api?path=packages/type-storage#info=devDependencies)
# @polkadot/storage
An base interface to the storage layer
+44
View File
@@ -0,0 +1,44 @@
{
"name": "@polkadot/storage",
"version": "0.28.0",
"description": "Generic wrapper wrapper around state storage",
"main": "index.js",
"engines": {
"node": ">=8.0"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"repository": {
"type": "git",
"url": "git+https://github.com/polkadot-js/api.git"
},
"keywords": [
"Polkadot",
"Merkel Patricia Tree"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [
"Jaco Greeff <jacogr@gmail.com>"
],
"contributors": [],
"license": "ISC",
"bugs": {
"url": "https://github.com/polkadot-js/api/issues"
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-storage#readme",
"scripts": {
"build": "polkadot-dev-build-babel",
"check": "eslint src && flow check",
"test": "echo \"Tests only available from root wrapper\""
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@polkadot/params": "^0.28.0",
"@polkadot/primitives": "^0.28.0",
"@polkadot/util": "^0.28.1",
"@polkadot/util-crypto": "^0.28.1",
"@polkadot/util-keyring": "^0.28.1"
}
}
+48
View File
@@ -0,0 +1,48 @@
// 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 authorityAt: CreateItemOptions = {
description: 'Authority at a specific index',
isUnhashed: true,
key: ':auth:',
params: [
param('index', 'u32')
],
type: 'AccountId'
};
const authorityCount: CreateItemOptions = {
description: 'The number of authorities',
isUnhashed: true,
key: ':auth:len',
params: [],
type: 'u32'
};
const code: CreateItemOptions = {
description: 'The current runtime code',
isUnhashed: true,
key: ':code',
params: [],
type: 'Code'
};
export default (name: Storage$Sections): Section<Storages> =>
createSection(name)((createMethod: CreateItems<Storages>) => ({
description: 'Consensus',
public: {
authorityAt:
createMethod('authorityAt')(authorityAt),
authorityCount:
createMethod('authorityCount')(authorityCount),
code:
createMethod('code')(code)
}
}));
+72
View File
@@ -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<Storages> =>
createSection(name)((createMethod: CreateItems<Storages>) => ({
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)
}
}));
+202
View File
@@ -0,0 +1,202 @@
// 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 } from './types';
import param from '@polkadot/params/param';
import createSection from '@polkadot/params/section';
const candidacyBond: CreateItemOptions = {
description: 'How much should be locked up in order to submit candidacy',
key: 'cou:cbo',
params: [],
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',
params: [],
type: 'u32'
};
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 inactiveGracePeriod: CreateItemOptions = {
description: 'How many votes need to go by after a last vote',
key: 'cou:vgp',
params: [],
type: 'VoteIndex'
};
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 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 = {
description: 'The vote index and list slot that the candidate was registered',
key: 'cou:reg',
params: [
param('who', 'AccountId')
],
type: [['VoteIndex', 'u32']]
};
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 voters: CreateItemOptions = {
description: 'The present voter list',
key: 'cou:vrs',
params: [],
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<Storages> =>
createSection(name)((createMethod: CreateItems<Storages>) => ({
description: 'Council',
public: {
candidacyBond:
createMethod('candidacyBond')(candidacyBond),
votingBond:
createMethod('votingBond')(votingBond),
presentSlashPerVoter:
createMethod('presentSlashPerVoter')(presentSlashPerVoter),
carryCount:
createMethod('carryCount')(carryCount),
presentationDuration:
createMethod('presentationDuration')(presentationDuration),
inactiveGracePeriod:
createMethod('inactiveGracePeriod')(inactiveGracePeriod),
votingPeriod:
createMethod('votingPeriod')(votingPeriod),
termDuration:
createMethod('termDuration')(termDuration),
desiredSeats:
createMethod('desiredSeats')(desiredSeats),
activeCouncil:
createMethod('activeCouncil')(activeCouncil),
voteCount:
createMethod('voteCount')(voteCount),
approvalsOf:
createMethod('approvalsOf')(approvalsOf),
registerInfoOf:
createMethod('registerInfoOf')(registerInfoOf),
lastActiveOf:
createMethod('lastActiveOf')(lastActiveOf),
voters:
createMethod('voters')(voters),
candidateCount:
createMethod('candidateCount')(candidateCount),
candidates:
createMethod('candidates')(candidates),
nextFinalise:
createMethod('nextFinalise')(nextFinalise),
snapshotedStakes:
createMethod('snapshotedStakes')(snapshotedStakes),
leaderboard:
createMethod('leaderboard')(leaderboard)
}
}));
@@ -0,0 +1,88 @@
// 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 cooloffPeriod: CreateItemOptions = {
description: 'The coolof period',
key: 'cov:cooloff',
params: [],
type: 'BlockNumber'
};
const votingPeriod: CreateItemOptions = {
description: 'The voting period',
key: 'cov:period',
params: [],
type: 'BlockNumber'
};
const proposals: CreateItemOptions = {
description: 'The current proposals',
key: 'cov:prs',
params: [],
type: [['BlockNumber', 'Hash']]
};
const proposalOf: CreateItemOptions = {
description: 'The proposal by hash',
key: 'cov:pro',
params: [
param('hash', 'Hash')
],
type: 'Proposal'
};
const proposalVoters: CreateItemOptions = {
description: 'Voters on a proposal',
key: 'cov:voters:',
params: [
param('hash', 'Hash')
],
type: ['AccountId']
};
const councilVoteOf: CreateItemOptions = {
description: 'Council votes on proposal',
key: 'cov:vote:',
params: [
param('hash', 'Hash'),
param('who', 'AccountId')
],
type: 'bool'
};
const vetoedProposal: CreateItemOptions = {
description: 'Council vetos on a proposal',
key: 'cov:veto:',
params: [
param('hash', 'Hash')
],
type: ['BlockNumber', 'AccountId']
};
export default (name: Storage$Sections): Section<Storages> =>
createSection(name)((createMethod: CreateItems<Storages>) => ({
description: 'Council voting',
public: {
cooloffPeriod:
createMethod('cooloffPeriod')(cooloffPeriod),
votingPeriod:
createMethod('votingPeriod')(votingPeriod),
proposals:
createMethod('proposals')(proposals),
proposalOf:
createMethod('proposalOf')(proposalOf),
proposalVoters:
createMethod('proposalVoters')(proposalVoters),
councilVoteOf:
createMethod('councilVoteOf')(councilVoteOf),
vetoedProposal:
createMethod('vetoedProposal')(vetoedProposal)
}
}));
+124
View File
@@ -0,0 +1,124 @@
// 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 proposalCount: CreateItemOptions = {
description: 'The number of (public) proposals that have been made so far',
key: 'dem:ppc',
params: [],
type: 'PropIndex'
};
const proposals: CreateItemOptions = {
description: 'The public proposals. Unsorted.',
key: 'dem:pub',
params: [],
type: [['PropIndex', 'Proposal', 'AccountId']]
};
const depositOf: CreateItemOptions = {
description: 'Those who have locked a deposit',
key: 'dem:dep:',
params: [
param('index', 'PropIndex')
],
type: ['Balance', ['AccountId']]
};
const launchPeriod: CreateItemOptions = {
description: 'How often (in blocks) new public referenda are launched',
key: 'dem:lau',
params: [],
type: 'BlockNumber'
};
const minimumDeposit: CreateItemOptions = {
description: 'The minimum amount as a deposit for a public referendum',
key: 'dem:min',
params: [],
type: 'Balance'
};
const votingPeriod: CreateItemOptions = {
description: 'How often (in blocks) to check for new votes',
key: 'dem:per',
params: [],
type: 'BlockNumber'
};
const referendumCount: CreateItemOptions = {
description: 'The number of referendums started so far',
key: 'dem:rco',
params: [],
type: 'ReferendumIndex'
};
const nextTally: CreateItemOptions = {
description: 'The next referendum index that should be tallied',
key: 'dem:nxt',
params: [],
type: 'ReferendumIndex'
};
const referendumInfoOf: CreateItemOptions = {
description: 'Details for a specific referendum',
key: 'dem:pro:',
params: [
param('referendum', 'ReferendumIndex')
],
type: ['BlockNumber', 'Proposal', 'VoteThreshold']
};
const votersFor: CreateItemOptions = {
description: 'Get the voters for the current proposal',
key: 'dem:vtr:',
params: [
param('referendum', 'ReferendumIndex')
],
type: ['AccountId']
};
const voteOf: CreateItemOptions = {
description: 'Get the vote for Account',
key: 'dem:vot:',
params: [
param('referendum', 'ReferendumIndex'),
param('who', 'AccountId')
],
type: 'bool'
};
export default (name: Storage$Sections): Section<Storages> =>
createSection(name)((createMethod: CreateItems<Storages>) => ({
description: 'Democracy',
public: {
proposalCount:
createMethod('proposalCount')(proposalCount),
proposals:
createMethod('proposals')(proposals),
depositOf:
createMethod('depositOf')(depositOf),
launchPeriod:
createMethod('launchPeriod')(launchPeriod),
minimumDeposit:
createMethod('minimumDeposit')(minimumDeposit),
votingPeriod:
createMethod('votingPeriod')(votingPeriod),
referendumCount:
createMethod('referendumCount')(referendumCount),
nextTally:
createMethod('nextTally')(nextTally),
referendumInfoOf:
createMethod('referendumInfoOf')(referendumInfoOf),
votersFor:
createMethod('votersFor')(votersFor),
voteOf:
createMethod('voteOf')(voteOf)
}
}));
+31
View File
@@ -0,0 +1,31 @@
// 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 { Storages } from './types';
import consensus from './consensus';
// import contract from './contract';
import council from './council';
import councilVoting from './councilVoting';
import democracy from './democracy';
import parachains from './parachains';
import session from './session';
import staking from './staking';
import system from './system';
import timestamp from './timestamp';
const storages: Storages = {
consensus: consensus('consensus'),
// contract: contract('contract'),
council: council('council'),
councilVoting: councilVoting('councilVoting'),
democracy: democracy('democracy'),
parachains: parachains('parachains'),
session: session('session'),
staking: staking('staking'),
system: system('system'),
timestamp: timestamp('timestamp')
};
export default storages;
@@ -0,0 +1,59 @@
// 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 hexToU8a from '@polkadot/util/hex/toU8a';
import u8aFromString from '@polkadot/util/u8a/fromString';
import param from '@polkadot/params/param';
import key from './index';
describe('key', () => {
it('concats the values', () => {
expect(
key({
key: 'sys:old:',
params: [
param('first', 'Bytes')
]
})(
hexToU8a('0x0100000000000000')
)
).toEqual(
hexToU8a('0x3117ecd3eaa7a8c27cb8d04eb597a1ef')
);
});
it('concats the values (Array<Uint8Array>)', () => {
expect(
key({
key: 'sys:old:',
params: [
param('first', 'Bytes'),
param('second', 'Bytes')
]
})(
hexToU8a('0x01000000'),
hexToU8a('0x00000000')
)
).toEqual(
hexToU8a('0x3117ecd3eaa7a8c27cb8d04eb597a1ef')
);
});
it('concats with empty key', () => {
expect(
key({ key: 'ses:llc' })()
).toEqual(
hexToU8a('0xe14daa763fce793346d4b7e131240849')
);
});
it('does not hash when not required', () => {
expect(
key({ key: ':code', isUnhashed: true })()
).toEqual(
u8aFromString(':code')
);
});
});
+29
View File
@@ -0,0 +1,29 @@
// 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 { SectionItem } from '@polkadot/params/types';
import { Storage$Key$Value } from '../types';
import u8aConcat from '@polkadot/util/u8a/concat';
import u8aFromString from '@polkadot/util/u8a/fromString';
import xxhash from '@polkadot/util-crypto/xxhash/asU8a';
import formatParams from './params';
export type Keygen = (...keyParams: Array<Storage$Key$Value>) => Uint8Array;
export default function bindKey <T> ({ isUnhashed, key, params }: SectionItem<T>): Keygen {
const prefix = u8aFromString(key);
return (...keyParams: Array<Storage$Key$Value>): Uint8Array => {
const postfix = keyParams.length !== 0
? u8aConcat.apply(null, formatParams(params, keyParams))
: new Uint8Array([]);
const prefixedKey = u8aConcat(prefix, postfix);
return isUnhashed
? prefixedKey
: xxhash(prefixedKey, 128);
};
}
+87
View File
@@ -0,0 +1,87 @@
// 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 BN from 'bn.js';
import { Param, Params } from '@polkadot/params/types';
import { Storage$Key$Value } from '../types';
import sizes from '@polkadot/primitives/sizes';
import bnToU8a from '@polkadot/util/bn/toU8a';
import u8aToU8a from '@polkadot/util/u8a/toU8a';
import u8aFromString from '@polkadot/util/u8a/fromString';
import addressDecode from '@polkadot/util-keyring/address/decode';
export default function formatParams (params: Params, values: Storage$Key$Value[] = []): Array<Uint8Array> {
const paramTypes = Object.values(params).map(({ type }: Param) => type);
return values.map((value: any, index: number): Uint8Array => {
try {
if (Array.isArray(paramTypes[index])) {
throw new Error('Unable to handle Array type');
}
const type = paramTypes[index];
switch (type) {
case 'AccountId':
return addressDecode((value as Uint8Array));
case 'Balance':
return bnToU8a((value as BN), sizes.Balance, true);
case 'u128':
return bnToU8a((value as BN), 128, true);
case 'BlockNumber':
case 'Gas':
case 'u64':
return bnToU8a((value as BN), 64, true);
case 'bool':
return new Uint8Array([value ? 1 : 0]);
case 'Bytes':
case 'Call':
case 'CandidateReceipt':
case 'Code':
case 'Digest':
case 'Hash':
case 'Header':
case 'KeyValue':
case 'KeyValueStorage':
case 'MisbehaviorReport':
case 'Proposal':
case 'Signature':
return u8aToU8a((value as Uint8Array));
case 'AccountIndex':
return bnToU8a((value as BN), sizes.AccountIndex, true);
case 'ParachainId':
case 'PropIndex':
case 'ReferendumIndex':
case 'SessionKey':
case 'VoteIndex':
case 'VoteThreshold':
case 'u32':
return bnToU8a((value as BN), 32, true);
case 'String':
return u8aFromString((value as string));
case 'Timestamp':
return bnToU8a((value as Date).getTime(), 64, true);
default:
// tslint:disable-next-line
(type as never);
throw new Error('Unable to find handler');
}
} catch (error) {
console.error('formatParams', value, index, paramTypes[index], error);
throw error;
}
});
}
+56
View File
@@ -0,0 +1,56 @@
// 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 activeParachains: CreateItemOptions = {
description: 'All registered parachains',
key: 'para:chains',
params: [],
type: ['ParachainId']
};
const parachainCode: CreateItemOptions = {
description: 'Gets the code for a specific parachain',
key: 'para:code',
params: [
param('id', 'ParachainId')
],
type: 'Code'
};
const parachainHeads: CreateItemOptions = {
description: 'The heads of the parachains registered at present',
key: 'para:head',
params: [
param('id', 'ParachainId')
],
type: 'Bytes'
};
const didUpdate: CreateItemOptions = {
description: 'Did the parachain heads get updated in this block',
key: 'para:did',
params: [],
type: 'bool'
};
export default (name: Storage$Sections): Section<Storages> =>
createSection(name)((createMethod: CreateItems<Storages>) => ({
description: 'Parachain related entries',
public: {
activeParachains:
createMethod('activeParachains')(activeParachains),
parachainCode:
createMethod('parachainCode')(parachainCode),
parachainHeads:
createMethod('parachainHeads')(parachainHeads),
didUpdate:
createMethod('didUpdate')(didUpdate)
}
}));
+99
View File
@@ -0,0 +1,99 @@
// 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 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',
params: [],
type: 'BlockNumber'
};
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: [],
type: 'BlockNumber'
};
const nextKeyFor: CreateItemOptions = {
description: 'The next key for a given validator',
key: 'ses:nxt:',
params: [
param('who', 'AccountId')
],
type: 'SessionKey'
};
const nextLength: CreateItemOptions = {
description: 'The next session length',
key: 'ses:nln',
params: [],
type: 'BlockNumber'
};
export default (name: Storage$Sections): Section<Storages> =>
createSection(name)((createMethod: CreateItems<Storages>) => ({
description: 'Session management information',
public: {
brokenPercentLate:
createMethod('brokenPercentLate')(brokenPercentLate),
currentIndex:
createMethod('currentIndex')(currentIndex),
currentStart:
createMethod('currentStart')(currentStart),
forcingNewSession:
createMethod('forcingNewSession')(forcingNewSession),
lastLengthChange:
createMethod('lastLengthChange')(lastLengthChange),
nextKeyFor:
createMethod('nextKeyFor')(nextKeyFor),
nextLength:
createMethod('nextLength')(nextLength),
length:
createMethod('length')(length),
validators:
createMethod('validators')(validators)
}
}));
+255
View File
@@ -0,0 +1,255 @@
// 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 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:',
params: [
param('who', 'AccountId')
],
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',
params: [
param('who', 'AccountId')
],
type: 'Balance'
};
export default (name: Storage$Sections): Section<Storages> =>
createSection(name)((createMethod: CreateItems<Storages>) => ({
description: 'Staking',
public: {
freeBalanceOf:
createMethod('freeBalanceOf')(freeBalanceOf),
bondageOf:
createMethod('bondageOf')(bondageOf),
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:
createMethod('currentEra')(currentEra),
reservedBalanceOf:
createMethod('reservedBalanceOf')(reservedBalanceOf),
intentions:
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),
sessionReward:
createMethod('sessionReward')(sessionReward),
totalStake:
createMethod('totalStake')(totalStake),
validatorCount:
createMethod('validatorCount')(validatorCount)
}
}));
+94
View File
@@ -0,0 +1,94 @@
// 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 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',
params: [
param('blockNumber', 'BlockNumber')
],
type: 'Hash'
};
const extrinsicIndex: CreateItemOptions = {
description: 'The extrinsics index',
key: 'sys:xti',
params: [],
type: 'u32'
};
const extrinsicData: CreateItemOptions = {
description: 'The data associated with an extrinsic',
key: 'sys:xtd',
params: [
param('extrinsic', 'u32')
],
type: 'Bytes'
};
const blockNumber: CreateItemOptions = {
description: 'The current block number being processed',
key: 'sys:num',
params: [],
type: 'BlockNumber'
};
const parentHash: CreateItemOptions = {
description: 'The parentHash for the current block',
key: 'sys:pha',
params: [],
type: 'Hash'
};
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<Storages> =>
createSection(name)((createMethod: CreateItems<Storages>) => ({
description: 'System',
public: {
blockHashAt:
createMethod('blockHashAt')(blockHashAt),
blockNumber:
createMethod('blockNumber')(blockNumber),
digest:
createMethod('digest')(digest),
extrinsicData:
createMethod('extrinsicData')(extrinsicData),
extrinsicIndex:
createMethod('extrinsicIndex')(extrinsicIndex),
extrinsicsRoot:
createMethod('extrinsicsRoot')(extrinsicsRoot),
accountIndexOf:
createMethod('accountIndexOf')(accountIndexOf),
parentHash:
createMethod('parentHash')(parentHash)
}
}));
+42
View File
@@ -0,0 +1,42 @@
// 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 createSection from '@polkadot/params/section';
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 in this block',
key: 'tim:did',
params: [],
type: 'bool'
};
export default (name: Storage$Sections): Section<Storages> =>
createSection(name)((createMethod: CreateItems<Storages>) => ({
description: 'Timestamp related entries',
public: {
blockPeriod:
createMethod('blockPeriod')(blockPeriod),
now:
createMethod('now')(now),
didUpdate:
createMethod('didUpdate')(didUpdate)
}
}));
+23
View File
@@ -0,0 +1,23 @@
// 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 BN from 'bn.js';
import { Section } from '@polkadot/params/types';
export type Storage$Key$Value = number | BN | Uint8Array | string;
export type Storages = {
consensus: Section<Storages>,
// contract: Section<Storages>,
council: Section<Storages>,
councilVoting: Section<Storages>,
democracy: Section<Storages>,
parachains: Section<Storages>,
session: Section<Storages>,
staking: Section<Storages>,
system: Section<Storages>,
timestamp: Section<Storages>
};
export type Storage$Sections = keyof Storages;