Skip to content

Commit

Permalink
fix: ens details view
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-ramos committed Aug 9, 2022
1 parent d1ea3e9 commit 148c677
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ proc getPreferredEnsUsername*(self: Controller): string =
proc releaseEnsEstimate*(self: Controller, ensUsername: string, address: string): int =
return self.ensService.releaseEnsEstimate(ensUsername, address)

proc release*(self: Controller, ensUsername: string, address: string, gas: string, gasPrice: string, password: string):
proc release*(self: Controller, ensUsername: string, address: string, gas: string, gasPrice: string,
maxPriorityFeePerGas: string, maxFeePerGas: string, password: string, eip1559Enabled: bool):
string =
return self.ensService.release(ensUsername, address, gas, gasPrice, password)
return self.ensService.release(ensUsername, address, gas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, password, eip1559Enabled)

proc setPreferredName*(self: Controller, preferredName: string) =
if(self.settingsService.savePreferredName(preferredName)):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ method releaseEnsEstimate*(self: AccessInterface, ensUsername: string, address:
raise newException(ValueError, "No implementation available")

method release*(self: AccessInterface, ensUsername: string, address: string, gas: string, gasPrice: string,
password: string): string {.base.} =
maxPriorityFeePerGas: string, maxFeePerGas: string, password: string, eip1559Enabled: bool): string {.base.} =
raise newException(ValueError, "No implementation available")

method connectOwnedUsername*(self: AccessInterface, ensUsername: string, isStatus: bool) {.base.} =
Expand Down
9 changes: 5 additions & 4 deletions src/app/modules/main/profile_section/ens_usernames/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ method setPubKey*(self: Module, ensUsername: string, address: string, gas: strin
method releaseEnsEstimate*(self: Module, ensUsername: string, address: string): int =
return self.controller.releaseEnsEstimate(ensUsername, address)

method release*(self: Module, ensUsername: string, address: string, gas: string, gasPrice: string, password: string): string =
let response = self.controller.release(ensUsername, address, gas, gasPrice, password)
method release*(self: Module, ensUsername: string, address: string, gas: string, gasPrice: string,
maxPriorityFeePerGas: string, maxFeePerGas: string, password: string, eip1559Enabled: bool): string =
let response = self.controller.release(ensUsername, address, gas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, password, eip1559Enabled)
if(response.len == 0):
info "expected response is empty", methodName="release"
return
Expand Down Expand Up @@ -180,15 +181,15 @@ method registerEnsGasEstimate*(self: Module, ensUsername: string, address: strin
method registerEns*(self: Module, ensUsername: string, address: string, gas: string, gasPrice: string,
maxPriorityFeePerGas: string, maxFeePerGas: string, password: string, eip1559Enabled: bool): string =
let response = self.controller.registerEns(ensUsername, address, gas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, password, eip1559Enabled)

let responseObj = response.parseJson
if (responseObj.kind != JObject):
info "expected response is not a json object", methodName="registerEns"
return

var respResult: string
if(responseObj.getProp("result", respResult) and responseObj{"success"}.getBool == true):
self.view.model().addItem(Item(ensUsername: ensUsername, isPending: true))
self.view.model().addItem(Item(ensUsername: self.formatUsername(ensUsername, true), isPending: true))
self.view.emitTransactionWasSentSignal(respResult)

return response
Expand Down
6 changes: 3 additions & 3 deletions src/app/modules/main/profile_section/ens_usernames/view.nim
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ QtObject:
proc releaseEnsEstimate*(self: View, ensUsername: string, address: string): int {.slot.} =
return self.delegate.releaseEnsEstimate(ensUsername, address)

proc release*(self: View, ensUsername: string, address: string, gas: string, gasPrice: string, password: string):
string {.slot.} =
return self.delegate.release(ensUsername, address, gas, gasPrice, password)
proc releaseEns*(self: View, ensUsername: string, address: string, gas: string, gasPrice: string,
maxPriorityFeePerGas: string, maxFeePerGas: string, password: string, eip1559Enabled: bool): string {.slot.} =
return self.delegate.release(ensUsername, address, gas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, password, eip1559Enabled)

proc connectOwnedUsername*(self: View, ensUsername: string, isStatus: bool) {.slot.} =
self.delegate.connectOwnedUsername(ensUsername, isStatus)
Expand Down
18 changes: 10 additions & 8 deletions src/app_service/service/ens/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -203,22 +203,20 @@ QtObject:
discard responseObj.getProp("pubkey", data.pubkey)
discard responseObj.getProp("isStatus", data.isStatus)
discard responseObj.getProp("expirationTime", data.expirationTime)

self.events.emit(SIGNAL_ENS_USERNAME_DETAILS_FETCHED, data)

proc fetchDetailsForEnsUsername*(self: Service, ensUsername: string) =
var isStatus = false
var username = ensUsername
if ensUsername.endsWith(ens_utils.STATUS_DOMAIN):
let onlyUsername = ensUsername.replace(ens_utils.STATUS_DOMAIN, "")
let label = fromHex(FixedBytes[32], label(onlyUsername))
let expTime = ExpirationTime(label: label)
username = ensUsername.replace(ens_utils.STATUS_DOMAIN, "")
isStatus = true

let arg = EnsUsernamDetailsTaskArg(
tptr: cast[ByteAddress](ensUsernameDetailsTask),
vptr: cast[ByteAddress](self.vptr),
slot: "onEnsUsernameDetailsFetched",
ensUsername: ensUsername,
ensUsername: username,
chainId: self.networkService.getNetworkForEns().chainId,
isStatus: isStatus
)
Expand Down Expand Up @@ -295,13 +293,17 @@ QtObject:
ensUsername: string,
address: string,
gas: string,
gasPrice: string,
password: string
gasPrice: string,
maxPriorityFeePerGas: string,
maxFeePerGas: string,
password: string,
eip1559Enabled: bool
): string =
try:
let
chainId = self.networkService.getNetworkForEns().chainId
txData = ens_utils.buildTransaction(parseAddress(address), 0.u256, gas, gasPrice)
txData = ens_utils.buildTransaction(parseAddress(address), 0.u256, gas, gasPrice,
eip1559Enabled, maxPriorityFeePerGas, maxFeePerGas)

let resp = status_ens.release(chainId, %txData, password, ensUsername)
let hash = resp.result.getStr
Expand Down
4 changes: 2 additions & 2 deletions ui/app/AppLayouts/Profile/stores/EnsUsernamesStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ QtObject {
return ensUsernamesModule.releaseEnsEstimate(ensUsername, address)
}

function releaseEns(ensUsername, address, gasLimit, gasPrice, password) {
function releaseEns(ensUsername, address, gas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, password, eip1559Enabled) {
if(!root.ensUsernamesModule)
return ""
return ensUsernamesModule.releaseEns(ensUsername, address, gasLimit, gasPrice, password)
return ensUsernamesModule.releaseEns(ensUsername, address, gas, gasPrice, maxPriorityFeePerGas, maxFeePerGas, password, eip1559Enabled)
}

function ensConnectOwnedUsername(name, isStatus) {
Expand Down
20 changes: 12 additions & 8 deletions ui/app/AppLayouts/Profile/views/EnsDetailsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Item {
Connections {
target: root.ensUsernamesStore.ensUsernamesModule
onDetailsObtained: {
if(username != ensName)
if(username != (isStatus ? ensName + ".stateofus.eth" : ensName))
return;
walletAddressLbl.subTitle = address;
keyLbl.subTitle = pubkey.substring(0, 20) + "..." + pubkey.substring(pubkey.length - 20);
Expand All @@ -61,6 +61,7 @@ Item {
releaseBtn.visible = isStatus
releaseBtn.enabled = (Date.now() / 1000) > expirationTime && expirationTime > 0 &&
root.ensUsernamesStore.preferredUsername != username
releaseBtn.enabled = true
expiration = new Date(expirationTime * 1000).getTime()
}
onLoading: {
Expand Down Expand Up @@ -107,20 +108,23 @@ Item {
contactsStore: root.contactsStore
ensUsername: root.username
chainId: root.ensUsernamesStore.getChainIdForEns()
title: qsTr("Connect username with your pubkey")
title: qsTr("Release your username")
onClosed: {
destroy()
}
estimateGasFunction: function(selectedAccount) {
if (username === "" || !selectedAccount) return 100000;
return root.ensUsernamesStore.releaseEnsEstimate(Utils.removeStatusEns(username), selectedAccount.address)
return root.ensUsernamesStore.releaseEnsEstimate(username, selectedAccount.address)
}
onSendTransaction: function(selectedAddress, gasLimit, gasPrice, password) {
onSendTransaction: function(userAddress, gasLimit, gasPrice, tipLimit, overallLimit, password, eip1559Enabled){
return root.ensUsernamesStore.releaseEns(username,
selectedAddress,
gasLimit,
gasPrice,
password)
userAddress,
gasLimit,
gasPrice,
tipLimit,
overallLimit,
password,
eip1559Enabled)
}
onSuccess: function(){
usernameReleased(username);
Expand Down
21 changes: 11 additions & 10 deletions ui/imports/shared/status/StatusETHTransactionModal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,22 @@ ModalPopup {
title: qsTr("Contract interaction")

property var estimateGasFunction: (function(userAddress) { return 0; })
property var onSendTransaction: (function(userAddress, gasLimit, gasPrice, password){ return ""; })
property var onSendTransaction: (function(userAddress, gasLimit, gasPrice, tipLimit, overallLimit, password, eip1559Enabled){ return ""; })
property var onSuccess: (function(){})

height: 540

function sendTransaction() {
try {
let responseStr = root.ensUsernamesStore.setPubKey(root.ensUsername,
selectFromAccount.selectedAccount.address,
gasSelector.selectedGasLimit,
gasSelector.suggestedFees.eip1559Enabled ? "" : gasSelector.selectedGasPrice,
gasSelector.selectedTipLimit,
gasSelector.selectedOverallLimit,
transactionSigner.enteredPassword,
gasSelector.suggestedFees.eip1559Enabled)
let responseStr = onSendTransaction(
selectFromAccount.selectedAccount.address,
gasSelector.selectedGasLimit,
gasSelector.suggestedFees.eip1559Enabled ? "" : gasSelector.selectedGasPrice,
gasSelector.selectedTipLimit,
gasSelector.selectedOverallLimit,
transactionSigner.enteredPassword,
gasSelector.suggestedFees.eip1559Enabled);

let response = JSON.parse(responseStr)

if (!response.success) {
Expand Down

0 comments on commit 148c677

Please sign in to comment.