wip: parse swap

This commit is contained in:
Emil Sawicki 2024-10-11 13:52:56 +02:00
parent 558e99c990
commit 33da74a079
3 changed files with 26 additions and 15 deletions

View File

@ -137,10 +137,15 @@ proc `$`*(contactUrlDataDto: ContactUrlDataDto): string =
jsonObj["publicKey"] = %* contactUrlDataDto.publicKey
return $jsonObj
proc `%`*(transactionURLData: TransactionURLDataDto): JsonNode =
return %* [{
"txType": transactionURLData.txType,
"asset": transactionURLData.asset,
"amount": transactionURLData.amount,
"address": transactionURLData.address,
"chainId": transactionURLData.chainId,
"toAsset": transactionURLData.toAsset,
}]
proc `$`*(transactionURLData: TransactionURLDataDto): string =
var jsonObj = newJObject()
jsonObj["txType"] = %* transactionURLData.txType
jsonObj["asset"] = %* transactionURLData.asset
jsonObj["amount"] = %* transactionURLData.amount
jsonObj["address"] = %* transactionURLData.address
return $jsonObj
return $(%transactionURLData)

View File

@ -151,7 +151,7 @@ StatusDialog {
id: shareButton
onClicked: {
const url = root.swapAdaptor.getShareTransactionUrl(Constants.SendType.Swap,
const url = root.swapAdaptor.swapStore.getShareTransactionUrl(Constants.SendType.Swap,
root.swapInputParamsForm.fromTokensKey,
root.swapInputParamsForm.fromTokenAmount,
root.swapInputParamsForm.selectedAccountAddress,

View File

@ -43,6 +43,7 @@ import AppLayouts.Chat.stores 1.0 as ChatStores
import AppLayouts.Communities.stores 1.0
import AppLayouts.Wallet.stores 1.0 as WalletStores
import AppLayouts.Wallet.popups 1.0 as WalletPopups
import AppLayouts.Wallet.popups.swap 1.0 as WalletSwapPopups
import mainui.activitycenter.stores 1.0
import mainui.activitycenter.popups 1.0
@ -386,7 +387,12 @@ Item {
console.log("=========== onShowTransactionModal txType:", txType, "asset:", asset, "amount:", amount, "address:", address, "chainId:", chainId, "toAsset:", toAsset)
if (txType === Constants.SendType.Swap) {
// TODO_ES implement
d.swapFormData.fromTokensKey = asset
d.swapFormData.toTokenKey = toAsset
d.swapFormData.fromTokenAmount = amount
d.swapFormData.selectedAccountAddress = address
d.swapFormData.selectedNetworkChainId = chainId
Global.openSwapModalRequested(d.swapFormData)
return
}
@ -400,16 +406,12 @@ Item {
case Constants.SendType.ERC1155Transfer:
sendModal.preSelectedHoldingType = Constants.TokenType.ERC1155
break
case Constants.SendType.Transfer:
sendModal.preSelectedHoldingType = Constants.TokenType.ERC20
break
case Constants.SendType.ENSRegister: // TODO_ES test ens
case Constants.SendType.ENSRegister:
case Constants.SendType.ENSSetPubKey:
case Constants.SendType.ENSRelease:
sendModal.preSelectedHoldingType = Constants.TokenType.ENS
break
case Constants.SendType.Transfer:
case Constants.SendType.StickersBuy:
// TOOD_ES handle
sendModal.preSelectedHoldingType = Constants.TokenType.ERC20
break
default:
break
@ -421,6 +423,10 @@ Item {
QtObject {
id: d
property WalletSwapPopups.SwapInputParamsForm swapFormData: WalletSwapPopups.SwapInputParamsForm {
selectedAccountAddress: WalletStores.RootStore.selectedAddress
}
property var activityCenterPopupObj: null
function openActivityCenterPopup() {