Unverified Commit da57bd3a authored by Hanwen Cheng's avatar Hanwen Cheng Committed by GitHub
Browse files

fix: use seed root account as first default key pair (#636)

* chore: generate seed root account as seed default account

* adjust e2e test

* make linter happy
parent 9e8d654a
Pipeline #96929 failed with stages
in 54 seconds
......@@ -108,6 +108,25 @@ export default function NetworkSelector({
return availableNetworks.includes(networkKey);
};
const deriveSubstrateSeedRootPath = async (
networkKey: string
): Promise<void> => {
await unlockSeedPhrase(navigation, seedRefHooks.isSeedRefValid);
const fullPath = '';
try {
await accounts.deriveNewPath(
fullPath,
seedRefHooks.substrateAddress,
networkKey,
'Root',
''
);
navigateToPathDetails(navigation, networkKey, fullPath);
} catch (error) {
alertPathDerivationError(error.message);
}
};
const deriveSubstrateNetworkRootPath = async (
networkKey: string,
networkParams: SubstrateNetworkParams
......@@ -193,7 +212,11 @@ export default function NetworkSelector({
): Promise<void> => {
if (isNew || shouldShowMoreNetworks) {
if (isSubstrateNetworkParams(networkParams)) {
await deriveSubstrateNetworkRootPath(networkKey, networkParams);
if (isNew) {
await deriveSubstrateSeedRootPath(networkKey);
} else {
await deriveSubstrateNetworkRootPath(networkKey, networkParams);
}
} else {
await deriveEthereumAccount(networkKey);
}
......
......@@ -24,7 +24,7 @@ const {
const passwordedPath = '//passworded';
const password = 'random';
describe('Load test', () => {
describe('passworded account test', () => {
testRecoverIdentity();
it('derive a passworded account', async () => {
......@@ -36,16 +36,6 @@ describe('Load test', () => {
});
describe('Kusama exporting test', () => {
it('is able to export a hard derived account', async () => {
await testTap(PathsList.pathCard + '//kusama');
await testTap(PathDetail.popupMenuButton);
await testTap(PathDetail.exportButton);
await testExist(
'secret:0xdf46d55a2d98695e9342b67edae6669e5c0b4e1a3895f1adf85989565b9ab827:0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe:Kusama root'
);
await tapBack();
});
it('is able to export a hard derived account with password', async () => {
await testTap(`${PathsList.pathCard}//kusama${passwordedPath}`);
await testTap(PathDetail.popupMenuButton);
......
......@@ -24,6 +24,7 @@ import {
pinCode,
tapBack,
testExist,
testInput,
testRecoverIdentity,
testScrollAndTap,
testTap,
......@@ -33,7 +34,15 @@ import {
import { ScanTestRequest } from 'e2e/mockScanRequests';
import testIDs from 'e2e/testIDs';
const { Main, PathDetail, SecurityHeader, SignedMessage, SignedTx } = testIDs;
const {
Main,
PathDerivation,
PathDetail,
PathsList,
SecurityHeader,
SignedMessage,
SignedTx
} = testIDs;
const testSignedTx = async (): Promise<void> => {
await testTap(SecurityHeader.scanButton);
......@@ -53,10 +62,27 @@ const testEthereumMessage = async (): Promise<void> => {
await testVisible(SignedMessage.qrView);
};
describe('Signing test', () => {
describe('Signing ane exporting test', () => {
testRecoverIdentity();
describe('Kusama Signing Test', () => {
it('Recover a Kusama signing account', async () => {
await testTap(PathsList.deriveButton);
await testInput(PathDerivation.pathInput, '');
await testInput(PathDerivation.nameInput, 'kusama root');
await testExist(PathsList.pathCard + '//kusama');
});
it('is able to export the signing account', async () => {
await testTap(PathsList.pathCard + '//kusama');
await testTap(PathDetail.popupMenuButton);
await testTap(PathDetail.exportButton);
await testExist(
'secret:0xdf46d55a2d98695e9342b67edae6669e5c0b4e1a3895f1adf85989565b9ab827:0xb0a8d493285c2df73290dfb7e61f870f17b41801197a149ca93654499ea3dafe:kusama root'
);
await tapBack();
});
it('should sign the set remarks request', async () => {
await launchWithScanRequest(ScanTestRequest.SetRemarkExtrinsicKusama);
await testSignedTx();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment