4
4
5
5
namespace Thirdweb ;
6
6
7
+ public enum ExecutionMode
8
+ {
9
+ EOA ,
10
+ EIP7702 ,
11
+ EIP7702Sponsored
12
+ }
13
+
7
14
/// <summary>
8
15
/// Represents a 7702 delegated wallet with granular session key permissions and automatic session key execution.
9
16
/// </summary>
@@ -17,27 +24,29 @@ public class ThirdwebWallet : IThirdwebWallet
17
24
internal IThirdwebWallet UserWallet { get ; }
18
25
internal ThirdwebContract UserContract { get ; }
19
26
internal BigInteger ChainId { get ; }
20
- internal bool ManagedExecution { get ; }
27
+ internal ExecutionMode ExecutionMode { get ; }
21
28
22
29
private EIP7702Authorization ? Authorization { get ; set ; }
23
30
24
- internal ThirdwebWallet ( ThirdwebClient client , BigInteger chainId , IThirdwebWallet userWallet , ThirdwebContract userContract , EIP7702Authorization ? authorization , bool managedExecution )
31
+ internal ThirdwebWallet ( ThirdwebClient client , BigInteger chainId , IThirdwebWallet userWallet , ThirdwebContract userContract , EIP7702Authorization ? authorization , ExecutionMode executionMode )
25
32
{
26
33
this . Client = client ;
27
34
this . ChainId = chainId ;
28
35
this . UserWallet = userWallet ;
29
36
this . UserContract = userContract ;
30
37
this . Authorization = authorization ;
31
- this . ManagedExecution = managedExecution ;
38
+ this . ExecutionMode = executionMode ;
32
39
}
33
40
34
- public static async Task < ThirdwebWallet > Create ( ThirdwebClient client , BigInteger chainId , IThirdwebWallet userWallet , bool managedExecution )
41
+ public static async Task < ThirdwebWallet > Create ( ThirdwebClient client , BigInteger chainId , IThirdwebWallet userWallet , ExecutionMode executionMode )
35
42
{
36
43
var userWalletAddress = await userWallet . GetAddress ( ) ;
37
44
var userContract = await ThirdwebContract . Create ( client , userWalletAddress , chainId , Constants . MINIMAL_ACCOUNT_7702_ABI ) ;
38
45
var needsDelegation = ! await Utils . IsDelegatedAccount ( client , chainId , userWalletAddress ) ;
39
- EIP7702Authorization ? authorization = needsDelegation ? await userWallet . SignAuthorization ( chainId , Constants . MINIMAL_ACCOUNT_7702 , willSelfExecute : ! managedExecution ) : null ;
40
- var wallet = new ThirdwebWallet ( client , chainId , userWallet , userContract , authorization , managedExecution ) ;
46
+ EIP7702Authorization ? authorization = needsDelegation
47
+ ? await userWallet . SignAuthorization ( chainId , Constants . MINIMAL_ACCOUNT_7702 , willSelfExecute : executionMode != ExecutionMode . EIP7702Sponsored )
48
+ : null ;
49
+ var wallet = new ThirdwebWallet ( client , chainId , userWallet , userContract , authorization , executionMode ) ;
41
50
Utils . TrackConnection ( wallet ) ;
42
51
return wallet ;
43
52
}
@@ -122,16 +131,16 @@ public Task<string> SignTransaction(ThirdwebTransactionInput transaction)
122
131
public async Task < string > SendTransaction ( ThirdwebTransactionInput transaction )
123
132
{
124
133
// TODO: managed execution - executeWithSig
125
- if ( this . ManagedExecution )
134
+ if ( this . ExecutionMode == ExecutionMode . EIP7702Sponsored )
126
135
{
127
- throw new NotImplementedException ( "Managed execution is not yet implemented." ) ;
136
+ throw new NotImplementedException ( "EIP7702 Sponsored Execution mode is not yet implemented." ) ;
128
137
129
138
// 1. Create payload with eoa address, wrapped calls, signature and optional authorizationList
130
139
// 2. Send to https://{chainId}.bundler.thirdweb.com as RpcRequest w/ method tw_execute
131
140
// 3. Retrieve tx hash or queue id from response
132
141
// 4. Return tx hash
133
142
}
134
- else
143
+ else if ( this . ExecutionMode == ExecutionMode . EIP7702 )
135
144
{
136
145
var calls = new List < Call >
137
146
{
@@ -165,6 +174,10 @@ public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
165
174
166
175
return await ThirdwebTransaction . Send ( tx ) ;
167
176
}
177
+ else
178
+ {
179
+ return await this . UserWallet . SendTransaction ( transaction ) ;
180
+ }
168
181
}
169
182
170
183
public async Task < ThirdwebTransactionReceipt > ExecuteTransaction ( ThirdwebTransactionInput transaction )
0 commit comments