@coinbase/agentkit 0.0.0-nightly-20250808210408 → 0.0.0-nightly-20250816210354

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 (39) hide show
  1. package/README.md +26 -0
  2. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +43 -0
  3. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +151 -0
  4. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.d.ts +1 -0
  5. package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +242 -0
  6. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +42 -0
  7. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +132 -0
  8. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.d.ts +1 -0
  9. package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +199 -0
  10. package/dist/action-providers/cdp/index.d.ts +3 -0
  11. package/dist/action-providers/cdp/index.js +3 -0
  12. package/dist/action-providers/cdp/schemas.d.ts +29 -0
  13. package/dist/action-providers/cdp/schemas.js +32 -1
  14. package/dist/action-providers/cdp/spendPermissionUtils.d.ts +24 -0
  15. package/dist/action-providers/cdp/spendPermissionUtils.js +66 -0
  16. package/dist/action-providers/flaunch/flaunchActionProvider.js +3 -11
  17. package/dist/action-providers/flaunch/flaunchActionProvider.test.js +5 -0
  18. package/dist/action-providers/truemarkets/truemarketsActionProvider.d.ts +4 -16
  19. package/dist/action-providers/truemarkets/truemarketsActionProvider.js +10 -31
  20. package/dist/action-providers/truemarkets/truemarketsActionProvider.test.js +11 -33
  21. package/dist/wallet-providers/cdpEvmWalletProvider.d.ts +7 -1
  22. package/dist/wallet-providers/cdpEvmWalletProvider.js +10 -1
  23. package/dist/wallet-providers/cdpShared.d.ts +5 -0
  24. package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +9 -2
  25. package/dist/wallet-providers/cdpSmartWalletProvider.js +20 -12
  26. package/dist/wallet-providers/evmWalletProvider.d.ts +5 -1
  27. package/dist/wallet-providers/legacyCdpSmartWalletProvider.d.ts +8 -1
  28. package/dist/wallet-providers/legacyCdpSmartWalletProvider.js +11 -1
  29. package/dist/wallet-providers/legacyCdpWalletProvider.d.ts +11 -1
  30. package/dist/wallet-providers/legacyCdpWalletProvider.js +10 -1
  31. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +9 -1
  32. package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +10 -1
  33. package/dist/wallet-providers/privyEvmWalletProvider.d.ts +2 -0
  34. package/dist/wallet-providers/privyEvmWalletProvider.js +2 -1
  35. package/dist/wallet-providers/viemWalletProvider.d.ts +7 -1
  36. package/dist/wallet-providers/viemWalletProvider.js +8 -0
  37. package/dist/wallet-providers/zeroDevWalletProvider.d.ts +9 -1
  38. package/dist/wallet-providers/zeroDevWalletProvider.js +10 -1
  39. package/package.json +2 -2
@@ -2,29 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const truemarketsActionProvider_1 = require("./truemarketsActionProvider");
4
4
  const constants_1 = require("./constants");
5
- const viem_1 = require("viem");
6
- // Mock viem's createPublicClient
7
- jest.mock("viem", () => {
8
- const originalModule = jest.requireActual("viem");
9
- return {
10
- ...originalModule,
11
- createPublicClient: jest.fn().mockImplementation(() => ({
12
- // Mock public client methods as needed
13
- multicall: jest.fn().mockImplementation(({ contracts }) => {
14
- // Create mock responses with success status
15
- return contracts.map(() => ({
16
- status: "success",
17
- result: "mock result",
18
- }));
19
- }),
20
- readContract: jest.fn(),
21
- })),
22
- http: jest.fn().mockImplementation(url => ({ url })),
23
- };
24
- });
25
5
  describe("TrueMarketsActionProvider", () => {
26
6
  let provider;
27
7
  let mockWallet;
8
+ let publicClientMock;
28
9
  // Mock addresses and data for tests
29
10
  const MOCK_MARKET_ADDRESS = "0x1234567890123456789012345678901234567890";
30
11
  const MOCK_YES_POOL_ADDRESS = "0x2345678901234567890123456789012345678901";
@@ -36,26 +17,22 @@ describe("TrueMarketsActionProvider", () => {
36
17
  const MOCK_MARKET_SOURCE = "Test source";
37
18
  const MOCK_STATUS_NUM = 0n; // Created status
38
19
  const MOCK_END_OF_TRADING = 1717171717n; // Unix timestamp
39
- describe("constructor", () => {
40
- it("should use the provided RPC_URL for the public client", () => {
41
- const customRpcUrl = "https://custom-rpc.example.com";
42
- (0, truemarketsActionProvider_1.truemarketsActionProvider)({ RPC_URL: customRpcUrl });
43
- // Verify createPublicClient was called with the correct URL
44
- expect(viem_1.createPublicClient).toHaveBeenCalledWith(expect.objectContaining({
45
- chain: expect.anything(),
46
- transport: expect.objectContaining({ url: customRpcUrl }),
47
- }));
48
- });
49
- });
50
20
  beforeEach(() => {
51
21
  jest.clearAllMocks();
52
22
  provider = (0, truemarketsActionProvider_1.truemarketsActionProvider)();
23
+ publicClientMock = {
24
+ multicall: jest
25
+ .fn()
26
+ .mockImplementation(({ contracts }) => contracts.map(() => ({ status: "success", result: "mock result" }))),
27
+ readContract: jest.fn(),
28
+ };
53
29
  mockWallet = {
54
30
  readContract: jest.fn(),
55
31
  getName: jest.fn().mockReturnValue("evm_wallet_provider"),
56
32
  getNetwork: jest.fn().mockReturnValue({
57
33
  networkId: "base-mainnet",
58
34
  }),
35
+ getPublicClient: jest.fn().mockReturnValue(publicClientMock),
59
36
  };
60
37
  });
61
38
  afterEach(() => {
@@ -134,8 +111,9 @@ describe("TrueMarketsActionProvider", () => {
134
111
  describe("getPredictionMarketDetails", () => {
135
112
  let mockPublicClient;
136
113
  beforeEach(() => {
137
- // Access the mocked public client
138
- mockPublicClient = viem_1.createPublicClient.mock.results[0].value;
114
+ // Use the shared mocked public client
115
+ mockPublicClient = publicClientMock;
116
+ mockPublicClient.multicall.mockReset();
139
117
  // Setup multicall mock responses
140
118
  mockPublicClient.multicall
141
119
  // Basic info calls
@@ -1,5 +1,5 @@
1
1
  import { CdpClient } from "@coinbase/cdp-sdk";
2
- import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionRequest } from "viem";
2
+ import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, PublicClient, ReadContractParameters, ReadContractReturnType, TransactionRequest } from "viem";
3
3
  import { Network } from "../network";
4
4
  import { EvmWalletProvider } from "./evmWalletProvider";
5
5
  import { WalletProviderWithClient, CdpWalletProviderConfig } from "./cdpShared";
@@ -83,6 +83,12 @@ export declare class CdpEvmWalletProvider extends EvmWalletProvider implements W
83
83
  * @returns The CDP client.
84
84
  */
85
85
  getClient(): CdpClient;
86
+ /**
87
+ * Gets the Viem PublicClient used for read-only operations.
88
+ *
89
+ * @returns The Viem PublicClient instance used for read-only operations.
90
+ */
91
+ getPublicClient(): PublicClient;
86
92
  /**
87
93
  * Gets the balance of the wallet.
88
94
  *
@@ -67,9 +67,10 @@ class CdpEvmWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
67
67
  const serverAccount = await (config.address
68
68
  ? cdpClient.evm.getAccount({ address: config.address })
69
69
  : cdpClient.evm.createAccount({ idempotencyKey }));
70
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
70
71
  const publicClient = (0, viem_1.createPublicClient)({
71
72
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[networkId],
72
- transport: (0, viem_1.http)(),
73
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
73
74
  });
74
75
  return new CdpEvmWalletProvider({
75
76
  publicClient,
@@ -188,6 +189,14 @@ class CdpEvmWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
188
189
  getClient() {
189
190
  return __classPrivateFieldGet(this, _CdpEvmWalletProvider_cdp, "f");
190
191
  }
192
+ /**
193
+ * Gets the Viem PublicClient used for read-only operations.
194
+ *
195
+ * @returns The Viem PublicClient instance used for read-only operations.
196
+ */
197
+ getPublicClient() {
198
+ return __classPrivateFieldGet(this, _CdpEvmWalletProvider_publicClient, "f");
199
+ }
191
200
  /**
192
201
  * Gets the balance of the wallet.
193
202
  *
@@ -30,6 +30,11 @@ export interface CdpWalletProviderConfig extends CdpProviderConfig {
30
30
  * The idempotency key of the wallet. Only used when creating a new account.
31
31
  */
32
32
  idempotencyKey?: string;
33
+ /**
34
+ * Optional RPC URL for Viem public client HTTP transport.
35
+ * Falls back to process.env.RPC_URL when not provided.
36
+ */
37
+ rpcUrl?: string;
33
38
  }
34
39
  export interface CdpSmartWalletProviderConfig extends CdpWalletProviderConfig {
35
40
  /**
@@ -1,5 +1,5 @@
1
- import { CdpClient } from "@coinbase/cdp-sdk";
2
- import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionRequest } from "viem";
1
+ import { CdpClient, EvmSmartAccount } from "@coinbase/cdp-sdk";
2
+ import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, PublicClient, ReadContractParameters, ReadContractReturnType, TransactionRequest } from "viem";
3
3
  import { Network } from "../network";
4
4
  import { EvmWalletProvider } from "./evmWalletProvider";
5
5
  import { WalletProviderWithClient, CdpSmartWalletProviderConfig } from "./cdpShared";
@@ -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
  *
@@ -90,6 +91,12 @@ export declare class CdpSmartWalletProvider extends EvmWalletProvider implements
90
91
  * @returns The paymaster URL if configured, undefined otherwise.
91
92
  */
92
93
  getPaymasterUrl(): string | undefined;
94
+ /**
95
+ * Gets the Viem PublicClient used for read-only operations.
96
+ *
97
+ * @returns The Viem PublicClient instance used for read-only operations.
98
+ */
99
+ getPublicClient(): PublicClient;
93
100
  /**
94
101
  * Gets the balance of the smart wallet.
95
102
  *
@@ -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_paymasterUrl, _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,12 +30,11 @@ 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
36
  _CdpSmartWalletProvider_paymasterUrl.set(this, void 0);
38
- __classPrivateFieldSet(this, _CdpSmartWalletProvider_smartAccount, config.smartAccount, "f");
37
+ this.smartAccount = config.smartAccount;
39
38
  __classPrivateFieldSet(this, _CdpSmartWalletProvider_ownerAccount, config.ownerAccount, "f");
40
39
  __classPrivateFieldSet(this, _CdpSmartWalletProvider_cdp, config.cdp, "f");
41
40
  __classPrivateFieldSet(this, _CdpSmartWalletProvider_publicClient, config.publicClient, "f");
@@ -93,9 +92,10 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
93
92
  : cdpClient.evm.createSmartAccount({
94
93
  owner: ownerAccount,
95
94
  }));
95
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
96
96
  const publicClient = (0, viem_1.createPublicClient)({
97
97
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[networkId],
98
- transport: (0, viem_1.http)(),
98
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
99
99
  });
100
100
  return new CdpSmartWalletProvider({
101
101
  publicClient,
@@ -113,8 +113,8 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
113
113
  */
114
114
  async exportWallet() {
115
115
  return {
116
- name: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").name,
117
- address: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address,
116
+ name: this.smartAccount.name,
117
+ address: this.smartAccount.address,
118
118
  ownerAddress: __classPrivateFieldGet(this, _CdpSmartWalletProvider_ownerAccount, "f").address,
119
119
  };
120
120
  }
@@ -136,7 +136,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
136
136
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
137
137
  async signTypedData(typedData) {
138
138
  const { domain, types, primaryType, message } = typedData;
139
- return await __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").signTypedData({
139
+ return await this.smartAccount.signTypedData({
140
140
  domain,
141
141
  types,
142
142
  primaryType,
@@ -168,7 +168,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
168
168
  },
169
169
  ];
170
170
  const userOperation = await __classPrivateFieldGet(this, _CdpSmartWalletProvider_cdp, "f").evm.sendUserOperation({
171
- smartAccount: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f"),
171
+ smartAccount: this.smartAccount,
172
172
  network: __classPrivateFieldGet(this, _CdpSmartWalletProvider_instances, "m", _CdpSmartWalletProvider_getCdpSdkNetwork).call(this),
173
173
  calls,
174
174
  paymasterUrl: __classPrivateFieldGet(this, _CdpSmartWalletProvider_paymasterUrl, "f"),
@@ -181,7 +181,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
181
181
  * @returns The address of the smart wallet.
182
182
  */
183
183
  getAddress() {
184
- return __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address;
184
+ return this.smartAccount.address;
185
185
  }
186
186
  /**
187
187
  * Gets the network of the wallet.
@@ -215,13 +215,21 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
215
215
  getPaymasterUrl() {
216
216
  return __classPrivateFieldGet(this, _CdpSmartWalletProvider_paymasterUrl, "f");
217
217
  }
218
+ /**
219
+ * Gets the Viem PublicClient used for read-only operations.
220
+ *
221
+ * @returns The Viem PublicClient instance used for read-only operations.
222
+ */
223
+ getPublicClient() {
224
+ return __classPrivateFieldGet(this, _CdpSmartWalletProvider_publicClient, "f");
225
+ }
218
226
  /**
219
227
  * Gets the balance of the smart wallet.
220
228
  *
221
229
  * @returns The balance of the wallet in wei
222
230
  */
223
231
  async getBalance() {
224
- return await __classPrivateFieldGet(this, _CdpSmartWalletProvider_publicClient, "f").getBalance({ address: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address });
232
+ return await __classPrivateFieldGet(this, _CdpSmartWalletProvider_publicClient, "f").getBalance({ address: this.smartAccount.address });
225
233
  }
226
234
  /**
227
235
  * Waits for a user operation receipt.
@@ -235,7 +243,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
235
243
  // This is a simplified implementation - in practice you might want to poll
236
244
  // the CDP API for user operation status
237
245
  return __classPrivateFieldGet(this, _CdpSmartWalletProvider_cdp, "f").evm.waitForUserOperation({
238
- smartAccountAddress: __classPrivateFieldGet(this, _CdpSmartWalletProvider_smartAccount, "f").address,
246
+ smartAccountAddress: this.smartAccount.address,
239
247
  userOpHash,
240
248
  });
241
249
  }
@@ -264,7 +272,7 @@ class CdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
264
272
  }
265
273
  }
266
274
  exports.CdpSmartWalletProvider = CdpSmartWalletProvider;
267
- _CdpSmartWalletProvider_publicClient = new WeakMap(), _CdpSmartWalletProvider_smartAccount = 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() {
275
+ _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() {
268
276
  switch (__classPrivateFieldGet(this, _CdpSmartWalletProvider_network, "f").networkId) {
269
277
  case "base-sepolia":
270
278
  return "base-sepolia";
@@ -1,5 +1,5 @@
1
1
  import { WalletProvider } from "./walletProvider";
2
- import { TransactionRequest, ReadContractParameters, ReadContractReturnType, ContractFunctionName, Abi, ContractFunctionArgs, Account } from "viem";
2
+ import { TransactionRequest, ReadContractParameters, ReadContractReturnType, ContractFunctionName, Abi, ContractFunctionArgs, Account, PublicClient } from "viem";
3
3
  /**
4
4
  * EvmWalletProvider is the abstract base class for all EVM wallet providers.
5
5
  *
@@ -54,4 +54,8 @@ export declare abstract class EvmWalletProvider extends WalletProvider {
54
54
  * @returns The response from the contract.
55
55
  */
56
56
  abstract readContract<const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi, "pure" | "view">, const args extends ContractFunctionArgs<abi, "pure" | "view", functionName>>(params: ReadContractParameters<abi, functionName, args>): Promise<ReadContractReturnType<abi, functionName, args>>;
57
+ /**
58
+ * Get the underlying Viem PublicClient for read-only blockchain operations.
59
+ */
60
+ abstract getPublicClient(): PublicClient;
57
61
  }
@@ -1,5 +1,5 @@
1
1
  import { SendUserOperationOptions, Signer } from "@coinbase/coinbase-sdk";
2
- import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionRequest } from "viem";
2
+ import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionRequest, PublicClient as ViemPublicClient } from "viem";
3
3
  import { Network } from "../network";
4
4
  import { EvmWalletProvider } from "./evmWalletProvider";
5
5
  export interface ConfigureLegacyCdpSmartWalletOptions {
@@ -9,6 +9,7 @@ export interface ConfigureLegacyCdpSmartWalletOptions {
9
9
  smartWalletAddress?: Hex;
10
10
  paymasterUrl?: string;
11
11
  signer: Signer;
12
+ rpcUrl?: string;
12
13
  }
13
14
  /**
14
15
  * A wallet provider that uses Smart Wallets from the Coinbase SDK.
@@ -146,6 +147,12 @@ export declare class LegacyCdpSmartWalletProvider extends EvmWalletProvider {
146
147
  * @returns The name of the wallet provider.
147
148
  */
148
149
  getName(): string;
150
+ /**
151
+ * Gets the Viem PublicClient used for read-only operations.
152
+ *
153
+ * @returns The Viem PublicClient instance used for read-only operations.
154
+ */
155
+ getPublicClient(): ViemPublicClient;
149
156
  /**
150
157
  * Gets the balance of the wallet.
151
158
  *
@@ -34,9 +34,10 @@ class LegacyCdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider
34
34
  _LegacyCdpSmartWalletProvider_publicClient.set(this, void 0);
35
35
  __classPrivateFieldSet(this, _LegacyCdpSmartWalletProvider_network, config.network, "f");
36
36
  __classPrivateFieldSet(this, _LegacyCdpSmartWalletProvider_smartWallet, config.smartWallet, "f");
37
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
37
38
  __classPrivateFieldSet(this, _LegacyCdpSmartWalletProvider_publicClient, (0, viem_1.createPublicClient)({
38
39
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[config.network.networkId],
39
- transport: (0, viem_1.http)(),
40
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
40
41
  }), "f");
41
42
  }
42
43
  /**
@@ -106,6 +107,7 @@ class LegacyCdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider
106
107
  smartWallet: networkScopedSmartWallet,
107
108
  network,
108
109
  chainId: network.chainId,
110
+ rpcUrl: config.rpcUrl,
109
111
  });
110
112
  return legacyCdpSmartWalletProvider;
111
113
  }
@@ -242,6 +244,14 @@ class LegacyCdpSmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider
242
244
  getName() {
243
245
  return "legacy_cdp_smart_wallet_provider";
244
246
  }
247
+ /**
248
+ * Gets the Viem PublicClient used for read-only operations.
249
+ *
250
+ * @returns The Viem PublicClient instance used for read-only operations.
251
+ */
252
+ getPublicClient() {
253
+ return __classPrivateFieldGet(this, _LegacyCdpSmartWalletProvider_publicClient, "f");
254
+ }
245
255
  /**
246
256
  * Gets the balance of the wallet.
247
257
  *
@@ -1,4 +1,4 @@
1
- import { ReadContractParameters, ReadContractReturnType, TransactionRequest, TransactionSerializable, Abi, ContractFunctionName, ContractFunctionArgs, Address, Hex } from "viem";
1
+ import { ReadContractParameters, ReadContractReturnType, TransactionRequest, TransactionSerializable, PublicClient, Abi, ContractFunctionName, ContractFunctionArgs, Address, Hex } from "viem";
2
2
  import { EvmWalletProvider } from "./evmWalletProvider";
3
3
  import { Network } from "../network";
4
4
  import { Coinbase, CreateERC20Options, CreateTradeOptions, SmartContract, Trade, Wallet, WalletData } from "@coinbase/coinbase-sdk";
@@ -50,6 +50,10 @@ export interface LegacyCdpWalletProviderConfig extends LegacyCdpProviderConfig {
50
50
  */
51
51
  feePerGasMultiplier?: number;
52
52
  };
53
+ /**
54
+ * Optional RPC URL for Viem public client.
55
+ */
56
+ rpcUrl?: string;
53
57
  }
54
58
  /**
55
59
  * Configuration options for the CDP Agentkit with a Wallet.
@@ -148,6 +152,12 @@ export declare class LegacyCdpWalletProvider extends EvmWalletProvider {
148
152
  * @returns The name of the wallet provider.
149
153
  */
150
154
  getName(): string;
155
+ /**
156
+ * Gets the Viem PublicClient used for read-only operations.
157
+ *
158
+ * @returns The Viem PublicClient instance used for read-only operations.
159
+ */
160
+ getPublicClient(): PublicClient;
151
161
  /**
152
162
  * Gets the balance of the wallet.
153
163
  *
@@ -43,9 +43,10 @@ class LegacyCdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
43
43
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_cdpWallet, config.wallet, "f");
44
44
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_address, config.address, "f");
45
45
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_network, config.network, "f");
46
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
46
47
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_publicClient, (0, viem_1.createPublicClient)({
47
48
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[config.network.networkId],
48
- transport: (0, viem_1.http)(),
49
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
49
50
  }), "f");
50
51
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_gasLimitMultiplier, Math.max(config.gas?.gasLimitMultiplier ?? 1.2, 1), "f");
51
52
  __classPrivateFieldSet(this, _LegacyCdpWalletProvider_feePerGasMultiplier, Math.max(config.gas?.feePerGasMultiplier ?? 1, 1), "f");
@@ -268,6 +269,14 @@ class LegacyCdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
268
269
  getName() {
269
270
  return "legacy_cdp_wallet_provider";
270
271
  }
272
+ /**
273
+ * Gets the Viem PublicClient used for read-only operations.
274
+ *
275
+ * @returns The Viem PublicClient instance used for read-only operations.
276
+ */
277
+ getPublicClient() {
278
+ return __classPrivateFieldGet(this, _LegacyCdpWalletProvider_publicClient, "f");
279
+ }
271
280
  /**
272
281
  * Gets the balance of the wallet.
273
282
  *
@@ -1,4 +1,4 @@
1
- import { Abi, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionReceipt, TransactionRequest } from "viem";
1
+ import { Abi, ContractFunctionArgs, ContractFunctionName, Hex, PublicClient, ReadContractParameters, ReadContractReturnType, TransactionReceipt, TransactionRequest } from "viem";
2
2
  import { Network } from "../network";
3
3
  import { PrivyWalletConfig, PrivyWalletExport } from "./privyShared";
4
4
  import { WalletProvider } from "./walletProvider";
@@ -14,6 +14,8 @@ export interface PrivyEvmDelegatedEmbeddedWalletConfig extends PrivyWalletConfig
14
14
  chainId?: string;
15
15
  /** The wallet type to use */
16
16
  walletType: "embedded";
17
+ /** Optional RPC URL for Viem public client */
18
+ rpcUrl?: string;
17
19
  }
18
20
  /**
19
21
  * A wallet provider that uses Privy's embedded wallets with delegation.
@@ -64,6 +66,12 @@ export declare class PrivyEvmDelegatedEmbeddedWalletProvider extends WalletProvi
64
66
  * @returns The name of the wallet provider.
65
67
  */
66
68
  getName(): string;
69
+ /**
70
+ * Gets the Viem PublicClient used for read-only operations.
71
+ *
72
+ * @returns The Viem PublicClient instance used for read-only operations.
73
+ */
74
+ getPublicClient(): PublicClient;
67
75
  /**
68
76
  * Gets the balance of the wallet.
69
77
  *
@@ -59,9 +59,10 @@ class PrivyEvmDelegatedEmbeddedWalletProvider extends walletProvider_1.WalletPro
59
59
  if (!chain) {
60
60
  throw new Error(`Chain with ID ${chainId} not found`);
61
61
  }
62
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
62
63
  __classPrivateFieldSet(this, _PrivyEvmDelegatedEmbeddedWalletProvider_publicClient, (0, viem_1.createPublicClient)({
63
64
  chain,
64
- transport: (0, viem_1.http)(),
65
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
65
66
  }), "f");
66
67
  }
67
68
  /**
@@ -142,6 +143,14 @@ class PrivyEvmDelegatedEmbeddedWalletProvider extends walletProvider_1.WalletPro
142
143
  getName() {
143
144
  return "privy_evm_embedded_wallet_provider";
144
145
  }
146
+ /**
147
+ * Gets the Viem PublicClient used for read-only operations.
148
+ *
149
+ * @returns The Viem PublicClient instance used for read-only operations.
150
+ */
151
+ getPublicClient() {
152
+ return __classPrivateFieldGet(this, _PrivyEvmDelegatedEmbeddedWalletProvider_publicClient, "f");
153
+ }
145
154
  /**
146
155
  * Gets the balance of the wallet.
147
156
  *
@@ -8,6 +8,8 @@ import { PrivyWalletConfig, PrivyWalletExport } from "./privyShared";
8
8
  export interface PrivyEvmWalletConfig extends PrivyWalletConfig {
9
9
  /** Optional chain ID to connect to */
10
10
  chainId?: string;
11
+ /** Optional RPC URL override for Viem wallet/public clients */
12
+ rpcUrl?: string;
11
13
  }
12
14
  /**
13
15
  * A wallet provider that uses Privy's server wallet API.
@@ -107,10 +107,11 @@ class PrivyEvmWalletProvider extends viemWalletProvider_1.ViemWalletProvider {
107
107
  if (!chain) {
108
108
  throw new Error(`Chain with ID ${chainId} not found`);
109
109
  }
110
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
110
111
  const walletClient = (0, viem_2.createWalletClient)({
111
112
  account,
112
113
  chain,
113
- transport: (0, viem_2.http)(),
114
+ transport: rpcUrl ? (0, viem_2.http)(rpcUrl) : (0, viem_2.http)(),
114
115
  });
115
116
  return new PrivyEvmWalletProvider(walletClient, { ...config, walletId });
116
117
  }
@@ -1,4 +1,4 @@
1
- import { WalletClient as ViemWalletClient, TransactionRequest, ReadContractParameters, ReadContractReturnType, Abi, ContractFunctionName, ContractFunctionArgs } from "viem";
1
+ import { WalletClient as ViemWalletClient, TransactionRequest, PublicClient as ViemPublicClient, ReadContractParameters, ReadContractReturnType, Abi, ContractFunctionName, ContractFunctionArgs } from "viem";
2
2
  import { EvmWalletProvider } from "./evmWalletProvider";
3
3
  import { Network } from "../network";
4
4
  /**
@@ -72,6 +72,12 @@ export declare class ViemWalletProvider extends EvmWalletProvider {
72
72
  * @returns The name of the wallet provider.
73
73
  */
74
74
  getName(): string;
75
+ /**
76
+ * Gets the Viem PublicClient used for read-only operations.
77
+ *
78
+ * @returns The Viem PublicClient instance used for read-only operations.
79
+ */
80
+ getPublicClient(): ViemPublicClient;
75
81
  /**
76
82
  * Gets the balance of the wallet.
77
83
  *
@@ -152,6 +152,14 @@ class ViemWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
152
152
  getName() {
153
153
  return "viem_wallet_provider";
154
154
  }
155
+ /**
156
+ * Gets the Viem PublicClient used for read-only operations.
157
+ *
158
+ * @returns The Viem PublicClient instance used for read-only operations.
159
+ */
160
+ getPublicClient() {
161
+ return __classPrivateFieldGet(this, _ViemWalletProvider_publicClient, "f");
162
+ }
155
163
  /**
156
164
  * Gets the balance of the wallet.
157
165
  *
@@ -1,6 +1,6 @@
1
1
  import { KernelSmartAccountImplementation } from "@zerodev/sdk";
2
2
  import { createIntentClient, type GetCABParameters, type GetCABResult } from "@zerodev/intent";
3
- import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ReadContractParameters, ReadContractReturnType, TransactionRequest, Hex, Hash, Account } from "viem";
3
+ import { Abi, Address, ContractFunctionArgs, ContractFunctionName, PublicClient, ReadContractParameters, ReadContractReturnType, TransactionRequest, Hex, Hash, Account } from "viem";
4
4
  import { SmartAccount } from "viem/account-abstraction";
5
5
  import { EvmWalletProvider } from "./evmWalletProvider";
6
6
  import { type Network } from "../network";
@@ -30,6 +30,8 @@ export interface ZeroDevWalletProviderConfig {
30
30
  * If not provided, it will be computed from the signer.
31
31
  */
32
32
  address?: Address;
33
+ /** Optional RPC URL override for Viem public client */
34
+ rpcUrl?: string;
33
35
  }
34
36
  /**
35
37
  * A wallet provider that uses ZeroDev's account abstraction.
@@ -111,6 +113,12 @@ export declare class ZeroDevWalletProvider extends EvmWalletProvider {
111
113
  * @returns The name of the wallet provider.
112
114
  */
113
115
  getName(): string;
116
+ /**
117
+ * Gets the Viem PublicClient used for read-only operations.
118
+ *
119
+ * @returns The Viem PublicClient instance used for read-only operations.
120
+ */
121
+ getPublicClient(): PublicClient;
114
122
  /**
115
123
  * Gets the balance of the wallet.
116
124
  *
@@ -51,9 +51,10 @@ class ZeroDevWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
51
51
  __classPrivateFieldSet(this, _ZeroDevWalletProvider_kernelAccount, kernelAccount, "f");
52
52
  __classPrivateFieldSet(this, _ZeroDevWalletProvider_intentClient, intentClient, "f");
53
53
  // Create public client
54
+ const rpcUrl = config.rpcUrl || process.env.RPC_URL;
54
55
  __classPrivateFieldSet(this, _ZeroDevWalletProvider_publicClient, (0, viem_1.createPublicClient)({
55
56
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[__classPrivateFieldGet(this, _ZeroDevWalletProvider_network, "f").networkId],
56
- transport: (0, viem_1.http)(),
57
+ transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
57
58
  }), "f");
58
59
  }
59
60
  /**
@@ -228,6 +229,14 @@ class ZeroDevWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
228
229
  getName() {
229
230
  return "zerodev_wallet_provider";
230
231
  }
232
+ /**
233
+ * Gets the Viem PublicClient used for read-only operations.
234
+ *
235
+ * @returns The Viem PublicClient instance used for read-only operations.
236
+ */
237
+ getPublicClient() {
238
+ return __classPrivateFieldGet(this, _ZeroDevWalletProvider_publicClient, "f");
239
+ }
231
240
  /**
232
241
  * Gets the balance of the wallet.
233
242
  *
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-20250808210408",
5
+ "version": "0.0.0-nightly-20250816210354",
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",