Skip to content

Commit

Permalink
chore: allow RSK Test ledger app
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Oct 11, 2024
1 parent becf1cf commit 33caf28
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
26 changes: 23 additions & 3 deletions src/components/HardwareDerivationPaths.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import log from "loglevel";
import { IoClose } from "solid-icons/io";
import { Accessor, For, Setter, Show, createSignal } from "solid-js";

import {
Accessor,
For,
Setter,
Show,
createMemo,
createSignal,
} from "solid-js";

import { config } from "../config";
import type {
EIP6963ProviderDetail,
EIP6963ProviderInfo,
Expand All @@ -12,6 +20,7 @@ import { formatError } from "../utils/errors";
import {
HardwareSigner,
derivationPaths,
derivationPathsTestnet,
} from "../utils/hardware/HadwareSigner";
import LoadingSpinner from "./LoadingSpinner";

Expand Down Expand Up @@ -160,6 +169,17 @@ const HardwareDerivationPaths = ({

const [loading, setLoading] = createSignal<boolean>(false);

const paths = createMemo(() => {
if (config.network === "testnet") {
return {
...derivationPaths,
...derivationPathsTestnet,
};
}

return derivationPaths;
});

return (
<div
class="frame assets-select"
Expand All @@ -173,7 +193,7 @@ const HardwareDerivationPaths = ({
<hr class="spacer" />
<Show when={!loading()} fallback={<LoadingSpinner />}>
<For
each={Object.entries(derivationPaths).sort(([a], [b]) =>
each={Object.entries(paths()).sort(([a], [b]) =>
a.toLowerCase().localeCompare(b.toLowerCase()),
)}>
{([name, path]) => (
Expand Down
6 changes: 5 additions & 1 deletion src/utils/hardware/HadwareSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ const derivationPaths = {
Ethereum: "44'/60'/0'/0/0",
};

const derivationPathsTestnet = {
["RSK Testnet"]: "44'/37310'/0'/0/0",
};

interface HardwareSigner {
setDerivationPath(path: string): void;
}

export { HardwareSigner, derivationPaths };
export { HardwareSigner, derivationPaths, derivationPathsTestnet };
4 changes: 2 additions & 2 deletions src/utils/hardware/LedgerSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { DictKey } from "../../i18n/i18n";
import { HardwareSigner, derivationPaths } from "./HadwareSigner";

class LedgerSigner implements EIP1193Provider, HardwareSigner {
private static readonly supportedApps = ["Ethereum", "RSK"];
private static readonly supportedApps = ["Ethereum", "RSK", "RSK Test"];

private readonly provider: JsonRpcProvider;
private derivationPath = derivationPaths.Ethereum;
Expand All @@ -30,7 +30,7 @@ class LedgerSigner implements EIP1193Provider, HardwareSigner {
) => string,
) {
this.provider = new JsonRpcProvider(
config.assets["RBTC"].network.rpcUrls[0],
config.assets["RBTC"]?.network?.rpcUrls[0],
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/hardware/TrezorSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TrezorSigner implements EIP1193Provider, HardwareSigner {

constructor() {
this.provider = new JsonRpcProvider(
config.assets["RBTC"].network.rpcUrls[0],
config.assets["RBTC"]?.network?.rpcUrls[0],
);
this.setDerivationPath(derivationPaths.Ethereum);
}
Expand Down

0 comments on commit 33caf28

Please sign in to comment.