-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add getControllers and update subscription functions #396
Conversation
WalkthroughThis PR introduces three new asynchronous methods into the SDK. The methods, Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant SDK
participant SubscriptionService
Client->>SDK: updateEntitySubscription(subscription, clauses)
SDK->>SubscriptionService: Process Update Request
SubscriptionService-->>SDK: Confirmation
SDK-->>Client: Promise Resolved
sequenceDiagram
participant Client
participant SDK
participant MessageService
Client->>SDK: updateEventMessageSubscription(subscription, clauses, historical)
SDK->>MessageService: Process Event Message Update
MessageService-->>SDK: Confirmation
SDK-->>Client: Promise Resolved
sequenceDiagram
participant Client
participant SDK
participant ControllerService
Client->>SDK: getControllers(contract_addresses)
SDK->>ControllerService: Request Controllers Data
ControllerService-->>SDK: Returns Controllers
SDK-->>Client: Promise Resolved with Data
Possibly related PRs
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/sdk/src/index.ts (3)
331-347
: Consider adding error handling.While the implementation is correct, consider adding try-catch block to handle potential errors from the client method and provide more context-specific error messages.
updateEntitySubscription: async ( subscription: torii.Subscription, clauses: torii.EntityKeysClause[] ): Promise<void> => { + try { return await client.updateEntitySubscription(subscription, clauses); + } catch (error) { + throw new Error(`Failed to update entity subscription: ${error.message}`); + } },
349-371
: Add parameter validation for historical flag.Consider validating the historical parameter to ensure it's a boolean value.
updateEventMessageSubscription: async ( subscription: torii.Subscription, clauses: torii.EntityKeysClause[], historical: boolean ): Promise<void> => { + if (typeof historical !== 'boolean') { + throw new TypeError('historical parameter must be a boolean'); + } return await client.updateEventMessageSubscription( subscription, clauses, historical ); },
373-388
: Validate contract addresses format.Consider adding validation for contract addresses to ensure they are valid hex strings.
getControllers: async ( contract_addresses: string[] ): Promise<torii.Controllers> => { + const isValidHexString = (str: string) => /^0x[0-9a-fA-F]+$/.test(str); + const invalidAddresses = contract_addresses.filter(addr => !isValidHexString(addr)); + if (invalidAddresses.length > 0) { + throw new Error(`Invalid hex format for addresses: ${invalidAddresses.join(', ')}`); + } return await client.getControllers(contract_addresses); },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/sdk/src/index.ts
(1 hunks)packages/sdk/src/types.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: check
- GitHub Check: build
🔇 Additional comments (3)
packages/sdk/src/types.ts (3)
382-396
: LGTM!The interface definition is well-documented and correctly typed.
398-414
: LGTM!The interface definition is well-documented and correctly typed.
416-429
: LGTM!The interface definition is well-documented and correctly typed.
Closes #
Introduced changes
Checklist
Summary by CodeRabbit