update `RequestClient` options (#546)

* update `RequestClient` options

* c

* u
This commit is contained in:
Felicio Mununga 2024-03-26 15:15:55 +09:00 committed by GitHub
parent 4ff9d6ba5c
commit e863523510
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
'@status-im/js': patch
---
update `RequestClient` options

View File

@ -56,19 +56,24 @@ class RequestClient {
constructor( constructor(
waku: LightNode, waku: LightNode,
options: { options: {
ethProviderURLs: Record<number, string>
ethProviderApiKey: string ethProviderApiKey: string
contractAddresses: Record<number, Record<string, string>> ethProviderURLs?: Record<number, string>
contractAddresses?: Record<number, Record<string, string>>
started?: boolean started?: boolean
environment?: 'development' | 'preview' | 'production'
} }
) { ) {
const { environment = 'development' } = options
this.waku = waku this.waku = waku
this.wakuMessages = new Set() this.wakuMessages = new Set()
this.#started = options.started ?? false this.#started = options.started ?? false
this.#ethProviderURLs = options.ethProviderURLs this.#ethProviderURLs =
options.ethProviderURLs ?? providers[environment].infura
this.#ethProviderApiKey = options.ethProviderApiKey this.#ethProviderApiKey = options.ethProviderApiKey
this.#ethereumClients = new Map() this.#ethereumClients = new Map()
this.#contractAddresses = options.contractAddresses this.#contractAddresses =
options.contractAddresses ?? contracts[environment]
} }
static async start(options: RequestClientOptions): Promise<RequestClient> { static async start(options: RequestClientOptions): Promise<RequestClient> {
@ -106,9 +111,9 @@ class RequestClient {
client = new RequestClient(waku, { client = new RequestClient(waku, {
started: true, started: true,
ethProviderURLs: providers['production'].infura, ethProviderURLs: providers[environment].infura,
ethProviderApiKey: options.ethProviderApiKey, ethProviderApiKey: options.ethProviderApiKey,
contractAddresses: contracts['production'], contractAddresses: contracts[environment],
}) })
} catch (error) { } catch (error) {
if (waku) { if (waku) {