-
Notifications
You must be signed in to change notification settings - Fork 8
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: Automatic consumer registration #34
Conversation
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.
Looks good 👍
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.
LGTM.
// Check if consumer name is empty | ||
if self.consumer_name.trim().is_empty() { | ||
return Err(StdError::generic_err("Consumer name cannot be empty")); | ||
} | ||
|
||
// Check if consumer description is empty | ||
if self.consumer_description.trim().is_empty() { | ||
return Err(StdError::generic_err("Consumer description cannot be empty")); | ||
} |
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.
Nit: Use a contract error proper (MissingConsumerInfo(String)
or so).
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.
this fn expects error of type StdError
, if we make a custom type then we need to change the fn definition as well?
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.
Yes, you can change the fn signature to return ContractError
, and adapt other errors if needed.
// Update config with consumer information | ||
cfg.consumer_name = msg.consumer_name; | ||
cfg.consumer_description = msg.consumer_description; |
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.
Thinking a bit more about this, another option could be to set an empty description (or remove description entirely), and do a query for the consumer's chain id. And then use that as consumer_name
.
That way it's not necessary to pass those fields during instantiation. It will also address the issue of consumer name being None
, or set but empty. It will also prevent setting a wrong / clashing consumer.
Fixes https://github.com/babylonlabs-io/babylon-private/issues/3
ibc_channel_connect
loads the config and prepares and send the packet