@partylayer/sdk 0.18.1 → 0.18.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 +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -53,6 +53,9 @@ var GenericAnnounceAdapter = class {
|
|
|
53
53
|
restore;
|
|
54
54
|
on;
|
|
55
55
|
ledgerApi;
|
|
56
|
+
// signMessage is optional too: assigned in the ctor only when the wallet
|
|
57
|
+
// declares support, so a wallet that cannot sign is not advertised as able to.
|
|
58
|
+
signMessage;
|
|
56
59
|
constructor(args) {
|
|
57
60
|
this.walletId = args.walletId ?? announcedWalletId(args.announceId);
|
|
58
61
|
this.name = args.name && args.name.length > 0 ? args.name : `Canton Wallet (${args.announceId.slice(0, 6)}\u2026)`;
|
|
@@ -66,13 +69,18 @@ var GenericAnnounceAdapter = class {
|
|
|
66
69
|
if (config?.events) this.on = this.makeOn();
|
|
67
70
|
if (config?.restore) this.restore = this.makeRestore();
|
|
68
71
|
if (config?.ledgerApi) this.ledgerApi = this.makeLedgerApi();
|
|
72
|
+
if (config?.signMessage !== false) this.signMessage = this.signMessageImpl.bind(this);
|
|
69
73
|
}
|
|
70
74
|
/**
|
|
71
|
-
* Capabilities
|
|
72
|
-
*
|
|
75
|
+
* Capabilities derived from actual presence: connect and submitTransaction are
|
|
76
|
+
* always present; signMessage, restore, ledgerApi, and events are each included
|
|
77
|
+
* only when the matching method was assigned, so the set is never advertised
|
|
78
|
+
* beyond what the adapter can do.
|
|
73
79
|
*/
|
|
74
80
|
getCapabilities() {
|
|
75
|
-
const caps = ["connect"
|
|
81
|
+
const caps = ["connect"];
|
|
82
|
+
if (this.signMessage) caps.push("signMessage");
|
|
83
|
+
caps.push("submitTransaction");
|
|
76
84
|
if (this.restore) caps.push("restore");
|
|
77
85
|
if (this.ledgerApi) caps.push("ledgerApi");
|
|
78
86
|
if (this.on) caps.push("events");
|
|
@@ -118,7 +126,10 @@ var GenericAnnounceAdapter = class {
|
|
|
118
126
|
} catch {
|
|
119
127
|
}
|
|
120
128
|
}
|
|
121
|
-
|
|
129
|
+
// Real signMessage implementation. Exposed as `this.signMessage` from the ctor
|
|
130
|
+
// only when the wallet declares support, so getCapabilities and feature
|
|
131
|
+
// detection stay honest for a wallet that cannot sign.
|
|
132
|
+
async signMessageImpl(_ctx, session, params) {
|
|
122
133
|
return this.guarded(async () => {
|
|
123
134
|
const rpcParams = this.signMessageBase64 ? { message: toBase64Message(params.message) } : { message: params.message };
|
|
124
135
|
const res = await this.provider.request({ method: "signMessage", params: rpcParams });
|
|
@@ -848,6 +859,10 @@ function deriveAnnounceConfig(entry) {
|
|
|
848
859
|
const cfg = entry.adapter?.config ?? {};
|
|
849
860
|
const config = {
|
|
850
861
|
events: entry.capabilities?.events === true,
|
|
862
|
+
// signMessage is ON unless the entry declares capabilities.signMessage:false,
|
|
863
|
+
// so a wallet that cannot sign is reported honestly. The default preserves the
|
|
864
|
+
// baseline for every entry that omits it or sets it true.
|
|
865
|
+
signMessage: entry.capabilities?.signMessage !== false,
|
|
851
866
|
restore: cfg.restore === true,
|
|
852
867
|
ledgerApi: cfg.ledgerApi === true,
|
|
853
868
|
metadata: cfg.metadata === true,
|
|
@@ -1144,8 +1159,16 @@ var PartyLayerClient = class {
|
|
|
1144
1159
|
if (!this.announceEnabled) return base;
|
|
1145
1160
|
if (this.announceEntriesCache === null) {
|
|
1146
1161
|
try {
|
|
1162
|
+
let injectionPaths;
|
|
1163
|
+
try {
|
|
1164
|
+
const registry = await this.registryClient.getRegistry();
|
|
1165
|
+
const props = registry.wallets.filter((w) => w.adapter?.transport === "announce").map((w) => w.installation?.windowProperty).filter((p) => typeof p === "string" && p.length > 0);
|
|
1166
|
+
if (props.length > 0) injectionPaths = [...new Set(props)];
|
|
1167
|
+
} catch {
|
|
1168
|
+
}
|
|
1147
1169
|
const snapshot = await discoverProviders({
|
|
1148
1170
|
timeoutMs: this.config.discovery?.announceTimeoutMs,
|
|
1171
|
+
injectionPaths,
|
|
1149
1172
|
// Working provider over the announce target channel; G4 (provider.md):
|
|
1150
1173
|
// target defaults to id when omitted — never a shared slot.
|
|
1151
1174
|
createProvider: (a) => createExtensionChannelProvider({ target: a.target ?? a.id })
|