Skip to content

Commit

Permalink
[baseURI-fix] handle burned token uri case
Browse files Browse the repository at this point in the history
Signed-off-by: David Echelberger <[email protected]>
  • Loading branch information
David Echelberger authored and awrichar committed Feb 2, 2022
1 parent 811c73f commit 7235015
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
31 changes: 17 additions & 14 deletions src/tokens/tokens.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,23 @@ class TokenListener implements EventListener {
contractAddress: string,
): Promise<string> {
const methodABI = standardAbiMap.ERC721WithData.find(method => method.name === 'tokenURI');

const response = await lastValueFrom(
this.service.http.post<EthConnectReturn>(`${this.service.baseUrl}?`, {
headers: {
type: 'Query',
},
from: operator,
to: contractAddress,
method: methodABI,
params: [tokenIdx],
} as EthConnectMsgRequest),
);

return response.data.output;
try {
const response = await lastValueFrom(
this.service.http.post<EthConnectReturn>(`${this.service.baseUrl}?`, {
headers: {
type: 'Query',
},
from: operator,
to: contractAddress,
method: methodABI,
params: [tokenIdx],
} as EthConnectMsgRequest),
);
return response.data.output;
} catch (e) {
this.logger.log(`Burned tokens do not have a URI: ${e}`);
return '';
}
}

private async transformTransferEvent(
Expand Down
4 changes: 2 additions & 2 deletions test/ws.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ describe('WebSocket AppController (e2e)', () => {
});

const baseUriResponse: EthConnectReturn = {
output: ERC721_BASE_URI,
output: '',
};

http.post = jest.fn(() => new FakeObservable(baseUriResponse));
Expand Down Expand Up @@ -552,7 +552,7 @@ describe('WebSocket AppController (e2e)', () => {
},
type: 'nonfungible',
tokenIndex: '721',
uri: ERC721_BASE_URI,
uri: '', // Burned tokens have no URI
} as TokenBurnEvent,
};

Expand Down

0 comments on commit 7235015

Please sign in to comment.