Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions apps/extension/src/hooks/use-unmount-promise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useState } from "react";
import { useUnmount } from "./use-unmount";

export function useUnmountPromise() {
const [unmountPromise] = useState(() => {
let resolver: () => void;
const promise = new Promise<void>((resolve) => {
resolver = resolve;
});
return { promise, resolver: resolver! };
});

useUnmount(() => {
unmountPromise.resolver();
});

return unmountPromise;
}
24 changes: 20 additions & 4 deletions apps/extension/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,6 @@
"page.wallet.smart-account.confirm.delegator": "Delegation Contract",
"page.wallet.smart-account.confirm.network": "Network",
"page.wallet.smart-account.confirm.account": "Account",
"page.wallet.smart-account.confirm.fee": "Network Fee",
"page.wallet.smart-account.confirm.fee.insufficient": "Insufficient balance for network fee.",
"page.wallet.smart-account.confirm.fee.failed": "Unable to estimate",
"page.wallet.smart-account.confirm.fee.retry": "Tap to retry",

"page.wallet.change-name.previous-name-input-label": "Previous Wallet Name",
"page.wallet.change-name.new-name-input-label": "New Wallet Name",
Expand Down Expand Up @@ -547,6 +543,26 @@
"page.sign.ethereum.message": "Signing Message",
"page.sign.ethereum.message.title": "Sign Message",
"page.sign.ethereum.eip-712.title": "Sign Typed Data",
"page.sign.ethereum.batch.title": "Confirm Transaction",
"page.sign.ethereum.batch.section-title": "Transaction Summary",
"page.sign.ethereum.batch.upgrade-notice.title": "Smart Account upgrade is included in this transaction",
"page.sign.ethereum.batch.calls.item": "Transaction {index}",
"page.sign.ethereum.batch.calls.to": "To",
"page.sign.ethereum.batch.calls.value": "Value",
"page.sign.ethereum.batch.calls.data": "Data",
"page.sign.ethereum.batch.calls.contract-deploy": "Contract Deploy",
"page.sign.ethereum.batch.calls.intent.transfer": "Transfer",
"page.sign.ethereum.batch.calls.intent.approve": "Approve",
"page.sign.ethereum.batch.calls.intent.swap": "Swap",
"page.sign.ethereum.batch.calls.intent.deposit": "Deposit",
"page.sign.ethereum.batch.calls.intent.withdraw": "Withdraw",
"page.sign.ethereum.batch.summary.title": "Batch Transaction",
"page.sign.ethereum.batch.summary.desc": "{count} transactions will be bundled together",
"page.sign.ethereum.batch.detail.account": "Account",
"page.sign.ethereum.batch.detail.requester": "Requester",
"page.sign.ethereum.batch.detail.network": "Network",
"page.sign.ethereum.batch.advanced.title": "Advanced Details",
"page.sign.ethereum.batch.advanced.nonce": "Nonce",

"page.sign.starknet.tx.calls": "Calls",

Expand Down
24 changes: 20 additions & 4 deletions apps/extension/src/languages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,6 @@
"page.wallet.smart-account.confirm.delegator": "์œ„์ž„ ์ปจํŠธ๋ž™ํŠธ",
"page.wallet.smart-account.confirm.network": "๋„คํŠธ์›Œํฌ",
"page.wallet.smart-account.confirm.account": "๊ณ„์ •",
"page.wallet.smart-account.confirm.fee": "๋„คํŠธ์›Œํฌ ์ˆ˜์ˆ˜๋ฃŒ",
"page.wallet.smart-account.confirm.fee.insufficient": "๋„คํŠธ์›Œํฌ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์œ„ํ•œ ์ž”์•ก์ด ๋ถ€์กฑํ•ฉ๋‹ˆ๋‹ค.",
"page.wallet.smart-account.confirm.fee.failed": "์ถ”์ • ๋ถˆ๊ฐ€",
"page.wallet.smart-account.confirm.fee.retry": "ํƒญํ•˜์—ฌ ์žฌ์‹œ๋„",

"page.wallet.change-name.previous-name-input-label": "ํ˜„์žฌ ์ง€๊ฐ‘ ์ด๋ฆ„",
"page.wallet.change-name.new-name-input-label": "์ƒˆ๋กœ์šด ์ง€๊ฐ‘ ์ด๋ฆ„",
Expand Down Expand Up @@ -539,6 +535,26 @@
"page.sign.ethereum.message": "์„œ๋ช…ํ•  ๋ฉ”์‹œ์ง€",
"page.sign.ethereum.message.title": "๋ฉ”์‹œ์ง€ ์„œ๋ช…",
"page.sign.ethereum.eip-712.title": "ํƒ€์ž… ๋ฐ์ดํ„ฐ ์„œ๋ช…",
"page.sign.ethereum.batch.title": "ํŠธ๋žœ์žญ์…˜ ํ™•์ธ",
"page.sign.ethereum.batch.section-title": "ํŠธ๋žœ์žญ์…˜ ์š”์•ฝ",
"page.sign.ethereum.batch.upgrade-notice.title": "์ด ํŠธ๋žœ์žญ์…˜์— ์Šค๋งˆํŠธ ์–ด์นด์šดํŠธ ์—…๊ทธ๋ ˆ์ด๋“œ๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค",
"page.sign.ethereum.batch.calls.item": "ํŠธ๋žœ์žญ์…˜ {index}",
"page.sign.ethereum.batch.calls.to": "์ˆ˜์‹ ",
"page.sign.ethereum.batch.calls.value": "๊ธˆ์•ก",
"page.sign.ethereum.batch.calls.data": "๋ฐ์ดํ„ฐ",
"page.sign.ethereum.batch.calls.contract-deploy": "์ปจํŠธ๋ž™ํŠธ ๋ฐฐํฌ",
"page.sign.ethereum.batch.calls.intent.transfer": "์ „์†ก",
"page.sign.ethereum.batch.calls.intent.approve": "์Šน์ธ",
"page.sign.ethereum.batch.calls.intent.swap": "์Šค์™‘",
"page.sign.ethereum.batch.calls.intent.deposit": "์˜ˆ์น˜",
"page.sign.ethereum.batch.calls.intent.withdraw": "์ธ์ถœ",
"page.sign.ethereum.batch.summary.title": "๋ฐฐ์น˜ ํŠธ๋žœ์žญ์…˜",
"page.sign.ethereum.batch.summary.desc": "{count}๊ฐœ์˜ ํŠธ๋žœ์žญ์…˜์ด ํ•จ๊ป˜ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค",
"page.sign.ethereum.batch.detail.account": "๊ณ„์ •",
"page.sign.ethereum.batch.detail.requester": "์š”์ฒญ์ž",
"page.sign.ethereum.batch.detail.network": "๋„คํŠธ์›Œํฌ",
"page.sign.ethereum.batch.advanced.title": "์ƒ์„ธ ์ •๋ณด",
"page.sign.ethereum.batch.advanced.nonce": "๋…ผ์Šค",

"page.sign.starknet.tx.calls": "์‹คํ–‰ํ•  ํ˜ธ์ถœ",

Expand Down
24 changes: 20 additions & 4 deletions apps/extension/src/languages/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,6 @@
"page.wallet.smart-account.confirm.delegator": "ๅง”ๆ‰˜ๅˆ็บฆ",
"page.wallet.smart-account.confirm.network": "็ฝ‘็ปœ",
"page.wallet.smart-account.confirm.account": "่ดฆๆˆท",
"page.wallet.smart-account.confirm.fee": "็ฝ‘็ปœ่ดน็”จ",
"page.wallet.smart-account.confirm.fee.insufficient": "ไฝ™้ขไธ่ถณไปฅๆ”ฏไป˜็ฝ‘็ปœ่ดน็”จใ€‚",
"page.wallet.smart-account.confirm.fee.failed": "ๆ— ๆณ•ไผฐ็ฎ—",
"page.wallet.smart-account.confirm.fee.retry": "็‚นๅ‡ป้‡่ฏ•",

"page.wallet.change-name.previous-name-input-label": "ๅŽŸ้’ฑๅŒ…ๅ็งฐ",
"page.wallet.change-name.new-name-input-label": "ๆ–ฐ้’ฑๅŒ…ๅ็งฐ",
Expand Down Expand Up @@ -501,6 +497,26 @@
"page.sign.ethereum.message": "็ญพ็ฝฒไฟกๆฏ",
"page.sign.ethereum.message.title": "ๆ ‡ๅฟ—ไฟกๆฏ",
"page.sign.ethereum.eip-712.title": "็ญพ็ฝฒ้”ฎๅ…ฅๆ•ฐๆฎ",
"page.sign.ethereum.batch.title": "็กฎ่ฎคไบคๆ˜“",
"page.sign.ethereum.batch.section-title": "ไบคๆ˜“ๆ‘˜่ฆ",
"page.sign.ethereum.batch.upgrade-notice.title": "ๆญคไบคๆ˜“ๅŒ…ๅซๆ™บ่ƒฝ่ดฆๆˆทๅ‡็บง",
"page.sign.ethereum.batch.calls.item": "ไบคๆ˜“ {index}",
"page.sign.ethereum.batch.calls.to": "ๆŽฅๆ”ถ",
"page.sign.ethereum.batch.calls.value": "้‡‘้ข",
"page.sign.ethereum.batch.calls.data": "ๆ•ฐๆฎ",
"page.sign.ethereum.batch.calls.contract-deploy": "ๅˆ็บฆ้ƒจ็ฝฒ",
"page.sign.ethereum.batch.calls.intent.transfer": "่ฝฌ่ดฆ",
"page.sign.ethereum.batch.calls.intent.approve": "ๆ‰นๅ‡†",
"page.sign.ethereum.batch.calls.intent.swap": "ๅ…‘ๆข",
"page.sign.ethereum.batch.calls.intent.deposit": "ๅญ˜ๅ…ฅ",
"page.sign.ethereum.batch.calls.intent.withdraw": "ๆๅ–",
"page.sign.ethereum.batch.summary.title": "ๆ‰น้‡ไบคๆ˜“",
"page.sign.ethereum.batch.summary.desc": "{count}็ฌ”ไบคๆ˜“ๅฐ†่ขซๆ‰“ๅŒ…ๆ‰ง่กŒ",
"page.sign.ethereum.batch.detail.account": "่ดฆๆˆท",
"page.sign.ethereum.batch.detail.requester": "่ฏทๆฑ‚่€…",
"page.sign.ethereum.batch.detail.network": "็ฝ‘็ปœ",
"page.sign.ethereum.batch.advanced.title": "้ซ˜็บง่ฏฆๆƒ…",
"page.sign.ethereum.batch.advanced.nonce": "Nonce",

"page.sign.bitcoin.transaction.data": "ไบคๆ˜“ๆ•ฐๆฎ",
"page.sign.bitcoin.transaction.input": "่พ“ๅ…ฅ",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import React, { FunctionComponent, useState } from "react";
import { useIntl } from "react-intl";
import styled from "styled-components";
import { DSColor, DSTypography } from "@keplr-wallet/design-system";
import { Buffer } from "buffer/";

export const AdvancedDetails: FunctionComponent<{
signingDataBuff: Buffer;
nonce: number;
}> = ({ signingDataBuff, nonce }) => {
const intl = useIntl();
const [expanded, setExpanded] = useState(false);

const rawData = (() => {
try {
return JSON.stringify(
JSON.parse(Buffer.from(signingDataBuff).toString("utf8")),
null,
2
);
} catch {
return Buffer.from(signingDataBuff).toString("utf8");
}
})();

return (
<Card>
<Header onClick={() => setExpanded((v) => !v)}>
<DSTypography
size="textXxs"
weight="medium"
color={DSColor.typography.secondary}
>
{intl.formatMessage({
id: "page.sign.ethereum.batch.advanced.title",
})}
</DSTypography>
<Chevron $open={expanded}>โ–พ</Chevron>
</Header>

<CollapseOuter $expanded={expanded}>
<CollapseInner>
<Body>
<InfoRow>
<DSTypography
size="textXxs"
weight="regular"
color={DSColor.typography.secondary}
>
{intl.formatMessage({
id: "page.sign.ethereum.batch.advanced.nonce",
})}
</DSTypography>
<DSTypography size="textXxs" weight="regular">
{nonce}
</DSTypography>
</InfoRow>
<RawDataBlock>{rawData}</RawDataBlock>
</Body>
</CollapseInner>
</CollapseOuter>
</Card>
);
};

const Card = styled.div`
border-radius: 0.375rem;
background-color: ${DSColor.background.surface.elevated};
overflow: hidden;
`;

const Header = styled.button`
width: 100%;
padding: 0.75rem 1rem;
display: flex;
justify-content: space-between;
align-items: center;
background: none;
border: none;
cursor: pointer;
`;

const CollapseOuter = styled.div<{ $expanded: boolean }>`
display: grid;
grid-template-rows: ${(p) => (p.$expanded ? "1fr" : "0fr")};
transition: grid-template-rows 0.22s ease;
`;

const CollapseInner = styled.div`
overflow: hidden;
`;

const Body = styled.div`
padding: 0 1rem 0 1rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
`;

const InfoRow = styled.div`
display: flex;
justify-content: space-between;
align-items: center;
`;

const RawDataBlock = styled.pre`
font-size: 0.625rem;
line-height: 1.4;
color: ${DSColor.typography.tertiary};
background-color: ${DSColor.background.surface.ground};
border-radius: 0.375rem;
padding: 0.75rem;
margin: 0 0 0.75rem 0;
white-space: pre-wrap;
word-break: break-all;
max-height: 10rem;
overflow-y: auto;
`;

const Chevron = styled.span<{ $open: boolean }>`
transform: ${(p) => (p.$open ? "rotate(0deg)" : "rotate(-90deg)")};
transition: transform 0.15s ease;
font-size: 0.625rem;
color: ${DSColor.typography.secondary};
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import React, { FunctionComponent } from "react";
import { useIntl } from "react-intl";
import styled from "styled-components";
import { DSColor, DSTypography } from "@keplr-wallet/design-system";
import { XAxis, YAxis } from "../../../../../components/axis";
import { ChainImageFallback } from "../../../../../components/image";
import type { IModularChainInfoImpl } from "@keplr-wallet/stores";

export const BatchDetailCard: FunctionComponent<{
accountName: string;
hexAddress: string;
origin: string;
chainName: string;
chainInfo: IModularChainInfoImpl;
}> = ({ accountName, hexAddress, origin, chainName, chainInfo }) => {
const intl = useIntl();

const originDisplay = (() => {
try {
return new URL(origin).hostname;
} catch {
return origin;
}
})();

const truncatedAddress = hexAddress
? `${hexAddress.slice(0, 10)}...${hexAddress.slice(-8)}`
: "";

return (
<Card>
<YAxis gap="0.625rem">
<InfoRow>
<Label>
{intl.formatMessage({
id: "page.sign.ethereum.batch.detail.account",
})}
</Label>
<YAxis alignX="right">
<DSTypography size="textXxs" weight="medium">
{accountName}
</DSTypography>
{truncatedAddress && (
<DSTypography
size="textXxs"
weight="regular"
color={DSColor.typography.secondary}
style={{ fontFamily: "monospace" }}
>
{truncatedAddress}
</DSTypography>
)}
</YAxis>
</InfoRow>
<Divider />
<InfoRow>
<Label>
{intl.formatMessage({
id: "page.sign.ethereum.batch.detail.requester",
})}
</Label>
<DSTypography size="textXxs" weight="medium">
{originDisplay}
</DSTypography>
</InfoRow>
<Divider />
<InfoRow>
<Label>
{intl.formatMessage({
id: "page.sign.ethereum.batch.detail.network",
})}
</Label>
<XAxis alignY="center" gap="0.375rem">
<ChainImageFallback chainInfo={chainInfo} size="0.75rem" />
<DSTypography size="textXxs" weight="regular">
{chainName}
</DSTypography>
</XAxis>
</InfoRow>
</YAxis>
</Card>
);
};

const Card = styled.div`
border-radius: 0.375rem;
background-color: ${DSColor.background.surface.elevated};
padding: 1rem;
`;

const Label: FunctionComponent<{ children: React.ReactNode }> = ({
children,
}) => (
<DSTypography
size="textXxs"
weight="regular"
color={DSColor.typography.secondary}
>
{children}
</DSTypography>
);

const InfoRow = styled(XAxis)`
justify-content: space-between;
align-items: center;
`;

const Divider = styled.div`
height: 1px;
background-color: ${DSColor.stroke.separator.primary};
`;
Loading
Loading