@coinbase/agentkit 0.0.0-nightly-20250904210426 → 0.0.0-nightly-20250906210355

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 (73) hide show
  1. package/README.md +29 -0
  2. package/dist/action-providers/across/acrossActionProvider.js +3 -3
  3. package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +0 -1
  4. package/dist/action-providers/cdp/cdpApiActionProvider.js +0 -16
  5. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +1 -2
  6. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +7 -26
  7. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +8 -0
  8. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +0 -1
  9. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +7 -22
  10. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +11 -1
  11. package/dist/action-providers/clanker/clankerActionProvider.d.ts +43 -0
  12. package/dist/action-providers/clanker/clankerActionProvider.js +130 -0
  13. package/dist/action-providers/clanker/clankerActionProvider.test.d.ts +4 -0
  14. package/dist/action-providers/clanker/clankerActionProvider.test.js +119 -0
  15. package/dist/action-providers/clanker/index.d.ts +2 -0
  16. package/dist/action-providers/clanker/index.js +18 -0
  17. package/dist/action-providers/clanker/schemas.d.ts +56 -0
  18. package/dist/action-providers/clanker/schemas.js +47 -0
  19. package/dist/action-providers/clanker/utils.d.ts +9 -0
  20. package/dist/action-providers/clanker/utils.js +23 -0
  21. package/dist/action-providers/compound/constants.d.ts +1 -1
  22. package/dist/action-providers/compound/constants.js +2 -2
  23. package/dist/action-providers/erc20/constants.d.ts +35 -135
  24. package/dist/action-providers/erc20/constants.js +37 -189
  25. package/dist/action-providers/erc20/erc20ActionProvider.d.ts +9 -1
  26. package/dist/action-providers/erc20/erc20ActionProvider.js +87 -35
  27. package/dist/action-providers/erc20/erc20ActionProvider.test.js +115 -52
  28. package/dist/action-providers/erc20/schemas.d.ts +25 -12
  29. package/dist/action-providers/erc20/schemas.js +34 -6
  30. package/dist/action-providers/erc20/utils.d.ts +19 -0
  31. package/dist/action-providers/erc20/utils.js +54 -0
  32. package/dist/action-providers/flaunch/constants.d.ts +1 -1
  33. package/dist/action-providers/flaunch/constants.js +2 -2
  34. package/dist/action-providers/index.d.ts +1 -0
  35. package/dist/action-providers/index.js +1 -0
  36. package/dist/action-providers/moonwell/schemas.d.ts +2 -2
  37. package/dist/action-providers/morpho/morphoActionProvider.js +5 -5
  38. package/dist/action-providers/morpho/schemas.d.ts +2 -2
  39. package/dist/action-providers/pyth/pythActionProvider.js +5 -0
  40. package/dist/action-providers/pyth/pythActionProvider.test.js +5 -1
  41. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.js +4 -4
  42. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.js +3 -3
  43. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.js +2 -2
  44. package/dist/action-providers/truemarkets/truemarketsActionProvider.js +10 -10
  45. package/dist/action-providers/wallet/walletActionProvider.js +21 -10
  46. package/dist/action-providers/wallet/walletActionProvider.test.js +6 -2
  47. package/dist/action-providers/zeroX/zeroXActionProvider.js +2 -0
  48. package/dist/wallet-providers/cdpEvmWalletProvider.d.ts +13 -1
  49. package/dist/wallet-providers/cdpEvmWalletProvider.js +30 -24
  50. package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +13 -1
  51. package/dist/wallet-providers/cdpSmartWalletProvider.js +31 -25
  52. package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +1 -1
  53. package/dist/wallet-providers/cdpSolanaWalletProvider.js +7 -7
  54. package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +15 -12
  55. package/dist/wallet-providers/legacyCdpSmartWalletProvider.d.ts +1 -1
  56. package/dist/wallet-providers/legacyCdpSmartWalletProvider.js +1 -1
  57. package/dist/wallet-providers/legacyCdpWalletProvider.d.ts +1 -1
  58. package/dist/wallet-providers/legacyCdpWalletProvider.js +1 -1
  59. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +1 -1
  60. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +2 -2
  61. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.test.js +1 -1
  62. package/dist/wallet-providers/privyEvmWalletProvider.test.js +1 -1
  63. package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +1 -1
  64. package/dist/wallet-providers/solanaKeypairWalletProvider.js +3 -4
  65. package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +4 -2
  66. package/dist/wallet-providers/viemWalletProvider.d.ts +1 -1
  67. package/dist/wallet-providers/viemWalletProvider.js +2 -2
  68. package/dist/wallet-providers/viemWalletProvider.test.js +6 -5
  69. package/dist/wallet-providers/walletProvider.d.ts +1 -1
  70. package/dist/wallet-providers/zeroDevWalletProvider.d.ts +1 -1
  71. package/dist/wallet-providers/zeroDevWalletProvider.js +4 -4
  72. package/dist/wallet-providers/zeroDevWalletProvider.test.js +2 -2
  73. package/package.json +3 -2
package/README.md CHANGED
@@ -182,6 +182,14 @@ const agent = createReactAgent({
182
182
  <td width="200"><code>use_spend_permission</code></td>
183
183
  <td width="768">Uses a spend permission to spend tokens on behalf of a smart account that the current EVM wallet has permission to spend.</td>
184
184
  </tr>
185
+ <tr>
186
+ <td width="200"><code>get_swap_price</code></td>
187
+ <td width="768">Fetches a price quote for swapping between two tokens using the CDP Swap API (does not execute swap).</td>
188
+ </tr>
189
+ <tr>
190
+ <td width="200"><code>swap</code></td>
191
+ <td width="768">Executes a token swap using the CDP Swap API with automatic token approvals.</td>
192
+ </tr>
185
193
  </table>
186
194
  </details>
187
195
  <details>
@@ -195,6 +203,14 @@ const agent = createReactAgent({
195
203
  <td width="200"><code>use_spend_permission</code></td>
196
204
  <td width="768">Uses a spend permission to spend tokens on behalf of a smart account that the current smart wallet has permission to spend.</td>
197
205
  </tr>
206
+ <tr>
207
+ <td width="200"><code>get_swap_price</code></td>
208
+ <td width="768">Fetches a price quote for swapping between two tokens using the CDP Swap API (does not execute swap).</td>
209
+ </tr>
210
+ <tr>
211
+ <td width="200"><code>swap</code></td>
212
+ <td width="768">Executes a token swap using the CDP Swap API with automatic token approvals.</td>
213
+ </tr>
198
214
  </table>
199
215
  </details>
200
216
  <details>
@@ -220,6 +236,15 @@ const agent = createReactAgent({
220
236
  </table>
221
237
  </details>
222
238
  <details>
239
+ <summary><strong>Clanker</strong></summary>
240
+ <table width="100%">
241
+ <tr>
242
+ <td width="200"><code>clank_token</code></td>
243
+ <td width="768">Deploys an ERC20 Clanker token based on the supplied config.</td>
244
+ </tr>
245
+ </table>
246
+ </details>
247
+ <details>
223
248
  <summary><strong>Compound</strong></summary>
224
249
  <table width="100%">
225
250
  <tr>
@@ -272,6 +297,10 @@ const agent = createReactAgent({
272
297
  <td width="200"><code>transfer</code></td>
273
298
  <td width="768">Transfers a specified amount of ERC-20 tokens to a destination address.</td>
274
299
  </tr>
300
+ <tr>
301
+ <td width="200"><code>get_erc20_token_address</code></td>
302
+ <td width="768">Gets the contract address for frequently used ERC20 tokens on different networks by token symbol.</td>
303
+ </tr>
275
304
  </table>
276
305
  </details>
277
306
  <details>
@@ -31,7 +31,7 @@ const schemas_1 = require("./schemas");
31
31
  const wallet_providers_1 = require("../../wallet-providers");
32
32
  const utils_1 = require("./utils");
33
33
  const accounts_1 = require("viem/accounts");
34
- const constants_1 = require("../erc20/constants");
34
+ const viem_2 = require("viem");
35
35
  /**
36
36
  * AcrossActionProvider provides actions for cross-chain bridging via Across Protocol.
37
37
  */
@@ -141,7 +141,7 @@ class AcrossActionProvider extends actionProvider_1.ActionProvider {
141
141
  // Check ERC20 token balance
142
142
  const tokenBalance = (await walletProvider.readContract({
143
143
  address: inputToken,
144
- abi: constants_1.abi,
144
+ abi: viem_2.erc20Abi,
145
145
  functionName: "balanceOf",
146
146
  args: [address],
147
147
  }));
@@ -194,7 +194,7 @@ class AcrossActionProvider extends actionProvider_1.ActionProvider {
194
194
  approvalTxHash = await walletProvider.sendTransaction({
195
195
  to: inputToken,
196
196
  data: (0, viem_1.encodeFunctionData)({
197
- abi: constants_1.abi,
197
+ abi: viem_2.erc20Abi,
198
198
  functionName: "approve",
199
199
  args: [quote.deposit.spokePoolAddress, quote.deposit.inputAmount],
200
200
  }),
@@ -9,7 +9,6 @@ import { RequestFaucetFundsV2Schema } from "./schemas";
9
9
  * This provider is used for any action that uses the CDP API, but does not require a CDP Wallet.
10
10
  */
11
11
  export declare class CdpApiActionProvider extends ActionProvider<WalletProvider> {
12
- #private;
13
12
  /**
14
13
  * Constructor for the CdpApiActionProvider class.
15
14
  */
@@ -8,7 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var _CdpApiActionProvider_instances, _CdpApiActionProvider_getCdpSdkNetwork;
12
11
  Object.defineProperty(exports, "__esModule", { value: true });
13
12
  exports.cdpApiActionProvider = exports.CdpApiActionProvider = void 0;
14
13
  const zod_1 = require("zod");
@@ -28,7 +27,6 @@ class CdpApiActionProvider extends actionProvider_1.ActionProvider {
28
27
  */
29
28
  constructor() {
30
29
  super("cdp_api", []);
31
- _CdpApiActionProvider_instances.add(this);
32
30
  /**
33
31
  * Checks if the CDP action provider supports the given network.
34
32
  *
@@ -81,20 +79,6 @@ class CdpApiActionProvider extends actionProvider_1.ActionProvider {
81
79
  }
82
80
  }
83
81
  exports.CdpApiActionProvider = CdpApiActionProvider;
84
- _CdpApiActionProvider_instances = new WeakSet(), _CdpApiActionProvider_getCdpSdkNetwork = function _CdpApiActionProvider_getCdpSdkNetwork(networkId) {
85
- switch (networkId) {
86
- case "base-sepolia":
87
- return "base-sepolia";
88
- case "base-mainnet":
89
- return "base";
90
- case "ethereum-sepolia":
91
- return "ethereum-sepolia";
92
- case "ethereum-mainnet":
93
- return "ethereum";
94
- default:
95
- return networkId; // For other networks, use as-is
96
- }
97
- };
98
82
  __decorate([
99
83
  (0, actionDecorator_1.CreateAction)({
100
84
  name: "request_faucet_funds",
@@ -11,7 +11,6 @@ import type { Network } from "../../network";
11
11
  * that are optimized for EVM functionality, including spend permission usage.
12
12
  */
13
13
  export declare class CdpEvmWalletActionProvider extends ActionProvider<CdpEvmWalletProvider> {
14
- #private;
15
14
  /**
16
15
  * Constructor for the CdpEvmWalletActionProvider class.
17
16
  */
@@ -31,7 +30,7 @@ export declare class CdpEvmWalletActionProvider extends ActionProvider<CdpEvmWal
31
30
  * @param args - The input arguments for using the spend permission.
32
31
  * @returns A confirmation message with transaction details.
33
32
  */
34
- useSpendPermission(walletProvider: WalletProvider, args: z.infer<typeof UseSpendPermissionSchema>): Promise<string>;
33
+ useSpendPermission(walletProvider: CdpEvmWalletProvider, args: z.infer<typeof UseSpendPermissionSchema>): Promise<string>;
35
34
  /**
36
35
  * Gets a price quote for swapping tokens using the CDP Swap API.
37
36
  *
@@ -8,12 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
- };
16
- var _CdpEvmWalletActionProvider_instances, _CdpEvmWalletActionProvider_getCdpSdkNetwork;
17
11
  Object.defineProperty(exports, "__esModule", { value: true });
18
12
  exports.cdpEvmWalletActionProvider = exports.CdpEvmWalletActionProvider = void 0;
19
13
  const zod_1 = require("zod");
@@ -38,7 +32,6 @@ class CdpEvmWalletActionProvider extends actionProvider_1.ActionProvider {
38
32
  */
39
33
  constructor() {
40
34
  super("cdp_evm_wallet", []);
41
- _CdpEvmWalletActionProvider_instances.add(this);
42
35
  /**
43
36
  * Checks if the EVM wallet action provider supports the given network.
44
37
  *
@@ -80,7 +73,7 @@ class CdpEvmWalletActionProvider extends actionProvider_1.ActionProvider {
80
73
  */
81
74
  async useSpendPermission(walletProvider, args) {
82
75
  const network = walletProvider.getNetwork();
83
- const cdpNetwork = __classPrivateFieldGet(this, _CdpEvmWalletActionProvider_instances, "m", _CdpEvmWalletActionProvider_getCdpSdkNetwork).call(this, network.networkId);
76
+ const cdpNetwork = walletProvider.getCdpSdkNetwork();
84
77
  if ((0, cdpShared_1.isWalletProviderWithClient)(walletProvider)) {
85
78
  if (network.protocolFamily === "evm") {
86
79
  try {
@@ -119,7 +112,7 @@ class CdpEvmWalletActionProvider extends actionProvider_1.ActionProvider {
119
112
  // Get CDP SDK network
120
113
  const network = walletProvider.getNetwork();
121
114
  const networkId = network.networkId;
122
- const cdpNetwork = __classPrivateFieldGet(this, _CdpEvmWalletActionProvider_instances, "m", _CdpEvmWalletActionProvider_getCdpSdkNetwork).call(this, networkId);
115
+ const cdpNetwork = walletProvider.getCdpSdkNetwork();
123
116
  // Check if the network is supported
124
117
  if (networkId !== "base-mainnet" && networkId !== "ethereum-mainnet")
125
118
  return JSON.stringify({
@@ -174,7 +167,7 @@ class CdpEvmWalletActionProvider extends actionProvider_1.ActionProvider {
174
167
  // Get CDP SDK network
175
168
  const network = walletProvider.getNetwork();
176
169
  const networkId = network.networkId;
177
- const cdpNetwork = __classPrivateFieldGet(this, _CdpEvmWalletActionProvider_instances, "m", _CdpEvmWalletActionProvider_getCdpSdkNetwork).call(this, networkId);
170
+ const cdpNetwork = walletProvider.getCdpSdkNetwork();
178
171
  // Check if the network is supported
179
172
  if (networkId !== "base-mainnet" && networkId !== "ethereum-mainnet")
180
173
  return JSON.stringify({
@@ -285,20 +278,6 @@ class CdpEvmWalletActionProvider extends actionProvider_1.ActionProvider {
285
278
  }
286
279
  }
287
280
  exports.CdpEvmWalletActionProvider = CdpEvmWalletActionProvider;
288
- _CdpEvmWalletActionProvider_instances = new WeakSet(), _CdpEvmWalletActionProvider_getCdpSdkNetwork = function _CdpEvmWalletActionProvider_getCdpSdkNetwork(networkId) {
289
- switch (networkId) {
290
- case "base-sepolia":
291
- return "base-sepolia";
292
- case "base-mainnet":
293
- return "base";
294
- case "ethereum-sepolia":
295
- return "ethereum-sepolia";
296
- case "ethereum-mainnet":
297
- return "ethereum";
298
- default:
299
- return networkId; // For other networks, use as-is
300
- }
301
- };
302
281
  __decorate([
303
282
  (0, actionDecorator_1.CreateAction)({
304
283
  name: "list_spend_permissions",
@@ -322,7 +301,7 @@ This action is specifically designed for EVM wallets and uses the EVM wallet for
322
301
  schema: schemas_1.UseSpendPermissionSchema,
323
302
  }),
324
303
  __metadata("design:type", Function),
325
- __metadata("design:paramtypes", [wallet_providers_1.WalletProvider, void 0]),
304
+ __metadata("design:paramtypes", [cdpEvmWalletProvider_1.CdpEvmWalletProvider, void 0]),
326
305
  __metadata("design:returntype", Promise)
327
306
  ], CdpEvmWalletActionProvider.prototype, "useSpendPermission", null);
328
307
  __decorate([
@@ -337,7 +316,8 @@ It takes the following inputs:
337
316
  - slippageBps: (Optional) Maximum allowed slippage in basis points (100 = 1%)
338
317
  Important notes:
339
318
  - The contract address for native ETH is "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
340
- - Use fromAmount units exactly as provided, do not convert to wei or any other units.
319
+ - Use fromAmount units exactly as provided, do not convert to wei or any other units
320
+ - Never assume token or address, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool if available to get the token address first
341
321
  `,
342
322
  schema: schemas_1.SwapSchema,
343
323
  }),
@@ -359,6 +339,7 @@ Important notes:
359
339
  - The contract address for native ETH is "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
360
340
  - If needed, it will automatically approve the permit2 contract to spend the fromToken
361
341
  - Use fromAmount units exactly as provided, do not convert to wei or any other units.
342
+ - Never assume token or address, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool if available to get the token address first
362
343
  `,
363
344
  schema: schemas_1.SwapSchema,
364
345
  }),
@@ -68,6 +68,7 @@ describe("CDP EVM Wallet Action Provider", () => {
68
68
  getClient: jest.fn(),
69
69
  sendTransaction: jest.fn(),
70
70
  waitForTransactionReceipt: jest.fn(),
71
+ getCdpSdkNetwork: jest.fn(),
71
72
  };
72
73
  // Default setup for utility functions
73
74
  mockRetryWithExponentialBackoff.mockImplementation(async (fn) => {
@@ -86,6 +87,7 @@ describe("CDP EVM Wallet Action Provider", () => {
86
87
  });
87
88
  mockWalletProvider.getAddress.mockReturnValue("0x1234567890123456789012345678901234567890");
88
89
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
90
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("base-sepolia");
89
91
  });
90
92
  it("should successfully list spend permissions for EVM wallets", async () => {
91
93
  const expectedResult = "Found 2 spend permission(s):\n1. Token: USDC, Allowance: 500, Period: 1800 seconds, Start: 111111, End: 222222\n2. Token: ETH, Allowance: 1000, Period: 3600 seconds, Start: 123456, End: 234567";
@@ -127,6 +129,7 @@ describe("CDP EVM Wallet Action Provider", () => {
127
129
  });
128
130
  mockWalletProvider.getAddress.mockReturnValue("0x1234567890123456789012345678901234567890");
129
131
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
132
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("base-sepolia");
130
133
  mockCdpClient.evm.getAccount.mockResolvedValue(mockAccount);
131
134
  });
132
135
  it("should successfully use spend permission for EVM wallets", async () => {
@@ -174,6 +177,7 @@ describe("CDP EVM Wallet Action Provider", () => {
174
177
  networkId: testCase.networkId,
175
178
  });
176
179
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
180
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue(testCase.expected);
177
181
  mockCdpClient.evm.getAccount.mockResolvedValue(mockAccount);
178
182
  await actionProvider.useSpendPermission(mockWalletProvider, mockArgs);
179
183
  expect(mockAccount.useSpendPermission).toHaveBeenCalledWith({
@@ -188,6 +192,7 @@ describe("CDP EVM Wallet Action Provider", () => {
188
192
  protocolFamily: "evm",
189
193
  networkId: "polygon-mainnet",
190
194
  });
195
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("polygon-mainnet");
191
196
  const mockPermission = { spender: "0x1234", token: "MATIC" };
192
197
  const mockSpendResult = { status: "completed" };
193
198
  spendPermissionUtils.findLatestSpendPermission.mockResolvedValue(mockPermission);
@@ -251,6 +256,7 @@ describe("CDP EVM Wallet Action Provider", () => {
251
256
  beforeEach(() => {
252
257
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
253
258
  mockWalletProvider.getAddress.mockReturnValue("0x1234567890123456789012345678901234567890");
259
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("base");
254
260
  mockGetTokenDetails.mockResolvedValue({
255
261
  fromTokenDecimals: 18,
256
262
  toTokenDecimals: 6,
@@ -288,6 +294,7 @@ describe("CDP EVM Wallet Action Provider", () => {
288
294
  protocolFamily: "evm",
289
295
  networkId: "ethereum-mainnet",
290
296
  });
297
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("ethereum");
291
298
  mockCdpClient.evm.getSwapPrice.mockResolvedValue({
292
299
  toAmount: "990000",
293
300
  minToAmount: "980000",
@@ -337,6 +344,7 @@ describe("CDP EVM Wallet Action Provider", () => {
337
344
  beforeEach(() => {
338
345
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
339
346
  mockWalletProvider.getAddress.mockReturnValue("0x1234567890123456789012345678901234567890");
347
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("base");
340
348
  mockCdpClient.evm.getAccount.mockResolvedValue(mockAccount);
341
349
  mockWalletProvider.waitForTransactionReceipt.mockResolvedValue({ status: "success" });
342
350
  mockGetTokenDetails.mockResolvedValue({
@@ -10,7 +10,6 @@ import type { Network } from "../../network";
10
10
  * that are optimized for smart wallet functionality.
11
11
  */
12
12
  export declare class CdpSmartWalletActionProvider extends ActionProvider<CdpSmartWalletProvider> {
13
- #private;
14
13
  /**
15
14
  * Constructor for the CdpSmartWalletActionProvider class.
16
15
  */
@@ -8,12 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
- };
16
- var _CdpSmartWalletActionProvider_instances, _CdpSmartWalletActionProvider_getCdpSdkNetwork;
17
11
  Object.defineProperty(exports, "__esModule", { value: true });
18
12
  exports.cdpSmartWalletActionProvider = exports.CdpSmartWalletActionProvider = void 0;
19
13
  const zod_1 = require("zod");
@@ -36,7 +30,6 @@ class CdpSmartWalletActionProvider extends actionProvider_1.ActionProvider {
36
30
  */
37
31
  constructor() {
38
32
  super("cdp_smart_wallet", []);
39
- _CdpSmartWalletActionProvider_instances.add(this);
40
33
  /**
41
34
  * Checks if the smart wallet action provider supports the given network.
42
35
  *
@@ -73,7 +66,7 @@ class CdpSmartWalletActionProvider extends actionProvider_1.ActionProvider {
73
66
  */
74
67
  async useSpendPermission(walletProvider, args) {
75
68
  const network = walletProvider.getNetwork();
76
- const cdpNetwork = __classPrivateFieldGet(this, _CdpSmartWalletActionProvider_instances, "m", _CdpSmartWalletActionProvider_getCdpSdkNetwork).call(this, network.networkId);
69
+ const cdpNetwork = walletProvider.getCdpSdkNetwork();
77
70
  if (network.protocolFamily === "evm") {
78
71
  try {
79
72
  const permission = await (0, spendPermissionUtils_1.findLatestSpendPermission)(walletProvider.getClient(), args.smartAccountAddress, walletProvider.getAddress());
@@ -109,8 +102,8 @@ class CdpSmartWalletActionProvider extends actionProvider_1.ActionProvider {
109
102
  error: "CDP Swap API for smart wallets is currently only supported on Base networks.",
110
103
  });
111
104
  }
112
- const cdpNetwork = __classPrivateFieldGet(this, _CdpSmartWalletActionProvider_instances, "m", _CdpSmartWalletActionProvider_getCdpSdkNetwork).call(this, networkId);
113
105
  try {
106
+ const cdpNetwork = walletProvider.getCdpSdkNetwork();
114
107
  // Get token details
115
108
  const { fromTokenDecimals, toTokenDecimals, fromTokenName, toTokenName } = await (0, swapUtils_1.getTokenDetails)(walletProvider, args.fromToken, args.toToken);
116
109
  // Get swap price quote
@@ -164,12 +157,12 @@ class CdpSmartWalletActionProvider extends actionProvider_1.ActionProvider {
164
157
  error: "CDP Swap API for smart wallets is currently only supported on Base networks.",
165
158
  });
166
159
  }
167
- const cdpNetwork = __classPrivateFieldGet(this, _CdpSmartWalletActionProvider_instances, "m", _CdpSmartWalletActionProvider_getCdpSdkNetwork).call(this, networkId);
168
160
  // Check if the owner account is a CDP server account
169
161
  if (walletProvider.ownerAccount.type === "local") {
170
162
  throw new Error("Smart wallet owner account is not a CDP server account.");
171
163
  }
172
164
  try {
165
+ const cdpNetwork = walletProvider.getCdpSdkNetwork();
173
166
  // Get token details
174
167
  const { fromTokenDecimals, fromTokenName, toTokenName, toTokenDecimals } = await (0, swapUtils_1.getTokenDetails)(walletProvider, args.fromToken, args.toToken);
175
168
  // Estimate swap price first to check liquidity, token balance and permit2 approval status
@@ -271,16 +264,6 @@ class CdpSmartWalletActionProvider extends actionProvider_1.ActionProvider {
271
264
  }
272
265
  }
273
266
  exports.CdpSmartWalletActionProvider = CdpSmartWalletActionProvider;
274
- _CdpSmartWalletActionProvider_instances = new WeakSet(), _CdpSmartWalletActionProvider_getCdpSdkNetwork = function _CdpSmartWalletActionProvider_getCdpSdkNetwork(networkId) {
275
- switch (networkId) {
276
- case "base-sepolia":
277
- return "base-sepolia";
278
- case "base-mainnet":
279
- return "base";
280
- default:
281
- throw new Error(`Unsupported network for smart wallets: ${networkId}`);
282
- }
283
- };
284
267
  __decorate([
285
268
  (0, actionDecorator_1.CreateAction)({
286
269
  name: "list_spend_permissions",
@@ -319,7 +302,8 @@ It takes the following inputs:
319
302
  - slippageBps: (Optional) Maximum allowed slippage in basis points (100 = 1%)
320
303
  Important notes:
321
304
  - The contract address for native ETH is "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
322
- - Use fromAmount units exactly as provided, do not convert to wei or any other units.
305
+ - Use fromAmount units exactly as provided, do not convert to wei or any other units
306
+ - Never assume token or address, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool if available to get the token address first
323
307
  `,
324
308
  schema: schemas_1.SwapSchema,
325
309
  }),
@@ -340,7 +324,8 @@ It takes the following inputs:
340
324
  Important notes:
341
325
  - The contract address for native ETH is "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"
342
326
  - If needed, it will automatically approve the permit2 contract to spend the fromToken
343
- - Use fromAmount units exactly as provided, do not convert to wei or any other units.
327
+ - Use fromAmount units exactly as provided, do not convert to wei or any other units
328
+ - Never assume token or address, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool if available to get the token address first
344
329
  `,
345
330
  schema: schemas_1.SwapSchema,
346
331
  }),
@@ -73,6 +73,7 @@ describe("CDP Smart Wallet Action Provider", () => {
73
73
  sendTransaction: jest.fn(),
74
74
  waitForTransactionReceipt: jest.fn(),
75
75
  getPaymasterUrl: jest.fn(),
76
+ getCdpSdkNetwork: jest.fn(),
76
77
  };
77
78
  // Default setup for utility functions
78
79
  mockRetryWithExponentialBackoff.mockImplementation(async (fn) => {
@@ -91,6 +92,7 @@ describe("CDP Smart Wallet Action Provider", () => {
91
92
  });
92
93
  mockWalletProvider.getAddress.mockReturnValue("0x1234567890123456789012345678901234567890");
93
94
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
95
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("base-sepolia");
94
96
  });
95
97
  it("should successfully list spend permissions for EVM networks", async () => {
96
98
  const expectedResult = "Found 1 spend permission(s):\n1. Token: ETH, Allowance: 1000, Period: 3600 seconds, Start: 123456, End: 234567";
@@ -127,6 +129,7 @@ describe("CDP Smart Wallet Action Provider", () => {
127
129
  });
128
130
  mockWalletProvider.getAddress.mockReturnValue("0x1234567890123456789012345678901234567890");
129
131
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
132
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("base-sepolia");
130
133
  });
131
134
  it("should successfully use spend permission for EVM networks", async () => {
132
135
  const mockPermission = {
@@ -157,6 +160,7 @@ describe("CDP Smart Wallet Action Provider", () => {
157
160
  protocolFamily: "evm",
158
161
  networkId: "base-mainnet",
159
162
  });
163
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("base");
160
164
  const mockPermission = { spender: "0x1234", token: "ETH" };
161
165
  const mockSpendResult = { status: "completed" };
162
166
  spendPermissionUtils.findLatestSpendPermission.mockResolvedValue(mockPermission);
@@ -173,6 +177,9 @@ describe("CDP Smart Wallet Action Provider", () => {
173
177
  protocolFamily: "evm",
174
178
  networkId: "ethereum-mainnet",
175
179
  });
180
+ mockWalletProvider.getCdpSdkNetwork.mockImplementation(() => {
181
+ throw new Error("Unsupported network for smart wallets: ethereum-mainnet");
182
+ });
176
183
  await expect(actionProvider.useSpendPermission(mockWalletProvider, mockArgs)).rejects.toThrow("Unsupported network for smart wallets: ethereum-mainnet");
177
184
  });
178
185
  it("should return error message for non-EVM networks", async () => {
@@ -180,7 +187,7 @@ describe("CDP Smart Wallet Action Provider", () => {
180
187
  protocolFamily: "svm",
181
188
  networkId: "solana-devnet",
182
189
  });
183
- await expect(actionProvider.useSpendPermission(mockWalletProvider, mockArgs)).rejects.toThrow("Unsupported network for smart wallets: solana-devnet");
190
+ await expect(actionProvider.useSpendPermission(mockWalletProvider, mockArgs)).rejects.toThrow("Spend permissions are currently only supported on EVM networks.");
184
191
  });
185
192
  it("should handle spend permission not found error", async () => {
186
193
  spendPermissionUtils.findLatestSpendPermission.mockRejectedValue(new Error("No spend permissions found"));
@@ -215,6 +222,7 @@ describe("CDP Smart Wallet Action Provider", () => {
215
222
  beforeEach(() => {
216
223
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
217
224
  mockWalletProvider.getAddress.mockReturnValue("0x1234567890123456789012345678901234567890");
225
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("base");
218
226
  mockGetTokenDetails.mockResolvedValue({
219
227
  fromTokenDecimals: 18,
220
228
  toTokenDecimals: 6,
@@ -252,6 +260,7 @@ describe("CDP Smart Wallet Action Provider", () => {
252
260
  protocolFamily: "evm",
253
261
  networkId: "base-sepolia",
254
262
  });
263
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("base-sepolia");
255
264
  mockCdpClient.evm.getSwapPrice.mockResolvedValue({
256
265
  toAmount: "990000",
257
266
  minToAmount: "980000",
@@ -301,6 +310,7 @@ describe("CDP Smart Wallet Action Provider", () => {
301
310
  beforeEach(() => {
302
311
  mockWalletProvider.getClient.mockReturnValue(mockCdpClient);
303
312
  mockWalletProvider.getAddress.mockReturnValue("0x1234567890123456789012345678901234567890");
313
+ mockWalletProvider.getCdpSdkNetwork.mockReturnValue("base");
304
314
  mockWalletProvider.waitForTransactionReceipt.mockResolvedValue({ status: "complete" });
305
315
  mockWalletProvider.getPaymasterUrl.mockReturnValue("https://paymaster.example");
306
316
  mockGetTokenDetails.mockResolvedValue({
@@ -0,0 +1,43 @@
1
+ import { z } from "zod";
2
+ import { ActionProvider } from "../actionProvider";
3
+ import { Network } from "../../network";
4
+ import { EvmWalletProvider } from "../../wallet-providers";
5
+ import { ClankTokenSchema } from "./schemas";
6
+ /**
7
+ * ClankerActionProvider provides actions for clanker operations.
8
+ *
9
+ * @description
10
+ * This provider is designed to work with EvmWalletProvider for blockchain interactions.
11
+ * It supports all evm networks.
12
+ */
13
+ export declare class ClankerActionProvider extends ActionProvider<EvmWalletProvider> {
14
+ /**
15
+ * Constructor for the ClankerActionProvider.
16
+ */
17
+ constructor();
18
+ /**
19
+ * Clanker action provider
20
+ *
21
+ * @description
22
+ * This action deploys a clanker token using the Clanker sdk
23
+ * It automatically includes the coin in the Clanker ecosystem
24
+ *
25
+ * @param walletProvider - The wallet provider instance for blockchain interactions
26
+ * @param args - Clanker arguments (modify these to fine tune token deployment, like initial quote token and rewards config)
27
+ * @returns A promise that resolves to a string describing the clanker result
28
+ */
29
+ clankToken(walletProvider: EvmWalletProvider, args: z.infer<typeof ClankTokenSchema>): Promise<string>;
30
+ /**
31
+ * Checks if this provider supports the given network.
32
+ *
33
+ * @param network - The network to check support for
34
+ * @returns True if the network is supported
35
+ */
36
+ supportsNetwork(network: Network): boolean;
37
+ }
38
+ /**
39
+ * Factory function to create a new ClankerActionProvider instance.
40
+ *
41
+ * @returns A new ClankerActionProvider instance
42
+ */
43
+ export declare const clankerActionProvider: () => ClankerActionProvider;
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.clankerActionProvider = exports.ClankerActionProvider = void 0;
13
+ const zod_1 = require("zod");
14
+ const actionProvider_1 = require("../actionProvider");
15
+ const actionDecorator_1 = require("../actionDecorator");
16
+ const wallet_providers_1 = require("../../wallet-providers");
17
+ const schemas_1 = require("./schemas");
18
+ const utils_1 = require("./utils");
19
+ /**
20
+ * ClankerActionProvider provides actions for clanker operations.
21
+ *
22
+ * @description
23
+ * This provider is designed to work with EvmWalletProvider for blockchain interactions.
24
+ * It supports all evm networks.
25
+ */
26
+ class ClankerActionProvider extends actionProvider_1.ActionProvider {
27
+ /**
28
+ * Constructor for the ClankerActionProvider.
29
+ */
30
+ constructor() {
31
+ super("clanker", []);
32
+ }
33
+ /**
34
+ * Clanker action provider
35
+ *
36
+ * @description
37
+ * This action deploys a clanker token using the Clanker sdk
38
+ * It automatically includes the coin in the Clanker ecosystem
39
+ *
40
+ * @param walletProvider - The wallet provider instance for blockchain interactions
41
+ * @param args - Clanker arguments (modify these to fine tune token deployment, like initial quote token and rewards config)
42
+ * @returns A promise that resolves to a string describing the clanker result
43
+ */
44
+ async clankToken(walletProvider, args) {
45
+ const network = walletProvider.getNetwork();
46
+ const networkId = network.networkId || "base-mainnet";
47
+ if (!this.supportsNetwork(network)) {
48
+ return `Can't Clank token; network ${networkId} is not supported`;
49
+ }
50
+ const clanker = await (0, utils_1.createClankerClient)(walletProvider, networkId);
51
+ const lockDuration = args.lockDuration_Days * 24 * 60 * 60;
52
+ const vestingDuration = args.vestingDuration_Days * 24 * 60 * 60;
53
+ const tokenConfig = {
54
+ name: args.tokenName,
55
+ symbol: args.tokenSymbol,
56
+ image: args.image,
57
+ metadata: {
58
+ socialMediaUrls: args.socialMediaUrls,
59
+ description: args.description,
60
+ },
61
+ context: {
62
+ interface: args.interface,
63
+ id: args.id,
64
+ },
65
+ tokenAdmin: walletProvider.getAddress(),
66
+ vault: {
67
+ percentage: args.vaultPercentage,
68
+ lockupDuration: lockDuration,
69
+ vestingDuration: vestingDuration,
70
+ },
71
+ chainId: Number(network.chainId),
72
+ };
73
+ try {
74
+ const res = await clanker.deploy(tokenConfig);
75
+ if ("error" in res) {
76
+ return `There was an error deploying the clanker token: ${res}`;
77
+ }
78
+ const { txHash } = res;
79
+ const confirmed = await res.waitForTransaction();
80
+ if ("error" in confirmed) {
81
+ return `There was an error confirming the clanker token deployment: ${confirmed}`;
82
+ }
83
+ const { address } = confirmed;
84
+ return `Clanker token deployed at ${address}! View the transaction at ${txHash}, or view the token page at https://clanker.world/clanker/${address}`;
85
+ }
86
+ catch (error) {
87
+ return `There was an error deploying the clanker token: ${error}`;
88
+ }
89
+ }
90
+ /**
91
+ * Checks if this provider supports the given network.
92
+ *
93
+ * @param network - The network to check support for
94
+ * @returns True if the network is supported
95
+ */
96
+ supportsNetwork(network) {
97
+ return (network.networkId === "base-mainnet" ||
98
+ network.networkId === "base-sepolia" ||
99
+ network.networkId === "arbitrum-mainnet");
100
+ }
101
+ }
102
+ exports.ClankerActionProvider = ClankerActionProvider;
103
+ __decorate([
104
+ (0, actionDecorator_1.CreateAction)({
105
+ name: "clank_token",
106
+ description: `
107
+ his tool will launch a Clanker token using the Clanker SDK.
108
+ It takes the following inputs:
109
+ - tokenName: The name of the deployed token
110
+ - tokenSymbol: The symbol of the deployed token
111
+ - description: An optional description of the token or token project
112
+ - socialMediaUrls: An optional array of social media links for the token, each with a platform and url
113
+ - image: A normal or ipfs URL pointing to the image of the token
114
+ - vaultPercentage: The percentage of the token supply to allocate to a vault accessible to the deployed after the lockup period with optional vesting
115
+ - lockDuration_Days: The lock duration of the tokens in the vault (in days) (minimum 7 days)
116
+ - vestingDuration_Days: The duration (in days) that the token should vest after lockup period, vesting is linear.
117
+ `,
118
+ schema: schemas_1.ClankTokenSchema,
119
+ }),
120
+ __metadata("design:type", Function),
121
+ __metadata("design:paramtypes", [wallet_providers_1.EvmWalletProvider, void 0]),
122
+ __metadata("design:returntype", Promise)
123
+ ], ClankerActionProvider.prototype, "clankToken", null);
124
+ /**
125
+ * Factory function to create a new ClankerActionProvider instance.
126
+ *
127
+ * @returns A new ClankerActionProvider instance
128
+ */
129
+ const clankerActionProvider = () => new ClankerActionProvider();
130
+ exports.clankerActionProvider = clankerActionProvider;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Clanker Action Provider tests
3
+ */
4
+ export {};