Adjust Edgeware types (imports) (#2294)

* Adjust Edgeware types (imports)

* Bump deps
This commit is contained in:
Jaco Greeff 2020-02-20 14:20:28 +01:00 committed by GitHub
parent 247987df8b
commit ecef8ca8cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 362 additions and 65 deletions

View File

@ -10,10 +10,10 @@
"packages/*"
],
"resolutions": {
"@polkadot/api": "^1.4.0-beta.10",
"@polkadot/api-contract": "^1.4.0-beta.10",
"@polkadot/api": "^1.4.0-beta.16",
"@polkadot/api-contract": "^1.4.0-beta.16",
"@polkadot/keyring": "^2.4.1",
"@polkadot/types": "^1.4.0-beta.10",
"@polkadot/types": "^1.4.0-beta.16",
"@polkadot/util": "^2.4.1",
"@polkadot/util-crypto": "^2.4.1",
"babel-core": "^7.0.0-bridge.0",
@ -38,7 +38,7 @@
"@babel/core": "^7.8.4",
"@babel/register": "^7.8.3",
"@babel/runtime": "^7.8.4",
"@polkadot/dev": "^0.40.18",
"@polkadot/dev": "^0.40.19",
"@polkadot/ts": "^0.2.3",
"@types/bn.js": "^4.11.6",
"@types/chart.js": "^2.9.11",

View File

@ -12,6 +12,6 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.8.4",
"@polkadot/api-contract": "^1.4.0-beta.10"
"@polkadot/api-contract": "^1.4.0-beta.16"
}
}

View File

@ -31,7 +31,7 @@
"homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme",
"dependencies": {
"@babel/runtime": "^7.8.4",
"@polkadot/api": "^1.4.0-beta.10",
"@polkadot/api": "^1.4.0-beta.16",
"@polkadot/extension-dapp": "^0.22.0-beta.4",
"edgeware-node-types": "^1.1.0",
"rxjs-compat": "^6.5.3"

View File

@ -0,0 +1,90 @@
/* eslint-disable comma-dangle */
/* eslint-disable lines-between-class-members */
/* eslint-disable @typescript-eslint/camelcase */
import { Bytes, Text, u32, Null } from '@polkadot/types';
import { Option, Struct, Enum } from '@polkadot/types/codec';
import { AccountId } from '@polkadot/types/interfaces';
import { Registry } from '@polkadot/types/types';
export class MetadataRecord extends Struct {
constructor (registry: Registry, value: any) {
super(registry, {
avatar: Text,
display_name: Text,
tagline: Text,
}, value);
}
get avatar (): Text {
return this.get('avatar') as Text;
}
get display_name (): Text {
return this.get('display_name') as Text;
}
get tagline (): Text {
return this.get('tagline') as Text;
}
}
export class Registered extends Null { }
export class Attested extends Null { }
export class Verified extends Null { }
export class IdentityStage extends Enum {
constructor (registry: Registry, value?: string, index?: number) {
super(registry, {
registered: Registered,
attested: Attested,
verified: Verified,
}, value, index);
}
}
export class IdentityRecord extends Struct {
constructor (registry: Registry, value: any) {
super(registry, {
account: 'AccountId',
identity_type: Text,
identity: Bytes,
stage: IdentityStage,
expiration_time: u32,
proof: Option.with(Text),
metadata: Option.with(MetadataRecord),
}, value);
}
get account (): AccountId {
return this.get('account') as AccountId;
}
get identity (): Bytes {
return this.get('identity') as Bytes;
}
get stage (): IdentityStage {
return this.get('stage') as IdentityStage;
}
get expiration_time (): u32 {
return this.get('expiration_time') as u32;
}
get proof (): Option<Text> {
return this.get('proof') as Option<Text>;
}
get metadata (): Option<MetadataRecord> {
return this.get('metadata') as Option<MetadataRecord>;
}
}
// Old types that aren't used anymore (kept for backwards compatability)
const ArchivedTypes = {
IdentityIndex: u32,
Claim: Bytes,
};
// Current types
const CurrentTypes = {
IdentityStage,
IdentityRecord,
MetadataRecord,
IdentityType: Text,
Attestation: Bytes,
Identity: Bytes,
};
export const IdentityTypes = { ...ArchivedTypes, ...CurrentTypes };

View File

@ -0,0 +1,11 @@
import { IdentityTypes } from './identity';
import { SignalingTypes } from './signaling';
import { TreasuryRewardTypes } from './treasuryReward';
import { VotingTypes } from './voting';
export const EdgewareTypes = {
...IdentityTypes,
...SignalingTypes,
...TreasuryRewardTypes,
...VotingTypes
};

View File

@ -0,0 +1,54 @@
/* eslint-disable comma-dangle */
/* eslint-disable lines-between-class-members */
/* eslint-disable @typescript-eslint/camelcase */
import { u32, Text, u64, Bytes } from '@polkadot/types';
import { Struct } from '@polkadot/types/codec';
import { AccountId } from '@polkadot/types/interfaces';
import { Registry } from '@polkadot/types/types';
import { VotingTypes, VoteStage } from './voting';
export class ProposalRecord extends Struct {
constructor (registry: Registry, value: any) {
super(registry, {
index: u32,
author: 'AccountId',
stage: VoteStage,
transition_time: u32,
title: Text,
contents: Text,
vote_id: u64,
}, value);
}
get index (): u32 {
return this.get('index') as u32;
}
get author (): AccountId {
return this.get('author') as AccountId;
}
get stage (): VoteStage {
return this.get('stage') as VoteStage;
}
get transition_time (): u32 {
return this.get('transition_time') as u32;
}
get title (): Text {
return this.get('title') as Text;
}
get contents (): Text {
return this.get('contents') as Text;
}
get vote_id (): u64 {
return this.get('vote_id') as u64;
}
}
export const SignalingTypes = {
PreVoting: VotingTypes.PreVoting,
Voting: VotingTypes.Voting,
Completed: VotingTypes.Completed,
Commit: VotingTypes.Commit,
VoteStage,
ProposalRecord,
ProposalContents: Bytes,
ProposalTitle: Bytes,
};

View File

@ -0,0 +1,7 @@
import { u128 } from '@polkadot/types';
export class Balance2 extends u128 { }
export const TreasuryRewardTypes = {
Balance2
};

View File

@ -0,0 +1,134 @@
/* eslint-disable comma-dangle */
/* eslint-disable lines-between-class-members */
/* eslint-disable @typescript-eslint/camelcase */
import { Null, bool, u64, Enum, Struct, Vec, Tuple, Option, u128 } from '@polkadot/types';
import U8aFixed from '@polkadot/types/codec/U8aFixed';
import { AccountId } from '@polkadot/types/interfaces';
import { AnyU8a, Registry } from '@polkadot/types/types';
export class PreVoting extends Null { }
export class Commit extends Null { }
export class Voting extends Null { }
export class Completed extends Null { }
export class VoteStage extends Enum {
constructor (registry: Registry, value?: string, index?: number) {
super(registry, {
prevoting: PreVoting,
commit: Commit,
voting: Voting,
completed: Completed,
}, value, index);
}
}
export class Binary extends Null { }
export class MultiOption extends Null { }
export class RankedChoice extends Null { }
export class VoteType extends Enum {
constructor (registry: Registry, value?: string, index?: number) {
super(registry, {
binary: Binary,
multioption: MultiOption,
rankedchoice: RankedChoice,
}, value, index);
}
}
export class OnePerson extends Null { }
export class OneCoin extends Null { }
export class TallyType extends Enum {
constructor (registry: Registry, value?: string, index?: number) {
super(registry, {
oneperson: OnePerson,
onecoin: OneCoin,
}, value, index);
}
}
export class VoteOutcome extends U8aFixed {
constructor (registry: Registry, value?: AnyU8a) {
super(registry, value, 256);
}
}
export class Tally extends Option.with(Vec.with(Tuple.with([VoteOutcome, u128]))) { }
export class VoteData extends Struct {
constructor (registry: Registry, value: any) {
super(registry, {
initiator: 'AccountId',
stage: VoteStage,
vote_type: VoteType,
tally_type: TallyType,
is_commit_reveal: bool,
}, value);
}
get initiator (): AccountId {
return this.get('initiator') as AccountId;
}
get stage (): VoteStage {
return this.get('stage') as VoteStage;
}
get vote_type (): VoteType {
return this.get('vote_type') as VoteType;
}
get tally_type (): TallyType {
return this.get('tally_type') as TallyType;
}
get is_commit_reveal (): bool {
return this.get('is_commit_reveal') as bool;
}
}
export class Commitments extends Vec.with(Tuple.with(['AccountId', VoteOutcome])) { }
export class Reveals extends Vec.with(Tuple.with(['AccountId', Vec.with(VoteOutcome)])) { }
export class VoteRecord extends Struct {
constructor (registry: Registry, value: any) {
super(registry, {
id: u64,
commitments: Commitments,
reveals: Reveals,
data: VoteData,
outcomes: Vec.with(VoteOutcome),
}, value);
}
get id (): u64 {
return this.get('id') as u64;
}
get commitments (): Commitments {
return this.get('commits') as Commitments;
}
get reveals (): Reveals {
return this.get('reveals') as Reveals;
}
get data (): VoteData {
return this.get('data') as VoteData;
}
get outcomes (): Vec<VoteOutcome> {
return this.get('outcomes') as Vec<VoteOutcome>;
}
}
export const VotingTypes = {
PreVoting,
Commit,
Voting,
Completed,
VoteStage,
Binary,
MultiOption,
VoteType,
OnePerson,
OneCoin,
TallyType,
VoteOutcome,
Tally,
VoteData,
VoteRecord,
'voting::VoteType': VoteType,
'voting::TallyType': TallyType,
};

View File

@ -2,7 +2,8 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { EdgewareTypes } from 'edgeware-node-types/dist';
// import { EdgewareTypes } from 'edgeware-node-types/dist';
import { EdgewareTypes } from './edgeware-node-types';
export default {
...EdgewareTypes,

116
yarn.lock
View File

@ -2200,57 +2200,57 @@
dependencies:
"@types/node" ">= 8"
"@polkadot/api-contract@^1.4.0-beta.10":
version "1.4.0-beta.10"
resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-1.4.0-beta.10.tgz#6d84b57495c7d044d7b43c9adb2e55bce718833c"
integrity sha512-5SybvwGerQ+Mgb86+tEqMG5jClfRkaOpvNz/UnsFC+RVNXEqGSR/U7z1pLUEPqjMZc8u1SUdxoOtBZaAwKss6A==
"@polkadot/api-contract@^1.4.0-beta.16":
version "1.4.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-1.4.0-beta.16.tgz#0ee1a7950380fd8543064b21b650438f10667f36"
integrity sha512-mOf2vis0J6tO7rjmy2qxt039/YNwcn0uGVauE05ZjTTUSnBcuFqD8axohyPu/htvAfviLXTxIqx8rBgw/rAc/g==
dependencies:
"@babel/runtime" "^7.8.4"
"@polkadot/api" "^1.4.0-beta.10"
"@polkadot/rpc-core" "^1.4.0-beta.10"
"@polkadot/types" "^1.4.0-beta.10"
"@polkadot/api" "1.4.0-beta.16"
"@polkadot/rpc-core" "1.4.0-beta.16"
"@polkadot/types" "1.4.0-beta.16"
"@polkadot/util" "^2.4.1"
bn.js "^5.1.1"
rxjs "^6.5.4"
"@polkadot/api-derive@^1.4.0-beta.10":
version "1.4.0-beta.10"
resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-1.4.0-beta.10.tgz#939a9a9aaba19bfd030da915b27058c64e9cafe7"
integrity sha512-Q8pWBc6bCdd3qJingum423dKV+QpfhH+/+k6w0tpVpZV8GikrW+yEbXrm9d5DIZEEOxQL8tVVcS9DiKgnUtdJA==
"@polkadot/api-derive@1.4.0-beta.16":
version "1.4.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-1.4.0-beta.16.tgz#d294d75ec8cb3c4880c914fb32d6e30bfbc6ad3c"
integrity sha512-9wErURD85sTMJigii+FTODwAUCUygYChMR94Q5OIoiV5yFkpxJHcOhfvswlzLIS4YbodFEy8qFSHfC4mrSWx0w==
dependencies:
"@babel/runtime" "^7.8.4"
"@polkadot/api" "^1.4.0-beta.10"
"@polkadot/rpc-core" "^1.4.0-beta.10"
"@polkadot/rpc-provider" "^1.4.0-beta.10"
"@polkadot/types" "^1.4.0-beta.10"
"@polkadot/api" "1.4.0-beta.16"
"@polkadot/rpc-core" "1.4.0-beta.16"
"@polkadot/rpc-provider" "1.4.0-beta.16"
"@polkadot/types" "1.4.0-beta.16"
"@polkadot/util" "^2.4.1"
"@polkadot/util-crypto" "^2.4.1"
bn.js "^5.1.1"
memoizee "^0.4.14"
rxjs "^6.5.4"
"@polkadot/api@^1.4.0-beta.10":
version "1.4.0-beta.10"
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-1.4.0-beta.10.tgz#f68c88033ca689acc970c846aacb28ec6343fc39"
integrity sha512-YehdEiF/hn/pMl7Gz/JVT37r3ntMZftL31VVniiFmU3ZUzqU6bwQ8pITtf6co202lOKsnPfXLGPxcF6tW7Flbg==
"@polkadot/api@1.4.0-beta.16", "@polkadot/api@^1.4.0-beta.16":
version "1.4.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-1.4.0-beta.16.tgz#fb0d3fda370b589d44bfb549f3d9edb05cc1b683"
integrity sha512-Vuw31PStYxbTG8YXMbXhuMR7JXq4Wi6tMirHjmX1SHtYvQTX16WHRJJDB2EPqDaewXhsFNMs4ozhQFcQy3kbUw==
dependencies:
"@babel/runtime" "^7.8.4"
"@polkadot/api-derive" "^1.4.0-beta.10"
"@polkadot/api-derive" "1.4.0-beta.16"
"@polkadot/keyring" "^2.4.1"
"@polkadot/metadata" "^1.4.0-beta.10"
"@polkadot/rpc-core" "^1.4.0-beta.10"
"@polkadot/rpc-provider" "^1.4.0-beta.10"
"@polkadot/types" "^1.4.0-beta.10"
"@polkadot/metadata" "1.4.0-beta.16"
"@polkadot/rpc-core" "1.4.0-beta.16"
"@polkadot/rpc-provider" "1.4.0-beta.16"
"@polkadot/types" "1.4.0-beta.16"
"@polkadot/util" "^2.4.1"
"@polkadot/util-crypto" "^2.4.1"
bn.js "^5.1.1"
eventemitter3 "^4.0.0"
rxjs "^6.5.4"
"@polkadot/dev@^0.40.18":
version "0.40.18"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.40.18.tgz#6ca40304bcc7c75b26c0190d60cb5b892a512dc5"
integrity sha512-SEkmrdZPYcnFzXnfpIjnvNfrwdBS3uAenEt8ZYBMkay59+XgFnPKi7xKV92x5iGYEiAXfcKFYjCAN0Nk2rXV5Q==
"@polkadot/dev@^0.40.19":
version "0.40.19"
resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.40.19.tgz#885860e8acc4cf965303034961c05b862ca49bd4"
integrity sha512-Di+5UMR5rX/HQZWFqDw4gArG+aZnZKwNSQZqHNXda+l25wXRAHCTOsSSu+3s/HgAtDSv4ENkWTioasnbeibiig==
dependencies:
"@babel/cli" "^7.8.4"
"@babel/core" "^7.8.4"
@ -2323,13 +2323,13 @@
dependencies:
"@babel/runtime" "^7.8.4"
"@polkadot/jsonrpc@^1.4.0-beta.10":
version "1.4.0-beta.10"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-1.4.0-beta.10.tgz#b1b37d6b50b10582688386fdecff961264cfe9f4"
integrity sha512-OmD5ywWrulKQJXsoy4oORbV3u1pGmiltGXclgHvHwCM1rxz9vr2YLKr/q96vafqhS9KzdJ+bwKGxHVWjmQV+bg==
"@polkadot/jsonrpc@1.4.0-beta.16":
version "1.4.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-1.4.0-beta.16.tgz#943b4bcb5804aa8024a6c7d2e1b61bf3a9fdcbbd"
integrity sha512-LlsVCd5prqwLboXivDaZP1tIBVVhsZ7o7M9X/0sUUxnhuI0Ih9NEEHzSMrmVdgEctOpIGL6oXYpWvsK8dWcqHw==
dependencies:
"@babel/runtime" "^7.8.4"
"@polkadot/types" "^1.4.0-beta.10"
"@polkadot/types" "1.4.0-beta.16"
"@polkadot/util" "^2.4.1"
"@polkadot/keyring@^2.4.1":
@ -2341,13 +2341,13 @@
"@polkadot/util" "^2.4.1"
"@polkadot/util-crypto" "^2.4.1"
"@polkadot/metadata@^1.4.0-beta.10":
version "1.4.0-beta.10"
resolved "https://registry.yarnpkg.com/@polkadot/metadata/-/metadata-1.4.0-beta.10.tgz#3b8ae0906db8f3573f586767f3ea48b28842f833"
integrity sha512-SUd/F9ff3Is730Y2dnn/ZqIaVFJpgwcH4k01LTdsOGV1+mUqNlAHeV4JEFF69x+x4Dy48Avutf3Z3SLBiEIOLw==
"@polkadot/metadata@1.4.0-beta.16":
version "1.4.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/metadata/-/metadata-1.4.0-beta.16.tgz#798e83474df49c289292f7e3e3678ce8c3715a57"
integrity sha512-1m/S1DVR8fSJSQa0oICPhMQYfDAeZO7CslnPGyEBAVVqHvE7grTsiMblkjVQ3omqf9NmHoMthOd/G2nfeFCcXQ==
dependencies:
"@babel/runtime" "^7.8.4"
"@polkadot/types" "^1.4.0-beta.10"
"@polkadot/types" "1.4.0-beta.16"
"@polkadot/util" "^2.4.1"
"@polkadot/util-crypto" "^2.4.1"
bn.js "^5.1.1"
@ -2374,29 +2374,29 @@
qrcode-generator "^1.4.4"
react-qr-reader "^2.2.1"
"@polkadot/rpc-core@^1.4.0-beta.10":
version "1.4.0-beta.10"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-1.4.0-beta.10.tgz#10cc193ebe6183a9e8a83d04e782213465cbba5b"
integrity sha512-d0/K2t6RN/y5hveOKJMDEf7f+vlTlNfWiXcFrohLGDIgCabDvjpErl7zzWdXIkiukTZwoh3Wsa2BT9PwoqPpdQ==
"@polkadot/rpc-core@1.4.0-beta.16":
version "1.4.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-1.4.0-beta.16.tgz#717c31fd967718e1cc3f5ce1a2a41319f03f34c6"
integrity sha512-8hSOCxtseWLJDnzAw52pXASWc/TUeyXhMmdhk/ZUq3QjymP4CpqyuTJojYfXyQQERjJb4hENaDzlmmrKk32Kkw==
dependencies:
"@babel/runtime" "^7.8.4"
"@polkadot/jsonrpc" "^1.4.0-beta.10"
"@polkadot/metadata" "^1.4.0-beta.10"
"@polkadot/rpc-provider" "^1.4.0-beta.10"
"@polkadot/types" "^1.4.0-beta.10"
"@polkadot/jsonrpc" "1.4.0-beta.16"
"@polkadot/metadata" "1.4.0-beta.16"
"@polkadot/rpc-provider" "1.4.0-beta.16"
"@polkadot/types" "1.4.0-beta.16"
"@polkadot/util" "^2.4.1"
memoizee "^0.4.14"
rxjs "^6.5.4"
"@polkadot/rpc-provider@^1.4.0-beta.10":
version "1.4.0-beta.10"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-1.4.0-beta.10.tgz#d54d541f5022de625973d922fcd52490237ddea2"
integrity sha512-C5Gp643pYpTsTSMZiS0FjVQAztzAvekgWgv+eHR8F2s2SBRxB9e4mW5KmL8e12Lx8/2lknPNTuRlItLp08gRcw==
"@polkadot/rpc-provider@1.4.0-beta.16":
version "1.4.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-1.4.0-beta.16.tgz#12efd9833c1cd5d538572152964c6cfcf3f27435"
integrity sha512-MwA5Esw+9857BmLpjQq4U2q1/CRqku+Xza1rwZkm3+HZ6cMy3sdPf5DkXA5/1sW5wtLX0HfRph9HDuWERERaDQ==
dependencies:
"@babel/runtime" "^7.8.4"
"@polkadot/jsonrpc" "^1.4.0-beta.10"
"@polkadot/metadata" "^1.4.0-beta.10"
"@polkadot/types" "^1.4.0-beta.10"
"@polkadot/jsonrpc" "1.4.0-beta.16"
"@polkadot/metadata" "1.4.0-beta.16"
"@polkadot/types" "1.4.0-beta.16"
"@polkadot/util" "^2.4.1"
"@polkadot/util-crypto" "^2.4.1"
bn.js "^5.1.1"
@ -2411,13 +2411,13 @@
dependencies:
"@types/chrome" "^0.0.95"
"@polkadot/types@^1.4.0-beta.10":
version "1.4.0-beta.10"
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-1.4.0-beta.10.tgz#c2e410d6e96f99bc59785288e68a467141d95179"
integrity sha512-cKM086+5MLbAm38+SEhsCer+yRCzP9SVIsYc41XkeERgT18I0v0SI1m2noZKnzlEUBdiR9T1bIuqXupmiTDexg==
"@polkadot/types@1.4.0-beta.16", "@polkadot/types@^1.4.0-beta.16":
version "1.4.0-beta.16"
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-1.4.0-beta.16.tgz#8446432fda47003f4eec8a43efcd7c5f41c8b666"
integrity sha512-cDcNKwgagV0dZGNYJjpKBcFDFYTuCQSmbDh69XuJe1E0YZtqTiXp8irWdb5hixjPhEQZ8mxQv8VxYs8G7Stptg==
dependencies:
"@babel/runtime" "^7.8.4"
"@polkadot/metadata" "^1.4.0-beta.10"
"@polkadot/metadata" "1.4.0-beta.16"
"@polkadot/util" "^2.4.1"
"@polkadot/util-crypto" "^2.4.1"
"@types/bn.js" "^4.11.6"