-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Managed ZkSync Paymaster * cleanup * Working example * Update BundlerClient.cs * Support normal tx flow w/ sw zk aa * Update SmartWallet.cs * Broadcast from engine * fix tests * Fix RLP indirection
- Loading branch information
1 parent
fa39694
commit 4c74bee
Showing
8 changed files
with
339 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
var privateKeyWallet = await PrivateKeyWallet.Create(client: client, privateKeyHex: privateKey); | ||
|
||
// var inAppWallet = await InAppWallet.Create(client: client, email: "[email protected]"); // or email: null, phoneNumber: "+1234567890" | ||
var inAppWallet = await InAppWallet.Create(client: client, authprovider: AuthProvider.Google); // or email: null, phoneNumber: "+1234567890" | ||
// var inAppWallet = await InAppWallet.Create(client: client, authprovider: AuthProvider.Google); // or email: null, phoneNumber: "+1234567890" | ||
|
||
// Reset InAppWallet (optional step for testing login flow) | ||
// if (await inAppWallet.IsConnected()) | ||
|
@@ -34,62 +34,68 @@ | |
// } | ||
|
||
// Relog if InAppWallet not logged in | ||
if (!await inAppWallet.IsConnected()) | ||
{ | ||
var address = await inAppWallet.LoginWithOauth( | ||
isMobile: false, | ||
(url) => | ||
{ | ||
var psi = new ProcessStartInfo { FileName = url, UseShellExecute = true }; | ||
_ = Process.Start(psi); | ||
}, | ||
"thirdweb://", | ||
new InAppWalletBrowser() | ||
); | ||
Console.WriteLine($"InAppWallet address: {address}"); | ||
// await inAppWallet.SendOTP(); | ||
// Console.WriteLine("Please submit the OTP."); | ||
// var otp = Console.ReadLine(); | ||
// (var inAppWalletAddress, var canRetry) = await inAppWallet.SubmitOTP(otp); | ||
// if (inAppWalletAddress == null && canRetry) | ||
// { | ||
// Console.WriteLine("Please submit the OTP again."); | ||
// otp = Console.ReadLine(); | ||
// (inAppWalletAddress, _) = await inAppWallet.SubmitOTP(otp); | ||
// } | ||
// if (inAppWalletAddress == null) | ||
// { | ||
// Console.WriteLine("OTP login failed. Please try again."); | ||
// return; | ||
// } | ||
} | ||
// if (!await inAppWallet.IsConnected()) | ||
// { | ||
// var address = await inAppWallet.LoginWithOauth( | ||
// isMobile: false, | ||
// (url) => | ||
// { | ||
// var psi = new ProcessStartInfo { FileName = url, UseShellExecute = true }; | ||
// _ = Process.Start(psi); | ||
// }, | ||
// "thirdweb://", | ||
// new InAppWalletBrowser() | ||
// ); | ||
// Console.WriteLine($"InAppWallet address: {address}"); | ||
// await inAppWallet.SendOTP(); | ||
// Console.WriteLine("Please submit the OTP."); | ||
// var otp = Console.ReadLine(); | ||
// (var inAppWalletAddress, var canRetry) = await inAppWallet.SubmitOTP(otp); | ||
// if (inAppWalletAddress == null && canRetry) | ||
// { | ||
// Console.WriteLine("Please submit the OTP again."); | ||
// otp = Console.ReadLine(); | ||
// (inAppWalletAddress, _) = await inAppWallet.SubmitOTP(otp); | ||
// } | ||
// if (inAppWalletAddress == null) | ||
// { | ||
// Console.WriteLine("OTP login failed. Please try again."); | ||
// return; | ||
// } | ||
// } | ||
|
||
// Prepare a transaction directly, or with Contract.Prepare | ||
var tx = await ThirdwebTransaction.Create( | ||
client: client, | ||
wallet: privateKeyWallet, | ||
txInput: new ThirdwebTransactionInput() | ||
{ | ||
From = await privateKeyWallet.GetAddress(), | ||
To = await privateKeyWallet.GetAddress(), | ||
Value = new HexBigInteger(BigInteger.Zero), | ||
}, | ||
chainId: 300 | ||
); | ||
|
||
// Set zkSync options | ||
tx.SetZkSyncOptions( | ||
new ZkSyncOptions( | ||
// Paymaster contract address | ||
paymaster: "0xbA226d47Cbb2731CBAA67C916c57d68484AA269F", | ||
// IPaymasterFlow interface encoded data | ||
paymasterInput: "0x8c5a344500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000" | ||
) | ||
); | ||
|
||
// Send as usual, it's now gasless! | ||
var txHash = await ThirdwebTransaction.Send(transaction: tx); | ||
Console.WriteLine($"Transaction hash: {txHash}"); | ||
// var tx = await ThirdwebTransaction.Create( | ||
// client: client, | ||
// wallet: privateKeyWallet, | ||
// txInput: new ThirdwebTransactionInput() | ||
// { | ||
// From = await privateKeyWallet.GetAddress(), | ||
// To = await privateKeyWallet.GetAddress(), | ||
// Value = new HexBigInteger(BigInteger.Zero), | ||
// }, | ||
// chainId: 300 | ||
// ); | ||
|
||
// // Set zkSync options | ||
// tx.SetZkSyncOptions( | ||
// new ZkSyncOptions( | ||
// // Paymaster contract address | ||
// paymaster: "0xbA226d47Cbb2731CBAA67C916c57d68484AA269F", | ||
// // IPaymasterFlow interface encoded data | ||
// paymasterInput: "0x8c5a344500000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000" | ||
// ) | ||
// ); | ||
|
||
// // Send as usual, it's now gasless! | ||
// var txHash = await ThirdwebTransaction.Send(transaction: tx); | ||
// Console.WriteLine($"Transaction hash: {txHash}"); | ||
|
||
var zkSmartWallet = await SmartWallet.Create(client: client, personalWallet: privateKeyWallet, chainId: 324, gasless: true); | ||
Console.WriteLine($"Smart wallet address: {await zkSmartWallet.GetAddress()}"); | ||
var zkAaTx = await ThirdwebTransaction.Create(client, zkSmartWallet, new ThirdwebTransactionInput() { From = await zkSmartWallet.GetAddress(), To = await zkSmartWallet.GetAddress(), }, 324); | ||
var zkSyncSignatureBasedAaTxHash = await ThirdwebTransaction.Send(zkAaTx); | ||
Console.WriteLine($"Transaction hash: {zkSyncSignatureBasedAaTxHash}"); | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.