morley-client-0.3.0: Client to interact with the Tezos blockchain
Safe HaskellSafe-Inferred
LanguageHaskell2010

Morley.Client.Action.Origination.Large

Description

Functions to originate large smart contracts via octez-client and node RPC.

This is based on a workaround leveraging the lack of gas cost limits on internal transactions produced by CREATE_CONTRACT.

So, in brief, we cannot directly originate a contract that's too large, but we can originate a small "originator" contract, progressively load a packed lambda into it in chunks and finally unpack and execute it, which will run the actual large contract origination.

Synopsis

Documentation

data SomeLargeContractOriginator where Source #

Contains the 'Value heavy' with all the large contract big_maps and tickets, the largeContractOriginator for it as well as the lambda to use there.

Constructors

SomeLargeContractOriginator :: forall heavy. StorageScope heavy => Value heavy -> Contract LargeOriginatorParam (LargeOriginatorStore heavy) -> Value (ToT (Lambda (Value heavy) (Address, [Operation]))) -> SomeLargeContractOriginator 

mkSomeLargeContractOriginator Source #

Arguments

:: (ParameterScope param, StorageScope store) 
=> Value store

initial storage of the large contract

-> Contract param store

large contract

-> Mutez

balance to tranfer during contract creation

-> SomeLargeContractOriginator 

Originator contract

type LargeOriginatorParam = 'TOr 'TBytes 'TUnit Source #

Parameter of the originator contract.

type LargeOriginatorStore heavy = 'TPair 'TAddress ('TOr 'TAddress ('TPair 'TBytes heavy)) Source #

Storage of the originator contract.

largeContractOriginator :: StorageScope heavy => Contract LargeOriginatorParam (LargeOriginatorStore heavy) Source #

Large Originator contract.

Only keeps track of the "owner" address and either - the heavy entries and packed lambda to do the generation (if still loading), or - the resulting address of the originated large contract.

If the large contract was originated any call will result in a failure containing its address. Any call from an address that's not the "owner" will result in a failure.

Origination lambda

divideValueInChunks :: ConstantScope val => Value val -> [ByteString] Source #

Returns bytes that fit into transaction limits from mkOriginationLambda.

Note: these have the original order, meaning they should be given to the originator contract from last to first.

mkOriginationLambda Source #

Arguments

:: (ParameterScope param, StorageScope store, StorageScope heavy) 
=> Instr '[heavy] '[store]

instruction to recreate the initial storage

-> Contract param store

large contract

-> Mutez

balance to tranfer during contract creation

-> Value (ToT (Lambda (Value heavy) (Address, [Operation]))) 

Generates the lambda to originate a large contract.

Utilities

mkLargeOriginatorStore :: StorageScope heavy => Value heavy -> ImplicitAddress -> Value (LargeOriginatorStore heavy) Source #

Helper to create a LargeOriginatorStore Value.

mkLargeOriginatorData :: ImplicitAddress -> LargeOriginationData -> OriginationData Source #

Makes OriginationData of the largeContractOriginator that will generate the large contract of the given OriginationData for the sender ImplicitAddress.

mkLargeOriginatorTransactions :: ContractAddress -> LargeOriginationData -> [TransactionData] Source #

Makes all the TransactionData to feed the origination lambda into a largeContractOriginator from the ContractAddress of the latter.

retrieveLargeContracts :: (HasTezosRpc m, HasTezosClient m) => ContractAddress -> OriginationData -> m ContractAddress Source #

Fetches back the ContractAddress of the large contract generated by a completed largeContractOriginator process.

It also uses the large contract OriginationData to associate it to the expected alias.