@@ -24,6 +24,7 @@ import {
2424console . log ( 'checking env' , process . env [ 'DEBUG' ] ) ;
2525export class TinnyEnvironment {
2626 public network : LIT_NETWORK_VALUES ;
27+ public customNetworkContext : any ;
2728
2829 /**
2930 * Environment variables used in the process.
@@ -36,7 +37,7 @@ export class TinnyEnvironment {
3637 DEBUG : process . env [ 'DEBUG' ] === 'true' ,
3738 REQUEST_PER_KILOSECOND :
3839 parseInt ( process . env [ 'REQUEST_PER_KILOSECOND' ] ) ||
39- ( process . env [ 'NETWORK' ] as LIT_NETWORK_VALUES ) === 'datil-dev'
40+ ( process . env [ 'NETWORK' ] as LIT_NETWORK_VALUES ) === 'datil-dev'
4041 ? 1
4142 : 200 ,
4243 LIT_RPC_URL : process . env [ 'LIT_RPC_URL' ] ,
@@ -100,7 +101,10 @@ export class TinnyEnvironment {
100101 private _shivaClient : ShivaClient = new ShivaClient ( ) ;
101102 private _contractContext : LitContractContext | LitContractResolverContext ;
102103
103- constructor ( override ?: Partial < ProcessEnvs > ) {
104+ constructor ( override ?: Partial < ProcessEnvs > & { customNetworkContext ?: any } ) {
105+
106+ this . customNetworkContext = override ?. customNetworkContext ;
107+
104108 // Merge default processEnvs with custom overrides
105109 this . processEnvs = {
106110 ...this . processEnvs ,
@@ -120,8 +124,7 @@ export class TinnyEnvironment {
120124
121125 if ( Object . values ( LIT_NETWORK ) . indexOf ( this . network ) === - 1 ) {
122126 throw new Error (
123- `Invalid network environment ${
124- this . network
127+ `Invalid network environment ${ this . network
125128 } . Please use one of ${ Object . values ( LIT_NETWORK ) } `
126129 ) ;
127130 }
@@ -244,7 +247,7 @@ export class TinnyEnvironment {
244247
245248 if ( this . network === LIT_NETWORK . Custom || centralisation === 'unknown' ) {
246249 const networkContext =
247- this ?. testnet ?. ContractContext ?? this . _contractContext ;
250+ this . customNetworkContext || ( this ?. testnet ?. ContractContext ?? this . _contractContext ) ;
248251 this . litNodeClient = new LitNodeClient ( {
249252 litNetwork : LIT_NETWORK . Custom ,
250253 rpcUrl : this . rpc ,
@@ -350,8 +353,8 @@ export class TinnyEnvironment {
350353 * Creates a random person.
351354 * @returns A promise that resolves to the created person.
352355 */
353- async createRandomPerson ( ) {
354- return await this . createNewPerson ( 'Alice' ) ;
356+ async createRandomPerson ( name ?: string ) {
357+ return await this . createNewPerson ( name || 'Alice' ) ;
355358 }
356359
357360 setUnavailable = ( network : LIT_NETWORK_VALUES ) => {
@@ -382,7 +385,7 @@ export class TinnyEnvironment {
382385
383386 await this . testnet . getTestnetConfig ( ) ;
384387 } else if ( this . network === LIT_NETWORK . Custom ) {
385- const context = await import ( './networkContext.json' ) ;
388+ const context = this . customNetworkContext || await import ( './networkContext.json' ) ;
386389 this . _contractContext = context ;
387390 }
388391
0 commit comments