Skip to content

Commit

Permalink
Update route guard (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
grod220 authored Mar 21, 2024
1 parent 4ed02a1 commit dd78a89
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 5 additions & 3 deletions apps/extension/src/entry/popup-root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ chrome.runtime.onMessage.addListener(
(req: unknown, _: chrome.runtime.MessageSender, responder: (x: unknown) => void) => {
if (isPopupRequest(req)) {
try {
if (isTxApprovalRequest(req))
if (isTxApprovalRequest(req)) {
void txApprovalSelector(useStore.getState()).acceptRequest(req, responder);
else if (isOriginApprovalRequest(req))
} else if (isOriginApprovalRequest(req)) {
originApprovalSelector(useStore.getState()).acceptRequest(req, responder);
else throw new Error('Unknown popup request');
} else {
throw new Error('Unknown popup request');
}
} catch (e) {
responder({
type: req.type,
Expand Down
5 changes: 1 addition & 4 deletions apps/extension/src/message/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,4 @@ export const isOriginApprovalRequest = (req: unknown): req is InternalRequest<Or
isPopupRequest(req) && req.type === PopupType.OriginApproval && 'origin' in req.request;

export const isTxApprovalRequest = (req: unknown): req is InternalRequest<TxApproval> =>
isPopupRequest(req) &&
req.type === PopupType.TxApproval &&
'authorizeRequest' in req.request &&
'transactionView' in req.request;
isPopupRequest(req) && req.type === PopupType.TxApproval && 'authorizeRequest' in req.request;
5 changes: 4 additions & 1 deletion apps/extension/src/state/tx-approval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ export const createTxApprovalSlice = (): SliceCreator<TxApprovalSlice> => (set,
return denomMetadata ?? new Metadata();
};

const wallets = await localExtStorage.get('wallets');
const activeWalletFvk = wallets[0]?.fullViewingKey ?? '';

const transactionView = await viewTransactionPlan(
authorizeRequest.plan ?? new TransactionPlan(),
getMetadata,
(await localExtStorage.get('wallets'))[0]?.fullViewingKey ?? '',
activeWalletFvk,
);

// pregenerate views from various perspectives.
Expand Down

0 comments on commit dd78a89

Please sign in to comment.