@coinbase/agentkit 0.8.2 → 0.9.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 (65) hide show
  1. package/README.md +373 -234
  2. package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +15 -15
  3. package/dist/action-providers/cdp/cdpApiActionProvider.js +110 -63
  4. package/dist/action-providers/cdp/cdpApiActionProvider.test.js +205 -124
  5. package/dist/action-providers/cdp/index.d.ts +0 -1
  6. package/dist/action-providers/cdp/index.js +0 -1
  7. package/dist/action-providers/cdp/schemas.d.ts +9 -70
  8. package/dist/action-providers/cdp/schemas.js +12 -61
  9. package/dist/action-providers/cdp-legacy/index.d.ts +3 -0
  10. package/dist/action-providers/{cdp-v2 → cdp-legacy}/index.js +2 -1
  11. package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.d.ts +45 -0
  12. package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.js +130 -0
  13. package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.test.js +146 -0
  14. package/dist/action-providers/{cdp/cdpWalletActionProvider.d.ts → cdp-legacy/legacyCdpWalletActionProvider.d.ts} +8 -8
  15. package/dist/action-providers/{cdp/cdpWalletActionProvider.js → cdp-legacy/legacyCdpWalletActionProvider.js} +14 -14
  16. package/dist/action-providers/{cdp/cdpWalletActionProvider.test.js → cdp-legacy/legacyCdpWalletActionProvider.test.js} +3 -3
  17. package/dist/action-providers/cdp-legacy/schemas.d.ts +91 -0
  18. package/dist/action-providers/cdp-legacy/schemas.js +77 -0
  19. package/dist/action-providers/erc20/erc20ActionProvider.js +1 -1
  20. package/dist/action-providers/index.d.ts +1 -1
  21. package/dist/action-providers/index.js +1 -1
  22. package/dist/action-providers/jupiter/jupiterActionProvider.test.js +2 -4
  23. package/dist/action-providers/x402/schemas.d.ts +58 -11
  24. package/dist/action-providers/x402/schemas.js +60 -8
  25. package/dist/action-providers/x402/x402ActionProvider.d.ts +33 -16
  26. package/dist/action-providers/x402/x402ActionProvider.js +203 -153
  27. package/dist/action-providers/x402/x402ActionProvider.test.js +78 -225
  28. package/dist/agentkit.d.ts +1 -0
  29. package/dist/agentkit.js +3 -2
  30. package/dist/wallet-providers/{cdpV2EvmWalletProvider.d.ts → cdpEvmWalletProvider.d.ts} +16 -7
  31. package/dist/wallet-providers/{cdpV2EvmWalletProvider.js → cdpEvmWalletProvider.js} +50 -39
  32. package/dist/wallet-providers/{cdpV2EvmWalletProvider.test.js → cdpEvmWalletProvider.test.js} +7 -7
  33. package/dist/wallet-providers/{cdpV2Shared.d.ts → cdpShared.d.ts} +15 -4
  34. package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +115 -0
  35. package/dist/wallet-providers/cdpSmartWalletProvider.js +263 -0
  36. package/dist/wallet-providers/cdpSmartWalletProvider.test.js +287 -0
  37. package/dist/wallet-providers/{cdpV2SolanaWalletProvider.d.ts → cdpSolanaWalletProvider.d.ts} +16 -7
  38. package/dist/wallet-providers/{cdpV2SolanaWalletProvider.js → cdpSolanaWalletProvider.js} +43 -32
  39. package/dist/wallet-providers/{cdpV2SolanaWalletProvider.test.js → cdpSolanaWalletProvider.test.js} +7 -7
  40. package/dist/wallet-providers/index.d.ts +6 -6
  41. package/dist/wallet-providers/index.js +6 -6
  42. package/dist/wallet-providers/{smartWalletProvider.d.ts → legacyCdpSmartWalletProvider.d.ts} +3 -3
  43. package/dist/wallet-providers/{smartWalletProvider.js → legacyCdpSmartWalletProvider.js} +21 -21
  44. package/dist/wallet-providers/legacyCdpSmartWalletProvider.test.d.ts +1 -0
  45. package/dist/wallet-providers/{smartWalletProvider.test.js → legacyCdpSmartWalletProvider.test.js} +2 -2
  46. package/dist/wallet-providers/{cdpWalletProvider.d.ts → legacyCdpWalletProvider.d.ts} +15 -11
  47. package/dist/wallet-providers/{cdpWalletProvider.js → legacyCdpWalletProvider.js} +72 -70
  48. package/dist/wallet-providers/legacyCdpWalletProvider.test.d.ts +1 -0
  49. package/dist/wallet-providers/{cdpWalletProvider.test.js → legacyCdpWalletProvider.test.js} +10 -10
  50. package/package.json +3 -2
  51. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +0 -34
  52. package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +0 -98
  53. package/dist/action-providers/cdp-v2/index.d.ts +0 -2
  54. package/dist/action-providers/cdp-v2/schemas.d.ts +0 -11
  55. package/dist/action-providers/cdp-v2/schemas.js +0 -13
  56. package/dist/wallet-providers/cdpV2WalletProvider.d.ts +0 -35
  57. package/dist/wallet-providers/cdpV2WalletProvider.js +0 -42
  58. /package/dist/action-providers/{cdp → cdp-legacy}/constants.d.ts +0 -0
  59. /package/dist/action-providers/{cdp → cdp-legacy}/constants.js +0 -0
  60. /package/dist/action-providers/{cdp/cdpWalletActionProvider.test.d.ts → cdp-legacy/legacyCdpApiActionProvider.test.d.ts} +0 -0
  61. /package/dist/{wallet-providers/cdpV2EvmWalletProvider.test.d.ts → action-providers/cdp-legacy/legacyCdpWalletActionProvider.test.d.ts} +0 -0
  62. /package/dist/wallet-providers/{cdpV2SolanaWalletProvider.test.d.ts → cdpEvmWalletProvider.test.d.ts} +0 -0
  63. /package/dist/wallet-providers/{cdpV2Shared.js → cdpShared.js} +0 -0
  64. /package/dist/wallet-providers/{cdpWalletProvider.test.d.ts → cdpSmartWalletProvider.test.d.ts} +0 -0
  65. /package/dist/wallet-providers/{smartWalletProvider.test.d.ts → cdpSolanaWalletProvider.test.d.ts} +0 -0
@@ -10,9 +10,9 @@ 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 _CdpWalletProvider_cdpWallet, _CdpWalletProvider_address, _CdpWalletProvider_network, _CdpWalletProvider_publicClient, _CdpWalletProvider_gasLimitMultiplier, _CdpWalletProvider_feePerGasMultiplier, _CdpWalletProvider_transactionQueue;
13
+ var _LegacyCdpWalletProvider_cdpWallet, _LegacyCdpWalletProvider_address, _LegacyCdpWalletProvider_network, _LegacyCdpWalletProvider_publicClient, _LegacyCdpWalletProvider_gasLimitMultiplier, _LegacyCdpWalletProvider_feePerGasMultiplier, _LegacyCdpWalletProvider_transactionQueue;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.CdpWalletProvider = void 0;
15
+ exports.LegacyCdpWalletProvider = void 0;
16
16
  const package_json_1 = require("../../package.json");
17
17
  const decimal_js_1 = require("decimal.js");
18
18
  const viem_1 = require("viem");
@@ -21,38 +21,40 @@ const coinbase_sdk_1 = require("@coinbase/coinbase-sdk");
21
21
  const network_1 = require("../network/network");
22
22
  const utils_1 = require("../utils");
23
23
  /**
24
- * A wallet provider that uses the Coinbase SDK.
24
+ * A legacy wallet provider that uses the old Coinbase SDK.
25
+ *
26
+ * @deprecated Use CdpEvmWalletProvider or CdpSmartWalletProvider instead
25
27
  */
26
- class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
28
+ class LegacyCdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
27
29
  /**
28
- * Constructs a new CdpWalletProvider.
30
+ * Constructs a new LegacyCdpWalletProvider.
29
31
  *
30
- * @param config - The configuration options for the CdpWalletProvider.
32
+ * @param config - The configuration options for the LegacyCdpWalletProvider.
31
33
  */
32
34
  constructor(config) {
33
35
  super();
34
- _CdpWalletProvider_cdpWallet.set(this, void 0);
35
- _CdpWalletProvider_address.set(this, void 0);
36
- _CdpWalletProvider_network.set(this, void 0);
37
- _CdpWalletProvider_publicClient.set(this, void 0);
38
- _CdpWalletProvider_gasLimitMultiplier.set(this, void 0);
39
- _CdpWalletProvider_feePerGasMultiplier.set(this, void 0);
40
- _CdpWalletProvider_transactionQueue.set(this, void 0);
41
- __classPrivateFieldSet(this, _CdpWalletProvider_cdpWallet, config.wallet, "f");
42
- __classPrivateFieldSet(this, _CdpWalletProvider_address, config.address, "f");
43
- __classPrivateFieldSet(this, _CdpWalletProvider_network, config.network, "f");
44
- __classPrivateFieldSet(this, _CdpWalletProvider_publicClient, (0, viem_1.createPublicClient)({
36
+ _LegacyCdpWalletProvider_cdpWallet.set(this, void 0);
37
+ _LegacyCdpWalletProvider_address.set(this, void 0);
38
+ _LegacyCdpWalletProvider_network.set(this, void 0);
39
+ _LegacyCdpWalletProvider_publicClient.set(this, void 0);
40
+ _LegacyCdpWalletProvider_gasLimitMultiplier.set(this, void 0);
41
+ _LegacyCdpWalletProvider_feePerGasMultiplier.set(this, void 0);
42
+ _LegacyCdpWalletProvider_transactionQueue.set(this, void 0);
43
+ __classPrivateFieldSet(this, _LegacyCdpWalletProvider_cdpWallet, config.wallet, "f");
44
+ __classPrivateFieldSet(this, _LegacyCdpWalletProvider_address, config.address, "f");
45
+ __classPrivateFieldSet(this, _LegacyCdpWalletProvider_network, config.network, "f");
46
+ __classPrivateFieldSet(this, _LegacyCdpWalletProvider_publicClient, (0, viem_1.createPublicClient)({
45
47
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[config.network.networkId],
46
48
  transport: (0, viem_1.http)(),
47
49
  }), "f");
48
- __classPrivateFieldSet(this, _CdpWalletProvider_gasLimitMultiplier, Math.max(config.gas?.gasLimitMultiplier ?? 1.2, 1), "f");
49
- __classPrivateFieldSet(this, _CdpWalletProvider_feePerGasMultiplier, Math.max(config.gas?.feePerGasMultiplier ?? 1, 1), "f");
50
+ __classPrivateFieldSet(this, _LegacyCdpWalletProvider_gasLimitMultiplier, Math.max(config.gas?.gasLimitMultiplier ?? 1.2, 1), "f");
51
+ __classPrivateFieldSet(this, _LegacyCdpWalletProvider_feePerGasMultiplier, Math.max(config.gas?.feePerGasMultiplier ?? 1, 1), "f");
50
52
  }
51
53
  /**
52
- * Configures a new CdpWalletProvider with a wallet.
54
+ * Configures a new LegacyCdpWalletProvider with a wallet.
53
55
  *
54
56
  * @param config - Optional configuration parameters
55
- * @returns A Promise that resolves to a new CdpWalletProvider instance
57
+ * @returns A Promise that resolves to a new LegacyCdpWalletProvider instance
56
58
  * @throws Error if required environment variables are missing or wallet initialization fails
57
59
  */
58
60
  static async configureWithWallet(config = {}) {
@@ -95,7 +97,7 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
95
97
  chainId: network_1.NETWORK_ID_TO_CHAIN_ID[networkId],
96
98
  networkId: networkId,
97
99
  };
98
- const cdpWalletProvider = new CdpWalletProvider({
100
+ const cdpWalletProvider = new LegacyCdpWalletProvider({
99
101
  wallet,
100
102
  address,
101
103
  network,
@@ -110,11 +112,11 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
110
112
  * @returns The signed message.
111
113
  */
112
114
  async signMessage(message) {
113
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
115
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
114
116
  throw new Error("Wallet not initialized");
115
117
  }
116
118
  const messageHash = (0, viem_1.hashMessage)(message);
117
- const payload = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createPayloadSignature(messageHash);
119
+ const payload = await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").createPayloadSignature(messageHash);
118
120
  if (payload.getStatus() === "pending" && payload?.wait) {
119
121
  await payload.wait(); // needed for Server-Signers
120
122
  }
@@ -128,11 +130,11 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
128
130
  */
129
131
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
130
132
  async signTypedData(typedData) {
131
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
133
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
132
134
  throw new Error("Wallet not initialized");
133
135
  }
134
136
  const messageHash = (0, coinbase_sdk_1.hashTypedDataMessage)(typedData.domain, typedData.types, typedData.message);
135
- const payload = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createPayloadSignature(messageHash);
137
+ const payload = await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").createPayloadSignature(messageHash);
136
138
  if (payload.getStatus() === "pending" && payload?.wait) {
137
139
  await payload.wait(); // needed for Server-Signers
138
140
  }
@@ -145,12 +147,12 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
145
147
  * @returns The signed transaction.
146
148
  */
147
149
  async signTransaction(transaction) {
148
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
150
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
149
151
  throw new Error("Wallet not initialized");
150
152
  }
151
153
  const serializedTx = (0, viem_1.serializeTransaction)(transaction);
152
154
  const transactionHash = (0, viem_1.keccak256)(serializedTx);
153
- const payload = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createPayloadSignature(transactionHash);
155
+ const payload = await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").createPayloadSignature(transactionHash);
154
156
  if (payload.getStatus() === "pending" && payload?.wait) {
155
157
  await payload.wait(); // needed for Server-Signers
156
158
  }
@@ -163,22 +165,22 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
163
165
  * @returns The hash of the transaction.
164
166
  */
165
167
  async sendTransaction(transaction) {
166
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
168
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
167
169
  throw new Error("Wallet not initialized");
168
170
  }
169
171
  const sendPromise = (async () => {
170
- if (__classPrivateFieldGet(this, _CdpWalletProvider_transactionQueue, "f"))
171
- await __classPrivateFieldGet(this, _CdpWalletProvider_transactionQueue, "f");
172
+ if (__classPrivateFieldGet(this, _LegacyCdpWalletProvider_transactionQueue, "f"))
173
+ await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_transactionQueue, "f");
172
174
  const preparedTransaction = await this.prepareTransaction(transaction.to, transaction.value, transaction.data);
173
175
  const signature = await this.signTransaction({
174
176
  ...preparedTransaction,
175
177
  });
176
178
  const signedPayload = await this.addSignatureAndSerialize(preparedTransaction, signature);
177
- const externalAddress = new coinbase_sdk_1.ExternalAddress(__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").getNetworkId(), __classPrivateFieldGet(this, _CdpWalletProvider_address, "f"));
179
+ const externalAddress = new coinbase_sdk_1.ExternalAddress(__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").getNetworkId(), __classPrivateFieldGet(this, _LegacyCdpWalletProvider_address, "f"));
178
180
  const tx = await externalAddress.broadcastExternalTransaction(signedPayload.slice(2));
179
181
  return tx.transactionHash;
180
182
  })();
181
- __classPrivateFieldSet(this, _CdpWalletProvider_transactionQueue, sendPromise
183
+ __classPrivateFieldSet(this, _LegacyCdpWalletProvider_transactionQueue, sendPromise
182
184
  .then(txHash => this.waitForTransactionReceipt(txHash))
183
185
  .catch(() => { }), "f");
184
186
  return await sendPromise;
@@ -192,24 +194,24 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
192
194
  * @returns The prepared transaction.
193
195
  */
194
196
  async prepareTransaction(to, value, data) {
195
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
197
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
196
198
  throw new Error("Wallet not initialized");
197
199
  }
198
- const nonce = await __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").getTransactionCount({
199
- address: __classPrivateFieldGet(this, _CdpWalletProvider_address, "f"),
200
+ const nonce = await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_publicClient, "f").getTransactionCount({
201
+ address: __classPrivateFieldGet(this, _LegacyCdpWalletProvider_address, "f"),
200
202
  blockTag: "pending",
201
203
  });
202
- const feeData = await __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").estimateFeesPerGas();
203
- const maxFeePerGas = (0, utils_1.applyGasMultiplier)(feeData.maxFeePerGas, __classPrivateFieldGet(this, _CdpWalletProvider_feePerGasMultiplier, "f"));
204
- const maxPriorityFeePerGas = (0, utils_1.applyGasMultiplier)(feeData.maxPriorityFeePerGas, __classPrivateFieldGet(this, _CdpWalletProvider_feePerGasMultiplier, "f"));
205
- const gasLimit = await __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").estimateGas({
206
- account: __classPrivateFieldGet(this, _CdpWalletProvider_address, "f"),
204
+ const feeData = await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_publicClient, "f").estimateFeesPerGas();
205
+ const maxFeePerGas = (0, utils_1.applyGasMultiplier)(feeData.maxFeePerGas, __classPrivateFieldGet(this, _LegacyCdpWalletProvider_feePerGasMultiplier, "f"));
206
+ const maxPriorityFeePerGas = (0, utils_1.applyGasMultiplier)(feeData.maxPriorityFeePerGas, __classPrivateFieldGet(this, _LegacyCdpWalletProvider_feePerGasMultiplier, "f"));
207
+ const gasLimit = await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_publicClient, "f").estimateGas({
208
+ account: __classPrivateFieldGet(this, _LegacyCdpWalletProvider_address, "f"),
207
209
  to,
208
210
  value,
209
211
  data,
210
212
  });
211
- const gas = BigInt(Math.round(Number(gasLimit) * __classPrivateFieldGet(this, _CdpWalletProvider_gasLimitMultiplier, "f")));
212
- const chainId = parseInt(__classPrivateFieldGet(this, _CdpWalletProvider_network, "f").chainId, 10);
213
+ const gas = BigInt(Math.round(Number(gasLimit) * __classPrivateFieldGet(this, _LegacyCdpWalletProvider_gasLimitMultiplier, "f")));
214
+ const chainId = parseInt(__classPrivateFieldGet(this, _LegacyCdpWalletProvider_network, "f").chainId, 10);
213
215
  return {
214
216
  to,
215
217
  value,
@@ -242,10 +244,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
242
244
  * @returns The address of the wallet.
243
245
  */
244
246
  getAddress() {
245
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_address, "f")) {
247
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_address, "f")) {
246
248
  throw new Error("Address not initialized");
247
249
  }
248
- return __classPrivateFieldGet(this, _CdpWalletProvider_address, "f");
250
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_address, "f");
249
251
  }
250
252
  /**
251
253
  * Gets the network of the wallet.
@@ -253,10 +255,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
253
255
  * @returns The network of the wallet.
254
256
  */
255
257
  getNetwork() {
256
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_network, "f")) {
258
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_network, "f")) {
257
259
  throw new Error("Network not initialized");
258
260
  }
259
- return __classPrivateFieldGet(this, _CdpWalletProvider_network, "f");
261
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_network, "f");
260
262
  }
261
263
  /**
262
264
  * Gets the name of the wallet provider.
@@ -264,7 +266,7 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
264
266
  * @returns The name of the wallet provider.
265
267
  */
266
268
  getName() {
267
- return "cdp_wallet_provider";
269
+ return "legacy_cdp_wallet_provider";
268
270
  }
269
271
  /**
270
272
  * Gets the balance of the wallet.
@@ -272,10 +274,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
272
274
  * @returns The balance of the wallet in wei
273
275
  */
274
276
  async getBalance() {
275
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
277
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
276
278
  throw new Error("Wallet not initialized");
277
279
  }
278
- const balance = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").getBalance("eth");
280
+ const balance = await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").getBalance("eth");
279
281
  return BigInt(balance.mul(10 ** 18).toString());
280
282
  }
281
283
  /**
@@ -286,7 +288,7 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
286
288
  */
287
289
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
288
290
  async waitForTransactionReceipt(txHash) {
289
- return await __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").waitForTransactionReceipt({ hash: txHash });
291
+ return await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_publicClient, "f").waitForTransactionReceipt({ hash: txHash });
290
292
  }
291
293
  /**
292
294
  * Reads a contract.
@@ -295,7 +297,7 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
295
297
  * @returns The response from the contract.
296
298
  */
297
299
  async readContract(params) {
298
- return __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").readContract(params);
300
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_publicClient, "f").readContract(params);
299
301
  }
300
302
  /**
301
303
  * Creates a trade.
@@ -304,10 +306,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
304
306
  * @returns The trade.
305
307
  */
306
308
  async createTrade(options) {
307
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
309
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
308
310
  throw new Error("Wallet not initialized");
309
311
  }
310
- return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createTrade(options);
312
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").createTrade(options);
311
313
  }
312
314
  /**
313
315
  * Deploys a token.
@@ -316,10 +318,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
316
318
  * @returns The deployed token.
317
319
  */
318
320
  async deployToken(options) {
319
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
321
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
320
322
  throw new Error("Wallet not initialized");
321
323
  }
322
- return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").deployToken(options);
324
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").deployToken(options);
323
325
  }
324
326
  /**
325
327
  * Deploys a contract.
@@ -334,10 +336,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
334
336
  * @throws Error if wallet is not initialized
335
337
  */
336
338
  async deployContract(options) {
337
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
339
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
338
340
  throw new Error("Wallet not initialized");
339
341
  }
340
- return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").deployContract(options);
342
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").deployContract(options);
341
343
  }
342
344
  /**
343
345
  * Deploys a new NFT (ERC-721) smart contract.
@@ -352,10 +354,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
352
354
  * @throws Error if the deployment fails for any reason (network issues, insufficient funds, etc.)
353
355
  */
354
356
  async deployNFT(options) {
355
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
357
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
356
358
  throw new Error("Wallet not initialized");
357
359
  }
358
- return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").deployNFT(options);
360
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").deployNFT(options);
359
361
  }
360
362
  /**
361
363
  * Transfer the native asset of the network.
@@ -365,10 +367,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
365
367
  * @returns The transaction hash.
366
368
  */
367
369
  async nativeTransfer(to, value) {
368
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
370
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
369
371
  throw new Error("Wallet not initialized");
370
372
  }
371
- const transferResult = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createTransfer({
373
+ const transferResult = await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").createTransfer({
372
374
  amount: new decimal_js_1.Decimal(value),
373
375
  assetId: coinbase_sdk_1.Coinbase.assets.Eth,
374
376
  destination: to,
@@ -386,10 +388,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
386
388
  * @returns The wallet's data.
387
389
  */
388
390
  async exportWallet() {
389
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
391
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
390
392
  throw new Error("Wallet not initialized");
391
393
  }
392
- return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").export();
394
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").export();
393
395
  }
394
396
  /**
395
397
  * Gets the wallet.
@@ -397,10 +399,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
397
399
  * @returns The wallet.
398
400
  */
399
401
  getWallet() {
400
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
402
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
401
403
  throw new Error("Wallet not initialized");
402
404
  }
403
- return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f");
405
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f");
404
406
  }
405
407
  /**
406
408
  * ERC20 transfer method
@@ -411,10 +413,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
411
413
  * @returns The transaction hash
412
414
  */
413
415
  async gaslessERC20Transfer(assetId, destination, amount) {
414
- if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
416
+ if (!__classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f")) {
415
417
  throw new Error("Wallet not initialized");
416
418
  }
417
- const transferResult = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createTransfer({
419
+ const transferResult = await __classPrivateFieldGet(this, _LegacyCdpWalletProvider_cdpWallet, "f").createTransfer({
418
420
  amount,
419
421
  assetId,
420
422
  destination,
@@ -427,5 +429,5 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
427
429
  return result.getTransactionHash();
428
430
  }
429
431
  }
430
- exports.CdpWalletProvider = CdpWalletProvider;
431
- _CdpWalletProvider_cdpWallet = new WeakMap(), _CdpWalletProvider_address = new WeakMap(), _CdpWalletProvider_network = new WeakMap(), _CdpWalletProvider_publicClient = new WeakMap(), _CdpWalletProvider_gasLimitMultiplier = new WeakMap(), _CdpWalletProvider_feePerGasMultiplier = new WeakMap(), _CdpWalletProvider_transactionQueue = new WeakMap();
432
+ exports.LegacyCdpWalletProvider = LegacyCdpWalletProvider;
433
+ _LegacyCdpWalletProvider_cdpWallet = new WeakMap(), _LegacyCdpWalletProvider_address = new WeakMap(), _LegacyCdpWalletProvider_network = new WeakMap(), _LegacyCdpWalletProvider_publicClient = new WeakMap(), _LegacyCdpWalletProvider_gasLimitMultiplier = new WeakMap(), _LegacyCdpWalletProvider_feePerGasMultiplier = new WeakMap(), _LegacyCdpWalletProvider_transactionQueue = new WeakMap();
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const cdpWalletProvider_1 = require("./cdpWalletProvider");
3
+ const legacyCdpWalletProvider_1 = require("./legacyCdpWalletProvider");
4
4
  const coinbase_sdk_1 = require("@coinbase/coinbase-sdk");
5
5
  const decimal_js_1 = require("decimal.js");
6
6
  global.fetch = jest.fn(() => Promise.resolve({
@@ -126,7 +126,7 @@ const MOCK_NETWORK = {
126
126
  const MOCK_TRANSACTION_RECEIPT = {
127
127
  transactionHash: MOCK_TRANSACTION_HASH,
128
128
  };
129
- describe("CdpWalletProvider", () => {
129
+ describe("LegacyCdpWalletProvider", () => {
130
130
  let provider;
131
131
  beforeEach(async () => {
132
132
  jest.clearAllMocks();
@@ -166,7 +166,7 @@ describe("CdpWalletProvider", () => {
166
166
  maxPriorityFeePerGas: BigInt(10000000),
167
167
  });
168
168
  mockPublicClient.estimateGas.mockResolvedValue(BigInt(21000));
169
- provider = await cdpWalletProvider_1.CdpWalletProvider.configureWithWallet({
169
+ provider = await legacyCdpWalletProvider_1.LegacyCdpWalletProvider.configureWithWallet({
170
170
  wallet: mockWalletObj,
171
171
  networkId: MOCK_NETWORK_ID,
172
172
  });
@@ -180,7 +180,7 @@ describe("CdpWalletProvider", () => {
180
180
  seed: MOCK_PRIVATE_KEY,
181
181
  networkId: MOCK_NETWORK_ID,
182
182
  });
183
- const provider = await cdpWalletProvider_1.CdpWalletProvider.configureWithWallet({
183
+ const provider = await legacyCdpWalletProvider_1.LegacyCdpWalletProvider.configureWithWallet({
184
184
  cdpWalletData: walletData,
185
185
  networkId: MOCK_NETWORK_ID,
186
186
  });
@@ -190,7 +190,7 @@ describe("CdpWalletProvider", () => {
190
190
  });
191
191
  it("should initialize with mnemonic phrase", async () => {
192
192
  const mnemonicPhrase = "test test test test test test test test test test test junk";
193
- const provider = await cdpWalletProvider_1.CdpWalletProvider.configureWithWallet({
193
+ const provider = await legacyCdpWalletProvider_1.LegacyCdpWalletProvider.configureWithWallet({
194
194
  mnemonicPhrase,
195
195
  networkId: MOCK_NETWORK_ID,
196
196
  });
@@ -201,7 +201,7 @@ describe("CdpWalletProvider", () => {
201
201
  it("should initialize with API keys", async () => {
202
202
  const apiKeyId = "test-key";
203
203
  const apiKeySecret = "private-key";
204
- const provider = await cdpWalletProvider_1.CdpWalletProvider.configureWithWallet({
204
+ const provider = await legacyCdpWalletProvider_1.LegacyCdpWalletProvider.configureWithWallet({
205
205
  apiKeyId,
206
206
  apiKeySecret,
207
207
  networkId: MOCK_NETWORK_ID,
@@ -216,7 +216,7 @@ describe("CdpWalletProvider", () => {
216
216
  expect(provider.getNetwork()).toEqual(MOCK_NETWORK);
217
217
  });
218
218
  it("should initialize with an existing wallet", async () => {
219
- const provider = await cdpWalletProvider_1.CdpWalletProvider.configureWithWallet({
219
+ const provider = await legacyCdpWalletProvider_1.LegacyCdpWalletProvider.configureWithWallet({
220
220
  wallet: mockWalletObj,
221
221
  networkId: MOCK_NETWORK_ID,
222
222
  });
@@ -225,14 +225,14 @@ describe("CdpWalletProvider", () => {
225
225
  });
226
226
  it("should default to base-sepolia if network not provided", async () => {
227
227
  mockWalletObj.getNetworkId.mockReturnValueOnce("base-sepolia");
228
- const provider = await cdpWalletProvider_1.CdpWalletProvider.configureWithWallet({
228
+ const provider = await legacyCdpWalletProvider_1.LegacyCdpWalletProvider.configureWithWallet({
229
229
  wallet: mockWalletObj,
230
230
  });
231
231
  expect(provider.getNetwork().networkId).toBe("base-sepolia");
232
232
  });
233
233
  it("should handle initialization failures gracefully", async () => {
234
234
  jest.spyOn(coinbase_sdk_1.Wallet, "create").mockRejectedValueOnce(new Error("Failed to create wallet"));
235
- await expect(cdpWalletProvider_1.CdpWalletProvider.configureWithWallet({
235
+ await expect(legacyCdpWalletProvider_1.LegacyCdpWalletProvider.configureWithWallet({
236
236
  networkId: MOCK_NETWORK_ID,
237
237
  })).rejects.toThrow("Failed to create wallet");
238
238
  });
@@ -248,7 +248,7 @@ describe("CdpWalletProvider", () => {
248
248
  expect(provider.getNetwork()).toEqual(MOCK_NETWORK);
249
249
  });
250
250
  it("should get the name", () => {
251
- expect(provider.getName()).toBe("cdp_wallet_provider");
251
+ expect(provider.getName()).toBe("legacy_cdp_wallet_provider");
252
252
  });
253
253
  it("should get the balance", async () => {
254
254
  const balance = await provider.getBalance();
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.8.2",
5
+ "version": "0.9.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.3.0",
27
+ "@coinbase/cdp-sdk": "^1.26.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",
@@ -44,6 +44,7 @@
44
44
  "reflect-metadata": "^0.2.2",
45
45
  "twitter-api-v2": "^1.18.2",
46
46
  "viem": "^2.22.16",
47
+ "x402": "^0.4.1",
47
48
  "x402-axios": "^0.3.3",
48
49
  "zod": "^3.23.8"
49
50
  },
@@ -1,34 +0,0 @@
1
- import { z } from "zod";
2
- import { Network } from "../../network";
3
- import { WalletProvider } from "../../wallet-providers";
4
- import { ActionProvider } from "../actionProvider";
5
- import { RequestFaucetFundsV2Schema } from "./schemas";
6
- /**
7
- * CdpApiActionProvider is an action provider for CDP API.
8
- *
9
- * This provider is used for any action that uses the CDP API, but does not require a CDP Wallet.
10
- */
11
- export declare class CdpApiV2ActionProvider extends ActionProvider<WalletProvider> {
12
- /**
13
- * Constructor for the CdpApiActionProvider class.
14
- */
15
- constructor();
16
- /**
17
- * Requests test tokens from the faucet for the default address in the wallet.
18
- *
19
- * @param walletProvider - The wallet provider to request funds from.
20
- * @param args - The input arguments for the action.
21
- * @returns A confirmation message with transaction details.
22
- */
23
- faucet(walletProvider: WalletProvider, args: z.infer<typeof RequestFaucetFundsV2Schema>): Promise<string>;
24
- /**
25
- * Checks if the Cdp action provider supports the given network.
26
- *
27
- * NOTE: Network scoping is done at the action implementation level
28
- *
29
- * @param _ - The network to check.
30
- * @returns True if the Cdp action provider supports the network, false otherwise.
31
- */
32
- supportsNetwork: (_: Network) => boolean;
33
- }
34
- export declare const cdpApiV2ActionProvider: () => CdpApiV2ActionProvider;
@@ -1,98 +0,0 @@
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.cdpApiV2ActionProvider = exports.CdpApiV2ActionProvider = void 0;
13
- const zod_1 = require("zod");
14
- const wallet_providers_1 = require("../../wallet-providers");
15
- const cdpV2Shared_1 = require("../../wallet-providers/cdpV2Shared");
16
- const actionDecorator_1 = require("../actionDecorator");
17
- const actionProvider_1 = require("../actionProvider");
18
- const schemas_1 = require("./schemas");
19
- /**
20
- * CdpApiActionProvider is an action provider for CDP API.
21
- *
22
- * This provider is used for any action that uses the CDP API, but does not require a CDP Wallet.
23
- */
24
- class CdpApiV2ActionProvider extends actionProvider_1.ActionProvider {
25
- /**
26
- * Constructor for the CdpApiActionProvider class.
27
- */
28
- constructor() {
29
- super("cdp_api_v2", []);
30
- /**
31
- * Checks if the Cdp action provider supports the given network.
32
- *
33
- * NOTE: Network scoping is done at the action implementation level
34
- *
35
- * @param _ - The network to check.
36
- * @returns True if the Cdp action provider supports the network, false otherwise.
37
- */
38
- this.supportsNetwork = (_) => true;
39
- }
40
- /**
41
- * Requests test tokens from the faucet for the default address in the wallet.
42
- *
43
- * @param walletProvider - The wallet provider to request funds from.
44
- * @param args - The input arguments for the action.
45
- * @returns A confirmation message with transaction details.
46
- */
47
- async faucet(walletProvider, args) {
48
- const network = walletProvider.getNetwork();
49
- const networkId = network.networkId;
50
- if ((0, cdpV2Shared_1.isWalletProviderWithClient)(walletProvider)) {
51
- if (network.protocolFamily === "evm") {
52
- if (networkId !== "base-sepolia" && networkId !== "ethereum-sepolia") {
53
- throw new Error("Faucet is only supported on 'base-sepolia' or 'ethereum-sepolia' evm networks.");
54
- }
55
- const faucetTx = await walletProvider.getClient().evm.requestFaucet({
56
- address: walletProvider.getAddress(),
57
- token: (args.assetId || "eth"),
58
- network: networkId,
59
- });
60
- return `Received ${args.assetId || "ETH"} from the faucet. Transaction hash: ${faucetTx.transactionHash}`;
61
- }
62
- else if (network.protocolFamily === "svm") {
63
- if (networkId !== "solana-devnet") {
64
- throw new Error("Faucet is only supported on 'solana-devnet' solana networks.");
65
- }
66
- const faucetTx = await walletProvider.getClient().solana.requestFaucet({
67
- address: walletProvider.getAddress(),
68
- token: (args.assetId || "sol"),
69
- });
70
- return `Received ${args.assetId || "SOL"} from the faucet. Transaction signature hash: ${faucetTx.signature}`;
71
- }
72
- else {
73
- throw new Error("Faucet is only supported on Ethereum and Solana protocol families.");
74
- }
75
- }
76
- else {
77
- throw new Error("Wallet provider is not a CDP Wallet Provider.");
78
- }
79
- }
80
- }
81
- exports.CdpApiV2ActionProvider = CdpApiV2ActionProvider;
82
- __decorate([
83
- (0, actionDecorator_1.CreateAction)({
84
- name: "request_faucet_funds",
85
- description: `This tool will request test tokens from the faucet for the default address in the wallet. It takes the wallet and asset ID as input.
86
- Faucet is only allowed on 'base-sepolia' or 'solana-devnet'.
87
- If fauceting on 'base-sepolia', user can only provide asset ID 'eth', 'usdc', 'eurc' or 'cbbtc', if no asset ID is provided, the faucet will default to 'eth'.
88
- If fauceting on 'solana-devnet', user can only provide asset ID 'sol' or 'usdc', if no asset ID is provided, the faucet will default to 'sol'.
89
- You are not allowed to faucet with any other network or asset ID. If you are on another network, suggest that the user sends you some ETH
90
- from another wallet and provide the user with your wallet details.`,
91
- schema: schemas_1.RequestFaucetFundsV2Schema,
92
- }),
93
- __metadata("design:type", Function),
94
- __metadata("design:paramtypes", [wallet_providers_1.WalletProvider, void 0]),
95
- __metadata("design:returntype", Promise)
96
- ], CdpApiV2ActionProvider.prototype, "faucet", null);
97
- const cdpApiV2ActionProvider = () => new CdpApiV2ActionProvider();
98
- exports.cdpApiV2ActionProvider = cdpApiV2ActionProvider;
@@ -1,2 +0,0 @@
1
- export * from "./schemas";
2
- export * from "./cdpApiV2ActionProvider";
@@ -1,11 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * Input schema for request faucet funds action.
4
- */
5
- export declare const RequestFaucetFundsV2Schema: z.ZodObject<{
6
- assetId: z.ZodOptional<z.ZodString>;
7
- }, "strip", z.ZodTypeAny, {
8
- assetId?: string | undefined;
9
- }, {
10
- assetId?: string | undefined;
11
- }>;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RequestFaucetFundsV2Schema = void 0;
4
- const zod_1 = require("zod");
5
- /**
6
- * Input schema for request faucet funds action.
7
- */
8
- exports.RequestFaucetFundsV2Schema = zod_1.z
9
- .object({
10
- assetId: zod_1.z.string().optional().describe("The optional asset ID to request from faucet"),
11
- })
12
- .strip()
13
- .describe("Instructions for requesting faucet funds");