@getpara/solana-wallet-connectors 2.27.0 → 2.28.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.
|
@@ -112,16 +112,63 @@ function SolanaExternalWalletProvider({
|
|
|
112
112
|
return (_a = solanaAddressRef.current) == null ? void 0 : _a.toString();
|
|
113
113
|
}),
|
|
114
114
|
signMessage: (_0) => __async(this, [_0], function* ({ message }) {
|
|
115
|
-
var _a, _b, _c
|
|
116
|
-
|
|
115
|
+
var _a, _b, _c;
|
|
116
|
+
const resolveSignFn = () => {
|
|
117
|
+
var _a2;
|
|
118
|
+
if (solanaSignMessageRef.current) return solanaSignMessageRef.current;
|
|
119
|
+
if (solanaSignMessage) return solanaSignMessage;
|
|
120
|
+
const adapter = (_a2 = walletRef.current) == null ? void 0 : _a2.adapter;
|
|
121
|
+
if (adapter && typeof adapter.signMessage === "function") {
|
|
122
|
+
return adapter.signMessage.bind(adapter);
|
|
123
|
+
}
|
|
124
|
+
return void 0;
|
|
125
|
+
};
|
|
126
|
+
const snapshotState = () => {
|
|
127
|
+
var _a2, _b2, _c2, _d, _e, _f, _g, _h;
|
|
128
|
+
return {
|
|
129
|
+
adapterName: (_b2 = (_a2 = walletRef.current) == null ? void 0 : _a2.adapter) == null ? void 0 : _b2.name,
|
|
130
|
+
adapterConnected: (_d = (_c2 = walletRef.current) == null ? void 0 : _c2.adapter) == null ? void 0 : _d.connected,
|
|
131
|
+
adapterHasPublicKey: !!((_f = (_e = walletRef.current) == null ? void 0 : _e.adapter) == null ? void 0 : _f.publicKey),
|
|
132
|
+
hasRefSignMessage: !!solanaSignMessageRef.current,
|
|
133
|
+
hasClosureSignMessage: !!solanaSignMessage,
|
|
134
|
+
hasAdapterSignMessage: typeof ((_h = (_g = walletRef.current) == null ? void 0 : _g.adapter) == null ? void 0 : _h.signMessage) === "function"
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
const waitForSignFn = () => __async(this, null, function* () {
|
|
117
138
|
const start = Date.now();
|
|
118
|
-
let fn = (
|
|
139
|
+
let fn = resolveSignFn();
|
|
119
140
|
while (!fn) {
|
|
120
141
|
if (Date.now() - start > SIGN_MESSAGE_REF_WAIT_MS) {
|
|
121
|
-
|
|
142
|
+
return void 0;
|
|
122
143
|
}
|
|
123
144
|
yield new Promise((resolve) => setTimeout(resolve, 100));
|
|
124
|
-
fn = (
|
|
145
|
+
fn = resolveSignFn();
|
|
146
|
+
}
|
|
147
|
+
return fn;
|
|
148
|
+
});
|
|
149
|
+
try {
|
|
150
|
+
let fn = yield waitForSignFn();
|
|
151
|
+
if (!fn) {
|
|
152
|
+
const adapter = (_a = walletRef.current) == null ? void 0 : _a.adapter;
|
|
153
|
+
if (adapter) {
|
|
154
|
+
const stateBefore = snapshotState();
|
|
155
|
+
console.warn(
|
|
156
|
+
"[Solana signMessage] sign fn unavailable after wait; attempting adapter.connect() recovery",
|
|
157
|
+
stateBefore
|
|
158
|
+
);
|
|
159
|
+
try {
|
|
160
|
+
if (!adapter.connected) {
|
|
161
|
+
yield adapter.connect();
|
|
162
|
+
}
|
|
163
|
+
fn = yield waitForSignFn();
|
|
164
|
+
} catch (reconnectErr) {
|
|
165
|
+
console.error("[Solana signMessage] reconnect attempt failed", reconnectErr, snapshotState());
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!fn) {
|
|
170
|
+
console.error("[Solana signMessage] sign fn unavailable after recovery", snapshotState());
|
|
171
|
+
throw new Error("Solana signMessage unavailable");
|
|
125
172
|
}
|
|
126
173
|
const encodedMessage = new TextEncoder().encode(message);
|
|
127
174
|
const signature = yield fn(encodedMessage);
|
|
@@ -130,11 +177,11 @@ function SolanaExternalWalletProvider({
|
|
|
130
177
|
};
|
|
131
178
|
} catch (e) {
|
|
132
179
|
console.error(e);
|
|
133
|
-
if ((
|
|
180
|
+
if ((_b = e == null ? void 0 : e.message) == null ? void 0 : _b.includes("User rejected the request")) {
|
|
134
181
|
throw new Error("Signature request rejected");
|
|
135
182
|
}
|
|
136
|
-
console.error("Solana signature error:", e == null ? void 0 : e.message);
|
|
137
|
-
throw new Error(`Solana signMessage failed: ${(
|
|
183
|
+
console.error("Solana signature error:", e == null ? void 0 : e.message, snapshotState());
|
|
184
|
+
throw new Error(`Solana signMessage failed: ${(_c = e == null ? void 0 : e.message) != null ? _c : "unknown"}`);
|
|
138
185
|
}
|
|
139
186
|
}),
|
|
140
187
|
watchDisconnection: (callback) => {
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/solana-wallet-connectors",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/react-common": "2.
|
|
6
|
-
"@getpara/web-sdk": "2.
|
|
5
|
+
"@getpara/react-common": "2.28.0",
|
|
6
|
+
"@getpara/web-sdk": "2.28.0",
|
|
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": "
|
|
26
|
+
"gitHead": "cb74d2b02aed6a8a5373249418b315d686b83b66",
|
|
27
27
|
"main": "dist/index.js",
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"@farcaster/mini-app-solana": "^1.0.5",
|