@coinbase/agentkit 0.7.2 → 0.8.1
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 +20 -20
- package/dist/action-providers/cdp/cdpApiActionProvider.js +3 -3
- package/dist/action-providers/cdp/cdpWalletActionProvider.js +3 -3
- package/dist/agentkit.d.ts +2 -2
- package/dist/agentkit.js +4 -4
- package/dist/wallet-providers/cdpWalletProvider.d.ts +2 -2
- package/dist/wallet-providers/cdpWalletProvider.js +3 -3
- package/dist/wallet-providers/cdpWalletProvider.test.js +6 -6
- package/dist/wallet-providers/smartWalletProvider.d.ts +4 -4
- package/dist/wallet-providers/smartWalletProvider.js +7 -7
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -65,8 +65,8 @@ npm install @coinbase/agentkit
|
|
|
65
65
|
|
|
66
66
|
```typescript
|
|
67
67
|
const agentKit = await AgentKit.from({
|
|
68
|
-
|
|
69
|
-
cdpApiKeyPrivate: "CDP API KEY
|
|
68
|
+
cdpApiKeyId: "CDP API KEY NAME",
|
|
69
|
+
cdpApiKeyPrivate: "CDP API KEY SECRET",
|
|
70
70
|
});
|
|
71
71
|
```
|
|
72
72
|
|
|
@@ -76,8 +76,8 @@ If no wallet or action provider are specified, the agent will use the `CdpWallet
|
|
|
76
76
|
|
|
77
77
|
```typescript
|
|
78
78
|
const agentKit = await AgentKit.from({
|
|
79
|
-
|
|
80
|
-
cdpApiKeyPrivate: "CDP API KEY
|
|
79
|
+
cdpApiKeyId: "CDP API KEY NAME",
|
|
80
|
+
cdpApiKeyPrivate: "CDP API KEY SECRET",
|
|
81
81
|
});
|
|
82
82
|
```
|
|
83
83
|
|
|
@@ -87,8 +87,8 @@ const agentKit = await AgentKit.from({
|
|
|
87
87
|
import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
88
88
|
|
|
89
89
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
90
|
-
|
|
91
|
-
apiKeyPrivate: "CDP API KEY
|
|
90
|
+
apiKeyId: "CDP API KEY NAME",
|
|
91
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
92
92
|
networkId: "base-mainnet",
|
|
93
93
|
});
|
|
94
94
|
|
|
@@ -106,8 +106,8 @@ const agentKit = await AgentKit.from({
|
|
|
106
106
|
walletProvider,
|
|
107
107
|
actionProviders: [
|
|
108
108
|
cdpApiActionProvider({
|
|
109
|
-
|
|
110
|
-
apiKeyPrivate: "CDP API KEY
|
|
109
|
+
apiKeyId: "CDP API KEY NAME",
|
|
110
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
111
111
|
}),
|
|
112
112
|
pythActionProvider(),
|
|
113
113
|
],
|
|
@@ -528,8 +528,8 @@ This gives your agent access to the actions defined in the action provider.
|
|
|
528
528
|
|
|
529
529
|
```typescript
|
|
530
530
|
const agentKit = new AgentKit({
|
|
531
|
-
|
|
532
|
-
cdpApiKeyPrivate: "CDP API KEY
|
|
531
|
+
cdpApiKeyId: "CDP API KEY NAME",
|
|
532
|
+
cdpApiKeyPrivate: "CDP API KEY SECRET",
|
|
533
533
|
actionProviders: [myActionProvider()],
|
|
534
534
|
});
|
|
535
535
|
```
|
|
@@ -621,8 +621,8 @@ The `CdpWalletProvider` can be configured to use a specific network by passing t
|
|
|
621
621
|
import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
622
622
|
|
|
623
623
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
624
|
-
|
|
625
|
-
apiKeyPrivate: "CDP API KEY
|
|
624
|
+
apiKeyId: "CDP API KEY NAME",
|
|
625
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
626
626
|
networkId: "base-mainnet",
|
|
627
627
|
});
|
|
628
628
|
```
|
|
@@ -636,8 +636,8 @@ import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
|
636
636
|
import { Wallet } from "@coinbase/coinbase-sdk";
|
|
637
637
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
638
638
|
wallet,
|
|
639
|
-
|
|
640
|
-
apiKeyPrivate: "CDP API KEY
|
|
639
|
+
apiKeyId: "CDP API KEY NAME",
|
|
640
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
641
641
|
});
|
|
642
642
|
```
|
|
643
643
|
|
|
@@ -678,8 +678,8 @@ import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
|
678
678
|
|
|
679
679
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
680
680
|
cdpWalletData: "WALLET DATA JSON STRING",
|
|
681
|
-
|
|
682
|
-
apiKeyPrivate: "CDP API KEY
|
|
681
|
+
apiKeyId: "CDP API KEY NAME",
|
|
682
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
683
683
|
});
|
|
684
684
|
```
|
|
685
685
|
|
|
@@ -692,8 +692,8 @@ import { CdpWalletProvider } from "@coinbase/agentkit";
|
|
|
692
692
|
|
|
693
693
|
const walletProvider = await CdpWalletProvider.configureWithWallet({
|
|
694
694
|
cdpWalletData: "WALLET DATA JSON STRING",
|
|
695
|
-
|
|
696
|
-
apiKeyPrivate: "CDP API KEY
|
|
695
|
+
apiKeyId: "CDP API KEY NAME",
|
|
696
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
697
697
|
gas: {
|
|
698
698
|
gasLimitMultiplier: 2.0, // Adjusts gas limit estimation
|
|
699
699
|
feePerGasMultiplier: 2.0, // Adjusts max fee per gas
|
|
@@ -879,8 +879,8 @@ import { ZeroDevWalletProvider, CdpWalletProvider } from "@coinbase/agentkit";
|
|
|
879
879
|
|
|
880
880
|
// First create a CDP wallet provider as the signer
|
|
881
881
|
const cdpWalletProvider = await CdpWalletProvider.configureWithWallet({
|
|
882
|
-
|
|
883
|
-
apiKeyPrivate: "CDP API KEY
|
|
882
|
+
apiKeyId: "CDP API KEY NAME",
|
|
883
|
+
apiKeyPrivate: "CDP API KEY SECRET",
|
|
884
884
|
networkId: "base-mainnet",
|
|
885
885
|
});
|
|
886
886
|
|
|
@@ -39,10 +39,10 @@ class CdpApiActionProvider extends actionProvider_1.ActionProvider {
|
|
|
39
39
|
* @returns True if the Cdp action provider supports the network, false otherwise.
|
|
40
40
|
*/
|
|
41
41
|
this.supportsNetwork = (_) => true;
|
|
42
|
-
if (config.
|
|
42
|
+
if (config.apiKeyId && config.apiKeySecret) {
|
|
43
43
|
coinbase_sdk_1.Coinbase.configure({
|
|
44
|
-
apiKeyName: config.
|
|
45
|
-
privateKey: config.
|
|
44
|
+
apiKeyName: config.apiKeyId,
|
|
45
|
+
privateKey: config.apiKeySecret?.replace(/\\n/g, "\n"),
|
|
46
46
|
source: "agentkit",
|
|
47
47
|
sourceVersion: package_json_1.version,
|
|
48
48
|
});
|
|
@@ -38,10 +38,10 @@ class CdpWalletActionProvider extends actionProvider_1.ActionProvider {
|
|
|
38
38
|
* @returns True if the Cdp action provider supports the network, false otherwise.
|
|
39
39
|
*/
|
|
40
40
|
this.supportsNetwork = (network) => network.protocolFamily === "evm";
|
|
41
|
-
if (config.
|
|
41
|
+
if (config.apiKeyId && config.apiKeySecret) {
|
|
42
42
|
coinbase_sdk_1.Coinbase.configure({
|
|
43
|
-
apiKeyName: config.
|
|
44
|
-
privateKey: config.
|
|
43
|
+
apiKeyName: config.apiKeyId,
|
|
44
|
+
privateKey: config.apiKeySecret?.replace(/\\n/g, "\n"),
|
|
45
45
|
source: "agentkit",
|
|
46
46
|
sourceVersion: package_json_1.version,
|
|
47
47
|
});
|
package/dist/agentkit.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { Action, ActionProvider } from "./action-providers";
|
|
|
4
4
|
* Configuration options for AgentKit
|
|
5
5
|
*/
|
|
6
6
|
export type AgentKitOptions = {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
cdpApiKeyId?: string;
|
|
8
|
+
cdpApiKeySecret?: string;
|
|
9
9
|
walletProvider?: WalletProvider;
|
|
10
10
|
actionProviders?: ActionProvider[];
|
|
11
11
|
};
|
package/dist/agentkit.js
CHANGED
|
@@ -32,12 +32,12 @@ class AgentKit {
|
|
|
32
32
|
static async from(config = { actionProviders: [(0, action_providers_1.walletActionProvider)()] }) {
|
|
33
33
|
let walletProvider = config.walletProvider;
|
|
34
34
|
if (!config.walletProvider) {
|
|
35
|
-
if (!config.
|
|
36
|
-
throw new Error("
|
|
35
|
+
if (!config.cdpApiKeyId || !config.cdpApiKeySecret) {
|
|
36
|
+
throw new Error("cdpApiKeyId and cdpApiKeySecret are required if not providing a walletProvider");
|
|
37
37
|
}
|
|
38
38
|
walletProvider = await wallet_providers_1.CdpWalletProvider.configureWithWallet({
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
apiKeyId: config.cdpApiKeyId,
|
|
40
|
+
apiKeySecret: config.cdpApiKeySecret,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
return new AgentKit({ ...config, walletProvider: walletProvider });
|
|
@@ -9,11 +9,11 @@ export interface CdpProviderConfig {
|
|
|
9
9
|
/**
|
|
10
10
|
* The CDP API Key Name.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
apiKeyId?: string;
|
|
13
13
|
/**
|
|
14
14
|
* The CDP API Key Private Key.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
apiKeySecret?: string;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Configuration options for the CdpActionProvider.
|
|
@@ -56,10 +56,10 @@ class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
56
56
|
* @throws Error if required environment variables are missing or wallet initialization fails
|
|
57
57
|
*/
|
|
58
58
|
static async configureWithWallet(config = {}) {
|
|
59
|
-
if (config.
|
|
59
|
+
if (config.apiKeyId && config.apiKeySecret) {
|
|
60
60
|
coinbase_sdk_1.Coinbase.configure({
|
|
61
|
-
apiKeyName: config.
|
|
62
|
-
privateKey: config.
|
|
61
|
+
apiKeyName: config.apiKeyId,
|
|
62
|
+
privateKey: config.apiKeySecret?.replace(/\\n/g, "\n"),
|
|
63
63
|
source: "agentkit",
|
|
64
64
|
sourceVersion: package_json_1.version,
|
|
65
65
|
});
|
|
@@ -199,16 +199,16 @@ describe("CdpWalletProvider", () => {
|
|
|
199
199
|
expect(provider.getNetwork()).toEqual(MOCK_NETWORK);
|
|
200
200
|
});
|
|
201
201
|
it("should initialize with API keys", async () => {
|
|
202
|
-
const
|
|
203
|
-
const
|
|
202
|
+
const apiKeyId = "test-key";
|
|
203
|
+
const apiKeySecret = "private-key";
|
|
204
204
|
const provider = await cdpWalletProvider_1.CdpWalletProvider.configureWithWallet({
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
apiKeyId,
|
|
206
|
+
apiKeySecret,
|
|
207
207
|
networkId: MOCK_NETWORK_ID,
|
|
208
208
|
});
|
|
209
209
|
expect(coinbase_sdk_1.Coinbase.configure).toHaveBeenCalledWith({
|
|
210
|
-
apiKeyName,
|
|
211
|
-
privateKey:
|
|
210
|
+
apiKeyName: apiKeyId,
|
|
211
|
+
privateKey: apiKeySecret,
|
|
212
212
|
source: "agentkit",
|
|
213
213
|
sourceVersion: "1.0.0",
|
|
214
214
|
});
|
|
@@ -3,8 +3,8 @@ import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, ReadCont
|
|
|
3
3
|
import { Network } from "../network";
|
|
4
4
|
import { EvmWalletProvider } from "./evmWalletProvider";
|
|
5
5
|
export interface ConfigureSmartWalletOptions {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
cdpApiKeyId?: string;
|
|
7
|
+
cdpApiKeySecret?: string;
|
|
8
8
|
networkId?: string;
|
|
9
9
|
smartWalletAddress?: Hex;
|
|
10
10
|
paymasterUrl?: string;
|
|
@@ -39,8 +39,8 @@ export declare class SmartWalletProvider extends EvmWalletProvider {
|
|
|
39
39
|
* const smartWalletProvider = await SmartWalletProvider.configureWithWallet({
|
|
40
40
|
* networkId: "base-sepolia",
|
|
41
41
|
* signer: privateKeyToAccount("0xethprivatekey"),
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* cdpApiKeyId: "my-api-key",
|
|
43
|
+
* cdpApiKeySecret: "my-private-key",
|
|
44
44
|
* smartWalletAddress: "0x123456...",
|
|
45
45
|
* });
|
|
46
46
|
* ```
|
|
@@ -57,8 +57,8 @@ class SmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
57
57
|
* const smartWalletProvider = await SmartWalletProvider.configureWithWallet({
|
|
58
58
|
* networkId: "base-sepolia",
|
|
59
59
|
* signer: privateKeyToAccount("0xethprivatekey"),
|
|
60
|
-
*
|
|
61
|
-
*
|
|
60
|
+
* cdpApiKeyId: "my-api-key",
|
|
61
|
+
* cdpApiKeySecret: "my-private-key",
|
|
62
62
|
* smartWalletAddress: "0x123456...",
|
|
63
63
|
* });
|
|
64
64
|
* ```
|
|
@@ -77,12 +77,12 @@ class SmartWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
77
77
|
if (!supportedChainIds.includes(network.chainId)) {
|
|
78
78
|
throw new Error(`Invalid chain id ${network.chainId}. Chain id must be one of ${supportedChainIds.join(", ")}`);
|
|
79
79
|
}
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
80
|
+
const cdpApiKeyId = config.cdpApiKeyId || process.env.CDP_API_KEY_ID;
|
|
81
|
+
const cdpApiKeySecret = config.cdpApiKeySecret || process.env.CDP_API_KEY_SECRET;
|
|
82
|
+
if (cdpApiKeyId && cdpApiKeySecret) {
|
|
83
83
|
coinbase_sdk_1.Coinbase.configure({
|
|
84
|
-
apiKeyName:
|
|
85
|
-
privateKey:
|
|
84
|
+
apiKeyName: cdpApiKeyId,
|
|
85
|
+
privateKey: cdpApiKeySecret?.replace(/\\n/g, "\n"),
|
|
86
86
|
source: "agentkit",
|
|
87
87
|
sourceVersion: package_json_1.version,
|
|
88
88
|
});
|
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.
|
|
5
|
+
"version": "0.8.1",
|
|
6
6
|
"author": "Coinbase Inc.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@coinbase/cdp-sdk": "^1.3.0",
|
|
28
28
|
"@coinbase/coinbase-sdk": "^0.20.0",
|
|
29
29
|
"@jup-ag/api": "^6.0.39",
|
|
30
|
-
"@privy-io/public-api": "
|
|
31
|
-
"@privy-io/server-auth": "
|
|
30
|
+
"@privy-io/public-api": "2.18.5",
|
|
31
|
+
"@privy-io/server-auth": "1.18.4",
|
|
32
32
|
"@solana/spl-token": "^0.4.12",
|
|
33
|
-
"@solana/web3.js": "^1.98.
|
|
33
|
+
"@solana/web3.js": "^1.98.1",
|
|
34
34
|
"bs58": "^4.0.1",
|
|
35
35
|
"canonicalize": "^2.1.0",
|
|
36
36
|
"decimal.js": "^10.5.0",
|