From d16a4282eeb6249218634d677989c80ec4bee08a Mon Sep 17 00:00:00 2001 From: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com> Date: Sat, 29 Jun 2019 10:11:45 +0200 Subject: [PATCH] Support 1.x setKey & 2.x setKeys (#1322) * setKeys * new one first * use same sessionId with both keys --- .../src/Actions/Account/SetSessionAccount.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx b/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx index 9c090e6072..dff4bfc595 100644 --- a/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx +++ b/packages/app-staking/src/Actions/Account/SetSessionAccount.tsx @@ -2,15 +2,17 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { ApiProps } from '@polkadot/ui-api/types'; import { I18nProps } from '@polkadot/ui-app/types'; import React from 'react'; import { Button, InputAddress, Modal, TxButton } from '@polkadot/ui-app'; +import { withApi, withMulti } from '@polkadot/ui-api'; import ValidateSession from './InputValidationSession'; import translate from '../../translate'; -type Props = I18nProps & { +type Props = I18nProps & ApiProps & { controllerId: string, isOpen: boolean, onClose: () => void, @@ -36,8 +38,11 @@ class SetSessionKey extends React.PureComponent { } render () { - const { controllerId, isOpen, onClose, t } = this.props; + const { api, controllerId, isOpen, onClose, t } = this.props; const { sessionError, sessionId } = this.state; + const isV2 = !!api.tx.session.setKeys; + + console.log('sessionId', sessionId); if (!isOpen) { return null; @@ -65,8 +70,8 @@ class SetSessionKey extends React.PureComponent { isPrimary label={t('Set Session Key')} onClick={ onClose } - params={[sessionId]} - tx='session.setKey' + params={ isV2 ? [{ auraKey: sessionId, grandpaKey: sessionId }, new Uint8Array([])] : [sessionId]} + tx={isV2 ? 'session.setKeys' : 'session.setKey'} /> @@ -118,4 +123,8 @@ class SetSessionKey extends React.PureComponent { } } -export default translate(SetSessionKey); +export default withMulti( + SetSessionKey, + translate, + withApi +);