-
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
Changes from 1 commit
137d188
465a39c
114ba5f
e96e43e
44a66ec
671888f
2cd226b
01bc40e
c93e741
fc96602
018ed0d
4310a6c
9d14529
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
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.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(::StrigaWalletRepositoryMapper) | ||
factoryOf(::StrigaWalletRemoteRepository) bind StrigaWalletRepository::class | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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.StrigaInitiateOnchainWithdrawalRequest | ||
import org.p2p.wallet.striga.wallet.api.response.StrigaEnrichFiatAccountResponse | ||
import org.p2p.wallet.striga.wallet.api.response.StrigaInitiateOnchainWithdrawalResponse | ||
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: StrigaInitiateOnchainWithdrawalRequest | ||
): StrigaInitiateOnchainWithdrawalResponse | ||
|
||
@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 | ||
} |
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 address: String, | ||
eduardmaximovich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@SerializedName("currency") | ||
val currency: String, | ||
@SerializedName("network") | ||
val network: String, | ||
@SerializedName("label") | ||
val label: String? = null | ||
) |
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, | ||
) |
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, | ||
) |
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 StrigaInitiateOnchainWithdrawalRequest( | ||
@SerializedName("userId") | ||
val userId: String, | ||
@SerializedName("sourceAccountId") | ||
val sourceAccountId: String, | ||
@SerializedName("whitelistedAddressId") | ||
val whitelistedAddressId: String, | ||
@SerializedName("amount") | ||
val amount: String, | ||
) |
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? | ||
) |
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 domestic: Boolean, | ||
eduardmaximovich marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@SerializedName("routingCodeEntries") | ||
val routingCodeEntries: List<String>, | ||
@SerializedName("payInReference") | ||
val payInReference: String?, | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package org.p2p.wallet.striga.wallet.api.response | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
class StrigaInitiateOnchainWithdrawalResponse( | ||
@SerializedName("challengeId") | ||
val challengeId: String, | ||
@SerializedName("dateExpires") | ||
val dateExpires: String, | ||
@SerializedName("transaction") | ||
val transaction: Transaction, | ||
@SerializedName("feeEstimate") | ||
val feeEstimate: FeeEstimate, | ||
) { | ||
|
||
class Transaction( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TransactionRequest just Transaction can be too ambiguous imho There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
@SerializedName("syncedOwnerId") | ||
val syncedOwnerId: String, | ||
@SerializedName("sourceAccountId") | ||
val sourceAccountId: String, | ||
@SerializedName("parentWalletId") | ||
val parentWalletId: String, | ||
@SerializedName("currency") | ||
val currency: String, | ||
@SerializedName("amount") | ||
val amount: 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, | ||
) | ||
|
||
class FeeEstimate( | ||
@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, | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.p2p.wallet.striga.wallet.api.response | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
class StrigaWhitelistedAddressItemResponse( | ||
@SerializedName("id") | ||
val id: String, | ||
@SerializedName("status") | ||
val status: String, | ||
@SerializedName("address") | ||
val address: String, | ||
@SerializedName("currency") | ||
val currency: String, | ||
@SerializedName("network") | ||
val network: StrigaBlockchainNetworkResponse | ||
) |
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 StrigaWhitelistedAddressesResponse( | ||
@SerializedName("addresses") | ||
val addresses: List<StrigaWhitelistedAddressItemResponse>, | ||
@SerializedName("count") | ||
val count: Int, | ||
@SerializedName("total") | ||
val total: Int | ||
) |
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