@coinbase/agentkit 0.9.0 → 0.10.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 (74) hide show
  1. package/README.md +137 -55
  2. package/dist/action-providers/cdp/cdpApiActionProvider.js +2 -0
  3. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +43 -0
  4. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +151 -0
  5. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.d.ts +1 -0
  6. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +242 -0
  7. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +42 -0
  8. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +132 -0
  9. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.d.ts +1 -0
  10. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +199 -0
  11. package/dist/action-providers/cdp/index.d.ts +3 -0
  12. package/dist/action-providers/cdp/index.js +3 -0
  13. package/dist/action-providers/cdp/schemas.d.ts +29 -0
  14. package/dist/action-providers/cdp/schemas.js +32 -1
  15. package/dist/action-providers/cdp/spendPermissionUtils.d.ts +24 -0
  16. package/dist/action-providers/cdp/spendPermissionUtils.js +66 -0
  17. package/dist/action-providers/farcaster/farcasterActionProvider.js +2 -0
  18. package/dist/action-providers/farcaster/farcasterActionProvider.test.js +55 -0
  19. package/dist/action-providers/farcaster/schemas.d.ts +13 -0
  20. package/dist/action-providers/farcaster/schemas.js +6 -0
  21. package/dist/action-providers/index.d.ts +3 -0
  22. package/dist/action-providers/index.js +3 -0
  23. package/dist/action-providers/truemarkets/constants.d.ts +179 -0
  24. package/dist/action-providers/truemarkets/constants.js +46 -0
  25. package/dist/action-providers/truemarkets/index.d.ts +1 -0
  26. package/dist/action-providers/truemarkets/index.js +17 -0
  27. package/dist/action-providers/truemarkets/schemas.d.ts +21 -0
  28. package/dist/action-providers/truemarkets/schemas.js +29 -0
  29. package/dist/action-providers/truemarkets/truemarketsActionProvider.d.ts +51 -0
  30. package/dist/action-providers/truemarkets/truemarketsActionProvider.js +469 -0
  31. package/dist/action-providers/truemarkets/truemarketsActionProvider.test.d.ts +1 -0
  32. package/dist/action-providers/truemarkets/truemarketsActionProvider.test.js +217 -0
  33. package/dist/action-providers/truemarkets/utils.d.ts +10 -0
  34. package/dist/action-providers/truemarkets/utils.js +9 -0
  35. package/dist/action-providers/twitter/schemas.d.ts +16 -0
  36. package/dist/action-providers/twitter/schemas.js +23 -1
  37. package/dist/action-providers/twitter/twitterActionProvider.d.ts +8 -1
  38. package/dist/action-providers/twitter/twitterActionProvider.js +56 -5
  39. package/dist/action-providers/twitter/twitterActionProvider.test.js +52 -2
  40. package/dist/action-providers/weth/constants.d.ts +9 -0
  41. package/dist/action-providers/weth/constants.js +12 -0
  42. package/dist/action-providers/weth/schemas.d.ts +7 -0
  43. package/dist/action-providers/weth/schemas.js +7 -1
  44. package/dist/action-providers/weth/wethActionProvider.d.ts +9 -1
  45. package/dist/action-providers/weth/wethActionProvider.js +50 -1
  46. package/dist/action-providers/weth/wethActionProvider.test.js +60 -0
  47. package/dist/action-providers/zerion/constants.d.ts +1 -0
  48. package/dist/action-providers/zerion/constants.js +4 -0
  49. package/dist/action-providers/zerion/index.d.ts +2 -0
  50. package/dist/action-providers/zerion/index.js +18 -0
  51. package/dist/action-providers/zerion/schemas.d.ts +11 -0
  52. package/dist/action-providers/zerion/schemas.js +15 -0
  53. package/dist/action-providers/zerion/types.d.ts +125 -0
  54. package/dist/action-providers/zerion/types.js +16 -0
  55. package/dist/action-providers/zerion/utils.d.ts +3 -0
  56. package/dist/action-providers/zerion/utils.js +45 -0
  57. package/dist/action-providers/zerion/zerionActionProvider.d.ts +57 -0
  58. package/dist/action-providers/zerion/zerionActionProvider.js +159 -0
  59. package/dist/action-providers/zerion/zerionActionProvider.test.d.ts +1 -0
  60. package/dist/action-providers/zerion/zerionActionProvider.test.js +213 -0
  61. package/dist/action-providers/zora/index.d.ts +3 -0
  62. package/dist/action-providers/zora/index.js +19 -0
  63. package/dist/action-providers/zora/schemas.d.ts +29 -0
  64. package/dist/action-providers/zora/schemas.js +31 -0
  65. package/dist/action-providers/zora/utils.d.ts +28 -0
  66. package/dist/action-providers/zora/utils.js +200 -0
  67. package/dist/action-providers/zora/zoraActionProvider.d.ts +36 -0
  68. package/dist/action-providers/zora/zoraActionProvider.js +151 -0
  69. package/dist/action-providers/zora/zoraActionProvider.test.d.ts +1 -0
  70. package/dist/action-providers/zora/zoraActionProvider.test.js +205 -0
  71. package/dist/wallet-providers/cdpShared.d.ts +4 -0
  72. package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +8 -1
  73. package/dist/wallet-providers/cdpSmartWalletProvider.js +23 -11
  74. package/package.json +3 -2
@@ -0,0 +1,151 @@
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
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
12
+ if (kind === "m") throw new TypeError("Private method is not writable");
13
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
14
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
15
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
16
+ };
17
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
18
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
19
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
20
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21
+ };
22
+ var _ZoraActionProvider_pinataJwt;
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.zoraActionProvider = exports.ZoraActionProvider = void 0;
25
+ const zod_1 = require("zod");
26
+ const actionProvider_1 = require("../actionProvider");
27
+ const evmWalletProvider_1 = require("../../wallet-providers/evmWalletProvider");
28
+ const schemas_1 = require("./schemas");
29
+ const actionDecorator_1 = require("../actionDecorator");
30
+ const viem_1 = require("viem");
31
+ const utils_1 = require("./utils");
32
+ const SUPPORTED_NETWORKS = ["base-mainnet", "base-sepolia"];
33
+ /**
34
+ * ZoraActionProvider provides actions for interacting with the Zora protocol.
35
+ */
36
+ class ZoraActionProvider extends actionProvider_1.ActionProvider {
37
+ /**
38
+ * Constructor for the ZoraActionProvider.
39
+ */
40
+ constructor() {
41
+ super("zora", []);
42
+ _ZoraActionProvider_pinataJwt.set(this, void 0);
43
+ /**
44
+ * Checks if the Zora action provider supports the given network.
45
+ *
46
+ * @param network - The network to check.
47
+ * @returns True if the Zora action provider supports the network, false otherwise.
48
+ */
49
+ this.supportsNetwork = (network) => network.protocolFamily === "evm" && SUPPORTED_NETWORKS.includes(network.networkId);
50
+ // Set Pinata JWT
51
+ const pinataJwt = process.env.PINATA_JWT;
52
+ if (!pinataJwt) {
53
+ throw new Error("PINATA_JWT is not configured. Required for IPFS uploads.");
54
+ }
55
+ __classPrivateFieldSet(this, _ZoraActionProvider_pinataJwt, pinataJwt, "f");
56
+ }
57
+ /**
58
+ * Creates a new Zora coin.
59
+ *
60
+ * @param walletProvider - The wallet provider to use for the transaction.
61
+ * @param args - The input arguments for the action.
62
+ * @returns A message containing the coin creation details.
63
+ */
64
+ async createCoin(walletProvider, args) {
65
+ try {
66
+ // Generate token URI from local file or URI
67
+ const { uri, imageUri } = await (0, utils_1.generateZoraTokenUri)({
68
+ name: args.name,
69
+ symbol: args.symbol,
70
+ description: args.description,
71
+ image: args.image,
72
+ category: args.category,
73
+ pinataConfig: { jwt: __classPrivateFieldGet(this, _ZoraActionProvider_pinataJwt, "f") },
74
+ });
75
+ // Dynamically import Zora SDK
76
+ const { createCoinCall, DeployCurrency, getCoinCreateFromLogs } = await import("@zoralabs/coins-sdk");
77
+ // Create coin call
78
+ const call = {
79
+ name: args.name,
80
+ symbol: args.symbol,
81
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
82
+ uri: uri,
83
+ payoutRecipient: args.payoutRecipient || walletProvider.getAddress(),
84
+ platformReferrer: args.platformReferrer || "0x0000000000000000000000000000000000000000",
85
+ currency: args.currency === "ZORA" ? DeployCurrency.ZORA : DeployCurrency.ETH,
86
+ };
87
+ const createCoinRequest = await createCoinCall(call);
88
+ const { abi, functionName, address, args: callArgs, value } = createCoinRequest;
89
+ const data = (0, viem_1.encodeFunctionData)({ abi, functionName, args: callArgs });
90
+ const txRequest = { to: address, data, value };
91
+ // Send transaction
92
+ const hash = await walletProvider.sendTransaction(txRequest);
93
+ const receipt = await walletProvider.waitForTransactionReceipt(hash);
94
+ const deployment = getCoinCreateFromLogs(receipt);
95
+ if (receipt.status === "success") {
96
+ return JSON.stringify({
97
+ success: true,
98
+ transactionHash: hash,
99
+ coinAddress: deployment?.coin,
100
+ imageUri,
101
+ uri,
102
+ deployment,
103
+ ...(walletProvider.getNetwork().networkId === "base-mainnet" &&
104
+ deployment?.coin && {
105
+ zoraURL: `https://zora.co/coin/base:${deployment.coin}`,
106
+ }),
107
+ });
108
+ }
109
+ else {
110
+ throw new Error("Coin creation transaction reverted");
111
+ }
112
+ }
113
+ catch (error) {
114
+ return JSON.stringify({
115
+ success: false,
116
+ error: error instanceof Error ? error.message : String(error),
117
+ });
118
+ }
119
+ }
120
+ }
121
+ exports.ZoraActionProvider = ZoraActionProvider;
122
+ _ZoraActionProvider_pinataJwt = new WeakMap();
123
+ __decorate([
124
+ (0, actionDecorator_1.CreateAction)({
125
+ name: "coinIt",
126
+ description: `
127
+ This tool will create a new Zora coin.
128
+ It takes the following parameters:
129
+ - name: The name of the coin
130
+ - symbol: The symbol of the coin
131
+ - image: Local image file path or URI (ipfs:// or https://)
132
+ - description: The description of the coin
133
+ - payoutRecipient: The address that will receive creator earnings (optional, defaults to the wallet address)
134
+ - platformReferrer: The address that will receive platform referrer fees (optional, defaults to 0x0000000000000000000000000000000000000000)
135
+ - category: The category of the coin (optional, defaults to 'social')
136
+ - currency: The currency for deployment, can be 'ZORA' or 'ETH'. Determines which token will be used for the trading pair (optional, defaults to 'ZORA').
137
+ The action will return the transaction hash, coin address, and deployment details upon success.
138
+ `,
139
+ schema: schemas_1.CreateCoinSchema,
140
+ }),
141
+ __metadata("design:type", Function),
142
+ __metadata("design:paramtypes", [evmWalletProvider_1.EvmWalletProvider, void 0]),
143
+ __metadata("design:returntype", Promise)
144
+ ], ZoraActionProvider.prototype, "createCoin", null);
145
+ /**
146
+ * Factory function to create a new ZoraActionProvider instance.
147
+ *
148
+ * @returns A new ZoraActionProvider instance
149
+ */
150
+ const zoraActionProvider = () => new ZoraActionProvider();
151
+ exports.zoraActionProvider = zoraActionProvider;
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const zoraActionProvider_1 = require("./zoraActionProvider");
4
+ const schemas_1 = require("./schemas");
5
+ // Mock viem's encodeFunctionData function to prevent ABI errors
6
+ jest.mock("viem", () => {
7
+ const originalModule = jest.requireActual("viem");
8
+ return {
9
+ ...originalModule,
10
+ encodeFunctionData: jest.fn().mockReturnValue("0x1234"),
11
+ };
12
+ });
13
+ // Mock the dynamically imported Zora SDK
14
+ jest.mock("@zoralabs/coins-sdk", () => ({
15
+ createCoinCall: jest.fn().mockResolvedValue({
16
+ abi: [{ name: "createCoin" }], // Add a minimal abi to prevent "function not found" error
17
+ functionName: "createCoin",
18
+ address: "0x1234567890123456789012345678901234567890",
19
+ args: [],
20
+ value: BigInt(0),
21
+ }),
22
+ getCoinCreateFromLogs: jest.fn().mockReturnValue({
23
+ coin: "0x2345678901234567890123456789012345678901",
24
+ }),
25
+ DeployCurrency: {
26
+ ZORA: "ZORA",
27
+ ETH: "ETH",
28
+ },
29
+ }), { virtual: true });
30
+ // Mock the utils module
31
+ jest.mock("./utils", () => ({
32
+ generateZoraTokenUri: jest.fn().mockResolvedValue({
33
+ uri: "ipfs://testCID",
34
+ imageUri: "ipfs://testImageCID",
35
+ }),
36
+ }));
37
+ describe("ZoraActionProvider", () => {
38
+ const MOCK_TX_HASH = "0xabcdef1234567890";
39
+ const MOCK_ADDRESS = "0x9876543210987654321098765432109876543210";
40
+ let provider;
41
+ let mockWalletProvider;
42
+ let originalPinataJwt;
43
+ beforeEach(() => {
44
+ // Reset mocks between tests
45
+ jest.clearAllMocks();
46
+ originalPinataJwt = process.env.PINATA_JWT;
47
+ process.env.PINATA_JWT = "test-jwt";
48
+ // Create the provider
49
+ provider = new zoraActionProvider_1.ZoraActionProvider();
50
+ // Set up the mock wallet provider
51
+ mockWalletProvider = {
52
+ getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
53
+ getNetwork: jest.fn().mockReturnValue({
54
+ protocolFamily: "evm",
55
+ networkId: "base-sepolia",
56
+ }),
57
+ sendTransaction: jest.fn().mockResolvedValue(MOCK_TX_HASH),
58
+ waitForTransactionReceipt: jest.fn().mockResolvedValue({
59
+ status: "success",
60
+ logs: [],
61
+ }),
62
+ };
63
+ });
64
+ afterEach(() => {
65
+ process.env.PINATA_JWT = originalPinataJwt;
66
+ });
67
+ describe("constructor", () => {
68
+ it("should throw an error if Pinata JWT is not provided", () => {
69
+ delete process.env.PINATA_JWT;
70
+ expect(() => new zoraActionProvider_1.ZoraActionProvider()).toThrow("PINATA_JWT is not configured. Required for IPFS uploads.");
71
+ });
72
+ it("should create provider with Pinata JWT from environment", () => {
73
+ expect(new zoraActionProvider_1.ZoraActionProvider()).toBeInstanceOf(zoraActionProvider_1.ZoraActionProvider);
74
+ });
75
+ });
76
+ describe("supportsNetwork", () => {
77
+ const testCases = [
78
+ { network: { protocolFamily: "evm", networkId: "base-mainnet" }, expected: true },
79
+ { network: { protocolFamily: "evm", networkId: "base-sepolia" }, expected: true },
80
+ { network: { protocolFamily: "evm", networkId: "ethereum" }, expected: false },
81
+ { network: { protocolFamily: "solana", networkId: "base-mainnet" }, expected: false },
82
+ ];
83
+ testCases.forEach(({ network, expected }) => {
84
+ it(`should ${expected ? "support" : "not support"} ${network.protocolFamily}/${network.networkId}`, () => {
85
+ expect(provider.supportsNetwork(network)).toBe(expected);
86
+ });
87
+ });
88
+ });
89
+ describe("createCoin", () => {
90
+ it("should validate createCoin schema", () => {
91
+ const validInput = {
92
+ name: "Test Coin",
93
+ symbol: "TEST",
94
+ description: "A test coin",
95
+ image: "https://example.com/image.png",
96
+ category: "social",
97
+ currency: "ZORA",
98
+ };
99
+ const parseResult = schemas_1.CreateCoinSchema.safeParse(validInput);
100
+ expect(parseResult.success).toBe(true);
101
+ });
102
+ it("should reject invalid input", () => {
103
+ const invalidInput = {
104
+ name: "Test Coin",
105
+ symbol: "TEST",
106
+ description: "A test coin",
107
+ image: "https://example.com/image.png",
108
+ category: "social",
109
+ currency: "ZORA",
110
+ payoutRecipient: "invalid-address", // Should be 0x format
111
+ };
112
+ const parseResult = schemas_1.CreateCoinSchema.safeParse(invalidInput);
113
+ expect(parseResult.success).toBe(false);
114
+ });
115
+ it("should successfully create a coin", async () => {
116
+ const args = {
117
+ name: "Test Coin",
118
+ symbol: "TEST",
119
+ description: "A test coin",
120
+ image: "https://example.com/image.png",
121
+ category: "social",
122
+ currency: "ZORA",
123
+ };
124
+ const result = await provider.createCoin(mockWalletProvider, args);
125
+ const parsedResult = JSON.parse(result);
126
+ expect(mockWalletProvider.sendTransaction).toHaveBeenCalled();
127
+ expect(mockWalletProvider.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
128
+ expect(parsedResult.success).toBe(true);
129
+ expect(parsedResult.transactionHash).toBe(MOCK_TX_HASH);
130
+ expect(parsedResult.coinAddress).toBe("0x2345678901234567890123456789012345678901");
131
+ });
132
+ it("should include zoraURL for base-mainnet network", async () => {
133
+ // Mock wallet provider to return base-mainnet network
134
+ mockWalletProvider.getNetwork.mockReturnValue({
135
+ protocolFamily: "evm",
136
+ networkId: "base-mainnet",
137
+ });
138
+ const args = {
139
+ name: "Test Coin",
140
+ symbol: "TEST",
141
+ description: "A test coin",
142
+ image: "https://example.com/image.png",
143
+ category: "social",
144
+ currency: "ZORA",
145
+ };
146
+ const result = await provider.createCoin(mockWalletProvider, args);
147
+ const parsedResult = JSON.parse(result);
148
+ expect(parsedResult.success).toBe(true);
149
+ expect(parsedResult.coinAddress).toBe("0x2345678901234567890123456789012345678901");
150
+ expect(parsedResult.zoraURL).toBe("https://zora.co/coin/base:0x2345678901234567890123456789012345678901");
151
+ });
152
+ it("should not include zoraURL for non-base-mainnet networks", async () => {
153
+ // Keep the default base-sepolia network from beforeEach
154
+ const args = {
155
+ name: "Test Coin",
156
+ symbol: "TEST",
157
+ description: "A test coin",
158
+ image: "https://example.com/image.png",
159
+ category: "social",
160
+ currency: "ZORA",
161
+ };
162
+ const result = await provider.createCoin(mockWalletProvider, args);
163
+ const parsedResult = JSON.parse(result);
164
+ expect(parsedResult.success).toBe(true);
165
+ expect(parsedResult.coinAddress).toBe("0x2345678901234567890123456789012345678901");
166
+ expect(parsedResult.zoraURL).toBeUndefined();
167
+ });
168
+ it("should handle transaction failure", async () => {
169
+ const args = {
170
+ name: "Test Coin",
171
+ symbol: "TEST",
172
+ description: "A test coin",
173
+ image: "https://example.com/image.png",
174
+ category: "social",
175
+ currency: "ZORA",
176
+ };
177
+ // Mock a reverted transaction
178
+ mockWalletProvider.waitForTransactionReceipt.mockResolvedValueOnce({
179
+ status: "reverted",
180
+ logs: [],
181
+ });
182
+ const result = await provider.createCoin(mockWalletProvider, args);
183
+ const parsedResult = JSON.parse(result);
184
+ expect(parsedResult.success).toBe(false);
185
+ expect(parsedResult.error).toBe("Coin creation transaction reverted");
186
+ });
187
+ it("should handle errors", async () => {
188
+ const args = {
189
+ name: "Test Coin",
190
+ symbol: "TEST",
191
+ description: "A test coin",
192
+ image: "https://example.com/image.png",
193
+ category: "social",
194
+ currency: "ZORA",
195
+ };
196
+ // Create an error that will be thrown during the request
197
+ const error = new Error("Failed to create coin");
198
+ mockWalletProvider.sendTransaction.mockRejectedValueOnce(error);
199
+ const result = await provider.createCoin(mockWalletProvider, args);
200
+ const parsedResult = JSON.parse(result);
201
+ expect(parsedResult.success).toBe(false);
202
+ expect(parsedResult.error).toBe("Failed to create coin");
203
+ });
204
+ });
205
+ });
@@ -40,6 +40,10 @@ export interface CdpSmartWalletProviderConfig extends CdpWalletProviderConfig {
40
40
  * The name of the smart wallet.
41
41
  */
42
42
  smartAccountName?: string;
43
+ /**
44
+ * The paymaster URL for gasless transactions.
45
+ */
46
+ paymasterUrl?: string;
43
47
  }
44
48
  /**
45
49
  * A wallet provider that can be used to interact with the CDP.
@@ -1,4 +1,4 @@
1
- import { CdpClient } from "@coinbase/cdp-sdk";
1
+ import { CdpClient, EvmSmartAccount } from "@coinbase/cdp-sdk";
2
2
  import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionRequest } from "viem";
3
3
  import { Network } from "../network";
4
4
  import { EvmWalletProvider } from "./evmWalletProvider";
@@ -8,6 +8,7 @@ import { WalletProviderWithClient, CdpSmartWalletProviderConfig } from "./cdpSha
8
8
  */
9
9
  export declare class CdpSmartWalletProvider extends EvmWalletProvider implements WalletProviderWithClient {
10
10
  #private;
11
+ smartAccount: EvmSmartAccount;
11
12
  /**
12
13
  * Constructs a new CdpSmartWalletProvider.
13
14
  *
@@ -84,6 +85,12 @@ export declare class CdpSmartWalletProvider extends EvmWalletProvider implements
84
85
  * @returns The CDP client.
85
86
  */
86
87
  getClient(): CdpClient;
88
+ /**
89
+ * Gets the paymaster URL for gasless transactions.
90
+ *
91
+ * @returns The paymaster URL if configured, undefined otherwise.
92
+ */
93
+ getPaymasterUrl(): string | undefined;
87
94
  /**
88
95
  * Gets the balance of the smart wallet.
89
96
  *
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _CdpSmartWalletProvider_instances, _CdpSmartWalletProvider_publicClient, _CdpSmartWalletProvider_smartAccount, _CdpSmartWalletProvider_ownerAccount, _CdpSmartWalletProvider_cdp, _CdpSmartWalletProvider_network, _CdpSmartWalletProvider_getCdpSdkNetwork;
13
+ var _CdpSmartWalletProvider_instances, _CdpSmartWalletProvider_publicClient, _CdpSmartWalletProvider_ownerAccount, _CdpSmartWalletProvider_cdp, _CdpSmartWalletProvider_network, _CdpSmartWalletProvider_paymasterUrl, _CdpSmartWalletProvider_getCdpSdkNetwork;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CdpSmartWalletProvider = void 0;
16
16
  const cdp_sdk_1 = require("@coinbase/cdp-sdk");
@@ -30,15 +30,16 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
30
30
  super();
31
31
  _CdpSmartWalletProvider_instances.add(this);
32
32
  _CdpSmartWalletProvider_publicClient.set(this, void 0);
33
- _CdpSmartWalletProvider_smartAccount.set(this, void 0);
34
33
  _CdpSmartWalletProvider_ownerAccount.set(this, void 0);
35
34
  _CdpSmartWalletProvider_cdp.set(this, void 0);
36
35
  _CdpSmartWalletProvider_network.set(this, void 0);
37
- __classPrivateFieldSet(this, _CdpSmartWalletProvider_smartAccount, config.smartAccount, "f");
36
+ _CdpSmartWalletProvider_paymasterUrl.set(this, void 0);
37
+ this.smartAccount = config.smartAccount;
38
38
  __classPrivateFieldSet(this, _CdpSmartWalletProvider_ownerAccount, config.ownerAccount, "f");
39
39
  __classPrivateFieldSet(this, _CdpSmartWalletProvider_cdp, config.cdp, "f");
40
40
  __classPrivateFieldSet(this, _CdpSmartWalletProvider_publicClient, config.publicClient, "f");
41
41
  __classPrivateFieldSet(this, _CdpSmartWalletProvider_network, config.network, "f");
42
+ __classPrivateFieldSet(this, _CdpSmartWalletProvider_paymasterUrl, config.paymasterUrl, "f");
42
43
  }
43
44
  /**
44
45
  * Configures a new CdpSmartWalletProvider with a smart wallet.
@@ -52,6 +53,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
52
53
  const apiKeySecret = config.apiKeySecret || process.env.CDP_API_KEY_SECRET;
53
54
  const walletSecret = config.walletSecret || process.env.CDP_WALLET_SECRET;
54
55
  const idempotencyKey = config.idempotencyKey || process.env.IDEMPOTENCY_KEY;
56
+ const paymasterUrl = config.paymasterUrl || process.env.PAYMASTER_URL;
55
57
  if (!apiKeyId || !apiKeySecret || !walletSecret) {
56
58
  throw new Error("Missing required environment variables. CDP_API_KEY_ID, CDP_API_KEY_SECRET, CDP_WALLET_SECRET are required.");
57
59
  }
@@ -100,6 +102,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
100
102
  smartAccount,
101
103
  ownerAccount,
102
104
  network,
105
+ paymasterUrl,
103
106
  });
104
107
  }
105
108
  /**
@@ -109,8 +112,8 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
109
112
  */
110
113
  async exportWallet() {
111
114
  return {
112
- name: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").name,
113
- address: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address,
115
+ name: this.smartAccount.name,
116
+ address: this.smartAccount.address,
114
117
  ownerAddress: __classPrivateFieldGet(this, _CdpSmartWalletProvider_ownerAccount, "f").address,
115
118
  };
116
119
  }
@@ -132,7 +135,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
132
135
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
136
  async signTypedData(typedData) {
134
137
  const { domain, types, primaryType, message } = typedData;
135
- return await __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").signTypedData({
138
+ return await this.smartAccount.signTypedData({
136
139
  domain,
137
140
  types,
138
141
  primaryType,
@@ -164,9 +167,10 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
164
167
  },
165
168
  ];
166
169
  const userOperation = await __classPrivateFieldGet(this, _CdpSmartWalletProvider_cdp, "f").evm.sendUserOperation({
167
- smartAccount: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f"),
170
+ smartAccount: this.smartAccount,
168
171
  network: __classPrivateFieldGet(this, _CdpSmartWalletProvider_instances, "m", _CdpSmartWalletProvider_getCdpSdkNetwork).call(this),
169
172
  calls,
173
+ paymasterUrl: __classPrivateFieldGet(this, _CdpSmartWalletProvider_paymasterUrl, "f"),
170
174
  });
171
175
  return userOperation.userOpHash;
172
176
  }
@@ -176,7 +180,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
176
180
  * @returns The address of the smart wallet.
177
181
  */
178
182
  getAddress() {
179
- return __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address;
183
+ return this.smartAccount.address;
180
184
  }
181
185
  /**
182
186
  * Gets the network of the wallet.
@@ -202,13 +206,21 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
202
206
  getClient() {
203
207
  return __classPrivateFieldGet(this, _CdpSmartWalletProvider_cdp, "f");
204
208
  }
209
+ /**
210
+ * Gets the paymaster URL for gasless transactions.
211
+ *
212
+ * @returns The paymaster URL if configured, undefined otherwise.
213
+ */
214
+ getPaymasterUrl() {
215
+ return __classPrivateFieldGet(this, _CdpSmartWalletProvider_paymasterUrl, "f");
216
+ }
205
217
  /**
206
218
  * Gets the balance of the smart wallet.
207
219
  *
208
220
  * @returns The balance of the wallet in wei
209
221
  */
210
222
  async getBalance() {
211
- return await __classPrivateFieldGet(this, _CdpSmartWalletProvider_publicClient, "f").getBalance({ address: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address });
223
+ return await __classPrivateFieldGet(this, _CdpSmartWalletProvider_publicClient, "f").getBalance({ address: this.smartAccount.address });
212
224
  }
213
225
  /**
214
226
  * Waits for a user operation receipt.
@@ -222,7 +234,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
222
234
  // This is a simplified implementation - in practice you might want to poll
223
235
  // the CDP API for user operation status
224
236
  return __classPrivateFieldGet(this, _CdpSmartWalletProvider_cdp, "f").evm.waitForUserOperation({
225
- smartAccountAddress: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address,
237
+ smartAccountAddress: this.smartAccount.address,
226
238
  userOpHash,
227
239
  });
228
240
  }
@@ -251,7 +263,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
251
263
  }
252
264
  }
253
265
  exports.CdpSmartWalletProvider = CdpSmartWalletProvider;
254
- _CdpSmartWalletProvider_publicClient = new WeakMap(), _CdpSmartWalletProvider_smartAccount = new WeakMap(), _CdpSmartWalletProvider_ownerAccount = new WeakMap(), _CdpSmartWalletProvider_cdp = new WeakMap(), _CdpSmartWalletProvider_network = new WeakMap(), _CdpSmartWalletProvider_instances = new WeakSet(), _CdpSmartWalletProvider_getCdpSdkNetwork = function _CdpSmartWalletProvider_getCdpSdkNetwork() {
266
+ _CdpSmartWalletProvider_publicClient = new WeakMap(), _CdpSmartWalletProvider_ownerAccount = new WeakMap(), _CdpSmartWalletProvider_cdp = new WeakMap(), _CdpSmartWalletProvider_network = new WeakMap(), _CdpSmartWalletProvider_paymasterUrl = new WeakMap(), _CdpSmartWalletProvider_instances = new WeakSet(), _CdpSmartWalletProvider_getCdpSdkNetwork = function _CdpSmartWalletProvider_getCdpSdkNetwork() {
255
267
  switch (__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId) {
256
268
  case "base-sepolia":
257
269
  return "base-sepolia";
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.9.0",
5
+ "version": "0.10.0",
6
6
  "author": "Coinbase Inc.",
7
7
  "license": "Apache-2.0",
8
8
  "main": "dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@across-protocol/app-sdk": "^0.2.0",
26
26
  "@alloralabs/allora-sdk": "^0.1.0",
27
- "@coinbase/cdp-sdk": "^1.26.0",
27
+ "@coinbase/cdp-sdk": "^1.34.0",
28
28
  "@coinbase/coinbase-sdk": "^0.20.0",
29
29
  "@jup-ag/api": "^6.0.39",
30
30
  "@privy-io/public-api": "2.18.5",
@@ -34,6 +34,7 @@
34
34
  "@zerodev/ecdsa-validator": "^5.4.5",
35
35
  "@zerodev/intent": "^0.0.24",
36
36
  "@zerodev/sdk": "^5.4.28",
37
+ "@zoralabs/coins-sdk": "^0.2.8",
37
38
  "axios": "^1.9.0",
38
39
  "bs58": "^4.0.1",
39
40
  "canonicalize": "^2.1.0",