I am facing a head scratching issue. I have created two contracts UserRole which has a map of username to a role and a Base contract that has a modifier which checks if the role is < 10.
So I deploy the first UserRole contract first and then I called the set function with the parameters _username = "jamesbond" and _role=7.
After the transaction is mined I call the getRole passing _username = "jamesbond" and I get back 7.
Now I deploy Base and pass the address of the the UserRole contract that I deployed earlier. I call the testModifier function and I pass it _username = "jamesbond". I expect that I get the value 7 back.
I tested this on http://remix.ethereum.org first. Then I tried it on quorum and parity. On remix it works as expected but on both quorum and parity I do not get any values back.
I am not sure what I am doing wrong.
pragma solidity ^0.4.24;
contract UserRole {
address owner;
mapping (string => uint8) userRoles;
constructor()
public
{
owner = msg.sender;
}
function set(string _username, uint8 _role)
public
returns (bool sucesss)
{
userRoles[_username] = _role;
return true;
}
function getRole(string _username)
public
view
returns (uint8 _role)
{
return userRoles[_username];
}
}
contract Base {
address owner;
UserRole userRole;
address public userRoleAddress;
constructor(address _t)
public
{
owner = msg.sender;
userRoleAddress = _t;
userRole = UserRole(_t);
}
modifier isAuthorized(string _username) {
uint8 role = 5;
require(role < 10);
_;
}
function testModifier(string _username)
public
isAuthorized(_username)
view
returns (uint8 result)
{
return userRole.getRole(_username);
}
}