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
|
chainId*: int
|
||||||
isStatus*: bool
|
isStatus*: bool
|
||||||
myPublicKey*: string
|
myPublicKey*: string
|
||||||
myWalletAddress*: string
|
myAddresses*: seq[string]
|
||||||
|
|
||||||
proc checkEnsAvailabilityTask(argEncoded: string) {.gcsafe, nimcall.} =
|
proc checkEnsAvailabilityTask(argEncoded: string) {.gcsafe, nimcall.} =
|
||||||
let arg = decode[CheckEnsAvailabilityTaskArg](argEncoded)
|
let arg = decode[CheckEnsAvailabilityTaskArg](argEncoded)
|
||||||
|
@ -21,12 +21,13 @@ proc checkEnsAvailabilityTask(argEncoded: string) {.gcsafe, nimcall.} =
|
||||||
availability = ENS_AVAILABILITY_STATUS_AVAILABLE
|
availability = ENS_AVAILABILITY_STATUS_AVAILABLE
|
||||||
else:
|
else:
|
||||||
let ensPubkey = ens_utils.publicKeyOf(arg.chainId, arg.ensUsername)
|
let ensPubkey = ens_utils.publicKeyOf(arg.chainId, arg.ensUsername)
|
||||||
|
let ownerIsAmongMyAddresses = arg.myAddresses.filter(address => cmpIgnoreCase(address, ownerAddr) == 0).len == 1
|
||||||
if ownerAddr != "":
|
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."
|
availability = ENS_AVAILABILITY_STATUS_OWNED # "Continuing will connect this username with your chat key."
|
||||||
elif ensPubkey == arg.myPublicKey:
|
elif ensPubkey == arg.myPublicKey:
|
||||||
availability = ENS_AVAILABILITY_STATUS_CONNECTED
|
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.",
|
availability = ENS_AVAILABILITY_STATUS_CONNECTED_DIFFERENT_KEY # "Continuing will require a transaction to connect the username with your current chat key.",
|
||||||
else:
|
else:
|
||||||
availability = ENS_AVAILABILITY_STATUS_TAKEN
|
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 web3/ethtypes, stew/byteutils, nimcrypto, json_serialization
|
||||||
|
|
||||||
import app/core/eventemitter
|
import app/core/eventemitter
|
||||||
|
@ -132,6 +132,10 @@ QtObject:
|
||||||
return
|
return
|
||||||
|
|
||||||
let key = makeKey(ensDto.username, chainId)
|
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:
|
if status == TxStatusSuccess:
|
||||||
self.pendingEnsUsernames[key].txStatus = TxStatusSuccess
|
self.pendingEnsUsernames[key].txStatus = TxStatusSuccess
|
||||||
let data = EnsTransactionArgs(txHash: transactionHash, ensUsername: ensDto.username, transactionType: $ensDto.txType)
|
let data = EnsTransactionArgs(txHash: transactionHash, ensUsername: ensDto.username, transactionType: $ensDto.txType)
|
||||||
|
@ -293,7 +297,7 @@ QtObject:
|
||||||
chainId: self.getChainId(),
|
chainId: self.getChainId(),
|
||||||
isStatus: isStatus,
|
isStatus: isStatus,
|
||||||
myPublicKey: self.settingsService.getPublicKey(),
|
myPublicKey: self.settingsService.getPublicKey(),
|
||||||
myWalletAddress: self.walletAccountService.getWalletAccount(0).address
|
myAddresses: self.walletAccountService.getWalletAccounts().map(a => a.address)
|
||||||
)
|
)
|
||||||
self.threadpool.start(arg)
|
self.threadpool.start(arg)
|
||||||
|
|
||||||
|
@ -340,7 +344,13 @@ QtObject:
|
||||||
result = ("0x" & pubkey[4..67], "0x" & pubkey[68..131])
|
result = ("0x" & pubkey[4..67], "0x" & pubkey[68..131])
|
||||||
|
|
||||||
proc getEnsRegisteredAddress*(self: Service): string =
|
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) =
|
proc resourceUrl*(self: Service, username: string): (string, string, string) =
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue