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

PWN-8895, PWN-8776 - striga. payment api #1878

Merged
merged 13 commits into from
Jun 28, 2023

Conversation

eduardmaximovich
Copy link
Collaborator

@eduardmaximovich eduardmaximovich commented Jun 26, 2023

Jira Ticket

https://p2pvalidator.atlassian.net/browse/PWN-8895
https://p2pvalidator.atlassian.net/browse/PWN-8776

Description of Work

  • Implemented api calls for striga payment:
    • add address to whitelist (v1/wallets/whitelist-address)
    • get all whitelisted addresses (v1/wallets/get/whitelisted-addresses)
    • init onchain withdrawal (v1/wallets/send/initiate/onchain)
    • enrich (get or create fiat account details) (v1/wallets/account/enrich)
    • get user wallets (v1/wallets/get/all)
    • get_estimated_fees

@github-actions
Copy link

github-actions bot commented Jun 26, 2023

Code coverage report

File Coverage [67.70%]
app/src/main/java/org/p2p/wallet/striga/model/StrigaApiError.kt 97.30%
app/src/main/java/org/p2p/wallet/striga/wallet/api/request/StrigaAddWhitelistedAddressRequest.kt 54.55%
app/src/main/java/org/p2p/wallet/striga/wallet/api/request/StrigaEnrichAccountRequest.kt 60.00%
app/src/main/java/org/p2p/wallet/striga/wallet/api/request/StrigaGetWhitelistedAddressesRequest.kt 60.00%
app/src/main/java/org/p2p/wallet/striga/wallet/api/request/StrigaInitWithdrawalRequest.kt 55.56%
app/src/main/java/org/p2p/wallet/striga/wallet/api/request/StrigaOnchainWithdrawalFeeRequest.kt 0.00%
app/src/main/java/org/p2p/wallet/striga/wallet/api/request/StrigaUserWalletsRequest.kt 55.56%
app/src/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaBlockchainNetworkResponse.kt 42.86%
app/src/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaEnrichFiatAccountResponse.kt 48.39%
app/src/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaInitWithdrawalResponse.kt 46.67%
app/src/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaOnchainWithdrawalFeeResponse.kt 46.67%
app/src/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaUserWalletAccountResponse.kt 35.71%
app/src/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaUserWalletDetailsResponse.kt 13.33%
app/src/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaUserWalletsResponse.kt 33.33%
app/src/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaWhitelistedAddressItemResponse.kt 45.45%
app/src/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaWhitelistedAddressesResponse.kt 14.29%
app/src/main/java/org/p2p/wallet/striga/wallet/interactor/StrigaWalletInteractor.kt 0.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaBlockchainNetworkInfo.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaFiatAccountDetails.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaFiatAccountStatus.kt 75.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaInitWithdrawalDetails.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaNetworkCurrency.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaNetworkType.kt 50.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaOnchainTxStatus.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaOnchainTxType.kt 87.50%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaOnchainWithdrawalFees.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaUserWallet.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaUserWalletAccount.kt 93.75%
app/src/main/java/org/p2p/wallet/striga/wallet/models/StrigaWhitelistedAddressItem.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/ids/StrigaAccountId.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/ids/StrigaWalletId.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/ids/StrigaWhitelistedAddressId.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/models/ids/StrigaWithdrawalChallengeId.kt 100.00%
app/src/main/java/org/p2p/wallet/striga/wallet/repository/StrigaUserWalletsMapper.kt 92.86%
app/src/main/java/org/p2p/wallet/striga/wallet/repository/StrigaWalletRemoteRepository.kt 64.10%
app/src/main/java/org/p2p/wallet/striga/wallet/repository/StrigaWalletRepository.kt 50.00%
app/src/main/java/org/p2p/wallet/striga/wallet/repository/StrigaWalletRepositoryMapper.kt 98.25%
Total Project Coverage 8.22%

import org.p2p.wallet.striga.kyc.StrigaKycModule

object StrigaModule : InjectionModule {

override fun create() = module {
includes(
StrigaSignupModule.create(),
StrigaKycModule.create()
StrigaKycModule.create(),
StrigaWalletModule.create()
Copy link
Contributor

Choose a reason for hiding this comment

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

such a good name, man! thanks

val feeEstimate: FeeEstimate,
) {

class Transaction(
Copy link
Contributor

Choose a reason for hiding this comment

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

TransactionRequest
StrigaTransactionRequest

just Transaction can be too ambiguous imho

Copy link
Collaborator Author

@eduardmaximovich eduardmaximovich Jun 27, 2023

Choose a reason for hiding this comment

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

I will change it to TransactionResponse, because it's hard to get confused as it's a subclass. You can't just use the type TransactionResponse, you need to first specify the parent class as StrigaInitOnchainWithdrawalResponse.TransactionResponse

suspend fun getFiatAccountDetails(
accountId: StrigaAccountId,
): StrigaDataLayerResult<StrigaFiatAccountDetails> {
return repository.getFiatAccountDetails(userIdProvider.getUserIdOrThrow(), accountId)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can insert StrigaUserIdProvider inside the repo and catch error there so there are no unexpected throws?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Initialy I had made this way, but changed my mind and moved userIdProvider to interactor. I can move it back.

import kotlinx.parcelize.Parcelize

/**
* @param value The ID of an account. Format example: 01c1f4e73d8b2587921c74e98951add0
Copy link
Contributor

Choose a reason for hiding this comment

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

it is a Hex?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's a sort of UUID but without hyphens

* Error codes that might be returned by striga:
* [org.p2p.wallet.striga.model.StrigaApiErrorCode.USER_LIMIT_EXCEEDED] - amount is too big
* [org.p2p.wallet.striga.model.StrigaApiErrorCode.BELOW_MINIMUM_AMOUNT] - amount is too small
* [org.p2p.wallet.striga.model.StrigaApiErrorCode.INVALID_DESTINATION] - addressId is invalid
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather rename error codes instead of supporting this doc
USER_LIMIT_EXCEEDED -> TOO_LARGE_AMOUNT
BELOW_MINIMUM_AMOUNT -> TOO_MIN_AMOUNT
INVALID_DESTINATION -> INVALID_ADDRESS_ID

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

First 2 - ok, but third might be ambigous, 'cause striga already has code 41006 Invalid address and I don't know in what cases we could get it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Finally, i've renamed this way:
TOO_LARGE_AMOUNT
TOO_SMALL_AMOUNT
INVALID_DESTINATION_ADDRESS (kept "destination" to avoid confusion)


assertTrue(result is StrigaDataLayerResult.Success)
result as StrigaDataLayerResult.Success<StrigaFiatAccountDetails>
assertEquals("EUR", result.value.currency)
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use mockito-kotlin assertions

@gslevinkov gslevinkov added the PR TOO BIG This PR is over 25 files changes threshold label Jun 27, 2023
…org/key-app-android into feature/PWN-8895-striga-payment-api

� Conflicts:
�	app/src/main/java/org/p2p/wallet/striga/wallet/api/StrigaWalletApi.kt
�	app/src/main/java/org/p2p/wallet/striga/wallet/repository/StrigaWalletRemoteRepository.kt
�	app/src/main/java/org/p2p/wallet/striga/wallet/repository/StrigaWalletRepository.kt
�	app/src/test/java/org/p2p/wallet/striga/wallet/repository/StrigaWalletRepositoryEnrichAccountTest.kt
* PWN-8904 - Striga API. get_estimated_fees

* PWN-8904 - comment fixes

* PWN-8904 - change base url

* PWN-8904 - add StrigaUserWalletsMapper to koin

* PWN-8904 - add ending slashes to new striga urls

---------

Co-authored-by: Eduard Maximovich <[email protected]>
@eduardmaximovich eduardmaximovich merged commit f426b32 into develop Jun 28, 2023
2 of 3 checks passed
@eduardmaximovich eduardmaximovich deleted the feature/PWN-8895-striga-payment-api branch June 28, 2023 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR TOO BIG This PR is over 25 files changes threshold
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants