packages feed

cleveland-0.1.1: test/TestSuite/Cleveland/Lorentz/Contracts/ContractAllocator.hs

-- SPDX-FileCopyrightText: 2021 Oxhead Alpha
-- SPDX-License-Identifier: LicenseRef-MIT-OA

module TestSuite.Cleveland.Lorentz.Contracts.ContractAllocator
  ( allocatorContract
  ) where

import Lorentz as L

import Test.Cleveland.Instances ()

allocatorContract :: Contract [Address] Storage ()
allocatorContract = defaultContract allocatorContractLorentz

type Storage = ("storage" :! [Address])

allocatorContractLorentz :: ContractCode [Address] Storage
allocatorContractLorentz =
  unpair #
  dip (nil @Operation) #
  iter (
    unsafeContractCalling @() DefEpName #
    whenSome
      (push 1 # unit # transferTokens # cons)
    ) #
  unit # push 0 # none @KeyHash #
  createContract @() @() (defaultContract failWith) #
  dip L.drop #
  cons #
  pair