This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Fix sierra class hash calculation #886
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1858369
reproduce bug
juanbono a1b1049
Merge branch 'main' into issue_with_class_hash
juanbono 1736373
use pythonic formatter
juanbono 61f53f7
Merge branch 'issue_with_class_hash' of github.com:lambdaclass/starkn…
juanbono 02fb577
rename test
juanbono bd3e6e9
fix test
juanbono 233bfd3
cargo fmt
juanbono File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,57 @@ | ||
use core::debug::PrintTrait; | ||
use core::traits::Into; | ||
use core::result::ResultTrait; | ||
use starknet::syscalls::{deploy_syscall, get_block_hash_syscall}; | ||
use traits::TryInto; | ||
use option::OptionTrait; | ||
use starknet::SyscallResultTrait; | ||
use starknet::class_hash::Felt252TryIntoClassHash; | ||
use array::ArrayTrait; | ||
use array::SpanTrait; | ||
|
||
#[starknet::interface] | ||
trait IContractWithEvent<T> { | ||
fn emit_event(ref self: T, incremental: bool); | ||
} | ||
|
||
#[starknet::contract] | ||
mod ContractWithEvent { | ||
use traits::Into; | ||
use starknet::info::get_contract_address; | ||
#[storage] | ||
struct Storage { | ||
value: u128, | ||
} | ||
|
||
#[derive(Copy, Drop, PartialEq, starknet::Event)] | ||
struct IncrementalEvent { | ||
value: u128, | ||
} | ||
|
||
#[derive(Copy, Drop, PartialEq, starknet::Event)] | ||
struct StaticEvent {} | ||
|
||
#[event] | ||
#[derive(Copy, Drop, PartialEq, starknet::Event)] | ||
enum Event { | ||
IncrementalEvent: IncrementalEvent, | ||
StaticEvent: StaticEvent, | ||
} | ||
|
||
#[constructor] | ||
fn constructor(ref self: ContractState) { | ||
self.value.write(0); | ||
} | ||
|
||
#[external(v0)] | ||
fn emit_event(ref self: ContractState, incremental: bool) { | ||
if incremental { | ||
self.emit(Event::IncrementalEvent(IncrementalEvent { value: self.value.read() })); | ||
self.value.write(self.value.read() + 1); | ||
} else { | ||
self.emit(Event::StaticEvent(StaticEvent {})); | ||
} | ||
} | ||
} | ||
|
||
use ContractWithEvent::{Event, IncrementalEvent, StaticEvent}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the contract used in the test, but its name was only changed in one of the two places. @juanbono