Skip to content

Commit

Permalink
Merge pull request #10 from zama-ai/update-dapps
Browse files Browse the repository at this point in the history
chore: use new version
  • Loading branch information
immortal-tofu authored Apr 30, 2024
2 parents 867293d + d265b1d commit db584d0
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 41,737 deletions.
41,695 changes: 0 additions & 41,695 deletions package-lock.json

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"eip-712": "^1.0.0",
"env-cmd": "^10.1.0",
"ethers": "^6.6.2",
"fhevmjs": "^0.3.2",
"fhevmjs": "^0.4.0",
"gatsby": "^5.13.3",
"gatsby-plugin-emotion": "^8.13.1",
"gatsby-plugin-postcss": "^6.13.1",
Expand Down
47 changes: 30 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/components/Bid/Bid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
TextField,
} from '@mui/material';
import { Loader } from '../Loader';
import { getInstance, getTokenSignature } from '../../wallet';
import { getInstance, getPublicKeySignature } from '../../wallet';

export const Bid: React.FC<{
abi: any;
Expand All @@ -39,7 +39,7 @@ export const Bid: React.FC<{
const getCurrentBid = async () => {
try {
const contractAddress = await contract.getAddress();
const { publicKey, signature } = await getTokenSignature(contractAddress, account);
const { publicKey, signature } = await getPublicKeySignature(contractAddress, account);
const encryptedBid = await contract.getBid(publicKey, signature);
const bid = getInstance().decrypt(contractAddress, encryptedBid);
console.log('get', account, bid);
Expand Down Expand Up @@ -89,7 +89,7 @@ export const Bid: React.FC<{
}
setLoading('Decrypting do I have highest bid...');
const contractAddress = await contract.getAddress();
const { publicKey, signature } = await getTokenSignature(contractAddress, account);
const { publicKey, signature } = await getPublicKeySignature(contractAddress, account);
const ciphertext = await contract.doIHaveHighestBid(publicKey, signature);
const hb = getInstance().decrypt(contractAddress, ciphertext);
setHighestBid(Boolean(hb));
Expand Down
4 changes: 2 additions & 2 deletions src/components/EIP712/EIP712.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
import { Contract, BrowserProvider, isAddress } from 'ethers';
import { Button, Card, CardActions, CardContent, CardHeader } from '@mui/material';
import { Loader } from '../Loader';
import { getTokenSignature } from '../../wallet';
import { getPublicKeySignature } from '../../wallet';

export const EIP712: React.FC<{
account: string;
Expand Down Expand Up @@ -32,7 +32,7 @@ export const EIP712: React.FC<{
const verifyToken = async () => {
setVerified(false);

const { publicKey, signature } = await getTokenSignature(contractAddress, account);
const { publicKey, signature } = await getPublicKeySignature(contractAddress, account);
await contract.verify(publicKey, signature);
setVerified(true);
setLoading('');
Expand Down
4 changes: 2 additions & 2 deletions src/components/TokenBalance/TokenBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ListItemText,
} from '@mui/material';
import { Loader } from '../Loader';
import { getInstance, getTokenSignature } from '../../wallet';
import { getInstance, getPublicKeySignature } from '../../wallet';

export const TokenBalance: React.FC<{
abi: any;
Expand Down Expand Up @@ -45,7 +45,7 @@ export const TokenBalance: React.FC<{
try {
const contractAddress = await contract.getAddress();
setLoading('Decrypting your balance...');
const { publicKey, signature } = await getTokenSignature(contractAddress, account);
const { publicKey, signature } = await getPublicKeySignature(contractAddress, account);
const ciphertext = await contract.balanceOf(account, publicKey, signature);
const balance = await getInstance().decrypt(contractAddress, ciphertext);
setDecryptedBalance(balance);
Expand Down
1 change: 0 additions & 1 deletion src/components/TokenInfo/TokenInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
ListItemText,
} from '@mui/material';
import { Loader } from '../Loader';
import { getInstance, getTokenSignature } from '../../wallet';

const NO_SUPPLY = 'NO_SUPPLY';
const toHexString = (bytes: Uint8Array) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/TokenTransfer/TokenTransfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const TokenTransfer: React.FC<{
return;
}
setLoading(`Encrypting "${Number(amount)}" and generating ZK proof...`);
const encryptedAmount = await getInstance().encrypt32(Number(amount));
const encryptedAmount = await getInstance().encrypt64(Number(amount));
setLoading('Sending transaction...');
const transaction = await contract['transfer(address,bytes)'](address, encryptedAmount);
setLoading('Waiting for transaction validation...');
Expand Down
22 changes: 11 additions & 11 deletions src/contracts/EncryptedERC20.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/modules/private-bet/components/BetAction/BetAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
TextField,
} from '@mui/material';
import { Loader } from '../../../../components/Loader';
import { getInstance, getTokenSignature } from '../../../../wallet';
import { getInstance, getPublicKeySignature } from '../../../../wallet';
import { Game } from '../../types';
import { GAME_STATE } from '../../constants';

Expand Down Expand Up @@ -93,7 +93,7 @@ export const BetAction: React.FC<{
const getCurrentBet = async () => {
try {
const contractAddress = await contract.getAddress();
const { publicKey, signature } = await getTokenSignature(contractAddress, account);
const { publicKey, signature } = await getPublicKeySignature(contractAddress, account);
const response = await contract.getBet(gameId, publicKey, signature);
const bet = response.toObject();
const betAmount = getInstance().decrypt(contractAddress, bet.amount);
Expand Down
4 changes: 2 additions & 2 deletions src/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export const getInstance = () => {
return instance;
};

export const getTokenSignature = async (contractAddress: string, userAddress: string) => {
export const getPublicKeySignature = async (contractAddress: string, userAddress: string) => {
if (getInstance().hasKeypair(contractAddress)) {
return getInstance().getTokenSignature(contractAddress)!;
return getInstance().getPublicKey(contractAddress)!;
} else {
const { publicKey, eip712 } = getInstance().generatePublicKey({ verifyingContract: contractAddress });
const params = [userAddress, JSON.stringify(eip712)];
Expand Down

0 comments on commit db584d0

Please sign in to comment.