File tree Expand file tree Collapse file tree 4 files changed +86
-2
lines changed
Thirdweb/Thirdweb.Wallets
InAppWallet/EcosystemWallet Expand file tree Collapse file tree 4 files changed +86
-2
lines changed Original file line number Diff line number Diff line change 9191
9292#endregion
9393
94+ #region Smart Ecosystem Wallet
95+
96+ var eco = await EcosystemWallet . Create ( client : client , ecosystemId : "ecosystem.the-bonfire" , authProvider : AuthProvider . Telegram ) ;
97+ if ( ! await eco . IsConnected ( ) )
98+ {
99+ _ = await eco . LoginWithOauth (
100+ isMobile : false ,
101+ browserOpenAction : ( url ) =>
102+ {
103+ var psi = new ProcessStartInfo { FileName = url , UseShellExecute = true } ;
104+ _ = Process . Start ( psi ) ;
105+ }
106+ ) ;
107+ }
108+ var smartEco = await SmartWallet . Create ( eco , 421614 ) ;
109+ var addy = await smartEco . GetAddress ( ) ;
110+ Console . WriteLine ( $ "Smart Ecosystem Wallet address: { addy } ") ;
111+
112+ #endregion
113+
94114#region Ecosystem Wallet
95115
96116// var ecosystemWallet = await EcosystemWallet.Create(client: client, ecosystemId: "ecosystem.the-bonfire", authProvider: AuthProvider.Telegram);
Original file line number Diff line number Diff line change 1+ using System . Numerics ;
12using Newtonsoft . Json ;
23
34namespace Thirdweb ;
@@ -54,4 +55,40 @@ internal class EnclaveSignResponse
5455 [ JsonProperty ( "hash" ) ]
5556 internal string Hash { get ; set ; }
5657 }
58+
59+ public class EcosystemDetails
60+ {
61+ [ JsonProperty ( "thirdwebAccountId" ) ]
62+ public string ThirdwebAccountId { get ; set ; }
63+
64+ [ JsonProperty ( "permission" ) ]
65+ public string Permission { get ; set ; }
66+
67+ [ JsonProperty ( "authOptions" ) ]
68+ public List < string > AuthOptions { get ; set ; }
69+
70+ [ JsonProperty ( "name" ) ]
71+ public string Name { get ; set ; }
72+
73+ [ JsonProperty ( "slug" ) ]
74+ public string Slug { get ; set ; }
75+
76+ [ JsonProperty ( "imageUrl" ) ]
77+ public string ImageUrl { get ; set ; }
78+
79+ [ JsonProperty ( "smartAccountOptions" ) ]
80+ public EcosystemDetails_SmartAccountOptions ? SmartAccountOptions { get ; set ; }
81+ }
82+
83+ public struct EcosystemDetails_SmartAccountOptions
84+ {
85+ [ JsonProperty ( "chainIds" ) ]
86+ public List < BigInteger > ChainIds { get ; set ; }
87+
88+ [ JsonProperty ( "sponsorGas" ) ]
89+ public bool SponsorGas { get ; set ; }
90+
91+ [ JsonProperty ( "accountFactoryAddress" ) ]
92+ public string AccountFactoryAddress { get ; set ; }
93+ }
5794}
Original file line number Diff line number Diff line change @@ -264,6 +264,15 @@ public string GetPhoneNumber()
264264 return this . _phoneNumber ;
265265 }
266266
267+ public async Task < EcosystemDetails > GetEcosystemDetails ( )
268+ {
269+ var url = $ "{ EMBEDDED_WALLET_PATH_2024 } /ecosystem-wallet";
270+ var response = await this . _httpClient . GetAsync ( url ) . ConfigureAwait ( false ) ;
271+ _ = response . EnsureSuccessStatusCode ( ) ;
272+ var content = await response . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
273+ return JsonConvert . DeserializeObject < EcosystemDetails > ( content ) ;
274+ }
275+
267276 #endregion
268277
269278 #region Account Linking
Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ BigInteger erc20PaymasterStorageSlot
123123 public static async Task < SmartWallet > Create (
124124 IThirdwebWallet personalWallet ,
125125 BigInteger chainId ,
126- bool gasless = true ,
126+ bool ? gasless = null ,
127127 string factoryAddress = null ,
128128 string accountAddressOverride = null ,
129129 string entryPoint = null ,
@@ -137,10 +137,28 @@ public static async Task<SmartWallet> Create(
137137 throw new InvalidOperationException ( "SmartAccount.Connect: Personal account must be connected." ) ;
138138 }
139139
140+ if ( personalWallet is EcosystemWallet ecoWallet )
141+ {
142+ try
143+ {
144+ var ecoDetails = await ecoWallet . GetEcosystemDetails ( ) ;
145+ if ( ecoDetails . SmartAccountOptions . HasValue )
146+ {
147+ gasless ??= ecoDetails . SmartAccountOptions ? . SponsorGas ;
148+ factoryAddress ??= string . IsNullOrEmpty ( ecoDetails . SmartAccountOptions ? . AccountFactoryAddress ) ? null : ecoDetails . SmartAccountOptions ? . AccountFactoryAddress ;
149+ }
150+ }
151+ catch
152+ {
153+ // no-op
154+ }
155+ }
156+
140157 entryPoint ??= Constants . ENTRYPOINT_ADDRESS_V06 ;
141158
142159 var entryPointVersion = Utils . GetEntryPointVersion ( entryPoint ) ;
143160
161+ gasless ??= true ;
144162 bundlerUrl ??= $ "https://{ chainId } .bundler.thirdweb.com/v2";
145163 paymasterUrl ??= $ "https://{ chainId } .bundler.thirdweb.com/v2";
146164 factoryAddress ??= entryPointVersion == 6 ? Constants . DEFAULT_FACTORY_ADDRESS_V06 : Constants . DEFAULT_FACTORY_ADDRESS_V07 ;
@@ -180,7 +198,7 @@ public static async Task<SmartWallet> Create(
180198
181199 return new SmartWallet (
182200 personalWallet ,
183- gasless ,
201+ gasless . Value ,
184202 chainId ,
185203 bundlerUrl ,
186204 paymasterUrl ,
You can’t perform that action at this time.
0 commit comments