poanetwork / poa-popa

DApp for proof of physical address (PoPA) attestation for validators of POA Network
https://popa.poa.network
GNU General Public License v3.0
24 stars 18 forks source link

(Refactor) Avoid decoding empty claim #157

Closed phahulin closed 6 years ago

phahulin commented 6 years ago

In function userAddressInfo

https://github.com/poanetwork/poa-popa/blob/master/blockchain/contracts/ProofOfPhysicalAddress.sol#L251-L262

it's suggested to use the following check to avoid decoding 0 claim:

bytes32 claim = registry.getClaim(
   address(this),
   wallet,
   users[wallet].physicalAddresses[addressIndex].keccakIdentifier);
return (
   users[wallet].physicalAddresses[addressIndex].name,
   users[wallet].physicalAddresses[addressIndex].creationBlock,
   uint256(claim) != 0 ? PhysicalAddressClaim.decodeConfirmation(claim) : 0,
   users[wallet].physicalAddresses[addressIndex].keccakIdentifier
);