Skip to content

Commit

Permalink
fixed laravel bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoruchiaki committed Aug 10, 2023
1 parent b03f34d commit 1274968
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/Interfaces/Web3Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,49 @@

interface Web3Interface
{
public function getBlockNumber();

public function getBlockByNumber(int $blockNumber);

public function getBlockByHash(string $blockHash);

public function getBlockTransCnt(int $blockNumber);

public function getPbftView();

public function getTransactionReceipt(string $transHash);

public function getTransaction(string $transHash);

public function getClientVersion();

public function getCode(string $address, int $blockNumber);

public function getTransactionTotal();

public function getTransByBlockHashAndIndex(string $blockHash, int $transactionIndex);

public function getTransByBlockNumberAndIndex(int $blockNumber, int $transactionIndex);

public function getConsensusStatus();

public function getNodeStatusList();

public function getGroupList();

public function getGroupPeers();

public function getObserverList();

public function getPeers();

public function getPendingTransactionsCount();

public function getSealerList();

public function getSearch(string $inputValue = null);

public function getSyncStatus();

public function refresh();
}
7 changes: 7 additions & 0 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Yoruchiaki\WebaseFront\Services\PrivateKey\PrivateKeyService;
use Yoruchiaki\WebaseFront\Services\Tool\ToolService;
use Yoruchiaki\WebaseFront\Services\Trans\TransService;
use Yoruchiaki\WebaseFront\Services\Web3\Web3Service;

class ServiceProvider extends \Illuminate\Support\ServiceProvider implements DeferrableProvider
{
Expand Down Expand Up @@ -37,6 +38,7 @@ public function register()
)
);
});

$this->app->singleton(ContractService::class, function ($app) {
return new ContractService($app->make(HttpRequestInterface::class));
});
Expand All @@ -53,10 +55,15 @@ public function register()
return new PrivateKeyService($app->make(HttpRequestInterface::class));
});

$this->app->singleton(Web3Service::class, function ($app) {
return new Web3Service($app->make(HttpRequestInterface::class));
});

$this->app->alias(ContractService::class, 'Contract');
$this->app->alias(TransService::class, 'Trans');
$this->app->alias(PrivateKeyService::class, 'Pk');
$this->app->alias(ToolService::class, 'Tool');
$this->app->alias(Web3Service::class, 'Web3');
}

public function provides(): array
Expand Down
126 changes: 126 additions & 0 deletions src/Services/Web3/Web3Service.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php

namespace Yoruchiaki\WebaseFront\Services\Web3;

use Yoruchiaki\WebaseFront\Interfaces\Web3Interface;
use Yoruchiaki\WebaseFront\Services\BaseService;

class Web3Service extends BaseService implements Web3Interface
{

public function getBlockNumber(): array
{
return $this->http->request('GET', $this->groupId . '/web3/blockNumber');
}

public function getBlockByNumber(int $blockNumber): array
{
return $this->http->request('GET', $this->groupId . "/web3/blockByNumber/$blockNumber");
}

public function getBlockByHash(string $blockHash): array
{
return $this->http->request('GET', $this->groupId . "/web3/blockByHash/${blockHash}");
}

public function getBlockTransCnt(int $blockNumber): array
{
return $this->http->request('GET', $this->groupId . "/web3/blockTransCnt/${blockNumber}");
}

public function getPbftView(): array
{
return $this->http->request('GET', $this->groupId . "/web3/pbftView");
}

public function getTransactionReceipt(string $transHash): array
{
return $this->http->request('GET', $this->groupId . "/web3/transactionReceipt/${transHash}");
}

public function getTransaction(string $transHash): array
{
return $this->http->request('GET', $this->groupId . "/web3/transaction/${transHash}");
}

public function getClientVersion(): array
{
return $this->http->request('GET', $this->groupId . "/web3/clientVersion");
}

public function getCode(string $address, int $blockNumber): array
{
return $this->http->request('GET', $this->groupId . "/web3/code/${address}/${blockNumber}");
}

public function getTransactionTotal(): array
{
return $this->http->request('GET', $this->groupId . "/web3/transaction-total");
}

public function getTransByBlockHashAndIndex(string $blockHash, int $transactionIndex): array
{
return $this->http->request('GET', $this->groupId . "/web3/transByBlockHashAndIndex/${blockHash}/${transactionIndex}");
}

public function getTransByBlockNumberAndIndex(int $blockNumber, int $transactionIndex): array
{
return $this->http->request('GET', $this->groupId . "/web3/transByBlockNumberAndIndex/{blockNumber}/{transactionIndex}");
}

public function getConsensusStatus(): array
{
return $this->http->request('GET', $this->groupId . "/web3/consensusStatus");
}

public function getNodeStatusList(): array
{
return $this->http->request('GET', $this->groupId . "/web3/getNodeStatusList");

}

public function getGroupList(): array
{
return $this->http->request('GET', $this->groupId . "/web3/groupList");
}

public function getGroupPeers(): array
{
return $this->http->request('GET', $this->groupId . "/web3/groupPeers");
}

public function getObserverList(): array
{
return $this->http->request('GET', $this->groupId . "/web3/observerList");
}

public function getPeers(): array
{
return $this->http->request('GET', $this->groupId . "/web3/peers");
}

public function getPendingTransactionsCount(): array
{
return $this->http->request('GET', $this->groupId . "/web3/pending-transactions-count");
}

public function getSealerList(): array
{
return $this->http->request('GET', $this->groupId . "/web3/sealerList");
}

public function getSearch(string $inputValue = null): array
{
return $this->http->request('GET', $this->groupId . "/web3/search?input=${inputValue}");
}

public function getSyncStatus(): array
{
return $this->http->request('GET', $this->groupId . "/web3/syncStatus");
}

public function refresh(): array
{
return $this->http->request('GET', $this->groupId . "/web3/refresh");
}
}

0 comments on commit 1274968

Please sign in to comment.