Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pass arguments for the contract functions in the correct order (#…
…347) # 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](https://explorer.zksync.io/address/0xE1D6A50E7101c8f8db77352897Ee3f1AC53f782B#contract#write-proxy), 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 <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [x] Tests for the changes have been added / updated. - [x] Documentation comments have been added / updated. --------- Co-authored-by: Vasyl Ivanchuk <[email protected]>
- Loading branch information