function forward(
bytes memory _signedHashedMessage,
address _user,
address _recipient,
uint _transactionObjectValueField,
bytes memory _transactionObjectDataField,
address _rewardTokenAddress,
uint _rewardAmount
)
public
returns (bool)
{
bytes32 hashedMessage = getHash(
_user,
_recipient,
_transactionObjectValueField,
_transactionObjectDataField,
_rewardTokenAddress,
_rewardAmount
);
//increment the nonce counter so this tx can't run again
nonce[_user] += 1;
//this makes sure signer signed correctly AND signer is a valid bouncer
require(
isSignerWhitelisted(hashedMessage, _signedHashedMessage),
"fn: forward(), msg: forward Signer is not whitelisted"
);
// make sure the signer pays in whatever token (or ether) the sender and signer agreed to
// or skip this if the sender is incentivized in other ways and there is no need for a token
if (_rewardAmount > 0) {
// address 0 mean reward with ETH
if (_rewardTokenAddress == address(0)){
// reward with ETH
msg.sender.transfer(_rewardAmount);
} else {
// reward token
require(
_rewardTokenAddress._safeTransfer(
msg.sender,
_rewardAmount
),
"fn: forward(), msg: token transfer failed"
);
}
}
// execute the transaction with all the given parameters
require(
executeCall(_recipient, _transactionObjectValueField, _transactionObjectDataField),
"fn: forward(), msg: executeCall() function failed"
);
emit LogTransactionForward(
_signedHashedMessage,
_user,
_recipient,
_transactionObjectValueField,
_transactionObjectDataField,
_rewardTokenAddress,
_rewardAmount,
hashedMessage
);
return true;
}
Last active
July 3, 2019 17:23
-
-
Save andreafspeziale/9c63dfb640e4e6a653df9089d0dbee22 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment