Skip to content

Commit

Permalink
Fix prover fee
Browse files Browse the repository at this point in the history
  • Loading branch information
AllFi committed Jun 6, 2024
1 parent 3c540d2 commit c30b57e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions zp-relayer/configs/commitmentWatcherConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getBaseConfig } from './baseConfig'
import { getGasPriceConfig } from './common/gasPriceConfig'
import { getNetworkConfig } from './common/networkConfig'
import { getTxManagerConfig } from './common/txManagerConfig'
import { zBooleanString } from './common/utils'
import { zBN, zBooleanString } from './common/utils'

const zSchema = z.object({
COMMITMENT_WATCHER_PORT: z.coerce.number().default(8000),
Expand All @@ -14,7 +14,7 @@ const zSchema = z.object({
COMMITMENT_WATCHER_TX_VK_PATH: z.string().default('../params/transfer_verification_key.json'),
COMMITMENT_WATCHER_FETCH_INTERVAL: z.coerce.number().default(10000),
COMMITMENT_WATCHER_TX_REDUNDANCY: zBooleanString().default('false'),
COMMITMENT_WATCHER_FEE: z.coerce.number().default(100_000_000),
COMMITMENT_WATCHER_FEE: zBN().default("100_000_000"),
})

const network = getNetworkConfig()
Expand Down
4 changes: 2 additions & 2 deletions zp-relayer/services/commitment-watcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import express from 'express'
import { init } from './init'
import { createRouter } from './router'

init().then(() => {
init().then((pool) => {
const app = express()

app.use(createRouter())
app.use(createRouter(pool))
const PORT = config.COMMITMENT_WATCHER_PORT
app.listen(PORT, () => logger.info(`Started commitment-watcher on port ${PORT}`))
})
2 changes: 2 additions & 0 deletions zp-relayer/services/commitment-watcher/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,6 @@ export async function init() {
workers.forEach(w => w.run())

runWatcher(pool)

return pool
}
9 changes: 7 additions & 2 deletions zp-relayer/services/commitment-watcher/router.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import config from '@/configs/commitmentWatcherConfig'
import { logger } from '@/lib/appLogger'
import { FeeOptions } from '@/lib/fee'
import { BasePool } from '@/pool/BasePool'
import { poolTxQueue, WorkerTx, WorkerTxType } from '@/queue/poolTxQueue'
import { ValidationError } from '@/validation/api/validation'
import cors from 'cors'
import express, { NextFunction, Request, Response } from 'express'

export function createRouter() {
export function createRouter(pool: BasePool) {
const router = express.Router()

router.use(cors())
Expand All @@ -26,7 +28,10 @@ export function createRouter() {
})

router.get('/fee', (req, res) => {
res.json({ fee: config.COMMITMENT_WATCHER_FEE })
const fee = new FeeOptions({
fee: config.COMMITMENT_WATCHER_FEE,
}).denominate(pool.denominator);
res.json({ fee: fee.fees[0] })
})

router.get('/job/:commitment', async (req, res) => {
Expand Down

0 comments on commit c30b57e

Please sign in to comment.