Skip to content

Commit

Permalink
fix: various fix
Browse files Browse the repository at this point in the history
  • Loading branch information
immortal-tofu committed Jun 27, 2024
1 parent d5bb937 commit 665c74f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/sdk/network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TfheCompactPublicKey, TfheClientKey } from 'node-tfhe';
import { createTfheKeypair } from '../tfhe';
import { createEncryptedInput } from './encrypt';
import {
getChainIdFromNetwork,
getPublicKeyCallParams,
getPublicKeyFromCoprocessor,
getPublicKeyFromNetwork,
Expand All @@ -16,6 +17,11 @@ describe('network', () => {
const keypair = createTfheKeypair();
});

it('get chainId', async () => {
const chainId = await getChainIdFromNetwork('https://devnet.zama.ai');
expect(chainId).toBe(8009);
});

it('get network key', async () => {
const pk = await getPublicKeyFromNetwork('https://devnet.zama.ai');
expect(pk!.length).toBe(33106);
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const getChainIdFromNetwork = async (url: string) => {
},
body: JSON.stringify(payload),
};
return Number(fetchJSONRPC(url, options));
return Number(await fetchJSONRPC(url, options));
};

// Define the function to perform the eth_call
Expand Down
4 changes: 2 additions & 2 deletions src/sdk/reencrypt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const reencryptRequest =
) => {
if (!gatewayUrl) throw new Error('You must provide a reencryption URL.');

const payload = {
const payload: { [key: string]: string } = {
signature,
user_address: userAddress,
enc_key: publicKey,
Expand All @@ -32,7 +32,7 @@ export const reencryptRequest =
},
body: JSON.stringify(payload),
};
const response = await fetch(`${gatewayUrl}/reencrypt`, options);
const response = await fetch(`${gatewayUrl}reencrypt`, options);
const json = await response.json();
const client = default_client_for_centralized_kms();
const pubKey = u8vec_to_cryptobox_pk(fromHexString(publicKey));
Expand Down

0 comments on commit 665c74f

Please sign in to comment.