@@ -56,31 +56,31 @@ type MyPluginResult = {
5656/// Export a handler function - that's it!
5757export async function handler(api: PluginAPI, params: MyPluginParams): Promise<MyPluginResult> {
5858 console.info("🚀 Plugin started...");
59-
59+
6060 // Validate parameters
6161 if (!params.destinationAddress) {
6262 throw new Error("destinationAddress is required");
6363 }
64-
64+
6565 // Use the relayer API
6666 const relayer = api.useRelayer(params.relayerId || "my-relayer");
67-
67+
6868 const result = await relayer.sendTransaction({
6969 to: params.destinationAddress,
7070 value: params.amount || 1,
7171 data: "0x",
7272 gas_limit: 21000,
7373 speed: Speed.FAST,
7474 });
75-
75+
7676 console.info(`Transaction submitted: ${result.id}`);
77-
77+
7878 // Wait for confirmation
7979 await result.wait({
8080 interval: 5000, // Check every 5 seconds
8181 timeout: 120000 // Timeout after 2 minutes
8282 });
83-
83+
8484 return {
8585 success: true,
8686 transactionId: result.id,
@@ -117,7 +117,7 @@ type Params = {
117117
118118async function example(api: PluginAPI, params: Params): Promise<string> {
119119 console.info("Plugin started...");
120-
120+
121121 const relayer = api.useRelayer("sepolia-example");
122122 const result = await relayer.sendTransaction({
123123 to: params.destinationAddress,
@@ -126,7 +126,7 @@ async function example(api: PluginAPI, params: Params): Promise<string> {
126126 gas_limit: 21000,
127127 speed: Speed.FAST,
128128 });
129-
129+
130130 await result.wait();
131131 return "done!";
132132}
@@ -246,18 +246,18 @@ type ExampleResult = {
246246export async function handler(api: PluginAPI, params: ExampleParams): Promise<ExampleResult> {
247247 console.info("🚀 Example plugin started");
248248 console.info(`📋 Parameters:`, JSON.stringify(params, null, 2));
249-
249+
250250 try {
251251 // Validate parameters
252252 if (!params.destinationAddress) {
253253 throw new Error("destinationAddress is required");
254254 }
255-
255+
256256 const amount = params.amount || 1;
257257 const message = params.message || "Hello from OpenZeppelin Relayer!";
258-
258+
259259 console.info(`💰 Sending ${amount} wei to ${params.destinationAddress}`);
260-
260+
261261 // Get relayer and send transaction
262262 const relayer = api.useRelayer("my-relayer");
263263 const result = await relayer.sendTransaction({
@@ -267,25 +267,25 @@ export async function handler(api: PluginAPI, params: ExampleParams): Promise<Ex
267267 gas_limit: 21000,
268268 speed: Speed.FAST,
269269 });
270-
270+
271271 console.info(`✅ Transaction submitted: ${result.id}`);
272-
272+
273273 // Wait for confirmation
274274 const confirmation = await result.wait({
275275 interval: 5000,
276276 timeout: 120000
277277 });
278-
278+
279279 console.info(`🎉 Transaction confirmed: ${confirmation.hash}`);
280-
280+
281281 return {
282282 success: true,
283283 transactionId: result.id,
284284 transactionHash: confirmation.hash || null,
285285 message: `Successfully sent ${amount} wei to ${params.destinationAddress}. ${message}`,
286286 timestamp: new Date().toISOString()
287287 };
288-
288+
289289 } catch (error) {
290290 console.error("❌ Plugin execution failed:", error);
291291 return {
@@ -341,7 +341,7 @@ curl -X POST http://localhost:8080/api/v1/plugins/example-plugin/call \
341341 "message": "🚀 Example plugin started"
342342 },
343343 {
344- "level": "info",
344+ "level": "info",
345345 "message": "💰 Sending 1000000000000000 wei to 0x742d35Cc6640C21a1c7656d2c9C8F6bF5e7c3F8A"
346346 },
347347 {
@@ -425,7 +425,7 @@ export async function handler(api: PluginAPI, params: any): Promise<any> {
425425=== Step-by-Step Migration
426426
4274271. **Remove the `runPlugin()` call** at the bottom of your file
428- 2. **Rename your function to `handler`** (or create a new handler export)
428+ 2. **Rename your function to `handler`** (or create a new handler export)
4294293. **Export the `handler` function** using `export async function handler`
4304304. **Add proper TypeScript types** for better development experience
4314315. **Test your plugin** to ensure it works with the new pattern
0 commit comments