fix(Update fees periodically): Adding requestId to compute fees nim flows
The compute fees flows are async and requestId/responseId is added for the UI to match a request with the proper response.
This commit is contained in:
parent
b5d555f00b
commit
f2b3ba1ae7
|
@ -49,13 +49,13 @@ proc init*(self: Controller) =
|
|||
self.communityTokensModule.onUserAuthenticated(args.password)
|
||||
self.events.on(SIGNAL_COMPUTE_DEPLOY_FEE) do(e:Args):
|
||||
let args = ComputeFeeArgs(e)
|
||||
self.communityTokensModule.onDeployFeeComputed(args.ethCurrency, args.fiatCurrency, args.errorCode)
|
||||
self.communityTokensModule.onDeployFeeComputed(args.ethCurrency, args.fiatCurrency, args.errorCode, args.requestId)
|
||||
self.events.on(SIGNAL_COMPUTE_SELF_DESTRUCT_FEE) do(e:Args):
|
||||
let args = ComputeFeeArgs(e)
|
||||
self.communityTokensModule.onSelfDestructFeeComputed(args.ethCurrency, args.fiatCurrency, args.errorCode)
|
||||
self.communityTokensModule.onSelfDestructFeeComputed(args.ethCurrency, args.fiatCurrency, args.errorCode, args.requestId)
|
||||
self.events.on(SIGNAL_COMPUTE_BURN_FEE) do(e:Args):
|
||||
let args = ComputeFeeArgs(e)
|
||||
self.communityTokensModule.onBurnFeeComputed(args.ethCurrency, args.fiatCurrency, args.errorCode)
|
||||
self.communityTokensModule.onBurnFeeComputed(args.ethCurrency, args.fiatCurrency, args.errorCode, args.requestId)
|
||||
self.events.on(SIGNAL_COMPUTE_AIRDROP_FEE) do(e:Args):
|
||||
let args = AirdropFeesArgs(e)
|
||||
self.communityTokensModule.onAirdropFeesComputed(args)
|
||||
|
@ -97,8 +97,8 @@ proc removeCommunityToken*(self: Controller, communityId: string, chainId: int,
|
|||
proc airdropTokens*(self: Controller, communityId: string, password: string, tokensAndAmounts: seq[CommunityTokenAndAmount], walletAddresses: seq[string], addressFrom: string) =
|
||||
self.communityTokensService.airdropTokens(communityId, password, tokensAndAmounts, walletAddresses, addressFrom)
|
||||
|
||||
proc computeAirdropFee*(self: Controller, tokensAndAmounts: seq[CommunityTokenAndAmount], walletAddresses: seq[string], addressFrom: string) =
|
||||
self.communityTokensService.computeAirdropFee(tokensAndAmounts, walletAddresses, addressFrom)
|
||||
proc computeAirdropFee*(self: Controller, tokensAndAmounts: seq[CommunityTokenAndAmount], walletAddresses: seq[string], addressFrom: string, requestId: string) =
|
||||
self.communityTokensService.computeAirdropFee(tokensAndAmounts, walletAddresses, addressFrom, requestId)
|
||||
|
||||
proc selfDestructCollectibles*(self: Controller, communityId: string, password: string, walletAndAmounts: seq[WalletAndAmount], contractUniqueKey: string, addressFrom: string) =
|
||||
self.communityTokensService.selfDestructCollectibles(communityId, password, walletAndAmounts, contractUniqueKey, addressFrom)
|
||||
|
@ -113,20 +113,20 @@ proc authenticateUser*(self: Controller, keyUid = "") =
|
|||
proc getCommunityTokens*(self: Controller, communityId: string): seq[CommunityTokenDto] =
|
||||
return self.communityTokensService.getCommunityTokens(communityId)
|
||||
|
||||
proc computeDeployFee*(self: Controller, chainId: int, accountAddress: string, tokenType: TokenType) =
|
||||
self.communityTokensService.computeDeployFee(chainId, accountAddress, tokenType)
|
||||
proc computeDeployFee*(self: Controller, chainId: int, accountAddress: string, tokenType: TokenType, requestId: string) =
|
||||
self.communityTokensService.computeDeployFee(chainId, accountAddress, tokenType, requestId)
|
||||
|
||||
proc computeDeployOwnerContractsFee*(self: Controller, chainId: int, accountAddress: string) =
|
||||
self.communityTokensService.computeDeployOwnerContractsFee(chainId, accountAddress)
|
||||
proc computeDeployOwnerContractsFee*(self: Controller, chainId: int, accountAddress: string, requestId: string) =
|
||||
self.communityTokensService.computeDeployOwnerContractsFee(chainId, accountAddress, requestId)
|
||||
|
||||
proc computeSelfDestructFee*(self: Controller, walletAndAmountList: seq[WalletAndAmount], contractUniqueKey: string, addressFrom: string) =
|
||||
self.communityTokensService.computeSelfDestructFee(walletAndAmountList, contractUniqueKey, addressFrom)
|
||||
proc computeSelfDestructFee*(self: Controller, walletAndAmountList: seq[WalletAndAmount], contractUniqueKey: string, addressFrom: string, requestId: string) =
|
||||
self.communityTokensService.computeSelfDestructFee(walletAndAmountList, contractUniqueKey, addressFrom, requestId)
|
||||
|
||||
proc findContractByUniqueId*(self: Controller, contractUniqueKey: string): CommunityTokenDto =
|
||||
return self.communityTokensService.findContractByUniqueId(contractUniqueKey)
|
||||
|
||||
proc computeBurnFee*(self: Controller, contractUniqueKey: string, amount: Uint256, addressFrom: string) =
|
||||
self.communityTokensService.computeBurnFee(contractUniqueKey, amount, addressFrom)
|
||||
proc computeBurnFee*(self: Controller, contractUniqueKey: string, amount: Uint256, addressFrom: string, requestId: string) =
|
||||
self.communityTokensService.computeBurnFee(contractUniqueKey, amount, addressFrom, requestId)
|
||||
|
||||
proc getNetwork*(self:Controller, chainId: int): NetworkDto =
|
||||
self.networksService.getNetwork(chainId)
|
||||
|
|
|
@ -15,7 +15,7 @@ method load*(self: AccessInterface) {.base.} =
|
|||
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) {.base.} =
|
||||
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.} =
|
||||
|
@ -42,25 +42,25 @@ method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} =
|
|||
method resetTempValues*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method computeDeployFee*(self: AccessInterface, chainId: int, accountAddress: string, tokenType: TokenType, isOwnerDeployment: bool) {.base.} =
|
||||
method computeDeployFee*(self: AccessInterface, chainId: int, accountAddress: string, tokenType: TokenType, isOwnerDeployment: bool, requestId: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method computeSelfDestructFee*(self: AccessInterface, collectiblesToBurnJsonString: string, contractUniqueKey: string, addressFrom: string) {.base.} =
|
||||
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) {.base.} =
|
||||
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) {.base.} =
|
||||
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) {.base.} =
|
||||
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) {.base.} =
|
||||
method onBurnFeeComputed*(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.} =
|
||||
|
|
|
@ -117,11 +117,11 @@ method airdropTokens*(self: Module, communityId: string, tokensJsonString: strin
|
|||
self.tempContractAction = ContractAction.Airdrop
|
||||
self.authenticate()
|
||||
|
||||
method computeAirdropFee*(self: Module, communityId: string, tokensJsonString: string, walletsJsonString: string, addressFrom: string) =
|
||||
method computeAirdropFee*(self: Module, communityId: string, tokensJsonString: string, walletsJsonString: string, addressFrom: string, requestId: string) =
|
||||
let tokenAndAmountList = self.getTokenAndAmountList(communityId, tokensJsonString)
|
||||
if len(tokenAndAmountList) == 0:
|
||||
return
|
||||
self.controller.computeAirdropFee(tokenAndAmountList, walletsJsonString.parseJson.to(seq[string]), addressFrom)
|
||||
self.controller.computeAirdropFee(tokenAndAmountList, walletsJsonString.parseJson.to(seq[string]), addressFrom, requestId)
|
||||
|
||||
proc getWalletAndAmountListFromJson(self: Module, collectiblesToBurnJsonString: string): seq[WalletAndAmount] =
|
||||
let collectiblesToBurnJson = collectiblesToBurnJsonString.parseJson
|
||||
|
@ -238,30 +238,30 @@ method onUserAuthenticated*(self: Module, password: string) =
|
|||
self.tempMasterDeploymentParams, self.tempMasterTokenMetadata,
|
||||
self.tempTokenImageCropInfoJson, self.tempChainId)
|
||||
|
||||
method onDeployFeeComputed*(self: Module, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: ComputeFeeErrorCode) =
|
||||
self.view.updateDeployFee(ethCurrency, fiatCurrency, errorCode.int)
|
||||
method onDeployFeeComputed*(self: Module, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: ComputeFeeErrorCode, responseId: string) =
|
||||
self.view.updateDeployFee(ethCurrency, fiatCurrency, errorCode.int, responseId)
|
||||
|
||||
method onSelfDestructFeeComputed*(self: Module, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: ComputeFeeErrorCode) =
|
||||
self.view.updateSelfDestructFee(ethCurrency, fiatCurrency, errorCode.int)
|
||||
method onSelfDestructFeeComputed*(self: Module, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: ComputeFeeErrorCode, responseId: string) =
|
||||
self.view.updateSelfDestructFee(ethCurrency, fiatCurrency, errorCode.int, responseId)
|
||||
|
||||
method onAirdropFeesComputed*(self: Module, args: AirdropFeesArgs) =
|
||||
self.view.updateAirdropFees(%args)
|
||||
|
||||
method onBurnFeeComputed*(self: Module, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: ComputeFeeErrorCode) =
|
||||
self.view.updateBurnFee(ethCurrency, fiatCurrency, errorCode.int)
|
||||
method onBurnFeeComputed*(self: Module, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: ComputeFeeErrorCode, responseId: string) =
|
||||
self.view.updateBurnFee(ethCurrency, fiatCurrency, errorCode.int, responseId)
|
||||
|
||||
method computeDeployFee*(self: Module, chainId: int, accountAddress: string, tokenType: TokenType, isOwnerDeployment: bool) =
|
||||
method computeDeployFee*(self: Module, chainId: int, accountAddress: string, tokenType: TokenType, isOwnerDeployment: bool, requestId: string) =
|
||||
if isOwnerDeployment:
|
||||
self.controller.computeDeployOwnerContractsFee(chainId, accountAddress)
|
||||
self.controller.computeDeployOwnerContractsFee(chainId, accountAddress, requestId)
|
||||
else:
|
||||
self.controller.computeDeployFee(chainId, accountAddress, tokenType)
|
||||
self.controller.computeDeployFee(chainId, accountAddress, tokenType, requestId)
|
||||
|
||||
method computeSelfDestructFee*(self: Module, collectiblesToBurnJsonString: string, contractUniqueKey: string, addressFrom: string) =
|
||||
method computeSelfDestructFee*(self: Module, collectiblesToBurnJsonString: string, contractUniqueKey: string, addressFrom: string, requestId: string) =
|
||||
let walletAndAmountList = self.getWalletAndAmountListFromJson(collectiblesToBurnJsonString)
|
||||
self.controller.computeSelfDestructFee(walletAndAmountList, contractUniqueKey, addressFrom)
|
||||
self.controller.computeSelfDestructFee(walletAndAmountList, contractUniqueKey, addressFrom, requestId)
|
||||
|
||||
method computeBurnFee*(self: Module, contractUniqueKey: string, amount: string, addressFrom: string) =
|
||||
self.controller.computeBurnFee(contractUniqueKey, amount.parse(Uint256), addressFrom)
|
||||
method computeBurnFee*(self: Module, contractUniqueKey: string, amount: string, addressFrom: string, requestId: string) =
|
||||
self.controller.computeBurnFee(contractUniqueKey, amount.parse(Uint256), addressFrom, requestId)
|
||||
|
||||
proc createUrl(self: Module, chainId: int, transactionHash: string): string =
|
||||
let network = self.controller.getNetwork(chainId)
|
||||
|
|
|
@ -36,8 +36,8 @@ QtObject:
|
|||
proc airdropTokens*(self: View, communityId: string, tokensJsonString: string, walletsJsonString: string, addressFrom: string) {.slot.} =
|
||||
self.communityTokensModule.airdropTokens(communityId, tokensJsonString, walletsJsonString, addressFrom)
|
||||
|
||||
proc computeAirdropFee*(self: View, communityId: string, tokensJsonString: string, walletsJsonString: string, addressFrom: string) {.slot.} =
|
||||
self.communityTokensModule.computeAirdropFee(communityId, tokensJsonString, walletsJsonString, addressFrom)
|
||||
proc computeAirdropFee*(self: View, communityId: string, tokensJsonString: string, walletsJsonString: string, addressFrom: string, requestId: string) {.slot.} =
|
||||
self.communityTokensModule.computeAirdropFee(communityId, tokensJsonString, walletsJsonString, addressFrom, requestId)
|
||||
|
||||
proc selfDestructCollectibles*(self: View, communityId: string, collectiblesToBurnJsonString: string, contractUniqueKey: string, addressFrom: string) {.slot.} =
|
||||
self.communityTokensModule.selfDestructCollectibles(communityId, collectiblesToBurnJsonString, contractUniqueKey, addressFrom)
|
||||
|
@ -45,28 +45,28 @@ QtObject:
|
|||
proc burnTokens*(self: View, communityId: string, contractUniqueKey: string, amount: string, addressFrom: string) {.slot.} =
|
||||
self.communityTokensModule.burnTokens(communityId, contractUniqueKey, amount, addressFrom)
|
||||
|
||||
proc deployFeeUpdated*(self: View, ethCurrency: QVariant, fiatCurrency: QVariant, errorCode: int) {.signal.}
|
||||
proc selfDestructFeeUpdated*(self: View, ethCurrency: QVariant, fiatCurrency: QVariant, errorCode: int) {.signal.}
|
||||
proc deployFeeUpdated*(self: View, ethCurrency: QVariant, fiatCurrency: QVariant, errorCode: int, responseId: string) {.signal.}
|
||||
proc selfDestructFeeUpdated*(self: View, ethCurrency: QVariant, fiatCurrency: QVariant, errorCode: int, responseId: string) {.signal.}
|
||||
proc airdropFeesUpdated*(self: View, json: string) {.signal.}
|
||||
proc burnFeeUpdated*(self: View, ethCurrency: QVariant, fiatCurrency: QVariant, errorCode: int) {.signal.}
|
||||
proc burnFeeUpdated*(self: View, ethCurrency: QVariant, fiatCurrency: QVariant, errorCode: int, responseId: string) {.signal.}
|
||||
|
||||
proc computeDeployFee*(self: View, chainId: int, accountAddress: string, tokenType: int, isOwnerDeployment: bool) {.slot.} =
|
||||
self.communityTokensModule.computeDeployFee(chainId, accountAddress, intToEnum(tokenType, TokenType.Unknown), isOwnerDeployment)
|
||||
proc computeDeployFee*(self: View, chainId: int, accountAddress: string, tokenType: int, isOwnerDeployment: bool, requestId: string) {.slot.} =
|
||||
self.communityTokensModule.computeDeployFee(chainId, accountAddress, intToEnum(tokenType, TokenType.Unknown), isOwnerDeployment, requestId)
|
||||
|
||||
proc computeSelfDestructFee*(self: View, collectiblesToBurnJsonString: string, contractUniqueKey: string, addressFrom: string) {.slot.} =
|
||||
self.communityTokensModule.computeSelfDestructFee(collectiblesToBurnJsonString, contractUniqueKey, addressFrom)
|
||||
proc computeSelfDestructFee*(self: View, collectiblesToBurnJsonString: string, contractUniqueKey: string, addressFrom: string, requestId: string) {.slot.} =
|
||||
self.communityTokensModule.computeSelfDestructFee(collectiblesToBurnJsonString, contractUniqueKey, addressFrom, requestId)
|
||||
|
||||
proc computeBurnFee*(self: View, contractUniqueKey: string, amount: string, addressFrom: string) {.slot.} =
|
||||
self.communityTokensModule.computeBurnFee(contractUniqueKey, amount, addressFrom)
|
||||
proc computeBurnFee*(self: View, contractUniqueKey: string, amount: string, addressFrom: string, requestId: string) {.slot.} =
|
||||
self.communityTokensModule.computeBurnFee(contractUniqueKey, amount, addressFrom, requestId)
|
||||
|
||||
proc updateDeployFee*(self: View, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: int) =
|
||||
self.deployFeeUpdated(newQVariant(ethCurrency), newQVariant(fiatCurrency), errorCode)
|
||||
proc updateDeployFee*(self: View, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: int, responseId: string) =
|
||||
self.deployFeeUpdated(newQVariant(ethCurrency), newQVariant(fiatCurrency), errorCode, responseId)
|
||||
|
||||
proc updateBurnFee*(self: View, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: int) =
|
||||
self.burnFeeUpdated(newQVariant(ethCurrency), newQVariant(fiatCurrency), errorCode)
|
||||
proc updateBurnFee*(self: View, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: int, responseId: string) =
|
||||
self.burnFeeUpdated(newQVariant(ethCurrency), newQVariant(fiatCurrency), errorCode, responseId)
|
||||
|
||||
proc updateSelfDestructFee*(self: View, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: int) =
|
||||
self.selfDestructFeeUpdated(newQVariant(ethCurrency), newQVariant(fiatCurrency), errorCode)
|
||||
proc updateSelfDestructFee*(self: View, ethCurrency: CurrencyAmount, fiatCurrency: CurrencyAmount, errorCode: int, responseId: string) =
|
||||
self.selfDestructFeeUpdated(newQVariant(ethCurrency), newQVariant(fiatCurrency), errorCode, responseId)
|
||||
|
||||
proc updateAirdropFees*(self: View, args: JsonNode) =
|
||||
self.airdropFeesUpdated($args)
|
||||
|
|
|
@ -21,6 +21,7 @@ type
|
|||
AsyncDeployOwnerContractsFeesArg = ref object of QObjectTaskArg
|
||||
chainId: int
|
||||
addressFrom: string
|
||||
requestId: string
|
||||
|
||||
const asyncGetDeployOwnerContractsFeesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[AsyncDeployOwnerContractsFeesArg](argEncoded)
|
||||
|
@ -37,10 +38,12 @@ const asyncGetDeployOwnerContractsFeesTask: Task = proc(argEncoded: string) {.gc
|
|||
"chainId": arg.chainId,
|
||||
"addressFrom": arg.addressFrom,
|
||||
"error": "",
|
||||
"requestId": arg.requestId,
|
||||
})
|
||||
except Exception as e:
|
||||
arg.finish(%* {
|
||||
"error": e.msg,
|
||||
"requestId": arg.requestId,
|
||||
})
|
||||
|
||||
type
|
||||
|
@ -48,6 +51,7 @@ type
|
|||
chainId: int
|
||||
addressFrom: string
|
||||
tokenType: TokenType
|
||||
requestId: string
|
||||
|
||||
const asyncGetDeployFeesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[AsyncGetDeployFeesArg](argEncoded)
|
||||
|
@ -58,6 +62,7 @@ const asyncGetDeployFeesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.
|
|||
feeTable[arg.chainId] = response.toSuggestedFeesDto()
|
||||
let deployGas = if arg.tokenType == TokenType.ERC721: community_tokens.deployCollectiblesEstimate().result.getInt
|
||||
else: community_tokens.deployAssetsEstimate().result.getInt
|
||||
|
||||
gasTable[(arg.chainId, "")] = deployGas
|
||||
arg.finish(%* {
|
||||
"feeTable": tableToJsonArray(feeTable),
|
||||
|
@ -65,10 +70,12 @@ const asyncGetDeployFeesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.
|
|||
"chainId": arg.chainId,
|
||||
"addressFrom": arg.addressFrom,
|
||||
"error": "",
|
||||
"requestId": arg.requestId,
|
||||
})
|
||||
except Exception as e:
|
||||
arg.finish(%* {
|
||||
"error": e.msg,
|
||||
"requestId": arg.requestId,
|
||||
})
|
||||
|
||||
type
|
||||
|
@ -77,6 +84,7 @@ type
|
|||
contractAddress: string
|
||||
tokenIds: seq[UInt256]
|
||||
addressFrom: string
|
||||
requestId: string
|
||||
|
||||
const asyncGetRemoteBurnFeesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[AsyncGetRemoteBurnFees](argEncoded)
|
||||
|
@ -92,10 +100,12 @@ const asyncGetRemoteBurnFeesTask: Task = proc(argEncoded: string) {.gcsafe, nimc
|
|||
"gasTable": tableToJsonArray(gasTable),
|
||||
"chainId": arg.chainId,
|
||||
"addressFrom": arg.addressFrom,
|
||||
"requestId": arg.requestId,
|
||||
"error": "" })
|
||||
except Exception as e:
|
||||
arg.finish(%* {
|
||||
"error": e.msg,
|
||||
"requestId": arg.requestId,
|
||||
})
|
||||
|
||||
type
|
||||
|
@ -104,6 +114,7 @@ type
|
|||
contractAddress: string
|
||||
amount: Uint256
|
||||
addressFrom: string
|
||||
requestId: string
|
||||
|
||||
const asyncGetBurnFeesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[AsyncGetBurnFees](argEncoded)
|
||||
|
@ -119,10 +130,12 @@ const asyncGetBurnFeesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.}
|
|||
"gasTable": tableToJsonArray(gasTable),
|
||||
"chainId": arg.chainId,
|
||||
"addressFrom": arg.addressFrom,
|
||||
"requestId": arg.requestId,
|
||||
"error": "" })
|
||||
except Exception as e:
|
||||
arg.finish(%* {
|
||||
"error": e.msg,
|
||||
"requestId": arg.requestId,
|
||||
})
|
||||
|
||||
type
|
||||
|
@ -130,6 +143,7 @@ type
|
|||
collectiblesAndAmounts: seq[CommunityTokenAndAmount]
|
||||
walletAddresses: seq[string]
|
||||
addressFrom: string
|
||||
requestId: string
|
||||
|
||||
const asyncGetMintFeesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[AsyncGetMintFees](argEncoded)
|
||||
|
@ -149,12 +163,14 @@ const asyncGetMintFeesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.}
|
|||
arg.walletAddresses, collectibleAndAmount.amount).result.getInt
|
||||
gasTable[(chainId, collectibleAndAmount.communityToken.address)] = gas
|
||||
arg.finish(%* {
|
||||
"requestId": arg.requestId,
|
||||
"feeTable": tableToJsonArray(feeTable),
|
||||
"gasTable": tableToJsonArray(gasTable),
|
||||
"addressFrom": arg.addressFrom,
|
||||
"error": "" })
|
||||
except Exception as e:
|
||||
let output = %* {
|
||||
"requestId": arg.requestId,
|
||||
"error": e.msg
|
||||
}
|
||||
arg.finish(output)
|
||||
|
|
|
@ -165,6 +165,7 @@ type
|
|||
fiatCurrency*: CurrencyAmount
|
||||
errorCode*: ComputeFeeErrorCode
|
||||
contractUniqueKey*: string # used for minting
|
||||
requestId*: string
|
||||
|
||||
proc `%`*(self: ComputeFeeArgs): JsonNode =
|
||||
result = %* {
|
||||
|
@ -186,13 +187,15 @@ type
|
|||
totalEthFee*: CurrencyAmount
|
||||
totalFiatFee*: CurrencyAmount
|
||||
errorCode*: ComputeFeeErrorCode
|
||||
requestId*: string
|
||||
|
||||
proc `%`*(self: AirdropFeesArgs): JsonNode =
|
||||
result = %* {
|
||||
"fees": computeFeeArgsToJsonArray(self.fees),
|
||||
"totalEthFee": self.totalEthFee.toJsonNode(),
|
||||
"totalFiatFee": self.totalFiatFee.toJsonNode(),
|
||||
"errorCode": self.errorCode.int
|
||||
"errorCode": self.errorCode.int,
|
||||
"requestId": self.requestId,
|
||||
}
|
||||
|
||||
type
|
||||
|
@ -639,7 +642,7 @@ QtObject:
|
|||
except RpcException:
|
||||
error "Error airdropping tokens", message = getCurrentExceptionMsg()
|
||||
|
||||
proc computeAirdropFee*(self: Service, collectiblesAndAmounts: seq[CommunityTokenAndAmount], walletAddresses: seq[string], addressFrom: string) =
|
||||
proc computeAirdropFee*(self: Service, collectiblesAndAmounts: seq[CommunityTokenAndAmount], walletAddresses: seq[string], addressFrom: string, requestId: string) =
|
||||
try:
|
||||
self.tempTokensAndAmounts = collectiblesAndAmounts
|
||||
let arg = AsyncGetMintFees(
|
||||
|
@ -648,10 +651,12 @@ QtObject:
|
|||
slot: "onAirdropFees",
|
||||
collectiblesAndAmounts: collectiblesAndAmounts,
|
||||
walletAddresses: walletAddresses,
|
||||
addressFrom: addressFrom
|
||||
addressFrom: addressFrom,
|
||||
requestId: requestId
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
except Exception as e:
|
||||
#TODO: handle error - emit error signal
|
||||
error "Error loading airdrop fees", msg = e.msg
|
||||
|
||||
proc getFiatValue*(self: Service, cryptoBalance: float, cryptoSymbol: string): float =
|
||||
|
@ -661,7 +666,7 @@ QtObject:
|
|||
let price = self.tokenService.getTokenPrice(cryptoSymbol, currentCurrency)
|
||||
return cryptoBalance * price
|
||||
|
||||
proc computeDeployFee*(self: Service, chainId: int, accountAddress: string, tokenType: TokenType) =
|
||||
proc computeDeployFee*(self: Service, chainId: int, accountAddress: string, tokenType: TokenType, requestId: string) =
|
||||
try:
|
||||
if tokenType != TokenType.ERC20 and tokenType != TokenType.ERC721:
|
||||
error "Error loading fees: unknown token type", tokenType = tokenType
|
||||
|
@ -672,23 +677,27 @@ QtObject:
|
|||
slot: "onDeployFees",
|
||||
chainId: chainId,
|
||||
addressFrom: accountAddress,
|
||||
tokenType: tokenType
|
||||
tokenType: tokenType,
|
||||
requestId: requestId
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
except Exception as e:
|
||||
#TODO: handle error - emit error signal
|
||||
error "Error loading fees", msg = e.msg
|
||||
|
||||
proc computeDeployOwnerContractsFee*(self: Service, chainId: int, accountAddress: string) =
|
||||
proc computeDeployOwnerContractsFee*(self: Service, chainId: int, accountAddress: string, requestId: string) =
|
||||
try:
|
||||
let arg = AsyncDeployOwnerContractsFeesArg(
|
||||
tptr: cast[ByteAddress](asyncGetDeployOwnerContractsFeesTask),
|
||||
vptr: cast[ByteAddress](self.vptr),
|
||||
slot: "onDeployOwnerContractsFees",
|
||||
chainId: chainId,
|
||||
addressFrom: accountAddress
|
||||
addressFrom: accountAddress,
|
||||
requestId: requestId
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
except Exception as e:
|
||||
#TODO: handle error - emit error signal
|
||||
error "Error loading fees", msg = e.msg
|
||||
|
||||
proc findContractByUniqueId*(self: Service, contractUniqueKey: string): CommunityTokenDto =
|
||||
|
@ -755,7 +764,7 @@ QtObject:
|
|||
except Exception as e:
|
||||
error "Remote self destruct error", msg = e.msg
|
||||
|
||||
proc computeSelfDestructFee*(self: Service, walletAndAmountList: seq[WalletAndAmount], contractUniqueKey: string, addressFrom: string) =
|
||||
proc computeSelfDestructFee*(self: Service, walletAndAmountList: seq[WalletAndAmount], contractUniqueKey: string, addressFrom: string, requestId: string) =
|
||||
try:
|
||||
let contract = self.findContractByUniqueId(contractUniqueKey)
|
||||
let tokenIds = self.getTokensToBurn(walletAndAmountList, contract)
|
||||
|
@ -769,7 +778,8 @@ QtObject:
|
|||
chainId: contract.chainId,
|
||||
contractAddress: contract.address,
|
||||
tokenIds: tokenIds,
|
||||
addressFrom: addressFrom
|
||||
addressFrom: addressFrom,
|
||||
requestId: requestId
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
except Exception as e:
|
||||
|
@ -816,7 +826,7 @@ QtObject:
|
|||
except Exception as e:
|
||||
error "Burn error", msg = e.msg
|
||||
|
||||
proc computeBurnFee*(self: Service, contractUniqueKey: string, amount: Uint256, addressFrom: string) =
|
||||
proc computeBurnFee*(self: Service, contractUniqueKey: string, amount: Uint256, addressFrom: string, requestId: string) =
|
||||
try:
|
||||
let contract = self.findContractByUniqueId(contractUniqueKey)
|
||||
let arg = AsyncGetBurnFees(
|
||||
|
@ -826,7 +836,8 @@ QtObject:
|
|||
chainId: contract.chainId,
|
||||
contractAddress: contract.address,
|
||||
amount: amount,
|
||||
addressFrom: addressFrom
|
||||
addressFrom: addressFrom,
|
||||
requestId: requestId
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
except Exception as e:
|
||||
|
@ -887,11 +898,12 @@ QtObject:
|
|||
error "Error converting to fee table", message = getCurrentExceptionMsg()
|
||||
|
||||
proc parseFeeResponseAndEmitSignal(self:Service, response: string, signalName: string) =
|
||||
let responseJson = response.parseJson()
|
||||
try:
|
||||
let responseJson = response.parseJson()
|
||||
let errorMessage = responseJson{"error"}.getStr
|
||||
if errorMessage != "":
|
||||
let data = self.createComputeFeeArgsWithError(errorMessage)
|
||||
data.requestId = responseJson{"requestId"}.getStr
|
||||
self.events.emit(signalName, data)
|
||||
return
|
||||
let gasTable = responseJson{"gasTable"}.toGasTable
|
||||
|
@ -903,10 +915,12 @@ QtObject:
|
|||
let gasUnits = toSeq(gasTable.values())[0]
|
||||
let suggestedFees = toSeq(feeTable.values())[0]
|
||||
let data = self.createComputeFeeArgs(gasUnits, suggestedFees, chainId, addressFrom)
|
||||
data.requestId = responseJson{"requestId"}.getStr
|
||||
self.events.emit(signalName, data)
|
||||
except Exception:
|
||||
error "Error creating fee args", message = getCurrentExceptionMsg()
|
||||
let data = self.createComputeFeeArgsWithError(getCurrentExceptionMsg())
|
||||
data.requestId = responseJson{"requestId"}.getStr
|
||||
self.events.emit(signalName, data)
|
||||
|
||||
proc onDeployOwnerContractsFees*(self:Service, response: string) {.slot.} =
|
||||
|
@ -927,10 +941,11 @@ QtObject:
|
|||
var allComputeFeeArgs: seq[ComputeFeeArgs]
|
||||
var dataToEmit = AirdropFeesArgs()
|
||||
dataToEmit.errorCode = ComputeFeeErrorCode.Success
|
||||
let responseJson = response.parseJson()
|
||||
|
||||
try:
|
||||
let responseJson = response.parseJson()
|
||||
let errorMessage = responseJson{"error"}.getStr
|
||||
let requestId = responseJson{"requestId"}.getStr
|
||||
if errorMessage != "":
|
||||
for collectibleAndAmount in self.tempTokensAndAmounts:
|
||||
let args = self.createComputeFeeArgsWithError(errorMessage)
|
||||
|
@ -940,6 +955,7 @@ QtObject:
|
|||
dataToEmit.totalEthFee = ethTotal
|
||||
dataToEmit.totalFiatFee = fiatTotal
|
||||
dataToEmit.errorCode = self.getErrorCodeFromMessage(errorMessage)
|
||||
dataToEmit.requestId = requestId
|
||||
self.events.emit(SIGNAL_COMPUTE_AIRDROP_FEE, dataToEmit)
|
||||
return
|
||||
|
||||
|
@ -981,10 +997,14 @@ QtObject:
|
|||
let (ethTotal, fiatTotal) = self.createCurrencyAmounts(totalEthVal, totalFiatVal)
|
||||
dataToEmit.totalEthFee = ethTotal
|
||||
dataToEmit.totalFiatFee = fiatTotal
|
||||
dataToEmit.requestId = requestId
|
||||
self.events.emit(SIGNAL_COMPUTE_AIRDROP_FEE, dataToEmit)
|
||||
|
||||
except Exception as e:
|
||||
error "Error computing airdrop fees", msg = e.msg
|
||||
dataToEmit.errorCode = ComputeFeeErrorCode.Other
|
||||
dataToEmit.requestId = responseJson{"requestId"}.getStr
|
||||
self.events.emit(SIGNAL_COMPUTE_AIRDROP_FEE, dataToEmit)
|
||||
|
||||
proc fetchCommunityOwners*(self: Service, communityToken: CommunityTokenDto) =
|
||||
if communityToken.tokenType != TokenType.ERC721:
|
||||
|
|
Loading…
Reference in New Issue