Remove PrehashType

This commit is contained in:
Simon Warta 2020-09-23 13:35:12 +02:00
parent bc890bee73
commit 5f2cf289eb
7 changed files with 7 additions and 34 deletions

View File

@ -49,6 +49,9 @@
serialize a `StdSignDoc`: `makeStdSignDoc` and `serializeSignDoc`.
- @cosmjs/launchpad: Let `OfflineSigner.sign` take an `StdSignDoc` instead of an
encoded message.
- @cosmjs/launchpad: Remove `PrehashType` and the prehash type argument in
`OfflineSigner.sign` because the signer now needs to know how to serialize an
`StdSignDoc`.
- @cosmjs/launchpad-ledger: Add package supporting Ledger device integration for
Launchpad. Two new classes are provided: `LedgerSigner` (for most use cases)
and `LaunchpadLedger` for more fine-grained access.

View File

@ -98,7 +98,7 @@ export {
} from "./pubkey";
export { findSequenceForSignedTx } from "./sequence";
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
export { AccountData, Algo, PrehashType, OfflineSigner } from "./signer";
export { AccountData, Algo, OfflineSigner } from "./signer";
export { CosmosFeeTable, SigningCosmosClient } from "./signingcosmosclient";
export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types";
export { makeCosmoshubPath, executeKdf, KdfConfiguration } from "./wallet";

View File

@ -1,8 +1,6 @@
import { StdSignDoc } from "./encoding";
import { StdSignature } from "./types";
export type PrehashType = "sha256" | "sha512" | null;
export type Algo = "secp256k1" | "ed25519" | "sr25519";
export interface AccountData {
@ -24,9 +22,5 @@ export interface OfflineSigner {
* @param signerAddress The address of the account that should sign the transaction
* @param signDoc The content that should be signed
*/
readonly sign: (
signerAddress: string,
signDoc: StdSignDoc,
prehashType?: PrehashType,
) => Promise<StdSignature>;
readonly sign: (signerAddress: string, signDoc: StdSignDoc) => Promise<StdSignature>;
}

View File

@ -3,29 +3,12 @@ import {
HdPath,
isArgon2idOptions,
Random,
Sha256,
Sha512,
Slip10RawIndex,
xchacha20NonceLength,
Xchacha20poly1305Ietf,
} from "@cosmjs/crypto";
import { toAscii } from "@cosmjs/encoding";
import { PrehashType } from "./signer";
export function prehash(bytes: Uint8Array, type: PrehashType): Uint8Array {
switch (type) {
case null:
return new Uint8Array([...bytes]);
case "sha256":
return new Sha256(bytes).digest();
case "sha512":
return new Sha512(bytes).digest();
default:
throw new Error("Unknown prehash type");
}
}
/**
* The Cosmoshub derivation path in the form `m/44'/118'/0'/0/a`
* with 0-based account index `a`.

View File

@ -96,7 +96,7 @@ export {
} from "./pubkey";
export { findSequenceForSignedTx } from "./sequence";
export { encodeSecp256k1Signature, decodeSignature } from "./signature";
export { AccountData, Algo, PrehashType, OfflineSigner } from "./signer";
export { AccountData, Algo, OfflineSigner } from "./signer";
export { CosmosFeeTable, SigningCosmosClient } from "./signingcosmosclient";
export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types";
export { makeCosmoshubPath, executeKdf, KdfConfiguration } from "./wallet";

View File

@ -1,6 +1,5 @@
import { StdSignDoc } from "./encoding";
import { StdSignature } from "./types";
export declare type PrehashType = "sha256" | "sha512" | null;
export declare type Algo = "secp256k1" | "ed25519" | "sr25519";
export interface AccountData {
/** A printable address (typically bech32 encoded) */
@ -19,9 +18,5 @@ export interface OfflineSigner {
* @param signerAddress The address of the account that should sign the transaction
* @param signDoc The content that should be signed
*/
readonly sign: (
signerAddress: string,
signDoc: StdSignDoc,
prehashType?: PrehashType,
) => Promise<StdSignature>;
readonly sign: (signerAddress: string, signDoc: StdSignDoc) => Promise<StdSignature>;
}

View File

@ -1,6 +1,4 @@
import { HdPath } from "@cosmjs/crypto";
import { PrehashType } from "./signer";
export declare function prehash(bytes: Uint8Array, type: PrehashType): Uint8Array;
/**
* The Cosmoshub derivation path in the form `m/44'/118'/0'/0/a`
* with 0-based account index `a`.