Skip to content

Commit 60f19d5

Browse files
authored
feat: contracts endpoint (#123)
1 parent 11dd776 commit 60f19d5

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

src/API/Contracts.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ArkEcosystem\Client\API;
6+
7+
class Contracts extends AbstractAPI
8+
{
9+
/**
10+
* Get all contracts.
11+
*
12+
* @return array
13+
*/
14+
public function all(): ?array
15+
{
16+
return $this->requestGet('contracts');
17+
}
18+
19+
/**
20+
* Get the node syncing status.
21+
*
22+
* @return array
23+
*/
24+
public function abi(string $name, string $implementation): ?array
25+
{
26+
return $this->requestGet(sprintf('contracts/%s/%s/abi', $name, $implementation));
27+
}
28+
}

tests/API/ContractsTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ArkEcosystem\Tests\Client\API;
6+
7+
use ArkEcosystem\Tests\Client\TestCase;
8+
9+
/**
10+
* @covers \ArkEcosystem\Client\API\Contracts
11+
*/
12+
class ContractsTest extends TestCase
13+
{
14+
/** @test */
15+
public function all_calls_correct_url()
16+
{
17+
$this->assertResponse('GET', 'contracts', function ($client) {
18+
return $client->contracts()->all();
19+
});
20+
}
21+
22+
/** @test */
23+
public function abi_calls_correct_url()
24+
{
25+
$this->assertResponse('GET', 'contracts/consensus/some-wallet/abi', function ($client) {
26+
return $client->contracts()->abi('consensus', 'some-wallet');
27+
});
28+
}
29+
}

0 commit comments

Comments
 (0)