Latest metadata (#1647)

* Latest metadata

* Updte static version (v9)

* Update tests for new storage keys

* Bump deps

* Bump extra

* Case, V8 -> v8
This commit is contained in:
Jaco Greeff
2019-12-07 14:13:20 +01:00
committed by GitHub
parent 664d2c8ab6
commit bf946c20db
18 changed files with 500 additions and 174 deletions
+1 -1
View File
@@ -26,7 +26,7 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.7.4",
"@babel/runtime": "^7.7.5",
"@polkadot/types": "^0.99.0-beta.3"
}
}
+1 -1
View File
@@ -27,7 +27,7 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.7.4",
"@babel/runtime": "^7.7.5",
"@polkadot/api": "^0.99.0-beta.3",
"@polkadot/types": "^0.99.0-beta.3"
},
+1 -1
View File
@@ -26,7 +26,7 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.7.4",
"@babel/runtime": "^7.7.5",
"@polkadot/api-derive": "^0.99.0-beta.3",
"@polkadot/keyring": "^1.7.1",
"@polkadot/metadata": "^0.99.0-beta.3",
+1
View File
@@ -47,6 +47,7 @@ declare module '@polkadot/metadata/Decorated/types' {
minimumDeposit: BalanceOf & ConstantCodec;
emergencyVotingPeriod: BlockNumber & ConstantCodec;
cooloffPeriod: BlockNumber & ConstantCodec;
preimageByteDeposit: BalanceOf & ConstantCodec;
};
elections: {
[index: string]: Codec;
+4 -4
View File
@@ -123,18 +123,19 @@ declare module './types' {
democracy: {
[index: string]: QueryableStorageEntry<ApiType>;
publicPropCount: StorageEntryExact<ApiType, () => Observable<PropIndex>> & QueryableStorageEntry<ApiType>;
publicProps: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[PropIndex, Proposal, AccountId]>>>> & QueryableStorageEntry<ApiType>;
publicProps: StorageEntryExact<ApiType, () => Observable<Vec<ITuple<[PropIndex, Hash, AccountId]>>>> & QueryableStorageEntry<ApiType>;
preimages: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Option<ITuple<[Bytes, AccountId, BalanceOf, BlockNumber]>>>> & QueryableStorageEntry<ApiType>;
depositOf: StorageEntryExact<ApiType, (arg: PropIndex | Uint8Array | number | string) => Observable<Option<ITuple<[BalanceOf, Vec<AccountId>]>>>> & QueryableStorageEntry<ApiType>;
referendumCount: StorageEntryExact<ApiType, () => Observable<ReferendumIndex>> & QueryableStorageEntry<ApiType>;
nextTally: StorageEntryExact<ApiType, () => Observable<ReferendumIndex>> & QueryableStorageEntry<ApiType>;
referendumInfoOf: StorageEntryExact<ApiType, (arg: ReferendumIndex | Uint8Array | number | string) => Observable<Option<ReferendumInfo>>> & QueryableStorageEntry<ApiType>;
dispatchQueue: StorageEntryExact<ApiType, (arg: BlockNumber | Uint8Array | number | string) => Observable<Vec<Option<ITuple<[Proposal, ReferendumIndex]>>>>> & QueryableStorageEntry<ApiType>;
dispatchQueue: StorageEntryExact<ApiType, (arg: BlockNumber | Uint8Array | number | string) => Observable<Vec<Option<ITuple<[Hash, ReferendumIndex]>>>>> & QueryableStorageEntry<ApiType>;
votersFor: StorageEntryExact<ApiType, (arg: ReferendumIndex | Uint8Array | number | string) => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
voteOf: StorageEntryExact<ApiType, (arg: ITuple<[ReferendumIndex, AccountId]>) => Observable<Vote>> & QueryableStorageEntry<ApiType>;
proxy: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Option<AccountId>>> & QueryableStorageEntry<ApiType>;
delegations: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<ITuple<[AccountId, Conviction]>>> & QueryableStorageEntry<ApiType>;
lastTabledWasExternal: StorageEntryExact<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
nextExternal: StorageEntryExact<ApiType, () => Observable<Option<ITuple<[Proposal, VoteThreshold]>>>> & QueryableStorageEntry<ApiType>;
nextExternal: StorageEntryExact<ApiType, () => Observable<Option<ITuple<[Hash, VoteThreshold]>>>> & QueryableStorageEntry<ApiType>;
blacklist: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<Option<ITuple<[BlockNumber, Vec<AccountId>]>>>> & QueryableStorageEntry<ApiType>;
cancellations: StorageEntryExact<ApiType, (arg: Hash | Uint8Array | string) => Observable<bool>> & QueryableStorageEntry<ApiType>;
};
@@ -162,7 +163,6 @@ declare module './types' {
votesOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
stakeOf: StorageEntryExact<ApiType, (arg: AccountId | Uint8Array | string) => Observable<BalanceOf>> & QueryableStorageEntry<ApiType>;
candidates: StorageEntryExact<ApiType, () => Observable<Vec<AccountId>>> & QueryableStorageEntry<ApiType>;
didMigrate: StorageEntryExact<ApiType, () => Observable<bool>> & QueryableStorageEntry<ApiType>;
};
technicalMembership: {
[index: string]: QueryableStorageEntry<ApiType>;
+1 -1
View File
@@ -26,7 +26,7 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.7.4",
"@babel/runtime": "^7.7.5",
"@polkadot/types": "^0.99.0-beta.3",
"@polkadot/util": "^1.7.1",
"@polkadot/util-crypto": "^1.7.1"
@@ -3,6 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { ClassOf, createType, TypeRegistry } from '@polkadot/types/codec/create';
import { hexToU8a } from '@polkadot/util';
import Decorated from './Decorated';
import json from '../Metadata/static';
@@ -17,10 +18,9 @@ describe('Decorated', () => {
.balances
.freeBalance('5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY')
).toEqual(
// length prefix attached
Uint8Array.from([
128, 127, 134, 78, 24, 227, 221, 139, 88, 56, 99, 16, 210, 254, 9, 25, 238, 242, 124, 110, 85, 133, 100, 183, 246, 127, 34, 217, 157, 32, 245, 135, 187
])
hexToU8a(
'0x0101c2261276cc9d1f8598ea4b6a74b15c2f6482b9ade7bc6657aaca787ba1add3b42e3fb4c297a84c5cebc0e78257d213d0927ccc7596044c6ba013dd05522aacba'
)
);
});
@@ -7,28 +7,49 @@ import { TypeRegistry } from '@polkadot/types';
import { u8aToHex } from '@polkadot/util';
import rpcMetadata from '../../../Metadata/static';
import rpcMetadataV8 from '../../../Metadata/v8/static';
import Decorated from '../../Decorated';
const registry = new TypeRegistry();
const keyring = testingPairs({ type: 'ed25519' });
const decorated = new Decorated(registry, rpcMetadata);
describe('fromMetadata', (): void => {
it('should throw if the storage function expects an argument', (): void => {
expect((): any => decorated.query.balances.freeBalance()).toThrowError(/requires one argument/);
describe('latest', (): void => {
const registry = new TypeRegistry();
const decorated = new Decorated(registry, rpcMetadata);
it('should throw if the storage function expects an argument', (): void => {
expect((): any => decorated.query.balances.freeBalance()).toThrowError(/requires one argument/);
});
it('should return a value if the storage function does not expect an argument', (): void => {
expect((): any => decorated.query.timestamp.now()).not.toThrow();
});
it('should return the correct length-prefixed storage key', (): void => {
expect(
u8aToHex(
decorated.query.balances.freeBalance(keyring.alice.address)
)
).toEqual(
// new storage key format
'0x0101c2261276cc9d1f8598ea4b6a74b15c2f6482b9ade7bc6657aaca787ba1add3b42e3fb4c297a84c5cebc0e78257d213d0927ccc7596044c6ba013dd05522aacba'
);
});
});
it('should return a value if the storage function does not expect an argument', (): void => {
expect((): any => decorated.query.timestamp.now()).not.toThrow();
});
describe('V8', (): void => {
const registry = new TypeRegistry();
const decorated = new Decorated(registry, rpcMetadataV8);
it('should return the correct length-prefixed storage key', (): void => {
expect(
u8aToHex(
decorated.query.balances.freeBalance(keyring.alice.address)
)
).toEqual(
'0x807f864e18e3dd8b58386310d2fe0919eef27c6e558564b7f67f22d99d20f587bb'
);
it('should return the correct length-prefixed storage key', (): void => {
expect(
u8aToHex(
decorated.query.balances.freeBalance(keyring.alice.address)
)
).toEqual(
// old storage key format
'0x807f864e18e3dd8b58386310d2fe0919eef27c6e558564b7f67f22d99d20f587bb'
);
});
});
});
+1 -1
View File
@@ -2,6 +2,6 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import metadata from './v8/static';
import metadata from './v9/static';
export default metadata;
@@ -1089,18 +1089,21 @@
},
{
"name": "Nominators",
"modifier": 1,
"modifier": 0,
"type": {
"Map": {
"hasher": "Blake2_256",
"key": "AccountId",
"value": "Vec<AccountId>",
"value": "Nominations",
"linked": true
}
},
"fallback": "0x00",
"documentation": [
" The map from nominator stash key to the set of stash keys of all validators to nominate."
" The map from nominator stash key to the set of stash keys of all validators to nominate.",
"",
" NOTE: is private so that we can ensure upgraded before all typical accesses.",
" Direct storage APIs can still bypass this protection."
]
},
{
@@ -1214,6 +1217,34 @@
" The rest of the slashed value is handled by the `Slash`."
]
},
{
"name": "CanceledSlashPayout",
"modifier": 1,
"type": {
"Plain": "BalanceOf"
},
"fallback": "0x00000000000000000000000000000000",
"documentation": [
" The amount of currency given to reporters of a slash event which was",
" canceled by extraordinary circumstances (e.g. governance)."
]
},
{
"name": "UnappliedSlashes",
"modifier": 1,
"type": {
"Map": {
"hasher": "Blake2_256",
"key": "EraIndex",
"value": "Vec<UnappliedSlash>",
"linked": false
}
},
"fallback": "0x00",
"documentation": [
" All unapplied slashes that are queued for later."
]
},
{
"name": "BondedEras",
"modifier": 1,
@@ -1226,19 +1257,93 @@
]
},
{
"name": "EraSlashJournal",
"modifier": 1,
"name": "ValidatorSlashInEra",
"modifier": 0,
"type": {
"DoubleMap": {
"hasher": "Blake2_256",
"key1": "EraIndex",
"key2": "AccountId",
"value": "(Perbill,BalanceOf)",
"key2Hasher": "Twox128"
}
},
"fallback": "0x00",
"documentation": [
" All slashing events on validators, mapped by era to the highest slash proportion",
" and slash value of the era."
]
},
{
"name": "NominatorSlashInEra",
"modifier": 0,
"type": {
"DoubleMap": {
"hasher": "Blake2_256",
"key1": "EraIndex",
"key2": "AccountId",
"value": "BalanceOf",
"key2Hasher": "Twox128"
}
},
"fallback": "0x00",
"documentation": [
" All slashing events on nominators, mapped by era to the highest slash value of the era."
]
},
{
"name": "SlashingSpans",
"modifier": 0,
"type": {
"Map": {
"hasher": "Blake2_256",
"key": "EraIndex",
"value": "Vec<SlashJournalEntry>",
"key": "AccountId",
"value": "SlashingSpans",
"linked": false
}
},
"fallback": "0x00",
"documentation": [
" All slashes that have occurred in a given era."
" Slashing spans for stash accounts."
]
},
{
"name": "SpanSlash",
"modifier": 1,
"type": {
"Map": {
"hasher": "Blake2_256",
"key": "(AccountId,SpanIndex)",
"value": "SpanRecord",
"linked": false
}
},
"fallback": "0x0000000000000000000000000000000000000000000000000000000000000000",
"documentation": [
" Records information about the maximum slash of a stash within a slashing span,",
" as well as how much reward has been paid out."
]
},
{
"name": "EarliestUnappliedSlash",
"modifier": 0,
"type": {
"Plain": "EraIndex"
},
"fallback": "0x00",
"documentation": [
" The earliest era for which we have a pending, unapplied slash."
]
},
{
"name": "StorageVersion",
"modifier": 1,
"type": {
"Plain": "u32"
},
"fallback": "0x00000000",
"documentation": [
" The version of storage for upgrade."
]
}
]
@@ -1533,6 +1638,28 @@
" - One storage write",
" # </weight>"
]
},
{
"name": "cancel_deferred_slash",
"args": [
{
"name": "era",
"type": "EraIndex"
},
{
"name": "slash_indices",
"type": "Vec<u32>"
}
],
"documentation": [
" Cancel enactment of a deferred slash. Can be called by either the root origin or",
" the `T::SlashCancelOrigin`.",
" passing the era and indices of the slashes for that era to kill.",
"",
" # <weight>",
" - One storage write.",
" # </weight>"
]
}
],
"events": [
@@ -1766,11 +1893,28 @@
"name": "PublicProps",
"modifier": 1,
"type": {
"Plain": "Vec<(PropIndex,Proposal,AccountId)>"
"Plain": "Vec<(PropIndex,Hash,AccountId)>"
},
"fallback": "0x00",
"documentation": [
" The public proposals. Unsorted."
" The public proposals. Unsorted. The second item is the proposal's hash."
]
},
{
"name": "Preimages",
"modifier": 0,
"type": {
"Map": {
"hasher": "Blake2_256",
"key": "Hash",
"value": "(Bytes,AccountId,BalanceOf,BlockNumber)",
"linked": false
}
},
"fallback": "0x00",
"documentation": [
" Map of hashes to the proposal preimage, along with who registered it and their deposit.",
" The block number is the block at which it was deposited."
]
},
{
@@ -1832,9 +1976,9 @@
"modifier": 1,
"type": {
"Map": {
"hasher": "Blake2_256",
"hasher": "Twox64Concat",
"key": "BlockNumber",
"value": "Vec<Option<(Proposal,ReferendumIndex)>>",
"value": "Vec<Option<(Hash,ReferendumIndex)>>",
"linked": false
}
},
@@ -1927,7 +2071,7 @@
"name": "NextExternal",
"modifier": 0,
"type": {
"Plain": "(Proposal,VoteThreshold)"
"Plain": "(Hash,VoteThreshold)"
},
"fallback": "0x00",
"documentation": [
@@ -1977,8 +2121,8 @@
"name": "propose",
"args": [
{
"name": "proposal",
"type": "Proposal"
"name": "proposal_hash",
"type": "Hash"
},
{
"name": "value",
@@ -2072,8 +2216,8 @@
"name": "external_propose",
"args": [
{
"name": "proposal",
"type": "Proposal"
"name": "proposal_hash",
"type": "Hash"
}
],
"documentation": [
@@ -2085,8 +2229,8 @@
"name": "external_propose_majority",
"args": [
{
"name": "proposal",
"type": "Proposal"
"name": "proposal_hash",
"type": "Hash"
}
],
"documentation": [
@@ -2101,8 +2245,8 @@
"name": "external_propose_default",
"args": [
{
"name": "proposal",
"type": "Proposal"
"name": "proposal_hash",
"type": "Hash"
}
],
"documentation": [
@@ -2258,6 +2402,59 @@
" - O(1).",
" # </weight>"
]
},
{
"name": "clear_public_proposals",
"args": [],
"documentation": [
" Veto and blacklist the proposal hash. Must be from Root origin."
]
},
{
"name": "note_preimage",
"args": [
{
"name": "encoded_proposal",
"type": "Bytes"
}
],
"documentation": [
" Register the preimage for an upcoming proposal. This doesn't require the proposal to be",
" in the dispatch queue but does require a deposit, returned once enacted."
]
},
{
"name": "note_imminent_preimage",
"args": [
{
"name": "encoded_proposal",
"type": "Bytes"
},
{
"name": "when",
"type": "BlockNumber"
},
{
"name": "which",
"type": "u32"
}
],
"documentation": [
" Register the preimage for an upcoming proposal. This requires the proposal to be",
" in the dispatch queue. No deposit is needed."
]
},
{
"name": "reap_preimage",
"args": [
{
"name": "proposal_hash",
"type": "Hash"
}
],
"documentation": [
" Remove an expired proposal preimage and collect the deposit."
]
}
],
"events": [
@@ -2267,7 +2464,9 @@
"PropIndex",
"Balance"
],
"documentation": []
"documentation": [
" A motion has been proposed by a public account."
]
},
{
"name": "Tabled",
@@ -2276,12 +2475,16 @@
"Balance",
"Vec<AccountId>"
],
"documentation": []
"documentation": [
" A public proposal has been tabled for referendum vote."
]
},
{
"name": "ExternalTabled",
"args": [],
"documentation": []
"documentation": [
" An external proposal has been tabled."
]
},
{
"name": "Started",
@@ -2289,28 +2492,36 @@
"ReferendumIndex",
"VoteThreshold"
],
"documentation": []
"documentation": [
" A referendum has begun."
]
},
{
"name": "Passed",
"args": [
"ReferendumIndex"
],
"documentation": []
"documentation": [
" A proposal has been approved by referendum."
]
},
{
"name": "NotPassed",
"args": [
"ReferendumIndex"
],
"documentation": []
"documentation": [
" A proposal has been rejected by referendum."
]
},
{
"name": "Cancelled",
"args": [
"ReferendumIndex"
],
"documentation": []
"documentation": [
" A referendum has been cancelled."
]
},
{
"name": "Executed",
@@ -2318,7 +2529,9 @@
"ReferendumIndex",
"bool"
],
"documentation": []
"documentation": [
" A proposal has been enacted."
]
},
{
"name": "Delegated",
@@ -2326,14 +2539,18 @@
"AccountId",
"AccountId"
],
"documentation": []
"documentation": [
" An account has delegated their vote to another account."
]
},
{
"name": "Undelegated",
"args": [
"AccountId"
],
"documentation": []
"documentation": [
" An account has cancelled a previous delegation operation."
]
},
{
"name": "Vetoed",
@@ -2342,7 +2559,63 @@
"Hash",
"BlockNumber"
],
"documentation": []
"documentation": [
" An external proposal has been vetoed."
]
},
{
"name": "PreimageNoted",
"args": [
"Hash",
"AccountId",
"Balance"
],
"documentation": [
" A proposal's preimage was noted, and the deposit taken."
]
},
{
"name": "PreimageUsed",
"args": [
"Hash",
"AccountId",
"Balance"
],
"documentation": [
" A proposal preimage was removed and used (the deposit was returned)."
]
},
{
"name": "PreimageInvalid",
"args": [
"Hash",
"ReferendumIndex"
],
"documentation": [
" A proposal could not be executed because its preimage was invalid."
]
},
{
"name": "PreimageMissing",
"args": [
"Hash",
"ReferendumIndex"
],
"documentation": [
" A proposal could not be executed because its preimage was missing."
]
},
{
"name": "PreimageReaped",
"args": [
"Hash",
"AccountId",
"Balance",
"AccountId"
],
"documentation": [
" A registered preimage was removed and the deposit collected by the reaper (last item)."
]
}
],
"constants": [
@@ -2397,6 +2670,14 @@
"documentation": [
" Period in blocks where an external proposal may not be re-submitted after being vetoed."
]
},
{
"name": "PreimageByteDeposit",
"type": "BalanceOf",
"value": "0x0010a5d4e80000000000000000000000",
"documentation": [
" The amount of balance that must be deposited per byte of preimage stored."
]
}
],
"errors": []
@@ -3205,6 +3486,20 @@
"",
" May only be called from `ResetOrigin` or root."
]
},
{
"name": "change_key",
"args": [
{
"name": "new",
"type": "AccountId"
}
],
"documentation": [
" Swap out the sending member for some other key `new`.",
"",
" May only be called from `Signed` origin of a current member."
]
}
],
"events": [
@@ -3236,6 +3531,13 @@
" The membership was reset; see the transaction for who the new set is."
]
},
{
"name": "KeyChanged",
"args": [],
"documentation": [
" One of the members' keys changed."
]
},
{
"name": "Dummy",
"args": [
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -26,7 +26,7 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.7.4",
"@babel/runtime": "^7.7.5",
"@polkadot/jsonrpc": "^0.99.0-beta.3",
"@polkadot/rpc-provider": "^0.99.0-beta.3",
"@polkadot/types": "^0.99.0-beta.3",
+2 -2
View File
@@ -26,13 +26,13 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.7.4",
"@babel/runtime": "^7.7.5",
"@polkadot/metadata": "^0.99.0-beta.3",
"@polkadot/util": "^1.7.1",
"@polkadot/util-crypto": "^1.7.1",
"eventemitter3": "^4.0.0",
"isomorphic-fetch": "^2.2.1",
"websocket": "^1.0.30"
"websocket": "^1.0.31"
},
"devDependencies": {
"@polkadot/keyring": "^1.7.1",
+1 -1
View File
@@ -26,6 +26,6 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-jsonrpc#readme",
"dependencies": {
"@babel/runtime": "^7.7.4"
"@babel/runtime": "^7.7.5"
}
}
+1 -1
View File
@@ -26,7 +26,7 @@
},
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.7.4",
"@babel/runtime": "^7.7.5",
"@polkadot/metadata": "^0.99.0-beta.3",
"@polkadot/util": "^1.7.1",
"@polkadot/util-crypto": "^1.7.1",
@@ -13,7 +13,7 @@ import json3 from '../../json/EventRecord.003.json';
describe('EventRecord', (): void => {
const registry = new TypeRegistry();
describe('EventRecord_0_76', (): void => {
describe('EventRecordTo76', (): void => {
beforeEach((): void => {
// eslint-disable-next-line no-new
new Metadata(registry, rpcMetadataV0);
@@ -46,7 +46,8 @@ describe('EventRecord', (): void => {
const er = records[0];
expect(er.phase.type).toEqual('ApplyExtrinsic');
expect(records.toHex()).toEqual(hex);
// additional payment info
expect(records.toHex()).toEqual(`${hex}000000000000`);
});
});
});