Skip to content

Commit 97930bd

Browse files
committed
1333 - add new AddressDetail table for TxOut
1 parent 6883a93 commit 97930bd

File tree

26 files changed

+380
-127
lines changed

26 files changed

+380
-127
lines changed

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Alonzo/Config.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ insertConfig = do
3434
, sioPoolStats = PoolStatsConfig False
3535
, sioJsonType = JsonTypeDisable
3636
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
37+
, sioAddressDetail = AddressDetailConfig False
3738
}
3839

3940
dncInsertOptions cfg @?= expected

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Alonzo/Plutus.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ simpleScript =
9595
testLabel = "simpleScript-alonzo"
9696
getOutFields txOut = (DB.txOutAddress txOut, DB.txOutAddressHasScript txOut, DB.txOutValue txOut, DB.txOutDataHash txOut)
9797
expectedFields =
98-
( renderAddress alwaysSucceedsScriptAddr
98+
( Just $ renderAddress alwaysSucceedsScriptAddr
9999
, True
100100
, DB.DbLovelace 20000
101101
, Just $ Crypto.hashToBytes (extractHash $ hashData @StandardAlonzo plutusDataList)

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage/Config/Parse.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ insertConfig = do
3434
, sioPoolStats = PoolStatsConfig False
3535
, sioJsonType = JsonTypeDisable
3636
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
37+
, sioAddressDetail = AddressDetailConfig False
3738
}
3839

3940
dncInsertOptions cfg @?= expected

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Babbage/Plutus.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ simpleScript =
102102
testLabel = "simpleScript"
103103
getOutFields txOut = (DB.txOutAddress txOut, DB.txOutAddressHasScript txOut, DB.txOutValue txOut, DB.txOutDataHash txOut)
104104
expectedFields =
105-
( renderAddress alwaysSucceedsScriptAddr
105+
( Just $ renderAddress alwaysSucceedsScriptAddr
106106
, True
107107
, DB.DbLovelace 20000
108108
, Just $ Crypto.hashToBytes (extractHash $ hashData @StandardBabbage plutusDataList)

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Config/Parse.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ insertConfig = do
104104
, sioPoolStats = PoolStatsConfig False
105105
, sioJsonType = JsonTypeDisable
106106
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
107+
, sioAddressDetail = AddressDetailConfig False
107108
}
108109

109110
dncInsertOptions cfg @?= expected

cardano-chain-gen/test/Test/Cardano/Db/Mock/Unit/Conway/Plutus.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ simpleScript =
9090
, DB.txOutDataHash txOut
9191
)
9292
expectedFields =
93-
( renderAddress Examples.alwaysSucceedsScriptAddr
93+
( Just $ renderAddress Examples.alwaysSucceedsScriptAddr
9494
, True
9595
, DB.DbLovelace 20_000
9696
, Just $

cardano-chain-gen/test/Test/Cardano/Db/Mock/Validate.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ module Test.Cardano.Db.Mock.Validate (
4444

4545
import Cardano.Db
4646
import qualified Cardano.Db as DB
47-
import qualified Cardano.DbSync.Era.Shelley.Generic as Generic
4847
import Cardano.DbSync.Era.Shelley.Generic.Util
4948
import qualified Cardano.Ledger.Address as Ledger
5049
import Cardano.Ledger.BaseTypes
@@ -212,7 +211,7 @@ assertAddrValues ::
212211
IO ()
213212
assertAddrValues env ix expected sta = do
214213
addr <- assertRight $ resolveAddress ix sta
215-
let address = Generic.renderAddress addr
214+
let address = Ledger.serialiseAddr addr
216215
q = queryAddressOutputs address
217216
assertEqBackoff env q expected defaultDelays "Unexpected Balance"
218217

cardano-db-sync/src/Cardano/DbSync.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ extractSyncOptions snp aop snc =
278278
, ioPoolStats = isPoolStatsEnabled (sioPoolStats (dncInsertOptions snc))
279279
, ioGov = useGovernance
280280
, ioRemoveJsonbFromSchema = isRemoveJsonbFromSchemaEnabled (sioRemoveJsonbFromSchema (dncInsertOptions snc))
281+
, ioAddressDetail = useAddressDetailTable (sioAddressDetail (dncInsertOptions snc))
281282
}
282283

283284
useLedger = sioLedger (dncInsertOptions snc) == LedgerEnable

cardano-db-sync/src/Cardano/DbSync/Api/Types.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ data InsertOptions = InsertOptions
8787
, ioPoolStats :: !Bool
8888
, ioGov :: !Bool
8989
, ioRemoveJsonbFromSchema :: !Bool
90+
, ioAddressDetail :: !Bool
9091
}
9192
deriving (Show)
9293

cardano-db-sync/src/Cardano/DbSync/Config/Types.hs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module Cardano.DbSync.Config.Types (
1919
GenesisHashAlonzo (..),
2020
GenesisHashConway (..),
2121
RemoveJsonbFromSchemaConfig (..),
22+
AddressDetailConfig (..),
2223
SyncNodeConfig (..),
2324
SyncPreConfig (..),
2425
SyncInsertConfig (..),
@@ -183,6 +184,7 @@ data SyncInsertOptions = SyncInsertOptions
183184
, sioPoolStats :: PoolStatsConfig
184185
, sioJsonType :: JsonTypeConfig
185186
, sioRemoveJsonbFromSchema :: RemoveJsonbFromSchemaConfig
187+
, sioAddressDetail :: AddressDetailConfig
186188
}
187189
deriving (Eq, Show)
188190

@@ -257,6 +259,11 @@ newtype RemoveJsonbFromSchemaConfig = RemoveJsonbFromSchemaConfig
257259
}
258260
deriving (Eq, Show)
259261

262+
newtype AddressDetailConfig = AddressDetailConfig
263+
{ useAddressDetailTable :: Bool
264+
}
265+
deriving (Eq, Show)
266+
260267
data JsonTypeConfig
261268
= JsonTypeText
262269
| JsonTypeJsonb
@@ -439,6 +446,7 @@ parseOverrides obj baseOptions = do
439446
<*> obj .:? "pool_stats" .!= sioPoolStats baseOptions
440447
<*> obj .:? "json_type" .!= sioJsonType baseOptions
441448
<*> obj .:? "remove_jsonb_from_schema" .!= sioRemoveJsonbFromSchema baseOptions
449+
<*> obj .:? "use_address_table" .!= sioAddressDetail baseOptions
442450

443451
instance ToJSON SyncInsertConfig where
444452
toJSON (SyncInsertConfig preset options) =
@@ -481,6 +489,7 @@ instance FromJSON SyncInsertOptions where
481489
<*> obj .:? "pool_stat" .!= sioPoolStats def
482490
<*> obj .:? "json_type" .!= sioJsonType def
483491
<*> obj .:? "remove_jsonb_from_schema" .!= sioRemoveJsonbFromSchema def
492+
<*> obj .:? "use_address_table" .!= sioAddressDetail def
484493

485494
instance ToJSON SyncInsertOptions where
486495
toJSON SyncInsertOptions {..} =
@@ -671,6 +680,15 @@ instance FromJSON RemoveJsonbFromSchemaConfig where
671680
instance ToJSON RemoveJsonbFromSchemaConfig where
672681
toJSON = boolToEnableDisable . isRemoveJsonbFromSchemaEnabled
673682

683+
instance FromJSON AddressDetailConfig where
684+
parseJSON = Aeson.withText "use_address_table" $ \v ->
685+
case enableDisableToBool v of
686+
Just g -> pure (AddressDetailConfig g)
687+
Nothing -> fail $ "unexpected use_address_table: " <> show v
688+
689+
instance ToJSON AddressDetailConfig where
690+
toJSON = boolToEnableDisable . useAddressDetailTable
691+
674692
instance FromJSON OffchainPoolDataConfig where
675693
parseJSON = Aeson.withText "offchain_pool_data" $ \v ->
676694
case enableDisableToBool v of
@@ -708,6 +726,7 @@ instance Default SyncInsertOptions where
708726
, sioPoolStats = PoolStatsConfig False
709727
, sioJsonType = JsonTypeText
710728
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
729+
, sioAddressDetail = AddressDetailConfig False
711730
}
712731

713732
fullInsertOptions :: SyncInsertOptions
@@ -726,6 +745,7 @@ fullInsertOptions =
726745
, sioPoolStats = PoolStatsConfig True
727746
, sioJsonType = JsonTypeText
728747
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
748+
, sioAddressDetail = AddressDetailConfig False
729749
}
730750

731751
onlyUTxOInsertOptions :: SyncInsertOptions
@@ -744,6 +764,7 @@ onlyUTxOInsertOptions =
744764
, sioPoolStats = PoolStatsConfig False
745765
, sioJsonType = JsonTypeText
746766
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
767+
, sioAddressDetail = AddressDetailConfig False
747768
}
748769

749770
onlyGovInsertOptions :: SyncInsertOptions
@@ -770,6 +791,7 @@ disableAllInsertOptions =
770791
, sioGovernance = GovernanceConfig False
771792
, sioJsonType = JsonTypeText
772793
, sioRemoveJsonbFromSchema = RemoveJsonbFromSchemaConfig False
794+
, sioAddressDetail = AddressDetailConfig False
773795
}
774796

775797
boolToEnableDisable :: IsString s => Bool -> s

0 commit comments

Comments
 (0)