launchpad-ledger: Update for new OfflineSigner
This commit is contained in:
parent
798d79b00e
commit
8bf0c97c08
@ -57,6 +57,6 @@ export async function sign(
|
||||
},
|
||||
];
|
||||
const signDoc = makeSignDoc(msgs, defaultFee, defaultChainId, defaultMemo, accountNumber, defaultSequence);
|
||||
const { signature } = await signer.sign(fromAddress, signDoc);
|
||||
const { signature } = await signer.signAmino(fromAddress, signDoc);
|
||||
return signature;
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ window.sign = async function sign(signer: LedgerSigner | undefined): Promise<voi
|
||||
const address = document.getElementById("address").value;
|
||||
const signDocJson = document.getElementById("sign-doc").textContent;
|
||||
const signDoc: StdSignDoc = JSON.parse(signDocJson);
|
||||
const signature = await signer.sign(address, signDoc);
|
||||
const signature = await signer.signAmino(address, signDoc);
|
||||
signatureDiv.textContent = JSON.stringify(signature, null, "\t");
|
||||
} catch (error) {
|
||||
signatureDiv.textContent = error;
|
||||
|
||||
@ -120,7 +120,7 @@ describe("LedgerSigner", () => {
|
||||
defaultAccountNumber,
|
||||
defaultSequence,
|
||||
);
|
||||
const { signed, signature } = await signer.sign(fistAccount.address, signDoc);
|
||||
const { signed, signature } = await signer.signAmino(fistAccount.address, signDoc);
|
||||
expect(signed).toEqual(signDoc);
|
||||
const valid = await Secp256k1.verifySignature(
|
||||
Secp256k1Signature.fromFixedLength(fromBase64(signature.signature)),
|
||||
|
||||
@ -6,7 +6,7 @@ import {
|
||||
OfflineSigner,
|
||||
StdSignDoc,
|
||||
} from "@cosmjs/launchpad";
|
||||
import { serializeSignDoc, SignResponse } from "@cosmjs/launchpad";
|
||||
import { AminoSignResponse, serializeSignDoc } from "@cosmjs/launchpad";
|
||||
import Transport from "@ledgerhq/hw-transport";
|
||||
|
||||
import { LaunchpadLedger, LaunchpadLedgerOptions } from "./launchpadledger";
|
||||
@ -36,7 +36,7 @@ export class LedgerSigner implements OfflineSigner {
|
||||
return this.accounts;
|
||||
}
|
||||
|
||||
public async sign(signerAddress: string, signDoc: StdSignDoc): Promise<SignResponse> {
|
||||
public async signAmino(signerAddress: string, signDoc: StdSignDoc): Promise<AminoSignResponse> {
|
||||
const accounts = this.accounts || (await this.getAccounts());
|
||||
const accountIndex = accounts.findIndex((account) => account.address === signerAddress);
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/// <reference types="ledgerhq__hw-transport" />
|
||||
import { AccountData, OfflineSigner, StdSignDoc } from "@cosmjs/launchpad";
|
||||
import { SignResponse } from "@cosmjs/launchpad";
|
||||
import { AminoSignResponse } from "@cosmjs/launchpad";
|
||||
import Transport from "@ledgerhq/hw-transport";
|
||||
import { LaunchpadLedgerOptions } from "./launchpadledger";
|
||||
export declare class LedgerSigner implements OfflineSigner {
|
||||
@ -9,5 +9,5 @@ export declare class LedgerSigner implements OfflineSigner {
|
||||
private accounts?;
|
||||
constructor(transport: Transport, options?: LaunchpadLedgerOptions);
|
||||
getAccounts(): Promise<readonly AccountData[]>;
|
||||
sign(signerAddress: string, signDoc: StdSignDoc): Promise<SignResponse>;
|
||||
signAmino(signerAddress: string, signDoc: StdSignDoc): Promise<AminoSignResponse>;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user