From f0d582dbb7fab0e6231b294ebc409504297ed617 Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Mon, 2 Oct 2023 17:18:01 +0200 Subject: [PATCH] refactor: Simplify inventory client parsing This helps to drop an UMA dependency, and is arguably nicer because it doesn't corce the js Object to and from a string type. --- src/relayer/RelayerConfig.ts | 6 ++++-- src/utils/index.ts | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/relayer/RelayerConfig.ts b/src/relayer/RelayerConfig.ts index 19801228f..856c1db45 100644 --- a/src/relayer/RelayerConfig.ts +++ b/src/relayer/RelayerConfig.ts @@ -1,4 +1,4 @@ -import { BigNumber, toBNWei, assert, toBN, replaceAddressCase, ethers } from "../utils"; +import { BigNumber, toBNWei, assert, toBN, ethers } from "../utils"; import { CommonConfig, ProcessEnv } from "../common"; import * as Constants from "../common/Constants"; import { InventoryConfig } from "../interfaces"; @@ -65,7 +65,9 @@ export class RelayerConfig extends CommonConfig { this.slowDepositors = SLOW_DEPOSITORS ? JSON.parse(SLOW_DEPOSITORS).map((depositor) => ethers.utils.getAddress(depositor)) : []; - this.inventoryConfig = RELAYER_INVENTORY_CONFIG ? JSON.parse(RELAYER_INVENTORY_CONFIG) : {}; + this.inventoryConfig = JSON.parse( + RELAYER_INVENTORY_CONFIG?.replace(/0x[a-fA-F0-9]{40}/g, ethers.utils.getAddress) ?? "{}" + ); this.minRelayerFeePct = toBNWei(MIN_RELAYER_FEE_PCT || Constants.RELAYER_MIN_FEE_PCT); if (Object.keys(this.inventoryConfig).length > 0) { diff --git a/src/utils/index.ts b/src/utils/index.ts index 959eebdcf..fcc1208a5 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -27,8 +27,6 @@ export { export type { Block, TransactionResponse, TransactionReceipt, Provider } from "@ethersproject/abstract-provider"; export { config } from "dotenv"; - -export { replaceAddressCase } from "@uma/common"; export { Logger } from "@uma/financial-templates-lib"; // TypeChain exports used in the bot.