Merge pull request #728 from cosmos/657-independent-stargate-5

Reorganise Amino paths/wallets
This commit is contained in:
Will Clark 2021-03-24 17:22:11 +00:00 committed by GitHub
commit 3abfcc28a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 47 additions and 107 deletions

View File

@ -19,6 +19,10 @@ export {
pubkeyType,
} from "./pubkeys";
export { createMultisigThresholdPubkey } from "./multisig";
export { makeCosmoshubPath } from "./paths";
export { extractKdfConfiguration, Secp256k1HdWallet } from "./secp256k1hdwallet";
export { Secp256k1Wallet } from "./secp256k1wallet";
export { decodeSignature, encodeSecp256k1Signature, StdSignature } from "./signature";
export { AminoMsg, Coin, makeSignDoc, serializeSignDoc, StdFee, StdSignDoc } from "./signdoc";
export { AccountData, Algo, AminoSignResponse, OfflineAminoSigner } from "./signer";
export { executeKdf, KdfConfiguration } from "./wallet";

View File

@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { serializeSignDoc, StdSignDoc } from "@cosmjs/amino";
import { Secp256k1, Secp256k1Signature, sha256 } from "@cosmjs/crypto";
import { fromBase64, fromHex } from "@cosmjs/encoding";
import { extractKdfConfiguration, Secp256k1HdWallet } from "./secp256k1hdwallet";
import { serializeSignDoc, StdSignDoc } from "./signdoc";
import { base64Matcher } from "./testutils.spec";
import { executeKdf, KdfConfiguration } from "./wallet";

View File

@ -1,12 +1,3 @@
import {
AccountData,
AminoSignResponse,
encodeSecp256k1Signature,
OfflineAminoSigner,
rawSecp256k1PubkeyToRawAddress,
serializeSignDoc,
StdSignDoc,
} from "@cosmjs/amino";
import {
Bip39,
EnglishMnemonic,
@ -22,7 +13,11 @@ import {
import { Bech32, fromBase64, fromUtf8, toBase64, toUtf8 } from "@cosmjs/encoding";
import { assert, isNonNullObject } from "@cosmjs/utils";
import { rawSecp256k1PubkeyToRawAddress } from "./addresses";
import { makeCosmoshubPath } from "./paths";
import { encodeSecp256k1Signature } from "./signature";
import { serializeSignDoc, StdSignDoc } from "./signdoc";
import { AccountData, AminoSignResponse, OfflineAminoSigner } from "./signer";
import {
decrypt,
encrypt,

View File

@ -1,9 +1,9 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { serializeSignDoc, StdSignDoc } from "@cosmjs/amino";
import { Secp256k1, Secp256k1Signature, Sha256 } from "@cosmjs/crypto";
import { fromBase64, fromHex } from "@cosmjs/encoding";
import { Secp256k1Wallet } from "./secp256k1wallet";
import { serializeSignDoc, StdSignDoc } from "./signdoc";
describe("Secp256k1Wallet", () => {
const defaultPrivkey = fromHex("b8c462d2bb0c1a92edf44f735021f16c270f28ee2c3d1cb49943a5e70a3c763e");

View File

@ -1,15 +1,11 @@
import {
AccountData,
AminoSignResponse,
encodeSecp256k1Signature,
OfflineAminoSigner,
rawSecp256k1PubkeyToRawAddress,
serializeSignDoc,
StdSignDoc,
} from "@cosmjs/amino";
import { Secp256k1, Sha256 } from "@cosmjs/crypto";
import { Bech32 } from "@cosmjs/encoding";
import { rawSecp256k1PubkeyToRawAddress } from "./addresses";
import { encodeSecp256k1Signature } from "./signature";
import { serializeSignDoc, StdSignDoc } from "./signdoc";
import { AccountData, AminoSignResponse, OfflineAminoSigner } from "./signer";
/**
* A wallet that holds a single secp256k1 keypair.
*

View File

@ -1,6 +1,8 @@
import { decodeBech32Pubkey } from "./encoding";
import { MultisigThresholdPubkey } from "./pubkeys";
export const base64Matcher = /^(?:[a-zA-Z0-9+/]{4})*(?:|(?:[a-zA-Z0-9+/]{3}=)|(?:[a-zA-Z0-9+/]{2}==)|(?:[a-zA-Z0-9+/]{1}===))$/;
// ./build/wasmd keys add test1
// ./build/wasmd keys add test2
// ./build/wasmd keys add test3

View File

@ -1,8 +1,9 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { Secp256k1HdWallet } from "@cosmjs/amino";
import { UploadMeta } from "@cosmjs/cosmwasm-launchpad";
import { sha256 } from "@cosmjs/crypto";
import { toHex } from "@cosmjs/encoding";
import { MsgDelegate as LaunchpadMsgDelegate, Secp256k1HdWallet } from "@cosmjs/launchpad";
import { MsgDelegate as LaunchpadMsgDelegate } from "@cosmjs/launchpad";
import { DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
import { AminoTypes, assertIsBroadcastTxSuccess, coin, coins, GasPrice } from "@cosmjs/stargate";
import { DeepPartial, MsgSend } from "@cosmjs/stargate/build/codec/cosmos/bank/v1beta1/tx";

View File

@ -1,14 +1,8 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { AminoSignResponse, StdSignDoc } from "@cosmjs/amino";
import { AminoSignResponse, makeCosmoshubPath, Secp256k1HdWallet, StdSignDoc } from "@cosmjs/amino";
import { Bip39, EnglishMnemonic, Random, Secp256k1, Slip10, Slip10Curve } from "@cosmjs/crypto";
import { Bech32, fromBase64 } from "@cosmjs/encoding";
import { Secp256k1HdWallet } from "@cosmjs/launchpad";
import {
DirectSecp256k1HdWallet,
DirectSignResponse,
makeAuthInfoBytes,
makeCosmoshubPath,
} from "@cosmjs/proto-signing";
import { DirectSecp256k1HdWallet, DirectSignResponse, makeAuthInfoBytes } from "@cosmjs/proto-signing";
import {
AuthExtension,
BankExtension,

View File

@ -1,12 +1,11 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { makeSignDoc } from "@cosmjs/amino";
import { makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino";
import { assert, sleep } from "@cosmjs/utils";
import { coins } from "./coins";
import { CosmosClient, isBroadcastTxFailure } from "./cosmosclient";
import { LcdClient } from "./lcdapi";
import { isMsgSend, MsgSend } from "./msgs";
import { Secp256k1HdWallet } from "./secp256k1hdwallet";
import { SigningCosmosClient } from "./signingcosmosclient";
import {
faucet,

View File

@ -1,12 +1,11 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { makeSignDoc, StdFee } from "@cosmjs/amino";
import { makeSignDoc, Secp256k1HdWallet, StdFee } from "@cosmjs/amino";
import { assert, sleep } from "@cosmjs/utils";
import { ReadonlyDate } from "readonly-date";
import { assertIsBroadcastTxSuccess, CosmosClient, PrivateCosmosClient } from "./cosmosclient";
import { findAttribute } from "./logs";
import { MsgSend } from "./msgs";
import { Secp256k1HdWallet } from "./secp256k1hdwallet";
import cosmoshub from "./testdata/cosmoshub.json";
import {
faucet,

View File

@ -5,7 +5,10 @@ export {
AminoMsg as Msg,
AminoSignResponse,
Coin,
KdfConfiguration,
OfflineAminoSigner as OfflineSigner,
Secp256k1HdWallet,
Secp256k1Wallet,
StdFee,
StdSignDoc,
StdSignature,
@ -16,6 +19,9 @@ export {
encodeBech32Pubkey,
encodeSecp256k1Pubkey,
encodeSecp256k1Signature,
extractKdfConfiguration,
executeKdf,
makeCosmoshubPath,
makeSignDoc,
pubkeyToAddress,
pubkeyType,
@ -147,10 +153,6 @@ export {
MsgWithdrawDelegatorReward,
MsgWithdrawValidatorCommission,
} from "./msgs";
export { makeCosmoshubPath } from "./paths";
export { findSequenceForSignedTx } from "./sequence";
export { CosmosFeeTable, SigningCosmosClient } from "./signingcosmosclient";
export { isStdTx, isWrappedStdTx, makeStdTx, CosmosSdkTx, StdTx, WrappedStdTx, WrappedTx } from "./tx";
export { executeKdf, KdfConfiguration } from "./wallet";
export { extractKdfConfiguration, Secp256k1HdWallet } from "./secp256k1hdwallet";
export { Secp256k1Wallet } from "./secp256k1wallet";

View File

@ -1,12 +1,11 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { makeSignDoc } from "@cosmjs/amino";
import { makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino";
import { Bech32 } from "@cosmjs/encoding";
import { sleep } from "@cosmjs/utils";
import { coin, coins } from "../coins";
import { assertIsBroadcastTxSuccess } from "../cosmosclient";
import { MsgDelegate } from "../msgs";
import { Secp256k1HdWallet } from "../secp256k1hdwallet";
import { SigningCosmosClient } from "../signingcosmosclient";
import {
bigDecimalMatcher,

View File

@ -1,10 +1,9 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { makeSignDoc } from "@cosmjs/amino";
import { makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino";
import { sleep } from "@cosmjs/utils";
import { coins } from "../coins";
import { assertIsBroadcastTxSuccess } from "../cosmosclient";
import { Secp256k1HdWallet } from "../secp256k1hdwallet";
import { SigningCosmosClient } from "../signingcosmosclient";
import {
dateTimeStampMatcher,

View File

@ -1,12 +1,10 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { Coin, makeSignDoc, StdFee } from "@cosmjs/amino";
import { Coin, makeCosmoshubPath, makeSignDoc, Secp256k1HdWallet, StdFee } from "@cosmjs/amino";
import { assert, sleep } from "@cosmjs/utils";
import { isBroadcastTxFailure } from "../cosmosclient";
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";
import {

View File

@ -1,11 +1,10 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { makeSignDoc } from "@cosmjs/amino";
import { makeSignDoc, Secp256k1HdWallet } from "@cosmjs/amino";
import { assert, sleep } from "@cosmjs/utils";
import { coin, coins } from "../coins";
import { assertIsBroadcastTxSuccess } from "../cosmosclient";
import { MsgDelegate, MsgUndelegate } from "../msgs";
import { Secp256k1HdWallet } from "../secp256k1hdwallet";
import { SigningCosmosClient } from "../signingcosmosclient";
import {
bigDecimalMatcher,

View File

@ -1,13 +1,11 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { Coin } from "@cosmjs/amino";
import { Coin, makeCosmoshubPath, Secp256k1HdWallet } from "@cosmjs/amino";
import { assert } from "@cosmjs/utils";
import { coin, coins } from "./coins";
import { assertIsBroadcastTxSuccess, PrivateCosmosClient } from "./cosmosclient";
import { GasPrice } from "./fee";
import { MsgDelegate, MsgSend } from "./msgs";
import { makeCosmoshubPath } from "./paths";
import { Secp256k1HdWallet } from "./secp256k1hdwallet";
import { PrivateSigningCosmosClient, SigningCosmosClient } from "./signingcosmosclient";
import {
base64Matcher,

View File

@ -1,4 +1,4 @@
import { encodeSecp256k1Signature, rawSecp256k1PubkeyToRawAddress } from "@cosmjs/amino";
import { encodeSecp256k1Signature, makeCosmoshubPath, rawSecp256k1PubkeyToRawAddress } from "@cosmjs/amino";
import {
Bip39,
EnglishMnemonic,
@ -12,7 +12,6 @@ import {
import { Bech32 } from "@cosmjs/encoding";
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
import { makeCosmoshubPath } from "./paths";
import { AccountData, DirectSignResponse, OfflineDirectSigner } from "./signer";
import { makeSignBytes } from "./signing";

View File

@ -10,7 +10,6 @@ export {
} from "./registry";
export { DirectSecp256k1HdWallet } from "./directsecp256k1hdwallet";
export { DirectSecp256k1Wallet } from "./directsecp256k1wallet";
export { makeCosmoshubPath } from "./paths";
export { decodePubkey, encodePubkey } from "./pubkey";
export {
AccountData,

View File

@ -1,26 +0,0 @@
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),
]);
});
});
});

View File

@ -1,17 +0,0 @@
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),
];
}

View File

@ -1,5 +1,11 @@
import { createMultisigThresholdPubkey, encodeSecp256k1Pubkey, pubkeyToAddress } from "@cosmjs/amino";
import { coins, makeCosmoshubPath, Secp256k1HdWallet } from "@cosmjs/launchpad";
import {
createMultisigThresholdPubkey,
encodeSecp256k1Pubkey,
makeCosmoshubPath,
pubkeyToAddress,
Secp256k1HdWallet,
} from "@cosmjs/amino";
import { coins } from "@cosmjs/proto-signing";
import { assert } from "@cosmjs/utils";
import { MsgSend } from "./codec/cosmos/bank/v1beta1/tx";

View File

@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention,no-bitwise */
import { MsgDelegate as LaunchpadMsgDelegate, Secp256k1HdWallet } from "@cosmjs/launchpad";
import { Secp256k1HdWallet } from "@cosmjs/amino";
import { MsgDelegate as LaunchpadMsgDelegate } from "@cosmjs/launchpad";
import { coin, coins, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing";
import { assert, sleep } from "@cosmjs/utils";
import protobuf from "protobufjs/minimal";

View File

@ -1,15 +1,8 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { AminoSignResponse, StdSignDoc } from "@cosmjs/amino";
import { AminoSignResponse, makeCosmoshubPath, Secp256k1HdWallet, StdSignDoc } from "@cosmjs/amino";
import { Bip39, EnglishMnemonic, Random, Secp256k1, Slip10, Slip10Curve } from "@cosmjs/crypto";
import { Bech32 } from "@cosmjs/encoding";
import { Secp256k1HdWallet } from "@cosmjs/launchpad";
import {
coins,
DirectSecp256k1HdWallet,
DirectSignResponse,
makeAuthInfoBytes,
makeCosmoshubPath,
} from "@cosmjs/proto-signing";
import { coins, DirectSecp256k1HdWallet, DirectSignResponse, makeAuthInfoBytes } from "@cosmjs/proto-signing";
import { SignMode } from "./codec/cosmos/tx/signing/v1beta1/signing";
import { AuthInfo, SignDoc, TxBody } from "./codec/cosmos/tx/v1beta1/tx";