Skip to content

Commit

Permalink
- [ ] Make default port=50000+chainId
Browse files Browse the repository at this point in the history
  • Loading branch information
orenyomtov committed Feb 23, 2023
1 parent 2a1362f commit 3f19084
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ export const DEFAULT_IPC_PATH = process.platform === "win32" ?
export const DEFAULT_ENV_VAR = "FIREBLOCKS_JSON_RPC_ADDRESS"
export const FIREBLOCKS_WEB3_PROVIDER_OPTION_DESC = "Fireblocks Web3 Provider option"
export const DEFAULT_TX_NOTE = "Created by Fireblocks JSON-RPC"
export const BASE_PORT = 50_000
7 changes: 6 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import express from "express"
import { FireblocksWeb3Provider, FireblocksProviderConfig, version as FireblocksWeb3ProviderVersion } from "@fireblocks/fireblocks-web3-provider"
import { ServerConfig } from "./types";
import Debug from "debug";
import { DEBUG_NAMESPACE } from "./constants";
import { BASE_PORT, DEBUG_NAMESPACE } from "./constants";
import { version } from "../package.json"
import net from "net";
import { mkdirSync } from "fs";
Expand Down Expand Up @@ -41,6 +41,11 @@ async function createServer(this: any, config: ServerConfig): Promise<{ server:

const fireblocksProvider = new FireblocksWeb3Provider(web3ProviderConfig)

if (config.http && !config.port) {
const chainId = config.chainId || await fireblocksProvider.request({ method: 'eth_chainId' })
config.port = BASE_PORT + Number(chainId)
}

function receiveRequest(jsonRpcRequest: any, exteernalResponseCallback: (response: any) => void) {
debug("Received request", jsonRpcRequest)

Expand Down

0 comments on commit 3f19084

Please sign in to comment.