Skip to content

Commit f018bf1

Browse files
committed
feat: replace Zerodev service with Thirdweb in user operation handling
- Remove Zerodev-specific logic from SponsorUserOperation and SendUserOperation functions. - Integrate Thirdweb service support, updating request parameters and response handling accordingly. - Adjust URL detection to recognize Thirdweb service.
1 parent 752c2ab commit f018bf1

File tree

1 file changed

+5
-40
lines changed

1 file changed

+5
-40
lines changed

utils/userop.go

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -173,32 +173,8 @@ func SponsorUserOperation(userOp *userop.UserOperation, mode string, token strin
173173
userOpExpanded,
174174
payload,
175175
}
176-
case "zerodev":
177-
method = "zd_sponsorUserOperation"
178-
var shouldOverrideFee bool
179-
var shouldConsume bool
180-
181-
if mode == "sponsored" {
182-
shouldOverrideFee = true
183-
shouldConsume = false
184-
} else if mode == "erc20" {
185-
shouldOverrideFee = true
186-
shouldConsume = true
187-
} else {
188-
return fmt.Errorf("invalid mode")
189-
}
190-
191-
requestParams = []interface{}{
192-
chainId,
193-
userOpExpanded,
194-
orderConf.EntryPointContractAddress.Hex(),
195-
map[string]interface{}{
196-
"tokenAddress": token,
197-
},
198-
shouldOverrideFee,
199-
shouldConsume,
200-
}
201176
case "pimlico":
177+
case "thirdweb":
202178
requestParams = []interface{}{
203179
userOpExpanded,
204180
map[string]interface{}{
@@ -247,13 +223,8 @@ func SponsorUserOperation(userOp *userop.UserOperation, mode string, token strin
247223
userOp.VerificationGasLimit = decimal.NewFromFloat(response["verificationGasLimit"].(float64)).BigInt()
248224
userOp.CallGasLimit = decimal.NewFromFloat(response["callGasLimit"].(float64)).BigInt()
249225

250-
case "zerodev":
251-
userOp.PaymasterAndData = common.FromHex(response["paymasterAndData"].(string))
252-
userOp.PreVerificationGas, _ = new(big.Int).SetString(response["preVerificationGas"].(string), 0)
253-
userOp.VerificationGasLimit = decimal.NewFromFloat(response["verificationGasLimit"].(float64)).BigInt()
254-
userOp.CallGasLimit = decimal.NewFromFloat(response["callGasLimit"].(float64)).BigInt()
255-
256226
case "pimlico":
227+
case "thirdweb":
257228
userOp.PaymasterAndData = common.FromHex(response["paymasterAndData"].(string))
258229
userOp.PreVerificationGas, _ = new(big.Int).SetString(response["preVerificationGas"].(string), 0)
259230
userOp.VerificationGasLimit = decimal.NewFromFloat(response["verificationGasLimit"].(float64)).BigInt()
@@ -309,14 +280,8 @@ func SendUserOperation(userOp *userop.UserOperation, chainId int64) (string, str
309280
"simulation_type": "validation_and_execution",
310281
},
311282
}
312-
case "zerodev":
313-
method = "zd_sendUserOperation"
314-
requestParams = []interface{}{
315-
chainId,
316-
userOp,
317-
orderConf.EntryPointContractAddress.Hex(),
318-
}
319283
case "pimlico":
284+
case "thirdweb":
320285
requestParams = []interface{}{
321286
userOp,
322287
orderConf.EntryPointContractAddress.Hex(),
@@ -631,8 +596,8 @@ func detectAAService(url string) (string, error) {
631596
return "biconomy", nil
632597
case strings.Contains(url, "api.pimlico.io"):
633598
return "pimlico", nil
634-
case strings.Contains(url, "rpc.zerodev.app"):
635-
return "zerodev", nil
599+
case strings.Contains(url, "thirdweb.com"):
600+
return "thirdweb", nil
636601
default:
637602
return "", fmt.Errorf("unsupported AA service URL pattern: %s", url)
638603
}

0 commit comments

Comments
 (0)