You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add error handling for the asynchronous requestSignature method call
Consider adding error handling for the requestSignature method call to handle possible rejections or failures, especially since it involves asynchronous operations.
Why: Adding error handling for the requestSignature method call is crucial for robustness, especially since it involves asynchronous operations that can fail. This suggestion significantly improves the reliability of the code.
9
Enhancement
Validate the format of hexString to ensure it starts with '0x'
Validate the input hexString to ensure it starts with '0x' before processing, to prevent errors when slicing and converting to bytes.
+if (!hexString.startsWith('0x')) {+ throw new Error(`Invalid hex string format: ${hexString}`);+}
if (hexString.slice(2).length !== 32 * 2) {
throw new Error(`Payload Hex must have 32 bytes: ${hexString}`);
}
return Array.from(toBytes(hexString));
Suggestion importance[1-10]: 8
Why: Ensuring the hexString starts with '0x' before processing prevents potential errors and improves input validation. This is a valuable enhancement for data integrity.
8
Maintainability
Use a utility function to generate expected payload arrays for test assertions
Consider using a utility function to generate expected payload arrays from hex strings to reduce redundancy and improve maintainability of tests.
Why: Using a utility function to generate expected payload arrays reduces redundancy and improves maintainability of the tests. However, the improvement is more about code cleanliness than fixing a critical issue.
7
Refactor payload expectation checks into a shared function for better code reuse and readability
Refactor the repeated payload expectation checks into a shared function to improve code reuse and test readability.
Why: Refactoring repeated payload expectation checks into a shared function enhances code reuse and readability, which is beneficial for maintainability. This suggestion improves the test code structure but is not critical.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Something that was somehow missed in #65 is that payloads are no longer reversed. This fixes that and updates tests.
PR Type
Bug fix, Tests
Description
requestSignature
method inNearEthAdapter
class.toPayload
function in transaction utility.utils.transaction.test.ts
to reflect payload without reversal.wc.handlers.test.ts
to reflect payload without reversal.Changes walkthrough 📝
ethereum.ts
Remove payload reversal in Ethereum adapter
src/chains/ethereum.ts
requestSignature
method.transaction.ts
Remove payload reversal in transaction utility
src/utils/transaction.ts
toPayload
function.utils.transaction.test.ts
Update transaction utility tests for payload change
tests/unit/utils.transaction.test.ts
wc.handlers.test.ts
Update Wallet Connect handler tests for payload change
tests/unit/wc.handlers.test.ts