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

Prefer author_getNextNonce for nonce retrieval #2576

Merged
merged 13 commits into from
Mar 15, 2024

Conversation

silva-fj
Copy link
Contributor

@silva-fj silva-fj commented Mar 14, 2024

  • Updated getSidechainNonce in di-utils.ts to retrieve the nonce using author_getNextNonce RPC call and updated the corresponding tests.
  • Refactored author_getNextNonce to expect Identity to support other type of accounts.

Copy link

linear bot commented Mar 14, 2024

@silva-fj silva-fj marked this pull request as draft March 14, 2024 12:10
@silva-fj silva-fj marked this pull request as ready for review March 15, 2024 10:08
@silva-fj
Copy link
Contributor Author

The failing tests are caused by some change in this PR. c.c @Kailai-Wang

@Kailai-Wang Kailai-Wang changed the title P610 prefer author_getNextNonce for nonce retrieval Prefer author_getNextNonce for nonce retrieval Mar 15, 2024
Copy link
Collaborator

@Kailai-Wang Kailai-Wang left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I removed P610 from the PR title :)

@silva-fj silva-fj enabled auto-merge (squash) March 15, 2024 15:25
@silva-fj silva-fj merged commit 276564a into dev Mar 15, 2024
24 of 25 checks passed
let nonce = 0;

if (nonceHex) {
nonce = context.api.createType('Index', '0x' + nonceHex.slice(2)?.match(/../g)?.reverse().join('')).toNumber();
Copy link
Contributor

Choose a reason for hiding this comment

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

hwo should we read this line:

nonceHex.slice(2)?.match(/../g)?.reverse().join('')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I borrowed that logic from here. What this line does is to reverse the order of two character groups in the hex string while keeping the '0x' prefix. (also known as byte swapping or endian swapping).

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.

None yet

3 participants