-
Notifications
You must be signed in to change notification settings - Fork 735
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: tvf #5630
feat: tvf #5630
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.
LGTM, feel free to merge when all comments are resolved, specially the one for more test cases for the unhappy path.
try { | ||
record = await this.client.core.history.get(topic, id); | ||
const request = record.request; |
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.
Should we validate/parse the request to avoid having to cast the method to JsonRpcTypes.WcMethod
?
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.
request.method
type is string
so i'm casting it to predefined set of protocol methods to be more intuitive of the values. I can try to refactor the type JsonRpcRecord
that history returns but it might cause unexpected breaking changes in the types
if (!params) return false; | ||
if (protocolMethod !== "wc_sessionRequest") return false; | ||
const { request, chainId } = params; | ||
const namespace = parseChainId(chainId).namespace; | ||
if (!(namespace in TVF_METHODS)) return false; | ||
const tvfMethods = TVF_METHODS[namespace as keyof typeof TVF_METHODS]; | ||
if (!tvfMethods) return false; | ||
return tvfMethods.includes(request.method); |
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.
Do you think it'd make sense to introduce a validation library with clear schemas for handling validation ?
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.
the parsing is simplified now so probably overkill to export it into its own library. if we expand the handling at later point, why not
} catch (e) { | ||
this.client.logger.warn("Error getting TVF params", e); | ||
} | ||
return {}; |
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.
Curious why you're adopting this pattern of returning outside of the catch ?
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.
seems easier to read whats going on in the fx
@@ -493,6 +493,91 @@ describe("Sign Client Integration", () => { | |||
await throttle(1_000); | |||
await deleteClients(clients); | |||
}); | |||
|
|||
it("can set tvf params", async () => { |
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.
Is that the only test case we need ? What about checking validation errors etc ?
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.
added extra validations for the different namespaces and result structures. Validation errors are tested with the other tests where different methods/values are used and don't assign tvf
Description
Implemented automatic parsing and adding of TVF params to relay message payloads on both peer sides. These params are assigned on a few selected rpc methods as per specs
Type of change
How has this been tested?
tests
Checklist
Additional Information (Optional)
Please include any additional information that may be useful for the reviewer.