Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA] Starknet Ledger app support #1253

Merged
merged 6 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion apps/extension/src/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"pages.register.back-up-private-key.import-button": "Got it",

"pages.register.connect-ledger.title": "Please connect your Hardware wallet",
"pages.register.connect-ledger.paragraph": "To use EVM-compatible chains (Injective, Evmos) with Keplr, you'll be prompted to connect to Ethereum app in the next steps.",
"pages.register.connect-ledger.paragraph": "Keplr supports Cosmos app chains, all EVM compatible chains including Ethereum, Injective and Evmos, and Starknet. Ledger connection will guide you through Cosmos, EVM, and Starknet in order.",
"pages.register.connect-ledger.step-text": "Step {step}",
"pages.register.connect-ledger.connect-ledger-step-paragraph": "Connect and unlock your Ledger.",
"pages.register.connect-ledger.open-app-step-paragraph": "Open the {app} app on your Ledger device.",
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/languages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"pages.register.back-up-private-key.import-button": "확인",

"pages.register.connect-ledger.title": "하드웨어 지갑을 연결해주세요.",
"pages.register.connect-ledger.paragraph": "EVM 체인(Injective, Evmos)을 케플러에서 사용하실 분들은 이후 단계에서 이더리움 앱을 연결하실 수 있습니다.",
"pages.register.connect-ledger.paragraph": "케플러는 코스모스 앱체인, Ethereum, Injective와 Evmos를 포함한 모든 EVM 호환 체인, 그리고 Starknet을 지원합니다. Ledger 연결은 코스모스, EVM, Starknet 순서로 진행됩니다.",
"pages.register.connect-ledger.step-text": "{step} 단계",
"pages.register.connect-ledger.connect-ledger-step-paragraph": "렛저를 연결하고 잠금을 해제하세요.",
"pages.register.connect-ledger.open-app-step-paragraph": "렛저에서 {app} 앱을 열어주세요.",
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/languages/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"pages.register.back-up-private-key.import-button": "导入",

"pages.register.connect-ledger.title": "请连接你的硬件钱包",
"pages.register.connect-ledger.paragraph": "要将EVM兼容链(Injective、Evmos)与Keplr一起使用,将在后续步骤中提示你连接到以太坊应用程序",
"pages.register.connect-ledger.paragraph": "Keplr 支援 Cosmos 應用程式鏈、所有 EVM 相容鏈,包括 Ethereum、Injective 和 Evmos,以及 Starknet。Ledger connection 會引導您依序瀏覽 Cosmos、EVM 和 Starknet",
"pages.register.connect-ledger.step-text": "步骤 {step}",
"pages.register.connect-ledger.connect-ledger-step-paragraph": "连接并解锁你的Ledger。",
"pages.register.connect-ledger.open-app-step-paragraph": "在你的Ledger设备上打开{app}应用。",
Expand Down
50 changes: 50 additions & 0 deletions apps/extension/src/ledger-grant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import "simplebar-react/dist/simplebar.min.css";
import { FormattedMessage, useIntl } from "react-intl";
import { useTheme } from "styled-components";
import { RoutePageAnalytics } from "./route-page-analytics";
import { LedgerError, StarknetClient } from "@ledgerhq/hw-app-starknet";
import { STARKNET_LEDGER_DERIVATION_PATH } from "./pages/sign/utils/handle-starknet-sign";

configure({
enforceActions: "always", // Make mobx to strict mode.
Expand Down Expand Up @@ -374,6 +376,54 @@ const LedgerGrantPage: FunctionComponent = observer(() => {
}
}}
/>
<Button
color="secondary"
text="Starknet app"
isLoading={appIsLoading === "Starknet"}
disabled={!!appIsLoading && appIsLoading !== "Starknet"}
onClick={async () => {
if (appIsLoading) {
return;
}
setAppIsLoading("Starknet");

try {
const transport = await TransportWebHID.create();

try {
const starknetApp = new StarknetClient(transport);

const res = await starknetApp.getPubKey(
STARKNET_LEDGER_DERIVATION_PATH,
false
);
switch (res.returnCode) {
case LedgerError.NoError:
setStatus("success");

return;
default:
setStatus("failed");

return;
}
} catch (e) {
console.log(e);
// noop
} finally {
setAppIsLoading("");

await transport.close();
}
} catch (e) {
console.log(e);

setStatus("failed");
} finally {
setAppIsLoading("");
}
}}
/>
</Columns>
</React.Fragment>
);
Expand Down
8 changes: 0 additions & 8 deletions apps/extension/src/pages/register/connect-ledger/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ export const ConnectLedgerScene: FunctionComponent<{
title: intl.formatMessage({
id: "pages.register.connect-ledger.title",
}),
paragraphs:
propApp !== "Ethereum" && propApp !== "Starknet"
? [
intl.formatMessage({
id: "pages.register.connect-ledger.paragraph",
}),
]
: undefined,
stepCurrent: stepPrevious + 1,
stepTotal: stepTotal,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export const RegisterNamePasswordHardwareScene: FunctionComponent<{
title: intl.formatMessage({
id: "pages.register.name-password-hardware.title",
}),
paragraphs: [
intl.formatMessage({
id: "pages.register.connect-ledger.paragraph",
}),
],
stepCurrent: 1,
stepTotal: type === "keystone" ? 4 : 5,
});
Expand Down
7 changes: 2 additions & 5 deletions apps/extension/src/pages/starknet/sign/message/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const SignStarknetMessageView: FunctionComponent<{
SignStarknetMessageInteractionStore["waitingData"]
>;
}> = observer(({ interactionData }) => {
const { signStarknetMessageInteractionStore, uiConfigStore } = useStore();
const { signStarknetMessageInteractionStore } = useStore();

const theme = useTheme();
const navigate = useNavigate();
Expand Down Expand Up @@ -81,10 +81,7 @@ export const SignStarknetMessageView: FunctionComponent<{
signature = await connectAndSignMessageWithLedger(
interactionData.data.pubKey,
interactionData.data.message,
interactionData.data.signer,
{
useWebHID: uiConfigStore.useWebHIDLedger,
}
interactionData.data.signer
);
}

Expand Down
6 changes: 1 addition & 5 deletions apps/extension/src/pages/starknet/sign/tx/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export const SignStarknetTxView: FunctionComponent<{
interactionData: NonNullable<SignStarknetTxInteractionStore["waitingData"]>;
}> = observer(({ interactionData }) => {
const {
uiConfigStore,
signStarknetTxInteractionStore,
starknetAccountStore,
starknetQueriesStore,
Expand Down Expand Up @@ -383,10 +382,7 @@ export const SignStarknetTxView: FunctionComponent<{
signature = await connectAndSignInvokeTxWithLedger(
interactionData.data.pubKey,
interactionData.data.transactions,
details,
{
useWebHID: uiConfigStore.useWebHIDLedger,
}
details
);
}

Expand Down
Loading