Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bin/commands/input-proof.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
valueColumnTypeListToFheTypedValues,
} from '../utils.js';

// npx . input-proof --values 123:euint32 true:ebool 1234567890123456789:euint256 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9:eaddress --version 2 --network testnet --rpc-url https://sepolia.drpc.org
// npx . input-proof --values 123:euint32 true:ebool 1234567890123456789:euint256 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9:eaddress --version 2
// npx . input-proof --values 123:euint32 true:ebool 1234567890123456789:euint256 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9:eaddress --version 1
// npx . input-proof --values 123:euint32 true:ebool 1234567890123456789:euint256 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9:eaddress --network testnet --rpc-url https://sepolia.drpc.org
// npx . input-proof --values 123:euint32 true:ebool 1234567890123456789:euint256 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9:eaddress
// npx . input-proof --values 123:euint32 true:ebool 1234567890123456789:euint256 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9:eaddress
// npx . input-proof --contract-address 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9 --user-address 0x37AC010c1c566696326813b840319B58Bb5840E4 --values 123:euint32
// npx . input-proof --values 123:euint32 true:ebool 1234567890123456789:euint256 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9:eaddress --version 2 --network mainnet
// npx . input-proof --values 123:euint32 true:ebool 1234567890123456789:euint256 0xb2a8A265dD5A27026693Aa6cE87Fb21Ac197b6b9:eaddress --network mainnet
export async function inputProofCommand(options) {
const { config, zamaFhevmApiKey } = parseCommonOptions(options);

Expand Down
8 changes: 4 additions & 4 deletions bin/commands/public-decrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import { parseCommonOptions, parseHandles } from '../utils.js';
// 0xfd82b3d4bc3318f57189a5841e248e24b59453a168ff0000000000aa36a70400

// npx . public-decrypt --handles 0xfd82b3d4bc3318f57189a5841e248e24b59453a168ff0000000000aa36a70400
// npx . public-decrypt --version 2 --handles 0xfd82b3d4bc3318f57189a5841e248e24b59453a168ff0000000000aa36a70400
// npx . public-decrypt --version 2 --handles 0xc49cf03ffa2768ee7ca49fb8b1fe930c6b43075ed0000000000000aa36a70000
// npx . public-decrypt --version 2 --handles 0xe85c2a81338b8542a6c0a99a5a794f158f4fb0f6a2ff0000000000aa36a70400
// npx . public-decrypt --version 2 --handles 0x7abb4a6c63af220fcd7da6bba4a0891fbe77e576efff00000000000000010500
// npx . public-decrypt --handles 0xfd82b3d4bc3318f57189a5841e248e24b59453a168ff0000000000aa36a70400
// npx . public-decrypt --handles 0xc49cf03ffa2768ee7ca49fb8b1fe930c6b43075ed0000000000000aa36a70000
// npx . public-decrypt --handles 0xe85c2a81338b8542a6c0a99a5a794f158f4fb0f6a2ff0000000000aa36a70400
// npx . public-decrypt --handles 0x7abb4a6c63af220fcd7da6bba4a0891fbe77e576efff00000000000000010500
export async function publicDecryptCommand(options) {
const { config, zamaFhevmApiKey } = parseCommonOptions(options);

Expand Down
1 change: 0 additions & 1 deletion bin/commands/test/test-add.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export async function testFHETestAddCommand(options) {
parseCommonOptions(options);

logCLI('🚚 network: ' + config.name, options);
logCLI('🚀 route: v' + config.version, options);
logCLI(`🍔 signer: ${signer.address}`);
logCLI(`🧀 value: ${BigInt(options.value)}`);
logCLI(`🍉 type: ${options.type}`);
Expand Down
1 change: 0 additions & 1 deletion bin/commands/test/test-make-publicly-decryptable.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export async function testFHETestMakePubliclyDecryptableCommand(options) {
const { config, provider, signer } = parseCommonOptions(options);

logCLI('🚚 network: ' + config.name, options);
logCLI('🚀 route: v' + config.version, options);
logCLI(`🍔 signer: ${signer.address}`);

if (!FHETestAddresses[config.name]) {
Expand Down
7 changes: 3 additions & 4 deletions bin/commands/test/test-public-decrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ import { safeJSONstringify } from '../../../lib/internal.js';
// 0x9d430a3e950560ba22013ce885d6d90f0da36efdf1ff0000000000aa36a70600 euint128 308429577281045301472547520724787086512
// 0xf6751d547a5c06123575aad93f22f76b7d841c4cacff0000000000aa36a70000 ebool false
//
// npx . test public-decrypt --types euint32 --network testnet --version 1
// npx . test public-decrypt --types euint32 --network testnet --version 2
// npx . test public-decrypt --types euint32 --network mainnet --version 2
// npx . test public-decrypt --types euint32 --network testnet
// npx . test public-decrypt --types euint32 --network testnet
// npx . test public-decrypt --types euint32 --network mainnet
export async function testFHETestPublicDecryptCommand(options) {
const { config, provider, signer, zamaFhevmApiKey } =
parseCommonOptions(options);

logCLI('🚚 network: ' + config.name, options);
logCLI('🚀 route: v' + config.version, options);
logCLI(`🍔 signer: ${signer.address}`, options);

if (!FHETestAddresses[config.name]) {
Expand Down
1 change: 0 additions & 1 deletion bin/commands/test/test-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export async function testFHETestRandomCommand(options) {
}

logCLI('🚚 network: ' + config.name, options);
logCLI('🚀 route: v' + config.version, options);
logCLI(`🍔 signer: ${signer.address}`);

if (!FHETestAddresses[config.name]) {
Expand Down
9 changes: 4 additions & 5 deletions bin/commands/test/test-user-decrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ import { FHETestAddresses } from './fheTest.js';
import { ethers } from 'ethers';
import { userDecrypt } from '../../userDecrypt.js';

// npx . test user-decrypt --types euint32 --network devnet --version 2
// npx . test user-decrypt --types euint32 --network testnet --version 1
// npx . test user-decrypt --types euint32 --network testnet --version 2
// npx . test user-decrypt --types euint32 --network mainnet --version 2
// npx . test user-decrypt --types euint32 --network devnet
// npx . test user-decrypt --types euint32 --network testnet
// npx . test user-decrypt --types euint32 --network testnet
// npx . test user-decrypt --types euint32 --network mainnet
export async function testFHETestUserDecryptCommand(options) {
const { config, provider, signer, zamaFhevmApiKey } =
parseCommonOptions(options);

logCLI('🚚 network: ' + config.name, options);
logCLI('🚀 route: v' + config.version, options);
logCLI(`🍔 signer: ${signer.address}`);

if (!FHETestAddresses[config.name]) {
Expand Down
3 changes: 1 addition & 2 deletions bin/commands/user-decrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import { userDecrypt } from '../userDecrypt.js';
import { logCLI, parseCommonOptions } from '../utils.js';

// npx . user-decrypt --version 2 --handle 0xe85c2a81338b8542a6c0a99a5a794f158f4fb0f6a2ff0000000000aa36a70400 --contract-address 0x1E7eA8fE4877E6ea5dc8856f0dA92da8d5066241 --network testnet
// npx . user-decrypt --handle 0xe85c2a81338b8542a6c0a99a5a794f158f4fb0f6a2ff0000000000aa36a70400 --contract-address 0x1E7eA8fE4877E6ea5dc8856f0dA92da8d5066241 --network testnet
export async function userDecryptCommand(options) {
const { config, signer, zamaFhevmApiKey } = parseCommonOptions(options);

logCLI('🚚 network: ' + config.name, options);
logCLI('🚀 route: v' + config.version, options);
logCLI(`🍔 signer: ${signer.address}`);

const handle = options.handle;
Expand Down
2 changes: 1 addition & 1 deletion bin/pubkeyCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function loadFhevmPublicKeyConfig(

const fhevm = await createRelayerFhevm({
...config.fhevmInstanceConfig,
defaultRelayerVersion: config.version,
defaultRelayerVersion: 2,
...instanceOptions,
});

Expand Down
3 changes: 3 additions & 0 deletions bin/userDecrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ export async function userDecrypt({

const startTimeStamp = Math.floor(Date.now() / 1000);
const durationDays = 1;
const extraData = await instance.getExtraData();

const eip712 = instance.createEIP712(
keypair.publicKey,
contractAddresses,
startTimeStamp,
durationDays,
extraData,
);

const signature = await signer.signTypedData(
Expand All @@ -73,6 +75,7 @@ export async function userDecrypt({
signer.address,
startTimeStamp,
durationDays,
extraData,
{
timeout,
//signal: abortController.signal,
Expand Down
25 changes: 2 additions & 23 deletions bin/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export function addCommonOptions(command) {
.option('--rpc-url <rpc url>', 'The rpc url')
.option('--relayer-url <relayer url>', 'The relayer url')
.option('--mnemonic <word list>', 'Mnemonic word list')
.option('--version <route v1 or v2>', 'The default route version: 1|2')
.option('--clear-cache', 'Clear the FHEVM public key cache')
.option('--json', 'Ouput in JSON format')
.option('--verbose', 'Verbose output')
Expand All @@ -111,7 +110,6 @@ export function addCommonOptions(command) {
* @returns {{
* config: {
* name: 'testnet' | 'devnet' | 'mainnet',
* version: 1 | 2,
* walletAddress: string,
* userAddress: string,
* contractAddress: string,
Expand All @@ -138,17 +136,6 @@ export function parseCommonOptions(options) {
throwError(`Invalid network name '${name}'.`);
}

let version = options?.version ?? 1;
if (version === 'v1' || version === '1') {
version = 1;
}
if (version === 'v2' || version === '2') {
version = 2;
}
if (version !== 1 && version !== 2) {
throwError(`Invalid relayer route version '${version}'.`);
}

let rpcUrl = options?.rpcUrl;
if (!rpcUrl) {
rpcUrl = getEnv('RPC_URL', `.env.${name}`);
Expand All @@ -165,15 +152,8 @@ export function parseCommonOptions(options) {
throwError(`Missing relayer Url.`);
}

if (version === 1) {
if (!relayerUrl.endsWith('/v1')) {
relayerUrl = relayerUrl + '/v1';
}
}
if (version === 2) {
if (!relayerUrl.endsWith('/v2')) {
relayerUrl = relayerUrl + '/v2';
}
if (!relayerUrl.endsWith('/v2')) {
relayerUrl = relayerUrl + '/v2';
}

let contractAddress = options?.contractAddress;
Expand Down Expand Up @@ -277,7 +257,6 @@ export function parseCommonOptions(options) {

const config = {
name: name,
version,
walletAddress: wallet?.address,
userAddress: userAddress ?? wallet?.address,
contractAddress,
Expand Down
2 changes: 1 addition & 1 deletion jest.base.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module.exports = {
testPathIgnorePatterns: ['/node_modules/', '/e2e/'],
coverageThreshold: {
global: {
branches: 70,
branches: 65,
functions: 62,
lines: 75,
},
Expand Down
Loading
Loading