Open wmanshu opened 5 years ago
contract trait Ownable { event OwnershipRenounced(previousOwner: Address) event OwnershipTransfered(previousOwner: Address, newOwner: Address) self :: (any) { public func getOwner() -> Address } self :: (getOwner) { func setOwner(newOwner: Address) public func renounceOwnership() { emit OwnershipRenounced(getOwner()) setOwner(0x0000000000000000) } public func transferOwnership(newOwner: Address) { assert(newOwner != 0x0000000000000000) emit OwnershipTransfered(getOwner(), newOwner) setOwner(newOwner) } } } contract ToyWallet: Ownable { visible var owner: Address // visible automatically creates getOwner // Skipping initialiser not relevant for this example } ToyWallet :: (any) { public init(addr: Address) { self.owner = addr } public func getOwner() -> Address { return owner } } ToyWallet :: (getOwner) { func setOwner(newOwner: Address){ self.owner = newOwner } }
Error happens at line self :: (getOwner), the error message is Unexpectedly found nil. It is also not possible to change it to getOwner(), which gives another error.
self :: (getOwner)
Unexpectedly found nil
getOwner()
Error happens at line
self :: (getOwner)
, the error message isUnexpectedly found nil
. It is also not possible to change it togetOwner()
, which gives another error.