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
117 });117 });
118 await this.api.isReadyOrError;118 await this.api.isReadyOrError;
119 this.network = await UniqueHelper.detectNetwork(this.api);119 this.network = await UniqueHelper.detectNetwork(this.api);
120 this.wsEndpoint = wsEndpoint;
120 }121 }
121}122}
122123
339 'chainql', 340 'chainql',
340 [341 [
341 `--tla-code=data=${kvStr}`,342 `--tla-code=data=${kvStr}`,
342 '-e', 'function(data) cql.dump(cql.chain("wss://ws-opal.unique.network:443").latest._meta, data, {omit_empty:true})',343 '-e', `function(data) cql.dump(cql.chain("${this.helper.getEndpoint()}").latest._meta, data, {omit_empty:true})`,
343 ],344 ],
344 );345 );
345346
modifiedtests/src/util/playgrounds/unique.tsdiffbeforeafterboth
--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -371,6 +371,7 @@
   api: ApiPromise | null;
   forcedNetwork: TNetworks | null;
   network: TNetworks | null;
+  wsEndpoint: string | null;
   chainLog: IUniqueHelperLog[];
   children: ChainHelperBase[];
   address: AddressGroup;
@@ -386,6 +387,7 @@
     this.api = null;
     this.forcedNetwork = null;
     this.network = null;
+    this.wsEndpoint = null;
     this.chainLog = [];
     this.children = [];
     this.address = new AddressGroup(this);
@@ -405,6 +407,11 @@
     return newHelper;
   }
 
+  getEndpoint(): string {
+    if (this.wsEndpoint === null) throw Error('No connection was established');
+    return this.wsEndpoint;
+  }
+
   getApi(): ApiPromise {
     if(this.api === null) throw Error('API not initialized');
     return this.api;
@@ -436,6 +443,7 @@
   async connect(wsEndpoint: string, listeners?: IApiListeners) {
     if (this.api !== null) throw Error('Already connected');
     const {api, network} = await ChainHelperBase.createConnection(wsEndpoint, listeners, this.forcedNetwork);
+    this.wsEndpoint = wsEndpoint;
     this.api = api;
     this.network = network;
   }