Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Feb 15, 2024
1 parent 6555cf8 commit c5ec412
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion spawn/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (cfg *NewChainConfig) SetupInterchainTest() error {
fc.ReplaceAll(`Binary = "wasmd"`, fmt.Sprintf(`Binary = "%s"`, cfg.BinDaemon)) // else it would replace the Cosmwasm/wasmd import path
fc.ReplaceAll(`Bech32 = "wasm"`, fmt.Sprintf(`Bech32 = "%s"`, cfg.Bech32Prefix))

fc.FindAndReplaceAddressBech32(cfg.Logger, "wasm", cfg.Bech32Prefix)
fc.FindAndReplaceAddressBech32("wasm", cfg.Bech32Prefix)

}

Expand Down
6 changes: 3 additions & 3 deletions spawn/file_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ func (fc *FileContent) ReplaceLocalInterchainJSON(cfg *NewChainConfig) {
fc.ReplaceAll("mydenom", cfg.Denom)
fc.ReplaceAll("wasmd", cfg.BinDaemon)

fc.FindAndReplaceAddressBech32(cfg.Logger, "wasm", cfg.Bech32Prefix)
fc.FindAndReplaceAddressBech32("wasm", cfg.Bech32Prefix)
}

}

// FindAndReplaceStandardWalletsBech32 finds a prefix1... address and replaces it with a new prefix1... address
// This works for both standard wallets (38 length after prefix1) and also smart contracts (58)
func (fc *FileContent) FindAndReplaceAddressBech32(logger *slog.Logger, oldPrefix, newPrefix string) {
func (fc *FileContent) FindAndReplaceAddressBech32(oldPrefix, newPrefix string) {
oldPrefix = strings.TrimSuffix(oldPrefix, "1")
newPrefix = strings.TrimSuffix(newPrefix, "1")

Expand All @@ -159,7 +159,7 @@ func (fc *FileContent) FindAndReplaceAddressBech32(logger *slog.Logger, oldPrefi
r := regexp.MustCompile(oldPrefix + `1([0-9a-z]{58}|[0-9a-z]{38})`)

foundAddrs := r.FindAllString(fc.Contents, -1)
logger.Debug("Regex: Found Addresses", "addresses", foundAddrs, "path", fc.NewPath)
fc.Logger.Debug("Regex: Found Addresses", "addresses", foundAddrs, "path", fc.NewPath)

for _, addr := range foundAddrs {
_, bz, err := bech32.Decode(addr, 100)
Expand Down

0 comments on commit c5ec412

Please sign in to comment.