@rocketh/web 0.17.16 → 0.17.17

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 +198 -3
  2. package/package.json +6 -5
package/README.md CHANGED
@@ -1,7 +1,202 @@
1
1
  # @rocketh/web
2
2
 
3
- Rocketh for web browsers, enabling you to run deployment scripts and interact with smart contracts directly in web applications.
3
+ Browser-compatible deployment execution for Rocketh. This package allows you to run Rocketh deploy scripts directly in web browsers.
4
4
 
5
- For full documentation, visit [rocketh.dev](https://rocketh.dev).
5
+ ## Features
6
6
 
7
- For hardhat-deploy documentation, see [rocketh.dev/hardhat-deploy/](https://rocketh.dev/hardhat-deploy/).
7
+ - 🌐 **Browser-First** - Execute deploy scripts in any web browser
8
+ - 💾 **IndexedDB Storage** - Load deployments from browser storage (planned)
9
+ - 🔌 **Wallet Integration** - Works with browser wallet providers
10
+ - 🔧 **Full Rocketh Compatibility** - Same API as Node.js environment
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ # Using pnpm
16
+ pnpm add @rocketh/web
17
+
18
+ # Using npm
19
+ npm install @rocketh/web
20
+
21
+ # Using yarn
22
+ yarn add @rocketh/web
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### Setting Up the Environment
28
+
29
+ ```typescript
30
+ import { setupEnvironment } from '@rocketh/web';
31
+ import { config, extensions } from './rocketh/config.js';
32
+
33
+ const { loadAndExecuteDeploymentsFromModules, loadEnvironment } = setupEnvironment(config, extensions);
34
+ ```
35
+
36
+ ### Loading an Environment
37
+
38
+ Use `loadEnvironment` to create an environment without executing deploy scripts:
39
+
40
+ ```typescript
41
+ import { setupEnvironment } from '@rocketh/web';
42
+ import { config, extensions } from './rocketh/config.js';
43
+
44
+ const { loadEnvironment } = setupEnvironment(config, extensions);
45
+
46
+ // Connect to a network via the browser provider
47
+ const env = await loadEnvironment({
48
+ environment: 'mainnet',
49
+ provider: window.ethereum, // Use browser wallet provider
50
+ });
51
+
52
+ // Access deployments
53
+ const myContract = env.get('MyContract');
54
+ console.log('Contract address:', myContract.address);
55
+ ```
56
+
57
+ ### Executing Deploy Scripts
58
+
59
+ Use `loadAndExecuteDeploymentsFromModules` to run deploy scripts in the browser:
60
+
61
+ ```typescript
62
+ import { setupEnvironment } from '@rocketh/web';
63
+ import { config, extensions } from './rocketh/config.js';
64
+ import deployMyContract from './deploy/deploy_MyContract.js';
65
+
66
+ const { loadAndExecuteDeploymentsFromModules } = setupEnvironment(config, extensions);
67
+
68
+ // Execute deploy scripts
69
+ const env = await loadAndExecuteDeploymentsFromModules(
70
+ [
71
+ { id: 'deploy_MyContract', module: deployMyContract },
72
+ ],
73
+ {
74
+ environment: 'sepolia',
75
+ provider: window.ethereum,
76
+ }
77
+ );
78
+ ```
79
+
80
+ ### Loading Deployments from IndexedDB
81
+
82
+ ```typescript
83
+ import { loadDeploymentsFromIndexedDB } from '@rocketh/web';
84
+
85
+ const { deployments, migrations, chainId, genesisHash } = await loadDeploymentsFromIndexedDB(
86
+ 'deployments',
87
+ 'mainnet',
88
+ true, // onlyABIAndAddress - load minimal data
89
+ {
90
+ chainId: '1',
91
+ genesisHash: '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3',
92
+ }
93
+ );
94
+ ```
95
+
96
+ ## API Reference
97
+
98
+ ### `setupEnvironment(config, extensions)`
99
+
100
+ Creates environment helpers for browser deployment.
101
+
102
+ **Parameters:**
103
+ - `config` - Rocketh user configuration
104
+ - `extensions` - Extension functions (e.g., deploy, read, execute)
105
+
106
+ **Returns:**
107
+ - `loadAndExecuteDeploymentsFromModules` - Execute deploy scripts
108
+ - `loadEnvironment` - Load environment without executing scripts
109
+
110
+ ### `loadDeploymentsFromIndexedDB(deploymentsPath, networkName, onlyABIAndAddress?, expectedChain?)`
111
+
112
+ Loads deployments from IndexedDB storage.
113
+
114
+ **Parameters:**
115
+ - `deploymentsPath` - Path/key for deployments in storage
116
+ - `networkName` - Name of the network/environment
117
+ - `onlyABIAndAddress` - If true, load only essential data
118
+ - `expectedChain` - Optional chain validation
119
+
120
+ **Returns:**
121
+ - `deployments` - Record of deployed contracts
122
+ - `migrations` - Record of executed migrations
123
+ - `chainId` - Chain ID string
124
+ - `genesisHash` - Genesis block hash
125
+
126
+ ## Use Cases
127
+
128
+ ### In-Browser Deployment Tools
129
+
130
+ Build deployment dashboards that allow users to deploy contracts directly from the browser:
131
+
132
+ ```typescript
133
+ async function deployFromBrowser() {
134
+ const { loadAndExecuteDeploymentsFromModules } = setupEnvironment(config, extensions);
135
+
136
+ try {
137
+ const env = await loadAndExecuteDeploymentsFromModules(
138
+ deployModules,
139
+ {
140
+ environment: 'sepolia',
141
+ provider: window.ethereum,
142
+ tags: ['MyContract'], // Deploy specific tags
143
+ }
144
+ );
145
+
146
+ console.log('Deployment complete!');
147
+ return env.deployments;
148
+ } catch (error) {
149
+ console.error('Deployment failed:', error);
150
+ }
151
+ }
152
+ ```
153
+
154
+ ### DApp Development
155
+
156
+ Load existing deployments in your DApp frontend:
157
+
158
+ ```typescript
159
+ import { setupEnvironment } from '@rocketh/web';
160
+ import { createPublicClient, custom } from 'viem';
161
+
162
+ const { loadEnvironment } = setupEnvironment(config, extensions);
163
+
164
+ async function initializeApp() {
165
+ const env = await loadEnvironment({
166
+ environment: 'mainnet',
167
+ provider: window.ethereum,
168
+ });
169
+
170
+ // Use deployed contracts
171
+ const token = env.get('Token');
172
+
173
+ // Create viem client for interactions
174
+ const client = createPublicClient({
175
+ chain: env.network.chain,
176
+ transport: custom(window.ethereum),
177
+ });
178
+
179
+ // Read contract data
180
+ const balance = await client.readContract({
181
+ address: token.address,
182
+ abi: token.abi,
183
+ functionName: 'balanceOf',
184
+ args: [userAddress],
185
+ });
186
+ }
187
+ ```
188
+
189
+ ## Limitations
190
+
191
+ - **Storage**: IndexedDB storage implementation is currently a stub. Deployments must be bundled or fetched from an API.
192
+ - **No File System**: Cannot read deploy scripts from filesystem - scripts must be imported directly.
193
+
194
+ ## Related Packages
195
+
196
+ - [`rocketh`](../rocketh) - Core deployment environment
197
+ - [`@rocketh/deploy`](../rocketh-deploy) - Standard deployment functions
198
+ - [`@rocketh/node`](../rocketh-node) - Node.js deployment executor
199
+
200
+ ## License
201
+
202
+ [MIT](../../LICENSE)
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@rocketh/web",
3
- "version": "0.17.16",
3
+ "version": "0.17.17",
4
+ "license": "MIT",
4
5
  "description": "rocketh for web",
5
6
  "publishConfig": {
6
7
  "access": "public"
@@ -24,15 +25,15 @@
24
25
  "dependencies": {
25
26
  "ldenv": "^0.3.16",
26
27
  "tsx": "^4.21.0",
27
- "@rocketh/core": "0.17.10"
28
+ "@rocketh/core": "0.17.11"
28
29
  },
29
30
  "devDependencies": {
30
- "as-soon": "^0.1.4",
31
+ "as-soon": "^0.1.5",
31
32
  "typescript": "^5.9.3",
32
- "rocketh": "0.17.16"
33
+ "rocketh": "0.17.17"
33
34
  },
34
35
  "peerDependencies": {
35
- "rocketh": "0.17.16"
36
+ "rocketh": "0.17.17"
36
37
  },
37
38
  "scripts": {
38
39
  "build": "tsc --project tsconfig.json",