Skip to content

Commit 87bce05

Browse files
committed
Add AGW support to the Abstract plugin
1 parent 4b391b3 commit 87bce05

File tree

4 files changed

+349
-44
lines changed

4 files changed

+349
-44
lines changed

packages/plugin-abstract/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"dist"
2020
],
2121
"dependencies": {
22+
"@abstract-foundation/agw-client": "^0.1.7",
2223
"@elizaos/core": "workspace:*",
2324
"tsup": "^8.3.5",
2425
"viem": "2.22.2"

packages/plugin-abstract/src/actions/transferAction.ts

+41-3
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@ import { validateAbstractConfig } from "../environment";
1515

1616
import {
1717
Address,
18-
createWalletClient,
1918
erc20Abi,
2019
http,
2120
parseEther,
2221
isAddress,
2322
parseUnits,
2423
createPublicClient,
24+
WalletClient,
2525
} from "viem";
2626
import { abstractTestnet, mainnet } from "viem/chains";
2727
import { normalize } from "viem/ens";
28+
import {
29+
createAbstractClient,
30+
AbstractClient,
31+
} from "@abstract-foundation/agw-client";
2832
import { z } from "zod";
2933
import { ValidateContext } from "../utils";
3034
import { ETH_ADDRESS, ERC20_OVERRIDE_INFO } from "../constants";
@@ -39,12 +43,14 @@ const TransferSchema = z.object({
3943
tokenAddress: z.string(),
4044
recipient: z.string(),
4145
amount: z.string(),
46+
useAGW: z.boolean(),
4247
});
4348

4449
export interface TransferContent extends Content {
4550
tokenAddress: string;
4651
recipient: string;
4752
amount: string | number;
53+
useAGW: boolean;
4854
}
4955

5056
const transferTemplate = `Respond with a JSON markdown block containing only the extracted values. Use null for any values that cannot be determined.
@@ -58,7 +64,8 @@ Example response:
5864
{
5965
"tokenAddress": "0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E",
6066
"recipient": "0xCCa8009f5e09F8C5dB63cb0031052F9CB635Af62",
61-
"amount": "1000"
67+
"amount": "1000",
68+
"useAGW": true
6269
}
6370
\`\`\`
6471
@@ -68,6 +75,7 @@ Given the recent messages, extract the following information about the requested
6875
- Token contract address
6976
- Recipient wallet address
7077
- Amount to transfer
78+
- Whether to use Abstract Global Wallet aka AGW
7179
7280
Respond with a JSON markdown block containing only the extracted values.`;
7381

@@ -150,7 +158,16 @@ export const transferAction: Action = {
150158

151159
try {
152160
const account = useGetAccount(runtime);
153-
const walletClient = useGetWalletClient();
161+
let walletClient: AbstractClient | WalletClient;
162+
163+
if (content.useAGW) {
164+
walletClient = await createAbstractClient({
165+
chain: abstractTestnet,
166+
signer: account,
167+
});
168+
} else {
169+
walletClient = useGetWalletClient();
170+
}
154171

155172
let hash;
156173

@@ -233,6 +250,27 @@ export const transferAction: Action = {
233250
},
234251
},
235252
],
253+
[
254+
{
255+
user: "{{user1}}",
256+
content: {
257+
text: "Send 0.01 ETH to 0x114B242D931B47D5cDcEe7AF065856f70ee278C4 using your abstract global wallet",
258+
},
259+
},
260+
{
261+
user: "{{agent}}",
262+
content: {
263+
text: "Sure, I'll send 0.01 ETH to that address now using my AGW.",
264+
action: "SEND_TOKEN",
265+
},
266+
},
267+
{
268+
user: "{{agent}}",
269+
content: {
270+
text: "Successfully sent 0.01 ETH to 0x114B242D931B47D5cDcEe7AF065856f70ee278C4\nTransaction: 0xdde850f9257365fffffc11324726ebdcf5b90b01c6eec9b3e7ab3e81fde6f14b using my AGW",
271+
},
272+
},
273+
],
236274
[
237275
{
238276
user: "{{user1}}",

packages/plugin-tts/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
],
2121
"dependencies": {
2222
"@elizaos/core": "workspace:*",
23+
"langdetect": "^0.2.1",
2324
"tsup": "8.3.5",
2425
"whatwg-url": "7.1.0"
2526
},

0 commit comments

Comments
 (0)