-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-contract-usage.js
More file actions
executable file
·182 lines (146 loc) · 5.92 KB
/
Copy pathverify-contract-usage.js
File metadata and controls
executable file
·182 lines (146 loc) · 5.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/env node
/**
* CONTRACT USAGE VERIFICATION
*
* Verifies that the frontend is using the correct PredinexPoolCore contract
* instead of the old PredinexPool contract
*/
const fs = require('fs');
const path = require('path');
class ContractUsageVerifier {
constructor() {
this.frontendPath = '/home/leon/predict-linux';
this.issues = [];
this.fixes = [];
}
async verifyContractUsage() {
console.log('🔍 Verifying Contract Usage in Frontend...');
console.log('='.repeat(50));
// Check contract configuration
await this.checkContractConfig();
// Check component usage
await this.checkComponentUsage();
// Check hook usage
await this.checkHookUsage();
// Check service usage
await this.checkServiceUsage();
// Display results
this.displayResults();
}
async checkContractConfig() {
console.log('\n📋 Checking Contract Configuration...');
try {
const configPath = path.join(this.frontendPath, 'config/wagmi.ts');
const configContent = fs.readFileSync(configPath, 'utf8');
// Check if POOL_CORE is configured correctly
if (configContent.includes('POOL_CORE:') && configContent.includes('0x3A6AFdC8C9c0eBe377B5413e87F1005675bbA413')) {
console.log('✅ POOL_CORE contract configured correctly');
} else {
this.issues.push('POOL_CORE contract not configured correctly');
}
// Check if old PREDINEX_POOL is still being used
if (configContent.includes('PREDINEX_POOL:') && configContent.includes('0x3A6AFdC8C9c0eBe377B5413e87F1005675bbA413')) {
console.log('⚠️ PREDINEX_POOL points to old address (DEPRECATED - use POOL_CORE)');
} else if (configContent.includes('PREDINEX_POOL:') && configContent.includes('0xBc54c64800d37d4A85C0ab15A13110a75742f423')) {
console.log('⚠️ PREDINEX_POOL points to same address as POOL_CORE (DEPRECATED - use POOL_CORE)');
}
} catch (error) {
this.issues.push(`Error reading config: ${error.message}`);
}
}
async checkComponentUsage() {
console.log('\n🧩 Checking Component Usage...');
const components = [
'components/PoolActions.tsx',
'components/PoolCard.tsx',
'components/PoolList.tsx'
];
for (const component of components) {
const componentPath = path.join(this.frontendPath, component);
if (fs.existsSync(componentPath)) {
const content = fs.readFileSync(componentPath, 'utf8');
if (content.includes('PredinexPoolABI')) {
this.issues.push(`${component} still uses old PredinexPoolABI`);
} else if (content.includes('CONTRACTS.POOL_CORE')) {
console.log(`✅ ${component} uses POOL_CORE correctly`);
}
if (content.includes('CONTRACTS.PREDINEX_POOL')) {
this.issues.push(`${component} still uses DEPRECATED PREDINEX_POOL (use POOL_CORE)`);
}
}
}
}
async checkHookUsage() {
console.log('\n🪝 Checking Hook Usage...');
const hooks = [
'hooks/usePools.ts',
'hooks/useContractInteractions.ts',
'hooks/usePoolCreation.ts'
];
for (const hook of hooks) {
const hookPath = path.join(this.frontendPath, hook);
if (fs.existsSync(hookPath)) {
const content = fs.readFileSync(hookPath, 'utf8');
if (content.includes('CONTRACTS.PREDINEX_POOL')) {
this.issues.push(`${hook} still uses DEPRECATED PREDINEX_POOL (use POOL_CORE)`);
} else if (content.includes('CONTRACTS.POOL_CORE')) {
console.log(`✅ ${hook} uses POOL_CORE correctly`);
}
}
}
}
async checkServiceUsage() {
console.log('\n🔧 Checking Service Usage...');
const services = [
'services/guidedMarketWalletService.ts',
'services/prizeClaimService.ts',
'services/poolService.ts'
];
for (const service of services) {
const servicePath = path.join(this.frontendPath, service);
if (fs.existsSync(servicePath)) {
const content = fs.readFileSync(servicePath, 'utf8');
if (content.includes('CONTRACTS.PREDINEX_POOL')) {
this.issues.push(`${service} still uses DEPRECATED PREDINEX_POOL (use POOL_CORE)`);
} else if (content.includes('CONTRACTS.POOL_CORE')) {
console.log(`✅ ${service} uses POOL_CORE correctly`);
}
}
}
}
displayResults() {
console.log('\n📊 VERIFICATION RESULTS');
console.log('='.repeat(50));
if (this.issues.length === 0) {
console.log('✅ All contract usage is correct!');
console.log('✅ Frontend is using PredinexPoolCore contract properly');
console.log('✅ No old PredinexPool references found');
} else {
console.log('❌ Issues found:');
this.issues.forEach(issue => {
console.log(` - ${issue}`);
});
}
console.log('\n📋 SUMMARY:');
console.log(`Contract Address: 0x3A6AFdC8C9c0eBe377B5413e87F1005675bbA413`);
console.log(`Contract Type: PredinexPoolCore (New Modular Architecture)`);
console.log(`ABI File: contracts/abis/PredinexPoolCore.json`);
console.log(`Configuration: CONTRACTS.POOL_CORE`);
if (this.issues.length > 0) {
console.log('\n🔧 RECOMMENDED FIXES:');
console.log('1. Replace all CONTRACTS.PREDINEX_POOL with CONTRACTS.POOL_CORE (DEPRECATED)');
console.log('2. Replace all PredinexPoolABI with CONTRACTS.POOL_CORE.abi (DEPRECATED)');
console.log('3. Update any hardcoded contract addresses to use POOL_CORE');
console.log('4. PREDINEX_POOL is now DEPRECATED - use POOL_CORE everywhere');
}
}
}
// Run if called directly
if (require.main === module) {
const verifier = new ContractUsageVerifier();
verifier.verifyContractUsage().catch(error => {
console.error('💥 Verification failed:', error);
process.exit(1);
});
}
module.exports = ContractUsageVerifier;