Merge pull request #663 from cosmos/duplicate-launchpad-types
Duplicate launchpad types (1)
This commit is contained in:
commit
466e31e5fd
@ -13,7 +13,6 @@ import {
|
||||
import { sha256 } from "@cosmjs/crypto";
|
||||
import { fromBase64, toAscii, toHex } from "@cosmjs/encoding";
|
||||
import {
|
||||
AccountData,
|
||||
buildFeeTable,
|
||||
Coin,
|
||||
CosmosFeeTable,
|
||||
@ -339,7 +338,7 @@ export class SigningCosmWasmClient extends CosmWasmClient {
|
||||
memo = "",
|
||||
): Promise<BroadcastTxResponse> {
|
||||
const accountFromSigner = (await this.signer.getAccounts()).find(
|
||||
(account: AccountData) => account.address === signerAddress,
|
||||
(account) => account.address === signerAddress,
|
||||
);
|
||||
if (!accountFromSigner) {
|
||||
throw new Error("Failed to retrieve account from signer");
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Bip39, EnglishMnemonic, Random, Secp256k1, Slip10, Slip10Curve } from "@cosmjs/crypto";
|
||||
import { Bech32, fromBase64 } from "@cosmjs/encoding";
|
||||
import { AminoSignResponse, coins, Secp256k1HdWallet, StdSignDoc } from "@cosmjs/launchpad";
|
||||
import {
|
||||
AminoSignResponse,
|
||||
coins,
|
||||
DirectSecp256k1HdWallet,
|
||||
DirectSignResponse,
|
||||
makeAuthInfoBytes,
|
||||
makeCosmoshubPath,
|
||||
Secp256k1HdWallet,
|
||||
StdSignDoc,
|
||||
} from "@cosmjs/launchpad";
|
||||
import { DirectSecp256k1HdWallet, DirectSignResponse, makeAuthInfoBytes } from "@cosmjs/proto-signing";
|
||||
} from "@cosmjs/proto-signing";
|
||||
import {
|
||||
AuthExtension,
|
||||
BankExtension,
|
||||
|
||||
@ -124,6 +124,7 @@ export {
|
||||
MsgWithdrawDelegatorReward,
|
||||
MsgWithdrawValidatorCommission,
|
||||
} from "./msgs";
|
||||
export { makeCosmoshubPath } from "./paths";
|
||||
export {
|
||||
decodeAminoPubkey,
|
||||
decodeBech32Pubkey,
|
||||
@ -137,6 +138,6 @@ export { AccountData, Algo, AminoSignResponse, OfflineSigner } from "./signer";
|
||||
export { CosmosFeeTable, SigningCosmosClient } from "./signingcosmosclient";
|
||||
export { isStdTx, isWrappedStdTx, makeStdTx, CosmosSdkTx, StdTx, WrappedStdTx, WrappedTx } from "./tx";
|
||||
export { pubkeyType, PubKey, StdFee, StdSignature } from "./types";
|
||||
export { makeCosmoshubPath, executeKdf, KdfConfiguration } from "./wallet";
|
||||
export { executeKdf, KdfConfiguration } from "./wallet";
|
||||
export { extractKdfConfiguration, Secp256k1HdWallet } from "./secp256k1hdwallet";
|
||||
export { Secp256k1Wallet } from "./secp256k1wallet";
|
||||
|
||||
@ -6,6 +6,7 @@ import { isBroadcastTxFailure } from "../cosmosclient";
|
||||
import { makeSignDoc } from "../encoding";
|
||||
import { parseLogs } from "../logs";
|
||||
import { MsgSend } from "../msgs";
|
||||
import { makeCosmoshubPath } from "../paths";
|
||||
import { Secp256k1HdWallet } from "../secp256k1hdwallet";
|
||||
import { SigningCosmosClient } from "../signingcosmosclient";
|
||||
import cosmoshub from "../testdata/cosmoshub.json";
|
||||
@ -21,7 +22,6 @@ import {
|
||||
} from "../testutils.spec";
|
||||
import { isWrappedStdTx, makeStdTx, StdTx } from "../tx";
|
||||
import { StdFee } from "../types";
|
||||
import { makeCosmoshubPath } from "../wallet";
|
||||
import { setupAuthExtension } from "./auth";
|
||||
import { TxsResponse } from "./base";
|
||||
import { LcdApiArray, LcdClient } from "./lcdclient";
|
||||
|
||||
26
packages/launchpad/src/paths.spec.ts
Normal file
26
packages/launchpad/src/paths.spec.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { Slip10RawIndex } from "@cosmjs/crypto";
|
||||
|
||||
import { makeCosmoshubPath } from "./paths";
|
||||
|
||||
describe("paths", () => {
|
||||
describe("makeCosmoshubPath", () => {
|
||||
it("works", () => {
|
||||
// m/44'/118'/0'/0/0
|
||||
expect(makeCosmoshubPath(0)).toEqual([
|
||||
Slip10RawIndex.hardened(44),
|
||||
Slip10RawIndex.hardened(118),
|
||||
Slip10RawIndex.hardened(0),
|
||||
Slip10RawIndex.normal(0),
|
||||
Slip10RawIndex.normal(0),
|
||||
]);
|
||||
// m/44'/118'/0'/0/123
|
||||
expect(makeCosmoshubPath(123)).toEqual([
|
||||
Slip10RawIndex.hardened(44),
|
||||
Slip10RawIndex.hardened(118),
|
||||
Slip10RawIndex.hardened(0),
|
||||
Slip10RawIndex.normal(0),
|
||||
Slip10RawIndex.normal(123),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
15
packages/launchpad/src/paths.ts
Normal file
15
packages/launchpad/src/paths.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { HdPath, Slip10RawIndex } from "@cosmjs/crypto";
|
||||
|
||||
/**
|
||||
* The Cosmos Hub derivation path in the form `m/44'/118'/0'/0/a`
|
||||
* with 0-based account index `a`.
|
||||
*/
|
||||
export function makeCosmoshubPath(a: number): HdPath {
|
||||
return [
|
||||
Slip10RawIndex.hardened(44),
|
||||
Slip10RawIndex.hardened(118),
|
||||
Slip10RawIndex.hardened(0),
|
||||
Slip10RawIndex.normal(0),
|
||||
Slip10RawIndex.normal(a),
|
||||
];
|
||||
}
|
||||
@ -15,6 +15,7 @@ import { assert, isNonNullObject } from "@cosmjs/utils";
|
||||
|
||||
import { rawSecp256k1PubkeyToAddress } from "./address";
|
||||
import { serializeSignDoc, StdSignDoc } from "./encoding";
|
||||
import { makeCosmoshubPath } from "./paths";
|
||||
import { encodeSecp256k1Signature } from "./signature";
|
||||
import { AccountData, AminoSignResponse, OfflineSigner } from "./signer";
|
||||
import {
|
||||
@ -23,7 +24,6 @@ import {
|
||||
EncryptionConfiguration,
|
||||
executeKdf,
|
||||
KdfConfiguration,
|
||||
makeCosmoshubPath,
|
||||
supportedAlgorithms,
|
||||
} from "./wallet";
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import { Coin, coin, coins } from "./coins";
|
||||
import { assertIsBroadcastTxSuccess, PrivateCosmosClient } from "./cosmosclient";
|
||||
import { GasPrice } from "./gas";
|
||||
import { MsgDelegate, MsgSend } from "./msgs";
|
||||
import { makeCosmoshubPath } from "./paths";
|
||||
import { Secp256k1HdWallet } from "./secp256k1hdwallet";
|
||||
import { PrivateSigningCosmosClient, SigningCosmosClient } from "./signingcosmosclient";
|
||||
import {
|
||||
@ -14,7 +15,6 @@ import {
|
||||
makeRandomAddress,
|
||||
pendingWithoutLaunchpad,
|
||||
} from "./testutils.spec";
|
||||
import { makeCosmoshubPath } from "./wallet";
|
||||
|
||||
describe("SigningCosmosClient", () => {
|
||||
describe("makeReadOnly", () => {
|
||||
|
||||
@ -1,28 +1,12 @@
|
||||
import {
|
||||
Argon2id,
|
||||
HdPath,
|
||||
isArgon2idOptions,
|
||||
Random,
|
||||
Slip10RawIndex,
|
||||
xchacha20NonceLength,
|
||||
Xchacha20poly1305Ietf,
|
||||
} from "@cosmjs/crypto";
|
||||
import { toAscii } from "@cosmjs/encoding";
|
||||
|
||||
/**
|
||||
* The Cosmoshub derivation path in the form `m/44'/118'/0'/0/a`
|
||||
* with 0-based account index `a`.
|
||||
*/
|
||||
export function makeCosmoshubPath(a: number): HdPath {
|
||||
return [
|
||||
Slip10RawIndex.hardened(44),
|
||||
Slip10RawIndex.hardened(118),
|
||||
Slip10RawIndex.hardened(0),
|
||||
Slip10RawIndex.normal(0),
|
||||
Slip10RawIndex.normal(a),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* A fixed salt is chosen to archive a deterministic password to key derivation.
|
||||
* This reduces the scope of a potential rainbow attack to all CosmJS users.
|
||||
|
||||
@ -8,15 +8,11 @@ import {
|
||||
Slip10,
|
||||
Slip10Curve,
|
||||
} from "@cosmjs/crypto";
|
||||
import {
|
||||
AccountData,
|
||||
encodeSecp256k1Signature,
|
||||
makeCosmoshubPath,
|
||||
rawSecp256k1PubkeyToAddress,
|
||||
} from "@cosmjs/launchpad";
|
||||
import { encodeSecp256k1Signature, rawSecp256k1PubkeyToAddress } from "@cosmjs/launchpad";
|
||||
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { DirectSignResponse, OfflineDirectSigner } from "./signer";
|
||||
import { makeCosmoshubPath } from "./paths";
|
||||
import { AccountData, DirectSignResponse, OfflineDirectSigner } from "./signer";
|
||||
import { makeSignBytes } from "./signing";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import { Secp256k1, sha256 } from "@cosmjs/crypto";
|
||||
import { AccountData, encodeSecp256k1Signature, rawSecp256k1PubkeyToAddress } from "@cosmjs/launchpad";
|
||||
import { encodeSecp256k1Signature, rawSecp256k1PubkeyToAddress } from "@cosmjs/launchpad";
|
||||
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { DirectSignResponse, OfflineDirectSigner } from "./signer";
|
||||
import { AccountData, DirectSignResponse, OfflineDirectSigner } from "./signer";
|
||||
import { makeSignBytes } from "./signing";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
export { EncodeObject, GeneratedType, Registry } from "./registry";
|
||||
export { DirectSecp256k1HdWallet } from "./directsecp256k1hdwallet";
|
||||
export { DirectSecp256k1Wallet } from "./directsecp256k1wallet";
|
||||
export { makeCosmoshubPath } from "./paths";
|
||||
export { decodePubkey, encodePubkey } from "./pubkey";
|
||||
export { DirectSignResponse, isOfflineDirectSigner, OfflineDirectSigner, OfflineSigner } from "./signer";
|
||||
export {
|
||||
AccountData,
|
||||
Algo,
|
||||
DirectSignResponse,
|
||||
isOfflineDirectSigner,
|
||||
OfflineDirectSigner,
|
||||
OfflineSigner,
|
||||
} from "./signer";
|
||||
export { makeAuthInfoBytes, makeSignBytes, makeSignDoc } from "./signing";
|
||||
|
||||
26
packages/proto-signing/src/paths.spec.ts
Normal file
26
packages/proto-signing/src/paths.spec.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { Slip10RawIndex } from "@cosmjs/crypto";
|
||||
|
||||
import { makeCosmoshubPath } from "./paths";
|
||||
|
||||
describe("paths", () => {
|
||||
describe("makeCosmoshubPath", () => {
|
||||
it("works", () => {
|
||||
// m/44'/118'/0'/0/0
|
||||
expect(makeCosmoshubPath(0)).toEqual([
|
||||
Slip10RawIndex.hardened(44),
|
||||
Slip10RawIndex.hardened(118),
|
||||
Slip10RawIndex.hardened(0),
|
||||
Slip10RawIndex.normal(0),
|
||||
Slip10RawIndex.normal(0),
|
||||
]);
|
||||
// m/44'/118'/0'/0/123
|
||||
expect(makeCosmoshubPath(123)).toEqual([
|
||||
Slip10RawIndex.hardened(44),
|
||||
Slip10RawIndex.hardened(118),
|
||||
Slip10RawIndex.hardened(0),
|
||||
Slip10RawIndex.normal(0),
|
||||
Slip10RawIndex.normal(123),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
17
packages/proto-signing/src/paths.ts
Normal file
17
packages/proto-signing/src/paths.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import { HdPath, Slip10RawIndex } from "@cosmjs/crypto";
|
||||
|
||||
/**
|
||||
* The Cosmos Hub derivation path in the form `m/44'/118'/0'/0/a`
|
||||
* with 0-based account index `a`.
|
||||
*
|
||||
* This is the same as makeCosmoshubPath from @cosmjs/launchpad but those might diverge in the future.
|
||||
*/
|
||||
export function makeCosmoshubPath(a: number): HdPath {
|
||||
return [
|
||||
Slip10RawIndex.hardened(44),
|
||||
Slip10RawIndex.hardened(118),
|
||||
Slip10RawIndex.hardened(0),
|
||||
Slip10RawIndex.normal(0),
|
||||
Slip10RawIndex.normal(a),
|
||||
];
|
||||
}
|
||||
@ -1,7 +1,22 @@
|
||||
import { AccountData, OfflineSigner as OfflineAminoSigner, StdSignature } from "@cosmjs/launchpad";
|
||||
import { OfflineSigner as OfflineAminoSigner, StdSignature } from "@cosmjs/launchpad";
|
||||
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
|
||||
/**
|
||||
* This is the same as Algo from @cosmjs/launchpad but those might diverge in the future.
|
||||
*/
|
||||
export type Algo = "secp256k1" | "ed25519" | "sr25519";
|
||||
|
||||
/**
|
||||
* This is the same as AccountData from @cosmjs/launchpad but those might diverge in the future.
|
||||
*/
|
||||
export interface AccountData {
|
||||
/** A printable address (typically bech32 encoded) */
|
||||
readonly address: string;
|
||||
readonly algo: Algo;
|
||||
readonly pubkey: Uint8Array;
|
||||
}
|
||||
|
||||
export interface DirectSignResponse {
|
||||
/**
|
||||
* The sign doc that was signed.
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { fromBase64 } from "@cosmjs/encoding";
|
||||
import {
|
||||
AccountData,
|
||||
buildFeeTable,
|
||||
Coin,
|
||||
CosmosFeeTable,
|
||||
@ -133,7 +132,7 @@ export class SigningStargateClient extends StargateClient {
|
||||
memo = "",
|
||||
): Promise<BroadcastTxResponse> {
|
||||
const accountFromSigner = (await this.signer.getAccounts()).find(
|
||||
(account: AccountData) => account.address === signerAddress,
|
||||
(account) => account.address === signerAddress,
|
||||
);
|
||||
if (!accountFromSigner) {
|
||||
throw new Error("Failed to retrieve account from signer");
|
||||
|
||||
@ -1,14 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
import { Bip39, EnglishMnemonic, Random, Secp256k1, Slip10, Slip10Curve } from "@cosmjs/crypto";
|
||||
import { Bech32 } from "@cosmjs/encoding";
|
||||
import { AminoSignResponse, coins, Secp256k1HdWallet, StdSignDoc } from "@cosmjs/launchpad";
|
||||
import {
|
||||
AminoSignResponse,
|
||||
coins,
|
||||
DirectSecp256k1HdWallet,
|
||||
DirectSignResponse,
|
||||
makeAuthInfoBytes,
|
||||
makeCosmoshubPath,
|
||||
Secp256k1HdWallet,
|
||||
StdSignDoc,
|
||||
} from "@cosmjs/launchpad";
|
||||
import { DirectSecp256k1HdWallet, DirectSignResponse, makeAuthInfoBytes } from "@cosmjs/proto-signing";
|
||||
} from "@cosmjs/proto-signing";
|
||||
|
||||
import { SignMode } from "./codec/cosmos/tx/signing/v1beta1/signing";
|
||||
import { AuthInfo, SignDoc, TxBody } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user