Skip to content

refactor: update eth call payload handling #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: feat/mainsail
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/API/EVM.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ class EVM extends AbstractAPI
*
* @return array|null
*/
public function ethCall(array $payload): ?array
public function call(array $payload): ?array
{
$body = [
'jsonrpc' => '2.0',
'method' => 'eth_call',
'params' => [$payload, 'latest'],
'id' => null,
...$payload,
];

$headers = [
'Content-Type' => 'application/json',
];

return $this->withApi('evm')->requestPost('api/', $body, $headers);
return $this->withApi('evm')
->requestPost('api/', $body, $headers);
}
}
14 changes: 9 additions & 5 deletions tests/API/EVMTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
class EVMTest extends TestCase
{
/** @test */
public function eth_call_calls_correct_url()
public function evm_call_calls_correct_url()
{
$this->assertResponse(
method: 'POST',
path: 'api/',
callback: function (ArkClient $client) {
return $client->evm()->ethCall([
'from' => '0x1234567890abcdef',
'to' => '0xfedcba0987654321',
'data' => '0xabcdef',
return $client->evm()->call([
'method' => 'eth_call',
'params' => [[
'from' => '0x1234567890abcdef',
'to' => '0xfedcba0987654321',
'data' => '0xabcdef',
], 'latest'],
'id' => null,
]);
},
expectedApi: 'evm'
Expand Down