isCompressedPubKey moved from Utils to UtilsStore

This commit is contained in:
Michał Cieślak 2024-10-21 15:40:14 +02:00 committed by Michał
parent 356275f2b3
commit a76ae0ade6
4 changed files with 10 additions and 16 deletions

View File

@ -99,13 +99,10 @@ QtObject {
return root.communitiesModuleInst.getCommunityPublicKeyFromPrivateKey(privateKey); return root.communitiesModuleInst.getCommunityPublicKeyFromPrivateKey(privateKey);
} }
function requestCommunityInfo(communityKey, shardCluster, shardIndex, importing = false) { function requestCommunityInfo(communityPubKey, shardCluster, shardIndex, importing = false) {
const publicKey = Utils.isCompressedPubKey(communityKey)
? Utils.changeCommunityKeyCompression(communityKey)
: communityKey
if (importing) if (importing)
root.mainModuleInst.setCommunityIdToSpectate(publicKey) root.mainModuleInst.setCommunityIdToSpectate(communityPubKey)
root.communitiesModuleInst.requestCommunityInfo(publicKey, shardCluster, shardIndex, importing) root.communitiesModuleInst.requestCommunityInfo(communityPubKey, shardCluster, shardIndex, importing)
} }
property var communitiesList: communitiesModuleInst.model property var communitiesList: communitiesModuleInst.model
@ -119,12 +116,9 @@ QtObject {
root.communitiesModuleInst.prepareTokenModelForCommunity(publicKey); root.communitiesModuleInst.prepareTokenModelForCommunity(publicKey);
} }
function getCommunityDetails(communityId) { function getCommunityDetails(communityPubKey) {
const publicKey = Utils.isCompressedPubKey(communityId)
? Utils.changeCommunityKeyCompression(communityId)
: communityId
try { try {
const communityJson = root.communitiesList.getSectionByIdJson(publicKey) const communityJson = root.communitiesList.getSectionByIdJson(communityPubKey)
if (!!communityJson) if (!!communityJson)
return JSON.parse(communityJson) return JSON.parse(communityJson)
} catch (e) { } catch (e) {

View File

@ -58,7 +58,7 @@ StatusDialog {
} }
if (!root.utilsStore.isCommunityPublicKey(inputKey)) if (!root.utilsStore.isCommunityPublicKey(inputKey))
return "" return ""
if (!Utils.isCompressedPubKey(inputKey)) if (!root.utilsStore.isCompressedPubKey(inputKey))
return inputKey return inputKey
return Utils.changeCommunityKeyCompression(inputKey) return Utils.changeCommunityKeyCompression(inputKey)
} }

View File

@ -20,4 +20,8 @@ QtObject {
return (Utils.startsWith0x(value) && Utils.isHex(value) && value.length === Constants.communityIdLength) return (Utils.startsWith0x(value) && Utils.isHex(value) && value.length === Constants.communityIdLength)
|| d.globalUtilsInst.isCompressedPubKey(value) || d.globalUtilsInst.isCompressedPubKey(value)
} }
function isCompressedPubKey(pubKey) {
return d.globalUtilsInst.isCompressedPubKey(pubKey)
}
} }

View File

@ -725,10 +725,6 @@ QtObject {
return (startsWith0x(value) && isHex(value) && value.length === 132) || globalUtilsInst.isCompressedPubKey(value) return (startsWith0x(value) && isHex(value) && value.length === 132) || globalUtilsInst.isCompressedPubKey(value)
} }
function isCompressedPubKey(pubKey) {
return globalUtilsInst.isCompressedPubKey(pubKey)
}
function isAlias(name) { function isAlias(name) {
return globalUtilsInst.isAlias(name) return globalUtilsInst.isAlias(name)
} }