@avalabs/avacloud-waas-react 1.0.9 → 1.0.12

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
@@ -73,9 +73,9 @@ The main provider component that wraps your application and provides wallet cont
73
73
 
74
74
  ```tsx
75
75
  <AvaCloudWalletProvider
76
- orgId="your-avacloud-org-id" // Required
77
- chainId={43113}
78
- darkMode={false}
76
+ orgId="your-avacloud-org-id" // Required - your AvaCloud organization ID
77
+ chainId={43113} // Optional - defaults to Avalanche Fuji Testnet
78
+ darkMode={false} // Optional - theme mode for UI components
79
79
  onAuthSuccess={(user) => console.log('Auth success', user)}
80
80
  onAuthError={(error) => console.error('Auth error', error)}
81
81
  onWalletUpdate={(wallet) => console.log('Wallet updated', wallet)}
@@ -88,13 +88,13 @@ The main provider component that wraps your application and provides wallet cont
88
88
 
89
89
  | Prop | Type | Description |
90
90
  |------|------|-------------|
91
- | `orgId` | `string` | Required AvaCloud organization ID |
92
- | `env` | `'local' \| 'development' \| 'prod'` | (Optional) Environment to use. Defaults to 'prod'. |
93
- | `chainId` | `number` | (Optional) EVM chain ID to use (defaults to Avalanche Fuji Testnet - 43113) |
94
- | `darkMode` | `boolean` | (Optional) Whether to use dark mode for UI components |
95
- | `onAuthSuccess` | `(user: Auth0User) => void` | (Optional) Callback called when authentication is successful |
96
- | `onAuthError` | `(error: Error) => void` | (Optional) Callback called when authentication fails |
97
- | `onWalletUpdate` | `(wallet: WalletInfo) => void` | (Optional) Callback called when wallet information is updated |
91
+ | `orgId` | `string` | **Required** - Your AvaCloud organization ID used to fetch wallet configuration |
92
+ | `env` | `'local' \| 'development' \| 'prod'` | Environment to use (default: `'prod'`) |
93
+ | `chainId` | `number` | EVM chain ID (default: `43113` - Avalanche Fuji Testnet) |
94
+ | `darkMode` | `boolean` | Enable dark mode for UI components (default: `false`) |
95
+ | `onAuthSuccess` | `(user: Auth0User) => void` | Callback on successful authentication |
96
+ | `onAuthError` | `(error: Error) => void` | Callback on authentication error |
97
+ | `onWalletUpdate` | `(wallet: WalletInfo) => void` | Callback when wallet information updates |
98
98
 
99
99
  ### UI Components
100
100
 
@@ -209,6 +209,100 @@ Hook for accessing and setting the current chain ID.
209
209
  const { chainId, setChainId } = useChainId();
210
210
  ```
211
211
 
212
+ ## WAGMI Integration
213
+
214
+ This SDK includes a WAGMI connector that allows you to use AvaCloud wallets with WAGMI (React Ethereum Library).
215
+
216
+ ### Prerequisites
217
+
218
+ Install the required WAGMI dependencies:
219
+
220
+ ```bash
221
+ npm install wagmi viem@2.x @tanstack/react-query
222
+ ```
223
+
224
+ ### Setting up WAGMI with AvaCloud
225
+
226
+ ```tsx
227
+ import { WagmiProvider, createConfig } from 'wagmi';
228
+ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
229
+ import { avaCloudWallet } from '@avalabs/avacloud-waas-react';
230
+ import { avalancheFuji } from 'wagmi/chains';
231
+ import { http } from 'wagmi';
232
+
233
+ const queryClient = new QueryClient();
234
+
235
+ const config = createConfig({
236
+ chains: [avalancheFuji],
237
+ connectors: [
238
+ avaCloudWallet(),
239
+ ],
240
+ transports: {
241
+ [avalancheFuji.id]: http(),
242
+ },
243
+ });
244
+
245
+ function App() {
246
+ return (
247
+ <QueryClientProvider client={queryClient}>
248
+ <WagmiProvider config={config}>
249
+ <AvaCloudWalletProvider orgId="your-avacloud-org-id">
250
+ <YourApp />
251
+ </AvaCloudWalletProvider>
252
+ </WagmiProvider>
253
+ </QueryClientProvider>
254
+ );
255
+ }
256
+ ```
257
+
258
+ ### Using WAGMI Hooks
259
+
260
+ Once configured, use standard WAGMI hooks with your AvaCloud wallet:
261
+
262
+ ```tsx
263
+ import { useAccount, useConnect, useDisconnect, useSignMessage } from 'wagmi';
264
+
265
+ function WagmiExample() {
266
+ const { address, isConnected } = useAccount();
267
+ const { connect, connectors } = useConnect();
268
+ const { disconnect } = useDisconnect();
269
+ const { signMessage } = useSignMessage();
270
+
271
+ const handleConnect = () => {
272
+ const avaCloudConnector = connectors.find(c => c.id === 'avaCloudWallet');
273
+ if (avaCloudConnector) {
274
+ connect({ connector: avaCloudConnector });
275
+ }
276
+ };
277
+
278
+ const handleSign = async () => {
279
+ const signature = await signMessage({ message: 'Hello from WAGMI!' });
280
+ console.log('Signature:', signature);
281
+ };
282
+
283
+ return (
284
+ <div>
285
+ {isConnected ? (
286
+ <>
287
+ <p>Connected: {address}</p>
288
+ <button onClick={() => disconnect()}>Disconnect</button>
289
+ <button onClick={handleSign}>Sign Message</button>
290
+ </>
291
+ ) : (
292
+ <button onClick={handleConnect}>Connect AvaCloud Wallet</button>
293
+ )}
294
+ </div>
295
+ );
296
+ }
297
+ ```
298
+
299
+ ### Important Notes
300
+
301
+ - The AvaCloud WAGMI connector requires the `AvaCloudWalletProvider` to be present in your component tree
302
+ - Authentication is still managed through the AvaCloud SDK's authentication flow
303
+ - The connector automatically syncs with the wallet state from `AvaCloudWalletProvider`
304
+ - All standard WAGMI hooks and functionality are supported
305
+
212
306
  ## Advanced Usage
213
307
 
214
308
  ### Theme Customization
@@ -274,30 +368,4 @@ We welcome contributions! Please see [CONTRIBUTING.md](https://github.com/ava-la
274
368
 
275
369
  ## License
276
370
 
277
- MIT © [Ava Labs, Inc.](https://github.com/ava-labs)
278
-
279
- ## Using the AvaCloud Organization ID
280
-
281
- The `AvaCloudWalletProvider` requires an AvaCloud organization ID (`orgId`). This is used to fetch the organization configuration from the AvaCloud API, which includes the mapping to the appropriate wallet service organization ID used for wallet operations.
282
-
283
- ```jsx
284
- import { AvaCloudWalletProvider } from '@avalabs/avacloud-waas-react';
285
-
286
- function App() {
287
- return (
288
- <AvaCloudWalletProvider
289
- orgId="your-avacloud-org-id" // Required AvaCloud organization ID
290
- >
291
- <YourApp />
292
- </AvaCloudWalletProvider>
293
- );
294
- }
295
- ```
296
-
297
- When provided, the `orgId` will be used to:
298
-
299
- 1. Fetch the organization configuration from the AvaCloud API
300
- 2. Map to the appropriate wallet service organization ID
301
- 3. Use the mapped ID for wallet operations
302
-
303
- This enables organizations to have their AvaCloud identity seamlessly map to their WaaS wallets.
371
+ MIT © [Ava Labs, Inc.](https://github.com/ava-labs)
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _cubist_labs_cubesigner_sdk from '@cubist-labs/cubesigner-sdk';
3
- import { IdentityProof, CubeSignerClient } from '@cubist-labs/cubesigner-sdk';
3
+ import { CubeSignerClient, IdentityProof } from '@cubist-labs/cubesigner-sdk';
4
4
  import { PropsWithChildren, ButtonHTMLAttributes } from 'react';
5
5
  import { ButtonProps } from '@avalabs/core-k2-components';
6
- import { Hex, TransactionRequest, Signature, Hash } from 'viem';
6
+ import { Hex, Signature, TransactionRequest, Hash } from 'viem';
7
+ import { CreateConnectorFn } from '@wagmi/core';
7
8
 
8
9
  /**
9
10
  * Cubist wallet information
@@ -518,4 +519,6 @@ interface UseUserWalletsResult {
518
519
  }
519
520
  declare function useUserWallets(): UseUserWalletsResult;
520
521
 
521
- export { type AddAccountMessage, type AdminPortalSettings, type Auth0User, type AuthMessage, type AuthMessagePayload, type AuthStateUpdateMessage, type AuthStatusMessage, type AvaCloudEnvironment, type AvaCloudWalletContextType, AvaCloudWalletProvider, type AvaCloudWalletProviderProps, type BaseAuthMessage, type CheckAuthStatusMessage, type CubistWalletInfo, type ErrorMessage, ExportView, type GetOidcMessage, type IframeReadyMessage, LoginButton, type LoginRequestMessage, type LogoutRequestMessage, type MessageType, type OrgConfig, type ReceiveOidcMessage, ReceiveView, type RegisterMessage, type RegisterPayload, type RegisterSuccessMessage, SendView, type SignupRequestMessage, ThemeProvider, TokensView, type UserInfo, UserProfile, VM, WalletButton, WalletCard, WalletDisplay, type WalletInfo, type WalletKeysErrorMessage, type WalletKeysUpdateMessage, useAuth, useAvaCloudWallet, useChainId, usePostMessage, useSignMessage, useSignTransaction, useThemeMode, useTransferTokens, useUserWallets };
522
+ declare function avaCloudWallet(): CreateConnectorFn;
523
+
524
+ export { type AddAccountMessage, type AdminPortalSettings, type Auth0User, type AuthMessage, type AuthMessagePayload, type AuthStateUpdateMessage, type AuthStatusMessage, type AvaCloudEnvironment, type AvaCloudWalletContextType, AvaCloudWalletProvider, type AvaCloudWalletProviderProps, type BaseAuthMessage, type CheckAuthStatusMessage, type CubistWalletInfo, type ErrorMessage, ExportView, type GetOidcMessage, type IframeReadyMessage, LoginButton, type LoginRequestMessage, type LogoutRequestMessage, type MessageType, type OrgConfig, type ReceiveOidcMessage, ReceiveView, type RegisterMessage, type RegisterPayload, type RegisterSuccessMessage, SendView, type SignupRequestMessage, ThemeProvider, TokensView, type UserInfo, UserProfile, VM, WalletButton, WalletCard, WalletDisplay, type WalletInfo, type WalletKeysErrorMessage, type WalletKeysUpdateMessage, avaCloudWallet, useAuth, useAvaCloudWallet, useChainId, usePostMessage, useSignMessage, useSignTransaction, useThemeMode, useTransferTokens, useUserWallets };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import * as _cubist_labs_cubesigner_sdk from '@cubist-labs/cubesigner-sdk';
3
- import { IdentityProof, CubeSignerClient } from '@cubist-labs/cubesigner-sdk';
3
+ import { CubeSignerClient, IdentityProof } from '@cubist-labs/cubesigner-sdk';
4
4
  import { PropsWithChildren, ButtonHTMLAttributes } from 'react';
5
5
  import { ButtonProps } from '@avalabs/core-k2-components';
6
- import { Hex, TransactionRequest, Signature, Hash } from 'viem';
6
+ import { Hex, Signature, TransactionRequest, Hash } from 'viem';
7
+ import { CreateConnectorFn } from '@wagmi/core';
7
8
 
8
9
  /**
9
10
  * Cubist wallet information
@@ -518,4 +519,6 @@ interface UseUserWalletsResult {
518
519
  }
519
520
  declare function useUserWallets(): UseUserWalletsResult;
520
521
 
521
- export { type AddAccountMessage, type AdminPortalSettings, type Auth0User, type AuthMessage, type AuthMessagePayload, type AuthStateUpdateMessage, type AuthStatusMessage, type AvaCloudEnvironment, type AvaCloudWalletContextType, AvaCloudWalletProvider, type AvaCloudWalletProviderProps, type BaseAuthMessage, type CheckAuthStatusMessage, type CubistWalletInfo, type ErrorMessage, ExportView, type GetOidcMessage, type IframeReadyMessage, LoginButton, type LoginRequestMessage, type LogoutRequestMessage, type MessageType, type OrgConfig, type ReceiveOidcMessage, ReceiveView, type RegisterMessage, type RegisterPayload, type RegisterSuccessMessage, SendView, type SignupRequestMessage, ThemeProvider, TokensView, type UserInfo, UserProfile, VM, WalletButton, WalletCard, WalletDisplay, type WalletInfo, type WalletKeysErrorMessage, type WalletKeysUpdateMessage, useAuth, useAvaCloudWallet, useChainId, usePostMessage, useSignMessage, useSignTransaction, useThemeMode, useTransferTokens, useUserWallets };
522
+ declare function avaCloudWallet(): CreateConnectorFn;
523
+
524
+ export { type AddAccountMessage, type AdminPortalSettings, type Auth0User, type AuthMessage, type AuthMessagePayload, type AuthStateUpdateMessage, type AuthStatusMessage, type AvaCloudEnvironment, type AvaCloudWalletContextType, AvaCloudWalletProvider, type AvaCloudWalletProviderProps, type BaseAuthMessage, type CheckAuthStatusMessage, type CubistWalletInfo, type ErrorMessage, ExportView, type GetOidcMessage, type IframeReadyMessage, LoginButton, type LoginRequestMessage, type LogoutRequestMessage, type MessageType, type OrgConfig, type ReceiveOidcMessage, ReceiveView, type RegisterMessage, type RegisterPayload, type RegisterSuccessMessage, SendView, type SignupRequestMessage, ThemeProvider, TokensView, type UserInfo, UserProfile, VM, WalletButton, WalletCard, WalletDisplay, type WalletInfo, type WalletKeysErrorMessage, type WalletKeysUpdateMessage, avaCloudWallet, useAuth, useAvaCloudWallet, useChainId, usePostMessage, useSignMessage, useSignTransaction, useThemeMode, useTransferTokens, useUserWallets };