Bump metadata, allow type alias on events (#2351)

* Bump metadata, allow type alias on events

* Update packages/api/src/submittable/createClass.ts

* Update packages/metadata/src/Metadata/v11/static-substrate.json

* Fresh, no config changes
This commit is contained in:
Jaco Greeff
2020-06-12 23:15:50 +02:00
committed by GitHub
parent 6ef94b3c3b
commit 6a281211b4
7 changed files with 66 additions and 4 deletions
@@ -1499,6 +1499,39 @@
"documentation": [
" Some amount was deposited (e.g. for transaction fees)."
]
},
{
"name": "Reserved",
"args": [
"AccountId",
"Balance"
],
"documentation": [
" Some balance was reserved (moved from free to reserved)."
]
},
{
"name": "Unreserved",
"args": [
"AccountId",
"Balance"
],
"documentation": [
" Some balance was unreserved (moved from reserved to free)."
]
},
{
"name": "ReserveRepatriated",
"args": [
"AccountId",
"AccountId",
"Balance",
"BalanceStatus"
],
"documentation": [
" Some balance was moved from the reserve of the first account to the second account.",
" Final argument indicates the destination balance type."
]
}
],
"constants": [
File diff suppressed because one or more lines are too long
+17 -1
View File
@@ -2,7 +2,7 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { FunctionMetadataV11, FunctionMetadataLatest, MetadataV11, MetadataLatest, ModuleMetadataLatest, StorageMetadataV11, StorageMetadataLatest, StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
import { EventMetadataV11, EventMetadataLatest, FunctionMetadataV11, FunctionMetadataLatest, MetadataV11, MetadataLatest, ModuleMetadataLatest, StorageMetadataV11, StorageMetadataLatest, StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
import { Registry, OverrideModuleType } from '@polkadot/types/types';
import { getModuleTypes } from '@polkadot/types-known';
@@ -35,6 +35,18 @@ function convertCalls (registry: Registry, calls: FunctionMetadataV11[], section
});
}
/**
* Apply module-specific type overrides (always be done as part of toLatest)
* @internal
**/
function convertEvents (registry: Registry, events: EventMetadataV11[], sectionTypes: OverrideModuleType): EventMetadataLatest[] {
return events.map(({ args, documentation, name }): EventMetadataLatest => {
args.forEach((type): void => setTypeOverride(sectionTypes, type));
return registry.createType('EventMetadataLatest', { args, documentation, name });
});
}
/**
* Apply module-specific storage type overrides (always part of toLatest)
* @internal
@@ -70,6 +82,7 @@ export default function toLatest (registry: Registry, { extrinsic, modules }: Me
extrinsic,
modules: modules.map((mod): ModuleMetadataLatest => {
const calls = mod.calls.unwrapOr(null);
const events = mod.events.unwrapOr(null);
const storage = mod.storage.unwrapOr(null);
const sectionTypes = getModuleTypes(registry, stringCamelCase(mod.name.toString()));
@@ -78,6 +91,9 @@ export default function toLatest (registry: Registry, { extrinsic, modules }: Me
calls: calls
? convertCalls(registry, calls, sectionTypes)
: null,
events: events
? convertEvents(registry, events, sectionTypes)
: null,
storage: storage
? convertStorage(registry, storage, sectionTypes)
: null
+2 -1
View File
@@ -7,7 +7,8 @@ import { OverrideModuleType } from '@polkadot/types/types';
// type overrides for modules (where duplication between modules exist)
const typesModules: Record<string, OverrideModuleType> = {
balances: {
Releases: 'ReleasesBalances'
Releases: 'ReleasesBalances',
Status: 'BalanceStatus'
},
contract: { // old metadata & naming
// v2 & v3
+4 -1
View File
@@ -8,7 +8,7 @@ import { RawAuraPreDigest } from '@polkadot/types/interfaces/aura';
import { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
import { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
import { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeWeight, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
import { AccountData, BalanceLock, BalanceLockTo212, Reasons, ReleasesBalances, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
import { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReleasesBalances, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
import { BlockHash } from '@polkadot/types/interfaces/chain';
import { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
import { EthereumAddress, StatementKind } from '@polkadot/types/interfaces/claims';
@@ -384,6 +384,9 @@ declare module '@polkadot/types/types/registry' {
BalanceLock: BalanceLock;
'Option<BalanceLock>': Option<BalanceLock>;
'Vec<BalanceLock>': Vec<BalanceLock>;
BalanceStatus: BalanceStatus;
'Option<BalanceStatus>': Option<BalanceStatus>;
'Vec<BalanceStatus>': Vec<BalanceStatus>;
ReleasesBalances: ReleasesBalances;
'Option<ReleasesBalances>': Option<ReleasesBalances>;
'Vec<ReleasesBalances>': Vec<ReleasesBalances>;
@@ -27,6 +27,9 @@ export default {
amount: 'Balance',
reasons: 'Reasons'
},
BalanceStatus: {
_enum: ['Free', 'Reserved']
},
ReleasesBalances: {
_enum: ['V1_0_0', 'V2_0_0']
},
@@ -27,6 +27,12 @@ export interface BalanceLockTo212 extends Struct {
readonly reasons: WithdrawReasons;
}
/** @name BalanceStatus */
export interface BalanceStatus extends Enum {
readonly isFree: boolean;
readonly isReserved: boolean;
}
/** @name Reasons */
export interface Reasons extends Enum {
readonly isFee: boolean;