Open grum-tez opened 2 weeks ago
EDIT + HACKY FIX: The problem, as best I can tell, is that the from_mich static in the new_challenger_registered class in the dapp bindings expects an Mpair but recieves an Array of micheline objects in the form of Mstring, Mint etc (see the achetype types library). My current workaround is to edit the event classes directly in the bindings so if they receieve an array of this type the process it correctly, until this is addressed.
Example of a working class in the bindings:
export class new_challenger_registered implements att.ArchetypeType {
constructor(public new_challenger_address: att.Address, public new_challenger_fighter_id: att.Nat, public new_challenger_fight_history: Array<fight_record>, public new_challenger_fight_count: att.Nat, public new_challenger_c_mode: att.Nat) { }
toString(): string {
return JSON.stringify(this, null, 2);
}
to_mich(): att.Micheline {
return att.pair_to_mich([this.new_challenger_address.to_mich(), this.new_challenger_fighter_id.to_mich(), att.list_to_mich(this.new_challenger_fight_history, x => {
return x.to_mich();
}), this.new_challenger_fight_count.to_mich(), this.new_challenger_c_mode.to_mich()]);
}
equals(v: new_challenger_registered): boolean {
return att.micheline_equals(this.to_mich(), v.to_mich());
}
static from_mich(input: att.Micheline): new_challenger_registered {
let args: att.Micheline[];
if (Array.isArray(input)) {
args = input;
} else {
args = (input as att.Mpair).args;
}
const new_challenger_address = att.Address.from_mich(args[0]);
const new_challenger_fighter_id = att.Nat.from_mich(args[1]);
const new_challenger_fight_history = att.mich_to_list(args[2], x => fight_record.from_mich(x));
const new_challenger_fight_count = att.Nat.from_mich(args[3]);
const new_challenger_c_mode = att.Nat.from_mich(args[4]);
return new new_challenger_registered(
new_challenger_address,
new_challenger_fighter_id,
new_challenger_fight_history,
new_challenger_fight_count,
new_challenger_c_mode
);
}
}
This .arl:
Produces this class which fails with a type error testing in mockup or in the browser:
Updating the from_mich static to this code (generated with LLM) resolves the error:
The error does not appear if only one or two variables are emitted.
When investigating this previously I noticed that the format of the emitted event data changes when more than 3 variables are output.
Error in browser:
Line 18 is the static from_mich