Skip to content

remove t0 from reserve immutable settings in onchain code #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changes/unreleased/Removed-20250124-094950.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Removed
body: t0 field from reserve immutable settings smart-contract
time: 2025-01-24T09:49:50.092863529+01:00
12 changes: 4 additions & 8 deletions onchain/src/TrustlessSidechain/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import PlutusLedgerApi.V1.Value (AssetClass)
import PlutusLedgerApi.V2 (
BuiltinData (BuiltinData),
CurrencySymbol,
POSIXTime,
)
import PlutusTx (makeIsDataIndexed)
import PlutusTx qualified
Expand Down Expand Up @@ -122,9 +121,7 @@ instance UnsafeFromData PermissionedCandidatesValidatorRedeemer where
_ -> error ()

data ImmutableReserveSettings = ImmutableReserveSettings
{ t0 :: POSIXTime
-- ^ `t0` is a POSIX time of a reserve UTxO initialization
, tokenKind :: AssetClass
{ tokenKind :: AssetClass
-- ^ `tokenKind` is an asset class of tokens that a reserve
-- UTxO is allowed to store
}
Expand All @@ -135,16 +132,15 @@ data ImmutableReserveSettings = ImmutableReserveSettings

instance ToData ImmutableReserveSettings where
{-# INLINEABLE toBuiltinData #-}
toBuiltinData (ImmutableReserveSettings s a) =
productToData2 s a
toBuiltinData (ImmutableReserveSettings a) = toBuiltinData a

instance FromData ImmutableReserveSettings where
{-# INLINEABLE fromBuiltinData #-}
fromBuiltinData = productFromData2 ImmutableReserveSettings
fromBuiltinData x = ImmutableReserveSettings <$> fromBuiltinData x

instance UnsafeFromData ImmutableReserveSettings where
{-# INLINEABLE unsafeFromBuiltinData #-}
unsafeFromBuiltinData = productUnsafeFromData2 ImmutableReserveSettings
unsafeFromBuiltinData = ImmutableReserveSettings . unsafeFromBuiltinData

makeHasField ''ImmutableReserveSettings

Expand Down
4 changes: 2 additions & 2 deletions onchain/test/Test/TrustlessSidechain/Golden/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Test.TrustlessSidechain.Golden.Types (tests) where
import TrustlessSidechain.HaskellPrelude

import PlutusLedgerApi.V1.Value qualified as Value
import PlutusLedgerApi.V2 (POSIXTime (..), toBuiltinData)
import PlutusLedgerApi.V2 (toBuiltinData)
import Test.Tasty (TestTree, testGroup)
import Test.TrustlessSidechain.GoldenTest (dataEncoderGoldenTest)
import TrustlessSidechain.Governance.MultiSig (
Expand Down Expand Up @@ -43,6 +43,7 @@ import TrustlessSidechain.Types (
-- Some of the data types are only checked transitively (included by some other type)
--
-- In order to regenerate golden tests files, simply delete the old ones in `./test/golden`
-- or run: cabal test trustless-sidechain-test --test-options "--accept"
tests :: TestTree
tests =
testGroup
Expand Down Expand Up @@ -82,7 +83,6 @@ sampleReserveDatum =
ReserveDatum
{ immutableSettings =
ImmutableReserveSettings
(POSIXTime 1234513245)
(Value.AssetClass ("0281158622b7d2eb738b885e1cca50218fb36ab4dc39014b83286b8ed95c78789d", "asdf"))
, mutableSettings =
MutableReserveSettings "726551f3f61ebd8f53198f7c137c646ae0bd57fb180c59759919174d" 0
Expand Down
2 changes: 1 addition & 1 deletion onchain/test/golden/ReserveDatum-cbor.golden
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9f9f9f1a49952d5dd8799f58210281158622b7d2eb738b885e1cca50218fb36ab4dc39014b83286b8ed95c78789d4461736466ffff9f581c726551f3f61ebd8f53198f7c137c646ae0bd57fb180c59759919174d00ff0fffd8798000ff
9f9fd8799f58210281158622b7d2eb738b885e1cca50218fb36ab4dc39014b83286b8ed95c78789d4461736466ff9f581c726551f3f61ebd8f53198f7c137c646ae0bd57fb180c59759919174d00ff0fffd8798000ff
2 changes: 1 addition & 1 deletion onchain/test/golden/ReserveDatum-isdata.golden
Original file line number Diff line number Diff line change
@@ -1 +1 @@
List [List [List [I 1234513245,Constr 0 [B "\STX\129\NAK\134\"\183\210\235s\139\136^\FS\202P!\143\179j\180\220\&9\SOHK\131(k\142\217\\xx\157",B "asdf"]],List [B "reQ\243\246\RS\189\143S\EM\143|\DC3|dj\224\189W\251\CAN\fYu\153\EM\ETBM",I 0],I 15],Constr 0 [],I 0]
List [List [Constr 0 [B "\STX\129\NAK\134\"\183\210\235s\139\136^\FS\202P!\143\179j\180\220\&9\SOHK\131(k\142\217\\xx\157",B "asdf"],List [B "reQ\243\246\RS\189\143S\EM\143|\DC3|dj\224\189W\251\CAN\fYu\153\EM\ETBM",I 0],I 15],Constr 0 [],I 0]
4 changes: 1 addition & 3 deletions onchain/test/roundtrip/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Laws (toDataSafeLaws', toDataUnsafeLaws')
import PlutusLedgerApi.V1.Value (AssetClass (AssetClass))
import PlutusLedgerApi.V2 (
CurrencySymbol (CurrencySymbol),
POSIXTime (POSIXTime),
PubKeyHash (PubKeyHash),
)
import Test.QuickCheck (
Expand Down Expand Up @@ -81,15 +80,14 @@ genPCVR = oneof [pure UpdatePermissionedCandidates, pure RemovePermissionedCandi

genRD :: Gen ReserveDatum
genRD = do
pt <- arbitrary
ArbitraryCurrencySymbol cs1 <- arbitrary
ArbitraryCurrencySymbol cs2 <- arbitrary
i <- arbitrary
c <- arbitrary

pure
$ ReserveDatum
(ImmutableReserveSettings (POSIXTime pt) (AssetClass (cs1, "")))
(ImmutableReserveSettings (AssetClass (cs1, "")))
(MutableReserveSettings cs2 i)
(ReserveStats c)

Expand Down
4 changes: 2 additions & 2 deletions onchain/test/script-size/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ main =
, scriptFitsInto
"mkReserveValidator (Reserve) serialized"
Reserve.serialisableReserveValidator
5_870
5_797
, scriptFitsInto
"mkReserveAuthPolicy (Reserve) serialized"
Reserve.serialisableReserveAuthPolicy
2_718
2_662
, scriptFitsInto
"mkIlliquidCirculationSupplyValidator (IlliquidCirculationSupply) serialized"
IlliquidCirculationSupply.serialisableIlliquidCirculationSupplyValidator
Expand Down
4 changes: 2 additions & 2 deletions raw-scripts/src/lib.rs

Large diffs are not rendered by default.