Skip to content

v1.0.0-alpha.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@ponderingdemocritus ponderingdemocritus released this 22 Jul 01:05
· 287 commits to main since this release

Breaking Changes

Pre-release Features

This pre-release introduces some long-awaited features for testing. More features will be added in the lead-up to v1 release. We suggest you try these and provide feedback to be added into the main release.

TLDR:

  • getSyncEntities now allows passing an array of clauses for specific state and fetching sync
  • New React hook useQuerySync allows easy fetching and syncing in React apps
  • Breaking change in the execute functions
  • Upgrade Starknet.js to latest version (previous versions were broken with latest Katana and Torii)

Torii Client Breaking Changes

Torii client must be created as follows. You no longer pass entities as the first parameter:

const toriiClient = await torii.createClient({
    rpcUrl: config.rpcUrl,
    toriiUrl: config.toriiUrl,
    relayUrl: "",
    worldAddress: config.manifest.world.address || "",
});

Getting and syncing entities introduces a Key Clause as the final parameter. Pass an empty array if you wish to fetch everything:

const sync = await getSyncEntities(
    toriiClient,
    contractComponents as any,
    []
);

If you pass in a query, it must match an array of EntityKeysClause:

export type EntityKeysClause = { HashedKeys: string[] } | { Keys: KeysClause };
export interface KeysClause {
    keys: (string | null)[];
    models: string[];
    pattern_matching: PatternMatching;
}
{
    Keys: {
        keys: [BigInt(account?.account.address).toString()],
        models: ["Position", "Moves", "DirectionsAvailable"],
        pattern_matching: "FixedLen",
    },
}

React Updates

There is a new React hook called useQuerySync which you can use to subscribe and sync specific parts of your app. This is very useful for large apps that wish to subscribe to only specific parts:

useQuerySync(toriiClient, contractComponents as any, [
    {
        Keys: {
            keys: [BigInt(account?.account.address).toString()],
            models: ["Position", "Moves", "DirectionsAvailable"],
            pattern_matching: "FixedLen",
        },
    },
]);

Core Updates

Dojo v1 introduces the concept of namespaces. Read full release notes here.

With the introduction of namespaces, a new field has been added to the execute functions - this allows you to specify which namespace to call:

return await provider.execute(
    account,
    {
        contractName: "actions",
        entrypoint: "spawn",
        calldata: [],
    },
    NAMESPACE
);

What's Changed

Full Changelog: v0.7.10-alpha.0...v1.0.0-alpha.0