@towns-protocol/generated 0.0.374 → 0.0.376

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@towns-protocol/generated",
3
- "version": "0.0.374",
3
+ "version": "0.0.376",
4
4
  "packageManager": "yarn@3.8.0",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "ethers": "^5.8.0"
14
14
  },
15
15
  "devDependencies": {
16
- "@towns-protocol/contracts": "^0.0.374"
16
+ "@towns-protocol/contracts": "^0.0.376"
17
17
  },
18
18
  "files": [
19
19
  "config/**/*",
@@ -32,5 +32,5 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "gitHead": "b6f28ce51336d969161de5c5aa0aa012f03a182a"
35
+ "gitHead": "500000c0d1b16a866df765a75c7972b5d1691693"
36
36
  }
@@ -2,13 +2,17 @@
2
2
 
3
3
  /**
4
4
  * CONTRACT ARTIFACT MANAGEMENT
5
- *
5
+ *
6
6
  * Strategy: npm download when possible, local generation when needed.
7
- *
8
- * 1. No artifacts → try npm download → validate hash → fallback to local gen
9
- * 2. Artifacts existcompare hashregenerate if contracts changed
10
- * 3. SKIP_CONTRACT_GEN=true use existing or npm download, never fail
11
- *
7
+ * Foundry auto-installation is removed; requires manual installation in local dev.
8
+ *
9
+ * 1. No artifactstry npm download validate hash:
10
+ * - Hash match: use npm artifacts
11
+ * - Hash mismatch + Foundry installed: regenerate locally
12
+ * - Hash mismatch + NO Foundry: use npm artifacts with warning (Vercel case)
13
+ * 2. Artifacts exist + contracts changed → regenerate locally (Foundry required, local only)
14
+ * 3. SKIP_CONTRACT_GEN=true → skip checks, use existing artifacts
15
+ *
12
16
  * Uses package.json version + git tree hash for validation.
13
17
  */
14
18
 
@@ -94,18 +98,7 @@ async function downloadArtifactsFromNpm() {
94
98
 
95
99
  if (!existsSync(devDir)) mkdirSync(devDir, { recursive: true });
96
100
  execSync(`cp -r "${extractedDevDir}/." "${devDir}/"`, { stdio: 'pipe' });
97
-
98
- // Validate hash if contracts exist
99
- const currentHash = getContractsHash();
100
- if (currentHash && existsSync(hashFile)) {
101
- const downloadedHash = readFileSync(hashFile, 'utf8').trim();
102
- if (currentHash !== downloadedHash) {
103
- console.log('Hash mismatch, falling back to local generation');
104
- execSync(`rm -rf "${devDir}"`, { stdio: 'pipe' });
105
- return false;
106
- }
107
- }
108
-
101
+
109
102
  console.log('Successfully downloaded artifacts from npm');
110
103
  return true;
111
104
  } catch (error) {
@@ -127,44 +120,18 @@ function isFoundryInstalled() {
127
120
  }
128
121
  }
129
122
 
130
- // Install Foundry if not present
131
- function installFoundry() {
132
- console.log('Installing Foundry...');
133
- try {
134
- // Install foundryup
135
- execSync('curl -L https://foundry.paradigm.xyz | bash', { stdio: 'inherit' });
136
-
137
- // foundryup modifies shell PATH, but we need to update Node.js process PATH
138
- // so subsequent execSync calls can find forge
139
- const foundryPath = `${process.env.HOME}/.foundry/bin`;
140
- process.env.PATH = `${foundryPath}:${process.env.PATH}`;
141
-
142
- // Install latest foundry
143
- execSync('foundryup', { stdio: 'inherit' });
144
-
145
- console.log('Foundry installation completed');
146
- return true;
147
- } catch (error) {
148
- console.log('Foundry installation failed:', error.message);
149
- return false;
150
- }
151
- }
152
-
153
123
  // Generate contract artifacts
154
124
  function generateArtifacts() {
155
- // Check for contracts directory FIRST (before trying to install Foundry)
125
+ // Check for contracts directory
156
126
  if (!existsSync(contractsDir)) {
157
- console.log('Contracts directory not found, cannot generate locally');
158
- throw new Error('Cannot generate artifacts: contracts package not available and npm download failed');
127
+ throw new Error('Cannot generate artifacts: contracts package not available');
159
128
  }
160
-
129
+
130
+ // Require Foundry to be installed
161
131
  if (!isFoundryInstalled()) {
162
- console.log('Foundry not found, attempting installation...');
163
- if (!installFoundry()) {
164
- throw new Error('Failed to install Foundry - cannot generate contract artifacts');
165
- }
132
+ throw new Error('Foundry is not installed and is required to generate contract artifacts.');
166
133
  }
167
-
134
+
168
135
  const buildScript = resolve(contractsDir, 'scripts/build-contract-types.sh');
169
136
 
170
137
  if (!existsSync(buildScript)) {
@@ -180,21 +147,36 @@ function generateArtifacts() {
180
147
  // Main logic
181
148
  async function main() {
182
149
  const skipRequested = process.env.SKIP_CONTRACT_GEN === 'true';
183
-
150
+
184
151
  if (!generatedFilesExist()) {
185
152
  console.log('No artifacts found, trying npm download first...');
186
- if (!(await downloadArtifactsFromNpm())) {
187
- console.log('NPM download failed, generating locally...');
153
+ if (await downloadArtifactsFromNpm()) {
154
+ // Check if hash validation is needed
155
+ const currentHash = getContractsHash();
156
+ if (currentHash && existsSync(hashFile)) {
157
+ const downloadedHash = readFileSync(hashFile, 'utf8').trim();
158
+ if (currentHash !== downloadedHash) {
159
+ // Hash mismatch: regenerate if Foundry available, otherwise use downloaded
160
+ if (isFoundryInstalled()) {
161
+ console.log('Hash mismatch detected, regenerating locally with Foundry...');
162
+ generateArtifacts();
163
+ } else {
164
+ console.log('WARNING: Hash mismatch but Foundry not available, using downloaded artifacts');
165
+ }
166
+ }
167
+ }
168
+ } else {
169
+ console.log('NPM download failed, attempting local generation...');
188
170
  generateArtifacts();
189
171
  }
190
172
  return;
191
173
  }
192
-
174
+
193
175
  if (skipRequested) {
194
176
  console.log('Skipping generation (SKIP_CONTRACT_GEN=true)');
195
177
  return;
196
178
  }
197
-
179
+
198
180
  if (contractsChanged()) {
199
181
  console.log('Contracts changed, regenerating...');
200
182
  generateArtifacts();