cairo
cairo copied to clipboard
bug: missing type in abi for a struct only used as event parameter
Bug Report
Abi is missing type infos for a struct only used as an event parameter It make it hard to parse event without type infos from abi.
Cairo version:
1.1.0 2.0.0-rc2
Current behavior:
missing in abi
{
"type": "struct",
"name": "events::events::EventInfo",
"members": [
{
"name": "a",
"type": "core::felt252"
},
]
},
Expected behavior:
to be generated in abi
Related code:
#[derive(Drop, Serde, Copy)]
struct EventInfo {
a: felt252,
}
#[contract]
mod Contract {
use serde::Serde;
use super::EventInfo;
struct Storage {
balance: felt252,
}
#[event]
fn BalanceChanged(prev_balance: felt252, balance: felt252) {}
#[event]
fn ComplexEvent(event_info: EventInfo) {}
#[constructor]
fn constructor(initial_balance: felt252) {
balance::write(initial_balance);
}
#[external]
fn send_events() {
BalanceChanged(0, 42);
let event_info = EventInfo {
a: 'abc'
};
ComplexEvent(event_info);
}
}
quick 2.0.0-rc2 test
#[derive(Drop, Serde, Copy)]
struct EventInfo {
a: felt252,
}
#[starknet::contract]
mod Contract {
use serde::Serde;
use super::EventInfo;
#[storage]
struct Storage {
balance: felt252,
}
#[event]
fn BalanceChanged(prev_balance: felt252, balance: felt252) {}
#[event]
fn ComplexEvent(event_info: EventInfo) {}
#[constructor]
fn constructor(ref self: ContractState, initial_balance: felt252) {
self.balance.write(initial_balance);
}
#[external]
fn send_events(ref self: ContractState) {
BalanceChanged(0, 42);
let event_info = EventInfo {
a: 'abc'
};
ComplexEvent(event_info);
}
}
using "old" syntax :
#[event]
fn ComplexEvent(event_info: EventInfo) {}
contract compiles, but EventInfo type is not generated (tested with 2.0.0-rc3)