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