@coinbase/agentkit 0.2.3 → 0.3.0

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 (28) hide show
  1. package/README.md +13 -0
  2. package/dist/action-providers/allora/alloraActionProvider.d.ts +44 -0
  3. package/dist/action-providers/allora/alloraActionProvider.js +195 -0
  4. package/dist/action-providers/allora/alloraActionProvider.test.d.ts +1 -0
  5. package/dist/action-providers/allora/alloraActionProvider.test.js +109 -0
  6. package/dist/action-providers/allora/index.d.ts +2 -0
  7. package/dist/action-providers/allora/index.js +18 -0
  8. package/dist/action-providers/allora/schemas.d.ts +28 -0
  9. package/dist/action-providers/allora/schemas.js +30 -0
  10. package/dist/action-providers/erc721/constants.d.ts +0 -4
  11. package/dist/action-providers/erc721/constants.js +1 -4
  12. package/dist/action-providers/erc721/erc721ActionProvider.js +1 -1
  13. package/dist/action-providers/erc721/erc721ActionProvider.test.js +1 -1
  14. package/dist/action-providers/index.d.ts +2 -0
  15. package/dist/action-providers/index.js +2 -0
  16. package/dist/action-providers/opensea/index.d.ts +1 -0
  17. package/dist/action-providers/opensea/index.js +17 -0
  18. package/dist/action-providers/opensea/openseaActionProvider.d.ts +59 -0
  19. package/dist/action-providers/opensea/openseaActionProvider.js +146 -0
  20. package/dist/action-providers/opensea/openseaActionProvider.test.d.ts +1 -0
  21. package/dist/action-providers/opensea/openseaActionProvider.test.js +201 -0
  22. package/dist/action-providers/opensea/schemas.d.ts +30 -0
  23. package/dist/action-providers/opensea/schemas.js +33 -0
  24. package/dist/action-providers/opensea/utils.d.ts +12 -0
  25. package/dist/action-providers/opensea/utils.js +47 -0
  26. package/dist/wallet-providers/cdpWalletProvider.d.ts +6 -0
  27. package/dist/wallet-providers/cdpWalletProvider.js +11 -0
  28. package/package.json +13 -2
package/README.md CHANGED
@@ -248,6 +248,19 @@ const agent = createReactAgent({
248
248
  </table>
249
249
  </details>
250
250
  <details>
251
+ <summary><strong>Opensea</strong></summary>
252
+ <table width="100%">
253
+ <tr>
254
+ <td width="200"><code>list_nft</code></td>
255
+ <td width="768">Lists an NFT for sale on OpenSea.</td>
256
+ </tr>
257
+ <tr>
258
+ <td width="200"><code>get_nfts_by_account</code></td>
259
+ <td width="768">Fetches NFTs owned by a specific wallet address on OpenSea.</td>
260
+ </tr>
261
+ </table>
262
+ </details>
263
+ <details>
251
264
  <summary><strong>Pyth</strong></summary>
252
265
  <table width="100%">
253
266
  <tr>
@@ -0,0 +1,44 @@
1
+ import { ActionProvider } from "../actionProvider";
2
+ import { AlloraAPIClientConfig } from "@alloralabs/allora-sdk";
3
+ import { z } from "zod";
4
+ import { GetAllTopicsSchema, GetInferenceByTopicIdSchema, GetPriceInferenceSchema } from "./schemas";
5
+ /**
6
+ * Action provider for interacting with Allora Network
7
+ */
8
+ export declare class AlloraActionProvider extends ActionProvider {
9
+ private client;
10
+ /**
11
+ * Creates an instance of AlloraActionProvider
12
+ *
13
+ * @param config - Configuration for the Allora API client including API key and optional chain slug
14
+ */
15
+ constructor(config?: AlloraAPIClientConfig);
16
+ /**
17
+ * Gets all available topics from Allora Network
18
+ *
19
+ * @param _ - Empty object as no parameters are required
20
+ * @returns A string containing the list of topics in JSON format
21
+ */
22
+ getAllTopics(_: z.infer<typeof GetAllTopicsSchema>): Promise<string>;
23
+ /**
24
+ * Gets inference data for a specific topic from Allora Network
25
+ *
26
+ * @param args - Object containing the topic ID to get inference for
27
+ * @returns A string containing the inference data in JSON format
28
+ */
29
+ getInferenceByTopicId(args: z.infer<typeof GetInferenceByTopicIdSchema>): Promise<string>;
30
+ /**
31
+ * Gets price inference for a token/timeframe pair from Allora Network
32
+ *
33
+ * @param args - Object containing the asset symbol and timeframe
34
+ * @returns A string containing the price inference data in JSON format
35
+ */
36
+ getPriceInference(args: z.infer<typeof GetPriceInferenceSchema>): Promise<string>;
37
+ /**
38
+ * Checks if the provider supports a given network
39
+ *
40
+ * @returns Always returns true as Allora service is network-agnostic
41
+ */
42
+ supportsNetwork(): boolean;
43
+ }
44
+ export declare const alloraActionProvider: (config?: AlloraAPIClientConfig) => AlloraActionProvider;
@@ -0,0 +1,195 @@
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.alloraActionProvider = exports.AlloraActionProvider = void 0;
13
+ const actionProvider_1 = require("../actionProvider");
14
+ const actionDecorator_1 = require("../actionDecorator");
15
+ const allora_sdk_1 = require("@alloralabs/allora-sdk");
16
+ const zod_1 = require("zod");
17
+ const schemas_1 = require("./schemas");
18
+ /**
19
+ * Action provider for interacting with Allora Network
20
+ */
21
+ class AlloraActionProvider extends actionProvider_1.ActionProvider {
22
+ /**
23
+ * Creates an instance of AlloraActionProvider
24
+ *
25
+ * @param config - Configuration for the Allora API client including API key and optional chain slug
26
+ */
27
+ constructor(config = {}) {
28
+ super("allora", []);
29
+ // This is a public, development only key and should be used for testing purposes only.
30
+ // It might be changed or revoked in the future. It is also subject to limits and usage policies.
31
+ const DEFAULT_API_KEY = "UP-4151d0cc489a44a7aa5cd7ef";
32
+ config.apiKey = config.apiKey || DEFAULT_API_KEY;
33
+ config.chainSlug = config.chainSlug || allora_sdk_1.ChainSlug.TESTNET;
34
+ this.client = new allora_sdk_1.AlloraAPIClient(config);
35
+ }
36
+ /**
37
+ * Gets all available topics from Allora Network
38
+ *
39
+ * @param _ - Empty object as no parameters are required
40
+ * @returns A string containing the list of topics in JSON format
41
+ */
42
+ async getAllTopics(_) {
43
+ try {
44
+ const topics = await this.client.getAllTopics();
45
+ const topicsJson = JSON.stringify(topics);
46
+ return `The available topics at Allora Network are:\n ${topicsJson}`;
47
+ }
48
+ catch (error) {
49
+ return `Error getting all topics: ${error}`;
50
+ }
51
+ }
52
+ /**
53
+ * Gets inference data for a specific topic from Allora Network
54
+ *
55
+ * @param args - Object containing the topic ID to get inference for
56
+ * @returns A string containing the inference data in JSON format
57
+ */
58
+ async getInferenceByTopicId(args) {
59
+ try {
60
+ const inference = await this.client.getInferenceByTopicID(args.topicId);
61
+ const inferenceJson = JSON.stringify(inference.inference_data);
62
+ return `The inference for topic ${args.topicId} is:\n ${inferenceJson}`;
63
+ }
64
+ catch (error) {
65
+ return `Error getting inference for topic ${args.topicId}: ${error}`;
66
+ }
67
+ }
68
+ /**
69
+ * Gets price inference for a token/timeframe pair from Allora Network
70
+ *
71
+ * @param args - Object containing the asset symbol and timeframe
72
+ * @returns A string containing the price inference data in JSON format
73
+ */
74
+ async getPriceInference(args) {
75
+ try {
76
+ const inference = await this.client.getPriceInference(args.asset, args.timeframe);
77
+ const response = {
78
+ price: inference.inference_data.network_inference_normalized,
79
+ timestamp: inference.inference_data.timestamp,
80
+ asset: args.asset,
81
+ timeframe: args.timeframe,
82
+ };
83
+ const inferenceJson = JSON.stringify(response);
84
+ return `The price inference for ${args.asset} (${args.timeframe}) is:\n${inferenceJson}`;
85
+ }
86
+ catch (error) {
87
+ return `Error getting price inference for ${args.asset} (${args.timeframe}): ${error}`;
88
+ }
89
+ }
90
+ /**
91
+ * Checks if the provider supports a given network
92
+ *
93
+ * @returns Always returns true as Allora service is network-agnostic
94
+ */
95
+ supportsNetwork() {
96
+ return true; // Allora service is network-agnostic
97
+ }
98
+ }
99
+ exports.AlloraActionProvider = AlloraActionProvider;
100
+ __decorate([
101
+ (0, actionDecorator_1.CreateAction)({
102
+ name: "get_all_topics",
103
+ description: `
104
+ This tool will get all available inference topics from Allora Network.
105
+
106
+ A successful response will return a list of available topics in JSON format. Example:
107
+ [
108
+ {
109
+ "topic_id": 1,
110
+ "topic_name": "Bitcoin 8h",
111
+ "description": "Bitcoin price prediction for the next 8 hours",
112
+ "epoch_length": 100,
113
+ "ground_truth_lag": 10,
114
+ "loss_method": "method1",
115
+ "worker_submission_window": 50,
116
+ "worker_count": 5,
117
+ "reputer_count": 3,
118
+ "total_staked_allo": 1000,
119
+ "total_emissions_allo": 500,
120
+ "is_active": true,
121
+ "updated_at": "2023-01-01T00:00:00Z"
122
+ }
123
+ ]
124
+
125
+ Key fields:
126
+ - topic_id: Unique identifier, use with get_inference_by_topic_id action
127
+ - topic_name: Name of the topic
128
+ - description: Short description of the topic's purpose
129
+ - is_active: If true, topic is active and accepting submissions
130
+ - updated_at: Timestamp of last update
131
+
132
+ A failure response will return an error message with details.
133
+ `,
134
+ schema: schemas_1.GetAllTopicsSchema,
135
+ }),
136
+ __metadata("design:type", Function),
137
+ __metadata("design:paramtypes", [void 0]),
138
+ __metadata("design:returntype", Promise)
139
+ ], AlloraActionProvider.prototype, "getAllTopics", null);
140
+ __decorate([
141
+ (0, actionDecorator_1.CreateAction)({
142
+ name: "get_inference_by_topic_id",
143
+ description: `
144
+ This tool will get inference for a specific topic from Allora Network.
145
+ It requires a topic ID as input, which can be obtained from the get_all_topics action.
146
+
147
+ A successful response will return a message with the inference data in JSON format. Example:
148
+ {
149
+ "network_inference": "0.5",
150
+ "network_inference_normalized": "0.5",
151
+ "confidence_interval_percentiles": ["0.1", "0.5", "0.9"],
152
+ "confidence_interval_percentiles_normalized": ["0.1", "0.5", "0.9"],
153
+ "confidence_interval_values": ["0.1", "0.5", "0.9"],
154
+ "confidence_interval_values_normalized": ["0.1", "0.5", "0.9"],
155
+ "topic_id": "1",
156
+ "timestamp": 1718198400,
157
+ "extra_data": "extra_data"
158
+ }
159
+ The network_inference field is the inference for the topic.
160
+ The network_inference_normalized field is the normalized inference for the topic.
161
+
162
+ A failure response will return an error message with details.
163
+ `,
164
+ schema: schemas_1.GetInferenceByTopicIdSchema,
165
+ }),
166
+ __metadata("design:type", Function),
167
+ __metadata("design:paramtypes", [void 0]),
168
+ __metadata("design:returntype", Promise)
169
+ ], AlloraActionProvider.prototype, "getInferenceByTopicId", null);
170
+ __decorate([
171
+ (0, actionDecorator_1.CreateAction)({
172
+ name: "get_price_inference",
173
+ description: `
174
+ This tool will get price inference for a specific token and timeframe from Allora Network.
175
+ It requires an asset symbol (e.g., 'BTC', 'ETH') and a timeframe (e.g., '8h', '24h') as input.
176
+
177
+ A successful response will return a message with the price inference. Example:
178
+ The price inference for BTC (8h) is:
179
+ {
180
+ "price": "100000",
181
+ "timestamp": 1718198400,
182
+ "asset": "BTC",
183
+ "timeframe": "8h"
184
+ }
185
+
186
+ A failure response will return an error message with details.
187
+ `,
188
+ schema: schemas_1.GetPriceInferenceSchema,
189
+ }),
190
+ __metadata("design:type", Function),
191
+ __metadata("design:paramtypes", [void 0]),
192
+ __metadata("design:returntype", Promise)
193
+ ], AlloraActionProvider.prototype, "getPriceInference", null);
194
+ const alloraActionProvider = (config = {}) => new AlloraActionProvider(config);
195
+ exports.alloraActionProvider = alloraActionProvider;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const alloraActionProvider_1 = require("./alloraActionProvider");
4
+ const allora_sdk_1 = require("@alloralabs/allora-sdk");
5
+ jest.mock("@alloralabs/allora-sdk");
6
+ describe("AlloraActionProvider", () => {
7
+ let provider;
8
+ const mockConfig = { apiKey: "test-api-key", chainSlug: allora_sdk_1.ChainSlug.TESTNET };
9
+ beforeEach(() => {
10
+ jest.clearAllMocks();
11
+ provider = new alloraActionProvider_1.AlloraActionProvider(mockConfig);
12
+ });
13
+ describe("getAllTopics", () => {
14
+ it("should return topics when successful", async () => {
15
+ const mockTopics = [
16
+ {
17
+ topic_id: 1,
18
+ topic_name: "Bitcoin 8h",
19
+ description: "Bitcoin price prediction",
20
+ epoch_length: 100,
21
+ ground_truth_lag: 10,
22
+ loss_method: "method1",
23
+ worker_submission_window: 50,
24
+ worker_count: 5,
25
+ reputer_count: 3,
26
+ total_staked_allo: 1000,
27
+ total_emissions_allo: 500,
28
+ is_active: true,
29
+ updated_at: "2023-01-01T00:00:00Z",
30
+ },
31
+ ];
32
+ allora_sdk_1.AlloraAPIClient.prototype.getAllTopics.mockResolvedValue(mockTopics);
33
+ const result = await provider.getAllTopics({});
34
+ expect(result).toContain("The available topics at Allora Network are:");
35
+ expect(result).toContain(JSON.stringify(mockTopics));
36
+ });
37
+ it("should handle errors", async () => {
38
+ const error = new Error("API Error");
39
+ allora_sdk_1.AlloraAPIClient.prototype.getAllTopics.mockRejectedValue(error);
40
+ const result = await provider.getAllTopics({});
41
+ expect(result).toContain("Error getting all topics:");
42
+ expect(result).toContain(error.toString());
43
+ });
44
+ });
45
+ describe("getInferenceByTopicId", () => {
46
+ const mockTopicId = 1;
47
+ it("should return inference when successful", async () => {
48
+ const mockInferenceResponse = {
49
+ inference_data: {
50
+ network_inference: "0.5",
51
+ network_inference_normalized: "0.5",
52
+ confidence_interval_percentiles: ["0.1", "0.5", "0.9"],
53
+ confidence_interval_percentiles_normalized: ["0.1", "0.5", "0.9"],
54
+ confidence_interval_values: ["0.1", "0.5", "0.9"],
55
+ confidence_interval_values_normalized: ["0.1", "0.5", "0.9"],
56
+ topic_id: "1",
57
+ timestamp: 1718198400,
58
+ extra_data: "extra_data",
59
+ },
60
+ };
61
+ allora_sdk_1.AlloraAPIClient.prototype.getInferenceByTopicID.mockResolvedValue(mockInferenceResponse);
62
+ const result = await provider.getInferenceByTopicId({ topicId: mockTopicId });
63
+ expect(result).toContain(`The inference for topic ${mockTopicId} is:`);
64
+ expect(result).toContain(JSON.stringify(mockInferenceResponse.inference_data));
65
+ });
66
+ it("should handle errors", async () => {
67
+ const error = new Error("API Error");
68
+ allora_sdk_1.AlloraAPIClient.prototype.getInferenceByTopicID.mockRejectedValue(error);
69
+ const result = await provider.getInferenceByTopicId({ topicId: mockTopicId });
70
+ expect(result).toContain(`Error getting inference for topic ${mockTopicId}:`);
71
+ expect(result).toContain(error.toString());
72
+ });
73
+ });
74
+ describe("getPriceInference", () => {
75
+ const mockAsset = allora_sdk_1.PriceInferenceToken.BTC;
76
+ const mockTimeframe = "8h";
77
+ it("should return price inference when successful", async () => {
78
+ const mockPriceInference = {
79
+ inference_data: {
80
+ network_inference_normalized: "50000.00",
81
+ timestamp: 1718198400,
82
+ },
83
+ };
84
+ allora_sdk_1.AlloraAPIClient.prototype.getPriceInference.mockResolvedValue(mockPriceInference);
85
+ const expectedResponse = {
86
+ price: "50000.00",
87
+ timestamp: 1718198400,
88
+ asset: mockAsset,
89
+ timeframe: mockTimeframe,
90
+ };
91
+ const result = await provider.getPriceInference({
92
+ asset: mockAsset,
93
+ timeframe: mockTimeframe,
94
+ });
95
+ expect(result).toContain(`The price inference for ${mockAsset} (${mockTimeframe}) is:`);
96
+ expect(result).toContain(JSON.stringify(expectedResponse));
97
+ });
98
+ it("should handle errors", async () => {
99
+ const error = new Error("API Error");
100
+ allora_sdk_1.AlloraAPIClient.prototype.getPriceInference.mockRejectedValue(error);
101
+ const result = await provider.getPriceInference({
102
+ asset: mockAsset,
103
+ timeframe: mockTimeframe,
104
+ });
105
+ expect(result).toContain(`Error getting price inference for ${mockAsset} (${mockTimeframe}):`);
106
+ expect(result).toContain(error.toString());
107
+ });
108
+ });
109
+ });
@@ -0,0 +1,2 @@
1
+ export * from "./alloraActionProvider";
2
+ export * from "./schemas";
@@ -0,0 +1,18 @@
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("./alloraActionProvider"), exports);
18
+ __exportStar(require("./schemas"), exports);
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Input schema for getting all topics from Allora Network
4
+ */
5
+ export declare const GetAllTopicsSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
6
+ /**
7
+ * Input schema for getting inference data by topic ID from Allora Network
8
+ */
9
+ export declare const GetInferenceByTopicIdSchema: z.ZodObject<{
10
+ topicId: z.ZodNumber;
11
+ }, "strip", z.ZodTypeAny, {
12
+ topicId: number;
13
+ }, {
14
+ topicId: number;
15
+ }>;
16
+ /**
17
+ * Input schema for getting price inference for a token/timeframe pair
18
+ */
19
+ export declare const GetPriceInferenceSchema: z.ZodObject<{
20
+ asset: z.ZodString;
21
+ timeframe: z.ZodString;
22
+ }, "strip", z.ZodTypeAny, {
23
+ asset: string;
24
+ timeframe: string;
25
+ }, {
26
+ asset: string;
27
+ timeframe: string;
28
+ }>;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetPriceInferenceSchema = exports.GetInferenceByTopicIdSchema = exports.GetAllTopicsSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Input schema for getting all topics from Allora Network
7
+ */
8
+ exports.GetAllTopicsSchema = zod_1.z
9
+ .object({})
10
+ .strip()
11
+ .describe("Instructions for getting all topics from Allora Network");
12
+ /**
13
+ * Input schema for getting inference data by topic ID from Allora Network
14
+ */
15
+ exports.GetInferenceByTopicIdSchema = zod_1.z
16
+ .object({
17
+ topicId: zod_1.z.number().describe("The ID of the topic to get inference data for"),
18
+ })
19
+ .strip()
20
+ .describe("Instructions for getting inference data from Allora Network by topic ID");
21
+ /**
22
+ * Input schema for getting price inference for a token/timeframe pair
23
+ */
24
+ exports.GetPriceInferenceSchema = zod_1.z
25
+ .object({
26
+ asset: zod_1.z.string().describe("The token to get price inference for (e.g., 'BTC', 'ETH')"),
27
+ timeframe: zod_1.z.string().describe("The timeframe for the prediction (e.g., '8h', '24h')"),
28
+ })
29
+ .strip()
30
+ .describe("Instructions for getting price inference for a token/timeframe pair");
@@ -3,10 +3,6 @@ export declare const ERC721_ABI: readonly [{
3
3
  readonly internalType: "address";
4
4
  readonly name: "to";
5
5
  readonly type: "address";
6
- }, {
7
- readonly internalType: "uint256";
8
- readonly name: "tokenId";
9
- readonly type: "uint256";
10
6
  }];
11
7
  readonly name: "mint";
12
8
  readonly outputs: readonly [];
@@ -3,10 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ERC721_ABI = void 0;
4
4
  exports.ERC721_ABI = [
5
5
  {
6
- inputs: [
7
- { internalType: "address", name: "to", type: "address" },
8
- { internalType: "uint256", name: "tokenId", type: "uint256" },
9
- ],
6
+ inputs: [{ internalType: "address", name: "to", type: "address" }],
10
7
  name: "mint",
11
8
  outputs: [],
12
9
  payable: false,
@@ -46,7 +46,7 @@ class Erc721ActionProvider extends actionProvider_1.ActionProvider {
46
46
  const data = (0, viem_1.encodeFunctionData)({
47
47
  abi: constants_1.ERC721_ABI,
48
48
  functionName: "mint",
49
- args: [args.destination, 1n],
49
+ args: [args.destination],
50
50
  });
51
51
  const hash = await walletProvider.sendTransaction({
52
52
  to: args.contractAddress,
@@ -34,7 +34,7 @@ describe("ERC721 Action Provider", () => {
34
34
  data: (0, viem_1.encodeFunctionData)({
35
35
  abi: constants_1.ERC721_ABI,
36
36
  functionName: "mint",
37
- args: [MOCK_DESTINATION, 1n],
37
+ args: [MOCK_DESTINATION],
38
38
  }),
39
39
  });
40
40
  expect(mockWallet.waitForTransactionReceipt).toHaveBeenCalledWith("0xmockhash");
@@ -12,8 +12,10 @@ export * from "./jupiter";
12
12
  export * from "./pyth";
13
13
  export * from "./moonwell";
14
14
  export * from "./morpho";
15
+ export * from "./opensea";
15
16
  export * from "./spl";
16
17
  export * from "./twitter";
17
18
  export * from "./wallet";
18
19
  export * from "./weth";
19
20
  export * from "./wow";
21
+ export * from "./allora";
@@ -28,8 +28,10 @@ __exportStar(require("./jupiter"), exports);
28
28
  __exportStar(require("./pyth"), exports);
29
29
  __exportStar(require("./moonwell"), exports);
30
30
  __exportStar(require("./morpho"), exports);
31
+ __exportStar(require("./opensea"), exports);
31
32
  __exportStar(require("./spl"), exports);
32
33
  __exportStar(require("./twitter"), exports);
33
34
  __exportStar(require("./wallet"), exports);
34
35
  __exportStar(require("./weth"), exports);
35
36
  __exportStar(require("./wow"), exports);
37
+ __exportStar(require("./allora"), exports);
@@ -0,0 +1 @@
1
+ export * from "./openseaActionProvider";
@@ -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("./openseaActionProvider"), exports);
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ import { ActionProvider } from "../actionProvider";
3
+ import { ListNftSchema, GetNftsByAccountSchema } from "./schemas";
4
+ import { Network } from "../../network";
5
+ import { EvmWalletProvider } from "../../wallet-providers";
6
+ /**
7
+ * Configuration options for the OpenseaActionProvider.
8
+ */
9
+ export interface OpenseaActionProviderConfig {
10
+ /**
11
+ * OpenSea API Key.
12
+ */
13
+ apiKey?: string;
14
+ /**
15
+ * The network ID to use for the OpenseaActionProvider.
16
+ */
17
+ networkId?: string;
18
+ /**
19
+ * The private key to use for the OpenseaActionProvider.
20
+ */
21
+ privateKey?: string;
22
+ }
23
+ /**
24
+ * OpenseaActionProvider is an action provider for OpenSea marketplace interactions.
25
+ */
26
+ export declare class OpenseaActionProvider extends ActionProvider<EvmWalletProvider> {
27
+ private readonly apiKey;
28
+ private walletWithProvider;
29
+ private openseaSDK;
30
+ private openseaBaseUrl;
31
+ /**
32
+ * Constructor for the OpenseaActionProvider class.
33
+ *
34
+ * @param config - The configuration options for the OpenseaActionProvider.
35
+ */
36
+ constructor(config?: OpenseaActionProviderConfig);
37
+ /**
38
+ * Lists an NFT for sale on OpenSea.
39
+ *
40
+ * @param args - The input arguments for the action.
41
+ * @returns A message containing the listing details.
42
+ */
43
+ listNft(args: z.infer<typeof ListNftSchema>): Promise<string>;
44
+ /**
45
+ * Fetch NFTs of a specific wallet address.
46
+ *
47
+ * @param args - The input arguments for the action.
48
+ * @returns A JSON string containing the NFTs or error message
49
+ */
50
+ getNftsByAccount(args: z.infer<typeof GetNftsByAccountSchema>): Promise<string>;
51
+ /**
52
+ * Checks if the Opensea action provider supports the given network.
53
+ *
54
+ * @param network - The network to check.
55
+ * @returns True if the Opensea action provider supports the network, false otherwise.
56
+ */
57
+ supportsNetwork: (network: Network) => boolean;
58
+ }
59
+ export declare const openseaActionProvider: (config?: OpenseaActionProviderConfig) => OpenseaActionProvider;
@@ -0,0 +1,146 @@
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.openseaActionProvider = exports.OpenseaActionProvider = void 0;
13
+ const zod_1 = require("zod");
14
+ const actionProvider_1 = require("../actionProvider");
15
+ const actionDecorator_1 = require("../actionDecorator");
16
+ const schemas_1 = require("./schemas");
17
+ const opensea_js_1 = require("opensea-js");
18
+ const network_1 = require("../../network");
19
+ const ethers_1 = require("ethers");
20
+ const utils_1 = require("./utils");
21
+ /**
22
+ * OpenseaActionProvider is an action provider for OpenSea marketplace interactions.
23
+ */
24
+ class OpenseaActionProvider extends actionProvider_1.ActionProvider {
25
+ /**
26
+ * Constructor for the OpenseaActionProvider class.
27
+ *
28
+ * @param config - The configuration options for the OpenseaActionProvider.
29
+ */
30
+ constructor(config = {}) {
31
+ super("opensea", []);
32
+ /**
33
+ * Checks if the Opensea action provider supports the given network.
34
+ *
35
+ * @param network - The network to check.
36
+ * @returns True if the Opensea action provider supports the network, false otherwise.
37
+ */
38
+ this.supportsNetwork = (network) => network.chainId !== undefined && utils_1.supportedChains[network.chainId] !== undefined;
39
+ const apiKey = config.apiKey || process.env.OPENSEA_API_KEY;
40
+ if (!apiKey) {
41
+ throw new Error("OPENSEA_API_KEY is not configured.");
42
+ }
43
+ this.apiKey = apiKey;
44
+ const chainId = network_1.NETWORK_ID_TO_CHAIN_ID[config.networkId || "base-sepolia"];
45
+ const provider = ethers_1.ethers.getDefaultProvider(parseInt(chainId));
46
+ const walletWithProvider = new ethers_1.Wallet(config.privateKey, provider);
47
+ this.walletWithProvider = walletWithProvider;
48
+ const openseaSDK = new opensea_js_1.OpenSeaSDK(walletWithProvider, {
49
+ chain: (0, utils_1.chainIdToOpenseaChain)(chainId),
50
+ apiKey: this.apiKey,
51
+ });
52
+ this.openseaSDK = openseaSDK;
53
+ this.openseaBaseUrl = this.openseaSDK.api.apiBaseUrl.replace("-api", "").replace("api", "");
54
+ }
55
+ /**
56
+ * Lists an NFT for sale on OpenSea.
57
+ *
58
+ * @param args - The input arguments for the action.
59
+ * @returns A message containing the listing details.
60
+ */
61
+ async listNft(args) {
62
+ try {
63
+ const expirationTime = Math.round(Date.now() / 1000 + args.expirationDays * 24 * 60 * 60);
64
+ await this.openseaSDK.createListing({
65
+ asset: {
66
+ tokenId: args.tokenId,
67
+ tokenAddress: args.contractAddress,
68
+ },
69
+ startAmount: args.price,
70
+ quantity: 1,
71
+ paymentTokenAddress: "0x0000000000000000000000000000000000000000", // ETH
72
+ expirationTime,
73
+ accountAddress: this.walletWithProvider.address,
74
+ });
75
+ const listingLink = `${this.openseaBaseUrl}/assets/${this.openseaSDK.chain}/${args.contractAddress}/${args.tokenId}`;
76
+ return `Successfully listed NFT ${args.contractAddress} token ${args.tokenId} for ${args.price} ETH, expiring in ${args.expirationDays} days. Listing on OpenSea: ${listingLink}.`;
77
+ }
78
+ catch (error) {
79
+ return `Error listing NFT ${args.contractAddress} token ${args.tokenId} for ${args.price} ETH using account ${this.walletWithProvider.address}: ${error}`;
80
+ }
81
+ }
82
+ /**
83
+ * Fetch NFTs of a specific wallet address.
84
+ *
85
+ * @param args - The input arguments for the action.
86
+ * @returns A JSON string containing the NFTs or error message
87
+ */
88
+ async getNftsByAccount(args) {
89
+ try {
90
+ const address = args.accountAddress || this.walletWithProvider.address;
91
+ const { nfts } = await this.openseaSDK.api.getNFTsByAccount(address);
92
+ return JSON.stringify(nfts);
93
+ }
94
+ catch (error) {
95
+ const address = args.accountAddress || this.walletWithProvider.address;
96
+ return `Error fetching NFTs for account ${address}: ${error}`;
97
+ }
98
+ }
99
+ }
100
+ exports.OpenseaActionProvider = OpenseaActionProvider;
101
+ __decorate([
102
+ (0, actionDecorator_1.CreateAction)({
103
+ name: "list_nft",
104
+ description: `
105
+ This tool will list an NFT for sale on the OpenSea marketplace.
106
+ EVM networks are supported on mainnet and testnets.
107
+
108
+ It takes the following inputs:
109
+ - contractAddress: The NFT contract address to list
110
+ - tokenId: The ID of the NFT to list
111
+ - price: The price in ETH for which the NFT will be listed
112
+ - expirationDays: (Optional) Number of days the listing should be active for (default: 90)
113
+
114
+ Important notes:
115
+ - The wallet must own the NFT
116
+ - Price is in ETH (e.g., 1.5 for 1.5 ETH). This is the amount the seller will receive if the NFT is sold. It is not required to have this amount in the wallet.
117
+ - Listing the NFT requires approval for OpenSea to manage the entire NFT collection:
118
+ - If the collection is not already approved, an onchain transaction is required, which will incur gas fees.
119
+ - If already approved, listing is gasless and does not require any onchain transaction.
120
+ - EVM networks are supported on mainnet and testnets, for example: base-mainnet and base-sepolia.
121
+ `,
122
+ schema: schemas_1.ListNftSchema,
123
+ }),
124
+ __metadata("design:type", Function),
125
+ __metadata("design:paramtypes", [void 0]),
126
+ __metadata("design:returntype", Promise)
127
+ ], OpenseaActionProvider.prototype, "listNft", null);
128
+ __decorate([
129
+ (0, actionDecorator_1.CreateAction)({
130
+ name: "get_nfts_by_account",
131
+ description: `
132
+ This tool will fetch NFTs owned by a specific wallet address on OpenSea.
133
+
134
+ It takes the following inputs:
135
+ - accountAddress: (Optional) The wallet address to fetch NFTs for. If not provided, uses the connected wallet address.
136
+
137
+ The tool will return a JSON string containing the NFTs owned by the specified address.
138
+ `,
139
+ schema: schemas_1.GetNftsByAccountSchema,
140
+ }),
141
+ __metadata("design:type", Function),
142
+ __metadata("design:paramtypes", [void 0]),
143
+ __metadata("design:returntype", Promise)
144
+ ], OpenseaActionProvider.prototype, "getNftsByAccount", null);
145
+ const openseaActionProvider = (config) => new OpenseaActionProvider(config);
146
+ exports.openseaActionProvider = openseaActionProvider;
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const opensea_js_1 = require("opensea-js");
4
+ const openseaActionProvider_1 = require("./openseaActionProvider");
5
+ jest.mock("opensea-js");
6
+ describe("OpenSea Action Provider", () => {
7
+ const MOCK_API_KEY = "test-api-key";
8
+ const MOCK_PRIVATE_KEY = "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
9
+ const MOCK_CONTRACT = "0x1234567890123456789012345678901234567890";
10
+ const MOCK_TOKEN_ID = "1";
11
+ const MOCK_PRICE = 0.1;
12
+ const MOCK_EXPIRATION_DAYS = 90;
13
+ const MOCK_OPENSEA_BASE_URL = "https://testnets.opensea.io";
14
+ const MOCK_OPENSEA_CHAIN = "base_sepolia";
15
+ let actionProvider;
16
+ beforeEach(() => {
17
+ jest.clearAllMocks();
18
+ // Mock OpenSeaSDK constructor
19
+ opensea_js_1.OpenSeaSDK.mockImplementation(() => ({
20
+ createListing: jest.fn(),
21
+ api: {
22
+ apiBaseUrl: MOCK_OPENSEA_BASE_URL,
23
+ getNFTsByAccount: jest.fn(),
24
+ },
25
+ chain: MOCK_OPENSEA_CHAIN,
26
+ }));
27
+ actionProvider = (0, openseaActionProvider_1.openseaActionProvider)({
28
+ apiKey: MOCK_API_KEY,
29
+ privateKey: MOCK_PRIVATE_KEY,
30
+ networkId: "base-sepolia",
31
+ });
32
+ });
33
+ describe("listNft", () => {
34
+ it("should successfully list an NFT", async () => {
35
+ const mockListing = {};
36
+ const mockCreateListing = jest.fn().mockResolvedValue(mockListing);
37
+ // Update the mock implementation with the mock function
38
+ opensea_js_1.OpenSeaSDK.mockImplementation(() => ({
39
+ createListing: mockCreateListing,
40
+ api: {
41
+ apiBaseUrl: MOCK_OPENSEA_BASE_URL,
42
+ },
43
+ chain: MOCK_OPENSEA_CHAIN,
44
+ }));
45
+ // Re-create provider with new mock
46
+ actionProvider = (0, openseaActionProvider_1.openseaActionProvider)({
47
+ apiKey: MOCK_API_KEY,
48
+ privateKey: MOCK_PRIVATE_KEY,
49
+ networkId: "base-sepolia",
50
+ });
51
+ const args = {
52
+ contractAddress: MOCK_CONTRACT,
53
+ tokenId: MOCK_TOKEN_ID,
54
+ price: MOCK_PRICE,
55
+ expirationDays: MOCK_EXPIRATION_DAYS,
56
+ };
57
+ const response = await actionProvider.listNft(args);
58
+ expect(mockCreateListing).toHaveBeenCalledWith(expect.objectContaining({
59
+ asset: {
60
+ tokenId: MOCK_TOKEN_ID,
61
+ tokenAddress: MOCK_CONTRACT,
62
+ },
63
+ startAmount: MOCK_PRICE,
64
+ quantity: 1,
65
+ }));
66
+ expect(response).toBe(`Successfully listed NFT ${MOCK_CONTRACT} token ${MOCK_TOKEN_ID} for ${MOCK_PRICE} ETH, expiring in ${MOCK_EXPIRATION_DAYS} days. Listing on OpenSea: ${MOCK_OPENSEA_BASE_URL}/assets/${MOCK_OPENSEA_CHAIN}/${MOCK_CONTRACT}/${MOCK_TOKEN_ID}.`);
67
+ });
68
+ it("should handle listing errors", async () => {
69
+ const error = new Error("Listing failed");
70
+ const mockCreateListing = jest.fn().mockRejectedValue(error);
71
+ // Update the mock implementation with the mock function
72
+ opensea_js_1.OpenSeaSDK.mockImplementation(() => ({
73
+ createListing: mockCreateListing,
74
+ api: {
75
+ apiBaseUrl: MOCK_OPENSEA_BASE_URL,
76
+ },
77
+ chain: MOCK_OPENSEA_CHAIN,
78
+ }));
79
+ // Re-create provider with new mock
80
+ actionProvider = (0, openseaActionProvider_1.openseaActionProvider)({
81
+ apiKey: MOCK_API_KEY,
82
+ privateKey: MOCK_PRIVATE_KEY,
83
+ networkId: "base-sepolia",
84
+ });
85
+ const args = {
86
+ contractAddress: MOCK_CONTRACT,
87
+ tokenId: MOCK_TOKEN_ID,
88
+ price: MOCK_PRICE,
89
+ expirationDays: MOCK_EXPIRATION_DAYS,
90
+ };
91
+ const response = await actionProvider.listNft(args);
92
+ expect(response).toContain(`Error listing NFT ${MOCK_CONTRACT} token ${MOCK_TOKEN_ID}`);
93
+ expect(response).toContain(error.message);
94
+ });
95
+ });
96
+ describe("getNftsByAccount", () => {
97
+ const MOCK_WALLET_ADDRESS = "0xabcdef1234567890abcdef1234567890abcdef12";
98
+ const MOCK_NFTS = [
99
+ {
100
+ identifier: "1",
101
+ contract: MOCK_CONTRACT,
102
+ name: "Test NFT 1",
103
+ },
104
+ {
105
+ identifier: "2",
106
+ contract: MOCK_CONTRACT,
107
+ name: "Test NFT 2",
108
+ },
109
+ ];
110
+ it("should successfully fetch NFTs for the specified account", async () => {
111
+ const mockGetNFTsByAccount = jest.fn().mockResolvedValue({ nfts: MOCK_NFTS });
112
+ // Update the mock implementation with the mock function
113
+ opensea_js_1.OpenSeaSDK.mockImplementation(() => ({
114
+ createListing: jest.fn(),
115
+ api: {
116
+ apiBaseUrl: MOCK_OPENSEA_BASE_URL,
117
+ getNFTsByAccount: mockGetNFTsByAccount,
118
+ },
119
+ chain: MOCK_OPENSEA_CHAIN,
120
+ }));
121
+ // Re-create provider with new mock
122
+ actionProvider = (0, openseaActionProvider_1.openseaActionProvider)({
123
+ apiKey: MOCK_API_KEY,
124
+ privateKey: MOCK_PRIVATE_KEY,
125
+ networkId: "base-sepolia",
126
+ });
127
+ const args = {
128
+ accountAddress: MOCK_WALLET_ADDRESS,
129
+ };
130
+ const response = await actionProvider.getNftsByAccount(args);
131
+ expect(mockGetNFTsByAccount).toHaveBeenCalledWith(MOCK_WALLET_ADDRESS);
132
+ expect(response).toBe(JSON.stringify(MOCK_NFTS));
133
+ });
134
+ it("should use connected wallet address when no account is specified", async () => {
135
+ const mockGetNFTsByAccount = jest.fn().mockResolvedValue({ nfts: MOCK_NFTS });
136
+ // Update the mock implementation with the mock function
137
+ opensea_js_1.OpenSeaSDK.mockImplementation(() => ({
138
+ createListing: jest.fn(),
139
+ api: {
140
+ apiBaseUrl: MOCK_OPENSEA_BASE_URL,
141
+ getNFTsByAccount: mockGetNFTsByAccount,
142
+ },
143
+ chain: MOCK_OPENSEA_CHAIN,
144
+ }));
145
+ // Re-create provider with new mock
146
+ actionProvider = (0, openseaActionProvider_1.openseaActionProvider)({
147
+ apiKey: MOCK_API_KEY,
148
+ privateKey: MOCK_PRIVATE_KEY,
149
+ networkId: "base-sepolia",
150
+ });
151
+ const args = {}; // No accountAddress provided
152
+ const response = await actionProvider.getNftsByAccount(args);
153
+ // Should use the wallet address from the provider
154
+ expect(mockGetNFTsByAccount).toHaveBeenCalled();
155
+ expect(response).toBe(JSON.stringify(MOCK_NFTS));
156
+ });
157
+ it("should handle errors when fetching NFTs", async () => {
158
+ const error = new Error("Failed to fetch NFTs");
159
+ const mockGetNFTsByAccount = jest.fn().mockRejectedValue(error);
160
+ // Update the mock implementation with the mock function
161
+ opensea_js_1.OpenSeaSDK.mockImplementation(() => ({
162
+ createListing: jest.fn(),
163
+ api: {
164
+ apiBaseUrl: MOCK_OPENSEA_BASE_URL,
165
+ getNFTsByAccount: mockGetNFTsByAccount,
166
+ },
167
+ chain: MOCK_OPENSEA_CHAIN,
168
+ }));
169
+ // Re-create provider with new mock
170
+ actionProvider = (0, openseaActionProvider_1.openseaActionProvider)({
171
+ apiKey: MOCK_API_KEY,
172
+ privateKey: MOCK_PRIVATE_KEY,
173
+ networkId: "base-sepolia",
174
+ });
175
+ const args = {
176
+ accountAddress: MOCK_WALLET_ADDRESS,
177
+ };
178
+ const response = await actionProvider.getNftsByAccount(args);
179
+ expect(mockGetNFTsByAccount).toHaveBeenCalledWith(MOCK_WALLET_ADDRESS);
180
+ expect(response).toContain(`Error fetching NFTs for account ${MOCK_WALLET_ADDRESS}`);
181
+ expect(response).toContain(error.message);
182
+ });
183
+ });
184
+ describe("supportsNetwork", () => {
185
+ it("should return true for supported networks", () => {
186
+ const baseSepoliaNetwork = {
187
+ protocolFamily: "evm",
188
+ networkId: "base-sepolia",
189
+ chainId: "84532",
190
+ };
191
+ expect(actionProvider.supportsNetwork(baseSepoliaNetwork)).toBe(true);
192
+ });
193
+ it("should return false for unsupported networks", () => {
194
+ const fantomNetwork = {
195
+ protocolFamily: "bitcoin",
196
+ networkId: "any",
197
+ };
198
+ expect(actionProvider.supportsNetwork(fantomNetwork)).toBe(false);
199
+ });
200
+ });
201
+ });
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Input schema for listing an NFT on OpenSea.
4
+ */
5
+ export declare const ListNftSchema: z.ZodObject<{
6
+ contractAddress: z.ZodString;
7
+ tokenId: z.ZodString;
8
+ price: z.ZodNumber;
9
+ expirationDays: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ contractAddress: string;
12
+ price: number;
13
+ tokenId: string;
14
+ expirationDays: number;
15
+ }, {
16
+ contractAddress: string;
17
+ price: number;
18
+ tokenId: string;
19
+ expirationDays?: number | undefined;
20
+ }>;
21
+ /**
22
+ * Input schema for getting NFTs from a specific wallet address.
23
+ */
24
+ export declare const GetNftsByAccountSchema: z.ZodObject<{
25
+ accountAddress: z.ZodOptional<z.ZodString>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ accountAddress?: string | undefined;
28
+ }, {
29
+ accountAddress?: string | undefined;
30
+ }>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetNftsByAccountSchema = exports.ListNftSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Input schema for listing an NFT on OpenSea.
7
+ */
8
+ exports.ListNftSchema = zod_1.z
9
+ .object({
10
+ contractAddress: zod_1.z.string().nonempty().describe("The NFT contract address to list"),
11
+ tokenId: zod_1.z.string().nonempty().describe("The tokenID of the NFT to list"),
12
+ price: zod_1.z.number().positive().describe("The price in ETH to list the NFT for"),
13
+ expirationDays: zod_1.z
14
+ .number()
15
+ .positive()
16
+ .optional()
17
+ .default(90)
18
+ .describe("Number of days the listing should be active for (default: 90)"),
19
+ })
20
+ .strip()
21
+ .describe("Input schema for listing an NFT on OpenSea");
22
+ /**
23
+ * Input schema for getting NFTs from a specific wallet address.
24
+ */
25
+ exports.GetNftsByAccountSchema = zod_1.z
26
+ .object({
27
+ accountAddress: zod_1.z
28
+ .string()
29
+ .optional()
30
+ .describe("The wallet address to fetch NFTs for (defaults to connected wallet if not provided)"),
31
+ })
32
+ .strip()
33
+ .describe("Input schema for fetching NFTs by account");
@@ -0,0 +1,12 @@
1
+ import { Chain } from "opensea-js";
2
+ /**
3
+ * Supported Opensea chains
4
+ */
5
+ export declare const supportedChains: Record<string, Chain>;
6
+ /**
7
+ * Maps EVM chain IDs to Opensea chain
8
+ *
9
+ * @param chainId - The EVM chain ID to map
10
+ * @returns The corresponding OpenSea Chain enum value
11
+ */
12
+ export declare const chainIdToOpenseaChain: (chainId: string) => Chain;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.chainIdToOpenseaChain = exports.supportedChains = void 0;
4
+ const opensea_js_1 = require("opensea-js");
5
+ /**
6
+ * Supported Opensea chains
7
+ */
8
+ exports.supportedChains = {
9
+ "1": opensea_js_1.Chain.Mainnet,
10
+ "137": opensea_js_1.Chain.Polygon,
11
+ "80002": opensea_js_1.Chain.Amoy,
12
+ "11155111": opensea_js_1.Chain.Sepolia,
13
+ "8217": opensea_js_1.Chain.Klaytn,
14
+ "1001": opensea_js_1.Chain.Baobab,
15
+ "43114": opensea_js_1.Chain.Avalanche,
16
+ "43113": opensea_js_1.Chain.Fuji,
17
+ "42161": opensea_js_1.Chain.Arbitrum,
18
+ "42170": opensea_js_1.Chain.ArbitrumNova,
19
+ "421614": opensea_js_1.Chain.ArbitrumSepolia,
20
+ "238": opensea_js_1.Chain.Blast,
21
+ "168587773": opensea_js_1.Chain.BlastSepolia,
22
+ "8453": opensea_js_1.Chain.Base,
23
+ "84532": opensea_js_1.Chain.BaseSepolia,
24
+ "10": opensea_js_1.Chain.Optimism,
25
+ "11155420": opensea_js_1.Chain.OptimismSepolia,
26
+ "7777777": opensea_js_1.Chain.Zora,
27
+ "999999999": opensea_js_1.Chain.ZoraSepolia,
28
+ "1329": opensea_js_1.Chain.Sei,
29
+ "1328": opensea_js_1.Chain.SeiTestnet,
30
+ "8333": opensea_js_1.Chain.B3,
31
+ "1993": opensea_js_1.Chain.B3Sepolia,
32
+ "80094": opensea_js_1.Chain.BeraChain,
33
+ };
34
+ /**
35
+ * Maps EVM chain IDs to Opensea chain
36
+ *
37
+ * @param chainId - The EVM chain ID to map
38
+ * @returns The corresponding OpenSea Chain enum value
39
+ */
40
+ const chainIdToOpenseaChain = (chainId) => {
41
+ const chain = exports.supportedChains[chainId];
42
+ if (!chain) {
43
+ throw new Error(`Unsupported chain ID on Opensea: ${chainId}`);
44
+ }
45
+ return chain;
46
+ };
47
+ exports.chainIdToOpenseaChain = chainIdToOpenseaChain;
@@ -227,5 +227,11 @@ export declare class CdpWalletProvider extends EvmWalletProvider {
227
227
  * @returns The wallet's data.
228
228
  */
229
229
  exportWallet(): Promise<WalletData>;
230
+ /**
231
+ * Gets the wallet.
232
+ *
233
+ * @returns The wallet.
234
+ */
235
+ getWallet(): Wallet;
230
236
  }
231
237
  export {};
@@ -381,6 +381,17 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
381
381
  }
382
382
  return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").export();
383
383
  }
384
+ /**
385
+ * Gets the wallet.
386
+ *
387
+ * @returns The wallet.
388
+ */
389
+ getWallet() {
390
+ if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
391
+ throw new Error("Wallet not initialized");
392
+ }
393
+ return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f");
394
+ }
384
395
  }
385
396
  exports.CdpWalletProvider = CdpWalletProvider;
386
397
  _CdpWalletProvider_cdpWallet = new WeakMap(), _CdpWalletProvider_address = new WeakMap(), _CdpWalletProvider_network = new WeakMap(), _CdpWalletProvider_publicClient = new WeakMap(), _CdpWalletProvider_gasLimitMultiplier = new WeakMap(), _CdpWalletProvider_feePerGasMultiplier = new WeakMap();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@coinbase/agentkit",
3
3
  "description": "Coinbase AgentKit core primitives",
4
4
  "repository": "https://github.com/coinbase/agentkit",
5
- "version": "0.2.3",
5
+ "version": "0.3.0",
6
6
  "author": "Coinbase Inc.",
7
7
  "license": "Apache-2.0",
8
8
  "main": "dist/index.js",
@@ -25,7 +25,8 @@
25
25
  "prepack": "tsc",
26
26
  "docs": "typedoc --entryPoints ./src --entryPointStrategy expand --exclude ./src/tests/**/*.ts",
27
27
  "docs:serve": "http-server ./docs",
28
- "dev": "tsc --watch"
28
+ "dev": "tsc --watch",
29
+ "generate:action-provider": "tsx ./scripts/generate-action-provider/main.ts"
29
30
  },
30
31
  "keywords": [
31
32
  "coinbase",
@@ -39,12 +40,14 @@
39
40
  "typescript"
40
41
  ],
41
42
  "dependencies": {
43
+ "@alloralabs/allora-sdk": "^0.1.0",
42
44
  "@coinbase/coinbase-sdk": "^0.20.0",
43
45
  "@jup-ag/api": "^6.0.39",
44
46
  "@privy-io/server-auth": "^1.18.4",
45
47
  "@solana/spl-token": "^0.4.12",
46
48
  "@solana/web3.js": "^1.98.0",
47
49
  "md5": "^2.3.0",
50
+ "opensea-js": "^7.1.18",
48
51
  "reflect-metadata": "^0.2.2",
49
52
  "twitter-api-v2": "^1.18.2",
50
53
  "viem": "^2.22.16",
@@ -52,12 +55,20 @@
52
55
  },
53
56
  "devDependencies": {
54
57
  "@types/jest": "^29.5.14",
58
+ "@types/nunjucks": "^3.2.6",
59
+ "@types/ora": "^3.2.0",
60
+ "@types/prompts": "^2.4.9",
55
61
  "@types/secp256k1": "^4.0.6",
56
62
  "http-server": "^14.1.1",
57
63
  "jest": "^29.7.0",
58
64
  "mock-fs": "^5.2.0",
65
+ "nunjucks": "^3.2.4",
66
+ "ora": "^7.0.1",
67
+ "picocolors": "^1.0.0",
68
+ "prompts": "^2.4.2",
59
69
  "ts-jest": "^29.2.5",
60
70
  "tsd": "^0.31.2",
71
+ "tsx": "^4.7.1",
61
72
  "typescript": "^5.7.2"
62
73
  },
63
74
  "exports": {