From b3af6be16f4bd529e55b8e945b524ced44501336 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 26 Jul 2021 14:29:42 +0200 Subject: [PATCH] Pull out makeSignerInfos --- packages/proto-signing/src/signing.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/proto-signing/src/signing.ts b/packages/proto-signing/src/signing.ts index 20b687e5..849f7639 100644 --- a/packages/proto-signing/src/signing.ts +++ b/packages/proto-signing/src/signing.ts @@ -5,8 +5,20 @@ import { AuthInfo, SignDoc, SignerInfo } from "cosmjs-types/cosmos/tx/v1beta1/tx import { Any } from "cosmjs-types/google/protobuf/any"; import Long from "long"; +function makeSignerInfos(pubkeys: readonly Any[], sequence: number, signMode: SignMode): SignerInfo[] { + return pubkeys.map( + (pubkey): SignerInfo => ({ + publicKey: pubkey, + modeInfo: { + single: { mode: signMode }, + }, + sequence: Long.fromNumber(sequence), + }), + ); +} + /** - * Creates and serializes an AuthInfo document using SIGN_MODE_DIRECT. + * Creates and serializes an AuthInfo document. */ export function makeAuthInfoBytes( pubkeys: readonly Any[], @@ -16,15 +28,7 @@ export function makeAuthInfoBytes( signMode = SignMode.SIGN_MODE_DIRECT, ): Uint8Array { const authInfo = { - signerInfos: pubkeys.map( - (pubkey): SignerInfo => ({ - publicKey: pubkey, - modeInfo: { - single: { mode: signMode }, - }, - sequence: Long.fromNumber(sequence), - }), - ), + signerInfos: makeSignerInfos(pubkeys, sequence, signMode), fee: { amount: [...feeAmount], gasLimit: Long.fromNumber(gasLimit),