@partylayer/sdk 0.12.0 → 0.13.0
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 +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +20 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -41,6 +41,7 @@ var GenericAnnounceAdapter = class {
|
|
|
41
41
|
icon;
|
|
42
42
|
provider;
|
|
43
43
|
metadataEnabled;
|
|
44
|
+
staticMetadata;
|
|
44
45
|
mapError;
|
|
45
46
|
// Optional WalletAdapter surface — assigned in the ctor ONLY when configured,
|
|
46
47
|
// so `getCapabilities()` and `'x' in adapter` feature-detection stay honest.
|
|
@@ -54,6 +55,7 @@ var GenericAnnounceAdapter = class {
|
|
|
54
55
|
this.provider = args.provider;
|
|
55
56
|
const config = args.config;
|
|
56
57
|
this.metadataEnabled = config?.metadata === true;
|
|
58
|
+
this.staticMetadata = config?.staticMetadata;
|
|
57
59
|
this.mapError = config?.mapError;
|
|
58
60
|
if (config?.events) this.on = this.makeOn();
|
|
59
61
|
if (config?.restore) this.restore = this.makeRestore();
|
|
@@ -96,7 +98,7 @@ var GenericAnnounceAdapter = class {
|
|
|
96
98
|
network: reportedNetwork ?? account.networkId ?? ctx.network
|
|
97
99
|
};
|
|
98
100
|
if (this.metadataEnabled) {
|
|
99
|
-
session.metadata = buildMetadata(status, account);
|
|
101
|
+
session.metadata = { ...this.staticMetadata ?? {}, ...buildMetadata(status, account) };
|
|
100
102
|
}
|
|
101
103
|
return { partyId, session, capabilities: this.getCapabilities() };
|
|
102
104
|
});
|
|
@@ -161,7 +163,12 @@ var GenericAnnounceAdapter = class {
|
|
|
161
163
|
return {
|
|
162
164
|
...persisted,
|
|
163
165
|
walletId: this.walletId,
|
|
164
|
-
|
|
166
|
+
// persisted (lowest) → static config → runtime RPC (wins).
|
|
167
|
+
metadata: {
|
|
168
|
+
...persisted.metadata ?? {},
|
|
169
|
+
...this.staticMetadata ?? {},
|
|
170
|
+
...buildMetadata(status, account)
|
|
171
|
+
}
|
|
165
172
|
};
|
|
166
173
|
});
|
|
167
174
|
}
|
|
@@ -201,6 +208,7 @@ function buildMetadata(status, account) {
|
|
|
201
208
|
const put = (k, v) => {
|
|
202
209
|
if (typeof v === "string" && v.length > 0) meta[k] = v;
|
|
203
210
|
};
|
|
211
|
+
put("kernelId", status?.kernel?.id);
|
|
204
212
|
put("publicKey", account.publicKey);
|
|
205
213
|
put("namespace", account.namespace);
|
|
206
214
|
put("networkId", account.networkId);
|
|
@@ -714,12 +722,21 @@ var SESSION_STORAGE_KEY = "active_session";
|
|
|
714
722
|
var WALLETS_CHANGED_DEBOUNCE_MS = 50;
|
|
715
723
|
function deriveAnnounceConfig(entry) {
|
|
716
724
|
const cfg = entry.adapter?.config ?? {};
|
|
717
|
-
|
|
725
|
+
const config = {
|
|
718
726
|
events: entry.capabilities?.events === true,
|
|
719
727
|
restore: cfg.restore === true,
|
|
720
728
|
ledgerApi: cfg.ledgerApi === true,
|
|
721
729
|
metadata: cfg.metadata === true
|
|
722
730
|
};
|
|
731
|
+
const sm = cfg.staticMetadata;
|
|
732
|
+
if (sm && typeof sm === "object") {
|
|
733
|
+
const out = {};
|
|
734
|
+
for (const [k, v] of Object.entries(sm)) {
|
|
735
|
+
if (typeof v === "string") out[k] = v;
|
|
736
|
+
}
|
|
737
|
+
if (Object.keys(out).length > 0) config.staticMetadata = out;
|
|
738
|
+
}
|
|
739
|
+
return config;
|
|
723
740
|
}
|
|
724
741
|
var PartyLayerClient = class {
|
|
725
742
|
config;
|