All Downloads are FREE. Search and download functionalities are using the official Maven repository.

form.lang.1.5.7.source-code.fomo.ride Maven / Gradle / Ivy

The newest version!
{-# STDLIB_VERSION 3 #-}
{-# CONTENT_TYPE DAPP -#}

let lpKey = "lastPayment"
let liKey = "bestFomoer"
let lhKey = "height"
let day = 1440

@Callable(i)
func fearmissing() = {
   let payment = match i.payment {
	   case p:AttachedPayment =>
	   		match p.asset {
				   case asset: ByteVector => throw("fomo waves only")
				   case _ => p.amount
			   }

	   case _ => throw("payment must be attached")
   }
	let lastPayment = match getInteger(this, "lastPayment") {
		case p:Int => p
		case _ => 0
	}

	if(payment <= lastPayment)
		then throw("min payment is " +toString(payment))
		else # storing best payment, caller and height
			WriteSet([
				DataEntry(lpKey, payment),
				DataEntry(liKey, i.caller.bytes),
				DataEntry(lhKey, height)
			])
}

@Callable(i)
func withdraw() = {
	let callerCorrect = i.caller.bytes == extract(getBinary(this, liKey))
	let heightCorrect = extract(getInteger(this, lhKey)) - height >= day
	let canWithdraw = heightCorrect && callerCorrect

	if (canWithdraw)
		then TransferSet([ScriptTransfer(i.caller, wavesBalance(this), unit)])
		else throw("behold")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy