Skip to content
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: call compliance endpoint for keplr #588

Merged
merged 5 commits into from
Aug 21, 2024
Merged

feat: call compliance endpoint for keplr #588

merged 5 commits into from
Aug 21, 2024

Conversation

rosepuppy
Copy link
Contributor

@rosepuppy rosepuppy commented Aug 21, 2024

Backend endpoint PR: dydxprotocol/v4-chain#2117

val signedMessage = helper.parser.asString(result["signedMessage"])
val publicKey = helper.parser.asString(result["publicKey"])
val timestamp = helper.parser.asString(result["timestamp"])
val isKeplr = helper.parser.asBool(result["isKeplr"])
val url = if (isKeplr == true) complianceGeoblockKeplrUrl() else complianceGeoblockUrl()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[discussion] we're starting to get a lot of branching in this function. you think it's worth splitting this into 2 separate functions? or creating 2 separate helper functions?

if this is urgent i'm down to stamp right away though since the logic makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely thought about it, and tried initially. Ended with this approach because the only code path change is just the body and url, but if you feel strongly I can take another stab!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah no worries! i think we can do this as part of a larger cleanup task in the future to reduce code duplication. the OnboardingSupervisor is a really bad offender of this... so easy to make mistakes when updating things since there's so much duplicate code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, feel that

"address" to address.rawAddress,
"message" to message,
"action" to complianceAction.toString(),
"signedMessage" to signedMessage!!,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] why do these properties have to be assumed non-null? (i know it's part of previously committed code too, but curious if you have the answer)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just that the request needs all these fields.

I check for it to be not null with isUrlAndKeysPresent before the body gets used, so if anything is null, the request would not send.

I don't know if there is a better kotlin way to do this tho

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, does kotlin remove the field entirely if the value is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh it will actually throw, thats a good catch actually. I think it should be inside the if statement

Copy link
Contributor

@yogurtandjam yogurtandjam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stamped but i think we need to wait for https://github.com/dydxprotocol/v4-chain/pull/2117/files to merge right? so just ping me when you need a restamp (you will, most likely, as you'll have to bump versions)

"address" to address.rawAddress,
"message" to message,
"action" to complianceAction.toString(),
"signedMessage" to signedMessage!!,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] we shouldn't need the non-null casting anymore, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still need to do for the type check haha

@rosepuppy
Copy link
Contributor Author

stamped but i think we need to wait for https://github.com/dydxprotocol/v4-chain/pull/2117/files to merge right? so just ping me when you need a restamp (you will, most likely, as you'll have to bump versions)

Should be fine, since the request won't get called unless the user is using Keplr which isn't launched yet

@rosepuppy rosepuppy merged commit 65c0942 into main Aug 21, 2024
8 checks passed
@rosepuppy rosepuppy deleted the geoblock-keplr branch August 21, 2024 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants