Skip to content

Commit 56f5229

Browse files
committed
fix: balance display for hardhat network
1 parent c7d544b commit 56f5229

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

javascript/tokenscript-viewer/src/integration/discoveryAdapter.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export class DiscoveryAdapter implements ITokenDiscoveryAdapter {
321321
const contract = this.getEthersContractInstance(token.contractAddress, token.chainId, token.tokenType);
322322

323323

324-
let name, symbol, contractUri, description, image;
324+
let name, symbol, contractUri, description, image, decimals = 1;
325325

326326
try {
327327
name = await contract.name();
@@ -363,11 +363,20 @@ export class DiscoveryAdapter implements ITokenDiscoveryAdapter {
363363
}
364364
}
365365

366+
if (token.tokenType === "erc20"){
367+
try {
368+
decimals = Number((await contract.decimals()).toString());
369+
} catch (e){
370+
console.log(e);
371+
}
372+
}
373+
366374
return <ITokenCollection>{
367375
name: name ?? "Test collection",
368376
symbol: symbol,
369377
description: description ?? "",
370378
image,
379+
decimals
371380
}
372381
}
373382

0 commit comments

Comments
 (0)