@getpara/solana-wallet-connectors 2.31.0 → 2.32.1

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.
@@ -86,6 +86,7 @@ function SolanaExternalWalletProvider({
86
86
  const solanaAddressRef = useRef(solanaAddress == null ? void 0 : solanaAddress.toString());
87
87
  const disconnectRef = useRef(disconnect);
88
88
  const walletRef = useRef(wallet);
89
+ const lastConnectedAdapterRef = useRef(void 0);
89
90
  useEffect(() => {
90
91
  walletRef.current = wallet;
91
92
  }, [wallet]);
@@ -109,13 +110,14 @@ function SolanaExternalWalletProvider({
109
110
  interface: {
110
111
  disconnect: () => __async(this, null, function* () {
111
112
  yield disconnectRef.current();
113
+ lastConnectedAdapterRef.current = void 0;
112
114
  }),
113
115
  getAddress: () => __async(this, null, function* () {
114
116
  var _a;
115
117
  return (_a = solanaAddressRef.current) == null ? void 0 : _a.toString();
116
118
  }),
117
119
  signMessage: (_0) => __async(this, [_0], function* ({ message }) {
118
- var _a, _b, _c;
120
+ var _a, _b, _c, _d;
119
121
  const resolveSignFn = () => {
120
122
  var _a2;
121
123
  if (solanaSignMessageRef.current) return solanaSignMessageRef.current;
@@ -124,17 +126,24 @@ function SolanaExternalWalletProvider({
124
126
  if (adapter && typeof adapter.signMessage === "function") {
125
127
  return adapter.signMessage.bind(adapter);
126
128
  }
129
+ const lastConnected = lastConnectedAdapterRef.current;
130
+ if (lastConnected && typeof lastConnected.signMessage === "function") {
131
+ return lastConnected.signMessage.bind(lastConnected);
132
+ }
127
133
  return void 0;
128
134
  };
129
135
  const snapshotState = () => {
130
- var _a2, _b2, _c2, _d, _e, _f, _g, _h;
136
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k;
131
137
  return {
132
138
  adapterName: (_b2 = (_a2 = walletRef.current) == null ? void 0 : _a2.adapter) == null ? void 0 : _b2.name,
133
- adapterConnected: (_d = (_c2 = walletRef.current) == null ? void 0 : _c2.adapter) == null ? void 0 : _d.connected,
139
+ adapterConnected: (_d2 = (_c2 = walletRef.current) == null ? void 0 : _c2.adapter) == null ? void 0 : _d2.connected,
134
140
  adapterHasPublicKey: !!((_f = (_e = walletRef.current) == null ? void 0 : _e.adapter) == null ? void 0 : _f.publicKey),
135
141
  hasRefSignMessage: !!solanaSignMessageRef.current,
136
142
  hasClosureSignMessage: !!solanaSignMessage,
137
- hasAdapterSignMessage: typeof ((_h = (_g = walletRef.current) == null ? void 0 : _g.adapter) == null ? void 0 : _h.signMessage) === "function"
143
+ hasAdapterSignMessage: typeof ((_h = (_g = walletRef.current) == null ? void 0 : _g.adapter) == null ? void 0 : _h.signMessage) === "function",
144
+ lastConnectedAdapterName: (_i = lastConnectedAdapterRef.current) == null ? void 0 : _i.name,
145
+ lastConnectedAdapterConnected: (_j = lastConnectedAdapterRef.current) == null ? void 0 : _j.connected,
146
+ hasLastConnectedAdapterSignMessage: typeof ((_k = lastConnectedAdapterRef.current) == null ? void 0 : _k.signMessage) === "function"
138
147
  };
139
148
  };
140
149
  const waitForSignFn = () => __async(this, null, function* () {
@@ -152,7 +161,7 @@ function SolanaExternalWalletProvider({
152
161
  try {
153
162
  let fn = yield waitForSignFn();
154
163
  if (!fn) {
155
- const adapter = (_a = walletRef.current) == null ? void 0 : _a.adapter;
164
+ const adapter = (_b = (_a = walletRef.current) == null ? void 0 : _a.adapter) != null ? _b : lastConnectedAdapterRef.current;
156
165
  if (adapter) {
157
166
  const stateBefore = snapshotState();
158
167
  console.warn(
@@ -180,11 +189,11 @@ function SolanaExternalWalletProvider({
180
189
  };
181
190
  } catch (e) {
182
191
  console.error(e);
183
- if ((_b = e == null ? void 0 : e.message) == null ? void 0 : _b.includes("User rejected the request")) {
192
+ if ((_c = e == null ? void 0 : e.message) == null ? void 0 : _c.includes("User rejected the request")) {
184
193
  throw new Error("Signature request rejected");
185
194
  }
186
195
  console.error("Solana signature error:", e == null ? void 0 : e.message, snapshotState());
187
- throw new Error(`Solana signMessage failed: ${(_c = e == null ? void 0 : e.message) != null ? _c : "unknown"}`);
196
+ throw new Error(`Solana signMessage failed: ${(_d = e == null ? void 0 : e.message) != null ? _d : "unknown"}`);
188
197
  }
189
198
  }),
190
199
  watchDisconnection: (callback) => {
@@ -309,6 +318,7 @@ function SolanaExternalWalletProvider({
309
318
  )
310
319
  ]);
311
320
  }
321
+ lastConnectedAdapterRef.current = adapter;
312
322
  return address;
313
323
  } catch (e) {
314
324
  console.error(e);
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@getpara/solana-wallet-connectors",
3
- "version": "2.31.0",
3
+ "version": "2.32.1",
4
4
  "dependencies": {
5
- "@getpara/react-common": "2.31.0",
6
- "@getpara/web-sdk": "2.31.0",
5
+ "@getpara/react-common": "2.32.1",
6
+ "@getpara/web-sdk": "2.32.1",
7
7
  "bs58": "^6.0.0"
8
8
  },
9
9
  "devDependencies": {
@@ -23,7 +23,7 @@
23
23
  "dist",
24
24
  "package.json"
25
25
  ],
26
- "gitHead": "174819efc3091ef104a4b54c887066587b07e4b8",
26
+ "gitHead": "8a8d69e6514eaf2c173fea0c9ebab8df0529e5c3",
27
27
  "main": "dist/index.js",
28
28
  "peerDependencies": {
29
29
  "@farcaster/mini-app-solana": "^1.0.5",