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

feat: prompt to fund the relayer key continuously #1131

Merged
Merged
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
37 changes: 27 additions & 10 deletions utils/keys/relayer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keys

import (
"errors"
"fmt"
"os/exec"
"path"
Expand Down Expand Up @@ -85,26 +86,42 @@ func GetRelayerKeysConfig(rollappConfig roller.RollappConfig) map[string]KeyConf
}

func GetRelayerKeysToFund(rollappConfig roller.RollappConfig) error {
relayerAddresses := make([]KeyInfo, 0)
relayerKeys := GetRelayerKeysConfig(rollappConfig)

relayerHubAddress, err := GetRelayerAddressInfo(
rhki, err := GetRelayerAddressInfo(
relayerKeys[consts.KeysIds.HubRelayer],
rollappConfig.HubData.ID,
)
if err != nil {
return err
}

relayerAddresses = append(
relayerAddresses, *relayerHubAddress,
)
for {
cqc := ChainQueryConfig{
Binary: consts.Executables.Dymension,
Denom: consts.Denoms.Hub,
RPC: rollappConfig.HubData.RpcUrl,
}
balance, err := QueryBalance(cqc, rhki.Address)
if err != nil {
return err
}

pterm.Info.Println(
"please fund the hub relayer key with at least 20 dym tokens: ",
)
for _, k := range relayerAddresses {
k.Print(WithName())
if !balance.Amount.IsPositive() {
pterm.Info.Println(
"please fund the addresses below to operate the relayer.",
)
rhki.Print(WithName())
proceed, _ := pterm.DefaultInteractiveConfirm.WithDefaultValue(false).
WithDefaultText(
"press 'y' when the wallets are funded",
).Show()
if !proceed {
return errors.New("cancelled by user")
}
} else {
break
}
}

return nil
Expand Down
Loading