Skip to content

Commit

Permalink
Merge pull request #396 from dojoengine/feat/add-sdk-functions
Browse files Browse the repository at this point in the history
feat: add getControllers and update subscription functions
  • Loading branch information
MartianGreed authored Feb 13, 2025
2 parents 58251c1 + 0bad2fb commit af2e457
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
59 changes: 59 additions & 0 deletions packages/sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,5 +327,64 @@ export async function init<T extends SchemaType>(
account_addresses
);
},

/**
* Updates an existing entity subscription
*
* # Parameters
* @param {torii.Subscription} subscription - Existing subscription to update
* @param {torii.EntityKeysClause[]} clauses - New array of key clauses for filtering
*
* # Returns
* Result containing unit or error
* @returns {Promise<void>}
*/
updateEntitySubscription: async (
subscription: torii.Subscription,
clauses: torii.EntityKeysClause[]
): Promise<void> => {
return await client.updateEntitySubscription(subscription, clauses);
},

/**
* Updates an existing event message subscription
*
* # Parameters
* @param {torii.Subscription} subscription - Existing subscription to update
* @param {torii.EntityKeysClause[]} clauses - New array of key clauses for filtering
* @param {boolean} historical - Whether to include historical messages
*
* # Returns
* Result containing unit or error
* @returns {Promise<void>}
*/
updateEventMessageSubscription: async (
subscription: torii.Subscription,
clauses: torii.EntityKeysClause[],
historical: boolean
): Promise<void> => {
return await client.updateEventMessageSubscription(
subscription,
clauses,
historical
);
},

/**
* Gets controllers along with their usernames for the given contract addresses
*
* # Parameters
* @param {string[]} contract_addresses - Array of contract addresses as hex strings. If empty, all
* controllers will be returned.
*
* # Returns
* Result containing controllers or error
* @returns {Promise<torii.Controllers>}
*/
getControllers: async (
contract_addresses: string[]
): Promise<torii.Controllers> => {
return await client.getControllers(contract_addresses);
},
};
}
49 changes: 49 additions & 0 deletions packages/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,55 @@ export interface SDK<T extends SchemaType> {
contract_addresses: string[],
account_addresses: string[]
) => Promise<void>;

/**
* Updates an existing entity subscription
*
* # Parameters
* @param {torii.Subscription} subscription - Existing subscription to update
* @param {torii.EntityKeysClause[]} clauses - New array of key clauses for filtering
*
* # Returns
* Result containing unit or error
* @returns {Promise<void>}
*/
updateEntitySubscription: (
subscription: torii.Subscription,
clauses: torii.EntityKeysClause[]
) => Promise<void>;

/**
* Updates an existing event message subscription
*
* # Parameters
* @param {torii.Subscription} subscription - Existing subscription to update
* @param {torii.EntityKeysClause[]} clauses - New array of key clauses for filtering
* @param {boolean} historical - Whether to include historical messages
*
* # Returns
* Result containing unit or error
* @returns {Promise<void>}
*/
updateEventMessageSubscription: (
subscription: torii.Subscription,
clauses: torii.EntityKeysClause[],
historical: boolean
) => Promise<void>;

/**
* Gets controllers along with their usernames for the given contract addresses
*
* # Parameters
* @param {string[]} contract_addresses - Array of contract addresses as hex strings. If empty, all
* controllers will be returned.
*
* # Returns
* Result containing controllers or error
* @returns {Promise<torii.Controllers>}
*/
getControllers: (
contract_addresses: string[]
) => Promise<torii.Controllers>;
}

/**
Expand Down

0 comments on commit af2e457

Please sign in to comment.