Skip to content

Commit

Permalink
Only Coin amounts in TxMeta
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jan 18, 2021
1 parent 060b6bb commit c5bf774
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Expand Up @@ -2071,10 +2071,10 @@ mkApiTransaction ti txid mfee ins outs ws (meta, timestamp) txMeta setTimeRefere
tx :: ApiTransaction n
tx = ApiTransaction
{ id = ApiT txid
, amount = Quantity . fromIntegral $ meta ^. #amount . #coin . #unCoin
, amount = Quantity . fromIntegral $ meta ^. #amount . #unCoin
, fee = maybe (Quantity 0) (Quantity . fromIntegral . unCoin) mfee
, deposit = Quantity depositIfAny
, assets = ApiT (meta ^. #amount . #tokens)
, assets = ApiT mempty
, insertedAt = Nothing
, pendingSince = Nothing
, expiresAt = Nothing
Expand Down
7 changes: 2 additions & 5 deletions lib/core/src/Cardano/Wallet/DB/Sqlite.hs
Expand Up @@ -1648,8 +1648,7 @@ mkTxMetaEntity wid txid mfee meta derived = TxMeta
, txMetaDirection = derived ^. #direction
, txMetaSlot = derived ^. #slotNo
, txMetaBlockHeight = getQuantity (derived ^. #blockHeight)
-- fixme: ADP-347 assets too
, txMetaAmount = fromIntegral $ W.unCoin (derived ^. #amount . #coin)
, txMetaAmount = derived ^. #amount
, txMetaFee = fromIntegral . W.unCoin <$> mfee
, txMetaSlotExpires = derived ^. #expiry
, txMetadata = meta
Expand Down Expand Up @@ -1725,9 +1724,7 @@ txHistoryFromEntity ti tip metas ins outs ws =
, W.direction = txMetaDirection m
, W.slotNo = txMetaSlot m
, W.blockHeight = Quantity (txMetaBlockHeight m)
-- TODO: ADP-347 assets too
, W.amount = TokenBundle.TokenBundle
(W.Coin $ fromIntegral $ txMetaAmount m) mempty
, W.amount = txMetaAmount m
, W.expiry = txMetaSlotExpires m
}

Expand Down
4 changes: 1 addition & 3 deletions lib/core/src/Cardano/Wallet/Primitive/Model.hs
Expand Up @@ -67,8 +67,6 @@ import Cardano.Wallet.Primitive.Types.Coin
( Coin (..) )
import Cardano.Wallet.Primitive.Types.RewardAccount
( RewardAccount (..) )
import Cardano.Wallet.Primitive.Types.TokenBundle
( TokenBundle (..) )
import Cardano.Wallet.Primitive.Types.Tx
( Direction (..)
, Tx (..)
Expand Down Expand Up @@ -380,7 +378,7 @@ prefilterBlock b u0 = runState $ do
, blockHeight = b ^. #header . #blockHeight
-- fixme: ADP-347
-- fixme: why on earth do we have both Coin and Quantity "lovelace" Natural?
, amount = TokenBundle (Coin $ fromIntegral amt) mempty
, amount = Coin (fromIntegral amt)
, expiry = Nothing
}
applyTx
Expand Down
4 changes: 1 addition & 3 deletions lib/core/src/Cardano/Wallet/Primitive/Types/Tx.hs
Expand Up @@ -286,10 +286,8 @@ data TxMeta = TxMeta
instance NFData TxMeta

instance Buildable TxMeta where
build (TxMeta s d sl (Quantity bh) (TokenBundle c a) mex) = mempty
build (TxMeta s d sl (Quantity bh) c mex) = mempty
<> build (WithDirection d c)
<> " assets "
<> build (WithDirection d (TokenMap.Nested a)) -- fixme: formatting
<> " " <> build s
<> " since " <> build sl <> "#" <> build bh
<> maybe mempty (\ex -> " (expires slot " <> build ex <> ")") mex
Expand Down

0 comments on commit c5bf774

Please sign in to comment.