2018-09-08 17:34:35 +02:00
|
|
|
package fluence
|
2018-09-07 19:46:53 +02:00
|
|
|
|
2018-09-08 17:34:35 +02:00
|
|
|
import hackethberlin._
|
|
|
|
import hackethberlin.types._
|
2018-09-07 19:46:53 +02:00
|
|
|
import shapeless._
|
2018-09-08 11:42:13 +02:00
|
|
|
import Decorator._
|
2018-09-09 08:45:56 +03:00
|
|
|
import cats.free.Free
|
2018-09-08 12:45:46 +02:00
|
|
|
import syntax.singleton._
|
2018-09-07 19:46:53 +02:00
|
|
|
|
|
|
|
object MakeVyperApp extends App {
|
|
|
|
|
2018-09-08 15:04:58 +02:00
|
|
|
val struct = ProductType(
|
2018-09-08 12:45:46 +02:00
|
|
|
('address ->> address) ::
|
|
|
|
('owner ->> address) ::
|
|
|
|
('size ->> uint256) ::
|
|
|
|
('time ->> int128) :: HNil
|
2018-09-07 19:46:53 +02:00
|
|
|
)
|
|
|
|
|
2018-09-08 15:04:58 +02:00
|
|
|
val data = ProductType(
|
2018-09-08 12:45:46 +02:00
|
|
|
('address ->> address) ::
|
|
|
|
('owner ->> `public`(address)) ::
|
|
|
|
('holders ->> (address ~>> bool)) ::
|
|
|
|
('structMap ->> `public`(uint256 ~>> struct)) ::
|
|
|
|
('struct ->> `public`(struct)) ::
|
|
|
|
('struct2 ->> struct) :: HNil
|
2018-09-08 00:12:56 +02:00
|
|
|
)
|
|
|
|
|
2018-09-08 12:03:18 +02:00
|
|
|
val func = FuncDef(
|
2018-09-08 11:42:13 +02:00
|
|
|
"myFunc",
|
2018-09-08 14:40:32 +02:00
|
|
|
('addr ->> address) :: HNil,
|
|
|
|
address
|
2018-09-08 17:06:02 +02:00
|
|
|
)(args ⇒ args.ref('addr).toReturn)
|
2018-09-08 12:45:46 +02:00
|
|
|
|
2018-09-08 15:04:58 +02:00
|
|
|
val recordStruct = ProductType(
|
2018-09-08 12:45:46 +02:00
|
|
|
('record_address ->> address) :: ('other_some ->> uint256) :: HNil
|
|
|
|
)
|
|
|
|
|
2018-09-08 14:40:32 +02:00
|
|
|
println(Console.RED + recordStruct.ref('other_some) + Console.RESET)
|
2018-09-08 13:18:56 +02:00
|
|
|
|
2018-09-08 12:45:46 +02:00
|
|
|
println(recordStruct.toVyper)
|
|
|
|
|
2018-09-08 15:04:58 +02:00
|
|
|
println(data.toDataVyper)
|
2018-09-07 19:46:53 +02:00
|
|
|
|
2018-09-08 11:42:13 +02:00
|
|
|
println(func.toVyper)
|
|
|
|
|
2018-09-08 16:39:58 +02:00
|
|
|
val sumArgs = ProductType(('a ->> uint256) :: ('b ->> uint256) :: HNil)
|
|
|
|
|
|
|
|
import Expr.Defs._
|
|
|
|
|
2018-09-08 19:01:12 +03:00
|
|
|
val f = `@public` @:
|
|
|
|
sumArgs.funcDef("sum", uint256) { args ⇒
|
2018-09-08 19:25:38 +02:00
|
|
|
for {
|
|
|
|
c ← 'c :=: `++`(args.ref('a), args.ref('b))
|
|
|
|
d ← 'd :=: `++`(args.ref('b), c)
|
2018-09-09 08:05:04 +02:00
|
|
|
_ ← d :=: c
|
2018-09-08 19:25:38 +02:00
|
|
|
sum ← `++`(args.ref('a), d).toReturn
|
|
|
|
} yield sum
|
|
|
|
}
|
2018-09-08 19:01:12 +03:00
|
|
|
|
|
|
|
val all = recordStruct :: data :: func :: f :: HNil
|
|
|
|
|
|
|
|
val c = new Contract(recordStruct :: struct :: data :: func :: f :: HNil)
|
|
|
|
|
|
|
|
println(c.toVyper)
|
2018-09-08 11:42:13 +02:00
|
|
|
|
2018-09-08 19:20:15 +02:00
|
|
|
println(
|
|
|
|
func(recordStruct.ref('record_address) :: HNil).toVyper
|
|
|
|
)
|
|
|
|
|
2018-09-08 23:08:06 +02:00
|
|
|
// println(s"MMMMMACRO\n\n ${new MyContract("abc", 123).toAST.toVyper}")
|
2018-09-08 12:45:46 +02:00
|
|
|
}
|
2018-09-09 08:45:56 +03:00
|
|
|
|
|
|
|
object Auction {
|
2018-09-09 08:05:04 +02:00
|
|
|
|
2018-09-09 08:45:56 +03:00
|
|
|
val data = ProductType(
|
|
|
|
('beneficiary ->> public(address)) ::
|
|
|
|
('auction_start ->> public(timestamp)) ::
|
|
|
|
('auction_end ->> public(timestamp)) ::
|
|
|
|
('highest_bidder ->> `public`(address)) ::
|
|
|
|
('highest_bid ->> `public`(wei_value)) ::
|
|
|
|
('ended ->> public(bool)) :: HNil
|
|
|
|
)
|
|
|
|
|
|
|
|
val beneficiary = data.ref('beneficiary)
|
|
|
|
val auction_start = data.ref('auction_start)
|
|
|
|
val auction_end = data.ref('auction_end)
|
|
|
|
val highest_bid = data.ref('highest_bid)
|
|
|
|
|
|
|
|
val initArgs = ProductType(('_beneficiary ->> address) :: ('_bidding_time ->> timedelta) :: HNil)
|
|
|
|
|
|
|
|
import untag._
|
|
|
|
|
|
|
|
val _beneficiary = initArgs.ref('_beneficiary)
|
|
|
|
val _bidding_time = initArgs.ref('_bidding_time)
|
|
|
|
|
|
|
|
println(_beneficiary.getClass)
|
|
|
|
|
|
|
|
val init = `@public` @: initArgs.funcDef(
|
|
|
|
"__init__",
|
|
|
|
Void
|
|
|
|
) { args ⇒
|
|
|
|
for {
|
2018-09-09 08:05:04 +02:00
|
|
|
_ <- Free.pure(Void)
|
|
|
|
_ <- beneficiary :=: _beneficiary
|
2018-09-09 08:45:56 +03:00
|
|
|
// _ <- auction_start :==: block.timestamp
|
|
|
|
// _ <- auction_end :==: auction_start `+:+` _bidding_time
|
|
|
|
} yield Void
|
|
|
|
}
|
|
|
|
|
2018-09-09 08:05:04 +02:00
|
|
|
/*val bid = `@public` @: `@payable` @: ProductType(HNil).funcDef(
|
2018-09-09 08:45:56 +03:00
|
|
|
"bid",
|
|
|
|
Void
|
|
|
|
) { args ⇒
|
|
|
|
for {
|
|
|
|
_ <- Free.pure(Void)
|
2018-09-09 08:05:04 +02:00
|
|
|
_ <- `assertt`(block.timestamp `<` auction_end)
|
|
|
|
_ <- `assertt`(msg.value `>` highest_bid)
|
2018-09-09 08:45:56 +03:00
|
|
|
} yield Void
|
2018-09-09 08:05:04 +02:00
|
|
|
}*/
|
|
|
|
}
|