Skip to content

Commit

Permalink
feat: add proxy support (#12)
Browse files Browse the repository at this point in the history
Co-authored-by: agoltzman <106151463+agoltzman@users.noreply.github.com>
  • Loading branch information
a0ngo and a0ngo authored Feb 8, 2024
1 parent a41d13c commit e60ff3e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 51 deletions.
95 changes: 47 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"hardhat": "^2.6.0"
},
"dependencies": {
"@fireblocks/fireblocks-web3-provider": "^1.3.2"
"@fireblocks/fireblocks-web3-provider": "^1.3.2",
"undici": "^6.6.2"
}
}
11 changes: 9 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
HardhatUserConfig,
HttpNetworkUserConfig,
} from "hardhat/types";
import { Dispatcher, ProxyAgent } from 'undici';

import { version as SDK_VERSION } from "../package.json";

Expand Down Expand Up @@ -46,16 +47,22 @@ extendConfig(
extendEnvironment((hre) => {
if ((hre.network.config as HttpNetworkUserConfig).fireblocks) {
const httpNetConfig = hre.network.config as HttpNetworkUserConfig;
const fireblocksW3PConfig =(hre.network.config as HttpNetworkUserConfig).fireblocks!;
let dispatcher: Dispatcher | undefined = undefined;
if(fireblocksW3PConfig.proxyPath){
dispatcher = new ProxyAgent(fireblocksW3PConfig.proxyPath!);
}
const eip1193Provider = new HttpProvider(
httpNetConfig.url!,
hre.network.name,
httpNetConfig.httpHeaders,
httpNetConfig.timeout
httpNetConfig.timeout,
dispatcher
);
let wrappedProvider: EIP1193Provider;
wrappedProvider = new FireblocksSigner(
eip1193Provider,
(hre.network.config as HttpNetworkUserConfig).fireblocks!
fireblocksW3PConfig
);
wrappedProvider = new AutomaticGasProvider(
wrappedProvider,
Expand Down

0 comments on commit e60ff3e

Please sign in to comment.