From cae5115f385eb220141d476d962ea514791d92cc Mon Sep 17 00:00:00 2001 From: Sylvain Bellemare Date: Mon, 4 Apr 2022 18:38:22 -0500 Subject: [PATCH] Remove src directory --- src/contracts/FlattenedHbSwap.sol | 591 ------ src/contracts/FlattenedHbSwapToken.sol | 570 ----- src/contracts/HbSwap.sol | 200 -- src/contracts/HbSwapToken.sol | 13 - src/genfiles/HbSwap.abi | 858 -------- src/genfiles/HbSwap.bin | 1 - src/genfiles/HbSwapToken.abi | 330 --- src/genfiles/HbSwapToken.bin | 1 - src/go/client/add_liquidity.go | 18 - src/go/client/deposit.go | 83 - src/go/client/init_pool.go | 75 - src/go/client/lib/confparse.go | 41 - src/go/client/remove_liquidity.go | 18 - src/go/client/secret_deposit.go | 55 - src/go/client/secret_withdraw.go | 55 - src/go/client/testnet.go | 52 - src/go/client/trade.go | 54 - src/go/client/withdraw.go | 62 - src/go/deploy/deploy.go | 77 - src/go/reset/reset.go | 20 - src/go/server/lib/confparse.go | 42 - src/go/server/server.go | 326 --- src/go/utils/utils.go | 216 -- src/go/utils/utils_eth.go | 92 - src/go/utils/utils_hbswap.go | 466 ----- src/go/utils/utils_pq.go | 48 - src/go/utils/utils_token.go | 83 - src/go_bindings/hbSwapToken/hbSwapToken.go | 850 -------- src/go_bindings/hbswap/hbswap.go | 1848 ----------------- src/mpc/hbswap_add_liquidity.mpc | 84 - src/mpc/hbswap_calc_batch_price.mpc | 32 - src/mpc/hbswap_calc_individual_price.mpc | 38 - src/mpc/hbswap_init_pool.mpc | 41 - src/mpc/hbswap_remove_liquidity.mpc | 76 - src/mpc/hbswap_secret_withdraw.mpc | 26 - src/mpc/hbswap_trade.mpc | 88 - src/node_modules/.package-lock.json | 12 - .../@openzeppelin/contracts/GSN/Context.sol | 27 - .../contracts/GSN/GSNRecipient.sol | 228 -- .../contracts/GSN/GSNRecipientERC20Fee.sol | 151 -- .../contracts/GSN/GSNRecipientSignature.sol | 72 - .../@openzeppelin/contracts/GSN/IRelayHub.sol | 267 --- .../contracts/GSN/IRelayRecipient.sol | 74 - .../@openzeppelin/contracts/GSN/README.adoc | 30 - .../@openzeppelin/contracts/README.md | 78 - .../contracts/access/README.adoc | 21 - .../@openzeppelin/contracts/access/Roles.sol | 36 - .../contracts/access/roles/CapperRole.sol | 44 - .../contracts/access/roles/MinterRole.sol | 44 - .../contracts/access/roles/PauserRole.sol | 44 - .../contracts/access/roles/SignerRole.sol | 44 - .../access/roles/WhitelistAdminRole.sol | 48 - .../access/roles/WhitelistedRole.sol | 51 - .../contracts/crowdsale/Crowdsale.sol | 200 -- .../contracts/crowdsale/README.adoc | 35 - .../distribution/FinalizableCrowdsale.sol | 51 - .../distribution/PostDeliveryCrowdsale.sol | 65 - .../distribution/RefundableCrowdsale.sol | 83 - .../RefundablePostDeliveryCrowdsale.sol | 20 - .../crowdsale/emission/AllowanceCrowdsale.sol | 51 - .../crowdsale/emission/MintedCrowdsale.sol | 24 - .../price/IncreasingPriceCrowdsale.sol | 79 - .../crowdsale/validation/CappedCrowdsale.sol | 48 - .../IndividuallyCappedCrowdsale.sol | 64 - .../validation/PausableCrowdsale.sol | 21 - .../crowdsale/validation/TimedCrowdsale.sol | 98 - .../validation/WhitelistCrowdsale.sol | 21 - .../contracts/cryptography/ECDSA.sol | 82 - .../contracts/cryptography/MerkleProof.sol | 31 - .../contracts/cryptography/README.adoc | 9 - .../contracts/drafts/Counters.sol | 38 - .../drafts/ERC1046/ERC20Metadata.sol | 24 - .../contracts/drafts/ERC20Migrator.sol | 103 - .../contracts/drafts/ERC20Snapshot.sol | 142 -- .../contracts/drafts/README.adoc | 23 - .../contracts/drafts/SignedSafeMath.sol | 60 - .../contracts/drafts/Strings.sol | 32 - .../contracts/drafts/TokenVesting.sol | 174 -- .../contracts/introspection/ERC165.sol | 52 - .../contracts/introspection/ERC165Checker.sol | 104 - .../introspection/ERC1820Implementer.sol | 35 - .../contracts/introspection/IERC165.sol | 22 - .../introspection/IERC1820Implementer.sol | 17 - .../introspection/IERC1820Registry.sol | 109 - .../contracts/introspection/README.adoc | 28 - .../contracts/lifecycle/Pausable.sol | 74 - .../contracts/lifecycle/README.adoc | 5 - .../@openzeppelin/contracts/math/Math.sol | 29 - .../@openzeppelin/contracts/math/README.adoc | 9 - .../@openzeppelin/contracts/math/SafeMath.sol | 156 -- .../contracts/ownership/Ownable.sol | 77 - .../contracts/ownership/README.adoc | 11 - .../contracts/ownership/Secondary.sol | 50 - .../@openzeppelin/contracts/package.json | 32 - .../contracts/payment/PaymentSplitter.sol | 132 -- .../contracts/payment/PullPayment.sol | 81 - .../contracts/payment/README.adoc | 17 - .../payment/escrow/ConditionalEscrow.sol | 22 - .../contracts/payment/escrow/Escrow.sol | 83 - .../contracts/payment/escrow/RefundEscrow.sol | 92 - .../contracts/token/ERC20/ERC20.sol | 230 -- .../contracts/token/ERC20/ERC20Burnable.sol | 27 - .../contracts/token/ERC20/ERC20Capped.sol | 38 - .../contracts/token/ERC20/ERC20Detailed.sol | 54 - .../contracts/token/ERC20/ERC20Mintable.sol | 24 - .../contracts/token/ERC20/ERC20Pausable.sol | 34 - .../contracts/token/ERC20/IERC20.sol | 76 - .../contracts/token/ERC20/README.adoc | 50 - .../contracts/token/ERC20/SafeERC20.sol | 75 - .../contracts/token/ERC20/TokenTimelock.sol | 67 - .../contracts/token/ERC721/ERC721.sol | 366 ---- .../contracts/token/ERC721/ERC721Burnable.sol | 20 - .../token/ERC721/ERC721Enumerable.sol | 200 -- .../contracts/token/ERC721/ERC721Full.sol | 18 - .../contracts/token/ERC721/ERC721Holder.sol | 9 - .../contracts/token/ERC721/ERC721Metadata.sol | 129 -- .../token/ERC721/ERC721MetadataMintable.sol | 24 - .../contracts/token/ERC721/ERC721Mintable.sol | 44 - .../contracts/token/ERC721/ERC721Pausable.sol | 22 - .../contracts/token/ERC721/IERC721.sol | 53 - .../token/ERC721/IERC721Enumerable.sol | 14 - .../contracts/token/ERC721/IERC721Full.sol | 13 - .../token/ERC721/IERC721Metadata.sol | 13 - .../token/ERC721/IERC721Receiver.sol | 25 - .../contracts/token/ERC721/README.adoc | 55 - .../contracts/token/ERC777/ERC777.sol | 479 ----- .../contracts/token/ERC777/IERC777.sol | 186 -- .../token/ERC777/IERC777Recipient.sol | 32 - .../contracts/token/ERC777/IERC777Sender.sol | 32 - .../contracts/token/ERC777/README.adoc | 20 - .../@openzeppelin/contracts/utils/Address.sol | 70 - .../@openzeppelin/contracts/utils/Arrays.sol | 45 - .../@openzeppelin/contracts/utils/Create2.sol | 49 - .../contracts/utils/EnumerableSet.sol | 138 -- .../@openzeppelin/contracts/utils/README.adoc | 17 - .../contracts/utils/ReentrancyGuard.sol | 55 - .../contracts/utils/SafeCast.sol | 97 - src/package-lock.json | 24 - src/package.json | 5 - src/python/.flake8 | 4 - src/python/.gitignore | 2 - src/python/Makefile | 85 - src/python/README.md | 1 - src/python/__init__.py | 0 src/python/fastapi.yml | 18 - src/python/honeybadgerswap/__init__.py | 0 src/python/honeybadgerswap/client/Client.py | 123 -- src/python/honeybadgerswap/client/__init__.py | 1 - .../honeybadgerswap/client/req_balance.py | 18 - .../honeybadgerswap/client/req_inputmasks.py | 31 - .../honeybadgerswap/client/req_price.py | 17 - src/python/honeybadgerswap/server/Server.py | 136 -- src/python/honeybadgerswap/server/__init__.py | 1 - .../server/add_liquidity_org_data.py | 42 - .../server/add_liquidity_set_data.py | 50 - .../server/calc_batch_price_org_data.py | 28 - .../server/calc_batch_price_set_data.py | 32 - .../server/calc_individual_price_org_data.py | 40 - .../server/calc_individual_price_set_data.py | 33 - src/python/honeybadgerswap/server/config.py | 34 - .../server/init_pool_org_data.py | 56 - .../server/init_pool_set_data.py | 34 - src/python/honeybadgerswap/server/main.py | 122 -- .../honeybadgerswap/server/proc_inputmask.py | 27 - .../server/remove_liquidity_org_data.py | 47 - .../server/remove_liquidity_set_data.py | 45 - .../honeybadgerswap/server/secret_deposit.py | 24 - .../server/secret_withdraw_org_data.py | 32 - .../server/secret_withdraw_set_data.py | 27 - .../honeybadgerswap/server/set_price_zero.py | 22 - .../honeybadgerswap/server/start_server.py | 16 - .../honeybadgerswap/server/trade_org_data.py | 45 - .../honeybadgerswap/server/trade_set_data.py | 43 - .../server/trade_update_balance.py | 23 - src/python/honeybadgerswap/utils.py | 159 -- src/python/pyproject.toml | 3 - src/python/setup.cfg | 46 - src/python/setup.py | 3 - src/python/tests/__init__.py | 0 src/python/tests/check.py | 41 - src/python/tests/debug.sh | 22 - src/python/tests/debug_trade.sh | 11 - src/python/tests/inputmask.sh | 8 - src/python/tests/set_data.py | 21 - src/python/tests/test.py | 23 - src/truffle-config.js | 99 - 186 files changed, 16240 deletions(-) delete mode 100644 src/contracts/FlattenedHbSwap.sol delete mode 100644 src/contracts/FlattenedHbSwapToken.sol delete mode 100644 src/contracts/HbSwap.sol delete mode 100644 src/contracts/HbSwapToken.sol delete mode 100644 src/genfiles/HbSwap.abi delete mode 100644 src/genfiles/HbSwap.bin delete mode 100644 src/genfiles/HbSwapToken.abi delete mode 100644 src/genfiles/HbSwapToken.bin delete mode 100644 src/go/client/add_liquidity.go delete mode 100644 src/go/client/deposit.go delete mode 100644 src/go/client/init_pool.go delete mode 100644 src/go/client/lib/confparse.go delete mode 100644 src/go/client/remove_liquidity.go delete mode 100644 src/go/client/secret_deposit.go delete mode 100644 src/go/client/secret_withdraw.go delete mode 100644 src/go/client/testnet.go delete mode 100644 src/go/client/trade.go delete mode 100644 src/go/client/withdraw.go delete mode 100644 src/go/deploy/deploy.go delete mode 100644 src/go/reset/reset.go delete mode 100644 src/go/server/lib/confparse.go delete mode 100644 src/go/server/server.go delete mode 100644 src/go/utils/utils.go delete mode 100644 src/go/utils/utils_eth.go delete mode 100644 src/go/utils/utils_hbswap.go delete mode 100644 src/go/utils/utils_pq.go delete mode 100644 src/go/utils/utils_token.go delete mode 100644 src/go_bindings/hbSwapToken/hbSwapToken.go delete mode 100644 src/go_bindings/hbswap/hbswap.go delete mode 100644 src/mpc/hbswap_add_liquidity.mpc delete mode 100644 src/mpc/hbswap_calc_batch_price.mpc delete mode 100644 src/mpc/hbswap_calc_individual_price.mpc delete mode 100644 src/mpc/hbswap_init_pool.mpc delete mode 100644 src/mpc/hbswap_remove_liquidity.mpc delete mode 100644 src/mpc/hbswap_secret_withdraw.mpc delete mode 100644 src/mpc/hbswap_trade.mpc delete mode 100644 src/node_modules/.package-lock.json delete mode 100644 src/node_modules/@openzeppelin/contracts/GSN/Context.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/GSN/GSNRecipient.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/GSN/GSNRecipientERC20Fee.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/GSN/GSNRecipientSignature.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/GSN/IRelayHub.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/GSN/IRelayRecipient.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/GSN/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/README.md delete mode 100644 src/node_modules/@openzeppelin/contracts/access/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/access/Roles.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/access/roles/CapperRole.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/access/roles/MinterRole.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/access/roles/PauserRole.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/access/roles/SignerRole.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/access/roles/WhitelistAdminRole.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/access/roles/WhitelistedRole.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/Crowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/distribution/FinalizableCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/distribution/RefundableCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/emission/AllowanceCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/emission/MintedCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/validation/CappedCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/validation/PausableCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/validation/TimedCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/crowdsale/validation/WhitelistCrowdsale.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/cryptography/ECDSA.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/cryptography/MerkleProof.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/cryptography/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/drafts/Counters.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/drafts/ERC1046/ERC20Metadata.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/drafts/ERC20Migrator.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/drafts/ERC20Snapshot.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/drafts/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/drafts/SignedSafeMath.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/drafts/Strings.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/drafts/TokenVesting.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/introspection/ERC165.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/introspection/ERC165Checker.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/introspection/ERC1820Implementer.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/introspection/IERC165.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/introspection/IERC1820Implementer.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/introspection/IERC1820Registry.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/introspection/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/lifecycle/Pausable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/lifecycle/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/math/Math.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/math/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/math/SafeMath.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/ownership/Ownable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/ownership/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/ownership/Secondary.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/package.json delete mode 100644 src/node_modules/@openzeppelin/contracts/payment/PaymentSplitter.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/payment/PullPayment.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/payment/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/payment/escrow/ConditionalEscrow.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/payment/escrow/Escrow.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/payment/escrow/RefundEscrow.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Capped.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC20/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC20/SafeERC20.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC20/TokenTimelock.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Burnable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Enumerable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Full.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Holder.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Metadata.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721MetadataMintable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Mintable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Pausable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Full.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC721/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC777/ERC777.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777Sender.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/token/ERC777/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/utils/Address.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/utils/Arrays.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/utils/Create2.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/utils/EnumerableSet.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/utils/README.adoc delete mode 100644 src/node_modules/@openzeppelin/contracts/utils/ReentrancyGuard.sol delete mode 100644 src/node_modules/@openzeppelin/contracts/utils/SafeCast.sol delete mode 100644 src/package-lock.json delete mode 100644 src/package.json delete mode 100644 src/python/.flake8 delete mode 100644 src/python/.gitignore delete mode 100644 src/python/Makefile delete mode 100644 src/python/README.md delete mode 100644 src/python/__init__.py delete mode 100644 src/python/fastapi.yml delete mode 100644 src/python/honeybadgerswap/__init__.py delete mode 100644 src/python/honeybadgerswap/client/Client.py delete mode 100644 src/python/honeybadgerswap/client/__init__.py delete mode 100644 src/python/honeybadgerswap/client/req_balance.py delete mode 100644 src/python/honeybadgerswap/client/req_inputmasks.py delete mode 100644 src/python/honeybadgerswap/client/req_price.py delete mode 100644 src/python/honeybadgerswap/server/Server.py delete mode 100644 src/python/honeybadgerswap/server/__init__.py delete mode 100644 src/python/honeybadgerswap/server/add_liquidity_org_data.py delete mode 100644 src/python/honeybadgerswap/server/add_liquidity_set_data.py delete mode 100644 src/python/honeybadgerswap/server/calc_batch_price_org_data.py delete mode 100644 src/python/honeybadgerswap/server/calc_batch_price_set_data.py delete mode 100644 src/python/honeybadgerswap/server/calc_individual_price_org_data.py delete mode 100644 src/python/honeybadgerswap/server/calc_individual_price_set_data.py delete mode 100644 src/python/honeybadgerswap/server/config.py delete mode 100644 src/python/honeybadgerswap/server/init_pool_org_data.py delete mode 100644 src/python/honeybadgerswap/server/init_pool_set_data.py delete mode 100644 src/python/honeybadgerswap/server/main.py delete mode 100644 src/python/honeybadgerswap/server/proc_inputmask.py delete mode 100644 src/python/honeybadgerswap/server/remove_liquidity_org_data.py delete mode 100644 src/python/honeybadgerswap/server/remove_liquidity_set_data.py delete mode 100644 src/python/honeybadgerswap/server/secret_deposit.py delete mode 100644 src/python/honeybadgerswap/server/secret_withdraw_org_data.py delete mode 100644 src/python/honeybadgerswap/server/secret_withdraw_set_data.py delete mode 100644 src/python/honeybadgerswap/server/set_price_zero.py delete mode 100644 src/python/honeybadgerswap/server/start_server.py delete mode 100644 src/python/honeybadgerswap/server/trade_org_data.py delete mode 100644 src/python/honeybadgerswap/server/trade_set_data.py delete mode 100644 src/python/honeybadgerswap/server/trade_update_balance.py delete mode 100644 src/python/honeybadgerswap/utils.py delete mode 100644 src/python/pyproject.toml delete mode 100644 src/python/setup.cfg delete mode 100644 src/python/setup.py delete mode 100644 src/python/tests/__init__.py delete mode 100644 src/python/tests/check.py delete mode 100755 src/python/tests/debug.sh delete mode 100755 src/python/tests/debug_trade.sh delete mode 100755 src/python/tests/inputmask.sh delete mode 100644 src/python/tests/set_data.py delete mode 100644 src/python/tests/test.py delete mode 100644 src/truffle-config.js diff --git a/src/contracts/FlattenedHbSwap.sol b/src/contracts/FlattenedHbSwap.sol deleted file mode 100644 index cd0f0253..00000000 --- a/src/contracts/FlattenedHbSwap.sol +++ /dev/null @@ -1,591 +0,0 @@ -// File: @openzeppelin/contracts/math/SafeMath.sol - -pragma solidity ^0.5.0; - -/** - * @dev Wrappers over Solidity's arithmetic operations with added overflow - * checks. - * - * Arithmetic operations in Solidity wrap on overflow. This can easily result - * in bugs, because programmers usually assume that an overflow raises an - * error, which is the standard behavior in high level programming languages. - * `SafeMath` restores this intuition by reverting the transaction when an - * operation overflows. - * - * Using this library instead of the unchecked operations eliminates an entire - * class of bugs, so it's recommended to use it always. - */ -library SafeMath { - /** - * @dev Returns the addition of two unsigned integers, reverting on - * overflow. - * - * Counterpart to Solidity's `+` operator. - * - * Requirements: - * - Addition cannot overflow. - */ - function add(uint256 a, uint256 b) internal pure returns (uint256) { - uint256 c = a + b; - require(c >= a, "SafeMath: addition overflow"); - - return c; - } - - /** - * @dev Returns the subtraction of two unsigned integers, reverting on - * overflow (when the result is negative). - * - * Counterpart to Solidity's `-` operator. - * - * Requirements: - * - Subtraction cannot overflow. - */ - function sub(uint256 a, uint256 b) internal pure returns (uint256) { - return sub(a, b, "SafeMath: subtraction overflow"); - } - - /** - * @dev Returns the subtraction of two unsigned integers, reverting with custom message on - * overflow (when the result is negative). - * - * Counterpart to Solidity's `-` operator. - * - * Requirements: - * - Subtraction cannot overflow. - * - * _Available since v2.4.0._ - */ - function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - require(b <= a, errorMessage); - uint256 c = a - b; - - return c; - } - - /** - * @dev Returns the multiplication of two unsigned integers, reverting on - * overflow. - * - * Counterpart to Solidity's `*` operator. - * - * Requirements: - * - Multiplication cannot overflow. - */ - function mul(uint256 a, uint256 b) internal pure returns (uint256) { - // Gas optimization: this is cheaper than requiring 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 - if (a == 0) { - return 0; - } - - uint256 c = a * b; - require(c / a == b, "SafeMath: multiplication overflow"); - - return c; - } - - /** - * @dev Returns the integer division of two unsigned integers. Reverts on - * division by zero. The result is rounded towards zero. - * - * Counterpart to Solidity's `/` operator. Note: this function uses a - * `revert` opcode (which leaves remaining gas untouched) while Solidity - * uses an invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - */ - function div(uint256 a, uint256 b) internal pure returns (uint256) { - return div(a, b, "SafeMath: division by zero"); - } - - /** - * @dev Returns the integer division of two unsigned integers. Reverts with custom message on - * division by zero. The result is rounded towards zero. - * - * Counterpart to Solidity's `/` operator. Note: this function uses a - * `revert` opcode (which leaves remaining gas untouched) while Solidity - * uses an invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - * - * _Available since v2.4.0._ - */ - function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - // Solidity only automatically asserts when dividing by 0 - require(b > 0, errorMessage); - uint256 c = a / b; - // assert(a == b * c + a % b); // There is no case in which this doesn't hold - - return c; - } - - /** - * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), - * Reverts when dividing by zero. - * - * Counterpart to Solidity's `%` operator. This function uses a `revert` - * opcode (which leaves remaining gas untouched) while Solidity uses an - * invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - */ - function mod(uint256 a, uint256 b) internal pure returns (uint256) { - return mod(a, b, "SafeMath: modulo by zero"); - } - - /** - * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), - * Reverts with custom message when dividing by zero. - * - * Counterpart to Solidity's `%` operator. This function uses a `revert` - * opcode (which leaves remaining gas untouched) while Solidity uses an - * invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - * - * _Available since v2.4.0._ - */ - function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - require(b != 0, errorMessage); - return a % b; - } -} - -// File: @openzeppelin/contracts/token/ERC20/IERC20.sol - -pragma solidity ^0.5.0; - -/** - * @dev Interface of the ERC20 standard as defined in the EIP. Does not include - * the optional functions; to access them see {ERC20Detailed}. - */ -interface IERC20 { - /** - * @dev Returns the amount of tokens in existence. - */ - function totalSupply() external view returns (uint256); - - /** - * @dev Returns the amount of tokens owned by `account`. - */ - function balanceOf(address account) external view returns (uint256); - - /** - * @dev Moves `amount` tokens from the caller's account to `recipient`. - * - * Returns a boolean value indicating whether the operation succeeded. - * - * Emits a {Transfer} event. - */ - function transfer(address recipient, uint256 amount) external returns (bool); - - /** - * @dev Returns the remaining number of tokens that `spender` will be - * allowed to spend on behalf of `owner` through {transferFrom}. This is - * zero by default. - * - * This value changes when {approve} or {transferFrom} are called. - */ - function allowance(address owner, address spender) external view returns (uint256); - - /** - * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. - * - * Returns a boolean value indicating whether the operation succeeded. - * - * IMPORTANT: Beware that changing an allowance with this method brings the risk - * that someone may use both the old and the new allowance by unfortunate - * transaction ordering. One possible solution to mitigate this race - * condition is to first reduce the spender's allowance to 0 and set the - * desired value afterwards: - * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - * - * Emits an {Approval} event. - */ - function approve(address spender, uint256 amount) external returns (bool); - - /** - * @dev Moves `amount` tokens from `sender` to `recipient` using the - * allowance mechanism. `amount` is then deducted from the caller's - * allowance. - * - * Returns a boolean value indicating whether the operation succeeded. - * - * Emits a {Transfer} event. - */ - function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); - - /** - * @dev Emitted when `value` tokens are moved from one account (`from`) to - * another (`to`). - * - * Note that `value` may be zero. - */ - event Transfer(address indexed from, address indexed to, uint256 value); - - /** - * @dev Emitted when the allowance of a `spender` for an `owner` is set by - * a call to {approve}. `value` is the new allowance. - */ - event Approval(address indexed owner, address indexed spender, uint256 value); -} - -// File: @openzeppelin/contracts/utils/Address.sol - -pragma solidity ^0.5.5; - -/** - * @dev Collection of functions related to the address type - */ -library Address { - /** - * @dev Returns true if `account` is a contract. - * - * [IMPORTANT] - * ==== - * It is unsafe to assume that an address for which this function returns - * false is an externally-owned account (EOA) and not a contract. - * - * Among others, `isContract` will return false for the following - * types of addresses: - * - * - an externally-owned account - * - a contract in construction - * - an address where a contract will be created - * - an address where a contract lived, but was destroyed - * ==== - */ - function isContract(address account) internal view returns (bool) { - // According to EIP-1052, 0x0 is the value returned for not-yet created accounts - // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned - // for accounts without code, i.e. `keccak256('')` - bytes32 codehash; - bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; - // solhint-disable-next-line no-inline-assembly - assembly { codehash := extcodehash(account) } - return (codehash != accountHash && codehash != 0x0); - } - - /** - * @dev Converts an `address` into `address payable`. Note that this is - * simply a type cast: the actual underlying value is not changed. - * - * _Available since v2.4.0._ - */ - function toPayable(address account) internal pure returns (address payable) { - return address(uint160(account)); - } - - /** - * @dev Replacement for Solidity's `transfer`: sends `amount` wei to - * `recipient`, forwarding all available gas and reverting on errors. - * - * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost - * of certain opcodes, possibly making contracts go over the 2300 gas limit - * imposed by `transfer`, making them unable to receive funds via - * `transfer`. {sendValue} removes this limitation. - * - * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. - * - * IMPORTANT: because control is transferred to `recipient`, care must be - * taken to not create reentrancy vulnerabilities. Consider using - * {ReentrancyGuard} or the - * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. - * - * _Available since v2.4.0._ - */ - function sendValue(address payable recipient, uint256 amount) internal { - require(address(this).balance >= amount, "Address: insufficient balance"); - - // solhint-disable-next-line avoid-call-value - (bool success, ) = recipient.call.value(amount)(""); - require(success, "Address: unable to send value, recipient may have reverted"); - } -} - -// File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol - -pragma solidity ^0.5.0; - - - - -/** - * @title SafeERC20 - * @dev Wrappers around ERC20 operations that throw on failure (when the token - * contract returns false). Tokens that return no value (and instead revert or - * throw on failure) are also supported, non-reverting calls are assumed to be - * successful. - * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, - * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. - */ -library SafeERC20 { - using SafeMath for uint256; - using Address for address; - - function safeTransfer(IERC20 token, address to, uint256 value) internal { - callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); - } - - function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { - callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); - } - - function safeApprove(IERC20 token, address spender, uint256 value) internal { - // safeApprove should only be called when setting an initial allowance, - // or when resetting it to zero. To increase and decrease it, use - // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' - // solhint-disable-next-line max-line-length - require((value == 0) || (token.allowance(address(this), spender) == 0), - "SafeERC20: approve from non-zero to non-zero allowance" - ); - callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); - } - - function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { - uint256 newAllowance = token.allowance(address(this), spender).add(value); - callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); - } - - function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { - uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); - callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); - } - - /** - * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement - * on the return value: the return value is optional (but if data is returned, it must not be false). - * @param token The token targeted by the call. - * @param data The call data (encoded using abi.encode or one of its variants). - */ - function callOptionalReturn(IERC20 token, bytes memory data) private { - // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since - // we're implementing it ourselves. - - // A Solidity high level call has three parts: - // 1. The target address is checked to verify it contains contract code - // 2. The call itself is made, and success asserted - // 3. The return value is decoded, which in turn checks the size of the returned data. - // solhint-disable-next-line max-line-length - require(address(token).isContract(), "SafeERC20: call to non-contract"); - - // solhint-disable-next-line avoid-low-level-calls - (bool success, bytes memory returndata) = address(token).call(data); - require(success, "SafeERC20: low-level call failed"); - - if (returndata.length > 0) { // Return data is optional - // solhint-disable-next-line max-line-length - require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); - } - } -} - -// File: contracts/HbSwap.sol - -pragma solidity ^0.5.0; - - - - -contract HbSwap { - using SafeMath for uint; - using SafeERC20 for IERC20; - - event InputMask(uint[] inpusMaskIndexes); - event SecretDeposit(address token, address user, uint amt); - event SecretWithdraw(uint seq, address token, address user, uint amt); - event InitPool(address user, address tokenA, address tokenB, uint amtA, uint amtB); - event AddLiquidity(address user, address tokenA, address tokenB, uint idxA, uint idxB, uint maskedAmtA, uint maskedAmtB); - event RemoveLiquidity(address user, address tokenA, address tokenB, uint idx, uint maskedAmt); - event Trade(uint tradeSeq, address user, address tokenA, address tokenB, uint idxA, uint idxB, uint maskedAmtA, uint maskedAmtB); - - struct SecretWithdrawIntention { - address token; - address user; - uint amt; - } - - uint constant public Decimals = 10**15; - uint constant public Fp = 2**16; - - address owner; - - uint public threshold; - mapping (address => bool) public servers; - - mapping (address => mapping(address => uint)) public publicBalance; - - uint public secretWithdrawCnt; - mapping (uint => SecretWithdrawIntention) public secretWithdrawMap; - mapping (uint => mapping (address => bool)) public consentRecord; - mapping (uint => uint) consentCounter; - mapping (uint => bool) expired; - - uint public inputmaskCnt; - mapping (uint => address) public inputMaskOwner; - - uint public tradeCnt; - - mapping (address => mapping (address => string)) public prices; - mapping (address => mapping (address => uint)) public lastUpdateSeq; - mapping (address => mapping (address => mapping (uint => mapping (string => uint)))) proposalCnt; - mapping (address => mapping (address => mapping (uint => mapping (address => bool)))) propose; - - constructor(address[] memory _servers, uint _threshold) public { - owner = msg.sender; - for (uint i = 0; i < _servers.length; i++) { - servers[_servers[i]] = true; - } - threshold = _threshold; - } - - function publicDeposit(address _token, uint _amt) payable public { - address user = msg.sender; - require(_amt > 0, "invalid amount"); - - if (_token == address(0x0)) { - require(msg.value * Fp == _amt * Decimals, "amounts not match" ); - } else { - IERC20 token = IERC20(_token); - token.safeTransferFrom(user, address(this), _amt / Fp * Decimals); - } - publicBalance[_token][user] += _amt; - } - - function secretDeposit(address _token, uint _amt) public { - address user = msg.sender; - - require(_amt > 0 && publicBalance[_token][user] >= _amt, "invalid amount"); - publicBalance[_token][user] -= _amt; - - emit SecretDeposit(_token, user, _amt); - } - - function secretWithdraw(address _token, uint _amt) public { - address user = msg.sender; - require(_amt > 0, "invalid amount"); - - secretWithdrawCnt += 1; - secretWithdrawMap[secretWithdrawCnt] = SecretWithdrawIntention(_token, user, _amt); - - emit SecretWithdraw(secretWithdrawCnt, _token, user, _amt); - } - - function consent(uint _seq) public { - address server = msg.sender; - - require(servers[server], "not a valid server"); - require(!consentRecord[_seq][server], "already consent"); - consentRecord[_seq][server] = true; - - consentCounter[_seq] += 1; - if (consentCounter[_seq] > threshold && !expired[_seq]) { - SecretWithdrawIntention memory secretWithdrawIntention = secretWithdrawMap[_seq]; - publicBalance[secretWithdrawIntention.token][secretWithdrawIntention.user] += secretWithdrawIntention.amt; - expired[_seq] = true; - } - } - - function publicWithdraw(address _token, uint _amt) public { - address payable user = msg.sender; - require(_amt > 0 && publicBalance[_token][user] >= _amt, "invalid amount"); - - if (_token == address(0x0)) { - user.transfer(_amt / Fp * Decimals); - } else { - IERC20 token = IERC20(_token); - token.safeTransfer(user, _amt / Fp * Decimals); - } - publicBalance[_token][user] -= _amt; - } - - function reserveInput(uint _num) public { - address user = msg.sender; - uint[] memory inputMaskIndexes = new uint[](_num); - - for (uint i = 0; i < _num; i++) { - uint inputMaskIdx = inputmaskCnt++; - inputMaskOwner[inputMaskIdx] = user; - inputMaskIndexes[i] = inputMaskIdx; - } - - emit InputMask(inputMaskIndexes); - } - - function initPool(address _tokenA, address _tokenB, uint _amtA, uint _amtB) public { - require(_tokenA < _tokenB, "invalid trading pair"); - require(_amtA > 0 && _amtB > 0, "invalid amount"); - - address user = msg.sender; - - emit InitPool(msg.sender, _tokenA, _tokenB, _amtA, _amtB); - } - - function addLiquidity(address _tokenA, address _tokenB, uint _idxA, uint _idxB, uint _maskedAmtA, uint _maskedAmtB) public { - require(_tokenA < _tokenB, "invalid trading pair"); - - address user = msg.sender; - require(inputMaskOwner[_idxA] == user, "unauthorized inputmask"); - require(inputMaskOwner[_idxB] == user, "unauthorized inputmask"); - - emit AddLiquidity(user, _tokenA, _tokenB, _idxA, _idxB, _maskedAmtA, _maskedAmtB); - } - - function removeLiquidity(address _tokenA, address _tokenB, uint _idx, uint _maskedAmt) public { - require(_tokenA < _tokenB, "invalid trading pair"); - - address user = msg.sender; - require(inputMaskOwner[_idx] == user, "unauthorized inputmask"); - - emit RemoveLiquidity(user, _tokenA, _tokenB, _idx, _maskedAmt); - } - - function trade(address _tokenA, address _tokenB, uint _idxA, uint _idxB, uint _maskedA, uint _maskedB) public { - require(_tokenA < _tokenB, "invalid trading pair"); - - address user = msg.sender; - require(inputMaskOwner[_idxA] == user, "unauthorized inputmask"); - require(inputMaskOwner[_idxB] == user, "unauthorized inputmask"); - - tradeCnt += 1; - emit Trade(tradeCnt, user, _tokenA, _tokenB, _idxA, _idxB, _maskedA, _maskedB); - } - - function updatePrice(address _tokenA, address _tokenB, uint _checkpointSeq, string memory _price) public { - address server = msg.sender; - require(servers[server], "not a valid server"); - - if (!propose[_tokenA][_tokenB][_checkpointSeq][server] || _checkpointSeq == 0) { - propose[_tokenA][_tokenB][_checkpointSeq][server] = true; - proposalCnt[_tokenA][_tokenB][_checkpointSeq][_price] += 1; - - if (proposalCnt[_tokenA][_tokenB][_checkpointSeq][_price] > threshold && _checkpointSeq >= lastUpdateSeq[_tokenA][_tokenB]) { - prices[_tokenA][_tokenB] = _price; - lastUpdateSeq[_tokenA][_tokenB] = _checkpointSeq; - } - } - } - - function resetPrice(address _tokenA, address _tokenB, address[] memory _servers) public { - require(msg.sender == owner); - - prices[_tokenA][_tokenB] = ""; - lastUpdateSeq[_tokenA][_tokenB] = 0; - for (uint i = 0; i < _servers.length; i++) { - propose[_tokenA][_tokenB][0][_servers[i]] = false; - } - proposalCnt[_tokenA][_tokenB][0]["0.0"] = 0; - } - - function resetBalance(address _token, address _user) public { - require(msg.sender == owner); - - publicBalance[_token][_user] = 0; - } -} diff --git a/src/contracts/FlattenedHbSwapToken.sol b/src/contracts/FlattenedHbSwapToken.sol deleted file mode 100644 index eae60940..00000000 --- a/src/contracts/FlattenedHbSwapToken.sol +++ /dev/null @@ -1,570 +0,0 @@ -// File: @openzeppelin/contracts/GSN/Context.sol - -pragma solidity ^0.5.0; - -/* - * @dev Provides information about the current execution context, including the - * sender of the transaction and its data. While these are generally available - * via msg.sender and msg.data, they should not be accessed in such a direct - * manner, since when dealing with GSN meta-transactions the account sending and - * paying for execution may not be the actual sender (as far as an application - * is concerned). - * - * This contract is only required for intermediate, library-like contracts. - */ -contract Context { - // Empty internal constructor, to prevent people from mistakenly deploying - // an instance of this contract, which should be used via inheritance. - constructor () internal { } - // solhint-disable-previous-line no-empty-blocks - - function _msgSender() internal view returns (address payable) { - return msg.sender; - } - - function _msgData() internal view returns (bytes memory) { - this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 - return msg.data; - } -} - -// File: @openzeppelin/contracts/token/ERC20/IERC20.sol - -pragma solidity ^0.5.0; - -/** - * @dev Interface of the ERC20 standard as defined in the EIP. Does not include - * the optional functions; to access them see {ERC20Detailed}. - */ -interface IERC20 { - /** - * @dev Returns the amount of tokens in existence. - */ - function totalSupply() external view returns (uint256); - - /** - * @dev Returns the amount of tokens owned by `account`. - */ - function balanceOf(address account) external view returns (uint256); - - /** - * @dev Moves `amount` tokens from the caller's account to `recipient`. - * - * Returns a boolean value indicating whether the operation succeeded. - * - * Emits a {Transfer} event. - */ - function transfer(address recipient, uint256 amount) external returns (bool); - - /** - * @dev Returns the remaining number of tokens that `spender` will be - * allowed to spend on behalf of `owner` through {transferFrom}. This is - * zero by default. - * - * This value changes when {approve} or {transferFrom} are called. - */ - function allowance(address owner, address spender) external view returns (uint256); - - /** - * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. - * - * Returns a boolean value indicating whether the operation succeeded. - * - * IMPORTANT: Beware that changing an allowance with this method brings the risk - * that someone may use both the old and the new allowance by unfortunate - * transaction ordering. One possible solution to mitigate this race - * condition is to first reduce the spender's allowance to 0 and set the - * desired value afterwards: - * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - * - * Emits an {Approval} event. - */ - function approve(address spender, uint256 amount) external returns (bool); - - /** - * @dev Moves `amount` tokens from `sender` to `recipient` using the - * allowance mechanism. `amount` is then deducted from the caller's - * allowance. - * - * Returns a boolean value indicating whether the operation succeeded. - * - * Emits a {Transfer} event. - */ - function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); - - /** - * @dev Emitted when `value` tokens are moved from one account (`from`) to - * another (`to`). - * - * Note that `value` may be zero. - */ - event Transfer(address indexed from, address indexed to, uint256 value); - - /** - * @dev Emitted when the allowance of a `spender` for an `owner` is set by - * a call to {approve}. `value` is the new allowance. - */ - event Approval(address indexed owner, address indexed spender, uint256 value); -} - -// File: @openzeppelin/contracts/math/SafeMath.sol - -pragma solidity ^0.5.0; - -/** - * @dev Wrappers over Solidity's arithmetic operations with added overflow - * checks. - * - * Arithmetic operations in Solidity wrap on overflow. This can easily result - * in bugs, because programmers usually assume that an overflow raises an - * error, which is the standard behavior in high level programming languages. - * `SafeMath` restores this intuition by reverting the transaction when an - * operation overflows. - * - * Using this library instead of the unchecked operations eliminates an entire - * class of bugs, so it's recommended to use it always. - */ -library SafeMath { - /** - * @dev Returns the addition of two unsigned integers, reverting on - * overflow. - * - * Counterpart to Solidity's `+` operator. - * - * Requirements: - * - Addition cannot overflow. - */ - function add(uint256 a, uint256 b) internal pure returns (uint256) { - uint256 c = a + b; - require(c >= a, "SafeMath: addition overflow"); - - return c; - } - - /** - * @dev Returns the subtraction of two unsigned integers, reverting on - * overflow (when the result is negative). - * - * Counterpart to Solidity's `-` operator. - * - * Requirements: - * - Subtraction cannot overflow. - */ - function sub(uint256 a, uint256 b) internal pure returns (uint256) { - return sub(a, b, "SafeMath: subtraction overflow"); - } - - /** - * @dev Returns the subtraction of two unsigned integers, reverting with custom message on - * overflow (when the result is negative). - * - * Counterpart to Solidity's `-` operator. - * - * Requirements: - * - Subtraction cannot overflow. - * - * _Available since v2.4.0._ - */ - function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - require(b <= a, errorMessage); - uint256 c = a - b; - - return c; - } - - /** - * @dev Returns the multiplication of two unsigned integers, reverting on - * overflow. - * - * Counterpart to Solidity's `*` operator. - * - * Requirements: - * - Multiplication cannot overflow. - */ - function mul(uint256 a, uint256 b) internal pure returns (uint256) { - // Gas optimization: this is cheaper than requiring 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 - if (a == 0) { - return 0; - } - - uint256 c = a * b; - require(c / a == b, "SafeMath: multiplication overflow"); - - return c; - } - - /** - * @dev Returns the integer division of two unsigned integers. Reverts on - * division by zero. The result is rounded towards zero. - * - * Counterpart to Solidity's `/` operator. Note: this function uses a - * `revert` opcode (which leaves remaining gas untouched) while Solidity - * uses an invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - */ - function div(uint256 a, uint256 b) internal pure returns (uint256) { - return div(a, b, "SafeMath: division by zero"); - } - - /** - * @dev Returns the integer division of two unsigned integers. Reverts with custom message on - * division by zero. The result is rounded towards zero. - * - * Counterpart to Solidity's `/` operator. Note: this function uses a - * `revert` opcode (which leaves remaining gas untouched) while Solidity - * uses an invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - * - * _Available since v2.4.0._ - */ - function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - // Solidity only automatically asserts when dividing by 0 - require(b > 0, errorMessage); - uint256 c = a / b; - // assert(a == b * c + a % b); // There is no case in which this doesn't hold - - return c; - } - - /** - * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), - * Reverts when dividing by zero. - * - * Counterpart to Solidity's `%` operator. This function uses a `revert` - * opcode (which leaves remaining gas untouched) while Solidity uses an - * invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - */ - function mod(uint256 a, uint256 b) internal pure returns (uint256) { - return mod(a, b, "SafeMath: modulo by zero"); - } - - /** - * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), - * Reverts with custom message when dividing by zero. - * - * Counterpart to Solidity's `%` operator. This function uses a `revert` - * opcode (which leaves remaining gas untouched) while Solidity uses an - * invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - * - * _Available since v2.4.0._ - */ - function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - require(b != 0, errorMessage); - return a % b; - } -} - -// File: @openzeppelin/contracts/token/ERC20/ERC20.sol - -pragma solidity ^0.5.0; - - - - -/** - * @dev Implementation of the {IERC20} interface. - * - * This implementation is agnostic to the way tokens are created. This means - * that a supply mechanism has to be added in a derived contract using {_mint}. - * For a generic mechanism see {ERC20Mintable}. - * - * TIP: For a detailed writeup see our guide - * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How - * to implement supply mechanisms]. - * - * We have followed general OpenZeppelin guidelines: functions revert instead - * of returning `false` on failure. This behavior is nonetheless conventional - * and does not conflict with the expectations of ERC20 applications. - * - * Additionally, an {Approval} event is emitted on calls to {transferFrom}. - * This allows applications to reconstruct the allowance for all accounts just - * by listening to said events. Other implementations of the EIP may not emit - * these events, as it isn't required by the specification. - * - * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} - * functions have been added to mitigate the well-known issues around setting - * allowances. See {IERC20-approve}. - */ -contract ERC20 is Context, IERC20 { - using SafeMath for uint256; - - mapping (address => uint256) private _balances; - - mapping (address => mapping (address => uint256)) private _allowances; - - uint256 private _totalSupply; - - /** - * @dev See {IERC20-totalSupply}. - */ - function totalSupply() public view returns (uint256) { - return _totalSupply; - } - - /** - * @dev See {IERC20-balanceOf}. - */ - function balanceOf(address account) public view returns (uint256) { - return _balances[account]; - } - - /** - * @dev See {IERC20-transfer}. - * - * Requirements: - * - * - `recipient` cannot be the zero address. - * - the caller must have a balance of at least `amount`. - */ - function transfer(address recipient, uint256 amount) public returns (bool) { - _transfer(_msgSender(), recipient, amount); - return true; - } - - /** - * @dev See {IERC20-allowance}. - */ - function allowance(address owner, address spender) public view returns (uint256) { - return _allowances[owner][spender]; - } - - /** - * @dev See {IERC20-approve}. - * - * Requirements: - * - * - `spender` cannot be the zero address. - */ - function approve(address spender, uint256 amount) public returns (bool) { - _approve(_msgSender(), spender, amount); - return true; - } - - /** - * @dev See {IERC20-transferFrom}. - * - * Emits an {Approval} event indicating the updated allowance. This is not - * required by the EIP. See the note at the beginning of {ERC20}; - * - * Requirements: - * - `sender` and `recipient` cannot be the zero address. - * - `sender` must have a balance of at least `amount`. - * - the caller must have allowance for `sender`'s tokens of at least - * `amount`. - */ - function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { - _transfer(sender, recipient, amount); - _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); - return true; - } - - /** - * @dev Atomically increases the allowance granted to `spender` by the caller. - * - * This is an alternative to {approve} that can be used as a mitigation for - * problems described in {IERC20-approve}. - * - * Emits an {Approval} event indicating the updated allowance. - * - * Requirements: - * - * - `spender` cannot be the zero address. - */ - function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { - _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); - return true; - } - - /** - * @dev Atomically decreases the allowance granted to `spender` by the caller. - * - * This is an alternative to {approve} that can be used as a mitigation for - * problems described in {IERC20-approve}. - * - * Emits an {Approval} event indicating the updated allowance. - * - * Requirements: - * - * - `spender` cannot be the zero address. - * - `spender` must have allowance for the caller of at least - * `subtractedValue`. - */ - function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { - _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); - return true; - } - - /** - * @dev Moves tokens `amount` from `sender` to `recipient`. - * - * This is internal function is equivalent to {transfer}, and can be used to - * e.g. implement automatic token fees, slashing mechanisms, etc. - * - * Emits a {Transfer} event. - * - * Requirements: - * - * - `sender` cannot be the zero address. - * - `recipient` cannot be the zero address. - * - `sender` must have a balance of at least `amount`. - */ - function _transfer(address sender, address recipient, uint256 amount) internal { - require(sender != address(0), "ERC20: transfer from the zero address"); - require(recipient != address(0), "ERC20: transfer to the zero address"); - - _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); - _balances[recipient] = _balances[recipient].add(amount); - emit Transfer(sender, recipient, amount); - } - - /** @dev Creates `amount` tokens and assigns them to `account`, increasing - * the total supply. - * - * Emits a {Transfer} event with `from` set to the zero address. - * - * Requirements - * - * - `to` cannot be the zero address. - */ - function _mint(address account, uint256 amount) internal { - require(account != address(0), "ERC20: mint to the zero address"); - - _totalSupply = _totalSupply.add(amount); - _balances[account] = _balances[account].add(amount); - emit Transfer(address(0), account, amount); - } - - /** - * @dev Destroys `amount` tokens from `account`, reducing the - * total supply. - * - * Emits a {Transfer} event with `to` set to the zero address. - * - * Requirements - * - * - `account` cannot be the zero address. - * - `account` must have at least `amount` tokens. - */ - function _burn(address account, uint256 amount) internal { - require(account != address(0), "ERC20: burn from the zero address"); - - _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); - _totalSupply = _totalSupply.sub(amount); - emit Transfer(account, address(0), amount); - } - - /** - * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. - * - * This is internal function is equivalent to `approve`, and can be used to - * e.g. set automatic allowances for certain subsystems, etc. - * - * Emits an {Approval} event. - * - * Requirements: - * - * - `owner` cannot be the zero address. - * - `spender` cannot be the zero address. - */ - function _approve(address owner, address spender, uint256 amount) internal { - require(owner != address(0), "ERC20: approve from the zero address"); - require(spender != address(0), "ERC20: approve to the zero address"); - - _allowances[owner][spender] = amount; - emit Approval(owner, spender, amount); - } - - /** - * @dev Destroys `amount` tokens from `account`.`amount` is then deducted - * from the caller's allowance. - * - * See {_burn} and {_approve}. - */ - function _burnFrom(address account, uint256 amount) internal { - _burn(account, amount); - _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); - } -} - -// File: @openzeppelin/contracts/token/ERC20/ERC20Detailed.sol - -pragma solidity ^0.5.0; - - -/** - * @dev Optional functions from the ERC20 standard. - */ -contract ERC20Detailed is IERC20 { - string private _name; - string private _symbol; - uint8 private _decimals; - - /** - * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of - * these values are immutable: they can only be set once during - * construction. - */ - constructor (string memory name, string memory symbol, uint8 decimals) public { - _name = name; - _symbol = symbol; - _decimals = decimals; - } - - /** - * @dev Returns the name of the token. - */ - function name() public view returns (string memory) { - return _name; - } - - /** - * @dev Returns the symbol of the token, usually a shorter version of the - * name. - */ - function symbol() public view returns (string memory) { - return _symbol; - } - - /** - * @dev Returns the number of decimals used to get its user representation. - * For example, if `decimals` equals `2`, a balance of `505` tokens should - * be displayed to a user as `5,05` (`505 / 10 ** 2`). - * - * Tokens usually opt for a value of 18, imitating the relationship between - * Ether and Wei. - * - * NOTE: This information is only used for _display_ purposes: it in - * no way affects any of the arithmetic of the contract, including - * {IERC20-balanceOf} and {IERC20-transfer}. - */ - function decimals() public view returns (uint8) { - return _decimals; - } -} - -// File: contracts/HbSwapToken.sol - -pragma solidity ^0.5.0; - - - -contract HbSwapToken is ERC20, ERC20Detailed { - uint8 public constant DECIMALS = 18; - uint256 public constant INITIAL_SUPPLY = 1e28; - - constructor () public ERC20Detailed("HbSwapToken", "HBS", DECIMALS) { - _mint(msg.sender, INITIAL_SUPPLY); - } -} diff --git a/src/contracts/HbSwap.sol b/src/contracts/HbSwap.sol deleted file mode 100644 index 0f28963c..00000000 --- a/src/contracts/HbSwap.sol +++ /dev/null @@ -1,200 +0,0 @@ -pragma solidity ^0.5.0; - -import "@openzeppelin/contracts/math/SafeMath.sol"; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; - -contract HbSwap { - using SafeMath for uint; - using SafeERC20 for IERC20; - - event InputMask(uint[] inpusMaskIndexes); - event SecretDeposit(address token, address user, uint amt); - event SecretWithdraw(uint seq, address token, address user, uint amt); - event InitPool(address user, address tokenA, address tokenB, uint amtA, uint amtB); - event AddLiquidity(address user, address tokenA, address tokenB, uint idxA, uint idxB, uint maskedAmtA, uint maskedAmtB); - event RemoveLiquidity(address user, address tokenA, address tokenB, uint idx, uint maskedAmt); - event Trade(uint tradeSeq, address user, address tokenA, address tokenB, uint idxA, uint idxB, uint maskedAmtA, uint maskedAmtB); - - struct SecretWithdrawIntention { - address token; - address user; - uint amt; - } - - uint constant public Decimals = 10**15; - uint constant public Fp = 2**16; - - address owner; - - uint public threshold; - mapping (address => bool) public servers; - - mapping (address => mapping(address => uint)) public publicBalance; - - uint public secretWithdrawCnt; - mapping (uint => SecretWithdrawIntention) public secretWithdrawMap; - mapping (uint => mapping (address => bool)) public consentRecord; - mapping (uint => uint) consentCounter; - mapping (uint => bool) expired; - - uint public inputmaskCnt; - mapping (uint => address) public inputMaskOwner; - - uint public tradeCnt; - - mapping (address => mapping (address => string)) public prices; - mapping (address => mapping (address => uint)) public lastUpdateSeq; - mapping (address => mapping (address => mapping (uint => mapping (string => uint)))) proposalCnt; - mapping (address => mapping (address => mapping (uint => mapping (address => bool)))) propose; - - constructor(address[] memory _servers, uint _threshold) public { - owner = msg.sender; - for (uint i = 0; i < _servers.length; i++) { - servers[_servers[i]] = true; - } - threshold = _threshold; - } - - function publicDeposit(address _token, uint _amt) payable public { - address user = msg.sender; - require(_amt > 0, "invalid amount"); - - if (_token == address(0x0)) { - require(msg.value * Fp == _amt * Decimals, "amounts not match" ); - } else { - IERC20 token = IERC20(_token); - token.safeTransferFrom(user, address(this), _amt / Fp * Decimals); - } - publicBalance[_token][user] += _amt; - } - - function secretDeposit(address _token, uint _amt) public { - address user = msg.sender; - - require(_amt > 0 && publicBalance[_token][user] >= _amt, "invalid amount"); - publicBalance[_token][user] -= _amt; - - emit SecretDeposit(_token, user, _amt); - } - - function secretWithdraw(address _token, uint _amt) public { - address user = msg.sender; - require(_amt > 0, "invalid amount"); - - secretWithdrawCnt += 1; - secretWithdrawMap[secretWithdrawCnt] = SecretWithdrawIntention(_token, user, _amt); - - emit SecretWithdraw(secretWithdrawCnt, _token, user, _amt); - } - - function consent(uint _seq) public { - address server = msg.sender; - - require(servers[server], "not a valid server"); - require(!consentRecord[_seq][server], "already consent"); - consentRecord[_seq][server] = true; - - consentCounter[_seq] += 1; - if (consentCounter[_seq] > threshold && !expired[_seq]) { - SecretWithdrawIntention memory secretWithdrawIntention = secretWithdrawMap[_seq]; - publicBalance[secretWithdrawIntention.token][secretWithdrawIntention.user] += secretWithdrawIntention.amt; - expired[_seq] = true; - } - } - - function publicWithdraw(address _token, uint _amt) public { - address payable user = msg.sender; - require(_amt > 0 && publicBalance[_token][user] >= _amt, "invalid amount"); - - if (_token == address(0x0)) { - user.transfer(_amt / Fp * Decimals); - } else { - IERC20 token = IERC20(_token); - token.safeTransfer(user, _amt / Fp * Decimals); - } - publicBalance[_token][user] -= _amt; - } - - function reserveInput(uint _num) public { - address user = msg.sender; - uint[] memory inputMaskIndexes = new uint[](_num); - - for (uint i = 0; i < _num; i++) { - uint inputMaskIdx = inputmaskCnt++; - inputMaskOwner[inputMaskIdx] = user; - inputMaskIndexes[i] = inputMaskIdx; - } - - emit InputMask(inputMaskIndexes); - } - - function initPool(address _tokenA, address _tokenB, uint _amtA, uint _amtB) public { - require(_tokenA < _tokenB, "invalid trading pair"); - require(_amtA > 0 && _amtB > 0, "invalid amount"); - - emit InitPool(msg.sender, _tokenA, _tokenB, _amtA, _amtB); - } - - function addLiquidity(address _tokenA, address _tokenB, uint _idxA, uint _idxB, uint _maskedAmtA, uint _maskedAmtB) public { - require(_tokenA < _tokenB, "invalid trading pair"); - - address user = msg.sender; - require(inputMaskOwner[_idxA] == user, "unauthorized inputmask"); - require(inputMaskOwner[_idxB] == user, "unauthorized inputmask"); - - emit AddLiquidity(user, _tokenA, _tokenB, _idxA, _idxB, _maskedAmtA, _maskedAmtB); - } - - function removeLiquidity(address _tokenA, address _tokenB, uint _idx, uint _maskedAmt) public { - require(_tokenA < _tokenB, "invalid trading pair"); - - address user = msg.sender; - require(inputMaskOwner[_idx] == user, "unauthorized inputmask"); - - emit RemoveLiquidity(user, _tokenA, _tokenB, _idx, _maskedAmt); - } - - function trade(address _tokenA, address _tokenB, uint _idxA, uint _idxB, uint _maskedA, uint _maskedB) public { - require(_tokenA < _tokenB, "invalid trading pair"); - - address user = msg.sender; - require(inputMaskOwner[_idxA] == user, "unauthorized inputmask"); - require(inputMaskOwner[_idxB] == user, "unauthorized inputmask"); - - tradeCnt += 1; - emit Trade(tradeCnt, user, _tokenA, _tokenB, _idxA, _idxB, _maskedA, _maskedB); - } - - function updatePrice(address _tokenA, address _tokenB, uint _checkpointSeq, string memory _price) public { - address server = msg.sender; - require(servers[server], "not a valid server"); - - if (!propose[_tokenA][_tokenB][_checkpointSeq][server] || _checkpointSeq == 0) { - propose[_tokenA][_tokenB][_checkpointSeq][server] = true; - proposalCnt[_tokenA][_tokenB][_checkpointSeq][_price] += 1; - - if (proposalCnt[_tokenA][_tokenB][_checkpointSeq][_price] > threshold && _checkpointSeq >= lastUpdateSeq[_tokenA][_tokenB]) { - prices[_tokenA][_tokenB] = _price; - lastUpdateSeq[_tokenA][_tokenB] = _checkpointSeq; - } - } - } - - function resetPrice(address _tokenA, address _tokenB, address[] memory _servers) public { - require(msg.sender == owner); - - prices[_tokenA][_tokenB] = ""; - lastUpdateSeq[_tokenA][_tokenB] = 0; - for (uint i = 0; i < _servers.length; i++) { - propose[_tokenA][_tokenB][0][_servers[i]] = false; - } - proposalCnt[_tokenA][_tokenB][0]["0.0"] = 0; - } - - function resetBalance(address _token, address _user) public { - require(msg.sender == owner); - - publicBalance[_token][_user] = 0; - } -} diff --git a/src/contracts/HbSwapToken.sol b/src/contracts/HbSwapToken.sol deleted file mode 100644 index dd2ce1d1..00000000 --- a/src/contracts/HbSwapToken.sol +++ /dev/null @@ -1,13 +0,0 @@ -pragma solidity ^0.5.0; - -import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; -import "@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol"; - -contract HbSwapToken is ERC20, ERC20Detailed { - uint8 public constant DECIMALS = 18; - uint256 public constant INITIAL_SUPPLY = 1e28; - - constructor () public ERC20Detailed("HbSwapToken", "HBS", DECIMALS) { - _mint(msg.sender, INITIAL_SUPPLY); - } -} \ No newline at end of file diff --git a/src/genfiles/HbSwap.abi b/src/genfiles/HbSwap.abi deleted file mode 100644 index 6aec7398..00000000 --- a/src/genfiles/HbSwap.abi +++ /dev/null @@ -1,858 +0,0 @@ -[ - { - "inputs": [ - { - "internalType": "address[]", - "name": "_servers", - "type": "address[]" - }, - { - "internalType": "uint256", - "name": "_threshold", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "tokenA", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "tokenB", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "idxA", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "idxB", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "maskedAmtA", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "maskedAmtB", - "type": "uint256" - } - ], - "name": "AddLiquidity", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "tokenA", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "tokenB", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amtA", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amtB", - "type": "uint256" - } - ], - "name": "InitPool", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256[]", - "name": "inpusMaskIndexes", - "type": "uint256[]" - } - ], - "name": "InputMask", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "tokenA", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "tokenB", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "idx", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "maskedAmt", - "type": "uint256" - } - ], - "name": "RemoveLiquidity", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amt", - "type": "uint256" - } - ], - "name": "SecretDeposit", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "seq", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "amt", - "type": "uint256" - } - ], - "name": "SecretWithdraw", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "tradeSeq", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "tokenA", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "tokenB", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "idxA", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "idxB", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "maskedAmtA", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "maskedAmtB", - "type": "uint256" - } - ], - "name": "Trade", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "Decimals", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "Fp", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "consentRecord", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "inputMaskOwner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "inputmaskCnt", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "lastUpdateSeq", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "prices", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - }, - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "publicBalance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "secretWithdrawCnt", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "secretWithdrawMap", - "outputs": [ - { - "internalType": "address", - "name": "token", - "type": "address" - }, - { - "internalType": "address", - "name": "user", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amt", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "name": "servers", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "threshold", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "tradeCnt", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amt", - "type": "uint256" - } - ], - "name": "publicDeposit", - "outputs": [], - "payable": true, - "stateMutability": "payable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amt", - "type": "uint256" - } - ], - "name": "secretDeposit", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amt", - "type": "uint256" - } - ], - "name": "secretWithdraw", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "_seq", - "type": "uint256" - } - ], - "name": "consent", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amt", - "type": "uint256" - } - ], - "name": "publicWithdraw", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "uint256", - "name": "_num", - "type": "uint256" - } - ], - "name": "reserveInput", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "_tokenB", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_amtA", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_amtB", - "type": "uint256" - } - ], - "name": "initPool", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "_tokenB", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_idxA", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_idxB", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_maskedAmtA", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_maskedAmtB", - "type": "uint256" - } - ], - "name": "addLiquidity", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "_tokenB", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_idx", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_maskedAmt", - "type": "uint256" - } - ], - "name": "removeLiquidity", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "_tokenB", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_idxA", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_idxB", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_maskedA", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "_maskedB", - "type": "uint256" - } - ], - "name": "trade", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "_tokenB", - "type": "address" - }, - { - "internalType": "uint256", - "name": "_checkpointSeq", - "type": "uint256" - }, - { - "internalType": "string", - "name": "_price", - "type": "string" - } - ], - "name": "updatePrice", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_tokenA", - "type": "address" - }, - { - "internalType": "address", - "name": "_tokenB", - "type": "address" - }, - { - "internalType": "address[]", - "name": "_servers", - "type": "address[]" - } - ], - "name": "resetPrice", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "_token", - "type": "address" - }, - { - "internalType": "address", - "name": "_user", - "type": "address" - } - ], - "name": "resetBalance", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/src/genfiles/HbSwap.bin b/src/genfiles/HbSwap.bin deleted file mode 100644 index 42be77f3..00000000 --- a/src/genfiles/HbSwap.bin +++ /dev/null @@ -1 +0,0 @@ -0x60806040523480156200001157600080fd5b5060405162003a7b38038062003a7b833981810160405260408110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b838201915060208201858111156200006f57600080fd5b82518660208202830111640100000000821117156200008d57600080fd5b8083526020830192505050908051906020019060200280838360005b83811015620000c6578082015181840152602081019050620000a9565b5050505090500160405260200180519060200190929190505050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008090505b8251811015620001aa576001600260008584815181106200014357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808060010191505062000126565b508060018190555050506138b780620001c46000396000f3fe6080604052600436106101815760003560e01c80639eef6ce8116100d1578063b7deef821161008a578063ca7b58ad11610064578063ca7b58ad14610b95578063cc5bd7fa14610c06578063dee4059514610c41578063e7e8927614610c9c57610181565b8063b7deef8214610a94578063bc94e7cf14610b0f578063c6ceb50b14610b6a57610181565b80639eef6ce81461088a578063a45b6ce6146108c5578063a4bea6c8146108f0578063ade28aad14610975578063af4170c4146109d0578063b72a2139146109fb57610181565b80633766dba71161013e5780637aa6fd65116101185780637aa6fd651461065757806393910e661461070c57806393f54644146107375780639450fb261461078557610181565b80633766dba7146104955780633ee7f9d3146105a757806342cde4e81461062c57610181565b806312ada8de146101865780631768af96146101ef5780631f312404146102625780632f8a68c51461034c5780633351733f146103d15780633394dc6f1461046a575b600080fd5b34801561019257600080fd5b506101d5600480360360208110156101a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d21565b604051808215151515815260200191505060405180910390f35b3480156101fb57600080fd5b506102486004803603604081101561021257600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d41565b604051808215151515815260200191505060405180910390f35b34801561026e57600080fd5b506102d16004803603604081101561028557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d70565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103115780820151818401526020810190506102f6565b50505050905090810190601f16801561033e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561035857600080fd5b506103cf6004803603608081101561036f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190505050610e2d565b005b3480156103dd57600080fd5b50610468600480360360c08110156103f457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050611037565b005b34801561047657600080fd5b5061047f611379565b6040518082815260200191505060405180910390f35b3480156104a157600080fd5b506105a5600480360360808110156104b857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561051f57600080fd5b82018360208201111561053157600080fd5b8035906020019184600183028401116401000000008311171561055357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061137f565b005b3480156105b357600080fd5b5061062a600480360360808110156105ca57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291905050506119b3565b005b34801561063857600080fd5b50610641611c0f565b6040518082815260200191505060405180910390f35b34801561066357600080fd5b506106906004803603602081101561067a57600080fd5b8101908080359060200190929190505050611c15565b604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060405180910390f35b34801561071857600080fd5b50610721611c7f565b6040518082815260200191505060405180910390f35b6107836004803603604081101561074d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611c85565b005b34801561079157600080fd5b50610888600480360360608110156107a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561080557600080fd5b82018360208201111561081757600080fd5b8035906020019184602083028401116401000000008311171561083957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050611e95565b005b34801561089657600080fd5b506108c3600480360360208110156108ad57600080fd5b81019080803590602001909291905050506121f7565b005b3480156108d157600080fd5b506108da612604565b6040518082815260200191505060405180910390f35b3480156108fc57600080fd5b5061095f6004803603604081101561091357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061260b565b6040518082815260200191505060405180910390f35b34801561098157600080fd5b506109ce6004803603604081101561099857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612630565b005b3480156109dc57600080fd5b506109e5612861565b6040518082815260200191505060405180910390f35b348015610a0757600080fd5b50610a92600480360360c0811015610a1e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050612867565b005b348015610aa057600080fd5b50610acd60048036036020811015610ab757600080fd5b8101908080359060200190929190505050612bc4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610b1b57600080fd5b50610b6860048036036040811015610b3257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612bf7565b005b348015610b7657600080fd5b50610b7f612e66565b6040518082815260200191505060405180910390f35b348015610ba157600080fd5b50610c0460048036036040811015610bb857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612e71565b005b348015610c1257600080fd5b50610c3f60048036036020811015610c2957600080fd5b8101908080359060200190929190505050612f50565b005b348015610c4d57600080fd5b50610c9a60048036036040811015610c6457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506130a3565b005b348015610ca857600080fd5b50610d0b60048036036040811015610cbf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506132d4565b6040518082815260200191505060405180910390f35b60026020528060005260406000206000915054906101000a900460ff1681565b60066020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b600c602052816000526040600020602052806000526040600020600091509150508054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e255780601f10610dfa57610100808354040283529160200191610e25565b820191906000526020600020905b815481529060010190602001808311610e0857829003601f168201915b505050505081565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610610ece576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f696e76616c69642074726164696e67207061697200000000000000000000000081525060200191505060405180910390fd5b600082118015610ede5750600081115b610f50576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f696e76616c696420616d6f756e7400000000000000000000000000000000000081525060200191505060405180910390fd5b60003390507ffaaebcb30b1b421f4f2ca7f2620e5add6a64532c087ee0646fd665a33d36fdf53386868686604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020019550505050505060405180910390a15050505050565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16106110d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f696e76616c69642074726164696e67207061697200000000000000000000000081525060200191505060405180910390fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff16600a600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f756e617574686f72697a656420696e7075746d61736b0000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611285576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f756e617574686f72697a656420696e7075746d61736b0000000000000000000081525060200191505060405180910390fd5b7fec7d4752dd44bf7fc59045c9d80163de2a1b9dbd9032d11cb1156f7f867c641181888888888888604051808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185815260200184815260200183815260200182815260200197505050505050505060405180910390a150505050505050565b60045481565b6000339050600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611443576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f6e6f7420612076616c696420736572766572000000000000000000000000000081525060200191505060405180910390fd5b600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615806115275750600083145b156119ac576001600f60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600e60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000858152602001908152602001600020836040518082805190602001908083835b602083106116d257805182526020820191506020810190506020830392506116af565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060008282540192505081905550600154600e60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000858152602001908152602001600020836040518082805190602001908083835b602083106117d657805182526020820191506020810190506020830392506117b3565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020541180156118935750600d60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548310155b156119ab5781600c60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209080519060200190611928929190613766565b5082600d60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5b5050505050565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610611a54576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f696e76616c69642074726164696e67207061697200000000000000000000000081525060200191505060405180910390fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff16600a600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b2d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f756e617574686f72697a656420696e7075746d61736b0000000000000000000081525060200191505060405180910390fd5b7fa8dbaaebbb025c88e9e34c84635cd8238043556e9af43fb161508c898a8e1ef98186868686604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020019550505050505060405180910390a15050505050565b60015481565b60056020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020154905083565b60095481565b600033905060008211611d00576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f696e76616c696420616d6f756e7400000000000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611dbd5766038d7ea4c68000820262010000340214611db8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f616d6f756e7473206e6f74206d6174636800000000000000000000000000000081525060200191505060405180910390fd5b611e06565b6000839050611e04823066038d7ea4c68000620100008781611ddb57fe5b04028473ffffffffffffffffffffffffffffffffffffffff166132f9909392919063ffffffff16565b505b81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611eee57600080fd5b60405180602001604052806000815250600c60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209080519060200190611f8d929190613766565b506000600d60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008090505b8151811015612122576000600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080815260200190815260200160002060008484815181106120bc57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080600101915050612016565b506000600e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080815260200190815260200160002060405180807f302e3000000000000000000000000000000000000000000000000000000000008152506003019050908152602001604051809103902081905550505050565b6000339050600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166122bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f6e6f7420612076616c696420736572766572000000000000000000000000000081525060200191505060405180910390fd5b6006600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561238c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f616c726561647920636f6e73656e74000000000000000000000000000000000081525060200191505060405180910390fd5b60016006600084815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060016007600084815260200190815260200160002060008282540192505081905550600154600760008481526020019081526020016000205411801561245957506008600083815260200190815260200160002060009054906101000a900460ff16155b15612600576124666137e6565b600560008481526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820154815250509050806040015160036000836000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000836020015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060016008600085815260200190815260200160002060006101000a81548160ff021916908315150217905550505b5050565b6201000081565b600d602052816000526040600020602052806000526040600020600091509150505481565b60003390506000821180156126c1575081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b612733576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f696e76616c696420616d6f756e7400000000000000000000000000000000000081525060200191505060405180910390fd5b81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055507f07c06144435b7d2bdccf9ee7e5a7022c63382ac7c3a0e14ed08b5969dedf0ecf838284604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060405180910390a1505050565b600b5481565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1610612908576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f696e76616c69642074726164696e67207061697200000000000000000000000081525060200191505060405180910390fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff16600a600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146129e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f756e617574686f72697a656420696e7075746d61736b0000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612ab5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f756e617574686f72697a656420696e7075746d61736b0000000000000000000081525060200191505060405180910390fd5b6001600b600082825401925050819055507f2b4d91cd20cc8800407e3614b8466a6f0729ac3b1fa43d4e2b059ff5593cbae6600b5482898989898989604051808981526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018481526020018381526020018281526020019850505050505050505060405180910390a150505050505050565b600a6020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000339050600082118015612c88575081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b612cfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f696e76616c696420616d6f756e7400000000000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612d90578073ffffffffffffffffffffffffffffffffffffffff166108fc66038d7ea4c68000620100008581612d5d57fe5b04029081150290604051600060405180830381858888f19350505050158015612d8a573d6000803e3d6000fd5b50612dd7565b6000839050612dd58266038d7ea4c68000620100008681612dad57fe5b04028373ffffffffffffffffffffffffffffffffffffffff166133ff9092919063ffffffff16565b505b81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550505050565b66038d7ea4c6800081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612eca57600080fd5b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b6000339050606082604051908082528060200260200182016040528015612f865781602001602082028038833980820191505090505b50905060008090505b838110156130255760006009600081548092919060010191905055905083600a600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508083838151811061300b57fe5b602002602001018181525050508080600101915050612f8f565b507fff742b54a62e49c065680fc16aa208f37f60ded27e03a3d19e6088ba0c7b41d4816040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561308b578082015181840152602081019050613070565b505050509050019250505060405180910390a1505050565b60003390506000821161311e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f696e76616c696420616d6f756e7400000000000000000000000000000000000081525060200191505060405180910390fd5b600160046000828254019250508190555060405180606001604052808473ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020018381525060056000600454815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604082015181600201559050507f4ef3cc4825a92c3b6922acc8a45152cc96ef48463e8ed500dacd5df9e29a67f3600454848385604051808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060405180910390a1505050565b6003602052816000526040600020602052806000526040600020600091509150505481565b6133f9848573ffffffffffffffffffffffffffffffffffffffff166323b872dd905060e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506134d0565b50505050565b6134cb838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506134d0565b505050565b6134ef8273ffffffffffffffffffffffffffffffffffffffff1661371b565b613561576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b602083106135b0578051825260208201915060208101905060208303925061358d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613612576040519150601f19603f3d011682016040523d82523d6000602084013e613617565b606091505b50915091508161368f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b600081511115613715578080602001905160208110156136ae57600080fd5b8101908080519060200190929190505050613714576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613859602a913960400191505060405180910390fd5b5b50505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f915080821415801561375d57506000801b8214155b92505050919050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106137a757805160ff19168380011785556137d5565b828001600101855582156137d5579182015b828111156137d45782518255916020019190600101906137b9565b5b5090506137e29190613833565b5090565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b61385591905b80821115613851576000816000905550600101613839565b5090565b9056fe5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a7231582055ef814be42664133bbeee941837ad8a5fdf784f88c4c26f0e45529bfdbf8e0964736f6c63430005110032 diff --git a/src/genfiles/HbSwapToken.abi b/src/genfiles/HbSwapToken.abi deleted file mode 100644 index 97219d0a..00000000 --- a/src/genfiles/HbSwapToken.abi +++ /dev/null @@ -1,330 +0,0 @@ -[ - { - "inputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "DECIMALS", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "INITIAL_SUPPLY", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "address", - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "internalType": "address", - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "decimals", - "outputs": [ - { - "internalType": "uint8", - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "spender", - "type": "address" - }, - { - "internalType": "uint256", - "name": "addedValue", - "type": "uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "name", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "symbol", - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "recipient", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } -] diff --git a/src/genfiles/HbSwapToken.bin b/src/genfiles/HbSwapToken.bin deleted file mode 100644 index 8a2cc8e0..00000000 --- a/src/genfiles/HbSwapToken.bin +++ /dev/null @@ -1 +0,0 @@ -0x60806040523480156200001157600080fd5b506040518060400160405280600b81526020017f486253776170546f6b656e0000000000000000000000000000000000000000008152506040518060400160405280600381526020017f4842530000000000000000000000000000000000000000000000000000000000815250601282600390805190602001906200009892919062000347565b508160049080519060200190620000b192919062000347565b5080600560006101000a81548160ff021916908360ff160217905550505050620000ee336b204fce5e3e25026110000000620000f460201b60201c565b620003f6565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141562000198576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b620001b481600254620002be60201b62000f9f1790919060201c565b60028190555062000212816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054620002be60201b62000f9f1790919060201c565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000808284019050838110156200033d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200038a57805160ff1916838001178555620003bb565b82800160010185558215620003bb579182015b82811115620003ba5782518255916020019190600101906200039d565b5b509050620003ca9190620003ce565b5090565b620003f391905b80821115620003ef576000816000905550600101620003d5565b5090565b90565b61115d80620004066000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063313ce5671161008c57806395d89b411161006657806395d89b4114610385578063a457c2d714610408578063a9059cbb1461046e578063dd62ed3e146104d4576100cf565b8063313ce567146102a357806339509351146102c757806370a082311461032d576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bd57806323b872dd146101db5780632e0f2625146102615780632ff2e9dc14610285575b600080fd5b6100dc61054c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ee565b604051808215151515815260200191505060405180910390f35b6101c561060c565b6040518082815260200191505060405180910390f35b610247600480360360608110156101f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610616565b604051808215151515815260200191505060405180910390f35b6102696106ef565b604051808260ff1660ff16815260200191505060405180910390f35b61028d6106f4565b6040518082815260200191505060405180910390f35b6102ab610704565b604051808260ff1660ff16815260200191505060405180910390f35b610313600480360360408110156102dd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061071b565b604051808215151515815260200191505060405180910390f35b61036f6004803603602081101561034357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107ce565b6040518082815260200191505060405180910390f35b61038d610816565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103cd5780820151818401526020810190506103b2565b50505050905090810190601f1680156103fa5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104546004803603604081101561041e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108b8565b604051808215151515815260200191505060405180910390f35b6104ba6004803603604081101561048457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610985565b604051808215151515815260200191505060405180910390f35b610536600480360360408110156104ea57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109a3565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105e45780601f106105b9576101008083540402835291602001916105e4565b820191906000526020600020905b8154815290600101906020018083116105c757829003601f168201915b5050505050905090565b60006106026105fb610a2a565b8484610a32565b6001905092915050565b6000600254905090565b6000610623848484610c29565b6106e48461062f610a2a565b6106df8560405180606001604052806028815260200161109360289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610695610a2a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610edf9092919063ffffffff16565b610a32565b600190509392505050565b601281565b6b204fce5e3e2502611000000081565b6000600560009054906101000a900460ff16905090565b60006107c4610728610a2a565b846107bf8560016000610739610a2a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f9f90919063ffffffff16565b610a32565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108ae5780601f10610883576101008083540402835291602001916108ae565b820191906000526020600020905b81548152906001019060200180831161089157829003601f168201915b5050505050905090565b600061097b6108c5610a2a565b846109768560405180606001604052806025815260200161110460259139600160006108ef610a2a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610edf9092919063ffffffff16565b610a32565b6001905092915050565b6000610999610992610a2a565b8484610c29565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ab8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806110e06024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b3e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061104b6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610caf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110bb6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d35576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806110286023913960400191505060405180910390fd5b610da08160405180606001604052806026815260200161106d602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610edf9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e33816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f9f90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f8c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f51578082015181840152602081019050610f36565b50505050905090810190601f168015610f7e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008082840190508381101561101d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a723158209635ee1504e4a1dc75ee1aa82dc07efbd187ee0e3805ceaaf097245eb422231764736f6c63430005110032 diff --git a/src/go/client/add_liquidity.go b/src/go/client/add_liquidity.go deleted file mode 100644 index 7d98ca01..00000000 --- a/src/go/client/add_liquidity.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "fmt" - "github.com/ethereum/go-ethereum/common" - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "os" -) - -func main() { - user := utils.GetAccount(fmt.Sprintf("account_%s", os.Args[1])) - tokenA, tokenB := common.HexToAddress(os.Args[2]), common.HexToAddress(os.Args[3]) - amtA, amtB := os.Args[4], os.Args[5] - - conn := utils.GetEthClient(utils.TestnetHttpEndpoint) - - utils.AddLiquidity(conn, user, tokenA, tokenB, utils.StrToBig(amtA), utils.StrToBig(amtB)) -} diff --git a/src/go/client/deposit.go b/src/go/client/deposit.go deleted file mode 100644 index eab51508..00000000 --- a/src/go/client/deposit.go +++ /dev/null @@ -1,83 +0,0 @@ -package main - -import ( - "bytes" - "flag" - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/initc3/HoneyBadgerSwap/src/go/client/lib" - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "math/big" - "os" -) - -func depositETH(network string, conn *ethclient.Client, auth *bind.TransactOpts, _amt string) { - fmt.Println("depositETH ...") - amt := utils.StrToBig(_amt) - if amt.Cmp(big.NewInt(0)) == 0 { - return - } - - utils.FundETH(network, conn, auth.From, amt) - auth.Value = amt - utils.Deposit(network, conn, auth, utils.EthAddr, amt) - - utils.GetBalance(network, conn, utils.EthAddr, auth.From) -} - -func depositTOK(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenAddr common.Address, _amt string) { - amt := utils.StrToBig(_amt) - if amt.Cmp(big.NewInt(0)) == 0 { - return - } - - utils.FundToken(conn, tokenAddr, auth.From, amt) - - auth.Value = big.NewInt(0) - utils.Approve(network, conn, auth, tokenAddr, utils.HbswapAddr[network], amt) - utils.Deposit(network, conn, auth, tokenAddr, amt) - - utils.GetBalance(network, conn, tokenAddr, auth.From) -} - -func main() { - // parse cmd line arguments/flags - var configfile string - flag.StringVar(&configfile, "config", "/opt/hbswap/conf/client.toml", "Config file. Default: /opt/hbswap/conf/client.toml") - flag.Parse() - - // parse config file - config := lib.ParseClientConfig(configfile) - network := config.EthNode.Network - ethHostname := config.EthNode.Hostname - fmt.Println("Eth network: ", network) - fmt.Println("Eth hostname: ", ethHostname) - fmt.Println("Eth http endpoint: ", config.EthNode.HttpEndpoint) - - user := utils.GetAccount(fmt.Sprintf("account_%s", os.Args[3])) - tokenA, tokenB := common.HexToAddress(os.Args[4]), common.HexToAddress(os.Args[5]) - amtA, amtB := os.Args[6], os.Args[7] - - ethUrl := ethHostname - if network == "privatenet" { - ethUrl = utils.GetEthURL(ethHostname) - } else { - ethUrl = config.EthNode.HttpEndpoint - } - conn := utils.GetEthClient(ethUrl) - fmt.Println("Eth client connection: %s", conn) - - if bytes.Equal(tokenA.Bytes(), utils.EthAddr.Bytes()) { - depositETH(network, conn, user, amtA) - } else { - depositTOK(network, conn, user, tokenA, amtA) - } - - if bytes.Equal(tokenB.Bytes(), utils.EthAddr.Bytes()) { - depositETH(network, conn, user, amtB) - } else { - depositTOK(network, conn, user, tokenB, amtB) - } -} diff --git a/src/go/client/init_pool.go b/src/go/client/init_pool.go deleted file mode 100644 index 3cca73b3..00000000 --- a/src/go/client/init_pool.go +++ /dev/null @@ -1,75 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "github.com/ethereum/go-ethereum/common" - "github.com/initc3/HoneyBadgerSwap/src/go/client/lib" - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "os" -) - -//func prepareETH(conn *ethclient.Client, auth *bind.TransactOpts, _amt string) *big.Int { -// amt := utils.StrToBig(_amt) -// if amt.Cmp(big.NewInt(0)) == 1 { -// utils.FundETH(conn, auth.From, amt) -// } -// return amt -//} -// -//func prepareTOK(conn *ethclient.Client, auth *bind.TransactOpts, tokenAddr common.Address, _amt string) { -// amt := utils.StrToBig(_amt) -// if amt.Cmp(big.NewInt(0)) == 0 { -// return -// } -// -// utils.FundToken(conn, tokenAddr, auth.From, amt) -// -// utils.Approve(conn, auth, tokenAddr, utils.HbswapAddr, amt) -//} - -func main() { - // parse cmd line arguments/flags - var configfile string - flag.StringVar(&configfile, "config", "/opt/hbswap/conf/client.toml", "Config file. Default: /opt/hbswap/conf/client.toml") - flag.Parse() - - // parse config file - config := lib.ParseClientConfig(configfile) - network := config.EthNode.Network - ethHostname := config.EthNode.Hostname - fmt.Println("Eth network: ", network) - fmt.Println("Eth hostname: ", ethHostname) - - user := utils.GetAccount(fmt.Sprintf("account_%s", os.Args[3])) - tokenA, tokenB := common.HexToAddress(os.Args[4]), common.HexToAddress(os.Args[5]) - amtA, amtB := os.Args[6], os.Args[7] - - ethUrl := ethHostname - if network == "privatenet" { - ethUrl = utils.GetEthURL(ethHostname) - } else { - ethUrl = config.EthNode.HttpEndpoint - } - conn := utils.GetEthClient(ethUrl) - - //ethA := bytes.Equal(tokenA.Bytes(), utils.EthAddr.Bytes()) - //ethB := bytes.Equal(tokenB.Bytes(), utils.EthAddr.Bytes()) - // - //if !ethA { - // prepareTOK(conn, user, tokenA, amtA) - //} - //if !ethB { - // prepareTOK(conn, user, tokenB, amtB) - //} - // - //value := big.NewInt(0) - //if ethA { - // value = prepareETH(conn, user, amtA) - //} - //if ethB { - // value = prepareETH(conn, user, amtB) - //} - - utils.InitPool(network, conn, user, tokenA, tokenB, utils.StrToBig(amtA), utils.StrToBig(amtB)) -} diff --git a/src/go/client/lib/confparse.go b/src/go/client/lib/confparse.go deleted file mode 100644 index 849fab75..00000000 --- a/src/go/client/lib/confparse.go +++ /dev/null @@ -1,41 +0,0 @@ -package lib - -import ( - "fmt" - toml "github.com/pelletier/go-toml" - "io/ioutil" - "log" -) - -type EthNodeConfig struct { - Network string - Hostname string - HttpEndpoint string - WsEndpoint string - HttpPort int - WsPort int -} - -type ServerConfig struct { - Id int - Host string - HttpPort int -} - -type ClientConfig struct { - N int - T int - EthNode EthNodeConfig - Servers []ServerConfig -} - -func ParseClientConfig(configfile string) ClientConfig { - fmt.Println("Parsing config file: ", configfile) - data, err := ioutil.ReadFile(configfile) - if err != nil { - log.Fatal(err) - } - config := ClientConfig{} - toml.Unmarshal(data, &config) - return config -} diff --git a/src/go/client/remove_liquidity.go b/src/go/client/remove_liquidity.go deleted file mode 100644 index ae837ae3..00000000 --- a/src/go/client/remove_liquidity.go +++ /dev/null @@ -1,18 +0,0 @@ -package main - -import ( - "fmt" - "github.com/ethereum/go-ethereum/common" - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "os" -) - -func main() { - user := utils.GetAccount(fmt.Sprintf("account_%s", os.Args[1])) - tokenA, tokenB := common.HexToAddress(os.Args[2]), common.HexToAddress(os.Args[3]) - amt := os.Args[4] - - conn := utils.GetEthClient(utils.TestnetHttpEndpoint) - - utils.RemoveLiquidity(conn, user, tokenA, tokenB, utils.StrToBig(amt)) -} diff --git a/src/go/client/secret_deposit.go b/src/go/client/secret_deposit.go deleted file mode 100644 index 3d9acfe0..00000000 --- a/src/go/client/secret_deposit.go +++ /dev/null @@ -1,55 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/initc3/HoneyBadgerSwap/src/go/client/lib" - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "math/big" - "os" -) - -func secretDeposit(network string, conn *ethclient.Client, auth *bind.TransactOpts, token common.Address, _amt string) { - amt := utils.StrToBig(_amt) - if amt.Cmp(big.NewInt(0)) == 0 { - return - } - - utils.SecretDeposit(network, conn, auth, token, amt) - - utils.GetBalance(network, conn, token, auth.From) -} - -func main() { - // parse cmd line arguments/flags - var configfile string - flag.StringVar(&configfile, "config", "/opt/hbswap/conf/client.toml", "Config file. Default: /opt/hbswap/conf/client.toml") - flag.Parse() - - // parse config file - config := lib.ParseClientConfig(configfile) - network := config.EthNode.Network - ethHostname := config.EthNode.Hostname - fmt.Println("Eth network: ", network) - fmt.Println("Eth hostname: ", ethHostname) - - user := os.Args[3] - tokenA, tokenB := common.HexToAddress(os.Args[4]), common.HexToAddress(os.Args[5]) - amtA, amtB := os.Args[6], os.Args[7] - - ethUrl := ethHostname - if network == "privatenet" { - ethUrl = utils.GetEthURL(ethHostname) - } else { - ethUrl = config.EthNode.HttpEndpoint - } - conn := utils.GetEthClient(ethUrl) - - owner := utils.GetAccount(fmt.Sprintf("account_%s", user)) - - secretDeposit(network, conn, owner, tokenA, amtA) - secretDeposit(network, conn, owner, tokenB, amtB) -} diff --git a/src/go/client/secret_withdraw.go b/src/go/client/secret_withdraw.go deleted file mode 100644 index 3c7b06d8..00000000 --- a/src/go/client/secret_withdraw.go +++ /dev/null @@ -1,55 +0,0 @@ -package main - -import ( - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/initc3/HoneyBadgerSwap/src/go/client/lib" - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "math/big" - "os" -) - -func secretWithdraw(conn *ethclient.Client, auth *bind.TransactOpts, token common.Address, _amt string) { - amt := utils.StrToBig(_amt) - if amt.Cmp(big.NewInt(0)) == 0 { - return - } - - utils.SecretWithdraw(conn, auth, token, amt) - - utils.GetBalance(conn, token, auth.From) -} - -func main() { - // parse cmd line arguments/flags - var configfile string - flag.StringVar(&configfile, "config", "/opt/hbswap/conf/client.toml", "Config file. Default: /opt/hbswap/conf/client.toml") - flag.Parse() - - // parse config file - config := lib.ParseClientConfig(configfile) - network := config.EthNode.Network - ethHostname := config.EthNode.Hostname - fmt.Println("Eth network: ", network) - fmt.Println("Eth hostname: ", ethHostname) - - user := os.Args[1] - tokenA, tokenB := common.HexToAddress(os.Args[2]), common.HexToAddress(os.Args[3]) - amtA, amtB := os.Args[4], os.Args[5] - - ethUrl := ethHostname - if network == "privatenet" { - ethUrl = utils.GetEthURL(ethHostname) - } - } else { - ethUrl = config.EthNode.HttpEndpoint - } - conn := utils.GetEthClient(ethUrl) - - owner := utils.GetAccount(fmt.Sprintf("account_%s", user)) - - secretWithdraw(conn, owner, tokenA, amtA) - secretWithdraw(conn, owner, tokenB, amtB) -} diff --git a/src/go/client/testnet.go b/src/go/client/testnet.go deleted file mode 100644 index 7d553887..00000000 --- a/src/go/client/testnet.go +++ /dev/null @@ -1,52 +0,0 @@ -// go run src/go/client/testnet.go - -package main - -import ( - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "math/big" -) - -var ( - balance *big.Int -) - -func main() { - network := "testnet" - conn := utils.GetEthClient(utils.TestnetWsEndpoint) - //conn := utils.GetEthClient("http://127.0.0.1:8545") - - //admin := utils.GetAccount("poa/keystore/server_0") - //balance, _ = conn.BalanceAt(context.Background(), admin.From, nil) - //fmt.Printf("admin eth balance %v\n", balance) - //balance = utils.GetBalanceToken(conn, admin.From, utils.HbSwapTokenAddr[network]) - //fmt.Printf("admin hbs balance %v\n", balance) - //// - //peer := utils.GetAccount(fmt.Sprintf("account_0")) - //peer := utils.GetAccount(fmt.Sprintf("server_3")) - //peer := common.HexToAddress("0xc33a4b5b609fcc294dca060347761226e78c0b7a") //Metamask - //peer := common.HexToAddress("0x3C19cA734eeaA2b3617C76afa993A54b5C6f6448") //sylvain - //peer := common.HexToAddress("0x786e3c83cd270414649079A758Ad92f961EDdA0A") //DAI - //peer := common.HexToAddress("0x37a25f181a43613e2917c650bd6d2f2bb26defd2") //new server_0 - //peer := common.HexToAddress("0xabbf7aedbb03f7fb09b6c7a41623ef67b97570b2") //new server_1 - //peer := common.HexToAddress("0x00377f482929288e237c50578553641a0a2e4ce2") //new server_2 - //peer := common.HexToAddress("0xae76f3dfa7a7b1556bb49ee41663b7ac6be58da5") //new server_3 - - /* transfer eth */ - //balance, _ = conn.BalanceAt(context.Background(), peer, nil) - //fmt.Printf("peer eth balance %v\n", balance) - //utils.FundETH("testnet", conn, peer, big.NewInt(5 * 1000000000000000000)) - //balance, _ = conn.BalanceAt(context.Background(), peer, nil) - //fmt.Printf("peer eth balance %v\n", balance) - - /* transfer hbs */ - //balance = utils.GetBalanceToken(conn, peer, utils.HbSwapTokenAddr[network]) - //fmt.Printf("peer hbs balance %v\n", balance) - //utils.FundToken(conn, utils.HbSwapTokenAddr[network], peer, big.NewInt(5 * 1000000000000000000)) - //balance = utils.GetBalanceToken(conn, peer, utils.HbSwapTokenAddr[network]) - //fmt.Printf("peer hbs balance %v\n", balance) - // - for i := 0; i < 100; i++ { - utils.GetInputmaskCnt(network, conn) - } -} diff --git a/src/go/client/trade.go b/src/go/client/trade.go deleted file mode 100644 index 8d7703c3..00000000 --- a/src/go/client/trade.go +++ /dev/null @@ -1,54 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "github.com/ethereum/go-ethereum/common" - "github.com/initc3/HoneyBadgerSwap/src/go/client/lib" - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "math/big" - "os" - "os/exec" - "strconv" - "strings" -) - -func main() { - // parse cmd line arguments/flags - var configfile string - flag.StringVar(&configfile, "config", "/opt/hbswap/conf/server.toml", "Config file. Default: /opt/hbswap/conf/server.toml") - flag.Parse() - - // parse config file - config := lib.ParseClientConfig(configfile) - network := config.EthNode.Network - ethHostname := config.EthNode.Hostname - fmt.Println("Eth network: ", network) - fmt.Println("Eth hostname: ", ethHostname) - - user := os.Args[3] - tokenA, tokenB := common.HexToAddress(os.Args[4]), common.HexToAddress(os.Args[5]) - amtA, amtB := os.Args[6], os.Args[7] - - ethUrl := ethHostname - if network == "privatenet" { - ethUrl = utils.GetEthURL(ethHostname) - } else { - ethUrl = config.EthNode.HttpEndpoint - } - conn := utils.GetEthClient(ethUrl) - - owner := utils.GetAccount(fmt.Sprintf("account_%s", user)) - - idxA, idxB := utils.TradePrep(network, conn, owner) - - cmd := exec.Command("python3", "-m", "honeybadgerswap.client.req_inputmasks", strconv.Itoa(int(idxA)), amtA, strconv.Itoa(int(idxB)), amtB) - stdout := utils.ExecCmd(cmd) - maskedInputs := strings.Split(stdout[:len(stdout)-1], " ") - - maskedA := utils.StrToBig(maskedInputs[0]) - maskedB := utils.StrToBig(maskedInputs[1]) - - fmt.Printf("maskedInputs: %v\n", maskedInputs) - utils.Trade(network, conn, owner, tokenA, tokenB, big.NewInt(idxA), big.NewInt(idxB), maskedA, maskedB) -} diff --git a/src/go/client/withdraw.go b/src/go/client/withdraw.go deleted file mode 100644 index 05875d53..00000000 --- a/src/go/client/withdraw.go +++ /dev/null @@ -1,62 +0,0 @@ -package main - -import ( - "bytes" - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "math/big" - "os" -) - -func withdrawETH(conn *ethclient.Client, auth *bind.TransactOpts, _amt string) { - amt := utils.StrToBig(_amt) - if amt.Cmp(big.NewInt(0)) == 0 { - return - } - - utils.GetBalance(conn, utils.EthAddr, auth.From) - - utils.Withdraw(conn, auth, utils.EthAddr, amt) - - utils.GetBalance(conn, utils.EthAddr, auth.From) -} - -func withdrawTOK(conn *ethclient.Client, auth *bind.TransactOpts, tokenAddr common.Address, _amt string) { - amt := utils.StrToBig(_amt) - if amt.Cmp(big.NewInt(0)) == 0 { - return - } - - utils.GetBalance(conn, tokenAddr, auth.From) - - utils.Withdraw(conn, auth, tokenAddr, amt) - - utils.GetBalance(conn, tokenAddr, auth.From) -} - -func main() { - user := os.Args[1] - tokenA, tokenB := common.HexToAddress(os.Args[2]), common.HexToAddress(os.Args[3]) - amtA, amtB := os.Args[4], os.Args[5] - - ethHostname := os.Args[6] - ethUrl := utils.GetEthURL(ethHostname) - conn := utils.GetEthClient(ethUrl) - - owner := utils.GetAccount(fmt.Sprintf("account_%s", user)) - - if bytes.Equal(tokenA.Bytes(), utils.EthAddr.Bytes()) { - withdrawETH(conn, owner, amtA) - } else { - withdrawTOK(conn, owner, tokenA, amtA) - } - - if bytes.Equal(tokenB.Bytes(), utils.EthAddr.Bytes()) { - withdrawETH(conn, owner, amtB) - } else { - withdrawTOK(conn, owner, tokenB, amtB) - } -} diff --git a/src/go/deploy/deploy.go b/src/go/deploy/deploy.go deleted file mode 100644 index bf679258..00000000 --- a/src/go/deploy/deploy.go +++ /dev/null @@ -1,77 +0,0 @@ -// go run src/go/deploy/deploy.go - -package main - -import ( - "context" - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "github.com/initc3/HoneyBadgerSwap/src/go_bindings/hbswap" - "github.com/initc3/HoneyBadgerSwap/src/go_bindings/hbSwapToken" - "log" - "math/big" -) - -func DeployHbSwap(conn *ethclient.Client, auth *bind.TransactOpts) common.Address { - fmt.Println("Deploying HbSwap contract...") - - var servers []common.Address - for i := 0; i < utils.N; i++ { - transactOpt := utils.GetAccount(fmt.Sprintf("poa/keystore/server_%v", i)) - servers = append(servers, transactOpt.From) - } - - hbswapAddr, tx, _, err := hbswap.DeployHbSwap(auth, conn, servers, big.NewInt(utils.T)) - if err != nil { - log.Fatalf("Failed to deploy HbSwap: %v", err) - } - - receipt, err := utils.WaitMined(context.Background(), conn, tx, 0) - if err != nil { - log.Fatalf("Failed to WaitMined HbSwap: %v", err) - } - if receipt.Status == 0 { - log.Fatalf("Transaction status: %x", receipt.Status) - } - - fmt.Println("Deployed HbSwap contract at", hbswapAddr.Hex()) - - return hbswapAddr -} - -func DeployToken(conn *ethclient.Client, auth *bind.TransactOpts) common.Address { - fmt.Println("Deploying Token contract...") - - tokenAddr, tx, _, err := hbSwapToken.DeployHbSwapToken(auth, conn) - if err != nil { - log.Fatalf("Failed to deploy Token: %v", err) - } - - receipt, err := utils.WaitMined(context.Background(), conn, tx, 0) - if err != nil { - log.Fatalf("Failed to WaitMined Token: %v", err) - } - if receipt.Status == 0 { - log.Fatalf("Transaction status: %x", receipt.Status) - } - - fmt.Println("Deployed Token contract at", tokenAddr.Hex()) - - return tokenAddr -} - -func main() { - //ethHostname := os.Args[1] - //ethUrl := utils.GetEthURL(ethHostname) - //conn := utils.GetEthClient(ethUrl) - - conn := utils.GetEthClient(utils.TestnetWsEndpoint) - owner := utils.GetAccount("poa/keystore/server_0") - - DeployHbSwap(conn, owner) - //DeployToken(conn, owner) - //DeployToken(conn, owner) -} diff --git a/src/go/reset/reset.go b/src/go/reset/reset.go deleted file mode 100644 index cb3a7ca3..00000000 --- a/src/go/reset/reset.go +++ /dev/null @@ -1,20 +0,0 @@ -// go run src/go/reset/reset.go - -package main - -import ( - "github.com/initc3/HoneyBadgerSwap/src/go/utils" -) - -const ( - network = "testnet" -) - -func main() { - conn := utils.GetEthClient(utils.TestnetWsEndpoint) - owner := utils.GetAccount("poa/keystore/server_0") - - utils.ResetPrice(network, conn, owner, utils.EthAddr, utils.HbSwapTokenAddr[network]) - utils.ResetPrice(network, conn, owner, utils.EthAddr, utils.DAIAddr[network]) - utils.ResetPrice(network, conn, owner, utils.DAIAddr[network], utils.HbSwapTokenAddr[network]) -} \ No newline at end of file diff --git a/src/go/server/lib/confparse.go b/src/go/server/lib/confparse.go deleted file mode 100644 index 868687b5..00000000 --- a/src/go/server/lib/confparse.go +++ /dev/null @@ -1,42 +0,0 @@ -package lib - -import ( - "github.com/pelletier/go-toml" - "io/ioutil" - "log" -) - -type EthNodeConfig struct { - Network string - Hostname string - HttpEndpoint string - WsEndpoint string - HttpPort int - WsPort int -} - -type _ServerConfig struct { - Id int - Host string - HttpPort int - HttpHost string -} - -type ServerConfig struct { - N int - T int - LeaderHostname string - EthNode EthNodeConfig - Servers []_ServerConfig -} - -func ParseServerConfig(configfile string) ServerConfig { - log.Println("Parsing config file: ", configfile) - data, err := ioutil.ReadFile(configfile) - if err != nil { - log.Fatal(err) - } - config := ServerConfig{} - toml.Unmarshal(data, &config) - return config -} diff --git a/src/go/server/server.go b/src/go/server/server.go deleted file mode 100644 index 01db60d5..00000000 --- a/src/go/server/server.go +++ /dev/null @@ -1,326 +0,0 @@ -package main - -import ( - "context" - "flag" - "fmt" - "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/initc3/HoneyBadgerSwap/src/go/server/lib" - "github.com/initc3/HoneyBadgerSwap/src/go/utils" - "log" - "math/big" - "os/exec" - "strconv" - "strings" - "sync" - "time" -) - -const ( - prog = "./malicious-shamir-party.x" - players = "4" - threshold = "1" - mpcPort = "5000" - blsPrime = "52435875175126190479447740508185965837690552500527637822603658699938581184513" - nshares = 1000 - spareShares = 100 - batchSize = 3 - returnPriceInterval = 10 - - confirmation = 2 - blockTime = 5 -) - -var ( - network string - serverID string - conn *ethclient.Client - server *bind.TransactOpts - mutex = &sync.Mutex{} - leaderHostname string -) - -func genInputmask() { - tot := utils.GetInputmaskCnt(network, conn) - for true { - cnt := utils.GetInputmaskCnt(network, conn) - - if cnt+spareShares >= tot { - mutex.Lock() - - log.Printf("Generating new inputmasks...\n") - - cmd := exec.Command("./random-shamir.x", "-i", serverID, "-N", players, "-T", threshold, "--nshares", strconv.Itoa(nshares), "--host", leaderHostname) - utils.ExecCmd(cmd) - - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.proc_inputmask", serverID, strconv.Itoa(int(tot))) - utils.ExecCmd(cmd) - - tot += nshares - log.Printf("Total inputmask number: %v\n", tot) - - mutex.Unlock() - } - - time.Sleep(60 * time.Second) - } -} - -func watch() { - ctx := context.Background() - - blkNum, _ := conn.BlockNumber(ctx) - for true{ - curBlockNum, _ := conn.BlockNumber(ctx) - //log.Println("curBlockNum", curBlockNum) - if curBlockNum - blkNum > confirmation { - query := ethereum.FilterQuery{ - FromBlock: big.NewInt(int64(blkNum)), - ToBlock: big.NewInt(int64(curBlockNum - confirmation)), - Addresses: []common.Address{utils.HbswapAddr[network]}, - } - logs, _ := conn.FilterLogs(ctx, query) - for _, eventLog := range logs { - switch eventLog.Topics[0].Hex() { - case utils.SecretDeposit: - oce := utils.ParseSecretDeposit(network, conn, eventLog) - - mutex.Lock() - - log.Printf("**** SecretDeposit ****\n") - - token := strings.ToLower(oce.Token.Hex()) - user := strings.ToLower(oce.User.Hex()) - amt := oce.Amt.String() // fix - - cmd := exec.Command("python3", "-m", "honeybadgerswap.server.secret_deposit", serverID, token, user, amt) - utils.ExecCmd(cmd) - - mutex.Unlock() - - case utils.SecretWithdraw: - oce := utils.ParseSecretWithdraw(network, conn, eventLog) - - mutex.Lock() - - log.Printf("**** SecretWithdraw ****\n") - - seq := oce.Seq - token := strings.ToLower(oce.Token.Hex()) - user := strings.ToLower(oce.User.Hex()) - amt := oce.Amt.String() // fix - - cmd := exec.Command("python3", "-m", "honeybadgerswap.server.secret_withdraw_set_data", serverID, user, token, amt) - utils.ExecCmd(cmd) - - cmd = exec.Command(prog, "-N", players, "-T", threshold, "-p", serverID, "-pn", mpcPort, "-P", blsPrime, "--hostname", leaderHostname, "hbswap_secret_withdraw") - utils.ExecCmd(cmd) - - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.secret_withdraw_org_data", serverID, token, user, amt) - stdout := utils.ExecCmd(cmd) - enough, _ := strconv.Atoi(stdout[:1]) - if enough == 1 { - utils.Consent(network, conn, server, seq) - } - - mutex.Unlock() - - case utils.InitPool: - oce := utils.ParseInitPool(network, conn, eventLog) - - mutex.Lock() - - log.Printf("**** InitPool ****\n") - - user := strings.ToLower(oce.User.Hex()) - tokenA := strings.ToLower(oce.TokenA.Hex()) - tokenB := strings.ToLower(oce.TokenB.Hex()) - amtA := oce.AmtA.String() // fix - amtB := oce.AmtB.String() // fix - - cmd := exec.Command("python3", "-m", "honeybadgerswap.server.init_pool_set_data", serverID, user, tokenA, tokenB, amtA, amtB) - utils.ExecCmd(cmd) - - cmd = exec.Command(prog, "-N", players, "-T", threshold, "-p", serverID, "-pn", mpcPort, "-P", blsPrime, "--hostname", leaderHostname, "hbswap_init_pool") - utils.ExecCmd(cmd) - - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.init_pool_org_data", serverID, tokenA, tokenB, user, amtA, amtB) - stdout := utils.ExecCmd(cmd) - outputs := strings.Split(stdout[:len(stdout) - 1], "\n") - validOrder, _ := strconv.Atoi(outputs[0]) - if validOrder == 1 { - price := outputs[1] - utils.UpdatePrice(network, conn, server, common.HexToAddress(tokenA), common.HexToAddress(tokenB), big.NewInt(0), price) - } - - mutex.Unlock() - - case utils.AddLiquidity: - oce := utils.ParseAddLiquidity(network, conn, eventLog) - - mutex.Lock() - - log.Printf("**** AddLiquidity ****\n") - - user := strings.ToLower(oce.User.Hex()) - tokenA := strings.ToLower(oce.TokenA.Hex()) - tokenB := strings.ToLower(oce.TokenB.Hex()) - idxA := oce.IdxA.String() - idxB := oce.IdxB.String() - maskedAmtA := oce.MaskedAmtA.String() - maskedAmtB := oce.MaskedAmtB.String() - - cmd := exec.Command("python3", "-m", "honeybadgerswap.server.add_liquidity_set_data", serverID, user, tokenA, tokenB, idxA, maskedAmtA, idxB, maskedAmtB) - utils.ExecCmd(cmd) - - cmd = exec.Command(prog, "-N", players, "-T", threshold, "-p", serverID, "-pn", mpcPort, "-P", blsPrime, "--hostname", leaderHostname, "hbswap_add_liquidity") - utils.ExecCmd(cmd) - - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.add_liquidity_org_data", serverID, user, tokenA, tokenB, user) - utils.ExecCmd(cmd) - - mutex.Unlock() - - case utils.RemoveLiquidity: - oce := utils.ParseRemoveLiquidity(network, conn, eventLog) - - mutex.Lock() - - log.Printf("**** RemoveLiquidity ****\n") - - user := strings.ToLower(oce.User.Hex()) - tokenA := strings.ToLower(oce.TokenA.Hex()) - tokenB := strings.ToLower(oce.TokenB.Hex()) - idx := oce.Idx.String() - maskedAmt := oce.MaskedAmt.String() - - cmd := exec.Command("python3", "-m", "honeybadgerswap.server.remove_liquidity_set_data", serverID, user, tokenA, tokenB, idx, maskedAmt) - utils.ExecCmd(cmd) - - cmd = exec.Command(prog, "-N", players, "-T", threshold, "-p", serverID, "-pn", mpcPort, "-P", blsPrime, "--hostname", leaderHostname, "hbswap_remove_liquidity") - utils.ExecCmd(cmd) - - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.remove_liquidity_org_data", serverID, user, tokenA, tokenB) - stdout := utils.ExecCmd(cmd) - zeroTotalLT, _ := strconv.Atoi(stdout[:1]) - if zeroTotalLT == 1 { - utils.ResetPrice(network, conn, server, common.HexToAddress(tokenA), common.HexToAddress(tokenB)) - } - - mutex.Unlock() - - case utils.Trade: - oce := utils.ParseTrade(network, conn, eventLog) - - mutex.Lock() - - log.Printf("**** Trade ****\n") - - tradeSeq := oce.TradeSeq.String() - user := strings.ToLower(oce.User.Hex()) - tokenA := strings.ToLower(oce.TokenA.Hex()) - tokenB := strings.ToLower(oce.TokenB.Hex()) - idxA := oce.IdxA.String() - idxB := oce.IdxB.String() - maskedAmtA := oce.MaskedAmtA.String() - maskedAmtB := oce.MaskedAmtB.String() - - cmd := exec.Command("python3", "-m", "honeybadgerswap.server.trade_set_data", serverID, user, tokenA, tokenB, idxA, maskedAmtA, idxB, maskedAmtB) - utils.ExecCmd(cmd) - - cmd = exec.Command(prog, "-N", players, "-T", threshold, "-p", serverID, "-pn", mpcPort, "-P", blsPrime, "--hostname", leaderHostname, "hbswap_trade") - utils.ExecCmd(cmd) - - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.trade_org_data", serverID, user, tokenA, tokenB) - stdout := utils.ExecCmd(cmd) - outputs := strings.Split(stdout, "\n") - orderSucceed, _ := strconv.Atoi(outputs[0][:1]) - - time.Sleep(returnPriceInterval * time.Second) - - balanceA := outputs[1] - balanceB := outputs[2] - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.trade_update_balance", serverID, user, tokenA, tokenB, balanceA, balanceB) - utils.ExecCmd(cmd) - - if orderSucceed == 1 { - changeB := outputs[3] - changeA := outputs[4] - - cmd := exec.Command("python3", "-m", "honeybadgerswap.server.calc_individual_price_set_data", serverID, changeB, changeA, tokenA, tokenB) - utils.ExecCmd(cmd) - - cmd = exec.Command(prog, "-N", players, "-T", threshold, "-p", serverID, "-pn", mpcPort, "-P", blsPrime, "--hostname", leaderHostname, "hbswap_calc_individual_price") - utils.ExecCmd(cmd) - - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.calc_individual_price_org_data", serverID, tokenA, tokenB, tradeSeq) - utils.ExecCmd(cmd) - - } else { - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.set_price_zero", serverID, tradeSeq) - utils.ExecCmd(cmd) - } - - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.calc_batch_price_set_data", serverID, tokenA, tokenB) - stdout = utils.ExecCmd(cmd) - cnt, _ := strconv.ParseFloat(strings.Split(stdout[:len(stdout) - 1], " ")[1], 32) - log.Println("cnt", cnt) - - if cnt >= batchSize { - cmd = exec.Command(prog, "-N", players, "-T", threshold, "-p", serverID, "-pn", mpcPort, "-P", blsPrime, "--hostname", leaderHostname, "hbswap_calc_batch_price") - stdout := utils.ExecCmd(cmd) - - cmd = exec.Command("python3", "-m", "honeybadgerswap.server.calc_batch_price_org_data", serverID, tokenA, tokenB) - stdout = utils.ExecCmd(cmd) - batchPrice := stdout[:len(stdout) - 1] - log.Println(batchPrice) - seq, _ := strconv.Atoi(tradeSeq) - utils.UpdatePrice(network, conn, server, common.HexToAddress(tokenA), common.HexToAddress(tokenB), big.NewInt(int64(seq)), batchPrice) - } - - mutex.Unlock() - } - } - blkNum = curBlockNum - confirmation + 1 - } - time.Sleep(blockTime * time.Second) - } -} - -func main() { - // parse cmd line arguments/flags - var configfile string - flag.StringVar(&configfile, "config", "/opt/hbswap/conf/server.toml", "Config file. Default: /opt/hbswap/conf/server.toml") - flag.StringVar(&serverID, "id", "0", "Server id. Default: 0") - flag.Parse() - - // parse config file - config := lib.ParseServerConfig(configfile) - - network = config.EthNode.Network - ethHostname := config.EthNode.Hostname - leaderHostname = config.LeaderHostname - log.Println("Eth network: ", network) - log.Println("Eth hostname: ", ethHostname) - log.Println("Leader hostname: ", leaderHostname) - - log.Printf("Starting mpc server %v\n", serverID) - server = utils.GetAccount(fmt.Sprintf("server_%s", serverID)) - - var wsUrl string - if network == "privatenet" { - wsUrl = utils.GetEthWsURL(ethHostname) - } else { - wsUrl = utils.TestnetWsEndpoint - } - conn = utils.GetEthClient(wsUrl) - - var wg sync.WaitGroup - wg.Add(1) - go genInputmask() - go watch() - wg.Wait() -} diff --git a/src/go/utils/utils.go b/src/go/utils/utils.go deleted file mode 100644 index 07d2c15d..00000000 --- a/src/go/utils/utils.go +++ /dev/null @@ -1,216 +0,0 @@ -package utils - -import ( - "bytes" - "context" - "errors" - "fmt" - "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethclient" - "io/ioutil" - "log" - "math/big" - "net" - "net/url" - "os" - "os/exec" - "path/filepath" - "strings" - "time" -) - -const ( - N = 4 - T = 1 -) - -var ( - GOPATH = os.Getenv("GOPATH") - KEYSTORE = os.Getenv("POA_KEYSTORE") - minBalance = big.NewInt(300000000000000000) - - chainID = map[string]string{ - "testnet": "42", - "privatenet": "123", - } - - EthAddr = common.HexToAddress("0x0000000000000000000000000000000000000000") - HbswapAddr = map[string]common.Address{ - "testnet": common.HexToAddress("0xbc003e9dffe7306e6e414197267581fd732fe8b4"), - "privatenet": common.HexToAddress("0xf74eb25ab1785d24306ca6b3cbff0d0b0817c5e2"), - } - HbSwapTokenAddr = map[string]common.Address{ - "testnet": common.HexToAddress("0x78160ee9e55fd81626f98d059c84d21d8b71bfda"), - } - DAIAddr = map[string]common.Address{ - "testnet": common.HexToAddress("0x4f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa"), - } - //TODO: delete it after testing - UserAddr = common.HexToAddress("0xc33a4b5b609fcc294dca060347761226e78c0b7a") - - HttpPort = 8545 - WsPort = 8546 - - TestnetHttpEndpoint = "https://kovan.infura.io/v3/6a82d2519efb4d748c02552e02e369c1" - TestnetWsEndpoint = "wss://kovan.infura.io/ws/v3/6a82d2519efb4d748c02552e02e369c1" - - AddLiquidity = "0xec7d4752dd44bf7fc59045c9d80163de2a1b9dbd9032d11cb1156f7f867c6411" - InitPool = "0xfaaebcb30b1b421f4f2ca7f2620e5add6a64532c087ee0646fd665a33d36fdf5" - RemoveLiquidity = "0xa8dbaaebbb025c88e9e34c84635cd8238043556e9af43fb161508c898a8e1ef9" - SecretDeposit = "0x07c06144435b7d2bdccf9ee7e5a7022c63382ac7c3a0e14ed08b5969dedf0ecf" - SecretWithdraw = "0x4ef3cc4825a92c3b6922acc8a45152cc96ef48463e8ed500dacd5df9e29a67f3" - Trade = "0x2b4d91cd20cc8800407e3614b8466a6f0729ac3b1fa43d4e2b059ff5593cbae6" -) - -func ExecCmd(cmd *exec.Cmd) string { - log.Printf("Cmd:\n====================\n%v\n====================\n", cmd) - var stdout, stderr bytes.Buffer - cmd.Stdout = &stdout - cmd.Stderr = &stderr - start := time.Now() - err := cmd.Run() - duration := time.Since(start) - log.Printf("Execution time: %s\n", duration) - if err != nil { - log.Printf("err:\n%s\n", stderr.String()) - log.Fatalf("cmd.Run() failed with %s\n", err) - } - log.Printf("Output:\n====================\n%s====================\n", stdout.String()) - return stdout.String() -} - -func StrToBig(st string) *big.Int { - v, _ := new(big.Int).SetString(st, 10) - return v -} - -func GetEthClient(ethInstance string) *ethclient.Client { - conn, err := ethclient.Dial(ethInstance) - if err != nil { - log.Fatal(err) - } - - return conn -} - -func GetAccount(account string) *bind.TransactOpts { - dir := filepath.Join(KEYSTORE, account) - - list, err := ioutil.ReadDir(dir) - if err != nil { - log.Printf("Error reading directory %s", dir) - log.Fatal(err) - } - - var name string - for _, info := range list { - name = info.Name() - if err != nil { - log.Fatal(err) - } - } - - //bytes, err := ioutil.ReadFile(dir + name) - bytes, err := ioutil.ReadFile(filepath.Join(dir, name)) - if err != nil { - log.Fatal(err) - } - - password := "" - auth, err := bind.NewTransactor(strings.NewReader(string(bytes)), password) - if err != nil { - log.Fatal(err) - } - - auth.GasLimit = 8000000 - - return auth -} - -func WaitMined(ctx context.Context, ec *ethclient.Client, - tx *types.Transaction, blockDelay uint64) (*types.Receipt, error) { - const missingFieldErr = "missing required field 'transactionHash' for Log" - - if ec == nil { - return nil, errors.New("nil ethclient") - } - queryTicker := time.NewTicker(time.Second) - defer queryTicker.Stop() - txHashBytes := common.HexToHash(tx.Hash().Hex()) - for { - receipt, rerr := ec.TransactionReceipt(ctx, txHashBytes) - if rerr == nil { - if blockDelay == 0 { - return receipt, rerr - } - break - } else if rerr == ethereum.NotFound || rerr.Error() == missingFieldErr { - select { - case <-ctx.Done(): - return nil, ctx.Err() - case <-queryTicker.C: - } - } else { - return receipt, rerr - } - } - ddl := big.NewInt(0) - latestBlockHeader, err := ec.HeaderByNumber(ctx, nil) - if err == nil { - ddl.Add(new(big.Int).SetUint64(blockDelay), latestBlockHeader.Number) - } - for { - latestBlockHeader, err := ec.HeaderByNumber(ctx, nil) - if err == nil && ddl.Cmp(latestBlockHeader.Number) < 0 { - receipt, rerr := ec.TransactionReceipt(ctx, txHashBytes) - if rerr == nil { - return receipt, rerr - } else if rerr == ethereum.NotFound || rerr.Error() == missingFieldErr { - return nil, errors.New("tx is dropped due to chain re-org") - } else { - return receipt, rerr - } - } - select { - case <-ctx.Done(): - return nil, ctx.Err() - case <-queryTicker.C: - } - } -} - -func stringToBigInt(v string) *big.Int { - value := big.NewInt(0) - value.SetString(v, 10) - return value -} - -func GetIPAddr(hostname string) net.IP { - addrs, err := net.LookupIP(hostname) - if err != nil { - fmt.Sprintf("Error looking up hostname %s", hostname) - log.Fatal(err) - } - return addrs[0] -} - -func GetURL(hostname string, port int, scheme string) string { - addr := GetIPAddr(hostname) - host := fmt.Sprintf("%s:%d", addr, port) - u := &url.URL{ - Scheme: scheme, - Host: host, - } - return u.String() -} - -func GetEthURL(hostname string) string { - return GetURL(hostname, HttpPort, "http") -} - -func GetEthWsURL(hostname string) string { - return GetURL(hostname, WsPort, "ws") -} \ No newline at end of file diff --git a/src/go/utils/utils_eth.go b/src/go/utils/utils_eth.go deleted file mode 100644 index b89a46e2..00000000 --- a/src/go/utils/utils_eth.go +++ /dev/null @@ -1,92 +0,0 @@ -package utils - -import ( - "context" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethclient" - "log" - "math/big" -) - -/********** external functions **********/ - -func FundETH(network string, conn *ethclient.Client, toAddr common.Address, amount *big.Int) { - log.Println("FundEth ...") - adminAuth := GetAccount("poa/keystore/server_0") - transferETH(conn, chainID[network], adminAuth, toAddr, amount) - - //balance := GetBalanceETH(conn, toAddr) - //fmt.Printf("Funded account %s to %v ETH\n", toAddr.Hex(), balance) -} - -func GetBalanceETH(conn *ethclient.Client, addr common.Address) *big.Int { - balance, err := conn.BalanceAt(context.Background(), addr, nil) - if err != nil { - log.Fatal(err) - } - - return balance -} - -/********** internal functions **********/ -func fundGas(network string, conn *ethclient.Client, toAddr common.Address) { - balance := GetBalanceETH(conn, toAddr) - amount := minBalance - if balance.Cmp(amount) != -1 { - //fmt.Printf("Funded %s to %v ETH on mainchain\n", toAddr.Hex(), balance) - return - } - amount.Sub(amount, balance) - - adminAuth := GetAccount("server_0") - transferETH(conn, chainID[network], adminAuth, toAddr, amount) - - balance = GetBalanceETH(conn, toAddr) - //fmt.Printf("Funded account %s to %v ETH\n", toAddr.Hex(), balance) -} - -func transferETH(conn *ethclient.Client, chainId string, fromAuth *bind.TransactOpts, toAddr common.Address, amount *big.Int) { - log.Println("transferETH ...") - ctx := context.Background() - - log.Printf("transfer ctx: %s", ctx) - fromAddr := fromAuth.From - - nonce, err := conn.PendingNonceAt(ctx, fromAddr) - if err != nil { - log.Printf("getting nonce error for address: %s, and context: %s", fromAddr.Hex(), ctx) - log.Fatal(err) - } - - gasLimit := uint64(300000) // in units - gasPrice, err := conn.SuggestGasPrice(ctx) - if err != nil { - log.Fatal(err) - } - - tx := types.NewTransaction(nonce, toAddr, amount, gasLimit, gasPrice, nil) - signedTx, err := fromAuth.Signer(fromAddr, tx) - if err != nil { - log.Fatal(err) - } - - log.Printf("Sending %v wei from %s to %s\n", amount, fromAddr.Hex(), toAddr.Hex()) - err = conn.SendTransaction(ctx, signedTx) - if err != nil { - log.Fatal(err) - transferETH(conn, chainId, fromAuth, toAddr, amount) - } - - //fmt.Printf("Waiting for transaction to be mined...\n") - receipt, err := WaitMined(ctx, conn, signedTx, 0) - if err != nil { - log.Fatal(err) - transferETH(conn, chainId, fromAuth, toAddr, amount) - } - if receipt.Status == 0 { - log.Fatalf("Transaction status: %x", receipt.Status) - transferETH(conn, chainId, fromAuth, toAddr, amount) - } -} diff --git a/src/go/utils/utils_hbswap.go b/src/go/utils/utils_hbswap.go deleted file mode 100644 index 188b1776..00000000 --- a/src/go/utils/utils_hbswap.go +++ /dev/null @@ -1,466 +0,0 @@ -package utils - -import ( - "context" - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/initc3/HoneyBadgerSwap/src/go_bindings/hbswap" - "log" - "math/big" - "time" -) - -//func Deposit(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenAddr common.Address, amt *big.Int) { -// fmt.Printf("Deposit user %s %v token %s\n", auth.From.Hex(), amt, tokenAddr.Hex()) -// hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) -// if err != nil { -// log.Fatal(err) -// } -// -// fundGas(network, conn, auth.From) -// tx, err := hbswapInstance.Deposit(auth, tokenAddr, amt) -// if err != nil { -// log.Fatal(err) -// } -// -// receipt, err := WaitMined(context.Background(), conn, tx, 0) -// if err != nil { -// log.Fatal(err) -// } -// -// if receipt.Status == 0 { -// log.Fatalf("Transaction status: %v", receipt.Status) -// } -//} -// -//func SecretDeposit(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenAddr common.Address, amt *big.Int) { -// hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) -// if err != nil { -// log.Fatal(err) -// } -// -// fundGas(network, conn, auth.From) -// fmt.Printf("SecretDeposit %s %v\n", tokenAddr.String(), amt) -// tx, err := hbswapInstance.SecretDeposit(auth, tokenAddr, amt) -// if err != nil { -// log.Fatal(err) -// } -// -// receipt, err := WaitMined(context.Background(), conn, tx, 0) -// if err != nil { -// log.Fatal(err) -// } -// -// if receipt.Status == 0 { -// log.Fatalf("Transaction status: %v", receipt.Status) -// } -//} -// -//func Withdraw(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenAddr common.Address, amt *big.Int) { -// hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) -// if err != nil { -// log.Fatal(err) -// } -// -// fundGas(network, conn, auth.From) -// tx, err := hbswapInstance.Withdraw(auth, tokenAddr, amt) -// if err != nil { -// log.Fatal(err) -// } -// -// receipt, err := WaitMined(context.Background(), conn, tx, 0) -// if err != nil { -// log.Fatal(err) -// } -// -// if receipt.Status == 0 { -// log.Fatalf("Transaction status: %v", receipt.Status) -// } -//} -// -//func SecretWithdraw(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenAddr common.Address, amt *big.Int) { -// fmt.Printf("secret withdraw %s\n", tokenAddr.Hex()) -// hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) -// if err != nil { -// log.Fatal(err) -// } -// -// prevBalance := GetBalance(network, conn, tokenAddr, auth.From).Int64() -// -// fundGas(network, conn, auth.From) -// tx, err := hbswapInstance.SecretWithdraw(auth, tokenAddr, amt) -// if err != nil { -// log.Fatal(err) -// } -// -// receipt, err := WaitMined(context.Background(), conn, tx, 0) -// if err != nil { -// log.Fatal(err) -// } -// -// if receipt.Status == 0 { -// log.Fatalf("Transaction status: %v", receipt.Status) -// } -// -// //fmt.Printf("current balance %v\n", prevBalance) -// for true { -// time.Sleep(10 * time.Second) -// balance := GetBalance(network, conn, tokenAddr, auth.From).Int64() -// //fmt.Printf("current balance %v\n", balance) -// if prevBalance+amt.Int64() == balance { -// break -// } -// } -//} -// -//func ReserveInput(network string, conn *ethclient.Client, auth *bind.TransactOpts, num *big.Int) []int64 { -// hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) -// if err != nil { -// log.Fatal(err) -// } -// -// fundGas(network, conn, auth.From) -// tx, err := hbswapInstance.ReserverInput(auth, num) -// if err != nil { -// log.Fatal(err) -// } -// -// receipt, err := WaitMined(context.Background(), conn, tx, 0) -// if err != nil { -// log.Fatal(err) -// } -// -// if receipt.Status == 0 { -// log.Fatalf("Transaction status: %v", receipt.Status) -// } -// -// var inputMaskIndexes []int64 -// //TODO: fix below -// data := receipt.Logs[0].Data -// idxSell, err := strconv.ParseInt(common.Bytes2Hex(data[1*32:2*32]), 16, 64) -// if err != nil { -// log.Fatal(err) -// } -// idxBuy, err := strconv.ParseInt(common.Bytes2Hex(data[2*32:3*32]), 16, 64) -// if err != nil { -// log.Fatal(err) -// } -// -// fmt.Printf("idxSell:%v idxBuy:%v\n", idxSell, idxBuy) -// return idxSell, idxBuy -//} - -//func InitPool(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenA common.Address, tokenB common.Address, amtA *big.Int, amtB *big.Int) { -// hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) -// if err != nil { -// log.Fatal(err) -// } -// -// fundGas(network, conn, auth.From) -// tx, err := hbswapInstance.InitPool(auth, tokenA, tokenB, amtA, amtB) -// if err != nil { -// log.Fatal(err) -// } -// -// receipt, err := WaitMined(context.Background(), conn, tx, 0) -// if err != nil { -// log.Fatal(err) -// } -// -// if receipt.Status == 0 { -// log.Fatalf("Transaction status: %v", receipt.Status) -// } -//} -// -//func AddLiquidity(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenA common.Address, tokenB common.Address, idxA *big.Int, idxB *big.Int, maskedAmtA *big.Int, maskedAmtB *big.Int) { -// hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) -// if err != nil { -// log.Fatal(err) -// } -// -// fundGas(network, conn, auth.From) -// tx, err := hbswapInstance.AddLiquidity(auth, tokenA, tokenB, idxA, idxB, maskedAmtA, maskedAmtB) -// if err != nil { -// log.Fatal(err) -// } -// -// receipt, err := WaitMined(context.Background(), conn, tx, 0) -// if err != nil { -// log.Fatal(err) -// } -// -// if receipt.Status == 0 { -// log.Fatalf("Transaction status: %v", receipt.Status) -// } -//} -// -//func RemoveLiquidity(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenA common.Address, tokenB common.Address, idx *big.Int, amt *big.Int) { -// hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) -// if err != nil { -// log.Fatal(err) -// } -// -// fundGas(network, conn, auth.From) -// tx, err := hbswapInstance.RemoveLiquidity(auth, tokenA, tokenB, idx, amt) -// if err != nil { -// log.Fatal(err) -// } -// -// receipt, err := WaitMined(context.Background(), conn, tx, 0) -// if err != nil { -// log.Fatal(err) -// } -// -// if receipt.Status == 0 { -// log.Fatalf("Transaction status: %v", receipt.Status) -// } -//} - -func Consent(network string, conn *ethclient.Client, auth *bind.TransactOpts, seq *big.Int) { - log.Printf("Consent seq %v\n", seq) - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - fundGas(network, conn, auth.From) - tx, err := hbswapInstance.Consent(auth, seq) - if err != nil { - log.Fatal(err) - } - - receipt, err := WaitMined(context.Background(), conn, tx, 0) - if err != nil { - log.Fatal(err) - } - - if receipt.Status == 0 { - log.Fatalf("Transaction status: %v", receipt.Status) - } - - log.Printf("Consent seq %v done\n", seq) -} - -//func Trade(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenA common.Address, tokenB common.Address, idxA *big.Int, idxB *big.Int, maskedAmtA *big.Int, maskedAmtB *big.Int) { -// hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) -// if err != nil { -// log.Fatal(err) -// } -// -// fundGas(network, conn, auth.From) -// tx, err := hbswapInstance.Trade(auth, tokenA, tokenB, idxA, idxB, maskedAmtA, maskedAmtB) -// if err != nil { -// log.Fatal(err) -// } -// -// receipt, err := WaitMined(context.Background(), conn, tx, 0) -// if err != nil { -// log.Fatal(err) -// } -// -// if receipt.Status == 0 { -// log.Fatalf("Transaction status: %v", receipt.Status) -// } -// -// data := receipt.Logs[0].Data -// tradeSeq, err := strconv.ParseInt(common.Bytes2Hex(data[0*32:1*32]), 16, 64) -// if err != nil { -// log.Fatal(err) -// } -// fmt.Printf("tradeSeq %v txHash %s\n", tradeSeq, tx.Hash().Hex()) -//} - -func UpdatePrice(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenA common.Address, tokenB common.Address, checkpointSeq *big.Int, price string) { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - GetPrice(network, conn, tokenA, tokenB) - - fundGas(network, conn, auth.From) - tx, err := hbswapInstance.UpdatePrice(auth, tokenA, tokenB, checkpointSeq, price) - if err != nil { - log.Fatal(err) - } - - receipt, err := WaitMined(context.Background(), conn, tx, 0) - if err != nil { - log.Fatal(err) - } - - if receipt.Status == 0 { - log.Fatalf("Transaction status: %v", receipt.Status) - } - - GetPrice(network, conn, tokenA, tokenB) -} - -func ResetPrice(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenA common.Address, tokenB common.Address) { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - price := GetPrice(network, conn, tokenA, tokenB) - if price == "" { - return - } - - var servers []common.Address - for i := 0; i < N; i++ { - transactOpt := GetAccount(fmt.Sprintf("poa/keystore/server_%v", i)) - servers = append(servers, transactOpt.From) - } - - log.Println("ResetPrice") - tx, err := hbswapInstance.ResetPrice(auth, tokenA, tokenB, servers) - if err != nil { - log.Fatal(err) - } - - receipt, err := WaitMined(context.Background(), conn, tx, 0) - if err != nil { - log.Fatal(err) - } - - if receipt.Status == 0 { - log.Fatalf("Transaction status: %v", receipt.Status) - } -} - -func ResetBalance(network string, conn *ethclient.Client, auth *bind.TransactOpts, token common.Address, user common.Address) { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - balance := GetBalance(network, conn, token, user) - if balance.Cmp(big.NewInt(0)) == 0 { - return - } - - log.Printf("ResetBalance token %s user %s\n", token.Hex(), user.Hex()) - tx, err := hbswapInstance.ResetBalance(auth, token, user) - if err != nil { - log.Fatal(err) - } - - receipt, err := WaitMined(context.Background(), conn, tx, 0) - if err != nil { - log.Fatal(err) - } - - if receipt.Status == 0 { - log.Fatalf("Transaction status: %v", receipt.Status) - } - - GetBalance(network, conn, token, user) -} - -/******** read-only ********/ - -func GetBalance(network string, conn *ethclient.Client, token common.Address, user common.Address) *big.Int { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - balance, _ := hbswapInstance.PublicBalance(nil, token, user) - log.Printf("GetBalance token %s user %s balance %v\n", token.Hex(), user.Hex(), balance) - - return balance -} - -func GetInputmaskCnt(network string, conn *ethclient.Client) int64 { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - cnt, err := hbswapInstance.InputmaskCnt(nil) - for err != nil { - log.Println(err) - time.Sleep(time.Second) - cnt, err = hbswapInstance.InputmaskCnt(nil) - } - log.Printf("Inputmask shares used: %v\n", cnt) - - return cnt.Int64() -} - -func GetPrice(network string, conn *ethclient.Client, tokenA common.Address, tokenB common.Address) string { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - price, _ := hbswapInstance.Prices(nil, tokenA, tokenB) - log.Printf("price: %v\n", price) - - return price -} - -/******** parse event ********/ -func ParseSecretDeposit(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapSecretDeposit { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - event, _ := hbswapInstance.HbSwapFilterer.ParseSecretDeposit(eventLog) - return event -} - -func ParseSecretWithdraw(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapSecretWithdraw { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - event, _ := hbswapInstance.HbSwapFilterer.ParseSecretWithdraw(eventLog) - return event -} - -func ParseInitPool(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapInitPool { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - event, _ := hbswapInstance.HbSwapFilterer.ParseInitPool(eventLog) - return event -} - -func ParseAddLiquidity(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapAddLiquidity { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - event, _ := hbswapInstance.HbSwapFilterer.ParseAddLiquidity(eventLog) - return event -} - -func ParseRemoveLiquidity(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapRemoveLiquidity { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - event, _ := hbswapInstance.HbSwapFilterer.ParseRemoveLiquidity(eventLog) - return event -} - -func ParseTrade(network string, conn *ethclient.Client, eventLog types.Log) *hbswap.HbSwapTrade { - hbswapInstance, err := hbswap.NewHbSwap(HbswapAddr[network], conn) - if err != nil { - log.Fatal(err) - } - - event, _ := hbswapInstance.HbSwapFilterer.ParseTrade(eventLog) - return event -} \ No newline at end of file diff --git a/src/go/utils/utils_pq.go b/src/go/utils/utils_pq.go deleted file mode 100644 index bff46fff..00000000 --- a/src/go/utils/utils_pq.go +++ /dev/null @@ -1,48 +0,0 @@ -package utils - -type EventID struct { - BlockNumber uint64 - TxIndex uint - LogIndex uint -} - -func (a *EventID) Less(b *EventID) bool { - if a.BlockNumber != b.BlockNumber { - return a.BlockNumber < b.BlockNumber - } - if a.TxIndex != b.TxIndex { - return a.TxIndex < b.TxIndex - } - return a.LogIndex < b.LogIndex -} - -type Task struct { - EventID EventID - - EventName string - Parameters []string -} - -type PriorityQueue []*Task - -func (pq PriorityQueue) Len() int { return len(pq) } - -func (pq PriorityQueue) Less(i, j int) bool { - return pq[i].EventID.Less(&pq[j].EventID) -} - -func (pq PriorityQueue) Swap(i, j int) { - pq[i], pq[j] = pq[j], pq[i] -} - -func (pq *PriorityQueue) Push(x interface{}) { - *pq = append(*pq, x.(*Task)) -} - -func (pq *PriorityQueue) Pop() interface{} { - old := *pq - n := len(old) - task := old[n-1] - *pq = old[0 : n-1] - return task -} \ No newline at end of file diff --git a/src/go/utils/utils_token.go b/src/go/utils/utils_token.go deleted file mode 100644 index 40c4b51d..00000000 --- a/src/go/utils/utils_token.go +++ /dev/null @@ -1,83 +0,0 @@ -package utils - -import ( - "context" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient" - "github.com/initc3/HoneyBadgerSwap/src/go_bindings/hbSwapToken" - "log" - "math/big" -) - -func FundToken(conn *ethclient.Client, tokenAddr common.Address, toAddr common.Address, amount *big.Int) { - balance := GetBalanceToken(conn, toAddr, tokenAddr) - if balance.Cmp(amount) != -1 { - //fmt.Printf("Funded account %s to %v token\n", toAddr.Hex(), balance) - return - } - amount.Sub(amount, balance) - - adminAuth := GetAccount("poa/keystore/server_0") - transferToken(conn, tokenAddr, adminAuth, toAddr, amount) - - balance = GetBalanceToken(conn, toAddr, tokenAddr) - //fmt.Printf("Funded account %s to %v token\n", toAddr.Hex(), balance) -} - -func Approve(network string, conn *ethclient.Client, auth *bind.TransactOpts, tokenAddr common.Address, receiver common.Address, amt *big.Int) { - tokenInstance, err := hbSwapToken.NewHbSwapToken(tokenAddr, conn) - if err != nil { - log.Fatal(err) - } - - fundGas(network, conn, auth.From) - tx, err := tokenInstance.Approve(auth, receiver, amt) - if err != nil { - log.Fatal(err) - } - - receipt, err := WaitMined(context.Background(), conn, tx, 0) - if err != nil { - log.Fatal(err) - } - - if receipt.Status == 0 { - log.Fatalf("Transaction status: %v", receipt.Status) - } -} - -func GetBalanceToken(conn *ethclient.Client, addr common.Address, tokenAddr common.Address) *big.Int { - tokenInstance, err := hbSwapToken.NewHbSwapToken(tokenAddr, conn) - if err != nil { - log.Fatal(err) - } - - balance, err := tokenInstance.BalanceOf(nil, addr) - if err != nil { - log.Fatal(err) - } - return balance -} - -func transferToken(conn *ethclient.Client, tokenAddr common.Address, fromAuth *bind.TransactOpts, toAddr common.Address, value *big.Int) { - //fmt.Printf("Trasfering %v token from %s to %s\n", value, fromAuth.From.Hex(), toAddr.Hex()) - - tokenInstance, err := hbSwapToken.NewHbSwapToken(tokenAddr, conn) - if err != nil { - log.Fatal(err) - } - - tx, err := tokenInstance.Transfer(fromAuth, toAddr, value) - if err != nil { - log.Fatal(err) - } - - receipt, err := WaitMined(context.Background(), conn, tx, 0) - if err != nil { - log.Fatal(err) - } - if receipt.Status == 0 { - log.Fatalf("Transaction status: %x", receipt.Status) - } -} diff --git a/src/go_bindings/hbSwapToken/hbSwapToken.go b/src/go_bindings/hbSwapToken/hbSwapToken.go deleted file mode 100644 index 3838b14b..00000000 --- a/src/go_bindings/hbSwapToken/hbSwapToken.go +++ /dev/null @@ -1,850 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package hbSwapToken - -import ( - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription -) - -// HbSwapTokenABI is the input ABI used to generate the binding from. -const HbSwapTokenABI = "[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[],\"name\":\"DECIMALS\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"INITIAL_SUPPLY\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - -// HbSwapTokenBin is the compiled bytecode used for deploying new contracts. -var HbSwapTokenBin = "0x60806040523480156200001157600080fd5b506040518060400160405280600b81526020017f486253776170546f6b656e0000000000000000000000000000000000000000008152506040518060400160405280600381526020017f4842530000000000000000000000000000000000000000000000000000000000815250601282600390805190602001906200009892919062000347565b508160049080519060200190620000b192919062000347565b5080600560006101000a81548160ff021916908360ff160217905550505050620000ee336b204fce5e3e25026110000000620000f460201b60201c565b620003f6565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141562000198576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f45524332303a206d696e7420746f20746865207a65726f20616464726573730081525060200191505060405180910390fd5b620001b481600254620002be60201b62000f9f1790919060201c565b60028190555062000212816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054620002be60201b62000f9f1790919060201c565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a35050565b6000808284019050838110156200033d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b8091505092915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200038a57805160ff1916838001178555620003bb565b82800160010185558215620003bb579182015b82811115620003ba5782518255916020019190600101906200039d565b5b509050620003ca9190620003ce565b5090565b620003f391905b80821115620003ef576000816000905550600101620003d5565b5090565b90565b61115d80620004066000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063313ce5671161008c57806395d89b411161006657806395d89b4114610385578063a457c2d714610408578063a9059cbb1461046e578063dd62ed3e146104d4576100cf565b8063313ce567146102a357806339509351146102c757806370a082311461032d576100cf565b806306fdde03146100d4578063095ea7b31461015757806318160ddd146101bd57806323b872dd146101db5780632e0f2625146102615780632ff2e9dc14610285575b600080fd5b6100dc61054c565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561011c578082015181840152602081019050610101565b50505050905090810190601f1680156101495780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101a36004803603604081101561016d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506105ee565b604051808215151515815260200191505060405180910390f35b6101c561060c565b6040518082815260200191505060405180910390f35b610247600480360360608110156101f157600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610616565b604051808215151515815260200191505060405180910390f35b6102696106ef565b604051808260ff1660ff16815260200191505060405180910390f35b61028d6106f4565b6040518082815260200191505060405180910390f35b6102ab610704565b604051808260ff1660ff16815260200191505060405180910390f35b610313600480360360408110156102dd57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919050505061071b565b604051808215151515815260200191505060405180910390f35b61036f6004803603602081101561034357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506107ce565b6040518082815260200191505060405180910390f35b61038d610816565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103cd5780820151818401526020810190506103b2565b50505050905090810190601f1680156103fa5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6104546004803603604081101561041e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506108b8565b604051808215151515815260200191505060405180910390f35b6104ba6004803603604081101561048457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050610985565b604051808215151515815260200191505060405180910390f35b610536600480360360408110156104ea57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506109a3565b6040518082815260200191505060405180910390f35b606060038054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156105e45780601f106105b9576101008083540402835291602001916105e4565b820191906000526020600020905b8154815290600101906020018083116105c757829003601f168201915b5050505050905090565b60006106026105fb610a2a565b8484610a32565b6001905092915050565b6000600254905090565b6000610623848484610c29565b6106e48461062f610a2a565b6106df8560405180606001604052806028815260200161109360289139600160008b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000610695610a2a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610edf9092919063ffffffff16565b610a32565b600190509392505050565b601281565b6b204fce5e3e2502611000000081565b6000600560009054906101000a900460ff16905090565b60006107c4610728610a2a565b846107bf8560016000610739610a2a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008973ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f9f90919063ffffffff16565b610a32565b6001905092915050565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b606060048054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156108ae5780601f10610883576101008083540402835291602001916108ae565b820191906000526020600020905b81548152906001019060200180831161089157829003601f168201915b5050505050905090565b600061097b6108c5610a2a565b846109768560405180606001604052806025815260200161110460259139600160006108ef610a2a565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008a73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610edf9092919063ffffffff16565b610a32565b6001905092915050565b6000610999610992610a2a565b8484610c29565b6001905092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ab8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260248152602001806110e06024913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610b3e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602281526020018061104b6022913960400191505060405180910390fd5b80600160008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925836040518082815260200191505060405180910390a3505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610caf576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260258152602001806110bb6025913960400191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415610d35576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260238152602001806110286023913960400191505060405180910390fd5b610da08160405180606001604052806026815260200161106d602691396000808773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610edf9092919063ffffffff16565b6000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550610e33816000808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054610f9f90919063ffffffff16565b6000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040518082815260200191505060405180910390a3505050565b6000838311158290610f8c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610f51578082015181840152602081019050610f36565b50505050905090810190601f168015610f7e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5060008385039050809150509392505050565b60008082840190508381101561101d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601b8152602001807f536166654d6174683a206164646974696f6e206f766572666c6f77000000000081525060200191505060405180910390fd5b809150509291505056fe45524332303a207472616e7366657220746f20746865207a65726f206164647265737345524332303a20617070726f766520746f20746865207a65726f206164647265737345524332303a207472616e7366657220616d6f756e7420657863656564732062616c616e636545524332303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636545524332303a207472616e736665722066726f6d20746865207a65726f206164647265737345524332303a20617070726f76652066726f6d20746865207a65726f206164647265737345524332303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726fa265627a7a723158209635ee1504e4a1dc75ee1aa82dc07efbd187ee0e3805ceaaf097245eb422231764736f6c63430005110032" - -// DeployHbSwapToken deploys a new Ethereum contract, binding an instance of HbSwapToken to it. -func DeployHbSwapToken(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *HbSwapToken, error) { - parsed, err := abi.JSON(strings.NewReader(HbSwapTokenABI)) - if err != nil { - return common.Address{}, nil, nil, err - } - - address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(HbSwapTokenBin), backend) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &HbSwapToken{HbSwapTokenCaller: HbSwapTokenCaller{contract: contract}, HbSwapTokenTransactor: HbSwapTokenTransactor{contract: contract}, HbSwapTokenFilterer: HbSwapTokenFilterer{contract: contract}}, nil -} - -// HbSwapToken is an auto generated Go binding around an Ethereum contract. -type HbSwapToken struct { - HbSwapTokenCaller // Read-only binding to the contract - HbSwapTokenTransactor // Write-only binding to the contract - HbSwapTokenFilterer // Log filterer for contract events -} - -// HbSwapTokenCaller is an auto generated read-only Go binding around an Ethereum contract. -type HbSwapTokenCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// HbSwapTokenTransactor is an auto generated write-only Go binding around an Ethereum contract. -type HbSwapTokenTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// HbSwapTokenFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type HbSwapTokenFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// HbSwapTokenSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type HbSwapTokenSession struct { - Contract *HbSwapToken // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// HbSwapTokenCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type HbSwapTokenCallerSession struct { - Contract *HbSwapTokenCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// HbSwapTokenTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type HbSwapTokenTransactorSession struct { - Contract *HbSwapTokenTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// HbSwapTokenRaw is an auto generated low-level Go binding around an Ethereum contract. -type HbSwapTokenRaw struct { - Contract *HbSwapToken // Generic contract binding to access the raw methods on -} - -// HbSwapTokenCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type HbSwapTokenCallerRaw struct { - Contract *HbSwapTokenCaller // Generic read-only contract binding to access the raw methods on -} - -// HbSwapTokenTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type HbSwapTokenTransactorRaw struct { - Contract *HbSwapTokenTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewHbSwapToken creates a new instance of HbSwapToken, bound to a specific deployed contract. -func NewHbSwapToken(address common.Address, backend bind.ContractBackend) (*HbSwapToken, error) { - contract, err := bindHbSwapToken(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &HbSwapToken{HbSwapTokenCaller: HbSwapTokenCaller{contract: contract}, HbSwapTokenTransactor: HbSwapTokenTransactor{contract: contract}, HbSwapTokenFilterer: HbSwapTokenFilterer{contract: contract}}, nil -} - -// NewHbSwapTokenCaller creates a new read-only instance of HbSwapToken, bound to a specific deployed contract. -func NewHbSwapTokenCaller(address common.Address, caller bind.ContractCaller) (*HbSwapTokenCaller, error) { - contract, err := bindHbSwapToken(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &HbSwapTokenCaller{contract: contract}, nil -} - -// NewHbSwapTokenTransactor creates a new write-only instance of HbSwapToken, bound to a specific deployed contract. -func NewHbSwapTokenTransactor(address common.Address, transactor bind.ContractTransactor) (*HbSwapTokenTransactor, error) { - contract, err := bindHbSwapToken(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &HbSwapTokenTransactor{contract: contract}, nil -} - -// NewHbSwapTokenFilterer creates a new log filterer instance of HbSwapToken, bound to a specific deployed contract. -func NewHbSwapTokenFilterer(address common.Address, filterer bind.ContractFilterer) (*HbSwapTokenFilterer, error) { - contract, err := bindHbSwapToken(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &HbSwapTokenFilterer{contract: contract}, nil -} - -// bindHbSwapToken binds a generic wrapper to an already deployed contract. -func bindHbSwapToken(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(HbSwapTokenABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_HbSwapToken *HbSwapTokenRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _HbSwapToken.Contract.HbSwapTokenCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_HbSwapToken *HbSwapTokenRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _HbSwapToken.Contract.HbSwapTokenTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_HbSwapToken *HbSwapTokenRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _HbSwapToken.Contract.HbSwapTokenTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_HbSwapToken *HbSwapTokenCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _HbSwapToken.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_HbSwapToken *HbSwapTokenTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _HbSwapToken.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_HbSwapToken *HbSwapTokenTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _HbSwapToken.Contract.contract.Transact(opts, method, params...) -} - -// DECIMALS is a free data retrieval call binding the contract method 0x2e0f2625. -// -// Solidity: function DECIMALS() view returns(uint8) -func (_HbSwapToken *HbSwapTokenCaller) DECIMALS(opts *bind.CallOpts) (uint8, error) { - var out []interface{} - err := _HbSwapToken.contract.Call(opts, &out, "DECIMALS") - - if err != nil { - return *new(uint8), err - } - - out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) - - return out0, err - -} - -// DECIMALS is a free data retrieval call binding the contract method 0x2e0f2625. -// -// Solidity: function DECIMALS() view returns(uint8) -func (_HbSwapToken *HbSwapTokenSession) DECIMALS() (uint8, error) { - return _HbSwapToken.Contract.DECIMALS(&_HbSwapToken.CallOpts) -} - -// DECIMALS is a free data retrieval call binding the contract method 0x2e0f2625. -// -// Solidity: function DECIMALS() view returns(uint8) -func (_HbSwapToken *HbSwapTokenCallerSession) DECIMALS() (uint8, error) { - return _HbSwapToken.Contract.DECIMALS(&_HbSwapToken.CallOpts) -} - -// INITIALSUPPLY is a free data retrieval call binding the contract method 0x2ff2e9dc. -// -// Solidity: function INITIAL_SUPPLY() view returns(uint256) -func (_HbSwapToken *HbSwapTokenCaller) INITIALSUPPLY(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _HbSwapToken.contract.Call(opts, &out, "INITIAL_SUPPLY") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// INITIALSUPPLY is a free data retrieval call binding the contract method 0x2ff2e9dc. -// -// Solidity: function INITIAL_SUPPLY() view returns(uint256) -func (_HbSwapToken *HbSwapTokenSession) INITIALSUPPLY() (*big.Int, error) { - return _HbSwapToken.Contract.INITIALSUPPLY(&_HbSwapToken.CallOpts) -} - -// INITIALSUPPLY is a free data retrieval call binding the contract method 0x2ff2e9dc. -// -// Solidity: function INITIAL_SUPPLY() view returns(uint256) -func (_HbSwapToken *HbSwapTokenCallerSession) INITIALSUPPLY() (*big.Int, error) { - return _HbSwapToken.Contract.INITIALSUPPLY(&_HbSwapToken.CallOpts) -} - -// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. -// -// Solidity: function allowance(address owner, address spender) view returns(uint256) -func (_HbSwapToken *HbSwapTokenCaller) Allowance(opts *bind.CallOpts, owner common.Address, spender common.Address) (*big.Int, error) { - var out []interface{} - err := _HbSwapToken.contract.Call(opts, &out, "allowance", owner, spender) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. -// -// Solidity: function allowance(address owner, address spender) view returns(uint256) -func (_HbSwapToken *HbSwapTokenSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { - return _HbSwapToken.Contract.Allowance(&_HbSwapToken.CallOpts, owner, spender) -} - -// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. -// -// Solidity: function allowance(address owner, address spender) view returns(uint256) -func (_HbSwapToken *HbSwapTokenCallerSession) Allowance(owner common.Address, spender common.Address) (*big.Int, error) { - return _HbSwapToken.Contract.Allowance(&_HbSwapToken.CallOpts, owner, spender) -} - -// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. -// -// Solidity: function balanceOf(address account) view returns(uint256) -func (_HbSwapToken *HbSwapTokenCaller) BalanceOf(opts *bind.CallOpts, account common.Address) (*big.Int, error) { - var out []interface{} - err := _HbSwapToken.contract.Call(opts, &out, "balanceOf", account) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. -// -// Solidity: function balanceOf(address account) view returns(uint256) -func (_HbSwapToken *HbSwapTokenSession) BalanceOf(account common.Address) (*big.Int, error) { - return _HbSwapToken.Contract.BalanceOf(&_HbSwapToken.CallOpts, account) -} - -// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. -// -// Solidity: function balanceOf(address account) view returns(uint256) -func (_HbSwapToken *HbSwapTokenCallerSession) BalanceOf(account common.Address) (*big.Int, error) { - return _HbSwapToken.Contract.BalanceOf(&_HbSwapToken.CallOpts, account) -} - -// Decimals is a free data retrieval call binding the contract method 0x313ce567. -// -// Solidity: function decimals() view returns(uint8) -func (_HbSwapToken *HbSwapTokenCaller) Decimals(opts *bind.CallOpts) (uint8, error) { - var out []interface{} - err := _HbSwapToken.contract.Call(opts, &out, "decimals") - - if err != nil { - return *new(uint8), err - } - - out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) - - return out0, err - -} - -// Decimals is a free data retrieval call binding the contract method 0x313ce567. -// -// Solidity: function decimals() view returns(uint8) -func (_HbSwapToken *HbSwapTokenSession) Decimals() (uint8, error) { - return _HbSwapToken.Contract.Decimals(&_HbSwapToken.CallOpts) -} - -// Decimals is a free data retrieval call binding the contract method 0x313ce567. -// -// Solidity: function decimals() view returns(uint8) -func (_HbSwapToken *HbSwapTokenCallerSession) Decimals() (uint8, error) { - return _HbSwapToken.Contract.Decimals(&_HbSwapToken.CallOpts) -} - -// Name is a free data retrieval call binding the contract method 0x06fdde03. -// -// Solidity: function name() view returns(string) -func (_HbSwapToken *HbSwapTokenCaller) Name(opts *bind.CallOpts) (string, error) { - var out []interface{} - err := _HbSwapToken.contract.Call(opts, &out, "name") - - if err != nil { - return *new(string), err - } - - out0 := *abi.ConvertType(out[0], new(string)).(*string) - - return out0, err - -} - -// Name is a free data retrieval call binding the contract method 0x06fdde03. -// -// Solidity: function name() view returns(string) -func (_HbSwapToken *HbSwapTokenSession) Name() (string, error) { - return _HbSwapToken.Contract.Name(&_HbSwapToken.CallOpts) -} - -// Name is a free data retrieval call binding the contract method 0x06fdde03. -// -// Solidity: function name() view returns(string) -func (_HbSwapToken *HbSwapTokenCallerSession) Name() (string, error) { - return _HbSwapToken.Contract.Name(&_HbSwapToken.CallOpts) -} - -// Symbol is a free data retrieval call binding the contract method 0x95d89b41. -// -// Solidity: function symbol() view returns(string) -func (_HbSwapToken *HbSwapTokenCaller) Symbol(opts *bind.CallOpts) (string, error) { - var out []interface{} - err := _HbSwapToken.contract.Call(opts, &out, "symbol") - - if err != nil { - return *new(string), err - } - - out0 := *abi.ConvertType(out[0], new(string)).(*string) - - return out0, err - -} - -// Symbol is a free data retrieval call binding the contract method 0x95d89b41. -// -// Solidity: function symbol() view returns(string) -func (_HbSwapToken *HbSwapTokenSession) Symbol() (string, error) { - return _HbSwapToken.Contract.Symbol(&_HbSwapToken.CallOpts) -} - -// Symbol is a free data retrieval call binding the contract method 0x95d89b41. -// -// Solidity: function symbol() view returns(string) -func (_HbSwapToken *HbSwapTokenCallerSession) Symbol() (string, error) { - return _HbSwapToken.Contract.Symbol(&_HbSwapToken.CallOpts) -} - -// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. -// -// Solidity: function totalSupply() view returns(uint256) -func (_HbSwapToken *HbSwapTokenCaller) TotalSupply(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _HbSwapToken.contract.Call(opts, &out, "totalSupply") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. -// -// Solidity: function totalSupply() view returns(uint256) -func (_HbSwapToken *HbSwapTokenSession) TotalSupply() (*big.Int, error) { - return _HbSwapToken.Contract.TotalSupply(&_HbSwapToken.CallOpts) -} - -// TotalSupply is a free data retrieval call binding the contract method 0x18160ddd. -// -// Solidity: function totalSupply() view returns(uint256) -func (_HbSwapToken *HbSwapTokenCallerSession) TotalSupply() (*big.Int, error) { - return _HbSwapToken.Contract.TotalSupply(&_HbSwapToken.CallOpts) -} - -// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. -// -// Solidity: function approve(address spender, uint256 amount) returns(bool) -func (_HbSwapToken *HbSwapTokenTransactor) Approve(opts *bind.TransactOpts, spender common.Address, amount *big.Int) (*types.Transaction, error) { - return _HbSwapToken.contract.Transact(opts, "approve", spender, amount) -} - -// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. -// -// Solidity: function approve(address spender, uint256 amount) returns(bool) -func (_HbSwapToken *HbSwapTokenSession) Approve(spender common.Address, amount *big.Int) (*types.Transaction, error) { - return _HbSwapToken.Contract.Approve(&_HbSwapToken.TransactOpts, spender, amount) -} - -// Approve is a paid mutator transaction binding the contract method 0x095ea7b3. -// -// Solidity: function approve(address spender, uint256 amount) returns(bool) -func (_HbSwapToken *HbSwapTokenTransactorSession) Approve(spender common.Address, amount *big.Int) (*types.Transaction, error) { - return _HbSwapToken.Contract.Approve(&_HbSwapToken.TransactOpts, spender, amount) -} - -// DecreaseAllowance is a paid mutator transaction binding the contract method 0xa457c2d7. -// -// Solidity: function decreaseAllowance(address spender, uint256 subtractedValue) returns(bool) -func (_HbSwapToken *HbSwapTokenTransactor) DecreaseAllowance(opts *bind.TransactOpts, spender common.Address, subtractedValue *big.Int) (*types.Transaction, error) { - return _HbSwapToken.contract.Transact(opts, "decreaseAllowance", spender, subtractedValue) -} - -// DecreaseAllowance is a paid mutator transaction binding the contract method 0xa457c2d7. -// -// Solidity: function decreaseAllowance(address spender, uint256 subtractedValue) returns(bool) -func (_HbSwapToken *HbSwapTokenSession) DecreaseAllowance(spender common.Address, subtractedValue *big.Int) (*types.Transaction, error) { - return _HbSwapToken.Contract.DecreaseAllowance(&_HbSwapToken.TransactOpts, spender, subtractedValue) -} - -// DecreaseAllowance is a paid mutator transaction binding the contract method 0xa457c2d7. -// -// Solidity: function decreaseAllowance(address spender, uint256 subtractedValue) returns(bool) -func (_HbSwapToken *HbSwapTokenTransactorSession) DecreaseAllowance(spender common.Address, subtractedValue *big.Int) (*types.Transaction, error) { - return _HbSwapToken.Contract.DecreaseAllowance(&_HbSwapToken.TransactOpts, spender, subtractedValue) -} - -// IncreaseAllowance is a paid mutator transaction binding the contract method 0x39509351. -// -// Solidity: function increaseAllowance(address spender, uint256 addedValue) returns(bool) -func (_HbSwapToken *HbSwapTokenTransactor) IncreaseAllowance(opts *bind.TransactOpts, spender common.Address, addedValue *big.Int) (*types.Transaction, error) { - return _HbSwapToken.contract.Transact(opts, "increaseAllowance", spender, addedValue) -} - -// IncreaseAllowance is a paid mutator transaction binding the contract method 0x39509351. -// -// Solidity: function increaseAllowance(address spender, uint256 addedValue) returns(bool) -func (_HbSwapToken *HbSwapTokenSession) IncreaseAllowance(spender common.Address, addedValue *big.Int) (*types.Transaction, error) { - return _HbSwapToken.Contract.IncreaseAllowance(&_HbSwapToken.TransactOpts, spender, addedValue) -} - -// IncreaseAllowance is a paid mutator transaction binding the contract method 0x39509351. -// -// Solidity: function increaseAllowance(address spender, uint256 addedValue) returns(bool) -func (_HbSwapToken *HbSwapTokenTransactorSession) IncreaseAllowance(spender common.Address, addedValue *big.Int) (*types.Transaction, error) { - return _HbSwapToken.Contract.IncreaseAllowance(&_HbSwapToken.TransactOpts, spender, addedValue) -} - -// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. -// -// Solidity: function transfer(address recipient, uint256 amount) returns(bool) -func (_HbSwapToken *HbSwapTokenTransactor) Transfer(opts *bind.TransactOpts, recipient common.Address, amount *big.Int) (*types.Transaction, error) { - return _HbSwapToken.contract.Transact(opts, "transfer", recipient, amount) -} - -// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. -// -// Solidity: function transfer(address recipient, uint256 amount) returns(bool) -func (_HbSwapToken *HbSwapTokenSession) Transfer(recipient common.Address, amount *big.Int) (*types.Transaction, error) { - return _HbSwapToken.Contract.Transfer(&_HbSwapToken.TransactOpts, recipient, amount) -} - -// Transfer is a paid mutator transaction binding the contract method 0xa9059cbb. -// -// Solidity: function transfer(address recipient, uint256 amount) returns(bool) -func (_HbSwapToken *HbSwapTokenTransactorSession) Transfer(recipient common.Address, amount *big.Int) (*types.Transaction, error) { - return _HbSwapToken.Contract.Transfer(&_HbSwapToken.TransactOpts, recipient, amount) -} - -// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. -// -// Solidity: function transferFrom(address sender, address recipient, uint256 amount) returns(bool) -func (_HbSwapToken *HbSwapTokenTransactor) TransferFrom(opts *bind.TransactOpts, sender common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { - return _HbSwapToken.contract.Transact(opts, "transferFrom", sender, recipient, amount) -} - -// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. -// -// Solidity: function transferFrom(address sender, address recipient, uint256 amount) returns(bool) -func (_HbSwapToken *HbSwapTokenSession) TransferFrom(sender common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { - return _HbSwapToken.Contract.TransferFrom(&_HbSwapToken.TransactOpts, sender, recipient, amount) -} - -// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd. -// -// Solidity: function transferFrom(address sender, address recipient, uint256 amount) returns(bool) -func (_HbSwapToken *HbSwapTokenTransactorSession) TransferFrom(sender common.Address, recipient common.Address, amount *big.Int) (*types.Transaction, error) { - return _HbSwapToken.Contract.TransferFrom(&_HbSwapToken.TransactOpts, sender, recipient, amount) -} - -// HbSwapTokenApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the HbSwapToken contract. -type HbSwapTokenApprovalIterator struct { - Event *HbSwapTokenApproval // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HbSwapTokenApprovalIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HbSwapTokenApproval) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HbSwapTokenApproval) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HbSwapTokenApprovalIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HbSwapTokenApprovalIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HbSwapTokenApproval represents a Approval event raised by the HbSwapToken contract. -type HbSwapTokenApproval struct { - Owner common.Address - Spender common.Address - Value *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterApproval is a free log retrieval operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. -// -// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) -func (_HbSwapToken *HbSwapTokenFilterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, spender []common.Address) (*HbSwapTokenApprovalIterator, error) { - - var ownerRule []interface{} - for _, ownerItem := range owner { - ownerRule = append(ownerRule, ownerItem) - } - var spenderRule []interface{} - for _, spenderItem := range spender { - spenderRule = append(spenderRule, spenderItem) - } - - logs, sub, err := _HbSwapToken.contract.FilterLogs(opts, "Approval", ownerRule, spenderRule) - if err != nil { - return nil, err - } - return &HbSwapTokenApprovalIterator{contract: _HbSwapToken.contract, event: "Approval", logs: logs, sub: sub}, nil -} - -// WatchApproval is a free log subscription operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. -// -// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) -func (_HbSwapToken *HbSwapTokenFilterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *HbSwapTokenApproval, owner []common.Address, spender []common.Address) (event.Subscription, error) { - - var ownerRule []interface{} - for _, ownerItem := range owner { - ownerRule = append(ownerRule, ownerItem) - } - var spenderRule []interface{} - for _, spenderItem := range spender { - spenderRule = append(spenderRule, spenderItem) - } - - logs, sub, err := _HbSwapToken.contract.WatchLogs(opts, "Approval", ownerRule, spenderRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HbSwapTokenApproval) - if err := _HbSwapToken.contract.UnpackLog(event, "Approval", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseApproval is a log parse operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925. -// -// Solidity: event Approval(address indexed owner, address indexed spender, uint256 value) -func (_HbSwapToken *HbSwapTokenFilterer) ParseApproval(log types.Log) (*HbSwapTokenApproval, error) { - event := new(HbSwapTokenApproval) - if err := _HbSwapToken.contract.UnpackLog(event, "Approval", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// HbSwapTokenTransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the HbSwapToken contract. -type HbSwapTokenTransferIterator struct { - Event *HbSwapTokenTransfer // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HbSwapTokenTransferIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HbSwapTokenTransfer) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HbSwapTokenTransfer) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HbSwapTokenTransferIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HbSwapTokenTransferIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HbSwapTokenTransfer represents a Transfer event raised by the HbSwapToken contract. -type HbSwapTokenTransfer struct { - From common.Address - To common.Address - Value *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterTransfer is a free log retrieval operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. -// -// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_HbSwapToken *HbSwapTokenFilterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address) (*HbSwapTokenTransferIterator, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - var toRule []interface{} - for _, toItem := range to { - toRule = append(toRule, toItem) - } - - logs, sub, err := _HbSwapToken.contract.FilterLogs(opts, "Transfer", fromRule, toRule) - if err != nil { - return nil, err - } - return &HbSwapTokenTransferIterator{contract: _HbSwapToken.contract, event: "Transfer", logs: logs, sub: sub}, nil -} - -// WatchTransfer is a free log subscription operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. -// -// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_HbSwapToken *HbSwapTokenFilterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *HbSwapTokenTransfer, from []common.Address, to []common.Address) (event.Subscription, error) { - - var fromRule []interface{} - for _, fromItem := range from { - fromRule = append(fromRule, fromItem) - } - var toRule []interface{} - for _, toItem := range to { - toRule = append(toRule, toItem) - } - - logs, sub, err := _HbSwapToken.contract.WatchLogs(opts, "Transfer", fromRule, toRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HbSwapTokenTransfer) - if err := _HbSwapToken.contract.UnpackLog(event, "Transfer", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseTransfer is a log parse operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef. -// -// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) -func (_HbSwapToken *HbSwapTokenFilterer) ParseTransfer(log types.Log) (*HbSwapTokenTransfer, error) { - event := new(HbSwapTokenTransfer) - if err := _HbSwapToken.contract.UnpackLog(event, "Transfer", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/src/go_bindings/hbswap/hbswap.go b/src/go_bindings/hbswap/hbswap.go deleted file mode 100644 index c8bfff19..00000000 --- a/src/go_bindings/hbswap/hbswap.go +++ /dev/null @@ -1,1848 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package hbswap - -import ( - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription -) - -// HbSwapABI is the input ABI used to generate the binding from. -const HbSwapABI = "[{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_servers\",\"type\":\"address[]\"},{\"internalType\":\"uint256\",\"name\":\"_threshold\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"tokenA\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"tokenB\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"idxA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"idxB\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"maskedAmtA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"maskedAmtB\",\"type\":\"uint256\"}],\"name\":\"AddLiquidity\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"tokenA\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"tokenB\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amtA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amtB\",\"type\":\"uint256\"}],\"name\":\"InitPool\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256[]\",\"name\":\"inpusMaskIndexes\",\"type\":\"uint256[]\"}],\"name\":\"InputMask\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"tokenA\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"tokenB\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"idx\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"maskedAmt\",\"type\":\"uint256\"}],\"name\":\"RemoveLiquidity\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amt\",\"type\":\"uint256\"}],\"name\":\"SecretDeposit\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"seq\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amt\",\"type\":\"uint256\"}],\"name\":\"SecretWithdraw\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"tradeSeq\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"tokenA\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"tokenB\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"idxA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"idxB\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"maskedAmtA\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"maskedAmtB\",\"type\":\"uint256\"}],\"name\":\"Trade\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[],\"name\":\"Decimals\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"Fp\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"consentRecord\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"inputMaskOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"inputmaskCnt\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"lastUpdateSeq\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"prices\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"publicBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"secretWithdrawCnt\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"secretWithdrawMap\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"user\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amt\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"servers\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"threshold\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"tradeCnt\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amt\",\"type\":\"uint256\"}],\"name\":\"publicDeposit\",\"outputs\":[],\"payable\":true,\"stateMutability\":\"payable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amt\",\"type\":\"uint256\"}],\"name\":\"secretDeposit\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amt\",\"type\":\"uint256\"}],\"name\":\"secretWithdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_seq\",\"type\":\"uint256\"}],\"name\":\"consent\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amt\",\"type\":\"uint256\"}],\"name\":\"publicWithdraw\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_num\",\"type\":\"uint256\"}],\"name\":\"reserveInput\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tokenA\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tokenB\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amtA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_amtB\",\"type\":\"uint256\"}],\"name\":\"initPool\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tokenA\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tokenB\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_idxA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_idxB\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maskedAmtA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maskedAmtB\",\"type\":\"uint256\"}],\"name\":\"addLiquidity\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tokenA\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tokenB\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_idx\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maskedAmt\",\"type\":\"uint256\"}],\"name\":\"removeLiquidity\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tokenA\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tokenB\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_idxA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_idxB\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maskedA\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_maskedB\",\"type\":\"uint256\"}],\"name\":\"trade\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tokenA\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tokenB\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_checkpointSeq\",\"type\":\"uint256\"},{\"internalType\":\"string\",\"name\":\"_price\",\"type\":\"string\"}],\"name\":\"updatePrice\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_tokenA\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_tokenB\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"_servers\",\"type\":\"address[]\"}],\"name\":\"resetPrice\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_user\",\"type\":\"address\"}],\"name\":\"resetBalance\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]" - -// HbSwapBin is the compiled bytecode used for deploying new contracts. -var HbSwapBin = "0x60806040523480156200001157600080fd5b5060405162003a7b38038062003a7b833981810160405260408110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b838201915060208201858111156200006f57600080fd5b82518660208202830111640100000000821117156200008d57600080fd5b8083526020830192505050908051906020019060200280838360005b83811015620000c6578082015181840152602081019050620000a9565b5050505090500160405260200180519060200190929190505050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008090505b8251811015620001aa576001600260008584815181106200014357fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff021916908315150217905550808060010191505062000126565b508060018190555050506138b780620001c46000396000f3fe6080604052600436106101815760003560e01c80639eef6ce8116100d1578063b7deef821161008a578063ca7b58ad11610064578063ca7b58ad14610b95578063cc5bd7fa14610c06578063dee4059514610c41578063e7e8927614610c9c57610181565b8063b7deef8214610a94578063bc94e7cf14610b0f578063c6ceb50b14610b6a57610181565b80639eef6ce81461088a578063a45b6ce6146108c5578063a4bea6c8146108f0578063ade28aad14610975578063af4170c4146109d0578063b72a2139146109fb57610181565b80633766dba71161013e5780637aa6fd65116101185780637aa6fd651461065757806393910e661461070c57806393f54644146107375780639450fb261461078557610181565b80633766dba7146104955780633ee7f9d3146105a757806342cde4e81461062c57610181565b806312ada8de146101865780631768af96146101ef5780631f312404146102625780632f8a68c51461034c5780633351733f146103d15780633394dc6f1461046a575b600080fd5b34801561019257600080fd5b506101d5600480360360208110156101a957600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d21565b604051808215151515815260200191505060405180910390f35b3480156101fb57600080fd5b506102486004803603604081101561021257600080fd5b8101908080359060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d41565b604051808215151515815260200191505060405180910390f35b34801561026e57600080fd5b506102d16004803603604081101561028557600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610d70565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156103115780820151818401526020810190506102f6565b50505050905090810190601f16801561033e5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561035857600080fd5b506103cf6004803603608081101561036f57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019092919080359060200190929190505050610e2d565b005b3480156103dd57600080fd5b50610468600480360360c08110156103f457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050611037565b005b34801561047657600080fd5b5061047f611379565b6040518082815260200191505060405180910390f35b3480156104a157600080fd5b506105a5600480360360808110156104b857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291908035906020019064010000000081111561051f57600080fd5b82018360208201111561053157600080fd5b8035906020019184600183028401116401000000008311171561055357600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050919291929050505061137f565b005b3480156105b357600080fd5b5061062a600480360360808110156105ca57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291905050506119b3565b005b34801561063857600080fd5b50610641611c0f565b6040518082815260200191505060405180910390f35b34801561066357600080fd5b506106906004803603602081101561067a57600080fd5b8101908080359060200190929190505050611c15565b604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060405180910390f35b34801561071857600080fd5b50610721611c7f565b6040518082815260200191505060405180910390f35b6107836004803603604081101561074d57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050611c85565b005b34801561079157600080fd5b50610888600480360360608110156107a857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291908035906020019064010000000081111561080557600080fd5b82018360208201111561081757600080fd5b8035906020019184602083028401116401000000008311171561083957600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f820116905080830192505050505050509192919290505050611e95565b005b34801561089657600080fd5b506108c3600480360360208110156108ad57600080fd5b81019080803590602001909291905050506121f7565b005b3480156108d157600080fd5b506108da612604565b6040518082815260200191505060405180910390f35b3480156108fc57600080fd5b5061095f6004803603604081101561091357600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061260b565b6040518082815260200191505060405180910390f35b34801561098157600080fd5b506109ce6004803603604081101561099857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612630565b005b3480156109dc57600080fd5b506109e5612861565b6040518082815260200191505060405180910390f35b348015610a0757600080fd5b50610a92600480360360c0811015610a1e57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190803590602001909291908035906020019092919080359060200190929190505050612867565b005b348015610aa057600080fd5b50610acd60048036036020811015610ab757600080fd5b8101908080359060200190929190505050612bc4565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b348015610b1b57600080fd5b50610b6860048036036040811015610b3257600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919080359060200190929190505050612bf7565b005b348015610b7657600080fd5b50610b7f612e66565b6040518082815260200191505060405180910390f35b348015610ba157600080fd5b50610c0460048036036040811015610bb857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050612e71565b005b348015610c1257600080fd5b50610c3f60048036036020811015610c2957600080fd5b8101908080359060200190929190505050612f50565b005b348015610c4d57600080fd5b50610c9a60048036036040811015610c6457600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803590602001909291905050506130a3565b005b348015610ca857600080fd5b50610d0b60048036036040811015610cbf57600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190803573ffffffffffffffffffffffffffffffffffffffff1690602001909291905050506132d4565b6040518082815260200191505060405180910390f35b60026020528060005260406000206000915054906101000a900460ff1681565b60066020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b600c602052816000526040600020602052806000526040600020600091509150508054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610e255780601f10610dfa57610100808354040283529160200191610e25565b820191906000526020600020905b815481529060010190602001808311610e0857829003601f168201915b505050505081565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610610ece576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f696e76616c69642074726164696e67207061697200000000000000000000000081525060200191505060405180910390fd5b600082118015610ede5750600081115b610f50576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f696e76616c696420616d6f756e7400000000000000000000000000000000000081525060200191505060405180910390fd5b60003390507ffaaebcb30b1b421f4f2ca7f2620e5add6a64532c087ee0646fd665a33d36fdf53386868686604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020019550505050505060405180910390a15050505050565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff16106110d8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f696e76616c69642074726164696e67207061697200000000000000000000000081525060200191505060405180910390fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff16600a600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146111b1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f756e617574686f72697a656420696e7075746d61736b0000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611285576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f756e617574686f72697a656420696e7075746d61736b0000000000000000000081525060200191505060405180910390fd5b7fec7d4752dd44bf7fc59045c9d80163de2a1b9dbd9032d11cb1156f7f867c641181888888888888604051808873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200185815260200184815260200183815260200182815260200197505050505050505060405180910390a150505050505050565b60045481565b6000339050600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16611443576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f6e6f7420612076616c696420736572766572000000000000000000000000000081525060200191505060405180910390fd5b600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615806115275750600083145b156119ac576001600f60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506001600e60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000858152602001908152602001600020836040518082805190602001908083835b602083106116d257805182526020820191506020810190506020830392506116af565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051809103902060008282540192505081905550600154600e60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000858152602001908152602001600020836040518082805190602001908083835b602083106117d657805182526020820191506020810190506020830392506117b3565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020541180156118935750600d60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020548310155b156119ab5781600c60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209080519060200190611928929190613766565b5082600d60008773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505b5b5050505050565b8273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff1610611a54576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f696e76616c69642074726164696e67207061697200000000000000000000000081525060200191505060405180910390fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff16600a600085815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614611b2d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f756e617574686f72697a656420696e7075746d61736b0000000000000000000081525060200191505060405180910390fd5b7fa8dbaaebbb025c88e9e34c84635cd8238043556e9af43fb161508c898a8e1ef98186868686604051808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018381526020018281526020019550505050505060405180910390a15050505050565b60015481565b60056020528060005260406000206000915090508060000160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060010160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16908060020154905083565b60095481565b600033905060008211611d00576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f696e76616c696420616d6f756e7400000000000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415611dbd5766038d7ea4c68000820262010000340214611db8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260118152602001807f616d6f756e7473206e6f74206d6174636800000000000000000000000000000081525060200191505060405180910390fd5b611e06565b6000839050611e04823066038d7ea4c68000620100008781611ddb57fe5b04028473ffffffffffffffffffffffffffffffffffffffff166132f9909392919063ffffffff16565b505b81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550505050565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614611eee57600080fd5b60405180602001604052806000815250600c60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000209080519060200190611f8d929190613766565b506000600d60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008090505b8151811015612122576000600f60008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080815260200190815260200160002060008484815181106120bc57fe5b602002602001015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508080600101915050612016565b506000600e60008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600080815260200190815260200160002060405180807f302e3000000000000000000000000000000000000000000000000000000000008152506003019050908152602001604051809103902081905550505050565b6000339050600260008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff166122bb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260128152602001807f6e6f7420612076616c696420736572766572000000000000000000000000000081525060200191505060405180910390fd5b6006600083815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff161561238c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600f8152602001807f616c726561647920636f6e73656e74000000000000000000000000000000000081525060200191505060405180910390fd5b60016006600084815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555060016007600084815260200190815260200160002060008282540192505081905550600154600760008481526020019081526020016000205411801561245957506008600083815260200190815260200160002060009054906101000a900460ff16155b15612600576124666137e6565b600560008481526020019081526020016000206040518060600160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820154815250509050806040015160036000836000015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000836020015173ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254019250508190555060016008600085815260200190815260200160002060006101000a81548160ff021916908315150217905550505b5050565b6201000081565b600d602052816000526040600020602052806000526040600020600091509150505481565b60003390506000821180156126c1575081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b612733576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f696e76616c696420616d6f756e7400000000000000000000000000000000000081525060200191505060405180910390fd5b81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055507f07c06144435b7d2bdccf9ee7e5a7022c63382ac7c3a0e14ed08b5969dedf0ecf838284604051808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001828152602001935050505060405180910390a1505050565b600b5481565b8473ffffffffffffffffffffffffffffffffffffffff168673ffffffffffffffffffffffffffffffffffffffff1610612908576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260148152602001807f696e76616c69642074726164696e67207061697200000000000000000000000081525060200191505060405180910390fd5b60003390508073ffffffffffffffffffffffffffffffffffffffff16600a600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146129e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f756e617574686f72697a656420696e7075746d61736b0000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16600a600086815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614612ab5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260168152602001807f756e617574686f72697a656420696e7075746d61736b0000000000000000000081525060200191505060405180910390fd5b6001600b600082825401925050819055507f2b4d91cd20cc8800407e3614b8466a6f0729ac3b1fa43d4e2b059ff5593cbae6600b5482898989898989604051808981526020018873ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018773ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018581526020018481526020018381526020018281526020019850505050505050505060405180910390a150505050505050565b600a6020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000339050600082118015612c88575081600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205410155b612cfa576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f696e76616c696420616d6f756e7400000000000000000000000000000000000081525060200191505060405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612d90578073ffffffffffffffffffffffffffffffffffffffff166108fc66038d7ea4c68000620100008581612d5d57fe5b04029081150290604051600060405180830381858888f19350505050158015612d8a573d6000803e3d6000fd5b50612dd7565b6000839050612dd58266038d7ea4c68000620100008681612dad57fe5b04028373ffffffffffffffffffffffffffffffffffffffff166133ff9092919063ffffffff16565b505b81600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540392505081905550505050565b66038d7ea4c6800081565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614612eca57600080fd5b6000600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055505050565b6000339050606082604051908082528060200260200182016040528015612f865781602001602082028038833980820191505090505b50905060008090505b838110156130255760006009600081548092919060010191905055905083600a600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508083838151811061300b57fe5b602002602001018181525050508080600101915050612f8f565b507fff742b54a62e49c065680fc16aa208f37f60ded27e03a3d19e6088ba0c7b41d4816040518080602001828103825283818151815260200191508051906020019060200280838360005b8381101561308b578082015181840152602081019050613070565b505050509050019250505060405180910390a1505050565b60003390506000821161311e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252600e8152602001807f696e76616c696420616d6f756e7400000000000000000000000000000000000081525060200191505060405180910390fd5b600160046000828254019250508190555060405180606001604052808473ffffffffffffffffffffffffffffffffffffffff1681526020018273ffffffffffffffffffffffffffffffffffffffff1681526020018381525060056000600454815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550604082015181600201559050507f4ef3cc4825a92c3b6922acc8a45152cc96ef48463e8ed500dacd5df9e29a67f3600454848385604051808581526020018473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200194505050505060405180910390a1505050565b6003602052816000526040600020602052806000526040600020600091509150505481565b6133f9848573ffffffffffffffffffffffffffffffffffffffff166323b872dd905060e01b858585604051602401808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019350505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506134d0565b50505050565b6134cb838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb905060e01b8484604051602401808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200182815260200192505050604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506134d0565b505050565b6134ef8273ffffffffffffffffffffffffffffffffffffffff1661371b565b613561576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252601f8152602001807f5361666545524332303a2063616c6c20746f206e6f6e2d636f6e74726163740081525060200191505060405180910390fd5b600060608373ffffffffffffffffffffffffffffffffffffffff16836040518082805190602001908083835b602083106135b0578051825260208201915060208101905060208303925061358d565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613612576040519150601f19603f3d011682016040523d82523d6000602084013e613617565b606091505b50915091508161368f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260208152602001807f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c656481525060200191505060405180910390fd5b600081511115613715578080602001905160208110156136ae57600080fd5b8101908080519060200190929190505050613714576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602a815260200180613859602a913960400191505060405180910390fd5b5b50505050565b60008060007fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a47060001b9050833f915080821415801561375d57506000801b8214155b92505050919050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106137a757805160ff19168380011785556137d5565b828001600101855582156137d5579182015b828111156137d45782518255916020019190600101906137b9565b5b5090506137e29190613833565b5090565b6040518060600160405280600073ffffffffffffffffffffffffffffffffffffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600081525090565b61385591905b80821115613851576000816000905550600101613839565b5090565b9056fe5361666545524332303a204552433230206f7065726174696f6e20646964206e6f742073756363656564a265627a7a7231582055ef814be42664133bbeee941837ad8a5fdf784f88c4c26f0e45529bfdbf8e0964736f6c63430005110032" - -// DeployHbSwap deploys a new Ethereum contract, binding an instance of HbSwap to it. -func DeployHbSwap(auth *bind.TransactOpts, backend bind.ContractBackend, _servers []common.Address, _threshold *big.Int) (common.Address, *types.Transaction, *HbSwap, error) { - parsed, err := abi.JSON(strings.NewReader(HbSwapABI)) - if err != nil { - return common.Address{}, nil, nil, err - } - - address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(HbSwapBin), backend, _servers, _threshold) - if err != nil { - return common.Address{}, nil, nil, err - } - return address, tx, &HbSwap{HbSwapCaller: HbSwapCaller{contract: contract}, HbSwapTransactor: HbSwapTransactor{contract: contract}, HbSwapFilterer: HbSwapFilterer{contract: contract}}, nil -} - -// HbSwap is an auto generated Go binding around an Ethereum contract. -type HbSwap struct { - HbSwapCaller // Read-only binding to the contract - HbSwapTransactor // Write-only binding to the contract - HbSwapFilterer // Log filterer for contract events -} - -// HbSwapCaller is an auto generated read-only Go binding around an Ethereum contract. -type HbSwapCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// HbSwapTransactor is an auto generated write-only Go binding around an Ethereum contract. -type HbSwapTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// HbSwapFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type HbSwapFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// HbSwapSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type HbSwapSession struct { - Contract *HbSwap // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// HbSwapCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type HbSwapCallerSession struct { - Contract *HbSwapCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// HbSwapTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type HbSwapTransactorSession struct { - Contract *HbSwapTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// HbSwapRaw is an auto generated low-level Go binding around an Ethereum contract. -type HbSwapRaw struct { - Contract *HbSwap // Generic contract binding to access the raw methods on -} - -// HbSwapCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type HbSwapCallerRaw struct { - Contract *HbSwapCaller // Generic read-only contract binding to access the raw methods on -} - -// HbSwapTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type HbSwapTransactorRaw struct { - Contract *HbSwapTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewHbSwap creates a new instance of HbSwap, bound to a specific deployed contract. -func NewHbSwap(address common.Address, backend bind.ContractBackend) (*HbSwap, error) { - contract, err := bindHbSwap(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &HbSwap{HbSwapCaller: HbSwapCaller{contract: contract}, HbSwapTransactor: HbSwapTransactor{contract: contract}, HbSwapFilterer: HbSwapFilterer{contract: contract}}, nil -} - -// NewHbSwapCaller creates a new read-only instance of HbSwap, bound to a specific deployed contract. -func NewHbSwapCaller(address common.Address, caller bind.ContractCaller) (*HbSwapCaller, error) { - contract, err := bindHbSwap(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &HbSwapCaller{contract: contract}, nil -} - -// NewHbSwapTransactor creates a new write-only instance of HbSwap, bound to a specific deployed contract. -func NewHbSwapTransactor(address common.Address, transactor bind.ContractTransactor) (*HbSwapTransactor, error) { - contract, err := bindHbSwap(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &HbSwapTransactor{contract: contract}, nil -} - -// NewHbSwapFilterer creates a new log filterer instance of HbSwap, bound to a specific deployed contract. -func NewHbSwapFilterer(address common.Address, filterer bind.ContractFilterer) (*HbSwapFilterer, error) { - contract, err := bindHbSwap(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &HbSwapFilterer{contract: contract}, nil -} - -// bindHbSwap binds a generic wrapper to an already deployed contract. -func bindHbSwap(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(HbSwapABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_HbSwap *HbSwapRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _HbSwap.Contract.HbSwapCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_HbSwap *HbSwapRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _HbSwap.Contract.HbSwapTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_HbSwap *HbSwapRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _HbSwap.Contract.HbSwapTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_HbSwap *HbSwapCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _HbSwap.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_HbSwap *HbSwapTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _HbSwap.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_HbSwap *HbSwapTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _HbSwap.Contract.contract.Transact(opts, method, params...) -} - -// Decimals is a free data retrieval call binding the contract method 0xc6ceb50b. -// -// Solidity: function Decimals() view returns(uint256) -func (_HbSwap *HbSwapCaller) Decimals(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "Decimals") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// Decimals is a free data retrieval call binding the contract method 0xc6ceb50b. -// -// Solidity: function Decimals() view returns(uint256) -func (_HbSwap *HbSwapSession) Decimals() (*big.Int, error) { - return _HbSwap.Contract.Decimals(&_HbSwap.CallOpts) -} - -// Decimals is a free data retrieval call binding the contract method 0xc6ceb50b. -// -// Solidity: function Decimals() view returns(uint256) -func (_HbSwap *HbSwapCallerSession) Decimals() (*big.Int, error) { - return _HbSwap.Contract.Decimals(&_HbSwap.CallOpts) -} - -// Fp is a free data retrieval call binding the contract method 0xa45b6ce6. -// -// Solidity: function Fp() view returns(uint256) -func (_HbSwap *HbSwapCaller) Fp(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "Fp") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// Fp is a free data retrieval call binding the contract method 0xa45b6ce6. -// -// Solidity: function Fp() view returns(uint256) -func (_HbSwap *HbSwapSession) Fp() (*big.Int, error) { - return _HbSwap.Contract.Fp(&_HbSwap.CallOpts) -} - -// Fp is a free data retrieval call binding the contract method 0xa45b6ce6. -// -// Solidity: function Fp() view returns(uint256) -func (_HbSwap *HbSwapCallerSession) Fp() (*big.Int, error) { - return _HbSwap.Contract.Fp(&_HbSwap.CallOpts) -} - -// ConsentRecord is a free data retrieval call binding the contract method 0x1768af96. -// -// Solidity: function consentRecord(uint256 , address ) view returns(bool) -func (_HbSwap *HbSwapCaller) ConsentRecord(opts *bind.CallOpts, arg0 *big.Int, arg1 common.Address) (bool, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "consentRecord", arg0, arg1) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// ConsentRecord is a free data retrieval call binding the contract method 0x1768af96. -// -// Solidity: function consentRecord(uint256 , address ) view returns(bool) -func (_HbSwap *HbSwapSession) ConsentRecord(arg0 *big.Int, arg1 common.Address) (bool, error) { - return _HbSwap.Contract.ConsentRecord(&_HbSwap.CallOpts, arg0, arg1) -} - -// ConsentRecord is a free data retrieval call binding the contract method 0x1768af96. -// -// Solidity: function consentRecord(uint256 , address ) view returns(bool) -func (_HbSwap *HbSwapCallerSession) ConsentRecord(arg0 *big.Int, arg1 common.Address) (bool, error) { - return _HbSwap.Contract.ConsentRecord(&_HbSwap.CallOpts, arg0, arg1) -} - -// InputMaskOwner is a free data retrieval call binding the contract method 0xb7deef82. -// -// Solidity: function inputMaskOwner(uint256 ) view returns(address) -func (_HbSwap *HbSwapCaller) InputMaskOwner(opts *bind.CallOpts, arg0 *big.Int) (common.Address, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "inputMaskOwner", arg0) - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// InputMaskOwner is a free data retrieval call binding the contract method 0xb7deef82. -// -// Solidity: function inputMaskOwner(uint256 ) view returns(address) -func (_HbSwap *HbSwapSession) InputMaskOwner(arg0 *big.Int) (common.Address, error) { - return _HbSwap.Contract.InputMaskOwner(&_HbSwap.CallOpts, arg0) -} - -// InputMaskOwner is a free data retrieval call binding the contract method 0xb7deef82. -// -// Solidity: function inputMaskOwner(uint256 ) view returns(address) -func (_HbSwap *HbSwapCallerSession) InputMaskOwner(arg0 *big.Int) (common.Address, error) { - return _HbSwap.Contract.InputMaskOwner(&_HbSwap.CallOpts, arg0) -} - -// InputmaskCnt is a free data retrieval call binding the contract method 0x93910e66. -// -// Solidity: function inputmaskCnt() view returns(uint256) -func (_HbSwap *HbSwapCaller) InputmaskCnt(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "inputmaskCnt") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// InputmaskCnt is a free data retrieval call binding the contract method 0x93910e66. -// -// Solidity: function inputmaskCnt() view returns(uint256) -func (_HbSwap *HbSwapSession) InputmaskCnt() (*big.Int, error) { - return _HbSwap.Contract.InputmaskCnt(&_HbSwap.CallOpts) -} - -// InputmaskCnt is a free data retrieval call binding the contract method 0x93910e66. -// -// Solidity: function inputmaskCnt() view returns(uint256) -func (_HbSwap *HbSwapCallerSession) InputmaskCnt() (*big.Int, error) { - return _HbSwap.Contract.InputmaskCnt(&_HbSwap.CallOpts) -} - -// LastUpdateSeq is a free data retrieval call binding the contract method 0xa4bea6c8. -// -// Solidity: function lastUpdateSeq(address , address ) view returns(uint256) -func (_HbSwap *HbSwapCaller) LastUpdateSeq(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (*big.Int, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "lastUpdateSeq", arg0, arg1) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// LastUpdateSeq is a free data retrieval call binding the contract method 0xa4bea6c8. -// -// Solidity: function lastUpdateSeq(address , address ) view returns(uint256) -func (_HbSwap *HbSwapSession) LastUpdateSeq(arg0 common.Address, arg1 common.Address) (*big.Int, error) { - return _HbSwap.Contract.LastUpdateSeq(&_HbSwap.CallOpts, arg0, arg1) -} - -// LastUpdateSeq is a free data retrieval call binding the contract method 0xa4bea6c8. -// -// Solidity: function lastUpdateSeq(address , address ) view returns(uint256) -func (_HbSwap *HbSwapCallerSession) LastUpdateSeq(arg0 common.Address, arg1 common.Address) (*big.Int, error) { - return _HbSwap.Contract.LastUpdateSeq(&_HbSwap.CallOpts, arg0, arg1) -} - -// Prices is a free data retrieval call binding the contract method 0x1f312404. -// -// Solidity: function prices(address , address ) view returns(string) -func (_HbSwap *HbSwapCaller) Prices(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (string, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "prices", arg0, arg1) - - if err != nil { - return *new(string), err - } - - out0 := *abi.ConvertType(out[0], new(string)).(*string) - - return out0, err - -} - -// Prices is a free data retrieval call binding the contract method 0x1f312404. -// -// Solidity: function prices(address , address ) view returns(string) -func (_HbSwap *HbSwapSession) Prices(arg0 common.Address, arg1 common.Address) (string, error) { - return _HbSwap.Contract.Prices(&_HbSwap.CallOpts, arg0, arg1) -} - -// Prices is a free data retrieval call binding the contract method 0x1f312404. -// -// Solidity: function prices(address , address ) view returns(string) -func (_HbSwap *HbSwapCallerSession) Prices(arg0 common.Address, arg1 common.Address) (string, error) { - return _HbSwap.Contract.Prices(&_HbSwap.CallOpts, arg0, arg1) -} - -// PublicBalance is a free data retrieval call binding the contract method 0xe7e89276. -// -// Solidity: function publicBalance(address , address ) view returns(uint256) -func (_HbSwap *HbSwapCaller) PublicBalance(opts *bind.CallOpts, arg0 common.Address, arg1 common.Address) (*big.Int, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "publicBalance", arg0, arg1) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// PublicBalance is a free data retrieval call binding the contract method 0xe7e89276. -// -// Solidity: function publicBalance(address , address ) view returns(uint256) -func (_HbSwap *HbSwapSession) PublicBalance(arg0 common.Address, arg1 common.Address) (*big.Int, error) { - return _HbSwap.Contract.PublicBalance(&_HbSwap.CallOpts, arg0, arg1) -} - -// PublicBalance is a free data retrieval call binding the contract method 0xe7e89276. -// -// Solidity: function publicBalance(address , address ) view returns(uint256) -func (_HbSwap *HbSwapCallerSession) PublicBalance(arg0 common.Address, arg1 common.Address) (*big.Int, error) { - return _HbSwap.Contract.PublicBalance(&_HbSwap.CallOpts, arg0, arg1) -} - -// SecretWithdrawCnt is a free data retrieval call binding the contract method 0x3394dc6f. -// -// Solidity: function secretWithdrawCnt() view returns(uint256) -func (_HbSwap *HbSwapCaller) SecretWithdrawCnt(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "secretWithdrawCnt") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// SecretWithdrawCnt is a free data retrieval call binding the contract method 0x3394dc6f. -// -// Solidity: function secretWithdrawCnt() view returns(uint256) -func (_HbSwap *HbSwapSession) SecretWithdrawCnt() (*big.Int, error) { - return _HbSwap.Contract.SecretWithdrawCnt(&_HbSwap.CallOpts) -} - -// SecretWithdrawCnt is a free data retrieval call binding the contract method 0x3394dc6f. -// -// Solidity: function secretWithdrawCnt() view returns(uint256) -func (_HbSwap *HbSwapCallerSession) SecretWithdrawCnt() (*big.Int, error) { - return _HbSwap.Contract.SecretWithdrawCnt(&_HbSwap.CallOpts) -} - -// SecretWithdrawMap is a free data retrieval call binding the contract method 0x7aa6fd65. -// -// Solidity: function secretWithdrawMap(uint256 ) view returns(address token, address user, uint256 amt) -func (_HbSwap *HbSwapCaller) SecretWithdrawMap(opts *bind.CallOpts, arg0 *big.Int) (struct { - Token common.Address - User common.Address - Amt *big.Int -}, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "secretWithdrawMap", arg0) - - outstruct := new(struct { - Token common.Address - User common.Address - Amt *big.Int - }) - if err != nil { - return *outstruct, err - } - - outstruct.Token = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - outstruct.User = *abi.ConvertType(out[1], new(common.Address)).(*common.Address) - outstruct.Amt = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) - - return *outstruct, err - -} - -// SecretWithdrawMap is a free data retrieval call binding the contract method 0x7aa6fd65. -// -// Solidity: function secretWithdrawMap(uint256 ) view returns(address token, address user, uint256 amt) -func (_HbSwap *HbSwapSession) SecretWithdrawMap(arg0 *big.Int) (struct { - Token common.Address - User common.Address - Amt *big.Int -}, error) { - return _HbSwap.Contract.SecretWithdrawMap(&_HbSwap.CallOpts, arg0) -} - -// SecretWithdrawMap is a free data retrieval call binding the contract method 0x7aa6fd65. -// -// Solidity: function secretWithdrawMap(uint256 ) view returns(address token, address user, uint256 amt) -func (_HbSwap *HbSwapCallerSession) SecretWithdrawMap(arg0 *big.Int) (struct { - Token common.Address - User common.Address - Amt *big.Int -}, error) { - return _HbSwap.Contract.SecretWithdrawMap(&_HbSwap.CallOpts, arg0) -} - -// Servers is a free data retrieval call binding the contract method 0x12ada8de. -// -// Solidity: function servers(address ) view returns(bool) -func (_HbSwap *HbSwapCaller) Servers(opts *bind.CallOpts, arg0 common.Address) (bool, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "servers", arg0) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// Servers is a free data retrieval call binding the contract method 0x12ada8de. -// -// Solidity: function servers(address ) view returns(bool) -func (_HbSwap *HbSwapSession) Servers(arg0 common.Address) (bool, error) { - return _HbSwap.Contract.Servers(&_HbSwap.CallOpts, arg0) -} - -// Servers is a free data retrieval call binding the contract method 0x12ada8de. -// -// Solidity: function servers(address ) view returns(bool) -func (_HbSwap *HbSwapCallerSession) Servers(arg0 common.Address) (bool, error) { - return _HbSwap.Contract.Servers(&_HbSwap.CallOpts, arg0) -} - -// Threshold is a free data retrieval call binding the contract method 0x42cde4e8. -// -// Solidity: function threshold() view returns(uint256) -func (_HbSwap *HbSwapCaller) Threshold(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "threshold") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// Threshold is a free data retrieval call binding the contract method 0x42cde4e8. -// -// Solidity: function threshold() view returns(uint256) -func (_HbSwap *HbSwapSession) Threshold() (*big.Int, error) { - return _HbSwap.Contract.Threshold(&_HbSwap.CallOpts) -} - -// Threshold is a free data retrieval call binding the contract method 0x42cde4e8. -// -// Solidity: function threshold() view returns(uint256) -func (_HbSwap *HbSwapCallerSession) Threshold() (*big.Int, error) { - return _HbSwap.Contract.Threshold(&_HbSwap.CallOpts) -} - -// TradeCnt is a free data retrieval call binding the contract method 0xaf4170c4. -// -// Solidity: function tradeCnt() view returns(uint256) -func (_HbSwap *HbSwapCaller) TradeCnt(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _HbSwap.contract.Call(opts, &out, "tradeCnt") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// TradeCnt is a free data retrieval call binding the contract method 0xaf4170c4. -// -// Solidity: function tradeCnt() view returns(uint256) -func (_HbSwap *HbSwapSession) TradeCnt() (*big.Int, error) { - return _HbSwap.Contract.TradeCnt(&_HbSwap.CallOpts) -} - -// TradeCnt is a free data retrieval call binding the contract method 0xaf4170c4. -// -// Solidity: function tradeCnt() view returns(uint256) -func (_HbSwap *HbSwapCallerSession) TradeCnt() (*big.Int, error) { - return _HbSwap.Contract.TradeCnt(&_HbSwap.CallOpts) -} - -// AddLiquidity is a paid mutator transaction binding the contract method 0x3351733f. -// -// Solidity: function addLiquidity(address _tokenA, address _tokenB, uint256 _idxA, uint256 _idxB, uint256 _maskedAmtA, uint256 _maskedAmtB) returns() -func (_HbSwap *HbSwapTransactor) AddLiquidity(opts *bind.TransactOpts, _tokenA common.Address, _tokenB common.Address, _idxA *big.Int, _idxB *big.Int, _maskedAmtA *big.Int, _maskedAmtB *big.Int) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "addLiquidity", _tokenA, _tokenB, _idxA, _idxB, _maskedAmtA, _maskedAmtB) -} - -// AddLiquidity is a paid mutator transaction binding the contract method 0x3351733f. -// -// Solidity: function addLiquidity(address _tokenA, address _tokenB, uint256 _idxA, uint256 _idxB, uint256 _maskedAmtA, uint256 _maskedAmtB) returns() -func (_HbSwap *HbSwapSession) AddLiquidity(_tokenA common.Address, _tokenB common.Address, _idxA *big.Int, _idxB *big.Int, _maskedAmtA *big.Int, _maskedAmtB *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.AddLiquidity(&_HbSwap.TransactOpts, _tokenA, _tokenB, _idxA, _idxB, _maskedAmtA, _maskedAmtB) -} - -// AddLiquidity is a paid mutator transaction binding the contract method 0x3351733f. -// -// Solidity: function addLiquidity(address _tokenA, address _tokenB, uint256 _idxA, uint256 _idxB, uint256 _maskedAmtA, uint256 _maskedAmtB) returns() -func (_HbSwap *HbSwapTransactorSession) AddLiquidity(_tokenA common.Address, _tokenB common.Address, _idxA *big.Int, _idxB *big.Int, _maskedAmtA *big.Int, _maskedAmtB *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.AddLiquidity(&_HbSwap.TransactOpts, _tokenA, _tokenB, _idxA, _idxB, _maskedAmtA, _maskedAmtB) -} - -// Consent is a paid mutator transaction binding the contract method 0x9eef6ce8. -// -// Solidity: function consent(uint256 _seq) returns() -func (_HbSwap *HbSwapTransactor) Consent(opts *bind.TransactOpts, _seq *big.Int) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "consent", _seq) -} - -// Consent is a paid mutator transaction binding the contract method 0x9eef6ce8. -// -// Solidity: function consent(uint256 _seq) returns() -func (_HbSwap *HbSwapSession) Consent(_seq *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.Consent(&_HbSwap.TransactOpts, _seq) -} - -// Consent is a paid mutator transaction binding the contract method 0x9eef6ce8. -// -// Solidity: function consent(uint256 _seq) returns() -func (_HbSwap *HbSwapTransactorSession) Consent(_seq *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.Consent(&_HbSwap.TransactOpts, _seq) -} - -// InitPool is a paid mutator transaction binding the contract method 0x2f8a68c5. -// -// Solidity: function initPool(address _tokenA, address _tokenB, uint256 _amtA, uint256 _amtB) returns() -func (_HbSwap *HbSwapTransactor) InitPool(opts *bind.TransactOpts, _tokenA common.Address, _tokenB common.Address, _amtA *big.Int, _amtB *big.Int) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "initPool", _tokenA, _tokenB, _amtA, _amtB) -} - -// InitPool is a paid mutator transaction binding the contract method 0x2f8a68c5. -// -// Solidity: function initPool(address _tokenA, address _tokenB, uint256 _amtA, uint256 _amtB) returns() -func (_HbSwap *HbSwapSession) InitPool(_tokenA common.Address, _tokenB common.Address, _amtA *big.Int, _amtB *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.InitPool(&_HbSwap.TransactOpts, _tokenA, _tokenB, _amtA, _amtB) -} - -// InitPool is a paid mutator transaction binding the contract method 0x2f8a68c5. -// -// Solidity: function initPool(address _tokenA, address _tokenB, uint256 _amtA, uint256 _amtB) returns() -func (_HbSwap *HbSwapTransactorSession) InitPool(_tokenA common.Address, _tokenB common.Address, _amtA *big.Int, _amtB *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.InitPool(&_HbSwap.TransactOpts, _tokenA, _tokenB, _amtA, _amtB) -} - -// PublicDeposit is a paid mutator transaction binding the contract method 0x93f54644. -// -// Solidity: function publicDeposit(address _token, uint256 _amt) payable returns() -func (_HbSwap *HbSwapTransactor) PublicDeposit(opts *bind.TransactOpts, _token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "publicDeposit", _token, _amt) -} - -// PublicDeposit is a paid mutator transaction binding the contract method 0x93f54644. -// -// Solidity: function publicDeposit(address _token, uint256 _amt) payable returns() -func (_HbSwap *HbSwapSession) PublicDeposit(_token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.PublicDeposit(&_HbSwap.TransactOpts, _token, _amt) -} - -// PublicDeposit is a paid mutator transaction binding the contract method 0x93f54644. -// -// Solidity: function publicDeposit(address _token, uint256 _amt) payable returns() -func (_HbSwap *HbSwapTransactorSession) PublicDeposit(_token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.PublicDeposit(&_HbSwap.TransactOpts, _token, _amt) -} - -// PublicWithdraw is a paid mutator transaction binding the contract method 0xbc94e7cf. -// -// Solidity: function publicWithdraw(address _token, uint256 _amt) returns() -func (_HbSwap *HbSwapTransactor) PublicWithdraw(opts *bind.TransactOpts, _token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "publicWithdraw", _token, _amt) -} - -// PublicWithdraw is a paid mutator transaction binding the contract method 0xbc94e7cf. -// -// Solidity: function publicWithdraw(address _token, uint256 _amt) returns() -func (_HbSwap *HbSwapSession) PublicWithdraw(_token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.PublicWithdraw(&_HbSwap.TransactOpts, _token, _amt) -} - -// PublicWithdraw is a paid mutator transaction binding the contract method 0xbc94e7cf. -// -// Solidity: function publicWithdraw(address _token, uint256 _amt) returns() -func (_HbSwap *HbSwapTransactorSession) PublicWithdraw(_token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.PublicWithdraw(&_HbSwap.TransactOpts, _token, _amt) -} - -// RemoveLiquidity is a paid mutator transaction binding the contract method 0x3ee7f9d3. -// -// Solidity: function removeLiquidity(address _tokenA, address _tokenB, uint256 _idx, uint256 _maskedAmt) returns() -func (_HbSwap *HbSwapTransactor) RemoveLiquidity(opts *bind.TransactOpts, _tokenA common.Address, _tokenB common.Address, _idx *big.Int, _maskedAmt *big.Int) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "removeLiquidity", _tokenA, _tokenB, _idx, _maskedAmt) -} - -// RemoveLiquidity is a paid mutator transaction binding the contract method 0x3ee7f9d3. -// -// Solidity: function removeLiquidity(address _tokenA, address _tokenB, uint256 _idx, uint256 _maskedAmt) returns() -func (_HbSwap *HbSwapSession) RemoveLiquidity(_tokenA common.Address, _tokenB common.Address, _idx *big.Int, _maskedAmt *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.RemoveLiquidity(&_HbSwap.TransactOpts, _tokenA, _tokenB, _idx, _maskedAmt) -} - -// RemoveLiquidity is a paid mutator transaction binding the contract method 0x3ee7f9d3. -// -// Solidity: function removeLiquidity(address _tokenA, address _tokenB, uint256 _idx, uint256 _maskedAmt) returns() -func (_HbSwap *HbSwapTransactorSession) RemoveLiquidity(_tokenA common.Address, _tokenB common.Address, _idx *big.Int, _maskedAmt *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.RemoveLiquidity(&_HbSwap.TransactOpts, _tokenA, _tokenB, _idx, _maskedAmt) -} - -// ReserveInput is a paid mutator transaction binding the contract method 0xcc5bd7fa. -// -// Solidity: function reserveInput(uint256 _num) returns() -func (_HbSwap *HbSwapTransactor) ReserveInput(opts *bind.TransactOpts, _num *big.Int) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "reserveInput", _num) -} - -// ReserveInput is a paid mutator transaction binding the contract method 0xcc5bd7fa. -// -// Solidity: function reserveInput(uint256 _num) returns() -func (_HbSwap *HbSwapSession) ReserveInput(_num *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.ReserveInput(&_HbSwap.TransactOpts, _num) -} - -// ReserveInput is a paid mutator transaction binding the contract method 0xcc5bd7fa. -// -// Solidity: function reserveInput(uint256 _num) returns() -func (_HbSwap *HbSwapTransactorSession) ReserveInput(_num *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.ReserveInput(&_HbSwap.TransactOpts, _num) -} - -// ResetBalance is a paid mutator transaction binding the contract method 0xca7b58ad. -// -// Solidity: function resetBalance(address _token, address _user) returns() -func (_HbSwap *HbSwapTransactor) ResetBalance(opts *bind.TransactOpts, _token common.Address, _user common.Address) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "resetBalance", _token, _user) -} - -// ResetBalance is a paid mutator transaction binding the contract method 0xca7b58ad. -// -// Solidity: function resetBalance(address _token, address _user) returns() -func (_HbSwap *HbSwapSession) ResetBalance(_token common.Address, _user common.Address) (*types.Transaction, error) { - return _HbSwap.Contract.ResetBalance(&_HbSwap.TransactOpts, _token, _user) -} - -// ResetBalance is a paid mutator transaction binding the contract method 0xca7b58ad. -// -// Solidity: function resetBalance(address _token, address _user) returns() -func (_HbSwap *HbSwapTransactorSession) ResetBalance(_token common.Address, _user common.Address) (*types.Transaction, error) { - return _HbSwap.Contract.ResetBalance(&_HbSwap.TransactOpts, _token, _user) -} - -// ResetPrice is a paid mutator transaction binding the contract method 0x9450fb26. -// -// Solidity: function resetPrice(address _tokenA, address _tokenB, address[] _servers) returns() -func (_HbSwap *HbSwapTransactor) ResetPrice(opts *bind.TransactOpts, _tokenA common.Address, _tokenB common.Address, _servers []common.Address) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "resetPrice", _tokenA, _tokenB, _servers) -} - -// ResetPrice is a paid mutator transaction binding the contract method 0x9450fb26. -// -// Solidity: function resetPrice(address _tokenA, address _tokenB, address[] _servers) returns() -func (_HbSwap *HbSwapSession) ResetPrice(_tokenA common.Address, _tokenB common.Address, _servers []common.Address) (*types.Transaction, error) { - return _HbSwap.Contract.ResetPrice(&_HbSwap.TransactOpts, _tokenA, _tokenB, _servers) -} - -// ResetPrice is a paid mutator transaction binding the contract method 0x9450fb26. -// -// Solidity: function resetPrice(address _tokenA, address _tokenB, address[] _servers) returns() -func (_HbSwap *HbSwapTransactorSession) ResetPrice(_tokenA common.Address, _tokenB common.Address, _servers []common.Address) (*types.Transaction, error) { - return _HbSwap.Contract.ResetPrice(&_HbSwap.TransactOpts, _tokenA, _tokenB, _servers) -} - -// SecretDeposit is a paid mutator transaction binding the contract method 0xade28aad. -// -// Solidity: function secretDeposit(address _token, uint256 _amt) returns() -func (_HbSwap *HbSwapTransactor) SecretDeposit(opts *bind.TransactOpts, _token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "secretDeposit", _token, _amt) -} - -// SecretDeposit is a paid mutator transaction binding the contract method 0xade28aad. -// -// Solidity: function secretDeposit(address _token, uint256 _amt) returns() -func (_HbSwap *HbSwapSession) SecretDeposit(_token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.SecretDeposit(&_HbSwap.TransactOpts, _token, _amt) -} - -// SecretDeposit is a paid mutator transaction binding the contract method 0xade28aad. -// -// Solidity: function secretDeposit(address _token, uint256 _amt) returns() -func (_HbSwap *HbSwapTransactorSession) SecretDeposit(_token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.SecretDeposit(&_HbSwap.TransactOpts, _token, _amt) -} - -// SecretWithdraw is a paid mutator transaction binding the contract method 0xdee40595. -// -// Solidity: function secretWithdraw(address _token, uint256 _amt) returns() -func (_HbSwap *HbSwapTransactor) SecretWithdraw(opts *bind.TransactOpts, _token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "secretWithdraw", _token, _amt) -} - -// SecretWithdraw is a paid mutator transaction binding the contract method 0xdee40595. -// -// Solidity: function secretWithdraw(address _token, uint256 _amt) returns() -func (_HbSwap *HbSwapSession) SecretWithdraw(_token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.SecretWithdraw(&_HbSwap.TransactOpts, _token, _amt) -} - -// SecretWithdraw is a paid mutator transaction binding the contract method 0xdee40595. -// -// Solidity: function secretWithdraw(address _token, uint256 _amt) returns() -func (_HbSwap *HbSwapTransactorSession) SecretWithdraw(_token common.Address, _amt *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.SecretWithdraw(&_HbSwap.TransactOpts, _token, _amt) -} - -// Trade is a paid mutator transaction binding the contract method 0xb72a2139. -// -// Solidity: function trade(address _tokenA, address _tokenB, uint256 _idxA, uint256 _idxB, uint256 _maskedA, uint256 _maskedB) returns() -func (_HbSwap *HbSwapTransactor) Trade(opts *bind.TransactOpts, _tokenA common.Address, _tokenB common.Address, _idxA *big.Int, _idxB *big.Int, _maskedA *big.Int, _maskedB *big.Int) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "trade", _tokenA, _tokenB, _idxA, _idxB, _maskedA, _maskedB) -} - -// Trade is a paid mutator transaction binding the contract method 0xb72a2139. -// -// Solidity: function trade(address _tokenA, address _tokenB, uint256 _idxA, uint256 _idxB, uint256 _maskedA, uint256 _maskedB) returns() -func (_HbSwap *HbSwapSession) Trade(_tokenA common.Address, _tokenB common.Address, _idxA *big.Int, _idxB *big.Int, _maskedA *big.Int, _maskedB *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.Trade(&_HbSwap.TransactOpts, _tokenA, _tokenB, _idxA, _idxB, _maskedA, _maskedB) -} - -// Trade is a paid mutator transaction binding the contract method 0xb72a2139. -// -// Solidity: function trade(address _tokenA, address _tokenB, uint256 _idxA, uint256 _idxB, uint256 _maskedA, uint256 _maskedB) returns() -func (_HbSwap *HbSwapTransactorSession) Trade(_tokenA common.Address, _tokenB common.Address, _idxA *big.Int, _idxB *big.Int, _maskedA *big.Int, _maskedB *big.Int) (*types.Transaction, error) { - return _HbSwap.Contract.Trade(&_HbSwap.TransactOpts, _tokenA, _tokenB, _idxA, _idxB, _maskedA, _maskedB) -} - -// UpdatePrice is a paid mutator transaction binding the contract method 0x3766dba7. -// -// Solidity: function updatePrice(address _tokenA, address _tokenB, uint256 _checkpointSeq, string _price) returns() -func (_HbSwap *HbSwapTransactor) UpdatePrice(opts *bind.TransactOpts, _tokenA common.Address, _tokenB common.Address, _checkpointSeq *big.Int, _price string) (*types.Transaction, error) { - return _HbSwap.contract.Transact(opts, "updatePrice", _tokenA, _tokenB, _checkpointSeq, _price) -} - -// UpdatePrice is a paid mutator transaction binding the contract method 0x3766dba7. -// -// Solidity: function updatePrice(address _tokenA, address _tokenB, uint256 _checkpointSeq, string _price) returns() -func (_HbSwap *HbSwapSession) UpdatePrice(_tokenA common.Address, _tokenB common.Address, _checkpointSeq *big.Int, _price string) (*types.Transaction, error) { - return _HbSwap.Contract.UpdatePrice(&_HbSwap.TransactOpts, _tokenA, _tokenB, _checkpointSeq, _price) -} - -// UpdatePrice is a paid mutator transaction binding the contract method 0x3766dba7. -// -// Solidity: function updatePrice(address _tokenA, address _tokenB, uint256 _checkpointSeq, string _price) returns() -func (_HbSwap *HbSwapTransactorSession) UpdatePrice(_tokenA common.Address, _tokenB common.Address, _checkpointSeq *big.Int, _price string) (*types.Transaction, error) { - return _HbSwap.Contract.UpdatePrice(&_HbSwap.TransactOpts, _tokenA, _tokenB, _checkpointSeq, _price) -} - -// HbSwapAddLiquidityIterator is returned from FilterAddLiquidity and is used to iterate over the raw logs and unpacked data for AddLiquidity events raised by the HbSwap contract. -type HbSwapAddLiquidityIterator struct { - Event *HbSwapAddLiquidity // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HbSwapAddLiquidityIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HbSwapAddLiquidity) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HbSwapAddLiquidity) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HbSwapAddLiquidityIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HbSwapAddLiquidityIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HbSwapAddLiquidity represents a AddLiquidity event raised by the HbSwap contract. -type HbSwapAddLiquidity struct { - User common.Address - TokenA common.Address - TokenB common.Address - IdxA *big.Int - IdxB *big.Int - MaskedAmtA *big.Int - MaskedAmtB *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterAddLiquidity is a free log retrieval operation binding the contract event 0xec7d4752dd44bf7fc59045c9d80163de2a1b9dbd9032d11cb1156f7f867c6411. -// -// Solidity: event AddLiquidity(address user, address tokenA, address tokenB, uint256 idxA, uint256 idxB, uint256 maskedAmtA, uint256 maskedAmtB) -func (_HbSwap *HbSwapFilterer) FilterAddLiquidity(opts *bind.FilterOpts) (*HbSwapAddLiquidityIterator, error) { - - logs, sub, err := _HbSwap.contract.FilterLogs(opts, "AddLiquidity") - if err != nil { - return nil, err - } - return &HbSwapAddLiquidityIterator{contract: _HbSwap.contract, event: "AddLiquidity", logs: logs, sub: sub}, nil -} - -// WatchAddLiquidity is a free log subscription operation binding the contract event 0xec7d4752dd44bf7fc59045c9d80163de2a1b9dbd9032d11cb1156f7f867c6411. -// -// Solidity: event AddLiquidity(address user, address tokenA, address tokenB, uint256 idxA, uint256 idxB, uint256 maskedAmtA, uint256 maskedAmtB) -func (_HbSwap *HbSwapFilterer) WatchAddLiquidity(opts *bind.WatchOpts, sink chan<- *HbSwapAddLiquidity) (event.Subscription, error) { - - logs, sub, err := _HbSwap.contract.WatchLogs(opts, "AddLiquidity") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HbSwapAddLiquidity) - if err := _HbSwap.contract.UnpackLog(event, "AddLiquidity", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseAddLiquidity is a log parse operation binding the contract event 0xec7d4752dd44bf7fc59045c9d80163de2a1b9dbd9032d11cb1156f7f867c6411. -// -// Solidity: event AddLiquidity(address user, address tokenA, address tokenB, uint256 idxA, uint256 idxB, uint256 maskedAmtA, uint256 maskedAmtB) -func (_HbSwap *HbSwapFilterer) ParseAddLiquidity(log types.Log) (*HbSwapAddLiquidity, error) { - event := new(HbSwapAddLiquidity) - if err := _HbSwap.contract.UnpackLog(event, "AddLiquidity", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// HbSwapInitPoolIterator is returned from FilterInitPool and is used to iterate over the raw logs and unpacked data for InitPool events raised by the HbSwap contract. -type HbSwapInitPoolIterator struct { - Event *HbSwapInitPool // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HbSwapInitPoolIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HbSwapInitPool) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HbSwapInitPool) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HbSwapInitPoolIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HbSwapInitPoolIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HbSwapInitPool represents a InitPool event raised by the HbSwap contract. -type HbSwapInitPool struct { - User common.Address - TokenA common.Address - TokenB common.Address - AmtA *big.Int - AmtB *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterInitPool is a free log retrieval operation binding the contract event 0xfaaebcb30b1b421f4f2ca7f2620e5add6a64532c087ee0646fd665a33d36fdf5. -// -// Solidity: event InitPool(address user, address tokenA, address tokenB, uint256 amtA, uint256 amtB) -func (_HbSwap *HbSwapFilterer) FilterInitPool(opts *bind.FilterOpts) (*HbSwapInitPoolIterator, error) { - - logs, sub, err := _HbSwap.contract.FilterLogs(opts, "InitPool") - if err != nil { - return nil, err - } - return &HbSwapInitPoolIterator{contract: _HbSwap.contract, event: "InitPool", logs: logs, sub: sub}, nil -} - -// WatchInitPool is a free log subscription operation binding the contract event 0xfaaebcb30b1b421f4f2ca7f2620e5add6a64532c087ee0646fd665a33d36fdf5. -// -// Solidity: event InitPool(address user, address tokenA, address tokenB, uint256 amtA, uint256 amtB) -func (_HbSwap *HbSwapFilterer) WatchInitPool(opts *bind.WatchOpts, sink chan<- *HbSwapInitPool) (event.Subscription, error) { - - logs, sub, err := _HbSwap.contract.WatchLogs(opts, "InitPool") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HbSwapInitPool) - if err := _HbSwap.contract.UnpackLog(event, "InitPool", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseInitPool is a log parse operation binding the contract event 0xfaaebcb30b1b421f4f2ca7f2620e5add6a64532c087ee0646fd665a33d36fdf5. -// -// Solidity: event InitPool(address user, address tokenA, address tokenB, uint256 amtA, uint256 amtB) -func (_HbSwap *HbSwapFilterer) ParseInitPool(log types.Log) (*HbSwapInitPool, error) { - event := new(HbSwapInitPool) - if err := _HbSwap.contract.UnpackLog(event, "InitPool", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// HbSwapInputMaskIterator is returned from FilterInputMask and is used to iterate over the raw logs and unpacked data for InputMask events raised by the HbSwap contract. -type HbSwapInputMaskIterator struct { - Event *HbSwapInputMask // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HbSwapInputMaskIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HbSwapInputMask) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HbSwapInputMask) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HbSwapInputMaskIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HbSwapInputMaskIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HbSwapInputMask represents a InputMask event raised by the HbSwap contract. -type HbSwapInputMask struct { - InpusMaskIndexes []*big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterInputMask is a free log retrieval operation binding the contract event 0xff742b54a62e49c065680fc16aa208f37f60ded27e03a3d19e6088ba0c7b41d4. -// -// Solidity: event InputMask(uint256[] inpusMaskIndexes) -func (_HbSwap *HbSwapFilterer) FilterInputMask(opts *bind.FilterOpts) (*HbSwapInputMaskIterator, error) { - - logs, sub, err := _HbSwap.contract.FilterLogs(opts, "InputMask") - if err != nil { - return nil, err - } - return &HbSwapInputMaskIterator{contract: _HbSwap.contract, event: "InputMask", logs: logs, sub: sub}, nil -} - -// WatchInputMask is a free log subscription operation binding the contract event 0xff742b54a62e49c065680fc16aa208f37f60ded27e03a3d19e6088ba0c7b41d4. -// -// Solidity: event InputMask(uint256[] inpusMaskIndexes) -func (_HbSwap *HbSwapFilterer) WatchInputMask(opts *bind.WatchOpts, sink chan<- *HbSwapInputMask) (event.Subscription, error) { - - logs, sub, err := _HbSwap.contract.WatchLogs(opts, "InputMask") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HbSwapInputMask) - if err := _HbSwap.contract.UnpackLog(event, "InputMask", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseInputMask is a log parse operation binding the contract event 0xff742b54a62e49c065680fc16aa208f37f60ded27e03a3d19e6088ba0c7b41d4. -// -// Solidity: event InputMask(uint256[] inpusMaskIndexes) -func (_HbSwap *HbSwapFilterer) ParseInputMask(log types.Log) (*HbSwapInputMask, error) { - event := new(HbSwapInputMask) - if err := _HbSwap.contract.UnpackLog(event, "InputMask", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// HbSwapRemoveLiquidityIterator is returned from FilterRemoveLiquidity and is used to iterate over the raw logs and unpacked data for RemoveLiquidity events raised by the HbSwap contract. -type HbSwapRemoveLiquidityIterator struct { - Event *HbSwapRemoveLiquidity // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HbSwapRemoveLiquidityIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HbSwapRemoveLiquidity) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HbSwapRemoveLiquidity) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HbSwapRemoveLiquidityIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HbSwapRemoveLiquidityIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HbSwapRemoveLiquidity represents a RemoveLiquidity event raised by the HbSwap contract. -type HbSwapRemoveLiquidity struct { - User common.Address - TokenA common.Address - TokenB common.Address - Idx *big.Int - MaskedAmt *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterRemoveLiquidity is a free log retrieval operation binding the contract event 0xa8dbaaebbb025c88e9e34c84635cd8238043556e9af43fb161508c898a8e1ef9. -// -// Solidity: event RemoveLiquidity(address user, address tokenA, address tokenB, uint256 idx, uint256 maskedAmt) -func (_HbSwap *HbSwapFilterer) FilterRemoveLiquidity(opts *bind.FilterOpts) (*HbSwapRemoveLiquidityIterator, error) { - - logs, sub, err := _HbSwap.contract.FilterLogs(opts, "RemoveLiquidity") - if err != nil { - return nil, err - } - return &HbSwapRemoveLiquidityIterator{contract: _HbSwap.contract, event: "RemoveLiquidity", logs: logs, sub: sub}, nil -} - -// WatchRemoveLiquidity is a free log subscription operation binding the contract event 0xa8dbaaebbb025c88e9e34c84635cd8238043556e9af43fb161508c898a8e1ef9. -// -// Solidity: event RemoveLiquidity(address user, address tokenA, address tokenB, uint256 idx, uint256 maskedAmt) -func (_HbSwap *HbSwapFilterer) WatchRemoveLiquidity(opts *bind.WatchOpts, sink chan<- *HbSwapRemoveLiquidity) (event.Subscription, error) { - - logs, sub, err := _HbSwap.contract.WatchLogs(opts, "RemoveLiquidity") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HbSwapRemoveLiquidity) - if err := _HbSwap.contract.UnpackLog(event, "RemoveLiquidity", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseRemoveLiquidity is a log parse operation binding the contract event 0xa8dbaaebbb025c88e9e34c84635cd8238043556e9af43fb161508c898a8e1ef9. -// -// Solidity: event RemoveLiquidity(address user, address tokenA, address tokenB, uint256 idx, uint256 maskedAmt) -func (_HbSwap *HbSwapFilterer) ParseRemoveLiquidity(log types.Log) (*HbSwapRemoveLiquidity, error) { - event := new(HbSwapRemoveLiquidity) - if err := _HbSwap.contract.UnpackLog(event, "RemoveLiquidity", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// HbSwapSecretDepositIterator is returned from FilterSecretDeposit and is used to iterate over the raw logs and unpacked data for SecretDeposit events raised by the HbSwap contract. -type HbSwapSecretDepositIterator struct { - Event *HbSwapSecretDeposit // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HbSwapSecretDepositIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HbSwapSecretDeposit) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HbSwapSecretDeposit) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HbSwapSecretDepositIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HbSwapSecretDepositIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HbSwapSecretDeposit represents a SecretDeposit event raised by the HbSwap contract. -type HbSwapSecretDeposit struct { - Token common.Address - User common.Address - Amt *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterSecretDeposit is a free log retrieval operation binding the contract event 0x07c06144435b7d2bdccf9ee7e5a7022c63382ac7c3a0e14ed08b5969dedf0ecf. -// -// Solidity: event SecretDeposit(address token, address user, uint256 amt) -func (_HbSwap *HbSwapFilterer) FilterSecretDeposit(opts *bind.FilterOpts) (*HbSwapSecretDepositIterator, error) { - - logs, sub, err := _HbSwap.contract.FilterLogs(opts, "SecretDeposit") - if err != nil { - return nil, err - } - return &HbSwapSecretDepositIterator{contract: _HbSwap.contract, event: "SecretDeposit", logs: logs, sub: sub}, nil -} - -// WatchSecretDeposit is a free log subscription operation binding the contract event 0x07c06144435b7d2bdccf9ee7e5a7022c63382ac7c3a0e14ed08b5969dedf0ecf. -// -// Solidity: event SecretDeposit(address token, address user, uint256 amt) -func (_HbSwap *HbSwapFilterer) WatchSecretDeposit(opts *bind.WatchOpts, sink chan<- *HbSwapSecretDeposit) (event.Subscription, error) { - - logs, sub, err := _HbSwap.contract.WatchLogs(opts, "SecretDeposit") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HbSwapSecretDeposit) - if err := _HbSwap.contract.UnpackLog(event, "SecretDeposit", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseSecretDeposit is a log parse operation binding the contract event 0x07c06144435b7d2bdccf9ee7e5a7022c63382ac7c3a0e14ed08b5969dedf0ecf. -// -// Solidity: event SecretDeposit(address token, address user, uint256 amt) -func (_HbSwap *HbSwapFilterer) ParseSecretDeposit(log types.Log) (*HbSwapSecretDeposit, error) { - event := new(HbSwapSecretDeposit) - if err := _HbSwap.contract.UnpackLog(event, "SecretDeposit", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// HbSwapSecretWithdrawIterator is returned from FilterSecretWithdraw and is used to iterate over the raw logs and unpacked data for SecretWithdraw events raised by the HbSwap contract. -type HbSwapSecretWithdrawIterator struct { - Event *HbSwapSecretWithdraw // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HbSwapSecretWithdrawIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HbSwapSecretWithdraw) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HbSwapSecretWithdraw) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HbSwapSecretWithdrawIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HbSwapSecretWithdrawIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HbSwapSecretWithdraw represents a SecretWithdraw event raised by the HbSwap contract. -type HbSwapSecretWithdraw struct { - Seq *big.Int - Token common.Address - User common.Address - Amt *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterSecretWithdraw is a free log retrieval operation binding the contract event 0x4ef3cc4825a92c3b6922acc8a45152cc96ef48463e8ed500dacd5df9e29a67f3. -// -// Solidity: event SecretWithdraw(uint256 seq, address token, address user, uint256 amt) -func (_HbSwap *HbSwapFilterer) FilterSecretWithdraw(opts *bind.FilterOpts) (*HbSwapSecretWithdrawIterator, error) { - - logs, sub, err := _HbSwap.contract.FilterLogs(opts, "SecretWithdraw") - if err != nil { - return nil, err - } - return &HbSwapSecretWithdrawIterator{contract: _HbSwap.contract, event: "SecretWithdraw", logs: logs, sub: sub}, nil -} - -// WatchSecretWithdraw is a free log subscription operation binding the contract event 0x4ef3cc4825a92c3b6922acc8a45152cc96ef48463e8ed500dacd5df9e29a67f3. -// -// Solidity: event SecretWithdraw(uint256 seq, address token, address user, uint256 amt) -func (_HbSwap *HbSwapFilterer) WatchSecretWithdraw(opts *bind.WatchOpts, sink chan<- *HbSwapSecretWithdraw) (event.Subscription, error) { - - logs, sub, err := _HbSwap.contract.WatchLogs(opts, "SecretWithdraw") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HbSwapSecretWithdraw) - if err := _HbSwap.contract.UnpackLog(event, "SecretWithdraw", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseSecretWithdraw is a log parse operation binding the contract event 0x4ef3cc4825a92c3b6922acc8a45152cc96ef48463e8ed500dacd5df9e29a67f3. -// -// Solidity: event SecretWithdraw(uint256 seq, address token, address user, uint256 amt) -func (_HbSwap *HbSwapFilterer) ParseSecretWithdraw(log types.Log) (*HbSwapSecretWithdraw, error) { - event := new(HbSwapSecretWithdraw) - if err := _HbSwap.contract.UnpackLog(event, "SecretWithdraw", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// HbSwapTradeIterator is returned from FilterTrade and is used to iterate over the raw logs and unpacked data for Trade events raised by the HbSwap contract. -type HbSwapTradeIterator struct { - Event *HbSwapTrade // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *HbSwapTradeIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(HbSwapTrade) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(HbSwapTrade) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *HbSwapTradeIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *HbSwapTradeIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// HbSwapTrade represents a Trade event raised by the HbSwap contract. -type HbSwapTrade struct { - TradeSeq *big.Int - User common.Address - TokenA common.Address - TokenB common.Address - IdxA *big.Int - IdxB *big.Int - MaskedAmtA *big.Int - MaskedAmtB *big.Int - Raw types.Log // Blockchain specific contextual infos -} - -// FilterTrade is a free log retrieval operation binding the contract event 0x2b4d91cd20cc8800407e3614b8466a6f0729ac3b1fa43d4e2b059ff5593cbae6. -// -// Solidity: event Trade(uint256 tradeSeq, address user, address tokenA, address tokenB, uint256 idxA, uint256 idxB, uint256 maskedAmtA, uint256 maskedAmtB) -func (_HbSwap *HbSwapFilterer) FilterTrade(opts *bind.FilterOpts) (*HbSwapTradeIterator, error) { - - logs, sub, err := _HbSwap.contract.FilterLogs(opts, "Trade") - if err != nil { - return nil, err - } - return &HbSwapTradeIterator{contract: _HbSwap.contract, event: "Trade", logs: logs, sub: sub}, nil -} - -// WatchTrade is a free log subscription operation binding the contract event 0x2b4d91cd20cc8800407e3614b8466a6f0729ac3b1fa43d4e2b059ff5593cbae6. -// -// Solidity: event Trade(uint256 tradeSeq, address user, address tokenA, address tokenB, uint256 idxA, uint256 idxB, uint256 maskedAmtA, uint256 maskedAmtB) -func (_HbSwap *HbSwapFilterer) WatchTrade(opts *bind.WatchOpts, sink chan<- *HbSwapTrade) (event.Subscription, error) { - - logs, sub, err := _HbSwap.contract.WatchLogs(opts, "Trade") - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(HbSwapTrade) - if err := _HbSwap.contract.UnpackLog(event, "Trade", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseTrade is a log parse operation binding the contract event 0x2b4d91cd20cc8800407e3614b8466a6f0729ac3b1fa43d4e2b059ff5593cbae6. -// -// Solidity: event Trade(uint256 tradeSeq, address user, address tokenA, address tokenB, uint256 idxA, uint256 idxB, uint256 maskedAmtA, uint256 maskedAmtB) -func (_HbSwap *HbSwapFilterer) ParseTrade(log types.Log) (*HbSwapTrade, error) { - event := new(HbSwapTrade) - if err := _HbSwap.contract.UnpackLog(event, "Trade", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/src/mpc/hbswap_add_liquidity.mpc b/src/mpc/hbswap_add_liquidity.mpc deleted file mode 100644 index 57024e37..00000000 --- a/src/mpc/hbswap_add_liquidity.mpc +++ /dev/null @@ -1,84 +0,0 @@ -n = 4 - -def read_sint(idx): - start = regint(idx * 32) - end = regint() - share = sint() - readsharesfromfile(start, end, share) - return share - -def read_sfix(idx): - return sfix._new(read_sint(idx)) - -def write_sfix(x): - writesharestofile(x.v) - -def main(): - balance_A = read_sfix(0) - print_ln('balance_A %s', balance_A.reveal()) - amt_A = read_sfix(1) - print_ln('amt_A %s', amt_A.reveal()) - enough_A = balance_A >= amt_A - print_ln('enough_A %s', enough_A.reveal()) - positive_A = amt_A > 0 - print_ln('positive_A %s', positive_A.reveal()) - - balance_B = read_sfix(2) - print_ln('balance_B %s', balance_B.reveal()) - amt_B = read_sfix(3) - print_ln('amt_B %s', amt_B.reveal()) - enough_B = balance_B >= amt_B - print_ln('enough_B %s', enough_B.reveal()) - positive_B = amt_B > 0 - print_ln('positive_B %s', positive_B.reveal()) - - total_supply_LT = read_sfix(4) - print_ln('total_supply_LT %s', total_supply_LT.reveal()) - positive_total_LT = total_supply_LT > 0 - print_ln('positive_total_LT %s', positive_total_LT.reveal()) - - valid_order = enough_A * positive_A * enough_B * positive_B * positive_total_LT - print_ln('valid_order %s', valid_order.reveal()) - - pool_A = read_sfix(5) - print_ln('pool_A %s', pool_A.reveal()) - pool_B = read_sfix(6) - print_ln('pool_B %s', pool_B.reveal()) - - surplus_A = amt_A * pool_B > amt_B * pool_A - print_ln('surplus_A %s', surplus_A.reveal()) - non_surplus_A = 1 - surplus_A - print_ln('non_surplus_A %s', non_surplus_A.reveal()) - - change_A = valid_order * (surplus_A * amt_B * pool_A / pool_B + non_surplus_A * amt_A) - print_ln('change_A %s', change_A.reveal()) - change_B = valid_order * (surplus_A * amt_B + non_surplus_A * amt_A * pool_B / pool_A) - print_ln('change_B %s', change_B.reveal()) - change_LT = change_A * total_supply_LT / pool_A - print_ln('change_LT %s', change_LT.reveal()) - - pool_A += change_A - print_ln('pool_A %s', pool_A.reveal()) - write_sfix(pool_A) - pool_B += change_B - print_ln('pool_B %s', pool_B.reveal()) - write_sfix(pool_B) - - balance_A -= change_A - print_ln('balance_A %s', balance_A.reveal()) - write_sfix(balance_A) - balance_B -= change_B - print_ln('balance_B %s', balance_B.reveal()) - write_sfix(balance_B) - - balance_LT = read_sfix(7) - print_ln('balance_LT %s', balance_LT.reveal()) - balance_LT += change_LT - print_ln('balance_LT %s', balance_LT.reveal()) - write_sfix(balance_LT) - - total_supply_LT += change_LT - print_ln('total_supply_LT %s', total_supply_LT.reveal()) - write_sfix(total_supply_LT) - -main() diff --git a/src/mpc/hbswap_calc_batch_price.mpc b/src/mpc/hbswap_calc_batch_price.mpc deleted file mode 100644 index 0c2133b1..00000000 --- a/src/mpc/hbswap_calc_batch_price.mpc +++ /dev/null @@ -1,32 +0,0 @@ -n = 4 -fee_rate = 0.003 - -def read_sint(idx): - start = regint(idx * 32) - end = regint() - share = sint() - readsharesfromfile(start, end, share) - return share - -def read_sfix(idx): - return sfix._new(read_sint(idx)) - -def write_sfix(x): - writesharestofile(x.v) - -def public_reveal(x): - for i in range(n): - x.reveal_to(i) - -def main(): - total_price = read_sfix(0) - print_ln('total_price %s', total_price.reveal()) - - total_cnt = read_sfix(1) - print_ln('total_cnt %s', total_cnt.reveal()) - - batch_price = total_price / total_cnt - print_ln('batch_price %s', batch_price.reveal()) - public_reveal(batch_price) - -main() diff --git a/src/mpc/hbswap_calc_individual_price.mpc b/src/mpc/hbswap_calc_individual_price.mpc deleted file mode 100644 index 3978635c..00000000 --- a/src/mpc/hbswap_calc_individual_price.mpc +++ /dev/null @@ -1,38 +0,0 @@ -n = 4 -fee_rate = 0.003 - -def read_sint(idx): - start = regint(idx * 32) - end = regint() - share = sint() - readsharesfromfile(start, end, share) - return share - -def read_sfix(idx): - return sfix._new(read_sint(idx)) - -def write_sfix(x): - writesharestofile(x.v) - -def public_reveal(x): - for i in range(n): - x.reveal_to(i) - -def main(): - change_B = read_sfix(0) - print_ln('change_B %s', change_B.reveal()) - - change_A = read_sfix(1) - print_ln('change_A %s', change_A.reveal()) - - price = -change_B / change_A - print_ln('price %s', price.reveal()) - write_sfix(price) - - total_price = read_sfix(2) - print_ln('total_price %s', total_price.reveal()) - total_price += price - print_ln('total_price %s', total_price.reveal()) - write_sfix(total_price) - -main() diff --git a/src/mpc/hbswap_init_pool.mpc b/src/mpc/hbswap_init_pool.mpc deleted file mode 100644 index 19bf97e6..00000000 --- a/src/mpc/hbswap_init_pool.mpc +++ /dev/null @@ -1,41 +0,0 @@ -n = 4 - -def read_sint(idx): - start = regint(idx * 32) - end = regint() - share = sint() - readsharesfromfile(start, end, share) - return share - -def read_sfix(idx): - return sfix._new(read_sint(idx)) - -def public_reveal(x): - for i in range(n): - x.reveal_to(i) - -def main(): - balance_A = read_sfix(0) - print_ln('balance_A %s', balance_A.reveal()) - amt_A = read_sfix(1) - print_ln('amt_A %s', amt_A.reveal()) - enough_A = balance_A >= amt_A - print_ln('enough_A %s', enough_A.reveal()) - - balance_B = read_sfix(2) - print_ln('balance_B %s', balance_B.reveal()) - amt_B = read_sfix(3) - print_ln('amt_B %s', amt_B.reveal()) - enough_B = balance_B >= amt_B - print_ln('enough_B %s', enough_B.reveal()) - - total_supply_LT = read_sfix(4) - print_ln('total_supply_LT %s', total_supply_LT.reveal()) - zero_total_LT = total_supply_LT == 0 - print_ln('zero_total_LT %s', zero_total_LT.reveal()) - - valid_order = enough_A * enough_B * zero_total_LT - print_ln('valid_order %s', valid_order.reveal()) - public_reveal(valid_order) - -main() diff --git a/src/mpc/hbswap_remove_liquidity.mpc b/src/mpc/hbswap_remove_liquidity.mpc deleted file mode 100644 index 3fd4d48c..00000000 --- a/src/mpc/hbswap_remove_liquidity.mpc +++ /dev/null @@ -1,76 +0,0 @@ -n = 4 - -def read_sint(idx): - start = regint(idx * 32) - end = regint() - share = sint() - readsharesfromfile(start, end, share) - return share - -def read_sfix(idx): - return sfix._new(read_sint(idx)) - -def write_sfix(x): - writesharestofile(x.v) - -def public_reveal(x): - for i in range(n): - x.reveal_to(i) - -def main(): - balance_LT = read_sfix(0) - print_ln('balance_LT %s', balance_LT.reveal()) - amt = read_sfix(1) - print_ln('amt %s', amt.reveal()) - enough_LT = balance_LT >= amt - print_ln('enough_LT %s', enough_LT.reveal()) - positive_LT = amt > 0 - print_ln('positive_LT %s', positive_LT.reveal()) - - valid_order = enough_LT * positive_LT - print_ln('valid_order %s', valid_order.reveal()) - - pool_A = read_sfix(2) - print_ln('pool_A %s', pool_A.reveal()) - pool_B = read_sfix(3) - print_ln('pool_B %s', pool_B.reveal()) - - change_LT = valid_order * amt - print_ln('change_LT %s', change_LT.reveal()) - total_supply_LT = read_sfix(4) - print_ln('total_supply_LT %s', total_supply_LT.reveal()) - change_A = change_LT * pool_A / total_supply_LT - print_ln('change_A %s', change_A.reveal()) - change_B = change_LT * pool_B / total_supply_LT - print_ln('change_B %s', change_B.reveal()) - - pool_A -= change_A - print_ln('pool_A %s', pool_A.reveal()) - write_sfix(pool_A) - pool_B -= change_B - print_ln('pool_B %s', pool_B.reveal()) - write_sfix(pool_B) - - balance_A = read_sfix(5) - print_ln('balance_A %s', balance_A.reveal()) - balance_A += change_A - print_ln('balance_A %s', balance_A.reveal()) - write_sfix(balance_A) - balance_B = read_sfix(6) - print_ln('balance_B %s', balance_B.reveal()) - balance_B += change_B - print_ln('balance_B %s', balance_B.reveal()) - write_sfix(balance_B) - - balance_LT -= change_LT - print_ln('balance_LT %s', balance_LT.reveal()) - write_sfix(balance_LT) - - total_supply_LT -= change_LT - print_ln('total_supply_LT %s', total_supply_LT.reveal()) - write_sfix(total_supply_LT) - - zero_total_LT = total_supply_LT == 0 - public_reveal(zero_total_LT) - -main() diff --git a/src/mpc/hbswap_secret_withdraw.mpc b/src/mpc/hbswap_secret_withdraw.mpc deleted file mode 100644 index 87deb2f7..00000000 --- a/src/mpc/hbswap_secret_withdraw.mpc +++ /dev/null @@ -1,26 +0,0 @@ -n = 4 - -def read_sint(idx): - start = regint(idx * 32) - end = regint() - share = sint() - readsharesfromfile(start, end, share) - return share - -def read_sfix(idx): - return sfix._new(read_sint(idx)) - -def public_reveal(x): - for i in range(n): - x.reveal_to(i) - -def main(): - balance = read_sfix(0) - print_ln('balance %s', balance.reveal()) - amt = read_sfix(1) - print_ln('amt %s', amt.reveal()) - enough = balance >= amt - print_ln('enough %s', enough.reveal()) - public_reveal(enough) - -main() diff --git a/src/mpc/hbswap_trade.mpc b/src/mpc/hbswap_trade.mpc deleted file mode 100644 index 36ae4651..00000000 --- a/src/mpc/hbswap_trade.mpc +++ /dev/null @@ -1,88 +0,0 @@ -n = 4 -fee_rate = 0.003 - -def read_sint(idx): - start = regint(idx * 32) - end = regint() - share = sint() - readsharesfromfile(start, end, share) - return share - -def read_sfix(idx): - return sfix._new(read_sint(idx)) - -def write_sfix(x): - writesharestofile(x.v) - -def public_reveal(x): - for i in range(n): - x.reveal_to(i) - -def main(): - amt_A = read_sfix(0) - print_ln('amt_A %s', amt_A.reveal()) - amt_B = read_sfix(1) - print_ln('amt_B %s', amt_B.reveal()) - valid_order = (amt_A * amt_B) < 0 - print_ln('valid_order %s', valid_order.reveal()) - - buy_A = amt_A > 0 - print_ln('buy_A %s', buy_A.reveal()) - total_B = (1 + fee_rate) * amt_B - print_ln('total_B %s', total_B.reveal()) - balance_B = read_sfix(2) - print_ln('balance_B %s', balance_B.reveal()) - enough_B = -total_B <= balance_B - print_ln('enough_B %s', enough_B.reveal()) - pool_A = read_sfix(3) - print_ln('pool_A %s', pool_A.reveal()) - pool_B = read_sfix(4) - print_ln('pool_B %s', pool_B.reveal()) - actual_amt_A = pool_A - pool_B * pool_A / (pool_B - amt_B) - print_ln('actual_amt_A %s', actual_amt_A.reveal()) - accept_A = actual_amt_A >= amt_A - print_ln('accept_A %s', accept_A.reveal()) - flag_buy_A = valid_order * buy_A * enough_B * accept_A - print_ln('flag_buy_A %s', flag_buy_A.reveal()) - - buy_B = 1 - buy_A - print_ln('buy_B %s', buy_B.reveal()) - total_A = (1 + fee_rate) * amt_A - print_ln('total_A %s', total_A.reveal()) - balance_A = read_sfix(5) - print_ln('balance_A %s', balance_A.reveal()) - enough_A = -total_A <= balance_A - print_ln('enough_A %s', enough_A.reveal()) - actual_amt_B = pool_B - pool_A * pool_B / (pool_A - amt_A) - print_ln('actual_amt_B %s', actual_amt_B.reveal()) - accept_B = actual_amt_B >= amt_B - print_ln('accept_B %s', accept_B.reveal()) - flag_buy_B = valid_order * buy_B * enough_A * accept_B - print_ln('flag_buy_B %s', flag_buy_B.reveal()) - - change_A = flag_buy_A * actual_amt_A + flag_buy_B * total_A - print_ln('change_A %s', change_A.reveal()) - write_sfix(change_A) - change_B = flag_buy_A * total_B + flag_buy_B * actual_amt_B - print_ln('change_B %s', change_B.reveal()) - write_sfix(change_B) - - pool_A -= change_A - print_ln('pool_A %s', pool_A.reveal()) - write_sfix(pool_A) - pool_B -= change_B - print_ln('pool_B %s', pool_B.reveal()) - write_sfix(pool_B) - - balance_A += change_A - print_ln('balance_A %s', balance_A.reveal()) - write_sfix(balance_A) - balance_B += change_B - print_ln('balance_B %s', balance_B.reveal()) - write_sfix(balance_B) - - order_succeed = flag_buy_A + flag_buy_B - print_ln('order_succeed %s', order_succeed.reveal()) - public_reveal(order_succeed) - -main() diff --git a/src/node_modules/.package-lock.json b/src/node_modules/.package-lock.json deleted file mode 100644 index 32122dbd..00000000 --- a/src/node_modules/.package-lock.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "src", - "lockfileVersion": 2, - "requires": true, - "packages": { - "node_modules/@openzeppelin/contracts": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-2.5.1.tgz", - "integrity": "sha512-qIy6tLx8rtybEsIOAlrM4J/85s2q2nPkDqj/Rx46VakBZ0LwtFhXIVub96LXHczQX0vaqmAueDqNPXtbSXSaYQ==" - } - } -} diff --git a/src/node_modules/@openzeppelin/contracts/GSN/Context.sol b/src/node_modules/@openzeppelin/contracts/GSN/Context.sol deleted file mode 100644 index 10772958..00000000 --- a/src/node_modules/@openzeppelin/contracts/GSN/Context.sol +++ /dev/null @@ -1,27 +0,0 @@ -pragma solidity ^0.5.0; - -/* - * @dev Provides information about the current execution context, including the - * sender of the transaction and its data. While these are generally available - * via msg.sender and msg.data, they should not be accessed in such a direct - * manner, since when dealing with GSN meta-transactions the account sending and - * paying for execution may not be the actual sender (as far as an application - * is concerned). - * - * This contract is only required for intermediate, library-like contracts. - */ -contract Context { - // Empty internal constructor, to prevent people from mistakenly deploying - // an instance of this contract, which should be used via inheritance. - constructor () internal { } - // solhint-disable-previous-line no-empty-blocks - - function _msgSender() internal view returns (address payable) { - return msg.sender; - } - - function _msgData() internal view returns (bytes memory) { - this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 - return msg.data; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/GSN/GSNRecipient.sol b/src/node_modules/@openzeppelin/contracts/GSN/GSNRecipient.sol deleted file mode 100644 index fb5996e5..00000000 --- a/src/node_modules/@openzeppelin/contracts/GSN/GSNRecipient.sol +++ /dev/null @@ -1,228 +0,0 @@ -pragma solidity ^0.5.0; - -import "./IRelayRecipient.sol"; -import "./IRelayHub.sol"; -import "./Context.sol"; - -/** - * @dev Base GSN recipient contract: includes the {IRelayRecipient} interface - * and enables GSN support on all contracts in the inheritance tree. - * - * TIP: This contract is abstract. The functions {IRelayRecipient-acceptRelayedCall}, - * {_preRelayedCall}, and {_postRelayedCall} are not implemented and must be - * provided by derived contracts. See the - * xref:ROOT:gsn-strategies.adoc#gsn-strategies[GSN strategies] for more - * information on how to use the pre-built {GSNRecipientSignature} and - * {GSNRecipientERC20Fee}, or how to write your own. - */ -contract GSNRecipient is IRelayRecipient, Context { - // Default RelayHub address, deployed on mainnet and all testnets at the same address - address private _relayHub = 0xD216153c06E857cD7f72665E0aF1d7D82172F494; - - uint256 constant private RELAYED_CALL_ACCEPTED = 0; - uint256 constant private RELAYED_CALL_REJECTED = 11; - - // How much gas is forwarded to postRelayedCall - uint256 constant internal POST_RELAYED_CALL_MAX_GAS = 100000; - - /** - * @dev Emitted when a contract changes its {IRelayHub} contract to a new one. - */ - event RelayHubChanged(address indexed oldRelayHub, address indexed newRelayHub); - - /** - * @dev Returns the address of the {IRelayHub} contract for this recipient. - */ - function getHubAddr() public view returns (address) { - return _relayHub; - } - - /** - * @dev Switches to a new {IRelayHub} instance. This method is added for future-proofing: there's no reason to not - * use the default instance. - * - * IMPORTANT: After upgrading, the {GSNRecipient} will no longer be able to receive relayed calls from the old - * {IRelayHub} instance. Additionally, all funds should be previously withdrawn via {_withdrawDeposits}. - */ - function _upgradeRelayHub(address newRelayHub) internal { - address currentRelayHub = _relayHub; - require(newRelayHub != address(0), "GSNRecipient: new RelayHub is the zero address"); - require(newRelayHub != currentRelayHub, "GSNRecipient: new RelayHub is the current one"); - - emit RelayHubChanged(currentRelayHub, newRelayHub); - - _relayHub = newRelayHub; - } - - /** - * @dev Returns the version string of the {IRelayHub} for which this recipient implementation was built. If - * {_upgradeRelayHub} is used, the new {IRelayHub} instance should be compatible with this version. - */ - // This function is view for future-proofing, it may require reading from - // storage in the future. - function relayHubVersion() public view returns (string memory) { - this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 - return "1.0.0"; - } - - /** - * @dev Withdraws the recipient's deposits in `RelayHub`. - * - * Derived contracts should expose this in an external interface with proper access control. - */ - function _withdrawDeposits(uint256 amount, address payable payee) internal { - IRelayHub(_relayHub).withdraw(amount, payee); - } - - // Overrides for Context's functions: when called from RelayHub, sender and - // data require some pre-processing: the actual sender is stored at the end - // of the call data, which in turns means it needs to be removed from it - // when handling said data. - - /** - * @dev Replacement for msg.sender. Returns the actual sender of a transaction: msg.sender for regular transactions, - * and the end-user for GSN relayed calls (where msg.sender is actually `RelayHub`). - * - * IMPORTANT: Contracts derived from {GSNRecipient} should never use `msg.sender`, and use {_msgSender} instead. - */ - function _msgSender() internal view returns (address payable) { - if (msg.sender != _relayHub) { - return msg.sender; - } else { - return _getRelayedCallSender(); - } - } - - /** - * @dev Replacement for msg.data. Returns the actual calldata of a transaction: msg.data for regular transactions, - * and a reduced version for GSN relayed calls (where msg.data contains additional information). - * - * IMPORTANT: Contracts derived from {GSNRecipient} should never use `msg.data`, and use {_msgData} instead. - */ - function _msgData() internal view returns (bytes memory) { - if (msg.sender != _relayHub) { - return msg.data; - } else { - return _getRelayedCallData(); - } - } - - // Base implementations for pre and post relayedCall: only RelayHub can invoke them, and data is forwarded to the - // internal hook. - - /** - * @dev See `IRelayRecipient.preRelayedCall`. - * - * This function should not be overriden directly, use `_preRelayedCall` instead. - * - * * Requirements: - * - * - the caller must be the `RelayHub` contract. - */ - function preRelayedCall(bytes calldata context) external returns (bytes32) { - require(msg.sender == getHubAddr(), "GSNRecipient: caller is not RelayHub"); - return _preRelayedCall(context); - } - - /** - * @dev See `IRelayRecipient.preRelayedCall`. - * - * Called by `GSNRecipient.preRelayedCall`, which asserts the caller is the `RelayHub` contract. Derived contracts - * must implement this function with any relayed-call preprocessing they may wish to do. - * - */ - function _preRelayedCall(bytes memory context) internal returns (bytes32); - - /** - * @dev See `IRelayRecipient.postRelayedCall`. - * - * This function should not be overriden directly, use `_postRelayedCall` instead. - * - * * Requirements: - * - * - the caller must be the `RelayHub` contract. - */ - function postRelayedCall(bytes calldata context, bool success, uint256 actualCharge, bytes32 preRetVal) external { - require(msg.sender == getHubAddr(), "GSNRecipient: caller is not RelayHub"); - _postRelayedCall(context, success, actualCharge, preRetVal); - } - - /** - * @dev See `IRelayRecipient.postRelayedCall`. - * - * Called by `GSNRecipient.postRelayedCall`, which asserts the caller is the `RelayHub` contract. Derived contracts - * must implement this function with any relayed-call postprocessing they may wish to do. - * - */ - function _postRelayedCall(bytes memory context, bool success, uint256 actualCharge, bytes32 preRetVal) internal; - - /** - * @dev Return this in acceptRelayedCall to proceed with the execution of a relayed call. Note that this contract - * will be charged a fee by RelayHub - */ - function _approveRelayedCall() internal pure returns (uint256, bytes memory) { - return _approveRelayedCall(""); - } - - /** - * @dev See `GSNRecipient._approveRelayedCall`. - * - * This overload forwards `context` to _preRelayedCall and _postRelayedCall. - */ - function _approveRelayedCall(bytes memory context) internal pure returns (uint256, bytes memory) { - return (RELAYED_CALL_ACCEPTED, context); - } - - /** - * @dev Return this in acceptRelayedCall to impede execution of a relayed call. No fees will be charged. - */ - function _rejectRelayedCall(uint256 errorCode) internal pure returns (uint256, bytes memory) { - return (RELAYED_CALL_REJECTED + errorCode, ""); - } - - /* - * @dev Calculates how much RelayHub will charge a recipient for using `gas` at a `gasPrice`, given a relayer's - * `serviceFee`. - */ - function _computeCharge(uint256 gas, uint256 gasPrice, uint256 serviceFee) internal pure returns (uint256) { - // The fee is expressed as a percentage. E.g. a value of 40 stands for a 40% fee, so the recipient will be - // charged for 1.4 times the spent amount. - return (gas * gasPrice * (100 + serviceFee)) / 100; - } - - function _getRelayedCallSender() private pure returns (address payable result) { - // We need to read 20 bytes (an address) located at array index msg.data.length - 20. In memory, the array - // is prefixed with a 32-byte length value, so we first add 32 to get the memory read index. However, doing - // so would leave the address in the upper 20 bytes of the 32-byte word, which is inconvenient and would - // require bit shifting. We therefore subtract 12 from the read index so the address lands on the lower 20 - // bytes. This can always be done due to the 32-byte prefix. - - // The final memory read index is msg.data.length - 20 + 32 - 12 = msg.data.length. Using inline assembly is the - // easiest/most-efficient way to perform this operation. - - // These fields are not accessible from assembly - bytes memory array = msg.data; - uint256 index = msg.data.length; - - // solhint-disable-next-line no-inline-assembly - assembly { - // Load the 32 bytes word from memory with the address on the lower 20 bytes, and mask those. - result := and(mload(add(array, index)), 0xffffffffffffffffffffffffffffffffffffffff) - } - return result; - } - - function _getRelayedCallData() private pure returns (bytes memory) { - // RelayHub appends the sender address at the end of the calldata, so in order to retrieve the actual msg.data, - // we must strip the last 20 bytes (length of an address type) from it. - - uint256 actualDataLength = msg.data.length - 20; - bytes memory actualData = new bytes(actualDataLength); - - for (uint256 i = 0; i < actualDataLength; ++i) { - actualData[i] = msg.data[i]; - } - - return actualData; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/GSN/GSNRecipientERC20Fee.sol b/src/node_modules/@openzeppelin/contracts/GSN/GSNRecipientERC20Fee.sol deleted file mode 100644 index 8e649029..00000000 --- a/src/node_modules/@openzeppelin/contracts/GSN/GSNRecipientERC20Fee.sol +++ /dev/null @@ -1,151 +0,0 @@ -pragma solidity ^0.5.0; - -import "./GSNRecipient.sol"; -import "../math/SafeMath.sol"; -import "../ownership/Secondary.sol"; -import "../token/ERC20/SafeERC20.sol"; -import "../token/ERC20/ERC20.sol"; -import "../token/ERC20/ERC20Detailed.sol"; - -/** - * @dev A xref:ROOT:gsn-strategies.adoc#gsn-strategies[GSN strategy] that charges transaction fees in a special purpose ERC20 - * token, which we refer to as the gas payment token. The amount charged is exactly the amount of Ether charged to the - * recipient. This means that the token is essentially pegged to the value of Ether. - * - * The distribution strategy of the gas payment token to users is not defined by this contract. It's a mintable token - * whose only minter is the recipient, so the strategy must be implemented in a derived contract, making use of the - * internal {_mint} function. - */ -contract GSNRecipientERC20Fee is GSNRecipient { - using SafeERC20 for __unstable__ERC20PrimaryAdmin; - using SafeMath for uint256; - - enum GSNRecipientERC20FeeErrorCodes { - INSUFFICIENT_BALANCE - } - - __unstable__ERC20PrimaryAdmin private _token; - - /** - * @dev The arguments to the constructor are the details that the gas payment token will have: `name` and `symbol`. `decimals` is hard-coded to 18. - */ - constructor(string memory name, string memory symbol) public { - _token = new __unstable__ERC20PrimaryAdmin(name, symbol, 18); - } - - /** - * @dev Returns the gas payment token. - */ - function token() public view returns (IERC20) { - return IERC20(_token); - } - - /** - * @dev Internal function that mints the gas payment token. Derived contracts should expose this function in their public API, with proper access control mechanisms. - */ - function _mint(address account, uint256 amount) internal { - _token.mint(account, amount); - } - - /** - * @dev Ensures that only users with enough gas payment token balance can have transactions relayed through the GSN. - */ - function acceptRelayedCall( - address, - address from, - bytes calldata, - uint256 transactionFee, - uint256 gasPrice, - uint256, - uint256, - bytes calldata, - uint256 maxPossibleCharge - ) - external - view - returns (uint256, bytes memory) - { - if (_token.balanceOf(from) < maxPossibleCharge) { - return _rejectRelayedCall(uint256(GSNRecipientERC20FeeErrorCodes.INSUFFICIENT_BALANCE)); - } - - return _approveRelayedCall(abi.encode(from, maxPossibleCharge, transactionFee, gasPrice)); - } - - /** - * @dev Implements the precharge to the user. The maximum possible charge (depending on gas limit, gas price, and - * fee) will be deducted from the user balance of gas payment token. Note that this is an overestimation of the - * actual charge, necessary because we cannot predict how much gas the execution will actually need. The remainder - * is returned to the user in {_postRelayedCall}. - */ - function _preRelayedCall(bytes memory context) internal returns (bytes32) { - (address from, uint256 maxPossibleCharge) = abi.decode(context, (address, uint256)); - - // The maximum token charge is pre-charged from the user - _token.safeTransferFrom(from, address(this), maxPossibleCharge); - } - - /** - * @dev Returns to the user the extra amount that was previously charged, once the actual execution cost is known. - */ - function _postRelayedCall(bytes memory context, bool, uint256 actualCharge, bytes32) internal { - (address from, uint256 maxPossibleCharge, uint256 transactionFee, uint256 gasPrice) = - abi.decode(context, (address, uint256, uint256, uint256)); - - // actualCharge is an _estimated_ charge, which assumes postRelayedCall will use all available gas. - // This implementation's gas cost can be roughly estimated as 10k gas, for the two SSTORE operations in an - // ERC20 transfer. - uint256 overestimation = _computeCharge(POST_RELAYED_CALL_MAX_GAS.sub(10000), gasPrice, transactionFee); - actualCharge = actualCharge.sub(overestimation); - - // After the relayed call has been executed and the actual charge estimated, the excess pre-charge is returned - _token.safeTransfer(from, maxPossibleCharge.sub(actualCharge)); - } -} - -/** - * @title __unstable__ERC20PrimaryAdmin - * @dev An ERC20 token owned by another contract, which has minting permissions and can use transferFrom to receive - * anyone's tokens. This contract is an internal helper for GSNRecipientERC20Fee, and should not be used - * outside of this context. - */ -// solhint-disable-next-line contract-name-camelcase -contract __unstable__ERC20PrimaryAdmin is ERC20, ERC20Detailed, Secondary { - uint256 private constant UINT256_MAX = 2**256 - 1; - - constructor(string memory name, string memory symbol, uint8 decimals) public ERC20Detailed(name, symbol, decimals) { - // solhint-disable-previous-line no-empty-blocks - } - - // The primary account (GSNRecipientERC20Fee) can mint tokens - function mint(address account, uint256 amount) public onlyPrimary { - _mint(account, amount); - } - - // The primary account has 'infinite' allowance for all token holders - function allowance(address owner, address spender) public view returns (uint256) { - if (spender == primary()) { - return UINT256_MAX; - } else { - return super.allowance(owner, spender); - } - } - - // Allowance for the primary account cannot be changed (it is always 'infinite') - function _approve(address owner, address spender, uint256 value) internal { - if (spender == primary()) { - return; - } else { - super._approve(owner, spender, value); - } - } - - function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { - if (recipient == primary()) { - _transfer(sender, recipient, amount); - return true; - } else { - return super.transferFrom(sender, recipient, amount); - } - } -} diff --git a/src/node_modules/@openzeppelin/contracts/GSN/GSNRecipientSignature.sol b/src/node_modules/@openzeppelin/contracts/GSN/GSNRecipientSignature.sol deleted file mode 100644 index c4c41a00..00000000 --- a/src/node_modules/@openzeppelin/contracts/GSN/GSNRecipientSignature.sol +++ /dev/null @@ -1,72 +0,0 @@ -pragma solidity ^0.5.0; - -import "./GSNRecipient.sol"; -import "../cryptography/ECDSA.sol"; - -/** - * @dev A xref:ROOT:gsn-strategies.adoc#gsn-strategies[GSN strategy] that allows relayed transactions through when they are - * accompanied by the signature of a trusted signer. The intent is for this signature to be generated by a server that - * performs validations off-chain. Note that nothing is charged to the user in this scheme. Thus, the server should make - * sure to account for this in their economic and threat model. - */ -contract GSNRecipientSignature is GSNRecipient { - using ECDSA for bytes32; - - address private _trustedSigner; - - enum GSNRecipientSignatureErrorCodes { - INVALID_SIGNER - } - - /** - * @dev Sets the trusted signer that is going to be producing signatures to approve relayed calls. - */ - constructor(address trustedSigner) public { - require(trustedSigner != address(0), "GSNRecipientSignature: trusted signer is the zero address"); - _trustedSigner = trustedSigner; - } - - /** - * @dev Ensures that only transactions with a trusted signature can be relayed through the GSN. - */ - function acceptRelayedCall( - address relay, - address from, - bytes calldata encodedFunction, - uint256 transactionFee, - uint256 gasPrice, - uint256 gasLimit, - uint256 nonce, - bytes calldata approvalData, - uint256 - ) - external - view - returns (uint256, bytes memory) - { - bytes memory blob = abi.encodePacked( - relay, - from, - encodedFunction, - transactionFee, - gasPrice, - gasLimit, - nonce, // Prevents replays on RelayHub - getHubAddr(), // Prevents replays in multiple RelayHubs - address(this) // Prevents replays in multiple recipients - ); - if (keccak256(blob).toEthSignedMessageHash().recover(approvalData) == _trustedSigner) { - return _approveRelayedCall(); - } else { - return _rejectRelayedCall(uint256(GSNRecipientSignatureErrorCodes.INVALID_SIGNER)); - } - } - - function _preRelayedCall(bytes memory) internal returns (bytes32) { - // solhint-disable-previous-line no-empty-blocks - } - - function _postRelayedCall(bytes memory, bool, uint256, bytes32) internal { - // solhint-disable-previous-line no-empty-blocks - } -} diff --git a/src/node_modules/@openzeppelin/contracts/GSN/IRelayHub.sol b/src/node_modules/@openzeppelin/contracts/GSN/IRelayHub.sol deleted file mode 100644 index 017415e4..00000000 --- a/src/node_modules/@openzeppelin/contracts/GSN/IRelayHub.sol +++ /dev/null @@ -1,267 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Interface for `RelayHub`, the core contract of the GSN. Users should not need to interact with this contract - * directly. - * - * See the https://github.com/OpenZeppelin/openzeppelin-gsn-helpers[OpenZeppelin GSN helpers] for more information on - * how to deploy an instance of `RelayHub` on your local test network. - */ -interface IRelayHub { - // Relay management - - /** - * @dev Adds stake to a relay and sets its `unstakeDelay`. If the relay does not exist, it is created, and the caller - * of this function becomes its owner. If the relay already exists, only the owner can call this function. A relay - * cannot be its own owner. - * - * All Ether in this function call will be added to the relay's stake. - * Its unstake delay will be assigned to `unstakeDelay`, but the new value must be greater or equal to the current one. - * - * Emits a {Staked} event. - */ - function stake(address relayaddr, uint256 unstakeDelay) external payable; - - /** - * @dev Emitted when a relay's stake or unstakeDelay are increased - */ - event Staked(address indexed relay, uint256 stake, uint256 unstakeDelay); - - /** - * @dev Registers the caller as a relay. - * The relay must be staked for, and not be a contract (i.e. this function must be called directly from an EOA). - * - * This function can be called multiple times, emitting new {RelayAdded} events. Note that the received - * `transactionFee` is not enforced by {relayCall}. - * - * Emits a {RelayAdded} event. - */ - function registerRelay(uint256 transactionFee, string calldata url) external; - - /** - * @dev Emitted when a relay is registered or re-registerd. Looking at these events (and filtering out - * {RelayRemoved} events) lets a client discover the list of available relays. - */ - event RelayAdded(address indexed relay, address indexed owner, uint256 transactionFee, uint256 stake, uint256 unstakeDelay, string url); - - /** - * @dev Removes (deregisters) a relay. Unregistered (but staked for) relays can also be removed. - * - * Can only be called by the owner of the relay. After the relay's `unstakeDelay` has elapsed, {unstake} will be - * callable. - * - * Emits a {RelayRemoved} event. - */ - function removeRelayByOwner(address relay) external; - - /** - * @dev Emitted when a relay is removed (deregistered). `unstakeTime` is the time when unstake will be callable. - */ - event RelayRemoved(address indexed relay, uint256 unstakeTime); - - /** Deletes the relay from the system, and gives back its stake to the owner. - * - * Can only be called by the relay owner, after `unstakeDelay` has elapsed since {removeRelayByOwner} was called. - * - * Emits an {Unstaked} event. - */ - function unstake(address relay) external; - - /** - * @dev Emitted when a relay is unstaked for, including the returned stake. - */ - event Unstaked(address indexed relay, uint256 stake); - - // States a relay can be in - enum RelayState { - Unknown, // The relay is unknown to the system: it has never been staked for - Staked, // The relay has been staked for, but it is not yet active - Registered, // The relay has registered itself, and is active (can relay calls) - Removed // The relay has been removed by its owner and can no longer relay calls. It must wait for its unstakeDelay to elapse before it can unstake - } - - /** - * @dev Returns a relay's status. Note that relays can be deleted when unstaked or penalized, causing this function - * to return an empty entry. - */ - function getRelay(address relay) external view returns (uint256 totalStake, uint256 unstakeDelay, uint256 unstakeTime, address payable owner, RelayState state); - - // Balance management - - /** - * @dev Deposits Ether for a contract, so that it can receive (and pay for) relayed transactions. - * - * Unused balance can only be withdrawn by the contract itself, by calling {withdraw}. - * - * Emits a {Deposited} event. - */ - function depositFor(address target) external payable; - - /** - * @dev Emitted when {depositFor} is called, including the amount and account that was funded. - */ - event Deposited(address indexed recipient, address indexed from, uint256 amount); - - /** - * @dev Returns an account's deposits. These can be either a contracts's funds, or a relay owner's revenue. - */ - function balanceOf(address target) external view returns (uint256); - - /** - * Withdraws from an account's balance, sending it back to it. Relay owners call this to retrieve their revenue, and - * contracts can use it to reduce their funding. - * - * Emits a {Withdrawn} event. - */ - function withdraw(uint256 amount, address payable dest) external; - - /** - * @dev Emitted when an account withdraws funds from `RelayHub`. - */ - event Withdrawn(address indexed account, address indexed dest, uint256 amount); - - // Relaying - - /** - * @dev Checks if the `RelayHub` will accept a relayed operation. - * Multiple things must be true for this to happen: - * - all arguments must be signed for by the sender (`from`) - * - the sender's nonce must be the current one - * - the recipient must accept this transaction (via {acceptRelayedCall}) - * - * Returns a `PreconditionCheck` value (`OK` when the transaction can be relayed), or a recipient-specific error - * code if it returns one in {acceptRelayedCall}. - */ - function canRelay( - address relay, - address from, - address to, - bytes calldata encodedFunction, - uint256 transactionFee, - uint256 gasPrice, - uint256 gasLimit, - uint256 nonce, - bytes calldata signature, - bytes calldata approvalData - ) external view returns (uint256 status, bytes memory recipientContext); - - // Preconditions for relaying, checked by canRelay and returned as the corresponding numeric values. - enum PreconditionCheck { - OK, // All checks passed, the call can be relayed - WrongSignature, // The transaction to relay is not signed by requested sender - WrongNonce, // The provided nonce has already been used by the sender - AcceptRelayedCallReverted, // The recipient rejected this call via acceptRelayedCall - InvalidRecipientStatusCode // The recipient returned an invalid (reserved) status code - } - - /** - * @dev Relays a transaction. - * - * For this to succeed, multiple conditions must be met: - * - {canRelay} must `return PreconditionCheck.OK` - * - the sender must be a registered relay - * - the transaction's gas price must be larger or equal to the one that was requested by the sender - * - the transaction must have enough gas to not run out of gas if all internal transactions (calls to the - * recipient) use all gas available to them - * - the recipient must have enough balance to pay the relay for the worst-case scenario (i.e. when all gas is - * spent) - * - * If all conditions are met, the call will be relayed and the recipient charged. {preRelayedCall}, the encoded - * function and {postRelayedCall} will be called in that order. - * - * Parameters: - * - `from`: the client originating the request - * - `to`: the target {IRelayRecipient} contract - * - `encodedFunction`: the function call to relay, including data - * - `transactionFee`: fee (%) the relay takes over actual gas cost - * - `gasPrice`: gas price the client is willing to pay - * - `gasLimit`: gas to forward when calling the encoded function - * - `nonce`: client's nonce - * - `signature`: client's signature over all previous params, plus the relay and RelayHub addresses - * - `approvalData`: dapp-specific data forwared to {acceptRelayedCall}. This value is *not* verified by the - * `RelayHub`, but it still can be used for e.g. a signature. - * - * Emits a {TransactionRelayed} event. - */ - function relayCall( - address from, - address to, - bytes calldata encodedFunction, - uint256 transactionFee, - uint256 gasPrice, - uint256 gasLimit, - uint256 nonce, - bytes calldata signature, - bytes calldata approvalData - ) external; - - /** - * @dev Emitted when an attempt to relay a call failed. - * - * This can happen due to incorrect {relayCall} arguments, or the recipient not accepting the relayed call. The - * actual relayed call was not executed, and the recipient not charged. - * - * The `reason` parameter contains an error code: values 1-10 correspond to `PreconditionCheck` entries, and values - * over 10 are custom recipient error codes returned from {acceptRelayedCall}. - */ - event CanRelayFailed(address indexed relay, address indexed from, address indexed to, bytes4 selector, uint256 reason); - - /** - * @dev Emitted when a transaction is relayed. - * Useful when monitoring a relay's operation and relayed calls to a contract - * - * Note that the actual encoded function might be reverted: this is indicated in the `status` parameter. - * - * `charge` is the Ether value deducted from the recipient's balance, paid to the relay's owner. - */ - event TransactionRelayed(address indexed relay, address indexed from, address indexed to, bytes4 selector, RelayCallStatus status, uint256 charge); - - // Reason error codes for the TransactionRelayed event - enum RelayCallStatus { - OK, // The transaction was successfully relayed and execution successful - never included in the event - RelayedCallFailed, // The transaction was relayed, but the relayed call failed - PreRelayedFailed, // The transaction was not relayed due to preRelatedCall reverting - PostRelayedFailed, // The transaction was relayed and reverted due to postRelatedCall reverting - RecipientBalanceChanged // The transaction was relayed and reverted due to the recipient's balance changing - } - - /** - * @dev Returns how much gas should be forwarded to a call to {relayCall}, in order to relay a transaction that will - * spend up to `relayedCallStipend` gas. - */ - function requiredGas(uint256 relayedCallStipend) external view returns (uint256); - - /** - * @dev Returns the maximum recipient charge, given the amount of gas forwarded, gas price and relay fee. - */ - function maxPossibleCharge(uint256 relayedCallStipend, uint256 gasPrice, uint256 transactionFee) external view returns (uint256); - - // Relay penalization. - // Any account can penalize relays, removing them from the system immediately, and rewarding the - // reporter with half of the relay's stake. The other half is burned so that, even if the relay penalizes itself, it - // still loses half of its stake. - - /** - * @dev Penalize a relay that signed two transactions using the same nonce (making only the first one valid) and - * different data (gas price, gas limit, etc. may be different). - * - * The (unsigned) transaction data and signature for both transactions must be provided. - */ - function penalizeRepeatedNonce(bytes calldata unsignedTx1, bytes calldata signature1, bytes calldata unsignedTx2, bytes calldata signature2) external; - - /** - * @dev Penalize a relay that sent a transaction that didn't target `RelayHub`'s {registerRelay} or {relayCall}. - */ - function penalizeIllegalTransaction(bytes calldata unsignedTx, bytes calldata signature) external; - - /** - * @dev Emitted when a relay is penalized. - */ - event Penalized(address indexed relay, address sender, uint256 amount); - - /** - * @dev Returns an account's nonce in `RelayHub`. - */ - function getNonce(address from) external view returns (uint256); -} - diff --git a/src/node_modules/@openzeppelin/contracts/GSN/IRelayRecipient.sol b/src/node_modules/@openzeppelin/contracts/GSN/IRelayRecipient.sol deleted file mode 100644 index 405f9d35..00000000 --- a/src/node_modules/@openzeppelin/contracts/GSN/IRelayRecipient.sol +++ /dev/null @@ -1,74 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Base interface for a contract that will be called via the GSN from {IRelayHub}. - * - * TIP: You don't need to write an implementation yourself! Inherit from {GSNRecipient} instead. - */ -interface IRelayRecipient { - /** - * @dev Returns the address of the {IRelayHub} instance this recipient interacts with. - */ - function getHubAddr() external view returns (address); - - /** - * @dev Called by {IRelayHub} to validate if this recipient accepts being charged for a relayed call. Note that the - * recipient will be charged regardless of the execution result of the relayed call (i.e. if it reverts or not). - * - * The relay request was originated by `from` and will be served by `relay`. `encodedFunction` is the relayed call - * calldata, so its first four bytes are the function selector. The relayed call will be forwarded `gasLimit` gas, - * and the transaction executed with a gas price of at least `gasPrice`. `relay`'s fee is `transactionFee`, and the - * recipient will be charged at most `maxPossibleCharge` (in wei). `nonce` is the sender's (`from`) nonce for - * replay attack protection in {IRelayHub}, and `approvalData` is a optional parameter that can be used to hold a signature - * over all or some of the previous values. - * - * Returns a tuple, where the first value is used to indicate approval (0) or rejection (custom non-zero error code, - * values 1 to 10 are reserved) and the second one is data to be passed to the other {IRelayRecipient} functions. - * - * {acceptRelayedCall} is called with 50k gas: if it runs out during execution, the request will be considered - * rejected. A regular revert will also trigger a rejection. - */ - function acceptRelayedCall( - address relay, - address from, - bytes calldata encodedFunction, - uint256 transactionFee, - uint256 gasPrice, - uint256 gasLimit, - uint256 nonce, - bytes calldata approvalData, - uint256 maxPossibleCharge - ) - external - view - returns (uint256, bytes memory); - - /** - * @dev Called by {IRelayHub} on approved relay call requests, before the relayed call is executed. This allows to e.g. - * pre-charge the sender of the transaction. - * - * `context` is the second value returned in the tuple by {acceptRelayedCall}. - * - * Returns a value to be passed to {postRelayedCall}. - * - * {preRelayedCall} is called with 100k gas: if it runs out during exection or otherwise reverts, the relayed call - * will not be executed, but the recipient will still be charged for the transaction's cost. - */ - function preRelayedCall(bytes calldata context) external returns (bytes32); - - /** - * @dev Called by {IRelayHub} on approved relay call requests, after the relayed call is executed. This allows to e.g. - * charge the user for the relayed call costs, return any overcharges from {preRelayedCall}, or perform - * contract-specific bookkeeping. - * - * `context` is the second value returned in the tuple by {acceptRelayedCall}. `success` is the execution status of - * the relayed call. `actualCharge` is an estimate of how much the recipient will be charged for the transaction, - * not including any gas used by {postRelayedCall} itself. `preRetVal` is {preRelayedCall}'s return value. - * - * - * {postRelayedCall} is called with 100k gas: if it runs out during execution or otherwise reverts, the relayed call - * and the call to {preRelayedCall} will be reverted retroactively, but the recipient will still be charged for the - * transaction's cost. - */ - function postRelayedCall(bytes calldata context, bool success, uint256 actualCharge, bytes32 preRetVal) external; -} diff --git a/src/node_modules/@openzeppelin/contracts/GSN/README.adoc b/src/node_modules/@openzeppelin/contracts/GSN/README.adoc deleted file mode 100644 index 16c1297e..00000000 --- a/src/node_modules/@openzeppelin/contracts/GSN/README.adoc +++ /dev/null @@ -1,30 +0,0 @@ -= Gas Station Network (GSN) - -_Available since v2.4.0._ - -This set of contracts provide all the tools required to make a contract callable via the https://gsn.openzeppelin.com[Gas Station Network]. - -TIP: If you're new to the GSN, head over to our xref:learn::sending-gasless-transactions.adoc[overview of the system] and basic guide to xref:ROOT:gsn.adoc[creating a GSN-capable contract]. - -The core contract a recipient must inherit from is {GSNRecipient}: it includes all necessary interfaces, as well as some helper methods to make interacting with the GSN easier. - -Utilities to make writing xref:ROOT:gsn-strategies.adoc[GSN strategies] easy are available in {GSNRecipient}, or you can simply use one of our pre-made strategies: - -* {GSNRecipientERC20Fee} charges the end user for gas costs in an application-specific xref:ROOT:tokens.adoc#ERC20[ERC20 token] -* {GSNRecipientSignature} accepts all relayed calls that have been signed by a trusted third party (e.g. a private key in a backend) - -You can also take a look at the two contract interfaces that make up the GSN protocol: {IRelayRecipient} and {IRelayHub}, but you won't need to use those directly. - -== Recipient - -{{GSNRecipient}} - -== Strategies - -{{GSNRecipientSignature}} -{{GSNRecipientERC20Fee}} - -== Protocol - -{{IRelayRecipient}} -{{IRelayHub}} diff --git a/src/node_modules/@openzeppelin/contracts/README.md b/src/node_modules/@openzeppelin/contracts/README.md deleted file mode 100644 index 6874c2a3..00000000 --- a/src/node_modules/@openzeppelin/contracts/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# OpenZeppelin - -[![NPM Package](https://img.shields.io/npm/v/@openzeppelin/contracts.svg)](https://www.npmjs.org/package/@openzeppelin/contracts) -[![Build Status](https://circleci.com/gh/OpenZeppelin/openzeppelin-contracts.svg?style=shield)](https://circleci.com/gh/OpenZeppelin/openzeppelin-contracts) -[![Coverage Status](https://codecov.io/gh/OpenZeppelin/openzeppelin-contracts/graph/badge.svg)](https://codecov.io/gh/OpenZeppelin/openzeppelin-contracts) - -**A library for secure smart contract development.** Build on a solid foundation of community-vetted code. - - * Implementations of standards like [ERC20](https://docs.openzeppelin.com/contracts/erc20) and [ERC721](https://docs.openzeppelin.com/contracts/erc721). - * Flexible [role-based permissioning](https://docs.openzeppelin.com/contracts/access-control) scheme. - * Reusable [Solidity components](https://docs.openzeppelin.com/contracts/utilities) to build custom contracts and complex decentralized systems. - * First-class integration with the [Gas Station Network](https://docs.openzeppelin.com/contracts/gsn) for systems with no gas fees! - * Audited by leading security firms. - -## Overview - -### Installation - -```console -$ npm install @openzeppelin/contracts -``` - -OpenZeppelin Contracts features a [stable API](https://docs.openzeppelin.com/contracts/releases-stability#api-stability), which means your contracts won't break unexpectedly when upgrading to a newer minor version. - -### Usage - -Once installed, you can use the contracts in the library by importing them: - -```solidity -pragma solidity ^0.5.0; - -import "@openzeppelin/contracts/token/ERC721/ERC721Full.sol"; -import "@openzeppelin/contracts/token/ERC721/ERC721Mintable.sol"; - -contract MyNFT is ERC721Full, ERC721Mintable { - constructor() ERC721Full("MyNFT", "MNFT") public { - } -} -``` - -_If you're new to smart contract development, head to [Developing Smart Contracts](https://docs.openzeppelin.com/contracts/learn::developing-smart-contracts) to learn about creating a new project and compiling your contracts._ - -To keep your system secure, you should **always** use the installed code as-is, and neither copy-paste it from online sources, nor modify it yourself. - -## Learn More - -The guides in the sidebar will teach about different concepts, and how to use the related contracts that OpenZeppelin Contracts provides: - -* [Access Control](https://docs.openzeppelin.com/contracts/access-control): decide who can perform each of the actions on your system. -* [Tokens](https://docs.openzeppelin.com/contracts/tokens): create tradeable assets or collectives, and distribute them via [Crowdsales](https://docs.openzeppelin.com/contracts/crowdsales). -* [Gas Station Network](https://docs.openzeppelin.com/contracts/gsn): let your users interact with your contracts without having to pay for gas themselves. -* [Utilities](https://docs.openzeppelin.com/contracts/utilities): generic useful tools, including non-overflowing math, signature verification, and trustless paying systems. - -The [full API](https://docs.openzeppelin.com/contracts/api/token/ERC20) is also thoroughly documented, and serves as a great reference when developing your smart contract application. You can also ask for help or follow Contracts's development in the [community forum](https://forum.openzeppelin.com). - -Finally, you may want to take a look at the [guides on our blog](https://blog.openzeppelin.com/guides), which cover several common use cases and good practices.. The following articles provide great background reading, though please note, some of the referenced tools have changed as the tooling in the ecosystem continues to rapidly evolve. - -* [The Hitchhiker’s Guide to Smart Contracts in Ethereum](https://blog.openzeppelin.com/the-hitchhikers-guide-to-smart-contracts-in-ethereum-848f08001f05) will help you get an overview of the various tools available for smart contract development, and help you set up your environment. -* [A Gentle Introduction to Ethereum Programming, Part 1](https://blog.openzeppelin.com/a-gentle-introduction-to-ethereum-programming-part-1-783cc7796094) provides very useful information on an introductory level, including many basic concepts from the Ethereum platform. -* For a more in-depth dive, you may read the guide [Designing the Architecture for Your Ethereum Application](https://blog.openzeppelin.com/designing-the-architecture-for-your-ethereum-application-9cec086f8317), which discusses how to better structure your application and its relationship to the real world. - -## Security - -This project is maintained by [OpenZeppelin](https://openzeppelin.com), and developed following our high standards for code quality and security. OpenZeppelin is meant to provide tested and community-audited code, but please use common sense when doing anything that deals with real money! We take no responsibility for your implementation decisions and any security problems you might experience. - -The core development principles and strategies that OpenZeppelin is based on include: security in depth, simple and modular code, clarity-driven naming conventions, comprehensive unit testing, pre-and-post-condition sanity checks, code consistency, and regular audits. - -The latest audit was done on October 2018 on version 2.0.0. - -Please report any security issues you find to security@openzeppelin.org. - -## Contribute - -OpenZeppelin exists thanks to its contributors. There are many ways you can participate and help build high quality software. Check out the [contribution guide](CONTRIBUTING.md)! - -## License - -OpenZeppelin is released under the [MIT License](LICENSE). diff --git a/src/node_modules/@openzeppelin/contracts/access/README.adoc b/src/node_modules/@openzeppelin/contracts/access/README.adoc deleted file mode 100644 index 1efb4dec..00000000 --- a/src/node_modules/@openzeppelin/contracts/access/README.adoc +++ /dev/null @@ -1,21 +0,0 @@ -= Access - -NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned! - -== Library - -{{Roles}} - -== Roles - -{{CapperRole}} - -{{MinterRole}} - -{{PauserRole}} - -{{SignerRole}} - -{{WhitelistAdminRole}} - -{{WhitelistedRole}} diff --git a/src/node_modules/@openzeppelin/contracts/access/Roles.sol b/src/node_modules/@openzeppelin/contracts/access/Roles.sol deleted file mode 100644 index 5f3eff6a..00000000 --- a/src/node_modules/@openzeppelin/contracts/access/Roles.sol +++ /dev/null @@ -1,36 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @title Roles - * @dev Library for managing addresses assigned to a Role. - */ -library Roles { - struct Role { - mapping (address => bool) bearer; - } - - /** - * @dev Give an account access to this role. - */ - function add(Role storage role, address account) internal { - require(!has(role, account), "Roles: account already has role"); - role.bearer[account] = true; - } - - /** - * @dev Remove an account's access to this role. - */ - function remove(Role storage role, address account) internal { - require(has(role, account), "Roles: account does not have role"); - role.bearer[account] = false; - } - - /** - * @dev Check if an account has this role. - * @return bool - */ - function has(Role storage role, address account) internal view returns (bool) { - require(account != address(0), "Roles: account is the zero address"); - return role.bearer[account]; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/access/roles/CapperRole.sol b/src/node_modules/@openzeppelin/contracts/access/roles/CapperRole.sol deleted file mode 100644 index 2b239c1f..00000000 --- a/src/node_modules/@openzeppelin/contracts/access/roles/CapperRole.sol +++ /dev/null @@ -1,44 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "../Roles.sol"; - -contract CapperRole is Context { - using Roles for Roles.Role; - - event CapperAdded(address indexed account); - event CapperRemoved(address indexed account); - - Roles.Role private _cappers; - - constructor () internal { - _addCapper(_msgSender()); - } - - modifier onlyCapper() { - require(isCapper(_msgSender()), "CapperRole: caller does not have the Capper role"); - _; - } - - function isCapper(address account) public view returns (bool) { - return _cappers.has(account); - } - - function addCapper(address account) public onlyCapper { - _addCapper(account); - } - - function renounceCapper() public { - _removeCapper(_msgSender()); - } - - function _addCapper(address account) internal { - _cappers.add(account); - emit CapperAdded(account); - } - - function _removeCapper(address account) internal { - _cappers.remove(account); - emit CapperRemoved(account); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/access/roles/MinterRole.sol b/src/node_modules/@openzeppelin/contracts/access/roles/MinterRole.sol deleted file mode 100644 index f881e3a7..00000000 --- a/src/node_modules/@openzeppelin/contracts/access/roles/MinterRole.sol +++ /dev/null @@ -1,44 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "../Roles.sol"; - -contract MinterRole is Context { - using Roles for Roles.Role; - - event MinterAdded(address indexed account); - event MinterRemoved(address indexed account); - - Roles.Role private _minters; - - constructor () internal { - _addMinter(_msgSender()); - } - - modifier onlyMinter() { - require(isMinter(_msgSender()), "MinterRole: caller does not have the Minter role"); - _; - } - - function isMinter(address account) public view returns (bool) { - return _minters.has(account); - } - - function addMinter(address account) public onlyMinter { - _addMinter(account); - } - - function renounceMinter() public { - _removeMinter(_msgSender()); - } - - function _addMinter(address account) internal { - _minters.add(account); - emit MinterAdded(account); - } - - function _removeMinter(address account) internal { - _minters.remove(account); - emit MinterRemoved(account); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/access/roles/PauserRole.sol b/src/node_modules/@openzeppelin/contracts/access/roles/PauserRole.sol deleted file mode 100644 index 6ad23840..00000000 --- a/src/node_modules/@openzeppelin/contracts/access/roles/PauserRole.sol +++ /dev/null @@ -1,44 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "../Roles.sol"; - -contract PauserRole is Context { - using Roles for Roles.Role; - - event PauserAdded(address indexed account); - event PauserRemoved(address indexed account); - - Roles.Role private _pausers; - - constructor () internal { - _addPauser(_msgSender()); - } - - modifier onlyPauser() { - require(isPauser(_msgSender()), "PauserRole: caller does not have the Pauser role"); - _; - } - - function isPauser(address account) public view returns (bool) { - return _pausers.has(account); - } - - function addPauser(address account) public onlyPauser { - _addPauser(account); - } - - function renouncePauser() public { - _removePauser(_msgSender()); - } - - function _addPauser(address account) internal { - _pausers.add(account); - emit PauserAdded(account); - } - - function _removePauser(address account) internal { - _pausers.remove(account); - emit PauserRemoved(account); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/access/roles/SignerRole.sol b/src/node_modules/@openzeppelin/contracts/access/roles/SignerRole.sol deleted file mode 100644 index 50535bea..00000000 --- a/src/node_modules/@openzeppelin/contracts/access/roles/SignerRole.sol +++ /dev/null @@ -1,44 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "../Roles.sol"; - -contract SignerRole is Context { - using Roles for Roles.Role; - - event SignerAdded(address indexed account); - event SignerRemoved(address indexed account); - - Roles.Role private _signers; - - constructor () internal { - _addSigner(_msgSender()); - } - - modifier onlySigner() { - require(isSigner(_msgSender()), "SignerRole: caller does not have the Signer role"); - _; - } - - function isSigner(address account) public view returns (bool) { - return _signers.has(account); - } - - function addSigner(address account) public onlySigner { - _addSigner(account); - } - - function renounceSigner() public { - _removeSigner(_msgSender()); - } - - function _addSigner(address account) internal { - _signers.add(account); - emit SignerAdded(account); - } - - function _removeSigner(address account) internal { - _signers.remove(account); - emit SignerRemoved(account); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/access/roles/WhitelistAdminRole.sol b/src/node_modules/@openzeppelin/contracts/access/roles/WhitelistAdminRole.sol deleted file mode 100644 index b26f4ed6..00000000 --- a/src/node_modules/@openzeppelin/contracts/access/roles/WhitelistAdminRole.sol +++ /dev/null @@ -1,48 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "../Roles.sol"; - -/** - * @title WhitelistAdminRole - * @dev WhitelistAdmins are responsible for assigning and removing Whitelisted accounts. - */ -contract WhitelistAdminRole is Context { - using Roles for Roles.Role; - - event WhitelistAdminAdded(address indexed account); - event WhitelistAdminRemoved(address indexed account); - - Roles.Role private _whitelistAdmins; - - constructor () internal { - _addWhitelistAdmin(_msgSender()); - } - - modifier onlyWhitelistAdmin() { - require(isWhitelistAdmin(_msgSender()), "WhitelistAdminRole: caller does not have the WhitelistAdmin role"); - _; - } - - function isWhitelistAdmin(address account) public view returns (bool) { - return _whitelistAdmins.has(account); - } - - function addWhitelistAdmin(address account) public onlyWhitelistAdmin { - _addWhitelistAdmin(account); - } - - function renounceWhitelistAdmin() public { - _removeWhitelistAdmin(_msgSender()); - } - - function _addWhitelistAdmin(address account) internal { - _whitelistAdmins.add(account); - emit WhitelistAdminAdded(account); - } - - function _removeWhitelistAdmin(address account) internal { - _whitelistAdmins.remove(account); - emit WhitelistAdminRemoved(account); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/access/roles/WhitelistedRole.sol b/src/node_modules/@openzeppelin/contracts/access/roles/WhitelistedRole.sol deleted file mode 100644 index 5d749bfd..00000000 --- a/src/node_modules/@openzeppelin/contracts/access/roles/WhitelistedRole.sol +++ /dev/null @@ -1,51 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "../Roles.sol"; -import "./WhitelistAdminRole.sol"; - -/** - * @title WhitelistedRole - * @dev Whitelisted accounts have been approved by a WhitelistAdmin to perform certain actions (e.g. participate in a - * crowdsale). This role is special in that the only accounts that can add it are WhitelistAdmins (who can also remove - * it), and not Whitelisteds themselves. - */ -contract WhitelistedRole is Context, WhitelistAdminRole { - using Roles for Roles.Role; - - event WhitelistedAdded(address indexed account); - event WhitelistedRemoved(address indexed account); - - Roles.Role private _whitelisteds; - - modifier onlyWhitelisted() { - require(isWhitelisted(_msgSender()), "WhitelistedRole: caller does not have the Whitelisted role"); - _; - } - - function isWhitelisted(address account) public view returns (bool) { - return _whitelisteds.has(account); - } - - function addWhitelisted(address account) public onlyWhitelistAdmin { - _addWhitelisted(account); - } - - function removeWhitelisted(address account) public onlyWhitelistAdmin { - _removeWhitelisted(account); - } - - function renounceWhitelisted() public { - _removeWhitelisted(_msgSender()); - } - - function _addWhitelisted(address account) internal { - _whitelisteds.add(account); - emit WhitelistedAdded(account); - } - - function _removeWhitelisted(address account) internal { - _whitelisteds.remove(account); - emit WhitelistedRemoved(account); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/Crowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/Crowdsale.sol deleted file mode 100644 index 5aec9619..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/Crowdsale.sol +++ /dev/null @@ -1,200 +0,0 @@ -pragma solidity ^0.5.0; - -import "../GSN/Context.sol"; -import "../token/ERC20/IERC20.sol"; -import "../math/SafeMath.sol"; -import "../token/ERC20/SafeERC20.sol"; -import "../utils/ReentrancyGuard.sol"; - -/** - * @title Crowdsale - * @dev Crowdsale is a base contract for managing a token crowdsale, - * allowing investors to purchase tokens with ether. This contract implements - * such functionality in its most fundamental form and can be extended to provide additional - * functionality and/or custom behavior. - * The external interface represents the basic interface for purchasing tokens, and conforms - * the base architecture for crowdsales. It is *not* intended to be modified / overridden. - * The internal interface conforms the extensible and modifiable surface of crowdsales. Override - * the methods to add functionality. Consider using 'super' where appropriate to concatenate - * behavior. - */ -contract Crowdsale is Context, ReentrancyGuard { - using SafeMath for uint256; - using SafeERC20 for IERC20; - - // The token being sold - IERC20 private _token; - - // Address where funds are collected - address payable private _wallet; - - // How many token units a buyer gets per wei. - // The rate is the conversion between wei and the smallest and indivisible token unit. - // So, if you are using a rate of 1 with a ERC20Detailed token with 3 decimals called TOK - // 1 wei will give you 1 unit, or 0.001 TOK. - uint256 private _rate; - - // Amount of wei raised - uint256 private _weiRaised; - - /** - * Event for token purchase logging - * @param purchaser who paid for the tokens - * @param beneficiary who got the tokens - * @param value weis paid for purchase - * @param amount amount of tokens purchased - */ - event TokensPurchased(address indexed purchaser, address indexed beneficiary, uint256 value, uint256 amount); - - /** - * @param rate Number of token units a buyer gets per wei - * @dev The rate is the conversion between wei and the smallest and indivisible - * token unit. So, if you are using a rate of 1 with a ERC20Detailed token - * with 3 decimals called TOK, 1 wei will give you 1 unit, or 0.001 TOK. - * @param wallet Address where collected funds will be forwarded to - * @param token Address of the token being sold - */ - constructor (uint256 rate, address payable wallet, IERC20 token) public { - require(rate > 0, "Crowdsale: rate is 0"); - require(wallet != address(0), "Crowdsale: wallet is the zero address"); - require(address(token) != address(0), "Crowdsale: token is the zero address"); - - _rate = rate; - _wallet = wallet; - _token = token; - } - - /** - * @dev fallback function ***DO NOT OVERRIDE*** - * Note that other contracts will transfer funds with a base gas stipend - * of 2300, which is not enough to call buyTokens. Consider calling - * buyTokens directly when purchasing tokens from a contract. - */ - function () external payable { - buyTokens(_msgSender()); - } - - /** - * @return the token being sold. - */ - function token() public view returns (IERC20) { - return _token; - } - - /** - * @return the address where funds are collected. - */ - function wallet() public view returns (address payable) { - return _wallet; - } - - /** - * @return the number of token units a buyer gets per wei. - */ - function rate() public view returns (uint256) { - return _rate; - } - - /** - * @return the amount of wei raised. - */ - function weiRaised() public view returns (uint256) { - return _weiRaised; - } - - /** - * @dev low level token purchase ***DO NOT OVERRIDE*** - * This function has a non-reentrancy guard, so it shouldn't be called by - * another `nonReentrant` function. - * @param beneficiary Recipient of the token purchase - */ - function buyTokens(address beneficiary) public nonReentrant payable { - uint256 weiAmount = msg.value; - _preValidatePurchase(beneficiary, weiAmount); - - // calculate token amount to be created - uint256 tokens = _getTokenAmount(weiAmount); - - // update state - _weiRaised = _weiRaised.add(weiAmount); - - _processPurchase(beneficiary, tokens); - emit TokensPurchased(_msgSender(), beneficiary, weiAmount, tokens); - - _updatePurchasingState(beneficiary, weiAmount); - - _forwardFunds(); - _postValidatePurchase(beneficiary, weiAmount); - } - - /** - * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. - * Use `super` in contracts that inherit from Crowdsale to extend their validations. - * Example from CappedCrowdsale.sol's _preValidatePurchase method: - * super._preValidatePurchase(beneficiary, weiAmount); - * require(weiRaised().add(weiAmount) <= cap); - * @param beneficiary Address performing the token purchase - * @param weiAmount Value in wei involved in the purchase - */ - function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { - require(beneficiary != address(0), "Crowdsale: beneficiary is the zero address"); - require(weiAmount != 0, "Crowdsale: weiAmount is 0"); - this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 - } - - /** - * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid - * conditions are not met. - * @param beneficiary Address performing the token purchase - * @param weiAmount Value in wei involved in the purchase - */ - function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view { - // solhint-disable-previous-line no-empty-blocks - } - - /** - * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends - * its tokens. - * @param beneficiary Address performing the token purchase - * @param tokenAmount Number of tokens to be emitted - */ - function _deliverTokens(address beneficiary, uint256 tokenAmount) internal { - _token.safeTransfer(beneficiary, tokenAmount); - } - - /** - * @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send - * tokens. - * @param beneficiary Address receiving the tokens - * @param tokenAmount Number of tokens to be purchased - */ - function _processPurchase(address beneficiary, uint256 tokenAmount) internal { - _deliverTokens(beneficiary, tokenAmount); - } - - /** - * @dev Override for extensions that require an internal state to check for validity (current user contributions, - * etc.) - * @param beneficiary Address receiving the tokens - * @param weiAmount Value in wei involved in the purchase - */ - function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal { - // solhint-disable-previous-line no-empty-blocks - } - - /** - * @dev Override to extend the way in which ether is converted to tokens. - * @param weiAmount Value in wei to be converted into tokens - * @return Number of tokens that can be purchased with the specified _weiAmount - */ - function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { - return weiAmount.mul(_rate); - } - - /** - * @dev Determines how ETH is stored/forwarded on purchases. - */ - function _forwardFunds() internal { - _wallet.transfer(msg.value); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/README.adoc b/src/node_modules/@openzeppelin/contracts/crowdsale/README.adoc deleted file mode 100644 index 3f64f9b3..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/README.adoc +++ /dev/null @@ -1,35 +0,0 @@ -= Crowdsales - -NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned! - -== Core - -{{Crowdsale}} - -== Emission - -{{AllowanceCrowdsale}} - -{{MintedCrowdsale}} - -== Validation - -{{CappedCrowdsale}} - -{{IndividuallyCappedCrowdsale}} - -{{PausableCrowdsale}} - -{{TimedCrowdsale}} - -{{WhitelistCrowdsale}} - -== Distribution - -{{FinalizableCrowdsale}} - -{{PostDeliveryCrowdsale}} - -{{RefundableCrowdsale}} - -{{RefundablePostDeliveryCrowdsale}} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/FinalizableCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/FinalizableCrowdsale.sol deleted file mode 100644 index 9c42e614..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/FinalizableCrowdsale.sol +++ /dev/null @@ -1,51 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../math/SafeMath.sol"; -import "../validation/TimedCrowdsale.sol"; - -/** - * @title FinalizableCrowdsale - * @dev Extension of TimedCrowdsale with a one-off finalization action, where one - * can do extra work after finishing. - */ -contract FinalizableCrowdsale is TimedCrowdsale { - using SafeMath for uint256; - - bool private _finalized; - - event CrowdsaleFinalized(); - - constructor () internal { - _finalized = false; - } - - /** - * @return true if the crowdsale is finalized, false otherwise. - */ - function finalized() public view returns (bool) { - return _finalized; - } - - /** - * @dev Must be called after crowdsale ends, to do some extra finalization - * work. Calls the contract's finalization function. - */ - function finalize() public { - require(!_finalized, "FinalizableCrowdsale: already finalized"); - require(hasClosed(), "FinalizableCrowdsale: not closed"); - - _finalized = true; - - _finalization(); - emit CrowdsaleFinalized(); - } - - /** - * @dev Can be overridden to add finalization logic. The overriding function - * should call super._finalization() to ensure the chain of finalization is - * executed entirely. - */ - function _finalization() internal { - // solhint-disable-previous-line no-empty-blocks - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol deleted file mode 100644 index 41b9059b..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol +++ /dev/null @@ -1,65 +0,0 @@ -pragma solidity ^0.5.0; - -import "../validation/TimedCrowdsale.sol"; -import "../../math/SafeMath.sol"; -import "../../ownership/Secondary.sol"; -import "../../token/ERC20/IERC20.sol"; - -/** - * @title PostDeliveryCrowdsale - * @dev Crowdsale that locks tokens from withdrawal until it ends. - */ -contract PostDeliveryCrowdsale is TimedCrowdsale { - using SafeMath for uint256; - - mapping(address => uint256) private _balances; - __unstable__TokenVault private _vault; - - constructor() public { - _vault = new __unstable__TokenVault(); - } - - /** - * @dev Withdraw tokens only after crowdsale ends. - * @param beneficiary Whose tokens will be withdrawn. - */ - function withdrawTokens(address beneficiary) public { - require(hasClosed(), "PostDeliveryCrowdsale: not closed"); - uint256 amount = _balances[beneficiary]; - require(amount > 0, "PostDeliveryCrowdsale: beneficiary is not due any tokens"); - - _balances[beneficiary] = 0; - _vault.transfer(token(), beneficiary, amount); - } - - /** - * @return the balance of an account. - */ - function balanceOf(address account) public view returns (uint256) { - return _balances[account]; - } - - /** - * @dev Overrides parent by storing due balances, and delivering tokens to the vault instead of the end user. This - * ensures that the tokens will be available by the time they are withdrawn (which may not be the case if - * `_deliverTokens` was called later). - * @param beneficiary Token purchaser - * @param tokenAmount Amount of tokens purchased - */ - function _processPurchase(address beneficiary, uint256 tokenAmount) internal { - _balances[beneficiary] = _balances[beneficiary].add(tokenAmount); - _deliverTokens(address(_vault), tokenAmount); - } -} - -/** - * @title __unstable__TokenVault - * @dev Similar to an Escrow for tokens, this contract allows its primary account to spend its tokens as it sees fit. - * This contract is an internal helper for PostDeliveryCrowdsale, and should not be used outside of this context. - */ -// solhint-disable-next-line contract-name-camelcase -contract __unstable__TokenVault is Secondary { - function transfer(IERC20 token, address to, uint256 amount) public onlyPrimary { - token.transfer(to, amount); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/RefundableCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/RefundableCrowdsale.sol deleted file mode 100644 index 9c42606f..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/RefundableCrowdsale.sol +++ /dev/null @@ -1,83 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "../../math/SafeMath.sol"; -import "./FinalizableCrowdsale.sol"; -import "../../payment/escrow/RefundEscrow.sol"; - -/** - * @title RefundableCrowdsale - * @dev Extension of `FinalizableCrowdsale` contract that adds a funding goal, and the possibility of users - * getting a refund if goal is not met. - * - * Deprecated, use `RefundablePostDeliveryCrowdsale` instead. Note that if you allow tokens to be traded before the goal - * is met, then an attack is possible in which the attacker purchases tokens from the crowdsale and when they sees that - * the goal is unlikely to be met, they sell their tokens (possibly at a discount). The attacker will be refunded when - * the crowdsale is finalized, and the users that purchased from them will be left with worthless tokens. - */ -contract RefundableCrowdsale is Context, FinalizableCrowdsale { - using SafeMath for uint256; - - // minimum amount of funds to be raised in weis - uint256 private _goal; - - // refund escrow used to hold funds while crowdsale is running - RefundEscrow private _escrow; - - /** - * @dev Constructor, creates RefundEscrow. - * @param goal Funding goal - */ - constructor (uint256 goal) public { - require(goal > 0, "RefundableCrowdsale: goal is 0"); - _escrow = new RefundEscrow(wallet()); - _goal = goal; - } - - /** - * @return minimum amount of funds to be raised in wei. - */ - function goal() public view returns (uint256) { - return _goal; - } - - /** - * @dev Investors can claim refunds here if crowdsale is unsuccessful. - * @param refundee Whose refund will be claimed. - */ - function claimRefund(address payable refundee) public { - require(finalized(), "RefundableCrowdsale: not finalized"); - require(!goalReached(), "RefundableCrowdsale: goal reached"); - - _escrow.withdraw(refundee); - } - - /** - * @dev Checks whether funding goal was reached. - * @return Whether funding goal was reached - */ - function goalReached() public view returns (bool) { - return weiRaised() >= _goal; - } - - /** - * @dev Escrow finalization task, called when finalize() is called. - */ - function _finalization() internal { - if (goalReached()) { - _escrow.close(); - _escrow.beneficiaryWithdraw(); - } else { - _escrow.enableRefunds(); - } - - super._finalization(); - } - - /** - * @dev Overrides Crowdsale fund forwarding, sending funds to escrow. - */ - function _forwardFunds() internal { - _escrow.deposit.value(msg.value)(_msgSender()); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol deleted file mode 100644 index 385aa195..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol +++ /dev/null @@ -1,20 +0,0 @@ -pragma solidity ^0.5.0; - -import "./RefundableCrowdsale.sol"; -import "./PostDeliveryCrowdsale.sol"; - - -/** - * @title RefundablePostDeliveryCrowdsale - * @dev Extension of RefundableCrowdsale contract that only delivers the tokens - * once the crowdsale has closed and the goal met, preventing refunds to be issued - * to token holders. - */ -contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale { - function withdrawTokens(address beneficiary) public { - require(finalized(), "RefundablePostDeliveryCrowdsale: not finalized"); - require(goalReached(), "RefundablePostDeliveryCrowdsale: goal not reached"); - - super.withdrawTokens(beneficiary); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/emission/AllowanceCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/emission/AllowanceCrowdsale.sol deleted file mode 100644 index beee692a..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/emission/AllowanceCrowdsale.sol +++ /dev/null @@ -1,51 +0,0 @@ -pragma solidity ^0.5.0; - -import "../Crowdsale.sol"; -import "../../token/ERC20/IERC20.sol"; -import "../../token/ERC20/SafeERC20.sol"; -import "../../math/SafeMath.sol"; -import "../../math/Math.sol"; - -/** - * @title AllowanceCrowdsale - * @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale. - */ -contract AllowanceCrowdsale is Crowdsale { - using SafeMath for uint256; - using SafeERC20 for IERC20; - - address private _tokenWallet; - - /** - * @dev Constructor, takes token wallet address. - * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale. - */ - constructor (address tokenWallet) public { - require(tokenWallet != address(0), "AllowanceCrowdsale: token wallet is the zero address"); - _tokenWallet = tokenWallet; - } - - /** - * @return the address of the wallet that will hold the tokens. - */ - function tokenWallet() public view returns (address) { - return _tokenWallet; - } - - /** - * @dev Checks the amount of tokens left in the allowance. - * @return Amount of tokens left in the allowance - */ - function remainingTokens() public view returns (uint256) { - return Math.min(token().balanceOf(_tokenWallet), token().allowance(_tokenWallet, address(this))); - } - - /** - * @dev Overrides parent behavior by transferring tokens from wallet. - * @param beneficiary Token purchaser - * @param tokenAmount Amount of tokens purchased - */ - function _deliverTokens(address beneficiary, uint256 tokenAmount) internal { - token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/emission/MintedCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/emission/MintedCrowdsale.sol deleted file mode 100644 index 7815b8ca..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/emission/MintedCrowdsale.sol +++ /dev/null @@ -1,24 +0,0 @@ -pragma solidity ^0.5.0; - -import "../Crowdsale.sol"; -import "../../token/ERC20/ERC20Mintable.sol"; - -/** - * @title MintedCrowdsale - * @dev Extension of Crowdsale contract whose tokens are minted in each purchase. - * Token ownership should be transferred to MintedCrowdsale for minting. - */ -contract MintedCrowdsale is Crowdsale { - /** - * @dev Overrides delivery by minting tokens upon purchase. - * @param beneficiary Token purchaser - * @param tokenAmount Number of tokens to be minted - */ - function _deliverTokens(address beneficiary, uint256 tokenAmount) internal { - // Potentially dangerous assumption about the type of the token. - require( - ERC20Mintable(address(token())).mint(beneficiary, tokenAmount), - "MintedCrowdsale: minting failed" - ); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol deleted file mode 100644 index 964514ba..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol +++ /dev/null @@ -1,79 +0,0 @@ -pragma solidity ^0.5.0; - -import "../validation/TimedCrowdsale.sol"; -import "../../math/SafeMath.sol"; - -/** - * @title IncreasingPriceCrowdsale - * @dev Extension of Crowdsale contract that increases the price of tokens linearly in time. - * Note that what should be provided to the constructor is the initial and final _rates_, that is, - * the amount of tokens per wei contributed. Thus, the initial rate must be greater than the final rate. - */ -contract IncreasingPriceCrowdsale is TimedCrowdsale { - using SafeMath for uint256; - - uint256 private _initialRate; - uint256 private _finalRate; - - /** - * @dev Constructor, takes initial and final rates of tokens received per wei contributed. - * @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale - * @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale - */ - constructor (uint256 initialRate, uint256 finalRate) public { - require(finalRate > 0, "IncreasingPriceCrowdsale: final rate is 0"); - // solhint-disable-next-line max-line-length - require(initialRate > finalRate, "IncreasingPriceCrowdsale: initial rate is not greater than final rate"); - _initialRate = initialRate; - _finalRate = finalRate; - } - - /** - * The base rate function is overridden to revert, since this crowdsale doesn't use it, and - * all calls to it are a mistake. - */ - function rate() public view returns (uint256) { - revert("IncreasingPriceCrowdsale: rate() called"); - } - - /** - * @return the initial rate of the crowdsale. - */ - function initialRate() public view returns (uint256) { - return _initialRate; - } - - /** - * @return the final rate of the crowdsale. - */ - function finalRate() public view returns (uint256) { - return _finalRate; - } - - /** - * @dev Returns the rate of tokens per wei at the present time. - * Note that, as price _increases_ with time, the rate _decreases_. - * @return The number of tokens a buyer gets per wei at a given time - */ - function getCurrentRate() public view returns (uint256) { - if (!isOpen()) { - return 0; - } - - // solhint-disable-next-line not-rely-on-time - uint256 elapsedTime = block.timestamp.sub(openingTime()); - uint256 timeRange = closingTime().sub(openingTime()); - uint256 rateRange = _initialRate.sub(_finalRate); - return _initialRate.sub(elapsedTime.mul(rateRange).div(timeRange)); - } - - /** - * @dev Overrides parent method taking into account variable rate. - * @param weiAmount The value in wei to be converted into tokens - * @return The number of tokens _weiAmount wei will buy at present time - */ - function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) { - uint256 currentRate = getCurrentRate(); - return currentRate.mul(weiAmount); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/validation/CappedCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/validation/CappedCrowdsale.sol deleted file mode 100644 index e8aeede1..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/validation/CappedCrowdsale.sol +++ /dev/null @@ -1,48 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../math/SafeMath.sol"; -import "../Crowdsale.sol"; - -/** - * @title CappedCrowdsale - * @dev Crowdsale with a limit for total contributions. - */ -contract CappedCrowdsale is Crowdsale { - using SafeMath for uint256; - - uint256 private _cap; - - /** - * @dev Constructor, takes maximum amount of wei accepted in the crowdsale. - * @param cap Max amount of wei to be contributed - */ - constructor (uint256 cap) public { - require(cap > 0, "CappedCrowdsale: cap is 0"); - _cap = cap; - } - - /** - * @return the cap of the crowdsale. - */ - function cap() public view returns (uint256) { - return _cap; - } - - /** - * @dev Checks whether the cap has been reached. - * @return Whether the cap was reached - */ - function capReached() public view returns (bool) { - return weiRaised() >= _cap; - } - - /** - * @dev Extend parent behavior requiring purchase to respect the funding cap. - * @param beneficiary Token purchaser - * @param weiAmount Amount of wei contributed - */ - function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { - super._preValidatePurchase(beneficiary, weiAmount); - require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: cap exceeded"); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol deleted file mode 100644 index 1f9df361..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol +++ /dev/null @@ -1,64 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../math/SafeMath.sol"; -import "../Crowdsale.sol"; -import "../../access/roles/CapperRole.sol"; - -/** - * @title IndividuallyCappedCrowdsale - * @dev Crowdsale with per-beneficiary caps. - */ -contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole { - using SafeMath for uint256; - - mapping(address => uint256) private _contributions; - mapping(address => uint256) private _caps; - - /** - * @dev Sets a specific beneficiary's maximum contribution. - * @param beneficiary Address to be capped - * @param cap Wei limit for individual contribution - */ - function setCap(address beneficiary, uint256 cap) external onlyCapper { - _caps[beneficiary] = cap; - } - - /** - * @dev Returns the cap of a specific beneficiary. - * @param beneficiary Address whose cap is to be checked - * @return Current cap for individual beneficiary - */ - function getCap(address beneficiary) public view returns (uint256) { - return _caps[beneficiary]; - } - - /** - * @dev Returns the amount contributed so far by a specific beneficiary. - * @param beneficiary Address of contributor - * @return Beneficiary contribution so far - */ - function getContribution(address beneficiary) public view returns (uint256) { - return _contributions[beneficiary]; - } - - /** - * @dev Extend parent behavior requiring purchase to respect the beneficiary's funding cap. - * @param beneficiary Token purchaser - * @param weiAmount Amount of wei contributed - */ - function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view { - super._preValidatePurchase(beneficiary, weiAmount); - // solhint-disable-next-line max-line-length - require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "IndividuallyCappedCrowdsale: beneficiary's cap exceeded"); - } - - /** - * @dev Extend parent behavior to update beneficiary contributions. - * @param beneficiary Token purchaser - * @param weiAmount Amount of wei contributed - */ - function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal { - super._updatePurchasingState(beneficiary, weiAmount); - _contributions[beneficiary] = _contributions[beneficiary].add(weiAmount); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/validation/PausableCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/validation/PausableCrowdsale.sol deleted file mode 100644 index cc89aeba..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/validation/PausableCrowdsale.sol +++ /dev/null @@ -1,21 +0,0 @@ -pragma solidity ^0.5.0; - -import "../Crowdsale.sol"; -import "../../lifecycle/Pausable.sol"; - -/** - * @title PausableCrowdsale - * @dev Extension of Crowdsale contract where purchases can be paused and unpaused by the pauser role. - */ -contract PausableCrowdsale is Crowdsale, Pausable { - /** - * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. - * Use super to concatenate validations. - * Adds the validation that the crowdsale must not be paused. - * @param _beneficiary Address performing the token purchase - * @param _weiAmount Value in wei involved in the purchase - */ - function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view whenNotPaused { - return super._preValidatePurchase(_beneficiary, _weiAmount); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/validation/TimedCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/validation/TimedCrowdsale.sol deleted file mode 100644 index 255a63f3..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/validation/TimedCrowdsale.sol +++ /dev/null @@ -1,98 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../math/SafeMath.sol"; -import "../Crowdsale.sol"; - -/** - * @title TimedCrowdsale - * @dev Crowdsale accepting contributions only within a time frame. - */ -contract TimedCrowdsale is Crowdsale { - using SafeMath for uint256; - - uint256 private _openingTime; - uint256 private _closingTime; - - /** - * Event for crowdsale extending - * @param newClosingTime new closing time - * @param prevClosingTime old closing time - */ - event TimedCrowdsaleExtended(uint256 prevClosingTime, uint256 newClosingTime); - - /** - * @dev Reverts if not in crowdsale time range. - */ - modifier onlyWhileOpen { - require(isOpen(), "TimedCrowdsale: not open"); - _; - } - - /** - * @dev Constructor, takes crowdsale opening and closing times. - * @param openingTime Crowdsale opening time - * @param closingTime Crowdsale closing time - */ - constructor (uint256 openingTime, uint256 closingTime) public { - // solhint-disable-next-line not-rely-on-time - require(openingTime >= block.timestamp, "TimedCrowdsale: opening time is before current time"); - // solhint-disable-next-line max-line-length - require(closingTime > openingTime, "TimedCrowdsale: opening time is not before closing time"); - - _openingTime = openingTime; - _closingTime = closingTime; - } - - /** - * @return the crowdsale opening time. - */ - function openingTime() public view returns (uint256) { - return _openingTime; - } - - /** - * @return the crowdsale closing time. - */ - function closingTime() public view returns (uint256) { - return _closingTime; - } - - /** - * @return true if the crowdsale is open, false otherwise. - */ - function isOpen() public view returns (bool) { - // solhint-disable-next-line not-rely-on-time - return block.timestamp >= _openingTime && block.timestamp <= _closingTime; - } - - /** - * @dev Checks whether the period in which the crowdsale is open has already elapsed. - * @return Whether crowdsale period has elapsed - */ - function hasClosed() public view returns (bool) { - // solhint-disable-next-line not-rely-on-time - return block.timestamp > _closingTime; - } - - /** - * @dev Extend parent behavior requiring to be within contributing period. - * @param beneficiary Token purchaser - * @param weiAmount Amount of wei contributed - */ - function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal onlyWhileOpen view { - super._preValidatePurchase(beneficiary, weiAmount); - } - - /** - * @dev Extend crowdsale. - * @param newClosingTime Crowdsale closing time - */ - function _extendTime(uint256 newClosingTime) internal { - require(!hasClosed(), "TimedCrowdsale: already closed"); - // solhint-disable-next-line max-line-length - require(newClosingTime > _closingTime, "TimedCrowdsale: new closing time is before current closing time"); - - emit TimedCrowdsaleExtended(_closingTime, newClosingTime); - _closingTime = newClosingTime; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/crowdsale/validation/WhitelistCrowdsale.sol b/src/node_modules/@openzeppelin/contracts/crowdsale/validation/WhitelistCrowdsale.sol deleted file mode 100644 index 0f596535..00000000 --- a/src/node_modules/@openzeppelin/contracts/crowdsale/validation/WhitelistCrowdsale.sol +++ /dev/null @@ -1,21 +0,0 @@ -pragma solidity ^0.5.0; -import "../Crowdsale.sol"; -import "../../access/roles/WhitelistedRole.sol"; - - -/** - * @title WhitelistCrowdsale - * @dev Crowdsale in which only whitelisted users can contribute. - */ -contract WhitelistCrowdsale is WhitelistedRole, Crowdsale { - /** - * @dev Extend parent behavior requiring beneficiary to be whitelisted. Note that no - * restriction is imposed on the account sending the transaction. - * @param _beneficiary Token beneficiary - * @param _weiAmount Amount of wei contributed - */ - function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view { - require(isWhitelisted(_beneficiary), "WhitelistCrowdsale: beneficiary doesn't have the Whitelisted role"); - super._preValidatePurchase(_beneficiary, _weiAmount); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/cryptography/ECDSA.sol b/src/node_modules/@openzeppelin/contracts/cryptography/ECDSA.sol deleted file mode 100644 index d85ce09d..00000000 --- a/src/node_modules/@openzeppelin/contracts/cryptography/ECDSA.sol +++ /dev/null @@ -1,82 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. - * - * These functions can be used to verify that a message was signed by the holder - * of the private keys of a given address. - */ -library ECDSA { - /** - * @dev Returns the address that signed a hashed message (`hash`) with - * `signature`. This address can then be used for verification purposes. - * - * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: - * this function rejects them by requiring the `s` value to be in the lower - * half order, and the `v` value to be either 27 or 28. - * - * NOTE: This call _does not revert_ if the signature is invalid, or - * if the signer is otherwise unable to be retrieved. In those scenarios, - * the zero address is returned. - * - * IMPORTANT: `hash` _must_ be the result of a hash operation for the - * verification to be secure: it is possible to craft signatures that - * recover to arbitrary addresses for non-hashed data. A safe way to ensure - * this is by receiving a hash of the original message (which may otherwise - * be too long), and then calling {toEthSignedMessageHash} on it. - */ - function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { - // Check the signature length - if (signature.length != 65) { - return (address(0)); - } - - // Divide the signature in r, s and v variables - bytes32 r; - bytes32 s; - uint8 v; - - // ecrecover takes the signature parameters, and the only way to get them - // currently is to use assembly. - // solhint-disable-next-line no-inline-assembly - assembly { - r := mload(add(signature, 0x20)) - s := mload(add(signature, 0x40)) - v := byte(0, mload(add(signature, 0x60))) - } - - // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature - // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines - // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most - // signatures from current libraries generate a unique signature with an s-value in the lower half order. - // - // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value - // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or - // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept - // these malleable signatures as well. - if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { - return address(0); - } - - if (v != 27 && v != 28) { - return address(0); - } - - // If the signature is valid (and not malleable), return the signer address - return ecrecover(hash, v, r, s); - } - - /** - * @dev Returns an Ethereum Signed Message, created from a `hash`. This - * replicates the behavior of the - * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] - * JSON-RPC method. - * - * See {recover}. - */ - function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { - // 32 is the length in bytes of hash, - // enforced by the type signature above - return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/cryptography/MerkleProof.sol b/src/node_modules/@openzeppelin/contracts/cryptography/MerkleProof.sol deleted file mode 100644 index c8480590..00000000 --- a/src/node_modules/@openzeppelin/contracts/cryptography/MerkleProof.sol +++ /dev/null @@ -1,31 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev These functions deal with verification of Merkle trees (hash trees), - */ -library MerkleProof { - /** - * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree - * defined by `root`. For this, a `proof` must be provided, containing - * sibling hashes on the branch from the leaf to the root of the tree. Each - * pair of leaves and each pair of pre-images are assumed to be sorted. - */ - function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { - bytes32 computedHash = leaf; - - for (uint256 i = 0; i < proof.length; i++) { - bytes32 proofElement = proof[i]; - - if (computedHash <= proofElement) { - // Hash(current computed hash + current element of the proof) - computedHash = keccak256(abi.encodePacked(computedHash, proofElement)); - } else { - // Hash(current element of the proof + current computed hash) - computedHash = keccak256(abi.encodePacked(proofElement, computedHash)); - } - } - - // Check if the computed hash (root) is equal to the provided root - return computedHash == root; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/cryptography/README.adoc b/src/node_modules/@openzeppelin/contracts/cryptography/README.adoc deleted file mode 100644 index 2adc27f0..00000000 --- a/src/node_modules/@openzeppelin/contracts/cryptography/README.adoc +++ /dev/null @@ -1,9 +0,0 @@ -= Cryptography - -This collection of libraries provides simple and safe ways to use different cryptographic primitives. - -== Libraries - -{{ECDSA}} - -{{MerkleProof}} diff --git a/src/node_modules/@openzeppelin/contracts/drafts/Counters.sol b/src/node_modules/@openzeppelin/contracts/drafts/Counters.sol deleted file mode 100644 index 15ecb775..00000000 --- a/src/node_modules/@openzeppelin/contracts/drafts/Counters.sol +++ /dev/null @@ -1,38 +0,0 @@ -pragma solidity ^0.5.0; - -import "../math/SafeMath.sol"; - -/** - * @title Counters - * @author Matt Condon (@shrugs) - * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number - * of elements in a mapping, issuing ERC721 ids, or counting request ids. - * - * Include with `using Counters for Counters.Counter;` - * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath} - * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never - * directly accessed. - */ -library Counters { - using SafeMath for uint256; - - struct Counter { - // This variable should never be directly accessed by users of the library: interactions must be restricted to - // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add - // this feature: see https://github.com/ethereum/solidity/issues/4637 - uint256 _value; // default: 0 - } - - function current(Counter storage counter) internal view returns (uint256) { - return counter._value; - } - - function increment(Counter storage counter) internal { - // The {SafeMath} overflow check can be skipped here, see the comment at the top - counter._value += 1; - } - - function decrement(Counter storage counter) internal { - counter._value = counter._value.sub(1); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/drafts/ERC1046/ERC20Metadata.sol b/src/node_modules/@openzeppelin/contracts/drafts/ERC1046/ERC20Metadata.sol deleted file mode 100644 index 2311de1c..00000000 --- a/src/node_modules/@openzeppelin/contracts/drafts/ERC1046/ERC20Metadata.sol +++ /dev/null @@ -1,24 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../token/ERC20/IERC20.sol"; - -/** - * @title ERC-1047 Token Metadata - * @dev See https://eips.ethereum.org/EIPS/eip-1046 - * @dev {tokenURI} must respond with a URI that implements https://eips.ethereum.org/EIPS/eip-1047 - */ -contract ERC20Metadata { - string private _tokenURI; - - constructor (string memory tokenURI_) public { - _setTokenURI(tokenURI_); - } - - function tokenURI() external view returns (string memory) { - return _tokenURI; - } - - function _setTokenURI(string memory tokenURI_) internal { - _tokenURI = tokenURI_; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/drafts/ERC20Migrator.sol b/src/node_modules/@openzeppelin/contracts/drafts/ERC20Migrator.sol deleted file mode 100644 index 44ab6e7f..00000000 --- a/src/node_modules/@openzeppelin/contracts/drafts/ERC20Migrator.sol +++ /dev/null @@ -1,103 +0,0 @@ -pragma solidity ^0.5.0; - -import "../token/ERC20/IERC20.sol"; -import "../token/ERC20/ERC20Mintable.sol"; -import "../token/ERC20/SafeERC20.sol"; -import "../math/Math.sol"; - -/** - * @title ERC20Migrator - * @dev This contract can be used to migrate an ERC20 token from one - * contract to another, where each token holder has to opt-in to the migration. - * To opt-in, users must approve for this contract the number of tokens they - * want to migrate. Once the allowance is set up, anyone can trigger the - * migration to the new token contract. In this way, token holders "turn in" - * their old balance and will be minted an equal amount in the new token. - * The new token contract must be mintable. For the precise interface refer to - * OpenZeppelin's {ERC20Mintable}, but the only functions that are needed are - * {MinterRole-isMinter} and {ERC20Mintable-mint}. The migrator will check - * that it is a minter for the token. - * The balance from the legacy token will be transferred to the migrator, as it - * is migrated, and remain there forever. - * Although this contract can be used in many different scenarios, the main - * motivation was to provide a way to migrate ERC20 tokens into an upgradeable - * version of it using ZeppelinOS. To read more about how this can be done - * using this implementation, please follow the official documentation site of - * ZeppelinOS: https://docs.zeppelinos.org/docs/erc20_onboarding.html - * - * Example of usage: - * ``` - * const migrator = await ERC20Migrator.new(legacyToken.address); - * await newToken.addMinter(migrator.address); - * await migrator.beginMigration(newToken.address); - * ``` - */ -contract ERC20Migrator { - using SafeERC20 for IERC20; - - /// Address of the old token contract - IERC20 private _legacyToken; - - /// Address of the new token contract - ERC20Mintable private _newToken; - - /** - * @param legacyToken address of the old token contract - */ - constructor (IERC20 legacyToken) public { - require(address(legacyToken) != address(0), "ERC20Migrator: legacy token is the zero address"); - _legacyToken = legacyToken; - } - - /** - * @dev Returns the legacy token that is being migrated. - */ - function legacyToken() public view returns (IERC20) { - return _legacyToken; - } - - /** - * @dev Returns the new token to which we are migrating. - */ - function newToken() public view returns (IERC20) { - return _newToken; - } - - /** - * @dev Begins the migration by setting which is the new token that will be - * minted. This contract must be a minter for the new token. - * @param newToken_ the token that will be minted - */ - function beginMigration(ERC20Mintable newToken_) public { - require(address(_newToken) == address(0), "ERC20Migrator: migration already started"); - require(address(newToken_) != address(0), "ERC20Migrator: new token is the zero address"); - //solhint-disable-next-line max-line-length - require(newToken_.isMinter(address(this)), "ERC20Migrator: not a minter for new token"); - - _newToken = newToken_; - } - - /** - * @dev Transfers part of an account's balance in the old token to this - * contract, and mints the same amount of new tokens for that account. - * @param account whose tokens will be migrated - * @param amount amount of tokens to be migrated - */ - function migrate(address account, uint256 amount) public { - require(address(_newToken) != address(0), "ERC20Migrator: migration not started"); - _legacyToken.safeTransferFrom(account, address(this), amount); - _newToken.mint(account, amount); - } - - /** - * @dev Transfers all of an account's allowed balance in the old token to - * this contract, and mints the same amount of new tokens for that account. - * @param account whose tokens will be migrated - */ - function migrateAll(address account) public { - uint256 balance = _legacyToken.balanceOf(account); - uint256 allowance = _legacyToken.allowance(account, address(this)); - uint256 amount = Math.min(balance, allowance); - migrate(account, amount); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/drafts/ERC20Snapshot.sol b/src/node_modules/@openzeppelin/contracts/drafts/ERC20Snapshot.sol deleted file mode 100644 index d1f42ec3..00000000 --- a/src/node_modules/@openzeppelin/contracts/drafts/ERC20Snapshot.sol +++ /dev/null @@ -1,142 +0,0 @@ -pragma solidity ^0.5.0; - -import "../math/SafeMath.sol"; -import "../utils/Arrays.sol"; -import "../drafts/Counters.sol"; -import "../token/ERC20/ERC20.sol"; - -/** - * @title ERC20 token with snapshots. - * @dev Inspired by Jordi Baylina's - * https://github.com/Giveth/minimd/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol[MiniMeToken] - * to record historical balances. - * - * When a snapshot is made, the balances and total supply at the time of the snapshot are recorded for later - * access. - * - * To make a snapshot, call the {snapshot} function, which will emit the {Snapshot} event and return a snapshot id. - * To get the total supply from a snapshot, call the function {totalSupplyAt} with the snapshot id. - * To get the balance of an account from a snapshot, call the {balanceOfAt} function with the snapshot id and the - * account address. - * @author Validity Labs AG - */ -contract ERC20Snapshot is ERC20 { - using SafeMath for uint256; - using Arrays for uint256[]; - using Counters for Counters.Counter; - - // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a - // Snapshot struct, but that would impede usage of functions that work on an array. - struct Snapshots { - uint256[] ids; - uint256[] values; - } - - mapping (address => Snapshots) private _accountBalanceSnapshots; - Snapshots private _totalSupplySnapshots; - - // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid. - Counters.Counter private _currentSnapshotId; - - event Snapshot(uint256 id); - - // Creates a new snapshot id. Balances are only stored in snapshots on demand: unless a snapshot was taken, a - // balance change will not be recorded. This means the extra added cost of storing snapshotted balances is only paid - // when required, but is also flexible enough that it allows for e.g. daily snapshots. - function snapshot() public returns (uint256) { - _currentSnapshotId.increment(); - - uint256 currentId = _currentSnapshotId.current(); - emit Snapshot(currentId); - return currentId; - } - - function balanceOfAt(address account, uint256 snapshotId) public view returns (uint256) { - (bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]); - - return snapshotted ? value : balanceOf(account); - } - - function totalSupplyAt(uint256 snapshotId) public view returns(uint256) { - (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots); - - return snapshotted ? value : totalSupply(); - } - - // _transfer, _mint and _burn are the only functions where the balances are modified, so it is there that the - // snapshots are updated. Note that the update happens _before_ the balance change, with the pre-modified value. - // The same is true for the total supply and _mint and _burn. - function _transfer(address from, address to, uint256 value) internal { - _updateAccountSnapshot(from); - _updateAccountSnapshot(to); - - super._transfer(from, to, value); - } - - function _mint(address account, uint256 value) internal { - _updateAccountSnapshot(account); - _updateTotalSupplySnapshot(); - - super._mint(account, value); - } - - function _burn(address account, uint256 value) internal { - _updateAccountSnapshot(account); - _updateTotalSupplySnapshot(); - - super._burn(account, value); - } - - // When a valid snapshot is queried, there are three possibilities: - // a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never - // created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds - // to this id is the current one. - // b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the - // requested id, and its value is the one to return. - // c) More snapshots were created after the requested one, and the queried value was later modified. There will be - // no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is - // larger than the requested one. - // - // In summary, we need to find an element in an array, returning the index of the smallest value that is larger if - // it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does - // exactly this. - function _valueAt(uint256 snapshotId, Snapshots storage snapshots) - private view returns (bool, uint256) - { - require(snapshotId > 0, "ERC20Snapshot: id is 0"); - // solhint-disable-next-line max-line-length - require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: nonexistent id"); - - uint256 index = snapshots.ids.findUpperBound(snapshotId); - - if (index == snapshots.ids.length) { - return (false, 0); - } else { - return (true, snapshots.values[index]); - } - } - - function _updateAccountSnapshot(address account) private { - _updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account)); - } - - function _updateTotalSupplySnapshot() private { - _updateSnapshot(_totalSupplySnapshots, totalSupply()); - } - - function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private { - uint256 currentId = _currentSnapshotId.current(); - if (_lastSnapshotId(snapshots.ids) < currentId) { - snapshots.ids.push(currentId); - snapshots.values.push(currentValue); - } - } - - function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) { - if (ids.length == 0) { - return 0; - } else { - return ids[ids.length - 1]; - } - } -} diff --git a/src/node_modules/@openzeppelin/contracts/drafts/README.adoc b/src/node_modules/@openzeppelin/contracts/drafts/README.adoc deleted file mode 100644 index 19e981ae..00000000 --- a/src/node_modules/@openzeppelin/contracts/drafts/README.adoc +++ /dev/null @@ -1,23 +0,0 @@ -= Drafts - -Contracts in this category should be considered unstable. They are as thoroughly reviewed as everything else in OpenZeppelin Contracts, but we have doubts about their API so we don't commit to backwards compatibility. This means these contracts can receive breaking changes in a minor version, so you should pay special attention to the changelog when upgrading. For anything that is outside of this category you can read more about xref:ROOT:api-stability.adoc[API Stability]. - -NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned! - -== ERC 20 - -{{ERC20Migrator}} - -{{ERC20Snapshot}} - -{{TokenVesting}} - -== Miscellaneous - -{{Counters}} - -{{SignedSafeMath}} - -== ERC 1046 - -{{ERC1046}} diff --git a/src/node_modules/@openzeppelin/contracts/drafts/SignedSafeMath.sol b/src/node_modules/@openzeppelin/contracts/drafts/SignedSafeMath.sol deleted file mode 100644 index 161d21bc..00000000 --- a/src/node_modules/@openzeppelin/contracts/drafts/SignedSafeMath.sol +++ /dev/null @@ -1,60 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @title SignedSafeMath - * @dev Signed math operations with safety checks that revert on error. - */ -library SignedSafeMath { - int256 constant private INT256_MIN = -2**255; - - /** - * @dev Multiplies two signed integers, reverts on overflow. - */ - function mul(int256 a, int256 b) internal pure returns (int256) { - // Gas optimization: this is cheaper than requiring 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 - if (a == 0) { - return 0; - } - - require(!(a == -1 && b == INT256_MIN), "SignedSafeMath: multiplication overflow"); - - int256 c = a * b; - require(c / a == b, "SignedSafeMath: multiplication overflow"); - - return c; - } - - /** - * @dev Integer division of two signed integers truncating the quotient, reverts on division by zero. - */ - function div(int256 a, int256 b) internal pure returns (int256) { - require(b != 0, "SignedSafeMath: division by zero"); - require(!(b == -1 && a == INT256_MIN), "SignedSafeMath: division overflow"); - - int256 c = a / b; - - return c; - } - - /** - * @dev Subtracts two signed integers, reverts on overflow. - */ - function sub(int256 a, int256 b) internal pure returns (int256) { - int256 c = a - b; - require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow"); - - return c; - } - - /** - * @dev Adds two signed integers, reverts on overflow. - */ - function add(int256 a, int256 b) internal pure returns (int256) { - int256 c = a + b; - require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow"); - - return c; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/drafts/Strings.sol b/src/node_modules/@openzeppelin/contracts/drafts/Strings.sol deleted file mode 100644 index d5fcbf65..00000000 --- a/src/node_modules/@openzeppelin/contracts/drafts/Strings.sol +++ /dev/null @@ -1,32 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @title Strings - * @dev String operations. - */ -library Strings { - /** - * @dev Converts a `uint256` to a `string`. - * via OraclizeAPI - MIT licence - * https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol - */ - function fromUint256(uint256 value) internal pure returns (string memory) { - if (value == 0) { - return "0"; - } - uint256 temp = value; - uint256 digits; - while (temp != 0) { - digits++; - temp /= 10; - } - bytes memory buffer = new bytes(digits); - uint256 index = digits - 1; - temp = value; - while (temp != 0) { - buffer[index--] = byte(uint8(48 + temp % 10)); - temp /= 10; - } - return string(buffer); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/drafts/TokenVesting.sol b/src/node_modules/@openzeppelin/contracts/drafts/TokenVesting.sol deleted file mode 100644 index 626db459..00000000 --- a/src/node_modules/@openzeppelin/contracts/drafts/TokenVesting.sol +++ /dev/null @@ -1,174 +0,0 @@ -pragma solidity ^0.5.0; - -import "../token/ERC20/SafeERC20.sol"; -import "../ownership/Ownable.sol"; -import "../math/SafeMath.sol"; - -/** - * @title TokenVesting - * @dev A token holder contract that can release its token balance gradually like a - * typical vesting scheme, with a cliff and vesting period. Optionally revocable by the - * owner. - */ -contract TokenVesting is Ownable { - // The vesting schedule is time-based (i.e. using block timestamps as opposed to e.g. block numbers), and is - // therefore sensitive to timestamp manipulation (which is something miners can do, to a certain degree). Therefore, - // it is recommended to avoid using short time durations (less than a minute). Typical vesting schemes, with a - // cliff period of a year and a duration of four years, are safe to use. - // solhint-disable not-rely-on-time - - using SafeMath for uint256; - using SafeERC20 for IERC20; - - event TokensReleased(address token, uint256 amount); - event TokenVestingRevoked(address token); - - // beneficiary of tokens after they are released - address private _beneficiary; - - // Durations and timestamps are expressed in UNIX time, the same units as block.timestamp. - uint256 private _cliff; - uint256 private _start; - uint256 private _duration; - - bool private _revocable; - - mapping (address => uint256) private _released; - mapping (address => bool) private _revoked; - - /** - * @dev Creates a vesting contract that vests its balance of any ERC20 token to the - * beneficiary, gradually in a linear fashion until start + duration. By then all - * of the balance will have vested. - * @param beneficiary address of the beneficiary to whom vested tokens are transferred - * @param cliffDuration duration in seconds of the cliff in which tokens will begin to vest - * @param start the time (as Unix time) at which point vesting starts - * @param duration duration in seconds of the period in which the tokens will vest - * @param revocable whether the vesting is revocable or not - */ - constructor (address beneficiary, uint256 start, uint256 cliffDuration, uint256 duration, bool revocable) public { - require(beneficiary != address(0), "TokenVesting: beneficiary is the zero address"); - // solhint-disable-next-line max-line-length - require(cliffDuration <= duration, "TokenVesting: cliff is longer than duration"); - require(duration > 0, "TokenVesting: duration is 0"); - // solhint-disable-next-line max-line-length - require(start.add(duration) > block.timestamp, "TokenVesting: final time is before current time"); - - _beneficiary = beneficiary; - _revocable = revocable; - _duration = duration; - _cliff = start.add(cliffDuration); - _start = start; - } - - /** - * @return the beneficiary of the tokens. - */ - function beneficiary() public view returns (address) { - return _beneficiary; - } - - /** - * @return the cliff time of the token vesting. - */ - function cliff() public view returns (uint256) { - return _cliff; - } - - /** - * @return the start time of the token vesting. - */ - function start() public view returns (uint256) { - return _start; - } - - /** - * @return the duration of the token vesting. - */ - function duration() public view returns (uint256) { - return _duration; - } - - /** - * @return true if the vesting is revocable. - */ - function revocable() public view returns (bool) { - return _revocable; - } - - /** - * @return the amount of the token released. - */ - function released(address token) public view returns (uint256) { - return _released[token]; - } - - /** - * @return true if the token is revoked. - */ - function revoked(address token) public view returns (bool) { - return _revoked[token]; - } - - /** - * @notice Transfers vested tokens to beneficiary. - * @param token ERC20 token which is being vested - */ - function release(IERC20 token) public { - uint256 unreleased = _releasableAmount(token); - - require(unreleased > 0, "TokenVesting: no tokens are due"); - - _released[address(token)] = _released[address(token)].add(unreleased); - - token.safeTransfer(_beneficiary, unreleased); - - emit TokensReleased(address(token), unreleased); - } - - /** - * @notice Allows the owner to revoke the vesting. Tokens already vested - * remain in the contract, the rest are returned to the owner. - * @param token ERC20 token which is being vested - */ - function revoke(IERC20 token) public onlyOwner { - require(_revocable, "TokenVesting: cannot revoke"); - require(!_revoked[address(token)], "TokenVesting: token already revoked"); - - uint256 balance = token.balanceOf(address(this)); - - uint256 unreleased = _releasableAmount(token); - uint256 refund = balance.sub(unreleased); - - _revoked[address(token)] = true; - - token.safeTransfer(owner(), refund); - - emit TokenVestingRevoked(address(token)); - } - - /** - * @dev Calculates the amount that has already vested but hasn't been released yet. - * @param token ERC20 token which is being vested - */ - function _releasableAmount(IERC20 token) private view returns (uint256) { - return _vestedAmount(token).sub(_released[address(token)]); - } - - /** - * @dev Calculates the amount that has already vested. - * @param token ERC20 token which is being vested - */ - function _vestedAmount(IERC20 token) private view returns (uint256) { - uint256 currentBalance = token.balanceOf(address(this)); - uint256 totalBalance = currentBalance.add(_released[address(token)]); - - if (block.timestamp < _cliff) { - return 0; - } else if (block.timestamp >= _start.add(_duration) || _revoked[address(token)]) { - return totalBalance; - } else { - return totalBalance.mul(block.timestamp.sub(_start)).div(_duration); - } - } -} diff --git a/src/node_modules/@openzeppelin/contracts/introspection/ERC165.sol b/src/node_modules/@openzeppelin/contracts/introspection/ERC165.sol deleted file mode 100644 index 86e7c9ae..00000000 --- a/src/node_modules/@openzeppelin/contracts/introspection/ERC165.sol +++ /dev/null @@ -1,52 +0,0 @@ -pragma solidity ^0.5.0; - -import "./IERC165.sol"; - -/** - * @dev Implementation of the {IERC165} interface. - * - * Contracts may inherit from this and call {_registerInterface} to declare - * their support of an interface. - */ -contract ERC165 is IERC165 { - /* - * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 - */ - bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; - - /** - * @dev Mapping of interface ids to whether or not it's supported. - */ - mapping(bytes4 => bool) private _supportedInterfaces; - - constructor () internal { - // Derived contracts need only register support for their own interfaces, - // we register support for ERC165 itself here - _registerInterface(_INTERFACE_ID_ERC165); - } - - /** - * @dev See {IERC165-supportsInterface}. - * - * Time complexity O(1), guaranteed to always use less than 30 000 gas. - */ - function supportsInterface(bytes4 interfaceId) external view returns (bool) { - return _supportedInterfaces[interfaceId]; - } - - /** - * @dev Registers the contract as an implementer of the interface defined by - * `interfaceId`. Support of the actual ERC165 interface is automatic and - * registering its interface id is not required. - * - * See {IERC165-supportsInterface}. - * - * Requirements: - * - * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). - */ - function _registerInterface(bytes4 interfaceId) internal { - require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); - _supportedInterfaces[interfaceId] = true; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/introspection/ERC165Checker.sol b/src/node_modules/@openzeppelin/contracts/introspection/ERC165Checker.sol deleted file mode 100644 index 31acc602..00000000 --- a/src/node_modules/@openzeppelin/contracts/introspection/ERC165Checker.sol +++ /dev/null @@ -1,104 +0,0 @@ -pragma solidity ^0.5.10; - -/** - * @dev Library used to query support of an interface declared via {IERC165}. - * - * Note that these functions return the actual result of the query: they do not - * `revert` if an interface is not supported. It is up to the caller to decide - * what to do in these cases. - */ -library ERC165Checker { - // As per the EIP-165 spec, no interface should ever match 0xffffffff - bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff; - - /* - * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7 - */ - bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7; - - /** - * @dev Returns true if `account` supports the {IERC165} interface, - */ - function _supportsERC165(address account) internal view returns (bool) { - // Any contract that implements ERC165 must explicitly indicate support of - // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid - return _supportsERC165Interface(account, _INTERFACE_ID_ERC165) && - !_supportsERC165Interface(account, _INTERFACE_ID_INVALID); - } - - /** - * @dev Returns true if `account` supports the interface defined by - * `interfaceId`. Support for {IERC165} itself is queried automatically. - * - * See {IERC165-supportsInterface}. - */ - function _supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) { - // query support of both ERC165 as per the spec and support of _interfaceId - return _supportsERC165(account) && - _supportsERC165Interface(account, interfaceId); - } - - /** - * @dev Returns true if `account` supports all the interfaces defined in - * `interfaceIds`. Support for {IERC165} itself is queried automatically. - * - * Batch-querying can lead to gas savings by skipping repeated checks for - * {IERC165} support. - * - * See {IERC165-supportsInterface}. - */ - function _supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) { - // query support of ERC165 itself - if (!_supportsERC165(account)) { - return false; - } - - // query support of each interface in _interfaceIds - for (uint256 i = 0; i < interfaceIds.length; i++) { - if (!_supportsERC165Interface(account, interfaceIds[i])) { - return false; - } - } - - // all interfaces supported - return true; - } - - /** - * @notice Query if a contract implements an interface, does not check ERC165 support - * @param account The address of the contract to query for support of an interface - * @param interfaceId The interface identifier, as specified in ERC-165 - * @return true if the contract at account indicates support of the interface with - * identifier interfaceId, false otherwise - * @dev Assumes that account contains a contract that supports ERC165, otherwise - * the behavior of this method is undefined. This precondition can be checked - * with the `supportsERC165` method in this library. - * Interface identification is specified in ERC-165. - */ - function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) { - // success determines whether the staticcall succeeded and result determines - // whether the contract at account indicates support of _interfaceId - (bool success, bool result) = _callERC165SupportsInterface(account, interfaceId); - - return (success && result); - } - - /** - * @notice Calls the function with selector 0x01ffc9a7 (ERC165) and suppresses throw - * @param account The address of the contract to query for support of an interface - * @param interfaceId The interface identifier, as specified in ERC-165 - * @return success true if the STATICCALL succeeded, false otherwise - * @return result true if the STATICCALL succeeded and the contract at account - * indicates support of the interface with identifier interfaceId, false otherwise - */ - function _callERC165SupportsInterface(address account, bytes4 interfaceId) - private - view - returns (bool, bool) - { - bytes memory encodedParams = abi.encodeWithSelector(_INTERFACE_ID_ERC165, interfaceId); - (bool success, bytes memory result) = account.staticcall.gas(30000)(encodedParams); - if (result.length < 32) return (false, false); - return (success, abi.decode(result, (bool))); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/introspection/ERC1820Implementer.sol b/src/node_modules/@openzeppelin/contracts/introspection/ERC1820Implementer.sol deleted file mode 100644 index 2aba6951..00000000 --- a/src/node_modules/@openzeppelin/contracts/introspection/ERC1820Implementer.sol +++ /dev/null @@ -1,35 +0,0 @@ -pragma solidity ^0.5.0; - -import "./IERC1820Implementer.sol"; - -/** - * @dev Implementation of the {IERC1820Implementer} interface. - * - * Contracts may inherit from this and call {_registerInterfaceForAddress} to - * declare their willingness to be implementers. - * {IERC1820Registry-setInterfaceImplementer} should then be called for the - * registration to be complete. - */ -contract ERC1820Implementer is IERC1820Implementer { - bytes32 constant private ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC")); - - mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces; - - /** - * See {IERC1820Implementer-canImplementInterfaceForAddress}. - */ - function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view returns (bytes32) { - return _supportedInterfaces[interfaceHash][account] ? ERC1820_ACCEPT_MAGIC : bytes32(0x00); - } - - /** - * @dev Declares the contract as willing to be an implementer of - * `interfaceHash` for `account`. - * - * See {IERC1820Registry-setInterfaceImplementer} and - * {IERC1820Registry-interfaceHash}. - */ - function _registerInterfaceForAddress(bytes32 interfaceHash, address account) internal { - _supportedInterfaces[interfaceHash][account] = true; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/introspection/IERC165.sol b/src/node_modules/@openzeppelin/contracts/introspection/IERC165.sol deleted file mode 100644 index 07c6fac5..00000000 --- a/src/node_modules/@openzeppelin/contracts/introspection/IERC165.sol +++ /dev/null @@ -1,22 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Interface of the ERC165 standard, as defined in the - * https://eips.ethereum.org/EIPS/eip-165[EIP]. - * - * Implementers can declare support of contract interfaces, which can then be - * queried by others ({ERC165Checker}). - * - * For an implementation, see {ERC165}. - */ -interface IERC165 { - /** - * @dev Returns true if this contract implements the interface defined by - * `interfaceId`. See the corresponding - * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] - * to learn more about how these ids are created. - * - * This function call must use less than 30 000 gas. - */ - function supportsInterface(bytes4 interfaceId) external view returns (bool); -} diff --git a/src/node_modules/@openzeppelin/contracts/introspection/IERC1820Implementer.sol b/src/node_modules/@openzeppelin/contracts/introspection/IERC1820Implementer.sol deleted file mode 100644 index 21fe8275..00000000 --- a/src/node_modules/@openzeppelin/contracts/introspection/IERC1820Implementer.sol +++ /dev/null @@ -1,17 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Interface for an ERC1820 implementer, as defined in the - * https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface[EIP]. - * Used by contracts that will be registered as implementers in the - * {IERC1820Registry}. - */ -interface IERC1820Implementer { - /** - * @dev Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract - * implements `interfaceHash` for `account`. - * - * See {IERC1820Registry-setInterfaceImplementer}. - */ - function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view returns (bytes32); -} diff --git a/src/node_modules/@openzeppelin/contracts/introspection/IERC1820Registry.sol b/src/node_modules/@openzeppelin/contracts/introspection/IERC1820Registry.sol deleted file mode 100644 index 6a7b2b16..00000000 --- a/src/node_modules/@openzeppelin/contracts/introspection/IERC1820Registry.sol +++ /dev/null @@ -1,109 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Interface of the global ERC1820 Registry, as defined in the - * https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register - * implementers for interfaces in this registry, as well as query support. - * - * Implementers may be shared by multiple accounts, and can also implement more - * than a single interface for each account. Contracts can implement interfaces - * for themselves, but externally-owned accounts (EOA) must delegate this to a - * contract. - * - * {IERC165} interfaces can also be queried via the registry. - * - * For an in-depth explanation and source code analysis, see the EIP text. - */ -interface IERC1820Registry { - /** - * @dev Sets `newManager` as the manager for `account`. A manager of an - * account is able to set interface implementers for it. - * - * By default, each account is its own manager. Passing a value of `0x0` in - * `newManager` will reset the manager to this initial state. - * - * Emits a {ManagerChanged} event. - * - * Requirements: - * - * - the caller must be the current manager for `account`. - */ - function setManager(address account, address newManager) external; - - /** - * @dev Returns the manager for `account`. - * - * See {setManager}. - */ - function getManager(address account) external view returns (address); - - /** - * @dev Sets the `implementer` contract as `account`'s implementer for - * `interfaceHash`. - * - * `account` being the zero address is an alias for the caller's address. - * The zero address can also be used in `implementer` to remove an old one. - * - * See {interfaceHash} to learn how these are created. - * - * Emits an {InterfaceImplementerSet} event. - * - * Requirements: - * - * - the caller must be the current manager for `account`. - * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not - * end in 28 zeroes). - * - `implementer` must implement {IERC1820Implementer} and return true when - * queried for support, unless `implementer` is the caller. See - * {IERC1820Implementer-canImplementInterfaceForAddress}. - */ - function setInterfaceImplementer(address account, bytes32 interfaceHash, address implementer) external; - - /** - * @dev Returns the implementer of `interfaceHash` for `account`. If no such - * implementer is registered, returns the zero address. - * - * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28 - * zeroes), `account` will be queried for support of it. - * - * `account` being the zero address is an alias for the caller's address. - */ - function getInterfaceImplementer(address account, bytes32 interfaceHash) external view returns (address); - - /** - * @dev Returns the interface hash for an `interfaceName`, as defined in the - * corresponding - * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP]. - */ - function interfaceHash(string calldata interfaceName) external pure returns (bytes32); - - /** - * @notice Updates the cache with whether the contract implements an ERC165 interface or not. - * @param account Address of the contract for which to update the cache. - * @param interfaceId ERC165 interface for which to update the cache. - */ - function updateERC165Cache(address account, bytes4 interfaceId) external; - - /** - * @notice Checks whether a contract implements an ERC165 interface or not. - * If the result is not cached a direct lookup on the contract address is performed. - * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling - * {updateERC165Cache} with the contract address. - * @param account Address of the contract to check. - * @param interfaceId ERC165 interface to check. - * @return True if `account` implements `interfaceId`, false otherwise. - */ - function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool); - - /** - * @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache. - * @param account Address of the contract to check. - * @param interfaceId ERC165 interface to check. - * @return True if `account` implements `interfaceId`, false otherwise. - */ - function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool); - - event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer); - - event ManagerChanged(address indexed account, address indexed newManager); -} diff --git a/src/node_modules/@openzeppelin/contracts/introspection/README.adoc b/src/node_modules/@openzeppelin/contracts/introspection/README.adoc deleted file mode 100644 index 8b58c9d1..00000000 --- a/src/node_modules/@openzeppelin/contracts/introspection/README.adoc +++ /dev/null @@ -1,28 +0,0 @@ -= Introspection - -This set of interfaces and contracts deal with [type introspection](https://en.wikipedia.org/wiki/Type_introspection) of contracts, that is, examining which functions can be called on them. This is usually referred to as a contract's _interface_. - -Ethereum contracts have no native concept of an interface, so applications must usually simply trust they are not making an incorrect call. For trusted setups this is a non-issue, but often unknown and untrusted third-party addresses need to be interacted with. There may even not be any direct calls to them! (e.g. `ERC20` tokens may be sent to a contract that lacks a way to transfer them out of it, locking them forever). In these cases, a contract _declaring_ its interface can be very helpful in preventing errors. - -There are two main ways to approach this. - -* Locally, where a contract implements `IERC165` and declares an interface, and a second one queries it directly via `ERC165Checker`. -* Globally, where a global and unique registry (`IERC1820Registry`) is used to register implementers of a certain interface (`IERC1820Implementer`). It is then the registry that is queried, which allows for more complex setups, like contracts implementing interfaces for externally-owned accounts. - -Note that, in all cases, accounts simply _declare_ their interfaces, but they are not required to actually implement them. This mechanism can therefore be used to both prevent errors and allow for complex interactions (see `ERC777`), but it must not be relied on for security. - -== Local - -{{IERC165}} - -{{ERC165}} - -{{ERC165Checker}} - -== Global - -{{IERC1820Registry}} - -{{IERC1820Implementer}} - -{{ERC1820Implementer}} diff --git a/src/node_modules/@openzeppelin/contracts/lifecycle/Pausable.sol b/src/node_modules/@openzeppelin/contracts/lifecycle/Pausable.sol deleted file mode 100644 index 77d11e33..00000000 --- a/src/node_modules/@openzeppelin/contracts/lifecycle/Pausable.sol +++ /dev/null @@ -1,74 +0,0 @@ -pragma solidity ^0.5.0; - -import "../GSN/Context.sol"; -import "../access/roles/PauserRole.sol"; - -/** - * @dev Contract module which allows children to implement an emergency stop - * mechanism that can be triggered by an authorized account. - * - * This module is used through inheritance. It will make available the - * modifiers `whenNotPaused` and `whenPaused`, which can be applied to - * the functions of your contract. Note that they will not be pausable by - * simply including this module, only once the modifiers are put in place. - */ -contract Pausable is Context, PauserRole { - /** - * @dev Emitted when the pause is triggered by a pauser (`account`). - */ - event Paused(address account); - - /** - * @dev Emitted when the pause is lifted by a pauser (`account`). - */ - event Unpaused(address account); - - bool private _paused; - - /** - * @dev Initializes the contract in unpaused state. Assigns the Pauser role - * to the deployer. - */ - constructor () internal { - _paused = false; - } - - /** - * @dev Returns true if the contract is paused, and false otherwise. - */ - function paused() public view returns (bool) { - return _paused; - } - - /** - * @dev Modifier to make a function callable only when the contract is not paused. - */ - modifier whenNotPaused() { - require(!_paused, "Pausable: paused"); - _; - } - - /** - * @dev Modifier to make a function callable only when the contract is paused. - */ - modifier whenPaused() { - require(_paused, "Pausable: not paused"); - _; - } - - /** - * @dev Called by a pauser to pause, triggers stopped state. - */ - function pause() public onlyPauser whenNotPaused { - _paused = true; - emit Paused(_msgSender()); - } - - /** - * @dev Called by a pauser to unpause, returns to normal state. - */ - function unpause() public onlyPauser whenPaused { - _paused = false; - emit Unpaused(_msgSender()); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/lifecycle/README.adoc b/src/node_modules/@openzeppelin/contracts/lifecycle/README.adoc deleted file mode 100644 index 52320770..00000000 --- a/src/node_modules/@openzeppelin/contracts/lifecycle/README.adoc +++ /dev/null @@ -1,5 +0,0 @@ -= Lifecycle - -== Pausable - -{{Pausable}} diff --git a/src/node_modules/@openzeppelin/contracts/math/Math.sol b/src/node_modules/@openzeppelin/contracts/math/Math.sol deleted file mode 100644 index 4970a6cc..00000000 --- a/src/node_modules/@openzeppelin/contracts/math/Math.sol +++ /dev/null @@ -1,29 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Standard math utilities missing in the Solidity language. - */ -library Math { - /** - * @dev Returns the largest of two numbers. - */ - function max(uint256 a, uint256 b) internal pure returns (uint256) { - return a >= b ? a : b; - } - - /** - * @dev Returns the smallest of two numbers. - */ - function min(uint256 a, uint256 b) internal pure returns (uint256) { - return a < b ? a : b; - } - - /** - * @dev Returns the average of two numbers. The result is rounded towards - * zero. - */ - function average(uint256 a, uint256 b) internal pure returns (uint256) { - // (a + b) / 2 can overflow, so we distribute - return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/math/README.adoc b/src/node_modules/@openzeppelin/contracts/math/README.adoc deleted file mode 100644 index 99789b94..00000000 --- a/src/node_modules/@openzeppelin/contracts/math/README.adoc +++ /dev/null @@ -1,9 +0,0 @@ -= Math - -These are math-related utilities. - -== Libraries - -{{SafeMath}} - -{{Math}} diff --git a/src/node_modules/@openzeppelin/contracts/math/SafeMath.sol b/src/node_modules/@openzeppelin/contracts/math/SafeMath.sol deleted file mode 100644 index e7091fb2..00000000 --- a/src/node_modules/@openzeppelin/contracts/math/SafeMath.sol +++ /dev/null @@ -1,156 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Wrappers over Solidity's arithmetic operations with added overflow - * checks. - * - * Arithmetic operations in Solidity wrap on overflow. This can easily result - * in bugs, because programmers usually assume that an overflow raises an - * error, which is the standard behavior in high level programming languages. - * `SafeMath` restores this intuition by reverting the transaction when an - * operation overflows. - * - * Using this library instead of the unchecked operations eliminates an entire - * class of bugs, so it's recommended to use it always. - */ -library SafeMath { - /** - * @dev Returns the addition of two unsigned integers, reverting on - * overflow. - * - * Counterpart to Solidity's `+` operator. - * - * Requirements: - * - Addition cannot overflow. - */ - function add(uint256 a, uint256 b) internal pure returns (uint256) { - uint256 c = a + b; - require(c >= a, "SafeMath: addition overflow"); - - return c; - } - - /** - * @dev Returns the subtraction of two unsigned integers, reverting on - * overflow (when the result is negative). - * - * Counterpart to Solidity's `-` operator. - * - * Requirements: - * - Subtraction cannot overflow. - */ - function sub(uint256 a, uint256 b) internal pure returns (uint256) { - return sub(a, b, "SafeMath: subtraction overflow"); - } - - /** - * @dev Returns the subtraction of two unsigned integers, reverting with custom message on - * overflow (when the result is negative). - * - * Counterpart to Solidity's `-` operator. - * - * Requirements: - * - Subtraction cannot overflow. - * - * _Available since v2.4.0._ - */ - function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - require(b <= a, errorMessage); - uint256 c = a - b; - - return c; - } - - /** - * @dev Returns the multiplication of two unsigned integers, reverting on - * overflow. - * - * Counterpart to Solidity's `*` operator. - * - * Requirements: - * - Multiplication cannot overflow. - */ - function mul(uint256 a, uint256 b) internal pure returns (uint256) { - // Gas optimization: this is cheaper than requiring 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 - if (a == 0) { - return 0; - } - - uint256 c = a * b; - require(c / a == b, "SafeMath: multiplication overflow"); - - return c; - } - - /** - * @dev Returns the integer division of two unsigned integers. Reverts on - * division by zero. The result is rounded towards zero. - * - * Counterpart to Solidity's `/` operator. Note: this function uses a - * `revert` opcode (which leaves remaining gas untouched) while Solidity - * uses an invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - */ - function div(uint256 a, uint256 b) internal pure returns (uint256) { - return div(a, b, "SafeMath: division by zero"); - } - - /** - * @dev Returns the integer division of two unsigned integers. Reverts with custom message on - * division by zero. The result is rounded towards zero. - * - * Counterpart to Solidity's `/` operator. Note: this function uses a - * `revert` opcode (which leaves remaining gas untouched) while Solidity - * uses an invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - * - * _Available since v2.4.0._ - */ - function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - // Solidity only automatically asserts when dividing by 0 - require(b > 0, errorMessage); - uint256 c = a / b; - // assert(a == b * c + a % b); // There is no case in which this doesn't hold - - return c; - } - - /** - * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), - * Reverts when dividing by zero. - * - * Counterpart to Solidity's `%` operator. This function uses a `revert` - * opcode (which leaves remaining gas untouched) while Solidity uses an - * invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - */ - function mod(uint256 a, uint256 b) internal pure returns (uint256) { - return mod(a, b, "SafeMath: modulo by zero"); - } - - /** - * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), - * Reverts with custom message when dividing by zero. - * - * Counterpart to Solidity's `%` operator. This function uses a `revert` - * opcode (which leaves remaining gas untouched) while Solidity uses an - * invalid opcode to revert (consuming all remaining gas). - * - * Requirements: - * - The divisor cannot be zero. - * - * _Available since v2.4.0._ - */ - function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { - require(b != 0, errorMessage); - return a % b; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/ownership/Ownable.sol b/src/node_modules/@openzeppelin/contracts/ownership/Ownable.sol deleted file mode 100644 index cd9c061d..00000000 --- a/src/node_modules/@openzeppelin/contracts/ownership/Ownable.sol +++ /dev/null @@ -1,77 +0,0 @@ -pragma solidity ^0.5.0; - -import "../GSN/Context.sol"; -/** - * @dev Contract module which provides a basic access control mechanism, where - * there is an account (an owner) that can be granted exclusive access to - * specific functions. - * - * This module is used through inheritance. It will make available the modifier - * `onlyOwner`, which can be applied to your functions to restrict their use to - * the owner. - */ -contract Ownable is Context { - address private _owner; - - event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); - - /** - * @dev Initializes the contract setting the deployer as the initial owner. - */ - constructor () internal { - address msgSender = _msgSender(); - _owner = msgSender; - emit OwnershipTransferred(address(0), msgSender); - } - - /** - * @dev Returns the address of the current owner. - */ - function owner() public view returns (address) { - return _owner; - } - - /** - * @dev Throws if called by any account other than the owner. - */ - modifier onlyOwner() { - require(isOwner(), "Ownable: caller is not the owner"); - _; - } - - /** - * @dev Returns true if the caller is the current owner. - */ - function isOwner() public view returns (bool) { - return _msgSender() == _owner; - } - - /** - * @dev Leaves the contract without owner. It will not be possible to call - * `onlyOwner` functions anymore. Can only be called by the current owner. - * - * NOTE: Renouncing ownership will leave the contract without an owner, - * thereby removing any functionality that is only available to the owner. - */ - function renounceOwnership() public onlyOwner { - emit OwnershipTransferred(_owner, address(0)); - _owner = address(0); - } - - /** - * @dev Transfers ownership of the contract to a new account (`newOwner`). - * Can only be called by the current owner. - */ - function transferOwnership(address newOwner) public onlyOwner { - _transferOwnership(newOwner); - } - - /** - * @dev Transfers ownership of the contract to a new account (`newOwner`). - */ - function _transferOwnership(address newOwner) internal { - require(newOwner != address(0), "Ownable: new owner is the zero address"); - emit OwnershipTransferred(_owner, newOwner); - _owner = newOwner; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/ownership/README.adoc b/src/node_modules/@openzeppelin/contracts/ownership/README.adoc deleted file mode 100644 index f0b7d003..00000000 --- a/src/node_modules/@openzeppelin/contracts/ownership/README.adoc +++ /dev/null @@ -1,11 +0,0 @@ -= Ownership - -Contract modules for simple authorization and access control mechanisms. - -TIP: For more complex needs see xref:access.adoc[Access]. - -== Contracts - -{{Ownable}} - -{{Secondary}} diff --git a/src/node_modules/@openzeppelin/contracts/ownership/Secondary.sol b/src/node_modules/@openzeppelin/contracts/ownership/Secondary.sol deleted file mode 100644 index cc474d43..00000000 --- a/src/node_modules/@openzeppelin/contracts/ownership/Secondary.sol +++ /dev/null @@ -1,50 +0,0 @@ -pragma solidity ^0.5.0; - -import "../GSN/Context.sol"; -/** - * @dev A Secondary contract can only be used by its primary account (the one that created it). - */ -contract Secondary is Context { - address private _primary; - - /** - * @dev Emitted when the primary contract changes. - */ - event PrimaryTransferred( - address recipient - ); - - /** - * @dev Sets the primary account to the one that is creating the Secondary contract. - */ - constructor () internal { - address msgSender = _msgSender(); - _primary = msgSender; - emit PrimaryTransferred(msgSender); - } - - /** - * @dev Reverts if called from any account other than the primary. - */ - modifier onlyPrimary() { - require(_msgSender() == _primary, "Secondary: caller is not the primary account"); - _; - } - - /** - * @return the address of the primary. - */ - function primary() public view returns (address) { - return _primary; - } - - /** - * @dev Transfers contract to a new primary. - * @param recipient The address of new primary. - */ - function transferPrimary(address recipient) public onlyPrimary { - require(recipient != address(0), "Secondary: new primary is the zero address"); - _primary = recipient; - emit PrimaryTransferred(recipient); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/package.json b/src/node_modules/@openzeppelin/contracts/package.json deleted file mode 100644 index 17f6d789..00000000 --- a/src/node_modules/@openzeppelin/contracts/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "@openzeppelin/contracts", - "version": "2.5.1", - "description": "Secure Smart Contract library for Solidity", - "files": [ - "**/*.sol", - "/build/contracts/*.json", - "!/mocks", - "!/examples" - ], - "scripts": { - "prepare": "bash ../scripts/prepare-contracts-package.sh" - }, - "repository": { - "type": "git", - "url": "https://github.com/OpenZeppelin/openzeppelin-contracts.git" - }, - "keywords": [ - "solidity", - "ethereum", - "smart", - "contracts", - "security", - "zeppelin" - ], - "author": "OpenZeppelin Community ", - "license": "MIT", - "bugs": { - "url": "https://github.com/OpenZeppelin/openzeppelin-contracts/issues" - }, - "homepage": "https://openzeppelin.com/contracts/" -} diff --git a/src/node_modules/@openzeppelin/contracts/payment/PaymentSplitter.sol b/src/node_modules/@openzeppelin/contracts/payment/PaymentSplitter.sol deleted file mode 100644 index 561af437..00000000 --- a/src/node_modules/@openzeppelin/contracts/payment/PaymentSplitter.sol +++ /dev/null @@ -1,132 +0,0 @@ -pragma solidity ^0.5.0; - -import "../GSN/Context.sol"; -import "../math/SafeMath.sol"; - -/** - * @title PaymentSplitter - * @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware - * that the Ether will be split in this way, since it is handled transparently by the contract. - * - * The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each - * account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim - * an amount proportional to the percentage of total shares they were assigned. - * - * `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the - * accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release} - * function. - */ -contract PaymentSplitter is Context { - using SafeMath for uint256; - - event PayeeAdded(address account, uint256 shares); - event PaymentReleased(address to, uint256 amount); - event PaymentReceived(address from, uint256 amount); - - uint256 private _totalShares; - uint256 private _totalReleased; - - mapping(address => uint256) private _shares; - mapping(address => uint256) private _released; - address[] private _payees; - - /** - * @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at - * the matching position in the `shares` array. - * - * All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no - * duplicates in `payees`. - */ - constructor (address[] memory payees, uint256[] memory shares) public payable { - // solhint-disable-next-line max-line-length - require(payees.length == shares.length, "PaymentSplitter: payees and shares length mismatch"); - require(payees.length > 0, "PaymentSplitter: no payees"); - - for (uint256 i = 0; i < payees.length; i++) { - _addPayee(payees[i], shares[i]); - } - } - - /** - * @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully - * reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the - * reliability of the events, and not the actual splitting of Ether. - * - * To learn more about this see the Solidity documentation for - * https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback - * functions]. - */ - function () external payable { - emit PaymentReceived(_msgSender(), msg.value); - } - - /** - * @dev Getter for the total shares held by payees. - */ - function totalShares() public view returns (uint256) { - return _totalShares; - } - - /** - * @dev Getter for the total amount of Ether already released. - */ - function totalReleased() public view returns (uint256) { - return _totalReleased; - } - - /** - * @dev Getter for the amount of shares held by an account. - */ - function shares(address account) public view returns (uint256) { - return _shares[account]; - } - - /** - * @dev Getter for the amount of Ether already released to a payee. - */ - function released(address account) public view returns (uint256) { - return _released[account]; - } - - /** - * @dev Getter for the address of the payee number `index`. - */ - function payee(uint256 index) public view returns (address) { - return _payees[index]; - } - - /** - * @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the - * total shares and their previous withdrawals. - */ - function release(address payable account) public { - require(_shares[account] > 0, "PaymentSplitter: account has no shares"); - - uint256 totalReceived = address(this).balance.add(_totalReleased); - uint256 payment = totalReceived.mul(_shares[account]).div(_totalShares).sub(_released[account]); - - require(payment != 0, "PaymentSplitter: account is not due payment"); - - _released[account] = _released[account].add(payment); - _totalReleased = _totalReleased.add(payment); - - account.transfer(payment); - emit PaymentReleased(account, payment); - } - - /** - * @dev Add a new payee to the contract. - * @param account The address of the payee to add. - * @param shares_ The number of shares owned by the payee. - */ - function _addPayee(address account, uint256 shares_) private { - require(account != address(0), "PaymentSplitter: account is the zero address"); - require(shares_ > 0, "PaymentSplitter: shares are 0"); - require(_shares[account] == 0, "PaymentSplitter: account already has shares"); - - _payees.push(account); - _shares[account] = shares_; - _totalShares = _totalShares.add(shares_); - emit PayeeAdded(account, shares_); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/payment/PullPayment.sol b/src/node_modules/@openzeppelin/contracts/payment/PullPayment.sol deleted file mode 100644 index 60144584..00000000 --- a/src/node_modules/@openzeppelin/contracts/payment/PullPayment.sol +++ /dev/null @@ -1,81 +0,0 @@ -pragma solidity ^0.5.0; - -import "./escrow/Escrow.sol"; - -/** - * @dev Simple implementation of a - * https://consensys.github.io/smart-contract-best-practices/recommendations/#favor-pull-over-push-for-external-calls[pull-payment] - * strategy, where the paying contract doesn't interact directly with the - * receiver account, which must withdraw its payments itself. - * - * Pull-payments are often considered the best practice when it comes to sending - * Ether, security-wise. It prevents recipients from blocking execution, and - * eliminates reentrancy concerns. - * - * TIP: If you would like to learn more about reentrancy and alternative ways - * to protect against it, check out our blog post - * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. - * - * To use, derive from the `PullPayment` contract, and use {_asyncTransfer} - * instead of Solidity's `transfer` function. Payees can query their due - * payments with {payments}, and retrieve them with {withdrawPayments}. - */ -contract PullPayment { - Escrow private _escrow; - - constructor () internal { - _escrow = new Escrow(); - } - - /** - * @dev Withdraw accumulated payments. - * - * Note that _any_ account can call this function, not just the `payee`. - * This means that contracts unaware of the `PullPayment` protocol can still - * receive funds this way, by having a separate account call - * {withdrawPayments}. - * - * NOTE: This function has been deprecated, use {withdrawPaymentsWithGas} - * instead. Calling contracts with fixed gas limits is an anti-pattern and - * may break contract interactions in network upgrades (hardforks). - * https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more.] - * - * @param payee Whose payments will be withdrawn. - */ - function withdrawPayments(address payable payee) public { - _escrow.withdraw(payee); - } - - /** - * @dev Same as {withdrawPayments}, but forwarding all gas to the recipient. - * - * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities. - * Make sure you trust the recipient, or are either following the - * checks-effects-interactions pattern or using {ReentrancyGuard}. - * - * _Available since v2.4.0._ - */ - function withdrawPaymentsWithGas(address payable payee) external { - _escrow.withdrawWithGas(payee); - } - - /** - * @dev Returns the payments owed to an address. - * @param dest The creditor's address. - */ - function payments(address dest) public view returns (uint256) { - return _escrow.depositsOf(dest); - } - - /** - * @dev Called by the payer to store the sent amount as credit to be pulled. - * Funds sent in this way are stored in an intermediate {Escrow} contract, so - * there is no danger of them being spent before withdrawal. - * - * @param dest The destination address of the funds. - * @param amount The amount to transfer. - */ - function _asyncTransfer(address dest, uint256 amount) internal { - _escrow.deposit.value(amount)(dest); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/payment/README.adoc b/src/node_modules/@openzeppelin/contracts/payment/README.adoc deleted file mode 100644 index 716addbd..00000000 --- a/src/node_modules/@openzeppelin/contracts/payment/README.adoc +++ /dev/null @@ -1,17 +0,0 @@ -= Payment - -NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned! - -== Utilities - -{{PaymentSplitter}} - -{{PullPayment}} - -== Escrow - -{{Escrow}} - -{{ConditionalEscrow}} - -{{RefundEscrow}} diff --git a/src/node_modules/@openzeppelin/contracts/payment/escrow/ConditionalEscrow.sol b/src/node_modules/@openzeppelin/contracts/payment/escrow/ConditionalEscrow.sol deleted file mode 100644 index d1f8e1eb..00000000 --- a/src/node_modules/@openzeppelin/contracts/payment/escrow/ConditionalEscrow.sol +++ /dev/null @@ -1,22 +0,0 @@ -pragma solidity ^0.5.0; - -import "./Escrow.sol"; - -/** - * @title ConditionalEscrow - * @dev Base abstract escrow to only allow withdrawal if a condition is met. - * @dev Intended usage: See {Escrow}. Same usage guidelines apply here. - */ -contract ConditionalEscrow is Escrow { - /** - * @dev Returns whether an address is allowed to withdraw their funds. To be - * implemented by derived contracts. - * @param payee The destination address of the funds. - */ - function withdrawalAllowed(address payee) public view returns (bool); - - function withdraw(address payable payee) public { - require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw"); - super.withdraw(payee); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/payment/escrow/Escrow.sol b/src/node_modules/@openzeppelin/contracts/payment/escrow/Escrow.sol deleted file mode 100644 index 01ef2cde..00000000 --- a/src/node_modules/@openzeppelin/contracts/payment/escrow/Escrow.sol +++ /dev/null @@ -1,83 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../math/SafeMath.sol"; -import "../../ownership/Secondary.sol"; -import "../../utils/Address.sol"; - - /** - * @title Escrow - * @dev Base escrow contract, holds funds designated for a payee until they - * withdraw them. - * - * Intended usage: This contract (and derived escrow contracts) should be a - * standalone contract, that only interacts with the contract that instantiated - * it. That way, it is guaranteed that all Ether will be handled according to - * the `Escrow` rules, and there is no need to check for payable functions or - * transfers in the inheritance tree. The contract that uses the escrow as its - * payment method should be its primary, and provide public methods redirecting - * to the escrow's deposit and withdraw. - */ -contract Escrow is Secondary { - using SafeMath for uint256; - using Address for address payable; - - event Deposited(address indexed payee, uint256 weiAmount); - event Withdrawn(address indexed payee, uint256 weiAmount); - - mapping(address => uint256) private _deposits; - - function depositsOf(address payee) public view returns (uint256) { - return _deposits[payee]; - } - - /** - * @dev Stores the sent amount as credit to be withdrawn. - * @param payee The destination address of the funds. - */ - function deposit(address payee) public onlyPrimary payable { - uint256 amount = msg.value; - _deposits[payee] = _deposits[payee].add(amount); - - emit Deposited(payee, amount); - } - - /** - * @dev Withdraw accumulated balance for a payee, forwarding 2300 gas (a - * Solidity `transfer`). - * - * NOTE: This function has been deprecated, use {withdrawWithGas} instead. - * Calling contracts with fixed-gas limits is an anti-pattern and may break - * contract interactions in network upgrades (hardforks). - * https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more.] - * - * @param payee The address whose funds will be withdrawn and transferred to. - */ - function withdraw(address payable payee) public onlyPrimary { - uint256 payment = _deposits[payee]; - - _deposits[payee] = 0; - - payee.transfer(payment); - - emit Withdrawn(payee, payment); - } - - /** - * @dev Same as {withdraw}, but forwarding all gas to the recipient. - * - * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities. - * Make sure you trust the recipient, or are either following the - * checks-effects-interactions pattern or using {ReentrancyGuard}. - * - * _Available since v2.4.0._ - */ - function withdrawWithGas(address payable payee) public onlyPrimary { - uint256 payment = _deposits[payee]; - - _deposits[payee] = 0; - - payee.sendValue(payment); - - emit Withdrawn(payee, payment); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/payment/escrow/RefundEscrow.sol b/src/node_modules/@openzeppelin/contracts/payment/escrow/RefundEscrow.sol deleted file mode 100644 index 9eb164cb..00000000 --- a/src/node_modules/@openzeppelin/contracts/payment/escrow/RefundEscrow.sol +++ /dev/null @@ -1,92 +0,0 @@ -pragma solidity ^0.5.0; - -import "./ConditionalEscrow.sol"; - -/** - * @title RefundEscrow - * @dev Escrow that holds funds for a beneficiary, deposited from multiple - * parties. - * @dev Intended usage: See {Escrow}. Same usage guidelines apply here. - * @dev The primary account (that is, the contract that instantiates this - * contract) may deposit, close the deposit period, and allow for either - * withdrawal by the beneficiary, or refunds to the depositors. All interactions - * with `RefundEscrow` will be made through the primary contract. See the - * `RefundableCrowdsale` contract for an example of `RefundEscrow`’s use. - */ -contract RefundEscrow is ConditionalEscrow { - enum State { Active, Refunding, Closed } - - event RefundsClosed(); - event RefundsEnabled(); - - State private _state; - address payable private _beneficiary; - - /** - * @dev Constructor. - * @param beneficiary The beneficiary of the deposits. - */ - constructor (address payable beneficiary) public { - require(beneficiary != address(0), "RefundEscrow: beneficiary is the zero address"); - _beneficiary = beneficiary; - _state = State.Active; - } - - /** - * @return The current state of the escrow. - */ - function state() public view returns (State) { - return _state; - } - - /** - * @return The beneficiary of the escrow. - */ - function beneficiary() public view returns (address) { - return _beneficiary; - } - - /** - * @dev Stores funds that may later be refunded. - * @param refundee The address funds will be sent to if a refund occurs. - */ - function deposit(address refundee) public payable { - require(_state == State.Active, "RefundEscrow: can only deposit while active"); - super.deposit(refundee); - } - - /** - * @dev Allows for the beneficiary to withdraw their funds, rejecting - * further deposits. - */ - function close() public onlyPrimary { - require(_state == State.Active, "RefundEscrow: can only close while active"); - _state = State.Closed; - emit RefundsClosed(); - } - - /** - * @dev Allows for refunds to take place, rejecting further deposits. - */ - function enableRefunds() public onlyPrimary { - require(_state == State.Active, "RefundEscrow: can only enable refunds while active"); - _state = State.Refunding; - emit RefundsEnabled(); - } - - /** - * @dev Withdraws the beneficiary's funds. - */ - function beneficiaryWithdraw() public { - require(_state == State.Closed, "RefundEscrow: beneficiary can only withdraw while closed"); - _beneficiary.transfer(address(this).balance); - } - - /** - * @dev Returns whether refundees can withdraw their deposits (be refunded). The overridden function receives a - * 'payee' argument, but we ignore it here since the condition is global, not per-payee. - */ - function withdrawalAllowed(address) public view returns (bool) { - return _state == State.Refunding; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol b/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol deleted file mode 100644 index 0846fb2c..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol +++ /dev/null @@ -1,230 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "./IERC20.sol"; -import "../../math/SafeMath.sol"; - -/** - * @dev Implementation of the {IERC20} interface. - * - * This implementation is agnostic to the way tokens are created. This means - * that a supply mechanism has to be added in a derived contract using {_mint}. - * For a generic mechanism see {ERC20Mintable}. - * - * TIP: For a detailed writeup see our guide - * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How - * to implement supply mechanisms]. - * - * We have followed general OpenZeppelin guidelines: functions revert instead - * of returning `false` on failure. This behavior is nonetheless conventional - * and does not conflict with the expectations of ERC20 applications. - * - * Additionally, an {Approval} event is emitted on calls to {transferFrom}. - * This allows applications to reconstruct the allowance for all accounts just - * by listening to said events. Other implementations of the EIP may not emit - * these events, as it isn't required by the specification. - * - * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} - * functions have been added to mitigate the well-known issues around setting - * allowances. See {IERC20-approve}. - */ -contract ERC20 is Context, IERC20 { - using SafeMath for uint256; - - mapping (address => uint256) private _balances; - - mapping (address => mapping (address => uint256)) private _allowances; - - uint256 private _totalSupply; - - /** - * @dev See {IERC20-totalSupply}. - */ - function totalSupply() public view returns (uint256) { - return _totalSupply; - } - - /** - * @dev See {IERC20-balanceOf}. - */ - function balanceOf(address account) public view returns (uint256) { - return _balances[account]; - } - - /** - * @dev See {IERC20-transfer}. - * - * Requirements: - * - * - `recipient` cannot be the zero address. - * - the caller must have a balance of at least `amount`. - */ - function transfer(address recipient, uint256 amount) public returns (bool) { - _transfer(_msgSender(), recipient, amount); - return true; - } - - /** - * @dev See {IERC20-allowance}. - */ - function allowance(address owner, address spender) public view returns (uint256) { - return _allowances[owner][spender]; - } - - /** - * @dev See {IERC20-approve}. - * - * Requirements: - * - * - `spender` cannot be the zero address. - */ - function approve(address spender, uint256 amount) public returns (bool) { - _approve(_msgSender(), spender, amount); - return true; - } - - /** - * @dev See {IERC20-transferFrom}. - * - * Emits an {Approval} event indicating the updated allowance. This is not - * required by the EIP. See the note at the beginning of {ERC20}; - * - * Requirements: - * - `sender` and `recipient` cannot be the zero address. - * - `sender` must have a balance of at least `amount`. - * - the caller must have allowance for `sender`'s tokens of at least - * `amount`. - */ - function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) { - _transfer(sender, recipient, amount); - _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); - return true; - } - - /** - * @dev Atomically increases the allowance granted to `spender` by the caller. - * - * This is an alternative to {approve} that can be used as a mitigation for - * problems described in {IERC20-approve}. - * - * Emits an {Approval} event indicating the updated allowance. - * - * Requirements: - * - * - `spender` cannot be the zero address. - */ - function increaseAllowance(address spender, uint256 addedValue) public returns (bool) { - _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); - return true; - } - - /** - * @dev Atomically decreases the allowance granted to `spender` by the caller. - * - * This is an alternative to {approve} that can be used as a mitigation for - * problems described in {IERC20-approve}. - * - * Emits an {Approval} event indicating the updated allowance. - * - * Requirements: - * - * - `spender` cannot be the zero address. - * - `spender` must have allowance for the caller of at least - * `subtractedValue`. - */ - function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) { - _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); - return true; - } - - /** - * @dev Moves tokens `amount` from `sender` to `recipient`. - * - * This is internal function is equivalent to {transfer}, and can be used to - * e.g. implement automatic token fees, slashing mechanisms, etc. - * - * Emits a {Transfer} event. - * - * Requirements: - * - * - `sender` cannot be the zero address. - * - `recipient` cannot be the zero address. - * - `sender` must have a balance of at least `amount`. - */ - function _transfer(address sender, address recipient, uint256 amount) internal { - require(sender != address(0), "ERC20: transfer from the zero address"); - require(recipient != address(0), "ERC20: transfer to the zero address"); - - _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); - _balances[recipient] = _balances[recipient].add(amount); - emit Transfer(sender, recipient, amount); - } - - /** @dev Creates `amount` tokens and assigns them to `account`, increasing - * the total supply. - * - * Emits a {Transfer} event with `from` set to the zero address. - * - * Requirements - * - * - `to` cannot be the zero address. - */ - function _mint(address account, uint256 amount) internal { - require(account != address(0), "ERC20: mint to the zero address"); - - _totalSupply = _totalSupply.add(amount); - _balances[account] = _balances[account].add(amount); - emit Transfer(address(0), account, amount); - } - - /** - * @dev Destroys `amount` tokens from `account`, reducing the - * total supply. - * - * Emits a {Transfer} event with `to` set to the zero address. - * - * Requirements - * - * - `account` cannot be the zero address. - * - `account` must have at least `amount` tokens. - */ - function _burn(address account, uint256 amount) internal { - require(account != address(0), "ERC20: burn from the zero address"); - - _balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance"); - _totalSupply = _totalSupply.sub(amount); - emit Transfer(account, address(0), amount); - } - - /** - * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. - * - * This is internal function is equivalent to `approve`, and can be used to - * e.g. set automatic allowances for certain subsystems, etc. - * - * Emits an {Approval} event. - * - * Requirements: - * - * - `owner` cannot be the zero address. - * - `spender` cannot be the zero address. - */ - function _approve(address owner, address spender, uint256 amount) internal { - require(owner != address(0), "ERC20: approve from the zero address"); - require(spender != address(0), "ERC20: approve to the zero address"); - - _allowances[owner][spender] = amount; - emit Approval(owner, spender, amount); - } - - /** - * @dev Destroys `amount` tokens from `account`.`amount` is then deducted - * from the caller's allowance. - * - * See {_burn} and {_approve}. - */ - function _burnFrom(address account, uint256 amount) internal { - _burn(account, amount); - _approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance")); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol b/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol deleted file mode 100644 index e58b72b2..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol +++ /dev/null @@ -1,27 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "./ERC20.sol"; - -/** - * @dev Extension of {ERC20} that allows token holders to destroy both their own - * tokens and those that they have an allowance for, in a way that can be - * recognized off-chain (via event analysis). - */ -contract ERC20Burnable is Context, ERC20 { - /** - * @dev Destroys `amount` tokens from the caller. - * - * See {ERC20-_burn}. - */ - function burn(uint256 amount) public { - _burn(_msgSender(), amount); - } - - /** - * @dev See {ERC20-_burnFrom}. - */ - function burnFrom(address account, uint256 amount) public { - _burnFrom(account, amount); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Capped.sol b/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Capped.sol deleted file mode 100644 index 17efca0c..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Capped.sol +++ /dev/null @@ -1,38 +0,0 @@ -pragma solidity ^0.5.0; - -import "./ERC20Mintable.sol"; - -/** - * @dev Extension of {ERC20Mintable} that adds a cap to the supply of tokens. - */ -contract ERC20Capped is ERC20Mintable { - uint256 private _cap; - - /** - * @dev Sets the value of the `cap`. This value is immutable, it can only be - * set once during construction. - */ - constructor (uint256 cap) public { - require(cap > 0, "ERC20Capped: cap is 0"); - _cap = cap; - } - - /** - * @dev Returns the cap on the token's total supply. - */ - function cap() public view returns (uint256) { - return _cap; - } - - /** - * @dev See {ERC20Mintable-mint}. - * - * Requirements: - * - * - `value` must not cause the total supply to go over the cap. - */ - function _mint(address account, uint256 value) internal { - require(totalSupply().add(value) <= _cap, "ERC20Capped: cap exceeded"); - super._mint(account, value); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol b/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol deleted file mode 100644 index 61d4ab92..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Detailed.sol +++ /dev/null @@ -1,54 +0,0 @@ -pragma solidity ^0.5.0; - -import "./IERC20.sol"; - -/** - * @dev Optional functions from the ERC20 standard. - */ -contract ERC20Detailed is IERC20 { - string private _name; - string private _symbol; - uint8 private _decimals; - - /** - * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of - * these values are immutable: they can only be set once during - * construction. - */ - constructor (string memory name, string memory symbol, uint8 decimals) public { - _name = name; - _symbol = symbol; - _decimals = decimals; - } - - /** - * @dev Returns the name of the token. - */ - function name() public view returns (string memory) { - return _name; - } - - /** - * @dev Returns the symbol of the token, usually a shorter version of the - * name. - */ - function symbol() public view returns (string memory) { - return _symbol; - } - - /** - * @dev Returns the number of decimals used to get its user representation. - * For example, if `decimals` equals `2`, a balance of `505` tokens should - * be displayed to a user as `5,05` (`505 / 10 ** 2`). - * - * Tokens usually opt for a value of 18, imitating the relationship between - * Ether and Wei. - * - * NOTE: This information is only used for _display_ purposes: it in - * no way affects any of the arithmetic of the contract, including - * {IERC20-balanceOf} and {IERC20-transfer}. - */ - function decimals() public view returns (uint8) { - return _decimals; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol b/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol deleted file mode 100644 index d2fd5b73..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Mintable.sol +++ /dev/null @@ -1,24 +0,0 @@ -pragma solidity ^0.5.0; - -import "./ERC20.sol"; -import "../../access/roles/MinterRole.sol"; - -/** - * @dev Extension of {ERC20} that adds a set of accounts with the {MinterRole}, - * which have permission to mint (create) new tokens as they see fit. - * - * At construction, the deployer of the contract is the only minter. - */ -contract ERC20Mintable is ERC20, MinterRole { - /** - * @dev See {ERC20-_mint}. - * - * Requirements: - * - * - the caller must have the {MinterRole}. - */ - function mint(address account, uint256 amount) public onlyMinter returns (bool) { - _mint(account, amount); - return true; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol b/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol deleted file mode 100644 index 5e8641eb..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC20/ERC20Pausable.sol +++ /dev/null @@ -1,34 +0,0 @@ -pragma solidity ^0.5.0; - -import "./ERC20.sol"; -import "../../lifecycle/Pausable.sol"; - -/** - * @title Pausable token - * @dev ERC20 with pausable transfers and allowances. - * - * Useful if you want to stop trades until the end of a crowdsale, or have - * an emergency switch for freezing all token transfers in the event of a large - * bug. - */ -contract ERC20Pausable is ERC20, Pausable { - function transfer(address to, uint256 value) public whenNotPaused returns (bool) { - return super.transfer(to, value); - } - - function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) { - return super.transferFrom(from, to, value); - } - - function approve(address spender, uint256 value) public whenNotPaused returns (bool) { - return super.approve(spender, value); - } - - function increaseAllowance(address spender, uint256 addedValue) public whenNotPaused returns (bool) { - return super.increaseAllowance(spender, addedValue); - } - - function decreaseAllowance(address spender, uint256 subtractedValue) public whenNotPaused returns (bool) { - return super.decreaseAllowance(spender, subtractedValue); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol b/src/node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol deleted file mode 100644 index bf5245ff..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC20/IERC20.sol +++ /dev/null @@ -1,76 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Interface of the ERC20 standard as defined in the EIP. Does not include - * the optional functions; to access them see {ERC20Detailed}. - */ -interface IERC20 { - /** - * @dev Returns the amount of tokens in existence. - */ - function totalSupply() external view returns (uint256); - - /** - * @dev Returns the amount of tokens owned by `account`. - */ - function balanceOf(address account) external view returns (uint256); - - /** - * @dev Moves `amount` tokens from the caller's account to `recipient`. - * - * Returns a boolean value indicating whether the operation succeeded. - * - * Emits a {Transfer} event. - */ - function transfer(address recipient, uint256 amount) external returns (bool); - - /** - * @dev Returns the remaining number of tokens that `spender` will be - * allowed to spend on behalf of `owner` through {transferFrom}. This is - * zero by default. - * - * This value changes when {approve} or {transferFrom} are called. - */ - function allowance(address owner, address spender) external view returns (uint256); - - /** - * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. - * - * Returns a boolean value indicating whether the operation succeeded. - * - * IMPORTANT: Beware that changing an allowance with this method brings the risk - * that someone may use both the old and the new allowance by unfortunate - * transaction ordering. One possible solution to mitigate this race - * condition is to first reduce the spender's allowance to 0 and set the - * desired value afterwards: - * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - * - * Emits an {Approval} event. - */ - function approve(address spender, uint256 amount) external returns (bool); - - /** - * @dev Moves `amount` tokens from `sender` to `recipient` using the - * allowance mechanism. `amount` is then deducted from the caller's - * allowance. - * - * Returns a boolean value indicating whether the operation succeeded. - * - * Emits a {Transfer} event. - */ - function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); - - /** - * @dev Emitted when `value` tokens are moved from one account (`from`) to - * another (`to`). - * - * Note that `value` may be zero. - */ - event Transfer(address indexed from, address indexed to, uint256 value); - - /** - * @dev Emitted when the allowance of a `spender` for an `owner` is set by - * a call to {approve}. `value` is the new allowance. - */ - event Approval(address indexed owner, address indexed spender, uint256 value); -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC20/README.adoc b/src/node_modules/@openzeppelin/contracts/token/ERC20/README.adoc deleted file mode 100644 index 4524a2d0..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC20/README.adoc +++ /dev/null @@ -1,50 +0,0 @@ -= ERC 20 - -This set of interfaces, contracts, and utilities are all related to the https://eips.ethereum.org/EIPS/eip-20[ERC20 Token Standard]. - -TIP: For an overview of ERC20 tokens and a walkthrough on how to create a token contract read our xref:ROOT:tokens.adoc#ERC20[ERC20 guide]. - -There a few core contracts that implement the behavior specified in the EIP: - -* {IERC20}: the interface all ERC20 implementations should conform to -* {ERC20}: the base implementation of the ERC20 interface -* {ERC20Detailed}: includes the <>, - <> and <> - optional standard extension to the base interface - -Additionally there are multiple custom extensions, including: - -* designation of addresses that can create token supply ({ERC20Mintable}), with an optional maximum cap ({ERC20Capped}) -* destruction of own tokens ({ERC20Burnable}) -* designation of addresses that can pause token operations for all users ({ERC20Pausable}). - -Finally, there are some utilities to interact with ERC20 contracts in various ways. - -* {SafeERC20} is a wrapper around the interface that eliminates the need to handle boolean return values. -* {TokenTimelock} can hold tokens for a beneficiary until a specified time. - -NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned! - -== Core - -{{IERC20}} - -{{ERC20}} - -{{ERC20Detailed}} - -== Extensions - -{{ERC20Mintable}} - -{{ERC20Burnable}} - -{{ERC20Pausable}} - -{{ERC20Capped}} - -== Utilities - -{{SafeERC20}} - -{{TokenTimelock}} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC20/SafeERC20.sol b/src/node_modules/@openzeppelin/contracts/token/ERC20/SafeERC20.sol deleted file mode 100644 index 8cbc7b2f..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC20/SafeERC20.sol +++ /dev/null @@ -1,75 +0,0 @@ -pragma solidity ^0.5.0; - -import "./IERC20.sol"; -import "../../math/SafeMath.sol"; -import "../../utils/Address.sol"; - -/** - * @title SafeERC20 - * @dev Wrappers around ERC20 operations that throw on failure (when the token - * contract returns false). Tokens that return no value (and instead revert or - * throw on failure) are also supported, non-reverting calls are assumed to be - * successful. - * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract, - * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. - */ -library SafeERC20 { - using SafeMath for uint256; - using Address for address; - - function safeTransfer(IERC20 token, address to, uint256 value) internal { - callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); - } - - function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { - callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); - } - - function safeApprove(IERC20 token, address spender, uint256 value) internal { - // safeApprove should only be called when setting an initial allowance, - // or when resetting it to zero. To increase and decrease it, use - // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' - // solhint-disable-next-line max-line-length - require((value == 0) || (token.allowance(address(this), spender) == 0), - "SafeERC20: approve from non-zero to non-zero allowance" - ); - callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); - } - - function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { - uint256 newAllowance = token.allowance(address(this), spender).add(value); - callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); - } - - function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { - uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); - callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); - } - - /** - * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement - * on the return value: the return value is optional (but if data is returned, it must not be false). - * @param token The token targeted by the call. - * @param data The call data (encoded using abi.encode or one of its variants). - */ - function callOptionalReturn(IERC20 token, bytes memory data) private { - // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since - // we're implementing it ourselves. - - // A Solidity high level call has three parts: - // 1. The target address is checked to verify it contains contract code - // 2. The call itself is made, and success asserted - // 3. The return value is decoded, which in turn checks the size of the returned data. - // solhint-disable-next-line max-line-length - require(address(token).isContract(), "SafeERC20: call to non-contract"); - - // solhint-disable-next-line avoid-low-level-calls - (bool success, bytes memory returndata) = address(token).call(data); - require(success, "SafeERC20: low-level call failed"); - - if (returndata.length > 0) { // Return data is optional - // solhint-disable-next-line max-line-length - require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); - } - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC20/TokenTimelock.sol b/src/node_modules/@openzeppelin/contracts/token/ERC20/TokenTimelock.sol deleted file mode 100644 index 542b22d8..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC20/TokenTimelock.sol +++ /dev/null @@ -1,67 +0,0 @@ -pragma solidity ^0.5.0; - -import "./SafeERC20.sol"; - -/** - * @dev A token holder contract that will allow a beneficiary to extract the - * tokens after a given release time. - * - * Useful for simple vesting schedules like "advisors get all of their tokens - * after 1 year". - * - * For a more complete vesting schedule, see {TokenVesting}. - */ -contract TokenTimelock { - using SafeERC20 for IERC20; - - // ERC20 basic token contract being held - IERC20 private _token; - - // beneficiary of tokens after they are released - address private _beneficiary; - - // timestamp when token release is enabled - uint256 private _releaseTime; - - constructor (IERC20 token, address beneficiary, uint256 releaseTime) public { - // solhint-disable-next-line not-rely-on-time - require(releaseTime > block.timestamp, "TokenTimelock: release time is before current time"); - _token = token; - _beneficiary = beneficiary; - _releaseTime = releaseTime; - } - - /** - * @return the token being held. - */ - function token() public view returns (IERC20) { - return _token; - } - - /** - * @return the beneficiary of the tokens. - */ - function beneficiary() public view returns (address) { - return _beneficiary; - } - - /** - * @return the time when the tokens are released. - */ - function releaseTime() public view returns (uint256) { - return _releaseTime; - } - - /** - * @notice Transfers tokens held by timelock to beneficiary. - */ - function release() public { - // solhint-disable-next-line not-rely-on-time - require(block.timestamp >= _releaseTime, "TokenTimelock: current time is before release time"); - - uint256 amount = _token.balanceOf(address(this)); - require(amount > 0, "TokenTimelock: no tokens to release"); - - _token.safeTransfer(_beneficiary, amount); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol deleted file mode 100644 index 67742b84..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol +++ /dev/null @@ -1,366 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "./IERC721.sol"; -import "./IERC721Receiver.sol"; -import "../../math/SafeMath.sol"; -import "../../utils/Address.sol"; -import "../../drafts/Counters.sol"; -import "../../introspection/ERC165.sol"; - -/** - * @title ERC721 Non-Fungible Token Standard basic implementation - * @dev see https://eips.ethereum.org/EIPS/eip-721 - */ -contract ERC721 is Context, ERC165, IERC721 { - using SafeMath for uint256; - using Address for address; - using Counters for Counters.Counter; - - // Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` - // which can be also obtained as `IERC721Receiver(0).onERC721Received.selector` - bytes4 private constant _ERC721_RECEIVED = 0x150b7a02; - - // Mapping from token ID to owner - mapping (uint256 => address) private _tokenOwner; - - // Mapping from token ID to approved address - mapping (uint256 => address) private _tokenApprovals; - - // Mapping from owner to number of owned token - mapping (address => Counters.Counter) private _ownedTokensCount; - - // Mapping from owner to operator approvals - mapping (address => mapping (address => bool)) private _operatorApprovals; - - /* - * bytes4(keccak256('balanceOf(address)')) == 0x70a08231 - * bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e - * bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3 - * bytes4(keccak256('getApproved(uint256)')) == 0x081812fc - * bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465 - * bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5 - * bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd - * bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e - * bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde - * - * => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ - * 0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd - */ - bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd; - - constructor () public { - // register the supported interfaces to conform to ERC721 via ERC165 - _registerInterface(_INTERFACE_ID_ERC721); - } - - /** - * @dev Gets the balance of the specified address. - * @param owner address to query the balance of - * @return uint256 representing the amount owned by the passed address - */ - function balanceOf(address owner) public view returns (uint256) { - require(owner != address(0), "ERC721: balance query for the zero address"); - - return _ownedTokensCount[owner].current(); - } - - /** - * @dev Gets the owner of the specified token ID. - * @param tokenId uint256 ID of the token to query the owner of - * @return address currently marked as the owner of the given token ID - */ - function ownerOf(uint256 tokenId) public view returns (address) { - address owner = _tokenOwner[tokenId]; - require(owner != address(0), "ERC721: owner query for nonexistent token"); - - return owner; - } - - /** - * @dev Approves another address to transfer the given token ID - * The zero address indicates there is no approved address. - * There can only be one approved address per token at a given time. - * Can only be called by the token owner or an approved operator. - * @param to address to be approved for the given token ID - * @param tokenId uint256 ID of the token to be approved - */ - function approve(address to, uint256 tokenId) public { - address owner = ownerOf(tokenId); - require(to != owner, "ERC721: approval to current owner"); - - require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), - "ERC721: approve caller is not owner nor approved for all" - ); - - _tokenApprovals[tokenId] = to; - emit Approval(owner, to, tokenId); - } - - /** - * @dev Gets the approved address for a token ID, or zero if no address set - * Reverts if the token ID does not exist. - * @param tokenId uint256 ID of the token to query the approval of - * @return address currently approved for the given token ID - */ - function getApproved(uint256 tokenId) public view returns (address) { - require(_exists(tokenId), "ERC721: approved query for nonexistent token"); - - return _tokenApprovals[tokenId]; - } - - /** - * @dev Sets or unsets the approval of a given operator - * An operator is allowed to transfer all tokens of the sender on their behalf. - * @param to operator address to set the approval - * @param approved representing the status of the approval to be set - */ - function setApprovalForAll(address to, bool approved) public { - require(to != _msgSender(), "ERC721: approve to caller"); - - _operatorApprovals[_msgSender()][to] = approved; - emit ApprovalForAll(_msgSender(), to, approved); - } - - /** - * @dev Tells whether an operator is approved by a given owner. - * @param owner owner address which you want to query the approval of - * @param operator operator address which you want to query the approval of - * @return bool whether the given operator is approved by the given owner - */ - function isApprovedForAll(address owner, address operator) public view returns (bool) { - return _operatorApprovals[owner][operator]; - } - - /** - * @dev Transfers the ownership of a given token ID to another address. - * Usage of this method is discouraged, use {safeTransferFrom} whenever possible. - * Requires the msg.sender to be the owner, approved, or operator. - * @param from current owner of the token - * @param to address to receive the ownership of the given token ID - * @param tokenId uint256 ID of the token to be transferred - */ - function transferFrom(address from, address to, uint256 tokenId) public { - //solhint-disable-next-line max-line-length - require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); - - _transferFrom(from, to, tokenId); - } - - /** - * @dev Safely transfers the ownership of a given token ID to another address - * If the target address is a contract, it must implement {IERC721Receiver-onERC721Received}, - * which is called upon a safe transfer, and return the magic value - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, - * the transfer is reverted. - * Requires the msg.sender to be the owner, approved, or operator - * @param from current owner of the token - * @param to address to receive the ownership of the given token ID - * @param tokenId uint256 ID of the token to be transferred - */ - function safeTransferFrom(address from, address to, uint256 tokenId) public { - safeTransferFrom(from, to, tokenId, ""); - } - - /** - * @dev Safely transfers the ownership of a given token ID to another address - * If the target address is a contract, it must implement {IERC721Receiver-onERC721Received}, - * which is called upon a safe transfer, and return the magic value - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, - * the transfer is reverted. - * Requires the _msgSender() to be the owner, approved, or operator - * @param from current owner of the token - * @param to address to receive the ownership of the given token ID - * @param tokenId uint256 ID of the token to be transferred - * @param _data bytes data to send along with a safe transfer check - */ - function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public { - require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); - _safeTransferFrom(from, to, tokenId, _data); - } - - /** - * @dev Safely transfers the ownership of a given token ID to another address - * If the target address is a contract, it must implement `onERC721Received`, - * which is called upon a safe transfer, and return the magic value - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, - * the transfer is reverted. - * Requires the msg.sender to be the owner, approved, or operator - * @param from current owner of the token - * @param to address to receive the ownership of the given token ID - * @param tokenId uint256 ID of the token to be transferred - * @param _data bytes data to send along with a safe transfer check - */ - function _safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) internal { - _transferFrom(from, to, tokenId); - require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); - } - - /** - * @dev Returns whether the specified token exists. - * @param tokenId uint256 ID of the token to query the existence of - * @return bool whether the token exists - */ - function _exists(uint256 tokenId) internal view returns (bool) { - address owner = _tokenOwner[tokenId]; - return owner != address(0); - } - - /** - * @dev Returns whether the given spender can transfer a given token ID. - * @param spender address of the spender to query - * @param tokenId uint256 ID of the token to be transferred - * @return bool whether the msg.sender is approved for the given token ID, - * is an operator of the owner, or is the owner of the token - */ - function _isApprovedOrOwner(address spender, uint256 tokenId) internal view returns (bool) { - require(_exists(tokenId), "ERC721: operator query for nonexistent token"); - address owner = ownerOf(tokenId); - return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); - } - - /** - * @dev Internal function to safely mint a new token. - * Reverts if the given token ID already exists. - * If the target address is a contract, it must implement `onERC721Received`, - * which is called upon a safe transfer, and return the magic value - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, - * the transfer is reverted. - * @param to The address that will own the minted token - * @param tokenId uint256 ID of the token to be minted - */ - function _safeMint(address to, uint256 tokenId) internal { - _safeMint(to, tokenId, ""); - } - - /** - * @dev Internal function to safely mint a new token. - * Reverts if the given token ID already exists. - * If the target address is a contract, it must implement `onERC721Received`, - * which is called upon a safe transfer, and return the magic value - * `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise, - * the transfer is reverted. - * @param to The address that will own the minted token - * @param tokenId uint256 ID of the token to be minted - * @param _data bytes data to send along with a safe transfer check - */ - function _safeMint(address to, uint256 tokenId, bytes memory _data) internal { - _mint(to, tokenId); - require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); - } - - /** - * @dev Internal function to mint a new token. - * Reverts if the given token ID already exists. - * @param to The address that will own the minted token - * @param tokenId uint256 ID of the token to be minted - */ - function _mint(address to, uint256 tokenId) internal { - require(to != address(0), "ERC721: mint to the zero address"); - require(!_exists(tokenId), "ERC721: token already minted"); - - _tokenOwner[tokenId] = to; - _ownedTokensCount[to].increment(); - - emit Transfer(address(0), to, tokenId); - } - - /** - * @dev Internal function to burn a specific token. - * Reverts if the token does not exist. - * Deprecated, use {_burn} instead. - * @param owner owner of the token to burn - * @param tokenId uint256 ID of the token being burned - */ - function _burn(address owner, uint256 tokenId) internal { - require(ownerOf(tokenId) == owner, "ERC721: burn of token that is not own"); - - _clearApproval(tokenId); - - _ownedTokensCount[owner].decrement(); - _tokenOwner[tokenId] = address(0); - - emit Transfer(owner, address(0), tokenId); - } - - /** - * @dev Internal function to burn a specific token. - * Reverts if the token does not exist. - * @param tokenId uint256 ID of the token being burned - */ - function _burn(uint256 tokenId) internal { - _burn(ownerOf(tokenId), tokenId); - } - - /** - * @dev Internal function to transfer ownership of a given token ID to another address. - * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. - * @param from current owner of the token - * @param to address to receive the ownership of the given token ID - * @param tokenId uint256 ID of the token to be transferred - */ - function _transferFrom(address from, address to, uint256 tokenId) internal { - require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); - require(to != address(0), "ERC721: transfer to the zero address"); - - _clearApproval(tokenId); - - _ownedTokensCount[from].decrement(); - _ownedTokensCount[to].increment(); - - _tokenOwner[tokenId] = to; - - emit Transfer(from, to, tokenId); - } - - /** - * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. - * The call is not executed if the target address is not a contract. - * - * This is an internal detail of the `ERC721` contract and its use is deprecated. - * @param from address representing the previous owner of the given token ID - * @param to target address that will receive the tokens - * @param tokenId uint256 ID of the token to be transferred - * @param _data bytes optional data to send along with the call - * @return bool whether the call correctly returned the expected magic value - */ - function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data) - internal returns (bool) - { - if (!to.isContract()) { - return true; - } - // solhint-disable-next-line avoid-low-level-calls - (bool success, bytes memory returndata) = to.call(abi.encodeWithSelector( - IERC721Receiver(to).onERC721Received.selector, - _msgSender(), - from, - tokenId, - _data - )); - if (!success) { - if (returndata.length > 0) { - // solhint-disable-next-line no-inline-assembly - assembly { - let returndata_size := mload(returndata) - revert(add(32, returndata), returndata_size) - } - } else { - revert("ERC721: transfer to non ERC721Receiver implementer"); - } - } else { - bytes4 retval = abi.decode(returndata, (bytes4)); - return (retval == _ERC721_RECEIVED); - } - } - - /** - * @dev Private function to clear current approval of a given token ID. - * @param tokenId uint256 ID of the token to be transferred - */ - function _clearApproval(uint256 tokenId) private { - if (_tokenApprovals[tokenId] != address(0)) { - _tokenApprovals[tokenId] = address(0); - } - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Burnable.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Burnable.sol deleted file mode 100644 index e35796b9..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Burnable.sol +++ /dev/null @@ -1,20 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "./ERC721.sol"; - -/** - * @title ERC721 Burnable Token - * @dev ERC721 Token that can be irreversibly burned (destroyed). - */ -contract ERC721Burnable is Context, ERC721 { - /** - * @dev Burns a specific ERC721 token. - * @param tokenId uint256 id of the ERC721 token to be burned. - */ - function burn(uint256 tokenId) public { - //solhint-disable-next-line max-line-length - require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); - _burn(tokenId); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Enumerable.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Enumerable.sol deleted file mode 100644 index ff7a1584..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Enumerable.sol +++ /dev/null @@ -1,200 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "./IERC721Enumerable.sol"; -import "./ERC721.sol"; -import "../../introspection/ERC165.sol"; - -/** - * @title ERC-721 Non-Fungible Token with optional enumeration extension logic - * @dev See https://eips.ethereum.org/EIPS/eip-721 - */ -contract ERC721Enumerable is Context, ERC165, ERC721, IERC721Enumerable { - // Mapping from owner to list of owned token IDs - mapping(address => uint256[]) private _ownedTokens; - - // Mapping from token ID to index of the owner tokens list - mapping(uint256 => uint256) private _ownedTokensIndex; - - // Array with all token ids, used for enumeration - uint256[] private _allTokens; - - // Mapping from token id to position in the allTokens array - mapping(uint256 => uint256) private _allTokensIndex; - - /* - * bytes4(keccak256('totalSupply()')) == 0x18160ddd - * bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59 - * bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7 - * - * => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63 - */ - bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63; - - /** - * @dev Constructor function. - */ - constructor () public { - // register the supported interface to conform to ERC721Enumerable via ERC165 - _registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE); - } - - /** - * @dev Gets the token ID at a given index of the tokens list of the requested owner. - * @param owner address owning the tokens list to be accessed - * @param index uint256 representing the index to be accessed of the requested tokens list - * @return uint256 token ID at the given index of the tokens list owned by the requested address - */ - function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) { - require(index < balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); - return _ownedTokens[owner][index]; - } - - /** - * @dev Gets the total amount of tokens stored by the contract. - * @return uint256 representing the total amount of tokens - */ - function totalSupply() public view returns (uint256) { - return _allTokens.length; - } - - /** - * @dev Gets the token ID at a given index of all the tokens in this contract - * Reverts if the index is greater or equal to the total number of tokens. - * @param index uint256 representing the index to be accessed of the tokens list - * @return uint256 token ID at the given index of the tokens list - */ - function tokenByIndex(uint256 index) public view returns (uint256) { - require(index < totalSupply(), "ERC721Enumerable: global index out of bounds"); - return _allTokens[index]; - } - - /** - * @dev Internal function to transfer ownership of a given token ID to another address. - * As opposed to transferFrom, this imposes no restrictions on msg.sender. - * @param from current owner of the token - * @param to address to receive the ownership of the given token ID - * @param tokenId uint256 ID of the token to be transferred - */ - function _transferFrom(address from, address to, uint256 tokenId) internal { - super._transferFrom(from, to, tokenId); - - _removeTokenFromOwnerEnumeration(from, tokenId); - - _addTokenToOwnerEnumeration(to, tokenId); - } - - /** - * @dev Internal function to mint a new token. - * Reverts if the given token ID already exists. - * @param to address the beneficiary that will own the minted token - * @param tokenId uint256 ID of the token to be minted - */ - function _mint(address to, uint256 tokenId) internal { - super._mint(to, tokenId); - - _addTokenToOwnerEnumeration(to, tokenId); - - _addTokenToAllTokensEnumeration(tokenId); - } - - /** - * @dev Internal function to burn a specific token. - * Reverts if the token does not exist. - * Deprecated, use {ERC721-_burn} instead. - * @param owner owner of the token to burn - * @param tokenId uint256 ID of the token being burned - */ - function _burn(address owner, uint256 tokenId) internal { - super._burn(owner, tokenId); - - _removeTokenFromOwnerEnumeration(owner, tokenId); - // Since tokenId will be deleted, we can clear its slot in _ownedTokensIndex to trigger a gas refund - _ownedTokensIndex[tokenId] = 0; - - _removeTokenFromAllTokensEnumeration(tokenId); - } - - /** - * @dev Gets the list of token IDs of the requested owner. - * @param owner address owning the tokens - * @return uint256[] List of token IDs owned by the requested address - */ - function _tokensOfOwner(address owner) internal view returns (uint256[] storage) { - return _ownedTokens[owner]; - } - - /** - * @dev Private function to add a token to this extension's ownership-tracking data structures. - * @param to address representing the new owner of the given token ID - * @param tokenId uint256 ID of the token to be added to the tokens list of the given address - */ - function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { - _ownedTokensIndex[tokenId] = _ownedTokens[to].length; - _ownedTokens[to].push(tokenId); - } - - /** - * @dev Private function to add a token to this extension's token tracking data structures. - * @param tokenId uint256 ID of the token to be added to the tokens list - */ - function _addTokenToAllTokensEnumeration(uint256 tokenId) private { - _allTokensIndex[tokenId] = _allTokens.length; - _allTokens.push(tokenId); - } - - /** - * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that - * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for - * gas optimizations e.g. when performing a transfer operation (avoiding double writes). - * This has O(1) time complexity, but alters the order of the _ownedTokens array. - * @param from address representing the previous owner of the given token ID - * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address - */ - function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { - // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and - // then delete the last slot (swap and pop). - - uint256 lastTokenIndex = _ownedTokens[from].length.sub(1); - uint256 tokenIndex = _ownedTokensIndex[tokenId]; - - // When the token to delete is the last token, the swap operation is unnecessary - if (tokenIndex != lastTokenIndex) { - uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; - - _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token - _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index - } - - // This also deletes the contents at the last position of the array - _ownedTokens[from].length--; - - // Note that _ownedTokensIndex[tokenId] hasn't been cleared: it still points to the old slot (now occupied by - // lastTokenId, or just over the end of the array if the token was the last one). - } - - /** - * @dev Private function to remove a token from this extension's token tracking data structures. - * This has O(1) time complexity, but alters the order of the _allTokens array. - * @param tokenId uint256 ID of the token to be removed from the tokens list - */ - function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { - // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and - // then delete the last slot (swap and pop). - - uint256 lastTokenIndex = _allTokens.length.sub(1); - uint256 tokenIndex = _allTokensIndex[tokenId]; - - // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so - // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding - // an 'if' statement (like in _removeTokenFromOwnerEnumeration) - uint256 lastTokenId = _allTokens[lastTokenIndex]; - - _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token - _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index - - // This also deletes the contents at the last position of the array - _allTokens.length--; - _allTokensIndex[tokenId] = 0; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Full.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Full.sol deleted file mode 100644 index a6fce273..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Full.sol +++ /dev/null @@ -1,18 +0,0 @@ -pragma solidity ^0.5.0; - -import "./ERC721.sol"; -import "./ERC721Enumerable.sol"; -import "./ERC721Metadata.sol"; - -/** - * @title Full ERC721 Token - * @dev This implementation includes all the required and some optional functionality of the ERC721 standard - * Moreover, it includes approve all functionality using operator terminology. - * - * See https://eips.ethereum.org/EIPS/eip-721 - */ -contract ERC721Full is ERC721, ERC721Enumerable, ERC721Metadata { - constructor (string memory name, string memory symbol) public ERC721Metadata(name, symbol) { - // solhint-disable-previous-line no-empty-blocks - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Holder.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Holder.sol deleted file mode 100644 index bcc10d7e..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Holder.sol +++ /dev/null @@ -1,9 +0,0 @@ -pragma solidity ^0.5.0; - -import "./IERC721Receiver.sol"; - -contract ERC721Holder is IERC721Receiver { - function onERC721Received(address, address, uint256, bytes memory) public returns (bytes4) { - return this.onERC721Received.selector; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Metadata.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Metadata.sol deleted file mode 100644 index c83b5e16..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Metadata.sol +++ /dev/null @@ -1,129 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "./ERC721.sol"; -import "./IERC721Metadata.sol"; -import "../../introspection/ERC165.sol"; - -contract ERC721Metadata is Context, ERC165, ERC721, IERC721Metadata { - // Token name - string private _name; - - // Token symbol - string private _symbol; - - // Base URI - string private _baseURI; - - // Optional mapping for token URIs - mapping(uint256 => string) private _tokenURIs; - - /* - * bytes4(keccak256('name()')) == 0x06fdde03 - * bytes4(keccak256('symbol()')) == 0x95d89b41 - * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd - * - * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f - */ - bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f; - - /** - * @dev Constructor function - */ - constructor (string memory name, string memory symbol) public { - _name = name; - _symbol = symbol; - - // register the supported interfaces to conform to ERC721 via ERC165 - _registerInterface(_INTERFACE_ID_ERC721_METADATA); - } - - /** - * @dev Gets the token name. - * @return string representing the token name - */ - function name() external view returns (string memory) { - return _name; - } - - /** - * @dev Gets the token symbol. - * @return string representing the token symbol - */ - function symbol() external view returns (string memory) { - return _symbol; - } - - /** - * @dev Returns the URI for a given token ID. May return an empty string. - * - * If the token's URI is non-empty and a base URI was set (via - * {_setBaseURI}), it will be added to the token ID's URI as a prefix. - * - * Reverts if the token ID does not exist. - */ - function tokenURI(uint256 tokenId) external view returns (string memory) { - require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); - - string memory _tokenURI = _tokenURIs[tokenId]; - - // Even if there is a base URI, it is only appended to non-empty token-specific URIs - if (bytes(_tokenURI).length == 0) { - return ""; - } else { - // abi.encodePacked is being used to concatenate strings - return string(abi.encodePacked(_baseURI, _tokenURI)); - } - } - - /** - * @dev Internal function to set the token URI for a given token. - * - * Reverts if the token ID does not exist. - * - * TIP: if all token IDs share a prefix (e.g. if your URIs look like - * `http://api.myproject.com/token/`), use {_setBaseURI} to store - * it and save gas. - */ - function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal { - require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token"); - _tokenURIs[tokenId] = _tokenURI; - } - - /** - * @dev Internal function to set the base URI for all token IDs. It is - * automatically added as a prefix to the value returned in {tokenURI}. - * - * _Available since v2.5.0._ - */ - function _setBaseURI(string memory baseURI) internal { - _baseURI = baseURI; - } - - /** - * @dev Returns the base URI set via {_setBaseURI}. This will be - * automatically added as a preffix in {tokenURI} to each token's URI, when - * they are non-empty. - * - * _Available since v2.5.0._ - */ - function baseURI() external view returns (string memory) { - return _baseURI; - } - - /** - * @dev Internal function to burn a specific token. - * Reverts if the token does not exist. - * Deprecated, use _burn(uint256) instead. - * @param owner owner of the token to burn - * @param tokenId uint256 ID of the token being burned by the msg.sender - */ - function _burn(address owner, uint256 tokenId) internal { - super._burn(owner, tokenId); - - // Clear metadata (if any) - if (bytes(_tokenURIs[tokenId]).length != 0) { - delete _tokenURIs[tokenId]; - } - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721MetadataMintable.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721MetadataMintable.sol deleted file mode 100644 index a1421d1d..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721MetadataMintable.sol +++ /dev/null @@ -1,24 +0,0 @@ -pragma solidity ^0.5.0; - -import "./ERC721Metadata.sol"; -import "../../access/roles/MinterRole.sol"; - - -/** - * @title ERC721MetadataMintable - * @dev ERC721 minting logic with metadata. - */ -contract ERC721MetadataMintable is ERC721, ERC721Metadata, MinterRole { - /** - * @dev Function to mint tokens. - * @param to The address that will receive the minted tokens. - * @param tokenId The token id to mint. - * @param tokenURI The token URI of the minted token. - * @return A boolean that indicates if the operation was successful. - */ - function mintWithTokenURI(address to, uint256 tokenId, string memory tokenURI) public onlyMinter returns (bool) { - _mint(to, tokenId); - _setTokenURI(tokenId, tokenURI); - return true; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Mintable.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Mintable.sol deleted file mode 100644 index faed7ad8..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Mintable.sol +++ /dev/null @@ -1,44 +0,0 @@ -pragma solidity ^0.5.0; - -import "./ERC721.sol"; -import "../../access/roles/MinterRole.sol"; - -/** - * @title ERC721Mintable - * @dev ERC721 minting logic. - */ -contract ERC721Mintable is ERC721, MinterRole { - /** - * @dev Function to mint tokens. - * @param to The address that will receive the minted token. - * @param tokenId The token id to mint. - * @return A boolean that indicates if the operation was successful. - */ - function mint(address to, uint256 tokenId) public onlyMinter returns (bool) { - _mint(to, tokenId); - return true; - } - - /** - * @dev Function to safely mint tokens. - * @param to The address that will receive the minted token. - * @param tokenId The token id to mint. - * @return A boolean that indicates if the operation was successful. - */ - function safeMint(address to, uint256 tokenId) public onlyMinter returns (bool) { - _safeMint(to, tokenId); - return true; - } - - /** - * @dev Function to safely mint tokens. - * @param to The address that will receive the minted token. - * @param tokenId The token id to mint. - * @param _data bytes data to send along with a safe transfer check. - * @return A boolean that indicates if the operation was successful. - */ - function safeMint(address to, uint256 tokenId, bytes memory _data) public onlyMinter returns (bool) { - _safeMint(to, tokenId, _data); - return true; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Pausable.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Pausable.sol deleted file mode 100644 index 5080d380..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/ERC721Pausable.sol +++ /dev/null @@ -1,22 +0,0 @@ -pragma solidity ^0.5.0; - -import "./ERC721.sol"; -import "../../lifecycle/Pausable.sol"; - -/** - * @title ERC721 Non-Fungible Pausable token - * @dev ERC721 modified with pausable transfers. - */ -contract ERC721Pausable is ERC721, Pausable { - function approve(address to, uint256 tokenId) public whenNotPaused { - super.approve(to, tokenId); - } - - function setApprovalForAll(address to, bool approved) public whenNotPaused { - super.setApprovalForAll(to, approved); - } - - function _transferFrom(address from, address to, uint256 tokenId) internal whenNotPaused { - super._transferFrom(from, to, tokenId); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol deleted file mode 100644 index b8efac23..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol +++ /dev/null @@ -1,53 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../introspection/IERC165.sol"; - -/** - * @dev Required interface of an ERC721 compliant contract. - */ -contract IERC721 is IERC165 { - event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); - event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); - event ApprovalForAll(address indexed owner, address indexed operator, bool approved); - - /** - * @dev Returns the number of NFTs in `owner`'s account. - */ - function balanceOf(address owner) public view returns (uint256 balance); - - /** - * @dev Returns the owner of the NFT specified by `tokenId`. - */ - function ownerOf(uint256 tokenId) public view returns (address owner); - - /** - * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to - * another (`to`). - * - * - * - * Requirements: - * - `from`, `to` cannot be zero. - * - `tokenId` must be owned by `from`. - * - If the caller is not `from`, it must be have been allowed to move this - * NFT by either {approve} or {setApprovalForAll}. - */ - function safeTransferFrom(address from, address to, uint256 tokenId) public; - /** - * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to - * another (`to`). - * - * Requirements: - * - If the caller is not `from`, it must be approved to move this NFT by - * either {approve} or {setApprovalForAll}. - */ - function transferFrom(address from, address to, uint256 tokenId) public; - function approve(address to, uint256 tokenId) public; - function getApproved(uint256 tokenId) public view returns (address operator); - - function setApprovalForAll(address operator, bool _approved) public; - function isApprovedForAll(address owner, address operator) public view returns (bool); - - - function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public; -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol deleted file mode 100644 index 4c1dfb56..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol +++ /dev/null @@ -1,14 +0,0 @@ -pragma solidity ^0.5.0; - -import "./IERC721.sol"; - -/** - * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension - * @dev See https://eips.ethereum.org/EIPS/eip-721 - */ -contract IERC721Enumerable is IERC721 { - function totalSupply() public view returns (uint256); - function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256 tokenId); - - function tokenByIndex(uint256 index) public view returns (uint256); -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Full.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Full.sol deleted file mode 100644 index e543aefe..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Full.sol +++ /dev/null @@ -1,13 +0,0 @@ -pragma solidity ^0.5.0; - -import "./IERC721.sol"; -import "./IERC721Enumerable.sol"; -import "./IERC721Metadata.sol"; - -/** - * @title ERC-721 Non-Fungible Token Standard, full implementation interface - * @dev See https://eips.ethereum.org/EIPS/eip-721 - */ -contract IERC721Full is IERC721, IERC721Enumerable, IERC721Metadata { - // solhint-disable-previous-line no-empty-blocks -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol deleted file mode 100644 index 05835aff..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Metadata.sol +++ /dev/null @@ -1,13 +0,0 @@ -pragma solidity ^0.5.0; - -import "./IERC721.sol"; - -/** - * @title ERC-721 Non-Fungible Token Standard, optional metadata extension - * @dev See https://eips.ethereum.org/EIPS/eip-721 - */ -contract IERC721Metadata is IERC721 { - function name() external view returns (string memory); - function symbol() external view returns (string memory); - function tokenURI(uint256 tokenId) external view returns (string memory); -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol b/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol deleted file mode 100644 index 94eeb75c..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol +++ /dev/null @@ -1,25 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @title ERC721 token receiver interface - * @dev Interface for any contract that wants to support safeTransfers - * from ERC721 asset contracts. - */ -contract IERC721Receiver { - /** - * @notice Handle the receipt of an NFT - * @dev The ERC721 smart contract calls this function on the recipient - * after a {IERC721-safeTransferFrom}. This function MUST return the function selector, - * otherwise the caller will revert the transaction. The selector to be - * returned can be obtained as `this.onERC721Received.selector`. This - * function MAY throw to revert and reject the transfer. - * Note: the ERC721 contract address is always the message sender. - * @param operator The address which called `safeTransferFrom` function - * @param from The address which previously owned the token - * @param tokenId The NFT identifier which is being transferred - * @param data Additional data with no specified format - * @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` - */ - function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data) - public returns (bytes4); -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC721/README.adoc b/src/node_modules/@openzeppelin/contracts/token/ERC721/README.adoc deleted file mode 100644 index 9dceaa7c..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC721/README.adoc +++ /dev/null @@ -1,55 +0,0 @@ -= ERC 721 - -This set of interfaces, contracts, and utilities are all related to the https://eips.ethereum.org/EIPS/eip-721[ERC721 Non-Fungible Token Standard]. - -TIP: For a walkthrough on how to create an ERC721 token read our xref:ROOT:tokens.adoc#ERC721[ERC721 guide]. - -The EIP consists of three interfaces, found here as {IERC721}, {IERC721Metadata}, and {IERC721Enumerable}. Only the first one is required in a contract to be ERC721 compliant. - -Each interface is implemented separately in {ERC721}, {ERC721Metadata}, and {ERC721Enumerable}. You can choose the subset of functionality you would like to support in your token by combining the -desired subset through inheritance. - -The fully featured token implementing all three interfaces is prepackaged as {ERC721Full}. - -Additionally, {IERC721Receiver} can be used to prevent tokens from becoming forever locked in contracts. Imagine sending an in-game item to an exchange address that can't send it back!. When using <>, the token contract checks to see that the receiver is an {IERC721Receiver}, which implies that it knows how to handle {ERC721} tokens. If you're writing a contract that needs to receive {ERC721} tokens, you'll want to include this interface. - -Finally, some custom extensions are also included: - -* {ERC721Mintable} — like the ERC20 version, this allows certain addresses to mint new tokens -* {ERC721Pausable} — like the ERC20 version, this allows addresses to freeze transfers of tokens - -NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned! - -== Core - -{{IERC721}} - -{{ERC721}} - -{{IERC721Metadata}} - -{{ERC721Metadata}} - -{{ERC721Enumerable}} - -{{IERC721Enumerable}} - -{{IERC721Full}} - -{{ERC721Full}} - -{{IERC721Receiver}} - -== Extensions - -{{ERC721Mintable}} - -{{ERC721MetadataMintable}} - -{{ERC721Burnable}} - -{{ERC721Pausable}} - -== Convenience - -{{ERC721Holder}} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC777/ERC777.sol b/src/node_modules/@openzeppelin/contracts/token/ERC777/ERC777.sol deleted file mode 100644 index 0c6f9f0a..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC777/ERC777.sol +++ /dev/null @@ -1,479 +0,0 @@ -pragma solidity ^0.5.0; - -import "../../GSN/Context.sol"; -import "./IERC777.sol"; -import "./IERC777Recipient.sol"; -import "./IERC777Sender.sol"; -import "../../token/ERC20/IERC20.sol"; -import "../../math/SafeMath.sol"; -import "../../utils/Address.sol"; -import "../../introspection/IERC1820Registry.sol"; - -/** - * @dev Implementation of the {IERC777} interface. - * - * This implementation is agnostic to the way tokens are created. This means - * that a supply mechanism has to be added in a derived contract using {_mint}. - * - * Support for ERC20 is included in this contract, as specified by the EIP: both - * the ERC777 and ERC20 interfaces can be safely used when interacting with it. - * Both {IERC777-Sent} and {IERC20-Transfer} events are emitted on token - * movements. - * - * Additionally, the {IERC777-granularity} value is hard-coded to `1`, meaning that there - * are no special restrictions in the amount of tokens that created, moved, or - * destroyed. This makes integration with ERC20 applications seamless. - */ -contract ERC777 is Context, IERC777, IERC20 { - using SafeMath for uint256; - using Address for address; - - IERC1820Registry constant internal ERC1820_REGISTRY = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24); - - mapping(address => uint256) private _balances; - - uint256 private _totalSupply; - - string private _name; - string private _symbol; - - // We inline the result of the following hashes because Solidity doesn't resolve them at compile time. - // See https://github.com/ethereum/solidity/issues/4024. - - // keccak256("ERC777TokensSender") - bytes32 constant private TOKENS_SENDER_INTERFACE_HASH = - 0x29ddb589b1fb5fc7cf394961c1adf5f8c6454761adf795e67fe149f658abe895; - - // keccak256("ERC777TokensRecipient") - bytes32 constant private TOKENS_RECIPIENT_INTERFACE_HASH = - 0xb281fc8c12954d22544db45de3159a39272895b169a852b314f9cc762e44c53b; - - // This isn't ever read from - it's only used to respond to the defaultOperators query. - address[] private _defaultOperatorsArray; - - // Immutable, but accounts may revoke them (tracked in __revokedDefaultOperators). - mapping(address => bool) private _defaultOperators; - - // For each account, a mapping of its operators and revoked default operators. - mapping(address => mapping(address => bool)) private _operators; - mapping(address => mapping(address => bool)) private _revokedDefaultOperators; - - // ERC20-allowances - mapping (address => mapping (address => uint256)) private _allowances; - - /** - * @dev `defaultOperators` may be an empty array. - */ - constructor( - string memory name, - string memory symbol, - address[] memory defaultOperators - ) public { - _name = name; - _symbol = symbol; - - _defaultOperatorsArray = defaultOperators; - for (uint256 i = 0; i < _defaultOperatorsArray.length; i++) { - _defaultOperators[_defaultOperatorsArray[i]] = true; - } - - // register interfaces - ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC777Token"), address(this)); - ERC1820_REGISTRY.setInterfaceImplementer(address(this), keccak256("ERC20Token"), address(this)); - } - - /** - * @dev See {IERC777-name}. - */ - function name() public view returns (string memory) { - return _name; - } - - /** - * @dev See {IERC777-symbol}. - */ - function symbol() public view returns (string memory) { - return _symbol; - } - - /** - * @dev See {ERC20Detailed-decimals}. - * - * Always returns 18, as per the - * [ERC777 EIP](https://eips.ethereum.org/EIPS/eip-777#backward-compatibility). - */ - function decimals() public pure returns (uint8) { - return 18; - } - - /** - * @dev See {IERC777-granularity}. - * - * This implementation always returns `1`. - */ - function granularity() public view returns (uint256) { - return 1; - } - - /** - * @dev See {IERC777-totalSupply}. - */ - function totalSupply() public view returns (uint256) { - return _totalSupply; - } - - /** - * @dev Returns the amount of tokens owned by an account (`tokenHolder`). - */ - function balanceOf(address tokenHolder) public view returns (uint256) { - return _balances[tokenHolder]; - } - - /** - * @dev See {IERC777-send}. - * - * Also emits a {IERC20-Transfer} event for ERC20 compatibility. - */ - function send(address recipient, uint256 amount, bytes memory data) public { - _send(_msgSender(), _msgSender(), recipient, amount, data, "", true); - } - - /** - * @dev See {IERC20-transfer}. - * - * Unlike `send`, `recipient` is _not_ required to implement the {IERC777Recipient} - * interface if it is a contract. - * - * Also emits a {Sent} event. - */ - function transfer(address recipient, uint256 amount) public returns (bool) { - require(recipient != address(0), "ERC777: transfer to the zero address"); - - address from = _msgSender(); - - _callTokensToSend(from, from, recipient, amount, "", ""); - - _move(from, from, recipient, amount, "", ""); - - _callTokensReceived(from, from, recipient, amount, "", "", false); - - return true; - } - - /** - * @dev See {IERC777-burn}. - * - * Also emits a {IERC20-Transfer} event for ERC20 compatibility. - */ - function burn(uint256 amount, bytes memory data) public { - _burn(_msgSender(), _msgSender(), amount, data, ""); - } - - /** - * @dev See {IERC777-isOperatorFor}. - */ - function isOperatorFor( - address operator, - address tokenHolder - ) public view returns (bool) { - return operator == tokenHolder || - (_defaultOperators[operator] && !_revokedDefaultOperators[tokenHolder][operator]) || - _operators[tokenHolder][operator]; - } - - /** - * @dev See {IERC777-authorizeOperator}. - */ - function authorizeOperator(address operator) public { - require(_msgSender() != operator, "ERC777: authorizing self as operator"); - - if (_defaultOperators[operator]) { - delete _revokedDefaultOperators[_msgSender()][operator]; - } else { - _operators[_msgSender()][operator] = true; - } - - emit AuthorizedOperator(operator, _msgSender()); - } - - /** - * @dev See {IERC777-revokeOperator}. - */ - function revokeOperator(address operator) public { - require(operator != _msgSender(), "ERC777: revoking self as operator"); - - if (_defaultOperators[operator]) { - _revokedDefaultOperators[_msgSender()][operator] = true; - } else { - delete _operators[_msgSender()][operator]; - } - - emit RevokedOperator(operator, _msgSender()); - } - - /** - * @dev See {IERC777-defaultOperators}. - */ - function defaultOperators() public view returns (address[] memory) { - return _defaultOperatorsArray; - } - - /** - * @dev See {IERC777-operatorSend}. - * - * Emits {Sent} and {IERC20-Transfer} events. - */ - function operatorSend( - address sender, - address recipient, - uint256 amount, - bytes memory data, - bytes memory operatorData - ) - public - { - require(isOperatorFor(_msgSender(), sender), "ERC777: caller is not an operator for holder"); - _send(_msgSender(), sender, recipient, amount, data, operatorData, true); - } - - /** - * @dev See {IERC777-operatorBurn}. - * - * Emits {Burned} and {IERC20-Transfer} events. - */ - function operatorBurn(address account, uint256 amount, bytes memory data, bytes memory operatorData) public { - require(isOperatorFor(_msgSender(), account), "ERC777: caller is not an operator for holder"); - _burn(_msgSender(), account, amount, data, operatorData); - } - - /** - * @dev See {IERC20-allowance}. - * - * Note that operator and allowance concepts are orthogonal: operators may - * not have allowance, and accounts with allowance may not be operators - * themselves. - */ - function allowance(address holder, address spender) public view returns (uint256) { - return _allowances[holder][spender]; - } - - /** - * @dev See {IERC20-approve}. - * - * Note that accounts cannot have allowance issued by their operators. - */ - function approve(address spender, uint256 value) public returns (bool) { - address holder = _msgSender(); - _approve(holder, spender, value); - return true; - } - - /** - * @dev See {IERC20-transferFrom}. - * - * Note that operator and allowance concepts are orthogonal: operators cannot - * call `transferFrom` (unless they have allowance), and accounts with - * allowance cannot call `operatorSend` (unless they are operators). - * - * Emits {Sent}, {IERC20-Transfer} and {IERC20-Approval} events. - */ - function transferFrom(address holder, address recipient, uint256 amount) public returns (bool) { - require(recipient != address(0), "ERC777: transfer to the zero address"); - require(holder != address(0), "ERC777: transfer from the zero address"); - - address spender = _msgSender(); - - _callTokensToSend(spender, holder, recipient, amount, "", ""); - - _move(spender, holder, recipient, amount, "", ""); - _approve(holder, spender, _allowances[holder][spender].sub(amount, "ERC777: transfer amount exceeds allowance")); - - _callTokensReceived(spender, holder, recipient, amount, "", "", false); - - return true; - } - - /** - * @dev Creates `amount` tokens and assigns them to `account`, increasing - * the total supply. - * - * If a send hook is registered for `account`, the corresponding function - * will be called with `operator`, `data` and `operatorData`. - * - * See {IERC777Sender} and {IERC777Recipient}. - * - * Emits {Minted} and {IERC20-Transfer} events. - * - * Requirements - * - * - `account` cannot be the zero address. - * - if `account` is a contract, it must implement the {IERC777Recipient} - * interface. - */ - function _mint( - address operator, - address account, - uint256 amount, - bytes memory userData, - bytes memory operatorData - ) - internal - { - require(account != address(0), "ERC777: mint to the zero address"); - - // Update state variables - _totalSupply = _totalSupply.add(amount); - _balances[account] = _balances[account].add(amount); - - _callTokensReceived(operator, address(0), account, amount, userData, operatorData, true); - - emit Minted(operator, account, amount, userData, operatorData); - emit Transfer(address(0), account, amount); - } - - /** - * @dev Send tokens - * @param operator address operator requesting the transfer - * @param from address token holder address - * @param to address recipient address - * @param amount uint256 amount of tokens to transfer - * @param userData bytes extra information provided by the token holder (if any) - * @param operatorData bytes extra information provided by the operator (if any) - * @param requireReceptionAck if true, contract recipients are required to implement ERC777TokensRecipient - */ - function _send( - address operator, - address from, - address to, - uint256 amount, - bytes memory userData, - bytes memory operatorData, - bool requireReceptionAck - ) - internal - { - require(operator != address(0), "ERC777: operator is the zero address"); - require(from != address(0), "ERC777: send from the zero address"); - require(to != address(0), "ERC777: send to the zero address"); - - _callTokensToSend(operator, from, to, amount, userData, operatorData); - - _move(operator, from, to, amount, userData, operatorData); - - _callTokensReceived(operator, from, to, amount, userData, operatorData, requireReceptionAck); - } - - /** - * @dev Burn tokens - * @param operator address operator requesting the operation - * @param from address token holder address - * @param amount uint256 amount of tokens to burn - * @param data bytes extra information provided by the token holder - * @param operatorData bytes extra information provided by the operator (if any) - */ - function _burn( - address operator, - address from, - uint256 amount, - bytes memory data, - bytes memory operatorData - ) - internal - { - require(from != address(0), "ERC777: burn from the zero address"); - - _callTokensToSend(operator, from, address(0), amount, data, operatorData); - - // Update state variables - _balances[from] = _balances[from].sub(amount, "ERC777: burn amount exceeds balance"); - _totalSupply = _totalSupply.sub(amount); - - emit Burned(operator, from, amount, data, operatorData); - emit Transfer(from, address(0), amount); - } - - function _move( - address operator, - address from, - address to, - uint256 amount, - bytes memory userData, - bytes memory operatorData - ) - private - { - _balances[from] = _balances[from].sub(amount, "ERC777: transfer amount exceeds balance"); - _balances[to] = _balances[to].add(amount); - - emit Sent(operator, from, to, amount, userData, operatorData); - emit Transfer(from, to, amount); - } - - /** - * @dev See {ERC20-_approve}. - * - * Note that accounts cannot have allowance issued by their operators. - */ - function _approve(address holder, address spender, uint256 value) internal { - require(holder != address(0), "ERC777: approve from the zero address"); - require(spender != address(0), "ERC777: approve to the zero address"); - - _allowances[holder][spender] = value; - emit Approval(holder, spender, value); - } - - /** - * @dev Call from.tokensToSend() if the interface is registered - * @param operator address operator requesting the transfer - * @param from address token holder address - * @param to address recipient address - * @param amount uint256 amount of tokens to transfer - * @param userData bytes extra information provided by the token holder (if any) - * @param operatorData bytes extra information provided by the operator (if any) - */ - function _callTokensToSend( - address operator, - address from, - address to, - uint256 amount, - bytes memory userData, - bytes memory operatorData - ) - internal - { - address implementer = ERC1820_REGISTRY.getInterfaceImplementer(from, TOKENS_SENDER_INTERFACE_HASH); - if (implementer != address(0)) { - IERC777Sender(implementer).tokensToSend(operator, from, to, amount, userData, operatorData); - } - } - - /** - * @dev Call to.tokensReceived() if the interface is registered. Reverts if the recipient is a contract but - * tokensReceived() was not registered for the recipient - * @param operator address operator requesting the transfer - * @param from address token holder address - * @param to address recipient address - * @param amount uint256 amount of tokens to transfer - * @param userData bytes extra information provided by the token holder (if any) - * @param operatorData bytes extra information provided by the operator (if any) - * @param requireReceptionAck if true, contract recipients are required to implement ERC777TokensRecipient - */ - function _callTokensReceived( - address operator, - address from, - address to, - uint256 amount, - bytes memory userData, - bytes memory operatorData, - bool requireReceptionAck - ) - internal - { - address implementer = ERC1820_REGISTRY.getInterfaceImplementer(to, TOKENS_RECIPIENT_INTERFACE_HASH); - if (implementer != address(0)) { - IERC777Recipient(implementer).tokensReceived(operator, from, to, amount, userData, operatorData); - } else if (requireReceptionAck) { - require(!to.isContract(), "ERC777: token recipient contract has no implementer for ERC777TokensRecipient"); - } - } -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777.sol b/src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777.sol deleted file mode 100644 index b7f60da9..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777.sol +++ /dev/null @@ -1,186 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Interface of the ERC777Token standard as defined in the EIP. - * - * This contract uses the - * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 registry standard] to let - * token holders and recipients react to token movements by using setting implementers - * for the associated interfaces in said registry. See {IERC1820Registry} and - * {ERC1820Implementer}. - */ -interface IERC777 { - /** - * @dev Returns the name of the token. - */ - function name() external view returns (string memory); - - /** - * @dev Returns the symbol of the token, usually a shorter version of the - * name. - */ - function symbol() external view returns (string memory); - - /** - * @dev Returns the smallest part of the token that is not divisible. This - * means all token operations (creation, movement and destruction) must have - * amounts that are a multiple of this number. - * - * For most token contracts, this value will equal 1. - */ - function granularity() external view returns (uint256); - - /** - * @dev Returns the amount of tokens in existence. - */ - function totalSupply() external view returns (uint256); - - /** - * @dev Returns the amount of tokens owned by an account (`owner`). - */ - function balanceOf(address owner) external view returns (uint256); - - /** - * @dev Moves `amount` tokens from the caller's account to `recipient`. - * - * If send or receive hooks are registered for the caller and `recipient`, - * the corresponding functions will be called with `data` and empty - * `operatorData`. See {IERC777Sender} and {IERC777Recipient}. - * - * Emits a {Sent} event. - * - * Requirements - * - * - the caller must have at least `amount` tokens. - * - `recipient` cannot be the zero address. - * - if `recipient` is a contract, it must implement the {IERC777Recipient} - * interface. - */ - function send(address recipient, uint256 amount, bytes calldata data) external; - - /** - * @dev Destroys `amount` tokens from the caller's account, reducing the - * total supply. - * - * If a send hook is registered for the caller, the corresponding function - * will be called with `data` and empty `operatorData`. See {IERC777Sender}. - * - * Emits a {Burned} event. - * - * Requirements - * - * - the caller must have at least `amount` tokens. - */ - function burn(uint256 amount, bytes calldata data) external; - - /** - * @dev Returns true if an account is an operator of `tokenHolder`. - * Operators can send and burn tokens on behalf of their owners. All - * accounts are their own operator. - * - * See {operatorSend} and {operatorBurn}. - */ - function isOperatorFor(address operator, address tokenHolder) external view returns (bool); - - /** - * @dev Make an account an operator of the caller. - * - * See {isOperatorFor}. - * - * Emits an {AuthorizedOperator} event. - * - * Requirements - * - * - `operator` cannot be calling address. - */ - function authorizeOperator(address operator) external; - - /** - * @dev Make an account an operator of the caller. - * - * See {isOperatorFor} and {defaultOperators}. - * - * Emits a {RevokedOperator} event. - * - * Requirements - * - * - `operator` cannot be calling address. - */ - function revokeOperator(address operator) external; - - /** - * @dev Returns the list of default operators. These accounts are operators - * for all token holders, even if {authorizeOperator} was never called on - * them. - * - * This list is immutable, but individual holders may revoke these via - * {revokeOperator}, in which case {isOperatorFor} will return false. - */ - function defaultOperators() external view returns (address[] memory); - - /** - * @dev Moves `amount` tokens from `sender` to `recipient`. The caller must - * be an operator of `sender`. - * - * If send or receive hooks are registered for `sender` and `recipient`, - * the corresponding functions will be called with `data` and - * `operatorData`. See {IERC777Sender} and {IERC777Recipient}. - * - * Emits a {Sent} event. - * - * Requirements - * - * - `sender` cannot be the zero address. - * - `sender` must have at least `amount` tokens. - * - the caller must be an operator for `sender`. - * - `recipient` cannot be the zero address. - * - if `recipient` is a contract, it must implement the {IERC777Recipient} - * interface. - */ - function operatorSend( - address sender, - address recipient, - uint256 amount, - bytes calldata data, - bytes calldata operatorData - ) external; - - /** - * @dev Destoys `amount` tokens from `account`, reducing the total supply. - * The caller must be an operator of `account`. - * - * If a send hook is registered for `account`, the corresponding function - * will be called with `data` and `operatorData`. See {IERC777Sender}. - * - * Emits a {Burned} event. - * - * Requirements - * - * - `account` cannot be the zero address. - * - `account` must have at least `amount` tokens. - * - the caller must be an operator for `account`. - */ - function operatorBurn( - address account, - uint256 amount, - bytes calldata data, - bytes calldata operatorData - ) external; - - event Sent( - address indexed operator, - address indexed from, - address indexed to, - uint256 amount, - bytes data, - bytes operatorData - ); - - event Minted(address indexed operator, address indexed to, uint256 amount, bytes data, bytes operatorData); - - event Burned(address indexed operator, address indexed from, uint256 amount, bytes data, bytes operatorData); - - event AuthorizedOperator(address indexed operator, address indexed tokenHolder); - - event RevokedOperator(address indexed operator, address indexed tokenHolder); -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol b/src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol deleted file mode 100644 index bde2e7c5..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777Recipient.sol +++ /dev/null @@ -1,32 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP. - * - * Accounts can be notified of {IERC777} tokens being sent to them by having a - * contract implement this interface (contract holders can be their own - * implementer) and registering it on the - * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. - * - * See {IERC1820Registry} and {ERC1820Implementer}. - */ -interface IERC777Recipient { - /** - * @dev Called by an {IERC777} token contract whenever tokens are being - * moved or created into a registered account (`to`). The type of operation - * is conveyed by `from` being the zero address or not. - * - * This call occurs _after_ the token contract's state is updated, so - * {IERC777-balanceOf}, etc., can be used to query the post-operation state. - * - * This function may revert to prevent the operation from being executed. - */ - function tokensReceived( - address operator, - address from, - address to, - uint256 amount, - bytes calldata userData, - bytes calldata operatorData - ) external; -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777Sender.sol b/src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777Sender.sol deleted file mode 100644 index d0662ca1..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC777/IERC777Sender.sol +++ /dev/null @@ -1,32 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Interface of the ERC777TokensSender standard as defined in the EIP. - * - * {IERC777} Token holders can be notified of operations performed on their - * tokens by having a contract implement this interface (contract holders can be - * their own implementer) and registering it on the - * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry]. - * - * See {IERC1820Registry} and {ERC1820Implementer}. - */ -interface IERC777Sender { - /** - * @dev Called by an {IERC777} token contract whenever a registered holder's - * (`from`) tokens are about to be moved or destroyed. The type of operation - * is conveyed by `to` being the zero address or not. - * - * This call occurs _before_ the token contract's state is updated, so - * {IERC777-balanceOf}, etc., can be used to query the pre-operation state. - * - * This function may revert to prevent the operation from being executed. - */ - function tokensToSend( - address operator, - address from, - address to, - uint256 amount, - bytes calldata userData, - bytes calldata operatorData - ) external; -} diff --git a/src/node_modules/@openzeppelin/contracts/token/ERC777/README.adoc b/src/node_modules/@openzeppelin/contracts/token/ERC777/README.adoc deleted file mode 100644 index d1fa6e6d..00000000 --- a/src/node_modules/@openzeppelin/contracts/token/ERC777/README.adoc +++ /dev/null @@ -1,20 +0,0 @@ -= ERC 777 -This set of interfaces and contracts are all related to the [ERC777 token standard](https://eips.ethereum.org/EIPS/eip-777). - -TIP: For an overview of ERC777 tokens and a walkthrough on how to create a token contract read our xref:ROOT:tokens.adoc#ERC777[ERC777 guide]. - -The token behavior itself is implemented in the core contracts: {IERC777}, {ERC777}. - -Additionally there are interfaces used to develop contracts that react to token movements: {IERC777Sender}, {IERC777Recipient}. - -== Core - -{{IERC777}} - -{{ERC777}} - -== Hooks - -{{IERC777Sender}} - -{{IERC777Recipient}} diff --git a/src/node_modules/@openzeppelin/contracts/utils/Address.sol b/src/node_modules/@openzeppelin/contracts/utils/Address.sol deleted file mode 100644 index 3dc496d4..00000000 --- a/src/node_modules/@openzeppelin/contracts/utils/Address.sol +++ /dev/null @@ -1,70 +0,0 @@ -pragma solidity ^0.5.5; - -/** - * @dev Collection of functions related to the address type - */ -library Address { - /** - * @dev Returns true if `account` is a contract. - * - * [IMPORTANT] - * ==== - * It is unsafe to assume that an address for which this function returns - * false is an externally-owned account (EOA) and not a contract. - * - * Among others, `isContract` will return false for the following - * types of addresses: - * - * - an externally-owned account - * - a contract in construction - * - an address where a contract will be created - * - an address where a contract lived, but was destroyed - * ==== - */ - function isContract(address account) internal view returns (bool) { - // According to EIP-1052, 0x0 is the value returned for not-yet created accounts - // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned - // for accounts without code, i.e. `keccak256('')` - bytes32 codehash; - bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; - // solhint-disable-next-line no-inline-assembly - assembly { codehash := extcodehash(account) } - return (codehash != accountHash && codehash != 0x0); - } - - /** - * @dev Converts an `address` into `address payable`. Note that this is - * simply a type cast: the actual underlying value is not changed. - * - * _Available since v2.4.0._ - */ - function toPayable(address account) internal pure returns (address payable) { - return address(uint160(account)); - } - - /** - * @dev Replacement for Solidity's `transfer`: sends `amount` wei to - * `recipient`, forwarding all available gas and reverting on errors. - * - * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost - * of certain opcodes, possibly making contracts go over the 2300 gas limit - * imposed by `transfer`, making them unable to receive funds via - * `transfer`. {sendValue} removes this limitation. - * - * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. - * - * IMPORTANT: because control is transferred to `recipient`, care must be - * taken to not create reentrancy vulnerabilities. Consider using - * {ReentrancyGuard} or the - * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. - * - * _Available since v2.4.0._ - */ - function sendValue(address payable recipient, uint256 amount) internal { - require(address(this).balance >= amount, "Address: insufficient balance"); - - // solhint-disable-next-line avoid-call-value - (bool success, ) = recipient.call.value(amount)(""); - require(success, "Address: unable to send value, recipient may have reverted"); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/utils/Arrays.sol b/src/node_modules/@openzeppelin/contracts/utils/Arrays.sol deleted file mode 100644 index eb0deb16..00000000 --- a/src/node_modules/@openzeppelin/contracts/utils/Arrays.sol +++ /dev/null @@ -1,45 +0,0 @@ -pragma solidity ^0.5.0; - -import "../math/Math.sol"; - -/** - * @dev Collection of functions related to array types. - */ -library Arrays { - /** - * @dev Searches a sorted `array` and returns the first index that contains - * a value greater or equal to `element`. If no such index exists (i.e. all - * values in the array are strictly less than `element`), the array length is - * returned. Time complexity O(log n). - * - * `array` is expected to be sorted in ascending order, and to contain no - * repeated elements. - */ - function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) { - if (array.length == 0) { - return 0; - } - - uint256 low = 0; - uint256 high = array.length; - - while (low < high) { - uint256 mid = Math.average(low, high); - - // Note that mid will always be strictly less than high (i.e. it will be a valid array index) - // because Math.average rounds down (it does integer division with truncation). - if (array[mid] > element) { - high = mid; - } else { - low = mid + 1; - } - } - - // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound. - if (low > 0 && array[low - 1] == element) { - return low - 1; - } else { - return low; - } - } -} diff --git a/src/node_modules/@openzeppelin/contracts/utils/Create2.sol b/src/node_modules/@openzeppelin/contracts/utils/Create2.sol deleted file mode 100644 index e055ea85..00000000 --- a/src/node_modules/@openzeppelin/contracts/utils/Create2.sol +++ /dev/null @@ -1,49 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer. - * `CREATE2` can be used to compute in advance the address where a smart - * contract will be deployed, which allows for interesting new mechanisms known - * as 'counterfactual interactions'. - * - * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more - * information. - * - * _Available since v2.5.0._ - */ -library Create2 { - /** - * @dev Deploys a contract using `CREATE2`. The address where the contract - * will be deployed can be known in advance via {computeAddress}. Note that - * a contract cannot be deployed twice using the same salt. - */ - function deploy(bytes32 salt, bytes memory bytecode) internal returns (address) { - address addr; - // solhint-disable-next-line no-inline-assembly - assembly { - addr := create2(0, add(bytecode, 0x20), mload(bytecode), salt) - } - require(addr != address(0), "Create2: Failed on deploy"); - return addr; - } - - /** - * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the `bytecode` - * or `salt` will result in a new destination address. - */ - function computeAddress(bytes32 salt, bytes memory bytecode) internal view returns (address) { - return computeAddress(salt, bytecode, address(this)); - } - - /** - * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at - * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. - */ - function computeAddress(bytes32 salt, bytes memory bytecodeHash, address deployer) internal pure returns (address) { - bytes32 bytecodeHashHash = keccak256(bytecodeHash); - bytes32 _data = keccak256( - abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHashHash) - ); - return address(bytes20(_data << 96)); - } -} diff --git a/src/node_modules/@openzeppelin/contracts/utils/EnumerableSet.sol b/src/node_modules/@openzeppelin/contracts/utils/EnumerableSet.sol deleted file mode 100644 index 2ea0d169..00000000 --- a/src/node_modules/@openzeppelin/contracts/utils/EnumerableSet.sol +++ /dev/null @@ -1,138 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Library for managing - * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive - * types. - * - * Sets have the following properties: - * - * - Elements are added, removed, and checked for existence in constant time - * (O(1)). - * - Elements are enumerated in O(n). No guarantees are made on the ordering. - * - * As of v2.5.0, only `address` sets are supported. - * - * Include with `using EnumerableSet for EnumerableSet.AddressSet;`. - * - * _Available since v2.5.0._ - * - * @author Alberto Cuesta Cañada - */ -library EnumerableSet { - - struct AddressSet { - // Position of the value in the `values` array, plus 1 because index 0 - // means a value is not in the set. - mapping (address => uint256) index; - address[] values; - } - - /** - * @dev Add a value to a set. O(1). - * Returns false if the value was already in the set. - */ - function add(AddressSet storage set, address value) - internal - returns (bool) - { - if (!contains(set, value)){ - set.index[value] = set.values.push(value); - return true; - } else { - return false; - } - } - - /** - * @dev Removes a value from a set. O(1). - * Returns false if the value was not present in the set. - */ - function remove(AddressSet storage set, address value) - internal - returns (bool) - { - if (contains(set, value)){ - uint256 toDeleteIndex = set.index[value] - 1; - uint256 lastIndex = set.values.length - 1; - - // If the element we're deleting is the last one, we can just remove it without doing a swap - if (lastIndex != toDeleteIndex) { - address lastValue = set.values[lastIndex]; - - // Move the last value to the index where the deleted value is - set.values[toDeleteIndex] = lastValue; - // Update the index for the moved value - set.index[lastValue] = toDeleteIndex + 1; // All indexes are 1-based - } - - // Delete the index entry for the deleted value - delete set.index[value]; - - // Delete the old entry for the moved value - set.values.pop(); - - return true; - } else { - return false; - } - } - - /** - * @dev Returns true if the value is in the set. O(1). - */ - function contains(AddressSet storage set, address value) - internal - view - returns (bool) - { - return set.index[value] != 0; - } - - /** - * @dev Returns an array with all values in the set. O(N). - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - - * WARNING: This function may run out of gas on large sets: use {length} and - * {get} instead in these cases. - */ - function enumerate(AddressSet storage set) - internal - view - returns (address[] memory) - { - address[] memory output = new address[](set.values.length); - for (uint256 i; i < set.values.length; i++){ - output[i] = set.values[i]; - } - return output; - } - - /** - * @dev Returns the number of elements on the set. O(1). - */ - function length(AddressSet storage set) - internal - view - returns (uint256) - { - return set.values.length; - } - - /** @dev Returns the element stored at position `index` in the set. O(1). - * Note that there are no guarantees on the ordering of values inside the - * array, and it may change when more values are added or removed. - * - * Requirements: - * - * - `index` must be strictly less than {length}. - */ - function get(AddressSet storage set, uint256 index) - internal - view - returns (address) - { - return set.values[index]; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/utils/README.adoc b/src/node_modules/@openzeppelin/contracts/utils/README.adoc deleted file mode 100644 index e994449a..00000000 --- a/src/node_modules/@openzeppelin/contracts/utils/README.adoc +++ /dev/null @@ -1,17 +0,0 @@ -= Utilities - -Miscellaneous contracts containing utility functions, often related to working with different data types. - -== Contracts - -{{Address}} - -{{SafeCast}} - -{{Arrays}} - -{{EnumerableSet}} - -{{Create2}} - -{{ReentrancyGuard}} diff --git a/src/node_modules/@openzeppelin/contracts/utils/ReentrancyGuard.sol b/src/node_modules/@openzeppelin/contracts/utils/ReentrancyGuard.sol deleted file mode 100644 index 762938d9..00000000 --- a/src/node_modules/@openzeppelin/contracts/utils/ReentrancyGuard.sol +++ /dev/null @@ -1,55 +0,0 @@ -pragma solidity ^0.5.0; - -/** - * @dev Contract module that helps prevent reentrant calls to a function. - * - * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier - * available, which can be applied to functions to make sure there are no nested - * (reentrant) calls to them. - * - * Note that because there is a single `nonReentrant` guard, functions marked as - * `nonReentrant` may not call one another. This can be worked around by making - * those functions `private`, and then adding `external` `nonReentrant` entry - * points to them. - * - * TIP: If you would like to learn more about reentrancy and alternative ways - * to protect against it, check out our blog post - * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. - * - * _Since v2.5.0:_ this module is now much more gas efficient, given net gas - * metering changes introduced in the Istanbul hardfork. - */ -contract ReentrancyGuard { - bool private _notEntered; - - constructor () internal { - // Storing an initial non-zero value makes deployment a bit more - // expensive, but in exchange the refund on every call to nonReentrant - // will be lower in amount. Since refunds are capped to a percetange of - // the total transaction's gas, it is best to keep them low in cases - // like this one, to increase the likelihood of the full refund coming - // into effect. - _notEntered = true; - } - - /** - * @dev Prevents a contract from calling itself, directly or indirectly. - * Calling a `nonReentrant` function from another `nonReentrant` - * function is not supported. It is possible to prevent this from happening - * by making the `nonReentrant` function external, and make it call a - * `private` function that does the actual work. - */ - modifier nonReentrant() { - // On the first call to nonReentrant, _notEntered will be true - require(_notEntered, "ReentrancyGuard: reentrant call"); - - // Any calls to nonReentrant after this point will fail - _notEntered = false; - - _; - - // By storing the original value once again, a refund is triggered (see - // https://eips.ethereum.org/EIPS/eip-2200) - _notEntered = true; - } -} diff --git a/src/node_modules/@openzeppelin/contracts/utils/SafeCast.sol b/src/node_modules/@openzeppelin/contracts/utils/SafeCast.sol deleted file mode 100644 index 5846190e..00000000 --- a/src/node_modules/@openzeppelin/contracts/utils/SafeCast.sol +++ /dev/null @@ -1,97 +0,0 @@ -pragma solidity ^0.5.0; - - -/** - * @dev Wrappers over Solidity's uintXX casting operators with added overflow - * checks. - * - * Downcasting from uint256 in Solidity does not revert on overflow. This can - * easily result in undesired exploitation or bugs, since developers usually - * assume that overflows raise errors. `SafeCast` restores this intuition by - * reverting the transaction when such an operation overflows. - * - * Using this library instead of the unchecked operations eliminates an entire - * class of bugs, so it's recommended to use it always. - * - * Can be combined with {SafeMath} to extend it to smaller types, by performing - * all math on `uint256` and then downcasting. - * - * _Available since v2.5.0._ - */ -library SafeCast { - - /** - * @dev Returns the downcasted uint128 from uint256, reverting on - * overflow (when the input is greater than largest uint128). - * - * Counterpart to Solidity's `uint128` operator. - * - * Requirements: - * - * - input must fit into 128 bits - */ - function toUint128(uint256 value) internal pure returns (uint128) { - require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits"); - return uint128(value); - } - - /** - * @dev Returns the downcasted uint64 from uint256, reverting on - * overflow (when the input is greater than largest uint64). - * - * Counterpart to Solidity's `uint64` operator. - * - * Requirements: - * - * - input must fit into 64 bits - */ - function toUint64(uint256 value) internal pure returns (uint64) { - require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits"); - return uint64(value); - } - - /** - * @dev Returns the downcasted uint32 from uint256, reverting on - * overflow (when the input is greater than largest uint32). - * - * Counterpart to Solidity's `uint32` operator. - * - * Requirements: - * - * - input must fit into 32 bits - */ - function toUint32(uint256 value) internal pure returns (uint32) { - require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits"); - return uint32(value); - } - - /** - * @dev Returns the downcasted uint16 from uint256, reverting on - * overflow (when the input is greater than largest uint16). - * - * Counterpart to Solidity's `uint16` operator. - * - * Requirements: - * - * - input must fit into 16 bits - */ - function toUint16(uint256 value) internal pure returns (uint16) { - require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits"); - return uint16(value); - } - - /** - * @dev Returns the downcasted uint8 from uint256, reverting on - * overflow (when the input is greater than largest uint8). - * - * Counterpart to Solidity's `uint8` operator. - * - * Requirements: - * - * - input must fit into 8 bits. - */ - function toUint8(uint256 value) internal pure returns (uint8) { - require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits"); - return uint8(value); - } -} diff --git a/src/package-lock.json b/src/package-lock.json deleted file mode 100644 index a526f732..00000000 --- a/src/package-lock.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "src", - "lockfileVersion": 2, - "requires": true, - "packages": { - "": { - "dependencies": { - "@openzeppelin/contracts": "^2.5.1" - } - }, - "node_modules/@openzeppelin/contracts": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-2.5.1.tgz", - "integrity": "sha512-qIy6tLx8rtybEsIOAlrM4J/85s2q2nPkDqj/Rx46VakBZ0LwtFhXIVub96LXHczQX0vaqmAueDqNPXtbSXSaYQ==" - } - }, - "dependencies": { - "@openzeppelin/contracts": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-2.5.1.tgz", - "integrity": "sha512-qIy6tLx8rtybEsIOAlrM4J/85s2q2nPkDqj/Rx46VakBZ0LwtFhXIVub96LXHczQX0vaqmAueDqNPXtbSXSaYQ==" - } - } -} diff --git a/src/package.json b/src/package.json deleted file mode 100644 index 28876a3d..00000000 --- a/src/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "@openzeppelin/contracts": "^2.5.1" - } -} diff --git a/src/python/.flake8 b/src/python/.flake8 deleted file mode 100644 index 87739279..00000000 --- a/src/python/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -max_line_length=80 -ignore = E203, E266, E501, W503 -select = B,C,E,F,W,T4,B9 diff --git a/src/python/.gitignore b/src/python/.gitignore deleted file mode 100644 index 3864a164..00000000 --- a/src/python/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.egg* -*.pyc diff --git a/src/python/Makefile b/src/python/Makefile deleted file mode 100644 index 92c9f9ba..00000000 --- a/src/python/Makefile +++ /dev/null @@ -1,85 +0,0 @@ -.PHONY: clean clean-test clean-pyc clean-build docs help -.DEFAULT_GOAL := help - -define BROWSER_PYSCRIPT -import os, webbrowser, sys - -from urllib.request import pathname2url - -webbrowser.open("http://localhost:57781/" + sys.argv[1]) -endef -export BROWSER_PYSCRIPT - -define PRINT_HELP_PYSCRIPT -import re, sys - -for line in sys.stdin: - match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) - if match: - target, help = match.groups() - print("%-20s %s" % (target, help)) -endef -export PRINT_HELP_PYSCRIPT - -BROWSER := python -c "$$BROWSER_PYSCRIPT" - -help: - @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) - -clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts - -clean-build: ## remove build artifacts - rm -fr build/ - rm -fr dist/ - rm -fr .eggs/ - find . -name '*.egg-info' -exec rm -fr {} + - find . -name '*.egg' -exec rm -f {} + - -clean-pyc: ## remove Python file artifacts - find . -name '*.pyc' -exec rm -f {} + - find . -name '*.pyo' -exec rm -f {} + - find . -name '*~' -exec rm -f {} + - find . -name '__pycache__' -exec rm -fr {} + - -clean-test: ## remove test and coverage artifacts - rm -fr .tox/ - rm -f .coverage - rm -fr htmlcov/ - rm -fr .pytest_cache - -lint: ## check style with flake8 - flake8 honeybadgerswap tests - -test: ## run tests quickly with the default Python - pytest - -test-all: ## run tests on every Python version with tox - tox - -coverage: ## check code coverage quickly with the default Python - pytest --verbose --cov --cov-report=term-missing --cov-report=html - -docs: ## generate Sphinx HTML documentation - docker-compose -f docs.yml run --rm builddocs make -C docs clean - docker-compose -f docs.yml up builddocs - docker-compose -f docs.yml stop viewdocs - docker-compose -f docs.yml up -d viewdocs - -servedocs: docs ## compile the docs watching for changes - docker-compose -f docs.yml stop viewdocs - docker-compose -f docs.yml up -d viewdocs - $(BROWSER) index.html - -release: dist ## package and upload a release - twine upload dist/* - -dist: clean ## builds source and wheel package - python setup.py sdist - python setup.py bdist_wheel - ls -l dist - -install: clean ## install the package to the active Python's site-packages - python setup.py install - -develop: clean - pip install --editable . diff --git a/src/python/README.md b/src/python/README.md deleted file mode 100644 index 54b971e1..00000000 --- a/src/python/README.md +++ /dev/null @@ -1 +0,0 @@ -# HoneyBadgerSwap Python Functions diff --git a/src/python/__init__.py b/src/python/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/python/fastapi.yml b/src/python/fastapi.yml deleted file mode 100644 index 5f8fe818..00000000 --- a/src/python/fastapi.yml +++ /dev/null @@ -1,18 +0,0 @@ -version: '3.8' - -services: - - mpcnode0: - image: hbswap:local - build: - context: . - dockerfile: Dockerfile - ports: - - 58123:8123 - volumes: - - ./src/python:/usr/src/honeybadgerswap-python - - ./poa/keystore:/opt/poa/keystore - secrets: - - P0.key - working_dir: /usr/src/honeybadgerswap-python/honeybadgerswap/server - command: ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8123"] diff --git a/src/python/honeybadgerswap/__init__.py b/src/python/honeybadgerswap/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/python/honeybadgerswap/client/Client.py b/src/python/honeybadgerswap/client/Client.py deleted file mode 100644 index 5e088037..00000000 --- a/src/python/honeybadgerswap/client/Client.py +++ /dev/null @@ -1,123 +0,0 @@ -import asyncio -import re -import toml - -from aiohttp import ClientSession - -from ..utils import get_inverse, p - - -class Client: - def __init__(self, n, t, servers): - self.n = n - self.t = t - self.servers = servers - - @classmethod - def from_toml_config(self, config_file): - config = toml.load(config_file) - - n = config["N"] - t = config["T"] - servers = config["Servers"] - - return Client(n, t, servers) - - async def send_request(self, url): - async with ClientSession() as session: - async with session.get(url) as resp: - json_response = await resp.json() - return json_response - - def interpolate(self, shares): - inputmask = 0 - for i in range(1, self.n + 1): - tot = 1 - for j in range(1, self.n + 1): - if i == j: - continue - tot = tot * j * get_inverse(j - i) % p - inputmask = (inputmask + shares[i - 1] * tot) % p - return inputmask - - # **** call from remote client **** - async def req_inputmask_shares(self, host, port, inputmask_idxes): - url = f"http://{host}:{port}/inputmasks/{inputmask_idxes}" - result = await self.send_request(url) - return re.split(",", result["inputmask_shares"]) - - async def get_inputmasks(self, inputmask_idxes): - tasks = [] - for server in self.servers: - host = server["Host"] - port = server["HttpPort"] - - task = asyncio.ensure_future( - self.req_inputmask_shares(host, port, inputmask_idxes) - ) - tasks.append(task) - - for task in tasks: - await task - - inputmask_shares = [] - for task in tasks: - inputmask_shares.append(task.result()) - - inputmasks = [] - for i in range(len(tasks[0].result())): - shares = [] - for j in range(len(self.servers)): - shares.append(int(inputmask_shares[j][i])) - inputmasks.append(self.interpolate(shares)) - return inputmasks - - async def req_balance_shares(self, host, port, token, user): - url = f"http://{host}:{port}/balance/{token},{user}" - result = await self.send_request(url) - return result["balance"] - - async def get_balance(self, token, user): - tasks = [] - for server in self.servers: - host = server["Host"] - port = server["HttpPort"] - - task = asyncio.ensure_future( - self.req_balance_shares(host, port, token, user) - ) - tasks.append(task) - - for task in tasks: - await task - - shares = [] - for task in tasks: - shares.append(int(task.result())) - - balance = self.interpolate(shares) - return balance - - async def req_price(self, host, port, seq): - url = f"http://{host}:{port}/price/{seq}" - result = await self.send_request(url) - return result["price"] - - async def get_price(self, seq): - tasks = [] - for server in self.servers: - host = server["Host"] - port = server["HttpPort"] - - task = asyncio.ensure_future(self.req_price(host, port, seq)) - tasks.append(task) - - for task in tasks: - await task - - shares = [] - for task in tasks: - shares.append(int(task.result())) - - price = self.interpolate(shares) - return price diff --git a/src/python/honeybadgerswap/client/__init__.py b/src/python/honeybadgerswap/client/__init__.py deleted file mode 100644 index 153b5ff7..00000000 --- a/src/python/honeybadgerswap/client/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .Client import Client # noqa F401 diff --git a/src/python/honeybadgerswap/client/req_balance.py b/src/python/honeybadgerswap/client/req_balance.py deleted file mode 100644 index 043c9856..00000000 --- a/src/python/honeybadgerswap/client/req_balance.py +++ /dev/null @@ -1,18 +0,0 @@ -import asyncio -import os -import sys - -from .Client import Client - -from ..utils import fp - -if __name__ == "__main__": - token = sys.argv[1] - user = sys.argv[2] - - config = os.getenv("HBSWAP_CLIENT_CONFIG", "/opt/hbswap/conf/client.toml") - client = Client.from_toml_config(config) - - balance = asyncio.run(client.get_balance(token, user)) - balance = 1.0 * balance / (2 ** fp) - print(balance) diff --git a/src/python/honeybadgerswap/client/req_inputmasks.py b/src/python/honeybadgerswap/client/req_inputmasks.py deleted file mode 100644 index c47622ff..00000000 --- a/src/python/honeybadgerswap/client/req_inputmasks.py +++ /dev/null @@ -1,31 +0,0 @@ -import asyncio -import os -import sys - -from .Client import Client - -from ..utils import float_to_fix - -if __name__ == "__main__": - config = os.getenv("HBSWAP_CLIENT_CONFIG", "/opt/hbswap/conf/client.toml") - client = Client.from_toml_config(config) - - inputmask_indexes = "" - for inputmask_index in sys.argv[1::2]: - inputmask_indexes += f"{inputmask_index}," - inputmask_indexes = inputmask_indexes[:-1] - - inputmasks = asyncio.run(client.get_inputmasks(inputmask_indexes)) - - values = [] - for value in sys.argv[2::2]: - values.append(float_to_fix(value)) - - masked_values = [] - for (inputmask, value) in zip(inputmasks, values): - masked_values.append(value + inputmask) - - out = "" - for masked_value in masked_values: - out += f"{masked_value} " - print(out) diff --git a/src/python/honeybadgerswap/client/req_price.py b/src/python/honeybadgerswap/client/req_price.py deleted file mode 100644 index 1c6bebcb..00000000 --- a/src/python/honeybadgerswap/client/req_price.py +++ /dev/null @@ -1,17 +0,0 @@ -import asyncio -import os -import sys - -from Client import Client - -from ..utils import fp - -if __name__ == "__main__": - seq = sys.argv[1] - - config = os.getenv("HBSWAP_CLIENT_CONFIG", "/opt/hbswap/conf/client.toml") - client = Client.from_toml_config(config) - - price = asyncio.run(client.get_price(seq)) - price = 1.0 * price / (2 ** fp) - print(price) diff --git a/src/python/honeybadgerswap/server/Server.py b/src/python/honeybadgerswap/server/Server.py deleted file mode 100644 index 053d0000..00000000 --- a/src/python/honeybadgerswap/server/Server.py +++ /dev/null @@ -1,136 +0,0 @@ -import aiohttp_cors -import asyncio -import re - -from aiohttp import web - -from .config import settings -from ..utils import ( - key_balance, - key_inputmask, - key_individual_price, - location_db, - openDB, - get_value, - hex_to_int, -) - - -# async def db_get(key): -# db = openDB(location_db(settings.NODE_ID)) -# return hex_to_int(get_value(db, key)) -# -# -# async def db_get_non_balance(key): -# while True: -# v = await db_get(key) -# if v == 0: -# print(f"{key} not ready. Try again...") -# time.sleep(10) -# else: -# return v - -# async def db_get(key): -# db = openDB(location_db(settings.NODE_ID)) -# return hex_to_int(get_value(db, key)) - -async def http_server(): - async def handler_inputmask(request): - print(f"s{settings.NODE_ID} request: {request}") - mask_idxes = re.split(",", request.match_info.get("mask_idxes")) - res = "" - for mask_idx in mask_idxes: - db = openDB(location_db(settings.NODE_ID)) - try: - share = db.Get(key_inputmask(mask_idx)) - except KeyError: - res = '' - break - res += ( - f"{',' if len(res) > 0 else share}" - ) - data = { - "inputmask_shares": res, - } - print(f"s{settings.NODE_ID} response: {res}") - return web.json_response(data) - - async def handler_price(request): - print(f"s{settings.NODE_ID} request: {request}") - trade_seq = request.match_info.get("trade_seq") - - # cur_time = int(time.time()) - # prev_time = await db_get_non_balance(key_trade_time(trade_seq)) - # passed_time = cur_time - prev_time - # time.sleep(max(0, 10 - passed_time)) - - db = openDB(location_db(settings.NODE_ID)) - res = '' - try: - res = db.Get(key_individual_price(trade_seq)) - except KeyError: - pass - data = { - "price": f"{res}", - } - print(f"s{settings.NODE_ID} response: {res}") - return web.json_response(data) - - async def handler_balance(request): - print(f"s{settings.NODE_ID} request: {request}") - token_user = re.split(",", request.match_info.get("token_user")) - token = token_user[0] - user = token_user[1] - db = openDB(location_db(settings.NODE_ID)) - res = await get_value(db, key_balance(token, user)) - data = { - "balance": f"{res}", - } - print(f"s{settings.NODE_ID} response: {res}") - return web.json_response(data) - - async def handler_log(request): - print(f"s{settings.NODE_ID} request: {request}") - n = int(request.match_info.get("n")) - log_file = open(f"/usr/src/hbswap/log/mpc_server_{settings.NODE_ID}.log", "r") - lines = log_file.readlines() - last_lines = lines[-n:] - res = "" - for line in last_lines: - res += line - data = { - "log": f"{res}", - } - print(f"s{settings.NODE_ID} response: {res}") - return web.json_response(data) - - app = web.Application() - - cors = aiohttp_cors.setup( - app, - defaults={ - "*": aiohttp_cors.ResourceOptions( - allow_credentials=True, expose_headers="*", allow_headers="*", - ) - }, - ) - - resource = cors.add(app.router.add_resource("/inputmasks/{mask_idxes}")) - cors.add(resource.add_route("GET", handler_inputmask)) - resource = cors.add(app.router.add_resource("/price/{trade_seq}")) - cors.add(resource.add_route("GET", handler_price)) - resource = cors.add(app.router.add_resource("/balance/{token_user}")) - cors.add(resource.add_route("GET", handler_balance)) - resource = cors.add(app.router.add_resource("/log/{n}")) - cors.add(resource.add_route("GET", handler_log)) - - print(f"http server {settings.NODE_ID} is starting ...") - runner = web.AppRunner(app) - await runner.setup() - site = web.TCPSite( - runner, - host=settings.Servers[settings.NODE_ID]["HttpHost"], - port=settings.Servers[settings.NODE_ID]["HttpPort"], - ) - await site.start() - await asyncio.sleep(100 * 3600) \ No newline at end of file diff --git a/src/python/honeybadgerswap/server/__init__.py b/src/python/honeybadgerswap/server/__init__.py deleted file mode 100644 index 1eeeaa30..00000000 --- a/src/python/honeybadgerswap/server/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .Server import http_server # noqa F401 diff --git a/src/python/honeybadgerswap/server/add_liquidity_org_data.py b/src/python/honeybadgerswap/server/add_liquidity_org_data.py deleted file mode 100644 index ffe1f5e2..00000000 --- a/src/python/honeybadgerswap/server/add_liquidity_org_data.py +++ /dev/null @@ -1,42 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - key_pool, - key_total_supply, - location_db, - location_sharefile, - openDB, - sz, -) - -input_parameter_num = 8 - -if __name__ == "__main__": - server_id = sys.argv[1] - user = sys.argv[2] - token_A = sys.argv[3] - token_B = sys.argv[4] - - file = location_sharefile(server_id) - with open(file, "rb") as f: - f.seek(input_parameter_num * sz) - pool_A = f.read(sz) - pool_B = f.read(sz) - balance_A = f.read(sz) - balance_B = f.read(sz) - balance_LT = f.read(sz) - total_supply_LT = f.read(sz) - - db = openDB(location_db(server_id)) - - db.Put(key_pool(token_A, token_B, token_A), pool_A) - db.Put(key_pool(token_A, token_B, token_B), pool_B) - - db.Put(key_balance(token_A, user), balance_A) - db.Put(key_balance(token_B, user), balance_B) - db.Put(key_balance(f'{token_A}+{token_B}', user), balance_LT) - - db.Put(key_total_supply(token_A, token_B), total_supply_LT) - - diff --git a/src/python/honeybadgerswap/server/add_liquidity_set_data.py b/src/python/honeybadgerswap/server/add_liquidity_set_data.py deleted file mode 100644 index 0a623ac8..00000000 --- a/src/python/honeybadgerswap/server/add_liquidity_set_data.py +++ /dev/null @@ -1,50 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - key_pool, - key_total_supply, - location_db, - location_sharefile, - openDB, - get_value, - recover_input -) - -if __name__ == "__main__": - server_id = sys.argv[1] - user = sys.argv[2] - token_A = sys.argv[3] - token_B = sys.argv[4] - idx_A = sys.argv[5] - masked_amt_A = int(sys.argv[6]) # fix - idx_B = sys.argv[7] - masked_amt_B = int(sys.argv[8]) # fix - - db = openDB(location_db(server_id)) - - balance_A = get_value(db, key_balance(token_A, user)) # hex - amt_A = recover_input(db, masked_amt_A, idx_A) # hex - - balance_B = get_value(db, key_balance(token_B, user)) # hex - amt_B = recover_input(db, masked_amt_B, idx_B) # hex - - total_supply_LT = get_value(db, key_total_supply(token_A, token_B)) # hex - - pool_A = get_value(db, key_pool(token_A, token_B, token_A)) # hex - pool_B = get_value(db, key_pool(token_A, token_B, token_B)) # hex - - balance_LT = get_value(db, key_balance(f'{token_A}+{token_B}', user)) # hex - - file = location_sharefile(server_id) - with open(file, "wb") as f: - f.write( - balance_A + - amt_A + - balance_B + - amt_B + - total_supply_LT + - pool_A + - pool_B + - balance_LT - ) diff --git a/src/python/honeybadgerswap/server/calc_batch_price_org_data.py b/src/python/honeybadgerswap/server/calc_batch_price_org_data.py deleted file mode 100644 index 27b3d7a8..00000000 --- a/src/python/honeybadgerswap/server/calc_batch_price_org_data.py +++ /dev/null @@ -1,28 +0,0 @@ -import sys - -from ..utils import( - key_total_price, - key_total_cnt, - location_db, - location_private_output, - openDB, - fix_to_float, - hex_to_int, - sz, - display_precision -) - -if __name__ == "__main__": - server_id = sys.argv[1] - token_A = sys.argv[2] - token_B = sys.argv[3] - - db = openDB(location_db(server_id)) - - db.Delete(key_total_price(token_A, token_B)) - db.Delete(key_total_cnt(token_A, token_B)) - - file = location_private_output(server_id) - with open(file, "rb") as f: - batch_price = fix_to_float(hex_to_int(f.read(sz))) - print('{:.{}f}'.format(batch_price, display_precision)) diff --git a/src/python/honeybadgerswap/server/calc_batch_price_set_data.py b/src/python/honeybadgerswap/server/calc_batch_price_set_data.py deleted file mode 100644 index db5deb71..00000000 --- a/src/python/honeybadgerswap/server/calc_batch_price_set_data.py +++ /dev/null @@ -1,32 +0,0 @@ -import sys - -from ..utils import( - key_total_price, - key_total_cnt, - location_db, - location_sharefile, - openDB, - get_value, - fix_to_float, - hex_to_int -) - -if __name__=='__main__': - server_id = sys.argv[1] - token_A = sys.argv[2] - token_B = sys.argv[3] - - db = openDB(location_db(server_id)) - - total_price = get_value(db, key_total_price(token_A, token_B)) # hex - - total_cnt = get_value(db, key_total_cnt(token_A, token_B)) # hex - cnt = fix_to_float(hex_to_int(total_cnt)) - print('cnt', cnt) - - file = location_sharefile(server_id) - with open(file, 'wb') as f: - f.write( - total_price + - total_cnt - ) \ No newline at end of file diff --git a/src/python/honeybadgerswap/server/calc_individual_price_org_data.py b/src/python/honeybadgerswap/server/calc_individual_price_org_data.py deleted file mode 100644 index 4bf06a61..00000000 --- a/src/python/honeybadgerswap/server/calc_individual_price_org_data.py +++ /dev/null @@ -1,40 +0,0 @@ -import sys - -from ..utils import ( - key_individual_price, - key_total_price, - key_total_cnt, - location_db, - location_sharefile, - openDB, - get_value, - hex_to_int, - int_to_hex, - sz, - fp -) - -input_parameter_num = 3 - -if __name__ == "__main__": - server_id = sys.argv[1] - token_A = sys.argv[2] - token_B = sys.argv[3] - trade_seq = sys.argv[4] - - file = location_sharefile(server_id) - with open(file, "rb") as f: - f.seek(input_parameter_num * sz) - price = f.read(sz) # hex - total_price = f.read(sz) # hex - - db = openDB(location_db(server_id)) - - db.Put(key_total_price(token_A, token_B), total_price) - - k_total_cnt = key_total_cnt(token_A, token_B) - total_cnt = get_value(db, k_total_cnt) # hex - total_cnt = hex_to_int(total_cnt) + fp # int - db.Put(k_total_cnt, int_to_hex(total_cnt)) - - db.Put(key_individual_price(trade_seq), price) \ No newline at end of file diff --git a/src/python/honeybadgerswap/server/calc_individual_price_set_data.py b/src/python/honeybadgerswap/server/calc_individual_price_set_data.py deleted file mode 100644 index e0bfb254..00000000 --- a/src/python/honeybadgerswap/server/calc_individual_price_set_data.py +++ /dev/null @@ -1,33 +0,0 @@ -import sys - -from ..utils import ( - key_total_price, - location_db, - location_sharefile, - openDB, - get_value, - int_to_hex, - hex_to_int, key_cnt_succeed_trade) - -if __name__=='__main__': - server_id = sys.argv[1] - change_B = int_to_hex(int(sys.argv[2])) # hex - change_A = int_to_hex(int(sys.argv[3])) # hex - token_A = sys.argv[4] - token_B = sys.argv[5] - - db = openDB(location_db(server_id)) - - total_price = get_value(db, key_total_price(token_A, token_B)) # hex - - file = location_sharefile(server_id) - with open(file, 'wb') as f: - f.write( - change_B + - change_A + - total_price - ) - - cnt_succeed_trade = hex_to_int(get_value(db, key_cnt_succeed_trade())) + 1 - print('cnt_succeed_trade', cnt_succeed_trade) - db.Put(key_cnt_succeed_trade(), int_to_hex(cnt_succeed_trade)) \ No newline at end of file diff --git a/src/python/honeybadgerswap/server/config.py b/src/python/honeybadgerswap/server/config.py deleted file mode 100644 index fcda9ba0..00000000 --- a/src/python/honeybadgerswap/server/config.py +++ /dev/null @@ -1,34 +0,0 @@ -from pathlib import Path -import os - -import toml -from pydantic import BaseSettings - -CONFIG_PATH_ENV = "HBSWAP_SERVER_CONFIG" -DEFAULT_CONFIG_PATH = "/opt/hbswap/conf/server.toml" - - -def toml_config_settings_source(settings: BaseSettings): - return toml.load(Path(os.getenv(CONFIG_PATH_ENV, DEFAULT_CONFIG_PATH))) - - -class Settings(BaseSettings): - N: int - T: int - LeaderHostname: str - Servers: list - EthNode: dict - NODE_ID: int - - class Config: - @classmethod - def customise_sources(cls, init_settings, env_settings, file_secret_settings): - return ( - init_settings, - toml_config_settings_source, - env_settings, - file_secret_settings, - ) - - -settings = Settings() diff --git a/src/python/honeybadgerswap/server/init_pool_org_data.py b/src/python/honeybadgerswap/server/init_pool_org_data.py deleted file mode 100644 index 7eb375ce..00000000 --- a/src/python/honeybadgerswap/server/init_pool_org_data.py +++ /dev/null @@ -1,56 +0,0 @@ -import math -import sys - -from ..utils import ( - key_balance, - key_pool, - key_total_supply, - location_db, - location_private_output, - openDB, - get_value, - hex_to_int, - int_to_hex, - sz, - p, - display_precision, -) - -input_parameter_num = 6 - -if __name__=='__main__': - server_id = sys.argv[1] - token_A = sys.argv[2] - token_B = sys.argv[3] - user = sys.argv[4] - amt_A = int(sys.argv[5]) # fix - amt_B = int(sys.argv[6]) # fix - - file = location_private_output(server_id) - with open(file, 'rb') as f: - valid_order = hex_to_int(f.read(sz)) - print(valid_order) - - if valid_order == 1: - db = openDB(location_db(server_id)) - - db.Put(key_pool(token_A, token_B, token_A), int_to_hex(amt_A)) - db.Put(key_pool(token_A, token_B, token_B), int_to_hex(amt_B)) - - balance_A = hex_to_int(get_value(db, key_balance(token_A, user))) # fix - balance_A = (balance_A - amt_A) % p - db.Put(key_balance(token_A, user), int_to_hex(balance_A)) - - balance_B = hex_to_int(get_value(db, key_balance(token_B, user))) # fix - balance_B = (balance_B - amt_B) % p - db.Put(key_balance(token_B, user), int_to_hex(balance_B)) - - amt_LT = int(math.sqrt(amt_A * amt_B)) % p - - db.Put(key_balance(f'{token_A}+{token_B}', user), int_to_hex(amt_LT)) - - db.Put(key_total_supply(token_A, token_B), int_to_hex(amt_LT)) - - init_price = 1. * amt_B / amt_A - print('{:.{}f}'.format(init_price, display_precision)) - diff --git a/src/python/honeybadgerswap/server/init_pool_set_data.py b/src/python/honeybadgerswap/server/init_pool_set_data.py deleted file mode 100644 index 140c54f6..00000000 --- a/src/python/honeybadgerswap/server/init_pool_set_data.py +++ /dev/null @@ -1,34 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - location_db, - location_sharefile, - openDB, - get_value, - int_to_hex, -) - -if __name__ == "__main__": - server_id = sys.argv[1] - user = sys.argv[2] - token_A = sys.argv[3] - token_B = sys.argv[4] - amt_A = int(sys.argv[5]) # fix - amt_B = int(sys.argv[6]) # fix - - db = openDB(location_db(server_id)) - - balance_A = get_value(db, key_balance(token_A, user)) # hex - balance_B = get_value(db, key_balance(token_B, user)) # hex - total_supply_LT = get_value(db, key_balance(f'{token_A}+{token_B}', user)) # hex - - file = location_sharefile(server_id) - with open(file, "wb") as f: - f.write( - balance_A + - int_to_hex(amt_A) + - balance_B + - int_to_hex(amt_B) + - total_supply_LT - ) diff --git a/src/python/honeybadgerswap/server/main.py b/src/python/honeybadgerswap/server/main.py deleted file mode 100644 index ae96d8f1..00000000 --- a/src/python/honeybadgerswap/server/main.py +++ /dev/null @@ -1,122 +0,0 @@ -import time - -from fastapi import FastAPI, HTTPException -from fastapi.middleware.cors import CORSMiddleware - -from .config import settings -from ..utils import ( - key_balance, - key_inputmask, - key_individual_price, - location_db, - openDB, - get_value, - hex_to_int -) - -app = FastAPI() - -app.add_middleware( - CORSMiddleware, - allow_origins="*", - allow_credentials=True, - allow_methods=["*"], - allow_headers=["*"], -) - - -@app.get("/") -async def root(): - return {"message": "Hello HoneyBadgerSwap!"} - - -@app.get("/info") -async def info(): - return {"info": "hbswap http server"} - - -@app.get("/inputmasks/{mask_idxes}") -async def get_inputmasks(mask_idxes: str): - print(f"s{settings.NODE_ID} processing request GET /inputmasks/{mask_idxes}") - mask_idx_list = mask_idxes.split(",") - res = "" - print(mask_idx_list) - db = openDB(location_db(settings.NODE_ID)) - for mask_idx in mask_idx_list: - try: - share = hex_to_int(bytes(db.Get(key_inputmask(mask_idx)))) - except KeyError: - print('key error: ', mask_idx) - res = '' - break - res += ( - f"{',' if len(res) > 0 else ''}{share}" - ) - data = {"inputmask_shares": res} - print(f"s{settings.NODE_ID} response to GET /inputmasks/{mask_idxes}: {res}") - return data - - -@app.get("/price/{trade_seq}") -async def get_price(trade_seq: str): - print(f"s{settings.NODE_ID} processing request GET /price/{trade_seq}") - db = openDB(location_db(settings.NODE_ID)) - res = '' - try: - res = hex_to_int(bytes(db.Get(key_individual_price(trade_seq)))) - except KeyError: - pass - data = {"price": f"{res}"} - print(f"s{settings.NODE_ID} response to GET /price/{trade_seq}: {res}") - return data - - -@app.get("/balance/{token_user}") -async def get_balance(token_user: str): - print(f"s{settings.NODE_ID} processing request GET /balance/{token_user}") - token, user = token_user.split(",") - db = openDB(location_db(settings.NODE_ID)) - res = hex_to_int(get_value(db, key_balance(token, user))) - data = {"balance": f"{res}"} - print(f"s{settings.NODE_ID} response to GET /balance/{token_user}: {res}") - return data - - -@app.get("/log/{n}") -async def get_logs(n: int): - print(f"s{settings.NODE_ID} processing request GET /log/{n}") - log_file = open(f"/usr/src/hbswap/log/mpc_server_{settings.NODE_ID}.log", "r") - lines = log_file.readlines() - last_lines = lines[-n:] - res = "" - for line in last_lines: - res += line - data = {"log": f"{res}"} - print(f"s{settings.NODE_ID} response to GET /log/{n}: {res}") - return data - - -def start_server(): - import argparse - import uvicorn - - parser = argparse.ArgumentParser("Start HoneyBadgerSwap HTTP server.") - parser.add_argument( - "--log-level", - type=str, - choices=("critical", "error", "warning", "info", "debug", "trace"), - default="info", - help="set log level", - ) - args = parser.parse_args() - - uvicorn.run( - "honeybadgerswap.server.main:app", - host=settings.Servers[settings.NODE_ID]["HttpHost"], - port=settings.Servers[settings.NODE_ID]["HttpPort"], - log_level=args.log_level, - ) - - -if __name__ == "__main__": - start_server() diff --git a/src/python/honeybadgerswap/server/proc_inputmask.py b/src/python/honeybadgerswap/server/proc_inputmask.py deleted file mode 100644 index 5f02dccf..00000000 --- a/src/python/honeybadgerswap/server/proc_inputmask.py +++ /dev/null @@ -1,27 +0,0 @@ -import logging -import sys - -from ..utils import key_inputmask, location_db, location_inputmask, openDB, int_to_hex, p - -logger = logging.getLogger(name=__name__) - -if __name__ == "__main__": - server_id = sys.argv[1] - init_idx = int(sys.argv[2]) - - logger.info("open db to write inputmasks ...") - db = openDB(location_db(server_id)) - logger.info("db has been opened") - - file = location_inputmask(server_id) - with open(file, "r") as f: - idx = init_idx - for line in f.readlines(): - key = key_inputmask(idx) - share = int_to_hex(int(line) % p) - logger.info( - f"will write to db: inputmasks {idx}, key: {key}, share: {share}" - ) - db.Put(key, share) - idx += 1 - logger.info(f"inputmasks {idx}, key: {key}, share: {share} written to db") diff --git a/src/python/honeybadgerswap/server/remove_liquidity_org_data.py b/src/python/honeybadgerswap/server/remove_liquidity_org_data.py deleted file mode 100644 index a7ffd991..00000000 --- a/src/python/honeybadgerswap/server/remove_liquidity_org_data.py +++ /dev/null @@ -1,47 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - key_pool, - key_total_supply, - location_db, - location_sharefile, - location_private_output, - openDB, - hex_to_int, - sz, -) - -input_parameter_num = 7 - -if __name__ == "__main__": - server_id = sys.argv[1] - user = sys.argv[2] - token_A = sys.argv[3] - token_B = sys.argv[4] - - file = location_sharefile(server_id) - with open(file, "rb") as f: - f.seek(input_parameter_num * sz) - pool_A = f.read(sz) - pool_B = f.read(sz) - balance_A = f.read(sz) - balance_B = f.read(sz) - balance_LT = f.read(sz) - total_supply_LT = f.read(sz) - - db = openDB(location_db(server_id)) - - db.Put(key_pool(token_A, token_B, token_A), pool_A) - db.Put(key_pool(token_A, token_B, token_B), pool_B) - - db.Put(key_balance(token_A, user), balance_A) - db.Put(key_balance(token_B, user), balance_B) - db.Put(key_balance(f'{token_A}+{token_B}', user), balance_LT) - - db.Put(key_total_supply(token_A, token_B), total_supply_LT) - - file = location_private_output(server_id) - with open(file, 'rb') as f: - zero_total_LT = hex_to_int(f.read(sz)) - print(zero_total_LT) diff --git a/src/python/honeybadgerswap/server/remove_liquidity_set_data.py b/src/python/honeybadgerswap/server/remove_liquidity_set_data.py deleted file mode 100644 index b4e742c9..00000000 --- a/src/python/honeybadgerswap/server/remove_liquidity_set_data.py +++ /dev/null @@ -1,45 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - key_pool, - key_total_supply, - location_db, - location_sharefile, - openDB, - get_value, - recover_input -) - -if __name__ == "__main__": - server_id = sys.argv[1] - user = sys.argv[2] - token_A = sys.argv[3] - token_B = sys.argv[4] - idx_LT = sys.argv[5] - masked_amt_LT = int(sys.argv[6]) # fix - - db = openDB(location_db(server_id)) - - balance_LT = get_value(db, key_balance(f'{token_A}+{token_B}', user)) # hex - amt_LT = recover_input(db, masked_amt_LT, idx_LT) # hex - - pool_A = get_value(db, key_pool(token_A, token_B, token_A)) # hex - pool_B = get_value(db, key_pool(token_A, token_B, token_B)) # hex - - total_supply_LT = get_value(db, key_total_supply(token_A, token_B)) # hex - - balance_A = get_value(db, key_balance(token_A, user)) # hex - balance_B = get_value(db, key_balance(token_B, user)) # hex - - file = location_sharefile(server_id) - with open(file, "wb") as f: - f.write( - balance_LT + - amt_LT + - pool_A + - pool_B + - total_supply_LT + - balance_A + - balance_B - ) diff --git a/src/python/honeybadgerswap/server/secret_deposit.py b/src/python/honeybadgerswap/server/secret_deposit.py deleted file mode 100644 index acffa715..00000000 --- a/src/python/honeybadgerswap/server/secret_deposit.py +++ /dev/null @@ -1,24 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - location_db, - openDB, - get_value, - fix_to_float, - hex_to_int, - int_to_hex, - p -) - -if __name__ == "__main__": - server_id = sys.argv[1] - token = sys.argv[2] - user = sys.argv[3] - amt = int(sys.argv[4]) - - db = openDB(location_db(server_id)) - key = key_balance(token, user) - balance = (hex_to_int(get_value(db, key)) + amt) % p - print(f'balance {fix_to_float(balance)}') - db.Put(key, int_to_hex(balance)) diff --git a/src/python/honeybadgerswap/server/secret_withdraw_org_data.py b/src/python/honeybadgerswap/server/secret_withdraw_org_data.py deleted file mode 100644 index 524ffee1..00000000 --- a/src/python/honeybadgerswap/server/secret_withdraw_org_data.py +++ /dev/null @@ -1,32 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - location_db, - location_private_output, - openDB, - get_value, - hex_to_int, - int_to_hex, - sz, - p -) - -if __name__=='__main__': - server_id = sys.argv[1] - token = sys.argv[2] - user = sys.argv[3] - amt = int(sys.argv[4]) # fix - - file = location_private_output(server_id) - with open(file, 'rb') as f: - enough = hex_to_int(f.read(sz)) - print(enough) - - if enough == 1: - db = openDB(location_db(server_id)) - - key = key_balance(token, user) - balance = hex_to_int(get_value(db, key)) # fix - balance = (balance - amt) % p - db.Put(key, int_to_hex(balance)) \ No newline at end of file diff --git a/src/python/honeybadgerswap/server/secret_withdraw_set_data.py b/src/python/honeybadgerswap/server/secret_withdraw_set_data.py deleted file mode 100644 index 6fd274ce..00000000 --- a/src/python/honeybadgerswap/server/secret_withdraw_set_data.py +++ /dev/null @@ -1,27 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - location_db, - location_sharefile, - openDB, - get_value, - int_to_hex -) - -if __name__ == "__main__": - server_id = sys.argv[1] - user = sys.argv[2] - token = sys.argv[3] - amt = int(sys.argv[4]) # fix - - db = openDB(location_db(server_id)) - - balance = get_value(db, key_balance(token, user)) # hex - - file = location_sharefile(server_id) - with open(file, "wb") as f: - f.write( - balance + - int_to_hex(amt) - ) diff --git a/src/python/honeybadgerswap/server/set_price_zero.py b/src/python/honeybadgerswap/server/set_price_zero.py deleted file mode 100644 index c0b6943c..00000000 --- a/src/python/honeybadgerswap/server/set_price_zero.py +++ /dev/null @@ -1,22 +0,0 @@ -import sys - -from ..utils import ( - key_individual_price, - location_db, - openDB, - int_to_hex, - get_value, key_cnt_failed_trade, hex_to_int) - -input_parameter_num = 3 - -if __name__ == "__main__": - server_id = sys.argv[1] - trade_seq = sys.argv[2] - - db = openDB(location_db(server_id)) - - db.Put(key_individual_price(trade_seq), int_to_hex(0)) - - cnt_failed_trade = hex_to_int(get_value(db, key_cnt_failed_trade())) + 1 - print('cnt_failed_trade', cnt_failed_trade) - db.Put(key_cnt_failed_trade(), int_to_hex(cnt_failed_trade)) \ No newline at end of file diff --git a/src/python/honeybadgerswap/server/start_server.py b/src/python/honeybadgerswap/server/start_server.py deleted file mode 100644 index 282d4623..00000000 --- a/src/python/honeybadgerswap/server/start_server.py +++ /dev/null @@ -1,16 +0,0 @@ -import asyncio - -from .Server import http_server - - -async def main(): - tasks = [] - tasks.append(asyncio.ensure_future(http_server())) - - for task in tasks: - await task - - -# TODO Use argparse to accept config file to use. -if __name__ == "__main__": - asyncio.run(main()) diff --git a/src/python/honeybadgerswap/server/trade_org_data.py b/src/python/honeybadgerswap/server/trade_org_data.py deleted file mode 100644 index c12ce565..00000000 --- a/src/python/honeybadgerswap/server/trade_org_data.py +++ /dev/null @@ -1,45 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - key_pool, - location_db, - location_private_output, - location_sharefile, - openDB, - hex_to_int, - sz -) - -input_parameter_num = 6 - -if __name__=='__main__': - server_id = sys.argv[1] - user = sys.argv[2] - token_A = sys.argv[3] - token_B = sys.argv[4] - - file = location_sharefile(server_id) - with open(file, 'rb') as f: - f.seek(input_parameter_num * sz) - change_A = hex_to_int(f.read(sz)) # int - change_B = hex_to_int(f.read(sz)) # int - pool_A = f.read(sz) # hex - pool_B = f.read(sz) # hex - balance_A = hex_to_int(f.read(sz)) # int - balance_B = hex_to_int(f.read(sz)) # int - - db = openDB(location_db(server_id)) - - db.Put(key_pool(token_A, token_B, token_A), pool_A) - db.Put(key_pool(token_A, token_B, token_B), pool_B) - - file = location_private_output(server_id) - with open(file, 'rb') as f: - order_succeed = hex_to_int(f.read(sz)) - print(order_succeed) - - print(balance_A) - print(balance_B) - print(change_B) - print(change_A) diff --git a/src/python/honeybadgerswap/server/trade_set_data.py b/src/python/honeybadgerswap/server/trade_set_data.py deleted file mode 100644 index b1d702db..00000000 --- a/src/python/honeybadgerswap/server/trade_set_data.py +++ /dev/null @@ -1,43 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - key_pool, - location_db, - location_sharefile, - openDB, - get_value, - recover_input, -) - -if __name__=='__main__': - server_id = sys.argv[1] - user = sys.argv[2] - token_A = sys.argv[3] - token_B = sys.argv[4] - idx_A = sys.argv[5] - masked_amt_A = int(sys.argv[6]) # fix - idx_B = sys.argv[7] - masked_amt_B = int(sys.argv[8]) # fix - - db = openDB(location_db(server_id)) - - amt_A = recover_input(db, masked_amt_A, idx_A) # hex - amt_B = recover_input(db, masked_amt_B, idx_B) # hex - - balance_A = get_value(db, key_balance(token_A, user)) # hex - balance_B = get_value(db, key_balance(token_B, user)) # hex - - pool_A = get_value(db, key_pool(token_A, token_B, token_A)) # hex - pool_B = get_value(db, key_pool(token_A, token_B, token_B)) # hex - - file = location_sharefile(server_id) - with open(file, 'wb') as f: - f.write( - amt_A + - amt_B + - balance_B + - pool_A + - pool_B + - balance_A - ) diff --git a/src/python/honeybadgerswap/server/trade_update_balance.py b/src/python/honeybadgerswap/server/trade_update_balance.py deleted file mode 100644 index ee6c8af1..00000000 --- a/src/python/honeybadgerswap/server/trade_update_balance.py +++ /dev/null @@ -1,23 +0,0 @@ -import sys - -from ..utils import ( - key_balance, - location_db, - openDB, - int_to_hex -) - -input_parameter_num = 6 - -if __name__=='__main__': - server_id = sys.argv[1] - user = sys.argv[2] - token_A = sys.argv[3] - token_B = sys.argv[4] - balance_A = int_to_hex(int(sys.argv[5])) # hex - balance_B = int_to_hex(int(sys.argv[6])) # hex - - db = openDB(location_db(server_id)) - - db.Put(key_balance(token_A, user), balance_A) - db.Put(key_balance(token_B, user), balance_B) \ No newline at end of file diff --git a/src/python/honeybadgerswap/utils.py b/src/python/honeybadgerswap/utils.py deleted file mode 100644 index e0184d62..00000000 --- a/src/python/honeybadgerswap/utils.py +++ /dev/null @@ -1,159 +0,0 @@ -import os -import time - -import leveldb - -from gmpy import binary, mpz -from gmpy2 import mpz_from_old_binary - -############################################################################## -# keys # -############################################################################## - - -def key_balance(token, user): - return f'balance_{token}_{user}'.encode() - - -def key_inputmask(idx): - return f'inputmask_{idx}'.encode() - -def key_cnt_failed_trade(): - return f'cnt_failed_trade'.encode() - -def key_cnt_succeed_trade(): - return f'cnt_succeed_trade'.encode() - -def key_pool(token_A, token_B, token): - return f'pool_{token_A}_{token_B}_{token}'.encode() - - -def key_individual_price(trade_seq): - return f'trade_price_{trade_seq}'.encode() - - -# def key_trade_time(trade_seq): -# return f'trade_time_{trade_seq}'.encode() - - -def key_total_price(token_A, token_B): - return f'trade_price_{token_A}_{token_B}'.encode() - - -def key_total_cnt(token_A, token_B): - return f'total_cnt_{token_A}-{token_B}'.encode() - - -def key_total_supply(token_A, token_B): - return f'total_supply_{token_A}_{token_B}'.encode() - - -############################################################################## -# files # -############################################################################## - - -def location_db(server_id): - db_path = os.getenv('DB_PATH', '/opt/hbswap/db') - return f'{db_path}/server-{server_id}' - - -def location_inputmask(server_id): - inputmask_shares_dir = os.getenv( - 'INPUTMASK_SHARES', '/opt/hbswap/inputmask-shares', - ) - return f'{inputmask_shares_dir}/4-MSp-255/Randoms-MSp-P{server_id}' - - -def location_private_output(server_id): - prep_dir = os.getenv('PREP_DIR', '/opt/hbswap/preprocessing-data') - return f'{prep_dir}/Private-Output-{server_id}' - - -def location_sharefile(server_id): - return f'Persistence/Transactions-P{server_id}.data' - - -############################################################################## -# functions # -############################################################################## - - -def openDB(location): - while True: - try: - return leveldb.LevelDB(location) - except leveldb.LevelDBError: - print('db not ready') - time.sleep(10) - - -def get_value(db, key): # return: hex - try: - return bytes(db.Get(key)) - except KeyError: - return int_to_hex(0) - - -def get_inverse(a): - ret = 1 - b = p - 2 - while b: - if b % 2 == 1: - ret = (ret * a) % p - b //= 2 - a = (a * a) % p - return ret - - -# def float_to_fix(x): -# return int(round(float(x) * fp)) - - -def fix_to_float(x): - return 1. * x / fp - - -def hex_to_int(x): - return int((mpz_from_old_binary(x) * inverse_R) % p) - - -def int_to_hex(x): - x = mpz(x) - x = (x * R) % p - x = binary(int(x)) - x += b'\x00' * (32 - len(x)) - return x - - -def check_consistency(shares): - value = reconstruct(shares, t + 1) - for i in range(t + 2, n + 1): - if reconstruct(shares, i) != value: - print('inconsistent') - -def reconstruct(shares, n): - inputmask = 0 - for i in range(1, n + 1): - tot = 1 - for j in range(1, n + 1): - if i == j: - continue - tot = tot * j * get_inverse(j - i) % p - inputmask = (inputmask + shares[i - 1] * tot) % p - print(inputmask) - return inputmask - -def recover_input(db, masked_value, idx): # return: hex - input_mask_share = hex_to_int(get_value(db, key_inputmask(idx))) - return int_to_hex((masked_value - input_mask_share) % p) - -n = 4 -t = 1 -p = 52435875175126190479447740508185965837690552500527637822603658699938581184513 -R = 10920338887063814464675503992315976177888879664585288394250266608035967270910 -inverse_R = get_inverse(R) -fp = 1 << 16 -sz = 32 - -display_precision = 4 diff --git a/src/python/pyproject.toml b/src/python/pyproject.toml deleted file mode 100644 index fed528d4..00000000 --- a/src/python/pyproject.toml +++ /dev/null @@ -1,3 +0,0 @@ -[build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" diff --git a/src/python/setup.cfg b/src/python/setup.cfg deleted file mode 100644 index ca181845..00000000 --- a/src/python/setup.cfg +++ /dev/null @@ -1,46 +0,0 @@ -[metadata] -name = honeybadgerswap -version = 0.0.1.dev0 - -[options] -packages = find: -install_requires = - aiohttp - aiohttp_cors - gmpy - gmpy2 - leveldb - toml - # fastapi - fastapi - pydantic - uvicorn[standard] - -[options.extras_require] -dev = - black - ipdb - ipython - flake8 - flake8-bugbear -docs: - sphinx -test = - pytest - -[options.entry_points] -console_scripts = - hbswap-check-balance-set-data=honeybadgerswap.server.check_balance_set_data:main - hbswap-check-balance-org-data=honeybadgerswap.server.check_balance_org_data:main - hbswap-update-balance=honeybadgerswap.server.update_balance:main - hbswap-proc-inputmasks=honeybadgerswap.server.proc_inputmask:main - hbswap-init-pool=honeybadgerswap.server.init_pool:main - hbswap-add-liquidity-set-data=honeybadgerswap.server.add_liquidity_set_data:main - hbswap-add-liquidity-org-data=honeybadgerswap.server.add_liquidity_org_data:main - hbswap-remove-liquidity-set-data=honeybadgerswap.server.remove_liquidity_set_data:main - hbswap-remove-liquidity-org-data=honeybadgerswap.server.remove_liquidity_org_data:main - hbswap-trade-set-data=honeybadgerswap.server.trade_set_data:main - hbswap-trade-org-data=honeybadgerswap.server.trade_org_data:main - hbswap-calc-price-set-data=honeybadgerswap.server.calc_price_set_data:main - hbswap-start-httpserver=honeybadgerswap.server.main:start_server - hbswap-req-inputmasks=honeybadgerswap.client.req_inputmasks:main diff --git a/src/python/setup.py b/src/python/setup.py deleted file mode 100644 index b908cbe5..00000000 --- a/src/python/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -import setuptools - -setuptools.setup() diff --git a/src/python/tests/__init__.py b/src/python/tests/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/python/tests/check.py b/src/python/tests/check.py deleted file mode 100644 index c831c2d8..00000000 --- a/src/python/tests/check.py +++ /dev/null @@ -1,41 +0,0 @@ -from honeybadgerswap.utils import check_consistency - -# def reconstruct(shares, n): -# inputmask = 0 -# for i in range(1, n + 1): -# tot = 1 -# for j in range(1, n + 1): -# if i == j: -# continue -# tot = tot * j * get_inverse(j - i) % p -# inputmask = (inputmask + shares[i - 1] * tot) % p -# return inputmask -# -# def check(shares): -# value = reconstruct(shares, t + 1) -# for i in range(t + 2, n + 1): -# if reconstruct(shares, i) != value: -# print('ohoh') - -# mask = [] -# for server_id in range(4): -# file = f'Player-Data/4-MSp-255/Randoms-MSp-P{server_id}' -# tmp = [] -# with open(file, 'r') as f: -# for line in f.readlines(): -# data = int(line) % p -# tmp.append(data) -# mask.append(tmp) -# -# for k in range(0, len(mask[0])): -# shares = [] -# for i in range(n): -# shares.append(mask[i][k]) -# -shares = [ - -6937119568177438155937978633434279269014265249325731686894819606448044537196, - -13874239136354876311875957266868558538028530498651463373789639212896089729752, - -20811358704532314467813935900302837807042795747977195060684458819344134922308, - 24687396902416437855695825974448848761633491503224711075024380274146401069649, -] -print(check_consistency(shares)) diff --git a/src/python/tests/debug.sh b/src/python/tests/debug.sh deleted file mode 100755 index 161f8576..00000000 --- a/src/python/tests/debug.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -set -e - -pkill -f malicious-shamir-party.x || true - -#mpc_prog=hbswap_calc_price -#python_prog=Scripts/hbswap/python/server/calc_price_set_data.py - -mpc_prog=hbswap_test -python_prog=Scripts/hbswap/python/test/set_data.py - -./compile.py -v -C -F 256 $mpc_prog - -#python3 $python_prog 0 0x0000000000000000000000000000000000000000 0x6b5c9637e0207c72Ee1a275b6C3b686ba8D87385 -#python3 $python_prog 1 0x0000000000000000000000000000000000000000 0x6b5c9637e0207c72Ee1a275b6C3b686ba8D87385 -#python3 $python_prog 2 0x0000000000000000000000000000000000000000 0x6b5c9637e0207c72Ee1a275b6C3b686ba8D87385 -#python3 $python_prog 3 0x0000000000000000000000000000000000000000 0x6b5c9637e0207c72Ee1a275b6C3b686ba8D87385 - -./malicious-shamir-party.x -N 4 -T 1 -p 0 -pn 5000 -P 52435875175126190479447740508185965837690552500527637822603658699938581184513 $mpc_prog & -./malicious-shamir-party.x -N 4 -T 1 -p 1 -pn 5000 -P 52435875175126190479447740508185965837690552500527637822603658699938581184513 $mpc_prog & -./malicious-shamir-party.x -N 4 -T 1 -p 2 -pn 5000 -P 52435875175126190479447740508185965837690552500527637822603658699938581184513 $mpc_prog & -./malicious-shamir-party.x -N 4 -T 1 -p 3 -pn 5000 -P 52435875175126190479447740508185965837690552500527637822603658699938581184513 $mpc_prog \ No newline at end of file diff --git a/src/python/tests/debug_trade.sh b/src/python/tests/debug_trade.sh deleted file mode 100755 index dc25b7c9..00000000 --- a/src/python/tests/debug_trade.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash -set -e - -pkill -f malicious-shamir-party.x || true - -./compile.py -v -C -F 256 hbswap_trade - -./malicious-shamir-party.x -N 4 -T 1 -p 0 -pn 5000 -P 52435875175126190479447740508185965837690552500527637822603658699938581184513 hbswap_trade & -./malicious-shamir-party.x -N 4 -T 1 -p 1 -pn 5000 -P 52435875175126190479447740508185965837690552500527637822603658699938581184513 hbswap_trade & -./malicious-shamir-party.x -N 4 -T 1 -p 2 -pn 5000 -P 52435875175126190479447740508185965837690552500527637822603658699938581184513 hbswap_trade & -./malicious-shamir-party.x -N 4 -T 1 -p 3 -pn 5000 -P 52435875175126190479447740508185965837690552500527637822603658699938581184513 hbswap_trade \ No newline at end of file diff --git a/src/python/tests/inputmask.sh b/src/python/tests/inputmask.sh deleted file mode 100755 index 37ab52c2..00000000 --- a/src/python/tests/inputmask.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash - -./random-shamir.x -i 0 -N 4 -T 1 --nshares 1000 & -./random-shamir.x -i 1 -N 4 -T 1 --nshares 1000 & -./random-shamir.x -i 2 -N 4 -T 1 --nshares 1000 & -./random-shamir.x -i 3 -N 4 -T 1 --nshares 1000 - -python3 Scripts/hbswap/python/test/check.py \ No newline at end of file diff --git a/src/python/tests/set_data.py b/src/python/tests/set_data.py deleted file mode 100644 index 476acf95..00000000 --- a/src/python/tests/set_data.py +++ /dev/null @@ -1,21 +0,0 @@ -import sys - -from ..utils import from_hex, to_hex # , sz - -if __name__ == "__main__": - server_id = sys.argv[1] - - print(from_hex(to_hex(1123411))) - - # file = f"Persistence/Transactions-P{server_id}.data" - # # with open(file, 'wb') as f: - # # f.write(to_hex(0)) - - # file = f"Player-Data/Private-Output-{server_id}" - # with open(file, 'rb') as f: - # zero = f.read(sz - # print(zero) - # print(from_hex(zero)) - # - # import os - # print('filesize:', os.path.getsize(file)) diff --git a/src/python/tests/test.py b/src/python/tests/test.py deleted file mode 100644 index 78f509d5..00000000 --- a/src/python/tests/test.py +++ /dev/null @@ -1,23 +0,0 @@ -from ..utils import get_inverse, n, t, p - -x = [] -y = [] - -for i in range(n): - file = f"PreProcessing-Data/4-MSp-255/Randoms-MSp-P{i}" - with open(file, "r") as f: - x.append(i + 1) - for line in f.readlines(): - y.append(int(line)) - break - -for nn in range(t + 1, n + 1): - inputmask = 0 - for i in range(nn): - tot = 1 - for j in range(nn): - if i == j: - continue - tot = tot * x[j] * get_inverse(x[j] - x[i]) % p - inputmask = (inputmask + y[i] * tot) % p - print(inputmask) diff --git a/src/truffle-config.js b/src/truffle-config.js deleted file mode 100644 index 3f307439..00000000 --- a/src/truffle-config.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Use this file to configure your truffle project. It's seeded with some - * common settings for different networks and features like migrations, - * compilation and testing. Uncomment the ones you need or modify - * them to suit your project as necessary. - * - * More information about configuration can be found at: - * - * truffleframework.com/docs/advanced/configuration - * - * To deploy via Infura you'll need a wallet provider (like @truffle/hdwallet-provider) - * to sign your transactions before they're sent to a remote public node. Infura accounts - * are available for free at: infura.io/register. - * - * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate - * public/private key pairs. If you're publishing your code to GitHub make sure you load this - * phrase from a file you've .gitignored so it doesn't accidentally become public. - * - */ - -// const HDWalletProvider = require('@truffle/hdwallet-provider'); -// const infuraKey = "fj4jll3k....."; -// -// const fs = require('fs'); -// const mnemonic = fs.readFileSync(".secret").toString().trim(); - -module.exports = { - /** - * Networks define how you connect to your ethereum client and let you set the - * defaults web3 uses to send transactions. If you don't specify one truffle - * will spin up a development blockchain for you on port 9545 when you - * run `develop` or `test`. You can ask a truffle command to use a specific - * network from the command line, e.g - * - * $ truffle test --network - */ - - networks: { - // Useful for testing. The `development` name is special - truffle uses it by default - // if it's defined here and no other network is specified at the command line. - // You should run a client (like ganache-cli, geth or parity) in a separate terminal - // tab if you use this network and you must also set the `host`, `port` and `network_id` - // options below to some value. - // - // development: { - // host: "127.0.0.1", // Localhost (default: none) - // port: 8545, // Standard Ethereum port (default: none) - // network_id: "*", // Any network (default: none) - // }, - - // Another network with more advanced options... - // advanced: { - // port: 8777, // Custom port - // network_id: 1342, // Custom network - // gas: 8500000, // Gas sent with each transaction (default: ~6700000) - // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei) - // from:
, // Account to send txs from (default: accounts[0]) - // websockets: true // Enable EventEmitter interface for web3 (default: false) - // }, - - // Useful for deploying to a public network. - // NB: It's important to wrap the provider as a function. - // ropsten: { - // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`), - // network_id: 3, // Ropsten's id - // gas: 5500000, // Ropsten has a lower block limit than mainnet - // confirmations: 2, // # of confs to wait between deployments. (default: 0) - // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50) - // skipDryRun: true // Skip dry run before migrations? (default: false for public nets ) - // }, - - // Useful for private networks - // private: { - // provider: () => new HDWalletProvider(mnemonic, `https://network.io`), - // network_id: 2111, // This network is yours, in the cloud. - // production: true // Treats this network as if it was a public net. (default: false) - // } - }, - - // Set default mocha options here, use special reporters etc. - mocha: { - // timeout: 100000 - }, - - // Configure your compilers - compilers: { - solc: { - version: "0.5.17", // Fetch exact version from solc-bin (default: truffle's version) - // docker: true, // Use "0.5.1" you've installed locally with docker (default: false) - settings: { // See the solidity docs for advice about optimization and evmVersion - optimizer: { - enabled: false, - runs: 200 - }, - // evmVersion: "byzantium" - } - } - } -}