Skip to content

Commit

Permalink
✨ (llc): Use dmk signer instead of legacy one if dmk transport
Browse files Browse the repository at this point in the history
  • Loading branch information
aussedatlo committed Jan 16, 2025
1 parent 2de7677 commit 3a29e84
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
2 changes: 2 additions & 0 deletions libs/ledger-live-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
"@ledgerhq/hw-app-aptos": "workspace:^",
"@ledgerhq/hw-app-btc": "workspace:^",
"@ledgerhq/hw-app-cosmos": "workspace:^",
"@ledgerhq/hw-app-dmk-eth": "workspace:^",
"@ledgerhq/hw-app-elrond": "workspace:^",
"@ledgerhq/hw-app-eth": "workspace:^",
"@ledgerhq/hw-app-exchange": "workspace:^",
Expand Down Expand Up @@ -251,6 +252,7 @@
"zod": "^3.22.4"
},
"devDependencies": {
"@ledgerhq/device-management-kit": "0.0.0-develop-20250106155719",
"@ledgerhq/device-react": "workspace:^",
"@ledgerhq/types-cryptoassets": "workspace:^",
"@ledgerhq/types-devices": "workspace:^",
Expand Down
21 changes: 19 additions & 2 deletions libs/ledger-live-common/src/families/evm/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,32 @@ import {
} from "../../bridge/setup";
import { Resolver } from "../../hw/getAddress/types";
import Transport from "@ledgerhq/hw-transport";
import { Bridge } from "@ledgerhq/types-live";
import type { Bridge, EvmSigner } from "@ledgerhq/types-live";
import { getCurrencyConfiguration } from "../../config";
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
import { EvmConfigInfo } from "@ledgerhq/coin-evm/config";
import { DeviceManagementKit } from "@ledgerhq/device-management-kit";
import { DmkSignerEth } from "@ledgerhq/hw-app-dmk-eth";

const createSigner: CreateSigner<EvmSigner> = (transport: Transport) => {
if (isDmkTransport(transport)) {
return new DmkSignerEth(transport.sdk, transport.sessionId);
}

const createSigner: CreateSigner<Eth> = (transport: Transport) => {
return new Eth(transport);
};

const isDmkTransport = (
transport: Transport,
): transport is Transport & { sdk: DeviceManagementKit; sessionId: string } => {
return (
"sdk" in transport &&
transport.sdk !== undefined &&
"sessionId" in transport &&
transport.sessionId !== undefined
);
};

const getCurrencyConfig = (currency: CryptoCurrency) => {
return { info: getCurrencyConfiguration<EvmConfigInfo>(currency) };
};
Expand Down
34 changes: 34 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3a29e84

Please sign in to comment.