@partylayer/sdk 0.10.0 → 0.10.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.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _partylayer_core from '@partylayer/core';
|
|
2
2
|
import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts } from '@partylayer/core';
|
|
3
|
-
export { AdapterConnectResult, AdapterContext, AdapterDetectResult, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TimeoutError, TransactionStatus, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
|
|
3
|
+
export { AdapterConnectResult, AdapterContext, AdapterDetectResult, AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TimeoutError, TransactionStatus, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
|
|
4
4
|
import { RegistryClient, RegistryStatus } from '@partylayer/registry-client';
|
|
5
5
|
export { Cip0103StatusForDetection, Cip0103Support, ProviderDetection, ProviderMatcher, RegistryStatus, deriveGenericWalletName, findMatchingWallet, findMatchingWalletInfo, isCip0103Native, matchesProviderDetection } from '@partylayer/registry-client';
|
|
6
6
|
export { CANTON_NETWORKS, CIP0103Account, CIP0103ConnectResult, CIP0103Event, CIP0103EventBus, CIP0103Method, CIP0103Network, CIP0103Provider, CIP0103StatusEvent, CIP0103TxChangedEvent, CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, DiscoveredProvider, JSON_RPC_ERRORS, PartyLayerProvider, PartyLayerProviderOptions, ProviderRpcError, RPC_ERRORS, createProviderBridge, discoverInjectedProviders, fromCAIP2Network, isCIP0103Provider, isValidCAIP2, toCAIP2Network, waitForProvider } from '@partylayer/provider';
|
|
@@ -332,6 +332,8 @@ declare class PartyLayerClient {
|
|
|
332
332
|
private telemetry?;
|
|
333
333
|
/** Cached announce-discovery picker entries (one-shot; cleared by refreshDiscovery). */
|
|
334
334
|
private announceEntriesCache;
|
|
335
|
+
private readonly announceRegistry;
|
|
336
|
+
private announceUnsubscribe;
|
|
335
337
|
private origin;
|
|
336
338
|
constructor(config: PartyLayerConfig);
|
|
337
339
|
/**
|
|
@@ -371,6 +373,13 @@ declare class PartyLayerClient {
|
|
|
371
373
|
* is unavailable (list is already adapters-only) or has no such entries.
|
|
372
374
|
*/
|
|
373
375
|
private gateDiscoveryAdapterEntries;
|
|
376
|
+
/**
|
|
377
|
+
* If `walletId` maps to a registry entry with `transport: 'discovery-adapter'`,
|
|
378
|
+
* return the bits to build an actionable "register its adapter" error; else
|
|
379
|
+
* null (truly-unknown or non-discovery → plain WalletNotFoundError). Reads the
|
|
380
|
+
* UNGATED registry (SWR-cached); registry-unavailable → null (safe fallback).
|
|
381
|
+
*/
|
|
382
|
+
private unregisteredDiscoveryInfo;
|
|
374
383
|
/**
|
|
375
384
|
* Whether announce discovery is active: explicit `discovery.announce`, else
|
|
376
385
|
* ON in the browser and OFF under SSR (no `window`). Canonical: provider.md.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _partylayer_core from '@partylayer/core';
|
|
2
2
|
import { WalletAdapter, NetworkId, OfficialProviderAdapter, OfficialAdapterFactory, StorageAdapter, CryptoAdapter, TelemetryAdapter, LoggerAdapter, WalletId, Session, SessionId, TransactionHash, TransactionStatus, WalletInfo, SignMessageParams, SignedMessage, SignTransactionParams, SignedTransaction, SubmitTransactionParams, TxReceipt, LedgerApiParams, LedgerApiResult, CIP0103Provider, CapabilityKey, AdapterDetectResult, AdapterContext, AdapterConnectResult, NetworkHosts } from '@partylayer/core';
|
|
3
|
-
export { AdapterConnectResult, AdapterContext, AdapterDetectResult, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TimeoutError, TransactionStatus, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
|
|
3
|
+
export { AdapterConnectResult, AdapterContext, AdapterDetectResult, AdapterNotRegisteredError, PartyLayerError as CantonConnectError, CapabilityKey, CapabilityNotSupportedError, ENABLEMENT_METRICS, ERROR_METRICS, ErrorCode, InternalError, LedgerApiParams, LedgerApiResult, METRICS, MetricName, MetricsPayload, NetworkHosts, NetworkId, OfficialAdapterFactory, OfficialProviderAdapter, OriginNotAllowedError, PartyId, PartyLayerError, REGISTRY_METRICS, RegistryFetchFailedError, RegistrySchemaInvalidError, RegistryVerificationFailedError, Session, SessionExpiredError, SessionId, SignMessageParams, SignTransactionParams, SignedMessage, SignedTransaction, SubmitTransactionParams, TimeoutError, TransactionStatus, TransportError, TxReceipt, UserRejectedError, WalletAdapter, WalletId, WalletInfo, WalletNotFoundError, WalletNotInstalledError, errorMetricName, isOfficialAdapterFactory, isOfficialProviderAdapter } from '@partylayer/core';
|
|
4
4
|
import { RegistryClient, RegistryStatus } from '@partylayer/registry-client';
|
|
5
5
|
export { Cip0103StatusForDetection, Cip0103Support, ProviderDetection, ProviderMatcher, RegistryStatus, deriveGenericWalletName, findMatchingWallet, findMatchingWalletInfo, isCip0103Native, matchesProviderDetection } from '@partylayer/registry-client';
|
|
6
6
|
export { CANTON_NETWORKS, CIP0103Account, CIP0103ConnectResult, CIP0103Event, CIP0103EventBus, CIP0103Method, CIP0103Network, CIP0103Provider, CIP0103StatusEvent, CIP0103TxChangedEvent, CIP0103TxStatus, CIP0103_EVENTS, CIP0103_MANDATORY_METHODS, CIP0103_METHODS, DiscoveredProvider, JSON_RPC_ERRORS, PartyLayerProvider, PartyLayerProviderOptions, ProviderRpcError, RPC_ERRORS, createProviderBridge, discoverInjectedProviders, fromCAIP2Network, isCIP0103Provider, isValidCAIP2, toCAIP2Network, waitForProvider } from '@partylayer/provider';
|
|
@@ -332,6 +332,8 @@ declare class PartyLayerClient {
|
|
|
332
332
|
private telemetry?;
|
|
333
333
|
/** Cached announce-discovery picker entries (one-shot; cleared by refreshDiscovery). */
|
|
334
334
|
private announceEntriesCache;
|
|
335
|
+
private readonly announceRegistry;
|
|
336
|
+
private announceUnsubscribe;
|
|
335
337
|
private origin;
|
|
336
338
|
constructor(config: PartyLayerConfig);
|
|
337
339
|
/**
|
|
@@ -371,6 +373,13 @@ declare class PartyLayerClient {
|
|
|
371
373
|
* is unavailable (list is already adapters-only) or has no such entries.
|
|
372
374
|
*/
|
|
373
375
|
private gateDiscoveryAdapterEntries;
|
|
376
|
+
/**
|
|
377
|
+
* If `walletId` maps to a registry entry with `transport: 'discovery-adapter'`,
|
|
378
|
+
* return the bits to build an actionable "register its adapter" error; else
|
|
379
|
+
* null (truly-unknown or non-discovery → plain WalletNotFoundError). Reads the
|
|
380
|
+
* UNGATED registry (SWR-cached); registry-unavailable → null (safe fallback).
|
|
381
|
+
*/
|
|
382
|
+
private unregisteredDiscoveryInfo;
|
|
374
383
|
/**
|
|
375
384
|
* Whether announce discovery is active: explicit `discovery.announce`, else
|
|
376
385
|
* ON in the browser and OFF under SSR (no `window`). Canonical: provider.md.
|
package/dist/index.js
CHANGED
|
@@ -599,6 +599,12 @@ var PartyLayerClient = class {
|
|
|
599
599
|
telemetry;
|
|
600
600
|
/** Cached announce-discovery picker entries (one-shot; cleared by refreshDiscovery). */
|
|
601
601
|
announceEntriesCache = null;
|
|
602
|
+
// Persistent announce accumulator (option 1): one window subscription mounted
|
|
603
|
+
// at construction so LATE / inject-time `canton:announceProvider` replies are
|
|
604
|
+
// captured (not just a one-shot window). Read by aggregateAnnouncedWallets;
|
|
605
|
+
// torn down in destroy(). Empty → listWallets() output is byte-identical.
|
|
606
|
+
announceRegistry = /* @__PURE__ */ new Map();
|
|
607
|
+
announceUnsubscribe = null;
|
|
602
608
|
origin;
|
|
603
609
|
constructor(config) {
|
|
604
610
|
this.config = config;
|
|
@@ -640,6 +646,12 @@ var PartyLayerClient = class {
|
|
|
640
646
|
storage: this.storage
|
|
641
647
|
});
|
|
642
648
|
this.updateRegistryStatus();
|
|
649
|
+
if (this.announceEnabled) {
|
|
650
|
+
this.announceUnsubscribe = provider.subscribeAnnouncedProviders(
|
|
651
|
+
(p) => this.announceRegistry.set(p.id, p),
|
|
652
|
+
{ createProvider: (a) => provider.createExtensionChannelProvider({ target: a.target ?? a.id }) }
|
|
653
|
+
);
|
|
654
|
+
}
|
|
643
655
|
this.restoreSession().catch((err) => {
|
|
644
656
|
this.emit("error", {
|
|
645
657
|
type: "error",
|
|
@@ -747,6 +759,27 @@ var PartyLayerClient = class {
|
|
|
747
759
|
if (!hidden || hidden.size === 0) return wallets;
|
|
748
760
|
return wallets.filter((w) => !hidden.has(String(w.walletId)));
|
|
749
761
|
}
|
|
762
|
+
/**
|
|
763
|
+
* If `walletId` maps to a registry entry with `transport: 'discovery-adapter'`,
|
|
764
|
+
* return the bits to build an actionable "register its adapter" error; else
|
|
765
|
+
* null (truly-unknown or non-discovery → plain WalletNotFoundError). Reads the
|
|
766
|
+
* UNGATED registry (SWR-cached); registry-unavailable → null (safe fallback).
|
|
767
|
+
*/
|
|
768
|
+
async unregisteredDiscoveryInfo(walletId) {
|
|
769
|
+
try {
|
|
770
|
+
const registry = await this.registryClient.getRegistry();
|
|
771
|
+
const entry = registry.wallets.find((w) => core.toWalletId(w.id) === walletId);
|
|
772
|
+
if (entry?.adapter?.transport !== "discovery-adapter") return null;
|
|
773
|
+
const pid = entry.adapter?.config?.providerId;
|
|
774
|
+
return {
|
|
775
|
+
name: entry.name,
|
|
776
|
+
providerId: typeof pid === "string" ? pid : entry.id,
|
|
777
|
+
adapterPackage: typeof entry.adapter?.type === "string" ? entry.adapter.type : void 0
|
|
778
|
+
};
|
|
779
|
+
} catch {
|
|
780
|
+
return null;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
750
783
|
/**
|
|
751
784
|
* Whether announce discovery is active: explicit `discovery.announce`, else
|
|
752
785
|
* ON in the browser and OFF under SSR (no `window`). Canonical: provider.md.
|
|
@@ -779,12 +812,17 @@ var PartyLayerClient = class {
|
|
|
779
812
|
if (!this.announceEnabled) return base;
|
|
780
813
|
if (this.announceEntriesCache === null) {
|
|
781
814
|
try {
|
|
782
|
-
const
|
|
815
|
+
const snapshot = await provider.discoverProviders({
|
|
783
816
|
timeoutMs: this.config.discovery?.announceTimeoutMs,
|
|
784
817
|
// Working provider over the announce target channel; G4 (provider.md):
|
|
785
818
|
// target defaults to id when omitted — never a shared slot.
|
|
786
819
|
createProvider: (a) => provider.createExtensionChannelProvider({ target: a.target ?? a.id })
|
|
787
820
|
});
|
|
821
|
+
const byId = /* @__PURE__ */ new Map();
|
|
822
|
+
for (const d of snapshot) byId.set(d.id, d);
|
|
823
|
+
for (const d of this.announceRegistry.values())
|
|
824
|
+
if (!byId.has(d.id)) byId.set(d.id, d);
|
|
825
|
+
const discovered = [...byId.values()];
|
|
788
826
|
const entries = [];
|
|
789
827
|
for (const d of discovered) {
|
|
790
828
|
if (d.identityResolved === false) continue;
|
|
@@ -910,6 +948,10 @@ var PartyLayerClient = class {
|
|
|
910
948
|
metadata: { source: "native-cip0103" }
|
|
911
949
|
};
|
|
912
950
|
} else {
|
|
951
|
+
const info = await this.unregisteredDiscoveryInfo(options.walletId);
|
|
952
|
+
if (info) {
|
|
953
|
+
throw new core.AdapterNotRegisteredError(String(options.walletId), info);
|
|
954
|
+
}
|
|
913
955
|
throw new core.WalletNotFoundError(String(options.walletId));
|
|
914
956
|
}
|
|
915
957
|
}
|
|
@@ -1290,6 +1332,9 @@ var PartyLayerClient = class {
|
|
|
1290
1332
|
this.telemetry.flush().catch(() => {
|
|
1291
1333
|
});
|
|
1292
1334
|
}
|
|
1335
|
+
this.announceUnsubscribe?.();
|
|
1336
|
+
this.announceUnsubscribe = null;
|
|
1337
|
+
this.announceRegistry.clear();
|
|
1293
1338
|
this.eventHandlers.clear();
|
|
1294
1339
|
this.activeSession = null;
|
|
1295
1340
|
}
|
|
@@ -1478,6 +1523,10 @@ function createPartyLayer(config) {
|
|
|
1478
1523
|
return new PartyLayerClient(config);
|
|
1479
1524
|
}
|
|
1480
1525
|
|
|
1526
|
+
Object.defineProperty(exports, "AdapterNotRegisteredError", {
|
|
1527
|
+
enumerable: true,
|
|
1528
|
+
get: function () { return core.AdapterNotRegisteredError; }
|
|
1529
|
+
});
|
|
1481
1530
|
Object.defineProperty(exports, "CantonConnectError", {
|
|
1482
1531
|
enumerable: true,
|
|
1483
1532
|
get: function () { return core.PartyLayerError; }
|