-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathGnosisChainMainModule.php
More file actions
57 lines (47 loc) · 2.39 KB
/
GnosisChainMainModule.php
File metadata and controls
57 lines (47 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php declare(strict_types = 1);
/* Idea (c) 2023 Nikita Zhavoronkov, nikzh@nikzh.com
* Copyright (c) 2023-2024 3xpl developers, 3@3xpl.com, see CONTRIBUTORS.md
* Distributed under the MIT software license, see LICENSE.md */
/* This is the main Gnosis Chain module. It requires either a Nethermind or an Erigon node to run (but the latter is much faster).
* Not that for some transactions such as 0x0cd5fc7f3d1ff461a01de546c8c32d4ec74fb66e640dbe4ed537f3a6ab2e27bc, Nethermind returns
* the created contract address neither in the transaction info, nor in the transaction receipt. That's probably a bug with
* Nethermind which is not observed with Erigon. `No address` exception will be thrown for such transactions. */
final class GnosisChainMainModule extends EVMMainModule implements Module, BalanceSpecial, TransactionSpecials, AddressSpecials, BroadcastTransactionSpecial
{
function initialize()
{
// CoreModule
$this->blockchain = 'gnosis-chain';
$this->module = 'gnosis-chain-main';
$this->is_main = true;
$this->first_block_date = '2018-10-08';
$this->first_block_id = 0;
$this->currency = 'xdai';
$this->currency_details = ['name' => 'xDAI', 'symbol' => 'xDAI', 'decimals' => 18, 'description' => null];
// EVMMainModule
$this->evm_implementation = EVMImplementation::Erigon; // Change to geth if you're running Nethermind, but this would be slower
$this->extra_features = [EVMSpecialFeatures::EffectiveGasPriceCanBeZero];
$this->reward_function = function($block_id)
{
return '0';
};
// Handles
$this->handles_implemented = true;
$this->handles_regex = '/(.*)\.(gno|owl)/';
$this->api_get_handle = function($handle)
{
if (!preg_match($this->handles_regex, $handle))
return null;
require_once __DIR__ . '/../Engine/Crypto/Keccak.php';
$hash = $this->ens_name_to_hash($handle);
if (is_null($hash) || $hash === '')
return null;
$resolver = $this->ens_get_data($hash, '0x0178b8bf', '0x4f132a7e39b1d717b39c789eb9ec1e790092042b');
$address = $this->ens_get_data_from_resolver($resolver, $hash, '0x3b3b57de', -40);
if ($address)
return '0x' . $address;
else
return null;
};
}
}