-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
I see that right now the default points to docker webhooks in sandbox here
Proposing modifications to sandbox such that we can enable interoperable communication, abstracting a lot of the logic for builders.
In order to recieve the callback at the same place as of action,
import { P2PEnergy } from '../p2p-energy';
const initObject = {
persona: process.env.PERSONA, // enum BAP, BPP, BOTH
bapServerUrl: process.env.BAPSERVER_URL || "",
bppServerUrl: process.env.BPPSERVER_URL || "",
redisUrl: process.env.REDIS_URL || "",
channelId: process.env.channelId || "", // ensure same channel name across devices if you are listening.
usecase: "p2p-trading" // enum of different usecases, right now static
}
const client = new P2PEnergy.init(initObject);
await client.connect();
const response = p2p.action(payload).then((onActionResponse) => console.log(onActionResponse));
or
// response resolves only when onAction comes back via redis channel otherwise returns a promise.
const response = await p2p.action(payload);
await client.disconnect();
In Order to receive callback at BPP's device or BAP's device or to multiple agents in between.
// in order to receive the callback on other device (initObject must be same)
await p2p.action(payload);
// in other device
client.on('action', (onActionResponse) => {
console.log("Received action callback:", onActionResponse);
});
In Order to have a custom middleware for db / agentic logic / or even verification logic.
// rest of it remains same as above.
const middleware = async (ctx, next) => {
if (['search', 'confirm'].includes(ctx.action)) {
console.log(`[VC] Verifying ${ctx.payload.vc_id}`);
// await vcService.verify(ctx.payload.vc_id);
}
return next();
};
const response = await client.action(payload, middleware);
old way,
client.action(payload, middleware).then((response) => {
console.log(response);
});
I was able to listen to :3001, :3002 and log callbacks as shown in the image below, I can make this work end to end to create pull request for other devs as well.
Looking forward for comments on the proposed architechture for sandbox using redis as pub sub.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels