@partylayer/sdk 0.22.1 → 0.22.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/README.md +4 -4
- package/dist/{application-ledger-reader-DYaIuRCD.d.mts → application-ledger-reader-D3MFRC4B.d.mts} +1 -0
- package/dist/{application-ledger-reader-DYaIuRCD.d.ts → application-ledger-reader-D3MFRC4B.d.ts} +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +55 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -18
- package/dist/index.mjs.map +1 -1
- package/dist/native.d.mts +2 -2
- package/dist/native.d.ts +2 -2
- package/dist/native.js +55 -17
- package/dist/native.js.map +1 -1
- package/dist/native.mjs +56 -18
- package/dist/native.mjs.map +1 -1
- package/package.json +9 -9
package/dist/native.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseTokenHoldingV2, parseTokenHoldingV1, toCAIP2Network, isOfficialAdapterFactory, isOfficialProviderAdapter, mapUnknownErrorToPartyLayerError, toWalletId,
|
|
1
|
+
import { parseTokenHoldingV2, parseTokenHoldingV1, toCAIP2Network, isOfficialAdapterFactory, isOfficialProviderAdapter, mapUnknownErrorToPartyLayerError, toWalletId, detectNetworkMismatch, NetworkMismatchError, METRICS, WalletNotFoundError, AdapterNotRegisteredError, WalletNotInstalledError, OriginNotAllowedError, capabilityGuard, installGuard, CapabilityNotSupportedError, toTransferIntent, errorMetricName, ledgerApiBodyToObject, normalizeLedgerMethodLower, toPartyId, isRecognizedNetwork, findMatchingWalletInfo, generateSessionId, TransportError, toSignature, hashForPrivacy, createMetricsPayload, toSessionId, toTransactionHash } from '@partylayer/core';
|
|
2
2
|
import { RegistryClient } from '@partylayer/registry-client';
|
|
3
3
|
import { subscribeAnnouncedProviders, createExtensionChannelProvider, discoverProviders, createProviderBridge, CIP0103EventBus, ProviderRpcError, JSON_RPC_ERRORS, toProviderRpcError } from '@partylayer/provider';
|
|
4
4
|
|
|
@@ -1203,6 +1203,12 @@ function matchKnownByIdentity(providerId, base) {
|
|
|
1203
1203
|
return providerId === String(w.walletId) || !!k && (providerId === k || providerId.startsWith(`${k}.`));
|
|
1204
1204
|
});
|
|
1205
1205
|
}
|
|
1206
|
+
function matchDiscoveredWallet(id, wallets) {
|
|
1207
|
+
return findMatchingWalletInfo(
|
|
1208
|
+
{ provider: { id } },
|
|
1209
|
+
wallets
|
|
1210
|
+
) ?? matchKnownByIdentity(id, wallets);
|
|
1211
|
+
}
|
|
1206
1212
|
var DEFAULT_CONNECT_TIMEOUT_MS = 12e4;
|
|
1207
1213
|
var PartyLayerClientBase = class {
|
|
1208
1214
|
constructor(config, runtime = {}) {
|
|
@@ -1439,7 +1445,8 @@ var PartyLayerClientBase = class {
|
|
|
1439
1445
|
}
|
|
1440
1446
|
await Promise.all(registry.wallets.map(async (entry) => {
|
|
1441
1447
|
const id = toWalletId(entry.id);
|
|
1442
|
-
|
|
1448
|
+
const network = this.config.network;
|
|
1449
|
+
if (this.adapters.has(id) || !entry.supportedNetworks.includes(network) && !entry.additionalNetworks?.includes(network) || entry.adapter?.transport === "discovery-adapter" && !entry.adapter.networkHosts?.[network]) return;
|
|
1443
1450
|
let pending = this.defaultLoads.get(entry.id);
|
|
1444
1451
|
if (!pending) {
|
|
1445
1452
|
pending = (async () => {
|
|
@@ -1452,8 +1459,9 @@ var PartyLayerClientBase = class {
|
|
|
1452
1459
|
networkHosts: entry.adapter?.networkHosts,
|
|
1453
1460
|
capabilities: entry.capabilities
|
|
1454
1461
|
}) : entryAdapter;
|
|
1462
|
+
if (!this.registryNetworkSupported(entry, adapter)) return;
|
|
1455
1463
|
if (typeof window !== "undefined" && adapter instanceof GenericDiscoveryAdapter) {
|
|
1456
|
-
adapter.resolveOfficial(
|
|
1464
|
+
adapter.resolveOfficial(network);
|
|
1457
1465
|
}
|
|
1458
1466
|
this.registerAdapter(adapter);
|
|
1459
1467
|
this.registryDefaultIds.add(id);
|
|
@@ -1470,6 +1478,10 @@ var PartyLayerClientBase = class {
|
|
|
1470
1478
|
await pending;
|
|
1471
1479
|
}));
|
|
1472
1480
|
}
|
|
1481
|
+
registryNetworkSupported(entry, adapter) {
|
|
1482
|
+
const network = this.config.network;
|
|
1483
|
+
return entry.supportedNetworks.includes(network) || entry.additionalNetworks?.includes(network) === true && adapter?.supportsNetwork?.(network) === true;
|
|
1484
|
+
}
|
|
1473
1485
|
/**
|
|
1474
1486
|
* Hide registry entries whose wallet needs an app-registered adapter that is
|
|
1475
1487
|
* NOT registered. This is the library default (RainbowKit-style): never show a
|
|
@@ -1491,19 +1503,23 @@ var PartyLayerClientBase = class {
|
|
|
1491
1503
|
* adapters-only) or every non-announce entry is registered.
|
|
1492
1504
|
*/
|
|
1493
1505
|
async gateUnconnectableEntries(wallets) {
|
|
1494
|
-
if (!this.runtime.browserDiscovery)
|
|
1506
|
+
if (!this.runtime.browserDiscovery) wallets = wallets.filter((wallet) => this.adapters.has(wallet.walletId));
|
|
1495
1507
|
let hidden = null;
|
|
1496
1508
|
const announceCapabilities = /* @__PURE__ */ new Map();
|
|
1509
|
+
const additionalNetworks = /* @__PURE__ */ new Map();
|
|
1497
1510
|
try {
|
|
1498
1511
|
const registry = await this.registryClient.getRegistry();
|
|
1499
1512
|
for (const entry of registry.wallets) {
|
|
1513
|
+
const adapter = this.adapters.get(toWalletId(entry.id));
|
|
1514
|
+
if (entry.additionalNetworks && adapter) {
|
|
1515
|
+
additionalNetworks.set(entry.id, entry.additionalNetworks.filter((network) => adapter.supportsNetwork?.(network) === true));
|
|
1516
|
+
}
|
|
1500
1517
|
if (entry.adapter?.transport === "announce" && this.runtime.browserDiscovery) {
|
|
1501
1518
|
announceCapabilities.set(entry.id, getAnnounceCapabilities(deriveAnnounceConfig(entry)));
|
|
1502
1519
|
continue;
|
|
1503
1520
|
}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
(hidden ??= /* @__PURE__ */ new Set()).add(String(walletId));
|
|
1521
|
+
if (!adapter) {
|
|
1522
|
+
(hidden ??= /* @__PURE__ */ new Set()).add(entry.id);
|
|
1507
1523
|
}
|
|
1508
1524
|
}
|
|
1509
1525
|
} catch {
|
|
@@ -1511,7 +1527,13 @@ var PartyLayerClientBase = class {
|
|
|
1511
1527
|
}
|
|
1512
1528
|
return wallets.filter((w) => !hidden?.has(String(w.walletId))).map((w) => {
|
|
1513
1529
|
const capabilities = announceCapabilities.get(String(w.walletId));
|
|
1514
|
-
|
|
1530
|
+
const networks = additionalNetworks.get(String(w.walletId));
|
|
1531
|
+
if (!capabilities && !networks?.length) return w;
|
|
1532
|
+
return {
|
|
1533
|
+
...w,
|
|
1534
|
+
capabilities: capabilities ?? w.capabilities,
|
|
1535
|
+
networks: networks?.length ? [.../* @__PURE__ */ new Set([...w.networks, ...networks])] : w.networks
|
|
1536
|
+
};
|
|
1515
1537
|
});
|
|
1516
1538
|
}
|
|
1517
1539
|
/**
|
|
@@ -1606,17 +1628,26 @@ var PartyLayerClientBase = class {
|
|
|
1606
1628
|
createProvider: (a) => this.announceChannel(a.target ?? a.id)
|
|
1607
1629
|
});
|
|
1608
1630
|
const byId = /* @__PURE__ */ new Map();
|
|
1609
|
-
|
|
1610
|
-
for (const d of
|
|
1611
|
-
|
|
1631
|
+
const matchedAnnouncements = /* @__PURE__ */ new Set();
|
|
1632
|
+
for (const d of snapshot) {
|
|
1633
|
+
const announced = this.announceRegistry.get(d.id);
|
|
1634
|
+
if (d.announcementId) matchedAnnouncements.add(d.announcementId);
|
|
1635
|
+
byId.set(d.id, {
|
|
1636
|
+
...d,
|
|
1637
|
+
name: d.name ?? announced?.name,
|
|
1638
|
+
icon: d.icon ?? announced?.icon
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
for (const announced of this.announceRegistry.values()) {
|
|
1642
|
+
if (!byId.has(announced.id) && !matchedAnnouncements.has(announced.id)) {
|
|
1643
|
+
byId.set(announced.id, announced);
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1612
1646
|
const discovered = [...byId.values()];
|
|
1613
1647
|
const entries = [];
|
|
1614
1648
|
for (const d of discovered) {
|
|
1615
1649
|
if (d.identityResolved === false) continue;
|
|
1616
|
-
const known =
|
|
1617
|
-
{ provider: { id: d.id } },
|
|
1618
|
-
base
|
|
1619
|
-
) ?? matchKnownByIdentity(d.id, base);
|
|
1650
|
+
const known = matchDiscoveredWallet(d.id, base) ?? (d.announcementId ? matchDiscoveredWallet(d.announcementId, base) : void 0);
|
|
1620
1651
|
if (known) {
|
|
1621
1652
|
if (this.adapters.has(known.walletId)) continue;
|
|
1622
1653
|
try {
|
|
@@ -1680,7 +1711,7 @@ var PartyLayerClientBase = class {
|
|
|
1680
1711
|
adapter: { packageName: "announced", versionRange: "*" },
|
|
1681
1712
|
docs: [],
|
|
1682
1713
|
networks: [this.config.network || "devnet"],
|
|
1683
|
-
channel: "stable"
|
|
1714
|
+
channel: this.config.channel ?? "stable"
|
|
1684
1715
|
});
|
|
1685
1716
|
}
|
|
1686
1717
|
this.announceEntriesCache = entries;
|
|
@@ -1776,7 +1807,7 @@ var PartyLayerClientBase = class {
|
|
|
1776
1807
|
const nativeAdapter = this.adapters.get(options.walletId);
|
|
1777
1808
|
if (nativeAdapter) {
|
|
1778
1809
|
const entry = await this.registryClient.getWalletEntry(String(options.walletId)).catch(() => null);
|
|
1779
|
-
if (entry?.supportedNetworks?.length && !
|
|
1810
|
+
if (entry?.supportedNetworks?.length && !this.registryNetworkSupported(entry, nativeAdapter)) {
|
|
1780
1811
|
throw new WalletNotFoundError(`${String(options.walletId)} is unavailable on ${this.config.network}`);
|
|
1781
1812
|
}
|
|
1782
1813
|
isNativeWallet = true;
|
|
@@ -1807,7 +1838,14 @@ var PartyLayerClientBase = class {
|
|
|
1807
1838
|
}
|
|
1808
1839
|
const adapter = this.adapters.get(selectedWallet.walletId);
|
|
1809
1840
|
if (!adapter) {
|
|
1810
|
-
|
|
1841
|
+
const walletId = String(selectedWallet.walletId);
|
|
1842
|
+
if (this.announceEnabled) {
|
|
1843
|
+
const entry = await this.registryClient.getWalletEntry(walletId).catch(() => null);
|
|
1844
|
+
if (entry?.adapter?.transport === "announce") {
|
|
1845
|
+
throw new WalletNotInstalledError(walletId);
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
throw new WalletNotFoundError(walletId);
|
|
1811
1849
|
}
|
|
1812
1850
|
if (!isNativeWallet) {
|
|
1813
1851
|
try {
|