diff --git a/src/API/EVM.php b/src/API/EVM.php new file mode 100644 index 0000000..9f972f1 --- /dev/null +++ b/src/API/EVM.php @@ -0,0 +1,31 @@ + '2.0', + 'method' => 'eth_call', + 'params' => [$payload, 'latest'], + 'id' => null, + ]; + + $headers = [ + 'Content-Type' => 'application/json', + ]; + + return $this->withApi('evm')->post('api/', $body, $headers); + } +} diff --git a/src/ArkClient.php b/src/ArkClient.php index 3fac7c0..295e542 100644 --- a/src/ArkClient.php +++ b/src/ArkClient.php @@ -128,7 +128,8 @@ public function getHosts(): array */ public function api(string $name): API\AbstractAPI { - $name = ucfirst($name); + $name = $name === 'evm' ? 'EVM' : ucfirst($name); + $class = "ArkEcosystem\\Client\\API\\{$name}"; if (! class_exists($class)) { diff --git a/tests/API/EVMTest.php b/tests/API/EVMTest.php new file mode 100644 index 0000000..44b3dd5 --- /dev/null +++ b/tests/API/EVMTest.php @@ -0,0 +1,30 @@ +assertResponse( + method: 'POST', + path: 'api/', + callback: function ($client) { + return $client->evm()->ethCall([ + 'from' => '0x1234567890abcdef', + 'to' => '0xfedcba0987654321', + 'data' => '0xabcdef', + ]); + }, + expectedApi: 'evm' + ); + } +}