@coinbase/agentkit 0.10.1 → 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 +179 -40
- package/dist/action-providers/across/schemas.d.ts +1 -1
- package/dist/action-providers/baseAccount/baseAccountActionProvider.d.ts +46 -0
- package/dist/action-providers/baseAccount/baseAccountActionProvider.js +404 -0
- package/dist/action-providers/baseAccount/baseAccountActionProvider.test.d.ts +1 -0
- package/dist/action-providers/baseAccount/baseAccountActionProvider.test.js +325 -0
- package/dist/action-providers/baseAccount/index.d.ts +2 -0
- package/dist/action-providers/baseAccount/index.js +18 -0
- package/dist/action-providers/baseAccount/schemas.d.ts +43 -0
- package/dist/action-providers/baseAccount/schemas.js +62 -0
- package/dist/action-providers/baseAccount/types.d.ts +17 -0
- package/dist/action-providers/baseAccount/types.js +2 -0
- package/dist/action-providers/baseAccount/utils.d.ts +14 -0
- package/dist/action-providers/baseAccount/utils.js +57 -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/cdpEvmWalletActionProvider.js +2 -1
- package/dist/action-providers/cdp/cdpEvmWalletActionProvider.test.js +3 -1
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.js +2 -1
- package/dist/action-providers/cdp/cdpSmartWalletActionProvider.test.js +3 -1
- package/dist/action-providers/cdp/faucetUtils.d.ts +38 -0
- package/dist/action-providers/cdp/faucetUtils.js +81 -0
- package/dist/action-providers/cdp/swapUtils.d.ts +0 -9
- package/dist/action-providers/cdp/swapUtils.js +0 -36
- package/dist/action-providers/clanker/schemas.d.ts +6 -6
- 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/flaunch/client_utils.d.ts +25 -0
- package/dist/action-providers/flaunch/client_utils.js +62 -0
- package/dist/action-providers/flaunch/constants.d.ts +41 -20
- package/dist/action-providers/flaunch/constants.js +111 -36
- package/dist/action-providers/flaunch/flaunchActionProvider.d.ts +4 -43
- package/dist/action-providers/flaunch/flaunchActionProvider.js +132 -200
- package/dist/action-providers/flaunch/flaunchActionProvider.test.js +108 -13
- package/dist/action-providers/flaunch/metadata_utils.d.ts +12 -0
- package/dist/action-providers/flaunch/metadata_utils.js +216 -0
- package/dist/action-providers/flaunch/schemas.d.ts +39 -3
- package/dist/action-providers/flaunch/schemas.js +62 -10
- package/dist/action-providers/flaunch/{utils.d.ts → swap_utils.d.ts} +17 -19
- package/dist/action-providers/flaunch/{utils.js → swap_utils.js} +137 -172
- package/dist/action-providers/index.d.ts +4 -1
- package/dist/action-providers/index.js +4 -1
- package/dist/action-providers/pyth/pythActionProvider.d.ts +2 -2
- package/dist/action-providers/pyth/pythActionProvider.js +83 -31
- package/dist/action-providers/pyth/pythActionProvider.test.js +178 -26
- package/dist/action-providers/pyth/schemas.d.ts +6 -0
- package/dist/action-providers/pyth/schemas.js +9 -1
- package/dist/action-providers/superfluid/superfluidSuperTokenCreatorActionProvider.js +5 -4
- package/dist/action-providers/superfluid/utils/parseLogs.d.ts +2 -1
- package/dist/action-providers/superfluid/utils/parseLogs.js +6 -3
- package/dist/action-providers/wallet/walletActionProvider.js +4 -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/schemas.d.ts +7 -0
- package/dist/action-providers/x402/schemas.js +11 -1
- package/dist/action-providers/x402/utils.d.ts +55 -0
- package/dist/action-providers/x402/utils.js +197 -0
- package/dist/action-providers/x402/x402ActionProvider.d.ts +14 -14
- package/dist/action-providers/x402/x402ActionProvider.js +179 -45
- package/dist/action-providers/x402/x402ActionProvider.test.js +162 -12
- 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/utils.d.ts +10 -0
- package/dist/utils.js +43 -13
- package/dist/wallet-providers/cdpEvmWalletProvider.d.ts +7 -0
- package/dist/wallet-providers/cdpEvmWalletProvider.js +14 -21
- package/dist/wallet-providers/cdpEvmWalletProvider.test.js +7 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.d.ts +7 -0
- package/dist/wallet-providers/cdpSmartWalletProvider.js +23 -8
- package/dist/wallet-providers/cdpSmartWalletProvider.test.js +6 -10
- 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/evmWalletProvider.d.ts +9 -2
- package/dist/wallet-providers/evmWalletProvider.js +4 -0
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.d.ts +9 -0
- package/dist/wallet-providers/legacyCdpSmartWalletProvider.js +11 -0
- package/dist/wallet-providers/legacyCdpWalletProvider.d.ts +7 -0
- package/dist/wallet-providers/legacyCdpWalletProvider.js +16 -0
- package/dist/wallet-providers/legacyCdpWalletProvider.test.js +6 -0
- package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.d.ts +7 -0
- package/dist/wallet-providers/privyEvmDelegatedEmbeddedWalletProvider.js +27 -0
- package/dist/wallet-providers/privyEvmWalletProvider.test.js +11 -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/dist/wallet-providers/viemWalletProvider.d.ts +8 -1
- package/dist/wallet-providers/viemWalletProvider.js +21 -1
- package/dist/wallet-providers/viemWalletProvider.test.js +21 -1
- package/dist/wallet-providers/zeroDevWalletProvider.d.ts +7 -0
- package/dist/wallet-providers/zeroDevWalletProvider.js +12 -0
- package/dist/wallet-providers/zeroDevWalletProvider.test.js +10 -0
- package/package.json +8 -4
|
@@ -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
|
});
|
|
@@ -30,13 +30,20 @@ export declare class ViemWalletProvider extends EvmWalletProvider {
|
|
|
30
30
|
* @param gasConfig - Configuration for gas multipliers.
|
|
31
31
|
*/
|
|
32
32
|
constructor(walletClient: ViemWalletClient, gasConfig?: ViemWalletProviderGasConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Signs a raw hash.
|
|
35
|
+
*
|
|
36
|
+
* @param hash - The hash to sign.
|
|
37
|
+
* @returns The signed hash.
|
|
38
|
+
*/
|
|
39
|
+
sign(hash: `0x${string}`): Promise<`0x${string}`>;
|
|
33
40
|
/**
|
|
34
41
|
* Signs a message.
|
|
35
42
|
*
|
|
36
43
|
* @param message - The message to sign.
|
|
37
44
|
* @returns The signed message.
|
|
38
45
|
*/
|
|
39
|
-
signMessage(message: string): Promise<`0x${string}`>;
|
|
46
|
+
signMessage(message: string | Uint8Array): Promise<`0x${string}`>;
|
|
40
47
|
/**
|
|
41
48
|
* Signs a typed data object.
|
|
42
49
|
*
|
|
@@ -44,6 +44,22 @@ class ViemWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
44
44
|
__classPrivateFieldSet(this, _ViemWalletProvider_gasLimitMultiplier, Math.max(gasConfig?.gasLimitMultiplier ?? 1.2, 1), "f");
|
|
45
45
|
__classPrivateFieldSet(this, _ViemWalletProvider_feePerGasMultiplier, Math.max(gasConfig?.feePerGasMultiplier ?? 1, 1), "f");
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Signs a raw hash.
|
|
49
|
+
*
|
|
50
|
+
* @param hash - The hash to sign.
|
|
51
|
+
* @returns The signed hash.
|
|
52
|
+
*/
|
|
53
|
+
async sign(hash) {
|
|
54
|
+
const account = __classPrivateFieldGet(this, _ViemWalletProvider_walletClient, "f").account;
|
|
55
|
+
if (!account) {
|
|
56
|
+
throw new Error("Account not found");
|
|
57
|
+
}
|
|
58
|
+
if (!account.sign) {
|
|
59
|
+
throw new Error("Account does not support raw hash signing");
|
|
60
|
+
}
|
|
61
|
+
return account.sign({ hash });
|
|
62
|
+
}
|
|
47
63
|
/**
|
|
48
64
|
* Signs a message.
|
|
49
65
|
*
|
|
@@ -55,7 +71,11 @@ class ViemWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
55
71
|
if (!account) {
|
|
56
72
|
throw new Error("Account not found");
|
|
57
73
|
}
|
|
58
|
-
|
|
74
|
+
const _message = typeof message === "string" ? ((0, viem_1.isHex)(message) ? message : (0, viem_1.toHex)(message)) : message;
|
|
75
|
+
return __classPrivateFieldGet(this, _ViemWalletProvider_walletClient, "f").signMessage({
|
|
76
|
+
account,
|
|
77
|
+
message: { raw: _message },
|
|
78
|
+
});
|
|
59
79
|
}
|
|
60
80
|
/**
|
|
61
81
|
* Signs a typed data object.
|
|
@@ -104,6 +104,8 @@ jest.mock("viem", () => {
|
|
|
104
104
|
fromHex: jest.fn(),
|
|
105
105
|
formatEther: jest.fn(),
|
|
106
106
|
privateKeyToAccount: jest.fn(),
|
|
107
|
+
isHex: jest.fn(value => typeof value === "string" && value.startsWith("0x")),
|
|
108
|
+
toHex: jest.fn(value => `0x${value}`),
|
|
107
109
|
};
|
|
108
110
|
});
|
|
109
111
|
jest.mock("viem/accounts", () => {
|
|
@@ -119,6 +121,7 @@ describe("ViemWalletProvider", () => {
|
|
|
119
121
|
jest.clearAllMocks();
|
|
120
122
|
const mockAccount = {
|
|
121
123
|
address: MOCK_ADDRESS,
|
|
124
|
+
sign: jest.fn().mockResolvedValue(MOCK_SIGNATURE),
|
|
122
125
|
};
|
|
123
126
|
mockPublicClient = {
|
|
124
127
|
chain: MOCK_CHAIN,
|
|
@@ -209,11 +212,28 @@ describe("ViemWalletProvider", () => {
|
|
|
209
212
|
});
|
|
210
213
|
});
|
|
211
214
|
describe("signing operations", () => {
|
|
215
|
+
it("should sign a hash", async () => {
|
|
216
|
+
const testHash = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
|
|
217
|
+
const signature = await provider.sign(testHash);
|
|
218
|
+
expect(mockWalletClient.account?.sign).toHaveBeenCalledWith({
|
|
219
|
+
hash: testHash,
|
|
220
|
+
});
|
|
221
|
+
expect(signature).toBe(MOCK_SIGNATURE);
|
|
222
|
+
});
|
|
212
223
|
it("should sign a message", async () => {
|
|
213
224
|
const signature = await provider.signMessage(MOCK_MESSAGE);
|
|
214
225
|
expect(mockWalletClient.signMessage).toHaveBeenCalledWith({
|
|
215
226
|
account: mockWalletClient.account,
|
|
216
|
-
message: MOCK_MESSAGE,
|
|
227
|
+
message: { raw: `0x${MOCK_MESSAGE}` },
|
|
228
|
+
});
|
|
229
|
+
expect(signature).toBe(MOCK_SIGNATURE);
|
|
230
|
+
});
|
|
231
|
+
it("should sign a hex message", async () => {
|
|
232
|
+
const hexMessage = "0x48656c6c6f2c20576f726c6421"; // "Hello, World!" in hex
|
|
233
|
+
const signature = await provider.signMessage(hexMessage);
|
|
234
|
+
expect(mockWalletClient.signMessage).toHaveBeenCalledWith({
|
|
235
|
+
account: mockWalletClient.account,
|
|
236
|
+
message: { raw: hexMessage },
|
|
217
237
|
});
|
|
218
238
|
expect(signature).toBe(MOCK_SIGNATURE);
|
|
219
239
|
});
|
|
@@ -53,6 +53,13 @@ export declare class ZeroDevWalletProvider extends EvmWalletProvider {
|
|
|
53
53
|
* @returns A Promise that resolves to a new ZeroDevWalletProvider instance.
|
|
54
54
|
*/
|
|
55
55
|
static configureWithWallet(config: ZeroDevWalletProviderConfig): Promise<ZeroDevWalletProvider>;
|
|
56
|
+
/**
|
|
57
|
+
* Signs a raw hash using the Kernel account.
|
|
58
|
+
*
|
|
59
|
+
* @param hash - The hash to sign.
|
|
60
|
+
* @returns The signed hash.
|
|
61
|
+
*/
|
|
62
|
+
sign(hash: `0x${string}`): Promise<Hex>;
|
|
56
63
|
/**
|
|
57
64
|
* Signs a message using the Kernel account.
|
|
58
65
|
*
|
|
@@ -105,6 +105,18 @@ class ZeroDevWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
|
105
105
|
});
|
|
106
106
|
return new ZeroDevWalletProvider(config, kernelAccount, intentClient);
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Signs a raw hash using the Kernel account.
|
|
110
|
+
*
|
|
111
|
+
* @param hash - The hash to sign.
|
|
112
|
+
* @returns The signed hash.
|
|
113
|
+
*/
|
|
114
|
+
async sign(hash) {
|
|
115
|
+
if (!__classPrivateFieldGet(this, _ZeroDevWalletProvider_kernelAccount, "f").sign) {
|
|
116
|
+
throw new Error("Kernel account does not support raw hash signing");
|
|
117
|
+
}
|
|
118
|
+
return __classPrivateFieldGet(this, _ZeroDevWalletProvider_kernelAccount, "f").sign({ hash });
|
|
119
|
+
}
|
|
108
120
|
/**
|
|
109
121
|
* Signs a message using the Kernel account.
|
|
110
122
|
*
|
|
@@ -65,6 +65,7 @@ jest.mock("../analytics", () => ({
|
|
|
65
65
|
// =========================================================
|
|
66
66
|
const mockKernelAccount = {
|
|
67
67
|
address: MOCK_ADDRESS,
|
|
68
|
+
sign: jest.fn(),
|
|
68
69
|
signMessage: jest.fn(),
|
|
69
70
|
signTypedData: jest.fn(),
|
|
70
71
|
};
|
|
@@ -101,6 +102,7 @@ describe("ZeroDevWalletProvider", () => {
|
|
|
101
102
|
transactionHash: MOCK_TRANSACTION_HASH,
|
|
102
103
|
});
|
|
103
104
|
mockPublicClient.getBalance.mockResolvedValue(BigInt(1000000000000000000));
|
|
105
|
+
mockKernelAccount.sign.mockResolvedValue(MOCK_SIGNATURE);
|
|
104
106
|
mockKernelAccount.signMessage.mockResolvedValue(MOCK_SIGNATURE);
|
|
105
107
|
mockKernelAccount.signTypedData.mockResolvedValue(MOCK_SIGNATURE);
|
|
106
108
|
// Mock Intent Client behavior
|
|
@@ -193,6 +195,14 @@ describe("ZeroDevWalletProvider", () => {
|
|
|
193
195
|
// Signing Operations Tests
|
|
194
196
|
// =========================================================
|
|
195
197
|
describe("signing operations", () => {
|
|
198
|
+
it("should sign a hash", async () => {
|
|
199
|
+
const testHash = "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef";
|
|
200
|
+
const signature = await provider.sign(testHash);
|
|
201
|
+
expect(mockKernelAccount.sign).toHaveBeenCalledWith({
|
|
202
|
+
hash: testHash,
|
|
203
|
+
});
|
|
204
|
+
expect(signature).toBe(MOCK_SIGNATURE);
|
|
205
|
+
});
|
|
196
206
|
it("should sign messages", async () => {
|
|
197
207
|
const message = "Hello, world!";
|
|
198
208
|
const signature = await provider.signMessage(message);
|
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",
|
|
@@ -24,11 +24,14 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@across-protocol/app-sdk": "^0.2.0",
|
|
26
26
|
"@alloralabs/allora-sdk": "^0.1.0",
|
|
27
|
-
"@
|
|
27
|
+
"@base-org/account": "^2.2.0",
|
|
28
|
+
"@coinbase/cdp-sdk": "^1.38.0",
|
|
28
29
|
"@coinbase/coinbase-sdk": "^0.20.0",
|
|
30
|
+
"@coinbase/x402": "^0.6.3",
|
|
29
31
|
"@jup-ag/api": "^6.0.39",
|
|
30
32
|
"@privy-io/public-api": "2.18.5",
|
|
31
33
|
"@privy-io/server-auth": "1.18.4",
|
|
34
|
+
"@solana/kit": "^2.1.1",
|
|
32
35
|
"@solana/spl-token": "^0.4.12",
|
|
33
36
|
"@solana/web3.js": "^1.98.1",
|
|
34
37
|
"@zerodev/ecdsa-validator": "^5.4.5",
|
|
@@ -45,10 +48,11 @@
|
|
|
45
48
|
"md5": "^2.3.0",
|
|
46
49
|
"opensea-js": "^7.1.18",
|
|
47
50
|
"reflect-metadata": "^0.2.2",
|
|
51
|
+
"@ensofinance/sdk": "^2.0.6",
|
|
48
52
|
"twitter-api-v2": "^1.18.2",
|
|
49
53
|
"viem": "^2.22.16",
|
|
50
|
-
"x402": "^0.
|
|
51
|
-
"x402-axios": "^0.
|
|
54
|
+
"x402": "^0.6.0",
|
|
55
|
+
"x402-axios": "^0.6.0",
|
|
52
56
|
"zod": "^3.23.8"
|
|
53
57
|
},
|
|
54
58
|
"devDependencies": {
|