Skip to content
Merged
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
50 changes: 50 additions & 0 deletions src/goplus/Api/Locker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* This file is part of GoPlus.
*
* @link https://www.gopluslabs.io
* @license https://github.com/GoPlusSecurity/goplus-sdk-php/blob/main/LICENSE
*/
namespace Goplus\Api;

use Swagger\Client\Api\LockControllerApi;
use Swagger\Client\Api\TokenControllerV1Api;
use Swagger\Client\Api\TokenSecurityAPIForSolanaBetaApi;
use Swagger\Client\Api\TokenSecurityAPIForSuiApi;

class Locker extends Base
{
public function __construct($accessToken = null, $guzzleOptions = [])
{
parent::__construct($accessToken, $guzzleOptions);
$guzzle = $this->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);
}

}
31 changes: 30 additions & 1 deletion src/goplus/Api/Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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);
}
}
36 changes: 36 additions & 0 deletions src/goplus/Api/TxSimulation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* This file is part of GoPlus.
*
* @link https://www.gopluslabs.io
* @license https://github.com/GoPlusSecurity/goplus-sdk-php/blob/main/LICENSE
*/
namespace Goplus\Api;

use Swagger\Client\Api\LockControllerApi;
use Swagger\Client\Api\TokenControllerV1Api;
use Swagger\Client\Api\TokenSecurityAPIForSolanaBetaApi;
use Swagger\Client\Api\TokenSecurityAPIForSuiApi;
use Swagger\Client\Api\TransactionSimulationForSolanaApi;
use Swagger\Client\Model\ParseAbiDataRequest;
use Swagger\Client\Model\SolanaPrerunTxRequest;

class TxSimulation extends Base
{
public function __construct($accessToken = null, $guzzleOptions = [])
{
parent::__construct($accessToken, $guzzleOptions);
$guzzle = $this->getGuzzleClient();
$this->client = new TransactionSimulationForSolanaApi($guzzle);
}

public function solanaTxSimulation($encodedTransaction)
{
$body = new SolanaPrerunTxRequest([
"encoded_transaction" => $encodedTransaction
]);

return $this->client->prerunTxUsingPOST($body, $this->accessToken);
}

}
32 changes: 32 additions & 0 deletions tests/LockerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* This file is part of GoPlus.
*
* @link https://www.gopluslabs.io
* @license https://github.com/GoPlusSecurity/goplus-sdk-php/blob/main/LICENSE
*/

use Goplus\Api\Token;
use Goplus\Api\Locker;
use Goplus\ErrorCode;
use PHPUnit\Framework\TestCase;

/**
* @internal
* @coversNothing
*/
class LockerTest extends TestCase
{
public function testLockerToken()
{
$res = (new Locker())->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());
}

}
15 changes: 15 additions & 0 deletions tests/TokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
25 changes: 25 additions & 0 deletions tests/TxSimulationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* This file is part of GoPlus.
*
* @link https://www.gopluslabs.io
* @license https://github.com/GoPlusSecurity/goplus-sdk-php/blob/main/LICENSE
*/

use Goplus\Api\TxSimulation;
use Goplus\ErrorCode;
use PHPUnit\Framework\TestCase;

/**
* @internal
* @coversNothing
*/
class TxSimulationTest extends TestCase
{
public function testSolanaTxSimulation()
{
$encodedTransaction = "AT+Td4vATQ8bPgyQPt25Hp6Ve2jECOkwS3+PC5Z8HhLK/7mDbnQ8tW3sKzQnNeVWxsJzo8knzMhQZbnL+FpzVgOAAQADGuGEgGi3qMErQECfFXEVxCXlALMU02fKK0Yf27WbmN3in0h2yAJOqRM87lkKfGtIJh/K1ZeTCGy7baAOhr7lAHEGm4hX/quBhPtof2NGGMA12sQ53BrrO1WYoPAAAAAAAUHVl1rR1ll4q3QLbxXmVinsWpdivaeQV/mhOzBJCk8REfu0KcAzb3YRg2Ma9lf/OneTw5veLElNTzFqNrsDkuYLvA+xH7fegRONkq/Pv7glUQsHQHoREAxHUw9pcWEqf8JzpBDzmh14iMUco6VGUnJ5JdUmYvy9vVSA7Oxsk9U/04YFfm4JbWwLmfCCrhw+JkLOorQ/LWaR1K9ts6sVhyf7Py+Jb8E9fs7m+Yp0tE0aoYujFI/3KfPd+ElqLb+wi+bW5R6OHe4FtxpdJLGwx6Vpl5tqHI0b/JFzDt2fRX4DOIT6Ynj6mq18q+cWm0lZkVpKNXSV+WHJK0O+B/b/M7kKPU71EHDfVbbANy9N/TBkLtvrgPawBy0NzW5ehEMJ/ciXSyf8WLm80PBN0XBjIITO5GQy+w8X4b7lC5ENdeNBQtxtFaOMHuCIMKYErfMjPnIdcZyqF/E23LNm67pyWhP4BpxgdtdoBCYrCN+usbbjQi3UwAXrm0zVY6Y/BpSVhMb6evO+2606PWXzaqvJdDGxu+TC0vbg5HymAgNFL11hjqY6esn2GopdBm3ZyMw1bOMZM/i2kbQAXFV+SN+vT8Fyjbr97ysVNCK0N0ppW+uvhHyoakZ54IPbNYs9uSpZxVAe6q5A+cCehtHSM5H1lGMuCl2Xy9kJpwfYFYHGYz5CEdnDZKSvMTjkXNIUKlSiFy/yY6fNErKOUn/kfnyrpIcseSoueZv3kcqOWpwwC/t0MMF1LNOwyHxINLlxBSA55tlrnVisLQ4iM8cK+92bmKEIM7Kye02Vb0y/QKi7zQUdfHu14hsh7jlG5aOhjOg75OXUg1wpZ5pceJoVtb4l9BcMwoDLa+MZLFA4OAHPRDAYD54/hmMiOsgBBpcQ2/fVBwVKU1qZKSEGTSTocWDaOHx8NbXdvJK7geQfqEBBBUSNAwZGb+UhFzL/7K26csOb57yM5bvF9xJrLEObOkAAAAB/EQusFKXzoXRK459NkGDBTgIsPmYN/3ocys69vB4asgUXBgABAhobHAkFoIYBAAAAAAAXIhodGxwAAQMeBAIFBgcICQoYCwwNDh4DBQ8GEBESExgUFRYxAKCGAQAAAAAAjDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABcGAAEAGhscAQYZAAkDmvYAAAAAAAAZAAUCDCsFAAEZjx9MOkUiY9QTss0X68vBoOWIc2TmJhoSqBeS6hZaPgAFAgcAAxA=";
$res = (new TxSimulation())->solanaTxSimulation($encodedTransaction);
$this->assertEquals(ErrorCode::SUCCESS, $res->getCode());
}
}