Skip to content

Commit cda06d2

Browse files
authored
Merge pull request #17 from WalletConnect/chore/client-id-rpc
chore: add clientId to BlockchainAPI requests
2 parents 7ee3220 + 00b64a4 commit cda06d2

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

Packages/com.walletconnect.web3modal/Runtime/Controllers/BlockchainApiController.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
4+
using UnityEngine;
45
using WalletConnect.Web3Modal.Http;
56
using WalletConnect.Web3Modal.Model.BlockchainApi;
67
using 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,22 @@ 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+
return await _httpClient.GetAsync<GetIdentityResponse>(path);
2644
}
2745

2846
public async Task<GetBalanceResponse> GetBalanceAsync(string address)

0 commit comments

Comments
 (0)