diff --git a/bun.lockb b/bun.lockb index c643556..c823b1e 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 1cfe583..2997cad 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/packages/agent-sdk/package.json b/packages/agent-sdk/package.json index 643ce7c..f9284d5 100644 --- a/packages/agent-sdk/package.json +++ b/packages/agent-sdk/package.json @@ -33,7 +33,7 @@ }, "dependencies": { "viem": "^2.21.53", - "near-safe": "^0.9.4", + "near-safe": "^0.9.6", "zerion-sdk": "^0.0.13" } } diff --git a/packages/agent-sdk/src/evm/safe.ts b/packages/agent-sdk/src/evm/safe.ts index c4bc663..ba27459 100644 --- a/packages/agent-sdk/src/evm/safe.ts +++ b/packages/agent-sdk/src/evm/safe.ts @@ -22,6 +22,7 @@ const SAFE_NETWORKS: { [chainId: number]: string } = { 137: "polygon", 8453: "base", 42161: "arbitrum", + 43114: "avalanche", 11155111: "sepolia", }; @@ -52,13 +53,14 @@ export async function getSafeBalances( zerionKey?: string, ): Promise { 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}`; diff --git a/packages/agent-sdk/tests/evm/safe.spec.ts b/packages/agent-sdk/tests/evm/safe.spec.ts index c7f1d14..8488c45 100644 --- a/packages/agent-sdk/tests/evm/safe.spec.ts +++ b/packages/agent-sdk/tests/evm/safe.spec.ts @@ -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, diff --git a/packages/agent-sdk/tests/evm/weth.spec.ts b/packages/agent-sdk/tests/evm/weth.spec.ts index 957b108..72d7bee 100644 --- a/packages/agent-sdk/tests/evm/weth.spec.ts +++ b/packages/agent-sdk/tests/evm/weth.spec.ts @@ -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({ @@ -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(