Skip to content

Commit

Permalink
Manager v1 extension compat (#546)
Browse files Browse the repository at this point in the history
* Make manager extension replacement v1 compatible

* Fix tests

* Lint fix

* Add revert

* Remove pure from addExtension
  • Loading branch information
nickmzero committed Jul 12, 2022
1 parent 167b522 commit a4c79f9
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
19 changes: 15 additions & 4 deletions contracts/adapters/Manager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,21 @@ contract Manager is Reimbursable, AdapterGuard, Signatures {
}

if (proposal.adapterOrExtensionAddr != address(0x0)) {
dao.addExtension(
proposal.adapterOrExtensionId,
IExtension(proposal.adapterOrExtensionAddr)
);
try
dao.addExtension(
proposal.adapterOrExtensionId,
IExtension(proposal.adapterOrExtensionAddr)
)
{} catch {
// v1.0.6 signature
dao.addExtension(
proposal.adapterOrExtensionId,
IExtension(proposal.adapterOrExtensionAddr),
// The creator of the extension must be set as the DAO owner,
// which is stored at index 0 in the members storage.
dao.getMemberAddress(0)
);
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions contracts/core/DaoRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,15 @@ contract DaoRegistry is MemberGuard, AdapterGuard {
emit ExtensionAdded(extensionId, address(extension));
}

// v1.0.6 signature
function addExtension(
bytes32,
IExtension,
address
) external {
revert("not implemented");
}

/**
* @notice Removes an adapter from the registry
* @param extensionId The unique identifier of the extension
Expand Down
5 changes: 4 additions & 1 deletion test/core/dao-registry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,10 @@ describe("Core - DaoRegistry", () => {

it("should not be possible to call addExtension without the ADD_EXTENSION permission", async () => {
await expect(
this.dao.addExtension(sha3("extension1"), accounts[2])
this.dao["addExtension(bytes32,address)"](
sha3("extension1"),
accounts[2]
)
).to.be.revertedWith("accessDenied");
});

Expand Down
5 changes: 4 additions & 1 deletion utils/deployment-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ const createExtensions = async ({ dao, factories, options }) => {
);

await waitTx(
dao.addExtension(sha3(newExtension.configs.id), newExtension.address)
dao["addExtension(bytes32,address)"](
sha3(newExtension.configs.id),
newExtension.address
)
);

info(`
Expand Down

0 comments on commit a4c79f9

Please sign in to comment.