@coinbase/agentkit 0.0.0-nightly-20250713210421 → 0.0.0-nightly-20250715210401
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 +360 -226
- package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +15 -15
- package/dist/action-providers/cdp/cdpApiActionProvider.js +110 -63
- package/dist/action-providers/cdp/cdpApiActionProvider.test.js +205 -124
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.d.ts +17 -0
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.js +20 -0
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.d.ts +17 -0
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +20 -0
- package/dist/action-providers/cdp/cdpSolanaWalletActionProvider.d.ts +17 -0
- package/dist/action-providers/cdp/cdpSolanaWalletActionProvider.js +20 -0
- package/dist/action-providers/cdp/index.d.ts +3 -1
- package/dist/action-providers/cdp/index.js +3 -1
- package/dist/action-providers/cdp/schemas.d.ts +9 -70
- package/dist/action-providers/cdp/schemas.js +12 -61
- package/dist/action-providers/cdp-legacy/index.d.ts +3 -0
- package/dist/action-providers/{cdp-v2 → cdp-legacy}/index.js +2 -1
- package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.d.ts +45 -0
- package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.js +130 -0
- package/dist/action-providers/cdp-legacy/legacyCdpApiActionProvider.test.js +146 -0
- package/dist/action-providers/{cdp/cdpWalletActionProvider.d.ts → cdp-legacy/legacyCdpWalletActionProvider.d.ts} +8 -8
- package/dist/action-providers/{cdp/cdpWalletActionProvider.js → cdp-legacy/legacyCdpWalletActionProvider.js} +14 -14
- package/dist/action-providers/{cdp/cdpWalletActionProvider.test.js → cdp-legacy/legacyCdpWalletActionProvider.test.js} +3 -3
- package/dist/action-providers/cdp-legacy/schemas.d.ts +91 -0
- package/dist/action-providers/cdp-legacy/schemas.js +77 -0
- package/dist/action-providers/erc20/erc20ActionProvider.js +1 -1
- package/dist/action-providers/index.d.ts +1 -1
- package/dist/action-providers/index.js +1 -1
- package/dist/action-providers/jupiter/jupiterActionProvider.test.js +2 -4
- package/dist/agentkit.d.ts +1 -0
- package/dist/agentkit.js +3 -2
- package/dist/wallet-providers/{cdpV2EvmWalletProvider.d.ts → cdpEvmWalletProvider.d.ts} +16 -7
- package/dist/wallet-providers/{cdpV2EvmWalletProvider.js → cdpEvmWalletProvider.js} +50 -39
- package/dist/wallet-providers/{cdpV2EvmWalletProvider.test.js → cdpEvmWalletProvider.test.js} +7 -7
- package/dist/wallet-providers/{cdpV2Shared.d.ts → cdpShared.d.ts} +15 -4
- package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +115 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.js +256 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.test.js +267 -0
- package/dist/wallet-providers/{cdpV2SolanaWalletProvider.d.ts → cdpSolanaWalletProvider.d.ts} +16 -7
- package/dist/wallet-providers/{cdpV2SolanaWalletProvider.js → cdpSolanaWalletProvider.js} +43 -32
- package/dist/wallet-providers/{cdpV2SolanaWalletProvider.test.js → cdpSolanaWalletProvider.test.js} +7 -7
- package/dist/wallet-providers/index.d.ts +6 -6
- package/dist/wallet-providers/index.js +6 -6
- package/dist/wallet-providers/{smartWalletProvider.d.ts → legacyCdpSmartWalletProvider.d.ts} +3 -3
- package/dist/wallet-providers/{smartWalletProvider.js → legacyCdpSmartWalletProvider.js} +21 -21
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/{smartWalletProvider.test.js → legacyCdpSmartWalletProvider.test.js} +2 -2
- package/dist/wallet-providers/{cdpWalletProvider.d.ts → legacyCdpWalletProvider.d.ts} +15 -11
- package/dist/wallet-providers/{cdpWalletProvider.js → legacyCdpWalletProvider.js} +72 -70
- package/dist/wallet-providers/legacyCdpWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/{cdpWalletProvider.test.js → legacyCdpWalletProvider.test.js} +10 -10
- package/package.json +2 -2
- package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.d.ts +0 -34
- package/dist/action-providers/cdp-v2/cdpApiV2ActionProvider.js +0 -98
- package/dist/action-providers/cdp-v2/index.d.ts +0 -2
- package/dist/action-providers/cdp-v2/schemas.d.ts +0 -11
- package/dist/action-providers/cdp-v2/schemas.js +0 -13
- package/dist/wallet-providers/cdpV2WalletProvider.d.ts +0 -35
- package/dist/wallet-providers/cdpV2WalletProvider.js +0 -42
- /package/dist/action-providers/{cdp → cdp-legacy}/constants.d.ts +0 -0
- /package/dist/action-providers/{cdp → cdp-legacy}/constants.js +0 -0
- /package/dist/action-providers/{cdp/cdpWalletActionProvider.test.d.ts → cdp-legacy/legacyCdpApiActionProvider.test.d.ts} +0 -0
- /package/dist/{wallet-providers/cdpV2EvmWalletProvider.test.d.ts → action-providers/cdp-legacy/legacyCdpWalletActionProvider.test.d.ts} +0 -0
- /package/dist/wallet-providers/{cdpV2SolanaWalletProvider.test.d.ts → cdpEvmWalletProvider.test.d.ts} +0 -0
- /package/dist/wallet-providers/{cdpV2Shared.js → cdpShared.js} +0 -0
- /package/dist/wallet-providers/{cdpWalletProvider.test.d.ts → cdpSmartWalletProvider.test.d.ts} +0 -0
- /package/dist/wallet-providers/{smartWalletProvider.test.d.ts → cdpSolanaWalletProvider.test.d.ts} +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { ActionProvider } from "../actionProvider";
|
|
3
3
|
import { Network } from "../../network";
|
|
4
|
-
import {
|
|
4
|
+
import { LegacyCdpWalletProvider, LegacyCdpProviderConfig } from "../../wallet-providers";
|
|
5
5
|
import { DeployContractSchema, DeployNftSchema, DeployTokenSchema, TradeSchema } from "./schemas";
|
|
6
6
|
/**
|
|
7
7
|
* CdpWalletActionProvider is an action provider for Cdp.
|
|
8
8
|
*
|
|
9
9
|
* This provider is used for any action that requires a CDP Wallet.
|
|
10
10
|
*/
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class LegacyCdpWalletActionProvider extends ActionProvider<LegacyCdpWalletProvider> {
|
|
12
12
|
/**
|
|
13
13
|
* Constructor for the CdpWalletActionProvider class.
|
|
14
14
|
*
|
|
15
15
|
* @param config - The configuration options for the CdpWalletActionProvider.
|
|
16
16
|
*/
|
|
17
|
-
constructor(config?:
|
|
17
|
+
constructor(config?: LegacyCdpProviderConfig);
|
|
18
18
|
/**
|
|
19
19
|
* Deploys a contract.
|
|
20
20
|
*
|
|
@@ -22,7 +22,7 @@ export declare class CdpWalletActionProvider extends ActionProvider<CdpWalletPro
|
|
|
22
22
|
* @param args - The input arguments for the action
|
|
23
23
|
* @returns A message containing the deployed contract address and details
|
|
24
24
|
*/
|
|
25
|
-
deployContract(walletProvider:
|
|
25
|
+
deployContract(walletProvider: LegacyCdpWalletProvider, args: z.infer<typeof DeployContractSchema>): Promise<string>;
|
|
26
26
|
/**
|
|
27
27
|
* Deploys an NFT (ERC-721) token collection onchain from the wallet.
|
|
28
28
|
*
|
|
@@ -30,7 +30,7 @@ export declare class CdpWalletActionProvider extends ActionProvider<CdpWalletPro
|
|
|
30
30
|
* @param args - The input arguments for the action.
|
|
31
31
|
* @returns A message containing the NFT token deployment details.
|
|
32
32
|
*/
|
|
33
|
-
deployNFT(walletProvider:
|
|
33
|
+
deployNFT(walletProvider: LegacyCdpWalletProvider, args: z.infer<typeof DeployNftSchema>): Promise<string>;
|
|
34
34
|
/**
|
|
35
35
|
* Deploys a token.
|
|
36
36
|
*
|
|
@@ -38,7 +38,7 @@ export declare class CdpWalletActionProvider extends ActionProvider<CdpWalletPro
|
|
|
38
38
|
* @param args - The arguments for the token deployment.
|
|
39
39
|
* @returns The deployed token.
|
|
40
40
|
*/
|
|
41
|
-
deployToken(walletProvider:
|
|
41
|
+
deployToken(walletProvider: LegacyCdpWalletProvider, args: z.infer<typeof DeployTokenSchema>): Promise<string>;
|
|
42
42
|
/**
|
|
43
43
|
* Trades a specified amount of a from asset to a to asset for the wallet.
|
|
44
44
|
*
|
|
@@ -46,7 +46,7 @@ export declare class CdpWalletActionProvider extends ActionProvider<CdpWalletPro
|
|
|
46
46
|
* @param args - The input arguments for the action.
|
|
47
47
|
* @returns A message containing the trade details.
|
|
48
48
|
*/
|
|
49
|
-
trade(walletProvider:
|
|
49
|
+
trade(walletProvider: LegacyCdpWalletProvider, args: z.infer<typeof TradeSchema>): Promise<string>;
|
|
50
50
|
/**
|
|
51
51
|
* Checks if the Cdp action provider supports the given network.
|
|
52
52
|
*
|
|
@@ -55,4 +55,4 @@ export declare class CdpWalletActionProvider extends ActionProvider<CdpWalletPro
|
|
|
55
55
|
*/
|
|
56
56
|
supportsNetwork: (network: Network) => boolean;
|
|
57
57
|
}
|
|
58
|
-
export declare const
|
|
58
|
+
export declare const legacyCdpWalletActionProvider: (config?: LegacyCdpProviderConfig) => LegacyCdpWalletActionProvider;
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.legacyCdpWalletActionProvider = exports.LegacyCdpWalletActionProvider = void 0;
|
|
13
13
|
const coinbase_sdk_1 = require("@coinbase/coinbase-sdk");
|
|
14
14
|
const zod_1 = require("zod");
|
|
15
15
|
const package_json_1 = require("../../../package.json");
|
|
@@ -23,14 +23,14 @@ const schemas_1 = require("./schemas");
|
|
|
23
23
|
*
|
|
24
24
|
* This provider is used for any action that requires a CDP Wallet.
|
|
25
25
|
*/
|
|
26
|
-
class
|
|
26
|
+
class LegacyCdpWalletActionProvider extends actionProvider_1.ActionProvider {
|
|
27
27
|
/**
|
|
28
28
|
* Constructor for the CdpWalletActionProvider class.
|
|
29
29
|
*
|
|
30
30
|
* @param config - The configuration options for the CdpWalletActionProvider.
|
|
31
31
|
*/
|
|
32
32
|
constructor(config = {}) {
|
|
33
|
-
super("
|
|
33
|
+
super("legacy_cdp_wallet", []);
|
|
34
34
|
/**
|
|
35
35
|
* Checks if the Cdp action provider supports the given network.
|
|
36
36
|
*
|
|
@@ -154,7 +154,7 @@ class CdpWalletActionProvider extends actionProvider_1.ActionProvider {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
exports.
|
|
157
|
+
exports.LegacyCdpWalletActionProvider = LegacyCdpWalletActionProvider;
|
|
158
158
|
__decorate([
|
|
159
159
|
(0, actionDecorator_1.CreateAction)({
|
|
160
160
|
name: "deploy_contract",
|
|
@@ -176,9 +176,9 @@ map where the key is the arg name and the value is the arg value. Encode uint/in
|
|
|
176
176
|
schema: schemas_1.DeployContractSchema,
|
|
177
177
|
}),
|
|
178
178
|
__metadata("design:type", Function),
|
|
179
|
-
__metadata("design:paramtypes", [wallet_providers_1.
|
|
179
|
+
__metadata("design:paramtypes", [wallet_providers_1.LegacyCdpWalletProvider, void 0]),
|
|
180
180
|
__metadata("design:returntype", Promise)
|
|
181
|
-
],
|
|
181
|
+
], LegacyCdpWalletActionProvider.prototype, "deployContract", null);
|
|
182
182
|
__decorate([
|
|
183
183
|
(0, actionDecorator_1.CreateAction)({
|
|
184
184
|
name: "deploy_nft",
|
|
@@ -187,9 +187,9 @@ __decorate([
|
|
|
187
187
|
schema: schemas_1.DeployNftSchema,
|
|
188
188
|
}),
|
|
189
189
|
__metadata("design:type", Function),
|
|
190
|
-
__metadata("design:paramtypes", [wallet_providers_1.
|
|
190
|
+
__metadata("design:paramtypes", [wallet_providers_1.LegacyCdpWalletProvider, void 0]),
|
|
191
191
|
__metadata("design:returntype", Promise)
|
|
192
|
-
],
|
|
192
|
+
], LegacyCdpWalletActionProvider.prototype, "deployNFT", null);
|
|
193
193
|
__decorate([
|
|
194
194
|
(0, actionDecorator_1.CreateAction)({
|
|
195
195
|
name: "deploy_token",
|
|
@@ -198,9 +198,9 @@ The token will be deployed using the wallet's default address as the owner and i
|
|
|
198
198
|
schema: schemas_1.DeployTokenSchema,
|
|
199
199
|
}),
|
|
200
200
|
__metadata("design:type", Function),
|
|
201
|
-
__metadata("design:paramtypes", [wallet_providers_1.
|
|
201
|
+
__metadata("design:paramtypes", [wallet_providers_1.LegacyCdpWalletProvider, void 0]),
|
|
202
202
|
__metadata("design:returntype", Promise)
|
|
203
|
-
],
|
|
203
|
+
], LegacyCdpWalletActionProvider.prototype, "deployToken", null);
|
|
204
204
|
__decorate([
|
|
205
205
|
(0, actionDecorator_1.CreateAction)({
|
|
206
206
|
name: "trade",
|
|
@@ -217,8 +217,8 @@ Important notes:
|
|
|
217
217
|
schema: schemas_1.TradeSchema,
|
|
218
218
|
}),
|
|
219
219
|
__metadata("design:type", Function),
|
|
220
|
-
__metadata("design:paramtypes", [wallet_providers_1.
|
|
220
|
+
__metadata("design:paramtypes", [wallet_providers_1.LegacyCdpWalletProvider, void 0]),
|
|
221
221
|
__metadata("design:returntype", Promise)
|
|
222
|
-
],
|
|
223
|
-
const
|
|
224
|
-
exports.
|
|
222
|
+
], LegacyCdpWalletActionProvider.prototype, "trade", null);
|
|
223
|
+
const legacyCdpWalletActionProvider = (config = {}) => new LegacyCdpWalletActionProvider(config);
|
|
224
|
+
exports.legacyCdpWalletActionProvider = legacyCdpWalletActionProvider;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const legacyCdpWalletActionProvider_1 = require("./legacyCdpWalletActionProvider");
|
|
4
4
|
const schemas_1 = require("./schemas");
|
|
5
5
|
// Mock the entire module
|
|
6
6
|
jest.mock("@coinbase/coinbase-sdk");
|
|
@@ -55,7 +55,7 @@ describe("CDP Wallet Action Provider Input Schemas", () => {
|
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
|
-
describe("CDP Wallet Action Provider", () => {
|
|
58
|
+
describe("Legacy CDP Wallet Action Provider", () => {
|
|
59
59
|
let actionProvider;
|
|
60
60
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
61
|
let mockExternalAddressInstance;
|
|
@@ -63,7 +63,7 @@ describe("CDP Wallet Action Provider", () => {
|
|
|
63
63
|
beforeEach(() => {
|
|
64
64
|
// Reset all mocks before each test
|
|
65
65
|
jest.clearAllMocks();
|
|
66
|
-
actionProvider = new
|
|
66
|
+
actionProvider = new legacyCdpWalletActionProvider_1.LegacyCdpWalletActionProvider();
|
|
67
67
|
mockExternalAddressInstance = {
|
|
68
68
|
reputation: jest.fn(),
|
|
69
69
|
faucet: jest.fn(),
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Input schema for address reputation check.
|
|
4
|
+
*/
|
|
5
|
+
export declare const AddressReputationSchema: z.ZodObject<{
|
|
6
|
+
address: z.ZodString;
|
|
7
|
+
network: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
address: string;
|
|
10
|
+
network: string;
|
|
11
|
+
}, {
|
|
12
|
+
address: string;
|
|
13
|
+
network: string;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Input schema for deploy contract action.
|
|
17
|
+
*/
|
|
18
|
+
export declare const DeployContractSchema: z.ZodObject<{
|
|
19
|
+
solidityVersion: z.ZodEnum<[string, ...string[]]>;
|
|
20
|
+
solidityInputJson: z.ZodString;
|
|
21
|
+
contractName: z.ZodString;
|
|
22
|
+
constructorArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
solidityVersion: string;
|
|
25
|
+
solidityInputJson: string;
|
|
26
|
+
contractName: string;
|
|
27
|
+
constructorArgs?: Record<string, any> | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
solidityVersion: string;
|
|
30
|
+
solidityInputJson: string;
|
|
31
|
+
contractName: string;
|
|
32
|
+
constructorArgs?: Record<string, any> | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Input schema for deploy NFT action
|
|
36
|
+
*/
|
|
37
|
+
export declare const DeployNftSchema: z.ZodObject<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
symbol: z.ZodString;
|
|
40
|
+
baseURI: z.ZodString;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
symbol: string;
|
|
43
|
+
name: string;
|
|
44
|
+
baseURI: string;
|
|
45
|
+
}, {
|
|
46
|
+
symbol: string;
|
|
47
|
+
name: string;
|
|
48
|
+
baseURI: string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Input schema for deploy token action.
|
|
52
|
+
*/
|
|
53
|
+
export declare const DeployTokenSchema: z.ZodObject<{
|
|
54
|
+
name: z.ZodString;
|
|
55
|
+
symbol: z.ZodString;
|
|
56
|
+
totalSupply: z.ZodType<bigint, z.ZodTypeDef, bigint>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
symbol: string;
|
|
59
|
+
name: string;
|
|
60
|
+
totalSupply: bigint;
|
|
61
|
+
}, {
|
|
62
|
+
symbol: string;
|
|
63
|
+
name: string;
|
|
64
|
+
totalSupply: bigint;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Input schema for request faucet funds action.
|
|
68
|
+
*/
|
|
69
|
+
export declare const RequestFaucetFundsSchema: z.ZodObject<{
|
|
70
|
+
assetId: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
assetId?: string | undefined;
|
|
73
|
+
}, {
|
|
74
|
+
assetId?: string | undefined;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Input schema for trade action.
|
|
78
|
+
*/
|
|
79
|
+
export declare const TradeSchema: z.ZodObject<{
|
|
80
|
+
amount: z.ZodType<bigint, z.ZodTypeDef, bigint>;
|
|
81
|
+
fromAssetId: z.ZodString;
|
|
82
|
+
toAssetId: z.ZodString;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
amount: bigint;
|
|
85
|
+
fromAssetId: string;
|
|
86
|
+
toAssetId: string;
|
|
87
|
+
}, {
|
|
88
|
+
amount: bigint;
|
|
89
|
+
fromAssetId: string;
|
|
90
|
+
toAssetId: string;
|
|
91
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TradeSchema = exports.RequestFaucetFundsSchema = exports.DeployTokenSchema = exports.DeployNftSchema = exports.DeployContractSchema = exports.AddressReputationSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
/**
|
|
7
|
+
* Input schema for address reputation check.
|
|
8
|
+
*/
|
|
9
|
+
exports.AddressReputationSchema = zod_1.z
|
|
10
|
+
.object({
|
|
11
|
+
address: zod_1.z
|
|
12
|
+
.string()
|
|
13
|
+
.regex(/^0x[a-fA-F0-9]{40}$/, "Invalid Ethereum address format")
|
|
14
|
+
.describe("The Ethereum address to check"),
|
|
15
|
+
network: zod_1.z.string().describe("The network to check the address on"),
|
|
16
|
+
})
|
|
17
|
+
.strip()
|
|
18
|
+
.describe("Input schema for address reputation check");
|
|
19
|
+
/**
|
|
20
|
+
* Input schema for deploy contract action.
|
|
21
|
+
*/
|
|
22
|
+
exports.DeployContractSchema = zod_1.z
|
|
23
|
+
.object({
|
|
24
|
+
solidityVersion: zod_1.z
|
|
25
|
+
.enum(Object.keys(constants_1.SolidityVersions))
|
|
26
|
+
.describe("The solidity compiler version"),
|
|
27
|
+
solidityInputJson: zod_1.z.string().describe("The input json for the solidity compiler"),
|
|
28
|
+
contractName: zod_1.z.string().describe("The name of the contract class to be deployed"),
|
|
29
|
+
constructorArgs: zod_1.z
|
|
30
|
+
.record(zod_1.z.string(), zod_1.z.any())
|
|
31
|
+
.describe("The constructor arguments for the contract")
|
|
32
|
+
.optional(),
|
|
33
|
+
})
|
|
34
|
+
.strip()
|
|
35
|
+
.describe("Instructions for deploying an arbitrary contract");
|
|
36
|
+
/**
|
|
37
|
+
* Input schema for deploy NFT action
|
|
38
|
+
*/
|
|
39
|
+
exports.DeployNftSchema = zod_1.z
|
|
40
|
+
.object({
|
|
41
|
+
name: zod_1.z.string().describe("The name of the NFT collection"),
|
|
42
|
+
symbol: zod_1.z.string().describe("The symbol of the NFT collection"),
|
|
43
|
+
baseURI: zod_1.z.string().describe("The base URI for the token metadata"),
|
|
44
|
+
})
|
|
45
|
+
.strip()
|
|
46
|
+
.describe("Instructions for deploying an NFT collection");
|
|
47
|
+
/**
|
|
48
|
+
* Input schema for deploy token action.
|
|
49
|
+
*/
|
|
50
|
+
exports.DeployTokenSchema = zod_1.z
|
|
51
|
+
.object({
|
|
52
|
+
name: zod_1.z.string().describe("The name of the token"),
|
|
53
|
+
symbol: zod_1.z.string().describe("The token symbol"),
|
|
54
|
+
totalSupply: zod_1.z.custom().describe("The total supply of tokens to mint"),
|
|
55
|
+
})
|
|
56
|
+
.strip()
|
|
57
|
+
.describe("Instructions for deploying a token");
|
|
58
|
+
/**
|
|
59
|
+
* Input schema for request faucet funds action.
|
|
60
|
+
*/
|
|
61
|
+
exports.RequestFaucetFundsSchema = zod_1.z
|
|
62
|
+
.object({
|
|
63
|
+
assetId: zod_1.z.string().optional().describe("The optional asset ID to request from faucet"),
|
|
64
|
+
})
|
|
65
|
+
.strip()
|
|
66
|
+
.describe("Instructions for requesting faucet funds");
|
|
67
|
+
/**
|
|
68
|
+
* Input schema for trade action.
|
|
69
|
+
*/
|
|
70
|
+
exports.TradeSchema = zod_1.z
|
|
71
|
+
.object({
|
|
72
|
+
amount: zod_1.z.custom().describe("The amount of the from asset to trade"),
|
|
73
|
+
fromAssetId: zod_1.z.string().describe("The from asset ID to trade"),
|
|
74
|
+
toAssetId: zod_1.z.string().describe("The to asset ID to receive from the trade"),
|
|
75
|
+
})
|
|
76
|
+
.strip()
|
|
77
|
+
.describe("Instructions for trading assets");
|
|
@@ -78,7 +78,7 @@ class ERC20ActionProvider extends actionProvider_1.ActionProvider {
|
|
|
78
78
|
((network.networkId === "base-mainnet" && constants_1.BaseTokenToAssetId.has(tokenAddress)) ||
|
|
79
79
|
(network.networkId === "base-sepolia" && constants_1.BaseSepoliaTokenToAssetId.has(tokenAddress)));
|
|
80
80
|
if (canDoGasless) {
|
|
81
|
-
// Cast to
|
|
81
|
+
// Cast to LegacyCdpWalletProvider to access erc20Transfer
|
|
82
82
|
const cdpWallet = walletProvider;
|
|
83
83
|
const assetId = network.networkId === "base-mainnet"
|
|
84
84
|
? constants_1.BaseTokenToAssetId.get(tokenAddress)
|
|
@@ -4,8 +4,8 @@ export * from "./customActionProvider";
|
|
|
4
4
|
export * from "./across";
|
|
5
5
|
export * from "./alchemy";
|
|
6
6
|
export * from "./basename";
|
|
7
|
+
export * from "./cdp-legacy";
|
|
7
8
|
export * from "./cdp";
|
|
8
|
-
export * from "./cdp-v2";
|
|
9
9
|
export * from "./compound";
|
|
10
10
|
export * from "./defillama";
|
|
11
11
|
export * from "./erc20";
|
|
@@ -20,8 +20,8 @@ __exportStar(require("./customActionProvider"), exports);
|
|
|
20
20
|
__exportStar(require("./across"), exports);
|
|
21
21
|
__exportStar(require("./alchemy"), exports);
|
|
22
22
|
__exportStar(require("./basename"), exports);
|
|
23
|
+
__exportStar(require("./cdp-legacy"), exports);
|
|
23
24
|
__exportStar(require("./cdp"), exports);
|
|
24
|
-
__exportStar(require("./cdp-v2"), exports);
|
|
25
25
|
__exportStar(require("./compound"), exports);
|
|
26
26
|
__exportStar(require("./defillama"), exports);
|
|
27
27
|
__exportStar(require("./erc20"), exports);
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const web3_js_1 = require("@solana/web3.js");
|
|
4
4
|
const jupiterActionProvider_1 = require("./jupiterActionProvider");
|
|
5
5
|
const api_1 = require("@jup-ag/api");
|
|
6
|
-
// Default SPL token decimals for tests
|
|
7
|
-
const DECIMALS = 6;
|
|
8
6
|
// Mock the @solana/web3.js module
|
|
9
7
|
jest.mock("@solana/web3.js", () => ({
|
|
10
8
|
// Preserve the actual implementation of @solana/web3.js while overriding specific methods
|
|
@@ -28,7 +26,7 @@ jest.mock("@solana/spl-token", () => ({
|
|
|
28
26
|
// Preserve the actual implementation of @solana/spl-token while overriding specific methods
|
|
29
27
|
...jest.requireActual("@solana/spl-token"),
|
|
30
28
|
// Mock getMint to always return a fixed decimal value for tokens
|
|
31
|
-
getMint: jest.fn().mockReturnValue({ decimals:
|
|
29
|
+
getMint: jest.fn().mockReturnValue({ decimals: 6 }),
|
|
32
30
|
}));
|
|
33
31
|
// Mock the @jup-ag/api module
|
|
34
32
|
jest.mock("@jup-ag/api", () => ({
|
|
@@ -107,7 +105,7 @@ describe("JupiterActionProvider", () => {
|
|
|
107
105
|
expect(mockQuoteGet).toHaveBeenCalledWith({
|
|
108
106
|
inputMint: INPUT_MINT,
|
|
109
107
|
outputMint: OUTPUT_MINT,
|
|
110
|
-
amount: swapArgs.amount * 10 **
|
|
108
|
+
amount: swapArgs.amount * 10 ** 6, // Ensure correct decimal conversion
|
|
111
109
|
slippageBps: swapArgs.slippageBps,
|
|
112
110
|
});
|
|
113
111
|
expect(mockSwapPost).toHaveBeenCalled();
|
package/dist/agentkit.d.ts
CHANGED
package/dist/agentkit.js
CHANGED
|
@@ -32,12 +32,13 @@ 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.cdpApiKeyId || !config.cdpApiKeySecret) {
|
|
35
|
+
if (!config.cdpApiKeyId || !config.cdpApiKeySecret || !config.cdpWalletSecret) {
|
|
36
36
|
throw new Error("cdpApiKeyId and cdpApiKeySecret are required if not providing a walletProvider");
|
|
37
37
|
}
|
|
38
|
-
walletProvider = await wallet_providers_1.
|
|
38
|
+
walletProvider = await wallet_providers_1.CdpSmartWalletProvider.configureWithWallet({
|
|
39
39
|
apiKeyId: config.cdpApiKeyId,
|
|
40
40
|
apiKeySecret: config.cdpApiKeySecret,
|
|
41
|
+
walletSecret: config.cdpWalletSecret,
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
return new AgentKit({ ...config, walletProvider: walletProvider });
|
|
@@ -2,26 +2,35 @@ import { CdpClient } from "@coinbase/cdp-sdk";
|
|
|
2
2
|
import { Abi, Address, ContractFunctionArgs, ContractFunctionName, Hex, ReadContractParameters, ReadContractReturnType, TransactionRequest } from "viem";
|
|
3
3
|
import { Network } from "../network";
|
|
4
4
|
import { EvmWalletProvider } from "./evmWalletProvider";
|
|
5
|
-
import { WalletProviderWithClient,
|
|
5
|
+
import { WalletProviderWithClient, CdpWalletProviderConfig } from "./cdpShared";
|
|
6
6
|
/**
|
|
7
7
|
* A wallet provider that uses the Coinbase SDK.
|
|
8
8
|
*/
|
|
9
|
-
export declare class
|
|
9
|
+
export declare class CdpEvmWalletProvider extends EvmWalletProvider implements WalletProviderWithClient {
|
|
10
10
|
#private;
|
|
11
11
|
/**
|
|
12
|
-
* Constructs a new
|
|
12
|
+
* Constructs a new CdpServerWalletProvider.
|
|
13
13
|
*
|
|
14
|
-
* @param config - The configuration options for the
|
|
14
|
+
* @param config - The configuration options for the CdpServerWalletProvider.
|
|
15
15
|
*/
|
|
16
16
|
private constructor();
|
|
17
17
|
/**
|
|
18
|
-
* Configures a new
|
|
18
|
+
* Configures a new CdpServerWalletProvider with a wallet.
|
|
19
19
|
*
|
|
20
20
|
* @param config - Optional configuration parameters
|
|
21
|
-
* @returns A Promise that resolves to a new
|
|
21
|
+
* @returns A Promise that resolves to a new CdpServerWalletProvider instance
|
|
22
22
|
* @throws Error if required environment variables are missing or wallet initialization fails
|
|
23
23
|
*/
|
|
24
|
-
static configureWithWallet(config?:
|
|
24
|
+
static configureWithWallet(config?: CdpWalletProviderConfig): Promise<CdpEvmWalletProvider>;
|
|
25
|
+
/**
|
|
26
|
+
* Exports the wallet.
|
|
27
|
+
*
|
|
28
|
+
* @returns The wallet's data.
|
|
29
|
+
*/
|
|
30
|
+
exportWallet(): Promise<{
|
|
31
|
+
name: string | undefined;
|
|
32
|
+
address: `0x${string}`;
|
|
33
|
+
}>;
|
|
25
34
|
/**
|
|
26
35
|
* Signs a message.
|
|
27
36
|
*
|