1+ import { LitNodeClientConfig } from '@lit-protocol/types' ;
12import { Contract } from '@ethersproject/contracts' ;
23import { JsonRpcProvider } from '@ethersproject/providers' ;
34import Ajv , { JSONSchemaType } from 'ajv' ;
@@ -31,6 +32,13 @@ import {
3132const logBuffer : any [ ] [ ] = [ ] ;
3233const ajv = new Ajv ( ) ;
3334
35+ // Module scoped variable to store the LitNodeClientConfig passed to LitCore
36+ let litConfig : LitNodeClientConfig | undefined ;
37+
38+ export const setMiscLitConfig = ( config : LitNodeClientConfig | undefined ) => {
39+ litConfig = config ;
40+ } ;
41+
3442/**
3543 *
3644 * Print error message based on Error interface
@@ -95,7 +103,6 @@ export const findMostCommonResponse = (responses: object[]): object => {
95103} ;
96104
97105declare global {
98- var litConfig : any ;
99106 var wasmExport : any ;
100107 var wasmECDSA : any ;
101108 var logger : any ;
@@ -148,13 +155,13 @@ export const log = (...args: any): void => {
148155 }
149156
150157 // check if config is loaded yet
151- if ( ! globalThis ?. litConfig ) {
158+ if ( ! litConfig ) {
152159 // config isn't loaded yet, push into buffer
153160 logBuffer . push ( args ) ;
154161 return ;
155162 }
156163
157- if ( globalThis ?. litConfig ?. debug !== true ) {
164+ if ( litConfig ?. debug !== true ) {
158165 return ;
159166 }
160167 // config is loaded, and debug is true
@@ -176,13 +183,13 @@ export const logWithRequestId = (id: string, ...args: any) => {
176183 }
177184
178185 // check if config is loaded yet
179- if ( ! globalThis ?. litConfig ) {
186+ if ( ! litConfig ) {
180187 // config isn't loaded yet, push into buffer
181188 logBuffer . push ( args ) ;
182189 return ;
183190 }
184191
185- if ( globalThis ?. litConfig ?. debug !== true ) {
192+ if ( litConfig ?. debug !== true ) {
186193 return ;
187194 }
188195 // config is loaded, and debug is true
@@ -206,13 +213,13 @@ export const logErrorWithRequestId = (id: string, ...args: any) => {
206213 }
207214
208215 // check if config is loaded yet
209- if ( ! globalThis ?. litConfig ) {
216+ if ( ! litConfig ) {
210217 // config isn't loaded yet, push into buffer
211218 logBuffer . push ( args ) ;
212219 return ;
213220 }
214221
215- if ( globalThis ?. litConfig ?. debug !== true ) {
222+ if ( litConfig ?. debug !== true ) {
216223 return ;
217224 }
218225 // config is loaded, and debug is true
@@ -236,13 +243,13 @@ export const logError = (...args: any) => {
236243 }
237244
238245 // check if config is loaded yet
239- if ( ! globalThis ?. litConfig ) {
246+ if ( ! litConfig ) {
240247 // config isn't loaded yet, push into buffer
241248 logBuffer . push ( args ) ;
242249 return ;
243250 }
244251
245- if ( globalThis ?. litConfig ?. debug !== true ) {
252+ if ( litConfig ?. debug !== true ) {
246253 return ;
247254 }
248255 // config is loaded, and debug is true
0 commit comments