Skip to content
This repository was archived by the owner on Jun 29, 2020. It is now read-only.

(Improvement) Use pure/view instead of const on functions #156

Merged
merged 2 commits into from
May 31, 2018

Conversation

garatortiz
Copy link
Contributor

Before submitting a pull request, please provide the following information:

  • What is it? (leave one option)
    • (Improvement) of existing functionality

Please also put it into pull request title, e.g. (Fix) confirmation page loading

  • What was the root cause of the problem originally / what feature was missing?
    Some functions in smart-contracts were using const.

  • How does this pull request solve it (in broad terms)?
    Replace const with pure/view

  • Does it close any open issues?
    Closes (Refactor) Use pure/view instead of const on functions #146

  • Quick checklist

    • npm run lint shows no errors
    • docs were updated where necessary OR they don't need to be updated
    • tests were updated where necessary OR they don't need to be updated
  • Additional information

@garatortiz garatortiz requested review from fvictorio and phahulin May 30, 2018 13:31
@ghost ghost assigned garatortiz May 30, 2018
@ghost ghost added the in progress label May 30, 2018
@@ -73,7 +73,7 @@ contract ProofOfPhysicalAddress {

// Helpers:
function signerIsValid(bytes32 data, uint8 v, bytes32 r, bytes32 s)
public constant returns (bool)
public view returns (bool)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this one can be turned into pure

Copy link
Contributor Author

@garatortiz garatortiz May 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but if run the test using pure, the output is this below, and for that I used view instead of pure:

poa-popa on  issue-#146 [$!]  ⬢ v8.9.4
🦄 npm run test --prefix blockchain

> [email protected] test /Users/matiasgaratortiz/Github/poa-popa/blockchain
> NODE_ENV=test truffle test --network test

Using network 'test'.

Compiling ./contracts/ERC20.sol...
Compiling ./contracts/EthereumClaimsRegistryInterface.sol...
Compiling ./contracts/PhysicalAddressClaim.sol...
Compiling ./contracts/ProofOfPhysicalAddress.sol...
Compiling ./contracts/TestERC20.sol...

/Users/matiasgaratortiz/Github/poa-popa/blockchain/contracts/ProofOfPhysicalAddress.sol:80:49: TypeError: Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view".
        return (ecrecover(prefixed, v, r, s) == signer);
                                                ^----^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, I missed that it reads signer from contract state. Nevermind then

@phahulin phahulin self-requested a review May 31, 2018 13:47
@phahulin phahulin merged commit b0b0957 into master May 31, 2018
@ghost ghost removed the in progress label May 31, 2018
@phahulin phahulin deleted the issue-#146 branch May 31, 2018 13:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(Refactor) Use pure/view instead of const on functions
3 participants