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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"next:lint": "pnpm --filter ./packages/erc7984example lint",
"next:serve": "pnpm --filter ./packages/erc7984example serve",
"precommit": "lint-staged",
"postinstall": "sh scripts/patch-node-tkms.sh",
"preinstall": "pnpm sdk:build",
"start": "pnpm --filter ./packages/erc7984example dev",
"test": "pnpm hardhat:test",
Expand Down
2 changes: 1 addition & 1 deletion packages/erc7984example/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const DappWrapper = ({ children }: { children: React.ReactNode }) => {
<html suppressHydrationWarning className={``}>
<head></head>
<body suppressHydrationWarning>
<Script src="https://cdn.zama.org/relayer-sdk-js/0.4.0-4/relayer-sdk-js.umd.cjs" strategy="beforeInteractive" />
<Script src="https://cdn.zama.org/relayer-sdk-js/0.4.1/relayer-sdk-js.umd.cjs" strategy="beforeInteractive" />
<ThemeProvider enableSystem>
<DappWrapperWithProviders>{children}</DappWrapperWithProviders>
</ThemeProvider>
Expand Down
32 changes: 16 additions & 16 deletions packages/erc7984example/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { PrivyProvider } from "@privy-io/react-auth";
import { WagmiProvider as PrivyWagmiProvider, createConfig } from "@privy-io/wagmi";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { sepolia } from "viem/chains";
import { sepolia, hardhat } from "viem/chains";

Check warning on line 7 in packages/erc7984example/app/providers.tsx

View workflow job for this annotation

GitHub Actions / Lint & Type Check

Replace `sepolia,·hardhat` with `hardhat,·sepolia`
import { createConfig as createWagmiConfig, http } from "wagmi";
import { WagmiProvider as StandardWagmiProvider } from "wagmi";
import scaffoldConfig from "~~/scaffold.config";
Expand All @@ -30,28 +30,28 @@

const { alchemyApiKey } = scaffoldConfig;

// Use Sepolia as the primary chain (Privy doesn't work well with local hardhat)
const activeChain = sepolia;

// Build RPC URL
const rpcUrl = alchemyApiKey
// Build RPC URLs
const sepoliaRpcUrl = alchemyApiKey
? `https://eth-sepolia.g.alchemy.com/v2/${alchemyApiKey}`
: "https://ethereum-sepolia-rpc.publicnode.com";

// Include both chains — hardhat transport is harmless in production
const chains = [sepolia, hardhat] as const;
const transports = {
[sepolia.id]: http(sepoliaRpcUrl),
[hardhat.id]: http("http://127.0.0.1:8545"),
};

// Create Wagmi config using Privy's createConfig (for when Privy is configured)
export const wagmiConfig = createConfig({
chains: [activeChain] as const,
transports: {
[activeChain.id]: http(rpcUrl),
} as Record<typeof activeChain.id, ReturnType<typeof http>>,
chains,
transports,
});

// Create standard Wagmi config (for fallback when Privy is not configured)
const standardWagmiConfig = createWagmiConfig({
chains: [activeChain],
transports: {
[activeChain.id]: http(rpcUrl),
},
chains,
transports,
});

export function Providers({ children }: Props) {
Expand All @@ -74,8 +74,8 @@
},
},
loginMethods: ["wallet", "email"],
supportedChains: [activeChain],
defaultChain: activeChain,
supportedChains: [...chains],
defaultChain: sepolia,
appearance: {
showWalletLoginFirst: true,
walletChainType: "ethereum-only",
Expand Down
149 changes: 149 additions & 0 deletions packages/erc7984example/contracts/deployedContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ const deployedContracts = {
name: "OwnershipTransferred",
type: "event",
},
{
inputs: [],
name: "AIRDROP_AMOUNT",
outputs: [
{
internalType: "uint64",
name: "",
type: "uint64",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
Expand Down Expand Up @@ -2119,6 +2132,142 @@ const deployedContracts = {
},
deployedOnBlock: 10092096,
},
PublicDecryptSingleValue: {
address: "0x1365229D1769232CCbC795c7181dD65B34872348",
abi: [
{
inputs: [],
stateMutability: "nonpayable",
type: "constructor",
},
{
inputs: [],
name: "InvalidKMSSignatures",
type: "error",
},
{
inputs: [],
name: "ZamaProtocolUnsupported",
type: "error",
},
{
anonymous: false,
inputs: [
{
indexed: false,
internalType: "bytes32[]",
name: "handlesList",
type: "bytes32[]",
},
{
indexed: false,
internalType: "bytes",
name: "abiEncodedCleartexts",
type: "bytes",
},
],
name: "PublicDecryptionVerified",
type: "event",
},
{
inputs: [
{
internalType: "bytes32[]",
name: "handlesList",
type: "bytes32[]",
},
{
internalType: "bytes",
name: "cleartexts",
type: "bytes",
},
{
internalType: "bytes",
name: "decryptionProof",
type: "bytes",
},
],
name: "callbackDecryptSingleUint32",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "clearUint32",
outputs: [
{
internalType: "uint32",
name: "",
type: "uint32",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "confidentialProtocolId",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "getHandle",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "uint32",
name: "value",
type: "uint32",
},
],
name: "initializeUint32",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [
{
internalType: "uint32",
name: "value",
type: "uint32",
},
],
name: "initializeUint32Wrong",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "requestDecryptSingleUint32",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
],
inheritedFunctions: {},
deployedOnBlock: 10106218,
},
},
} as const;

Expand Down
22 changes: 22 additions & 0 deletions packages/erc7984example/empty-module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Browser-compatible fs shim for node-tkms WASM loading.
// node-tkms calls require('fs').readFileSync(path) to load kms_lib_bg.wasm.
// In the browser, we serve it from public/ and load via synchronous XHR.
module.exports = {
readFileSync: function (filePath) {
var filename = filePath.split("/").pop();
var xhr = new XMLHttpRequest();
xhr.open("GET", "/" + filename, false); // synchronous
// Use binary string override since synchronous XHR doesn't support responseType
xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.send();
if (xhr.status >= 200 && xhr.status < 300) {
var text = xhr.responseText;
var bytes = new Uint8Array(text.length);
for (var i = 0; i < text.length; i++) {
bytes[i] = text.charCodeAt(i) & 0xff;
}
return bytes;
}
throw new Error("fs shim: failed to load /" + filename + " (status: " + xhr.status + ")");
},
};
14 changes: 11 additions & 3 deletions packages/erc7984example/next.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@ const nextConfig: NextConfig = {
transpilePackages: ["fhevm-sdk"],
// Exclude Node.js packages that are incompatible with Turbopack bundling
serverExternalPackages: ["pino", "thread-stream", "pino-pretty"],
// Empty turbopack config - Turbopack handles Node.js fallbacks automatically
turbopack: {},
// Turbopack: resolve Node.js built-ins to empty modules for client bundle
turbopack: {
resolveAlias: {
fs: "./empty-module.js",
net: "./empty-module.js",
tls: "./empty-module.js",
child_process: "./empty-module.js",
worker_threads: "./empty-module.js",
},
},
// Configure webpack fallbacks for client-side (these packages shouldn't be bundled for browser)
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
fs: require.resolve("./empty-module.js"),
net: false,
tls: false,
child_process: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/erc7984example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@tanstack/react-query": "~5.59.20",
"@uniswap/sdk-core": "~5.8.5",
"@uniswap/v2-sdk": "~4.6.2",
"@zama-fhe/relayer-sdk": "0.4.0-4",
"@zama-fhe/relayer-sdk": "0.4.1",
"blo": "~1.2.0",
"daisyui": "5.0.9",
"ethers": "^6.15.0",
Expand Down
Binary file added packages/erc7984example/public/kms_lib_bg.wasm
Binary file not shown.
Binary file added packages/erc7984example/public/tfhe_bg.wasm
Binary file not shown.
8 changes: 4 additions & 4 deletions packages/fhevm-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
},
"dependencies": {
"idb": "^8.0.3",
"@zama-fhe/relayer-sdk": "^0.4.0-2",
"ethers": "^6.13.4"
"@zama-fhe/relayer-sdk": "^0.4.1",
"ethers": "^6.16.0"
},
"peerDependencies": {
"@fhevm/mock-utils": "^0.3.0-4",
"@fhevm/mock-utils": "^0.4.2",
"react": ">=16.8.0"
},
"peerDependenciesMeta": {
Expand All @@ -53,7 +53,7 @@
"@types/node": "~18.19.50",
"@types/react": "~19.0.7",
"@vitest/coverage-v8": "2.1.9",
"ethers": "^6.13.7",
"ethers": "^6.16.0",
"fake-indexeddb": "~6.0.0",
"jsdom": "^27.0.0",
"react": "~19.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/fhevm-sdk/src/internal/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const SDK_CDN_URL =
"https://cdn.zama.org/relayer-sdk-js/0.4.0-4/relayer-sdk-js.umd.cjs";
"https://cdn.zama.org/relayer-sdk-js/0.4.1/relayer-sdk-js.umd.cjs";
6 changes: 3 additions & 3 deletions packages/fhevm-sdk/src/internal/fhevm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,11 @@ export const createFhevmInstance = async (parameters: {
notify("creating");

//////////////////////////////////////////////////////////////////////////
//
//
// WARNING!!
// ALWAY USE DYNAMIC IMPORT TO AVOID INCLUDING THE ENTIRE FHEVM MOCK LIB
// ALWAY USE DYNAMIC IMPORT TO AVOID INCLUDING THE ENTIRE FHEVM MOCK LIB
// IN THE FINAL PRODUCTION BUNDLE!!
//
//
//////////////////////////////////////////////////////////////////////////
const fhevmMock = await import("./mock/fhevmMock");
const mockInstance = await fhevmMock.fhevmMockCreateInstance({
Expand Down
12 changes: 6 additions & 6 deletions packages/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
"hardhat"
],
"dependencies": {
"@fhevm/solidity": "^0.10.0",
"@fhevm/solidity": "^0.11.1",
"@openzeppelin/contracts": "^5.4.0",
"@openzeppelin/contracts-upgradeable": "^5.4.0",
"@zama-fhe/oracle-solidity": "^0.1.0",
"encrypted-types": "^0.0.4",
"openzeppelin-confidential-contracts": "git+https://github.com/OpenZeppelin/openzeppelin-confidential-contracts.git#master"
},
"devDependencies": {
"@fhevm/hardhat-plugin": "^0.3.0-4",
"@fhevm/mock-utils": "^0.3.0-4",
"@fhevm/hardhat-plugin": "^0.4.2",
"@fhevm/mock-utils": "^0.4.2",
"@nomicfoundation/hardhat-chai-matchers": "^2.1.0",
"@nomicfoundation/hardhat-ethers": "^3.1.0",
"@nomicfoundation/hardhat-ethers": "^3.1.3",
"@nomicfoundation/hardhat-network-helpers": "^1.1.0",
"@nomicfoundation/hardhat-verify": "^2.1.0",
"@typechain/ethers-v6": "^0.5.1",
Expand All @@ -45,13 +45,13 @@
"@types/node": "^20.19.8",
"@typescript-eslint/eslint-plugin": "^8.37.0",
"@typescript-eslint/parser": "^8.37.0",
"@zama-fhe/relayer-sdk": "0.3.0-8",
"@zama-fhe/relayer-sdk": "0.4.1",
"chai": "^4.5.0",
"chai-as-promised": "^8.0.1",
"cross-env": "^7.0.3",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"ethers": "^6.15.0",
"ethers": "^6.16.0",
"hardhat": "^2.27.0",
"hardhat-deploy": "^0.11.45",
"hardhat-gas-reporter": "^2.3.0",
Expand Down
Loading
Loading