From 71579edead37202d6de670f151b66444ef12cb17 Mon Sep 17 00:00:00 2001 From: mx dec0de Date: Tue, 9 Feb 2021 21:19:42 +0300 Subject: [PATCH 01/10] upgrade to taconet --- README.md | 283 +++++++++++++++- composer.json | 2 +- src/Minter/MinterAPI.php | 76 ++++- .../SDK/MinterCoins/MinterAddLiquidityTx.php | 60 ++++ .../SDK/MinterCoins/MinterBurnTokenTx.php | 49 +++ .../SDK/MinterCoins/MinterBuyCoinTx.php | 3 +- .../SDK/MinterCoins/MinterBuySwapPoolTx.php | 55 ++++ src/Minter/SDK/MinterCoins/MinterCoinTx.php | 63 ++-- .../SDK/MinterCoins/MinterCreateCoinTx.php | 3 +- .../MinterCoins/MinterCreateMultisigTx.php | 3 +- .../MinterCoins/MinterCreateSwapPoolTx.php | 60 ++++ .../SDK/MinterCoins/MinterCreateTokenTx.php | 69 ++++ .../MinterCoins/MinterDeclareCandidacyTx.php | 3 +- .../SDK/MinterCoins/MinterDelegateTx.php | 3 +- .../MinterEditCandidateCommissionTx.php | 50 +++ .../MinterEditCandidatePublicKeyTx.php | 3 +- .../SDK/MinterCoins/MinterEditCandidateTx.php | 3 +- .../SDK/MinterCoins/MinterEditCoinOwnerTx.php | 3 +- .../SDK/MinterCoins/MinterEditMultisigTx.php | 3 +- .../SDK/MinterCoins/MinterMintTokenTx.php | 49 +++ .../SDK/MinterCoins/MinterMoveStakeTx.php | 60 ++++ .../SDK/MinterCoins/MinterMultiSendTx.php | 8 +- .../MinterCoins/MinterPriceCommissionTx.php | 307 ++++++++++++++++++ .../SDK/MinterCoins/MinterPriceVoteTx.php | 3 +- .../SDK/MinterCoins/MinterRecreateCoinTx.php | 3 +- .../SDK/MinterCoins/MinterRecreateTokenTx.php | 69 ++++ .../SDK/MinterCoins/MinterRedeemCheckTx.php | 3 +- .../MinterCoins/MinterRemoveLiquidityTx.php | 65 ++++ .../SDK/MinterCoins/MinterSellAllCoinTx.php | 3 +- .../MinterCoins/MinterSellAllSwapPoolTx.php | 55 ++++ .../SDK/MinterCoins/MinterSellCoinTx.php | 3 +- .../SDK/MinterCoins/MinterSellSwapPoolTx.php | 60 ++++ .../SDK/MinterCoins/MinterSendCoinTx.php | 3 +- .../MinterCoins/MinterSetCandidateOffTx.php | 3 +- .../MinterCoins/MinterSetCandidateOnTx.php | 3 +- .../SDK/MinterCoins/MinterSetHaltBlockTx.php | 3 +- src/Minter/SDK/MinterCoins/MinterUnbondTx.php | 3 +- tests/MinterAddLiquidityTxTest.php | 64 ++++ tests/MinterBurnTokenTxTest.php | 62 ++++ tests/MinterBuySwapPoolTxTest.php | 61 ++++ tests/MinterCreateSwapPoolTxTest.php | 65 ++++ tests/MinterCreateTokenTxTest.php | 63 ++++ tests/MinterEditCandidateCommissionTxTest.php | 63 ++++ tests/MinterMintTokenTxTest.php | 62 ++++ tests/MinterMoveStakeTxTest.php | 64 ++++ tests/MinterPriceCommissionTxTest.php | 104 ++++++ tests/MinterRecreateTokenTxTest.php | 63 ++++ tests/MinterRemoveLiquidityTxTest.php | 66 ++++ tests/MinterSellAllSwapPoolTxTest.php | 60 ++++ tests/MinterSellSwapPoolTxTest.php | 61 ++++ 50 files changed, 2263 insertions(+), 92 deletions(-) create mode 100644 src/Minter/SDK/MinterCoins/MinterAddLiquidityTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterBurnTokenTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterBuySwapPoolTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterCreateSwapPoolTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterCreateTokenTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterEditCandidateCommissionTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterMintTokenTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterMoveStakeTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterPriceCommissionTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterRecreateTokenTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterRemoveLiquidityTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterSellAllSwapPoolTx.php create mode 100644 src/Minter/SDK/MinterCoins/MinterSellSwapPoolTx.php create mode 100644 tests/MinterAddLiquidityTxTest.php create mode 100644 tests/MinterBurnTokenTxTest.php create mode 100644 tests/MinterBuySwapPoolTxTest.php create mode 100644 tests/MinterCreateSwapPoolTxTest.php create mode 100644 tests/MinterCreateTokenTxTest.php create mode 100644 tests/MinterEditCandidateCommissionTxTest.php create mode 100644 tests/MinterMintTokenTxTest.php create mode 100644 tests/MinterMoveStakeTxTest.php create mode 100644 tests/MinterPriceCommissionTxTest.php create mode 100644 tests/MinterRecreateTokenTxTest.php create mode 100644 tests/MinterRemoveLiquidityTxTest.php create mode 100644 tests/MinterSellAllSwapPoolTxTest.php create mode 100644 tests/MinterSellSwapPoolTxTest.php diff --git a/README.md b/README.md index 6619dfd..e44d7b0 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,10 @@ This is a pure PHP SDK for working with Minter blockchain - [getMinGasPrice](#getmingasprice) - [getMissedBlocks](#getmissedblocks) - [getWaitlist](#getwaitlist) + - [getPriceCommissions](#getPriceCommissions) + - [getPriceVotes](#getPriceCommissions) + - [getSwapPool](#getSwapPool) + - [getSwapPoolProvider](#getSwapPoolProvider) - [Error handling](#error-handling) * [Minter SDK](#using-mintersdk) @@ -53,6 +57,19 @@ This is a pure PHP SDK for working with Minter blockchain - [EditMultisig](#example-20) - [PriceVote](#example-21) - [EditCandidatePublicKey](#example-22) + - [AddLiquidity](#example-23) + - [RemoveLiquidity](#example-24) + - [SellSwapPool](#example-25) + - [BuySwapPool](#example-26) + - [SellAllSwapPool](#example-27) + - [EditCandidateCommission](#example-28) + - [MoveStake](#example-29) + - [MintToken](#example-30) + - [BurnToken](#example-31) + - [CreateToken](#example-32) + - [RecreateToken](#example-33) + - [PriceCommission](#example-34) + - [CreateSwapPool](#example-35) - [Sign transaction with multisignatures](#sign-transaction-with-multisignatures) - [Get fee of transaction](#get-fee-of-transaction) - [Decode Transaction](#decode-transaction) @@ -229,7 +246,7 @@ getCandidates(?int $height = null, ?bool $includeStakes = false): \stdClass ### estimateTxCommission -Return estimate of transaction. +Returns estimate of transaction. `` estimateTxCommission(string $tx, ?int $height = null): \stdClass @@ -237,7 +254,7 @@ estimateTxCommission(string $tx, ?int $height = null): \stdClass ### getTransactions -Return transactions by query. +Returns transactions by query. `` getTransactions(string $query, ?int $page = null, ?int $perPage = null): \stdClass @@ -277,7 +294,7 @@ getMissedBlocks(string $pubKey, ?int $height = null): \stdClass ### getGenesis -Return network genesis. +Returns network genesis. `` getGenesis(): \stdClass @@ -285,7 +302,7 @@ getGenesis(): \stdClass ### getNetworkInfo -Return node network information. +Returns node network information. `` getNetworkInfo(): \stdClass @@ -293,12 +310,54 @@ getNetworkInfo(): \stdClass ### getWaitlist -Return waitlisted stakes by address +Returns waitlisted stakes by address `` getWaitlist(string $address, ?string $publicKey = null, ?int $height = null): \stdClass `` +### getWaitlist + +Returns waitlisted stakes by address + +`` +getWaitlist(string $address, ?string $publicKey = null, ?int $height = null): \stdClass +`` + +### getPriceCommissions + +Returns the list of the commissions that are set up on the Minter Network + +`` +getPriceCommissions(?int $height = null): \stdClass +`` + +### getPriceVotes + +Returns the list of validators' votes for changing commissions on the network + +`` +getPriceVotes(int $height): \stdClass +`` + +### getSwapPool + +Returns entire liquidity volume of the swap pool + +`` +getSwapPool(string $coin0, string $coin1, ?int $height = null): \stdClass +`` + +### getSwapPoolProvider + +Returns liquidity volume of the swap pool provided by specified address + +`` +getSwapPoolProvider(string $coin0, string $coin1, string $provider, ?int $height = null): \stdClass +`` + + + ### Error handling Example of how you can handle errors and get the response body. @@ -639,6 +698,220 @@ $tx = new MinterTx($nonce, $data); $tx->sign('your private key') ``` +###### Example +* Sign the AddLiquidity transaction +* Constructor: ```MinterAddLiquidityTx($coin0, $coin1, $volume0, $maximumVolume1)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterAddLiquidityTx; + +$data = new MinterAddLiquidityTx(0, 1, '1000', '2000'); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the RemoveLiquidity transaction +* Constructor: ```MinterRemoveLiquidityTx($coin0, $coin1, $liquidity, $minimumVolume0, $minimumVolume1)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterRemoveLiquidityTx; + +$data = new MinterRemoveLiquidityTx(0, 1, '2000', '500', '1000'); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the SellSwapPool transaction +* Constructor: ```MinterSellSwapPoolTx($coinToSell, $valueToSell, $coinToBuy, $minimumValueToBuy)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterSellSwapPoolTx; + +$data = new MinterSellSwapPoolTx(0, '100', 1, '200'); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the BuySwapPool transaction +* Constructor: ```MinterBuySwapPoolTx($coinToBuy, $valueToBuy, $coinToSell, $maximumValueToSell)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterBuySwapPoolTx; + +$data = new MinterBuySwapPoolTx(0, '100', 1, '200'); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the SellAllSwapPool transaction +* Constructor: ```MinterSellAllSwapPoolTx($coinToSell, $coinToBuy, $minimumValueToBuy)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterSellAllSwapPoolTx; + +$data = new MinterSellAllSwapPoolTx(0, 1, '100'); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the EditCandidateCommission transaction +* Constructor: ```MinterEditCandidateCommissionTx($publicKey, $commission)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterEditCandidateCommissionTx; + +$data = new MinterEditCandidateCommissionTx('public key', 77); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the MoveStake transaction +* Constructor: ```MinterMoveStakeTx($from, $to, $coin, $stake)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterEditCandidateCommissionTx; + +$data = new MinterEditCandidateCommissionTx('from public key', 'to public key', 1, '3000'); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the MintToken transaction +* Constructor: ```MinterMintTokenTx($coin, $value)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterMintTokenTx; + +$data = new MinterMintTokenTx(2, '3000'); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the BurnToken transaction +* Constructor: ```MinterBurnTokenTx($coin, $value)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterBurnTokenTx; + +$data = new MinterBurnTokenTx(3, '100000'); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the CreateToken transaction +* Constructor: ```MinterCreateTokenTx($name, $symbol, $initialAmount, $maxSupply, $mintable, $burnable)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterCreateTokenTx; + +$data = new MinterCreateTokenTx('TEST COIN IS MINTABLE ONLY', 'TEST', '10000', '50000', true, false); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the RecreateToken transaction +* Constructor: ```MinterRecreateTokenTx($name, $symbol, $initialAmount, $maxSupply, $mintable, $burnable)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterRecreateTokenTx; + +$data = new MinterRecreateTokenTx('TEST COIN IS TURNED TO BE BURNABLE ONLY', 'TEST', '50000', '50000', false, true); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the PriceCommission transaction +* Constructor: ```MinterPriceCommissionTx( + $pubKey, + $height, + $coin, + $payloadByte, + $send, + $buyBancor, + $sellBancor, + $sellAllBancor, + $buyPool, + $sellPool, + $sellAllPool, + $createTicker3, + $createTicker4, + $createTicker5, + $createTicker6, + $createTicker7to10, + $createCoin, + $createToken, + $recreateCoin, + $recreateToken, + $declareCandidacy, + $delegate, + $unbond, + $redeemCheck, + $setCandidateOn, + $setCandidateOff, + $createMultisig, + $multisendBase, + $multisendDelta, + $editCandidate, + $setHaltBlock, + $editTickerOwner, + $editMultisig, + $priceVote, + $editCandidatePublicKey, + $createSwapPool, + $addLiquidity, + $removeLiquidity, + $editCandidateCommission, + $moveStake, + $burnToken, + $mintToken, + $voteCommission, + $voteUpdate + )``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterPriceCommissionTx; + +$data = new MinterPriceCommissionTx('public key', 100000,0,'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41'); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + +###### Example +* Sign the CreateSwapPoll transaction +* Constructor: ```MinterCreateSwapPoolTx($coin0, $coin1, $volume0, $volume1)``` + +```php +use Minter\SDK\MinterTx; +use Minter\SDK\MinterCoins\MinterCreateSwapPoolTx; + +$data = new MinterCreateSwapPoolTx(1, 2, '11000', '22000'); +$tx = new MinterTx($nonce, $data); +$tx->sign('your private key') +``` + ### Sign transaction with multisignatures Returns a signed tx. diff --git a/composer.json b/composer.json index f01b5a4..741587b 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "minter/minter-php-sdk", + "name": "mx-dec0de/minter-php-sdk", "autoload": { "psr-0" : { "Minter\\" : "src" diff --git a/src/Minter/MinterAPI.php b/src/Minter/MinterAPI.php index 5734fb5..f494304 100644 --- a/src/Minter/MinterAPI.php +++ b/src/Minter/MinterAPI.php @@ -185,16 +185,17 @@ public function getTransaction(string $hash): \stdClass } /** - * Returns block data at given height. - * * @param int $height + * @param bool|null $failedTxs * @return \stdClass - * @throws Exception * @throws GuzzleException */ - public function getBlock(int $height): \stdClass + public function getBlock(int $height, ?bool $failedTxs = false): \stdClass { - return $this->get('block/' . $height); + if ($failedTxs) { + $params['failed_txs'] = 'true'; + } + return $this->get('block/' . $height, $params); } /** @@ -268,12 +269,14 @@ public function estimateCoinSell( string $coinToSell, string $valueToSell, string $coinToBuy, - ?int $height = null + ?int $height = null, + string $swapFrom = 'optimal' ): \stdClass { $params = [ 'coin_to_sell' => $coinToSell, 'value_to_sell' => $valueToSell, - 'coin_to_buy' => $coinToBuy + 'coin_to_buy' => $coinToBuy, + 'swap_from' => $swapFrom ]; if ($height) { @@ -297,12 +300,14 @@ public function estimateCoinSellAll( string $coinToSell, string $valueToSell, string $coinToBuy, - ?int $height = null + ?int $height = null, + string $swapFrom = 'optimal' ): \stdClass { $params = [ 'coin_to_sell' => $coinToSell, 'value_to_sell' => $valueToSell, - 'coin_to_buy' => $coinToBuy + 'coin_to_buy' => $coinToBuy, + 'swap_from' => $swapFrom ]; if ($height) { @@ -327,12 +332,15 @@ public function estimateCoinBuy( string $coinToSell, string $valueToBuy, string $coinToBuy, - ?int $height = null + ?int $height = null, + string $swapFrom = 'optimal' ): \stdClass { $params = [ 'coin_to_sell' => $coinToSell, 'value_to_buy' => $valueToBuy, - 'coin_to_buy' => $coinToBuy + 'coin_to_buy' => $coinToBuy, + 'swap_from' => $swapFrom + ]; if ($height) { @@ -517,4 +525,50 @@ public function getWaitlist(string $address, ?string $publicKey = null, ?int $he return $this->get('waitlist/' . $address, $params); } + + /** + * @param int|null $height + * @return \stdClass + * @throws GuzzleException + */ + public function getPriceCommissions(?int $height = null): \stdClass + { + return $this->get('price_commissions', ($height ? ['height' => $height] : null)); + } + + /** + * @param int $height + * @return \stdClass + * @throws GuzzleException + */ + public function getPriceVotes(int $height): \stdClass + { + return $this->get('price_votes/' . $height); + } + + /** + * @param string $coin0 + * @param string $coin1 + * @param int|null $height + * @return \stdClass + * @throws GuzzleException + */ + public function getSwapPool(string $coin0, string $coin1, ?int $height = null): \stdClass + { + return $this->get('swap_pool/' . $coin0 . '/' . $coin1, ($height ? ['height' => $height] : null)); + } + + /** + * @param string $coin0 + * @param string $coin1 + * @param string $provider + * @param int|null $height + * @return \stdClass + * @throws GuzzleException + */ + public function getSwapPoolProvider(string $coin0, string $coin1, string $provider, ?int $height = null): \stdClass + { + return $this->get('swap_pool/' . $coin0 . '/' . $coin1 . '/' . $provider, ($height ? ['height' => $height] : null)); + } + } diff --git a/src/Minter/SDK/MinterCoins/MinterAddLiquidityTx.php b/src/Minter/SDK/MinterCoins/MinterAddLiquidityTx.php new file mode 100644 index 0000000..d55dfe1 --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterAddLiquidityTx.php @@ -0,0 +1,60 @@ +coin0 = $coin0; + $this->coin1 = $coin1; + $this->volume0 = $volume0; + $this->maximumVolume1 = $maximumVolume1; + } + + /** + * Prepare data for signing + * + * @return array + */ + function encodeData(): array + { + return [ + $this->coin0, + $this->coin1, + MinterConverter::convertToPip($this->volume0), + MinterConverter::convertToPip($this->maximumVolume1) + ]; + } + + function decodeData() + { + $this->coin0 = hexdec($this->coin0); + $this->coin1 = hexdec($this->coin1); + $this->volume0 = MinterConverter::convertToBase(Helper::hexDecode($this->volume0)); + $this->maximumVolume1 = MinterConverter::convertToBase(Helper::hexDecode($this->maximumVolume1)); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterBurnTokenTx.php b/src/Minter/SDK/MinterCoins/MinterBurnTokenTx.php new file mode 100644 index 0000000..8c5807f --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterBurnTokenTx.php @@ -0,0 +1,49 @@ +coin = $coin; + $this->value = $value; + } + + /** + * Prepare data for signing + * + * @return array + */ + public function encodeData(): array + { + return [ + $this->coin, + MinterConverter::convertToPip($this->value) + ]; + } + + public function decodeData() + { + $this->coin = hexdec($this->coin); + $this->value = MinterConverter::convertToBase(Helper::hexDecode($this->value)); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterBuyCoinTx.php b/src/Minter/SDK/MinterCoins/MinterBuyCoinTx.php index 97b878a..8f5f06e 100644 --- a/src/Minter/SDK/MinterCoins/MinterBuyCoinTx.php +++ b/src/Minter/SDK/MinterCoins/MinterBuyCoinTx.php @@ -17,8 +17,7 @@ class MinterBuyCoinTx extends MinterCoinTx implements MinterTxInterface public $valueToBuy; public $maximumValueToSell; - const TYPE = 4; - const COMMISSION = 100; + const TYPE = 4; /** * MinterBuyCoinTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterBuySwapPoolTx.php b/src/Minter/SDK/MinterCoins/MinterBuySwapPoolTx.php new file mode 100644 index 0000000..eed0c6e --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterBuySwapPoolTx.php @@ -0,0 +1,55 @@ +coinToBuy = $coinToBuy; + $this->coinToSell = $coinToSell; + $this->valueToBuy = $valueToBuy; + $this->maximumValueToSell = $maximumValueToSell; + } + + public function encodeData(): array + { + return [ + $this->coinToBuy, + MinterConverter::convertToPip($this->valueToBuy), + $this->coinToSell, + MinterConverter::convertToPip($this->maximumValueToSell) + ]; + } + + public function decodeData() + { + $this->coinToBuy = hexdec($this->coinToBuy); + $this->valueToBuy = MinterConverter::convertToBase(Helper::hexDecode($this->valueToBuy)); + $this->coinToSell = hexdec($this->coinToSell); + $this->maximumValueToSell = MinterConverter::convertToBase(Helper::hexDecode($this->maximumValueToSell)); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterCoinTx.php b/src/Minter/SDK/MinterCoins/MinterCoinTx.php index 9913f8e..e9ee258 100644 --- a/src/Minter/SDK/MinterCoins/MinterCoinTx.php +++ b/src/Minter/SDK/MinterCoins/MinterCoinTx.php @@ -13,38 +13,41 @@ abstract class MinterCoinTx implements MinterTxInterface { public const TYPE_TO_DATA = [ - MinterSendCoinTx::TYPE => MinterSendCoinTx::class, - MinterSellCoinTx::TYPE => MinterSellCoinTx::class, - MinterSellAllCoinTx::TYPE => MinterSellAllCoinTx::class, - MinterBuyCoinTx::TYPE => MinterBuyCoinTx::class, - MinterCreateCoinTx::TYPE => MinterCreateCoinTx::class, - MinterDeclareCandidacyTx::TYPE => MinterDeclareCandidacyTx::class, - MinterDelegateTx::TYPE => MinterDelegateTx::class, - MinterUnbondTx::TYPE => MinterUnbondTx::class, - MinterRedeemCheckTx::TYPE => MinterRedeemCheckTx::class, - MinterSetCandidateOnTx::TYPE => MinterSetCandidateOnTx::class, - MinterSetCandidateOffTx::TYPE => MinterSetCandidateOffTx::class, - MinterCreateMultisigTx::TYPE => MinterCreateMultisigTx::class, - MinterMultiSendTx::TYPE => MinterMultiSendTx::class, - MinterEditCandidateTx::TYPE => MinterEditCandidateTx::class, - MinterRecreateCoinTx::TYPE => MinterRecreateCoinTx::class, - MinterEditCoinOwnerTx::TYPE => MinterEditCoinOwnerTx::class, - MinterSetHaltBlockTx::TYPE => MinterSetHaltBlockTx::class, - MinterEditMultisigTx::TYPE => MinterEditMultisigTx::class, - MinterPriceVoteTx::TYPE => MinterPriceVoteTx::class, - MinterEditCandidatePublicKeyTx::TYPE => MinterEditCandidatePublicKeyTx::class + MinterSendCoinTx::TYPE => MinterSendCoinTx::class, + MinterSellCoinTx::TYPE => MinterSellCoinTx::class, + MinterSellAllCoinTx::TYPE => MinterSellAllCoinTx::class, + MinterBuyCoinTx::TYPE => MinterBuyCoinTx::class, + MinterCreateCoinTx::TYPE => MinterCreateCoinTx::class, + MinterDeclareCandidacyTx::TYPE => MinterDeclareCandidacyTx::class, + MinterDelegateTx::TYPE => MinterDelegateTx::class, + MinterUnbondTx::TYPE => MinterUnbondTx::class, + MinterRedeemCheckTx::TYPE => MinterRedeemCheckTx::class, + MinterSetCandidateOnTx::TYPE => MinterSetCandidateOnTx::class, + MinterSetCandidateOffTx::TYPE => MinterSetCandidateOffTx::class, + MinterCreateMultisigTx::TYPE => MinterCreateMultisigTx::class, + MinterMultiSendTx::TYPE => MinterMultiSendTx::class, + MinterEditCandidateTx::TYPE => MinterEditCandidateTx::class, + MinterRecreateCoinTx::TYPE => MinterRecreateCoinTx::class, + MinterEditCoinOwnerTx::TYPE => MinterEditCoinOwnerTx::class, + MinterSetHaltBlockTx::TYPE => MinterSetHaltBlockTx::class, + MinterEditMultisigTx::TYPE => MinterEditMultisigTx::class, + MinterPriceVoteTx::TYPE => MinterPriceVoteTx::class, + MinterEditCandidatePublicKeyTx::TYPE => MinterEditCandidatePublicKeyTx::class, + MinterAddLiquidityTx::TYPE => MinterAddLiquidityTx::class, + MinterRemoveLiquidityTx::TYPE => MinterRemoveLiquidityTx::class, + MinterSellSwapPoolTx::TYPE => MinterSellSwapPoolTx::class, + MinterBuySwapPoolTx::TYPE => MinterBuySwapPoolTx::class, + MinterSellAllSwapPoolTx::TYPE => MinterSellAllSwapPoolTx::class, + MinterEditCandidateCommissionTx::TYPE => MinterEditCandidateCommissionTx::class, + MinterMoveStakeTx::TYPE => MinterMoveStakeTx::class, + MinterMintTokenTx::TYPE => MinterMintTokenTx::class, + MinterBurnTokenTx::TYPE => MinterBurnTokenTx::class, + MinterCreateTokenTx::TYPE => MinterCreateTokenTx::class, + MinterRecreateTokenTx::TYPE => MinterRecreateTokenTx::class, + MinterPriceCommissionTx::TYPE => MinterPriceCommissionTx::class, + MinterCreateSwapPoolTx::TYPE => MinterCreateSwapPoolTx::class ]; - /** - * Get transaction data fee - * - * @return int - */ - public function getFee() - { - return static::COMMISSION; - } - /** * @return int */ diff --git a/src/Minter/SDK/MinterCoins/MinterCreateCoinTx.php b/src/Minter/SDK/MinterCoins/MinterCreateCoinTx.php index add8084..5e7bd09 100644 --- a/src/Minter/SDK/MinterCoins/MinterCreateCoinTx.php +++ b/src/Minter/SDK/MinterCoins/MinterCreateCoinTx.php @@ -19,8 +19,7 @@ class MinterCreateCoinTx extends MinterCoinTx implements MinterTxInterface public $crr; public $maxSupply; - const TYPE = 5; - const COMMISSION = 1000; + const TYPE = 5; /** * MinterCreateCoinTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterCreateMultisigTx.php b/src/Minter/SDK/MinterCoins/MinterCreateMultisigTx.php index 9760de3..dac4b29 100644 --- a/src/Minter/SDK/MinterCoins/MinterCreateMultisigTx.php +++ b/src/Minter/SDK/MinterCoins/MinterCreateMultisigTx.php @@ -15,8 +15,7 @@ class MinterCreateMultisigTx extends MinterCoinTx implements MinterTxInterface public $weights; public $addresses; - const TYPE = 12; - const COMMISSION = 100; + const TYPE = 12; /** * MinterCreateMultisigTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterCreateSwapPoolTx.php b/src/Minter/SDK/MinterCoins/MinterCreateSwapPoolTx.php new file mode 100644 index 0000000..dfc0bb0 --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterCreateSwapPoolTx.php @@ -0,0 +1,60 @@ +coin0 = $coin0; + $this->coin1 = $coin1; + $this->volume0 = $volume0; + $this->volume1 = $volume1; + } + + /** + * Prepare data for signing + * + * @return array + */ + function encodeData(): array + { + return [ + $this->coin0, + $this->coin1, + MinterConverter::convertToPip($this->volume0), + MinterConverter::convertToPip($this->volume1) + ]; + } + + function decodeData() + { + $this->coin0 = hexdec($this->coin0); + $this->coin1 = hexdec($this->coin1); + $this->volume0 = MinterConverter::convertToBase(Helper::hexDecode($this->volume0)); + $this->volume1 = MinterConverter::convertToBase(Helper::hexDecode($this->volume1)); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterCreateTokenTx.php b/src/Minter/SDK/MinterCoins/MinterCreateTokenTx.php new file mode 100644 index 0000000..1534c2f --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterCreateTokenTx.php @@ -0,0 +1,69 @@ +name = $name; + $this->symbol = $symbol; + $this->initialAmount = $initialAmount; + $this->maxSupply = $maxSupply; + $this->mintable = $mintable; + $this->burnable = $burnable; + } + + /** + * Prepare tx data for signing + * + * @return array + */ + public function encodeData(): array + { + return [ + $this->name, + MinterConverter::convertCoinName($this->symbol), + MinterConverter::convertToPip($this->initialAmount), + MinterConverter::convertToPip($this->maxSupply), + (int) $this->mintable, + (int) $this->burnable + ]; + } + + public function decodeData() + { + $this->name = Helper::hex2str($this->name); + $this->symbol = Helper::hex2str($this->symbol); + $this->initialAmount = MinterConverter::convertToBase(Helper::hexDecode($this->initialAmount)); + $this->maxSupply = MinterConverter::convertToBase(Helper::hexDecode($this->maxSupply)); + $this->mintable = (bool) hexdec($this->mintable); + $this->burnable = (bool) hexdec($this->burnable); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterDeclareCandidacyTx.php b/src/Minter/SDK/MinterCoins/MinterDeclareCandidacyTx.php index de7bb90..1d77fa9 100644 --- a/src/Minter/SDK/MinterCoins/MinterDeclareCandidacyTx.php +++ b/src/Minter/SDK/MinterCoins/MinterDeclareCandidacyTx.php @@ -13,8 +13,7 @@ */ class MinterDeclareCandidacyTx extends MinterCoinTx implements MinterTxInterface { - const TYPE = 6; - const COMMISSION = 10000; + const TYPE = 6; public $address; public $publicKey; diff --git a/src/Minter/SDK/MinterCoins/MinterDelegateTx.php b/src/Minter/SDK/MinterCoins/MinterDelegateTx.php index c8f180c..1ee5d75 100644 --- a/src/Minter/SDK/MinterCoins/MinterDelegateTx.php +++ b/src/Minter/SDK/MinterCoins/MinterDelegateTx.php @@ -17,8 +17,7 @@ class MinterDelegateTx extends MinterCoinTx implements MinterTxInterface public $coin; public $stake; - const TYPE = 7; - const COMMISSION = 200; + const TYPE = 7; /** * MinterDelegateTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterEditCandidateCommissionTx.php b/src/Minter/SDK/MinterCoins/MinterEditCandidateCommissionTx.php new file mode 100644 index 0000000..f23ffa6 --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterEditCandidateCommissionTx.php @@ -0,0 +1,50 @@ +publicKey = $publicKey; + $this->commission = $commission; + } + + /** + * Prepare data for signing + * + * @return array + */ + public function encodeData(): array + { + return [ + hex2bin(Helper::removePrefix($this->publicKey, MinterPrefix::PUBLIC_KEY)), + $this->commission === 0 ? '' : $this->commission + ]; + } + + public function decodeData() + { + $this->publicKey = MinterPrefix::PUBLIC_KEY . $this->publicKey; + $this->commission = (int) Helper::hexDecode($this->commission); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterEditCandidatePublicKeyTx.php b/src/Minter/SDK/MinterCoins/MinterEditCandidatePublicKeyTx.php index ad8305e..26d79a5 100644 --- a/src/Minter/SDK/MinterCoins/MinterEditCandidatePublicKeyTx.php +++ b/src/Minter/SDK/MinterCoins/MinterEditCandidatePublicKeyTx.php @@ -15,8 +15,7 @@ class MinterEditCandidatePublicKeyTx extends MinterCoinTx implements MinterTxInt public $publicKey; public $newPublicKey; - const TYPE = 20; - const COMMISSION = 100000000; + const TYPE = 20; /** * MinterEditCandidatePublicKeyTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterEditCandidateTx.php b/src/Minter/SDK/MinterCoins/MinterEditCandidateTx.php index f8af10b..c1eec15 100644 --- a/src/Minter/SDK/MinterCoins/MinterEditCandidateTx.php +++ b/src/Minter/SDK/MinterCoins/MinterEditCandidateTx.php @@ -17,8 +17,7 @@ class MinterEditCandidateTx extends MinterCoinTx implements MinterTxInterface public $ownerAddress; public $controlAddress; - const TYPE = 14; - const COMMISSION = 10000; + const TYPE = 14; /** * MinterEditCandidateTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterEditCoinOwnerTx.php b/src/Minter/SDK/MinterCoins/MinterEditCoinOwnerTx.php index e44b407..1321afb 100644 --- a/src/Minter/SDK/MinterCoins/MinterEditCoinOwnerTx.php +++ b/src/Minter/SDK/MinterCoins/MinterEditCoinOwnerTx.php @@ -15,8 +15,7 @@ class MinterEditCoinOwnerTx extends MinterCoinTx implements MinterTxInterface public $symbol; public $newOwner; - const TYPE = 17; - const COMMISSION = 10000000; + const TYPE = 17; /** * MinterEditCoinOwnerTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterEditMultisigTx.php b/src/Minter/SDK/MinterCoins/MinterEditMultisigTx.php index 8c1dec5..6cb54fc 100644 --- a/src/Minter/SDK/MinterCoins/MinterEditMultisigTx.php +++ b/src/Minter/SDK/MinterCoins/MinterEditMultisigTx.php @@ -15,8 +15,7 @@ class MinterEditMultisigTx extends MinterCoinTx implements MinterTxInterface public $addresses; public $threshold; - const TYPE = 18; - const COMMISSION = 1000; + const TYPE = 18; /** * MinterEditMultisigTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterMintTokenTx.php b/src/Minter/SDK/MinterCoins/MinterMintTokenTx.php new file mode 100644 index 0000000..3eef5b1 --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterMintTokenTx.php @@ -0,0 +1,49 @@ +coin = $coin; + $this->value = $value; + } + + /** + * Prepare data for signing + * + * @return array + */ + public function encodeData(): array + { + return [ + $this->coin, + MinterConverter::convertToPip($this->value) + ]; + } + + public function decodeData() + { + $this->coin = hexdec($this->coin); + $this->value = MinterConverter::convertToBase(Helper::hexDecode($this->value)); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterMoveStakeTx.php b/src/Minter/SDK/MinterCoins/MinterMoveStakeTx.php new file mode 100644 index 0000000..25313f8 --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterMoveStakeTx.php @@ -0,0 +1,60 @@ +from = $from; + $this->to = $to; + $this->coin = $coin; + $this->stake = $stake; + } + + /** + * Prepare data for signing + * + * @return array + */ + public function encodeData(): array + { + return [ + hex2bin(Helper::removePrefix($this->from, MinterPrefix::PUBLIC_KEY)), + hex2bin(Helper::removePrefix($this->to, MinterPrefix::PUBLIC_KEY)), + $this->coin, + MinterConverter::convertToPip($this->stake) + ]; + } + + public function decodeData() + { + $this->from = MinterPrefix::PUBLIC_KEY . $this->from; + $this->to = MinterPrefix::PUBLIC_KEY . $this->to; + $this->coin = hexdec($this->coin); + $this->stake = MinterConverter::convertToBase(Helper::hexDecode($this->stake)); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterMultiSendTx.php b/src/Minter/SDK/MinterCoins/MinterMultiSendTx.php index 29b7708..7fa68fd 100644 --- a/src/Minter/SDK/MinterCoins/MinterMultiSendTx.php +++ b/src/Minter/SDK/MinterCoins/MinterMultiSendTx.php @@ -12,8 +12,7 @@ class MinterMultiSendTx extends MinterCoinTx implements MinterTxInterface { public $list; - const TYPE = 13; - const COMMISSION = 5; + const TYPE = 13; /** * MinterMultiSendTx constructor. @@ -50,9 +49,4 @@ public function decodeData() $this->list[$key] = $send; } } - - public function getFee() - { - return MinterSendCoinTx::COMMISSION + (count($this->list) - 1) * self::COMMISSION; - } } \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterPriceCommissionTx.php b/src/Minter/SDK/MinterCoins/MinterPriceCommissionTx.php new file mode 100644 index 0000000..b5ce20a --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterPriceCommissionTx.php @@ -0,0 +1,307 @@ +pubKey = $pubKey; + $this->height = $height; + $this->coin = $coin; + $this->payloadByte = $payloadByte; + $this->send = $send; + $this->buyBancor = $buyBancor; + $this->sellBancor = $sellBancor; + $this->sellAllBancor = $sellAllBancor; + $this->buyPool = $buyPool; + $this->sellPool = $sellPool; + $this->sellAllPool = $sellAllPool; + $this->createTicker3 = $createTicker3; + $this->createTicker4 = $createTicker4; + $this->createTicker5 = $createTicker5; + $this->createTicker6 = $createTicker6; + $this->createTicker7to10 = $createTicker7to10; + $this->createCoin = $createCoin; + $this->createToken = $createToken; + $this->recreateCoin = $recreateCoin; + $this->recreateToken = $recreateToken; + $this->declareCandidacy = $declareCandidacy; + $this->delegate = $delegate; + $this->unbond = $unbond; + $this->redeemCheck = $redeemCheck; + $this->setCandidateOn = $setCandidateOn; + $this->setCandidateOff = $setCandidateOff; + $this->createMultisig = $createMultisig; + $this->multisendBase = $multisendBase; + $this->multisendDelta = $multisendDelta; + $this->editCandidate = $editCandidate; + $this->setHaltBlock = $setHaltBlock; + $this->editTickerOwner = $editTickerOwner; + $this->editMultisig = $editMultisig; + $this->priceVote = $priceVote; + $this->editCandidatePublicKey = $editCandidatePublicKey; + $this->createSwapPool = $createSwapPool; + $this->addLiquidity = $addLiquidity; + $this->removeLiquidity = $removeLiquidity; + $this->editCandidateCommission = $editCandidateCommission; + $this->moveStake = $moveStake; + $this->burnToken = $burnToken; + $this->mintToken = $mintToken; + $this->voteCommission = $voteCommission; + $this->voteUpdate = $voteUpdate; + } + + /** + * Prepare tx data for signing + * + * @return array + */ + function encodeData(): array + { + return [ + hex2bin(Helper::removePrefix($this->pubKey, MinterPrefix::PUBLIC_KEY)), + $this->height, + $this->coin, + MinterConverter::convertToPip($this->payloadByte), + MinterConverter::convertToPip($this->send), + MinterConverter::convertToPip($this->buyBancor), + MinterConverter::convertToPip($this->sellBancor), + MinterConverter::convertToPip($this->sellAllBancor), + MinterConverter::convertToPip($this->buyPool), + MinterConverter::convertToPip($this->sellPool), + MinterConverter::convertToPip($this->sellAllPool), + MinterConverter::convertToPip($this->createTicker3), + MinterConverter::convertToPip($this->createTicker4), + MinterConverter::convertToPip($this->createTicker5), + MinterConverter::convertToPip($this->createTicker6), + MinterConverter::convertToPip($this->createTicker7to10), + MinterConverter::convertToPip($this->createCoin), + MinterConverter::convertToPip($this->createToken), + MinterConverter::convertToPip($this->recreateCoin), + MinterConverter::convertToPip($this->recreateToken), + MinterConverter::convertToPip($this->declareCandidacy), + MinterConverter::convertToPip($this->delegate), + MinterConverter::convertToPip($this->unbond), + MinterConverter::convertToPip($this->redeemCheck), + MinterConverter::convertToPip($this->setCandidateOn), + MinterConverter::convertToPip($this->setCandidateOff), + MinterConverter::convertToPip($this->createMultisig), + MinterConverter::convertToPip($this->multisendBase), + MinterConverter::convertToPip($this->multisendDelta), + MinterConverter::convertToPip($this->editCandidate), + MinterConverter::convertToPip($this->setHaltBlock), + MinterConverter::convertToPip($this->editTickerOwner), + MinterConverter::convertToPip($this->editMultisig), + MinterConverter::convertToPip($this->priceVote), + MinterConverter::convertToPip($this->editCandidatePublicKey), + MinterConverter::convertToPip($this->createSwapPool), + MinterConverter::convertToPip($this->addLiquidity), + MinterConverter::convertToPip($this->removeLiquidity), + MinterConverter::convertToPip($this->editCandidateCommission), + MinterConverter::convertToPip($this->moveStake), + MinterConverter::convertToPip($this->burnToken), + MinterConverter::convertToPip($this->mintToken), + MinterConverter::convertToPip($this->voteCommission), + MinterConverter::convertToPip($this->voteUpdate) + ]; + } + + + function decodeData() + { + $this->pubKey = MinterPrefix::PUBLIC_KEY . $this->pubKey; + $this->height = (int)hexdec($this->height); + $this->coin = hexdec($this->coin); + $this->payloadByte = MinterConverter::convertToBase(Helper::hexDecode($this->payloadByte)); + $this->send = MinterConverter::convertToBase(Helper::hexDecode($this->send)); + $this->buyBancor = MinterConverter::convertToBase(Helper::hexDecode($this->buyBancor)); + $this->sellBancor = MinterConverter::convertToBase(Helper::hexDecode($this->sellBancor)); + $this->sellAllBancor = MinterConverter::convertToBase(Helper::hexDecode($this->sellAllBancor)); + $this->buyPool = MinterConverter::convertToBase(Helper::hexDecode($this->buyPool)); + $this->sellPool = MinterConverter::convertToBase(Helper::hexDecode($this->sellPool)); + $this->sellAllPool = MinterConverter::convertToBase(Helper::hexDecode($this->sellAllPool)); + $this->createTicker3 = MinterConverter::convertToBase(Helper::hexDecode($this->createTicker3)); + $this->createTicker4 = MinterConverter::convertToBase(Helper::hexDecode($this->createTicker4)); + $this->createTicker5 = MinterConverter::convertToBase(Helper::hexDecode($this->createTicker5)); + $this->createTicker6 = MinterConverter::convertToBase(Helper::hexDecode($this->createTicker6)); + $this->createTicker7to10 = MinterConverter::convertToBase(Helper::hexDecode($this->createTicker7to10)); + $this->createCoin = MinterConverter::convertToBase(Helper::hexDecode($this->createCoin)); + $this->createToken = MinterConverter::convertToBase(Helper::hexDecode($this->createToken)); + $this->recreateCoin = MinterConverter::convertToBase(Helper::hexDecode($this->recreateCoin)); + $this->recreateToken = MinterConverter::convertToBase(Helper::hexDecode($this->recreateToken)); + $this->declareCandidacy = MinterConverter::convertToBase(Helper::hexDecode($this->declareCandidacy)); + $this->delegate = MinterConverter::convertToBase(Helper::hexDecode($this->delegate)); + $this->unbond = MinterConverter::convertToBase(Helper::hexDecode($this->unbond)); + $this->redeemCheck = MinterConverter::convertToBase(Helper::hexDecode($this->redeemCheck)); + $this->setCandidateOn = MinterConverter::convertToBase(Helper::hexDecode($this->setCandidateOn)); + $this->setCandidateOff = MinterConverter::convertToBase(Helper::hexDecode($this->setCandidateOff)); + $this->createMultisig = MinterConverter::convertToBase(Helper::hexDecode($this->createMultisig)); + $this->multisendBase = MinterConverter::convertToBase(Helper::hexDecode($this->multisendBase)); + $this->multisendDelta = MinterConverter::convertToBase(Helper::hexDecode($this->multisendDelta)); + $this->editCandidate = MinterConverter::convertToBase(Helper::hexDecode($this->editCandidate)); + $this->setHaltBlock = MinterConverter::convertToBase(Helper::hexDecode($this->setHaltBlock)); + $this->editTickerOwner = MinterConverter::convertToBase(Helper::hexDecode($this->editTickerOwner)); + $this->editMultisig = MinterConverter::convertToBase(Helper::hexDecode($this->editMultisig)); + $this->priceVote = MinterConverter::convertToBase(Helper::hexDecode($this->priceVote)); + $this->editCandidatePublicKey = MinterConverter::convertToBase(Helper::hexDecode($this->editCandidatePublicKey)); + $this->createSwapPool = MinterConverter::convertToBase(Helper::hexDecode($this->createSwapPool)); + $this->addLiquidity = MinterConverter::convertToBase(Helper::hexDecode($this->addLiquidity)); + $this->removeLiquidity = MinterConverter::convertToBase(Helper::hexDecode($this->removeLiquidity)); + $this->editCandidateCommission = MinterConverter::convertToBase(Helper::hexDecode($this->editCandidateCommission)); + $this->moveStake = MinterConverter::convertToBase(Helper::hexDecode($this->moveStake)); + $this->burnToken = MinterConverter::convertToBase(Helper::hexDecode($this->burnToken)); + $this->mintToken = MinterConverter::convertToBase(Helper::hexDecode($this->mintToken)); + $this->voteCommission = MinterConverter::convertToBase(Helper::hexDecode($this->voteCommission)); + $this->voteUpdate = MinterConverter::convertToBase(Helper::hexDecode($this->voteUpdate)); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterPriceVoteTx.php b/src/Minter/SDK/MinterCoins/MinterPriceVoteTx.php index bf39f70..a323bd6 100644 --- a/src/Minter/SDK/MinterCoins/MinterPriceVoteTx.php +++ b/src/Minter/SDK/MinterCoins/MinterPriceVoteTx.php @@ -12,8 +12,7 @@ class MinterPriceVoteTx extends MinterCoinTx implements MinterTxInterface { public $price; - const TYPE = 19; - const COMMISSION = 10; + const TYPE = 19; /** * MinterPriceVoteTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterRecreateCoinTx.php b/src/Minter/SDK/MinterCoins/MinterRecreateCoinTx.php index ca58a09..59fe31b 100644 --- a/src/Minter/SDK/MinterCoins/MinterRecreateCoinTx.php +++ b/src/Minter/SDK/MinterCoins/MinterRecreateCoinTx.php @@ -19,8 +19,7 @@ class MinterRecreateCoinTx extends MinterCoinTx implements MinterTxInterface public $maxSupply; public $name; - const TYPE = 16; - const COMMISSION = 10000000; + const TYPE = 16; /** * MinterRecreateCoinTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterRecreateTokenTx.php b/src/Minter/SDK/MinterCoins/MinterRecreateTokenTx.php new file mode 100644 index 0000000..4444f88 --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterRecreateTokenTx.php @@ -0,0 +1,69 @@ +name = $name; + $this->symbol = $symbol; + $this->initialAmount = $initialAmount; + $this->maxSupply = $maxSupply; + $this->mintable = $mintable; + $this->burnable = $burnable; + } + + /** + * Prepare tx data for signing + * + * @return array + */ + public function encodeData(): array + { + return [ + $this->name, + MinterConverter::convertCoinName($this->symbol), + MinterConverter::convertToPip($this->initialAmount), + MinterConverter::convertToPip($this->maxSupply), + (int) $this->mintable, + (int) $this->burnable + ]; + } + + public function decodeData() + { + $this->name = Helper::hex2str($this->name); + $this->symbol = Helper::hex2str($this->symbol); + $this->initialAmount = MinterConverter::convertToBase(Helper::hexDecode($this->initialAmount)); + $this->maxSupply = MinterConverter::convertToBase(Helper::hexDecode($this->maxSupply)); + $this->mintable = (bool) hexdec($this->mintable); + $this->burnable = (bool) hexdec($this->burnable); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterRedeemCheckTx.php b/src/Minter/SDK/MinterCoins/MinterRedeemCheckTx.php index 19f68c0..e5af79c 100644 --- a/src/Minter/SDK/MinterCoins/MinterRedeemCheckTx.php +++ b/src/Minter/SDK/MinterCoins/MinterRedeemCheckTx.php @@ -15,8 +15,7 @@ class MinterRedeemCheckTx extends MinterCoinTx implements MinterTxInterface public $check; public $proof; - const TYPE = 9; - const COMMISSION = 30; + const TYPE = 9; /** * MinterRedeemCheckTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterRemoveLiquidityTx.php b/src/Minter/SDK/MinterCoins/MinterRemoveLiquidityTx.php new file mode 100644 index 0000000..fb3dfc0 --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterRemoveLiquidityTx.php @@ -0,0 +1,65 @@ +coin0 = $coin0; + $this->coin1 = $coin1; + $this->liquidity = $liquidity; + $this->minimumVolume0 = $minimumVolume0; + $this->minimumVolume1 = $minimumVolume1; + } + + /** + * Prepare data for signing + * + * @return array + */ + function encodeData(): array + { + return [ + $this->coin0, + $this->coin1, + MinterConverter::convertToPip($this->liquidity), + MinterConverter::convertToPip($this->minimumVolume0), + MinterConverter::convertToPip($this->minimumVolume1) + ]; + } + + function decodeData() + { + $this->coin0 = hexdec($this->coin0); + $this->coin1 = hexdec($this->coin1); + $this->liquidity = MinterConverter::convertToBase(Helper::hexDecode($this->liquidity)); + $this->minimumVolume0 = MinterConverter::convertToBase(Helper::hexDecode($this->minimumVolume0)); + $this->minimumVolume1 = MinterConverter::convertToBase(Helper::hexDecode($this->minimumVolume1)); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterSellAllCoinTx.php b/src/Minter/SDK/MinterCoins/MinterSellAllCoinTx.php index ef85fe2..3aeda56 100644 --- a/src/Minter/SDK/MinterCoins/MinterSellAllCoinTx.php +++ b/src/Minter/SDK/MinterCoins/MinterSellAllCoinTx.php @@ -16,8 +16,7 @@ class MinterSellAllCoinTx extends MinterCoinTx implements MinterTxInterface public $coinToSell; public $minimumValueToBuy; - const TYPE = 3; - const COMMISSION = 100; + const TYPE = 3; /** * MinterSellAllCoinTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterSellAllSwapPoolTx.php b/src/Minter/SDK/MinterCoins/MinterSellAllSwapPoolTx.php new file mode 100644 index 0000000..9c625b3 --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterSellAllSwapPoolTx.php @@ -0,0 +1,55 @@ +coinToBuy = $coinToBuy; + $this->coinToSell = $coinToSell; + $this->minimumValueToBuy = $minimumValueToBuy; + } + + /** + * Prepare tx data for signing + * + * @return array + */ + public function encodeData(): array + { + return [ + $this->coinToSell, + $this->coinToBuy, + MinterConverter::convertToPip($this->minimumValueToBuy) + ]; + } + + public function decodeData() + { + $this->coinToSell = hexdec($this->coinToSell); + $this->coinToBuy = hexdec($this->coinToBuy); + $this->minimumValueToBuy = MinterConverter::convertToBase(Helper::hexDecode($this->minimumValueToBuy)); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterSellCoinTx.php b/src/Minter/SDK/MinterCoins/MinterSellCoinTx.php index ff35f08..94babb5 100644 --- a/src/Minter/SDK/MinterCoins/MinterSellCoinTx.php +++ b/src/Minter/SDK/MinterCoins/MinterSellCoinTx.php @@ -17,8 +17,7 @@ class MinterSellCoinTx extends MinterCoinTx implements MinterTxInterface public $valueToSell; public $minimumValueToBuy; - const TYPE = 2; - const COMMISSION = 100; + const TYPE = 2; /** * MinterSellCoinTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterSellSwapPoolTx.php b/src/Minter/SDK/MinterCoins/MinterSellSwapPoolTx.php new file mode 100644 index 0000000..aca4cd2 --- /dev/null +++ b/src/Minter/SDK/MinterCoins/MinterSellSwapPoolTx.php @@ -0,0 +1,60 @@ +coinToBuy = $coinToBuy; + $this->coinToSell = $coinToSell; + $this->valueToSell = $valueToSell; + $this->minimumValueToBuy = $minimumValueToBuy; + } + + /** + * Prepare tx data for signing + * + * @return array + */ + public function encodeData(): array + { + return [ + $this->coinToSell, + MinterConverter::convertToPip($this->valueToSell), + $this->coinToBuy, + MinterConverter::convertToPip($this->minimumValueToBuy) + ]; + } + + public function decodeData() + { + $this->coinToSell = hexdec($this->coinToSell); + $this->valueToSell = MinterConverter::convertToBase(Helper::hexDecode($this->valueToSell)); + $this->coinToBuy = hexdec($this->coinToBuy); + $this->minimumValueToBuy = MinterConverter::convertToBase(Helper::hexDecode($this->minimumValueToBuy)); + } +} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterSendCoinTx.php b/src/Minter/SDK/MinterCoins/MinterSendCoinTx.php index c04b488..abba8f1 100644 --- a/src/Minter/SDK/MinterCoins/MinterSendCoinTx.php +++ b/src/Minter/SDK/MinterCoins/MinterSendCoinTx.php @@ -16,8 +16,7 @@ class MinterSendCoinTx extends MinterCoinTx implements MinterTxInterface public $to; public $value; - const TYPE = 1; - const COMMISSION = 10; + const TYPE = 1; /** * MinterSendCoinTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterSetCandidateOffTx.php b/src/Minter/SDK/MinterCoins/MinterSetCandidateOffTx.php index 97bb597..e37b80b 100644 --- a/src/Minter/SDK/MinterCoins/MinterSetCandidateOffTx.php +++ b/src/Minter/SDK/MinterCoins/MinterSetCandidateOffTx.php @@ -14,8 +14,7 @@ class MinterSetCandidateOffTx extends MinterCoinTx implements MinterTxInterface { public $publicKey; - const TYPE = 11; - const COMMISSION = 100; + const TYPE = 11; /** * MinterSetCandidateOffTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterSetCandidateOnTx.php b/src/Minter/SDK/MinterCoins/MinterSetCandidateOnTx.php index bef14af..4291bfa 100644 --- a/src/Minter/SDK/MinterCoins/MinterSetCandidateOnTx.php +++ b/src/Minter/SDK/MinterCoins/MinterSetCandidateOnTx.php @@ -14,8 +14,7 @@ class MinterSetCandidateOnTx extends MinterCoinTx implements MinterTxInterface { public $publicKey; - const TYPE = 10; - const COMMISSION = 100; + const TYPE = 10; /** * MinterSetCandidateOnTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterSetHaltBlockTx.php b/src/Minter/SDK/MinterCoins/MinterSetHaltBlockTx.php index 7f5049c..180a110 100644 --- a/src/Minter/SDK/MinterCoins/MinterSetHaltBlockTx.php +++ b/src/Minter/SDK/MinterCoins/MinterSetHaltBlockTx.php @@ -15,8 +15,7 @@ class MinterSetHaltBlockTx extends MinterCoinTx implements MinterTxInterface public $publicKey; public $height; - const TYPE = 15; - const COMMISSION = 1000; + const TYPE = 15; /** * MinterUnbondTx constructor. diff --git a/src/Minter/SDK/MinterCoins/MinterUnbondTx.php b/src/Minter/SDK/MinterCoins/MinterUnbondTx.php index bc33af3..50e7a80 100644 --- a/src/Minter/SDK/MinterCoins/MinterUnbondTx.php +++ b/src/Minter/SDK/MinterCoins/MinterUnbondTx.php @@ -17,8 +17,7 @@ class MinterUnbondTx extends MinterCoinTx implements MinterTxInterface public $coin; public $value; - const TYPE = 8; - const COMMISSION = 200; + const TYPE = 8; /** * MinterUnbondTx constructor. diff --git a/tests/MinterAddLiquidityTxTest.php b/tests/MinterAddLiquidityTxTest.php new file mode 100644 index 0000000..679b790 --- /dev/null +++ b/tests/MinterAddLiquidityTxTest.php @@ -0,0 +1,64 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->coin0, $tx->getData()->coin0); + $this->assertSame($validTx->getData()->coin1, $tx->getData()->coin1); + $this->assertSame($validTx->getData()->volume0, $tx->getData()->volume0); + $this->assertSame($validTx->getData()->maximumVolume1, $tx->getData()->maximumVolume1); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterAddLiquidityTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterAddLiquidityTx(0, 1, '250', '500'); + return (new MinterTx(13, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID);; + } +} \ No newline at end of file diff --git a/tests/MinterBurnTokenTxTest.php b/tests/MinterBurnTokenTxTest.php new file mode 100644 index 0000000..fb2cf25 --- /dev/null +++ b/tests/MinterBurnTokenTxTest.php @@ -0,0 +1,62 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->coin, $tx->getData()->coin); + $this->assertSame($validTx->getData()->value, $tx->getData()->value); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterBurnTokenTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterBurnTokenTx(4,'2500'); + return (new MinterTx(24, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} diff --git a/tests/MinterBuySwapPoolTxTest.php b/tests/MinterBuySwapPoolTxTest.php new file mode 100644 index 0000000..ddd5306 --- /dev/null +++ b/tests/MinterBuySwapPoolTxTest.php @@ -0,0 +1,61 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->coinToBuy, $tx->getData()->coinToBuy); + $this->assertSame($validTx->getData()->valueToBuy, $tx->getData()->valueToBuy); + $this->assertSame($validTx->getData()->coinToSell, $tx->getData()->coinToSell); + $this->assertSame($validTx->getData()->maximumValueToSell, $tx->getData()->maximumValueToSell); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterBuySwapPoolTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterBuySwapPoolTx(1, '3', 0, '5000'); + return (new MinterTx(14, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} \ No newline at end of file diff --git a/tests/MinterCreateSwapPoolTxTest.php b/tests/MinterCreateSwapPoolTxTest.php new file mode 100644 index 0000000..d659a41 --- /dev/null +++ b/tests/MinterCreateSwapPoolTxTest.php @@ -0,0 +1,65 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->coin0, $tx->getData()->coin0); + $this->assertSame($validTx->getData()->coin1, $tx->getData()->coin1); + $this->assertSame($validTx->getData()->volume0, $tx->getData()->volume0); + $this->assertSame($validTx->getData()->volume1, $tx->getData()->volume1); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterCreateSwapPoolTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterCreateSwapPoolTx(3,4,'5000','10000'); + return (new MinterTx(26, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} \ No newline at end of file diff --git a/tests/MinterCreateTokenTxTest.php b/tests/MinterCreateTokenTxTest.php new file mode 100644 index 0000000..a993451 --- /dev/null +++ b/tests/MinterCreateTokenTxTest.php @@ -0,0 +1,63 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->name, $tx->getData()->name); + $this->assertSame($validTx->getData()->symbol, $tx->getData()->symbol); + $this->assertSame($validTx->getData()->initialAmount, $tx->getData()->initialAmount); + $this->assertSame($validTx->getData()->maxSupply, $tx->getData()->maxSupply); + $this->assertSame($validTx->getData()->mintable, $tx->getData()->mintable); + $this->assertSame($validTx->getData()->burnable, $tx->getData()->burnable); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterCreateTokenTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterCreateTokenTx('BURNABLE TOKEN','BURNABLE','250000','300000',false,true); + return (new MinterTx(19, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} \ No newline at end of file diff --git a/tests/MinterEditCandidateCommissionTxTest.php b/tests/MinterEditCandidateCommissionTxTest.php new file mode 100644 index 0000000..2ce9d37 --- /dev/null +++ b/tests/MinterEditCandidateCommissionTxTest.php @@ -0,0 +1,63 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->publicKey, $tx->getData()->publicKey); + $this->assertSame($validTx->getData()->commission, $tx->getData()->commission); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterEditCandidateCommissionTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterEditCandidateCommissionTx('Mp325580a8baed04899252ae5b5f6167ee34ec0144f3401d88586b350999999999',15); + return (new MinterTx(25, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} diff --git a/tests/MinterMintTokenTxTest.php b/tests/MinterMintTokenTxTest.php new file mode 100644 index 0000000..e828a3e --- /dev/null +++ b/tests/MinterMintTokenTxTest.php @@ -0,0 +1,62 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->coin, $tx->getData()->coin); + $this->assertSame($validTx->getData()->value, $tx->getData()->value); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterMintTokenTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterMintTokenTx(3,'2500'); + return (new MinterTx(23, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} diff --git a/tests/MinterMoveStakeTxTest.php b/tests/MinterMoveStakeTxTest.php new file mode 100644 index 0000000..7c25479 --- /dev/null +++ b/tests/MinterMoveStakeTxTest.php @@ -0,0 +1,64 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->from, $tx->getData()->from); + $this->assertSame($validTx->getData()->to, $tx->getData()->to); + $this->assertSame($validTx->getData()->coin, $tx->getData()->coin); + $this->assertSame($validTx->getData()->stake, $tx->getData()->stake); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterMoveStakeTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterMoveStakeTx('Mp325580a8baed04899252ae5b5f6167ee34ec0144f3401d88586b350999999999','Mp325580a8baed04899252ae5b5f6167ee34ec0144f3401d88586b350a380bc7d4',0,'5000'); + return (new MinterTx(20, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} diff --git a/tests/MinterPriceCommissionTxTest.php b/tests/MinterPriceCommissionTxTest.php new file mode 100644 index 0000000..f726f72 --- /dev/null +++ b/tests/MinterPriceCommissionTxTest.php @@ -0,0 +1,104 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->pubKey, $tx->getData()->pubKey); + $this->assertSame($validTx->getData()->height, $tx->getData()->height); + $this->assertSame($validTx->getData()->coin, $tx->getData()->coin); + $this->assertSame($validTx->getData()->payloadByte, $tx->getData()->payloadByte); + $this->assertSame($validTx->getData()->send, $tx->getData()->send); + $this->assertSame($validTx->getData()->buyBancor, $tx->getData()->buyBancor); + $this->assertSame($validTx->getData()->sellBancor, $tx->getData()->sellBancor); + $this->assertSame($validTx->getData()->sellAllBancor, $tx->getData()->sellAllBancor); + $this->assertSame($validTx->getData()->buyPool, $tx->getData()->buyPool); + $this->assertSame($validTx->getData()->sellPool, $tx->getData()->sellPool); + $this->assertSame($validTx->getData()->sellAllPool, $tx->getData()->sellAllPool); + $this->assertSame($validTx->getData()->createTicker3, $tx->getData()->createTicker3); + $this->assertSame($validTx->getData()->createTicker4, $tx->getData()->createTicker4); + $this->assertSame($validTx->getData()->createTicker5, $tx->getData()->createTicker5); + $this->assertSame($validTx->getData()->createTicker6, $tx->getData()->createTicker6); + $this->assertSame($validTx->getData()->createTicker7to10, $tx->getData()->createTicker7to10); + $this->assertSame($validTx->getData()->createCoin, $tx->getData()->createCoin); + $this->assertSame($validTx->getData()->createToken, $tx->getData()->createToken); + $this->assertSame($validTx->getData()->recreateCoin, $tx->getData()->recreateCoin); + $this->assertSame($validTx->getData()->recreateToken, $tx->getData()->recreateToken); + $this->assertSame($validTx->getData()->declareCandidacy, $tx->getData()->declareCandidacy); + $this->assertSame($validTx->getData()->delegate, $tx->getData()->delegate); + $this->assertSame($validTx->getData()->unbond, $tx->getData()->unbond); + $this->assertSame($validTx->getData()->redeemCheck, $tx->getData()->redeemCheck); + $this->assertSame($validTx->getData()->setCandidateOn, $tx->getData()->setCandidateOn); + $this->assertSame($validTx->getData()->setCandidateOff, $tx->getData()->setCandidateOff); + $this->assertSame($validTx->getData()->createMultisig, $tx->getData()->createMultisig); + $this->assertSame($validTx->getData()->multisendBase, $tx->getData()->multisendBase); + $this->assertSame($validTx->getData()->multisendDelta, $tx->getData()->multisendDelta); + $this->assertSame($validTx->getData()->editCandidate, $tx->getData()->editCandidate); + $this->assertSame($validTx->getData()->setHaltBlock, $tx->getData()->setHaltBlock); + $this->assertSame($validTx->getData()->editTickerOwner, $tx->getData()->editTickerOwner); + $this->assertSame($validTx->getData()->editMultisig, $tx->getData()->editMultisig); + $this->assertSame($validTx->getData()->priceVote, $tx->getData()->priceVote); + $this->assertSame($validTx->getData()->editCandidatePublicKey, $tx->getData()->editCandidatePublicKey); + $this->assertSame($validTx->getData()->createSwapPool, $tx->getData()->createSwapPool); + $this->assertSame($validTx->getData()->addLiquidity, $tx->getData()->addLiquidity); + $this->assertSame($validTx->getData()->removeLiquidity, $tx->getData()->removeLiquidity); + $this->assertSame($validTx->getData()->editCandidateCommission, $tx->getData()->editCandidateCommission); + $this->assertSame($validTx->getData()->moveStake, $tx->getData()->moveStake); + $this->assertSame($validTx->getData()->burnToken, $tx->getData()->burnToken); + $this->assertSame($validTx->getData()->mintToken, $tx->getData()->mintToken); + $this->assertSame($validTx->getData()->voteCommission, $tx->getData()->voteCommission); + $this->assertSame($validTx->getData()->voteUpdate, $tx->getData()->voteUpdate); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterPriceCommissionTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterPriceCommissionTx('Mp325580a8baed04899252ae5b5f6167ee34ec0144f3401d88586b350999999999', 100000,0,'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41'); + return (new MinterTx(31, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} diff --git a/tests/MinterRecreateTokenTxTest.php b/tests/MinterRecreateTokenTxTest.php new file mode 100644 index 0000000..f177dfb --- /dev/null +++ b/tests/MinterRecreateTokenTxTest.php @@ -0,0 +1,63 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->name, $tx->getData()->name); + $this->assertSame($validTx->getData()->symbol, $tx->getData()->symbol); + $this->assertSame($validTx->getData()->initialAmount, $tx->getData()->initialAmount); + $this->assertSame($validTx->getData()->maxSupply, $tx->getData()->maxSupply); + $this->assertSame($validTx->getData()->mintable, $tx->getData()->mintable); + $this->assertSame($validTx->getData()->burnable, $tx->getData()->burnable); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterRecreateTokenTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterRecreateTokenTx('BURNABLE & MINTABLE TOKEN','BURNABLE','999999','999999',true,true); + return (new MinterTx(30, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} \ No newline at end of file diff --git a/tests/MinterRemoveLiquidityTxTest.php b/tests/MinterRemoveLiquidityTxTest.php new file mode 100644 index 0000000..34688f2 --- /dev/null +++ b/tests/MinterRemoveLiquidityTxTest.php @@ -0,0 +1,66 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->coin0, $tx->getData()->coin0); + $this->assertSame($validTx->getData()->coin1, $tx->getData()->coin1); + $this->assertSame($validTx->getData()->liquidity, $tx->getData()->liquidity); + $this->assertSame($validTx->getData()->minimumVolume0, $tx->getData()->minimumVolume0); + $this->assertSame($validTx->getData()->minimumVolume1, $tx->getData()->minimumVolume1); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterRemoveLiquidityTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterRemoveLiquidityTx(0, 1, '100', '25', '15'); + return (new MinterTx(6, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} \ No newline at end of file diff --git a/tests/MinterSellAllSwapPoolTxTest.php b/tests/MinterSellAllSwapPoolTxTest.php new file mode 100644 index 0000000..3a4aa47 --- /dev/null +++ b/tests/MinterSellAllSwapPoolTxTest.php @@ -0,0 +1,60 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->coinToBuy, $tx->getData()->coinToBuy); + $this->assertSame($validTx->getData()->coinToSell, $tx->getData()->coinToSell); + $this->assertSame($validTx->getData()->minimumValueToBuy, $tx->getData()->minimumValueToBuy); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterSellAllSwapPoolTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterSellAllSwapPoolTx(1, 0, '100'); + return (new MinterTx(16, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} \ No newline at end of file diff --git a/tests/MinterSellSwapPoolTxTest.php b/tests/MinterSellSwapPoolTxTest.php new file mode 100644 index 0000000..7b59113 --- /dev/null +++ b/tests/MinterSellSwapPoolTxTest.php @@ -0,0 +1,61 @@ +makeTransaction(); + + $this->assertSame($validTx->getNonce(), $tx->getNonce()); + $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); + $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); + $this->assertSame($validTx->getChainID(), $tx->getChainID()); + $this->assertSame($validTx->getData()->coinToSell, $tx->getData()->coinToSell); + $this->assertSame($validTx->getData()->valueToSell, $tx->getData()->valueToSell); + $this->assertSame($validTx->getData()->coinToBuy, $tx->getData()->coinToBuy); + $this->assertSame($validTx->getData()->minimumValueToBuy, $tx->getData()->minimumValueToBuy); + $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); + } + + /** + * Test signing MinterSellSwapPoolTx + */ + public function testSign(): void + { + $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); + $this->assertSame($signature, self::VALID_SIGNATURE); + } + + /** + * @return MinterTx + */ + private function makeTransaction(): MinterTx + { + $data = new MinterSellSwapPoolTx(1, '20', 0, '2'); + return (new MinterTx(5, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); + } +} \ No newline at end of file From e5cfdaa5ab65c7062d0e2bf91f25dfe3cea972c2 Mon Sep 17 00:00:00 2001 From: MinterPro <51757982+minterpro@users.noreply.github.com> Date: Wed, 10 Feb 2021 11:43:27 +0300 Subject: [PATCH 02/10] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 741587b..f01b5a4 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "mx-dec0de/minter-php-sdk", + "name": "minter/minter-php-sdk", "autoload": { "psr-0" : { "Minter\\" : "src" From 33bfdcbc28dfb9eda1486183e414e87089b252ba Mon Sep 17 00:00:00 2001 From: MinterPro <51757982+minterpro@users.noreply.github.com> Date: Wed, 10 Feb 2021 11:44:02 +0300 Subject: [PATCH 03/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e44d7b0..59fcb30 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ This is a pure PHP SDK for working with Minter blockchain - [getMissedBlocks](#getmissedblocks) - [getWaitlist](#getwaitlist) - [getPriceCommissions](#getPriceCommissions) - - [getPriceVotes](#getPriceCommissions) + - [getPriceVotes](#getPriceVotes) - [getSwapPool](#getSwapPool) - [getSwapPoolProvider](#getSwapPoolProvider) - [Error handling](#error-handling) From b89354f05c0fbec2d0855a189a57a115e47549d0 Mon Sep 17 00:00:00 2001 From: MinterPro <51757982+minterpro@users.noreply.github.com> Date: Wed, 10 Feb 2021 11:49:53 +0300 Subject: [PATCH 04/10] Update MinterAPI.php --- src/Minter/MinterAPI.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Minter/MinterAPI.php b/src/Minter/MinterAPI.php index f494304..9acf59f 100644 --- a/src/Minter/MinterAPI.php +++ b/src/Minter/MinterAPI.php @@ -192,10 +192,7 @@ public function getTransaction(string $hash): \stdClass */ public function getBlock(int $height, ?bool $failedTxs = false): \stdClass { - if ($failedTxs) { - $params['failed_txs'] = 'true'; - } - return $this->get('block/' . $height, $params); + return $this->get('block/' . $height, (failedTxs ? ['failed_txs' => true] : null)); } /** @@ -261,6 +258,7 @@ public function getCoinInfo(string $symbol, ?int $height = null): \stdClass * @param string $valueToSell * @param string $coinToBuy * @param null|int $height + * @param string $swapFrom * @return \stdClass * @throws Exception * @throws GuzzleException @@ -293,6 +291,7 @@ public function estimateCoinSell( * @param string $valueToSell * @param string $coinToBuy * @param int|null $height + * @param string $swapFrom * @return \stdClass * @throws GuzzleException */ @@ -324,6 +323,7 @@ public function estimateCoinSellAll( * @param string $valueToBuy * @param string $coinToBuy * @param null|int $height + * @param string $swapFrom * @return \stdClass * @throws Exception * @throws GuzzleException From 14dd73d7387203c2f23aa77cf0c36b0079be8d99 Mon Sep 17 00:00:00 2001 From: MinterPro <51757982+minterpro@users.noreply.github.com> Date: Wed, 10 Feb 2021 11:51:23 +0300 Subject: [PATCH 05/10] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 59fcb30..6d24c3a 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ getValidators(?int $height = null, ?int $page = 1, ?int $perPage = null): \stdCl Return estimate of buy coin transaction. `` -estimateCoinBuy(string $coinToSell, string $valueToBuy, string $coinToBuy, ?int $height = null): \stdClass +estimateCoinBuy(string $coinToSell, string $valueToBuy, string $coinToBuy, ?int $height = null, string $swapFrom): \stdClass `` ### estimateCoinSell @@ -182,7 +182,7 @@ estimateCoinBuy(string $coinToSell, string $valueToBuy, string $coinToBuy, ?int Return estimate of sell coin transaction. `` -estimateCoinSell(string $coinToSell, string $valueToSell, string $coinToBuy, ?int $height = null): \stdClass +estimateCoinSell(string $coinToSell, string $valueToSell, string $coinToBuy, ?int $height = null, string $swapFrom): \stdClass `` ### estimateCoinSellAll @@ -190,7 +190,7 @@ estimateCoinSell(string $coinToSell, string $valueToSell, string $coinToBuy, ?in Return estimate of sell coin all transaction. `` -estimateCoinSellAll(string $coinToSell, string $valueToSell, string $coinToBuy, ?int $height = null): \stdClass +estimateCoinSellAll(string $coinToSell, string $valueToSell, string $coinToBuy, ?int $height = null, string $swapFrom): \stdClass `` ### getCoinInfo From 7d73655c5945347aadf003eb5e7169f4a9f85433 Mon Sep 17 00:00:00 2001 From: MinterPro <51757982+minterpro@users.noreply.github.com> Date: Wed, 10 Feb 2021 11:53:04 +0300 Subject: [PATCH 06/10] Update MinterRecreateTokenTx.php --- src/Minter/SDK/MinterCoins/MinterRecreateTokenTx.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Minter/SDK/MinterCoins/MinterRecreateTokenTx.php b/src/Minter/SDK/MinterCoins/MinterRecreateTokenTx.php index 4444f88..220f6c2 100644 --- a/src/Minter/SDK/MinterCoins/MinterRecreateTokenTx.php +++ b/src/Minter/SDK/MinterCoins/MinterRecreateTokenTx.php @@ -7,10 +7,10 @@ use Minter\SDK\MinterConverter; /** - * Class MinterReCreateTokenTx + * Class MinterRecreateTokenTx * @package Minter\SDK\MinterCoins */ -class MinterReCreateTokenTx extends MinterCoinTx implements MinterTxInterface +class MinterRecreateTokenTx extends MinterCoinTx implements MinterTxInterface { public $name; public $symbol; @@ -22,7 +22,7 @@ class MinterReCreateTokenTx extends MinterCoinTx implements MinterTxInterface const TYPE = 31; /** - * MinterReCreateTokenTx constructor. + * MinterRecreateTokenTx constructor. * @param $name * @param $symbol * @param $initialAmount @@ -66,4 +66,4 @@ public function decodeData() $this->mintable = (bool) hexdec($this->mintable); $this->burnable = (bool) hexdec($this->burnable); } -} \ No newline at end of file +} From 7b53d22f7d793a16d666aa292338561cb77d247a Mon Sep 17 00:00:00 2001 From: MinterPro <51757982+minterpro@users.noreply.github.com> Date: Wed, 10 Feb 2021 11:53:51 +0300 Subject: [PATCH 07/10] Update MinterAddLiquidityTxTest.php --- tests/MinterAddLiquidityTxTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/MinterAddLiquidityTxTest.php b/tests/MinterAddLiquidityTxTest.php index 679b790..9c1a60c 100644 --- a/tests/MinterAddLiquidityTxTest.php +++ b/tests/MinterAddLiquidityTxTest.php @@ -59,6 +59,6 @@ public function testSign(): void private function makeTransaction(): MinterTx { $data = new MinterAddLiquidityTx(0, 1, '250', '500'); - return (new MinterTx(13, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID);; + return (new MinterTx(13, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); } -} \ No newline at end of file +} From 0b20afaebc989617eeafd6b12fb20dc230c0b10f Mon Sep 17 00:00:00 2001 From: MinterPro <51757982+minterpro@users.noreply.github.com> Date: Wed, 10 Feb 2021 11:57:51 +0300 Subject: [PATCH 08/10] Update MinterAPI.php --- src/Minter/MinterAPI.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Minter/MinterAPI.php b/src/Minter/MinterAPI.php index 9acf59f..da7f112 100644 --- a/src/Minter/MinterAPI.php +++ b/src/Minter/MinterAPI.php @@ -192,7 +192,7 @@ public function getTransaction(string $hash): \stdClass */ public function getBlock(int $height, ?bool $failedTxs = false): \stdClass { - return $this->get('block/' . $height, (failedTxs ? ['failed_txs' => true] : null)); + return $this->get('block/' . $height, ($failedTxs ? ['failed_txs' => true] : null)); } /** From eedda35694ed0b0bec00cf119e6ac389d7a777b2 Mon Sep 17 00:00:00 2001 From: Kamil Mukhametzyanov Date: Tue, 23 Feb 2021 11:04:22 +0300 Subject: [PATCH 09/10] fix swap transactions --- .../SDK/MinterCoins/MinterBuySwapPoolTx.php | 19 +++++++-------- .../MinterCoins/MinterSellAllSwapPoolTx.php | 21 ++++++++--------- .../SDK/MinterCoins/MinterSellSwapPoolTx.php | 23 ++++++++----------- src/Minter/SDK/MinterTx.php | 15 +++++++++++- tests/MinterBuySwapPoolTxTest.php | 7 +++--- tests/MinterSellAllSwapPoolTxTest.php | 9 ++++---- tests/MinterSellSwapPoolTxTest.php | 7 +++--- 7 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/Minter/SDK/MinterCoins/MinterBuySwapPoolTx.php b/src/Minter/SDK/MinterCoins/MinterBuySwapPoolTx.php index eed0c6e..270ceba 100644 --- a/src/Minter/SDK/MinterCoins/MinterBuySwapPoolTx.php +++ b/src/Minter/SDK/MinterCoins/MinterBuySwapPoolTx.php @@ -13,8 +13,7 @@ */ class MinterBuySwapPoolTx extends MinterCoinTx implements MinterTxInterface { - public $coinToBuy; - public $coinToSell; + public $coins; public $valueToBuy; public $maximumValueToSell; @@ -22,15 +21,13 @@ class MinterBuySwapPoolTx extends MinterCoinTx implements MinterTxInterface /** * MinterBuySwapPoolTx constructor. - * @param $coinToBuy + * @param $coins * @param $valueToBuy - * @param $coinToSell * @param $maximumValueToSell */ - public function __construct($coinToBuy, $valueToBuy, $coinToSell, $maximumValueToSell) + public function __construct($coins, $valueToBuy, $maximumValueToSell) { - $this->coinToBuy = $coinToBuy; - $this->coinToSell = $coinToSell; + $this->coins = $coins; $this->valueToBuy = $valueToBuy; $this->maximumValueToSell = $maximumValueToSell; } @@ -38,18 +35,18 @@ public function __construct($coinToBuy, $valueToBuy, $coinToSell, $maximumValueT public function encodeData(): array { return [ - $this->coinToBuy, + $this->coins, MinterConverter::convertToPip($this->valueToBuy), - $this->coinToSell, MinterConverter::convertToPip($this->maximumValueToSell) ]; } public function decodeData() { - $this->coinToBuy = hexdec($this->coinToBuy); $this->valueToBuy = MinterConverter::convertToBase(Helper::hexDecode($this->valueToBuy)); - $this->coinToSell = hexdec($this->coinToSell); $this->maximumValueToSell = MinterConverter::convertToBase(Helper::hexDecode($this->maximumValueToSell)); + $this->coins = array_map(function ($value) { + return hexdec($value); + }, $this->coins); } } \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterSellAllSwapPoolTx.php b/src/Minter/SDK/MinterCoins/MinterSellAllSwapPoolTx.php index 9c625b3..f55072e 100644 --- a/src/Minter/SDK/MinterCoins/MinterSellAllSwapPoolTx.php +++ b/src/Minter/SDK/MinterCoins/MinterSellAllSwapPoolTx.php @@ -13,22 +13,19 @@ */ class MinterSellAllSwapPoolTx extends MinterCoinTx implements MinterTxInterface { - public $coinToBuy; - public $coinToSell; + public $coins; public $minimumValueToBuy; const TYPE = 25; /** * MinterSellAllSwapPoolTx constructor. - * @param $coinToSell - * @param $coinToBuy - * @param $minimumValueToBuy + * @param array $coins + * @param $minimumValueToBuy */ - public function __construct($coinToSell, $coinToBuy, $minimumValueToBuy) + public function __construct(array $coins, $minimumValueToBuy) { - $this->coinToBuy = $coinToBuy; - $this->coinToSell = $coinToSell; + $this->coins = $coins; $this->minimumValueToBuy = $minimumValueToBuy; } @@ -40,16 +37,16 @@ public function __construct($coinToSell, $coinToBuy, $minimumValueToBuy) public function encodeData(): array { return [ - $this->coinToSell, - $this->coinToBuy, + $this->coins, MinterConverter::convertToPip($this->minimumValueToBuy) ]; } public function decodeData() { - $this->coinToSell = hexdec($this->coinToSell); - $this->coinToBuy = hexdec($this->coinToBuy); $this->minimumValueToBuy = MinterConverter::convertToBase(Helper::hexDecode($this->minimumValueToBuy)); + $this->coins = array_map(function ($value) { + return hexdec($value); + }, $this->coins); } } \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterSellSwapPoolTx.php b/src/Minter/SDK/MinterCoins/MinterSellSwapPoolTx.php index aca4cd2..f3c294e 100644 --- a/src/Minter/SDK/MinterCoins/MinterSellSwapPoolTx.php +++ b/src/Minter/SDK/MinterCoins/MinterSellSwapPoolTx.php @@ -13,8 +13,7 @@ */ class MinterSellSwapPoolTx extends MinterCoinTx implements MinterTxInterface { - public $coinToBuy; - public $coinToSell; + public $coins; public $valueToSell; public $minimumValueToBuy; @@ -22,15 +21,13 @@ class MinterSellSwapPoolTx extends MinterCoinTx implements MinterTxInterface /** * MinterSellSwapPoolTx constructor. - * @param $coinToSell - * @param $valueToSell - * @param $coinToBuy - * @param $minimumValueToBuy + * @param array $coins + * @param $valueToSell + * @param $minimumValueToBuy */ - public function __construct($coinToSell, $valueToSell, $coinToBuy, $minimumValueToBuy) + public function __construct(array $coins, $valueToSell, $minimumValueToBuy) { - $this->coinToBuy = $coinToBuy; - $this->coinToSell = $coinToSell; + $this->coins = $coins; $this->valueToSell = $valueToSell; $this->minimumValueToBuy = $minimumValueToBuy; } @@ -43,18 +40,18 @@ public function __construct($coinToSell, $valueToSell, $coinToBuy, $minimumValue public function encodeData(): array { return [ - $this->coinToSell, + $this->coins, MinterConverter::convertToPip($this->valueToSell), - $this->coinToBuy, MinterConverter::convertToPip($this->minimumValueToBuy) ]; } public function decodeData() { - $this->coinToSell = hexdec($this->coinToSell); $this->valueToSell = MinterConverter::convertToBase(Helper::hexDecode($this->valueToSell)); - $this->coinToBuy = hexdec($this->coinToBuy); $this->minimumValueToBuy = MinterConverter::convertToBase(Helper::hexDecode($this->minimumValueToBuy)); + $this->coins = array_map(function ($value) { + return hexdec($value); + }, $this->coins); } } \ No newline at end of file diff --git a/src/Minter/SDK/MinterTx.php b/src/Minter/SDK/MinterTx.php index a365435..16427ef 100644 --- a/src/Minter/SDK/MinterTx.php +++ b/src/Minter/SDK/MinterTx.php @@ -4,18 +4,31 @@ use InvalidArgumentException; use Minter\Contracts\MinterTxInterface; +use Minter\SDK\MinterCoins\MinterAddLiquidityTx; +use Minter\SDK\MinterCoins\MinterBurnTokenTx; use Minter\SDK\MinterCoins\MinterBuyCoinTx; +use Minter\SDK\MinterCoins\MinterBuySwapPoolTx; +use Minter\SDK\MinterCoins\MinterCreateSwapPoolTx; +use Minter\SDK\MinterCoins\MinterCreateTokenTx; use Minter\SDK\MinterCoins\MinterEditCoinOwnerTx; use Minter\SDK\MinterCoins\MinterCreateCoinTx; use Minter\SDK\MinterCoins\MinterCreateMultisigTx; use Minter\SDK\MinterCoins\MinterDeclareCandidacyTx; use Minter\SDK\MinterCoins\MinterDelegateTx; use Minter\SDK\MinterCoins\MinterEditCandidateTx; +use Minter\SDK\MinterCoins\MinterMintTokenTx; +use Minter\SDK\MinterCoins\MinterMoveStakeTx; use Minter\SDK\MinterCoins\MinterMultiSendTx; +use Minter\SDK\MinterCoins\MinterPriceCommissionTx; +use Minter\SDK\MinterCoins\MinterPriceVoteTx; use Minter\SDK\MinterCoins\MinterRecreateCoinTx; +use Minter\SDK\MinterCoins\MinterRecreateTokenTx; use Minter\SDK\MinterCoins\MinterRedeemCheckTx; +use Minter\SDK\MinterCoins\MinterRemoveLiquidityTx; use Minter\SDK\MinterCoins\MinterSellAllCoinTx; +use Minter\SDK\MinterCoins\MinterSellAllSwapPoolTx; use Minter\SDK\MinterCoins\MinterSellCoinTx; +use Minter\SDK\MinterCoins\MinterSellSwapPoolTx; use Minter\SDK\MinterCoins\MinterSendCoinTx; use Minter\SDK\MinterCoins\MinterSetCandidateOffTx; use Minter\SDK\MinterCoins\MinterSetCandidateOnTx; @@ -350,7 +363,7 @@ public function getSignatureData(): MinterSignature } /** - * @return MinterSendCoinTx|MinterBuyCoinTx|MinterSellCoinTx|MinterSellAllCoinTx|MinterDelegateTx|MinterUnbondTx|MinterMultiSendTx|MinterCreateMultisigTx|MinterCreateCoinTx|MinterRecreateCoinTx|MinterEditCoinOwnerTx|MinterDeclareCandidacyTx|MinterSetCandidateOnTx|MinterSetCandidateOffTx|MinterEditCandidateTx|MinterRedeemCheckTx|MinterSetHaltBlockTx + * @return MinterSendCoinTx|MinterBuyCoinTx|MinterSellCoinTx|MinterSellAllCoinTx|MinterDelegateTx|MinterUnbondTx|MinterMultiSendTx|MinterCreateMultisigTx|MinterCreateCoinTx|MinterRecreateCoinTx|MinterEditCoinOwnerTx|MinterDeclareCandidacyTx|MinterSetCandidateOnTx|MinterSetCandidateOffTx|MinterEditCandidateTx|MinterRedeemCheckTx|MinterSetHaltBlockTx|MinterSellSwapPoolTx|MinterSellAllSwapPoolTx|MinterBuySwapPoolTx|MinterPriceVoteTx|MinterPriceCommissionTx|MinterCreateTokenTx|MinterRecreateTokenTx|MinterCreateSwapPoolTx|MinterBurnTokenTx|MinterMintTokenTx|MinterAddLiquidityTx|MinterMoveStakeTx|MinterRemoveLiquidityTx */ public function getData(): MinterTxInterface { diff --git a/tests/MinterBuySwapPoolTxTest.php b/tests/MinterBuySwapPoolTxTest.php index ddd5306..7840efa 100644 --- a/tests/MinterBuySwapPoolTxTest.php +++ b/tests/MinterBuySwapPoolTxTest.php @@ -20,7 +20,7 @@ final class MinterBuySwapPoolTxTest extends TestCase /** * Predefined valid signature */ - const VALID_SIGNATURE = '0xf8670e0201801897d6018829a2241af62c0000808a010f0cf064dd59200000808001b845f8431ba06f309b5ebb47042147c0e6481e186bdd06d6e883b680c7f282495efb75e83423a076aa9b5da356f9075604c0f6e20ac64832b1df885fdbe28010cc006b38c48d8d'; + const VALID_SIGNATURE = '0xf8680e0201801898d7c202038829a2241af62c00008a010f0cf064dd59200000808001b845f8431ca0d77c1c580754c5143abb5a3ad3f5e892ebd36e7f9f44b7da2734ffff6c2e9611a022034256303ee750a9b32b148e60c6fff34665b5854f1a9770f7ab4a8a26cc00'; /** * Test to decode data for MinterBuySwapPoolTx @@ -34,9 +34,8 @@ public function testDecode(): void $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); $this->assertSame($validTx->getChainID(), $tx->getChainID()); - $this->assertSame($validTx->getData()->coinToBuy, $tx->getData()->coinToBuy); + $this->assertSame($validTx->getData()->coins, $tx->getData()->coins); $this->assertSame($validTx->getData()->valueToBuy, $tx->getData()->valueToBuy); - $this->assertSame($validTx->getData()->coinToSell, $tx->getData()->coinToSell); $this->assertSame($validTx->getData()->maximumValueToSell, $tx->getData()->maximumValueToSell); $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); } @@ -55,7 +54,7 @@ public function testSign(): void */ private function makeTransaction(): MinterTx { - $data = new MinterBuySwapPoolTx(1, '3', 0, '5000'); + $data = new MinterBuySwapPoolTx([2, 3], '3', '5000'); return (new MinterTx(14, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); } } \ No newline at end of file diff --git a/tests/MinterSellAllSwapPoolTxTest.php b/tests/MinterSellAllSwapPoolTxTest.php index 3a4aa47..383393e 100644 --- a/tests/MinterSellAllSwapPoolTxTest.php +++ b/tests/MinterSellAllSwapPoolTxTest.php @@ -20,22 +20,21 @@ class MinterSellAllSwapPoolTxTest extends TestCase /** * Predefined valid signature */ - const VALID_SIGNATURE = '0xf85d10020180198dcc018089056bc75e2d63100000808001b845f8431ca0e50537db70ed7263094cfaee22c69545c0c41e9efedef521c0ecce3a4f33ade6a03e71cde08a52561136584bc14707b3c01e618513b01a96b9865b44ff0395fc7a'; + const VALID_SIGNATURE = '0xf85f10020180198fcec301040589056bc75e2d63100000808001b845f8431ca095651bdd2afa8964213f7bc064898b0edeb67fa39f3a0c71b52934f6463412afa0604ced9ff973bf1de6b252c9582982780cf1de4fd2b2e3814bfa8185d10bd6f5'; /** * Test to decode data for MinterSellAllSwapPoolTx */ public function testDecode(): void { - $tx = MinterTx::decode(self::VALID_SIGNATURE); + $tx = MinterTx::decode(self::VALID_SIGNATURE); $validTx = $this->makeTransaction(); $this->assertSame($validTx->getNonce(), $tx->getNonce()); $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); $this->assertSame($validTx->getChainID(), $tx->getChainID()); - $this->assertSame($validTx->getData()->coinToBuy, $tx->getData()->coinToBuy); - $this->assertSame($validTx->getData()->coinToSell, $tx->getData()->coinToSell); + $this->assertSame($validTx->getData()->coins, $tx->getData()->coins); $this->assertSame($validTx->getData()->minimumValueToBuy, $tx->getData()->minimumValueToBuy); $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); } @@ -54,7 +53,7 @@ public function testSign(): void */ private function makeTransaction(): MinterTx { - $data = new MinterSellAllSwapPoolTx(1, 0, '100'); + $data = new MinterSellAllSwapPoolTx([1, 4, 5], '100'); return (new MinterTx(16, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); } } \ No newline at end of file diff --git a/tests/MinterSellSwapPoolTxTest.php b/tests/MinterSellSwapPoolTxTest.php index 7b59113..128151b 100644 --- a/tests/MinterSellSwapPoolTxTest.php +++ b/tests/MinterSellSwapPoolTxTest.php @@ -20,7 +20,7 @@ final class MinterSellSwapPoolTxTest extends TestCase /** * Predefined valid signature */ - const VALID_SIGNATURE = '0xf866050201801796d5018901158e460913d0000080881bc16d674ec80000808001b845f8431ba09e7c9adca770f8bdb6822d447c656dd0203ae97d0284153be7d6bfc8e07c4456a03cbe6a6db71cecacd5ee149c6c518b0d61b763a9265b5f2847fd150124571ccc'; + const VALID_SIGNATURE = '0xf867050201801797d6c201028901158e460913d00000881bc16d674ec80000808001b845f8431ba01ba1d7c9c05993e6d92d4db8cb24b32c9a28f61286464e41ffcaf86551f97a79a042dcd34363bd981676541b8e8f88b8bbbfcbf0746db2017be73f378afbf045c2'; /** * Test to decode data for MinterSellSwapPoolTx @@ -34,9 +34,8 @@ public function testDecode(): void $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); $this->assertSame($validTx->getChainID(), $tx->getChainID()); - $this->assertSame($validTx->getData()->coinToSell, $tx->getData()->coinToSell); + $this->assertSame($validTx->getData()->coins, $tx->getData()->coins); $this->assertSame($validTx->getData()->valueToSell, $tx->getData()->valueToSell); - $this->assertSame($validTx->getData()->coinToBuy, $tx->getData()->coinToBuy); $this->assertSame($validTx->getData()->minimumValueToBuy, $tx->getData()->minimumValueToBuy); $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); } @@ -55,7 +54,7 @@ public function testSign(): void */ private function makeTransaction(): MinterTx { - $data = new MinterSellSwapPoolTx(1, '20', 0, '2'); + $data = new MinterSellSwapPoolTx([1, 2], '20', '2'); return (new MinterTx(5, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); } } \ No newline at end of file From 0560f06e46e3d3f50f19b2428873a65d1d2ab755 Mon Sep 17 00:00:00 2001 From: Kamil Mukhametzyanov Date: Fri, 5 Mar 2021 10:15:00 +0300 Subject: [PATCH 10/10] remove move stake, price vote --- README.md | 112 +++++++----------- src/Minter/SDK/MinterCoins/MinterCoinTx.php | 2 - .../SDK/MinterCoins/MinterMoveStakeTx.php | 60 ---------- .../MinterCoins/MinterPriceCommissionTx.php | 12 -- .../SDK/MinterCoins/MinterPriceVoteTx.php | 37 ------ src/Minter/SDK/MinterTx.php | 4 +- tests/MinterMoveStakeTxTest.php | 64 ---------- tests/MinterPriceCommissionTxTest.php | 4 +- tests/MinterPriceVoteTxTest.php | 61 ---------- 9 files changed, 43 insertions(+), 313 deletions(-) delete mode 100644 src/Minter/SDK/MinterCoins/MinterMoveStakeTx.php delete mode 100644 src/Minter/SDK/MinterCoins/MinterPriceVoteTx.php delete mode 100644 tests/MinterMoveStakeTxTest.php delete mode 100644 tests/MinterPriceVoteTxTest.php diff --git a/README.md b/README.md index 6d24c3a..7896f1b 100644 --- a/README.md +++ b/README.md @@ -55,21 +55,19 @@ This is a pure PHP SDK for working with Minter blockchain - [RecreateCoin](#example-18) - [EditCoinOwner](#example-19) - [EditMultisig](#example-20) - - [PriceVote](#example-21) - - [EditCandidatePublicKey](#example-22) - - [AddLiquidity](#example-23) - - [RemoveLiquidity](#example-24) - - [SellSwapPool](#example-25) - - [BuySwapPool](#example-26) - - [SellAllSwapPool](#example-27) - - [EditCandidateCommission](#example-28) - - [MoveStake](#example-29) - - [MintToken](#example-30) - - [BurnToken](#example-31) - - [CreateToken](#example-32) - - [RecreateToken](#example-33) - - [PriceCommission](#example-34) - - [CreateSwapPool](#example-35) + - [EditCandidatePublicKey](#example-21) + - [AddLiquidity](#example-22) + - [RemoveLiquidity](#example-23) + - [SellSwapPool](#example-24) + - [BuySwapPool](#example-25) + - [SellAllSwapPool](#example-26) + - [EditCandidateCommission](#example-27) + - [MintToken](#example-28) + - [BurnToken](#example-29) + - [CreateToken](#example-30) + - [RecreateToken](#example-31) + - [PriceCommission](#example-32) + - [CreateSwapPool](#example-33) - [Sign transaction with multisignatures](#sign-transaction-with-multisignatures) - [Get fee of transaction](#get-fee-of-transaction) - [Decode Transaction](#decode-transaction) @@ -405,7 +403,7 @@ use Minter\SDK\MinterCoins\MinterSendCoinTx; $data = new MinterSendCoinTx($coinID, 'Mxfe60014a6e9ac91618f5d1cab3fd58cded61ee99', '10'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` At all type of transactions you can also set optional fields: @@ -421,9 +419,9 @@ $tx = (new MinterTx($nonce, $data)) ->setGasPrice(1) ->setGasCoin(MinterTx::BASE_COIN_ID) ->setPayload('some payload') - ->setServiceData('some data') + ->setServiceData('some data'); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -437,7 +435,7 @@ use Minter\SDK\MinterCoins\MinterSellCoinTx; $data = new MinterSellCoinTx(123, '1', 321, '1'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -451,7 +449,7 @@ use Minter\SDK\MinterCoins\MinterSellAllCoinTx; $data = new MinterSellAllCoinTx(123, 321, '1'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -465,7 +463,7 @@ use Minter\SDK\MinterCoins\MinterBuyCoinTx; $data = new MinterBuyCoinTx(123, '1', 321, '1'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -479,7 +477,7 @@ use Minter\SDK\MinterCoins\MinterCreateCoinTx; $data = new MinterCreateCoinTx('TEST COIN', 'TEST', '10000', '10', 10, '10000'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -497,7 +495,7 @@ $data = new MinterDeclareCandidacyTx( ); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -511,7 +509,7 @@ use Minter\SDK\MinterCoins\MinterDelegateTx; $data = new MinterDelegateTx('Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43', 123, '10000'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -525,7 +523,7 @@ use Minter\SDK\MinterCoins\MinterSetCandidateOnTx; $data = new MinterSetCandidateOnTx('Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -539,7 +537,7 @@ use Minter\SDK\MinterCoins\MinterSetCandidateOffTx; $data = new MinterSetCandidateOffTx('Mp0eb98ea04ae466d8d38f490db3c99b3996a90e24243952ce9822c6dc1e2c1a43'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -553,7 +551,7 @@ use Minter\SDK\MinterCoins\MinterRedeemCheckTx; $data = new MinterRedeemCheckTx('your check', 'created by MinterCheck proof'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -567,7 +565,7 @@ use Minter\SDK\MinterCoins\MinterUnbondTx; $data = new MinterUnbondTx('Mp....', 123, '10000'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -585,7 +583,7 @@ $data = new MinterMultiSendTx([ ]); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -599,7 +597,7 @@ use Minter\SDK\MinterCoins\MinterEditCandidateTx; $data = new MinterEditCandidateTx('candidate public key', 'Minter address for rewards', 'Minter address of owner', 'Minter address for control'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -617,7 +615,7 @@ $data = new MinterCreateMultisigTx(7, [1, 3, 5], [ ]); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -630,7 +628,7 @@ use Minter\SDK\MinterCoins\MinterSetHaltBlockTx; $data = new MinterSetHaltBlockTx('your public key', 236503); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -643,7 +641,7 @@ use Minter\SDK\MinterCoins\MinterRecreateCoinTx; $data = new MinterRecreateCoinTx('TEST', '10000', '10', 10000, 10, '10000'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -656,7 +654,7 @@ use Minter\SDK\MinterCoins\MinterEditCoinOwnerTx; $data = new MinterEditCoinOwnerTx('COINSYMBOL', 'Mxee81347211c72524338f9680072af90744333145'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -669,20 +667,7 @@ use Minter\SDK\MinterCoins\MinterEditMultisigTx; $data = new MinterEditMultisigTx(1, [1, 2], ['Mxee81347211c72524338f9680072af90744333145', 'Mxee81347211c72524338f9680072af90744333146']); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') -``` - -###### Example -* Sign the PriceVote transaction -* Constructor: ```MinterPriceVoteTx($price)``` - -```php -use Minter\SDK\MinterTx; -use Minter\SDK\MinterCoins\MinterPriceVoteTx; - -$data = new MinterPriceVoteTx(1000); -$tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -695,7 +680,7 @@ use Minter\SDK\MinterCoins\MinterEditCandidatePublicKeyTx; $data = new MinterEditCandidatePublicKeyTx('public key', 'new public key....'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -708,7 +693,7 @@ use Minter\SDK\MinterCoins\MinterAddLiquidityTx; $data = new MinterAddLiquidityTx(0, 1, '1000', '2000'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -721,7 +706,7 @@ use Minter\SDK\MinterCoins\MinterRemoveLiquidityTx; $data = new MinterRemoveLiquidityTx(0, 1, '2000', '500', '1000'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -734,7 +719,7 @@ use Minter\SDK\MinterCoins\MinterSellSwapPoolTx; $data = new MinterSellSwapPoolTx(0, '100', 1, '200'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -747,7 +732,7 @@ use Minter\SDK\MinterCoins\MinterBuySwapPoolTx; $data = new MinterBuySwapPoolTx(0, '100', 1, '200'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -760,7 +745,7 @@ use Minter\SDK\MinterCoins\MinterSellAllSwapPoolTx; $data = new MinterSellAllSwapPoolTx(0, 1, '100'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -773,20 +758,7 @@ use Minter\SDK\MinterCoins\MinterEditCandidateCommissionTx; $data = new MinterEditCandidateCommissionTx('public key', 77); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') -``` - -###### Example -* Sign the MoveStake transaction -* Constructor: ```MinterMoveStakeTx($from, $to, $coin, $stake)``` - -```php -use Minter\SDK\MinterTx; -use Minter\SDK\MinterCoins\MinterEditCandidateCommissionTx; - -$data = new MinterEditCandidateCommissionTx('from public key', 'to public key', 1, '3000'); -$tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example @@ -877,13 +849,11 @@ $tx->sign('your private key') $setHaltBlock, $editTickerOwner, $editMultisig, - $priceVote, $editCandidatePublicKey, $createSwapPool, $addLiquidity, $removeLiquidity, $editCandidateCommission, - $moveStake, $burnToken, $mintToken, $voteCommission, @@ -896,7 +866,7 @@ use Minter\SDK\MinterCoins\MinterPriceCommissionTx; $data = new MinterPriceCommissionTx('public key', 100000,0,'1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41'); $tx = new MinterTx($nonce, $data); -$tx->sign('your private key') +$tx->sign('your private key'); ``` ###### Example diff --git a/src/Minter/SDK/MinterCoins/MinterCoinTx.php b/src/Minter/SDK/MinterCoins/MinterCoinTx.php index e9ee258..511e848 100644 --- a/src/Minter/SDK/MinterCoins/MinterCoinTx.php +++ b/src/Minter/SDK/MinterCoins/MinterCoinTx.php @@ -31,7 +31,6 @@ abstract class MinterCoinTx implements MinterTxInterface MinterEditCoinOwnerTx::TYPE => MinterEditCoinOwnerTx::class, MinterSetHaltBlockTx::TYPE => MinterSetHaltBlockTx::class, MinterEditMultisigTx::TYPE => MinterEditMultisigTx::class, - MinterPriceVoteTx::TYPE => MinterPriceVoteTx::class, MinterEditCandidatePublicKeyTx::TYPE => MinterEditCandidatePublicKeyTx::class, MinterAddLiquidityTx::TYPE => MinterAddLiquidityTx::class, MinterRemoveLiquidityTx::TYPE => MinterRemoveLiquidityTx::class, @@ -39,7 +38,6 @@ abstract class MinterCoinTx implements MinterTxInterface MinterBuySwapPoolTx::TYPE => MinterBuySwapPoolTx::class, MinterSellAllSwapPoolTx::TYPE => MinterSellAllSwapPoolTx::class, MinterEditCandidateCommissionTx::TYPE => MinterEditCandidateCommissionTx::class, - MinterMoveStakeTx::TYPE => MinterMoveStakeTx::class, MinterMintTokenTx::TYPE => MinterMintTokenTx::class, MinterBurnTokenTx::TYPE => MinterBurnTokenTx::class, MinterCreateTokenTx::TYPE => MinterCreateTokenTx::class, diff --git a/src/Minter/SDK/MinterCoins/MinterMoveStakeTx.php b/src/Minter/SDK/MinterCoins/MinterMoveStakeTx.php deleted file mode 100644 index 25313f8..0000000 --- a/src/Minter/SDK/MinterCoins/MinterMoveStakeTx.php +++ /dev/null @@ -1,60 +0,0 @@ -from = $from; - $this->to = $to; - $this->coin = $coin; - $this->stake = $stake; - } - - /** - * Prepare data for signing - * - * @return array - */ - public function encodeData(): array - { - return [ - hex2bin(Helper::removePrefix($this->from, MinterPrefix::PUBLIC_KEY)), - hex2bin(Helper::removePrefix($this->to, MinterPrefix::PUBLIC_KEY)), - $this->coin, - MinterConverter::convertToPip($this->stake) - ]; - } - - public function decodeData() - { - $this->from = MinterPrefix::PUBLIC_KEY . $this->from; - $this->to = MinterPrefix::PUBLIC_KEY . $this->to; - $this->coin = hexdec($this->coin); - $this->stake = MinterConverter::convertToBase(Helper::hexDecode($this->stake)); - } -} \ No newline at end of file diff --git a/src/Minter/SDK/MinterCoins/MinterPriceCommissionTx.php b/src/Minter/SDK/MinterCoins/MinterPriceCommissionTx.php index b5ce20a..5eff70e 100644 --- a/src/Minter/SDK/MinterCoins/MinterPriceCommissionTx.php +++ b/src/Minter/SDK/MinterCoins/MinterPriceCommissionTx.php @@ -48,13 +48,11 @@ class MinterPriceCommissionTx extends MinterCoinTx implements MinterTxInterface public $setHaltBlock; public $editTickerOwner; public $editMultisig; - public $priceVote; public $editCandidatePublicKey; public $createSwapPool; public $addLiquidity; public $removeLiquidity; public $editCandidateCommission; - public $moveStake; public $burnToken; public $mintToken; public $voteCommission; @@ -97,13 +95,11 @@ class MinterPriceCommissionTx extends MinterCoinTx implements MinterTxInterface * @param $setHaltBlock * @param $editTickerOwner * @param $editMultisig - * @param $priceVote * @param $editCandidatePublicKey * @param $createSwapPool * @param $addLiquidity * @param $removeLiquidity * @param $editCandidateCommission - * @param $moveStake * @param $burnToken * @param $mintToken * @param $voteCommission @@ -143,13 +139,11 @@ public function __construct( $setHaltBlock, $editTickerOwner, $editMultisig, - $priceVote, $editCandidatePublicKey, $createSwapPool, $addLiquidity, $removeLiquidity, $editCandidateCommission, - $moveStake, $burnToken, $mintToken, $voteCommission, @@ -188,13 +182,11 @@ public function __construct( $this->setHaltBlock = $setHaltBlock; $this->editTickerOwner = $editTickerOwner; $this->editMultisig = $editMultisig; - $this->priceVote = $priceVote; $this->editCandidatePublicKey = $editCandidatePublicKey; $this->createSwapPool = $createSwapPool; $this->addLiquidity = $addLiquidity; $this->removeLiquidity = $removeLiquidity; $this->editCandidateCommission = $editCandidateCommission; - $this->moveStake = $moveStake; $this->burnToken = $burnToken; $this->mintToken = $mintToken; $this->voteCommission = $voteCommission; @@ -242,13 +234,11 @@ function encodeData(): array MinterConverter::convertToPip($this->setHaltBlock), MinterConverter::convertToPip($this->editTickerOwner), MinterConverter::convertToPip($this->editMultisig), - MinterConverter::convertToPip($this->priceVote), MinterConverter::convertToPip($this->editCandidatePublicKey), MinterConverter::convertToPip($this->createSwapPool), MinterConverter::convertToPip($this->addLiquidity), MinterConverter::convertToPip($this->removeLiquidity), MinterConverter::convertToPip($this->editCandidateCommission), - MinterConverter::convertToPip($this->moveStake), MinterConverter::convertToPip($this->burnToken), MinterConverter::convertToPip($this->mintToken), MinterConverter::convertToPip($this->voteCommission), @@ -292,13 +282,11 @@ function decodeData() $this->setHaltBlock = MinterConverter::convertToBase(Helper::hexDecode($this->setHaltBlock)); $this->editTickerOwner = MinterConverter::convertToBase(Helper::hexDecode($this->editTickerOwner)); $this->editMultisig = MinterConverter::convertToBase(Helper::hexDecode($this->editMultisig)); - $this->priceVote = MinterConverter::convertToBase(Helper::hexDecode($this->priceVote)); $this->editCandidatePublicKey = MinterConverter::convertToBase(Helper::hexDecode($this->editCandidatePublicKey)); $this->createSwapPool = MinterConverter::convertToBase(Helper::hexDecode($this->createSwapPool)); $this->addLiquidity = MinterConverter::convertToBase(Helper::hexDecode($this->addLiquidity)); $this->removeLiquidity = MinterConverter::convertToBase(Helper::hexDecode($this->removeLiquidity)); $this->editCandidateCommission = MinterConverter::convertToBase(Helper::hexDecode($this->editCandidateCommission)); - $this->moveStake = MinterConverter::convertToBase(Helper::hexDecode($this->moveStake)); $this->burnToken = MinterConverter::convertToBase(Helper::hexDecode($this->burnToken)); $this->mintToken = MinterConverter::convertToBase(Helper::hexDecode($this->mintToken)); $this->voteCommission = MinterConverter::convertToBase(Helper::hexDecode($this->voteCommission)); diff --git a/src/Minter/SDK/MinterCoins/MinterPriceVoteTx.php b/src/Minter/SDK/MinterCoins/MinterPriceVoteTx.php deleted file mode 100644 index a323bd6..0000000 --- a/src/Minter/SDK/MinterCoins/MinterPriceVoteTx.php +++ /dev/null @@ -1,37 +0,0 @@ -price = $price; - } - - public function encodeData(): array - { - return [ - $this->price, - ]; - } - - public function decodeData() - { - $this->price = hexdec($this->price); - } -} \ No newline at end of file diff --git a/src/Minter/SDK/MinterTx.php b/src/Minter/SDK/MinterTx.php index 16427ef..b50faaf 100644 --- a/src/Minter/SDK/MinterTx.php +++ b/src/Minter/SDK/MinterTx.php @@ -17,10 +17,8 @@ use Minter\SDK\MinterCoins\MinterDelegateTx; use Minter\SDK\MinterCoins\MinterEditCandidateTx; use Minter\SDK\MinterCoins\MinterMintTokenTx; -use Minter\SDK\MinterCoins\MinterMoveStakeTx; use Minter\SDK\MinterCoins\MinterMultiSendTx; use Minter\SDK\MinterCoins\MinterPriceCommissionTx; -use Minter\SDK\MinterCoins\MinterPriceVoteTx; use Minter\SDK\MinterCoins\MinterRecreateCoinTx; use Minter\SDK\MinterCoins\MinterRecreateTokenTx; use Minter\SDK\MinterCoins\MinterRedeemCheckTx; @@ -363,7 +361,7 @@ public function getSignatureData(): MinterSignature } /** - * @return MinterSendCoinTx|MinterBuyCoinTx|MinterSellCoinTx|MinterSellAllCoinTx|MinterDelegateTx|MinterUnbondTx|MinterMultiSendTx|MinterCreateMultisigTx|MinterCreateCoinTx|MinterRecreateCoinTx|MinterEditCoinOwnerTx|MinterDeclareCandidacyTx|MinterSetCandidateOnTx|MinterSetCandidateOffTx|MinterEditCandidateTx|MinterRedeemCheckTx|MinterSetHaltBlockTx|MinterSellSwapPoolTx|MinterSellAllSwapPoolTx|MinterBuySwapPoolTx|MinterPriceVoteTx|MinterPriceCommissionTx|MinterCreateTokenTx|MinterRecreateTokenTx|MinterCreateSwapPoolTx|MinterBurnTokenTx|MinterMintTokenTx|MinterAddLiquidityTx|MinterMoveStakeTx|MinterRemoveLiquidityTx + * @return MinterSendCoinTx|MinterBuyCoinTx|MinterSellCoinTx|MinterSellAllCoinTx|MinterDelegateTx|MinterUnbondTx|MinterMultiSendTx|MinterCreateMultisigTx|MinterCreateCoinTx|MinterRecreateCoinTx|MinterEditCoinOwnerTx|MinterDeclareCandidacyTx|MinterSetCandidateOnTx|MinterSetCandidateOffTx|MinterEditCandidateTx|MinterRedeemCheckTx|MinterSetHaltBlockTx|MinterSellSwapPoolTx|MinterSellAllSwapPoolTx|MinterBuySwapPoolTx|MinterPriceCommissionTx|MinterCreateTokenTx|MinterRecreateTokenTx|MinterCreateSwapPoolTx|MinterBurnTokenTx|MinterMintTokenTx|MinterAddLiquidityTx|MinterRemoveLiquidityTx */ public function getData(): MinterTxInterface { diff --git a/tests/MinterMoveStakeTxTest.php b/tests/MinterMoveStakeTxTest.php deleted file mode 100644 index 7c25479..0000000 --- a/tests/MinterMoveStakeTxTest.php +++ /dev/null @@ -1,64 +0,0 @@ -makeTransaction(); - - $this->assertSame($validTx->getNonce(), $tx->getNonce()); - $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); - $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); - $this->assertSame($validTx->getChainID(), $tx->getChainID()); - $this->assertSame($validTx->getData()->from, $tx->getData()->from); - $this->assertSame($validTx->getData()->to, $tx->getData()->to); - $this->assertSame($validTx->getData()->coin, $tx->getData()->coin); - $this->assertSame($validTx->getData()->stake, $tx->getData()->stake); - $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); - } - - /** - * Test signing MinterMoveStakeTx - */ - public function testSign(): void - { - $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); - $this->assertSame($signature, self::VALID_SIGNATURE); - } - - /** - * @return MinterTx - */ - private function makeTransaction(): MinterTx - { - $data = new MinterMoveStakeTx('Mp325580a8baed04899252ae5b5f6167ee34ec0144f3401d88586b350999999999','Mp325580a8baed04899252ae5b5f6167ee34ec0144f3401d88586b350a380bc7d4',0,'5000'); - return (new MinterTx(20, $data))->setChainID(MinterTx::TESTNET_CHAIN_ID); - } -} diff --git a/tests/MinterPriceCommissionTxTest.php b/tests/MinterPriceCommissionTxTest.php index f726f72..af01436 100644 --- a/tests/MinterPriceCommissionTxTest.php +++ b/tests/MinterPriceCommissionTxTest.php @@ -23,7 +23,7 @@ final class MinterPriceCommissionTxTest extends TestCase /** * Predefined valid signature */ - const VALID_SIGNATURE = '0xf902031f02018020b901b1f901aea0325580a8baed04899252ae5b5f6167ee34ec0144f3401d88586b350999999999830186a080880de0b6b3a7640000881bc16d674ec800008829a2241af62c0000883782dace9d900000884563918244f400008853444835ec580000886124fee993bc0000886f05b59d3b200000887ce66c50e2840000888ac7230489e800008898a7d9b8314c000088a688906bd8b0000088b469471f8014000088c249fdd32778000088d02ab486cedc000088de0b6b3a7640000088ebec21ee1da4000088f9ccd8a1c5080000890107ad8f556c6c00008901158e460913d000008901236efcbcbb3400008901314fb3706298000089013f306a2409fc000089014d1120d7b160000089015af1d78b58c40000890168d28e3f00280000890176b344f2a78c000089018493fba64ef0000089019274b259f65400008901a055690d9db800008901ae361fc1451c00008901bc16d674ec8000008901c9f78d2893e400008901d7d843dc3b4800008901e5b8fa8fe2ac00008901f399b1438a1000008902017a67f73174000089020f5b1eaad8d8000089021d3bd55e803c000089022b1c8c1227a00000890238fd42c5cf040000808001b845f8431ca013b5fc16f4bd45cc6c58b634954977e4a73c9f3d3c864835dfb6f4eaea2e7db7a014afd6498dea11cc4ac0471b738bf608bb72d10c27500730e1258f345c8373d9'; + const VALID_SIGNATURE = '0xf901ef1f02018020b9019df9019aa0325580a8baed04899252ae5b5f6167ee34ec0144f3401d88586b350999999999830186a080880de0b6b3a7640000881bc16d674ec800008829a2241af62c0000883782dace9d900000884563918244f400008853444835ec580000886124fee993bc0000886f05b59d3b200000887ce66c50e2840000888ac7230489e800008898a7d9b8314c000088a688906bd8b0000088b469471f8014000088c249fdd32778000088d02ab486cedc000088de0b6b3a7640000088ebec21ee1da4000088f9ccd8a1c5080000890107ad8f556c6c00008901158e460913d000008901236efcbcbb3400008901314fb3706298000089013f306a2409fc000089014d1120d7b160000089015af1d78b58c40000890168d28e3f00280000890176b344f2a78c000089018493fba64ef0000089019274b259f65400008901a055690d9db800008901ae361fc1451c00008901bc16d674ec8000008901c9f78d2893e400008901d7d843dc3b4800008901e5b8fa8fe2ac00008901f399b1438a1000008902017a67f73174000089020f5b1eaad8d8000089021d3bd55e803c0000808001b845f8431ba01a4a00cbaf631afe162117702c05e9ad2e342970064671a44ce3b4cc51647dada079beab994992431c341a12dfe63f8e13edf70d472427f02ca03b15f742a87df9'; /** * Test to decode data for MinterPriceCommissionTx @@ -70,13 +70,11 @@ public function testDecode(): void $this->assertSame($validTx->getData()->setHaltBlock, $tx->getData()->setHaltBlock); $this->assertSame($validTx->getData()->editTickerOwner, $tx->getData()->editTickerOwner); $this->assertSame($validTx->getData()->editMultisig, $tx->getData()->editMultisig); - $this->assertSame($validTx->getData()->priceVote, $tx->getData()->priceVote); $this->assertSame($validTx->getData()->editCandidatePublicKey, $tx->getData()->editCandidatePublicKey); $this->assertSame($validTx->getData()->createSwapPool, $tx->getData()->createSwapPool); $this->assertSame($validTx->getData()->addLiquidity, $tx->getData()->addLiquidity); $this->assertSame($validTx->getData()->removeLiquidity, $tx->getData()->removeLiquidity); $this->assertSame($validTx->getData()->editCandidateCommission, $tx->getData()->editCandidateCommission); - $this->assertSame($validTx->getData()->moveStake, $tx->getData()->moveStake); $this->assertSame($validTx->getData()->burnToken, $tx->getData()->burnToken); $this->assertSame($validTx->getData()->mintToken, $tx->getData()->mintToken); $this->assertSame($validTx->getData()->voteCommission, $tx->getData()->voteCommission); diff --git a/tests/MinterPriceVoteTxTest.php b/tests/MinterPriceVoteTxTest.php deleted file mode 100644 index 6d92a9c..0000000 --- a/tests/MinterPriceVoteTxTest.php +++ /dev/null @@ -1,61 +0,0 @@ -makeTransaction(); - - $this->assertSame($validTx->getNonce(), $tx->getNonce()); - $this->assertSame($validTx->getGasCoin(), $tx->getGasCoin()); - $this->assertSame($validTx->getGasPrice(), $tx->getGasPrice()); - $this->assertSame($validTx->getChainID(), $tx->getChainID()); - $this->assertSame($validTx->getData()->price, $tx->getData()->price); - $this->assertSame(self::MINTER_ADDRESS, $tx->getSenderAddress()); - } - - /** - * Test signing MinterEditCoinOwnerTx - */ - public function testSign(): void - { - $signature = $this->makeTransaction()->sign(self::PRIVATE_KEY); - $this->assertSame($signature, self::VALID_SIGNATURE); - } - - /** - * @return MinterTx - */ - private function makeTransaction(): MinterTx - { - $data = new MinterPriceVoteTx(10000); - return new MinterTx(10, $data); - } -}