diff --git a/src/event-stream/event-stream.service.ts b/src/event-stream/event-stream.service.ts index bc3b439..a81c92c 100644 --- a/src/event-stream/event-stream.service.ts +++ b/src/event-stream/event-stream.service.ts @@ -22,7 +22,7 @@ import { Event, EventStream, EventStreamReply, - EventStreamSubscription + EventStreamSubscription, } from './event-stream.interfaces'; const RECONNECT_TIME = 5000; @@ -144,17 +144,20 @@ export class EventStreamService { inputs: true, }; - const existingStreamRes = await lastValueFrom(this.http - .get(`${baseUrl}/eventstreams`)); + const existingStreamRes = await lastValueFrom( + this.http.get(`${baseUrl}/eventstreams`), + ); const stream = existingStreamRes.data.find(s => s.name === streamDetails.name); if (stream) { - const patchedStreamRes = await lastValueFrom(this.http - .patch(`${baseUrl}/eventstreams/${stream.id}`, streamDetails)); + const patchedStreamRes = await lastValueFrom( + this.http.patch(`${baseUrl}/eventstreams/${stream.id}`, streamDetails), + ); this.logger.log(`Event stream for ${topic}: ${stream.id}`); return patchedStreamRes.data; } - const newStreamRes = await lastValueFrom(this.http - .post(`${baseUrl}/eventstreams`, streamDetails)); + const newStreamRes = await lastValueFrom( + this.http.post(`${baseUrl}/eventstreams`, streamDetails), + ); this.logger.log(`Event stream for ${topic}: ${newStreamRes.data.id}`); return newStreamRes.data; } @@ -164,13 +167,14 @@ export class EventStreamService { event: string, streamId: string, ): Promise { - const response = await lastValueFrom(this.http - .post(`${instanceUrl}/${event}`, { + const response = await lastValueFrom( + this.http.post(`${instanceUrl}/${event}`, { name: event, description: event, stream: streamId, fromBlock: '0', // subscribe from the start of the chain - })); + }), + ); this.logger.log(`Created subscription ${event}: ${response.data.id}`); return response.data; } @@ -181,8 +185,9 @@ export class EventStreamService { streamId: string, subscriptions: string[], ): Promise { - const existingRes = await lastValueFrom(this.http - .get(`${baseUrl}/subscriptions`)); + const existingRes = await lastValueFrom( + this.http.get(`${baseUrl}/subscriptions`), + ); const results: EventStreamSubscription[] = []; for (const eventName of subscriptions) { const sub = existingRes.data.find(s => s.name === eventName && s.stream === streamId); diff --git a/src/tokens/tokens.service.ts b/src/tokens/tokens.service.ts index 0931d96..39c54d6 100644 --- a/src/tokens/tokens.service.ts +++ b/src/tokens/tokens.service.ts @@ -38,7 +38,7 @@ import { TokenTransfer, TokenTransferEvent, TokenType, - TransferSingleEvent + TransferSingleEvent, } from './tokens.interfaces'; import { decodeHex, encodeHex, isFungible, packTokenId, unpackTokenId } from './tokens.util'; @@ -79,12 +79,13 @@ export class TokensService { } async getReceipt(id: string): Promise { - const response = await lastValueFrom(this.http - .get(`${this.baseUrl}/reply/${id}`, { + const response = await lastValueFrom( + this.http.get(`${this.baseUrl}/reply/${id}`, { validateStatus: status => { return status < 300 || status === 404; }, - })); + }), + ); if (response.status === 404) { throw new NotFoundException(); } @@ -96,15 +97,16 @@ export class TokensService { trackingId: dto.trackingId, data: dto.data, // TODO: remove }; - const response = await lastValueFrom(this.http - .post( + const response = await lastValueFrom( + this.http.post( `${this.instanceUrl}/create`, { is_fungible: dto.type === TokenType.FUNGIBLE, data: encodeHex(JSON.stringify(dataToPack)), }, this.postOptions(dto.requestId), - )); + ), + ); return { id: response.data.id }; } @@ -115,8 +117,8 @@ export class TokensService { data: dto.data, }; if (isFungible(dto.poolId)) { - const response = await lastValueFrom(this.http - .post( + const response = await lastValueFrom( + this.http.post( `${this.instanceUrl}/mintFungible`, { type_id: typeId, @@ -125,7 +127,8 @@ export class TokensService { data: encodeHex(JSON.stringify(dataToPack)), }, this.postOptions(dto.requestId), - )); + ), + ); return { id: response.data.id }; } else { // In the case of a non-fungible token: @@ -137,8 +140,8 @@ export class TokensService { to.push(dto.to); } - const response = await lastValueFrom(this.http - .post( + const response = await lastValueFrom( + this.http.post( `${this.instanceUrl}/mintNonFungible`, { type_id: typeId, @@ -146,7 +149,8 @@ export class TokensService { data: encodeHex(JSON.stringify(dataToPack)), }, this.postOptions(dto.requestId), - )); + ), + ); return { id: response.data.id }; } } @@ -156,8 +160,8 @@ export class TokensService { trackingId: dto.trackingId, data: dto.data, }; - const response = await lastValueFrom(this.http - .post( + const response = await lastValueFrom( + this.http.post( `${this.instanceUrl}/safeTransferFrom`, { from: dto.from, @@ -167,7 +171,8 @@ export class TokensService { data: encodeHex(JSON.stringify(dataToPack)), }, this.postOptions(dto.requestId), - )); + ), + ); return { id: response.data.id }; } @@ -176,8 +181,8 @@ export class TokensService { trackingId: dto.trackingId, data: dto.data, }; - const response = await lastValueFrom(this.http - .post( + const response = await lastValueFrom( + this.http.post( `${this.instanceUrl}/burn`, { from: dto.from, @@ -186,18 +191,20 @@ export class TokensService { data: encodeHex(JSON.stringify(dataToPack)), }, this.postOptions(dto.requestId), - )); + ), + ); return { id: response.data.id }; } async balance(dto: TokenBalanceQuery): Promise { - const response = await lastValueFrom(this.http - .get(`${this.instanceUrl}/balanceOf`, { + const response = await lastValueFrom( + this.http.get(`${this.instanceUrl}/balanceOf`, { params: { account: dto.account, id: packTokenId(dto.poolId, dto.tokenIndex), }, - })); + }), + ); return { balance: response.data.output }; } } diff --git a/test/app.e2e-spec.ts b/test/app.e2e-spec.ts index de9cb6f..b818b24 100644 --- a/test/app.e2e-spec.ts +++ b/test/app.e2e-spec.ts @@ -41,7 +41,7 @@ import { TokenTransfer, TokenTransferEvent, TokenType, - TransferSingleEvent + TransferSingleEvent, } from '../src/tokens/tokens.interfaces'; import { TokensService } from '../src/tokens/tokens.service'; import { WebSocketMessage } from '../src/websocket-events/websocket-events.base'; @@ -66,13 +66,14 @@ class FakeObservable { constructor(public data: T) {} subscribe(observer?: Partial>>) { - observer?.next && observer?.next({ - status: 200, - statusText: 'OK', - headers: {}, - config: {}, - data: this.data, - }); + observer?.next && + observer?.next({ + status: 200, + statusText: 'OK', + headers: {}, + config: {}, + data: this.data, + }); observer?.complete && observer?.complete(); } }