11using System ;
22using System . Collections . Generic ;
33using System . Threading . Tasks ;
4+ using UnityEngine ;
45using WalletConnect . Web3Modal . Http ;
56using WalletConnect . Web3Modal . Model . BlockchainApi ;
67using WalletConnectUnity . Core ;
@@ -11,6 +12,8 @@ public class BlockchainApiController
1112 {
1213 private const string BasePath = "https://rpc.walletconnect.org/v1/" ;
1314 private const int TimoutSeconds = 5 ;
15+
16+ private string _clientIdQueryParam ;
1417
1518 private readonly UnityHttpClient _httpClient = new ( new Uri ( BasePath ) , TimeSpan . FromSeconds ( TimoutSeconds ) ) ;
1619
@@ -22,7 +25,23 @@ public class BlockchainApiController
2225 public async Task < GetIdentityResponse > GetIdentityAsync ( string address )
2326 {
2427 var projectId = ProjectConfiguration . Load ( ) . Id ;
25- return await _httpClient . GetAsync < GetIdentityResponse > ( $ "identity/{ address } ?projectId={ projectId } ") ;
28+ var path = $ "identity/{ address } ?projectId={ projectId } ";
29+
30+ if ( string . IsNullOrWhiteSpace ( _clientIdQueryParam ) )
31+ {
32+ var wc = WalletConnectConnector . WalletConnectInstance ;
33+ if ( wc is { IsInitialized : true } )
34+ {
35+ var rawClientId = await wc . SignClient . Core . Crypto . GetClientId ( ) ;
36+ _clientIdQueryParam = $ "&clientId={ Uri . EscapeDataString ( rawClientId ) } ";
37+ }
38+ }
39+
40+ if ( ! string . IsNullOrWhiteSpace ( _clientIdQueryParam ) )
41+ path += _clientIdQueryParam ;
42+
43+ Debug . Log ( $ "Send identity request to { path } ") ;
44+ return await _httpClient . GetAsync < GetIdentityResponse > ( path ) ;
2645 }
2746
2847 public async Task < GetBalanceResponse > GetBalanceAsync ( string address )
0 commit comments