Skip to content

Commit

Permalink
skip logic when eibc-config not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
anhductn2001 committed Mar 10, 2025
1 parent b081184 commit 6c4f123
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions cmd/alert-agent/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,25 +161,28 @@ func Cmd() *cobra.Command {
eibcConfigPath := filepath.Join(eibcHome, "config.yaml")
eibcConfig, err := eibcutils.ReadConfig(eibcConfigPath)
if err != nil {
return fmt.Errorf("failed to read eibc config %w", err)
}

grantsByGrantee, err := eibcutils.GetGrantsByGrantee(eibcConfig.Fulfillers.PolicyAddress)
for _, grant := range grantsByGrantee.Grants {
for _, rollapp := range grant.Authorization.Value.Rollapps {
for _, spendLimit := range rollapp.SpendLimit {
config.Addresses = append(config.Addresses, AddressConfig{
Name: fmt.Sprintf(
"%s LP wallet",
strings.ToUpper(rollerData.RollappID),
),
RestEndpoint: rollerData.HubData.ApiUrl,
Address: grant.Granter,
Threshold: AddressThreshold{
Denom: spendLimit.Denom,
Amount: amount,
},
})
pterm.Error.Println("failed to read eibc config", err)
} else {
grantsByGrantee, err := eibcutils.GetGrantsByGrantee(eibcConfig.Fulfillers.PolicyAddress)
if err != nil {
return fmt.Errorf("failed to get grants-by-gratee: %w", err)
}
for _, grant := range grantsByGrantee.Grants {
for _, rollapp := range grant.Authorization.Value.Rollapps {
for _, spendLimit := range rollapp.SpendLimit {
config.Addresses = append(config.Addresses, AddressConfig{
Name: fmt.Sprintf(
"%s LP wallet",
strings.ToUpper(rollerData.RollappID),
),
RestEndpoint: rollerData.HubData.ApiUrl,
Address: grant.Granter,
Threshold: AddressThreshold{
Denom: spendLimit.Denom,
Amount: amount,
},
})
}
}
}
}
Expand Down

0 comments on commit 6c4f123

Please sign in to comment.