@coinbase/agentkit 0.10.2 → 0.10.3
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 +42 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.js +7 -30
- package/dist/action-providers/cdp/cdpApiActionProvider.test.js +2 -8
- package/dist/action-providers/cdp/faucetUtils.d.ts +38 -0
- package/dist/action-providers/cdp/faucetUtils.js +81 -0
- package/dist/action-providers/clanker/schemas.d.ts +4 -4
- package/dist/action-providers/enso/constants.d.ts +4 -0
- package/dist/action-providers/enso/constants.js +10 -0
- package/dist/action-providers/enso/ensoActionProvider.d.ts +34 -0
- package/dist/action-providers/enso/ensoActionProvider.js +125 -0
- package/dist/action-providers/enso/ensoActionProvider.test.d.ts +1 -0
- package/dist/action-providers/enso/ensoActionProvider.test.js +141 -0
- package/dist/action-providers/enso/index.d.ts +1 -0
- package/dist/action-providers/enso/index.js +17 -0
- package/dist/action-providers/enso/schemas.d.ts +23 -0
- package/dist/action-providers/enso/schemas.js +22 -0
- package/dist/action-providers/erc20/constants.d.ts +2 -0
- package/dist/action-providers/erc20/constants.js +2 -0
- package/dist/action-providers/erc20/erc20ActionProvider.d.ts +17 -1
- package/dist/action-providers/erc20/erc20ActionProvider.js +103 -1
- package/dist/action-providers/erc20/erc20ActionProvider.test.js +201 -0
- package/dist/action-providers/erc20/schemas.d.ts +29 -0
- package/dist/action-providers/erc20/schemas.js +34 -1
- package/dist/action-providers/index.d.ts +3 -1
- package/dist/action-providers/index.js +3 -1
- package/dist/action-providers/wallet/walletActionProvider.js +1 -1
- package/dist/action-providers/weth/constants.d.ts +0 -1
- package/dist/action-providers/weth/constants.js +1 -2
- package/dist/action-providers/weth/schemas.js +6 -2
- package/dist/action-providers/weth/wethActionProvider.d.ts +7 -0
- package/dist/action-providers/weth/wethActionProvider.js +57 -32
- package/dist/action-providers/weth/wethActionProvider.test.js +60 -11
- package/dist/action-providers/x402/utils.d.ts +4 -4
- package/dist/action-providers/x402/utils.js +42 -5
- package/dist/action-providers/x402/x402ActionProvider.d.ts +6 -6
- package/dist/action-providers/x402/x402ActionProvider.js +23 -8
- package/dist/action-providers/x402/x402ActionProvider.test.js +50 -6
- package/dist/action-providers/yelay/constants.d.ts +64 -0
- package/dist/action-providers/yelay/constants.js +137 -0
- package/dist/action-providers/yelay/index.d.ts +2 -0
- package/dist/action-providers/yelay/index.js +18 -0
- package/dist/action-providers/yelay/schemas.d.ts +47 -0
- package/dist/action-providers/yelay/schemas.js +59 -0
- package/dist/action-providers/yelay/types.d.ts +24 -0
- package/dist/action-providers/yelay/types.js +2 -0
- package/dist/action-providers/yelay/yelayActionProvider.d.ts +70 -0
- package/dist/action-providers/yelay/yelayActionProvider.js +329 -0
- package/dist/action-providers/yelay/yelayActionProvider.test.d.ts +1 -0
- package/dist/action-providers/yelay/yelayActionProvider.test.js +302 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.js +1 -3
- package/dist/wallet-providers/cdpSolanaWalletProvider.d.ts +14 -0
- package/dist/wallet-providers/cdpSolanaWalletProvider.js +39 -3
- package/dist/wallet-providers/cdpSolanaWalletProvider.test.js +16 -0
- package/dist/wallet-providers/privySvmWalletProvider.d.ts +14 -0
- package/dist/wallet-providers/privySvmWalletProvider.js +17 -0
- package/dist/wallet-providers/privySvmWalletProvider.test.js +10 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +14 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.js +17 -0
- package/dist/wallet-providers/svmWalletProvider.d.ts +34 -0
- package/dist/wallet-providers/svmWalletProvider.js +43 -0
- package/dist/wallet-providers/svmWalletProvider.test.js +10 -0
- package/package.json +3 -1
|
@@ -10,11 +10,15 @@ 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
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _CdpSolanaWalletProvider_connection, _CdpSolanaWalletProvider_cdp, _CdpSolanaWalletProvider_network, _CdpSolanaWalletProvider_serverAccount;
|
|
14
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
18
|
exports.CdpSolanaWalletProvider = void 0;
|
|
16
19
|
const cdp_sdk_1 = require("@coinbase/cdp-sdk");
|
|
17
20
|
const web3_js_1 = require("@solana/web3.js");
|
|
21
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
18
22
|
const svm_1 = require("../network/svm");
|
|
19
23
|
const svmWalletProvider_1 = require("./svmWalletProvider");
|
|
20
24
|
/**
|
|
@@ -29,9 +33,9 @@ class CdpSolanaWalletProvider extends svmWalletProvider_1.SvmWalletProvider {
|
|
|
29
33
|
constructor(config) {
|
|
30
34
|
super();
|
|
31
35
|
_CdpSolanaWalletProvider_connection.set(this, void 0);
|
|
32
|
-
_CdpSolanaWalletProvider_serverAccount.set(this, void 0);
|
|
33
36
|
_CdpSolanaWalletProvider_cdp.set(this, void 0);
|
|
34
37
|
_CdpSolanaWalletProvider_network.set(this, void 0);
|
|
38
|
+
_CdpSolanaWalletProvider_serverAccount.set(this, void 0);
|
|
35
39
|
__classPrivateFieldSet(this, _CdpSolanaWalletProvider_serverAccount, config.serverAccount, "f");
|
|
36
40
|
__classPrivateFieldSet(this, _CdpSolanaWalletProvider_cdp, config.cdp, "f");
|
|
37
41
|
__classPrivateFieldSet(this, _CdpSolanaWalletProvider_connection, config.connection, "f");
|
|
@@ -216,6 +220,23 @@ class CdpSolanaWalletProvider extends svmWalletProvider_1.SvmWalletProvider {
|
|
|
216
220
|
getClient() {
|
|
217
221
|
return __classPrivateFieldGet(this, _CdpSolanaWalletProvider_cdp, "f");
|
|
218
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Sign a message.
|
|
225
|
+
*
|
|
226
|
+
* @param message - The message to sign as a Uint8Array
|
|
227
|
+
* @returns The signature as a Uint8Array
|
|
228
|
+
*/
|
|
229
|
+
async signMessage(message) {
|
|
230
|
+
// Convert Uint8Array to string for CDP SDK
|
|
231
|
+
const messageString = Buffer.from(message).toString("utf8");
|
|
232
|
+
const { signature } = await __classPrivateFieldGet(this, _CdpSolanaWalletProvider_cdp, "f").solana.signMessage({
|
|
233
|
+
address: __classPrivateFieldGet(this, _CdpSolanaWalletProvider_serverAccount, "f").address,
|
|
234
|
+
message: messageString,
|
|
235
|
+
});
|
|
236
|
+
// Convert signature string back to Uint8Array
|
|
237
|
+
// CDP returns signature as a hex string, convert to bytes
|
|
238
|
+
return new Uint8Array(Buffer.from(signature, "hex"));
|
|
239
|
+
}
|
|
219
240
|
/**
|
|
220
241
|
* Transfer SOL from the wallet to another address
|
|
221
242
|
*
|
|
@@ -253,6 +274,21 @@ class CdpSolanaWalletProvider extends svmWalletProvider_1.SvmWalletProvider {
|
|
|
253
274
|
await this.waitForSignatureResult(signature);
|
|
254
275
|
return signature;
|
|
255
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* Get the keypair signer for this wallet.
|
|
279
|
+
*
|
|
280
|
+
* @returns The KeyPairSigner
|
|
281
|
+
*/
|
|
282
|
+
async getKeyPairSigner() {
|
|
283
|
+
// Export the private key from CDP
|
|
284
|
+
const exportedPrivateKey = await __classPrivateFieldGet(this, _CdpSolanaWalletProvider_cdp, "f").solana.exportAccount({
|
|
285
|
+
address: __classPrivateFieldGet(this, _CdpSolanaWalletProvider_serverAccount, "f").address,
|
|
286
|
+
});
|
|
287
|
+
// Decode the base58 encoded private key to get the full 64-byte key
|
|
288
|
+
const fullKeyBytes = bs58_1.default.decode(exportedPrivateKey);
|
|
289
|
+
// Create and return the KeyPairSigner using the full key bytes
|
|
290
|
+
return (0, svmWalletProvider_1.createSignerFromBytes)(fullKeyBytes);
|
|
291
|
+
}
|
|
256
292
|
}
|
|
257
293
|
exports.CdpSolanaWalletProvider = CdpSolanaWalletProvider;
|
|
258
|
-
_CdpSolanaWalletProvider_connection = new WeakMap(),
|
|
294
|
+
_CdpSolanaWalletProvider_connection = new WeakMap(), _CdpSolanaWalletProvider_cdp = new WeakMap(), _CdpSolanaWalletProvider_network = new WeakMap(), _CdpSolanaWalletProvider_serverAccount = new WeakMap();
|
|
@@ -307,4 +307,20 @@ describe("CdpSolanaWalletProvider", () => {
|
|
|
307
307
|
await expect(provider.nativeTransfer(invalidAddress, amount)).rejects.toThrow();
|
|
308
308
|
});
|
|
309
309
|
});
|
|
310
|
+
// =========================================================
|
|
311
|
+
// KeyPairSigner tests
|
|
312
|
+
// =========================================================
|
|
313
|
+
describe("KeyPairSigner", () => {
|
|
314
|
+
it("should handle errors when getting KeyPairSigner", async () => {
|
|
315
|
+
// Mock exportAccount to throw an error
|
|
316
|
+
mockCdpClient.solana.exportAccount = jest.fn().mockRejectedValue(new Error("Export failed"));
|
|
317
|
+
await expect(provider.getKeyPairSigner()).rejects.toThrow("Export failed");
|
|
318
|
+
});
|
|
319
|
+
it("should handle errors gracefully in isKeyPairSigner", async () => {
|
|
320
|
+
// Mock exportAccount to throw an error
|
|
321
|
+
mockCdpClient.solana.exportAccount = jest.fn().mockRejectedValue(new Error("Export failed"));
|
|
322
|
+
const isValid = await provider.isKeyPairSigner();
|
|
323
|
+
expect(isValid).toBe(false);
|
|
324
|
+
});
|
|
325
|
+
});
|
|
310
326
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { KeyPairSigner } from "@solana/kit";
|
|
1
2
|
import { SvmWalletProvider } from "./svmWalletProvider";
|
|
2
3
|
import { RpcResponseAndContext, SignatureStatus, VersionedTransaction, Connection, PublicKey, SignatureResult } from "@solana/web3.js";
|
|
3
4
|
import { Network } from "../network/types";
|
|
@@ -127,4 +128,17 @@ export declare class PrivySvmWalletProvider extends SvmWalletProvider {
|
|
|
127
128
|
* @returns The public key.
|
|
128
129
|
*/
|
|
129
130
|
getPublicKey(): PublicKey;
|
|
131
|
+
/**
|
|
132
|
+
* Sign a message.
|
|
133
|
+
*
|
|
134
|
+
* @param _ - The message to sign as a Uint8Array (unused)
|
|
135
|
+
* @returns Never - throws an error as message signing is not supported yet
|
|
136
|
+
*/
|
|
137
|
+
signMessage(_: Uint8Array): Promise<Uint8Array>;
|
|
138
|
+
/**
|
|
139
|
+
* Get the keypair signer for this wallet.
|
|
140
|
+
*
|
|
141
|
+
* @returns The KeyPairSigner
|
|
142
|
+
*/
|
|
143
|
+
getKeyPairSigner(): Promise<KeyPairSigner>;
|
|
130
144
|
}
|
|
@@ -210,6 +210,23 @@ class PrivySvmWalletProvider extends svmWalletProvider_1.SvmWalletProvider {
|
|
|
210
210
|
getPublicKey() {
|
|
211
211
|
return new web3_js_1.PublicKey(__classPrivateFieldGet(this, _PrivySvmWalletProvider_address, "f"));
|
|
212
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Sign a message.
|
|
215
|
+
*
|
|
216
|
+
* @param _ - The message to sign as a Uint8Array (unused)
|
|
217
|
+
* @returns Never - throws an error as message signing is not supported yet
|
|
218
|
+
*/
|
|
219
|
+
async signMessage(_) {
|
|
220
|
+
throw new Error("Message signing is not supported yet for PrivySvmWalletProvider");
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Get the keypair signer for this wallet.
|
|
224
|
+
*
|
|
225
|
+
* @returns The KeyPairSigner
|
|
226
|
+
*/
|
|
227
|
+
async getKeyPairSigner() {
|
|
228
|
+
throw new Error("getKeyPairSigner is not supported for PrivySvmWalletProvider");
|
|
229
|
+
}
|
|
213
230
|
}
|
|
214
231
|
exports.PrivySvmWalletProvider = PrivySvmWalletProvider;
|
|
215
232
|
_PrivySvmWalletProvider_walletId = new WeakMap(), _PrivySvmWalletProvider_address = new WeakMap(), _PrivySvmWalletProvider_authorizationPrivateKey = new WeakMap(), _PrivySvmWalletProvider_privyClient = new WeakMap(), _PrivySvmWalletProvider_connection = new WeakMap(), _PrivySvmWalletProvider_genesisHash = new WeakMap();
|
|
@@ -307,5 +307,15 @@ describe("PrivySvmWalletProvider", () => {
|
|
|
307
307
|
connection.getBalance = mockMethod;
|
|
308
308
|
await expect(provider.getBalance()).rejects.toThrow("RPC endpoint error");
|
|
309
309
|
});
|
|
310
|
+
it("should throw error when trying to get KeyPairSigner", async () => {
|
|
311
|
+
await expect(provider.getKeyPairSigner()).rejects.toThrow("getKeyPairSigner is not supported for PrivySvmWalletProvider");
|
|
312
|
+
});
|
|
313
|
+
it("should throw error when trying to convert to signer", async () => {
|
|
314
|
+
await expect(provider.toSigner()).rejects.toThrow("getKeyPairSigner is not supported for PrivySvmWalletProvider");
|
|
315
|
+
});
|
|
316
|
+
it("should return false for isKeyPairSigner", async () => {
|
|
317
|
+
const isValid = await provider.isKeyPairSigner();
|
|
318
|
+
expect(isValid).toBe(false);
|
|
319
|
+
});
|
|
310
320
|
});
|
|
311
321
|
});
|
|
@@ -2,6 +2,7 @@ import { SvmWalletProvider } from "./svmWalletProvider";
|
|
|
2
2
|
import { Network } from "../network";
|
|
3
3
|
import { Connection, PublicKey, VersionedTransaction, RpcResponseAndContext, SignatureResult, SignatureStatus, SignatureStatusConfig } from "@solana/web3.js";
|
|
4
4
|
import { SOLANA_CLUSTER, SOLANA_NETWORK_ID } from "../network/svm";
|
|
5
|
+
import { KeyPairSigner } from "@solana/kit";
|
|
5
6
|
/**
|
|
6
7
|
* SolanaKeypairWalletProvider is a wallet provider that uses a local Solana keypair.
|
|
7
8
|
*
|
|
@@ -133,6 +134,13 @@ export declare class SolanaKeypairWalletProvider extends SvmWalletProvider {
|
|
|
133
134
|
* @returns The signature
|
|
134
135
|
*/
|
|
135
136
|
nativeTransfer(to: string, value: string): Promise<string>;
|
|
137
|
+
/**
|
|
138
|
+
* Sign a message.
|
|
139
|
+
*
|
|
140
|
+
* @param _ - The message to sign as a Uint8Array (unused)
|
|
141
|
+
* @returns Never - throws an error as message signing is not supported yet
|
|
142
|
+
*/
|
|
143
|
+
signMessage(_: Uint8Array): Promise<Uint8Array>;
|
|
136
144
|
/**
|
|
137
145
|
* Request SOL tokens from the Solana faucet. This method only works on devnet and testnet networks.
|
|
138
146
|
*
|
|
@@ -140,4 +148,10 @@ export declare class SolanaKeypairWalletProvider extends SvmWalletProvider {
|
|
|
140
148
|
* @returns A Promise that resolves to the signature of the airdrop
|
|
141
149
|
*/
|
|
142
150
|
requestAirdrop(lamports: number): Promise<string>;
|
|
151
|
+
/**
|
|
152
|
+
* Get the keypair signer for this wallet.
|
|
153
|
+
*
|
|
154
|
+
* @returns The KeyPairSigner
|
|
155
|
+
*/
|
|
156
|
+
getKeyPairSigner(): Promise<KeyPairSigner>;
|
|
143
157
|
}
|
|
@@ -265,6 +265,15 @@ class SolanaKeypairWalletProvider extends svmWalletProvider_1.SvmWalletProvider
|
|
|
265
265
|
await this.waitForSignatureResult(signature);
|
|
266
266
|
return signature;
|
|
267
267
|
}
|
|
268
|
+
/**
|
|
269
|
+
* Sign a message.
|
|
270
|
+
*
|
|
271
|
+
* @param _ - The message to sign as a Uint8Array (unused)
|
|
272
|
+
* @returns Never - throws an error as message signing is not supported yet
|
|
273
|
+
*/
|
|
274
|
+
async signMessage(_) {
|
|
275
|
+
throw new Error("Message signing is not supported yet for SolanaKeypairWalletProvider");
|
|
276
|
+
}
|
|
268
277
|
/**
|
|
269
278
|
* Request SOL tokens from the Solana faucet. This method only works on devnet and testnet networks.
|
|
270
279
|
*
|
|
@@ -274,6 +283,14 @@ class SolanaKeypairWalletProvider extends svmWalletProvider_1.SvmWalletProvider
|
|
|
274
283
|
async requestAirdrop(lamports) {
|
|
275
284
|
return await __classPrivateFieldGet(this, _SolanaKeypairWalletProvider_connection, "f").requestAirdrop(__classPrivateFieldGet(this, _SolanaKeypairWalletProvider_keypair, "f").publicKey, lamports);
|
|
276
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Get the keypair signer for this wallet.
|
|
288
|
+
*
|
|
289
|
+
* @returns The KeyPairSigner
|
|
290
|
+
*/
|
|
291
|
+
async getKeyPairSigner() {
|
|
292
|
+
return (0, svmWalletProvider_1.createSignerFromBytes)(__classPrivateFieldGet(this, _SolanaKeypairWalletProvider_keypair, "f").secretKey);
|
|
293
|
+
}
|
|
277
294
|
}
|
|
278
295
|
exports.SolanaKeypairWalletProvider = SolanaKeypairWalletProvider;
|
|
279
296
|
_SolanaKeypairWalletProvider_keypair = new WeakMap(), _SolanaKeypairWalletProvider_connection = new WeakMap(), _SolanaKeypairWalletProvider_genesisHash = new WeakMap();
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { WalletProvider } from "./walletProvider";
|
|
2
2
|
import { Connection, PublicKey, RpcResponseAndContext, SignatureStatus, SignatureStatusConfig, VersionedTransaction, SignatureResult } from "@solana/web3.js";
|
|
3
|
+
import { KeyPairSigner } from "@solana/kit";
|
|
3
4
|
/**
|
|
4
5
|
* SvmWalletProvider is the abstract base class for all Solana wallet providers (non browsers).
|
|
5
6
|
*
|
|
6
7
|
* @abstract
|
|
7
8
|
*/
|
|
8
9
|
export declare abstract class SvmWalletProvider extends WalletProvider {
|
|
10
|
+
/**
|
|
11
|
+
* Convert the wallet provider to a KeyPairSigner.
|
|
12
|
+
*
|
|
13
|
+
* @returns The KeyPairSigner instance
|
|
14
|
+
*/
|
|
15
|
+
toSigner(): Promise<KeyPairSigner>;
|
|
16
|
+
/**
|
|
17
|
+
* Check if this wallet's signer is a valid KeyPairSigner.
|
|
18
|
+
*
|
|
19
|
+
* @returns True if the signer is a valid KeyPairSigner, false otherwise
|
|
20
|
+
*/
|
|
21
|
+
isKeyPairSigner(): Promise<boolean>;
|
|
9
22
|
/**
|
|
10
23
|
* Get the connection instance.
|
|
11
24
|
*
|
|
@@ -53,4 +66,25 @@ export declare abstract class SvmWalletProvider extends WalletProvider {
|
|
|
53
66
|
* @returns The confirmation response
|
|
54
67
|
*/
|
|
55
68
|
abstract waitForSignatureResult(signature: string): Promise<RpcResponseAndContext<SignatureResult>>;
|
|
69
|
+
/**
|
|
70
|
+
* Sign a message.
|
|
71
|
+
*
|
|
72
|
+
* @param message - The message to sign as a Uint8Array
|
|
73
|
+
* @returns The signature as a Uint8Array
|
|
74
|
+
*/
|
|
75
|
+
abstract signMessage(message: Uint8Array): Promise<Uint8Array>;
|
|
76
|
+
/**
|
|
77
|
+
* Get the keypair for this wallet.
|
|
78
|
+
*
|
|
79
|
+
* @returns The CryptoKeyPair for KeyPairSigner compatibility
|
|
80
|
+
*/
|
|
81
|
+
abstract getKeyPairSigner(): Promise<KeyPairSigner>;
|
|
56
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Create a KeyPairSigner from raw bytes.
|
|
85
|
+
*
|
|
86
|
+
* @param bytes - The raw key bytes (32 bytes for private key only, 64 bytes for private + public key)
|
|
87
|
+
* @returns A KeyPairSigner instance
|
|
88
|
+
* @throws Error if the byte length is not 32 or 64
|
|
89
|
+
*/
|
|
90
|
+
export declare function createSignerFromBytes(bytes: Uint8Array): Promise<KeyPairSigner>;
|
|
@@ -2,12 +2,55 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.SvmWalletProvider = void 0;
|
|
5
|
+
exports.createSignerFromBytes = createSignerFromBytes;
|
|
5
6
|
const walletProvider_1 = require("./walletProvider");
|
|
7
|
+
const kit_1 = require("@solana/kit");
|
|
6
8
|
/**
|
|
7
9
|
* SvmWalletProvider is the abstract base class for all Solana wallet providers (non browsers).
|
|
8
10
|
*
|
|
9
11
|
* @abstract
|
|
10
12
|
*/
|
|
11
13
|
class SvmWalletProvider extends walletProvider_1.WalletProvider {
|
|
14
|
+
/**
|
|
15
|
+
* Convert the wallet provider to a KeyPairSigner.
|
|
16
|
+
*
|
|
17
|
+
* @returns The KeyPairSigner instance
|
|
18
|
+
*/
|
|
19
|
+
async toSigner() {
|
|
20
|
+
return this.getKeyPairSigner();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if this wallet's signer is a valid KeyPairSigner.
|
|
24
|
+
*
|
|
25
|
+
* @returns True if the signer is a valid KeyPairSigner, false otherwise
|
|
26
|
+
*/
|
|
27
|
+
async isKeyPairSigner() {
|
|
28
|
+
try {
|
|
29
|
+
const signer = await this.toSigner();
|
|
30
|
+
return (0, kit_1.isKeyPairSigner)(signer);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
12
36
|
}
|
|
13
37
|
exports.SvmWalletProvider = SvmWalletProvider;
|
|
38
|
+
/**
|
|
39
|
+
* Create a KeyPairSigner from raw bytes.
|
|
40
|
+
*
|
|
41
|
+
* @param bytes - The raw key bytes (32 bytes for private key only, 64 bytes for private + public key)
|
|
42
|
+
* @returns A KeyPairSigner instance
|
|
43
|
+
* @throws Error if the byte length is not 32 or 64
|
|
44
|
+
*/
|
|
45
|
+
async function createSignerFromBytes(bytes) {
|
|
46
|
+
// generate a keypair signer from the bytes based on the byte-length
|
|
47
|
+
// 64 bytes represents concatenated private + public key
|
|
48
|
+
if (bytes.length === 64) {
|
|
49
|
+
return await (0, kit_1.createKeyPairSignerFromBytes)(bytes);
|
|
50
|
+
}
|
|
51
|
+
// 32 bytes represents only the private key
|
|
52
|
+
if (bytes.length === 32) {
|
|
53
|
+
return await (0, kit_1.createKeyPairSignerFromPrivateKeyBytes)(bytes);
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`Unexpected key length: ${bytes.length}. Expected 32 or 64 bytes.`);
|
|
56
|
+
}
|
|
@@ -52,4 +52,14 @@ describe("SvmWalletProvider", () => {
|
|
|
52
52
|
expect(getConnectionDescriptor).toBeDefined();
|
|
53
53
|
expect(typeof getConnectionDescriptor.value).toBe("function");
|
|
54
54
|
});
|
|
55
|
+
it("should have toSigner method", () => {
|
|
56
|
+
const toSignerDescriptor = Object.getOwnPropertyDescriptor(svmWalletProvider_1.SvmWalletProvider.prototype, "toSigner");
|
|
57
|
+
expect(toSignerDescriptor).toBeDefined();
|
|
58
|
+
expect(typeof toSignerDescriptor.value).toBe("function");
|
|
59
|
+
});
|
|
60
|
+
it("should have isKeyPairSigner method", () => {
|
|
61
|
+
const isKeyPairSignerDescriptor = Object.getOwnPropertyDescriptor(svmWalletProvider_1.SvmWalletProvider.prototype, "isKeyPairSigner");
|
|
62
|
+
expect(isKeyPairSignerDescriptor).toBeDefined();
|
|
63
|
+
expect(typeof isKeyPairSignerDescriptor.value).toBe("function");
|
|
64
|
+
});
|
|
55
65
|
});
|
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.10.
|
|
5
|
+
"version": "0.10.3",
|
|
6
6
|
"author": "Coinbase Inc.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@jup-ag/api": "^6.0.39",
|
|
32
32
|
"@privy-io/public-api": "2.18.5",
|
|
33
33
|
"@privy-io/server-auth": "1.18.4",
|
|
34
|
+
"@solana/kit": "^2.1.1",
|
|
34
35
|
"@solana/spl-token": "^0.4.12",
|
|
35
36
|
"@solana/web3.js": "^1.98.1",
|
|
36
37
|
"@zerodev/ecdsa-validator": "^5.4.5",
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"md5": "^2.3.0",
|
|
48
49
|
"opensea-js": "^7.1.18",
|
|
49
50
|
"reflect-metadata": "^0.2.2",
|
|
51
|
+
"@ensofinance/sdk": "^2.0.6",
|
|
50
52
|
"twitter-api-v2": "^1.18.2",
|
|
51
53
|
"viem": "^2.22.16",
|
|
52
54
|
"x402": "^0.6.0",
|