Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions to originate large smart contracts via tezos-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
- data LargeOriginationData = LargeOriginationData {}
- data SomeLargeContractOriginator where
- SomeLargeContractOriginator :: forall heavy. StorageScope heavy => Value heavy -> Contract LargeOriginatorParam (LargeOriginatorStore heavy) -> Value (ToT (Lambda (Value heavy) (Address, [Operation]))) -> SomeLargeContractOriginator
- mkLargeOriginationData :: OriginationData -> LargeOriginationData
- mkSomeLargeContractOriginator :: (ParameterScope param, StorageScope store) => Value store -> Contract param store -> Mutez -> SomeLargeContractOriginator
- type LargeOriginatorParam = 'TOr 'TBytes 'TUnit
- type LargeOriginatorStore heavy = 'TPair 'TAddress ('TOr 'TAddress ('TPair 'TBytes heavy))
- largeContractOriginator :: StorageScope heavy => Contract LargeOriginatorParam (LargeOriginatorStore heavy)
- divideValueInChunks :: ConstantScope val => Value val -> [ByteString]
- mkOriginationLambda :: (ParameterScope param, StorageScope store, StorageScope heavy) => Instr '[heavy] '[store] -> Contract param store -> Mutez -> Value (ToT (Lambda (Value heavy) (Address, [Operation])))
- mkLargeOriginatorStore :: StorageScope heavy => Value heavy -> Address -> Value (LargeOriginatorStore heavy)
- mkLargeOriginatorData :: Address -> LargeOriginationData -> OriginationData
- mkLargeOriginatorTransactions :: Address -> LargeOriginationData -> [TransactionData]
- retrieveLargeContracts :: (HasTezosRpc m, HasTezosClient m) => Address -> OriginationData -> m Address
Documentation
data LargeOriginationData Source #
Just a utility type to hold SomeLargeContractOriginator
and its large
contract OriginationData
.
data SomeLargeContractOriginator where Source #
Contains the 'Value heavy' with all the large contract big_map
s
and ticket
s, the largeContractOriginator
for it as well as the lambda
to use there.
SomeLargeContractOriginator :: forall heavy. StorageScope heavy => Value heavy -> Contract LargeOriginatorParam (LargeOriginatorStore heavy) -> Value (ToT (Lambda (Value heavy) (Address, [Operation]))) -> SomeLargeContractOriginator |
mkSomeLargeContractOriginator Source #
:: (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.
:: (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 -> Address -> Value (LargeOriginatorStore heavy) Source #
Helper to create a LargeOriginatorStore
Value
.
mkLargeOriginatorData :: Address -> LargeOriginationData -> OriginationData Source #
Makes OriginationData
of the largeContractOriginator
that will generate
the large contract of the given OriginationData
for the sender Address
.
mkLargeOriginatorTransactions :: Address -> LargeOriginationData -> [TransactionData] Source #
Makes all the TransactionData
to feed the origination lambda into a
largeContractOriginator
from the Address
of the latter.
retrieveLargeContracts :: (HasTezosRpc m, HasTezosClient m) => Address -> OriginationData -> m Address Source #
Fetches back the Address
of the large contract generated by a completed
largeContractOriginator
process.
It also uses the large contract OriginationData
to associate it to the
expected alias.