fix(wallet): checking for an ens name now checks all users' addresses instead the default one only
This commit is contained in:
parent
9ca7167f71
commit
1dd973340a
|
@ -8,7 +8,7 @@ type
|
|||
chainId*: int
|
||||
isStatus*: bool
|
||||
myPublicKey*: string
|
||||
myWalletAddress*: string
|
||||
myAddresses*: seq[string]
|
||||
|
||||
proc checkEnsAvailabilityTask(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[CheckEnsAvailabilityTaskArg](argEncoded)
|
||||
|
@ -21,12 +21,13 @@ proc checkEnsAvailabilityTask(argEncoded: string) {.gcsafe, nimcall.} =
|
|||
availability = ENS_AVAILABILITY_STATUS_AVAILABLE
|
||||
else:
|
||||
let ensPubkey = ens_utils.publicKeyOf(arg.chainId, arg.ensUsername)
|
||||
let ownerIsAmongMyAddresses = arg.myAddresses.filter(address => cmpIgnoreCase(address, ownerAddr) == 0).len == 1
|
||||
if ownerAddr != "":
|
||||
if ensPubkey == "" and ownerAddr == arg.myWalletAddress:
|
||||
if ensPubkey == "" and ownerIsAmongMyAddresses:
|
||||
availability = ENS_AVAILABILITY_STATUS_OWNED # "Continuing will connect this username with your chat key."
|
||||
elif ensPubkey == arg.myPublicKey:
|
||||
availability = ENS_AVAILABILITY_STATUS_CONNECTED
|
||||
elif ownerAddr == arg.myWalletAddress:
|
||||
elif ownerIsAmongMyAddresses:
|
||||
availability = ENS_AVAILABILITY_STATUS_CONNECTED_DIFFERENT_KEY # "Continuing will require a transaction to connect the username with your current chat key.",
|
||||
else:
|
||||
availability = ENS_AVAILABILITY_STATUS_TAKEN
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import NimQml, Tables, json, sequtils, strutils, stint, chronicles
|
||||
import NimQml, Tables, json, sequtils, strutils, stint, sugar, chronicles
|
||||
import web3/ethtypes, stew/byteutils, nimcrypto, json_serialization
|
||||
|
||||
import app/core/eventemitter
|
||||
|
@ -132,6 +132,10 @@ QtObject:
|
|||
return
|
||||
|
||||
let key = makeKey(ensDto.username, chainId)
|
||||
if not self.pendingEnsUsernames.hasKey(key):
|
||||
error "Error updating ens username status", message = "unknown key: " & key
|
||||
return
|
||||
|
||||
if status == TxStatusSuccess:
|
||||
self.pendingEnsUsernames[key].txStatus = TxStatusSuccess
|
||||
let data = EnsTransactionArgs(txHash: transactionHash, ensUsername: ensDto.username, transactionType: $ensDto.txType)
|
||||
|
@ -293,7 +297,7 @@ QtObject:
|
|||
chainId: self.getChainId(),
|
||||
isStatus: isStatus,
|
||||
myPublicKey: self.settingsService.getPublicKey(),
|
||||
myWalletAddress: self.walletAccountService.getWalletAccount(0).address
|
||||
myAddresses: self.walletAccountService.getWalletAccounts().map(a => a.address)
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
|
||||
|
@ -340,7 +344,13 @@ QtObject:
|
|||
result = ("0x" & pubkey[4..67], "0x" & pubkey[68..131])
|
||||
|
||||
proc getEnsRegisteredAddress*(self: Service): string =
|
||||
return status_ens.getRegistrarAddress(self.getChainId()).result.getStr
|
||||
try:
|
||||
let res = status_ens.getRegistrarAddress(self.getChainId())
|
||||
if res.error != nil:
|
||||
raise newException(ValueError, res.error.message)
|
||||
return res.result.getStr
|
||||
except Exception as e:
|
||||
error "Error getting ENS registered address", err=e.msg
|
||||
|
||||
proc resourceUrl*(self: Service, username: string): (string, string, string) =
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue