diff --git a/README.md b/README.md index be05249..dbecf22 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Metaprogramming for Ethereum Smart Contracts expressed in Scala's Type System. -- Unlock Smart Contracts **adoption with JVM**-based language: code them _from_ Scala or _in_ Scala +- Unlock Smart Contracts **adoption with a JVM**-based language: code them _from_ Scala or _in_ Scala - Smart Contracts code generator is itself **a strictly typed program** - Write a Contract using structs and definitions of **Crotalinae DSL**, and if it compiles, you're **safe** - **Export** Smart Contract in [Vyper](https://github.com/ethereum/vyper) as a single plaintext and check it visually if needed diff --git a/core/src/main/scala/fluence/hackethberlin/types/ProductType.scala b/core/src/main/scala/fluence/hackethberlin/types/ProductType.scala index d497df5..157e5fd 100644 --- a/core/src/main/scala/fluence/hackethberlin/types/ProductType.scala +++ b/core/src/main/scala/fluence/hackethberlin/types/ProductType.scala @@ -5,10 +5,10 @@ import fluence.hackethberlin.{Expr, FuncDef, InlineExpr} import shapeless._ import shapeless.ops.record.Selector -class ProductType[D <: HList](dataDef: D, dv: DataVyper[D]) extends Type { +class ProductType[D <: HList](dataDef: D, refPrefix: String, dv: DataVyper[D]) extends Type { def ref[T <: Symbol, V <: Type](k: Witness.Aux[T])(implicit selector: Selector.Aux[D, T, V]): Expr.Ref[V] = - Expr.Ref[V](k.value.name, selector(dataDef)) + Expr.Ref[V](refPrefix + k.value.name, selector(dataDef)) // type in type definition somewhere override def toVyper: String = @@ -35,7 +35,10 @@ class ProductType[D <: HList](dataDef: D, dv: DataVyper[D]) extends Type { object ProductType { def apply[D <: HList](dataDef: D)(implicit dv: DataVyper[D]): ProductType[D] = - new ProductType[D](dataDef, dv) + new ProductType[D](dataDef, "", dv) + + def self[D <: HList](dataDef: D)(implicit dv: DataVyper[D]): ProductType[D] = + new ProductType[D](dataDef, "self.", dv) def hNil: ProductType[HNil] = ProductType(HNil) } diff --git a/src/main/scala/fluence/MakeVyperApp.scala b/src/main/scala/fluence/MakeVyperApp.scala index e12af31..8f38a11 100644 --- a/src/main/scala/fluence/MakeVyperApp.scala +++ b/src/main/scala/fluence/MakeVyperApp.scala @@ -87,7 +87,7 @@ object Auction extends App { val `msg.sender` = predef.ref(Symbol("msg.sender")) val `True` = predef.ref('True) - val data = ProductType( + val data = ProductType.self( ('beneficiary ->> public(address)) :: ('auction_start ->> public(timestamp)) :: ('auction_end ->> public(timestamp)) ::