@meshconnect/uwc-bridge-parent 1.4.2-snapshot.e930396 → 1.5.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/BaseWalletAdapter.d.ts.map +1 -1
- package/dist/BaseWalletAdapter.js +0 -6
- package/dist/BaseWalletAdapter.js.map +1 -1
- package/dist/BridgeParent.d.ts +76 -0
- package/dist/BridgeParent.d.ts.map +1 -1
- package/dist/BridgeParent.js +331 -6
- package/dist/BridgeParent.js.map +1 -1
- package/dist/BridgeParent.test.js +621 -28
- package/dist/BridgeParent.test.js.map +1 -1
- package/package.json +1 -1
- package/src/BaseWalletAdapter.ts +0 -6
- package/src/BridgeParent.test.ts +923 -28
- package/src/BridgeParent.ts +455 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseWalletAdapter.d.ts","sourceRoot":"","sources":["../src/BaseWalletAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sBAAsB,EACtB,UAAU,EACX,MAAM,6BAA6B,CAAA;AACpC,OAAO,EACL,8BAA8B,EAW9B,gBAAgB,EAIjB,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EACV,UAAU,EAEV,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AA8B3C,eAAO,MAAM,cAAc,EAAoB,UAAU,CAAC,aAAa,CAAC,CAAA;AAExE,qBAAa,iBAAkB,SAAQ,8BAA8B;IACnE,IAAI,4BAAiB;IACrB,GAAG,SACqG;IACxG,IAAI,SAC8sB;IACltB,4BAA4B,EAAE,WAAW,CAAC,kBAAkB,CAAC,CAG3D;IAEF,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,WAAW,CAG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e,CAAC,CAAC,SAAS,WAAW,GAAG,oBAAoB,EAChE,WAAW,EAAE,CAAC,GACb,OAAO,CAAC,CAAC,CAAC;IAkBE,mBAAmB,CAChC,CAAC,SAAS,WAAW,GAAG,oBAAoB,EAC5C,YAAY,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;IAqB5B,WAAW,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAmB3D,OAAO,CAAC,aAAa,CAWpB;CACF"}
|
|
@@ -95,12 +95,6 @@ export class BaseWalletAdapter extends BaseMessageSignerWalletAdapter {
|
|
|
95
95
|
}
|
|
96
96
|
this.emit('disconnect');
|
|
97
97
|
}
|
|
98
|
-
// INTENTIONAL DIVERGENCE (ONC-249): the injected-connector twin
|
|
99
|
-
// (LegacyInjectedSolanaWalletAdapter) now signs + self-broadcasts via
|
|
100
|
-
// `connection.sendRawTransaction` to survive Coinbase/Base Wallet Legacy's
|
|
101
|
-
// page-reload-on-`signAndSendTransaction` bug. This bridge-parent twin still
|
|
102
|
-
// calls `signAndSendTransaction` below; converging the two is tracked by the
|
|
103
|
-
// shared-adapter dedupe (ONC-140), not this ticket.
|
|
104
98
|
async sendTransaction(transaction, connection, options = {}) {
|
|
105
99
|
try {
|
|
106
100
|
const wallet = this._wallet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseWalletAdapter.js","sourceRoot":"","sources":["../src/BaseWalletAdapter.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,EACtB,6BAA6B,EAC7B,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACxB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,0BAA0B,EAC1B,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,6BAA6B,CAAA;AASpC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAi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AY,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;YAE5C,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACnB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAA;YAEtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,uBAAuB,EAAE,CAAC,CAAA;YACjD,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACzB,CAAC;IACH,CAAC,CAAA;CACF"}
|
package/dist/BridgeParent.d.ts
CHANGED
|
@@ -68,6 +68,42 @@ export interface ParentAPI {
|
|
|
68
68
|
parentOrigin: string;
|
|
69
69
|
discoverTronWallets: (injectedIds: string[]) => void;
|
|
70
70
|
discoverTonWallets: (jsBridgeKeys: string[]) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Attach a real listener for `eventName` on the EIP-6963 provider. Awaits the
|
|
73
|
+
* one-shot EIP-6963 discovery window before looking up the wallet by `uuid` in
|
|
74
|
+
* `eip6963Wallets`; if that misses and an optional `rdns` was supplied, falls
|
|
75
|
+
* back to matching by `rdns` (a wallet-defined identifier stable across
|
|
76
|
+
* injection contexts). Forwards every event firing to `callback` (a
|
|
77
|
+
* Comlink-proxied callback the child supplies). Resolves to a teardown that
|
|
78
|
+
* removes the listener. THROWS when neither `uuid` nor the `rdns` fallback
|
|
79
|
+
* resolves a wallet (surfaced to the child as a bridge error rather than a
|
|
80
|
+
* silent no-op); resolves to `undefined` only when the wallet IS found but
|
|
81
|
+
* exposes no `.on` to observe.
|
|
82
|
+
*/
|
|
83
|
+
subscribeEip6963ProviderEvent: (uuid: string, eventName: 'accountsChanged' | 'chainChanged' | 'disconnect', callback: (payload?: unknown) => void, rdns?: string) => Promise<(() => void) | undefined>;
|
|
84
|
+
/**
|
|
85
|
+
* Same as `subscribeEip6963ProviderEvent`, but for an injected Tron
|
|
86
|
+
* provider resolved fresh by its window path (`injectedId`) rather than a
|
|
87
|
+
* cached discovery list, since Tron providers aren't cached the same way.
|
|
88
|
+
*/
|
|
89
|
+
subscribeTronProviderEvent: (injectedId: string, eventName: 'accountsChanged' | 'disconnect', callback: (payload?: unknown) => void) => (() => void) | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Relay a connected Solana wallet's account-change events across the
|
|
92
|
+
* bridge. `walletId` is the SAME id `walletStandardWallets[].uuid`
|
|
93
|
+
* publishes (see `generateWalletId` — name+chain based, not a real UUID),
|
|
94
|
+
* which the child mirrors back as
|
|
95
|
+
* `SolanaWalletService.connectedWalletUuid`. Deliberately re-resolves the
|
|
96
|
+
* REAL, in-frame adapter (via `getWallets()`) rather than reusing the
|
|
97
|
+
* serialized `walletStandardWallets[].adapter` object — that object only
|
|
98
|
+
* exposes the whitelisted sign/transaction methods for Comlink, not
|
|
99
|
+
* `.on`/`.off`, so it can't be used to attach a live listener. Forwards a
|
|
100
|
+
* plain `string | null` (never a `PublicKey`) to `callback`, a
|
|
101
|
+
* Comlink-proxied callback the child supplies. Throws when no wallet
|
|
102
|
+
* matches `walletId` (reported as a bridge error on the child side,
|
|
103
|
+
* mirroring `subscribeEip6963ProviderEvent`'s uuid-miss); returns
|
|
104
|
+
* `undefined` when the resolved adapter can't be observed.
|
|
105
|
+
*/
|
|
106
|
+
subscribeSolanaWalletEvent: (walletId: string, callback: (address: string | null) => void) => (() => void) | undefined;
|
|
71
107
|
}
|
|
72
108
|
export declare class BridgeParent {
|
|
73
109
|
private iframe;
|
|
@@ -75,6 +111,7 @@ export declare class BridgeParent {
|
|
|
75
111
|
private endpoint;
|
|
76
112
|
private exposeListeners;
|
|
77
113
|
private destroyed;
|
|
114
|
+
private eip6963DiscoveryPromise;
|
|
78
115
|
constructor(iframe: HTMLIFrameElement);
|
|
79
116
|
private initializeConnection;
|
|
80
117
|
private discovereip6963Wallets;
|
|
@@ -85,6 +122,45 @@ export declare class BridgeParent {
|
|
|
85
122
|
* Checks if a value looks like a Tron provider (has request and tronWeb)
|
|
86
123
|
*/
|
|
87
124
|
private isTronProvider;
|
|
125
|
+
/**
|
|
126
|
+
* Resolve the REAL (non-serialized) Solana adapter for `walletId` — the
|
|
127
|
+
* same id `getSolanaWallets()` publishes as `WalletStandardInfo.uuid` (see
|
|
128
|
+
* `generateWalletId`). Mirrors `getSolanaWallets()`'s wallet-standard +
|
|
129
|
+
* traditional-Base-Wallet resolution, but returns the adapter instance
|
|
130
|
+
* itself instead of the Comlink-serialized object literal, since only the
|
|
131
|
+
* real instance has `.on`/`.off` to subscribe to.
|
|
132
|
+
*/
|
|
133
|
+
private resolveSolanaAdapterForWalletEvent;
|
|
134
|
+
/** Resolve a nested window path (e.g. 'tokenpocket.tron' -> window.tokenpocket.tron). */
|
|
135
|
+
private resolveTronProviderByPath;
|
|
136
|
+
/**
|
|
137
|
+
* TronLink's account/disconnect events fire on its TIP-1193 provider
|
|
138
|
+
* (`window.tron`), NOT on the `window.tronLink` object the catalog
|
|
139
|
+
* `injectedId` resolves to (that one carries `request`+`tronWeb` but is not
|
|
140
|
+
* an event emitter). Returns TronLink's `window.tron` emitter, but ONLY when
|
|
141
|
+
* the subscription is for TronLink itself.
|
|
142
|
+
*
|
|
143
|
+
* `window.tron` belongs exclusively to TronLink. Other Tron wallets whose own
|
|
144
|
+
* provider happens to lack `.on` (confirmed for OKX's `okxwallet.tronLink`,
|
|
145
|
+
* which is not an event emitter and broadcasts account switches on the window
|
|
146
|
+
* `message` channel instead) MUST NOT inherit it — binding OKX's
|
|
147
|
+
* `accountsChanged` on TronLink's `window.tron` means OKX's switches fire on
|
|
148
|
+
* the wrong wallet's provider and are silently dropped. Gated on the
|
|
149
|
+
* subscription's identity so only the TronLink path uses this fallback; every
|
|
150
|
+
* other wallet falls through to `subscribeTronWindowMessage`.
|
|
151
|
+
*/
|
|
152
|
+
private resolveTronEventEmitter;
|
|
153
|
+
/**
|
|
154
|
+
* Last-resort account/disconnect subscription for TronLink builds that expose
|
|
155
|
+
* neither an EIP-1193 nor a TIP-1193 `.on`: the wallet broadcasts changes as
|
|
156
|
+
* `window` `message` events (`{ message: { action, data } }`). Maps the
|
|
157
|
+
* TronLink `action` to the requested UWC event and forwards a
|
|
158
|
+
* Comlink-cloneable payload (never the raw event). Returns a teardown.
|
|
159
|
+
*
|
|
160
|
+
* `message` is window-global (not wallet-scoped), so this is only reached
|
|
161
|
+
* when no `.on` emitter exists anywhere for this session.
|
|
162
|
+
*/
|
|
163
|
+
private subscribeTronWindowMessage;
|
|
88
164
|
private getTronWallets;
|
|
89
165
|
private isTonConnectBridge;
|
|
90
166
|
private getTonWallets;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BridgeParent.d.ts","sourceRoot":"","sources":["../src/BridgeParent.ts"],"names":[],"mappings":"AAOA,OAAO,EAAc,WAAW,EAAwB,MAAM,iBAAiB,CAAA;AAC/E,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAA;AAkCnF,MAAM,WAAW,gBAAgB;IAE/B,OAAO,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAEvE,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAA;IAE/D,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,KAAK,IAAI,CAAA;CAC5E;AAED,UAAU,6BAA8B,SAAQ,qBAAqB;IACnE,eAAe,EAAE,CACb,2BAA2B,GAC3B,2BAA2B,GAC3B,+BAA+B,GAC/B,4BAA4B,CAC/B,EAAE,CAAA;IACH,yBAAyB,EAAE,CACzB,WAAW,EAAE,eAAe,EAC5B,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,MAAM,CAAC,CAAA;IACpB,yBAAyB,EAA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,IAAI,KACvC,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAA;CAC9B;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,QAAQ,CAAgC;IAKhD,OAAO,CAAC,eAAe,CAGhB;IACP,OAAO,CAAC,SAAS,CAAQ;IAIzB,OAAO,CAAC,uBAAuB,CAAyC;gBAE5D,MAAM,EAAE,iBAAiB;YASvB,oBAAoB;YA2UpB,sBAAsB;IAoDpC,OAAO,CAAC,gBAAgB;IAqYxB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,gBAAgB;IAKxB;;OAEG;IACH,OAAO,CAAC,cAAc;IAMtB;;;;;;;OAOG;IACH,OAAO,CAAC,kCAAkC;IA+B1C,yFAAyF;IAEzF,OAAO,CAAC,yBAAyB;IASjC;;;;;;;;;;;;;;;OAeG;IACH,OAAO,CAAC,uBAAuB;IAsC/B;;;;;;;;;OASG;IACH,OAAO,CAAC,0BAA0B;IA6ClC,OAAO,CAAC,cAAc;IAgFtB,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,aAAa;IAmDd,OAAO,IAAI,IAAI;CA8BvB"}
|
package/dist/BridgeParent.js
CHANGED
|
@@ -33,6 +33,10 @@ export class BridgeParent {
|
|
|
33
33
|
// bare listener won't match a capture-phase registration.
|
|
34
34
|
exposeListeners = [];
|
|
35
35
|
destroyed = false;
|
|
36
|
+
// Captured so subscribeEip6963ProviderEvent can await the one-shot discovery
|
|
37
|
+
// window before its uuid/rdns lookup, instead of racing an empty
|
|
38
|
+
// eip6963Wallets when a subscribe call arrives before discovery resolves.
|
|
39
|
+
eip6963DiscoveryPromise = null;
|
|
36
40
|
constructor(iframe) {
|
|
37
41
|
if (!iframe) {
|
|
38
42
|
throw new Error('BridgeParent requires an iframe element');
|
|
@@ -51,6 +55,7 @@ export class BridgeParent {
|
|
|
51
55
|
// while that's in flight — those paths are independent. The readiness
|
|
52
56
|
// flags gate the child from reading a still-empty array.
|
|
53
57
|
const eip6963Promise = this.discovereip6963Wallets();
|
|
58
|
+
this.eip6963DiscoveryPromise = eip6963Promise;
|
|
54
59
|
// Solana is synchronous, so run it inline (no benefit to a microtask hop)
|
|
55
60
|
const walletStandardWallets = this.getSolanaWallets();
|
|
56
61
|
this.parentAPI = {
|
|
@@ -76,6 +81,192 @@ export class BridgeParent {
|
|
|
76
81
|
this.parentAPI.tonWallets = this.getTonWallets(jsBridgeKeys);
|
|
77
82
|
this.parentAPI.tonWalletsReady = true;
|
|
78
83
|
}
|
|
84
|
+
},
|
|
85
|
+
subscribeEip6963ProviderEvent: async (uuid, eventName, callback, rdns) => {
|
|
86
|
+
// Discovery is one-shot with a fixed window (see
|
|
87
|
+
// discovereip6963Wallets) — a subscribe call can legitimately arrive
|
|
88
|
+
// before it resolves (e.g. immediately on page load during a session
|
|
89
|
+
// restore). Awaiting here means the lookup below always runs against
|
|
90
|
+
// the FINAL discovered list instead of racing a still-empty one. This
|
|
91
|
+
// is safe to await unconditionally: it resolves immediately once
|
|
92
|
+
// discovery has already completed. Comlink calls are already async
|
|
93
|
+
// over postMessage (the child already wraps this in
|
|
94
|
+
// `Promise.resolve()` — see BridgeChild.ts), so returning a Promise
|
|
95
|
+
// here changes nothing from the child's perspective.
|
|
96
|
+
await this.eip6963DiscoveryPromise;
|
|
97
|
+
const wallets = this.parentAPI?.eip6963Wallets ?? [];
|
|
98
|
+
// uuid is the primary match. It can genuinely diverge from what this
|
|
99
|
+
// parent discovered: each independent EIP-6963 injection context
|
|
100
|
+
// (top frame vs. this iframe) mints its own random uuid per spec, so
|
|
101
|
+
// the SAME physical wallet can be known under two different uuids —
|
|
102
|
+
// widening the discovery window (see the sibling plan this one
|
|
103
|
+
// follows) only narrows that race, it can't close it. rdns
|
|
104
|
+
// ("io.metamask"-style) is wallet-defined and stable across
|
|
105
|
+
// injection contexts, so it's a reliable fallback identity when the
|
|
106
|
+
// uuid the child captured doesn't match anything this parent saw.
|
|
107
|
+
const wallet = wallets.find(w => w.uuid === uuid) ??
|
|
108
|
+
(rdns ? wallets.find(w => w.rdns === rdns) : undefined);
|
|
109
|
+
if (!wallet) {
|
|
110
|
+
// Neither the uuid nor (if supplied) the rdns matched anything —
|
|
111
|
+
// genuinely not discovered by this parent. Throwing — instead of
|
|
112
|
+
// returning undefined like the "found but not observable" branch
|
|
113
|
+
// below does — turns this into a reported bridge error on the
|
|
114
|
+
// child side (see BridgeChild.ts's
|
|
115
|
+
// window.__uwcSubscribeEip6963ProviderEvent) instead of a silent,
|
|
116
|
+
// undetectable no-op.
|
|
117
|
+
throw new Error(`subscribeEip6963ProviderEvent: no wallet found for uuid "${uuid}"`);
|
|
118
|
+
}
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
+
const provider = wallet.provider;
|
|
121
|
+
if (!provider || typeof provider.on !== 'function')
|
|
122
|
+
return undefined;
|
|
123
|
+
// `callback` here IS the Comlink proxy the child passed — registering
|
|
124
|
+
// it DIRECTLY as the provider's own event listener would make Comlink
|
|
125
|
+
// serialize EVERY argument the wallet's own dispatch calls it with.
|
|
126
|
+
// Some wallets' internal EventEmitter passes extra, non-EIP-1193
|
|
127
|
+
// arguments alongside the real payload (observed in production: a
|
|
128
|
+
// wallet's own internal accountsChanged handler function), and
|
|
129
|
+
// Comlink can't clone a function — throwing "DataCloneError" the
|
|
130
|
+
// moment the wallet actually fires the event, silently breaking
|
|
131
|
+
// delivery. A local (non-proxied, ordinary JS) wrapper that only
|
|
132
|
+
// forwards the first argument sidesteps this entirely — extra
|
|
133
|
+
// arguments are simply never looked at, the same way the direct
|
|
134
|
+
// (non-bridge) `EthereumWalletService.onLifecycleEvent` path already
|
|
135
|
+
// does by using a plain single-parameter handler.
|
|
136
|
+
const localListener = (payload) => callback(payload);
|
|
137
|
+
provider.on(eventName, localListener);
|
|
138
|
+
// The teardown crosses back to the child as a Comlink return value —
|
|
139
|
+
// like TON's `listen()` above, an un-proxied function can't be
|
|
140
|
+
// structured-cloned over postMessage (Comlink throws
|
|
141
|
+
// "Unserializable return value" the moment the child tries to
|
|
142
|
+
// receive it), silently losing the child's ability to unsubscribe.
|
|
143
|
+
// The block body below is deliberate, not stylistic: an
|
|
144
|
+
// expression-bodied `() => provider.removeListener?.(...)` would
|
|
145
|
+
// implicitly return removeListener's OWN return value — by
|
|
146
|
+
// EventEmitter convention that's `this` (the whole provider), which
|
|
147
|
+
// is itself unserializable and reproduces the exact same failure one
|
|
148
|
+
// level down, the moment this teardown is actually invoked.
|
|
149
|
+
return Comlink.proxy(() => {
|
|
150
|
+
provider.removeListener?.(eventName, localListener);
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
subscribeTronProviderEvent: (injectedId, eventName, callback) => {
|
|
154
|
+
const provider = this.resolveTronProviderByPath(injectedId);
|
|
155
|
+
if (!provider) {
|
|
156
|
+
// Same rationale as subscribeEip6963ProviderEvent above — surface
|
|
157
|
+
// a genuine "nothing at this path" miss as a reported bridge
|
|
158
|
+
// error instead of a silent no-op.
|
|
159
|
+
throw new Error(`subscribeTronProviderEvent: no provider found at injectedId "${injectedId}"`);
|
|
160
|
+
}
|
|
161
|
+
// Choose an EVENT-CAPABLE emitter. The provider resolved by
|
|
162
|
+
// `injectedId` (e.g. `window.tronLink`) carries `request`+`tronWeb` —
|
|
163
|
+
// enough for discovery + signing — but is NOT necessarily an event
|
|
164
|
+
// emitter. TronLink specifically injects a SEPARATE TIP-1193 provider
|
|
165
|
+
// at `window.tron` that is the one emitting `accountsChanged` /
|
|
166
|
+
// `disconnect`; `window.tronLink` has no `.on`, so binding there
|
|
167
|
+
// silently dropped every in-wallet account switch (MFS-778). Order:
|
|
168
|
+
// 1) the resolved provider itself (Trust / Bitget expose their own `.on`)
|
|
169
|
+
// 2) TronLink's TIP-1193 `window.tron` — but ONLY for the TronLink
|
|
170
|
+
// subscription (see `resolveTronEventEmitter`). A wallet whose own
|
|
171
|
+
// Tron provider lacks `.on` (e.g. OKX's `okxwallet.tronLink`) must
|
|
172
|
+
// NOT inherit TronLink's `window.tron`, or its switches bind to the
|
|
173
|
+
// wrong wallet and are dropped — it falls through to (3) instead.
|
|
174
|
+
// 3) the window `message` channel (below), which OKX actually uses.
|
|
175
|
+
const emitter = typeof provider.on === 'function'
|
|
176
|
+
? provider
|
|
177
|
+
: this.resolveTronEventEmitter(injectedId, provider);
|
|
178
|
+
if (emitter) {
|
|
179
|
+
// Same "don't register the raw Comlink proxy directly" requirement
|
|
180
|
+
// as subscribeEip6963ProviderEvent above.
|
|
181
|
+
const localListener = (payload) => callback(payload);
|
|
182
|
+
emitter.on(eventName, localListener);
|
|
183
|
+
// Same block-body requirement as subscribeEip6963ProviderEvent above
|
|
184
|
+
// — discard removeListener's own (EventEmitter-convention `this`)
|
|
185
|
+
// return value rather than implicitly returning it.
|
|
186
|
+
return Comlink.proxy(() => {
|
|
187
|
+
emitter.removeListener?.(eventName, localListener);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
// 3) Legacy TronLink builds expose neither `.on` surface: the wallet
|
|
191
|
+
// broadcasts account/disconnect changes as `window` `message`
|
|
192
|
+
// events instead. Last-resort, and window-global (not
|
|
193
|
+
// wallet-scoped), so only reached when no emitter exists at all.
|
|
194
|
+
return Comlink.proxy(this.subscribeTronWindowMessage(eventName, callback));
|
|
195
|
+
},
|
|
196
|
+
subscribeSolanaWalletEvent: (walletId, callback) => {
|
|
197
|
+
const adapter = this.resolveSolanaAdapterForWalletEvent(walletId);
|
|
198
|
+
if (!adapter) {
|
|
199
|
+
// Same rationale as subscribeEip6963ProviderEvent's uuid miss —
|
|
200
|
+
// surface a genuine "nothing at this walletId" miss as a reported
|
|
201
|
+
// bridge error instead of a silent no-op.
|
|
202
|
+
throw new Error(`subscribeSolanaWalletEvent: no wallet found for walletId "${walletId}"`);
|
|
203
|
+
}
|
|
204
|
+
// PREFERRED — subscribe to the underlying wallet's wallet-standard
|
|
205
|
+
// `standard:events` `change` stream, which fires on EVERY account switch
|
|
206
|
+
// and carries the wallet's updated `accounts`. We must NOT derive switches
|
|
207
|
+
// from the adapter's own `connect`/`disconnect` here:
|
|
208
|
+
// `resolveSolanaAdapterForWalletEvent` returns a FRESH, never-connected
|
|
209
|
+
// `StandardWalletAdapter`, and that adapter only translates a `change` into
|
|
210
|
+
// `connect`/`disconnect` when it is already connected — so on the bridge an
|
|
211
|
+
// account-to-account switch emits NEITHER event and is silently dropped
|
|
212
|
+
// (only an eventual full de-auth trips `disconnect`). That is the Phantom
|
|
213
|
+
// multi-switch regression: several switches produce no telemetry and no
|
|
214
|
+
// session update, and only the final de-auth disconnects (MFS-778).
|
|
215
|
+
// Reading the wallet's `standard:events` directly captures every switch.
|
|
216
|
+
const standardWallet = adapter.wallet;
|
|
217
|
+
const standardEvents = standardWallet?.features?.['standard:events'];
|
|
218
|
+
if (standardWallet && typeof standardEvents?.on === 'function') {
|
|
219
|
+
// Forward the authoritative current active account as a plain base58
|
|
220
|
+
// string | null BEFORE crossing Comlink (the raw account object isn't
|
|
221
|
+
// structured-cloneable, and the child only needs the address). null =
|
|
222
|
+
// the switch de-authorized the dapp → the child maps it to [] (disconnect),
|
|
223
|
+
// a non-null address maps to [address] (switch), exactly as the legacy
|
|
224
|
+
// connect/disconnect path did.
|
|
225
|
+
const forwardActiveAccount = () => {
|
|
226
|
+
callback(standardWallet.accounts?.[0]?.address ?? null);
|
|
227
|
+
};
|
|
228
|
+
const off = standardEvents.on('change', properties => {
|
|
229
|
+
// React only to account-set changes; ignore pure chain/feature deltas.
|
|
230
|
+
if (properties && 'accounts' in properties)
|
|
231
|
+
forwardActiveAccount();
|
|
232
|
+
});
|
|
233
|
+
// Block body (not an expression arrow): the wallet-standard unsubscribe
|
|
234
|
+
// returns its own value, which must not become this teardown's
|
|
235
|
+
// (unserializable) return across Comlink. Best-effort + idempotent.
|
|
236
|
+
return Comlink.proxy(() => {
|
|
237
|
+
try {
|
|
238
|
+
off?.();
|
|
239
|
+
}
|
|
240
|
+
catch {
|
|
241
|
+
// Unsubscribe must never throw across the bridge.
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// FALLBACK — a traditional (non-wallet-standard) adapter, e.g. the legacy
|
|
246
|
+
// Base Wallet, exposes only EventEmitter `connect`/`disconnect` and no
|
|
247
|
+
// `standard:events` stream. Its connected instance re-emits `connect` on a
|
|
248
|
+
// switch, so this path stays correct for it.
|
|
249
|
+
if (typeof adapter.on !== 'function')
|
|
250
|
+
return undefined;
|
|
251
|
+
// Reduce to a plain string | null BEFORE crossing Comlink — the raw
|
|
252
|
+
// PublicKey (or the adapter/emitter itself) must never be forwarded:
|
|
253
|
+
// it isn't structured-cloneable and the child only ever needs the
|
|
254
|
+
// base58 address.
|
|
255
|
+
const onConnect = (publicKey) => {
|
|
256
|
+
callback(publicKey?.toBase58?.() ?? null);
|
|
257
|
+
};
|
|
258
|
+
const onDisconnect = () => callback(null);
|
|
259
|
+
adapter.on('connect', onConnect);
|
|
260
|
+
adapter.on('disconnect', onDisconnect);
|
|
261
|
+
// Block body — same requirement as subscribeEip6963ProviderEvent's
|
|
262
|
+
// teardown above: an expression-bodied `() => adapter.off(...)`
|
|
263
|
+
// would implicitly return `.off`'s own (EventEmitter-convention
|
|
264
|
+
// `this`) value, reproducing the unserializable-return-value failure
|
|
265
|
+
// one level down, the moment this teardown is actually invoked.
|
|
266
|
+
return Comlink.proxy(() => {
|
|
267
|
+
adapter.off('connect', onConnect);
|
|
268
|
+
adapter.off('disconnect', onDisconnect);
|
|
269
|
+
});
|
|
79
270
|
}
|
|
80
271
|
};
|
|
81
272
|
// Use Comlink's windowEndpoint with proper cross-origin support
|
|
@@ -139,7 +330,16 @@ export class BridgeParent {
|
|
|
139
330
|
async discovereip6963Wallets() {
|
|
140
331
|
return new Promise(resolve => {
|
|
141
332
|
const detectedWallets = [];
|
|
142
|
-
|
|
333
|
+
// 300ms (not 100ms): a wallet extension racing other extensions to
|
|
334
|
+
// inject, or a slow page load, can announce after a 100ms window
|
|
335
|
+
// closes — this parent's discovery is one-shot with no retry, so a
|
|
336
|
+
// missed announcement is missed forever for this session. Widening
|
|
337
|
+
// the window doesn't make discovery bulletproof (no fixed window
|
|
338
|
+
// can be), but meaningfully reduces how often a real wallet gets
|
|
339
|
+
// missed here and pushed onto the CHILD's local-discovery fallback,
|
|
340
|
+
// which is where the uuid-mismatch bug this constant guards against
|
|
341
|
+
// originates.
|
|
342
|
+
const timeout = 300; // Wait 300ms for wallets to announce
|
|
143
343
|
// Set up listener for wallet announcements
|
|
144
344
|
const handleAnnouncement = (event) => {
|
|
145
345
|
const announcementEvent = event;
|
|
@@ -496,6 +696,135 @@ export class BridgeParent {
|
|
|
496
696
|
const provider = value;
|
|
497
697
|
return provider['tronWeb'] != null && 'request' in provider;
|
|
498
698
|
}
|
|
699
|
+
/**
|
|
700
|
+
* Resolve the REAL (non-serialized) Solana adapter for `walletId` — the
|
|
701
|
+
* same id `getSolanaWallets()` publishes as `WalletStandardInfo.uuid` (see
|
|
702
|
+
* `generateWalletId`). Mirrors `getSolanaWallets()`'s wallet-standard +
|
|
703
|
+
* traditional-Base-Wallet resolution, but returns the adapter instance
|
|
704
|
+
* itself instead of the Comlink-serialized object literal, since only the
|
|
705
|
+
* real instance has `.on`/`.off` to subscribe to.
|
|
706
|
+
*/
|
|
707
|
+
resolveSolanaAdapterForWalletEvent(walletId) {
|
|
708
|
+
const { get } = getWallets();
|
|
709
|
+
const wallets = get();
|
|
710
|
+
for (const wallet of wallets) {
|
|
711
|
+
if (!this.isSolanaWallet(wallet))
|
|
712
|
+
continue;
|
|
713
|
+
if (this.generateWalletId(wallet) !== walletId)
|
|
714
|
+
continue;
|
|
715
|
+
if (!isWalletAdapterCompatibleStandardWallet(wallet))
|
|
716
|
+
return undefined;
|
|
717
|
+
return new StandardWalletAdapter({ wallet });
|
|
718
|
+
}
|
|
719
|
+
try {
|
|
720
|
+
const baseAdapter = new BaseWalletAdapter();
|
|
721
|
+
const baseWalletId = `${baseAdapter.name}-traditional`
|
|
722
|
+
.toLowerCase()
|
|
723
|
+
.replace(/\s+/g, '-');
|
|
724
|
+
const isDetected = baseAdapter.readyState === WalletReadyState.Installed ||
|
|
725
|
+
baseAdapter.readyState === WalletReadyState.Loadable;
|
|
726
|
+
if (baseWalletId === walletId && isDetected) {
|
|
727
|
+
return baseAdapter;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
catch {
|
|
731
|
+
// Base Wallet adapter failed to initialize — no traditional fallback.
|
|
732
|
+
}
|
|
733
|
+
return undefined;
|
|
734
|
+
}
|
|
735
|
+
/** Resolve a nested window path (e.g. 'tokenpocket.tron' -> window.tokenpocket.tron). */
|
|
736
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
737
|
+
resolveTronProviderByPath(injectedId) {
|
|
738
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
739
|
+
return injectedId.split('.').reduce((acc, part) => acc?.[part],
|
|
740
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
741
|
+
window);
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* TronLink's account/disconnect events fire on its TIP-1193 provider
|
|
745
|
+
* (`window.tron`), NOT on the `window.tronLink` object the catalog
|
|
746
|
+
* `injectedId` resolves to (that one carries `request`+`tronWeb` but is not
|
|
747
|
+
* an event emitter). Returns TronLink's `window.tron` emitter, but ONLY when
|
|
748
|
+
* the subscription is for TronLink itself.
|
|
749
|
+
*
|
|
750
|
+
* `window.tron` belongs exclusively to TronLink. Other Tron wallets whose own
|
|
751
|
+
* provider happens to lack `.on` (confirmed for OKX's `okxwallet.tronLink`,
|
|
752
|
+
* which is not an event emitter and broadcasts account switches on the window
|
|
753
|
+
* `message` channel instead) MUST NOT inherit it — binding OKX's
|
|
754
|
+
* `accountsChanged` on TronLink's `window.tron` means OKX's switches fire on
|
|
755
|
+
* the wrong wallet's provider and are silently dropped. Gated on the
|
|
756
|
+
* subscription's identity so only the TronLink path uses this fallback; every
|
|
757
|
+
* other wallet falls through to `subscribeTronWindowMessage`.
|
|
758
|
+
*/
|
|
759
|
+
resolveTronEventEmitter(injectedId,
|
|
760
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
761
|
+
provider) {
|
|
762
|
+
if (typeof window === 'undefined')
|
|
763
|
+
return undefined;
|
|
764
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
765
|
+
const win = window;
|
|
766
|
+
const tip1193 = win.tron;
|
|
767
|
+
if (!tip1193 ||
|
|
768
|
+
typeof tip1193.on !== 'function' ||
|
|
769
|
+
!this.isTronProvider(tip1193)) {
|
|
770
|
+
return undefined;
|
|
771
|
+
}
|
|
772
|
+
// Only TronLink may use its own `window.tron`. Identify the TronLink
|
|
773
|
+
// subscription by provider identity (the resolved provider IS `window.tron`
|
|
774
|
+
// / `window.tronLink`) or the canonical TronLink injectedId paths.
|
|
775
|
+
const isTronLinkSubscription = provider === tip1193 ||
|
|
776
|
+
provider === win.tronLink ||
|
|
777
|
+
injectedId === 'tron' ||
|
|
778
|
+
injectedId === 'tronLink';
|
|
779
|
+
if (isTronLinkSubscription) {
|
|
780
|
+
return tip1193;
|
|
781
|
+
}
|
|
782
|
+
return undefined;
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Last-resort account/disconnect subscription for TronLink builds that expose
|
|
786
|
+
* neither an EIP-1193 nor a TIP-1193 `.on`: the wallet broadcasts changes as
|
|
787
|
+
* `window` `message` events (`{ message: { action, data } }`). Maps the
|
|
788
|
+
* TronLink `action` to the requested UWC event and forwards a
|
|
789
|
+
* Comlink-cloneable payload (never the raw event). Returns a teardown.
|
|
790
|
+
*
|
|
791
|
+
* `message` is window-global (not wallet-scoped), so this is only reached
|
|
792
|
+
* when no `.on` emitter exists anywhere for this session.
|
|
793
|
+
*/
|
|
794
|
+
subscribeTronWindowMessage(eventName, callback) {
|
|
795
|
+
const handler = (event) => {
|
|
796
|
+
// Runs in the client's TOP frame and the payload flows straight into the
|
|
797
|
+
// live session address, so only trust broadcasts from THIS window — the
|
|
798
|
+
// page context TronLink/OKX inject into. Without this, any same-origin
|
|
799
|
+
// sibling frame or `window.opener` could post `{ message: { action:
|
|
800
|
+
// 'setAccount' } }` and move the user's account. Mirrors the posture of
|
|
801
|
+
// `wrapWithSourceGuard` and `Comlink.expose(..., [iframeOrigin])`.
|
|
802
|
+
if (event.source !== window || event.origin !== window.location.origin) {
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
const message = event?.data?.message;
|
|
806
|
+
const action = message?.action;
|
|
807
|
+
if (typeof action !== 'string')
|
|
808
|
+
return;
|
|
809
|
+
if (eventName === 'accountsChanged' &&
|
|
810
|
+
(action === 'setAccount' || action === 'accountsChanged')) {
|
|
811
|
+
const data = message?.data;
|
|
812
|
+
const address = typeof data === 'string'
|
|
813
|
+
? data
|
|
814
|
+
: Array.isArray(data)
|
|
815
|
+
? data[0]
|
|
816
|
+
: data?.address;
|
|
817
|
+
// Match the TIP-1193 `accountsChanged` shape (`string[]`) so the
|
|
818
|
+
// connector's normalization treats an absent address as a logout.
|
|
819
|
+
callback(address ? [address] : []);
|
|
820
|
+
}
|
|
821
|
+
else if (eventName === 'disconnect' && action === 'disconnect') {
|
|
822
|
+
callback();
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
window.addEventListener('message', handler);
|
|
826
|
+
return () => window.removeEventListener('message', handler);
|
|
827
|
+
}
|
|
499
828
|
getTronWallets(injectedIds) {
|
|
500
829
|
if (typeof window === 'undefined' || injectedIds.length === 0) {
|
|
501
830
|
return [];
|
|
@@ -503,11 +832,7 @@ export class BridgeParent {
|
|
|
503
832
|
const wallets = [];
|
|
504
833
|
const seen = new Set();
|
|
505
834
|
for (const injectedId of injectedIds) {
|
|
506
|
-
|
|
507
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
508
|
-
const provider = injectedId.split('.').reduce((acc, part) => acc?.[part],
|
|
509
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
510
|
-
window);
|
|
835
|
+
const provider = this.resolveTronProviderByPath(injectedId);
|
|
511
836
|
// Check if it looks like a TronProvider (has tronWeb.trx)
|
|
512
837
|
if (this.isTronProvider(provider) && !seen.has(injectedId)) {
|
|
513
838
|
seen.add(injectedId);
|