git.delta.rocks / unique-network / refs/commits / e000126d21b1

difftreelog

fix add wsEndpoint to playgrnd helpers

Daniel Shiposha2022-11-25parent: #c207e15.patch.diff
in: master

2 files changed

modifiedtests/src/util/playgrounds/unique.dev.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.dev.ts
+++ b/tests/src/util/playgrounds/unique.dev.ts
@@ -117,6 +117,7 @@
     });
     await this.api.isReadyOrError;
     this.network = await UniqueHelper.detectNetwork(this.api);
+    this.wsEndpoint = wsEndpoint;
   }
 }
 
@@ -339,7 +340,7 @@
       'chainql', 
       [
         `--tla-code=data=${kvStr}`,
-        '-e', 'function(data) cql.dump(cql.chain("wss://ws-opal.unique.network:443").latest._meta, data, {omit_empty:true})',
+        '-e', `function(data) cql.dump(cql.chain("${this.helper.getEndpoint()}").latest._meta, data, {omit_empty:true})`,
       ],
     );
 
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
371 api: ApiPromise | null;371 api: ApiPromise | null;
372 forcedNetwork: TNetworks | null;372 forcedNetwork: TNetworks | null;
373 network: TNetworks | null;373 network: TNetworks | null;
374 wsEndpoint: string | null;
374 chainLog: IUniqueHelperLog[];375 chainLog: IUniqueHelperLog[];
375 children: ChainHelperBase[];376 children: ChainHelperBase[];
376 address: AddressGroup;377 address: AddressGroup;
386 this.api = null;387 this.api = null;
387 this.forcedNetwork = null;388 this.forcedNetwork = null;
388 this.network = null;389 this.network = null;
390 this.wsEndpoint = null;
389 this.chainLog = [];391 this.chainLog = [];
390 this.children = [];392 this.children = [];
391 this.address = new AddressGroup(this);393 this.address = new AddressGroup(this);
405 return newHelper;407 return newHelper;
406 }408 }
409
410 getEndpoint(): string {
411 if (this.wsEndpoint === null) throw Error('No connection was established');
412 return this.wsEndpoint;
413 }
407414
408 getApi(): ApiPromise {415 getApi(): ApiPromise {
409 if(this.api === null) throw Error('API not initialized');416 if(this.api === null) throw Error('API not initialized');
436 async connect(wsEndpoint: string, listeners?: IApiListeners) {443 async connect(wsEndpoint: string, listeners?: IApiListeners) {
437 if (this.api !== null) throw Error('Already connected');444 if (this.api !== null) throw Error('Already connected');
438 const {api, network} = await ChainHelperBase.createConnection(wsEndpoint, listeners, this.forcedNetwork);445 const {api, network} = await ChainHelperBase.createConnection(wsEndpoint, listeners, this.forcedNetwork);
446 this.wsEndpoint = wsEndpoint;
439 this.api = api;447 this.api = api;
440 this.network = network;448 this.network = network;
441 }449 }