-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathDecentralandUrlsSource.cs
More file actions
389 lines (331 loc) · 23.6 KB
/
Copy pathDecentralandUrlsSource.cs
File metadata and controls
389 lines (331 loc) · 23.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
using DCL.Diagnostics;
using DCL.FeatureFlags;
using DCL.Multiplayer.Connections.DecentralandUrls;
using DCL.Utility;
using ECS;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.Pool;
// ReSharper disable once CheckNamespace
namespace DCL.Browser.DecentralandUrls
{
public class DecentralandUrlsSource : IDecentralandUrlsSource
{
protected enum CacheBehaviour
{
/// <summary>
/// URL is static and can be safely cached
/// </summary>
Static = 0,
/// <summary>
/// URL should be invalidated upon realm change
/// </summary>
RealmDependent = 1,
/// <summary>
/// URL can't be cached if FF are not yet configured
/// </summary>
FeatureFlagsDependent = 2,
}
protected const string ENV = "{ENV}";
private const string SCENE_ADAPTER_PATH = "/get-scene-adapter";
private static readonly string FEATURE_FLAGS_RAW_URL = $"https://feature-flags.decentraland.{ENV}";
private readonly Dictionary<DecentralandUrl, UrlData> cache = new ();
private readonly IRealmData realmData;
private readonly ILaunchMode launchMode;
private readonly string decentralandDomain;
private readonly string? gatekeeperBaseOverride;
private string? optimizedAssetsBaseOverride;
private readonly bool isTodayEnvironment;
public DecentralandUrlsSource(
DecentralandEnvironment environment,
IRealmData realmData,
ILaunchMode launchMode,
GatekeeperMode gatekeeperMode = GatekeeperMode.Org,
string customGatekeeperUrl = "",
string? cliGatekeeperUrl = null,
string? cliOptimizedAssetsUrl = null)
{
decentralandDomain = environment.ToString()!.ToLower();
isTodayEnvironment = environment == DecentralandEnvironment.Today;
this.realmData = realmData;
this.launchMode = launchMode;
gatekeeperBaseOverride = ResolveGatekeeperOverride(gatekeeperMode, customGatekeeperUrl, cliGatekeeperUrl, out string source);
ReportHub.Log(ReportCategory.STARTUP, $"Gatekeeper base override: {gatekeeperBaseOverride ?? "(default)"} (source: {source})");
optimizedAssetsBaseOverride = cliOptimizedAssetsUrl?.TrimEnd('/');
if (isTodayEnvironment)
{
// The today environment is a mixture of the org and today environments.
// Asset delivery (registry and S3) are used with the `.today` extension
// Adapter info (both scene and room) also have to responde to the `.today` environment
// Archipelago status as well, to have a clear minimap
// All the remaining urls should use the `Org` domain, that's why we change the domain to forcefully `.org`
// It's a catalyst that replicates the org environment and eth network, but doesn't propagate back to the production catalysts
Url(DecentralandUrl.AssetBundleRegistry);
Url(DecentralandUrl.AssetBundleRegistryVersion);
Url(DecentralandUrl.AssetBundlesCDN);
Url(DecentralandUrl.Profiles);
Url(DecentralandUrl.ProfilesMetadata);
Url(DecentralandUrl.EntitiesActive);
Url(DecentralandUrl.EntitiesActiveElements);
Url(DecentralandUrl.WorldEntitiesActive);
Url(DecentralandUrl.ArchipelagoStatus);
Url(DecentralandUrl.ArchipelagoHotScenes);
Url(DecentralandUrl.Genesis);
Url(DecentralandUrl.Gatekeeper);
Url(DecentralandUrl.GateKeeperSceneAdapter);
Url(DecentralandUrl.LocalGateKeeperSceneAdapter);
Url(DecentralandUrl.ChatAdapter);
Url(DecentralandUrl.GatekeeperStatus);
Url(DecentralandUrl.BannedUsers);
Url(DecentralandUrl.SceneAdmins);
Url(DecentralandUrl.RemotePeers);
decentralandDomain = nameof(DecentralandEnvironment.Org).ToLower();
}
realmData.RealmType.OnUpdate += ResetRealmDependentUrls;
}
private static string? ResolveGatekeeperOverride(GatekeeperMode mode, string customUrl, string? cliOverride, out string source)
{
if (!string.IsNullOrEmpty(cliOverride))
{
source = "CLI";
return cliOverride;
}
source = mode.ToString();
return mode switch
{
GatekeeperMode.Org => null,
GatekeeperMode.Zone => "https://comms-gatekeeper." + IDecentralandUrlsSource.ZONE_DOMAIN,
GatekeeperMode.Today => "https://comms-gatekeeper." + IDecentralandUrlsSource.TODAY_DOMAIN,
GatekeeperMode.Localhost => "http://localhost:3000",
GatekeeperMode.Custom => string.IsNullOrEmpty(customUrl) ? null : customUrl,
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, null),
};
}
/// <summary>
/// Creates a fully irrelevant stub
/// </summary>
public static DecentralandUrlsSource CreateForTest() =>
new (DecentralandEnvironment.Zone, new IRealmData.Fake(), ILaunchMode.PLAY);
public static DecentralandUrlsSource CreateForTest(DecentralandEnvironment environment, ILaunchMode launchMode) =>
new (environment, new IRealmData.Fake(), launchMode);
public string Probe(DecentralandUrl decentralandUrl)
{
if (cache.TryGetValue(decentralandUrl, out UrlData cached))
return cached.Url!;
UrlData rawUrl = RawUrl(decentralandUrl);
return Probe(rawUrl.ToString(), decentralandDomain);
}
private static string Probe(string rawUrl, string environment) =>
rawUrl.Replace(ENV, environment);
public string Url(DecentralandUrl decentralandUrl)
{
const string REALM_DEPENDENT = "<REALM_DEPENDENT>";
const string FEATURE_FLAG_DEPENDENT = "<FEATURE_FLAG_DEPENDENT>";
if (!cache.TryGetValue(decentralandUrl, out UrlData urlData))
{
urlData = RawUrl(decentralandUrl);
switch (urlData.Caching)
{
case CacheBehaviour.RealmDependent when !realmData.Configured:
return REALM_DEPENDENT;
case CacheBehaviour.FeatureFlagsDependent when FeatureFlagsConfiguration.Instance.IsEmpty:
return urlData.Url ?? FEATURE_FLAG_DEPENDENT;
default:
urlData = new UrlData(urlData.Caching, urlData.Url!.Replace(ENV, decentralandDomain));
cache[decentralandUrl] = urlData;
break;
}
}
return urlData.Url!;
}
public virtual string TransformUrl(string originalUrl) =>
originalUrl;
public virtual string GetOriginalUrl(string url) =>
url;
public string GetHostnameForFeatureFlag() =>
launchMode.CurrentMode switch
{
LaunchMode.Play => Url(DecentralandUrl.Host),
LaunchMode.LocalSceneDevelopment => "localhost", //TODO should this behaviour be extracted to Url() call?
_ => throw new ArgumentOutOfRangeException(),
};
private void ResetRealmDependentUrls(RealmKind realmKind)
{
using PooledObject<List<DecentralandUrl>> _ = ListPool<DecentralandUrl>.Get(out List<DecentralandUrl>? realmDependentCachedUrls);
realmDependentCachedUrls.AddRange(cache.Where(kvp => kvp.Value.Caching == CacheBehaviour.RealmDependent).Select(kvp => kvp.Key));
foreach (DecentralandUrl url in realmDependentCachedUrls)
cache.Remove(url);
}
/// <summary>
/// Drops the "--optimized-assets-url" override so every optimized-asset endpoint re-resolves to its
/// production host. Called when the local-ab abgen sidecar the override pointed at never came up, so the
/// session behaves as if local-ab were never requested instead of routing every scene, wearable, LOD and
/// registry-composed profile/entities-active request at a dead loopback port and recovering per request.
/// </summary>
public void ClearOptimizedAssetsOverride()
{
if (optimizedAssetsBaseOverride == null)
return;
optimizedAssetsBaseOverride = null;
// With the override present these all resolved as FeatureFlagsDependent (the registry-composed
// profile/entities endpoints inherit the registry base's caching), so evicting that class forces
// production re-resolution. Anything already flag-dependent for other reasons simply re-resolves
// to the same value.
using PooledObject<List<DecentralandUrl>> _ = ListPool<DecentralandUrl>.Get(out List<DecentralandUrl>? flagDependentCachedUrls);
flagDependentCachedUrls.AddRange(cache.Where(kvp => kvp.Value.Caching == CacheBehaviour.FeatureFlagsDependent).Select(kvp => kvp.Key));
foreach (DecentralandUrl url in flagDependentCachedUrls)
cache.Remove(url);
}
private string ResolveGatekeeperBaseUrl(string defaultBaseUrl) =>
gatekeeperBaseOverride ?? defaultBaseUrl;
/// <summary>
/// The "--optimized-assets-url" arg or the flag variant payload override the base url, otherwise
/// https://abcdn.decentraland.{ENV}. FeatureFlagsDependent means it is re-resolved (not cached) until flags load.
/// </summary>
private UrlData ResolveOptimizedAssetsUrl(string dedicatedHostUrl)
{
if (optimizedAssetsBaseOverride is { Length: > 0 })
return new UrlData(CacheBehaviour.FeatureFlagsDependent, optimizedAssetsBaseOverride);
FeatureFlagsConfiguration featureFlags = FeatureFlagsConfiguration.Instance;
if (featureFlags.IsEmpty)
return isTodayEnvironment
? dedicatedHostUrl // Static — pinned on construction before the domain switches to org
: new UrlData(CacheBehaviour.FeatureFlagsDependent, dedicatedHostUrl.Replace(ENV, decentralandDomain));
if (!featureFlags.IsEnabled(FeatureFlagsStrings.OPTIMIZED_ASSETS))
return dedicatedHostUrl;
if (featureFlags.TryGetTextPayload(FeatureFlagsStrings.OPTIMIZED_ASSETS, FeatureFlagsStrings.OPTIMIZED_ASSETS_BASE_URL_VARIANT, out string? customBaseUrl) && customBaseUrl is { Length: > 0 })
return new UrlData(CacheBehaviour.FeatureFlagsDependent, customBaseUrl.TrimEnd('/'));
return new UrlData(CacheBehaviour.FeatureFlagsDependent, $"https://abcdn.decentraland.{ENV}");
}
/// <summary>Registry-composed endpoints inherit the registry base's caching so a flag-driven base is not cached early.</summary>
private UrlData ComposeRegistryUrl(string path) =>
new (RawUrl(DecentralandUrl.AssetBundleRegistry).Caching, $"{Url(DecentralandUrl.AssetBundleRegistry)}{path}");
public static string GetFeatureFlagsUrl(DecentralandEnvironment env) =>
Probe(FEATURE_FLAGS_RAW_URL, env.ToString().ToLower());
protected virtual UrlData RawUrl(DecentralandUrl decentralandUrl) =>
decentralandUrl switch
{
DecentralandUrl.SupportLink => $"https://decentraland.{ENV}/help/",
DecentralandUrl.DiscordDirectLink => "https://discord.gg/decentraland",
DecentralandUrl.TwitterLink => "https://x.com/decentraland",
DecentralandUrl.TwitterNewPostLink => "https://twitter.com/intent/tweet?text={0}&hashtags={1}&url={2}",
DecentralandUrl.NewsletterSubscriptionLink => "https://decentraland.beehiiv.com/?utm_org=dcl&utm_source=client&utm_medium=organic&utm_campaign=marketplacecredits&utm_term=trialend",
DecentralandUrl.MarketplaceLink => $"https://decentraland.{ENV}/marketplace",
DecentralandUrl.ShopLink => $"https://decentraland.{ENV}/shop",
DecentralandUrl.MarketplaceServer => $"https://marketplace-api.decentraland.{ENV}",
DecentralandUrl.PrivacyPolicy => $"https://decentraland.{ENV}/privacy",
DecentralandUrl.TermsOfUse => $"https://decentraland.{ENV}/terms",
DecentralandUrl.ContentPolicy => $"https://decentraland.{ENV}/content",
DecentralandUrl.CodeOfEthics => $"https://decentraland.{ENV}/ethics",
DecentralandUrl.ApiPlaces => $"https://places.decentraland.{ENV}/api/places",
DecentralandUrl.ApiWorlds => $"https://places.decentraland.{ENV}/api/worlds",
DecentralandUrl.ApiDestinations => $"https://places.decentraland.{ENV}/api/destinations",
DecentralandUrl.ApiAuth => $"https://auth-api.decentraland.{ENV}",
DecentralandUrl.ApiRpc => $"wss://rpc.decentraland.{ENV}",
DecentralandUrl.MetaTransactionServer => $"https://transactions-api.decentraland.{ENV}/v1/transactions",
DecentralandUrl.AuthSignatureWebApp => $"https://decentraland.{ENV}/auth/requests",
DecentralandUrl.BuilderApiDtos => $"https://builder-api.decentraland.{ENV}/v1/collections/[COL-ID]/items",
DecentralandUrl.BuilderApiContent => $"https://builder-api.decentraland.{ENV}/v1/storage/contents/",
DecentralandUrl.BuilderApiNewsletter => $"https://builder-api.decentraland.{ENV}/v1/newsletter",
DecentralandUrl.POI => $"https://dcl-lists.decentraland.{ENV}/pois",
DecentralandUrl.Map => $"https://places.decentraland.{ENV}/api/map",
DecentralandUrl.ContentModerationReport => $"https://places.decentraland.{ENV}/api/report",
DecentralandUrl.Gatekeeper => ResolveGatekeeperBaseUrl($"https://comms-gatekeeper.decentraland.{ENV}"),
DecentralandUrl.GateKeeperSceneAdapter => $"{RawUrl(DecentralandUrl.Gatekeeper).Url!}{SCENE_ADAPTER_PATH}",
DecentralandUrl.LocalGateKeeperSceneAdapter => $"{ResolveGatekeeperBaseUrl("https://comms-gatekeeper-local." + IDecentralandUrlsSource.ORG_DOMAIN)}{SCENE_ADAPTER_PATH}",
DecentralandUrl.ChatAdapter => $"{RawUrl(DecentralandUrl.Gatekeeper).Url!}/private-messages/token",
DecentralandUrl.ApiEvents => $"https://events.decentraland.{ENV}/api/events",
DecentralandUrl.WhatsOnNewEventLink => $"https://decentraland.{ENV}/whats-on/new-event",
DecentralandUrl.WhatsOnEventLink => $"https://decentraland.{ENV}/whats-on/?id={{0}}",
DecentralandUrl.OpenSea => $"https://opensea.decentraland.{ENV}",
DecentralandUrl.Host => $"https://decentraland.{ENV}",
DecentralandUrl.ApiChunks => $"https://api.decentraland.{ENV}/v1/map.png",
DecentralandUrl.PeerAbout => $"https://peer.decentraland.{ENV}/about",
DecentralandUrl.PeerContent => $"https://peer.decentraland.{ENV}/content/contents",
DecentralandUrl.RemotePeers => $"https://archipelago-ea-stats.decentraland.{ENV}/comms/peers",
DecentralandUrl.RemotePeersWorld => $"https://worlds-content-server.decentraland.{ENV}/wallet/[USER-ID]/connected-world",
DecentralandUrl.DAO => $"https://decentraland.{ENV}/dao/",
DecentralandUrl.FeatureFlags => FEATURE_FLAGS_RAW_URL,
DecentralandUrl.Help => $"https://decentraland.{ENV}/help/",
DecentralandUrl.Faqs => $"https://docs.decentraland.{ENV}/faqs/decentraland-101",
DecentralandUrl.Discord => $"https://decentraland.{ENV}/discord/",
DecentralandUrl.Account => $"https://decentraland.{ENV}/account/",
DecentralandUrl.MinimumSpecs => $"https://docs.decentraland.{ENV}/player/FAQs/decentraland-101/#what-hardware-do-i-need-to-run-decentraland",
DecentralandUrl.Market => $"https://market.decentraland.{ENV}",
DecentralandUrl.AssetBundlesCDN => ResolveOptimizedAssetsUrl($"https://ab-cdn.decentraland.{ENV}"),
DecentralandUrl.LodGeneratorCDN => ResolveOptimizedAssetsUrl($"https://lod-generator-unity-cdn.decentraland.{ENV}"),
DecentralandUrl.ArchipelagoStatus => $"https://archipelago-ea-stats.decentraland.{ENV}/status",
DecentralandUrl.ArchipelagoHotScenes => $"https://archipelago-ea-stats.decentraland.{ENV}/hot-scenes",
DecentralandUrl.GatekeeperStatus => $"{RawUrl(DecentralandUrl.Gatekeeper).Url!}/status",
DecentralandUrl.Genesis => $"https://realm-provider-ea.decentraland.{ENV}/main",
DecentralandUrl.Badges => $"https://badges.decentraland.{ENV}",
DecentralandUrl.CameraReelUsers => $"https://camera-reel-service.decentraland.{ENV}/api/users",
DecentralandUrl.CameraReelImages => $"https://camera-reel-service.decentraland.{ENV}/api/images",
DecentralandUrl.CameraReelPlaces => $"https://camera-reel-service.decentraland.{ENV}/api/places",
DecentralandUrl.CameraReelLink => $"https://reels.decentraland.{ENV}",
DecentralandUrl.Blocklist => $"https://config.decentraland.{ENV}/denylist.json",
DecentralandUrl.ApiFriends => $"wss://rpc-social-service-ea.decentraland.{ENV}",
DecentralandUrl.AssetBundleRegistry => ResolveOptimizedAssetsUrl($"https://asset-bundle-registry.decentraland.{ENV}"),
DecentralandUrl.AssetBundleRegistryVersion => ComposeRegistryUrl("/entities/versions"),
DecentralandUrl.MarketplaceClaimName => $"https://decentraland.{ENV}/marketplace/names/claim",
DecentralandUrl.WorldPermissions => $"https://worlds-content-server.decentraland.{ENV}/world/{{0}}/permissions",
DecentralandUrl.WorldComms => $"https://worlds-content-server.decentraland.{ENV}/worlds/{{0}}/comms",
DecentralandUrl.WorldServer => $"https://worlds-content-server.decentraland.{ENV}/world",
DecentralandUrl.WorldContentServer => $"https://worlds-content-server.decentraland.{ENV}/contents/",
DecentralandUrl.Servers => $"https://peer.decentraland.{ENV}/lambdas/contracts/servers",
DecentralandUrl.MediaConverter => $"https://metamorph-api.decentraland.{ENV}/convert?url={{0}}",
DecentralandUrl.MarketplaceCredits => $"https://credits.decentraland.{ENV}",
DecentralandUrl.GoShoppingWithMarketplaceCredits => $"https://decentraland.{ENV}/marketplace/browse?sortBy=newest&status=on_sale&withCredits=true",
DecentralandUrl.Notifications => $"https://notifications.decentraland.{ENV}",
DecentralandUrl.Communities => $"https://social-api.decentraland.{ENV}/v1/communities",
DecentralandUrl.CommunitiesV2 => $"https://social-api.decentraland.{ENV}/v2/communities",
DecentralandUrl.CommunityThumbnail => $"https://assets-cdn.decentraland.{ENV}/social/communities/{{0}}/raw-thumbnail.png",
DecentralandUrl.Members => $"https://social-api.decentraland.{ENV}/v1/members",
DecentralandUrl.MembersV2 => $"https://social-api.decentraland.{ENV}/v2/members",
DecentralandUrl.CommunityProfileLink => $"https://decentraland.{ENV}/social/communities/{{0}}?utm_org=dcl&utm_source=explorer&utm_medium=organic&utm_campaign=communities",
DecentralandUrl.DecentralandWorlds => "https://decentraland.org/blog/about-decentraland/decentraland-worldsTake -your-own-virtual-space?utm_org=dcl&utm_source=explorer&utm_medium=organic",
DecentralandUrl.ChatTranslate => $"https://autotranslate-server.decentraland.{ENV}/translate",
DecentralandUrl.ActiveCommunityVoiceChats => $"https://social-api.decentraland.{ENV}/v1/community-voice-chats/active",
DecentralandUrl.Support => $"https://docs.decentraland.{ENV}/player/support/",
DecentralandUrl.CreatorHub => $"https://decentraland.{ENV}/create/",
DecentralandUrl.ManaUsdRateApiUrl => "https://api.coingecko.com/api/v3/simple/price?ids=decentraland&vs_currencies=usd",
DecentralandUrl.JumpInGenesisCityLink => $"https://decentraland.{ENV}/jump/?position={{0}},{{1}}",
DecentralandUrl.JumpInWorldLink => $"https://decentraland.{ENV}/jump/?realm={{0}}",
DecentralandUrl.ReportUserForm => $"https://decentraland.{ENV}/report/players?player_address={{0}}&reported_address={{1}}",
DecentralandUrl.BannedUsers => $"{RawUrl(DecentralandUrl.Gatekeeper).Url!}/users/{{0}}/bans",
DecentralandUrl.SceneAdmins => $"{RawUrl(DecentralandUrl.Gatekeeper).Url!}/scene-admin",
DecentralandUrl.Pulse => $"pulse-server.decentraland.{ENV}",
DecentralandUrl.Profiles => ComposeRegistryUrl("/profiles"),
DecentralandUrl.ProfilesMetadata => ComposeRegistryUrl("/profiles/metadata"),
DecentralandUrl.WorldCommsAdapter => $"https://worlds-content-server.decentraland.{ENV}/worlds/{{0}}/scenes/{{1}}/comms",
DecentralandUrl.EntitiesActive => UrlData.RealmDependent(FeatureFlagsConfiguration.Instance.IsEnabled(FeatureFlagsStrings.ASSET_BUNDLE_FALLBACK) && launchMode.CurrentMode != LaunchMode.LocalSceneDevelopment ? $"{Url(DecentralandUrl.AssetBundleRegistry)}/entities/active" :
realmData.Configured ? realmData.Ipfs.EntitiesActiveEndpoint.Value : null),
// Meant for Wearables and Emotes since they always must be solved by the AB-Registry
DecentralandUrl.EntitiesActiveElements => ComposeRegistryUrl("/entities/active"),
DecentralandUrl.WorldEntitiesActive => UrlData.RealmDependent(FeatureFlagsConfiguration.Instance.IsEnabled(FeatureFlagsStrings.ASSET_BUNDLE_FALLBACK) && launchMode.CurrentMode != LaunchMode.LocalSceneDevelopment ? $"{Url(DecentralandUrl.AssetBundleRegistry)}/entities/active?world_name={{0}}" :
realmData.Configured ? realmData.Ipfs.EntitiesActiveEndpoint.Value : null),
DecentralandUrl.EntitiesDeployment => UrlData.RealmDependent(realmData.Configured ? realmData.Ipfs.EntitiesBaseUrl.Value : null),
DecentralandUrl.Lambdas => UrlData.RealmDependent(realmData.Configured ? realmData.Ipfs.LambdasBaseUrl.Value : null),
DecentralandUrl.Content => UrlData.RealmDependent(realmData.Configured ? realmData.Ipfs.ContentBaseUrl.Value : null),
DecentralandUrl.SocialServiceMutes => $"https://social-api.decentraland.{ENV}/v1/mutes",
_ => throw new ArgumentOutOfRangeException(nameof(decentralandUrl), decentralandUrl, null!),
};
protected readonly struct UrlData
{
public readonly CacheBehaviour Caching;
public readonly string? Url;
public UrlData(CacheBehaviour caching, string? url)
{
Caching = caching;
Url = url;
}
public static UrlData RealmDependent(string? url) =>
new (CacheBehaviour.RealmDependent, url);
public static implicit operator UrlData(string rawUrl) =>
new (CacheBehaviour.Static, rawUrl);
public override string ToString() =>
Url ?? "<NOT_CONFIGURED>";
}
}
}