Skip to content

Commit

Permalink
Merge pull request #72 from hyperledger/uri
Browse files Browse the repository at this point in the history
Remove token URI for fungible tokens
  • Loading branch information
peterbroadhurst authored Apr 26, 2022
2 parents 2335748 + 336e9d8 commit ec538c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/tokens/tokens.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export class TokenTransferEvent extends tokenEventBase {
tokenIndex?: string;

@ApiProperty()
uri: string;
uri?: string;

@ApiProperty()
from: string;
Expand Down
3 changes: 2 additions & 1 deletion src/tokens/tokens.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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,
Expand Down
22 changes: 6 additions & 16 deletions test/suites/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,6 @@ export default (context: TestContext) => {
name: packSubscriptionName(TOPIC, '0x123', 'id=F1&block=1', ''),
});

context.http.get = jest.fn(
() =>
new FakeObservable(<EthConnectReturn>{
output: 'firefly://token/{id}',
}),
);

await context.server
.ws('/api/ws')
.exec(() => {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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(<EventStreamSubscription>{
name: packSubscriptionName(TOPIC, '0x123', 'F1', ''),
name: packSubscriptionName(TOPIC, '0x123', 'N1', ''),
});

context.http.get = jest.fn(
Expand All @@ -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',
Expand All @@ -391,11 +380,12 @@ export default (context: TestContext) => {
event: 'token-mint',
data: <TokenMintEvent>{
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',
Expand All @@ -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',
Expand Down

0 comments on commit ec538c7

Please sign in to comment.