@@ -39,6 +39,7 @@ public partial class EcosystemWallet : IThirdwebWallet
3939
4040 internal string Address ;
4141 internal ExecutionMode ExecutionMode ;
42+ internal string DelegationContractAddress ;
4243
4344 private readonly string _ecosystemId ;
4445 private readonly string _ecosystemPartnerId ;
@@ -60,7 +61,8 @@ internal EcosystemWallet(
6061 IThirdwebWallet siweSigner ,
6162 string legacyEncryptionKey ,
6263 string walletSecret ,
63- ExecutionMode executionMode
64+ ExecutionMode executionMode ,
65+ string delegationContractAddress
6466 )
6567 {
6668 this . Client = client ;
@@ -76,7 +78,7 @@ ExecutionMode executionMode
7678 this . WalletSecret = walletSecret ;
7779 this . ExecutionMode = executionMode ;
7880 this . AccountType = executionMode == ExecutionMode . EOA ? ThirdwebAccountType . PrivateKeyAccount : ThirdwebAccountType . ExternalAccount ;
79- ;
81+ this . DelegationContractAddress = delegationContractAddress ;
8082 }
8183
8284 #region Creation
@@ -118,6 +120,8 @@ public static async Task<EcosystemWallet> Create(
118120 throw new ArgumentNullException ( nameof ( client ) , "Client cannot be null." ) ;
119121 }
120122
123+ var delegationContractResponse = await BundlerClient . TwGetDelegationContract ( client : client , url : $ "https://1.bundler.thirdweb.com", requestId : 7702 ) ;
124+
121125 if ( string . IsNullOrEmpty ( email ) && string . IsNullOrEmpty ( phoneNumber ) && authProvider == Thirdweb . AuthProvider . Default )
122126 {
123127 throw new ArgumentException ( "Email, Phone Number, or OAuth Provider must be provided to login." ) ;
@@ -193,7 +197,8 @@ public static async Task<EcosystemWallet> Create(
193197 siweSigner ,
194198 legacyEncryptionKey ,
195199 walletSecret ,
196- executionMode
200+ executionMode ,
201+ delegationContractResponse . DelegationContract
197202 )
198203 {
199204 Address = userAddress ,
@@ -214,7 +219,8 @@ public static async Task<EcosystemWallet> Create(
214219 siweSigner ,
215220 legacyEncryptionKey ,
216221 walletSecret ,
217- executionMode
222+ executionMode ,
223+ delegationContractResponse . DelegationContract
218224 )
219225 {
220226 Address = null ,
@@ -1294,9 +1300,9 @@ public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
12941300 {
12951301 var userWalletAddress = await this . GetAddress ( ) ;
12961302 var userContract = await ThirdwebContract . Create ( this . Client , userWalletAddress , transaction . ChainId , Constants . MINIMAL_ACCOUNT_7702_ABI ) ;
1297- var needsDelegation = ! await Utils . IsDelegatedAccount ( this . Client , transaction . ChainId , userWalletAddress ) ;
1303+ var needsDelegation = ! await Utils . IsDelegatedAccount ( this . Client , transaction . ChainId , userWalletAddress , this . DelegationContractAddress ) ;
12981304 EIP7702Authorization ? authorization = needsDelegation
1299- ? await this . SignAuthorization ( transaction . ChainId , Constants . MINIMAL_ACCOUNT_7702 , willSelfExecute : this . ExecutionMode != ExecutionMode . EIP7702Sponsored )
1305+ ? await this . SignAuthorization ( transaction . ChainId , this . DelegationContractAddress , willSelfExecute : this . ExecutionMode != ExecutionMode . EIP7702Sponsored )
13001306 : null ;
13011307
13021308 var calls = new List < Call >
@@ -1337,7 +1343,7 @@ public async Task<string> SendTransaction(ThirdwebTransactionInput transaction)
13371343 eoaAddress : userWalletAddress ,
13381344 wrappedCalls : wrappedCalls ,
13391345 signature : signature ,
1340- authorization : authorization != null && ! await Utils . IsDelegatedAccount ( this . Client , transaction . ChainId , userWalletAddress ) ? authorization : null
1346+ authorization : authorization != null && ! await Utils . IsDelegatedAccount ( this . Client , transaction . ChainId , userWalletAddress , this . DelegationContractAddress ) ? authorization : null
13411347 ) ;
13421348 var queueId = response ? . QueueId ;
13431349 string txHash = null ;
@@ -1473,7 +1479,7 @@ private async Task Ensure7702(BigInteger chainId, bool ensureDelegated)
14731479 throw new InvalidOperationException ( "This operation is only supported for EIP7702 and EIP7702Sponsored execution modes." ) ;
14741480 }
14751481
1476- if ( ! await Utils . IsDelegatedAccount ( this . Client , chainId , this . Address ) . ConfigureAwait ( false ) )
1482+ if ( ! await Utils . IsDelegatedAccount ( this . Client , chainId , this . Address , this . DelegationContractAddress ) . ConfigureAwait ( false ) )
14771483 {
14781484 if ( ensureDelegated )
14791485 {
0 commit comments