Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(communities-wallet): various improvements on community related transaction flows #17010

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/app/boot/app_controller.nim
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,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 @@ -244,7 +245,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 @@ -47,6 +47,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
201 changes: 110 additions & 91 deletions src/app/modules/main/communities/tokens/controller.nim

Large diffs are not rendered by default.

110 changes: 43 additions & 67 deletions src/app/modules/main/communities/tokens/io_interface.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
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/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,110 +14,84 @@ 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.} =
method computeAirdropFee*(self: AccessInterface, uuid: string, 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.} =
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 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 burnTokens*(self: AccessInterface, communityId: string, contractUniqueKey: string, amount: string, addressFrom: 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 setSigner*(self: AccessInterface, communityId: string, chainId: int, contractAddress: string, addressFrom: 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 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.} =
method authenticateAndTransfer*(self: AccessInterface) {.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 deployOwnerToken*(self: AccessInterface, 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 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.} =
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.} =
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.} =
method computeDeployFee*(self: AccessInterface, uuid: string, communityId: string, chainId: int, accountAddress: string,
tokenType: TokenType, isOwnerDeployment: bool) {.base.} =
raise newException(ValueError, "No implementation available")

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

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

method onCommunityTokenDeployStateChanged*(self: AccessInterface, communityId: string, chainId: int, transactionHash: string, deployState: DeployState) {.base.} =
method computeBurnFee*(self: AccessInterface, uuid: string, contractUniqueKey: string, amount: string, addressFrom: string) {.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.} =
method removeCommunityToken*(self: AccessInterface, communityId: string, chainId: int, address: string) {.base.} =
raise newException(ValueError, "No implementation available")

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

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

method removeCommunityToken*(self: AccessInterface, communityId: string, chainId: int, address: string) {.base.} =
method onCommunityTokenReceived*(self: AccessInterface, name: string, symbol: string, image: string, communityId: string, communityName: string, balance: string, chainId: int, txHash: string, isFirst: bool, tokenType: int, accountName: string, accountAddress: string) {.base.} =
raise newException(ValueError, "No implementation available")

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

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

method onCommunityTokenReceived*(self: AccessInterface, name: string, symbol: string, image: string, communityId: string, communityName: string, balance: string, chainId: int, txHash: string, isFirst: bool, tokenType: int, accountName: string, accountAddress: string) {.base.} =
method onOwnerTokenOwnerAddress*(self: AccessInterface, chainId: int, contractAddress: string, address: string, addressName: string) {.base.} =
raise newException(ValueError, "No implementation available")

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

method onSetSignerStateChanged*(self: AccessInterface, communityId: string, chainId: int, transactionHash: string, status: ContractTransactionStatus) {.base.} =
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 onLostOwnership*(self: AccessInterface, communityId: string) {.base.} =
method stopUpdatesForSuggestedRoute*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

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

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

method asyncGetOwnerTokenDetails*(self: AccessInterface, communityId: string) {.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