Skip to content

Commit

Permalink
Support contract consumer set by self (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
nz-neooo authored Feb 19, 2024
1 parent a6eca6b commit 6d9d562
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions contracts/ConsumerRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ contract ConsumerRegistry is Initializable, OwnableUpgradeable {
* @dev Consumer add controller can request access token from indexer.
*/
function addController(address consumer, address controller) external {
if (_isContract(consumer)) {
require(consumer.supportsInterface(type(IConsumer).interfaceId), 'CR002');
IConsumer cConsumer = IConsumer(consumer);
require(cConsumer.isSigner(msg.sender), 'CR003');
} else {
require(msg.sender == consumer, 'CR001');
if (msg.sender != consumer) {
if (_isContract(consumer)) {
require(consumer.supportsInterface(type(IConsumer).interfaceId), 'CR002');
IConsumer cConsumer = IConsumer(consumer);
require(cConsumer.isSigner(msg.sender), 'CR003');
} else {
revert('CR001');
}
}

controllers[consumer][controller] = true;
Expand Down

0 comments on commit 6d9d562

Please sign in to comment.