Skip to content

Instantly share code, notes, and snippets.

@fracek
Last active July 18, 2022 20:19
Show Gist options
  • Save fracek/846d3082f9803a7e65edc44292da9241 to your computer and use it in GitHub Desktop.
Save fracek/846d3082f9803a7e65edc44292da9241 to your computer and use it in GitHub Desktop.
utils/ownable.cairo:11:5: Cannot compare 'starkware.cairo.common.invoke.invoke.Return' and 'felt'.
assert existing_owner = 0
^***********************^
%lang starknet
from starkware.cairo.common.invoke import invoke
from starkware.cairo.common.alloc import alloc
func initialize_owner{syscall_ptr : felt*}(owner_reader, owner_writer, initial_owner : felt):
alloc_locals
let (owner_reader_args : felt*) = alloc()
let existing_owner = invoke(owner_reader, 0, owner_reader_args)
assert existing_owner = 0
let (owner_writer_args : felt*) = alloc()
assert [owner_writer_args] = initialize_owner
invoke(owner_writer, 1, owner_writer_args)
return ()
end
%lang starknet
from starkware.cairo.common.registers import get_label_location
from starkware.starknet.common.syscalls import get_caller_address
from utils.ownable import initialize_owner
@storage_var
func _owner() -> (owner : felt):
end
@external
func initialize{syscall_ptr : felt*}():
let (initial_owner) = get_caller_address()
tempvar syscall_ptr = syscall_ptr
let (owner_reader) = get_label_location(_owner.read)
let (owner_writer) = get_label_location(_owner.write)
initialize_owner(owner_reader, owner_writer, initial_owner)
tempvar syscall_ptr = syscall_ptr
return ()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment