Skip to content

Commit fdbcc07

Browse files
authored
adjust relay to work in non dev without acdc (#11597)
1 parent e6ce181 commit fdbcc07

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

packages/discovery-provider/plugins/pedalboard/apps/relay/src/config/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ const defaultCoreEndpoint = (env: string): string => {
4343
return 'http://core:50051'
4444
}
4545

46+
export const chainId = (config: Config): string => {
47+
if (config.environment == "stage") return "1056801"
48+
if (config.environment == "dev") return "1337"
49+
return "31524"
50+
}
51+
4652
export const readConfig = (): Config => {
4753
if (config !== null) {
4854
return config

packages/discovery-provider/plugins/pedalboard/apps/relay/src/index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Config, readConfig } from './config/config'
1+
import { chainId, Config, readConfig } from './config/config'
22
import { ethers, providers } from 'ethers'
33
import { WalletManager } from './walletManager'
44
import { logger } from './logger'
@@ -26,16 +26,17 @@ export let web3: providers.JsonRpcProvider
2626
export let wallets: WalletManager
2727

2828
const main = async () => {
29-
if (config.environment !== "dev") {
29+
try {
3030
// async config
3131
const connectedWeb3 = await connectWeb3(config)
3232
web3 = connectedWeb3.web3
3333
config.acdcChainId = connectedWeb3.chainId.toString()
3434
wallets = new WalletManager(web3)
35-
} else {
36-
// needs to stay so decoding can happen correctly
37-
config.acdcChainId = "1337"
35+
} catch (e) {
36+
logger.warn("web3 not configured for relay, acdc not reachable")
3837
}
38+
// needs to stay so decoding can happen correctly
39+
config.acdcChainId = chainId(config)
3940

4041
// start webserver after async config
4142
const { serverHost, serverPort } = config

0 commit comments

Comments
 (0)