Skip to content

Commit fce76b8

Browse files
feat: Add wagmi adapter for in-app wallet
1 parent 5574c15 commit fce76b8

File tree

9 files changed

+555
-9
lines changed

9 files changed

+555
-9
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# @thirdweb-dev/react-native-adapter
2+
3+
## 1.5.2
4+
5+
### Patch Changes
6+
7+
- [#5594](https://github.com/thirdweb-dev/js/pull/5594) [`b7c8854`](https://github.com/thirdweb-dev/js/commit/b7c885432726eeaf3401217573f2cff0f5247ff7) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Support for Expo 52 and React Native 0.76
8+
9+
## 1.5.1
10+
11+
### Patch Changes
12+
13+
- [#5150](https://github.com/thirdweb-dev/js/pull/5150) [`9fadbcc`](https://github.com/thirdweb-dev/js/commit/9fadbcc17abfe302933f7b860ab7c3b4fb577789) Thanks [@jnsdls](https://github.com/jnsdls)! - update dependencies
14+
15+
- [#5151](https://github.com/thirdweb-dev/js/pull/5151) [`06c0cf3`](https://github.com/thirdweb-dev/js/commit/06c0cf3898419edc79ba042d041612a8ae6967f8) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - update to latest @mobile-wallet-protocol/client
16+
17+
## 1.5.0
18+
19+
### Minor Changes
20+
21+
- [#4992](https://github.com/thirdweb-dev/js/pull/4992) [`1994d9e`](https://github.com/thirdweb-dev/js/commit/1994d9e52d3a3874e6111ff7bc688f95618fbc25) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Updated required dependencies
22+
23+
## 1.4.4
24+
25+
### Patch Changes
26+
27+
- [#4874](https://github.com/thirdweb-dev/js/pull/4874) [`783d844`](https://github.com/thirdweb-dev/js/commit/783d84467d81db856a1f0b3509036bbc612ba7e5) Thanks [@jnsdls](https://github.com/jnsdls)! - update dependencies
28+
29+
## 1.4.3
30+
31+
### Patch Changes
32+
33+
- [#4789](https://github.com/thirdweb-dev/js/pull/4789) [`e384001`](https://github.com/thirdweb-dev/js/commit/e38400195f2644ef8dfcfbce5fa127a9a218247d) Thanks [@MananTank](https://github.com/MananTank)! - Fix whitespaces in UI components
34+
35+
## 1.4.2
36+
37+
### Patch Changes
38+
39+
- [#4665](https://github.com/thirdweb-dev/js/pull/4665) [`6ce7c83`](https://github.com/thirdweb-dev/js/commit/6ce7c83a3b9eb2374ad2f8163d9c6a68bba4bc42) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Update @mobile-wallet-protocol/client to 0.0.3
40+
41+
## 1.4.1
42+
43+
### Patch Changes
44+
45+
- [#4603](https://github.com/thirdweb-dev/js/pull/4603) [`b837b69`](https://github.com/thirdweb-dev/js/commit/b837b690ae27fb8bf45f6cd51820f7591e94dab0) Thanks [@jnsdls](https://github.com/jnsdls)! - bump various dependencies
46+
47+
## 1.4.0
48+
49+
### Minor Changes
50+
51+
- [#4527](https://github.com/thirdweb-dev/js/pull/4527) [`b76a82c`](https://github.com/thirdweb-dev/js/commit/b76a82c30345e06d7b2c203c1e20bf7ec7e0dd9d) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Update React Native dependencies and add support for React Native 0.75
52+
53+
## 1.3.0
54+
55+
### Minor Changes
56+
57+
- [#4094](https://github.com/thirdweb-dev/js/pull/4094) [`f1d087e`](https://github.com/thirdweb-dev/js/commit/f1d087e24e8ad74948c0cdfa85d3705319753850) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Support for Coinbase Smart Wallet in React Native
58+
59+
You can now use the Coinbase Smart Wallet in your React Native apps.
60+
61+
```ts
62+
const wallet = createWallet("com.coinbase.wallet", {
63+
appMetadata: {
64+
name: "My app name",
65+
},
66+
mobileConfig: {
67+
callbackURL: "https://example.com",
68+
},
69+
walletConfig: {
70+
options: "smartWalletOnly",
71+
},
72+
});
73+
74+
await wallet.connect({
75+
client,
76+
});
77+
```
78+
79+
## 1.2.0
80+
81+
### Minor Changes
82+
83+
- [#3271](https://github.com/thirdweb-dev/js/pull/3271) [`3a1fd98`](https://github.com/thirdweb-dev/js/commit/3a1fd985fc4b2720f4d46d54b562c00b2edf21ce) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Align inAppWallet secret sharing implementation with web and previous RN SDK
84+
85+
## 1.1.1
86+
87+
### Patch Changes
88+
89+
- [#3162](https://github.com/thirdweb-dev/js/pull/3162) [`b9b185b`](https://github.com/thirdweb-dev/js/commit/b9b185b665e9cc2085f0cc07e3a3cc06a755b42a) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Add support for CB wallet in react native
90+
91+
## 1.1.0
92+
93+
### Minor Changes
94+
95+
- [#3064](https://github.com/thirdweb-dev/js/pull/3064) [`f55fa4c`](https://github.com/thirdweb-dev/js/commit/f55fa4ca856924a0a1eb6b8e5fe743d76b6e2760) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - In-app wallet support for react native
96+
97+
### Patch Changes
98+
99+
- [#3110](https://github.com/thirdweb-dev/js/pull/3110) [`49aa6e4`](https://github.com/thirdweb-dev/js/commit/49aa6e41d5df93204821b72f17f1ba5c3cfe41f7) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - Phone number sign in for React Native
100+
101+
## 1.0.0
102+
103+
### Major Changes
104+
105+
- [#3037](https://github.com/thirdweb-dev/js/pull/3037) [`f006429`](https://github.com/thirdweb-dev/js/commit/f006429d7c2415e9f2206e081f6b867854842f0b) Thanks [@joaquim-verges](https://github.com/joaquim-verges)! - initial release

packages/wagmi-adapter/README.md

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# React Native Adapter
2+
3+
This package is required to run the thirdweb connect SDK in React Native.
4+
5+
## Instructions
6+
7+
### 1. Install the packages
8+
9+
Using your favorite pacakge manager, install all the require dependencies
10+
11+
```shell
12+
npx expo install thirdweb @thirdweb-dev/react-native-adapter
13+
```
14+
15+
Since react native requires installing native dependencies directly, you also have to install these required peer dependencies:
16+
17+
```shell
18+
npx expo install react-native-get-random-values @react-native-community/netinfo expo-application @react-native-async-storage/async-storage expo-web-browser expo-linking react-native-aes-gcm-crypto [email protected] amazon-cognito-identity-js @coinbase/wallet-mobile-sdk react-native-mmkv react-native-svg @react-native-clipboard/clipboard
19+
```
20+
21+
Here's an explanation of each peer dependency and why its needed:
22+
23+
```
24+
// needed for wallet connect
25+
react-native-get-random-values
26+
@react-native-community/netinfo
27+
expo-application
28+
29+
// needed wallet connect + in-app wallet
30+
@react-native-async-storage/async-storage
31+
32+
// needed for inapp wallet
33+
expo-web-browser // for oauth flows
34+
amazon-cognito-identity-js // for authentication
35+
react-native-aes-gcm-crypto // for encryption
36+
[email protected] //for fast hashing
37+
38+
// needed for the prebuilt UIs
39+
react-native-svg
40+
@react-native-clipboard/clipboard
41+
```
42+
43+
### 2. Edit your `metro.config.js`
44+
45+
If you don't already have a `metro.config.file.js` in your project, you can create one by running:
46+
47+
```shell
48+
npx expo customize metro.config.js
49+
```
50+
51+
Then, you need to add 2 properties to the metro resolver: `unstable_enablePackageExports` and `unstable_conditionNames`. This is to tell metro to resolve named `exports` properly.
52+
53+
```js
54+
// file: metro.config.js
55+
56+
// Learn more https://docs.expo.io/guides/customizing-metro
57+
const { getDefaultConfig } = require("expo/metro-config");
58+
59+
/** @type {import('expo/metro-config').MetroConfig} */
60+
const config = getDefaultConfig(__dirname);
61+
62+
// ADD THESE 2 PROPERTIES
63+
config.resolver.unstable_enablePackageExports = true;
64+
config.resolver.unstable_conditionNames = [
65+
"react-native",
66+
"browser",
67+
"require",
68+
];
69+
70+
module.exports = config;
71+
```
72+
73+
### 3. Import `@thirdweb-dev/react-native-adapter` at the top of your `App.tsx`
74+
75+
This will polyfill all the required functionality needed.
76+
77+
```js
78+
// this needs to be imported before anything else
79+
import "@thirdweb-dev/react-native-adapter";
80+
// the rest of your app
81+
```
82+
83+
If you're using `expo-router`, you need to polyfill before the router entry:
84+
85+
1. create a `app/index.ts`
86+
87+
This will be the new entrypoint to your app, ensuring the polyfills happen before any routing.
88+
89+
```ts
90+
// file: app/index.ts
91+
92+
// this needs to be imported before expo-router
93+
import "@thirdweb-dev/react-native-adapter";
94+
import "expo-router/entry";
95+
```
96+
97+
2. Change your main entrypoint in `package.json`
98+
99+
Now you can replace `expo-router/entry` with `./app/index` as your main entrypoint.
100+
101+
```
102+
// file: package.json
103+
104+
"main": "./app/index",
105+
```
106+
107+
### Additional notes
108+
109+
1. `react-native-aes-gcm-crypto` requires `minSDK 26` for android, you can edit this in your `build.gradle` file
110+
2. You will get some warnings about unresolved exports, this is normal and will get better as the libraries get updated.
111+
112+
113+
### Use the `thirdweb` package in React Native
114+
115+
Once all the setup above is all done, you can use the most of functionality in the `thirdweb` package out of the box, without having to do any react native specific code.
116+
117+
This means that you can follow all the React documentation and expect it all to be exactly the same.
118+
119+
Examples:
120+
121+
```tsx
122+
import { ThirdwebProvider } form "thirdweb/react";
123+
```
124+
125+
### Resources
126+
127+
- [Full working demo](https://github.com/thirdweb-dev/expo-starter)
128+
- [React docs](https://portal.thirdweb.com/typescript/v5/react)
129+
- [TypeScript docs](https://portal.thirdweb.com/typescript/v5)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "@thirdweb-dev/wagmi-adapter",
3+
"version": "1.0.0",
4+
"repository": {
5+
"type": "git",
6+
"url": "git+https://github.com/thirdweb-dev/js.git#main"
7+
},
8+
"license": "Apache-2.0",
9+
"bugs": {
10+
"url": "https://github.com/thirdweb-dev/js/issues"
11+
},
12+
"author": "thirdweb eng <[email protected]>",
13+
"type": "module",
14+
"main": "./dist/cjs/exports/thirdweb.js",
15+
"module": "./dist/esm/exports/thirdweb.js",
16+
"types": "./dist/types/exports/thirdweb.d.ts",
17+
"typings": "./dist/types/exports/thirdweb.d.ts",
18+
"exports": {
19+
".": {
20+
"types": "./dist/types/exports/thirdweb.d.ts",
21+
"import": "./dist/esm/exports/thirdweb.js",
22+
"default": "./dist/cjs/exports/thirdweb.js"
23+
},
24+
"./package.json": "./package.json"
25+
},
26+
"files": ["dist/*", "src/*"],
27+
"dependencies": {},
28+
"devDependencies": {
29+
"@wagmi/core": "2.15.2",
30+
"thirdweb": "workspace:*",
31+
"rimraf": "6.0.1"
32+
},
33+
"peerDependencies": {
34+
"@wagmi/core": "^2",
35+
"thirdweb": "^5",
36+
"typescript": ">=5.0.4"
37+
},
38+
"peerDependenciesMeta": {
39+
"typescript": {
40+
"optional": true
41+
}
42+
},
43+
"scripts": {
44+
"format": "biome format ./src --write",
45+
"lint": "biome check ./src",
46+
"fix": "biome check ./src --fix",
47+
"build": "pnpm clean && pnpm build:cjs && pnpm build:esm && pnpm build:types",
48+
"build:cjs": "tsc --project ./tsconfig.build.json --module commonjs --outDir ./dist/cjs --verbatimModuleSyntax false && printf '{\"type\":\"commonjs\"}' > ./dist/cjs/package.json",
49+
"build:esm": "tsc --project ./tsconfig.build.json --module es2020 --outDir ./dist/esm && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/esm/package.json",
50+
"build:types": "tsc --project ./tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap",
51+
"clean": "rimraf dist"
52+
},
53+
"engines": {
54+
"node": ">=18"
55+
}
56+
}

0 commit comments

Comments
 (0)