/**
  * @param Wallet $wallet
  * @param Address[] $addresses
  * @param BlockCypherAddressBalance[] $blockCypherAddressBalances
  * @param ApiRouter $apiRouter
  * @param ExplorerRouter $explorerRouter
  * @return AddressListItemDto
  */
 public static function from($wallet, $addresses, $blockCypherAddressBalances, $apiRouter, $explorerRouter)
 {
     $addressListItemDtos = array();
     foreach ($addresses as $address) {
         $addressListItemDto = AddressListItemDto::from($address, $blockCypherAddressBalances[$address->getAddress()], $apiRouter->address($address->getAddress(), $wallet->getCoinSymbol(), $wallet->getToken()), $explorerRouter->address($address->getAddress(), $wallet->getCoinSymbol()));
         $addressListItemDtos[] = $addressListItemDto;
     }
     return $addressListItemDtos;
 }
 /**
  * @param Wallet $wallet
  * @param BigMoney|null $balance
  * @param $apiUrl
  * @return WalletListItemDto
  */
 public static function from(Wallet $wallet, BigMoney $balance, $apiUrl)
 {
     $walletListItemDto = new self();
     $walletListItemDto->setId($wallet->getId()->getValue());
     $walletListItemDto->setCoinSymbol($wallet->getCoinSymbol());
     $walletListItemDto->setCreationTime($wallet->getCreationTime());
     $walletListItemDto->setName($wallet->getName());
     if ($balance !== null) {
         $walletListItemDto->setBalance((double) (string) $balance->getAmount());
     } else {
         $walletListItemDto->setBalance(-1);
     }
     $walletListItemDto->setApiUrl($apiUrl);
     return $walletListItemDto;
 }
Example #3
0
 /**
  * @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[] $transactions
  * @param TransactionListItem[] $transactionListItems
  * @param ApiRouter $apiRouter
  * @param ExplorerRouter $explorerRouter
  * @return TransactionListItemDto[]
  */
 public static function from(Wallet $wallet, $transactions, $transactionListItems, ApiRouter $apiRouter, ExplorerRouter $explorerRouter)
 {
     // DEBUG
     //var_dump($transactionListItems);
     //die();
     $transactionListItemDtos = array();
     foreach ($transactionListItems as $transactionListItem) {
         $txHash = $transactionListItem->getTxHash();
         if (isset($transactions[$txHash])) {
             $transaction = $transactions[$txHash];
         } else {
             $transaction = null;
         }
         $transactionListItemDto = TransactionListItemDto::from($transaction, $transactionListItem, $apiRouter->transaction($txHash, $wallet->getCoinSymbol(), $wallet->getToken()), $explorerRouter->transaction($txHash, $wallet->getCoinSymbol(), $wallet->getToken()));
         $transactionListItemDtos[] = $transactionListItemDto;
     }
     // DEBUG
     //var_dump($transactionListItemDtos);
     //die();
     return $transactionListItemDtos;
 }
 /**
  * @param Wallet $wallet
  * @throws \Exception
  */
 public function delete(Wallet $wallet)
 {
     $this->encryptedWalletRepository->delete($wallet->encryptUsing($this->encryptor));
 }
 /**
  * @param Crawler $crawler
  */
 private function assertWalletListIsShown($crawler)
 {
     $walletId = $this->wallet->getId()->getValue();
     $this->assertTrue($crawler->filter('html:contains("' . $walletId . '")')->count() > 0);
 }
 /**
  * @param Wallet $wallet
  * @return BlockCypherAddress
  */
 private function getBlockCypherAddress(Wallet $wallet)
 {
     $blockCypherAddress = null;
     $blockCypherAddress = $this->blockCypherAddressService->getAddress($wallet->getId()->getValue(), $wallet->getCoinSymbol(), $wallet->getToken());
     return $blockCypherAddress;
 }