@coinbase/agentkit 0.6.2 → 0.7.1

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 (48) hide show
  1. package/README.md +234 -0
  2. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +37 -0
  3. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +91 -0
  4. package/dist/action-providers/cdp-v2/index.d.ts +2 -0
  5. package/dist/action-providers/cdp-v2/index.js +18 -0
  6. package/dist/action-providers/cdp-v2/schemas.d.ts +11 -0
  7. package/dist/action-providers/cdp-v2/schemas.js +13 -0
  8. package/dist/action-providers/compound/schemas.d.ts +8 -8
  9. package/dist/action-providers/flaunch/utils.js +1 -1
  10. package/dist/action-providers/index.d.ts +2 -0
  11. package/dist/action-providers/index.js +2 -0
  12. package/dist/action-providers/twitter/twitterActionProvider.d.ts +8 -1
  13. package/dist/action-providers/twitter/twitterActionProvider.js +36 -18
  14. package/dist/action-providers/twitter/twitterActionProvider.test.js +45 -0
  15. package/dist/action-providers/zerodev/index.d.ts +1 -0
  16. package/dist/action-providers/zerodev/index.js +17 -0
  17. package/dist/action-providers/zerodev/schemas.d.ts +29 -0
  18. package/dist/action-providers/zerodev/schemas.js +21 -0
  19. package/dist/action-providers/zerodev/zeroDevWalletActionProvider.d.ts +32 -0
  20. package/dist/action-providers/zerodev/zeroDevWalletActionProvider.js +66 -0
  21. package/dist/action-providers/zerodev/zeroDevWalletActionProvider.test.d.ts +1 -0
  22. package/dist/action-providers/zerodev/zeroDevWalletActionProvider.test.js +112 -0
  23. package/dist/network/svm.d.ts +1 -0
  24. package/dist/network/svm.js +6 -1
  25. package/dist/wallet-providers/cdpV2EvmWalletProvider.d.ts +105 -0
  26. package/dist/wallet-providers/cdpV2EvmWalletProvider.js +212 -0
  27. package/dist/wallet-providers/cdpV2EvmWalletProvider.test.d.ts +1 -0
  28. package/dist/wallet-providers/cdpV2EvmWalletProvider.test.js +343 -0
  29. package/dist/wallet-providers/cdpV2Shared.d.ts +41 -0
  30. package/dist/wallet-providers/cdpV2Shared.js +2 -0
  31. package/dist/wallet-providers/cdpV2SolanaWalletProvider.d.ts +111 -0
  32. package/dist/wallet-providers/cdpV2SolanaWalletProvider.js +247 -0
  33. package/dist/wallet-providers/cdpV2SolanaWalletProvider.test.d.ts +1 -0
  34. package/dist/wallet-providers/cdpV2SolanaWalletProvider.test.js +307 -0
  35. package/dist/wallet-providers/cdpV2WalletProvider.d.ts +35 -0
  36. package/dist/wallet-providers/cdpV2WalletProvider.js +42 -0
  37. package/dist/wallet-providers/cdpWalletProvider.js +1 -1
  38. package/dist/wallet-providers/cdpWalletProvider.test.js +1 -0
  39. package/dist/wallet-providers/evmWalletProvider.d.ts +7 -1
  40. package/dist/wallet-providers/evmWalletProvider.js +20 -0
  41. package/dist/wallet-providers/index.d.ts +5 -0
  42. package/dist/wallet-providers/index.js +5 -0
  43. package/dist/wallet-providers/walletProvider.test.js +22 -0
  44. package/dist/wallet-providers/zeroDevWalletProvider.d.ts +147 -0
  45. package/dist/wallet-providers/zeroDevWalletProvider.js +301 -0
  46. package/dist/wallet-providers/zeroDevWalletProvider.test.d.ts +1 -0
  47. package/dist/wallet-providers/zeroDevWalletProvider.test.js +435 -0
  48. package/package.json +5 -1
@@ -27,29 +27,29 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
27
27
  * @param config - The configuration options for the TwitterActionProvider
28
28
  */
29
29
  constructor(config = {}) {
30
+ var _a, _b, _c, _d;
30
31
  super("twitter", []);
31
- config.apiKey || (config.apiKey = process.env.TWITTER_API_KEY);
32
- config.apiSecret || (config.apiSecret = process.env.TWITTER_API_SECRET);
33
- config.accessToken || (config.accessToken = process.env.TWITTER_ACCESS_TOKEN);
34
- config.accessTokenSecret || (config.accessTokenSecret = process.env.TWITTER_ACCESS_TOKEN_SECRET);
35
- if (!config.apiKey) {
32
+ this.client = null;
33
+ // Store config for later use but don't initialize the client yet
34
+ this.config = { ...config };
35
+ // Set defaults from environment variables
36
+ (_a = this.config).apiKey || (_a.apiKey = process.env.TWITTER_API_KEY);
37
+ (_b = this.config).apiSecret || (_b.apiSecret = process.env.TWITTER_API_SECRET);
38
+ (_c = this.config).accessToken || (_c.accessToken = process.env.TWITTER_ACCESS_TOKEN);
39
+ (_d = this.config).accessTokenSecret || (_d.accessTokenSecret = process.env.TWITTER_ACCESS_TOKEN_SECRET);
40
+ // Validate config
41
+ if (!this.config.apiKey) {
36
42
  throw new Error("TWITTER_API_KEY is not configured.");
37
43
  }
38
- if (!config.apiSecret) {
44
+ if (!this.config.apiSecret) {
39
45
  throw new Error("TWITTER_API_SECRET is not configured.");
40
46
  }
41
- if (!config.accessToken) {
47
+ if (!this.config.accessToken) {
42
48
  throw new Error("TWITTER_ACCESS_TOKEN is not configured.");
43
49
  }
44
- if (!config.accessTokenSecret) {
50
+ if (!this.config.accessTokenSecret) {
45
51
  throw new Error("TWITTER_ACCESS_TOKEN_SECRET is not configured.");
46
52
  }
47
- this.client = new twitter_api_v2_1.TwitterApi({
48
- appKey: config.apiKey,
49
- appSecret: config.apiSecret,
50
- accessToken: config.accessToken,
51
- accessSecret: config.accessTokenSecret,
52
- });
53
53
  }
54
54
  /**
55
55
  * Get account details for the currently authenticated Twitter (X) user.
@@ -59,7 +59,7 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
59
59
  */
60
60
  async accountDetails(_) {
61
61
  try {
62
- const response = await this.client.v2.me();
62
+ const response = await this.getClient().v2.me();
63
63
  response.data.url = `https://x.com/${response.data.username}`;
64
64
  return `Successfully retrieved authenticated user account details:\n${JSON.stringify(response)}`;
65
65
  }
@@ -75,7 +75,7 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
75
75
  */
76
76
  async accountMentions(args) {
77
77
  try {
78
- const response = await this.client.v2.userMentionTimeline(args.userId);
78
+ const response = await this.getClient().v2.userMentionTimeline(args.userId);
79
79
  return `Successfully retrieved account mentions:\n${JSON.stringify(response)}`;
80
80
  }
81
81
  catch (error) {
@@ -90,7 +90,7 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
90
90
  */
91
91
  async postTweet(args) {
92
92
  try {
93
- const response = await this.client.v2.tweet(args.tweet);
93
+ const response = await this.getClient().v2.tweet(args.tweet);
94
94
  return `Successfully posted to Twitter:\n${JSON.stringify(response)}`;
95
95
  }
96
96
  catch (error) {
@@ -105,7 +105,7 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
105
105
  */
106
106
  async postTweetReply(args) {
107
107
  try {
108
- const response = await this.client.v2.tweet(args.tweetReply, {
108
+ const response = await this.getClient().v2.tweet(args.tweetReply, {
109
109
  reply: { in_reply_to_tweet_id: args.tweetId },
110
110
  });
111
111
  return `Successfully posted reply to Twitter:\n${JSON.stringify(response)}`;
@@ -124,6 +124,24 @@ class TwitterActionProvider extends actionProvider_1.ActionProvider {
124
124
  supportsNetwork(_) {
125
125
  return true;
126
126
  }
127
+ /**
128
+ * Get the Twitter API client, initializing it if needed
129
+ *
130
+ * @returns The Twitter API client
131
+ */
132
+ getClient() {
133
+ if (!this.client) {
134
+ // Initialize client only when needed
135
+ const tokens = {
136
+ appKey: this.config.apiKey,
137
+ appSecret: this.config.apiSecret,
138
+ accessToken: this.config.accessToken,
139
+ accessSecret: this.config.accessTokenSecret,
140
+ };
141
+ this.client = new twitter_api_v2_1.TwitterApi(tokens);
142
+ }
143
+ return this.client;
144
+ }
127
145
  }
128
146
  exports.TwitterActionProvider = TwitterActionProvider;
129
147
  __decorate([
@@ -44,6 +44,24 @@ describe("TwitterActionProvider", () => {
44
44
  delete process.env.TWITTER_ACCESS_TOKEN_SECRET;
45
45
  expect(() => new twitterActionProvider_1.TwitterActionProvider()).toThrow("TWITTER_API_KEY is not configured.");
46
46
  });
47
+ it("should implement lazy initialization", async () => {
48
+ // We'll check lazy initialization by observing that we can create an instance
49
+ // without error, and then use it to call methods successfully
50
+ const provider = new twitterActionProvider_1.TwitterActionProvider(MOCK_CONFIG);
51
+ // Mock a response for accountDetails
52
+ mockClient.me.mockResolvedValue({
53
+ data: {
54
+ id: MOCK_ID,
55
+ name: MOCK_NAME,
56
+ username: MOCK_USERNAME,
57
+ },
58
+ });
59
+ // Call a method that should trigger initialization
60
+ const response = await provider.accountDetails({});
61
+ // Verify the method worked, which means initialization succeeded
62
+ expect(response).toContain("Successfully retrieved authenticated user account details");
63
+ expect(mockClient.me).toHaveBeenCalled();
64
+ });
47
65
  });
48
66
  describe("Account Details Action", () => {
49
67
  const mockResponse = {
@@ -182,4 +200,31 @@ describe("TwitterActionProvider", () => {
182
200
  expect(provider.supportsNetwork({ protocolFamily: "solana", networkId: "2" })).toBe(true);
183
201
  });
184
202
  });
203
+ describe("Next.js Integration", () => {
204
+ it("should work in a simulated Next.js environment", async () => {
205
+ // Create a clean instance of the provider
206
+ const provider = new twitterActionProvider_1.TwitterActionProvider(MOCK_CONFIG);
207
+ // Mock v2.me to test functionality
208
+ const mockResponse = {
209
+ data: {
210
+ id: MOCK_ID,
211
+ name: MOCK_NAME,
212
+ username: MOCK_USERNAME,
213
+ },
214
+ };
215
+ const mockTwitterApi = {
216
+ v2: {
217
+ me: jest.fn().mockResolvedValue(mockResponse),
218
+ },
219
+ };
220
+ // Override the getClient method to return our mocked API
221
+ jest
222
+ .spyOn(provider, "getClient")
223
+ .mockReturnValue(mockTwitterApi);
224
+ // Simulate a Next.js API route calling the provider
225
+ const result = await provider.accountDetails({});
226
+ expect(result).toContain("Successfully retrieved authenticated user account details");
227
+ expect(mockTwitterApi.v2.me).toHaveBeenCalled();
228
+ });
229
+ });
185
230
  });
@@ -0,0 +1 @@
1
+ export * from "./zeroDevWalletActionProvider";
@@ -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("./zeroDevWalletActionProvider"), exports);
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Input schema for get CAB action.
4
+ */
5
+ export declare const GetCABSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
6
+ type: z.ZodLiteral<"networkFilter">;
7
+ tokenTickers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
8
+ networks: z.ZodArray<z.ZodNumber, "many">;
9
+ }, "strip", z.ZodTypeAny, {
10
+ type: "networkFilter";
11
+ networks: number[];
12
+ tokenTickers?: string[] | undefined;
13
+ }, {
14
+ type: "networkFilter";
15
+ networks: number[];
16
+ tokenTickers?: string[] | undefined;
17
+ }>, z.ZodObject<{
18
+ type: z.ZodLiteral<"networkType">;
19
+ tokenTickers: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
20
+ networkType: z.ZodEnum<["mainnet", "testnet"]>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ type: "networkType";
23
+ networkType: "testnet" | "mainnet";
24
+ tokenTickers?: string[] | undefined;
25
+ }, {
26
+ type: "networkType";
27
+ networkType: "testnet" | "mainnet";
28
+ tokenTickers?: string[] | undefined;
29
+ }>]>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetCABSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Input schema for get CAB action.
7
+ */
8
+ exports.GetCABSchema = zod_1.z.discriminatedUnion("type", [
9
+ zod_1.z.object({
10
+ type: zod_1.z.literal("networkFilter"),
11
+ tokenTickers: zod_1.z.array(zod_1.z.string()).optional(),
12
+ networks: zod_1.z.array(zod_1.z.number()).describe("The networks to get the balance for."),
13
+ }),
14
+ zod_1.z.object({
15
+ type: zod_1.z.literal("networkType"),
16
+ tokenTickers: zod_1.z.array(zod_1.z.string()).optional(),
17
+ networkType: zod_1.z
18
+ .enum(["mainnet", "testnet"])
19
+ .describe("The type of network to get the balance for."),
20
+ }),
21
+ ]);
@@ -0,0 +1,32 @@
1
+ import { ZeroDevWalletProvider } from "../../wallet-providers";
2
+ import { ActionProvider } from "../actionProvider";
3
+ import { Network } from "../../network";
4
+ import { GetCABSchema } from "./schemas";
5
+ import { z } from "zod";
6
+ /**
7
+ * ZeroDevWalletActionProvider is an action provider for ZeroDevWalletProvider.
8
+ *
9
+ * This provider is used for any action that requires a ZeroDevWalletProvider.
10
+ */
11
+ export declare class ZeroDevWalletActionProvider extends ActionProvider<ZeroDevWalletProvider> {
12
+ /**
13
+ * Constructs a new ZeroDevWalletActionProvider.
14
+ */
15
+ constructor();
16
+ /**
17
+ * Gets the chain abstracted balance for the wallet.
18
+ *
19
+ * @param walletProvider - The wallet provider to get the balance for.
20
+ * @param args - The arguments for the action.
21
+ * @returns The chain abstracted balance for the wallet.
22
+ */
23
+ getCAB(walletProvider: ZeroDevWalletProvider, args: z.infer<typeof GetCABSchema>): Promise<import("@zerodev/intent").GetCABResult>;
24
+ /**
25
+ * Checks if the ZeroDevWalletActionProvider supports the given network.
26
+ *
27
+ * @param network - The network to check.
28
+ * @returns True if the ZeroDevWalletActionProvider supports the network, false otherwise.
29
+ */
30
+ supportsNetwork: (network: Network) => boolean;
31
+ }
32
+ export declare const zeroDevWalletActionProvider: () => ZeroDevWalletActionProvider;
@@ -0,0 +1,66 @@
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.zeroDevWalletActionProvider = exports.ZeroDevWalletActionProvider = void 0;
13
+ const wallet_providers_1 = require("../../wallet-providers");
14
+ const actionProvider_1 = require("../actionProvider");
15
+ const actionDecorator_1 = require("../actionDecorator");
16
+ const schemas_1 = require("./schemas");
17
+ const zod_1 = require("zod");
18
+ /**
19
+ * ZeroDevWalletActionProvider is an action provider for ZeroDevWalletProvider.
20
+ *
21
+ * This provider is used for any action that requires a ZeroDevWalletProvider.
22
+ */
23
+ class ZeroDevWalletActionProvider extends actionProvider_1.ActionProvider {
24
+ /**
25
+ * Constructs a new ZeroDevWalletActionProvider.
26
+ */
27
+ constructor() {
28
+ super("zeroDevWallet", []);
29
+ /**
30
+ * Checks if the ZeroDevWalletActionProvider supports the given network.
31
+ *
32
+ * @param network - The network to check.
33
+ * @returns True if the ZeroDevWalletActionProvider supports the network, false otherwise.
34
+ */
35
+ this.supportsNetwork = (network) => network.protocolFamily === "evm";
36
+ }
37
+ /**
38
+ * Gets the chain abstracted balance for the wallet.
39
+ *
40
+ * @param walletProvider - The wallet provider to get the balance for.
41
+ * @param args - The arguments for the action.
42
+ * @returns The chain abstracted balance for the wallet.
43
+ */
44
+ async getCAB(walletProvider, args) {
45
+ return walletProvider.getCAB(args);
46
+ }
47
+ }
48
+ exports.ZeroDevWalletActionProvider = ZeroDevWalletActionProvider;
49
+ __decorate([
50
+ (0, actionDecorator_1.CreateAction)({
51
+ name: "get_cab",
52
+ description: `This tool retrieves the chain abstracted balance (CAB) for specified tokens across multiple networks.
53
+ It takes the following inputs:
54
+ - tokenTickers: An array of token symbols (e.g., ["ETH", "USDC"]) to get balances for
55
+ - networks (optional): An array of network IDs to check balances on. If not provided, will check all supported networks
56
+ - networkType (optional): Filter networks by type ("mainnet" or "testnet"). If not provided, will check both types
57
+
58
+ The tool will return the aggregated balance across all specified networks for each token ticker. This is useful for getting a complete picture of a wallet's holdings across different chains in a single call.`,
59
+ schema: schemas_1.GetCABSchema,
60
+ }),
61
+ __metadata("design:type", Function),
62
+ __metadata("design:paramtypes", [wallet_providers_1.ZeroDevWalletProvider, void 0]),
63
+ __metadata("design:returntype", Promise)
64
+ ], ZeroDevWalletActionProvider.prototype, "getCAB", null);
65
+ const zeroDevWalletActionProvider = () => new ZeroDevWalletActionProvider();
66
+ exports.zeroDevWalletActionProvider = zeroDevWalletActionProvider;
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const zeroDevWalletActionProvider_1 = require("./zeroDevWalletActionProvider");
4
+ const schemas_1 = require("./schemas");
5
+ describe("ZeroDev Wallet Action Provider Input Schemas", () => {
6
+ describe("Get CAB Schema", () => {
7
+ it("should successfully parse valid input with network type", () => {
8
+ const validInput = {
9
+ type: "networkType",
10
+ tokenTickers: ["ETH", "USDC"],
11
+ networkType: "mainnet",
12
+ };
13
+ const result = schemas_1.GetCABSchema.safeParse(validInput);
14
+ expect(result.success).toBe(true);
15
+ expect(result.data).toEqual(validInput);
16
+ });
17
+ it("should successfully parse valid input with network filter", () => {
18
+ const validInput = {
19
+ type: "networkFilter",
20
+ tokenTickers: ["ETH", "USDC"],
21
+ networks: [1, 8453], // ethereum and base network IDs
22
+ };
23
+ const result = schemas_1.GetCABSchema.safeParse(validInput);
24
+ expect(result.success).toBe(true);
25
+ expect(result.data).toEqual(validInput);
26
+ });
27
+ it("should successfully parse input with optional tokenTickers omitted", () => {
28
+ const validInput = {
29
+ type: "networkType",
30
+ networkType: "mainnet",
31
+ };
32
+ const result = schemas_1.GetCABSchema.safeParse(validInput);
33
+ expect(result.success).toBe(true);
34
+ expect(result.data).toEqual(validInput);
35
+ });
36
+ it("should fail parsing empty input", () => {
37
+ const emptyInput = {};
38
+ const result = schemas_1.GetCABSchema.safeParse(emptyInput);
39
+ expect(result.success).toBe(false);
40
+ });
41
+ });
42
+ });
43
+ describe("ZeroDev Wallet Action Provider", () => {
44
+ let actionProvider;
45
+ let mockWallet;
46
+ beforeEach(() => {
47
+ // Reset all mocks before each test
48
+ jest.clearAllMocks();
49
+ actionProvider = new zeroDevWalletActionProvider_1.ZeroDevWalletActionProvider();
50
+ mockWallet = {
51
+ getCAB: jest.fn(),
52
+ getAddress: jest.fn().mockReturnValue("0xe6b2af36b3bb8d47206a129ff11d5a2de2a63c83"),
53
+ getNetwork: jest.fn().mockReturnValue({ networkId: "ethereum-mainnet" }),
54
+ };
55
+ });
56
+ describe("getCAB", () => {
57
+ const MOCK_BALANCES = {
58
+ balance: BigInt(1000000000000000000),
59
+ tokenAddress: "0x1234567890123456789012345678901234567890",
60
+ tokens: {
61
+ ETH: {
62
+ ethereum: "1.5",
63
+ base: "0.5",
64
+ },
65
+ USDC: {
66
+ ethereum: "1000",
67
+ base: "500",
68
+ },
69
+ },
70
+ };
71
+ beforeEach(() => {
72
+ mockWallet.getCAB.mockResolvedValue(MOCK_BALANCES);
73
+ });
74
+ it("should successfully get chain abstracted balances with network type", async () => {
75
+ const args = {
76
+ type: "networkType",
77
+ tokenTickers: ["ETH", "USDC"],
78
+ networkType: "mainnet",
79
+ };
80
+ const result = await actionProvider.getCAB(mockWallet, args);
81
+ expect(mockWallet.getCAB).toHaveBeenCalledWith(args);
82
+ expect(result).toEqual(MOCK_BALANCES);
83
+ });
84
+ it("should successfully get chain abstracted balances with network filter", async () => {
85
+ const args = {
86
+ type: "networkFilter",
87
+ tokenTickers: ["ETH", "USDC"],
88
+ networks: [1, 8453], // ethereum and base network IDs
89
+ };
90
+ const result = await actionProvider.getCAB(mockWallet, args);
91
+ expect(mockWallet.getCAB).toHaveBeenCalledWith(args);
92
+ expect(result).toEqual(MOCK_BALANCES);
93
+ });
94
+ it("should handle errors when getting balances", async () => {
95
+ const args = {
96
+ type: "networkType",
97
+ networkType: "mainnet",
98
+ };
99
+ const error = new Error("Failed to get balances");
100
+ mockWallet.getCAB.mockRejectedValue(error);
101
+ await expect(actionProvider.getCAB(mockWallet, args)).rejects.toThrow(error);
102
+ });
103
+ });
104
+ describe("supportsNetwork", () => {
105
+ it("should return true when protocolFamily is evm", () => {
106
+ expect(actionProvider.supportsNetwork({ protocolFamily: "evm" })).toBe(true);
107
+ });
108
+ it("should return false when protocolFamily is not evm", () => {
109
+ expect(actionProvider.supportsNetwork({ protocolFamily: "solana" })).toBe(false);
110
+ });
111
+ });
112
+ });
@@ -3,6 +3,7 @@ export declare const SOLANA_MAINNET_NETWORK_ID = "solana-mainnet";
3
3
  export declare const SOLANA_TESTNET_NETWORK_ID = "solana-testnet";
4
4
  export declare const SOLANA_DEVNET_NETWORK_ID = "solana-devnet";
5
5
  export type SOLANA_NETWORK_ID = typeof SOLANA_MAINNET_NETWORK_ID | typeof SOLANA_TESTNET_NETWORK_ID | typeof SOLANA_DEVNET_NETWORK_ID;
6
+ export declare const SOLANA_NETWORK_IDS: SOLANA_NETWORK_ID[];
6
7
  export declare const SOLANA_PROTOCOL_FAMILY = "svm";
7
8
  export declare const SOLANA_MAINNET_GENESIS_BLOCK_HASH = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
8
9
  export declare const SOLANA_TESTNET_GENESIS_BLOCK_HASH = "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY";
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SOLANA_CLUSTER_ID_BY_NETWORK_ID = exports.SOLANA_NETWORKS = exports.SOLANA_DEVNET_NETWORK = exports.SOLANA_TESTNET_NETWORK = exports.SOLANA_MAINNET_NETWORK = exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH = exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH = exports.SOLANA_MAINNET_GENESIS_BLOCK_HASH = exports.SOLANA_PROTOCOL_FAMILY = exports.SOLANA_DEVNET_NETWORK_ID = exports.SOLANA_TESTNET_NETWORK_ID = exports.SOLANA_MAINNET_NETWORK_ID = void 0;
3
+ exports.SOLANA_CLUSTER_ID_BY_NETWORK_ID = exports.SOLANA_NETWORKS = exports.SOLANA_DEVNET_NETWORK = exports.SOLANA_TESTNET_NETWORK = exports.SOLANA_MAINNET_NETWORK = exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH = exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH = exports.SOLANA_MAINNET_GENESIS_BLOCK_HASH = exports.SOLANA_PROTOCOL_FAMILY = exports.SOLANA_NETWORK_IDS = exports.SOLANA_DEVNET_NETWORK_ID = exports.SOLANA_TESTNET_NETWORK_ID = exports.SOLANA_MAINNET_NETWORK_ID = void 0;
4
4
  // CDP Network IDs
5
5
  exports.SOLANA_MAINNET_NETWORK_ID = "solana-mainnet";
6
6
  exports.SOLANA_TESTNET_NETWORK_ID = "solana-testnet";
7
7
  exports.SOLANA_DEVNET_NETWORK_ID = "solana-devnet";
8
+ exports.SOLANA_NETWORK_IDS = [
9
+ exports.SOLANA_MAINNET_NETWORK_ID,
10
+ exports.SOLANA_TESTNET_NETWORK_ID,
11
+ exports.SOLANA_DEVNET_NETWORK_ID,
12
+ ];
8
13
  // AgentKit Protocol Family
9
14
  exports.SOLANA_PROTOCOL_FAMILY = "svm";
10
15
  // Chain IDs - Genesis Block Hashes
@@ -0,0 +1,105 @@
1
+ import { CdpClient } from "@coinbase/cdp-sdk";
2
+ import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionRequest } from "viem";
3
+ import { Network } from "../network";
4
+ import { EvmWalletProvider } from "./evmWalletProvider";
5
+ import { WalletProviderWithClient, CdpV2WalletProviderConfig } from "./cdpV2Shared";
6
+ /**
7
+ * A wallet provider that uses the Coinbase SDK.
8
+ */
9
+ export declare class CdpV2EvmWalletProvider extends EvmWalletProvider implements WalletProviderWithClient {
10
+ #private;
11
+ /**
12
+ * Constructs a new CdpWalletProvider.
13
+ *
14
+ * @param config - The configuration options for the CdpWalletProvider.
15
+ */
16
+ private constructor();
17
+ /**
18
+ * Configures a new CdpWalletProvider with a wallet.
19
+ *
20
+ * @param config - Optional configuration parameters
21
+ * @returns A Promise that resolves to a new CdpWalletProvider instance
22
+ * @throws Error if required environment variables are missing or wallet initialization fails
23
+ */
24
+ static configureWithWallet(config?: CdpV2WalletProviderConfig): Promise<CdpV2EvmWalletProvider>;
25
+ /**
26
+ * Signs a message.
27
+ *
28
+ * @param message - The message to sign.
29
+ * @returns The signed message.
30
+ */
31
+ signMessage(message: string): Promise<Hex>;
32
+ /**
33
+ * Signs a typed data object.
34
+ *
35
+ * @param typedData - The typed data object to sign.
36
+ * @returns The signed typed data object.
37
+ */
38
+ signTypedData(typedData: any): Promise<Hex>;
39
+ /**
40
+ * Signs a transaction.
41
+ *
42
+ * @param transaction - The transaction to sign.
43
+ * @returns The signed transaction.
44
+ */
45
+ signTransaction(transaction: TransactionRequest): Promise<Hex>;
46
+ /**
47
+ * Sends a transaction.
48
+ *
49
+ * @param transaction - The transaction to send.
50
+ * @returns The hash of the transaction.
51
+ */
52
+ sendTransaction(transaction: TransactionRequest): Promise<Hex>;
53
+ /**
54
+ * Gets the address of the wallet.
55
+ *
56
+ * @returns The address of the wallet.
57
+ */
58
+ getAddress(): string;
59
+ /**
60
+ * Gets the network of the wallet.
61
+ *
62
+ * @returns The network of the wallet.
63
+ */
64
+ getNetwork(): Network;
65
+ /**
66
+ * Gets the name of the wallet provider.
67
+ *
68
+ * @returns The name of the wallet provider.
69
+ */
70
+ getName(): string;
71
+ /**
72
+ * Gets the CDP client.
73
+ *
74
+ * @returns The CDP client.
75
+ */
76
+ getClient(): CdpClient;
77
+ /**
78
+ * Gets the balance of the wallet.
79
+ *
80
+ * @returns The balance of the wallet in wei
81
+ */
82
+ getBalance(): Promise<bigint>;
83
+ /**
84
+ * Waits for a transaction receipt.
85
+ *
86
+ * @param txHash - The hash of the transaction to wait for.
87
+ * @returns The transaction receipt.
88
+ */
89
+ waitForTransactionReceipt(txHash: Hex): Promise<any>;
90
+ /**
91
+ * Reads a contract.
92
+ *
93
+ * @param params - The parameters to read the contract.
94
+ * @returns The response from the contract.
95
+ */
96
+ readContract<const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi, "pure" | "view">, const args extends ContractFunctionArgs<abi, "pure" | "view", functionName>>(params: ReadContractParameters<abi, functionName, args>): Promise<ReadContractReturnType<abi, functionName, args>>;
97
+ /**
98
+ * Transfer the native asset of the network.
99
+ *
100
+ * @param to - The destination address.
101
+ * @param value - The amount to transfer in Wei.
102
+ * @returns The transaction hash.
103
+ */
104
+ nativeTransfer(to: Address, value: string): Promise<Hex>;
105
+ }