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