-
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: Add a
no-output
flag to roller init and register (#406)
- Loading branch information
1 parent
ec6cd87
commit 7624ca9
Showing
9 changed files
with
171 additions
and
109 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,23 @@ | ||
package initconfig | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
func dirNotEmpty(path string) (bool, error) { | ||
info, err := os.Stat(path) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
return false, nil | ||
} | ||
return false, err | ||
} | ||
|
||
if !info.IsDir() { | ||
return false, fmt.Errorf("%s is not a directory", path) | ||
} | ||
|
||
files, err := os.ReadDir(path) | ||
return len(files) > 0, err | ||
} |
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,46 @@ | ||
package initconfig | ||
|
||
import ( | ||
"fmt" | ||
"github.com/dymensionxyz/roller/cmd/consts" | ||
"github.com/dymensionxyz/roller/cmd/utils" | ||
"github.com/dymensionxyz/roller/config" | ||
datalayer "github.com/dymensionxyz/roller/data_layer" | ||
"strings" | ||
) | ||
|
||
func formatAddresses(rollappConfig config.RollappConfig, addresses []utils.AddressData) []utils.AddressData { | ||
damanager := datalayer.NewDAManager(rollappConfig.DA, rollappConfig.Home) | ||
requireFundingKeys := map[string]string{ | ||
consts.KeysIds.HubSequencer: fmt.Sprintf("Sequencer, %s Hub", rollappConfig.HubData.ID), | ||
consts.KeysIds.HubRelayer: fmt.Sprintf("Relayer, %s Hub", rollappConfig.HubData.ID), | ||
damanager.GetKeyName(): fmt.Sprintf("DA, %s Network", damanager.GetNetworkName()), | ||
} | ||
filteredAddresses := make([]utils.AddressData, 0) | ||
for _, address := range addresses { | ||
if newName, ok := requireFundingKeys[address.Name]; ok { | ||
address.Name = newName | ||
filteredAddresses = append(filteredAddresses, address) | ||
} | ||
} | ||
return filteredAddresses | ||
} | ||
|
||
func FormatTokenSupplyLine(rollappConfig config.RollappConfig) string { | ||
displayDenom := strings.ToUpper(rollappConfig.Denom[1:]) | ||
return fmt.Sprintf("💰 Total Token Supply: %s %s. Note that 1 %s == 1 * 10^%d %s (like 1 ETH == 1 * 10^18 wei).", | ||
addCommasToNum(rollappConfig.TokenSupply), displayDenom, displayDenom, rollappConfig.Decimals, "u"+displayDenom) | ||
} | ||
|
||
func addCommasToNum(number string) string { | ||
var result strings.Builder | ||
n := len(number) | ||
|
||
for i := 0; i < n; i++ { | ||
if i > 0 && (n-i)%3 == 0 { | ||
result.WriteString(",") | ||
} | ||
result.WriteByte(number[i]) | ||
} | ||
return result.String() | ||
} |
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 was deleted.
Oops, something went wrong.
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.