@coinbase/agentkit 0.0.0-nightly-20251003210419 → 0.0.0-nightly-20251008210432

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.
@@ -32,6 +32,7 @@ const wallet_providers_1 = require("../../wallet-providers");
32
32
  const utils_1 = require("./utils");
33
33
  const accounts_1 = require("viem/accounts");
34
34
  const viem_2 = require("viem");
35
+ const app_sdk_1 = require("@across-protocol/app-sdk");
35
36
  /**
36
37
  * AcrossActionProvider provides actions for cross-chain bridging via Across Protocol.
37
38
  */
@@ -68,9 +69,6 @@ class AcrossActionProvider extends actionProvider_1.ActionProvider {
68
69
  */
69
70
  async bridgeToken(walletProvider, args) {
70
71
  try {
71
- // Use dynamic import to get the Across SDK
72
- const acrossModule = await import("@across-protocol/app-sdk");
73
- const createAcrossClient = acrossModule.createAcrossClient;
74
72
  // Get recipient address if provided, otherwise use sender
75
73
  const address = walletProvider.getAddress();
76
74
  const recipient = (args.recipient || address);
@@ -105,7 +103,7 @@ class AcrossActionProvider extends actionProvider_1.ActionProvider {
105
103
  transport: (0, viem_1.http)(),
106
104
  });
107
105
  // Create Across client
108
- const acrossClient = createAcrossClient({
106
+ const acrossClient = (0, app_sdk_1.createAcrossClient)({
109
107
  chains: [originChain, destinationChain],
110
108
  useTestnet,
111
109
  });
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const acrossActionProvider_1 = require("./acrossActionProvider");
4
4
  const viem_1 = require("viem");
5
+ const app_sdk_1 = require("@across-protocol/app-sdk");
5
6
  // Mock the necessary imports and modules
6
7
  jest.mock("viem", () => {
7
8
  return {
@@ -63,10 +64,11 @@ jest.mock("../../network", () => {
63
64
  };
64
65
  });
65
66
  // Mock the Across SDK
66
- const mockCreateAcrossClient = jest.fn();
67
67
  jest.mock("@across-protocol/app-sdk", () => ({
68
- createAcrossClient: mockCreateAcrossClient,
68
+ createAcrossClient: jest.fn(),
69
69
  }));
70
+ // Cast the imported mock to a Jest mock function
71
+ const mockedCreateAcrossClient = app_sdk_1.createAcrossClient;
70
72
  // Default implementation for the createAcrossClient mock
71
73
  const defaultClientImplementation = () => ({
72
74
  getSupportedChains: jest.fn().mockResolvedValue([
@@ -134,7 +136,7 @@ const defaultClientImplementation = () => ({
134
136
  }),
135
137
  });
136
138
  // Set the default implementation
137
- mockCreateAcrossClient.mockImplementation(() => {
139
+ mockedCreateAcrossClient.mockImplementation(() => {
138
140
  const client = defaultClientImplementation();
139
141
  // Add the chains property to match what the code expects
140
142
  return {
@@ -151,6 +153,7 @@ mockCreateAcrossClient.mockImplementation(() => {
151
153
  network: "optimism",
152
154
  },
153
155
  ],
156
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
157
  };
155
158
  });
156
159
  // Mock the isTestnet function
@@ -170,7 +173,7 @@ describe("Across Action Provider", () => {
170
173
  beforeEach(() => {
171
174
  jest.clearAllMocks();
172
175
  // Reset to default implementation
173
- mockCreateAcrossClient.mockImplementation(() => {
176
+ mockedCreateAcrossClient.mockImplementation(() => {
174
177
  const client = defaultClientImplementation();
175
178
  // Add the chains property to match what the code expects
176
179
  return {
@@ -187,6 +190,7 @@ describe("Across Action Provider", () => {
187
190
  network: "optimism",
188
191
  },
189
192
  ],
193
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
190
194
  };
191
195
  });
192
196
  mockPublicClient = {
@@ -247,7 +251,7 @@ describe("Across Action Provider", () => {
247
251
  });
248
252
  it("should fail when slippage is too high", async () => {
249
253
  // Override the default mock with high slippage for this test only
250
- mockCreateAcrossClient.mockImplementationOnce(() => ({
254
+ mockedCreateAcrossClient.mockImplementationOnce(() => ({
251
255
  getSupportedChains: jest.fn().mockResolvedValue([
252
256
  {
253
257
  chainId: 1,
@@ -288,6 +292,7 @@ describe("Across Action Provider", () => {
288
292
  waitForDepositTx: jest.fn().mockResolvedValue({
289
293
  depositId: "123456",
290
294
  }),
295
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
291
296
  }));
292
297
  // Set a low max slippage
293
298
  const args = {
@@ -19,6 +19,7 @@ const utils_1 = require("../erc20/utils");
19
19
  const schemas_1 = require("./schemas");
20
20
  const utils_2 = require("./utils");
21
21
  const utils_3 = require("../../utils");
22
+ const spend_permission_1 = require("@base-org/account/spend-permission");
22
23
  /**
23
24
  * Fetch spend permissions for a user account from a spender address
24
25
  *
@@ -29,8 +30,7 @@ const utils_3 = require("../../utils");
29
30
  */
30
31
  async function fetchUserSpendPermissions(userAccount, spenderAccount, tokenAddress) {
31
32
  try {
32
- const { fetchPermissions } = await import("@base-org/account/spend-permission");
33
- const permissions = await fetchPermissions({
33
+ const permissions = await (0, spend_permission_1.fetchPermissions)({
34
34
  account: userAccount,
35
35
  chainId: 8453,
36
36
  spender: spenderAccount,
@@ -200,10 +200,9 @@ class BaseAccountActionProvider extends actionProvider_1.ActionProvider {
200
200
  });
201
201
  }
202
202
  // Check permission status and prepare spend call data
203
- const { getPermissionStatus, prepareSpendCallData } = await import("@base-org/account/spend-permission");
204
203
  const status = await (0, utils_3.retryWithExponentialBackoff)(
205
204
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
206
- () => getPermissionStatus(_permission), 3, // Max 3 retries
205
+ () => (0, spend_permission_1.getPermissionStatus)(_permission), 3, // Max 3 retries
207
206
  1000, // 1s base delay
208
207
  2000);
209
208
  // Determine amount to spend - use provided amount or full remaining allowance
@@ -226,7 +225,7 @@ class BaseAccountActionProvider extends actionProvider_1.ActionProvider {
226
225
  // Prepare the spend transaction - returns an array of calls
227
226
  const spendCalls = await (0, utils_3.retryWithExponentialBackoff)(
228
227
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
229
- () => prepareSpendCallData(_permission, amountInAtomicUnits), 3, // Max 3 retries
228
+ () => (0, spend_permission_1.prepareSpendCallData)(_permission, amountInAtomicUnits), 3, // Max 3 retries
230
229
  1000, // 1s base delay
231
230
  2000);
232
231
  // Take the first call from the array (there should be one for spend operations)
@@ -303,9 +302,8 @@ class BaseAccountActionProvider extends actionProvider_1.ActionProvider {
303
302
  // Use the specified permission (convert to 0-based index)
304
303
  const _permission = permissions[permissionIndex - 1];
305
304
  // Prepare the revoke transaction
306
- const { prepareRevokeCallData } = await import("@base-org/account/spend-permission");
307
305
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
308
- const revokeCall = await prepareRevokeCallData(_permission);
306
+ const revokeCall = await (0, spend_permission_1.prepareRevokeCallData)(_permission);
309
307
  // Execute the revoke transaction
310
308
  const txHash = await walletProvider.sendTransaction({
311
309
  to: revokeCall.to,
@@ -1,4 +1,5 @@
1
1
  import { EvmWalletProvider } from "../../wallet-providers";
2
+ import { Clanker } from "clanker-sdk/v4";
2
3
  /**
3
4
  * Creates the client Clanker expects from the EvmWalletProvider
4
5
  *
@@ -6,4 +7,4 @@ import { EvmWalletProvider } from "../../wallet-providers";
6
7
  * @param networkId - The network to Clank on
7
8
  * @returns The Clanker implementation
8
9
  */
9
- export declare function createClankerClient(walletProvider: EvmWalletProvider, networkId: string): Promise<import("clanker-sdk/v4", { with: { "resolution-mode": "import" } }).Clanker>;
10
+ export declare function createClankerClient(walletProvider: EvmWalletProvider, networkId: string): Promise<Clanker>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createClankerClient = createClankerClient;
4
4
  const viem_1 = require("viem");
5
5
  const network_1 = require("../../network");
6
+ const v4_1 = require("clanker-sdk/v4");
6
7
  /**
7
8
  * Creates the client Clanker expects from the EvmWalletProvider
8
9
  *
@@ -11,7 +12,6 @@ const network_1 = require("../../network");
11
12
  * @returns The Clanker implementation
12
13
  */
13
14
  async function createClankerClient(walletProvider, networkId) {
14
- const { Clanker } = await import("clanker-sdk/v4");
15
15
  const account = walletProvider.toSigner();
16
16
  const publicClient = walletProvider.getPublicClient();
17
17
  const wallet = (0, viem_1.createWalletClient)({
@@ -19,5 +19,5 @@ async function createClankerClient(walletProvider, networkId) {
19
19
  chain: network_1.NETWORK_ID_TO_VIEM_CHAIN[networkId],
20
20
  transport: (0, viem_1.http)(publicClient.transport.url),
21
21
  });
22
- return new Clanker({ wallet, publicClient });
22
+ return new v4_1.Clanker({ wallet, publicClient });
23
23
  }
@@ -226,7 +226,7 @@ __decorate([
226
226
  It takes the following inputs:
227
227
  - amount: The amount to transfer in whole units (e.g. 10.5 USDC)
228
228
  - tokenAddress: The contract address of the token to transfer
229
- - destinationAddress: Where to send the funds (can be an onchain address, ENS 'example.eth', or Basename 'example.base.eth')
229
+ - destinationAddress: The address to send the funds to
230
230
  Important notes:
231
231
  - Never assume token or destination addresses, they have to be provided as inputs. If only token symbol is provided, use the get_token_address tool to get the token address first
232
232
  `,
@@ -17,6 +17,7 @@ const actionDecorator_1 = require("../actionDecorator");
17
17
  const schemas_1 = require("./schemas");
18
18
  const web3_js_1 = require("@solana/web3.js");
19
19
  const api_1 = require("@jup-ag/api");
20
+ const spl_token_1 = require("@solana/spl-token");
20
21
  /**
21
22
  * JupiterActionProvider handles token swaps using Jupiter's API.
22
23
  */
@@ -40,10 +41,9 @@ class JupiterActionProvider extends actionProvider_1.ActionProvider {
40
41
  const userPublicKey = walletProvider.getPublicKey();
41
42
  const inputMint = new web3_js_1.PublicKey(args.inputMint);
42
43
  const outputMint = new web3_js_1.PublicKey(args.outputMint);
43
- const { getMint } = await import("@solana/spl-token");
44
44
  let mintInfo;
45
45
  try {
46
- mintInfo = await getMint(walletProvider.getConnection(), inputMint);
46
+ mintInfo = await (0, spl_token_1.getMint)(walletProvider.getConnection(), inputMint);
47
47
  }
48
48
  catch (error) {
49
49
  return `Failed to fetch mint info for mint address ${args.inputMint}. Error: ${error}`;
@@ -16,6 +16,7 @@ const zod_1 = require("zod");
16
16
  const actionDecorator_1 = require("../actionDecorator");
17
17
  const schemas_1 = require("./schemas");
18
18
  const web3_js_1 = require("@solana/web3.js");
19
+ const spl_token_1 = require("@solana/spl-token");
19
20
  /**
20
21
  * SplActionProvider serves as a provider for SPL token actions.
21
22
  * It provides SPL token transfer functionality.
@@ -42,22 +43,21 @@ class SplActionProvider extends actionProvider_1.ActionProvider {
42
43
  const connection = walletProvider.getConnection();
43
44
  const mintPubkey = new web3_js_1.PublicKey(args.mintAddress);
44
45
  const ownerPubkey = new web3_js_1.PublicKey(args.address);
45
- const { getMint, getAssociatedTokenAddress, getAccount, TokenAccountNotFoundError } = await import("@solana/spl-token");
46
46
  let mintInfo;
47
47
  try {
48
- mintInfo = await getMint(connection, mintPubkey);
48
+ mintInfo = await (0, spl_token_1.getMint)(connection, mintPubkey);
49
49
  }
50
50
  catch (error) {
51
51
  return `Failed to fetch mint info for mint address ${args.mintAddress}. Error: ${error}`;
52
52
  }
53
53
  try {
54
- const ata = await getAssociatedTokenAddress(mintPubkey, ownerPubkey);
55
- const account = await getAccount(connection, ata);
54
+ const ata = await (0, spl_token_1.getAssociatedTokenAddress)(mintPubkey, ownerPubkey);
55
+ const account = await (0, spl_token_1.getAccount)(connection, ata);
56
56
  const balance = Number(account.amount) / Math.pow(10, mintInfo.decimals);
57
57
  return `Balance for ${args.address} is ${balance} tokens`;
58
58
  }
59
59
  catch (error) {
60
- if (error instanceof TokenAccountNotFoundError) {
60
+ if (error instanceof spl_token_1.TokenAccountNotFoundError) {
61
61
  return `Balance for ${args.address} is 0 tokens`;
62
62
  }
63
63
  throw error;
@@ -80,29 +80,28 @@ class SplActionProvider extends actionProvider_1.ActionProvider {
80
80
  const fromPubkey = walletProvider.getPublicKey();
81
81
  const toPubkey = new web3_js_1.PublicKey(args.recipient);
82
82
  const mintPubkey = new web3_js_1.PublicKey(args.mintAddress);
83
- const { getMint, getAssociatedTokenAddress, getAccount, createAssociatedTokenAccountInstruction, createTransferCheckedInstruction, } = await import("@solana/spl-token");
84
83
  let mintInfo;
85
84
  try {
86
- mintInfo = await getMint(connection, mintPubkey);
85
+ mintInfo = await (0, spl_token_1.getMint)(connection, mintPubkey);
87
86
  }
88
87
  catch (error) {
89
88
  return `Failed to fetch mint info for mint address ${args.mintAddress}. Error: ${error}`;
90
89
  }
91
90
  const adjustedAmount = args.amount * Math.pow(10, mintInfo.decimals);
92
- const sourceAta = await getAssociatedTokenAddress(mintPubkey, fromPubkey);
93
- const destinationAta = await getAssociatedTokenAddress(mintPubkey, toPubkey);
91
+ const sourceAta = await (0, spl_token_1.getAssociatedTokenAddress)(mintPubkey, fromPubkey);
92
+ const destinationAta = await (0, spl_token_1.getAssociatedTokenAddress)(mintPubkey, toPubkey);
94
93
  const instructions = [];
95
- const sourceAccount = await getAccount(connection, sourceAta);
94
+ const sourceAccount = await (0, spl_token_1.getAccount)(connection, sourceAta);
96
95
  if (sourceAccount.amount < BigInt(adjustedAmount)) {
97
96
  throw new Error(`Insufficient token balance. Have ${sourceAccount.amount}, need ${adjustedAmount}`);
98
97
  }
99
98
  try {
100
- await getAccount(connection, destinationAta);
99
+ await (0, spl_token_1.getAccount)(connection, destinationAta);
101
100
  }
102
101
  catch {
103
- instructions.push(createAssociatedTokenAccountInstruction(fromPubkey, destinationAta, toPubkey, mintPubkey));
102
+ instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(fromPubkey, destinationAta, toPubkey, mintPubkey));
104
103
  }
105
- instructions.push(createTransferCheckedInstruction(sourceAta, mintPubkey, destinationAta, fromPubkey, adjustedAmount, mintInfo.decimals));
104
+ instructions.push((0, spl_token_1.createTransferCheckedInstruction)(sourceAta, mintPubkey, destinationAta, fromPubkey, adjustedAmount, mintInfo.decimals));
106
105
  const tx = new web3_js_1.VersionedTransaction(web3_js_1.MessageV0.compile({
107
106
  payerKey: fromPubkey,
108
107
  instructions: instructions,
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getAccountOutflow = getAccountOutflow;
4
4
  const queries_1 = require("./queries");
5
5
  const endpoints_1 = require("./endpoints");
6
+ const graphql_request_1 = require("graphql-request");
6
7
  /**
7
8
  * Gets the current account outflows for the user
8
9
  *
@@ -11,8 +12,7 @@ const endpoints_1 = require("./endpoints");
11
12
  */
12
13
  async function getAccountOutflow(userId) {
13
14
  try {
14
- const { GraphQLClient } = await import("graphql-request");
15
- const client = new GraphQLClient(endpoints_1.BASE_GRAPH_ENDPOINT);
15
+ const client = new graphql_request_1.GraphQLClient(endpoints_1.BASE_GRAPH_ENDPOINT);
16
16
  const variables = { id: userId.toLowerCase() };
17
17
  const data = await client.request(queries_1.getAccountOutflowQuery, variables);
18
18
  return data;
@@ -133,7 +133,7 @@ __decorate([
133
133
  (0, actionDecorator_1.CreateAction)({
134
134
  name: "native_transfer",
135
135
  description: `
136
- This tool will transfer (send) native tokens from the wallet to another onchain address.
136
+ This tool will transfer (send) native tokens (ETH for EVM networks, SOL for SVM networks) from the wallet to another onchain address.
137
137
 
138
138
  It takes the following inputs:
139
139
  - amount: The amount to transfer in whole units (e.g. 4.2 ETH, 0.1 SOL)
@@ -29,6 +29,7 @@ const schemas_1 = require("./schemas");
29
29
  const actionDecorator_1 = require("../actionDecorator");
30
30
  const viem_1 = require("viem");
31
31
  const utils_1 = require("./utils");
32
+ const coins_sdk_1 = require("@zoralabs/coins-sdk");
32
33
  const SUPPORTED_NETWORKS = ["base-mainnet", "base-sepolia"];
33
34
  /**
34
35
  * ZoraActionProvider provides actions for interacting with the Zora protocol.
@@ -72,8 +73,6 @@ class ZoraActionProvider extends actionProvider_1.ActionProvider {
72
73
  category: args.category,
73
74
  pinataConfig: { jwt: __classPrivateFieldGet(this, _ZoraActionProvider_pinataJwt, "f") },
74
75
  });
75
- // Dynamically import Zora SDK
76
- const { createCoinCall, DeployCurrency, getCoinCreateFromLogs } = await import("@zoralabs/coins-sdk");
77
76
  // Create coin call
78
77
  const call = {
79
78
  name: args.name,
@@ -82,16 +81,16 @@ class ZoraActionProvider extends actionProvider_1.ActionProvider {
82
81
  uri: uri,
83
82
  payoutRecipient: args.payoutRecipient || walletProvider.getAddress(),
84
83
  platformReferrer: args.platformReferrer || "0x0000000000000000000000000000000000000000",
85
- currency: args.currency === "ZORA" ? DeployCurrency.ZORA : DeployCurrency.ETH,
84
+ currency: args.currency === "ZORA" ? coins_sdk_1.DeployCurrency.ZORA : coins_sdk_1.DeployCurrency.ETH,
86
85
  };
87
- const createCoinRequest = await createCoinCall(call);
86
+ const createCoinRequest = await (0, coins_sdk_1.createCoinCall)(call);
88
87
  const { abi, functionName, address, args: callArgs, value } = createCoinRequest;
89
88
  const data = (0, viem_1.encodeFunctionData)({ abi, functionName, args: callArgs });
90
89
  const txRequest = { to: address, data, value };
91
90
  // Send transaction
92
91
  const hash = await walletProvider.sendTransaction(txRequest);
93
92
  const receipt = await walletProvider.waitForTransactionReceipt(hash);
94
- const deployment = getCoinCreateFromLogs(receipt);
93
+ const deployment = (0, coins_sdk_1.getCoinCreateFromLogs)(receipt);
95
94
  if (receipt.status === "success") {
96
95
  return JSON.stringify({
97
96
  success: true,
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.0.0-nightly-20251003210419",
5
+ "version": "0.0.0-nightly-20251008210432",
6
6
  "author": "Coinbase Inc.",
7
7
  "license": "Apache-2.0",
8
8
  "main": "dist/index.js",