@mocanetwork/airkit-connector 1.4.0-beta.2 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +152 -64
- package/dist/airkitConnector.cjs.js +1 -1
- package/dist/airkitConnector.esm.js +1 -1
- package/dist/airkitConnector.umd.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,85 +1,173 @@
|
|
|
1
|
-
|
|
2
|
-
<img src="https://web3auth.io/images/w3a-L-Favicon-1.svg" align="center" alt="Ledger" />
|
|
3
|
-
<h2 align="center">Web3Auth Mocaverse Embed Wagmi Connector</h2>
|
|
4
|
-
<p align="center"><a href="https://github.com/tmm/wagmi">Wagmi</a> Connector for Web3Auth Mocaverse Embed</p>
|
|
5
|
-
</p>
|
|
1
|
+
# Air Kit Wagmi Connector
|
|
6
2
|
|
|
7
|
-
[
|
|
8
|
-

|
|
3
|
+
This connector is part of the [Moca Network](https://moca.network/) offering and provides seamless integration between the Air Kit SDK and the popular [wagmi](https://wagmi.sh/) library for React applications.
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
## ⚡ Quick Start
|
|
11
6
|
|
|
12
|
-
|
|
7
|
+
```shell
|
|
8
|
+
npm install @mocanetwork/airkit-connector
|
|
9
|
+
```
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
### Initialize & Connect
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
```ts
|
|
14
|
+
import { createConfig, http } from "wagmi";
|
|
15
|
+
import { mainnet, polygon } from "wagmi/chains";
|
|
16
|
+
import { airConnector } from "@mocanetwork/airkit-connector";
|
|
17
|
+
import { BUILD_ENV } from "@mocanetwork/airkit";
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
const config = createConfig({
|
|
20
|
+
chains: [mainnet, polygon],
|
|
21
|
+
transports: {
|
|
22
|
+
[mainnet.id]: http(),
|
|
23
|
+
[polygon.id]: http(),
|
|
24
|
+
},
|
|
25
|
+
connectors: [
|
|
26
|
+
airConnector({
|
|
27
|
+
partnerId: YOUR_PARTNER_ID,
|
|
28
|
+
buildEnv: BUILD_ENV.SANDBOX,
|
|
29
|
+
enableLogging: true,
|
|
30
|
+
})
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
```
|
|
19
34
|
|
|
20
|
-
|
|
21
|
-
- Fully decentralized, non-custodial key infrastructure
|
|
22
|
-
- Multi Party Computation + Account Abstraction based key management
|
|
23
|
-
- Multi Factor Authentication Setup & Recovery (Includes password, backup phrase, device factor editing/deletion etc)
|
|
24
|
-
- Support for connecting to external wallets like Metamask
|
|
25
|
-
- DApp Active Session Management
|
|
35
|
+
The `airConnector` integrates the Air Kit SDK with wagmi, providing a familiar wagmi interface while leveraging the full power of Air Account Login, Air Id Minting, and Air Account Management.
|
|
26
36
|
|
|
27
|
-
|
|
37
|
+
## 🔗 Installation
|
|
28
38
|
|
|
29
|
-
|
|
39
|
+
### Dependencies
|
|
30
40
|
|
|
31
|
-
|
|
41
|
+
This connector requires the following peer dependencies:
|
|
32
42
|
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
import { MocaverseConnector } from "@web3auth/mocaverse-wagmi-connector";
|
|
43
|
+
```shell
|
|
44
|
+
npm install @wagmi/core viem
|
|
45
|
+
```
|
|
37
46
|
|
|
38
|
-
|
|
47
|
+
### Bundling
|
|
39
48
|
|
|
49
|
+
This module is distributed in multiple formats:
|
|
40
50
|
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
- `esm` build `dist/airkitConnector.esm.js` in es6 format
|
|
52
|
+
- `commonjs` build `dist/airkitConnector.cjs.js` in es5 format
|
|
53
|
+
- `umd` build `dist/airkitConnector.umd.min.js` in es5 format minified
|
|
43
54
|
|
|
44
|
-
|
|
45
|
-
chainNamespace: CHAIN_NAMESPACES.EIP155,
|
|
46
|
-
chainId: `0x${polygon.id.toString(16)}`,
|
|
47
|
-
rpcTarget: polygon.rpcUrls.default.http[0], // This is the public RPC we have added, please pass on your own endpoint while creating an app
|
|
48
|
-
displayName: polygon.name,
|
|
49
|
-
tickerName: polygon.nativeCurrency?.name,
|
|
50
|
-
ticker: polygon.nativeCurrency?.symbol,
|
|
51
|
-
blockExplorerUrl: polygon.blockExplorers?.default.url[0] as string,
|
|
52
|
-
logo: "https://cryptologos.cc/logos/polygon-matic-logo.png",
|
|
53
|
-
};
|
|
55
|
+
By default, the appropriate format is used for your specified use case.
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
Once the connector is configured with your wagmi client, you can use all standard wagmi hooks and functions while the connector handles the Air Kit integration behind the scenes.
|
|
60
|
+
|
|
61
|
+
### Basic Connection Example
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { useConnect, useAccount, useDisconnect } from "wagmi";
|
|
65
|
+
import { airConnector } from "@mocanetwork/airkit-connector";
|
|
66
|
+
|
|
67
|
+
function App() {
|
|
68
|
+
const { connect, connectors } = useConnect();
|
|
69
|
+
const { address, isConnected } = useAccount();
|
|
70
|
+
const { disconnect } = useDisconnect();
|
|
71
|
+
|
|
72
|
+
const handleConnect = () => {
|
|
73
|
+
connect({ connector: connectors[0] });
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div>
|
|
78
|
+
{isConnected ? (
|
|
79
|
+
<div>
|
|
80
|
+
<p>Connected to {address}</p>
|
|
81
|
+
<button onClick={() => disconnect()}>Disconnect</button>
|
|
82
|
+
</div>
|
|
83
|
+
) : (
|
|
84
|
+
<button onClick={handleConnect}>Connect with Air Kit</button>
|
|
85
|
+
)}
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Advanced Connection with Auth Token
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { useConnect } from "wagmi";
|
|
95
|
+
import { airConnector } from "@mocanetwork/airkit-connector";
|
|
96
|
+
|
|
97
|
+
function App() {
|
|
98
|
+
const { connect, connectors } = useConnect();
|
|
99
|
+
|
|
100
|
+
const handleConnectWithAuth = () => {
|
|
101
|
+
// Connect with a pre-existing auth token
|
|
102
|
+
connect({
|
|
103
|
+
connector: connectors[0],
|
|
104
|
+
chainId: 1, // Optional: specify chain
|
|
105
|
+
authToken: "your-auth-token" // Optional: pass auth token
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<button onClick={handleConnectWithAuth}>
|
|
111
|
+
Connect with Auth Token
|
|
112
|
+
</button>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Chain Switching
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import { useSwitchChain } from "wagmi";
|
|
121
|
+
|
|
122
|
+
function ChainSwitcher() {
|
|
123
|
+
const { switchChain } = useSwitchChain();
|
|
124
|
+
|
|
125
|
+
const switchToPolygon = () => {
|
|
126
|
+
switchChain({ chainId: 137 }); // Polygon
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<button onClick={switchToPolygon}>
|
|
131
|
+
Switch to Polygon
|
|
132
|
+
</button>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## 🔧 Configuration
|
|
138
|
+
|
|
139
|
+
The `airConnector` accepts the following configuration parameters:
|
|
140
|
+
|
|
141
|
+
```ts
|
|
142
|
+
interface AirConnectorParams {
|
|
143
|
+
partnerId: string; // Required: Your Moca Network partner ID
|
|
144
|
+
buildEnv: BUILD_ENV; // Required: Environment (staging, production, etc.)
|
|
145
|
+
enableLogging: boolean; // Required: Enable/disable logging
|
|
146
|
+
loginOptions?: {
|
|
147
|
+
authToken?: string; // Optional: Pre-existing auth token
|
|
148
|
+
};
|
|
149
|
+
}
|
|
75
150
|
```
|
|
76
151
|
|
|
77
|
-
##
|
|
152
|
+
## 🚀 Features
|
|
153
|
+
|
|
154
|
+
- **Seamless Integration**: Works with all wagmi hooks and functions
|
|
155
|
+
- **Air Kit Power**: Full access to Air Account Login, Air Id Minting, and Account Management
|
|
156
|
+
- **Chain Support**: Automatic chain switching and network management
|
|
157
|
+
- **Session Management**: Handles Air Kit session lifecycle within wagmi
|
|
158
|
+
- **TypeScript Support**: Full TypeScript support with proper type definitions
|
|
159
|
+
|
|
160
|
+
## 📚 Examples
|
|
161
|
+
|
|
162
|
+
For complete examples and integration patterns, check out the [Air Kit documentation](https://docs.moca.network/) and the [wagmi documentation](https://wagmi.sh/).
|
|
163
|
+
|
|
164
|
+
### Live Example
|
|
78
165
|
|
|
79
|
-
|
|
166
|
+
- **[Deployed Example App](https://developers.sandbox.air3.com/example)** - See the Air Kit Connector in action
|
|
167
|
+
- **[Source Code](https://github.com/MocaNetwork/airkit-example)** - Complete React + TypeScript example with wagmi integration
|
|
80
168
|
|
|
81
|
-
##
|
|
169
|
+
## 🔗 Related
|
|
82
170
|
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
171
|
+
- [Air Kit SDK](https://github.com/mocanetwork/airkit) - The main Air Kit SDK
|
|
172
|
+
- [wagmi](https://wagmi.sh/) - React Hooks for Ethereum
|
|
173
|
+
- [Moca Network](https://moca.network/) - Learn more about Moca Network
|
|
@@ -94,7 +94,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
94
94
|
var e = new Error(message);
|
|
95
95
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
96
96
|
};
|
|
97
|
-
var version$2 = "1.4.0-beta.
|
|
97
|
+
var version$2 = "1.4.0-beta.1";
|
|
98
98
|
var airkitPackage = {
|
|
99
99
|
version: version$2
|
|
100
100
|
};
|
|
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
92
92
|
var e = new Error(message);
|
|
93
93
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
94
94
|
};
|
|
95
|
-
var version$2 = "1.4.0-beta.
|
|
95
|
+
var version$2 = "1.4.0-beta.1";
|
|
96
96
|
var airkitPackage = {
|
|
97
97
|
version: version$2
|
|
98
98
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mocanetwork/airkit-connector",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "AirKit wagmi connector to connect with the AirService",
|
|
5
5
|
"main": "dist/airkitConnector.cjs.js",
|
|
6
6
|
"unpkg": "dist/airkitConnector.umd.min.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"pre-commit": "lint-staged --cwd ."
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@mocanetwork/airkit": "^1.4.
|
|
26
|
+
"@mocanetwork/airkit": "^1.4.2",
|
|
27
27
|
"@wagmi/core": "^2.x",
|
|
28
28
|
"loglevel": "^1.8.1",
|
|
29
29
|
"viem": "^2.x"
|