Skip to content

Commit

Permalink
setup.ts refactored with .bind
Browse files Browse the repository at this point in the history
  • Loading branch information
Wozacosta committed Aug 28, 2024
1 parent af1227a commit 1de1923
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions libs/ledger-live-common/src/families/cosmos/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,13 @@ import Cosmos from "@ledgerhq/hw-app-cosmos";
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";

const createSigner: CreateSigner<CosmosSigner> = (transport: Transport) => {
const cosmos = new CosmosApp(transport) as CosmosApp & {
getAddress: typeof hwCosmos.getAddress;
serializePath: typeof hwCosmos.serializePath;
};
const cosmos = new CosmosApp(transport);
const hwCosmos = new Cosmos(transport);
cosmos.getAddress = hwCosmos.getAddress;
return cosmos;

// NOTE: cannot do like below, "this" would get lost
// return {
// getAddressAndPubKey: cosmos.getAddressAndPubKey,
// sign: cosmos.sign,
// getAddress: hwCosmos.getAddress,
// };
return {
getAddressAndPubKey: cosmos.getAddressAndPubKey.bind(cosmos),
sign: cosmos.sign.bind(cosmos),
getAddress: hwCosmos.getAddress.bind(hwCosmos),
};
};
const getCurrencyConfig = (currency: CryptoCurrency): CosmosCoinConfig => {
return getCurrencyConfiguration(currency);
Expand Down

0 comments on commit 1de1923

Please sign in to comment.