-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-contract.js
More file actions
80 lines (64 loc) · 2.93 KB
/
test-contract.js
File metadata and controls
80 lines (64 loc) · 2.93 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
const { ethers } = require('ethers');
require('dotenv').config({ path: './operator/.env' });
async function testContract() {
const provider = new ethers.JsonRpcProvider(process.env.RPC_URL);
const wallet = new ethers.Wallet(process.env.PRIVATE_KEY, provider);
// Load deployment data
const fs = require('fs');
const path = require('path');
const coreDeploymentData = JSON.parse(fs.readFileSync(path.resolve(__dirname, `./avs/deployments/core/31337.json`), 'utf8'));
const avsDeploymentData = JSON.parse(fs.readFileSync(path.resolve(__dirname, `./avs/deployments/avs/31337.json`), 'utf8'));
const avsDirectoryAddress = coreDeploymentData.addresses.avsDirectory;
const avsServiceManagerAddress = avsDeploymentData.addresses.avsServiceManager;
console.log('AVS Directory address:', avsDirectoryAddress);
console.log('AVS Service Manager address:', avsServiceManagerAddress);
// Check if contract exists
console.log('\nChecking if contract exists...');
const code = await provider.getCode(avsDirectoryAddress);
console.log('Contract bytecode length:', code.length);
console.log('Contract bytecode (first 100 chars):', code.substring(0, 100));
if (code === '0x') {
console.log('ERROR: No contract deployed at this address!');
return;
}
// Load ABI
const avsDirectoryABI = JSON.parse(fs.readFileSync(path.resolve(__dirname, './abis/IAVSDirectory.json'), 'utf8'));
// Create contract instance
const avsDirectory = new ethers.Contract(avsDirectoryAddress, avsDirectoryABI, wallet);
try {
// Check available functions
console.log('\nAvailable functions in ABI:');
avsDirectoryABI.forEach(func => {
if (func.type === 'function') {
console.log(`- ${func.name}`);
}
});
console.log('\nTesting OPERATOR_AVS_REGISTRATION_TYPEHASH...');
const typeHash = await avsDirectory.OPERATOR_AVS_REGISTRATION_TYPEHASH();
console.log('Type hash:', typeHash);
// Test the problematic function
console.log('\nTesting calculateOperatorAVSRegistrationDigestHash...');
const salt = ethers.hexlify(ethers.randomBytes(32));
const expiry = Math.floor(Date.now() / 1000) + 3600;
console.log('Parameters:');
console.log('- operator:', wallet.address);
console.log('- avs:', avsServiceManagerAddress);
console.log('- salt:', salt);
console.log('- expiry:', expiry);
const digestHash = await avsDirectory.calculateOperatorAVSRegistrationDigestHash(
wallet.address,
avsServiceManagerAddress,
salt,
expiry
);
console.log('Digest hash:', digestHash);
} catch (error) {
console.error('Error:', error);
console.error('Error details:', {
code: error.code,
value: error.value,
info: error.info
});
}
}
testContract();