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

[BUG] sozo --typescript bindings errors #2628

Open
rsodre opened this issue Nov 4, 2024 · 0 comments
Open

[BUG] sozo --typescript bindings errors #2628

rsodre opened this issue Nov 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@rsodre
Copy link

rsodre commented Nov 4, 2024

Describe the bug

Source files generated by sozo --typescript have errors.

To Reproduce

  • clone pistols, branch thai
  • run: cd dojo && git checkout thai && sozo build --typescript
  • inspect dojo/bindings/typescript/contracts.gen.ts and dojo/bindings/typescript/models.gen.ts

or just get the generated files here:

models.gen.ts

  • big integer types (u64, u128, u256, felt252, ContractAddress) are being converted as number, while they should be bigint or BigNumberish.
// Type definition for `pistols::models::challenge::Challenge` struct
export interface Challenge {
  fieldOrder: string[];
  duel_id: number;        // u128 should be: bigint
  seed: number;           // u128 should be: bigint
  table_id: number;       // felt252 should be: bigint
  premise: Premise;
  quote: number;          // felt252 should be: bigint
  address_a: string;      // ContractAddress should be: bigint
  address_b: string;      // ContractAddress should be: bigint
  duelist_id_a: number;   // u128 should be: bigint
  duelist_id_b: number;   // u128 should be: bigint
  state: ChallengeState;
  winner: number;
  timestamp_start: number; // u64 should be: bigint
  timestamp_end: number;   // u64 should be: bigint
}

contracts.gen.ts

  • calls to provider.execute have the wrong number of parameters (missing namespace)
Screenshot 2024-11-04 at 14 48 20
  • if I add the namespace manually, there's another error on entryPoint:
Screenshot 2024-11-04 at 15 04 03
  • any function with an argument named account generates a Duplicate identifier 'account'.ts(2300) error:
Screenshot 2024-11-04 at 14 58 28
  • interfaces that include snake_case and camelCase versions of the same functions have their functions duplicated, as the generator converts snake_casr to camelCase.
Screenshot 2024-11-04 at 14 59 47 Screenshot 2024-11-04 at 14 59 57
  • some types are missing the namespace. ex: [Payment](payment: Payment) should be payment: models.Payment
const bank_charge = async (_account: Account, payer: string, payment: Payment) => {
const admin_setConfig = async (_account: Account, config: Config) => {
const admin_setTable = async (_account: Account, table: TableConfig) => {
const admin_setTableAdmittance = async (_account: Account, tableAdmittance: TableAdmittance) => {
Screenshot 2024-11-04 at 15 02 00
@rsodre rsodre added the bug Something isn't working label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant