Skip to content

Commit 2b03a5b

Browse files
authored
Possibly undefined TokenDetails (#19)
1 parent 07ef069 commit 2b03a5b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/agent-sdk/src/evm/tokens.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { isAddress } from "viem";
22
import { getTokenInfo } from "./erc20";
33
import { type TokenInfo } from "./types";
44

5-
type SymbolMapping = Record<string, TokenInfo>;
5+
type SymbolMapping = Record<string, TokenInfo | undefined>;
66
type ChainId = number;
77
export type BlockchainMapping = Record<ChainId, SymbolMapping>;
88

@@ -36,7 +36,7 @@ export async function getTokenDetails(
3636
chainId: number,
3737
symbolOrAddress: string,
3838
tokenMap?: BlockchainMapping,
39-
): Promise<TokenInfo> {
39+
): Promise<TokenInfo | undefined> {
4040
if (isAddress(symbolOrAddress, { strict: false })) {
4141
return getTokenInfo(chainId, symbolOrAddress);
4242
}

packages/agent-sdk/tests/evm/token.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,9 @@ describe("getTokenDetails", () => {
1212
);
1313
expect(tokenDetails).toBeDefined();
1414
});
15+
16+
it("should return the token details for a given symbol", async () => {
17+
const tokenDetails = await getTokenDetails(43114, "UNI");
18+
expect(tokenDetails).toBeUndefined();
19+
});
1520
});

0 commit comments

Comments
 (0)