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

feat: assert that client chain matches wallet's active chain #223

Merged
merged 2 commits into from
Mar 16, 2023

Conversation

jxom
Copy link
Member

@jxom jxom commented Mar 16, 2023

We currently check if the chain arg on sendTransaction matches the wallet's active chain, but we don't check if the wallet client chain matches the wallet's active chain. Would be good to add it in.

@changeset-bot
Copy link

changeset-bot bot commented Mar 16, 2023

🦋 Changeset detected

Latest commit: 62fdd02

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Mar 16, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
viem ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 16, 2023 at 4:08AM (UTC)
viem-playground ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 16, 2023 at 4:08AM (UTC)

@@ -270,6 +270,49 @@ await walletClient.writeContract({
})
```

### assertChain (optional)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding missing docs on writeContract.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2023

Size Change: -7 B (0%)

Total Size: 45.8 kB

Filename Size Change
dist/abi.js 255 B -3 B (-1%)
dist/chains.js 1.59 kB +1 B (0%)
dist/chunk-FDTKU2PS.js 0 B -1.38 kB (removed) 🏆
dist/chunk-ZTHR4YS2.js 0 B -34.2 kB (removed) 🏆
dist/contract.js 437 B -2 B (0%)
dist/ethers.js 504 B -2 B (0%)
dist/index.js 4.62 kB -3 B (0%)
dist/public.js 456 B -3 B (-1%)
dist/test.js 505 B -3 B (-1%)
dist/utils/index.js 1.07 kB -2 B (0%)
dist/wallet.js 293 B -4 B (-1%)
dist/chunk-A5BRAPQQ.js 34.3 kB +34.3 kB (new file) 🆕
dist/chunk-GZ67J32T.js 1.38 kB +1.38 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
dist/ens.js 344 B
dist/window.js 67 B

compressed-size-action

@codecov
Copy link

codecov bot commented Mar 16, 2023

Codecov Report

Merging #223 (62fdd02) into main (ee9cae6) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #223   +/-   ##
=======================================
  Coverage   99.84%   99.84%           
=======================================
  Files         221      221           
  Lines       13116    13119    +3     
  Branches     1406     1402    -4     
=======================================
+ Hits        13096    13099    +3     
  Misses         19       19           
  Partials        1        1           
Impacted Files Coverage Δ
src/actions/wallet/sendTransaction.ts 100.00% <100.00%> (ø)
src/clients/createWalletClient.ts 100.00% <100.00%> (ø)
src/errors/chain.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

sendTransaction(walletClient, {
account: getAccount(sourceAccount.address),
to: targetAccount.address,
value: parseEther('1'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to pass in some kind of autoSwitch: true here that would automatically switch chains first if connected to wrong chain. Made a discussion here

@jxom jxom merged commit 2e9c000 into main Mar 16, 2023
@jxom jxom deleted the jxom/assert-client-chain branch March 16, 2023 04:24
@github-actions github-actions bot mentioned this pull request Mar 16, 2023
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.

2 participants