@coinbase/agentkit 0.2.3-nightly.20250223.12 → 0.2.3-nightly.20250224.14
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/dist/action-providers/erc20/erc20ActionProvider.js +7 -1
- package/dist/action-providers/erc20/erc20ActionProvider.test.js +4 -2
- package/dist/wallet-providers/cdpWalletProvider.d.ts +2 -2
- package/dist/wallet-providers/evmWalletProvider.d.ts +2 -2
- package/dist/wallet-providers/viemWalletProvider.d.ts +2 -2
- package/package.json +1 -1
|
@@ -49,7 +49,13 @@ class ERC20ActionProvider extends actionProvider_1.ActionProvider {
|
|
|
49
49
|
functionName: "balanceOf",
|
|
50
50
|
args: [walletProvider.getAddress()],
|
|
51
51
|
});
|
|
52
|
-
|
|
52
|
+
const decimals = await walletProvider.readContract({
|
|
53
|
+
address: args.contractAddress,
|
|
54
|
+
abi: constants_1.abi,
|
|
55
|
+
functionName: "decimals",
|
|
56
|
+
args: [],
|
|
57
|
+
});
|
|
58
|
+
return `Balance of ${args.contractAddress} is ${(0, viem_1.formatUnits)(balance, decimals)}`;
|
|
53
59
|
}
|
|
54
60
|
catch (error) {
|
|
55
61
|
return `Error getting balance: ${error}`;
|
|
@@ -5,6 +5,7 @@ const schemas_1 = require("./schemas");
|
|
|
5
5
|
const viem_1 = require("viem");
|
|
6
6
|
const constants_1 = require("./constants");
|
|
7
7
|
const MOCK_AMOUNT = 15;
|
|
8
|
+
const MOCK_DECIMALS = 6;
|
|
8
9
|
const MOCK_CONTRACT_ADDRESS = "0x1234567890123456789012345678901234567890";
|
|
9
10
|
const MOCK_DESTINATION = "0x9876543210987654321098765432109876543210";
|
|
10
11
|
const MOCK_ADDRESS = "0x1234567890123456789012345678901234567890";
|
|
@@ -33,9 +34,10 @@ describe("Get Balance Action", () => {
|
|
|
33
34
|
getAddress: jest.fn().mockReturnValue(MOCK_ADDRESS),
|
|
34
35
|
readContract: jest.fn(),
|
|
35
36
|
};
|
|
36
|
-
mockWallet.readContract.mockResolvedValue(MOCK_AMOUNT);
|
|
37
37
|
});
|
|
38
38
|
it("should successfully respond", async () => {
|
|
39
|
+
mockWallet.readContract.mockResolvedValueOnce(MOCK_AMOUNT);
|
|
40
|
+
mockWallet.readContract.mockResolvedValueOnce(MOCK_DECIMALS);
|
|
39
41
|
const args = {
|
|
40
42
|
contractAddress: MOCK_CONTRACT_ADDRESS,
|
|
41
43
|
};
|
|
@@ -46,7 +48,7 @@ describe("Get Balance Action", () => {
|
|
|
46
48
|
functionName: "balanceOf",
|
|
47
49
|
args: [mockWallet.getAddress()],
|
|
48
50
|
});
|
|
49
|
-
expect(response).toContain(`Balance of ${MOCK_CONTRACT_ADDRESS} is ${MOCK_AMOUNT}`);
|
|
51
|
+
expect(response).toContain(`Balance of ${MOCK_CONTRACT_ADDRESS} is ${MOCK_AMOUNT / 10 ** MOCK_DECIMALS}`);
|
|
50
52
|
});
|
|
51
53
|
it("should fail with an error", async () => {
|
|
52
54
|
const args = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReadContractParameters, ReadContractReturnType, TransactionRequest, TransactionSerializable } from "viem";
|
|
1
|
+
import { ReadContractParameters, ReadContractReturnType, TransactionRequest, TransactionSerializable, Abi, ContractFunctionName, ContractFunctionArgs } from "viem";
|
|
2
2
|
import { EvmWalletProvider } from "./evmWalletProvider";
|
|
3
3
|
import { Network } from "../network";
|
|
4
4
|
import { CreateERC20Options, CreateTradeOptions, SmartContract, Trade, Wallet, WalletData } from "@coinbase/coinbase-sdk";
|
|
@@ -163,7 +163,7 @@ export declare class CdpWalletProvider extends EvmWalletProvider {
|
|
|
163
163
|
* @param params - The parameters to read the contract.
|
|
164
164
|
* @returns The response from the contract.
|
|
165
165
|
*/
|
|
166
|
-
readContract(params: ReadContractParameters): Promise<ReadContractReturnType
|
|
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
167
|
/**
|
|
168
168
|
* Creates a trade.
|
|
169
169
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WalletProvider } from "./walletProvider";
|
|
2
|
-
import { TransactionRequest, ReadContractParameters, ReadContractReturnType } from "viem";
|
|
2
|
+
import { TransactionRequest, ReadContractParameters, ReadContractReturnType, ContractFunctionName, Abi, ContractFunctionArgs } from "viem";
|
|
3
3
|
/**
|
|
4
4
|
* EvmWalletProvider is the abstract base class for all EVM wallet providers.
|
|
5
5
|
*
|
|
@@ -47,5 +47,5 @@ export declare abstract class EvmWalletProvider extends WalletProvider {
|
|
|
47
47
|
* @param params - The parameters to read the contract.
|
|
48
48
|
* @returns The response from the contract.
|
|
49
49
|
*/
|
|
50
|
-
abstract readContract(params: ReadContractParameters): Promise<ReadContractReturnType
|
|
50
|
+
abstract 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>>;
|
|
51
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletClient as ViemWalletClient, TransactionRequest, ReadContractParameters, ReadContractReturnType } from "viem";
|
|
1
|
+
import { WalletClient as ViemWalletClient, TransactionRequest, ReadContractParameters, ReadContractReturnType, Abi, ContractFunctionName, ContractFunctionArgs } from "viem";
|
|
2
2
|
import { EvmWalletProvider } from "./evmWalletProvider";
|
|
3
3
|
import { Network } from "../network";
|
|
4
4
|
/**
|
|
@@ -91,7 +91,7 @@ export declare class ViemWalletProvider extends EvmWalletProvider {
|
|
|
91
91
|
* @param params - The parameters to read the contract.
|
|
92
92
|
* @returns The response from the contract.
|
|
93
93
|
*/
|
|
94
|
-
readContract(params: ReadContractParameters): Promise<ReadContractReturnType
|
|
94
|
+
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>>;
|
|
95
95
|
/**
|
|
96
96
|
* Transfer the native asset of the network.
|
|
97
97
|
*
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@coinbase/agentkit",
|
|
3
3
|
"description": "Coinbase AgentKit core primitives",
|
|
4
4
|
"repository": "https://github.com/coinbase/agentkit",
|
|
5
|
-
"version": "0.2.3-nightly.
|
|
5
|
+
"version": "0.2.3-nightly.20250224.14",
|
|
6
6
|
"author": "Coinbase Inc.",
|
|
7
7
|
"license": "Apache-2.0",
|
|
8
8
|
"main": "dist/index.js",
|