launchpad-ledger: Update demos

This commit is contained in:
willclarktech 2020-09-16 13:39:10 +02:00
parent 5d426ac35c
commit 12b7178a7f
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
2 changed files with 6 additions and 8 deletions

View File

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { toBase64 } from "@cosmjs/encoding";
import { makeCosmoshubPath, makeSignBytes, StdFee, StdSignature } from "@cosmjs/launchpad";
import { makeSignBytes, StdFee, StdSignature } from "@cosmjs/launchpad";
import { LedgerSigner } from "../ledgersigner";
@ -11,11 +11,10 @@ const defaultFee: StdFee = {
};
const defaultMemo = "Some memo";
const defaultSequence = "0";
const defaultPrehashType = undefined;
const signer = new LedgerSigner({
testModeAllowed: true,
hdPaths: [makeCosmoshubPath(0), makeCosmoshubPath(1), makeCosmoshubPath(2)],
accountNumbers: [0, 1, 2],
});
export async function getAccounts(): Promise<
@ -57,5 +56,5 @@ export async function sign(
accountNumber,
defaultSequence,
);
return signer.sign(fromAddress, signBytes, defaultPrehashType, accountNumber);
return signer.sign(fromAddress, signBytes);
}

View File

@ -1,5 +1,5 @@
import { toBase64, toUtf8 } from "@cosmjs/encoding";
import { AccountData, makeCosmoshubPath } from "@cosmjs/launchpad";
import { AccountData } from "@cosmjs/launchpad";
import { LedgerSigner } from "../ledgersigner";
@ -34,7 +34,7 @@ function createMessage(accountNumber: number, address: string): string {
const signer = new LedgerSigner({
testModeAllowed: true,
hdPaths: [makeCosmoshubPath(0), makeCosmoshubPath(1), makeCosmoshubPath(2)],
accountNumbers: [0, 1, 2],
});
window.updateMessage = (accountNumber: number) => {
@ -80,11 +80,10 @@ window.sign = async function sign(): Promise<void> {
signatureDiv.textContent = "Loading...";
try {
const accountNumber = document.getElementById("account-number").value;
const address = document.getElementById("address").value;
const rawMessage = document.getElementById("message").textContent;
const message = JSON.stringify(JSON.parse(rawMessage));
const signature = await signer.sign(address, toUtf8(message), undefined, parseInt(accountNumber, 10));
const signature = await signer.sign(address, toUtf8(message));
signatureDiv.textContent = JSON.stringify(signature, null, "\t");
} catch (error) {
signatureDiv.textContent = error;