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