-
Notifications
You must be signed in to change notification settings - Fork 18
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
eduardmaximovich
merged 13 commits into
develop
from
feature/PWN-8895-striga-payment-api
Jun 28, 2023
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
137d188
PWN-8895, PWN-8776 - striga. payment api
eduardmaximovich 465a39c
Merge branch 'develop' of github_p2p:p2p-org/key-app-android into fea…
eduardmaximovich 114ba5f
PWN-8895, PWN-8776 - removed class doc
eduardmaximovich e96e43e
PWN-8895, PWN-8776 - comment fix
eduardmaximovich 44a66ec
PWN-8904 - Striga API. get_user_wallets (#1883)
gslevinkov 671888f
PWN-8895 - namings and improvements
eduardmaximovich 2cd226b
Merge branch 'develop' of github_p2p:p2p-org/key-app-android into fea…
eduardmaximovich 01bc40e
Merge branch 'feature/PWN-8895-striga-payment-api' of github_p2p:p2p-…
eduardmaximovich c93e741
PWN-8895 - merge
eduardmaximovich fc96602
Merge branch 'develop' of github_p2p:p2p-org/key-app-android into fea…
eduardmaximovich 018ed0d
PWN-8895 - amount -> amountInUnits
eduardmaximovich 4310a6c
PWN-8904 - Striga API. get_estimated_fees (#1884)
gslevinkov 9d14529
Merge branch 'develop' of github_p2p:p2p-org/key-app-android into fea…
eduardmaximovich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,25 @@ | ||
package org.p2p.wallet.striga | ||
|
||
import org.koin.core.module.dsl.factoryOf | ||
import org.koin.dsl.module | ||
import org.p2p.wallet.common.di.InjectionModule | ||
import org.p2p.wallet.infrastructure.network.interceptor.StrigaHeaderSignatureGenerator | ||
import org.p2p.wallet.kyc.StrigaFragmentFactory | ||
import org.p2p.wallet.striga.di.StrigaSignupModule | ||
import org.p2p.wallet.striga.di.StrigaWalletModule | ||
import org.p2p.wallet.striga.kyc.StrigaKycModule | ||
|
||
object StrigaModule : InjectionModule { | ||
|
||
override fun create() = module { | ||
includes( | ||
StrigaSignupModule.create(), | ||
StrigaKycModule.create() | ||
StrigaKycModule.create(), | ||
StrigaWalletModule.create() | ||
) | ||
|
||
factoryOf(::StrigaUserIdProvider) | ||
factoryOf(::StrigaHeaderSignatureGenerator) | ||
factoryOf(::StrigaFragmentFactory) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
app/src/main/java/org/p2p/wallet/striga/di/StrigaWalletModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.p2p.wallet.striga.di | ||
|
||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.core.module.Module | ||
import org.koin.core.module.dsl.factoryOf | ||
import org.koin.core.module.dsl.new | ||
import org.koin.dsl.bind | ||
import org.koin.dsl.module | ||
import retrofit2.create | ||
import org.p2p.wallet.R | ||
import org.p2p.wallet.common.di.InjectionModule | ||
import org.p2p.wallet.infrastructure.network.NetworkModule.getRetrofit | ||
import org.p2p.wallet.infrastructure.network.interceptor.StrigaProxyApiInterceptor | ||
import org.p2p.wallet.striga.wallet.api.StrigaWalletApi | ||
import org.p2p.wallet.striga.wallet.interactor.StrigaWalletInteractor | ||
import org.p2p.wallet.striga.wallet.repository.StrigaUserWalletsMapper | ||
import org.p2p.wallet.striga.wallet.repository.StrigaWalletRemoteRepository | ||
import org.p2p.wallet.striga.wallet.repository.StrigaWalletRepository | ||
import org.p2p.wallet.striga.wallet.repository.StrigaWalletRepositoryMapper | ||
|
||
object StrigaWalletModule : InjectionModule { | ||
|
||
override fun create(): Module = module { | ||
initDataLayer() | ||
|
||
factoryOf(::StrigaWalletInteractor) | ||
} | ||
|
||
private fun Module.initDataLayer() { | ||
single<StrigaWalletApi> { | ||
val url = androidContext().getString(R.string.strigaProxyServiceBaseUrl) | ||
getRetrofit( | ||
baseUrl = url, | ||
tag = "StrigaProxyApi", | ||
interceptor = new(::StrigaProxyApiInterceptor) | ||
).create() | ||
} | ||
|
||
factoryOf(::StrigaUserWalletsMapper) | ||
factoryOf(::StrigaWalletRepositoryMapper) | ||
factoryOf(::StrigaWalletRemoteRepository) bind StrigaWalletRepository::class | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
app/src/main/java/org/p2p/wallet/striga/wallet/api/StrigaWalletApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package org.p2p.wallet.striga.wallet.api | ||
|
||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
import org.p2p.wallet.striga.wallet.api.request.StrigaAddWhitelistedAddressRequest | ||
import org.p2p.wallet.striga.wallet.api.request.StrigaEnrichAccountRequest | ||
import org.p2p.wallet.striga.wallet.api.request.StrigaGetWhitelistedAddressesRequest | ||
import org.p2p.wallet.striga.wallet.api.request.StrigaInitWithdrawalRequest | ||
import org.p2p.wallet.striga.wallet.api.request.StrigaOnchainWithdrawalFeeRequest | ||
import org.p2p.wallet.striga.wallet.api.request.StrigaUserWalletsRequest | ||
import org.p2p.wallet.striga.wallet.api.response.StrigaEnrichFiatAccountResponse | ||
import org.p2p.wallet.striga.wallet.api.response.StrigaInitWithdrawalResponse | ||
import org.p2p.wallet.striga.wallet.api.response.StrigaOnchainWithdrawalFeeResponse | ||
import org.p2p.wallet.striga.wallet.api.response.StrigaUserWalletsResponse | ||
import org.p2p.wallet.striga.wallet.api.response.StrigaWhitelistedAddressItemResponse | ||
import org.p2p.wallet.striga.wallet.api.response.StrigaWhitelistedAddressesResponse | ||
|
||
interface StrigaWalletApi { | ||
|
||
@POST("v1/wallets/send/initiate/onchain") | ||
suspend fun initiateOnchainWithdrawal( | ||
@Body body: StrigaInitWithdrawalRequest | ||
): StrigaInitWithdrawalResponse | ||
|
||
@POST("v1/wallets/get/whitelisted-addresses") | ||
suspend fun getWhitelistedAddresses( | ||
@Body body: StrigaGetWhitelistedAddressesRequest | ||
): StrigaWhitelistedAddressesResponse | ||
|
||
@POST("v1/wallets/whitelist-address") | ||
suspend fun addWhitelistedAddress( | ||
@Body body: StrigaAddWhitelistedAddressRequest | ||
): StrigaWhitelistedAddressItemResponse | ||
|
||
/** | ||
* This method returns absolutely different responses for crypto and fiat accounts | ||
* So use it for fiat accounts only | ||
*/ | ||
@POST("v1/wallets/account/enrich") | ||
suspend fun enrichFiatAccount( | ||
@Body body: StrigaEnrichAccountRequest | ||
): StrigaEnrichFiatAccountResponse | ||
|
||
@POST("v1/wallets/get/all") | ||
suspend fun getUserWallets( | ||
@Body body: StrigaUserWalletsRequest | ||
): StrigaUserWalletsResponse | ||
|
||
@POST("v1/wallets/send/initiate/onchain/fee-estimate") | ||
suspend fun getOnchainWithdrawalFees( | ||
@Body body: StrigaOnchainWithdrawalFeeRequest | ||
): StrigaOnchainWithdrawalFeeResponse | ||
} |
16 changes: 16 additions & 0 deletions
16
.../main/java/org/p2p/wallet/striga/wallet/api/request/StrigaAddWhitelistedAddressRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.p2p.wallet.striga.wallet.api.request | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
class StrigaAddWhitelistedAddressRequest( | ||
@SerializedName("userId") | ||
val userId: String, | ||
@SerializedName("address") | ||
val addressToWhitelist: String, | ||
@SerializedName("currency") | ||
val currency: String, | ||
@SerializedName("network") | ||
val network: String, | ||
@SerializedName("label") | ||
val label: String? = null | ||
) |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/p2p/wallet/striga/wallet/api/request/StrigaEnrichAccountRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.p2p.wallet.striga.wallet.api.request | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
class StrigaEnrichAccountRequest( | ||
@SerializedName("userId") | ||
val userId: String, | ||
@SerializedName("accountId") | ||
val accountId: String, | ||
) |
10 changes: 10 additions & 0 deletions
10
...ain/java/org/p2p/wallet/striga/wallet/api/request/StrigaGetWhitelistedAddressesRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.p2p.wallet.striga.wallet.api.request | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
class StrigaGetWhitelistedAddressesRequest( | ||
@SerializedName("userId") | ||
val userId: String, | ||
@SerializedName("label") | ||
val label: String? = null, | ||
) |
21 changes: 21 additions & 0 deletions
21
app/src/main/java/org/p2p/wallet/striga/wallet/api/request/StrigaInitWithdrawalRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.p2p.wallet.striga.wallet.api.request | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
/** | ||
* @param userId The Id of the user who is sending this transaction | ||
* @param sourceAccountId The Id of the account to debit | ||
* @param whitelistedAddressId The Id of the whitelisted destination | ||
* @param amount The amount denominated in the smallest divisible unit of the sending currency. | ||
* For example: cents or satoshis | ||
*/ | ||
class StrigaInitWithdrawalRequest( | ||
@SerializedName("userId") | ||
val userId: String, | ||
@SerializedName("sourceAccountId") | ||
val sourceAccountId: String, | ||
@SerializedName("whitelistedAddressId") | ||
val whitelistedAddressId: String, | ||
@SerializedName("amount") | ||
val amountInUnits: String, | ||
) |
18 changes: 18 additions & 0 deletions
18
...c/main/java/org/p2p/wallet/striga/wallet/api/request/StrigaOnchainWithdrawalFeeRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.p2p.wallet.striga.wallet.api.request | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
/** | ||
* @param amountInUnits The amount denominated in the smallest divisible unit of the sending currency. | ||
* For example: cents or satoshis | ||
*/ | ||
class StrigaOnchainWithdrawalFeeRequest( | ||
@SerializedName("userId") | ||
val userId: String, | ||
@SerializedName("sourceAccountId") | ||
val sourceAccountId: String, | ||
@SerializedName("whitelistedAddressId") | ||
val whitelistedAddressId: String, | ||
@SerializedName("amount") | ||
val amountInUnits: String, | ||
) |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/org/p2p/wallet/striga/wallet/api/request/StrigaUserWalletsRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.p2p.wallet.striga.wallet.api.request | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import org.p2p.core.utils.MillisSinceEpoch | ||
|
||
class StrigaUserWalletsRequest( | ||
@SerializedName("userId") | ||
val userId: String, | ||
@SerializedName("startDate") | ||
val startDate: MillisSinceEpoch, | ||
@SerializedName("endDate") | ||
val endDate: MillisSinceEpoch, | ||
@SerializedName("page") | ||
val page: Long | ||
) |
12 changes: 12 additions & 0 deletions
12
...rc/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaBlockchainNetworkResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.p2p.wallet.striga.wallet.api.response | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
class StrigaBlockchainNetworkResponse( | ||
@SerializedName("name") | ||
val name: String, | ||
@SerializedName("contractAddress") | ||
val contractAddress: String?, | ||
@SerializedName("type") | ||
val type: String? | ||
) |
36 changes: 36 additions & 0 deletions
36
...rc/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaEnrichFiatAccountResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.p2p.wallet.striga.wallet.api.response | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
class StrigaEnrichFiatAccountResponse( | ||
@SerializedName("currency") | ||
val currency: String, | ||
@SerializedName("status") | ||
val status: String, | ||
@SerializedName("internalAccountId") | ||
val internalAccountId: String, | ||
@SerializedName("bankCountry") | ||
val bankCountry: String, | ||
@SerializedName("bankAddress") | ||
val bankAddress: String, | ||
@SerializedName("iban") | ||
val iban: String, | ||
@SerializedName("bic") | ||
val bic: String, | ||
@SerializedName("accountNumber") | ||
val accountNumber: String, | ||
@SerializedName("bankName") | ||
val bankName: String, | ||
@SerializedName("bankAccountHolderName") | ||
val bankAccountHolderName: String, | ||
@SerializedName("provider") | ||
val provider: String, | ||
@SerializedName("paymentType") | ||
val paymentType: String?, | ||
@SerializedName("domestic") | ||
val isDomesticAccount: Boolean, | ||
@SerializedName("routingCodeEntries") | ||
val routingCodeEntries: List<String>, | ||
@SerializedName("payInReference") | ||
val payInReference: String?, | ||
) |
37 changes: 37 additions & 0 deletions
37
app/src/main/java/org/p2p/wallet/striga/wallet/api/response/StrigaInitWithdrawalResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.p2p.wallet.striga.wallet.api.response | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
class StrigaInitWithdrawalResponse( | ||
@SerializedName("challengeId") | ||
val challengeId: String, | ||
@SerializedName("dateExpires") | ||
val dateExpires: String, | ||
@SerializedName("transaction") | ||
val transaction: WithdrawalTransactionResponse, | ||
@SerializedName("feeEstimate") | ||
val feeEstimate: StrigaOnchainWithdrawalFeeResponse, | ||
) { | ||
class WithdrawalTransactionResponse( | ||
@SerializedName("syncedOwnerId") | ||
val syncedOwnerId: String, | ||
@SerializedName("sourceAccountId") | ||
val sourceAccountId: String, | ||
@SerializedName("parentWalletId") | ||
val parentWalletId: String, | ||
@SerializedName("currency") | ||
val currency: String, | ||
@SerializedName("amount") | ||
val amountInUnits: String, | ||
@SerializedName("status") | ||
val status: String, | ||
@SerializedName("txType") | ||
val txType: String, | ||
@SerializedName("blockchainDestinationAddress") | ||
val blockchainDestinationAddress: String, | ||
@SerializedName("blockchainNetwork") | ||
val blockchainNetwork: StrigaBlockchainNetworkResponse, | ||
@SerializedName("transactionCurrency") | ||
val transactionCurrency: String, | ||
) | ||
} |
20 changes: 20 additions & 0 deletions
20
...main/java/org/p2p/wallet/striga/wallet/api/response/StrigaOnchainWithdrawalFeeResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.p2p.wallet.striga.wallet.api.response | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class StrigaOnchainWithdrawalFeeResponse( | ||
@SerializedName("totalFee") | ||
val totalFee: String, | ||
@SerializedName("networkFee") | ||
val networkFee: String, | ||
@SerializedName("ourFee") | ||
val ourFee: String, | ||
@SerializedName("theirFee") | ||
val theirFee: String, | ||
@SerializedName("feeCurrency") | ||
val feeCurrency: String, | ||
@SerializedName("gasLimit") | ||
val gasLimit: String, | ||
@SerializedName("gasPrice") | ||
val gasPrice: String | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
such a good name, man! thanks