Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/modules/main/communities/tokens/io_interface.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ method computeDeployCollectiblesFee*(self: AccessInterface, uuid: string, commu
raise newException(ValueError, "No implementation available")

method computeDeployAssetsFee*(self: AccessInterface, uuid: string, communityId: string, address: string, name: string,
symbol: string, description: string, supply: string, infiniteSupply: bool, decimals: int, chainId: int,
symbol: string, description: string, supply: string, infiniteSupply: bool, chainId: int,
imageCropInfoJson: string) {.base.} =
raise newException(ValueError, "No implementation available")

Expand Down
7 changes: 5 additions & 2 deletions src/app/modules/main/communities/tokens/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import ./io_interface, ./view , ./controller

export io_interface

const DEFAULT_COMMUNITY_TOKENS_DECIMALS = 18 # determined by the community creation contract

type
ContractAction {.pure.} = enum
Unknown = 0
Expand Down Expand Up @@ -348,6 +350,7 @@ method computeDeployCollectiblesFee*(self: Module, uuid: string, communityId: st
self.tempDeploymentParams.symbol = symbol
self.tempDeploymentParams.supply = supply.parse(Uint256)
self.tempDeploymentParams.infiniteSupply = infiniteSupply
self.tempDeploymentParams.decimals = 0 # collectibles have no decimals
self.tempDeploymentParams.transferable = transferable
self.tempDeploymentParams.remoteSelfDestruct = selfDestruct
self.tempDeploymentParams.tokenUri = utl.changeCommunityKeyCompression(communityId) & "/"
Expand Down Expand Up @@ -391,7 +394,7 @@ method computeDeployTokenOwnerFee*(self: Module, uuid: string, communityId: stri
self.controller.computeDeployOwnerContractsFee(uuid, chainId, fromAddress, communityId, self.tempOwnerDeploymentParams, self.tempMasterDeploymentParams)

method computeDeployAssetsFee*(self: Module, uuid: string, communityId: string, fromAddress: string, name: string, symbol: string, description: string,
supply: string, infiniteSupply: bool, decimals: int, chainId: int, imageCropInfoJson: string) =
supply: string, infiniteSupply: bool, chainId: int, imageCropInfoJson: string) =
# TODO: move this check to service and send route ready signal to update the UI and notifiy the user
let (ownerTokenAddress, masterTokenAddress, isDeployed) = self.getOwnerAndMasterTokensAddresses(communityId, chainId)
if not isDeployed:
Expand All @@ -405,7 +408,7 @@ method computeDeployAssetsFee*(self: Module, uuid: string, communityId: string,
self.tempDeploymentParams.symbol = symbol
self.tempDeploymentParams.supply = supply.parse(Uint256)
self.tempDeploymentParams.infiniteSupply = infiniteSupply
self.tempDeploymentParams.decimals = decimals
self.tempDeploymentParams.decimals = DEFAULT_COMMUNITY_TOKENS_DECIMALS
self.tempDeploymentParams.tokenUri = utl.changeCommunityKeyCompression(communityId) & "/"
self.tempDeploymentParams.ownerTokenAddress = ownerTokenAddress
self.tempDeploymentParams.masterTokenAddress = masterTokenAddress
Expand Down
4 changes: 2 additions & 2 deletions src/app/modules/main/communities/tokens/view.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ QtObject:
supply, infiniteSupply, transferable, selfDestruct, chainId, imageCropInfoJson)

proc computeDeployAssetsFee*(self: View, uuid: string, communityId: string, fromAddress: string, name: string,
symbol: string, description: string, supply: string, infiniteSupply: bool, decimals: int, chainId: int,
symbol: string, description: string, supply: string, infiniteSupply: bool, chainId: int,
imageCropInfoJson: string) {.slot.} =
self.communityTokensModule.computeDeployAssetsFee(uuid, communityId, fromAddress, name, symbol, description, supply,
infiniteSupply, decimals, chainId, imageCropInfoJson)
infiniteSupply, chainId, imageCropInfoJson)

proc computeDeployTokenOwnerFee*(self:View, uuid: string, communityId: string, fromAddress: string, ownerName: string,
ownerSymbol: string, ownerDescription: string, masterName: string, masterSymbol: string, masterDescription: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ QtObject {
args.token.description,
args.token.supply,
args.token.infiniteSupply,
args.token.decimals,
args.token.artworkSource,
args.token.artworkCropRect)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ StackView {
property var tokensModel
property var membersModel
property var accounts // Expected roles: address, name, color, emoji, walletType
required property var referenceAssetsBySymbolModel
required property var referenceTokenGroupsModel

signal mintCollectible(var collectibleItem)
signal mintAsset(var assetItem)
Expand Down Expand Up @@ -430,7 +430,7 @@ StackView {

accounts: root.accounts
tokensModel: root.tokensModel
referenceAssetsBySymbolModel: root.referenceAssetsBySymbolModel
referenceTokenGroupsModel: root.referenceTokenGroupsModel

referenceName: newTokenPage.referenceName
referenceSymbol: newTokenPage.referenceSymbol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ StatusSectionLayout {
membersModel: membersModelAdaptor.joinedMembers
flatNetworks: root.activeNetworks
accounts: root.walletAccountsModel
referenceAssetsBySymbolModel: root.tokensStore.assetsBySymbolModel
referenceTokenGroupsModel: root.tokensStore.tokenGroupsModel

onStopUpdatingFees: {
communityTokensStore.stopUpdatesForSuggestedRoute()
Expand Down
35 changes: 5 additions & 30 deletions ui/app/AppLayouts/Communities/views/EditCommunityTokenView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ StatusScrollView {
}

// Used for reference validation
required property var referenceAssetsBySymbolModel
required property var referenceTokenGroupsModel

// Used for reference validation when editing a failed deployment
property string referenceName: ""
Expand Down Expand Up @@ -66,7 +66,6 @@ StatusScrollView {
&& descriptionInput.valid
&& symbolInput.valid
&& (unlimitedSupplyChecker.checked || (!unlimitedSupplyChecker.checked && parseInt(supplyInput.text) > 0))
&& (!root.isAssetView || (root.isAssetView && assetDecimalsInput.valid))
readonly property bool isFullyFilled: d.formFilled
&& deployFeeSubscriber.feeText !== ""
&& deployFeeSubscriber.feeErrorText === ""
Expand All @@ -75,7 +74,7 @@ StatusScrollView {

readonly property bool containsAssetReferenceName: root.isAssetView ? checkNameProxy.count > 0 : false
readonly property SortFilterProxyModel checkNameProxy : SortFilterProxyModel {
sourceModel: root.referenceAssetsBySymbolModel
sourceModel: root.referenceTokenGroupsModel
filters: ValueFilter {
roleName: "name"
value: nameInput.text
Expand All @@ -84,7 +83,7 @@ StatusScrollView {

readonly property bool containsAssetReferenceSymbol: root.isAssetView ? checkSymbolProxy.count > 0 : false
readonly property SortFilterProxyModel checkSymbolProxy: SortFilterProxyModel {
sourceModel: root.referenceAssetsBySymbolModel
sourceModel: root.referenceTokenGroupsModel
filters: ValueFilter {
roleName: "symbol"
value: symbolInput.text
Expand Down Expand Up @@ -227,7 +226,7 @@ StatusScrollView {
return (!SQUtils.ModelUtils.contains(root.tokensModel, "symbol", symbolInput.text) && !d.containsAssetReferenceSymbol)
}
extraValidator.errorMessage: d.containsAssetReferenceSymbol ? qsTr("Symbol already exists") : qsTr("You have used this token symbol before")
input.tabNavItem: supplyInput.visible ? supplyInput : assetDecimalsInput
input.tabNavItem: supplyInput.visible ? supplyInput : previewButton

onTextChanged: {
const cursorPos = input.edit.cursorPosition
Expand Down Expand Up @@ -341,7 +340,7 @@ StatusScrollView {
regexValidator.regularExpression: Constants.regularExpressions.numerical
extraValidator.validate: function (value) { return parseInt(value) > 0 && parseInt(value) <= 999999999 }
extraValidator.errorMessage: qsTr("Enter a number between 1 and 999,999,999")
input.tabNavItem: assetDecimalsInput.visible ? assetDecimalsInput : previewButton
input.tabNavItem: previewButton

onTextChanged: {
const supplyNumber = parseInt(text)
Expand Down Expand Up @@ -376,30 +375,6 @@ StatusScrollView {
onCheckedChanged: root.token.remotelyDestruct = checked
}

CustomStatusInput {
id: assetDecimalsInput

Layout.fillWidth: true
Layout.maximumWidth: root.preferredContentWidth
Layout.rightMargin: root.internalRightPadding

visible: root.isAssetView
label: qsTr("Decimals (DP)")
charLimit: 2
charLimitLabel: qsTr("Max 10")
placeholderText: "2"
text: root.token.decimals
validationMode: StatusInput.ValidationMode.Always
minLengthValidator.errorMessage: qsTr("Please enter how many decimals your token should have")
regexValidator.errorMessage: d.hasEmoji(text) ? qsTr("Your decimal amount is too cool (use 0-9 only)") :
qsTr("Your decimal amount contains invalid characters (use 0-9 only)")
regexValidator.regularExpression: Constants.regularExpressions.numerical
extraValidator.validate: function (value) { return parseInt(value) > 0 && parseInt(value) <= 10 }
extraValidator.errorMessage: qsTr("Enter a number between 1 and 10")
input.tabNavItem: previewButton
onTextChanged: root.token.decimals = parseInt(text)
}

CustomSwitchRowComponent {
id: showFees
enabled: d.formFilled
Expand Down
4 changes: 2 additions & 2 deletions ui/imports/shared/stores/CommunityTokensStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ QtObject {
}

function computeDeployAssetsFee(subscriptionId, communityId, aKey, aChainId, aAccountAddress, aName, aSymbol,
aDescription, aSupply, aInfiniteSupply, aDecimals, aArtworkSource, aArtworkCropRect) {
aDescription, aSupply, aInfiniteSupply, aArtworkSource, aArtworkCropRect) {
if (aKey !== "")
deleteToken(communityId, aKey)

const jsonArtworkFile = Utils.getImageAndCropInfoJson(aArtworkSource, aArtworkCropRect)
communityTokensModuleInst.computeDeployAssetsFee(subscriptionId, communityId, aAccountAddress, aName,
aSymbol, aDescription, aSupply,
aInfiniteSupply, aDecimals, aChainId, jsonArtworkFile)
aInfiniteSupply, aChainId, jsonArtworkFile)
}


Expand Down