From 96fa0f4b6422395410c5f6d0be069c120023043f Mon Sep 17 00:00:00 2001 From: willclarktech Date: Tue, 14 Jul 2020 12:16:12 +0200 Subject: [PATCH] demo-staking: Update test for sdk38 OfflineSigner --- packages/demo-staking/src/index.spec.ts | 29 ++++++++++--------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/packages/demo-staking/src/index.spec.ts b/packages/demo-staking/src/index.spec.ts index 49bd7877..4fe01ede 100644 --- a/packages/demo-staking/src/index.spec.ts +++ b/packages/demo-staking/src/index.spec.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/camelcase */ import { SigningCosmWasmClient } from "@cosmjs/cosmwasm"; -import { Coin, coins, makeCosmoshubPath, Secp256k1Pen } from "@cosmjs/sdk38"; +import { Coin, coins, makeCosmoshubPath, Secp256k1OfflineWallet } from "@cosmjs/sdk38"; import { BalanceResponse, @@ -40,26 +40,19 @@ describe("Staking demo", () => { it("works", async () => { pendingWithoutWasmd(); // The owner of the contract that will collect the tax - const ownerPen = await Secp256k1Pen.fromMnemonic(alice.mnemonic); - const ownerAddress = ownerPen.address("cosmos"); - const ownerClient = new SigningCosmWasmClient(httpUrl, ownerAddress, (signBytes) => - ownerPen.sign(signBytes), - ); + const ownerWallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const [{ address: ownerAddress }] = await ownerWallet.getAccounts(); + const ownerClient = new SigningCosmWasmClient(httpUrl, ownerAddress, ownerWallet); // a user of the contract - const userPen = await Secp256k1Pen.fromMnemonic(alice.mnemonic, makeCosmoshubPath(1)); - const userAddress = userPen.address("cosmos"); - const userClient = new SigningCosmWasmClient( - httpUrl, - userAddress, - (signBytes) => userPen.sign(signBytes), - { - exec: { - amount: coins(5000, "ucosm"), - gas: "300000", // 300k, needed for unbonding - }, + const userWallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic, makeCosmoshubPath(1)); + const [{ address: userAddress }] = await userWallet.getAccounts(); + const userClient = new SigningCosmWasmClient(httpUrl, userAddress, userWallet, { + exec: { + amount: coins(5000, "ucosm"), + gas: "300000", // 300k, needed for unbonding }, - ); + }); const initMsg: InitMsg = { name: params.name,