Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ASI mobix staking replacement #348

Merged

Conversation

Jonathansumner
Copy link
Member

No description provided.

@Jonathansumner Jonathansumner self-assigned this May 13, 2024
@Jonathansumner Jonathansumner changed the title feat: initial mobix staking replacement function feat: mobix staking replacement May 13, 2024
… feat/asi-mobix-staking-replacement

# Conflicts:
#	cmd/fetchd/cmd/genasiupgrade.go
@Jonathansumner Jonathansumner changed the title feat: mobix staking replacement feat: ASI mobix staking replacement May 16, 2024
contracts := jsonData["wasm"].(map[string]interface{})["contracts"].([]interface{})
MobixStakingContractAddress := networkInfo.Contracts.MobixStaking.Addr

re := regexp.MustCompile(fmt.Sprintf(`%s%s1([%s]{%d})$`, OldAddrPrefix, "", Bech32Chars, AddrDataLength+AddrChecksumLength))
Copy link
Collaborator

@pbukva pbukva May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
re := regexp.MustCompile(fmt.Sprintf(`%s%s1([%s]{%d})$`, OldAddrPrefix, "", Bech32Chars, AddrDataLength+AddrChecksumLength))
re := regexp.MustCompile(fmt.Sprintf(`$(stakes|unbond_entries)%s%s1([%s]{%d,%d})$`, OldAddrPrefix, "", Bech32Chars, 32+AddrChecksumLength, 52+AddrChecksumLength))

or, probably even better:

Suggested change
re := regexp.MustCompile(fmt.Sprintf(`%s%s1([%s]{%d})$`, OldAddrPrefix, "", Bech32Chars, AddrDataLength+AddrChecksumLength))
re := regexp.MustCompile(fmt.Sprintf(`$(stakes|unbond_entries)%s%s1([%s]{%d,%d})$`, OldAddrPrefix, "", Bech32Chars, AddrChecksumLength, 52+AddrChecksumLength))

Above suggested $(stakes|unbond_entries) start of the regexp is overkill, due to complications with multiple matches.
Perhaps, simpler solution would be simply check the key value manually whether it starts with the "stakes" or "unbond_entries" strings and pass follosing substring in to the address conversion functionm which would return just converted address, which would then be conctatenated back with original "stakes" or "unbond_entries" prefix.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use leven higher value then 52 (which supposed to be for contract address, and at the moment it looks like it is largest address length we know of), for example at least 60, or even 100.

Copy link
Collaborator

@pbukva pbukva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Jonathansumner Jonathansumner merged commit 76a6d67 into feat/aasi-merger-cmd May 22, 2024
1 check passed
@Jonathansumner Jonathansumner deleted the feat/asi-mobix-staking-replacement branch May 22, 2024 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants