From cbbb7a9368fe2cfa033360435cbe4ab4f61ea4bf Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Mon, 12 Nov 2018 14:22:32 -0700 Subject: [PATCH 1/2] fix compiler errors --- Subscription/Subscription.sol | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Subscription/Subscription.sol b/Subscription/Subscription.sol index 59cca71..d137cc0 100644 --- a/Subscription/Subscription.sol +++ b/Subscription/Subscription.sol @@ -169,7 +169,7 @@ contract Subscription { uint256 nonce,// to allow multiple subscriptions with the same parameters bytes signature //proof the subscriber signed the meta trasaction ) - external + public view returns (bool) { @@ -242,8 +242,12 @@ contract Subscription { public returns (bool success) { + bytes32 subscriptionHash = getSubscriptionHash( + from, to, tokenAddress, tokenAmount, periodSeconds, gasPrice, nonce + ); + // make sure the subscription is valid and ready - require(isSubscriptionReady(from, to, tokenAddress, tokenAmount, periodSeconds, gasPrice, nonce, signature), "Subscription is not ready or conditions of transction are not met") + require( isSubscriptionReady(from, to, tokenAddress, tokenAmount, periodSeconds, gasPrice, nonce, signature), "Subscription is not ready or conditions of transction are not met" ); //increment the timestamp by the period so it wont be valid until then nextValidTimestamp[subscriptionHash] = block.timestamp.add(periodSeconds); From 469d2e20044403dc1b3fb6d43a09ac18df7ff564 Mon Sep 17 00:00:00 2001 From: Kevin Seagraves Date: Mon, 26 Nov 2018 13:05:22 -0700 Subject: [PATCH 2/2] add versioning variable to contract --- Subscription/Subscription.sol | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Subscription/Subscription.sol b/Subscription/Subscription.sol index d137cc0..0b45af2 100644 --- a/Subscription/Subscription.sol +++ b/Subscription/Subscription.sol @@ -33,6 +33,7 @@ contract Subscription { //who deploys the contract address public author; + uint8 public contractVersion; // the publisher may optionally deploy requirements for the subscription // so only meta transactions that match the requirements can be relayed @@ -42,6 +43,7 @@ contract Subscription { uint256 public requiredPeriodSeconds; uint256 public requiredGasPrice; + // similar to a nonce that avoids replay attacks this allows a single execution // every x seconds for a given subscription // subscriptionHash => next valid block number @@ -77,7 +79,8 @@ contract Subscription { address _tokenAddress, uint256 _tokenAmount, uint256 _periodSeconds, - uint256 _gasPrice + uint256 _gasPrice, + uint8 _version ) public { requiredToAddress=_toAddress; requiredTokenAddress=_tokenAddress; @@ -85,6 +88,7 @@ contract Subscription { requiredPeriodSeconds=_periodSeconds; requiredGasPrice=_gasPrice; author=msg.sender; + contractVersion=_version; } // this is used by external smart contracts to verify on-chain that a