Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sol-macro): correct TypeArray::is_abi_dynamic #353

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions crates/sol-types/tests/sol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ fn rust_keywords() {
}

// TODO
// https://github.com/alloy-rs/core/issues/347
// https://github.com/alloy-rs/core/issues/351
#[test]
#[cfg(TODO)]
fn contract_type() {
Expand All @@ -469,6 +471,19 @@ fn contract_type() {
}
}

// https://github.com/alloy-rs/core/issues/352
#[test]
fn word_dynarray_event() {
sol! {
event Dynamic1(string[] indexed);
event Dynamic2(string[] indexed, bytes[] indexed);

event Word1(address[] indexed);
event Word2(address[] indexed, bytes32[] indexed);
event Word3(address[] indexed, bytes32[] indexed, uint256[] indexed);
}
}

// TODO: make commented out code work
#[test]
fn paths_resolution_1() {
Expand Down
15 changes: 14 additions & 1 deletion crates/syn-solidity/src/item/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
kw, utils::DebugPunctuated, ParameterList, SolIdent, Spanned, Type, VariableDeclaration,
};
use proc_macro2::Span;
use std::fmt::{self, Debug};
use std::fmt;
use syn::{
parenthesized,
parse::{Parse, ParseStream},
Expand Down Expand Up @@ -178,6 +178,19 @@ pub struct EventParameter {
pub name: Option<SolIdent>,
}

impl fmt::Display for EventParameter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.ty.fmt(f)?;
if self.indexed.is_some() {
f.write_str(" indexed")?;
}
if let Some(name) = &self.name {
write!(f, " {name}")?;
}
Ok(())
}
}

impl fmt::Debug for EventParameter {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("EventParameter")
Expand Down
4 changes: 2 additions & 2 deletions crates/syn-solidity/src/type/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ impl TypeArray {
/// See [`Type::is_abi_dynamic`].
pub fn is_abi_dynamic(&self) -> bool {
match self.size {
Some(_) => false,
None => self.ty.is_abi_dynamic(),
Some(_) => self.ty.is_abi_dynamic(),
None => true,
}
}

Expand Down
Loading