-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: calculate tx hash before seal #337
Conversation
src/background/controller/wallet.ts
Outdated
0, // Fixed value | ||
gasLimit, // Gas Limit | ||
Buffer.from(to, 'hex'), // To Address | ||
BigInt(amount * 10 ** 18), // Value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BigInt(number)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the amount is already a number
src/background/controller/wallet.ts
Outdated
// [nonce, gasPrice, gasLimit, to.addressData, value, data, v, r, s] | ||
const transaction = [ | ||
Number(addressNonce), // nonce | ||
0, // Fixed value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use the variable instead of magic number ?
const gasPrice = 0
const transaction = [
Number(addressNonce), // nonce
gasPrice,
...
]
src/background/controller/wallet.ts
Outdated
Buffer.from(dataArray), // Call Data | ||
255, // Fixed value | ||
BigInt('0x' + evmAddress), // From Account | ||
5, // SubType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for 255 and 5.
const directCallTxType = 255
const contractCallSubType = 5
src/background/controller/wallet.ts
Outdated
const encodedData = encode(transaction); | ||
const hash = keccak256(Buffer.from(encodedData)); | ||
const hashHexString = Buffer.from(hash).toString('hex'); | ||
if (hashHexString) { | ||
return hashHexString; | ||
} else { | ||
console.log('Transaction Executed event not found'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if hashHexString
is nil, we need handle the error response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update code by those comments
src/background/controller/wallet.ts
Outdated
const contractCallSubType = 5; | ||
const noceNumber = Number(addressNonce); | ||
const gasPrice = 0; | ||
const transactionValue = BigInt(amount * 10 ** 18); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Above we already convert hex to number, we can use it redirectly.
the value*10**18 is the example code, I don't wanna add web3js lib.
// Convert the hex value to number
const number = web3.utils.hexToNumber(value);
Related Issue
Closes #336
Summary of Changes
Need Regression Testing
Updated the process when approving dapp ttransaction
Risk Assessment
Need to test if the transaction id is correct across different dapp platforms.
Additional Notes
Screenshots (if applicable)