@coinbase/agentkit 0.0.0-nightly-20250904210426 → 0.0.0-nightly-20250906210355

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 (73) hide show
  1. package/README.md +29 -0
  2. package/dist/action-providers/across/acrossActionProvider.js +3 -3
  3. package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +0 -1
  4. package/dist/action-providers/cdp/cdpApiActionProvider.js +0 -16
  5. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +1 -2
  6. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +7 -26
  7. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +8 -0
  8. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +0 -1
  9. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +7 -22
  10. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +11 -1
  11. package/dist/action-providers/clanker/clankerActionProvider.d.ts +43 -0
  12. package/dist/action-providers/clanker/clankerActionProvider.js +130 -0
  13. package/dist/action-providers/clanker/clankerActionProvider.test.d.ts +4 -0
  14. package/dist/action-providers/clanker/clankerActionProvider.test.js +119 -0
  15. package/dist/action-providers/clanker/index.d.ts +2 -0
  16. package/dist/action-providers/clanker/index.js +18 -0
  17. package/dist/action-providers/clanker/schemas.d.ts +56 -0
  18. package/dist/action-providers/clanker/schemas.js +47 -0
  19. package/dist/action-providers/clanker/utils.d.ts +9 -0
  20. package/dist/action-providers/clanker/utils.js +23 -0
  21. package/dist/action-providers/compound/constants.d.ts +1 -1
  22. package/dist/action-providers/compound/constants.js +2 -2
  23. package/dist/action-providers/erc20/constants.d.ts +35 -135
  24. package/dist/action-providers/erc20/constants.js +37 -189
  25. package/dist/action-providers/erc20/erc20ActionProvider.d.ts +9 -1
  26. package/dist/action-providers/erc20/erc20ActionProvider.js +87 -35
  27. package/dist/action-providers/erc20/erc20ActionProvider.test.js +115 -52
  28. package/dist/action-providers/erc20/schemas.d.ts +25 -12
  29. package/dist/action-providers/erc20/schemas.js +34 -6
  30. package/dist/action-providers/erc20/utils.d.ts +19 -0
  31. package/dist/action-providers/erc20/utils.js +54 -0
  32. package/dist/action-providers/flaunch/constants.d.ts +1 -1
  33. package/dist/action-providers/flaunch/constants.js +2 -2
  34. package/dist/action-providers/index.d.ts +1 -0
  35. package/dist/action-providers/index.js +1 -0
  36. package/dist/action-providers/moonwell/schemas.d.ts +2 -2
  37. package/dist/action-providers/morpho/morphoActionProvider.js +5 -5
  38. package/dist/action-providers/morpho/schemas.d.ts +2 -2
  39. package/dist/action-providers/pyth/pythActionProvider.js +5 -0
  40. package/dist/action-providers/pyth/pythActionProvider.test.js +5 -1
  41. package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.js +4 -4
  42. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.js +3 -3
  43. package/dist/action-providers/superfluid/superfluidWrapperActionProvider.test.js +2 -2
  44. package/dist/action-providers/truemarkets/truemarketsActionProvider.js +10 -10
  45. package/dist/action-providers/wallet/walletActionProvider.js +21 -10
  46. package/dist/action-providers/wallet/walletActionProvider.test.js +6 -2
  47. package/dist/action-providers/zeroX/zeroXActionProvider.js +2 -0
  48. package/dist/wallet-providers/cdpEvmWalletProvider.d.ts +13 -1
  49. package/dist/wallet-providers/cdpEvmWalletProvider.js +30 -24
  50. package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +13 -1
  51. package/dist/wallet-providers/cdpSmartWalletProvider.js +31 -25
  52. package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +1 -1
  53. package/dist/wallet-providers/cdpSolanaWalletProvider.js +7 -7
  54. package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +15 -12
  55. package/dist/wallet-providers/legacyCdpSmartWalletProvider.d.ts +1 -1
  56. package/dist/wallet-providers/legacyCdpSmartWalletProvider.js +1 -1
  57. package/dist/wallet-providers/legacyCdpWalletProvider.d.ts +1 -1
  58. package/dist/wallet-providers/legacyCdpWalletProvider.js +1 -1
  59. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +1 -1
  60. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +2 -2
  61. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.test.js +1 -1
  62. package/dist/wallet-providers/privyEvmWalletProvider.test.js +1 -1
  63. package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +1 -1
  64. package/dist/wallet-providers/solanaKeypairWalletProvider.js +3 -4
  65. package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +4 -2
  66. package/dist/wallet-providers/viemWalletProvider.d.ts +1 -1
  67. package/dist/wallet-providers/viemWalletProvider.js +2 -2
  68. package/dist/wallet-providers/viemWalletProvider.test.js +6 -5
  69. package/dist/wallet-providers/walletProvider.d.ts +1 -1
  70. package/dist/wallet-providers/zeroDevWalletProvider.d.ts +1 -1
  71. package/dist/wallet-providers/zeroDevWalletProvider.js +4 -4
  72. package/dist/wallet-providers/zeroDevWalletProvider.test.js +2 -2
  73. package/package.json +3 -2
@@ -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 _CdpEvmWalletProvider_instances, _CdpEvmWalletProvider_publicClient, _CdpEvmWalletProvider_serverAccount, _CdpEvmWalletProvider_cdp, _CdpEvmWalletProvider_network, _CdpEvmWalletProvider_getCdpSdkNetwork;
13
+ var _CdpEvmWalletProvider_publicClient, _CdpEvmWalletProvider_serverAccount, _CdpEvmWalletProvider_cdp, _CdpEvmWalletProvider_network;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CdpEvmWalletProvider = void 0;
16
16
  const cdp_sdk_1 = require("@coinbase/cdp-sdk");
@@ -28,7 +28,6 @@ class CdpEvmWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
28
28
  */
29
29
  constructor(config) {
30
30
  super();
31
- _CdpEvmWalletProvider_instances.add(this);
32
31
  _CdpEvmWalletProvider_publicClient.set(this, void 0);
33
32
  _CdpEvmWalletProvider_serverAccount.set(this, void 0);
34
33
  _CdpEvmWalletProvider_cdp.set(this, void 0);
@@ -153,7 +152,7 @@ class CdpEvmWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
153
152
  const result = await __classPrivateFieldGet(this, _CdpEvmWalletProvider_cdp, "f").evm.sendTransaction({
154
153
  address: __classPrivateFieldGet(this, _CdpEvmWalletProvider_serverAccount, "f").address,
155
154
  transaction: (0, viem_1.serializeTransaction)(txWithGasParams),
156
- network: __classPrivateFieldGet(this, _CdpEvmWalletProvider_instances, "m", _CdpEvmWalletProvider_getCdpSdkNetwork).call(this),
155
+ network: this.getCdpSdkNetwork(),
157
156
  });
158
157
  return result.transactionHash;
159
158
  }
@@ -228,7 +227,7 @@ class CdpEvmWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
228
227
  * Transfer the native asset of the network.
229
228
  *
230
229
  * @param to - The destination address.
231
- * @param value - The amount to transfer in Wei.
230
+ * @param value - The amount to transfer in atomic units (Wei).
232
231
  * @returns The transaction hash.
233
232
  */
234
233
  async nativeTransfer(to, value) {
@@ -238,25 +237,32 @@ class CdpEvmWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
238
237
  data: "0x",
239
238
  });
240
239
  }
240
+ /**
241
+ * Converts the internal network ID to the format expected by the CDP SDK.
242
+ *
243
+ * @returns The network ID in CDP SDK format
244
+ * @throws Error if the network is not supported
245
+ */
246
+ getCdpSdkNetwork() {
247
+ switch (__classPrivateFieldGet(this, _CdpEvmWalletProvider_network, "f").networkId) {
248
+ case "base-sepolia":
249
+ return "base-sepolia";
250
+ case "base-mainnet":
251
+ return "base";
252
+ case "ethereum-mainnet":
253
+ return "ethereum";
254
+ case "ethereum-sepolia":
255
+ return "ethereum-sepolia";
256
+ case "polygon-mainnet":
257
+ return "polygon";
258
+ case "arbitrum-mainnet":
259
+ return "arbitrum";
260
+ case "optimism-mainnet":
261
+ return "optimism";
262
+ default:
263
+ throw new Error(`Unsupported network for CDP SDK: ${__classPrivateFieldGet(this, _CdpEvmWalletProvider_network, "f").networkId}`);
264
+ }
265
+ }
241
266
  }
242
267
  exports.CdpEvmWalletProvider = CdpEvmWalletProvider;
243
- _CdpEvmWalletProvider_publicClient = new WeakMap(), _CdpEvmWalletProvider_serverAccount = new WeakMap(), _CdpEvmWalletProvider_cdp = new WeakMap(), _CdpEvmWalletProvider_network = new WeakMap(), _CdpEvmWalletProvider_instances = new WeakSet(), _CdpEvmWalletProvider_getCdpSdkNetwork = function _CdpEvmWalletProvider_getCdpSdkNetwork() {
244
- switch (__classPrivateFieldGet(this, _CdpEvmWalletProvider_network, "f").networkId) {
245
- case "base-sepolia":
246
- return "base-sepolia";
247
- case "base-mainnet":
248
- return "base";
249
- case "ethereum-mainnet":
250
- return "ethereum";
251
- case "ethereum-sepolia":
252
- return "ethereum-sepolia";
253
- case "polygon-mainnet":
254
- return "polygon";
255
- case "arbitrum-mainnet":
256
- return "arbitrum";
257
- case "optimism-mainnet":
258
- return "optimism";
259
- default:
260
- throw new Error(`Unsupported network for CDP SDK: ${__classPrivateFieldGet(this, _CdpEvmWalletProvider_network, "f").networkId}`);
261
- }
262
- };
268
+ _CdpEvmWalletProvider_publicClient = new WeakMap(), _CdpEvmWalletProvider_serverAccount = new WeakMap(), _CdpEvmWalletProvider_cdp = new WeakMap(), _CdpEvmWalletProvider_network = new WeakMap();
@@ -3,6 +3,10 @@ import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, PublicCl
3
3
  import { Network } from "../network";
4
4
  import { EvmWalletProvider } from "./evmWalletProvider";
5
5
  import { WalletProviderWithClient, CdpSmartWalletProviderConfig } from "./cdpShared";
6
+ /**
7
+ * Supported network types for CDP SDK smart wallet operations
8
+ */
9
+ type CdpSmartWalletNetwork = "base" | "base-sepolia" | "ethereum" | "ethereum-sepolia" | "polygon" | "arbitrum" | "optimism";
6
10
  /**
7
11
  * A wallet provider that uses the Coinbase CDP SDK smart wallets.
8
12
  */
@@ -122,8 +126,16 @@ export declare class CdpSmartWalletProvider extends EvmWalletProvider implements
122
126
  * Transfer the native asset of the network using smart wallet.
123
127
  *
124
128
  * @param to - The destination address.
125
- * @param value - The amount to transfer in Wei.
129
+ * @param value - The amount to transfer in atomic units (Wei).
126
130
  * @returns The user operation hash.
127
131
  */
128
132
  nativeTransfer(to: Address, value: string): Promise<Hex>;
133
+ /**
134
+ * Converts the internal network ID to the format expected by the CDP SDK.
135
+ *
136
+ * @returns The network ID in CDP SDK format
137
+ * @throws Error if the network is not supported
138
+ */
139
+ getCdpSdkNetwork(): CdpSmartWalletNetwork;
129
140
  }
141
+ export {};
@@ -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_cdp, _CdpSmartWalletProvider_network, _CdpSmartWalletProvider_paymasterUrl, _CdpSmartWalletProvider_getCdpSdkNetwork;
13
+ var _CdpSmartWalletProvider_publicClient, _CdpSmartWalletProvider_cdp, _CdpSmartWalletProvider_network, _CdpSmartWalletProvider_paymasterUrl;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.CdpSmartWalletProvider = void 0;
16
16
  const cdp_sdk_1 = require("@coinbase/cdp-sdk");
@@ -28,7 +28,6 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
28
28
  */
29
29
  constructor(config) {
30
30
  super();
31
- _CdpSmartWalletProvider_instances.add(this);
32
31
  _CdpSmartWalletProvider_publicClient.set(this, void 0);
33
32
  _CdpSmartWalletProvider_cdp.set(this, void 0);
34
33
  _CdpSmartWalletProvider_network.set(this, void 0);
@@ -140,7 +139,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
140
139
  types,
141
140
  primaryType,
142
141
  message,
143
- network: __classPrivateFieldGet(this, _CdpSmartWalletProvider_instances, "m", _CdpSmartWalletProvider_getCdpSdkNetwork).call(this),
142
+ network: this.getCdpSdkNetwork(),
144
143
  });
145
144
  }
146
145
  /**
@@ -168,7 +167,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
168
167
  ];
169
168
  const userOperation = await __classPrivateFieldGet(this, _CdpSmartWalletProvider_cdp, "f").evm.sendUserOperation({
170
169
  smartAccount: this.smartAccount,
171
- network: __classPrivateFieldGet(this, _CdpSmartWalletProvider_instances, "m", _CdpSmartWalletProvider_getCdpSdkNetwork).call(this),
170
+ network: this.getCdpSdkNetwork(),
172
171
  calls,
173
172
  paymasterUrl: __classPrivateFieldGet(this, _CdpSmartWalletProvider_paymasterUrl, "f"),
174
173
  });
@@ -259,7 +258,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
259
258
  * Transfer the native asset of the network using smart wallet.
260
259
  *
261
260
  * @param to - The destination address.
262
- * @param value - The amount to transfer in Wei.
261
+ * @param value - The amount to transfer in atomic units (Wei).
263
262
  * @returns The user operation hash.
264
263
  */
265
264
  async nativeTransfer(to, value) {
@@ -269,25 +268,32 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
269
268
  data: "0x",
270
269
  });
271
270
  }
271
+ /**
272
+ * Converts the internal network ID to the format expected by the CDP SDK.
273
+ *
274
+ * @returns The network ID in CDP SDK format
275
+ * @throws Error if the network is not supported
276
+ */
277
+ getCdpSdkNetwork() {
278
+ switch (__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId) {
279
+ case "base-sepolia":
280
+ return "base-sepolia";
281
+ case "base-mainnet":
282
+ return "base";
283
+ case "ethereum-mainnet":
284
+ return "ethereum";
285
+ case "ethereum-sepolia":
286
+ return "ethereum-sepolia";
287
+ case "polygon-mainnet":
288
+ return "polygon";
289
+ case "arbitrum-mainnet":
290
+ return "arbitrum";
291
+ case "optimism-mainnet":
292
+ return "optimism";
293
+ default:
294
+ throw new Error(`Unsupported network for smart wallets: ${__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId}`);
295
+ }
296
+ }
272
297
  }
273
298
  exports.CdpSmartWalletProvider = CdpSmartWalletProvider;
274
- _CdpSmartWalletProvider_publicClient = new WeakMap(), _CdpSmartWalletProvider_cdp = new WeakMap(), _CdpSmartWalletProvider_network = new WeakMap(), _CdpSmartWalletProvider_paymasterUrl = new WeakMap(), _CdpSmartWalletProvider_instances = new WeakSet(), _CdpSmartWalletProvider_getCdpSdkNetwork = function _CdpSmartWalletProvider_getCdpSdkNetwork() {
275
- switch (__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId) {
276
- case "base-sepolia":
277
- return "base-sepolia";
278
- case "base-mainnet":
279
- return "base";
280
- case "ethereum-mainnet":
281
- return "ethereum";
282
- case "ethereum-sepolia":
283
- return "ethereum-sepolia";
284
- case "polygon-mainnet":
285
- return "polygon";
286
- case "arbitrum-mainnet":
287
- return "arbitrum";
288
- case "optimism-mainnet":
289
- return "optimism";
290
- default:
291
- throw new Error(`Unsupported network for smart wallets: ${__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId}`);
292
- }
293
- };
299
+ _CdpSmartWalletProvider_publicClient = new WeakMap(), _CdpSmartWalletProvider_cdp = new WeakMap(), _CdpSmartWalletProvider_network = new WeakMap(), _CdpSmartWalletProvider_paymasterUrl = new WeakMap();
@@ -113,7 +113,7 @@ export declare class CdpSolanaWalletProvider extends SvmWalletProvider implement
113
113
  * Transfer SOL from the wallet to another address
114
114
  *
115
115
  * @param to - The base58 encoded address to transfer the SOL to
116
- * @param value - The amount of SOL to transfer (as a decimal string, e.g. "0.0001")
116
+ * @param value - The amount to transfer in atomic units (Lamports)
117
117
  * @returns The signature
118
118
  */
119
119
  nativeTransfer(to: string, value: string): Promise<string>;
@@ -147,12 +147,13 @@ class CdpSolanaWalletProvider extends svmWalletProvider_1.SvmWalletProvider {
147
147
  async signTransaction(transaction) {
148
148
  const serializedTransaction = transaction.serialize();
149
149
  const encodedSerializedTransaction = Buffer.from(serializedTransaction).toString("base64");
150
- const signedTransaction = await __classPrivateFieldGet(this, _CdpSolanaWalletProvider_cdp, "f").solana.signTransaction({
150
+ const signedTransactionResponse = await __classPrivateFieldGet(this, _CdpSolanaWalletProvider_cdp, "f").solana.signTransaction({
151
151
  transaction: encodedSerializedTransaction,
152
152
  address: __classPrivateFieldGet(this, _CdpSolanaWalletProvider_serverAccount, "f").address,
153
153
  });
154
- transaction.addSignature(this.getPublicKey(), Buffer.from(signedTransaction.signature, "base64"));
155
- return transaction;
154
+ const signedTransactionBytes = Buffer.from(signedTransactionResponse.signedTransaction, "base64");
155
+ const signedTransaction = web3_js_1.VersionedTransaction.deserialize(signedTransactionBytes);
156
+ return signedTransaction;
156
157
  }
157
158
  /**
158
159
  * Send a transaction
@@ -219,16 +220,15 @@ class CdpSolanaWalletProvider extends svmWalletProvider_1.SvmWalletProvider {
219
220
  * Transfer SOL from the wallet to another address
220
221
  *
221
222
  * @param to - The base58 encoded address to transfer the SOL to
222
- * @param value - The amount of SOL to transfer (as a decimal string, e.g. "0.0001")
223
+ * @param value - The amount to transfer in atomic units (Lamports)
223
224
  * @returns The signature
224
225
  */
225
226
  async nativeTransfer(to, value) {
226
227
  const initialBalance = await this.getBalance();
227
- const solAmount = parseFloat(value);
228
- const lamports = BigInt(Math.floor(solAmount * web3_js_1.LAMPORTS_PER_SOL));
228
+ const lamports = BigInt(value);
229
229
  // Check if we have enough balance (including estimated fees)
230
230
  if (initialBalance < lamports + BigInt(5000)) {
231
- throw new Error(`Insufficient balance. Have ${Number(initialBalance) / web3_js_1.LAMPORTS_PER_SOL} SOL, need ${solAmount + 0.000005} SOL (including fees)`);
231
+ throw new Error(`Insufficient balance. Have ${Number(initialBalance)} lamports, need ${Number(lamports) + 5000} lamports (including fees)`);
232
232
  }
233
233
  const toPubkey = new web3_js_1.PublicKey(to);
234
234
  const instructions = [
@@ -29,13 +29,16 @@ jest.mock("@solana/web3.js", () => {
29
29
  };
30
30
  const MockPublicKey = jest.fn(() => mockPublicKey);
31
31
  MockPublicKey.prototype = mockPublicKey;
32
+ const mockVersionedTransaction = {
33
+ serialize: jest.fn(() => Buffer.from("mock-serialized-tx")),
34
+ addSignature: jest.fn(),
35
+ };
36
+ const MockVersionedTransaction = jest.fn(() => mockVersionedTransaction);
37
+ MockVersionedTransaction.deserialize = jest.fn(() => mockVersionedTransaction);
32
38
  return {
33
39
  Connection: jest.fn(() => mockConnection),
34
40
  PublicKey: MockPublicKey,
35
- VersionedTransaction: jest.fn().mockImplementation(() => ({
36
- serialize: jest.fn(() => Buffer.from("mock-serialized-tx")),
37
- addSignature: jest.fn(),
38
- })),
41
+ VersionedTransaction: MockVersionedTransaction,
39
42
  MessageV0: {
40
43
  compile: jest.fn(),
41
44
  },
@@ -69,9 +72,9 @@ jest.mock("@coinbase/cdp-sdk", () => {
69
72
  address: MOCK_ADDRESS,
70
73
  signTransaction: jest.fn().mockResolvedValue({ signature: MOCK_SIGNATURE }),
71
74
  }));
72
- const mockSignTransaction = jest
73
- .fn()
74
- .mockImplementation(async () => ({ signature: MOCK_SIGNATURE }));
75
+ const mockSignTransaction = jest.fn().mockImplementation(async () => ({
76
+ signedTransaction: Buffer.from("mock-signed-transaction").toString("base64"),
77
+ }));
75
78
  const mockSolanaClient = {
76
79
  createAccount: mockCreateAccount,
77
80
  getAccount: jest.fn(),
@@ -122,9 +125,9 @@ describe("CdpSolanaWalletProvider", () => {
122
125
  };
123
126
  // Set up the mock server account for the provider
124
127
  mockCdpClient.solana.createAccount.mockResolvedValue(mockServerAccount);
125
- mockCdpClient.solana.signTransaction = jest
126
- .fn()
127
- .mockResolvedValue({ signature: MOCK_SIGNATURE });
128
+ mockCdpClient.solana.signTransaction = jest.fn().mockResolvedValue({
129
+ signedTransaction: Buffer.from("mock-signed-transaction").toString("base64"),
130
+ });
128
131
  mockConnection.getBalance.mockResolvedValue(Number(MOCK_BALANCE));
129
132
  mockConnection.getLatestBlockhash.mockResolvedValue({
130
133
  blockhash: "test-blockhash",
@@ -285,7 +288,7 @@ describe("CdpSolanaWalletProvider", () => {
285
288
  describe("native transfer", () => {
286
289
  it("should transfer SOL", async () => {
287
290
  const toAddress = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin";
288
- const amount = "1.0";
291
+ const amount = "1000000000"; // 1 SOL in lamports
289
292
  // Set a balance that's high enough to cover the transfer + fees
290
293
  mockConnection.getBalance.mockResolvedValueOnce(Number(2000000000n)); // 2 SOL
291
294
  const signature = await provider.nativeTransfer(toAddress, amount);
@@ -295,7 +298,7 @@ describe("CdpSolanaWalletProvider", () => {
295
298
  it("should handle insufficient balance", async () => {
296
299
  mockConnection.getBalance.mockResolvedValueOnce(Number(1000000n)); // 0.001 SOL
297
300
  const toAddress = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin";
298
- const amount = "1.0";
301
+ const amount = "1000000000"; // 1 SOL in lamports
299
302
  await expect(provider.nativeTransfer(toAddress, amount)).rejects.toThrow("Insufficient balance");
300
303
  });
301
304
  it("should handle invalid address", async () => {
@@ -177,7 +177,7 @@ export declare class LegacyCdpSmartWalletProvider extends EvmWalletProvider {
177
177
  * Transfer the native asset of the network.
178
178
  *
179
179
  * @param to - The destination address.
180
- * @param value - The amount to transfer in Wei.
180
+ * @param value - The amount to transfer in atomic units (Wei).
181
181
  * @returns The transaction hash.
182
182
  */
183
183
  nativeTransfer(to: Address, value: string): Promise<Hex>;
@@ -288,7 +288,7 @@ class LegacyCdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider
288
288
  * Transfer the native asset of the network.
289
289
  *
290
290
  * @param to - The destination address.
291
- * @param value - The amount to transfer in Wei.
291
+ * @param value - The amount to transfer in atomic units (Wei).
292
292
  * @returns The transaction hash.
293
293
  */
294
294
  async nativeTransfer(to, value) {
@@ -231,7 +231,7 @@ export declare class LegacyCdpWalletProvider extends EvmWalletProvider {
231
231
  * Transfer the native asset of the network.
232
232
  *
233
233
  * @param to - The destination address.
234
- * @param value - The amount to transfer in Wei.
234
+ * @param value - The amount to transfer in atomic units (Wei).
235
235
  * @returns The transaction hash.
236
236
  */
237
237
  nativeTransfer(to: `0x${string}`, value: string): Promise<`0x${string}`>;
@@ -372,7 +372,7 @@ class LegacyCdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
372
372
  * Transfer the native asset of the network.
373
373
  *
374
374
  * @param to - The destination address.
375
- * @param value - The amount to transfer in Wei.
375
+ * @param value - The amount to transfer in atomic units (Wei).
376
376
  * @returns The transaction hash.
377
377
  */
378
378
  async nativeTransfer(to, value) {
@@ -140,7 +140,7 @@ export declare class PrivyEvmDelegatedEmbeddedWalletProvider extends WalletProvi
140
140
  * Transfer the native asset of the network.
141
141
  *
142
142
  * @param to - The destination address.
143
- * @param value - The amount to transfer in Wei.
143
+ * @param value - The amount to transfer in atomic units (Wei).
144
144
  * @returns The transaction hash.
145
145
  */
146
146
  nativeTransfer(to: string, value: string): Promise<Hex>;
@@ -315,11 +315,11 @@ class PrivyEvmDelegatedEmbeddedWalletProvider extends walletProvider_1.WalletPro
315
315
  * Transfer the native asset of the network.
316
316
  *
317
317
  * @param to - The destination address.
318
- * @param value - The amount to transfer in Wei.
318
+ * @param value - The amount to transfer in atomic units (Wei).
319
319
  * @returns The transaction hash.
320
320
  */
321
321
  async nativeTransfer(to, value) {
322
- const valueInWei = (0, viem_1.parseEther)(value);
322
+ const valueInWei = BigInt(value);
323
323
  const valueHex = `0x${valueInWei.toString(16)}`;
324
324
  const body = {
325
325
  address: __classPrivateFieldGet(this, _PrivyEvmDelegatedEmbeddedWalletProvider_address, "f"),
@@ -211,7 +211,7 @@ describe("PrivyEvmDelegatedEmbeddedWalletProvider", () => {
211
211
  });
212
212
  });
213
213
  it("should transfer native tokens", async () => {
214
- const result = await provider.nativeTransfer("0x1234567890123456789012345678901234567890", "1.0");
214
+ const result = await provider.nativeTransfer("0x1234567890123456789012345678901234567890", "1000000000000000000");
215
215
  expect(result).toBe(MOCK_TRANSACTION_HASH);
216
216
  });
217
217
  it("should export wallet data", () => {
@@ -272,7 +272,7 @@ describe("PrivyEvmWalletProvider", () => {
272
272
  expect(result).toBe("mock_result");
273
273
  });
274
274
  it("should transfer native tokens", async () => {
275
- const result = await provider.nativeTransfer("0x1234567890123456789012345678901234567890", "1.0");
275
+ const result = await provider.nativeTransfer("0x1234567890123456789012345678901234567890", "1000000000000000000");
276
276
  expect(result).toBe(MOCK_TRANSACTION_HASH);
277
277
  });
278
278
  it("should export wallet data", () => {
@@ -129,7 +129,7 @@ export declare class SolanaKeypairWalletProvider extends SvmWalletProvider {
129
129
  * Transfer SOL from the wallet to another address
130
130
  *
131
131
  * @param to - The base58 encoded address to transfer the SOL to
132
- * @param value - The amount of SOL to transfer (as a decimal string, e.g. "0.0001")
132
+ * @param value - The amount to transfer in atomic units (Lamports)
133
133
  * @returns The signature
134
134
  */
135
135
  nativeTransfer(to: string, value: string): Promise<string>;
@@ -231,16 +231,15 @@ class SolanaKeypairWalletProvider extends svmWalletProvider_1.SvmWalletProvider
231
231
  * Transfer SOL from the wallet to another address
232
232
  *
233
233
  * @param to - The base58 encoded address to transfer the SOL to
234
- * @param value - The amount of SOL to transfer (as a decimal string, e.g. "0.0001")
234
+ * @param value - The amount to transfer in atomic units (Lamports)
235
235
  * @returns The signature
236
236
  */
237
237
  async nativeTransfer(to, value) {
238
238
  const initialBalance = await this.getBalance();
239
- const solAmount = parseFloat(value);
240
- const lamports = BigInt(Math.floor(solAmount * web3_js_1.LAMPORTS_PER_SOL));
239
+ const lamports = BigInt(value);
241
240
  // Check if we have enough balance (including estimated fees)
242
241
  if (initialBalance < lamports + BigInt(5000)) {
243
- throw new Error(`Insufficient balance. Have ${Number(initialBalance) / web3_js_1.LAMPORTS_PER_SOL} SOL, need ${solAmount + 0.000005} SOL (including fees)`);
242
+ throw new Error(`Insufficient balance. Have ${Number(initialBalance)} lamports, need ${Number(lamports) + 5000} lamports (including fees)`);
244
243
  }
245
244
  const toPubkey = new web3_js_1.PublicKey(to);
246
245
  const instructions = [
@@ -183,14 +183,16 @@ describe("SolanaKeypairWalletProvider", () => {
183
183
  });
184
184
  it("should transfer native tokens", async () => {
185
185
  const destination = "EQJqzeeVEnm8rKWQJ5SMTtQBD4xEgixwgzNWKkpeFRZ9";
186
- const signature = await wallet.nativeTransfer(destination, "0.1");
186
+ const signature = await wallet.nativeTransfer(destination, "100000000"); // 0.1 SOL in lamports
187
187
  expect(signature).toBe("signature123");
188
188
  });
189
189
  it("should handle insufficient balance when transferring", async () => {
190
190
  const connection = wallet.getConnection();
191
191
  connection.getBalance.mockResolvedValueOnce(100);
192
192
  const destination = "EQJqzeeVEnm8rKWQJ5SMTtQBD4xEgixwgzNWKkpeFRZ9";
193
- await expect(wallet.nativeTransfer(destination, "1.0")).rejects.toThrow("Insufficient balance");
193
+ await expect(wallet.nativeTransfer(destination, "1000000000")).rejects.toThrow(
194
+ // 1 SOL in lamports
195
+ "Insufficient balance");
194
196
  });
195
197
  it("should handle transaction failure when sending", async () => {
196
198
  const connection = wallet.getConnection();
@@ -106,7 +106,7 @@ export declare class ViemWalletProvider extends EvmWalletProvider {
106
106
  * Transfer the native asset of the network.
107
107
  *
108
108
  * @param to - The destination address.
109
- * @param value - The amount to transfer in whole units (e.g. ETH)
109
+ * @param value - The amount to transfer in atomic units (Wei)
110
110
  * @returns The transaction hash.
111
111
  */
112
112
  nativeTransfer(to: `0x${string}`, value: string): Promise<`0x${string}`>;
@@ -195,11 +195,11 @@ class ViemWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
195
195
  * Transfer the native asset of the network.
196
196
  *
197
197
  * @param to - The destination address.
198
- * @param value - The amount to transfer in whole units (e.g. ETH)
198
+ * @param value - The amount to transfer in atomic units (Wei)
199
199
  * @returns The transaction hash.
200
200
  */
201
201
  async nativeTransfer(to, value) {
202
- const atomicAmount = (0, viem_1.parseEther)(value);
202
+ const atomicAmount = BigInt(value);
203
203
  const tx = await this.sendTransaction({
204
204
  to: to,
205
205
  value: atomicAmount,
@@ -284,15 +284,16 @@ describe("ViemWalletProvider", () => {
284
284
  });
285
285
  describe("native token operations", () => {
286
286
  it("should transfer native tokens", async () => {
287
- viem.parseEther.mockReturnValueOnce(BigInt(1000000000000000000));
288
- const hash = await provider.nativeTransfer(MOCK_ADDRESS_TO, "1.0");
289
- expect(viem.parseEther).toHaveBeenCalledWith("1.0");
290
- expect(mockWalletClient.sendTransaction).toHaveBeenCalled();
287
+ const hash = await provider.nativeTransfer(MOCK_ADDRESS_TO, "1000000000000000000");
288
+ expect(mockWalletClient.sendTransaction).toHaveBeenCalledWith(expect.objectContaining({
289
+ to: MOCK_ADDRESS_TO,
290
+ value: BigInt("1000000000000000000"),
291
+ }));
291
292
  expect(hash).toBe(MOCK_TRANSACTION_HASH);
292
293
  });
293
294
  it("should handle native transfer errors", async () => {
294
295
  mockWalletClient.sendTransaction.mockRejectedValueOnce(new Error("Transaction failed"));
295
- await expect(provider.nativeTransfer(MOCK_ADDRESS_TO, "1.0")).rejects.toThrow("Transaction failed");
296
+ await expect(provider.nativeTransfer(MOCK_ADDRESS_TO, "1000000000000000000")).rejects.toThrow("Transaction failed");
296
297
  });
297
298
  it("should handle invalid address in native transfer", async () => {
298
299
  const invalidAddress = "not_a_valid_address";
@@ -41,7 +41,7 @@ export declare abstract class WalletProvider {
41
41
  * Transfer the native asset of the network.
42
42
  *
43
43
  * @param to - The destination address.
44
- * @param value - The amount to transfer in whole units (e.g. ETH)
44
+ * @param value - The amount to transfer in atomic units (e.g. Wei for EVM, Lamports for Solana)
45
45
  * @returns The transaction hash.
46
46
  */
47
47
  abstract nativeTransfer(to: string, value: string): Promise<string>;
@@ -129,7 +129,7 @@ export declare class ZeroDevWalletProvider extends EvmWalletProvider {
129
129
  * Transfer the native asset of the network.
130
130
  *
131
131
  * @param to - The destination address.
132
- * @param value - The amount to transfer in whole units (e.g. ETH).
132
+ * @param value - The amount to transfer in atomic units (Wei).
133
133
  * @returns The transaction hash.
134
134
  */
135
135
  nativeTransfer(to: string, value: string): Promise<string>;
@@ -74,9 +74,10 @@ class ZeroDevWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
74
74
  const chain = network_1.NETWORK_ID_TO_VIEM_CHAIN[networkId];
75
75
  const bundlerRpc = `https://rpc.zerodev.app/api/v3/bundler/${config.projectId}`;
76
76
  // Create public client
77
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
77
78
  const publicClient = (0, viem_1.createPublicClient)({
78
79
  chain,
79
- transport: (0, viem_1.http)(),
80
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
80
81
  });
81
82
  // Create ECDSA validator
82
83
  const entryPoint = (0, constants_1.getEntryPoint)(config.entryPointVersion || "0.7");
@@ -251,12 +252,11 @@ class ZeroDevWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
251
252
  * Transfer the native asset of the network.
252
253
  *
253
254
  * @param to - The destination address.
254
- * @param value - The amount to transfer in whole units (e.g. ETH).
255
+ * @param value - The amount to transfer in atomic units (Wei).
255
256
  * @returns The transaction hash.
256
257
  */
257
258
  async nativeTransfer(to, value) {
258
- // Convert value to wei (assuming value is in whole units)
259
- const valueInWei = BigInt(parseFloat(value) * 10 ** 18);
259
+ const valueInWei = BigInt(value);
260
260
  // Get the chain ID from the network
261
261
  const chainId = parseInt(__classPrivateFieldGet(this, _ZeroDevWalletProvider_network, "f").chainId || "1");
262
262
  const intent = await __classPrivateFieldGet(this, _ZeroDevWalletProvider_intentClient, "f").sendUserIntent({
@@ -283,8 +283,8 @@ describe("ZeroDevWalletProvider", () => {
283
283
  });
284
284
  it("should handle native transfers using nativeTransfer method", async () => {
285
285
  const to = "0x1234567890123456789012345678901234567890";
286
- const value = "1.0";
287
- const valueInWei = BigInt(parseFloat(value) * 10 ** 18);
286
+ const value = "1000000000000000000"; // 1 ETH in wei
287
+ const valueInWei = BigInt(value);
288
288
  const txHash = await provider.nativeTransfer(to, value);
289
289
  expect(mockIntentClient.sendUserIntent).toHaveBeenCalledWith({
290
290
  calls: [
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.0.0-nightly-20250904210426",
5
+ "version": "0.0.0-nightly-20250906210355",
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.36.0",
27
+ "@coinbase/cdp-sdk": "^1.36.1",
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",
@@ -38,6 +38,7 @@
38
38
  "axios": "^1.9.0",
39
39
  "bs58": "^4.0.1",
40
40
  "canonicalize": "^2.1.0",
41
+ "clanker-sdk": "^4.1.18",
41
42
  "decimal.js": "^10.5.0",
42
43
  "ethers": "^6.13.5",
43
44
  "graphql-request": "^7.2.0",