diff --git a/contracts/Crowdsale.sol b/contracts/Crowdsale.sol index 5d15f2b7..ecec53e5 100644 --- a/contracts/Crowdsale.sol +++ b/contracts/Crowdsale.sol @@ -119,11 +119,19 @@ contract Crowdsale is CrowdsaleBase { * Invest to tokens, recognize the payer. * */ - function buyWithCustomerId(uint128 customerId, bytes1 checksum) public payable { + function buyWithCustomerIdWithChecksum(uint128 customerId, bytes1 checksum) public payable { + // see customerid.py if (bytes1(sha3(customerId)) != checksum) throw; investWithCustomerId(msg.sender, customerId); } + /** + * Legacy API signature. + */ + function buyWithCustomerId(uint128 customerId) public payable { + investWithCustomerId(msg.sender, customerId); + } + /** * The basic entry point to participate the crowdsale process. * diff --git a/contracts/PaymentForwarder.sol b/contracts/PaymentForwarder.sol index 678a173a..2a804462 100644 --- a/contracts/PaymentForwarder.sol +++ b/contracts/PaymentForwarder.sol @@ -72,6 +72,7 @@ contract PaymentForwarder is Haltable { * */ function pay(uint128 customerId, address benefactor, bytes1 checksum) public stopInEmergency payable { + // see customerid.py if (bytes1(sha3(customerId, benefactor)) != checksum) throw; payWithoutChecksum(customerId, benefactor); } @@ -82,9 +83,17 @@ contract PaymentForwarder is Haltable { * @param customerId Identifier in the central database, UUID v4 * */ - function payForMyself(uint128 customerId, bytes1 checksum) public payable { + function payForMyselfWithChecksum(uint128 customerId, bytes1 checksum) public payable { + // see customerid.py if (bytes1(sha3(customerId)) != checksum) throw; payWithoutChecksum(customerId, msg.sender); } + /** + * Legacy API signature. + */ + function payForMyself(uint128 customerId) public payable { + payWithoutChecksum(customerId, msg.sender); + } + } diff --git a/ico/tests/contracts/test_forwarder.py b/ico/tests/contracts/test_forwarder.py index 3b625acf..12be5ffe 100644 --- a/ico/tests/contracts/test_forwarder.py +++ b/ico/tests/contracts/test_forwarder.py @@ -8,6 +8,7 @@ from sha3 import keccak_256 from rlp.utils import decode_hex + @pytest.fixture def payment_forwarder(chain, team_multisig): args = [team_multisig, team_multisig] @@ -93,7 +94,7 @@ def test_pay_for_myself(web3, payment_forwarder, team_multisig, customer): team_multisig_begin = web3.eth.getBalance(team_multisig) checksumbyte = keccak_256(decode_hex(format(customer_id, 'x').zfill(32))).digest()[:1] - payment_forwarder.transact({"value": value, "from": customer}).payForMyself(customer_id, checksumbyte) + payment_forwarder.transact({"value": value, "from": customer}).payForMyselfWithChecksum(customer_id, checksumbyte) team_multisig_end = web3.eth.getBalance(team_multisig) assert team_multisig_end - team_multisig_begin > 0 diff --git a/ico/tests/contracts/test_require_customer_id.py b/ico/tests/contracts/test_require_customer_id.py index 95a5a6ff..3dfa23e0 100644 --- a/ico/tests/contracts/test_require_customer_id.py +++ b/ico/tests/contracts/test_require_customer_id.py @@ -45,7 +45,7 @@ def test_participate_with_customer_id(chain, crowdsale, customer, customer_id, t wei_value = to_wei(1, "ether") assert crowdsale.call().getState() == CrowdsaleState.Funding checksumbyte = keccak_256(decode_hex(format(customer_id, 'x').zfill(32))).digest()[:1] - crowdsale.transact({"from": customer, "value": wei_value}).buyWithCustomerId(customer_id, checksumbyte) + crowdsale.transact({"from": customer, "value": wei_value}).buyWithCustomerIdWithChecksum(customer_id, checksumbyte) # We got credited assert token.call().balanceOf(customer) > 0