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

[Feature] Merge sep-6 into develop #1151

Merged
merged 57 commits into from
Nov 3, 2023
Merged

[Feature] Merge sep-6 into develop #1151

merged 57 commits into from
Nov 3, 2023

Conversation

philipliu
Copy link
Contributor

@philipliu philipliu commented Oct 11, 2023

Description

This merges the sep-6 development branch into develop.

Context

Anchor Platform is releasing SEP-6 support in 2.4.0.

Documentation

API docs have been updated in stellar/stellar-docs#253. This will merged be merged alongside this PR.

Testing

  • ./gradlew test

Known limitations

N/A

philipliu and others added 30 commits September 8, 2023 15:45
This implements the SEP-6 `GET /deposit` endpoint _mostly_ according to
the sequence diagram from the PR.

Where the implementation deviates is how `CUSTOMER_UPDATED` anchor
events are structured. This implementation sends out 1 event whenever a
SEP-12 customer is updated instead of fanning them out a
`TRANSACTION_STATUS_CHANGED` event for each ongoing transaction
submitted by the customer. This was done to keep the scope of this
change small, but we can consider whether to move this into the platform
later.
### Description

This removes the `ActiveTransactionStore` from the Kotlin reference
server. Previously, this was used to track which transactions were
pending KYC info updates. Now, we request the transactions from the
platform.

### Context

This is part of a series of commits to clean up the reference server
implementation.

### Testing

`./gradlew test`

### Known limitations

N/A
### Description

This PR implements the GET `/withdraw` endpoint and the reference server
implementation so that the E2E tests pass. It also includes minor
refactoring to the payment observer.

### Context

SEP-6 implementation.

### Testing

`./gradlew test`

### Known limitations

N/A
### Description

This adds a diagram illustrating the withdraw flow in an Anchor Platform
deployment.

### Context

Knowledge sharing.

### Testing

N/A

### Known limitations

N/A
### Description

This implements the SEP-6 `withdraw-exchange` endpoint. The request
object is prefixed with `Get`, all request objects will be renamed in a
separate PR.

### Context

SEP-6 implementation.

### Testing

`./gradlew test`

### Known limitations

This PR only includes unit tests. Integration tests and end-to-end tests
will follow after this PR is merged.
### Description

This fixes the response returned by GET `/info`.

### Context

This was discovered after enabling the SEP-6 test suite in
`stellar-anchor-tests`.

### Testing

- `./gradlew test`
- `stellar-anchor-tests`

### Known limitations

N/A
### Description

This change:
- Adds additional validation to SEP-6 deposit
- Adds `minAmount` and `maxAmount` validation to all operations
- Makes `type` and `amount` optional in `deposit` and `withdraw`
- Refactors the validation into its own class

### Context

During the testing of `stellar-anchor-tests`, it was discovered that
`type` and `amount` are optional parameters for the `deposit` and
`withdraw` endpoints. `Sep6Service` had a lot of code duplication so I
decided to refactor the validation into its own class.

### Testing

- `./gradlew test`
- `stellar-anchor-tests`

### Known limitations

N/A
### Description

This implements the GET `deposit-exchange` endpoint. There's a lot of
duplicated code that could be shared with `deposit` and
`withdraw`/`withdraw-exchange`. Once the integration and end-to-end
tests have been implemented, I will focus on cleaning up the code.

### Context

SEP-6 implementation.

### Testing

`./gradlew test`

### Known limitations

Integration and end-to-end tests are missing, they will be added in
another PR.
…eeds (#1136)

### Description

This adds a check to verify that a customer is SEP-12 accepted as part
of the deposit/withdraw request validation. This also removes the
`VERIFICATION_REQUIRED` status as it is not a valid SEP-12 customer info
status.

### Context

This was caught by a `stellar-anchor-tests` test case.

### Testing

- `./gradlew test`
- `stellar-anchor-tests`

### Known limitations

N/A
### Description

This enables client status callback for SEP-6.

### Context

Status callback should be supported by the SEP-6 implement.

### Testing

`./gradlew test`

### Known limitations

The SEP-24 end-to-end was previously not asserting on the wallet status
callbacks. This was caused by the signature verification failing in the
wallet reference server, causing the GET `/callback` to always return
null. The test previously only asserted when the result was _not_ null.
These tests have been disabled in this PR due to flakiness but will be
re-enabled again when `develop` is merged in.
### Description

Since we are validating min/max amounts, if set, these should be show in
the GET /info response.

### Context

These are currently missing from the info response.

### Testing

- `./gradlew test`

### Known limitations

N/A
### Description

Removes the `to` account set by the withdraw endpoint.

### Context

`to` is an optional field in the transactions object, and is meant to
store the user's off-chain account. This is not known at the time of
transaction creation.

### Testing

- `./gradlew test`

### Known limitations

N/A
### Description

This enables SEP-6 validation tests in the CI workflow. SEP-24 tests
have been disabled as they don't pass in the latest version `0.6.x`.
They will be re-enabled again once they have been fixed in ANCHOR-487.

### Context

Testing SEP-6.

### Testing

- `./gradlew test`

### Known limitations

N/A
### Description

SEP-6 will now check the KYC information of the SEP-10 account instead
of the requested account.

### Context

The requested account is not the same as the SEP-10 account for
custodial wallets.

### Testing

- `./gradlew test`

### Known limitations

N/A
philipliu and others added 3 commits October 11, 2023 17:20
### Description

This merges `develop` into `sep-6`. The RPC API and Custody service
changes make up the bulk of the commits.

### Context

Catch up `sep-6` branch to `develop`

### Testing

- `./gradlew test`

### Known limitations

N/A
@github-actions
Copy link

github-actions bot commented Oct 11, 2023

Code Coverage

Overall Project 30.21% -4.93%
Files changed 40.51%

Module Coverage
integration-tests 91.65% 🍏
core 70.96% -2.57% 🍏
platform 49.1% -1.69% 🍏
api-schema 1.07% -8.16%
Files
Module File Coverage
integration-tests Sep6Client.kt 100% 🍏
core Sep12Service.java 98.62% 🍏
Sep6Service.java 92.72% -5.5% 🍏
ClientFinder.java 91.6% -8.4% 🍏
Sep6TransactionUtils.java 91.21% -8.79% 🍏
RequestValidator.java 90.23% -9.77% 🍏
AssetServiceValidator.java 88.34% -2.69% 🍏
Sep31Service.java 84.46% 🍏
Sep6Transaction.java 79.52% -20.48%
Sep6TransactionBuilder.java 61.21% -7.76%
ExchangeAmountsCalculator.java 60.39% -39.61% 🍏
TransactionHelper.java 57.9% -9.95% 🍏
DefaultAssetService.java 56.44% 🍏
PlatformApiClient.java 0% 🍏
TransactionsParams.java 0% 🍏
Sep6Config.java 0% -56.67%
platform NotifyTransactionErrorHandler.java 100% 🍏
NotifyInteractiveFlowCompletedHandler.java 100% 🍏
NotifyTrustSetHandler.java 100% 🍏
NotifyAmountsUpdatedHandler.java 100% 🍏
RequestOffchainFundsHandler.java 100% 🍏
RpcMethodHandler.java 100% 🍏
NotifyOnchainFundsSentHandler.java 100% 🍏
NotifyOffchainFundsPendingHandler.java 100% 🍏
NotifyCustomerInfoUpdatedHandler.java 100% 🍏
RequestTrustlineHandler.java 100% 🍏
NotifyRefundPendingHandler.java 100% 🍏
NotifyOffchainFundsAvailableHandler.java 100% 🍏
NotifyTransactionExpiredHandler.java 100% 🍏
SimpleInteractiveUrlConstructor.java 100% 🍏
NotifyOffchainFundsReceivedHandler.java 97.95% -2.05% 🍏
DoStellarPaymentHandler.java 96.88% -2.68% 🍏
RequestOnchainFundsHandler.java 96.65% -3.35% 🍏
NotifyRefundSentHandler.java 96.64% 🍏
AssetValidationUtils.java 96.19% 🍏
DoStellarRefundHandler.java 95.47% 🍏
RequestCustomerInfoUpdateHandler.java 93.33% -6.67% 🍏
NotifyOnchainFundsReceivedHandler.java 92.56% 🍏
Sep6DepositInfoSelfGenerator.java 89.58% -10.42% 🍏
PaymentObserverBeans.java 87.72% 🍏
StringEnumConverter.java 85.54% 🍏
Sep6DepositInfoCustodyGenerator.java 82.76% -17.24% 🍏
JdbcSep24Transaction.java 81.05% 🍏
PaymentsUtil.java 80.75% -6.95%
TransactionService.java 80.33% 🍏
NotifyOffchainFundsSentHandler.java 75% -8.98% 🍏
PaymentOperationToEventListener.java 73.8% -10% 🍏
JdbcSep6Transaction.java 71.81% 🍏
NotifyTransactionRecoveryHandler.java 70.97% 🍏
CustodyServiceImpl.java 64.97% 🍏
PlatformTransactionHelper.java 54.76% 🍏
SepBeans.java 50.47% -10.28%
EventProcessorManager.java 33.27% -0.6%
PropertySep6Config.java 31.45% -60.07%
ClientStatusCallbackHandler.java 16.73% -6.05%
AbstractControllerExceptionHandler.java 0% -5.71%
Sep6Controller.java 0% -59.84%
PlatformServerBeans.java 0% -25.17%
RpcActionBeans.java 0% 🍏
EventProcessorBeans.java 0% 🍏
Sep6DepositInfoNoneGenerator.java 0%
JdbcSep6TransactionStore.java 0% -19.59%
PlatformController.java 0% 🍏
UtilityBeans.java 0% -9.26%
api-schema SendEventRequestPayload.java 0% -3.52%
SepCustomerInfoNeededException.java 0%
AssetInfo.java 0% -1.66%
CustomerInfoNeededResponse.java 0%
StartWithdrawRequest.java 0%
InfoResponse.java 0% -6.43%
StartWithdrawResponse.java 0%
GetTransactionResponse.java 0% -3.85%
StartDepositExchangeRequest.java 0%
StartDepositResponse.java 0%
GetTransactionsResponse.java 0% -3.85%
StartWithdrawExchangeRequest.java 0%
Sep6TransactionResponse.java 0% -0.9%
StartDepositRequest.java 0%
GetTransactionsRequest.java 0%
TransactionsOrderBy.java 0% 🍏
CustomerUpdatedResponse.java 0%
TransactionsOrder.java 0%
TransactionsSeps.java 0% 🍏
PlatformTransactionData.java 0% -4.8%
AnchorEvent.java 0% -61.4%
Sep12PutCustomerRequest.java 0% -0.29%
Sep12Status.java 0% 🍏
RequestCustomerInfoUpdateRequest.java 0% -3.59%
RequestOffchainFundsRequest.java 0% -0.9%
InstructionField.java 0%
StellarId.java 0% -1.45%

philipliu and others added 18 commits October 13, 2023 11:55
### Description

This sets the `customers`(See `TransactionSEP31`
[docs](https://developers.stellar.org/api/anchor-platform/resources/get-transaction))
field in the SEP-6 platform transaction.

### Context

When the business server receives a transaction event, it needs to
verify if the customer has enough KYC information to proceed with the
transaction. Currently, the platform transaction only has
`source_account` and `destination_account` fields which is not enough to
identify users using a custodial wallet.

### Testing

- `./gradlew test`

### Known limitations

This persists SEP-12 customer IDs in the SEP-6 transaction table. SEP-12
customers can be deleted at any time, therefore an anchor may lose the
mapping from transactions to these customers. This should be fine though
since transactions would likely not move back into
`pending_customer_info_update` after accepting user funds and can be
completed.
…info_updates (#1161)

### Description

This updates the SEP-6 E2E test to use the
`required_customer_info_updates` field when providing KYC updates.

### Context

Currently, this field is not set by the reference server implementation.
This is needed so that the demo wallet could prompt the user to submit
the missing KYC information.

### Testing

- `./gradlew test`

### Known limitations

N/A
### Description

This sets the `client_id` in the `GET /fee` integration request. It also
fixes a bug where the `senderId` and `receiverId`s were incorrectly set
in the same request.

### Context

Client attribution should work for SEP-6.

### Testing

- `./gradlew test`

### Known limitations

N/A
### Description

Merge `develop` into `sep-6`.

### Context

`sep-6` will be released soon.

### Testing

- `./gradlew test`

### Known limitations

N/A
### Description

This commit adds the `type` field to the SEP-6 platform transaction.

### Context

The `type` determines which fields need to be collected for KYC.

### Testing

- `./gradlew test`

### Known limitations

N/A
### Description

This fixes two test concurrency bugs due to static mocking.

1. `Sep10ServiceTest`: the verify sees two calls to
`Sep10Challenge#newChallenge`. My guess is that the `LockAndMockStatic`
annotation does not know about `ParameterizedTest`s.
2. `Sep24ServiceTest`: the mock of `KeyPair` in `Sep10ServiceTest` to
throw an exception causes the `Sep24Service` to throw it as well.

These two issues were only observed in the `sep-6` branch despite it
using static mocks or touching existing tests.

### Context

Fixes test stability in `sep-6` branch.

### Testing

- Ran `./gradlew test` a few times

### Documentation

N/A

### Known limitations

This is only a temporary fix as it does not prevent us from writing
similar tests in the future.
### Description

This removes KYC verification from the SEP-6 transaction initiation. Now
that KYC is removed, the customer may not be known to the Anchor at the
time of transaction initiation so the `customer` field cannot be set. To
allow Anchors to associate SEP transactions with a customer, the SEP-10
account memo is now added as a field to the `StellarId` object.

This means for the exchange endpoints, the platform can no longer make a
request to the Fee integration as it requires setting SEP-12 sender and
receiver fields. Business servers are expected to update the amounts
asynchronously like they already do for regular fees.

### Context

KYC verification is done "interactively" in SEP-6.

### Testing

- `./gradlew test`

### Documentation

Stellar docs need to be updated so that the `StellarId` object includes
an optional `memo` field

### Known limitations

N/A
### 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
### Description

Cleanly shut down the reference server's Kafka consumer.

### Context

I am making this small change to test why the CI passes in PR, but not
after merging into `sep-6` branch.

### Testing

- `./gradlew test`

### Documentation

N/A

### Known limitations

N/A
### Description

Merges `develop` into `sep-6`.

### Context

Keep `sep-6` branch up to date.

### Testing

- `./gradlew test`

### Documentation

N/A

### Known limitations

N/A
@philipliu philipliu changed the title Implement SEP-6 [Feature] Merge sep-6 into develop Nov 1, 2023
philipliu and others added 2 commits November 2, 2023 18:36
### Description

This implements the custody service RPC actions. This includes payments
as well as refunds.

### Context

SEP-6 will support custodians.

### Testing

- `./gradlew test`

### Documentation

- [stellar-docs](stellar/stellar-docs#253)

### Known limitations

N/A
@philipliu philipliu marked this pull request as ready for review November 2, 2023 22:51
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

### Description

Merges `develop` into `sep-6`.

### Context

Keep `sep-6` branch up to date.

### Testing

- `./gradlew test`

### Documentation

N/A

### Known limitations

N/A
@philipliu philipliu merged commit fd7b651 into develop Nov 3, 2023
5 checks passed
@philipliu philipliu deleted the sep-6 branch November 3, 2023 14:23
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.

2 participants