From ce55795911459486f30e19e22c7f637c3ad1de48 Mon Sep 17 00:00:00 2001 From: Antonio Pitasi Date: Thu, 18 Apr 2024 13:04:34 +0200 Subject: [PATCH] feat(snap): redirect to approve requests based on the account origin url --- snap/src/keyring.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/snap/src/keyring.ts b/snap/src/keyring.ts index 1bd8eb57c..191554f7d 100644 --- a/snap/src/keyring.ts +++ b/snap/src/keyring.ts @@ -39,11 +39,7 @@ export class WardenKeyring implements Keyring { id, address: options?.address?.valueOf() as string, options: options ?? {}, - methods: [ - 'personal_sign', - 'eth_signTransaction', - 'eth_signTypedData_v4', - ], + methods: ['personal_sign', 'eth_signTransaction', 'eth_signTypedData_v4'], }; this.state.accounts[id] = account; await emitSnapKeyringEvent(snap, KeyringEvent.AccountCreated, { account }); @@ -78,11 +74,13 @@ export class WardenKeyring implements Keyring { this.state.pendingRequests[request.id] = request; await this.saveState(); + const url = account.options.url?.toString() ?? 'http://localhost:5173/'; + return { pending: true, redirect: { message: 'Proceed in SpaceWard to approve this request', - url: 'http://localhost:5173/metamask', + url, }, }; }