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

Use stdToml where possible, custom functions elsewhere #700

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

alcueca
Copy link
Contributor

@alcueca alcueca commented Mar 1, 2025

Description

There is a suggestion from @mds1 about using stdToml instead of the more raw parseToml commands.

I took a stab at it. In the current repo, we would use stdToml exactly twice, because most of the time we are parsing structs that stdToml can't manage.

We could extract the struct-reading abi.decode command into its own function. Some of them would be reusable such as AddressesRegistry.readChainsFromToml in this PR. Most of them would be template-specific.

@mds1, worth it to fix the other templates in the same way as TransferOwnerTemplate here, or should we let it be?

@alcueca alcueca requested review from a team as code owners March 1, 2025 07:14
@alcueca alcueca requested review from AmadiMichael and mds1 March 1, 2025 07:14
@alcueca alcueca mentioned this pull request Mar 1, 2025
@mds1
Copy link
Contributor

mds1 commented Mar 12, 2025

Sorry, I missed this, but am supportive of this PR once conflicts are resolved

Comment on lines +295 to +297
function readChainsFromToml(string memory toml, string memory key) public view returns (ChainInfo[] memory) {
return abi.decode(vm.parseToml(vm.readFile(toml), key), (ChainInfo[]));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can even hardcode the key here since it will always be the same

Suggested change
function readChainsFromToml(string memory toml, string memory key) public view returns (ChainInfo[] memory) {
return abi.decode(vm.parseToml(vm.readFile(toml), key), (ChainInfo[]));
}
function readChainsFromToml(string memory toml) public view returns (ChainInfo[] memory) {
return abi.decode(vm.parseToml(vm.readFile(toml), ".l2Chains"), (ChainInfo[]));
}

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.

2 participants