diff --git a/package.json b/package.json index 971d7db7..f8ed6789 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "dependencies": { "@babel/core": "^7.10.4", - "@kiltprotocol/sdk-js": "^0.19.1-34", + "@kiltprotocol/sdk-js": "^0.20.0-rc.2", "@polkadot/ui-identicon": "^0.33.1", "@types/react-select": "^2.0.11", "@types/reselect": "^2.2.0", diff --git a/src/components/DevTools/DevTools.anticov.ts b/src/components/DevTools/DevTools.anticov.ts index 95e39615..e4265734 100644 --- a/src/components/DevTools/DevTools.anticov.ts +++ b/src/components/DevTools/DevTools.anticov.ts @@ -43,7 +43,9 @@ let cachedSetup: ISetup function setup(): ISetup { if (!cachedSetup) { - const root = Identity.buildFromMnemonic(ROOT_SEED) + const root = Identity.buildFromMnemonic(ROOT_SEED, { + signingKeyPairType: 'ed25519', + }) const delegationRoot = new DelegationRootNode( DELEGATION_ROOT_ID, diff --git a/src/components/DevTools/DevTools.wallet.tsx b/src/components/DevTools/DevTools.wallet.tsx index 9f90c0c2..af7708c0 100644 --- a/src/components/DevTools/DevTools.wallet.tsx +++ b/src/components/DevTools/DevTools.wallet.tsx @@ -35,7 +35,9 @@ class BsIdentity { public static async create(alias: string): Promise { const randomPhrase = mnemonicGenerate() - const identity = Identity.buildFromMnemonic(randomPhrase) + const identity = Identity.buildFromMnemonic(randomPhrase, { + signingKeyPairType: 'ed25519', + }) return BsIdentity.save(identity, randomPhrase, alias) } diff --git a/src/containers/WalletAdd/WalletAdd.tsx b/src/containers/WalletAdd/WalletAdd.tsx index 2cfc6558..a9b81c42 100644 --- a/src/containers/WalletAdd/WalletAdd.tsx +++ b/src/containers/WalletAdd/WalletAdd.tsx @@ -1,11 +1,12 @@ import { Identity } from '@kiltprotocol/sdk-js' import * as mnemonic from '@polkadot/util-crypto/mnemonic' +import { KeypairType } from '@polkadot/util-crypto/types' import React from 'react' import { connect } from 'react-redux' import { RouteComponentProps } from 'react-router' import { Link, withRouter } from 'react-router-dom' +import Select from 'react-select' import DidService from '../../services/DidService' - import Input from '../../components/Input/Input' import { BalanceUtilities } from '../../services/BalanceUtilities' import ContactRepository from '../../services/ContactRepository' @@ -18,6 +19,11 @@ import { IContact, IMyIdentity } from '../../types/Contact' import './WalletAdd.scss' +type OptionsKeyPairType = { + label: string + value: KeypairType +} + type DispatchProps = { saveIdentity: (myIdentity: IMyIdentity) => void } @@ -30,19 +36,29 @@ type State = { randomPhrase: string useMyPhrase: boolean myPhrase: string + mySigningKeyPairType: OptionsKeyPairType + advancedOptions: boolean } +const keypairTypeOptions: OptionsKeyPairType[] = [ + { value: 'sr25519', label: 'SR25519' }, + { value: 'ed25519', label: 'ED25519' }, +] + class WalletAdd extends React.Component { constructor(props: Props) { super(props) this.state = { alias: '', myPhrase: '', + mySigningKeyPairType: keypairTypeOptions[0], pendingAdd: false, randomPhrase: mnemonic.mnemonicGenerate(), useMyPhrase: false, + advancedOptions: false, } this.togglePhrase = this.togglePhrase.bind(this) + this.toggleAdvancedOptions = this.toggleAdvancedOptions.bind(this) this.addIdentity = this.addIdentity.bind(this) } @@ -50,6 +66,14 @@ class WalletAdd extends React.Component { this.setState({ myPhrase: e.currentTarget.value }) } + private setMySigningKeyPairType = ( + selectedKeyPairType: OptionsKeyPairType + ): void => { + this.setState({ + mySigningKeyPairType: selectedKeyPairType, + }) + } + private setAlias = (e: React.ChangeEvent): void => { this.setState({ alias: e.currentTarget.value }) } @@ -65,14 +89,29 @@ class WalletAdd extends React.Component { }) } + private toggleAdvancedOptions(): void { + const { advancedOptions } = this.state + this.setState({ + advancedOptions: !advancedOptions, + }) + } + private async addIdentity(): Promise { - const { alias, myPhrase, randomPhrase, useMyPhrase } = this.state + const { + alias, + myPhrase, + randomPhrase, + useMyPhrase, + mySigningKeyPairType, + } = this.state const { history, saveIdentity } = this.props let identity const phrase = useMyPhrase ? myPhrase : randomPhrase try { - identity = Identity.buildFromMnemonic(phrase) + identity = Identity.buildFromMnemonic(phrase, { + signingKeyPairType: mySigningKeyPairType.value, + }) } catch (error) { errorService.log({ error, @@ -87,6 +126,7 @@ class WalletAdd extends React.Component { const newIdentity: IMyIdentity = { identity, + keypairType: mySigningKeyPairType.value, metaData: { name: alias, }, @@ -123,7 +163,10 @@ class WalletAdd extends React.Component { pendingAdd, useMyPhrase, myPhrase, + advancedOptions, + mySigningKeyPairType, } = this.state + return (

Create ID

@@ -177,6 +220,25 @@ class WalletAdd extends React.Component { Import Seed Phrase +
+ +
+ + {advancedOptions && ( +
+ +
+