silence spurious warnings

This commit is contained in:
jangko 2020-07-15 10:03:36 +07:00
parent fd8b5de13c
commit b29311a9d0
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 21 additions and 15 deletions

4
nim.cfg Normal file
View File

@ -0,0 +1,4 @@
# nim.cfg
@if nimHasWarningObservableStores:
warning[ObservableStores]: off
@end

View File

@ -5,6 +5,8 @@
# * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) # * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
# at your option. This file may not be copied, modified, or distributed except according to those terms. # at your option. This file may not be copied, modified, or distributed except according to those terms.
{. warning[UnusedImport]:off .}
import import
test, test,
test_deposit_contract, test_deposit_contract,

View File

@ -44,7 +44,7 @@ type
historicalEventsProcessed: bool historicalEventsProcessed: bool
removed: bool removed: bool
ContractCallBase = object {.pure, inheritable.} ContractCallBase {.pure, inheritable.} = object
web3: Web3 web3: Web3
data: string data: string
to: Address to: Address
@ -220,10 +220,10 @@ func encode*[N](x: DynamicBytes[N]): EncodeResult {.inline.} =
func decodeDynamic(input: string, offset: int, to: var openarray[byte]): int = func decodeDynamic(input: string, offset: int, to: var openarray[byte]): int =
var dataOffset, dataLen: UInt256 var dataOffset, dataLen: UInt256
result = decode(input, offset, dataOffset) result = decode(input, offset, dataOffset)
discard decode(input, dataOffset.toInt * 2, dataLen) discard decode(input, dataOffset.truncate(int) * 2, dataLen)
# TODO: Check data len, and raise? # TODO: Check data len, and raise?
let meaningfulLen = to.len * 2 let meaningfulLen = to.len * 2
let actualDataOffset = (dataOffset.toInt + 32) * 2 let actualDataOffset = (dataOffset.truncate(int) + 32) * 2
hexToByteArray(input[actualDataOffset .. actualDataOffset + meaningfulLen - 1], to) hexToByteArray(input[actualDataOffset .. actualDataOffset + meaningfulLen - 1], to)
func decode*[N](input: string, offset: int, to: var DynamicBytes[N]): int {.inline.} = func decode*[N](input: string, offset: int, to: var DynamicBytes[N]): int {.inline.} =
@ -483,17 +483,17 @@ proc parseContract(body: NimNode): seq[InterfaceObject] =
doAssert(procdef.kind == nnkProcDef, doAssert(procdef.kind == nnkProcDef,
"Contracts can only be built with procedures") "Contracts can only be built with procedures")
let let
isconstructor = procdef[4].findChild(it.ident == !"constructor") != nil isconstructor = procdef[4].findChild(it.strVal == "constructor") != nil
isevent = procdef[4].findChild(it.ident == !"event") != nil isevent = procdef[4].findChild(it.strVal == "event") != nil
doAssert(not (isconstructor and constructor.isSome), doAssert(not (isconstructor and constructor.isSome),
"Contract can only have a single constructor") "Contract can only have a single constructor")
doAssert(not (isconstructor and isevent), doAssert(not (isconstructor and isevent),
"Can't be both event and constructor") "Can't be both event and constructor")
if not isevent: if not isevent:
let let
ispure = procdef[4].findChild(it.ident == !"pure") != nil ispure = procdef[4].findChild(it.strVal == "pure") != nil
isview = procdef[4].findChild(it.ident == !"view") != nil isview = procdef[4].findChild(it.strVal == "view") != nil
ispayable = procdef[4].findChild(it.ident == !"payable") != nil ispayable = procdef[4].findChild(it.strVal == "payable") != nil
doAssert(not (ispure and isview), doAssert(not (ispure and isview),
"can't be both `pure` and `view`") "can't be both `pure` and `view`")
doAssert(not ((ispure or isview) and ispayable), doAssert(not ((ispure or isview) and ispayable),
@ -506,17 +506,17 @@ proc parseContract(body: NimNode): seq[InterfaceObject] =
)) ))
else: else:
functions.add FunctionObject( functions.add FunctionObject(
name: $procdef[0].ident, name: procdef[0].strVal,
stateMutability: if ispure: pure elif isview: view elif ispayable: payable else: nonpayable, stateMutability: if ispure: pure elif isview: view elif ispayable: payable else: nonpayable,
inputs: parseInputs(procdef[3]), inputs: parseInputs(procdef[3]),
outputs: parseOutputs(procdef[3][0]) outputs: parseOutputs(procdef[3][0])
) )
else: else:
let isanonymous = procdef[4].findChild(it.ident == !"anonymous") != nil let isanonymous = procdef[4].findChild(it.strVal == "anonymous") != nil
doAssert(procdef[3][0].kind == nnkEmpty, doAssert(procdef[3][0].kind == nnkEmpty,
"Events can't have return values") "Events can't have return values")
events.add EventObject( events.add EventObject(
name: $procdef[0].ident, name: procdef[0].strVal,
inputs: parseEventInputs(procdef[3]), inputs: parseEventInputs(procdef[3]),
anonymous: isanonymous anonymous: isanonymous
) )