-
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 support for standard ibc (#614)
Co-authored-by: Michael Tsitrin <[email protected]>
- Loading branch information
1 parent
4bd2530
commit 3be9ca6
Showing
19 changed files
with
322 additions
and
216 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,74 @@ | ||
package initconfig | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
"strings" | ||
) | ||
|
||
type BankDenomMetadata struct { | ||
Base string `json:"base"` | ||
DenomUnits []BankDenomUnitMetadata `json:"denom_units"` | ||
Description string `json:"description"` | ||
Display string `json:"display"` | ||
Name string `json:"name"` | ||
Symbol string `json:"symbol"` | ||
} | ||
|
||
type BankDenomUnitMetadata struct { | ||
Aliases []string `json:"aliases"` | ||
Denom string `json:"denom"` | ||
Exponent uint `json:"exponent"` | ||
} | ||
|
||
func getBankDenomMetadata(denom string, decimals uint) string { | ||
displayDenom := denom[1:] | ||
|
||
metadata := []BankDenomMetadata{ | ||
{ | ||
Base: denom, | ||
DenomUnits: []BankDenomUnitMetadata{ | ||
{ | ||
Aliases: []string{}, | ||
Denom: denom, | ||
Exponent: 0, | ||
}, | ||
{ | ||
Aliases: []string{}, | ||
Denom: displayDenom, | ||
Exponent: decimals, | ||
}, | ||
}, | ||
Description: fmt.Sprintf("Denom metadata for %s (%s)", displayDenom, denom), | ||
Display: displayDenom, | ||
Name: displayDenom, | ||
Symbol: strings.ToUpper(displayDenom), | ||
}, | ||
} | ||
|
||
json, err := json.Marshal(metadata) | ||
if err != nil { | ||
return "" | ||
} | ||
|
||
return string(json) | ||
} | ||
|
||
func createTokenMetadaJSON(metadataPath string, denom string, decimals uint) error { | ||
metadata := getBankDenomMetadata(denom, decimals) | ||
if metadata == "" { | ||
return fmt.Errorf("failed to generate token metadata") | ||
} | ||
|
||
file, err := os.Create(metadataPath) | ||
if err != nil { | ||
return err | ||
} | ||
_, err = file.WriteString(metadata) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package migrate | ||
|
||
import ( | ||
"fmt" | ||
"os/exec" | ||
|
||
"github.com/dymensionxyz/roller/cmd/consts" | ||
"github.com/dymensionxyz/roller/cmd/utils" | ||
"github.com/dymensionxyz/roller/config" | ||
"github.com/dymensionxyz/roller/relayer" | ||
) | ||
|
||
type VersionMigratorV1000 struct{} | ||
|
||
func (v *VersionMigratorV1000) ShouldMigrate(prevVersion VersionData) bool { | ||
return prevVersion.Major < 1 | ||
} | ||
|
||
func (v *VersionMigratorV1000) PerformMigration(rlpCfg config.RollappConfig) error { | ||
fmt.Println("💈 Migrating Rollapp key...") | ||
migrateRollappKeyCmd := exec.Command(consts.Executables.RollappEVM, "keys", "migrate", "--home", rlpCfg.Home+"/relayer/keys/"+rlpCfg.RollappID, "--keyring-backend", "test") | ||
out, err := utils.ExecBashCommandWithStdout(migrateRollappKeyCmd) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(out.String()) | ||
fmt.Println("💈 Migrating Hub key...") | ||
migrateHubKeyCmd := exec.Command(consts.Executables.Dymension, "keys", "migrate", "--home", rlpCfg.Home+"/relayer/keys/"+rlpCfg.HubData.ID, "--keyring-backend", "test") | ||
out, err = utils.ExecBashCommandWithStdout(migrateHubKeyCmd) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println(out.String()) | ||
fmt.Println("💈 Updating relayer configuration to match new relayer key...") | ||
if err := relayer.UpdateRlyConfigValue(rlpCfg, []string{"chains", rlpCfg.RollappID, "value", "extra-codecs"}, []string{"ethermint"}); err != nil { | ||
return err | ||
} | ||
return nil | ||
|
||
} |
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.