@partylayer/sdk 0.18.0 → 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.d.mts
CHANGED
|
@@ -676,6 +676,15 @@ declare function announcedWalletId(announceId: string): WalletId;
|
|
|
676
676
|
interface AnnounceAdapterConfig {
|
|
677
677
|
/** Enable `on()` — bridge the provider's CIP-0103 `txChanged` → adapter `txStatus`. */
|
|
678
678
|
events?: boolean;
|
|
679
|
+
/**
|
|
680
|
+
* Whether the wallet supports signMessage. Defaults to true, the CIP-0103
|
|
681
|
+
* baseline, so an entry that omits it is unchanged. Set false for a wallet that
|
|
682
|
+
* answers signMessage with the unsupported code (4200), so the reported
|
|
683
|
+
* capability set omits signMessage and a dApp never offers a sign action that
|
|
684
|
+
* would fail. This can only make the reported set more accurate, never more
|
|
685
|
+
* permissive.
|
|
686
|
+
*/
|
|
687
|
+
signMessage?: boolean;
|
|
679
688
|
/** Enable `restore()` — silent `status()`/`getPrimaryAccount()` probe + party-match. */
|
|
680
689
|
restore?: boolean;
|
|
681
690
|
/** Enable `ledgerApi()` — proxy the standard CIP-0103 `ledgerApi` call. */
|
|
@@ -738,10 +747,13 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
738
747
|
restore?: WalletAdapter['restore'];
|
|
739
748
|
on?: WalletAdapter['on'];
|
|
740
749
|
ledgerApi?: WalletAdapter['ledgerApi'];
|
|
750
|
+
signMessage?: WalletAdapter['signMessage'];
|
|
741
751
|
constructor(args: GenericAnnounceAdapterArgs);
|
|
742
752
|
/**
|
|
743
|
-
* Capabilities
|
|
744
|
-
*
|
|
753
|
+
* Capabilities derived from actual presence: connect and submitTransaction are
|
|
754
|
+
* always present; signMessage, restore, ledgerApi, and events are each included
|
|
755
|
+
* only when the matching method was assigned, so the set is never advertised
|
|
756
|
+
* beyond what the adapter can do.
|
|
745
757
|
*/
|
|
746
758
|
getCapabilities(): CapabilityKey[];
|
|
747
759
|
/**
|
|
@@ -751,7 +763,7 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
751
763
|
detectInstalled(): Promise<AdapterDetectResult>;
|
|
752
764
|
connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
|
|
753
765
|
disconnect(): Promise<void>;
|
|
754
|
-
|
|
766
|
+
private signMessageImpl;
|
|
755
767
|
submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
|
|
756
768
|
/** events: bridge the provider's CIP-0103 `txChanged` push event → `txStatus`. */
|
|
757
769
|
private makeOn;
|
package/dist/index.d.ts
CHANGED
|
@@ -676,6 +676,15 @@ declare function announcedWalletId(announceId: string): WalletId;
|
|
|
676
676
|
interface AnnounceAdapterConfig {
|
|
677
677
|
/** Enable `on()` — bridge the provider's CIP-0103 `txChanged` → adapter `txStatus`. */
|
|
678
678
|
events?: boolean;
|
|
679
|
+
/**
|
|
680
|
+
* Whether the wallet supports signMessage. Defaults to true, the CIP-0103
|
|
681
|
+
* baseline, so an entry that omits it is unchanged. Set false for a wallet that
|
|
682
|
+
* answers signMessage with the unsupported code (4200), so the reported
|
|
683
|
+
* capability set omits signMessage and a dApp never offers a sign action that
|
|
684
|
+
* would fail. This can only make the reported set more accurate, never more
|
|
685
|
+
* permissive.
|
|
686
|
+
*/
|
|
687
|
+
signMessage?: boolean;
|
|
679
688
|
/** Enable `restore()` — silent `status()`/`getPrimaryAccount()` probe + party-match. */
|
|
680
689
|
restore?: boolean;
|
|
681
690
|
/** Enable `ledgerApi()` — proxy the standard CIP-0103 `ledgerApi` call. */
|
|
@@ -738,10 +747,13 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
738
747
|
restore?: WalletAdapter['restore'];
|
|
739
748
|
on?: WalletAdapter['on'];
|
|
740
749
|
ledgerApi?: WalletAdapter['ledgerApi'];
|
|
750
|
+
signMessage?: WalletAdapter['signMessage'];
|
|
741
751
|
constructor(args: GenericAnnounceAdapterArgs);
|
|
742
752
|
/**
|
|
743
|
-
* Capabilities
|
|
744
|
-
*
|
|
753
|
+
* Capabilities derived from actual presence: connect and submitTransaction are
|
|
754
|
+
* always present; signMessage, restore, ledgerApi, and events are each included
|
|
755
|
+
* only when the matching method was assigned, so the set is never advertised
|
|
756
|
+
* beyond what the adapter can do.
|
|
745
757
|
*/
|
|
746
758
|
getCapabilities(): CapabilityKey[];
|
|
747
759
|
/**
|
|
@@ -751,7 +763,7 @@ declare class GenericAnnounceAdapter implements WalletAdapter {
|
|
|
751
763
|
detectInstalled(): Promise<AdapterDetectResult>;
|
|
752
764
|
connect(ctx: AdapterContext): Promise<AdapterConnectResult>;
|
|
753
765
|
disconnect(): Promise<void>;
|
|
754
|
-
|
|
766
|
+
private signMessageImpl;
|
|
755
767
|
submitTransaction(_ctx: AdapterContext, _session: Session, params: SubmitTransactionParams): Promise<TxReceipt>;
|
|
756
768
|
/** events: bridge the provider's CIP-0103 `txChanged` push event → `txStatus`. */
|
|
757
769
|
private makeOn;
|
package/dist/index.js
CHANGED
|
@@ -49,6 +49,9 @@ var GenericAnnounceAdapter = class {
|
|
|
49
49
|
restore;
|
|
50
50
|
on;
|
|
51
51
|
ledgerApi;
|
|
52
|
+
// signMessage is optional too: assigned in the ctor only when the wallet
|
|
53
|
+
// declares support, so a wallet that cannot sign is not advertised as able to.
|
|
54
|
+
signMessage;
|
|
52
55
|
constructor(args) {
|
|
53
56
|
this.walletId = args.walletId ?? announcedWalletId(args.announceId);
|
|
54
57
|
this.name = args.name && args.name.length > 0 ? args.name : `Canton Wallet (${args.announceId.slice(0, 6)}\u2026)`;
|
|
@@ -62,13 +65,18 @@ var GenericAnnounceAdapter = class {
|
|
|
62
65
|
if (config?.events) this.on = this.makeOn();
|
|
63
66
|
if (config?.restore) this.restore = this.makeRestore();
|
|
64
67
|
if (config?.ledgerApi) this.ledgerApi = this.makeLedgerApi();
|
|
68
|
+
if (config?.signMessage !== false) this.signMessage = this.signMessageImpl.bind(this);
|
|
65
69
|
}
|
|
66
70
|
/**
|
|
67
|
-
* Capabilities
|
|
68
|
-
*
|
|
71
|
+
* Capabilities derived from actual presence: connect and submitTransaction are
|
|
72
|
+
* always present; signMessage, restore, ledgerApi, and events are each included
|
|
73
|
+
* only when the matching method was assigned, so the set is never advertised
|
|
74
|
+
* beyond what the adapter can do.
|
|
69
75
|
*/
|
|
70
76
|
getCapabilities() {
|
|
71
|
-
const caps = ["connect"
|
|
77
|
+
const caps = ["connect"];
|
|
78
|
+
if (this.signMessage) caps.push("signMessage");
|
|
79
|
+
caps.push("submitTransaction");
|
|
72
80
|
if (this.restore) caps.push("restore");
|
|
73
81
|
if (this.ledgerApi) caps.push("ledgerApi");
|
|
74
82
|
if (this.on) caps.push("events");
|
|
@@ -114,7 +122,10 @@ var GenericAnnounceAdapter = class {
|
|
|
114
122
|
} catch {
|
|
115
123
|
}
|
|
116
124
|
}
|
|
117
|
-
|
|
125
|
+
// Real signMessage implementation. Exposed as `this.signMessage` from the ctor
|
|
126
|
+
// only when the wallet declares support, so getCapabilities and feature
|
|
127
|
+
// detection stay honest for a wallet that cannot sign.
|
|
128
|
+
async signMessageImpl(_ctx, session, params) {
|
|
118
129
|
return this.guarded(async () => {
|
|
119
130
|
const rpcParams = this.signMessageBase64 ? { message: toBase64Message(params.message) } : { message: params.message };
|
|
120
131
|
const res = await this.provider.request({ method: "signMessage", params: rpcParams });
|
|
@@ -844,6 +855,10 @@ function deriveAnnounceConfig(entry) {
|
|
|
844
855
|
const cfg = entry.adapter?.config ?? {};
|
|
845
856
|
const config = {
|
|
846
857
|
events: entry.capabilities?.events === true,
|
|
858
|
+
// signMessage is ON unless the entry declares capabilities.signMessage:false,
|
|
859
|
+
// so a wallet that cannot sign is reported honestly. The default preserves the
|
|
860
|
+
// baseline for every entry that omits it or sets it true.
|
|
861
|
+
signMessage: entry.capabilities?.signMessage !== false,
|
|
847
862
|
restore: cfg.restore === true,
|
|
848
863
|
ledgerApi: cfg.ledgerApi === true,
|
|
849
864
|
metadata: cfg.metadata === true,
|
|
@@ -1140,8 +1155,16 @@ var PartyLayerClient = class {
|
|
|
1140
1155
|
if (!this.announceEnabled) return base;
|
|
1141
1156
|
if (this.announceEntriesCache === null) {
|
|
1142
1157
|
try {
|
|
1158
|
+
let injectionPaths;
|
|
1159
|
+
try {
|
|
1160
|
+
const registry = await this.registryClient.getRegistry();
|
|
1161
|
+
const props = registry.wallets.filter((w) => w.adapter?.transport === "announce").map((w) => w.installation?.windowProperty).filter((p) => typeof p === "string" && p.length > 0);
|
|
1162
|
+
if (props.length > 0) injectionPaths = [...new Set(props)];
|
|
1163
|
+
} catch {
|
|
1164
|
+
}
|
|
1143
1165
|
const snapshot = await provider.discoverProviders({
|
|
1144
1166
|
timeoutMs: this.config.discovery?.announceTimeoutMs,
|
|
1167
|
+
injectionPaths,
|
|
1145
1168
|
// Working provider over the announce target channel; G4 (provider.md):
|
|
1146
1169
|
// target defaults to id when omitted — never a shared slot.
|
|
1147
1170
|
createProvider: (a) => provider.createExtensionChannelProvider({ target: a.target ?? a.id })
|