mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-17 17:19:02 +00:00
fix(WalletConnect): Fixing crashes
1. In some cases it was crashing on JSON.stringify for the model item 2. Avoid storing model objects 3. Fixing storybook
This commit is contained in:
parent
1601da58ff
commit
c769e42212
@ -216,7 +216,7 @@ Item {
|
|||||||
if (d.activeTestCase < d.openPairTestCase)
|
if (d.activeTestCase < d.openPairTestCase)
|
||||||
return
|
return
|
||||||
|
|
||||||
let buttons = InspectionUtils.findVisualsByTypeName(dappsWorkflow.popup, "StatusButton")
|
let buttons = StoryBook.InspectionUtils.findVisualsByTypeName(dappsWorkflow.popup, "StatusButton")
|
||||||
if (buttons.length === 1) {
|
if (buttons.length === 1) {
|
||||||
buttons[0].clicked()
|
buttons[0].clicked()
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ Item {
|
|||||||
return
|
return
|
||||||
|
|
||||||
if (pairUriInput.text.length > 0) {
|
if (pairUriInput.text.length > 0) {
|
||||||
let items = InspectionUtils.findVisualsByTypeName(dappsWorkflow, "StatusBaseInput")
|
let items = StoryBook.InspectionUtils.findVisualsByTypeName(dappsWorkflow, "StatusBaseInput")
|
||||||
if (items.length === 1) {
|
if (items.length === 1) {
|
||||||
items[0].text = pairUriInput.text
|
items[0].text = pairUriInput.text
|
||||||
|
|
||||||
@ -241,9 +241,9 @@ Item {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let modals = InspectionUtils.findVisualsByTypeName(dappsWorkflow, "PairWCModal")
|
let modals = StoryBook.InspectionUtils.findVisualsByTypeName(dappsWorkflow, "PairWCModal")
|
||||||
if (modals.length === 1) {
|
if (modals.length === 1) {
|
||||||
let buttons = InspectionUtils.findVisualsByTypeName(modals[0].footer, "StatusButton")
|
let buttons = StoryBook.InspectionUtils.findVisualsByTypeName(modals[0].footer, "StatusButton")
|
||||||
if (buttons.length === 1 && buttons[0].enabled && walletConnectService.wcSDK.sdkReady) {
|
if (buttons.length === 1 && buttons[0].enabled && walletConnectService.wcSDK.sdkReady) {
|
||||||
d.activeTestCase = d.noTestCase
|
d.activeTestCase = d.noTestCase
|
||||||
buttons[0].clicked()
|
buttons[0].clicked()
|
||||||
@ -307,6 +307,7 @@ Item {
|
|||||||
signal dappsListReceived(string dappsJson)
|
signal dappsListReceived(string dappsJson)
|
||||||
signal userAuthenticated(string topic, string id, string password, string pin)
|
signal userAuthenticated(string topic, string id, string password, string pin)
|
||||||
signal userAuthenticationFailed(string topic, string id)
|
signal userAuthenticationFailed(string topic, string id)
|
||||||
|
signal signingResult(string topic, string id, string data)
|
||||||
|
|
||||||
function addWalletConnectSession(sessionJson) {
|
function addWalletConnectSession(sessionJson) {
|
||||||
console.info("Persist Session", sessionJson)
|
console.info("Persist Session", sessionJson)
|
||||||
|
@ -528,7 +528,7 @@ Item {
|
|||||||
const store = service.store
|
const store = service.store
|
||||||
|
|
||||||
const testAddress = "0x3a"
|
const testAddress = "0x3a"
|
||||||
const chainId = 2
|
const chainId = "2"
|
||||||
const method = "personal_sign"
|
const method = "personal_sign"
|
||||||
const message = "hello world"
|
const message = "hello world"
|
||||||
const params = [`"${DAppsHelpers.strToHex(message)}"`, `"${testAddress}"`]
|
const params = [`"${DAppsHelpers.strToHex(message)}"`, `"${testAddress}"`]
|
||||||
@ -550,10 +550,10 @@ Item {
|
|||||||
compare(request.dappName, Testing.dappName, "expected dappName to be set")
|
compare(request.dappName, Testing.dappName, "expected dappName to be set")
|
||||||
compare(request.dappUrl, Testing.dappUrl, "expected dappUrl to be set")
|
compare(request.dappUrl, Testing.dappUrl, "expected dappUrl to be set")
|
||||||
compare(request.dappIcon, Testing.dappFirstIcon, "expected dappIcon to be set")
|
compare(request.dappIcon, Testing.dappFirstIcon, "expected dappIcon to be set")
|
||||||
verify(!!request.account, "expected account to be set")
|
verify(!!request.accountAddress, "expected account to be set")
|
||||||
compare(request.account.address, testAddress, "expected look up of the right account")
|
compare(request.accountAddress, testAddress, "expected look up of the right account")
|
||||||
verify(!!request.network, "expected network to be set")
|
verify(!!request.chainId, "expected network to be set")
|
||||||
compare(request.network.chainId, chainId, "expected look up of the right network")
|
compare(request.chainId, chainId, "expected look up of the right network")
|
||||||
verify(!!request.data, "expected data to be set")
|
verify(!!request.data, "expected data to be set")
|
||||||
compare(request.data.message, message, "expected message to be set")
|
compare(request.data.message, message, "expected message to be set")
|
||||||
}
|
}
|
||||||
@ -909,8 +909,8 @@ Item {
|
|||||||
topic,
|
topic,
|
||||||
id: requestEvent.id,
|
id: requestEvent.id,
|
||||||
method: Constants.personal_sign,
|
method: Constants.personal_sign,
|
||||||
account,
|
accountAddress: account.address,
|
||||||
network,
|
chainId: network.chainId,
|
||||||
data: message,
|
data: message,
|
||||||
preparedData: message
|
preparedData: message
|
||||||
})
|
})
|
||||||
|
@ -157,23 +157,35 @@ DappsComboBox {
|
|||||||
sourceComponent: DAppSignRequestModal {
|
sourceComponent: DAppSignRequestModal {
|
||||||
id: dappRequestModal
|
id: dappRequestModal
|
||||||
objectName: "dappsRequestModal"
|
objectName: "dappsRequestModal"
|
||||||
loginType: request.account.migragedToKeycard ? Constants.LoginType.Keycard : root.loginType
|
|
||||||
formatBigNumber: (number, symbol, noSymbolOption) => root.wcService.walletRootStore.currencyStore.formatBigNumber(number, symbol, noSymbolOption)
|
|
||||||
visible: true
|
|
||||||
|
|
||||||
property var feesInfo: null
|
property var feesInfo: null
|
||||||
|
readonly property var account: accountEntry.available ? accountEntry.item : {
|
||||||
|
name: "",
|
||||||
|
address: "",
|
||||||
|
emoji: "",
|
||||||
|
colorId: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property var network: networkEntry.available ? networkEntry.item : {
|
||||||
|
chainName: "",
|
||||||
|
iconUrl: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
loginType: account.migragedToKeycard ? Constants.LoginType.Keycard : root.loginType
|
||||||
|
formatBigNumber: (number, symbol, noSymbolOption) => root.wcService.walletRootStore.currencyStore.formatBigNumber(number, symbol, noSymbolOption)
|
||||||
|
visible: true
|
||||||
|
|
||||||
dappUrl: request.dappUrl
|
dappUrl: request.dappUrl
|
||||||
dappIcon: request.dappIcon
|
dappIcon: request.dappIcon
|
||||||
dappName: request.dappName
|
dappName: request.dappName
|
||||||
|
|
||||||
accountColor: Utils.getColorForId(request.account.colorId)
|
accountColor: Utils.getColorForId(account.colorId)
|
||||||
accountName: request.account.name
|
accountName: account.name
|
||||||
accountAddress: request.account.address
|
accountAddress: account.address
|
||||||
accountEmoji: request.account.emoji
|
accountEmoji: account.emoji
|
||||||
|
|
||||||
networkName: request.network.chainName
|
networkName: network.chainName
|
||||||
networkIconPath: Style.svg(request.network.iconUrl)
|
networkIconPath: Style.svg(network.iconUrl)
|
||||||
|
|
||||||
fiatFees: request.maxFeesText
|
fiatFees: request.maxFeesText
|
||||||
cryptoFees: request.maxFeesEthText
|
cryptoFees: request.maxFeesEthText
|
||||||
@ -237,6 +249,20 @@ DappsComboBox {
|
|||||||
dappRequestModal.estimatedTime = WalletUtils.getLabelForEstimatedTxTime(estimatedTimeEnum)
|
dappRequestModal.estimatedTime = WalletUtils.getLabelForEstimatedTxTime(estimatedTimeEnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModelEntry {
|
||||||
|
id: accountEntry
|
||||||
|
sourceModel: root.wcService.validAccounts
|
||||||
|
key: "address"
|
||||||
|
value: request.accountAddress
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelEntry {
|
||||||
|
id: networkEntry
|
||||||
|
sourceModel: root.wcService.flatNetworks
|
||||||
|
key: "chainId"
|
||||||
|
value: request.chainId
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ SQUtils.QObject {
|
|||||||
|
|
||||||
/// Beware, it will fail if called multiple times before getting an answer
|
/// Beware, it will fail if called multiple times before getting an answer
|
||||||
function authenticate(request, payload) {
|
function authenticate(request, payload) {
|
||||||
return store.authenticateUser(request.topic, request.id, request.account.address, payload)
|
return store.authenticateUser(request.topic, request.id, request.accountAddress, payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
signal sessionRequest(SessionRequestResolved request)
|
signal sessionRequest(SessionRequestResolved request)
|
||||||
@ -150,20 +150,20 @@ SQUtils.QObject {
|
|||||||
// }
|
// }
|
||||||
function resolveAsync(event) {
|
function resolveAsync(event) {
|
||||||
const method = event.params.request.method
|
const method = event.params.request.method
|
||||||
const res = lookupAccountFromEvent(event, method)
|
const { accountAddress, success } = lookupAccountFromEvent(event, method)
|
||||||
if(!res.success) {
|
if(!success) {
|
||||||
console.info("Error finding account for event", JSON.stringify(event))
|
console.info("Error finding accountAddress for event", JSON.stringify(event))
|
||||||
return { obj: null, code: resolveAsyncResult.error }
|
return { obj: null, code: resolveAsyncResult.error }
|
||||||
}
|
}
|
||||||
if (!res.account) {
|
|
||||||
console.info("Ignoring request for an account not in the current profile.")
|
if (!accountAddress) {
|
||||||
|
console.info("Account not found for event", JSON.stringify(event))
|
||||||
return { obj: null, code: resolveAsyncResult.ignored }
|
return { obj: null, code: resolveAsyncResult.ignored }
|
||||||
}
|
}
|
||||||
const account = res.account
|
|
||||||
|
|
||||||
let network = lookupNetworkFromEvent(event, method)
|
let chainId = lookupNetworkFromEvent(event, method)
|
||||||
if(!network) {
|
if(!chainId) {
|
||||||
console.error("Error finding network for event", JSON.stringify(event))
|
console.error("Error finding chainId for event", JSON.stringify(event))
|
||||||
return { obj: null, code: resolveAsyncResult.error }
|
return { obj: null, code: resolveAsyncResult.error }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,8 +181,8 @@ SQUtils.QObject {
|
|||||||
topic: event.topic,
|
topic: event.topic,
|
||||||
id: event.id,
|
id: event.id,
|
||||||
method,
|
method,
|
||||||
account,
|
accountAddress,
|
||||||
network,
|
chainId,
|
||||||
data,
|
data,
|
||||||
preparedData: interpreted.preparedData,
|
preparedData: interpreted.preparedData,
|
||||||
maxFeesText: "?",
|
maxFeesText: "?",
|
||||||
@ -212,19 +212,20 @@ SQUtils.QObject {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let estimatedTimeEnum = getEstimatedTimeInterval(data, method, obj.network.chainId)
|
|
||||||
|
let estimatedTimeEnum = getEstimatedTimeInterval(data, method, obj.chainId)
|
||||||
root.estimatedTimeUpdated(estimatedTimeEnum)
|
root.estimatedTimeUpdated(estimatedTimeEnum)
|
||||||
|
|
||||||
const mainNet = lookupMainnetNetwork()
|
const mainNet = lookupMainnetNetwork()
|
||||||
let mainChainId = obj.network.chainId
|
let mainChainId = obj.chainId
|
||||||
if (!!mainNet) {
|
if (!!mainNet) {
|
||||||
mainChainId = mainNet.chainId
|
mainChainId = mainNet.chainId
|
||||||
} else {
|
} else {
|
||||||
console.error("Error finding mainnet network")
|
console.error("Error finding mainnet network")
|
||||||
}
|
}
|
||||||
let st = getEstimatedFeesStatus(data, method, obj.network.chainId, mainChainId)
|
let st = getEstimatedFeesStatus(data, method, obj.chainId, mainChainId)
|
||||||
|
|
||||||
let fundsStatus = checkFundsStatus(st.feesInfo.maxFees, st.feesInfo.l1GasFee, account.address, obj.network.chainId, mainNet.chainId, interpreted.value)
|
let fundsStatus = checkFundsStatus(st.feesInfo.maxFees, st.feesInfo.l1GasFee, obj.accountAddress, obj.chainId, mainNet.chainId, interpreted.value)
|
||||||
|
|
||||||
root.maxFeesUpdated(st.fiatMaxFees, st.maxFeesEth, fundsStatus.haveEnoughFunds,
|
root.maxFeesUpdated(st.fiatMaxFees, st.maxFeesEth, fundsStatus.haveEnoughFunds,
|
||||||
fundsStatus.haveEnoughForFees, st.symbol, st.feesInfo)
|
fundsStatus.haveEnoughForFees, st.symbol, st.feesInfo)
|
||||||
@ -237,7 +238,7 @@ SQUtils.QObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// returns {
|
/// returns {
|
||||||
/// account
|
/// accountAddress
|
||||||
/// success
|
/// success
|
||||||
/// }
|
/// }
|
||||||
/// if account is null and success is true it means that the account was not found
|
/// if account is null and success is true it means that the account was not found
|
||||||
@ -245,47 +246,39 @@ SQUtils.QObject {
|
|||||||
let address = ""
|
let address = ""
|
||||||
if (method === SessionRequest.methods.personalSign.name) {
|
if (method === SessionRequest.methods.personalSign.name) {
|
||||||
if (event.params.request.params.length < 2) {
|
if (event.params.request.params.length < 2) {
|
||||||
return { account: null, success: false }
|
return { accountAddress: "", success: false }
|
||||||
}
|
}
|
||||||
address = event.params.request.params[1]
|
address = event.params.request.params[1]
|
||||||
} else if (method === SessionRequest.methods.sign.name) {
|
} else if (method === SessionRequest.methods.sign.name) {
|
||||||
if (event.params.request.params.length === 1) {
|
if (event.params.request.params.length === 1) {
|
||||||
return { account: null, success: false }
|
return { accountAddress: "", success: false }
|
||||||
}
|
}
|
||||||
address = event.params.request.params[0]
|
address = event.params.request.params[0]
|
||||||
} else if(method === SessionRequest.methods.signTypedData_v4.name ||
|
} else if(method === SessionRequest.methods.signTypedData_v4.name ||
|
||||||
method === SessionRequest.methods.signTypedData.name)
|
method === SessionRequest.methods.signTypedData.name)
|
||||||
{
|
{
|
||||||
if (event.params.request.params.length < 2) {
|
if (event.params.request.params.length < 2) {
|
||||||
return { account: null, success: false }
|
return { accountAddress: "", success: false }
|
||||||
}
|
}
|
||||||
address = event.params.request.params[0]
|
address = event.params.request.params[0]
|
||||||
} else if (d.isTransactionMethod(method)) {
|
} else if (d.isTransactionMethod(method)) {
|
||||||
if (event.params.request.params.length == 0) {
|
if (event.params.request.params.length == 0) {
|
||||||
return { account: null, success: false }
|
return { accountAddress: "", success: false }
|
||||||
}
|
}
|
||||||
address = event.params.request.params[0].from
|
address = event.params.request.params[0].from
|
||||||
} else {
|
} else {
|
||||||
console.error("Unsupported method to lookup account: ", method)
|
console.error("Unsupported method to lookup account: ", method)
|
||||||
return { account: null, success: false }
|
return { accountAddress: "", success: false }
|
||||||
}
|
}
|
||||||
const account = SQUtils.ModelUtils.getFirstModelEntryIf(root.accountsModel, (account) => {
|
const account = SQUtils.ModelUtils.getFirstModelEntryIf(root.accountsModel, (account) => {
|
||||||
return account.address.toLowerCase() === address.toLowerCase();
|
return account.address.toLowerCase() === address.toLowerCase();
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return { account: null, success: true }
|
return { accountAddress: "", success: true }
|
||||||
}
|
}
|
||||||
|
|
||||||
// deep copy to avoid operations on the original object
|
return { accountAddress: account.address, success: true }
|
||||||
try {
|
|
||||||
const accountCopy = JSON.parse(JSON.stringify(account))
|
|
||||||
return { account: accountCopy, success: true }
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.error("Error parsing account", e)
|
|
||||||
return { account: null, success: false }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns null if the network is not found
|
/// Returns null if the network is not found
|
||||||
@ -300,13 +293,7 @@ SQUtils.QObject {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
// deep copy to avoid operations on the original object
|
return network.chainId
|
||||||
try {
|
|
||||||
return JSON.parse(JSON.stringify(network))
|
|
||||||
} catch (e) {
|
|
||||||
console.error("Error parsing network", network)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns null if the network is not found
|
/// Returns null if the network is not found
|
||||||
@ -384,14 +371,14 @@ SQUtils.QObject {
|
|||||||
if (request.method === SessionRequest.methods.sign.name) {
|
if (request.method === SessionRequest.methods.sign.name) {
|
||||||
store.signMessageUnsafe(request.topic,
|
store.signMessageUnsafe(request.topic,
|
||||||
request.id,
|
request.id,
|
||||||
request.account.address,
|
request.accountAddress,
|
||||||
SessionRequest.methods.personalSign.getMessageFromData(request.data),
|
SessionRequest.methods.personalSign.getMessageFromData(request.data),
|
||||||
password,
|
password,
|
||||||
pin)
|
pin)
|
||||||
} else if (request.method === SessionRequest.methods.personalSign.name) {
|
} else if (request.method === SessionRequest.methods.personalSign.name) {
|
||||||
store.signMessage(request.topic,
|
store.signMessage(request.topic,
|
||||||
request.id,
|
request.id,
|
||||||
request.account.address,
|
request.accountAddress,
|
||||||
SessionRequest.methods.personalSign.getMessageFromData(request.data),
|
SessionRequest.methods.personalSign.getMessageFromData(request.data),
|
||||||
password,
|
password,
|
||||||
pin)
|
pin)
|
||||||
@ -401,9 +388,9 @@ SQUtils.QObject {
|
|||||||
let legacy = request.method === SessionRequest.methods.signTypedData.name
|
let legacy = request.method === SessionRequest.methods.signTypedData.name
|
||||||
store.safeSignTypedData(request.topic,
|
store.safeSignTypedData(request.topic,
|
||||||
request.id,
|
request.id,
|
||||||
request.account.address,
|
request.accountAddress,
|
||||||
SessionRequest.methods.signTypedData.getMessageFromData(request.data),
|
SessionRequest.methods.signTypedData.getMessageFromData(request.data),
|
||||||
request.network.chainId,
|
request.chainId,
|
||||||
legacy,
|
legacy,
|
||||||
password,
|
password,
|
||||||
pin)
|
pin)
|
||||||
@ -430,8 +417,8 @@ SQUtils.QObject {
|
|||||||
if (request.method === SessionRequest.methods.signTransaction.name) {
|
if (request.method === SessionRequest.methods.signTransaction.name) {
|
||||||
store.signTransaction(request.topic,
|
store.signTransaction(request.topic,
|
||||||
request.id,
|
request.id,
|
||||||
request.account.address,
|
request.accountAddress,
|
||||||
request.network.chainId,
|
request.chainId,
|
||||||
txObj,
|
txObj,
|
||||||
password,
|
password,
|
||||||
pin)
|
pin)
|
||||||
@ -439,8 +426,8 @@ SQUtils.QObject {
|
|||||||
store.sendTransaction(
|
store.sendTransaction(
|
||||||
request.topic,
|
request.topic,
|
||||||
request.id,
|
request.id,
|
||||||
request.account.address,
|
request.accountAddress,
|
||||||
request.network.chainId,
|
request.chainId,
|
||||||
txObj,
|
txObj,
|
||||||
password,
|
password,
|
||||||
pin)
|
pin)
|
||||||
@ -539,7 +526,7 @@ SQUtils.QObject {
|
|||||||
function getBalanceInEth(balances, address, chainId) {
|
function getBalanceInEth(balances, address, chainId) {
|
||||||
const BigOps = SQUtils.AmountsArithmetic
|
const BigOps = SQUtils.AmountsArithmetic
|
||||||
let accEth = SQUtils.ModelUtils.getFirstModelEntryIf(balances, (balance) => {
|
let accEth = SQUtils.ModelUtils.getFirstModelEntryIf(balances, (balance) => {
|
||||||
return balance.account.toLowerCase() === address.toLowerCase() && balance.chainId === chainId
|
return balance.account.toLowerCase() === address.toLowerCase() && balance.chainId == chainId
|
||||||
})
|
})
|
||||||
if (!accEth) {
|
if (!accEth) {
|
||||||
console.error("Error balance lookup for account ", address, " on chain ", chainId)
|
console.error("Error balance lookup for account ", address, " on chain ", chainId)
|
||||||
|
@ -64,13 +64,13 @@ WalletConnectSDKBase {
|
|||||||
|
|
||||||
function resolveAsync(event) {
|
function resolveAsync(event) {
|
||||||
let method = event.params.request.method
|
let method = event.params.request.method
|
||||||
let account = lookupAccountFromEvent(event, method)
|
let accountAddress = lookupAccountFromEvent(event, method)
|
||||||
if(!account) {
|
if(!accountAddress) {
|
||||||
console.error("Error finding account for event", JSON.stringify(event))
|
console.error("Error finding accountAddress for event", JSON.stringify(event))
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
let network = lookupNetworkFromEvent(event, method)
|
let chainId = lookupNetworkFromEvent(event, method)
|
||||||
if(!network) {
|
if(!chainId) {
|
||||||
console.error("Error finding network for event", JSON.stringify(event))
|
console.error("Error finding network for event", JSON.stringify(event))
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -85,8 +85,8 @@ WalletConnectSDKBase {
|
|||||||
topic: event.topic,
|
topic: event.topic,
|
||||||
id: event.id,
|
id: event.id,
|
||||||
method,
|
method,
|
||||||
account,
|
accountAddress,
|
||||||
network,
|
chainId,
|
||||||
data,
|
data,
|
||||||
maxFeesText: "?",
|
maxFeesText: "?",
|
||||||
maxFeesEthText: "?",
|
maxFeesEthText: "?",
|
||||||
@ -126,25 +126,25 @@ WalletConnectSDKBase {
|
|||||||
var address = ""
|
var address = ""
|
||||||
if (method === SessionRequest.methods.personalSign.name) {
|
if (method === SessionRequest.methods.personalSign.name) {
|
||||||
if (event.params.request.params.length < 2) {
|
if (event.params.request.params.length < 2) {
|
||||||
return null
|
return address
|
||||||
}
|
}
|
||||||
address = event.params.request.params[0]
|
address = event.params.request.params[0]
|
||||||
} else if (method === SessionRequest.methods.sign.name) {
|
} else if (method === SessionRequest.methods.sign.name) {
|
||||||
if (event.params.request.params.length === 1) {
|
if (event.params.request.params.length === 1) {
|
||||||
return null
|
return address
|
||||||
}
|
}
|
||||||
address = event.params.request.params[0]
|
address = event.params.request.params[0]
|
||||||
} else if(method === SessionRequest.methods.signTypedData_v4.name ||
|
} else if(method === SessionRequest.methods.signTypedData_v4.name ||
|
||||||
method === SessionRequest.methods.signTypedData.name)
|
method === SessionRequest.methods.signTypedData.name)
|
||||||
{
|
{
|
||||||
if (event.params.request.params.length < 2) {
|
if (event.params.request.params.length < 2) {
|
||||||
return null
|
return address
|
||||||
}
|
}
|
||||||
address = event.params.request.params[0]
|
address = event.params.request.params[0]
|
||||||
} else if (method === SessionRequest.methods.signTransaction.name
|
} else if (method === SessionRequest.methods.signTransaction.name
|
||||||
|| method === SessionRequest.methods.sendTransaction.name) {
|
|| method === SessionRequest.methods.sendTransaction.name) {
|
||||||
if (event.params.request.params.length == 0) {
|
if (event.params.request.params.length == 0) {
|
||||||
return null
|
return address
|
||||||
}
|
}
|
||||||
address = event.params.request.params[0]
|
address = event.params.request.params[0]
|
||||||
}
|
}
|
||||||
@ -153,17 +153,10 @@ WalletConnectSDKBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!account) {
|
if (!account) {
|
||||||
return null
|
return address
|
||||||
}
|
}
|
||||||
|
|
||||||
// deep copy to avoid operations on the original object
|
return account.address
|
||||||
try {
|
|
||||||
return JSON.parse(JSON.stringify(account))
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.error("Error parsing account", e.message)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns null if the network is not found
|
/// Returns null if the network is not found
|
||||||
@ -172,20 +165,13 @@ WalletConnectSDKBase {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const chainId = DAppsHelpers.chainIdFromEip155(event.params.chainId)
|
const chainId = DAppsHelpers.chainIdFromEip155(event.params.chainId)
|
||||||
const network = SQUtils.ModelUtils.getByKey(networksModule.flatNetworks, "chainId", chainId)
|
const network = SQUtils.ModelUtils.getByKey(root.walletStore.filteredFlatModel, "chainId", chainId)
|
||||||
|
|
||||||
if (!network) {
|
if (!network) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
// deep copy to avoid operations on the original object
|
return network.chainId
|
||||||
try {
|
|
||||||
return JSON.parse(JSON.stringify(network))
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.error("Error parsing network", e)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractMethodData(event, method) {
|
function extractMethodData(event, method) {
|
||||||
@ -248,14 +234,14 @@ WalletConnectSDKBase {
|
|||||||
if (request.method === SessionRequest.methods.sign.name) {
|
if (request.method === SessionRequest.methods.sign.name) {
|
||||||
store.signMessageUnsafe(request.topic,
|
store.signMessageUnsafe(request.topic,
|
||||||
request.id,
|
request.id,
|
||||||
request.account.address,
|
request.accountAddress,
|
||||||
SessionRequest.methods.personalSign.getMessageFromData(request.data),
|
SessionRequest.methods.personalSign.getMessageFromData(request.data),
|
||||||
password,
|
password,
|
||||||
pin)
|
pin)
|
||||||
} else if (request.method === SessionRequest.methods.personalSign.name) {
|
} else if (request.method === SessionRequest.methods.personalSign.name) {
|
||||||
store.signMessage(request.topic,
|
store.signMessage(request.topic,
|
||||||
request.id,
|
request.id,
|
||||||
request.account.address,
|
request.accountAddress,
|
||||||
SessionRequest.methods.personalSign.getMessageFromData(request.data),
|
SessionRequest.methods.personalSign.getMessageFromData(request.data),
|
||||||
password,
|
password,
|
||||||
pin)
|
pin)
|
||||||
@ -265,9 +251,9 @@ WalletConnectSDKBase {
|
|||||||
let legacy = request.method === SessionRequest.methods.signTypedData.name
|
let legacy = request.method === SessionRequest.methods.signTypedData.name
|
||||||
store.safeSignTypedData(request.topic,
|
store.safeSignTypedData(request.topic,
|
||||||
request.id,
|
request.id,
|
||||||
request.account.address,
|
request.accountAddress,
|
||||||
SessionRequest.methods.signTypedData.getMessageFromData(request.data),
|
SessionRequest.methods.signTypedData.getMessageFromData(request.data),
|
||||||
request.network.chainId,
|
request.chainId,
|
||||||
legacy,
|
legacy,
|
||||||
password,
|
password,
|
||||||
pin)
|
pin)
|
||||||
@ -275,8 +261,8 @@ WalletConnectSDKBase {
|
|||||||
let txObj = SessionRequest.methods.signTransaction.getTxObjFromData(request.data)
|
let txObj = SessionRequest.methods.signTransaction.getTxObjFromData(request.data)
|
||||||
store.signTransaction(request.topic,
|
store.signTransaction(request.topic,
|
||||||
request.id,
|
request.id,
|
||||||
request.account.address,
|
request.accountAddress,
|
||||||
request.network.chainId,
|
request.chainId,
|
||||||
txObj,
|
txObj,
|
||||||
password,
|
password,
|
||||||
pin)
|
pin)
|
||||||
@ -285,7 +271,7 @@ WalletConnectSDKBase {
|
|||||||
store.sendTransaction(request.topic,
|
store.sendTransaction(request.topic,
|
||||||
request.id,
|
request.id,
|
||||||
request.account.address,
|
request.account.address,
|
||||||
request.network.chainId,
|
request.chainId,
|
||||||
txObj,
|
txObj,
|
||||||
password,
|
password,
|
||||||
pin)
|
pin)
|
||||||
@ -430,7 +416,21 @@ WalletConnectSDKBase {
|
|||||||
sourceComponent: DAppSignRequestModal {
|
sourceComponent: DAppSignRequestModal {
|
||||||
id: dappRequestModal
|
id: dappRequestModal
|
||||||
objectName: "connectorDappsRequestModal"
|
objectName: "connectorDappsRequestModal"
|
||||||
loginType: request.account.migragedToKeycard ? Constants.LoginType.Keycard : root.loginType
|
|
||||||
|
readonly property var account: accountEntry.available ? accountEntry.model : {
|
||||||
|
"address": "",
|
||||||
|
"name": "",
|
||||||
|
"emoji": "",
|
||||||
|
"colorId": 0
|
||||||
|
}
|
||||||
|
|
||||||
|
readonly property var network: networkEntry.available ? networkEntry.model : {
|
||||||
|
"chainId": 0,
|
||||||
|
"chainName": "",
|
||||||
|
"iconUrl": ""
|
||||||
|
}
|
||||||
|
|
||||||
|
loginType: account.migragedToKeycard ? Constants.LoginType.Keycard : root.loginType
|
||||||
formatBigNumber: (number, symbol, noSymbolOption) => root.wcService.walletRootStore.currencyStore.formatBigNumber(number, symbol, noSymbolOption)
|
formatBigNumber: (number, symbol, noSymbolOption) => root.wcService.walletRootStore.currencyStore.formatBigNumber(number, symbol, noSymbolOption)
|
||||||
|
|
||||||
visible: true
|
visible: true
|
||||||
@ -439,13 +439,13 @@ WalletConnectSDKBase {
|
|||||||
dappUrl: request.dappUrl
|
dappUrl: request.dappUrl
|
||||||
dappIcon: request.dappIcon
|
dappIcon: request.dappIcon
|
||||||
|
|
||||||
accountColor: Utils.getColorForId(request.account.colorId)
|
accountColor: Utils.getColorForId(account.colorId)
|
||||||
accountName: request.account.name
|
accountName: account.name
|
||||||
accountAddress: request.account.address
|
accountAddress: account.address
|
||||||
accountEmoji: request.account.emoji
|
accountEmoji: account.emoji
|
||||||
|
|
||||||
networkName: request.network.chainName
|
networkName: network.chainName
|
||||||
networkIconPath: Style.svg(request.network.iconUrl)
|
networkIconPath: Style.svg(network.iconUrl)
|
||||||
|
|
||||||
fiatFees: request.maxFeesText
|
fiatFees: request.maxFeesText
|
||||||
cryptoFees: request.maxFeesEthText
|
cryptoFees: request.maxFeesEthText
|
||||||
@ -503,6 +503,20 @@ WalletConnectSDKBase {
|
|||||||
controller.rejectTransactionSigning(root.requestId)
|
controller.rejectTransactionSigning(root.requestId)
|
||||||
root.wcService.displayToastMessage(qsTr("Failed to sign transaction from %1").arg(request.dappUrl), true)
|
root.wcService.displayToastMessage(qsTr("Failed to sign transaction from %1").arg(request.dappUrl), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ModelEntry {
|
||||||
|
id: networkEntry
|
||||||
|
sourceModel: root.wcService.flatNetworks
|
||||||
|
key: "chainId"
|
||||||
|
value: request.chainId
|
||||||
|
}
|
||||||
|
|
||||||
|
ModelEntry {
|
||||||
|
id: accountEntry
|
||||||
|
sourceModel: root.wcService.validAccounts
|
||||||
|
key: "address"
|
||||||
|
value: request.accountAddress
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,8 @@ QObject {
|
|||||||
required property string topic
|
required property string topic
|
||||||
required property string id
|
required property string id
|
||||||
required property string method
|
required property string method
|
||||||
|
required property string accountAddress
|
||||||
required property var account
|
required property string chainId
|
||||||
required property var network
|
|
||||||
|
|
||||||
required property var data
|
required property var data
|
||||||
// Data prepared for display in a human readable format
|
// Data prepared for display in a human readable format
|
||||||
|
Loading…
x
Reference in New Issue
Block a user