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

fix: pass arguments for the contract functions in the correct order #347

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

tx-nikola
Copy link
Contributor

@tx-nikola tx-nikola commented Dec 4, 2024

What ❔

This PR fixes the bug where the contract function arguments are not passed in the correct order.

Why ❔

In order to call the contract functions correctly, we need to pass the arguments in the right order.

Explanation

The issue was that we were trying to get Object.entries(params) without actually sorting it, so, for example, contract 0xE1D6A50E7101c8f8db77352897Ee3f1AC53f782B, the revokeRole function asks for [role, account] arguments to be passed.
In the form object, it looks like this:

{
  account: "0xExample",
  role: "0xExample
}

and when we run Object.entries(params) we always get it like this:

[
  ["account", "0x969Bb8Ae65602B4F8f9B459a11084e591c4491C7"],
  ["role", "0x03c321230b026fb61a5a21f62c5f618751ec6d8435327f673bae5bfa570e5879"]]
]

and later after we map it, it becomes ["0x969Bb8Ae65602B4F8f9B459a11084e591c4491C7", "0x03c321230b026fb61a5a21f62c5f618751ec6d8435327f673bae5bfa570e5879"] - swapping the arguments from their intended places.

This issue was happening when someone types the account first, therefore forms become

{
  account: "0xExample",
  role: "0xExample
}

instead of

{
  role: "0xExample,
  account: "0xExample"
}

thus messing up the order of the arguments in the function call.

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.

@tx-nikola tx-nikola added bug Something isn't working frontend Task requires changes to the frontend implementation labels Dec 4, 2024
@tx-nikola tx-nikola requested a review from popzxc December 4, 2024 12:55
@tx-nikola tx-nikola self-assigned this Dec 4, 2024
Copy link

github-actions bot commented Dec 4, 2024

API E2E Test Results

207 tests   207 ✅  21s ⏱️
 14 suites    0 💤
  1 files      0 ❌

Results for commit 1de8844.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 4, 2024

Unit Test Results

    4 files    263 suites   11m 35s ⏱️
2 125 tests 2 124 ✅ 1 💤 0 ❌
2 337 runs  2 336 ✅ 1 💤 0 ❌

Results for commit 1de8844.

♻️ This comment has been updated with latest results.

@tx-nikola tx-nikola force-pushed the tx-nikola-txfusion-fix-passing-contract-arguments-in-correct-order branch from 7232ef9 to fa4146d Compare December 4, 2024 14:50
Copy link

github-actions bot commented Dec 5, 2024

Visit the preview URL for this PR:
https://staging-scan-v2--pr-347-6chskmeh.web.app

@popzxc popzxc requested a review from vasyl-ivanchuk December 6, 2024 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Task requires changes to the frontend implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant