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
If a generic
VotingVault
instance was created, it registered aVotingVaultContactDataSource
with theCouncilContext
. Then later if aLockingVault
instance was created with the same address, it would try to register aLockingVaultContractDataSource
using the same filter as theVotingVault
which would just return the previously registered genericVotingVaultContactDataSource
.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: