@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,421 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _CdpWalletProvider_cdpWallet, _CdpWalletProvider_address, _CdpWalletProvider_network, _CdpWalletProvider_publicClient, _CdpWalletProvider_gasLimitMultiplier, _CdpWalletProvider_feePerGasMultiplier;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CdpWalletProvider = void 0;
|
|
16
|
+
const package_json_1 = require("../../package.json");
|
|
17
|
+
const decimal_js_1 = require("decimal.js");
|
|
18
|
+
const viem_1 = require("viem");
|
|
19
|
+
const evmWalletProvider_1 = require("./evmWalletProvider");
|
|
20
|
+
const coinbase_sdk_1 = require("@coinbase/coinbase-sdk");
|
|
21
|
+
const network_1 = require("../network/network");
|
|
22
|
+
const utils_1 = require("../utils");
|
|
23
|
+
/**
|
|
24
|
+
* A wallet provider that uses the Coinbase SDK.
|
|
25
|
+
*/
|
|
26
|
+
class CdpWalletProvider extends evmWalletProvider_1.EvmWalletProvider {
|
|
27
|
+
/**
|
|
28
|
+
* Constructs a new CdpWalletProvider.
|
|
29
|
+
*
|
|
30
|
+
* @param config - The configuration options for the CdpWalletProvider.
|
|
31
|
+
*/
|
|
32
|
+
constructor(config) {
|
|
33
|
+
super();
|
|
34
|
+
_CdpWalletProvider_cdpWallet.set(this, void 0);
|
|
35
|
+
_CdpWalletProvider_address.set(this, void 0);
|
|
36
|
+
_CdpWalletProvider_network.set(this, void 0);
|
|
37
|
+
_CdpWalletProvider_publicClient.set(this, void 0);
|
|
38
|
+
_CdpWalletProvider_gasLimitMultiplier.set(this, void 0);
|
|
39
|
+
_CdpWalletProvider_feePerGasMultiplier.set(this, void 0);
|
|
40
|
+
__classPrivateFieldSet(this, _CdpWalletProvider_cdpWallet, config.wallet, "f");
|
|
41
|
+
__classPrivateFieldSet(this, _CdpWalletProvider_address, config.address, "f");
|
|
42
|
+
__classPrivateFieldSet(this, _CdpWalletProvider_network, config.network, "f");
|
|
43
|
+
__classPrivateFieldSet(this, _CdpWalletProvider_publicClient, (0, viem_1.createPublicClient)({
|
|
44
|
+
chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[config.network.networkId],
|
|
45
|
+
transport: (0, viem_1.http)(),
|
|
46
|
+
}), "f");
|
|
47
|
+
__classPrivateFieldSet(this, _CdpWalletProvider_gasLimitMultiplier, Math.max(config.gas?.gasLimitMultiplier ?? 1.2, 1), "f");
|
|
48
|
+
__classPrivateFieldSet(this, _CdpWalletProvider_feePerGasMultiplier, Math.max(config.gas?.feePerGasMultiplier ?? 1, 1), "f");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Configures a new CdpWalletProvider with a wallet.
|
|
52
|
+
*
|
|
53
|
+
* @param config - Optional configuration parameters
|
|
54
|
+
* @returns A Promise that resolves to a new CdpWalletProvider instance
|
|
55
|
+
* @throws Error if required environment variables are missing or wallet initialization fails
|
|
56
|
+
*/
|
|
57
|
+
static async configureWithWallet(config = {}) {
|
|
58
|
+
if (config.apiKeyName && config.apiKeyPrivateKey) {
|
|
59
|
+
coinbase_sdk_1.Coinbase.configure({
|
|
60
|
+
apiKeyName: config.apiKeyName,
|
|
61
|
+
privateKey: config.apiKeyPrivateKey?.replace(/\\n/g, "\n"),
|
|
62
|
+
source: "agentkit",
|
|
63
|
+
sourceVersion: package_json_1.version,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
coinbase_sdk_1.Coinbase.configureFromJson({ source: "agentkit", sourceVersion: package_json_1.version });
|
|
68
|
+
}
|
|
69
|
+
let wallet;
|
|
70
|
+
const mnemonicPhrase = config.mnemonicPhrase || process.env.MNEMONIC_PHRASE;
|
|
71
|
+
let networkId = config.networkId || process.env.NETWORK_ID || coinbase_sdk_1.Coinbase.networks.BaseSepolia;
|
|
72
|
+
try {
|
|
73
|
+
if (config.wallet) {
|
|
74
|
+
wallet = config.wallet;
|
|
75
|
+
}
|
|
76
|
+
else if (config.cdpWalletData) {
|
|
77
|
+
const walletData = JSON.parse(config.cdpWalletData);
|
|
78
|
+
wallet = await coinbase_sdk_1.Wallet.import(walletData);
|
|
79
|
+
networkId = wallet.getNetworkId();
|
|
80
|
+
}
|
|
81
|
+
else if (mnemonicPhrase) {
|
|
82
|
+
wallet = await coinbase_sdk_1.Wallet.import({ mnemonicPhrase: mnemonicPhrase }, networkId);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
wallet = await coinbase_sdk_1.Wallet.create({ networkId: networkId });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
throw new Error(`Failed to initialize wallet: ${error}`);
|
|
90
|
+
}
|
|
91
|
+
const address = (await wallet.getDefaultAddress())?.getId();
|
|
92
|
+
const network = {
|
|
93
|
+
protocolFamily: "evm",
|
|
94
|
+
chainId: network_1.NETWORK_ID_TO_CHAIN_ID[networkId],
|
|
95
|
+
networkId: networkId,
|
|
96
|
+
};
|
|
97
|
+
const cdpWalletProvider = new CdpWalletProvider({
|
|
98
|
+
wallet,
|
|
99
|
+
address,
|
|
100
|
+
network,
|
|
101
|
+
gas: config.gas,
|
|
102
|
+
});
|
|
103
|
+
return cdpWalletProvider;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Signs a message.
|
|
107
|
+
*
|
|
108
|
+
* @param message - The message to sign.
|
|
109
|
+
* @returns The signed message.
|
|
110
|
+
*/
|
|
111
|
+
async signMessage(message) {
|
|
112
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
113
|
+
throw new Error("Wallet not initialized");
|
|
114
|
+
}
|
|
115
|
+
const messageHash = (0, coinbase_sdk_1.hashMessage)(message);
|
|
116
|
+
const payload = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createPayloadSignature(messageHash);
|
|
117
|
+
if (payload.getStatus() === "pending" && payload?.wait) {
|
|
118
|
+
await payload.wait(); // needed for Server-Signers
|
|
119
|
+
}
|
|
120
|
+
return payload.getSignature();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Signs a typed data object.
|
|
124
|
+
*
|
|
125
|
+
* @param typedData - The typed data object to sign.
|
|
126
|
+
* @returns The signed typed data object.
|
|
127
|
+
*/
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
|
+
async signTypedData(typedData) {
|
|
130
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
131
|
+
throw new Error("Wallet not initialized");
|
|
132
|
+
}
|
|
133
|
+
const messageHash = (0, coinbase_sdk_1.hashTypedDataMessage)(typedData.domain, typedData.types, typedData.message);
|
|
134
|
+
const payload = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createPayloadSignature(messageHash);
|
|
135
|
+
if (payload.getStatus() === "pending" && payload?.wait) {
|
|
136
|
+
await payload.wait(); // needed for Server-Signers
|
|
137
|
+
}
|
|
138
|
+
return payload.getSignature();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Signs a transaction.
|
|
142
|
+
*
|
|
143
|
+
* @param transaction - The transaction to sign.
|
|
144
|
+
* @returns The signed transaction.
|
|
145
|
+
*/
|
|
146
|
+
async signTransaction(transaction) {
|
|
147
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
148
|
+
throw new Error("Wallet not initialized");
|
|
149
|
+
}
|
|
150
|
+
const serializedTx = (0, viem_1.serializeTransaction)(transaction);
|
|
151
|
+
const transactionHash = (0, viem_1.keccak256)(serializedTx);
|
|
152
|
+
const payload = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createPayloadSignature(transactionHash);
|
|
153
|
+
if (payload.getStatus() === "pending" && payload?.wait) {
|
|
154
|
+
await payload.wait(); // needed for Server-Signers
|
|
155
|
+
}
|
|
156
|
+
return payload.getSignature();
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Sends a transaction.
|
|
160
|
+
*
|
|
161
|
+
* @param transaction - The transaction to send.
|
|
162
|
+
* @returns The hash of the transaction.
|
|
163
|
+
*/
|
|
164
|
+
async sendTransaction(transaction) {
|
|
165
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
166
|
+
throw new Error("Wallet not initialized");
|
|
167
|
+
}
|
|
168
|
+
const preparedTransaction = await this.prepareTransaction(transaction.to, transaction.value, transaction.data);
|
|
169
|
+
const signature = await this.signTransaction({
|
|
170
|
+
...preparedTransaction,
|
|
171
|
+
});
|
|
172
|
+
const signedPayload = await this.addSignatureAndSerialize(preparedTransaction, signature);
|
|
173
|
+
const externalAddress = new coinbase_sdk_1.ExternalAddress(__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").getNetworkId(), __classPrivateFieldGet(this, _CdpWalletProvider_address, "f"));
|
|
174
|
+
const tx = await externalAddress.broadcastExternalTransaction(signedPayload.slice(2));
|
|
175
|
+
return tx.transactionHash;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Prepares a transaction.
|
|
179
|
+
*
|
|
180
|
+
* @param to - The address to send the transaction to.
|
|
181
|
+
* @param value - The value of the transaction.
|
|
182
|
+
* @param data - The data of the transaction.
|
|
183
|
+
* @returns The prepared transaction.
|
|
184
|
+
*/
|
|
185
|
+
async prepareTransaction(to, value, data) {
|
|
186
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
187
|
+
throw new Error("Wallet not initialized");
|
|
188
|
+
}
|
|
189
|
+
const nonce = await __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").getTransactionCount({
|
|
190
|
+
address: __classPrivateFieldGet(this, _CdpWalletProvider_address, "f"),
|
|
191
|
+
});
|
|
192
|
+
const feeData = await __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").estimateFeesPerGas();
|
|
193
|
+
const maxFeePerGas = (0, utils_1.applyGasMultiplier)(feeData.maxFeePerGas, __classPrivateFieldGet(this, _CdpWalletProvider_feePerGasMultiplier, "f"));
|
|
194
|
+
const maxPriorityFeePerGas = (0, utils_1.applyGasMultiplier)(feeData.maxPriorityFeePerGas, __classPrivateFieldGet(this, _CdpWalletProvider_feePerGasMultiplier, "f"));
|
|
195
|
+
const gasLimit = await __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").estimateGas({
|
|
196
|
+
account: __classPrivateFieldGet(this, _CdpWalletProvider_address, "f"),
|
|
197
|
+
to,
|
|
198
|
+
value,
|
|
199
|
+
data,
|
|
200
|
+
});
|
|
201
|
+
const gas = BigInt(Math.round(Number(gasLimit) * __classPrivateFieldGet(this, _CdpWalletProvider_gasLimitMultiplier, "f")));
|
|
202
|
+
const chainId = parseInt(__classPrivateFieldGet(this, _CdpWalletProvider_network, "f").chainId, 10);
|
|
203
|
+
return {
|
|
204
|
+
to,
|
|
205
|
+
value,
|
|
206
|
+
data,
|
|
207
|
+
nonce,
|
|
208
|
+
maxFeePerGas,
|
|
209
|
+
maxPriorityFeePerGas,
|
|
210
|
+
gas,
|
|
211
|
+
chainId,
|
|
212
|
+
type: "eip1559",
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Adds signature to a transaction and serializes it for broadcast.
|
|
217
|
+
*
|
|
218
|
+
* @param transaction - The transaction to sign.
|
|
219
|
+
* @param signature - The signature to add to the transaction.
|
|
220
|
+
* @returns A serialized transaction.
|
|
221
|
+
*/
|
|
222
|
+
async addSignatureAndSerialize(transaction, signature) {
|
|
223
|
+
// Decode the signature into its components
|
|
224
|
+
const r = `0x${signature.slice(2, 66)}`; // First 32 bytes
|
|
225
|
+
const s = `0x${signature.slice(66, 130)}`; // Next 32 bytes
|
|
226
|
+
const v = BigInt(parseInt(signature.slice(130, 132), 16)); // Last byte
|
|
227
|
+
return (0, viem_1.serializeTransaction)(transaction, { r, s, v });
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Gets the address of the wallet.
|
|
231
|
+
*
|
|
232
|
+
* @returns The address of the wallet.
|
|
233
|
+
*/
|
|
234
|
+
getAddress() {
|
|
235
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_address, "f")) {
|
|
236
|
+
throw new Error("Address not initialized");
|
|
237
|
+
}
|
|
238
|
+
return __classPrivateFieldGet(this, _CdpWalletProvider_address, "f");
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Gets the network of the wallet.
|
|
242
|
+
*
|
|
243
|
+
* @returns The network of the wallet.
|
|
244
|
+
*/
|
|
245
|
+
getNetwork() {
|
|
246
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_network, "f")) {
|
|
247
|
+
throw new Error("Network not initialized");
|
|
248
|
+
}
|
|
249
|
+
return __classPrivateFieldGet(this, _CdpWalletProvider_network, "f");
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Gets the name of the wallet provider.
|
|
253
|
+
*
|
|
254
|
+
* @returns The name of the wallet provider.
|
|
255
|
+
*/
|
|
256
|
+
getName() {
|
|
257
|
+
return "cdp_wallet_provider";
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Gets the balance of the wallet.
|
|
261
|
+
*
|
|
262
|
+
* @returns The balance of the wallet in wei
|
|
263
|
+
*/
|
|
264
|
+
async getBalance() {
|
|
265
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
266
|
+
throw new Error("Wallet not initialized");
|
|
267
|
+
}
|
|
268
|
+
const balance = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").getBalance("eth");
|
|
269
|
+
return BigInt(balance.mul(10 ** 18).toString());
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Waits for a transaction receipt.
|
|
273
|
+
*
|
|
274
|
+
* @param txHash - The hash of the transaction to wait for.
|
|
275
|
+
* @returns The transaction receipt.
|
|
276
|
+
*/
|
|
277
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
278
|
+
async waitForTransactionReceipt(txHash) {
|
|
279
|
+
return await __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").waitForTransactionReceipt({ hash: txHash });
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Reads a contract.
|
|
283
|
+
*
|
|
284
|
+
* @param params - The parameters to read the contract.
|
|
285
|
+
* @returns The response from the contract.
|
|
286
|
+
*/
|
|
287
|
+
async readContract(params) {
|
|
288
|
+
return __classPrivateFieldGet(this, _CdpWalletProvider_publicClient, "f").readContract(params);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Creates a trade.
|
|
292
|
+
*
|
|
293
|
+
* @param options - The options for the trade.
|
|
294
|
+
* @returns The trade.
|
|
295
|
+
*/
|
|
296
|
+
async createTrade(options) {
|
|
297
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
298
|
+
throw new Error("Wallet not initialized");
|
|
299
|
+
}
|
|
300
|
+
return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createTrade(options);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Deploys a token.
|
|
304
|
+
*
|
|
305
|
+
* @param options - The options for the token deployment.
|
|
306
|
+
* @returns The deployed token.
|
|
307
|
+
*/
|
|
308
|
+
async deployToken(options) {
|
|
309
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
310
|
+
throw new Error("Wallet not initialized");
|
|
311
|
+
}
|
|
312
|
+
return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").deployToken(options);
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Deploys a contract.
|
|
316
|
+
*
|
|
317
|
+
* @param options - The options for contract deployment
|
|
318
|
+
* @param options.solidityVersion - The version of the Solidity compiler to use (e.g. "0.8.0+commit.c7dfd78e")
|
|
319
|
+
* @param options.solidityInputJson - The JSON input for the Solidity compiler containing contract source and settings
|
|
320
|
+
* @param options.contractName - The name of the contract to deploy
|
|
321
|
+
* @param options.constructorArgs - Key-value map of constructor args
|
|
322
|
+
*
|
|
323
|
+
* @returns A Promise that resolves to the deployed contract instance
|
|
324
|
+
* @throws Error if wallet is not initialized
|
|
325
|
+
*/
|
|
326
|
+
async deployContract(options) {
|
|
327
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
328
|
+
throw new Error("Wallet not initialized");
|
|
329
|
+
}
|
|
330
|
+
return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").deployContract(options);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Deploys a new NFT (ERC-721) smart contract.
|
|
334
|
+
*
|
|
335
|
+
* @param options - Configuration options for the NFT contract deployment
|
|
336
|
+
* @param options.name - The name of the collection
|
|
337
|
+
* @param options.symbol - The token symbol for the collection
|
|
338
|
+
* @param options.baseURI - The base URI for token metadata.
|
|
339
|
+
*
|
|
340
|
+
* @returns A Promise that resolves to the deployed SmartContract instance
|
|
341
|
+
* @throws Error if the wallet is not properly initialized
|
|
342
|
+
* @throws Error if the deployment fails for any reason (network issues, insufficient funds, etc.)
|
|
343
|
+
*/
|
|
344
|
+
async deployNFT(options) {
|
|
345
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
346
|
+
throw new Error("Wallet not initialized");
|
|
347
|
+
}
|
|
348
|
+
return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").deployNFT(options);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Transfer the native asset of the network.
|
|
352
|
+
*
|
|
353
|
+
* @param to - The destination address.
|
|
354
|
+
* @param value - The amount to transfer in Wei.
|
|
355
|
+
* @returns The transaction hash.
|
|
356
|
+
*/
|
|
357
|
+
async nativeTransfer(to, value) {
|
|
358
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
359
|
+
throw new Error("Wallet not initialized");
|
|
360
|
+
}
|
|
361
|
+
const transferResult = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createTransfer({
|
|
362
|
+
amount: new decimal_js_1.Decimal(value),
|
|
363
|
+
assetId: coinbase_sdk_1.Coinbase.assets.Eth,
|
|
364
|
+
destination: to,
|
|
365
|
+
gasless: false,
|
|
366
|
+
});
|
|
367
|
+
const result = await transferResult.wait();
|
|
368
|
+
if (!result.getTransactionHash()) {
|
|
369
|
+
throw new Error("Transaction hash not found");
|
|
370
|
+
}
|
|
371
|
+
return result.getTransactionHash();
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Exports the wallet.
|
|
375
|
+
*
|
|
376
|
+
* @returns The wallet's data.
|
|
377
|
+
*/
|
|
378
|
+
async exportWallet() {
|
|
379
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
380
|
+
throw new Error("Wallet not initialized");
|
|
381
|
+
}
|
|
382
|
+
return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").export();
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Gets the wallet.
|
|
386
|
+
*
|
|
387
|
+
* @returns The wallet.
|
|
388
|
+
*/
|
|
389
|
+
getWallet() {
|
|
390
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
391
|
+
throw new Error("Wallet not initialized");
|
|
392
|
+
}
|
|
393
|
+
return __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f");
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* ERC20 transfer method
|
|
397
|
+
*
|
|
398
|
+
* @param assetId - The asset ID to transfer. Either USDC, CBBTC or EURC
|
|
399
|
+
* @param destination - The destination address
|
|
400
|
+
* @param amount - The amount to transfer
|
|
401
|
+
* @returns The transaction hash
|
|
402
|
+
*/
|
|
403
|
+
async gaslessERC20Transfer(assetId, destination, amount) {
|
|
404
|
+
if (!__classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f")) {
|
|
405
|
+
throw new Error("Wallet not initialized");
|
|
406
|
+
}
|
|
407
|
+
const transferResult = await __classPrivateFieldGet(this, _CdpWalletProvider_cdpWallet, "f").createTransfer({
|
|
408
|
+
amount,
|
|
409
|
+
assetId,
|
|
410
|
+
destination,
|
|
411
|
+
gasless: true,
|
|
412
|
+
});
|
|
413
|
+
const result = await transferResult.wait();
|
|
414
|
+
if (!result.getTransactionHash()) {
|
|
415
|
+
throw new Error("Transaction hash not found");
|
|
416
|
+
}
|
|
417
|
+
return result.getTransactionHash();
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
exports.CdpWalletProvider = CdpWalletProvider;
|
|
421
|
+
_CdpWalletProvider_cdpWallet = new WeakMap(), _CdpWalletProvider_address = new WeakMap(), _CdpWalletProvider_network = new WeakMap(), _CdpWalletProvider_publicClient = new WeakMap(), _CdpWalletProvider_gasLimitMultiplier = new WeakMap(), _CdpWalletProvider_feePerGasMultiplier = new WeakMap();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|