module Morley.Client.Action.Origination.Large
( LargeOriginationData (..)
, SomeLargeContractOriginator (..)
, mkLargeOriginationData
, mkSomeLargeContractOriginator
, LargeOriginatorParam
, LargeOriginatorStore
, largeContractOriginator
, divideValueInChunks
, mkOriginationLambda
, mkLargeOriginatorStore
, mkLargeOriginatorData
, mkLargeOriginatorTransactions
, retrieveLargeContracts
) where
import Prelude hiding (concat, drop, swap)
import qualified Data.ByteString.Lazy as LBS
import Lorentz
import Morley.Client.Action.Common
import Morley.Client.RPC.Class
import Morley.Client.RPC.Error
import Morley.Client.RPC.Getters (getContractStorage)
import Morley.Client.TezosClient
import Morley.Micheline (fromExpression)
import Morley.Michelson.Interpret.Pack (packValue)
import qualified Morley.Michelson.Typed as T
import Morley.Michelson.Typed.Instr
import Morley.Michelson.Typed.Scope
import Morley.Michelson.Typed.Util (PushableStorageSplit(..), splitPushableStorage)
import Morley.Michelson.Typed.Value
import Morley.Michelson.Untyped.Annotation (annQ, noAnn)
data LargeOriginationData = LargeOriginationData
{ LargeOriginationData -> SomeLargeContractOriginator
largeOriginator :: SomeLargeContractOriginator
, LargeOriginationData -> OriginationData
largeContractData :: OriginationData
}
data SomeLargeContractOriginator where
SomeLargeContractOriginator
:: forall heavy. StorageScope heavy
=> Value heavy
-> T.Contract LargeOriginatorParam (LargeOriginatorStore heavy)
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
-> SomeLargeContractOriginator
mkLargeOriginationData :: OriginationData -> LargeOriginationData
mkLargeOriginationData :: OriginationData -> LargeOriginationData
mkLargeOriginationData largeContractData :: OriginationData
largeContractData@OriginationData{Bool
Maybe Mutez
Mutez
Value st
Contract cp st
AliasHint
odMbFee :: OriginationData -> Maybe Mutez
odStorage :: ()
odContract :: ()
odBalance :: OriginationData -> Mutez
odName :: OriginationData -> AliasHint
odReplaceExisting :: OriginationData -> Bool
odMbFee :: Maybe Mutez
odStorage :: Value st
odContract :: Contract cp st
odBalance :: Mutez
odName :: AliasHint
odReplaceExisting :: Bool
..} = LargeOriginationData :: SomeLargeContractOriginator
-> OriginationData -> LargeOriginationData
LargeOriginationData{OriginationData
SomeLargeContractOriginator
largeOriginator :: SomeLargeContractOriginator
largeContractData :: OriginationData
largeContractData :: OriginationData
largeOriginator :: SomeLargeContractOriginator
..}
where
largeOriginator :: SomeLargeContractOriginator
largeOriginator = Value st -> Contract cp st -> Mutez -> SomeLargeContractOriginator
forall (param :: T) (store :: T).
(ParameterScope param, StorageScope store) =>
Value store
-> Contract param store -> Mutez -> SomeLargeContractOriginator
mkSomeLargeContractOriginator Value st
odStorage Contract cp st
odContract Mutez
odBalance
mkSomeLargeContractOriginator
:: (ParameterScope param, StorageScope store)
=> Value store
-> T.Contract param store
-> Mutez
-> SomeLargeContractOriginator
mkSomeLargeContractOriginator :: Value store
-> Contract param store -> Mutez -> SomeLargeContractOriginator
mkSomeLargeContractOriginator Value store
store Contract param store
largeContract Mutez
xtzs =
case Value store -> PushableStorageSplit '[] store
forall (t :: T) (s :: [T]).
StorageScope t =>
Value t -> PushableStorageSplit s t
splitPushableStorage Value store
store of
ConstantStorage Value store
val ->
let origContract :: Contract LargeOriginatorParam (LargeOriginatorStore 'TUnit)
origContract = Contract LargeOriginatorParam (LargeOriginatorStore 'TUnit)
forall (heavy :: T).
StorageScope heavy =>
Contract LargeOriginatorParam (LargeOriginatorStore heavy)
largeContractOriginator
origLambda :: Value (ToT (Lambda (Value 'TUnit) (Address, [Operation])))
origLambda = Instr '[ 'TUnit] '[store]
-> Contract param store
-> Mutez
-> Value (ToT (Lambda (Value 'TUnit) (Address, [Operation])))
forall (param :: T) (store :: T) (heavy :: T).
(ParameterScope param, StorageScope store, StorageScope heavy) =>
Instr '[heavy] '[store]
-> Contract param store
-> Mutez
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
mkOriginationLambda (Instr '[ 'TUnit] '[]
forall (a :: T) (out :: [T]). Instr (a : out) out
DROP Instr '[ 'TUnit] '[]
-> Instr '[] '[store] -> Instr '[ 'TUnit] '[store]
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Value store -> Instr '[] '[store]
forall (t :: T) (inp :: [T]).
ConstantScope t =>
Value' Instr t -> Instr inp (t : inp)
PUSH Value store
val) Contract param store
largeContract Mutez
xtzs
in Value 'TUnit
-> Contract LargeOriginatorParam (LargeOriginatorStore 'TUnit)
-> Value (ToT (Lambda (Value 'TUnit) (Address, [Operation])))
-> SomeLargeContractOriginator
forall (heavy :: T).
StorageScope heavy =>
Value heavy
-> Contract LargeOriginatorParam (LargeOriginatorStore heavy)
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
-> SomeLargeContractOriginator
SomeLargeContractOriginator Value 'TUnit
forall (instr :: [T] -> [T] -> *). Value' instr 'TUnit
VUnit Contract LargeOriginatorParam (LargeOriginatorStore 'TUnit)
origContract Value (ToT (Lambda (Value 'TUnit) (Address, [Operation])))
origLambda
PushableValueStorage Instr '[] '[store]
instr ->
let origContract :: Contract LargeOriginatorParam (LargeOriginatorStore 'TUnit)
origContract = Contract LargeOriginatorParam (LargeOriginatorStore 'TUnit)
forall (heavy :: T).
StorageScope heavy =>
Contract LargeOriginatorParam (LargeOriginatorStore heavy)
largeContractOriginator
origLambda :: Value (ToT (Lambda (Value 'TUnit) (Address, [Operation])))
origLambda = Instr '[ 'TUnit] '[store]
-> Contract param store
-> Mutez
-> Value (ToT (Lambda (Value 'TUnit) (Address, [Operation])))
forall (param :: T) (store :: T) (heavy :: T).
(ParameterScope param, StorageScope store, StorageScope heavy) =>
Instr '[heavy] '[store]
-> Contract param store
-> Mutez
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
mkOriginationLambda (Instr '[ 'TUnit] '[]
forall (a :: T) (out :: [T]). Instr (a : out) out
DROP Instr '[ 'TUnit] '[]
-> Instr '[] '[store] -> Instr '[ 'TUnit] '[store]
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr '[] '[store]
instr) Contract param store
largeContract Mutez
xtzs
in Value 'TUnit
-> Contract LargeOriginatorParam (LargeOriginatorStore 'TUnit)
-> Value (ToT (Lambda (Value 'TUnit) (Address, [Operation])))
-> SomeLargeContractOriginator
forall (heavy :: T).
StorageScope heavy =>
Value heavy
-> Contract LargeOriginatorParam (LargeOriginatorStore heavy)
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
-> SomeLargeContractOriginator
SomeLargeContractOriginator Value 'TUnit
forall (instr :: [T] -> [T] -> *). Value' instr 'TUnit
VUnit Contract LargeOriginatorParam (LargeOriginatorStore 'TUnit)
origContract Value (ToT (Lambda (Value 'TUnit) (Address, [Operation])))
origLambda
PartlyPushableStorage Value heavy
val Instr '[heavy] '[store]
instr ->
let origContract :: Contract LargeOriginatorParam (LargeOriginatorStore heavy)
origContract = Contract LargeOriginatorParam (LargeOriginatorStore heavy)
forall (heavy :: T).
StorageScope heavy =>
Contract LargeOriginatorParam (LargeOriginatorStore heavy)
largeContractOriginator
origLambda :: Value (ToT (Lambda (Value heavy) (Address, [Operation])))
origLambda = Instr '[heavy] '[store]
-> Contract param store
-> Mutez
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
forall (param :: T) (store :: T) (heavy :: T).
(ParameterScope param, StorageScope store, StorageScope heavy) =>
Instr '[heavy] '[store]
-> Contract param store
-> Mutez
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
mkOriginationLambda Instr '[heavy] '[store]
instr Contract param store
largeContract Mutez
xtzs
in Value heavy
-> Contract LargeOriginatorParam (LargeOriginatorStore heavy)
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
-> SomeLargeContractOriginator
forall (heavy :: T).
StorageScope heavy =>
Value heavy
-> Contract LargeOriginatorParam (LargeOriginatorStore heavy)
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
-> SomeLargeContractOriginator
SomeLargeContractOriginator Value heavy
val Contract LargeOriginatorParam (LargeOriginatorStore heavy)
origContract Value (ToT (Lambda (Value heavy) (Address, [Operation])))
origLambda
type LargeOriginatorParam = 'T.TOr 'T.TBytes 'T.TUnit
type LargeOriginatorStore heavy =
'T.TPair 'T.TAddress ('T.TOr 'T.TAddress ('T.TPair 'T.TBytes heavy))
largeContractOriginator
:: StorageScope heavy
=> T.Contract LargeOriginatorParam (LargeOriginatorStore heavy)
largeContractOriginator :: Contract LargeOriginatorParam (LargeOriginatorStore heavy)
largeContractOriginator = Contract :: forall (instr :: [T] -> [T] -> *) (cp :: T) (st :: T).
(ParameterScope cp, StorageScope st) =>
ContractCode' instr cp st
-> ParamNotes cp
-> Notes st
-> ViewsSet' instr st
-> EntriesOrder
-> Contract' instr cp st
T.Contract{Instr
'[ 'TPair LargeOriginatorParam (LargeOriginatorStore heavy)]
'[ 'TPair ('TList 'TOperation) (LargeOriginatorStore heavy)]
Notes (LargeOriginatorStore heavy)
ParamNotes LargeOriginatorParam
ViewsSet' Instr (LargeOriginatorStore heavy)
EntriesOrder
forall (b :: T) (s :: [T]).
Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TPair ('TList 'TOperation) (LargeOriginatorStore heavy) : s)
cViews :: ViewsSet' Instr (LargeOriginatorStore heavy)
cStoreNotes :: Notes (LargeOriginatorStore heavy)
cParamNotes :: ParamNotes LargeOriginatorParam
cEntriesOrder :: EntriesOrder
cCode :: Instr
'[ 'TPair LargeOriginatorParam (LargeOriginatorStore heavy)]
'[ 'TPair ('TList 'TOperation) (LargeOriginatorStore heavy)]
cCode :: forall (b :: T) (s :: [T]).
Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TPair ('TList 'TOperation) (LargeOriginatorStore heavy) : s)
cViews :: ViewsSet' Instr (LargeOriginatorStore heavy)
cEntriesOrder :: EntriesOrder
cStoreNotes :: Notes (LargeOriginatorStore heavy)
cParamNotes :: ParamNotes LargeOriginatorParam
..}
where
epsNotes :: Notes LargeOriginatorParam
epsNotes = TypeAnn
-> FieldAnn
-> FieldAnn
-> Notes 'TBytes
-> Notes 'TUnit
-> Notes LargeOriginatorParam
forall (p :: T) (q :: T).
TypeAnn
-> FieldAnn -> FieldAnn -> Notes p -> Notes q -> Notes ('TOr p q)
T.NTOr TypeAnn
forall k (a :: k). Annotation a
noAnn [annQ|load_lambda|] [annQ|run_lambda|] Notes 'TBytes
forall (t :: T). SingI t => Notes t
T.starNotes Notes 'TUnit
forall (t :: T). SingI t => Notes t
T.starNotes
cParamNotes :: ParamNotes LargeOriginatorParam
cParamNotes = ParamNotes LargeOriginatorParam
-> Either ParamEpError (ParamNotes LargeOriginatorParam)
-> ParamNotes LargeOriginatorParam
forall b a. b -> Either a b -> b
fromRight ParamNotes LargeOriginatorParam
forall (t :: T). SingI t => ParamNotes t
T.starParamNotes (Either ParamEpError (ParamNotes LargeOriginatorParam)
-> ParamNotes LargeOriginatorParam)
-> Either ParamEpError (ParamNotes LargeOriginatorParam)
-> ParamNotes LargeOriginatorParam
forall a b. (a -> b) -> a -> b
$ Notes LargeOriginatorParam
-> FieldAnn
-> Either ParamEpError (ParamNotes LargeOriginatorParam)
forall (t :: T).
Notes t -> FieldAnn -> Either ParamEpError (ParamNotes t)
T.mkParamNotes Notes LargeOriginatorParam
epsNotes FieldAnn
forall k (a :: k). Annotation a
noAnn
stateNotes :: Notes ('TOr 'TAddress ('TPair 'TBytes heavy))
stateNotes = TypeAnn
-> FieldAnn
-> FieldAnn
-> Notes 'TAddress
-> Notes ('TPair 'TBytes heavy)
-> Notes ('TOr 'TAddress ('TPair 'TBytes heavy))
forall (p :: T) (q :: T).
TypeAnn
-> FieldAnn -> FieldAnn -> Notes p -> Notes q -> Notes ('TOr p q)
T.NTOr TypeAnn
forall k (a :: k). Annotation a
noAnn [annQ|originated|] [annQ|loading|] Notes 'TAddress
forall (t :: T). SingI t => Notes t
T.starNotes Notes ('TPair 'TBytes heavy)
forall (t :: T). SingI t => Notes t
T.starNotes
cStoreNotes :: Notes (LargeOriginatorStore heavy)
cStoreNotes = TypeAnn
-> FieldAnn
-> FieldAnn
-> VarAnn
-> VarAnn
-> Notes 'TAddress
-> Notes ('TOr 'TAddress ('TPair 'TBytes heavy))
-> Notes (LargeOriginatorStore heavy)
forall (p :: T) (q :: T).
TypeAnn
-> FieldAnn
-> FieldAnn
-> VarAnn
-> VarAnn
-> Notes p
-> Notes q
-> Notes ('TPair p q)
T.NTPair TypeAnn
forall k (a :: k). Annotation a
noAnn [annQ|owner|] FieldAnn
forall k (a :: k). Annotation a
noAnn VarAnn
forall k (a :: k). Annotation a
noAnn VarAnn
forall k (a :: k). Annotation a
noAnn Notes 'TAddress
forall (t :: T). SingI t => Notes t
T.starNotes Notes ('TOr 'TAddress ('TPair 'TBytes heavy))
stateNotes
cEntriesOrder :: EntriesOrder
cEntriesOrder = EntriesOrder
forall a. Default a => a
def
cViews :: ViewsSet' Instr (LargeOriginatorStore heavy)
cViews = ViewsSet' Instr (LargeOriginatorStore heavy)
forall a. Default a => a
def
cCode :: Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TPair ('TList 'TOperation) (LargeOriginatorStore heavy) : s)
cCode =
Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TOr 'TBytes b : LargeOriginatorStore heavy : s)
forall (i :: [T]) (o :: [T]) (a :: T) (b :: T) (s :: [T]).
(i ~ ('TPair a b : s), o ~ (a : b : s)) =>
Instr i o
UNPAIR Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TOr 'TBytes b : LargeOriginatorStore heavy : s)
-> Instr
('TOr 'TBytes b : LargeOriginatorStore heavy : s)
('TOr 'TBytes b : 'TBytes : heavy : 'TAddress : s)
-> Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TOr 'TBytes b : 'TBytes : heavy : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq`
Instr
(LargeOriginatorStore heavy : s) ('TBytes : heavy : 'TAddress : s)
-> Instr
('TOr 'TBytes b : LargeOriginatorStore heavy : s)
('TOr 'TBytes b : 'TBytes : heavy : 'TAddress : s)
forall (a :: [T]) (c :: [T]) (b :: T).
Instr a c -> Instr (b : a) (b : c)
DIP
( Instr
(LargeOriginatorStore heavy : s)
('TAddress : 'TOr 'TAddress ('TPair 'TBytes heavy) : s)
forall (i :: [T]) (o :: [T]) (a :: T) (b :: T) (s :: [T]).
(i ~ ('TPair a b : s), o ~ (a : b : s)) =>
Instr i o
UNPAIR Instr
(LargeOriginatorStore heavy : s)
('TAddress : 'TOr 'TAddress ('TPair 'TBytes heavy) : s)
-> Instr
('TAddress : 'TOr 'TAddress ('TPair 'TBytes heavy) : s)
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
(LargeOriginatorStore heavy : s)
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TAddress : 'TOr 'TAddress ('TPair 'TBytes heavy) : s)
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (a :: T) (b :: T) (s :: [T]). Instr (a : b : s) (b : a : s)
SWAP Instr
(LargeOriginatorStore heavy : s)
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
('TBytes : heavy : 'TAddress : s)
-> Instr
(LargeOriginatorStore heavy : s) ('TBytes : heavy : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr ('TAddress : 'TAddress : s) ('TBytes : heavy : 'TAddress : s)
-> Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TBytes : heavy : 'TAddress : s)
-> Instr
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
('TBytes : heavy : 'TAddress : s)
forall (a :: T) (s :: [T]) (out :: [T]) (b :: T).
Instr (a : s) out -> Instr (b : s) out -> Instr ('TOr a b : s) out
IF_LEFT
Instr ('TAddress : 'TAddress : s) ('TBytes : heavy : 'TAddress : s)
forall (a :: T) (s :: [T]) (out :: [T]).
(SingI a, ConstantScope a) =>
Instr (a : s) out
FAILWITH
( Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TAddress : 'TPair 'TBytes heavy : s)
forall (a :: T) (b :: T) (s :: [T]). Instr (a : b : s) (b : a : s)
SWAP Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TAddress : 'TPair 'TBytes heavy : s)
-> Instr
('TAddress : 'TPair 'TBytes heavy : s)
('TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
-> Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TAddress : 'TPair 'TBytes heavy : s)
('TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
forall (a :: T) (s :: [T]).
DupableScope a =>
Instr (a : s) (a : a : s)
DUP Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
-> Instr
('TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
('TAddress : 'TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
-> Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TAddress : 'TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
('TAddress : 'TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
forall (inp :: [T]). Instr inp ('TAddress : inp)
SENDER Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TAddress : 'TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
-> Instr
('TAddress : 'TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
('TInt : 'TAddress : 'TPair 'TBytes heavy : s)
-> Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TInt : 'TAddress : 'TPair 'TBytes heavy : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TAddress : 'TAddress : 'TAddress : 'TPair 'TBytes heavy : s)
('TInt : 'TAddress : 'TPair 'TBytes heavy : s)
forall (n :: T) (s :: [T]).
(Comparable n, SingI n) =>
Instr (n : n : s) ('TInt : s)
COMPARE Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TInt : 'TAddress : 'TPair 'TBytes heavy : s)
-> Instr
('TInt : 'TAddress : 'TPair 'TBytes heavy : s)
('TBool : 'TAddress : 'TPair 'TBytes heavy : s)
-> Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TBool : 'TAddress : 'TPair 'TBytes heavy : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TInt : 'TAddress : 'TPair 'TBytes heavy : s)
('TBool : 'TAddress : 'TPair 'TBytes heavy : s)
forall (n :: T) (s :: [T]).
UnaryArithOp Eq' n =>
Instr (n : s) (UnaryArithRes Eq' n : s)
T.EQ Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TBool : 'TAddress : 'TPair 'TBytes heavy : s)
-> Instr
('TBool : 'TAddress : 'TPair 'TBytes heavy : s)
('TBytes : heavy : 'TAddress : s)
-> Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TBytes : heavy : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TAddress : 'TPair 'TBytes heavy : s)
('TBytes : heavy : 'TAddress : s)
-> Instr
('TAddress : 'TPair 'TBytes heavy : s)
('TBytes : heavy : 'TAddress : s)
-> Instr
('TBool : 'TAddress : 'TPair 'TBytes heavy : s)
('TBytes : heavy : 'TAddress : s)
forall (s :: [T]) (out :: [T]).
Instr s out -> Instr s out -> Instr ('TBool : s) out
IF
( Instr
('TAddress : 'TPair 'TBytes heavy : s)
('TPair 'TBytes heavy : 'TAddress : s)
forall (a :: T) (b :: T) (s :: [T]). Instr (a : b : s) (b : a : s)
SWAP Instr
('TAddress : 'TPair 'TBytes heavy : s)
('TPair 'TBytes heavy : 'TAddress : s)
-> Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TBytes : heavy : 'TAddress : s)
-> Instr
('TAddress : 'TPair 'TBytes heavy : s)
('TBytes : heavy : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TBytes : heavy : 'TAddress : s)
forall (i :: [T]) (o :: [T]) (a :: T) (b :: T) (s :: [T]).
(i ~ ('TPair a b : s), o ~ (a : b : s)) =>
Instr i o
UNPAIR )
( Value' Instr 'TString
-> Instr
('TAddress : 'TPair 'TBytes heavy : s)
('TString : 'TAddress : 'TPair 'TBytes heavy : s)
forall (t :: T) (inp :: [T]).
ConstantScope t =>
Value' Instr t -> Instr inp (t : inp)
PUSH (MText -> Value' Instr 'TString
forall (instr :: [T] -> [T] -> *). MText -> Value' instr 'TString
VString [mt|sender is not originator owner|]) Instr
('TAddress : 'TPair 'TBytes heavy : s)
('TString : 'TAddress : 'TPair 'TBytes heavy : s)
-> Instr
('TString : 'TAddress : 'TPair 'TBytes heavy : s)
('TBytes : heavy : 'TAddress : s)
-> Instr
('TAddress : 'TPair 'TBytes heavy : s)
('TBytes : heavy : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TString : 'TAddress : 'TPair 'TBytes heavy : s)
('TBytes : heavy : 'TAddress : s)
forall (a :: T) (s :: [T]) (out :: [T]).
(SingI a, ConstantScope a) =>
Instr (a : s) out
FAILWITH )
)
) Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TOr 'TBytes b : 'TBytes : heavy : 'TAddress : s)
-> Instr
('TOr 'TBytes b : 'TBytes : heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq`
Instr
('TBytes : 'TBytes : heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
(b : 'TBytes : heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
('TOr 'TBytes b : 'TBytes : heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (a :: T) (s :: [T]) (out :: [T]) (b :: T).
Instr (a : s) out -> Instr (b : s) out -> Instr ('TOr a b : s) out
IF_LEFT
( Instr
('TBytes : 'TBytes : heavy : 'TAddress : s)
('TBytes : heavy : 'TAddress : s)
forall (c :: T) (s :: [T]). ConcatOp c => Instr (c : c : s) (c : s)
CONCAT Instr
('TBytes : 'TBytes : heavy : 'TAddress : s)
('TBytes : heavy : 'TAddress : s)
-> Instr
('TBytes : heavy : 'TAddress : s)
('TPair 'TBytes heavy : 'TAddress : s)
-> Instr
('TBytes : 'TBytes : heavy : 'TAddress : s)
('TPair 'TBytes heavy : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TBytes : heavy : 'TAddress : s)
('TPair 'TBytes heavy : 'TAddress : s)
forall (i :: [T]) (o :: [T]) (a :: T) (b :: T) (s :: [T]).
(i ~ (a : b : s), o ~ ('TPair a b : s)) =>
Instr i o
PAIR Instr
('TBytes : 'TBytes : heavy : 'TAddress : s)
('TPair 'TBytes heavy : 'TAddress : s)
-> Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
('TBytes : 'TBytes : heavy : 'TAddress : s)
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TPair 'TBytes heavy : 'TAddress : s)
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (i :: [T]) (o :: [T]) (a :: T) (b :: T) (s :: [T]).
(SingI a, i ~ (b : s), o ~ ('TOr a b : s)) =>
Instr i o
RIGHT Instr
('TBytes : 'TBytes : heavy : 'TAddress : s)
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
('TBytes : 'TBytes : heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (p :: T) (inp :: [T]). SingI p => Instr inp ('TList p : inp)
NIL)
( Instr
(b : 'TBytes : heavy : 'TAddress : s)
('TBytes : heavy : 'TAddress : s)
forall (a :: T) (out :: [T]). Instr (a : out) out
DROP Instr
(b : 'TBytes : heavy : 'TAddress : s)
('TBytes : heavy : 'TAddress : s)
-> Instr
('TBytes : heavy : 'TAddress : s)
('TOption ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation)))
: heavy : 'TAddress : s)
-> Instr
(b : 'TBytes : heavy : 'TAddress : s)
('TOption ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation)))
: heavy : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TBytes : heavy : 'TAddress : s)
('TOption ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation)))
: heavy : 'TAddress : s)
forall (a :: T) (s :: [T]).
(UnpackedValScope a, SingI a) =>
Instr ('TBytes : s) ('TOption a : s)
UNPACK Instr
(b : 'TBytes : heavy : 'TAddress : s)
('TOption ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation)))
: heavy : 'TAddress : s)
-> Instr
('TOption ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation)))
: heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
(b : 'TBytes : heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq`
Instr
(heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
('TOption ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation)))
: heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (s :: [T]) (out :: [T]) (a :: T).
Instr s out -> Instr (a : s) out -> Instr ('TOption a : s) out
IF_NONE
( Value' Instr 'TString
-> Instr (heavy : 'TAddress : s) ('TString : heavy : 'TAddress : s)
forall (t :: T) (inp :: [T]).
ConstantScope t =>
Value' Instr t -> Instr inp (t : inp)
PUSH (MText -> Value' Instr 'TString
forall (instr :: [T] -> [T] -> *). MText -> Value' instr 'TString
VString [mt|failed to unpack lambda|]) Instr (heavy : 'TAddress : s) ('TString : heavy : 'TAddress : s)
-> Instr
('TString : heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
(heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TString : heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (a :: T) (s :: [T]) (out :: [T]).
(SingI a, ConstantScope a) =>
Instr (a : s) out
FAILWITH )
( Instr
('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: heavy : 'TAddress : s)
(heavy
: 'TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: 'TAddress : s)
forall (a :: T) (b :: T) (s :: [T]). Instr (a : b : s) (b : a : s)
SWAP Instr
('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: heavy : 'TAddress : s)
(heavy
: 'TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: 'TAddress : s)
-> Instr
(heavy
: 'TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: 'TAddress : s)
('TPair 'TAddress ('TList 'TOperation) : 'TAddress : s)
-> Instr
('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: heavy : 'TAddress : s)
('TPair 'TAddress ('TList 'TOperation) : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
(heavy
: 'TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: 'TAddress : s)
('TPair 'TAddress ('TList 'TOperation) : 'TAddress : s)
forall (t1 :: T) (t2 :: T) (s :: [T]).
Instr (t1 : 'TLambda t1 t2 : s) (t2 : s)
EXEC Instr
('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: heavy : 'TAddress : s)
('TPair 'TAddress ('TList 'TOperation) : 'TAddress : s)
-> Instr
('TPair 'TAddress ('TList 'TOperation) : 'TAddress : s)
('TAddress : 'TList 'TOperation : 'TAddress : s)
-> Instr
('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: heavy : 'TAddress : s)
('TAddress : 'TList 'TOperation : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TPair 'TAddress ('TList 'TOperation) : 'TAddress : s)
('TAddress : 'TList 'TOperation : 'TAddress : s)
forall (i :: [T]) (o :: [T]) (a :: T) (b :: T) (s :: [T]).
(i ~ ('TPair a b : s), o ~ (a : b : s)) =>
Instr i o
UNPAIR Instr
('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: heavy : 'TAddress : s)
('TAddress : 'TList 'TOperation : 'TAddress : s)
-> Instr
('TAddress : 'TList 'TOperation : 'TAddress : s)
('TOr 'TAddress ('TPair 'TBytes heavy)
: 'TList 'TOperation : 'TAddress : s)
-> Instr
('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: heavy : 'TAddress : s)
('TOr 'TAddress ('TPair 'TBytes heavy)
: 'TList 'TOperation : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TAddress : 'TList 'TOperation : 'TAddress : s)
('TOr 'TAddress ('TPair 'TBytes heavy)
: 'TList 'TOperation : 'TAddress : s)
forall (i :: [T]) (o :: [T]) (b :: T) (a :: T) (s :: [T]).
(SingI b, i ~ (a : s), o ~ ('TOr a b : s)) =>
Instr i o
LEFT Instr
('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: heavy : 'TAddress : s)
('TOr 'TAddress ('TPair 'TBytes heavy)
: 'TList 'TOperation : 'TAddress : s)
-> Instr
('TOr 'TAddress ('TPair 'TBytes heavy)
: 'TList 'TOperation : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))
: heavy : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TOr 'TAddress ('TPair 'TBytes heavy)
: 'TList 'TOperation : 'TAddress : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
forall (a :: T) (b :: T) (s :: [T]). Instr (a : b : s) (b : a : s)
SWAP
)
) Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
-> Instr
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
('TList 'TOperation : LargeOriginatorStore heavy : s)
-> Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TList 'TOperation : LargeOriginatorStore heavy : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq`
Instr
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
(LargeOriginatorStore heavy : s)
-> Instr
('TList 'TOperation
: 'TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
('TList 'TOperation : LargeOriginatorStore heavy : s)
forall (a :: [T]) (c :: [T]) (b :: T).
Instr a c -> Instr (b : a) (b : c)
DIP (Instr
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
('TAddress : 'TOr 'TAddress ('TPair 'TBytes heavy) : s)
forall (a :: T) (b :: T) (s :: [T]). Instr (a : b : s) (b : a : s)
SWAP Instr
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
('TAddress : 'TOr 'TAddress ('TPair 'TBytes heavy) : s)
-> Instr
('TAddress : 'TOr 'TAddress ('TPair 'TBytes heavy) : s)
(LargeOriginatorStore heavy : s)
-> Instr
('TOr 'TAddress ('TPair 'TBytes heavy) : 'TAddress : s)
(LargeOriginatorStore heavy : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
('TAddress : 'TOr 'TAddress ('TPair 'TBytes heavy) : s)
(LargeOriginatorStore heavy : s)
forall (i :: [T]) (o :: [T]) (a :: T) (b :: T) (s :: [T]).
(i ~ (a : b : s), o ~ ('TPair a b : s)) =>
Instr i o
PAIR) Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TList 'TOperation : LargeOriginatorStore heavy : s)
-> Instr
('TList 'TOperation : LargeOriginatorStore heavy : s)
('TPair ('TList 'TOperation) (LargeOriginatorStore heavy) : s)
-> Instr
('TPair ('TOr 'TBytes b) (LargeOriginatorStore heavy) : s)
('TPair ('TList 'TOperation) (LargeOriginatorStore heavy) : s)
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq`
Instr
('TList 'TOperation : LargeOriginatorStore heavy : s)
('TPair ('TList 'TOperation) (LargeOriginatorStore heavy) : s)
forall (i :: [T]) (o :: [T]) (a :: T) (b :: T) (s :: [T]).
(i ~ (a : b : s), o ~ ('TPair a b : s)) =>
Instr i o
PAIR
divideValueInChunks :: ConstantScope val => Value val -> [ByteString]
divideValueInChunks :: Value val -> [ByteString]
divideValueInChunks = LByteString -> [ByteString]
divideInChunks (LByteString -> [ByteString])
-> (Value val -> LByteString) -> Value val -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value val -> LByteString
forall (t :: T). PackedValScope t => Value t -> LByteString
packValue
divideInChunks :: LByteString -> [ByteString]
divideInChunks :: LByteString -> [ByteString]
divideInChunks LByteString
bytes
| LByteString -> Bool
LBS.null LByteString
bytes = []
| Bool
otherwise =
let (LByteString
chunk, LByteString
rest) = Int64 -> LByteString -> (LByteString, LByteString)
LBS.splitAt Int64
14000 LByteString
bytes
in LByteString -> ByteString
LBS.toStrict LByteString
chunk ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: LByteString -> [ByteString]
divideInChunks LByteString
rest
mkOriginationLambda
:: (ParameterScope param, StorageScope store, StorageScope heavy)
=> Instr '[heavy] '[store]
-> T.Contract param store
-> Mutez
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
mkOriginationLambda :: Instr '[heavy] '[store]
-> Contract param store
-> Mutez
-> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
mkOriginationLambda Instr '[heavy] '[store]
instr Contract param store
largeContract Mutez
xtzs = RemFail Instr '[heavy] '[ 'TPair 'TAddress ('TList 'TOperation)]
-> Value'
Instr ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation)))
forall (inp :: T) (out :: T) (instr :: [T] -> [T] -> *).
(SingI inp, SingI out,
forall (i :: [T]) (o :: [T]). Show (instr i o),
forall (i :: [T]) (o :: [T]). Eq (instr i o),
forall (i :: [T]) (o :: [T]). NFData (instr i o)) =>
RemFail instr '[inp] '[out] -> Value' instr ('TLambda inp out)
VLam (RemFail Instr '[heavy] '[ 'TPair 'TAddress ('TList 'TOperation)]
-> Value'
Instr ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation))))
-> RemFail Instr '[heavy] '[ 'TPair 'TAddress ('TList 'TOperation)]
-> Value'
Instr ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation)))
forall a b. (a -> b) -> a -> b
$ Instr '[heavy] '[ 'TPair 'TAddress ('TList 'TOperation)]
-> RemFail Instr '[heavy] '[ 'TPair 'TAddress ('TList 'TOperation)]
forall k (instr :: k -> k -> *) (i :: k) (o :: k).
instr i o -> RemFail instr i o
RfNormal (Instr '[heavy] '[ 'TPair 'TAddress ('TList 'TOperation)]
-> RemFail
Instr '[heavy] '[ 'TPair 'TAddress ('TList 'TOperation)])
-> Instr '[heavy] '[ 'TPair 'TAddress ('TList 'TOperation)]
-> RemFail Instr '[heavy] '[ 'TPair 'TAddress ('TList 'TOperation)]
forall a b. (a -> b) -> a -> b
$
Instr '[heavy] '[store]
instr Instr '[heavy] '[store]
-> Instr '[store] '[ 'TMutez, store]
-> Instr '[heavy] '[ 'TMutez, store]
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Value' Instr 'TMutez -> Instr '[store] '[ 'TMutez, store]
forall (t :: T) (inp :: [T]).
ConstantScope t =>
Value' Instr t -> Instr inp (t : inp)
PUSH (Mutez -> Value' Instr 'TMutez
forall (instr :: [T] -> [T] -> *). Mutez -> Value' instr 'TMutez
VMutez Mutez
xtzs) Instr '[heavy] '[ 'TMutez, store]
-> Instr '[ 'TMutez, store] '[ 'TOption 'TKeyHash, 'TMutez, store]
-> Instr '[heavy] '[ 'TOption 'TKeyHash, 'TMutez, store]
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr '[ 'TMutez, store] '[ 'TOption 'TKeyHash, 'TMutez, store]
forall (a :: T) (inp :: [T]).
SingI a =>
Instr inp ('TOption a : inp)
NONE Instr '[heavy] '[ 'TOption 'TKeyHash, 'TMutez, store]
-> Instr
'[ 'TOption 'TKeyHash, 'TMutez, store] '[ 'TOperation, 'TAddress]
-> Instr '[heavy] '[ 'TOperation, 'TAddress]
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq`
Contract param store
-> Instr
'[ 'TOption 'TKeyHash, 'TMutez, store] '[ 'TOperation, 'TAddress]
forall (p :: T) (g :: T) (s :: [T]).
(ParameterScope p, StorageScope g) =>
Contract' Instr p g
-> Instr
('TOption 'TKeyHash : 'TMutez : g : s)
('TOperation : 'TAddress : s)
CREATE_CONTRACT Contract param store
largeContract Instr '[heavy] '[ 'TOperation, 'TAddress]
-> Instr
'[ 'TOperation, 'TAddress]
'[ 'TList 'TOperation, 'TOperation, 'TAddress]
-> Instr '[heavy] '[ 'TList 'TOperation, 'TOperation, 'TAddress]
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq`
Instr
'[ 'TOperation, 'TAddress]
'[ 'TList 'TOperation, 'TOperation, 'TAddress]
forall (p :: T) (inp :: [T]). SingI p => Instr inp ('TList p : inp)
NIL Instr '[heavy] '[ 'TList 'TOperation, 'TOperation, 'TAddress]
-> Instr
'[ 'TList 'TOperation, 'TOperation, 'TAddress]
'[ 'TOperation, 'TList 'TOperation, 'TAddress]
-> Instr '[heavy] '[ 'TOperation, 'TList 'TOperation, 'TAddress]
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
'[ 'TList 'TOperation, 'TOperation, 'TAddress]
'[ 'TOperation, 'TList 'TOperation, 'TAddress]
forall (a :: T) (b :: T) (s :: [T]). Instr (a : b : s) (b : a : s)
SWAP Instr '[heavy] '[ 'TOperation, 'TList 'TOperation, 'TAddress]
-> Instr
'[ 'TOperation, 'TList 'TOperation, 'TAddress]
'[ 'TList 'TOperation, 'TAddress]
-> Instr '[heavy] '[ 'TList 'TOperation, 'TAddress]
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
'[ 'TOperation, 'TList 'TOperation, 'TAddress]
'[ 'TList 'TOperation, 'TAddress]
forall (a :: T) (s :: [T]). Instr (a : 'TList a : s) ('TList a : s)
CONS Instr '[heavy] '[ 'TList 'TOperation, 'TAddress]
-> Instr
'[ 'TList 'TOperation, 'TAddress] '[ 'TAddress, 'TList 'TOperation]
-> Instr '[heavy] '[ 'TAddress, 'TList 'TOperation]
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
'[ 'TList 'TOperation, 'TAddress] '[ 'TAddress, 'TList 'TOperation]
forall (a :: T) (b :: T) (s :: [T]). Instr (a : b : s) (b : a : s)
SWAP Instr '[heavy] '[ 'TAddress, 'TList 'TOperation]
-> Instr
'[ 'TAddress, 'TList 'TOperation]
'[ 'TPair 'TAddress ('TList 'TOperation)]
-> Instr '[heavy] '[ 'TPair 'TAddress ('TList 'TOperation)]
forall (inp :: [T]) (b :: [T]) (out :: [T]).
Instr inp b -> Instr b out -> Instr inp out
`Seq` Instr
'[ 'TAddress, 'TList 'TOperation]
'[ 'TPair 'TAddress ('TList 'TOperation)]
forall (i :: [T]) (o :: [T]) (a :: T) (b :: T) (s :: [T]).
(i ~ (a : b : s), o ~ ('TPair a b : s)) =>
Instr i o
PAIR
mkLargeOriginatorStore
:: StorageScope heavy
=> Value heavy
-> Address
-> Value (LargeOriginatorStore heavy)
mkLargeOriginatorStore :: Value heavy -> Address -> Value (LargeOriginatorStore heavy)
mkLargeOriginatorStore Value heavy
heavyVal Address
owner =
let vAddr :: Value (ToT Address)
vAddr = Address -> Value (ToT Address)
forall a. IsoValue a => a -> Value (ToT a)
toVal Address
owner in
(Value' Instr 'TAddress,
Value' Instr ('TOr 'TAddress ('TPair 'TBytes heavy)))
-> Value (LargeOriginatorStore heavy)
forall (l :: T) (r :: T) (instr :: [T] -> [T] -> *).
(Value' instr l, Value' instr r) -> Value' instr ('TPair l r)
VPair (Value (ToT Address)
Value' Instr 'TAddress
vAddr, Either
(Value' Instr 'TAddress) (Value' Instr ('TPair 'TBytes heavy))
-> Value' Instr ('TOr 'TAddress ('TPair 'TBytes heavy))
forall (l :: T) (r :: T) (instr :: [T] -> [T] -> *).
(SingI l, SingI r) =>
Either (Value' instr l) (Value' instr r) -> Value' instr ('TOr l r)
VOr (Either
(Value' Instr 'TAddress) (Value' Instr ('TPair 'TBytes heavy))
-> Value' Instr ('TOr 'TAddress ('TPair 'TBytes heavy)))
-> Either
(Value' Instr 'TAddress) (Value' Instr ('TPair 'TBytes heavy))
-> Value' Instr ('TOr 'TAddress ('TPair 'TBytes heavy))
forall a b. (a -> b) -> a -> b
$ Value' Instr ('TPair 'TBytes heavy)
-> Either
(Value' Instr 'TAddress) (Value' Instr ('TPair 'TBytes heavy))
forall a b. b -> Either a b
Right (Value' Instr ('TPair 'TBytes heavy)
-> Either
(Value' Instr 'TAddress) (Value' Instr ('TPair 'TBytes heavy)))
-> Value' Instr ('TPair 'TBytes heavy)
-> Either
(Value' Instr 'TAddress) (Value' Instr ('TPair 'TBytes heavy))
forall a b. (a -> b) -> a -> b
$ (Value' Instr 'TBytes, Value heavy)
-> Value' Instr ('TPair 'TBytes heavy)
forall (l :: T) (r :: T) (instr :: [T] -> [T] -> *).
(Value' instr l, Value' instr r) -> Value' instr ('TPair l r)
VPair (ByteString -> Value' Instr 'TBytes
forall (instr :: [T] -> [T] -> *).
ByteString -> Value' instr 'TBytes
VBytes ByteString
forall a. Monoid a => a
mempty, Value heavy
heavyVal))
mkLargeOriginatorData
:: Address -> LargeOriginationData
-> OriginationData
mkLargeOriginatorData :: Address -> LargeOriginationData -> OriginationData
mkLargeOriginatorData Address
sender' LargeOriginationData{OriginationData
SomeLargeContractOriginator
largeContractData :: OriginationData
largeOriginator :: SomeLargeContractOriginator
largeContractData :: LargeOriginationData -> OriginationData
largeOriginator :: LargeOriginationData -> SomeLargeContractOriginator
..} = case SomeLargeContractOriginator
largeOriginator of
SomeLargeContractOriginator Value heavy
heavyVal Contract LargeOriginatorParam (LargeOriginatorStore heavy)
origContract Value (ToT (Lambda (Value heavy) (Address, [Operation])))
_origLambda -> OriginationData :: forall (cp :: T) (st :: T).
(ParameterScope cp, StorageScope st) =>
Bool
-> AliasHint
-> Mutez
-> Contract cp st
-> Value st
-> Maybe Mutez
-> OriginationData
OriginationData
{ odReplaceExisting :: Bool
odReplaceExisting = OriginationData -> Bool
odReplaceExisting (OriginationData -> Bool) -> OriginationData -> Bool
forall a b. (a -> b) -> a -> b
$ OriginationData
largeContractData
, odName :: AliasHint
odName = AliasHint
"largeOriginator." AliasHint -> AliasHint -> AliasHint
forall a. Semigroup a => a -> a -> a
<> OriginationData -> AliasHint
odName OriginationData
largeContractData
, odBalance :: Mutez
odBalance = Word32 -> Mutez
toMutez Word32
0
, odContract :: Contract LargeOriginatorParam (LargeOriginatorStore heavy)
odContract = Contract LargeOriginatorParam (LargeOriginatorStore heavy)
origContract
, odStorage :: Value (LargeOriginatorStore heavy)
odStorage = Value heavy -> Address -> Value (LargeOriginatorStore heavy)
forall (heavy :: T).
StorageScope heavy =>
Value heavy -> Address -> Value (LargeOriginatorStore heavy)
mkLargeOriginatorStore Value heavy
heavyVal Address
sender'
, odMbFee :: Maybe Mutez
odMbFee = OriginationData -> Maybe Mutez
odMbFee OriginationData
largeContractData
}
mkLargeOriginatorTransactions
:: Address -> LargeOriginationData
-> [TransactionData]
mkLargeOriginatorTransactions :: Address -> LargeOriginationData -> [TransactionData]
mkLargeOriginatorTransactions Address
originatorAddr LargeOriginationData{OriginationData
SomeLargeContractOriginator
largeContractData :: OriginationData
largeOriginator :: SomeLargeContractOriginator
largeContractData :: LargeOriginationData -> OriginationData
largeOriginator :: LargeOriginationData -> SomeLargeContractOriginator
..} =
case OriginationData
largeContractData of
OriginationData{Bool
Maybe Mutez
Mutez
Value st
Contract cp st
AliasHint
odMbFee :: Maybe Mutez
odStorage :: Value st
odContract :: Contract cp st
odBalance :: Mutez
odName :: AliasHint
odReplaceExisting :: Bool
odMbFee :: OriginationData -> Maybe Mutez
odStorage :: ()
odContract :: ()
odBalance :: OriginationData -> Mutez
odName :: OriginationData -> AliasHint
odReplaceExisting :: OriginationData -> Bool
..} -> case SomeLargeContractOriginator
largeOriginator of
SomeLargeContractOriginator Value heavy
_ Contract LargeOriginatorParam (LargeOriginatorStore heavy)
_ Value (ToT (Lambda (Value heavy) (Address, [Operation])))
origLambda ->
let lambdaChunks :: [ByteString]
lambdaChunks = Value ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation)))
-> [ByteString]
forall (val :: T). ConstantScope val => Value val -> [ByteString]
divideValueInChunks Value (ToT (Lambda (Value heavy) (Address, [Operation])))
Value ('TLambda heavy ('TPair 'TAddress ('TList 'TOperation)))
origLambda
doRunLambda :: TransactionData
doRunLambda = ParameterScope 'TUnit => TD (Value 'TUnit) -> TransactionData
forall (t :: T).
ParameterScope t =>
TD (Value t) -> TransactionData
TransactionData @'T.TUnit (TD (Value 'TUnit) -> TransactionData)
-> TD (Value 'TUnit) -> TransactionData
forall a b. (a -> b) -> a -> b
$ TD :: forall t. Address -> Mutez -> EpName -> t -> Maybe Mutez -> TD t
TD
{ tdReceiver :: Address
tdReceiver = Address
originatorAddr
, tdAmount :: Mutez
tdAmount = Mutez
odBalance
, tdEpName :: EpName
tdEpName = EntrypointRef ('Just "run_lambda") -> EpName
forall (mname :: Maybe Symbol). EntrypointRef mname -> EpName
eprName (EntrypointRef ('Just "run_lambda") -> EpName)
-> EntrypointRef ('Just "run_lambda") -> EpName
forall a b. (a -> b) -> a -> b
$ NiceEntrypointName "run_lambda" =>
EntrypointRef ('Just "run_lambda")
forall (name :: Symbol).
NiceEntrypointName name =>
EntrypointRef ('Just name)
Call @"run_lambda"
, tdParam :: Value 'TUnit
tdParam = Value 'TUnit
forall (instr :: [T] -> [T] -> *). Value' instr 'TUnit
VUnit
, tdMbFee :: Maybe Mutez
tdMbFee = Maybe Mutez
odMbFee
}
mkLoadLambda :: ByteString -> TransactionData
mkLoadLambda ByteString
bytes = ParameterScope 'TBytes =>
TD (Value' Instr 'TBytes) -> TransactionData
forall (t :: T).
ParameterScope t =>
TD (Value t) -> TransactionData
TransactionData @'T.TBytes (TD (Value' Instr 'TBytes) -> TransactionData)
-> TD (Value' Instr 'TBytes) -> TransactionData
forall a b. (a -> b) -> a -> b
$ TD :: forall t. Address -> Mutez -> EpName -> t -> Maybe Mutez -> TD t
TD
{ tdReceiver :: Address
tdReceiver = Address
originatorAddr
, tdAmount :: Mutez
tdAmount = Word32 -> Mutez
toMutez Word32
0
, tdEpName :: EpName
tdEpName = EntrypointRef ('Just "load_lambda") -> EpName
forall (mname :: Maybe Symbol). EntrypointRef mname -> EpName
eprName (EntrypointRef ('Just "load_lambda") -> EpName)
-> EntrypointRef ('Just "load_lambda") -> EpName
forall a b. (a -> b) -> a -> b
$ NiceEntrypointName "load_lambda" =>
EntrypointRef ('Just "load_lambda")
forall (name :: Symbol).
NiceEntrypointName name =>
EntrypointRef ('Just name)
Call @"load_lambda"
, tdParam :: Value' Instr 'TBytes
tdParam = ByteString -> Value' Instr 'TBytes
forall (instr :: [T] -> [T] -> *).
ByteString -> Value' instr 'TBytes
VBytes ByteString
bytes
, tdMbFee :: Maybe Mutez
tdMbFee = Maybe Mutez
odMbFee
}
in ([TransactionData] -> Element [ByteString] -> [TransactionData])
-> [TransactionData] -> [ByteString] -> [TransactionData]
forall t b. Container t => (b -> Element t -> b) -> b -> t -> b
foldl' (\[TransactionData]
lst Element [ByteString]
bytes -> ByteString -> TransactionData
mkLoadLambda ByteString
Element [ByteString]
bytes TransactionData -> [TransactionData] -> [TransactionData]
forall a. a -> [a] -> [a]
: [TransactionData]
lst) [TransactionData
doRunLambda] [ByteString]
lambdaChunks
retrieveLargeContracts
:: (HasTezosRpc m, HasTezosClient m)
=> Address -> OriginationData -> m Address
retrieveLargeContracts :: Address -> OriginationData -> m Address
retrieveLargeContracts Address
originatorAddr OriginationData{Bool
Maybe Mutez
Mutez
Value st
Contract cp st
AliasHint
odMbFee :: Maybe Mutez
odStorage :: Value st
odContract :: Contract cp st
odBalance :: Mutez
odName :: AliasHint
odReplaceExisting :: Bool
odMbFee :: OriginationData -> Maybe Mutez
odStorage :: ()
odContract :: ()
odBalance :: OriginationData -> Mutez
odName :: OriginationData -> AliasHint
odReplaceExisting :: OriginationData -> Bool
..} = do
Expression
expr <- Address -> m Expression
forall (m :: * -> *). HasTezosRpc m => Address -> m Expression
getContractStorage Address
originatorAddr
let completedStore :: Either FromExpressionError (Value (LargeOriginatorStore 'TUnit))
completedStore = Expression
-> Either FromExpressionError (Value (LargeOriginatorStore 'TUnit))
forall a.
FromExpression a =>
Expression -> Either FromExpressionError a
fromExpression @(Value (LargeOriginatorStore 'T.TUnit)) Expression
expr
case Either FromExpressionError (Value (LargeOriginatorStore 'TUnit))
completedStore of
Right (VPair (Value' Instr l
_, VOr (Left Value' Instr l
largeVAddr))) -> do
let largeAddr :: Address
largeAddr = Value (ToT Address) -> Address
forall a. IsoValue a => Value (ToT a) -> a
fromVal @Address Value' Instr l
Value (ToT Address)
largeVAddr
Bool -> Address -> AliasOrAliasHint -> m ()
forall (m :: * -> *).
HasTezosClient m =>
Bool -> Address -> AliasOrAliasHint -> m ()
rememberContract Bool
odReplaceExisting Address
largeAddr (AliasHint -> AliasOrAliasHint
AnAliasHint AliasHint
odName)
pure Address
largeAddr
Either FromExpressionError (Value (LargeOriginatorStore 'TUnit))
_ -> IncorrectRpcResponse -> m Address
forall (m :: * -> *) e a. (MonadThrow m, Exception e) => e -> m a
throwM IncorrectRpcResponse
RpcOriginatedNoContracts