コード例 #1
0
 /**
  * @param string $walletId
  * @return WalletDto|null
  */
 public function getWallet($walletId)
 {
     $wallet = $this->walletService->getWallet(new WalletId($walletId));
     $blockCypherAddress = null;
     $blockCypherAddress = $this->blockCypherAddressService->getAddress($wallet->getId()->getValue(), $wallet->getCoinSymbol(), $wallet->getToken());
     if ($blockCypherAddress === null) {
         return null;
     }
     return WalletDto::from($wallet, $blockCypherAddress);
 }
コード例 #2
0
 /**
  * @param WalletDto $walletDto
  */
 protected function checkAuthorizationForWallet(WalletDto $walletDto)
 {
     $token = $this->tokenStorage->getToken();
     if (!$token) {
         throw $this->createAccessDeniedException();
     }
     /** @var User $user */
     $user = $token->getUser();
     if (!$user) {
         throw $this->createAccessDeniedException();
     }
     // Is the user the owner of this wallet?
     if (!$user->getId()->equals(new UserId($walletDto->getUserId()))) {
         throw $this->createAccessDeniedException();
     }
 }
コード例 #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;
 }