[BUG]sozo typescript-v2 bindings errors
Closed this issue · 1 comments
rsodre commented
Describe the bug
Source files generated by sozo --typescript
and sozo --typescript-v2
have errors.
To Reproduce
- clone pistols
- run:
cd dojo && ./migrate dev
- inspect
dojo/bindings/typescript-v2/pistols.ts
Expected behavior
Generated files should not have any errors.
Screenshots
Attached generated source:
pistols.ts.txt
Those are the issues:
- Import errors:
Module '"@dojoengine/torii-client"' has no exported member 'Client'. ts(2305)
Module '"@dojoengine/torii-client"' has no exported member 'ModelClause'. ts(2305)
Module '"@dojoengine/torii-client"' has no exported member 'valueToToriiValueAndOperator'. ts(2305)
import {
Clause,
Client,
ModelClause,
createClient,
valueToToriiValueAndOperator,
} from "@dojoengine/torii-client";
- Function arguments:
Cannot find name 'props'.ts(2304)
This happens many times, always when a struct is passed. A couple of examples...
async charge(payer: string, payment: Payment): Promise<void> {
try {
await this.execute("charge", [payer,
props.payment.key,
props.payment.amount,
props.payment.client_percent,
props.payment.ranking_percent,
props.payment.owner_percent,
props.payment.pool_percent,
props.payment.treasury_percent])
} catch (error) {
console.error("Error executing charge:", error);
throw error;
}
}
async getTokenDescription(token_id: U256): Promise<void> {
try {
await this.execute("get_token_description", [props.token_id.low,
props.token_id.high])
} catch (error) {
console.error("Error executing getTokenDescription:", error);
throw error;
}
}
- Duplicated functions
Duplicate function implementation.ts(2393)
Apparently, the generator is creating camelCase versions of functions that already have a camelCase declared I the interface, or functions that do not need camelCase (like name()
)
class DuelTokenCalls extends BaseCalls {
// ...
async ownerOf(token_id: U256): Promise<void> {
try {
await this.execute("owner_of", [props.token_id.low,
props.token_id.high])
} catch (error) {
console.error("Error executing ownerOf:", error);
throw error;
}
}
async name(): Promise<void> {
try {
await this.execute("_name", [])
} catch (error) {
console.error("Error executing name:", error);
throw error;
}
}
- the
createClient()
call is outdated:Expected 1 arguments, but got 2.ts. (2554)
this.toriiPromise = createClient([], {
rpcUrl: this.rpcUrl,
toriiUrl: this.toriiUrl,
worldAddress: this.worldAddress,
relayUrl: this.relayUrl,
});