diff --git a/packages/launchpad/src/secp256k1key.spec.ts b/packages/launchpad/src/secp256k1wallet.spec.ts similarity index 84% rename from packages/launchpad/src/secp256k1key.spec.ts rename to packages/launchpad/src/secp256k1wallet.spec.ts index 643a4b21..6ba21057 100644 --- a/packages/launchpad/src/secp256k1key.spec.ts +++ b/packages/launchpad/src/secp256k1wallet.spec.ts @@ -3,23 +3,23 @@ import { Secp256k1, Secp256k1Signature, Sha256 } from "@cosmjs/crypto"; import { fromBase64, fromHex } from "@cosmjs/encoding"; import { serializeSignDoc, StdSignDoc } from "./encoding"; -import { Secp256k1Key } from "./secp256k1key"; +import { Secp256k1Wallet } from "./secp256k1wallet"; -describe("Secp256k1Key", () => { +describe("Secp256k1Wallet", () => { const defaultPrivkey = fromHex("b8c462d2bb0c1a92edf44f735021f16c270f28ee2c3d1cb49943a5e70a3c763e"); const defaultAddress = "cosmos1kxt5x5q2l57ma2d434pqpafxdm0mgeg9c8cvtx"; const defaultPubkey = fromHex("03f146c27639179e5b67b8646108f48e1a78b146c74939e34afaa5414ad5c93f8a"); describe("fromPrivkey", () => { it("works", async () => { - const signer = await Secp256k1Key.fromPrivkey(defaultPrivkey); + const signer = await Secp256k1Wallet.fromPrivkey(defaultPrivkey); expect(signer).toBeTruthy(); }); }); describe("getAccounts", () => { it("resolves to a list of accounts", async () => { - const signer = await Secp256k1Key.fromPrivkey(defaultPrivkey); + const signer = await Secp256k1Wallet.fromPrivkey(defaultPrivkey); const accounts = await signer.getAccounts(); expect(accounts.length).toEqual(1); expect(accounts[0]).toEqual({ @@ -32,7 +32,7 @@ describe("Secp256k1Key", () => { describe("sign", () => { it("resolves to valid signature if enabled", async () => { - const signer = await Secp256k1Key.fromPrivkey(defaultPrivkey); + const signer = await Secp256k1Wallet.fromPrivkey(defaultPrivkey); const signDoc: StdSignDoc = { msgs: [], fee: { amount: [], gas: "23" }, diff --git a/packages/launchpad/src/secp256k1key.ts b/packages/launchpad/src/secp256k1wallet.ts similarity index 84% rename from packages/launchpad/src/secp256k1key.ts rename to packages/launchpad/src/secp256k1wallet.ts index 33bde15f..174a6b79 100644 --- a/packages/launchpad/src/secp256k1key.ts +++ b/packages/launchpad/src/secp256k1wallet.ts @@ -5,16 +5,21 @@ import { serializeSignDoc, StdSignDoc } from "./encoding"; import { encodeSecp256k1Signature } from "./signature"; import { AccountData, OfflineSigner, SignResponse } from "./signer"; -export class Secp256k1Key implements OfflineSigner { +/** + * A wallet that holds a single secp256k1 keypair. + * + * If you want to work with BIP39 mnemonics and multiple accounts, use Secp256k1HdWallet. + */ +export class Secp256k1Wallet implements OfflineSigner { /** * Creates a Secp256k1 key signer from the given private key * * @param privkey The private key. * @param prefix The bech32 address prefix (human readable part). Defaults to "cosmos". */ - public static async fromPrivkey(privkey: Uint8Array, prefix = "cosmos"): Promise { + public static async fromPrivkey(privkey: Uint8Array, prefix = "cosmos"): Promise { const uncompressed = (await Secp256k1.makeKeypair(privkey)).pubkey; - return new Secp256k1Key(privkey, Secp256k1.compressPubkey(uncompressed), prefix); + return new Secp256k1Wallet(privkey, Secp256k1.compressPubkey(uncompressed), prefix); } private readonly pubkey: Uint8Array; diff --git a/packages/launchpad/types/secp256k1key.d.ts b/packages/launchpad/types/secp256k1wallet.d.ts similarity index 72% rename from packages/launchpad/types/secp256k1key.d.ts rename to packages/launchpad/types/secp256k1wallet.d.ts index 1f5d6edc..401201d8 100644 --- a/packages/launchpad/types/secp256k1key.d.ts +++ b/packages/launchpad/types/secp256k1wallet.d.ts @@ -1,13 +1,18 @@ import { StdSignDoc } from "./encoding"; import { AccountData, OfflineSigner, SignResponse } from "./signer"; -export declare class Secp256k1Key implements OfflineSigner { +/** + * A wallet that holds a single secp256k1 keypair. + * + * If you want to work with BIP39 mnemonics and multiple accounts, use Secp256k1HdWallet. + */ +export declare class Secp256k1Wallet implements OfflineSigner { /** * Creates a Secp256k1 key signer from the given private key * * @param privkey The private key. * @param prefix The bech32 address prefix (human readable part). Defaults to "cosmos". */ - static fromPrivkey(privkey: Uint8Array, prefix?: string): Promise; + static fromPrivkey(privkey: Uint8Array, prefix?: string): Promise; private readonly pubkey; private readonly privkey; private readonly prefix;