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

sendAsync method doesn't follow SafeEventEmitter #1303

Closed
vanya2h opened this issue Jan 7, 2024 · 2 comments
Closed

sendAsync method doesn't follow SafeEventEmitter #1303

vanya2h opened this issue Jan 7, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@vanya2h
Copy link

vanya2h commented Jan 7, 2024

I'm using json rpc middlewares with https://github.com/MetaMask/eth-json-rpc-middleware and it seems working with the most of injectable wallets. And recently I've discovered it doesn't work with Rainbow's so I dived deeper and discovered that your sendAsync method doesn't accept second argument - callback and instead returns just promise.

Example of problem:

window.rainbow.sendAsync(jsonRpcRequest, (err, jsonRpcResponse) => {
 // it'll never happen, callback is never called
})
@vanya2h
Copy link
Author

vanya2h commented Jan 8, 2024

Also I need to mention the format of response itself. Here's example of call to Ethereum Goerli

window.rainbow.sendAsync({
    "jsonrpc": "2.0",
    "id": 1,
    "method": "eth_estimateGas",
    "params": [
        {
            "from": "0x76c5855e93bd498b6331652854c4549d34bc3a30",
            "data": "0x22a775b6000000000000000000000000000000000000000000000000000000000000004000000000000000000000000076c5855e93bd498b6331652854c4549d34bc3a3076c5855e93bd498b6331652854c4549d34bc3a3000000000000000000000002e00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001e000000000000000000000000000000000000000000000000000000000000000412f697066732f6261666b726569677a616573766e35326e62726c7a7334337964676c32626c7a65777a3233636533706a706c376b62627968686c326d757635696900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000076c5855e93bd498b6331652854c4549d34bc3a300000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000000000000000000100000000000000000000000076c5855e93bd498b6331652854c4549d34bc3a3000000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000",
            "to": "0x1723017329a804564bc8d215496c89eabf1f3211"
        }
    ]
})

I see two problems in the response:

  1. The response doesn't follow standard json rpc response with such fields as jsonrpc, result, id and have just the raw value as it was sent via request API and not sendAsync
  2. The response is not hexademical number and instead just a decimal number which is not working with some libraries that depends on estimateGas call
  3. On some calls (e.g. eth_getBalance) returns unknown structure such as { "type": "BigNumber", "hex": "0x410ec70450f539bf" } and it seems very far away from the standards

@DanielSinclair DanielSinclair transferred this issue from rainbow-me/rainbow Jan 15, 2024
@DanielSinclair DanielSinclair added the bug Something isn't working label Apr 6, 2024
@DanielSinclair
Copy link
Collaborator

@vanya2h Thanks for reporting this! This was fixed and released a few weeks back with additions to our window provider described here: rainbow-me/provider#9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants