Skip to content

Commit c686f0b

Browse files
committed
remove reserve t0
1 parent 077a088 commit c686f0b

File tree

16 files changed

+65
-114
lines changed

16 files changed

+65
-114
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Changed
2+
body: updated offchain code to match onchain types
3+
time: 2025-01-24T09:50:24.917518792+01:00
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Removed
2+
body: t0 field from reserve immutable settings smart-contract
3+
time: 2025-01-24T09:49:50.092863529+01:00

offchain/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ candidates and add new ones in a single transaction. Just provide
314314
```
315315
nix run .#pc-contracts-cli -- reserve-create \
316316
--total-accrued-function-script-hash SCRIPT-HASH \
317-
--reserve-posixtime-t0 POSIXTIME \
318317
--reserve-asset-script-hash ASSET-SCRIPT-HASH \
319318
--reserve-asset-name RESERVE_ASSET_NAME \
320319
--reserve-initial-deposit-amount RESERVE-DEPOSIT-AMOUNT

offchain/src/TrustlessSidechain/DParameter.purs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,8 @@ mkInsertDParameterLookupsAndConstraints
102102

103103
constraints :: TxConstraints
104104
constraints =
105-
Constraints.mustMintCurrencyWithRedeemer
105+
Constraints.mustMintCurrency
106106
dParameterMintingPolicyHash
107-
(RedeemerDatum $ PlutusData.unit)
108107
dParameterTokenName
109108
(Int.fromInt 1)
110109
<> Constraints.mustPayToScript dParameterValidatorHash datum

offchain/src/TrustlessSidechain/NativeTokenManagement/Reserve.purs

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ import Contract.PlutusData
3232
, toData
3333
)
3434
import Contract.ScriptLookups as Lookups
35-
import Contract.Time
36-
( POSIXTime
37-
)
3835
import Contract.Time as Time
3936
import Contract.Transaction
4037
( ScriptRef(..)
@@ -51,25 +48,16 @@ import Contract.Utxos (UtxoMap)
5148
import Contract.Value (add, minus, singleton) as Value
5249
import Data.Array as Array
5350
import Data.Bifunctor (lmap)
54-
import Data.DateTime.Instant (unInstant)
55-
import Data.Int (floor)
5651
import Data.Map as Map
57-
import Data.Time.Duration (Milliseconds(..))
58-
import Effect.Now as Now
59-
import Effect.Unsafe (unsafePerformEffect)
6052
import JS.BigInt as BigInt
61-
import Partial.Unsafe (unsafePartial)
62-
import Run (EFFECT, Run, liftEffect)
6353
import Run (Run)
6454
import Run.Except (EXCEPT, throw)
65-
import TrustlessSidechain.Effects.App (APP, BASE)
66-
import TrustlessSidechain.Effects.Contract (CONTRACT, liftContract)
55+
import TrustlessSidechain.Effects.App (APP)
6756
import TrustlessSidechain.Effects.Time (getCurrentEra, getSystemStart)
6857
import TrustlessSidechain.Effects.Transaction (TRANSACTION, getUtxo, utxosAt)
6958
import TrustlessSidechain.Effects.Util (fromEitherThrow, fromMaybeThrow)
7059
import TrustlessSidechain.Effects.Wallet (WALLET)
7160
import TrustlessSidechain.Error (OffchainError(..))
72-
import TrustlessSidechain.Error (OffchainError(GenericInternalError))
7361
import TrustlessSidechain.Governance.Utils as Governance
7462
import TrustlessSidechain.NativeTokenManagement.Types
7563
( ImmutableReserveSettings
@@ -318,9 +306,8 @@ initialiseReserveUtxo
318306
governanceConstraints
319307
<> reserveAuthConstraints
320308
<> reserveConstraints
321-
<> TxConstraints.mustMintCurrencyWithRedeemerUsingScriptRef
309+
<> TxConstraints.mustMintCurrencyUsingScriptRef
322310
reserveAuthCurrencySymbol
323-
(RedeemerDatum $ toData unit)
324311
reserveAuthTokenName
325312
(Int.fromInt 1)
326313
( RefInput $ TransactionUnspentOutput
@@ -440,8 +427,7 @@ depositToReserve genesisUtxo asset amount = do
440427
DatumInline
441428
newValue
442429
<> TxConstraints.mustSpendScriptOutputUsingScriptRef (fst utxo)
443-
( RedeemerDatum $ toData $ DepositToReserve
444-
{ governanceVersion: BigInt.fromInt 1 }
430+
( RedeemerDatum $ toData DepositToReserve
445431
)
446432
( RefInput $ TransactionUnspentOutput
447433
{ input: reserveValidatorTxInput
@@ -489,12 +475,13 @@ updateReserveUtxo genesisUtxo updatedMutableSettings utxo = do
489475
versionOracleConfig <- Versioning.getVersionOracleConfig genesisUtxo
490476
reserveValidator' <- reserveValidator versionOracleConfig
491477

478+
let txOutput = snd utxo
479+
492480
genericDatum <-
493481
fromMaybeThrow (InvalidData "Reserve does not carry inline datum")
494482
$ pure
495483
$ extractReserveDatum
496-
$ snd
497-
$ utxo
484+
$ txOutput
498485

499486
let
500487
updatedReserveDatum = ReserveDatum $ (unwrap $ getDatum genericDatum)
@@ -510,7 +497,7 @@ updateReserveUtxo genesisUtxo updatedMutableSettings utxo = do
510497
, version
511498
}
512499

513-
value = unwrap >>> _.amount $ snd utxo
500+
value = unwrap >>> _.amount $ txOutput
514501

515502
lookups :: Lookups.ScriptLookups
516503
lookups =
@@ -526,20 +513,19 @@ updateReserveUtxo genesisUtxo updatedMutableSettings utxo = do
526513
<> icsConstraints
527514
<> reserveAuthConstraints
528515
<> reserveConstraints
529-
<> TxConstraints.mustPayToScript
530-
(PlutusScript.hash reserveValidator')
531-
(toData updatedDatum)
532-
DatumInline
533-
value
534516
<> TxConstraints.mustSpendScriptOutputUsingScriptRef (fst utxo)
535-
( RedeemerDatum $ toData $ UpdateReserve
536-
{ governanceVersion: BigInt.fromInt 1 }
517+
( RedeemerDatum $ toData UpdateReserve
537518
)
538519
( RefInput $ TransactionUnspentOutput
539520
{ input: reserveValidatorTxInput
540521
, output: reserveValidatorTxOutput
541522
}
542523
)
524+
<> TxConstraints.mustPayToScript
525+
(PlutusScript.hash reserveValidator')
526+
(toData updatedDatum)
527+
DatumInline
528+
value
543529

544530
balanceSignAndSubmit
545531
"Update reserve mutable settings"
@@ -822,18 +808,15 @@ handover
822808
toHandover
823809
<> TxConstraints.mustSpendScriptOutputUsingScriptRef
824810
(fst utxo)
825-
( RedeemerDatum $ toData $ Handover
826-
{ governanceVersion: BigInt.fromInt 1 }
811+
( RedeemerDatum $ toData Handover
827812
)
828813
( RefInput $ TransactionUnspentOutput
829814
{ input: reserveRefTxInput
830815
, output: reserveRefTxOutput
831816
}
832817
)
833-
<> TxConstraints.mustMintCurrencyWithRedeemerUsingScriptRef
818+
<> TxConstraints.mustMintCurrencyUsingScriptRef
834819
(PlutusScript.hash reserveAuthPolicy')
835-
( RedeemerDatum $ toData $ unit
836-
)
837820
emptyAssetName
838821
(Int.fromInt (-1))
839822
( RefInput $ TransactionUnspentOutput

offchain/src/TrustlessSidechain/NativeTokenManagement/Types.purs

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ import Cardano.Types.ScriptHash (ScriptHash)
1616
import Contract.PlutusData
1717
( class FromData
1818
, class ToData
19-
, PlutusData(Constr, Integer, List)
19+
, PlutusData(Constr, Integer)
2020
, fromData
2121
, toData
2222
)
23-
import Ctl.Internal.Types.Interval (POSIXTime)
2423
import Data.ByteArray as ByteArray
2524
import TrustlessSidechain.Utils.Data
2625
( productFromData2
@@ -30,8 +29,7 @@ import TrustlessSidechain.Utils.Data
3029
)
3130

3231
newtype ImmutableReserveSettings = ImmutableReserveSettings
33-
{ t0 :: POSIXTime
34-
, tokenKind :: Asset
32+
{ tokenKind :: Asset
3533
}
3634

3735
derive instance Generic ImmutableReserveSettings _
@@ -40,28 +38,27 @@ derive newtype instance Eq ImmutableReserveSettings
4038
derive newtype instance Show ImmutableReserveSettings
4139

4240
instance ToData ImmutableReserveSettings where
43-
toData (ImmutableReserveSettings { t0, tokenKind: Asset cs tn }) =
44-
productToData2 t0 (Constr (BigNum.fromInt 0) [ toData cs, toData tn ])
45-
toData (ImmutableReserveSettings { t0, tokenKind: AdaAsset }) =
46-
productToData2 t0
41+
toData (ImmutableReserveSettings { tokenKind: Asset cs tn }) =
42+
toData (Constr (BigNum.fromInt 0) [ toData cs, toData tn ])
43+
toData (ImmutableReserveSettings { tokenKind: AdaAsset }) =
44+
toData
4745
( Constr (BigNum.fromInt 0)
4846
[ toData $ ByteArray.hexToByteArrayUnsafe ""
4947
, toData $ ByteArray.hexToByteArrayUnsafe ""
5048
]
5149
)
5250

5351
instance FromData ImmutableReserveSettings where
54-
fromData (List [ t0', Constr _ [ cs', tn' ] ]) = do
52+
fromData (Constr _ [ cs', tn' ]) = do
5553
csB <- fromData cs'
5654
tnB <- fromData tn'
57-
t0 <- fromData t0'
5855
let emptyByteString = ByteArray.hexToByteArrayUnsafe ""
5956
if (csB /\ tnB) == (emptyByteString /\ emptyByteString) then Just $
60-
ImmutableReserveSettings { t0, tokenKind: AdaAsset }
57+
ImmutableReserveSettings { tokenKind: AdaAsset }
6158
else do
6259
cs <- fromData cs'
6360
tn <- fromData tn'
64-
Just $ ImmutableReserveSettings { t0, tokenKind: Asset cs tn }
61+
Just $ ImmutableReserveSettings { tokenKind: Asset cs tn }
6562
fromData _ = Nothing
6663

6764
newtype MutableReserveSettings = MutableReserveSettings
@@ -133,12 +130,9 @@ instance FromData ReserveDatum where
133130

134131
data ReserveRedeemer
135132
= DepositToReserve
136-
{ governanceVersion :: BigInt.BigInt }
137133
| TransferToIlliquidCirculationSupply
138134
| UpdateReserve
139-
{ governanceVersion :: BigInt.BigInt }
140135
| Handover
141-
{ governanceVersion :: BigInt.BigInt }
142136

143137
derive instance Eq ReserveRedeemer
144138

@@ -148,28 +142,25 @@ instance Show ReserveRedeemer where
148142
show = genericShow
149143

150144
instance ToData ReserveRedeemer where
151-
toData (DepositToReserve { governanceVersion }) =
152-
Constr (BigNum.fromInt 0) [ toData governanceVersion ]
145+
toData DepositToReserve =
146+
Constr (BigNum.fromInt 0) []
153147
toData TransferToIlliquidCirculationSupply =
154148
Constr (BigNum.fromInt 1) []
155-
toData (UpdateReserve { governanceVersion }) =
156-
Constr (BigNum.fromInt 2) [ toData governanceVersion ]
157-
toData (Handover { governanceVersion }) =
158-
Constr (BigNum.fromInt 3) [ toData governanceVersion ]
149+
toData UpdateReserve =
150+
Constr (BigNum.fromInt 2) []
151+
toData Handover =
152+
Constr (BigNum.fromInt 3) []
159153

160154
instance FromData ReserveRedeemer where
161155
fromData = case _ of
162-
Constr tag [ arg ] | tag == BigNum.fromInt 0 -> do
163-
governanceVersion <- fromData arg
164-
pure $ DepositToReserve { governanceVersion }
156+
Constr tag [] | tag == BigNum.fromInt 0 -> pure
157+
DepositToReserve
165158
Constr tag [] | tag == BigNum.fromInt 1 -> pure
166159
TransferToIlliquidCirculationSupply
167-
Constr tag [ arg ] | tag == BigNum.fromInt 2 -> do
168-
governanceVersion <- fromData arg
169-
pure $ UpdateReserve { governanceVersion }
170-
Constr tag [ arg ] | tag == BigNum.fromInt 3 -> do
171-
governanceVersion <- fromData arg
172-
pure $ Handover { governanceVersion }
160+
Constr tag [] | tag == BigNum.fromInt 2 -> pure
161+
UpdateReserve
162+
Constr tag [] | tag == BigNum.fromInt 3 -> pure
163+
Handover
173164
_ -> Nothing
174165

175166
data IlliquidCirculationSupplyRedeemer

offchain/src/TrustlessSidechain/Options/Specs.purs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import Contract.Config
1414
, testnetConfig
1515
)
1616
import Contract.Prim.ByteArray (ByteArray)
17-
import Contract.Time (POSIXTime)
1817
import Contract.Transaction (TransactionInput)
1918
import Contract.Value (AssetName)
2019
import Contract.Wallet
@@ -589,17 +588,6 @@ parseIncentiveAmount =
589588
]
590589
)
591590

592-
-- `parsePOSIXTime`
593-
parserT0 :: Parser POSIXTime
594-
parserT0 = option Parsers.posixTime
595-
( fold
596-
[ long "reserve-posixtime-t0"
597-
, metavar "POSIXTIME"
598-
, help
599-
"Partner chain POSIX timestamp of the moment the reserve is launched"
600-
]
601-
)
602-
603591
parseAssetName :: Parser AssetName
604592
parseAssetName =
605593
( option
@@ -644,9 +632,8 @@ parseAsset long' metavar' =
644632

645633
parseImmutableReserveSettings :: Parser ImmutableReserveSettings
646634
parseImmutableReserveSettings = ado
647-
t0 <- parserT0
648635
tokenKind <- parseAsset "reserve-asset-script-hash" "ASSET-SCRIPT-HASH"
649-
in ImmutableReserveSettings { t0, tokenKind }
636+
in ImmutableReserveSettings { tokenKind }
650637

651638
parseMutableReserveSettings :: Parser MutableReserveSettings
652639
parseMutableReserveSettings = ado

0 commit comments

Comments
 (0)