@coinbase/agentkit 0.0.0-nightly-20250328174338

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/README.md +827 -0
  2. package/dist/action-providers/across/acrossActionProvider.d.ts +50 -0
  3. package/dist/action-providers/across/acrossActionProvider.js +333 -0
  4. package/dist/action-providers/across/acrossActionProvider.test.d.ts +1 -0
  5. package/dist/action-providers/across/acrossActionProvider.test.js +391 -0
  6. package/dist/action-providers/across/constants.d.ts +1 -0
  7. package/dist/action-providers/across/constants.js +2 -0
  8. package/dist/action-providers/across/index.d.ts +1 -0
  9. package/dist/action-providers/across/index.js +17 -0
  10. package/dist/action-providers/across/schemas.d.ts +36 -0
  11. package/dist/action-providers/across/schemas.js +46 -0
  12. package/dist/action-providers/across/utils.d.ts +7 -0
  13. package/dist/action-providers/across/utils.js +25 -0
  14. package/dist/action-providers/actionDecorator.d.ts +69 -0
  15. package/dist/action-providers/actionDecorator.js +96 -0
  16. package/dist/action-providers/actionProvider.d.ts +48 -0
  17. package/dist/action-providers/actionProvider.js +62 -0
  18. package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.d.ts +55 -0
  19. package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.js +173 -0
  20. package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.test.d.ts +1 -0
  21. package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.test.js +131 -0
  22. package/dist/action-providers/alchemy/index.d.ts +2 -0
  23. package/dist/action-providers/alchemy/index.js +18 -0
  24. package/dist/action-providers/alchemy/schemas.d.ts +41 -0
  25. package/dist/action-providers/alchemy/schemas.js +34 -0
  26. package/dist/action-providers/allora/alloraActionProvider.d.ts +44 -0
  27. package/dist/action-providers/allora/alloraActionProvider.js +195 -0
  28. package/dist/action-providers/allora/alloraActionProvider.test.d.ts +1 -0
  29. package/dist/action-providers/allora/alloraActionProvider.test.js +109 -0
  30. package/dist/action-providers/allora/index.d.ts +2 -0
  31. package/dist/action-providers/allora/index.js +18 -0
  32. package/dist/action-providers/allora/schemas.d.ts +28 -0
  33. package/dist/action-providers/allora/schemas.js +30 -0
  34. package/dist/action-providers/basename/basenameActionProvider.d.ts +30 -0
  35. package/dist/action-providers/basename/basenameActionProvider.js +109 -0
  36. package/dist/action-providers/basename/basenameActionProvider.test.d.ts +1 -0
  37. package/dist/action-providers/basename/basenameActionProvider.test.js +146 -0
  38. package/dist/action-providers/basename/constants.d.ts +52 -0
  39. package/dist/action-providers/basename/constants.js +81 -0
  40. package/dist/action-providers/basename/index.d.ts +2 -0
  41. package/dist/action-providers/basename/index.js +18 -0
  42. package/dist/action-providers/basename/schemas.d.ts +14 -0
  43. package/dist/action-providers/basename/schemas.js +14 -0
  44. package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +43 -0
  45. package/dist/action-providers/cdp/cdpApiActionProvider.js +128 -0
  46. package/dist/action-providers/cdp/cdpApiActionProvider.test.d.ts +1 -0
  47. package/dist/action-providers/cdp/cdpApiActionProvider.test.js +146 -0
  48. package/dist/action-providers/cdp/cdpWalletActionProvider.d.ts +58 -0
  49. package/dist/action-providers/cdp/cdpWalletActionProvider.js +224 -0
  50. package/dist/action-providers/cdp/cdpWalletActionProvider.test.d.ts +1 -0
  51. package/dist/action-providers/cdp/cdpWalletActionProvider.test.js +267 -0
  52. package/dist/action-providers/cdp/constants.d.ts +31 -0
  53. package/dist/action-providers/cdp/constants.js +34 -0
  54. package/dist/action-providers/cdp/index.d.ts +3 -0
  55. package/dist/action-providers/cdp/index.js +19 -0
  56. package/dist/action-providers/cdp/schemas.d.ts +91 -0
  57. package/dist/action-providers/cdp/schemas.js +77 -0
  58. package/dist/action-providers/compound/compoundActionProvider.d.ts +67 -0
  59. package/dist/action-providers/compound/compoundActionProvider.js +365 -0
  60. package/dist/action-providers/compound/compoundActionProvider.test.d.ts +1 -0
  61. package/dist/action-providers/compound/compoundActionProvider.test.js +353 -0
  62. package/dist/action-providers/compound/constants.d.ts +180 -0
  63. package/dist/action-providers/compound/constants.js +129 -0
  64. package/dist/action-providers/compound/index.d.ts +1 -0
  65. package/dist/action-providers/compound/index.js +17 -0
  66. package/dist/action-providers/compound/schemas.d.ts +57 -0
  67. package/dist/action-providers/compound/schemas.js +58 -0
  68. package/dist/action-providers/compound/utils.d.ts +95 -0
  69. package/dist/action-providers/compound/utils.js +353 -0
  70. package/dist/action-providers/customActionProvider.d.ts +30 -0
  71. package/dist/action-providers/customActionProvider.js +66 -0
  72. package/dist/action-providers/defillama/constants.d.ts +8 -0
  73. package/dist/action-providers/defillama/constants.js +11 -0
  74. package/dist/action-providers/defillama/defillamaActionProvider.d.ts +54 -0
  75. package/dist/action-providers/defillama/defillamaActionProvider.js +180 -0
  76. package/dist/action-providers/defillama/defillamaActionProvider.test.d.ts +1 -0
  77. package/dist/action-providers/defillama/defillamaActionProvider.test.js +114 -0
  78. package/dist/action-providers/defillama/index.d.ts +1 -0
  79. package/dist/action-providers/defillama/index.js +17 -0
  80. package/dist/action-providers/defillama/schemas.d.ts +34 -0
  81. package/dist/action-providers/defillama/schemas.js +34 -0
  82. package/dist/action-providers/defillama/types.d.ts +73 -0
  83. package/dist/action-providers/defillama/types.js +2 -0
  84. package/dist/action-providers/defillama/utils.d.ts +10 -0
  85. package/dist/action-providers/defillama/utils.js +87 -0
  86. package/dist/action-providers/defillama/utils.test.d.ts +1 -0
  87. package/dist/action-providers/defillama/utils.test.js +124 -0
  88. package/dist/action-providers/erc20/constants.d.ts +137 -0
  89. package/dist/action-providers/erc20/constants.js +202 -0
  90. package/dist/action-providers/erc20/erc20ActionProvider.d.ts +38 -0
  91. package/dist/action-providers/erc20/erc20ActionProvider.js +142 -0
  92. package/dist/action-providers/erc20/erc20ActionProvider.test.d.ts +1 -0
  93. package/dist/action-providers/erc20/erc20ActionProvider.test.js +131 -0
  94. package/dist/action-providers/erc20/index.d.ts +1 -0
  95. package/dist/action-providers/erc20/index.js +17 -0
  96. package/dist/action-providers/erc20/schemas.d.ts +27 -0
  97. package/dist/action-providers/erc20/schemas.js +26 -0
  98. package/dist/action-providers/erc721/constants.d.ts +232 -0
  99. package/dist/action-providers/erc721/constants.js +298 -0
  100. package/dist/action-providers/erc721/erc721ActionProvider.d.ts +46 -0
  101. package/dist/action-providers/erc721/erc721ActionProvider.js +164 -0
  102. package/dist/action-providers/erc721/erc721ActionProvider.test.d.ts +1 -0
  103. package/dist/action-providers/erc721/erc721ActionProvider.test.js +137 -0
  104. package/dist/action-providers/erc721/index.d.ts +1 -0
  105. package/dist/action-providers/erc721/index.js +17 -0
  106. package/dist/action-providers/erc721/schemas.d.ts +46 -0
  107. package/dist/action-providers/erc721/schemas.js +44 -0
  108. package/dist/action-providers/farcaster/farcasterActionProvider.d.ts +57 -0
  109. package/dist/action-providers/farcaster/farcasterActionProvider.js +142 -0
  110. package/dist/action-providers/farcaster/farcasterActionProvider.test.d.ts +1 -0
  111. package/dist/action-providers/farcaster/farcasterActionProvider.test.js +151 -0
  112. package/dist/action-providers/farcaster/index.d.ts +2 -0
  113. package/dist/action-providers/farcaster/index.js +18 -0
  114. package/dist/action-providers/farcaster/schemas.d.ts +15 -0
  115. package/dist/action-providers/farcaster/schemas.js +20 -0
  116. package/dist/action-providers/index.d.ts +24 -0
  117. package/dist/action-providers/index.js +40 -0
  118. package/dist/action-providers/jupiter/index.d.ts +1 -0
  119. package/dist/action-providers/jupiter/index.js +17 -0
  120. package/dist/action-providers/jupiter/jupiterActionProvider.d.ts +36 -0
  121. package/dist/action-providers/jupiter/jupiterActionProvider.js +115 -0
  122. package/dist/action-providers/jupiter/jupiterActionProvider.test.d.ts +1 -0
  123. package/dist/action-providers/jupiter/jupiterActionProvider.test.js +146 -0
  124. package/dist/action-providers/jupiter/schemas.d.ts +20 -0
  125. package/dist/action-providers/jupiter/schemas.js +20 -0
  126. package/dist/action-providers/messari/constants.d.ts +17 -0
  127. package/dist/action-providers/messari/constants.js +20 -0
  128. package/dist/action-providers/messari/index.d.ts +5 -0
  129. package/dist/action-providers/messari/index.js +21 -0
  130. package/dist/action-providers/messari/messariActionProvider.d.ts +42 -0
  131. package/dist/action-providers/messari/messariActionProvider.js +128 -0
  132. package/dist/action-providers/messari/messariActionProvider.test.d.ts +1 -0
  133. package/dist/action-providers/messari/messariActionProvider.test.js +152 -0
  134. package/dist/action-providers/messari/schemas.d.ts +11 -0
  135. package/dist/action-providers/messari/schemas.js +16 -0
  136. package/dist/action-providers/messari/types.d.ts +40 -0
  137. package/dist/action-providers/messari/types.js +2 -0
  138. package/dist/action-providers/messari/utils.d.ts +22 -0
  139. package/dist/action-providers/messari/utils.js +65 -0
  140. package/dist/action-providers/moonwell/constants.d.ts +78 -0
  141. package/dist/action-providers/moonwell/constants.js +111 -0
  142. package/dist/action-providers/moonwell/index.d.ts +1 -0
  143. package/dist/action-providers/moonwell/index.js +5 -0
  144. package/dist/action-providers/moonwell/moonwellActionProvider.d.ts +39 -0
  145. package/dist/action-providers/moonwell/moonwellActionProvider.js +249 -0
  146. package/dist/action-providers/moonwell/moonwellActionProvider.test.d.ts +1 -0
  147. package/dist/action-providers/moonwell/moonwellActionProvider.test.js +455 -0
  148. package/dist/action-providers/moonwell/schemas.d.ts +30 -0
  149. package/dist/action-providers/moonwell/schemas.js +39 -0
  150. package/dist/action-providers/morpho/constants.d.ts +16 -0
  151. package/dist/action-providers/morpho/constants.js +27 -0
  152. package/dist/action-providers/morpho/index.d.ts +2 -0
  153. package/dist/action-providers/morpho/index.js +18 -0
  154. package/dist/action-providers/morpho/morphoActionProvider.d.ts +39 -0
  155. package/dist/action-providers/morpho/morphoActionProvider.js +154 -0
  156. package/dist/action-providers/morpho/morphoActionProvider.test.d.ts +1 -0
  157. package/dist/action-providers/morpho/morphoActionProvider.test.js +128 -0
  158. package/dist/action-providers/morpho/schemas.d.ts +36 -0
  159. package/dist/action-providers/morpho/schemas.js +47 -0
  160. package/dist/action-providers/opensea/index.d.ts +1 -0
  161. package/dist/action-providers/opensea/index.js +17 -0
  162. package/dist/action-providers/opensea/openseaActionProvider.d.ts +59 -0
  163. package/dist/action-providers/opensea/openseaActionProvider.js +146 -0
  164. package/dist/action-providers/opensea/openseaActionProvider.test.d.ts +1 -0
  165. package/dist/action-providers/opensea/openseaActionProvider.test.js +201 -0
  166. package/dist/action-providers/opensea/schemas.d.ts +30 -0
  167. package/dist/action-providers/opensea/schemas.js +33 -0
  168. package/dist/action-providers/opensea/utils.d.ts +12 -0
  169. package/dist/action-providers/opensea/utils.js +47 -0
  170. package/dist/action-providers/pyth/index.d.ts +2 -0
  171. package/dist/action-providers/pyth/index.js +18 -0
  172. package/dist/action-providers/pyth/pythActionProvider.d.ts +33 -0
  173. package/dist/action-providers/pyth/pythActionProvider.js +121 -0
  174. package/dist/action-providers/pyth/pythActionProvider.test.d.ts +1 -0
  175. package/dist/action-providers/pyth/pythActionProvider.test.js +113 -0
  176. package/dist/action-providers/pyth/schemas.d.ts +21 -0
  177. package/dist/action-providers/pyth/schemas.js +20 -0
  178. package/dist/action-providers/spl/index.d.ts +1 -0
  179. package/dist/action-providers/spl/index.js +17 -0
  180. package/dist/action-providers/spl/schemas.d.ts +30 -0
  181. package/dist/action-providers/spl/schemas.js +26 -0
  182. package/dist/action-providers/spl/splActionProvider.d.ts +45 -0
  183. package/dist/action-providers/spl/splActionProvider.js +173 -0
  184. package/dist/action-providers/spl/splActionProvider.test.d.ts +1 -0
  185. package/dist/action-providers/spl/splActionProvider.test.js +300 -0
  186. package/dist/action-providers/twitter/index.d.ts +2 -0
  187. package/dist/action-providers/twitter/index.js +18 -0
  188. package/dist/action-providers/twitter/schemas.d.ts +38 -0
  189. package/dist/action-providers/twitter/schemas.js +44 -0
  190. package/dist/action-providers/twitter/twitterActionProvider.d.ts +82 -0
  191. package/dist/action-providers/twitter/twitterActionProvider.js +204 -0
  192. package/dist/action-providers/twitter/twitterActionProvider.test.d.ts +1 -0
  193. package/dist/action-providers/twitter/twitterActionProvider.test.js +185 -0
  194. package/dist/action-providers/wallet/index.d.ts +1 -0
  195. package/dist/action-providers/wallet/index.js +17 -0
  196. package/dist/action-providers/wallet/schemas.d.ts +19 -0
  197. package/dist/action-providers/wallet/schemas.js +19 -0
  198. package/dist/action-providers/wallet/walletActionProvider.d.ts +44 -0
  199. package/dist/action-providers/wallet/walletActionProvider.js +140 -0
  200. package/dist/action-providers/wallet/walletActionProvider.test.d.ts +1 -0
  201. package/dist/action-providers/wallet/walletActionProvider.test.js +194 -0
  202. package/dist/action-providers/weth/constants.d.ts +19 -0
  203. package/dist/action-providers/weth/constants.js +29 -0
  204. package/dist/action-providers/weth/index.d.ts +1 -0
  205. package/dist/action-providers/weth/index.js +17 -0
  206. package/dist/action-providers/weth/schemas.d.ts +8 -0
  207. package/dist/action-providers/weth/schemas.js +10 -0
  208. package/dist/action-providers/weth/wethActionProvider.d.ts +30 -0
  209. package/dist/action-providers/weth/wethActionProvider.js +89 -0
  210. package/dist/action-providers/weth/wethActionProvider.test.d.ts +1 -0
  211. package/dist/action-providers/weth/wethActionProvider.test.js +92 -0
  212. package/dist/action-providers/wow/constants.d.ts +15 -0
  213. package/dist/action-providers/wow/constants.js +844 -0
  214. package/dist/action-providers/wow/index.d.ts +2 -0
  215. package/dist/action-providers/wow/index.js +18 -0
  216. package/dist/action-providers/wow/schemas.d.ts +43 -0
  217. package/dist/action-providers/wow/schemas.js +47 -0
  218. package/dist/action-providers/wow/uniswap/constants.d.ts +3 -0
  219. package/dist/action-providers/wow/uniswap/constants.js +100 -0
  220. package/dist/action-providers/wow/uniswap/utils.d.ts +82 -0
  221. package/dist/action-providers/wow/uniswap/utils.js +226 -0
  222. package/dist/action-providers/wow/utils.d.ts +27 -0
  223. package/dist/action-providers/wow/utils.js +63 -0
  224. package/dist/action-providers/wow/wowActionProvider.d.ts +46 -0
  225. package/dist/action-providers/wow/wowActionProvider.js +223 -0
  226. package/dist/action-providers/wow/wowActionProvider.test.d.ts +1 -0
  227. package/dist/action-providers/wow/wowActionProvider.test.js +291 -0
  228. package/dist/agentkit.d.ts +44 -0
  229. package/dist/agentkit.js +68 -0
  230. package/dist/analytics/index.d.ts +1 -0
  231. package/dist/analytics/index.js +17 -0
  232. package/dist/analytics/sendAnalyticsEvent.d.ts +31 -0
  233. package/dist/analytics/sendAnalyticsEvent.js +52 -0
  234. package/dist/index.d.ts +4 -0
  235. package/dist/index.js +20 -0
  236. package/dist/network/index.d.ts +3 -0
  237. package/dist/network/index.js +19 -0
  238. package/dist/network/network.d.ts +20 -0
  239. package/dist/network/network.js +86 -0
  240. package/dist/network/svm.d.ts +15 -0
  241. package/dist/network/svm.js +38 -0
  242. package/dist/network/types.d.ts +17 -0
  243. package/dist/network/types.js +2 -0
  244. package/dist/utils.d.ts +22 -0
  245. package/dist/utils.js +57 -0
  246. package/dist/utils.test.d.ts +1 -0
  247. package/dist/utils.test.js +50 -0
  248. package/dist/wallet-providers/cdpWalletProvider.d.ts +246 -0
  249. package/dist/wallet-providers/cdpWalletProvider.js +421 -0
  250. package/dist/wallet-providers/cdpWalletProvider.test.d.ts +1 -0
  251. package/dist/wallet-providers/cdpWalletProvider.test.js +701 -0
  252. package/dist/wallet-providers/evmWalletProvider.d.ts +51 -0
  253. package/dist/wallet-providers/evmWalletProvider.js +14 -0
  254. package/dist/wallet-providers/evmWalletProvider.test.d.ts +1 -0
  255. package/dist/wallet-providers/evmWalletProvider.test.js +56 -0
  256. package/dist/wallet-providers/index.d.ts +10 -0
  257. package/dist/wallet-providers/index.js +26 -0
  258. package/dist/wallet-providers/privyEvmWalletProvider.d.ts +55 -0
  259. package/dist/wallet-providers/privyEvmWalletProvider.js +140 -0
  260. package/dist/wallet-providers/privyEvmWalletProvider.test.d.ts +1 -0
  261. package/dist/wallet-providers/privyEvmWalletProvider.test.js +331 -0
  262. package/dist/wallet-providers/privyShared.d.ts +40 -0
  263. package/dist/wallet-providers/privyShared.js +49 -0
  264. package/dist/wallet-providers/privySvmWalletProvider.d.ts +128 -0
  265. package/dist/wallet-providers/privySvmWalletProvider.js +212 -0
  266. package/dist/wallet-providers/privySvmWalletProvider.test.d.ts +1 -0
  267. package/dist/wallet-providers/privySvmWalletProvider.test.js +310 -0
  268. package/dist/wallet-providers/privyWalletProvider.d.ts +35 -0
  269. package/dist/wallet-providers/privyWalletProvider.js +39 -0
  270. package/dist/wallet-providers/privyWalletProvider.test.d.ts +1 -0
  271. package/dist/wallet-providers/privyWalletProvider.test.js +124 -0
  272. package/dist/wallet-providers/smartWalletProvider.d.ts +177 -0
  273. package/dist/wallet-providers/smartWalletProvider.js +303 -0
  274. package/dist/wallet-providers/smartWalletProvider.test.d.ts +1 -0
  275. package/dist/wallet-providers/smartWalletProvider.test.js +388 -0
  276. package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +143 -0
  277. package/dist/wallet-providers/solanaKeypairWalletProvider.js +280 -0
  278. package/dist/wallet-providers/solanaKeypairWalletProvider.test.d.ts +1 -0
  279. package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +218 -0
  280. package/dist/wallet-providers/svmWalletProvider.d.ts +56 -0
  281. package/dist/wallet-providers/svmWalletProvider.js +13 -0
  282. package/dist/wallet-providers/svmWalletProvider.test.d.ts +1 -0
  283. package/dist/wallet-providers/svmWalletProvider.test.js +55 -0
  284. package/dist/wallet-providers/viemWalletProvider.d.ts +103 -0
  285. package/dist/wallet-providers/viemWalletProvider.js +206 -0
  286. package/dist/wallet-providers/viemWalletProvider.test.d.ts +1 -0
  287. package/dist/wallet-providers/viemWalletProvider.test.js +338 -0
  288. package/dist/wallet-providers/walletProvider.d.ts +48 -0
  289. package/dist/wallet-providers/walletProvider.js +41 -0
  290. package/dist/wallet-providers/walletProvider.test.d.ts +1 -0
  291. package/dist/wallet-providers/walletProvider.test.js +103 -0
  292. package/package.json +83 -0
@@ -0,0 +1,391 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const acrossActionProvider_1 = require("./acrossActionProvider");
4
+ const viem_1 = require("viem");
5
+ // Mock the necessary imports and modules
6
+ jest.mock("viem", () => {
7
+ return {
8
+ ...jest.requireActual("viem"),
9
+ createPublicClient: jest.fn(),
10
+ createWalletClient: jest.fn(() => ({
11
+ writeContract: jest.fn().mockResolvedValue("0xdepositTxHash"),
12
+ })),
13
+ http: jest.fn(),
14
+ formatUnits: jest.fn().mockImplementation((value, decimals) => {
15
+ // Simple mock implementation just for testing
16
+ if (typeof value === "bigint") {
17
+ if (decimals === 18) {
18
+ return (Number(value) / 10 ** 18).toString();
19
+ }
20
+ return value.toString();
21
+ }
22
+ return value.toString();
23
+ }),
24
+ parseUnits: jest.fn().mockImplementation((value, decimals) => {
25
+ if (decimals === 18) {
26
+ return BigInt(Number(value) * 10 ** 18);
27
+ }
28
+ return BigInt(value);
29
+ }),
30
+ };
31
+ });
32
+ jest.mock("viem/accounts", () => ({
33
+ privateKeyToAccount: jest.fn().mockReturnValue({
34
+ address: "0x9876543210987654321098765432109876543210",
35
+ }),
36
+ }));
37
+ // Mock the network module
38
+ jest.mock("../../network", () => {
39
+ return {
40
+ ...jest.requireActual("../../network"),
41
+ NETWORK_ID_TO_VIEM_CHAIN: {
42
+ "ethereum-mainnet": {
43
+ id: 1,
44
+ name: "Ethereum",
45
+ network: "mainnet",
46
+ },
47
+ optimism: {
48
+ id: 10,
49
+ name: "Optimism",
50
+ network: "optimism",
51
+ },
52
+ "base-sepolia": {
53
+ id: 84532,
54
+ name: "Base Sepolia",
55
+ network: "base-sepolia",
56
+ },
57
+ },
58
+ CHAIN_ID_TO_NETWORK_ID: {
59
+ "1": "ethereum-mainnet",
60
+ "10": "optimism",
61
+ "84532": "base-sepolia",
62
+ },
63
+ };
64
+ });
65
+ // Mock the Across SDK
66
+ const mockCreateAcrossClient = jest.fn();
67
+ jest.mock("@across-protocol/app-sdk", () => ({
68
+ createAcrossClient: mockCreateAcrossClient,
69
+ }));
70
+ // Default implementation for the createAcrossClient mock
71
+ const defaultClientImplementation = () => ({
72
+ getSupportedChains: jest.fn().mockResolvedValue([
73
+ {
74
+ chainId: 1, // Ethereum
75
+ name: "Ethereum",
76
+ network: "mainnet",
77
+ inputTokens: [
78
+ {
79
+ symbol: "ETH",
80
+ address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
81
+ decimals: 18,
82
+ },
83
+ {
84
+ symbol: "USDC",
85
+ address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
86
+ decimals: 6,
87
+ },
88
+ ],
89
+ },
90
+ {
91
+ chainId: 10, // Optimism
92
+ name: "Optimism",
93
+ network: "optimism",
94
+ inputTokens: [
95
+ {
96
+ symbol: "ETH",
97
+ address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
98
+ decimals: 18,
99
+ },
100
+ ],
101
+ },
102
+ ]),
103
+ getAvailableRoutes: jest.fn().mockResolvedValue([
104
+ {
105
+ isNative: true,
106
+ originToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
107
+ },
108
+ {
109
+ isNative: false,
110
+ originToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
111
+ },
112
+ ]),
113
+ getQuote: jest.fn().mockResolvedValue({
114
+ deposit: {
115
+ inputAmount: BigInt("1000000000000000000"), // 1 ETH
116
+ outputAmount: BigInt("990000000000000000"), // 0.99 ETH (1% difference)
117
+ spokePoolAddress: "0x1234567890123456789012345678901234567890",
118
+ },
119
+ limits: {
120
+ minDeposit: BigInt("100000000000000000"), // 0.1 ETH
121
+ maxDeposit: BigInt("10000000000000000000"), // 10 ETH
122
+ },
123
+ }),
124
+ simulateDepositTx: jest.fn().mockResolvedValue({
125
+ request: {
126
+ address: "0x1234567890123456789012345678901234567890",
127
+ abi: [],
128
+ functionName: "deposit",
129
+ args: [],
130
+ },
131
+ }),
132
+ waitForDepositTx: jest.fn().mockResolvedValue({
133
+ depositId: "123456",
134
+ }),
135
+ });
136
+ // Set the default implementation
137
+ mockCreateAcrossClient.mockImplementation(() => {
138
+ const client = defaultClientImplementation();
139
+ // Add the chains property to match what the code expects
140
+ return {
141
+ ...client,
142
+ chains: [
143
+ {
144
+ id: 1,
145
+ name: "Ethereum",
146
+ network: "mainnet",
147
+ },
148
+ {
149
+ id: 10,
150
+ name: "Optimism",
151
+ network: "optimism",
152
+ },
153
+ ],
154
+ };
155
+ });
156
+ // Mock the isTestnet function
157
+ jest.mock("./utils", () => ({
158
+ isAcrossSupportedTestnet: jest.fn().mockReturnValue(false),
159
+ }));
160
+ describe("Across Action Provider", () => {
161
+ const MOCK_PRIVATE_KEY = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
162
+ const MOCK_INPUT_TOKEN_SYMBOL = "ETH";
163
+ const MOCK_AMOUNT = "1.0";
164
+ const MOCK_DESTINATION_CHAIN_ID = "10"; // Optimism
165
+ const MOCK_RECIPIENT = "0x9876543210987654321098765432109876543210";
166
+ const MOCK_MAX_SLIPPAGE = 2.0;
167
+ let mockWallet;
168
+ let actionProvider;
169
+ let mockPublicClient;
170
+ beforeEach(() => {
171
+ jest.clearAllMocks();
172
+ // Reset to default implementation
173
+ mockCreateAcrossClient.mockImplementation(() => {
174
+ const client = defaultClientImplementation();
175
+ // Add the chains property to match what the code expects
176
+ return {
177
+ ...client,
178
+ chains: [
179
+ {
180
+ id: 1,
181
+ name: "Ethereum",
182
+ network: "mainnet",
183
+ },
184
+ {
185
+ id: 10,
186
+ name: "Optimism",
187
+ network: "optimism",
188
+ },
189
+ ],
190
+ };
191
+ });
192
+ mockPublicClient = {
193
+ getBalance: jest.fn().mockResolvedValue(BigInt("2000000000000000000")), // 2 ETH
194
+ readContract: jest.fn().mockResolvedValue(BigInt("2000000000000000000")), // 2 ETH or 2 USDC
195
+ waitForTransactionReceipt: jest.fn().mockResolvedValue({}),
196
+ };
197
+ viem_1.createPublicClient.mockReturnValue(mockPublicClient);
198
+ mockWallet = {
199
+ getAddress: jest.fn().mockReturnValue(MOCK_RECIPIENT),
200
+ sendTransaction: jest.fn().mockResolvedValue("0xmocktxhash"),
201
+ waitForTransactionReceipt: jest.fn(),
202
+ getNetwork: jest.fn().mockReturnValue({
203
+ chainId: "1", // Ethereum mainnet
204
+ networkId: "ethereum-mainnet",
205
+ protocolFamily: "evm",
206
+ }),
207
+ getBalance: jest.fn().mockResolvedValue(BigInt("2000000000000000000")), // 2 ETH
208
+ readContract: jest.fn().mockResolvedValue(BigInt("2000000000000000000")), // 2 ETH/USDC
209
+ };
210
+ actionProvider = (0, acrossActionProvider_1.acrossActionProvider)({
211
+ privateKey: MOCK_PRIVATE_KEY,
212
+ });
213
+ });
214
+ describe("bridgeToken", () => {
215
+ it("should successfully bridge native ETH", async () => {
216
+ const args = {
217
+ inputTokenSymbol: MOCK_INPUT_TOKEN_SYMBOL,
218
+ amount: MOCK_AMOUNT,
219
+ destinationChainId: MOCK_DESTINATION_CHAIN_ID,
220
+ recipient: MOCK_RECIPIENT,
221
+ maxSplippage: MOCK_MAX_SLIPPAGE,
222
+ };
223
+ const response = await actionProvider.bridgeToken(mockWallet, args);
224
+ // Verify the SDK interactions and response
225
+ expect(response).toContain("Successfully deposited tokens");
226
+ expect(response).toContain(`Token: ${MOCK_INPUT_TOKEN_SYMBOL}`);
227
+ expect(response).toContain("Transaction Hash for deposit: 0xdepositTxHash");
228
+ });
229
+ it("should successfully bridge ERC20 tokens", async () => {
230
+ const args = {
231
+ inputTokenSymbol: "USDC",
232
+ amount: "100",
233
+ destinationChainId: MOCK_DESTINATION_CHAIN_ID,
234
+ recipient: MOCK_RECIPIENT,
235
+ maxSplippage: MOCK_MAX_SLIPPAGE,
236
+ };
237
+ // Set up mock for approval and deposit transactions
238
+ mockWallet.sendTransaction
239
+ .mockResolvedValueOnce("0xapprovalTxHash")
240
+ .mockResolvedValueOnce("0xdepositTxHash");
241
+ const response = await actionProvider.bridgeToken(mockWallet, args);
242
+ // Verify the SDK interactions and response
243
+ expect(response).toContain("Successfully deposited tokens");
244
+ expect(response).toContain(`Token: ${args.inputTokenSymbol}`);
245
+ expect(response).toContain("Transaction Hash for approval: 0xapprovalTxHash");
246
+ expect(response).toContain("Transaction Hash for deposit: 0xdepositTxHash");
247
+ });
248
+ it("should fail when slippage is too high", async () => {
249
+ // Override the default mock with high slippage for this test only
250
+ mockCreateAcrossClient.mockImplementationOnce(() => ({
251
+ getSupportedChains: jest.fn().mockResolvedValue([
252
+ {
253
+ chainId: 1,
254
+ inputTokens: [
255
+ {
256
+ symbol: "ETH",
257
+ address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
258
+ decimals: 18,
259
+ },
260
+ ],
261
+ },
262
+ ]),
263
+ getAvailableRoutes: jest.fn().mockResolvedValue([
264
+ {
265
+ isNative: true,
266
+ originToken: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
267
+ },
268
+ ]),
269
+ getQuote: jest.fn().mockResolvedValue({
270
+ deposit: {
271
+ inputAmount: BigInt("1000000000000000000"), // 1 ETH
272
+ outputAmount: BigInt("800000000000000000"), // 0.8 ETH (20% difference)
273
+ spokePoolAddress: "0x1234567890123456789012345678901234567890",
274
+ },
275
+ limits: {
276
+ minDeposit: BigInt("100000000000000000"),
277
+ maxDeposit: BigInt("10000000000000000000"),
278
+ },
279
+ }),
280
+ simulateDepositTx: jest.fn().mockResolvedValue({
281
+ request: {
282
+ address: "0x1234567890123456789012345678901234567890",
283
+ abi: [],
284
+ functionName: "deposit",
285
+ args: [],
286
+ },
287
+ }),
288
+ waitForDepositTx: jest.fn().mockResolvedValue({
289
+ depositId: "123456",
290
+ }),
291
+ }));
292
+ // Set a low max slippage
293
+ const args = {
294
+ inputTokenSymbol: MOCK_INPUT_TOKEN_SYMBOL,
295
+ amount: MOCK_AMOUNT,
296
+ destinationChainId: MOCK_DESTINATION_CHAIN_ID,
297
+ recipient: MOCK_RECIPIENT,
298
+ maxSplippage: 0.5, // Only allow 0.5% slippage
299
+ };
300
+ const response = await actionProvider.bridgeToken(mockWallet, args);
301
+ // Verify the error response
302
+ expect(response).toContain("Error with Across SDK");
303
+ expect(response).toContain("exceeds the maximum allowed slippage of 0.5%");
304
+ });
305
+ it("should handle errors in bridging", async () => {
306
+ const error = new Error("Insufficient balance");
307
+ mockWallet.getBalance.mockRejectedValueOnce(error);
308
+ mockWallet.sendTransaction.mockRejectedValueOnce(error);
309
+ const args = {
310
+ inputTokenSymbol: MOCK_INPUT_TOKEN_SYMBOL,
311
+ amount: MOCK_AMOUNT,
312
+ destinationChainId: MOCK_DESTINATION_CHAIN_ID,
313
+ recipient: MOCK_RECIPIENT,
314
+ maxSplippage: MOCK_MAX_SLIPPAGE,
315
+ };
316
+ const response = await actionProvider.bridgeToken(mockWallet, args);
317
+ expect(response).toContain("Error with Across SDK");
318
+ expect(response).toContain(error.message);
319
+ });
320
+ });
321
+ describe("checkDepositStatus", () => {
322
+ beforeEach(() => {
323
+ global.fetch = jest.fn();
324
+ });
325
+ it("should successfully check deposit status", async () => {
326
+ // Mock successful API response
327
+ const mockApiResponse = {
328
+ status: "filled",
329
+ originChainId: 1,
330
+ destinationChainId: 10,
331
+ depositTxHash: "0xdepositTxHash",
332
+ fillTx: "0xfillTxHash",
333
+ };
334
+ global.fetch.mockResolvedValueOnce({
335
+ ok: true,
336
+ json: async () => mockApiResponse,
337
+ });
338
+ const args = {
339
+ originChainId: "1",
340
+ depositId: "123456",
341
+ };
342
+ const response = await actionProvider.checkDepositStatus(mockWallet, args);
343
+ const parsedResponse = JSON.parse(response);
344
+ expect(parsedResponse.status).toEqual("filled");
345
+ expect(parsedResponse.depositTxInfo.txHash).toEqual("0xdepositTxHash");
346
+ expect(parsedResponse.fillTxInfo.txHash).toEqual("0xfillTxHash");
347
+ });
348
+ it("should handle API errors", async () => {
349
+ // Mock API error
350
+ global.fetch.mockResolvedValueOnce({
351
+ ok: false,
352
+ status: 404,
353
+ });
354
+ const args = {
355
+ originChainId: "1",
356
+ depositId: "123456",
357
+ };
358
+ const response = await actionProvider.checkDepositStatus(mockWallet, args);
359
+ expect(response).toContain("Error checking deposit status");
360
+ expect(response).toContain("404");
361
+ });
362
+ it("should handle network errors", async () => {
363
+ // Mock network error
364
+ global.fetch.mockRejectedValueOnce(new Error("Network error"));
365
+ const args = {
366
+ originChainId: "1",
367
+ depositId: "123456",
368
+ };
369
+ const response = await actionProvider.checkDepositStatus(mockWallet, args);
370
+ expect(response).toContain("Error checking deposit status");
371
+ expect(response).toContain("Network error");
372
+ });
373
+ });
374
+ describe("supportsNetwork", () => {
375
+ it("should return true for supported networks", () => {
376
+ const evmNetwork = {
377
+ protocolFamily: "evm",
378
+ networkId: "ethereum",
379
+ chainId: "1",
380
+ };
381
+ expect(actionProvider.supportsNetwork(evmNetwork)).toBe(true);
382
+ });
383
+ it("should return false for unsupported networks", () => {
384
+ const nonEvmNetwork = {
385
+ protocolFamily: "solana",
386
+ networkId: "mainnet",
387
+ };
388
+ expect(actionProvider.supportsNetwork(nonEvmNetwork)).toBe(false);
389
+ });
390
+ });
391
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./acrossActionProvider";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./acrossActionProvider"), exports);
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Input schema for bridge token action.
4
+ */
5
+ export declare const BridgeTokenSchema: z.ZodObject<{
6
+ destinationChainId: z.ZodString;
7
+ inputTokenSymbol: z.ZodDefault<z.ZodString>;
8
+ amount: z.ZodString;
9
+ recipient: z.ZodOptional<z.ZodString>;
10
+ maxSplippage: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ amount: string;
13
+ destinationChainId: string;
14
+ inputTokenSymbol: string;
15
+ maxSplippage: number;
16
+ recipient?: string | undefined;
17
+ }, {
18
+ amount: string;
19
+ destinationChainId: string;
20
+ inputTokenSymbol?: string | undefined;
21
+ recipient?: string | undefined;
22
+ maxSplippage?: number | undefined;
23
+ }>;
24
+ /**
25
+ * Input schema for check deposit status action.
26
+ */
27
+ export declare const CheckDepositStatusSchema: z.ZodObject<{
28
+ originChainId: z.ZodOptional<z.ZodString>;
29
+ depositId: z.ZodString;
30
+ }, "strip", z.ZodTypeAny, {
31
+ depositId: string;
32
+ originChainId?: string | undefined;
33
+ }, {
34
+ depositId: string;
35
+ originChainId?: string | undefined;
36
+ }>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CheckDepositStatusSchema = exports.BridgeTokenSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Input schema for bridge token action.
7
+ */
8
+ exports.BridgeTokenSchema = zod_1.z
9
+ .object({
10
+ destinationChainId: zod_1.z
11
+ .string()
12
+ .describe("The chain ID of the destination chain (e.g. 11155111 for ethereum-sepolia)"),
13
+ inputTokenSymbol: zod_1.z
14
+ .string()
15
+ .describe("The symbol of the token to bridge (e.g., 'ETH', 'WETH', 'USDC')")
16
+ .default("ETH"),
17
+ amount: zod_1.z
18
+ .string()
19
+ .describe("The amount of tokens to bridge in whole units (e.g. 1.5 WETH, 10 USDC)"),
20
+ recipient: zod_1.z
21
+ .string()
22
+ .optional()
23
+ .describe("The recipient address on the destination chain (defaults to sender)"),
24
+ maxSplippage: zod_1.z
25
+ .number()
26
+ .optional()
27
+ .describe("The maximum slippage percentage (e.g. 10 for 10%)")
28
+ .default(1.5),
29
+ })
30
+ .strip()
31
+ .describe("Instructions for bridging tokens across chains using Across Protocol");
32
+ /**
33
+ * Input schema for check deposit status action.
34
+ */
35
+ exports.CheckDepositStatusSchema = zod_1.z
36
+ .object({
37
+ originChainId: zod_1.z
38
+ .string()
39
+ .optional()
40
+ .describe("The chain ID of the origin chain (defaults to the current chain)"),
41
+ depositId: zod_1.z
42
+ .string()
43
+ .describe("The ID of the deposit to check (returned by the bridge deposit transaction)"),
44
+ })
45
+ .strip()
46
+ .describe("Instructions for checking the status of a deposit on Across Protocol");
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Checks if a chain ID corresponds to a testnet network supported by Across
3
+ *
4
+ * @param chainId - The blockchain network chain ID
5
+ * @returns true if the chain ID corresponds to a testnet network supported by Across, false otherwise
6
+ */
7
+ export declare function isAcrossSupportedTestnet(chainId: number): boolean;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAcrossSupportedTestnet = isAcrossSupportedTestnet;
4
+ /**
5
+ * Checks if a chain ID corresponds to a testnet network supported by Across
6
+ *
7
+ * @param chainId - The blockchain network chain ID
8
+ * @returns true if the chain ID corresponds to a testnet network supported by Across, false otherwise
9
+ */
10
+ function isAcrossSupportedTestnet(chainId) {
11
+ // List of testnet chain IDs
12
+ const testnetChainIds = [
13
+ 11155111, // Sepolia
14
+ 84532, // Base Sepolia
15
+ 421614, // Arbitrum Sepolia
16
+ 11155420, // Optimism Sepolia
17
+ 919, // Mode Sepolia
18
+ 80002, // Polygon Amoy
19
+ 168587773, // Blast Sepolia
20
+ 4202, // Lisk Sepolia
21
+ 37111, // Lens Sepolia
22
+ 1301, // Unichain Sepolia
23
+ ];
24
+ return testnetChainIds.includes(chainId);
25
+ }
@@ -0,0 +1,69 @@
1
+ import { z } from "zod";
2
+ import "reflect-metadata";
3
+ /**
4
+ * Parameters for the create action decorator
5
+ */
6
+ export interface CreateActionDecoratorParams {
7
+ /**
8
+ * The name of the action
9
+ */
10
+ name: string;
11
+ /**
12
+ * The description of the action
13
+ */
14
+ description: string;
15
+ /**
16
+ * The schema of the action
17
+ */
18
+ schema: z.ZodSchema;
19
+ }
20
+ /**
21
+ * Metadata key for the action decorator
22
+ */
23
+ export declare const ACTION_DECORATOR_KEY: unique symbol;
24
+ /**
25
+ * Metadata for AgentKit actions
26
+ */
27
+ export interface ActionMetadata {
28
+ /**
29
+ * The name of the action
30
+ */
31
+ name: string;
32
+ /**
33
+ * The description of the action
34
+ */
35
+ description: string;
36
+ /**
37
+ * The schema of the action
38
+ */
39
+ schema: z.ZodSchema;
40
+ /**
41
+ * The function to invoke the action
42
+ */
43
+ invoke: (...args: any[]) => any;
44
+ /**
45
+ * The wallet provider to use for the action
46
+ */
47
+ walletProvider: boolean;
48
+ }
49
+ /**
50
+ * A map of action names to their metadata
51
+ */
52
+ export type StoredActionMetadata = Map<string, ActionMetadata>;
53
+ /**
54
+ * Decorator to embed metadata on class methods to indicate they are actions accessible to the agent
55
+ *
56
+ * @param params - The parameters for the action decorator
57
+ * @returns A decorator function
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * class MyActionProvider extends ActionProvider {
62
+ * @CreateAction({ name: "my_action", description: "My action", schema: myActionSchema })
63
+ * public myAction(args: z.infer<typeof myActionSchema>) {
64
+ * // ...
65
+ * }
66
+ * }
67
+ * ```
68
+ */
69
+ export declare function CreateAction(params: CreateActionDecoratorParams): (target: object, propertyKey: string, descriptor: PropertyDescriptor) => object;