@ledgerhq/live-common
Version:
Common ground for the Ledger Live apps
31 lines • 1.26 kB
JavaScript
import resolver from "../../../../families/stellar/getAddress";
import { executeWithSigner } from "../../../setup";
import Stellar from "@ledgerhq/hw-app-str";
import { StrKey } from "@stellar/stellar-sdk";
const createSignerStellar = (transport) => {
const stellar = new Stellar(transport);
const originalSignTransaction = stellar.signTransaction;
// Return the original Stellar instance with overridden methods
return Object.assign(stellar, {
signTransaction: async (path, transaction) => {
const unsignedPayload = Buffer.from(transaction, "base64");
const { signature } = await originalSignTransaction(path, unsignedPayload);
return signature.toString("base64");
},
getAddress: async (path, verify) => {
const { rawPublicKey } = await stellar.getPublicKey(path, verify);
const publicKey = StrKey.encodeEd25519PublicKey(rawPublicKey);
return {
path,
address: publicKey,
publicKey: publicKey,
};
},
});
};
export const context = executeWithSigner(createSignerStellar);
export default {
context,
getAddress: resolver(context),
};
//# sourceMappingURL=signer.js.map