@openzeppelin/ui-builder-adapter-stellar 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +102 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +114 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/access-control/indexer-client.ts +115 -8
- package/src/access-control/service.ts +16 -0
- package/src/networks/testnet.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3336,13 +3336,74 @@ function verifyOZInterface(functionNames, hasOwnable, hasAccessControl, hasTwoSt
|
|
|
3336
3336
|
var import_ui_builder_types7 = require("@openzeppelin/ui-builder-types");
|
|
3337
3337
|
var import_ui_builder_utils20 = require("@openzeppelin/ui-builder-utils");
|
|
3338
3338
|
var LOG_SYSTEM3 = "StellarIndexerClient";
|
|
3339
|
+
function getUserIndexerEndpoints(networkId) {
|
|
3340
|
+
const svcCfg = import_ui_builder_utils20.userNetworkServiceConfigService.get(networkId, "indexer");
|
|
3341
|
+
if (!svcCfg || typeof svcCfg !== "object") {
|
|
3342
|
+
return void 0;
|
|
3343
|
+
}
|
|
3344
|
+
const endpoints = {};
|
|
3345
|
+
if ("indexerUri" in svcCfg && svcCfg.indexerUri) {
|
|
3346
|
+
const httpUrl = String(svcCfg.indexerUri).trim();
|
|
3347
|
+
if (httpUrl && (0, import_ui_builder_utils20.isValidUrl)(httpUrl)) {
|
|
3348
|
+
endpoints.http = httpUrl;
|
|
3349
|
+
} else if (httpUrl) {
|
|
3350
|
+
import_ui_builder_utils20.logger.warn(
|
|
3351
|
+
LOG_SYSTEM3,
|
|
3352
|
+
`User-configured indexer HTTP URL for ${networkId} is invalid: ${httpUrl}. Ignoring.`
|
|
3353
|
+
);
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
if ("indexerWsUri" in svcCfg && svcCfg.indexerWsUri) {
|
|
3357
|
+
const wsUrl = String(svcCfg.indexerWsUri).trim();
|
|
3358
|
+
if (wsUrl && (0, import_ui_builder_utils20.isValidUrl)(wsUrl)) {
|
|
3359
|
+
endpoints.ws = wsUrl;
|
|
3360
|
+
} else if (wsUrl) {
|
|
3361
|
+
import_ui_builder_utils20.logger.warn(
|
|
3362
|
+
LOG_SYSTEM3,
|
|
3363
|
+
`User-configured indexer WebSocket URL for ${networkId} is invalid: ${wsUrl}. Ignoring.`
|
|
3364
|
+
);
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
if (!endpoints.http && !endpoints.ws) {
|
|
3368
|
+
return void 0;
|
|
3369
|
+
}
|
|
3370
|
+
return endpoints;
|
|
3371
|
+
}
|
|
3339
3372
|
var StellarIndexerClient = class {
|
|
3340
3373
|
constructor(networkConfig) {
|
|
3341
3374
|
__publicField(this, "networkConfig");
|
|
3342
3375
|
__publicField(this, "resolvedEndpoints", null);
|
|
3343
3376
|
__publicField(this, "availabilityChecked", false);
|
|
3344
3377
|
__publicField(this, "isAvailable", false);
|
|
3378
|
+
__publicField(this, "unsubscribeFromConfigChanges");
|
|
3345
3379
|
this.networkConfig = networkConfig;
|
|
3380
|
+
this.unsubscribeFromConfigChanges = import_ui_builder_utils20.userNetworkServiceConfigService.subscribe(
|
|
3381
|
+
networkConfig.id,
|
|
3382
|
+
"indexer",
|
|
3383
|
+
() => {
|
|
3384
|
+
import_ui_builder_utils20.logger.info(
|
|
3385
|
+
LOG_SYSTEM3,
|
|
3386
|
+
`User indexer config changed for ${networkConfig.id}, resetting cache`
|
|
3387
|
+
);
|
|
3388
|
+
this.resetCache();
|
|
3389
|
+
}
|
|
3390
|
+
);
|
|
3391
|
+
}
|
|
3392
|
+
/**
|
|
3393
|
+
* Resets the resolved endpoints and availability cache.
|
|
3394
|
+
* Called when user configuration changes to force re-resolution.
|
|
3395
|
+
*/
|
|
3396
|
+
resetCache() {
|
|
3397
|
+
this.resolvedEndpoints = null;
|
|
3398
|
+
this.availabilityChecked = false;
|
|
3399
|
+
this.isAvailable = false;
|
|
3400
|
+
}
|
|
3401
|
+
/**
|
|
3402
|
+
* Cleans up subscriptions when the client is no longer needed.
|
|
3403
|
+
* Call this method when disposing of the client to prevent memory leaks.
|
|
3404
|
+
*/
|
|
3405
|
+
dispose() {
|
|
3406
|
+
this.unsubscribeFromConfigChanges();
|
|
3346
3407
|
}
|
|
3347
3408
|
/**
|
|
3348
3409
|
* Check if indexer is available and configured
|
|
@@ -4039,10 +4100,11 @@ var StellarIndexerClient = class {
|
|
|
4039
4100
|
/**
|
|
4040
4101
|
* Resolve indexer endpoints with config precedence
|
|
4041
4102
|
* Priority:
|
|
4042
|
-
* 1.
|
|
4043
|
-
* 2.
|
|
4044
|
-
* 3.
|
|
4045
|
-
* 4.
|
|
4103
|
+
* 1. User-configured indexer from UserNetworkServiceConfigService (localStorage)
|
|
4104
|
+
* 2. Runtime override from AppConfigService (environment/JSON config)
|
|
4105
|
+
* 3. Network config defaults (indexerUri/indexerWsUri)
|
|
4106
|
+
* 4. Derived from RPC (if safe pattern exists)
|
|
4107
|
+
* 5. None (returns empty object)
|
|
4046
4108
|
*
|
|
4047
4109
|
* @returns Resolved indexer endpoints
|
|
4048
4110
|
*/
|
|
@@ -4052,6 +4114,23 @@ var StellarIndexerClient = class {
|
|
|
4052
4114
|
}
|
|
4053
4115
|
const networkId = this.networkConfig.id;
|
|
4054
4116
|
const endpoints = {};
|
|
4117
|
+
const userIndexerConfig = getUserIndexerEndpoints(networkId);
|
|
4118
|
+
if (userIndexerConfig) {
|
|
4119
|
+
if (userIndexerConfig.http) {
|
|
4120
|
+
endpoints.http = userIndexerConfig.http;
|
|
4121
|
+
}
|
|
4122
|
+
if (userIndexerConfig.ws) {
|
|
4123
|
+
endpoints.ws = userIndexerConfig.ws;
|
|
4124
|
+
}
|
|
4125
|
+
if (endpoints.http || endpoints.ws) {
|
|
4126
|
+
import_ui_builder_utils20.logger.info(
|
|
4127
|
+
LOG_SYSTEM3,
|
|
4128
|
+
`Using user-configured indexer for ${networkId}: http=${endpoints.http}, ws=${endpoints.ws}`
|
|
4129
|
+
);
|
|
4130
|
+
this.resolvedEndpoints = endpoints;
|
|
4131
|
+
return endpoints;
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
4055
4134
|
const indexerOverride = import_ui_builder_utils20.appConfigService.getIndexerEndpointOverride(networkId);
|
|
4056
4135
|
if (indexerOverride) {
|
|
4057
4136
|
if (typeof indexerOverride === "string") {
|
|
@@ -4110,7 +4189,8 @@ var StellarIndexerClient = class {
|
|
|
4110
4189
|
OWNERSHIP_TRANSFER_STARTED: "OWNERSHIP_TRANSFER_STARTED",
|
|
4111
4190
|
OWNERSHIP_TRANSFER_COMPLETED: "OWNERSHIP_TRANSFER_COMPLETED",
|
|
4112
4191
|
ADMIN_TRANSFER_INITIATED: "ADMIN_TRANSFER_INITIATED",
|
|
4113
|
-
ADMIN_TRANSFER_COMPLETED: "ADMIN_TRANSFER_COMPLETED"
|
|
4192
|
+
ADMIN_TRANSFER_COMPLETED: "ADMIN_TRANSFER_COMPLETED",
|
|
4193
|
+
UNKNOWN: "UNKNOWN"
|
|
4114
4194
|
};
|
|
4115
4195
|
return mapping[changeType];
|
|
4116
4196
|
}
|
|
@@ -5446,6 +5526,21 @@ var StellarAccessControlService = class {
|
|
|
5446
5526
|
return [];
|
|
5447
5527
|
}
|
|
5448
5528
|
}
|
|
5529
|
+
/**
|
|
5530
|
+
* Disposes of the service and cleans up resources.
|
|
5531
|
+
*
|
|
5532
|
+
* Cleans up the indexer client's subscriptions to prevent memory leaks.
|
|
5533
|
+
* Call this method when the service is no longer needed.
|
|
5534
|
+
*
|
|
5535
|
+
* Note: In typical usage where the service is application-scoped and lives
|
|
5536
|
+
* for the duration of the application, calling dispose is not strictly necessary.
|
|
5537
|
+
* However, it should be called if the service is created/destroyed dynamically
|
|
5538
|
+
* (e.g., in tests or when switching networks).
|
|
5539
|
+
*/
|
|
5540
|
+
dispose() {
|
|
5541
|
+
this.indexerClient.dispose();
|
|
5542
|
+
import_ui_builder_utils22.logger.debug("StellarAccessControlService.dispose", "Service disposed");
|
|
5543
|
+
}
|
|
5449
5544
|
};
|
|
5450
5545
|
function createStellarAccessControlService(networkConfig) {
|
|
5451
5546
|
return new StellarAccessControlService(networkConfig);
|
|
@@ -8289,8 +8384,8 @@ var stellarTestnet = {
|
|
|
8289
8384
|
sorobanRpcUrl: "https://soroban-testnet.stellar.org",
|
|
8290
8385
|
networkPassphrase: "Test SDF Network ; September 2015",
|
|
8291
8386
|
explorerUrl: "https://stellar.expert/explorer/testnet",
|
|
8292
|
-
iconComponent: import_react12.NetworkStellar
|
|
8293
|
-
|
|
8387
|
+
iconComponent: import_react12.NetworkStellar,
|
|
8388
|
+
indexerUri: "https://openzepplin-stellar-testnet.graphql.subquery.network"
|
|
8294
8389
|
};
|
|
8295
8390
|
|
|
8296
8391
|
// src/networks/index.ts
|