Skip to content

Commit 7ee2bf6

Browse files
authored
Separate withdraw and deposit description in gateway commands
1 parent 7361b28 commit 7ee2bf6

12 files changed

Lines changed: 59 additions & 23 deletions

File tree

api/api-core/src/main/kotlin/co/nilin/opex/api/core/inout/GatewayCommand.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ open abstract class CurrencyGatewayCommand(
3030
open var depositMax: BigDecimal? = BigDecimal.ZERO,
3131
open var withdrawMin: BigDecimal? = BigDecimal.ZERO,
3232
open var withdrawMax: BigDecimal? = BigDecimal.ZERO,
33-
open var description: String? = null,
33+
open var depositDescription: String? = null,
34+
open var withdrawDescription: String? = null,
3435
open var displayOrder: Int? = null,
3536
)
3637

@@ -47,7 +48,8 @@ data class OffChainGatewayCommand(
4748
override var depositMax: BigDecimal? = BigDecimal.ZERO,
4849
override var withdrawMin: BigDecimal? = BigDecimal.ZERO,
4950
override var withdrawMax: BigDecimal? = BigDecimal.ZERO,
50-
override var description: String? = null,
51+
override var depositDescription: String? = null,
52+
override var withdrawDescription: String? = null,
5153
override var displayOrder: Int? = null,
5254

5355
) : CurrencyGatewayCommand(
@@ -62,7 +64,8 @@ data class OffChainGatewayCommand(
6264
depositMax,
6365
withdrawMin,
6466
withdrawMax,
65-
description,
67+
depositDescription,
68+
withdrawDescription,
6669
displayOrder
6770
)
6871

@@ -85,7 +88,8 @@ data class OnChainGatewayCommand(
8588
override var depositMax: BigDecimal? = BigDecimal.ZERO,
8689
override var withdrawMin: BigDecimal? = BigDecimal.ZERO,
8790
override var withdrawMax: BigDecimal? = BigDecimal.ZERO,
88-
override var description: String? = null,
91+
override var depositDescription: String? = null,
92+
override var withdrawDescription: String? = null,
8993
override var displayOrder: Int? = null,
9094
) : CurrencyGatewayCommand(
9195
currencySymbol,
@@ -99,7 +103,8 @@ data class OnChainGatewayCommand(
99103
depositMax,
100104
withdrawMin,
101105
withdrawMax,
102-
description,
106+
depositDescription,
107+
withdrawDescription,
103108
displayOrder
104109
)
105110

bc-gateway/bc-gateway-core/src/main/kotlin/co/nilin/opex/bcgateway/core/model/CryptoCurrencyCommand.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ data class CryptoCurrencyCommand(
2020
var depositMax: BigDecimal? = BigDecimal.ZERO,
2121
var decimal: Int,
2222
var chain: String,
23-
var description: String?,
23+
var depositDescription: String? = null,
24+
var withdrawDescription: String? = null,
2425
var displayOrder: Int? = null,
2526
var type: String = "OnChain",
2627

bc-gateway/bc-gateway-core/src/main/kotlin/co/nilin/opex/bcgateway/core/service/AssignAddressServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ open class AssignAddressServiceImpl(
3030
?: throw OpexError.CurrencyNotFound.exception()
3131

3232
val requestedChain = chainLoader.fetchChainInfo(requestedGateway.chain)
33-
val addressTypes = requestedChain?.addressTypes
33+
val addressTypes = requestedChain?.addressTypes?: throw OpexError.BadRequest.exception()
3434

3535
val userAssignedAddresses =
3636
(assignedAddressHandler.fetchAssignedAddresses(user, addressTypes!!)).toMutableList()

bc-gateway/bc-gateway-ports/bc-gateway-persister-postgres/src/main/kotlin/co/nilin/opex/bcgateway/ports/postgres/impl/ChainHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ChainHandler(
2424
) : ChainLoader {
2525

2626
override suspend fun addChain(name: String, addressType: String): Chain {
27-
val chain = chainRepository.findByName(name).awaitFirstOrNull()
27+
val chain = chainRepository.findByName(name)?.awaitFirstOrNull()
2828
if (chain != null)
2929
throw OpexError.BadRequest.exception()
3030

@@ -51,7 +51,7 @@ class ChainHandler(
5151
}
5252

5353
override suspend fun fetchChainInfo(chain: String): Chain {
54-
val chainDao = chainRepository.findByName(chain).awaitSingle()
54+
val chainDao = chainRepository.findByName(chain)?.awaitSingle()
5555
val addressTypes = chainRepository.findAddressTypesByName(chain)
5656
.map { AddressType(it.id!!, it.type, it.addressRegex, it.memoRegex) }.toList()
5757
return Chain(chainDao.name, addressTypes)

bc-gateway/bc-gateway-ports/bc-gateway-persister-postgres/src/main/kotlin/co/nilin/opex/bcgateway/ports/postgres/impl/CurrencyHandlerImpl.kt

Whitespace-only changes.

bc-gateway/bc-gateway-ports/bc-gateway-persister-postgres/src/main/kotlin/co/nilin/opex/bcgateway/ports/postgres/model/CurrencyOnChainGatewayModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ class CurrencyOnChainGatewayModel(
2525
@Column("deposit_max") var depositMax: BigDecimal? = BigDecimal.ZERO, @Column("decimal") var decimal: Int,
2626
@Column("is_deposit_active") var isDepositActive: Boolean? = true,
2727
@Column("is_withdraw_active") var isWithdrawActive: Boolean? = true,
28-
@Column("description") val description: String?,
28+
@Column("deposit_description") val depositDescription: String?,
29+
@Column("withdraw_description") val withdrawDescription: String?,
2930
@Column("display_order") val displayOrder: Int? = null,
3031

3132
)

bc-gateway/bc-gateway-ports/bc-gateway-persister-postgres/src/main/kotlin/co/nilin/opex/bcgateway/ports/postgres/util/convertor.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ fun CryptoCurrencyCommand.toModel(): CurrencyOnChainGatewayModel {
2323
decimal,
2424
isDepositActive,
2525
isWithdrawActive,
26-
description,
26+
depositDescription,
27+
withdrawDescription,
2728
displayOrder,
2829
)
2930
}
@@ -48,9 +49,9 @@ fun CurrencyOnChainGatewayModel.toDto(): CryptoCurrencyCommand {
4849
depositMax,
4950
decimal,
5051
chain,
51-
description,
52+
depositDescription,
53+
withdrawDescription,
5254
displayOrder,
53-
5455
)
5556

5657
}

bc-gateway/bc-gateway-ports/bc-gateway-persister-postgres/src/main/resources/schema.sql

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,21 @@ CREATE TABLE IF NOT EXISTS currency_on_chain_gateway
7979
decimal INTEGER NOT NULL,
8080
is_deposit_active BOOLEAN NOT NULL DEFAULT TRUE,
8181
is_withdraw_active BOOLEAN NOT NULL DEFAULT TRUE,
82-
description TEXT,
82+
deposit_description TEXT,
83+
withdraw_description TEXT,
8384
display_order INTEGER,
8485
UNIQUE (currency_symbol, chain, implementation_symbol)
8586
);
87+
ALTER TABLE currency_on_chain_gateway
88+
add COLUMN IF NOT EXISTS deposit_description TEXT;
8689

8790

91+
ALTER TABLE currency_on_chain_gateway
92+
add COLUMN IF NOT EXISTS withdraw_description TEXT;
93+
94+
ALTER TABLE currency_on_chain_gateway
95+
drop COLUMN IF EXISTS description;
96+
8897

8998
CREATE TABLE IF NOT EXISTS deposits
9099
(

wallet/wallet-core/src/main/kotlin/co/nilin/opex/wallet/core/inout/GatewayCommand.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ open abstract class CurrencyGatewayCommand(
3030
open var depositMax: BigDecimal? = BigDecimal.ZERO,
3131
open var withdrawMin: BigDecimal? = BigDecimal.ZERO,
3232
open var withdrawMax: BigDecimal? = BigDecimal.ZERO,
33-
open var description: String? = null,
33+
open var depositDescription: String? = null,
34+
open var withdrawDescription: String? = null,
3435
open var displayOrder: Int? = null,
3536
)
3637

@@ -47,7 +48,8 @@ data class OffChainGatewayCommand(
4748
override var depositMax: BigDecimal? = BigDecimal.ZERO,
4849
override var withdrawMin: BigDecimal? = BigDecimal.ZERO,
4950
override var withdrawMax: BigDecimal? = BigDecimal.ZERO,
50-
override var description: String? = null,
51+
override var depositDescription: String? = null,
52+
override var withdrawDescription: String? = null,
5153
override var displayOrder: Int? = null,
5254
) : CurrencyGatewayCommand(
5355
currencySymbol,
@@ -61,7 +63,8 @@ data class OffChainGatewayCommand(
6163
depositMax,
6264
withdrawMin,
6365
withdrawMax,
64-
description,
66+
depositDescription,
67+
withdrawDescription,
6568
displayOrder
6669
)
6770

@@ -84,7 +87,8 @@ data class OnChainGatewayCommand(
8487
override var depositMax: BigDecimal? = BigDecimal.ZERO,
8588
override var withdrawMin: BigDecimal? = BigDecimal.ZERO,
8689
override var withdrawMax: BigDecimal? = BigDecimal.ZERO,
87-
override var description: String? = null,
90+
override var depositDescription: String? = null,
91+
override var withdrawDescription: String? = null,
8892
override var displayOrder: Int? = null,
8993
) : CurrencyGatewayCommand(
9094
currencySymbol,
@@ -98,7 +102,8 @@ data class OnChainGatewayCommand(
98102
depositMax,
99103
withdrawMin,
100104
withdrawMax,
101-
description,
105+
depositDescription,
106+
withdrawDescription,
102107
displayOrder
103108
)
104109

wallet/wallet-ports/wallet-persister-postgres/src/main/kotlin/co/nilin/opex/wallet/ports/postgres/model/OffChainGatewayModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ data class OffChainGatewayModel(
2121
@Column("transfer_method") var transferMethod: String,
2222
@Column("is_deposit_active") var isDepositActive: Boolean? = true,
2323
@Column("is_withdraw_active") var isWithdrawActive: Boolean? = true,
24-
@Column("description") val description: String? = null,
24+
@Column("deposit_description") val depositDescription: String?,
25+
@Column("withdraw_description") val withdrawDescription: String?,
2526
@Column("display_order") val displayOrder: Int? = null,
2627
)

0 commit comments

Comments
 (0)