mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-10 21:49:15 +00:00
Move OfflineSigner interface to signer module
This commit is contained in:
parent
973a31028a
commit
a0ee9963c1
@ -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";
|
||||
|
@ -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";
|
||||
|
||||
|
24
packages/launchpad/src/signer.ts
Normal file
24
packages/launchpad/src/signer.ts
Normal 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>;
|
||||
}
|
@ -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
|
||||
|
@ -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) {
|
||||
|
11
packages/launchpad/types/index.d.ts
vendored
11
packages/launchpad/types/index.d.ts
vendored
@ -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";
|
||||
|
@ -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
19
packages/launchpad/types/signer.d.ts
vendored
Normal 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>;
|
||||
}
|
@ -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
|
||||
*/
|
||||
|
19
packages/launchpad/types/wallet.d.ts
vendored
19
packages/launchpad/types/wallet.d.ts
vendored
@ -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`
|
||||
|
Loading…
x
Reference in New Issue
Block a user