diff --git a/EIPS/eip-1337.md b/EIPS/eip-1337.md index fc58164c7c7221..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 --- @@ -45,25 +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 Operation { - Call, - DelegateCall, - Create, - ERC20, - ERC20Approve - } - enum SubscriptionStatus { - ACTIVE, - PAUSED, - CANCELLED, - EXPIRED + enum Status { + INIT, + TRIAL, + VALID, + CANCELLED, + EXPIRED } enum Period { INIT, + SECOND, + MINUTE, + HOUR, DAY, WEEK, - MONTH + BI_WEEKLY, + MONTH, + THREE_MONTH, + SIX_MONTH, + YEAR, + TWO_YEAR, + THREE_YEAR } } ``` @@ -76,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 + ); } ``` @@ -92,146 +102,119 @@ interface ERC165 { #### Public View Functions -###### isValidSubscription -```SOLIDITY - -/** @dev Checks if the subscription is valid. - * @param bytes subscriptionHash is the identifier of the customer's subscription with its relevant details. - * @return success is the result of whether the subscription is valid or not. - **/ - -function isValidSubscription( - uint256 subscriptionHash - ) - public - view - returns ( - bool success - ) -``` -###### getSubscriptionStatus +###### isValid ```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 + /** @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 ( - uint256 status, - uint256 nextWithdraw + bool success ) ``` -###### getSubscriptionHash +###### 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 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. - **/ -function getSubscriptionHash( + /** @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, - Enum.Operation operation, - uint256 txGas, - uint256 dataGas, - uint256 gasPrice, - address gasToken, - bytes meta + Enum.Period period, + uint256 startDate, + uint256 endDate, + uint256 uniqueId ) - public + external 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 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 + /** @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 ) public view returns ( - bytes32 modifyStatusHash + bytes32 actionHash ) ``` + + #### Public Functions -###### modifyStatus +###### execute ```SOLIDITY -/** @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 + /// @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 memory data, + uint8 period, + uint256 startDate, + uint256 endDate, + uint256 unique, + bytes memory signatures + ) + public returns ( - bool success + bool paid ) ``` -###### 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 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 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( - address to, - uint256 value, - bytes data, - Enum.Operation operation, - uint256 txGas, - uint256 dataGas, - uint256 gasPrice, - address gasToken, - bytes meta, + /** @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