mirror of
https://github.com/fluencelabs/hackethberlin
synced 2025-04-24 08:52:18 +00:00
summirizing contract
This commit is contained in:
parent
c3f30a2b71
commit
31d4d171ca
@ -115,6 +115,19 @@ object Expr {
|
||||
|
||||
object Defs extends Defs {
|
||||
|
||||
import types._
|
||||
import syntax.singleton._
|
||||
|
||||
val send =
|
||||
ProductType(('_addr ->> `public`(address)) :: ('_money ->> `public`(wei_value)) :: HNil).funcDef(
|
||||
"send",
|
||||
Void
|
||||
) { args ⇒
|
||||
for {
|
||||
_ <- Free.pure(Void)
|
||||
} yield Void
|
||||
}
|
||||
|
||||
val predef = ProductType(
|
||||
(Symbol("block.timestamp") ->> timestamp) ::
|
||||
(Symbol("msg.value") ->> wei_value) ::
|
||||
|
@ -47,18 +47,4 @@ object FuncDef {
|
||||
mapped: ops.hlist.Mapped[_Values, InlineExpr]
|
||||
)(implicit values: ops.record.Values.Aux[Args, _Values]): FuncDef[Args, types.Void, mapped.Out] =
|
||||
new FuncDef(name, ProductType(argsDef), types.Void, args ⇒ body(args).map(_ ⇒ types.Void))
|
||||
|
||||
import types._
|
||||
import syntax.singleton._
|
||||
|
||||
val send = {
|
||||
ProductType(('_addr ->> `public`(address)) :: ('_money ->> `public`(wei_value)) :: HNil).funcDef(
|
||||
"send",
|
||||
Void
|
||||
) { args ⇒
|
||||
for {
|
||||
_ <- Free.pure(Void)
|
||||
} yield Void
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import hackethberlin.types._
|
||||
import shapeless._
|
||||
import Decorator._
|
||||
import syntax.singleton._
|
||||
import cats.free.Free
|
||||
import fluence.hackethberlin.{Contract, Expr, FuncDef}
|
||||
import fluence.hackethberlin.types.{`public`, ProductType, Void}
|
||||
import shapeless.HNil
|
||||
@ -39,7 +38,6 @@ object Auction extends App {
|
||||
Void
|
||||
) { args ⇒
|
||||
for {
|
||||
_ <- Free.pure(Void)
|
||||
_ <- beneficiary :=: _beneficiary
|
||||
_ <- auction_start :=: `block.timestamp`
|
||||
_ <- auction_end :=: `+:+`(auction_start, _bidding_time)
|
||||
@ -55,9 +53,7 @@ object Auction extends App {
|
||||
_ <- `assert`(`>>`(`msg.value`, highest_bid))
|
||||
_ <- `if`(`not`(`:===:`(highest_bid, `msg.value`)), {
|
||||
() =>
|
||||
for {
|
||||
_ <- FuncDef.send(highest_bidder :: highest_bid :: HNil).liftF
|
||||
} yield Void
|
||||
send(highest_bidder :: highest_bid :: HNil).liftF.map(_ => Void)
|
||||
})
|
||||
_ <- highest_bidder :=: `msg.sender`
|
||||
_ <- highest_bid :=: `msg.value`
|
||||
@ -72,7 +68,7 @@ object Auction extends App {
|
||||
_ <- `assert`(`>=`(`block.timestamp`, auction_end))
|
||||
_ <- `assert`(`not`(ended))
|
||||
_ <- ended :=: `True`
|
||||
_ <- FuncDef.send(beneficiary :: highest_bid :: HNil).liftF
|
||||
_ <- send(beneficiary :: highest_bid :: HNil).liftF.map(_ => Void)
|
||||
} yield Void
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user