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] Typescript bindings generation order is random #2782

Open
rsodre opened this issue Dec 6, 2024 · 1 comment
Open

[BUG] Typescript bindings generation order is random #2782

rsodre opened this issue Dec 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@rsodre
Copy link

rsodre commented Dec 6, 2024

Describe the bug

Every time we generate typescript bindings, the order of models in models.gen.ts is changed.
It makes it impossible to review the generated models.
And is terrible to track changes and update the client after contract changes.

To Reproduce

Build dojo-starter multiple times and compare the bindings.
If there was no change in the models, they should not be updated.

# clone dojo-starter
$ git clone https://github.com/dojoengine/dojo-starter
Cloning into 'dojo-starter'...
$ cd dojo-starter 

# build once and backup the bindings
$ sozo build --typescript
   Compiling dojo_starter v1.0.2 (/Users/roger/Dev/Realms/dojo-starter/Scarb.toml)
    Finished `dev` profile target(s) in 4 seconds
$ cp bindings/typescript/models.gen.ts bindings/typescript/models.gen-0.ts

# build again multiple times and compare...
$ sozo build --typescript
   Compiling dojo_starter v1.0.2 (/Users/roger/Dev/Realms/dojo-starter/Scarb.toml)
    Finished `dev` profile target(s) in 4 seconds
$ diff bindings/typescript/models.gen.ts bindings/typescript/models.gen-0.ts
33a34,40
> // Type definition for `dojo_starter::models::Vec2` struct
> export interface Vec2 {
> 	fieldOrder: string[];
> 	x: BigNumberish;
> 	y: BigNumberish;
> }
> 
47,53d53
< // Type definition for `dojo_starter::models::Vec2` struct
< export interface Vec2 {
< 	fieldOrder: string[];
< 	x: BigNumberish;
< 	y: BigNumberish;
< }
< 
68a69
> 		Vec2: Vec2,
71d71
< 		Vec2: Vec2,
100a101,105
> 		Vec2: {
> 			fieldOrder: ['x', 'y'],
> 			x: 0,
> 			y: 0,
> 		},
110,114d114
< 		Vec2: {
< 			fieldOrder: ['x', 'y'],
< 			x: 0,
< 			y: 0,
< 		},

Expected behavior

The generated sources should be deterministic and historically accurate.

@rsodre rsodre added the bug Something isn't working label Dec 6, 2024
@rsodre
Copy link
Author

rsodre commented Dec 27, 2024

I see #2816 is ordering the models
but contracts.gen is still completely random

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