@1claw/wallet-react 0.1.0

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.
Files changed (2) hide show
  1. package/README.md +86 -0
  2. package/package.json +39 -0
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # @1claw/wallet-react
2
+
3
+ Embeddable treasury wallet React component for Platform API apps built on 1Claw.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @1claw/wallet-react
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```tsx
14
+ import { OneclawTreasuryWidget } from "@1claw/wallet-react";
15
+
16
+ function App() {
17
+ return (
18
+ <OneclawTreasuryWidget
19
+ apiKey="plt_your_platform_api_key"
20
+ chains={["ethereum", "base"]}
21
+ onTransactionSent={(tx) => console.log("Sent:", tx.txHash)}
22
+ onError={(err) => console.error(err)}
23
+ />
24
+ );
25
+ }
26
+ ```
27
+
28
+ ## Components
29
+
30
+ ### `<OneclawTreasuryWidget />`
31
+
32
+ All-in-one widget that displays wallet balances and allows transfers.
33
+
34
+ | Prop | Type | Required | Description |
35
+ |------|------|----------|-------------|
36
+ | `apiKey` | `string` | Yes | Platform API key (`plt_...`) |
37
+ | `baseUrl` | `string` | No | API base URL (default: `https://api.1claw.xyz`) |
38
+ | `chains` | `string[]` | No | Chains to generate wallets for |
39
+ | `theme` | `"light" \| "dark" \| "auto"` | No | Color theme |
40
+ | `onError` | `(error: Error) => void` | No | Error callback |
41
+ | `onTransactionSent` | `(result) => void` | No | Transaction success callback |
42
+ | `className` | `string` | No | CSS class for outer container |
43
+
44
+ ### `<OneclawWalletProvider />`
45
+
46
+ Lower-level provider for building custom UI:
47
+
48
+ ```tsx
49
+ import { OneclawWalletProvider, useOneclawWallet } from "@1claw/wallet-react";
50
+
51
+ function CustomWalletUI() {
52
+ const { wallets, balances, send, refreshBalance } = useOneclawWallet();
53
+ // Build your own UI...
54
+ }
55
+
56
+ function App() {
57
+ return (
58
+ <OneclawWalletProvider apiKey="plt_...">
59
+ <CustomWalletUI />
60
+ </OneclawWalletProvider>
61
+ );
62
+ }
63
+ ```
64
+
65
+ ## Hooks
66
+
67
+ ### `useOneclawWallet()`
68
+
69
+ Returns:
70
+
71
+ | Field | Type | Description |
72
+ |-------|------|-------------|
73
+ | `wallets` | `WalletInfo[]` | Active wallets |
74
+ | `balances` | `Record<string, WalletBalance>` | Cached balances by chain |
75
+ | `loading` | `boolean` | Initial load state |
76
+ | `error` | `Error \| null` | Last error |
77
+ | `refreshWallets()` | `() => Promise<void>` | Refetch wallet list |
78
+ | `refreshBalance(chain)` | `(chain: string) => Promise<WalletBalance>` | Fetch balance |
79
+ | `generateWallets(chains?)` | `(chains?: string[]) => Promise<WalletInfo[]>` | Generate new wallets |
80
+ | `send(params)` | `(params: SendTransactionParams) => Promise<SendTransactionResult>` | Send a transaction |
81
+
82
+ ## Security
83
+
84
+ - The `apiKey` is a Platform API key, not a user key — it inherits platform custody guarantees.
85
+ - Sends require password re-authentication via the `password` field in `SendTransactionParams`.
86
+ - The widget never stores or caches private keys client-side.
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@1claw/wallet-react",
3
+ "version": "0.1.0",
4
+ "description": "Embeddable treasury wallet component for Platform API apps built on 1Claw",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": ["dist"],
16
+ "scripts": {
17
+ "build": "tsup src/index.ts --format cjs,esm --dts",
18
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
19
+ "lint": "tsc --noEmit"
20
+ },
21
+ "peerDependencies": {
22
+ "react": ">=18.0.0",
23
+ "react-dom": ">=18.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/react": "^19.0.0",
27
+ "react": "^19.0.0",
28
+ "react-dom": "^19.0.0",
29
+ "tsup": "^8.0.0",
30
+ "typescript": "^5.6.0"
31
+ },
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/1clawAI/1claw",
36
+ "directory": "packages/wallet-react"
37
+ },
38
+ "keywords": ["1claw", "wallet", "treasury", "react", "crypto", "embedded"]
39
+ }