Skip to content

Commit

Permalink
Merge pull request #25 from hollow-leaf/fix/publicClient
Browse files Browse the repository at this point in the history
feat: change public client
  • Loading branch information
yeeetai authored Aug 24, 2023
2 parents e26f2c4 + 8bc4c1a commit 5f81241
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 28 deletions.
16 changes: 11 additions & 5 deletions apps/web/src/app/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ export default function Home() {
return (
<div className="flex flex-col items-center justify-center">
<main className="mx-auto w-auto px-4 pt-16 pb-8 sm:pt-24 lg:px-8">
<h1 className="mx-auto text-center text-6xl font-extrabold tracking-tight text-white sm:text-7xl lg:text-8xl xl:text-8xl">
Tobi
<span className="block bg-gradient-to-r from-brandred to-brandblue bg-clip-text text-transparent px-2">
Time-lock Omni Bridge Interface
</span>
<h1 className="mx-auto text-center font-extrabold tracking-tight text-white space-y-8">
<span className="text-7xl sm:text-8xl lg:text-9xl xl:text-9xl">TOBI</span>
<span className="block bg-gradient-to-r from-brandred to-brandblue bg-clip-text text-transparent px-2 text-6xl sm:text-7xl lg:text-8xl xl:text-8xl">
All-Chain KYC Platform
</span>
<span className="block px-2 text-3xl sm:text-4xl lg:text-5xl xl:text-5xl space-x-2">
<span className="text-cat-orange500">T</span>oken
<span className="text-cat-orange500">O</span>ptimizing
<span className="text-cat-orange500">B</span>ridge
<span className="text-cat-orange500">I</span>ntelligence
</span>
</h1>
</main>
</div>
Expand Down
27 changes: 20 additions & 7 deletions apps/web/src/service/kamui/client.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
import { createWalletClient, createPublicClient, http } from 'viem'
import { fallback, createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { goerli, sepolia } from 'viem/chains'

// This is example
export const account = privateKeyToAccount(`0x${process.env.NEXT_PUBLIC_PRIVATE_KEY}`)

export const publicClient: any = createPublicClient({
const sepoliaProvider = [
http('https://api.zan.top/node/v1/eth/sepolia/public'),
http('https://rpc.notadegen.com/eth/sepolia'),
http('https://rpc-sepolia.rockx.com'),
http('https://rpc.notadegen.com/eth/sepolia')
]

const goerliProvider = [
http('https://eth-goerli.api.onfinality.io/public'),
http('https://goerli.blockpi.network/v1/rpc/public'),
http('https://ethereum-goerli.publicnode.com'),
http('https://api.zan.top/node/v1/eth/goerli/public')
]

export const sepoliaClient: any = createPublicClient({
chain: sepolia,
transport: http(`https://sepolia.infura.io/v3/${process.env.NEXT_PUBLIC_INFURA_API_KEY}`)
transport: fallback(sepoliaProvider)
})

export const walletClient: any = createWalletClient({
account,
chain: sepolia,
transport: http(`https://sepolia.infura.io/v3/${process.env.NEXT_PUBLIC_INFURA_API_KEY}`)
export const goerliClient: any = createPublicClient({
chain: goerli,
transport: fallback(goerliProvider)
})
14 changes: 10 additions & 4 deletions apps/web/src/service/kamui/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { writeContract, prepareWriteContract, getNetwork } from 'wagmi/actions'
import { wagmiAbi } from './abi'
import { zkproof } from './verify'
import { publicClient, walletClient, account } from './client'
import { sepoliaClient, goerliClient, account } from './client'
import { copyFileSync } from 'fs'

const { buildPoseidon } = require('circomlibjs')
Expand All @@ -13,6 +13,11 @@ const contractAddress: any = {
'Sepolia': process.env.NEXT_PUBLIC_SEPOLIA_CONTRACT
}

const publicClients: any = {
'Goerli': goerliClient,
'Sepolia': sepoliaClient,
}

export const createProposal = async (name: string, endTime: number) => {
const { chain } = getNetwork()
const { request } = await prepareWriteContract({
Expand All @@ -38,7 +43,7 @@ export const vote = async (proof: any, proposalId: number, accept: boolean) => {

export const getResult = async (proposal: bigint) => {
const { chain } = getNetwork()

const publicClient = publicClients[chain!.name]
const data = await publicClient.readContract({
address: contractAddress[chain!.name],
abi: wagmiAbi,
Expand All @@ -50,7 +55,7 @@ export const getResult = async (proposal: bigint) => {

export const getBlockTime = async () => {
const { chain } = getNetwork()

const publicClient = publicClients[chain!.name]
const data = await publicClient.readContract({
address: contractAddress[chain!.name],
abi: wagmiAbi,
Expand All @@ -61,6 +66,7 @@ export const getBlockTime = async () => {

export const getProposal = async (proposalId: number) => {
const { chain } = getNetwork()
const publicClient = publicClients[chain!.name]
const data = await publicClient.readContract({
address: contractAddress[chain!.name],
abi: wagmiAbi,
Expand All @@ -72,7 +78,7 @@ export const getProposal = async (proposalId: number) => {

export const getProposalCount = async () => {
const { chain } = getNetwork()

const publicClient = publicClients[chain!.name]
const data = await publicClient.readContract({
address: contractAddress[chain!.name],
abi: wagmiAbi,
Expand Down
20 changes: 10 additions & 10 deletions packages/zk-circuits/cache/solidity-files-cache.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"_format": "hh-sol-cache-2",
"files": {
"/Users/eric/Workspace/hackathon/hollowleaf/tobi/packages/zk-circuits/contracts/CircuitsVerifier.sol": {
"lastModificationDate": 1692714895344,
"/Users/cfh00890942/Workspace/hackathon/tobi/tobi/packages/zk-circuits/contracts/CircuitsVerifier.sol": {
"lastModificationDate": 1692676198788,
"contentHash": "a1cd466008240a0102cf704daf699062",
"sourceName": "contracts/CircuitsVerifier.sol",
"solcConfig": {
Expand Down Expand Up @@ -37,8 +37,8 @@
"Verifier"
]
},
"/Users/eric/Workspace/hackathon/hollowleaf/tobi/packages/zk-circuits/contracts/KamuiField.sol": {
"lastModificationDate": 1692803139535,
"/Users/cfh00890942/Workspace/hackathon/tobi/tobi/packages/zk-circuits/contracts/KamuiField.sol": {
"lastModificationDate": 1692839634797,
"contentHash": "2623c233915cd7f0088dc81ee90882fd",
"sourceName": "contracts/KamuiField.sol",
"solcConfig": {
Expand Down Expand Up @@ -75,8 +75,8 @@
"KamuiField"
]
},
"/Users/eric/Workspace/hackathon/hollowleaf/tobi/packages/zk-circuits/contracts/interface/ICircuitsVerifier.sol": {
"lastModificationDate": 1692803131438,
"/Users/cfh00890942/Workspace/hackathon/tobi/tobi/packages/zk-circuits/contracts/interface/ICircuitsVerifier.sol": {
"lastModificationDate": 1692839634798,
"contentHash": "8414b18f6719c8db16c5484ac9265015",
"sourceName": "contracts/interface/ICircuitsVerifier.sol",
"solcConfig": {
Expand Down Expand Up @@ -110,8 +110,8 @@
"ICircuitsVerifier"
]
},
"/Users/eric/Workspace/hackathon/hollowleaf/tobi/node_modules/.pnpm/@[email protected]/node_modules/@openzeppelin/contracts/access/Ownable.sol": {
"lastModificationDate": 1692715035066,
"/Users/cfh00890942/Workspace/hackathon/tobi/tobi/node_modules/.pnpm/@[email protected]/node_modules/@openzeppelin/contracts/access/Ownable.sol": {
"lastModificationDate": 1692672501304,
"contentHash": "5a20b2cad87ddb61c7a3a6af21289e28",
"sourceName": "@openzeppelin/contracts/access/Ownable.sol",
"solcConfig": {
Expand Down Expand Up @@ -147,8 +147,8 @@
"Ownable"
]
},
"/Users/eric/Workspace/hackathon/hollowleaf/tobi/node_modules/.pnpm/@[email protected]/node_modules/@openzeppelin/contracts/utils/Context.sol": {
"lastModificationDate": 1692715035039,
"/Users/cfh00890942/Workspace/hackathon/tobi/tobi/node_modules/.pnpm/@[email protected]/node_modules/@openzeppelin/contracts/utils/Context.sol": {
"lastModificationDate": 1692672501254,
"contentHash": "5f2c5c4b6af2dd4551027144797bc8be",
"sourceName": "@openzeppelin/contracts/utils/Context.sol",
"solcConfig": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"main":"0x461Cd208b91D65e2E1d5549ee5A5c6dcbCBfE1E1"}
{"main":"0x950798121c8A4d647Fc156334cCF09c59F038Eb5"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"main":"0xfC0A4C89D8B94ea81654DaEd99E3C40Ae51fb5d6"}
{"main":"0x621cA77D5501ceD495a792988C450e1Ca639a962"}

0 comments on commit 5f81241

Please sign in to comment.