From 4f622384558d3142770cd1ef50508ab3e2db92ab Mon Sep 17 00:00:00 2001 From: Andrew Redden Date: Wed, 27 Feb 2019 12:32:31 -0400 Subject: [PATCH 1/4] EIP1337 Updated to remove gas information from the specification, the concept of a refund, and to define 4 additional paramaters as apart of the function specification for execute, the removal of subscription from function paramaters as the spec is defining them directly --- EIPS/eip-1337.md | 121 +++++++++++++++-------------------------------- 1 file changed, 39 insertions(+), 82 deletions(-) diff --git a/EIPS/eip-1337.md b/EIPS/eip-1337.md index fc58164c7c7221..af26271d5f098b 100644 --- a/EIPS/eip-1337.md +++ b/EIPS/eip-1337.md @@ -45,13 +45,6 @@ EIP-1337 Contracts should be compiled with a contract that references all the en /// @title Enum - Collection of enums /// Original concept from Richard Meissner - Gnosis safe contracts contract Enum { - enum Operation { - Call, - DelegateCall, - Create, - ERC20, - ERC20Approve - } enum SubscriptionStatus { ACTIVE, PAUSED, @@ -61,6 +54,9 @@ contract Enum { enum Period { INIT, + SECONDS, + MINUTES, + HOURS, DAY, WEEK, MONTH @@ -92,16 +88,18 @@ interface ERC165 { #### Public View Functions -###### isValidSubscription +###### isValid ```SOLIDITY /** @dev Checks if the subscription is valid. - * @param bytes subscriptionHash is the identifier of the customer's subscription with its relevant details. + * @param bytes32 subscriptionHash is the identifier of the customer's subscription with its relevant details. + * @param bytes signatures is the signature provided to the merchant to validate the subscription * @return success is the result of whether the subscription is valid or not. **/ -function isValidSubscription( - uint256 subscriptionHash +function isValid( + bytes32 subscriptionHash, + bytes signatures ) public view @@ -109,25 +107,8 @@ function isValidSubscription( bool success ) ``` -###### getSubscriptionStatus -```SOLIDITY -/** @dev returns the value of the subscription - * @param bytes subscriptionHash is the identifier of the customer's subscription with its relevant details. - * @return status is the enumerated status of the current subscription, 0 expired, 1 active, 2 paused, 3 cancelled - **/ -function getSubscriptionStatus( - uint256 subscriptionHash - ) - public - view - returns ( - uint256 status, - uint256 nextWithdraw - ) -``` - -###### getSubscriptionHash +###### getHash ```SOLIDITY /** @dev returns the hash of cocatenated inputs to the address of the contract holding the logic., @@ -137,101 +118,77 @@ function getSubscriptionStatus( * @param address recipient the address of the person who is getting the funds. * @param uint256 value the value of the transaction * @param bytes data the data the user is agreeing to - * @param uint256 txGas the cost of executing one of these transactions in gas(probably safe to pad this) - * @param uint256 dataGas the cost of executing the data portion of the trasnaction(delegate calls etc) - * @param uint 256 gasPrice the agreed upon gas cost of Execution of this subscription(cost incurment is up to implementation, ie, sender or reciever) - * @param address gasToken address of the token in which gas will be compensated by, address(0) is ETH, only works in the case of an enscrow implementation) - * @param bytes meta dynamic bytes array with 4 slots, 2 required, 2 optional // address refundAddress / uint256 period / uint256 offChainID / uint256 expiration (uinx timestamp) - * @return bytes32, return the hash input arguments concatenated to the address of the contract that holds the logic. + * @param Enum.period period valid period supported by the spec + * @param uint256 startDate the start of the agreement (UNIX TIMESTAMP) + * @param uint256 endDate the end of the agreement (UNIX TIMESTAMP) + * @param uint256 uniqueId the unique identifier of the subscription hash, (for more than 1 subscription to the same merchant) + * @return bytes32, return the EIP712 compliant hash **/ -function getSubscriptionHash( +function getHash( address recipient, uint256 value, bytes data, - Enum.Operation operation, - uint256 txGas, - uint256 dataGas, - uint256 gasPrice, - address gasToken, - bytes meta + Enum.Period period, + uint256 startDate, + uint256 endDate, + uint256 uniqueId ) public view returns ( - bytes32 subscriptionHash + bytes32 hash ) ``` -###### getModifyStatusHash +###### getActionHash ```SOLIDITY /** @dev returns the hash of concatenated inputs that the owners user would sign with their public keys - * @param address recipient the address of the person who is getting the funds. + * @param bytes32 the hash to modify * @param uint256 value the value of the transaction * @return bytes32 returns the hash of concatenated inputs with the address of the contract holding the subscription hash **/ -function getModifyStatusHash( - bytes32 subscriptionHash - Enum.SubscriptionStatus status +function getActionHash( + bytes32 hash + string action ) public view returns ( - bytes32 modifyStatusHash + bytes32 actionHash ) ``` -#### Public Functions -###### modifyStatus -```SOLIDITY +#### Public Functions -/** @dev modifys the current subscription status - * @param uint256 subscriptionHash is the identifier of the customer's subscription with its relevant details. - * @param Enum.SubscriptionStatus status the new status of the subscription - * @param bytes signatures of the requested method being called - * @return success is the result of the subscription being paused - **/ -function modifyStatus( - uint256 subscriptionHash, - Enum.SubscriptionStatus status, - bytes signatures - ) - public - returns ( - bool success - ) -``` -###### executeSubscription +###### execute ```SOLIDITY /** @dev returns the hash of cocatenated inputs to the address of the contract holding the logic., * the owner would sign this hash and then provide it to the party for execution at a later date, * this could be viewed like a cheque, with the exception that unless you specifically * capture the hash on chain a valid signature will be executable at a later date, capturing the hash lets you modify the status to cancel or expire it. - * @param address recipient the address of the person who is getting the funds. + * @param address to the address of the person who is getting the funds. * @param uint256 value the value of the transaction * @param bytes data the data the user is agreeing to - * @param uint256 txGas the cost of executing one of these transactions in gas(probably safe to pad this) - * @param uint256 dataGas the cost of executing the data portion of the trasnaction(delegate calls etc) - * @param uint 256 gasPrice the agreed upon gas cost of Execution of this subscription(cost incurment is up to implementation, ie, sender or reciever) - * @param address gasToken address of the token in which gas will be compensated by, address(0) is ETH, only works in the case of an enscrow implementation) - * @param bytes meta dynamic bytes array with 4 slots, 2 required, 2 optional // address refundAddress / uint256 period / uint256 offChainID / uint256 expiration (uinx timestamp) + * @param Enum.Period period the defined period of the agreement + * @param uint256 startDate the startDate of the agreement (UNIX TIMESTAMP) + * @param uint256 endDate the endDate of the agreement (UNIX TIMESTAMP) + * @param uint256 uniqueId unique identifier of the subscription agreement * @param bytes signatures signatures concatenated that have signed the inputs as proof of valid execution * @return bool success something to note that a failed execution will still pay the issuer of the transaction for their gas costs. **/ -function executeSubscription( +function execute( address to, uint256 value, bytes data, - Enum.Operation operation, - uint256 txGas, - uint256 dataGas, - uint256 gasPrice, - address gasToken, - bytes meta, + Enum.Period period + uint256 startDate, + uint256 endDate, + uint256 uniqueId bytes signatures ) public From 38adef36c39dd68bf196884d0cfdf8ea8f62b2fd Mon Sep 17 00:00:00 2001 From: Andrew Redden Date: Wed, 27 Feb 2019 12:34:43 -0400 Subject: [PATCH 2/4] Added cancel method --- EIPS/eip-1337.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/EIPS/eip-1337.md b/EIPS/eip-1337.md index af26271d5f098b..c54fe3bb1841ef 100644 --- a/EIPS/eip-1337.md +++ b/EIPS/eip-1337.md @@ -197,6 +197,24 @@ function execute( ) ``` +###### execute +```SOLIDITY + +/** @dev cancel the subscription and check against the actionHash to ensure that its a valid subscription + * @param bytes32 hash the hash of the subscription that is being cancelled + * @param bytes signatures the signature proving the users intent to cancel + * @return bool success something to note that a failed execution will still pay the issuer of the transaction for their gas costs. + **/ +function cancel( + bytes32 hash, + bytes signatures + ) + public + returns ( + bool success + ) +``` + ## Rationale Merchants who accept credit-cards do so by storing a token that is retrieved from a third party processor(stripe, paypal, etc), this token is used to grant access to pull payment from the cx's credit card provider and move funds to the merchant account. From d918bc6094915d4c1705b7172dcf3b97eedacbb5 Mon Sep 17 00:00:00 2001 From: Andrew Redden Date: Wed, 27 Feb 2019 13:02:11 -0400 Subject: [PATCH 3/4] Added periods and status to support --- EIPS/eip-1337.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/EIPS/eip-1337.md b/EIPS/eip-1337.md index c54fe3bb1841ef..91b9b21ec55de8 100644 --- a/EIPS/eip-1337.md +++ b/EIPS/eip-1337.md @@ -45,21 +45,28 @@ EIP-1337 Contracts should be compiled with a contract that references all the en /// @title Enum - Collection of enums /// Original concept from Richard Meissner - Gnosis safe contracts contract Enum { - enum SubscriptionStatus { - ACTIVE, - PAUSED, - CANCELLED, - EXPIRED + enum Status { + INIT, + TRIAL, + VALID, + CANCELLED, + EXPIRED } enum Period { INIT, - SECONDS, - MINUTES, - HOURS, + SECOND, + MINUTE, + HOUR, DAY, WEEK, - MONTH + BI_WEEKLY, + MONTH, + THREE_MONTH, + SIX_MONTH, + YEAR, + TWO_YEAR, + THREE_YEAR } } ``` From 506add707e16c44ecd0cd908a035be3a0a6d3c8c Mon Sep 17 00:00:00 2001 From: Andrew Redden Date: Thu, 31 Oct 2019 13:49:40 -0300 Subject: [PATCH 4/4] EIP-1271 added as a requirement, and updated some formatting changes --- EIPS/eip-1337.md | 147 ++++++++++++++++++++++++----------------------- 1 file changed, 74 insertions(+), 73 deletions(-) diff --git a/EIPS/eip-1337.md b/EIPS/eip-1337.md index 91b9b21ec55de8..75d1ee172f30f9 100644 --- a/EIPS/eip-1337.md +++ b/EIPS/eip-1337.md @@ -7,7 +7,7 @@ discussions-to: https://github.com/EthereumOpenSubscriptions/standard/issues or type: Standards category: Interface created: 2018-08-01 -requires: ERC-20, ERC-948, EIP-165 +requires: ERC-20, ERC-948, EIP-165, EIP-1271 --- @@ -79,15 +79,22 @@ ERC-948 Compliant contracts support EIP-165 announcing what interfaces they supp ```SOLIDITY interface ERC165 { - /** - * @notice Query if a contract implements an interface - * @param interfaceID The interface identifier, as specified in ERC-165 - * @dev Interface identification is specified in ERC-165. This function - * uses less than 30,000 gas. - * @return `true` if the contract implements `interfaceID` and - * `interfaceID` is not 0xffffffff, `false` otherwise - **/ - function supportsInterface(bytes4 interfaceID) external view returns (bool); + /** + * @notice Query if a contract implements an interface + * @param interfaceID The interface identifier, as specified in ERC-165 + * @dev Interface identification is specified in ERC-165. This function + * uses less than 30,000 gas. + * @return `true` if the contract implements `interfaceID` and + * `interfaceID` is not 0xffffffff, `false` otherwise + **/ + function supportsInterface( + bytes4 interfaceID + ) + external + view + returns ( + bool + ); } ``` @@ -98,40 +105,39 @@ interface ERC165 { ###### isValid ```SOLIDITY -/** @dev Checks if the subscription is valid. - * @param bytes32 subscriptionHash is the identifier of the customer's subscription with its relevant details. - * @param bytes signatures is the signature provided to the merchant to validate the subscription - * @return success is the result of whether the subscription is valid or not. - **/ - -function isValid( - bytes32 subscriptionHash, - bytes signatures - ) - public - view - returns ( - bool success - ) + /** @dev Checks if the subscription is valid. + * @param bytes32 signatureData is the identifier of the customer's subscription with its relevant details. + * @param bytes signatures is the signature provided to the merchant to validate the subscription + * @return success is the result of whether the subscription is valid or not. + **/ + function isValid( + bytes signatureData, + bytes signatures + ) + external + view + returns ( + bool success + ) ``` ###### getHash ```SOLIDITY -/** @dev returns the hash of cocatenated inputs to the address of the contract holding the logic., - * the owner would sign this hash and then provide it to the party for execution at a later date, - * this could be viewed like a cheque, with the exception that unless you specifically - * capture the hash on chain a valid signature will be executable at a later date, capturing the hash lets you modify the status to cancel or expire it. - * @param address recipient the address of the person who is getting the funds. - * @param uint256 value the value of the transaction - * @param bytes data the data the user is agreeing to - * @param Enum.period period valid period supported by the spec - * @param uint256 startDate the start of the agreement (UNIX TIMESTAMP) - * @param uint256 endDate the end of the agreement (UNIX TIMESTAMP) - * @param uint256 uniqueId the unique identifier of the subscription hash, (for more than 1 subscription to the same merchant) - * @return bytes32, return the EIP712 compliant hash - **/ -function getHash( + /** @dev returns the hash of concatenated inputs to the address of the contract holding the logic., + * the owner would sign this hash and then provide it to the party for execution at a later date, + * this could be viewed like a cheque, with the exception that unless you specifically + * capture the hash on chain a valid signature will be executable at a later date, capturing the hash lets you modify the status to cancel or expire it. + * @param address recipient the address of the person who is getting the funds. + * @param uint256 value the value of the transaction + * @param bytes data the data the user is agreeing to + * @param Enum.period period valid period supported by the spec + * @param uint256 startDate the start of the agreement (UNIX TIMESTAMP) + * @param uint256 endDate the end of the agreement (UNIX TIMESTAMP) + * @param uint256 uniqueId the unique identifier of the subscription hash, (for more than 1 subscription to the same merchant) + * @return bytes32, return the EIP712 compliant hash + **/ + function getHash( address recipient, uint256 value, bytes data, @@ -140,7 +146,7 @@ function getHash( uint256 endDate, uint256 uniqueId ) - public + external view returns ( bytes32 hash @@ -151,12 +157,12 @@ function getHash( ###### getActionHash ```SOLIDITY -/** @dev returns the hash of concatenated inputs that the owners user would sign with their public keys - * @param bytes32 the hash to modify - * @param uint256 value the value of the transaction - * @return bytes32 returns the hash of concatenated inputs with the address of the contract holding the subscription hash - **/ -function getActionHash( + /** @dev returns the hash of concatenated inputs that the owners user would sign with their public keys + * @param bytes32 the hash to modify + * @param uint256 value the value of the transaction + * @return bytes32 returns the hash of concatenated inputs with the address of the contract holding the subscription hash + **/ + function getActionHash( bytes32 hash string action ) @@ -174,45 +180,40 @@ function getActionHash( ###### execute ```SOLIDITY -/** @dev returns the hash of cocatenated inputs to the address of the contract holding the logic., - * the owner would sign this hash and then provide it to the party for execution at a later date, - * this could be viewed like a cheque, with the exception that unless you specifically - * capture the hash on chain a valid signature will be executable at a later date, capturing the hash lets you modify the status to cancel or expire it. - * @param address to the address of the person who is getting the funds. - * @param uint256 value the value of the transaction - * @param bytes data the data the user is agreeing to - * @param Enum.Period period the defined period of the agreement - * @param uint256 startDate the startDate of the agreement (UNIX TIMESTAMP) - * @param uint256 endDate the endDate of the agreement (UNIX TIMESTAMP) - * @param uint256 uniqueId unique identifier of the subscription agreement - * @param bytes signatures signatures concatenated that have signed the inputs as proof of valid execution - * @return bool success something to note that a failed execution will still pay the issuer of the transaction for their gas costs. - **/ -function execute( + /// @param to Destination of transaction + /// @param value Ether value + /// @param data bytes payload transaction. + /// @param period uint256 1337 period + /// @param unique uint256 1337 unique + /// @param startDate uint256 1337 start + /// @param endDate uint256 1337 end + /// @param signatures Packed signature data ({bytes32 r}{bytes32 s}{uint256 v}) + /// @return success boolean value of execution + function execute( address to, uint256 value, - bytes data, - Enum.Period period + bytes memory data, + uint8 period, uint256 startDate, uint256 endDate, - uint256 uniqueId - bytes signatures + uint256 unique, + bytes memory signatures ) - public + public returns ( - bool success + bool paid ) ``` ###### execute ```SOLIDITY -/** @dev cancel the subscription and check against the actionHash to ensure that its a valid subscription - * @param bytes32 hash the hash of the subscription that is being cancelled - * @param bytes signatures the signature proving the users intent to cancel - * @return bool success something to note that a failed execution will still pay the issuer of the transaction for their gas costs. - **/ -function cancel( + /** @dev cancel the subscription and check against the actionHash to ensure that its a valid subscription + * @param bytes32 hash the hash of the subscription that is being cancelled + * @param bytes signatures the signature proving the users intent to cancel + * @return bool success something to note that a failed execution will still pay the issuer of the transaction for their gas costs. + **/ + function cancel( bytes32 hash, bytes signatures )