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

[ANCHOR-388] SEP-6: Implement RPC actions #1166

Merged
merged 9 commits into from
Oct 31, 2023

Conversation

philipliu
Copy link
Contributor

@philipliu philipliu commented Oct 17, 2023

Description

This updates the RPC actions for SEP-6 and updates the reference server implementation to use them. This PR is quite large as it updates the unit tests for most of the RPC actions but, implementation-wise, not much has changed. It might helpful to start by reviewing the Sep6End2EndTest to get a sense of what changed with this PR.

Context

SEP-6 should support RPC API.

Testing

  • ./gradlew test

Known limitations

  • Platform API integration tests do not test the new flow but are covered by the SEP-6 e2e tests.
  • Refunds and custody service integration have not been implemented.

Both of these will be addressed by ANCHOR-508

@philipliu philipliu force-pushed the feature/anchor-388-rpc-api branch 8 times, most recently from 001eb85 to a18779e Compare October 23, 2023 14:06
@philipliu philipliu force-pushed the feature/anchor-388-rpc-api branch from a18779e to f3005cd Compare October 23, 2023 15:00
@philipliu philipliu marked this pull request as ready for review October 23, 2023 15:27
@lijamie98
Copy link
Collaborator

Can we add class comments of the RPC handler classes? Or some reference link to the RPC definition document?

Copy link
Collaborator

@lijamie98 lijamie98 left a comment

Choose a reason for hiding this comment

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

LGTM.

@lijamie98
Copy link
Collaborator

At this moment, I am not familiar with the RPC enough to make too much meaningful reviews. But the PR looks fine with me.

@philipliu
Copy link
Contributor Author

Can we add class comments of the RPC handler classes? Or some reference link to the RPC definition document?

Sure, I can link to the docs, but I'll do this outside of this PR.

@@ -90,6 +90,14 @@ public StartDepositResponse deposit(Sep10Jwt token, StartDepositRequest request)
.type(request.getType())
.assetCode(request.getAssetCode())
.assetIssuer(asset.getIssuer())
// NB: these are purposely set to incorrect values.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it mean there will be a state of the transaction in DB when it has incorrect amounts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, the amounts are technically incorrect anyway since the Anchor updates fees asynchronously. Deposit instructions and withdraw anchor accounts (to be done in the next PR) will not be provided until the business server makes a request for funds RPC so there is no way for the user to accidentally submit the wrong amount.

Copy link
Contributor

Choose a reason for hiding this comment

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

But if the user requests the transaction, won't we return incorrect data? Shouldn't amount just be null instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. the NotifyAmountsUpdatedHandler validation requires the assets to be set so it can't be null (code). I guess we can remove the validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I should probably think about this more, so I'll create a ticket to address this and merge it as is.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure RPC validation should just validate only the request having amount to not be null, if we expect transaction to start with null amounts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that makes sense. Created ANCHOR-525 to fix it.

@@ -165,18 +200,26 @@ NotifyOffchainFundsReceivedHandler notifyOffchainFundsReceivedHandler(

@Bean
NotifyOffchainFundsSentHandler notifyOffchainFundsSentHandler(
Sep6TransactionStore txn6Store,
Copy link
Contributor

Choose a reason for hiding this comment

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

We def should group this services together to simplify all factory methods for RPC handlers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this was quite annoying...

@philipliu philipliu merged commit 86d95d4 into stellar:sep-6 Oct 31, 2023
5 checks passed
@philipliu philipliu deleted the feature/anchor-388-rpc-api branch October 31, 2023 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants