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