From 2480c96644a8d763cce6646f7f5e5d0d9c8f93aa Mon Sep 17 00:00:00 2001 From: dylanyang Date: Mon, 18 Mar 2024 23:02:51 +0800 Subject: [PATCH] update PackUserOp --- service/operator/try_pay_user_op_execute.go | 10 ++++------ service/operator/try_pay_user_op_execute_test.go | 5 +++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/service/operator/try_pay_user_op_execute.go b/service/operator/try_pay_user_op_execute.go index 3f3d5d58..1c343d1b 100644 --- a/service/operator/try_pay_user_op_execute.go +++ b/service/operator/try_pay_user_op_execute.go @@ -133,7 +133,7 @@ func getPayMasterSignature(strategy *model.Strategy, userOp *model.UserOperation } func packUserOp(userOp *model.UserOperation) (string, error) { abiEncoder, err := abi.JSON(strings.NewReader(`[ -{ + { "inputs": [ { "components": [ @@ -194,7 +194,7 @@ func packUserOp(userOp *model.UserOperation) (string, error) { } ], "internalType": "struct UserOperation", - "name": "op", + "name": "userOp", "type": "tuple" } ], @@ -203,14 +203,12 @@ func packUserOp(userOp *model.UserOperation) (string, error) { "stateMutability": "nonpayable", "type": "function" } - ]`)) +]`)) if err != nil { return "", err } - encoded, err := abiEncoder.Pack("test", userOp.Sender.String(), userOp.Nonce, userOp.InitCode, - userOp.CallData, userOp.CallGasLimit, userOp.VerificationGasLimit, userOp.PreVerificationGas, - userOp.MaxFeePerGas, userOp.MaxPriorityFeePerGas) + encoded, err := abiEncoder.Pack("test", userOp) if err != nil { return "", err } diff --git a/service/operator/try_pay_user_op_execute_test.go b/service/operator/try_pay_user_op_execute_test.go index 72a7a707..b9da05e5 100644 --- a/service/operator/try_pay_user_op_execute_test.go +++ b/service/operator/try_pay_user_op_execute_test.go @@ -35,12 +35,13 @@ func TestGenerateTestData(t *testing.T) { } func TestPackUserOp(t *testing.T) { userOp, _ := model.NewUserOp(utils.GenerateMockUserOperation()) - userOp.Signature = nil userOp.PaymasterAndData = nil - + userOp.Signature = nil res, err := packUserOp(userOp) + assert.NoError(t, err) fmt.Println(res) + } func TestPackUserOpV2(t *testing.T) { userOp, _ := model.NewUserOp(utils.GenerateMockUserOperation())