@coinbase/agentkit 0.2.3 → 0.4.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 (46) hide show
  1. package/README.md +30 -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/defillama/constants.d.ts +8 -0
  11. package/dist/action-providers/defillama/constants.js +11 -0
  12. package/dist/action-providers/defillama/defillamaActionProvider.d.ts +54 -0
  13. package/dist/action-providers/defillama/defillamaActionProvider.js +180 -0
  14. package/dist/action-providers/defillama/defillamaActionProvider.test.d.ts +1 -0
  15. package/dist/action-providers/defillama/defillamaActionProvider.test.js +114 -0
  16. package/dist/action-providers/defillama/index.d.ts +1 -0
  17. package/dist/action-providers/defillama/index.js +17 -0
  18. package/dist/action-providers/defillama/schemas.d.ts +34 -0
  19. package/dist/action-providers/defillama/schemas.js +34 -0
  20. package/dist/action-providers/defillama/types.d.ts +73 -0
  21. package/dist/action-providers/defillama/types.js +2 -0
  22. package/dist/action-providers/defillama/utils.d.ts +10 -0
  23. package/dist/action-providers/defillama/utils.js +87 -0
  24. package/dist/action-providers/defillama/utils.test.d.ts +1 -0
  25. package/dist/action-providers/defillama/utils.test.js +124 -0
  26. package/dist/action-providers/erc721/constants.d.ts +0 -4
  27. package/dist/action-providers/erc721/constants.js +1 -4
  28. package/dist/action-providers/erc721/erc721ActionProvider.js +1 -1
  29. package/dist/action-providers/erc721/erc721ActionProvider.test.js +1 -1
  30. package/dist/action-providers/index.d.ts +3 -0
  31. package/dist/action-providers/index.js +3 -0
  32. package/dist/action-providers/morpho/morphoActionProvider.js +11 -4
  33. package/dist/action-providers/morpho/morphoActionProvider.test.js +2 -0
  34. package/dist/action-providers/opensea/index.d.ts +1 -0
  35. package/dist/action-providers/opensea/index.js +17 -0
  36. package/dist/action-providers/opensea/openseaActionProvider.d.ts +59 -0
  37. package/dist/action-providers/opensea/openseaActionProvider.js +146 -0
  38. package/dist/action-providers/opensea/openseaActionProvider.test.d.ts +1 -0
  39. package/dist/action-providers/opensea/openseaActionProvider.test.js +201 -0
  40. package/dist/action-providers/opensea/schemas.d.ts +30 -0
  41. package/dist/action-providers/opensea/schemas.js +33 -0
  42. package/dist/action-providers/opensea/utils.d.ts +12 -0
  43. package/dist/action-providers/opensea/utils.js +47 -0
  44. package/dist/wallet-providers/cdpWalletProvider.d.ts +6 -0
  45. package/dist/wallet-providers/cdpWalletProvider.js +11 -0
  46. package/package.json +13 -2
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("./utils");
4
+ describe("DefiLlama Utilities", () => {
5
+ describe("pruneGetProtocolResponse", () => {
6
+ it("should handle null input", () => {
7
+ expect((0, utils_1.pruneGetProtocolResponse)(null)).toBeNull();
8
+ });
9
+ it("should not modify objects without time-series data", () => {
10
+ const input = {
11
+ id: "test-protocol",
12
+ name: "Protocol",
13
+ symbol: "ABC",
14
+ };
15
+ const result = (0, utils_1.pruneGetProtocolResponse)(input);
16
+ expect(result).not.toBeNull();
17
+ expect(result).toEqual(input);
18
+ });
19
+ it("should prune time-series arrays", () => {
20
+ const timeSeriesData = Array.from({ length: 20 }, (_, i) => ({
21
+ date: Date.now() - i * 86400000,
22
+ totalLiquidityUSD: 1000 + i,
23
+ }));
24
+ const input = {
25
+ id: "test-protocol",
26
+ name: "Protocol",
27
+ tvl: [...timeSeriesData],
28
+ };
29
+ const result = (0, utils_1.pruneGetProtocolResponse)(input, 5);
30
+ expect(result).not.toBeNull();
31
+ if (result) {
32
+ expect(result.name).toBe("Protocol");
33
+ expect(result.tvl).toHaveLength(5);
34
+ const resultDates = result.tvl.map(entry => entry.date);
35
+ const sortedDates = [...resultDates].sort((a, b) => b - a);
36
+ expect(resultDates).toEqual(sortedDates);
37
+ }
38
+ });
39
+ it("should prune nested time-series arrays in chainTvls", () => {
40
+ const timeSeriesData = Array.from({ length: 20 }, (_, i) => ({
41
+ date: Date.now() - i * 86400000,
42
+ totalLiquidityUSD: 1000 + i,
43
+ }));
44
+ const tokenTimeSeriesData = Array.from({ length: 20 }, (_, i) => ({
45
+ date: Date.now() - i * 86400000,
46
+ tokens: { ETH: 1000 + i },
47
+ }));
48
+ const input = {
49
+ id: "test-protocol",
50
+ name: "Protocol",
51
+ chainTvls: {
52
+ Ethereum: {
53
+ tvl: [...timeSeriesData],
54
+ tokens: [...tokenTimeSeriesData],
55
+ },
56
+ Polygon: {
57
+ tvl: [...timeSeriesData],
58
+ tokensInUsd: [...tokenTimeSeriesData],
59
+ },
60
+ },
61
+ };
62
+ const result = (0, utils_1.pruneGetProtocolResponse)(input, 3);
63
+ expect(result).not.toBeNull();
64
+ if (result) {
65
+ expect(result.name).toBe("Protocol");
66
+ expect(result.chainTvls).toBeDefined();
67
+ if (result.chainTvls) {
68
+ expect(result.chainTvls.Ethereum.tvl).toHaveLength(3);
69
+ expect(result.chainTvls.Ethereum.tokens).toHaveLength(3);
70
+ expect(result.chainTvls.Polygon.tvl).toHaveLength(3);
71
+ expect(result.chainTvls.Polygon.tokensInUsd).toHaveLength(3);
72
+ const ethereumTvlDates = result.chainTvls.Ethereum.tvl.map(entry => entry.date);
73
+ const sortedDates = [...ethereumTvlDates].sort((a, b) => b - a);
74
+ expect(ethereumTvlDates).toEqual(sortedDates);
75
+ }
76
+ }
77
+ });
78
+ it("should respect the maxEntries parameter", () => {
79
+ const timeSeriesData = Array.from({ length: 50 }, (_, i) => ({
80
+ date: Date.now() - i * 86400000,
81
+ totalLiquidityUSD: 1000 + i,
82
+ }));
83
+ const tokenTimeSeriesData = Array.from({ length: 50 }, (_, i) => ({
84
+ date: Date.now() - i * 86400000,
85
+ tokens: { ETH: 1000 + i },
86
+ }));
87
+ const input = {
88
+ id: "test-protocol",
89
+ name: "Protocol",
90
+ tvl: [...timeSeriesData],
91
+ tokens: [...tokenTimeSeriesData],
92
+ };
93
+ const result1 = (0, utils_1.pruneGetProtocolResponse)(input, 1);
94
+ expect(result1).not.toBeNull();
95
+ if (result1) {
96
+ expect(result1.tvl).toHaveLength(1);
97
+ expect(result1.tokens).toHaveLength(1);
98
+ }
99
+ const result10 = (0, utils_1.pruneGetProtocolResponse)(input, 10);
100
+ expect(result10).not.toBeNull();
101
+ if (result10) {
102
+ expect(result10.tvl).toHaveLength(10);
103
+ expect(result10.tokens).toHaveLength(10);
104
+ }
105
+ });
106
+ it("should handle arrays without date property", () => {
107
+ const nonDateArray = Array.from({ length: 20 }, (_, i) => ({
108
+ value: 1000 + i,
109
+ name: `Item ${i}`,
110
+ }));
111
+ // Using a type assertion for this test case as it's testing a specific behavior
112
+ const input = {
113
+ id: "test-protocol",
114
+ name: "Protocol",
115
+ tvl: [...nonDateArray],
116
+ };
117
+ const result = (0, utils_1.pruneGetProtocolResponse)(input, 5);
118
+ expect(result).not.toBeNull();
119
+ if (result) {
120
+ expect(result.tvl).toHaveLength(5);
121
+ }
122
+ });
123
+ });
124
+ });
@@ -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");
@@ -5,6 +5,7 @@ export * from "./alchemy";
5
5
  export * from "./basename";
6
6
  export * from "./cdp";
7
7
  export * from "./compound";
8
+ export * from "./defillama";
8
9
  export * from "./erc20";
9
10
  export * from "./erc721";
10
11
  export * from "./farcaster";
@@ -12,8 +13,10 @@ export * from "./jupiter";
12
13
  export * from "./pyth";
13
14
  export * from "./moonwell";
14
15
  export * from "./morpho";
16
+ export * from "./opensea";
15
17
  export * from "./spl";
16
18
  export * from "./twitter";
17
19
  export * from "./wallet";
18
20
  export * from "./weth";
19
21
  export * from "./wow";
22
+ export * from "./allora";
@@ -21,6 +21,7 @@ __exportStar(require("./alchemy"), exports);
21
21
  __exportStar(require("./basename"), exports);
22
22
  __exportStar(require("./cdp"), exports);
23
23
  __exportStar(require("./compound"), exports);
24
+ __exportStar(require("./defillama"), exports);
24
25
  __exportStar(require("./erc20"), exports);
25
26
  __exportStar(require("./erc721"), exports);
26
27
  __exportStar(require("./farcaster"), exports);
@@ -28,8 +29,10 @@ __exportStar(require("./jupiter"), exports);
28
29
  __exportStar(require("./pyth"), exports);
29
30
  __exportStar(require("./moonwell"), exports);
30
31
  __exportStar(require("./morpho"), exports);
32
+ __exportStar(require("./opensea"), exports);
31
33
  __exportStar(require("./spl"), exports);
32
34
  __exportStar(require("./twitter"), exports);
33
35
  __exportStar(require("./wallet"), exports);
34
36
  __exportStar(require("./weth"), exports);
35
37
  __exportStar(require("./wow"), exports);
38
+ __exportStar(require("./allora"), exports);
@@ -13,11 +13,12 @@ exports.morphoActionProvider = exports.MorphoActionProvider = exports.SUPPORTED_
13
13
  const zod_1 = require("zod");
14
14
  const decimal_js_1 = require("decimal.js");
15
15
  const viem_1 = require("viem");
16
+ const constants_1 = require("../erc20/constants");
16
17
  const actionProvider_1 = require("../actionProvider");
17
18
  const wallet_providers_1 = require("../../wallet-providers");
18
19
  const actionDecorator_1 = require("../actionDecorator");
19
20
  const utils_1 = require("../../utils");
20
- const constants_1 = require("./constants");
21
+ const constants_2 = require("./constants");
21
22
  const schemas_1 = require("./schemas");
22
23
  exports.SUPPORTED_NETWORKS = ["base-mainnet", "base-sepolia"];
23
24
  /**
@@ -50,13 +51,19 @@ class MorphoActionProvider extends actionProvider_1.ActionProvider {
50
51
  return "Error: Assets amount must be greater than 0";
51
52
  }
52
53
  try {
53
- const atomicAssets = (0, viem_1.parseEther)(args.assets);
54
+ const decimals = await wallet.readContract({
55
+ address: args.tokenAddress,
56
+ abi: constants_1.abi,
57
+ functionName: "decimals",
58
+ args: [],
59
+ });
60
+ const atomicAssets = (0, viem_1.parseUnits)(args.assets, decimals);
54
61
  const approvalResult = await (0, utils_1.approve)(wallet, args.tokenAddress, args.vaultAddress, atomicAssets);
55
62
  if (approvalResult.startsWith("Error")) {
56
63
  return `Error approving Morpho Vault as spender: ${approvalResult}`;
57
64
  }
58
65
  const data = (0, viem_1.encodeFunctionData)({
59
- abi: constants_1.METAMORPHO_ABI,
66
+ abi: constants_2.METAMORPHO_ABI,
60
67
  functionName: "deposit",
61
68
  args: [atomicAssets, args.receiver],
62
69
  });
@@ -84,7 +91,7 @@ class MorphoActionProvider extends actionProvider_1.ActionProvider {
84
91
  }
85
92
  try {
86
93
  const data = (0, viem_1.encodeFunctionData)({
87
- abi: constants_1.METAMORPHO_ABI,
94
+ abi: constants_2.METAMORPHO_ABI,
88
95
  functionName: "withdraw",
89
96
  args: [BigInt(args.assets), args.receiver, args.receiver],
90
97
  });
@@ -11,6 +11,7 @@ const MOCK_RECEIVER_ID = "0x9876543210987654321098765432109876543210";
11
11
  const MOCK_TOKEN_ADDRESS = "0x4200000000000000000000000000000000000006";
12
12
  const MOCK_TX_HASH = "0xabcdef1234567890";
13
13
  const MOCK_RECEIPT = { status: 1, blockNumber: 1234567 };
14
+ const MOCK_DECIMALS = 18;
14
15
  jest.mock("../../utils");
15
16
  const mockApprove = utils_1.approve;
16
17
  describe("Morpho Action Provider", () => {
@@ -22,6 +23,7 @@ describe("Morpho Action Provider", () => {
22
23
  getNetwork: jest.fn().mockReturnValue({ protocolFamily: "evm", networkId: "1" }),
23
24
  sendTransaction: jest.fn().mockResolvedValue(MOCK_TX_HASH),
24
25
  waitForTransactionReceipt: jest.fn().mockResolvedValue(MOCK_RECEIPT),
26
+ readContract: jest.fn().mockResolvedValue(MOCK_DECIMALS),
25
27
  };
26
28
  mockApprove.mockResolvedValue("Approval successful");
27
29
  });
@@ -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;