-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtest-get.js
More file actions
executable file
·41 lines (32 loc) · 1.08 KB
/
test-get.js
File metadata and controls
executable file
·41 lines (32 loc) · 1.08 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
'use strict';
import { logCLI, parseCommonOptions } from '../../utils.js';
import { FHETestAddresses } from './fheTest.js';
import { ethers } from 'ethers';
// npx . test get --type euint32 --network testnet --json
// npx . test get --type euint32 --network mainnet --json
export async function testFHETestGetCommand(options) {
const { config, provider, signer, zamaFhevmApiKey } =
parseCommonOptions(options);
if (!FHETestAddresses[config.name]) {
logCLI(`❌ FHETest is not deployed on network ${config.name}`, options);
process.exit(1);
}
const contractAddress = FHETestAddresses[config.name];
const t = 'E' + options.type.substring(1);
const funcName = `get${t}`;
const contract = new ethers.Contract(
contractAddress,
[`function ${funcName}() view returns (bytes32)`],
signer,
);
const handle = await contract[funcName]();
const res = {
network: config.name,
chainId: config.fhevmInstanceConfig.chainId,
contractAddress,
caller: signer.address,
type: options.type,
handle,
};
console.log(JSON.stringify(res, null, 2));
}