Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
"@duneanalytics/client-sdk": "^0.2.4",
"@types/bun": "latest",
"@types/jest": "^29.5.14",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"@typescript-eslint/parser": "^8.17.0",
"csv-parser": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^8.20.0",
"@typescript-eslint/parser": "^8.20.0",
"csv-parser": "^3.1.0",
"dotenv": "^16.4.7",
"eslint": "^9.16.0",
"eslint": "^9.18.0",
"jest": "^29.7.0",
"next": "^15.0.3",
"next": "^15.1.4",
"prettier": "^3.4.2",
"ts-jest": "^29.2.5",
"typescript": "^5.7.2",
"viem": "^2.21.53"
"typescript": "^5.7.3",
"viem": "^2.22.8"
}
}
2 changes: 1 addition & 1 deletion packages/agent-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"viem": "^2.21.53",
"near-safe": "^0.9.4",
"near-safe": "^0.9.6",
"zerion-sdk": "^0.0.13"
}
}
4 changes: 3 additions & 1 deletion packages/agent-sdk/src/evm/safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const SAFE_NETWORKS: { [chainId: number]: string } = {
137: "polygon",
8453: "base",
42161: "arbitrum",
43114: "avalanche",
11155111: "sepolia",
};

Expand Down Expand Up @@ -52,13 +53,14 @@ export async function getSafeBalances(
zerionKey?: string,
): Promise<TokenBalance[]> {
const baseUrl = safeTxServiceUrlFor(chainId);
console.log(baseUrl);
if (!baseUrl) {
console.warn(
`Chain ID ${chainId} not supported by Safe Transaction Service`,
);
return [];
}
const trusted = chainId === 11155111 ? false : true;
const trusted = false; // Avalanche USDC not trusted: 0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E
const exclude_spam = chainId === 11155111 ? false : true;
const url = `${baseUrl}/api/v1/safes/${checksumAddress(address)}/balances/?trusted=${trusted}&exclude_spam=${exclude_spam}`;

Expand Down
21 changes: 21 additions & 0 deletions packages/agent-sdk/tests/evm/safe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,27 @@ describe("getSafeBalances", () => {
]);
});

it.skip("should fetch balances for Avalanche", async () => {
const result = await getSafeBalances(
43114,
"0x54F08c27e75BeA0cdDdb8aA9D69FD61551B19BbA",
);
expect(result).toEqual([
{ tokenAddress: null, token: null, balance: "0" },
{
tokenAddress: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
token: {
name: "USD Coin",
symbol: "USDC",
decimals: 6,
logoUri:
"https://safe-transaction-assets.safe.global/tokens/logos/0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E.png",
},
balance: "19969999",
},
]);
});

it.skip("should fetch balances for Mainnet", async () => {
const result = await flatSafeBalances(
1,
Expand Down
13 changes: 12 additions & 1 deletion packages/agent-sdk/tests/evm/weth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("evm/weth", () => {
});

describe("getNativeAsset", () => {
it("returns correct native asset info for known chain", () => {
it("returns correct native asset info for known/gnosis chain", () => {
const result = getNativeAsset(100);

expect(result).toEqual({
Expand All @@ -106,6 +106,17 @@ describe("evm/weth", () => {
});
});

it("returns correct native asset info for Avalanche chain", () => {
const result = getNativeAsset(43114);
const WAVAX = "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7";
expect(result).toEqual({
address: WAVAX,
symbol: "AVAX",
scanUrl: `https://snowtrace.io/address/${WAVAX}`,
decimals: 18,
});
});

it("throws error for chain without wrapped address", () => {
// Mock a network without wrapped address
jest.spyOn(Network, "fromChainId").mockImplementationOnce(
Expand Down
Loading