Skip to content

Commit

Permalink
Merge remote-tracking branch 'social-tw/feat_system_cicd' into feat_s…
Browse files Browse the repository at this point in the history
…ystem_cicd_enhancment
  • Loading branch information
Lisooo790926 committed Oct 28, 2023
2 parents 7e43ed4 + 1c6aa22 commit 3597cd7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 4 additions & 0 deletions packages/contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export async function main() {
: `/**
This contract was deployed using a mnemonic. The PRIVATE_KEY variable needs to be set manually
**/`

// get forked block number
const blockNum = await ethers.provider.getBlockNumber()
config.GENESIS_BLOCK = (blockNum - 999).toString()
await fs.promises.writeFile(configPath, envfile.stringify(config))
})

Expand Down
10 changes: 8 additions & 2 deletions packages/relay/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,17 @@ Object.assign(process.env, {
PRIVATE_KEY:
process.env.PRIVATE_KEY ??
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
GENESIS_BLOCK: process.env.GENESIS_BLOCK ?? '0',
...process.env,
})

export const { UNIREP_ADDRESS, APP_ADDRESS, ETH_PROVIDER_URL, PRIVATE_KEY } =
process.env as any
export const {
UNIREP_ADDRESS,
APP_ADDRESS,
ETH_PROVIDER_URL,
PRIVATE_KEY,
GENESIS_BLOCK,
} = process.env as any

export const APP_ABI = ABI

Expand Down
5 changes: 2 additions & 3 deletions packages/relay/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
DB_PATH,
APP_ADDRESS,
APP_ABI,
GENESIS_BLOCK,
} from './config'
import TransactionManager from './singletons/TransactionManager'

Expand All @@ -27,8 +28,6 @@ main().catch((err) => {

async function main() {
const db = await SQLiteConnector.create(schema, DB_PATH ?? ':memory:')
// TODO: this should be switched by stage and prod
const blockNum = await provider.send('eth_blockNumber', [])

const synchronizer = new UnirepSocialSynchronizer(
{
Expand All @@ -37,7 +36,7 @@ async function main() {
prover: prover,
provider: provider,
unirepAddress: UNIREP_ADDRESS,
genesisBlock: parseInt(blockNum) - 999,
genesisBlock: parseInt(GENESIS_BLOCK),
},
new ethers.Contract(APP_ADDRESS, APP_ABI, provider)
)
Expand Down

0 comments on commit 3597cd7

Please sign in to comment.