Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add rfoxDir flag for custom storage path #85

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions cli/MultiSig.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,50 +21,50 @@ TAG=mainnet,cgo,ledger make install

- Add your key:
```bash
./thornode keys add {person1} --ledger
thornode keys add {person1} --ledger
kaladinlight marked this conversation as resolved.
Show resolved Hide resolved
```
- Export pubkey:
```bash
./thornode keys show {person1} --pubkey
thornode keys show {person1} --pubkey
```
- Import signer pubkeys (ex. `'{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"someKeyValue}'`):
```bash
./thornode keys add {person2} --pubkey '{person2_pubkey}'
./thornode keys add {person3} --pubkey '{person3_pubkey}'
thornode keys add {person2} --pubkey '{person2_pubkey}'
thornode keys add {person3} --pubkey '{person3_pubkey}'
```
- View keys:
```bash
./thornode keys list
thornode keys list
```
- Add multisig key:
```bash
./thornode keys add multisig --multisig {person1},{person2},{person3} --multisig-threshold 2
thornode keys add multisig --multisig {person1},{person2},{person3} --multisig-threshold 2
```
- Validate multisig address:
```bash
./thornode keys show multisig --address
thornode keys show multisig --address
```

## Sign Transaction

- Person 1 signs:
```bash
./thornode tx sign --from {person1} --multisig multisig ~/rfox/unsignedTx_epoch-{N}.json --chain-id thorchain-mainnet-v1 --node https://daemon.thorchain.shapeshift.com:443/rpc --ledger --sign-mode amino-json > ~/rfox/signedTx_epoch-{N}_{person1}.json
thornode tx sign --from {person1} --multisig multisig ~/rfox/unsignedTx_epoch-{N}.json --chain-id thorchain-mainnet-v1 --node https://daemon.thorchain.shapeshift.com:443/rpc --ledger --sign-mode amino-json > ~/rfox/signedTx_epoch-{N}_{person1}.json
```
- Person 2 signs:
```bash
./thornode tx sign --from {person2} --multisig multisig ~/rfox/unsignedTx_epoch-{N}.json --chain-id thorchain-mainnet-v1 --node https://daemon.thorchain.shapeshift.com:443/rpc --ledger --sign-mode amino-json > ~/rfox/signedTx_epoch-{N}_{person2}.json
thornode tx sign --from {person2} --multisig multisig ~/rfox/unsignedTx_epoch-{N}.json --chain-id thorchain-mainnet-v1 --node https://daemon.thorchain.shapeshift.com:443/rpc --ledger --sign-mode amino-json > ~/rfox/signedTx_epoch-{N}_{person2}.json
```
- Multisign:
```bash
./thornode tx multisign ~/rfox/unsignedTx_epoch-{N}.json multisig ~/rfox/signedTx_epoch-{N}_{person1}.json ~/rfox/signedTx_epoch-{N}_{person2}.json --from multisig --chain-id thorchain-mainnet-v1 --node https://daemon.thorchain.shapeshift.com:443/rpc > ~/rfox/signedTx_epoch-{N}_multisig.json
thornode tx multisign ~/rfox/unsignedTx_epoch-{N}.json multisig ~/rfox/signedTx_epoch-{N}_{person1}.json ~/rfox/signedTx_epoch-{N}_{person2}.json --from multisig --chain-id thorchain-mainnet-v1 --node https://daemon.thorchain.shapeshift.com:443/rpc > ~/rfox/signedTx_epoch-{N}_multisig.json
```

## Send Transaction

- Broadcast transaction:
```bash
./thornode tx broadcast ~/rfox/signedTx_epoch-{N}_multisig.json --chain-id thorchain-mainnet-v1 --node https://daemon.thorchain.shapeshift.com:443/rpc --gas auto > tx.json
thornode tx broadcast ~/rfox/signedTx_epoch-{N}_multisig.json --chain-id thorchain-mainnet-v1 --node https://daemon.thorchain.shapeshift.com:443/rpc --gas auto > tx.json
```

At this point, the cli should pick up the funding transaction and continue running the distribution from the hot wallet.
1 change: 1 addition & 0 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"bignumber.js": "^9.1.2",
"bip39": "^3.1.0",
"chalk": "^5.3.0",
"commander": "^12.1.0",
"dotenv": "^16.4.5",
"hash-wasm": "^4.11.0",
"log-symbols": "^6.0.0",
Expand Down
4 changes: 0 additions & 4 deletions cli/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import os from 'node:os'
import path from 'node:path'

export const RFOX_DIR = path.join(os.homedir(), 'rfox')
export const RFOX_REWARD_RATE = 1n * 10n ** 27n

export const MONTHS = [
Expand Down
2 changes: 1 addition & 1 deletion cli/src/file.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs'
import { RFOX_DIR } from './constants'
import { error, info, warn } from './logging'
import { RFOX_DIR } from '.'

const deleteIfExists = (file: string) => {
try {
Expand Down
14 changes: 13 additions & 1 deletion cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@ import 'dotenv/config'
import * as prompts from '@inquirer/prompts'
import BigNumber from 'bignumber.js'
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import ora from 'ora'
import { Client } from './client'
import { MONTHS, RFOX_DIR } from './constants'
import { MONTHS } from './constants'
import { isEpochDistributionStarted } from './file'
import { IPFS } from './ipfs'
import { error, info, success, warn } from './logging'
import { create, recoverKeystore } from './mnemonic'
import { Epoch, RFOXMetadata } from './types'
import { Wallet } from './wallet'
import { Command } from 'commander'

const program = new Command()

program.name('rFOX CLI')
program.description('Here to help you do all things rFOX')
program.option('--rfoxDir <path>', 'path to rfox directory', '~/rfox')
program.parse(process.argv)

const options = program.opts()
export const RFOX_DIR = options.rfoxDir.replace(/^~(?=$|\/|\\)/, os.homedir())

const processEpoch = async () => {
const ipfs = await IPFS.new()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/mnemonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import * as prompts from '@inquirer/prompts'
import { generateMnemonic, validateMnemonic } from 'bip39'
import crypto from 'node:crypto'
import path from 'node:path'
import { RFOX_DIR } from './constants'
import { read, write } from './file'
import { error, info, success, warn } from './logging'
import { RFOX_DIR } from '.'

const recoveryChoices = [
{
Expand Down
2 changes: 1 addition & 1 deletion cli/src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import chalk from 'chalk'
import symbols from 'log-symbols'
import path from 'node:path'
import ora, { Ora } from 'ora'
import { RFOX_DIR } from './constants'
import { read, write } from './file'
import { error, info, success } from './logging'
import { Epoch } from './types'
import { RFOX_DIR } from '.'

const BIP32_PATH = `m/44'/931'/0'/0/0`
const SHAPESHIFT_MULTISIG_ADDRESS = 'thor1xmaggkcln5m5fnha2780xrdrulmplvfrz6wj3l'
Expand Down
5 changes: 5 additions & 0 deletions cli/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,11 @@ [email protected]:
dependencies:
graceful-readlink ">= 1.0.0"

commander@^12.1.0:
version "12.1.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3"
integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==

[email protected]:
version "1.2.1"
resolved "https://registry.yarnpkg.com/component-type/-/component-type-1.2.1.tgz#8a47901700238e4fc32269771230226f24b415a9"
Expand Down