diff --git a/app/Main.hs b/app/Main.hs index 92cdffc4..7577a727 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -41,12 +41,14 @@ import qualified Tezos.Address as Tezos import qualified Tezos.Core as Core (parseTimestamp) import Lorentz (Timestamp, ToT, IsoValue) import qualified Lorentz as L +import Lorentz.Run import Util.IO (hSetTranslit, writeFileUtf8) import Universum.Print import Universum.String import Universum.Lifted import Universum.Exception +import Michelson.Printer import Michelson.TypeCheck import Michelson.Typed.Instr (FullContract(..)) import Michelson.Typed.Scope @@ -315,9 +317,11 @@ main = do fa12ContractAddr' PrintSpecializedAnyFA12 centralWalletAddr' mOutput forceOneline -> writeFunc mOutput $ - L.printLorentzContract + printTypedFullContract forceOneline $ + compileLorentzContractWithOptions (CompilationOptions { coDisableInitialCast = True }) $ Specialized.specializedAnyForwarderContract centralWalletAddr' + -- PrintSpecializedAnyTezFA12 centralWalletAddr' mOutput forceOneline -> writeFunc mOutput $ L.printLorentzContract @@ -332,4 +336,3 @@ main = do writeFunc mOutput $ L.printLorentzValue True $ Specialized.mkParameter amountToFlush tokenContract - diff --git a/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny.hs b/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny.hs index d779a9b1..ee83508e 100644 --- a/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny.hs +++ b/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny.hs @@ -29,7 +29,6 @@ import Lorentz.Base (SomeContract(..)) import Michelson.Analyzer (AnalyzerRes) import Michelson.Typed.EntryPoints -import Lorentz.Contracts.Spec.AbstractLedgerInterface (TransferParams) import qualified Lorentz.Contracts.Spec.AbstractLedgerInterface as AL import qualified Lorentz.Contracts.Forwarder.Specialized as Specialized @@ -39,6 +38,7 @@ import Prelude (Show(..), Enum(..), Eq(..), ($), String, show) import Michelson.Typed.Value.Orphans () +type TransferParams = (Address,Address,Natural) -- | The number of sub-tokens to forward and the typed contract address of the -- token to forward it on @@ -104,26 +104,25 @@ toTransferParameter = do pair forcedCoerce_ @(Address, (Address, Natural)) @TransferParams --- | Run a transfer to the given central wallet `Address`, given the token --- contract `Address` and the number of tokens to transfer -runSpecializedAnyTransfer :: Address -> (Natural & ContractRef TransferParams & s) :-> (Operation & s) -runSpecializedAnyTransfer centralWalletAddr' = do - push centralWalletAddr' - toTransferParameter - dip . push $ toEnum @Mutez 0 - transferTokens - -- | Forwarder contract: forwards the given number of sub-tokens -- from its own address to the central wallet. specializedAnyForwarderContract :: Address -> ContractCode Parameter Storage specializedAnyForwarderContract centralWalletAddr' = do car unParameter - unpair - runSpecializedAnyTransfer centralWalletAddr' - dip nil + dup + car + dip $ do + cdr + push $ toEnum @Mutez 0 + push centralWalletAddr' + toTransferParameter + transferTokens @TransferParams + nil + swap cons - dip unit + unit + swap pair -- | `analyzeLorentz` specialized to the `specializedAnyForwarderContract` diff --git a/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny/ForwardAnyFA12.hs b/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny/ForwardAnyFA12.hs index b43d59eb..92688f3f 100644 --- a/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny/ForwardAnyFA12.hs +++ b/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny/ForwardAnyFA12.hs @@ -62,7 +62,9 @@ runSpecializedAnyTezTransfer centralWalletAddr' = do ifNone nil $ do dip dup FlushAny.unParameter - unpair + dup + car + dip cdr dig @2 FlushAny.toTransferParameter dip . push $ toEnum @Mutez 0 @@ -128,4 +130,3 @@ verifyForwarderContract centralWalletAddr' (SomeContract (contract' :: ContractC forceOneline (specializedAnyFA12ForwarderContract centralWalletAddr') - diff --git a/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny/Tez.hs b/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny/Tez.hs index 733d5aad..b2980f24 100644 --- a/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny/Tez.hs +++ b/src/Lorentz/Contracts/Forwarder/Specialized/FlushAny/Tez.hs @@ -28,9 +28,9 @@ import Lorentz.Base (SomeContract(..)) import Michelson.Analyzer (AnalyzerRes) import Michelson.Text -import Lorentz.Contracts.Spec.AbstractLedgerInterface (TransferParams) import Lorentz.Contracts.Forwarder.Specialized.FlushAny (Parameter(..)) import qualified Lorentz.Contracts.Forwarder.Specialized as Specialized +import Lorentz.Contracts.Forwarder.Specialized.FlushAny (TransferParams) import qualified Lorentz.Contracts.Forwarder.Specialized.FlushAny as FlushAny import Data.Type.Equality @@ -81,7 +81,9 @@ specializedAnyTezForwarderContract :: Address -> ContractCode Parameter Storage specializedAnyTezForwarderContract centralWalletAddr' = do car FlushAny.unParameter - unpair + dup + car + dip cdr runSpecializedAnyTezTransfer centralWalletAddr' dip unit pair @@ -115,4 +117,3 @@ verifyForwarderContract centralWalletAddr' (SomeContract (contract' :: ContractC forceOneline (specializedAnyTezForwarderContract centralWalletAddr') -