Skip to content

Commit

Permalink
chore(communities-wallet): various improvements on community related …
Browse files Browse the repository at this point in the history
…transaction flows

These changes should simplify the community related tx handlings on the client side, align it with
tx flows that we already have for other sending types and make it maintainable.

Related issue: #16810
  • Loading branch information
saledjenic committed Jan 13, 2025
1 parent 620b37f commit b37a3ee
Show file tree
Hide file tree
Showing 48 changed files with 1,782 additions and 1,362 deletions.
5 changes: 3 additions & 2 deletions src/app/boot/app_controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.communityService = community_service.newService(statusFoundation.events,
statusFoundation.threadpool, result.chatService, result.activityCenterService, result.messageService)
result.rampService = ramp_service.newService(statusFoundation.events, statusFoundation.threadpool)
result.transactionService = transaction_service.newService(statusFoundation.events, statusFoundation.threadpool, result.networkService, result.settingsService, result.tokenService)
result.transactionService = transaction_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.currencyService, result.networkService, result.settingsService, result.tokenService)
result.profileService = profile_service.newService(statusFoundation.events, statusFoundation.threadpool, result.settingsService)
result.stickersService = stickers_service.newService(
statusFoundation.events,
Expand Down Expand Up @@ -237,7 +238,7 @@ proc newAppController*(statusFoundation: StatusFoundation): AppController =
result.settingsService, result.walletAccountService, result.transactionService,
result.networkService, result.tokenService)
result.tokensService = tokens_service.newService(statusFoundation.events, statusFoundation.threadpool,
result.transactionService, result.tokenService, result.settingsService, result.walletAccountService,
result.networkService, result.transactionService, result.tokenService, result.settingsService, result.walletAccountService,
result.activityCenterService, result.communityService, result.currencyService)
result.providerService = provider_service.newService(statusFoundation.events, statusFoundation.threadpool, result.ensService)
result.networkConnectionService = network_connection_service.newService(statusFoundation.events,
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/signals/remote_signals/community.nim
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type DiscordChannelImportFinishedSignal* = ref object of Signal
channelId*: string

type CommunityTokenTransactionStatusChangedSignal* = ref object of Signal
transactionType*: string
sendType*: int
success*: bool
hash*: string
communityToken*: CommunityTokenDto
Expand Down Expand Up @@ -276,7 +276,7 @@ proc downloadingHistoryArchivesFinishedFromEvent*(T: type HistoryArchivesSignal,
proc fromEvent*(T: type CommunityTokenTransactionStatusChangedSignal, event: JsonNode): CommunityTokenTransactionStatusChangedSignal =
result = CommunityTokenTransactionStatusChangedSignal()
result.signalType = SignalType.CommunityTokenTransactionStatusChanged
result.transactionType = event["event"]{"transactionType"}.getStr()
result.sendType = event["event"]{"sendType"}.getInt()
result.success = event["event"]{"success"}.getBool()
result.hash = event["event"]{"hash"}.getStr()
if event["event"].hasKey("communityToken"):
Expand Down
3 changes: 3 additions & 0 deletions src/app/global/utils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ QtObject:
weiValue = fromHex(Stuint[256], weiValue).toString()
return conversion.wei2Eth(weiValue, decimals)

proc hexToDec*(self: Utils, hexValue: string): string {.slot.} =
return fromHex(Stuint[256], hexValue).toString()

proc hex2Ascii*(self: Utils, value: string): string {.slot.} =
result = string.fromBytes(hexToSeqByte(value))

Expand Down
5 changes: 3 additions & 2 deletions src/app/modules/main/communities/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ proc newModule*(
walletAccountService,
keycardService,
)
result.communityTokensModule = community_tokens_module.newCommunityTokensModule(result, events, communityTokensService, transactionService, networksService, communityService)
result.communityTokensModule = community_tokens_module.newCommunityTokensModule(result, events, walletAccountService,
communityTokensService, transactionService, networksService, communityService, keycardService)
result.moduleLoaded = false
result.events = events
result.curatedCommunitiesLoaded = false
Expand Down Expand Up @@ -955,7 +956,7 @@ proc applyPermissionResponse*(self: Module, communityId: string, permissions: Ta

if not aCriteriaChanged:
continue

let updatedTokenPermissionItem = initTokenPermissionItem(
tokenPermissionItem.id,
tokenPermissionItem.`type`,
Expand Down
179 changes: 112 additions & 67 deletions src/app/modules/main/communities/tokens/controller.nim

Large diffs are not rendered by default.

78 changes: 44 additions & 34 deletions src/app/modules/main/communities/tokens/io_interface.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import ../../../../../app_service/service/community_tokens/service
import ../../../../../app_service/service/community/dto/community
import ../../../../../app_service/common/types
import ../../../shared_models/currency_amount
import app_service/service/transaction/dto
import app_service/service/transaction/router_transactions_dto
import app_service/service/community_tokens/service
import app_service/service/community/dto/community
import app_service/common/types
import app/modules/shared_models/currency_amount
from app_service/service/keycard/service import KeycardEvent

type
AccessInterface* {.pure inheritable.} = ref object of RootObj
Expand All @@ -12,77 +15,67 @@ method delete*(self: AccessInterface) {.base.} =
method load*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

method airdropTokens*(self: AccessInterface, communityId: string, tokensJsonString: string, walletsJsonString: string, addressFrom: string) {.base.} =
raise newException(ValueError, "No implementation available")

method computeAirdropFee*(self: AccessInterface, communityId: string, tokensJsonString: string, walletsJsonString: string, addressFrom: string, requestId: string) {.base.} =
method computeAirdropFee*(self: AccessInterface, uuid: string, communityId: string, tokensJsonString: string,
walletsJsonString: string, addressFrom: string) {.base.} =
raise newException(ValueError, "No implementation available")

method selfDestructCollectibles*(self: AccessInterface, communityId: string, collectiblesToBurnJsonString: string, contractUniqueKey: string, addressFrom: string) {.base.} =
raise newException(ValueError, "No implementation available")

method burnTokens*(self: AccessInterface, communityId: string, contractUniqueKey: string, amount: string, addressFrom: string) {.base.} =
raise newException(ValueError, "No implementation available")

method setSigner*(self: AccessInterface, communityId: string, chainId: int, contractAddress: string, addressFrom: string) {.base.} =
raise newException(ValueError, "No implementation available")

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

method deployAssets*(self: AccessInterface, communityId: string, address: string, name: string, symbol: string, description: string, supply: string, infiniteSupply: bool, decimals: int,
chainId: int, imageCropInfoJson: string) {.base.} =
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,
imageCropInfoJson: string) {.base.} =
raise newException(ValueError, "No implementation available")

method computeDeployTokenOwnerFee*(self: AccessInterface, uuid: string, communityId: string, fromAddress: string,
ownerName: string, ownerSymbol: string, ownerDescription: string, masterName: string, masterSymbol: string,
masterDescription: string, chainId: int, imageCropInfoJson: string) {.base.} =
raise newException(ValueError, "No implementation available")

method deployOwnerToken*(self: AccessInterface, communityId: string, fromAddress: string, ownerName: string, ownerSymbol: string, ownerDescription: string,
masterName: string, masterSymbol: string, masterDescription: string, chainId: int, imageCropInfoJson: string) {.base.} =
method authenticateAndTransfer*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} =
method onUserAuthenticated*(self: AccessInterface, password: string, pin: string) {.base.} =
raise newException(ValueError, "No implementation available")

method resetTempValues*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

method computeDeployFee*(self: AccessInterface, communityId: string, chainId: int, accountAddress: string, tokenType: TokenType, isOwnerDeployment: bool, requestId: string) {.base.} =
method computeDeployFee*(self: AccessInterface, uuid: string, communityId: string, chainId: int, accountAddress: string,
tokenType: TokenType, isOwnerDeployment: bool) {.base.} =
raise newException(ValueError, "No implementation available")

method computeSetSignerFee*(self: AccessInterface, chainId: int, contractAddress: string, addressFrom: string, requestId: string) {.base.} =
raise newException(ValueError, "No implementation available")

method computeSelfDestructFee*(self: AccessInterface, collectiblesToBurnJsonString: string, contractUniqueKey: string, addressFrom: string, requestId: string) {.base.} =
method computeSelfDestructFee*(self: AccessInterface, uuid: string, collectiblesToBurnJsonString: string, contractUniqueKey: string, addressFrom: string) {.base.} =
raise newException(ValueError, "No implementation available")

method computeBurnFee*(self: AccessInterface, contractUniqueKey: string, amount: string, addressFrom: string, requestId: string) {.base.} =
raise newException(ValueError, "No implementation available")

method onDeployFeeComputed*(self: AccessInterface, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: ComputeFeeErrorCode, responseId: string) {.base.} =
raise newException(ValueError, "No implementation available")

method onSelfDestructFeeComputed*(self: AccessInterface, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: ComputeFeeErrorCode, responseId: string) {.base.} =
raise newException(ValueError, "No implementation available")

method onAirdropFeesComputed*(self: AccessInterface, args: AirdropFeesArgs) {.base.} =
raise newException(ValueError, "No implementation available")

method onBurnFeeComputed*(self: AccessInterface, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: ComputeFeeErrorCode, responseId: string) {.base.} =
raise newException(ValueError, "No implementation available")

method onSetSignerFeeComputed*(self: AccessInterface, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: ComputeFeeErrorCode, responseId: string) {.base.} =
raise newException(ValueError, "No implementation available")

method onCommunityTokenDeployStateChanged*(self: AccessInterface, communityId: string, chainId: int, transactionHash: string, deployState: DeployState) {.base.} =
raise newException(ValueError, "No implementation available")

method onOwnerTokenDeployStateChanged*(self: AccessInterface, communityId: string, chainId: int, transactionHash: string, deployState: DeployState) {.base.} =
raise newException(ValueError, "No implementation available")

method onOwnerTokenDeployStarted*(self: AccessInterface, communityId: string, chainId: int, transactionHash: string) {.base.} =
raise newException(ValueError, "No implementation available")

method onRemoteDestructStateChanged*(self: AccessInterface, communityId: string, tokenName: string, chainId: int, transactionHash: string, status: ContractTransactionStatus) {.base.} =
raise newException(ValueError, "No implementation available")

method onBurnStateChanged*(self: AccessInterface, communityId: string, tokenName: string, chainId: int, transactionHash: string, status: ContractTransactionStatus) {.base.} =
raise newException(ValueError, "No implementation available")
Expand Down Expand Up @@ -119,3 +112,20 @@ method onOwnerTokenOwnerAddress*(self: AccessInterface, chainId: int, contractAd

method asyncGetOwnerTokenDetails*(self: AccessInterface, communityId: string) {.base.} =
raise newException(ValueError, "No implementation available")

method suggestedRoutesReady*(self: AccessInterface, uuid: string, sendType: SendType, ethCurrency: CurrencyAmount,
fiatCurrency: CurrencyAmount, costPerPath: seq[CostPerPath], errCode: string, errDescription: string) {.base.} =
raise newException(ValueError, "No implementation available")

method stopUpdatesForSuggestedRoute*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

method prepareSignaturesForTransactions*(self:AccessInterface, txForSigning: RouterTransactionsForSigningDto) {.base.} =
raise newException(ValueError, "No implementation available")

method onTransactionSigned*(self: AccessInterface, keycardFlowType: string, keycardEvent: KeycardEvent) {.base.} =
raise newException(ValueError, "No implementation available")

method onTransactionSent*(self: AccessInterface, uuid: string, sendType: SendType, chainId: int, approvalTx: bool,
txHash: string, toAddress: string, error: string) {.base.} =
raise newException(ValueError, "No implementation available")
Loading

0 comments on commit b37a3ee

Please sign in to comment.