From e86352351049369a83ebbb74517c152b7442dddd Mon Sep 17 00:00:00 2001 From: Felicio Mununga Date: Tue, 26 Mar 2024 15:15:55 +0900 Subject: [PATCH] update `RequestClient` options (#546) * update `RequestClient` options * c * u --- .changeset/silver-colts-wash.md | 5 +++++ .../src/request-client/request-client.ts | 17 +++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .changeset/silver-colts-wash.md diff --git a/.changeset/silver-colts-wash.md b/.changeset/silver-colts-wash.md new file mode 100644 index 00000000..6d30b077 --- /dev/null +++ b/.changeset/silver-colts-wash.md @@ -0,0 +1,5 @@ +--- +'@status-im/js': patch +--- + +update `RequestClient` options diff --git a/packages/status-js/src/request-client/request-client.ts b/packages/status-js/src/request-client/request-client.ts index 6ca2ce85..2937a94c 100644 --- a/packages/status-js/src/request-client/request-client.ts +++ b/packages/status-js/src/request-client/request-client.ts @@ -56,19 +56,24 @@ class RequestClient { constructor( waku: LightNode, options: { - ethProviderURLs: Record ethProviderApiKey: string - contractAddresses: Record> + ethProviderURLs?: Record + contractAddresses?: Record> started?: boolean + environment?: 'development' | 'preview' | 'production' } ) { + const { environment = 'development' } = options + this.waku = waku this.wakuMessages = new Set() this.#started = options.started ?? false - this.#ethProviderURLs = options.ethProviderURLs + this.#ethProviderURLs = + options.ethProviderURLs ?? providers[environment].infura this.#ethProviderApiKey = options.ethProviderApiKey this.#ethereumClients = new Map() - this.#contractAddresses = options.contractAddresses + this.#contractAddresses = + options.contractAddresses ?? contracts[environment] } static async start(options: RequestClientOptions): Promise { @@ -106,9 +111,9 @@ class RequestClient { client = new RequestClient(waku, { started: true, - ethProviderURLs: providers['production'].infura, + ethProviderURLs: providers[environment].infura, ethProviderApiKey: options.ethProviderApiKey, - contractAddresses: contracts['production'], + contractAddresses: contracts[environment], }) } catch (error) { if (waku) {