Skip to content

Commit

Permalink
Migrating to Base
Browse files Browse the repository at this point in the history
  • Loading branch information
wannabehero committed May 9, 2024
1 parent f910eb4 commit 1f9638f
Show file tree
Hide file tree
Showing 18 changed files with 4,203 additions and 798 deletions.
3 changes: 1 addition & 2 deletions backend/fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
app = "zkwordo-backend"
kill_signal = "SIGINT"
kill_timeout = 5
mounts = []
primary_region = "lhr"
processes = []

[env]
PORT = "8080"
ZK_WORDO_ADDRESS = "0x4b79635f3cd08c704db30181ca2b4d1415b472da"
ZK_WORDO_ADDRESS = "0x02a2c1Eab5740eA8660CeBeCc99CB43ed0b1f295"
WORDS_PATH = "/app/data/words.json"
ZK_WASM_PATH = "/app/data/zkwordo.wasm"
ZK_ZKEY_PATH = "/app/data/zkwordo.zkey"
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
cors: {
origin: ['https://zkwordo.xyz', 'http://localhost:5173'],
origin: ['https://zkwordo.xyz', /http:\/\/localhost:\d+/],
},
});
app.setGlobalPrefix('api');
Expand Down
8 changes: 4 additions & 4 deletions backend/src/proof/proof.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class ProofService {
const hashedWords = words.map((word, idx) => hashFunc(word, BigInt(idx)));
const hashedWord = hashFunc(preparedWord, day);

const rootAndPath = await calculateMerkleRootAndPath({
const { root, pathElements, pathIndices } = calculateMerkleRootAndPath({
hashFunc,
levels: 6,
elements: hashedWords,
Expand All @@ -82,11 +82,11 @@ export class ProofService {
const payload = {
day,
nullifier,
root: rootAndPath.root,
root,

pathIndices,
pathElements,
word: preparedWord,
pathElements: rootAndPath.pathElements,
pathIndices: rootAndPath.pathIndices,
};

const { proof, publicSignals } = await snarkjs.plonk.fullProve(
Expand Down
4 changes: 2 additions & 2 deletions backend/src/web3/web3.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Global, Module } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { createPublicClient, http } from 'viem';
import { polygon } from 'viem/chains';
import { base } from 'viem/chains';

import { VIEM_CLIENT } from './consts';

Expand All @@ -13,7 +13,7 @@ import { VIEM_CLIENT } from './consts';
inject: [ConfigService],
useFactory: (config: ConfigService) =>
createPublicClient({
chain: polygon,
chain: base,
transport: http(config.get('RPC_URL')),
}),
},
Expand Down
Binary file modified data/words.json.gpg
Binary file not shown.
24 changes: 24 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ const config: HardhatUserConfig = {
truffle: {
url: "http://localhost:24012/rpc",
},
"base-sepolia": {
accounts,
url: "https://sepolia.base.org",
},
base: {
accounts,
url: "https://mainnet.base.org",
}
},
etherscan: {
apiKey: process.env.ETHERSCAN_KEY,
Expand All @@ -48,6 +56,22 @@ const config: HardhatUserConfig = {
apiURL: "https://testnet-zkevm.polygonscan.com/api",
browserURL: "https://testnet-zkevm.polygonscan.com"
}
},
{
network: "base-sepolia",
chainId: 84532,
urls: {
apiURL: "https://api-sepolia.basescan.org/api",
browserURL: "https://sepolia.basescan.org"
}
},
{
network: "base",
chainId: 8453,
urls: {
apiURL: "https://api.basescan.org/api",
browserURL: "https://basescan.org"
}
}
]
}
Expand Down
Loading

0 comments on commit 1f9638f

Please sign in to comment.