Skip to content

Commit

Permalink
Fix some codes related to the ledger secret app
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunnini committed Aug 4, 2023
1 parent 39ddedb commit abc8ed5
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
53 changes: 50 additions & 3 deletions packages/extension/src/ledger-grant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const LedgerGrantPage: FunctionComponent = observer(() => {
<Columns sum={1} gutter="1rem">
<Button
color="secondary"
text="Cosmos App"
text="Cosmos app"
isLoading={appIsLoading === "Cosmos"}
disabled={!!appIsLoading && appIsLoading !== "Cosmos"}
onClick={async () => {
Expand Down Expand Up @@ -227,7 +227,7 @@ const LedgerGrantPage: FunctionComponent = observer(() => {
/>
<Button
color="secondary"
text="Terra App"
text="Terra app"
isLoading={appIsLoading === "Terra"}
disabled={!!appIsLoading && appIsLoading !== "Terra"}
onClick={async () => {
Expand Down Expand Up @@ -274,7 +274,54 @@ const LedgerGrantPage: FunctionComponent = observer(() => {
/>
<Button
color="secondary"
text="Ethereum App"
text="Secret app"
isLoading={appIsLoading === "Secret"}
disabled={!!appIsLoading && appIsLoading !== "Secret"}
onClick={async () => {
if (appIsLoading) {
return;
}
setAppIsLoading("Secret");

let transport: Transport | undefined = undefined;
try {
transport = uiConfigStore.useWebHIDLedger
? await TransportWebHID.create()
: await TransportWebUSB.create();

let app = new CosmosApp("Secret", transport);

if ((await app.getAppInfo()).app_name === "Secret") {
setStatus("success");
return;
}

transport = await LedgerUtils.tryAppOpen(
transport,
"Secret"
);
app = new CosmosApp("Secret", transport);

if ((await app.getAppInfo()).app_name === "Secret ") {
setStatus("success");
return;
}

setStatus("failed");
} catch (e) {
console.log(e);

setStatus("failed");
} finally {
transport?.close().catch(console.log);

setAppIsLoading("");
}
}}
/>
<Button
color="secondary"
text="Ethereum app"
isLoading={appIsLoading === "Ethereum"}
disabled={!!appIsLoading && appIsLoading !== "Ethereum"}
onClick={async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export const LedgerGuideBox: FunctionComponent<{
if (appData["Terra"]) {
app = "Terra";
}
if (appData["Secret"]) {
app = "Secret";
}

if (data.isEthereum) {
if (appData["Ethereum"]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const connectAndSignWithLedger = async (
},
signDoc: StdSignDoc
): Promise<Uint8Array> => {
if (propApp !== "Cosmos" && propApp !== "Terra") {
if (propApp !== "Cosmos" && propApp !== "Terra" && propApp !== "Secret") {
throw new KeplrError(
ErrModuleLedgerSign,
ErrCodeUnsupportedApp,
Expand Down
3 changes: 3 additions & 0 deletions packages/extension/src/pages/sign/utils/handle-cosmos-sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export const handleCosmosPreSign = async (
if (appData["Terra"]) {
ledgerApp = "Terra";
publicKey = Buffer.from((appData["Terra"] as any)["pubKey"], "hex");
} else if (appData["Secret"]) {
ledgerApp = "Secret";
publicKey = Buffer.from((appData["Secret"] as any)["pubKey"], "hex");
} else {
publicKey = Buffer.from((appData["Cosmos"] as any)["pubKey"], "hex");
}
Expand Down
2 changes: 2 additions & 0 deletions packages/extension/src/pages/wallet/select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ const KeyringItem: FunctionComponent<{
}

if (
app.length === 1 &&
app.includes("Cosmos") &&
bip44Path.account === 0 &&
bip44Path.change === 0 &&
bip44Path.addressIndex === 0
Expand Down

0 comments on commit abc8ed5

Please sign in to comment.