Skip to content

Commit aefe804

Browse files
committed
feat: Transaction deep link sharing
1 parent 03db155 commit aefe804

File tree

30 files changed

+280
-6
lines changed

30 files changed

+280
-6
lines changed

src/app/global/feature_flags.nim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const DEFAULT_FLAG_DAPPS_ENABLED = false
55
const DEFAULT_FLAG_SWAP_ENABLED = true
66
const DEFAULT_FLAG_CONNECTOR_ENABLED* = false
77
const DEFAULT_FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED = true
8+
const DEFAULT_FLAG_TRANSACTION_DEEP_LINK_ENABLED = false
89

910
proc boolToEnv*(defaultValue: bool): string =
1011
return if defaultValue: "1" else: "0"
@@ -15,13 +16,15 @@ QtObject:
1516
swapEnabled: bool
1617
connectorEnabled: bool
1718
sendViaPersonalChatEnabled: bool
19+
transactionDeepLinkEnabled: bool
1820

1921
proc setup(self: FeatureFlags) =
2022
self.QObject.setup()
2123
self.dappsEnabled = getEnv("FLAG_DAPPS_ENABLED", boolToEnv(DEFAULT_FLAG_DAPPS_ENABLED)) != "0"
2224
self.swapEnabled = getEnv("FLAG_SWAP_ENABLED", boolToEnv(DEFAULT_FLAG_SWAP_ENABLED)) != "0"
2325
self.connectorEnabled = getEnv("FLAG_CONNECTOR_ENABLED", boolToEnv(DEFAULT_FLAG_CONNECTOR_ENABLED)) != "0"
2426
self.sendViaPersonalChatEnabled = getEnv("FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED", boolToEnv(DEFAULT_FLAG_SEND_VIA_PERSONAL_CHAT_ENABLED)) != "0"
27+
self.transactionDeepLinkEnabled = getEnv("FLAG_TRANSACTION_DEEP_LINK_ENABLED", boolToEnv(DEFAULT_FLAG_TRANSACTION_DEEP_LINK_ENABLED)) != "0"
2528

2629
proc delete*(self: FeatureFlags) =
2730
self.QObject.delete()
@@ -53,3 +56,9 @@ QtObject:
5356

5457
QtProperty[bool] sendViaPersonalChatEnabled:
5558
read = getSendViaPersonalChatEnabled
59+
60+
proc getTransactionDeepLinkEnabled*(self: FeatureFlags): bool {.slot.} =
61+
return self.transactionDeepLinkEnabled
62+
63+
QtProperty[bool] transactionDeepLinkEnabled:
64+
read = getTransactionDeepLinkEnabled

src/app/modules/main/module.nim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,6 +1657,8 @@ method activateStatusDeepLink*[T](self: Module[T], statusDeepLink: string) =
16571657
self.onStatusUrlRequested(StatusUrlAction.DisplayUserProfile, communityId="", channelId="", url="",
16581658
urlData.contact.publicKey, urlData.community.shard)
16591659
return
1660+
if urlData.transaction.txType >= 0:
1661+
self.view.emitShowTransactionModal(urlData.transaction.txType, urlData.transaction.asset, urlData.transaction.amount, urlData.transaction.address, urlData.transaction.chainId, urlData.transaction.toAsset)
16601662

16611663
method onDeactivateChatLoader*[T](self: Module[T], sectionId: string, chatId: string) =
16621664
if (sectionId.len > 0 and self.chatSectionModules.contains(sectionId)):

src/app/modules/main/shared_urls/controller.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ proc parseContactSharedUrl*(self: Controller, url: string): ContactUrlDataDto =
3737

3838
proc parseSharedUrl*(self: Controller, url: string): UrlDataDto =
3939
return self.sharedUrlsService.parseSharedUrl(url)
40+
41+
proc parseTransactionSharedUrl*(self: Controller, url: string): TransactionUrlDataDto =
42+
let data = self.sharedUrlsService.parseSharedUrl(url)
43+
return data.transaction

src/app/modules/main/shared_urls/io_interface.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ method parseContactSharedUrl*(self: AccessInterface, url: string): string {.base
2727
method parseSharedUrl*(self: AccessInterface, url: string): UrlDataDto {.base.} =
2828
raise newException(ValueError, "No implementation available")
2929

30+
method parseTransactionSharedUrl*(self: AccessInterface, url: string): string {.base.} =
31+
raise newException(ValueError, "No implementation available")
32+
3033
# This way (using concepts) is used only for the modules managed by AppController
3134
type
3235
DelegateInterface* = concept c

src/app/modules/main/shared_urls/module.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ method parseCommunityChannelSharedUrl*(self: Module, url: string): string =
6363
method parseContactSharedUrl*(self: Module, url: string): string =
6464
let contactData = self.controller.parseContactSharedUrl(url)
6565
return $contactData
66+
67+
method parseTransactionSharedUrl*(self: Module, url: string): string =
68+
let transactionData = self.controller.parseTransactionSharedUrl(url)
69+
return $transactionData

src/app/modules/main/shared_urls/view.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ QtObject:
2525
return self.delegate.parseCommunityChannelSharedUrl(url)
2626

2727
proc parseContactSharedUrl*(self: View, url: string): string {.slot.} =
28-
return self.delegate.parseContactSharedUrl(url)
28+
return self.delegate.parseContactSharedUrl(url)
29+
30+
proc parseTransactionSharedUrl*(self: View, url: string): string {.slot.} =
31+
return self.delegate.parseTransactionSharedUrl(url)

src/app/modules/main/view.nim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,3 +382,8 @@ QtObject:
382382

383383
proc stopTokenHoldersManagement*(self: View) {.slot.} =
384384
self.delegate.stopTokenHoldersManagement()
385+
386+
proc showTransactionModal*(self: View, txType: int, asset: string, amount: string, address: string, chainId: int, toAsset: string) {.signal.}
387+
proc emitShowTransactionModal*(self: View, txType: int, asset: string, amount: string, address: string, chainId: int, toAsset: string) =
388+
self.showTransactionModal(txType, asset, amount, address, chainId, toAsset)
389+

src/app/modules/main/wallet_section/send/controller.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import app_service/service/currency/service as currency_service
88
import app_service/service/currency/dto as currency_dto
99
import app_service/service/keycard/service as keycard_service
1010
import app_service/service/network/network_item
11+
import app_service/service/shared_urls/dto/url_data as shared_urls_dto
1112

1213
import app/modules/shared_modules/keycard_popup/io_interface as keycard_shared_module
1314
import app/modules/shared/wallet_utils
@@ -137,6 +138,9 @@ proc signMessage*(self: Controller, address: string, hashedPassword: string, has
137138
proc sendRouterTransactionsWithSignatures*(self: Controller, uuid: string, signatures: TransactionsSignatures): string =
138139
return self.transactionService.sendRouterTransactionsWithSignatures(uuid, signatures)
139140

141+
proc shareTransactionURL*(self: Controller, urlData: shared_urls_dto.TransactionURLDataDto): string =
142+
return self.transactionService.shareTransactionURL(urlData)
143+
140144
proc areTestNetworksEnabled*(self: Controller): bool =
141145
return self.walletAccountService.areTestNetworksEnabled()
142146

src/app/modules/main/wallet_section/send/io_interface.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import Tables
22
import app/modules/shared_models/currency_amount
33
import app_service/service/transaction/dto
44
import app_service/service/transaction/router_transactions_dto
5+
import app_service/service/shared_urls/dto/url_data
56
import app_service/service/network/network_item
67
import app/modules/shared_models/collectibles_model as collectibles
78
from app_service/service/keycard/service import KeycardEvent
@@ -90,4 +91,7 @@ method getNetworkItem*(self: AccessInterface, chainId: int): NetworkItem {.base.
9091
raise newException(ValueError, "No implementation available")
9192

9293
method getNetworkChainId*(self: AccessInterface, shortName: string): int {.base.} =
94+
raise newException(ValueError, "No implementation available")
95+
96+
method shareTransactionURL*(self: AccessInterface, urlData: TransactionURLDataDto): string {.base.} =
9397
raise newException(ValueError, "No implementation available")

src/app/modules/main/wallet_section/send/module.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import app_service/service/transaction/service as transaction_service
1414
import app_service/service/keycard/service as keycard_service
1515
import app_service/service/keycard/constants as keycard_constants
1616
import app_service/service/transaction/dto
17+
import app_service/service/shared_urls/dto/url_data as shared_urls_dto
1718
import app/modules/shared_models/currency_amount
1819
import app_service/service/network/network_item as network_service_item
1920

@@ -404,3 +405,6 @@ method splitAndFormatAddressPrefix*(self: Module, text : string, updateInStore:
404405

405406
method transactionSendingComplete*(self: Module, txHash: string, status: string) =
406407
self.view.sendtransactionSendingCompleteSignal(txHash, status)
408+
409+
method shareTransactionURL*(self: Module, urlData: shared_urls_dto.TransactionURLDataDto): string =
410+
return self.controller.shareTransactionURL(urlData)

0 commit comments

Comments
 (0)