From ddd8666cd7835a27564fcbbf292da7935674763d Mon Sep 17 00:00:00 2001 From: cong <1461561010@qq.com> Date: Mon, 9 Jun 2025 10:22:10 +0800 Subject: [PATCH] feat: support new detection API --- src/goplus/Api/Locker.php | 50 +++++++++++++++++++++++++++++++++ src/goplus/Api/Token.php | 31 +++++++++++++++++++- src/goplus/Api/TxSimulation.php | 36 ++++++++++++++++++++++++ tests/LockerTest.php | 32 +++++++++++++++++++++ tests/TokenTest.php | 15 ++++++++++ tests/TxSimulationTest.php | 25 +++++++++++++++++ 6 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 src/goplus/Api/Locker.php create mode 100644 src/goplus/Api/TxSimulation.php create mode 100644 tests/LockerTest.php create mode 100644 tests/TxSimulationTest.php diff --git a/src/goplus/Api/Locker.php b/src/goplus/Api/Locker.php new file mode 100644 index 0000000..80ad403 --- /dev/null +++ b/src/goplus/Api/Locker.php @@ -0,0 +1,50 @@ +getGuzzleClient(); + $this->client = new LockControllerApi($guzzle); + } + + /** + * @param $chainId + * @param $pageNum + * @param $pageSize + * @param $tokenAddress + * @return \Swagger\Client\Model\ResponseWrapperTokenLockerResponse + * @throws \Swagger\Client\ApiException + */ + public function lockerToken($chainId, $pageNum, $pageSize, $tokenAddress) + { + return $this->client->getTokenLockersUsingGET($chainId, $pageNum, $pageSize, $tokenAddress, $this->accessToken); + } + + /** + * @param $chainId + * @param $pageNum + * @param $pageSize + * @param $poolAddress + * @return \Swagger\Client\Model\ResponseWrapperNftLockerResponse + * @throws \Swagger\Client\ApiException + */ + public function lockerLPV3($chainId, $pageNum, $pageSize, $poolAddress) + { + return $this->client->getNftLockersUsingGET($chainId, $pageNum, $pageSize, $poolAddress, $this->accessToken); + } + +} diff --git a/src/goplus/Api/Token.php b/src/goplus/Api/Token.php index cfec0db..4693d38 100644 --- a/src/goplus/Api/Token.php +++ b/src/goplus/Api/Token.php @@ -8,13 +8,22 @@ namespace Goplus\Api; use Swagger\Client\Api\TokenControllerV1Api; +use Swagger\Client\Api\TokenSecurityAPIForSolanaBetaApi; +use Swagger\Client\Api\TokenSecurityAPIForSuiApi; class Token extends Base { + protected $solanaClient; + + protected $suiClient; + public function __construct($accessToken = null, $guzzleOptions = []) { parent::__construct($accessToken, $guzzleOptions); - $this->client = new TokenControllerV1Api($this->getGuzzleClient()); + $guzzle = $this->getGuzzleClient(); + $this->client = new TokenControllerV1Api($guzzle); + $this->solanaClient = new TokenSecurityAPIForSolanaBetaApi($guzzle); + $this->suiClient = new TokenSecurityAPIForSuiApi($guzzle); } /** @@ -26,4 +35,24 @@ public function tokenSecurity($chainId, $address) { return $this->client->tokenSecurityUsingGET1($chainId, $address, $this->accessToken); } + + /** + * @param $address + * @return \Swagger\Client\Model\ResponseWrapperSolanaTokenSecurity + * @throws \Swagger\Client\ApiException + */ + public function solanaTokenSecurity($address) + { + return $this->solanaClient->solanaTokenSecurityUsingGET($address, $this->accessToken); + } + + /** + * @param $address + * @return \Swagger\Client\Model\ResponseWrapperSuiTokenSecurity + * @throws \Swagger\Client\ApiException + */ + public function suiTokenSecurity($address) + { + return $this->suiClient->suiTokenSecurityUsingGET($address, $this->accessToken); + } } diff --git a/src/goplus/Api/TxSimulation.php b/src/goplus/Api/TxSimulation.php new file mode 100644 index 0000000..ae139bb --- /dev/null +++ b/src/goplus/Api/TxSimulation.php @@ -0,0 +1,36 @@ +getGuzzleClient(); + $this->client = new TransactionSimulationForSolanaApi($guzzle); + } + + public function solanaTxSimulation($encodedTransaction) + { + $body = new SolanaPrerunTxRequest([ + "encoded_transaction" => $encodedTransaction + ]); + + return $this->client->prerunTxUsingPOST($body, $this->accessToken); + } + +} diff --git a/tests/LockerTest.php b/tests/LockerTest.php new file mode 100644 index 0000000..7e8f805 --- /dev/null +++ b/tests/LockerTest.php @@ -0,0 +1,32 @@ +lockerToken("8453",1,100,"0x6fd0303649296360f10c07b24521deda9223086d"); + $this->assertEquals(ErrorCode::SUCCESS, $res->getCode()); + } + + public function testLockerLPV3() + { + $res = (new Locker())->lockerLPV3("56",1,100,"0x579df956c6cE6178fBBD78bbE4f05786cFBA9B76"); + $this->assertEquals(ErrorCode::SUCCESS, $res->getCode()); + } + +} diff --git a/tests/TokenTest.php b/tests/TokenTest.php index f36b793..5156596 100644 --- a/tests/TokenTest.php +++ b/tests/TokenTest.php @@ -29,4 +29,19 @@ public function testTokenSecurityByInvalidChainId() $res = (new Token())->tokenSecurity('0111110', '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'); $this->assertNotEquals(ErrorCode::SUCCESS, $res->getCode()); } + + public function testSolanaTokenSecurity() + { + $res = (new Token())->solanaTokenSecurity(['HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3']); + $this->assertEquals(ErrorCode::SUCCESS, $res->getCode()); + $this->assertArrayHasKey('HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3', $res->getResult()); + } + + + public function testSuiTokenSecurity() + { + $res = (new Token())->suiTokenSecurity(["0x40402a987c2f8a71b755561bfbd16c2cbb991e27e609ad148809491c32bacab9::kui::KUI"]); + $this->assertEquals(ErrorCode::SUCCESS, $res->getCode()); + $this->assertArrayHasKey('0x40402a987c2f8a71b755561bfbd16c2cbb991e27e609ad148809491c32bacab9::kui::KUI', $res->getResult()); + } } diff --git a/tests/TxSimulationTest.php b/tests/TxSimulationTest.php new file mode 100644 index 0000000..8aec1fd --- /dev/null +++ b/tests/TxSimulationTest.php @@ -0,0 +1,25 @@ +solanaTxSimulation($encodedTransaction); + $this->assertEquals(ErrorCode::SUCCESS, $res->getCode()); + } +}