Skip to content

Commit 7a60cb2

Browse files
committed
chore: community related tokens should always have 18 decimals
18 decimals for community related tokens is determined by the community creation contract. UI input field for entering custom decimal is removed. Colses #14073 and #19185
1 parent 0786ddf commit 7a60cb2

File tree

9 files changed

+19
-42
lines changed

9 files changed

+19
-42
lines changed

src/app/modules/main/communities/tokens/io_interface.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ method computeDeployCollectiblesFee*(self: AccessInterface, uuid: string, commu
2424
raise newException(ValueError, "No implementation available")
2525

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

src/app/modules/main/communities/tokens/module.nim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import ./io_interface, ./view , ./controller
2020

2121
export io_interface
2222

23+
const DEFAULT_COMMUNITY_TOKENS_DECIMALS = 18 # determined by the community creation contract
24+
2325
type
2426
ContractAction {.pure.} = enum
2527
Unknown = 0
@@ -348,6 +350,7 @@ method computeDeployCollectiblesFee*(self: Module, uuid: string, communityId: st
348350
self.tempDeploymentParams.symbol = symbol
349351
self.tempDeploymentParams.supply = supply.parse(Uint256)
350352
self.tempDeploymentParams.infiniteSupply = infiniteSupply
353+
self.tempDeploymentParams.decimals = 0 # collectibles have no decimals
351354
self.tempDeploymentParams.transferable = transferable
352355
self.tempDeploymentParams.remoteSelfDestruct = selfDestruct
353356
self.tempDeploymentParams.tokenUri = utl.changeCommunityKeyCompression(communityId) & "/"
@@ -391,7 +394,7 @@ method computeDeployTokenOwnerFee*(self: Module, uuid: string, communityId: stri
391394
self.controller.computeDeployOwnerContractsFee(uuid, chainId, fromAddress, communityId, self.tempOwnerDeploymentParams, self.tempMasterDeploymentParams)
392395

393396
method computeDeployAssetsFee*(self: Module, uuid: string, communityId: string, fromAddress: string, name: string, symbol: string, description: string,
394-
supply: string, infiniteSupply: bool, decimals: int, chainId: int, imageCropInfoJson: string) =
397+
supply: string, infiniteSupply: bool, chainId: int, imageCropInfoJson: string) =
395398
# TODO: move this check to service and send route ready signal to update the UI and notifiy the user
396399
let (ownerTokenAddress, masterTokenAddress, isDeployed) = self.getOwnerAndMasterTokensAddresses(communityId, chainId)
397400
if not isDeployed:
@@ -405,7 +408,7 @@ method computeDeployAssetsFee*(self: Module, uuid: string, communityId: string,
405408
self.tempDeploymentParams.symbol = symbol
406409
self.tempDeploymentParams.supply = supply.parse(Uint256)
407410
self.tempDeploymentParams.infiniteSupply = infiniteSupply
408-
self.tempDeploymentParams.decimals = decimals
411+
self.tempDeploymentParams.decimals = DEFAULT_COMMUNITY_TOKENS_DECIMALS
409412
self.tempDeploymentParams.tokenUri = utl.changeCommunityKeyCompression(communityId) & "/"
410413
self.tempDeploymentParams.ownerTokenAddress = ownerTokenAddress
411414
self.tempDeploymentParams.masterTokenAddress = masterTokenAddress

src/app/modules/main/communities/tokens/view.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ QtObject:
2828
supply, infiniteSupply, transferable, selfDestruct, chainId, imageCropInfoJson)
2929

3030
proc computeDeployAssetsFee*(self: View, uuid: string, communityId: string, fromAddress: string, name: string,
31-
symbol: string, description: string, supply: string, infiniteSupply: bool, decimals: int, chainId: int,
31+
symbol: string, description: string, supply: string, infiniteSupply: bool, chainId: int,
3232
imageCropInfoJson: string) {.slot.} =
3333
self.communityTokensModule.computeDeployAssetsFee(uuid, communityId, fromAddress, name, symbol, description, supply,
34-
infiniteSupply, decimals, chainId, imageCropInfoJson)
34+
infiniteSupply, chainId, imageCropInfoJson)
3535

3636
proc computeDeployTokenOwnerFee*(self:View, uuid: string, communityId: string, fromAddress: string, ownerName: string,
3737
ownerSymbol: string, ownerDescription: string, masterName: string, masterSymbol: string, masterDescription: string,

ui/app/AppLayouts/Communities/helpers/TransactionFeesBroker.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ QtObject {
248248
args.token.description,
249249
args.token.supply,
250250
args.token.infiniteSupply,
251-
args.token.decimals,
252251
args.token.artworkSource,
253252
args.token.artworkCropRect)
254253
}

ui/app/AppLayouts/Communities/panels/MintTokensSettingsPanel.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ StackView {
7575
property var tokensModel
7676
property var membersModel
7777
property var accounts // Expected roles: address, name, color, emoji, walletType
78-
required property var referenceAssetsBySymbolModel
78+
required property var referenceTokenGroupsModel
7979

8080
signal mintCollectible(var collectibleItem)
8181
signal mintAsset(var assetItem)
@@ -430,7 +430,7 @@ StackView {
430430

431431
accounts: root.accounts
432432
tokensModel: root.tokensModel
433-
referenceAssetsBySymbolModel: root.referenceAssetsBySymbolModel
433+
referenceTokenGroupsModel: root.referenceTokenGroupsModel
434434

435435
referenceName: newTokenPage.referenceName
436436
referenceSymbol: newTokenPage.referenceSymbol

ui/app/AppLayouts/Communities/views/CommunitySettingsView.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ StatusSectionLayout {
446446
membersModel: membersModelAdaptor.joinedMembers
447447
flatNetworks: root.activeNetworks
448448
accounts: root.walletAccountsModel
449-
referenceAssetsBySymbolModel: root.tokensStore.assetsBySymbolModel
449+
referenceTokenGroupsModel: root.tokensStore.tokenGroupsModel
450450

451451
onStopUpdatingFees: {
452452
communityTokensStore.stopUpdatesForSuggestedRoute()

ui/app/AppLayouts/Communities/views/EditCommunityTokenView.qml

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ StatusScrollView {
3333
}
3434

3535
// Used for reference validation
36-
required property var referenceAssetsBySymbolModel
36+
required property var referenceTokenGroupsModel
3737

3838
// Used for reference validation when editing a failed deployment
3939
property string referenceName: ""
@@ -66,7 +66,6 @@ StatusScrollView {
6666
&& descriptionInput.valid
6767
&& symbolInput.valid
6868
&& (unlimitedSupplyChecker.checked || (!unlimitedSupplyChecker.checked && parseInt(supplyInput.text) > 0))
69-
&& (!root.isAssetView || (root.isAssetView && assetDecimalsInput.valid))
7069
readonly property bool isFullyFilled: d.formFilled
7170
&& deployFeeSubscriber.feeText !== ""
7271
&& deployFeeSubscriber.feeErrorText === ""
@@ -75,7 +74,7 @@ StatusScrollView {
7574

7675
readonly property bool containsAssetReferenceName: root.isAssetView ? checkNameProxy.count > 0 : false
7776
readonly property SortFilterProxyModel checkNameProxy : SortFilterProxyModel {
78-
sourceModel: root.referenceAssetsBySymbolModel
77+
sourceModel: root.referenceTokenGroupsModel
7978
filters: ValueFilter {
8079
roleName: "name"
8180
value: nameInput.text
@@ -84,7 +83,7 @@ StatusScrollView {
8483

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

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

346345
onTextChanged: {
347346
const supplyNumber = parseInt(text)
@@ -376,30 +375,6 @@ StatusScrollView {
376375
onCheckedChanged: root.token.remotelyDestruct = checked
377376
}
378377

379-
CustomStatusInput {
380-
id: assetDecimalsInput
381-
382-
Layout.fillWidth: true
383-
Layout.maximumWidth: root.preferredContentWidth
384-
Layout.rightMargin: root.internalRightPadding
385-
386-
visible: root.isAssetView
387-
label: qsTr("Decimals (DP)")
388-
charLimit: 2
389-
charLimitLabel: qsTr("Max 10")
390-
placeholderText: "2"
391-
text: root.token.decimals
392-
validationMode: StatusInput.ValidationMode.Always
393-
minLengthValidator.errorMessage: qsTr("Please enter how many decimals your token should have")
394-
regexValidator.errorMessage: d.hasEmoji(text) ? qsTr("Your decimal amount is too cool (use 0-9 only)") :
395-
qsTr("Your decimal amount contains invalid characters (use 0-9 only)")
396-
regexValidator.regularExpression: Constants.regularExpressions.numerical
397-
extraValidator.validate: function (value) { return parseInt(value) > 0 && parseInt(value) <= 10 }
398-
extraValidator.errorMessage: qsTr("Enter a number between 1 and 10")
399-
input.tabNavItem: previewButton
400-
onTextChanged: root.token.decimals = parseInt(text)
401-
}
402-
403378
CustomSwitchRowComponent {
404379
id: showFees
405380
enabled: d.formFilled

ui/imports/shared/stores/CommunityTokensStore.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ QtObject {
4343
}
4444

4545
function computeDeployAssetsFee(subscriptionId, communityId, aKey, aChainId, aAccountAddress, aName, aSymbol,
46-
aDescription, aSupply, aInfiniteSupply, aDecimals, aArtworkSource, aArtworkCropRect) {
46+
aDescription, aSupply, aInfiniteSupply, aArtworkSource, aArtworkCropRect) {
4747
if (aKey !== "")
4848
deleteToken(communityId, aKey)
4949

5050
const jsonArtworkFile = Utils.getImageAndCropInfoJson(aArtworkSource, aArtworkCropRect)
5151
communityTokensModuleInst.computeDeployAssetsFee(subscriptionId, communityId, aAccountAddress, aName,
5252
aSymbol, aDescription, aSupply,
53-
aInfiniteSupply, aDecimals, aChainId, jsonArtworkFile)
53+
aInfiniteSupply, aChainId, jsonArtworkFile)
5454
}
5555

5656

0 commit comments

Comments
 (0)