From 9c5a6817cadb131c2b672ec7c1d604007b235c45 Mon Sep 17 00:00:00 2001 From: Wighawag Date: Mon, 13 May 2019 09:33:10 +0100 Subject: [PATCH 1/4] add 5000 gas rules --- EIPS/eip-1155.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/EIPS/eip-1155.md b/EIPS/eip-1155.md index 6e93a48dc20563..77e1e8e8f68938 100644 --- a/EIPS/eip-1155.md +++ b/EIPS/eip-1155.md @@ -317,7 +317,9 @@ To be more explicit about how safeTransferFrom and safeBatchTransferFrom MUST op return 0x0d912442; // bytes4(keccak256("isERC1155TokenReceiver()")) } ``` -* The implementation MAY differ from the above but it MUST return the same value. +* The implementation MAY differ from the above but : + - it MUST return the same value. + - it MUST spend at max 5,000 gas **_Implementation specific transfer api rules:_** * If implementation specific api functions are used to transfer 1155 tokens to a contract, the safeTransferFrom, or safeBatchTransferFrom (as appropriate) rules MUST be followed. From 1dad31150cec22194c57695eff10eb7b1fdd0750 Mon Sep 17 00:00:00 2001 From: Wighawag Date: Mon, 13 May 2019 09:34:38 +0100 Subject: [PATCH 2/4] rewording --- EIPS/eip-1155.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-1155.md b/EIPS/eip-1155.md index 77e1e8e8f68938..e89f9ed437f88a 100644 --- a/EIPS/eip-1155.md +++ b/EIPS/eip-1155.md @@ -319,7 +319,7 @@ To be more explicit about how safeTransferFrom and safeBatchTransferFrom MUST op ``` * The implementation MAY differ from the above but : - it MUST return the same value. - - it MUST spend at max 5,000 gas + - it MUST not spend more than 5,000 gas **_Implementation specific transfer api rules:_** * If implementation specific api functions are used to transfer 1155 tokens to a contract, the safeTransferFrom, or safeBatchTransferFrom (as appropriate) rules MUST be followed. From 08c64cb767de33a831f83a4133e78c5c5ede771c Mon Sep 17 00:00:00 2001 From: Wighawag Date: Mon, 13 May 2019 09:59:45 +0100 Subject: [PATCH 3/4] add 5000 rules for the caller too --- EIPS/eip-1155.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-1155.md b/EIPS/eip-1155.md index e89f9ed437f88a..11e396a49efcc3 100644 --- a/EIPS/eip-1155.md +++ b/EIPS/eip-1155.md @@ -335,7 +335,7 @@ To cater for this scenario, there is some leeway with the rejection logic should Hence in a hybrid 1155 contract implementation an extra call MUST be made on the recipient contract and checked before any hook calls to `onERC1155Received` or `onERC1155BatchReceived` are made. Order of operation MUST therefore be: -1. The implementation MUST call the function `isERC1155TokenReceiver` on the recipient. +1. The implementation MUST call the function `isERC1155TokenReceiver` on the recipient, providing at least 5,000 gas. 2. If the function call succeeds and the return value is `bytes4(keccak256("isERC1155TokenReceiver()"))` the implementation proceeds as a regular 1155 implementation, with the call(s) to the `onERC1155Received` or `onERC1155BatchReceived` hooks and rules associated. 3. If the function call fails or the return value is NOT `bytes4(keccak256("isERC1155TokenReceiver()"))` the implementation can assume the contract recipient is not an `ERC1155TokenReceiver` and follow its other standard's rules for transfers. From fe9613049a18457b8636d5703ea6a30382a70bbd Mon Sep 17 00:00:00 2001 From: Wighawag Date: Mon, 13 May 2019 10:01:14 +0100 Subject: [PATCH 4/4] precision in isERC1155TokenReceiver doc comments --- EIPS/eip-1155.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EIPS/eip-1155.md b/EIPS/eip-1155.md index 11e396a49efcc3..0894c4eb50aceb 100644 --- a/EIPS/eip-1155.md +++ b/EIPS/eip-1155.md @@ -189,7 +189,7 @@ interface ERC1155TokenReceiver { /** @notice Indicates whether a contract implements the `ERC1155TokenReceiver` functions and so can accept ERC1155 token types. - @dev This function MUST return `bytes4(keccak256("isERC1155TokenReceiver()"))` (i.e. 0x0d912442). + @dev This function MUST return `bytes4(keccak256("isERC1155TokenReceiver()"))` (i.e. 0x0d912442). and MUST not consume more than 5,000 gas. @return `bytes4(keccak256("isERC1155TokenReceiver()"))` */ function isERC1155TokenReceiver() external pure returns (bytes4);