From 855ce0bb4a3a312d328236494fd94c3237fdb52e Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Tue, 7 Jul 2020 07:17:21 +0200 Subject: [PATCH] Pull out makeSignedTx --- packages/sdk38/src/lcdclient.spec.ts | 14 +++----------- packages/sdk38/src/restclient.spec.ts | 14 +++----------- packages/sdk38/src/testutils.spec.ts | 12 ++++++++++++ 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/packages/sdk38/src/lcdclient.spec.ts b/packages/sdk38/src/lcdclient.spec.ts index a5f13cb9..63b9f859 100644 --- a/packages/sdk38/src/lcdclient.spec.ts +++ b/packages/sdk38/src/lcdclient.spec.ts @@ -7,7 +7,7 @@ import { isPostTxFailure } from "./cosmosclient"; import { makeSignBytes } from "./encoding"; import { LcdApiArray, LcdClient, normalizeArray } from "./lcdclient"; import { parseLogs } from "./logs"; -import { Msg, MsgSend } from "./msgs"; +import { MsgSend } from "./msgs"; import { makeCosmoshubPath, Secp256k1Pen } from "./pen"; import { BroadcastMode, TxsResponse } from "./restclient"; import { SigningCosmosClient } from "./signingcosmosclient"; @@ -15,13 +15,14 @@ import cosmoshub from "./testdata/cosmoshub.json"; import { faucet, makeRandomAddress, + makeSignedTx, nonNegativeIntegerMatcher, pendingWithoutWasmd, tendermintIdMatcher, wasmd, wasmdEnabled, } from "./testutils.spec"; -import { StdFee, StdSignature, StdTx } from "./types"; +import { StdFee } from "./types"; /** Deployed as part of scripts/wasmd/init.sh */ export const deployedErc20 = { @@ -36,15 +37,6 @@ export const deployedErc20 = { ], }; -function makeSignedTx(firstMsg: Msg, fee: StdFee, memo: string, firstSignature: StdSignature): StdTx { - return { - msg: [firstMsg], - fee: fee, - memo: memo, - signatures: [firstSignature], - }; -} - describe("LcdClient", () => { const defaultRecipientAddress = makeRandomAddress(); diff --git a/packages/sdk38/src/restclient.spec.ts b/packages/sdk38/src/restclient.spec.ts index ad17e4be..bc6cffc3 100644 --- a/packages/sdk38/src/restclient.spec.ts +++ b/packages/sdk38/src/restclient.spec.ts @@ -6,7 +6,7 @@ import { rawSecp256k1PubkeyToAddress } from "./address"; import { isPostTxFailure } from "./cosmosclient"; import { makeSignBytes } from "./encoding"; import { parseLogs } from "./logs"; -import { Msg, MsgSend } from "./msgs"; +import { MsgSend } from "./msgs"; import { makeCosmoshubPath, Secp256k1Pen } from "./pen"; import { encodeBech32Pubkey } from "./pubkey"; import { RestClient, TxsResponse } from "./restclient"; @@ -15,6 +15,7 @@ import cosmoshub from "./testdata/cosmoshub.json"; import { faucet, makeRandomAddress, + makeSignedTx, nonNegativeIntegerMatcher, pendingWithoutWasmd, semverMatcher, @@ -26,16 +27,7 @@ import { wasmd, wasmdEnabled, } from "./testutils.spec"; -import { StdFee, StdSignature, StdTx } from "./types"; - -function makeSignedTx(firstMsg: Msg, fee: StdFee, memo: string, firstSignature: StdSignature): StdTx { - return { - msg: [firstMsg], - fee: fee, - memo: memo, - signatures: [firstSignature], - }; -} +import { StdFee } from "./types"; describe("RestClient", () => { const defaultRecipientAddress = makeRandomAddress(); diff --git a/packages/sdk38/src/testutils.spec.ts b/packages/sdk38/src/testutils.spec.ts index b04b1de5..e61c6927 100644 --- a/packages/sdk38/src/testutils.spec.ts +++ b/packages/sdk38/src/testutils.spec.ts @@ -1,6 +1,9 @@ import { Random } from "@cosmjs/crypto"; import { Bech32 } from "@cosmjs/encoding"; +import { Msg } from "./msgs"; +import { StdFee, StdSignature, StdTx } from "./types"; + export function makeRandomAddress(): string { return Bech32.encode("cosmos", Random.getBytes(20)); } @@ -56,3 +59,12 @@ export function fromOneElementArray(elements: ArrayLike): T { if (elements.length !== 1) throw new Error(`Expected exactly one element but got ${elements.length}`); return elements[0]; } + +export function makeSignedTx(firstMsg: Msg, fee: StdFee, memo: string, firstSignature: StdSignature): StdTx { + return { + msg: [firstMsg], + fee: fee, + memo: memo, + signatures: [firstSignature], + }; +}