diff --git a/README.md b/README.md index 170c1b83a1..b494edd07e 100644 --- a/README.md +++ b/README.md @@ -56,16 +56,16 @@ Run `fe --help` to explore further options. The following is a simple contract implemented in Fe. ```rust +struct Signed { + book_msg: String<100> +} + contract GuestBook { messages: Map> - event Signed { - book_msg: String<100> - } - pub fn sign(self, ctx: Context, book_msg: String<100>) { self.messages[ctx.msg_sender()] = book_msg - emit Signed(ctx, book_msg: book_msg) + ctx.emit(Signed(book_msg: book_msg)) } pub fn get_msg(self, addr: address) -> String<100> { diff --git a/crates/analyzer/src/constants.rs b/crates/analyzer/src/constants.rs index 54e27646aa..25f75d0d3b 100644 --- a/crates/analyzer/src/constants.rs +++ b/crates/analyzer/src/constants.rs @@ -1 +1,4 @@ +pub const EMITTABLE_TRAIT_NAME: &str = "Emittable"; +pub const EMIT_FN_NAME: &str = "emit"; +pub const INDEXED: &str = "indexed"; pub const MAX_INDEXED_EVENT_FIELDS: usize = 3; diff --git a/crates/analyzer/src/context.rs b/crates/analyzer/src/context.rs index cc73e031e8..588831917d 100644 --- a/crates/analyzer/src/context.rs +++ b/crates/analyzer/src/context.rs @@ -6,7 +6,7 @@ use crate::{ }; use crate::namespace::items::{ - ContractId, DiagnosticSink, EventId, FunctionId, FunctionSigId, Item, TraitId, + ContractId, DiagnosticSink, FunctionId, FunctionSigId, Item, TraitId, }; use crate::namespace::types::{Generic, SelfDecl, Type, TypeId}; use crate::AnalyzerDb; @@ -408,7 +408,6 @@ impl Location { #[derive(Default, Clone, Debug, PartialEq, Eq)] pub struct FunctionBody { pub expressions: IndexMap, - pub emits: IndexMap, // Map match statements to the corresponding [`PatternMatrix`] pub matches: IndexMap, // Map lhs of variable declaration to type. diff --git a/crates/analyzer/src/db.rs b/crates/analyzer/src/db.rs index ef73e82594..1c5d42cfda 100644 --- a/crates/analyzer/src/db.rs +++ b/crates/analyzer/src/db.rs @@ -1,7 +1,7 @@ use crate::namespace::items::{ - self, ContractFieldId, ContractId, DepGraphWrapper, EnumVariantKind, EventId, FunctionId, - FunctionSigId, ImplId, IngotId, Item, ModuleConstantId, ModuleId, StructFieldId, StructId, - TraitId, TypeAliasId, + self, ContractFieldId, ContractId, DepGraphWrapper, EnumVariantKind, FunctionId, FunctionSigId, + ImplId, IngotId, Item, ModuleConstantId, ModuleId, StructFieldId, StructId, TraitId, + TypeAliasId, }; use crate::namespace::types::{self, Type, TypeId}; use crate::{ @@ -51,8 +51,6 @@ pub trait AnalyzerDb: SourceDb + Upcast + UpcastMut #[salsa::interned] fn intern_function(&self, data: Rc) -> FunctionId; #[salsa::interned] - fn intern_event(&self, data: Rc) -> EventId; - #[salsa::interned] fn intern_type(&self, data: Type) -> TypeId; // Ingot @@ -132,11 +130,6 @@ pub trait AnalyzerDb: SourceDb + Upcast + UpcastMut #[salsa::invoke(queries::contracts::contract_call_function)] fn contract_call_function(&self, id: ContractId) -> Analysis>; - #[salsa::invoke(queries::contracts::contract_all_events)] - fn contract_all_events(&self, id: ContractId) -> Rc<[EventId]>; - #[salsa::invoke(queries::contracts::contract_event_map)] - fn contract_event_map(&self, id: ContractId) -> Analysis>>; - #[salsa::invoke(queries::contracts::contract_all_fields)] fn contract_all_fields(&self, id: ContractId) -> Rc<[ContractFieldId]>; #[salsa::invoke(queries::contracts::contract_field_map)] @@ -206,10 +199,6 @@ pub trait AnalyzerDb: SourceDb + Upcast + UpcastMut #[salsa::invoke(queries::impls::impl_function_map)] fn impl_function_map(&self, id: ImplId) -> Analysis>>; - // Event - #[salsa::invoke(queries::events::event_type)] - fn event_type(&self, event: EventId) -> Analysis>; - // Type #[salsa::invoke(queries::types::all_impls)] fn all_impls(&self, ty: TypeId) -> Rc<[ImplId]>; diff --git a/crates/analyzer/src/db/queries.rs b/crates/analyzer/src/db/queries.rs index ea055d276d..07d640ba41 100644 --- a/crates/analyzer/src/db/queries.rs +++ b/crates/analyzer/src/db/queries.rs @@ -1,6 +1,5 @@ pub mod contracts; pub mod enums; -pub mod events; pub mod functions; pub mod impls; pub mod ingots; diff --git a/crates/analyzer/src/db/queries/contracts.rs b/crates/analyzer/src/db/queries/contracts.rs index 7e0fd54b0b..3f1aa8fc5e 100644 --- a/crates/analyzer/src/db/queries/contracts.rs +++ b/crates/analyzer/src/db/queries/contracts.rs @@ -1,16 +1,13 @@ use crate::db::{Analysis, AnalyzerDb}; use crate::errors; use crate::namespace::items::{ - self, ContractFieldId, ContractId, DepGraph, DepGraphWrapper, DepLocality, EventId, FunctionId, - Item, TypeDef, + self, ContractFieldId, ContractId, DepGraph, DepGraphWrapper, DepLocality, FunctionId, Item, + TypeDef, }; use crate::namespace::scopes::ItemScope; use crate::namespace::types::{self, Type}; use crate::traversal::types::type_desc; -use crate::{ - context::{AnalyzerContext, NamedThing}, - namespace::types::TypeId, -}; +use crate::{context::AnalyzerContext, namespace::types::TypeId}; use fe_common::diagnostics::Label; use fe_parser::ast; use indexmap::map::{Entry, IndexMap}; @@ -23,16 +20,13 @@ pub fn contract_all_functions(db: &dyn AnalyzerDb, contract: ContractId) -> Rc<[ let module = contract.module(db); let body = &contract.data(db).ast.kind.body; body.iter() - .filter_map(|stmt| match stmt { - ast::ContractStmt::Event(_) => None, - ast::ContractStmt::Function(node) => { - Some(db.intern_function(Rc::new(items::Function::new( - db, - node, - Some(Item::Type(TypeDef::Contract(contract))), - module, - )))) - } + .map(|stmt| match stmt { + ast::ContractStmt::Function(node) => db.intern_function(Rc::new(items::Function::new( + db, + node, + Some(Item::Type(TypeDef::Contract(contract))), + module, + ))), }) .collect() } @@ -51,17 +45,6 @@ pub fn contract_function_map( continue; } - if let Some(event) = contract.event(db, def_name) { - scope.name_conflict_error( - "function", - def_name, - &NamedThing::Item(Item::Event(event)), - Some(event.name_span(db)), - def.kind.sig.kind.name.span, - ); - continue; - } - if let Ok(Some(named_item)) = scope.resolve_name(def_name, func.name_span(db)) { scope.name_conflict_error( "function", @@ -269,54 +252,6 @@ pub fn contract_call_function( } } -/// A `Vec` of all events defined within the contract, including those with -/// duplicate names. -pub fn contract_all_events(db: &dyn AnalyzerDb, contract: ContractId) -> Rc<[EventId]> { - let body = &contract.data(db).ast.kind.body; - body.iter() - .filter_map(|stmt| match stmt { - ast::ContractStmt::Function(_) => None, - ast::ContractStmt::Event(node) => Some(db.intern_event(Rc::new(items::Event { - ast: node.clone(), - module: contract.module(db), - contract: Some(contract), - }))), - }) - .collect() -} - -pub fn contract_event_map( - db: &dyn AnalyzerDb, - contract: ContractId, -) -> Analysis>> { - let scope = ItemScope::new(db, contract.module(db)); - let mut map = IndexMap::::new(); - - let contract_name = contract.name(db); - for event in db.contract_all_events(contract).iter() { - let node = &event.data(db).ast; - - match map.entry(node.name().into()) { - Entry::Occupied(entry) => { - scope.duplicate_name_error( - &format!("duplicate event names in `contract {}`", contract_name,), - entry.key(), - entry.get().data(db).ast.span, - node.span, - ); - } - Entry::Vacant(entry) => { - entry.insert(*event); - } - } - } - - Analysis { - value: Rc::new(map), - diagnostics: scope.diagnostics.take().into(), - } -} - /// All field ids, including those with duplicate names pub fn contract_all_fields(db: &dyn AnalyzerDb, contract: ContractId) -> Rc<[ContractFieldId]> { contract diff --git a/crates/analyzer/src/db/queries/events.rs b/crates/analyzer/src/db/queries/events.rs deleted file mode 100644 index fd7a4548b4..0000000000 --- a/crates/analyzer/src/db/queries/events.rs +++ /dev/null @@ -1,115 +0,0 @@ -use crate::constants::MAX_INDEXED_EVENT_FIELDS; -use crate::context::AnalyzerContext; -use crate::db::Analysis; -use crate::errors::TypeError; -use crate::namespace::items::EventId; -use crate::namespace::scopes::ItemScope; -use crate::namespace::types; -use crate::traversal::types::type_desc; -use crate::AnalyzerDb; -use fe_common::diagnostics::Label; -use fe_common::utils::humanize::pluralize_conditionally; -use fe_parser::ast; -use fe_parser::node::Node; -use std::collections::HashMap; -use std::rc::Rc; - -// Event fields aren't interned for now, but they probably should be. If/when -// events are handled as normal type definitions, the current setup will run -// into a salsa cycle if a user tries to define an event that contains itself. - -pub fn event_type(db: &dyn AnalyzerDb, event: EventId) -> Analysis> { - let mut scope = ItemScope::new(db, event.module(db)); - - let ast::Event { - name: event_name, - fields: field_nodes, - pub_qual: _, - } = &event.data(db).ast.kind; - - let mut names = HashMap::new(); - let mut indexed_count = 0; - let fields = field_nodes - .iter() - .enumerate() - .filter_map(|(index, field)| { - let ast::EventField { - is_idx, - name, - typ: typ_node, - } = &field.kind; - - let typ = type_desc(&mut scope, typ_node).and_then(|typ| match typ { - typ if typ.has_fixed_size(scope.db()) => Ok(typ), - _ => Err(TypeError::new(scope.error( - "event field type must have a fixed size", - typ_node.span, - "this can't be used as an event field", - ))), - }); - - // If we've already seen the max number of indexed fields, - // ignore the `idx` qualifier on this one. We'll emit an error below. - indexed_count += *is_idx as usize; - - if let Some(dup_idx) = names.get(&name.kind) { - let dup_field: &Node = &field_nodes[*dup_idx]; - scope.fancy_error( - &format!("duplicate field names in `event {}`", &event_name.kind,), - vec![ - Label::primary( - dup_field.span, - format!("`{}` first defined here", name.kind), - ), - Label::secondary(field.span, format!("`{}` redefined here", name.kind)), - ], - vec![], - ); - None - } else { - names.insert(&name.kind, index); - Some(types::EventField { - name: name.kind.clone(), - typ, - is_indexed: *is_idx, - }) - } - }) - .collect(); - - if indexed_count > MAX_INDEXED_EVENT_FIELDS { - let excess_count = indexed_count - MAX_INDEXED_EVENT_FIELDS; - - let mut labels = field_nodes - .iter() - .filter_map(|field| { - field - .kind - .is_idx - .then(|| Label::primary(field.span, String::new())) - }) - .collect::>(); - labels.last_mut().unwrap().message = format!("{} indexed fields", indexed_count); - - scope.fancy_error( - &format!( - "more than three indexed fields in `event {}`", - event_name.kind - ), - labels, - vec![format!( - "Note: Remove the `idx` keyword from at least {} {}.", - excess_count, - pluralize_conditionally("field", excess_count) - )], - ); - } - - Analysis { - value: Rc::new(types::Event { - name: event_name.kind.clone(), - fields, - }), - diagnostics: scope.diagnostics.take().into(), - } -} diff --git a/crates/analyzer/src/db/queries/functions.rs b/crates/analyzer/src/db/queries/functions.rs index 4ba89b6193..86af976b73 100644 --- a/crates/analyzer/src/db/queries/functions.rs +++ b/crates/analyzer/src/db/queries/functions.rs @@ -436,11 +436,6 @@ pub fn function_dependency_graph(db: &dyn AnalyzerDb, function: FunctionId) -> D } } - directs.extend( - body.emits - .values() - .map(|event| (root, Item::Event(*event), DepLocality::Local)), - ); directs.extend( body.var_types .values() diff --git a/crates/analyzer/src/db/queries/module.rs b/crates/analyzer/src/db/queries/module.rs index 8648864a7d..3e35f45027 100644 --- a/crates/analyzer/src/db/queries/module.rs +++ b/crates/analyzer/src/db/queries/module.rs @@ -2,8 +2,8 @@ use crate::context::{Analysis, AnalyzerContext, Constant, NamedThing}; use crate::display::Displayable; use crate::errors::{self, ConstEvalError, TypeError}; use crate::namespace::items::{ - Contract, ContractId, Enum, Event, Function, Impl, ImplId, Item, ModuleConstant, - ModuleConstantId, ModuleId, ModuleSource, Struct, StructId, Trait, TraitId, TypeAlias, TypeDef, + Contract, ContractId, Enum, Function, Impl, ImplId, Item, ModuleConstant, ModuleConstantId, + ModuleId, ModuleSource, Struct, StructId, Trait, TraitId, TypeAlias, TypeDef, }; use crate::namespace::scopes::ItemScope; use crate::namespace::types::{self, TypeId}; @@ -101,11 +101,6 @@ pub fn module_all_items(db: &dyn AnalyzerDb, module: ModuleId) -> Rc<[Item]> { module, })))), ast::ModuleStmt::Pragma(_) | ast::ModuleStmt::Use(_) | ast::ModuleStmt::Impl(_) => None, - ast::ModuleStmt::Event(node) => Some(Item::Event(db.intern_event(Rc::new(Event { - ast: node.clone(), - module, - contract: None, - })))), ast::ModuleStmt::ParseError(_) => None, }) .collect() diff --git a/crates/analyzer/src/db/queries/structs.rs b/crates/analyzer/src/db/queries/structs.rs index 2ad679d1ec..f3e7cf8a10 100644 --- a/crates/analyzer/src/db/queries/structs.rs +++ b/crates/analyzer/src/db/queries/structs.rs @@ -1,4 +1,5 @@ use crate::builtins; +use crate::constants::MAX_INDEXED_EVENT_FIELDS; use crate::context::AnalyzerContext; use crate::db::Analysis; use crate::errors::TypeError; @@ -10,7 +11,8 @@ use crate::namespace::scopes::ItemScope; use crate::namespace::types::{Type, TypeId}; use crate::traversal::types::type_desc; use crate::AnalyzerDb; -use fe_parser::ast; +use fe_common::utils::humanize::pluralize_conditionally; +use fe_parser::{ast, Label}; use indexmap::map::{Entry, IndexMap}; use smol_str::SmolStr; use std::rc::Rc; @@ -39,10 +41,25 @@ pub fn struct_field_map( let scope = ItemScope::new(db, struct_.module(db)); let mut fields = IndexMap::::new(); + let mut indexed_count = 0; let struct_name = struct_.name(db); for field in db.struct_all_fields(struct_).iter() { let node = &field.data(db).ast; + if field.is_indexed(db) { + indexed_count += 1; + } + + // Multiple attributes are currently still rejected by the parser so we only need to check the name here + if !field.attributes(db).is_empty() && !field.is_indexed(db) { + let span = field.data(db).ast.kind.attributes.first().unwrap().span; + scope.error( + "Invalid attribute", + span, + "illegal name. Only `indexed` supported.", + ); + } + match fields.entry(node.name().into()) { Entry::Occupied(entry) => { scope.duplicate_name_error( @@ -58,6 +75,33 @@ pub fn struct_field_map( } } + if indexed_count > MAX_INDEXED_EVENT_FIELDS { + let excess_count = indexed_count - MAX_INDEXED_EVENT_FIELDS; + + let mut labels = fields + .iter() + .filter_map(|(_, field)| { + field + .is_indexed(db) + .then(|| Label::primary(field.span(db), String::new())) + }) + .collect::>(); + labels.last_mut().unwrap().message = format!("{} indexed fields", indexed_count); + + scope.fancy_error( + &format!( + "more than three indexed fields in `event {}`", + struct_.name(db) + ), + labels, + vec![format!( + "Note: Remove the `indexed` attribute from at least {} {}.", + excess_count, + pluralize_conditionally("field", excess_count) + )], + ); + } + Analysis::new(Rc::new(fields), scope.diagnostics.take().into()) } @@ -70,6 +114,7 @@ pub fn struct_field_type( let mut scope = ItemScope::new(db, field_data.parent.module(db)); let ast::Field { + attributes: _, is_pub: _, is_const, name: _, diff --git a/crates/analyzer/src/db/queries/types.rs b/crates/analyzer/src/db/queries/types.rs index 486e8f1bb1..96feefa36e 100644 --- a/crates/analyzer/src/db/queries/types.rs +++ b/crates/analyzer/src/db/queries/types.rs @@ -20,7 +20,6 @@ pub fn all_impls(db: &dyn AnalyzerDb, ty: TypeId) -> Rc<[ImplId]> { .iter() .flat_map(|module_id| module_id.all_impls(db).to_vec()) .collect::>(); - db.ingot_external_ingots(db.root_ingot()) .values() .flat_map(|ingot| ingot.all_modules(db).to_vec()) diff --git a/crates/analyzer/src/namespace/items.rs b/crates/analyzer/src/namespace/items.rs index 406bcf2e95..e280f18e8c 100644 --- a/crates/analyzer/src/namespace/items.rs +++ b/crates/analyzer/src/namespace/items.rs @@ -1,3 +1,4 @@ +use crate::constants::{EMITTABLE_TRAIT_NAME, INDEXED}; use crate::context::{self, Analysis, Constant, NamedThing}; use crate::display::{DisplayWithDb, Displayable}; use crate::errors::{self, IncompleteItem, TypeError}; @@ -30,9 +31,6 @@ pub enum Item { // Any of the items inside TypeDef (struct, alias, etc) // could be optionally generic. GenericType(GenericType), - // Events aren't normal types; they *could* be moved into - // TypeDef, but it would have consequences. - Event(EventId), Trait(TraitId), Impl(ImplId), Function(FunctionId), @@ -50,7 +48,6 @@ impl Item { Item::Trait(id) => id.name(db), Item::Impl(id) => id.name(db), Item::GenericType(id) => id.name(), - Item::Event(id) => id.name(db), Item::Function(id) => id.name(db), Item::BuiltinFunction(id) => id.as_ref().into(), Item::Intrinsic(id) => id.as_ref().into(), @@ -65,7 +62,6 @@ impl Item { Item::Type(id) => id.name_span(db), Item::Trait(id) => Some(id.name_span(db)), Item::GenericType(_) => None, - Item::Event(id) => Some(id.name_span(db)), Item::Function(id) => Some(id.name_span(db)), Item::Constant(id) => Some(id.name_span(db)), Item::BuiltinFunction(_) @@ -87,7 +83,6 @@ impl Item { | Self::GenericType(_) => true, Self::Type(id) => id.is_public(db), Self::Trait(id) => id.is_public(db), - Self::Event(id) => id.is_public(db), Self::Function(id) => id.is_public(db), Self::Constant(id) => id.is_public(db), } @@ -102,7 +97,6 @@ impl Item { Item::Type(_) | Item::Trait(_) | Item::Impl(_) - | Item::Event(_) | Item::Function(_) | Item::Constant(_) | Item::Ingot(_) @@ -124,7 +118,6 @@ impl Item { Item::Type(_) | Item::GenericType(_) => "type", Item::Trait(_) => "trait", Item::Impl(_) => "impl", - Item::Event(_) => "event", Item::Function(_) | Item::BuiltinFunction(_) => "function", Item::Intrinsic(_) => "intrinsic function", Item::Constant(_) => "constant", @@ -139,7 +132,6 @@ impl Item { Item::Module(module) => module.items(db), Item::Type(val) => val.items(db), Item::GenericType(_) - | Item::Event(_) | Item::Trait(_) | Item::Impl(_) | Item::Function(_) @@ -155,7 +147,6 @@ impl Item { Item::Trait(id) => Some(id.parent(db)), Item::Impl(id) => Some(id.parent(db)), Item::GenericType(_) => None, - Item::Event(id) => Some(id.parent(db)), Item::Function(id) => Some(id.parent(db)), Item::Constant(id) => Some(id.parent(db)), Item::Module(id) => Some(id.parent(db)), @@ -250,7 +241,6 @@ impl Item { Item::Type(id) => id.sink_diagnostics(db, sink), Item::Trait(id) => id.sink_diagnostics(db, sink), Item::Impl(id) => id.sink_diagnostics(db, sink), - Item::Event(id) => id.sink_diagnostics(db, sink), Item::Function(id) => id.sink_diagnostics(db, sink), Item::GenericType(_) | Item::BuiltinFunction(_) | Item::Intrinsic(_) => {} Item::Constant(id) => id.sink_diagnostics(db, sink), @@ -997,7 +987,6 @@ impl ContractId { .function(db, name) .filter(|f| !f.takes_self(db)) .map(Item::Function) - .or_else(|| self.event(db, name).map(Item::Event)) { Ok(Some(NamedThing::Item(item))) } else { @@ -1033,16 +1022,6 @@ impl ContractId { db.contract_public_function_map(*self) } - /// Lookup an event by name. - pub fn event(&self, db: &dyn AnalyzerDb, name: &str) -> Option { - self.events(db).get(name).copied() - } - - /// A map of events defined within the contract. - pub fn events(&self, db: &dyn AnalyzerDb) -> Rc> { - db.contract_event_map(*self).value - } - pub fn parent(&self, db: &dyn AnalyzerDb) -> Item { Item::Module(self.data(db).module) } @@ -1068,12 +1047,6 @@ impl ContractId { .iter() .for_each(|field| field.sink_diagnostics(db, sink)); - // events - db.contract_event_map(*self).sink_diagnostics(sink); - db.contract_all_events(*self) - .iter() - .for_each(|event| event.sink_diagnostics(db, sink)); - // functions db.contract_init_function(*self).sink_diagnostics(sink); db.contract_call_function(*self).sink_diagnostics(sink); @@ -1465,6 +1438,20 @@ impl StructFieldId { pub fn data(&self, db: &dyn AnalyzerDb) -> Rc { db.lookup_intern_struct_field(*self) } + pub fn attributes(&self, db: &dyn AnalyzerDb) -> Vec { + self.data(db) + .ast + .kind + .attributes + .iter() + .map(|node| node.kind.clone()) + .collect() + } + + pub fn is_indexed(&self, db: &dyn AnalyzerDb) -> bool { + self.attributes(db).contains(&INDEXED.into()) + } + pub fn typ(&self, db: &dyn AnalyzerDb) -> Result { db.struct_field_type(*self).value } @@ -1891,6 +1878,11 @@ impl TraitId { } pub fn is_implemented_for(&self, db: &dyn AnalyzerDb, ty: TypeId) -> bool { + // All structs automagically implement the Emittable trait + if self.is_std_trait(db, EMITTABLE_TRAIT_NAME) && ty.is_struct(db) { + return true; + } + ty.get_all_impls(db) .iter() .any(|val| &val.trait_id(db) == self) @@ -1900,6 +1892,10 @@ impl TraitId { self.module(db).is_in_std(db) } + pub fn is_std_trait(&self, db: &dyn AnalyzerDb, name: &str) -> bool { + self.is_in_std(db) && self.name(db).to_lowercase() == name.to_lowercase() + } + pub fn parent(&self, db: &dyn AnalyzerDb) -> Item { Item::Module(self.data(db).module) } @@ -1932,51 +1928,6 @@ impl TraitId { } } -#[derive(Debug, PartialEq, Eq, Hash, Clone)] -pub struct Event { - pub ast: Node, - pub module: ModuleId, - pub contract: Option, -} - -#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, Clone)] -pub struct EventId(pub(crate) u32); -impl_intern_key!(EventId); - -impl EventId { - pub fn name(&self, db: &dyn AnalyzerDb) -> SmolStr { - self.data(db).ast.name().into() - } - pub fn span(&self, db: &dyn AnalyzerDb) -> Span { - self.data(db).ast.span - } - pub fn name_span(&self, db: &dyn AnalyzerDb) -> Span { - self.data(db).ast.kind.name.span - } - pub fn data(&self, db: &dyn AnalyzerDb) -> Rc { - db.lookup_intern_event(*self) - } - pub fn is_public(&self, db: &dyn AnalyzerDb) -> bool { - self.data(db).ast.kind.pub_qual.is_some() - } - pub fn typ(&self, db: &dyn AnalyzerDb) -> Rc { - db.event_type(*self).value - } - pub fn module(&self, db: &dyn AnalyzerDb) -> ModuleId { - self.data(db).module - } - pub fn parent(&self, db: &dyn AnalyzerDb) -> Item { - if let Some(contract_id) = self.data(db).contract { - Item::Type(TypeDef::Contract(contract_id)) - } else { - Item::Module(self.module(db)) - } - } - pub fn sink_diagnostics(&self, db: &dyn AnalyzerDb, sink: &mut impl DiagnosticSink) { - sink.push_all(db.event_type(*self).diagnostics.iter()); - } -} - pub trait DiagnosticSink { fn push(&mut self, diag: &Diagnostic); fn push_all<'a>(&mut self, iter: impl Iterator) { diff --git a/crates/analyzer/src/namespace/scopes.rs b/crates/analyzer/src/namespace/scopes.rs index 9ac1218cbd..27b90a073e 100644 --- a/crates/analyzer/src/namespace/scopes.rs +++ b/crates/analyzer/src/namespace/scopes.rs @@ -4,7 +4,7 @@ use crate::context::{ AnalyzerContext, CallType, Constant, ExpressionAttributes, FunctionBody, NamedThing, }; use crate::errors::{AlreadyDefined, FatalError, IncompleteItem, TypeError}; -use crate::namespace::items::{EventId, FunctionId, ModuleId}; +use crate::namespace::items::{FunctionId, ModuleId}; use crate::namespace::items::{Item, TypeDef}; use crate::namespace::types::{Type, TypeId}; use crate::pattern_analysis::PatternMatrix; @@ -197,21 +197,6 @@ impl<'a> FunctionScope<'a> { self.function.signature(self.db).return_type.clone() } - /// Attribute contextual information to an emit statement node. - /// - /// # Panics - /// - /// Panics if an entry already exists for the node id. - pub fn add_emit(&self, node: &Node, event: EventId) { - debug_assert!(matches!(node.kind, ast::FuncStmt::Emit { .. })); - self.add_node(node); - self.body - .borrow_mut() - .emits - .insert(node.id, event) - .expect_none("emit statement attributes already exist"); - } - pub fn map_variable_type(&self, node: &Node, typ: TypeId) { self.add_node(node); self.body diff --git a/crates/analyzer/src/namespace/types.rs b/crates/analyzer/src/namespace/types.rs index 5e855fb1c7..a257518377 100644 --- a/crates/analyzer/src/namespace/types.rs +++ b/crates/analyzer/src/namespace/types.rs @@ -99,6 +99,9 @@ impl TypeId { pub fn is_string(&self, db: &dyn AnalyzerDb) -> bool { self.typ(db).as_string().is_some() } + pub fn is_struct(&self, db: &dyn AnalyzerDb) -> bool { + matches!(self.typ(db), Type::Struct(_)) + } pub fn as_struct(&self, db: &dyn AnalyzerDb) -> Option { self.typ(db).as_struct() } @@ -450,19 +453,6 @@ impl Integer { } } -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub struct Event { - pub name: SmolStr, - pub fields: Vec, -} - -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub struct EventField { - pub name: SmolStr, - pub typ: Result, - pub is_indexed: bool, -} - impl Type { pub fn id(&self, db: &dyn AnalyzerDb) -> TypeId { db.intern_type(self.clone()) diff --git a/crates/analyzer/src/traversal/call_args.rs b/crates/analyzer/src/traversal/call_args.rs index 93f719e7b9..4c65ce58ed 100644 --- a/crates/analyzer/src/traversal/call_args.rs +++ b/crates/analyzer/src/traversal/call_args.rs @@ -1,7 +1,7 @@ use crate::context::{AnalyzerContext, DiagnosticVoucher}; use crate::display::Displayable; use crate::errors::{FatalError, TypeError}; -use crate::namespace::types::{EventField, FunctionParam, Generic, Type, TypeId}; +use crate::namespace::types::{FunctionParam, Generic, Type, TypeId}; use crate::traversal::expressions::assignable_expr; use fe_common::{diagnostics::Label, utils::humanize::pluralize_conditionally}; use fe_common::{Span, Spanned}; @@ -23,15 +23,6 @@ impl LabeledParameter for FunctionParam { } } -impl LabeledParameter for EventField { - fn label(&self) -> Option<&str> { - Some(&self.name) - } - fn typ(&self) -> Result { - self.typ.clone() - } -} - impl LabeledParameter for (SmolStr, Result) { fn label(&self) -> Option<&str> { Some(&self.0) diff --git a/crates/analyzer/src/traversal/expressions.rs b/crates/analyzer/src/traversal/expressions.rs index 2c9715046d..df7024418b 100644 --- a/crates/analyzer/src/traversal/expressions.rs +++ b/crates/analyzer/src/traversal/expressions.rs @@ -1044,20 +1044,6 @@ fn expr_call_named_thing( id.typ(context.db())?.display(context.db()), ), ))), - NamedThing::Item(Item::Event(_)) => Err(FatalError::new(context.fancy_error( - &format!("`{}` is not callable", func.kind), - vec![Label::primary( - func.span, - &format!( - "`{}` is an event, and can't be constructed in this context", - func.kind - ), - )], - vec![format!( - "Hint: to emit an event, use `emit {}(..)`", - func.kind - )], - ))), NamedThing::Item(Item::Trait(_)) => Err(FatalError::new(context.error( &format!("`{}` is not callable", func.kind), func.span, diff --git a/crates/analyzer/src/traversal/functions.rs b/crates/analyzer/src/traversal/functions.rs index 9663aad94e..a43b624612 100644 --- a/crates/analyzer/src/traversal/functions.rs +++ b/crates/analyzer/src/traversal/functions.rs @@ -1,10 +1,10 @@ use crate::context::{AnalyzerContext, ExpressionAttributes, Location, NamedThing}; use crate::display::Displayable; -use crate::namespace::items::{EnumVariantId, Item}; +use crate::namespace::items::EnumVariantId; use crate::namespace::scopes::{BlockScope, BlockScopeType}; -use crate::namespace::types::{EventField, Type, TypeId}; +use crate::namespace::types::{Type, TypeId}; use crate::pattern_analysis::PatternMatrix; -use crate::traversal::{assignments, call_args, declarations, expressions}; +use crate::traversal::{assignments, declarations, expressions}; use crate::{ errors::{self, FatalError}, namespace::items::EnumVariantKind, @@ -35,7 +35,6 @@ fn func_stmt(scope: &mut BlockScope, stmt: &Node) -> Result<(), Fa VarDecl { .. } => declarations::var_decl(scope, stmt), ConstantDecl { .. } => declarations::const_decl(scope, stmt), Assign { .. } => assignments::assign(scope, stmt), - Emit { .. } => emit(scope, stmt), AugAssign { .. } => assignments::aug_assign(scope, stmt), For { .. } => for_loop(scope, stmt), While { .. } => while_loop(scope, stmt), @@ -552,97 +551,6 @@ fn while_loop(scope: &mut BlockScope, stmt: &Node) -> Result<(), F } } -fn emit(scope: &mut BlockScope, stmt: &Node) -> Result<(), FatalError> { - if let fe::FuncStmt::Emit { name, args } = &stmt.kind { - match scope.resolve_name(&name.kind, name.span)? { - None => { - scope.error( - &format!("undefined event: `{}`", name.kind), - name.span, - "undefined event", - ); - } - Some(NamedThing::Item(Item::Event(event))) => { - scope.root.add_emit(stmt, event); - - // Check visibility of event. - if !event.is_public(scope.db()) && event.module(scope.db()) != scope.module() { - let module_name = event.module(scope.db()).name(scope.db()); - scope.fancy_error( - &format!( - "the event `{}` is private", - name.kind, - ), - vec![ - Label::primary(name.span, "this event is not `pub`"), - Label::secondary( - event.data(scope.db()).ast.span, - format!("`{}` is defined here", name.kind) - ), - ], - vec![ - format!("`{}` can only be used within `{}`", name.kind, module_name), - format!("Hint: use `pub event {event}` to make `{event}` visible from outside of `{module}`", event=name.kind, module=module_name), - ], - ); - } - - if let Some(context_type) = scope.get_context_type() { - // we add ctx to the list of expected params - let params_with_ctx = [ - vec![EventField { - name: "ctx".into(), - typ: Ok(context_type), - is_indexed: false, - }], - event.typ(scope.db()).fields.clone(), - ] - .concat(); - call_args::validate_named_args( - scope, - &name.kind, - name.span, - args, - ¶ms_with_ctx, - )?; - } else { - scope.fancy_error( - "`Context` is not defined", - vec![ - Label::primary( - stmt.span, - "`ctx` must be defined and passed into the event", - ), - Label::secondary( - scope.parent_function().name_span(scope.db()), - "Note: declare `ctx` in this function signature", - ), - Label::secondary( - scope.parent_function().name_span(scope.db()), - "Example: `pub fn foo(ctx: Context, ...)`", - ), - ], - vec!["Example: emit MyEvent(ctx, ...)".into()], - ); - } - } - Some(named_thing) => { - scope.error( - "`emit` expects an event", - name.span, - &format!( - "`{}` is a {} name; expected an event", - &name.kind, - named_thing.item_kind_display_name(), - ), - ); - } - } - return Ok(()); - } - unreachable!() -} - fn assert(scope: &mut BlockScope, stmt: &Node) -> Result<(), FatalError> { if let fe::FuncStmt::Assert { test, msg } = &stmt.kind { let test_type = expressions::value_expr(scope, test, None)?.typ; diff --git a/crates/analyzer/tests/analysis.rs b/crates/analyzer/tests/analysis.rs index ecb8bbb517..10b28d9b9b 100644 --- a/crates/analyzer/tests/analysis.rs +++ b/crates/analyzer/tests/analysis.rs @@ -1,6 +1,5 @@ use fe_analyzer::display::Displayable; use fe_analyzer::namespace::items::{self, IngotId, IngotMode, Item, ModuleId, TypeDef}; -use fe_analyzer::namespace::types::TypeId; use fe_analyzer::{AnalyzerDb, TestDb}; use fe_common::diagnostics::{diagnostics_string, print_diagnostics, Diagnostic, Label, Severity}; use fe_common::files::{FileKind, Utf8Path}; @@ -351,11 +350,6 @@ fn build_snapshot(db: &dyn AnalyzerDb, module: items::ModuleId) -> String { .map(|field| (field.data(db).ast.span, field.typ(db).unwrap())) .collect::>(), ), - contract - .events(db) - .values() - .flat_map(|id| event_diagnostics(*id, db)) - .collect(), contract .functions(db) .values() @@ -382,7 +376,6 @@ fn build_snapshot(db: &dyn AnalyzerDb, module: items::ModuleId) -> String { id.span(db), &id.typ(db).unwrap().display(db), )], - Item::Event(id) => event_diagnostics(*id, db), // Built-in stuff Item::Type(TypeDef::Primitive(_)) | Item::GenericType(_) @@ -461,10 +454,6 @@ fn function_diagnostics(fun: items::FunctionId, db: &dyn AnalyzerDb) -> Vec Vec Vec { - // Event field spans are a bit of a hassle right now - label_in_non_overlapping_groups( - db, - &event - .data(db) - .ast - .kind - .fields - .iter() - .map(|node| node.span) - .zip( - event - .typ(db) - .fields - .iter() - .map(|field| field.typ.clone().unwrap()), - ) - .collect::>(), - ) -} - fn lookup_spans( node_attrs: &IndexMap, spans: &HashMap, diff --git a/crates/analyzer/tests/errors.rs b/crates/analyzer/tests/errors.rs index 781754373d..2c460a0f7f 100644 --- a/crates/analyzer/tests/errors.rs +++ b/crates/analyzer/tests/errors.rs @@ -131,9 +131,6 @@ test_stmt! { call_balance_with_arg, "unsafe { std::evm::balance(address(0)) }" } test_stmt! { clone_arg_count, "let x: Array = [5, 6]\nlet y: Array = x.clone(y)" } test_stmt! { continue_without_loop, "continue" } test_stmt! { continue_without_loop_2, "if true { continue }" } -test_stmt! { emit_undefined_event, "emit MyEvent()" } -test_stmt! { emit_type_name, "emit u8()" } -test_stmt! { emit_variable, "let x: u8 = 10\nemit x()" } test_stmt! { int_type_generic_arg_list, "let x: u256<>" } test_stmt! { int_type_generic_arg, "let x: u256<10>" } test_stmt! { int_type_constructor_generic_arg_list, "u256<>(10)" } @@ -227,7 +224,6 @@ test_file! { call_generic_function_with_unsatisfied_bound} test_file! { call_builtin_object } test_file! { call_create_with_wrong_type } test_file! { call_create2_with_wrong_type } -test_file! { call_event_with_wrong_types } test_file! { call_static_function_without_double_colon } test_file! { call_undefined_function_on_external_contract } test_file! { call_undefined_function_on_memory_struct } @@ -245,7 +241,6 @@ test_file! { const_generics_param } test_file! { const_local } test_file! { duplicate_arg_in_contract_method } test_file! { duplicate_contract_in_module } -test_file! { duplicate_event_in_contract } test_file! { duplicate_field_in_contract } test_file! { duplicate_field_in_struct } test_file! { duplicate_method_in_contract } @@ -255,9 +250,9 @@ test_file! { duplicate_var_in_child_scope } test_file! { duplicate_var_in_contract_method } test_file! { duplicate_var_in_for_loop } test_file! { duplicate_generic_params } -test_file! { emit_bad_args } test_file! { external_call_type_error } test_file! { external_call_wrong_number_of_params } +test_file! { emittable_not_implementable } test_file! { contract_function_with_generic_params } test_file! { indexed_event } test_file! { invalid_compiler_version } @@ -269,6 +264,7 @@ test_file! { invalid_impl_type } test_file! { invalid_impl_location } test_file! { invalid_msg_field } test_file! { invalid_string_field } +test_file! { invalid_struct_attribute } test_file! { invalid_struct_field } test_file! { invalid_tuple_field } test_file! { invalid_tx_field } @@ -348,11 +344,9 @@ test_file! { ctx_undeclared } test_file! { ctx_missing_internal_call } test_file! { ctx_missing_create } test_file! { ctx_missing_load } -test_file! { ctx_missing_event } test_file! { ctx_builtins_param_incorrect_type } test_file! { ctx_undefined_create } test_file! { ctx_undefined_create2 } -test_file! { ctx_undefined_event } test_file! { uninit_values } test_file! { invalid_repeat_length } test_file! { invalid_struct_pub_qualifier } diff --git a/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap b/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap index 52f35296b6..af992074e4 100644 --- a/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__abi_encoding_stress.snap @@ -18,35 +18,35 @@ note: note: ┌─ abi_encoding_stress.fe:9:5 │ - 9 │ my_addrs: Array + 9 │ pub my_addrs: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array +10 │ pub my_u128: u128 + │ ^^^^^^^^^^^^^^^^^ u128 +11 │ pub my_string: String<10> + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ String<10> +12 │ pub my_u16s: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array +13 │ pub my_bool: bool + │ ^^^^^^^^^^^^^^^^^ bool +14 │ pub my_bytes: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + +note: + ┌─ abi_encoding_stress.fe:18:5 + │ +18 │ my_addrs: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array -10 │ my_u128: u128 +19 │ my_u128: u128 │ ^^^^^^^^^^^^^ u128 -11 │ my_string: String<10> +20 │ my_string: String<10> │ ^^^^^^^^^^^^^^^^^^^^^ String<10> -12 │ my_u16s: Array +21 │ my_u16s: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array -13 │ my_bool: bool +22 │ my_bool: bool │ ^^^^^^^^^^^^^ bool -14 │ my_bytes: Array +23 │ my_bytes: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array -note: - ┌─ abi_encoding_stress.fe:17:9 - │ -17 │ my_addrs: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array -18 │ my_u128: u128 - │ ^^^^^^^^^^^^^ u128 -19 │ my_string: String<10> - │ ^^^^^^^^^^^^^^^^^^^^^ String<10> -20 │ my_u16s: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array -21 │ my_bool: bool - │ ^^^^^^^^^^^^^ bool -22 │ my_bytes: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array - note: ┌─ abi_encoding_stress.fe:25:5 │ @@ -434,86 +434,98 @@ note: ┌─ abi_encoding_stress.fe:85:5 │ 85 │ ╭ pub fn emit_my_event(self, ctx: Context) { -86 │ │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) +86 │ │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) 87 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }] -> () note: - ┌─ abi_encoding_stress.fe:86:22 + ┌─ abi_encoding_stress.fe:86:9 + │ +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^ ^^^^ Foo: Value + │ │ + │ Context: Memory + +note: + ┌─ abi_encoding_stress.fe:86:36 + │ +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^^ Array: Storage { nonce: Some(0) } + +note: + ┌─ abi_encoding_stress.fe:86:36 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^ ^^^^ Foo: Value - │ │ - │ Context: Memory +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ Array: Storage { nonce: Some(0) } => Memory note: - ┌─ abi_encoding_stress.fe:86:37 + ┌─ abi_encoding_stress.fe:86:69 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^^^^^^^^^^^ Array: Storage { nonce: Some(0) } +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ u128: Storage { nonce: Some(1) } => Value note: - ┌─ abi_encoding_stress.fe:86:37 + ┌─ abi_encoding_stress.fe:86:94 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value - │ │ - │ Array: Storage { nonce: Some(0) } => Memory +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^^^ String<10>: Storage { nonce: Some(2) } note: - ┌─ abi_encoding_stress.fe:86:70 + ┌─ abi_encoding_stress.fe:86:94 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^^^^^^^^^^ ^^^^ Foo: Value - │ │ - │ u128: Storage { nonce: Some(1) } => Value +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ String<10>: Storage { nonce: Some(2) } => Memory note: - ┌─ abi_encoding_stress.fe:86:95 + ┌─ abi_encoding_stress.fe:86:128 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^^^^^^^^^^^^ String<10>: Storage { nonce: Some(2) } +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^ Array: Storage { nonce: Some(3) } note: - ┌─ abi_encoding_stress.fe:86:95 + ┌─ abi_encoding_stress.fe:86:128 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value - │ │ - │ String<10>: Storage { nonce: Some(2) } => Memory +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ Array: Storage { nonce: Some(3) } => Memory note: - ┌─ abi_encoding_stress.fe:86:129 + ┌─ abi_encoding_stress.fe:86:160 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^^^^^^^^^^ Array: Storage { nonce: Some(3) } +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ bool: Storage { nonce: Some(4) } => Value note: - ┌─ abi_encoding_stress.fe:86:129 + ┌─ abi_encoding_stress.fe:86:184 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value - │ │ - │ Array: Storage { nonce: Some(3) } => Memory +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^^ Array: Storage { nonce: Some(5) } note: - ┌─ abi_encoding_stress.fe:86:161 + ┌─ abi_encoding_stress.fe:86:184 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^^^^^^^^^^ ^^^^ Foo: Value - │ │ - │ bool: Storage { nonce: Some(4) } => Value +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(5) } => Memory note: - ┌─ abi_encoding_stress.fe:86:185 + ┌─ abi_encoding_stress.fe:86:18 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^^^^^^^^^^^ Array: Storage { nonce: Some(5) } +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ MyEvent: Memory note: - ┌─ abi_encoding_stress.fe:86:185 + ┌─ abi_encoding_stress.fe:86:9 │ -86 │ emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) - │ ^^^^^^^^^^^^^^^^^^^^^^ Array: Storage { nonce: Some(5) } => Memory +86 │ ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value diff --git a/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap b/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap index 690799b08a..0dbef5e33f 100644 --- a/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__data_copying_stress.snap @@ -6,26 +6,26 @@ expression: "build_snapshot(&db, module)" note: ┌─ data_copying_stress.fe:2:5 │ -2 │ my_string: String<42> - │ ^^^^^^^^^^^^^^^^^^^^^ String<42> -3 │ my_other_string: String<42> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<42> -4 │ my_u256: u256 - │ ^^^^^^^^^^^^^ u256 -5 │ my_other_u256: u256 - │ ^^^^^^^^^^^^^^^^^^^ u256 -6 │ my_nums: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^ Array -7 │ my_addrs: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array +2 │ pub my_string: String<42> + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ String<42> +3 │ pub my_u256: u256 + │ ^^^^^^^^^^^^^^^^^ u256 note: - ┌─ data_copying_stress.fe:10:9 + ┌─ data_copying_stress.fe:7:5 │ -10 │ my_string: String<42> - │ ^^^^^^^^^^^^^^^^^^^^^ String<42> -11 │ my_u256: u256 - │ ^^^^^^^^^^^^^ u256 + 7 │ my_string: String<42> + │ ^^^^^^^^^^^^^^^^^^^^^ String<42> + 8 │ my_other_string: String<42> + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<42> + 9 │ my_u256: u256 + │ ^^^^^^^^^^^^^ u256 +10 │ my_other_u256: u256 + │ ^^^^^^^^^^^^^^^^^^^ u256 +11 │ my_nums: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^ Array +12 │ my_addrs: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array note: ┌─ data_copying_stress.fe:14:5 @@ -571,18 +571,30 @@ note: ┌─ data_copying_stress.fe:69:5 │ 69 │ ╭ fn emit_my_event_internal(ctx: Context, _ my_string: String<42>, _ my_u256: u256) { -70 │ │ emit MyEvent(ctx, my_string, my_u256) +70 │ │ ctx.emit(MyEvent(my_string, my_u256)) 71 │ │ } │ ╰─────^ self: None, params: [{ label: None, name: ctx, typ: Context }, { label: Some("_"), name: my_string, typ: String<42> }, { label: Some("_"), name: my_u256, typ: u256 }] -> () note: - ┌─ data_copying_stress.fe:70:22 + ┌─ data_copying_stress.fe:70:9 │ -70 │ emit MyEvent(ctx, my_string, my_u256) - │ ^^^ ^^^^^^^^^ ^^^^^^^ u256: Value - │ │ │ - │ │ String<42>: Memory - │ Context: Memory +70 │ ctx.emit(MyEvent(my_string, my_u256)) + │ ^^^ ^^^^^^^^^ ^^^^^^^ u256: Value + │ │ │ + │ │ String<42>: Memory + │ Context: Memory + +note: + ┌─ data_copying_stress.fe:70:18 + │ +70 │ ctx.emit(MyEvent(my_string, my_u256)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ MyEvent: Memory + +note: + ┌─ data_copying_stress.fe:70:9 + │ +70 │ ctx.emit(MyEvent(my_string, my_u256)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: ┌─ data_copying_stress.fe:73:5 diff --git a/crates/analyzer/tests/snapshots/analysis__erc20_token.snap b/crates/analyzer/tests/snapshots/analysis__erc20_token.snap index 1085f02449..0ff8be2368 100644 --- a/crates/analyzer/tests/snapshots/analysis__erc20_token.snap +++ b/crates/analyzer/tests/snapshots/analysis__erc20_token.snap @@ -4,320 +4,322 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ erc20_token.fe:2:5 + ┌─ erc20_token.fe:3:5 │ -2 │ _balances: Map - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map -3 │ _allowances: Map> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> -4 │ _total_supply: u256 - │ ^^^^^^^^^^^^^^^^^^^ u256 -5 │ _name: String<100> - │ ^^^^^^^^^^^^^^^^^^ String<100> -6 │ _symbol: String<100> - │ ^^^^^^^^^^^^^^^^^^^^ String<100> -7 │ _decimals: u8 - │ ^^^^^^^^^^^^^ u8 +3 │ pub owner: address + │ ^^^^^^^^^^^^^^^^^^ address +4 │ #indexed +5 │ pub spender: address + │ ^^^^^^^^^^^^^^^^^^^^ address +6 │ pub value: u256 + │ ^^^^^^^^^^^^^^^ u256 + +note: + ┌─ erc20_token.fe:11:5 + │ +11 │ pub from: address + │ ^^^^^^^^^^^^^^^^^ address +12 │ #indexed +13 │ pub to: address + │ ^^^^^^^^^^^^^^^ address +14 │ pub value: u256 + │ ^^^^^^^^^^^^^^^ u256 + +note: + ┌─ erc20_token.fe:18:5 + │ +18 │ _balances: Map + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map +19 │ _allowances: Map> + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> +20 │ _total_supply: u256 + │ ^^^^^^^^^^^^^^^^^^^ u256 +21 │ _name: String<100> + │ ^^^^^^^^^^^^^^^^^^ String<100> +22 │ _symbol: String<100> + │ ^^^^^^^^^^^^^^^^^^^^ String<100> +23 │ _decimals: u8 + │ ^^^^^^^^^^^^^ u8 note: - ┌─ erc20_token.fe:10:9 - │ -10 │ idx owner: address - │ ^^^^^^^^^^^^^^^^^^ address -11 │ idx spender: address - │ ^^^^^^^^^^^^^^^^^^^^ address -12 │ value: u256 - │ ^^^^^^^^^^^ u256 - -note: - ┌─ erc20_token.fe:16:9 - │ -16 │ idx from: address - │ ^^^^^^^^^^^^^^^^^ address -17 │ idx to: address - │ ^^^^^^^^^^^^^^^ address -18 │ value: u256 - │ ^^^^^^^^^^^ u256 - -note: - ┌─ erc20_token.fe:28:5 + ┌─ erc20_token.fe:32:5 │ -28 │ ╭ pub fn name(self) -> String<100> { -29 │ │ return self._name.to_mem() -30 │ │ } +32 │ ╭ pub fn name(self) -> String<100> { +33 │ │ return self._name.to_mem() +34 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> String<100> note: - ┌─ erc20_token.fe:29:16 + ┌─ erc20_token.fe:33:16 │ -29 │ return self._name.to_mem() +33 │ return self._name.to_mem() │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:29:16 + ┌─ erc20_token.fe:33:16 │ -29 │ return self._name.to_mem() +33 │ return self._name.to_mem() │ ^^^^^^^^^^ String<100>: Storage { nonce: Some(3) } note: - ┌─ erc20_token.fe:29:16 + ┌─ erc20_token.fe:33:16 │ -29 │ return self._name.to_mem() +33 │ return self._name.to_mem() │ ^^^^^^^^^^^^^^^^^^^ String<100>: Storage { nonce: Some(3) } => Memory note: - ┌─ erc20_token.fe:32:5 + ┌─ erc20_token.fe:36:5 │ -32 │ ╭ pub fn symbol(self) -> String<100> { -33 │ │ return self._symbol.to_mem() -34 │ │ } +36 │ ╭ pub fn symbol(self) -> String<100> { +37 │ │ return self._symbol.to_mem() +38 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> String<100> note: - ┌─ erc20_token.fe:33:16 + ┌─ erc20_token.fe:37:16 │ -33 │ return self._symbol.to_mem() +37 │ return self._symbol.to_mem() │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:33:16 + ┌─ erc20_token.fe:37:16 │ -33 │ return self._symbol.to_mem() +37 │ return self._symbol.to_mem() │ ^^^^^^^^^^^^ String<100>: Storage { nonce: Some(4) } note: - ┌─ erc20_token.fe:33:16 + ┌─ erc20_token.fe:37:16 │ -33 │ return self._symbol.to_mem() +37 │ return self._symbol.to_mem() │ ^^^^^^^^^^^^^^^^^^^^^ String<100>: Storage { nonce: Some(4) } => Memory note: - ┌─ erc20_token.fe:36:5 + ┌─ erc20_token.fe:40:5 │ -36 │ ╭ pub fn decimals(self) -> u8 { -37 │ │ return self._decimals -38 │ │ } +40 │ ╭ pub fn decimals(self) -> u8 { +41 │ │ return self._decimals +42 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> u8 note: - ┌─ erc20_token.fe:37:16 + ┌─ erc20_token.fe:41:16 │ -37 │ return self._decimals +41 │ return self._decimals │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:37:16 + ┌─ erc20_token.fe:41:16 │ -37 │ return self._decimals +41 │ return self._decimals │ ^^^^^^^^^^^^^^ u8: Storage { nonce: Some(5) } => Value note: - ┌─ erc20_token.fe:40:5 + ┌─ erc20_token.fe:44:5 │ -40 │ ╭ pub fn totalSupply(self) -> u256 { -41 │ │ return self._total_supply -42 │ │ } +44 │ ╭ pub fn totalSupply(self) -> u256 { +45 │ │ return self._total_supply +46 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> u256 note: - ┌─ erc20_token.fe:41:16 + ┌─ erc20_token.fe:45:16 │ -41 │ return self._total_supply +45 │ return self._total_supply │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:41:16 + ┌─ erc20_token.fe:45:16 │ -41 │ return self._total_supply +45 │ return self._total_supply │ ^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(2) } => Value note: - ┌─ erc20_token.fe:44:5 + ┌─ erc20_token.fe:48:5 │ -44 │ ╭ pub fn balanceOf(self, _ account: address) -> u256 { -45 │ │ return self._balances[account] -46 │ │ } +48 │ ╭ pub fn balanceOf(self, _ account: address) -> u256 { +49 │ │ return self._balances[account] +50 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: Some("_"), name: account, typ: address }] -> u256 note: - ┌─ erc20_token.fe:45:16 + ┌─ erc20_token.fe:49:16 │ -45 │ return self._balances[account] +49 │ return self._balances[account] │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:45:16 + ┌─ erc20_token.fe:49:16 │ -45 │ return self._balances[account] +49 │ return self._balances[account] │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:45:16 + ┌─ erc20_token.fe:49:16 │ -45 │ return self._balances[account] +49 │ return self._balances[account] │ ^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:48:5 + ┌─ erc20_token.fe:52:5 │ -48 │ ╭ pub fn transfer(self, ctx: Context, recipient: address, value: u256) -> bool { -49 │ │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) -50 │ │ return true -51 │ │ } +52 │ ╭ pub fn transfer(self, ctx: Context, recipient: address, value: u256) -> bool { +53 │ │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) +54 │ │ return true +55 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: recipient, typ: address }, { label: None, name: value, typ: u256 }] -> bool note: - ┌─ erc20_token.fe:49:9 + ┌─ erc20_token.fe:53:9 │ -49 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) +53 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ ERC20: Value note: - ┌─ erc20_token.fe:49:37 + ┌─ erc20_token.fe:53:37 │ -49 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) +53 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) │ ^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:49:9 + ┌─ erc20_token.fe:53:9 │ -49 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) +53 │ self._transfer(ctx, sender: ctx.msg_sender(), recipient, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -50 │ return true +54 │ return true │ ^^^^ bool: Value note: - ┌─ erc20_token.fe:53:5 + ┌─ erc20_token.fe:57:5 │ -53 │ ╭ pub fn allowance(self, owner: address, spender: address) -> u256 { -54 │ │ return self._allowances[owner][spender] -55 │ │ } +57 │ ╭ pub fn allowance(self, owner: address, spender: address) -> u256 { +58 │ │ return self._allowances[owner][spender] +59 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: owner, typ: address }, { label: None, name: spender, typ: address }] -> u256 note: - ┌─ erc20_token.fe:54:16 + ┌─ erc20_token.fe:58:16 │ -54 │ return self._allowances[owner][spender] +58 │ return self._allowances[owner][spender] │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:54:16 + ┌─ erc20_token.fe:58:16 │ -54 │ return self._allowances[owner][spender] +58 │ return self._allowances[owner][spender] │ ^^^^^^^^^^^^^^^^ ^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:54:16 + ┌─ erc20_token.fe:58:16 │ -54 │ return self._allowances[owner][spender] +58 │ return self._allowances[owner][spender] │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:54:16 + ┌─ erc20_token.fe:58:16 │ -54 │ return self._allowances[owner][spender] +58 │ return self._allowances[owner][spender] │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:57:5 + ┌─ erc20_token.fe:61:5 │ -57 │ ╭ pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { -58 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) -59 │ │ return true -60 │ │ } +61 │ ╭ pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { +62 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +63 │ │ return true +64 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: spender, typ: address }, { label: None, name: value, typ: u256 }] -> bool note: - ┌─ erc20_token.fe:58:9 + ┌─ erc20_token.fe:62:9 │ -58 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +62 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ ERC20: Value note: - ┌─ erc20_token.fe:58:35 + ┌─ erc20_token.fe:62:35 │ -58 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +62 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:58:9 + ┌─ erc20_token.fe:62:9 │ -58 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +62 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -59 │ return true +63 │ return true │ ^^^^ bool: Value note: - ┌─ erc20_token.fe:62:5 + ┌─ erc20_token.fe:66:5 │ -62 │ ╭ pub fn transferFrom(self, ctx: Context, sender: address, recipient: address, value: u256) -> bool { -63 │ │ assert self._allowances[sender][ctx.msg_sender()] >= value -64 │ │ self._transfer(ctx, sender, recipient, value) -65 │ │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) -66 │ │ return true -67 │ │ } +66 │ ╭ pub fn transferFrom(self, ctx: Context, sender: address, recipient: address, value: u256) -> bool { +67 │ │ assert self._allowances[sender][ctx.msg_sender()] >= value +68 │ │ self._transfer(ctx, sender, recipient, value) +69 │ │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +70 │ │ return true +71 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: sender, typ: address }, { label: None, name: recipient, typ: address }, { label: None, name: value, typ: u256 }] -> bool note: - ┌─ erc20_token.fe:63:16 + ┌─ erc20_token.fe:67:16 │ -63 │ assert self._allowances[sender][ctx.msg_sender()] >= value +67 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:63:16 + ┌─ erc20_token.fe:67:16 │ -63 │ assert self._allowances[sender][ctx.msg_sender()] >= value +67 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:63:16 + ┌─ erc20_token.fe:67:16 │ -63 │ assert self._allowances[sender][ctx.msg_sender()] >= value +67 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:63:41 + ┌─ erc20_token.fe:67:41 │ -63 │ assert self._allowances[sender][ctx.msg_sender()] >= value +67 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:63:16 + ┌─ erc20_token.fe:67:16 │ -63 │ assert self._allowances[sender][ctx.msg_sender()] >= value +67 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:63:16 + ┌─ erc20_token.fe:67:16 │ -63 │ assert self._allowances[sender][ctx.msg_sender()] >= value +67 │ assert self._allowances[sender][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -64 │ self._transfer(ctx, sender, recipient, value) +68 │ self._transfer(ctx, sender, recipient, value) │ ^^^^ ^^^ ^^^^^^ ^^^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ │ │ │ │ address: Value @@ -326,11 +328,11 @@ note: │ ERC20: Value note: - ┌─ erc20_token.fe:64:9 + ┌─ erc20_token.fe:68:9 │ -64 │ self._transfer(ctx, sender, recipient, value) +68 │ self._transfer(ctx, sender, recipient, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -65 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +69 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^ ^^^ ^^^^^^ ^^^ Context: Memory │ │ │ │ │ │ │ address: Value @@ -338,702 +340,750 @@ note: │ ERC20: Value note: - ┌─ erc20_token.fe:65:52 + ┌─ erc20_token.fe:69:52 │ -65 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +69 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:65:77 + ┌─ erc20_token.fe:69:77 │ -65 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +69 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:65:77 + ┌─ erc20_token.fe:69:77 │ -65 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +69 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:65:102 + ┌─ erc20_token.fe:69:102 │ -65 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +69 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:65:77 + ┌─ erc20_token.fe:69:77 │ -65 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +69 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:65:77 + ┌─ erc20_token.fe:69:77 │ -65 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +69 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ erc20_token.fe:65:9 + ┌─ erc20_token.fe:69:9 │ -65 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) +69 │ self._approve(ctx, owner: sender, spender: ctx.msg_sender(), value: self._allowances[sender][ctx.msg_sender()] - value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -66 │ return true +70 │ return true │ ^^^^ bool: Value note: - ┌─ erc20_token.fe:69:5 + ┌─ erc20_token.fe:73:5 │ -69 │ ╭ pub fn increaseAllowance(self, ctx: Context, spender: address, addedValue: u256) -> bool { -70 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) -71 │ │ return true -72 │ │ } +73 │ ╭ pub fn increaseAllowance(self, ctx: Context, spender: address, addedValue: u256) -> bool { +74 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +75 │ │ return true +76 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: spender, typ: address }, { label: None, name: addedValue, typ: u256 }] -> bool note: - ┌─ erc20_token.fe:70:9 + ┌─ erc20_token.fe:74:9 │ -70 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +74 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ ERC20: Value note: - ┌─ erc20_token.fe:70:35 + ┌─ erc20_token.fe:74:35 │ -70 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +74 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^ ERC20: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:70:69 + ┌─ erc20_token.fe:74:69 │ -70 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +74 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:70:86 + ┌─ erc20_token.fe:74:86 │ -70 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +74 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:70:69 + ┌─ erc20_token.fe:74:69 │ -70 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +74 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:70:69 + ┌─ erc20_token.fe:74:69 │ -70 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +74 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:70:69 + ┌─ erc20_token.fe:74:69 │ -70 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +74 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ erc20_token.fe:70:9 + ┌─ erc20_token.fe:74:9 │ -70 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) +74 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] + addedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -71 │ return true +75 │ return true │ ^^^^ bool: Value note: - ┌─ erc20_token.fe:74:5 + ┌─ erc20_token.fe:78:5 │ -74 │ ╭ pub fn decreaseAllowance(self, ctx: Context, spender: address, subtractedValue: u256) -> bool { -75 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) -76 │ │ return true -77 │ │ } +78 │ ╭ pub fn decreaseAllowance(self, ctx: Context, spender: address, subtractedValue: u256) -> bool { +79 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +80 │ │ return true +81 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: spender, typ: address }, { label: None, name: subtractedValue, typ: u256 }] -> bool note: - ┌─ erc20_token.fe:75:9 + ┌─ erc20_token.fe:79:9 │ -75 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +79 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ ERC20: Value note: - ┌─ erc20_token.fe:75:35 + ┌─ erc20_token.fe:79:35 │ -75 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +79 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^ ERC20: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:75:69 + ┌─ erc20_token.fe:79:69 │ -75 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +79 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:75:86 + ┌─ erc20_token.fe:79:86 │ -75 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +79 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:75:69 + ┌─ erc20_token.fe:79:69 │ -75 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +79 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:75:69 + ┌─ erc20_token.fe:79:69 │ -75 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +79 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:75:69 + ┌─ erc20_token.fe:79:69 │ -75 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +79 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ erc20_token.fe:75:9 + ┌─ erc20_token.fe:79:9 │ -75 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) +79 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value: self._allowances[ctx.msg_sender()][spender] - subtractedValue) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -76 │ return true +80 │ return true │ ^^^^ bool: Value note: - ┌─ erc20_token.fe:79:5 + ┌─ erc20_token.fe:83:5 │ -79 │ ╭ fn _transfer(self, ctx: Context, sender: address, recipient: address, value: u256) { -80 │ │ assert sender != address(0) -81 │ │ assert recipient != address(0) -82 │ │ _before_token_transfer(from: sender, to: recipient, value) +83 │ ╭ fn _transfer(self, ctx: Context, sender: address, recipient: address, value: u256) { +84 │ │ assert sender != address(0) +85 │ │ assert recipient != address(0) +86 │ │ _before_token_transfer(from: sender, to: recipient, value) · │ -85 │ │ emit Transfer(ctx, from: sender, to: recipient, value) -86 │ │ } +89 │ │ ctx.emit(Transfer(from: sender, to: recipient, value)) +90 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: sender, typ: address }, { label: None, name: recipient, typ: address }, { label: None, name: value, typ: u256 }] -> () note: - ┌─ erc20_token.fe:80:16 + ┌─ erc20_token.fe:84:16 │ -80 │ assert sender != address(0) +84 │ assert sender != address(0) │ ^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:80:26 + ┌─ erc20_token.fe:84:26 │ -80 │ assert sender != address(0) +84 │ assert sender != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:80:16 + ┌─ erc20_token.fe:84:16 │ -80 │ assert sender != address(0) +84 │ assert sender != address(0) │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -81 │ assert recipient != address(0) +85 │ assert recipient != address(0) │ ^^^^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:81:29 + ┌─ erc20_token.fe:85:29 │ -81 │ assert recipient != address(0) +85 │ assert recipient != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:81:16 + ┌─ erc20_token.fe:85:16 │ -81 │ assert recipient != address(0) +85 │ assert recipient != address(0) │ ^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -82 │ _before_token_transfer(from: sender, to: recipient, value) +86 │ _before_token_transfer(from: sender, to: recipient, value) │ ^^^^^^ ^^^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:82:9 + ┌─ erc20_token.fe:86:9 │ -82 │ _before_token_transfer(from: sender, to: recipient, value) +86 │ _before_token_transfer(from: sender, to: recipient, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -83 │ self._balances[sender] = self._balances[sender] - value +87 │ self._balances[sender] = self._balances[sender] - value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:83:9 + ┌─ erc20_token.fe:87:9 │ -83 │ self._balances[sender] = self._balances[sender] - value +87 │ self._balances[sender] = self._balances[sender] - value │ ^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:83:9 + ┌─ erc20_token.fe:87:9 │ -83 │ self._balances[sender] = self._balances[sender] - value +87 │ self._balances[sender] = self._balances[sender] - value │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ erc20_token.fe:83:34 + ┌─ erc20_token.fe:87:34 │ -83 │ self._balances[sender] = self._balances[sender] - value +87 │ self._balances[sender] = self._balances[sender] - value │ ^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:83:34 + ┌─ erc20_token.fe:87:34 │ -83 │ self._balances[sender] = self._balances[sender] - value +87 │ self._balances[sender] = self._balances[sender] - value │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:83:34 + ┌─ erc20_token.fe:87:34 │ -83 │ self._balances[sender] = self._balances[sender] - value +87 │ self._balances[sender] = self._balances[sender] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -84 │ self._balances[recipient] = self._balances[recipient] + value +88 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:84:9 + ┌─ erc20_token.fe:88:9 │ -84 │ self._balances[recipient] = self._balances[recipient] + value +88 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^^^^^^^^^^^ ^^^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:84:9 + ┌─ erc20_token.fe:88:9 │ -84 │ self._balances[recipient] = self._balances[recipient] + value +88 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ erc20_token.fe:84:37 + ┌─ erc20_token.fe:88:37 │ -84 │ self._balances[recipient] = self._balances[recipient] + value +88 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^^^^^^^^^^^ ^^^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:84:37 + ┌─ erc20_token.fe:88:37 │ -84 │ self._balances[recipient] = self._balances[recipient] + value +88 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:84:37 + ┌─ erc20_token.fe:88:37 │ -84 │ self._balances[recipient] = self._balances[recipient] + value +88 │ self._balances[recipient] = self._balances[recipient] + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -85 │ emit Transfer(ctx, from: sender, to: recipient, value) - │ ^^^ ^^^^^^ ^^^^^^^^^ ^^^^^ u256: Value - │ │ │ │ - │ │ │ address: Value - │ │ address: Value - │ Context: Memory +89 │ ctx.emit(Transfer(from: sender, to: recipient, value)) + │ ^^^ ^^^^^^ ^^^^^^^^^ ^^^^^ u256: Value + │ │ │ │ + │ │ │ address: Value + │ │ address: Value + │ Context: Memory + +note: + ┌─ erc20_token.fe:89:18 + │ +89 │ ctx.emit(Transfer(from: sender, to: recipient, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Transfer: Memory note: - ┌─ erc20_token.fe:88:5 + ┌─ erc20_token.fe:89:9 + │ +89 │ ctx.emit(Transfer(from: sender, to: recipient, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value + +note: + ┌─ erc20_token.fe:92:5 │ -88 │ ╭ fn _mint(self, ctx: Context, account: address, value: u256) { -89 │ │ assert account != address(0) -90 │ │ _before_token_transfer(from: address(0), to: account, value) -91 │ │ self._total_supply = self._total_supply + value -92 │ │ self._balances[account] = self._balances[account] + value -93 │ │ emit Transfer(ctx, from: address(0), to: account, value) -94 │ │ } +92 │ ╭ fn _mint(self, ctx: Context, account: address, value: u256) { +93 │ │ assert account != address(0) +94 │ │ _before_token_transfer(from: address(0), to: account, value) +95 │ │ self._total_supply = self._total_supply + value +96 │ │ self._balances[account] = self._balances[account] + value +97 │ │ ctx.emit(Transfer(from: address(0), to: account, value)) +98 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: account, typ: address }, { label: None, name: value, typ: u256 }] -> () note: - ┌─ erc20_token.fe:89:16 + ┌─ erc20_token.fe:93:16 │ -89 │ assert account != address(0) +93 │ assert account != address(0) │ ^^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:89:27 + ┌─ erc20_token.fe:93:27 │ -89 │ assert account != address(0) +93 │ assert account != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:89:16 + ┌─ erc20_token.fe:93:16 │ -89 │ assert account != address(0) +93 │ assert account != address(0) │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -90 │ _before_token_transfer(from: address(0), to: account, value) +94 │ _before_token_transfer(from: address(0), to: account, value) │ ^ u256: Value note: - ┌─ erc20_token.fe:90:38 + ┌─ erc20_token.fe:94:38 │ -90 │ _before_token_transfer(from: address(0), to: account, value) +94 │ _before_token_transfer(from: address(0), to: account, value) │ ^^^^^^^^^^ ^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ erc20_token.fe:90:9 + ┌─ erc20_token.fe:94:9 │ -90 │ _before_token_transfer(from: address(0), to: account, value) +94 │ _before_token_transfer(from: address(0), to: account, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -91 │ self._total_supply = self._total_supply + value +95 │ self._total_supply = self._total_supply + value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:91:9 + ┌─ erc20_token.fe:95:9 │ -91 │ self._total_supply = self._total_supply + value +95 │ self._total_supply = self._total_supply + value │ ^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ u256: Storage { nonce: Some(2) } note: - ┌─ erc20_token.fe:91:30 + ┌─ erc20_token.fe:95:30 │ -91 │ self._total_supply = self._total_supply + value +95 │ self._total_supply = self._total_supply + value │ ^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(2) } => Value note: - ┌─ erc20_token.fe:91:30 + ┌─ erc20_token.fe:95:30 │ -91 │ self._total_supply = self._total_supply + value +95 │ self._total_supply = self._total_supply + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -92 │ self._balances[account] = self._balances[account] + value +96 │ self._balances[account] = self._balances[account] + value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:92:9 + ┌─ erc20_token.fe:96:9 │ -92 │ self._balances[account] = self._balances[account] + value +96 │ self._balances[account] = self._balances[account] + value │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:92:9 + ┌─ erc20_token.fe:96:9 │ -92 │ self._balances[account] = self._balances[account] + value +96 │ self._balances[account] = self._balances[account] + value │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ erc20_token.fe:92:35 + ┌─ erc20_token.fe:96:35 │ -92 │ self._balances[account] = self._balances[account] + value +96 │ self._balances[account] = self._balances[account] + value │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:92:35 + ┌─ erc20_token.fe:96:35 │ -92 │ self._balances[account] = self._balances[account] + value +96 │ self._balances[account] = self._balances[account] + value │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:92:35 + ┌─ erc20_token.fe:96:35 │ -92 │ self._balances[account] = self._balances[account] + value +96 │ self._balances[account] = self._balances[account] + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -93 │ emit Transfer(ctx, from: address(0), to: account, value) - │ ^^^ ^ u256: Value - │ │ - │ Context: Memory +97 │ ctx.emit(Transfer(from: address(0), to: account, value)) + │ ^^^ ^ u256: Value + │ │ + │ Context: Memory note: - ┌─ erc20_token.fe:93:34 + ┌─ erc20_token.fe:97:33 │ -93 │ emit Transfer(ctx, from: address(0), to: account, value) - │ ^^^^^^^^^^ ^^^^^^^ ^^^^^ u256: Value - │ │ │ - │ │ address: Value - │ address: Value +97 │ ctx.emit(Transfer(from: address(0), to: account, value)) + │ ^^^^^^^^^^ ^^^^^^^ ^^^^^ u256: Value + │ │ │ + │ │ address: Value + │ address: Value note: - ┌─ erc20_token.fe:96:5 + ┌─ erc20_token.fe:97:18 + │ +97 │ ctx.emit(Transfer(from: address(0), to: account, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Transfer: Memory + +note: + ┌─ erc20_token.fe:97:9 + │ +97 │ ctx.emit(Transfer(from: address(0), to: account, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value + +note: + ┌─ erc20_token.fe:100:5 │ - 96 │ ╭ fn _burn(self, ctx: Context, account: address, value: u256) { - 97 │ │ assert account != address(0) - 98 │ │ _before_token_transfer(from: account, to: address(0), value) - 99 │ │ self._balances[account] = self._balances[account] - value -100 │ │ self._total_supply = self._total_supply - value -101 │ │ emit Transfer(ctx, from: account, to: address(0), value) -102 │ │ } +100 │ ╭ fn _burn(self, ctx: Context, account: address, value: u256) { +101 │ │ assert account != address(0) +102 │ │ _before_token_transfer(from: account, to: address(0), value) +103 │ │ self._balances[account] = self._balances[account] - value +104 │ │ self._total_supply = self._total_supply - value +105 │ │ ctx.emit(Transfer(from: account, to: address(0), value)) +106 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: account, typ: address }, { label: None, name: value, typ: u256 }] -> () note: - ┌─ erc20_token.fe:97:16 - │ -97 │ assert account != address(0) - │ ^^^^^^^ ^ u256: Value - │ │ - │ address: Value + ┌─ erc20_token.fe:101:16 + │ +101 │ assert account != address(0) + │ ^^^^^^^ ^ u256: Value + │ │ + │ address: Value note: - ┌─ erc20_token.fe:97:27 - │ -97 │ assert account != address(0) - │ ^^^^^^^^^^ address: Value + ┌─ erc20_token.fe:101:27 + │ +101 │ assert account != address(0) + │ ^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:97:16 - │ -97 │ assert account != address(0) - │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -98 │ _before_token_transfer(from: account, to: address(0), value) - │ ^^^^^^^ ^ u256: Value - │ │ - │ address: Value + ┌─ erc20_token.fe:101:16 + │ +101 │ assert account != address(0) + │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value +102 │ _before_token_transfer(from: account, to: address(0), value) + │ ^^^^^^^ ^ u256: Value + │ │ + │ address: Value note: - ┌─ erc20_token.fe:98:51 - │ -98 │ _before_token_transfer(from: account, to: address(0), value) - │ ^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ address: Value + ┌─ erc20_token.fe:102:51 + │ +102 │ _before_token_transfer(from: account, to: address(0), value) + │ ^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ address: Value note: - ┌─ erc20_token.fe:98:9 - │ -98 │ _before_token_transfer(from: account, to: address(0), value) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -99 │ self._balances[account] = self._balances[account] - value - │ ^^^^ ERC20: Value + ┌─ erc20_token.fe:102:9 + │ +102 │ _before_token_transfer(from: account, to: address(0), value) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value +103 │ self._balances[account] = self._balances[account] - value + │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:99:9 - │ -99 │ self._balances[account] = self._balances[account] - value - │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value - │ │ - │ Map: Storage { nonce: Some(0) } + ┌─ erc20_token.fe:103:9 + │ +103 │ self._balances[account] = self._balances[account] - value + │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value + │ │ + │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:99:9 - │ -99 │ self._balances[account] = self._balances[account] - value - │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value - │ │ - │ u256: Storage { nonce: None } + ┌─ erc20_token.fe:103:9 + │ +103 │ self._balances[account] = self._balances[account] - value + │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value + │ │ + │ u256: Storage { nonce: None } note: - ┌─ erc20_token.fe:99:35 - │ -99 │ self._balances[account] = self._balances[account] - value - │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value - │ │ - │ Map: Storage { nonce: Some(0) } + ┌─ erc20_token.fe:103:35 + │ +103 │ self._balances[account] = self._balances[account] - value + │ ^^^^^^^^^^^^^^ ^^^^^^^ address: Value + │ │ + │ Map: Storage { nonce: Some(0) } note: - ┌─ erc20_token.fe:99:35 - │ -99 │ self._balances[account] = self._balances[account] - value - │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ u256: Storage { nonce: None } => Value + ┌─ erc20_token.fe:103:35 + │ +103 │ self._balances[account] = self._balances[account] - value + │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ u256: Storage { nonce: None } => Value note: - ┌─ erc20_token.fe:99:35 + ┌─ erc20_token.fe:103:35 │ - 99 │ self._balances[account] = self._balances[account] - value +103 │ self._balances[account] = self._balances[account] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -100 │ self._total_supply = self._total_supply - value +104 │ self._total_supply = self._total_supply - value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:100:9 + ┌─ erc20_token.fe:104:9 │ -100 │ self._total_supply = self._total_supply - value +104 │ self._total_supply = self._total_supply - value │ ^^^^^^^^^^^^^^^^^^ ^^^^ ERC20: Value │ │ │ u256: Storage { nonce: Some(2) } note: - ┌─ erc20_token.fe:100:30 + ┌─ erc20_token.fe:104:30 │ -100 │ self._total_supply = self._total_supply - value +104 │ self._total_supply = self._total_supply - value │ ^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(2) } => Value note: - ┌─ erc20_token.fe:100:30 + ┌─ erc20_token.fe:104:30 │ -100 │ self._total_supply = self._total_supply - value +104 │ self._total_supply = self._total_supply - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -101 │ emit Transfer(ctx, from: account, to: address(0), value) - │ ^^^ ^^^^^^^ ^ u256: Value - │ │ │ - │ │ address: Value - │ Context: Memory +105 │ ctx.emit(Transfer(from: account, to: address(0), value)) + │ ^^^ ^^^^^^^ ^ u256: Value + │ │ │ + │ │ address: Value + │ Context: Memory note: - ┌─ erc20_token.fe:101:47 + ┌─ erc20_token.fe:105:46 │ -101 │ emit Transfer(ctx, from: account, to: address(0), value) - │ ^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ address: Value +105 │ ctx.emit(Transfer(from: account, to: address(0), value)) + │ ^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ address: Value note: - ┌─ erc20_token.fe:104:5 + ┌─ erc20_token.fe:105:18 + │ +105 │ ctx.emit(Transfer(from: account, to: address(0), value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Transfer: Memory + +note: + ┌─ erc20_token.fe:105:9 + │ +105 │ ctx.emit(Transfer(from: account, to: address(0), value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value + +note: + ┌─ erc20_token.fe:108:5 │ -104 │ ╭ fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { -105 │ │ assert owner != address(0) -106 │ │ assert spender != address(0) -107 │ │ self._allowances[owner][spender] = value -108 │ │ emit Approval(ctx, owner, spender, value) -109 │ │ } +108 │ ╭ fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { +109 │ │ assert owner != address(0) +110 │ │ assert spender != address(0) +111 │ │ self._allowances[owner][spender] = value +112 │ │ ctx.emit(Approval(owner, spender, value)) +113 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: owner, typ: address }, { label: None, name: spender, typ: address }, { label: None, name: value, typ: u256 }] -> () note: - ┌─ erc20_token.fe:105:16 + ┌─ erc20_token.fe:109:16 │ -105 │ assert owner != address(0) +109 │ assert owner != address(0) │ ^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:105:25 + ┌─ erc20_token.fe:109:25 │ -105 │ assert owner != address(0) +109 │ assert owner != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:105:16 + ┌─ erc20_token.fe:109:16 │ -105 │ assert owner != address(0) +109 │ assert owner != address(0) │ ^^^^^^^^^^^^^^^^^^^ bool: Value -106 │ assert spender != address(0) +110 │ assert spender != address(0) │ ^^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ erc20_token.fe:106:27 + ┌─ erc20_token.fe:110:27 │ -106 │ assert spender != address(0) +110 │ assert spender != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ erc20_token.fe:106:16 + ┌─ erc20_token.fe:110:16 │ -106 │ assert spender != address(0) +110 │ assert spender != address(0) │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -107 │ self._allowances[owner][spender] = value +111 │ self._allowances[owner][spender] = value │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:107:9 + ┌─ erc20_token.fe:111:9 │ -107 │ self._allowances[owner][spender] = value +111 │ self._allowances[owner][spender] = value │ ^^^^^^^^^^^^^^^^ ^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ erc20_token.fe:107:9 + ┌─ erc20_token.fe:111:9 │ -107 │ self._allowances[owner][spender] = value +111 │ self._allowances[owner][spender] = value │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ erc20_token.fe:107:9 + ┌─ erc20_token.fe:111:9 │ -107 │ self._allowances[owner][spender] = value +111 │ self._allowances[owner][spender] = value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } -108 │ emit Approval(ctx, owner, spender, value) - │ ^^^ ^^^^^ ^^^^^^^ ^^^^^ u256: Value - │ │ │ │ - │ │ │ address: Value - │ │ address: Value - │ Context: Memory +112 │ ctx.emit(Approval(owner, spender, value)) + │ ^^^ ^^^^^ ^^^^^^^ ^^^^^ u256: Value + │ │ │ │ + │ │ │ address: Value + │ │ address: Value + │ Context: Memory + +note: + ┌─ erc20_token.fe:112:18 + │ +112 │ ctx.emit(Approval(owner, spender, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Approval: Memory note: - ┌─ erc20_token.fe:111:5 + ┌─ erc20_token.fe:112:9 + │ +112 │ ctx.emit(Approval(owner, spender, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value + +note: + ┌─ erc20_token.fe:115:5 │ -111 │ ╭ fn _setup_decimals(self, _ decimals_: u8) { -112 │ │ self._decimals = decimals_ -113 │ │ } +115 │ ╭ fn _setup_decimals(self, _ decimals_: u8) { +116 │ │ self._decimals = decimals_ +117 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: Some("_"), name: decimals_, typ: u8 }] -> () note: - ┌─ erc20_token.fe:112:9 + ┌─ erc20_token.fe:116:9 │ -112 │ self._decimals = decimals_ +116 │ self._decimals = decimals_ │ ^^^^ ERC20: Value note: - ┌─ erc20_token.fe:112:9 + ┌─ erc20_token.fe:116:9 │ -112 │ self._decimals = decimals_ +116 │ self._decimals = decimals_ │ ^^^^^^^^^^^^^^ ^^^^^^^^^ u8: Value │ │ │ u8: Storage { nonce: Some(5) } note: - ┌─ erc20_token.fe:115:5 + ┌─ erc20_token.fe:119:5 │ -115 │ fn _before_token_transfer(from: address, to: address, _ value: u256) {} +119 │ fn _before_token_transfer(from: address, to: address, _ value: u256) {} │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ self: None, params: [{ label: None, name: from, typ: address }, { label: None, name: to, typ: address }, { label: Some("_"), name: value, typ: u256 }] -> () diff --git a/crates/analyzer/tests/snapshots/analysis__events.snap b/crates/analyzer/tests/snapshots/analysis__events.snap index 52af8b4cc6..8a6e55de06 100644 --- a/crates/analyzer/tests/snapshots/analysis__events.snap +++ b/crates/analyzer/tests/snapshots/analysis__events.snap @@ -4,155 +4,204 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ events.fe:3:9 + ┌─ events.fe:3:5 │ -3 │ idx num1: u256 - │ ^^^^^^^^^^^^^^ u256 -4 │ num2: u256 - │ ^^^^^^^^^^ u256 +3 │ pub num1: u256 + │ ^^^^^^^^^^^^^^ u256 +4 │ pub num2: u256 + │ ^^^^^^^^^^^^^^ u256 note: - ┌─ events.fe:8:9 + ┌─ events.fe:8:5 │ -8 │ num: u256 - │ ^^^^^^^^^ u256 -9 │ addr: address - │ ^^^^^^^^^^^^^ address +8 │ pub num: u256 + │ ^^^^^^^^^^^^^ u256 +9 │ pub addr: address + │ ^^^^^^^^^^^^^^^^^ address note: - ┌─ events.fe:13:9 + ┌─ events.fe:13:5 │ -13 │ num1: u256 - │ ^^^^^^^^^^ u256 -14 │ idx addr: address - │ ^^^^^^^^^^^^^^^^^ address -15 │ num2: u256 - │ ^^^^^^^^^^ u256 -16 │ my_bytes: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array - -note: - ┌─ events.fe:20:9 +13 │ pub num1: u256 + │ ^^^^^^^^^^^^^^ u256 +14 │ #indexed +15 │ pub addr: address + │ ^^^^^^^^^^^^^^^^^ address +16 │ pub num2: u256 + │ ^^^^^^^^^^^^^^ u256 +17 │ pub my_bytes: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array + +note: + ┌─ events.fe:21:5 │ -20 │ addrs: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^ Array +21 │ pub addrs: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array note: - ┌─ events.fe:23:5 + ┌─ events.fe:26:5 │ -23 │ ╭ pub fn emit_nums(ctx: Context) { -24 │ │ emit Nums(ctx, num1: 26, num2: 42) -25 │ │ } +26 │ ╭ pub fn emit_nums(ctx: Context) { +27 │ │ ctx.emit(Nums(num1: 26, num2: 42)) +28 │ │ } │ ╰─────^ self: None, params: [{ label: None, name: ctx, typ: Context }] -> () note: - ┌─ events.fe:24:19 + ┌─ events.fe:27:9 │ -24 │ emit Nums(ctx, num1: 26, num2: 42) - │ ^^^ ^^ ^^ u256: Value - │ │ │ - │ │ u256: Value - │ Context: Memory +27 │ ctx.emit(Nums(num1: 26, num2: 42)) + │ ^^^ ^^ ^^ u256: Value + │ │ │ + │ │ u256: Value + │ Context: Memory note: - ┌─ events.fe:27:5 + ┌─ events.fe:27:18 + │ +27 │ ctx.emit(Nums(num1: 26, num2: 42)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^ Nums: Memory + +note: + ┌─ events.fe:27:9 + │ +27 │ ctx.emit(Nums(num1: 26, num2: 42)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value + +note: + ┌─ events.fe:30:5 │ -27 │ ╭ pub fn emit_bases(ctx: Context, addr: address) { -28 │ │ emit Bases(ctx, num: 26, addr) -29 │ │ } +30 │ ╭ pub fn emit_bases(ctx: Context, addr: address) { +31 │ │ ctx.emit(Bases(num: 26, addr)) +32 │ │ } │ ╰─────^ self: None, params: [{ label: None, name: ctx, typ: Context }, { label: None, name: addr, typ: address }] -> () note: - ┌─ events.fe:28:20 + ┌─ events.fe:31:9 + │ +31 │ ctx.emit(Bases(num: 26, addr)) + │ ^^^ ^^ ^^^^ address: Value + │ │ │ + │ │ u256: Value + │ Context: Memory + +note: + ┌─ events.fe:31:18 + │ +31 │ ctx.emit(Bases(num: 26, addr)) + │ ^^^^^^^^^^^^^^^^^^^^ Bases: Memory + +note: + ┌─ events.fe:31:9 │ -28 │ emit Bases(ctx, num: 26, addr) - │ ^^^ ^^ ^^^^ address: Value - │ │ │ - │ │ u256: Value - │ Context: Memory +31 │ ctx.emit(Bases(num: 26, addr)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ events.fe:31:5 + ┌─ events.fe:34:5 │ -31 │ ╭ pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array) { -32 │ │ emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) -33 │ │ } +34 │ ╭ pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array) { +35 │ │ ctx.emit(Mix(num1: 26, addr, num2: 42, my_bytes)) +36 │ │ } │ ╰─────^ self: None, params: [{ label: None, name: ctx, typ: Context }, { label: None, name: addr, typ: address }, { label: None, name: my_bytes, typ: Array }] -> () note: - ┌─ events.fe:32:18 + ┌─ events.fe:35:9 + │ +35 │ ctx.emit(Mix(num1: 26, addr, num2: 42, my_bytes)) + │ ^^^ ^^ ^^^^ ^^ ^^^^^^^^ Array: Memory + │ │ │ │ │ + │ │ │ │ u256: Value + │ │ │ address: Value + │ │ u256: Value + │ Context: Memory + +note: + ┌─ events.fe:35:18 + │ +35 │ ctx.emit(Mix(num1: 26, addr, num2: 42, my_bytes)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Mix: Memory + +note: + ┌─ events.fe:35:9 │ -32 │ emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) - │ ^^^ ^^ ^^^^ ^^ ^^^^^^^^ Array: Memory - │ │ │ │ │ - │ │ │ │ u256: Value - │ │ │ address: Value - │ │ u256: Value - │ Context: Memory +35 │ ctx.emit(Mix(num1: 26, addr, num2: 42, my_bytes)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ events.fe:35:5 + ┌─ events.fe:38:5 │ -35 │ ╭ pub fn emit_addresses(ctx: Context, addr1: address, addr2: address) { -36 │ │ let addrs: Array = [address(0); 2] -37 │ │ addrs[0] = addr1 -38 │ │ addrs[1] = addr2 -39 │ │ emit Addresses(ctx, addrs) -40 │ │ } +38 │ ╭ pub fn emit_addresses(ctx: Context, addr1: address, addr2: address) { +39 │ │ let addrs: Array = [address(0); 2] +40 │ │ addrs[0] = addr1 +41 │ │ addrs[1] = addr2 +42 │ │ ctx.emit(Addresses(addrs)) +43 │ │ } │ ╰─────^ self: None, params: [{ label: None, name: ctx, typ: Context }, { label: None, name: addr1, typ: address }, { label: None, name: addr2, typ: address }] -> () note: - ┌─ events.fe:36:13 + ┌─ events.fe:39:13 │ -36 │ let addrs: Array = [address(0); 2] +39 │ let addrs: Array = [address(0); 2] │ ^^^^^ Array note: - ┌─ events.fe:36:49 + ┌─ events.fe:39:49 │ -36 │ let addrs: Array = [address(0); 2] +39 │ let addrs: Array = [address(0); 2] │ ^ u256: Value note: - ┌─ events.fe:36:41 + ┌─ events.fe:39:41 │ -36 │ let addrs: Array = [address(0); 2] +39 │ let addrs: Array = [address(0); 2] │ ^^^^^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ events.fe:36:40 + ┌─ events.fe:39:40 │ -36 │ let addrs: Array = [address(0); 2] +39 │ let addrs: Array = [address(0); 2] │ ^^^^^^^^^^^^^^^ Array: Memory -37 │ addrs[0] = addr1 +40 │ addrs[0] = addr1 │ ^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ events.fe:37:9 + ┌─ events.fe:40:9 │ -37 │ addrs[0] = addr1 +40 │ addrs[0] = addr1 │ ^^^^^^^^ ^^^^^ address: Value │ │ │ address: Memory -38 │ addrs[1] = addr2 +41 │ addrs[1] = addr2 │ ^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ events.fe:38:9 + ┌─ events.fe:41:9 │ -38 │ addrs[1] = addr2 +41 │ addrs[1] = addr2 │ ^^^^^^^^ ^^^^^ address: Value │ │ │ address: Memory -39 │ emit Addresses(ctx, addrs) - │ ^^^ ^^^^^ Array: Memory - │ │ - │ Context: Memory +42 │ ctx.emit(Addresses(addrs)) + │ ^^^ ^^^^^ Array: Memory + │ │ + │ Context: Memory + +note: + ┌─ events.fe:42:18 + │ +42 │ ctx.emit(Addresses(addrs)) + │ ^^^^^^^^^^^^^^^^ Addresses: Memory + +note: + ┌─ events.fe:42:9 + │ +42 │ ctx.emit(Addresses(addrs)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value diff --git a/crates/analyzer/tests/snapshots/analysis__external_contract.snap b/crates/analyzer/tests/snapshots/analysis__external_contract.snap index 9287407749..01287a5fd2 100644 --- a/crates/analyzer/tests/snapshots/analysis__external_contract.snap +++ b/crates/analyzer/tests/snapshots/analysis__external_contract.snap @@ -4,159 +4,171 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ external_contract.fe:3:9 + ┌─ external_contract.fe:2:5 │ -3 │ my_num: u256 - │ ^^^^^^^^^^^^ u256 -4 │ my_addrs: Array - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array -5 │ my_string: String<11> - │ ^^^^^^^^^^^^^^^^^^^^^ String<11> +2 │ pub my_num: u256 + │ ^^^^^^^^^^^^^^^^ u256 +3 │ pub my_addrs: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array +4 │ pub my_string: String<11> + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ String<11> note: - ┌─ external_contract.fe:8:5 + ┌─ external_contract.fe:9:5 │ - 8 │ ╭ pub fn emit_event(self, ctx: Context, my_num: u256, my_addrs: Array, my_string: String<11>) { - 9 │ │ emit MyEvent(ctx, my_num, my_addrs, my_string) -10 │ │ } + 9 │ ╭ pub fn emit_event(self, ctx: Context, my_num: u256, my_addrs: Array, my_string: String<11>) { +10 │ │ ctx.emit(MyEvent(my_num, my_addrs, my_string)) +11 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: my_num, typ: u256 }, { label: None, name: my_addrs, typ: Array }, { label: None, name: my_string, typ: String<11> }] -> () note: - ┌─ external_contract.fe:9:22 - │ -9 │ emit MyEvent(ctx, my_num, my_addrs, my_string) - │ ^^^ ^^^^^^ ^^^^^^^^ ^^^^^^^^^ String<11>: Memory - │ │ │ │ - │ │ │ Array: Memory - │ │ u256: Value - │ Context: Memory + ┌─ external_contract.fe:10:9 + │ +10 │ ctx.emit(MyEvent(my_num, my_addrs, my_string)) + │ ^^^ ^^^^^^ ^^^^^^^^ ^^^^^^^^^ String<11>: Memory + │ │ │ │ + │ │ │ Array: Memory + │ │ u256: Value + │ Context: Memory + +note: + ┌─ external_contract.fe:10:18 + │ +10 │ ctx.emit(MyEvent(my_num, my_addrs, my_string)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ MyEvent: Memory + +note: + ┌─ external_contract.fe:10:9 + │ +10 │ ctx.emit(MyEvent(my_num, my_addrs, my_string)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ external_contract.fe:12:5 + ┌─ external_contract.fe:13:5 │ -12 │ ╭ pub fn build_array(self, a: u256, b: u256) -> Array { -13 │ │ let my_array: Array = [0; 3] -14 │ │ my_array[0] = a -15 │ │ my_array[1] = a * b -16 │ │ my_array[2] = b -17 │ │ return my_array -18 │ │ } +13 │ ╭ pub fn build_array(self, a: u256, b: u256) -> Array { +14 │ │ let my_array: Array = [0; 3] +15 │ │ my_array[0] = a +16 │ │ my_array[1] = a * b +17 │ │ my_array[2] = b +18 │ │ return my_array +19 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: a, typ: u256 }, { label: None, name: b, typ: u256 }] -> Array note: - ┌─ external_contract.fe:13:13 + ┌─ external_contract.fe:14:13 │ -13 │ let my_array: Array = [0; 3] +14 │ let my_array: Array = [0; 3] │ ^^^^^^^^ Array note: - ┌─ external_contract.fe:13:41 + ┌─ external_contract.fe:14:41 │ -13 │ let my_array: Array = [0; 3] +14 │ let my_array: Array = [0; 3] │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ external_contract.fe:13:40 + ┌─ external_contract.fe:14:40 │ -13 │ let my_array: Array = [0; 3] +14 │ let my_array: Array = [0; 3] │ ^^^^^^ Array: Memory -14 │ my_array[0] = a +15 │ my_array[0] = a │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ external_contract.fe:14:9 + ┌─ external_contract.fe:15:9 │ -14 │ my_array[0] = a +15 │ my_array[0] = a │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -15 │ my_array[1] = a * b +16 │ my_array[1] = a * b │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ external_contract.fe:15:9 + ┌─ external_contract.fe:16:9 │ -15 │ my_array[1] = a * b +16 │ my_array[1] = a * b │ ^^^^^^^^^^^ ^ ^ u256: Value │ │ │ │ │ u256: Value │ u256: Memory note: - ┌─ external_contract.fe:15:23 + ┌─ external_contract.fe:16:23 │ -15 │ my_array[1] = a * b +16 │ my_array[1] = a * b │ ^^^^^ u256: Value -16 │ my_array[2] = b +17 │ my_array[2] = b │ ^^^^^^^^ ^ u256: Value │ │ │ Array: Memory note: - ┌─ external_contract.fe:16:9 + ┌─ external_contract.fe:17:9 │ -16 │ my_array[2] = b +17 │ my_array[2] = b │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Memory -17 │ return my_array +18 │ return my_array │ ^^^^^^^^ Array: Memory note: - ┌─ external_contract.fe:20:5 + ┌─ external_contract.fe:21:5 │ -20 │ ╭ pub fn pure_add(_ x: u256, _ y: u256) -> u256 { -21 │ │ return x + y -22 │ │ } +21 │ ╭ pub fn pure_add(_ x: u256, _ y: u256) -> u256 { +22 │ │ return x + y +23 │ │ } │ ╰─────^ self: None, params: [{ label: Some("_"), name: x, typ: u256 }, { label: Some("_"), name: y, typ: u256 }] -> u256 note: - ┌─ external_contract.fe:21:16 + ┌─ external_contract.fe:22:16 │ -21 │ return x + y +22 │ return x + y │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ external_contract.fe:21:16 + ┌─ external_contract.fe:22:16 │ -21 │ return x + y +22 │ return x + y │ ^^^^^ u256: Value note: - ┌─ external_contract.fe:26:5 + ┌─ external_contract.fe:27:5 │ -26 │ ╭ pub fn call_emit_event(ctx: Context, foo_address: address, my_num: u256, my_addrs: Array, my_string: String<11>) { -27 │ │ let foo: Foo = Foo(foo_address) -28 │ │ foo.emit_event(ctx, my_num, my_addrs, my_string) -29 │ │ } +27 │ ╭ pub fn call_emit_event(ctx: Context, foo_address: address, my_num: u256, my_addrs: Array, my_string: String<11>) { +28 │ │ let foo: Foo = Foo(foo_address) +29 │ │ foo.emit_event(ctx, my_num, my_addrs, my_string) +30 │ │ } │ ╰─────^ self: None, params: [{ label: None, name: ctx, typ: Context }, { label: None, name: foo_address, typ: address }, { label: None, name: my_num, typ: u256 }, { label: None, name: my_addrs, typ: Array }, { label: None, name: my_string, typ: String<11> }] -> () note: - ┌─ external_contract.fe:27:13 + ┌─ external_contract.fe:28:13 │ -27 │ let foo: Foo = Foo(foo_address) +28 │ let foo: Foo = Foo(foo_address) │ ^^^ Foo note: - ┌─ external_contract.fe:27:28 + ┌─ external_contract.fe:28:28 │ -27 │ let foo: Foo = Foo(foo_address) +28 │ let foo: Foo = Foo(foo_address) │ ^^^^^^^^^^^ address: Value note: - ┌─ external_contract.fe:27:24 + ┌─ external_contract.fe:28:24 │ -27 │ let foo: Foo = Foo(foo_address) +28 │ let foo: Foo = Foo(foo_address) │ ^^^^^^^^^^^^^^^^ Foo: Value -28 │ foo.emit_event(ctx, my_num, my_addrs, my_string) +29 │ foo.emit_event(ctx, my_num, my_addrs, my_string) │ ^^^ ^^^ ^^^^^^ ^^^^^^^^ ^^^^^^^^^ String<11>: Memory │ │ │ │ │ │ │ │ │ Array: Memory @@ -165,69 +177,69 @@ note: │ Foo: Value note: - ┌─ external_contract.fe:28:9 + ┌─ external_contract.fe:29:9 │ -28 │ foo.emit_event(ctx, my_num, my_addrs, my_string) +29 │ foo.emit_event(ctx, my_num, my_addrs, my_string) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ external_contract.fe:31:5 + ┌─ external_contract.fe:32:5 │ -31 │ ╭ pub fn call_build_array(foo_address: address, a: u256, b: u256) -> Array { -32 │ │ let foo: Foo = Foo(foo_address) -33 │ │ return foo.build_array(a, b) -34 │ │ } +32 │ ╭ pub fn call_build_array(foo_address: address, a: u256, b: u256) -> Array { +33 │ │ let foo: Foo = Foo(foo_address) +34 │ │ return foo.build_array(a, b) +35 │ │ } │ ╰─────^ self: None, params: [{ label: None, name: foo_address, typ: address }, { label: None, name: a, typ: u256 }, { label: None, name: b, typ: u256 }] -> Array note: - ┌─ external_contract.fe:32:13 + ┌─ external_contract.fe:33:13 │ -32 │ let foo: Foo = Foo(foo_address) +33 │ let foo: Foo = Foo(foo_address) │ ^^^ Foo note: - ┌─ external_contract.fe:32:28 + ┌─ external_contract.fe:33:28 │ -32 │ let foo: Foo = Foo(foo_address) +33 │ let foo: Foo = Foo(foo_address) │ ^^^^^^^^^^^ address: Value note: - ┌─ external_contract.fe:32:24 + ┌─ external_contract.fe:33:24 │ -32 │ let foo: Foo = Foo(foo_address) +33 │ let foo: Foo = Foo(foo_address) │ ^^^^^^^^^^^^^^^^ Foo: Value -33 │ return foo.build_array(a, b) +34 │ return foo.build_array(a, b) │ ^^^ ^ ^ u256: Value │ │ │ │ │ u256: Value │ Foo: Value note: - ┌─ external_contract.fe:33:16 + ┌─ external_contract.fe:34:16 │ -33 │ return foo.build_array(a, b) +34 │ return foo.build_array(a, b) │ ^^^^^^^^^^^^^^^^^^^^^ Array: Memory note: - ┌─ external_contract.fe:36:5 + ┌─ external_contract.fe:37:5 │ -36 │ ╭ pub fn add(_ x: u256, _ y: u256) -> u256 { -37 │ │ return Foo::pure_add(x, y) -38 │ │ } +37 │ ╭ pub fn add(_ x: u256, _ y: u256) -> u256 { +38 │ │ return Foo::pure_add(x, y) +39 │ │ } │ ╰─────^ self: None, params: [{ label: Some("_"), name: x, typ: u256 }, { label: Some("_"), name: y, typ: u256 }] -> u256 note: - ┌─ external_contract.fe:37:30 + ┌─ external_contract.fe:38:30 │ -37 │ return Foo::pure_add(x, y) +38 │ return Foo::pure_add(x, y) │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ external_contract.fe:37:16 + ┌─ external_contract.fe:38:16 │ -37 │ return Foo::pure_add(x, y) +38 │ return Foo::pure_add(x, y) │ ^^^^^^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/analysis__guest_book.snap b/crates/analyzer/tests/snapshots/analysis__guest_book.snap index bc5bc01bda..ec11fe291b 100644 --- a/crates/analyzer/tests/snapshots/analysis__guest_book.snap +++ b/crates/analyzer/tests/snapshots/analysis__guest_book.snap @@ -4,16 +4,16 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ guest_book.fe:5:5 + ┌─ guest_book.fe:3:5 │ -5 │ messages: Map> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> +3 │ pub book_msg: String<100> + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ String<100> note: - ┌─ guest_book.fe:9:9 - │ -9 │ book_msg: String<100> - │ ^^^^^^^^^^^^^^^^^^^^^ String<100> + ┌─ guest_book.fe:10:5 + │ +10 │ messages: Map> + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> note: ┌─ guest_book.fe:14:5 @@ -22,9 +22,9 @@ note: 15 │ │ // All storage access is explicit using `self.` 16 │ │ self.messages[ctx.msg_sender()] = book_msg 17 │ │ - · │ -20 │ │ emit Signed(ctx, book_msg) -21 │ │ } +18 │ │ // Emit the `Signed` event. +19 │ │ ctx.emit(Signed(book_msg)) +20 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: book_msg, typ: String<100> }] -> () note: @@ -55,45 +55,57 @@ note: │ │ │ String<100>: Storage { nonce: None } · -20 │ emit Signed(ctx, book_msg) - │ ^^^ ^^^^^^^^ String<100>: Memory - │ │ - │ Context: Memory +19 │ ctx.emit(Signed(book_msg)) + │ ^^^ ^^^^^^^^ String<100>: Memory + │ │ + │ Context: Memory + +note: + ┌─ guest_book.fe:19:18 + │ +19 │ ctx.emit(Signed(book_msg)) + │ ^^^^^^^^^^^^^^^^ Signed: Memory + +note: + ┌─ guest_book.fe:19:9 + │ +19 │ ctx.emit(Signed(book_msg)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ guest_book.fe:23:5 + ┌─ guest_book.fe:22:5 │ -23 │ ╭ pub fn get_msg(self, addr: address) -> String<100> { -24 │ │ // Copying data from storage to memory -25 │ │ // has to be done explicitly via `to_mem()` -26 │ │ return self.messages[addr].to_mem() -27 │ │ } +22 │ ╭ pub fn get_msg(self, addr: address) -> String<100> { +23 │ │ // Copying data from storage to memory +24 │ │ // has to be done explicitly via `to_mem()` +25 │ │ return self.messages[addr].to_mem() +26 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: addr, typ: address }] -> String<100> note: - ┌─ guest_book.fe:26:16 + ┌─ guest_book.fe:25:16 │ -26 │ return self.messages[addr].to_mem() +25 │ return self.messages[addr].to_mem() │ ^^^^ GuestBook: Value note: - ┌─ guest_book.fe:26:16 + ┌─ guest_book.fe:25:16 │ -26 │ return self.messages[addr].to_mem() +25 │ return self.messages[addr].to_mem() │ ^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(0) } note: - ┌─ guest_book.fe:26:16 + ┌─ guest_book.fe:25:16 │ -26 │ return self.messages[addr].to_mem() +25 │ return self.messages[addr].to_mem() │ ^^^^^^^^^^^^^^^^^^^ String<100>: Storage { nonce: None } note: - ┌─ guest_book.fe:26:16 + ┌─ guest_book.fe:25:16 │ -26 │ return self.messages[addr].to_mem() +25 │ return self.messages[addr].to_mem() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<100>: Storage { nonce: None } => Memory diff --git a/crates/analyzer/tests/snapshots/analysis__module_level_events.snap b/crates/analyzer/tests/snapshots/analysis__module_level_events.snap index 5cfebf1831..cef89c762f 100644 --- a/crates/analyzer/tests/snapshots/analysis__module_level_events.snap +++ b/crates/analyzer/tests/snapshots/analysis__module_level_events.snap @@ -4,38 +4,51 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ module_level_events.fe:2:5 + ┌─ module_level_events.fe:3:5 │ -2 │ idx sender: address +3 │ pub sender: address │ ^^^^^^^^^^^^^^^^^^^ address -3 │ idx receiver: address +4 │ #indexed +5 │ pub receiver: address │ ^^^^^^^^^^^^^^^^^^^^^ address -4 │ value: u256 - │ ^^^^^^^^^^^ u256 +6 │ pub value: u256 + │ ^^^^^^^^^^^^^^^ u256 note: - ┌─ module_level_events.fe:8:5 + ┌─ module_level_events.fe:10:5 │ - 8 │ ╭ fn transfer(ctx: Context, to: address, value: u256) { - 9 │ │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) -10 │ │ } +10 │ ╭ fn transfer(ctx: Context, to: address, value: u256) { +11 │ │ ctx.emit(Transfer(sender: ctx.msg_sender(), receiver: to, value)) +12 │ │ } │ ╰─────^ self: None, params: [{ label: None, name: ctx, typ: Context }, { label: None, name: to, typ: address }, { label: None, name: value, typ: u256 }] -> () note: - ┌─ module_level_events.fe:9:23 - │ -9 │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) - │ ^^^ ^^^ Context: Memory - │ │ - │ Context: Memory + ┌─ module_level_events.fe:11:9 + │ +11 │ ctx.emit(Transfer(sender: ctx.msg_sender(), receiver: to, value)) + │ ^^^ ^^^ Context: Memory + │ │ + │ Context: Memory note: - ┌─ module_level_events.fe:9:36 - │ -9 │ emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) - │ ^^^^^^^^^^^^^^^^ ^^ ^^^^^ u256: Value - │ │ │ - │ │ address: Value - │ address: Value + ┌─ module_level_events.fe:11:35 + │ +11 │ ctx.emit(Transfer(sender: ctx.msg_sender(), receiver: to, value)) + │ ^^^^^^^^^^^^^^^^ ^^ ^^^^^ u256: Value + │ │ │ + │ │ address: Value + │ address: Value + +note: + ┌─ module_level_events.fe:11:18 + │ +11 │ ctx.emit(Transfer(sender: ctx.msg_sender(), receiver: to, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Transfer: Memory + +note: + ┌─ module_level_events.fe:11:9 + │ +11 │ ctx.emit(Transfer(sender: ctx.msg_sender(), receiver: to, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value diff --git a/crates/analyzer/tests/snapshots/analysis__ownable.snap b/crates/analyzer/tests/snapshots/analysis__ownable.snap index 783561b22c..edd4653542 100644 --- a/crates/analyzer/tests/snapshots/analysis__ownable.snap +++ b/crates/analyzer/tests/snapshots/analysis__ownable.snap @@ -4,182 +4,207 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ ownable.fe:2:5 + ┌─ ownable.fe:3:5 │ -2 │ _owner: address - │ ^^^^^^^^^^^^^^^ address +3 │ pub previousOwner: address + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ address +4 │ #indexed +5 │ pub newOwner: address + │ ^^^^^^^^^^^^^^^^^^^^^ address note: - ┌─ ownable.fe:5:9 + ┌─ ownable.fe:9:5 │ -5 │ idx previousOwner: address - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ address -6 │ idx newOwner: address - │ ^^^^^^^^^^^^^^^^^^^^^ address +9 │ _owner: address + │ ^^^^^^^^^^^^^^^ address note: - ┌─ ownable.fe:13:5 + ┌─ ownable.fe:15:5 │ -13 │ ╭ pub fn owner(self) -> address { -14 │ │ return self._owner -15 │ │ } +15 │ ╭ pub fn owner(self) -> address { +16 │ │ return self._owner +17 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> address note: - ┌─ ownable.fe:14:16 + ┌─ ownable.fe:16:16 │ -14 │ return self._owner +16 │ return self._owner │ ^^^^ Ownable: Value note: - ┌─ ownable.fe:14:16 + ┌─ ownable.fe:16:16 │ -14 │ return self._owner +16 │ return self._owner │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value note: - ┌─ ownable.fe:17:5 + ┌─ ownable.fe:19:5 │ -17 │ ╭ pub fn renounceOwnership(self, ctx: Context) { -18 │ │ assert ctx.msg_sender() == self._owner -19 │ │ self._owner = address(0) -20 │ │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) -21 │ │ } +19 │ ╭ pub fn renounceOwnership(self, ctx: Context) { +20 │ │ assert ctx.msg_sender() == self._owner +21 │ │ self._owner = address(0) +22 │ │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner: address(0))) +23 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }] -> () note: - ┌─ ownable.fe:18:16 + ┌─ ownable.fe:20:16 │ -18 │ assert ctx.msg_sender() == self._owner +20 │ assert ctx.msg_sender() == self._owner │ ^^^ Context: Memory note: - ┌─ ownable.fe:18:16 + ┌─ ownable.fe:20:16 │ -18 │ assert ctx.msg_sender() == self._owner +20 │ assert ctx.msg_sender() == self._owner │ ^^^^^^^^^^^^^^^^ ^^^^ Ownable: Value │ │ │ address: Value note: - ┌─ ownable.fe:18:36 + ┌─ ownable.fe:20:36 │ -18 │ assert ctx.msg_sender() == self._owner +20 │ assert ctx.msg_sender() == self._owner │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value note: - ┌─ ownable.fe:18:16 + ┌─ ownable.fe:20:16 │ -18 │ assert ctx.msg_sender() == self._owner +20 │ assert ctx.msg_sender() == self._owner │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -19 │ self._owner = address(0) +21 │ self._owner = address(0) │ ^^^^ Ownable: Value note: - ┌─ ownable.fe:19:9 + ┌─ ownable.fe:21:9 │ -19 │ self._owner = address(0) +21 │ self._owner = address(0) │ ^^^^^^^^^^^ ^ u256: Value │ │ │ address: Storage { nonce: Some(0) } note: - ┌─ ownable.fe:19:23 + ┌─ ownable.fe:21:23 │ -19 │ self._owner = address(0) +21 │ self._owner = address(0) │ ^^^^^^^^^^ address: Value -20 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) - │ ^^^ ^^^ Context: Memory - │ │ - │ Context: Memory +22 │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner: address(0))) + │ ^^^ ^^^ Context: Memory + │ │ + │ Context: Memory + +note: + ┌─ ownable.fe:22:54 + │ +22 │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner: address(0))) + │ ^^^^^^^^^^^^^^^^ ^ u256: Value + │ │ + │ address: Value + +note: + ┌─ ownable.fe:22:82 + │ +22 │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner: address(0))) + │ ^^^^^^^^^^ address: Value note: - ┌─ ownable.fe:20:55 + ┌─ ownable.fe:22:18 │ -20 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) - │ ^^^^^^^^^^^^^^^^ ^ u256: Value - │ │ - │ address: Value +22 │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner: address(0))) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OwnershipTransferred: Memory note: - ┌─ ownable.fe:20:83 + ┌─ ownable.fe:22:9 │ -20 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) - │ ^^^^^^^^^^ address: Value +22 │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner: address(0))) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ ownable.fe:23:5 + ┌─ ownable.fe:25:5 │ -23 │ ╭ pub fn transferOwnership(self, ctx: Context, newOwner: address) { -24 │ │ assert ctx.msg_sender() == self._owner -25 │ │ assert newOwner != address(0) -26 │ │ self._owner = newOwner -27 │ │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) -28 │ │ } +25 │ ╭ pub fn transferOwnership(self, ctx: Context, newOwner: address) { +26 │ │ assert ctx.msg_sender() == self._owner +27 │ │ assert newOwner != address(0) +28 │ │ self._owner = newOwner +29 │ │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner)) +30 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: newOwner, typ: address }] -> () note: - ┌─ ownable.fe:24:16 + ┌─ ownable.fe:26:16 │ -24 │ assert ctx.msg_sender() == self._owner +26 │ assert ctx.msg_sender() == self._owner │ ^^^ Context: Memory note: - ┌─ ownable.fe:24:16 + ┌─ ownable.fe:26:16 │ -24 │ assert ctx.msg_sender() == self._owner +26 │ assert ctx.msg_sender() == self._owner │ ^^^^^^^^^^^^^^^^ ^^^^ Ownable: Value │ │ │ address: Value note: - ┌─ ownable.fe:24:36 + ┌─ ownable.fe:26:36 │ -24 │ assert ctx.msg_sender() == self._owner +26 │ assert ctx.msg_sender() == self._owner │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value note: - ┌─ ownable.fe:24:16 + ┌─ ownable.fe:26:16 │ -24 │ assert ctx.msg_sender() == self._owner +26 │ assert ctx.msg_sender() == self._owner │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -25 │ assert newOwner != address(0) +27 │ assert newOwner != address(0) │ ^^^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ ownable.fe:25:28 + ┌─ ownable.fe:27:28 │ -25 │ assert newOwner != address(0) +27 │ assert newOwner != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ ownable.fe:25:16 + ┌─ ownable.fe:27:16 │ -25 │ assert newOwner != address(0) +27 │ assert newOwner != address(0) │ ^^^^^^^^^^^^^^^^^^^^^^ bool: Value -26 │ self._owner = newOwner +28 │ self._owner = newOwner │ ^^^^ Ownable: Value note: - ┌─ ownable.fe:26:9 + ┌─ ownable.fe:28:9 │ -26 │ self._owner = newOwner +28 │ self._owner = newOwner │ ^^^^^^^^^^^ ^^^^^^^^ address: Value │ │ │ address: Storage { nonce: Some(0) } -27 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) - │ ^^^ ^^^ Context: Memory - │ │ - │ Context: Memory +29 │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner)) + │ ^^^ ^^^ Context: Memory + │ │ + │ Context: Memory + +note: + ┌─ ownable.fe:29:54 + │ +29 │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner)) + │ ^^^^^^^^^^^^^^^^ ^^^^^^^^ address: Value + │ │ + │ address: Value + +note: + ┌─ ownable.fe:29:18 + │ +29 │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ OwnershipTransferred: Memory note: - ┌─ ownable.fe:27:55 + ┌─ ownable.fe:29:9 │ -27 │ emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) - │ ^^^^^^^^^^^^^^^^ ^^^^^^^^ address: Value - │ │ - │ address: Value +29 │ ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value diff --git a/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap b/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap index 93dd727b82..2d8797f230 100644 --- a/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap +++ b/crates/analyzer/tests/snapshots/analysis__simple_open_auction.snap @@ -10,419 +10,443 @@ note: │ ^^^^^^^^^^^^^^^^^^^^^ u256 note: - ┌─ simple_open_auction.fe:12:5 + ┌─ simple_open_auction.fe:13:5 │ -12 │ auction_end_time: u256 - │ ^^^^^^^^^^^^^^^^^^^^^^ u256 -13 │ beneficiary: address - │ ^^^^^^^^^^^^^^^^^^^^ address -14 │ -15 │ highest_bidder: address - │ ^^^^^^^^^^^^^^^^^^^^^^^ address -16 │ highest_bid: u256 - │ ^^^^^^^^^^^^^^^^^ u256 -17 │ -18 │ pending_returns: Map - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map -19 │ -20 │ ended: bool - │ ^^^^^^^^^^^ bool +13 │ pub bidder: address + │ ^^^^^^^^^^^^^^^^^^^ address +14 │ pub amount: u256 + │ ^^^^^^^^^^^^^^^^ u256 note: - ┌─ simple_open_auction.fe:24:9 + ┌─ simple_open_auction.fe:19:5 │ -24 │ idx bidder: address - │ ^^^^^^^^^^^^^^^^^^^ address -25 │ amount: u256 - │ ^^^^^^^^^^^^ u256 +19 │ pub winner: address + │ ^^^^^^^^^^^^^^^^^^^ address +20 │ pub amount: u256 + │ ^^^^^^^^^^^^^^^^ u256 note: - ┌─ simple_open_auction.fe:29:9 + ┌─ simple_open_auction.fe:25:5 │ -29 │ idx winner: address - │ ^^^^^^^^^^^^^^^^^^^ address -30 │ amount: u256 - │ ^^^^^^^^^^^^ u256 +25 │ auction_end_time: u256 + │ ^^^^^^^^^^^^^^^^^^^^^^ u256 +26 │ beneficiary: address + │ ^^^^^^^^^^^^^^^^^^^^ address +27 │ +28 │ highest_bidder: address + │ ^^^^^^^^^^^^^^^^^^^^^^^ address +29 │ highest_bid: u256 + │ ^^^^^^^^^^^^^^^^^ u256 +30 │ +31 │ pending_returns: Map + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map +32 │ +33 │ ended: bool + │ ^^^^^^^^^^^ bool note: - ┌─ simple_open_auction.fe:40:5 + ┌─ simple_open_auction.fe:42:5 │ -40 │ ╭ pub fn bid(self, ctx: Context) { -41 │ │ if ctx.block_timestamp() > self.auction_end_time { -42 │ │ revert AuctionAlreadyEnded() -43 │ │ } +42 │ ╭ pub fn bid(self, ctx: Context) { +43 │ │ if ctx.block_timestamp() > self.auction_end_time { +44 │ │ revert AuctionAlreadyEnded() +45 │ │ } · │ -53 │ │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) -54 │ │ } +55 │ │ ctx.emit(HighestBidIncreased(bidder: ctx.msg_sender(), amount: ctx.msg_value())) +56 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }] -> () note: - ┌─ simple_open_auction.fe:41:12 + ┌─ simple_open_auction.fe:43:12 │ -41 │ if ctx.block_timestamp() > self.auction_end_time { +43 │ if ctx.block_timestamp() > self.auction_end_time { │ ^^^ Context: Memory note: - ┌─ simple_open_auction.fe:41:12 + ┌─ simple_open_auction.fe:43:12 │ -41 │ if ctx.block_timestamp() > self.auction_end_time { +43 │ if ctx.block_timestamp() > self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ u256: Value note: - ┌─ simple_open_auction.fe:41:36 + ┌─ simple_open_auction.fe:43:36 │ -41 │ if ctx.block_timestamp() > self.auction_end_time { +43 │ if ctx.block_timestamp() > self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(0) } => Value note: - ┌─ simple_open_auction.fe:41:12 + ┌─ simple_open_auction.fe:43:12 │ -41 │ if ctx.block_timestamp() > self.auction_end_time { +43 │ if ctx.block_timestamp() > self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -42 │ revert AuctionAlreadyEnded() +44 │ revert AuctionAlreadyEnded() │ ^^^^^^^^^^^^^^^^^^^^^ AuctionAlreadyEnded: Memory -43 │ } -44 │ if ctx.msg_value() <= self.highest_bid { +45 │ } +46 │ if ctx.msg_value() <= self.highest_bid { │ ^^^ Context: Memory note: - ┌─ simple_open_auction.fe:44:12 + ┌─ simple_open_auction.fe:46:12 │ -44 │ if ctx.msg_value() <= self.highest_bid { +46 │ if ctx.msg_value() <= self.highest_bid { │ ^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ u256: Value note: - ┌─ simple_open_auction.fe:44:31 + ┌─ simple_open_auction.fe:46:31 │ -44 │ if ctx.msg_value() <= self.highest_bid { +46 │ if ctx.msg_value() <= self.highest_bid { │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } => Value note: - ┌─ simple_open_auction.fe:44:12 + ┌─ simple_open_auction.fe:46:12 │ -44 │ if ctx.msg_value() <= self.highest_bid { +46 │ if ctx.msg_value() <= self.highest_bid { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -45 │ revert BidNotHighEnough(highest_bid: self.highest_bid) +47 │ revert BidNotHighEnough(highest_bid: self.highest_bid) │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:45:50 + ┌─ simple_open_auction.fe:47:50 │ -45 │ revert BidNotHighEnough(highest_bid: self.highest_bid) +47 │ revert BidNotHighEnough(highest_bid: self.highest_bid) │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } => Value note: - ┌─ simple_open_auction.fe:45:20 + ┌─ simple_open_auction.fe:47:20 │ -45 │ revert BidNotHighEnough(highest_bid: self.highest_bid) +47 │ revert BidNotHighEnough(highest_bid: self.highest_bid) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ BidNotHighEnough: Memory -46 │ } -47 │ if self.highest_bid != 0 { +48 │ } +49 │ if self.highest_bid != 0 { │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:47:12 + ┌─ simple_open_auction.fe:49:12 │ -47 │ if self.highest_bid != 0 { +49 │ if self.highest_bid != 0 { │ ^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(3) } => Value note: - ┌─ simple_open_auction.fe:47:12 + ┌─ simple_open_auction.fe:49:12 │ -47 │ if self.highest_bid != 0 { +49 │ if self.highest_bid != 0 { │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value -48 │ self.pending_returns[self.highest_bidder] += self.highest_bid +50 │ self.pending_returns[self.highest_bidder] += self.highest_bid │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:48:13 + ┌─ simple_open_auction.fe:50:13 │ -48 │ self.pending_returns[self.highest_bidder] += self.highest_bid +50 │ self.pending_returns[self.highest_bidder] += self.highest_bid │ ^^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ Map: Storage { nonce: Some(4) } note: - ┌─ simple_open_auction.fe:48:34 + ┌─ simple_open_auction.fe:50:34 │ -48 │ self.pending_returns[self.highest_bidder] += self.highest_bid +50 │ self.pending_returns[self.highest_bidder] += self.highest_bid │ ^^^^^^^^^^^^^^^^^^^ address: Storage { nonce: Some(2) } => Value note: - ┌─ simple_open_auction.fe:48:13 + ┌─ simple_open_auction.fe:50:13 │ -48 │ self.pending_returns[self.highest_bidder] += self.highest_bid +50 │ self.pending_returns[self.highest_bidder] += self.highest_bid │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ simple_open_auction.fe:48:58 + ┌─ simple_open_auction.fe:50:58 │ -48 │ self.pending_returns[self.highest_bidder] += self.highest_bid +50 │ self.pending_returns[self.highest_bidder] += self.highest_bid │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } -49 │ } -50 │ self.highest_bidder = ctx.msg_sender() +51 │ } +52 │ self.highest_bidder = ctx.msg_sender() │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:50:9 + ┌─ simple_open_auction.fe:52:9 │ -50 │ self.highest_bidder = ctx.msg_sender() +52 │ self.highest_bidder = ctx.msg_sender() │ ^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ address: Storage { nonce: Some(2) } note: - ┌─ simple_open_auction.fe:50:31 + ┌─ simple_open_auction.fe:52:31 │ -50 │ self.highest_bidder = ctx.msg_sender() +52 │ self.highest_bidder = ctx.msg_sender() │ ^^^^^^^^^^^^^^^^ address: Value -51 │ self.highest_bid = ctx.msg_value() +53 │ self.highest_bid = ctx.msg_value() │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:51:9 + ┌─ simple_open_auction.fe:53:9 │ -51 │ self.highest_bid = ctx.msg_value() +53 │ self.highest_bid = ctx.msg_value() │ ^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ u256: Storage { nonce: Some(3) } note: - ┌─ simple_open_auction.fe:51:28 + ┌─ simple_open_auction.fe:53:28 │ -51 │ self.highest_bid = ctx.msg_value() +53 │ self.highest_bid = ctx.msg_value() │ ^^^^^^^^^^^^^^^ u256: Value -52 │ -53 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) - │ ^^^ ^^^ Context: Memory - │ │ - │ Context: Memory +54 │ +55 │ ctx.emit(HighestBidIncreased(bidder: ctx.msg_sender(), amount: ctx.msg_value())) + │ ^^^ ^^^ Context: Memory + │ │ + │ Context: Memory + +note: + ┌─ simple_open_auction.fe:55:46 + │ +55 │ ctx.emit(HighestBidIncreased(bidder: ctx.msg_sender(), amount: ctx.msg_value())) + │ ^^^^^^^^^^^^^^^^ ^^^ Context: Memory + │ │ + │ address: Value note: - ┌─ simple_open_auction.fe:53:47 + ┌─ simple_open_auction.fe:55:72 │ -53 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) - │ ^^^^^^^^^^^^^^^^ ^^^ Context: Memory - │ │ - │ address: Value +55 │ ctx.emit(HighestBidIncreased(bidder: ctx.msg_sender(), amount: ctx.msg_value())) + │ ^^^^^^^^^^^^^^^ u256: Value note: - ┌─ simple_open_auction.fe:53:73 + ┌─ simple_open_auction.fe:55:18 │ -53 │ emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) - │ ^^^^^^^^^^^^^^^ u256: Value +55 │ ctx.emit(HighestBidIncreased(bidder: ctx.msg_sender(), amount: ctx.msg_value())) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ HighestBidIncreased: Memory note: - ┌─ simple_open_auction.fe:56:5 + ┌─ simple_open_auction.fe:55:9 + │ +55 │ ctx.emit(HighestBidIncreased(bidder: ctx.msg_sender(), amount: ctx.msg_value())) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value + +note: + ┌─ simple_open_auction.fe:58:5 │ -56 │ ╭ pub fn withdraw(self, ctx: Context) -> bool { -57 │ │ let amount: u256 = self.pending_returns[ctx.msg_sender()] -58 │ │ -59 │ │ if amount > 0 { +58 │ ╭ pub fn withdraw(self, ctx: Context) -> bool { +59 │ │ let amount: u256 = self.pending_returns[ctx.msg_sender()] +60 │ │ +61 │ │ if amount > 0 { · │ -63 │ │ return true -64 │ │ } +65 │ │ return true +66 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }] -> bool note: - ┌─ simple_open_auction.fe:57:13 + ┌─ simple_open_auction.fe:59:13 │ -57 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] +59 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] │ ^^^^^^ u256 note: - ┌─ simple_open_auction.fe:57:28 + ┌─ simple_open_auction.fe:59:28 │ -57 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] +59 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:57:28 + ┌─ simple_open_auction.fe:59:28 │ -57 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] +59 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] │ ^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: Some(4) } note: - ┌─ simple_open_auction.fe:57:49 + ┌─ simple_open_auction.fe:59:49 │ -57 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] +59 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ simple_open_auction.fe:57:28 + ┌─ simple_open_auction.fe:59:28 │ -57 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] +59 │ let amount: u256 = self.pending_returns[ctx.msg_sender()] │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value -58 │ -59 │ if amount > 0 { +60 │ +61 │ if amount > 0 { │ ^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ simple_open_auction.fe:59:12 + ┌─ simple_open_auction.fe:61:12 │ -59 │ if amount > 0 { +61 │ if amount > 0 { │ ^^^^^^^^^^ bool: Value -60 │ self.pending_returns[ctx.msg_sender()] = 0 +62 │ self.pending_returns[ctx.msg_sender()] = 0 │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:60:13 + ┌─ simple_open_auction.fe:62:13 │ -60 │ self.pending_returns[ctx.msg_sender()] = 0 +62 │ self.pending_returns[ctx.msg_sender()] = 0 │ ^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: Some(4) } note: - ┌─ simple_open_auction.fe:60:34 + ┌─ simple_open_auction.fe:62:34 │ -60 │ self.pending_returns[ctx.msg_sender()] = 0 +62 │ self.pending_returns[ctx.msg_sender()] = 0 │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ simple_open_auction.fe:60:13 + ┌─ simple_open_auction.fe:62:13 │ -60 │ self.pending_returns[ctx.msg_sender()] = 0 +62 │ self.pending_returns[ctx.msg_sender()] = 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: None } -61 │ ctx.send_value(to: ctx.msg_sender(), wei: amount) +63 │ ctx.send_value(to: ctx.msg_sender(), wei: amount) │ ^^^ ^^^ Context: Memory │ │ │ Context: Memory note: - ┌─ simple_open_auction.fe:61:32 + ┌─ simple_open_auction.fe:63:32 │ -61 │ ctx.send_value(to: ctx.msg_sender(), wei: amount) +63 │ ctx.send_value(to: ctx.msg_sender(), wei: amount) │ ^^^^^^^^^^^^^^^^ ^^^^^^ u256: Value │ │ │ address: Value note: - ┌─ simple_open_auction.fe:61:13 + ┌─ simple_open_auction.fe:63:13 │ -61 │ ctx.send_value(to: ctx.msg_sender(), wei: amount) +63 │ ctx.send_value(to: ctx.msg_sender(), wei: amount) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -62 │ } -63 │ return true +64 │ } +65 │ return true │ ^^^^ bool: Value note: - ┌─ simple_open_auction.fe:66:5 + ┌─ simple_open_auction.fe:68:5 │ -66 │ ╭ pub fn action_end(self, ctx: Context) { -67 │ │ if ctx.block_timestamp() <= self.auction_end_time { -68 │ │ revert AuctionNotYetEnded() -69 │ │ } +68 │ ╭ pub fn action_end(self, ctx: Context) { +69 │ │ if ctx.block_timestamp() <= self.auction_end_time { +70 │ │ revert AuctionNotYetEnded() +71 │ │ } · │ -76 │ │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) -77 │ │ } +78 │ │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) +79 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }] -> () note: - ┌─ simple_open_auction.fe:67:12 + ┌─ simple_open_auction.fe:69:12 │ -67 │ if ctx.block_timestamp() <= self.auction_end_time { +69 │ if ctx.block_timestamp() <= self.auction_end_time { │ ^^^ Context: Memory note: - ┌─ simple_open_auction.fe:67:12 + ┌─ simple_open_auction.fe:69:12 │ -67 │ if ctx.block_timestamp() <= self.auction_end_time { +69 │ if ctx.block_timestamp() <= self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ u256: Value note: - ┌─ simple_open_auction.fe:67:37 + ┌─ simple_open_auction.fe:69:37 │ -67 │ if ctx.block_timestamp() <= self.auction_end_time { +69 │ if ctx.block_timestamp() <= self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(0) } => Value note: - ┌─ simple_open_auction.fe:67:12 + ┌─ simple_open_auction.fe:69:12 │ -67 │ if ctx.block_timestamp() <= self.auction_end_time { +69 │ if ctx.block_timestamp() <= self.auction_end_time { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -68 │ revert AuctionNotYetEnded() +70 │ revert AuctionNotYetEnded() │ ^^^^^^^^^^^^^^^^^^^^ AuctionNotYetEnded: Memory -69 │ } -70 │ if self.ended { +71 │ } +72 │ if self.ended { │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:70:12 + ┌─ simple_open_auction.fe:72:12 │ -70 │ if self.ended { +72 │ if self.ended { │ ^^^^^^^^^^ bool: Storage { nonce: Some(5) } => Value -71 │ revert AuctionEndAlreadyCalled() +73 │ revert AuctionEndAlreadyCalled() │ ^^^^^^^^^^^^^^^^^^^^^^^^^ AuctionEndAlreadyCalled: Memory -72 │ } -73 │ self.ended = true +74 │ } +75 │ self.ended = true │ ^^^^ SimpleOpenAuction: Value note: - ┌─ simple_open_auction.fe:73:9 + ┌─ simple_open_auction.fe:75:9 │ -73 │ self.ended = true +75 │ self.ended = true │ ^^^^^^^^^^ ^^^^ bool: Value │ │ │ bool: Storage { nonce: Some(5) } -74 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) - │ ^^^ ^^^^ SimpleOpenAuction: Value - │ │ - │ Context: Memory +76 │ ctx.emit(AuctionEnded(winner: self.highest_bidder, amount: self.highest_bid)) + │ ^^^ ^^^^ SimpleOpenAuction: Value + │ │ + │ Context: Memory + +note: + ┌─ simple_open_auction.fe:76:39 + │ +76 │ ctx.emit(AuctionEnded(winner: self.highest_bidder, amount: self.highest_bid)) + │ ^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value + │ │ + │ address: Storage { nonce: Some(2) } => Value note: - ┌─ simple_open_auction.fe:74:40 + ┌─ simple_open_auction.fe:76:68 │ -74 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) - │ ^^^^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value - │ │ - │ address: Storage { nonce: Some(2) } => Value +76 │ ctx.emit(AuctionEnded(winner: self.highest_bidder, amount: self.highest_bid)) + │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } => Value note: - ┌─ simple_open_auction.fe:74:69 + ┌─ simple_open_auction.fe:76:18 │ -74 │ emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) - │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } => Value -75 │ -76 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) +76 │ ctx.emit(AuctionEnded(winner: self.highest_bidder, amount: self.highest_bid)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AuctionEnded: Memory + +note: + ┌─ simple_open_auction.fe:76:9 + │ +76 │ ctx.emit(AuctionEnded(winner: self.highest_bidder, amount: self.highest_bid)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value +77 │ +78 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) │ ^^^ ^^^^ SimpleOpenAuction: Value │ │ │ Context: Memory note: - ┌─ simple_open_auction.fe:76:28 + ┌─ simple_open_auction.fe:78:28 │ -76 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) +78 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) │ ^^^^^^^^^^^^^^^^ ^^^^ SimpleOpenAuction: Value │ │ │ address: Storage { nonce: Some(1) } => Value note: - ┌─ simple_open_auction.fe:76:51 + ┌─ simple_open_auction.fe:78:51 │ -76 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) +78 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) │ ^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(3) } => Value note: - ┌─ simple_open_auction.fe:76:9 + ┌─ simple_open_auction.fe:78:9 │ -76 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) +78 │ ctx.send_value(to: self.beneficiary, wei: self.highest_bid) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value diff --git a/crates/analyzer/tests/snapshots/analysis__sized_vals_in_sto.snap b/crates/analyzer/tests/snapshots/analysis__sized_vals_in_sto.snap index e6cf4fb36e..7744a0fd06 100644 --- a/crates/analyzer/tests/snapshots/analysis__sized_vals_in_sto.snap +++ b/crates/analyzer/tests/snapshots/analysis__sized_vals_in_sto.snap @@ -6,22 +6,22 @@ expression: "build_snapshot(&db, module)" note: ┌─ sized_vals_in_sto.fe:2:5 │ -2 │ num: u256 - │ ^^^^^^^^^ u256 -3 │ nums: Array - │ ^^^^^^^^^^^^^^^^^^^^^ Array -4 │ str: String<26> - │ ^^^^^^^^^^^^^^^ String<26> +2 │ pub num: u256 + │ ^^^^^^^^^^^^^ u256 +3 │ pub nums: Array + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Array +4 │ pub str: String<26> + │ ^^^^^^^^^^^^^^^^^^^ String<26> note: - ┌─ sized_vals_in_sto.fe:7:9 - │ -7 │ num: u256 - │ ^^^^^^^^^ u256 -8 │ nums: Array - │ ^^^^^^^^^^^^^^^^^^^^^ Array -9 │ str: String<26> - │ ^^^^^^^^^^^^^^^ String<26> + ┌─ sized_vals_in_sto.fe:8:5 + │ + 8 │ num: u256 + │ ^^^^^^^^^ u256 + 9 │ nums: Array + │ ^^^^^^^^^^^^^^^^^^^^^ Array +10 │ str: String<26> + │ ^^^^^^^^^^^^^^^ String<26> note: ┌─ sized_vals_in_sto.fe:12:5 @@ -165,50 +165,62 @@ note: ┌─ sized_vals_in_sto.fe:36:5 │ 36 │ ╭ pub fn emit_event(self, ctx: Context) { -37 │ │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) +37 │ │ ctx.emit(MyEvent(num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem())) 38 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }] -> () note: - ┌─ sized_vals_in_sto.fe:37:22 + ┌─ sized_vals_in_sto.fe:37:9 + │ +37 │ ctx.emit(MyEvent(num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem())) + │ ^^^ ^^^^ Foo: Value + │ │ + │ Context: Memory + +note: + ┌─ sized_vals_in_sto.fe:37:31 + │ +37 │ ctx.emit(MyEvent(num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem())) + │ ^^^^^^^^ ^^^^ Foo: Value + │ │ + │ u256: Storage { nonce: Some(0) } => Value + +note: + ┌─ sized_vals_in_sto.fe:37:47 │ -37 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) - │ ^^^ ^^^^ Foo: Value - │ │ - │ Context: Memory +37 │ ctx.emit(MyEvent(num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem())) + │ ^^^^^^^^^ Array: Storage { nonce: Some(1) } note: - ┌─ sized_vals_in_sto.fe:37:32 + ┌─ sized_vals_in_sto.fe:37:47 │ -37 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) - │ ^^^^^^^^ ^^^^ Foo: Value - │ │ - │ u256: Storage { nonce: Some(0) } => Value +37 │ ctx.emit(MyEvent(num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem())) + │ ^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value + │ │ + │ Array: Storage { nonce: Some(1) } => Memory note: - ┌─ sized_vals_in_sto.fe:37:48 + ┌─ sized_vals_in_sto.fe:37:72 │ -37 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) - │ ^^^^^^^^^ Array: Storage { nonce: Some(1) } +37 │ ctx.emit(MyEvent(num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem())) + │ ^^^^^^^^ String<26>: Storage { nonce: Some(2) } note: - ┌─ sized_vals_in_sto.fe:37:48 + ┌─ sized_vals_in_sto.fe:37:72 │ -37 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) - │ ^^^^^^^^^^^^^^^^^^ ^^^^ Foo: Value - │ │ - │ Array: Storage { nonce: Some(1) } => Memory +37 │ ctx.emit(MyEvent(num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem())) + │ ^^^^^^^^^^^^^^^^^ String<26>: Storage { nonce: Some(2) } => Memory note: - ┌─ sized_vals_in_sto.fe:37:73 + ┌─ sized_vals_in_sto.fe:37:18 │ -37 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) - │ ^^^^^^^^ String<26>: Storage { nonce: Some(2) } +37 │ ctx.emit(MyEvent(num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem())) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ MyEvent: Memory note: - ┌─ sized_vals_in_sto.fe:37:73 + ┌─ sized_vals_in_sto.fe:37:9 │ -37 │ emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) - │ ^^^^^^^^^^^^^^^^^ String<26>: Storage { nonce: Some(2) } => Memory +37 │ ctx.emit(MyEvent(num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem())) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value diff --git a/crates/analyzer/tests/snapshots/analysis__strings.snap b/crates/analyzer/tests/snapshots/analysis__strings.snap index b6958bc307..988bea67b5 100644 --- a/crates/analyzer/tests/snapshots/analysis__strings.snap +++ b/crates/analyzer/tests/snapshots/analysis__strings.snap @@ -4,106 +4,106 @@ expression: "build_snapshot(&db, module)" --- note: - ┌─ strings.fe:3:9 + ┌─ strings.fe:2:5 │ -3 │ s2: String<26> - │ ^^^^^^^^^^^^^^ String<26> -4 │ u: u256 - │ ^^^^^^^ u256 -5 │ s1: String<42> - │ ^^^^^^^^^^^^^^ String<42> -6 │ s3: String<100> - │ ^^^^^^^^^^^^^^^ String<100> -7 │ a: address - │ ^^^^^^^^^^ address -8 │ s4: String<18> - │ ^^^^^^^^^^^^^^ String<18> -9 │ s5: String<100> - │ ^^^^^^^^^^^^^^^ String<100> +2 │ pub s2: String<26> + │ ^^^^^^^^^^^^^^^^^^ String<26> +3 │ pub u: u256 + │ ^^^^^^^^^^^ u256 +4 │ pub s1: String<42> + │ ^^^^^^^^^^^^^^^^^^ String<42> +5 │ pub s3: String<100> + │ ^^^^^^^^^^^^^^^^^^^ String<100> +6 │ pub a: address + │ ^^^^^^^^^^^^^^ address +7 │ pub s4: String<18> + │ ^^^^^^^^^^^^^^^^^^ String<18> +8 │ pub s5: String<100> + │ ^^^^^^^^^^^^^^^^^^^ String<100> note: - ┌─ strings.fe:16:5 + ┌─ strings.fe:17:5 │ -16 │ ╭ pub fn bar(s1: String<100>, s2: String<100>) -> String<100> { -17 │ │ return s2 -18 │ │ } +17 │ ╭ pub fn bar(s1: String<100>, s2: String<100>) -> String<100> { +18 │ │ return s2 +19 │ │ } │ ╰─────^ self: None, params: [{ label: None, name: s1, typ: String<100> }, { label: None, name: s2, typ: String<100> }] -> String<100> note: - ┌─ strings.fe:17:16 + ┌─ strings.fe:18:16 │ -17 │ return s2 +18 │ return s2 │ ^^ String<100>: Memory note: - ┌─ strings.fe:20:5 + ┌─ strings.fe:21:5 │ -20 │ ╭ pub fn return_static_string() -> String<43> { -21 │ │ return "The quick brown fox jumps over the lazy dog" -22 │ │ } +21 │ ╭ pub fn return_static_string() -> String<43> { +22 │ │ return "The quick brown fox jumps over the lazy dog" +23 │ │ } │ ╰─────^ self: None, params: [] -> String<43> note: - ┌─ strings.fe:21:16 + ┌─ strings.fe:22:16 │ -21 │ return "The quick brown fox jumps over the lazy dog" +22 │ return "The quick brown fox jumps over the lazy dog" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<43>: Memory note: - ┌─ strings.fe:24:5 + ┌─ strings.fe:25:5 │ -24 │ ╭ pub fn return_casted_static_string() -> String<100> { -25 │ │ return String<100>("foo") -26 │ │ } +25 │ ╭ pub fn return_casted_static_string() -> String<100> { +26 │ │ return String<100>("foo") +27 │ │ } │ ╰─────^ self: None, params: [] -> String<100> note: - ┌─ strings.fe:25:28 + ┌─ strings.fe:26:28 │ -25 │ return String<100>("foo") +26 │ return String<100>("foo") │ ^^^^^ String<3>: Memory note: - ┌─ strings.fe:25:16 + ┌─ strings.fe:26:16 │ -25 │ return String<100>("foo") +26 │ return String<100>("foo") │ ^^^^^^^^^^^^^^^^^^ String<100>: Memory note: - ┌─ strings.fe:28:5 + ┌─ strings.fe:29:5 │ -28 │ ╭ pub fn shorter_string_assign() { -29 │ │ let s: String<18> = "fe" -30 │ │ } +29 │ ╭ pub fn shorter_string_assign() { +30 │ │ let s: String<18> = "fe" +31 │ │ } │ ╰─────^ self: None, params: [] -> () note: - ┌─ strings.fe:29:13 + ┌─ strings.fe:30:13 │ -29 │ let s: String<18> = "fe" +30 │ let s: String<18> = "fe" │ ^ String<18> note: - ┌─ strings.fe:29:29 + ┌─ strings.fe:30:29 │ -29 │ let s: String<18> = "fe" +30 │ let s: String<18> = "fe" │ ^^^^ String<18>: Memory note: - ┌─ strings.fe:32:5 + ┌─ strings.fe:33:5 │ -32 │ ╭ pub fn return_special_chars() -> String<18> { -33 │ │ return "\n\"'\r\t -34 │ │ foo\\" -35 │ │ } +33 │ ╭ pub fn return_special_chars() -> String<18> { +34 │ │ return "\n\"'\r\t +35 │ │ foo\\" +36 │ │ } │ ╰─────^ self: None, params: [] -> String<18> note: - ┌─ strings.fe:33:16 + ┌─ strings.fe:34:16 │ -33 │ return "\n\"'\r\t +34 │ return "\n\"'\r\t │ ╭────────────────^ -34 │ │ foo\\" +35 │ │ foo\\" │ ╰──────────────^ String<18>: Memory diff --git a/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap b/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap index 235856c4fc..17b62a25df 100644 --- a/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap +++ b/crates/analyzer/tests/snapshots/analysis__tuple_stress.snap @@ -6,14 +6,14 @@ expression: "build_snapshot(&db, module)" note: ┌─ tuple_stress.fe:2:5 │ -2 │ my_sto_tuple: (u256, i32) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, i32) +2 │ pub my_tuple: (u256, bool, address) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, bool, address) note: - ┌─ tuple_stress.fe:5:9 + ┌─ tuple_stress.fe:6:5 │ -5 │ my_tuple: (u256, bool, address) - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, bool, address) +6 │ my_sto_tuple: (u256, i32) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, i32) note: ┌─ tuple_stress.fe:8:5 @@ -122,17 +122,29 @@ note: ┌─ tuple_stress.fe:28:5 │ 28 │ ╭ pub fn emit_my_event(ctx: Context, my_tuple: (u256, bool, address)) { -29 │ │ emit MyEvent(ctx, my_tuple) +29 │ │ ctx.emit(MyEvent(my_tuple)) 30 │ │ } │ ╰─────^ self: None, params: [{ label: None, name: ctx, typ: Context }, { label: None, name: my_tuple, typ: (u256, bool, address) }] -> () note: - ┌─ tuple_stress.fe:29:22 + ┌─ tuple_stress.fe:29:9 + │ +29 │ ctx.emit(MyEvent(my_tuple)) + │ ^^^ ^^^^^^^^ (u256, bool, address): Memory + │ │ + │ Context: Memory + +note: + ┌─ tuple_stress.fe:29:18 + │ +29 │ ctx.emit(MyEvent(my_tuple)) + │ ^^^^^^^^^^^^^^^^^ MyEvent: Memory + +note: + ┌─ tuple_stress.fe:29:9 │ -29 │ emit MyEvent(ctx, my_tuple) - │ ^^^ ^^^^^^^^ (u256, bool, address): Memory - │ │ - │ Context: Memory +29 │ ctx.emit(MyEvent(my_tuple)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: ┌─ tuple_stress.fe:32:5 diff --git a/crates/analyzer/tests/snapshots/analysis__uniswap.snap b/crates/analyzer/tests/snapshots/analysis__uniswap.snap index a43bce79d5..2eaf4f66f4 100644 --- a/crates/analyzer/tests/snapshots/analysis__uniswap.snap +++ b/crates/analyzer/tests/snapshots/analysis__uniswap.snap @@ -32,695 +32,747 @@ note: │ ^^^^^ bool: Value note: - ┌─ uniswap.fe:15:5 + ┌─ uniswap.fe:13:5 │ -15 │ balances: Map - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map -16 │ allowances: Map> - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> -17 │ total_supply: u256 - │ ^^^^^^^^^^^^^^^^^^ u256 -18 │ -19 │ nonces: Map - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Map -20 │ -21 │ factory: address - │ ^^^^^^^^^^^^^^^^ address -22 │ token0: ERC20 - │ ^^^^^^^^^^^^^ ERC20 -23 │ token1: ERC20 - │ ^^^^^^^^^^^^^ ERC20 -24 │ -25 │ reserve0: u256 - │ ^^^^^^^^^^^^^^ u256 -26 │ reserve1: u256 - │ ^^^^^^^^^^^^^^ u256 -27 │ block_timestamp_last: u256 - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ u256 -28 │ -29 │ price0_cumulative_last: u256 - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256 -30 │ price1_cumulative_last: u256 - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256 -31 │ k_last: u256 - │ ^^^^^^^^^^^^ u256 +13 │ pub owner: address + │ ^^^^^^^^^^^^^^^^^^ address +14 │ #indexed +15 │ pub spender: address + │ ^^^^^^^^^^^^^^^^^^^^ address +16 │ pub value: u256 + │ ^^^^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:34:9 + ┌─ uniswap.fe:21:5 │ -34 │ idx owner: address - │ ^^^^^^^^^^^^^^^^^^ address -35 │ idx spender: address - │ ^^^^^^^^^^^^^^^^^^^^ address -36 │ value: u256 - │ ^^^^^^^^^^^ u256 +21 │ pub from: address + │ ^^^^^^^^^^^^^^^^^ address +22 │ #indexed +23 │ pub to: address + │ ^^^^^^^^^^^^^^^ address +24 │ pub value: u256 + │ ^^^^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:40:9 + ┌─ uniswap.fe:29:5 │ -40 │ idx from: address - │ ^^^^^^^^^^^^^^^^^ address -41 │ idx to: address - │ ^^^^^^^^^^^^^^^ address -42 │ value: u256 - │ ^^^^^^^^^^^ u256 +29 │ pub sender: address + │ ^^^^^^^^^^^^^^^^^^^ address +30 │ pub amount0: u256 + │ ^^^^^^^^^^^^^^^^^ u256 +31 │ pub amount1: u256 + │ ^^^^^^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:46:9 + ┌─ uniswap.fe:36:5 │ -46 │ idx sender: address - │ ^^^^^^^^^^^^^^^^^^^ address -47 │ amount0: u256 - │ ^^^^^^^^^^^^^ u256 -48 │ amount1: u256 - │ ^^^^^^^^^^^^^ u256 - -note: - ┌─ uniswap.fe:52:9 +36 │ pub sender: address + │ ^^^^^^^^^^^^^^^^^^^ address +37 │ pub amount0: u256 + │ ^^^^^^^^^^^^^^^^^ u256 +38 │ pub amount1: u256 + │ ^^^^^^^^^^^^^^^^^ u256 +39 │ #indexed +40 │ pub to: address + │ ^^^^^^^^^^^^^^^ address + +note: + ┌─ uniswap.fe:45:5 │ -52 │ idx sender: address - │ ^^^^^^^^^^^^^^^^^^^ address -53 │ amount0: u256 - │ ^^^^^^^^^^^^^ u256 -54 │ amount1: u256 - │ ^^^^^^^^^^^^^ u256 -55 │ idx to: address - │ ^^^^^^^^^^^^^^^ address +45 │ pub sender: address + │ ^^^^^^^^^^^^^^^^^^^ address +46 │ pub amount0_in: u256 + │ ^^^^^^^^^^^^^^^^^^^^ u256 +47 │ pub amount1_in: u256 + │ ^^^^^^^^^^^^^^^^^^^^ u256 +48 │ pub amount0_out: u256 + │ ^^^^^^^^^^^^^^^^^^^^^ u256 +49 │ pub amount1_out: u256 + │ ^^^^^^^^^^^^^^^^^^^^^ u256 +50 │ #indexed +51 │ pub to: address + │ ^^^^^^^^^^^^^^^ address + +note: + ┌─ uniswap.fe:55:5 + │ +55 │ pub reserve0: u256 + │ ^^^^^^^^^^^^^^^^^^ u256 +56 │ pub reserve1: u256 + │ ^^^^^^^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:59:9 - │ -59 │ idx sender: address - │ ^^^^^^^^^^^^^^^^^^^ address -60 │ amount0_in: u256 - │ ^^^^^^^^^^^^^^^^ u256 -61 │ amount1_in: u256 - │ ^^^^^^^^^^^^^^^^ u256 -62 │ amount0_out: u256 - │ ^^^^^^^^^^^^^^^^^ u256 -63 │ amount1_out: u256 - │ ^^^^^^^^^^^^^^^^^ u256 -64 │ idx to: address - │ ^^^^^^^^^^^^^^^ address - -note: - ┌─ uniswap.fe:68:9 + ┌─ uniswap.fe:63:5 │ -68 │ reserve0: u256 - │ ^^^^^^^^^^^^^^ u256 -69 │ reserve1: u256 - │ ^^^^^^^^^^^^^^ u256 +63 │ balances: Map + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map +64 │ allowances: Map> + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> +65 │ total_supply: u256 + │ ^^^^^^^^^^^^^^^^^^ u256 +66 │ +67 │ nonces: Map + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ Map +68 │ +69 │ factory: address + │ ^^^^^^^^^^^^^^^^ address +70 │ token0: ERC20 + │ ^^^^^^^^^^^^^ ERC20 +71 │ token1: ERC20 + │ ^^^^^^^^^^^^^ ERC20 +72 │ +73 │ reserve0: u256 + │ ^^^^^^^^^^^^^^ u256 +74 │ reserve1: u256 + │ ^^^^^^^^^^^^^^ u256 +75 │ block_timestamp_last: u256 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ u256 +76 │ +77 │ price0_cumulative_last: u256 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256 +78 │ price1_cumulative_last: u256 + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256 +79 │ k_last: u256 + │ ^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:76:5 + ┌─ uniswap.fe:85:5 │ -76 │ ╭ pub fn factory(self) -> address { -77 │ │ return self.factory -78 │ │ } +85 │ ╭ pub fn factory(self) -> address { +86 │ │ return self.factory +87 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> address note: - ┌─ uniswap.fe:77:16 + ┌─ uniswap.fe:86:16 │ -77 │ return self.factory +86 │ return self.factory │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:77:16 + ┌─ uniswap.fe:86:16 │ -77 │ return self.factory +86 │ return self.factory │ ^^^^^^^^^^^^ address: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:80:5 + ┌─ uniswap.fe:89:5 │ -80 │ ╭ pub fn token0(self) -> address { -81 │ │ return address(self.token0) -82 │ │ } +89 │ ╭ pub fn token0(self) -> address { +90 │ │ return address(self.token0) +91 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> address note: - ┌─ uniswap.fe:81:24 + ┌─ uniswap.fe:90:24 │ -81 │ return address(self.token0) +90 │ return address(self.token0) │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:81:24 + ┌─ uniswap.fe:90:24 │ -81 │ return address(self.token0) +90 │ return address(self.token0) │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(5) } => Value note: - ┌─ uniswap.fe:81:16 + ┌─ uniswap.fe:90:16 │ -81 │ return address(self.token0) +90 │ return address(self.token0) │ ^^^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:84:5 + ┌─ uniswap.fe:93:5 │ -84 │ ╭ pub fn token1(self) -> address { -85 │ │ return address(self.token1) -86 │ │ } +93 │ ╭ pub fn token1(self) -> address { +94 │ │ return address(self.token1) +95 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> address note: - ┌─ uniswap.fe:85:24 + ┌─ uniswap.fe:94:24 │ -85 │ return address(self.token1) +94 │ return address(self.token1) │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:85:24 + ┌─ uniswap.fe:94:24 │ -85 │ return address(self.token1) +94 │ return address(self.token1) │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(6) } => Value note: - ┌─ uniswap.fe:85:16 + ┌─ uniswap.fe:94:16 │ -85 │ return address(self.token1) +94 │ return address(self.token1) │ ^^^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:88:5 - │ -88 │ ╭ fn _mint(self, ctx: Context, to: address, value: u256) { -89 │ │ self.total_supply = self.total_supply + value -90 │ │ self.balances[to] = self.balances[to] + value -91 │ │ emit Transfer(ctx, from: address(0), to, value) -92 │ │ } - │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: to, typ: address }, { label: None, name: value, typ: u256 }] -> () + ┌─ uniswap.fe:97:5 + │ + 97 │ ╭ fn _mint(self, ctx: Context, to: address, value: u256) { + 98 │ │ self.total_supply = self.total_supply + value + 99 │ │ self.balances[to] = self.balances[to] + value +100 │ │ ctx.emit(Transfer(from: address(0), to, value)) +101 │ │ } + │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: to, typ: address }, { label: None, name: value, typ: u256 }] -> () note: - ┌─ uniswap.fe:89:9 + ┌─ uniswap.fe:98:9 │ -89 │ self.total_supply = self.total_supply + value +98 │ self.total_supply = self.total_supply + value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:89:9 + ┌─ uniswap.fe:98:9 │ -89 │ self.total_supply = self.total_supply + value +98 │ self.total_supply = self.total_supply + value │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(2) } note: - ┌─ uniswap.fe:89:29 + ┌─ uniswap.fe:98:29 │ -89 │ self.total_supply = self.total_supply + value +98 │ self.total_supply = self.total_supply + value │ ^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(2) } => Value note: - ┌─ uniswap.fe:89:29 + ┌─ uniswap.fe:98:29 │ -89 │ self.total_supply = self.total_supply + value +98 │ self.total_supply = self.total_supply + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -90 │ self.balances[to] = self.balances[to] + value +99 │ self.balances[to] = self.balances[to] + value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:90:9 + ┌─ uniswap.fe:99:9 │ -90 │ self.balances[to] = self.balances[to] + value +99 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^ ^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:90:9 + ┌─ uniswap.fe:99:9 │ -90 │ self.balances[to] = self.balances[to] + value +99 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ uniswap.fe:90:29 + ┌─ uniswap.fe:99:29 │ -90 │ self.balances[to] = self.balances[to] + value +99 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^ ^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:90:29 + ┌─ uniswap.fe:99:29 │ -90 │ self.balances[to] = self.balances[to] + value +99 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:90:29 - │ -90 │ self.balances[to] = self.balances[to] + value - │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -91 │ emit Transfer(ctx, from: address(0), to, value) - │ ^^^ ^ u256: Value - │ │ - │ Context: Memory + ┌─ uniswap.fe:99:29 + │ + 99 │ self.balances[to] = self.balances[to] + value + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +100 │ ctx.emit(Transfer(from: address(0), to, value)) + │ ^^^ ^ u256: Value + │ │ + │ Context: Memory note: - ┌─ uniswap.fe:91:34 - │ -91 │ emit Transfer(ctx, from: address(0), to, value) - │ ^^^^^^^^^^ ^^ ^^^^^ u256: Value - │ │ │ - │ │ address: Value - │ address: Value + ┌─ uniswap.fe:100:33 + │ +100 │ ctx.emit(Transfer(from: address(0), to, value)) + │ ^^^^^^^^^^ ^^ ^^^^^ u256: Value + │ │ │ + │ │ address: Value + │ address: Value note: - ┌─ uniswap.fe:94:5 - │ -94 │ ╭ fn _burn(self, ctx: Context, from: address, value: u256) { -95 │ │ self.balances[from] = self.balances[from] - value -96 │ │ self.total_supply = self.total_supply - value -97 │ │ emit Transfer(ctx, from, to: address(0), value) -98 │ │ } - │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: from, typ: address }, { label: None, name: value, typ: u256 }] -> () + ┌─ uniswap.fe:100:18 + │ +100 │ ctx.emit(Transfer(from: address(0), to, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Transfer: Memory note: - ┌─ uniswap.fe:95:9 - │ -95 │ self.balances[from] = self.balances[from] - value - │ ^^^^ UniswapV2Pair: Value + ┌─ uniswap.fe:100:9 + │ +100 │ ctx.emit(Transfer(from: address(0), to, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ uniswap.fe:95:9 - │ -95 │ self.balances[from] = self.balances[from] - value - │ ^^^^^^^^^^^^^ ^^^^ address: Value - │ │ - │ Map: Storage { nonce: Some(0) } + ┌─ uniswap.fe:103:5 + │ +103 │ ╭ fn _burn(self, ctx: Context, from: address, value: u256) { +104 │ │ self.balances[from] = self.balances[from] - value +105 │ │ self.total_supply = self.total_supply - value +106 │ │ ctx.emit(Transfer(from, to: address(0), value)) +107 │ │ } + │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: from, typ: address }, { label: None, name: value, typ: u256 }] -> () note: - ┌─ uniswap.fe:95:9 - │ -95 │ self.balances[from] = self.balances[from] - value - │ ^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value - │ │ - │ u256: Storage { nonce: None } + ┌─ uniswap.fe:104:9 + │ +104 │ self.balances[from] = self.balances[from] - value + │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:95:31 - │ -95 │ self.balances[from] = self.balances[from] - value - │ ^^^^^^^^^^^^^ ^^^^ address: Value - │ │ - │ Map: Storage { nonce: Some(0) } + ┌─ uniswap.fe:104:9 + │ +104 │ self.balances[from] = self.balances[from] - value + │ ^^^^^^^^^^^^^ ^^^^ address: Value + │ │ + │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:95:31 - │ -95 │ self.balances[from] = self.balances[from] - value - │ ^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ u256: Storage { nonce: None } => Value + ┌─ uniswap.fe:104:9 + │ +104 │ self.balances[from] = self.balances[from] - value + │ ^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value + │ │ + │ u256: Storage { nonce: None } note: - ┌─ uniswap.fe:95:31 - │ -95 │ self.balances[from] = self.balances[from] - value - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -96 │ self.total_supply = self.total_supply - value - │ ^^^^ UniswapV2Pair: Value + ┌─ uniswap.fe:104:31 + │ +104 │ self.balances[from] = self.balances[from] - value + │ ^^^^^^^^^^^^^ ^^^^ address: Value + │ │ + │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:96:9 - │ -96 │ self.total_supply = self.total_supply - value - │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value - │ │ - │ u256: Storage { nonce: Some(2) } + ┌─ uniswap.fe:104:31 + │ +104 │ self.balances[from] = self.balances[from] - value + │ ^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:96:29 - │ -96 │ self.total_supply = self.total_supply - value - │ ^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ u256: Storage { nonce: Some(2) } => Value + ┌─ uniswap.fe:104:31 + │ +104 │ self.balances[from] = self.balances[from] - value + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +105 │ self.total_supply = self.total_supply - value + │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:96:29 - │ -96 │ self.total_supply = self.total_supply - value - │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -97 │ emit Transfer(ctx, from, to: address(0), value) - │ ^^^ ^^^^ ^ u256: Value - │ │ │ - │ │ address: Value - │ Context: Memory + ┌─ uniswap.fe:105:9 + │ +105 │ self.total_supply = self.total_supply - value + │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value + │ │ + │ u256: Storage { nonce: Some(2) } note: - ┌─ uniswap.fe:97:38 - │ -97 │ emit Transfer(ctx, from, to: address(0), value) - │ ^^^^^^^^^^ ^^^^^ u256: Value - │ │ - │ address: Value + ┌─ uniswap.fe:105:29 + │ +105 │ self.total_supply = self.total_supply - value + │ ^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ u256: Storage { nonce: Some(2) } => Value + +note: + ┌─ uniswap.fe:105:29 + │ +105 │ self.total_supply = self.total_supply - value + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value +106 │ ctx.emit(Transfer(from, to: address(0), value)) + │ ^^^ ^^^^ ^ u256: Value + │ │ │ + │ │ address: Value + │ Context: Memory + +note: + ┌─ uniswap.fe:106:37 + │ +106 │ ctx.emit(Transfer(from, to: address(0), value)) + │ ^^^^^^^^^^ ^^^^^ u256: Value + │ │ + │ address: Value + +note: + ┌─ uniswap.fe:106:18 + │ +106 │ ctx.emit(Transfer(from, to: address(0), value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Transfer: Memory note: - ┌─ uniswap.fe:100:5 + ┌─ uniswap.fe:106:9 + │ +106 │ ctx.emit(Transfer(from, to: address(0), value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value + +note: + ┌─ uniswap.fe:109:5 │ -100 │ ╭ fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { -101 │ │ self.allowances[owner][spender] = value -102 │ │ emit Approval(ctx, owner, spender, value) -103 │ │ } +109 │ ╭ fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { +110 │ │ self.allowances[owner][spender] = value +111 │ │ ctx.emit(Approval(owner, spender, value)) +112 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: owner, typ: address }, { label: None, name: spender, typ: address }, { label: None, name: value, typ: u256 }] -> () note: - ┌─ uniswap.fe:101:9 + ┌─ uniswap.fe:110:9 │ -101 │ self.allowances[owner][spender] = value +110 │ self.allowances[owner][spender] = value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:101:9 + ┌─ uniswap.fe:110:9 │ -101 │ self.allowances[owner][spender] = value +110 │ self.allowances[owner][spender] = value │ ^^^^^^^^^^^^^^^ ^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ uniswap.fe:101:9 + ┌─ uniswap.fe:110:9 │ -101 │ self.allowances[owner][spender] = value +110 │ self.allowances[owner][spender] = value │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:101:9 + ┌─ uniswap.fe:110:9 │ -101 │ self.allowances[owner][spender] = value +110 │ self.allowances[owner][spender] = value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } -102 │ emit Approval(ctx, owner, spender, value) - │ ^^^ ^^^^^ ^^^^^^^ ^^^^^ u256: Value - │ │ │ │ - │ │ │ address: Value - │ │ address: Value - │ Context: Memory +111 │ ctx.emit(Approval(owner, spender, value)) + │ ^^^ ^^^^^ ^^^^^^^ ^^^^^ u256: Value + │ │ │ │ + │ │ │ address: Value + │ │ address: Value + │ Context: Memory note: - ┌─ uniswap.fe:105:5 + ┌─ uniswap.fe:111:18 + │ +111 │ ctx.emit(Approval(owner, spender, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Approval: Memory + +note: + ┌─ uniswap.fe:111:9 + │ +111 │ ctx.emit(Approval(owner, spender, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value + +note: + ┌─ uniswap.fe:114:5 │ -105 │ ╭ fn _transfer(self, ctx: Context, from: address, to: address, value: u256) { -106 │ │ self.balances[from] = self.balances[from] - value -107 │ │ self.balances[to] = self.balances[to] + value -108 │ │ emit Transfer(ctx, from, to, value) -109 │ │ } +114 │ ╭ fn _transfer(self, ctx: Context, from: address, to: address, value: u256) { +115 │ │ self.balances[from] = self.balances[from] - value +116 │ │ self.balances[to] = self.balances[to] + value +117 │ │ ctx.emit(Transfer(from, to, value)) +118 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: from, typ: address }, { label: None, name: to, typ: address }, { label: None, name: value, typ: u256 }] -> () note: - ┌─ uniswap.fe:106:9 + ┌─ uniswap.fe:115:9 │ -106 │ self.balances[from] = self.balances[from] - value +115 │ self.balances[from] = self.balances[from] - value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:106:9 + ┌─ uniswap.fe:115:9 │ -106 │ self.balances[from] = self.balances[from] - value +115 │ self.balances[from] = self.balances[from] - value │ ^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:106:9 + ┌─ uniswap.fe:115:9 │ -106 │ self.balances[from] = self.balances[from] - value +115 │ self.balances[from] = self.balances[from] - value │ ^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ uniswap.fe:106:31 + ┌─ uniswap.fe:115:31 │ -106 │ self.balances[from] = self.balances[from] - value +115 │ self.balances[from] = self.balances[from] - value │ ^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:106:31 + ┌─ uniswap.fe:115:31 │ -106 │ self.balances[from] = self.balances[from] - value +115 │ self.balances[from] = self.balances[from] - value │ ^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:106:31 + ┌─ uniswap.fe:115:31 │ -106 │ self.balances[from] = self.balances[from] - value +115 │ self.balances[from] = self.balances[from] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -107 │ self.balances[to] = self.balances[to] + value +116 │ self.balances[to] = self.balances[to] + value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:107:9 + ┌─ uniswap.fe:116:9 │ -107 │ self.balances[to] = self.balances[to] + value +116 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^ ^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:107:9 + ┌─ uniswap.fe:116:9 │ -107 │ self.balances[to] = self.balances[to] + value +116 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ uniswap.fe:107:29 + ┌─ uniswap.fe:116:29 │ -107 │ self.balances[to] = self.balances[to] + value +116 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^ ^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:107:29 + ┌─ uniswap.fe:116:29 │ -107 │ self.balances[to] = self.balances[to] + value +116 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:107:29 + ┌─ uniswap.fe:116:29 │ -107 │ self.balances[to] = self.balances[to] + value +116 │ self.balances[to] = self.balances[to] + value │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -108 │ emit Transfer(ctx, from, to, value) - │ ^^^ ^^^^ ^^ ^^^^^ u256: Value - │ │ │ │ - │ │ │ address: Value - │ │ address: Value - │ Context: Memory +117 │ ctx.emit(Transfer(from, to, value)) + │ ^^^ ^^^^ ^^ ^^^^^ u256: Value + │ │ │ │ + │ │ │ address: Value + │ │ address: Value + │ Context: Memory note: - ┌─ uniswap.fe:111:5 + ┌─ uniswap.fe:117:18 + │ +117 │ ctx.emit(Transfer(from, to, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^ Transfer: Memory + +note: + ┌─ uniswap.fe:117:9 + │ +117 │ ctx.emit(Transfer(from, to, value)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value + +note: + ┌─ uniswap.fe:120:5 │ -111 │ ╭ pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { -112 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) -113 │ │ return true -114 │ │ } +120 │ ╭ pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { +121 │ │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +122 │ │ return true +123 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: spender, typ: address }, { label: None, name: value, typ: u256 }] -> bool note: - ┌─ uniswap.fe:112:9 + ┌─ uniswap.fe:121:9 │ -112 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +121 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:112:35 + ┌─ uniswap.fe:121:35 │ -112 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +121 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ uniswap.fe:112:9 + ┌─ uniswap.fe:121:9 │ -112 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) +121 │ self._approve(ctx, owner: ctx.msg_sender(), spender, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -113 │ return true +122 │ return true │ ^^^^ bool: Value note: - ┌─ uniswap.fe:116:5 + ┌─ uniswap.fe:125:5 │ -116 │ ╭ pub fn transfer(self, ctx: Context, to: address, value: u256) -> bool { -117 │ │ self._transfer(ctx, from: ctx.msg_sender(), to, value) -118 │ │ return true -119 │ │ } +125 │ ╭ pub fn transfer(self, ctx: Context, to: address, value: u256) -> bool { +126 │ │ self._transfer(ctx, from: ctx.msg_sender(), to, value) +127 │ │ return true +128 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: to, typ: address }, { label: None, name: value, typ: u256 }] -> bool note: - ┌─ uniswap.fe:117:9 + ┌─ uniswap.fe:126:9 │ -117 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) +126 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:117:35 + ┌─ uniswap.fe:126:35 │ -117 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) +126 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) │ ^^^^^^^^^^^^^^^^ ^^ ^^^^^ u256: Value │ │ │ │ │ address: Value │ address: Value note: - ┌─ uniswap.fe:117:9 + ┌─ uniswap.fe:126:9 │ -117 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) +126 │ self._transfer(ctx, from: ctx.msg_sender(), to, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -118 │ return true +127 │ return true │ ^^^^ bool: Value note: - ┌─ uniswap.fe:121:5 + ┌─ uniswap.fe:130:5 │ -121 │ ╭ pub fn transferFrom(self, ctx: Context, from: address, to: address, value: u256) -> bool { -122 │ │ assert self.allowances[from][ctx.msg_sender()] >= value -123 │ │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value -124 │ │ self._transfer(ctx, from, to, value) -125 │ │ return true -126 │ │ } +130 │ ╭ pub fn transferFrom(self, ctx: Context, from: address, to: address, value: u256) -> bool { +131 │ │ assert self.allowances[from][ctx.msg_sender()] >= value +132 │ │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +133 │ │ self._transfer(ctx, from, to, value) +134 │ │ return true +135 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: from, typ: address }, { label: None, name: to, typ: address }, { label: None, name: value, typ: u256 }] -> bool note: - ┌─ uniswap.fe:122:16 + ┌─ uniswap.fe:131:16 │ -122 │ assert self.allowances[from][ctx.msg_sender()] >= value +131 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:122:16 + ┌─ uniswap.fe:131:16 │ -122 │ assert self.allowances[from][ctx.msg_sender()] >= value +131 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ uniswap.fe:122:16 + ┌─ uniswap.fe:131:16 │ -122 │ assert self.allowances[from][ctx.msg_sender()] >= value +131 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:122:38 + ┌─ uniswap.fe:131:38 │ -122 │ assert self.allowances[from][ctx.msg_sender()] >= value +131 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:122:16 + ┌─ uniswap.fe:131:16 │ -122 │ assert self.allowances[from][ctx.msg_sender()] >= value +131 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:122:16 + ┌─ uniswap.fe:131:16 │ -122 │ assert self.allowances[from][ctx.msg_sender()] >= value +131 │ assert self.allowances[from][ctx.msg_sender()] >= value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -123 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +132 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:123:9 + ┌─ uniswap.fe:132:9 │ -123 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +132 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ uniswap.fe:123:9 + ┌─ uniswap.fe:132:9 │ -123 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +132 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:123:31 + ┌─ uniswap.fe:132:31 │ -123 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +132 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:123:9 + ┌─ uniswap.fe:132:9 │ -123 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +132 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: None } note: - ┌─ uniswap.fe:123:51 + ┌─ uniswap.fe:132:51 │ -123 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +132 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^ ^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(1) } note: - ┌─ uniswap.fe:123:51 + ┌─ uniswap.fe:132:51 │ -123 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +132 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:123:73 + ┌─ uniswap.fe:132:73 │ -123 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +132 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:123:51 + ┌─ uniswap.fe:132:51 │ -123 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +132 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^ u256: Value │ │ │ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:123:51 + ┌─ uniswap.fe:132:51 │ -123 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value +132 │ self.allowances[from][ctx.msg_sender()] = self.allowances[from][ctx.msg_sender()] - value │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -124 │ self._transfer(ctx, from, to, value) +133 │ self._transfer(ctx, from, to, value) │ ^^^^ ^^^ ^^^^ ^^ ^^^^^ u256: Value │ │ │ │ │ │ │ │ │ address: Value @@ -729,561 +781,573 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:124:9 + ┌─ uniswap.fe:133:9 │ -124 │ self._transfer(ctx, from, to, value) +133 │ self._transfer(ctx, from, to, value) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -125 │ return true +134 │ return true │ ^^^^ bool: Value note: - ┌─ uniswap.fe:128:5 + ┌─ uniswap.fe:137:5 │ -128 │ ╭ pub fn balanceOf(self, _ account: address) -> u256 { -129 │ │ return self.balances[account] -130 │ │ } +137 │ ╭ pub fn balanceOf(self, _ account: address) -> u256 { +138 │ │ return self.balances[account] +139 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: Some("_"), name: account, typ: address }] -> u256 note: - ┌─ uniswap.fe:129:16 + ┌─ uniswap.fe:138:16 │ -129 │ return self.balances[account] +138 │ return self.balances[account] │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:129:16 + ┌─ uniswap.fe:138:16 │ -129 │ return self.balances[account] +138 │ return self.balances[account] │ ^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:129:16 + ┌─ uniswap.fe:138:16 │ -129 │ return self.balances[account] +138 │ return self.balances[account] │ ^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:132:5 + ┌─ uniswap.fe:141:5 │ -132 │ ╭ pub fn get_reserves(self) -> (u256, u256, u256) { -133 │ │ return (self.reserve0, self.reserve1, self.block_timestamp_last) -134 │ │ } +141 │ ╭ pub fn get_reserves(self) -> (u256, u256, u256) { +142 │ │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +143 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> (u256, u256, u256) note: - ┌─ uniswap.fe:133:17 + ┌─ uniswap.fe:142:17 │ -133 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +142 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:133:17 + ┌─ uniswap.fe:142:17 │ -133 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +142 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) │ ^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(7) } => Value note: - ┌─ uniswap.fe:133:32 + ┌─ uniswap.fe:142:32 │ -133 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +142 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) │ ^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(8) } => Value note: - ┌─ uniswap.fe:133:47 + ┌─ uniswap.fe:142:47 │ -133 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +142 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(9) } => Value note: - ┌─ uniswap.fe:133:16 + ┌─ uniswap.fe:142:16 │ -133 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) +142 │ return (self.reserve0, self.reserve1, self.block_timestamp_last) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (u256, u256, u256): Memory note: - ┌─ uniswap.fe:137:5 + ┌─ uniswap.fe:146:5 │ -137 │ ╭ pub fn initialize(self, ctx: Context, token0: ERC20, token1: ERC20) { -138 │ │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" -139 │ │ self.token0 = token0 -140 │ │ self.token1 = token1 -141 │ │ } +146 │ ╭ pub fn initialize(self, ctx: Context, token0: ERC20, token1: ERC20) { +147 │ │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +148 │ │ self.token0 = token0 +149 │ │ self.token1 = token1 +150 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: token0, typ: ERC20 }, { label: None, name: token1, typ: ERC20 }] -> () note: - ┌─ uniswap.fe:138:16 + ┌─ uniswap.fe:147:16 │ -138 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +147 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" │ ^^^ Context: Memory note: - ┌─ uniswap.fe:138:16 + ┌─ uniswap.fe:147:16 │ -138 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +147 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ address: Value note: - ┌─ uniswap.fe:138:36 + ┌─ uniswap.fe:147:36 │ -138 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +147 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^ address: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:138:16 + ┌─ uniswap.fe:147:16 │ -138 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" +147 │ assert ctx.msg_sender() == self.factory, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ String<20>: Memory │ │ │ bool: Value -139 │ self.token0 = token0 +148 │ self.token0 = token0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:139:9 + ┌─ uniswap.fe:148:9 │ -139 │ self.token0 = token0 +148 │ self.token0 = token0 │ ^^^^^^^^^^^ ^^^^^^ ERC20: Value │ │ │ ERC20: Storage { nonce: Some(5) } -140 │ self.token1 = token1 +149 │ self.token1 = token1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:140:9 + ┌─ uniswap.fe:149:9 │ -140 │ self.token1 = token1 +149 │ self.token1 = token1 │ ^^^^^^^^^^^ ^^^^^^ ERC20: Value │ │ │ ERC20: Storage { nonce: Some(6) } note: - ┌─ uniswap.fe:144:5 + ┌─ uniswap.fe:153:5 │ -144 │ ╭ fn _update(self, ctx: Context, balance0: u256, balance1: u256, reserve0: u256, reserve1: u256) { -145 │ │ // changed from u32s -146 │ │ // TODO: reproduce desired overflow (https://github.com/ethereum/fe/issues/286) -147 │ │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 +153 │ ╭ fn _update(self, ctx: Context, balance0: u256, balance1: u256, reserve0: u256, reserve1: u256) { +154 │ │ // changed from u32s +155 │ │ // TODO: reproduce desired overflow (https://github.com/ethereum/fe/issues/286) +156 │ │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 · │ -156 │ │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) -157 │ │ } +165 │ │ ctx.emit(Sync(reserve0: self.reserve0, reserve1: self.reserve1)) +166 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: balance0, typ: u256 }, { label: None, name: balance1, typ: u256 }, { label: None, name: reserve0, typ: u256 }, { label: None, name: reserve1, typ: u256 }] -> () note: - ┌─ uniswap.fe:147:13 + ┌─ uniswap.fe:156:13 │ -147 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 +156 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 │ ^^^^^^^^^^^^^^^ u256 -148 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last +157 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last │ ^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:147:37 + ┌─ uniswap.fe:156:37 │ -147 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 +156 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 │ ^^^ Context: Memory note: - ┌─ uniswap.fe:147:37 + ┌─ uniswap.fe:156:37 │ -147 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 +156 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 │ ^^^^^^^^^^^^^^^^^^^^^ ^ ^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:147:61 + ┌─ uniswap.fe:156:61 │ -147 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 +156 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 │ ^^^^^^^ u256: Value note: - ┌─ uniswap.fe:147:37 + ┌─ uniswap.fe:156:37 │ -147 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 +156 │ let block_timestamp: u256 = ctx.block_timestamp() % 2 ** 32 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -148 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last +157 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last │ ^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:148:52 + ┌─ uniswap.fe:157:52 │ -148 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last +157 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(9) } => Value note: - ┌─ uniswap.fe:148:34 + ┌─ uniswap.fe:157:34 │ -148 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last +157 │ let time_elapsed: u256 = block_timestamp - self.block_timestamp_last │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -149 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { +158 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:149:12 + ┌─ uniswap.fe:158:12 │ -149 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { +158 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^^^^^ ^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:149:33 + ┌─ uniswap.fe:158:33 │ -149 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { +158 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:149:12 + ┌─ uniswap.fe:158:12 │ -149 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { +158 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:149:51 + ┌─ uniswap.fe:158:51 │ -149 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { +158 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:149:12 + ┌─ uniswap.fe:158:12 │ -149 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { +158 │ if time_elapsed > 0 and reserve0 != 0 and reserve1 != 0 { │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -150 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed +159 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:150:13 + ┌─ uniswap.fe:159:13 │ -150 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed +159 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(10) } note: - ┌─ uniswap.fe:150:43 + ┌─ uniswap.fe:159:43 │ -150 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed +159 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Storage { nonce: Some(10) } => Value note: - ┌─ uniswap.fe:150:73 + ┌─ uniswap.fe:159:73 │ -150 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed +159 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:150:73 + ┌─ uniswap.fe:159:73 │ -150 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed +159 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:150:43 + ┌─ uniswap.fe:159:43 │ -150 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed +159 │ self.price0_cumulative_last = self.price0_cumulative_last + reserve1 / reserve0 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -151 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed +160 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:151:13 + ┌─ uniswap.fe:160:13 │ -151 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed +160 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Storage { nonce: Some(11) } note: - ┌─ uniswap.fe:151:43 + ┌─ uniswap.fe:160:43 │ -151 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed +160 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Storage { nonce: Some(11) } => Value note: - ┌─ uniswap.fe:151:73 + ┌─ uniswap.fe:160:73 │ -151 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed +160 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:151:73 + ┌─ uniswap.fe:160:73 │ -151 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed +160 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:151:43 + ┌─ uniswap.fe:160:43 │ -151 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed +160 │ self.price1_cumulative_last = self.price1_cumulative_last + reserve0 / reserve1 * time_elapsed │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -152 │ } -153 │ self.reserve0 = balance0 +161 │ } +162 │ self.reserve0 = balance0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:153:9 + ┌─ uniswap.fe:162:9 │ -153 │ self.reserve0 = balance0 +162 │ self.reserve0 = balance0 │ ^^^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(7) } -154 │ self.reserve1 = balance1 +163 │ self.reserve1 = balance1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:154:9 + ┌─ uniswap.fe:163:9 │ -154 │ self.reserve1 = balance1 +163 │ self.reserve1 = balance1 │ ^^^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(8) } -155 │ self.block_timestamp_last = block_timestamp +164 │ self.block_timestamp_last = block_timestamp │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:155:9 + ┌─ uniswap.fe:164:9 │ -155 │ self.block_timestamp_last = block_timestamp +164 │ self.block_timestamp_last = block_timestamp │ ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(9) } -156 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) - │ ^^^ ^^^^ UniswapV2Pair: Value - │ │ - │ Context: Memory +165 │ ctx.emit(Sync(reserve0: self.reserve0, reserve1: self.reserve1)) + │ ^^^ ^^^^ UniswapV2Pair: Value + │ │ + │ Context: Memory + +note: + ┌─ uniswap.fe:165:33 + │ +165 │ ctx.emit(Sync(reserve0: self.reserve0, reserve1: self.reserve1)) + │ ^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value + │ │ + │ u256: Storage { nonce: Some(7) } => Value + +note: + ┌─ uniswap.fe:165:58 + │ +165 │ ctx.emit(Sync(reserve0: self.reserve0, reserve1: self.reserve1)) + │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value note: - ┌─ uniswap.fe:156:34 + ┌─ uniswap.fe:165:18 │ -156 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) - │ ^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value - │ │ - │ u256: Storage { nonce: Some(7) } => Value +165 │ ctx.emit(Sync(reserve0: self.reserve0, reserve1: self.reserve1)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Sync: Memory note: - ┌─ uniswap.fe:156:59 + ┌─ uniswap.fe:165:9 │ -156 │ emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) - │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value +165 │ ctx.emit(Sync(reserve0: self.reserve0, reserve1: self.reserve1)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value note: - ┌─ uniswap.fe:159:5 + ┌─ uniswap.fe:168:5 │ -159 │ ╭ fn _mint_fee(self, ctx: Context, reserve0: u256, reserve1: u256) -> bool { -160 │ │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() -161 │ │ let fee_on: bool = fee_to != address(0) -162 │ │ let k_last: u256 = self.k_last +168 │ ╭ fn _mint_fee(self, ctx: Context, reserve0: u256, reserve1: u256) -> bool { +169 │ │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() +170 │ │ let fee_on: bool = fee_to != address(0) +171 │ │ let k_last: u256 = self.k_last · │ -179 │ │ return fee_on -180 │ │ } +188 │ │ return fee_on +189 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: reserve0, typ: u256 }, { label: None, name: reserve1, typ: u256 }] -> bool note: - ┌─ uniswap.fe:160:13 + ┌─ uniswap.fe:169:13 │ -160 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() +169 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() │ ^^^^^^ address -161 │ let fee_on: bool = fee_to != address(0) +170 │ let fee_on: bool = fee_to != address(0) │ ^^^^^^ bool -162 │ let k_last: u256 = self.k_last +171 │ let k_last: u256 = self.k_last │ ^^^^^^ u256 · -165 │ let root_k: u256 = sqrt(reserve0 * reserve1) +174 │ let root_k: u256 = sqrt(reserve0 * reserve1) │ ^^^^^^ u256 -166 │ let root_k_last: u256 = sqrt(k_last) +175 │ let root_k_last: u256 = sqrt(k_last) │ ^^^^^^^^^^^ u256 -167 │ if root_k > root_k_last { -168 │ let numerator: u256 = self.total_supply * root_k - root_k_last +176 │ if root_k > root_k_last { +177 │ let numerator: u256 = self.total_supply * root_k - root_k_last │ ^^^^^^^^^ u256 -169 │ let denominator: u256 = root_k * 5 + root_k_last +178 │ let denominator: u256 = root_k * 5 + root_k_last │ ^^^^^^^^^^^ u256 -170 │ let liquidity: u256 = numerator / denominator +179 │ let liquidity: u256 = numerator / denominator │ ^^^^^^^^^ u256 note: - ┌─ uniswap.fe:160:48 + ┌─ uniswap.fe:169:48 │ -160 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() +169 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:160:48 + ┌─ uniswap.fe:169:48 │ -160 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() +169 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() │ ^^^^^^^^^^^^ address: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:160:31 + ┌─ uniswap.fe:169:31 │ -160 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() +169 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:160:31 + ┌─ uniswap.fe:169:31 │ -160 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() +169 │ let fee_to: address = UniswapV2Factory(self.factory).fee_to() │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ address: Value -161 │ let fee_on: bool = fee_to != address(0) +170 │ let fee_on: bool = fee_to != address(0) │ ^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ uniswap.fe:161:38 + ┌─ uniswap.fe:170:38 │ -161 │ let fee_on: bool = fee_to != address(0) +170 │ let fee_on: bool = fee_to != address(0) │ ^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:161:28 + ┌─ uniswap.fe:170:28 │ -161 │ let fee_on: bool = fee_to != address(0) +170 │ let fee_on: bool = fee_to != address(0) │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -162 │ let k_last: u256 = self.k_last +171 │ let k_last: u256 = self.k_last │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:162:28 + ┌─ uniswap.fe:171:28 │ -162 │ let k_last: u256 = self.k_last +171 │ let k_last: u256 = self.k_last │ ^^^^^^^^^^^ u256: Storage { nonce: Some(12) } => Value -163 │ if fee_on { +172 │ if fee_on { │ ^^^^^^ bool: Value -164 │ if k_last != 0 { +173 │ if k_last != 0 { │ ^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:164:16 + ┌─ uniswap.fe:173:16 │ -164 │ if k_last != 0 { +173 │ if k_last != 0 { │ ^^^^^^^^^^^ bool: Value -165 │ let root_k: u256 = sqrt(reserve0 * reserve1) +174 │ let root_k: u256 = sqrt(reserve0 * reserve1) │ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:165:41 + ┌─ uniswap.fe:174:41 │ -165 │ let root_k: u256 = sqrt(reserve0 * reserve1) +174 │ let root_k: u256 = sqrt(reserve0 * reserve1) │ ^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:165:36 + ┌─ uniswap.fe:174:36 │ -165 │ let root_k: u256 = sqrt(reserve0 * reserve1) +174 │ let root_k: u256 = sqrt(reserve0 * reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -166 │ let root_k_last: u256 = sqrt(k_last) +175 │ let root_k_last: u256 = sqrt(k_last) │ ^^^^^^ u256: Value note: - ┌─ uniswap.fe:166:41 + ┌─ uniswap.fe:175:41 │ -166 │ let root_k_last: u256 = sqrt(k_last) +175 │ let root_k_last: u256 = sqrt(k_last) │ ^^^^^^^^^^^^ u256: Value -167 │ if root_k > root_k_last { +176 │ if root_k > root_k_last { │ ^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:167:20 + ┌─ uniswap.fe:176:20 │ -167 │ if root_k > root_k_last { +176 │ if root_k > root_k_last { │ ^^^^^^^^^^^^^^^^^^^^ bool: Value -168 │ let numerator: u256 = self.total_supply * root_k - root_k_last +177 │ let numerator: u256 = self.total_supply * root_k - root_k_last │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:168:43 + ┌─ uniswap.fe:177:43 │ -168 │ let numerator: u256 = self.total_supply * root_k - root_k_last +177 │ let numerator: u256 = self.total_supply * root_k - root_k_last │ ^^^^^^^^^^^^^^^^^ ^^^^^^ u256: Value │ │ │ u256: Storage { nonce: Some(2) } => Value note: - ┌─ uniswap.fe:168:43 + ┌─ uniswap.fe:177:43 │ -168 │ let numerator: u256 = self.total_supply * root_k - root_k_last +177 │ let numerator: u256 = self.total_supply * root_k - root_k_last │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:168:43 + ┌─ uniswap.fe:177:43 │ -168 │ let numerator: u256 = self.total_supply * root_k - root_k_last +177 │ let numerator: u256 = self.total_supply * root_k - root_k_last │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -169 │ let denominator: u256 = root_k * 5 + root_k_last +178 │ let denominator: u256 = root_k * 5 + root_k_last │ ^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:169:45 + ┌─ uniswap.fe:178:45 │ -169 │ let denominator: u256 = root_k * 5 + root_k_last +178 │ let denominator: u256 = root_k * 5 + root_k_last │ ^^^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:169:45 + ┌─ uniswap.fe:178:45 │ -169 │ let denominator: u256 = root_k * 5 + root_k_last +178 │ let denominator: u256 = root_k * 5 + root_k_last │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -170 │ let liquidity: u256 = numerator / denominator +179 │ let liquidity: u256 = numerator / denominator │ ^^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:170:43 + ┌─ uniswap.fe:179:43 │ -170 │ let liquidity: u256 = numerator / denominator +179 │ let liquidity: u256 = numerator / denominator │ ^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -171 │ if liquidity > 0 { +180 │ if liquidity > 0 { │ ^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:171:24 + ┌─ uniswap.fe:180:24 │ -171 │ if liquidity > 0 { +180 │ if liquidity > 0 { │ ^^^^^^^^^^^^^ bool: Value -172 │ self._mint(ctx, to: fee_to, value: liquidity) +181 │ self._mint(ctx, to: fee_to, value: liquidity) │ ^^^^ ^^^ ^^^^^^ ^^^^^^^^^ u256: Value │ │ │ │ │ │ │ address: Value @@ -1291,169 +1355,169 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:172:25 + ┌─ uniswap.fe:181:25 │ -172 │ self._mint(ctx, to: fee_to, value: liquidity) +181 │ self._mint(ctx, to: fee_to, value: liquidity) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value · -176 │ } else if k_last != 0 { +185 │ } else if k_last != 0 { │ ^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:176:19 + ┌─ uniswap.fe:185:19 │ -176 │ } else if k_last != 0 { +185 │ } else if k_last != 0 { │ ^^^^^^^^^^^ bool: Value -177 │ self.k_last = 0 +186 │ self.k_last = 0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:177:13 + ┌─ uniswap.fe:186:13 │ -177 │ self.k_last = 0 +186 │ self.k_last = 0 │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(12) } -178 │ } -179 │ return fee_on +187 │ } +188 │ return fee_on │ ^^^^^^ bool: Value note: - ┌─ uniswap.fe:183:5 + ┌─ uniswap.fe:192:5 │ -183 │ ╭ pub fn mint(self, ctx: Context, to: address) -> u256 { -184 │ │ let MINIMUM_LIQUIDITY: u256 = 1000 -185 │ │ let reserve0: u256 = self.reserve0 -186 │ │ let reserve1: u256 = self.reserve1 +192 │ ╭ pub fn mint(self, ctx: Context, to: address) -> u256 { +193 │ │ let MINIMUM_LIQUIDITY: u256 = 1000 +194 │ │ let reserve0: u256 = self.reserve0 +195 │ │ let reserve1: u256 = self.reserve1 · │ -207 │ │ return liquidity -208 │ │ } +216 │ │ return liquidity +217 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: to, typ: address }] -> u256 note: - ┌─ uniswap.fe:184:13 + ┌─ uniswap.fe:193:13 │ -184 │ let MINIMUM_LIQUIDITY: u256 = 1000 +193 │ let MINIMUM_LIQUIDITY: u256 = 1000 │ ^^^^^^^^^^^^^^^^^ u256 -185 │ let reserve0: u256 = self.reserve0 +194 │ let reserve0: u256 = self.reserve0 │ ^^^^^^^^ u256 -186 │ let reserve1: u256 = self.reserve1 +195 │ let reserve1: u256 = self.reserve1 │ ^^^^^^^^ u256 -187 │ let balance0: u256 = self.token0.balanceOf(ctx.self_address()) +196 │ let balance0: u256 = self.token0.balanceOf(ctx.self_address()) │ ^^^^^^^^ u256 -188 │ let balance1: u256 = self.token1.balanceOf(ctx.self_address()) +197 │ let balance1: u256 = self.token1.balanceOf(ctx.self_address()) │ ^^^^^^^^ u256 -189 │ let amount0: u256 = balance0 - self.reserve0 +198 │ let amount0: u256 = balance0 - self.reserve0 │ ^^^^^^^ u256 -190 │ let amount1: u256 = balance1 - self.reserve1 +199 │ let amount1: u256 = balance1 - self.reserve1 │ ^^^^^^^ u256 -191 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +200 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^^^ bool -192 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since totalSupply can update in _mintFee +201 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since totalSupply can update in _mintFee │ ^^^^^^^^^^^^ u256 -193 │ let liquidity: u256 = 0 +202 │ let liquidity: u256 = 0 │ ^^^^^^^^^ u256 note: - ┌─ uniswap.fe:184:39 + ┌─ uniswap.fe:193:39 │ -184 │ let MINIMUM_LIQUIDITY: u256 = 1000 +193 │ let MINIMUM_LIQUIDITY: u256 = 1000 │ ^^^^ u256: Value -185 │ let reserve0: u256 = self.reserve0 +194 │ let reserve0: u256 = self.reserve0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:185:30 + ┌─ uniswap.fe:194:30 │ -185 │ let reserve0: u256 = self.reserve0 +194 │ let reserve0: u256 = self.reserve0 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value -186 │ let reserve1: u256 = self.reserve1 +195 │ let reserve1: u256 = self.reserve1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:186:30 + ┌─ uniswap.fe:195:30 │ -186 │ let reserve1: u256 = self.reserve1 +195 │ let reserve1: u256 = self.reserve1 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value -187 │ let balance0: u256 = self.token0.balanceOf(ctx.self_address()) +196 │ let balance0: u256 = self.token0.balanceOf(ctx.self_address()) │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:187:30 + ┌─ uniswap.fe:196:30 │ -187 │ let balance0: u256 = self.token0.balanceOf(ctx.self_address()) +196 │ let balance0: u256 = self.token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Storage { nonce: Some(5) } => Value note: - ┌─ uniswap.fe:187:52 + ┌─ uniswap.fe:196:52 │ -187 │ let balance0: u256 = self.token0.balanceOf(ctx.self_address()) +196 │ let balance0: u256 = self.token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:187:30 + ┌─ uniswap.fe:196:30 │ -187 │ let balance0: u256 = self.token0.balanceOf(ctx.self_address()) +196 │ let balance0: u256 = self.token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -188 │ let balance1: u256 = self.token1.balanceOf(ctx.self_address()) +197 │ let balance1: u256 = self.token1.balanceOf(ctx.self_address()) │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:188:30 + ┌─ uniswap.fe:197:30 │ -188 │ let balance1: u256 = self.token1.balanceOf(ctx.self_address()) +197 │ let balance1: u256 = self.token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Storage { nonce: Some(6) } => Value note: - ┌─ uniswap.fe:188:52 + ┌─ uniswap.fe:197:52 │ -188 │ let balance1: u256 = self.token1.balanceOf(ctx.self_address()) +197 │ let balance1: u256 = self.token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:188:30 + ┌─ uniswap.fe:197:30 │ -188 │ let balance1: u256 = self.token1.balanceOf(ctx.self_address()) +197 │ let balance1: u256 = self.token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -189 │ let amount0: u256 = balance0 - self.reserve0 +198 │ let amount0: u256 = balance0 - self.reserve0 │ ^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:189:40 + ┌─ uniswap.fe:198:40 │ -189 │ let amount0: u256 = balance0 - self.reserve0 +198 │ let amount0: u256 = balance0 - self.reserve0 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value note: - ┌─ uniswap.fe:189:29 + ┌─ uniswap.fe:198:29 │ -189 │ let amount0: u256 = balance0 - self.reserve0 +198 │ let amount0: u256 = balance0 - self.reserve0 │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -190 │ let amount1: u256 = balance1 - self.reserve1 +199 │ let amount1: u256 = balance1 - self.reserve1 │ ^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:190:40 + ┌─ uniswap.fe:199:40 │ -190 │ let amount1: u256 = balance1 - self.reserve1 +199 │ let amount1: u256 = balance1 - self.reserve1 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value note: - ┌─ uniswap.fe:190:29 + ┌─ uniswap.fe:199:29 │ -190 │ let amount1: u256 = balance1 - self.reserve1 +199 │ let amount1: u256 = balance1 - self.reserve1 │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -191 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +200 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^ ^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ │ │ u256: Value @@ -1461,131 +1525,131 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:191:28 + ┌─ uniswap.fe:200:28 │ -191 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +200 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -192 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since totalSupply can update in _mintFee +201 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since totalSupply can update in _mintFee │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:192:34 + ┌─ uniswap.fe:201:34 │ -192 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since totalSupply can update in _mintFee +201 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since totalSupply can update in _mintFee │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(2) } => Value -193 │ let liquidity: u256 = 0 +202 │ let liquidity: u256 = 0 │ ^ u256: Value -194 │ if total_supply == 0 { +203 │ if total_supply == 0 { │ ^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:194:12 + ┌─ uniswap.fe:203:12 │ -194 │ if total_supply == 0 { +203 │ if total_supply == 0 { │ ^^^^^^^^^^^^^^^^^ bool: Value -195 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY +204 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY │ ^^^^^^^^^ ^^^^^^^ ^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:195:30 + ┌─ uniswap.fe:204:30 │ -195 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY +204 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY │ ^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:195:25 + ┌─ uniswap.fe:204:25 │ -195 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY +204 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY │ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:195:25 + ┌─ uniswap.fe:204:25 │ -195 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY +204 │ liquidity = sqrt(amount0 * amount1) - MINIMUM_LIQUIDITY │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -196 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) // permanently lock the first MINIMUM_LIQUIDITY tokens +205 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) // permanently lock the first MINIMUM_LIQUIDITY tokens │ ^^^^ ^^^ ^ u256: Value │ │ │ │ │ Context: Memory │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:196:33 + ┌─ uniswap.fe:205:33 │ -196 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) // permanently lock the first MINIMUM_LIQUIDITY tokens +205 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) // permanently lock the first MINIMUM_LIQUIDITY tokens │ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ u256: Value │ │ │ address: Value note: - ┌─ uniswap.fe:196:13 + ┌─ uniswap.fe:205:13 │ -196 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) // permanently lock the first MINIMUM_LIQUIDITY tokens +205 │ self._mint(ctx, to: address(0), value: MINIMUM_LIQUIDITY) // permanently lock the first MINIMUM_LIQUIDITY tokens │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -197 │ } else { -198 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) +206 │ } else { +207 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) │ ^^^^^^^^^ ^^^^^^^ ^^^^^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:198:29 + ┌─ uniswap.fe:207:29 │ -198 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) +207 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:198:29 + ┌─ uniswap.fe:207:29 │ -198 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) +207 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:198:64 + ┌─ uniswap.fe:207:64 │ -198 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) +207 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:198:64 + ┌─ uniswap.fe:207:64 │ -198 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) +207 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:198:25 + ┌─ uniswap.fe:207:25 │ -198 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) +207 │ liquidity = min(amount0 * total_supply / reserve0, amount1 * total_supply / reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -199 │ } -200 │ assert liquidity > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED" +208 │ } +209 │ assert liquidity > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED" │ ^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:200:16 + ┌─ uniswap.fe:209:16 │ -200 │ assert liquidity > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED" +209 │ assert liquidity > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_MINTED" │ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<40>: Memory │ │ │ bool: Value -201 │ self._mint(ctx, to, value: liquidity) +210 │ self._mint(ctx, to, value: liquidity) │ ^^^^ ^^^ ^^ ^^^^^^^^^ u256: Value │ │ │ │ │ │ │ address: Value @@ -1593,11 +1657,11 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:201:9 + ┌─ uniswap.fe:210:9 │ -201 │ self._mint(ctx, to, value: liquidity) +210 │ self._mint(ctx, to, value: liquidity) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -202 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +211 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^ ^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ │ │ │ │ │ │ u256: Value @@ -1607,176 +1671,188 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:202:9 + ┌─ uniswap.fe:211:9 │ -202 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +211 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -203 │ if fee_on { +212 │ if fee_on { │ ^^^^^^ bool: Value -204 │ self.k_last = reserve0 * reserve1 // reserve0 and reserve1 are up-to-date +213 │ self.k_last = reserve0 * reserve1 // reserve0 and reserve1 are up-to-date │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:204:13 + ┌─ uniswap.fe:213:13 │ -204 │ self.k_last = reserve0 * reserve1 // reserve0 and reserve1 are up-to-date +213 │ self.k_last = reserve0 * reserve1 // reserve0 and reserve1 are up-to-date │ ^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Storage { nonce: Some(12) } note: - ┌─ uniswap.fe:204:27 + ┌─ uniswap.fe:213:27 │ -204 │ self.k_last = reserve0 * reserve1 // reserve0 and reserve1 are up-to-date +213 │ self.k_last = reserve0 * reserve1 // reserve0 and reserve1 are up-to-date │ ^^^^^^^^^^^^^^^^^^^ u256: Value -205 │ } -206 │ emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) - │ ^^^ ^^^ Context: Memory - │ │ - │ Context: Memory +214 │ } +215 │ ctx.emit(Mint(sender: ctx.msg_sender(), amount0, amount1)) + │ ^^^ ^^^ Context: Memory + │ │ + │ Context: Memory note: - ┌─ uniswap.fe:206:32 + ┌─ uniswap.fe:215:31 │ -206 │ emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) - │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^ u256: Value - │ │ │ - │ │ u256: Value - │ address: Value -207 │ return liquidity +215 │ ctx.emit(Mint(sender: ctx.msg_sender(), amount0, amount1)) + │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^ u256: Value + │ │ │ + │ │ u256: Value + │ address: Value + +note: + ┌─ uniswap.fe:215:18 + │ +215 │ ctx.emit(Mint(sender: ctx.msg_sender(), amount0, amount1)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Mint: Memory + +note: + ┌─ uniswap.fe:215:9 + │ +215 │ ctx.emit(Mint(sender: ctx.msg_sender(), amount0, amount1)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value +216 │ return liquidity │ ^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:211:5 + ┌─ uniswap.fe:220:5 │ -211 │ ╭ pub fn burn(self, ctx: Context, to: address) -> (u256, u256) { -212 │ │ let reserve0: u256 = self.reserve0 -213 │ │ let reserve1: u256 = self.reserve1 -214 │ │ let token0: ERC20 = self.token0 +220 │ ╭ pub fn burn(self, ctx: Context, to: address) -> (u256, u256) { +221 │ │ let reserve0: u256 = self.reserve0 +222 │ │ let reserve1: u256 = self.reserve1 +223 │ │ let token0: ERC20 = self.token0 · │ -235 │ │ return (amount0, amount1) -236 │ │ } +244 │ │ return (amount0, amount1) +245 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: to, typ: address }] -> (u256, u256) note: - ┌─ uniswap.fe:212:13 + ┌─ uniswap.fe:221:13 │ -212 │ let reserve0: u256 = self.reserve0 +221 │ let reserve0: u256 = self.reserve0 │ ^^^^^^^^ u256 -213 │ let reserve1: u256 = self.reserve1 +222 │ let reserve1: u256 = self.reserve1 │ ^^^^^^^^ u256 -214 │ let token0: ERC20 = self.token0 +223 │ let token0: ERC20 = self.token0 │ ^^^^^^ ERC20 -215 │ let token1: ERC20 = self.token1 +224 │ let token1: ERC20 = self.token1 │ ^^^^^^ ERC20 -216 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +225 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^ u256 -217 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +226 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^ u256 -218 │ let liquidity: u256 = self.balances[ctx.self_address()] +227 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^^^^^^ u256 -219 │ -220 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +228 │ +229 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^^^ bool -221 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since total_supply can update in _mintFee +230 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since total_supply can update in _mintFee │ ^^^^^^^^^^^^ u256 -222 │ let amount0: u256 = (liquidity * balance0) / total_supply // using balances ensures pro-rata distribution +231 │ let amount0: u256 = (liquidity * balance0) / total_supply // using balances ensures pro-rata distribution │ ^^^^^^^ u256 -223 │ let amount1: u256 = (liquidity * balance1) / total_supply // using balances ensures pro-rata distribution +232 │ let amount1: u256 = (liquidity * balance1) / total_supply // using balances ensures pro-rata distribution │ ^^^^^^^ u256 note: - ┌─ uniswap.fe:212:30 + ┌─ uniswap.fe:221:30 │ -212 │ let reserve0: u256 = self.reserve0 +221 │ let reserve0: u256 = self.reserve0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:212:30 + ┌─ uniswap.fe:221:30 │ -212 │ let reserve0: u256 = self.reserve0 +221 │ let reserve0: u256 = self.reserve0 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value -213 │ let reserve1: u256 = self.reserve1 +222 │ let reserve1: u256 = self.reserve1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:213:30 + ┌─ uniswap.fe:222:30 │ -213 │ let reserve1: u256 = self.reserve1 +222 │ let reserve1: u256 = self.reserve1 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value -214 │ let token0: ERC20 = self.token0 +223 │ let token0: ERC20 = self.token0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:214:29 + ┌─ uniswap.fe:223:29 │ -214 │ let token0: ERC20 = self.token0 +223 │ let token0: ERC20 = self.token0 │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(5) } => Value -215 │ let token1: ERC20 = self.token1 +224 │ let token1: ERC20 = self.token1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:215:29 + ┌─ uniswap.fe:224:29 │ -215 │ let token1: ERC20 = self.token1 +224 │ let token1: ERC20 = self.token1 │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(6) } => Value -216 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +225 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:216:47 + ┌─ uniswap.fe:225:47 │ -216 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +225 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:216:30 + ┌─ uniswap.fe:225:30 │ -216 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +225 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -217 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +226 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:217:47 + ┌─ uniswap.fe:226:47 │ -217 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +226 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:217:30 + ┌─ uniswap.fe:226:30 │ -217 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +226 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -218 │ let liquidity: u256 = self.balances[ctx.self_address()] +227 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:218:31 + ┌─ uniswap.fe:227:31 │ -218 │ let liquidity: u256 = self.balances[ctx.self_address()] +227 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^^^^^^^^^^ ^^^ Context: Memory │ │ │ Map: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:218:45 + ┌─ uniswap.fe:227:45 │ -218 │ let liquidity: u256 = self.balances[ctx.self_address()] +227 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:218:31 + ┌─ uniswap.fe:227:31 │ -218 │ let liquidity: u256 = self.balances[ctx.self_address()] +227 │ let liquidity: u256 = self.balances[ctx.self_address()] │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Storage { nonce: None } => Value -219 │ -220 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +228 │ +229 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^ ^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ │ │ u256: Value @@ -1784,157 +1860,157 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:220:28 + ┌─ uniswap.fe:229:28 │ -220 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) +229 │ let fee_on: bool = self._mint_fee(ctx, reserve0, reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -221 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since total_supply can update in _mintFee +230 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since total_supply can update in _mintFee │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:221:34 + ┌─ uniswap.fe:230:34 │ -221 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since total_supply can update in _mintFee +230 │ let total_supply: u256 = self.total_supply // gas savings, must be defined here since total_supply can update in _mintFee │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(2) } => Value -222 │ let amount0: u256 = (liquidity * balance0) / total_supply // using balances ensures pro-rata distribution +231 │ let amount0: u256 = (liquidity * balance0) / total_supply // using balances ensures pro-rata distribution │ ^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:222:29 + ┌─ uniswap.fe:231:29 │ -222 │ let amount0: u256 = (liquidity * balance0) / total_supply // using balances ensures pro-rata distribution +231 │ let amount0: u256 = (liquidity * balance0) / total_supply // using balances ensures pro-rata distribution │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:222:29 + ┌─ uniswap.fe:231:29 │ -222 │ let amount0: u256 = (liquidity * balance0) / total_supply // using balances ensures pro-rata distribution +231 │ let amount0: u256 = (liquidity * balance0) / total_supply // using balances ensures pro-rata distribution │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -223 │ let amount1: u256 = (liquidity * balance1) / total_supply // using balances ensures pro-rata distribution +232 │ let amount1: u256 = (liquidity * balance1) / total_supply // using balances ensures pro-rata distribution │ ^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:223:29 + ┌─ uniswap.fe:232:29 │ -223 │ let amount1: u256 = (liquidity * balance1) / total_supply // using balances ensures pro-rata distribution +232 │ let amount1: u256 = (liquidity * balance1) / total_supply // using balances ensures pro-rata distribution │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:223:29 + ┌─ uniswap.fe:232:29 │ -223 │ let amount1: u256 = (liquidity * balance1) / total_supply // using balances ensures pro-rata distribution +232 │ let amount1: u256 = (liquidity * balance1) / total_supply // using balances ensures pro-rata distribution │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -224 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" +233 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" │ ^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:224:16 + ┌─ uniswap.fe:233:16 │ -224 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" +233 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" │ ^^^^^^^^^^^ ^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:224:32 + ┌─ uniswap.fe:233:32 │ -224 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" +233 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" │ ^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:224:16 + ┌─ uniswap.fe:233:16 │ -224 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" +233 │ assert amount0 > 0 and amount1 > 0, "UniswapV2: INSUFFICIENT_LIQUIDITY_BURNED" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<40>: Memory │ │ │ bool: Value -225 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) +234 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) │ ^^^^ ^^^ ^^^ Context: Memory │ │ │ │ │ Context: Memory │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:225:31 + ┌─ uniswap.fe:234:31 │ -225 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) +234 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) │ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ u256: Value │ │ │ address: Value note: - ┌─ uniswap.fe:225:9 + ┌─ uniswap.fe:234:9 │ -225 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) +234 │ self._burn(ctx, from: ctx.self_address(), value: liquidity) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -226 │ token0.transfer(to, amount0) +235 │ token0.transfer(to, amount0) │ ^^^^^^ ^^ ^^^^^^^ u256: Value │ │ │ │ │ address: Value │ ERC20: Value note: - ┌─ uniswap.fe:226:9 + ┌─ uniswap.fe:235:9 │ -226 │ token0.transfer(to, amount0) +235 │ token0.transfer(to, amount0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -227 │ token1.transfer(to, amount1) +236 │ token1.transfer(to, amount1) │ ^^^^^^ ^^ ^^^^^^^ u256: Value │ │ │ │ │ address: Value │ ERC20: Value note: - ┌─ uniswap.fe:227:9 + ┌─ uniswap.fe:236:9 │ -227 │ token1.transfer(to, amount1) +236 │ token1.transfer(to, amount1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -228 │ balance0 = token0.balanceOf(ctx.self_address()) +237 │ balance0 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^ ^^^^^^ ^^^ Context: Memory │ │ │ │ │ ERC20: Value │ u256: Value note: - ┌─ uniswap.fe:228:37 + ┌─ uniswap.fe:237:37 │ -228 │ balance0 = token0.balanceOf(ctx.self_address()) +237 │ balance0 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:228:20 + ┌─ uniswap.fe:237:20 │ -228 │ balance0 = token0.balanceOf(ctx.self_address()) +237 │ balance0 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -229 │ balance1 = token1.balanceOf(ctx.self_address()) +238 │ balance1 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^ ^^^^^^ ^^^ Context: Memory │ │ │ │ │ ERC20: Value │ u256: Value note: - ┌─ uniswap.fe:229:37 + ┌─ uniswap.fe:238:37 │ -229 │ balance1 = token1.balanceOf(ctx.self_address()) +238 │ balance1 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:229:20 + ┌─ uniswap.fe:238:20 │ -229 │ balance1 = token1.balanceOf(ctx.self_address()) +238 │ balance1 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -230 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +239 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^ ^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ │ │ │ │ │ │ u256: Value @@ -1944,514 +2020,526 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:230:9 + ┌─ uniswap.fe:239:9 │ -230 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +239 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -231 │ if fee_on { +240 │ if fee_on { │ ^^^^^^ bool: Value -232 │ self.k_last = reserve0 * reserve1 +241 │ self.k_last = reserve0 * reserve1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:232:13 + ┌─ uniswap.fe:241:13 │ -232 │ self.k_last = reserve0 * reserve1 +241 │ self.k_last = reserve0 * reserve1 │ ^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Storage { nonce: Some(12) } note: - ┌─ uniswap.fe:232:27 + ┌─ uniswap.fe:241:27 │ -232 │ self.k_last = reserve0 * reserve1 +241 │ self.k_last = reserve0 * reserve1 │ ^^^^^^^^^^^^^^^^^^^ u256: Value -233 │ } -234 │ emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) - │ ^^^ ^^^ Context: Memory - │ │ - │ Context: Memory - -note: - ┌─ uniswap.fe:234:32 - │ -234 │ emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) - │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^ ^^ address: Value - │ │ │ │ - │ │ │ u256: Value - │ │ u256: Value - │ address: Value -235 │ return (amount0, amount1) +242 │ } +243 │ ctx.emit(Burn(sender: ctx.msg_sender(), amount0, amount1, to)) + │ ^^^ ^^^ Context: Memory + │ │ + │ Context: Memory + +note: + ┌─ uniswap.fe:243:31 + │ +243 │ ctx.emit(Burn(sender: ctx.msg_sender(), amount0, amount1, to)) + │ ^^^^^^^^^^^^^^^^ ^^^^^^^ ^^^^^^^ ^^ address: Value + │ │ │ │ + │ │ │ u256: Value + │ │ u256: Value + │ address: Value + +note: + ┌─ uniswap.fe:243:18 + │ +243 │ ctx.emit(Burn(sender: ctx.msg_sender(), amount0, amount1, to)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Burn: Memory + +note: + ┌─ uniswap.fe:243:9 + │ +243 │ ctx.emit(Burn(sender: ctx.msg_sender(), amount0, amount1, to)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value +244 │ return (amount0, amount1) │ ^^^^^^^ ^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:235:16 + ┌─ uniswap.fe:244:16 │ -235 │ return (amount0, amount1) +244 │ return (amount0, amount1) │ ^^^^^^^^^^^^^^^^^^ (u256, u256): Memory note: - ┌─ uniswap.fe:241:5 + ┌─ uniswap.fe:250:5 │ -241 │ ╭ pub fn swap(self, ctx: Context, amount0_out: u256, amount1_out: u256, to: address) { -242 │ │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" -243 │ │ let reserve0: u256 = self.reserve0 -244 │ │ let reserve1: u256 = self.reserve1 +250 │ ╭ pub fn swap(self, ctx: Context, amount0_out: u256, amount1_out: u256, to: address) { +251 │ │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" +252 │ │ let reserve0: u256 = self.reserve0 +253 │ │ let reserve1: u256 = self.reserve1 · │ -277 │ │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) -278 │ │ } +286 │ │ ctx.emit(Swap(sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to)) +287 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: amount0_out, typ: u256 }, { label: None, name: amount1_out, typ: u256 }, { label: None, name: to, typ: address }] -> () note: - ┌─ uniswap.fe:243:13 + ┌─ uniswap.fe:252:13 │ -243 │ let reserve0: u256 = self.reserve0 +252 │ let reserve0: u256 = self.reserve0 │ ^^^^^^^^ u256 -244 │ let reserve1: u256 = self.reserve1 +253 │ let reserve1: u256 = self.reserve1 │ ^^^^^^^^ u256 · -247 │ let token0: ERC20 = self.token0 +256 │ let token0: ERC20 = self.token0 │ ^^^^^^ ERC20 -248 │ let token1: ERC20 = self.token1 +257 │ let token1: ERC20 = self.token1 │ ^^^^^^ ERC20 · -263 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +272 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^ u256 -264 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +273 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^ u256 -265 │ -266 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +274 │ +275 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^^^ u256 -267 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +276 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^^^ u256 · -271 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 +280 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 │ ^^^^^^^^^^^^^^^^^ u256 -272 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 +281 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 │ ^^^^^^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:242:16 + ┌─ uniswap.fe:251:16 │ -242 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" +251 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:242:16 + ┌─ uniswap.fe:251:16 │ -242 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" +251 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" │ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:242:35 + ┌─ uniswap.fe:251:35 │ -242 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" +251 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" │ ^^^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:242:16 + ┌─ uniswap.fe:251:16 │ -242 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" +251 │ assert amount0_out > 0 or amount1_out > 0, "UniswapV2: INSUFFICIENT_OUTPUT_AMOUNT" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<37>: Memory │ │ │ bool: Value -243 │ let reserve0: u256 = self.reserve0 +252 │ let reserve0: u256 = self.reserve0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:243:30 + ┌─ uniswap.fe:252:30 │ -243 │ let reserve0: u256 = self.reserve0 +252 │ let reserve0: u256 = self.reserve0 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value -244 │ let reserve1: u256 = self.reserve1 +253 │ let reserve1: u256 = self.reserve1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:244:30 + ┌─ uniswap.fe:253:30 │ -244 │ let reserve1: u256 = self.reserve1 +253 │ let reserve1: u256 = self.reserve1 │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value -245 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" +254 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" │ ^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:245:16 + ┌─ uniswap.fe:254:16 │ -245 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" +254 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" │ ^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:245:43 + ┌─ uniswap.fe:254:43 │ -245 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" +254 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" │ ^^^^^^^^^^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:245:16 + ┌─ uniswap.fe:254:16 │ -245 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" +254 │ assert amount0_out < reserve0 and amount1_out < reserve1, "UniswapV2: INSUFFICIENT_LIQUIDITY" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<33>: Memory │ │ │ bool: Value -246 │ -247 │ let token0: ERC20 = self.token0 +255 │ +256 │ let token0: ERC20 = self.token0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:247:29 + ┌─ uniswap.fe:256:29 │ -247 │ let token0: ERC20 = self.token0 +256 │ let token0: ERC20 = self.token0 │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(5) } => Value -248 │ let token1: ERC20 = self.token1 +257 │ let token1: ERC20 = self.token1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:248:29 + ┌─ uniswap.fe:257:29 │ -248 │ let token1: ERC20 = self.token1 +257 │ let token1: ERC20 = self.token1 │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(6) } => Value · -251 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +260 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^ ^^^^^^ ERC20: Value │ │ │ address: Value note: - ┌─ uniswap.fe:251:22 + ┌─ uniswap.fe:260:22 │ -251 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +260 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:251:16 + ┌─ uniswap.fe:260:16 │ -251 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +260 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^ ERC20: Value │ │ │ │ │ address: Value │ bool: Value note: - ┌─ uniswap.fe:251:48 + ┌─ uniswap.fe:260:48 │ -251 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +260 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:251:42 + ┌─ uniswap.fe:260:42 │ -251 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +260 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^^^^^^^^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:251:16 + ┌─ uniswap.fe:260:16 │ -251 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" +260 │ assert to != address(token0) and to != address(token1), "UniswapV2: INVALID_TO" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ String<21>: Memory │ │ │ bool: Value -252 │ -253 │ if amount0_out > 0 { +261 │ +262 │ if amount0_out > 0 { │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:253:12 + ┌─ uniswap.fe:262:12 │ -253 │ if amount0_out > 0 { +262 │ if amount0_out > 0 { │ ^^^^^^^^^^^^^^^ bool: Value -254 │ token0.transfer(to, amount0_out) // optimistically transfer tokens +263 │ token0.transfer(to, amount0_out) // optimistically transfer tokens │ ^^^^^^ ^^ ^^^^^^^^^^^ u256: Value │ │ │ │ │ address: Value │ ERC20: Value note: - ┌─ uniswap.fe:254:13 + ┌─ uniswap.fe:263:13 │ -254 │ token0.transfer(to, amount0_out) // optimistically transfer tokens +263 │ token0.transfer(to, amount0_out) // optimistically transfer tokens │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -255 │ } -256 │ if amount1_out > 0 { +264 │ } +265 │ if amount1_out > 0 { │ ^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:256:12 + ┌─ uniswap.fe:265:12 │ -256 │ if amount1_out > 0 { +265 │ if amount1_out > 0 { │ ^^^^^^^^^^^^^^^ bool: Value -257 │ token1.transfer(to, amount1_out) // optimistically transfer tokens +266 │ token1.transfer(to, amount1_out) // optimistically transfer tokens │ ^^^^^^ ^^ ^^^^^^^^^^^ u256: Value │ │ │ │ │ address: Value │ ERC20: Value note: - ┌─ uniswap.fe:257:13 + ┌─ uniswap.fe:266:13 │ -257 │ token1.transfer(to, amount1_out) // optimistically transfer tokens +266 │ token1.transfer(to, amount1_out) // optimistically transfer tokens │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value · -263 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +272 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:263:47 + ┌─ uniswap.fe:272:47 │ -263 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +272 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:263:30 + ┌─ uniswap.fe:272:30 │ -263 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) +272 │ let balance0: u256 = token0.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -264 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +273 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:264:47 + ┌─ uniswap.fe:273:47 │ -264 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +273 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:264:30 + ┌─ uniswap.fe:273:30 │ -264 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) +273 │ let balance1: u256 = token1.balanceOf(ctx.self_address()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -265 │ -266 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +274 │ +275 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:266:82 + ┌─ uniswap.fe:275:82 │ -266 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +275 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:266:32 + ┌─ uniswap.fe:275:32 │ -266 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +275 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:266:44 + ┌─ uniswap.fe:275:44 │ -266 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +275 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:266:43 + ┌─ uniswap.fe:275:43 │ -266 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +275 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:266:32 + ┌─ uniswap.fe:275:32 │ -266 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +275 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:266:32 + ┌─ uniswap.fe:275:32 │ -266 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 +275 │ let amount0_in: u256 = balance0 - (reserve0 - amount0_out) if balance0 > reserve0 - amount0_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -267 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +276 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:267:82 + ┌─ uniswap.fe:276:82 │ -267 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +276 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:267:32 + ┌─ uniswap.fe:276:32 │ -267 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +276 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:267:44 + ┌─ uniswap.fe:276:44 │ -267 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +276 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^ ^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:267:43 + ┌─ uniswap.fe:276:43 │ -267 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +276 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:267:32 + ┌─ uniswap.fe:276:32 │ -267 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +276 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:267:32 + ┌─ uniswap.fe:276:32 │ -267 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 +276 │ let amount1_in: u256 = balance1 - (reserve1 - amount1_out) if balance1 > reserve1 - amount1_out else 0 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -268 │ -269 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" +277 │ +278 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" │ ^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:269:16 + ┌─ uniswap.fe:278:16 │ -269 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" +278 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" │ ^^^^^^^^^^^^^^ ^^^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ bool: Value note: - ┌─ uniswap.fe:269:34 + ┌─ uniswap.fe:278:34 │ -269 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" +278 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" │ ^^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:269:16 + ┌─ uniswap.fe:278:16 │ -269 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" +278 │ assert amount0_in > 0 or amount1_in > 0, "UniswapV2: INSUFFICIENT_INPUT_AMOUNT" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<36>: Memory │ │ │ bool: Value -270 │ -271 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 +279 │ +280 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 │ ^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:271:39 + ┌─ uniswap.fe:280:39 │ -271 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 +280 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 │ ^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:271:57 + ┌─ uniswap.fe:280:57 │ -271 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 +280 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 │ ^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:271:39 + ┌─ uniswap.fe:280:39 │ -271 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 +280 │ let balance0_adjusted: u256 = balance0 * 1000 - amount0_in * 3 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -272 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 +281 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 │ ^^^^^^^^ ^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:272:39 + ┌─ uniswap.fe:281:39 │ -272 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 +281 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 │ ^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:272:57 + ┌─ uniswap.fe:281:57 │ -272 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 +281 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 │ ^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:272:39 + ┌─ uniswap.fe:281:39 │ -272 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 +281 │ let balance1_adjusted: u256 = balance1 * 1000 - amount1_in * 3 │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -273 │ -274 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" +282 │ +283 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" │ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:274:16 + ┌─ uniswap.fe:283:16 │ -274 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" +283 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:274:57 + ┌─ uniswap.fe:283:57 │ -274 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" +283 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" │ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:274:57 + ┌─ uniswap.fe:283:57 │ -274 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" +283 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:274:16 + ┌─ uniswap.fe:283:16 │ -274 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" +283 │ assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ String<12>: Memory │ │ │ bool: Value -275 │ -276 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +284 │ +285 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^ ^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ u256: Value │ │ │ │ │ │ │ │ │ │ │ u256: Value @@ -2461,66 +2549,78 @@ note: │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:276:9 + ┌─ uniswap.fe:285:9 │ -276 │ self._update(ctx, balance0, balance1, reserve0, reserve1) +285 │ self._update(ctx, balance0, balance1, reserve0, reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -277 │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) - │ ^^^ ^^^ Context: Memory - │ │ - │ Context: Memory +286 │ ctx.emit(Swap(sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to)) + │ ^^^ ^^^ Context: Memory + │ │ + │ Context: Memory + +note: + ┌─ uniswap.fe:286:31 + │ +286 │ ctx.emit(Swap(sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to)) + │ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ address: Value + │ │ │ │ │ │ + │ │ │ │ │ u256: Value + │ │ │ │ u256: Value + │ │ │ u256: Value + │ │ u256: Value + │ address: Value note: - ┌─ uniswap.fe:277:32 + ┌─ uniswap.fe:286:18 │ -277 │ emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) - │ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^ ^^ address: Value - │ │ │ │ │ │ - │ │ │ │ │ u256: Value - │ │ │ │ u256: Value - │ │ │ u256: Value - │ │ u256: Value - │ address: Value +286 │ ctx.emit(Swap(sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Swap: Memory note: - ┌─ uniswap.fe:281:5 + ┌─ uniswap.fe:286:9 + │ +286 │ ctx.emit(Swap(sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value + +note: + ┌─ uniswap.fe:290:5 │ -281 │ ╭ pub fn skim(self, ctx: Context, to: address) { -282 │ │ let token0: ERC20 = self.token0 // gas savings -283 │ │ let token1: ERC20 = self.token1 // gas savings -284 │ │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) -285 │ │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) -286 │ │ } +290 │ ╭ pub fn skim(self, ctx: Context, to: address) { +291 │ │ let token0: ERC20 = self.token0 // gas savings +292 │ │ let token1: ERC20 = self.token1 // gas savings +293 │ │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +294 │ │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +295 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: to, typ: address }] -> () note: - ┌─ uniswap.fe:282:13 + ┌─ uniswap.fe:291:13 │ -282 │ let token0: ERC20 = self.token0 // gas savings +291 │ let token0: ERC20 = self.token0 // gas savings │ ^^^^^^ ERC20 -283 │ let token1: ERC20 = self.token1 // gas savings +292 │ let token1: ERC20 = self.token1 // gas savings │ ^^^^^^ ERC20 note: - ┌─ uniswap.fe:282:29 + ┌─ uniswap.fe:291:29 │ -282 │ let token0: ERC20 = self.token0 // gas savings +291 │ let token0: ERC20 = self.token0 // gas savings │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:282:29 + ┌─ uniswap.fe:291:29 │ -282 │ let token0: ERC20 = self.token0 // gas savings +291 │ let token0: ERC20 = self.token0 // gas savings │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(5) } => Value -283 │ let token1: ERC20 = self.token1 // gas savings +292 │ let token1: ERC20 = self.token1 // gas savings │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:283:29 + ┌─ uniswap.fe:292:29 │ -283 │ let token1: ERC20 = self.token1 // gas savings +292 │ let token1: ERC20 = self.token1 // gas savings │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(6) } => Value -284 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +293 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^ ^^ ^^^^^^ ^^^ Context: Memory │ │ │ │ │ │ │ ERC20: Value @@ -2528,37 +2628,37 @@ note: │ ERC20: Value note: - ┌─ uniswap.fe:284:46 + ┌─ uniswap.fe:293:46 │ -284 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +293 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:284:29 + ┌─ uniswap.fe:293:29 │ -284 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +293 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:284:68 + ┌─ uniswap.fe:293:68 │ -284 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +293 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value note: - ┌─ uniswap.fe:284:29 + ┌─ uniswap.fe:293:29 │ -284 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +293 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:284:9 + ┌─ uniswap.fe:293:9 │ -284 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) +293 │ token0.transfer(to, token0.balanceOf(ctx.self_address()) - self.reserve0) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value -285 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +294 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^ ^^ ^^^^^^ ^^^ Context: Memory │ │ │ │ │ │ │ ERC20: Value @@ -2566,805 +2666,818 @@ note: │ ERC20: Value note: - ┌─ uniswap.fe:285:46 + ┌─ uniswap.fe:294:46 │ -285 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +294 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:285:29 + ┌─ uniswap.fe:294:29 │ -285 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +294 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:285:68 + ┌─ uniswap.fe:294:68 │ -285 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +294 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value note: - ┌─ uniswap.fe:285:29 + ┌─ uniswap.fe:294:29 │ -285 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +294 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value note: - ┌─ uniswap.fe:285:9 + ┌─ uniswap.fe:294:9 │ -285 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) +294 │ token1.transfer(to, token1.balanceOf(ctx.self_address()) - self.reserve1) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ bool: Value note: - ┌─ uniswap.fe:289:5 + ┌─ uniswap.fe:298:5 │ -289 │ ╭ pub fn sync(self, ctx: Context) { -290 │ │ let token0: ERC20 = self.token0 -291 │ │ let token1: ERC20 = self.token1 -292 │ │ self._update(ctx, +298 │ ╭ pub fn sync(self, ctx: Context) { +299 │ │ let token0: ERC20 = self.token0 +300 │ │ let token1: ERC20 = self.token1 +301 │ │ self._update(ctx, · │ -296 │ │ reserve1: self.reserve1) -297 │ │ } +305 │ │ reserve1: self.reserve1) +306 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }] -> () note: - ┌─ uniswap.fe:290:13 + ┌─ uniswap.fe:299:13 │ -290 │ let token0: ERC20 = self.token0 +299 │ let token0: ERC20 = self.token0 │ ^^^^^^ ERC20 -291 │ let token1: ERC20 = self.token1 +300 │ let token1: ERC20 = self.token1 │ ^^^^^^ ERC20 note: - ┌─ uniswap.fe:290:29 + ┌─ uniswap.fe:299:29 │ -290 │ let token0: ERC20 = self.token0 +299 │ let token0: ERC20 = self.token0 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:290:29 + ┌─ uniswap.fe:299:29 │ -290 │ let token0: ERC20 = self.token0 +299 │ let token0: ERC20 = self.token0 │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(5) } => Value -291 │ let token1: ERC20 = self.token1 +300 │ let token1: ERC20 = self.token1 │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:291:29 + ┌─ uniswap.fe:300:29 │ -291 │ let token1: ERC20 = self.token1 +300 │ let token1: ERC20 = self.token1 │ ^^^^^^^^^^^ ERC20: Storage { nonce: Some(6) } => Value -292 │ self._update(ctx, +301 │ self._update(ctx, │ ^^^^ ^^^ Context: Memory │ │ │ UniswapV2Pair: Value -293 │ balance0: token0.balanceOf(ctx.self_address()), +302 │ balance0: token0.balanceOf(ctx.self_address()), │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:293:49 + ┌─ uniswap.fe:302:49 │ -293 │ balance0: token0.balanceOf(ctx.self_address()), +302 │ balance0: token0.balanceOf(ctx.self_address()), │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:293:32 + ┌─ uniswap.fe:302:32 │ -293 │ balance0: token0.balanceOf(ctx.self_address()), +302 │ balance0: token0.balanceOf(ctx.self_address()), │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -294 │ balance1: token1.balanceOf(ctx.self_address()), +303 │ balance1: token1.balanceOf(ctx.self_address()), │ ^^^^^^ ^^^ Context: Memory │ │ │ ERC20: Value note: - ┌─ uniswap.fe:294:49 + ┌─ uniswap.fe:303:49 │ -294 │ balance1: token1.balanceOf(ctx.self_address()), +303 │ balance1: token1.balanceOf(ctx.self_address()), │ ^^^^^^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:294:32 + ┌─ uniswap.fe:303:32 │ -294 │ balance1: token1.balanceOf(ctx.self_address()), +303 │ balance1: token1.balanceOf(ctx.self_address()), │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -295 │ reserve0: self.reserve0, +304 │ reserve0: self.reserve0, │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:295:32 + ┌─ uniswap.fe:304:32 │ -295 │ reserve0: self.reserve0, +304 │ reserve0: self.reserve0, │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(7) } => Value -296 │ reserve1: self.reserve1) +305 │ reserve1: self.reserve1) │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:296:32 + ┌─ uniswap.fe:305:32 │ -296 │ reserve1: self.reserve1) +305 │ reserve1: self.reserve1) │ ^^^^^^^^^^^^^ u256: Storage { nonce: Some(8) } => Value note: - ┌─ uniswap.fe:292:9 + ┌─ uniswap.fe:301:9 │ -292 │ ╭ self._update(ctx, -293 │ │ balance0: token0.balanceOf(ctx.self_address()), -294 │ │ balance1: token1.balanceOf(ctx.self_address()), -295 │ │ reserve0: self.reserve0, -296 │ │ reserve1: self.reserve1) +301 │ ╭ self._update(ctx, +302 │ │ balance0: token0.balanceOf(ctx.self_address()), +303 │ │ balance1: token1.balanceOf(ctx.self_address()), +304 │ │ reserve0: self.reserve0, +305 │ │ reserve1: self.reserve1) │ ╰─────────────────────────────────────────────^ (): Value note: - ┌─ uniswap.fe:301:5 + ┌─ uniswap.fe:311:5 │ -301 │ fee_to: address +311 │ pub token0: address + │ ^^^^^^^^^^^^^^^^^^^ address +312 │ #indexed +313 │ pub token1: address + │ ^^^^^^^^^^^^^^^^^^^ address +314 │ pub pair: address + │ ^^^^^^^^^^^^^^^^^ address +315 │ pub index: u256 + │ ^^^^^^^^^^^^^^^ u256 + +note: + ┌─ uniswap.fe:319:5 + │ +319 │ fee_to: address │ ^^^^^^^^^^^^^^^ address -302 │ fee_to_setter: address +320 │ fee_to_setter: address │ ^^^^^^^^^^^^^^^^^^^^^^ address -303 │ -304 │ pairs: Map> +321 │ +322 │ pairs: Map> │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Map> -305 │ -306 │ all_pairs: Array +323 │ +324 │ all_pairs: Array │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array -307 │ pair_counter: u256 +325 │ pair_counter: u256 │ ^^^^^^^^^^^^^^^^^^ u256 note: - ┌─ uniswap.fe:310:9 - │ -310 │ idx token0: address - │ ^^^^^^^^^^^^^^^^^^^ address -311 │ idx token1: address - │ ^^^^^^^^^^^^^^^^^^^ address -312 │ pair: address - │ ^^^^^^^^^^^^^ address -313 │ index: u256 - │ ^^^^^^^^^^^ u256 - -note: - ┌─ uniswap.fe:320:5 + ┌─ uniswap.fe:331:5 │ -320 │ ╭ pub fn fee_to(self) -> address { -321 │ │ return self.fee_to -322 │ │ } +331 │ ╭ pub fn fee_to(self) -> address { +332 │ │ return self.fee_to +333 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> address note: - ┌─ uniswap.fe:321:16 + ┌─ uniswap.fe:332:16 │ -321 │ return self.fee_to +332 │ return self.fee_to │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:321:16 + ┌─ uniswap.fe:332:16 │ -321 │ return self.fee_to +332 │ return self.fee_to │ ^^^^^^^^^^^ address: Storage { nonce: Some(0) } => Value note: - ┌─ uniswap.fe:324:5 + ┌─ uniswap.fe:335:5 │ -324 │ ╭ pub fn fee_to_setter(self) -> address { -325 │ │ return self.fee_to_setter -326 │ │ } +335 │ ╭ pub fn fee_to_setter(self) -> address { +336 │ │ return self.fee_to_setter +337 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> address note: - ┌─ uniswap.fe:325:16 + ┌─ uniswap.fe:336:16 │ -325 │ return self.fee_to_setter +336 │ return self.fee_to_setter │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:325:16 + ┌─ uniswap.fe:336:16 │ -325 │ return self.fee_to_setter +336 │ return self.fee_to_setter │ ^^^^^^^^^^^^^^^^^^ address: Storage { nonce: Some(1) } => Value note: - ┌─ uniswap.fe:328:5 + ┌─ uniswap.fe:339:5 │ -328 │ ╭ pub fn all_pairs_length(self) -> u256 { -329 │ │ return self.pair_counter -330 │ │ } +339 │ ╭ pub fn all_pairs_length(self) -> u256 { +340 │ │ return self.pair_counter +341 │ │ } │ ╰─────^ self: Some(Mutable), params: [] -> u256 note: - ┌─ uniswap.fe:329:16 + ┌─ uniswap.fe:340:16 │ -329 │ return self.pair_counter +340 │ return self.pair_counter │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:329:16 + ┌─ uniswap.fe:340:16 │ -329 │ return self.pair_counter +340 │ return self.pair_counter │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:332:5 + ┌─ uniswap.fe:343:5 │ -332 │ ╭ pub fn create_pair(self, ctx: Context, _ token_a: address, _ token_b: address) -> address { -333 │ │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" -334 │ │ -335 │ │ let token0: address = token_a if token_a < token_b else token_b +343 │ ╭ pub fn create_pair(self, ctx: Context, _ token_a: address, _ token_b: address) -> address { +344 │ │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" +345 │ │ +346 │ │ let token0: address = token_a if token_a < token_b else token_b · │ -350 │ │ return address(pair) -351 │ │ } +361 │ │ return address(pair) +362 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: Some("_"), name: token_a, typ: address }, { label: Some("_"), name: token_b, typ: address }] -> address note: - ┌─ uniswap.fe:335:13 + ┌─ uniswap.fe:346:13 │ -335 │ let token0: address = token_a if token_a < token_b else token_b +346 │ let token0: address = token_a if token_a < token_b else token_b │ ^^^^^^ address -336 │ let token1: address = token_a if token_a > token_b else token_b +347 │ let token1: address = token_a if token_a > token_b else token_b │ ^^^^^^ address · -340 │ let salt: u256 = keccak256((token0, token1).abi_encode()) +351 │ let salt: u256 = keccak256((token0, token1).abi_encode()) │ ^^^^ u256 -341 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) +352 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) │ ^^^^ UniswapV2Pair note: - ┌─ uniswap.fe:333:16 + ┌─ uniswap.fe:344:16 │ -333 │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" +344 │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" │ ^^^^^^^ ^^^^^^^ address: Value │ │ │ address: Value note: - ┌─ uniswap.fe:333:16 + ┌─ uniswap.fe:344:16 │ -333 │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" +344 │ assert token_a != token_b, "UniswapV2: IDENTICAL_ADDRESSES" │ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ String<30>: Memory │ │ │ bool: Value -334 │ -335 │ let token0: address = token_a if token_a < token_b else token_b +345 │ +346 │ let token0: address = token_a if token_a < token_b else token_b │ ^^^^^^^ ^^^^^^^ address: Value │ │ │ address: Value note: - ┌─ uniswap.fe:335:31 + ┌─ uniswap.fe:346:31 │ -335 │ let token0: address = token_a if token_a < token_b else token_b +346 │ let token0: address = token_a if token_a < token_b else token_b │ ^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ │ │ bool: Value │ address: Value note: - ┌─ uniswap.fe:335:31 + ┌─ uniswap.fe:346:31 │ -335 │ let token0: address = token_a if token_a < token_b else token_b +346 │ let token0: address = token_a if token_a < token_b else token_b │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ address: Value -336 │ let token1: address = token_a if token_a > token_b else token_b +347 │ let token1: address = token_a if token_a > token_b else token_b │ ^^^^^^^ ^^^^^^^ address: Value │ │ │ address: Value note: - ┌─ uniswap.fe:336:31 + ┌─ uniswap.fe:347:31 │ -336 │ let token1: address = token_a if token_a > token_b else token_b +347 │ let token1: address = token_a if token_a > token_b else token_b │ ^^^^^^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^ address: Value │ │ │ │ │ bool: Value │ address: Value note: - ┌─ uniswap.fe:336:31 + ┌─ uniswap.fe:347:31 │ -336 │ let token1: address = token_a if token_a > token_b else token_b +347 │ let token1: address = token_a if token_a > token_b else token_b │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ address: Value -337 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" +348 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" │ ^^^^^^ ^ u256: Value │ │ │ address: Value note: - ┌─ uniswap.fe:337:26 + ┌─ uniswap.fe:348:26 │ -337 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" +348 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" │ ^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:337:16 + ┌─ uniswap.fe:348:16 │ -337 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" +348 │ assert token0 != address(0), "UniswapV2: ZERO_ADDRESS" │ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^ String<23>: Memory │ │ │ bool: Value -338 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +349 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:338:16 + ┌─ uniswap.fe:349:16 │ -338 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +349 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(2) } note: - ┌─ uniswap.fe:338:16 + ┌─ uniswap.fe:349:16 │ -338 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +349 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:338:16 + ┌─ uniswap.fe:349:16 │ -338 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +349 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ address: Storage { nonce: None } => Value note: - ┌─ uniswap.fe:338:46 + ┌─ uniswap.fe:349:46 │ -338 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +349 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:338:16 + ┌─ uniswap.fe:349:16 │ -338 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" +349 │ assert self.pairs[token0][token1] == address(0), "UniswapV2: PAIR_EXISTS" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^ String<22>: Memory │ │ │ bool: Value -339 │ -340 │ let salt: u256 = keccak256((token0, token1).abi_encode()) +350 │ +351 │ let salt: u256 = keccak256((token0, token1).abi_encode()) │ ^^^^^^ ^^^^^^ address: Value │ │ │ address: Value note: - ┌─ uniswap.fe:340:36 + ┌─ uniswap.fe:351:36 │ -340 │ let salt: u256 = keccak256((token0, token1).abi_encode()) +351 │ let salt: u256 = keccak256((token0, token1).abi_encode()) │ ^^^^^^^^^^^^^^^^ (address, address): Memory note: - ┌─ uniswap.fe:340:36 + ┌─ uniswap.fe:351:36 │ -340 │ let salt: u256 = keccak256((token0, token1).abi_encode()) +351 │ let salt: u256 = keccak256((token0, token1).abi_encode()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array: Memory note: - ┌─ uniswap.fe:340:26 + ┌─ uniswap.fe:351:26 │ -340 │ let salt: u256 = keccak256((token0, token1).abi_encode()) +351 │ let salt: u256 = keccak256((token0, token1).abi_encode()) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u256: Value -341 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) +352 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) │ ^^^ ^ ^^^^ u256: Value │ │ │ │ │ u256: Value │ Context: Memory note: - ┌─ uniswap.fe:341:35 + ┌─ uniswap.fe:352:35 │ -341 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) +352 │ let pair: UniswapV2Pair = UniswapV2Pair.create2(ctx, 0, salt) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UniswapV2Pair: Value -342 │ pair.initialize(ctx, token0: ERC20(token0), token1: ERC20(token1)) +353 │ pair.initialize(ctx, token0: ERC20(token0), token1: ERC20(token1)) │ ^^^^ ^^^ ^^^^^^ address: Value │ │ │ │ │ Context: Memory │ UniswapV2Pair: Value note: - ┌─ uniswap.fe:342:38 + ┌─ uniswap.fe:353:38 │ -342 │ pair.initialize(ctx, token0: ERC20(token0), token1: ERC20(token1)) +353 │ pair.initialize(ctx, token0: ERC20(token0), token1: ERC20(token1)) │ ^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ ERC20: Value note: - ┌─ uniswap.fe:342:61 + ┌─ uniswap.fe:353:61 │ -342 │ pair.initialize(ctx, token0: ERC20(token0), token1: ERC20(token1)) +353 │ pair.initialize(ctx, token0: ERC20(token0), token1: ERC20(token1)) │ ^^^^^^^^^^^^^ ERC20: Value note: - ┌─ uniswap.fe:342:9 + ┌─ uniswap.fe:353:9 │ -342 │ pair.initialize(ctx, token0: ERC20(token0), token1: ERC20(token1)) +353 │ pair.initialize(ctx, token0: ERC20(token0), token1: ERC20(token1)) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value -343 │ -344 │ self.pairs[token0][token1] = address(pair) +354 │ +355 │ self.pairs[token0][token1] = address(pair) │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:344:9 + ┌─ uniswap.fe:355:9 │ -344 │ self.pairs[token0][token1] = address(pair) +355 │ self.pairs[token0][token1] = address(pair) │ ^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(2) } note: - ┌─ uniswap.fe:344:9 + ┌─ uniswap.fe:355:9 │ -344 │ self.pairs[token0][token1] = address(pair) +355 │ self.pairs[token0][token1] = address(pair) │ ^^^^^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:344:9 + ┌─ uniswap.fe:355:9 │ -344 │ self.pairs[token0][token1] = address(pair) +355 │ self.pairs[token0][token1] = address(pair) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ address: Storage { nonce: None } note: - ┌─ uniswap.fe:344:38 + ┌─ uniswap.fe:355:38 │ -344 │ self.pairs[token0][token1] = address(pair) +355 │ self.pairs[token0][token1] = address(pair) │ ^^^^^^^^^^^^^ address: Value -345 │ self.pairs[token1][token0] = address(pair) +356 │ self.pairs[token1][token0] = address(pair) │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:345:9 + ┌─ uniswap.fe:356:9 │ -345 │ self.pairs[token1][token0] = address(pair) +356 │ self.pairs[token1][token0] = address(pair) │ ^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map>: Storage { nonce: Some(2) } note: - ┌─ uniswap.fe:345:9 + ┌─ uniswap.fe:356:9 │ -345 │ self.pairs[token1][token0] = address(pair) +356 │ self.pairs[token1][token0] = address(pair) │ ^^^^^^^^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ Map: Storage { nonce: None } note: - ┌─ uniswap.fe:345:9 + ┌─ uniswap.fe:356:9 │ -345 │ self.pairs[token1][token0] = address(pair) +356 │ self.pairs[token1][token0] = address(pair) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ address: Storage { nonce: None } note: - ┌─ uniswap.fe:345:38 + ┌─ uniswap.fe:356:38 │ -345 │ self.pairs[token1][token0] = address(pair) +356 │ self.pairs[token1][token0] = address(pair) │ ^^^^^^^^^^^^^ address: Value -346 │ self.all_pairs[self.pair_counter] = address(pair) +357 │ self.all_pairs[self.pair_counter] = address(pair) │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:346:9 + ┌─ uniswap.fe:357:9 │ -346 │ self.all_pairs[self.pair_counter] = address(pair) +357 │ self.all_pairs[self.pair_counter] = address(pair) │ ^^^^^^^^^^^^^^ ^^^^ UniswapV2Factory: Value │ │ │ Array: Storage { nonce: Some(3) } note: - ┌─ uniswap.fe:346:24 + ┌─ uniswap.fe:357:24 │ -346 │ self.all_pairs[self.pair_counter] = address(pair) +357 │ self.all_pairs[self.pair_counter] = address(pair) │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:346:9 + ┌─ uniswap.fe:357:9 │ -346 │ self.all_pairs[self.pair_counter] = address(pair) +357 │ self.all_pairs[self.pair_counter] = address(pair) │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Pair: Value │ │ │ address: Storage { nonce: None } note: - ┌─ uniswap.fe:346:45 + ┌─ uniswap.fe:357:45 │ -346 │ self.all_pairs[self.pair_counter] = address(pair) +357 │ self.all_pairs[self.pair_counter] = address(pair) │ ^^^^^^^^^^^^^ address: Value -347 │ self.pair_counter = self.pair_counter + 1 +358 │ self.pair_counter = self.pair_counter + 1 │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:347:9 + ┌─ uniswap.fe:358:9 │ -347 │ self.pair_counter = self.pair_counter + 1 +358 │ self.pair_counter = self.pair_counter + 1 │ ^^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Factory: Value │ │ │ u256: Storage { nonce: Some(4) } note: - ┌─ uniswap.fe:347:29 + ┌─ uniswap.fe:358:29 │ -347 │ self.pair_counter = self.pair_counter + 1 +358 │ self.pair_counter = self.pair_counter + 1 │ ^^^^^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:347:29 + ┌─ uniswap.fe:358:29 │ -347 │ self.pair_counter = self.pair_counter + 1 +358 │ self.pair_counter = self.pair_counter + 1 │ ^^^^^^^^^^^^^^^^^^^^^ u256: Value -348 │ -349 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) - │ ^^^ ^^^^^^ ^^^^^^ ^^^^ UniswapV2Pair: Value - │ │ │ │ - │ │ │ address: Value - │ │ address: Value - │ Context: Memory +359 │ +360 │ ctx.emit(PairCreated(token0, token1, pair: address(pair), index: self.pair_counter)) + │ ^^^ ^^^^^^ ^^^^^^ ^^^^ UniswapV2Pair: Value + │ │ │ │ + │ │ │ address: Value + │ │ address: Value + │ Context: Memory + +note: + ┌─ uniswap.fe:360:52 + │ +360 │ ctx.emit(PairCreated(token0, token1, pair: address(pair), index: self.pair_counter)) + │ ^^^^^^^^^^^^^ ^^^^ UniswapV2Factory: Value + │ │ + │ address: Value note: - ┌─ uniswap.fe:349:53 + ┌─ uniswap.fe:360:74 │ -349 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) - │ ^^^^^^^^^^^^^ ^^^^ UniswapV2Factory: Value - │ │ - │ address: Value +360 │ ctx.emit(PairCreated(token0, token1, pair: address(pair), index: self.pair_counter)) + │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(4) } => Value note: - ┌─ uniswap.fe:349:75 + ┌─ uniswap.fe:360:18 │ -349 │ emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) - │ ^^^^^^^^^^^^^^^^^ u256: Storage { nonce: Some(4) } => Value -350 │ return address(pair) +360 │ ctx.emit(PairCreated(token0, token1, pair: address(pair), index: self.pair_counter)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PairCreated: Memory + +note: + ┌─ uniswap.fe:360:9 + │ +360 │ ctx.emit(PairCreated(token0, token1, pair: address(pair), index: self.pair_counter)) + │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (): Value +361 │ return address(pair) │ ^^^^ UniswapV2Pair: Value note: - ┌─ uniswap.fe:350:16 + ┌─ uniswap.fe:361:16 │ -350 │ return address(pair) +361 │ return address(pair) │ ^^^^^^^^^^^^^ address: Value note: - ┌─ uniswap.fe:353:5 + ┌─ uniswap.fe:364:5 │ -353 │ ╭ pub fn set_fee_to(self, ctx: Context, fee_to: address) { -354 │ │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" -355 │ │ self.fee_to = fee_to -356 │ │ } +364 │ ╭ pub fn set_fee_to(self, ctx: Context, fee_to: address) { +365 │ │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" +366 │ │ self.fee_to = fee_to +367 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: fee_to, typ: address }] -> () note: - ┌─ uniswap.fe:354:16 + ┌─ uniswap.fe:365:16 │ -354 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" +365 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^ Context: Memory note: - ┌─ uniswap.fe:354:16 + ┌─ uniswap.fe:365:16 │ -354 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" +365 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^ ^^^^ UniswapV2Factory: Value │ │ │ address: Value note: - ┌─ uniswap.fe:354:36 + ┌─ uniswap.fe:365:36 │ -354 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" +365 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^^^ address: Storage { nonce: Some(1) } => Value note: - ┌─ uniswap.fe:354:16 + ┌─ uniswap.fe:365:16 │ -354 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" +365 │ assert ctx.msg_sender() == self.fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ String<20>: Memory │ │ │ bool: Value -355 │ self.fee_to = fee_to +366 │ self.fee_to = fee_to │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:355:9 + ┌─ uniswap.fe:366:9 │ -355 │ self.fee_to = fee_to +366 │ self.fee_to = fee_to │ ^^^^^^^^^^^ ^^^^^^ address: Value │ │ │ address: Storage { nonce: Some(0) } note: - ┌─ uniswap.fe:358:5 + ┌─ uniswap.fe:369:5 │ -358 │ ╭ pub fn set_fee_to_setter(self, ctx: Context, fee_to_setter: address) { -359 │ │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" -360 │ │ self.fee_to_setter = fee_to_setter -361 │ │ } +369 │ ╭ pub fn set_fee_to_setter(self, ctx: Context, fee_to_setter: address) { +370 │ │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" +371 │ │ self.fee_to_setter = fee_to_setter +372 │ │ } │ ╰─────^ self: Some(Mutable), params: [{ label: None, name: ctx, typ: Context }, { label: None, name: fee_to_setter, typ: address }] -> () note: - ┌─ uniswap.fe:359:16 + ┌─ uniswap.fe:370:16 │ -359 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" +370 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^ Context: Memory note: - ┌─ uniswap.fe:359:16 + ┌─ uniswap.fe:370:16 │ -359 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" +370 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ address: Value │ │ │ address: Value note: - ┌─ uniswap.fe:359:16 + ┌─ uniswap.fe:370:16 │ -359 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" +370 │ assert ctx.msg_sender() == fee_to_setter, "UniswapV2: FORBIDDEN" │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ String<20>: Memory │ │ │ bool: Value -360 │ self.fee_to_setter = fee_to_setter +371 │ self.fee_to_setter = fee_to_setter │ ^^^^ UniswapV2Factory: Value note: - ┌─ uniswap.fe:360:9 + ┌─ uniswap.fe:371:9 │ -360 │ self.fee_to_setter = fee_to_setter +371 │ self.fee_to_setter = fee_to_setter │ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ address: Value │ │ │ address: Storage { nonce: Some(1) } note: - ┌─ uniswap.fe:364:1 + ┌─ uniswap.fe:375:1 │ -364 │ ╭ fn sqrt(_ val: u256) -> u256 { -365 │ │ let z: u256 -366 │ │ if val > 3 { -367 │ │ z = val +375 │ ╭ fn sqrt(_ val: u256) -> u256 { +376 │ │ let z: u256 +377 │ │ if val > 3 { +378 │ │ z = val · │ -376 │ │ return z -377 │ │ } +387 │ │ return z +388 │ │ } │ ╰─^ self: None, params: [{ label: Some("_"), name: val, typ: u256 }] -> u256 note: - ┌─ uniswap.fe:365:9 + ┌─ uniswap.fe:376:9 │ -365 │ let z: u256 +376 │ let z: u256 │ ^ u256 · -368 │ let x: u256 = val / 2 + 1 +379 │ let x: u256 = val / 2 + 1 │ ^ u256 note: - ┌─ uniswap.fe:366:8 + ┌─ uniswap.fe:377:8 │ -366 │ if val > 3 { +377 │ if val > 3 { │ ^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:366:8 + ┌─ uniswap.fe:377:8 │ -366 │ if val > 3 { +377 │ if val > 3 { │ ^^^^^^^ bool: Value -367 │ z = val +378 │ z = val │ ^ ^^^ u256: Value │ │ │ u256: Value -368 │ let x: u256 = val / 2 + 1 +379 │ let x: u256 = val / 2 + 1 │ ^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:368:23 + ┌─ uniswap.fe:379:23 │ -368 │ let x: u256 = val / 2 + 1 +379 │ let x: u256 = val / 2 + 1 │ ^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:368:23 + ┌─ uniswap.fe:379:23 │ -368 │ let x: u256 = val / 2 + 1 +379 │ let x: u256 = val / 2 + 1 │ ^^^^^^^^^^^ u256: Value -369 │ while x < z { +380 │ while x < z { │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:369:15 + ┌─ uniswap.fe:380:15 │ -369 │ while x < z { +380 │ while x < z { │ ^^^^^ bool: Value -370 │ z = x +381 │ z = x │ ^ ^ u256: Value │ │ │ u256: Value -371 │ x = (val / x + x) / 2 +382 │ x = (val / x + x) / 2 │ ^ ^^^ ^ u256: Value │ │ │ │ │ u256: Value │ u256: Value note: - ┌─ uniswap.fe:371:18 + ┌─ uniswap.fe:382:18 │ -371 │ x = (val / x + x) / 2 +382 │ x = (val / x + x) / 2 │ ^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:371:17 + ┌─ uniswap.fe:382:17 │ -371 │ x = (val / x + x) / 2 +382 │ x = (val / x + x) / 2 │ ^^^^^^^^^^^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:371:17 + ┌─ uniswap.fe:382:17 │ -371 │ x = (val / x + x) / 2 +382 │ x = (val / x + x) / 2 │ ^^^^^^^^^^^^^^^^^ u256: Value -372 │ } -373 │ } else if val != 0 { +383 │ } +384 │ } else if val != 0 { │ ^^^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:373:15 + ┌─ uniswap.fe:384:15 │ -373 │ } else if val != 0 { +384 │ } else if val != 0 { │ ^^^^^^^^ bool: Value -374 │ z = 1 +385 │ z = 1 │ ^ ^ u256: Value │ │ │ u256: Value -375 │ } -376 │ return z +386 │ } +387 │ return z │ ^ u256: Value note: - ┌─ uniswap.fe:379:1 + ┌─ uniswap.fe:390:1 │ -379 │ ╭ fn min(_ x: u256, _ y: u256) -> u256 { -380 │ │ return x if x < y else y -381 │ │ } +390 │ ╭ fn min(_ x: u256, _ y: u256) -> u256 { +391 │ │ return x if x < y else y +392 │ │ } │ ╰─^ self: None, params: [{ label: Some("_"), name: x, typ: u256 }, { label: Some("_"), name: y, typ: u256 }] -> u256 note: - ┌─ uniswap.fe:380:17 + ┌─ uniswap.fe:391:17 │ -380 │ return x if x < y else y +391 │ return x if x < y else y │ ^ ^ u256: Value │ │ │ u256: Value note: - ┌─ uniswap.fe:380:12 + ┌─ uniswap.fe:391:12 │ -380 │ return x if x < y else y +391 │ return x if x < y else y │ ^ ^^^^^ ^ u256: Value │ │ │ │ │ bool: Value │ u256: Value note: - ┌─ uniswap.fe:380:12 + ┌─ uniswap.fe:391:12 │ -380 │ return x if x < y else y +391 │ return x if x < y else y │ ^^^^^^^^^^^^^^^^^ u256: Value diff --git a/crates/analyzer/tests/snapshots/errors__bad_visibility.snap b/crates/analyzer/tests/snapshots/errors__bad_visibility.snap index 7ce7b6661e..25663d9fe7 100644 --- a/crates/analyzer/tests/snapshots/errors__bad_visibility.snap +++ b/crates/analyzer/tests/snapshots/errors__bad_visibility.snap @@ -1,7 +1,14 @@ --- source: crates/analyzer/tests/errors.rs expression: error_string_ingot(&path) + --- +error: unresolved path item + ┌─ compile_errors/bad_visibility/src/main.fe:1:68 + │ +1 │ use foo::{MyInt, MY_CONST, MyStruct, MyTrait, my_func, MyContract, MyEnum } + │ ^^^^^^ not found + error: the type `MyInt` is private ┌─ compile_errors/bad_visibility/src/main.fe:7:33 │ @@ -44,129 +51,93 @@ error: the constant `MY_CONST` is private = `MY_CONST` can only be used within `foo` = Hint: use `pub` to make `MY_CONST` visible from outside of `foo` -error: the event `MyEvent` is private - ┌─ compile_errors/bad_visibility/src/main.fe:17:14 - │ -17 │ emit MyEvent(ctx, x: 1) - │ ^^^^^^^ this event is not `pub` - │ - ┌─ compile_errors/bad_visibility/src/foo.fe:7:7 - │ - 7 │ event MyEvent { - │ ------- `MyEvent` is defined here - │ - = `MyEvent` can only be used within `foo` - = Hint: use `pub` to make `MyEvent` visible from outside of `foo` - -error: the event `MyEvent` is private - ┌─ compile_errors/bad_visibility/src/main.fe:17:14 - │ -17 │ emit MyEvent(ctx, x: 1) - │ ^^^^^^^ this event is not `pub` - │ - ┌─ compile_errors/bad_visibility/src/foo.fe:7:1 - │ - 7 │ ╭ event MyEvent { - 8 │ │ x: i32 - 9 │ │ } - │ ╰─' `MyEvent` is defined here - │ - = `MyEvent` can only be used within `foo` - = Hint: use `pub event MyEvent` to make `MyEvent` visible from outside of `foo` - -error: cannot find value `ctx` in this scope - ┌─ compile_errors/bad_visibility/src/main.fe:17:22 - │ -17 │ emit MyEvent(ctx, x: 1) - │ ^^^ undefined - error: the struct `MyStruct` is private - ┌─ compile_errors/bad_visibility/src/main.fe:21:16 + ┌─ compile_errors/bad_visibility/src/main.fe:17:16 │ -21 │ let s: MyStruct = MyStruct(x: 1) +17 │ let s: MyStruct = MyStruct(x: 1) │ ^^^^^^^^ this struct is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:11:8 + ┌─ compile_errors/bad_visibility/src/foo.fe:7:8 │ -11 │ struct MyStruct { + 7 │ struct MyStruct { │ -------- `MyStruct` is defined here │ = `MyStruct` can only be used within `foo` = Hint: use `pub` to make `MyStruct` visible from outside of `foo` error: the struct `MyStruct` is private - ┌─ compile_errors/bad_visibility/src/main.fe:21:27 + ┌─ compile_errors/bad_visibility/src/main.fe:17:27 │ -21 │ let s: MyStruct = MyStruct(x: 1) +17 │ let s: MyStruct = MyStruct(x: 1) │ ^^^^^^^^ this struct is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:11:8 + ┌─ compile_errors/bad_visibility/src/foo.fe:7:8 │ -11 │ struct MyStruct { + 7 │ struct MyStruct { │ -------- `MyStruct` is defined here │ = `MyStruct` can only be used within `foo` = Hint: use `pub` to make `MyStruct` visible from outside of `foo` error: Can not call private constructor of struct `MyStruct` - ┌─ compile_errors/bad_visibility/src/foo.fe:12:5 - │ -12 │ x: i32 - │ ^^^^^^ Field `x` is private - │ - = Suggestion: implement a method `new(...)` on struct `MyStruct` to call the constructor and return the struct + ┌─ compile_errors/bad_visibility/src/foo.fe:8:5 + │ +8 │ x: i32 + │ ^^^^^^ Field `x` is private + │ + = Suggestion: implement a method `new(...)` on struct `MyStruct` to call the constructor and return the struct error: the function `my_func` is private - ┌─ compile_errors/bad_visibility/src/main.fe:25:9 + ┌─ compile_errors/bad_visibility/src/main.fe:21:9 │ -25 │ my_func() +21 │ my_func() │ ^^^^^^^ this function is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:15:4 + ┌─ compile_errors/bad_visibility/src/foo.fe:11:4 │ -15 │ fn my_func() {} +11 │ fn my_func() {} │ ------- `my_func` is defined here │ = `my_func` can only be used within `foo` = Hint: use `pub` to make `my_func` visible from outside of `foo` error: the type `MyContract` is private - ┌─ compile_errors/bad_visibility/src/main.fe:29:16 + ┌─ compile_errors/bad_visibility/src/main.fe:25:16 │ -29 │ let _: MyContract = MyContract(addr) +25 │ let _: MyContract = MyContract(addr) │ ^^^^^^^^^^ this type is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:17:10 + ┌─ compile_errors/bad_visibility/src/foo.fe:13:10 │ -17 │ contract MyContract { +13 │ contract MyContract { │ ---------- `MyContract` is defined here │ = `MyContract` can only be used within `foo` = Hint: use `pub` to make `MyContract` visible from outside of `foo` error: the type `MyContract` is private - ┌─ compile_errors/bad_visibility/src/main.fe:29:29 + ┌─ compile_errors/bad_visibility/src/main.fe:25:29 │ -29 │ let _: MyContract = MyContract(addr) +25 │ let _: MyContract = MyContract(addr) │ ^^^^^^^^^^ this type is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:17:10 + ┌─ compile_errors/bad_visibility/src/foo.fe:13:10 │ -17 │ contract MyContract { +13 │ contract MyContract { │ ---------- `MyContract` is defined here │ = `MyContract` can only be used within `foo` = Hint: use `pub` to make `MyContract` visible from outside of `foo` error: the type `MyContract` is private - ┌─ compile_errors/bad_visibility/src/main.fe:30:9 + ┌─ compile_errors/bad_visibility/src/main.fe:26:9 │ -30 │ MyContract.create(ctx, 1) +26 │ MyContract.create(ctx, 1) │ ^^^^^^^^^^ this type is not `pub` │ - ┌─ compile_errors/bad_visibility/src/foo.fe:17:10 + ┌─ compile_errors/bad_visibility/src/foo.fe:13:10 │ -17 │ contract MyContract { +13 │ contract MyContract { │ ---------- `MyContract` is defined here │ = `MyContract` can only be used within `foo` diff --git a/crates/analyzer/tests/snapshots/errors__call_event_with_wrong_types.snap b/crates/analyzer/tests/snapshots/errors__call_event_with_wrong_types.snap deleted file mode 100644 index 793fc5270a..0000000000 --- a/crates/analyzer/tests/snapshots/errors__call_event_with_wrong_types.snap +++ /dev/null @@ -1,18 +0,0 @@ ---- -source: crates/analyzer/tests/errors.rs -expression: "error_string(&path, test_files::fixture(path))" - ---- -error: incorrect type for `MyEvent` argument `val_1` - ┌─ compile_errors/call_event_with_wrong_types.fe:8:34 - │ -8 │ emit MyEvent(ctx, val_1: "foo bar", val_2: 1000) - │ ^^^^^^^^^ this has type `String<7>`; expected type `String<5>` - -error: literal out of range for `u8` - ┌─ compile_errors/call_event_with_wrong_types.fe:8:52 - │ -8 │ emit MyEvent(ctx, val_1: "foo bar", val_2: 1000) - │ ^^^^ does not fit into type `u8` - - diff --git a/crates/analyzer/tests/snapshots/errors__ctx_builtins_param_incorrect_type.snap b/crates/analyzer/tests/snapshots/errors__ctx_builtins_param_incorrect_type.snap index 43c76a015e..9340d20f6b 100644 --- a/crates/analyzer/tests/snapshots/errors__ctx_builtins_param_incorrect_type.snap +++ b/crates/analyzer/tests/snapshots/errors__ctx_builtins_param_incorrect_type.snap @@ -4,37 +4,23 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `Barn` expects 1 argument, but 2 were provided - ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:11:35 - │ -11 │ let existing_barn: Barn = Barn("hello world", address(0)) - │ ^^^^ ------------- ---------- supplied 2 arguments - │ │ - │ expects 1 argument + ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:7:35 + │ +7 │ let existing_barn: Barn = Barn("hello world", address(0)) + │ ^^^^ ------------- ---------- supplied 2 arguments + │ │ + │ expects 1 argument error: type mismatch - ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:11:40 - │ -11 │ let existing_barn: Barn = Barn("hello world", address(0)) - │ ^^^^^^^^^^^^^ this has type `String<11>`; expected type `address` + ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:7:40 + │ +7 │ let existing_barn: Barn = Barn("hello world", address(0)) + │ ^^^^^^^^^^^^^ this has type `String<11>`; expected type `address` error: incorrect type for argument to `Barn.create` - ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:12:46 - │ -12 │ let created_barn: Barn = Barn.create(address(26), 0) - │ ^^^^^^^^^^^ this has type `address`; expected `Context` - -error: missing argument label - ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:13:27 - │ -13 │ emit WorldMessage(42, message: "hello world") - │ ^ add `ctx:` here - │ - = Note: this label is optional if the argument is a variable named `ctx`. - -error: incorrect type for `WorldMessage` argument `ctx` - ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:13:27 - │ -13 │ emit WorldMessage(42, message: "hello world") - │ ^^ this has type `u256`; expected type `Context` + ┌─ compile_errors/ctx_builtins_param_incorrect_type.fe:8:46 + │ +8 │ let created_barn: Barn = Barn.create(address(26), 0) + │ ^^^^^^^^^^^ this has type `address`; expected `Context` diff --git a/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap b/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap deleted file mode 100644 index be544e6d50..0000000000 --- a/crates/analyzer/tests/snapshots/errors__emit_bad_args.snap +++ /dev/null @@ -1,44 +0,0 @@ ---- -source: crates/analyzer/tests/errors.rs -expression: "error_string(&path, test_files::fixture(path))" - ---- -error: `Foo` expects 4 arguments, but 5 were provided - ┌─ compile_errors/emit_bad_args.fe:9:14 - │ -9 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - │ ^^^ --- ------ ----- ------- ---- supplied 5 arguments - │ │ - │ expects 4 arguments - -error: missing argument label - ┌─ compile_errors/emit_bad_args.fe:9:23 - │ -9 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - │ ^ add `x:` here - │ - = Note: this label is optional if the argument is a variable named `x`. - -error: incorrect type for `Foo` argument `x` - ┌─ compile_errors/emit_bad_args.fe:9:23 - │ -9 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - │ ^^^^^^ this has type `(u256, u256)`; expected type `address` - -error: argument label mismatch - ┌─ compile_errors/emit_bad_args.fe:9:31 - │ -9 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - │ ^ expected `y` - │ - = Note: arguments must be provided in order. - -error: argument label mismatch - ┌─ compile_errors/emit_bad_args.fe:9:38 - │ -9 │ emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - │ ^ expected `z` - │ - = Note: arguments must be provided in order. - - diff --git a/crates/analyzer/tests/snapshots/errors__emittable_not_implementable.snap b/crates/analyzer/tests/snapshots/errors__emittable_not_implementable.snap new file mode 100644 index 0000000000..44f3cee7b5 --- /dev/null +++ b/crates/analyzer/tests/snapshots/errors__emittable_not_implementable.snap @@ -0,0 +1,20 @@ +--- +source: crates/analyzer/tests/errors.rs +expression: "error_string(&path, test_files::fixture(path))" + +--- +error: the struct `OutOfReachMarker` is private + ┌─ compile_errors/emittable_not_implementable.fe:6:24 + │ +6 │ fn emit(self, _ val: OutOfReachMarker) { + │ ^^^^^^^^^^^^^^^^ this struct is not `pub` + │ + ┌─ src/context.fe:8:8 + │ +8 │ struct OutOfReachMarker {} + │ ---------------- `OutOfReachMarker` is defined here + │ + = `OutOfReachMarker` can only be used within `context` + = Hint: use `pub` to make `OutOfReachMarker` visible from outside of `context` + + diff --git a/crates/analyzer/tests/snapshots/errors__indexed_event.snap b/crates/analyzer/tests/snapshots/errors__indexed_event.snap index de80ca4efe..27941abee0 100644 --- a/crates/analyzer/tests/snapshots/errors__indexed_event.snap +++ b/crates/analyzer/tests/snapshots/errors__indexed_event.snap @@ -4,17 +4,20 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: more than three indexed fields in `event MyEvent` - ┌─ compile_errors/indexed_event.fe:3:9 + ┌─ compile_errors/indexed_event.fe:3:5 │ -3 │ idx addr1: address - │ ^^^^^^^^^^^^^^^^^^ -4 │ idx addr2: address - │ ^^^^^^^^^^^^^^^^^^ -5 │ idx addr3: address - │ ^^^^^^^^^^^^^^^^^^ -6 │ idx addr4: address - │ ^^^^^^^^^^^^^^^^^^ 4 indexed fields +3 │ pub addr1: address + │ ^^^^^^^^^^^^^^^^^^ +4 │ #indexed +5 │ pub addr2: address + │ ^^^^^^^^^^^^^^^^^^ +6 │ #indexed +7 │ pub addr3: address + │ ^^^^^^^^^^^^^^^^^^ +8 │ #indexed +9 │ pub addr4: address + │ ^^^^^^^^^^^^^^^^^^ 4 indexed fields │ - = Note: Remove the `idx` keyword from at least 1 field. + = Note: Remove the `indexed` attribute from at least 1 field. diff --git a/crates/analyzer/tests/snapshots/errors__invalid_struct_attribute.snap b/crates/analyzer/tests/snapshots/errors__invalid_struct_attribute.snap new file mode 100644 index 0000000000..0d85c0b4d4 --- /dev/null +++ b/crates/analyzer/tests/snapshots/errors__invalid_struct_attribute.snap @@ -0,0 +1,12 @@ +--- +source: crates/analyzer/tests/errors.rs +expression: "error_string(&path, test_files::fixture(path))" + +--- +error: Invalid attribute + ┌─ compile_errors/invalid_struct_attribute.fe:2:5 + │ +2 │ #invalid + │ ^^^^^^^^ illegal name. Only `indexed` supported. + + diff --git a/crates/analyzer/tests/snapshots/errors__not_callable.snap b/crates/analyzer/tests/snapshots/errors__not_callable.snap index 4d01f65c4f..1ad8c6bc31 100644 --- a/crates/analyzer/tests/snapshots/errors__not_callable.snap +++ b/crates/analyzer/tests/snapshots/errors__not_callable.snap @@ -4,23 +4,15 @@ expression: "error_string(&path, test_files::fixture(path))" --- error: `u256` type is not callable - ┌─ compile_errors/not_callable.fe:7:9 + ┌─ compile_errors/not_callable.fe:3:9 │ -7 │ 5() +3 │ 5() │ ^ this has type `u256` -error: `MyEvent` is not callable - ┌─ compile_errors/not_callable.fe:11:9 - │ -11 │ MyEvent(x: 10) - │ ^^^^^^^ `MyEvent` is an event, and can't be constructed in this context - │ - = Hint: to emit an event, use `emit MyEvent(..)` - error: `self` is not callable - ┌─ compile_errors/not_callable.fe:15:9 - │ -15 │ self() - │ ^^^^ can't be used as a function + ┌─ compile_errors/not_callable.fe:7:9 + │ +7 │ self() + │ ^^^^ can't be used as a function diff --git a/crates/codegen/src/db/queries/abi.rs b/crates/codegen/src/db/queries/abi.rs index 9f7c1ce017..d990766bf2 100644 --- a/crates/codegen/src/db/queries/abi.rs +++ b/crates/codegen/src/db/queries/abi.rs @@ -4,7 +4,7 @@ use fe_abi::{ function::{AbiFunction, AbiFunctionType}, types::{AbiTupleField, AbiType}, }; -use fe_analyzer::namespace::items::ContractId; +use fe_analyzer::{constants::INDEXED, namespace::items::ContractId}; use fe_mir::ir::{self, FunctionId, TypeId}; use crate::db::CodegenDb; @@ -27,8 +27,9 @@ pub fn abi_contract(db: &dyn CodegenDb, contract: ContractId) -> AbiContract { } let mut events = vec![]; - for &event in db.contract_all_events(contract).as_ref() { - let mir_event = db.mir_lowered_event_type(event); + // We consider all structs that are defined or imported in the scope of the contract as possible events + for &event in db.module_structs(contract.module(db.upcast())).as_ref() { + let mir_event = db.mir_lowered_type(event.as_type(db.upcast())); let event = db.codegen_abi_event(mir_event); events.push(event); } @@ -197,8 +198,7 @@ pub fn abi_type(db: &dyn CodegenDb, ty: TypeId) -> AbiType { AbiType::Tuple(fields) } - ir::TypeKind::Event(_) - | ir::TypeKind::Contract(_) + ir::TypeKind::Contract(_) | ir::TypeKind::Map(_) | ir::TypeKind::MPtr(_) | ir::TypeKind::Enum(_) @@ -207,21 +207,30 @@ pub fn abi_type(db: &dyn CodegenDb, ty: TypeId) -> AbiType { } pub fn abi_event(db: &dyn CodegenDb, ty: TypeId) -> AbiEvent { - debug_assert!(ty.is_event(db.upcast())); + debug_assert!(ty.is_struct(db.upcast())); let legalized_ty = db.codegen_legalized_type(ty); - + let analyzer_struct = ty + .analyzer_ty(db.upcast()) + .and_then(|val| val.as_struct(db.upcast())) + .unwrap(); let legalized_ty_data = legalized_ty.data(db.upcast()); let event_def = match &legalized_ty_data.kind { - ir::TypeKind::Event(def) => def, + ir::TypeKind::Struct(def) => def, _ => unreachable!(), }; let fields = event_def .fields .iter() - .map(|(name, ty, indexed)| { + .map(|(name, ty)| { + let attr = analyzer_struct + .field(db.upcast(), name) + .unwrap() + .attributes(db.upcast()); + let ty = db.codegen_abi_type(*ty); - AbiEventField::new(name.to_string(), ty, *indexed) + let indexed = attr.iter().any(|attr| attr == INDEXED); + AbiEventField::new(name.to_string(), ty, indexed) }) .collect(); diff --git a/crates/codegen/src/db/queries/types.rs b/crates/codegen/src/db/queries/types.rs index c414a69ea6..5bb4df9883 100644 --- a/crates/codegen/src/db/queries/types.rs +++ b/crates/codegen/src/db/queries/types.rs @@ -1,5 +1,5 @@ use fe_mir::ir::{ - types::{ArrayDef, EventDef, MapDef, StructDef, TupleDef}, + types::{ArrayDef, MapDef, StructDef, TupleDef}, Type, TypeId, TypeKind, }; @@ -54,28 +54,6 @@ pub fn legalized_type(db: &dyn CodegenDb, ty: TypeId) -> TypeId { TypeKind::Struct(new_def) } - TypeKind::Event(def) => { - let fields = def - .fields - .iter() - .cloned() - .filter_map(|(name, ty, indexed)| { - if ty.is_zero_sized(db.upcast()) { - None - } else { - Some((name, legalized_type(db, ty), indexed)) - } - }) - .collect(); - let new_def = EventDef { - name: def.name.clone(), - fields, - span: def.span, - module_id: def.module_id, - }; - TypeKind::Event(new_def) - } - TypeKind::Contract(def) => { let fields = def .fields diff --git a/crates/library/std/src/context.fe b/crates/library/std/src/context.fe index 222cdf7353..9b93e1cb85 100644 --- a/crates/library/std/src/context.fe +++ b/crates/library/std/src/context.fe @@ -5,6 +5,15 @@ use ingot::error::{ Error } +struct OutOfReachMarker {} + +// ctx.emit(my_event) should be the only way to emit an event. We achieve this by defining the +// private `OutOfReachMarker` here to which only the `Context` has access. +// Now there is no way to call `emit` directly on an Emittable. +pub trait Emittable { + fn emit(self, _ val: OutOfReachMarker); +} + pub struct Context { pub fn base_fee(self) -> u256 { unsafe { return evm::base_fee() } @@ -76,4 +85,8 @@ pub struct Context { } } } + + pub fn emit(self, _ val: T) { + val.emit(OutOfReachMarker()) + } } \ No newline at end of file diff --git a/crates/library/std/src/traits.fe b/crates/library/std/src/traits.fe index 36445adb2e..5c0ed29d92 100644 --- a/crates/library/std/src/traits.fe +++ b/crates/library/std/src/traits.fe @@ -1,3 +1,3 @@ // Dummy trait used in testing. We can remove this once we have more useful traits -pub trait Dummy {} \ No newline at end of file +pub trait Dummy {} diff --git a/crates/mir/src/db.rs b/crates/mir/src/db.rs index f324f07925..8c160a31ee 100644 --- a/crates/mir/src/db.rs +++ b/crates/mir/src/db.rs @@ -1,4 +1,4 @@ -use std::rc::Rc; +use std::{collections::BTreeMap, rc::Rc}; use fe_analyzer::{ db::AnalyzerDbStorage, @@ -6,6 +6,7 @@ use fe_analyzer::{ AnalyzerDb, }; use fe_common::db::{SourceDb, SourceDbStorage, Upcast, UpcastMut}; +use smol_str::SmolStr; use crate::ir::{self, ConstantId, TypeId}; @@ -46,8 +47,6 @@ pub trait MirDb: AnalyzerDb + Upcast + UpcastMut #[salsa::invoke(queries::types::mir_lowered_type)] fn mir_lowered_type(&self, analyzer_type: analyzer_types::TypeId) -> TypeId; - #[salsa::invoke(queries::types::mir_lowered_event_type)] - fn mir_lowered_event_type(&self, analyzer_type: analyzer_items::EventId) -> TypeId; #[salsa::invoke(queries::constant::mir_lowered_constant)] fn mir_lowered_constant(&self, analyzer_const: analyzer_items::ModuleConstantId) -> ConstantId; @@ -61,7 +60,12 @@ pub trait MirDb: AnalyzerDb + Upcast + UpcastMut fn mir_lowered_monomorphized_func_signature( &self, analyzer_func: analyzer_items::FunctionId, - concrete_args: Vec, + resolved_generics: BTreeMap, + ) -> ir::FunctionId; + #[salsa::invoke(queries::function::mir_lowered_pseudo_monomorphized_func_signature)] + fn mir_lowered_pseudo_monomorphized_func_signature( + &self, + analyzer_func: analyzer_items::FunctionId, ) -> ir::FunctionId; #[salsa::invoke(queries::function::mir_lowered_func_body)] fn mir_lowered_func_body(&self, func: ir::FunctionId) -> Rc; diff --git a/crates/mir/src/db/queries/function.rs b/crates/mir/src/db/queries/function.rs index fd5a4e3f57..ad9924342a 100644 --- a/crates/mir/src/db/queries/function.rs +++ b/crates/mir/src/db/queries/function.rs @@ -1,4 +1,4 @@ -use std::rc::Rc; +use std::{collections::BTreeMap, rc::Rc}; use fe_analyzer::display::Displayable; use fe_analyzer::namespace::items as analyzer_items; @@ -23,9 +23,25 @@ pub fn mir_lowered_func_signature( pub fn mir_lowered_monomorphized_func_signature( db: &dyn MirDb, analyzer_func: analyzer_items::FunctionId, - concrete_args: Vec, + resolved_generics: BTreeMap, ) -> ir::FunctionId { - lower_monomorphized_func_signature(db, analyzer_func, &concrete_args) + lower_monomorphized_func_signature(db, analyzer_func, resolved_generics) +} + +/// Generate MIR function and monomorphize generic parameters as if they were called with unit type +/// NOTE: THIS SHOULD ONLY BE USED IN TEST CODE +pub fn mir_lowered_pseudo_monomorphized_func_signature( + db: &dyn MirDb, + analyzer_func: analyzer_items::FunctionId, +) -> ir::FunctionId { + let resolved_generics = analyzer_func + .sig(db.upcast()) + .generic_params(db.upcast()) + .iter() + .map(|generic| (generic.name(), analyzer_types::TypeId::unit(db.upcast()))) + .collect::>(); + + lower_monomorphized_func_signature(db, analyzer_func, resolved_generics) } pub fn mir_lowered_func_body(db: &dyn MirDb, func: ir::FunctionId) -> Rc { diff --git a/crates/mir/src/db/queries/structs.rs b/crates/mir/src/db/queries/structs.rs index 29278c134d..8ca121f94a 100644 --- a/crates/mir/src/db/queries/structs.rs +++ b/crates/mir/src/db/queries/structs.rs @@ -11,7 +11,7 @@ pub fn mir_lower_struct_all_functions( struct_ .all_functions(db.upcast()) .iter() - .map(|func| db.mir_lowered_func_signature(*func)) + .map(|func| db.mir_lowered_pseudo_monomorphized_func_signature(*func)) .collect::>() .into() } diff --git a/crates/mir/src/db/queries/types.rs b/crates/mir/src/db/queries/types.rs index 2e8c3979a2..fd60692e83 100644 --- a/crates/mir/src/db/queries/types.rs +++ b/crates/mir/src/db/queries/types.rs @@ -1,9 +1,6 @@ use std::{rc::Rc, str::FromStr}; -use fe_analyzer::namespace::{ - items::{self as analyzer_items, EnumVariantId}, - types as analyzer_types, -}; +use fe_analyzer::namespace::{items::EnumVariantId, types as analyzer_types}; use num_bigint::BigInt; use num_traits::ToPrimitive; @@ -14,17 +11,13 @@ use crate::{ types::{ArrayDef, TypeKind}, Type, TypeId, Value, }, - lower::types::{lower_event_type, lower_type}, + lower::types::lower_type, }; pub fn mir_lowered_type(db: &dyn MirDb, analyzer_type: analyzer_types::TypeId) -> TypeId { lower_type(db, &analyzer_type) } -pub fn mir_lowered_event_type(db: &dyn MirDb, event: analyzer_items::EventId) -> TypeId { - lower_event_type(db, event) -} - impl TypeId { pub fn data(self, db: &dyn MirDb) -> Rc { db.lookup_mir_intern_type(self) @@ -46,10 +39,6 @@ impl TypeId { let index = expect_projection_index(access); def.fields[index].1 } - TypeKind::Event(def) => { - let index = expect_projection_index(access); - def.fields[index].1 - } TypeKind::Enum(_) => { let index = expect_projection_index(access); debug_assert_eq!(index, 0); @@ -80,7 +69,6 @@ impl TypeId { TypeKind::Array(ArrayDef { elem_ty, .. }) => *elem_ty, TypeKind::Tuple(def) => def.items[index], TypeKind::Struct(def) | TypeKind::Contract(def) => def.fields[index].1, - TypeKind::Event(def) => def.fields[index].1, TypeKind::Enum(_) => { debug_assert_eq!(index, 0); self.enum_disc_type(db) @@ -94,7 +82,6 @@ impl TypeId { TypeKind::Array(ArrayDef { len, .. }) => *len, TypeKind::Tuple(def) => def.items.len(), TypeKind::Struct(def) | TypeKind::Contract(def) => def.fields.len(), - TypeKind::Event(def) => def.fields.len(), TypeKind::Enum(_) => 2, _ => unreachable!(), } @@ -163,13 +150,6 @@ impl TypeId { .find_map(|(i, field)| (field.0 == fname).then(|| i.into())) .unwrap(), - TypeKind::Event(def) => def - .fields - .iter() - .enumerate() - .find_map(|(i, field)| (field.0 == fname).then(|| i.into())) - .unwrap(), - other => unreachable!("{:?} does not have fields", other), } } @@ -284,15 +264,6 @@ impl TypeId { .unwrap_or(0); data_offset + maximum_data_size } - - TypeKind::Event(def) => { - if def.fields.is_empty() { - return 0; - } - let last_idx = def.fields.len() - 1; - self.aggregate_elem_offset(db, last_idx, slot_size) - + def.fields[last_idx].1.size_of(db, slot_size) - } } } @@ -352,10 +323,13 @@ impl TypeId { | TypeKind::Struct(_) | TypeKind::Enum(_) | TypeKind::Contract(_) - | TypeKind::Event(_) ) } + pub fn is_struct(self, db: &dyn MirDb) -> bool { + matches!(&self.data(db).as_ref().kind, TypeKind::Struct(_)) + } + pub fn is_array(self, db: &dyn MirDb) -> bool { matches!(&self.data(db).as_ref().kind, TypeKind::Array(_)) } @@ -387,10 +361,6 @@ impl TypeId { matches!(self.data(db).kind, TypeKind::Contract(_)) } - pub fn is_event(self, db: &dyn MirDb) -> bool { - matches!(self.data(db).kind, TypeKind::Event(_)) - } - pub fn array_elem_size(self, db: &dyn MirDb, slot_size: usize) -> usize { let data = self.data(db); if let TypeKind::Array(def) = &data.kind { diff --git a/crates/mir/src/ir/function.rs b/crates/mir/src/ir/function.rs index ccfb0dbee8..f1f466ea0e 100644 --- a/crates/mir/src/ir/function.rs +++ b/crates/mir/src/ir/function.rs @@ -22,7 +22,7 @@ use super::{ #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct FunctionSignature { pub params: Vec, - pub resolved_generics: BTreeMap, + pub resolved_generics: BTreeMap, pub return_type: Option, pub module_id: analyzer_items::ModuleId, pub analyzer_func_id: analyzer_items::FunctionId, diff --git a/crates/mir/src/ir/types.rs b/crates/mir/src/ir/types.rs index 1d06158e5d..9692d858c5 100644 --- a/crates/mir/src/ir/types.rs +++ b/crates/mir/src/ir/types.rs @@ -38,7 +38,6 @@ pub enum TypeKind { Tuple(TupleDef), Struct(StructDef), Enum(EnumDef), - Event(EventDef), Contract(StructDef), Map(MapDef), MPtr(TypeId), diff --git a/crates/mir/src/lower/function.rs b/crates/mir/src/lower/function.rs index a9053bd1cf..fd667698be 100644 --- a/crates/mir/src/lower/function.rs +++ b/crates/mir/src/lower/function.rs @@ -2,6 +2,7 @@ use std::{collections::BTreeMap, rc::Rc, vec}; use fe_analyzer::{ builtins::{ContractTypeMethod, GlobalFunction, ValueMethod}, + constants::{EMITTABLE_TRAIT_NAME, EMIT_FN_NAME}, context::{CallType as AnalyzerCallType, NamedThing}, namespace::{ items::{self as analyzer_items}, @@ -32,12 +33,12 @@ use crate::{ type ScopeId = Id; pub fn lower_func_signature(db: &dyn MirDb, func: analyzer_items::FunctionId) -> FunctionId { - lower_monomorphized_func_signature(db, func, &[]) + lower_monomorphized_func_signature(db, func, BTreeMap::new()) } pub fn lower_monomorphized_func_signature( db: &dyn MirDb, func: analyzer_items::FunctionId, - mut concrete_args: &[analyzer_types::TypeId], + resolved_generics: BTreeMap, ) -> FunctionId { // TODO: Remove this when an analyzer's function signature contains `self` type. let mut params = vec![]; @@ -47,28 +48,20 @@ pub fn lower_monomorphized_func_signature( let self_ty = func.self_type(db.upcast()).unwrap(); let source = self_arg_source(db, func); params.push(make_param(db, "self", self_ty, source)); - // similarly, when in the future analyzer params contain `self` we won't need to - // adjust the concrete args anymore - if !concrete_args.is_empty() { - concrete_args = &concrete_args[1..] - } } let analyzer_signature = func.signature(db.upcast()); - let mut resolved_generics: BTreeMap = - BTreeMap::new(); - for (index, param) in analyzer_signature.params.iter().enumerate() { + for param in analyzer_signature.params.iter() { let source = arg_source(db, func, ¶m.name); - let provided_type = concrete_args - .get(index) - .cloned() - .unwrap_or_else(|| param.typ.clone().unwrap()); - params.push(make_param(db, param.clone().name, provided_type, source)); + let param_type = if let Type::Generic(generic) = param.typ.clone().unwrap().typ(db.upcast()) + { + *resolved_generics.get(&generic.name).unwrap() + } else { + param.typ.clone().unwrap() + }; - if let Type::Generic(generic) = param.typ.clone().unwrap().typ(db.upcast()) { - resolved_generics.insert(generic, provided_type); - } + params.push(make_param(db, param.clone().name, param_type, source)) } let return_type = db.mir_lowered_type(analyzer_signature.return_type.clone().unwrap()); @@ -216,26 +209,6 @@ impl<'db, 'a> BodyLowerHelper<'db, 'a> { self.builder.move_to_block(then_bb); } - ast::FuncStmt::Emit { args, .. } => { - let event_id = self.analyzer_body.emits[&stmt.id]; - let event_type = self.db.mir_lowered_event_type(event_id); - // NOTE: Event arguments are guaranteed to be in the same order with - // the definition. - let lowered_args = args - .kind - .iter() - .map(|arg| self.lower_expr_to_value(&arg.kind.value)) - .collect(); - - let event = Local::tmp_local("$event".into(), event_type); - let event = self.builder.declare(event); - let inst = self - .builder - .aggregate_construct(event_type, lowered_args, args.into()); - self.builder.map_result(inst, event.into()); - self.builder.emit(event, stmt.into()); - } - ast::FuncStmt::Expr { value } => { self.lower_expr_to_value(value); } @@ -586,7 +559,7 @@ impl<'db, 'a> BodyLowerHelper<'db, 'a> { .func .signature(self.db) .resolved_generics - .get(&generic) + .get(&generic.name) .cloned() .expect("expected generic to be resolved"); @@ -898,6 +871,31 @@ impl<'db, 'a> BodyLowerHelper<'db, 'a> { } } + fn resolve_generics_args( + &mut self, + method: &analyzer_items::FunctionId, + args: &[Id], + ) -> BTreeMap { + method + .signature(self.db.upcast()) + .params + .iter() + .zip(args.iter().map(|val| { + self.builder + .value_ty(*val) + .analyzer_ty(self.db) + .expect("invalid parameter") + })) + .filter_map(|(param, typ)| { + if let Type::Generic(generic) = param.typ.clone().unwrap().typ(self.db.upcast()) { + Some((generic.name, typ)) + } else { + None + } + }) + .collect::>() + } + fn lower_call( &mut self, func: &Node, @@ -946,21 +944,14 @@ impl<'db, 'a> BodyLowerHelper<'db, 'a> { } AnalyzerCallType::ValueMethod { method, .. } => { + let resolved_generics = self.resolve_generics_args(method, &args); + let mut method_args = vec![self.lower_method_receiver(func)]; method_args.append(&mut args); let func_id = if method.is_generic(self.db.upcast()) { - let concrete_args = method_args - .iter() - .map(|val| { - self.builder - .value_ty(*val) - .analyzer_ty(self.db) - .expect("invalid parameter") - }) - .collect::>(); self.db - .mir_lowered_monomorphized_func_signature(*method, concrete_args) + .mir_lowered_monomorphized_func_signature(*method, resolved_generics) } else { self.db.mir_lowered_func_signature(*method) }; @@ -968,6 +959,14 @@ impl<'db, 'a> BodyLowerHelper<'db, 'a> { self.builder .call(func_id, method_args, CallType::Internal, source) } + AnalyzerCallType::TraitValueMethod { + trait_id, method, .. + } if trait_id.is_std_trait(self.db.upcast(), EMITTABLE_TRAIT_NAME) + && method.name(self.db.upcast()) == EMIT_FN_NAME => + { + let event = self.lower_method_receiver(func); + self.builder.emit(event, source) + } AnalyzerCallType::TraitValueMethod { method, trait_id, @@ -981,7 +980,7 @@ impl<'db, 'a> BodyLowerHelper<'db, 'a> { .func .signature(self.db) .resolved_generics - .get(generic_type) + .get(&generic_type.name) .cloned() .expect("unresolved generic type"); diff --git a/crates/mir/src/lower/types.rs b/crates/mir/src/lower/types.rs index cd2e03108b..8a2abbc1cb 100644 --- a/crates/mir/src/lower/types.rs +++ b/crates/mir/src/lower/types.rs @@ -1,7 +1,7 @@ use crate::{ db::MirDb, ir::{ - types::{ArrayDef, EnumDef, EnumVariant, EventDef, MapDef, StructDef, TupleDef}, + types::{ArrayDef, EnumDef, EnumVariant, MapDef, StructDef, TupleDef}, Type, TypeId, TypeKind, }, }; @@ -27,35 +27,6 @@ pub fn lower_type(db: &dyn MirDb, analyzer_ty: &analyzer_types::TypeId) -> TypeI intern_type(db, ty_kind, Some(*analyzer_ty)) } -pub fn lower_event_type(db: &dyn MirDb, event: analyzer_items::EventId) -> TypeId { - let name = event.name(db.upcast()); - - let analyzer_ty = event.typ(db.upcast()); - // Lower event fields. - let fields = analyzer_ty - .fields - .iter() - .map(|field| { - let ty = db.mir_lowered_type(field.typ.clone().unwrap()); - (field.name.clone(), ty, field.is_indexed) - }) - .collect(); - - // Obtain span. - let span = event.span(db.upcast()); - - let module_id = event.module(db.upcast()); - - let def = EventDef { - name, - fields, - span, - module_id, - }; - let ty = TypeKind::Event(def); - intern_type(db, ty, None) -} - fn lower_base(base: &analyzer_types::Base) -> TypeKind { use analyzer_types::{Base, Integer}; diff --git a/crates/mir/src/pretty_print/types.rs b/crates/mir/src/pretty_print/types.rs index 9093a1a229..75d0d296d2 100644 --- a/crates/mir/src/pretty_print/types.rs +++ b/crates/mir/src/pretty_print/types.rs @@ -60,9 +60,6 @@ impl PrettyPrint for TypeId { TypeKind::Enum(def) => { write!(w, "{}", def.name) } - TypeKind::Event(def) => { - write!(w, "{}", def.name) - } TypeKind::Contract(def) => { write!(w, "{}", def.name) } diff --git a/crates/parser/src/ast.rs b/crates/parser/src/ast.rs index 987a0193a3..68fa7ba5b5 100644 --- a/crates/parser/src/ast.rs +++ b/crates/parser/src/ast.rs @@ -25,7 +25,6 @@ pub enum ModuleStmt { Trait(Node), Impl(Node), Function(Node), - Event(Node), ParseError(Span), } @@ -184,6 +183,7 @@ impl Spanned for GenericParameter { pub struct Field { pub is_pub: bool, pub is_const: bool, + pub attributes: Vec>, pub name: Node, pub typ: Node, pub value: Option>, @@ -225,17 +225,9 @@ pub enum VariantKind { #[allow(clippy::large_enum_variant)] #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)] pub enum ContractStmt { - Event(Node), Function(Node), } -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)] -pub struct Event { - pub name: Node, - pub fields: Vec>, - pub pub_qual: Option, -} - #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)] pub struct FunctionSignature { // qualifier order: `pub unsafe fn` @@ -253,13 +245,6 @@ pub struct Function { pub body: Vec>, } -#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)] -pub struct EventField { - pub is_idx: bool, - pub name: Node, - pub typ: Node, -} - #[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone)] pub struct RegularFunctionArg { pub label: Option>, @@ -343,10 +328,6 @@ pub enum FuncStmt { test: Node, msg: Option>, }, - Emit { - name: Node, - args: Node>>, - }, Expr { value: Node, }, @@ -530,12 +511,6 @@ impl Node { } } -impl Node { - pub fn name(&self) -> &str { - &self.kind.name.kind - } -} - impl Node { pub fn name(&self) -> &str { &self.kind.name.kind @@ -583,7 +558,6 @@ impl Spanned for ModuleStmt { ModuleStmt::Struct(inner) => inner.span, ModuleStmt::Enum(inner) => inner.span, ModuleStmt::Function(inner) => inner.span, - ModuleStmt::Event(inner) => inner.span, ModuleStmt::ParseError(span) => *span, } } @@ -592,7 +566,6 @@ impl Spanned for ModuleStmt { impl Spanned for ContractStmt { fn span(&self) -> Span { match self { - ContractStmt::Event(inner) => inner.span, ContractStmt::Function(inner) => inner.span, } } @@ -632,7 +605,6 @@ impl fmt::Display for ModuleStmt { ModuleStmt::Struct(node) => write!(f, "{}", node.kind), ModuleStmt::Enum(node) => write!(f, "{}", node.kind), ModuleStmt::Function(node) => write!(f, "{}", node.kind), - ModuleStmt::Event(node) => write!(f, "{}", node.kind), ModuleStmt::ParseError(span) => { write!(f, "# PARSE ERROR: {}..{}", span.start, span.end) } @@ -880,25 +852,11 @@ impl fmt::Display for Variant { impl fmt::Display for ContractStmt { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { - ContractStmt::Event(node) => write!(f, "{}", node.kind), ContractStmt::Function(node) => write!(f, "{}", node.kind), } } } -impl fmt::Display for Event { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - write!(f, "event {} ", self.name.kind)?; - if self.fields.is_empty() { - write!(f, "{{}}") - } else { - writeln!(f, "{{")?; - writeln!(indented(f), "{}", node_line_joined(&self.fields))?; - write!(f, "}}") - } - } -} - impl fmt::Display for Node { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { self.kind.fmt(f) @@ -937,15 +895,6 @@ impl fmt::Display for Function { } } -impl fmt::Display for EventField { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { - if self.is_idx { - write!(f, "idx ")?; - } - write!(f, "{}: {}", self.name.kind, self.typ.kind) - } -} - impl fmt::Display for RegularFunctionArg { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { if let Some(label) = &self.label { @@ -1041,9 +990,6 @@ impl fmt::Display for FuncStmt { write!(f, "assert {}", test.kind) } } - FuncStmt::Emit { name, args } => { - write!(f, "emit {}({})", name.kind, node_comma_joined(&args.kind)) - } FuncStmt::Expr { value } => write!(f, "{}", value.kind), FuncStmt::Break => write!(f, "break"), FuncStmt::Continue => write!(f, "continue"), @@ -1286,18 +1232,6 @@ fn write_nodes_line_wrapped(f: &mut impl Write, nodes: &[Node Ok(()) } -fn node_line_joined(nodes: &[Node]) -> String { - line_joined(&nodes.iter().map(|node| &node.kind).collect::>()) -} - -fn line_joined(items: &[impl fmt::Display]) -> String { - items - .iter() - .map(|item| format!("{}", item)) - .collect::>() - .join("\n") -} - fn double_line_joined(items: &[impl fmt::Display]) -> String { items .iter() diff --git a/crates/parser/src/grammar/Fe.grammar b/crates/parser/src/grammar/Fe.grammar index 9d8d931b7c..d11f5f8aaa 100644 --- a/crates/parser/src/grammar/Fe.grammar +++ b/crates/parser/src/grammar/Fe.grammar @@ -25,12 +25,9 @@ type_def: 'type' NAME '=' type_desc NEWLINE ########################### contract_def ############################# contract_def: 'contract' NAME '{' contract_stmt* '}' -contract_stmt: contract_field | event_def | func_def +contract_stmt: contract_field | func_def contract_field: [contract_field_qual] NAME ':' type_desc NEWLINE -event_def: 'event' NAME '{' event_field* '}' -event_field: [event_field_qual] NAME ':' type_desc NEWLINE - func_def: [func_qual] 'fn' NAME '(' [arg_list] ')' ['->' base_type] ':' block arg_list: arg_def (',' arg_def)* [','] @@ -45,7 +42,6 @@ base_type: NAME arr_list arr_list: ('[' NUMBER ']')* contract_field_qual: 'const' | 'pub' -event_field_qual: 'idx' func_qual: 'pub' ########################### func_stmt ############################### diff --git a/crates/parser/src/grammar/contracts.rs b/crates/parser/src/grammar/contracts.rs index 5841c6c949..ed234aab57 100644 --- a/crates/parser/src/grammar/contracts.rs +++ b/crates/parser/src/grammar/contracts.rs @@ -1,5 +1,5 @@ use super::functions::parse_fn_def; -use super::types::{parse_event_def, parse_field, parse_opt_qualifier}; +use super::types::{parse_field, parse_opt_qualifier}; use crate::ast::{Contract, ContractStmt}; use crate::node::{Node, Span}; @@ -45,9 +45,12 @@ pub fn parse_contract_def( match par.peek_or_err()? { TokenKind::Name => { - let field = parse_field(par, pub_qual, const_qual)?; + let field = parse_field(par, vec![], pub_qual, const_qual)?; if !defs.is_empty() { - par.error(field.span, "contract field definitions must come before any function or event definitions"); + par.error( + field.span, + "contract field definitions must come before any function definitions", + ); } fields.push(field); } @@ -60,21 +63,6 @@ pub fn parse_contract_def( } defs.push(ContractStmt::Function(parse_fn_def(par, pub_qual)?)); } - TokenKind::Event => { - if let Some(span) = pub_qual { - par.error( - span, - "`pub` qualifier can't be used with contract-level event definitions", - ); - } - if let Some(span) = const_qual { - par.error( - span, - "`const` qualifier can't be used with event definitions", - ); - } - defs.push(ContractStmt::Event(parse_event_def(par, None)?)); - } TokenKind::BraceClose => { span += par.next()?.span; break; diff --git a/crates/parser/src/grammar/functions.rs b/crates/parser/src/grammar/functions.rs index 163e57f10c..5b17deb6c5 100644 --- a/crates/parser/src/grammar/functions.rs +++ b/crates/parser/src/grammar/functions.rs @@ -1,4 +1,4 @@ -use super::expressions::{parse_call_args, parse_expr}; +use super::expressions::parse_expr; use super::types::parse_type_desc; use crate::ast::{ @@ -335,7 +335,6 @@ pub fn parse_stmt(par: &mut Parser) -> ParseResult> { Assert => parse_assert_stmt(par), Revert => parse_revert_stmt(par), Continue | Break => parse_single_word_stmt(par), - Emit => parse_emit_statement(par), Let => parse_var_decl(par), Const => parse_const_decl(par), Unsafe => parse_unsafe_block(par), @@ -687,35 +686,6 @@ pub fn parse_revert_stmt(par: &mut Parser) -> ParseResult> { Ok(Node::new(FuncStmt::Revert { error }, span)) } -/// Parse an `emit` statement -/// -/// # Panics -/// Panics if the next token isn't `emit` -pub fn parse_emit_statement(par: &mut Parser) -> ParseResult> { - let emit_tok = par.assert(TokenKind::Emit); - let event_name = par.expect(TokenKind::Name, "failed to parse emit statement")?; - - if let Some(TokenKind::ParenOpen) = par.peek() { - let args = parse_call_args(par)?; - par.expect_stmt_end("emit statement")?; - let span = emit_tok.span + args.span; - return Ok(Node::new( - FuncStmt::Emit { - name: event_name.into(), - args, - }, - span, - )); - } else { - par.expect( - TokenKind::ParenOpen, - "failed to parse event invocation parameter list", - )?; - } - - Err(ParseFailed) -} - /// Parse an `unsafe` block. /// /// # Panics diff --git a/crates/parser/src/grammar/module.rs b/crates/parser/src/grammar/module.rs index 7d77d7551f..f57ba1ec3d 100644 --- a/crates/parser/src/grammar/module.rs +++ b/crates/parser/src/grammar/module.rs @@ -1,8 +1,8 @@ use super::expressions::parse_expr; use super::functions::parse_fn_def; use super::types::{ - parse_event_def, parse_impl_def, parse_path_tail, parse_struct_def, parse_trait_def, - parse_type_alias, parse_type_desc, + parse_impl_def, parse_path_tail, parse_struct_def, parse_trait_def, parse_type_alias, + parse_type_desc, }; use super::{contracts::parse_contract_def, types::parse_enum_def}; use crate::ast::{ConstantDecl, Module, ModuleStmt, Pragma, Use, UseTree}; @@ -48,12 +48,9 @@ pub fn parse_module_stmt(par: &mut Parser) -> ParseResult { TokenKind::Impl => ModuleStmt::Impl(parse_impl_def(par)?), TokenKind::Type => ModuleStmt::TypeAlias(parse_type_alias(par, None)?), TokenKind::Const => ModuleStmt::Constant(parse_constant(par, None)?), - - TokenKind::Event => ModuleStmt::Event(parse_event_def(par, None)?), TokenKind::Pub => { let pub_span = par.next()?.span; match par.peek_or_err()? { - TokenKind::Event => ModuleStmt::Event(parse_event_def(par, Some(pub_span))?), TokenKind::Fn | TokenKind::Unsafe => { ModuleStmt::Function(parse_fn_def(par, Some(pub_span))?) } @@ -82,7 +79,7 @@ pub fn parse_module_stmt(par: &mut Parser) -> ParseResult { par.unexpected_token_error( &tok, "failed to parse module", - vec!["Note: expected import, contract, struct, type, const or event".into()], + vec!["Note: expected import, contract, struct, type or const".into()], ); return Err(ParseFailed); } diff --git a/crates/parser/src/grammar/types.rs b/crates/parser/src/grammar/types.rs index 73a3f667c7..33fa0aa9f4 100644 --- a/crates/parser/src/grammar/types.rs +++ b/crates/parser/src/grammar/types.rs @@ -1,6 +1,5 @@ use crate::ast::{ - self, Enum, EventField, Field, GenericArg, Impl, Path, Trait, TypeAlias, TypeDesc, Variant, - VariantKind, + self, Enum, Field, GenericArg, Impl, Path, Trait, TypeAlias, TypeDesc, Variant, VariantKind, }; use crate::grammar::expressions::parse_expr; use crate::grammar::functions::{parse_fn_def, parse_fn_sig}; @@ -31,10 +30,22 @@ pub fn parse_struct_def( loop { par.eat_newlines(); + + let attributes = if let Some(attr) = par.optional(TokenKind::Hash) { + let attr_name = par.expect_with_notes(TokenKind::Name, "failed to parse attribute definition", |_| + vec!["Note: an attribute name must start with a letter or underscore, and contain letters, numbers, or underscores".into()])?; + // This hints to a future where we would support multiple attributes per field. For now we don't need it. + vec![Node::new(attr_name.text.into(), attr.span + attr_name.span)] + } else { + vec![] + }; + + par.eat_newlines(); + let pub_qual = par.optional(TokenKind::Pub).map(|tok| tok.span); match par.peek_or_err()? { TokenKind::Name => { - let field = parse_field(par, pub_qual, None)?; + let field = parse_field(par, attributes, pub_qual, None)?; if !functions.is_empty() { par.error( field.span, @@ -275,77 +286,11 @@ pub fn parse_type_alias(par: &mut Parser, pub_qual: Option) -> ParseResult )) } -/// Parse an event definition. -/// # Panics -/// Panics if the next token isn't `event`. -pub fn parse_event_def(par: &mut Parser, pub_qual: Option) -> ParseResult> { - use TokenKind::*; - - let event_tok = par.assert(Event); - let name = par.expect(Name, "failed to parse event definition")?; - par.enter_block(event_tok.span + name.span, "event definition")?; - - let mut span = event_tok.span; - let mut fields = vec![]; - loop { - match par.peek_or_err()? { - Name | Idx => { - fields.push(parse_event_field(par)?); - } - BraceClose => { - span += par.next()?.span; - break; - } - _ => { - let tok = par.next()?; - par.unexpected_token_error(&tok, "failed to parse event definition", vec![]); - return Err(ParseFailed); - } - } - } - Ok(Node::new( - ast::Event { - name: name.into(), - fields, - pub_qual, - }, - span, - )) -} - -/// Parse an event field, e.g. `foo: u8` or `idx from: address`. -pub fn parse_event_field(par: &mut Parser) -> ParseResult> { - let idx_qual = parse_opt_qualifier(par, TokenKind::Idx); - let name = par.expect(TokenKind::Name, "failed to parse event field")?; - par.expect_with_notes(TokenKind::Colon, "failed to parse event field", |_| { - vec![ - "Note: event field name must be followed by a colon and a type description".into(), - format!( - "Example: `{}{}: address`", - if idx_qual.is_some() { "idx " } else { "" }, - name.text - ), - ] - })?; - - let typ = parse_type_desc(par)?; - par.expect_stmt_end("event field")?; - let span = name.span + idx_qual + &typ; - Ok(Node::new( - EventField { - is_idx: idx_qual.is_some(), - name: name.into(), - typ, - }, - span, - )) -} - /// Parse a field for a struct or contract. The leading optional `pub` and /// `const` qualifiers must be parsed by the caller, and passed in. -/// Note that `event` fields are handled in [`parse_event_field`]. pub fn parse_field( par: &mut Parser, + attributes: Vec>, pub_qual: Option, const_qual: Option, ) -> ParseResult> { @@ -388,6 +333,7 @@ pub fn parse_field( Field { is_pub: pub_qual.is_some(), is_const: const_qual.is_some(), + attributes, name: name.into(), typ, value, diff --git a/crates/parser/src/lexer/token.rs b/crates/parser/src/lexer/token.rs index 30344e9e32..4aa399b674 100644 --- a/crates/parser/src/lexer/token.rs +++ b/crates/parser/src/lexer/token.rs @@ -71,10 +71,6 @@ pub enum TokenKind { Const, #[token("else")] Else, - #[token("emit")] - Emit, - #[token("event")] - Event, #[token("idx")] Idx, #[token("if")] @@ -141,6 +137,8 @@ pub enum TokenKind { ColonColon, #[token(",")] Comma, + #[token("#")] + Hash, #[token(";")] Semi, #[token("+")] @@ -238,8 +236,6 @@ impl TokenKind { Const => "keyword `const`", Let => "keyword `let`", Else => "keyword `else`", - Emit => "keyword `emit`", - Event => "keyword `event`", Idx => "keyword `idx`", If => "keyword `if`", Match => "keyword `match`", @@ -271,6 +267,7 @@ impl TokenKind { Colon => "symbol `:`", ColonColon => "symbol `::`", Comma => "symbol `,`", + Hash => "symbol `#`", Semi => "symbol `;`", Plus => "symbol `+`", Minus => "symbol `-`", diff --git a/crates/parser/tests/cases/errors.rs b/crates/parser/tests/cases/errors.rs index ebeb74abdb..aa38a26aaa 100644 --- a/crates/parser/tests/cases/errors.rs +++ b/crates/parser/tests/cases/errors.rs @@ -66,13 +66,8 @@ contract C { } test_parse_err! { type_desc_path_number, module::parse_module, "type Foo = some::mod::Foo::5000" } -test_parse_err! { module_pub_event, module::parse_module, "pub event E{\n x: u8}" } -test_parse_err! { contract_pub_event, module::parse_module, "contract C {\n pub event E{\n x: u8 \n}}" } test_parse_err! { contract_const_pub, module::parse_module, "contract C {\n const pub x: u8\n}" } test_parse_err! { contract_const_fn, module::parse_module, "contract C {\n const fn f() {}\n}" } -test_parse_err! { emit_no_args, functions::parse_stmt, "emit x" } -test_parse_err! { emit_expr, functions::parse_stmt, "emit x + 1" } -test_parse_err! { emit_bad_call, functions::parse_stmt, "emit MyEvent(1)()" } test_parse_err! { expr_bad_prefix, expressions::parse_expr, "*x + 1" } test_parse_err! { expr_path_left, expressions::parse_expr, "(1 + 2)::foo::bar" } test_parse_err! { expr_path_right, expressions::parse_expr, "foo::10::bar" } @@ -88,7 +83,7 @@ test_parse_err! { fn_invalid_bound, module::parse_module, "pub fn f( test_parse_err! { use_bad_name, module::parse_use, "use x as 123" } test_parse_err! { module_bad_stmt, module::parse_module, "if x { y }" } test_parse_err! { module_nonsense, module::parse_module, "))" } -test_parse_err! { struct_bad_field_name, module::parse_module, "struct f {\n pub event }" } +test_parse_err! { struct_bad_field_name, module::parse_module, "struct f {\n pub type }" } test_parse_err! { stmt_vardecl_attr, functions::parse_stmt, "f.s : u" } test_parse_err! { stmt_vardecl_tuple, functions::parse_stmt, "(a, x+1) : u256" } test_parse_err! { stmt_vardecl_tuple_empty, functions::parse_stmt, "(a, ()) : u256" } diff --git a/crates/parser/tests/cases/parse_ast.rs b/crates/parser/tests/cases/parse_ast.rs index d641f6790d..103a508b7e 100644 --- a/crates/parser/tests/cases/parse_ast.rs +++ b/crates/parser/tests/cases/parse_ast.rs @@ -114,8 +114,6 @@ test_parse! { stmt_aug_xor, functions::parse_stmt, "x ^= y" } test_parse! { stmt_aug_lsh, functions::parse_stmt, "x <<= y" } test_parse! { stmt_aug_rsh, functions::parse_stmt, "x >>= y" } test_parse! { stmt_aug_exp, functions::parse_stmt, "x **= y" } -test_parse! { stmt_emit1, functions::parse_stmt, "emit Foo()" } -test_parse! { stmt_emit2, functions::parse_stmt, "emit Foo(1, 2, x: y)" } test_parse! { stmt_path_type, functions::parse_stmt, "let x: foo::Bar = foo::Bar(1, 2)" } test_parse! { stmt_return1, functions::parse_stmt, "return" } test_parse! { stmt_return2, functions::parse_stmt, "return x" } @@ -172,9 +170,6 @@ test_parse! { fn_def_generic, try_parse_module, "fn foo(this: T, th test_parse! { fn_def_pub, try_parse_module, "pub fn foo21(x: bool, y: address,) -> bool { x }"} test_parse! { fn_def_unsafe, try_parse_module, "unsafe fn foo21(x: bool, y: address,) -> bool {\n x\n}"} test_parse! { fn_def_pub_unsafe, try_parse_module, "pub unsafe fn foo21(x: bool, y: address,) -> bool{x}"} -test_parse! { event_def, try_parse_module, "event Foo {\n x: address\n idx y: u8\n}" } -test_parse! { empty_event_def, try_parse_module, "event Foo {}" } -test_parse! { pub_event_def, try_parse_module, "pub event Foo {\nx: address\nidx y: u8\n}" } test_parse! { const_def, try_parse_module, "const FOO: i32 = 1" } test_parse! { pub_const_def, try_parse_module, "pub const FOO: i32 = 1" } test_parse! { pragma1, module::parse_pragma, "pragma 0.1.0" } @@ -192,6 +187,7 @@ test_parse! { use_nested2, module::parse_use, r#"use std::bar::{ }"# } test_parse! { struct_def, try_parse_module, r#"struct S { + #indexed x: address pub y: u8 z: u8 @@ -220,9 +216,6 @@ test_parse! { contract_def, try_parse_module, r#"contract Foo { pub fn foo() -> u8 { return 10 } - event Bar { - idx from: address - } } "# } @@ -262,17 +255,18 @@ contract B { test_parse! { guest_book, try_parse_module, r#" type BookMsg = Array +struct Signed { + #indexed + book_msg: BookMsg +} + contract GuestBook { pub guest_book: Map - event Signed { - idx book_msg: BookMsg - } - pub fn sign(self, book_msg: BookMsg) { self.guest_book[msg.sender] = book_msg - emit Signed(book_msg: book_msg) + ctx.emit(Signed(book_msg: book_msg)) } pub fn get_msg(self, addr: address) -> BookMsg { return self.guest_book[addr] @@ -280,14 +274,16 @@ contract GuestBook { }"# } test_parse! { module_level_events, try_parse_module, r#" -event Transfer { - idx sender: address - idx receiver: address +struct Transfer { + #indexed + sender: address + #indexed + receiver: address value: u256 } contract Foo { fn transfer(ctx: Context, to: address, value: u256) { - emit Transfer(ctx, sender: msg.sender, receiver: to, value) + ctx.emit(Transfer(sender: msg.sender, receiver: to, value)) } } "# } diff --git a/crates/parser/tests/cases/snapshots/cases__errors__array_old_syntax.snap b/crates/parser/tests/cases/snapshots/cases__errors__array_old_syntax.snap index b62ab9fc5f..dcd62511ce 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__array_old_syntax.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__array_old_syntax.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(array_old_syntax), functions::parse_stmt, false,\n \"let x: u8[10]\")" +expression: "err_string(stringify!(array_old_syntax), functions::parse_stmt,\n \"let x: u8[10]\")" --- error: Outdated array syntax diff --git a/crates/parser/tests/cases/snapshots/cases__errors__array_old_syntax_invalid.snap b/crates/parser/tests/cases/snapshots/cases__errors__array_old_syntax_invalid.snap index 21590011df..91bc344611 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__array_old_syntax_invalid.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__array_old_syntax_invalid.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(array_old_syntax_invalid), functions::parse_stmt, true,\n \"let x: u8[10\")" +expression: "err_string(stringify!(array_old_syntax_invalid), functions::parse_stmt,\n \"let x: u8[10\")" --- error: Unexpected token while parsing type description diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_bad_name.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_bad_name.snap index 701fab48ce..5a6f1290e5 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_bad_name.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_bad_name.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_bad_name), module::parse_module,\n \"contract 1X {\\n x: u8 \\n}\")" +expression: "err_string(stringify!(contract_bad_name), module::parse_module,\n \"contract 1X {\\n x: u8 \\n}\")" --- error: failed to parse contract definition diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_const_fn.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_const_fn.snap index 7e5b3c3bf4..488045f2cb 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_const_fn.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_const_fn.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_const_fn), module::parse_module,\n \"contract C {\\n const fn f() {}\\n}\")" +expression: "err_string(stringify!(contract_const_fn), module::parse_module,\n \"contract C {\\n const fn f() {}\\n}\")" --- error: `const` qualifier can't be used with function definitions diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_const_pub.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_const_pub.snap index 201d462758..8da4de01f9 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_const_pub.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_const_pub.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_const_pub), contracts::parse_contract_def,\n false, \"contract C:\\n const pub x: u8\")" +expression: "err_string(stringify!(contract_const_pub), module::parse_module,\n \"contract C {\\n const pub x: u8\\n}\")" --- error: `const pub` should be written `pub const` diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_empty_body.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_empty_body.snap deleted file mode 100644 index a8ab66646a..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_empty_body.snap +++ /dev/null @@ -1,6 +0,0 @@ ---- -source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_empty_body), module::parse_module,\n \"contract X {} \\ncontract Y {\\n x: u8 \\n}\")" - ---- - diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_field_after_def.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_field_after_def.snap index 0fe3d767d9..9125c01f58 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_field_after_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_field_after_def.snap @@ -1,9 +1,9 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_field_after_def), module::parse_module,\n r#\"\ncontract C {\n fn f() {}\n x: u8\n}\"#)" +expression: "err_string(stringify!(contract_field_after_def), module::parse_module,\n r#\"\ncontract C {\n fn f() {}\n x: u8\n}\"#)" --- -error: contract field definitions must come before any function or event definitions +error: contract field definitions must come before any function definitions ┌─ contract_field_after_def:4:3 │ 4 │ x: u8 diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_invalid_version_requirement.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_invalid_version_requirement.snap index 9038bb5058..0c28af95dc 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_invalid_version_requirement.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_invalid_version_requirement.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_invalid_version_requirement),\n module::parse_module, true, r#\"\npragma 0.o\ncontract C:\n pass\n\"#)" +expression: "err_string(stringify!(contract_invalid_version_requirement),\n module::parse_module, r#\"\npragma 0.o\ncontract C {}\"#)" --- error: failed to parse pragma statement: unexpected character 'o' while parsing minor version number diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_missing_version_requirement.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_missing_version_requirement.snap index 1bf821c62b..0ac6693cfc 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_missing_version_requirement.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__contract_missing_version_requirement.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_missing_version_requirement),\n module::parse_module, true, r#\"\npragma\ncontract C:\n pass\n\"#)" +expression: "err_string(stringify!(contract_missing_version_requirement),\n module::parse_module, r#\"\npragma\ncontract C {}\n\"#)" --- error: failed to parse pragma statement: missing version requirement diff --git a/crates/parser/tests/cases/snapshots/cases__errors__contract_pub_event.snap b/crates/parser/tests/cases/snapshots/cases__errors__contract_pub_event.snap deleted file mode 100644 index 4f756465b5..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__errors__contract_pub_event.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(contract_pub_event), module::parse_module,\n \"contract C {\\n pub event E{\\n x: u8 \\n}}\")" - ---- -error: `pub` qualifier can't be used with contract-level event definitions - ┌─ contract_pub_event:2:2 - │ -2 │ pub event E{ - │ ^^^ - - diff --git a/crates/parser/tests/cases/snapshots/cases__errors__emit_bad_call.snap b/crates/parser/tests/cases/snapshots/cases__errors__emit_bad_call.snap deleted file mode 100644 index 162aac79d5..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__errors__emit_bad_call.snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(emit_bad_call), functions::parse_stmt,\n \"emit MyEvent(1)()\")" - ---- -error: unexpected token while parsing emit statement - ┌─ emit_bad_call:1:16 - │ -1 │ emit MyEvent(1)() - │ ^ unexpected token - │ - = expected a newline; found symbol `(` instead - - diff --git a/crates/parser/tests/cases/snapshots/cases__errors__emit_expr.snap b/crates/parser/tests/cases/snapshots/cases__errors__emit_expr.snap deleted file mode 100644 index 5f0f4d00e4..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__errors__emit_expr.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(emit_expr), functions::parse_stmt, true, \"emit x + 1\")" - ---- -error: failed to parse event invocation parameter list - ┌─ emit_expr:1:8 - │ -1 │ emit x + 1 - │ ^ expected symbol `(`, found symbol `+` - - diff --git a/crates/parser/tests/cases/snapshots/cases__errors__emit_no_args.snap b/crates/parser/tests/cases/snapshots/cases__errors__emit_no_args.snap deleted file mode 100644 index 855ae81e75..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__errors__emit_no_args.snap +++ /dev/null @@ -1,12 +0,0 @@ ---- -source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(emit_no_args), functions::parse_stmt, true, \"emit x\")" - ---- -error: unexpected end of file - ┌─ emit_no_args:1:7 - │ -1 │ emit x - │ ^ - - diff --git a/crates/parser/tests/cases/snapshots/cases__errors__expr_assignment.snap b/crates/parser/tests/cases/snapshots/cases__errors__expr_assignment.snap index bcfde190c6..d93747d464 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__expr_assignment.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__expr_assignment.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(expr_assignment), expressions::parse_expr,\n \"1 + (x = y)\")" +expression: "err_string(stringify!(expr_assignment), expressions::parse_expr,\n \"1 + (x = y)\")" --- error: Unexpected token while parsing expression in parentheses diff --git a/crates/parser/tests/cases/snapshots/cases__errors__expr_bad_prefix.snap b/crates/parser/tests/cases/snapshots/cases__errors__expr_bad_prefix.snap index 140809fa1c..ed4a3eba33 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__expr_bad_prefix.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__expr_bad_prefix.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(expr_bad_prefix), expressions::parse_expr, true,\n \"*x + 1\")" +expression: "err_string(stringify!(expr_bad_prefix), expressions::parse_expr, \"*x + 1\")" --- error: Unexpected token while parsing expression: `*` diff --git a/crates/parser/tests/cases/snapshots/cases__errors__expr_call_eq_label.snap b/crates/parser/tests/cases/snapshots/cases__errors__expr_call_eq_label.snap index b5351c7817..50ac6989e4 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__expr_call_eq_label.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__expr_call_eq_label.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(expr_call_eq_label), expressions::parse_expr,\n \"foo(bar=1, baz = 2)\")" +expression: "err_string(stringify!(expr_call_eq_label), expressions::parse_expr,\n \"foo(bar=1, baz = 2)\")" --- error: Syntax error in argument list diff --git a/crates/parser/tests/cases/snapshots/cases__errors__expr_dotted_number.snap b/crates/parser/tests/cases/snapshots/cases__errors__expr_dotted_number.snap index de0d770f4b..aafeb1cd74 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__expr_dotted_number.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__expr_dotted_number.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(expr_dotted_number), expressions::parse_expr, true,\n \"3.14\")" +expression: "err_string(stringify!(expr_dotted_number), expressions::parse_expr, \"3.14\")" --- error: floats not supported diff --git a/crates/parser/tests/cases/snapshots/cases__errors__expr_path_left.snap b/crates/parser/tests/cases/snapshots/cases__errors__expr_path_left.snap index 331c396d6b..15e9037fad 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__expr_path_left.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__expr_path_left.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(expr_path_left), expressions::parse_expr, true,\n \"(1 + 2)::foo::bar\")" +expression: "err_string(stringify!(expr_path_left), expressions::parse_expr,\n \"(1 + 2)::foo::bar\")" --- error: failed to parse path expression diff --git a/crates/parser/tests/cases/snapshots/cases__errors__expr_path_right.snap b/crates/parser/tests/cases/snapshots/cases__errors__expr_path_right.snap index 7a73d9c8aa..d96cc4ba41 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__expr_path_right.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__expr_path_right.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(expr_path_right), expressions::parse_expr, true,\n \"foo::10::bar\")" +expression: "err_string(stringify!(expr_path_right), expressions::parse_expr,\n \"foo::10::bar\")" --- error: failed to parse path expression diff --git a/crates/parser/tests/cases/snapshots/cases__errors__fn_def_kw.snap b/crates/parser/tests/cases/snapshots/cases__errors__fn_def_kw.snap index 5aed9e3fea..6e3744e580 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__fn_def_kw.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__fn_def_kw.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(fn_def_kw), module::parse_module,\n \"contract C {\\n pub def f(x: u8){\\n return x \\n}\\n}\")" +expression: "err_string(stringify!(fn_def_kw), module::parse_module,\n \"contract C {\\n pub def f(x: u8){\\n return x \\n}\\n}\")" --- error: failed to parse field definition diff --git a/crates/parser/tests/cases/snapshots/cases__errors__fn_no_args.snap b/crates/parser/tests/cases/snapshots/cases__errors__fn_no_args.snap index c3ea8fe4c0..a2790dafcc 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__fn_no_args.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__fn_no_args.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(fn_no_args), module::parse_module,\n \"fn f {\\n return 5\\n}\")" +expression: "err_string(stringify!(fn_no_args), module::parse_module,\n \"fn f {\\n return 5\\n}\")" --- error: function definition requires a list of parameters diff --git a/crates/parser/tests/cases/snapshots/cases__errors__fn_unsafe_pub.snap b/crates/parser/tests/cases/snapshots/cases__errors__fn_unsafe_pub.snap index 5b60da1b8a..b59c85f4db 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__fn_unsafe_pub.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__fn_unsafe_pub.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(fn_unsafe_pub), module::parse_module,\n \"unsafe pub fn f() {\\n return 5 }\")" +expression: "err_string(stringify!(fn_unsafe_pub), module::parse_module,\n \"unsafe pub fn f() {\\n return 5 }\")" --- error: `pub` visibility modifier must come before `unsafe` diff --git a/crates/parser/tests/cases/snapshots/cases__errors__if_no_body.snap b/crates/parser/tests/cases/snapshots/cases__errors__if_no_body.snap deleted file mode 100644 index 5231063b3e..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__errors__if_no_body.snap +++ /dev/null @@ -1,6 +0,0 @@ ---- -source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(if_no_body), functions::parse_stmt,\n \"if x {} else { x }\")" - ---- - diff --git a/crates/parser/tests/cases/snapshots/cases__errors__module_bad_stmt.snap b/crates/parser/tests/cases/snapshots/cases__errors__module_bad_stmt.snap index a0ae7cec6e..b871e37067 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__module_bad_stmt.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__module_bad_stmt.snap @@ -9,6 +9,6 @@ error: failed to parse module 1 │ if x { y } │ ^^ unexpected token │ - = Note: expected import, contract, struct, type, const or event + = Note: expected import, contract, struct, type or const diff --git a/crates/parser/tests/cases/snapshots/cases__errors__module_nonsense.snap b/crates/parser/tests/cases/snapshots/cases__errors__module_nonsense.snap index 1ac7b8ae48..f93763d091 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__module_nonsense.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__module_nonsense.snap @@ -15,6 +15,6 @@ error: failed to parse module 1 │ )) │ ^ unexpected token │ - = Note: expected import, contract, struct, type, const or event + = Note: expected import, contract, struct, type or const diff --git a/crates/parser/tests/cases/snapshots/cases__errors__module_pub_event.snap b/crates/parser/tests/cases/snapshots/cases__errors__module_pub_event.snap deleted file mode 100644 index 91c4848deb..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__errors__module_pub_event.snap +++ /dev/null @@ -1,6 +0,0 @@ ---- -source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(module_pub_event), module::parse_module, false,\n \"pub event E:\\n x: u8\")" - ---- - diff --git a/crates/parser/tests/cases/snapshots/cases__errors__number_end_with_underscore.snap b/crates/parser/tests/cases/snapshots/cases__errors__number_end_with_underscore.snap index 0001137aad..db38b4305b 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__number_end_with_underscore.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__number_end_with_underscore.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(number_end_with_underscore), functions::parse_stmt,\n \"42_42_\")" +expression: "err_string(stringify!(number_end_with_underscore), functions::parse_stmt,\n \"42_42_\")" --- error: invalid syntax in function body diff --git a/crates/parser/tests/cases/snapshots/cases__errors__self_const.snap b/crates/parser/tests/cases/snapshots/cases__errors__self_const.snap index c80c4348ce..d786708e58 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__self_const.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__self_const.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(self_const), module::parse_module, true,\n \"const self: u8 = 10\")" +expression: "err_string(stringify!(self_const), module::parse_module,\n \"const self: u8 = 10\")" --- error: failed to parse constant declaration diff --git a/crates/parser/tests/cases/snapshots/cases__errors__self_contract.snap b/crates/parser/tests/cases/snapshots/cases__errors__self_contract.snap index f877986d7a..fbd6ceda4f 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__self_contract.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__self_contract.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(self_contract), module::parse_module,\n \"contract self {}\")" +expression: "err_string(stringify!(self_contract), module::parse_module,\n \"contract self {}\")" --- error: failed to parse contract definition diff --git a/crates/parser/tests/cases/snapshots/cases__errors__self_use.snap b/crates/parser/tests/cases/snapshots/cases__errors__self_use.snap deleted file mode 100644 index dd7753bdeb..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__errors__self_use.snap +++ /dev/null @@ -1,15 +0,0 @@ ---- -source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(self_use), module::parse_module, true,\n \"use self as self\")" - ---- -error: failed to parse path - ┌─ self_use:1:5 - │ -1 │ use self as self - │ ^^^^ Expected a name, found keyword `self`. - │ - = Note: paths must start with a name - = Example: `foo::bar` - - diff --git a/crates/parser/tests/cases/snapshots/cases__errors__self_use1.snap b/crates/parser/tests/cases/snapshots/cases__errors__self_use1.snap index ff2df665b6..c702464069 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__self_use1.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__self_use1.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(self_use1), module::parse_module, true,\n \"use self as bar\")" +expression: "err_string(stringify!(self_use1), module::parse_module, \"use self as bar\")" --- error: failed to parse `use` statement diff --git a/crates/parser/tests/cases/snapshots/cases__errors__self_use2.snap b/crates/parser/tests/cases/snapshots/cases__errors__self_use2.snap index 76031e46c3..f2ff012d98 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__self_use2.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__self_use2.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(self_use2), module::parse_module, true,\n \"use bar as self\")" +expression: "err_string(stringify!(self_use2), module::parse_module, \"use bar as self\")" --- error: failed to parse `use` tree diff --git a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_attr.snap b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_attr.snap index c3578a1133..2cf4067c52 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_attr.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_attr.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(stmt_vardecl_attr), functions::parse_stmt, true,\n \"f.s : u\")" +expression: "err_string(stringify!(stmt_vardecl_attr), functions::parse_stmt, \"f.s : u\")" --- error: Variable declaration must begin with `let` diff --git a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_name.snap b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_name.snap index 1eb0aa592e..b434e4d013 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_name.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_name.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(stmt_vardecl_invalid_name), functions::parse_stmt, true,\n \"let x + y: u8\")" +expression: "err_string(stringify!(stmt_vardecl_invalid_name), functions::parse_stmt,\n \"let x + y: u8\")" --- error: failed to parse variable declaration diff --git a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_type_annotation.snap b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_type_annotation.snap index 2199d5131c..ad57319380 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_type_annotation.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_invalid_type_annotation.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(stmt_vardecl_invalid_type_annotation),\n functions::parse_stmt, \"let x: y + z\")" +expression: "err_string(stringify!(stmt_vardecl_invalid_type_annotation),\n functions::parse_stmt, \"let x: y + z\")" --- error: unexpected token while parsing variable declaration diff --git a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation.snap b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation.snap index d3d5e2debb..d3970f2ecc 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(stmt_vardecl_missing_type_annotation),\n functions::parse_stmt, true, \"let x = 1\")" +expression: "err_string(stringify!(stmt_vardecl_missing_type_annotation),\n functions::parse_stmt, \"let x = 1\")" --- error: failed to parse variable declaration diff --git a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation_2.snap b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation_2.snap index 8526110fa7..d5e945ee4a 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation_2.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation_2.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(stmt_vardecl_missing_type_annotation_2),\n functions::parse_stmt, true, \"let x\")" +expression: "err_string(stringify!(stmt_vardecl_missing_type_annotation_2),\n functions::parse_stmt, \"let x\")" --- error: failed to parse variable declaration diff --git a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation_3.snap b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation_3.snap index 12ad66f5c5..30276b9512 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation_3.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_missing_type_annotation_3.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(stmt_vardecl_missing_type_annotation_3),\n functions::parse_stmt, true, \"let x:\")" +expression: "err_string(stringify!(stmt_vardecl_missing_type_annotation_3),\n functions::parse_stmt, \"let x:\")" --- error: unexpected end of file diff --git a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_subscript.snap b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_subscript.snap index d16c7bc2f3..9e49e49276 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_subscript.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_subscript.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(stmt_vardecl_subscript), functions::parse_stmt, true,\n \"a[1] : u256\")" +expression: "err_string(stringify!(stmt_vardecl_subscript), functions::parse_stmt,\n \"a[1] : u256\")" --- error: Variable declaration must begin with `let` diff --git a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_tuple.snap b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_tuple.snap index a9ac30743c..0e0e8568cb 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_tuple.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_tuple.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(stmt_vardecl_tuple), functions::parse_stmt, true,\n \"(a, x+1) : u256\")" +expression: "err_string(stringify!(stmt_vardecl_tuple), functions::parse_stmt,\n \"(a, x+1) : u256\")" --- error: Variable declaration must begin with `let` diff --git a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_tuple_empty.snap b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_tuple_empty.snap index 0b8d74e418..c4e4bbf69d 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_tuple_empty.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__stmt_vardecl_tuple_empty.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(stmt_vardecl_tuple_empty), functions::parse_stmt, true,\n \"(a, ()) : u256\")" +expression: "err_string(stringify!(stmt_vardecl_tuple_empty), functions::parse_stmt,\n \"(a, ()) : u256\")" --- error: Variable declaration must begin with `let` diff --git a/crates/parser/tests/cases/snapshots/cases__errors__struct_bad_field_name.snap b/crates/parser/tests/cases/snapshots/cases__errors__struct_bad_field_name.snap index 616996aed7..353a91f589 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__struct_bad_field_name.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__struct_bad_field_name.snap @@ -1,12 +1,12 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(struct_bad_field_name), module::parse_module,\n \"struct f {\\n pub event }\")" +expression: "err_string(stringify!(struct_bad_field_name), module::parse_module,\n \"struct f {\\n pub type }\")" --- error: failed to parse struct definition ┌─ struct_bad_field_name:2:6 │ -2 │ pub event } - │ ^^^^^ unexpected token +2 │ pub type } + │ ^^^^ unexpected token diff --git a/crates/parser/tests/cases/snapshots/cases__errors__type_desc_path_number.snap b/crates/parser/tests/cases/snapshots/cases__errors__type_desc_path_number.snap index e0e5417905..45f40d0f98 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__type_desc_path_number.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__type_desc_path_number.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(type_desc_path_number), module::parse_module, true,\n \"type Foo = some::mod::Foo::5000\")" +expression: "err_string(stringify!(type_desc_path_number), module::parse_module,\n \"type Foo = some::mod::Foo::5000\")" --- error: failed to parse type description diff --git a/crates/parser/tests/cases/snapshots/cases__errors__use_bad_name.snap b/crates/parser/tests/cases/snapshots/cases__errors__use_bad_name.snap index b7b02916e1..822ecfaae8 100644 --- a/crates/parser/tests/cases/snapshots/cases__errors__use_bad_name.snap +++ b/crates/parser/tests/cases/snapshots/cases__errors__use_bad_name.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/errors.rs -expression: "err_string(stringify!(use_bad_name), module::parse_use, true, \"use x as 123\")" +expression: "err_string(stringify!(use_bad_name), module::parse_use, \"use x as 123\")" --- error: failed to parse `use` tree diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__contract_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__contract_def.snap index 3b28b98e5b..24ca1a2e1e 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__contract_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__contract_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(contract_def), try_parse_module,\n r#\"contract Foo {\n x: address\n pub y: u8\n pub const z: Map\n\n pub fn foo() -> u8 {\n return 10\n }\n event Bar {\n idx from: address\n }\n}\n\"#)" +expression: "ast_string(stringify!(contract_def), try_parse_module,\n r#\"contract Foo {\n x: address\n pub y: u8\n pub const z: Map\n\n pub fn foo() -> u8 {\n return 10\n }\n}\n\"#)" --- Node( @@ -20,6 +20,7 @@ Node( kind: Field( is_pub: false, is_const: false, + attributes: [], name: Node( kind: "x", span: Span( @@ -47,6 +48,7 @@ Node( kind: Field( is_pub: true, is_const: false, + attributes: [], name: Node( kind: "y", span: Span( @@ -74,6 +76,7 @@ Node( kind: Field( is_pub: true, is_const: true, + attributes: [], name: Node( kind: "z", span: Span( @@ -193,61 +196,18 @@ Node( end: 113, ), )), - Event(Node( - kind: Event( - name: Node( - kind: "Bar", - span: Span( - start: 122, - end: 125, - ), - ), - fields: [ - Node( - kind: EventField( - is_idx: true, - name: Node( - kind: "from", - span: Span( - start: 136, - end: 140, - ), - ), - typ: Node( - kind: Base( - base: "address", - ), - span: Span( - start: 142, - end: 149, - ), - ), - ), - span: Span( - start: 132, - end: 149, - ), - ), - ], - pub_qual: None, - ), - span: Span( - start: 116, - end: 153, - ), - )), ], pub_qual: None, ), span: Span( start: 0, - end: 155, + end: 115, ), )), ], ), span: Span( start: 0, - end: 155, + end: 115, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_contract_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_contract_def.snap index 7c064f97da..d454898259 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_contract_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_contract_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(empty_contract_def), try_parse_module,\n \"contract Foo {}\")" +expression: "ast_string(stringify!(empty_contract_def), try_parse_module,\n \"contract Foo {}\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_event_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_event_def.snap deleted file mode 100644 index 29d785698c..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__empty_event_def.snap +++ /dev/null @@ -1,32 +0,0 @@ ---- -source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(empty_event_def), try_parse_module, \"event Foo {}\")" - ---- -Node( - kind: Module( - body: [ - Event(Node( - kind: Event( - name: Node( - kind: "Foo", - span: Span( - start: 6, - end: 9, - ), - ), - fields: [], - pub_qual: None, - ), - span: Span( - start: 0, - end: 12, - ), - )), - ], - ), - span: Span( - start: 0, - end: 12, - ), -) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__event_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__event_def.snap deleted file mode 100644 index 23b5b63790..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__event_def.snap +++ /dev/null @@ -1,83 +0,0 @@ ---- -source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(event_def), try_parse_module,\n \"event Foo {\\n x: address\\n idx y: u8\\n}\")" - ---- -Node( - kind: Module( - body: [ - Event(Node( - kind: Event( - name: Node( - kind: "Foo", - span: Span( - start: 6, - end: 9, - ), - ), - fields: [ - Node( - kind: EventField( - is_idx: false, - name: Node( - kind: "x", - span: Span( - start: 14, - end: 15, - ), - ), - typ: Node( - kind: Base( - base: "address", - ), - span: Span( - start: 17, - end: 24, - ), - ), - ), - span: Span( - start: 14, - end: 24, - ), - ), - Node( - kind: EventField( - is_idx: true, - name: Node( - kind: "y", - span: Span( - start: 31, - end: 32, - ), - ), - typ: Node( - kind: Base( - base: "u8", - ), - span: Span( - start: 34, - end: 36, - ), - ), - ), - span: Span( - start: 27, - end: 36, - ), - ), - ], - pub_qual: None, - ), - span: Span( - start: 0, - end: 38, - ), - )), - ], - ), - span: Span( - start: 0, - end: 38, - ), -) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call2.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call2.snap index 0c09f9f923..43e97b6d29 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call2.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call2.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(expr_call2), expressions::parse_expr, \"foo(1,2,x=3)\")" +expression: "ast_string(stringify!(expr_call2), expressions::parse_expr, \"foo(1,2,x:3)\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call3.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call3.snap index 20da75bae8..2e1fb1ef1d 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call3.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call3.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(expr_call3), expressions::parse_expr,\n \"bing.foo(x:3)\")" +expression: "ast_string(stringify!(expr_call3), expressions::parse_expr,\n \"bing.foo(x:3)\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call4.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call4.snap index 80390780f2..702e803844 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call4.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_call4.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(expr_call4), expressions::parse_expr,\n \"bang.bing.foo(26, 42)\")" +expression: "ast_string(stringify!(expr_call4), expressions::parse_expr,\n \"bang.bing.foo(26, 42)\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_path_call.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_path_call.snap index 227ea5f720..0dc9838c42 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_path_call.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_path_call.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(expr_path_call), expressions::parse_expr,\n \"foo::bar::abc1()\")" +expression: "ast_string(stringify!(expr_path_call), expressions::parse_expr,\n \"foo::bar::abc1()\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_string.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_string.snap index d8fa8740d4..a8184d7832 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_string.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_string.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(expr_string), expressions::parse_expr,\n r#\"\"hi \\tmom\\n\"\"#)" +expression: "ast_string(stringify!(expr_string), expressions::parse_expr,\n r#\"\"hi \\tmom\\n\"\"#)" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_ternary.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_ternary.snap index ae1af6938b..48043b08ba 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_ternary.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_ternary.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(expr_ternary), expressions::parse_expr,\n \"x + 1 if y + 2 else z + 3\")" +expression: "ast_string(stringify!(expr_ternary), expressions::parse_expr,\n \"x + 1 if y + 2 else z + 3\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_tuple3.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_tuple3.snap index c711965483..4d141fac99 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_tuple3.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__expr_tuple3.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(expr_tuple3), expressions::parse_expr,\n \"(1, (2 + 3), (3 * 4, 5))\")" +expression: "ast_string(stringify!(expr_tuple3), expressions::parse_expr,\n \"(1, (2 + 3), (3 * 4, 5))\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__guest_book.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__guest_book.snap index d145fbed9b..436cf8ff70 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__guest_book.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__guest_book.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(guest_book), try_parse_module,\n r#\"\ntype BookMsg = Array\n\ncontract GuestBook {\n pub guest_book: Map\n\n event Signed {\n idx book_msg: BookMsg\n }\n\n pub fn sign(self, book_msg: BookMsg) {\n self.guest_book[msg.sender] = book_msg\n\n emit Signed(book_msg: book_msg)\n }\n pub fn get_msg(self, addr: address) -> BookMsg {\n return self.guest_book[addr]\n }\n}\"#)" +expression: "ast_string(stringify!(guest_book), try_parse_module,\n r#\"\ntype BookMsg = Array\n\nstruct Signed {\n #indexed\n book_msg: BookMsg\n}\n\ncontract GuestBook {\n pub guest_book: Map\n\n pub fn sign(self, book_msg: BookMsg) {\n self.guest_book[msg.sender] = book_msg\n\n ctx.emit(Signed(book_msg: book_msg))\n }\n pub fn get_msg(self, addr: address) -> BookMsg {\n return self.guest_book[addr]\n }\n}\"#)" --- Node( @@ -61,13 +61,68 @@ Node( end: 33, ), )), + Struct(Node( + kind: Struct( + name: Node( + kind: "Signed", + span: Span( + start: 42, + end: 48, + ), + ), + fields: [ + Node( + kind: Field( + is_pub: false, + is_const: false, + attributes: [ + Node( + kind: "indexed", + span: Span( + start: 55, + end: 63, + ), + ), + ], + name: Node( + kind: "book_msg", + span: Span( + start: 68, + end: 76, + ), + ), + typ: Node( + kind: Base( + base: "BookMsg", + ), + span: Span( + start: 78, + end: 85, + ), + ), + value: None, + ), + span: Span( + start: 68, + end: 85, + ), + ), + ], + functions: [], + pub_qual: None, + ), + span: Span( + start: 35, + end: 87, + ), + )), Contract(Node( kind: Contract( name: Node( kind: "GuestBook", span: Span( - start: 44, - end: 53, + start: 98, + end: 107, ), ), fields: [ @@ -75,11 +130,12 @@ Node( kind: Field( is_pub: true, is_const: false, + attributes: [], name: Node( kind: "guest_book", span: Span( - start: 64, - end: 74, + start: 118, + end: 128, ), ), typ: Node( @@ -87,8 +143,8 @@ Node( base: Node( kind: "Map", span: Span( - start: 76, - end: 79, + start: 130, + end: 133, ), ), args: Node( @@ -98,8 +154,8 @@ Node( base: "address", ), span: Span( - start: 80, - end: 87, + start: 134, + end: 141, ), )), TypeDesc(Node( @@ -107,103 +163,60 @@ Node( base: "BookMsg", ), span: Span( - start: 89, - end: 96, + start: 143, + end: 150, ), )), ], span: Span( - start: 79, - end: 97, + start: 133, + end: 151, ), ), ), span: Span( - start: 76, - end: 97, + start: 130, + end: 151, ), ), value: None, ), span: Span( - start: 60, - end: 97, + start: 114, + end: 151, ), ), ], body: [ - Event(Node( - kind: Event( - name: Node( - kind: "Signed", - span: Span( - start: 109, - end: 115, - ), - ), - fields: [ - Node( - kind: EventField( - is_idx: true, - name: Node( - kind: "book_msg", - span: Span( - start: 130, - end: 138, - ), - ), - typ: Node( - kind: Base( - base: "BookMsg", - ), - span: Span( - start: 140, - end: 147, - ), - ), - ), - span: Span( - start: 126, - end: 147, - ), - ), - ], - pub_qual: None, - ), - span: Span( - start: 103, - end: 153, - ), - )), Function(Node( kind: Function( sig: Node( kind: FunctionSignature( pub_: Some(Span( - start: 159, - end: 162, + start: 157, + end: 160, )), unsafe_: None, name: Node( kind: "sign", span: Span( - start: 166, - end: 170, + start: 164, + end: 168, ), ), generic_params: Node( kind: [], span: Span( - start: 166, - end: 170, + start: 164, + end: 168, ), ), args: [ Node( kind: Self_, span: Span( - start: 171, - end: 175, + start: 169, + end: 173, ), ), Node( @@ -212,8 +225,8 @@ Node( name: Node( kind: "book_msg", span: Span( - start: 177, - end: 185, + start: 175, + end: 183, ), ), typ: Node( @@ -221,22 +234,22 @@ Node( base: "BookMsg", ), span: Span( - start: 187, - end: 194, + start: 185, + end: 192, ), ), )), span: Span( - start: 177, - end: 194, + start: 175, + end: 192, ), ), ], return_type: None, ), span: Span( - start: 159, - end: 195, + start: 157, + end: 193, ), ), body: [ @@ -249,21 +262,21 @@ Node( value: Node( kind: Name("self"), span: Span( - start: 206, - end: 210, + start: 204, + end: 208, ), ), attr: Node( kind: "guest_book", span: Span( - start: 211, - end: 221, + start: 209, + end: 219, ), ), ), span: Span( - start: 206, - end: 221, + start: 204, + end: 219, ), ), index: Node( @@ -271,92 +284,149 @@ Node( value: Node( kind: Name("msg"), span: Span( - start: 222, - end: 225, + start: 220, + end: 223, ), ), attr: Node( kind: "sender", span: Span( - start: 226, - end: 232, + start: 224, + end: 230, ), ), ), span: Span( - start: 222, - end: 232, + start: 220, + end: 230, ), ), ), span: Span( - start: 206, - end: 233, + start: 204, + end: 231, ), ), value: Node( kind: Name("book_msg"), span: Span( - start: 236, - end: 244, + start: 234, + end: 242, ), ), ), span: Span( - start: 206, - end: 244, + start: 204, + end: 242, ), ), Node( - kind: Emit( - name: Node( - kind: "Signed", - span: Span( - start: 259, - end: 265, - ), - ), - args: Node( - kind: [ - Node( - kind: CallArg( - label: Some(Node( - kind: "book_msg", + kind: Expr( + value: Node( + kind: Call( + func: Node( + kind: Attribute( + value: Node( + kind: Name("ctx"), span: Span( - start: 266, - end: 274, + start: 252, + end: 255, ), - )), - value: Node( - kind: Name("book_msg"), + ), + attr: Node( + kind: "emit", span: Span( - start: 276, - end: 284, + start: 256, + end: 260, ), ), ), span: Span( - start: 266, - end: 284, + start: 252, + end: 260, ), ), - ], + generic_args: None, + args: Node( + kind: [ + Node( + kind: CallArg( + label: None, + value: Node( + kind: Call( + func: Node( + kind: Name("Signed"), + span: Span( + start: 261, + end: 267, + ), + ), + generic_args: None, + args: Node( + kind: [ + Node( + kind: CallArg( + label: Some(Node( + kind: "book_msg", + span: Span( + start: 268, + end: 276, + ), + )), + value: Node( + kind: Name("book_msg"), + span: Span( + start: 278, + end: 286, + ), + ), + ), + span: Span( + start: 268, + end: 286, + ), + ), + ], + span: Span( + start: 267, + end: 287, + ), + ), + ), + span: Span( + start: 261, + end: 287, + ), + ), + ), + span: Span( + start: 261, + end: 287, + ), + ), + ], + span: Span( + start: 260, + end: 288, + ), + ), + ), span: Span( - start: 265, - end: 285, + start: 252, + end: 288, ), ), ), span: Span( - start: 254, - end: 285, + start: 252, + end: 288, ), ), ], ), span: Span( - start: 159, - end: 291, + start: 157, + end: 294, ), )), Function(Node( @@ -364,30 +434,30 @@ Node( sig: Node( kind: FunctionSignature( pub_: Some(Span( - start: 296, - end: 299, + start: 299, + end: 302, )), unsafe_: None, name: Node( kind: "get_msg", span: Span( - start: 303, - end: 310, + start: 306, + end: 313, ), ), generic_params: Node( kind: [], span: Span( - start: 303, - end: 310, + start: 306, + end: 313, ), ), args: [ Node( kind: Self_, span: Span( - start: 311, - end: 315, + start: 314, + end: 318, ), ), Node( @@ -396,8 +466,8 @@ Node( name: Node( kind: "addr", span: Span( - start: 317, - end: 321, + start: 320, + end: 324, ), ), typ: Node( @@ -405,14 +475,14 @@ Node( base: "address", ), span: Span( - start: 323, - end: 330, + start: 326, + end: 333, ), ), )), span: Span( - start: 317, - end: 330, + start: 320, + end: 333, ), ), ], @@ -421,14 +491,14 @@ Node( base: "BookMsg", ), span: Span( - start: 335, - end: 342, + start: 338, + end: 345, ), )), ), span: Span( - start: 296, - end: 342, + start: 299, + end: 345, ), ), body: [ @@ -441,61 +511,61 @@ Node( value: Node( kind: Name("self"), span: Span( - start: 360, - end: 364, + start: 363, + end: 367, ), ), attr: Node( kind: "guest_book", span: Span( - start: 365, - end: 375, + start: 368, + end: 378, ), ), ), span: Span( - start: 360, - end: 375, + start: 363, + end: 378, ), ), index: Node( kind: Name("addr"), span: Span( - start: 376, - end: 380, + start: 379, + end: 383, ), ), ), span: Span( - start: 360, - end: 381, + start: 363, + end: 384, ), )), ), span: Span( - start: 353, - end: 381, + start: 356, + end: 384, ), ), ], ), span: Span( - start: 296, - end: 387, + start: 299, + end: 390, ), )), ], pub_qual: None, ), span: Span( - start: 35, - end: 389, + start: 89, + end: 392, ), )), ], ), span: Span( start: 0, - end: 389, + end: 392, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__module_level_events.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__module_level_events.snap index 72817b8b11..b69e621ee2 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__module_level_events.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__module_level_events.snap @@ -1,29 +1,39 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(module_level_events), try_parse_module,\n r#\"\nevent Transfer {\n idx sender: address\n idx receiver: address\n value: u256\n}\ncontract Foo {\n fn transfer(ctx: Context, to: address, value: u256) {\n emit Transfer(ctx, sender: msg.sender, receiver: to, value)\n }\n}\n\"#)" +expression: "ast_string(stringify!(module_level_events), try_parse_module,\n r#\"\nstruct Transfer {\n #indexed\n sender: address\n #indexed\n receiver: address\n value: u256\n}\ncontract Foo {\n fn transfer(ctx: Context, to: address, value: u256) {\n ctx.emit(Transfer(sender: msg.sender, receiver: to, value))\n }\n}\n\"#)" --- Node( kind: Module( body: [ - Event(Node( - kind: Event( + Struct(Node( + kind: Struct( name: Node( kind: "Transfer", span: Span( - start: 7, - end: 15, + start: 8, + end: 16, ), ), fields: [ Node( - kind: EventField( - is_idx: true, + kind: Field( + is_pub: false, + is_const: false, + attributes: [ + Node( + kind: "indexed", + span: Span( + start: 23, + end: 31, + ), + ), + ], name: Node( kind: "sender", span: Span( - start: 26, - end: 32, + start: 36, + end: 42, ), ), typ: Node( @@ -31,24 +41,35 @@ Node( base: "address", ), span: Span( - start: 34, - end: 41, + start: 44, + end: 51, ), ), + value: None, ), span: Span( - start: 22, - end: 41, + start: 36, + end: 51, ), ), Node( - kind: EventField( - is_idx: true, + kind: Field( + is_pub: false, + is_const: false, + attributes: [ + Node( + kind: "indexed", + span: Span( + start: 56, + end: 64, + ), + ), + ], name: Node( kind: "receiver", span: Span( - start: 50, - end: 58, + start: 69, + end: 77, ), ), typ: Node( @@ -56,24 +77,27 @@ Node( base: "address", ), span: Span( - start: 60, - end: 67, + start: 79, + end: 86, ), ), + value: None, ), span: Span( - start: 46, - end: 67, + start: 69, + end: 86, ), ), Node( - kind: EventField( - is_idx: false, + kind: Field( + is_pub: false, + is_const: false, + attributes: [], name: Node( kind: "value", span: Span( - start: 72, - end: 77, + start: 91, + end: 96, ), ), typ: Node( @@ -81,22 +105,24 @@ Node( base: "u256", ), span: Span( - start: 79, - end: 83, + start: 98, + end: 102, ), ), + value: None, ), span: Span( - start: 72, - end: 83, + start: 91, + end: 102, ), ), ], + functions: [], pub_qual: None, ), span: Span( start: 1, - end: 85, + end: 104, ), )), Contract(Node( @@ -104,8 +130,8 @@ Node( name: Node( kind: "Foo", span: Span( - start: 95, - end: 98, + start: 114, + end: 117, ), ), fields: [], @@ -119,15 +145,15 @@ Node( name: Node( kind: "transfer", span: Span( - start: 108, - end: 116, + start: 127, + end: 135, ), ), generic_params: Node( kind: [], span: Span( - start: 108, - end: 116, + start: 127, + end: 135, ), ), args: [ @@ -137,8 +163,8 @@ Node( name: Node( kind: "ctx", span: Span( - start: 117, - end: 120, + start: 136, + end: 139, ), ), typ: Node( @@ -146,14 +172,14 @@ Node( base: "Context", ), span: Span( - start: 122, - end: 129, + start: 141, + end: 148, ), ), )), span: Span( - start: 117, - end: 129, + start: 136, + end: 148, ), ), Node( @@ -162,8 +188,8 @@ Node( name: Node( kind: "to", span: Span( - start: 131, - end: 133, + start: 150, + end: 152, ), ), typ: Node( @@ -171,14 +197,14 @@ Node( base: "address", ), span: Span( - start: 135, - end: 142, + start: 154, + end: 161, ), ), )), span: Span( - start: 131, - end: 142, + start: 150, + end: 161, ), ), Node( @@ -187,8 +213,8 @@ Node( name: Node( kind: "value", span: Span( - start: 144, - end: 149, + start: 163, + end: 168, ), ), typ: Node( @@ -196,158 +222,199 @@ Node( base: "u256", ), span: Span( - start: 151, - end: 155, + start: 170, + end: 174, ), ), )), span: Span( - start: 144, - end: 155, + start: 163, + end: 174, ), ), ], return_type: None, ), span: Span( - start: 105, - end: 156, + start: 124, + end: 175, ), ), body: [ Node( - kind: Emit( - name: Node( - kind: "Transfer", - span: Span( - start: 172, - end: 180, - ), - ), - args: Node( - kind: [ - Node( - kind: CallArg( - label: None, + kind: Expr( + value: Node( + kind: Call( + func: Node( + kind: Attribute( value: Node( kind: Name("ctx"), span: Span( - start: 181, - end: 184, + start: 186, + end: 189, + ), + ), + attr: Node( + kind: "emit", + span: Span( + start: 190, + end: 194, ), ), ), span: Span( - start: 181, - end: 184, + start: 186, + end: 194, ), ), - Node( - kind: CallArg( - label: Some(Node( - kind: "sender", - span: Span( - start: 186, - end: 192, - ), - )), - value: Node( - kind: Attribute( + generic_args: None, + args: Node( + kind: [ + Node( + kind: CallArg( + label: None, value: Node( - kind: Name("msg"), - span: Span( - start: 194, - end: 197, + kind: Call( + func: Node( + kind: Name("Transfer"), + span: Span( + start: 195, + end: 203, + ), + ), + generic_args: None, + args: Node( + kind: [ + Node( + kind: CallArg( + label: Some(Node( + kind: "sender", + span: Span( + start: 204, + end: 210, + ), + )), + value: Node( + kind: Attribute( + value: Node( + kind: Name("msg"), + span: Span( + start: 212, + end: 215, + ), + ), + attr: Node( + kind: "sender", + span: Span( + start: 216, + end: 222, + ), + ), + ), + span: Span( + start: 212, + end: 222, + ), + ), + ), + span: Span( + start: 204, + end: 222, + ), + ), + Node( + kind: CallArg( + label: Some(Node( + kind: "receiver", + span: Span( + start: 224, + end: 232, + ), + )), + value: Node( + kind: Name("to"), + span: Span( + start: 234, + end: 236, + ), + ), + ), + span: Span( + start: 224, + end: 236, + ), + ), + Node( + kind: CallArg( + label: None, + value: Node( + kind: Name("value"), + span: Span( + start: 238, + end: 243, + ), + ), + ), + span: Span( + start: 238, + end: 243, + ), + ), + ], + span: Span( + start: 203, + end: 244, + ), + ), ), - ), - attr: Node( - kind: "sender", span: Span( - start: 198, - end: 204, + start: 195, + end: 244, ), ), ), span: Span( - start: 194, - end: 204, - ), - ), - ), - span: Span( - start: 186, - end: 204, - ), - ), - Node( - kind: CallArg( - label: Some(Node( - kind: "receiver", - span: Span( - start: 206, - end: 214, - ), - )), - value: Node( - kind: Name("to"), - span: Span( - start: 216, - end: 218, - ), - ), - ), - span: Span( - start: 206, - end: 218, - ), - ), - Node( - kind: CallArg( - label: None, - value: Node( - kind: Name("value"), - span: Span( - start: 220, - end: 225, + start: 195, + end: 244, ), ), - ), + ], span: Span( - start: 220, - end: 225, + start: 194, + end: 245, ), ), - ], + ), span: Span( - start: 180, - end: 226, + start: 186, + end: 245, ), ), ), span: Span( - start: 167, - end: 226, + start: 186, + end: 245, ), ), ], ), span: Span( - start: 105, - end: 232, + start: 124, + end: 251, ), )), ], pub_qual: None, ), span: Span( - start: 86, - end: 234, + start: 105, + end: 253, ), )), ], ), span: Span( start: 0, - end: 234, + end: 253, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__module_stmts.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__module_stmts.snap index 579339eaa3..6429c89ac6 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__module_stmts.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__module_stmts.snap @@ -342,6 +342,7 @@ Node( kind: Field( is_pub: true, is_const: true, + attributes: [], name: Node( kind: "x", span: Span( @@ -394,6 +395,7 @@ Node( kind: Field( is_pub: true, is_const: false, + attributes: [], name: Node( kind: "x", span: Span( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__ops_math.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__ops_math.snap index cb54e8144a..ed9d213c54 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__ops_math.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__ops_math.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(ops_math), expressions::parse_expr,\n \"a + b * -c ** d / e % f\")" +expression: "ast_string(stringify!(ops_math), expressions::parse_expr,\n \"a + b * -c ** d / e % f\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_const_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_const_def.snap index 56e8471942..ebd21d3d26 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_const_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_const_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(pub_const_def), try_parse_module,\n \"pub const FOO: i32 = 1\")" +expression: "ast_string(stringify!(pub_const_def), try_parse_module,\n \"pub const FOO: i32 = 1\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_event_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_event_def.snap deleted file mode 100644 index 486e9c4837..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_event_def.snap +++ /dev/null @@ -1,86 +0,0 @@ ---- -source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(pub_event_def), try_parse_module,\n \"pub event Foo {\\nx: address\\nidx y: u8\\n}\")" - ---- -Node( - kind: Module( - body: [ - Event(Node( - kind: Event( - name: Node( - kind: "Foo", - span: Span( - start: 10, - end: 13, - ), - ), - fields: [ - Node( - kind: EventField( - is_idx: false, - name: Node( - kind: "x", - span: Span( - start: 16, - end: 17, - ), - ), - typ: Node( - kind: Base( - base: "address", - ), - span: Span( - start: 19, - end: 26, - ), - ), - ), - span: Span( - start: 16, - end: 26, - ), - ), - Node( - kind: EventField( - is_idx: true, - name: Node( - kind: "y", - span: Span( - start: 31, - end: 32, - ), - ), - typ: Node( - kind: Base( - base: "u8", - ), - span: Span( - start: 34, - end: 36, - ), - ), - ), - span: Span( - start: 27, - end: 36, - ), - ), - ], - pub_qual: Some(Span( - start: 0, - end: 3, - )), - ), - span: Span( - start: 4, - end: 38, - ), - )), - ], - ), - span: Span( - start: 0, - end: 38, - ), -) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_type_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_type_def.snap index ac2a7b6420..1c77351523 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_type_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__pub_type_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(pub_type_def), module::parse_module,\n \"pub type X = Map\")" +expression: "ast_string(stringify!(pub_type_def), try_parse_module,\n \"pub type X = Map\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_assert_msg.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_assert_msg.snap index 32a29fab3a..fcf36d2c94 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_assert_msg.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_assert_msg.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_assert_msg), functions::parse_stmt,\n \"assert x == y, z\")" +expression: "ast_string(stringify!(stmt_assert_msg), functions::parse_stmt,\n \"assert x == y, z\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_assert_no_msg.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_assert_no_msg.snap index 26be17b075..eda952968d 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_assert_no_msg.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_assert_no_msg.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_assert_no_msg), functions::parse_stmt,\n \"assert x == y\")" +expression: "ast_string(stringify!(stmt_assert_no_msg), functions::parse_stmt,\n \"assert x == y\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_emit1.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_emit1.snap deleted file mode 100644 index d6c920e494..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_emit1.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_emit1), functions::parse_stmt, \"emit Foo()\")" - ---- -Node( - kind: Emit( - name: Node( - kind: "Foo", - span: Span( - start: 5, - end: 8, - ), - ), - args: Node( - kind: [], - span: Span( - start: 8, - end: 10, - ), - ), - ), - span: Span( - start: 0, - end: 10, - ), -) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_emit2.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_emit2.snap deleted file mode 100644 index f2b2dda687..0000000000 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_emit2.snap +++ /dev/null @@ -1,82 +0,0 @@ ---- -source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_emit2), functions::parse_stmt,\n \"emit Foo(1, 2, x: y)\")" - ---- -Node( - kind: Emit( - name: Node( - kind: "Foo", - span: Span( - start: 5, - end: 8, - ), - ), - args: Node( - kind: [ - Node( - kind: CallArg( - label: None, - value: Node( - kind: Num("1"), - span: Span( - start: 9, - end: 10, - ), - ), - ), - span: Span( - start: 9, - end: 10, - ), - ), - Node( - kind: CallArg( - label: None, - value: Node( - kind: Num("2"), - span: Span( - start: 12, - end: 13, - ), - ), - ), - span: Span( - start: 12, - end: 13, - ), - ), - Node( - kind: CallArg( - label: Some(Node( - kind: "x", - span: Span( - start: 15, - end: 16, - ), - )), - value: Node( - kind: Name("y"), - span: Span( - start: 18, - end: 19, - ), - ), - ), - span: Span( - start: 15, - end: 19, - ), - ), - ], - span: Span( - start: 8, - end: 20, - ), - ), - ), - span: Span( - start: 0, - end: 20, - ), -) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if2.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if2.snap index f57594e327..588a4c7cea 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if2.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_if2.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_if2), functions::parse_stmt,\n \"if a { b } else if c { d } else if e { \\n f } \\n else {\\n g }\")" +expression: "ast_string(stringify!(stmt_if2), functions::parse_stmt,\n \"if a { b } else if c { d } else if e { \\n f } \\n else {\\n g }\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_path_type.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_path_type.snap index 6adab29298..6fac3532c1 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_path_type.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_path_type.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_path_type), functions::parse_stmt,\n \"let x: foo::Bar = foo::Bar(1, 2)\")" +expression: "ast_string(stringify!(stmt_path_type), functions::parse_stmt,\n \"let x: foo::Bar = foo::Bar(1, 2)\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_revert2.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_revert2.snap index df79440a8e..b702475779 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_revert2.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_revert2.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_revert2), functions::parse_stmt,\n \"revert something\")" +expression: "ast_string(stringify!(stmt_revert2), functions::parse_stmt,\n \"revert something\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_semicolons.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_semicolons.snap index abd92a54c1..e27f72ad12 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_semicolons.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_semicolons.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_semicolons), functions::parse_stmt,\n \"if a { b; c; d; for x in y {}; }\")" +expression: "ast_string(stringify!(stmt_semicolons), functions::parse_stmt,\n \"if a { b; c; d; for x in y {}; }\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_name.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_name.snap index 69206bc530..9ede189c16 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_name.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_name.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_var_decl_name), functions::parse_stmt,\n \"let foo: u256 = 1\")" +expression: "ast_string(stringify!(stmt_var_decl_name), functions::parse_stmt,\n \"let foo: u256 = 1\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_tuple.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_tuple.snap index 983abd1db8..0710f21619 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_tuple.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_tuple.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_var_decl_tuple), functions::parse_stmt,\n \"let (foo, bar): (u256, u256) = (10, 10)\")" +expression: "ast_string(stringify!(stmt_var_decl_tuple), functions::parse_stmt,\n \"let (foo, bar): (u256, u256) = (10, 10)\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_tuples.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_tuples.snap index fa032f92d3..01dc98a4bf 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_tuples.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_var_decl_tuples.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_var_decl_tuples), functions::parse_stmt,\n \"let (a, (b, (c, d))): x\")" +expression: "ast_string(stringify!(stmt_var_decl_tuples), functions::parse_stmt,\n \"let (a, (b, (c, d))): x\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_while.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_while.snap index 64a685f7ba..077228d34b 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_while.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__stmt_while.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(stmt_while), functions::parse_stmt,\n \"while a > 5 { \\n a -= 1 }\")" +expression: "ast_string(stringify!(stmt_while), functions::parse_stmt,\n \"while a > 5 { \\n a -= 1 }\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__struct_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__struct_def.snap index 9e8461d9cc..b92b8d643e 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__struct_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__struct_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(struct_def), try_parse_module,\n r#\"struct S {\n x: address\n pub y: u8\n z: u8\n pub a: Map\n\n pub fn foo(self) -> u8 {\n return self.z + self.y\n }\n unsafe fn bar() {}\n}\"#)" +expression: "ast_string(stringify!(struct_def), try_parse_module,\n r#\"struct S {\n #indexed\n x: address\n pub y: u8\n z: u8\n pub a: Map\n\n pub fn foo(self) -> u8 {\n return self.z + self.y\n }\n unsafe fn bar() {}\n}\"#)" --- Node( @@ -20,11 +20,20 @@ Node( kind: Field( is_pub: false, is_const: false, + attributes: [ + Node( + kind: "indexed", + span: Span( + start: 13, + end: 21, + ), + ), + ], name: Node( kind: "x", span: Span( - start: 13, - end: 14, + start: 24, + end: 25, ), ), typ: Node( @@ -32,26 +41,27 @@ Node( base: "address", ), span: Span( - start: 16, - end: 23, + start: 27, + end: 34, ), ), value: None, ), span: Span( - start: 13, - end: 23, + start: 24, + end: 34, ), ), Node( kind: Field( is_pub: true, is_const: false, + attributes: [], name: Node( kind: "y", span: Span( - start: 30, - end: 31, + start: 41, + end: 42, ), ), typ: Node( @@ -59,26 +69,27 @@ Node( base: "u8", ), span: Span( - start: 33, - end: 35, + start: 44, + end: 46, ), ), value: None, ), span: Span( - start: 26, - end: 35, + start: 37, + end: 46, ), ), Node( kind: Field( is_pub: false, is_const: false, + attributes: [], name: Node( kind: "z", span: Span( - start: 38, - end: 39, + start: 49, + end: 50, ), ), typ: Node( @@ -86,26 +97,27 @@ Node( base: "u8", ), span: Span( - start: 41, - end: 43, + start: 52, + end: 54, ), ), value: None, ), span: Span( - start: 38, - end: 43, + start: 49, + end: 54, ), ), Node( kind: Field( is_pub: true, is_const: false, + attributes: [], name: Node( kind: "a", span: Span( - start: 50, - end: 51, + start: 61, + end: 62, ), ), typ: Node( @@ -113,8 +125,8 @@ Node( base: Node( kind: "Map", span: Span( - start: 53, - end: 56, + start: 64, + end: 67, ), ), args: Node( @@ -124,8 +136,8 @@ Node( base: "u8", ), span: Span( - start: 57, - end: 59, + start: 68, + end: 70, ), )), TypeDesc(Node( @@ -133,27 +145,27 @@ Node( base: "foo", ), span: Span( - start: 61, - end: 64, + start: 72, + end: 75, ), )), ], span: Span( - start: 56, - end: 65, + start: 67, + end: 76, ), ), ), span: Span( - start: 53, - end: 65, + start: 64, + end: 76, ), ), value: None, ), span: Span( - start: 46, - end: 65, + start: 57, + end: 76, ), ), ], @@ -163,30 +175,30 @@ Node( sig: Node( kind: FunctionSignature( pub_: Some(Span( - start: 69, - end: 72, + start: 80, + end: 83, )), unsafe_: None, name: Node( kind: "foo", span: Span( - start: 76, - end: 79, + start: 87, + end: 90, ), ), generic_params: Node( kind: [], span: Span( - start: 76, - end: 79, + start: 87, + end: 90, ), ), args: [ Node( kind: Self_, span: Span( - start: 80, - end: 84, + start: 91, + end: 95, ), ), ], @@ -195,14 +207,14 @@ Node( base: "u8", ), span: Span( - start: 89, - end: 91, + start: 100, + end: 102, ), )), ), span: Span( - start: 69, - end: 91, + start: 80, + end: 102, ), ), body: [ @@ -215,28 +227,28 @@ Node( value: Node( kind: Name("self"), span: Span( - start: 105, - end: 109, + start: 116, + end: 120, ), ), attr: Node( kind: "z", span: Span( - start: 110, - end: 111, + start: 121, + end: 122, ), ), ), span: Span( - start: 105, - end: 111, + start: 116, + end: 122, ), ), op: Node( kind: Add, span: Span( - start: 112, - end: 113, + start: 123, + end: 124, ), ), right: Node( @@ -244,40 +256,40 @@ Node( value: Node( kind: Name("self"), span: Span( - start: 114, - end: 118, + start: 125, + end: 129, ), ), attr: Node( kind: "y", span: Span( - start: 119, - end: 120, + start: 130, + end: 131, ), ), ), span: Span( - start: 114, - end: 120, + start: 125, + end: 131, ), ), ), span: Span( - start: 105, - end: 120, + start: 116, + end: 131, ), )), ), span: Span( - start: 98, - end: 120, + start: 109, + end: 131, ), ), ], ), span: Span( - start: 69, - end: 124, + start: 80, + end: 135, ), ), Node( @@ -286,36 +298,36 @@ Node( kind: FunctionSignature( pub_: None, unsafe_: Some(Span( - start: 127, - end: 133, + start: 138, + end: 144, )), name: Node( kind: "bar", span: Span( - start: 137, - end: 140, + start: 148, + end: 151, ), ), generic_params: Node( kind: [], span: Span( - start: 137, - end: 140, + start: 148, + end: 151, ), ), args: [], return_type: None, ), span: Span( - start: 127, - end: 142, + start: 138, + end: 153, ), ), body: [], ), span: Span( - start: 127, - end: 145, + start: 138, + end: 156, ), ), ], @@ -323,13 +335,13 @@ Node( ), span: Span( start: 0, - end: 147, + end: 158, ), )), ], ), span: Span( start: 0, - end: 147, + end: 158, ), ) diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_3d.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_3d.snap index a65af8fb01..9ad4a4b94e 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_3d.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_3d.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(type_3d), types::parse_type_desc,\n \"Array, 4>, 4>\")" +expression: "ast_string(stringify!(type_3d), types::parse_type_desc,\n \"Array, 4>, 4>\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_array.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_array.snap index 06de1726a1..2115a46ba6 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_array.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_array.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(type_array), types::parse_type_desc,\n \"Array\")" +expression: "ast_string(stringify!(type_array), types::parse_type_desc,\n \"Array\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_def.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_def.snap index 12c4008148..a0ceb1e7ed 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_def.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_def.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(type_def), module::parse_module,\n \"type X = Map\")" +expression: "ast_string(stringify!(type_def), try_parse_module,\n \"type X = Map\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_generic.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_generic.snap index 924a785a8c..4988fecb8d 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_generic.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_generic.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(type_generic), types::parse_type_desc,\n \"foo, Array>\")" +expression: "ast_string(stringify!(type_generic), types::parse_type_desc,\n \"foo, Array>\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map1.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map1.snap index a9adee9e64..f6f1b2043e 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map1.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map1.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(type_map1), types::parse_type_desc,\n \"Map\")" +expression: "ast_string(stringify!(type_map1), types::parse_type_desc,\n \"Map\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map2.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map2.snap index a92ae6826b..be43ac36bd 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map2.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map2.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(type_map2), types::parse_type_desc,\n \"Map>\")" +expression: "ast_string(stringify!(type_map2), types::parse_type_desc,\n \"Map>\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map3.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map3.snap index fd14b0c60e..4e733105d4 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map3.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map3.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(type_map3), types::parse_type_desc,\n \"Map>>\")" +expression: "ast_string(stringify!(type_map3), types::parse_type_desc,\n \"Map>>\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map4.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map4.snap index 6b838b9b78..704e65723f 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map4.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_map4.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(type_map4), types::parse_type_desc,\n \"map < address , map < u8, u256 > >\")" +expression: "ast_string(stringify!(type_map4), types::parse_type_desc,\n \"map < address , map < u8, u256 > >\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_tuple.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_tuple.snap index 174fe061d0..d1ba76652a 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__type_tuple.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__type_tuple.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(type_tuple), types::parse_type_desc,\n \"(u8, u16, address, Map)\")" +expression: "ast_string(stringify!(type_tuple), types::parse_type_desc,\n \"(u8, u16, address, Map)\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__use_nested1.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__use_nested1.snap index d20bb93ee6..691bf40b78 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__use_nested1.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__use_nested1.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(use_nested1), module::parse_use,\n \"use foo::bar::{bing::*, bang::big, bass as fish, bong::{hello as hi, goodbye}}\")" +expression: "ast_string(stringify!(use_nested1), module::parse_use,\n \"use foo::bar::{bing::*, bang::big, bass as fish, bong::{hello as hi, goodbye}}\")" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__parse_ast__use_nested2.snap b/crates/parser/tests/cases/snapshots/cases__parse_ast__use_nested2.snap index 9390e296b5..ffe54b5dd0 100644 --- a/crates/parser/tests/cases/snapshots/cases__parse_ast__use_nested2.snap +++ b/crates/parser/tests/cases/snapshots/cases__parse_ast__use_nested2.snap @@ -1,6 +1,6 @@ --- source: crates/parser/tests/cases/parse_ast.rs -expression: "ast_string(stringify!(use_nested2), module::parse_use,\n r#\"use std::bar::{\n bing::*,\n bad::{food as burger, barge::*, bill::bob::{jkl::*}},\n evm as mve\n}\"#)" +expression: "ast_string(stringify!(use_nested2), module::parse_use,\n r#\"use std::bar::{\n bing::*,\n bad::{food as burger, barge::*, bill::bob::{jkl::*}},\n evm as mve\n}\"#)" --- Node( diff --git a/crates/parser/tests/cases/snapshots/cases__print_ast__defs.snap b/crates/parser/tests/cases/snapshots/cases__print_ast__defs.snap index ebe56f1eee..47bd8a4609 100644 --- a/crates/parser/tests/cases/snapshots/cases__print_ast__defs.snap +++ b/crates/parser/tests/cases/snapshots/cases__print_ast__defs.snap @@ -22,17 +22,15 @@ struct MyStruct { struct EmptyType {} +struct MyEvent { + field1: bool + field2: String<42> +} + contract Foo { field1: Map field2: bool - event EmptyEvent {} - - event MyEvent { - idx field1: bool - field2: String<42> - } - pub fn my_func() { std::solidity::bytes2::from_array([1, 2]) if x { diff --git a/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap b/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap index 5fc5b7ce12..61dc805a6e 100644 --- a/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap +++ b/crates/parser/tests/cases/snapshots/cases__print_ast__erc20.snap @@ -3,6 +3,18 @@ source: crates/parser/tests/cases/print_ast.rs expression: "parse_and_print(\"demos/erc20_token.fe\", src)" --- +struct Approval { + pub owner: address + pub spender: address + pub value: u256 +} + +struct Transfer { + pub from: address + pub to: address + pub value: u256 +} + contract ERC20 { _balances: Map _allowances: Map> @@ -11,18 +23,6 @@ contract ERC20 { _symbol: String<100> _decimals: u8 - event Approval { - idx owner: address - idx spender: address - value: u256 - } - - event Transfer { - idx from: address - idx to: address - value: u256 - } - pub fn __init__(self, ctx: Context, name: String<100>, symbol: String<100>) { self._name = name self._symbol = symbol @@ -87,7 +87,7 @@ contract ERC20 { _before_token_transfer(from: sender, to: recipient, value) self._balances[sender] = self._balances[sender] - value self._balances[recipient] = self._balances[recipient] + value - emit Transfer(ctx, from: sender, to: recipient, value) + ctx.emit(Transfer(from: sender, to: recipient, value)) } fn _mint(self, ctx: Context, account: address, value: u256) { @@ -95,7 +95,7 @@ contract ERC20 { _before_token_transfer(from: address(0), to: account, value) self._total_supply = self._total_supply + value self._balances[account] = self._balances[account] + value - emit Transfer(ctx, from: address(0), to: account, value) + ctx.emit(Transfer(from: address(0), to: account, value)) } fn _burn(self, ctx: Context, account: address, value: u256) { @@ -103,14 +103,14 @@ contract ERC20 { _before_token_transfer(from: account, to: address(0), value) self._balances[account] = self._balances[account] - value self._total_supply = self._total_supply - value - emit Transfer(ctx, from: account, to: address(0), value) + ctx.emit(Transfer(from: account, to: address(0), value)) } fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { assert owner != address(0) assert spender != address(0) self._allowances[owner][spender] = value - emit Approval(ctx, owner, spender, value) + ctx.emit(Approval(owner, spender, value)) } fn _setup_decimals(self, _ decimals_: u8) { diff --git a/crates/parser/tests/cases/snapshots/cases__print_ast__guest_book.snap b/crates/parser/tests/cases/snapshots/cases__print_ast__guest_book.snap index 5a7750f2ca..8643ef6392 100644 --- a/crates/parser/tests/cases/snapshots/cases__print_ast__guest_book.snap +++ b/crates/parser/tests/cases/snapshots/cases__print_ast__guest_book.snap @@ -3,16 +3,16 @@ source: crates/parser/tests/cases/print_ast.rs expression: "parse_and_print(\"demos/guest_book.fe\", src)" --- +struct Signed { + pub book_msg: String<100> +} + contract GuestBook { messages: Map> - event Signed { - book_msg: String<100> - } - pub fn sign(self, ctx: Context, book_msg: String<100>) { self.messages[ctx.msg_sender()] = book_msg - emit Signed(ctx, book_msg) + ctx.emit(Signed(book_msg)) } pub fn get_msg(self, addr: address) -> String<100> { diff --git a/crates/test-files/fixtures/compile_errors/bad_visibility/src/foo.fe b/crates/test-files/fixtures/compile_errors/bad_visibility/src/foo.fe index 2be73b7d16..ba7a7d21b3 100644 --- a/crates/test-files/fixtures/compile_errors/bad_visibility/src/foo.fe +++ b/crates/test-files/fixtures/compile_errors/bad_visibility/src/foo.fe @@ -4,10 +4,6 @@ const MY_CONST: MyInt = 1 trait MyTrait {} -event MyEvent { - x: i32 -} - struct MyStruct { x: i32 } @@ -16,4 +12,4 @@ fn my_func() {} contract MyContract { x: i32 -} +} \ No newline at end of file diff --git a/crates/test-files/fixtures/compile_errors/bad_visibility/src/main.fe b/crates/test-files/fixtures/compile_errors/bad_visibility/src/main.fe index 7c5eabd1ca..44dafa5941 100644 --- a/crates/test-files/fixtures/compile_errors/bad_visibility/src/main.fe +++ b/crates/test-files/fixtures/compile_errors/bad_visibility/src/main.fe @@ -1,4 +1,4 @@ -use foo::{MyInt, MY_CONST, MyEvent, MyStruct, MyTrait, my_func, MyContract} +use foo::{MyInt, MY_CONST, MyStruct, MyTrait, my_func, MyContract, MyEnum } struct SomeThing {} impl MyTrait for SomeThing {} @@ -13,10 +13,6 @@ contract Main { return MY_CONST } - pub fn priv_event() { - emit MyEvent(ctx, x: 1) - } - pub fn priv_struct() { let s: MyStruct = MyStruct(x: 1) } diff --git a/crates/test-files/fixtures/compile_errors/call_event_with_wrong_types.fe b/crates/test-files/fixtures/compile_errors/call_event_with_wrong_types.fe deleted file mode 100644 index de7b8a15e5..0000000000 --- a/crates/test-files/fixtures/compile_errors/call_event_with_wrong_types.fe +++ /dev/null @@ -1,10 +0,0 @@ -contract Foo { - event MyEvent { - val_1: String<5> - idx val_2: u8 - } - - pub fn foo(ctx: Context) { - emit MyEvent(ctx, val_1: "foo bar", val_2: 1000) - } -} diff --git a/crates/test-files/fixtures/compile_errors/ctx_builtins_param_incorrect_type.fe b/crates/test-files/fixtures/compile_errors/ctx_builtins_param_incorrect_type.fe index b6bfd0effd..4a21928f55 100644 --- a/crates/test-files/fixtures/compile_errors/ctx_builtins_param_incorrect_type.fe +++ b/crates/test-files/fixtures/compile_errors/ctx_builtins_param_incorrect_type.fe @@ -1,7 +1,3 @@ -event WorldMessage { - message: String<42> -} - contract Barn { pub fn cow() {} } @@ -10,6 +6,5 @@ contract Foo { pub fn bar(ctx: Context) { let existing_barn: Barn = Barn("hello world", address(0)) let created_barn: Barn = Barn.create(address(26), 0) - emit WorldMessage(42, message: "hello world") } } diff --git a/crates/test-files/fixtures/compile_errors/ctx_missing_event.fe b/crates/test-files/fixtures/compile_errors/ctx_missing_event.fe deleted file mode 100644 index 430a855bd9..0000000000 --- a/crates/test-files/fixtures/compile_errors/ctx_missing_event.fe +++ /dev/null @@ -1,9 +0,0 @@ -event HelloWorld { - message: String<26> -} - -contract Bar { - pub fn say_hello(ctx: Context) { - emit HelloWorld(message: "hello world") - } -} diff --git a/crates/test-files/fixtures/compile_errors/ctx_undefined_event.fe b/crates/test-files/fixtures/compile_errors/ctx_undefined_event.fe deleted file mode 100644 index bce08b154d..0000000000 --- a/crates/test-files/fixtures/compile_errors/ctx_undefined_event.fe +++ /dev/null @@ -1,9 +0,0 @@ -event YouWin { - amount: u256 -} - -contract Foo { - pub fn bar() { - emit YouWin(amount: 42) - } -} diff --git a/crates/test-files/fixtures/compile_errors/duplicate_event_in_contract.fe b/crates/test-files/fixtures/compile_errors/duplicate_event_in_contract.fe deleted file mode 100644 index 49f545190c..0000000000 --- a/crates/test-files/fixtures/compile_errors/duplicate_event_in_contract.fe +++ /dev/null @@ -1,9 +0,0 @@ -contract Foo { - event MyEvent { - idx addr1: address - } - - event MyEvent { - idx addr1: address - } -} diff --git a/crates/test-files/fixtures/compile_errors/emit_bad_args.fe b/crates/test-files/fixtures/compile_errors/emit_bad_args.fe deleted file mode 100644 index 66fbf135aa..0000000000 --- a/crates/test-files/fixtures/compile_errors/emit_bad_args.fe +++ /dev/null @@ -1,11 +0,0 @@ -contract Bar { - event Foo { - idx x: address - y: u256 - z: bool - } - - pub fn test(ctx: Context) { - emit Foo(ctx, (1, 2), z: 10, y: true, x: 5) - } -} diff --git a/crates/test-files/fixtures/compile_errors/emittable_not_implementable.fe b/crates/test-files/fixtures/compile_errors/emittable_not_implementable.fe new file mode 100644 index 0000000000..bb010dcb86 --- /dev/null +++ b/crates/test-files/fixtures/compile_errors/emittable_not_implementable.fe @@ -0,0 +1,9 @@ +use std::context::{Emittable, OutOfReachMarker} + +struct Custom {} + +impl Emittable for Custom { + fn emit(self, _ val: OutOfReachMarker) { + + } +} \ No newline at end of file diff --git a/crates/test-files/fixtures/compile_errors/indexed_event.fe b/crates/test-files/fixtures/compile_errors/indexed_event.fe index 9083c4df30..2b18b825d4 100644 --- a/crates/test-files/fixtures/compile_errors/indexed_event.fe +++ b/crates/test-files/fixtures/compile_errors/indexed_event.fe @@ -1,8 +1,13 @@ +struct MyEvent { + #indexed + pub addr1: address + #indexed + pub addr2: address + #indexed + pub addr3: address + #indexed + pub addr4: address +} + contract Foo { - event MyEvent { - idx addr1: address - idx addr2: address - idx addr3: address - idx addr4: address - } } diff --git a/crates/test-files/fixtures/compile_errors/invalid_struct_attribute.fe b/crates/test-files/fixtures/compile_errors/invalid_struct_attribute.fe new file mode 100644 index 0000000000..cbd70e944a --- /dev/null +++ b/crates/test-files/fixtures/compile_errors/invalid_struct_attribute.fe @@ -0,0 +1,4 @@ +struct Bar { + #invalid + id: u256 +} \ No newline at end of file diff --git a/crates/test-files/fixtures/compile_errors/not_callable.fe b/crates/test-files/fixtures/compile_errors/not_callable.fe index 48c2cb1638..4a45416a2b 100644 --- a/crates/test-files/fixtures/compile_errors/not_callable.fe +++ b/crates/test-files/fixtures/compile_errors/not_callable.fe @@ -1,16 +1,8 @@ contract Foo { - event MyEvent { - x: u8 - } - fn call_int() { 5() } - fn call_event() { - MyEvent(x: 10) - } - fn call_self(self) { self() } diff --git a/crates/test-files/fixtures/demos/erc20_token.fe b/crates/test-files/fixtures/demos/erc20_token.fe index 77edcb1a3d..c4e72c53e1 100644 --- a/crates/test-files/fixtures/demos/erc20_token.fe +++ b/crates/test-files/fixtures/demos/erc20_token.fe @@ -1,3 +1,19 @@ +struct Approval { + #indexed + pub owner: address + #indexed + pub spender: address + pub value: u256 +} + +struct Transfer { + #indexed + pub from: address + #indexed + pub to: address + pub value: u256 +} + contract ERC20 { _balances: Map _allowances: Map> @@ -6,18 +22,6 @@ contract ERC20 { _symbol: String<100> _decimals: u8 - event Approval { - idx owner: address - idx spender: address - value: u256 - } - - event Transfer { - idx from: address - idx to: address - value: u256 - } - pub fn __init__(self, ctx: Context, name: String<100>, symbol: String<100>) { self._name = name self._symbol = symbol @@ -82,7 +86,7 @@ contract ERC20 { _before_token_transfer(from: sender, to: recipient, value) self._balances[sender] = self._balances[sender] - value self._balances[recipient] = self._balances[recipient] + value - emit Transfer(ctx, from: sender, to: recipient, value) + ctx.emit(Transfer(from: sender, to: recipient, value)) } fn _mint(self, ctx: Context, account: address, value: u256) { @@ -90,7 +94,7 @@ contract ERC20 { _before_token_transfer(from: address(0), to: account, value) self._total_supply = self._total_supply + value self._balances[account] = self._balances[account] + value - emit Transfer(ctx, from: address(0), to: account, value) + ctx.emit(Transfer(from: address(0), to: account, value)) } fn _burn(self, ctx: Context, account: address, value: u256) { @@ -98,14 +102,14 @@ contract ERC20 { _before_token_transfer(from: account, to: address(0), value) self._balances[account] = self._balances[account] - value self._total_supply = self._total_supply - value - emit Transfer(ctx, from: account, to: address(0), value) + ctx.emit(Transfer(from: account, to: address(0), value)) } fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { assert owner != address(0) assert spender != address(0) self._allowances[owner][spender] = value - emit Approval(ctx, owner, spender, value) + ctx.emit(Approval(owner, spender, value)) } fn _setup_decimals(self, _ decimals_: u8) { diff --git a/crates/test-files/fixtures/demos/guest_book.fe b/crates/test-files/fixtures/demos/guest_book.fe index 99161de0f3..52726ae2cb 100644 --- a/crates/test-files/fixtures/demos/guest_book.fe +++ b/crates/test-files/fixtures/demos/guest_book.fe @@ -1,23 +1,22 @@ +// Structs can be emitted as events +struct Signed { + pub book_msg: String<100> +} + // The `contract` keyword defines a new contract type contract GuestBook { // Strings are generic over a constant number // that restricts its maximum size messages: Map> - // Events can be defined on contract or module level - event Signed { - book_msg: String<100> - } - // Context is a struct provided by the standard library // that gives access to various features of the EVM pub fn sign(self, ctx: Context, book_msg: String<100>) { // All storage access is explicit using `self.` self.messages[ctx.msg_sender()] = book_msg - // Emit the `Signed` event. In the future, this will change to: - // `ctx.emit(Signed(ctx, book_msg))` - emit Signed(ctx, book_msg) + // Emit the `Signed` event. + ctx.emit(Signed(book_msg)) } pub fn get_msg(self, addr: address) -> String<100> { diff --git a/crates/test-files/fixtures/demos/simple_open_auction.fe b/crates/test-files/fixtures/demos/simple_open_auction.fe index 643f695f0d..5b8a6fec13 100644 --- a/crates/test-files/fixtures/demos/simple_open_auction.fe +++ b/crates/test-files/fixtures/demos/simple_open_auction.fe @@ -7,6 +7,19 @@ struct BidNotHighEnough { pub highest_bid: u256 } +// events +struct HighestBidIncreased { + #indexed + pub bidder: address + pub amount: u256 +} + +struct AuctionEnded { + #indexed + pub winner: address + pub amount: u256 +} + contract SimpleOpenAuction { // states auction_end_time: u256 @@ -19,17 +32,6 @@ contract SimpleOpenAuction { ended: bool - // events - event HighestBidIncreased { - idx bidder: address - amount: u256 - } - - event AuctionEnded { - idx winner: address - amount: u256 - } - // constructor pub fn __init__(self, ctx: Context, bidding_time: u256, beneficiary_addr: address) { self.beneficiary = beneficiary_addr @@ -50,7 +52,7 @@ contract SimpleOpenAuction { self.highest_bidder = ctx.msg_sender() self.highest_bid = ctx.msg_value() - emit HighestBidIncreased(ctx, bidder: ctx.msg_sender(), amount: ctx.msg_value()) + ctx.emit(HighestBidIncreased(bidder: ctx.msg_sender(), amount: ctx.msg_value())) } pub fn withdraw(self, ctx: Context) -> bool { @@ -71,7 +73,7 @@ contract SimpleOpenAuction { revert AuctionEndAlreadyCalled() } self.ended = true - emit AuctionEnded(ctx, winner: self.highest_bidder, amount: self.highest_bid) + ctx.emit(AuctionEnded(winner: self.highest_bidder, amount: self.highest_bid)) ctx.send_value(to: self.beneficiary, wei: self.highest_bid) } diff --git a/crates/test-files/fixtures/demos/uniswap.fe b/crates/test-files/fixtures/demos/uniswap.fe index 4519c9b0b4..c2dd1a2f68 100644 --- a/crates/test-files/fixtures/demos/uniswap.fe +++ b/crates/test-files/fixtures/demos/uniswap.fe @@ -8,6 +8,54 @@ contract ERC20 { } } +struct Approval { + #indexed + pub owner: address + #indexed + pub spender: address + pub value: u256 +} + +struct Transfer { + #indexed + pub from: address + #indexed + pub to: address + pub value: u256 +} + +struct Mint { + #indexed + pub sender: address + pub amount0: u256 + pub amount1: u256 +} + +struct Burn { + #indexed + pub sender: address + pub amount0: u256 + pub amount1: u256 + #indexed + pub to: address +} + +struct Swap { + #indexed + pub sender: address + pub amount0_in: u256 + pub amount1_in: u256 + pub amount0_out: u256 + pub amount1_out: u256 + #indexed + pub to: address +} + +struct Sync { + pub reserve0: u256 + pub reserve1: u256 +} + contract UniswapV2Pair { // TODO: const support (https://github.com/ethereum/fe/issues/192) // const MINIMUM_LIQUIDITY: u256 = 1000 @@ -30,45 +78,6 @@ contract UniswapV2Pair { price1_cumulative_last: u256 k_last: u256 - event Approval { - idx owner: address - idx spender: address - value: u256 - } - - event Transfer { - idx from: address - idx to: address - value: u256 - } - - event Mint { - idx sender: address - amount0: u256 - amount1: u256 - } - - event Burn { - idx sender: address - amount0: u256 - amount1: u256 - idx to: address - } - - event Swap { - idx sender: address - amount0_in: u256 - amount1_in: u256 - amount0_out: u256 - amount1_out: u256 - idx to: address - } - - event Sync { - reserve0: u256 - reserve1: u256 - } - pub fn __init__(self, ctx: Context) { self.factory = ctx.msg_sender() } @@ -88,24 +97,24 @@ contract UniswapV2Pair { fn _mint(self, ctx: Context, to: address, value: u256) { self.total_supply = self.total_supply + value self.balances[to] = self.balances[to] + value - emit Transfer(ctx, from: address(0), to, value) + ctx.emit(Transfer(from: address(0), to, value)) } fn _burn(self, ctx: Context, from: address, value: u256) { self.balances[from] = self.balances[from] - value self.total_supply = self.total_supply - value - emit Transfer(ctx, from, to: address(0), value) + ctx.emit(Transfer(from, to: address(0), value)) } fn _approve(self, ctx: Context, owner: address, spender: address, value: u256) { self.allowances[owner][spender] = value - emit Approval(ctx, owner, spender, value) + ctx.emit(Approval(owner, spender, value)) } fn _transfer(self, ctx: Context, from: address, to: address, value: u256) { self.balances[from] = self.balances[from] - value self.balances[to] = self.balances[to] + value - emit Transfer(ctx, from, to, value) + ctx.emit(Transfer(from, to, value)) } pub fn approve(self, ctx: Context, spender: address, value: u256) -> bool { @@ -153,7 +162,7 @@ contract UniswapV2Pair { self.reserve0 = balance0 self.reserve1 = balance1 self.block_timestamp_last = block_timestamp - emit Sync(ctx, reserve0: self.reserve0, reserve1: self.reserve1) + ctx.emit(Sync(reserve0: self.reserve0, reserve1: self.reserve1)) } fn _mint_fee(self, ctx: Context, reserve0: u256, reserve1: u256) -> bool { @@ -203,7 +212,7 @@ contract UniswapV2Pair { if fee_on { self.k_last = reserve0 * reserve1 // reserve0 and reserve1 are up-to-date } - emit Mint(ctx, sender: ctx.msg_sender(), amount0, amount1) + ctx.emit(Mint(sender: ctx.msg_sender(), amount0, amount1)) return liquidity } @@ -231,7 +240,7 @@ contract UniswapV2Pair { if fee_on { self.k_last = reserve0 * reserve1 } - emit Burn(ctx, sender: ctx.msg_sender(), amount0, amount1, to) + ctx.emit(Burn(sender: ctx.msg_sender(), amount0, amount1, to)) return (amount0, amount1) } @@ -274,7 +283,7 @@ contract UniswapV2Pair { assert balance0_adjusted * balance1_adjusted >= reserve0 * reserve1 * 1000000, "UniswapV2: K" self._update(ctx, balance0, balance1, reserve0, reserve1) - emit Swap(ctx, sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to) + ctx.emit(Swap(sender: ctx.msg_sender(), amount0_in, amount1_in, amount0_out, amount1_out, to)) } // force balances to match reserves @@ -297,6 +306,15 @@ contract UniswapV2Pair { } } +struct PairCreated { + #indexed + pub token0: address + #indexed + pub token1: address + pub pair: address + pub index: u256 +} + contract UniswapV2Factory { fee_to: address fee_to_setter: address @@ -306,13 +324,6 @@ contract UniswapV2Factory { all_pairs: Array pair_counter: u256 - event PairCreated { - idx token0: address - idx token1: address - pair: address - index: u256 - } - pub fn __init__(self, _ fee_to_setter: address) { self.fee_to_setter = fee_to_setter } @@ -346,7 +357,7 @@ contract UniswapV2Factory { self.all_pairs[self.pair_counter] = address(pair) self.pair_counter = self.pair_counter + 1 - emit PairCreated(ctx, token0, token1, pair: address(pair), index: self.pair_counter) + ctx.emit(PairCreated(token0, token1, pair: address(pair), index: self.pair_counter)) return address(pair) } diff --git a/crates/test-files/fixtures/features/events.fe b/crates/test-files/fixtures/features/events.fe index 3fc4a325e7..54dccf4cc1 100644 --- a/crates/test-files/fixtures/features/events.fe +++ b/crates/test-files/fixtures/features/events.fe @@ -1,41 +1,44 @@ -contract Foo { - event Nums { - idx num1: u256 - num2: u256 - } +pub struct Nums { + #indexed + pub num1: u256 + pub num2: u256 +} - event Bases { - num: u256 - addr: address - } +pub struct Bases { + pub num: u256 + pub addr: address +} - event Mix { - num1: u256 - idx addr: address - num2: u256 - my_bytes: Array - } +pub struct Mix { + pub num1: u256 + #indexed + pub addr: address + pub num2: u256 + pub my_bytes: Array +} - event Addresses { - addrs: Array - } +pub struct Addresses { + pub addrs: Array +} + +contract Foo { pub fn emit_nums(ctx: Context) { - emit Nums(ctx, num1: 26, num2: 42) + ctx.emit(Nums(num1: 26, num2: 42)) } pub fn emit_bases(ctx: Context, addr: address) { - emit Bases(ctx, num: 26, addr) + ctx.emit(Bases(num: 26, addr)) } pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array) { - emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) + ctx.emit(Mix(num1: 26, addr, num2: 42, my_bytes)) } pub fn emit_addresses(ctx: Context, addr1: address, addr2: address) { let addrs: Array = [address(0); 2] addrs[0] = addr1 addrs[1] = addr2 - emit Addresses(ctx, addrs) + ctx.emit(Addresses(addrs)) } } diff --git a/crates/test-files/fixtures/features/external_contract.fe b/crates/test-files/fixtures/features/external_contract.fe index c160d3802e..0ddb4b4c28 100644 --- a/crates/test-files/fixtures/features/external_contract.fe +++ b/crates/test-files/fixtures/features/external_contract.fe @@ -1,12 +1,13 @@ +struct MyEvent { + pub my_num: u256 + pub my_addrs: Array + pub my_string: String<11> +} + contract Foo { - event MyEvent { - my_num: u256 - my_addrs: Array - my_string: String<11> - } pub fn emit_event(self, ctx: Context, my_num: u256, my_addrs: Array, my_string: String<11>) { - emit MyEvent(ctx, my_num, my_addrs, my_string) + ctx.emit(MyEvent(my_num, my_addrs, my_string)) } pub fn build_array(self, a: u256, b: u256) -> Array { diff --git a/crates/test-files/fixtures/features/module_level_events.fe b/crates/test-files/fixtures/features/module_level_events.fe index 82bd668558..6a412960f6 100644 --- a/crates/test-files/fixtures/features/module_level_events.fe +++ b/crates/test-files/fixtures/features/module_level_events.fe @@ -1,11 +1,13 @@ -event Transfer { - idx sender: address - idx receiver: address - value: u256 +struct Transfer { + #indexed + pub sender: address + #indexed + pub receiver: address + pub value: u256 } contract Foo { fn transfer(ctx: Context, to: address, value: u256) { - emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) + ctx.emit(Transfer(sender: ctx.msg_sender(), receiver: to, value)) } } diff --git a/crates/test-files/fixtures/features/ownable.fe b/crates/test-files/fixtures/features/ownable.fe index dda3b365a5..258b5469e9 100644 --- a/crates/test-files/fixtures/features/ownable.fe +++ b/crates/test-files/fixtures/features/ownable.fe @@ -1,11 +1,13 @@ +struct OwnershipTransferred { + #indexed + pub previousOwner: address + #indexed + pub newOwner: address +} + contract Ownable { _owner: address - event OwnershipTransferred { - idx previousOwner: address - idx newOwner: address - } - pub fn __init__(self, ctx: Context) { self._owner = ctx.msg_sender() } @@ -17,13 +19,13 @@ contract Ownable { pub fn renounceOwnership(self, ctx: Context) { assert ctx.msg_sender() == self._owner self._owner = address(0) - emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner: address(0)) + ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner: address(0))) } pub fn transferOwnership(self, ctx: Context, newOwner: address) { assert ctx.msg_sender() == self._owner assert newOwner != address(0) self._owner = newOwner - emit OwnershipTransferred(ctx, previousOwner: ctx.msg_sender(), newOwner) + ctx.emit(OwnershipTransferred(previousOwner: ctx.msg_sender(), newOwner)) } } diff --git a/crates/test-files/fixtures/features/sized_vals_in_sto.fe b/crates/test-files/fixtures/features/sized_vals_in_sto.fe index bddded7613..b16e14700a 100644 --- a/crates/test-files/fixtures/features/sized_vals_in_sto.fe +++ b/crates/test-files/fixtures/features/sized_vals_in_sto.fe @@ -1,14 +1,14 @@ +struct MyEvent { + pub num: u256 + pub nums: Array + pub str: String<26> +} + contract Foo { num: u256 nums: Array str: String<26> - event MyEvent { - num: u256 - nums: Array - str: String<26> - } - pub fn write_num(self, x: u256) { self.num = x } @@ -34,6 +34,6 @@ contract Foo { } pub fn emit_event(self, ctx: Context) { - emit MyEvent(ctx, num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem()) + ctx.emit(MyEvent(num: self.num, nums: self.nums.to_mem(), str: self.str.to_mem())) } } diff --git a/crates/test-files/fixtures/features/strings.fe b/crates/test-files/fixtures/features/strings.fe index 5a2da2354a..941fe3f052 100644 --- a/crates/test-files/fixtures/features/strings.fe +++ b/crates/test-files/fixtures/features/strings.fe @@ -1,16 +1,17 @@ +struct MyEvent { + pub s2: String<26> + pub u: u256 + pub s1: String<42> + pub s3: String<100> + pub a: address + pub s4: String<18> + pub s5: String<100> +} + contract Foo { - event MyEvent { - s2: String<26> - u: u256 - s1: String<42> - s3: String<100> - a: address - s4: String<18> - s5: String<100> - } pub fn __init__(ctx: Context, s1: String<42>, a: address, s2: String<26>, u: u256, s3: String<100>) { - emit MyEvent(ctx, s2, u, s1, s3, a, s4: "static string", s5: String<100>("foo")) + ctx.emit(MyEvent(s2, u, s1, s3, a, s4: "static string", s5: String<100>("foo"))) } pub fn bar(s1: String<100>, s2: String<100>) -> String<100> { diff --git a/crates/test-files/fixtures/printing/defs.fe b/crates/test-files/fixtures/printing/defs.fe index 43a4076567..58d501b064 100644 --- a/crates/test-files/fixtures/printing/defs.fe +++ b/crates/test-files/fixtures/printing/defs.fe @@ -17,17 +17,16 @@ struct MyStruct { struct EmptyType {} +struct MyEvent { + #indexed + field1: bool + field2: String<42> +} + contract Foo { field1: Map field2: bool - event EmptyEvent {} - - event MyEvent { - idx field1: bool - field2: String<42> - } - pub fn my_func() { std::solidity::bytes2::from_array([1, 2]) if x { diff --git a/crates/test-files/fixtures/stress/abi_encoding_stress.fe b/crates/test-files/fixtures/stress/abi_encoding_stress.fe index 7085c109ae..8a13a5860e 100644 --- a/crates/test-files/fixtures/stress/abi_encoding_stress.fe +++ b/crates/test-files/fixtures/stress/abi_encoding_stress.fe @@ -5,6 +5,15 @@ struct MyStruct { pub my_addr: address } +struct MyEvent { + pub my_addrs: Array + pub my_u128: u128 + pub my_string: String<10> + pub my_u16s: Array + pub my_bool: bool + pub my_bytes: Array +} + contract Foo { my_addrs: Array my_u128: u128 @@ -13,15 +22,6 @@ contract Foo { my_bool: bool my_bytes: Array - event MyEvent { - my_addrs: Array - my_u128: u128 - my_string: String<10> - my_u16s: Array - my_bool: bool - my_bytes: Array - } - pub fn set_my_addrs(self, my_addrs: Array) { self.my_addrs = my_addrs } @@ -83,6 +83,6 @@ contract Foo { } pub fn emit_my_event(self, ctx: Context) { - emit MyEvent(ctx, my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem()) + ctx.emit(MyEvent(my_addrs: self.my_addrs.to_mem(), my_u128: self.my_u128, my_string: self.my_string.to_mem(), my_u16s: self.my_u16s.to_mem(), my_bool: self.my_bool, my_bytes: self.my_bytes.to_mem())) } } diff --git a/crates/test-files/fixtures/stress/data_copying_stress.fe b/crates/test-files/fixtures/stress/data_copying_stress.fe index f0c4a82a59..fc9de7b436 100644 --- a/crates/test-files/fixtures/stress/data_copying_stress.fe +++ b/crates/test-files/fixtures/stress/data_copying_stress.fe @@ -1,3 +1,8 @@ +struct MyEvent { + pub my_string: String<42> + pub my_u256: u256 +} + contract Foo { my_string: String<42> my_other_string: String<42> @@ -6,11 +11,6 @@ contract Foo { my_nums: Array my_addrs: Array - event MyEvent { - my_string: String<42> - my_u256: u256 - } - pub fn set_my_vals(self, my_string: String<42>, my_other_string: String<42>, my_u256: u256, my_other_u256: u256) { self.my_string = my_string self.my_other_string = my_other_string @@ -67,7 +67,7 @@ contract Foo { } fn emit_my_event_internal(ctx: Context, _ my_string: String<42>, _ my_u256: u256) { - emit MyEvent(ctx, my_string, my_u256) + ctx.emit(MyEvent(my_string, my_u256)) } pub fn set_my_addrs(self, my_addrs: Array) { diff --git a/crates/test-files/fixtures/stress/tuple_stress.fe b/crates/test-files/fixtures/stress/tuple_stress.fe index 89a3aaaa12..aad920f2e4 100644 --- a/crates/test-files/fixtures/stress/tuple_stress.fe +++ b/crates/test-files/fixtures/stress/tuple_stress.fe @@ -1,10 +1,10 @@ +struct MyEvent { + pub my_tuple: (u256, bool, address) +} + contract Foo { my_sto_tuple: (u256, i32) - event MyEvent { - my_tuple: (u256, bool, address) - } - pub fn build_my_tuple(my_num: u256, my_bool: bool, my_address: address) -> (u256, bool, address) { return (my_num, my_bool, my_address) } @@ -26,7 +26,7 @@ contract Foo { } pub fn emit_my_event(ctx: Context, my_tuple: (u256, bool, address)) { - emit MyEvent(ctx, my_tuple) + ctx.emit(MyEvent(my_tuple)) } pub fn set_my_sto_tuple(self, my_u256: u256, my_i32: i32) { diff --git a/crates/tests/src/features.rs b/crates/tests/src/features.rs index ffc2467ba9..8d8f597ca9 100644 --- a/crates/tests/src/features.rs +++ b/crates/tests/src/features.rs @@ -2043,7 +2043,6 @@ fn abi_decode_complex() { let dynamic_complex_array = ethabi::Token::FixedArray(std::iter::repeat(nested_dynamic_complex).take(3).collect()); - dbg!(ethabi::encode(&[dynamic_complex_array.clone()]).len()); harness.test_function( &mut executor, "decode_dynamic_complex_elem_array", diff --git a/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts-2.snap b/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts-2.snap index 3902443b03..4f3a7e0e99 100644 --- a/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts-2.snap +++ b/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts-2.snap @@ -3,5 +3,5 @@ source: crates/tests/src/demo_uniswap.rs expression: "format!(\"{}\", factory_harness.gas_reporter)" --- -create_pair([Address(0x5dddfce53ee040d9eb21afbc0ae1bb4dbb0ba643), Address(0x5f8bd49cd9f0cb2bd5bb9d4320dfe9b61023249d)]) used 1541680 gas +create_pair([Address(0x5dddfce53ee040d9eb21afbc0ae1bb4dbb0ba643), Address(0x5f8bd49cd9f0cb2bd5bb9d4320dfe9b61023249d)]) used 1539870 gas diff --git a/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts.snap b/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts.snap index 79d956ffab..85c6a0a008 100644 --- a/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts.snap +++ b/crates/tests/src/snapshots/fe_compiler_tests__demo_uniswap__uniswap_contracts.snap @@ -12,7 +12,7 @@ balanceOf([Address(0x0000000000000000000000000000000000000000)]) used 621 gas get_reserves([]) used 797 gas swap([Uint(1993), Uint(0), Address(0x0000000000000000000000000000000000000042)]) used 36362 gas get_reserves([]) used 797 gas -transfer([Address(0x57a4f26f3614afce2434dd6bb3931ce32644dd26), Uint(141421356237309503880)]) used 5795 gas -burn([Address(0x1000000000000000000000000000000000000001)]) used 3634 gas +transfer([Address(0x3cebee86eadd50bcd84fcb6c6a4fae52b8ce8feb), Uint(141421356237309503880)]) used 5795 gas +burn([Address(0x1000000000000000000000000000000000000001)]) used 3669 gas get_reserves([]) used 797 gas diff --git a/crates/tests/src/snapshots/fe_compiler_tests__stress__abi_encoding_stress.snap b/crates/tests/src/snapshots/fe_compiler_tests__stress__abi_encoding_stress.snap index 7045cf7068..7ce0eb29c1 100644 --- a/crates/tests/src/snapshots/fe_compiler_tests__stress__abi_encoding_stress.snap +++ b/crates/tests/src/snapshots/fe_compiler_tests__stress__abi_encoding_stress.snap @@ -14,8 +14,8 @@ get_my_u16s([]) used 26296 gas set_my_bool([Bool(true)]) used 550 gas get_my_bool([]) used 463 gas set_my_bytes([Bytes([116, 101, 110, 32, 98, 121, 116, 101, 115, 46, 116, 101, 110, 32, 98, 121, 116, 101, 115, 46, 116, 101, 110, 32, 98, 121, 116, 101, 115, 46, 116, 101, 110, 32, 98, 121, 116, 101, 115, 46, 116, 101, 110, 32, 98, 121, 116, 101, 115, 46, 116, 101, 110, 32, 98, 121, 116, 101, 115, 46, 116, 101, 110, 32, 98, 121, 116, 101, 115, 46, 116, 101, 110, 32, 98, 121, 116, 101, 115, 46, 116, 101, 110, 32, 98, 121, 116, 101, 115, 46, 116, 101, 110, 32, 98, 121, 116, 101, 115, 46])]) used 89387 gas -get_my_bytes([]) used 1789 gas +get_my_bytes([]) used 1791 gas get_my_struct([]) used 769 gas mod_my_struct([Tuple([Uint(42), Uint(26), Bool(true), Address(0x000000000000000000000000000000000001e240)])]) used 1132 gas -emit_my_event([]) used 103821 gas +emit_my_event([]) used 103823 gas diff --git a/docs/src/release_notes.md b/docs/src/release_notes.md index 8c300ff796..dd51a93455 100644 --- a/docs/src/release_notes.md +++ b/docs/src/release_notes.md @@ -44,7 +44,7 @@ Fe is moving fast. Read up on all the latest improvements. Example: - ```fe + ```fe,ignore use std::context::Context // see issue #679 contract Foo { diff --git a/docs/src/spec/index.md b/docs/src/spec/index.md index 002edf9151..7b932ccfd2 100644 --- a/docs/src/spec/index.md +++ b/docs/src/spec/index.md @@ -14,7 +14,6 @@ * [Visibility and Privacy](items/visibility_and_privacy.md) * [Functions](items/functions.md) * [Structs](items/structs.md) - * [Events](items/events.md) * [Enums](items/enums.md) * [Type Aliases](items/type_aliases.md) * [Contracts](items/contracts.md) @@ -26,7 +25,6 @@ * [`let` Statement](statements/let.md) * [`revert` Statement](statements/revert.md) * [`return` Statement](statements/return.md) - * [`emit` Statement](statements/emit.md) * [`if` Statement](statements/if.md) * [`for` Statement](statements/for.md) * [`while` Statement](statements/while.md) diff --git a/docs/src/spec/items/contracts.md b/docs/src/spec/items/contracts.md index 90aaba89c3..01be0fd493 100644 --- a/docs/src/spec/items/contracts.md +++ b/docs/src/spec/items/contracts.md @@ -28,16 +28,16 @@ An example of a `contract`: ```fe +struct Signed { + pub book_msg: String<100> +} + contract GuestBook { messages: Map> - event Signed { - book_msg: String<100> - } - pub fn sign(self, ctx: Context, book_msg: String<100>) { self.messages[ctx.msg_sender()] = book_msg - emit Signed(ctx, book_msg: book_msg) + ctx.emit(Signed(book_msg: book_msg)) } pub fn get_msg(self, addr: address) -> String<100> { diff --git a/docs/src/spec/items/events.md b/docs/src/spec/items/events.md deleted file mode 100644 index da67659b03..0000000000 --- a/docs/src/spec/items/events.md +++ /dev/null @@ -1,38 +0,0 @@ -# Events - -> **Syntax**\ -> _Event_ :\ ->    `event` [IDENTIFIER] `{` ->    _EventField_\*\ ->    `}` -> -> _EventField_ :\ ->    _EventIndexability_ [IDENTIFIER] `:` [_Type_]\ -> -> _EventIndexability_ :\ ->    `idx`? - -An _event_ is a nominal [event type] defined with the keyword `event`. It is emitted with the keyword `emit`. - -An example of a `event` item and its use: - -```fe -contract Foo { - event Transfer { - idx sender: address - idx receiver: address - value: u256 - } - - fn transfer(ctx: Context, to: address, value: u256) { - // Heavy logic here - // All done, log the event for listeners - emit Transfer(ctx, sender: ctx.msg_sender(), receiver: to, value) - } -} -``` - -[NEWLINE]: ../lexical_structure/tokens.md#newline -[IDENTIFIER]: ../lexical_structure/identifiers.md -[_Type_]: ../type_system/types/index.md -[event type]: ../type_system/types/event.md diff --git a/docs/src/spec/items/index.md b/docs/src/spec/items/index.md index d9ab1ea2f8..b9054e91fb 100644 --- a/docs/src/spec/items/index.md +++ b/docs/src/spec/items/index.md @@ -3,7 +3,6 @@ * [Visibility and Privacy](./visibility_and_privacy.md) * [Functions](./functions.md) * [Structs](./structs.md) -* [Events](./events.md) * [Enums](./enums.md) * [Type Aliases](./type_aliases.md) * [Contracts](./contracts.md) \ No newline at end of file diff --git a/docs/src/spec/statements/emit.md b/docs/src/spec/statements/emit.md deleted file mode 100644 index 4984f419d5..0000000000 --- a/docs/src/spec/statements/emit.md +++ /dev/null @@ -1,43 +0,0 @@ -# `emit` statement - - -> **Syntax**\ -> _EmitStatement_ :\ ->    `emit` _EventLiteral_ `(` _CallParams_? `)` -> -> _EventLiteral_ :\ ->    [IDENTIFIER]Name of event defined in current module -> -> _CallParams_ :\ ->    _CallArg_ ( `,` _CallArg_ )\* `,`? -> -> _CallArg_ :\ ->    (_CallArgLabel_ `:`)? [_Expression_] -> -> _CallArgLabel_ :\ ->    [IDENTIFIER]Label must correspond to the name of the event property at the given position. It can be omitted if parameter name and event property name are equal. - -The `emit` statement is used to create [log entries] in the blockchain. The `emit` keyword is followed by a literal that corresponds to a defined event, followed by a parenthesized comma-separated list of expressions. - - -Examples: - -```fe -contract Foo { - event Mix { - num1: u256 - idx addr: address - num2: u256 - my_bytes: Array - } - pub fn emit_mix(ctx: Context, addr: address, my_bytes: Array) { - emit Mix(ctx, num1: 26, addr, num2: 42, my_bytes) - } -} -``` - -[_Expression_]: ../expressions/index.md -[IDENTIFIER]: ../lexical_structure/identifiers.md -[struct]: ../items/structs.md -[EIP-838]: https://github.com/ethereum/EIPs/issues/838 -[log entries]: https://ethereum.stackexchange.com/questions/12950/what-are-solidity-events-and-how-they-are-related-to-topics-and-logs/12951#12951 diff --git a/docs/src/spec/statements/index.md b/docs/src/spec/statements/index.md index 4fdd73eaa6..f7feb5a28e 100644 --- a/docs/src/spec/statements/index.md +++ b/docs/src/spec/statements/index.md @@ -7,7 +7,6 @@ * [Augmenting Assignment Statement](./augassign.md) * [revert Statement](./revert.md) * [return Statemetn](./return.md) -* [emit Statement](./emit.md) * [if Statement](./if.md) * [for Statement](./for.md) * [while Statement](./while.md) diff --git a/docs/src/spec/type_system/types/event.md b/docs/src/spec/type_system/types/event.md deleted file mode 100644 index 2ccdc1b23a..0000000000 --- a/docs/src/spec/type_system/types/event.md +++ /dev/null @@ -1,5 +0,0 @@ -# Event types - -An *event type* is the type denoted by the name of an [`event` item]. - -[`event` item]: ../../items/events.md \ No newline at end of file diff --git a/newsfragments/717.feature.md b/newsfragments/717.feature.md new file mode 100644 index 0000000000..36f6771b15 --- /dev/null +++ b/newsfragments/717.feature.md @@ -0,0 +1,22 @@ +Removed the `event` type as well as the `emit` keyword. +Instead the `struct` type now automatically implements +the `Emittable` trait and can be emitted via `ctx.emit(..)`. + +Indexed fields can be annotated via the `#indexed` attribute. + +E.g. + +``` +struct Signed { + book_msg: String<100> +} + +contract GuestBook { + messages: Map> + + pub fn sign(self, ctx: Context, book_msg: String<100>) { + self.messages[ctx.msg_sender()] = book_msg + ctx.emit(Signed(book_msg: book_msg)) + } +} +```