From 336e9d8fbf4aa0e23f3ae5dc8c3f4a37dd585b2b Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Tue, 26 Apr 2022 11:57:40 -0400 Subject: [PATCH] Remove token URI for fungible tokens Fixes #71 Signed-off-by: Andrew Richardson --- src/tokens/tokens.interfaces.ts | 2 +- src/tokens/tokens.service.ts | 3 ++- test/suites/websocket.ts | 22 ++++++---------------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/src/tokens/tokens.interfaces.ts b/src/tokens/tokens.interfaces.ts index 039614d..bd4974d 100644 --- a/src/tokens/tokens.interfaces.ts +++ b/src/tokens/tokens.interfaces.ts @@ -304,7 +304,7 @@ export class TokenTransferEvent extends tokenEventBase { tokenIndex?: string; @ApiProperty() - uri: string; + uri?: string; @ApiProperty() from: string; diff --git a/src/tokens/tokens.service.ts b/src/tokens/tokens.service.ts index de34555..2efad1c 100644 --- a/src/tokens/tokens.service.ts +++ b/src/tokens/tokens.service.ts @@ -535,6 +535,7 @@ class TokenListener implements EventListener { return undefined; } + const uri = unpackedId.isFungible ? undefined : await this.getTokenUri(output.id); const eventId = this.formatBlockchainEventId(event); const transferId = eventIndex === undefined ? eventId : eventId + '/' + eventIndex.toString(10).padStart(6, '0'); @@ -543,7 +544,7 @@ class TokenListener implements EventListener { id: transferId, poolLocator: unpackedSub.poolLocator, tokenIndex: unpackedId.tokenIndex, - uri: await this.getTokenUri(output.id), + uri, amount: output.value, signer: output.operator, data: decodedData, diff --git a/test/suites/websocket.ts b/test/suites/websocket.ts index 6b6655b..835e73e 100644 --- a/test/suites/websocket.ts +++ b/test/suites/websocket.ts @@ -247,13 +247,6 @@ export default (context: TestContext) => { name: packSubscriptionName(TOPIC, '0x123', 'id=F1&block=1', ''), }); - context.http.get = jest.fn( - () => - new FakeObservable({ - output: 'firefly://token/{id}', - }), - ); - await context.server .ws('/api/ws') .exec(() => { @@ -299,7 +292,6 @@ export default (context: TestContext) => { to: 'A', amount: '5', signer: 'A', - uri: 'firefly://token/0000000000000000000000000000000100000000000000000000000000000000', data: 'test', blockchain: { id: '000000000001/000000/000001', @@ -333,14 +325,11 @@ export default (context: TestContext) => { }); return true; }); - - expect(context.http.get).toHaveBeenCalledTimes(1); - expect(context.http.get).toHaveBeenCalledWith(`${BASE_URL}${INSTANCE_PATH}/uri?input=0`, {}); }); it('Token mint event with old pool ID', async () => { context.eventstream.getSubscription.mockReturnValueOnce({ - name: packSubscriptionName(TOPIC, '0x123', 'F1', ''), + name: packSubscriptionName(TOPIC, '0x123', 'N1', ''), }); context.http.get = jest.fn( @@ -365,7 +354,7 @@ export default (context: TestContext) => { logIndex: '1', timestamp: '2020-01-01 00:00:00Z', data: { - id: '340282366920938463463374607431768211456', + id: '57896044618658097711785492504343953926975274699741220483192166611388333031425', from: ZERO_ADDRESS, to: 'A', operator: 'A', @@ -391,11 +380,12 @@ export default (context: TestContext) => { event: 'token-mint', data: { id: '000000000001/000000/000001', - poolLocator: 'F1', + poolLocator: 'N1', + tokenIndex: '1', to: 'A', amount: '5', signer: 'A', - uri: 'firefly://token/0000000000000000000000000000000100000000000000000000000000000000', + uri: 'firefly://token/8000000000000000000000000000000100000000000000000000000000000001', data: 'test', blockchain: { id: '000000000001/000000/000001', @@ -404,7 +394,7 @@ export default (context: TestContext) => { signature: transferSingleEventSignature, timestamp: '2020-01-01 00:00:00Z', output: { - id: '340282366920938463463374607431768211456', + id: '57896044618658097711785492504343953926975274699741220483192166611388333031425', from: ZERO_ADDRESS, to: 'A', operator: 'A',