--- 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})`, ], ); --- 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; }