diff --git a/packages/cli/examples/delegate.ts b/packages/cli/examples/delegate.ts index dd1dd2d9..88a4a47e 100644 --- a/packages/cli/examples/delegate.ts +++ b/packages/cli/examples/delegate.ts @@ -1,4 +1,4 @@ -const wallet = await Secp256k1OfflineWallet.fromMnemonic( +const wallet = await Secp256k1Wallet.fromMnemonic( "enlist hip relief stomach skate base shallow young switch frequent cry park", ); const [{ address: senderAddress }] = await wallet.getAccounts(); diff --git a/packages/cli/examples/faucet_addresses.ts b/packages/cli/examples/faucet_addresses.ts index 603b9da9..211ff61f 100644 --- a/packages/cli/examples/faucet_addresses.ts +++ b/packages/cli/examples/faucet_addresses.ts @@ -2,7 +2,7 @@ const mnemonic = "economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone"; for (let i of [0, 1, 2, 3, 4]) { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(mnemonic, makeCosmoshubPath(i), "cosmos"); + const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic, makeCosmoshubPath(i), "cosmos"); const [{ address, pubkey }] = await wallet.getAccounts(); console.info(`Address ${i}: ${address}`); console.info(`Pubkey ${i}: ${pubkey}`); diff --git a/packages/cli/examples/generate_address.ts b/packages/cli/examples/generate_address.ts index 88ca6bb9..cbf7ae95 100644 --- a/packages/cli/examples/generate_address.ts +++ b/packages/cli/examples/generate_address.ts @@ -1,5 +1,5 @@ const mnemonic = Bip39.encode(Random.getBytes(16)).toString(); -const wallet = await Secp256k1OfflineWallet.fromMnemonic(mnemonic); +const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic); const [{ address, pubkey }] = await wallet.getAccounts(); console.info("mnemonic:", mnemonic); diff --git a/packages/cli/examples/helpers.ts b/packages/cli/examples/helpers.ts index 69cbf57e..3e39b1af 100644 --- a/packages/cli/examples/helpers.ts +++ b/packages/cli/examples/helpers.ts @@ -52,7 +52,7 @@ const connect = async ( }> => { const options: Options = { ...defaultOptions, ...opts }; const feeTable = buildFeeTable(options.feeToken, options.gasPrice); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic); const [{ address }] = await wallet.getAccounts(); const client = new SigningCosmWasmClient(options.httpUrl, address, wallet, feeTable); @@ -92,7 +92,7 @@ const randomAddress = async (prefix: string): Promise => { }; const mnemonicToAddress = async (prefix: string, mnemonic: string): Promise => { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic); const [{ address }] = await wallet.getAccounts(); return address; }; diff --git a/packages/cli/examples/local_faucet.ts b/packages/cli/examples/local_faucet.ts index 44301d71..ce72447f 100644 --- a/packages/cli/examples/local_faucet.ts +++ b/packages/cli/examples/local_faucet.ts @@ -14,5 +14,5 @@ const faucetMnemonic = "economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone"; const faucetAddress = "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6"; -const wallet = await Secp256k1OfflineWallet.fromMnemonic(faucetMnemonic); +const wallet = await Secp256k1Wallet.fromMnemonic(faucetMnemonic); const client = new LcdClient(defaultHttpUrl); diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 765eea7b..41c4474a 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -100,7 +100,7 @@ export function main(originalArgs: readonly string[]): void { "OfflineSigner", "PubKey", "pubkeyToAddress", - "Secp256k1OfflineWallet", + "Secp256k1Wallet", "SigningCosmosClient", "StdFee", "StdTx", @@ -145,7 +145,7 @@ export function main(originalArgs: readonly string[]): void { assert(Decimal.fromAtomics("12870000", 6).toString() === "12.87"); const mnemonic = Bip39.encode(Random.getBytes(16)).toString(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(mnemonic, makeCosmoshubPath(0)); + const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic, makeCosmoshubPath(0)); const [{ address }] = await wallet.getAccounts(); const data = toAscii("foo bar"); const signature = await wallet.sign(address, data); diff --git a/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts b/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts index 012a0b49..19979b42 100644 --- a/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts +++ b/packages/cosmwasm/src/cosmwasmclient.searchtx.spec.ts @@ -7,7 +7,7 @@ import { LcdClient, makeSignBytes, MsgSend, - Secp256k1OfflineWallet, + Secp256k1Wallet, } from "@cosmjs/sdk38"; import { assert, sleep } from "@cosmjs/utils"; @@ -48,7 +48,7 @@ describe("CosmWasmClient.searchTx", () => { beforeAll(async () => { if (wasmdEnabled()) { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(wasmd.endpoint, alice.address0, wallet); { diff --git a/packages/cosmwasm/src/cosmwasmclient.spec.ts b/packages/cosmwasm/src/cosmwasmclient.spec.ts index 52e88b28..555e113c 100644 --- a/packages/cosmwasm/src/cosmwasmclient.spec.ts +++ b/packages/cosmwasm/src/cosmwasmclient.spec.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/camelcase */ import { Sha256 } from "@cosmjs/crypto"; import { Bech32, fromHex, fromUtf8, toAscii, toBase64 } from "@cosmjs/encoding"; -import { makeSignBytes, MsgSend, Secp256k1OfflineWallet, StdFee } from "@cosmjs/sdk38"; +import { makeSignBytes, MsgSend, Secp256k1Wallet, StdFee } from "@cosmjs/sdk38"; import { assert, sleep } from "@cosmjs/utils"; import { ReadonlyDate } from "readonly-date"; @@ -204,7 +204,7 @@ describe("CosmWasmClient", () => { describe("postTx", () => { it("works", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new CosmWasmClient(wasmd.endpoint); const memo = "My first contract on chain"; @@ -388,7 +388,7 @@ describe("CosmWasmClient", () => { beforeAll(async () => { if (wasmdEnabled()) { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(wasmd.endpoint, alice.address0, wallet); const { codeId } = await client.upload(getHackatom().data); const initMsg = { verifier: makeRandomAddress(), beneficiary: makeRandomAddress() }; @@ -439,7 +439,7 @@ describe("CosmWasmClient", () => { beforeAll(async () => { if (wasmdEnabled()) { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(wasmd.endpoint, alice.address0, wallet); const { codeId } = await client.upload(getHackatom().data); const initMsg = { verifier: makeRandomAddress(), beneficiary: makeRandomAddress() }; diff --git a/packages/cosmwasm/src/lcdapi/wasm.spec.ts b/packages/cosmwasm/src/lcdapi/wasm.spec.ts index 43dd6ff7..0d3aa836 100644 --- a/packages/cosmwasm/src/lcdapi/wasm.spec.ts +++ b/packages/cosmwasm/src/lcdapi/wasm.spec.ts @@ -10,7 +10,7 @@ import { makeSignBytes, OfflineSigner, PostTxsResponse, - Secp256k1OfflineWallet, + Secp256k1Wallet, setupAuthExtension, StdFee, } from "@cosmjs/sdk38"; @@ -256,7 +256,7 @@ describe("wasm", () => { describe("postTx", () => { it("can upload, instantiate and execute wasm", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = makeWasmClient(wasmd.endpoint); const transferAmount = [coin(1234, "ucosm"), coin(321, "ustake")]; @@ -324,7 +324,7 @@ describe("wasm", () => { describe("query", () => { it("can list upload code", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = makeWasmClient(wasmd.endpoint); // check with contracts were here first to compare @@ -362,7 +362,7 @@ describe("wasm", () => { it("can list contracts and get info", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = makeWasmClient(wasmd.endpoint); const beneficiaryAddress = makeRandomAddress(); const transferAmount: readonly Coin[] = [ @@ -438,7 +438,7 @@ describe("wasm", () => { beforeAll(async () => { if (wasmdEnabled()) { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const uploadResult = await uploadContract(client, wallet, getHackatom()); assert(!uploadResult.code); const uploadLogs = parseLogs(uploadResult.logs); diff --git a/packages/cosmwasm/src/signingcosmwasmclient.spec.ts b/packages/cosmwasm/src/signingcosmwasmclient.spec.ts index d3fb5a1c..927458a7 100644 --- a/packages/cosmwasm/src/signingcosmwasmclient.spec.ts +++ b/packages/cosmwasm/src/signingcosmwasmclient.spec.ts @@ -1,13 +1,6 @@ import { Sha256 } from "@cosmjs/crypto"; import { toHex } from "@cosmjs/encoding"; -import { - AuthExtension, - coin, - coins, - LcdClient, - Secp256k1OfflineWallet, - setupAuthExtension, -} from "@cosmjs/sdk38"; +import { AuthExtension, coin, coins, LcdClient, Secp256k1Wallet, setupAuthExtension } from "@cosmjs/sdk38"; import { assert } from "@cosmjs/utils"; import { isPostTxFailure, PrivateCosmWasmClient } from "./cosmwasmclient"; @@ -24,7 +17,7 @@ function makeWasmClient(apiUrl: string): LcdClient & AuthExtension & WasmExtensi describe("SigningCosmWasmClient", () => { describe("makeReadOnly", () => { it("can be constructed", async () => { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); expect(client).toBeTruthy(); }); @@ -33,7 +26,7 @@ describe("SigningCosmWasmClient", () => { describe("getHeight", () => { it("always uses authAccount implementation", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const openedClient = (client as unknown) as PrivateCosmWasmClient; @@ -51,7 +44,7 @@ describe("SigningCosmWasmClient", () => { describe("upload", () => { it("works", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const wasm = getHackatom().data; const { @@ -70,7 +63,7 @@ describe("SigningCosmWasmClient", () => { it("can set builder and source", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const hackatom = getHackatom(); @@ -89,7 +82,7 @@ describe("SigningCosmWasmClient", () => { describe("instantiate", () => { it("works with transfer amount", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const { codeId } = await client.upload(getHackatom().data); @@ -115,7 +108,7 @@ describe("SigningCosmWasmClient", () => { it("works with admin", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const { codeId } = await client.upload(getHackatom().data); @@ -138,7 +131,7 @@ describe("SigningCosmWasmClient", () => { it("can instantiate one code multiple times", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const { codeId } = await client.upload(getHackatom().data); @@ -165,7 +158,7 @@ describe("SigningCosmWasmClient", () => { describe("updateAdmin", () => { it("can update an admin", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const { codeId } = await client.upload(getHackatom().data); @@ -198,7 +191,7 @@ describe("SigningCosmWasmClient", () => { describe("clearAdmin", () => { it("can clear an admin", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const { codeId } = await client.upload(getHackatom().data); @@ -231,7 +224,7 @@ describe("SigningCosmWasmClient", () => { describe("migrate", () => { it("can can migrate from one code ID to another", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const { codeId: codeId1 } = await client.upload(getHackatom().data); const { codeId: codeId2 } = await client.upload(getHackatom().data); @@ -270,7 +263,7 @@ describe("SigningCosmWasmClient", () => { describe("execute", () => { it("works", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const { codeId } = await client.upload(getHackatom().data); @@ -311,7 +304,7 @@ describe("SigningCosmWasmClient", () => { describe("sendTokens", () => { it("works", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); // instantiate diff --git a/packages/cosmwasm/src/signingcosmwasmclient.ts b/packages/cosmwasm/src/signingcosmwasmclient.ts index cfab3de3..4a4b1df9 100644 --- a/packages/cosmwasm/src/signingcosmwasmclient.ts +++ b/packages/cosmwasm/src/signingcosmwasmclient.ts @@ -176,7 +176,7 @@ export class SigningCosmWasmClient extends CosmWasmClient { * * @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API) * @param senderAddress The address that will sign and send transactions using this instance - * @param signer A wallet provider which can provide signatures for transactions, potentially requiring user input. + * @param signer An implementation of OfflineSigner which can provide signatures for transactions, potentially requiring user input. * @param customFees The fees that are paid for transactions * @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns */ diff --git a/packages/cosmwasm/types/signingcosmwasmclient.d.ts b/packages/cosmwasm/types/signingcosmwasmclient.d.ts index 1e876944..18949878 100644 --- a/packages/cosmwasm/types/signingcosmwasmclient.d.ts +++ b/packages/cosmwasm/types/signingcosmwasmclient.d.ts @@ -93,7 +93,7 @@ export declare class SigningCosmWasmClient extends CosmWasmClient { * * @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API) * @param senderAddress The address that will sign and send transactions using this instance - * @param signer A wallet provider which can provide signatures for transactions, potentially requiring user input. + * @param signer An implementation of OfflineSigner which can provide signatures for transactions, potentially requiring user input. * @param customFees The fees that are paid for transactions * @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns */ diff --git a/packages/demo-staking/src/index.spec.ts b/packages/demo-staking/src/index.spec.ts index 4fe01ede..6c6fa869 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, Secp256k1OfflineWallet } from "@cosmjs/sdk38"; +import { Coin, coins, makeCosmoshubPath, Secp256k1Wallet } from "@cosmjs/sdk38"; import { BalanceResponse, @@ -40,12 +40,12 @@ describe("Staking demo", () => { it("works", async () => { pendingWithoutWasmd(); // The owner of the contract that will collect the tax - const ownerWallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const ownerWallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const [{ address: ownerAddress }] = await ownerWallet.getAccounts(); const ownerClient = new SigningCosmWasmClient(httpUrl, ownerAddress, ownerWallet); // a user of the contract - const userWallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic, makeCosmoshubPath(1)); + const userWallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic, makeCosmoshubPath(1)); const [{ address: userAddress }] = await userWallet.getAccounts(); const userClient = new SigningCosmWasmClient(httpUrl, userAddress, userWallet, { exec: { diff --git a/packages/faucet/src/profile.ts b/packages/faucet/src/profile.ts index f5355fba..1ef5cce2 100644 --- a/packages/faucet/src/profile.ts +++ b/packages/faucet/src/profile.ts @@ -1,5 +1,5 @@ import { pathToString } from "@cosmjs/crypto"; -import { makeCosmoshubPath, OfflineSigner, Secp256k1OfflineWallet } from "@cosmjs/sdk38"; +import { makeCosmoshubPath, OfflineSigner, Secp256k1Wallet } from "@cosmjs/sdk38"; export async function createWallets( mnemonic: string, @@ -13,7 +13,7 @@ export async function createWallets( const numberOfIdentities = 1 + numberOfDistributors; for (let i = 0; i < numberOfIdentities; i++) { const path = makeCosmoshubPath(i); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(mnemonic, path, addressPrefix); + const wallet = await Secp256k1Wallet.fromMnemonic(mnemonic, path, addressPrefix); const [{ address }] = await wallet.getAccounts(); if (logging) { const role = i === 0 ? "token holder " : `distributor ${i}`; diff --git a/packages/sdk38/src/cosmosclient.searchtx.spec.ts b/packages/sdk38/src/cosmosclient.searchtx.spec.ts index caeb9e4c..3f244466 100644 --- a/packages/sdk38/src/cosmosclient.searchtx.spec.ts +++ b/packages/sdk38/src/cosmosclient.searchtx.spec.ts @@ -16,7 +16,7 @@ import { wasmdEnabled, } from "./testutils.spec"; import { CosmosSdkTx } from "./types"; -import { Secp256k1OfflineWallet } from "./wallet"; +import { Secp256k1Wallet } from "./wallet"; interface TestTxSend { readonly sender: string; @@ -32,7 +32,7 @@ describe("CosmosClient.searchTx", () => { beforeAll(async () => { if (wasmdEnabled()) { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic); const accounts = await wallet.getAccounts(); const [{ address: walletAddress }] = accounts; const client = new SigningCosmosClient(wasmd.endpoint, faucet.address, wallet); diff --git a/packages/sdk38/src/cosmosclient.spec.ts b/packages/sdk38/src/cosmosclient.spec.ts index f8c3b062..29e2d991 100644 --- a/packages/sdk38/src/cosmosclient.spec.ts +++ b/packages/sdk38/src/cosmosclient.spec.ts @@ -16,7 +16,7 @@ import { wasmd, } from "./testutils.spec"; import { StdFee } from "./types"; -import { Secp256k1OfflineWallet } from "./wallet"; +import { Secp256k1Wallet } from "./wallet"; const blockTime = 1_000; // ms @@ -193,7 +193,7 @@ describe("CosmosClient", () => { describe("postTx", () => { it("works", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic); const accounts = await wallet.getAccounts(); const [{ address: walletAddress }] = accounts; const client = new CosmosClient(wasmd.endpoint); diff --git a/packages/sdk38/src/index.ts b/packages/sdk38/src/index.ts index 5caf70db..4233a729 100644 --- a/packages/sdk38/src/index.ts +++ b/packages/sdk38/src/index.ts @@ -55,4 +55,4 @@ export { findSequenceForSignedTx } from "./sequence"; export { encodeSecp256k1Signature, decodeSignature } from "./signature"; export { FeeTable, SigningCosmosClient } from "./signingcosmosclient"; export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types"; -export { OfflineSigner, Secp256k1OfflineWallet, makeCosmoshubPath } from "./wallet"; +export { OfflineSigner, Secp256k1Wallet, makeCosmoshubPath } from "./wallet"; diff --git a/packages/sdk38/src/lcdapi/lcdclient.spec.ts b/packages/sdk38/src/lcdapi/lcdclient.spec.ts index cf20a5e5..b928af0c 100644 --- a/packages/sdk38/src/lcdapi/lcdclient.spec.ts +++ b/packages/sdk38/src/lcdapi/lcdclient.spec.ts @@ -19,7 +19,7 @@ import { wasmdEnabled, } from "../testutils.spec"; import { StdFee } from "../types"; -import { makeCosmoshubPath, Secp256k1OfflineWallet } from "../wallet"; +import { makeCosmoshubPath, Secp256k1Wallet } from "../wallet"; import { setupAuthExtension } from "./auth"; import { TxsResponse } from "./base"; import { LcdApiArray, LcdClient, normalizeLcdApiArray } from "./lcdclient"; @@ -216,7 +216,7 @@ describe("LcdClient", () => { beforeAll(async () => { if (wasmdEnabled()) { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic); const accounts = await wallet.getAccounts(); const [{ address: walletAddress }] = accounts; const client = new SigningCosmosClient(wasmd.endpoint, faucet.address, wallet); @@ -350,7 +350,7 @@ describe("LcdClient", () => { beforeAll(async () => { if (wasmdEnabled()) { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic); const client = new SigningCosmosClient(wasmd.endpoint, faucet.address, wallet); const recipient = makeRandomAddress(); @@ -531,7 +531,7 @@ describe("LcdClient", () => { describe("postTx", () => { it("can send tokens", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic); const accounts = await wallet.getAccounts(); const [{ address: walletAddress }] = accounts; @@ -581,9 +581,9 @@ describe("LcdClient", () => { it("can't send transaction with additional signatures", async () => { pendingWithoutWasmd(); - const account1 = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(0)); - const account2 = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(1)); - const account3 = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(2)); + const account1 = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(0)); + const account2 = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(1)); + const account3 = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(2)); const [address1, address2, address3] = await Promise.all( [account1, account2, account3].map(async (wallet) => { return (await wallet.getAccounts())[0].address; @@ -639,7 +639,7 @@ describe("LcdClient", () => { it("can send multiple messages with one signature", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(0)); + const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(0)); const accounts = await wallet.getAccounts(); const [{ address: walletAddress }] = accounts; @@ -698,8 +698,8 @@ describe("LcdClient", () => { it("can send multiple messages with multiple signatures", async () => { pendingWithoutWasmd(); - const account1 = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(0)); - const account2 = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(1)); + const account1 = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(0)); + const account2 = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(1)); const [address1, address2] = await Promise.all( [account1, account2].map(async (wallet) => { return (await wallet.getAccounts())[0].address; @@ -769,8 +769,8 @@ describe("LcdClient", () => { it("can't send transaction with wrong signature order (1)", async () => { pendingWithoutWasmd(); - const account1 = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(0)); - const account2 = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(1)); + const account1 = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(0)); + const account2 = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(1)); const [address1, address2] = await Promise.all( [account1, account2].map(async (wallet) => { return (await wallet.getAccounts())[0].address; @@ -835,8 +835,8 @@ describe("LcdClient", () => { it("can't send transaction with wrong signature order (2)", async () => { pendingWithoutWasmd(); - const account1 = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(0)); - const account2 = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(1)); + const account1 = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(0)); + const account2 = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic, makeCosmoshubPath(1)); const [address1, address2] = await Promise.all( [account1, account2].map(async (wallet) => { return (await wallet.getAccounts())[0].address; diff --git a/packages/sdk38/src/signingcosmosclient.spec.ts b/packages/sdk38/src/signingcosmosclient.spec.ts index 93a833e0..ac5c6e5f 100644 --- a/packages/sdk38/src/signingcosmosclient.spec.ts +++ b/packages/sdk38/src/signingcosmosclient.spec.ts @@ -4,7 +4,7 @@ import { Coin } from "./coins"; import { isPostTxFailure, PrivateCosmWasmClient } from "./cosmosclient"; import { SigningCosmosClient } from "./signingcosmosclient"; import { makeRandomAddress, pendingWithoutWasmd } from "./testutils.spec"; -import { Secp256k1OfflineWallet } from "./wallet"; +import { Secp256k1Wallet } from "./wallet"; const httpUrl = "http://localhost:1317"; @@ -21,7 +21,7 @@ const faucet = { describe("SigningCosmosClient", () => { describe("makeReadOnly", () => { it("can be constructed", async () => { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic); const client = new SigningCosmosClient(httpUrl, faucet.address, wallet); expect(client).toBeTruthy(); }); @@ -30,7 +30,7 @@ describe("SigningCosmosClient", () => { describe("getHeight", () => { it("always uses authAccount implementation", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic); const client = new SigningCosmosClient(httpUrl, faucet.address, wallet); const openedClient = (client as unknown) as PrivateCosmWasmClient; @@ -48,7 +48,7 @@ describe("SigningCosmosClient", () => { describe("sendTokens", () => { it("works", async () => { pendingWithoutWasmd(); - const wallet = await Secp256k1OfflineWallet.fromMnemonic(faucet.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic); const client = new SigningCosmosClient(httpUrl, faucet.address, wallet); // instantiate diff --git a/packages/sdk38/src/signingcosmosclient.ts b/packages/sdk38/src/signingcosmosclient.ts index 8be5d14b..63d7f89a 100644 --- a/packages/sdk38/src/signingcosmosclient.ts +++ b/packages/sdk38/src/signingcosmosclient.ts @@ -46,7 +46,7 @@ export class SigningCosmosClient extends CosmosClient { * * @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API) * @param senderAddress The address that will sign and send transactions using this instance - * @param signer A wallet provider which can provide signatures for transactions, potentially requiring user input. + * @param signer An implementation of OfflineSigner which can provide signatures for transactions, potentially requiring user input. * @param customFees The fees that are paid for transactions * @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns */ diff --git a/packages/sdk38/src/wallet.spec.ts b/packages/sdk38/src/wallet.spec.ts index bb1b1d18..c016b1a8 100644 --- a/packages/sdk38/src/wallet.spec.ts +++ b/packages/sdk38/src/wallet.spec.ts @@ -1,9 +1,9 @@ import { Secp256k1, Secp256k1Signature, Sha256 } from "@cosmjs/crypto"; import { fromBase64, fromHex, toAscii } from "@cosmjs/encoding"; -import { Secp256k1OfflineWallet } from "./wallet"; +import { Secp256k1Wallet } from "./wallet"; -describe("Secp256k1OfflineWallet", () => { +describe("Secp256k1Wallet", () => { // m/44'/118'/0'/0/0 // pubkey: 02baa4ef93f2ce84592a49b1d729c074eab640112522a7a89f7d03ebab21ded7b6 const defaultMnemonic = "special sign fit simple patrol salute grocery chicken wheat radar tonight ceiling"; @@ -11,13 +11,13 @@ describe("Secp256k1OfflineWallet", () => { const defaultAddress = "cosmos1jhg0e7s6gn44tfc5k37kr04sznyhedtc9rzys5"; it("can be constructed", async () => { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(defaultMnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(defaultMnemonic); expect(wallet).toBeTruthy(); }); describe("getAccounts", () => { it("resolves to a list of accounts if enabled", async () => { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(defaultMnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(defaultMnemonic); const accounts = await wallet.getAccounts(); expect(accounts.length).toEqual(1); expect(accounts[0]).toEqual({ @@ -28,7 +28,7 @@ describe("Secp256k1OfflineWallet", () => { }); it("creates the same address as Go implementation", async () => { - const wallet = await Secp256k1OfflineWallet.fromMnemonic( + const wallet = await Secp256k1Wallet.fromMnemonic( "oyster design unusual machine spread century engine gravity focus cave carry slot", ); const [{ address }] = await wallet.getAccounts(); @@ -38,7 +38,7 @@ describe("Secp256k1OfflineWallet", () => { describe("sign", () => { it("resolves to valid signature if enabled", async () => { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(defaultMnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(defaultMnemonic); const message = toAscii("foo bar"); const signature = await wallet.sign(defaultAddress, message); const valid = await Secp256k1.verifySignature( diff --git a/packages/sdk38/src/wallet.ts b/packages/sdk38/src/wallet.ts index 1bf42fc8..c252d9a7 100644 --- a/packages/sdk38/src/wallet.ts +++ b/packages/sdk38/src/wallet.ts @@ -63,16 +63,16 @@ export function makeCosmoshubPath(a: number): readonly Slip10RawIndex[] { ]; } -export class Secp256k1OfflineWallet implements OfflineSigner { +export class Secp256k1Wallet implements OfflineSigner { public static async fromMnemonic( mnemonic: string, hdPath: readonly Slip10RawIndex[] = makeCosmoshubPath(0), prefix = "cosmos", - ): Promise { + ): Promise { const seed = await Bip39.mnemonicToSeed(new EnglishMnemonic(mnemonic)); const { privkey } = Slip10.derivePath(Slip10Curve.Secp256k1, seed, hdPath); const uncompressed = (await Secp256k1.makeKeypair(privkey)).pubkey; - return new Secp256k1OfflineWallet(privkey, Secp256k1.compressPubkey(uncompressed), prefix); + return new Secp256k1Wallet(privkey, Secp256k1.compressPubkey(uncompressed), prefix); } private readonly pubkey: Uint8Array; diff --git a/packages/sdk38/types/index.d.ts b/packages/sdk38/types/index.d.ts index 0deb1c37..4fd2a02e 100644 --- a/packages/sdk38/types/index.d.ts +++ b/packages/sdk38/types/index.d.ts @@ -53,4 +53,4 @@ export { findSequenceForSignedTx } from "./sequence"; export { encodeSecp256k1Signature, decodeSignature } from "./signature"; export { FeeTable, SigningCosmosClient } from "./signingcosmosclient"; export { isStdTx, pubkeyType, CosmosSdkTx, PubKey, StdFee, StdSignature, StdTx } from "./types"; -export { OfflineSigner, Secp256k1OfflineWallet, makeCosmoshubPath } from "./wallet"; +export { OfflineSigner, Secp256k1Wallet, makeCosmoshubPath } from "./wallet"; diff --git a/packages/sdk38/types/signingcosmosclient.d.ts b/packages/sdk38/types/signingcosmosclient.d.ts index dfcb9a70..616b3e25 100644 --- a/packages/sdk38/types/signingcosmosclient.d.ts +++ b/packages/sdk38/types/signingcosmosclient.d.ts @@ -21,7 +21,7 @@ export declare class SigningCosmosClient extends CosmosClient { * * @param apiUrl The URL of a Cosmos SDK light client daemon API (sometimes called REST server or REST API) * @param senderAddress The address that will sign and send transactions using this instance - * @param signer A wallet provider which can provide signatures for transactions, potentially requiring user input. + * @param signer An implementation of OfflineSigner which can provide signatures for transactions, potentially requiring user input. * @param customFees The fees that are paid for transactions * @param broadcastMode Defines at which point of the transaction processing the postTx method (i.e. transaction broadcasting) returns */ diff --git a/packages/sdk38/types/wallet.d.ts b/packages/sdk38/types/wallet.d.ts index 27c5bcad..463ce554 100644 --- a/packages/sdk38/types/wallet.d.ts +++ b/packages/sdk38/types/wallet.d.ts @@ -22,12 +22,12 @@ export interface OfflineSigner { * with 0-based account index `a`. */ export declare function makeCosmoshubPath(a: number): readonly Slip10RawIndex[]; -export declare class Secp256k1OfflineWallet implements OfflineSigner { +export declare class Secp256k1Wallet implements OfflineSigner { static fromMnemonic( mnemonic: string, hdPath?: readonly Slip10RawIndex[], prefix?: string, - ): Promise; + ): Promise; private readonly pubkey; private readonly privkey; private readonly prefix; diff --git a/scripts/wasmd/deploy_erc20.js b/scripts/wasmd/deploy_erc20.js index edd912a6..6ce0f5c9 100755 --- a/scripts/wasmd/deploy_erc20.js +++ b/scripts/wasmd/deploy_erc20.js @@ -2,7 +2,7 @@ /* eslint-disable @typescript-eslint/camelcase */ const { SigningCosmWasmClient } = require("@cosmjs/cosmwasm"); -const { Secp256k1OfflineWallet } = require("@cosmjs/sdk38"); +const { Secp256k1Wallet } = require("@cosmjs/sdk38"); const fs = require("fs"); const httpUrl = "http://localhost:1317"; @@ -134,7 +134,7 @@ const initDataJade = { }; async function main() { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const wasm = fs.readFileSync(__dirname + "/contracts/cw-erc20.wasm"); diff --git a/scripts/wasmd/deploy_nameservice.js b/scripts/wasmd/deploy_nameservice.js index 21853214..1a20340e 100755 --- a/scripts/wasmd/deploy_nameservice.js +++ b/scripts/wasmd/deploy_nameservice.js @@ -2,7 +2,7 @@ /* eslint-disable @typescript-eslint/camelcase */ const { SigningCosmWasmClient } = require("@cosmjs/cosmwasm"); -const { Secp256k1OfflineWallet } = require("@cosmjs/sdk38"); +const { Secp256k1Wallet } = require("@cosmjs/sdk38"); const fs = require("fs"); const httpUrl = "http://localhost:1317"; @@ -36,7 +36,7 @@ const luxury = { }; async function main() { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet); const wasm = fs.readFileSync(__dirname + "/contracts/cw-nameservice.wasm"); diff --git a/scripts/wasmd/deploy_staking.js b/scripts/wasmd/deploy_staking.js index a1bb7926..ce9b32bb 100755 --- a/scripts/wasmd/deploy_staking.js +++ b/scripts/wasmd/deploy_staking.js @@ -2,7 +2,7 @@ /* eslint-disable @typescript-eslint/camelcase */ const { SigningCosmWasmClient } = require("@cosmjs/cosmwasm"); -const { coins, Secp256k1OfflineWallet } = require("@cosmjs/sdk38"); +const { coins, Secp256k1Wallet } = require("@cosmjs/sdk38"); const fs = require("fs"); const httpUrl = "http://localhost:1317"; @@ -38,7 +38,7 @@ const fees = { }; async function main() { - const wallet = await Secp256k1OfflineWallet.fromMnemonic(alice.mnemonic); + const wallet = await Secp256k1Wallet.fromMnemonic(alice.mnemonic); const client = new SigningCosmWasmClient(httpUrl, alice.address0, wallet, fees); const wasm = fs.readFileSync(__dirname + "/contracts/staking.wasm");