diff --git a/README.md b/README.md index 3cd7e08..e49d14f 100644 --- a/README.md +++ b/README.md @@ -1,135 +1,138 @@ -# RedPacket - -## Introduction - -This project(`RedPacket` smart contract) is a Dapplet based on the Mask browser extension. Inspired by [Red Packet](https://en.wikipedia.org/wiki/Red_envelope). It enables you to put cryptocurrency tokens(ETH or ERC-20) into red packets and send them to your friends and family. - -Besides, Mask Network developed a new red packet for ERC721/NFT token. - -## Getting Started - -This is a hardhat project. To install required node.js modules - -```bash -npm ci -``` - -To compile the solidity source code - -```bash -npm run compile -``` - -To run ERC20 RedPacket unit test - -```bash -npm run test:normal -``` - -To run ERC721/NFT RedPacket unit test - -```bash -npm run test:erc721 -``` - -To deploy the smart contract on Ethereum ropsten testnet - -```bash -npm run deploy:ropsten -``` - -## Deployed Contract Address - - - -| Chain | HappyRedPacket | HappyRedPacket_ERC721 | -| ---------------- | :---------------------------------: | :------------------------------------: | -| Mainnet | [`0xaBBe1101`][rp-mainnet] | [`0x8d285739`][rp721-mainnet] | -| Ropsten | [`0x0722507c`][rp-ropsten] | [`0x8fF42e93`][rp721-ropsten] | -| BSC | [`0x0ca42C17`][rp-bsc] | [`0xf8968e1F`][rp721-bsc] | -| Matic | [`0x93e0b87A`][rp-matic] | [`0xf6Dc0427`][rp721-matic] | -| Rinkeby_arbitrum | [`0x4A77E797`][rp-rinkeby_arbitrum] | | -| Arbitrum | [`0x83D6b366`][rp-arbitrum] | [`0x561c5f3a`][rp721-arbitrum] | -| xDai | [`0x54a0A221`][rp-xdai] | [`0x561c5f3a`][rp721-xdai] | -| Goerli | [`0x8bF6b979`][rp-goerli] | [`0x0a04e23f`][rp721-goerli] | -| Fantom | [`0x578a7Fee`][rp-fantom] | [`0xF9F7C149`][rp721-fantom] | -| Avalanche | [`0xF9F7C149`][rp-avalanche] | [`0x96c7D011`][rp721-avalanche] | -| Celo | [`0xab7b1be4`][rp-celo] | [`0x96c7D011`][rp721-celo] | -| Kovan_optimistic | [`0x68EDbfA3`][rp-kovan_optimistic] | [`0x556F63d7`][rp721-kovan_optimistic] | -| Optimistic | [`0x981be454`][rp-optimistic] | [`0x02Ea0720`][rp721-optimistic] | -| Aurora | [`0x19f179D7`][rp-aurora] | [`0x05ee315E`][rp721-aurora] | -| Fuse | [`0x561c5f3a`][rp-fuse] | [`0x066804d9`][rp721-fuse] | -| Boba | [`0x578a7Fee`][rp-boba] | [`0xF9F7C149`][rp721-boba] | -| Moonriver | [`0x578a7Fee`][rp-moonriver] | [`0xF9F7C149`][rp721-moonriver] | -| Conflux | [`0x96c7d011`][rp-conflux] | [`0x5b966f3a`][rp721-conflux] | -| Conflux_test | [`0x913975af`][rp-conflux_test] | [`0x71834a3f`][rp721-conflux_test] | -| Harmony | [`0xab7b1be4`][rp-harmony] | [`0x83d6b366`][rp721-harmony] | -| Harmony_test | [`0x96c7d011`][rp-harmony_test] | [`0x981be454`][rp721-harmony_test] | -| Metis | [`0x2cf91AD8`][rp-metis] | [`0x81246335`][rp721-metis] | -| Metis_test | [`0xAb7B1bE4`][rp-metis_test] | [`0x2cf91AD8`][rp721-metis_test] | - -[rp-mainnet]: https://etherscan.io/address/0xaBBe1101FD8fa5847c452A6D70C8655532B03C33 -[rp-ropsten]: https://ropsten.etherscan.io/address/0x0722507c3b776A6B205946592016e358B0D34c3F -[rp-bsc]: https://bscscan.com/address/0x0ca42C178e14c618c81B8438043F27d9D38145f6 -[rp-matic]: https://polygonscan.com/address/0x93e0b87A0aD0C991dc1B5176ddCD850c9a78aabb -[rp-rinkeby_arbitrum]: https://rinkeby-explorer.arbitrum.io/address/0x4A77E797031257db72F7D2C3Ec08a4FAc5c8CfE9 -[rp-arbitrum]: https://explorer.arbitrum.io/address/0x83D6b366f21e413f214EB077D5378478e71a5eD2 -[rp-xdai]: https://blockscout.com/xdai/mainnet/address/0x54a0A221C25Fc0a347EC929cFC5db0be17fA2a2B -[rp-goerli]: https://goerli.etherscan.io/address/0x8bF6b979286970860Adc75dc621cf1969b0bE66C -[rp-fantom]: https://ftmscan.com/address/0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98 -[rp-avalanche]: https://snowtrace.io/address/0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 -[rp-celo]: https://explorer.celo.org/address/0xab7b1be4233a04e5c43a810e75657eced8e5463b -[rp-kovan_optimistic]: https://kovan-optimistic.etherscan.io/address/0x68EDbfA3E564C987FaaAB54f4FD1E7567D4151Dd -[rp-optimistic]: https://optimistic.etherscan.io/address/0x981be454a930479d92C91a0092D204b64845A5D6 -[rp-aurora]: https://explorer.mainnet.aurora.dev/address/0x19f179D7e0D7d9F9d5386afFF64271D98A91615B -[rp-fuse]: https://explorer.fuse.io/address/0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4 -[rp-boba]: https://blockexplorer.boba.network/address/0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98 -[rp-moonriver]: https://moonriver.moonscan.io/address/0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98 -[rp-conflux]: https://evm.confluxscan.io/address/0x96c7d011cdfd467f551605f0f5fce279f86f4186 -[rp-conflux_test]: https://evmtestnet.confluxscan.io/address/0x913975af2bb8a6be4100d7dc5e9765b77f6a5d6c -[rp-harmony]: https://explorer.harmony.one/address/0xab7b1be4233a04e5c43a810e75657eced8e5463b -[rp-harmony_test]: https://explorer.pops.one/address/0x96c7d011cdfd467f551605f0f5fce279f86f4186 -[rp-metis]: https://andromeda-explorer.metis.io/address/0x2cf91AD8C175305EBe6970Bd8f81231585EFbd77 -[rp-metis_test]: https://stardust-explorer.metis.io/address/0xAb7B1bE4233A04e5C43a810E75657ECED8E5463B -[rp721-mainnet]: https://etherscan.io/address/0x8d285739523FC2Ac8eC9c9C229ee863C8C9bF8C8 -[rp721-ropsten]: https://ropsten.etherscan.io/address/0x8fF42e93C19E44763FD1cD07b9E04d13bA07AD3f -[rp721-bsc]: https://bscscan.com/address/0xf8968e1Fcf1440Be5Cec7Bb495bcee79753d5E06 -[rp721-matic]: https://polygonscan.com/address/0xf6Dc042717EF4C097348bE00f4BaE688dcaDD4eA -[rp721-arbitrum]: https://explorer.arbitrum.io/address/0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4 -[rp721-xdai]: https://blockscout.com/xdai/mainnet/address/0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4 -[rp721-goerli]: https://goerli.etherscan.io/address/0x0a04e23f95E9DB2Fe4C31252548F663fFe3AAe4d -[rp721-fantom]: https://ftmscan.com/address/0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 -[rp721-avalanche]: https://snowtrace.io/address/0x96c7D011cdFD467f551605f0f5Fce279F86F4186 -[rp721-celo]: https://explorer.celo.org/address/0x96c7D011cdFD467f551605f0f5Fce279F86F4186 -[rp721-kovan_optimistic]: https://kovan-optimistic.etherscan.io/address/0x556F63d7467c729034585C3e50e54e582222b491 -[rp721-optimistic]: https://optimistic.etherscan.io/address/0x02Ea0720254F7fa4eca7d09A1b9C783F1020EbEF -[rp721-aurora]: https://explorer.mainnet.aurora.dev/address/0x05ee315E407C21a594f807D61d6CC11306D1F149 -[rp721-fuse]: https://explorer.fuse.io/address/0x066804d9123bF2609Ed4A4a40b1177a9c5a9Ed51 -[rp721-boba]: https://blockexplorer.boba.network/address/0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 -[rp721-moonriver]: https://moonriver.moonscan.io/address/0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 -[rp721-conflux]: https://evm.confluxscan.io/address/0x5b966f3a32db9c180843bcb40267a66b73e4f022 -[rp721-conflux_test]: https://evmtestnet.confluxscan.io/address/0x71834a3fdea3e70f14a93ed85c6be70925d0cad9 -[rp721-harmony]: https://explorer.harmony.one/address/0x83d6b366f21e413f214eb077d5378478e71a5ed2 -[rp721-harmony_test]: https://explorer.pops.one/address/0x981be454a930479d92c91a0092d204b64845a5d6 -[rp721-metis]: https://andromeda-explorer.metis.io/address/0x812463356F58fc8194645A1838ee6C52D8ca2D26 -[rp721-metis_test]: https://stardust-explorer.metis.io/address/0x2cf91AD8C175305EBe6970Bd8f81231585EFbd77 - - - -## Test report - -Unit test and performance(gas consumption) results, please see [test report](docs/test_report.txt) and [gas consumption test report](docs/performance_test.txt). - -## Version history - -Change, please see [Change log](docs/CHANGELOG.md) for changes. - -## Contribute - -Any contribution is welcomed to make it better. - -If you have any questions, please create an [issue](https://github.com/DimensionDev/RedPacket/issues). - -## License - -[MIT LICENSE](LICENSE) +# RedPacket + +## Introduction + +This project(`RedPacket` smart contract) is a Dapplet based on the Mask browser extension. Inspired by [Red Packet](https://en.wikipedia.org/wiki/Red_envelope). It enables you to put cryptocurrency tokens(ETH or ERC-20) into red packets and send them to your friends and family. + +Besides, Mask Network developed a new red packet for ERC721/NFT token. + +## Getting Started + +This is a hardhat project. To install required node.js modules + +```bash +npm ci +``` + +To compile the solidity source code + +```bash +npm run compile +``` + +To run ERC20 RedPacket unit test + +```bash +npm run test:normal +``` + +To run ERC721/NFT RedPacket unit test + +```bash +npm run test:erc721 +``` + +To deploy the smart contract on Ethereum ropsten testnet + +```bash +npm run deploy:ropsten +``` + +## Deployed Contract Address + + + +| Chain | HappyRedPacket | HappyRedPacket_ERC721 | +| ------------------- | -------------------------------------- | ----------------------------------------- | +| Mainnet | [`0xaBBe1101`][rp-mainnet] | [`0x8d285739`][rp721-mainnet] | +| Ropsten | [`0x0722507c`][rp-ropsten] | [`0x8fF42e93`][rp721-ropsten] | +| BSC | [`0x0ca42C17`][rp-bsc] | [`0xf8968e1F`][rp721-bsc] | +| Matic | [`0x93e0b87A`][rp-matic] | [`0xf6Dc0427`][rp721-matic] | +| Arbitrum_rinkeby | [`0x4A77E797`][rp-arbitrum_rinkeby] | | +| Arbitrum | [`0x83D6b366`][rp-arbitrum] | [`0x561c5f3a`][rp721-arbitrum] | +| xDai | [`0x54a0A221`][rp-xdai] | [`0x561c5f3a`][rp721-xdai] | +| Goerli | [`0x8bF6b979`][rp-goerli] | [`0x0a04e23f`][rp721-goerli] | +| Fantom | [`0x578a7Fee`][rp-fantom] | [`0xF9F7C149`][rp721-fantom] | +| Avalanche | [`0xF9F7C149`][rp-avalanche] | [`0x96c7D011`][rp721-avalanche] | +| Celo | [`0xab7b1be4`][rp-celo] | [`0x96c7D011`][rp721-celo] | +| Optimism_kovan | [`0x68EDbfA3`][rp-optimism_kovan] | [`0x556F63d7`][rp721-optimism_kovan] | +| Optimism | [`0x981be454`][rp-optimism] | [`0x02Ea0720`][rp721-optimism] | +| Aurora | [`0x19f179D7`][rp-aurora] | [`0x05ee315E`][rp721-aurora] | +| Fuse | [`0x561c5f3a`][rp-fuse] | [`0x066804d9`][rp721-fuse] | +| Boba | [`0x578a7Fee`][rp-boba] | [`0xF9F7C149`][rp721-boba] | +| Moonriver | [`0x578a7Fee`][rp-moonriver] | [`0xF9F7C149`][rp721-moonriver] | +| Conflux_espace | [`0x96c7d011`][rp-conflux_espace] | [`0x5b966f3a`][rp721-conflux_espace] | +| Conflux_espace_test | [`0x913975af`][rp-conflux_espace_test] | [`0x71834a3f`][rp721-conflux_espace_test] | +| Harmony | [`0xab7b1be4`][rp-harmony] | [`0x83d6b366`][rp721-harmony] | +| Harmony_test | [`0x96c7d011`][rp-harmony_test] | [`0x981be454`][rp721-harmony_test] | +| Metis | [`0x2cf91AD8`][rp-metis] | [`0x81246335`][rp721-metis] | +| Metis_test | [`0xAb7B1bE4`][rp-metis_test] | [`0x2cf91AD8`][rp721-metis_test] | +| Kardia | [`0x081ea643`][rp-kardia] | [`0xc3e62b2C`][rp721-kardia] | + +[rp-mainnet]: https://etherscan.io/address/0xaBBe1101FD8fa5847c452A6D70C8655532B03C33 +[rp-ropsten]: https://ropsten.etherscan.io/address/0x0722507c3b776A6B205946592016e358B0D34c3F +[rp-bsc]: https://bscscan.com/address/0x0ca42C178e14c618c81B8438043F27d9D38145f6 +[rp-matic]: https://polygonscan.com/address/0x93e0b87A0aD0C991dc1B5176ddCD850c9a78aabb +[rp-arbitrum_rinkeby]: https://rinkeby-explorer.arbitrum.io/address/0x4A77E797031257db72F7D2C3Ec08a4FAc5c8CfE9 +[rp-arbitrum]: https://explorer.arbitrum.io/address/0x83D6b366f21e413f214EB077D5378478e71a5eD2 +[rp-xdai]: https://blockscout.com/xdai/mainnet/address/0x54a0A221C25Fc0a347EC929cFC5db0be17fA2a2B +[rp-goerli]: https://goerli.etherscan.io/address/0x8bF6b979286970860Adc75dc621cf1969b0bE66C +[rp-fantom]: https://ftmscan.com/address/0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98 +[rp-avalanche]: https://snowtrace.io/address/0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 +[rp-celo]: https://explorer.celo.org/address/0xab7b1be4233a04e5c43a810e75657eced8e5463b +[rp-optimism_kovan]: https://kovan-optimistic.etherscan.io/address/0x68EDbfA3E564C987FaaAB54f4FD1E7567D4151Dd +[rp-optimism]: https://optimistic.etherscan.io/address/0x981be454a930479d92C91a0092D204b64845A5D6 +[rp-aurora]: https://explorer.mainnet.aurora.dev/address/0x19f179D7e0D7d9F9d5386afFF64271D98A91615B +[rp-fuse]: https://explorer.fuse.io/address/0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4 +[rp-boba]: https://blockexplorer.boba.network/address/0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98 +[rp-moonriver]: https://moonriver.moonscan.io/address/0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98 +[rp-conflux_espace]: https://evm.confluxscan.io/address/0x96c7d011cdfd467f551605f0f5fce279f86f4186 +[rp-conflux_espace_test]: https://evmtestnet.confluxscan.io/address/0x913975af2bb8a6be4100d7dc5e9765b77f6a5d6c +[rp-harmony]: https://explorer.harmony.one/address/0xab7b1be4233a04e5c43a810e75657eced8e5463b +[rp-harmony_test]: https://explorer.pops.one/address/0x96c7d011cdfd467f551605f0f5fce279f86f4186 +[rp-metis]: https://andromeda-explorer.metis.io/address/0x2cf91AD8C175305EBe6970Bd8f81231585EFbd77 +[rp-metis_test]: https://stardust-explorer.metis.io/address/0xAb7B1bE4233A04e5C43a810E75657ECED8E5463B +[rp-kardia]: https://explorer.kardiachain.io/address/0x081ea6437E73F3b4504b131443309404a9bC2054 +[rp721-mainnet]: https://etherscan.io/address/0x8d285739523FC2Ac8eC9c9C229ee863C8C9bF8C8 +[rp721-ropsten]: https://ropsten.etherscan.io/address/0x8fF42e93C19E44763FD1cD07b9E04d13bA07AD3f +[rp721-bsc]: https://bscscan.com/address/0xf8968e1Fcf1440Be5Cec7Bb495bcee79753d5E06 +[rp721-matic]: https://polygonscan.com/address/0xf6Dc042717EF4C097348bE00f4BaE688dcaDD4eA +[rp721-arbitrum]: https://explorer.arbitrum.io/address/0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4 +[rp721-xdai]: https://blockscout.com/xdai/mainnet/address/0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4 +[rp721-goerli]: https://goerli.etherscan.io/address/0x0a04e23f95E9DB2Fe4C31252548F663fFe3AAe4d +[rp721-fantom]: https://ftmscan.com/address/0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 +[rp721-avalanche]: https://snowtrace.io/address/0x96c7D011cdFD467f551605f0f5Fce279F86F4186 +[rp721-celo]: https://explorer.celo.org/address/0x96c7D011cdFD467f551605f0f5Fce279F86F4186 +[rp721-optimism_kovan]: https://kovan-optimistic.etherscan.io/address/0x556F63d7467c729034585C3e50e54e582222b491 +[rp721-optimism]: https://optimistic.etherscan.io/address/0x02Ea0720254F7fa4eca7d09A1b9C783F1020EbEF +[rp721-aurora]: https://explorer.mainnet.aurora.dev/address/0x05ee315E407C21a594f807D61d6CC11306D1F149 +[rp721-fuse]: https://explorer.fuse.io/address/0x066804d9123bF2609Ed4A4a40b1177a9c5a9Ed51 +[rp721-boba]: https://blockexplorer.boba.network/address/0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 +[rp721-moonriver]: https://moonriver.moonscan.io/address/0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 +[rp721-conflux_espace]: https://evm.confluxscan.io/address/0x5b966f3a32db9c180843bcb40267a66b73e4f022 +[rp721-conflux_espace_test]: https://evmtestnet.confluxscan.io/address/0x71834a3fdea3e70f14a93ed85c6be70925d0cad9 +[rp721-harmony]: https://explorer.harmony.one/address/0x83d6b366f21e413f214eb077d5378478e71a5ed2 +[rp721-harmony_test]: https://explorer.pops.one/address/0x981be454a930479d92c91a0092d204b64845a5d6 +[rp721-metis]: https://andromeda-explorer.metis.io/address/0x812463356F58fc8194645A1838ee6C52D8ca2D26 +[rp721-metis_test]: https://stardust-explorer.metis.io/address/0x2cf91AD8C175305EBe6970Bd8f81231585EFbd77 +[rp721-kardia]: https://explorer.kardiachain.io/address/0xc3e62b2CC70439C32a381Bfc056aCEd1d7162cef + + + +## Test report + +Unit test and performance(gas consumption) results, please see [test report](docs/test_report.txt) and [gas consumption test report](docs/performance_test.txt). + +## Version history + +Change, please see [Change log](docs/CHANGELOG.md) for changes. + +## Contribute + +Any contribution is welcomed to make it better. + +If you have any questions, please create an [issue](https://github.com/DimensionDev/RedPacket/issues). + +## License + +[MIT LICENSE](LICENSE) diff --git a/SmartContractProjectConfig b/SmartContractProjectConfig index 4383d8f..7987991 160000 --- a/SmartContractProjectConfig +++ b/SmartContractProjectConfig @@ -1 +1 @@ -Subproject commit 4383d8f1407aad1a49888fabbc04b11b938d8b43 +Subproject commit 7987991da4a3690572ef6d59f82665dbeb8214a5 diff --git a/contracts/redpacket.sol b/contracts/redpacket.sol index eba6d9a..357a889 100644 --- a/contracts/redpacket.sol +++ b/contracts/redpacket.sol @@ -9,8 +9,7 @@ **/ pragma solidity >= 0.8.0; -import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; +import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts/utils/math/SafeMath.sol"; import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol"; @@ -56,7 +55,7 @@ contract HappyRedPacket is Initializable { uint remaining_balance ); - using SafeERC20 for IERC20; + using SafeERC20Upgradeable for IERC20Upgradeable; uint32 nonce; mapping(bytes32 => RedPacket) redpacket_by_id; bytes32 private seed; @@ -84,9 +83,9 @@ contract HappyRedPacket is Initializable { else if (_token_type == 1) { // https://github.com/DimensionDev/Maskbook/issues/4168 // `received_amount` is not necessarily equal to `_total_tokens` - uint256 balance_before_transfer = IERC20(_token_addr).balanceOf(address(this)); - IERC20(_token_addr).safeTransferFrom(msg.sender, address(this), _total_tokens); - uint256 balance_after_transfer = IERC20(_token_addr).balanceOf(address(this)); + uint256 balance_before_transfer = IERC20Upgradeable(_token_addr).balanceOf(address(this)); + IERC20Upgradeable(_token_addr).safeTransferFrom(msg.sender, address(this), _total_tokens); + uint256 balance_after_transfer = IERC20Upgradeable(_token_addr).balanceOf(address(this)); received_amount = balance_after_transfer.sub(balance_before_transfer); require(received_amount >= _number, "#received > #packets"); } @@ -271,7 +270,7 @@ contract HappyRedPacket is Initializable { } function transfer_token(address token_address, address recipient_address, uint amount) internal{ - IERC20(token_address).safeTransfer(recipient_address, amount); + IERC20Upgradeable(token_address).safeTransfer(recipient_address, amount); } // A boring wrapper diff --git a/deploy/erc721_support.ts b/deploy/erc721_support.ts index 3a9fb54..c40f02b 100644 --- a/deploy/erc721_support.ts +++ b/deploy/erc721_support.ts @@ -1,39 +1,21 @@ -import { HardhatRuntimeEnvironment } from 'hardhat/types' -import { DeployFunction } from 'hardhat-deploy/types' -import { ethers, upgrades } from 'hardhat' +import { HardhatRuntimeEnvironment } from 'hardhat/types'; +import { DeployFunction } from 'hardhat-deploy/types'; +import { ethers, upgrades } from 'hardhat'; +import fs from "fs/promises"; +import path from "path"; +import { parse } from "csv-parse/sync"; -type MyMapLikeType = Record -const deployedContracts: MyMapLikeType = { - mainnet: '0x8d285739523FC2Ac8eC9c9C229ee863C8C9bF8C8', - ropsten: '0x8fF42e93C19E44763FD1cD07b9E04d13bA07AD3f', - bsc_mainnet: '0xf8968e1Fcf1440Be5Cec7Bb495bcee79753d5E06', - matic_mainnet: '0xf6Dc042717EF4C097348bE00f4BaE688dcaDD4eA', - arbitrum: '0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4', - xdai: '0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4', - goerli: '0x0a04e23f95E9DB2Fe4C31252548F663fFe3AAe4d', - fantom: '0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0', - avalanche: '0x96c7D011cdFD467f551605f0f5Fce279F86F4186', - celo: '0x96c7D011cdFD467f551605f0f5Fce279F86F4186', - optimism: '0x02Ea0720254F7fa4eca7d09A1b9C783F1020EbEF', - optimism_kovan: '0x556F63d7467c729034585C3e50e54e582222b491', - aurora: '0x05ee315E407C21a594f807D61d6CC11306D1F149', - fuse: '0x066804d9123bF2609Ed4A4a40b1177a9c5a9Ed51', - boba: '0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0', - moonriver: '0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0', - conflux_eSpace: '0x5b966f3a32db9c180843bcb40267a66b73e4f022', - conflux_eSpace_test: '0x71834a3fdea3e70f14a93ed85c6be70925d0cad9', - harmony: '0x83d6b366f21e413f214eb077d5378478e71a5ed2', - metis: '0x812463356F58fc8194645A1838ee6C52D8ca2D26', -} +const ADDRESS_TABLE_PATH = path.resolve(__dirname, "..", "helper_scripts", "contract-addresses.csv"); const func: DeployFunction = async function(hre: HardhatRuntimeEnvironment) { const { deployments, getNamedAccounts } = hre const { deploy } = deployments const { deployer } = await getNamedAccounts() const network: string = hre.hardhatArguments.network ? hre.hardhatArguments.network : 'ropsten' + const deployedContracts = await loadDeployedAddress(); const proxyAddress = deployedContracts[network] - if (false) { + if (true) { // deploy, we normally do this only once const HappyRedPacketImpl_erc721 = await ethers.getContractFactory('HappyRedPacket_ERC721') const HappyRedPacketProxy_erc721 = await upgrades.deployProxy(HappyRedPacketImpl_erc721, []) @@ -62,6 +44,17 @@ const func: DeployFunction = async function(hre: HardhatRuntimeEnvironment) { } } +async function loadDeployedAddress(): Promise> { + const data = await fs.readFile(ADDRESS_TABLE_PATH, "utf-8"); + const columns = ['Chain', 'HappyRedPacket', 'HappyRedPacket_ERC721']; + const records = parse(data, { delimiter: ',', columns, from: 2 }); + let deployedContract: Record = {}; + for (const { Chain, HappyRedPacket_ERC721 } of records) { + deployedContract[Chain.toLowerCase()] = HappyRedPacket_ERC721; + } + return deployedContract; +} + func.tags = ['HappyRedPacket_ERC721'] module.exports = func diff --git a/deploy/redpacket.ts b/deploy/redpacket.ts index b6f29cc..e0dbc6d 100644 --- a/deploy/redpacket.ts +++ b/deploy/redpacket.ts @@ -1,40 +1,21 @@ -import { HardhatRuntimeEnvironment } from 'hardhat/types' -import { DeployFunction } from 'hardhat-deploy/types' -import { ethers, upgrades } from 'hardhat' +import { HardhatRuntimeEnvironment } from 'hardhat/types'; +import { DeployFunction } from 'hardhat-deploy/types'; +import { ethers, upgrades } from 'hardhat'; +import fs from "fs/promises"; +import path from "path"; +import { parse } from "csv-parse/sync"; -type MyMapLikeType = Record -const deployedContracts: MyMapLikeType = { - mainnet: '0xaBBe1101FD8fa5847c452A6D70C8655532B03C33', - ropsten: '0x0722507c3b776A6B205946592016e358B0D34c3F', - bsc_mainnet: '0x0ca42C178e14c618c81B8438043F27d9D38145f6', - matic_mainnet: '0x93e0b87A0aD0C991dc1B5176ddCD850c9a78aabb', - arbitrum: '0x83D6b366f21e413f214EB077D5378478e71a5eD2', - arbitrum_rinkeby: '0x4A77E797031257db72F7D2C3Ec08a4FAc5c8CfE9', - xdai: '0x54a0A221C25Fc0a347EC929cFC5db0be17fA2a2B', - goerli: '0x8bF6b979286970860Adc75dc621cf1969b0bE66C', - fantom: '0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98', - avalanche: '0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0', - celo: '0x871F2635EeB0bA3D9f90C4524E3f148C31393F9d', - optimism: '0x981be454a930479d92C91a0092D204b64845A5D6', - optimism_kovan: '0x68EDbfA3E564C987FaaAB54f4FD1E7567D4151Dd', - aurora: '0x19f179D7e0D7d9F9d5386afFF64271D98A91615B', - fuse: '0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4', - boba: '0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98', - moonriver: '0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98', - conflux_eSpace: '0x96c7d011cdfd467f551605f0f5fce279f86f4186', - conflux_eSpace_test: '0x913975af2bb8a6be4100d7dc5e9765b77f6a5d6c', - harmony: '0xab7b1be4233a04e5c43a810e75657eced8e5463b', - metis: '0x2cf91AD8C175305EBe6970Bd8f81231585EFbd77', -} +const ADDRESS_TABLE_PATH = path.resolve(__dirname, "..", "helper_scripts", "contract-addresses.csv"); const func: DeployFunction = async function(hre: HardhatRuntimeEnvironment) { const { deployments, getNamedAccounts } = hre const { deploy } = deployments const { deployer } = await getNamedAccounts() const network: string = hre.hardhatArguments.network ? hre.hardhatArguments.network : 'ropsten' + const deployedContracts = await loadDeployedAddress(); const proxyAddress = deployedContracts[network] - - if (false) { + + if (true) { // deploy, we normally do this only once const HappyRedPacketImpl = await ethers.getContractFactory('HappyRedPacket') const HappyRedPacketProxy = await upgrades.deployProxy(HappyRedPacketImpl, []) @@ -63,6 +44,17 @@ const func: DeployFunction = async function(hre: HardhatRuntimeEnvironment) { } } +async function loadDeployedAddress(): Promise> { + const data = await fs.readFile(ADDRESS_TABLE_PATH, "utf-8"); + const columns = ['Chain', 'HappyRedPacket', 'HappyRedPacket_ERC721']; + const records = parse(data, { delimiter: ',', columns, from: 2 }); + let deployedContract: Record = {}; + for (const { Chain, HappyRedPacket } of records) { + deployedContract[Chain.toLowerCase()] = HappyRedPacket; + } + return deployedContract; +} + func.tags = ['HappyRedPacket'] module.exports = func diff --git a/helper_scripts/contract-addresses.csv b/helper_scripts/contract-addresses.csv index 8d415e1..89fb3df 100644 --- a/helper_scripts/contract-addresses.csv +++ b/helper_scripts/contract-addresses.csv @@ -3,22 +3,23 @@ Mainnet,0xaBBe1101FD8fa5847c452A6D70C8655532B03C33,0x8d285739523FC2Ac8eC9c9C229e Ropsten,0x0722507c3b776A6B205946592016e358B0D34c3F,0x8fF42e93C19E44763FD1cD07b9E04d13bA07AD3f BSC,0x0ca42C178e14c618c81B8438043F27d9D38145f6,0xf8968e1Fcf1440Be5Cec7Bb495bcee79753d5E06 Matic,0x93e0b87A0aD0C991dc1B5176ddCD850c9a78aabb,0xf6Dc042717EF4C097348bE00f4BaE688dcaDD4eA -Rinkeby_arbitrum,0x4A77E797031257db72F7D2C3Ec08a4FAc5c8CfE9, +Arbitrum_rinkeby,0x4A77E797031257db72F7D2C3Ec08a4FAc5c8CfE9, Arbitrum,0x83D6b366f21e413f214EB077D5378478e71a5eD2,0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4 xDai,0x54a0A221C25Fc0a347EC929cFC5db0be17fA2a2B,0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4 Goerli,0x8bF6b979286970860Adc75dc621cf1969b0bE66C,0x0a04e23f95E9DB2Fe4C31252548F663fFe3AAe4d Fantom,0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98,0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 Avalanche,0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0,0x96c7D011cdFD467f551605f0f5Fce279F86F4186 Celo,0xab7b1be4233a04e5c43a810e75657eced8e5463b,0x96c7D011cdFD467f551605f0f5Fce279F86F4186 -Kovan_optimistic,0x68EDbfA3E564C987FaaAB54f4FD1E7567D4151Dd,0x556F63d7467c729034585C3e50e54e582222b491 -Optimistic,0x981be454a930479d92C91a0092D204b64845A5D6,0x02Ea0720254F7fa4eca7d09A1b9C783F1020EbEF +Optimism_kovan,0x68EDbfA3E564C987FaaAB54f4FD1E7567D4151Dd,0x556F63d7467c729034585C3e50e54e582222b491 +Optimism,0x981be454a930479d92C91a0092D204b64845A5D6,0x02Ea0720254F7fa4eca7d09A1b9C783F1020EbEF Aurora,0x19f179D7e0D7d9F9d5386afFF64271D98A91615B,0x05ee315E407C21a594f807D61d6CC11306D1F149 Fuse,0x561c5f3a19871ecb1273D6D8eCc276BeEDa5c8b4,0x066804d9123bF2609Ed4A4a40b1177a9c5a9Ed51 Boba,0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98,0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 Moonriver,0x578a7Fee5f0D8CEc7d00578Bf37374C5b95C4b98,0xF9F7C1496c21bC0180f4B64daBE0754ebFc8A8c0 -Conflux,0x96c7d011cdfd467f551605f0f5fce279f86f4186,0x5b966f3a32db9c180843bcb40267a66b73e4f022 -Conflux_test,0x913975af2bb8a6be4100d7dc5e9765b77f6a5d6c,0x71834a3fdea3e70f14a93ed85c6be70925d0cad9 +Conflux_espace,0x96c7d011cdfd467f551605f0f5fce279f86f4186,0x5b966f3a32db9c180843bcb40267a66b73e4f022 +Conflux_espace_test,0x913975af2bb8a6be4100d7dc5e9765b77f6a5d6c,0x71834a3fdea3e70f14a93ed85c6be70925d0cad9 Harmony,0xab7b1be4233a04e5c43a810e75657eced8e5463b,0x83d6b366f21e413f214eb077d5378478e71a5ed2 Harmony_test,0x96c7d011cdfd467f551605f0f5fce279f86f4186,0x981be454a930479d92c91a0092d204b64845a5d6 Metis,0x2cf91AD8C175305EBe6970Bd8f81231585EFbd77,0x812463356F58fc8194645A1838ee6C52D8ca2D26 -Metis_test,0xAb7B1bE4233A04e5C43a810E75657ECED8E5463B,0x2cf91AD8C175305EBe6970Bd8f81231585EFbd77 \ No newline at end of file +Metis_test,0xAb7B1bE4233A04e5C43a810E75657ECED8E5463B,0x2cf91AD8C175305EBe6970Bd8f81231585EFbd77 +Kardia,0x081ea6437E73F3b4504b131443309404a9bC2054,0xc3e62b2CC70439C32a381Bfc056aCEd1d7162cef \ No newline at end of file diff --git a/helper_scripts/generate-readme.ts b/helper_scripts/generate-readme.ts index 1c0b11a..a1e485f 100644 --- a/helper_scripts/generate-readme.ts +++ b/helper_scripts/generate-readme.ts @@ -26,7 +26,7 @@ main(); function* makeTable(rows: DeployedAddressRow[]) { yield "| Chain | HappyRedPacket | HappyRedPacket_ERC721 |"; - yield "| - | :-: | :-: |"; + yield "| - | - | - |"; for (const { Chain, HappyRedPacket, HappyRedPacket_ERC721 } of rows) { const rpElement = formElement(HappyRedPacket, `rp-${Chain}`); const nftRpElement = formElement(HappyRedPacket_ERC721, `rp721-${Chain}`); diff --git a/helper_scripts/types.ts b/helper_scripts/types.ts index 02a1465..2aafb39 100644 --- a/helper_scripts/types.ts +++ b/helper_scripts/types.ts @@ -4,25 +4,26 @@ export enum ChainId { Rinkeby = 4, BSC = 56, Matic = 137, - Rinkeby_arbitrum = 421611, + Arbitrum_rinkeby = 421611, Arbitrum = 42161, Goerli = 5, Fantom = 250, Celo = 42220, Avalanche = 43114, - Kovan_optimistic = 69, - Optimistic = 10, + Optimism_kovan = 69, + Optimism = 10, Aurora = 1313161554, Fuse = 122, Boba = 288, Moonriver = 1285, - Conflux_test = 71, - Conflux = 1030, + Conflux_espace_test = 71, + Conflux_espace = 1030, Harmony = 1666600000, Harmony_test = 1666700000, Metis = 1088, Metis_test = 28, xDai = 100, + Kardia = 24, } function makeAddressDetailURL(domain: string) { @@ -39,21 +40,22 @@ export const BlockExplorer: Record string> = { [ChainId.Fantom]: makeAddressDetailURL("ftmscan.com"), [ChainId.Celo]: makeAddressDetailURL("explorer.celo.org"), [ChainId.Avalanche]: makeAddressDetailURL("snowtrace.io"), - [ChainId.Kovan_optimistic]: makeAddressDetailURL("kovan-optimistic.etherscan.io"), - [ChainId.Optimistic]: makeAddressDetailURL("optimistic.etherscan.io"), + [ChainId.Optimism_kovan]: makeAddressDetailURL("kovan-optimistic.etherscan.io"), + [ChainId.Optimism]: makeAddressDetailURL("optimistic.etherscan.io"), [ChainId.Aurora]: makeAddressDetailURL("explorer.mainnet.aurora.dev"), [ChainId.Fuse]: makeAddressDetailURL("explorer.fuse.io"), [ChainId.Boba]: makeAddressDetailURL("blockexplorer.boba.network"), [ChainId.Moonriver]: makeAddressDetailURL("moonriver.moonscan.io"), - [ChainId.Conflux_test]: makeAddressDetailURL("evmtestnet.confluxscan.io"), - [ChainId.Conflux]: makeAddressDetailURL("evm.confluxscan.io"), + [ChainId.Conflux_espace_test]: makeAddressDetailURL("evmtestnet.confluxscan.io"), + [ChainId.Conflux_espace]: makeAddressDetailURL("evm.confluxscan.io"), [ChainId.Harmony]: makeAddressDetailURL("explorer.harmony.one"), [ChainId.Harmony_test]: makeAddressDetailURL("explorer.pops.one"), [ChainId.Metis]: makeAddressDetailURL("andromeda-explorer.metis.io"), [ChainId.Metis_test]: makeAddressDetailURL("stardust-explorer.metis.io"), [ChainId.xDai]: (address) => `https://blockscout.com/xdai/mainnet/address/${address}`, [ChainId.Arbitrum]: makeAddressDetailURL("explorer.arbitrum.io"), - [ChainId.Rinkeby_arbitrum]: makeAddressDetailURL("rinkeby-explorer.arbitrum.io"), + [ChainId.Arbitrum_rinkeby]: makeAddressDetailURL("rinkeby-explorer.arbitrum.io"), + [ChainId.Kardia]: makeAddressDetailURL("explorer.kardiachain.io") } export type DeployedAddressRow = { diff --git a/package-lock.json b/package-lock.json index 8753196..e60158b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,12 +42,6 @@ "@cspotcode/source-map-consumer": "0.8.0" } }, - "@cto.af/textdecoder": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/@cto.af/textdecoder/-/textdecoder-0.0.0.tgz", - "integrity": "sha512-sJpx3F5xcVV/9jNYJQtvimo4Vfld/nD3ph+ZWtQzZ03Zo8rJC7QKQTRcIGS13Rcz80DwFNthCWMrd58vpY4ZAQ==", - "dev": true - }, "@ethereumjs/block": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/@ethereumjs/block/-/block-3.4.0.tgz", @@ -3421,25 +3415,83 @@ "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.1.0.tgz", "integrity": "sha512-TihZitscnaHNcZgXGj9zDLDyCqjziytB4tMCwXq0XimfWkAjBYyk5/pOsDbbwcavhlc79HhpTEpQcrMnPVa1mw==" }, + "@openzeppelin/contracts-upgradeable": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.5.2.tgz", + "integrity": "sha512-xgWZYaPlrEOQo3cBj97Ufiuv79SPd8Brh4GcFYhPgb6WvAq4ppz8dWKL6h+jLAK01rUqMRp/TS9AdXgAeNvCLA==" + }, "@openzeppelin/hardhat-upgrades": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@openzeppelin/hardhat-upgrades/-/hardhat-upgrades-1.9.0.tgz", - "integrity": "sha512-ND1sqm8dpTY6CZLdaC5IgtUo6zvlVgSeqadrWRbr/N7J2Bs2JsINWA2G+r4IeunzbcOJFB7GHTs/RkFR6hNLmA==", + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/@openzeppelin/hardhat-upgrades/-/hardhat-upgrades-1.17.0.tgz", + "integrity": "sha512-GNxR3/3fCKQsFpBi/r+5ib6U81UM9KCypmcOQxuCkVp9JKJ80/3hQdg1R+AQku/dlnhutPsfkCokH2LZFc5mNA==", "dev": true, "requires": { - "@openzeppelin/upgrades-core": "^1.8.0" + "@openzeppelin/upgrades-core": "^1.14.1", + "chalk": "^4.1.0", + "proper-lockfile": "^4.1.1" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } } }, "@openzeppelin/upgrades-core": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@openzeppelin/upgrades-core/-/upgrades-core-1.8.0.tgz", - "integrity": "sha512-hO/SqUusFzD8mxrtDllShTE0eeWXsBkrR8zjjr8C8j+/gzvWQnd9HkNGTh7bpf8giUGzkERDuOOpFdSI1R3yvQ==", + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/@openzeppelin/upgrades-core/-/upgrades-core-1.14.1.tgz", + "integrity": "sha512-iKlh1mbUxyfdjdEiUFyhMkqirfas+DMUu7ED53nZbHEyhcYsm+5Fl/g0Bv6bZA+a7k8kO8+22DNEKsqaDUBc2Q==", "dev": true, "requires": { "bn.js": "^5.1.2", - "cbor": "^7.0.0", + "cbor": "^8.0.0", "chalk": "^4.1.0", - "compare-versions": "^3.6.0", + "compare-versions": "^4.0.0", "debug": "^4.1.1", "ethereumjs-util": "^7.0.3", "proper-lockfile": "^4.1.1", @@ -3471,9 +3523,9 @@ "dev": true }, "chalk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", - "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "requires": { "ansi-styles": "^4.1.0", @@ -3496,16 +3548,15 @@ "dev": true }, "ethereumjs-util": { - "version": "7.0.10", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.0.10.tgz", - "integrity": "sha512-c/xThw6A+EAnej5Xk5kOzFzyoSnw0WX0tSlZ6pAsfGVvQj3TItaDg9b1+Fz1RJXA+y2YksKwQnuzgt1eY6LKzw==", + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.4.tgz", + "integrity": "sha512-p6KmuPCX4mZIqsQzXfmSx9Y0l2hqf+VkAiwSisW3UKUFdk8ZkAt+AYaor83z2nSi6CU2zSsXMlD80hAbNEGM0A==", "dev": true, "requires": { "@types/bn.js": "^5.1.0", "bn.js": "^5.1.2", "create-hash": "^1.1.2", "ethereum-cryptography": "^0.1.3", - "ethjs-util": "0.1.6", "rlp": "^2.2.4" } }, @@ -5417,13 +5468,12 @@ } }, "cbor": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cbor/-/cbor-7.0.6.tgz", - "integrity": "sha512-rgt2RFogHGDLFU5r0kSfyeBc+de55DwYHP73KxKsQxsR5b0CYuQPH6AnJaXByiohpLdjQqj/K0SFcOV+dXdhSA==", + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/cbor/-/cbor-8.1.0.tgz", + "integrity": "sha512-DwGjNW9omn6EwP70aXsn7FQJx5kO12tX0bZkaTjzdVFM6/7nhA4t0EENocKGx6D2Bch9PE2KzCUf5SceBdeijg==", "dev": true, "requires": { - "@cto.af/textdecoder": "^0.0.0", - "nofilter": "^2.0.3" + "nofilter": "^3.1.0" } }, "chai": { @@ -5703,9 +5753,9 @@ "integrity": "sha512-6CYPa+JP2ftfRU2qkDK+UTVeQYosOg/2GbcjIcKPHfinyOLPVGXu/ovN86RP49Re5ndJK1N0kuiidFFuepc4ZQ==" }, "compare-versions": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-3.6.0.tgz", - "integrity": "sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA==", + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-4.1.3.tgz", + "integrity": "sha512-WQfnbDcrYnGr55UwbxKiQKASnTtNnaAWVi8jZyy8NTpVAXWACSne8lMD1iaIo9AiU6mnuLvSVshCzewVuWxHUg==", "dev": true }, "concat-map": { @@ -11731,13 +11781,10 @@ "dev": true }, "nofilter": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/nofilter/-/nofilter-2.0.3.tgz", - "integrity": "sha512-FbuXC+lK+GU2+63D1kC1ETiZo+Z7SIi7B+mxKTCH1byrh6WFvfBCN/wpherFz0a0bjGd7EKTst/cz0yLeNngug==", - "dev": true, - "requires": { - "@cto.af/textdecoder": "^0.0.0" - } + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/nofilter/-/nofilter-3.1.0.tgz", + "integrity": "sha512-l2NNj07e9afPnhAhvgVrCD/oy2Ai1yfLpuo3EpiO1jFTsB4sFz6oIfAfSZyQzVpkZQ9xS8ZS5g1jCBgq4Hwo0g==", + "dev": true }, "nopt": { "version": "3.0.6", @@ -13235,9 +13282,9 @@ } }, "solidity-ast": { - "version": "0.4.26", - "resolved": "https://registry.npmjs.org/solidity-ast/-/solidity-ast-0.4.26.tgz", - "integrity": "sha512-UR9Ip3QoiEvNON5lOA28JNEzKT+1fLFA4xpIbZSEl4CEnYr/a4Pj0qMJh0652UQ51pKplI/nncZsDOMzdHdCcg==", + "version": "0.4.31", + "resolved": "https://registry.npmjs.org/solidity-ast/-/solidity-ast-0.4.31.tgz", + "integrity": "sha512-kX6o4XE4ihaqENuRRTMJfwQNHoqWusPENZUlX4oVb19gQdfi7IswFWnThONHSW/61umgfWdKtCBgW45iuOTryQ==", "dev": true }, "solidity-comments-extractor": { diff --git a/package.json b/package.json index 7a14706..90affad 100644 --- a/package.json +++ b/package.json @@ -4,46 +4,21 @@ "license": "MIT", "main": "hardhat.config.ts", "scripts": { - "test": "npx hardhat test", + "test": "hardhat test", "test:coverage": "hardhat coverage", - "lint": "npx hardhat check", + "lint": "hardhat check", "compile": "hardhat compile", - "deploy:arbitrum_rinkeby": "hardhat --network arbitrum_rinkeby deploy", - "deploy:arbitrum": "hardhat --network arbitrum deploy", - "deploy:optimism": "hardhat --network optimism deploy", - "deploy:optimism_kovan": "hardhat --network optimism_kovan deploy", - "deploy:mainnet": "hardhat --network mainnet deploy", - "deploy:ropsten": "hardhat --network ropsten deploy", - "deploy:rinkeby": "hardhat --network rinkeby deploy", - "deploy:goerli": "hardhat --network goerli deploy", - "deploy:fantom": "hardhat --network fantom deploy", - "deploy:celo": "hardhat --network celo deploy", - "deploy:avalanche_test": "hardhat --network avalanche_test deploy", - "deploy:avalanche": "hardhat --network avalanche deploy", - "deploy:xdai": "hardhat --network xdai deploy", - "deploy:bsc_mainnet": "hardhat --network bsc_mainnet deploy", - "deploy:matic_mainnet": "hardhat --network matic_mainnet deploy", - "deploy:aurora_test": "hardhat --network aurora_test deploy", - "deploy:aurora": "hardhat --network aurora deploy", - "deploy:fuse": "hardhat --network fuse deploy", - "deploy:boba": "hardhat --network boba deploy", - "deploy:boba_test": "hardhat --network boba_test deploy", - "deploy:metis": "hardhat --network metis deploy", - "deploy:metis_test": "hardhat --network metis_test deploy", - "deploy:moonriver": "hardhat --network moonriver deploy", - "deploy:cfx_test": "hardhat --network conflux_eSpace_test deploy", - "deploy:cfx": "hardhat --network conflux_eSpace deploy", - "deploy:harmony": "hardhat --network harmony deploy", - "deploy:harmony_test": "hardhat --network harmony_test deploy", + "deploy": "hardhat deploy --network", "test:erc721": "hardhat test ./test/TestRP_erc721.js", "test:normal": "hardhat test ./test/TestRedPacket.js", - "prettier:solidity": "./node_modules/.bin/prettier --write contracts/**/*.sol", + "prettier:solidity": "prettier --write contracts/**/*.sol", "format": "prettier --write './test/*.js' './deploy/*.ts'" }, "dependencies": { "@nomiclabs/hardhat-etherscan": "^3.0.3", "@nomiclabs/hardhat-solhint": "^2.0.0", - "@openzeppelin/contracts": "^4.0.0" + "@openzeppelin/contracts": "^4.0.0", + "@openzeppelin/contracts-upgradeable": "^4.5.2" }, "devDependencies": { "@nomiclabs/buidler": "^1.4.8", @@ -51,7 +26,7 @@ "@nomiclabs/hardhat-truffle5": "^2.0.5", "@nomiclabs/hardhat-waffle": "^2.0.3", "@nomiclabs/hardhat-web3": "^2.0.0", - "@openzeppelin/hardhat-upgrades": "^1.9.0", + "@openzeppelin/hardhat-upgrades": "^1.17.0", "@types/prettier": "^2.4.4", "bignumber.js": "^9.0.2", "chai": "^4.3.6",