Skip to content
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

Merged
merged 5 commits into from
Jan 9, 2025
Merged

Conversation

zzggo
Copy link
Contributor

@zzggo zzggo commented Jan 8, 2025

Related Issue

Closes #336

Summary of Changes

Need Regression Testing

  • Yes
  • No

Updated the process when approving dapp ttransaction

Risk Assessment

  • Low
  • Medium
  • High

Need to test if the transaction id is correct across different dapp platforms.

Additional Notes

Screenshots (if applicable)

@zzggo zzggo requested review from tombeckenham and lmcmz January 8, 2025 11:42
@zzggo zzggo linked an issue Jan 8, 2025 that may be closed by this pull request
lmcmz
lmcmz previously approved these changes Jan 9, 2025
0, // Fixed value
gasLimit, // Gas Limit
Buffer.from(to, 'hex'), // To Address
BigInt(amount * 10 ** 18), // Value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BigInt(number)

Copy link
Contributor Author

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

// [nonce, gasPrice, gasLimit, to.addressData, value, data, v, r, s]
const transaction = [
Number(addressNonce), // nonce
0, // Fixed value
Copy link
Contributor

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, 
      ...
]

Buffer.from(dataArray), // Call Data
255, // Fixed value
BigInt('0x' + evmAddress), // From Account
5, // SubType
Copy link
Contributor

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

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');
Copy link
Contributor

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.

@lmcmz lmcmz self-requested a review January 9, 2025 00:51
@lmcmz lmcmz dismissed their stale review January 9, 2025 00:52

It should be request to change

Copy link
Contributor

@lmcmz lmcmz left a 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

@zzggo zzggo requested a review from lmcmz January 9, 2025 02:06
const contractCallSubType = 5;
const noceNumber = Number(addressNonce);
const gasPrice = 0;
const transactionValue = BigInt(amount * 10 ** 18);
Copy link
Contributor

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);

@zzggo zzggo merged commit 6d6e7de into dev Jan 9, 2025
2 checks passed
@zzggo zzggo deleted the EP.04.02---Calculate-TX-ID branch January 9, 2025 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EVM TX ID Calculation
2 participants