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

Bug: Error in Coinbase Wallet SDK Documentation for Smart Wallet Creation #1254

Closed
sflanary97 opened this issue May 1, 2024 · 3 comments
Closed
Assignees
Labels
type: bug Something isn't working

Comments

@sflanary97
Copy link

Describe the bug

The documentation on the README here: https://github.com/coinbase/coinbase-wallet-sdk

Steps

Following documentation for Wallet SDK Version 4.0.0-rc on README, or Coinbase Smart Wallet Docs:

  1. Install @coinbase/wallet-sdk version 4.0.0-rc.1
  2. Initialize SDK:
const sdk = new CoinbaseWalletSDK({
  appName: 'SDK Playground',
});
  1. Initialize Provider:
const provider = sdk.makeWeb3Provider();
  1. Request accounts:
const addresses = provider.request('eth_requestAccounts');
  1. View error:
ERROR
Expected a single, non-array, object argument.
    at getEthJsonRpcError
    at Object.invalidRequest
    at checkErrorForInvalidRequestArgs
    at CoinbaseWalletProvider.request

In my case, after inspecting the util.js code for the CoinbaseWalletProvider.request's checkErrorForInvalidRequestArgs, it seems to be failing from this line:

/**
 * Validates the arguments for an invalid request and returns an error if any validation fails.
 * Valid request args are defined here: https://eips.ethereum.org/EIPS/eip-1193#request
 * @param args The request arguments to validate.
 * @returns An error object if the arguments are invalid, otherwise undefined.
 */
function checkErrorForInvalidRequestArgs(args) {
    if (!args || typeof args !== 'object' || Array.isArray(args)) {
        return error_1.standardErrors.rpc.invalidRequest({
            message: 'Expected a single, non-array, object argument.',
            data: args,
        });
    }
    ...
}

The documentation in this README as well as CoinBase Smart Wallet Docs pass in a single string argument to provider.request as 'eth_requestAccounts' but following the EIP-1193 specs, "The Provider MUST identify the requested RPC method by the value of RequestArguments.method."

To properly request accounts and view the Coinbase Wallet pop up, the documentation should be updated to provider.request({ method: 'eth_requestAccounts' }) instead of provider.request('eth_requestAccounts'). This update resolves the Expected a single, non-array, object argument

Expected behavior

Coinbase Smart Wallet should open after following README docs.

Version

4.0.0-rc.1

Additional info

Version from documentation

Screenshot 2024-04-30 at 8 40 44 PM

Produces this error:

Screenshot 2024-04-30 at 8 40 44 PM

Proposed Fix:
const addresses = provider.request({ method: 'eth_requestAccounts' })

Produces expected wallet pop up:
Screenshot 2024-04-30 at 8 43 04 PM

Desktop

Browser - [tested on Brave, Chrome, Safari]

Smartphone

No response

@Josh350Hops
Copy link

Hey From Joshua

@jakzaizzat
Copy link

@sflanary97 Try to pass the object inside the request function

let response: string[] = await provider.request({
  method: 'eth_requestAccounts',
 })

@nateReiners
Copy link
Contributor

Hi @sflanary97 thanks for catching this. This was a typo but has since been addressed. Also, we have new and improved docs here: https://www.smartwallet.dev/sdk/makeWeb3Provider#usage

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

No branches or pull requests

4 participants