@coinbase/agentkit 0.2.0 → 0.2.2
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 +88 -2
- package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +5 -3
- package/dist/action-providers/cdp/cdpApiActionProvider.js +15 -4
- package/dist/action-providers/cdp/cdpApiActionProvider.test.js +14 -2
- package/dist/action-providers/cdp/cdpWalletActionProvider.js +4 -1
- package/dist/action-providers/index.d.ts +2 -0
- package/dist/action-providers/index.js +2 -0
- package/dist/action-providers/jupiter/index.d.ts +1 -0
- package/dist/action-providers/jupiter/index.js +17 -0
- package/dist/action-providers/jupiter/jupiterActionProvider.d.ts +36 -0
- package/dist/action-providers/jupiter/jupiterActionProvider.js +115 -0
- package/dist/action-providers/jupiter/jupiterActionProvider.test.d.ts +1 -0
- package/dist/action-providers/jupiter/jupiterActionProvider.test.js +146 -0
- package/dist/action-providers/jupiter/schemas.d.ts +20 -0
- package/dist/action-providers/jupiter/schemas.js +20 -0
- package/dist/action-providers/spl/schemas.d.ts +13 -0
- package/dist/action-providers/spl/schemas.js +13 -1
- package/dist/action-providers/spl/splActionProvider.d.ts +9 -1
- package/dist/action-providers/spl/splActionProvider.js +62 -1
- package/dist/action-providers/spl/splActionProvider.test.js +101 -7
- package/dist/action-providers/wow/constants.js +1 -1
- package/dist/action-providers/wow/wowActionProvider.d.ts +4 -4
- package/dist/action-providers/wow/wowActionProvider.js +19 -19
- package/dist/action-providers/wow/wowActionProvider.test.js +14 -10
- package/dist/analytics/sendAnalyticsEvent.js +1 -0
- package/dist/network/svm.d.ts +1 -0
- package/dist/network/svm.js +6 -1
- package/dist/wallet-providers/cdpWalletProvider.js +1 -1
- package/dist/wallet-providers/index.d.ts +2 -0
- package/dist/wallet-providers/index.js +2 -0
- package/dist/wallet-providers/privyEvmWalletProvider.d.ts +55 -0
- package/dist/wallet-providers/privyEvmWalletProvider.js +140 -0
- package/dist/wallet-providers/privyShared.d.ts +40 -0
- package/dist/wallet-providers/privyShared.js +49 -0
- package/dist/wallet-providers/privySvmWalletProvider.d.ts +128 -0
- package/dist/wallet-providers/privySvmWalletProvider.js +212 -0
- package/dist/wallet-providers/privyWalletProvider.d.ts +21 -56
- package/dist/wallet-providers/privyWalletProvider.js +18 -118
- package/package.json +2 -1
|
@@ -1,139 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _PrivyWalletProvider_walletId, _PrivyWalletProvider_authorizationPrivateKey;
|
|
14
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.PrivyWalletProvider = void 0;
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const viemWalletProvider_1 = require("./viemWalletProvider");
|
|
19
|
-
const viem_2 = require("viem");
|
|
20
|
-
const network_1 = require("../network/network");
|
|
4
|
+
const privyEvmWalletProvider_1 = require("./privyEvmWalletProvider");
|
|
5
|
+
const privySvmWalletProvider_1 = require("./privySvmWalletProvider");
|
|
21
6
|
/**
|
|
22
|
-
*
|
|
23
|
-
* This provider extends the ViemWalletProvider to provide Privy-specific wallet functionality
|
|
24
|
-
* while maintaining compatibility with the base wallet provider interface.
|
|
7
|
+
* Factory class for creating chain-specific Privy wallet providers
|
|
25
8
|
*/
|
|
26
|
-
class PrivyWalletProvider
|
|
9
|
+
class PrivyWalletProvider {
|
|
27
10
|
/**
|
|
28
|
-
*
|
|
11
|
+
* Creates and configures a new wallet provider instance based on the chain type.
|
|
29
12
|
*
|
|
30
|
-
* @param walletClient - The Viem wallet client instance
|
|
31
13
|
* @param config - The configuration options for the Privy wallet
|
|
32
|
-
|
|
33
|
-
constructor(walletClient, config) {
|
|
34
|
-
super(walletClient);
|
|
35
|
-
_PrivyWalletProvider_walletId.set(this, void 0);
|
|
36
|
-
_PrivyWalletProvider_authorizationPrivateKey.set(this, void 0);
|
|
37
|
-
__classPrivateFieldSet(this, _PrivyWalletProvider_walletId, config.walletId, "f"); // Now guaranteed to exist
|
|
38
|
-
__classPrivateFieldSet(this, _PrivyWalletProvider_authorizationPrivateKey, config.authorizationPrivateKey, "f");
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates and configures a new PrivyWalletProvider instance.
|
|
42
|
-
*
|
|
43
|
-
* @param config - The configuration options for the Privy wallet
|
|
44
|
-
* @returns A configured PrivyWalletProvider instance
|
|
14
|
+
* @returns A configured WalletProvider instance for the specified chain
|
|
45
15
|
*
|
|
46
16
|
* @example
|
|
47
17
|
* ```typescript
|
|
48
|
-
*
|
|
18
|
+
* // For EVM (default)
|
|
19
|
+
* const evmWallet = await PrivyWalletProvider.configureWithWallet({
|
|
20
|
+
* appId: "your-app-id",
|
|
21
|
+
* appSecret: "your-app-secret"
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* // For Solana
|
|
25
|
+
* const solanaWallet = await PrivyWalletProvider.configureWithWallet({
|
|
49
26
|
* appId: "your-app-id",
|
|
50
27
|
* appSecret: "your-app-secret",
|
|
51
|
-
*
|
|
52
|
-
* chainId: "84532"
|
|
28
|
+
* chainType: "solana"
|
|
53
29
|
* });
|
|
54
30
|
* ```
|
|
55
31
|
*/
|
|
56
32
|
static async configureWithWallet(config) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
? {
|
|
60
|
-
authorizationPrivateKey: config.authorizationPrivateKey,
|
|
61
|
-
}
|
|
62
|
-
: undefined,
|
|
63
|
-
});
|
|
64
|
-
let walletId;
|
|
65
|
-
let address;
|
|
66
|
-
if (!config.walletId) {
|
|
67
|
-
if (config.authorizationPrivateKey && !config.authorizationKeyId) {
|
|
68
|
-
throw new Error("authorizationKeyId is required when creating a new wallet with an authorization key, this can be found in your Privy Dashboard");
|
|
69
|
-
}
|
|
70
|
-
if (config.authorizationKeyId && !config.authorizationPrivateKey) {
|
|
71
|
-
throw new Error("authorizationPrivateKey is required when creating a new wallet with an authorizationKeyId. " +
|
|
72
|
-
"If you don't have it, you can create a new one in your Privy Dashboard, or delete the authorization key.");
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
const wallet = await privy.walletApi.create({
|
|
76
|
-
chainType: "ethereum",
|
|
77
|
-
authorizationKeyIds: config.authorizationKeyId ? [config.authorizationKeyId] : undefined,
|
|
78
|
-
});
|
|
79
|
-
walletId = wallet.id;
|
|
80
|
-
address = wallet.address;
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
console.error(error);
|
|
84
|
-
if (error instanceof Error &&
|
|
85
|
-
error.message.includes("Missing `privy-authorization-signature` header")) {
|
|
86
|
-
// Providing a more informative error message, see context: https://github.com/coinbase/agentkit/pull/242#discussion_r1956428617
|
|
87
|
-
throw new Error("Privy error: you have an authorization key on your account which can create and modify wallets, please delete this key or pass it to the PrivyWalletProvider to create a new wallet");
|
|
88
|
-
}
|
|
89
|
-
throw new Error("Failed to create wallet");
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
walletId = config.walletId;
|
|
94
|
-
const wallet = await privy.walletApi.getWallet({ id: walletId });
|
|
95
|
-
if (!wallet) {
|
|
96
|
-
throw new Error(`Wallet with ID ${walletId} not found`);
|
|
97
|
-
}
|
|
98
|
-
address = wallet.address;
|
|
33
|
+
if (config.chainType === "solana") {
|
|
34
|
+
return (await privySvmWalletProvider_1.PrivySvmWalletProvider.configureWithWallet(config));
|
|
99
35
|
}
|
|
100
|
-
|
|
101
|
-
walletId,
|
|
102
|
-
address,
|
|
103
|
-
privy,
|
|
104
|
-
});
|
|
105
|
-
const chainId = config.chainId || "84532";
|
|
106
|
-
const chain = (0, network_1.getChain)(chainId);
|
|
107
|
-
if (!chain) {
|
|
108
|
-
throw new Error(`Chain with ID ${chainId} not found`);
|
|
109
|
-
}
|
|
110
|
-
const walletClient = (0, viem_2.createWalletClient)({
|
|
111
|
-
account,
|
|
112
|
-
chain,
|
|
113
|
-
transport: (0, viem_2.http)(),
|
|
114
|
-
});
|
|
115
|
-
return new PrivyWalletProvider(walletClient, { ...config, walletId });
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Gets the name of the wallet provider.
|
|
119
|
-
*
|
|
120
|
-
* @returns The string identifier for this wallet provider
|
|
121
|
-
*/
|
|
122
|
-
getName() {
|
|
123
|
-
return "privy_wallet_provider";
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Exports the wallet data.
|
|
127
|
-
*
|
|
128
|
-
* @returns The wallet data
|
|
129
|
-
*/
|
|
130
|
-
exportWallet() {
|
|
131
|
-
return {
|
|
132
|
-
walletId: __classPrivateFieldGet(this, _PrivyWalletProvider_walletId, "f"),
|
|
133
|
-
authorizationPrivateKey: __classPrivateFieldGet(this, _PrivyWalletProvider_authorizationPrivateKey, "f"),
|
|
134
|
-
chainId: this.getNetwork().chainId,
|
|
135
|
-
};
|
|
36
|
+
return (await privyEvmWalletProvider_1.PrivyEvmWalletProvider.configureWithWallet(config));
|
|
136
37
|
}
|
|
137
38
|
}
|
|
138
39
|
exports.PrivyWalletProvider = PrivyWalletProvider;
|
|
139
|
-
_PrivyWalletProvider_walletId = new WeakMap(), _PrivyWalletProvider_authorizationPrivateKey = new WeakMap();
|
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.2.
|
|
5
|
+
"version": "0.2.2",
|
|
6
6
|
"author": "Coinbase Inc.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@coinbase/coinbase-sdk": "^0.17.0",
|
|
43
|
+
"@jup-ag/api": "^6.0.39",
|
|
43
44
|
"@privy-io/server-auth": "^1.18.4",
|
|
44
45
|
"@solana/spl-token": "^0.4.12",
|
|
45
46
|
"@solana/web3.js": "^1.98.0",
|