/** * @param Wallet $wallet * @param BlockCypherAddress $blockCypherAddress * @return WalletDto */ public static function from(Wallet $wallet, BlockCypherAddress $blockCypherAddress) { $walletDto = new WalletDto(); // From Wallet $walletDto->setUserId($wallet->getUserId()->getValue()); $walletDto->setName($wallet->getName()); // From BlockCypherAddress $walletDto->setId($blockCypherAddress->getWallet()->getName()); $walletDto->setTotalSent($blockCypherAddress->getTotalSent()); $walletDto->setTotalReceived($blockCypherAddress->getTotalReceived()); $walletDto->setUnconfirmedBalance($blockCypherAddress->getUnconfirmedBalance()); $walletDto->setBalance($blockCypherAddress->getBalance()); $walletDto->setFinalBalance($blockCypherAddress->getFinalBalance()); $walletDto->setNTx($blockCypherAddress->getNTx()); $walletDto->setUnconfirmedNTx($blockCypherAddress->getUnconfirmedNTx()); $walletDto->setFinalNTx($blockCypherAddress->getFinalNTx()); return $walletDto; }
/** * @param Wallet $wallet * @param Transaction[]|null $transactions * @param BlockCypherAddress $blockCypherAddress * @param ApiRouter $apiRouter * @param ExplorerRouter $explorerRouter * @return TransactionListDto */ public static function from(Wallet $wallet, $transactions, BlockCypherAddress $blockCypherAddress, ApiRouter $apiRouter, ExplorerRouter $explorerRouter) { $transactionListDto = new self(); // From BlockCypher Address $transactionListDto->setTotalSent($blockCypherAddress->getTotalSent()); $transactionListDto->setTotalReceived($blockCypherAddress->getTotalReceived()); $transactionListDto->setUnconfirmedBalance($blockCypherAddress->getUnconfirmedBalance()); $transactionListDto->setBalance($blockCypherAddress->getBalance()); $transactionListDto->setFinalBalance($blockCypherAddress->getFinalBalance()); $transactionListDto->setNTx($blockCypherAddress->getNTx()); $transactionListDto->setUnconfirmedNTx($blockCypherAddress->getUnconfirmedNTx()); $transactionListDto->setFinalNTx($blockCypherAddress->getFinalNTx()); $blockCypherTXRefs = $blockCypherAddress->getAllTxrefs(); // Confirmed and unconfirmed $transactionListItems = TransactionListItemArray::from($blockCypherTXRefs); $transactionListItemDtos = TransactionListItemDtoArray::from($wallet, $transactions, $transactionListItems, $apiRouter, $explorerRouter); $transactionListDto->setTransactionListItemDtos($transactionListItemDtos); return $transactionListDto; }
/** * @depends testSerializationDeserialization * @param Address $obj */ public function testGetters($obj) { $this->assertEquals($obj->getAddress(), "1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD"); $this->assertEquals($obj->getTotalReceived(), 4433416); $this->assertEquals($obj->getTotalSent(), 0); $this->assertEquals($obj->getBalance(), 4433416); $this->assertEquals($obj->getUnconfirmedBalance(), 0); $this->assertEquals($obj->getFinalBalance(), 4433416); $this->assertEquals($obj->getNTx(), 7); $this->assertEquals($obj->getUnconfirmedNTx(), 0); $this->assertEquals($obj->getFinalNTx(), 7); $this->assertEquals($obj->getTxrefs(), array(TXRefTest::getObject())); $this->assertEquals($obj->getUnconfirmedTxrefs(), array(TXRefTest::getObject())); $this->assertEquals($obj->getTxUrl(), "https://api.blockcypher.com/v1/btc/main/txs/"); // Calculate properties $this->assertEquals($obj->getAllTxrefs(), array(TXRefTest::getObject(), TXRefTest::getObject())); }