mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-24 21:39:24 +00:00
feat(@desktop/wallet): Handle collectible minting (#11796)
This commit is contained in:
parent
66e9631933
commit
b5a81badaa
@ -114,6 +114,9 @@ QtObject:
|
||||
isPending:{self.isPending}
|
||||
)"""
|
||||
|
||||
proc isInTransactionType(self: ActivityEntry): bool =
|
||||
return self.metadata.activityType == backend.ActivityType.Receive or self.metadata.activityType == backend.ActivityType.Mint
|
||||
|
||||
proc getMultiTransaction*(self: ActivityEntry): MultiTransactionDto =
|
||||
if not self.isMultiTransaction():
|
||||
raise newException(Defect, "ActivityEntry is not a MultiTransaction")
|
||||
@ -144,7 +147,7 @@ QtObject:
|
||||
read = getOutSymbol
|
||||
|
||||
proc getSymbol*(self: ActivityEntry): string {.slot.} =
|
||||
if self.metadata.activityType == backend.ActivityType.Receive:
|
||||
if self.isInTransactionType():
|
||||
return self.getInSymbol()
|
||||
return self.getOutSymbol()
|
||||
|
||||
@ -168,7 +171,7 @@ QtObject:
|
||||
error "getChainId: ActivityEntry is not a transaction"
|
||||
return 0
|
||||
|
||||
if self.metadata.activityType == backend.ActivityType.Receive:
|
||||
if self.isInTransactionType():
|
||||
return self.metadata.chainIdIn.get(ChainId(0)).int
|
||||
return self.metadata.chainIdOut.get(ChainId(0)).int
|
||||
|
||||
@ -236,7 +239,7 @@ QtObject:
|
||||
proc getTokenType*(self: ActivityEntry): string {.slot.} =
|
||||
if self.transaction != nil:
|
||||
return self.transaction[].typeValue
|
||||
if self.metadata.activityType == backend.ActivityType.Receive and self.metadata.tokenOut.isSome:
|
||||
if self.isInTransactionType() and self.metadata.tokenOut.isSome:
|
||||
return $self.metadata.tokenOut.unsafeGet().tokenType
|
||||
if self.metadata.tokenIn.isSome:
|
||||
return $self.metadata.tokenIn.unsafeGet().tokenType
|
||||
@ -267,7 +270,7 @@ QtObject:
|
||||
read = getTokenOutAddress
|
||||
|
||||
proc getTokenAddress*(self: ActivityEntry): string {.slot.} =
|
||||
if self.metadata.activityType == backend.ActivityType.Receive:
|
||||
if self.isInTransactionType():
|
||||
return self.getTokenInAddress()
|
||||
return self.getTokenOutAddress()
|
||||
|
||||
@ -296,7 +299,7 @@ QtObject:
|
||||
error "getTokenID: ActivityEntry is not a transaction"
|
||||
return ""
|
||||
|
||||
if self.metadata.activityType == backend.ActivityType.Receive:
|
||||
if self.isInTransactionType():
|
||||
return if self.metadata.tokenIn.isSome(): $self.metadata.tokenIn.unsafeGet().tokenId else: ""
|
||||
return if self.metadata.tokenOut.isSome(): $self.metadata.tokenOut.unsafeGet().tokenId else: ""
|
||||
|
||||
@ -336,7 +339,7 @@ QtObject:
|
||||
read = getInAmount
|
||||
|
||||
proc getAmount*(self: ActivityEntry): float {.slot.} =
|
||||
if self.metadata.activityType == backend.ActivityType.Receive:
|
||||
if self.isInTransactionType():
|
||||
return self.getInAmount()
|
||||
return self.getOutAmount()
|
||||
|
||||
|
@ -26,7 +26,7 @@ type
|
||||
|
||||
# see status-go/services/wallet/activity/filter.go Type
|
||||
ActivityType* {.pure.} = enum
|
||||
Send, Receive, Buy, Swap, Bridge, ContractDeployment
|
||||
Send, Receive, Buy, Swap, Bridge, ContractDeployment, Mint
|
||||
|
||||
# see status-go/services/wallet/activity/filter.go Status
|
||||
ActivityStatus* {.pure.} = enum
|
||||
|
@ -195,6 +195,12 @@ StatusListItem {
|
||||
case Constants.TransactionType.ContractDeployment:
|
||||
details += qsTr("Contract deployment details") + endl2
|
||||
break
|
||||
case Constants.TransactionType.Mint:
|
||||
if (isNFT)
|
||||
details += qsTr("Mint collectible details") + endl2
|
||||
else
|
||||
details += qsTr("Mint token details") + endl2
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
@ -207,6 +213,7 @@ StatusListItem {
|
||||
case Constants.TransactionType.Swap:
|
||||
case Constants.TransactionType.Bridge:
|
||||
case Constants.TransactionType.ContractDeployment:
|
||||
case Constants.TransactionType.Mint:
|
||||
details += getSubtitle(true) + endl2
|
||||
break
|
||||
default:
|
||||
@ -457,6 +464,10 @@ StatusListItem {
|
||||
const name = addressNameTo || addressNameFrom
|
||||
return !!modelData.contract ? qsTr("Contract %1 via %2 on %3").arg(Utils.compactAddress(modelData.contract, 4)).arg(name).arg(networkName)
|
||||
: qsTr("Via %1 on %2").arg(name).arg(networkName)
|
||||
case Constants.TransactionType.Mint:
|
||||
if (allAccounts)
|
||||
return qsTr("%1 via %2 in %4").arg(transactionValue).arg(networkName).arg(toAddress)
|
||||
return qsTr("%1 via %2").arg(transactionValue).arg(networkName).arg(networkName)
|
||||
default:
|
||||
if (allAccounts)
|
||||
return qsTr("%1 from %2 to %3 via %4").arg(transactionValue).arg(fromAddress).arg(toAddress).arg(networkName)
|
||||
@ -487,6 +498,7 @@ StatusListItem {
|
||||
return "receive"
|
||||
case Constants.TransactionType.Buy:
|
||||
case Constants.TransactionType.Sell:
|
||||
case Constants.TransactionType.Mint:
|
||||
return "token"
|
||||
case Constants.TransactionType.Destroy:
|
||||
return "destroy"
|
||||
@ -545,6 +557,10 @@ StatusListItem {
|
||||
return failed ? qsTr("Bridge failed") : (isPending ? qsTr("Bridging") : qsTr("Bridged"))
|
||||
case Constants.TransactionType.ContractDeployment:
|
||||
return failed ? qsTr("Contract deployment failed") : (isPending ? qsTr("Deploying contract") : qsTr("Contract deployed"))
|
||||
case Constants.TransactionType.Mint:
|
||||
if (isNFT)
|
||||
return failed ? qsTr("Collectible minting failed") : (isPending ? qsTr("Minting collectible") : qsTr("Collectible minted"))
|
||||
return failed ? qsTr("Token minting failed") : (isPending ? qsTr("Minting token") : qsTr("Token minted"))
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
@ -1009,6 +1009,7 @@ QtObject {
|
||||
Swap,
|
||||
Bridge,
|
||||
ContractDeployment,
|
||||
Mint,
|
||||
Sell,
|
||||
Destroy // TODO update value when added to backend
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user