Skip to content

Commit 0fdd0ac

Browse files
authored
Feature - Replace internal Ethers functionality with Viem - Add WAGMI support module (#2203)
* Replaced isAddress check from ethers * Replace Ethers BigNumber usage with browser native BigInt * Remove ethers from common * Testing package size * Working as expected! * Disable ums * Cleanup chain usage * More cleanup * Ens avatar testing * Some ethers swapped out for viem in Trezor and import map expanded * Alittle cleanup in Trezor * revert Trezor changes * All is working from old commit * Fix conflict * Remove logs * Return Address type to official check * Update versions and handle type issues * Bump Viem to latest * Add node version check and min set to 16.15.1 * Add npmrc files with engine-strict set to true to core, react and vue to ensure the node engine check is enforced * Added function for converting wei in both hex and string to eth, updated chain usage for ens and l2s, added function for handling decimel resolution with bigints * Return bignumber to core for now * cleanup and testing, removing unused code, refactor and rename to properly reflect functionality * Remove bignumber from core again * Fix merge issue with unstoppable resolution * Return getText function for ens and update to viem * Refine ci changes scope to core and related packages * Final pass of PR for cleanup and refactor * Remove ethers from tp * Update to latest viem * Update cede and WC docs * resolve conflict * Update config to publish viem test branches * Update tsconfig and types * Update node version in core * Bump versions for release and Remove console.log * ENS working again * Progress within hw wallets * Progress on chain imports * Further refinement on viem usage of public client * refine ledger, deprecate v1 * Update TS, revert viem changes to HW-wallets * Handle ts errors * Update packages for test release * Handle all ts errors! * Cleanup * Making progress * Wagmi core * Refine imports and test a whole bunch * Fix build errors * Try later version of node in CI * Add sass types to common * Update tsconfig * Update imports from common * Refine types * Update core imports * Update svelte preprocess * Bump common version * More refinements to core * Remove log * Update tsconfig for hw-common to resolve build error * Ensure new utils file is part of commit * Remove unnecessary commonjs as the issue was fixed by viem team * Use viem utils in common * Changes to versioning and ready for testing * Bump version * Merge in changes from viem branch * More updates from viem branch * Refine package intialization and wagmi init * testing signing * Update wagmi disconnect * Update viem versions * Yarn it * Update publish workflow to publish all packages * Fix issue and redeploy * Update solid node build version * Handle build errors * Update configs for build * Update ci build config * Bump arcana node version in CI * Fix arcana * Fix venly * Update gnosis pakcage.json * Get all of the changes from viem merged and stablelized * Use toHex function, switch chain now working * Handle multiple wallets correctly * Still working thru MM sdk issues * Working through issues * Still working through MM issues * Connect working for sdks * wagmi support stabilized * Cleanup logs * More updates to wagmi on disconnect * Refine disconnect * Create and test wagmi module * Create wagmi module * Add wagmi docs * Update examples * Update disconnect to handle wagmi * Handle ts errors in wagmi package * Refine examples and more ts fixes * Handle more errors * Update tags to be named as wagmi * Update CI for deployment * Fix CI build for wagmi * Update tsconfig * Update tsconfig again * Update docs examples * Fix build error * cleanup exports and hook within react and document * Refine docs * Capsule is working! * Add note about init object to docs and readme * Export all wagmi functions from wagmi package * Update docs * Fix examples * Bump to latest versions of wagmi and viem * bump common version * Bump versions for latest deps * Bump versions for pub * Version from wagmi to alpha flag * Revert testing ci changes * update CI to remove testing flow * Remove log * Remove capsule for failing build from demo
1 parent 15af477 commit 0fdd0ac

File tree

150 files changed

+2412
-1286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+2412
-1286
lines changed

.circleci/config.yml

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ commands:
167167
jobs:
168168
build-core:
169169
docker:
170-
- image: cimg/node:16.13.1
170+
- image: cimg/node:16.15.1
171171
working_directory: ~/web3-onboard-monorepo/packages/core
172172
steps:
173173
- node-build-steps
@@ -275,7 +275,7 @@ jobs:
275275
- node-build-steps
276276
build-react:
277277
docker:
278-
- image: cimg/node:16.13.1
278+
- image: cimg/node:16.15.1
279279
working_directory: ~/web3-onboard-monorepo/packages/react
280280
steps:
281281
- node-build-steps
@@ -293,7 +293,7 @@ jobs:
293293
- node-build-steps
294294
build-web3auth:
295295
docker:
296-
- image: cimg/node:16.18.1
296+
- image: cimg/node:18.0.0
297297
working_directory: ~/web3-onboard-monorepo/packages/web3auth
298298
steps:
299299
- node-build-steps
@@ -305,7 +305,7 @@ jobs:
305305
- node-build-steps
306306
build-vue:
307307
docker:
308-
- image: cimg/node:16.13.1
308+
- image: cimg/node:16.15.1
309309
working_directory: ~/web3-onboard-monorepo/packages/vue
310310
steps:
311311
- node-build-steps
@@ -341,7 +341,7 @@ jobs:
341341
- node-build-steps
342342
build-uauth:
343343
docker:
344-
- image: cimg/node:16.13.1
344+
- image: cimg/node:18.0.0
345345
working_directory: ~/web3-onboard-monorepo/packages/uauth
346346
steps:
347347
- node-build-steps
@@ -395,7 +395,7 @@ jobs:
395395
- node-build-steps
396396
build-arcana-auth:
397397
docker:
398-
- image: cimg/node:16.13.1
398+
- image: cimg/node:18.0.0
399399
working_directory: ~/web3-onboard-monorepo/packages/arcana-auth
400400
steps:
401401
- node-build-steps
@@ -407,7 +407,7 @@ jobs:
407407
- node-build-steps
408408
build-venly:
409409
docker:
410-
- image: cimg/node:16.13.1
410+
- image: cimg/node:18.18.2
411411
working_directory: ~/web3-onboard-monorepo/packages/venly
412412
steps:
413413
- node-build-steps
@@ -432,7 +432,7 @@ jobs:
432432
resource_class: large
433433
build-solid:
434434
docker:
435-
- image: cimg/node:16.14.2
435+
- image: cimg/node:16.15.1
436436
working_directory: ~/web3-onboard-monorepo/packages/solid
437437
steps:
438438
- node-build-steps
@@ -448,6 +448,12 @@ jobs:
448448
working_directory: ~/web3-onboard-monorepo/packages/particle-network
449449
steps:
450450
- node-build-steps
451+
build-wagmi:
452+
docker:
453+
- image: cimg/node:18.0.0
454+
working_directory: ~/web3-onboard-monorepo/packages/wagmi
455+
steps:
456+
- node-build-steps
451457
build-passport:
452458
docker:
453459
- image: cimg/node:18.0.0
@@ -458,7 +464,7 @@ jobs:
458464
# Build staging/Alpha releases
459465
build-staging-core:
460466
docker:
461-
- image: cimg/node:16.13.1
467+
- image: cimg/node:16.15.1
462468
working_directory: ~/web3-onboard-monorepo/packages/core
463469
steps:
464470
- node-staging-build-steps
@@ -566,7 +572,7 @@ jobs:
566572
- node-staging-build-steps
567573
build-staging-react:
568574
docker:
569-
- image: cimg/node:16.13.1
575+
- image: cimg/node:16.15.1
570576
working_directory: ~/web3-onboard-monorepo/packages/react
571577
steps:
572578
- node-staging-build-steps
@@ -584,7 +590,7 @@ jobs:
584590
- node-staging-build-steps
585591
build-staging-web3auth:
586592
docker:
587-
- image: cimg/node:16.18.1
593+
- image: cimg/node:18.0.0
588594
working_directory: ~/web3-onboard-monorepo/packages/web3auth
589595
steps:
590596
- node-staging-build-steps
@@ -596,7 +602,7 @@ jobs:
596602
- node-staging-build-steps
597603
build-staging-vue:
598604
docker:
599-
- image: cimg/node:16.13.1
605+
- image: cimg/node:16.15.1
600606
working_directory: ~/web3-onboard-monorepo/packages/vue
601607
steps:
602608
- node-staging-build-steps
@@ -632,7 +638,7 @@ jobs:
632638
- node-staging-build-steps
633639
build-staging-uauth:
634640
docker:
635-
- image: cimg/node:16.13.1
641+
- image: cimg/node:18.0.0
636642
working_directory: ~/web3-onboard-monorepo/packages/uauth
637643
steps:
638644
- node-staging-build-steps
@@ -686,7 +692,7 @@ jobs:
686692
- node-staging-build-steps
687693
build-staging-arcana-auth:
688694
docker:
689-
- image: cimg/node:16.13.1
695+
- image: cimg/node:18.0.0
690696
working_directory: ~/web3-onboard-monorepo/packages/arcana-auth
691697
steps:
692698
- node-staging-build-steps
@@ -698,7 +704,7 @@ jobs:
698704
- node-staging-build-steps
699705
build-staging-venly:
700706
docker:
701-
- image: cimg/node:16.13.1
707+
- image: cimg/node:18.18.2
702708
working_directory: ~/web3-onboard-monorepo/packages/venly
703709
steps:
704710
- node-staging-build-steps
@@ -722,7 +728,7 @@ jobs:
722728
- node-staging-build-steps
723729
build-staging-solid:
724730
docker:
725-
- image: cimg/node:16.14.2
731+
- image: cimg/node:16.15.1
726732
working_directory: ~/web3-onboard-monorepo/packages/solid
727733
steps:
728734
- node-staging-build-steps
@@ -738,6 +744,12 @@ jobs:
738744
working_directory: ~/web3-onboard-monorepo/packages/particle-network
739745
steps:
740746
- node-staging-build-steps
747+
build-staging-wagmi:
748+
docker:
749+
- image: cimg/node:18.0.0
750+
working_directory: ~/web3-onboard-monorepo/packages/wagmi
751+
steps:
752+
- node-staging-build-steps
741753
build-staging-passport:
742754
docker:
743755
- image: cimg/node:18.0.0
@@ -753,6 +765,7 @@ workflows:
753765
<<: *deploy_production_filters
754766
- build-staging-common:
755767
<<: *deploy_staging_filters
768+
756769
core:
757770
jobs:
758771
- build-core:
@@ -1030,6 +1043,12 @@ workflows:
10301043
<<: *deploy_production_filters
10311044
- build-staging-particle:
10321045
<<: *deploy_staging_filters
1046+
wagmi:
1047+
jobs:
1048+
- build-wagmi:
1049+
<<: *deploy_production_filters
1050+
- build-staging-wagmi:
1051+
<<: *deploy_staging_filters
10331052
passport:
10341053
jobs:
10351054
- build-passport:

docs/src/routes/docs/[...1]overview/[...1]introduction/+page.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const MAINNET_RPC_URL = 'https://mainnet.infura.io/v3/<INFURA_KEY>'
102102
const injected = injectedModule()
103103

104104
const onboard = Onboard({
105+
// This javascript object is unordered meaning props do not require a certain order
105106
wallets: [injected],
106107
chains: [
107108
{

docs/src/routes/docs/[...2]getting-started/[...1]installation/+page.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const appMetadata = {
110110

111111
```ts
112112
const onboard = Onboard({
113+
// This javascript object is unordered meaning props do not require a certain order
113114
wallets,
114115
chains,
115116
appMetadata

docs/src/routes/docs/[...3]modules/[...1]core/+page.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ import injectedModule from '@web3-onboard/injected-wallets'
621621
const injected = injectedModule()
622622

623623
const onboard = Onboard({
624+
// This javascript object is unordered meaning props do not require a certain order
624625
// head to https://explorer.blocknative.com/account to sign up for free
625626
apiKey: 'xxx387fb-bxx1-4xxc-a0x3-9d37e426xxxx'
626627
wallets: [injected],

docs/src/routes/docs/[...3]modules/[...3]react/+page.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const rpcUrl = `https://mainnet.infura.io/v3/${infuraKey}`
4646

4747
// initialize Onboard
4848
init({
49+
// This javascript object is unordered meaning props do not require a certain order
4950
apiKey,
5051
wallets: [injected],
5152
chains: [
@@ -724,3 +725,31 @@ export default {
724725
}
725726
}
726727
```
728+
729+
## `useWagmiConfig`
730+
731+
This hook allows you to get the WagmiConfig (Config from the Wagmi project) from @web3-onboard/core if W3O has been initialized with the [WAGMI property imported and passing into the web3-onboard/core config](../../modules/wagmi.md#usage).
732+
733+
```typescript
734+
import { sendTransaction as wagmiSendTransaction } from '@web3-onboard/wagmi'
735+
import { parseEther } from 'viem'
736+
import { useWagmiConfig, wallets } from '@web3-onboard/react'
737+
import type { WagmiConfig } from '@web3-onboard/core'
738+
739+
type useWagmiConfig = (): WagmiConfig
740+
741+
const wagmiConfig = useWagmiConfig()
742+
const w3OWallets = useWallets()
743+
744+
const sendTransaction = async () => {
745+
// current primary wallet - as multiple wallets can connect this value is the currently active
746+
const [currentPrimaryWallet] = w3OWallets
747+
const result = await wagmiSendTransaction(wagmiConfig, {
748+
to: toAddress,
749+
// desired connector to send txn from
750+
account: currentPrimaryWallet.accounts[0],
751+
value: parseEther('0.001')
752+
})
753+
console.log(result)
754+
}
755+
```
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: wagmi
3+
---
4+
5+
# {$frontmatter.title}
6+
7+
A module for connecting wallets using WAGMI which returns a WAGMI config object to be used with [@wagmi/core](https://wagmi.sh/core/getting-started) functions.
8+
9+
### Install
10+
11+
<Tabs values={['yarn', 'npm']}>
12+
<TabPanel value="yarn">
13+
14+
```sh copy
15+
yarn add @web3-onboard/wagmi
16+
```
17+
18+
</TabPanel>
19+
<TabPanel value="npm">
20+
21+
```sh copy
22+
npm install @web3-onboard/wagmi
23+
```
24+
25+
</TabPanel>
26+
</Tabs>
27+
28+
## Usage
29+
30+
This example assumes you have already setup web3-onboard to connect wallets to your dapp.
31+
For more information see [web3-onboard docs](https://onboard.blocknative.com/docs/modules/core#install).
32+
33+
```ts
34+
import Onboard from '@web3-onboard/core'
35+
import injectedModule from '@web3-onboard/injected-wallets'
36+
import wagmi from '@web3-onboard/wagmi'
37+
import { parseEther } from 'viem'
38+
import {
39+
sendTransaction as wagmiSendTransaction,
40+
switchChain,
41+
disconnect,
42+
getConnectors
43+
} from '@web3-onboard/wagmi'
44+
import { parseEther, isHex, fromHex } from 'viem'
45+
46+
const injected = injectedModule()
47+
48+
const onboard = Onboard({
49+
// This javascript object is unordered meaning props do not require a certain order
50+
// ... other Onboard options
51+
wagmi,
52+
wallets: [injected],
53+
chains: [
54+
{
55+
id: '0x1',
56+
token: 'ETH',
57+
label: 'Ethereum',
58+
rpcUrl: 'https://mainnet.infura.io/v3/17c1e1500e384acfb6a72c5d2e67742e'
59+
}
60+
]
61+
// ... other Onboard options
62+
})
63+
64+
const sendTransaction = async () => {
65+
// current primary wallet - as multiple wallets can connect this value is the currently active
66+
const [currentPrimaryWallet] = onboard.state.get().wallets
67+
const wagmiConfig = onboard.state.get().wagmiConfig
68+
const result = await wagmiSendTransaction(wagmiConfig, {
69+
to: toAddress,
70+
// desired connector to send txn from
71+
account: currentPrimaryWallet.accounts[0],
72+
value: parseEther('0.001')
73+
})
74+
console.log(result)
75+
}
76+
77+
async function switchWagmiChain(chainId) {
78+
let chainAsNumber
79+
if (isHex(chainId)) {
80+
chainAsNumber = fromHex(chainId, 'number')
81+
} else if (!isHex(chainId) && typeof chainId === 'number') {
82+
chainAsNumber = chainId
83+
} else {
84+
throw new Error('Invalid chainId')
85+
}
86+
const wagmiConfig = onboard.state.get().wagmiConfig
87+
await switchChain(wagmiConfig, { chainId: chainAsNumber })
88+
}
89+
90+
async function disconnectWallet() {
91+
const wagmiConfig = onboard.state.get().wagmiConfig
92+
const disconnectThisWallet = getConnectors(wagmiConfig).find(
93+
(connector) => connector.name === label
94+
)
95+
disconnect(wagmiConfig, { connector: disconnectThisWallet })
96+
}
97+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"devDependencies": {
6464
"prettier": "^2.4.1",
6565
"prettier-plugin-svelte": "^2.4.0",
66-
"typescript": "^4.5.5"
66+
"typescript": "^4.9.4"
6767
},
6868
"peerDependencies": {
6969
"react": "*",

packages/arcana-auth/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/arcana-auth",
3-
"version": "2.0.0",
3+
"version": "2.1.0-alpha.2",
44
"license": "MIT",
55
"description": "Arcana wallet is a built-in, secure Web3 wallet that users can access instantly when logging into an app integrated with the Arcana Auth SDK. It offers a customizable interface that can be branded to match the app's style. Users don't need to generate or manage cryptographic keys or remember passphrases. The wallet uses advanced distributed key generation, giving users full control over their wallets while onboarding Web3 apps using familiar Web2 authentication methods. It is user-friendly, secure, and puts users in control of their Web3 experience.",
66
"private": false,
@@ -13,10 +13,10 @@
1313
"type-check": "tsc --noEmit"
1414
},
1515
"dependencies": {
16-
"@arcana/auth": "^1.0.7",
17-
"@web3-onboard/common": "2.3.3"
16+
"@arcana/auth": "^1.0.10",
17+
"@web3-onboard/common": "2.4.0-alpha.2"
1818
},
1919
"devDependencies": {
20-
"typescript": "^5.1.6"
20+
"typescript": "^5.4.5"
2121
}
2222
}

0 commit comments

Comments
 (0)