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

[CodeArena] - [G-31] : Remove token variable from struct Holding #80

Merged
merged 2 commits into from
Jan 5, 2022

Conversation

maximebrugel
Copy link
Contributor

Issue => code-423n4/2021-11-nested-findings#121

This change allows to save around 1k Gas, this is an important optimization.

However, it will impact the front-end, because the function tokenHoldings will not longer contain the token field.

Here are the different possibilities :

  • Add address token or address[] tokens alongside Holding. But not convenient for the front-end, since we are removing the tuple.
  • Create a new struct inside NestedRecords (but keep Holding) to match the front-end needs. But will increase the bytecode size.
  • Create a batcher smart contract for custom views. But need to store a new address in the front-end.

@maximebrugel maximebrugel added Draft Do not merge To review Let people know this PR is ready for a review labels Dec 22, 2021
@maximebrugel
Copy link
Contributor Author

We could remove the isActive to remove the struct Holding :

struct NftRecord {
    mapping(address => uint256) holdings;
    address[] tokens;
    address reserve;
    uint256 lockTimestamp;
}

Then adapt the view functions.

@maximebrugel maximebrugel added Changes required Second review needed after changes and removed Draft Do not merge To review Let people know this PR is ready for a review labels Jan 3, 2022
@maximebrugel
Copy link
Contributor Author

@adrien-supizet The struct Holding is now removed.

@maximebrugel maximebrugel added To review Let people know this PR is ready for a review and removed Changes required Second review needed after changes labels Jan 3, 2022
@adrien-supizet adrien-supizet added Can merge Good to go and removed To review Let people know this PR is ready for a review labels Jan 5, 2022
@maximebrugel maximebrugel merged commit 3e50e75 into codearena Jan 5, 2022
@maximebrugel maximebrugel deleted the codearena-121 branch January 5, 2022 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can merge Good to go
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants