dojo icon indicating copy to clipboard operation
dojo copied to clipboard

[BUG] Typescript bindings: structs not exported

Open rsodre opened this issue 8 months ago • 5 comments
trafficstars

Describe the bug Structs used in contract calls, but not in any models, are not being exported.

To Reproduce

Generate typescript bindgens for a contract with a call like this... ( from pistols/fools branch)

// https://github.com/underware-gg/pistols/blob/fools/dojo/src/systems/game.cairo
use pistols::types::rules::{RewardValues};
#[starknet::interface]
pub trait IGame<TState> {
  // ...
  fn calc_season_reward(self: @TState, table_id: felt252, duelist_id: u128, lives_staked: u8) -> RewardValues;
  // ...
}

// https://github.com/underware-gg/pistols/blob/fools/dojo/src/systems/bank.cairo
use pistols::models::pool::{PoolType, LordsReleaseBill};
#[starknet::interface]
pub trait IBank<TState> {
  // ...
  fn release_lords_from_fame_to_be_burned(ref self: TState, bills: Span<LordsReleaseBill>) -> u128;
  // ...
}

Expected behavior The structs RewardValues and LordsReleaseBill should be exported to typescript.

rsodre avatar Feb 25 '25 20:02 rsodre

Having the same issue, for now just created a dummy model that includes the missing Structs.

thiscaspar avatar Mar 18 '25 23:03 thiscaspar

Have not done this before, but if not urgent would like to take this.

cwkang1998 avatar Apr 11 '25 10:04 cwkang1998

bump!

rsodre avatar Apr 22 '25 14:04 rsodre

@rsodre will try to get something out these 2 days, been travelling a bit.

cwkang1998 avatar May 02 '25 07:05 cwkang1998

@rsodre attempted to replicate this but can't manage to do it, the branch you pointed to seems to be missing / merged, do you have another example?

cwkang1998 avatar May 04 '25 05:05 cwkang1998

@cwkang1998 you can use this https://github.com/underware-gg/pistols/tree/3cf4909b0fcbbfb224cf5455da3a8e8817c49312/dojo

start a local katana, cd dojo and ./migrate dev --bindings

on the generated sources, LordsReleaseBill and MockedValue are not present.

this is the latest fix commit I made after generating bindings: https://github.com/underware-gg/pistols/commit/f30a9d6af4d112727564c540adde8c034a481f55

rsodre avatar May 04 '25 17:05 rsodre

@rsodre, just fixed the underlying issue with Dojo bindgen, will open the PR and check with @MartianGreed to verify/complete the typescript part. 🫡

Sorry for the delay on that.

glihm avatar Sep 18 '25 22:09 glihm