@coinbase/agentkit 0.10.2 → 0.10.3

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 (62) hide show
  1. package/README.md +42 -0
  2. package/dist/action-providers/cdp/cdpApiActionProvider.js +7 -30
  3. package/dist/action-providers/cdp/cdpApiActionProvider.test.js +2 -8
  4. package/dist/action-providers/cdp/faucetUtils.d.ts +38 -0
  5. package/dist/action-providers/cdp/faucetUtils.js +81 -0
  6. package/dist/action-providers/clanker/schemas.d.ts +4 -4
  7. package/dist/action-providers/enso/constants.d.ts +4 -0
  8. package/dist/action-providers/enso/constants.js +10 -0
  9. package/dist/action-providers/enso/ensoActionProvider.d.ts +34 -0
  10. package/dist/action-providers/enso/ensoActionProvider.js +125 -0
  11. package/dist/action-providers/enso/ensoActionProvider.test.d.ts +1 -0
  12. package/dist/action-providers/enso/ensoActionProvider.test.js +141 -0
  13. package/dist/action-providers/enso/index.d.ts +1 -0
  14. package/dist/action-providers/enso/index.js +17 -0
  15. package/dist/action-providers/enso/schemas.d.ts +23 -0
  16. package/dist/action-providers/enso/schemas.js +22 -0
  17. package/dist/action-providers/erc20/constants.d.ts +2 -0
  18. package/dist/action-providers/erc20/constants.js +2 -0
  19. package/dist/action-providers/erc20/erc20ActionProvider.d.ts +17 -1
  20. package/dist/action-providers/erc20/erc20ActionProvider.js +103 -1
  21. package/dist/action-providers/erc20/erc20ActionProvider.test.js +201 -0
  22. package/dist/action-providers/erc20/schemas.d.ts +29 -0
  23. package/dist/action-providers/erc20/schemas.js +34 -1
  24. package/dist/action-providers/index.d.ts +3 -1
  25. package/dist/action-providers/index.js +3 -1
  26. package/dist/action-providers/wallet/walletActionProvider.js +1 -1
  27. package/dist/action-providers/weth/constants.d.ts +0 -1
  28. package/dist/action-providers/weth/constants.js +1 -2
  29. package/dist/action-providers/weth/schemas.js +6 -2
  30. package/dist/action-providers/weth/wethActionProvider.d.ts +7 -0
  31. package/dist/action-providers/weth/wethActionProvider.js +57 -32
  32. package/dist/action-providers/weth/wethActionProvider.test.js +60 -11
  33. package/dist/action-providers/x402/utils.d.ts +4 -4
  34. package/dist/action-providers/x402/utils.js +42 -5
  35. package/dist/action-providers/x402/x402ActionProvider.d.ts +6 -6
  36. package/dist/action-providers/x402/x402ActionProvider.js +23 -8
  37. package/dist/action-providers/x402/x402ActionProvider.test.js +50 -6
  38. package/dist/action-providers/yelay/constants.d.ts +64 -0
  39. package/dist/action-providers/yelay/constants.js +137 -0
  40. package/dist/action-providers/yelay/index.d.ts +2 -0
  41. package/dist/action-providers/yelay/index.js +18 -0
  42. package/dist/action-providers/yelay/schemas.d.ts +47 -0
  43. package/dist/action-providers/yelay/schemas.js +59 -0
  44. package/dist/action-providers/yelay/types.d.ts +24 -0
  45. package/dist/action-providers/yelay/types.js +2 -0
  46. package/dist/action-providers/yelay/yelayActionProvider.d.ts +70 -0
  47. package/dist/action-providers/yelay/yelayActionProvider.js +329 -0
  48. package/dist/action-providers/yelay/yelayActionProvider.test.d.ts +1 -0
  49. package/dist/action-providers/yelay/yelayActionProvider.test.js +302 -0
  50. package/dist/wallet-providers/cdpSmartWalletProvider.js +1 -3
  51. package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +14 -0
  52. package/dist/wallet-providers/cdpSolanaWalletProvider.js +39 -3
  53. package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +16 -0
  54. package/dist/wallet-providers/privySvmWalletProvider.d.ts +14 -0
  55. package/dist/wallet-providers/privySvmWalletProvider.js +17 -0
  56. package/dist/wallet-providers/privySvmWalletProvider.test.js +10 -0
  57. package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +14 -0
  58. package/dist/wallet-providers/solanaKeypairWalletProvider.js +17 -0
  59. package/dist/wallet-providers/svmWalletProvider.d.ts +34 -0
  60. package/dist/wallet-providers/svmWalletProvider.js +43 -0
  61. package/dist/wallet-providers/svmWalletProvider.test.js +10 -0
  62. package/package.json +3 -1
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EnsoRouteSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Input schema for route action.
7
+ */
8
+ exports.EnsoRouteSchema = zod_1.z
9
+ .object({
10
+ tokenIn: zod_1.z
11
+ .string()
12
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
13
+ .describe("Address of the token to swap from. For ETH, use 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"),
14
+ tokenOut: zod_1.z
15
+ .string()
16
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
17
+ .describe("Address of the token to swap to, For ETH, use 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"),
18
+ amountIn: zod_1.z.string().describe("Amount of tokenIn to swap in whole units (e.g. 100 USDC)"),
19
+ slippage: zod_1.z.number().optional().describe("Slippage in basis points (1/10000). Default - 50"),
20
+ })
21
+ .strip()
22
+ .describe("Instructions for routing through Enso API");
@@ -30,8 +30,10 @@ export declare const TOKEN_ADDRESSES_BY_SYMBOLS: {
30
30
  };
31
31
  readonly "arbitrum-mainnet": {
32
32
  readonly USDC: "0xaf88d065e77c8cc2239327c5edb3a432268e5831";
33
+ readonly WETH: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1";
33
34
  };
34
35
  readonly "optimism-mainnet": {
35
36
  readonly USDC: "0x0b2c639c533813f4aa9d7837caf62653d097ff85";
37
+ readonly WETH: "0x4200000000000000000000000000000000000006";
36
38
  };
37
39
  };
@@ -43,8 +43,10 @@ exports.TOKEN_ADDRESSES_BY_SYMBOLS = {
43
43
  },
44
44
  "arbitrum-mainnet": {
45
45
  USDC: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
46
+ WETH: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
46
47
  },
47
48
  "optimism-mainnet": {
48
49
  USDC: "0x0b2c639c533813f4aa9d7837caf62653d097ff85",
50
+ WETH: "0x4200000000000000000000000000000000000006",
49
51
  },
50
52
  };
@@ -1,7 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { ActionProvider } from "../actionProvider";
3
3
  import { Network } from "../../network";
4
- import { GetBalanceSchema, TransferSchema, GetTokenAddressSchema } from "./schemas";
4
+ import { GetBalanceSchema, TransferSchema, GetTokenAddressSchema, ApproveSchema, AllowanceSchema } from "./schemas";
5
5
  import { EvmWalletProvider } from "../../wallet-providers";
6
6
  /**
7
7
  * ERC20ActionProvider is an action provider for ERC20 tokens.
@@ -27,6 +27,22 @@ export declare class ERC20ActionProvider extends ActionProvider<EvmWalletProvide
27
27
  * @returns A message containing the transfer details.
28
28
  */
29
29
  transfer(walletProvider: EvmWalletProvider, args: z.infer<typeof TransferSchema>): Promise<string>;
30
+ /**
31
+ * Approves a spender to transfer a specified amount of tokens.
32
+ *
33
+ * @param walletProvider - The wallet provider to approve from.
34
+ * @param args - The input arguments for the action.
35
+ * @returns A message containing the approval details.
36
+ */
37
+ approve(walletProvider: EvmWalletProvider, args: z.infer<typeof ApproveSchema>): Promise<string>;
38
+ /**
39
+ * Checks the allowance for a spender of an ERC20 token.
40
+ *
41
+ * @param walletProvider - The wallet provider to check the allowance from.
42
+ * @param args - The input arguments containing tokenAddress and spender.
43
+ * @returns A message containing the allowance amount for the spender.
44
+ */
45
+ getAllowance(walletProvider: EvmWalletProvider, args: z.infer<typeof AllowanceSchema>): Promise<string>;
30
46
  /**
31
47
  * Gets the contract address for a token symbol on the current network.
32
48
  *
@@ -117,6 +117,66 @@ class ERC20ActionProvider extends actionProvider_1.ActionProvider {
117
117
  return `Error transferring the asset: ${error}`;
118
118
  }
119
119
  }
120
+ /**
121
+ * Approves a spender to transfer a specified amount of tokens.
122
+ *
123
+ * @param walletProvider - The wallet provider to approve from.
124
+ * @param args - The input arguments for the action.
125
+ * @returns A message containing the approval details.
126
+ */
127
+ async approve(walletProvider, args) {
128
+ try {
129
+ // Get token details for better error messages and validation
130
+ const tokenAddress = (0, viem_1.getAddress)(args.tokenAddress);
131
+ const tokenDetails = await (0, utils_1.getTokenDetails)(walletProvider, args.tokenAddress);
132
+ if (!tokenDetails) {
133
+ return `Error: Could not fetch token details for ${args.tokenAddress}. Please verify the token address is correct.`;
134
+ }
135
+ // Convert amount to wei using token decimals
136
+ const amountInWei = (0, viem_1.parseUnits)(String(args.amount), tokenDetails.decimals);
137
+ const hash = await walletProvider.sendTransaction({
138
+ to: tokenAddress,
139
+ data: (0, viem_1.encodeFunctionData)({
140
+ abi: viem_1.erc20Abi,
141
+ functionName: "approve",
142
+ args: [args.spenderAddress, amountInWei],
143
+ }),
144
+ });
145
+ await walletProvider.waitForTransactionReceipt(hash);
146
+ return `Approved ${args.amount} ${tokenDetails.name} (${args.tokenAddress}) for spender ${args.spenderAddress}.\nTransaction hash: ${hash}`;
147
+ }
148
+ catch (error) {
149
+ return `Error approving tokens: ${error}`;
150
+ }
151
+ }
152
+ /**
153
+ * Checks the allowance for a spender of an ERC20 token.
154
+ *
155
+ * @param walletProvider - The wallet provider to check the allowance from.
156
+ * @param args - The input arguments containing tokenAddress and spender.
157
+ * @returns A message containing the allowance amount for the spender.
158
+ */
159
+ async getAllowance(walletProvider, args) {
160
+ try {
161
+ // Get token details for proper formatting
162
+ const tokenDetails = await (0, utils_1.getTokenDetails)(walletProvider, args.tokenAddress);
163
+ if (!tokenDetails) {
164
+ return `Error: Could not fetch token details for ${args.tokenAddress}. Please verify the token address is correct.`;
165
+ }
166
+ const allowance = await walletProvider.readContract({
167
+ address: args.tokenAddress,
168
+ abi: viem_1.erc20Abi,
169
+ functionName: "allowance",
170
+ args: [walletProvider.getAddress(), args.spenderAddress],
171
+ });
172
+ // Format the allowance using token decimals
173
+ const formattedAllowance = (0, viem_1.formatUnits)(allowance, tokenDetails.decimals);
174
+ return `Allowance for ${args.spenderAddress} to spend ${tokenDetails.name} (${args.tokenAddress}) is ${formattedAllowance} tokens`;
175
+ }
176
+ catch (error) {
177
+ return `Error checking allowance: ${error}`;
178
+ }
179
+ }
120
180
  /**
121
181
  * Gets the contract address for a token symbol on the current network.
122
182
  *
@@ -166,7 +226,7 @@ __decorate([
166
226
  It takes the following inputs:
167
227
  - amount: The amount to transfer in whole units (e.g. 10.5 USDC)
168
228
  - tokenAddress: The contract address of the token to transfer
169
- - destinationAddress: Where to send the funds (can be an onchain address, ENS 'example.eth', or Basename 'example.base.eth')
229
+ - destinationAddress: The address to send the funds to
170
230
  Important notes:
171
231
  - Never assume token or destination addresses, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool to get the token address first
172
232
  `,
@@ -176,6 +236,48 @@ Important notes:
176
236
  __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
177
237
  __metadata("design:returntype", Promise)
178
238
  ], ERC20ActionProvider.prototype, "transfer", null);
239
+ __decorate([
240
+ (0, actionDecorator_1.CreateAction)({
241
+ name: "approve",
242
+ description: `
243
+ This tool will approve a spender to transfer ERC20 tokens from the wallet.
244
+
245
+ It takes the following inputs:
246
+ - amount: The amount to approve in whole units (e.g. 100 for 100 USDC)
247
+ - tokenAddress: The contract address of the token to approve
248
+ - spenderAddress: The spender address to approve
249
+
250
+ Important notes:
251
+ - This will overwrite any existing allowance
252
+ - To revoke an allowance, set the amount to 0
253
+ - Ensure you trust the spender address before approving
254
+ - Never assume token addresses, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool to get the token address first
255
+ `,
256
+ schema: schemas_1.ApproveSchema,
257
+ }),
258
+ __metadata("design:type", Function),
259
+ __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
260
+ __metadata("design:returntype", Promise)
261
+ ], ERC20ActionProvider.prototype, "approve", null);
262
+ __decorate([
263
+ (0, actionDecorator_1.CreateAction)({
264
+ name: "get_allowance",
265
+ description: `
266
+ This tool will get the allowance amount for a spender of an ERC20 token.
267
+
268
+ It takes the following inputs:
269
+ - tokenAddress: The contract address of the token to check allowance for
270
+ - spenderAddress: The address to check allowance for
271
+
272
+ Important notes:
273
+ - Never assume token addresses, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool to get the token address first
274
+ `,
275
+ schema: schemas_1.AllowanceSchema,
276
+ }),
277
+ __metadata("design:type", Function),
278
+ __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
279
+ __metadata("design:returntype", Promise)
280
+ ], ERC20ActionProvider.prototype, "getAllowance", null);
179
281
  __decorate([
180
282
  (0, actionDecorator_1.CreateAction)({
181
283
  name: "get_erc20_token_address",
@@ -7,6 +7,7 @@ const MOCK_DECIMALS = 6;
7
7
  const MOCK_CONTRACT_ADDRESS = "0x1234567890123456789012345678901234567890";
8
8
  const MOCK_DESTINATION = "0x9876543210987654321098765432109876543210";
9
9
  const MOCK_ADDRESS = "0x1234567890123456789012345678901234567890";
10
+ const MOCK_SPENDER = "0xabcdef1234567890123456789012345678901234";
10
11
  describe("Transfer Schema", () => {
11
12
  it("should successfully parse valid input", () => {
12
13
  const validInput = {
@@ -142,6 +143,206 @@ describe("GetTokenAddress Schema", () => {
142
143
  expect(result.success).toBe(false);
143
144
  });
144
145
  });
146
+ describe("Approve Schema", () => {
147
+ it("should successfully parse valid input", () => {
148
+ const validInput = {
149
+ amount: MOCK_AMOUNT.toString(),
150
+ tokenAddress: MOCK_CONTRACT_ADDRESS,
151
+ spenderAddress: MOCK_SPENDER,
152
+ };
153
+ const result = schemas_1.ApproveSchema.safeParse(validInput);
154
+ expect(result.success).toBe(true);
155
+ expect(result.data).toEqual(validInput);
156
+ });
157
+ it("should fail parsing empty input", () => {
158
+ const emptyInput = {};
159
+ const result = schemas_1.ApproveSchema.safeParse(emptyInput);
160
+ expect(result.success).toBe(false);
161
+ });
162
+ it("should fail parsing invalid token address", () => {
163
+ const invalidInput = {
164
+ amount: MOCK_AMOUNT.toString(),
165
+ tokenAddress: "invalid-address",
166
+ spenderAddress: MOCK_SPENDER,
167
+ };
168
+ const result = schemas_1.ApproveSchema.safeParse(invalidInput);
169
+ expect(result.success).toBe(false);
170
+ });
171
+ it("should fail parsing invalid spender address", () => {
172
+ const invalidInput = {
173
+ amount: MOCK_AMOUNT.toString(),
174
+ tokenAddress: MOCK_CONTRACT_ADDRESS,
175
+ spenderAddress: "invalid-address",
176
+ };
177
+ const result = schemas_1.ApproveSchema.safeParse(invalidInput);
178
+ expect(result.success).toBe(false);
179
+ });
180
+ });
181
+ describe("Allowance Schema", () => {
182
+ it("should successfully parse valid input", () => {
183
+ const validInput = {
184
+ tokenAddress: MOCK_CONTRACT_ADDRESS,
185
+ spenderAddress: MOCK_SPENDER,
186
+ };
187
+ const result = schemas_1.AllowanceSchema.safeParse(validInput);
188
+ expect(result.success).toBe(true);
189
+ expect(result.data).toEqual(validInput);
190
+ });
191
+ it("should fail parsing empty input", () => {
192
+ const emptyInput = {};
193
+ const result = schemas_1.AllowanceSchema.safeParse(emptyInput);
194
+ expect(result.success).toBe(false);
195
+ });
196
+ it("should fail parsing invalid token address", () => {
197
+ const invalidInput = {
198
+ tokenAddress: "invalid-address",
199
+ spenderAddress: MOCK_SPENDER,
200
+ };
201
+ const result = schemas_1.AllowanceSchema.safeParse(invalidInput);
202
+ expect(result.success).toBe(false);
203
+ });
204
+ it("should fail parsing invalid spender address", () => {
205
+ const invalidInput = {
206
+ tokenAddress: MOCK_CONTRACT_ADDRESS,
207
+ spenderAddress: "invalid-address",
208
+ };
209
+ const result = schemas_1.AllowanceSchema.safeParse(invalidInput);
210
+ expect(result.success).toBe(false);
211
+ });
212
+ });
213
+ describe("Approve Action", () => {
214
+ const TRANSACTION_HASH = "0xapprove123456789";
215
+ let mockWallet;
216
+ let mockMulticall;
217
+ const actionProvider = (0, erc20ActionProvider_1.erc20ActionProvider)();
218
+ beforeEach(async () => {
219
+ mockMulticall = jest.fn();
220
+ const mockPublicClient = {
221
+ multicall: mockMulticall,
222
+ getCode: jest.fn().mockResolvedValue("0x"),
223
+ };
224
+ mockWallet = {
225
+ sendTransaction: jest.fn(),
226
+ waitForTransactionReceipt: jest.fn(),
227
+ getName: jest.fn().mockReturnValue("evm_wallet_provider"),
228
+ getNetwork: jest.fn().mockReturnValue({
229
+ networkId: "base-mainnet",
230
+ }),
231
+ getPublicClient: jest.fn().mockReturnValue(mockPublicClient),
232
+ getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
233
+ };
234
+ mockWallet.sendTransaction.mockResolvedValue(TRANSACTION_HASH);
235
+ mockWallet.waitForTransactionReceipt.mockResolvedValue({});
236
+ });
237
+ it("should successfully approve tokens", async () => {
238
+ mockMulticall.mockResolvedValueOnce([
239
+ { result: "MockToken" }, // name
240
+ { result: MOCK_DECIMALS }, // decimals
241
+ { result: BigInt(100000 * 10 ** MOCK_DECIMALS) }, // balance
242
+ ]);
243
+ const args = {
244
+ amount: MOCK_AMOUNT.toString(),
245
+ tokenAddress: MOCK_CONTRACT_ADDRESS,
246
+ spenderAddress: MOCK_SPENDER,
247
+ };
248
+ const response = await actionProvider.approve(mockWallet, args);
249
+ expect(mockMulticall).toHaveBeenCalled();
250
+ expect(mockWallet.sendTransaction).toHaveBeenCalled();
251
+ expect(mockWallet.waitForTransactionReceipt).toHaveBeenCalledWith(TRANSACTION_HASH);
252
+ expect(response).toContain(`Approved ${MOCK_AMOUNT} MockToken (${MOCK_CONTRACT_ADDRESS}) for spender ${MOCK_SPENDER}`);
253
+ expect(response).toContain(`Transaction hash: ${TRANSACTION_HASH}`);
254
+ });
255
+ it("should fail with an error when token details cannot be fetched", async () => {
256
+ mockMulticall.mockRejectedValue(new Error("Failed to get token details"));
257
+ const args = {
258
+ amount: MOCK_AMOUNT.toString(),
259
+ tokenAddress: MOCK_CONTRACT_ADDRESS,
260
+ spenderAddress: MOCK_SPENDER,
261
+ };
262
+ const response = await actionProvider.approve(mockWallet, args);
263
+ expect(mockMulticall).toHaveBeenCalled();
264
+ expect(response).toContain("Error: Could not fetch token details");
265
+ });
266
+ it("should fail with an error when transaction fails", async () => {
267
+ mockMulticall.mockResolvedValueOnce([
268
+ { result: "MockToken" }, // name
269
+ { result: MOCK_DECIMALS }, // decimals
270
+ { result: BigInt(100000 * 10 ** MOCK_DECIMALS) }, // balance
271
+ ]);
272
+ mockWallet.sendTransaction.mockRejectedValue(new Error("Transaction failed"));
273
+ const args = {
274
+ amount: MOCK_AMOUNT.toString(),
275
+ tokenAddress: MOCK_CONTRACT_ADDRESS,
276
+ spenderAddress: MOCK_SPENDER,
277
+ };
278
+ const response = await actionProvider.approve(mockWallet, args);
279
+ expect(response).toContain("Error approving tokens: Error: Transaction failed");
280
+ });
281
+ });
282
+ describe("Get Allowance Action", () => {
283
+ let mockWallet;
284
+ let mockMulticall;
285
+ let mockReadContract;
286
+ const actionProvider = (0, erc20ActionProvider_1.erc20ActionProvider)();
287
+ beforeEach(async () => {
288
+ mockMulticall = jest.fn();
289
+ mockReadContract = jest.fn();
290
+ const mockPublicClient = {
291
+ multicall: mockMulticall,
292
+ getCode: jest.fn().mockResolvedValue("0x"),
293
+ };
294
+ mockWallet = {
295
+ readContract: mockReadContract,
296
+ getName: jest.fn().mockReturnValue("evm_wallet_provider"),
297
+ getNetwork: jest.fn().mockReturnValue({
298
+ networkId: "base-mainnet",
299
+ }),
300
+ getPublicClient: jest.fn().mockReturnValue(mockPublicClient),
301
+ getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
302
+ };
303
+ });
304
+ it("should successfully get allowance", async () => {
305
+ const allowanceAmount = BigInt(MOCK_AMOUNT * 10 ** MOCK_DECIMALS);
306
+ mockMulticall.mockResolvedValueOnce([
307
+ { result: "MockToken" }, // name
308
+ { result: MOCK_DECIMALS }, // decimals
309
+ { result: BigInt(100000 * 10 ** MOCK_DECIMALS) }, // balance
310
+ ]);
311
+ mockReadContract.mockResolvedValue(allowanceAmount);
312
+ const args = {
313
+ tokenAddress: MOCK_CONTRACT_ADDRESS,
314
+ spenderAddress: MOCK_SPENDER,
315
+ };
316
+ const response = await actionProvider.getAllowance(mockWallet, args);
317
+ expect(mockMulticall).toHaveBeenCalled();
318
+ expect(mockReadContract).toHaveBeenCalled();
319
+ expect(response).toContain(`Allowance for ${MOCK_SPENDER} to spend MockToken (${MOCK_CONTRACT_ADDRESS}) is ${MOCK_AMOUNT}`);
320
+ });
321
+ it("should fail with an error when token details cannot be fetched", async () => {
322
+ mockMulticall.mockRejectedValue(new Error("Failed to get token details"));
323
+ const args = {
324
+ tokenAddress: MOCK_CONTRACT_ADDRESS,
325
+ spenderAddress: MOCK_SPENDER,
326
+ };
327
+ const response = await actionProvider.getAllowance(mockWallet, args);
328
+ expect(mockMulticall).toHaveBeenCalled();
329
+ expect(response).toContain("Error: Could not fetch token details");
330
+ });
331
+ it("should fail with an error when allowance read fails", async () => {
332
+ mockMulticall.mockResolvedValueOnce([
333
+ { result: "MockToken" }, // name
334
+ { result: MOCK_DECIMALS }, // decimals
335
+ { result: BigInt(100000 * 10 ** MOCK_DECIMALS) }, // balance
336
+ ]);
337
+ mockReadContract.mockRejectedValue(new Error("Allowance read failed"));
338
+ const args = {
339
+ tokenAddress: MOCK_CONTRACT_ADDRESS,
340
+ spenderAddress: MOCK_SPENDER,
341
+ };
342
+ const response = await actionProvider.getAllowance(mockWallet, args);
343
+ expect(response).toContain("Error checking allowance: Error: Allowance read failed");
344
+ });
345
+ });
145
346
  describe("Get Token Address Action", () => {
146
347
  let mockWallet;
147
348
  const actionProvider = (0, erc20ActionProvider_1.erc20ActionProvider)();
@@ -28,6 +28,35 @@ export declare const GetBalanceSchema: z.ZodObject<{
28
28
  tokenAddress: string;
29
29
  address?: string | undefined;
30
30
  }>;
31
+ /**
32
+ * Input schema for approve action.
33
+ */
34
+ export declare const ApproveSchema: z.ZodObject<{
35
+ amount: z.ZodString;
36
+ tokenAddress: z.ZodString;
37
+ spenderAddress: z.ZodString;
38
+ }, "strip", z.ZodTypeAny, {
39
+ amount: string;
40
+ tokenAddress: string;
41
+ spenderAddress: string;
42
+ }, {
43
+ amount: string;
44
+ tokenAddress: string;
45
+ spenderAddress: string;
46
+ }>;
47
+ /**
48
+ * Input schema for allowance action.
49
+ */
50
+ export declare const AllowanceSchema: z.ZodObject<{
51
+ tokenAddress: z.ZodString;
52
+ spenderAddress: z.ZodString;
53
+ }, "strip", z.ZodTypeAny, {
54
+ tokenAddress: string;
55
+ spenderAddress: string;
56
+ }, {
57
+ tokenAddress: string;
58
+ spenderAddress: string;
59
+ }>;
31
60
  /**
32
61
  * Input schema for get token address action.
33
62
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetTokenAddressSchema = exports.GetBalanceSchema = exports.TransferSchema = void 0;
3
+ exports.GetTokenAddressSchema = exports.AllowanceSchema = exports.ApproveSchema = exports.GetBalanceSchema = exports.TransferSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  /**
6
6
  * Input schema for transfer action.
@@ -38,6 +38,39 @@ exports.GetBalanceSchema = zod_1.z
38
38
  })
39
39
  .strip()
40
40
  .describe("Instructions for getting wallet balance");
41
+ /**
42
+ * Input schema for approve action.
43
+ */
44
+ exports.ApproveSchema = zod_1.z
45
+ .object({
46
+ amount: zod_1.z.string().describe("The amount to approve in whole units (e.g. 100 for 100 USDC)"),
47
+ tokenAddress: zod_1.z
48
+ .string()
49
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
50
+ .describe("The contract address of the token"),
51
+ spenderAddress: zod_1.z
52
+ .string()
53
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
54
+ .describe("The address to approve for spending tokens"),
55
+ })
56
+ .strip()
57
+ .describe("Instructions for approving token spending");
58
+ /**
59
+ * Input schema for allowance action.
60
+ */
61
+ exports.AllowanceSchema = zod_1.z
62
+ .object({
63
+ tokenAddress: zod_1.z
64
+ .string()
65
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
66
+ .describe("The contract address of the token"),
67
+ spenderAddress: zod_1.z
68
+ .string()
69
+ .regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
70
+ .describe("The address to check allowance for"),
71
+ })
72
+ .strip()
73
+ .describe("Instructions for checking token allowance");
41
74
  /**
42
75
  * Input schema for get token address action.
43
76
  */
@@ -7,8 +7,10 @@ export * from "./baseAccount";
7
7
  export * from "./basename";
8
8
  export * from "./cdp-legacy";
9
9
  export * from "./cdp";
10
+ export * from "./clanker";
10
11
  export * from "./compound";
11
12
  export * from "./defillama";
13
+ export * from "./enso";
12
14
  export * from "./erc20";
13
15
  export * from "./erc721";
14
16
  export * from "./farcaster";
@@ -30,8 +32,8 @@ export * from "./flaunch";
30
32
  export * from "./onramp";
31
33
  export * from "./vaultsfyi";
32
34
  export * from "./x402";
35
+ export * from "./yelay";
33
36
  export * from "./zerion";
34
37
  export * from "./zerodev";
35
38
  export * from "./zeroX";
36
39
  export * from "./zora";
37
- export * from "./clanker";
@@ -23,8 +23,10 @@ __exportStar(require("./baseAccount"), exports);
23
23
  __exportStar(require("./basename"), exports);
24
24
  __exportStar(require("./cdp-legacy"), exports);
25
25
  __exportStar(require("./cdp"), exports);
26
+ __exportStar(require("./clanker"), exports);
26
27
  __exportStar(require("./compound"), exports);
27
28
  __exportStar(require("./defillama"), exports);
29
+ __exportStar(require("./enso"), exports);
28
30
  __exportStar(require("./erc20"), exports);
29
31
  __exportStar(require("./erc721"), exports);
30
32
  __exportStar(require("./farcaster"), exports);
@@ -46,8 +48,8 @@ __exportStar(require("./flaunch"), exports);
46
48
  __exportStar(require("./onramp"), exports);
47
49
  __exportStar(require("./vaultsfyi"), exports);
48
50
  __exportStar(require("./x402"), exports);
51
+ __exportStar(require("./yelay"), exports);
49
52
  __exportStar(require("./zerion"), exports);
50
53
  __exportStar(require("./zerodev"), exports);
51
54
  __exportStar(require("./zeroX"), exports);
52
55
  __exportStar(require("./zora"), exports);
53
- __exportStar(require("./clanker"), exports);
@@ -133,7 +133,7 @@ __decorate([
133
133
  (0, actionDecorator_1.CreateAction)({
134
134
  name: "native_transfer",
135
135
  description: `
136
- This tool will transfer (send) native tokens from the wallet to another onchain address.
136
+ This tool will transfer (send) native tokens (ETH for EVM networks, SOL for SVM networks) from the wallet to another onchain address.
137
137
 
138
138
  It takes the following inputs:
139
139
  - amount: The amount to transfer in whole units (e.g. 4.2 ETH, 0.1 SOL)
@@ -1,4 +1,3 @@
1
- export declare const WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
2
1
  export declare const WETH_ABI: readonly [{
3
2
  readonly inputs: readonly [];
4
3
  readonly name: "deposit";
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WETH_ABI = exports.WETH_ADDRESS = void 0;
4
- exports.WETH_ADDRESS = "0x4200000000000000000000000000000000000006";
3
+ exports.WETH_ABI = void 0;
5
4
  exports.WETH_ABI = [
6
5
  {
7
6
  inputs: [],
@@ -4,13 +4,17 @@ exports.UnwrapEthSchema = exports.WrapEthSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.WrapEthSchema = zod_1.z
6
6
  .object({
7
- amountToWrap: zod_1.z.string().describe("Amount of ETH to wrap in wei"),
7
+ amountToWrap: zod_1.z
8
+ .string()
9
+ .describe("Amount of ETH to wrap in human-readable format (e.g., 0.1 for 0.1 ETH)"),
8
10
  })
9
11
  .strip()
10
12
  .describe("Instructions for wrapping ETH to WETH");
11
13
  exports.UnwrapEthSchema = zod_1.z
12
14
  .object({
13
- amountToUnwrap: zod_1.z.string().describe("Amount of WETH to unwrap in wei"),
15
+ amountToUnwrap: zod_1.z
16
+ .string()
17
+ .describe("Amount of WETH to unwrap in human-readable format (e.g., 0.1 for 0.1 WETH)"),
14
18
  })
15
19
  .strip()
16
20
  .describe("Instructions for unwrapping WETH to ETH");
@@ -3,6 +3,13 @@ import { ActionProvider } from "../actionProvider";
3
3
  import { Network } from "../../network";
4
4
  import { WrapEthSchema, UnwrapEthSchema } from "./schemas";
5
5
  import { EvmWalletProvider } from "../../wallet-providers";
6
+ /**
7
+ * Gets the WETH address for the given network.
8
+ *
9
+ * @param network - The network to get the WETH address for.
10
+ * @returns The WETH address for the network, or undefined if not supported.
11
+ */
12
+ export declare const getWethAddress: (network: Network) => string | undefined;
6
13
  /**
7
14
  * WethActionProvider is an action provider for WETH.
8
15
  */