@coinbase/agentkit 0.0.0-nightly-20250328174338
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 +827 -0
- package/dist/action-providers/across/acrossActionProvider.d.ts +50 -0
- package/dist/action-providers/across/acrossActionProvider.js +333 -0
- package/dist/action-providers/across/acrossActionProvider.test.d.ts +1 -0
- package/dist/action-providers/across/acrossActionProvider.test.js +391 -0
- package/dist/action-providers/across/constants.d.ts +1 -0
- package/dist/action-providers/across/constants.js +2 -0
- package/dist/action-providers/across/index.d.ts +1 -0
- package/dist/action-providers/across/index.js +17 -0
- package/dist/action-providers/across/schemas.d.ts +36 -0
- package/dist/action-providers/across/schemas.js +46 -0
- package/dist/action-providers/across/utils.d.ts +7 -0
- package/dist/action-providers/across/utils.js +25 -0
- package/dist/action-providers/actionDecorator.d.ts +69 -0
- package/dist/action-providers/actionDecorator.js +96 -0
- package/dist/action-providers/actionProvider.d.ts +48 -0
- package/dist/action-providers/actionProvider.js +62 -0
- package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.d.ts +55 -0
- package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.js +173 -0
- package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.test.d.ts +1 -0
- package/dist/action-providers/alchemy/alchemyTokenPricesActionProvider.test.js +131 -0
- package/dist/action-providers/alchemy/index.d.ts +2 -0
- package/dist/action-providers/alchemy/index.js +18 -0
- package/dist/action-providers/alchemy/schemas.d.ts +41 -0
- package/dist/action-providers/alchemy/schemas.js +34 -0
- package/dist/action-providers/allora/alloraActionProvider.d.ts +44 -0
- package/dist/action-providers/allora/alloraActionProvider.js +195 -0
- package/dist/action-providers/allora/alloraActionProvider.test.d.ts +1 -0
- package/dist/action-providers/allora/alloraActionProvider.test.js +109 -0
- package/dist/action-providers/allora/index.d.ts +2 -0
- package/dist/action-providers/allora/index.js +18 -0
- package/dist/action-providers/allora/schemas.d.ts +28 -0
- package/dist/action-providers/allora/schemas.js +30 -0
- package/dist/action-providers/basename/basenameActionProvider.d.ts +30 -0
- package/dist/action-providers/basename/basenameActionProvider.js +109 -0
- package/dist/action-providers/basename/basenameActionProvider.test.d.ts +1 -0
- package/dist/action-providers/basename/basenameActionProvider.test.js +146 -0
- package/dist/action-providers/basename/constants.d.ts +52 -0
- package/dist/action-providers/basename/constants.js +81 -0
- package/dist/action-providers/basename/index.d.ts +2 -0
- package/dist/action-providers/basename/index.js +18 -0
- package/dist/action-providers/basename/schemas.d.ts +14 -0
- package/dist/action-providers/basename/schemas.js +14 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.d.ts +43 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.js +128 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.test.d.ts +1 -0
- package/dist/action-providers/cdp/cdpApiActionProvider.test.js +146 -0
- package/dist/action-providers/cdp/cdpWalletActionProvider.d.ts +58 -0
- package/dist/action-providers/cdp/cdpWalletActionProvider.js +224 -0
- package/dist/action-providers/cdp/cdpWalletActionProvider.test.d.ts +1 -0
- package/dist/action-providers/cdp/cdpWalletActionProvider.test.js +267 -0
- package/dist/action-providers/cdp/constants.d.ts +31 -0
- package/dist/action-providers/cdp/constants.js +34 -0
- package/dist/action-providers/cdp/index.d.ts +3 -0
- package/dist/action-providers/cdp/index.js +19 -0
- package/dist/action-providers/cdp/schemas.d.ts +91 -0
- package/dist/action-providers/cdp/schemas.js +77 -0
- package/dist/action-providers/compound/compoundActionProvider.d.ts +67 -0
- package/dist/action-providers/compound/compoundActionProvider.js +365 -0
- package/dist/action-providers/compound/compoundActionProvider.test.d.ts +1 -0
- package/dist/action-providers/compound/compoundActionProvider.test.js +353 -0
- package/dist/action-providers/compound/constants.d.ts +180 -0
- package/dist/action-providers/compound/constants.js +129 -0
- package/dist/action-providers/compound/index.d.ts +1 -0
- package/dist/action-providers/compound/index.js +17 -0
- package/dist/action-providers/compound/schemas.d.ts +57 -0
- package/dist/action-providers/compound/schemas.js +58 -0
- package/dist/action-providers/compound/utils.d.ts +95 -0
- package/dist/action-providers/compound/utils.js +353 -0
- package/dist/action-providers/customActionProvider.d.ts +30 -0
- package/dist/action-providers/customActionProvider.js +66 -0
- package/dist/action-providers/defillama/constants.d.ts +8 -0
- package/dist/action-providers/defillama/constants.js +11 -0
- package/dist/action-providers/defillama/defillamaActionProvider.d.ts +54 -0
- package/dist/action-providers/defillama/defillamaActionProvider.js +180 -0
- package/dist/action-providers/defillama/defillamaActionProvider.test.d.ts +1 -0
- package/dist/action-providers/defillama/defillamaActionProvider.test.js +114 -0
- package/dist/action-providers/defillama/index.d.ts +1 -0
- package/dist/action-providers/defillama/index.js +17 -0
- package/dist/action-providers/defillama/schemas.d.ts +34 -0
- package/dist/action-providers/defillama/schemas.js +34 -0
- package/dist/action-providers/defillama/types.d.ts +73 -0
- package/dist/action-providers/defillama/types.js +2 -0
- package/dist/action-providers/defillama/utils.d.ts +10 -0
- package/dist/action-providers/defillama/utils.js +87 -0
- package/dist/action-providers/defillama/utils.test.d.ts +1 -0
- package/dist/action-providers/defillama/utils.test.js +124 -0
- package/dist/action-providers/erc20/constants.d.ts +137 -0
- package/dist/action-providers/erc20/constants.js +202 -0
- package/dist/action-providers/erc20/erc20ActionProvider.d.ts +38 -0
- package/dist/action-providers/erc20/erc20ActionProvider.js +142 -0
- package/dist/action-providers/erc20/erc20ActionProvider.test.d.ts +1 -0
- package/dist/action-providers/erc20/erc20ActionProvider.test.js +131 -0
- package/dist/action-providers/erc20/index.d.ts +1 -0
- package/dist/action-providers/erc20/index.js +17 -0
- package/dist/action-providers/erc20/schemas.d.ts +27 -0
- package/dist/action-providers/erc20/schemas.js +26 -0
- package/dist/action-providers/erc721/constants.d.ts +232 -0
- package/dist/action-providers/erc721/constants.js +298 -0
- package/dist/action-providers/erc721/erc721ActionProvider.d.ts +46 -0
- package/dist/action-providers/erc721/erc721ActionProvider.js +164 -0
- package/dist/action-providers/erc721/erc721ActionProvider.test.d.ts +1 -0
- package/dist/action-providers/erc721/erc721ActionProvider.test.js +137 -0
- package/dist/action-providers/erc721/index.d.ts +1 -0
- package/dist/action-providers/erc721/index.js +17 -0
- package/dist/action-providers/erc721/schemas.d.ts +46 -0
- package/dist/action-providers/erc721/schemas.js +44 -0
- package/dist/action-providers/farcaster/farcasterActionProvider.d.ts +57 -0
- package/dist/action-providers/farcaster/farcasterActionProvider.js +142 -0
- package/dist/action-providers/farcaster/farcasterActionProvider.test.d.ts +1 -0
- package/dist/action-providers/farcaster/farcasterActionProvider.test.js +151 -0
- package/dist/action-providers/farcaster/index.d.ts +2 -0
- package/dist/action-providers/farcaster/index.js +18 -0
- package/dist/action-providers/farcaster/schemas.d.ts +15 -0
- package/dist/action-providers/farcaster/schemas.js +20 -0
- package/dist/action-providers/index.d.ts +24 -0
- package/dist/action-providers/index.js +40 -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/messari/constants.d.ts +17 -0
- package/dist/action-providers/messari/constants.js +20 -0
- package/dist/action-providers/messari/index.d.ts +5 -0
- package/dist/action-providers/messari/index.js +21 -0
- package/dist/action-providers/messari/messariActionProvider.d.ts +42 -0
- package/dist/action-providers/messari/messariActionProvider.js +128 -0
- package/dist/action-providers/messari/messariActionProvider.test.d.ts +1 -0
- package/dist/action-providers/messari/messariActionProvider.test.js +152 -0
- package/dist/action-providers/messari/schemas.d.ts +11 -0
- package/dist/action-providers/messari/schemas.js +16 -0
- package/dist/action-providers/messari/types.d.ts +40 -0
- package/dist/action-providers/messari/types.js +2 -0
- package/dist/action-providers/messari/utils.d.ts +22 -0
- package/dist/action-providers/messari/utils.js +65 -0
- package/dist/action-providers/moonwell/constants.d.ts +78 -0
- package/dist/action-providers/moonwell/constants.js +111 -0
- package/dist/action-providers/moonwell/index.d.ts +1 -0
- package/dist/action-providers/moonwell/index.js +5 -0
- package/dist/action-providers/moonwell/moonwellActionProvider.d.ts +39 -0
- package/dist/action-providers/moonwell/moonwellActionProvider.js +249 -0
- package/dist/action-providers/moonwell/moonwellActionProvider.test.d.ts +1 -0
- package/dist/action-providers/moonwell/moonwellActionProvider.test.js +455 -0
- package/dist/action-providers/moonwell/schemas.d.ts +30 -0
- package/dist/action-providers/moonwell/schemas.js +39 -0
- package/dist/action-providers/morpho/constants.d.ts +16 -0
- package/dist/action-providers/morpho/constants.js +27 -0
- package/dist/action-providers/morpho/index.d.ts +2 -0
- package/dist/action-providers/morpho/index.js +18 -0
- package/dist/action-providers/morpho/morphoActionProvider.d.ts +39 -0
- package/dist/action-providers/morpho/morphoActionProvider.js +154 -0
- package/dist/action-providers/morpho/morphoActionProvider.test.d.ts +1 -0
- package/dist/action-providers/morpho/morphoActionProvider.test.js +128 -0
- package/dist/action-providers/morpho/schemas.d.ts +36 -0
- package/dist/action-providers/morpho/schemas.js +47 -0
- package/dist/action-providers/opensea/index.d.ts +1 -0
- package/dist/action-providers/opensea/index.js +17 -0
- package/dist/action-providers/opensea/openseaActionProvider.d.ts +59 -0
- package/dist/action-providers/opensea/openseaActionProvider.js +146 -0
- package/dist/action-providers/opensea/openseaActionProvider.test.d.ts +1 -0
- package/dist/action-providers/opensea/openseaActionProvider.test.js +201 -0
- package/dist/action-providers/opensea/schemas.d.ts +30 -0
- package/dist/action-providers/opensea/schemas.js +33 -0
- package/dist/action-providers/opensea/utils.d.ts +12 -0
- package/dist/action-providers/opensea/utils.js +47 -0
- package/dist/action-providers/pyth/index.d.ts +2 -0
- package/dist/action-providers/pyth/index.js +18 -0
- package/dist/action-providers/pyth/pythActionProvider.d.ts +33 -0
- package/dist/action-providers/pyth/pythActionProvider.js +121 -0
- package/dist/action-providers/pyth/pythActionProvider.test.d.ts +1 -0
- package/dist/action-providers/pyth/pythActionProvider.test.js +113 -0
- package/dist/action-providers/pyth/schemas.d.ts +21 -0
- package/dist/action-providers/pyth/schemas.js +20 -0
- package/dist/action-providers/spl/index.d.ts +1 -0
- package/dist/action-providers/spl/index.js +17 -0
- package/dist/action-providers/spl/schemas.d.ts +30 -0
- package/dist/action-providers/spl/schemas.js +26 -0
- package/dist/action-providers/spl/splActionProvider.d.ts +45 -0
- package/dist/action-providers/spl/splActionProvider.js +173 -0
- package/dist/action-providers/spl/splActionProvider.test.d.ts +1 -0
- package/dist/action-providers/spl/splActionProvider.test.js +300 -0
- package/dist/action-providers/twitter/index.d.ts +2 -0
- package/dist/action-providers/twitter/index.js +18 -0
- package/dist/action-providers/twitter/schemas.d.ts +38 -0
- package/dist/action-providers/twitter/schemas.js +44 -0
- package/dist/action-providers/twitter/twitterActionProvider.d.ts +82 -0
- package/dist/action-providers/twitter/twitterActionProvider.js +204 -0
- package/dist/action-providers/twitter/twitterActionProvider.test.d.ts +1 -0
- package/dist/action-providers/twitter/twitterActionProvider.test.js +185 -0
- package/dist/action-providers/wallet/index.d.ts +1 -0
- package/dist/action-providers/wallet/index.js +17 -0
- package/dist/action-providers/wallet/schemas.d.ts +19 -0
- package/dist/action-providers/wallet/schemas.js +19 -0
- package/dist/action-providers/wallet/walletActionProvider.d.ts +44 -0
- package/dist/action-providers/wallet/walletActionProvider.js +140 -0
- package/dist/action-providers/wallet/walletActionProvider.test.d.ts +1 -0
- package/dist/action-providers/wallet/walletActionProvider.test.js +194 -0
- package/dist/action-providers/weth/constants.d.ts +19 -0
- package/dist/action-providers/weth/constants.js +29 -0
- package/dist/action-providers/weth/index.d.ts +1 -0
- package/dist/action-providers/weth/index.js +17 -0
- package/dist/action-providers/weth/schemas.d.ts +8 -0
- package/dist/action-providers/weth/schemas.js +10 -0
- package/dist/action-providers/weth/wethActionProvider.d.ts +30 -0
- package/dist/action-providers/weth/wethActionProvider.js +89 -0
- package/dist/action-providers/weth/wethActionProvider.test.d.ts +1 -0
- package/dist/action-providers/weth/wethActionProvider.test.js +92 -0
- package/dist/action-providers/wow/constants.d.ts +15 -0
- package/dist/action-providers/wow/constants.js +844 -0
- package/dist/action-providers/wow/index.d.ts +2 -0
- package/dist/action-providers/wow/index.js +18 -0
- package/dist/action-providers/wow/schemas.d.ts +43 -0
- package/dist/action-providers/wow/schemas.js +47 -0
- package/dist/action-providers/wow/uniswap/constants.d.ts +3 -0
- package/dist/action-providers/wow/uniswap/constants.js +100 -0
- package/dist/action-providers/wow/uniswap/utils.d.ts +82 -0
- package/dist/action-providers/wow/uniswap/utils.js +226 -0
- package/dist/action-providers/wow/utils.d.ts +27 -0
- package/dist/action-providers/wow/utils.js +63 -0
- package/dist/action-providers/wow/wowActionProvider.d.ts +46 -0
- package/dist/action-providers/wow/wowActionProvider.js +223 -0
- package/dist/action-providers/wow/wowActionProvider.test.d.ts +1 -0
- package/dist/action-providers/wow/wowActionProvider.test.js +291 -0
- package/dist/agentkit.d.ts +44 -0
- package/dist/agentkit.js +68 -0
- package/dist/analytics/index.d.ts +1 -0
- package/dist/analytics/index.js +17 -0
- package/dist/analytics/sendAnalyticsEvent.d.ts +31 -0
- package/dist/analytics/sendAnalyticsEvent.js +52 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -0
- package/dist/network/index.d.ts +3 -0
- package/dist/network/index.js +19 -0
- package/dist/network/network.d.ts +20 -0
- package/dist/network/network.js +86 -0
- package/dist/network/svm.d.ts +15 -0
- package/dist/network/svm.js +38 -0
- package/dist/network/types.d.ts +17 -0
- package/dist/network/types.js +2 -0
- package/dist/utils.d.ts +22 -0
- package/dist/utils.js +57 -0
- package/dist/utils.test.d.ts +1 -0
- package/dist/utils.test.js +50 -0
- package/dist/wallet-providers/cdpWalletProvider.d.ts +246 -0
- package/dist/wallet-providers/cdpWalletProvider.js +421 -0
- package/dist/wallet-providers/cdpWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/cdpWalletProvider.test.js +701 -0
- package/dist/wallet-providers/evmWalletProvider.d.ts +51 -0
- package/dist/wallet-providers/evmWalletProvider.js +14 -0
- package/dist/wallet-providers/evmWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/evmWalletProvider.test.js +56 -0
- package/dist/wallet-providers/index.d.ts +10 -0
- package/dist/wallet-providers/index.js +26 -0
- package/dist/wallet-providers/privyEvmWalletProvider.d.ts +55 -0
- package/dist/wallet-providers/privyEvmWalletProvider.js +140 -0
- package/dist/wallet-providers/privyEvmWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/privyEvmWalletProvider.test.js +331 -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/privySvmWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/privySvmWalletProvider.test.js +310 -0
- package/dist/wallet-providers/privyWalletProvider.d.ts +35 -0
- package/dist/wallet-providers/privyWalletProvider.js +39 -0
- package/dist/wallet-providers/privyWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/privyWalletProvider.test.js +124 -0
- package/dist/wallet-providers/smartWalletProvider.d.ts +177 -0
- package/dist/wallet-providers/smartWalletProvider.js +303 -0
- package/dist/wallet-providers/smartWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/smartWalletProvider.test.js +388 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.d.ts +143 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.js +280 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/solanaKeypairWalletProvider.test.js +218 -0
- package/dist/wallet-providers/svmWalletProvider.d.ts +56 -0
- package/dist/wallet-providers/svmWalletProvider.js +13 -0
- package/dist/wallet-providers/svmWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/svmWalletProvider.test.js +55 -0
- package/dist/wallet-providers/viemWalletProvider.d.ts +103 -0
- package/dist/wallet-providers/viemWalletProvider.js +206 -0
- package/dist/wallet-providers/viemWalletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/viemWalletProvider.test.js +338 -0
- package/dist/wallet-providers/walletProvider.d.ts +48 -0
- package/dist/wallet-providers/walletProvider.js +41 -0
- package/dist/wallet-providers/walletProvider.test.d.ts +1 -0
- package/dist/wallet-providers/walletProvider.test.js +103 -0
- package/package.json +83 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sendAnalyticsEvent = sendAnalyticsEvent;
|
|
7
|
+
const md5_1 = __importDefault(require("md5"));
|
|
8
|
+
/**
|
|
9
|
+
* Sends an analytics event to the default endpoint
|
|
10
|
+
*
|
|
11
|
+
* @param event - The event data containing required action, component and name fields
|
|
12
|
+
* @returns Promise that resolves when the event is sent
|
|
13
|
+
*/
|
|
14
|
+
async function sendAnalyticsEvent(event) {
|
|
15
|
+
const timestamp = event.timestamp || Date.now();
|
|
16
|
+
// Prepare the event with required fields
|
|
17
|
+
const enhancedEvent = {
|
|
18
|
+
event_type: event.name,
|
|
19
|
+
platform: "server",
|
|
20
|
+
event_properties: {
|
|
21
|
+
component_type: event.component,
|
|
22
|
+
platform: "server",
|
|
23
|
+
project_name: "agentkit",
|
|
24
|
+
time_start: timestamp,
|
|
25
|
+
agentkit_language: "typescript",
|
|
26
|
+
...event,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const events = [enhancedEvent];
|
|
30
|
+
const stringifiedEventData = JSON.stringify(events);
|
|
31
|
+
const uploadTime = timestamp.toString();
|
|
32
|
+
// Calculate checksum inline
|
|
33
|
+
const checksum = (0, md5_1.default)(stringifiedEventData + uploadTime);
|
|
34
|
+
const analyticsServiceData = {
|
|
35
|
+
e: stringifiedEventData,
|
|
36
|
+
checksum,
|
|
37
|
+
};
|
|
38
|
+
const apiEndpoint = "https://cca-lite.coinbase.com";
|
|
39
|
+
const eventPath = "/amp";
|
|
40
|
+
const eventEndPoint = `${apiEndpoint}${eventPath}`;
|
|
41
|
+
const response = await fetch(eventEndPoint, {
|
|
42
|
+
method: "POST",
|
|
43
|
+
mode: "no-cors",
|
|
44
|
+
headers: {
|
|
45
|
+
"Content-Type": "application/json",
|
|
46
|
+
},
|
|
47
|
+
body: JSON.stringify(analyticsServiceData),
|
|
48
|
+
});
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./agentkit"), exports);
|
|
18
|
+
__exportStar(require("./wallet-providers"), exports);
|
|
19
|
+
__exportStar(require("./action-providers"), exports);
|
|
20
|
+
__exportStar(require("./network"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./network"), exports);
|
|
18
|
+
__exportStar(require("./svm"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Chain } from "viem/chains";
|
|
2
|
+
/**
|
|
3
|
+
* Maps EVM chain IDs to Coinbase network IDs
|
|
4
|
+
*/
|
|
5
|
+
export declare const CHAIN_ID_TO_NETWORK_ID: Record<number, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Maps Coinbase network IDs to EVM chain IDs
|
|
8
|
+
*/
|
|
9
|
+
export declare const NETWORK_ID_TO_CHAIN_ID: Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Maps Coinbase network IDs to Viem chain objects
|
|
12
|
+
*/
|
|
13
|
+
export declare const NETWORK_ID_TO_VIEM_CHAIN: Record<string, Chain>;
|
|
14
|
+
/**
|
|
15
|
+
* Get a chain from the viem chains object
|
|
16
|
+
*
|
|
17
|
+
* @param id - The chain ID
|
|
18
|
+
* @returns The chain
|
|
19
|
+
*/
|
|
20
|
+
export declare const getChain: (id: string) => Chain;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.getChain = exports.NETWORK_ID_TO_VIEM_CHAIN = exports.NETWORK_ID_TO_CHAIN_ID = exports.CHAIN_ID_TO_NETWORK_ID = void 0;
|
|
37
|
+
const chains_1 = require("viem/chains");
|
|
38
|
+
const chains = __importStar(require("viem/chains"));
|
|
39
|
+
/**
|
|
40
|
+
* Maps EVM chain IDs to Coinbase network IDs
|
|
41
|
+
*/
|
|
42
|
+
exports.CHAIN_ID_TO_NETWORK_ID = {
|
|
43
|
+
1: "ethereum-mainnet",
|
|
44
|
+
11155111: "ethereum-sepolia",
|
|
45
|
+
137: "polygon-mainnet",
|
|
46
|
+
80001: "polygon-mumbai",
|
|
47
|
+
8453: "base-mainnet",
|
|
48
|
+
84532: "base-sepolia",
|
|
49
|
+
42161: "arbitrum-mainnet",
|
|
50
|
+
421614: "arbitrum-sepolia",
|
|
51
|
+
10: "optimism-mainnet",
|
|
52
|
+
11155420: "optimism-sepolia",
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Maps Coinbase network IDs to EVM chain IDs
|
|
56
|
+
*/
|
|
57
|
+
exports.NETWORK_ID_TO_CHAIN_ID = Object.entries(exports.CHAIN_ID_TO_NETWORK_ID).reduce((acc, [chainId, networkId]) => {
|
|
58
|
+
acc[networkId] = String(chainId);
|
|
59
|
+
return acc;
|
|
60
|
+
}, {});
|
|
61
|
+
/**
|
|
62
|
+
* Maps Coinbase network IDs to Viem chain objects
|
|
63
|
+
*/
|
|
64
|
+
exports.NETWORK_ID_TO_VIEM_CHAIN = {
|
|
65
|
+
"ethereum-mainnet": chains_1.mainnet,
|
|
66
|
+
"ethereum-sepolia": chains_1.sepolia,
|
|
67
|
+
"polygon-mainnet": chains_1.polygon,
|
|
68
|
+
"polygon-mumbai": chains_1.polygonMumbai,
|
|
69
|
+
"base-mainnet": chains_1.base,
|
|
70
|
+
"base-sepolia": chains_1.baseSepolia,
|
|
71
|
+
"arbitrum-mainnet": chains_1.arbitrum,
|
|
72
|
+
"arbitrum-sepolia": chains_1.arbitrumSepolia,
|
|
73
|
+
"optimism-mainnet": chains_1.optimism,
|
|
74
|
+
"optimism-sepolia": chains_1.optimismSepolia,
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Get a chain from the viem chains object
|
|
78
|
+
*
|
|
79
|
+
* @param id - The chain ID
|
|
80
|
+
* @returns The chain
|
|
81
|
+
*/
|
|
82
|
+
const getChain = (id) => {
|
|
83
|
+
const chainList = Object.values(chains);
|
|
84
|
+
return chainList.find(chain => chain.id === parseInt(id));
|
|
85
|
+
};
|
|
86
|
+
exports.getChain = getChain;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Network } from "./types";
|
|
2
|
+
export declare const SOLANA_MAINNET_NETWORK_ID = "solana-mainnet";
|
|
3
|
+
export declare const SOLANA_TESTNET_NETWORK_ID = "solana-testnet";
|
|
4
|
+
export declare const SOLANA_DEVNET_NETWORK_ID = "solana-devnet";
|
|
5
|
+
export type SOLANA_NETWORK_ID = typeof SOLANA_MAINNET_NETWORK_ID | typeof SOLANA_TESTNET_NETWORK_ID | typeof SOLANA_DEVNET_NETWORK_ID;
|
|
6
|
+
export declare const SOLANA_PROTOCOL_FAMILY = "svm";
|
|
7
|
+
export declare const SOLANA_MAINNET_GENESIS_BLOCK_HASH = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
|
|
8
|
+
export declare const SOLANA_TESTNET_GENESIS_BLOCK_HASH = "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY";
|
|
9
|
+
export declare const SOLANA_DEVNET_GENESIS_BLOCK_HASH = "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG";
|
|
10
|
+
export type SOLANA_CLUSTER = typeof SOLANA_MAINNET_GENESIS_BLOCK_HASH | typeof SOLANA_TESTNET_GENESIS_BLOCK_HASH | typeof SOLANA_DEVNET_GENESIS_BLOCK_HASH;
|
|
11
|
+
export declare const SOLANA_MAINNET_NETWORK: Network;
|
|
12
|
+
export declare const SOLANA_TESTNET_NETWORK: Network;
|
|
13
|
+
export declare const SOLANA_DEVNET_NETWORK: Network;
|
|
14
|
+
export declare const SOLANA_NETWORKS: Record<SOLANA_CLUSTER, Network>;
|
|
15
|
+
export declare const SOLANA_CLUSTER_ID_BY_NETWORK_ID: Record<SOLANA_NETWORK_ID, string>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SOLANA_CLUSTER_ID_BY_NETWORK_ID = exports.SOLANA_NETWORKS = exports.SOLANA_DEVNET_NETWORK = exports.SOLANA_TESTNET_NETWORK = exports.SOLANA_MAINNET_NETWORK = exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH = exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH = exports.SOLANA_MAINNET_GENESIS_BLOCK_HASH = exports.SOLANA_PROTOCOL_FAMILY = exports.SOLANA_DEVNET_NETWORK_ID = exports.SOLANA_TESTNET_NETWORK_ID = exports.SOLANA_MAINNET_NETWORK_ID = void 0;
|
|
4
|
+
// CDP Network IDs
|
|
5
|
+
exports.SOLANA_MAINNET_NETWORK_ID = "solana-mainnet";
|
|
6
|
+
exports.SOLANA_TESTNET_NETWORK_ID = "solana-testnet";
|
|
7
|
+
exports.SOLANA_DEVNET_NETWORK_ID = "solana-devnet";
|
|
8
|
+
// AgentKit Protocol Family
|
|
9
|
+
exports.SOLANA_PROTOCOL_FAMILY = "svm";
|
|
10
|
+
// Chain IDs - Genesis Block Hashes
|
|
11
|
+
exports.SOLANA_MAINNET_GENESIS_BLOCK_HASH = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d";
|
|
12
|
+
exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH = "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY";
|
|
13
|
+
exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH = "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG";
|
|
14
|
+
exports.SOLANA_MAINNET_NETWORK = {
|
|
15
|
+
protocolFamily: exports.SOLANA_PROTOCOL_FAMILY,
|
|
16
|
+
chainId: exports.SOLANA_MAINNET_GENESIS_BLOCK_HASH,
|
|
17
|
+
networkId: exports.SOLANA_MAINNET_NETWORK_ID,
|
|
18
|
+
};
|
|
19
|
+
exports.SOLANA_TESTNET_NETWORK = {
|
|
20
|
+
protocolFamily: exports.SOLANA_PROTOCOL_FAMILY,
|
|
21
|
+
chainId: exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH,
|
|
22
|
+
networkId: exports.SOLANA_TESTNET_NETWORK_ID,
|
|
23
|
+
};
|
|
24
|
+
exports.SOLANA_DEVNET_NETWORK = {
|
|
25
|
+
protocolFamily: exports.SOLANA_PROTOCOL_FAMILY,
|
|
26
|
+
chainId: exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH,
|
|
27
|
+
networkId: exports.SOLANA_DEVNET_NETWORK_ID,
|
|
28
|
+
};
|
|
29
|
+
exports.SOLANA_NETWORKS = {
|
|
30
|
+
[exports.SOLANA_MAINNET_GENESIS_BLOCK_HASH]: exports.SOLANA_MAINNET_NETWORK,
|
|
31
|
+
[exports.SOLANA_TESTNET_GENESIS_BLOCK_HASH]: exports.SOLANA_TESTNET_NETWORK,
|
|
32
|
+
[exports.SOLANA_DEVNET_GENESIS_BLOCK_HASH]: exports.SOLANA_DEVNET_NETWORK,
|
|
33
|
+
};
|
|
34
|
+
exports.SOLANA_CLUSTER_ID_BY_NETWORK_ID = {
|
|
35
|
+
[exports.SOLANA_MAINNET_NETWORK_ID]: "mainnet-beta",
|
|
36
|
+
[exports.SOLANA_TESTNET_NETWORK_ID]: "testnet",
|
|
37
|
+
[exports.SOLANA_DEVNET_NETWORK_ID]: "devnet",
|
|
38
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Network is the network that the wallet provider is connected to.
|
|
3
|
+
*/
|
|
4
|
+
export interface Network {
|
|
5
|
+
/**
|
|
6
|
+
* The protocol family of the network.
|
|
7
|
+
*/
|
|
8
|
+
protocolFamily: string;
|
|
9
|
+
/**
|
|
10
|
+
* The network ID of the network.
|
|
11
|
+
*/
|
|
12
|
+
networkId?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The chain ID of the network.
|
|
15
|
+
*/
|
|
16
|
+
chainId?: string;
|
|
17
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EvmWalletProvider } from "./wallet-providers";
|
|
2
|
+
/**
|
|
3
|
+
* Approves a spender to spend tokens on behalf of the owner
|
|
4
|
+
*
|
|
5
|
+
* @param wallet - The wallet provider
|
|
6
|
+
* @param tokenAddress - The address of the token contract
|
|
7
|
+
* @param spenderAddress - The address of the spender
|
|
8
|
+
* @param amount - The amount to approve in atomic units (wei)
|
|
9
|
+
* @returns A success message or error message
|
|
10
|
+
*/
|
|
11
|
+
export declare function approve(wallet: EvmWalletProvider, tokenAddress: string, spenderAddress: string, amount: bigint): Promise<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Scales a gas estimate by a given multiplier.
|
|
14
|
+
*
|
|
15
|
+
* This function converts the gas estimate to a number, applies the multiplier,
|
|
16
|
+
* rounds the result to the nearest integer, and returns it as a bigint.
|
|
17
|
+
*
|
|
18
|
+
* @param gas - The original gas estimate (bigint).
|
|
19
|
+
* @param multiplier - The factor by which to scale the estimate.
|
|
20
|
+
* @returns The adjusted gas estimate as a bigint.
|
|
21
|
+
*/
|
|
22
|
+
export declare function applyGasMultiplier(gas: bigint, multiplier: number): bigint;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.approve = approve;
|
|
4
|
+
exports.applyGasMultiplier = applyGasMultiplier;
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const ERC20_ABI = [
|
|
7
|
+
{
|
|
8
|
+
inputs: [
|
|
9
|
+
{ name: "spender", type: "address" },
|
|
10
|
+
{ name: "amount", type: "uint256" },
|
|
11
|
+
],
|
|
12
|
+
name: "approve",
|
|
13
|
+
outputs: [{ name: "", type: "bool" }],
|
|
14
|
+
stateMutability: "nonpayable",
|
|
15
|
+
type: "function",
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
/**
|
|
19
|
+
* Approves a spender to spend tokens on behalf of the owner
|
|
20
|
+
*
|
|
21
|
+
* @param wallet - The wallet provider
|
|
22
|
+
* @param tokenAddress - The address of the token contract
|
|
23
|
+
* @param spenderAddress - The address of the spender
|
|
24
|
+
* @param amount - The amount to approve in atomic units (wei)
|
|
25
|
+
* @returns A success message or error message
|
|
26
|
+
*/
|
|
27
|
+
async function approve(wallet, tokenAddress, spenderAddress, amount) {
|
|
28
|
+
try {
|
|
29
|
+
const data = (0, viem_1.encodeFunctionData)({
|
|
30
|
+
abi: ERC20_ABI,
|
|
31
|
+
functionName: "approve",
|
|
32
|
+
args: [spenderAddress, amount],
|
|
33
|
+
});
|
|
34
|
+
const txHash = await wallet.sendTransaction({
|
|
35
|
+
to: tokenAddress,
|
|
36
|
+
data,
|
|
37
|
+
});
|
|
38
|
+
await wallet.waitForTransactionReceipt(txHash);
|
|
39
|
+
return `Successfully approved ${spenderAddress} to spend ${amount} tokens`;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
return `Error approving tokens: ${error}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Scales a gas estimate by a given multiplier.
|
|
47
|
+
*
|
|
48
|
+
* This function converts the gas estimate to a number, applies the multiplier,
|
|
49
|
+
* rounds the result to the nearest integer, and returns it as a bigint.
|
|
50
|
+
*
|
|
51
|
+
* @param gas - The original gas estimate (bigint).
|
|
52
|
+
* @param multiplier - The factor by which to scale the estimate.
|
|
53
|
+
* @returns The adjusted gas estimate as a bigint.
|
|
54
|
+
*/
|
|
55
|
+
function applyGasMultiplier(gas, multiplier) {
|
|
56
|
+
return BigInt(Math.round(Number(gas) * multiplier));
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const viem_1 = require("viem");
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
const MOCK_TOKEN_ADDRESS = "0x1234567890123456789012345678901234567890";
|
|
6
|
+
const MOCK_SPENDER_ADDRESS = "0x9876543210987654321098765432109876543210";
|
|
7
|
+
const MOCK_AMOUNT = BigInt("1000000000000000000");
|
|
8
|
+
const MOCK_TX_HASH = "0xabcdef1234567890";
|
|
9
|
+
const MOCK_RECEIPT = { status: 1, blockNumber: 1234567 };
|
|
10
|
+
describe("utils", () => {
|
|
11
|
+
describe("approve", () => {
|
|
12
|
+
let mockWallet;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
mockWallet = {
|
|
15
|
+
sendTransaction: jest.fn().mockResolvedValue(MOCK_TX_HASH),
|
|
16
|
+
waitForTransactionReceipt: jest.fn().mockResolvedValue(MOCK_RECEIPT),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
it("should successfully approve tokens", async () => {
|
|
20
|
+
const response = await (0, utils_1.approve)(mockWallet, MOCK_TOKEN_ADDRESS, MOCK_SPENDER_ADDRESS, MOCK_AMOUNT);
|
|
21
|
+
expect(mockWallet.sendTransaction).toHaveBeenCalledWith({
|
|
22
|
+
to: MOCK_TOKEN_ADDRESS,
|
|
23
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
24
|
+
abi: [
|
|
25
|
+
{
|
|
26
|
+
inputs: [
|
|
27
|
+
{ name: "spender", type: "address" },
|
|
28
|
+
{ name: "amount", type: "uint256" },
|
|
29
|
+
],
|
|
30
|
+
name: "approve",
|
|
31
|
+
outputs: [{ name: "", type: "bool" }],
|
|
32
|
+
stateMutability: "nonpayable",
|
|
33
|
+
type: "function",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
functionName: "approve",
|
|
37
|
+
args: [MOCK_SPENDER_ADDRESS, MOCK_AMOUNT],
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
expect(mockWallet.waitForTransactionReceipt).toHaveBeenCalledWith(MOCK_TX_HASH);
|
|
41
|
+
expect(response).toBe(`Successfully approved ${MOCK_SPENDER_ADDRESS} to spend ${MOCK_AMOUNT} tokens`);
|
|
42
|
+
});
|
|
43
|
+
it("should handle approval errors", async () => {
|
|
44
|
+
const error = new Error("Failed to approve");
|
|
45
|
+
mockWallet.sendTransaction.mockRejectedValue(error);
|
|
46
|
+
const response = await (0, utils_1.approve)(mockWallet, MOCK_TOKEN_ADDRESS, MOCK_SPENDER_ADDRESS, MOCK_AMOUNT);
|
|
47
|
+
expect(response).toBe(`Error approving tokens: ${error}`);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { ReadContractParameters, ReadContractReturnType, TransactionRequest, TransactionSerializable, Abi, ContractFunctionName, ContractFunctionArgs, Address, Hex } from "viem";
|
|
2
|
+
import { EvmWalletProvider } from "./evmWalletProvider";
|
|
3
|
+
import { Network } from "../network";
|
|
4
|
+
import { Coinbase, CreateERC20Options, CreateTradeOptions, SmartContract, Trade, Wallet, WalletData } from "@coinbase/coinbase-sdk";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for the CDP Providers.
|
|
7
|
+
*/
|
|
8
|
+
export interface CdpProviderConfig {
|
|
9
|
+
/**
|
|
10
|
+
* The CDP API Key Name.
|
|
11
|
+
*/
|
|
12
|
+
apiKeyName?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The CDP API Key Private Key.
|
|
15
|
+
*/
|
|
16
|
+
apiKeyPrivateKey?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Configuration options for the CdpActionProvider.
|
|
20
|
+
*/
|
|
21
|
+
export interface CdpWalletProviderConfig extends CdpProviderConfig {
|
|
22
|
+
/**
|
|
23
|
+
* The CDP Wallet.
|
|
24
|
+
*/
|
|
25
|
+
wallet?: Wallet;
|
|
26
|
+
/**
|
|
27
|
+
* The address of the wallet.
|
|
28
|
+
*/
|
|
29
|
+
address?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The network of the wallet.
|
|
32
|
+
*/
|
|
33
|
+
network?: Network;
|
|
34
|
+
/**
|
|
35
|
+
* The network ID of the wallet.
|
|
36
|
+
*/
|
|
37
|
+
networkId?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Configuration for gas multipliers.
|
|
40
|
+
*/
|
|
41
|
+
gas?: {
|
|
42
|
+
/**
|
|
43
|
+
* An internal multiplier on gas limit estimation.
|
|
44
|
+
*/
|
|
45
|
+
gasLimitMultiplier?: number;
|
|
46
|
+
/**
|
|
47
|
+
* An internal multiplier on fee per gas estimation.
|
|
48
|
+
*/
|
|
49
|
+
feePerGasMultiplier?: number;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Configuration options for the CDP Agentkit with a Wallet.
|
|
54
|
+
*/
|
|
55
|
+
interface ConfigureCdpAgentkitWithWalletOptions extends CdpWalletProviderConfig {
|
|
56
|
+
/**
|
|
57
|
+
* The data of the CDP Wallet as a JSON string.
|
|
58
|
+
*/
|
|
59
|
+
cdpWalletData?: string;
|
|
60
|
+
/**
|
|
61
|
+
* The mnemonic phrase of the wallet.
|
|
62
|
+
*/
|
|
63
|
+
mnemonicPhrase?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A wallet provider that uses the Coinbase SDK.
|
|
67
|
+
*/
|
|
68
|
+
export declare class CdpWalletProvider extends EvmWalletProvider {
|
|
69
|
+
#private;
|
|
70
|
+
/**
|
|
71
|
+
* Constructs a new CdpWalletProvider.
|
|
72
|
+
*
|
|
73
|
+
* @param config - The configuration options for the CdpWalletProvider.
|
|
74
|
+
*/
|
|
75
|
+
private constructor();
|
|
76
|
+
/**
|
|
77
|
+
* Configures a new CdpWalletProvider with a wallet.
|
|
78
|
+
*
|
|
79
|
+
* @param config - Optional configuration parameters
|
|
80
|
+
* @returns A Promise that resolves to a new CdpWalletProvider instance
|
|
81
|
+
* @throws Error if required environment variables are missing or wallet initialization fails
|
|
82
|
+
*/
|
|
83
|
+
static configureWithWallet(config?: ConfigureCdpAgentkitWithWalletOptions): Promise<CdpWalletProvider>;
|
|
84
|
+
/**
|
|
85
|
+
* Signs a message.
|
|
86
|
+
*
|
|
87
|
+
* @param message - The message to sign.
|
|
88
|
+
* @returns The signed message.
|
|
89
|
+
*/
|
|
90
|
+
signMessage(message: string): Promise<`0x${string}`>;
|
|
91
|
+
/**
|
|
92
|
+
* Signs a typed data object.
|
|
93
|
+
*
|
|
94
|
+
* @param typedData - The typed data object to sign.
|
|
95
|
+
* @returns The signed typed data object.
|
|
96
|
+
*/
|
|
97
|
+
signTypedData(typedData: any): Promise<`0x${string}`>;
|
|
98
|
+
/**
|
|
99
|
+
* Signs a transaction.
|
|
100
|
+
*
|
|
101
|
+
* @param transaction - The transaction to sign.
|
|
102
|
+
* @returns The signed transaction.
|
|
103
|
+
*/
|
|
104
|
+
signTransaction(transaction: TransactionRequest): Promise<`0x${string}`>;
|
|
105
|
+
/**
|
|
106
|
+
* Sends a transaction.
|
|
107
|
+
*
|
|
108
|
+
* @param transaction - The transaction to send.
|
|
109
|
+
* @returns The hash of the transaction.
|
|
110
|
+
*/
|
|
111
|
+
sendTransaction(transaction: TransactionRequest): Promise<`0x${string}`>;
|
|
112
|
+
/**
|
|
113
|
+
* Prepares a transaction.
|
|
114
|
+
*
|
|
115
|
+
* @param to - The address to send the transaction to.
|
|
116
|
+
* @param value - The value of the transaction.
|
|
117
|
+
* @param data - The data of the transaction.
|
|
118
|
+
* @returns The prepared transaction.
|
|
119
|
+
*/
|
|
120
|
+
prepareTransaction(to: `0x${string}`, value: bigint, data: `0x${string}`): Promise<TransactionSerializable>;
|
|
121
|
+
/**
|
|
122
|
+
* Adds signature to a transaction and serializes it for broadcast.
|
|
123
|
+
*
|
|
124
|
+
* @param transaction - The transaction to sign.
|
|
125
|
+
* @param signature - The signature to add to the transaction.
|
|
126
|
+
* @returns A serialized transaction.
|
|
127
|
+
*/
|
|
128
|
+
addSignatureAndSerialize(transaction: TransactionSerializable, signature: `0x${string}`): Promise<string>;
|
|
129
|
+
/**
|
|
130
|
+
* Gets the address of the wallet.
|
|
131
|
+
*
|
|
132
|
+
* @returns The address of the wallet.
|
|
133
|
+
*/
|
|
134
|
+
getAddress(): string;
|
|
135
|
+
/**
|
|
136
|
+
* Gets the network of the wallet.
|
|
137
|
+
*
|
|
138
|
+
* @returns The network of the wallet.
|
|
139
|
+
*/
|
|
140
|
+
getNetwork(): Network;
|
|
141
|
+
/**
|
|
142
|
+
* Gets the name of the wallet provider.
|
|
143
|
+
*
|
|
144
|
+
* @returns The name of the wallet provider.
|
|
145
|
+
*/
|
|
146
|
+
getName(): string;
|
|
147
|
+
/**
|
|
148
|
+
* Gets the balance of the wallet.
|
|
149
|
+
*
|
|
150
|
+
* @returns The balance of the wallet in wei
|
|
151
|
+
*/
|
|
152
|
+
getBalance(): Promise<bigint>;
|
|
153
|
+
/**
|
|
154
|
+
* Waits for a transaction receipt.
|
|
155
|
+
*
|
|
156
|
+
* @param txHash - The hash of the transaction to wait for.
|
|
157
|
+
* @returns The transaction receipt.
|
|
158
|
+
*/
|
|
159
|
+
waitForTransactionReceipt(txHash: `0x${string}`): Promise<any>;
|
|
160
|
+
/**
|
|
161
|
+
* Reads a contract.
|
|
162
|
+
*
|
|
163
|
+
* @param params - The parameters to read the contract.
|
|
164
|
+
* @returns The response from the contract.
|
|
165
|
+
*/
|
|
166
|
+
readContract<const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi, "pure" | "view">, const args extends ContractFunctionArgs<abi, "pure" | "view", functionName>>(params: ReadContractParameters<abi, functionName, args>): Promise<ReadContractReturnType<abi, functionName, args>>;
|
|
167
|
+
/**
|
|
168
|
+
* Creates a trade.
|
|
169
|
+
*
|
|
170
|
+
* @param options - The options for the trade.
|
|
171
|
+
* @returns The trade.
|
|
172
|
+
*/
|
|
173
|
+
createTrade(options: CreateTradeOptions): Promise<Trade>;
|
|
174
|
+
/**
|
|
175
|
+
* Deploys a token.
|
|
176
|
+
*
|
|
177
|
+
* @param options - The options for the token deployment.
|
|
178
|
+
* @returns The deployed token.
|
|
179
|
+
*/
|
|
180
|
+
deployToken(options: CreateERC20Options): Promise<SmartContract>;
|
|
181
|
+
/**
|
|
182
|
+
* Deploys a contract.
|
|
183
|
+
*
|
|
184
|
+
* @param options - The options for contract deployment
|
|
185
|
+
* @param options.solidityVersion - The version of the Solidity compiler to use (e.g. "0.8.0+commit.c7dfd78e")
|
|
186
|
+
* @param options.solidityInputJson - The JSON input for the Solidity compiler containing contract source and settings
|
|
187
|
+
* @param options.contractName - The name of the contract to deploy
|
|
188
|
+
* @param options.constructorArgs - Key-value map of constructor args
|
|
189
|
+
*
|
|
190
|
+
* @returns A Promise that resolves to the deployed contract instance
|
|
191
|
+
* @throws Error if wallet is not initialized
|
|
192
|
+
*/
|
|
193
|
+
deployContract(options: {
|
|
194
|
+
solidityVersion: string;
|
|
195
|
+
solidityInputJson: string;
|
|
196
|
+
contractName: string;
|
|
197
|
+
constructorArgs: Record<string, unknown>;
|
|
198
|
+
}): Promise<SmartContract>;
|
|
199
|
+
/**
|
|
200
|
+
* Deploys a new NFT (ERC-721) smart contract.
|
|
201
|
+
*
|
|
202
|
+
* @param options - Configuration options for the NFT contract deployment
|
|
203
|
+
* @param options.name - The name of the collection
|
|
204
|
+
* @param options.symbol - The token symbol for the collection
|
|
205
|
+
* @param options.baseURI - The base URI for token metadata.
|
|
206
|
+
*
|
|
207
|
+
* @returns A Promise that resolves to the deployed SmartContract instance
|
|
208
|
+
* @throws Error if the wallet is not properly initialized
|
|
209
|
+
* @throws Error if the deployment fails for any reason (network issues, insufficient funds, etc.)
|
|
210
|
+
*/
|
|
211
|
+
deployNFT(options: {
|
|
212
|
+
name: string;
|
|
213
|
+
symbol: string;
|
|
214
|
+
baseURI: string;
|
|
215
|
+
}): Promise<SmartContract>;
|
|
216
|
+
/**
|
|
217
|
+
* Transfer the native asset of the network.
|
|
218
|
+
*
|
|
219
|
+
* @param to - The destination address.
|
|
220
|
+
* @param value - The amount to transfer in Wei.
|
|
221
|
+
* @returns The transaction hash.
|
|
222
|
+
*/
|
|
223
|
+
nativeTransfer(to: `0x${string}`, value: string): Promise<`0x${string}`>;
|
|
224
|
+
/**
|
|
225
|
+
* Exports the wallet.
|
|
226
|
+
*
|
|
227
|
+
* @returns The wallet's data.
|
|
228
|
+
*/
|
|
229
|
+
exportWallet(): Promise<WalletData>;
|
|
230
|
+
/**
|
|
231
|
+
* Gets the wallet.
|
|
232
|
+
*
|
|
233
|
+
* @returns The wallet.
|
|
234
|
+
*/
|
|
235
|
+
getWallet(): Wallet;
|
|
236
|
+
/**
|
|
237
|
+
* ERC20 transfer method
|
|
238
|
+
*
|
|
239
|
+
* @param assetId - The asset ID to transfer. Either USDC, CBBTC or EURC
|
|
240
|
+
* @param destination - The destination address
|
|
241
|
+
* @param amount - The amount to transfer
|
|
242
|
+
* @returns The transaction hash
|
|
243
|
+
*/
|
|
244
|
+
gaslessERC20Transfer(assetId: typeof Coinbase.assets.Usdc | typeof Coinbase.assets.Cbbtc | typeof Coinbase.assets.Eurc, destination: Address, amount: bigint): Promise<Hex>;
|
|
245
|
+
}
|
|
246
|
+
export {};
|