@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 CHANGED
@@ -1,85 +1,173 @@
1
- <p align="center">
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
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
8
- ![npm](https://img.shields.io/npm/dw/@web3auth/mocaverse-wagmi-connector)
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
- `@web3auth/mocaverse-wagmi-connector` is a connector for the popular [wagmi](https://github.com/tmm/wagmi) library and Web3Auth Wallet Ecosystems, Mocaverse Embed SDK.
5
+ ## Quick Start
11
6
 
12
- It can be used to initialize a [wagmi client](https://wagmi.sh/docs/client) that will seemlessly manage the interaction of your DApp with Torus Wallet.
7
+ ```shell
8
+ npm install @mocanetwork/airkit-connector
9
+ ```
13
10
 
14
- ## 📖 Documentation
11
+ ### Initialize & Connect
15
12
 
16
- Checkout the official [Web3Auth Documentation](https://web3auth.io/docs) and [SDK Reference](https://web3auth.io/docs/sdk/) to get started!
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
- ## 💡 Features
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
- - Plug and Play, OAuth based Web3 Authentication Service
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
- ...and a lot more
37
+ ## 🔗 Installation
28
38
 
29
- ## How to use
39
+ ### Dependencies
30
40
 
31
- Here is an example of a wagmi client using the `MocaverseConnector`.
41
+ This connector requires the following peer dependencies:
32
42
 
33
- ```js
34
- import { WagmiProvider, createConfig, http } from "wagmi";
35
- import { polygon, optimism, polygonMumbai } from "wagmi/chains";
36
- import { MocaverseConnector } from "@web3auth/mocaverse-wagmi-connector";
43
+ ```shell
44
+ npm install @wagmi/core viem
45
+ ```
37
46
 
38
- import { CHAIN_NAMESPACES, WEB3AUTH_NETWORK } from "@web3auth/base";
47
+ ### Bundling
39
48
 
49
+ This module is distributed in multiple formats:
40
50
 
41
- const web3AuthClientId =
42
- "BANbxuTYFGeYi8HxUzaPQkvQlSAXiKRtUqb1vqsXbsZsZKrNr05PEPCM2J2PhUJZpIYl0XzQa6jxUjnYzSU9LXY";
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
- const chainConfig = {
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
- // Set up client
56
- const config = createConfig({
57
- chains: [polygon, optimism, polygonMumbai],
58
- transports: {
59
- [polygon.id]: http(),
60
- [optimism.id]: http(),
61
- [polygonMumbai.id]: http(),
62
- },
63
- connectors: [
64
- MocaverseConnector({
65
- web3AuthClientId,
66
- web3AuthNetwork: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
67
- initParams: {
68
- buildEnv: "testing",
69
- chainConfig,
70
- enableLogging: true,
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
- ## 🩹 Examples
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
- Checkout the examples for your preferred blockchain and platform in our [examples repository](https://github.com/Web3Auth/wallet-ecosystems-examples/)
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
- ## 💬 Troubleshooting and Support
169
+ ## 🔗 Related
82
170
 
83
- - Have a look at our [Community Portal](https://community.web3auth.io/) to see if anyone has any questions or issues you might be having. Feel free to reate new topics and we'll help you out as soon as possible.
84
- - Checkout our [Troubleshooting Documentation Page](https://web3auth.io/docs/troubleshooting) to know the common issues and solutions.
85
- - For Priority Support, please have a look at our [Pricing Page](https://web3auth.io/pricing.html) for the plan that suits your needs
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.2";
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.2";
95
+ var version$2 = "1.4.0-beta.1";
96
96
  var airkitPackage = {
97
97
  version: version$2
98
98
  };
@@ -98,7 +98,7 @@
98
98
  var e = new Error(message);
99
99
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
100
100
  };
101
- var version$2 = "1.4.0-beta.2";
101
+ var version$2 = "1.4.0-beta.1";
102
102
  var airkitPackage = {
103
103
  version: version$2
104
104
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mocanetwork/airkit-connector",
3
- "version": "1.4.0-beta.2",
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.0-beta.2",
26
+ "@mocanetwork/airkit": "^1.4.2",
27
27
  "@wagmi/core": "^2.x",
28
28
  "loglevel": "^1.8.1",
29
29
  "viem": "^2.x"