@pooflabs/web 0.0.81 → 0.0.82
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/{index-B2WGCssJ.js → index-BicMkamC.js} +221 -116
- package/dist/index-BicMkamC.js.map +1 -0
- package/dist/{index-nt_HQVrk.esm.js → index-BsY_Lgiu.esm.js} +222 -116
- package/dist/index-BsY_Lgiu.esm.js.map +1 -0
- package/dist/index-CHWmdXHE.esm.js +6 -0
- package/dist/index-CHWmdXHE.esm.js.map +1 -0
- package/dist/{index-CjHbp7Dq.esm.js → index-CK_2Zn89.esm.js} +135 -8
- package/dist/index-CK_2Zn89.esm.js.map +1 -0
- package/dist/{index-DXPkkq81.js → index-Ci3m3diI.js} +134 -7
- package/dist/index-Ci3m3diI.js.map +1 -0
- package/dist/{index-dcJIjFrs.esm.js → index-DWf2AOhe.esm.js} +134 -7
- package/dist/index-DWf2AOhe.esm.js.map +1 -0
- package/dist/{index-D_DiP8XQ.js → index-DlKo76M3.js} +135 -8
- package/dist/index-DlKo76M3.js.map +1 -0
- package/dist/index-Dz0bPXrU.js +8 -0
- package/dist/index-Dz0bPXrU.js.map +1 -0
- package/dist/{index.browser-CT6PUv9G.js → index.browser-BkMiHSON.js} +1366 -1569
- package/dist/index.browser-BkMiHSON.js.map +1 -0
- package/dist/index.browser-C-_FEr5M.esm.js +1134 -0
- package/dist/index.browser-C-_FEr5M.esm.js.map +1 -0
- package/dist/index.browser-C9bFQZyQ.esm.js +1373 -0
- package/dist/index.browser-C9bFQZyQ.esm.js.map +1 -0
- package/dist/{index.browser-BNdFfyIg.esm.js → index.browser-DCOvqSUT.esm.js} +1366 -1569
- package/dist/index.browser-DCOvqSUT.esm.js.map +1 -0
- package/dist/index.browser-Dbq5Qf1G.esm.js +242 -0
- package/dist/index.browser-Dbq5Qf1G.esm.js.map +1 -0
- package/dist/index.browser-Df7yN8D5.js +245 -0
- package/dist/index.browser-Df7yN8D5.js.map +1 -0
- package/dist/index.browser-DjEZSiqI.js +1137 -0
- package/dist/index.browser-DjEZSiqI.js.map +1 -0
- package/dist/index.browser-dszs5oe5.js +1376 -0
- package/dist/index.browser-dszs5oe5.js.map +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{index.native-CyA-RdvW.js → index.native-11supFRU.js} +2683 -207
- package/dist/index.native-11supFRU.js.map +1 -0
- package/dist/{index.native-BqYr--vb.esm.js → index.native-CLaHKvDv.esm.js} +2682 -207
- package/dist/index.native-CLaHKvDv.esm.js.map +1 -0
- package/dist/index.native.esm.js +1 -1
- package/dist/index.native.js +1 -1
- package/dist/{phantom-wallet-provider-K2V96G-G.esm.js → phantom-wallet-provider-BN47klTp.esm.js} +4 -4
- package/dist/{phantom-wallet-provider-K2V96G-G.esm.js.map → phantom-wallet-provider-BN47klTp.esm.js.map} +1 -1
- package/dist/{phantom-wallet-provider-DWCaMkyz.js → phantom-wallet-provider-Xb070-O6.js} +4 -4
- package/dist/{phantom-wallet-provider-DWCaMkyz.js.map → phantom-wallet-provider-Xb070-O6.js.map} +1 -1
- package/dist/{privy-wallet-provider-BMg_S_d0.js → privy-wallet-provider-Ch22rj_G.js} +4 -4
- package/dist/privy-wallet-provider-Ch22rj_G.js.map +1 -0
- package/dist/{privy-wallet-provider-DoX8q99w.esm.js → privy-wallet-provider-DUJS5viU.esm.js} +4 -4
- package/dist/privy-wallet-provider-DUJS5viU.esm.js.map +1 -0
- package/dist/{solana-mobile-wallet-provider-Cmphb3oB.esm.js → solana-mobile-wallet-provider-BF04Xp8P.esm.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-Cmphb3oB.esm.js.map → solana-mobile-wallet-provider-BF04Xp8P.esm.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-t22Ie8lY.js → solana-mobile-wallet-provider-BXm94fqW.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-t22Ie8lY.js.map → solana-mobile-wallet-provider-BXm94fqW.js.map} +1 -1
- package/package.json +2 -2
- package/dist/index-B2WGCssJ.js.map +0 -1
- package/dist/index-Bdcc5821.js +0 -2375
- package/dist/index-Bdcc5821.js.map +0 -1
- package/dist/index-CjHbp7Dq.esm.js.map +0 -1
- package/dist/index-CrOVJFX9.esm.js +0 -2373
- package/dist/index-CrOVJFX9.esm.js.map +0 -1
- package/dist/index-DXPkkq81.js.map +0 -1
- package/dist/index-D_DiP8XQ.js.map +0 -1
- package/dist/index-dcJIjFrs.esm.js.map +0 -1
- package/dist/index-nt_HQVrk.esm.js.map +0 -1
- package/dist/index.browser-BNdFfyIg.esm.js.map +0 -1
- package/dist/index.browser-CT6PUv9G.js.map +0 -1
- package/dist/index.browser-Cy21yaX0.esm.js +0 -1096
- package/dist/index.browser-Cy21yaX0.esm.js.map +0 -1
- package/dist/index.browser-OvGNsMPu.esm.js +0 -1002
- package/dist/index.browser-OvGNsMPu.esm.js.map +0 -1
- package/dist/index.browser-ZD7Tz2bn.js +0 -1099
- package/dist/index.browser-ZD7Tz2bn.js.map +0 -1
- package/dist/index.browser-d0PlOXpF.js +0 -105
- package/dist/index.browser-d0PlOXpF.js.map +0 -1
- package/dist/index.browser-pE1s68e9.esm.js +0 -102
- package/dist/index.browser-pE1s68e9.esm.js.map +0 -1
- package/dist/index.browser-vuTr40so.js +0 -1008
- package/dist/index.browser-vuTr40so.js.map +0 -1
- package/dist/index.native-BqYr--vb.esm.js.map +0 -1
- package/dist/index.native-CyA-RdvW.js.map +0 -1
- package/dist/privy-wallet-provider-BMg_S_d0.js.map +0 -1
- package/dist/privy-wallet-provider-DoX8q99w.esm.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { g as getDefaultExportFromCjs } from './index-BsY_Lgiu.esm.js';
|
|
2
|
+
import { s as startRemoteScenario, t as transact } from './index.browser-C-_FEr5M.esm.js';
|
|
3
3
|
import 'axios';
|
|
4
4
|
import '@solana/web3.js';
|
|
5
5
|
import '@coral-xyz/anchor';
|
|
@@ -20,15 +20,6 @@ const SolanaSignMessage = 'solana:signMessage';
|
|
|
20
20
|
/** Name of the feature. */
|
|
21
21
|
const SolanaSignTransaction = 'solana:signTransaction';
|
|
22
22
|
|
|
23
|
-
/** Name of the feature. */
|
|
24
|
-
const StandardConnect = 'standard:connect';
|
|
25
|
-
|
|
26
|
-
/** Name of the feature. */
|
|
27
|
-
const StandardDisconnect = 'standard:disconnect';
|
|
28
|
-
|
|
29
|
-
/** Name of the feature. */
|
|
30
|
-
const StandardEvents = 'standard:events';
|
|
31
|
-
|
|
32
23
|
var browser = {};
|
|
33
24
|
|
|
34
25
|
var canPromise;
|
|
@@ -3101,239 +3092,200 @@ function requireBrowser () {
|
|
|
3101
3092
|
var browserExports = requireBrowser();
|
|
3102
3093
|
var QRCode = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
|
|
3103
3094
|
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
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");
|
|
3107
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
3108
|
-
};
|
|
3109
|
-
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3110
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3111
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
3112
|
-
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");
|
|
3113
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
3114
|
-
};
|
|
3115
|
-
var _RegisterWalletEvent_detail;
|
|
3116
|
-
/**
|
|
3117
|
-
* Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
|
|
3118
|
-
*
|
|
3119
|
-
* This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
|
|
3120
|
-
* ready to be registered.
|
|
3121
|
-
*
|
|
3122
|
-
* This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
|
|
3123
|
-
* the app that the app is ready to register the Wallet.
|
|
3124
|
-
*
|
|
3125
|
-
* This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
|
|
3126
|
-
* as the app is ready whether the Wallet loads before or after the app.
|
|
3127
|
-
*
|
|
3128
|
-
* @param wallet Wallet to register.
|
|
3129
|
-
*
|
|
3130
|
-
* @group Wallet
|
|
3131
|
-
*/
|
|
3132
|
-
function registerWallet(wallet) {
|
|
3133
|
-
const callback = ({ register }) => register(wallet);
|
|
3134
|
-
try {
|
|
3135
|
-
window.dispatchEvent(new RegisterWalletEvent(callback));
|
|
3136
|
-
}
|
|
3137
|
-
catch (error) {
|
|
3138
|
-
console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
|
|
3139
|
-
}
|
|
3140
|
-
try {
|
|
3141
|
-
window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
|
|
3142
|
-
}
|
|
3143
|
-
catch (error) {
|
|
3144
|
-
console.error('wallet-standard:app-ready event listener could not be added\n', error);
|
|
3145
|
-
}
|
|
3146
|
-
}
|
|
3147
|
-
class RegisterWalletEvent extends Event {
|
|
3148
|
-
get detail() {
|
|
3149
|
-
return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
|
|
3150
|
-
}
|
|
3151
|
-
get type() {
|
|
3152
|
-
return 'wallet-standard:register-wallet';
|
|
3153
|
-
}
|
|
3154
|
-
constructor(callback) {
|
|
3155
|
-
super('wallet-standard:register-wallet', {
|
|
3156
|
-
bubbles: false,
|
|
3157
|
-
cancelable: false,
|
|
3158
|
-
composed: false,
|
|
3159
|
-
});
|
|
3160
|
-
_RegisterWalletEvent_detail.set(this, void 0);
|
|
3161
|
-
__classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
|
|
3162
|
-
}
|
|
3163
|
-
/** @deprecated */
|
|
3164
|
-
preventDefault() {
|
|
3165
|
-
throw new Error('preventDefault cannot be called');
|
|
3166
|
-
}
|
|
3167
|
-
/** @deprecated */
|
|
3168
|
-
stopImmediatePropagation() {
|
|
3169
|
-
throw new Error('stopImmediatePropagation cannot be called');
|
|
3170
|
-
}
|
|
3171
|
-
/** @deprecated */
|
|
3172
|
-
stopPropagation() {
|
|
3173
|
-
throw new Error('stopPropagation cannot be called');
|
|
3174
|
-
}
|
|
3175
|
-
}
|
|
3176
|
-
_RegisterWalletEvent_detail = new WeakMap();
|
|
3095
|
+
/** Name of the feature. */
|
|
3096
|
+
const StandardConnect = 'standard:connect';
|
|
3177
3097
|
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
return window.btoa(String.fromCharCode.call(null, ...byteArray));
|
|
3181
|
-
}
|
|
3182
|
-
function toUint8Array(base64EncodedByteArray) {
|
|
3183
|
-
return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
|
|
3184
|
-
}
|
|
3185
|
-
//#endregion
|
|
3186
|
-
//#region src/embedded-modal/loadingSpinner.ts
|
|
3187
|
-
const modalHtml$1 = `
|
|
3188
|
-
<div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
3189
|
-
<div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
|
|
3190
|
-
<div class="mobile-wallet-adapter-embedded-loading-container">
|
|
3191
|
-
<div class="mobile-wallet-adapter-embedded-loading-animation"></div>
|
|
3192
|
-
</div>
|
|
3193
|
-
</div>
|
|
3194
|
-
`;
|
|
3195
|
-
const css$6 = `
|
|
3196
|
-
.mobile-wallet-adapter-embedded-loading-indicator {
|
|
3197
|
-
display: flex; /* Use flexbox to center content */
|
|
3198
|
-
justify-content: center; /* Center horizontally */
|
|
3199
|
-
align-items: start; /* Center vertically */
|
|
3200
|
-
position: fixed; /* Stay in place */
|
|
3201
|
-
z-index: 1; /* Sit on top */
|
|
3202
|
-
left: 0;
|
|
3203
|
-
top: 0;
|
|
3204
|
-
width: 100%; /* Full width */
|
|
3205
|
-
height: 100%; /* Full height */
|
|
3206
|
-
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
|
3207
|
-
overflow-y: auto; /* enable scrolling */
|
|
3208
|
-
}
|
|
3098
|
+
/** Name of the feature. */
|
|
3099
|
+
const StandardDisconnect = 'standard:disconnect';
|
|
3209
3100
|
|
|
3210
|
-
.
|
|
3211
|
-
|
|
3212
|
-
|
|
3101
|
+
/** Name of the feature. */
|
|
3102
|
+
const StandardEvents = 'standard:events';
|
|
3103
|
+
|
|
3104
|
+
var src;
|
|
3105
|
+
var hasRequiredSrc;
|
|
3106
|
+
|
|
3107
|
+
function requireSrc () {
|
|
3108
|
+
if (hasRequiredSrc) return src;
|
|
3109
|
+
hasRequiredSrc = 1;
|
|
3110
|
+
// base-x encoding / decoding
|
|
3111
|
+
// Copyright (c) 2018 base-x contributors
|
|
3112
|
+
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
3113
|
+
// Distributed under the MIT software license, see the accompanying
|
|
3114
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
3115
|
+
function base (ALPHABET) {
|
|
3116
|
+
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
3117
|
+
var BASE_MAP = new Uint8Array(256);
|
|
3118
|
+
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
3119
|
+
BASE_MAP[j] = 255;
|
|
3120
|
+
}
|
|
3121
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
|
3122
|
+
var x = ALPHABET.charAt(i);
|
|
3123
|
+
var xc = x.charCodeAt(0);
|
|
3124
|
+
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
3125
|
+
BASE_MAP[xc] = i;
|
|
3126
|
+
}
|
|
3127
|
+
var BASE = ALPHABET.length;
|
|
3128
|
+
var LEADER = ALPHABET.charAt(0);
|
|
3129
|
+
var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
3130
|
+
var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
3131
|
+
function encode (source) {
|
|
3132
|
+
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
3133
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
3134
|
+
} else if (Array.isArray(source)) {
|
|
3135
|
+
source = Uint8Array.from(source);
|
|
3136
|
+
}
|
|
3137
|
+
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
3138
|
+
if (source.length === 0) { return '' }
|
|
3139
|
+
// Skip & count leading zeroes.
|
|
3140
|
+
var zeroes = 0;
|
|
3141
|
+
var length = 0;
|
|
3142
|
+
var pbegin = 0;
|
|
3143
|
+
var pend = source.length;
|
|
3144
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
3145
|
+
pbegin++;
|
|
3146
|
+
zeroes++;
|
|
3147
|
+
}
|
|
3148
|
+
// Allocate enough space in big-endian base58 representation.
|
|
3149
|
+
var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
3150
|
+
var b58 = new Uint8Array(size);
|
|
3151
|
+
// Process the bytes.
|
|
3152
|
+
while (pbegin !== pend) {
|
|
3153
|
+
var carry = source[pbegin];
|
|
3154
|
+
// Apply "b58 = b58 * 256 + ch".
|
|
3155
|
+
var i = 0;
|
|
3156
|
+
for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
3157
|
+
carry += (256 * b58[it1]) >>> 0;
|
|
3158
|
+
b58[it1] = (carry % BASE) >>> 0;
|
|
3159
|
+
carry = (carry / BASE) >>> 0;
|
|
3160
|
+
}
|
|
3161
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
3162
|
+
length = i;
|
|
3163
|
+
pbegin++;
|
|
3164
|
+
}
|
|
3165
|
+
// Skip leading zeroes in base58 result.
|
|
3166
|
+
var it2 = size - length;
|
|
3167
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
3168
|
+
it2++;
|
|
3169
|
+
}
|
|
3170
|
+
// Translate the result into a string.
|
|
3171
|
+
var str = LEADER.repeat(zeroes);
|
|
3172
|
+
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
3173
|
+
return str
|
|
3174
|
+
}
|
|
3175
|
+
function decodeUnsafe (source) {
|
|
3176
|
+
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
3177
|
+
if (source.length === 0) { return new Uint8Array() }
|
|
3178
|
+
var psz = 0;
|
|
3179
|
+
// Skip and count leading '1's.
|
|
3180
|
+
var zeroes = 0;
|
|
3181
|
+
var length = 0;
|
|
3182
|
+
while (source[psz] === LEADER) {
|
|
3183
|
+
zeroes++;
|
|
3184
|
+
psz++;
|
|
3185
|
+
}
|
|
3186
|
+
// Allocate enough space in big-endian base256 representation.
|
|
3187
|
+
var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
3188
|
+
var b256 = new Uint8Array(size);
|
|
3189
|
+
// Process the characters.
|
|
3190
|
+
while (source[psz]) {
|
|
3191
|
+
// Find code of next character
|
|
3192
|
+
var charCode = source.charCodeAt(psz);
|
|
3193
|
+
// Base map can not be indexed using char code
|
|
3194
|
+
if (charCode > 255) { return }
|
|
3195
|
+
// Decode character
|
|
3196
|
+
var carry = BASE_MAP[charCode];
|
|
3197
|
+
// Invalid character
|
|
3198
|
+
if (carry === 255) { return }
|
|
3199
|
+
var i = 0;
|
|
3200
|
+
for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
3201
|
+
carry += (BASE * b256[it3]) >>> 0;
|
|
3202
|
+
b256[it3] = (carry % 256) >>> 0;
|
|
3203
|
+
carry = (carry / 256) >>> 0;
|
|
3204
|
+
}
|
|
3205
|
+
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
3206
|
+
length = i;
|
|
3207
|
+
psz++;
|
|
3208
|
+
}
|
|
3209
|
+
// Skip leading zeroes in b256.
|
|
3210
|
+
var it4 = size - length;
|
|
3211
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
3212
|
+
it4++;
|
|
3213
|
+
}
|
|
3214
|
+
var vch = new Uint8Array(zeroes + (size - it4));
|
|
3215
|
+
var j = zeroes;
|
|
3216
|
+
while (it4 !== size) {
|
|
3217
|
+
vch[j++] = b256[it4++];
|
|
3218
|
+
}
|
|
3219
|
+
return vch
|
|
3220
|
+
}
|
|
3221
|
+
function decode (string) {
|
|
3222
|
+
var buffer = decodeUnsafe(string);
|
|
3223
|
+
if (buffer) { return buffer }
|
|
3224
|
+
throw new Error('Non-base' + BASE + ' character')
|
|
3225
|
+
}
|
|
3226
|
+
return {
|
|
3227
|
+
encode: encode,
|
|
3228
|
+
decodeUnsafe: decodeUnsafe,
|
|
3229
|
+
decode: decode
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
src = base;
|
|
3233
|
+
return src;
|
|
3213
3234
|
}
|
|
3214
3235
|
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
animation: dot-typing 1.5s infinite linear;
|
|
3236
|
+
var bs58;
|
|
3237
|
+
var hasRequiredBs58;
|
|
3238
|
+
|
|
3239
|
+
function requireBs58 () {
|
|
3240
|
+
if (hasRequiredBs58) return bs58;
|
|
3241
|
+
hasRequiredBs58 = 1;
|
|
3242
|
+
const basex = requireSrc();
|
|
3243
|
+
const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
3244
|
+
|
|
3245
|
+
bs58 = basex(ALPHABET);
|
|
3246
|
+
return bs58;
|
|
3227
3247
|
}
|
|
3228
3248
|
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
}
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3249
|
+
var bs58Exports = requireBs58();
|
|
3250
|
+
var base58 = /*@__PURE__*/getDefaultExportFromCjs(bs58Exports);
|
|
3251
|
+
|
|
3252
|
+
/******************************************************************************
|
|
3253
|
+
Copyright (c) Microsoft Corporation.
|
|
3254
|
+
|
|
3255
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
3256
|
+
purpose with or without fee is hereby granted.
|
|
3257
|
+
|
|
3258
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
3259
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
3260
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
3261
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
3262
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
3263
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
3264
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
3265
|
+
***************************************************************************** */
|
|
3266
|
+
|
|
3267
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
3268
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3269
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
3270
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
3271
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
3272
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
3273
|
+
step((generator = generator.apply(thisArg, [])).next());
|
|
3274
|
+
});
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
function __classPrivateFieldGet$1(receiver, state, kind, f) {
|
|
3278
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3279
|
+
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");
|
|
3280
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
function __classPrivateFieldSet$1(receiver, state, value, kind, f) {
|
|
3284
|
+
if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
3285
|
+
return (state.set(receiver, value)), value;
|
|
3265
3286
|
}
|
|
3266
|
-
|
|
3267
|
-
var
|
|
3268
|
-
#root = null;
|
|
3269
|
-
#eventListeners = {};
|
|
3270
|
-
#listenersAttached = false;
|
|
3271
|
-
dom = null;
|
|
3272
|
-
constructor() {
|
|
3273
|
-
this.init = this.init.bind(this);
|
|
3274
|
-
this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
|
|
3275
|
-
}
|
|
3276
|
-
async init() {
|
|
3277
|
-
console.log("Injecting modal");
|
|
3278
|
-
this.#injectHTML();
|
|
3279
|
-
}
|
|
3280
|
-
open = () => {
|
|
3281
|
-
console.debug("Modal open");
|
|
3282
|
-
this.#attachEventListeners();
|
|
3283
|
-
if (this.#root) this.#root.style.display = "flex";
|
|
3284
|
-
};
|
|
3285
|
-
close = (event = void 0) => {
|
|
3286
|
-
console.debug("Modal close");
|
|
3287
|
-
this.#removeEventListeners();
|
|
3288
|
-
if (this.#root) this.#root.style.display = "none";
|
|
3289
|
-
this.#eventListeners["close"]?.forEach((listener) => listener(event));
|
|
3290
|
-
};
|
|
3291
|
-
addEventListener(event, listener) {
|
|
3292
|
-
this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
|
|
3293
|
-
return () => this.removeEventListener(event, listener);
|
|
3294
|
-
}
|
|
3295
|
-
removeEventListener(event, listener) {
|
|
3296
|
-
this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
|
|
3297
|
-
}
|
|
3298
|
-
#injectHTML() {
|
|
3299
|
-
if (this.dom) return;
|
|
3300
|
-
this.#root = document.createElement("div");
|
|
3301
|
-
this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
|
|
3302
|
-
this.#root.innerHTML = modalHtml$1;
|
|
3303
|
-
this.#root.style.display = "none";
|
|
3304
|
-
const styles = document.createElement("style");
|
|
3305
|
-
styles.id = "mobile-wallet-adapter-embedded-modal-styles";
|
|
3306
|
-
styles.textContent = css$6;
|
|
3307
|
-
const host = document.createElement("div");
|
|
3308
|
-
this.dom = host.attachShadow({ mode: "closed" });
|
|
3309
|
-
host.style.setProperty("--spinner-color", "#FFFFFF");
|
|
3310
|
-
this.dom.appendChild(styles);
|
|
3311
|
-
this.dom.appendChild(this.#root);
|
|
3312
|
-
document.body.appendChild(host);
|
|
3313
|
-
}
|
|
3314
|
-
#attachEventListeners() {
|
|
3315
|
-
if (!this.#root || this.#listenersAttached) return;
|
|
3316
|
-
[...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
|
|
3317
|
-
this.close(event);
|
|
3318
|
-
}));
|
|
3319
|
-
window.addEventListener("load", this.close);
|
|
3320
|
-
document.addEventListener("keydown", this.#handleKeyDown);
|
|
3321
|
-
this.#listenersAttached = true;
|
|
3322
|
-
}
|
|
3323
|
-
#removeEventListeners() {
|
|
3324
|
-
if (!this.#listenersAttached) return;
|
|
3325
|
-
window.removeEventListener("load", this.close);
|
|
3326
|
-
document.removeEventListener("keydown", this.#handleKeyDown);
|
|
3327
|
-
if (!this.#root) return;
|
|
3328
|
-
[...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
|
|
3329
|
-
this.#listenersAttached = false;
|
|
3330
|
-
}
|
|
3331
|
-
#handleKeyDown = (event) => {
|
|
3332
|
-
if (event.key === "Escape") this.close(event);
|
|
3333
|
-
};
|
|
3334
|
-
};
|
|
3335
|
-
//#endregion
|
|
3336
|
-
//#region src/embedded-modal/modal.ts
|
|
3287
|
+
|
|
3288
|
+
var _EmbeddedModal_instances, _EmbeddedModal_root, _EmbeddedModal_eventListeners, _EmbeddedModal_listenersAttached, _EmbeddedModal_injectHTML, _EmbeddedModal_attachEventListeners, _EmbeddedModal_removeEventListeners, _EmbeddedModal_handleKeyDown;
|
|
3337
3289
|
const modalHtml = `
|
|
3338
3290
|
<div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
3339
3291
|
<div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
|
|
@@ -3349,13 +3301,13 @@ const modalHtml = `
|
|
|
3349
3301
|
</div>
|
|
3350
3302
|
</div>
|
|
3351
3303
|
`;
|
|
3352
|
-
const css$
|
|
3304
|
+
const css$2 = `
|
|
3353
3305
|
.mobile-wallet-adapter-embedded-modal-container {
|
|
3354
3306
|
display: flex; /* Use flexbox to center content */
|
|
3355
3307
|
justify-content: center; /* Center horizontally */
|
|
3356
3308
|
align-items: center; /* Center vertically */
|
|
3357
3309
|
position: fixed; /* Stay in place */
|
|
3358
|
-
z-index:
|
|
3310
|
+
z-index: 1; /* Sit on top */
|
|
3359
3311
|
left: 0;
|
|
3360
3312
|
top: 0;
|
|
3361
3313
|
width: 100%; /* Full width */
|
|
@@ -3411,100 +3363,134 @@ const fonts = `
|
|
|
3411
3363
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
3412
3364
|
<link href="https://fonts.googleapis.com/css2?family=Inter+Tight:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
|
|
3413
3365
|
`;
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
};
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3366
|
+
class EmbeddedModal {
|
|
3367
|
+
constructor() {
|
|
3368
|
+
_EmbeddedModal_instances.add(this);
|
|
3369
|
+
_EmbeddedModal_root.set(this, null);
|
|
3370
|
+
_EmbeddedModal_eventListeners.set(this, {});
|
|
3371
|
+
_EmbeddedModal_listenersAttached.set(this, false);
|
|
3372
|
+
this.dom = null;
|
|
3373
|
+
this.open = () => {
|
|
3374
|
+
console.debug('Modal open');
|
|
3375
|
+
__classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_attachEventListeners).call(this);
|
|
3376
|
+
if (__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f")) {
|
|
3377
|
+
__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'flex';
|
|
3378
|
+
}
|
|
3379
|
+
};
|
|
3380
|
+
this.close = (event = undefined) => {
|
|
3381
|
+
var _a;
|
|
3382
|
+
console.debug('Modal close');
|
|
3383
|
+
__classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_removeEventListeners).call(this);
|
|
3384
|
+
if (__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f")) {
|
|
3385
|
+
__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'none';
|
|
3386
|
+
}
|
|
3387
|
+
(_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")['close']) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener(event));
|
|
3388
|
+
};
|
|
3389
|
+
_EmbeddedModal_handleKeyDown.set(this, (event) => {
|
|
3390
|
+
if (event.key === 'Escape')
|
|
3391
|
+
this.close(event);
|
|
3392
|
+
});
|
|
3393
|
+
// Bind methods to ensure `this` context is correct
|
|
3394
|
+
this.init = this.init.bind(this);
|
|
3395
|
+
__classPrivateFieldSet$1(this, _EmbeddedModal_root, document.getElementById('mobile-wallet-adapter-embedded-root-ui'));
|
|
3396
|
+
}
|
|
3397
|
+
init() {
|
|
3398
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3399
|
+
console.log('Injecting modal');
|
|
3400
|
+
__classPrivateFieldGet$1(this, _EmbeddedModal_instances, "m", _EmbeddedModal_injectHTML).call(this);
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3403
|
+
addEventListener(event, listener) {
|
|
3404
|
+
var _a;
|
|
3405
|
+
((_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event] = [listener]);
|
|
3406
|
+
return () => this.removeEventListener(event, listener);
|
|
3407
|
+
}
|
|
3408
|
+
removeEventListener(event, listener) {
|
|
3409
|
+
var _a;
|
|
3410
|
+
__classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _EmbeddedModal_eventListeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
_EmbeddedModal_root = new WeakMap(), _EmbeddedModal_eventListeners = new WeakMap(), _EmbeddedModal_listenersAttached = new WeakMap(), _EmbeddedModal_handleKeyDown = new WeakMap(), _EmbeddedModal_instances = new WeakSet(), _EmbeddedModal_injectHTML = function _EmbeddedModal_injectHTML() {
|
|
3414
|
+
// Check if the HTML has already been injected
|
|
3415
|
+
if (document.getElementById('mobile-wallet-adapter-embedded-root-ui')) {
|
|
3416
|
+
if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"))
|
|
3417
|
+
__classPrivateFieldSet$1(this, _EmbeddedModal_root, document.getElementById('mobile-wallet-adapter-embedded-root-ui'));
|
|
3418
|
+
return;
|
|
3419
|
+
}
|
|
3420
|
+
// Create a container for the modal
|
|
3421
|
+
__classPrivateFieldSet$1(this, _EmbeddedModal_root, document.createElement('div'));
|
|
3422
|
+
__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").id = 'mobile-wallet-adapter-embedded-root-ui';
|
|
3423
|
+
__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").innerHTML = modalHtml;
|
|
3424
|
+
__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").style.display = 'none';
|
|
3425
|
+
// Add modal content
|
|
3426
|
+
const content = __classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelector('.mobile-wallet-adapter-embedded-modal-content');
|
|
3427
|
+
if (content)
|
|
3428
|
+
content.innerHTML = this.contentHtml;
|
|
3429
|
+
// Apply styles
|
|
3430
|
+
const styles = document.createElement('style');
|
|
3431
|
+
styles.id = 'mobile-wallet-adapter-embedded-modal-styles';
|
|
3432
|
+
styles.textContent = css$2 + this.contentStyles;
|
|
3433
|
+
// Create a shadow DOM to encapsulate the modal
|
|
3434
|
+
const host = document.createElement('div');
|
|
3435
|
+
host.innerHTML = fonts;
|
|
3436
|
+
this.dom = host.attachShadow({ mode: 'closed' });
|
|
3437
|
+
this.dom.appendChild(styles);
|
|
3438
|
+
this.dom.appendChild(__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"));
|
|
3439
|
+
// Append the shadow DOM host to the body
|
|
3440
|
+
document.body.appendChild(host);
|
|
3441
|
+
}, _EmbeddedModal_attachEventListeners = function _EmbeddedModal_attachEventListeners() {
|
|
3442
|
+
if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f") || __classPrivateFieldGet$1(this, _EmbeddedModal_listenersAttached, "f"))
|
|
3443
|
+
return;
|
|
3444
|
+
const closers = [...__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelectorAll('[data-modal-close]')];
|
|
3445
|
+
closers.forEach(closer => closer === null || closer === void 0 ? void 0 : closer.addEventListener('click', this.close));
|
|
3446
|
+
window.addEventListener('load', this.close);
|
|
3447
|
+
document.addEventListener('keydown', __classPrivateFieldGet$1(this, _EmbeddedModal_handleKeyDown, "f"));
|
|
3448
|
+
__classPrivateFieldSet$1(this, _EmbeddedModal_listenersAttached, true);
|
|
3449
|
+
}, _EmbeddedModal_removeEventListeners = function _EmbeddedModal_removeEventListeners() {
|
|
3450
|
+
if (!__classPrivateFieldGet$1(this, _EmbeddedModal_listenersAttached, "f"))
|
|
3451
|
+
return;
|
|
3452
|
+
window.removeEventListener('load', this.close);
|
|
3453
|
+
document.removeEventListener('keydown', __classPrivateFieldGet$1(this, _EmbeddedModal_handleKeyDown, "f"));
|
|
3454
|
+
if (!__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f"))
|
|
3455
|
+
return;
|
|
3456
|
+
const closers = [...__classPrivateFieldGet$1(this, _EmbeddedModal_root, "f").querySelectorAll('[data-modal-close]')];
|
|
3457
|
+
closers.forEach(closer => closer === null || closer === void 0 ? void 0 : closer.removeEventListener('click', this.close));
|
|
3458
|
+
__classPrivateFieldSet$1(this, _EmbeddedModal_listenersAttached, false);
|
|
3507
3459
|
};
|
|
3460
|
+
|
|
3461
|
+
class RemoteConnectionModal extends EmbeddedModal {
|
|
3462
|
+
constructor() {
|
|
3463
|
+
super(...arguments);
|
|
3464
|
+
this.contentStyles = css$1;
|
|
3465
|
+
this.contentHtml = QRCodeHtml;
|
|
3466
|
+
}
|
|
3467
|
+
initWithQR(qrCode) {
|
|
3468
|
+
const _super = Object.create(null, {
|
|
3469
|
+
init: { get: () => super.init }
|
|
3470
|
+
});
|
|
3471
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3472
|
+
_super.init.call(this);
|
|
3473
|
+
this.populateQRCode(qrCode);
|
|
3474
|
+
});
|
|
3475
|
+
}
|
|
3476
|
+
populateQRCode(qrUrl) {
|
|
3477
|
+
var _a;
|
|
3478
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3479
|
+
const qrcodeContainer = (_a = this.dom) === null || _a === void 0 ? void 0 : _a.getElementById('mobile-wallet-adapter-embedded-modal-qr-code-container');
|
|
3480
|
+
if (qrcodeContainer) {
|
|
3481
|
+
const qrCodeElement = yield QRCode.toCanvas(qrUrl, { width: 200, margin: 0 });
|
|
3482
|
+
if (qrcodeContainer.firstElementChild !== null) {
|
|
3483
|
+
qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
|
|
3484
|
+
}
|
|
3485
|
+
else
|
|
3486
|
+
qrcodeContainer.appendChild(qrCodeElement);
|
|
3487
|
+
}
|
|
3488
|
+
else {
|
|
3489
|
+
console.error('QRCode Container not found');
|
|
3490
|
+
}
|
|
3491
|
+
});
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3508
3494
|
const QRCodeHtml = `
|
|
3509
3495
|
<div class="mobile-wallet-adapter-embedded-modal-qr-content">
|
|
3510
3496
|
<div>
|
|
@@ -3520,9 +3506,7 @@ const QRCodeHtml = `
|
|
|
3520
3506
|
Open your wallet and scan this code
|
|
3521
3507
|
</h4>
|
|
3522
3508
|
</div>
|
|
3523
|
-
<div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
|
|
3524
|
-
<div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
|
|
3525
|
-
</div>
|
|
3509
|
+
<div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container"></div>
|
|
3526
3510
|
</div>
|
|
3527
3511
|
</div>
|
|
3528
3512
|
<div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
|
|
@@ -3549,7 +3533,7 @@ const QRCodeHtml = `
|
|
|
3549
3533
|
</div>
|
|
3550
3534
|
</div>
|
|
3551
3535
|
`;
|
|
3552
|
-
const css$
|
|
3536
|
+
const css$1 = `
|
|
3553
3537
|
.mobile-wallet-adapter-embedded-modal-qr-content {
|
|
3554
3538
|
display: flex;
|
|
3555
3539
|
margin-top: 10px;
|
|
@@ -3593,16 +3577,6 @@ const css$4 = `
|
|
|
3593
3577
|
margin-left: auto;
|
|
3594
3578
|
}
|
|
3595
3579
|
|
|
3596
|
-
.mobile-wallet-adapter-embedded-modal-qr-placeholder {
|
|
3597
|
-
margin-left: auto;
|
|
3598
|
-
min-width: 200px;
|
|
3599
|
-
min-height: 200px;
|
|
3600
|
-
background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
|
|
3601
|
-
background-size: 200%;
|
|
3602
|
-
animation: placeholderAnimate 2.7s linear infinite;
|
|
3603
|
-
border-radius: 12px;
|
|
3604
|
-
}
|
|
3605
|
-
|
|
3606
3580
|
.mobile-wallet-adapter-embedded-modal-divider {
|
|
3607
3581
|
margin-top: 20px;
|
|
3608
3582
|
padding-left: 10px;
|
|
@@ -3675,15 +3649,6 @@ const css$4 = `
|
|
|
3675
3649
|
.mobile-wallet-adapter-embedded-modal-qr-code-container {
|
|
3676
3650
|
margin: auto;
|
|
3677
3651
|
}
|
|
3678
|
-
.mobile-wallet-adapter-embedded-modal-qr-placeholder {
|
|
3679
|
-
margin: auto;
|
|
3680
|
-
}
|
|
3681
|
-
}
|
|
3682
|
-
|
|
3683
|
-
/* QR Placeholder */
|
|
3684
|
-
@keyframes placeholderAnimate {
|
|
3685
|
-
0% { background-position: 200% 0; }
|
|
3686
|
-
100% { background-position: -200% 0; }
|
|
3687
3652
|
}
|
|
3688
3653
|
|
|
3689
3654
|
/* Spinner */
|
|
@@ -3764,1173 +3729,962 @@ const css$4 = `
|
|
|
3764
3729
|
animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
|
|
3765
3730
|
}
|
|
3766
3731
|
`;
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
initWithCallback(callback) {
|
|
3773
|
-
super.init();
|
|
3774
|
-
this.#prepareLaunchAction(callback);
|
|
3775
|
-
}
|
|
3776
|
-
#prepareLaunchAction(callback) {
|
|
3777
|
-
const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
|
|
3778
|
-
const listener = async () => {
|
|
3779
|
-
launchButton?.removeEventListener("click", listener);
|
|
3780
|
-
this.close();
|
|
3781
|
-
callback();
|
|
3782
|
-
};
|
|
3783
|
-
launchButton?.addEventListener("click", listener);
|
|
3784
|
-
}
|
|
3785
|
-
};
|
|
3786
|
-
const ErrorDialogHtml$3 = `
|
|
3787
|
-
<svg class="mobile-wallet-adapter-embedded-modal-launch-icon" width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3788
|
-
<path d="M21.6 48C7.2 48 0 40.8 0 26.4V21.6C0 7.2 7.2 0 21.6 0H26.4C40.8 0 48 7.2 48 21.6V26.4C48 40.8 40.8 48 26.4 48H21.6Z" fill="#15994E"/>
|
|
3789
|
-
<mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
|
|
3790
|
-
<rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
|
|
3791
|
-
</mask>
|
|
3792
|
-
<g mask="url(#mask0_189_522)">
|
|
3793
|
-
<mask id="mask1_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
|
|
3794
|
-
<rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
|
|
3795
|
-
</mask>
|
|
3796
|
-
<g mask="url(#mask1_189_522)">
|
|
3797
|
-
<path d="M22.1092 26.1208L19.4498 23.4615C19.1736 23.1851 18.8253 23.0468 18.4048 23.0468C17.9846 23.0468 17.6363 23.1851 17.3598 23.4615C17.0836 23.7377 16.9468 24.0861 16.9495 24.5065C16.9522 24.9267 17.0916 25.275 17.3678 25.5512L21.0405 29.2238C21.3463 29.5276 21.7031 29.6795 22.1108 29.6795C22.5184 29.6795 22.8742 29.5276 23.1782 29.2238L30.5918 21.8098C30.8683 21.5336 31.0065 21.1867 31.0065 20.7692C31.0065 20.3514 30.8683 20.0044 30.5918 19.7282C30.3156 19.4517 29.9673 19.3135 29.5468 19.3135C29.1266 19.3135 28.7784 19.4517 28.5022 19.7282L22.1092 26.1208ZM23.9998 37.6042C22.113 37.6042 20.3425 37.2473 18.6885 36.5335C17.0343 35.8197 15.5954 34.8512 14.3718 33.6278C13.1485 32.4043 12.18 30.9654 11.4662 29.3112C10.7524 27.6572 10.3955 25.8867 10.3955 23.9998C10.3955 22.113 10.7524 20.3425 11.4662 18.6885C12.18 17.0343 13.1485 15.5954 14.3718 14.3718C15.5954 13.1485 17.0343 12.18 18.6885 11.4662C20.3425 10.7524 22.113 10.3955 23.9998 10.3955C25.8867 10.3955 27.6572 10.7524 29.3112 11.4662C30.9654 12.18 32.4043 13.1485 33.6278 14.3718C34.8512 15.5954 35.8197 17.0343 36.5335 18.6885C37.2473 20.3425 37.6042 22.113 37.6042 23.9998C37.6042 25.8867 37.2473 27.6572 36.5335 29.3112C35.8197 30.9654 34.8512 32.4043 33.6278 33.6278C32.4043 34.8512 30.9654 35.8197 29.3112 36.5335C27.6572 37.2473 25.8867 37.6042 23.9998 37.6042Z" fill="white"/>
|
|
3798
|
-
</g>
|
|
3799
|
-
</g>
|
|
3800
|
-
</svg>
|
|
3801
|
-
<div class="mobile-wallet-adapter-embedded-modal-title">Ready to connect!</div>
|
|
3802
|
-
<div>
|
|
3803
|
-
<button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
|
|
3804
|
-
Connect Wallet
|
|
3805
|
-
</button>
|
|
3806
|
-
</div>
|
|
3807
|
-
`;
|
|
3808
|
-
const css$3 = `
|
|
3809
|
-
.mobile-wallet-adapter-embedded-modal-close {
|
|
3810
|
-
display: none;
|
|
3811
|
-
}
|
|
3812
|
-
.mobile-wallet-adapter-embedded-modal-content {
|
|
3813
|
-
text-align: center;
|
|
3814
|
-
min-width: 300px;
|
|
3815
|
-
}
|
|
3816
|
-
.mobile-wallet-adapter-embedded-modal-launch-icon {
|
|
3817
|
-
margin-top: 24px;
|
|
3818
|
-
}
|
|
3819
|
-
.mobile-wallet-adapter-embedded-modal-title {
|
|
3820
|
-
margin: 18px 100px 30px 100px;
|
|
3821
|
-
color: #000000;
|
|
3822
|
-
font-size: 2.75em;
|
|
3823
|
-
font-weight: 600;
|
|
3732
|
+
|
|
3733
|
+
const icon = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=';
|
|
3734
|
+
|
|
3735
|
+
function fromUint8Array(byteArray) {
|
|
3736
|
+
return window.btoa(String.fromCharCode.call(null, ...byteArray));
|
|
3824
3737
|
}
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
background: #000000;
|
|
3831
|
-
color: #FFFFFF;
|
|
3832
|
-
border-radius: 18px;
|
|
3738
|
+
function toUint8Array(base64EncodedByteArray) {
|
|
3739
|
+
return new Uint8Array(window
|
|
3740
|
+
.atob(base64EncodedByteArray)
|
|
3741
|
+
.split('')
|
|
3742
|
+
.map((c) => c.charCodeAt(0)));
|
|
3833
3743
|
}
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3744
|
+
|
|
3745
|
+
var _LocalSolanaMobileWalletAdapterWallet_instances, _LocalSolanaMobileWalletAdapterWallet_listeners, _LocalSolanaMobileWalletAdapterWallet_version, _LocalSolanaMobileWalletAdapterWallet_name, _LocalSolanaMobileWalletAdapterWallet_url, _LocalSolanaMobileWalletAdapterWallet_icon, _LocalSolanaMobileWalletAdapterWallet_appIdentity, _LocalSolanaMobileWalletAdapterWallet_authorization, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, _LocalSolanaMobileWalletAdapterWallet_connecting, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, _LocalSolanaMobileWalletAdapterWallet_chains, _LocalSolanaMobileWalletAdapterWallet_chainSelector, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, _LocalSolanaMobileWalletAdapterWallet_on, _LocalSolanaMobileWalletAdapterWallet_emit, _LocalSolanaMobileWalletAdapterWallet_off, _LocalSolanaMobileWalletAdapterWallet_connect, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, _LocalSolanaMobileWalletAdapterWallet_disconnect, _LocalSolanaMobileWalletAdapterWallet_transact, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, _LocalSolanaMobileWalletAdapterWallet_performSignTransactions, _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, _LocalSolanaMobileWalletAdapterWallet_signTransaction, _LocalSolanaMobileWalletAdapterWallet_signMessage, _LocalSolanaMobileWalletAdapterWallet_signIn, _LocalSolanaMobileWalletAdapterWallet_performSignIn, _RemoteSolanaMobileWalletAdapterWallet_instances, _RemoteSolanaMobileWalletAdapterWallet_listeners, _RemoteSolanaMobileWalletAdapterWallet_version, _RemoteSolanaMobileWalletAdapterWallet_name, _RemoteSolanaMobileWalletAdapterWallet_url, _RemoteSolanaMobileWalletAdapterWallet_icon, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, _RemoteSolanaMobileWalletAdapterWallet_authorization, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, _RemoteSolanaMobileWalletAdapterWallet_connecting, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, _RemoteSolanaMobileWalletAdapterWallet_chains, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, _RemoteSolanaMobileWalletAdapterWallet_session, _RemoteSolanaMobileWalletAdapterWallet_on, _RemoteSolanaMobileWalletAdapterWallet_emit, _RemoteSolanaMobileWalletAdapterWallet_off, _RemoteSolanaMobileWalletAdapterWallet_connect, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, _RemoteSolanaMobileWalletAdapterWallet_disconnect, _RemoteSolanaMobileWalletAdapterWallet_transact, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions, _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, _RemoteSolanaMobileWalletAdapterWallet_signMessage, _RemoteSolanaMobileWalletAdapterWallet_signIn, _RemoteSolanaMobileWalletAdapterWallet_performSignIn;
|
|
3746
|
+
const SolanaMobileWalletAdapterWalletName = 'Mobile Wallet Adapter';
|
|
3747
|
+
const SolanaMobileWalletAdapterRemoteWalletName = 'Remote Mobile Wallet Adapter';
|
|
3748
|
+
const SIGNATURE_LENGTH_IN_BYTES = 64;
|
|
3749
|
+
const DEFAULT_FEATURES = [SolanaSignAndSendTransaction, SolanaSignTransaction, SolanaSignMessage, SolanaSignIn];
|
|
3750
|
+
class LocalSolanaMobileWalletAdapterWallet {
|
|
3751
|
+
constructor(config) {
|
|
3752
|
+
_LocalSolanaMobileWalletAdapterWallet_instances.add(this);
|
|
3753
|
+
_LocalSolanaMobileWalletAdapterWallet_listeners.set(this, {});
|
|
3754
|
+
_LocalSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
|
|
3755
|
+
_LocalSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterWalletName);
|
|
3756
|
+
_LocalSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
|
|
3757
|
+
_LocalSolanaMobileWalletAdapterWallet_icon.set(this, icon);
|
|
3758
|
+
_LocalSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
|
|
3759
|
+
_LocalSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
|
|
3760
|
+
_LocalSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
|
|
3761
|
+
_LocalSolanaMobileWalletAdapterWallet_connecting.set(this, false);
|
|
3762
|
+
/**
|
|
3763
|
+
* Every time the connection is recycled in some way (eg. `disconnect()` is called)
|
|
3764
|
+
* increment this and use it to make sure that `transact` calls from the previous
|
|
3765
|
+
* 'generation' don't continue to do work and throw exceptions.
|
|
3766
|
+
*/
|
|
3767
|
+
_LocalSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
|
|
3768
|
+
_LocalSolanaMobileWalletAdapterWallet_chains.set(this, []);
|
|
3769
|
+
_LocalSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
|
|
3770
|
+
_LocalSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
|
|
3771
|
+
_LocalSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
|
|
3772
|
+
_LocalSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
|
|
3773
|
+
var _a;
|
|
3774
|
+
((_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event] = [listener]);
|
|
3775
|
+
return () => __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
|
|
3776
|
+
});
|
|
3777
|
+
_LocalSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
|
|
3778
|
+
if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
|
|
3779
|
+
return { accounts: this.accounts };
|
|
3780
|
+
}
|
|
3781
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
|
|
3782
|
+
try {
|
|
3783
|
+
if (silent) {
|
|
3784
|
+
const cachedAuthorization = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
|
|
3785
|
+
if (cachedAuthorization) {
|
|
3786
|
+
yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, cachedAuthorization.capabilities);
|
|
3787
|
+
yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorization);
|
|
3788
|
+
}
|
|
3789
|
+
else {
|
|
3790
|
+
return { accounts: this.accounts };
|
|
3791
|
+
}
|
|
3792
|
+
}
|
|
3793
|
+
else {
|
|
3794
|
+
yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
|
|
3795
|
+
}
|
|
3796
|
+
}
|
|
3797
|
+
catch (e) {
|
|
3798
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
3799
|
+
}
|
|
3800
|
+
finally {
|
|
3801
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
|
|
3802
|
+
}
|
|
3803
|
+
return { accounts: this.accounts };
|
|
3804
|
+
}));
|
|
3805
|
+
_LocalSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
|
|
3806
|
+
try {
|
|
3807
|
+
const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
|
|
3808
|
+
if (cachedAuthorizationResult) {
|
|
3809
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
3810
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
|
|
3811
|
+
return cachedAuthorizationResult;
|
|
3812
|
+
}
|
|
3813
|
+
const selectedChain = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"));
|
|
3814
|
+
return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
3815
|
+
const [capabilities, mwaAuthorizationResult] = yield Promise.all([
|
|
3816
|
+
wallet.getCapabilities(),
|
|
3817
|
+
wallet.authorize({
|
|
3818
|
+
chain: selectedChain,
|
|
3819
|
+
identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
|
|
3820
|
+
sign_in_payload: signInPayload,
|
|
3821
|
+
})
|
|
3822
|
+
]);
|
|
3823
|
+
const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
3824
|
+
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
|
|
3825
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
3826
|
+
Promise.all([
|
|
3827
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
|
|
3828
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
|
|
3829
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
|
|
3830
|
+
]);
|
|
3831
|
+
return authorization;
|
|
3832
|
+
}));
|
|
3833
|
+
}
|
|
3834
|
+
catch (e) {
|
|
3835
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
3836
|
+
}
|
|
3837
|
+
}));
|
|
3838
|
+
_LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
|
|
3839
|
+
var _a;
|
|
3840
|
+
const didPublicKeysChange =
|
|
3841
|
+
// Case 1: We started from having no authorization.
|
|
3842
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
|
|
3843
|
+
// Case 2: The number of authorized accounts changed.
|
|
3844
|
+
((_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
|
|
3845
|
+
// Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
|
|
3846
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
|
|
3847
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, authorization);
|
|
3848
|
+
if (didPublicKeysChange) {
|
|
3849
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
|
|
3850
|
+
}
|
|
3851
|
+
}));
|
|
3852
|
+
_LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
|
|
3853
|
+
// TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
|
|
3854
|
+
const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
|
|
3855
|
+
const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
|
|
3856
|
+
const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
|
|
3857
|
+
SolanaSignTransaction in this.features !== supportsSignTransaction;
|
|
3858
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, ((supportsSignAndSendTransaction || (!supportsSignAndSendTransaction && !supportsSignTransaction)) && {
|
|
3859
|
+
[SolanaSignAndSendTransaction]: {
|
|
3860
|
+
version: '1.0.0',
|
|
3861
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
3862
|
+
signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
|
|
3863
|
+
},
|
|
3864
|
+
})), (supportsSignTransaction && {
|
|
3865
|
+
[SolanaSignTransaction]: {
|
|
3866
|
+
version: '1.0.0',
|
|
3867
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
3868
|
+
signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
|
|
3869
|
+
},
|
|
3870
|
+
})));
|
|
3871
|
+
if (didCapabilitiesChange) {
|
|
3872
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
|
|
3873
|
+
}
|
|
3874
|
+
}));
|
|
3875
|
+
_LocalSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
|
|
3876
|
+
var _b, _c;
|
|
3877
|
+
try {
|
|
3878
|
+
const [capabilities, mwaAuthorizationResult] = yield Promise.all([
|
|
3879
|
+
(_c = (_b = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
|
|
3880
|
+
wallet.authorize({
|
|
3881
|
+
auth_token: authToken,
|
|
3882
|
+
identity: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, "f"),
|
|
3883
|
+
chain: chain
|
|
3884
|
+
})
|
|
3885
|
+
]);
|
|
3886
|
+
const accounts = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
3887
|
+
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
|
|
3888
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
3889
|
+
Promise.all([
|
|
3890
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
|
|
3891
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
|
|
3892
|
+
]);
|
|
3893
|
+
}
|
|
3894
|
+
catch (e) {
|
|
3895
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
|
|
3896
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
3897
|
+
}
|
|
3898
|
+
}));
|
|
3899
|
+
_LocalSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
3900
|
+
var _d;
|
|
3901
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
3902
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
|
|
3903
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, (_d = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _d++, _d));
|
|
3904
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, undefined);
|
|
3905
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_instances, "m", _LocalSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
|
|
3906
|
+
}));
|
|
3907
|
+
_LocalSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
|
|
3908
|
+
var _e;
|
|
3909
|
+
const walletUriBase = (_e = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _e === void 0 ? void 0 : _e.wallet_uri_base;
|
|
3910
|
+
const config = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
3911
|
+
const currentConnectionGeneration = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
|
|
3912
|
+
try {
|
|
3913
|
+
return yield transact(callback, config);
|
|
3914
|
+
}
|
|
3915
|
+
catch (e) {
|
|
3916
|
+
if (__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
|
|
3917
|
+
yield new Promise(() => { }); // Never resolve.
|
|
3918
|
+
}
|
|
3919
|
+
if (e instanceof Error &&
|
|
3920
|
+
e.name === 'SolanaMobileWalletAdapterError' &&
|
|
3921
|
+
e.code === 'ERROR_WALLET_NOT_FOUND') {
|
|
3922
|
+
yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
|
|
3923
|
+
}
|
|
3924
|
+
throw e;
|
|
3925
|
+
}
|
|
3926
|
+
}));
|
|
3927
|
+
_LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
|
|
3928
|
+
if (!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f"))
|
|
3929
|
+
throw new Error('Wallet not connected');
|
|
3930
|
+
return { authToken: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f").chain };
|
|
3931
|
+
});
|
|
3932
|
+
_LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
|
|
3933
|
+
return accounts.map((account) => {
|
|
3934
|
+
var _a, _b;
|
|
3935
|
+
const publicKey = toUint8Array(account.address);
|
|
3936
|
+
return {
|
|
3937
|
+
address: base58.encode(publicKey),
|
|
3938
|
+
publicKey,
|
|
3939
|
+
label: account.label,
|
|
3940
|
+
icon: account.icon,
|
|
3941
|
+
chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"),
|
|
3942
|
+
// TODO: get supported features from getCapabilities API
|
|
3943
|
+
features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
|
|
3944
|
+
};
|
|
3945
|
+
});
|
|
3946
|
+
});
|
|
3947
|
+
_LocalSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
|
|
3948
|
+
const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
|
|
3949
|
+
try {
|
|
3950
|
+
const base64Transactions = transactions.map((tx) => { return fromUint8Array(tx); });
|
|
3951
|
+
return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
3952
|
+
yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
|
|
3953
|
+
const signedTransactions = (yield wallet.signTransactions({
|
|
3954
|
+
payloads: base64Transactions,
|
|
3955
|
+
})).signed_payloads.map(toUint8Array);
|
|
3956
|
+
return signedTransactions;
|
|
3957
|
+
}));
|
|
3958
|
+
}
|
|
3959
|
+
catch (e) {
|
|
3960
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
3961
|
+
}
|
|
3962
|
+
}));
|
|
3963
|
+
_LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
|
|
3964
|
+
const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
|
|
3965
|
+
try {
|
|
3966
|
+
return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
3967
|
+
const [capabilities, _1] = yield Promise.all([
|
|
3968
|
+
wallet.getCapabilities(),
|
|
3969
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
|
|
3970
|
+
]);
|
|
3971
|
+
if (capabilities.supports_sign_and_send_transactions) {
|
|
3972
|
+
const base64Transaction = fromUint8Array(transaction);
|
|
3973
|
+
const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [base64Transaction] }))).signatures.map(toUint8Array);
|
|
3974
|
+
return signatures[0];
|
|
3975
|
+
}
|
|
3976
|
+
else {
|
|
3977
|
+
throw new Error('connected wallet does not support signAndSendTransaction');
|
|
3978
|
+
}
|
|
3979
|
+
}));
|
|
3980
|
+
}
|
|
3981
|
+
catch (e) {
|
|
3982
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
3983
|
+
}
|
|
3984
|
+
}));
|
|
3985
|
+
_LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
3986
|
+
const outputs = [];
|
|
3987
|
+
for (const input of inputs) {
|
|
3988
|
+
const signature = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options);
|
|
3989
|
+
outputs.push({ signature });
|
|
3990
|
+
}
|
|
3991
|
+
return outputs;
|
|
3992
|
+
}));
|
|
3993
|
+
_LocalSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
3994
|
+
return (yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
|
|
3995
|
+
.map((signedTransaction) => {
|
|
3996
|
+
return { signedTransaction };
|
|
3997
|
+
});
|
|
3998
|
+
}));
|
|
3999
|
+
_LocalSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
4000
|
+
const { authToken, chain } = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
|
|
4001
|
+
const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
|
|
4002
|
+
const messages = inputs.map(({ message }) => fromUint8Array(message));
|
|
4003
|
+
try {
|
|
4004
|
+
return yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
4005
|
+
yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
|
|
4006
|
+
const signedMessages = (yield wallet.signMessages({
|
|
4007
|
+
addresses: addresses,
|
|
4008
|
+
payloads: messages,
|
|
4009
|
+
})).signed_payloads.map(toUint8Array);
|
|
4010
|
+
return signedMessages.map((signedMessage) => {
|
|
4011
|
+
return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
|
|
4012
|
+
});
|
|
4013
|
+
}));
|
|
4014
|
+
}
|
|
4015
|
+
catch (e) {
|
|
4016
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
4017
|
+
}
|
|
4018
|
+
}));
|
|
4019
|
+
_LocalSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
4020
|
+
const outputs = [];
|
|
4021
|
+
if (inputs.length > 1) {
|
|
4022
|
+
for (const input of inputs) {
|
|
4023
|
+
outputs.push(yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
|
|
4024
|
+
}
|
|
4025
|
+
}
|
|
4026
|
+
else {
|
|
4027
|
+
return [yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
|
|
4028
|
+
}
|
|
4029
|
+
return outputs;
|
|
4030
|
+
}));
|
|
4031
|
+
_LocalSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
|
|
4032
|
+
var _f, _g, _h;
|
|
4033
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, true);
|
|
4034
|
+
try {
|
|
4035
|
+
const authorizationResult = yield __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_f = input === null || input === void 0 ? void 0 : input.domain) !== null && _f !== void 0 ? _f : window.location.host }));
|
|
4036
|
+
if (!authorizationResult.sign_in_result) {
|
|
4037
|
+
throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
4038
|
+
}
|
|
4039
|
+
const signedInAddress = authorizationResult.sign_in_result.address;
|
|
4040
|
+
const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
|
|
4041
|
+
return {
|
|
4042
|
+
account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
|
|
4043
|
+
address: base58.encode(toUint8Array(signedInAddress))
|
|
4044
|
+
}), { publicKey: toUint8Array(signedInAddress), chains: (_g = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _g !== void 0 ? _g : __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f"), features: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _h !== void 0 ? _h : authorizationResult.capabilities.features }),
|
|
4045
|
+
signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
4046
|
+
signature: toUint8Array(authorizationResult.sign_in_result.signature)
|
|
4047
|
+
};
|
|
4048
|
+
}
|
|
4049
|
+
catch (e) {
|
|
4050
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
4051
|
+
}
|
|
4052
|
+
finally {
|
|
4053
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_connecting, false);
|
|
4054
|
+
}
|
|
4055
|
+
}));
|
|
4056
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
|
|
4057
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
|
|
4058
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, config.chains);
|
|
4059
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
|
|
4060
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
|
|
4061
|
+
__classPrivateFieldSet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, {
|
|
4062
|
+
// In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
|
|
4063
|
+
// signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
|
|
4064
|
+
// 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
|
|
4065
|
+
// assume both are supported here. The features will be updated based on the actual connected
|
|
4066
|
+
// wallets capabilities during connection regardless, so this is safe.
|
|
4067
|
+
[SolanaSignAndSendTransaction]: {
|
|
4068
|
+
version: '1.0.0',
|
|
4069
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
4070
|
+
signAndSendTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
|
|
4071
|
+
},
|
|
4072
|
+
[SolanaSignTransaction]: {
|
|
4073
|
+
version: '1.0.0',
|
|
4074
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
4075
|
+
signTransaction: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signTransaction, "f"),
|
|
4076
|
+
},
|
|
4077
|
+
});
|
|
4078
|
+
}
|
|
4079
|
+
get version() {
|
|
4080
|
+
return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_version, "f");
|
|
4081
|
+
}
|
|
4082
|
+
get name() {
|
|
4083
|
+
return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_name, "f");
|
|
4084
|
+
}
|
|
4085
|
+
get url() {
|
|
4086
|
+
return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_url, "f");
|
|
4087
|
+
}
|
|
4088
|
+
get icon() {
|
|
4089
|
+
return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_icon, "f");
|
|
4090
|
+
}
|
|
4091
|
+
get chains() {
|
|
4092
|
+
return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_chains, "f");
|
|
4093
|
+
}
|
|
4094
|
+
get features() {
|
|
4095
|
+
return Object.assign({ [StandardConnect]: {
|
|
4096
|
+
version: '1.0.0',
|
|
4097
|
+
connect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_connect, "f"),
|
|
4098
|
+
}, [StandardDisconnect]: {
|
|
4099
|
+
version: '1.0.0',
|
|
4100
|
+
disconnect: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_disconnect, "f"),
|
|
4101
|
+
}, [StandardEvents]: {
|
|
4102
|
+
version: '1.0.0',
|
|
4103
|
+
on: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_on, "f"),
|
|
4104
|
+
}, [SolanaSignMessage]: {
|
|
4105
|
+
version: '1.0.0',
|
|
4106
|
+
signMessage: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signMessage, "f"),
|
|
4107
|
+
}, [SolanaSignIn]: {
|
|
4108
|
+
version: '1.0.0',
|
|
4109
|
+
signIn: __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_signIn, "f"),
|
|
4110
|
+
} }, __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
|
|
4111
|
+
}
|
|
4112
|
+
get accounts() {
|
|
4113
|
+
var _a, _b;
|
|
4114
|
+
return (_b = (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
|
|
4115
|
+
}
|
|
4116
|
+
get connected() {
|
|
4117
|
+
return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
|
|
4118
|
+
}
|
|
4119
|
+
get isAuthorized() {
|
|
4120
|
+
return !!__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
|
|
4121
|
+
}
|
|
4122
|
+
get currentAuthorization() {
|
|
4123
|
+
return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorization, "f");
|
|
4124
|
+
}
|
|
4125
|
+
get cachedAuthorizationResult() {
|
|
4126
|
+
return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
|
|
3840
4127
|
}
|
|
3841
4128
|
}
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
return ErrorDialogHtml$2.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
|
|
3850
|
-
}
|
|
3851
|
-
async init() {
|
|
3852
|
-
super.init();
|
|
3853
|
-
this.#prepareLaunchAction();
|
|
3854
|
-
}
|
|
3855
|
-
#prepareLaunchAction() {
|
|
3856
|
-
const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
|
|
3857
|
-
const listener = async (event) => {
|
|
3858
|
-
launchButton?.removeEventListener("click", listener);
|
|
3859
|
-
this.close(event);
|
|
3860
|
-
};
|
|
3861
|
-
launchButton?.addEventListener("click", listener);
|
|
3862
|
-
}
|
|
4129
|
+
_LocalSolanaMobileWalletAdapterWallet_listeners = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_version = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_name = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_url = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_icon = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_appIdentity = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_authorization = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_authorizationCache = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_connecting = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_connectionGeneration = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_chains = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_chainSelector = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_optionalFeatures = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_onWalletNotFound = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_on = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_connect = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performAuthorization = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_handleAuthorizationResult = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performReauthorization = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_disconnect = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_transact = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_assertIsAuthorized = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performSignTransactions = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performSignAndSendTransaction = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signAndSendTransaction = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signTransaction = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signMessage = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_signIn = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_performSignIn = new WeakMap(), _LocalSolanaMobileWalletAdapterWallet_instances = new WeakSet(), _LocalSolanaMobileWalletAdapterWallet_emit = function _LocalSolanaMobileWalletAdapterWallet_emit(event, ...args) {
|
|
4130
|
+
var _a;
|
|
4131
|
+
// eslint-disable-next-line prefer-spread
|
|
4132
|
+
(_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
|
|
4133
|
+
}, _LocalSolanaMobileWalletAdapterWallet_off = function _LocalSolanaMobileWalletAdapterWallet_off(event, listener) {
|
|
4134
|
+
var _a;
|
|
4135
|
+
__classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
|
|
3863
4136
|
};
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
.
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
.
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
}
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
.
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
}
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
.
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
4137
|
+
class RemoteSolanaMobileWalletAdapterWallet {
|
|
4138
|
+
constructor(config) {
|
|
4139
|
+
_RemoteSolanaMobileWalletAdapterWallet_instances.add(this);
|
|
4140
|
+
_RemoteSolanaMobileWalletAdapterWallet_listeners.set(this, {});
|
|
4141
|
+
_RemoteSolanaMobileWalletAdapterWallet_version.set(this, '1.0.0'); // wallet-standard version
|
|
4142
|
+
_RemoteSolanaMobileWalletAdapterWallet_name.set(this, SolanaMobileWalletAdapterRemoteWalletName);
|
|
4143
|
+
_RemoteSolanaMobileWalletAdapterWallet_url.set(this, 'https://solanamobile.com/wallets');
|
|
4144
|
+
_RemoteSolanaMobileWalletAdapterWallet_icon.set(this, icon);
|
|
4145
|
+
_RemoteSolanaMobileWalletAdapterWallet_appIdentity.set(this, void 0);
|
|
4146
|
+
_RemoteSolanaMobileWalletAdapterWallet_authorization.set(this, void 0);
|
|
4147
|
+
_RemoteSolanaMobileWalletAdapterWallet_authorizationCache.set(this, void 0);
|
|
4148
|
+
_RemoteSolanaMobileWalletAdapterWallet_connecting.set(this, false);
|
|
4149
|
+
/**
|
|
4150
|
+
* Every time the connection is recycled in some way (eg. `disconnect()` is called)
|
|
4151
|
+
* increment this and use it to make sure that `transact` calls from the previous
|
|
4152
|
+
* 'generation' don't continue to do work and throw exceptions.
|
|
4153
|
+
*/
|
|
4154
|
+
_RemoteSolanaMobileWalletAdapterWallet_connectionGeneration.set(this, 0);
|
|
4155
|
+
_RemoteSolanaMobileWalletAdapterWallet_chains.set(this, []);
|
|
4156
|
+
_RemoteSolanaMobileWalletAdapterWallet_chainSelector.set(this, void 0);
|
|
4157
|
+
_RemoteSolanaMobileWalletAdapterWallet_optionalFeatures.set(this, void 0);
|
|
4158
|
+
_RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound.set(this, void 0);
|
|
4159
|
+
_RemoteSolanaMobileWalletAdapterWallet_hostAuthority.set(this, void 0);
|
|
4160
|
+
_RemoteSolanaMobileWalletAdapterWallet_session.set(this, void 0);
|
|
4161
|
+
_RemoteSolanaMobileWalletAdapterWallet_on.set(this, (event, listener) => {
|
|
4162
|
+
var _a;
|
|
4163
|
+
((_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.push(listener)) || (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event] = [listener]);
|
|
4164
|
+
return () => __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_off).call(this, event, listener);
|
|
4165
|
+
});
|
|
4166
|
+
_RemoteSolanaMobileWalletAdapterWallet_connect.set(this, ({ silent } = {}) => __awaiter(this, void 0, void 0, function* () {
|
|
4167
|
+
if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, "f") || this.connected) {
|
|
4168
|
+
return { accounts: this.accounts };
|
|
4169
|
+
}
|
|
4170
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true);
|
|
4171
|
+
try {
|
|
4172
|
+
yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this);
|
|
4173
|
+
}
|
|
4174
|
+
catch (e) {
|
|
4175
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
4176
|
+
}
|
|
4177
|
+
finally {
|
|
4178
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
|
|
4179
|
+
}
|
|
4180
|
+
return { accounts: this.accounts };
|
|
4181
|
+
}));
|
|
4182
|
+
_RemoteSolanaMobileWalletAdapterWallet_performAuthorization.set(this, (signInPayload) => __awaiter(this, void 0, void 0, function* () {
|
|
4183
|
+
try {
|
|
4184
|
+
const cachedAuthorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
|
|
4185
|
+
if (cachedAuthorizationResult) {
|
|
4186
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
4187
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, cachedAuthorizationResult);
|
|
4188
|
+
return cachedAuthorizationResult;
|
|
4189
|
+
}
|
|
4190
|
+
if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f"))
|
|
4191
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined, "f");
|
|
4192
|
+
const selectedChain = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, "f").select(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"));
|
|
4193
|
+
return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
4194
|
+
const [capabilities, mwaAuthorizationResult] = yield Promise.all([
|
|
4195
|
+
wallet.getCapabilities(),
|
|
4196
|
+
wallet.authorize({
|
|
4197
|
+
chain: selectedChain,
|
|
4198
|
+
identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
|
|
4199
|
+
sign_in_payload: signInPayload,
|
|
4200
|
+
})
|
|
4201
|
+
]);
|
|
4202
|
+
const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
4203
|
+
const authorizationResult = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts, chain: selectedChain, capabilities: capabilities });
|
|
4204
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
4205
|
+
Promise.all([
|
|
4206
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult, "f").call(this, capabilities),
|
|
4207
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorizationResult),
|
|
4208
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorizationResult),
|
|
4209
|
+
]);
|
|
4210
|
+
return authorizationResult;
|
|
4211
|
+
}));
|
|
4212
|
+
}
|
|
4213
|
+
catch (e) {
|
|
4214
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
4215
|
+
}
|
|
4216
|
+
}));
|
|
4217
|
+
_RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult.set(this, (authorization) => __awaiter(this, void 0, void 0, function* () {
|
|
4218
|
+
var _a;
|
|
4219
|
+
const didPublicKeysChange =
|
|
4220
|
+
// Case 1: We started from having no authorization.
|
|
4221
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f") == null ||
|
|
4222
|
+
// Case 2: The number of authorized accounts changed.
|
|
4223
|
+
((_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts.length) !== authorization.accounts.length ||
|
|
4224
|
+
// Case 3: The new list of addresses isn't exactly the same as the old list, in the same order.
|
|
4225
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
|
|
4226
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, authorization);
|
|
4227
|
+
if (didPublicKeysChange) {
|
|
4228
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
|
|
4229
|
+
}
|
|
4230
|
+
}));
|
|
4231
|
+
_RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult.set(this, (capabilities) => __awaiter(this, void 0, void 0, function* () {
|
|
4232
|
+
// TODO: investigate why using SolanaSignTransactions constant breaks treeshaking
|
|
4233
|
+
const supportsSignTransaction = capabilities.features.includes('solana:signTransactions'); //SolanaSignTransactions);
|
|
4234
|
+
const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions ||
|
|
4235
|
+
capabilities.features.includes('solana:signAndSendTransaction');
|
|
4236
|
+
const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction ||
|
|
4237
|
+
SolanaSignTransaction in this.features !== supportsSignTransaction;
|
|
4238
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, Object.assign(Object.assign({}, (supportsSignAndSendTransaction && {
|
|
4239
|
+
[SolanaSignAndSendTransaction]: {
|
|
4240
|
+
version: '1.0.0',
|
|
4241
|
+
supportedTransactionVersions: capabilities.supported_transaction_versions,
|
|
4242
|
+
signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
|
|
4243
|
+
},
|
|
4244
|
+
})), (supportsSignTransaction && {
|
|
4245
|
+
[SolanaSignTransaction]: {
|
|
4246
|
+
version: '1.0.0',
|
|
4247
|
+
supportedTransactionVersions: capabilities.supported_transaction_versions,
|
|
4248
|
+
signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
|
|
4249
|
+
},
|
|
4250
|
+
})));
|
|
4251
|
+
if (didCapabilitiesChange) {
|
|
4252
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { features: this.features });
|
|
4253
|
+
}
|
|
4254
|
+
}));
|
|
4255
|
+
_RemoteSolanaMobileWalletAdapterWallet_performReauthorization.set(this, (wallet, authToken, chain) => __awaiter(this, void 0, void 0, function* () {
|
|
4256
|
+
var _b, _c;
|
|
4257
|
+
try {
|
|
4258
|
+
const [capabilities, mwaAuthorizationResult] = yield Promise.all([
|
|
4259
|
+
(_c = (_b = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _b === void 0 ? void 0 : _b.capabilities) !== null && _c !== void 0 ? _c : yield wallet.getCapabilities(),
|
|
4260
|
+
wallet.authorize({
|
|
4261
|
+
auth_token: authToken,
|
|
4262
|
+
identity: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, "f"),
|
|
4263
|
+
chain: chain
|
|
4264
|
+
})
|
|
4265
|
+
]);
|
|
4266
|
+
const accounts = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts, "f").call(this, mwaAuthorizationResult.accounts);
|
|
4267
|
+
const authorization = Object.assign(Object.assign({}, mwaAuthorizationResult), { accounts: accounts, chain: chain, capabilities: capabilities });
|
|
4268
|
+
// TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
4269
|
+
Promise.all([
|
|
4270
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").set(authorization),
|
|
4271
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult, "f").call(this, authorization),
|
|
4272
|
+
]);
|
|
4273
|
+
}
|
|
4274
|
+
catch (e) {
|
|
4275
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_disconnect, "f").call(this);
|
|
4276
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
4277
|
+
}
|
|
4278
|
+
}));
|
|
4279
|
+
_RemoteSolanaMobileWalletAdapterWallet_disconnect.set(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
4280
|
+
var _d;
|
|
4281
|
+
var _e;
|
|
4282
|
+
(_d = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) === null || _d === void 0 ? void 0 : _d.close();
|
|
4283
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").clear(); // TODO: Evaluate whether there's any threat to not `awaiting` this expression
|
|
4284
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
|
|
4285
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, (_e = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f"), _e++, _e));
|
|
4286
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, undefined);
|
|
4287
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, undefined);
|
|
4288
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_instances, "m", _RemoteSolanaMobileWalletAdapterWallet_emit).call(this, 'change', { accounts: this.accounts });
|
|
4289
|
+
}));
|
|
4290
|
+
_RemoteSolanaMobileWalletAdapterWallet_transact.set(this, (callback) => __awaiter(this, void 0, void 0, function* () {
|
|
4291
|
+
var _f;
|
|
4292
|
+
const walletUriBase = (_f = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _f === void 0 ? void 0 : _f.wallet_uri_base;
|
|
4293
|
+
const baseConfig = walletUriBase ? { baseUri: walletUriBase } : undefined;
|
|
4294
|
+
const remoteConfig = Object.assign(Object.assign({}, baseConfig), { remoteHostAuthority: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, "f") });
|
|
4295
|
+
const currentConnectionGeneration = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f");
|
|
4296
|
+
const modal = new RemoteConnectionModal();
|
|
4297
|
+
if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f")) {
|
|
4298
|
+
return callback(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f").wallet);
|
|
4299
|
+
}
|
|
4300
|
+
try {
|
|
4301
|
+
const { associationUrl, close, wallet } = yield startRemoteScenario(remoteConfig);
|
|
4302
|
+
const removeCloseListener = modal.addEventListener('close', (event) => {
|
|
4303
|
+
if (event)
|
|
4304
|
+
close();
|
|
4305
|
+
});
|
|
4306
|
+
modal.initWithQR(associationUrl.toString());
|
|
4307
|
+
modal.open();
|
|
4308
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, { close, wallet: yield wallet }, "f");
|
|
4309
|
+
removeCloseListener();
|
|
4310
|
+
modal.close();
|
|
4311
|
+
return yield callback(__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f").wallet);
|
|
4312
|
+
}
|
|
4313
|
+
catch (e) {
|
|
4314
|
+
modal.close();
|
|
4315
|
+
if (__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration, "f") !== currentConnectionGeneration) {
|
|
4316
|
+
yield new Promise(() => { }); // Never resolve.
|
|
4317
|
+
}
|
|
4318
|
+
if (e instanceof Error &&
|
|
4319
|
+
e.name === 'SolanaMobileWalletAdapterError' &&
|
|
4320
|
+
e.code === 'ERROR_WALLET_NOT_FOUND') {
|
|
4321
|
+
yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, "f").call(this, this);
|
|
4322
|
+
}
|
|
4323
|
+
throw e;
|
|
4324
|
+
}
|
|
4325
|
+
}));
|
|
4326
|
+
_RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized.set(this, () => {
|
|
4327
|
+
if (!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f"))
|
|
4328
|
+
throw new Error('Wallet not connected');
|
|
4329
|
+
return { authToken: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").auth_token, chain: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f").chain };
|
|
4330
|
+
});
|
|
4331
|
+
_RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts.set(this, (accounts) => {
|
|
4332
|
+
return accounts.map((account) => {
|
|
4333
|
+
var _a, _b;
|
|
4334
|
+
const publicKey = toUint8Array(account.address);
|
|
4335
|
+
return {
|
|
4336
|
+
address: base58.encode(publicKey),
|
|
4337
|
+
publicKey,
|
|
4338
|
+
label: account.label,
|
|
4339
|
+
icon: account.icon,
|
|
4340
|
+
chains: (_a = account.chains) !== null && _a !== void 0 ? _a : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"),
|
|
4341
|
+
// TODO: get supported features from getCapabilities API
|
|
4342
|
+
features: (_b = account.features) !== null && _b !== void 0 ? _b : DEFAULT_FEATURES
|
|
4343
|
+
};
|
|
4344
|
+
});
|
|
4345
|
+
});
|
|
4346
|
+
_RemoteSolanaMobileWalletAdapterWallet_performSignTransactions.set(this, (transactions) => __awaiter(this, void 0, void 0, function* () {
|
|
4347
|
+
const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
|
|
4348
|
+
try {
|
|
4349
|
+
return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
4350
|
+
yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
|
|
4351
|
+
const signedTransactions = (yield wallet.signTransactions({
|
|
4352
|
+
payloads: transactions.map(fromUint8Array),
|
|
4353
|
+
})).signed_payloads.map(toUint8Array);
|
|
4354
|
+
return signedTransactions;
|
|
4355
|
+
}));
|
|
4356
|
+
}
|
|
4357
|
+
catch (e) {
|
|
4358
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
4359
|
+
}
|
|
4360
|
+
}));
|
|
4361
|
+
_RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction.set(this, (transaction, options) => __awaiter(this, void 0, void 0, function* () {
|
|
4362
|
+
const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
|
|
4363
|
+
try {
|
|
4364
|
+
return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
4365
|
+
const [capabilities, _1] = yield Promise.all([
|
|
4366
|
+
wallet.getCapabilities(),
|
|
4367
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain)
|
|
4368
|
+
]);
|
|
4369
|
+
if (capabilities.supports_sign_and_send_transactions) {
|
|
4370
|
+
const signatures = (yield wallet.signAndSendTransactions(Object.assign(Object.assign({}, options), { payloads: [fromUint8Array(transaction)] }))).signatures.map(toUint8Array);
|
|
4371
|
+
return signatures[0];
|
|
4372
|
+
}
|
|
4373
|
+
else {
|
|
4374
|
+
throw new Error('connected wallet does not support signAndSendTransaction');
|
|
4375
|
+
}
|
|
4376
|
+
}));
|
|
4377
|
+
}
|
|
4378
|
+
catch (e) {
|
|
4379
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
4380
|
+
}
|
|
4381
|
+
}));
|
|
4382
|
+
_RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
4383
|
+
const outputs = [];
|
|
4384
|
+
for (const input of inputs) {
|
|
4385
|
+
const signature = (yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction, "f").call(this, input.transaction, input.options));
|
|
4386
|
+
outputs.push({ signature });
|
|
4387
|
+
}
|
|
4388
|
+
return outputs;
|
|
4389
|
+
}));
|
|
4390
|
+
_RemoteSolanaMobileWalletAdapterWallet_signTransaction.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
4391
|
+
return (yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions, "f").call(this, inputs.map(({ transaction }) => transaction)))
|
|
4392
|
+
.map((signedTransaction) => {
|
|
4393
|
+
return { signedTransaction };
|
|
4394
|
+
});
|
|
4395
|
+
}));
|
|
4396
|
+
_RemoteSolanaMobileWalletAdapterWallet_signMessage.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
4397
|
+
const { authToken, chain } = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized, "f").call(this);
|
|
4398
|
+
const addresses = inputs.map(({ account }) => fromUint8Array(account.publicKey));
|
|
4399
|
+
const messages = inputs.map(({ message }) => fromUint8Array(message));
|
|
4400
|
+
try {
|
|
4401
|
+
return yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_transact, "f").call(this, (wallet) => __awaiter(this, void 0, void 0, function* () {
|
|
4402
|
+
yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performReauthorization, "f").call(this, wallet, authToken, chain);
|
|
4403
|
+
const signedMessages = (yield wallet.signMessages({
|
|
4404
|
+
addresses: addresses,
|
|
4405
|
+
payloads: messages,
|
|
4406
|
+
})).signed_payloads.map(toUint8Array);
|
|
4407
|
+
return signedMessages.map((signedMessage) => {
|
|
4408
|
+
return { signedMessage: signedMessage, signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES) };
|
|
4409
|
+
});
|
|
4410
|
+
}));
|
|
4411
|
+
}
|
|
4412
|
+
catch (e) {
|
|
4413
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
4414
|
+
}
|
|
4415
|
+
}));
|
|
4416
|
+
_RemoteSolanaMobileWalletAdapterWallet_signIn.set(this, (...inputs) => __awaiter(this, void 0, void 0, function* () {
|
|
4417
|
+
const outputs = [];
|
|
4418
|
+
if (inputs.length > 1) {
|
|
4419
|
+
for (const input of inputs) {
|
|
4420
|
+
outputs.push(yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, input));
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
else {
|
|
4424
|
+
return [yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performSignIn, "f").call(this, inputs[0])];
|
|
4425
|
+
}
|
|
4426
|
+
return outputs;
|
|
4427
|
+
}));
|
|
4428
|
+
_RemoteSolanaMobileWalletAdapterWallet_performSignIn.set(this, (input) => __awaiter(this, void 0, void 0, function* () {
|
|
4429
|
+
var _g, _h, _j;
|
|
4430
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, true);
|
|
4431
|
+
try {
|
|
4432
|
+
const authorizationResult = yield __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_performAuthorization, "f").call(this, Object.assign(Object.assign({}, input), { domain: (_g = input === null || input === void 0 ? void 0 : input.domain) !== null && _g !== void 0 ? _g : window.location.host }));
|
|
4433
|
+
if (!authorizationResult.sign_in_result) {
|
|
4434
|
+
throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
4435
|
+
}
|
|
4436
|
+
const signedInAddress = authorizationResult.sign_in_result.address;
|
|
4437
|
+
const signedInAccount = authorizationResult.accounts.find(acc => acc.address == signedInAddress);
|
|
4438
|
+
return {
|
|
4439
|
+
account: Object.assign(Object.assign({}, signedInAccount !== null && signedInAccount !== void 0 ? signedInAccount : {
|
|
4440
|
+
address: base58.encode(toUint8Array(signedInAddress))
|
|
4441
|
+
}), { publicKey: toUint8Array(signedInAddress), chains: (_h = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.chains) !== null && _h !== void 0 ? _h : __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f"), features: (_j = signedInAccount === null || signedInAccount === void 0 ? void 0 : signedInAccount.features) !== null && _j !== void 0 ? _j : authorizationResult.capabilities.features }),
|
|
4442
|
+
signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
4443
|
+
signature: toUint8Array(authorizationResult.sign_in_result.signature)
|
|
4444
|
+
};
|
|
4445
|
+
}
|
|
4446
|
+
catch (e) {
|
|
4447
|
+
throw new Error((e instanceof Error && e.message) || 'Unknown error');
|
|
4448
|
+
}
|
|
4449
|
+
finally {
|
|
4450
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connecting, false);
|
|
4451
|
+
}
|
|
4452
|
+
}));
|
|
4453
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, config.authorizationCache);
|
|
4454
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_appIdentity, config.appIdentity);
|
|
4455
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, config.chains);
|
|
4456
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chainSelector, config.chainSelector);
|
|
4457
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_hostAuthority, config.remoteHostAuthority);
|
|
4458
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound, config.onWalletNotFound);
|
|
4459
|
+
__classPrivateFieldSet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, {
|
|
4460
|
+
// In MWA 1.0, signAndSend is optional and signTransaction is mandatory. Whereas in MWA 2.0+,
|
|
4461
|
+
// signAndSend is mandatory and signTransaction is optional (and soft deprecated). As of mid
|
|
4462
|
+
// 2025, all MWA wallets support both signAndSendTransaction and signTransaction so its safe
|
|
4463
|
+
// assume both are supported here. The features will be updated based on the actual connected
|
|
4464
|
+
// wallets capabilities during connection regardless, so this is safe.
|
|
4465
|
+
[SolanaSignAndSendTransaction]: {
|
|
4466
|
+
version: '1.0.0',
|
|
4467
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
4468
|
+
signAndSendTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction, "f"),
|
|
4469
|
+
},
|
|
4470
|
+
[SolanaSignTransaction]: {
|
|
4471
|
+
version: '1.0.0',
|
|
4472
|
+
supportedTransactionVersions: ['legacy', 0],
|
|
4473
|
+
signTransaction: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signTransaction, "f"),
|
|
4474
|
+
},
|
|
4475
|
+
});
|
|
3997
4476
|
}
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4477
|
+
get version() {
|
|
4478
|
+
return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_version, "f");
|
|
4479
|
+
}
|
|
4480
|
+
get name() {
|
|
4481
|
+
return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_name, "f");
|
|
4482
|
+
}
|
|
4483
|
+
get url() {
|
|
4484
|
+
return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_url, "f");
|
|
4485
|
+
}
|
|
4486
|
+
get icon() {
|
|
4487
|
+
return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_icon, "f");
|
|
4488
|
+
}
|
|
4489
|
+
get chains() {
|
|
4490
|
+
return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_chains, "f");
|
|
4491
|
+
}
|
|
4492
|
+
get features() {
|
|
4493
|
+
return Object.assign({ [StandardConnect]: {
|
|
4494
|
+
version: '1.0.0',
|
|
4495
|
+
connect: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_connect, "f"),
|
|
4496
|
+
}, [StandardDisconnect]: {
|
|
4497
|
+
version: '1.0.0',
|
|
4498
|
+
disconnect: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_disconnect, "f"),
|
|
4499
|
+
}, [StandardEvents]: {
|
|
4500
|
+
version: '1.0.0',
|
|
4501
|
+
on: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_on, "f"),
|
|
4502
|
+
}, [SolanaSignMessage]: {
|
|
4503
|
+
version: '1.0.0',
|
|
4504
|
+
signMessage: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signMessage, "f"),
|
|
4505
|
+
}, [SolanaSignIn]: {
|
|
4506
|
+
version: '1.0.0',
|
|
4507
|
+
signIn: __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_signIn, "f"),
|
|
4508
|
+
} }, __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures, "f"));
|
|
4509
|
+
}
|
|
4510
|
+
get accounts() {
|
|
4511
|
+
var _a, _b;
|
|
4512
|
+
return (_b = (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f")) === null || _a === void 0 ? void 0 : _a.accounts) !== null && _b !== void 0 ? _b : [];
|
|
4513
|
+
}
|
|
4514
|
+
get connected() {
|
|
4515
|
+
return !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_session, "f") && !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
|
|
4516
|
+
}
|
|
4517
|
+
get isAuthorized() {
|
|
4518
|
+
return !!__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
|
|
4519
|
+
}
|
|
4520
|
+
get currentAuthorization() {
|
|
4521
|
+
return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorization, "f");
|
|
4522
|
+
}
|
|
4523
|
+
get cachedAuthorizationResult() {
|
|
4524
|
+
return __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_authorizationCache, "f").get();
|
|
4001
4525
|
}
|
|
4002
4526
|
}
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
super.init();
|
|
4011
|
-
this.#prepareLaunchAction();
|
|
4012
|
-
}
|
|
4013
|
-
#prepareLaunchAction() {
|
|
4014
|
-
const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
|
|
4015
|
-
const listener = async () => {
|
|
4016
|
-
launchButton?.removeEventListener("click", listener);
|
|
4017
|
-
try {
|
|
4018
|
-
await fetch("http://localhost");
|
|
4019
|
-
} catch {}
|
|
4020
|
-
this.close();
|
|
4021
|
-
};
|
|
4022
|
-
launchButton?.addEventListener("click", listener);
|
|
4023
|
-
}
|
|
4527
|
+
_RemoteSolanaMobileWalletAdapterWallet_listeners = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_version = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_name = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_url = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_icon = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_appIdentity = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_authorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_authorizationCache = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connecting = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connectionGeneration = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_chains = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_chainSelector = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_optionalFeatures = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_onWalletNotFound = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_hostAuthority = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_session = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_on = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_connect = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performAuthorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_handleAuthorizationResult = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_handleWalletCapabilitiesResult = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performReauthorization = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_disconnect = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_transact = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_assertIsAuthorized = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_accountsToWalletStandardAccounts = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignTransactions = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignAndSendTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signAndSendTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signTransaction = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signMessage = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_signIn = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_performSignIn = new WeakMap(), _RemoteSolanaMobileWalletAdapterWallet_instances = new WeakSet(), _RemoteSolanaMobileWalletAdapterWallet_emit = function _RemoteSolanaMobileWalletAdapterWallet_emit(event, ...args) {
|
|
4528
|
+
var _a;
|
|
4529
|
+
// eslint-disable-next-line prefer-spread
|
|
4530
|
+
(_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.forEach((listener) => listener.apply(null, args));
|
|
4531
|
+
}, _RemoteSolanaMobileWalletAdapterWallet_off = function _RemoteSolanaMobileWalletAdapterWallet_off(event, listener) {
|
|
4532
|
+
var _a;
|
|
4533
|
+
__classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event] = (_a = __classPrivateFieldGet$1(this, _RemoteSolanaMobileWalletAdapterWallet_listeners, "f")[event]) === null || _a === void 0 ? void 0 : _a.filter((existingListener) => listener !== existingListener);
|
|
4024
4534
|
};
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
}
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
font-weight: 400;
|
|
4069
|
-
}
|
|
4070
|
-
.mobile-wallet-adapter-embedded-modal-permission-prompt-mock {
|
|
4071
|
-
width: 90%;
|
|
4072
|
-
height: auto;
|
|
4073
|
-
margin: 0 auto 30px auto;
|
|
4074
|
-
display: block;
|
|
4075
|
-
}
|
|
4076
|
-
.mobile-wallet-adapter-embedded-modal-launch-action {
|
|
4077
|
-
display: block;
|
|
4078
|
-
width: 100%;
|
|
4079
|
-
height: 56px;
|
|
4080
|
-
font-size: 1.25em;
|
|
4081
|
-
background: #000000;
|
|
4082
|
-
color: #FFFFFF;
|
|
4083
|
-
border-radius: 18px;
|
|
4535
|
+
|
|
4536
|
+
var __classPrivateFieldSet = function (receiver, state, value, kind, f) {
|
|
4537
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4538
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4539
|
+
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");
|
|
4540
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
4541
|
+
};
|
|
4542
|
+
var __classPrivateFieldGet = function (receiver, state, kind, f) {
|
|
4543
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4544
|
+
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");
|
|
4545
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
4546
|
+
};
|
|
4547
|
+
var _RegisterWalletEvent_detail;
|
|
4548
|
+
/**
|
|
4549
|
+
* Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
|
|
4550
|
+
*
|
|
4551
|
+
* This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
|
|
4552
|
+
* ready to be registered.
|
|
4553
|
+
*
|
|
4554
|
+
* This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
|
|
4555
|
+
* the app that the app is ready to register the Wallet.
|
|
4556
|
+
*
|
|
4557
|
+
* This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
|
|
4558
|
+
* as the app is ready whether the Wallet loads before or after the app.
|
|
4559
|
+
*
|
|
4560
|
+
* @param wallet Wallet to register.
|
|
4561
|
+
*
|
|
4562
|
+
* @group Wallet
|
|
4563
|
+
*/
|
|
4564
|
+
function registerWallet(wallet) {
|
|
4565
|
+
const callback = ({ register }) => register(wallet);
|
|
4566
|
+
try {
|
|
4567
|
+
window.dispatchEvent(new RegisterWalletEvent(callback));
|
|
4568
|
+
}
|
|
4569
|
+
catch (error) {
|
|
4570
|
+
console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
|
|
4571
|
+
}
|
|
4572
|
+
try {
|
|
4573
|
+
window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
|
|
4574
|
+
}
|
|
4575
|
+
catch (error) {
|
|
4576
|
+
console.error('wallet-standard:app-ready event listener could not be added\n', error);
|
|
4577
|
+
}
|
|
4084
4578
|
}
|
|
4085
|
-
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4579
|
+
class RegisterWalletEvent extends Event {
|
|
4580
|
+
constructor(callback) {
|
|
4581
|
+
super('wallet-standard:register-wallet', {
|
|
4582
|
+
bubbles: false,
|
|
4583
|
+
cancelable: false,
|
|
4584
|
+
composed: false,
|
|
4585
|
+
});
|
|
4586
|
+
_RegisterWalletEvent_detail.set(this, void 0);
|
|
4587
|
+
__classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
|
|
4091
4588
|
}
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4589
|
+
get detail() {
|
|
4590
|
+
return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
|
|
4591
|
+
}
|
|
4592
|
+
get type() {
|
|
4593
|
+
return 'wallet-standard:register-wallet';
|
|
4594
|
+
}
|
|
4595
|
+
/** @deprecated */
|
|
4596
|
+
preventDefault() {
|
|
4597
|
+
throw new Error('preventDefault cannot be called');
|
|
4598
|
+
}
|
|
4599
|
+
/** @deprecated */
|
|
4600
|
+
stopImmediatePropagation() {
|
|
4601
|
+
throw new Error('stopImmediatePropagation cannot be called');
|
|
4602
|
+
}
|
|
4603
|
+
/** @deprecated */
|
|
4604
|
+
stopPropagation() {
|
|
4605
|
+
throw new Error('stopPropagation cannot be called');
|
|
4095
4606
|
}
|
|
4096
4607
|
}
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
//#region src/getIsSupported.ts
|
|
4608
|
+
_RegisterWalletEvent_detail = new WeakMap();
|
|
4609
|
+
|
|
4100
4610
|
function getIsLocalAssociationSupported() {
|
|
4101
|
-
|
|
4611
|
+
return (typeof window !== 'undefined' &&
|
|
4612
|
+
window.isSecureContext &&
|
|
4613
|
+
typeof document !== 'undefined' &&
|
|
4614
|
+
/android/i.test(navigator.userAgent));
|
|
4102
4615
|
}
|
|
4103
4616
|
function getIsRemoteAssociationSupported() {
|
|
4104
|
-
|
|
4617
|
+
return (typeof window !== 'undefined' &&
|
|
4618
|
+
window.isSecureContext &&
|
|
4619
|
+
typeof document !== 'undefined' &&
|
|
4620
|
+
!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
|
|
4105
4621
|
}
|
|
4622
|
+
// Source: https://github.com/anza-xyz/wallet-adapter/blob/master/packages/core/react/src/getEnvironment.ts#L14
|
|
4623
|
+
// This is the same implementation that gated MWA in the Anza wallet-adapter-react library.
|
|
4106
4624
|
function isWebView(userAgentString) {
|
|
4107
|
-
|
|
4108
|
-
}
|
|
4109
|
-
function isSolanaMobileWebShell(userAgentString) {
|
|
4110
|
-
return userAgentString.includes("Solana Mobile Web Shell");
|
|
4111
|
-
}
|
|
4112
|
-
function getIsPwaLaunchedAsApp() {
|
|
4113
|
-
const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
|
|
4114
|
-
if (typeof window == "undefined") return isAndroidTwa;
|
|
4115
|
-
const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
|
|
4116
|
-
const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
|
|
4117
|
-
const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
|
|
4118
|
-
return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
|
|
4119
|
-
}
|
|
4120
|
-
async function checkLocalNetworkAccessPermission() {
|
|
4121
|
-
if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
|
|
4122
|
-
try {
|
|
4123
|
-
const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
|
|
4124
|
-
if (lnaPermission.state === "granted") return;
|
|
4125
|
-
else if (lnaPermission.state === "denied") {
|
|
4126
|
-
const modal = new LoopbackPermissionBlockedModal();
|
|
4127
|
-
modal.init();
|
|
4128
|
-
modal.open();
|
|
4129
|
-
throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
|
|
4130
|
-
} else if (lnaPermission.state === "prompt") {
|
|
4131
|
-
const modal = new LoopbackPermissionModal();
|
|
4132
|
-
if (await new Promise((resolve, reject) => {
|
|
4133
|
-
modal.addEventListener("close", (event) => {
|
|
4134
|
-
if (event) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
|
|
4135
|
-
});
|
|
4136
|
-
lnaPermission.onchange = () => {
|
|
4137
|
-
lnaPermission.onchange = null;
|
|
4138
|
-
resolve(lnaPermission.state);
|
|
4139
|
-
};
|
|
4140
|
-
modal.init();
|
|
4141
|
-
modal.open();
|
|
4142
|
-
}) === "granted") {
|
|
4143
|
-
const modal = new LocalConnectionModal();
|
|
4144
|
-
await new Promise((resolve, reject) => {
|
|
4145
|
-
modal.addEventListener("close", (event) => {
|
|
4146
|
-
if (event) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
|
|
4147
|
-
});
|
|
4148
|
-
modal.initWithCallback(async () => {
|
|
4149
|
-
resolve(true);
|
|
4150
|
-
});
|
|
4151
|
-
modal.open();
|
|
4152
|
-
});
|
|
4153
|
-
return;
|
|
4154
|
-
} else return await checkLocalNetworkAccessPermission();
|
|
4155
|
-
}
|
|
4156
|
-
throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
|
|
4157
|
-
} catch (e) {
|
|
4158
|
-
if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
|
|
4159
|
-
if (e instanceof SolanaMobileWalletAdapterError) throw e;
|
|
4160
|
-
throw new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
|
|
4161
|
-
}
|
|
4625
|
+
return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
|
|
4162
4626
|
}
|
|
4163
|
-
|
|
4164
|
-
//#region src/icon.ts
|
|
4165
|
-
const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
|
|
4166
|
-
//#endregion
|
|
4167
|
-
//#region src/wallet.ts
|
|
4168
|
-
const SolanaMobileWalletAdapterWalletName = "Mobile Wallet Adapter";
|
|
4169
|
-
const SolanaMobileWalletAdapterRemoteWalletName = "Remote Mobile Wallet Adapter";
|
|
4170
|
-
const SIGNATURE_LENGTH_IN_BYTES = 64;
|
|
4171
|
-
const DEFAULT_FEATURES = [
|
|
4172
|
-
SolanaSignAndSendTransaction,
|
|
4173
|
-
SolanaSignTransaction,
|
|
4174
|
-
SolanaSignMessage,
|
|
4175
|
-
SolanaSignIn
|
|
4176
|
-
];
|
|
4177
|
-
const WALLET_ASSOCIATION_TIMEOUT = 3e4;
|
|
4178
|
-
function getErrorMessage(error) {
|
|
4179
|
-
return error instanceof Error ? error.message : "Unknown error";
|
|
4180
|
-
}
|
|
4181
|
-
var LocalSolanaMobileWalletAdapterWallet = class {
|
|
4182
|
-
#listeners = {};
|
|
4183
|
-
#version = "1.0.0";
|
|
4184
|
-
#name = SolanaMobileWalletAdapterWalletName;
|
|
4185
|
-
#url = "https://solanamobile.com/wallets";
|
|
4186
|
-
#icon = icon;
|
|
4187
|
-
#appIdentity;
|
|
4188
|
-
#authorization;
|
|
4189
|
-
#authorizationCache;
|
|
4190
|
-
#connecting = false;
|
|
4191
|
-
/**
|
|
4192
|
-
* Every time the connection is recycled in some way (eg. `disconnect()` is called)
|
|
4193
|
-
* increment this and use it to make sure that `transact` calls from the previous
|
|
4194
|
-
* 'generation' don't continue to do work and throw exceptions.
|
|
4195
|
-
*/
|
|
4196
|
-
#connectionGeneration = 0;
|
|
4197
|
-
#chains = [];
|
|
4198
|
-
#chainSelector;
|
|
4199
|
-
#optionalFeatures;
|
|
4200
|
-
#onWalletNotFound;
|
|
4201
|
-
get version() {
|
|
4202
|
-
return this.#version;
|
|
4203
|
-
}
|
|
4204
|
-
get name() {
|
|
4205
|
-
return this.#name;
|
|
4206
|
-
}
|
|
4207
|
-
get url() {
|
|
4208
|
-
return this.#url;
|
|
4209
|
-
}
|
|
4210
|
-
get icon() {
|
|
4211
|
-
return this.#icon;
|
|
4212
|
-
}
|
|
4213
|
-
get chains() {
|
|
4214
|
-
return this.#chains;
|
|
4215
|
-
}
|
|
4216
|
-
get features() {
|
|
4217
|
-
return {
|
|
4218
|
-
[StandardConnect]: {
|
|
4219
|
-
version: "1.0.0",
|
|
4220
|
-
connect: this.#connect
|
|
4221
|
-
},
|
|
4222
|
-
[StandardDisconnect]: {
|
|
4223
|
-
version: "1.0.0",
|
|
4224
|
-
disconnect: this.#disconnect
|
|
4225
|
-
},
|
|
4226
|
-
[StandardEvents]: {
|
|
4227
|
-
version: "1.0.0",
|
|
4228
|
-
on: this.#on
|
|
4229
|
-
},
|
|
4230
|
-
[SolanaSignMessage]: {
|
|
4231
|
-
version: "1.0.0",
|
|
4232
|
-
signMessage: this.#signMessage
|
|
4233
|
-
},
|
|
4234
|
-
[SolanaSignIn]: {
|
|
4235
|
-
version: "1.0.0",
|
|
4236
|
-
signIn: this.#signIn
|
|
4237
|
-
},
|
|
4238
|
-
...this.#optionalFeatures
|
|
4239
|
-
};
|
|
4240
|
-
}
|
|
4241
|
-
get accounts() {
|
|
4242
|
-
return this.#authorization?.accounts ?? [];
|
|
4243
|
-
}
|
|
4244
|
-
constructor(config) {
|
|
4245
|
-
this.#authorizationCache = config.authorizationCache;
|
|
4246
|
-
this.#appIdentity = config.appIdentity;
|
|
4247
|
-
this.#chains = config.chains;
|
|
4248
|
-
this.#chainSelector = config.chainSelector;
|
|
4249
|
-
this.#onWalletNotFound = config.onWalletNotFound;
|
|
4250
|
-
this.#optionalFeatures = {
|
|
4251
|
-
[SolanaSignAndSendTransaction]: {
|
|
4252
|
-
version: "1.0.0",
|
|
4253
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4254
|
-
signAndSendTransaction: this.#signAndSendTransaction
|
|
4255
|
-
},
|
|
4256
|
-
[SolanaSignTransaction]: {
|
|
4257
|
-
version: "1.0.0",
|
|
4258
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4259
|
-
signTransaction: this.#signTransaction
|
|
4260
|
-
}
|
|
4261
|
-
};
|
|
4262
|
-
}
|
|
4263
|
-
get connected() {
|
|
4264
|
-
return !!this.#authorization;
|
|
4265
|
-
}
|
|
4266
|
-
get isAuthorized() {
|
|
4267
|
-
return !!this.#authorization;
|
|
4268
|
-
}
|
|
4269
|
-
get currentAuthorization() {
|
|
4270
|
-
return this.#authorization;
|
|
4271
|
-
}
|
|
4272
|
-
get cachedAuthorizationResult() {
|
|
4273
|
-
return this.#authorizationCache.get();
|
|
4274
|
-
}
|
|
4275
|
-
#on = (event, listener) => {
|
|
4276
|
-
this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
|
|
4277
|
-
return () => this.#off(event, listener);
|
|
4278
|
-
};
|
|
4279
|
-
#emit(event, ...args) {
|
|
4280
|
-
this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
|
|
4281
|
-
}
|
|
4282
|
-
#off(event, listener) {
|
|
4283
|
-
this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
|
|
4284
|
-
}
|
|
4285
|
-
#connect = async ({ silent } = {}) => {
|
|
4286
|
-
if (this.#connecting || this.connected) return { accounts: this.accounts };
|
|
4287
|
-
this.#connecting = true;
|
|
4288
|
-
try {
|
|
4289
|
-
if (silent) {
|
|
4290
|
-
const cachedAuthorization = await this.#authorizationCache.get();
|
|
4291
|
-
if (cachedAuthorization) {
|
|
4292
|
-
await this.#handleWalletCapabilitiesResult(cachedAuthorization.capabilities);
|
|
4293
|
-
await this.#handleAuthorizationResult(cachedAuthorization);
|
|
4294
|
-
} else return { accounts: this.accounts };
|
|
4295
|
-
} else await this.#performAuthorization();
|
|
4296
|
-
} catch (e) {
|
|
4297
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4298
|
-
} finally {
|
|
4299
|
-
this.#connecting = false;
|
|
4300
|
-
}
|
|
4301
|
-
return { accounts: this.accounts };
|
|
4302
|
-
};
|
|
4303
|
-
#performAuthorization = async (signInPayload) => {
|
|
4304
|
-
try {
|
|
4305
|
-
const cachedAuthorizationResult = await this.#authorizationCache.get();
|
|
4306
|
-
if (cachedAuthorizationResult) {
|
|
4307
|
-
this.#handleAuthorizationResult(cachedAuthorizationResult);
|
|
4308
|
-
return cachedAuthorizationResult;
|
|
4309
|
-
}
|
|
4310
|
-
const selectedChain = await this.#chainSelector.select(this.#chains);
|
|
4311
|
-
return await this.#transact(async (wallet) => {
|
|
4312
|
-
const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
|
|
4313
|
-
chain: selectedChain,
|
|
4314
|
-
identity: this.#appIdentity,
|
|
4315
|
-
sign_in_payload: signInPayload
|
|
4316
|
-
})]);
|
|
4317
|
-
const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
|
|
4318
|
-
const authorization = {
|
|
4319
|
-
...mwaAuthorizationResult,
|
|
4320
|
-
accounts,
|
|
4321
|
-
chain: selectedChain,
|
|
4322
|
-
capabilities
|
|
4323
|
-
};
|
|
4324
|
-
Promise.all([
|
|
4325
|
-
this.#handleWalletCapabilitiesResult(capabilities),
|
|
4326
|
-
this.#authorizationCache.set(authorization),
|
|
4327
|
-
this.#handleAuthorizationResult(authorization)
|
|
4328
|
-
]);
|
|
4329
|
-
return authorization;
|
|
4330
|
-
});
|
|
4331
|
-
} catch (e) {
|
|
4332
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4333
|
-
}
|
|
4334
|
-
};
|
|
4335
|
-
#handleAuthorizationResult = async (authorization) => {
|
|
4336
|
-
const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
|
|
4337
|
-
this.#authorization = authorization;
|
|
4338
|
-
if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
|
|
4339
|
-
};
|
|
4340
|
-
#handleWalletCapabilitiesResult = async (capabilities) => {
|
|
4341
|
-
const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
|
|
4342
|
-
const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
|
|
4343
|
-
const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
|
|
4344
|
-
this.#optionalFeatures = {
|
|
4345
|
-
...(supportsSignAndSendTransaction || !supportsSignAndSendTransaction && !supportsSignTransaction) && { [SolanaSignAndSendTransaction]: {
|
|
4346
|
-
version: "1.0.0",
|
|
4347
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4348
|
-
signAndSendTransaction: this.#signAndSendTransaction
|
|
4349
|
-
} },
|
|
4350
|
-
...supportsSignTransaction && { [SolanaSignTransaction]: {
|
|
4351
|
-
version: "1.0.0",
|
|
4352
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4353
|
-
signTransaction: this.#signTransaction
|
|
4354
|
-
} }
|
|
4355
|
-
};
|
|
4356
|
-
if (didCapabilitiesChange) this.#emit("change", { features: this.features });
|
|
4357
|
-
};
|
|
4358
|
-
#performReauthorization = async (wallet, authToken, chain) => {
|
|
4359
|
-
try {
|
|
4360
|
-
const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
|
|
4361
|
-
auth_token: authToken,
|
|
4362
|
-
identity: this.#appIdentity,
|
|
4363
|
-
chain
|
|
4364
|
-
})]);
|
|
4365
|
-
const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
|
|
4366
|
-
const authorization = {
|
|
4367
|
-
...mwaAuthorizationResult,
|
|
4368
|
-
accounts,
|
|
4369
|
-
chain,
|
|
4370
|
-
capabilities
|
|
4371
|
-
};
|
|
4372
|
-
Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
|
|
4373
|
-
} catch (e) {
|
|
4374
|
-
this.#disconnect();
|
|
4375
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4376
|
-
}
|
|
4377
|
-
};
|
|
4378
|
-
#disconnect = async () => {
|
|
4379
|
-
this.#authorizationCache.clear();
|
|
4380
|
-
this.#connecting = false;
|
|
4381
|
-
this.#connectionGeneration++;
|
|
4382
|
-
this.#authorization = void 0;
|
|
4383
|
-
this.#emit("change", { accounts: this.accounts });
|
|
4384
|
-
};
|
|
4385
|
-
#transact = async (callback) => {
|
|
4386
|
-
const walletUriBase = this.#authorization?.wallet_uri_base;
|
|
4387
|
-
const config = walletUriBase ? { baseUri: walletUriBase } : void 0;
|
|
4388
|
-
const currentConnectionGeneration = this.#connectionGeneration;
|
|
4389
|
-
const loadingSpinner = new EmbeddedLoadingSpinner();
|
|
4390
|
-
try {
|
|
4391
|
-
let associating = true;
|
|
4392
|
-
let timeout = void 0;
|
|
4393
|
-
const result = await Promise.race([checkLocalNetworkAccessPermission().then(async () => {
|
|
4394
|
-
loadingSpinner.init();
|
|
4395
|
-
const { wallet, close } = await startScenario(config);
|
|
4396
|
-
associating = false;
|
|
4397
|
-
loadingSpinner.addEventListener("close", (event) => {
|
|
4398
|
-
if (event) close();
|
|
4399
|
-
});
|
|
4400
|
-
loadingSpinner.open();
|
|
4401
|
-
const result = await callback(await wallet);
|
|
4402
|
-
loadingSpinner.close();
|
|
4403
|
-
close();
|
|
4404
|
-
return result;
|
|
4405
|
-
}), new Promise((_, reject) => {
|
|
4406
|
-
timeout = setTimeout(() => {
|
|
4407
|
-
if (associating) reject(new SolanaMobileWalletAdapterError(SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
|
|
4408
|
-
}, WALLET_ASSOCIATION_TIMEOUT);
|
|
4409
|
-
})]);
|
|
4410
|
-
clearTimeout(timeout);
|
|
4411
|
-
return result;
|
|
4412
|
-
} catch (e) {
|
|
4413
|
-
loadingSpinner.close();
|
|
4414
|
-
if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
|
|
4415
|
-
if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
|
|
4416
|
-
throw e;
|
|
4417
|
-
}
|
|
4418
|
-
};
|
|
4419
|
-
#assertIsAuthorized = () => {
|
|
4420
|
-
if (!this.#authorization) throw new Error("Wallet not connected");
|
|
4421
|
-
return {
|
|
4422
|
-
authToken: this.#authorization.auth_token,
|
|
4423
|
-
chain: this.#authorization.chain
|
|
4424
|
-
};
|
|
4425
|
-
};
|
|
4426
|
-
#accountsToWalletStandardAccounts = (accounts) => {
|
|
4427
|
-
return accounts.map((account) => {
|
|
4428
|
-
const publicKey = toUint8Array(account.address);
|
|
4429
|
-
return {
|
|
4430
|
-
address: base58.encode(publicKey),
|
|
4431
|
-
publicKey,
|
|
4432
|
-
label: account.label,
|
|
4433
|
-
icon: account.icon,
|
|
4434
|
-
chains: account.chains ?? this.#chains,
|
|
4435
|
-
features: account.features ?? DEFAULT_FEATURES
|
|
4436
|
-
};
|
|
4437
|
-
});
|
|
4438
|
-
};
|
|
4439
|
-
#performSignTransactions = async (transactions) => {
|
|
4440
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4441
|
-
try {
|
|
4442
|
-
const base64Transactions = transactions.map((tx) => {
|
|
4443
|
-
return fromUint8Array(tx);
|
|
4444
|
-
});
|
|
4445
|
-
return await this.#transact(async (wallet) => {
|
|
4446
|
-
await this.#performReauthorization(wallet, authToken, chain);
|
|
4447
|
-
return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(toUint8Array);
|
|
4448
|
-
});
|
|
4449
|
-
} catch (e) {
|
|
4450
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4451
|
-
}
|
|
4452
|
-
};
|
|
4453
|
-
#performSignAndSendTransaction = async (transaction, options) => {
|
|
4454
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4455
|
-
try {
|
|
4456
|
-
return await this.#transact(async (wallet) => {
|
|
4457
|
-
const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
|
|
4458
|
-
if (capabilities.supports_sign_and_send_transactions) {
|
|
4459
|
-
const base64Transaction = fromUint8Array(transaction);
|
|
4460
|
-
return (await wallet.signAndSendTransactions({
|
|
4461
|
-
...options,
|
|
4462
|
-
payloads: [base64Transaction]
|
|
4463
|
-
})).signatures.map(toUint8Array)[0];
|
|
4464
|
-
} else throw new Error("connected wallet does not support signAndSendTransaction");
|
|
4465
|
-
});
|
|
4466
|
-
} catch (e) {
|
|
4467
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4468
|
-
}
|
|
4469
|
-
};
|
|
4470
|
-
#signAndSendTransaction = async (...inputs) => {
|
|
4471
|
-
const outputs = [];
|
|
4472
|
-
for (const input of inputs) {
|
|
4473
|
-
const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
|
|
4474
|
-
outputs.push({ signature });
|
|
4475
|
-
}
|
|
4476
|
-
return outputs;
|
|
4477
|
-
};
|
|
4478
|
-
#signTransaction = async (...inputs) => {
|
|
4479
|
-
return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
|
|
4480
|
-
return { signedTransaction };
|
|
4481
|
-
});
|
|
4482
|
-
};
|
|
4483
|
-
#signMessage = async (...inputs) => {
|
|
4484
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4485
|
-
const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
|
|
4486
|
-
const messages = inputs.map(({ message }) => fromUint8Array(message));
|
|
4487
|
-
try {
|
|
4488
|
-
return await this.#transact(async (wallet) => {
|
|
4489
|
-
await this.#performReauthorization(wallet, authToken, chain);
|
|
4490
|
-
return (await wallet.signMessages({
|
|
4491
|
-
addresses,
|
|
4492
|
-
payloads: messages
|
|
4493
|
-
})).signed_payloads.map(toUint8Array).map((signedMessage) => {
|
|
4494
|
-
return {
|
|
4495
|
-
signedMessage,
|
|
4496
|
-
signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
|
|
4497
|
-
};
|
|
4498
|
-
});
|
|
4499
|
-
});
|
|
4500
|
-
} catch (e) {
|
|
4501
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4502
|
-
}
|
|
4503
|
-
};
|
|
4504
|
-
#signIn = async (...inputs) => {
|
|
4505
|
-
const outputs = [];
|
|
4506
|
-
if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
|
|
4507
|
-
else return [await this.#performSignIn(inputs[0])];
|
|
4508
|
-
return outputs;
|
|
4509
|
-
};
|
|
4510
|
-
#performSignIn = async (input) => {
|
|
4511
|
-
this.#connecting = true;
|
|
4512
|
-
try {
|
|
4513
|
-
const authorizationResult = await this.#performAuthorization({
|
|
4514
|
-
...input,
|
|
4515
|
-
domain: input?.domain ?? window.location.host
|
|
4516
|
-
});
|
|
4517
|
-
if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
4518
|
-
const signedInAddress = authorizationResult.sign_in_result.address;
|
|
4519
|
-
const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
|
|
4520
|
-
return {
|
|
4521
|
-
account: {
|
|
4522
|
-
...signedInAccount ?? { address: base58.encode(toUint8Array(signedInAddress)) },
|
|
4523
|
-
publicKey: toUint8Array(signedInAddress),
|
|
4524
|
-
chains: signedInAccount?.chains ?? this.#chains,
|
|
4525
|
-
features: signedInAccount?.features ?? authorizationResult.capabilities.features
|
|
4526
|
-
},
|
|
4527
|
-
signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
4528
|
-
signature: toUint8Array(authorizationResult.sign_in_result.signature)
|
|
4529
|
-
};
|
|
4530
|
-
} catch (e) {
|
|
4531
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4532
|
-
} finally {
|
|
4533
|
-
this.#connecting = false;
|
|
4534
|
-
}
|
|
4535
|
-
};
|
|
4536
|
-
};
|
|
4537
|
-
var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
4538
|
-
#listeners = {};
|
|
4539
|
-
#version = "1.0.0";
|
|
4540
|
-
#name = SolanaMobileWalletAdapterRemoteWalletName;
|
|
4541
|
-
#url = "https://solanamobile.com/wallets";
|
|
4542
|
-
#icon = icon;
|
|
4543
|
-
#appIdentity;
|
|
4544
|
-
#authorization;
|
|
4545
|
-
#authorizationCache;
|
|
4546
|
-
#connecting = false;
|
|
4547
|
-
/**
|
|
4548
|
-
* Every time the connection is recycled in some way (eg. `disconnect()` is called)
|
|
4549
|
-
* increment this and use it to make sure that `transact` calls from the previous
|
|
4550
|
-
* 'generation' don't continue to do work and throw exceptions.
|
|
4551
|
-
*/
|
|
4552
|
-
#connectionGeneration = 0;
|
|
4553
|
-
#chains = [];
|
|
4554
|
-
#chainSelector;
|
|
4555
|
-
#optionalFeatures;
|
|
4556
|
-
#onWalletNotFound;
|
|
4557
|
-
#hostAuthority;
|
|
4558
|
-
#session;
|
|
4559
|
-
get version() {
|
|
4560
|
-
return this.#version;
|
|
4561
|
-
}
|
|
4562
|
-
get name() {
|
|
4563
|
-
return this.#name;
|
|
4564
|
-
}
|
|
4565
|
-
get url() {
|
|
4566
|
-
return this.#url;
|
|
4567
|
-
}
|
|
4568
|
-
get icon() {
|
|
4569
|
-
return this.#icon;
|
|
4570
|
-
}
|
|
4571
|
-
get chains() {
|
|
4572
|
-
return this.#chains;
|
|
4573
|
-
}
|
|
4574
|
-
get features() {
|
|
4575
|
-
return {
|
|
4576
|
-
[StandardConnect]: {
|
|
4577
|
-
version: "1.0.0",
|
|
4578
|
-
connect: this.#connect
|
|
4579
|
-
},
|
|
4580
|
-
[StandardDisconnect]: {
|
|
4581
|
-
version: "1.0.0",
|
|
4582
|
-
disconnect: this.#disconnect
|
|
4583
|
-
},
|
|
4584
|
-
[StandardEvents]: {
|
|
4585
|
-
version: "1.0.0",
|
|
4586
|
-
on: this.#on
|
|
4587
|
-
},
|
|
4588
|
-
[SolanaSignMessage]: {
|
|
4589
|
-
version: "1.0.0",
|
|
4590
|
-
signMessage: this.#signMessage
|
|
4591
|
-
},
|
|
4592
|
-
[SolanaSignIn]: {
|
|
4593
|
-
version: "1.0.0",
|
|
4594
|
-
signIn: this.#signIn
|
|
4595
|
-
},
|
|
4596
|
-
...this.#optionalFeatures
|
|
4597
|
-
};
|
|
4598
|
-
}
|
|
4599
|
-
get accounts() {
|
|
4600
|
-
return this.#authorization?.accounts ?? [];
|
|
4601
|
-
}
|
|
4602
|
-
constructor(config) {
|
|
4603
|
-
this.#authorizationCache = config.authorizationCache;
|
|
4604
|
-
this.#appIdentity = config.appIdentity;
|
|
4605
|
-
this.#chains = config.chains;
|
|
4606
|
-
this.#chainSelector = config.chainSelector;
|
|
4607
|
-
this.#hostAuthority = config.remoteHostAuthority;
|
|
4608
|
-
this.#onWalletNotFound = config.onWalletNotFound;
|
|
4609
|
-
this.#optionalFeatures = {
|
|
4610
|
-
[SolanaSignAndSendTransaction]: {
|
|
4611
|
-
version: "1.0.0",
|
|
4612
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4613
|
-
signAndSendTransaction: this.#signAndSendTransaction
|
|
4614
|
-
},
|
|
4615
|
-
[SolanaSignTransaction]: {
|
|
4616
|
-
version: "1.0.0",
|
|
4617
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4618
|
-
signTransaction: this.#signTransaction
|
|
4619
|
-
}
|
|
4620
|
-
};
|
|
4621
|
-
}
|
|
4622
|
-
get connected() {
|
|
4623
|
-
return !!this.#session && !!this.#authorization;
|
|
4624
|
-
}
|
|
4625
|
-
get isAuthorized() {
|
|
4626
|
-
return !!this.#authorization;
|
|
4627
|
-
}
|
|
4628
|
-
get currentAuthorization() {
|
|
4629
|
-
return this.#authorization;
|
|
4630
|
-
}
|
|
4631
|
-
get cachedAuthorizationResult() {
|
|
4632
|
-
return this.#authorizationCache.get();
|
|
4633
|
-
}
|
|
4634
|
-
#on = (event, listener) => {
|
|
4635
|
-
this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
|
|
4636
|
-
return () => this.#off(event, listener);
|
|
4637
|
-
};
|
|
4638
|
-
#emit(event, ...args) {
|
|
4639
|
-
this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
|
|
4640
|
-
}
|
|
4641
|
-
#off(event, listener) {
|
|
4642
|
-
this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
|
|
4643
|
-
}
|
|
4644
|
-
#connect = async (_input = {}) => {
|
|
4645
|
-
if (this.#connecting || this.connected) return { accounts: this.accounts };
|
|
4646
|
-
this.#connecting = true;
|
|
4647
|
-
try {
|
|
4648
|
-
await this.#performAuthorization();
|
|
4649
|
-
} catch (e) {
|
|
4650
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4651
|
-
} finally {
|
|
4652
|
-
this.#connecting = false;
|
|
4653
|
-
}
|
|
4654
|
-
return { accounts: this.accounts };
|
|
4655
|
-
};
|
|
4656
|
-
#performAuthorization = async (signInPayload) => {
|
|
4657
|
-
try {
|
|
4658
|
-
const cachedAuthorizationResult = await this.#authorizationCache.get();
|
|
4659
|
-
if (cachedAuthorizationResult) {
|
|
4660
|
-
this.#handleAuthorizationResult(cachedAuthorizationResult);
|
|
4661
|
-
return cachedAuthorizationResult;
|
|
4662
|
-
}
|
|
4663
|
-
if (this.#session) this.#session = void 0;
|
|
4664
|
-
const selectedChain = await this.#chainSelector.select(this.#chains);
|
|
4665
|
-
return await this.#transact(async (wallet) => {
|
|
4666
|
-
const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
|
|
4667
|
-
chain: selectedChain,
|
|
4668
|
-
identity: this.#appIdentity,
|
|
4669
|
-
sign_in_payload: signInPayload
|
|
4670
|
-
})]);
|
|
4671
|
-
const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
|
|
4672
|
-
const authorizationResult = {
|
|
4673
|
-
...mwaAuthorizationResult,
|
|
4674
|
-
accounts,
|
|
4675
|
-
chain: selectedChain,
|
|
4676
|
-
capabilities
|
|
4677
|
-
};
|
|
4678
|
-
Promise.all([
|
|
4679
|
-
this.#handleWalletCapabilitiesResult(capabilities),
|
|
4680
|
-
this.#authorizationCache.set(authorizationResult),
|
|
4681
|
-
this.#handleAuthorizationResult(authorizationResult)
|
|
4682
|
-
]);
|
|
4683
|
-
return authorizationResult;
|
|
4684
|
-
});
|
|
4685
|
-
} catch (e) {
|
|
4686
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4687
|
-
}
|
|
4688
|
-
};
|
|
4689
|
-
#handleAuthorizationResult = async (authorization) => {
|
|
4690
|
-
const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
|
|
4691
|
-
this.#authorization = authorization;
|
|
4692
|
-
if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
|
|
4693
|
-
};
|
|
4694
|
-
#handleWalletCapabilitiesResult = async (capabilities) => {
|
|
4695
|
-
const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
|
|
4696
|
-
const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions || capabilities.features.includes("solana:signAndSendTransaction");
|
|
4697
|
-
const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
|
|
4698
|
-
this.#optionalFeatures = {
|
|
4699
|
-
...supportsSignAndSendTransaction && { [SolanaSignAndSendTransaction]: {
|
|
4700
|
-
version: "1.0.0",
|
|
4701
|
-
supportedTransactionVersions: capabilities.supported_transaction_versions,
|
|
4702
|
-
signAndSendTransaction: this.#signAndSendTransaction
|
|
4703
|
-
} },
|
|
4704
|
-
...supportsSignTransaction && { [SolanaSignTransaction]: {
|
|
4705
|
-
version: "1.0.0",
|
|
4706
|
-
supportedTransactionVersions: capabilities.supported_transaction_versions,
|
|
4707
|
-
signTransaction: this.#signTransaction
|
|
4708
|
-
} }
|
|
4709
|
-
};
|
|
4710
|
-
if (didCapabilitiesChange) this.#emit("change", { features: this.features });
|
|
4711
|
-
};
|
|
4712
|
-
#performReauthorization = async (wallet, authToken, chain) => {
|
|
4713
|
-
try {
|
|
4714
|
-
const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
|
|
4715
|
-
auth_token: authToken,
|
|
4716
|
-
identity: this.#appIdentity,
|
|
4717
|
-
chain
|
|
4718
|
-
})]);
|
|
4719
|
-
const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
|
|
4720
|
-
const authorization = {
|
|
4721
|
-
...mwaAuthorizationResult,
|
|
4722
|
-
accounts,
|
|
4723
|
-
chain,
|
|
4724
|
-
capabilities
|
|
4725
|
-
};
|
|
4726
|
-
Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
|
|
4727
|
-
} catch (e) {
|
|
4728
|
-
this.#disconnect();
|
|
4729
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4730
|
-
}
|
|
4731
|
-
};
|
|
4732
|
-
#disconnect = async () => {
|
|
4733
|
-
this.#session?.close();
|
|
4734
|
-
this.#authorizationCache.clear();
|
|
4735
|
-
this.#connecting = false;
|
|
4736
|
-
this.#connectionGeneration++;
|
|
4737
|
-
this.#authorization = void 0;
|
|
4738
|
-
this.#session = void 0;
|
|
4739
|
-
this.#emit("change", { accounts: this.accounts });
|
|
4740
|
-
};
|
|
4741
|
-
#transact = async (callback) => {
|
|
4742
|
-
const walletUriBase = this.#authorization?.wallet_uri_base;
|
|
4743
|
-
const remoteConfig = {
|
|
4744
|
-
...walletUriBase ? { baseUri: walletUriBase } : void 0,
|
|
4745
|
-
remoteHostAuthority: this.#hostAuthority
|
|
4746
|
-
};
|
|
4747
|
-
const currentConnectionGeneration = this.#connectionGeneration;
|
|
4748
|
-
const modal = new RemoteConnectionModal();
|
|
4749
|
-
if (this.#session) return callback(this.#session.wallet);
|
|
4750
|
-
try {
|
|
4751
|
-
modal.init();
|
|
4752
|
-
modal.open();
|
|
4753
|
-
const { associationUrl, close, wallet } = await startRemoteScenario(remoteConfig);
|
|
4754
|
-
const removeCloseListener = modal.addEventListener("close", (event) => {
|
|
4755
|
-
if (event) close();
|
|
4756
|
-
});
|
|
4757
|
-
modal.populateQRCode(associationUrl.toString());
|
|
4758
|
-
this.#session = {
|
|
4759
|
-
close,
|
|
4760
|
-
wallet: await wallet
|
|
4761
|
-
};
|
|
4762
|
-
removeCloseListener();
|
|
4763
|
-
modal.close();
|
|
4764
|
-
return await callback(this.#session.wallet);
|
|
4765
|
-
} catch (e) {
|
|
4766
|
-
modal.close();
|
|
4767
|
-
if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
|
|
4768
|
-
if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
|
|
4769
|
-
throw e;
|
|
4770
|
-
}
|
|
4771
|
-
};
|
|
4772
|
-
#assertIsAuthorized = () => {
|
|
4773
|
-
if (!this.#authorization) throw new Error("Wallet not connected");
|
|
4774
|
-
return {
|
|
4775
|
-
authToken: this.#authorization.auth_token,
|
|
4776
|
-
chain: this.#authorization.chain
|
|
4777
|
-
};
|
|
4778
|
-
};
|
|
4779
|
-
#accountsToWalletStandardAccounts = (accounts) => {
|
|
4780
|
-
return accounts.map((account) => {
|
|
4781
|
-
const publicKey = toUint8Array(account.address);
|
|
4782
|
-
return {
|
|
4783
|
-
address: base58.encode(publicKey),
|
|
4784
|
-
publicKey,
|
|
4785
|
-
label: account.label,
|
|
4786
|
-
icon: account.icon,
|
|
4787
|
-
chains: account.chains ?? this.#chains,
|
|
4788
|
-
features: account.features ?? DEFAULT_FEATURES
|
|
4789
|
-
};
|
|
4790
|
-
});
|
|
4791
|
-
};
|
|
4792
|
-
#performSignTransactions = async (transactions) => {
|
|
4793
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4794
|
-
try {
|
|
4795
|
-
return await this.#transact(async (wallet) => {
|
|
4796
|
-
await this.#performReauthorization(wallet, authToken, chain);
|
|
4797
|
-
return (await wallet.signTransactions({ payloads: transactions.map(fromUint8Array) })).signed_payloads.map(toUint8Array);
|
|
4798
|
-
});
|
|
4799
|
-
} catch (e) {
|
|
4800
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4801
|
-
}
|
|
4802
|
-
};
|
|
4803
|
-
#performSignAndSendTransaction = async (transaction, options) => {
|
|
4804
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4805
|
-
try {
|
|
4806
|
-
return await this.#transact(async (wallet) => {
|
|
4807
|
-
const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
|
|
4808
|
-
if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
|
|
4809
|
-
...options,
|
|
4810
|
-
payloads: [fromUint8Array(transaction)]
|
|
4811
|
-
})).signatures.map(toUint8Array)[0];
|
|
4812
|
-
else throw new Error("connected wallet does not support signAndSendTransaction");
|
|
4813
|
-
});
|
|
4814
|
-
} catch (e) {
|
|
4815
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4816
|
-
}
|
|
4817
|
-
};
|
|
4818
|
-
#signAndSendTransaction = async (...inputs) => {
|
|
4819
|
-
const outputs = [];
|
|
4820
|
-
for (const input of inputs) {
|
|
4821
|
-
const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
|
|
4822
|
-
outputs.push({ signature });
|
|
4823
|
-
}
|
|
4824
|
-
return outputs;
|
|
4825
|
-
};
|
|
4826
|
-
#signTransaction = async (...inputs) => {
|
|
4827
|
-
return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
|
|
4828
|
-
return { signedTransaction };
|
|
4829
|
-
});
|
|
4830
|
-
};
|
|
4831
|
-
#signMessage = async (...inputs) => {
|
|
4832
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4833
|
-
const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
|
|
4834
|
-
const messages = inputs.map(({ message }) => fromUint8Array(message));
|
|
4835
|
-
try {
|
|
4836
|
-
return await this.#transact(async (wallet) => {
|
|
4837
|
-
await this.#performReauthorization(wallet, authToken, chain);
|
|
4838
|
-
return (await wallet.signMessages({
|
|
4839
|
-
addresses,
|
|
4840
|
-
payloads: messages
|
|
4841
|
-
})).signed_payloads.map(toUint8Array).map((signedMessage) => {
|
|
4842
|
-
return {
|
|
4843
|
-
signedMessage,
|
|
4844
|
-
signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
|
|
4845
|
-
};
|
|
4846
|
-
});
|
|
4847
|
-
});
|
|
4848
|
-
} catch (e) {
|
|
4849
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4850
|
-
}
|
|
4851
|
-
};
|
|
4852
|
-
#signIn = async (...inputs) => {
|
|
4853
|
-
const outputs = [];
|
|
4854
|
-
if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
|
|
4855
|
-
else return [await this.#performSignIn(inputs[0])];
|
|
4856
|
-
return outputs;
|
|
4857
|
-
};
|
|
4858
|
-
#performSignIn = async (input) => {
|
|
4859
|
-
this.#connecting = true;
|
|
4860
|
-
try {
|
|
4861
|
-
const authorizationResult = await this.#performAuthorization({
|
|
4862
|
-
...input,
|
|
4863
|
-
domain: input?.domain ?? window.location.host
|
|
4864
|
-
});
|
|
4865
|
-
if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
4866
|
-
const signedInAddress = authorizationResult.sign_in_result.address;
|
|
4867
|
-
const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
|
|
4868
|
-
return {
|
|
4869
|
-
account: {
|
|
4870
|
-
...signedInAccount ?? { address: base58.encode(toUint8Array(signedInAddress)) },
|
|
4871
|
-
publicKey: toUint8Array(signedInAddress),
|
|
4872
|
-
chains: signedInAccount?.chains ?? this.#chains,
|
|
4873
|
-
features: signedInAccount?.features ?? authorizationResult.capabilities.features
|
|
4874
|
-
},
|
|
4875
|
-
signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
4876
|
-
signature: toUint8Array(authorizationResult.sign_in_result.signature)
|
|
4877
|
-
};
|
|
4878
|
-
} catch (e) {
|
|
4879
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4880
|
-
} finally {
|
|
4881
|
-
this.#connecting = false;
|
|
4882
|
-
}
|
|
4883
|
-
};
|
|
4884
|
-
};
|
|
4885
|
-
//#endregion
|
|
4886
|
-
//#region src/initialize.ts
|
|
4627
|
+
|
|
4887
4628
|
function registerMwa(config) {
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4629
|
+
if (typeof window === 'undefined') {
|
|
4630
|
+
console.warn(`MWA not registered: no window object`);
|
|
4631
|
+
return;
|
|
4632
|
+
}
|
|
4633
|
+
if (!window.isSecureContext) {
|
|
4634
|
+
console.warn(`MWA not registered: secure context required (https)`);
|
|
4635
|
+
return;
|
|
4636
|
+
}
|
|
4637
|
+
// Local association technically is possible in a webview, but we prevent registration
|
|
4638
|
+
// by default because it usually fails in the most common cases (e.g wallet browsers).
|
|
4639
|
+
if (getIsLocalAssociationSupported() && !isWebView(navigator.userAgent)) {
|
|
4640
|
+
registerWallet(new LocalSolanaMobileWalletAdapterWallet(config));
|
|
4641
|
+
}
|
|
4642
|
+
else if (getIsRemoteAssociationSupported() && config.remoteHostAuthority !== undefined) {
|
|
4643
|
+
registerWallet(new RemoteSolanaMobileWalletAdapterWallet(Object.assign(Object.assign({}, config), { remoteHostAuthority: config.remoteHostAuthority })));
|
|
4644
|
+
}
|
|
4645
|
+
else ;
|
|
4646
|
+
}
|
|
4647
|
+
|
|
4648
|
+
const WALLET_NOT_FOUND_ERROR_MESSAGE = 'To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.';
|
|
4649
|
+
const BROWSER_NOT_SUPPORTED_ERROR_MESSAGE = 'This browser appears to be incompatible with mobile wallet adapter. Open this page in a compatible mobile browser app and try again.';
|
|
4650
|
+
class ErrorModal extends EmbeddedModal {
|
|
4651
|
+
constructor() {
|
|
4652
|
+
super(...arguments);
|
|
4653
|
+
this.contentStyles = css;
|
|
4654
|
+
this.contentHtml = ErrorDialogHtml;
|
|
4655
|
+
}
|
|
4656
|
+
initWithError(error) {
|
|
4657
|
+
super.init();
|
|
4658
|
+
this.populateError(error);
|
|
4659
|
+
}
|
|
4660
|
+
populateError(error) {
|
|
4661
|
+
var _a, _b;
|
|
4662
|
+
const errorMessageElement = (_a = this.dom) === null || _a === void 0 ? void 0 : _a.getElementById('mobile-wallet-adapter-error-message');
|
|
4663
|
+
const actionBtn = (_b = this.dom) === null || _b === void 0 ? void 0 : _b.getElementById('mobile-wallet-adapter-error-action');
|
|
4664
|
+
if (errorMessageElement) {
|
|
4665
|
+
if (error.name === 'SolanaMobileWalletAdapterError') {
|
|
4666
|
+
switch (error.code) {
|
|
4667
|
+
case 'ERROR_WALLET_NOT_FOUND':
|
|
4668
|
+
errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
|
|
4669
|
+
if (actionBtn)
|
|
4670
|
+
actionBtn.addEventListener('click', () => {
|
|
4671
|
+
window.location.href = 'https://solanamobile.com/wallets';
|
|
4672
|
+
});
|
|
4673
|
+
return;
|
|
4674
|
+
case 'ERROR_BROWSER_NOT_SUPPORTED':
|
|
4675
|
+
errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
|
|
4676
|
+
if (actionBtn)
|
|
4677
|
+
actionBtn.style.display = 'none';
|
|
4678
|
+
return;
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4681
|
+
errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
|
|
4682
|
+
}
|
|
4683
|
+
else {
|
|
4684
|
+
console.log('Failed to locate error dialog element');
|
|
4685
|
+
}
|
|
4686
|
+
}
|
|
4902
4687
|
}
|
|
4903
|
-
//#endregion
|
|
4904
|
-
//#region src/embedded-modal/errorModal.ts
|
|
4905
|
-
const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
|
|
4906
|
-
const BROWSER_NOT_SUPPORTED_ERROR_MESSAGE = "This browser appears to be incompatible with mobile wallet adapter. Open this page in a compatible mobile browser app and try again.";
|
|
4907
|
-
var ErrorModal = class extends EmbeddedModal {
|
|
4908
|
-
contentStyles = css;
|
|
4909
|
-
contentHtml = ErrorDialogHtml;
|
|
4910
|
-
initWithError(error) {
|
|
4911
|
-
super.init();
|
|
4912
|
-
this.populateError(error);
|
|
4913
|
-
}
|
|
4914
|
-
populateError(error) {
|
|
4915
|
-
const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
|
|
4916
|
-
const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
|
|
4917
|
-
if (errorMessageElement) {
|
|
4918
|
-
if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
|
|
4919
|
-
case "ERROR_WALLET_NOT_FOUND":
|
|
4920
|
-
errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
|
|
4921
|
-
if (actionBtn) actionBtn.addEventListener("click", () => {
|
|
4922
|
-
window.location.href = "https://solanamobile.com/wallets";
|
|
4923
|
-
});
|
|
4924
|
-
return;
|
|
4925
|
-
case "ERROR_BROWSER_NOT_SUPPORTED":
|
|
4926
|
-
errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
|
|
4927
|
-
if (actionBtn) actionBtn.style.display = "none";
|
|
4928
|
-
return;
|
|
4929
|
-
}
|
|
4930
|
-
errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
|
|
4931
|
-
} else console.log("Failed to locate error dialog element");
|
|
4932
|
-
}
|
|
4933
|
-
};
|
|
4934
4688
|
const ErrorDialogHtml = `
|
|
4935
4689
|
<svg class="mobile-wallet-adapter-embedded-modal-error-icon" xmlns="http://www.w3.org/2000/svg" height="50px" viewBox="0 -960 960 960" width="50px" fill="#000000"><path d="M 280,-80 Q 197,-80 138.5,-138.5 80,-197 80,-280 80,-363 138.5,-421.5 197,-480 280,-480 q 83,0 141.5,58.5 58.5,58.5 58.5,141.5 0,83 -58.5,141.5 Q 363,-80 280,-80 Z M 824,-120 568,-376 Q 556,-389 542.5,-402.5 529,-416 516,-428 q 38,-24 61,-64 23,-40 23,-88 0,-75 -52.5,-127.5 Q 495,-760 420,-760 345,-760 292.5,-707.5 240,-655 240,-580 q 0,6 0.5,11.5 0.5,5.5 1.5,11.5 -18,2 -39.5,8 -21.5,6 -38.5,14 -2,-11 -3,-22 -1,-11 -1,-23 0,-109 75.5,-184.5 Q 311,-840 420,-840 q 109,0 184.5,75.5 75.5,75.5 75.5,184.5 0,43 -13.5,81.5 Q 653,-460 629,-428 l 251,252 z m -615,-61 71,-71 70,71 29,-28 -71,-71 71,-71 -28,-28 -71,71 -71,-71 -28,28 71,71 -71,71 z"/></svg>
|
|
4936
4690
|
<div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
|
|
@@ -4990,80 +4744,123 @@ const css = `
|
|
|
4990
4744
|
}
|
|
4991
4745
|
}
|
|
4992
4746
|
`;
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
4747
|
+
|
|
4748
|
+
function defaultErrorModalWalletNotFoundHandler() {
|
|
4749
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4750
|
+
if (typeof window !== 'undefined') {
|
|
4751
|
+
const userAgent = window.navigator.userAgent.toLowerCase();
|
|
4752
|
+
const errorDialog = new ErrorModal();
|
|
4753
|
+
if (userAgent.includes('wv')) { // Android WebView
|
|
4754
|
+
// MWA is not supported in this browser so we inform the user
|
|
4755
|
+
// errorDialog.initWithError(
|
|
4756
|
+
// new SolanaMobileWalletAdapterError(
|
|
4757
|
+
// SolanaMobileWalletAdapterErrorCode.ERROR_BROWSER_NOT_SUPPORTED,
|
|
4758
|
+
// ''
|
|
4759
|
+
// )
|
|
4760
|
+
// );
|
|
4761
|
+
// TODO: investigate why instantiating a new SolanaMobileWalletAdapterError here breaks treeshaking
|
|
4762
|
+
errorDialog.initWithError({
|
|
4763
|
+
name: 'SolanaMobileWalletAdapterError',
|
|
4764
|
+
code: 'ERROR_BROWSER_NOT_SUPPORTED',
|
|
4765
|
+
message: ''
|
|
4766
|
+
});
|
|
4767
|
+
}
|
|
4768
|
+
else { // Browser, user does not have a wallet installed.
|
|
4769
|
+
// errorDialog.initWithError(
|
|
4770
|
+
// new SolanaMobileWalletAdapterError(
|
|
4771
|
+
// SolanaMobileWalletAdapterErrorCode.ERROR_WALLET_NOT_FOUND,
|
|
4772
|
+
// ''
|
|
4773
|
+
// )
|
|
4774
|
+
// );
|
|
4775
|
+
// TODO: investigate why instantiating a new SolanaMobileWalletAdapterError here breaks treeshaking
|
|
4776
|
+
errorDialog.initWithError({
|
|
4777
|
+
name: 'SolanaMobileWalletAdapterError',
|
|
4778
|
+
code: 'ERROR_WALLET_NOT_FOUND',
|
|
4779
|
+
message: ''
|
|
4780
|
+
});
|
|
4781
|
+
}
|
|
4782
|
+
errorDialog.open();
|
|
4783
|
+
}
|
|
4784
|
+
});
|
|
5011
4785
|
}
|
|
5012
4786
|
function createDefaultWalletNotFoundHandler() {
|
|
5013
|
-
|
|
5014
|
-
defaultErrorModalWalletNotFoundHandler();
|
|
5015
|
-
};
|
|
4787
|
+
return () => __awaiter(this, void 0, void 0, function* () { defaultErrorModalWalletNotFoundHandler(); });
|
|
5016
4788
|
}
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
|
|
4789
|
+
|
|
4790
|
+
const CACHE_KEY = 'SolanaMobileWalletAdapterDefaultAuthorizationCache';
|
|
5020
4791
|
function createDefaultAuthorizationCache() {
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
4792
|
+
let storage;
|
|
4793
|
+
try {
|
|
4794
|
+
storage = window.localStorage;
|
|
4795
|
+
// eslint-disable-next-line no-empty
|
|
4796
|
+
}
|
|
4797
|
+
catch (_a) { }
|
|
4798
|
+
return {
|
|
4799
|
+
clear() {
|
|
4800
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4801
|
+
if (!storage) {
|
|
4802
|
+
return;
|
|
4803
|
+
}
|
|
4804
|
+
try {
|
|
4805
|
+
storage.removeItem(CACHE_KEY);
|
|
4806
|
+
// eslint-disable-next-line no-empty
|
|
4807
|
+
}
|
|
4808
|
+
catch (_a) { }
|
|
4809
|
+
});
|
|
4810
|
+
},
|
|
4811
|
+
get() {
|
|
4812
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4813
|
+
if (!storage) {
|
|
4814
|
+
return;
|
|
4815
|
+
}
|
|
4816
|
+
try {
|
|
4817
|
+
const parsed = JSON.parse(storage.getItem(CACHE_KEY));
|
|
4818
|
+
if (parsed && parsed.accounts) {
|
|
4819
|
+
const parsedAccounts = parsed.accounts.map((account) => {
|
|
4820
|
+
return Object.assign(Object.assign({}, account), { publicKey: 'publicKey' in account
|
|
4821
|
+
? new Uint8Array(Object.values(account.publicKey)) // Rebuild publicKey for WalletAccount
|
|
4822
|
+
: base58.decode(account.address) });
|
|
4823
|
+
});
|
|
4824
|
+
return Object.assign(Object.assign({}, parsed), { accounts: parsedAccounts });
|
|
4825
|
+
}
|
|
4826
|
+
else
|
|
4827
|
+
return parsed || undefined;
|
|
4828
|
+
// eslint-disable-next-line no-empty
|
|
4829
|
+
}
|
|
4830
|
+
catch (_a) { }
|
|
4831
|
+
});
|
|
4832
|
+
},
|
|
4833
|
+
set(authorization) {
|
|
4834
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4835
|
+
if (!storage) {
|
|
4836
|
+
return;
|
|
4837
|
+
}
|
|
4838
|
+
try {
|
|
4839
|
+
storage.setItem(CACHE_KEY, JSON.stringify(authorization));
|
|
4840
|
+
// eslint-disable-next-line no-empty
|
|
4841
|
+
}
|
|
4842
|
+
catch (_a) { }
|
|
4843
|
+
});
|
|
4844
|
+
},
|
|
4845
|
+
};
|
|
5057
4846
|
}
|
|
5058
|
-
|
|
5059
|
-
//#region src/createDefaultChainSelector.ts
|
|
4847
|
+
|
|
5060
4848
|
function createDefaultChainSelector() {
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
4849
|
+
return {
|
|
4850
|
+
select(chains) {
|
|
4851
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4852
|
+
if (chains.length === 1) {
|
|
4853
|
+
return chains[0];
|
|
4854
|
+
}
|
|
4855
|
+
else if (chains.includes(SOLANA_MAINNET_CHAIN)) {
|
|
4856
|
+
return SOLANA_MAINNET_CHAIN;
|
|
4857
|
+
}
|
|
4858
|
+
else
|
|
4859
|
+
return chains[0];
|
|
4860
|
+
});
|
|
4861
|
+
},
|
|
4862
|
+
};
|
|
5066
4863
|
}
|
|
5067
4864
|
|
|
5068
4865
|
export { LocalSolanaMobileWalletAdapterWallet, RemoteSolanaMobileWalletAdapterWallet, SolanaMobileWalletAdapterRemoteWalletName, SolanaMobileWalletAdapterWalletName, createDefaultAuthorizationCache, createDefaultChainSelector, createDefaultWalletNotFoundHandler, defaultErrorModalWalletNotFoundHandler, registerMwa };
|
|
5069
|
-
//# sourceMappingURL=index.browser-
|
|
4866
|
+
//# sourceMappingURL=index.browser-DCOvqSUT.esm.js.map
|