From 6db23c11e049efbd0e75f72b7cc61b947b2daa47 Mon Sep 17 00:00:00 2001 From: oskal174 Date: Thu, 23 Nov 2023 12:30:09 +0500 Subject: [PATCH] cronos support --- .env.example | 55 ++++++++++++++++++++++++++++++++ CONTRIBUTORS.md | 2 ++ Modules/Common/EVMMainModule.php | 5 ++- Modules/Common/EVMTraits.php | 1 + Modules/CronosERC1155Module.php | 20 ++++++++++++ Modules/CronosERC20Module.php | 20 ++++++++++++ Modules/CronosERC721Module.php | 20 ++++++++++++ Modules/CronosMainModule.php | 30 +++++++++++++++++ Modules/CronosTraceModule.php | 24 ++++++++++++++ 9 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 Modules/CronosERC1155Module.php create mode 100644 Modules/CronosERC20Module.php create mode 100644 Modules/CronosERC721Module.php create mode 100644 Modules/CronosMainModule.php create mode 100644 Modules/CronosTraceModule.php diff --git a/.env.example b/.env.example index f41639e6..50770cd9 100644 --- a/.env.example +++ b/.env.example @@ -744,6 +744,61 @@ MODULE_zcash-main_NODES[]=http://login:password@127.0.0.2:1234/ MODULE_zcash-main_REQUESTER_TIMEOUT=60 MODULE_zcash-main_REQUESTER_THREADS=12 +###################### +## Main Cronos Module +###################### + +MODULES[]=cronos-main +MODULE_cronos-main_CLASS=CronosMainModule +MODULE_cronos-main_NODES[]=http://login:password@127.0.0.2:1234/ +MODULE_cronos-main_NODES[]=http://login:password@127.0.0.2:1234/ +MODULE_cronos-main_REQUESTER_TIMEOUT=60 +MODULE_cronos-main_REQUESTER_THREADS=12 + +###################### +## Trace Cronos Module +###################### + +MODULES[]=cronos-trace +MODULE_cronos-trace_CLASS=CronosTraceModule +MODULE_cronos-trace_NODES[]=http://login:password@127.0.0.2:1234/ +MODULE_cronos-trace_NODES[]=http://login:password@127.0.0.2:1234/ +MODULE_cronos-trace_REQUESTER_TIMEOUT=60 +MODULE_cronos-trace_REQUESTER_THREADS=12 + +###################### +## ERC20 Cronos Module +###################### + +MODULES[]=cronos-erc-20 +MODULE_cronos-erc-20_CLASS=CronosERC20Module +MODULE_cronos-erc-20_NODES[]=http://login:password@127.0.0.2:1234/ +MODULE_cronos-erc-20_NODES[]=http://login:password@127.0.0.2:1234/ +MODULE_cronos-erc-20_REQUESTER_TIMEOUT=60 +MODULE_cronos-erc-20_REQUESTER_THREADS=12 + +###################### +## ERC721 Cronos Module +###################### + +MODULES[]=cronos-erc-721 +MODULE_cronos-erc-721_CLASS=CronosERC721Module +MODULE_cronos-erc-721_NODES[]=http://login:password@127.0.0.2:1234/ +MODULE_cronos-erc-721_NODES[]=http://login:password@127.0.0.2:1234/ +MODULE_cronos-erc-721_REQUESTER_TIMEOUT=60 +MODULE_cronos-erc-721_REQUESTER_THREADS=12 + +###################### +## ERC1155 Cronos Module +###################### + +MODULES[]=cronos-erc-1155 +MODULE_cronos-erc-1155_CLASS=CronosERC1155Module +MODULE_cronos-erc-1155_NODES[]=http://login:password@127.0.0.2:1234/ +MODULE_cronos-erc-1155_NODES[]=http://login:password@127.0.0.2:1234/ +MODULE_cronos-erc-1155_REQUESTER_TIMEOUT=60 +MODULE_cronos-erc-1155_REQUESTER_THREADS=12 + ############################ # Titles, descriptions, etc. ############################ diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 7c87c9e5..86ac4c9c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -9,3 +9,5 @@ - TVM modules * [Oleg Makaussov](https://github.com/Lorgansar) - Cardano Tokens modules +* [Kirill Kuzminykh](https://github.com/Oskal174) + - Cronos modules diff --git a/Modules/Common/EVMMainModule.php b/Modules/Common/EVMMainModule.php index e6336359..7374f03f 100644 --- a/Modules/Common/EVMMainModule.php +++ b/Modules/Common/EVMMainModule.php @@ -67,7 +67,7 @@ final public function post_post_initialize() if (is_null($this->reward_function)) throw new DeveloperError("`reward_function` is not set (developer error)"); - + if (in_array(EVMSpecialFeatures::PoSWithdrawals, $this->extra_features) && is_null($this->staking_contract)) throw new DeveloperError('`staking_contract` is not set when `PoSWithdrawals` is enabled'); @@ -236,6 +236,9 @@ final public function pre_process_block($block_id) result_in: 'result', timeout: $this->timeout); } + if (in_array(EVMSpecialFeatures::FeesToTreasury, $this->extra_features)) + $miner = 'treasury'; + // Data processing $this->block_time = date('Y-m-d H:i:s', to_int64_from_0xhex($block_time)); diff --git a/Modules/Common/EVMTraits.php b/Modules/Common/EVMTraits.php index 76b6e5e4..1c034f12 100644 --- a/Modules/Common/EVMTraits.php +++ b/Modules/Common/EVMTraits.php @@ -33,6 +33,7 @@ enum EVMSpecialFeatures case zkEVM; case HasSystemTransactions; case EffectiveGasPriceCanBeZero; + case FeesToTreasury; } trait EVMTraits diff --git a/Modules/CronosERC1155Module.php b/Modules/CronosERC1155Module.php new file mode 100644 index 00000000..3d46b4a9 --- /dev/null +++ b/Modules/CronosERC1155Module.php @@ -0,0 +1,20 @@ +blockchain = 'cronos'; + $this->module = 'cronos-erc-1155'; + $this->is_main = false; + $this->first_block_date = '2021-11-08'; + $this->first_block_id = 0; + } +} diff --git a/Modules/CronosERC20Module.php b/Modules/CronosERC20Module.php new file mode 100644 index 00000000..8d97b24b --- /dev/null +++ b/Modules/CronosERC20Module.php @@ -0,0 +1,20 @@ +blockchain = 'cronos'; + $this->module = 'cronos-erc-20'; + $this->is_main = false; + $this->first_block_date = '2021-11-08'; + $this->first_block_id = 1; + } +} diff --git a/Modules/CronosERC721Module.php b/Modules/CronosERC721Module.php new file mode 100644 index 00000000..32642e05 --- /dev/null +++ b/Modules/CronosERC721Module.php @@ -0,0 +1,20 @@ +blockchain = 'cronos'; + $this->module = 'cronos-erc-721'; + $this->is_main = false; + $this->first_block_date = '2021-11-08'; + $this->first_block_id = 0; + } +} diff --git a/Modules/CronosMainModule.php b/Modules/CronosMainModule.php new file mode 100644 index 00000000..751ff17f --- /dev/null +++ b/Modules/CronosMainModule.php @@ -0,0 +1,30 @@ +blockchain = 'cronos'; + $this->module = 'cronos-main'; + $this->is_main = true; + $this->currency = 'cronos'; + $this->currency_details = ['name' => 'Cronos', 'symbol' => 'CRO', 'decimals' => 18, 'description' => null]; + $this->first_block_id = 1; + $this->first_block_date = '2021-11-08'; + + // EVMMainModule + $this->evm_implementation = EVMImplementation::geth; + $this->extra_features = [EVMSpecialFeatures::FeesToTreasury]; + $this->reward_function = function($block_id) + { + return '0'; + }; + } +} diff --git a/Modules/CronosTraceModule.php b/Modules/CronosTraceModule.php new file mode 100644 index 00000000..7482e198 --- /dev/null +++ b/Modules/CronosTraceModule.php @@ -0,0 +1,24 @@ +blockchain = 'cronos'; + $this->module = 'cronos-trace'; + $this->complements = 'cronos-main'; + $this->is_main = false; + $this->first_block_id = 1; + $this->first_block_date = '2021-11-08'; + + // EVMTraceModule + $this->evm_implementation = EVMImplementation::geth; + } +}