Skip to content

Commit

Permalink
add option for hd path
Browse files Browse the repository at this point in the history
  • Loading branch information
liangping committed Nov 23, 2022
1 parent 92b63ea commit 5e52fbc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion config.js
@@ -1,3 +1,6 @@

import { stringToPath } from '@cosmjs/crypto'

export default {
"port": 80, // http port
"db": {
Expand All @@ -17,7 +20,7 @@ export default {
"sender": {
"mnemonic": "surround miss nominee dream gap cross assault thank captain prosper drop duty group candy wealth weather scale put",
"option": {
"hdPaths": ["m/44'/118'/0'/0/0"],
"hdPaths": [stringToPath("m/44'/118'/0'/0/0")],
"prefix": "cosmos"
}
},
Expand Down
6 changes: 2 additions & 4 deletions faucet.js
Expand Up @@ -4,13 +4,11 @@ import * as path from 'path'
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { SigningStargateClient } from "@cosmjs/stargate";
import { FrequencyChecker } from './checker';

// import conf from './config.json' assert {type: 'json'}
import conf from './config'
// let confs = require.context('./chains', false, /\.json$/)
// console.log(confs)


// load config
console.log("loaded config: ", conf)

Expand Down Expand Up @@ -67,9 +65,9 @@ app.listen(conf.port, () => {


async function sendTx(recipient) {

// const mnemonic = "surround miss nominee dream gap cross assault thank captain prosper drop duty group candy wealth weather scale put";
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(conf.sender.mnemonic, /*conf.sender.option*/);
const wallet = await DirectSecp256k1HdWallet.fromMnemonic(conf.sender.mnemonic, conf.sender.option);
const [firstAccount] = await wallet.getAccounts();

// console.log("sender", firstAccount);
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -25,6 +25,7 @@
},
"homepage": "https://github.com/ping-pub/faucet#readme",
"dependencies": {
"@cosmjs/crypto": "^0.29.4",
"@cosmjs/proto-signing": "^0.29.4",
"@cosmjs/stargate": "^0.29.4",
"express": "^4.18.2",
Expand Down

0 comments on commit 5e52fbc

Please sign in to comment.