Skip to content

Commit

Permalink
Merge pull request #398 from dojoengine/update_sdk
Browse files Browse the repository at this point in the history
chore: update sdk
  • Loading branch information
MartianGreed authored Feb 19, 2025
2 parents 720b48f + 896c98e commit accf743
Show file tree
Hide file tree
Showing 19 changed files with 39 additions and 37 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ jobs:
run: git submodule update --init --recursive

- run: curl -L https://install.dojoengine.org | bash
- run: /home/runner/.config/.dojo/bin/dojoup -v v1.0.10
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.9.2"
- run: /home/runner/.config/.dojo/bin/dojoup -v v1.2.1
- run: |
cd worlds/dojo-starter
/home/runner/.config/.dojo/bin/sozo build
Expand Down
1 change: 0 additions & 1 deletion examples/example-vanillajs-phaser-recs/src/dojo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export async function setup({ ...config }: Config) {
let toriiClient = null;
try {
toriiClient = await torii.createClient({
rpcUrl: config.rpcUrl,
toriiUrl: config.toriiUrl,
relayUrl: "",
worldAddress: config.manifest.world.address || "",
Expand Down
1 change: 0 additions & 1 deletion examples/example-vite-experimental-sdk/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ async function main() {

const sdk = await init({
client: {
rpcUrl: dojoConfig.rpcUrl,
toriiUrl: dojoConfig.toriiUrl,
relayUrl: dojoConfig.relayUrl,
worldAddress: dojoConfig.manifest.world.address,
Expand Down
1 change: 0 additions & 1 deletion examples/example-vite-grpc-playground/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { dojoConfig } from "../dojoConfig.ts";
async function main() {
const sdk = await init({
client: {
rpcUrl: dojoConfig.rpcUrl,
toriiUrl: dojoConfig.toriiUrl,
relayUrl: dojoConfig.relayUrl,
worldAddress: dojoConfig.manifest.world.address,
Expand Down
3 changes: 1 addition & 2 deletions examples/example-vite-kitchen-sink/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import { dojoConfig } from "../dojoConfig";
import { setupWorld } from "./typescript/contracts.gen";
import { SchemaType } from "./typescript/models.gen";

import { env, getRpcUrl } from "@/env";
import { env } from "@/env";

async function main() {
const sdk = await init<SchemaType>({
client: {
rpcUrl: getRpcUrl(),
toriiUrl: env.VITE_TORII_URL,
relayUrl: env.VITE_RELAY_URL,
worldAddress: dojoConfig.manifest.world.address,
Expand Down
1 change: 0 additions & 1 deletion examples/example-vite-phaser-sdk/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const useDojoStore = createDojoStore<SchemaType>();
async function main() {
const sdk = await init<SchemaType>({
client: {
rpcUrl: dojoConfig.rpcUrl,
toriiUrl: dojoConfig.toriiUrl,
relayUrl: dojoConfig.relayUrl,
worldAddress: dojoConfig.manifest.world.address,
Expand Down
1 change: 0 additions & 1 deletion examples/example-vite-react-app-recs/src/dojo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type SetupResult = Awaited<ReturnType<typeof setup>>;
export async function setup({ ...config }: DojoConfig) {
// Initialize Torii client for interacting with the Dojo network
const toriiClient = await torii.createClient({
rpcUrl: config.rpcUrl,
toriiUrl: config.toriiUrl,
relayUrl: "",
worldAddress: config.manifest.world.address || "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export type SetupResult = Awaited<ReturnType<typeof setup>>;
export async function setup({ ...config }: DojoConfig) {
// torii client
const toriiClient = await torii.createClient({
rpcUrl: config.rpcUrl,
toriiUrl: config.toriiUrl,
relayUrl: config.relayUrl,
worldAddress: config.manifest.world.address || "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type SetupResult = Awaited<ReturnType<typeof setup>>;
export async function setup({ ...config }: DojoConfig) {
// torii client
const toriiClient = await torii.createClient({
rpcUrl: config.rpcUrl,
toriiUrl: config.toriiUrl,
relayUrl: config.relayUrl,
worldAddress: config.manifest.world.address || "",
Expand Down
1 change: 0 additions & 1 deletion examples/example-vite-react-sdk/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import StarknetProvider from "./starknet-provider.tsx";
async function main() {
const sdk = await init<SchemaType>({
client: {
rpcUrl: dojoConfig.rpcUrl,
toriiUrl: dojoConfig.toriiUrl,
relayUrl: dojoConfig.relayUrl,
worldAddress: dojoConfig.manifest.world.address,
Expand Down
1 change: 0 additions & 1 deletion examples/example-vite-react-sql/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ declare module "@tanstack/react-router" {
async function main() {
const sdk = await init<SchemaType>({
client: {
rpcUrl: dojoConfig.rpcUrl,
toriiUrl: dojoConfig.toriiUrl,
relayUrl: dojoConfig.relayUrl,
worldAddress: dojoConfig.manifest.world.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type SetupResult = Awaited<ReturnType<typeof setup>>;
export async function setup({ ...config }: DojoConfig) {
// torii client
const toriiClient = await torii.createClient({
rpcUrl: config.rpcUrl,
toriiUrl: config.toriiUrl,
relayUrl: config.relayUrl,
worldAddress: config.manifest.world.address || "",
Expand Down
1 change: 0 additions & 1 deletion examples/example-vite-svelte-recs/src/dojo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export type SetupResult = Awaited<ReturnType<typeof setup>>;
export async function setup({ ...config }: DojoConfig) {
// torii client
const toriiClient = await torii.createClient({
rpcUrl: config.rpcUrl,
toriiUrl: config.toriiUrl,
relayUrl: "",
worldAddress: config.manifest.world.address || "",
Expand Down
13 changes: 2 additions & 11 deletions examples/example-vue-app-recs/src/dojo/generated/setup.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import {
createModelTypedData,
DojoConfig,
DojoProvider,
} from "@dojoengine/core";
import { DojoConfig, DojoProvider } from "@dojoengine/core";
import { getSyncEntities } from "@dojoengine/state";
import * as torii from "@dojoengine/torii-client";
import {
ArraySignatureType,
TypedData,
WeierstrassSignatureType,
} from "starknet";
import { ArraySignatureType } from "starknet";

import { createClientComponents } from "../createClientComponents";
import { createSystemCalls } from "../createSystemCalls";
Expand All @@ -22,7 +14,6 @@ export type SetupResult = Awaited<ReturnType<typeof setup>>;
export async function setup({ ...config }: DojoConfig) {
// torii client
const toriiClient = await torii.createClient({
rpcUrl: config.rpcUrl,
toriiUrl: config.toriiUrl,
relayUrl: "",
worldAddress: config.manifest.world.address || "",
Expand Down
1 change: 0 additions & 1 deletion packages/sdk/src/__example__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ export const schema: MockSchemaType = {
async function exampleUsage() {
const db = await init<MockSchemaType>({
client: {
rpcUrl: "your-rpc-url",
toriiUrl: "your-torii-url",
relayUrl: "your-relay-url",
worldAddress: "your-world-address",
Expand Down
23 changes: 17 additions & 6 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,26 +257,31 @@ export async function init<T extends SchemaType>(

/**
* @param {(string)[]} contract_addresses
* @param {string[]} token_ids
* @returns {Promise<Tokens>}
*/
getTokens: async (
contract_addresses: string[]
contract_addresses: string[],
token_ids: string[]
): Promise<torii.Tokens> => {
return await client.getTokens(contract_addresses);
return await client.getTokens(contract_addresses, token_ids);
},

/**
* @param {(string)[]} account_addresses
* @param {(string)[]} contract_addresses
* @param {string[]} token_ids
* @returns {Promise<TokenBalances>}
*/
getTokenBalances: async (
account_addresses: string[],
contract_addresses: string[]
contract_addresses: string[],
token_ids: string[]
): Promise<torii.TokenBalances> => {
return await client.getTokenBalances(
account_addresses,
contract_addresses
contract_addresses,
token_ids
);
},

Expand All @@ -286,6 +291,7 @@ export async function init<T extends SchemaType>(
* # Parameters
* @param {string[]} contract_addresses - Array of contract addresses to filter (empty for all)
* @param {string[]} account_addresses - Array of account addresses to filter (empty for all)
* @param {string[]} token_ids - Array of token ids to filter (empty for all)
* @param {Funtion} callback - JavaScript function to call on updates
*
* # Returns
Expand All @@ -295,11 +301,13 @@ export async function init<T extends SchemaType>(
onTokenBalanceUpdated: (
contract_addresses: string[],
account_addresses: string[],
token_ids: string[],
callback: Function
): torii.Subscription => {
return client.onTokenBalanceUpdated(
contract_addresses,
account_addresses,
token_ids,
callback
);
},
Expand All @@ -311,6 +319,7 @@ export async function init<T extends SchemaType>(
* @param {torii.Subscription} subscription - Existing subscription to update
* @param {string[]} contract_addresses - New array of contract addresses to filter
* @param {string[]} account_addresses - New array of account addresses to filter
* @param {string[]} token_ids - New array of token ids to filter (empty for all)
*
* # Returns
* Result containing unit or error
Expand All @@ -319,12 +328,14 @@ export async function init<T extends SchemaType>(
updateTokenBalanceSubscription: async (
subscription: torii.Subscription,
contract_addresses: string[],
account_addresses: string[]
account_addresses: string[],
token_ids: string[]
): Promise<void> => {
return await client.updateTokenBalanceSubscription(
subscription,
contract_addresses,
account_addresses
account_addresses,
token_ids
);
},

Expand Down
16 changes: 13 additions & 3 deletions packages/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,18 +324,24 @@ export interface SDK<T extends SchemaType> {

/**
* @param {string[]} contract_addresses
* @param {string[]} token_ids
* @returns {Promise<torii.Tokens>}
*/
getTokens(contract_addresses: string[]): Promise<torii.Tokens>;
getTokens(
contract_addresses: string[],
token_ids: string[]
): Promise<torii.Tokens>;

/**
* @param {string[]} account_addresses
* @param {string[]} contract_addresses
* @param {string[]} token_ids
* @returns {Promise<torii.TokenBalances>}
*/
getTokenBalances(
account_addresses: string[],
contract_addresses: string[]
contract_addresses: string[],
token_ids: string[]
): Promise<torii.TokenBalances>;

/**
Expand All @@ -344,6 +350,7 @@ export interface SDK<T extends SchemaType> {
* # Parameters
* @param {string[]} contract_addresses - Array of contract addresses to filter (empty for all)
* @param {string[]} account_addresses - Array of account addresses to filter (empty for all)
* @param {string[]} token_ids - Array of token ids to filter (empty for all)
* @param {Funtion} callback - JavaScript function to call on updates
*
* # Returns
Expand All @@ -353,6 +360,7 @@ export interface SDK<T extends SchemaType> {
onTokenBalanceUpdated: (
contract_addresses: string[],
account_addresses: string[],
token_ids: string[],
callback: Function
) => torii.Subscription;

Expand All @@ -363,6 +371,7 @@ export interface SDK<T extends SchemaType> {
* @param {torii.Subscription} subscription - Existing subscription to update
* @param {string[]} contract_addresses - New array of contract addresses to filter
* @param {string[]} account_addresses - New array of account addresses to filter
* @param {string[]} token_ids - New array of token ids to filter
*
* # Returns
* Result containing unit or error
Expand All @@ -371,7 +380,8 @@ export interface SDK<T extends SchemaType> {
updateTokenBalanceSubscription: (
subscription: torii.Subscription,
contract_addresses: string[],
account_addresses: string[]
account_addresses: string[],
token_ids: string[]
) => Promise<void>;

/**
Expand Down
2 changes: 1 addition & 1 deletion worlds/dojo-starter
2 changes: 1 addition & 1 deletion worlds/onchain-dash

0 comments on commit accf743

Please sign in to comment.