Merge pull request #795 from cosmos/770-makeCosmoshubPath-stargate
Export makeCosmoshubPath from proto-signing/stargate
This commit is contained in:
commit
d88f81a1e4
@ -6,6 +6,11 @@ and this project adheres to
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
|
||||
- @cosmjs/proto-signing: Export `makeCosmoshubPath` helper.
|
||||
- @cosmjs/stargate: Export `makeCosmoshubPath` helper.
|
||||
|
||||
## [0.25.1] - 2021-05-06
|
||||
|
||||
### Added
|
||||
|
||||
@ -16,6 +16,7 @@ export {
|
||||
} from "./registry";
|
||||
export { DirectSecp256k1HdWallet, DirectSecp256k1HdWalletOptions } 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),
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
15
packages/proto-signing/src/paths.ts
Normal file
15
packages/proto-signing/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),
|
||||
];
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
export { StdFee } from "@cosmjs/amino";
|
||||
export { Coin, coin, coins, parseCoins } from "@cosmjs/proto-signing";
|
||||
export { Coin, coin, coins, makeCosmoshubPath, parseCoins } from "@cosmjs/proto-signing";
|
||||
|
||||
export { Account, accountFromAny } from "./accounts";
|
||||
export {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user