2024-11-05 18:51:17 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
|
|
|
|
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
2024-11-05 15:59:45 +00:00
|
|
|
import AppLayouts.Wallet.popups.simpleSend 1.0
|
2024-11-05 18:51:17 +00:00
|
|
|
|
|
|
|
import shared.popups.send 1.0
|
|
|
|
import shared.stores.send 1.0
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
required property var popupParent
|
|
|
|
required property int loginType
|
|
|
|
required property TransactionStore transactionStore
|
|
|
|
required property WalletStores.CollectiblesStore walletCollectiblesStore
|
|
|
|
|
|
|
|
// for ens flows
|
|
|
|
required property string myPublicKey
|
|
|
|
required property string ensRegisteredAddress
|
|
|
|
// TODO: This should probably be a property and not a function. Needs changes on backend side
|
|
|
|
property var getStatusTokenKey: function() {}
|
|
|
|
|
|
|
|
// for sticker flows
|
|
|
|
required property string stickersMarketAddress
|
|
|
|
required property string stickersNetworkId
|
|
|
|
|
2024-11-05 15:59:45 +00:00
|
|
|
// Feature flag for single network send until its feature complete
|
|
|
|
required property bool simpleSendEnabled
|
|
|
|
|
2024-11-05 18:51:17 +00:00
|
|
|
function openSend(params = {}) {
|
2024-11-05 15:59:45 +00:00
|
|
|
// TODO remove once simple send is feature complete
|
|
|
|
let sendModalCmp = root.simpleSendEnabled ? simpleSendModalComponent: sendModalComponent
|
|
|
|
let sendModalInst = sendModalCmp.createObject(popupParent, params)
|
|
|
|
sendModalInst.open()
|
2024-11-05 18:51:17 +00:00
|
|
|
}
|
|
|
|
|
2024-12-02 11:02:05 +00:00
|
|
|
function connectUsername(ensName) {
|
2024-11-05 18:51:17 +00:00
|
|
|
let params = {
|
|
|
|
preSelectedSendType: Constants.SendType.ENSSetPubKey,
|
|
|
|
preSelectedHoldingID: Constants.ethToken ,
|
|
|
|
preSelectedHoldingType: Constants.TokenType.Native,
|
|
|
|
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0),
|
|
|
|
preSelectedRecipient: root.ensRegisteredAddress,
|
|
|
|
interactive: false,
|
|
|
|
publicKey: root.myPublicKey,
|
|
|
|
ensName: ensName
|
|
|
|
}
|
|
|
|
openSend(params)
|
|
|
|
}
|
|
|
|
|
2024-12-02 11:02:05 +00:00
|
|
|
function registerUsername(ensName) {
|
2024-11-05 18:51:17 +00:00
|
|
|
let params = {
|
|
|
|
preSelectedSendType: Constants.SendType.ENSRegister,
|
|
|
|
preSelectedHoldingID: root.getStatusTokenKey(),
|
|
|
|
preSelectedHoldingType: Constants.TokenType.ERC20,
|
|
|
|
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(10),
|
|
|
|
preSelectedRecipient: root.ensRegisteredAddress,
|
|
|
|
interactive: false,
|
|
|
|
publicKey: root.myPublicKey,
|
|
|
|
ensName: ensName
|
|
|
|
}
|
|
|
|
openSend(params)
|
|
|
|
}
|
|
|
|
|
2024-12-02 11:02:05 +00:00
|
|
|
function releaseUsername(ensName, senderAddress, chainId) {
|
2024-11-05 18:51:17 +00:00
|
|
|
let params = {
|
|
|
|
preSelectedSendType: Constants.SendType.ENSRelease,
|
|
|
|
preSelectedAccountAddress: senderAddress,
|
|
|
|
preSelectedHoldingID: Constants.ethToken ,
|
|
|
|
preSelectedHoldingType: Constants.TokenType.Native,
|
|
|
|
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(0),
|
|
|
|
preSelectedChainId: chainId,
|
|
|
|
preSelectedRecipient: root.ensRegisteredAddress,
|
|
|
|
interactive: false,
|
|
|
|
publicKey: root.myPublicKey,
|
|
|
|
ensName: ensName
|
|
|
|
}
|
|
|
|
openSend(params)
|
|
|
|
}
|
|
|
|
|
2024-12-02 11:02:05 +00:00
|
|
|
function buyStickerPack(packId, price) {
|
2024-11-05 18:51:17 +00:00
|
|
|
let params = {
|
|
|
|
preSelectedSendType: Constants.SendType.StickersBuy,
|
|
|
|
preSelectedHoldingID: root.getStatusTokenKey(),
|
|
|
|
preSelectedHoldingType: Constants.TokenType.ERC20,
|
|
|
|
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(price),
|
|
|
|
preSelectedChainId: root.stickersNetworkId,
|
|
|
|
preSelectedRecipient: root.stickersMarketAddress,
|
|
|
|
interactive: false,
|
|
|
|
stickersPackId: packId
|
|
|
|
}
|
|
|
|
openSend(params)
|
|
|
|
}
|
|
|
|
|
2024-12-02 11:02:05 +00:00
|
|
|
function transferOwnership(tokenId, senderAddress) {
|
2024-11-05 18:51:17 +00:00
|
|
|
let params = {
|
|
|
|
preSelectedSendType: Constants.SendType.ERC721Transfer,
|
|
|
|
preSelectedAccountAddress: senderAddress,
|
|
|
|
preSelectedHoldingID: tokenId,
|
|
|
|
preSelectedHoldingType: Constants.TokenType.ERC721,
|
|
|
|
}
|
|
|
|
openSend(params)
|
|
|
|
}
|
|
|
|
|
2024-12-02 11:02:05 +00:00
|
|
|
function sendToRecipient(recipientAddress) {
|
2024-11-05 18:51:17 +00:00
|
|
|
let params = {
|
|
|
|
preSelectedRecipient: recipientAddress
|
|
|
|
}
|
|
|
|
openSend(params)
|
|
|
|
}
|
|
|
|
|
2024-12-02 11:02:05 +00:00
|
|
|
function bridgeToken(tokenId, tokenType) {
|
2024-11-05 18:51:17 +00:00
|
|
|
let params = {
|
|
|
|
preSelectedSendType: Constants.SendType.Bridge,
|
|
|
|
preSelectedHoldingID: tokenId ,
|
|
|
|
preSelectedHoldingType: tokenType,
|
|
|
|
onlyAssets: true
|
|
|
|
}
|
|
|
|
openSend(params)
|
|
|
|
}
|
|
|
|
|
2024-12-02 11:02:05 +00:00
|
|
|
function sendToken(senderAddress, tokenId, tokenType) {
|
2024-11-05 18:51:17 +00:00
|
|
|
let sendType = Constants.SendType.Transfer
|
|
|
|
if (tokenType === Constants.TokenType.ERC721) {
|
|
|
|
sendType = Constants.SendType.ERC721Transfer
|
|
|
|
} else if(tokenType === Constants.TokenType.ERC1155) {
|
|
|
|
sendType = Constants.SendType.ERC1155Transfer
|
|
|
|
}
|
|
|
|
let params = {
|
|
|
|
preSelectedSendType: sendType,
|
|
|
|
preSelectedAccountAddress: senderAddress,
|
|
|
|
preSelectedHoldingID: tokenId ,
|
|
|
|
preSelectedHoldingType: tokenType,
|
|
|
|
}
|
|
|
|
openSend(params)
|
|
|
|
}
|
|
|
|
|
|
|
|
readonly property Component sendModalComponent: Component {
|
|
|
|
SendModal {
|
|
|
|
loginType: root.loginType
|
|
|
|
|
|
|
|
store: root.transactionStore
|
|
|
|
collectiblesStore: root.walletCollectiblesStore
|
|
|
|
|
|
|
|
showCustomRoutingMode: !production
|
|
|
|
|
|
|
|
onClosed: destroy()
|
|
|
|
}
|
|
|
|
}
|
2024-12-02 11:02:05 +00:00
|
|
|
|
2024-11-05 15:59:45 +00:00
|
|
|
readonly property Component simpleSendModalComponent: Component {
|
|
|
|
SimpleSendModal {
|
|
|
|
onClosed: destroy()
|
|
|
|
}
|
|
|
|
}
|
2024-11-05 18:51:17 +00:00
|
|
|
}
|