Allow contract procs to be exported

This commit is contained in:
Mark Spanbroek 2022-01-20 14:00:28 +01:00
parent 04ff046553
commit 2140084d97
2 changed files with 7 additions and 6 deletions

View File

@ -47,14 +47,15 @@ func getParameterTuple(procedure: var NimNode): NimNode =
return tupl
func addContractCall(procedure: var NimNode) =
let name = $procedure[0]
let name = procedure[0]
let function = if name.kind == nnkPostfix: $name[1] else: $name
let parameters = procedure[3]
let contract = parameters[1][0]
let contracttype = parameters[1][1]
let resulttype = parameters[0]
let tupl = getParameterTuple(procedure)
procedure[6] = quote do:
result = await call[`contracttype`,`resulttype`](`contract`, `name`, `tupl`)
return await call[`contracttype`,`resulttype`](`contract`, `function`, `tupl`)
func addFuture(procedure: var NimNode) =
let returntype = procedure[3][0]

View File

@ -4,12 +4,12 @@ import pkg/ethers
import ./hardhat
type
Erc20 = ref object of Contract
Erc20* = ref object of Contract
TestToken = ref object of Erc20
method totalSupply(erc20: Erc20): UInt256 {.base, contract.}
method balanceOf(erc20: Erc20, account: Address): UInt256 {.base, contract.}
method allowance(erc20: Erc20, owner, spender: Address): UInt256 {.base, contract.}
method totalSupply*(erc20: Erc20): UInt256 {.base, contract.}
method balanceOf*(erc20: Erc20, account: Address): UInt256 {.base, contract.}
method allowance*(erc20: Erc20, owner, spender: Address): UInt256 {.base, contract.}
suite "Contracts":