diff --git a/src/ape/contracts/base.py b/src/ape/contracts/base.py index 486dd89d50..cc27dd8880 100644 --- a/src/ape/contracts/base.py +++ b/src/ape/contracts/base.py @@ -648,6 +648,7 @@ def query( f"'stop={stop_block}' cannot be greater than " f"the chain length ({self.chain_manager.blocks.height})." ) + query: dict = { "columns": list(ContractLog.model_fields) if columns[0] == "*" else columns, "event": self.abi, @@ -665,7 +666,13 @@ def query( ) columns_ls = validate_and_expand_columns(columns, ContractLog) data = map(partial(extract_fields, columns=columns_ls), contract_events) - return pd.DataFrame(columns=columns_ls, data=data) + df = pd.DataFrame(columns=columns_ls, data=data) + # Note: The below check is to check for `event_arguments` in the request. + # If `event_arguments` exists in the request, we flatten the field. + if "event_arguments" in columns_ls: + event_arguments = df["event_arguments"].apply(pd.Series) + df = pd.concat([df.drop("event_arguments", axis=1), event_arguments], axis=1) + return df def range( self,