From 5b5a173f5a93d23799b657ea1e68f36a4a04db3a Mon Sep 17 00:00:00 2001 From: willclarktech Date: Wed, 21 Oct 2020 16:07:05 +0200 Subject: [PATCH] proto-signing: Add OfflineSigner and OfflineDirectSigner types --- packages/proto-signing/src/signer.ts | 22 ++++++++++++++++++++++ packages/proto-signing/types/signer.d.ts | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 packages/proto-signing/src/signer.ts create mode 100644 packages/proto-signing/types/signer.d.ts diff --git a/packages/proto-signing/src/signer.ts b/packages/proto-signing/src/signer.ts new file mode 100644 index 00000000..a5aca75b --- /dev/null +++ b/packages/proto-signing/src/signer.ts @@ -0,0 +1,22 @@ +import { AccountData, OfflineSigner as OfflineAminoSigner, StdSignature } from "@cosmjs/launchpad"; + +import { cosmos } from "./codec"; + +export interface DirectSignResponse { + /** + * 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: cosmos.tx.v1beta1.ISignDoc; + readonly signature: StdSignature; +} + +export interface OfflineDirectSigner { + readonly getAccounts: () => Promise; + readonly signDirect: ( + signerAddress: string, + signDoc: cosmos.tx.v1beta1.ISignDoc, + ) => Promise; +} + +export type OfflineSigner = OfflineAminoSigner | OfflineDirectSigner; diff --git a/packages/proto-signing/types/signer.d.ts b/packages/proto-signing/types/signer.d.ts new file mode 100644 index 00000000..dc2d9e98 --- /dev/null +++ b/packages/proto-signing/types/signer.d.ts @@ -0,0 +1,18 @@ +import { AccountData, OfflineSigner as OfflineAminoSigner, StdSignature } from "@cosmjs/launchpad"; +import { cosmos } from "./codec"; +export interface DirectSignResponse { + /** + * 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: cosmos.tx.v1beta1.ISignDoc; + readonly signature: StdSignature; +} +export interface OfflineDirectSigner { + readonly getAccounts: () => Promise; + readonly signDirect: ( + signerAddress: string, + signDoc: cosmos.tx.v1beta1.ISignDoc, + ) => Promise; +} +export declare type OfflineSigner = OfflineAminoSigner | OfflineDirectSigner;