-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deploy starknet account if CairoLib caller is not deployed (#1253)
<!--- Please provide a general summary of your changes in the title above --> <!-- Give an estimate of the time you spent on this PR in terms of work days. Did you spend 0.5 days on this PR or rather 2 days? --> Time spent on this PR: 0.3d ## Pull request type <!-- Please try to limit your pull request to one type, submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> Resolves #<Issue number> ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - Deploys a SN account for a caller of a Cairo contract if its account is not deployed on starknet already. - - <!-- Reviewable:start --> - - - This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1253) <!-- Reviewable:end -->
- Loading branch information
Showing
8 changed files
with
148 additions
and
108 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
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,36 @@ | ||
from starkware.cairo.common.math_cmp import is_le, is_not_zero, is_in_range | ||
|
||
const LAST_ETHEREUM_PRECOMPILE_ADDRESS = 0x0a; | ||
const FIRST_ROLLUP_PRECOMPILE_ADDRESS = 0x100; | ||
const LAST_ROLLUP_PRECOMPILE_ADDRESS = 0x100; | ||
const EXEC_PRECOMPILE_SELECTOR = 0x01e3e7ac032066525c37d0791c3c0f5fbb1c17f1cb6fe00afc206faa3fbd18e1; | ||
const FIRST_KAKAROT_PRECOMPILE_ADDRESS = 0x75001; | ||
const LAST_KAKAROT_PRECOMPILE_ADDRESS = 0x75002; | ||
|
||
namespace PrecompilesHelpers { | ||
func is_rollup_precompile{range_check_ptr}(address: felt) -> felt { | ||
return is_in_range( | ||
address, FIRST_ROLLUP_PRECOMPILE_ADDRESS, LAST_ROLLUP_PRECOMPILE_ADDRESS + 1 | ||
); | ||
} | ||
|
||
func is_kakarot_precompile{range_check_ptr}(address: felt) -> felt { | ||
return is_in_range( | ||
address, FIRST_KAKAROT_PRECOMPILE_ADDRESS, LAST_KAKAROT_PRECOMPILE_ADDRESS + 1 | ||
); | ||
} | ||
// @notice Return whether the address is a precompile address. | ||
// @dev Ethereum precompiles start at address 0x01. | ||
// @dev RIP precompiles start at address FIRST_ROLLUP_PRECOMPILE_ADDRESS. | ||
// @dev Kakarot precompiles start at address FIRST_KAKAROT_PRECOMPILE_ADDRESS. | ||
func is_precompile{range_check_ptr}(address: felt) -> felt { | ||
alloc_locals; | ||
let is_rollup_precompile_ = is_rollup_precompile(address); | ||
let is_kakarot_precompile_ = is_kakarot_precompile(address); | ||
return is_not_zero(address) * ( | ||
is_le(address, LAST_ETHEREUM_PRECOMPILE_ADDRESS) + | ||
is_rollup_precompile_ + | ||
is_kakarot_precompile_ | ||
); | ||
} | ||
} |
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