amino: Transfer signer interfaces from launchpad
This commit is contained in:
parent
7a7329cc4f
commit
f616abc4d8
@ -20,3 +20,4 @@ export {
|
||||
} from "./pubkeys";
|
||||
export { createMultisigThresholdPubkey } from "./multisig";
|
||||
export { decodeSignature, encodeSecp256k1Signature, StdSignature } from "./signature";
|
||||
export { AccountData, Algo, AminoMsg, AminoSignResponse, OfflineAminoSigner, StdSignDoc } from "./signer";
|
||||
|
||||
67
packages/amino/src/signer.ts
Normal file
67
packages/amino/src/signer.ts
Normal file
@ -0,0 +1,67 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { StdSignature } from "./signature";
|
||||
|
||||
export interface AminoMsg {
|
||||
readonly type: string;
|
||||
readonly value: any;
|
||||
}
|
||||
|
||||
interface Coin {
|
||||
readonly denom: string;
|
||||
readonly amount: string;
|
||||
}
|
||||
|
||||
interface StdFee {
|
||||
readonly amount: readonly Coin[];
|
||||
readonly gas: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The document to be signed
|
||||
*
|
||||
* @see https://docs.cosmos.network/master/modules/auth/03_types.html#stdsigndoc
|
||||
*/
|
||||
export interface StdSignDoc {
|
||||
readonly chain_id: string;
|
||||
readonly account_number: string;
|
||||
readonly sequence: string;
|
||||
readonly fee: StdFee;
|
||||
readonly msgs: readonly AminoMsg[];
|
||||
readonly memo: string;
|
||||
}
|
||||
|
||||
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 AminoSignResponse {
|
||||
/**
|
||||
* The sign doc that was signed.
|
||||
* This may be different from the input signDoc when the signer modifies it as part of the signing process.
|
||||
*/
|
||||
readonly signed: StdSignDoc;
|
||||
readonly signature: StdSignature;
|
||||
}
|
||||
|
||||
export interface OfflineAminoSigner {
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* The signer implementation may offer the user the ability to override parts of the signDoc. It must
|
||||
* return the doc that was signed in the response.
|
||||
*
|
||||
* @param signerAddress The address of the account that should sign the transaction
|
||||
* @param signDoc The content that should be signed
|
||||
*/
|
||||
readonly signAmino: (signerAddress: string, signDoc: StdSignDoc) => Promise<AminoSignResponse>;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user