@coinbase/agentkit 0.0.0-nightly-20250424210504 → 0.0.0-nightly-20250429210433
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.
- package/README.md +142 -0
- package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +37 -0
- package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +91 -0
- package/dist/action-providers/cdp-v2/index.d.ts +2 -0
- package/dist/action-providers/cdp-v2/index.js +18 -0
- package/dist/action-providers/cdp-v2/schemas.d.ts +11 -0
- package/dist/action-providers/cdp-v2/schemas.js +13 -0
- package/dist/action-providers/compound/schemas.d.ts +8 -8
- package/dist/action-providers/flaunch/utils.js +1 -1
- package/dist/action-providers/index.d.ts +1 -0
- package/dist/action-providers/index.js +1 -0
- package/dist/action-providers/twitter/twitterActionProvider.d.ts +8 -1
- package/dist/action-providers/twitter/twitterActionProvider.js +36 -18
- package/dist/action-providers/twitter/twitterActionProvider.test.js +45 -0
- package/dist/network/svm.d.ts +1 -0
- package/dist/network/svm.js +6 -1
- package/dist/wallet-providers/cdpV2EvmWalletProvider.d.ts +105 -0
- package/dist/wallet-providers/cdpV2EvmWalletProvider.js +212 -0
- package/dist/wallet-providers/cdpV2EvmWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/cdpV2EvmWalletProvider.test.js +343 -0
- package/dist/wallet-providers/cdpV2Shared.d.ts +41 -0
- package/dist/wallet-providers/cdpV2Shared.js +2 -0
- package/dist/wallet-providers/cdpV2SolanaWalletProvider.d.ts +111 -0
- package/dist/wallet-providers/cdpV2SolanaWalletProvider.js +247 -0
- package/dist/wallet-providers/cdpV2SolanaWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/cdpV2SolanaWalletProvider.test.js +307 -0
- package/dist/wallet-providers/cdpV2WalletProvider.d.ts +35 -0
- package/dist/wallet-providers/cdpV2WalletProvider.js +42 -0
- package/dist/wallet-providers/index.d.ts +4 -0
- package/dist/wallet-providers/index.js +4 -0
- package/package.json +2 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cdp_sdk_1 = require("@coinbase/cdp-sdk");
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const cdpV2SolanaWalletProvider_1 = require("./cdpV2SolanaWalletProvider");
|
|
6
|
+
// =========================================================
|
|
7
|
+
// consts
|
|
8
|
+
// =========================================================
|
|
9
|
+
const mockConnection = {
|
|
10
|
+
sendTransaction: jest.fn(),
|
|
11
|
+
getBalance: jest.fn(),
|
|
12
|
+
getLatestBlockhash: jest.fn(),
|
|
13
|
+
getSignatureStatus: jest.fn(),
|
|
14
|
+
confirmTransaction: jest.fn(),
|
|
15
|
+
};
|
|
16
|
+
// =========================================================
|
|
17
|
+
// mocks
|
|
18
|
+
// =========================================================
|
|
19
|
+
jest.mock("../analytics", () => ({
|
|
20
|
+
sendAnalyticsEvent: jest.fn().mockImplementation(() => Promise.resolve()),
|
|
21
|
+
}));
|
|
22
|
+
jest.mock("../../package.json", () => ({
|
|
23
|
+
version: "1.0.0",
|
|
24
|
+
}));
|
|
25
|
+
jest.mock("@solana/web3.js", () => {
|
|
26
|
+
const mockPublicKey = {
|
|
27
|
+
toBase58: () => MOCK_ADDRESS,
|
|
28
|
+
equals: () => true,
|
|
29
|
+
};
|
|
30
|
+
const MockPublicKey = jest.fn(() => mockPublicKey);
|
|
31
|
+
MockPublicKey.prototype = mockPublicKey;
|
|
32
|
+
return {
|
|
33
|
+
Connection: jest.fn(() => mockConnection),
|
|
34
|
+
PublicKey: MockPublicKey,
|
|
35
|
+
VersionedTransaction: jest.fn().mockImplementation(() => ({
|
|
36
|
+
serialize: jest.fn(() => Buffer.from("mock-serialized-tx")),
|
|
37
|
+
addSignature: jest.fn(),
|
|
38
|
+
})),
|
|
39
|
+
MessageV0: {
|
|
40
|
+
compile: jest.fn(),
|
|
41
|
+
},
|
|
42
|
+
SystemProgram: {
|
|
43
|
+
transfer: jest.fn(),
|
|
44
|
+
},
|
|
45
|
+
ComputeBudgetProgram: {
|
|
46
|
+
setComputeUnitPrice: jest.fn(),
|
|
47
|
+
setComputeUnitLimit: jest.fn(),
|
|
48
|
+
},
|
|
49
|
+
clusterApiUrl: jest.fn((cluster) => {
|
|
50
|
+
switch (cluster) {
|
|
51
|
+
case "mainnet-beta":
|
|
52
|
+
return "https://api.mainnet-beta.solana.com";
|
|
53
|
+
case "devnet":
|
|
54
|
+
return "https://api.devnet.solana.com";
|
|
55
|
+
case "testnet":
|
|
56
|
+
return "https://api.testnet.solana.com";
|
|
57
|
+
default:
|
|
58
|
+
return "https://api.devnet.solana.com";
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
LAMPORTS_PER_SOL: 1000000000,
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
// Mock CdpClient
|
|
65
|
+
jest.mock("@coinbase/cdp-sdk", () => {
|
|
66
|
+
const MOCK_ADDRESS = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin";
|
|
67
|
+
const MOCK_SIGNATURE = "5HxWvvfubhXpYYpS3tJkw6fq9jE9j18THftkZjrrVHx6";
|
|
68
|
+
const mockCreateAccount = jest.fn().mockImplementation(() => Promise.resolve({
|
|
69
|
+
address: MOCK_ADDRESS,
|
|
70
|
+
signTransaction: jest.fn().mockResolvedValue({ signature: MOCK_SIGNATURE }),
|
|
71
|
+
}));
|
|
72
|
+
const mockSignTransaction = jest
|
|
73
|
+
.fn()
|
|
74
|
+
.mockImplementation(async () => ({ signature: MOCK_SIGNATURE }));
|
|
75
|
+
const mockSolanaClient = {
|
|
76
|
+
createAccount: mockCreateAccount,
|
|
77
|
+
getAccount: jest.fn(),
|
|
78
|
+
signTransaction: mockSignTransaction,
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
CdpClient: jest.fn().mockImplementation(() => ({
|
|
82
|
+
solana: mockSolanaClient,
|
|
83
|
+
})),
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
// =========================================================
|
|
87
|
+
// test constants
|
|
88
|
+
// =========================================================
|
|
89
|
+
const MOCK_ADDRESS = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin";
|
|
90
|
+
const MOCK_NETWORK_ID = "solana-mainnet";
|
|
91
|
+
const MOCK_SIGNATURE = "5HxWvvfubhXpYYpS3tJkw6fq9jE9j18THftkZjrrVHx6";
|
|
92
|
+
const MOCK_BALANCE = 1000000000n; // 1 SOL in lamports
|
|
93
|
+
const MOCK_NETWORK = {
|
|
94
|
+
protocolFamily: "svm",
|
|
95
|
+
networkId: MOCK_NETWORK_ID,
|
|
96
|
+
chainId: "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d", // Solana mainnet chain ID
|
|
97
|
+
};
|
|
98
|
+
const MOCK_SIGNATURE_RESULT = {
|
|
99
|
+
value: {
|
|
100
|
+
err: null,
|
|
101
|
+
slot: 123456,
|
|
102
|
+
confirmations: 32,
|
|
103
|
+
},
|
|
104
|
+
context: {
|
|
105
|
+
slot: 123456,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
describe("CdpV2SolanaWalletProvider", () => {
|
|
109
|
+
let provider;
|
|
110
|
+
let mockCdpClient;
|
|
111
|
+
let mockServerAccount;
|
|
112
|
+
beforeEach(async () => {
|
|
113
|
+
jest.clearAllMocks();
|
|
114
|
+
mockCdpClient = new cdp_sdk_1.CdpClient({
|
|
115
|
+
apiKeyId: "test-key-id",
|
|
116
|
+
apiKeySecret: "test-key-secret",
|
|
117
|
+
walletSecret: "test-wallet-secret",
|
|
118
|
+
});
|
|
119
|
+
mockServerAccount = {
|
|
120
|
+
address: MOCK_ADDRESS,
|
|
121
|
+
signTransaction: jest.fn().mockResolvedValue({ signature: MOCK_SIGNATURE }),
|
|
122
|
+
};
|
|
123
|
+
// Set up the mock server account for the provider
|
|
124
|
+
mockCdpClient.solana.createAccount.mockResolvedValue(mockServerAccount);
|
|
125
|
+
mockCdpClient.solana.signTransaction = jest
|
|
126
|
+
.fn()
|
|
127
|
+
.mockResolvedValue({ signature: MOCK_SIGNATURE });
|
|
128
|
+
mockConnection.getBalance.mockResolvedValue(Number(MOCK_BALANCE));
|
|
129
|
+
mockConnection.getLatestBlockhash.mockResolvedValue({
|
|
130
|
+
blockhash: "test-blockhash",
|
|
131
|
+
lastValidBlockHeight: 123456,
|
|
132
|
+
});
|
|
133
|
+
mockConnection.confirmTransaction.mockResolvedValue(MOCK_SIGNATURE_RESULT);
|
|
134
|
+
mockConnection.sendTransaction.mockResolvedValue(MOCK_SIGNATURE);
|
|
135
|
+
provider = await cdpV2SolanaWalletProvider_1.CdpV2SolanaWalletProvider.configureWithWallet({
|
|
136
|
+
apiKeyId: "test-key-id",
|
|
137
|
+
apiKeySecret: "test-key-secret",
|
|
138
|
+
walletSecret: "test-wallet-secret",
|
|
139
|
+
networkId: MOCK_NETWORK_ID,
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
// =========================================================
|
|
143
|
+
// initialization tests
|
|
144
|
+
// =========================================================
|
|
145
|
+
describe("initialization", () => {
|
|
146
|
+
it("should initialize with API keys", async () => {
|
|
147
|
+
const provider = await cdpV2SolanaWalletProvider_1.CdpV2SolanaWalletProvider.configureWithWallet({
|
|
148
|
+
apiKeyId: "test-key-id",
|
|
149
|
+
apiKeySecret: "test-key-secret",
|
|
150
|
+
walletSecret: "test-wallet-secret",
|
|
151
|
+
networkId: MOCK_NETWORK_ID,
|
|
152
|
+
});
|
|
153
|
+
expect(provider.getAddress()).toBe(MOCK_ADDRESS);
|
|
154
|
+
expect(provider.getNetwork()).toEqual(MOCK_NETWORK);
|
|
155
|
+
});
|
|
156
|
+
it("should default to solana-devnet if network not provided", async () => {
|
|
157
|
+
const provider = await cdpV2SolanaWalletProvider_1.CdpV2SolanaWalletProvider.configureWithWallet({
|
|
158
|
+
apiKeyId: "test-key-id",
|
|
159
|
+
apiKeySecret: "test-key-secret",
|
|
160
|
+
walletSecret: "test-wallet-secret",
|
|
161
|
+
});
|
|
162
|
+
expect(provider.getNetwork().networkId).toBe("solana-devnet");
|
|
163
|
+
});
|
|
164
|
+
it("should handle initialization failures gracefully", async () => {
|
|
165
|
+
const mockCreateAccount = jest.fn().mockRejectedValue(new Error("Failed to create account"));
|
|
166
|
+
const mockSolanaClient = {
|
|
167
|
+
createAccount: mockCreateAccount,
|
|
168
|
+
getAccount: jest.fn(),
|
|
169
|
+
signTransaction: jest.fn(),
|
|
170
|
+
};
|
|
171
|
+
const mockCdpClient = new cdp_sdk_1.CdpClient({
|
|
172
|
+
apiKeyId: "test-key-id",
|
|
173
|
+
apiKeySecret: "test-key-secret",
|
|
174
|
+
walletSecret: "test-wallet-secret",
|
|
175
|
+
});
|
|
176
|
+
mockCdpClient.solana = mockSolanaClient;
|
|
177
|
+
cdp_sdk_1.CdpClient.mockImplementation(() => mockCdpClient);
|
|
178
|
+
await expect(cdpV2SolanaWalletProvider_1.CdpV2SolanaWalletProvider.configureWithWallet({
|
|
179
|
+
apiKeyId: "test-key-id",
|
|
180
|
+
apiKeySecret: "test-key-secret",
|
|
181
|
+
walletSecret: "test-wallet-secret",
|
|
182
|
+
networkId: MOCK_NETWORK_ID,
|
|
183
|
+
})).rejects.toThrow("Failed to create account");
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
// =========================================================
|
|
187
|
+
// basic wallet method tests
|
|
188
|
+
// =========================================================
|
|
189
|
+
describe("basic wallet methods", () => {
|
|
190
|
+
it("should get the address", () => {
|
|
191
|
+
expect(provider.getAddress()).toBe(MOCK_ADDRESS);
|
|
192
|
+
});
|
|
193
|
+
it("should get the network", () => {
|
|
194
|
+
expect(provider.getNetwork()).toEqual(MOCK_NETWORK);
|
|
195
|
+
});
|
|
196
|
+
it("should get the name", () => {
|
|
197
|
+
expect(provider.getName()).toBe("cdp_v2_solana_wallet_provider");
|
|
198
|
+
});
|
|
199
|
+
it("should get the balance", async () => {
|
|
200
|
+
const balance = await provider.getBalance();
|
|
201
|
+
expect(balance).toBe(MOCK_BALANCE);
|
|
202
|
+
expect(mockConnection.getBalance).toHaveBeenCalledWith(expect.any(Object));
|
|
203
|
+
});
|
|
204
|
+
it("should handle connection errors during balance check", async () => {
|
|
205
|
+
mockConnection.getBalance.mockRejectedValueOnce(new Error("Network connection error"));
|
|
206
|
+
await expect(provider.getBalance()).rejects.toThrow("Network connection error");
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
// =========================================================
|
|
210
|
+
// transaction operation tests
|
|
211
|
+
// =========================================================
|
|
212
|
+
describe("transaction operations", () => {
|
|
213
|
+
it("should sign transactions", async () => {
|
|
214
|
+
const mockTransaction = new web3_js_1.VersionedTransaction(web3_js_1.MessageV0.compile({
|
|
215
|
+
payerKey: new web3_js_1.PublicKey(MOCK_ADDRESS),
|
|
216
|
+
instructions: [],
|
|
217
|
+
recentBlockhash: "test-blockhash",
|
|
218
|
+
}));
|
|
219
|
+
const signedTx = await provider.signTransaction(mockTransaction);
|
|
220
|
+
expect(mockCdpClient.solana.signTransaction).toHaveBeenCalledWith({
|
|
221
|
+
transaction: expect.any(String),
|
|
222
|
+
address: MOCK_ADDRESS,
|
|
223
|
+
});
|
|
224
|
+
expect(signedTx).toBe(mockTransaction);
|
|
225
|
+
});
|
|
226
|
+
it("should send transactions", async () => {
|
|
227
|
+
const mockTransaction = new web3_js_1.VersionedTransaction(web3_js_1.MessageV0.compile({
|
|
228
|
+
payerKey: new web3_js_1.PublicKey(MOCK_ADDRESS),
|
|
229
|
+
instructions: [],
|
|
230
|
+
recentBlockhash: "test-blockhash",
|
|
231
|
+
}));
|
|
232
|
+
const signature = await provider.sendTransaction(mockTransaction);
|
|
233
|
+
expect(mockConnection.sendTransaction).toHaveBeenCalledWith(mockTransaction);
|
|
234
|
+
expect(signature).toBe(MOCK_SIGNATURE);
|
|
235
|
+
});
|
|
236
|
+
it("should sign and send transactions", async () => {
|
|
237
|
+
const mockTransaction = new web3_js_1.VersionedTransaction(web3_js_1.MessageV0.compile({
|
|
238
|
+
payerKey: new web3_js_1.PublicKey(MOCK_ADDRESS),
|
|
239
|
+
instructions: [],
|
|
240
|
+
recentBlockhash: "test-blockhash",
|
|
241
|
+
}));
|
|
242
|
+
const signature = await provider.signAndSendTransaction(mockTransaction);
|
|
243
|
+
expect(mockCdpClient.solana.signTransaction).toHaveBeenCalled();
|
|
244
|
+
expect(mockConnection.sendTransaction).toHaveBeenCalled();
|
|
245
|
+
expect(signature).toBe(MOCK_SIGNATURE);
|
|
246
|
+
});
|
|
247
|
+
it("should handle transaction failures during send", async () => {
|
|
248
|
+
mockConnection.sendTransaction.mockRejectedValueOnce(new Error("Transaction failed"));
|
|
249
|
+
const mockTransaction = new web3_js_1.VersionedTransaction(web3_js_1.MessageV0.compile({
|
|
250
|
+
payerKey: new web3_js_1.PublicKey(MOCK_ADDRESS),
|
|
251
|
+
instructions: [],
|
|
252
|
+
recentBlockhash: "test-blockhash",
|
|
253
|
+
}));
|
|
254
|
+
await expect(provider.sendTransaction(mockTransaction)).rejects.toThrow("Transaction failed");
|
|
255
|
+
});
|
|
256
|
+
it("should get signature status", async () => {
|
|
257
|
+
const mockStatus = {
|
|
258
|
+
value: {
|
|
259
|
+
slot: 123456,
|
|
260
|
+
confirmations: 32,
|
|
261
|
+
err: null,
|
|
262
|
+
},
|
|
263
|
+
context: {
|
|
264
|
+
slot: 123456,
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
mockConnection.getSignatureStatus.mockResolvedValue(mockStatus);
|
|
268
|
+
const status = await provider.getSignatureStatus(MOCK_SIGNATURE);
|
|
269
|
+
expect(status).toBe(mockStatus);
|
|
270
|
+
expect(mockConnection.getSignatureStatus).toHaveBeenCalledWith(MOCK_SIGNATURE, undefined);
|
|
271
|
+
});
|
|
272
|
+
it("should wait for signature result", async () => {
|
|
273
|
+
const result = await provider.waitForSignatureResult(MOCK_SIGNATURE);
|
|
274
|
+
expect(result).toBe(MOCK_SIGNATURE_RESULT);
|
|
275
|
+
expect(mockConnection.confirmTransaction).toHaveBeenCalledWith({
|
|
276
|
+
signature: MOCK_SIGNATURE,
|
|
277
|
+
lastValidBlockHeight: 123456,
|
|
278
|
+
blockhash: "test-blockhash",
|
|
279
|
+
});
|
|
280
|
+
});
|
|
281
|
+
});
|
|
282
|
+
// =========================================================
|
|
283
|
+
// native transfer tests
|
|
284
|
+
// =========================================================
|
|
285
|
+
describe("native transfer", () => {
|
|
286
|
+
it("should transfer SOL", async () => {
|
|
287
|
+
const toAddress = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin";
|
|
288
|
+
const amount = "1.0";
|
|
289
|
+
// Set a balance that's high enough to cover the transfer + fees
|
|
290
|
+
mockConnection.getBalance.mockResolvedValueOnce(Number(2000000000n)); // 2 SOL
|
|
291
|
+
const signature = await provider.nativeTransfer(toAddress, amount);
|
|
292
|
+
expect(signature).toBe(MOCK_SIGNATURE);
|
|
293
|
+
expect(mockConnection.sendTransaction).toHaveBeenCalled();
|
|
294
|
+
});
|
|
295
|
+
it("should handle insufficient balance", async () => {
|
|
296
|
+
mockConnection.getBalance.mockResolvedValueOnce(Number(1000000n)); // 0.001 SOL
|
|
297
|
+
const toAddress = "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin";
|
|
298
|
+
const amount = "1.0";
|
|
299
|
+
await expect(provider.nativeTransfer(toAddress, amount)).rejects.toThrow("Insufficient balance");
|
|
300
|
+
});
|
|
301
|
+
it("should handle invalid address", async () => {
|
|
302
|
+
const invalidAddress = "invalid-address";
|
|
303
|
+
const amount = "1.0";
|
|
304
|
+
await expect(provider.nativeTransfer(invalidAddress, amount)).rejects.toThrow();
|
|
305
|
+
});
|
|
306
|
+
});
|
|
307
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { CdpV2EvmWalletProvider } from "./cdpV2EvmWalletProvider";
|
|
2
|
+
import { CdpV2SolanaWalletProvider } from "./cdpV2SolanaWalletProvider";
|
|
3
|
+
import { CdpV2WalletProviderConfig } from "./cdpV2Shared";
|
|
4
|
+
export type CdpV2WalletProviderVariant = CdpV2SolanaWalletProvider | CdpV2EvmWalletProvider;
|
|
5
|
+
/**
|
|
6
|
+
* Factory class for creating chain-specific CDP V2 wallet providers
|
|
7
|
+
*/
|
|
8
|
+
export declare class CdpV2WalletProvider {
|
|
9
|
+
/**
|
|
10
|
+
* Creates and configures a new wallet provider instance based on the chain type.
|
|
11
|
+
*
|
|
12
|
+
* @param config - The configuration options for the CdpV2 wallet
|
|
13
|
+
* @returns A configured WalletProvider instance for the specified chain
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // For EVM server wallets (default)
|
|
18
|
+
* const evmWallet = await CdpV2WalletProvider.configureWithWallet({
|
|
19
|
+
* apiKeyId: "your-api-key-id",
|
|
20
|
+
* apiKeySecret: "your-api-key-secret",
|
|
21
|
+
* walletSecret: "your-wallet-secret",
|
|
22
|
+
* networkId: "base-sepolia" // or any EVM network. Defaults to "base-sepolia"
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* // For Solana server wallets
|
|
26
|
+
* const solanaWallet = await CdpV2WalletProvider.configureWithWallet({
|
|
27
|
+
* apiKeyId: "your-api-key-id",
|
|
28
|
+
* apiKeySecret: "your-api-key-secret",
|
|
29
|
+
* walletSecret: "your-wallet-secret",
|
|
30
|
+
* networkId: "solana-devnet" // or "solana-mainnet"
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
static configureWithWallet<T extends CdpV2WalletProviderConfig>(config: T): Promise<CdpV2WalletProviderVariant>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CdpV2WalletProvider = void 0;
|
|
4
|
+
const cdpV2EvmWalletProvider_1 = require("./cdpV2EvmWalletProvider");
|
|
5
|
+
const cdpV2SolanaWalletProvider_1 = require("./cdpV2SolanaWalletProvider");
|
|
6
|
+
const network_1 = require("../network");
|
|
7
|
+
/**
|
|
8
|
+
* Factory class for creating chain-specific CDP V2 wallet providers
|
|
9
|
+
*/
|
|
10
|
+
class CdpV2WalletProvider {
|
|
11
|
+
/**
|
|
12
|
+
* Creates and configures a new wallet provider instance based on the chain type.
|
|
13
|
+
*
|
|
14
|
+
* @param config - The configuration options for the CdpV2 wallet
|
|
15
|
+
* @returns A configured WalletProvider instance for the specified chain
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // For EVM server wallets (default)
|
|
20
|
+
* const evmWallet = await CdpV2WalletProvider.configureWithWallet({
|
|
21
|
+
* apiKeyId: "your-api-key-id",
|
|
22
|
+
* apiKeySecret: "your-api-key-secret",
|
|
23
|
+
* walletSecret: "your-wallet-secret",
|
|
24
|
+
* networkId: "base-sepolia" // or any EVM network. Defaults to "base-sepolia"
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // For Solana server wallets
|
|
28
|
+
* const solanaWallet = await CdpV2WalletProvider.configureWithWallet({
|
|
29
|
+
* apiKeyId: "your-api-key-id",
|
|
30
|
+
* apiKeySecret: "your-api-key-secret",
|
|
31
|
+
* walletSecret: "your-wallet-secret",
|
|
32
|
+
* networkId: "solana-devnet" // or "solana-mainnet"
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
static async configureWithWallet(config) {
|
|
37
|
+
const useSolana = config.networkId && network_1.SOLANA_NETWORK_IDS.includes(config.networkId);
|
|
38
|
+
const walletProviderClass = useSolana ? cdpV2SolanaWalletProvider_1.CdpV2SolanaWalletProvider : cdpV2EvmWalletProvider_1.CdpV2EvmWalletProvider;
|
|
39
|
+
return await walletProviderClass.configureWithWallet(config);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.CdpV2WalletProvider = CdpV2WalletProvider;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export * from "./walletProvider";
|
|
2
2
|
export * from "./evmWalletProvider";
|
|
3
3
|
export * from "./viemWalletProvider";
|
|
4
|
+
export * from "./cdpV2EvmWalletProvider";
|
|
5
|
+
export * from "./cdpV2SolanaWalletProvider";
|
|
6
|
+
export * from "./cdpV2WalletProvider";
|
|
7
|
+
export * from "./cdpV2Shared";
|
|
4
8
|
export * from "./cdpWalletProvider";
|
|
5
9
|
export * from "./svmWalletProvider";
|
|
6
10
|
export * from "./smartWalletProvider";
|
|
@@ -17,6 +17,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./walletProvider"), exports);
|
|
18
18
|
__exportStar(require("./evmWalletProvider"), exports);
|
|
19
19
|
__exportStar(require("./viemWalletProvider"), exports);
|
|
20
|
+
__exportStar(require("./cdpV2EvmWalletProvider"), exports);
|
|
21
|
+
__exportStar(require("./cdpV2SolanaWalletProvider"), exports);
|
|
22
|
+
__exportStar(require("./cdpV2WalletProvider"), exports);
|
|
23
|
+
__exportStar(require("./cdpV2Shared"), exports);
|
|
20
24
|
__exportStar(require("./cdpWalletProvider"), exports);
|
|
21
25
|
__exportStar(require("./svmWalletProvider"), exports);
|
|
22
26
|
__exportStar(require("./smartWalletProvider"), exports);
|
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-
|
|
5
|
+
"version": "0.0.0-nightly-20250429210433",
|
|
6
6
|
"author": "Coinbase Inc.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -24,6 +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
28
|
"@coinbase/coinbase-sdk": "^0.20.0",
|
|
28
29
|
"@jup-ag/api": "^6.0.39",
|
|
29
30
|
"@privy-io/public-api": "^2.18.5",
|