-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create separate execute function * Add is_valid_eth_signature to account library * Add eth_execute to account library * Create eth account mock and test * Add missing dependencies * Create TestEthSigner * Update used private key * Update implicit parameters * Update execute parameters * Update all implicit arguments * Update signature values and hash * Update variable name * Update documentation * Fix merge error * Improve format * Update tests/utils.py Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com> * Update docs/Account.md Co-authored-by: Martín Triay <martriay@gmail.com> * Update docs/Account.md Co-authored-by: Martín Triay <martriay@gmail.com> * Rename test and fix documentation * Add documentation * Update src/openzeppelin/account/library.cairo Co-authored-by: Martín Triay <martriay@gmail.com> * Update src/openzeppelin/account/library.cairo Co-authored-by: Martín Triay <martriay@gmail.com> * Update src/openzeppelin/account/library.cairo Co-authored-by: Martín Triay <martriay@gmail.com> * Update src/openzeppelin/account/library.cairo Co-authored-by: Martín Triay <martriay@gmail.com> * Update tests/utils.py Co-authored-by: Martín Triay <martriay@gmail.com> * Update tests/utils.py Co-authored-by: Martín Triay <martriay@gmail.com> * Update tests/mocks/eth_account.cairo Co-authored-by: Martín Triay <martriay@gmail.com> * Create eth account preset * Create signers module * use assert_revert to test nonce * Add test for valid signature * use internal hash * Update validity test * Update docs/Account.md Co-authored-by: Martín Triay <martriay@gmail.com> * Update docs/Account.md Co-authored-by: Martín Triay <martriay@gmail.com> * Update tests/signers.py Co-authored-by: Martín Triay <martriay@gmail.com> * Update src/openzeppelin/account/library.cairo Co-authored-by: Martín Triay <martriay@gmail.com> * Fix after merge * Improve tests * Update account library * Update Account.md * update format * Update src/openzeppelin/account/library.cairo Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com> * Update tests/access/test_Ownable.py Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com> * Update src/openzeppelin/account/library.cairo Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com> * Update eth test * Update Account.md * Update test * Update tests/signers.py Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com> * Fix typo * Update signers * Update test * Update docs/Account.md Co-authored-by: Martín Triay <martriay@gmail.com> * Update docs/Account.md Co-authored-by: Martín Triay <martriay@gmail.com> * Update tests/signers.py Co-authored-by: Martín Triay <martriay@gmail.com> * Update docs/Account.md Co-authored-by: Martín Triay <martriay@gmail.com> * update test * Update documenation for Account * Update docs/Account.md * Update docs/Account.md Co-authored-by: Martín Triay <martriay@gmail.com> Co-authored-by: Andrew Fleming <fleming.andrew@protonmail.com> Co-authored-by: Martín Triay <martriay@gmail.com>
- Loading branch information
1 parent
f7d319f
commit 2cd6027
Showing
22 changed files
with
640 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# SPDX-License-Identifier: MIT | ||
# OpenZeppelin Contracts for Cairo v0.1.0 (account/EthAccount.cairo) | ||
|
||
%lang starknet | ||
from starkware.cairo.common.cairo_builtins import HashBuiltin, SignatureBuiltin, BitwiseBuiltin | ||
from openzeppelin.account.library import Account, AccountCallArray | ||
|
||
from openzeppelin.introspection.ERC165 import ERC165 | ||
|
||
# | ||
# Constructor | ||
# | ||
|
||
@constructor | ||
func constructor{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}(eth_address: felt): | ||
Account.initializer(eth_address) | ||
return () | ||
end | ||
|
||
# | ||
# Getters | ||
# | ||
|
||
@view | ||
func get_eth_address{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}() -> (res: felt): | ||
let (res) = Account.get_public_key() | ||
return (res=res) | ||
end | ||
|
||
@view | ||
func get_nonce{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}() -> (res: felt): | ||
let (res) = Account.get_nonce() | ||
return (res=res) | ||
end | ||
|
||
@view | ||
func supportsInterface{ | ||
syscall_ptr: felt*, | ||
pedersen_ptr: HashBuiltin*, | ||
range_check_ptr | ||
} (interfaceId: felt) -> (success: felt): | ||
let (success) = ERC165.supports_interface(interfaceId) | ||
return (success) | ||
end | ||
|
||
# | ||
# Setters | ||
# | ||
|
||
@external | ||
func set_eth_address{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr | ||
}(new_eth_address: felt): | ||
Account.set_public_key(new_eth_address) | ||
return () | ||
end | ||
|
||
# | ||
# Business logic | ||
# | ||
|
||
@view | ||
func is_valid_signature{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr, | ||
ecdsa_ptr: SignatureBuiltin*, | ||
bitwise_ptr: BitwiseBuiltin* | ||
}( | ||
hash: felt, | ||
signature_len: felt, | ||
signature: felt* | ||
) -> (is_valid: felt): | ||
let (is_valid) = Account.is_valid_eth_signature(hash, signature_len, signature) | ||
return (is_valid=is_valid) | ||
end | ||
|
||
@external | ||
func __execute__{ | ||
syscall_ptr : felt*, | ||
pedersen_ptr : HashBuiltin*, | ||
range_check_ptr, | ||
bitwise_ptr: BitwiseBuiltin* | ||
}( | ||
call_array_len: felt, | ||
call_array: AccountCallArray*, | ||
calldata_len: felt, | ||
calldata: felt*, | ||
nonce: felt | ||
) -> (response_len: felt, response: felt*): | ||
let (response_len, response) = Account.eth_execute( | ||
call_array_len, | ||
call_array, | ||
calldata_len, | ||
calldata, | ||
nonce | ||
) | ||
return (response_len=response_len, response=response) | ||
end |
Oops, something went wrong.