From 0bad2fbb0953294e0e1563bfeb9b585ea1d3a4fc Mon Sep 17 00:00:00 2001 From: Valentin Dosimont Date: Thu, 13 Feb 2025 15:45:03 +0100 Subject: [PATCH] feat: add getControllers and update subscription functions --- packages/sdk/src/index.ts | 59 +++++++++++++++++++++++++++++++++++++++ packages/sdk/src/types.ts | 49 ++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/packages/sdk/src/index.ts b/packages/sdk/src/index.ts index 47bfe878..2658ba27 100644 --- a/packages/sdk/src/index.ts +++ b/packages/sdk/src/index.ts @@ -327,5 +327,64 @@ export async function init( 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} + */ + updateEntitySubscription: async ( + subscription: torii.Subscription, + clauses: torii.EntityKeysClause[] + ): Promise => { + 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} + */ + updateEventMessageSubscription: async ( + subscription: torii.Subscription, + clauses: torii.EntityKeysClause[], + historical: boolean + ): Promise => { + 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} + */ + getControllers: async ( + contract_addresses: string[] + ): Promise => { + return await client.getControllers(contract_addresses); + }, }; } diff --git a/packages/sdk/src/types.ts b/packages/sdk/src/types.ts index 7f856743..a5757077 100644 --- a/packages/sdk/src/types.ts +++ b/packages/sdk/src/types.ts @@ -378,6 +378,55 @@ export interface SDK { contract_addresses: string[], account_addresses: string[] ) => Promise; + + /** + * 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} + */ + updateEntitySubscription: ( + subscription: torii.Subscription, + clauses: torii.EntityKeysClause[] + ) => Promise; + + /** + * 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} + */ + updateEventMessageSubscription: ( + subscription: torii.Subscription, + clauses: torii.EntityKeysClause[], + historical: boolean + ) => Promise; + + /** + * 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} + */ + getControllers: ( + contract_addresses: string[] + ) => Promise; } /**