@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,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const erc20ActionProvider_1 = require("./erc20ActionProvider");
|
|
4
|
+
const schemas_1 = require("./schemas");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
const MOCK_AMOUNT = 15;
|
|
8
|
+
const MOCK_DECIMALS = 6;
|
|
9
|
+
const MOCK_CONTRACT_ADDRESS = "0x1234567890123456789012345678901234567890";
|
|
10
|
+
const MOCK_DESTINATION = "0x9876543210987654321098765432109876543210";
|
|
11
|
+
const MOCK_ADDRESS = "0x1234567890123456789012345678901234567890";
|
|
12
|
+
describe("Transfer Schema", () => {
|
|
13
|
+
it("should successfully parse valid input", () => {
|
|
14
|
+
const validInput = {
|
|
15
|
+
amount: MOCK_AMOUNT,
|
|
16
|
+
contractAddress: MOCK_CONTRACT_ADDRESS,
|
|
17
|
+
destination: MOCK_DESTINATION,
|
|
18
|
+
};
|
|
19
|
+
const result = schemas_1.TransferSchema.safeParse(validInput);
|
|
20
|
+
expect(result.success).toBe(true);
|
|
21
|
+
expect(result.data).toEqual(validInput);
|
|
22
|
+
});
|
|
23
|
+
it("should fail parsing empty input", () => {
|
|
24
|
+
const emptyInput = {};
|
|
25
|
+
const result = schemas_1.TransferSchema.safeParse(emptyInput);
|
|
26
|
+
expect(result.success).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe("Get Balance Action", () => {
|
|
30
|
+
let mockWallet;
|
|
31
|
+
const actionProvider = (0, erc20ActionProvider_1.erc20ActionProvider)();
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
mockWallet = {
|
|
34
|
+
getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
|
|
35
|
+
readContract: jest.fn(),
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
it("should successfully respond", async () => {
|
|
39
|
+
mockWallet.readContract.mockResolvedValueOnce(MOCK_AMOUNT);
|
|
40
|
+
mockWallet.readContract.mockResolvedValueOnce(MOCK_DECIMALS);
|
|
41
|
+
const args = {
|
|
42
|
+
contractAddress: MOCK_CONTRACT_ADDRESS,
|
|
43
|
+
};
|
|
44
|
+
const response = await actionProvider.getBalance(mockWallet, args);
|
|
45
|
+
expect(mockWallet.readContract).toHaveBeenCalledWith({
|
|
46
|
+
address: args.contractAddress,
|
|
47
|
+
abi: constants_1.abi,
|
|
48
|
+
functionName: "balanceOf",
|
|
49
|
+
args: [mockWallet.getAddress()],
|
|
50
|
+
});
|
|
51
|
+
expect(response).toContain(`Balance of ${MOCK_CONTRACT_ADDRESS} is ${MOCK_AMOUNT / 10 ** MOCK_DECIMALS}`);
|
|
52
|
+
});
|
|
53
|
+
it("should fail with an error", async () => {
|
|
54
|
+
const args = {
|
|
55
|
+
contractAddress: MOCK_CONTRACT_ADDRESS,
|
|
56
|
+
};
|
|
57
|
+
const error = new Error("Failed to get balance");
|
|
58
|
+
mockWallet.readContract.mockRejectedValue(error);
|
|
59
|
+
const response = await actionProvider.getBalance(mockWallet, args);
|
|
60
|
+
expect(mockWallet.readContract).toHaveBeenCalledWith({
|
|
61
|
+
address: args.contractAddress,
|
|
62
|
+
abi: constants_1.abi,
|
|
63
|
+
functionName: "balanceOf",
|
|
64
|
+
args: [mockWallet.getAddress()],
|
|
65
|
+
});
|
|
66
|
+
expect(response).toContain(`Error getting balance: ${error}`);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe("Transfer Action", () => {
|
|
70
|
+
const TRANSACTION_HASH = "0xghijkl987654321";
|
|
71
|
+
let mockWallet;
|
|
72
|
+
const actionProvider = (0, erc20ActionProvider_1.erc20ActionProvider)();
|
|
73
|
+
beforeEach(async () => {
|
|
74
|
+
mockWallet = {
|
|
75
|
+
sendTransaction: jest.fn(),
|
|
76
|
+
waitForTransactionReceipt: jest.fn(),
|
|
77
|
+
getName: jest.fn().mockReturnValue("evm_wallet_provider"),
|
|
78
|
+
getNetwork: jest.fn().mockReturnValue({
|
|
79
|
+
networkId: "base-mainnet",
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
82
|
+
mockWallet.sendTransaction.mockResolvedValue(TRANSACTION_HASH);
|
|
83
|
+
mockWallet.waitForTransactionReceipt.mockResolvedValue({});
|
|
84
|
+
});
|
|
85
|
+
it("should successfully respond", async () => {
|
|
86
|
+
const args = {
|
|
87
|
+
amount: BigInt(MOCK_AMOUNT),
|
|
88
|
+
contractAddress: MOCK_CONTRACT_ADDRESS,
|
|
89
|
+
destination: MOCK_DESTINATION,
|
|
90
|
+
};
|
|
91
|
+
const response = await actionProvider.transfer(mockWallet, args);
|
|
92
|
+
expect(mockWallet.sendTransaction).toHaveBeenCalledWith({
|
|
93
|
+
to: args.contractAddress,
|
|
94
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
95
|
+
abi: constants_1.abi,
|
|
96
|
+
functionName: "transfer",
|
|
97
|
+
args: [args.destination, BigInt(args.amount)],
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
expect(mockWallet.waitForTransactionReceipt).toHaveBeenCalledWith(TRANSACTION_HASH);
|
|
101
|
+
expect(response).toContain(`Transferred ${MOCK_AMOUNT} of ${MOCK_CONTRACT_ADDRESS} to ${MOCK_DESTINATION}`);
|
|
102
|
+
expect(response).toContain(`Transaction hash for the transfer: ${TRANSACTION_HASH}`);
|
|
103
|
+
});
|
|
104
|
+
it("should fail with an error", async () => {
|
|
105
|
+
const args = {
|
|
106
|
+
amount: BigInt(MOCK_AMOUNT),
|
|
107
|
+
contractAddress: MOCK_CONTRACT_ADDRESS,
|
|
108
|
+
destination: MOCK_DESTINATION,
|
|
109
|
+
};
|
|
110
|
+
const error = new Error("Failed to execute transfer");
|
|
111
|
+
mockWallet.sendTransaction.mockRejectedValue(error);
|
|
112
|
+
const response = await actionProvider.transfer(mockWallet, args);
|
|
113
|
+
expect(mockWallet.sendTransaction).toHaveBeenCalledWith({
|
|
114
|
+
to: args.contractAddress,
|
|
115
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
116
|
+
abi: constants_1.abi,
|
|
117
|
+
functionName: "transfer",
|
|
118
|
+
args: [args.destination, BigInt(args.amount)],
|
|
119
|
+
}),
|
|
120
|
+
});
|
|
121
|
+
expect(response).toContain(`Error transferring the asset: ${error}`);
|
|
122
|
+
});
|
|
123
|
+
describe("supportsNetwork", () => {
|
|
124
|
+
it("should return true when protocolFamily is evm", () => {
|
|
125
|
+
expect(actionProvider.supportsNetwork({ protocolFamily: "evm" })).toBe(true);
|
|
126
|
+
});
|
|
127
|
+
it("should return false when protocolFamily is not evm", () => {
|
|
128
|
+
expect(actionProvider.supportsNetwork({ protocolFamily: "solana" })).toBe(false);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./erc20ActionProvider";
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./erc20ActionProvider"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Input schema for transfer action.
|
|
4
|
+
*/
|
|
5
|
+
export declare const TransferSchema: z.ZodObject<{
|
|
6
|
+
amount: z.ZodType<bigint, z.ZodTypeDef, bigint>;
|
|
7
|
+
contractAddress: z.ZodString;
|
|
8
|
+
destination: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
contractAddress: string;
|
|
11
|
+
amount: bigint;
|
|
12
|
+
destination: string;
|
|
13
|
+
}, {
|
|
14
|
+
contractAddress: string;
|
|
15
|
+
amount: bigint;
|
|
16
|
+
destination: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Input schema for get balance action.
|
|
20
|
+
*/
|
|
21
|
+
export declare const GetBalanceSchema: z.ZodObject<{
|
|
22
|
+
contractAddress: z.ZodString;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
contractAddress: string;
|
|
25
|
+
}, {
|
|
26
|
+
contractAddress: string;
|
|
27
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GetBalanceSchema = exports.TransferSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
/**
|
|
6
|
+
* Input schema for transfer action.
|
|
7
|
+
*/
|
|
8
|
+
exports.TransferSchema = zod_1.z
|
|
9
|
+
.object({
|
|
10
|
+
amount: zod_1.z.custom().describe("The amount of the asset to transfer"),
|
|
11
|
+
contractAddress: zod_1.z.string().describe("The contract address of the token to transfer"),
|
|
12
|
+
destination: zod_1.z.string().describe("The destination to transfer the funds"),
|
|
13
|
+
})
|
|
14
|
+
.strip()
|
|
15
|
+
.describe("Instructions for transferring assets");
|
|
16
|
+
/**
|
|
17
|
+
* Input schema for get balance action.
|
|
18
|
+
*/
|
|
19
|
+
exports.GetBalanceSchema = zod_1.z
|
|
20
|
+
.object({
|
|
21
|
+
contractAddress: zod_1.z
|
|
22
|
+
.string()
|
|
23
|
+
.describe("The contract address of the token to get the balance for"),
|
|
24
|
+
})
|
|
25
|
+
.strip()
|
|
26
|
+
.describe("Instructions for getting wallet balance");
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
export declare const ERC721_ABI: readonly [{
|
|
2
|
+
readonly inputs: readonly [{
|
|
3
|
+
readonly internalType: "address";
|
|
4
|
+
readonly name: "to";
|
|
5
|
+
readonly type: "address";
|
|
6
|
+
}];
|
|
7
|
+
readonly name: "mint";
|
|
8
|
+
readonly outputs: readonly [];
|
|
9
|
+
readonly payable: false;
|
|
10
|
+
readonly stateMutability: "nonpayable";
|
|
11
|
+
readonly type: "function";
|
|
12
|
+
}, {
|
|
13
|
+
readonly inputs: readonly [{
|
|
14
|
+
readonly internalType: "bytes4";
|
|
15
|
+
readonly name: "interfaceId";
|
|
16
|
+
readonly type: "bytes4";
|
|
17
|
+
}];
|
|
18
|
+
readonly name: "supportsInterface";
|
|
19
|
+
readonly outputs: readonly [{
|
|
20
|
+
readonly internalType: "bool";
|
|
21
|
+
readonly name: "";
|
|
22
|
+
readonly type: "bool";
|
|
23
|
+
}];
|
|
24
|
+
readonly stateMutability: "view";
|
|
25
|
+
readonly type: "function";
|
|
26
|
+
}, {
|
|
27
|
+
readonly anonymous: false;
|
|
28
|
+
readonly inputs: readonly [{
|
|
29
|
+
readonly indexed: true;
|
|
30
|
+
readonly internalType: "address";
|
|
31
|
+
readonly name: "from";
|
|
32
|
+
readonly type: "address";
|
|
33
|
+
}, {
|
|
34
|
+
readonly indexed: true;
|
|
35
|
+
readonly internalType: "address";
|
|
36
|
+
readonly name: "to";
|
|
37
|
+
readonly type: "address";
|
|
38
|
+
}, {
|
|
39
|
+
readonly indexed: true;
|
|
40
|
+
readonly internalType: "uint256";
|
|
41
|
+
readonly name: "tokenId";
|
|
42
|
+
readonly type: "uint256";
|
|
43
|
+
}];
|
|
44
|
+
readonly name: "Transfer";
|
|
45
|
+
readonly type: "event";
|
|
46
|
+
}, {
|
|
47
|
+
readonly anonymous: false;
|
|
48
|
+
readonly inputs: readonly [{
|
|
49
|
+
readonly indexed: true;
|
|
50
|
+
readonly internalType: "address";
|
|
51
|
+
readonly name: "owner";
|
|
52
|
+
readonly type: "address";
|
|
53
|
+
}, {
|
|
54
|
+
readonly indexed: true;
|
|
55
|
+
readonly internalType: "address";
|
|
56
|
+
readonly name: "approved";
|
|
57
|
+
readonly type: "address";
|
|
58
|
+
}, {
|
|
59
|
+
readonly indexed: true;
|
|
60
|
+
readonly internalType: "uint256";
|
|
61
|
+
readonly name: "tokenId";
|
|
62
|
+
readonly type: "uint256";
|
|
63
|
+
}];
|
|
64
|
+
readonly name: "Approval";
|
|
65
|
+
readonly type: "event";
|
|
66
|
+
}, {
|
|
67
|
+
readonly anonymous: false;
|
|
68
|
+
readonly inputs: readonly [{
|
|
69
|
+
readonly indexed: true;
|
|
70
|
+
readonly internalType: "address";
|
|
71
|
+
readonly name: "owner";
|
|
72
|
+
readonly type: "address";
|
|
73
|
+
}, {
|
|
74
|
+
readonly indexed: true;
|
|
75
|
+
readonly internalType: "address";
|
|
76
|
+
readonly name: "operator";
|
|
77
|
+
readonly type: "address";
|
|
78
|
+
}, {
|
|
79
|
+
readonly indexed: false;
|
|
80
|
+
readonly internalType: "bool";
|
|
81
|
+
readonly name: "approved";
|
|
82
|
+
readonly type: "bool";
|
|
83
|
+
}];
|
|
84
|
+
readonly name: "ApprovalForAll";
|
|
85
|
+
readonly type: "event";
|
|
86
|
+
}, {
|
|
87
|
+
readonly inputs: readonly [{
|
|
88
|
+
readonly internalType: "address";
|
|
89
|
+
readonly name: "owner";
|
|
90
|
+
readonly type: "address";
|
|
91
|
+
}];
|
|
92
|
+
readonly name: "balanceOf";
|
|
93
|
+
readonly outputs: readonly [{
|
|
94
|
+
readonly internalType: "uint256";
|
|
95
|
+
readonly name: "balance";
|
|
96
|
+
readonly type: "uint256";
|
|
97
|
+
}];
|
|
98
|
+
readonly stateMutability: "view";
|
|
99
|
+
readonly type: "function";
|
|
100
|
+
}, {
|
|
101
|
+
readonly inputs: readonly [{
|
|
102
|
+
readonly internalType: "uint256";
|
|
103
|
+
readonly name: "tokenId";
|
|
104
|
+
readonly type: "uint256";
|
|
105
|
+
}];
|
|
106
|
+
readonly name: "ownerOf";
|
|
107
|
+
readonly outputs: readonly [{
|
|
108
|
+
readonly internalType: "address";
|
|
109
|
+
readonly name: "owner";
|
|
110
|
+
readonly type: "address";
|
|
111
|
+
}];
|
|
112
|
+
readonly stateMutability: "view";
|
|
113
|
+
readonly type: "function";
|
|
114
|
+
}, {
|
|
115
|
+
readonly inputs: readonly [{
|
|
116
|
+
readonly internalType: "address";
|
|
117
|
+
readonly name: "from";
|
|
118
|
+
readonly type: "address";
|
|
119
|
+
}, {
|
|
120
|
+
readonly internalType: "address";
|
|
121
|
+
readonly name: "to";
|
|
122
|
+
readonly type: "address";
|
|
123
|
+
}, {
|
|
124
|
+
readonly internalType: "uint256";
|
|
125
|
+
readonly name: "tokenId";
|
|
126
|
+
readonly type: "uint256";
|
|
127
|
+
}, {
|
|
128
|
+
readonly internalType: "bytes";
|
|
129
|
+
readonly name: "data";
|
|
130
|
+
readonly type: "bytes";
|
|
131
|
+
}];
|
|
132
|
+
readonly name: "safeTransferFrom";
|
|
133
|
+
readonly outputs: readonly [];
|
|
134
|
+
readonly stateMutability: "nonpayable";
|
|
135
|
+
readonly type: "function";
|
|
136
|
+
}, {
|
|
137
|
+
readonly inputs: readonly [{
|
|
138
|
+
readonly internalType: "address";
|
|
139
|
+
readonly name: "from";
|
|
140
|
+
readonly type: "address";
|
|
141
|
+
}, {
|
|
142
|
+
readonly internalType: "address";
|
|
143
|
+
readonly name: "to";
|
|
144
|
+
readonly type: "address";
|
|
145
|
+
}, {
|
|
146
|
+
readonly internalType: "uint256";
|
|
147
|
+
readonly name: "tokenId";
|
|
148
|
+
readonly type: "uint256";
|
|
149
|
+
}];
|
|
150
|
+
readonly name: "safeTransferFrom";
|
|
151
|
+
readonly outputs: readonly [];
|
|
152
|
+
readonly stateMutability: "nonpayable";
|
|
153
|
+
readonly type: "function";
|
|
154
|
+
}, {
|
|
155
|
+
readonly inputs: readonly [{
|
|
156
|
+
readonly internalType: "address";
|
|
157
|
+
readonly name: "from";
|
|
158
|
+
readonly type: "address";
|
|
159
|
+
}, {
|
|
160
|
+
readonly internalType: "address";
|
|
161
|
+
readonly name: "to";
|
|
162
|
+
readonly type: "address";
|
|
163
|
+
}, {
|
|
164
|
+
readonly internalType: "uint256";
|
|
165
|
+
readonly name: "tokenId";
|
|
166
|
+
readonly type: "uint256";
|
|
167
|
+
}];
|
|
168
|
+
readonly name: "transferFrom";
|
|
169
|
+
readonly outputs: readonly [];
|
|
170
|
+
readonly stateMutability: "nonpayable";
|
|
171
|
+
readonly type: "function";
|
|
172
|
+
}, {
|
|
173
|
+
readonly inputs: readonly [{
|
|
174
|
+
readonly internalType: "address";
|
|
175
|
+
readonly name: "to";
|
|
176
|
+
readonly type: "address";
|
|
177
|
+
}, {
|
|
178
|
+
readonly internalType: "uint256";
|
|
179
|
+
readonly name: "tokenId";
|
|
180
|
+
readonly type: "uint256";
|
|
181
|
+
}];
|
|
182
|
+
readonly name: "approve";
|
|
183
|
+
readonly outputs: readonly [];
|
|
184
|
+
readonly stateMutability: "nonpayable";
|
|
185
|
+
readonly type: "function";
|
|
186
|
+
}, {
|
|
187
|
+
readonly inputs: readonly [{
|
|
188
|
+
readonly internalType: "address";
|
|
189
|
+
readonly name: "operator";
|
|
190
|
+
readonly type: "address";
|
|
191
|
+
}, {
|
|
192
|
+
readonly internalType: "bool";
|
|
193
|
+
readonly name: "approved";
|
|
194
|
+
readonly type: "bool";
|
|
195
|
+
}];
|
|
196
|
+
readonly name: "setApprovalForAll";
|
|
197
|
+
readonly outputs: readonly [];
|
|
198
|
+
readonly stateMutability: "nonpayable";
|
|
199
|
+
readonly type: "function";
|
|
200
|
+
}, {
|
|
201
|
+
readonly inputs: readonly [{
|
|
202
|
+
readonly internalType: "uint256";
|
|
203
|
+
readonly name: "tokenId";
|
|
204
|
+
readonly type: "uint256";
|
|
205
|
+
}];
|
|
206
|
+
readonly name: "getApproved";
|
|
207
|
+
readonly outputs: readonly [{
|
|
208
|
+
readonly internalType: "address";
|
|
209
|
+
readonly name: "operator";
|
|
210
|
+
readonly type: "address";
|
|
211
|
+
}];
|
|
212
|
+
readonly stateMutability: "view";
|
|
213
|
+
readonly type: "function";
|
|
214
|
+
}, {
|
|
215
|
+
readonly inputs: readonly [{
|
|
216
|
+
readonly internalType: "address";
|
|
217
|
+
readonly name: "owner";
|
|
218
|
+
readonly type: "address";
|
|
219
|
+
}, {
|
|
220
|
+
readonly internalType: "address";
|
|
221
|
+
readonly name: "operator";
|
|
222
|
+
readonly type: "address";
|
|
223
|
+
}];
|
|
224
|
+
readonly name: "isApprovedForAll";
|
|
225
|
+
readonly outputs: readonly [{
|
|
226
|
+
readonly internalType: "bool";
|
|
227
|
+
readonly name: "";
|
|
228
|
+
readonly type: "bool";
|
|
229
|
+
}];
|
|
230
|
+
readonly stateMutability: "view";
|
|
231
|
+
readonly type: "function";
|
|
232
|
+
}];
|