Skip to content

Commit

Permalink
Additional PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jurevans committed Jul 27, 2023
1 parent ed9917b commit ef5f096
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 23 deletions.
10 changes: 5 additions & 5 deletions apps/extension/src/Approvals/Approvals.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export enum Status {
}

export type ApprovalDetails = {
source: string | null;
msgId: string | null;
txType: TxType | null;
publicKey: string | null;
target: string | null;
source: string;
msgId: string;
txType: TxType;
publicKey?: string;
target?: string;
};

export const Approvals: React.FC = () => {
Expand Down
20 changes: 11 additions & 9 deletions apps/extension/src/Approvals/ApproveTx/ApproveTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,23 @@ export const ApproveTx: React.FC<Props> = ({ setDetails }) => {
?.symbol || "";

useEffect(() => {
setDetails({
source,
txType,
msgId,
publicKey,
target,
});
if (source && txType && msgId) {
setDetails({
source,
txType,
msgId,
publicKey,
target,
});
}
}, [source, publicKey, txType, target, msgId]);

const handleApproveClick = (): void => {
const handleApproveClick = useCallback((): void => {
if (accountType === AccountType.Ledger) {
return navigate(`${TopLevelRoute.ConfirmLedgerTx}`);
}
navigate(TopLevelRoute.ConfirmTx);
};
}, [accountType]);

const handleReject = useCallback(async (): Promise<void> => {
try {
Expand Down
4 changes: 2 additions & 2 deletions apps/extension/src/background/approvals/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class ApprovalsService {
) {}

// Deserialize transfer details and prompt user
async approveTransfer(txMsg: string, type?: AccountType): Promise<void> {
async approveTransfer(txMsg: string, type: AccountType): Promise<void> {
const txMsgBuffer = Buffer.from(fromBase64(txMsg));
const msgId = uuid();
await this.txStore.set(msgId, txMsg);
Expand All @@ -52,7 +52,7 @@ export class ApprovalsService {
target,
tokenAddress,
amount: amount.toString(),
accountType: type as string,
accountType: type,
publicKey,
});

Expand Down
10 changes: 6 additions & 4 deletions apps/extension/src/hooks/useQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sanitize } from "dompurify";

interface SanitizedURLSearchParams {
get(name: string): string | null;
getAll(): Record<string, string | null>;
getAll(): Record<string, string>;
}

const toSanitized = (
Expand All @@ -14,12 +14,14 @@ const toSanitized = (
const unsanitized = urlSearchParams.get(name);
return unsanitized === null ? unsanitized : sanitize(unsanitized);
},
getAll: (): Record<string, string | null> => {
const values: Record<string, string | null> = {};
getAll: (): Record<string, string> => {
const values: Record<string, string> = {};

urlSearchParams.forEach((val, key) => {
const unsanitized = val;
values[key] = unsanitized === null ? unsanitized : sanitize(unsanitized);
if (unsanitized) {
values[sanitize(key)] = sanitize(unsanitized);
}
});

return values;
Expand Down
4 changes: 2 additions & 2 deletions apps/extension/src/provider/Namada.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class Namada implements INamada {
constructor(
private readonly _version: string,
protected readonly requester?: MessageRequester
) { }
) {}

public async connect(chainId: string): Promise<void> {
return await this.requester?.sendMessage(
Expand Down Expand Up @@ -124,7 +124,7 @@ export class Namada implements INamada {

public async submitTransfer(props: {
txMsg: string;
type?: AccountType;
type: AccountType;
}): Promise<void> {
const { txMsg, type } = props;
return await this.requester?.sendMessage(
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/provider/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class ApproveTransferMsg extends Message<void> {

constructor(
public readonly txMsg: string,
public readonly accountType?: AccountType
public readonly accountType: AccountType
) {
super();
}
Expand Down

0 comments on commit ef5f096

Please sign in to comment.