Move OfflineSigner interface to signer module

This commit is contained in:
Simon Warta 2020-09-23 10:21:42 +02:00
parent 973a31028a
commit a0ee9963c1
10 changed files with 54 additions and 66 deletions

View File

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

View File

@ -14,18 +14,16 @@ import { assert, isNonNullObject } from "@cosmjs/utils";
import { rawSecp256k1PubkeyToAddress } from "./address";
import { encodeSecp256k1Signature } from "./signature";
import { AccountData, OfflineSigner, PrehashType } from "./signer";
import { StdSignature } from "./types";
import {
AccountData,
decrypt,
encrypt,
EncryptionConfiguration,
executeKdf,
KdfConfiguration,
makeCosmoshubPath,
OfflineSigner,
prehash,
PrehashType,
supportedAlgorithms,
} from "./wallet";

View File

@ -0,0 +1,24 @@
import { StdSignature } from "./types";
export type PrehashType = "sha256" | "sha512" | null;
export type Algo = "secp256k1" | "ed25519" | "sr25519";
export interface AccountData {
/** A printable address (typically bech32 encoded) */
readonly address: string;
readonly algo: Algo;
readonly pubkey: Uint8Array;
}
export interface OfflineSigner {
/**
* Get AccountData array from wallet. Rejects if not enabled.
*/
readonly getAccounts: () => Promise<readonly AccountData[]>;
/**
* Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled.
*/
readonly sign: (address: string, message: Uint8Array, prehashType?: PrehashType) => Promise<StdSignature>;
}

View File

@ -5,8 +5,8 @@ import { makeSignBytes } from "./encoding";
import { buildFeeTable, FeeTable, GasLimits, GasPrice } from "./gas";
import { BroadcastMode } from "./lcdapi";
import { Msg, MsgSend } from "./msgs";
import { OfflineSigner } from "./signer";
import { StdFee, StdTx } from "./types";
import { OfflineSigner } from "./wallet";
/**
* These fees are used by the higher level methods of SigningCosmosClient

View File

@ -11,30 +11,7 @@ import {
} from "@cosmjs/crypto";
import { toAscii } from "@cosmjs/encoding";
import { StdSignature } from "./types";
export type PrehashType = "sha256" | "sha512" | null;
export type Algo = "secp256k1" | "ed25519" | "sr25519";
export interface AccountData {
// bech32-encoded
readonly address: string;
readonly algo: Algo;
readonly pubkey: Uint8Array;
}
export interface OfflineSigner {
/**
* Get AccountData array from wallet. Rejects if not enabled.
*/
readonly getAccounts: () => Promise<readonly AccountData[]>;
/**
* Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled.
*/
readonly sign: (address: string, message: Uint8Array, prehashType?: PrehashType) => Promise<StdSignature>;
}
import { PrehashType } from "./signer";
export function prehash(bytes: Uint8Array, type: PrehashType): Uint8Array {
switch (type) {

View File

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

View File

@ -1,6 +1,7 @@
import { HdPath } from "@cosmjs/crypto";
import { AccountData, OfflineSigner, PrehashType } from "./signer";
import { StdSignature } from "./types";
import { AccountData, EncryptionConfiguration, KdfConfiguration, OfflineSigner, PrehashType } from "./wallet";
import { EncryptionConfiguration, KdfConfiguration } from "./wallet";
/**
* This interface describes a JSON object holding the encrypted wallet and the meta data.
* All fields in here must be JSON types.

19
packages/launchpad/types/signer.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
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) */
readonly address: string;
readonly algo: Algo;
readonly pubkey: Uint8Array;
}
export interface OfflineSigner {
/**
* Get AccountData array from wallet. Rejects if not enabled.
*/
readonly getAccounts: () => Promise<readonly AccountData[]>;
/**
* Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled.
*/
readonly sign: (address: string, message: Uint8Array, prehashType?: PrehashType) => Promise<StdSignature>;
}

View File

@ -3,8 +3,8 @@ import { Account, BroadcastTxResult, CosmosClient, GetSequenceResult } from "./c
import { FeeTable, GasLimits, GasPrice } from "./gas";
import { BroadcastMode } from "./lcdapi";
import { Msg } from "./msgs";
import { OfflineSigner } from "./signer";
import { StdFee } from "./types";
import { OfflineSigner } from "./wallet";
/**
* These fees are used by the higher level methods of SigningCosmosClient
*/

View File

@ -1,22 +1,5 @@
import { HdPath } from "@cosmjs/crypto";
import { StdSignature } from "./types";
export declare type PrehashType = "sha256" | "sha512" | null;
export declare type Algo = "secp256k1" | "ed25519" | "sr25519";
export interface AccountData {
readonly address: string;
readonly algo: Algo;
readonly pubkey: Uint8Array;
}
export interface OfflineSigner {
/**
* Get AccountData array from wallet. Rejects if not enabled.
*/
readonly getAccounts: () => Promise<readonly AccountData[]>;
/**
* Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled.
*/
readonly sign: (address: string, message: Uint8Array, prehashType?: PrehashType) => Promise<StdSignature>;
}
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`