diff --git a/packages/launchpad/src/index.ts b/packages/launchpad/src/index.ts index 3701ab33..7cc94695 100644 --- a/packages/launchpad/src/index.ts +++ b/packages/launchpad/src/index.ts @@ -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"; diff --git a/packages/launchpad/src/secp256k1wallet.ts b/packages/launchpad/src/secp256k1wallet.ts index 5f5aea9a..e788250a 100644 --- a/packages/launchpad/src/secp256k1wallet.ts +++ b/packages/launchpad/src/secp256k1wallet.ts @@ -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"; diff --git a/packages/launchpad/src/signer.ts b/packages/launchpad/src/signer.ts new file mode 100644 index 00000000..93e1ce59 --- /dev/null +++ b/packages/launchpad/src/signer.ts @@ -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; + + /** + * Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled. + */ + readonly sign: (address: string, message: Uint8Array, prehashType?: PrehashType) => Promise; +} diff --git a/packages/launchpad/src/signingcosmosclient.ts b/packages/launchpad/src/signingcosmosclient.ts index 5ffbd236..718e7e48 100644 --- a/packages/launchpad/src/signingcosmosclient.ts +++ b/packages/launchpad/src/signingcosmosclient.ts @@ -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 diff --git a/packages/launchpad/src/wallet.ts b/packages/launchpad/src/wallet.ts index eaded173..6f4f2b44 100644 --- a/packages/launchpad/src/wallet.ts +++ b/packages/launchpad/src/wallet.ts @@ -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; - - /** - * Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled. - */ - readonly sign: (address: string, message: Uint8Array, prehashType?: PrehashType) => Promise; -} +import { PrehashType } from "./signer"; export function prehash(bytes: Uint8Array, type: PrehashType): Uint8Array { switch (type) { diff --git a/packages/launchpad/types/index.d.ts b/packages/launchpad/types/index.d.ts index 9d137f0b..ed0097b2 100644 --- a/packages/launchpad/types/index.d.ts +++ b/packages/launchpad/types/index.d.ts @@ -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"; diff --git a/packages/launchpad/types/secp256k1wallet.d.ts b/packages/launchpad/types/secp256k1wallet.d.ts index a24a3366..feed1eef 100644 --- a/packages/launchpad/types/secp256k1wallet.d.ts +++ b/packages/launchpad/types/secp256k1wallet.d.ts @@ -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. diff --git a/packages/launchpad/types/signer.d.ts b/packages/launchpad/types/signer.d.ts new file mode 100644 index 00000000..d21ed77a --- /dev/null +++ b/packages/launchpad/types/signer.d.ts @@ -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; + /** + * Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled. + */ + readonly sign: (address: string, message: Uint8Array, prehashType?: PrehashType) => Promise; +} diff --git a/packages/launchpad/types/signingcosmosclient.d.ts b/packages/launchpad/types/signingcosmosclient.d.ts index e1110ad9..839ad665 100644 --- a/packages/launchpad/types/signingcosmosclient.d.ts +++ b/packages/launchpad/types/signingcosmosclient.d.ts @@ -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 */ diff --git a/packages/launchpad/types/wallet.d.ts b/packages/launchpad/types/wallet.d.ts index 5c284f5d..f3e49071 100644 --- a/packages/launchpad/types/wallet.d.ts +++ b/packages/launchpad/types/wallet.d.ts @@ -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; - /** - * Request signature from whichever key corresponds to provided bech32-encoded address. Rejects if not enabled. - */ - readonly sign: (address: string, message: Uint8Array, prehashType?: PrehashType) => Promise; -} +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`