Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ data class WithdrawHistoryResponse(
val withdrawId: Long?,
val uuid: String,
val amount: BigDecimal,
val currency: String,
val acceptedFee: BigDecimal,
val appliedFee: BigDecimal?,
val destAmount: BigDecimal?,
val destCurrency: String?,
val destSymbol: String?,
Comment thread
maryarm marked this conversation as resolved.
val destAddress: String?,
val destNetwork: String?,
var destNote: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class WalletController(
LocalDateTime.ofInstant(Instant.ofEpochMilli(it.createDate), ZoneId.systemDefault())
.toString()
.replace("T", " "),
it.destCurrency ?: "",
it.destSymbol ?: "",
it.withdrawId?.toString() ?: "",
"",
it.destNetwork ?: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,28 @@ class WithdrawController(private val withdrawService: WithdrawService) {
)
suspend fun requestWithdraw(
principal: Principal,
@PathVariable("symbol") symbol: String,
@PathVariable("currency") currency: String,
@PathVariable("amount") amount: BigDecimal,
@RequestParam("description", required = false) description: String?,
@RequestParam("transferRef", required = false) transferRef: String?,
@RequestParam("fee") fee: BigDecimal,
@RequestParam("destCurrency") destCurrency: String,
@RequestParam("destSymbol") destSymbol: String,
@RequestParam("destAddress") destAddress: String,
@RequestParam("destNetwork") destNetwork: String,
@RequestParam("destNote", required = false) destNote: String?,
): WithdrawResult {
return withdrawService.requestWithdraw(
WithdrawCommand(
principal.name, symbol,
amount, description, transferRef, destCurrency, destAddress, destNetwork, destNote, fee
principal.name,
currency,
amount,
description,
transferRef,
destSymbol,
destAddress,
destNetwork,
destNote,
fee
)
)
}
Expand All @@ -99,10 +107,11 @@ class WithdrawController(private val withdrawService: WithdrawService) {
it.withdrawId,
it.ownerUuid,
it.amount,
it.currency,
it.acceptedFee,
it.appliedFee,
it.destAmount,
it.destCurrency,
it.destSymbol,
it.destAddress,
it.destNetwork,
it.destNote,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ data class WithdrawHistoryResponse(
val withdrawId: Long? = null,
val uuid: String,
val amount: BigDecimal,
val currency: String,
val acceptedFee: BigDecimal,
val appliedFee: BigDecimal?,
val destAmount: BigDecimal?,
val destCurrency: String?,
val destSymbol: String?,
val destAddress: String?,
val destNetwork: String?,
var destNote: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import java.math.BigDecimal

class WithdrawCommand(
val uuid: String,
val symbol: String,
val currency: String,
val amount: BigDecimal,
val description: String?,
val transferRef: String?,
val destCurrency: String,
val destSymbol: String,
val destAddress: String,
val destNetwork: String,
val destNote: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class WithdrawResponse(
val appliedFee: BigDecimal?,
val amount: BigDecimal?,
val destAmount: BigDecimal?,
val destCurrency: String?,
val destSymbol: String?,
val destAddress: String?,
val destNetwork: String?,
var destNote: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import java.time.LocalDateTime
data class Withdraw(
val withdrawId: Long? = null,
val ownerUuid: String,
val currency: String,
val wallet: Long,
val amount: BigDecimal,
val requestTransaction: String,
val finalizedTransaction: String?,
val acceptedFee: BigDecimal,
val appliedFee: BigDecimal?,
val destAmount: BigDecimal?,
val destCurrency: String?,
val destSymbol: String?,
val destAddress: String?,
val destNetwork: String?,
var destNote: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WithdrawService(
suspend fun requestWithdraw(
withdrawCommand: WithdrawCommand
): WithdrawResult {
val currency = currencyService.getCurrency(withdrawCommand.symbol) ?: throw IllegalArgumentException()
val currency = currencyService.getCurrency(withdrawCommand.currency) ?: throw IllegalArgumentException()
val owner = walletOwnerManager.findWalletOwner(withdrawCommand.uuid) ?: throw IllegalArgumentException()
val sourceWallet =
walletManager.findWalletByOwnerAndCurrencyAndType(owner, "main", currency)
Expand All @@ -51,12 +51,23 @@ class WithdrawService(
)
val withdraw = withdrawPersister.persist(
Withdraw(
null, owner.uuid, receiverWallet.id!!, withdrawCommand.amount,
transferResultDetailed.tx, null,
withdrawCommand.acceptedFee, null,
null, withdrawCommand.destCurrency,
withdrawCommand.destAddress, withdrawCommand.destNetwork,
withdrawCommand.destNote, null, null, "CREATED"
null,
owner.uuid,
currency.symbol,
receiverWallet.id!!,
withdrawCommand.amount,
transferResultDetailed.tx,
null,
withdrawCommand.acceptedFee,
null,
null,
withdrawCommand.destSymbol,
withdrawCommand.destAddress,
withdrawCommand.destNetwork,
withdrawCommand.destNote,
null,
null,
"CREATED"
)
)
return WithdrawResult(withdraw.withdrawId!!, withdraw.status)
Expand Down Expand Up @@ -97,14 +108,15 @@ class WithdrawService(
Withdraw(
withdraw.withdrawId,
withdraw.ownerUuid,
withdraw.currency,
withdraw.wallet,
withdraw.amount,
withdraw.requestTransaction,
transferResultDetailed.tx,
withdraw.acceptedFee,
withdraw.appliedFee,
withdraw.amount.subtract(acceptCommand.appliedFee),
withdraw.destCurrency,
withdraw.destSymbol,
withdraw.destAddress,
withdraw.destNetwork,
withdraw.destNote ?: ("" + "-----------" + (acceptCommand.destNote ?: "")),
Expand Down Expand Up @@ -150,14 +162,15 @@ class WithdrawService(
Withdraw(
withdraw.withdrawId,
withdraw.ownerUuid,
withdraw.currency,
withdraw.wallet,
withdraw.amount,
withdraw.requestTransaction,
transferResultDetailed.tx,
withdraw.acceptedFee,
null,
null,
withdraw.destCurrency,
withdraw.destSymbol,
withdraw.destAddress,
withdraw.destNetwork,
withdraw.destNote ?: ("" + "-----------" + (rejectCommand.destNote ?: "")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ interface WithdrawRepository : ReactiveCrudRepository<WithdrawModel, String> {
"""
select * from withdraws
where uuid = :uuid
and dest_currency = :currency
and currency = :currency
Comment thread
maryarm marked this conversation as resolved.
and create_date > :startTime
and create_date <= :endTime
limit :limit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,15 @@ class WithdrawPersisterImpl(
WithdrawModel(
withdraw.withdrawId,
withdraw.ownerUuid,
withdraw.currency,
withdraw.wallet,
withdraw.amount,
withdraw.requestTransaction,
withdraw.finalizedTransaction,
withdraw.acceptedFee,
withdraw.appliedFee,
withdraw.destAmount,
withdraw.destCurrency,
withdraw.destSymbol,
withdraw.destNetwork,
withdraw.destAddress,
withdraw.destNote,
Expand Down Expand Up @@ -157,7 +158,7 @@ class WithdrawPersisterImpl(
appliedFee,
amount,
destAmount,
destCurrency,
destSymbol,
destAddress,
destNetwork,
destNote,
Expand All @@ -173,14 +174,15 @@ class WithdrawPersisterImpl(
return Withdraw(
id,
ownerUuid,
currency,
wallet,
amount,
requestTransaction,
finalizedTransaction,
acceptedFee,
appliedFee,
destAmount,
destCurrency,
destSymbol,
destAddress,
destNetwork,
destNote,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import java.time.LocalDateTime
data class WithdrawModel(
@Id var id: Long?,
@Column("uuid") val ownerUuid: String,
@Column("currency") val currency: String,
@Column("wallet") val wallet: Long,
@Column("amount") val amount: BigDecimal,
@Column("req_transaction_id") val requestTransaction: String,
@Column("final_transaction_id") val finalizedTransaction: String?,
@Column("accepted_fee") val acceptedFee: BigDecimal,
@Column("applied_fee") val appliedFee: BigDecimal?,
@Column("dest_amount") val destAmount: BigDecimal?,
@Column("dest_currency") val destCurrency: String?,
@Column("dest_symbol") val destSymbol: String?,
@Column("dest_network") val destNetwork: String?,
@Column("dest_address") val destAddress: String?,
@Column("dest_notes") var destNote: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,20 @@ CREATE TABLE IF NOT EXISTS withdraws
uuid VARCHAR(36) NOT NULL,
req_transaction_id VARCHAR(20) NOT NULL UNIQUE,
final_transaction_id VARCHAR(20) UNIQUE,
wallet INTEGER REFERENCES wallet (id),
amount DECIMAL NOT NULL,
accepted_fee DECIMAL,
currency VARCHAR(20) NOT NULL REFERENCES currency (symbol),
wallet INTEGER NOT NULL REFERENCES wallet (id),
amount DECIMAL NOT NULL,
accepted_fee DECIMAL NOT NULL,
applied_fee DECIMAL,
dest_amount DECIMAL,
dest_currency VARCHAR(20) REFERENCES currency (symbol),
dest_symbol VARCHAR(20),
dest_network VARCHAR(20),
dest_address VARCHAR(80),
dest_notes TEXT,
dest_transaction_ref VARCHAR(100),
description TEXT,
status_reason TEXT,
status VARCHAR(20),
create_date TIMESTAMP NOT NULL,
create_date TIMESTAMP NOT NULL,
accept_date TIMESTAMP
);