From 7544bd6fb5f6785b52bb33d41c52cff47df9695e Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Wed, 10 Aug 2022 15:18:20 -0400 Subject: [PATCH] fix: change gateway and remove old code to decode the hash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: - https://github.com/status-im/status-desktop/issues/6964 Depends on: - https://github.com/status-im/status-go/pull/2795 - https://github.com/status-im/status-jenkins-lib/pull/44 Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile.combined | 2 +- ci/Jenkinsfile.linux | 2 +- ci/Jenkinsfile.linux-cpp | 2 +- ci/Jenkinsfile.mac-cpp.todo | 2 +- ci/Jenkinsfile.macos | 2 +- ci/Jenkinsfile.uitests | 2 +- ci/Jenkinsfile.windows | 2 +- ci/Jenkinsfile.windows-cpp.todo | 2 +- .../main/activity_center/controller.nim | 3 -- .../modules/main/activity_center/module.nim | 2 +- .../chat_section/chat_content/controller.nim | 3 -- .../chat_content/messages/controller.nim | 3 -- .../chat_content/messages/module.nim | 4 +- .../main/chat_section/chat_content/module.nim | 2 +- src/app/modules/main/stickers/controller.nim | 3 -- .../modules/main/stickers/io_interface.nim | 3 -- src/app/modules/main/stickers/module.nim | 3 -- src/app/modules/main/stickers/view.nim | 4 +- src/app_service/service/eth/utils.nim | 52 ------------------- .../service/message/dto/message.nim | 2 + ui/app/AppLayouts/Chat/stores/RootStore.qml | 5 +- .../AppLayouts/Chat/views/ChatColumnView.qml | 6 ++- .../AppLayouts/Chat/views/ChatContentView.qml | 3 +- .../AppLayouts/Chat/views/CreateChatView.qml | 1 + ui/imports/shared/status/StatusChatInput.qml | 4 +- .../shared/status/StatusStickerList.qml | 4 +- .../shared/status/StatusStickersPopup.qml | 4 +- 27 files changed, 32 insertions(+), 95 deletions(-) diff --git a/ci/Jenkinsfile.combined b/ci/Jenkinsfile.combined index e012b06852..4fc86d451c 100644 --- a/ci/Jenkinsfile.combined +++ b/ci/Jenkinsfile.combined @@ -1,4 +1,4 @@ -library 'status-jenkins-lib@v1.3.4' +library 'status-jenkins-lib@v1.5.1' pipeline { agent { label 'linux' } diff --git a/ci/Jenkinsfile.linux b/ci/Jenkinsfile.linux index 0d6c64b468..de1ab73cca 100644 --- a/ci/Jenkinsfile.linux +++ b/ci/Jenkinsfile.linux @@ -1,4 +1,4 @@ -library 'status-jenkins-lib@v1.3.4' +library 'status-jenkins-lib@v1.5.1' pipeline { agent { diff --git a/ci/Jenkinsfile.linux-cpp b/ci/Jenkinsfile.linux-cpp index 916057ddf2..e6c30af945 100644 --- a/ci/Jenkinsfile.linux-cpp +++ b/ci/Jenkinsfile.linux-cpp @@ -1,4 +1,4 @@ -library 'status-jenkins-lib@v1.3.4' +library 'status-jenkins-lib@v1.5.1' pipeline { agent { diff --git a/ci/Jenkinsfile.mac-cpp.todo b/ci/Jenkinsfile.mac-cpp.todo index b2e4124266..a26df44ef2 100644 --- a/ci/Jenkinsfile.mac-cpp.todo +++ b/ci/Jenkinsfile.mac-cpp.todo @@ -1,4 +1,4 @@ -library 'status-jenkins-lib@v1.3.4' +library 'status-jenkins-lib@v1.5.1' pipeline { agent { diff --git a/ci/Jenkinsfile.macos b/ci/Jenkinsfile.macos index 2c5966abbd..e116fda51e 100644 --- a/ci/Jenkinsfile.macos +++ b/ci/Jenkinsfile.macos @@ -1,4 +1,4 @@ -library 'status-jenkins-lib@v1.3.4' +library 'status-jenkins-lib@v1.5.1' pipeline { agent { diff --git a/ci/Jenkinsfile.uitests b/ci/Jenkinsfile.uitests index 314261923c..d7ec4619a6 100644 --- a/ci/Jenkinsfile.uitests +++ b/ci/Jenkinsfile.uitests @@ -1,4 +1,4 @@ -library 'status-jenkins-lib@v1.3.4' +library 'status-jenkins-lib@v1.5.1' pipeline { agent { label 'linux' } diff --git a/ci/Jenkinsfile.windows b/ci/Jenkinsfile.windows index 8c58e5a0de..16073be510 100644 --- a/ci/Jenkinsfile.windows +++ b/ci/Jenkinsfile.windows @@ -1,4 +1,4 @@ -library 'status-jenkins-lib@v1.3.4' +library 'status-jenkins-lib@v1.5.1' pipeline { agent { label 'windows' } diff --git a/ci/Jenkinsfile.windows-cpp.todo b/ci/Jenkinsfile.windows-cpp.todo index 3ab5959579..826defe32c 100644 --- a/ci/Jenkinsfile.windows-cpp.todo +++ b/ci/Jenkinsfile.windows-cpp.todo @@ -1,4 +1,4 @@ -library 'status-jenkins-lib@v1.3.4' +library 'status-jenkins-lib@v1.5.1' pipeline { agent { diff --git a/src/app/modules/main/activity_center/controller.nim b/src/app/modules/main/activity_center/controller.nim index 4d3e635c7c..0708f738c4 100644 --- a/src/app/modules/main/activity_center/controller.nim +++ b/src/app/modules/main/activity_center/controller.nim @@ -102,9 +102,6 @@ proc dismissActivityCenterNotifications*(self: Controller, notificationIds: seq[ proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText]): string = return self.messageService.getRenderedText(parsedTextArray) -proc decodeContentHash*(self: Controller, hash: string): string = - return eth_utils.decodeContentHash(hash) - proc switchTo*(self: Controller, sectionId, chatId, messageId: string) = let data = ActiveSectionChatArgs(sectionId: sectionId, chatId: chatId, messageId: messageId) self.events.emit(SIGNAL_MAKE_SECTION_CHAT_ACTIVE, data) diff --git a/src/app/modules/main/activity_center/module.nim b/src/app/modules/main/activity_center/module.nim index 8834e2777e..e1f45caa80 100644 --- a/src/app/modules/main/activity_center/module.nim +++ b/src/app/modules/main/activity_center/module.nim @@ -88,7 +88,7 @@ proc createMessageItemFromDto(self: Module, message: MessageDto, chatDetails: Ch message.timestamp, ContentType(message.contentType), message.messageType, - self.controller.decodeContentHash(message.sticker.hash), + message.sticker.url, message.sticker.pack, message.links, newTransactionParametersItem("","","","","","",-1,""), diff --git a/src/app/modules/main/chat_section/chat_content/controller.nim b/src/app/modules/main/chat_section/chat_content/controller.nim index 359714f9da..93add3d3b2 100644 --- a/src/app/modules/main/chat_section/chat_content/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/controller.nim @@ -235,9 +235,6 @@ proc getCurrentFleet*(self: Controller): string = proc getRenderedText*(self: Controller, parsedTextArray: seq[ParsedText]): string = return self.messageService.getRenderedText(parsedTextArray) -proc decodeContentHash*(self: Controller, hash: string): string = - return eth_utils.decodeContentHash(hash) - proc getTransactionDetails*(self: Controller, message: MessageDto): (string,string) = return self.messageService.getTransactionDetails(message) diff --git a/src/app/modules/main/chat_section/chat_content/messages/controller.nim b/src/app/modules/main/chat_section/chat_content/messages/controller.nim index 4f9de560b1..fcffedb926 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/controller.nim @@ -227,9 +227,6 @@ proc getMessageDetails*(self: Controller, messageId: string): proc deleteMessage*(self: Controller, messageId: string) = self.messageService.deleteMessage(messageId) -proc decodeContentHash*(self: Controller, hash: string): string = - return eth_utils.decodeContentHash(hash) - proc editMessage*(self: Controller, messageId: string, updatedMsg: string) = self.messageService.editMessage(messageId, updatedMsg) diff --git a/src/app/modules/main/chat_section/chat_content/messages/module.nim b/src/app/modules/main/chat_section/chat_content/messages/module.nim index 426ffbbc89..9a62810b48 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/module.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/module.nim @@ -192,7 +192,7 @@ method newMessagesLoaded*(self: Module, messages: seq[MessageDto], reactions: se m.whisperTimestamp, m.contentType.ContentType, m.messageType, - sticker = self.controller.decodeContentHash(m.sticker.hash), + sticker = m.sticker.url, m.sticker.pack, m.links, newTransactionParametersItem(m.transactionParameters.id, @@ -281,7 +281,7 @@ method messageAdded*(self: Module, message: MessageDto) = message.whisperTimestamp, message.contentType.ContentType, message.messageType, - sticker = self.controller.decodeContentHash(message.sticker.hash), + sticker = message.sticker.url, message.sticker.pack, message.links, newTransactionParametersItem(message.transactionParameters.id, diff --git a/src/app/modules/main/chat_section/chat_content/module.nim b/src/app/modules/main/chat_section/chat_content/module.nim index 9cd44ae5e9..ce9f6b5a16 100644 --- a/src/app/modules/main/chat_section/chat_content/module.nim +++ b/src/app/modules/main/chat_section/chat_content/module.nim @@ -180,7 +180,7 @@ proc buildPinnedMessageItem(self: Module, messageId: string, actionInitiatedBy: m.timestamp, m.contentType.ContentType, m.messageType, - self.controller.decodeContentHash(m.sticker.hash), + m.sticker.url, m.sticker.pack, m.links, newTransactionParametersItem(m.transactionParameters.id, diff --git a/src/app/modules/main/stickers/controller.nim b/src/app/modules/main/stickers/controller.nim index 883863ed08..392a6817db 100644 --- a/src/app/modules/main/stickers/controller.nim +++ b/src/app/modules/main/stickers/controller.nim @@ -124,9 +124,6 @@ proc sendSticker*( preferredUsername: string) = self.stickerService.sendSticker(channelId, replyTo, sticker, preferredUsername) -proc decodeContentHash*(self: Controller, hash: string): string = - eth_utils.decodeContentHash(hash) - proc wei2Eth*(self: Controller, price: Stuint[256]): string = eth_utils.wei2Eth(price) diff --git a/src/app/modules/main/stickers/io_interface.nim b/src/app/modules/main/stickers/io_interface.nim index 1a6b47307f..f7694494c7 100644 --- a/src/app/modules/main/stickers/io_interface.nim +++ b/src/app/modules/main/stickers/io_interface.nim @@ -49,9 +49,6 @@ method installStickerPack*(self: AccessInterface, packId: string) {.base.} = method uninstallStickerPack*(self: AccessInterface, packId: string) {.base.} = raise newException(ValueError, "No implementation available") -method decodeContentHash*(self: AccessInterface, hash: string): string {.base.} = - raise newException(ValueError, "No implementation available") - method wei2Eth*(self: AccessInterface, price: Stuint[256]): string {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/stickers/module.nim b/src/app/modules/main/stickers/module.nim index cf0db50825..f2aa5bf9e1 100644 --- a/src/app/modules/main/stickers/module.nim +++ b/src/app/modules/main/stickers/module.nim @@ -73,9 +73,6 @@ method uninstallStickerPack*(self: Module, packId: string) = method removeRecentStickers*(self: Module, packId: string) = self.controller.removeRecentStickers(packId) -method decodeContentHash*(self: Module, hash: string): string = - self.controller.decodeContentHash(hash) - method wei2Eth*(self: Module, price: Stuint[256]): string = self.controller.wei2Eth(price) diff --git a/src/app/modules/main/stickers/view.nim b/src/app/modules/main/stickers/view.nim index 536128432a..6f720dd43a 100644 --- a/src/app/modules/main/stickers/view.nim +++ b/src/app/modules/main/stickers/view.nim @@ -123,8 +123,8 @@ QtObject: self.stickerPacksLoaded() self.installedStickerPacksUpdated() - proc send*(self: View, channelId: string, hash: string, replyTo: string, pack: string) {.slot.} = - let sticker = initItem(hash, pack, eth_utils.decodeContentHash(hash)) + proc send*(self: View, channelId: string, hash: string, replyTo: string, pack: string, url: string) {.slot.} = + let sticker = initItem(hash, pack, url) self.addRecentStickerToList(sticker) self.delegate.sendSticker(channelId, replyTo, sticker) diff --git a/src/app_service/service/eth/utils.nim b/src/app_service/service/eth/utils.nim index 0f67f6419b..231aaefeca 100644 --- a/src/app_service/service/eth/utils.nim +++ b/src/app_service/service/eth/utils.nim @@ -13,58 +13,6 @@ import ../../common/conversion as common_conversion export common_conversion -proc decodeContentHash*(value: string): string = - if value == "": - return "" - - # eg encoded sticker multihash cid: - # e30101701220eab9a8ef4eac6c3e5836a3768d8e04935c10c67d9a700436a0e53199e9b64d29 - # e3017012205c531b83da9dd91529a4cf8ecd01cb62c399139e6f767e397d2f038b820c139f (testnet) - # e3011220c04c617170b1f5725070428c01280b4c19ae9083b7e6d71b7a0d2a1b5ae3ce30 (testnet) - # - # The first 4 bytes (in hex) represent: - # e3 = codec identifier "ipfs-ns" for content-hash - # 01 = unused - sometimes this is NOT included (ie ropsten) - # 01 = CID version (effectively unused, as we will decode with CIDv0 regardless) - # 70 = codec identifier "dag-pb" - - # ipfs-ns - if value[0..1] != "e3": - warn "Could not decode sticker. It may still be valid, but requires a different codec to be used", hash=value - return "" - - try: - # dag-pb - let defaultCodec = parseHexInt("70") #dag-pb - var codec = defaultCodec # no codec specified - var codecStartIdx = 2 # idx of where codec would start if it was specified - # handle the case when starts with 0xe30170 instead of 0xe3010170 - if value[2..5] == "0101": - codecStartIdx = 6 - codec = parseHexInt(value[6..7]) - elif value[2..3] == "01" and value[4..5] != "12": - codecStartIdx = 4 - codec = parseHexInt(value[4..5]) - - # strip the info we no longer need - var multiHashStr = value[codecStartIdx + 2.. 0) { diff --git a/ui/app/AppLayouts/Chat/views/ChatContentView.qml b/ui/app/AppLayouts/Chat/views/ChatContentView.qml index 50924eda90..592e4cdd4c 100644 --- a/ui/app/AppLayouts/Chat/views/ChatContentView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatContentView.qml @@ -516,7 +516,8 @@ ColumnLayout { root.rootStore.sendSticker(chatContentModule.getMyChatId(), hashId, chatInput.isReply ? chatInput.replyMessageId : "", - packId) + packId, + url) } diff --git a/ui/app/AppLayouts/Chat/views/CreateChatView.qml b/ui/app/AppLayouts/Chat/views/CreateChatView.qml index 2ead7f8cfc..536408e96e 100644 --- a/ui/app/AppLayouts/Chat/views/CreateChatView.qml +++ b/ui/app/AppLayouts/Chat/views/CreateChatView.qml @@ -167,6 +167,7 @@ Page { onStickerSelected: { root.rootStore.createChatStickerHashId = hashId; root.rootStore.createChatStickerPackId = packId; + root.rootStore.createChatStickerUrl = url; root.createChat(); } diff --git a/ui/imports/shared/status/StatusChatInput.qml b/ui/imports/shared/status/StatusChatInput.qml index 642b4e28f8..98202dd5ea 100644 --- a/ui/imports/shared/status/StatusChatInput.qml +++ b/ui/imports/shared/status/StatusChatInput.qml @@ -27,7 +27,7 @@ Rectangle { signal sendTransactionCommandButtonClicked() signal receiveTransactionCommandButtonClicked() - signal stickerSelected(string hashId, string packId) + signal stickerSelected(string hashId, string packId, string url) signal sendMessage(var event) signal unblockChat() @@ -815,7 +815,7 @@ Rectangle { recentStickers: control.recentStickers stickerPackList: control.stickerPackList onStickerSelected: { - control.stickerSelected(hashId, packId) + control.stickerSelected(hashId, packId, url) control.hideExtendedArea(); messageInputField.forceActiveFocus(); } diff --git a/ui/imports/shared/status/StatusStickerList.qml b/ui/imports/shared/status/StatusStickerList.qml index 8df4eb38e3..f7935e1969 100644 --- a/ui/imports/shared/status/StatusStickerList.qml +++ b/ui/imports/shared/status/StatusStickerList.qml @@ -19,7 +19,7 @@ StatusGridView { cellHeight: 88 model: stickerList focus: true - signal stickerClicked(string hash, int packId) + signal stickerClicked(string hash, int packId, string url) delegate: Item { width: root.cellWidth height: root.cellHeight @@ -32,7 +32,7 @@ StatusGridView { height: 80 source: url onClicked: { - root.stickerClicked(hash, packId) + root.stickerClicked(hash, packId, url) } } } diff --git a/ui/imports/shared/status/StatusStickersPopup.qml b/ui/imports/shared/status/StatusStickersPopup.qml index 435e9787a5..d1ac56757a 100644 --- a/ui/imports/shared/status/StatusStickersPopup.qml +++ b/ui/imports/shared/status/StatusStickersPopup.qml @@ -17,7 +17,7 @@ Popup { property var store property var recentStickers: StickerData {} property var stickerPackList: StickerPackData {} - signal stickerSelected(string hashId, string packId) + signal stickerSelected(string hashId, string packId, string url) property int installedPacksCount: stickersModule.numInstalledStickerPacks property bool stickerPacksLoaded: false width: 360 @@ -172,7 +172,7 @@ Popup { model: recentStickers packId: stickerPackListView.selectedPackId onStickerClicked: { - root.stickerSelected(hash, packId) + root.stickerSelected(hash, packId, url) root.close() } }