Skip to content

Commit d8a5199

Browse files
committed
OTP v2 Flow, IAW SIWE Login, ERC20Paymaster Interface
1 parent 75c36cb commit d8a5199

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed
-25 KB
Binary file not shown.

Assets/Thirdweb/Runtime/Unity/ThirdwebManager.cs

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,16 @@ public class InAppWalletOptions
2323
public string JwtOrPayload;
2424
public string EncryptionKey;
2525
public string StorageDirectoryPath;
26+
public IThirdwebWallet SiweSigner;
2627

2728
public InAppWalletOptions(
2829
string email = null,
2930
string phoneNumber = null,
3031
AuthProvider authprovider = AuthProvider.Default,
3132
string jwtOrPayload = null,
3233
string encryptionKey = null,
33-
string storageDirectoryPath = null
34+
string storageDirectoryPath = null,
35+
IThirdwebWallet siweSigner = null
3436
)
3537
{
3638
Email = email;
@@ -39,6 +41,7 @@ public InAppWalletOptions(
3941
JwtOrPayload = jwtOrPayload;
4042
EncryptionKey = encryptionKey;
4143
StorageDirectoryPath = storageDirectoryPath ?? Application.persistentDataPath;
44+
SiweSigner = siweSigner;
4245
}
4346
}
4447

@@ -50,15 +53,28 @@ public class SmartWalletOptions
5053
public string EntryPoint;
5154
public string BundlerUrl;
5255
public string PaymasterUrl;
53-
54-
public SmartWalletOptions(bool sponsorGas, string factoryAddress = null, string accountAddressOverride = null, string entryPoint = null, string bundlerUrl = null, string paymasterUrl = null)
56+
public string ERC20PaymasterAddress;
57+
public string ERC20PaymasterToken;
58+
59+
public SmartWalletOptions(
60+
bool sponsorGas,
61+
string factoryAddress = null,
62+
string accountAddressOverride = null,
63+
string entryPoint = null,
64+
string bundlerUrl = null,
65+
string paymasterUrl = null,
66+
string erc20PaymasterAddress = null,
67+
string erc20PaymasterToken = null
68+
)
5569
{
5670
SponsorGas = sponsorGas;
5771
FactoryAddress = factoryAddress;
5872
AccountAddressOverride = accountAddressOverride;
5973
EntryPoint = entryPoint;
6074
BundlerUrl = bundlerUrl;
6175
PaymasterUrl = paymasterUrl;
76+
ERC20PaymasterAddress = erc20PaymasterAddress;
77+
ERC20PaymasterToken = erc20PaymasterToken;
6278
}
6379
}
6480

@@ -259,6 +275,11 @@ public async Task<IThirdwebWallet> ConnectWallet(WalletOptions walletOptions)
259275
await inAppWallet.SendOTP();
260276
_ = await InAppWalletModal.VerifyOTP(inAppWallet);
261277
}
278+
else if (walletOptions.InAppWalletOptions.AuthProvider == AuthProvider.Siwe)
279+
{
280+
var siweSigner = walletOptions.InAppWalletOptions.SiweSigner;
281+
_ = await inAppWallet.LoginWithSiwe(siweSigner, walletOptions.ChainId);
282+
}
262283
else
263284
{
264285
_ = await inAppWallet.LoginWithOauth(
@@ -324,7 +345,9 @@ public async Task<SmartWallet> UpgradeToSmartWallet(IThirdwebWallet personalWall
324345
accountAddressOverride: smartWalletOptions.AccountAddressOverride,
325346
entryPoint: smartWalletOptions.EntryPoint,
326347
bundlerUrl: smartWalletOptions.BundlerUrl,
327-
paymasterUrl: smartWalletOptions.PaymasterUrl
348+
paymasterUrl: smartWalletOptions.PaymasterUrl,
349+
erc20PaymasterAddress: smartWalletOptions.ERC20PaymasterAddress,
350+
erc20PaymasterToken: smartWalletOptions.ERC20PaymasterToken
328351
);
329352

330353
await AddWallet(wallet);

0 commit comments

Comments
 (0)