@solana-mobile/wallet-adapter-mobile 2.2.5 → 2.2.7
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/README.md +4 -5
- package/lib/cjs/index.browser.js +321 -501
- package/lib/cjs/index.browser.js.map +1 -0
- package/lib/cjs/index.js +321 -501
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/index.native.js +360 -531
- package/lib/cjs/index.native.js.map +1 -0
- package/lib/cjs/package.json +1 -3
- package/lib/esm/index.browser.js +318 -495
- package/lib/esm/index.browser.js.map +1 -0
- package/lib/esm/index.js +318 -495
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/package.json +1 -3
- package/lib/types/index.d.ts +68 -61
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +74 -68
- package/lib/types/index.browser.d.ts +0 -79
- package/lib/types/index.browser.d.ts.map +0 -1
- package/lib/types/index.native.d.ts +0 -79
- package/lib/types/index.native.d.ts.map +0 -1
package/lib/cjs/index.js
CHANGED
|
@@ -1,521 +1,339 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var walletStandardMobile = require('@solana-mobile/wallet-standard-mobile');
|
|
9
|
-
|
|
10
|
-
/******************************************************************************
|
|
11
|
-
Copyright (c) Microsoft Corporation.
|
|
12
|
-
|
|
13
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
-
purpose with or without fee is hereby granted.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
-
***************************************************************************** */
|
|
24
|
-
|
|
25
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
36
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
37
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
38
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
42
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
43
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
44
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
45
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
(undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
49
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
50
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
51
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
52
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
53
|
-
};
|
|
54
|
-
(undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
55
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
56
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
57
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/** Name of the feature. */
|
|
61
|
-
const StandardConnect = 'standard:connect';
|
|
62
|
-
|
|
63
|
-
/** Name of the feature. */
|
|
64
|
-
const StandardDisconnect = 'standard:disconnect';
|
|
65
|
-
|
|
66
|
-
/** Name of the feature. */
|
|
67
|
-
const StandardEvents = 'standard:events';
|
|
68
|
-
|
|
69
|
-
(undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
70
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
71
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
72
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
73
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
74
|
-
};
|
|
75
|
-
(undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
76
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
77
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
78
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
(undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
82
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
83
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
84
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
85
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
86
|
-
};
|
|
87
|
-
(undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
88
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
89
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
90
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
91
|
-
};
|
|
92
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _solana_wallet_adapter_base = require("@solana/wallet-adapter-base");
|
|
3
|
+
let _solana_web3_js = require("@solana/web3.js");
|
|
4
|
+
let _solana_wallet_standard_features = require("@solana/wallet-standard-features");
|
|
5
|
+
let _wallet_standard_core = require("@wallet-standard/core");
|
|
6
|
+
let _solana_mobile_wallet_standard_mobile = require("@solana-mobile/wallet-standard-mobile");
|
|
7
|
+
//#region src/base64Utils.ts
|
|
93
8
|
function fromUint8Array(byteArray) {
|
|
94
|
-
|
|
9
|
+
return window.btoa(String.fromCharCode.call(null, ...byteArray));
|
|
95
10
|
}
|
|
96
|
-
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/getIsSupported.ts
|
|
97
13
|
function getIsSupported() {
|
|
98
|
-
|
|
99
|
-
window.isSecureContext &&
|
|
100
|
-
typeof document !== 'undefined' &&
|
|
101
|
-
/android/i.test(navigator.userAgent));
|
|
14
|
+
return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
|
|
102
15
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const SolanaMobileWalletAdapterWalletName =
|
|
106
|
-
const SolanaMobileWalletAdapterRemoteWalletName =
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/adapter.ts
|
|
18
|
+
const SolanaMobileWalletAdapterWalletName = _solana_mobile_wallet_standard_mobile.SolanaMobileWalletAdapterWalletName;
|
|
19
|
+
const SolanaMobileWalletAdapterRemoteWalletName = _solana_mobile_wallet_standard_mobile.SolanaMobileWalletAdapterRemoteWalletName;
|
|
107
20
|
const SIGNATURE_LENGTH_IN_BYTES = 64;
|
|
108
21
|
function isVersionedTransaction(transaction) {
|
|
109
|
-
|
|
22
|
+
return "version" in transaction;
|
|
110
23
|
}
|
|
111
24
|
function chainOrClusterToChainId(chain) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return 'solana:devnet';
|
|
119
|
-
default:
|
|
120
|
-
return chain;
|
|
121
|
-
}
|
|
25
|
+
switch (chain) {
|
|
26
|
+
case "mainnet-beta": return "solana:mainnet";
|
|
27
|
+
case "testnet": return "solana:testnet";
|
|
28
|
+
case "devnet": return "solana:devnet";
|
|
29
|
+
default: return chain;
|
|
30
|
+
}
|
|
122
31
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
signTransaction(transaction) {
|
|
359
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
360
|
-
return yield __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_instances, "m", _BaseSolanaMobileWalletAdapter_runWithGuard).call(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
361
|
-
const [signedTransaction] = yield __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_instances, "m", _BaseSolanaMobileWalletAdapter_performSignTransactions).call(this, [transaction]);
|
|
362
|
-
return signedTransaction;
|
|
363
|
-
}));
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
signAllTransactions(transactions) {
|
|
367
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
368
|
-
return yield __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_instances, "m", _BaseSolanaMobileWalletAdapter_runWithGuard).call(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
369
|
-
const signedTransactions = yield __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_instances, "m", _BaseSolanaMobileWalletAdapter_performSignTransactions).call(this, transactions);
|
|
370
|
-
return signedTransactions;
|
|
371
|
-
}));
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
_BaseSolanaMobileWalletAdapter_wallet = new WeakMap(), _BaseSolanaMobileWalletAdapter_connecting = new WeakMap(), _BaseSolanaMobileWalletAdapter_readyState = new WeakMap(), _BaseSolanaMobileWalletAdapter_accountSelector = new WeakMap(), _BaseSolanaMobileWalletAdapter_selectedAccount = new WeakMap(), _BaseSolanaMobileWalletAdapter_publicKey = new WeakMap(), _BaseSolanaMobileWalletAdapter_handleChangeEvent = new WeakMap(), _BaseSolanaMobileWalletAdapter_instances = new WeakSet(), _BaseSolanaMobileWalletAdapter_connect = function _BaseSolanaMobileWalletAdapter_connect(autoConnect = false) {
|
|
376
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
377
|
-
if (this.connecting || this.connected) {
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
return yield __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_instances, "m", _BaseSolanaMobileWalletAdapter_runWithGuard).call(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
381
|
-
if (__classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_readyState, "f") !== walletAdapterBase.WalletReadyState.Installed && __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_readyState, "f") !== walletAdapterBase.WalletReadyState.Loadable) {
|
|
382
|
-
throw new walletAdapterBase.WalletNotReadyError();
|
|
383
|
-
}
|
|
384
|
-
__classPrivateFieldSet(this, _BaseSolanaMobileWalletAdapter_connecting, true, "f");
|
|
385
|
-
try {
|
|
386
|
-
yield __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_wallet, "f").features[StandardConnect].connect({ silent: autoConnect });
|
|
387
|
-
}
|
|
388
|
-
catch (e) {
|
|
389
|
-
throw new walletAdapterBase.WalletConnectionError((e instanceof Error && e.message) || 'Unknown error', e);
|
|
390
|
-
}
|
|
391
|
-
finally {
|
|
392
|
-
__classPrivateFieldSet(this, _BaseSolanaMobileWalletAdapter_connecting, false, "f");
|
|
393
|
-
}
|
|
394
|
-
}));
|
|
395
|
-
});
|
|
396
|
-
}, _BaseSolanaMobileWalletAdapter_declareWalletAsInstalled = function _BaseSolanaMobileWalletAdapter_declareWalletAsInstalled() {
|
|
397
|
-
if (__classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_readyState, "f") !== walletAdapterBase.WalletReadyState.Installed) {
|
|
398
|
-
this.emit('readyStateChange', (__classPrivateFieldSet(this, _BaseSolanaMobileWalletAdapter_readyState, walletAdapterBase.WalletReadyState.Installed, "f")));
|
|
399
|
-
}
|
|
400
|
-
}, _BaseSolanaMobileWalletAdapter_assertIsAuthorized = function _BaseSolanaMobileWalletAdapter_assertIsAuthorized() {
|
|
401
|
-
if (!__classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_wallet, "f").isAuthorized || !__classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_selectedAccount, "f"))
|
|
402
|
-
throw new walletAdapterBase.WalletNotConnectedError();
|
|
403
|
-
return __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_selectedAccount, "f");
|
|
404
|
-
}, _BaseSolanaMobileWalletAdapter_performSignTransactions = function _BaseSolanaMobileWalletAdapter_performSignTransactions(transactions) {
|
|
405
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
406
|
-
const account = __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_instances, "m", _BaseSolanaMobileWalletAdapter_assertIsAuthorized).call(this);
|
|
407
|
-
try {
|
|
408
|
-
if (walletStandardFeatures.SolanaSignTransaction in __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_wallet, "f").features) {
|
|
409
|
-
return __classPrivateFieldGet(this, _BaseSolanaMobileWalletAdapter_wallet, "f").features[walletStandardFeatures.SolanaSignTransaction].signTransaction(...transactions.map((value) => {
|
|
410
|
-
return { account, transaction: value.serialize() };
|
|
411
|
-
})).then((outputs) => {
|
|
412
|
-
return outputs.map((output) => {
|
|
413
|
-
const byteArray = output.signedTransaction;
|
|
414
|
-
const numSignatures = byteArray[0];
|
|
415
|
-
const messageOffset = numSignatures * SIGNATURE_LENGTH_IN_BYTES + 1;
|
|
416
|
-
const version = web3_js.VersionedMessage.deserializeMessageVersion(byteArray.slice(messageOffset, byteArray.length));
|
|
417
|
-
if (version === 'legacy') {
|
|
418
|
-
return web3_js.Transaction.from(byteArray);
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
return web3_js.VersionedTransaction.deserialize(byteArray);
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
else {
|
|
427
|
-
throw new Error('Connected wallet does not support signing transactions');
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
catch (error) {
|
|
431
|
-
throw new walletAdapterBase.WalletSignTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
}, _BaseSolanaMobileWalletAdapter_runWithGuard = function _BaseSolanaMobileWalletAdapter_runWithGuard(callback) {
|
|
435
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
436
|
-
try {
|
|
437
|
-
return yield callback();
|
|
438
|
-
}
|
|
439
|
-
catch (e) {
|
|
440
|
-
this.emit('error', e);
|
|
441
|
-
throw e;
|
|
442
|
-
}
|
|
443
|
-
});
|
|
32
|
+
var BaseSolanaMobileWalletAdapter = class extends _solana_wallet_adapter_base.BaseSignInMessageSignerWalletAdapter {
|
|
33
|
+
supportedTransactionVersions = new Set(["legacy", 0]);
|
|
34
|
+
name;
|
|
35
|
+
icon;
|
|
36
|
+
url;
|
|
37
|
+
#wallet;
|
|
38
|
+
#connecting = false;
|
|
39
|
+
#readyState = getIsSupported() ? _solana_wallet_adapter_base.WalletReadyState.Loadable : _solana_wallet_adapter_base.WalletReadyState.Unsupported;
|
|
40
|
+
#accountSelector;
|
|
41
|
+
#selectedAccount;
|
|
42
|
+
#publicKey;
|
|
43
|
+
#handleChangeEvent = async (properties) => {
|
|
44
|
+
if (properties.accounts && properties.accounts.length > 0) {
|
|
45
|
+
this.#declareWalletAsInstalled();
|
|
46
|
+
const nextSelectedAccount = await this.#accountSelector(properties.accounts);
|
|
47
|
+
if (nextSelectedAccount !== this.#selectedAccount) {
|
|
48
|
+
this.#selectedAccount = nextSelectedAccount;
|
|
49
|
+
this.#publicKey = void 0;
|
|
50
|
+
this.emit("connect", this.publicKey);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
constructor(wallet, config) {
|
|
55
|
+
super();
|
|
56
|
+
this.#accountSelector = async (accounts) => {
|
|
57
|
+
const selectedBase64EncodedAddress = await config.addressSelector.select(accounts.map(({ publicKey }) => fromUint8Array(new Uint8Array(publicKey))));
|
|
58
|
+
return accounts.find(({ publicKey }) => fromUint8Array(new Uint8Array(publicKey)) === selectedBase64EncodedAddress) ?? accounts[0];
|
|
59
|
+
};
|
|
60
|
+
this.#wallet = wallet;
|
|
61
|
+
this.#wallet.features[_wallet_standard_core.StandardEvents].on("change", this.#handleChangeEvent);
|
|
62
|
+
this.name = this.#wallet.name;
|
|
63
|
+
this.icon = this.#wallet.icon;
|
|
64
|
+
this.url = this.#wallet.url;
|
|
65
|
+
}
|
|
66
|
+
get publicKey() {
|
|
67
|
+
if (!this.#publicKey && this.#selectedAccount) try {
|
|
68
|
+
this.#publicKey = new _solana_web3_js.PublicKey(this.#selectedAccount.publicKey);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
throw new _solana_wallet_adapter_base.WalletPublicKeyError(e instanceof Error && e?.message || "Unknown error", e);
|
|
71
|
+
}
|
|
72
|
+
return this.#publicKey ?? null;
|
|
73
|
+
}
|
|
74
|
+
get connected() {
|
|
75
|
+
return this.#wallet.connected;
|
|
76
|
+
}
|
|
77
|
+
get connecting() {
|
|
78
|
+
return this.#connecting;
|
|
79
|
+
}
|
|
80
|
+
get readyState() {
|
|
81
|
+
return this.#readyState;
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated Use `autoConnect()` instead. */
|
|
84
|
+
async autoConnect_DO_NOT_USE_OR_YOU_WILL_BE_FIRED() {
|
|
85
|
+
return await this.autoConnect();
|
|
86
|
+
}
|
|
87
|
+
async autoConnect() {
|
|
88
|
+
this.#connect(true);
|
|
89
|
+
}
|
|
90
|
+
async connect() {
|
|
91
|
+
this.#connect();
|
|
92
|
+
}
|
|
93
|
+
async #connect(autoConnect = false) {
|
|
94
|
+
if (this.connecting || this.connected) return;
|
|
95
|
+
return await this.#runWithGuard(async () => {
|
|
96
|
+
if (this.#readyState !== _solana_wallet_adapter_base.WalletReadyState.Installed && this.#readyState !== _solana_wallet_adapter_base.WalletReadyState.Loadable) throw new _solana_wallet_adapter_base.WalletNotReadyError();
|
|
97
|
+
this.#connecting = true;
|
|
98
|
+
try {
|
|
99
|
+
await this.#wallet.features[_wallet_standard_core.StandardConnect].connect({ silent: autoConnect });
|
|
100
|
+
} catch (e) {
|
|
101
|
+
throw new _solana_wallet_adapter_base.WalletConnectionError(e instanceof Error && e.message || "Unknown error", e);
|
|
102
|
+
} finally {
|
|
103
|
+
this.#connecting = false;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** @deprecated Use `connect()` or `autoConnect()` instead. */
|
|
108
|
+
async performAuthorization(signInPayload) {
|
|
109
|
+
try {
|
|
110
|
+
const cachedAuthorizationResult = await this.#wallet.cachedAuthorizationResult;
|
|
111
|
+
if (cachedAuthorizationResult) {
|
|
112
|
+
await this.#wallet.features[_wallet_standard_core.StandardConnect].connect({ silent: true });
|
|
113
|
+
return cachedAuthorizationResult;
|
|
114
|
+
}
|
|
115
|
+
if (signInPayload) await this.#wallet.features[_solana_wallet_standard_features.SolanaSignIn].signIn(signInPayload);
|
|
116
|
+
else await this.#wallet.features[_wallet_standard_core.StandardConnect].connect();
|
|
117
|
+
return await await this.#wallet.cachedAuthorizationResult;
|
|
118
|
+
} catch (e) {
|
|
119
|
+
throw new _solana_wallet_adapter_base.WalletConnectionError(e instanceof Error && e.message || "Unknown error", e);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async disconnect() {
|
|
123
|
+
return await this.#runWithGuard(async () => {
|
|
124
|
+
this.#connecting = false;
|
|
125
|
+
this.#publicKey = void 0;
|
|
126
|
+
this.#selectedAccount = void 0;
|
|
127
|
+
await this.#wallet.features[_wallet_standard_core.StandardDisconnect].disconnect();
|
|
128
|
+
this.emit("disconnect");
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
async signIn(input) {
|
|
132
|
+
return this.#runWithGuard(async () => {
|
|
133
|
+
if (this.#readyState !== _solana_wallet_adapter_base.WalletReadyState.Installed && this.#readyState !== _solana_wallet_adapter_base.WalletReadyState.Loadable) throw new _solana_wallet_adapter_base.WalletNotReadyError();
|
|
134
|
+
this.#connecting = true;
|
|
135
|
+
try {
|
|
136
|
+
const outputs = await this.#wallet.features[_solana_wallet_standard_features.SolanaSignIn].signIn({
|
|
137
|
+
...input,
|
|
138
|
+
domain: input?.domain ?? window.location.host
|
|
139
|
+
});
|
|
140
|
+
if (outputs.length > 0) return outputs[0];
|
|
141
|
+
else throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
142
|
+
} catch (e) {
|
|
143
|
+
throw new _solana_wallet_adapter_base.WalletConnectionError(e instanceof Error && e.message || "Unknown error", e);
|
|
144
|
+
} finally {
|
|
145
|
+
this.#connecting = false;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async signMessage(message) {
|
|
150
|
+
return await this.#runWithGuard(async () => {
|
|
151
|
+
const account = this.#assertIsAuthorized();
|
|
152
|
+
try {
|
|
153
|
+
return (await this.#wallet.features[_solana_wallet_standard_features.SolanaSignMessage].signMessage({
|
|
154
|
+
account,
|
|
155
|
+
message
|
|
156
|
+
}))[0].signature;
|
|
157
|
+
} catch (error) {
|
|
158
|
+
throw new _solana_wallet_adapter_base.WalletSignMessageError(error?.message, error);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
async sendTransaction(transaction, connection, options) {
|
|
163
|
+
return await this.#runWithGuard(async () => {
|
|
164
|
+
const account = this.#assertIsAuthorized();
|
|
165
|
+
try {
|
|
166
|
+
function getTargetCommitment() {
|
|
167
|
+
let targetCommitment;
|
|
168
|
+
switch (connection.commitment) {
|
|
169
|
+
case "confirmed":
|
|
170
|
+
case "finalized":
|
|
171
|
+
case "processed":
|
|
172
|
+
targetCommitment = connection.commitment;
|
|
173
|
+
break;
|
|
174
|
+
default: targetCommitment = "finalized";
|
|
175
|
+
}
|
|
176
|
+
let targetPreflightCommitment;
|
|
177
|
+
switch (options?.preflightCommitment) {
|
|
178
|
+
case "confirmed":
|
|
179
|
+
case "finalized":
|
|
180
|
+
case "processed":
|
|
181
|
+
targetPreflightCommitment = options.preflightCommitment;
|
|
182
|
+
break;
|
|
183
|
+
case void 0:
|
|
184
|
+
targetPreflightCommitment = targetCommitment;
|
|
185
|
+
break;
|
|
186
|
+
default: targetPreflightCommitment = "finalized";
|
|
187
|
+
}
|
|
188
|
+
return (targetPreflightCommitment === "finalized" ? 2 : targetPreflightCommitment === "confirmed" ? 1 : 0) < (targetCommitment === "finalized" ? 2 : targetCommitment === "confirmed" ? 1 : 0) ? targetPreflightCommitment : targetCommitment;
|
|
189
|
+
}
|
|
190
|
+
if (_solana_wallet_standard_features.SolanaSignAndSendTransaction in this.#wallet.features) {
|
|
191
|
+
const chain = chainOrClusterToChainId(this.#wallet.currentAuthorization.chain);
|
|
192
|
+
const [signature] = (await this.#wallet.features[_solana_wallet_standard_features.SolanaSignAndSendTransaction].signAndSendTransaction({
|
|
193
|
+
account,
|
|
194
|
+
transaction: transaction.serialize(),
|
|
195
|
+
chain,
|
|
196
|
+
options: options ? {
|
|
197
|
+
skipPreflight: options.skipPreflight,
|
|
198
|
+
maxRetries: options.maxRetries
|
|
199
|
+
} : void 0
|
|
200
|
+
})).map((output) => {
|
|
201
|
+
return fromUint8Array(output.signature);
|
|
202
|
+
});
|
|
203
|
+
return signature;
|
|
204
|
+
} else {
|
|
205
|
+
const [signedTransaction] = await this.#performSignTransactions([transaction]);
|
|
206
|
+
if (isVersionedTransaction(signedTransaction)) return await connection.sendTransaction(signedTransaction);
|
|
207
|
+
else {
|
|
208
|
+
const serializedTransaction = signedTransaction.serialize();
|
|
209
|
+
return await connection.sendRawTransaction(serializedTransaction, {
|
|
210
|
+
...options,
|
|
211
|
+
preflightCommitment: getTargetCommitment()
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
} catch (error) {
|
|
216
|
+
throw new _solana_wallet_adapter_base.WalletSendTransactionError(error?.message, error);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
async signTransaction(transaction) {
|
|
221
|
+
return await this.#runWithGuard(async () => {
|
|
222
|
+
const [signedTransaction] = await this.#performSignTransactions([transaction]);
|
|
223
|
+
return signedTransaction;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
async signAllTransactions(transactions) {
|
|
227
|
+
return await this.#runWithGuard(async () => {
|
|
228
|
+
return await this.#performSignTransactions(transactions);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
#declareWalletAsInstalled() {
|
|
232
|
+
if (this.#readyState !== _solana_wallet_adapter_base.WalletReadyState.Installed) this.emit("readyStateChange", this.#readyState = _solana_wallet_adapter_base.WalletReadyState.Installed);
|
|
233
|
+
}
|
|
234
|
+
#assertIsAuthorized() {
|
|
235
|
+
if (!this.#wallet.isAuthorized || !this.#selectedAccount) throw new _solana_wallet_adapter_base.WalletNotConnectedError();
|
|
236
|
+
return this.#selectedAccount;
|
|
237
|
+
}
|
|
238
|
+
async #performSignTransactions(transactions) {
|
|
239
|
+
const account = this.#assertIsAuthorized();
|
|
240
|
+
try {
|
|
241
|
+
if (_solana_wallet_standard_features.SolanaSignTransaction in this.#wallet.features) return this.#wallet.features[_solana_wallet_standard_features.SolanaSignTransaction].signTransaction(...transactions.map((value) => {
|
|
242
|
+
return {
|
|
243
|
+
account,
|
|
244
|
+
transaction: value.serialize()
|
|
245
|
+
};
|
|
246
|
+
})).then((outputs) => {
|
|
247
|
+
return outputs.map((output) => {
|
|
248
|
+
const byteArray = output.signedTransaction;
|
|
249
|
+
const messageOffset = byteArray[0] * SIGNATURE_LENGTH_IN_BYTES + 1;
|
|
250
|
+
if (_solana_web3_js.VersionedMessage.deserializeMessageVersion(byteArray.slice(messageOffset, byteArray.length)) === "legacy") return _solana_web3_js.Transaction.from(byteArray);
|
|
251
|
+
else return _solana_web3_js.VersionedTransaction.deserialize(byteArray);
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
else throw new Error("Connected wallet does not support signing transactions");
|
|
255
|
+
} catch (error) {
|
|
256
|
+
throw new _solana_wallet_adapter_base.WalletSignTransactionError(error?.message, error);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
async #runWithGuard(callback) {
|
|
260
|
+
try {
|
|
261
|
+
return await callback();
|
|
262
|
+
} catch (e) {
|
|
263
|
+
this.emit("error", e);
|
|
264
|
+
throw e;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
444
267
|
};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
268
|
+
var LocalSolanaMobileWalletAdapter = class extends BaseSolanaMobileWalletAdapter {
|
|
269
|
+
constructor(config) {
|
|
270
|
+
const chain = chainOrClusterToChainId(config.chain ?? config.cluster);
|
|
271
|
+
super(new _solana_mobile_wallet_standard_mobile.LocalSolanaMobileWalletAdapterWallet({
|
|
272
|
+
appIdentity: config.appIdentity,
|
|
273
|
+
authorizationCache: {
|
|
274
|
+
set: config.authorizationResultCache.set,
|
|
275
|
+
get: async () => {
|
|
276
|
+
return await config.authorizationResultCache.get();
|
|
277
|
+
},
|
|
278
|
+
clear: config.authorizationResultCache.clear
|
|
279
|
+
},
|
|
280
|
+
chains: [chain],
|
|
281
|
+
chainSelector: (0, _solana_mobile_wallet_standard_mobile.createDefaultChainSelector)(),
|
|
282
|
+
onWalletNotFound: async () => {
|
|
283
|
+
config.onWalletNotFound(this);
|
|
284
|
+
}
|
|
285
|
+
}), {
|
|
286
|
+
addressSelector: config.addressSelector,
|
|
287
|
+
chain
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
var RemoteSolanaMobileWalletAdapter = class extends BaseSolanaMobileWalletAdapter {
|
|
292
|
+
constructor(config) {
|
|
293
|
+
const chain = chainOrClusterToChainId(config.chain);
|
|
294
|
+
super(new _solana_mobile_wallet_standard_mobile.RemoteSolanaMobileWalletAdapterWallet({
|
|
295
|
+
appIdentity: config.appIdentity,
|
|
296
|
+
authorizationCache: {
|
|
297
|
+
set: config.authorizationResultCache.set,
|
|
298
|
+
get: async () => {
|
|
299
|
+
return await config.authorizationResultCache.get();
|
|
300
|
+
},
|
|
301
|
+
clear: config.authorizationResultCache.clear
|
|
302
|
+
},
|
|
303
|
+
chains: [chain],
|
|
304
|
+
chainSelector: (0, _solana_mobile_wallet_standard_mobile.createDefaultChainSelector)(),
|
|
305
|
+
remoteHostAuthority: config.remoteHostAuthority,
|
|
306
|
+
onWalletNotFound: async () => {
|
|
307
|
+
config.onWalletNotFound(this);
|
|
308
|
+
}
|
|
309
|
+
}), {
|
|
310
|
+
addressSelector: config.addressSelector,
|
|
311
|
+
chain
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
var SolanaMobileWalletAdapter = class extends LocalSolanaMobileWalletAdapter {};
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/createDefaultAddressSelector.ts
|
|
496
318
|
function createDefaultAddressSelector() {
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
return addresses[0];
|
|
501
|
-
});
|
|
502
|
-
},
|
|
503
|
-
};
|
|
319
|
+
return { async select(addresses) {
|
|
320
|
+
return addresses[0];
|
|
321
|
+
} };
|
|
504
322
|
}
|
|
505
|
-
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/createDefaultAuthorizationResultCache.ts
|
|
506
325
|
function createDefaultAuthorizationResultCache() {
|
|
507
|
-
|
|
326
|
+
return (0, _solana_mobile_wallet_standard_mobile.createDefaultAuthorizationCache)();
|
|
508
327
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
});
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/createDefaultWalletNotFoundHandler.ts
|
|
330
|
+
async function defaultWalletNotFoundHandler(mobileWalletAdapter) {
|
|
331
|
+
return (0, _solana_mobile_wallet_standard_mobile.defaultErrorModalWalletNotFoundHandler)();
|
|
514
332
|
}
|
|
515
333
|
function createDefaultWalletNotFoundHandler() {
|
|
516
|
-
|
|
334
|
+
return defaultWalletNotFoundHandler;
|
|
517
335
|
}
|
|
518
|
-
|
|
336
|
+
//#endregion
|
|
519
337
|
exports.LocalSolanaMobileWalletAdapter = LocalSolanaMobileWalletAdapter;
|
|
520
338
|
exports.RemoteSolanaMobileWalletAdapter = RemoteSolanaMobileWalletAdapter;
|
|
521
339
|
exports.SolanaMobileWalletAdapter = SolanaMobileWalletAdapter;
|
|
@@ -524,3 +342,5 @@ exports.SolanaMobileWalletAdapterWalletName = SolanaMobileWalletAdapterWalletNam
|
|
|
524
342
|
exports.createDefaultAddressSelector = createDefaultAddressSelector;
|
|
525
343
|
exports.createDefaultAuthorizationResultCache = createDefaultAuthorizationResultCache;
|
|
526
344
|
exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
|
|
345
|
+
|
|
346
|
+
//# sourceMappingURL=index.js.map
|