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

default request args #51

Merged
merged 17 commits into from
Jul 1, 2024
Merged

default request args #51

merged 17 commits into from
Jul 1, 2024

Conversation

zeroXbrock
Copy link
Member

@zeroXbrock zeroXbrock commented Jun 29, 2024

  • adds customRpc to getSuaveWallet args, which allows the wallet to access an alternate RPC (i.e. not the RPC to which the wallet is currently connected) when signing & sending txs (getting nonce, gas price)
  • this fixes common nonce & gas errors arising from custom-transport (browser) wallets being connected to an RPC other than suave

example usage in a web app:

const suaveWallet = getSuaveWallet({
    jsonRpcAccount: "0xBE69d72ca5f88aCba033a063dF5DBe43a4148De0",
    transport: custom(window.ethereum),
    customRpc: "http://localhost:8545",
})

const ccr: TransactionRequestSuave = {
    to: "0xd594760b2a36467ec7f0267382564772d7b0b73c",
    data: getCalldata(), // pretend you have this
    isEIP712: true, // true is default; can be omitted
    kettleAddress: "0xb5feafbdd752ad52afb7e1bd2e40432a485bbb7f",
    confidentialInputs: getConfidentialInputsBytes(), // pretend you have this
}

await suaveWallet.sendTransaction(ccr)

If you don't specify customRpc, the wallet will fall back on the provided custom transport, which will cause errors if the user's wallet is not connected to the suave RPC (which was the behavior prior to this PR).

@zeroXbrock zeroXbrock merged commit 4005170 into main Jul 1, 2024
11 checks passed
@zeroXbrock zeroXbrock deleted the default-request-args branch July 1, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant