diff --git a/ethers/contract.nim b/ethers/contract.nim index 37a93e2..ee2c5f4 100644 --- a/ethers/contract.nim +++ b/ethers/contract.nim @@ -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] diff --git a/testmodule/testContracts.nim b/testmodule/testContracts.nim index 720db2b..144be6f 100644 --- a/testmodule/testContracts.nim +++ b/testmodule/testContracts.nim @@ -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":