delvtech / council-kit

A monorepo of apps and packages for the Council governance protocol.
https://council.delv.tech
GNU Affero General Public License v3.0
27 stars 22 forks source link

Add type field to some data sources for better registering #293

Closed ryangoree closed 1 year ago

ryangoree commented 1 year ago

If a generic VotingVault instance was created, it registered a VotingVaultContactDataSource with the CouncilContext. Then later if a LockingVault instance was created with the same address, it would try to register a LockingVaultContractDataSource using the same filter as the VotingVault which would just return the previously registered generic VotingVaultContactDataSource.

To fix this, I've added a type field to some of the data sources which are more specific versions of others so that the models can create more specific filters for them when registering.

Example:

// BEFORE

const address = '0x0'
const votingVault = new VotingVault(address, context)
const lockingVault = new LockingVault(address, context)

console.log(votingVault.dataSource === lockingVault.dataSource) // true

// this would throw an error since this method doesn't
// exist on the generic `VotingVaultContractDataSource`
lockingVault.getToken()

// AFTER

const address = '0x1'
const votingVault = new VotingVault(address, context)
const lockingVault = new LockingVault(address, context)

console.log(votingVault.dataSource === lockingVault.dataSource) // false

// works fine
lockingVault.getToken()

// ALSO

const address = '0x2'
// more specific created first
const lockingVault = new LockingVault(address, context)
const votingVault = new VotingVault(address, context)

console.log(votingVault.dataSource === lockingVault.dataSource) // true
vercel[bot] commented 1 year ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
council-kit-landing-page ✅ Ready (Inspect) Visit Preview Mar 15, 2023 at 6:47AM (UTC)