Copy makeCosmoshubPath to @cosmjs/proto-signing
This commit is contained in:
parent
83a4b0ef80
commit
ab1b51485c
@ -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,
|
||||
|
||||
@ -8,9 +8,10 @@ import {
|
||||
Slip10,
|
||||
Slip10Curve,
|
||||
} from "@cosmjs/crypto";
|
||||
import { encodeSecp256k1Signature, makeCosmoshubPath, rawSecp256k1PubkeyToAddress } from "@cosmjs/launchpad";
|
||||
import { encodeSecp256k1Signature, rawSecp256k1PubkeyToAddress } from "@cosmjs/launchpad";
|
||||
|
||||
import { SignDoc } from "./codec/cosmos/tx/v1beta1/tx";
|
||||
import { makeCosmoshubPath } from "./paths";
|
||||
import { AccountData, DirectSignResponse, OfflineDirectSigner } from "./signer";
|
||||
import { makeSignBytes } from "./signing";
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
export { EncodeObject, GeneratedType, Registry } from "./registry";
|
||||
export { DirectSecp256k1HdWallet } from "./directsecp256k1hdwallet";
|
||||
export { DirectSecp256k1Wallet } from "./directsecp256k1wallet";
|
||||
export { makeCosmoshubPath } from "./paths";
|
||||
export { decodePubkey, encodePubkey } from "./pubkey";
|
||||
export {
|
||||
AccountData,
|
||||
|
||||
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,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