Fix for abi_gen payable.

This commit is contained in:
Jacques Wagener 2019-09-13 12:37:24 +02:00
parent 39f4294d2a
commit 1201dc828b
No known key found for this signature in database
GPG Key ID: C294D1025DA0E923
3 changed files with 38 additions and 8 deletions

View File

@ -61,12 +61,12 @@ vendors:
.PHONY: king_of_the_hill
king_of_the_hill:
# $(WASM32_NIMC) --out:examples/king_of_the_hill.wasm examples/king_of_the_hill.nim
# $(POSTPROCESS) examples/king_of_the_hill.wasm
# $(WASM32_NIMC) --out:examples/map.wasm examples/map.nim
# $(POSTPROCESS) examples/map.wasm
$(WASM32_NIMC) --out:examples/balances.wasm examples/balances.nim
$(POSTPROCESS) examples/balances.wasm
$(WASM32_NIMC) --out:examples/king_of_the_hill.wasm examples/king_of_the_hill.nim
$(POSTPROCESS) examples/king_of_the_hill.wasm
.PHONY: examples
examples: king_of_the_hill
$(WASM32_NIMC) --out:examples/registry.wasm examples/registry.nim
$(POSTPROCESS) examples/registry.wasm
$(WASM32_NIMC) --out:examples/balances.wasm examples/balances.nim
$(POSTPROCESS) examples/balances.wasm

29
examples/balances.nim Normal file
View File

@ -0,0 +1,29 @@
import ../nimplay0_1
contract("Depository"):
balances: StorageTable[address, bytes32, wei_value]
proc deposit*(k: bytes32) {.self,msg,payable.} =
self.balances[msg.sender][k] = msg.value
proc get_balance*(k: bytes32): wei_value {.self,msg.} =
self.balances[msg.sender][k]
# proc withdraw*(amount: wei_value) =
# var
# balance = self.balances[msg.sender][k]
# if amount <= balance:
# self.balances[msg.sender][k] =
# call(
# getGasLeft(),
# addr msg.sender
# amount,
# )
# proc call*(gas: int64, addressOffset, valueOffset, dataOffset: pointer,
# dataLength: int32, resultOffset: pointer,
# resultLength: int32): int32

View File

@ -91,8 +91,9 @@ proc generate_function_signature(proc_def: PNode): FunctionSignature =
else:
raise newException(Exception, "unknown param type")
of nkPragma:
if child[0].kind == nkIdent and child[0].ident.s == "payable":
func_sig.payable = true
for pragma_child in child:
if pragma_child.kind == nkIdent and pragma_child.ident.s == "payable":
func_sig.payable = true
else:
discard
return func_sig