Skip to content

Commit

Permalink
starting implement the new trigger/node
Browse files Browse the repository at this point in the history
  • Loading branch information
v9n committed Nov 11, 2024
1 parent bf48a9c commit 8ce3e99
Show file tree
Hide file tree
Showing 7 changed files with 2,201 additions and 1,224 deletions.
6 changes: 3 additions & 3 deletions core/taskengine/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,17 @@ func (c *ContractProcessor) Perform(job *apqueue.Job) error {
// Process entrypoint node, then from the next pointer, and flow of the node, we will follow the chain of execution
action := task.Nodes[0]

if action.ContractExecution == nil {
if action.GetContractExecution() == nil {
err := fmt.Errorf("invalid task action")
task.AppendExecution(currentTime.Unix(), "", err)
task.SetFailed()
return err
}

userOpCalldata, e := aa.PackExecute(
common.HexToAddress(action.ContractExecution.ContractAddress),
common.HexToAddress(action.GetContractExecution().ContractAddress),
big.NewInt(0),
common.FromHex(action.ContractExecution.CallData),
common.FromHex(action.GetContractExecution().CallData),
)
//calldata := common.FromHex("b61d27f600000000000000000000000069256ca54e6296e460dec7b29b7dcd97b81a3d55000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000e0f7d11fd714674722d325cd86062a5f1882e13a0000000000000000000000000000000000000000000000001bc16d674ec8000000000000000000000000000000000000000000000000000000000000")

Expand Down
17 changes: 12 additions & 5 deletions examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ async function listTask(owner, token) {
smart_wallet_address: process.argv[3]
}, metadata);

console.log("Tasks that has created by", process.argv[3], "\n", result);
console.log("Tasks that has created by", process.argv[3]);
for (const item of result.tasks) {
console.log("raw data", item.id, item);

}
}

async function getTask(owner, token, taskId) {
Expand Down Expand Up @@ -371,10 +375,13 @@ async function scheduleERC20TransferJob(owner, token, taskCondition) {
}
}],
trigger: {
trigger_type: TriggerType.EXPRESSIONTRIGGER,
expression: {
expression: taskCondition,
}
trigger_type: TriggerType.EVENTTRIGGER,
//event: {
// expression: taskCondition,
//}
cron: {
cron_table: ["0 /2"],
},
},
start_at: Math.floor(Date.now() / 1000) + 30,
expired_at: Math.floor(Date.now() / 1000 + 3600 * 24 * 30),
Expand Down
35 changes: 34 additions & 1 deletion examples/static_codegen/avs_grpc_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ function deserialize_aggregator_CreateTaskResp(buffer_arg) {
return avs_pb.CreateTaskResp.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_aggregator_CreateWalletReq(arg) {
if (!(arg instanceof avs_pb.CreateWalletReq)) {
throw new Error('Expected argument of type aggregator.CreateWalletReq');
}
return Buffer.from(arg.serializeBinary());
}

function deserialize_aggregator_CreateWalletReq(buffer_arg) {
return avs_pb.CreateWalletReq.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_aggregator_CreateWalletResp(arg) {
if (!(arg instanceof avs_pb.CreateWalletResp)) {
throw new Error('Expected argument of type aggregator.CreateWalletResp');
}
return Buffer.from(arg.serializeBinary());
}

function deserialize_aggregator_CreateWalletResp(buffer_arg) {
return avs_pb.CreateWalletResp.deserializeBinary(new Uint8Array(buffer_arg));
}

function serialize_aggregator_GetKeyReq(arg) {
if (!(arg instanceof avs_pb.GetKeyReq)) {
throw new Error('Expected argument of type aggregator.GetKeyReq');
Expand Down Expand Up @@ -253,7 +275,18 @@ getNonce: {
responseDeserialize: deserialize_aggregator_AddressResp,
},
// Task Management
createTask: {
createWallet: {
path: '/aggregator.Aggregator/CreateWallet',
requestStream: false,
responseStream: false,
requestType: avs_pb.CreateWalletReq,
responseType: avs_pb.CreateWalletResp,
requestSerialize: serialize_aggregator_CreateWalletReq,
requestDeserialize: deserialize_aggregator_CreateWalletReq,
responseSerialize: serialize_aggregator_CreateWalletResp,
responseDeserialize: deserialize_aggregator_CreateWalletResp,
},
createTask: {
path: '/aggregator.Aggregator/CreateTask',
requestStream: false,
responseStream: false,
Expand Down
Loading

0 comments on commit 8ce3e99

Please sign in to comment.