-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(eibc): store json object as the group and policy metadata (#1153)
- Loading branch information
1 parent
2ff5e50
commit 2a99f2c
Showing
12 changed files
with
829 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package consts | ||
|
||
const ( | ||
DefaultIndexer = "http://44.206.211.230:3000/" | ||
DefaultEibcOperatorFeeShare = 0.1 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package feeshare | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"strconv" | ||
|
||
"github.com/pterm/pterm" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/dymensionxyz/roller/cmd/consts" | ||
"github.com/dymensionxyz/roller/utils/config/yamlconfig" | ||
eibcutils "github.com/dymensionxyz/roller/utils/eibc" | ||
) | ||
|
||
func Cmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "fee-share [fee-share]", | ||
Short: "Set", | ||
Example: "roller eibc fulfill fee-share 0.1", | ||
Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
home, err := os.UserHomeDir() | ||
if err != nil { | ||
pterm.Error.Println("failed to get user home dir", err) | ||
return | ||
} | ||
|
||
if err != nil { | ||
pterm.Error.Println("failed to expand home directory") | ||
return | ||
} | ||
|
||
eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc) | ||
eibcConfigPath := filepath.Join(eibcHome, "config.yaml") | ||
|
||
fee := args[0] | ||
ff, err := strconv.ParseFloat(fee, 64) | ||
if err != nil { | ||
pterm.Error.Printf("fee must be a valid number, got %s\n", fee) | ||
return | ||
} | ||
|
||
updates := map[string]interface{}{ | ||
"operator.min_fee_share": ff, | ||
} | ||
err = yamlconfig.UpdateNestedYAML(eibcConfigPath, updates) | ||
if err != nil { | ||
pterm.Error.Println("failed to update config", err) | ||
return | ||
} | ||
|
||
var cfg eibcutils.Config | ||
err = cfg.LoadConfig(eibcConfigPath) | ||
if err != nil { | ||
pterm.Error.Println("failed to load eibc config: ", err) | ||
return | ||
} | ||
|
||
err = eibcutils.UpdateGroupOperatorMinFee(eibcConfigPath, ff, cfg, home) | ||
if err != nil { | ||
pterm.Error.Println("failed to update eibc operator metadata: ", err) | ||
return | ||
} | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.