Skip to content
Merged
Prev Previous commit
Next Next commit
Open message rename
  • Loading branch information
jacogr committed May 30, 2020
commit 5e98803d646741c2cb3c5e305aad39acba21cc10
20 changes: 7 additions & 13 deletions packages/extension-base/src/background/handlers/Extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,6 @@ export default class Extension {
return { message: 'Could not restore account.' };
}

private jsonRestoreWindowOpen (): boolean {
chrome.tabs.create({
url: chrome.extension.getURL('index.html#/account/restore-json')
});

return true;
}

private jsonVerifyFile ({ json }: RequestJsonRestore): boolean {
try {
const publicKey = keyring.decodeAddress(json.address, true);
Expand Down Expand Up @@ -315,9 +307,11 @@ export default class Extension {
return true;
}

private windowOpen (): boolean {
private windowOpen (path = '/'): boolean {
console.error('open', `${chrome.extension.getURL('index.html')}#${path}`);

chrome.tabs.create({
url: chrome.extension.getURL('index.html')
url: `${chrome.extension.getURL('index.html')}#${path}`
});

return true;
Expand Down Expand Up @@ -415,9 +409,6 @@ export default class Extension {
case 'pri(json.restore)':
return this.jsonRestore(request as RequestJsonRestore);

case 'pri(json.restore.window.open)':
return this.jsonRestoreWindowOpen();

case 'pri(json.verify.file)':
return this.jsonVerifyFile(request as RequestJsonRestore);

Expand Down Expand Up @@ -445,6 +436,9 @@ export default class Extension {
case 'pri(window.open)':
return this.windowOpen();

case 'pri(window.open.json)':
return this.windowOpen('/account/restore-json');

default:
throw new Error(`Unable to handle message of type ${type}`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-base/src/background/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export interface RequestSignatures {
'pri(derivation.create)': [RequestDeriveCreate, boolean];
'pri(derivation.validate)': [RequestDeriveValidate, ResponseDeriveValidate];
'pri(json.restore)': [RequestJsonRestore, ResponseJsonRestore];
'pri(json.restore.window.open)': [null, boolean];
'pri(json.verify.file)': [RequestJsonRestore, boolean];
'pri(json.verify.password)': [string, boolean];
'pri(metadata.approve)': [RequestMetadataApprove, boolean];
Expand All @@ -91,6 +90,7 @@ export interface RequestSignatures {
'pri(signing.cancel)': [RequestSigningCancel, boolean];
'pri(signing.requests)': [RequestSigningSubscribe, boolean, SigningRequest[]];
'pri(window.open)': [null, boolean];
'pri(window.open.json)': [null, boolean];
// public/external requests, i.e. from a page
'pub(accounts.list)': [RequestAccountList, InjectedAccount[]];
'pub(accounts.subscribe)': [RequestAccountSubscribe, boolean, InjectedAccount[]];
Expand Down
2 changes: 1 addition & 1 deletion packages/extension-ui/src/messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export async function deriveAccount (parentAddress: string, suri: string, parent
}

export async function jsonRestoreWindowOpen (): Promise<boolean> {
return sendMessage('pri(json.restore.window.open)', null);
return sendMessage('pri(window.open.json)', null);
}

export async function jsonVerifyFile (json: KeyringPair$Json): Promise<boolean> {
Expand Down