Skip to content

Commit

Permalink
use Config.Bin for namada command
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Nov 11, 2024
1 parent 86c62e8 commit 95abd68
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 24 deletions.
59 changes: 39 additions & 20 deletions chain/namada/namada_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ func (c *NamadaChain) HomeDir() string {
func (c *NamadaChain) CreateKey(ctx context.Context, keyName string) error {
var err error
cmd := []string{
"namadaw",
c.cfg.Bin,
"wallet",
"--base-dir",
c.HomeDir(),
"gen",
Expand All @@ -268,7 +269,8 @@ func (c *NamadaChain) RecoverKey(ctx context.Context, keyName, mnemonic string)
"echo",
mnemonic,
"|",
"namadaw",
c.cfg.Bin,
"wallet",
"--base-dir",
c.HomeDir(),
"derive",
Expand All @@ -284,7 +286,8 @@ func (c *NamadaChain) RecoverKey(ctx context.Context, keyName, mnemonic string)
// Get the Namada address.
func (c *NamadaChain) GetAddress(ctx context.Context, keyName string) ([]byte, error) {
cmd := []string{
"namadaw",
c.cfg.Bin,
"wallet",
"--base-dir",
c.HomeDir(),
"find",
Expand Down Expand Up @@ -312,7 +315,8 @@ func (c *NamadaChain) GetAddress(ctx context.Context, keyName string) ([]byte, e
// Get the key alias.
func (c *NamadaChain) getAlias(ctx context.Context, address string) (string, error) {
cmd := []string{
"namadaw",
c.cfg.Bin,
"wallet",
"--base-dir",
c.HomeDir(),
"find",
Expand Down Expand Up @@ -346,7 +350,8 @@ func (c *NamadaChain) SendFunds(ctx context.Context, keyName string, amount ibc.
transferCmd = "transparent-transfer"
}
cmd := []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
transferCmd,
Expand Down Expand Up @@ -375,7 +380,8 @@ func (c *NamadaChain) SendFundsWithNote(ctx context.Context, keyName string, amo
transferCmd = "transparent-transfer"
}
cmd := []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
transferCmd,
Expand All @@ -400,7 +406,8 @@ func (c *NamadaChain) SendFundsWithNote(ctx context.Context, keyName string, amo
// Send on IBC transfer.
func (c *NamadaChain) SendIBCTransfer(ctx context.Context, channelID, keyName string, amount ibc.WalletAmount, options ibc.TransferOptions) (ibc.Tx, error) {
cmd := []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
"ibc-transfer",
Expand Down Expand Up @@ -555,7 +562,8 @@ func (c *NamadaChain) SendIBCTransfer(ctx context.Context, channelID, keyName st
// Shielded transfer (shielded account to shielded account) on Namada.
func (c *NamadaChain) ShieldedTransfer(ctx context.Context, keyName string, amount ibc.WalletAmount) error {
cmd := []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
"transfer",
Expand Down Expand Up @@ -587,7 +595,8 @@ func (c *NamadaChain) GenIbcShieldingTransfer(ctx context.Context, channelID str
}

cmd := []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
"ibc-gen-shielding",
Expand Down Expand Up @@ -638,7 +647,8 @@ func (c *NamadaChain) Height(ctx context.Context) (int64, error) {
func (c *NamadaChain) GetBalance(ctx context.Context, keyName string, denom string) (math.Int, error) {
if strings.HasPrefix(keyName, "shielded") {
cmd := []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
"shielded-sync",
Expand All @@ -654,7 +664,8 @@ func (c *NamadaChain) GetBalance(ctx context.Context, keyName string, denom stri
}

cmd := []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
"balance",
Expand Down Expand Up @@ -766,7 +777,8 @@ func (c *NamadaChain) createGenesisKey(ctx context.Context, keyName string) (ibc

func (c *NamadaChain) createKeyAndMnemonic(ctx context.Context, keyName string, isShielded bool) (ibc.Wallet, error) {
cmd := []string{
"namadaw",
c.cfg.Bin,
"wallet",
"--base-dir",
c.HomeDir(),
"gen",
Expand Down Expand Up @@ -801,7 +813,8 @@ func (c *NamadaChain) createKeyAndMnemonic(ctx context.Context, keyName string,
// Generate a payment address
if isShielded {
cmd = []string{
"namadaw",
c.cfg.Bin,
"wallet",
"--base-dir",
c.HomeDir(),
"gen-payment-addr",
Expand Down Expand Up @@ -831,7 +844,8 @@ func (c *NamadaChain) createKeyAndMnemonic(ctx context.Context, keyName string,

func (c *NamadaChain) addAddress(ctx context.Context, keyName, address string) error {
cmd := []string{
"namadaw",
c.cfg.Bin,
"wallet",
"--base-dir",
c.HomeDir(),
"add",
Expand Down Expand Up @@ -980,7 +994,8 @@ func (c *NamadaChain) setValidators(ctx context.Context) error {

// Generate a validator key
cmd := []string{
"namadaw",
c.cfg.Bin,
"wallet",
"--base-dir",
c.HomeDir(),
"--pre-genesis",
Expand Down Expand Up @@ -1012,7 +1027,8 @@ func (c *NamadaChain) setValidators(ctx context.Context) error {

// Initialize a genesis validator
cmd = []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
"utils",
Expand Down Expand Up @@ -1041,7 +1057,8 @@ func (c *NamadaChain) setValidators(ctx context.Context) error {
}

cmd = []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
"utils",
Expand Down Expand Up @@ -1165,7 +1182,8 @@ func (c *NamadaChain) initAccounts(ctx context.Context, additionalGenesisWallets

func (c *NamadaChain) initGenesisEstablishedAccount(ctx context.Context, keyName, transactionPath string) (string, error) {
cmd := []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
"utils",
Expand Down Expand Up @@ -1202,7 +1220,7 @@ func (c *NamadaChain) updateParameters(ctx context.Context) error {
"-i",
// for enough trusting period
"-e",
"s/epochs_per_year = [0-9_]\\+/epochs_per_year = 31_536/",
"s/epochs_per_year = [0-9_]\\+/epochs_per_year = 365/",
// delete steward addresses
"-e",
"s/\"tnam.*//",
Expand All @@ -1224,7 +1242,8 @@ func (c *NamadaChain) initNetwork(ctx context.Context) error {
checksumsPath := filepath.Join(wasmDir, "checksums.json")
genesisTime := time.Now().UTC().Format("2006-01-02T15:04:05.000000000-07:00")
cmd := []string{
"namadac",
c.cfg.Bin,
"client",
"--base-dir",
c.HomeDir(),
"utils",
Expand Down
4 changes: 2 additions & 2 deletions chain/namada/namada_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (n *NamadaNode) Height(ctx context.Context) (int64, error) {
func (n *NamadaNode) CreateContainer(ctx context.Context) error {
setConfigDir := fmt.Sprintf("NAMADA_NETWORK_CONFIGS_DIR=%s", n.HomeDir())

joinNetworkCmd := fmt.Sprintf(`%s namadac --base-dir %s utils join-network --add-persistent-peers --chain-id %s --allow-duplicate-ip`, setConfigDir, n.HomeDir(), n.Chain.Config().ChainID)
joinNetworkCmd := fmt.Sprintf(`%s %s client --base-dir %s utils join-network --add-persistent-peers --chain-id %s --allow-duplicate-ip`, setConfigDir, n.Chain.Config().Bin, n.HomeDir(), n.Chain.Config().ChainID)
if n.Validator {
joinNetworkCmd += " --genesis-validator " + fmt.Sprintf("validator-%d", n.Index)
}
Expand All @@ -194,7 +194,7 @@ func (n *NamadaNode) CreateContainer(ctx context.Context) error {
mvCmd = fmt.Sprintf(`mv %s/wallet.toml %s/%s`, n.HomeDir(), n.HomeDir(), n.Chain.Config().ChainID)
}

ledgerCmd := fmt.Sprintf(`namadan --base-dir %s ledger`, n.HomeDir())
ledgerCmd := fmt.Sprintf(`%s node --base-dir %s ledger`, n.Chain.Config().Bin, n.HomeDir())

cmd := []string{
"sh",
Expand Down
2 changes: 1 addition & 1 deletion configuredChains.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ namada:
denom: nam
gas-prices: 0.000001tnam1qxgfw7myv4dh0qna4hq0xdg6lx77fzl7dcem8h7e
gas-adjustment: 1.1
trusting-period: 2000s
trusting-period: 48h
images:
- repository: ghcr.io/anoma/namada
uid-gid: 1000:1000
Expand Down
1 change: 1 addition & 0 deletions examples/namada/namada_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func TestNamadaNetwork(t *testing.T) {
Denom: namadachain.NamAddress,
Gas: "250000",
CoinDecimals: &coinDecimals,
Bin: "namada",
},
NumValidators: &nv,
NumFullNodes: &fn,
Expand Down
2 changes: 1 addition & 1 deletion relayer/hermes/hermes_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewConfig(chainConfigs ...ChainConfig) Config {
case ibc.Namada:
chainType = Namada
accountPrefix = ""
trustingPeriod = "1000s"
trustingPeriod = "1day"
default:
chainType = Cosmos
accountPrefix = chainCfg.Bech32Prefix
Expand Down

0 comments on commit 95abd68

Please sign in to comment.