@calimero-network/mero-react 9.11.0 → 9.11.1

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/README.md CHANGED
@@ -125,7 +125,7 @@ const {
125
125
  } = useMero();
126
126
  ```
127
127
 
128
- How an account (delegated session) learns its `applicationId`: first from its own contexts on the relay — one distinct application across them is the answer; several leaves it `null` on purpose (nothing says which the tab is for). With no contexts yet, it is derived from the registry by `packageName`: the id is `sha256(borsh((package, signerId)))` of the newest non-yanked bundle, exactly as merod computes it at install, so a brand-new account can found its first namespace (`admin.createNamespace({ applicationId })`). Without a `packageName`, or when the registry lists the package under more than one publisher, it stays `null`. `applicationIdForBundle` and `resolveApplicationIdFromRegistry` are exported for apps that need the same derivation.
128
+ How an account (delegated session) learns its `applicationId`: `packageName` decides. When the app passes one, the id is derived from the registry: `sha256(borsh((package, signerId)))` of the newest non-yanked bundle, exactly as merod computes it at install, so a brand-new account can found its first namespace (`admin.createNamespace({ applicationId })`) and an account already used in other apps is never handed one of THEIR ids. The account's own contexts on the relay are consulted only when the app passes no `packageName` (or the registry did not answer, after one `console.warn`): one distinct application across them is the answer; several leaves it `null` on purpose (nothing says which the tab is for). When the registry lists the package under more than one publisher, it stays `null`. `applicationIdForBundle` and `resolveApplicationIdFromRegistry` are exported for apps that need the same derivation.
129
129
 
130
130
  Through `mero` you access the full MeroJs API:
131
131
 
package/dist/index.cjs CHANGED
@@ -1599,26 +1599,29 @@ function MeroProvider({
1599
1599
  setIsLoading(false);
1600
1600
  if (!nodeKey) return;
1601
1601
  }
1602
+ if (packageName) {
1603
+ try {
1604
+ const { applicationId: derived } = await resolveApplicationIdFromRegistry(
1605
+ registryUrl ?? DEFAULT_REGISTRY_URL,
1606
+ packageName
1607
+ );
1608
+ if (!active) return;
1609
+ setApplicationIdState(derived);
1610
+ return;
1611
+ } catch (e) {
1612
+ console.warn(`[mero-react] could not learn the application id of ${packageName} from the registry`, e);
1613
+ if (!active) return;
1614
+ }
1615
+ }
1602
1616
  try {
1603
1617
  const contexts = await listDelegatedContexts(delegated);
1618
+ if (!active) return;
1604
1619
  const apps = [
1605
1620
  ...new Set((contexts ?? []).map((c) => c.applicationId).filter(Boolean))
1606
1621
  ];
1607
- if (!active) return;
1608
1622
  if (apps.length === 1) {
1609
1623
  setApplicationIdState(apps[0]);
1610
1624
  }
1611
- if (apps.length === 0 && packageName) {
1612
- try {
1613
- const { applicationId: derived } = await resolveApplicationIdFromRegistry(
1614
- registryUrl ?? DEFAULT_REGISTRY_URL,
1615
- packageName
1616
- );
1617
- if (active) setApplicationIdState(derived);
1618
- } catch (e) {
1619
- console.warn(`[mero-react] could not learn the application id of ${packageName} from the registry`, e);
1620
- }
1621
- }
1622
1625
  } catch {
1623
1626
  }
1624
1627
  })();