Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird use of approver id #62

Open
lightclient opened this issue Dec 5, 2018 · 2 comments
Open

Weird use of approver id #62

lightclient opened this issue Dec 5, 2018 · 2 comments

Comments

@lightclient
Copy link
Contributor

When calling acceptFulfillment an _approverId is passed in as a parameter. That is then passed to the modifier to determine if the user is authorized to accept fulfillments. The modifier looks like this:

modifier canApprove(uint _approverId) {
     require(msg.sender == controller || msg.sender == approvers[_approverId]);
     _;
}

I think it is weird that if msg.sender == controller it doesn't matter what the approverId is. I believe a better approach would be to overload the function with two different signatures where one could be called with the approveId and one could be called without.

@lightclient
Copy link
Contributor Author

i.e.

function acceptFulfillment(uint _fulfillmentId, address[] _payoutTokens, uint[] _tokenVersions, uint[][] _tokenAmounts)
       public
       onlyController
{
       _acceptFulfillment(_fulfillmentId, _payoutTokens,  _tokenVersions, _tokenAmounts)
}

function acceptFulfillment(uint _approverId, uint _fulfillmentId, address[] _payoutTokens, uint[] _tokenVersions, uint[][] _tokenAmounts) 
       public
       canApprove(_approverId)
{
      _acceptFulfillment(_fulfillmentId, _payoutTokens,  _tokenVersions, _tokenAmounts)
}

function _acceptFufillment(uint _fulfillmentId, address[] _payoutTokens, uint[] _tokenVersions, uint[][] _tokenAmounts) 
      private
      validateFulfillmentArrayIndex(_fulfillmentId)
      validateApproverArrayIndex(_approverId)
      sameLength(_payoutTokens.length, _tokenVersions.length)
{
      // do accepting logic
}

@lightclient
Copy link
Contributor Author

same issue with fulfillAndAccept

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

No branches or pull requests

1 participant