@openzeppelin/ui-builder-adapter-stellar 1.8.0 → 1.8.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.js CHANGED
@@ -19,7 +19,8 @@ import {
19
19
  Contract,
20
20
  nativeToScVal as nativeToScVal5,
21
21
  rpc as StellarRpc,
22
- TransactionBuilder
22
+ TransactionBuilder,
23
+ xdr as xdr7
23
24
  } from "@stellar/stellar-sdk";
24
25
  import { logger as logger8, userRpcConfigService } from "@openzeppelin/ui-utils";
25
26
 
@@ -1455,17 +1456,34 @@ async function checkStellarFunctionStateMutability(contractAddress, functionName
1455
1456
  );
1456
1457
  return true;
1457
1458
  }
1458
- const hasStateChanges = simulationResult.stateChanges && simulationResult.stateChanges.length > 0;
1459
+ const storageChanges = (simulationResult.stateChanges ?? []).filter((change) => {
1460
+ try {
1461
+ const keyType = change.key.switch();
1462
+ if (keyType === xdr7.LedgerEntryType.contractCode()) {
1463
+ return false;
1464
+ }
1465
+ if (keyType === xdr7.LedgerEntryType.contractData()) {
1466
+ const dataKey = change.key.contractData().key();
1467
+ if (dataKey.switch() === xdr7.ScValType.scvLedgerKeyContractInstance()) {
1468
+ return false;
1469
+ }
1470
+ }
1471
+ return true;
1472
+ } catch {
1473
+ return true;
1474
+ }
1475
+ });
1476
+ const hasStorageChanges = storageChanges.length > 0;
1459
1477
  logger8.info(
1460
1478
  "checkStellarFunctionStateMutability",
1461
1479
  `[Check ${functionName}] State mutability check complete:`,
1462
1480
  {
1463
- hasStateChanges,
1464
- stateChangesCount: simulationResult.stateChanges?.length || 0,
1465
- modifiesState: Boolean(hasStateChanges)
1481
+ totalStateChanges: simulationResult.stateChanges?.length || 0,
1482
+ storageChangesCount: storageChanges.length,
1483
+ modifiesState: hasStorageChanges
1466
1484
  }
1467
1485
  );
1468
- return Boolean(hasStateChanges);
1486
+ return hasStorageChanges;
1469
1487
  } catch (error) {
1470
1488
  logger8.warn(
1471
1489
  "checkStellarFunctionStateMutability",
@@ -2145,14 +2163,14 @@ var WalletsKitImplementation = class {
2145
2163
  * @param address - The account address
2146
2164
  * @returns Promise resolving to signed transaction
2147
2165
  */
2148
- async signTransaction(xdr13, address) {
2166
+ async signTransaction(xdr14, address) {
2149
2167
  if (!this.initialized) {
2150
2168
  throw new Error("Wallet implementation not initialized");
2151
2169
  }
2152
2170
  const kit = this.getKitToUse();
2153
2171
  const networkPassphrase = this.getWalletNetwork();
2154
2172
  logger11.info(LOG_SYSTEM, "Signing transaction with wallet");
2155
- return await kit.signTransaction(xdr13, {
2173
+ return await kit.signTransaction(xdr14, {
2156
2174
  address,
2157
2175
  networkPassphrase
2158
2176
  });
@@ -2619,9 +2637,9 @@ function onStellarWalletConnectionChange(callback) {
2619
2637
  }
2620
2638
  });
2621
2639
  }
2622
- async function signTransaction(xdr13, address) {
2640
+ async function signTransaction(xdr14, address) {
2623
2641
  const impl = await getStellarWalletImplementation();
2624
- return impl.signTransaction(xdr13, address);
2642
+ return impl.signTransaction(xdr14, address);
2625
2643
  }
2626
2644
 
2627
2645
  // src/transaction/eoa.ts
@@ -3336,7 +3354,7 @@ import {
3336
3354
  } from "@openzeppelin/ui-utils";
3337
3355
  var LOG_SYSTEM3 = "StellarIndexerClient";
3338
3356
  function getUserIndexerEndpoints(networkId) {
3339
- const svcCfg = userNetworkServiceConfigService.get(networkId, "indexer");
3357
+ const svcCfg = userNetworkServiceConfigService.get(networkId, "access-control-indexer");
3340
3358
  if (!svcCfg || typeof svcCfg !== "object") {
3341
3359
  return void 0;
3342
3360
  }
@@ -3378,7 +3396,7 @@ var StellarIndexerClient = class {
3378
3396
  this.networkConfig = networkConfig;
3379
3397
  this.unsubscribeFromConfigChanges = userNetworkServiceConfigService.subscribe(
3380
3398
  networkConfig.id,
3381
- "indexer",
3399
+ "access-control-indexer",
3382
3400
  () => {
3383
3401
  logger19.info(
3384
3402
  LOG_SYSTEM3,
@@ -5761,7 +5779,7 @@ function getStellarDefaultServiceConfig(networkConfig, serviceId) {
5761
5779
  return { sorobanRpcUrl: networkConfig.sorobanRpcUrl };
5762
5780
  }
5763
5781
  break;
5764
- case "indexer":
5782
+ case "access-control-indexer":
5765
5783
  if (networkConfig.indexerUri && networkConfig.indexerWsUri) {
5766
5784
  return {
5767
5785
  indexerUri: networkConfig.indexerUri,
@@ -5790,26 +5808,27 @@ function getStellarNetworkServiceForms(exclude = []) {
5790
5808
  ]
5791
5809
  },
5792
5810
  {
5793
- id: "indexer",
5794
- label: "Indexer",
5795
- description: "Optional GraphQL indexer endpoint for historical access control data",
5811
+ id: "access-control-indexer",
5812
+ label: "Access Control Indexer",
5813
+ description: "Optional GraphQL indexer endpoint for historical access control data. Overrides the default indexer URL for this network.",
5796
5814
  supportsConnectionTest: true,
5815
+ requiredFeature: "access_control_indexer",
5797
5816
  fields: [
5798
5817
  {
5799
- id: "stellar-indexer-uri",
5818
+ id: "stellar-access-control-indexer-uri",
5800
5819
  name: "indexerUri",
5801
5820
  type: "text",
5802
- label: "Indexer GraphQL HTTP Endpoint",
5821
+ label: "Access Control Indexer GraphQL Endpoint",
5803
5822
  placeholder: "https://indexer.example.com/graphql",
5804
5823
  validation: { required: false, pattern: "^https?://.+" },
5805
5824
  width: "full",
5806
- helperText: "Optional. Used for querying historical access control events."
5825
+ helperText: "Optional. Used for querying historical access control events and role discovery."
5807
5826
  },
5808
5827
  {
5809
- id: "stellar-indexer-ws-uri",
5828
+ id: "stellar-access-control-indexer-ws-uri",
5810
5829
  name: "indexerWsUri",
5811
5830
  type: "text",
5812
- label: "Indexer GraphQL WebSocket Endpoint",
5831
+ label: "Access Control Indexer GraphQL WebSocket Endpoint",
5813
5832
  placeholder: "wss://indexer.example.com/graphql",
5814
5833
  validation: { required: false, pattern: "^wss?://.+" },
5815
5834
  width: "full",
@@ -5828,7 +5847,7 @@ async function validateStellarNetworkServiceConfig(serviceId, values) {
5828
5847
  };
5829
5848
  return validateStellarRpcEndpoint(cfg);
5830
5849
  }
5831
- if (serviceId === "indexer") {
5850
+ if (serviceId === "access-control-indexer") {
5832
5851
  if (values.indexerUri !== void 0 && values.indexerUri !== null && values.indexerUri !== "") {
5833
5852
  if (!isValidUrl3(String(values.indexerUri))) {
5834
5853
  return false;
@@ -5851,7 +5870,7 @@ async function testStellarNetworkServiceConnection(serviceId, values) {
5851
5870
  };
5852
5871
  return testStellarRpcConnection(cfg);
5853
5872
  }
5854
- if (serviceId === "indexer") {
5873
+ if (serviceId === "access-control-indexer") {
5855
5874
  const indexerUri = values.indexerUri;
5856
5875
  if (!indexerUri || typeof indexerUri !== "string" || indexerUri.trim() === "") {
5857
5876
  return { success: true };
@@ -5956,7 +5975,7 @@ function getStellarExplorerTxUrl(txHash, networkConfig) {
5956
5975
  }
5957
5976
 
5958
5977
  // src/mapping/struct-fields.ts
5959
- import { xdr as xdr8 } from "@stellar/stellar-sdk";
5978
+ import { xdr as xdr9 } from "@stellar/stellar-sdk";
5960
5979
  import { logger as logger23 } from "@openzeppelin/ui-utils";
5961
5980
  function extractStructFields(entries, structName) {
5962
5981
  try {
@@ -5971,7 +5990,7 @@ function extractStructFields(entries, structName) {
5971
5990
  return null;
5972
5991
  }
5973
5992
  const entryKind = entry.switch();
5974
- if (entryKind.value === xdr8.ScSpecEntryKind.scSpecEntryUdtStructV0().value) {
5993
+ if (entryKind.value === xdr9.ScSpecEntryKind.scSpecEntryUdtStructV0().value) {
5975
5994
  const structUdt = entry.udtStructV0();
5976
5995
  const fields = structUdt.fields();
5977
5996
  const structFields = [];
@@ -6016,7 +6035,7 @@ function isStructType2(entries, typeName) {
6016
6035
  return false;
6017
6036
  }
6018
6037
  const entryKind = entry.switch();
6019
- const isStruct = entryKind.value === xdr8.ScSpecEntryKind.scSpecEntryUdtStructV0().value;
6038
+ const isStruct = entryKind.value === xdr9.ScSpecEntryKind.scSpecEntryUdtStructV0().value;
6020
6039
  return isStruct;
6021
6040
  } catch (error) {
6022
6041
  logger23.error("isStructType", `Failed to check if ${typeName} is struct:`, error);
@@ -6055,7 +6074,7 @@ async function fetchSacSpecJson(cfg = {}) {
6055
6074
  }
6056
6075
 
6057
6076
  // src/sac/xdr.ts
6058
- import { xdr as xdr9 } from "@stellar/stellar-sdk";
6077
+ import { xdr as xdr10 } from "@stellar/stellar-sdk";
6059
6078
  import stellarXdrJsonPackage from "@stellar/stellar-xdr-json/package.json";
6060
6079
  import { parse, stringify } from "lossless-json";
6061
6080
  import { logger as logger25 } from "@openzeppelin/ui-utils";
@@ -6099,7 +6118,7 @@ async function encodeSacSpecEntries(jsonString) {
6099
6118
  }
6100
6119
  }
6101
6120
  function toScSpecEntries(base64Entries) {
6102
- return base64Entries.map((b64) => xdr9.ScSpecEntry.fromXDR(b64, "base64"));
6121
+ return base64Entries.map((b64) => xdr10.ScSpecEntry.fromXDR(b64, "base64"));
6103
6122
  }
6104
6123
 
6105
6124
  // src/sac/spec-cache.ts
@@ -6137,7 +6156,7 @@ async function getSacSpecArtifacts(cfg = {}) {
6137
6156
  }
6138
6157
 
6139
6158
  // src/contract/type.ts
6140
- import { Contract as Contract4, rpc as StellarRpc6, xdr as xdr10 } from "@stellar/stellar-sdk";
6159
+ import { Contract as Contract4, rpc as StellarRpc6, xdr as xdr11 } from "@stellar/stellar-sdk";
6141
6160
  import { logger as logger27, userRpcConfigService as userRpcConfigService5 } from "@openzeppelin/ui-utils";
6142
6161
  function getSorobanRpcServer3(networkConfig) {
6143
6162
  const customRpcConfig = userRpcConfigService5.getUserRpcConfig(networkConfig.id);
@@ -6164,8 +6183,8 @@ async function getStellarContractType(contractId, networkConfig) {
6164
6183
  if (!executable) {
6165
6184
  throw new Error("Could not get executable from contract data.");
6166
6185
  }
6167
- const execWasmType = xdr10.ContractExecutableType.contractExecutableWasm().name;
6168
- const execStellarAssetType = xdr10.ContractExecutableType.contractExecutableStellarAsset().name;
6186
+ const execWasmType = xdr11.ContractExecutableType.contractExecutableWasm().name;
6187
+ const execStellarAssetType = xdr11.ContractExecutableType.contractExecutableStellarAsset().name;
6169
6188
  const detected = executable.switch()?.name;
6170
6189
  if (detected === execWasmType) return "contractExecutableWasm";
6171
6190
  if (detected === execStellarAssetType) return "contractExecutableStellarAsset";
@@ -6978,7 +6997,7 @@ import {
6978
6997
  } from "@openzeppelin/ui-utils";
6979
6998
 
6980
6999
  // src/mapping/enum-metadata.ts
6981
- import { xdr as xdr11 } from "@stellar/stellar-sdk";
7000
+ import { xdr as xdr12 } from "@stellar/stellar-sdk";
6982
7001
  import { logger as logger30 } from "@openzeppelin/ui-utils";
6983
7002
 
6984
7003
  // src/mapping/tuple-components.ts
@@ -7047,20 +7066,20 @@ function extractEnumVariants(entries, enumName) {
7047
7066
  return null;
7048
7067
  }
7049
7068
  const entryKind = entry.switch();
7050
- if (entryKind.value === xdr11.ScSpecEntryKind.scSpecEntryUdtUnionV0().value) {
7069
+ if (entryKind.value === xdr12.ScSpecEntryKind.scSpecEntryUdtUnionV0().value) {
7051
7070
  const unionUdt = entry.udtUnionV0();
7052
7071
  const cases = unionUdt.cases();
7053
7072
  const variants = [];
7054
7073
  let isUnitOnly = true;
7055
7074
  for (const caseEntry of cases) {
7056
7075
  const caseKind = caseEntry.switch();
7057
- if (caseKind.value === xdr11.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value) {
7076
+ if (caseKind.value === xdr12.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value) {
7058
7077
  const voidCase = caseEntry.voidCase();
7059
7078
  variants.push({
7060
7079
  name: voidCase.name().toString(),
7061
7080
  type: "void"
7062
7081
  });
7063
- } else if (caseKind.value === xdr11.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value) {
7082
+ } else if (caseKind.value === xdr12.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value) {
7064
7083
  const tupleCase = caseEntry.tupleCase();
7065
7084
  const rawPayloadTypes = tupleCase.type().map((typeDef) => extractSorobanTypeFromScSpec(typeDef));
7066
7085
  const isSingleTuplePayload = rawPayloadTypes.length === 1 && rawPayloadTypes[0].startsWith("Tuple<");
@@ -7095,7 +7114,7 @@ function extractEnumVariants(entries, enumName) {
7095
7114
  isUnitOnly
7096
7115
  };
7097
7116
  }
7098
- if (entryKind.value === xdr11.ScSpecEntryKind.scSpecEntryUdtEnumV0().value) {
7117
+ if (entryKind.value === xdr12.ScSpecEntryKind.scSpecEntryUdtEnumV0().value) {
7099
7118
  const enumUdt = entry.udtEnumV0();
7100
7119
  const cases = enumUdt.cases();
7101
7120
  const variants = [];
@@ -7133,7 +7152,7 @@ function isEnumType(entries, typeName) {
7133
7152
  return false;
7134
7153
  }
7135
7154
  const entryKind = entry.switch();
7136
- const isEnum = entryKind.value === xdr11.ScSpecEntryKind.scSpecEntryUdtUnionV0().value || entryKind.value === xdr11.ScSpecEntryKind.scSpecEntryUdtEnumV0().value;
7155
+ const isEnum = entryKind.value === xdr12.ScSpecEntryKind.scSpecEntryUdtUnionV0().value || entryKind.value === xdr12.ScSpecEntryKind.scSpecEntryUdtEnumV0().value;
7137
7156
  return isEnum;
7138
7157
  } catch (error) {
7139
7158
  logger30.error("isEnumType", `Failed to check if ${typeName} is enum:`, error);
@@ -8587,7 +8606,7 @@ var stellarPublic = {
8587
8606
  networkPassphrase: "Public Global Stellar Network ; September 2015",
8588
8607
  explorerUrl: "https://stellar.expert/explorer/public",
8589
8608
  iconComponent: NetworkStellar2,
8590
- accessControlIndexerUrl: "https://openzeppelin-stellar-mainnet.graphql.subquery.network/"
8609
+ accessControlIndexerUrl: "https://openzeppelin-stellar-mainnet.graphql.subquery.network"
8591
8610
  };
8592
8611
 
8593
8612
  // src/networks/testnet.ts
@@ -8605,7 +8624,7 @@ var stellarTestnet = {
8605
8624
  networkPassphrase: "Test SDF Network ; September 2015",
8606
8625
  explorerUrl: "https://stellar.expert/explorer/testnet",
8607
8626
  iconComponent: NetworkStellar3,
8608
- accessControlIndexerUrl: "https://openzepplin-stellar-testnet.graphql.subquery.network"
8627
+ accessControlIndexerUrl: "https://openzeppelin-stellar-testnet.graphql.subquery.network"
8609
8628
  };
8610
8629
 
8611
8630
  // src/networks/index.ts