mirror of https://github.com/status-im/nimplay.git
Merge branch 'master' into nlvm-makefiles
This commit is contained in:
commit
66719ca476
|
@ -1,7 +1,4 @@
|
|||
import ../nimplay/nimplay_macros
|
||||
import ../nimplay/types
|
||||
import ../nimplay/ewasm_eei
|
||||
import stint
|
||||
import ../nimplay0_1
|
||||
|
||||
|
||||
contract("KingOfTheHill"):
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import ../nimplay/nimplay_macros
|
||||
import ../nimplay/types
|
||||
import ../nimplay/ewasm_eei
|
||||
import stint
|
||||
|
||||
|
||||
contract("PayAssert"):
|
||||
|
||||
proc plus_two*(a: uint256): uint256 {.payable.} =
|
||||
a + 2
|
||||
|
||||
proc plus_one*(a: uint256): uint256 =
|
||||
a + 1
|
|
@ -18,10 +18,10 @@ proc buildTool(name: string) =
|
|||
|
||||
|
||||
task examples, "Build examples":
|
||||
buildExample("wrc20")
|
||||
buildExample("wrc202")
|
||||
# buildExample("wrc20")
|
||||
# buildExample("wrc202")
|
||||
buildExample("king_of_the_hill")
|
||||
# buildExample("hello")
|
||||
# buildExample("payable")
|
||||
# buildExample("hello2")
|
||||
# buildExample("hello3")
|
||||
|
||||
|
|
|
@ -209,11 +209,21 @@ proc handle_event_defines(event_def: NimNode, global_ctx: var GlobalContext) =
|
|||
|
||||
|
||||
proc get_util_functions(): NimNode =
|
||||
parseStmt("""
|
||||
var stmts = newStmtList()
|
||||
|
||||
stmts.add(parseStmt("""
|
||||
template copy_into_ba(to_ba: var untyped, offset: int, from_ba: untyped) =
|
||||
for i, x in from_ba:
|
||||
to_ba[offset + i] = x
|
||||
""")
|
||||
"""))
|
||||
stmts.add(parseStmt("""
|
||||
proc assertNotPayable() =
|
||||
var b {.noinit.}: array[16, byte]
|
||||
getCallValue(addr b)
|
||||
if Uint128.fromBytesBE(b) > 0.stuint(128):
|
||||
revert(nil, 0)
|
||||
"""))
|
||||
stmts # return
|
||||
|
||||
|
||||
proc get_getter_func(var_struct: VariableType): NimNode =
|
||||
|
@ -315,6 +325,9 @@ proc handle_contract_interface(in_stmts: NimNode): NimNode =
|
|||
)
|
||||
var start_offset = 4
|
||||
|
||||
if not func_sig.payable:
|
||||
call_and_copy_block.add(parseStmt("assertNotPayable()"))
|
||||
|
||||
for idx, param in func_sig.inputs:
|
||||
var static_param_size = get_byte_size_of(param.var_type)
|
||||
var tmp_var_name = fmt"{func_sig.name}_param_{idx}"
|
||||
|
|
|
@ -62,6 +62,7 @@ proc get_byte_size_of*(type_str: string): int =
|
|||
let BASE32_TYPES_NAMES: array = [
|
||||
"uint256",
|
||||
"uint128",
|
||||
"int128",
|
||||
"address",
|
||||
"bytes32",
|
||||
"wei_value"
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import nimplay/nimplay_macros
|
||||
import nimplay/types
|
||||
import nimplay/ewasm_eei
|
||||
import stint
|
||||
|
||||
export nimplay_macros
|
||||
export types
|
||||
export ewasm_eei
|
||||
export stint
|
Loading…
Reference in New Issue