fix(WC): Fix property names collisions

to squash - property names collisions
This commit is contained in:
Alex Jbanca 2024-10-18 23:36:10 +03:00
parent 80b5d7e9a8
commit a398d348a4
No known key found for this signature in database
GPG Key ID: 6004079575C21C5D
6 changed files with 37 additions and 36 deletions

View File

@ -51,7 +51,7 @@ Item {
const requestItem = testCase.createTemporaryObject(sessionRequestComponent, root, { const requestItem = testCase.createTemporaryObject(sessionRequestComponent, root, {
event: requestObj, event: requestObj,
topic, topic,
id: requestObj.id, requestId: requestObj.id,
method: Constants.personal_sign, method: Constants.personal_sign,
accountAddress: account, accountAddress: account,
chainId: network, chainId: network,
@ -314,7 +314,7 @@ Item {
compare(handler.store.authenticateUserCalls.length, 1, "expected a call to store.authenticateUser") compare(handler.store.authenticateUserCalls.length, 1, "expected a call to store.authenticateUser")
let store = handler.store let store = handler.store
store.userAuthenticated(td.topic, td.request.id, "hello world", "") store.userAuthenticated(td.topic, td.request.requestId, "hello world", "")
compare(store.signMessageCalls.length, 1, "expected a call to store.signMessage") compare(store.signMessageCalls.length, 1, "expected a call to store.signMessage")
compare(store.signMessageCalls[0].message, td.request.data) compare(store.signMessageCalls[0].message, td.request.data)
} }

View File

@ -297,7 +297,7 @@ DappsComboBox {
return return
} }
requestHandled = true requestHandled = true
root.signRequestRejected(request.topic, request.id) root.signRequestRejected(request.topic, request.requestId)
} }
parent: root parent: root
@ -347,7 +347,7 @@ DappsComboBox {
hasExpiryDate: !!request.expirationTimestamp hasExpiryDate: !!request.expirationTimestamp
onOpened: { onOpened: {
root.subscribeForFeeUpdates(request.topic, request.id) root.subscribeForFeeUpdates(request.topic, request.requestId)
} }
onClosed: { onClosed: {
@ -356,7 +356,7 @@ DappsComboBox {
onAccepted: { onAccepted: {
requestHandled = true requestHandled = true
root.signRequestAccepted(request.topic, request.id) root.signRequestAccepted(request.topic, request.requestId)
} }
onRejected: { onRejected: {

View File

@ -309,7 +309,7 @@ SQUtils.QObject {
let obj = sessionRequestComponent.createObject(null, { let obj = sessionRequestComponent.createObject(null, {
event, event,
topic: event.topic, topic: event.topic,
id: event.id, requestId: event.id,
method, method,
accountAddress, accountAddress,
chainId, chainId,
@ -317,7 +317,6 @@ SQUtils.QObject {
preparedData: interpreted.preparedData, preparedData: interpreted.preparedData,
maxFeesText: "?", maxFeesText: "?",
maxFeesEthText: "?", maxFeesEthText: "?",
enoughFunds: enoughFunds,
expirationTimestamp: requestExpiry expirationTimestamp: requestExpiry
}) })
if (obj === null) { if (obj === null) {
@ -338,7 +337,7 @@ SQUtils.QObject {
} }
obj.resolveDappInfoFromSession(session) obj.resolveDappInfoFromSession(session)
root.sessionRequest(obj.id) root.sessionRequest(obj.requestId)
d.updateFeesParamsToPassedObj(obj) d.updateFeesParamsToPassedObj(obj)
}) })
@ -498,24 +497,24 @@ SQUtils.QObject {
function executeSessionRequest(request, password, pin, payload) { function executeSessionRequest(request, password, pin, payload) {
if (!SessionRequest.getSupportedMethods().includes(request.method)) { if (!SessionRequest.getSupportedMethods().includes(request.method)) {
console.error("Unsupported method to execute: ", request.method) console.error("Unsupported method to execute: ", request.method)
return return false
} }
if (password === "") { if (password === "") {
console.error("No password provided to sign message") console.error("No password provided to sign message")
return return false
} }
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.requestId,
request.accountAddress, 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.requestId,
request.accountAddress, request.accountAddress,
SessionRequest.methods.personalSign.getMessageFromData(request.data), SessionRequest.methods.personalSign.getMessageFromData(request.data),
password, password,
@ -525,7 +524,7 @@ 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.requestId,
request.accountAddress, request.accountAddress,
SessionRequest.methods.signTypedData.getMessageFromData(request.data), SessionRequest.methods.signTypedData.getMessageFromData(request.data),
request.chainId, request.chainId,
@ -554,7 +553,7 @@ 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.requestId,
request.accountAddress, request.accountAddress,
request.chainId, request.chainId,
txObj, txObj,
@ -563,7 +562,7 @@ SQUtils.QObject {
} else if (request.method === SessionRequest.methods.sendTransaction.name) { } else if (request.method === SessionRequest.methods.sendTransaction.name) {
store.sendTransaction( store.sendTransaction(
request.topic, request.topic,
request.id, request.requestId,
request.accountAddress, request.accountAddress,
request.chainId, request.chainId,
txObj, txObj,
@ -571,6 +570,8 @@ SQUtils.QObject {
pin) pin)
} }
} }
return true
} }
// Returns Constants.TransactionEstimatedTime // Returns Constants.TransactionEstimatedTime

View File

@ -86,7 +86,7 @@ WalletConnectSDKBase {
let obj = sessionRequestComponent.createObject(null, { let obj = sessionRequestComponent.createObject(null, {
event, event,
topic: event.topic, topic: event.topic,
id: event.id, requestId: event.id,
method, method,
accountAddress, accountAddress,
chainId, chainId,
@ -94,7 +94,7 @@ WalletConnectSDKBase {
preparedData: interpreted.preparedData, preparedData: interpreted.preparedData,
maxFeesText: "?", maxFeesText: "?",
maxFeesEthText: "?", maxFeesEthText: "?",
enoughFunds: enoughFunds haveEnoughFunds: enoughFunds
}) })
if (obj === null) { if (obj === null) {
@ -133,14 +133,14 @@ WalletConnectSDKBase {
let maxFeesString = maxFees.toString() let maxFeesString = maxFees.toString()
obj.maxFeesText = maxFeesString obj.maxFeesText = maxFeesString
obj.maxFeesEthText = maxFeesString obj.maxFeesEthText = maxFeesString
obj.enoughFunds = true obj.haveEnoughFunds = true
} else { } else {
let gasPrice = hexToGwei(tx.gasPrice) let gasPrice = hexToGwei(tx.gasPrice)
let maxFees = BigOps.times(gasLimit, gasPrice) let maxFees = BigOps.times(gasLimit, gasPrice)
let maxFeesString = maxFees.toString() let maxFeesString = maxFees.toString()
obj.maxFeesText = maxFeesString obj.maxFeesText = maxFeesString
obj.maxFeesEthText = maxFeesString obj.maxFeesEthText = maxFeesString
obj.enoughFunds = true obj.haveEnoughFunds = true
} }
} }
@ -364,14 +364,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.requestId,
request.accountAddress, 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.requestId,
request.accountAddress, request.accountAddress,
SessionRequest.methods.personalSign.getMessageFromData(request.data), SessionRequest.methods.personalSign.getMessageFromData(request.data),
password, password,
@ -381,7 +381,7 @@ 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.requestId,
request.accountAddress, request.accountAddress,
SessionRequest.methods.signTypedData.getMessageFromData(request.data), SessionRequest.methods.signTypedData.getMessageFromData(request.data),
request.chainId, request.chainId,
@ -391,7 +391,7 @@ WalletConnectSDKBase {
} else if (request.method === SessionRequest.methods.signTransaction.name) { } else if (request.method === SessionRequest.methods.signTransaction.name) {
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.requestId,
request.accountAddress, request.accountAddress,
request.chainId, request.chainId,
txObj, txObj,
@ -399,9 +399,9 @@ WalletConnectSDKBase {
pin) pin)
} else if (request.method === SessionRequest.methods.sendTransaction.name) { } else if (request.method === SessionRequest.methods.sendTransaction.name) {
store.sendTransaction(request.topic, store.sendTransaction(request.topic,
request.id, request.requestId,
request.account.address, request.accountAddress,
request.network.chainId, request.chainId,
request.data.tx, request.data.tx,
password, password,
pin) pin)
@ -445,7 +445,7 @@ WalletConnectSDKBase {
} }
function authenticate(request) { function authenticate(request) {
return store.authenticateUser(request.topic, request.id, request.account.address) return store.authenticateUser(request.topic, request.requestId, request.accountAddress)
} }
} }
@ -545,14 +545,14 @@ WalletConnectSDKBase {
id: dappRequestModal id: dappRequestModal
objectName: "connectorDappsRequestModal" objectName: "connectorDappsRequestModal"
readonly property var account: accountEntry.available ? accountEntry.model : { readonly property var account: accountEntry.available ? accountEntry.item : {
"address": "", "address": "",
"name": "", "name": "",
"emoji": "", "emoji": "",
"colorId": 0 "colorId": 0
} }
readonly property var network: networkEntry.available ? networkEntry.model : { readonly property var network: networkEntry.available ? networkEntry.item : {
"chainId": 0, "chainId": 0,
"chainName": "", "chainName": "",
"iconUrl": "" "iconUrl": ""
@ -580,8 +580,8 @@ WalletConnectSDKBase {
estimatedTime: "" estimatedTime: ""
feesLoading: !request.maxFeesText || !request.maxFeesEthText feesLoading: !request.maxFeesText || !request.maxFeesEthText
hasFees: signingTransaction hasFees: signingTransaction
enoughFundsForTransaction: request.enoughFunds enoughFundsForTransaction: request.haveEnoughFunds
enoughFundsForFees: request.enoughFunds enoughFundsForFees: request.haveEnoughFunds
signingTransaction: request.method === SessionRequest.methods.signTransaction.name || request.method === SessionRequest.methods.sendTransaction.name signingTransaction: request.method === SessionRequest.methods.signTransaction.name || request.method === SessionRequest.methods.sendTransaction.name

View File

@ -17,7 +17,7 @@ QObject {
/// dApp request data /// dApp request data
required property string topic required property string topic
required property string id required property string requestId
required property string method required property string method
required property string accountAddress required property string accountAddress
required property string chainId required property string chainId

View File

@ -5,7 +5,7 @@ ListModel {
id: root id: root
function enqueue(request) { function enqueue(request) {
root.append({requestId: request.id, requestItem: request}); root.append({requestId: request.requestId, requestItem: request});
} }
function dequeue() { function dequeue() {
@ -20,7 +20,7 @@ ListModel {
function removeRequest(topic, id) { function removeRequest(topic, id) {
for (var i = 0; i < root.count; i++) { for (var i = 0; i < root.count; i++) {
let entry = root.get(i).requestItem let entry = root.get(i).requestItem
if (entry.topic == topic && entry.id == id) { if (entry.topic == topic && entry.requestId == id) {
root.remove(i, 1); root.remove(i, 1);
return; return;
} }
@ -31,7 +31,7 @@ ListModel {
function findRequest(topic, id) { function findRequest(topic, id) {
for (var i = 0; i < root.count; i++) { for (var i = 0; i < root.count; i++) {
let entry = root.get(i).requestItem let entry = root.get(i).requestItem
if (entry.topic == topic && entry.id == id) { if (entry.topic == topic && entry.requestId == id) {
return entry; return entry;
} }
} }
@ -42,7 +42,7 @@ ListModel {
function findById(id) { function findById(id) {
for (var i = 0; i < root.count; i++) { for (var i = 0; i < root.count; i++) {
let entry = root.get(i).requestItem let entry = root.get(i).requestItem
if (entry.id == id) { if (entry.requestId == id) {
return entry; return entry;
} }
} }