Skip to content

Conversation

sohamsk13
Copy link

Dynamic vote weights based on NFT metadata

Proper delegation handling during transfers

Metadata changes affecting voting power

Batch operations for large collections

Edge cases around transfers and delegation

PR : 5209

…s Tests

The changes maintain all existing functionality while adding comprehensive support for NFT-based voting scenarios. The tests cover:

Dynamic vote weights based on NFT metadata

Proper delegation handling during transfers

Metadata changes affecting voting power

Batch operations for large collections

Edge cases around transfers and delegation
@sohamsk13 sohamsk13 requested a review from a team as a code owner August 11, 2025 06:48
Copy link

changeset-bot bot commented Aug 11, 2025

⚠️ No Changeset found

Latest commit: f465f7d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ernestognw
Copy link
Member

Hi @sohamsk13, would you mind fixing the CI? If the tests are good we're happy to get them merged

@sohamsk13
Copy link
Author

Hi @sohamsk13, would you mind fixing the CI? If the tests are good we're happy to get them merged

Sure I will

Comment on lines +17 to +19
this.other,
this.charlie,
this.dave
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
this.other,
this.charlie,
this.dave
this.charlie,
this.dave,
this.other,

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd consider renaming to alice / bruce / chris / david, so that all names are 5 letters long

Comment on lines +25 to +31
this.metadata = {};
tokens.forEach(tokenId => {
this.metadata[tokenId] = {
weight: (tokenId % 10n) + 1n, // Example: weight based on token ID
rarity: ['common', 'uncommon', 'rare', 'legendary'][Number(tokenId % 4n)] // Example metadata
};
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can build the metadata registry directly

Suggested change
this.metadata = {};
tokens.forEach(tokenId => {
this.metadata[tokenId] = {
weight: (tokenId % 10n) + 1n, // Example: weight based on token ID
rarity: ['common', 'uncommon', 'rare', 'legendary'][Number(tokenId % 4n)] // Example metadata
};
});
this.metadata = Object.fromEntries(tokens.map(tokenId => [
tokenId,
{
weight: (tokenId % 10n) + 1n, // Example: weight based on token ID
rarity: ['common', 'uncommon', 'rare', 'legendary'][Number(tokenId % 4n)] // Example metadata
}
]));

};
});

this.getNFTWeight = (tokenId) => this.metadata[tokenId]?.weight || 1n;
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should not need that, getWeight (defined later) should be enough

});

shouldBehaveLikeERC6372(mode);

const getWeight = token => (fungible ? token : 1n);
const getWeight = token => (fungible ? token : (this.getNFTWeight ? this.getNFTWeight(token) : 1n));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const getWeight = token => (fungible ? token : (this.getNFTWeight ? this.getNFTWeight(token) : 1n));
const getWeight = token => this?.metadata?.[token]?.weigth ?? 1n;

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.

3 participants