mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-31 16:56:05 +00:00
chores(@desktop/chat): add guard when buying stickers
Call the same function as to when we do a transaction to validate the argument
This commit is contained in:
parent
cd8b539dc6
commit
20b1bed309
src
@ -113,8 +113,15 @@ QtObject:
|
|||||||
self.gasEstimateReturned(estimateResult.estimate, estimateResult.uuid)
|
self.gasEstimateReturned(estimateResult.estimate, estimateResult.uuid)
|
||||||
|
|
||||||
proc buy*(self: StickersView, packId: int, address: string, price: string, gas: string, gasPrice: string, password: string): string {.slot.} =
|
proc buy*(self: StickersView, packId: int, address: string, price: string, gas: string, gasPrice: string, password: string): string {.slot.} =
|
||||||
|
try:
|
||||||
|
validateTransactionInput(address, address, "", price, gas, gasPrice, "", "ok")
|
||||||
|
except Exception as e:
|
||||||
|
error "Error buying sticker pack", msg = e.msg
|
||||||
|
return ""
|
||||||
|
|
||||||
var success: bool
|
var success: bool
|
||||||
let response = self.status.stickers.buyPack(packId, address, price, gas, gasPrice, password, success)
|
let response = self.status.stickers.buyPack(packId, address, price, gas, gasPrice, password, success)
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
# check if response["error"] is not null and handle the error
|
# check if response["error"] is not null and handle the error
|
||||||
result = $(%* { "result": %response, "success": %success })
|
result = $(%* { "result": %response, "success": %success })
|
||||||
|
@ -145,6 +145,7 @@ proc validateTransactionInput*(from_addr, to_addr, assetAddress, value, gas, gas
|
|||||||
if parseFloat(value) < 0: raise newException(ValueError, "value should be a number >= 0")
|
if parseFloat(value) < 0: raise newException(ValueError, "value should be a number >= 0")
|
||||||
if parseInt(gas) <= 0: raise newException(ValueError, "gas should be a number > 0")
|
if parseInt(gas) <= 0: raise newException(ValueError, "gas should be a number > 0")
|
||||||
if parseFloat(gasPrice) <= 0: raise newException(ValueError, "gasPrice should be a number > 0")
|
if parseFloat(gasPrice) <= 0: raise newException(ValueError, "gasPrice should be a number > 0")
|
||||||
|
|
||||||
if uuid.isEmptyOrWhitespace(): raise newException(ValueError, "uuid is required")
|
if uuid.isEmptyOrWhitespace(): raise newException(ValueError, "uuid is required")
|
||||||
|
|
||||||
if assetAddress != "": # If a token is being used
|
if assetAddress != "": # If a token is being used
|
||||||
|
Loading…
x
Reference in New Issue
Block a user