@pooflabs/web 0.0.80 → 0.0.81-rc1
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/auth/providers/phantom-wallet-provider.d.ts +20 -0
- package/dist/{index-BhfNMrC0.js → index-BSL3D7PC.js} +25 -883
- package/dist/index-BSL3D7PC.js.map +1 -0
- package/dist/{index-BNyxZ82q.js → index-BU6puWaY.js} +279 -275
- package/dist/index-BU6puWaY.js.map +1 -0
- package/dist/index-Bdcc5821.js +2375 -0
- package/dist/index-Bdcc5821.js.map +1 -0
- package/dist/{index-Db0NqU8R.esm.js → index-Cpw11-0x.esm.js} +279 -276
- package/dist/index-Cpw11-0x.esm.js.map +1 -0
- package/dist/index-CrOVJFX9.esm.js +2373 -0
- package/dist/index-CrOVJFX9.esm.js.map +1 -0
- package/dist/{index-COIUWugk.esm.js → index-CtwdL0-L.esm.js} +23 -881
- package/dist/index-CtwdL0-L.esm.js.map +1 -0
- package/dist/{index-BbtYb8sE.esm.js → index-DLfRKZI7.esm.js} +24 -882
- package/dist/index-DLfRKZI7.esm.js.map +1 -0
- package/dist/{index-BVi7fTm2.js → index-Fo9o33oZ.js} +24 -882
- package/dist/index-Fo9o33oZ.js.map +1 -0
- package/dist/index.browser-9JJy5Y7o.esm.js +119 -0
- package/dist/index.browser-9JJy5Y7o.esm.js.map +1 -0
- package/dist/index.browser-B4RzFwu2.js +1253 -0
- package/dist/index.browser-B4RzFwu2.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-8hyi2LOX.js → index.browser-CGfTdDXe.js} +1367 -1697
- package/dist/index.browser-CGfTdDXe.js.map +1 -0
- package/dist/index.browser-CQUvzkLr.js +122 -0
- package/dist/index.browser-CQUvzkLr.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-Dzo4A2XB.esm.js +1250 -0
- package/dist/index.browser-Dzo4A2XB.esm.js.map +1 -0
- package/dist/{index.browser-BuHl80dp.esm.js → index.browser-HEDpODB5.esm.js} +1367 -1697
- package/dist/index.browser-HEDpODB5.esm.js.map +1 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{index.native-DUnE51Mx.js → index.native-DYI4vw0X.js} +186 -2669
- package/dist/index.native-DYI4vw0X.js.map +1 -0
- package/dist/{index.native-DuKhZcus.esm.js → index.native-UxpBL0TA.esm.js} +187 -2669
- package/dist/index.native-UxpBL0TA.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-Cg-srwP4.js → phantom-wallet-provider-BPSAXPZ6.js} +127 -11
- package/dist/{phantom-wallet-provider-Cg-srwP4.js.map → phantom-wallet-provider-BPSAXPZ6.js.map} +1 -1
- package/dist/{phantom-wallet-provider--BJjVUA1.esm.js → phantom-wallet-provider-DcMJW18_.esm.js} +127 -11
- package/dist/{phantom-wallet-provider--BJjVUA1.esm.js.map → phantom-wallet-provider-DcMJW18_.esm.js.map} +1 -1
- package/dist/{privy-wallet-provider-BLcur3Ue.esm.js → privy-wallet-provider-CtIl8FgH.esm.js} +3 -3
- package/dist/privy-wallet-provider-CtIl8FgH.esm.js.map +1 -0
- package/dist/{privy-wallet-provider-DpNVyaXa.js → privy-wallet-provider-Zu5K_vNN.js} +3 -3
- package/dist/privy-wallet-provider-Zu5K_vNN.js.map +1 -0
- package/dist/{solana-mobile-wallet-provider-CFaubssb.esm.js → solana-mobile-wallet-provider-C31APzEp.esm.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-CFaubssb.esm.js.map → solana-mobile-wallet-provider-C31APzEp.esm.js.map} +1 -1
- package/dist/{solana-mobile-wallet-provider-zXAk2tfS.js → solana-mobile-wallet-provider-Dg9_h3QI.js} +4 -4
- package/dist/{solana-mobile-wallet-provider-zXAk2tfS.js.map → solana-mobile-wallet-provider-Dg9_h3QI.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-BNyxZ82q.js.map +0 -1
- package/dist/index-BVi7fTm2.js.map +0 -1
- package/dist/index-BbtYb8sE.esm.js.map +0 -1
- package/dist/index-BhfNMrC0.js.map +0 -1
- package/dist/index-CKIoDkjJ.esm.js +0 -6
- package/dist/index-CKIoDkjJ.esm.js.map +0 -1
- package/dist/index-COIUWugk.esm.js.map +0 -1
- package/dist/index-CSraUgD6.js +0 -8
- package/dist/index-CSraUgD6.js.map +0 -1
- package/dist/index-Db0NqU8R.esm.js.map +0 -1
- package/dist/index.browser-8hyi2LOX.js.map +0 -1
- package/dist/index.browser-B4zXnffD.esm.js +0 -225
- package/dist/index.browser-B4zXnffD.esm.js.map +0 -1
- package/dist/index.browser-BJ_TdUVA.js +0 -228
- package/dist/index.browser-BJ_TdUVA.js.map +0 -1
- package/dist/index.browser-BkNaRRVe.js +0 -1222
- package/dist/index.browser-BkNaRRVe.js.map +0 -1
- package/dist/index.browser-BuHl80dp.esm.js.map +0 -1
- package/dist/index.browser-CnbxBj3-.esm.js +0 -1219
- package/dist/index.browser-CnbxBj3-.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-vuTr40so.js +0 -1008
- package/dist/index.browser-vuTr40so.js.map +0 -1
- package/dist/index.native-DUnE51Mx.js.map +0 -1
- package/dist/index.native-DuKhZcus.esm.js.map +0 -1
- package/dist/privy-wallet-provider-BLcur3Ue.esm.js.map +0 -1
- package/dist/privy-wallet-provider-DpNVyaXa.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var index = require('./index-BU6puWaY.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,142 +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
|
-
// base-x encoding / decoding
|
|
35
|
-
// Copyright (c) 2018 base-x contributors
|
|
36
|
-
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
|
|
37
|
-
// Distributed under the MIT software license, see the accompanying
|
|
38
|
-
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
39
|
-
function base (ALPHABET) {
|
|
40
|
-
if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }
|
|
41
|
-
const BASE_MAP = new Uint8Array(256);
|
|
42
|
-
for (let j = 0; j < BASE_MAP.length; j++) {
|
|
43
|
-
BASE_MAP[j] = 255;
|
|
44
|
-
}
|
|
45
|
-
for (let i = 0; i < ALPHABET.length; i++) {
|
|
46
|
-
const x = ALPHABET.charAt(i);
|
|
47
|
-
const xc = x.charCodeAt(0);
|
|
48
|
-
if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }
|
|
49
|
-
BASE_MAP[xc] = i;
|
|
50
|
-
}
|
|
51
|
-
const BASE = ALPHABET.length;
|
|
52
|
-
const LEADER = ALPHABET.charAt(0);
|
|
53
|
-
const FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
|
|
54
|
-
const iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
|
|
55
|
-
function encode (source) {
|
|
56
|
-
// eslint-disable-next-line no-empty
|
|
57
|
-
if (source instanceof Uint8Array) ; else if (ArrayBuffer.isView(source)) {
|
|
58
|
-
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
59
|
-
} else if (Array.isArray(source)) {
|
|
60
|
-
source = Uint8Array.from(source);
|
|
61
|
-
}
|
|
62
|
-
if (!(source instanceof Uint8Array)) { throw new TypeError('Expected Uint8Array') }
|
|
63
|
-
if (source.length === 0) { return '' }
|
|
64
|
-
// Skip & count leading zeroes.
|
|
65
|
-
let zeroes = 0;
|
|
66
|
-
let length = 0;
|
|
67
|
-
let pbegin = 0;
|
|
68
|
-
const pend = source.length;
|
|
69
|
-
while (pbegin !== pend && source[pbegin] === 0) {
|
|
70
|
-
pbegin++;
|
|
71
|
-
zeroes++;
|
|
72
|
-
}
|
|
73
|
-
// Allocate enough space in big-endian base58 representation.
|
|
74
|
-
const size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
|
|
75
|
-
const b58 = new Uint8Array(size);
|
|
76
|
-
// Process the bytes.
|
|
77
|
-
while (pbegin !== pend) {
|
|
78
|
-
let carry = source[pbegin];
|
|
79
|
-
// Apply "b58 = b58 * 256 + ch".
|
|
80
|
-
let i = 0;
|
|
81
|
-
for (let it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
|
|
82
|
-
carry += (256 * b58[it1]) >>> 0;
|
|
83
|
-
b58[it1] = (carry % BASE) >>> 0;
|
|
84
|
-
carry = (carry / BASE) >>> 0;
|
|
85
|
-
}
|
|
86
|
-
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
87
|
-
length = i;
|
|
88
|
-
pbegin++;
|
|
89
|
-
}
|
|
90
|
-
// Skip leading zeroes in base58 result.
|
|
91
|
-
let it2 = size - length;
|
|
92
|
-
while (it2 !== size && b58[it2] === 0) {
|
|
93
|
-
it2++;
|
|
94
|
-
}
|
|
95
|
-
// Translate the result into a string.
|
|
96
|
-
let str = LEADER.repeat(zeroes);
|
|
97
|
-
for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]); }
|
|
98
|
-
return str
|
|
99
|
-
}
|
|
100
|
-
function decodeUnsafe (source) {
|
|
101
|
-
if (typeof source !== 'string') { throw new TypeError('Expected String') }
|
|
102
|
-
if (source.length === 0) { return new Uint8Array() }
|
|
103
|
-
let psz = 0;
|
|
104
|
-
// Skip and count leading '1's.
|
|
105
|
-
let zeroes = 0;
|
|
106
|
-
let length = 0;
|
|
107
|
-
while (source[psz] === LEADER) {
|
|
108
|
-
zeroes++;
|
|
109
|
-
psz++;
|
|
110
|
-
}
|
|
111
|
-
// Allocate enough space in big-endian base256 representation.
|
|
112
|
-
const size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
|
|
113
|
-
const b256 = new Uint8Array(size);
|
|
114
|
-
// Process the characters.
|
|
115
|
-
while (psz < source.length) {
|
|
116
|
-
// Find code of next character
|
|
117
|
-
const charCode = source.charCodeAt(psz);
|
|
118
|
-
// Base map can not be indexed using char code
|
|
119
|
-
if (charCode > 255) { return }
|
|
120
|
-
// Decode character
|
|
121
|
-
let carry = BASE_MAP[charCode];
|
|
122
|
-
// Invalid character
|
|
123
|
-
if (carry === 255) { return }
|
|
124
|
-
let i = 0;
|
|
125
|
-
for (let it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
|
|
126
|
-
carry += (BASE * b256[it3]) >>> 0;
|
|
127
|
-
b256[it3] = (carry % 256) >>> 0;
|
|
128
|
-
carry = (carry / 256) >>> 0;
|
|
129
|
-
}
|
|
130
|
-
if (carry !== 0) { throw new Error('Non-zero carry') }
|
|
131
|
-
length = i;
|
|
132
|
-
psz++;
|
|
133
|
-
}
|
|
134
|
-
// Skip leading zeroes in b256.
|
|
135
|
-
let it4 = size - length;
|
|
136
|
-
while (it4 !== size && b256[it4] === 0) {
|
|
137
|
-
it4++;
|
|
138
|
-
}
|
|
139
|
-
const vch = new Uint8Array(zeroes + (size - it4));
|
|
140
|
-
let j = zeroes;
|
|
141
|
-
while (it4 !== size) {
|
|
142
|
-
vch[j++] = b256[it4++];
|
|
143
|
-
}
|
|
144
|
-
return vch
|
|
145
|
-
}
|
|
146
|
-
function decode (string) {
|
|
147
|
-
const buffer = decodeUnsafe(string);
|
|
148
|
-
if (buffer) { return buffer }
|
|
149
|
-
throw new Error('Non-base' + BASE + ' character')
|
|
150
|
-
}
|
|
151
|
-
return {
|
|
152
|
-
encode,
|
|
153
|
-
decodeUnsafe,
|
|
154
|
-
decode
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
var ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
159
|
-
var base58 = base(ALPHABET);
|
|
160
|
-
|
|
161
25
|
var browser = {};
|
|
162
26
|
|
|
163
27
|
var canPromise;
|
|
@@ -3230,239 +3094,200 @@ function requireBrowser () {
|
|
|
3230
3094
|
var browserExports = requireBrowser();
|
|
3231
3095
|
var QRCode = /*@__PURE__*/index.getDefaultExportFromCjs(browserExports);
|
|
3232
3096
|
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
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");
|
|
3236
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
3237
|
-
};
|
|
3238
|
-
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3239
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3240
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
3241
|
-
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");
|
|
3242
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
3243
|
-
};
|
|
3244
|
-
var _RegisterWalletEvent_detail;
|
|
3245
|
-
/**
|
|
3246
|
-
* Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
|
|
3247
|
-
*
|
|
3248
|
-
* This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
|
|
3249
|
-
* ready to be registered.
|
|
3250
|
-
*
|
|
3251
|
-
* This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
|
|
3252
|
-
* the app that the app is ready to register the Wallet.
|
|
3253
|
-
*
|
|
3254
|
-
* This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
|
|
3255
|
-
* as the app is ready whether the Wallet loads before or after the app.
|
|
3256
|
-
*
|
|
3257
|
-
* @param wallet Wallet to register.
|
|
3258
|
-
*
|
|
3259
|
-
* @group Wallet
|
|
3260
|
-
*/
|
|
3261
|
-
function registerWallet(wallet) {
|
|
3262
|
-
const callback = ({ register }) => register(wallet);
|
|
3263
|
-
try {
|
|
3264
|
-
window.dispatchEvent(new RegisterWalletEvent(callback));
|
|
3265
|
-
}
|
|
3266
|
-
catch (error) {
|
|
3267
|
-
console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
|
|
3268
|
-
}
|
|
3269
|
-
try {
|
|
3270
|
-
window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
|
|
3271
|
-
}
|
|
3272
|
-
catch (error) {
|
|
3273
|
-
console.error('wallet-standard:app-ready event listener could not be added\n', error);
|
|
3274
|
-
}
|
|
3275
|
-
}
|
|
3276
|
-
class RegisterWalletEvent extends Event {
|
|
3277
|
-
get detail() {
|
|
3278
|
-
return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
|
|
3279
|
-
}
|
|
3280
|
-
get type() {
|
|
3281
|
-
return 'wallet-standard:register-wallet';
|
|
3282
|
-
}
|
|
3283
|
-
constructor(callback) {
|
|
3284
|
-
super('wallet-standard:register-wallet', {
|
|
3285
|
-
bubbles: false,
|
|
3286
|
-
cancelable: false,
|
|
3287
|
-
composed: false,
|
|
3288
|
-
});
|
|
3289
|
-
_RegisterWalletEvent_detail.set(this, void 0);
|
|
3290
|
-
__classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
|
|
3291
|
-
}
|
|
3292
|
-
/** @deprecated */
|
|
3293
|
-
preventDefault() {
|
|
3294
|
-
throw new Error('preventDefault cannot be called');
|
|
3295
|
-
}
|
|
3296
|
-
/** @deprecated */
|
|
3297
|
-
stopImmediatePropagation() {
|
|
3298
|
-
throw new Error('stopImmediatePropagation cannot be called');
|
|
3299
|
-
}
|
|
3300
|
-
/** @deprecated */
|
|
3301
|
-
stopPropagation() {
|
|
3302
|
-
throw new Error('stopPropagation cannot be called');
|
|
3303
|
-
}
|
|
3304
|
-
}
|
|
3305
|
-
_RegisterWalletEvent_detail = new WeakMap();
|
|
3097
|
+
/** Name of the feature. */
|
|
3098
|
+
const StandardConnect = 'standard:connect';
|
|
3306
3099
|
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
return window.btoa(String.fromCharCode.call(null, ...byteArray));
|
|
3310
|
-
}
|
|
3311
|
-
function toUint8Array(base64EncodedByteArray) {
|
|
3312
|
-
return new Uint8Array(window.atob(base64EncodedByteArray).split("").map((c) => c.charCodeAt(0)));
|
|
3313
|
-
}
|
|
3314
|
-
//#endregion
|
|
3315
|
-
//#region src/embedded-modal/loadingSpinner.ts
|
|
3316
|
-
const modalHtml$1 = `
|
|
3317
|
-
<div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
3318
|
-
<div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
|
|
3319
|
-
<div class="mobile-wallet-adapter-embedded-loading-container">
|
|
3320
|
-
<div class="mobile-wallet-adapter-embedded-loading-animation"></div>
|
|
3321
|
-
</div>
|
|
3322
|
-
</div>
|
|
3323
|
-
`;
|
|
3324
|
-
const css$6 = `
|
|
3325
|
-
.mobile-wallet-adapter-embedded-loading-indicator {
|
|
3326
|
-
display: flex; /* Use flexbox to center content */
|
|
3327
|
-
justify-content: center; /* Center horizontally */
|
|
3328
|
-
align-items: start; /* Center vertically */
|
|
3329
|
-
position: fixed; /* Stay in place */
|
|
3330
|
-
z-index: 1; /* Sit on top */
|
|
3331
|
-
left: 0;
|
|
3332
|
-
top: 0;
|
|
3333
|
-
width: 100%; /* Full width */
|
|
3334
|
-
height: 100%; /* Full height */
|
|
3335
|
-
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
|
3336
|
-
overflow-y: auto; /* enable scrolling */
|
|
3337
|
-
}
|
|
3100
|
+
/** Name of the feature. */
|
|
3101
|
+
const StandardDisconnect = 'standard:disconnect';
|
|
3338
3102
|
|
|
3339
|
-
.
|
|
3340
|
-
|
|
3341
|
-
|
|
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;
|
|
3342
3236
|
}
|
|
3343
3237
|
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
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;
|
|
3356
3249
|
}
|
|
3357
3250
|
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
}
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
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;
|
|
3394
3288
|
}
|
|
3395
|
-
|
|
3396
|
-
var
|
|
3397
|
-
#root = null;
|
|
3398
|
-
#eventListeners = {};
|
|
3399
|
-
#listenersAttached = false;
|
|
3400
|
-
dom = null;
|
|
3401
|
-
constructor() {
|
|
3402
|
-
this.init = this.init.bind(this);
|
|
3403
|
-
this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
|
|
3404
|
-
}
|
|
3405
|
-
async init() {
|
|
3406
|
-
console.log("Injecting modal");
|
|
3407
|
-
this.#injectHTML();
|
|
3408
|
-
}
|
|
3409
|
-
open = () => {
|
|
3410
|
-
console.debug("Modal open");
|
|
3411
|
-
this.#attachEventListeners();
|
|
3412
|
-
if (this.#root) this.#root.style.display = "flex";
|
|
3413
|
-
};
|
|
3414
|
-
close = (event = void 0) => {
|
|
3415
|
-
console.debug("Modal close");
|
|
3416
|
-
this.#removeEventListeners();
|
|
3417
|
-
if (this.#root) this.#root.style.display = "none";
|
|
3418
|
-
this.#eventListeners["close"]?.forEach((listener) => listener(event));
|
|
3419
|
-
};
|
|
3420
|
-
addEventListener(event, listener) {
|
|
3421
|
-
this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
|
|
3422
|
-
return () => this.removeEventListener(event, listener);
|
|
3423
|
-
}
|
|
3424
|
-
removeEventListener(event, listener) {
|
|
3425
|
-
this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
|
|
3426
|
-
}
|
|
3427
|
-
#injectHTML() {
|
|
3428
|
-
if (this.dom) return;
|
|
3429
|
-
this.#root = document.createElement("div");
|
|
3430
|
-
this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
|
|
3431
|
-
this.#root.innerHTML = modalHtml$1;
|
|
3432
|
-
this.#root.style.display = "none";
|
|
3433
|
-
const styles = document.createElement("style");
|
|
3434
|
-
styles.id = "mobile-wallet-adapter-embedded-modal-styles";
|
|
3435
|
-
styles.textContent = css$6;
|
|
3436
|
-
const host = document.createElement("div");
|
|
3437
|
-
this.dom = host.attachShadow({ mode: "closed" });
|
|
3438
|
-
host.style.setProperty("--spinner-color", "#FFFFFF");
|
|
3439
|
-
this.dom.appendChild(styles);
|
|
3440
|
-
this.dom.appendChild(this.#root);
|
|
3441
|
-
document.body.appendChild(host);
|
|
3442
|
-
}
|
|
3443
|
-
#attachEventListeners() {
|
|
3444
|
-
if (!this.#root || this.#listenersAttached) return;
|
|
3445
|
-
[...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
|
|
3446
|
-
this.close(event);
|
|
3447
|
-
}));
|
|
3448
|
-
window.addEventListener("load", this.close);
|
|
3449
|
-
document.addEventListener("keydown", this.#handleKeyDown);
|
|
3450
|
-
this.#listenersAttached = true;
|
|
3451
|
-
}
|
|
3452
|
-
#removeEventListeners() {
|
|
3453
|
-
if (!this.#listenersAttached) return;
|
|
3454
|
-
window.removeEventListener("load", this.close);
|
|
3455
|
-
document.removeEventListener("keydown", this.#handleKeyDown);
|
|
3456
|
-
if (!this.#root) return;
|
|
3457
|
-
[...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
|
|
3458
|
-
this.#listenersAttached = false;
|
|
3459
|
-
}
|
|
3460
|
-
#handleKeyDown = (event) => {
|
|
3461
|
-
if (event.key === "Escape") this.close(event);
|
|
3462
|
-
};
|
|
3463
|
-
};
|
|
3464
|
-
//#endregion
|
|
3465
|
-
//#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;
|
|
3466
3291
|
const modalHtml = `
|
|
3467
3292
|
<div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
3468
3293
|
<div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
|
|
@@ -3478,13 +3303,13 @@ const modalHtml = `
|
|
|
3478
3303
|
</div>
|
|
3479
3304
|
</div>
|
|
3480
3305
|
`;
|
|
3481
|
-
const css$
|
|
3306
|
+
const css$2 = `
|
|
3482
3307
|
.mobile-wallet-adapter-embedded-modal-container {
|
|
3483
3308
|
display: flex; /* Use flexbox to center content */
|
|
3484
3309
|
justify-content: center; /* Center horizontally */
|
|
3485
3310
|
align-items: center; /* Center vertically */
|
|
3486
3311
|
position: fixed; /* Stay in place */
|
|
3487
|
-
z-index:
|
|
3312
|
+
z-index: 1; /* Sit on top */
|
|
3488
3313
|
left: 0;
|
|
3489
3314
|
top: 0;
|
|
3490
3315
|
width: 100%; /* Full width */
|
|
@@ -3540,100 +3365,134 @@ const fonts = `
|
|
|
3540
3365
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
3541
3366
|
<link href="https://fonts.googleapis.com/css2?family=Inter+Tight:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
|
|
3542
3367
|
`;
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
};
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
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);
|
|
3636
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
|
+
}
|
|
3637
3496
|
const QRCodeHtml = `
|
|
3638
3497
|
<div class="mobile-wallet-adapter-embedded-modal-qr-content">
|
|
3639
3498
|
<div>
|
|
@@ -3649,9 +3508,7 @@ const QRCodeHtml = `
|
|
|
3649
3508
|
Open your wallet and scan this code
|
|
3650
3509
|
</h4>
|
|
3651
3510
|
</div>
|
|
3652
|
-
<div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
|
|
3653
|
-
<div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
|
|
3654
|
-
</div>
|
|
3511
|
+
<div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container"></div>
|
|
3655
3512
|
</div>
|
|
3656
3513
|
</div>
|
|
3657
3514
|
<div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
|
|
@@ -3678,7 +3535,7 @@ const QRCodeHtml = `
|
|
|
3678
3535
|
</div>
|
|
3679
3536
|
</div>
|
|
3680
3537
|
`;
|
|
3681
|
-
const css$
|
|
3538
|
+
const css$1 = `
|
|
3682
3539
|
.mobile-wallet-adapter-embedded-modal-qr-content {
|
|
3683
3540
|
display: flex;
|
|
3684
3541
|
margin-top: 10px;
|
|
@@ -3722,16 +3579,6 @@ const css$4 = `
|
|
|
3722
3579
|
margin-left: auto;
|
|
3723
3580
|
}
|
|
3724
3581
|
|
|
3725
|
-
.mobile-wallet-adapter-embedded-modal-qr-placeholder {
|
|
3726
|
-
margin-left: auto;
|
|
3727
|
-
min-width: 200px;
|
|
3728
|
-
min-height: 200px;
|
|
3729
|
-
background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
|
|
3730
|
-
background-size: 200%;
|
|
3731
|
-
animation: placeholderAnimate 2.7s linear infinite;
|
|
3732
|
-
border-radius: 12px;
|
|
3733
|
-
}
|
|
3734
|
-
|
|
3735
3582
|
.mobile-wallet-adapter-embedded-modal-divider {
|
|
3736
3583
|
margin-top: 20px;
|
|
3737
3584
|
padding-left: 10px;
|
|
@@ -3804,15 +3651,6 @@ const css$4 = `
|
|
|
3804
3651
|
.mobile-wallet-adapter-embedded-modal-qr-code-container {
|
|
3805
3652
|
margin: auto;
|
|
3806
3653
|
}
|
|
3807
|
-
.mobile-wallet-adapter-embedded-modal-qr-placeholder {
|
|
3808
|
-
margin: auto;
|
|
3809
|
-
}
|
|
3810
|
-
}
|
|
3811
|
-
|
|
3812
|
-
/* QR Placeholder */
|
|
3813
|
-
@keyframes placeholderAnimate {
|
|
3814
|
-
0% { background-position: 200% 0; }
|
|
3815
|
-
100% { background-position: -200% 0; }
|
|
3816
3654
|
}
|
|
3817
3655
|
|
|
3818
3656
|
/* Spinner */
|
|
@@ -3893,1173 +3731,962 @@ const css$4 = `
|
|
|
3893
3731
|
animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
|
|
3894
3732
|
}
|
|
3895
3733
|
`;
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
initWithCallback(callback) {
|
|
3902
|
-
super.init();
|
|
3903
|
-
this.#prepareLaunchAction(callback);
|
|
3904
|
-
}
|
|
3905
|
-
#prepareLaunchAction(callback) {
|
|
3906
|
-
const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
|
|
3907
|
-
const listener = async () => {
|
|
3908
|
-
launchButton?.removeEventListener("click", listener);
|
|
3909
|
-
this.close();
|
|
3910
|
-
callback();
|
|
3911
|
-
};
|
|
3912
|
-
launchButton?.addEventListener("click", listener);
|
|
3913
|
-
}
|
|
3914
|
-
};
|
|
3915
|
-
const ErrorDialogHtml$3 = `
|
|
3916
|
-
<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">
|
|
3917
|
-
<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"/>
|
|
3918
|
-
<mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
|
|
3919
|
-
<rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
|
|
3920
|
-
</mask>
|
|
3921
|
-
<g mask="url(#mask0_189_522)">
|
|
3922
|
-
<mask id="mask1_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
|
|
3923
|
-
<rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
|
|
3924
|
-
</mask>
|
|
3925
|
-
<g mask="url(#mask1_189_522)">
|
|
3926
|
-
<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"/>
|
|
3927
|
-
</g>
|
|
3928
|
-
</g>
|
|
3929
|
-
</svg>
|
|
3930
|
-
<div class="mobile-wallet-adapter-embedded-modal-title">Ready to connect!</div>
|
|
3931
|
-
<div>
|
|
3932
|
-
<button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
|
|
3933
|
-
Connect Wallet
|
|
3934
|
-
</button>
|
|
3935
|
-
</div>
|
|
3936
|
-
`;
|
|
3937
|
-
const css$3 = `
|
|
3938
|
-
.mobile-wallet-adapter-embedded-modal-close {
|
|
3939
|
-
display: none;
|
|
3940
|
-
}
|
|
3941
|
-
.mobile-wallet-adapter-embedded-modal-content {
|
|
3942
|
-
text-align: center;
|
|
3943
|
-
min-width: 300px;
|
|
3944
|
-
}
|
|
3945
|
-
.mobile-wallet-adapter-embedded-modal-launch-icon {
|
|
3946
|
-
margin-top: 24px;
|
|
3947
|
-
}
|
|
3948
|
-
.mobile-wallet-adapter-embedded-modal-title {
|
|
3949
|
-
margin: 18px 100px 30px 100px;
|
|
3950
|
-
color: #000000;
|
|
3951
|
-
font-size: 2.75em;
|
|
3952
|
-
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));
|
|
3953
3739
|
}
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
background: #000000;
|
|
3960
|
-
color: #FFFFFF;
|
|
3961
|
-
border-radius: 18px;
|
|
3740
|
+
function toUint8Array(base64EncodedByteArray) {
|
|
3741
|
+
return new Uint8Array(window
|
|
3742
|
+
.atob(base64EncodedByteArray)
|
|
3743
|
+
.split('')
|
|
3744
|
+
.map((c) => c.charCodeAt(0)));
|
|
3962
3745
|
}
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
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
|
+
});
|
|
3969
4080
|
}
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
//#endregion
|
|
3973
|
-
//#region src/embedded-modal/loopbackBlockedModal.ts
|
|
3974
|
-
var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
|
|
3975
|
-
contentStyles = css$2;
|
|
3976
|
-
get contentHtml() {
|
|
3977
|
-
const instructions = getIsPwaLaunchedAsApp() ? "Long press the app icon on your home screen to open site settings" : "Tap the lock or settings icon in the address bar to open site settings";
|
|
3978
|
-
return ErrorDialogHtml$2.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
|
|
3979
|
-
}
|
|
3980
|
-
async init() {
|
|
3981
|
-
super.init();
|
|
3982
|
-
this.#prepareLaunchAction();
|
|
3983
|
-
}
|
|
3984
|
-
#prepareLaunchAction() {
|
|
3985
|
-
const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
|
|
3986
|
-
const listener = async (event) => {
|
|
3987
|
-
launchButton?.removeEventListener("click", listener);
|
|
3988
|
-
this.close(event);
|
|
3989
|
-
};
|
|
3990
|
-
launchButton?.addEventListener("click", listener);
|
|
3991
|
-
}
|
|
3992
|
-
};
|
|
3993
|
-
const ErrorDialogHtml$2 = `
|
|
3994
|
-
<div class="mobile-wallet-adapter-embedded-modal-header">
|
|
3995
|
-
Local Wallet Connection
|
|
3996
|
-
</div>
|
|
3997
|
-
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3998
|
-
<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="#ED1515"/>
|
|
3999
|
-
<mask id="mask0_147_1364" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
|
|
4000
|
-
<rect x="8" y="8" width="32" height="32" fill="#D9D9D9"/>
|
|
4001
|
-
</mask>
|
|
4002
|
-
<g mask="url(#mask0_147_1364)">
|
|
4003
|
-
<path d="M20.1398 36.2705C19.7363 36.2705 19.3508 36.1945 18.9835 36.0425C18.6162 35.8907 18.2916 35.674 18.0098 35.3922L12.6072 29.9895C12.3254 29.7077 12.1086 29.3832 11.9568 29.0158C11.8048 28.6485 11.7288 28.2631 11.7288 27.8595V20.1395C11.7288 19.736 11.8048 19.3505 11.9568 18.9832C12.1086 18.6158 12.3254 18.2913 12.6072 18.0095L18.0098 12.6068C18.2916 12.3251 18.6162 12.1083 18.9835 11.9565C19.3508 11.8045 19.7363 11.7285 20.1398 11.7285H27.8598C28.2634 11.7285 28.6488 11.8045 29.0162 11.9565C29.3835 12.1083 29.708 12.3251 29.9898 12.6068L35.3925 18.0095C35.6743 18.2913 35.891 18.6158 36.0428 18.9832C36.1948 19.3505 36.2708 19.736 36.2708 20.1395V27.8595C36.2708 28.2631 36.1948 28.6485 36.0428 29.0158C35.891 29.3832 35.6743 29.7077 35.3925 29.9895L29.9898 35.3922C29.708 35.674 29.3835 35.8907 29.0162 36.0425C28.6488 36.1945 28.2634 36.2705 27.8598 36.2705H20.1398ZM20.1732 33.2372H27.8265L33.2375 27.8262V20.1728L27.8265 14.7618H20.1732L14.7622 20.1728V27.8262L20.1732 33.2372ZM23.9998 25.9538L26.7868 28.7408C27.0473 29.0013 27.3729 29.1302 27.7638 29.1275C28.1549 29.1248 28.4807 28.9933 28.7412 28.7328C29.0016 28.4724 29.1318 28.1466 29.1318 27.7555C29.1318 27.3646 29.0016 27.039 28.7412 26.7785L25.9542 23.9995L28.7412 21.2125C29.0016 20.9521 29.1318 20.6264 29.1318 20.2355C29.1318 19.8444 29.0016 19.5186 28.7412 19.2582C28.4807 18.9977 28.1549 18.8675 27.7638 18.8675C27.3729 18.8675 27.0473 18.9977 26.7868 19.2582L23.9998 22.0452L21.2128 19.2582C20.9524 18.9977 20.628 18.8675 20.2398 18.8675C19.8514 18.8675 19.5269 18.9977 19.2665 19.2582C19.006 19.5186 18.8758 19.8444 18.8758 20.2355C18.8758 20.6264 19.006 20.9521 19.2665 21.2125L22.0455 23.9995L19.2585 26.7865C18.998 27.047 18.8692 27.3713 18.8718 27.7595C18.8745 28.148 19.006 28.4724 19.2665 28.7328C19.5269 28.9933 19.8527 29.1235 20.2438 29.1235C20.6347 29.1235 20.9604 28.9933 21.2208 28.7328L23.9998 25.9538Z" fill="black"/>
|
|
4004
|
-
</g>
|
|
4005
|
-
</svg>
|
|
4006
|
-
<div class="mobile-wallet-adapter-embedded-modal-title">
|
|
4007
|
-
Your wallet connection is blocked
|
|
4008
|
-
</div>
|
|
4009
|
-
<div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
|
|
4010
|
-
Visit site settings in the address bar and allow "Apps on Device".
|
|
4011
|
-
</div>
|
|
4012
|
-
|
|
4013
|
-
<div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
|
|
4014
|
-
<div class="mobile-wallet-adapter-embedded-modal-footer">
|
|
4015
|
-
<div class="mobile-wallet-adapter-embedded-modal-details">
|
|
4016
|
-
<!-- Clickable header (label associated with the checkbox) -->
|
|
4017
|
-
<label for="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-header">
|
|
4018
|
-
<!-- Hidden checkbox to track state -->
|
|
4019
|
-
<input type="checkbox" id="collapsible-1" class="mobile-wallet-adapter-embedded-modal-details-collapsible-input">
|
|
4020
|
-
<span class="mobile-wallet-adapter-embedded-modal-details-collapsible-header-label">
|
|
4021
|
-
See details
|
|
4022
|
-
</span>
|
|
4023
|
-
<svg class="mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
4024
|
-
<mask id="mask0_147_1382" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="24" height="24">
|
|
4025
|
-
<rect width="24" height="24" fill="#D9D9D9"/>
|
|
4026
|
-
</mask>
|
|
4027
|
-
<g mask="url(#mask0_147_1382)">
|
|
4028
|
-
<path d="M11.9999 17.0811C11.8506 17.0811 11.7087 17.0563 11.5741 17.0067C11.4395 16.957 11.3162 16.8762 11.2042 16.7643L6.57924 12.1393C6.36801 11.9281 6.26656 11.667 6.27489 11.3561C6.28322 11.0453 6.39301 10.7842 6.60424 10.573C6.81547 10.3618 7.08069 10.2561 7.39989 10.2561C7.71909 10.2561 7.9843 10.3618 8.19554 10.573L11.9999 14.3773L15.8292 10.548C16.0405 10.3368 16.3015 10.2353 16.6124 10.2436C16.9233 10.252 17.1843 10.3618 17.3955 10.573C17.6068 10.7842 17.7124 11.0494 17.7124 11.3686C17.7124 11.6878 17.6068 11.9531 17.3955 12.1643L12.7955 16.7643C12.6836 16.8762 12.5603 16.957 12.4257 17.0067C12.2911 17.0563 12.1492 17.0811 11.9999 17.0811Z" fill="black"/>
|
|
4029
|
-
</g>
|
|
4030
|
-
</svg>
|
|
4031
|
-
</label>
|
|
4032
|
-
|
|
4033
|
-
<!-- Content to show/hide -->
|
|
4034
|
-
<ul class="mobile-wallet-adapter-embedded-modal-details-collapsible-content">
|
|
4035
|
-
<li>{{PERMISSION_INSTRUCTION_DETAIL}}</li>
|
|
4036
|
-
<li>Allow "Apps on Device"</li>
|
|
4037
|
-
</ul>
|
|
4038
|
-
</div>
|
|
4039
|
-
</div>
|
|
4040
|
-
<div>
|
|
4041
|
-
<button data-modal-action id="mobile-wallet-adapter-launch-action" class="mobile-wallet-adapter-embedded-modal-launch-action">
|
|
4042
|
-
Got it
|
|
4043
|
-
</button>
|
|
4044
|
-
</div>
|
|
4045
|
-
`;
|
|
4046
|
-
const css$2 = `
|
|
4047
|
-
.mobile-wallet-adapter-embedded-modal-close {
|
|
4048
|
-
display: none;
|
|
4049
|
-
}
|
|
4050
|
-
.mobile-wallet-adapter-embedded-modal-content {
|
|
4051
|
-
text-align: center;
|
|
4052
|
-
}
|
|
4053
|
-
.mobile-wallet-adapter-embedded-modal-header {
|
|
4054
|
-
margin: 18px auto 30px auto;
|
|
4055
|
-
color: #7D9093;
|
|
4056
|
-
font-size: 1.0em;
|
|
4057
|
-
font-weight: 500;
|
|
4058
|
-
}
|
|
4059
|
-
.mobile-wallet-adapter-embedded-modal-title {
|
|
4060
|
-
margin: 18px 100px auto 100px;
|
|
4061
|
-
color: #000000;
|
|
4062
|
-
font-size: 2.75em;
|
|
4063
|
-
font-weight: 600;
|
|
4064
|
-
}
|
|
4065
|
-
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
4066
|
-
margin: 12px 60px 30px 60px;
|
|
4067
|
-
color: #7D9093;
|
|
4068
|
-
font-size: 1.25em;
|
|
4069
|
-
font-weight: 400;
|
|
4070
|
-
}
|
|
4071
|
-
.mobile-wallet-adapter-embedded-modal-details-collapsible-header {
|
|
4072
|
-
display: flex;
|
|
4073
|
-
flex-direction: row;
|
|
4074
|
-
justify-content: space-between;
|
|
4075
|
-
margin: 10px auto 10px auto;
|
|
4076
|
-
color: #000000;
|
|
4077
|
-
font-size: 1.5em;
|
|
4078
|
-
font-weight: 600;
|
|
4079
|
-
cursor: pointer; /* Show pointer on hover */
|
|
4080
|
-
transition: background 0.2s ease; /* Smooth background change */
|
|
4081
|
-
}
|
|
4082
|
-
.mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
|
|
4083
|
-
transition: rotate 0.3s ease;
|
|
4084
|
-
}
|
|
4085
|
-
.mobile-wallet-adapter-embedded-modal-details-collapsible-input {
|
|
4086
|
-
display: none; /* Hide the checkbox */
|
|
4087
|
-
}
|
|
4088
|
-
.mobile-wallet-adapter-embedded-modal-details-collapsible-content {
|
|
4089
|
-
margin: 0px auto 40px auto;
|
|
4090
|
-
max-height: 0px; /* Collapse content */
|
|
4091
|
-
overflow: hidden; /* Hide overflow when collapsed */
|
|
4092
|
-
transition: max-height 0.3s ease; /* Smooth transition */
|
|
4093
|
-
}
|
|
4094
|
-
.mobile-wallet-adapter-embedded-modal-details-collapsible-content li {
|
|
4095
|
-
margin: 20px auto;
|
|
4096
|
-
color: #000000;
|
|
4097
|
-
font-size: 1.25em;
|
|
4098
|
-
font-weight: 400;
|
|
4099
|
-
text-align: left;
|
|
4100
|
-
}
|
|
4101
|
-
/* When checkbox is checked, show content */
|
|
4102
|
-
.mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) ~ .mobile-wallet-adapter-embedded-modal-details-collapsible-content {
|
|
4103
|
-
max-height: 300px;
|
|
4104
|
-
}
|
|
4105
|
-
.mobile-wallet-adapter-embedded-modal-details-collapsible-header:has(> input:checked) > .mobile-wallet-adapter-embedded-modal-details-collapsible-header-icon {
|
|
4106
|
-
rotate: 180deg;
|
|
4107
|
-
}
|
|
4108
|
-
.mobile-wallet-adapter-embedded-modal-launch-action {
|
|
4109
|
-
display: block;
|
|
4110
|
-
width: 100%;
|
|
4111
|
-
height: 56px;
|
|
4112
|
-
/*margin-top: 40px;*/
|
|
4113
|
-
font-size: 1.25em;
|
|
4114
|
-
/*line-height: 24px;*/
|
|
4115
|
-
/*letter-spacing: -1%;*/
|
|
4116
|
-
background: #000000;
|
|
4117
|
-
color: #FFFFFF;
|
|
4118
|
-
border-radius: 18px;
|
|
4119
|
-
}
|
|
4120
|
-
/* Smaller screens */
|
|
4121
|
-
@media all and (max-width: 600px) {
|
|
4122
|
-
.mobile-wallet-adapter-embedded-modal-title {
|
|
4123
|
-
font-size: 1.75em;
|
|
4124
|
-
margin-right: 12px;
|
|
4125
|
-
margin-left: 12px;
|
|
4081
|
+
get version() {
|
|
4082
|
+
return __classPrivateFieldGet$1(this, _LocalSolanaMobileWalletAdapterWallet_version, "f");
|
|
4126
4083
|
}
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
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();
|
|
4130
4129
|
}
|
|
4131
4130
|
}
|
|
4132
|
-
|
|
4133
|
-
|
|
4134
|
-
|
|
4135
|
-
|
|
4136
|
-
|
|
4137
|
-
|
|
4138
|
-
|
|
4139
|
-
super.init();
|
|
4140
|
-
this.#prepareLaunchAction();
|
|
4141
|
-
}
|
|
4142
|
-
#prepareLaunchAction() {
|
|
4143
|
-
const launchButton = this.dom?.getElementById("mobile-wallet-adapter-launch-action");
|
|
4144
|
-
const listener = async () => {
|
|
4145
|
-
launchButton?.removeEventListener("click", listener);
|
|
4146
|
-
try {
|
|
4147
|
-
await fetch("http://localhost");
|
|
4148
|
-
} catch {}
|
|
4149
|
-
this.close();
|
|
4150
|
-
};
|
|
4151
|
-
launchButton?.addEventListener("click", listener);
|
|
4152
|
-
}
|
|
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);
|
|
4153
4138
|
};
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
.
|
|
4182
|
-
|
|
4183
|
-
}
|
|
4184
|
-
.
|
|
4185
|
-
|
|
4186
|
-
}
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
}
|
|
4199
|
-
.
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
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
|
+
});
|
|
4478
|
+
}
|
|
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();
|
|
4527
|
+
}
|
|
4204
4528
|
}
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
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);
|
|
4536
|
+
};
|
|
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
|
+
}
|
|
4213
4580
|
}
|
|
4214
|
-
|
|
4215
|
-
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
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");
|
|
4220
4590
|
}
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
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');
|
|
4224
4608
|
}
|
|
4225
4609
|
}
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
//#region src/getIsSupported.ts
|
|
4610
|
+
_RegisterWalletEvent_detail = new WeakMap();
|
|
4611
|
+
|
|
4229
4612
|
function getIsLocalAssociationSupported() {
|
|
4230
|
-
|
|
4613
|
+
return (typeof window !== 'undefined' &&
|
|
4614
|
+
window.isSecureContext &&
|
|
4615
|
+
typeof document !== 'undefined' &&
|
|
4616
|
+
/android/i.test(navigator.userAgent));
|
|
4231
4617
|
}
|
|
4232
4618
|
function getIsRemoteAssociationSupported() {
|
|
4233
|
-
|
|
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));
|
|
4234
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.
|
|
4235
4626
|
function isWebView(userAgentString) {
|
|
4236
|
-
|
|
4237
|
-
}
|
|
4238
|
-
function isSolanaMobileWebShell(userAgentString) {
|
|
4239
|
-
return userAgentString.includes("Solana Mobile Web Shell");
|
|
4240
|
-
}
|
|
4241
|
-
function getIsPwaLaunchedAsApp() {
|
|
4242
|
-
const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
|
|
4243
|
-
if (typeof window == "undefined") return isAndroidTwa;
|
|
4244
|
-
const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
|
|
4245
|
-
const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
|
|
4246
|
-
const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
|
|
4247
|
-
return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
|
|
4248
|
-
}
|
|
4249
|
-
async function checkLocalNetworkAccessPermission() {
|
|
4250
|
-
if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
|
|
4251
|
-
try {
|
|
4252
|
-
const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
|
|
4253
|
-
if (lnaPermission.state === "granted") return;
|
|
4254
|
-
else if (lnaPermission.state === "denied") {
|
|
4255
|
-
const modal = new LoopbackPermissionBlockedModal();
|
|
4256
|
-
modal.init();
|
|
4257
|
-
modal.open();
|
|
4258
|
-
throw new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
|
|
4259
|
-
} else if (lnaPermission.state === "prompt") {
|
|
4260
|
-
const modal = new LoopbackPermissionModal();
|
|
4261
|
-
if (await new Promise((resolve, reject) => {
|
|
4262
|
-
modal.addEventListener("close", (event) => {
|
|
4263
|
-
if (event) reject(new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
|
|
4264
|
-
});
|
|
4265
|
-
lnaPermission.onchange = () => {
|
|
4266
|
-
lnaPermission.onchange = null;
|
|
4267
|
-
resolve(lnaPermission.state);
|
|
4268
|
-
};
|
|
4269
|
-
modal.init();
|
|
4270
|
-
modal.open();
|
|
4271
|
-
}) === "granted") {
|
|
4272
|
-
const modal = new LocalConnectionModal();
|
|
4273
|
-
await new Promise((resolve, reject) => {
|
|
4274
|
-
modal.addEventListener("close", (event) => {
|
|
4275
|
-
if (event) reject(new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
|
|
4276
|
-
});
|
|
4277
|
-
modal.initWithCallback(async () => {
|
|
4278
|
-
resolve(true);
|
|
4279
|
-
});
|
|
4280
|
-
modal.open();
|
|
4281
|
-
});
|
|
4282
|
-
return;
|
|
4283
|
-
} else return await checkLocalNetworkAccessPermission();
|
|
4284
|
-
}
|
|
4285
|
-
throw new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
|
|
4286
|
-
} catch (e) {
|
|
4287
|
-
if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
|
|
4288
|
-
if (e instanceof index_browser.SolanaMobileWalletAdapterError) throw e;
|
|
4289
|
-
throw new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
|
|
4290
|
-
}
|
|
4291
|
-
}
|
|
4292
|
-
//#endregion
|
|
4293
|
-
//#region src/icon.ts
|
|
4294
|
-
const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
|
|
4295
|
-
//#endregion
|
|
4296
|
-
//#region src/wallet.ts
|
|
4297
|
-
const SolanaMobileWalletAdapterWalletName = "Mobile Wallet Adapter";
|
|
4298
|
-
const SolanaMobileWalletAdapterRemoteWalletName = "Remote Mobile Wallet Adapter";
|
|
4299
|
-
const SIGNATURE_LENGTH_IN_BYTES = 64;
|
|
4300
|
-
const DEFAULT_FEATURES = [
|
|
4301
|
-
SolanaSignAndSendTransaction,
|
|
4302
|
-
SolanaSignTransaction,
|
|
4303
|
-
SolanaSignMessage,
|
|
4304
|
-
SolanaSignIn
|
|
4305
|
-
];
|
|
4306
|
-
const WALLET_ASSOCIATION_TIMEOUT = 3e4;
|
|
4307
|
-
function getErrorMessage(error) {
|
|
4308
|
-
return error instanceof Error ? error.message : "Unknown error";
|
|
4627
|
+
return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
|
|
4309
4628
|
}
|
|
4310
|
-
|
|
4311
|
-
#listeners = {};
|
|
4312
|
-
#version = "1.0.0";
|
|
4313
|
-
#name = SolanaMobileWalletAdapterWalletName;
|
|
4314
|
-
#url = "https://solanamobile.com/wallets";
|
|
4315
|
-
#icon = icon;
|
|
4316
|
-
#appIdentity;
|
|
4317
|
-
#authorization;
|
|
4318
|
-
#authorizationCache;
|
|
4319
|
-
#connecting = false;
|
|
4320
|
-
/**
|
|
4321
|
-
* Every time the connection is recycled in some way (eg. `disconnect()` is called)
|
|
4322
|
-
* increment this and use it to make sure that `transact` calls from the previous
|
|
4323
|
-
* 'generation' don't continue to do work and throw exceptions.
|
|
4324
|
-
*/
|
|
4325
|
-
#connectionGeneration = 0;
|
|
4326
|
-
#chains = [];
|
|
4327
|
-
#chainSelector;
|
|
4328
|
-
#optionalFeatures;
|
|
4329
|
-
#onWalletNotFound;
|
|
4330
|
-
get version() {
|
|
4331
|
-
return this.#version;
|
|
4332
|
-
}
|
|
4333
|
-
get name() {
|
|
4334
|
-
return this.#name;
|
|
4335
|
-
}
|
|
4336
|
-
get url() {
|
|
4337
|
-
return this.#url;
|
|
4338
|
-
}
|
|
4339
|
-
get icon() {
|
|
4340
|
-
return this.#icon;
|
|
4341
|
-
}
|
|
4342
|
-
get chains() {
|
|
4343
|
-
return this.#chains;
|
|
4344
|
-
}
|
|
4345
|
-
get features() {
|
|
4346
|
-
return {
|
|
4347
|
-
[StandardConnect]: {
|
|
4348
|
-
version: "1.0.0",
|
|
4349
|
-
connect: this.#connect
|
|
4350
|
-
},
|
|
4351
|
-
[StandardDisconnect]: {
|
|
4352
|
-
version: "1.0.0",
|
|
4353
|
-
disconnect: this.#disconnect
|
|
4354
|
-
},
|
|
4355
|
-
[StandardEvents]: {
|
|
4356
|
-
version: "1.0.0",
|
|
4357
|
-
on: this.#on
|
|
4358
|
-
},
|
|
4359
|
-
[SolanaSignMessage]: {
|
|
4360
|
-
version: "1.0.0",
|
|
4361
|
-
signMessage: this.#signMessage
|
|
4362
|
-
},
|
|
4363
|
-
[SolanaSignIn]: {
|
|
4364
|
-
version: "1.0.0",
|
|
4365
|
-
signIn: this.#signIn
|
|
4366
|
-
},
|
|
4367
|
-
...this.#optionalFeatures
|
|
4368
|
-
};
|
|
4369
|
-
}
|
|
4370
|
-
get accounts() {
|
|
4371
|
-
return this.#authorization?.accounts ?? [];
|
|
4372
|
-
}
|
|
4373
|
-
constructor(config) {
|
|
4374
|
-
this.#authorizationCache = config.authorizationCache;
|
|
4375
|
-
this.#appIdentity = config.appIdentity;
|
|
4376
|
-
this.#chains = config.chains;
|
|
4377
|
-
this.#chainSelector = config.chainSelector;
|
|
4378
|
-
this.#onWalletNotFound = config.onWalletNotFound;
|
|
4379
|
-
this.#optionalFeatures = {
|
|
4380
|
-
[SolanaSignAndSendTransaction]: {
|
|
4381
|
-
version: "1.0.0",
|
|
4382
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4383
|
-
signAndSendTransaction: this.#signAndSendTransaction
|
|
4384
|
-
},
|
|
4385
|
-
[SolanaSignTransaction]: {
|
|
4386
|
-
version: "1.0.0",
|
|
4387
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4388
|
-
signTransaction: this.#signTransaction
|
|
4389
|
-
}
|
|
4390
|
-
};
|
|
4391
|
-
}
|
|
4392
|
-
get connected() {
|
|
4393
|
-
return !!this.#authorization;
|
|
4394
|
-
}
|
|
4395
|
-
get isAuthorized() {
|
|
4396
|
-
return !!this.#authorization;
|
|
4397
|
-
}
|
|
4398
|
-
get currentAuthorization() {
|
|
4399
|
-
return this.#authorization;
|
|
4400
|
-
}
|
|
4401
|
-
get cachedAuthorizationResult() {
|
|
4402
|
-
return this.#authorizationCache.get();
|
|
4403
|
-
}
|
|
4404
|
-
#on = (event, listener) => {
|
|
4405
|
-
this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
|
|
4406
|
-
return () => this.#off(event, listener);
|
|
4407
|
-
};
|
|
4408
|
-
#emit(event, ...args) {
|
|
4409
|
-
this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
|
|
4410
|
-
}
|
|
4411
|
-
#off(event, listener) {
|
|
4412
|
-
this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
|
|
4413
|
-
}
|
|
4414
|
-
#connect = async ({ silent } = {}) => {
|
|
4415
|
-
if (this.#connecting || this.connected) return { accounts: this.accounts };
|
|
4416
|
-
this.#connecting = true;
|
|
4417
|
-
try {
|
|
4418
|
-
if (silent) {
|
|
4419
|
-
const cachedAuthorization = await this.#authorizationCache.get();
|
|
4420
|
-
if (cachedAuthorization) {
|
|
4421
|
-
await this.#handleWalletCapabilitiesResult(cachedAuthorization.capabilities);
|
|
4422
|
-
await this.#handleAuthorizationResult(cachedAuthorization);
|
|
4423
|
-
} else return { accounts: this.accounts };
|
|
4424
|
-
} else await this.#performAuthorization();
|
|
4425
|
-
} catch (e) {
|
|
4426
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4427
|
-
} finally {
|
|
4428
|
-
this.#connecting = false;
|
|
4429
|
-
}
|
|
4430
|
-
return { accounts: this.accounts };
|
|
4431
|
-
};
|
|
4432
|
-
#performAuthorization = async (signInPayload) => {
|
|
4433
|
-
try {
|
|
4434
|
-
const cachedAuthorizationResult = await this.#authorizationCache.get();
|
|
4435
|
-
if (cachedAuthorizationResult) {
|
|
4436
|
-
this.#handleAuthorizationResult(cachedAuthorizationResult);
|
|
4437
|
-
return cachedAuthorizationResult;
|
|
4438
|
-
}
|
|
4439
|
-
const selectedChain = await this.#chainSelector.select(this.#chains);
|
|
4440
|
-
return await this.#transact(async (wallet) => {
|
|
4441
|
-
const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
|
|
4442
|
-
chain: selectedChain,
|
|
4443
|
-
identity: this.#appIdentity,
|
|
4444
|
-
sign_in_payload: signInPayload
|
|
4445
|
-
})]);
|
|
4446
|
-
const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
|
|
4447
|
-
const authorization = {
|
|
4448
|
-
...mwaAuthorizationResult,
|
|
4449
|
-
accounts,
|
|
4450
|
-
chain: selectedChain,
|
|
4451
|
-
capabilities
|
|
4452
|
-
};
|
|
4453
|
-
Promise.all([
|
|
4454
|
-
this.#handleWalletCapabilitiesResult(capabilities),
|
|
4455
|
-
this.#authorizationCache.set(authorization),
|
|
4456
|
-
this.#handleAuthorizationResult(authorization)
|
|
4457
|
-
]);
|
|
4458
|
-
return authorization;
|
|
4459
|
-
});
|
|
4460
|
-
} catch (e) {
|
|
4461
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4462
|
-
}
|
|
4463
|
-
};
|
|
4464
|
-
#handleAuthorizationResult = async (authorization) => {
|
|
4465
|
-
const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
|
|
4466
|
-
this.#authorization = authorization;
|
|
4467
|
-
if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
|
|
4468
|
-
};
|
|
4469
|
-
#handleWalletCapabilitiesResult = async (capabilities) => {
|
|
4470
|
-
const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
|
|
4471
|
-
const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions;
|
|
4472
|
-
const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
|
|
4473
|
-
this.#optionalFeatures = {
|
|
4474
|
-
...(supportsSignAndSendTransaction || !supportsSignAndSendTransaction && !supportsSignTransaction) && { [SolanaSignAndSendTransaction]: {
|
|
4475
|
-
version: "1.0.0",
|
|
4476
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4477
|
-
signAndSendTransaction: this.#signAndSendTransaction
|
|
4478
|
-
} },
|
|
4479
|
-
...supportsSignTransaction && { [SolanaSignTransaction]: {
|
|
4480
|
-
version: "1.0.0",
|
|
4481
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4482
|
-
signTransaction: this.#signTransaction
|
|
4483
|
-
} }
|
|
4484
|
-
};
|
|
4485
|
-
if (didCapabilitiesChange) this.#emit("change", { features: this.features });
|
|
4486
|
-
};
|
|
4487
|
-
#performReauthorization = async (wallet, authToken, chain) => {
|
|
4488
|
-
try {
|
|
4489
|
-
const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
|
|
4490
|
-
auth_token: authToken,
|
|
4491
|
-
identity: this.#appIdentity,
|
|
4492
|
-
chain
|
|
4493
|
-
})]);
|
|
4494
|
-
const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
|
|
4495
|
-
const authorization = {
|
|
4496
|
-
...mwaAuthorizationResult,
|
|
4497
|
-
accounts,
|
|
4498
|
-
chain,
|
|
4499
|
-
capabilities
|
|
4500
|
-
};
|
|
4501
|
-
Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
|
|
4502
|
-
} catch (e) {
|
|
4503
|
-
this.#disconnect();
|
|
4504
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4505
|
-
}
|
|
4506
|
-
};
|
|
4507
|
-
#disconnect = async () => {
|
|
4508
|
-
this.#authorizationCache.clear();
|
|
4509
|
-
this.#connecting = false;
|
|
4510
|
-
this.#connectionGeneration++;
|
|
4511
|
-
this.#authorization = void 0;
|
|
4512
|
-
this.#emit("change", { accounts: this.accounts });
|
|
4513
|
-
};
|
|
4514
|
-
#transact = async (callback) => {
|
|
4515
|
-
const walletUriBase = this.#authorization?.wallet_uri_base;
|
|
4516
|
-
const config = walletUriBase ? { baseUri: walletUriBase } : void 0;
|
|
4517
|
-
const currentConnectionGeneration = this.#connectionGeneration;
|
|
4518
|
-
const loadingSpinner = new EmbeddedLoadingSpinner();
|
|
4519
|
-
try {
|
|
4520
|
-
let associating = true;
|
|
4521
|
-
let timeout = void 0;
|
|
4522
|
-
const result = await Promise.race([checkLocalNetworkAccessPermission().then(async () => {
|
|
4523
|
-
loadingSpinner.init();
|
|
4524
|
-
const { wallet, close } = await index_browser.startScenario(config);
|
|
4525
|
-
associating = false;
|
|
4526
|
-
loadingSpinner.addEventListener("close", (event) => {
|
|
4527
|
-
if (event) close();
|
|
4528
|
-
});
|
|
4529
|
-
loadingSpinner.open();
|
|
4530
|
-
const result = await callback(await wallet);
|
|
4531
|
-
loadingSpinner.close();
|
|
4532
|
-
close();
|
|
4533
|
-
return result;
|
|
4534
|
-
}), new Promise((_, reject) => {
|
|
4535
|
-
timeout = setTimeout(() => {
|
|
4536
|
-
if (associating) reject(new index_browser.SolanaMobileWalletAdapterError(index_browser.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection timed out", { event: void 0 }));
|
|
4537
|
-
}, WALLET_ASSOCIATION_TIMEOUT);
|
|
4538
|
-
})]);
|
|
4539
|
-
clearTimeout(timeout);
|
|
4540
|
-
return result;
|
|
4541
|
-
} catch (e) {
|
|
4542
|
-
loadingSpinner.close();
|
|
4543
|
-
if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
|
|
4544
|
-
if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
|
|
4545
|
-
throw e;
|
|
4546
|
-
}
|
|
4547
|
-
};
|
|
4548
|
-
#assertIsAuthorized = () => {
|
|
4549
|
-
if (!this.#authorization) throw new Error("Wallet not connected");
|
|
4550
|
-
return {
|
|
4551
|
-
authToken: this.#authorization.auth_token,
|
|
4552
|
-
chain: this.#authorization.chain
|
|
4553
|
-
};
|
|
4554
|
-
};
|
|
4555
|
-
#accountsToWalletStandardAccounts = (accounts) => {
|
|
4556
|
-
return accounts.map((account) => {
|
|
4557
|
-
const publicKey = toUint8Array(account.address);
|
|
4558
|
-
return {
|
|
4559
|
-
address: base58.encode(publicKey),
|
|
4560
|
-
publicKey,
|
|
4561
|
-
label: account.label,
|
|
4562
|
-
icon: account.icon,
|
|
4563
|
-
chains: account.chains ?? this.#chains,
|
|
4564
|
-
features: account.features ?? DEFAULT_FEATURES
|
|
4565
|
-
};
|
|
4566
|
-
});
|
|
4567
|
-
};
|
|
4568
|
-
#performSignTransactions = async (transactions) => {
|
|
4569
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4570
|
-
try {
|
|
4571
|
-
const base64Transactions = transactions.map((tx) => {
|
|
4572
|
-
return fromUint8Array(tx);
|
|
4573
|
-
});
|
|
4574
|
-
return await this.#transact(async (wallet) => {
|
|
4575
|
-
await this.#performReauthorization(wallet, authToken, chain);
|
|
4576
|
-
return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(toUint8Array);
|
|
4577
|
-
});
|
|
4578
|
-
} catch (e) {
|
|
4579
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4580
|
-
}
|
|
4581
|
-
};
|
|
4582
|
-
#performSignAndSendTransaction = async (transaction, options) => {
|
|
4583
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4584
|
-
try {
|
|
4585
|
-
return await this.#transact(async (wallet) => {
|
|
4586
|
-
const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
|
|
4587
|
-
if (capabilities.supports_sign_and_send_transactions) {
|
|
4588
|
-
const base64Transaction = fromUint8Array(transaction);
|
|
4589
|
-
return (await wallet.signAndSendTransactions({
|
|
4590
|
-
...options,
|
|
4591
|
-
payloads: [base64Transaction]
|
|
4592
|
-
})).signatures.map(toUint8Array)[0];
|
|
4593
|
-
} else throw new Error("connected wallet does not support signAndSendTransaction");
|
|
4594
|
-
});
|
|
4595
|
-
} catch (e) {
|
|
4596
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4597
|
-
}
|
|
4598
|
-
};
|
|
4599
|
-
#signAndSendTransaction = async (...inputs) => {
|
|
4600
|
-
const outputs = [];
|
|
4601
|
-
for (const input of inputs) {
|
|
4602
|
-
const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
|
|
4603
|
-
outputs.push({ signature });
|
|
4604
|
-
}
|
|
4605
|
-
return outputs;
|
|
4606
|
-
};
|
|
4607
|
-
#signTransaction = async (...inputs) => {
|
|
4608
|
-
return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
|
|
4609
|
-
return { signedTransaction };
|
|
4610
|
-
});
|
|
4611
|
-
};
|
|
4612
|
-
#signMessage = async (...inputs) => {
|
|
4613
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4614
|
-
const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
|
|
4615
|
-
const messages = inputs.map(({ message }) => fromUint8Array(message));
|
|
4616
|
-
try {
|
|
4617
|
-
return await this.#transact(async (wallet) => {
|
|
4618
|
-
await this.#performReauthorization(wallet, authToken, chain);
|
|
4619
|
-
return (await wallet.signMessages({
|
|
4620
|
-
addresses,
|
|
4621
|
-
payloads: messages
|
|
4622
|
-
})).signed_payloads.map(toUint8Array).map((signedMessage) => {
|
|
4623
|
-
return {
|
|
4624
|
-
signedMessage,
|
|
4625
|
-
signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
|
|
4626
|
-
};
|
|
4627
|
-
});
|
|
4628
|
-
});
|
|
4629
|
-
} catch (e) {
|
|
4630
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4631
|
-
}
|
|
4632
|
-
};
|
|
4633
|
-
#signIn = async (...inputs) => {
|
|
4634
|
-
const outputs = [];
|
|
4635
|
-
if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
|
|
4636
|
-
else return [await this.#performSignIn(inputs[0])];
|
|
4637
|
-
return outputs;
|
|
4638
|
-
};
|
|
4639
|
-
#performSignIn = async (input) => {
|
|
4640
|
-
this.#connecting = true;
|
|
4641
|
-
try {
|
|
4642
|
-
const authorizationResult = await this.#performAuthorization({
|
|
4643
|
-
...input,
|
|
4644
|
-
domain: input?.domain ?? window.location.host
|
|
4645
|
-
});
|
|
4646
|
-
if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
4647
|
-
const signedInAddress = authorizationResult.sign_in_result.address;
|
|
4648
|
-
const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
|
|
4649
|
-
return {
|
|
4650
|
-
account: {
|
|
4651
|
-
...signedInAccount ?? { address: base58.encode(toUint8Array(signedInAddress)) },
|
|
4652
|
-
publicKey: toUint8Array(signedInAddress),
|
|
4653
|
-
chains: signedInAccount?.chains ?? this.#chains,
|
|
4654
|
-
features: signedInAccount?.features ?? authorizationResult.capabilities.features
|
|
4655
|
-
},
|
|
4656
|
-
signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
4657
|
-
signature: toUint8Array(authorizationResult.sign_in_result.signature)
|
|
4658
|
-
};
|
|
4659
|
-
} catch (e) {
|
|
4660
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4661
|
-
} finally {
|
|
4662
|
-
this.#connecting = false;
|
|
4663
|
-
}
|
|
4664
|
-
};
|
|
4665
|
-
};
|
|
4666
|
-
var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
4667
|
-
#listeners = {};
|
|
4668
|
-
#version = "1.0.0";
|
|
4669
|
-
#name = SolanaMobileWalletAdapterRemoteWalletName;
|
|
4670
|
-
#url = "https://solanamobile.com/wallets";
|
|
4671
|
-
#icon = icon;
|
|
4672
|
-
#appIdentity;
|
|
4673
|
-
#authorization;
|
|
4674
|
-
#authorizationCache;
|
|
4675
|
-
#connecting = false;
|
|
4676
|
-
/**
|
|
4677
|
-
* Every time the connection is recycled in some way (eg. `disconnect()` is called)
|
|
4678
|
-
* increment this and use it to make sure that `transact` calls from the previous
|
|
4679
|
-
* 'generation' don't continue to do work and throw exceptions.
|
|
4680
|
-
*/
|
|
4681
|
-
#connectionGeneration = 0;
|
|
4682
|
-
#chains = [];
|
|
4683
|
-
#chainSelector;
|
|
4684
|
-
#optionalFeatures;
|
|
4685
|
-
#onWalletNotFound;
|
|
4686
|
-
#hostAuthority;
|
|
4687
|
-
#session;
|
|
4688
|
-
get version() {
|
|
4689
|
-
return this.#version;
|
|
4690
|
-
}
|
|
4691
|
-
get name() {
|
|
4692
|
-
return this.#name;
|
|
4693
|
-
}
|
|
4694
|
-
get url() {
|
|
4695
|
-
return this.#url;
|
|
4696
|
-
}
|
|
4697
|
-
get icon() {
|
|
4698
|
-
return this.#icon;
|
|
4699
|
-
}
|
|
4700
|
-
get chains() {
|
|
4701
|
-
return this.#chains;
|
|
4702
|
-
}
|
|
4703
|
-
get features() {
|
|
4704
|
-
return {
|
|
4705
|
-
[StandardConnect]: {
|
|
4706
|
-
version: "1.0.0",
|
|
4707
|
-
connect: this.#connect
|
|
4708
|
-
},
|
|
4709
|
-
[StandardDisconnect]: {
|
|
4710
|
-
version: "1.0.0",
|
|
4711
|
-
disconnect: this.#disconnect
|
|
4712
|
-
},
|
|
4713
|
-
[StandardEvents]: {
|
|
4714
|
-
version: "1.0.0",
|
|
4715
|
-
on: this.#on
|
|
4716
|
-
},
|
|
4717
|
-
[SolanaSignMessage]: {
|
|
4718
|
-
version: "1.0.0",
|
|
4719
|
-
signMessage: this.#signMessage
|
|
4720
|
-
},
|
|
4721
|
-
[SolanaSignIn]: {
|
|
4722
|
-
version: "1.0.0",
|
|
4723
|
-
signIn: this.#signIn
|
|
4724
|
-
},
|
|
4725
|
-
...this.#optionalFeatures
|
|
4726
|
-
};
|
|
4727
|
-
}
|
|
4728
|
-
get accounts() {
|
|
4729
|
-
return this.#authorization?.accounts ?? [];
|
|
4730
|
-
}
|
|
4731
|
-
constructor(config) {
|
|
4732
|
-
this.#authorizationCache = config.authorizationCache;
|
|
4733
|
-
this.#appIdentity = config.appIdentity;
|
|
4734
|
-
this.#chains = config.chains;
|
|
4735
|
-
this.#chainSelector = config.chainSelector;
|
|
4736
|
-
this.#hostAuthority = config.remoteHostAuthority;
|
|
4737
|
-
this.#onWalletNotFound = config.onWalletNotFound;
|
|
4738
|
-
this.#optionalFeatures = {
|
|
4739
|
-
[SolanaSignAndSendTransaction]: {
|
|
4740
|
-
version: "1.0.0",
|
|
4741
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4742
|
-
signAndSendTransaction: this.#signAndSendTransaction
|
|
4743
|
-
},
|
|
4744
|
-
[SolanaSignTransaction]: {
|
|
4745
|
-
version: "1.0.0",
|
|
4746
|
-
supportedTransactionVersions: ["legacy", 0],
|
|
4747
|
-
signTransaction: this.#signTransaction
|
|
4748
|
-
}
|
|
4749
|
-
};
|
|
4750
|
-
}
|
|
4751
|
-
get connected() {
|
|
4752
|
-
return !!this.#session && !!this.#authorization;
|
|
4753
|
-
}
|
|
4754
|
-
get isAuthorized() {
|
|
4755
|
-
return !!this.#authorization;
|
|
4756
|
-
}
|
|
4757
|
-
get currentAuthorization() {
|
|
4758
|
-
return this.#authorization;
|
|
4759
|
-
}
|
|
4760
|
-
get cachedAuthorizationResult() {
|
|
4761
|
-
return this.#authorizationCache.get();
|
|
4762
|
-
}
|
|
4763
|
-
#on = (event, listener) => {
|
|
4764
|
-
this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);
|
|
4765
|
-
return () => this.#off(event, listener);
|
|
4766
|
-
};
|
|
4767
|
-
#emit(event, ...args) {
|
|
4768
|
-
this.#listeners[event]?.forEach((listener) => listener.apply(null, args));
|
|
4769
|
-
}
|
|
4770
|
-
#off(event, listener) {
|
|
4771
|
-
this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);
|
|
4772
|
-
}
|
|
4773
|
-
#connect = async (_input = {}) => {
|
|
4774
|
-
if (this.#connecting || this.connected) return { accounts: this.accounts };
|
|
4775
|
-
this.#connecting = true;
|
|
4776
|
-
try {
|
|
4777
|
-
await this.#performAuthorization();
|
|
4778
|
-
} catch (e) {
|
|
4779
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4780
|
-
} finally {
|
|
4781
|
-
this.#connecting = false;
|
|
4782
|
-
}
|
|
4783
|
-
return { accounts: this.accounts };
|
|
4784
|
-
};
|
|
4785
|
-
#performAuthorization = async (signInPayload) => {
|
|
4786
|
-
try {
|
|
4787
|
-
const cachedAuthorizationResult = await this.#authorizationCache.get();
|
|
4788
|
-
if (cachedAuthorizationResult) {
|
|
4789
|
-
this.#handleAuthorizationResult(cachedAuthorizationResult);
|
|
4790
|
-
return cachedAuthorizationResult;
|
|
4791
|
-
}
|
|
4792
|
-
if (this.#session) this.#session = void 0;
|
|
4793
|
-
const selectedChain = await this.#chainSelector.select(this.#chains);
|
|
4794
|
-
return await this.#transact(async (wallet) => {
|
|
4795
|
-
const [capabilities, mwaAuthorizationResult] = await Promise.all([wallet.getCapabilities(), wallet.authorize({
|
|
4796
|
-
chain: selectedChain,
|
|
4797
|
-
identity: this.#appIdentity,
|
|
4798
|
-
sign_in_payload: signInPayload
|
|
4799
|
-
})]);
|
|
4800
|
-
const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
|
|
4801
|
-
const authorizationResult = {
|
|
4802
|
-
...mwaAuthorizationResult,
|
|
4803
|
-
accounts,
|
|
4804
|
-
chain: selectedChain,
|
|
4805
|
-
capabilities
|
|
4806
|
-
};
|
|
4807
|
-
Promise.all([
|
|
4808
|
-
this.#handleWalletCapabilitiesResult(capabilities),
|
|
4809
|
-
this.#authorizationCache.set(authorizationResult),
|
|
4810
|
-
this.#handleAuthorizationResult(authorizationResult)
|
|
4811
|
-
]);
|
|
4812
|
-
return authorizationResult;
|
|
4813
|
-
});
|
|
4814
|
-
} catch (e) {
|
|
4815
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4816
|
-
}
|
|
4817
|
-
};
|
|
4818
|
-
#handleAuthorizationResult = async (authorization) => {
|
|
4819
|
-
const didPublicKeysChange = this.#authorization == null || this.#authorization?.accounts.length !== authorization.accounts.length || this.#authorization.accounts.some((account, ii) => account.address !== authorization.accounts[ii].address);
|
|
4820
|
-
this.#authorization = authorization;
|
|
4821
|
-
if (didPublicKeysChange) this.#emit("change", { accounts: this.accounts });
|
|
4822
|
-
};
|
|
4823
|
-
#handleWalletCapabilitiesResult = async (capabilities) => {
|
|
4824
|
-
const supportsSignTransaction = capabilities.features.includes("solana:signTransactions");
|
|
4825
|
-
const supportsSignAndSendTransaction = capabilities.supports_sign_and_send_transactions || capabilities.features.includes("solana:signAndSendTransaction");
|
|
4826
|
-
const didCapabilitiesChange = SolanaSignAndSendTransaction in this.features !== supportsSignAndSendTransaction || SolanaSignTransaction in this.features !== supportsSignTransaction;
|
|
4827
|
-
this.#optionalFeatures = {
|
|
4828
|
-
...supportsSignAndSendTransaction && { [SolanaSignAndSendTransaction]: {
|
|
4829
|
-
version: "1.0.0",
|
|
4830
|
-
supportedTransactionVersions: capabilities.supported_transaction_versions,
|
|
4831
|
-
signAndSendTransaction: this.#signAndSendTransaction
|
|
4832
|
-
} },
|
|
4833
|
-
...supportsSignTransaction && { [SolanaSignTransaction]: {
|
|
4834
|
-
version: "1.0.0",
|
|
4835
|
-
supportedTransactionVersions: capabilities.supported_transaction_versions,
|
|
4836
|
-
signTransaction: this.#signTransaction
|
|
4837
|
-
} }
|
|
4838
|
-
};
|
|
4839
|
-
if (didCapabilitiesChange) this.#emit("change", { features: this.features });
|
|
4840
|
-
};
|
|
4841
|
-
#performReauthorization = async (wallet, authToken, chain) => {
|
|
4842
|
-
try {
|
|
4843
|
-
const [capabilities, mwaAuthorizationResult] = await Promise.all([this.#authorization?.capabilities ?? await wallet.getCapabilities(), wallet.authorize({
|
|
4844
|
-
auth_token: authToken,
|
|
4845
|
-
identity: this.#appIdentity,
|
|
4846
|
-
chain
|
|
4847
|
-
})]);
|
|
4848
|
-
const accounts = this.#accountsToWalletStandardAccounts(mwaAuthorizationResult.accounts);
|
|
4849
|
-
const authorization = {
|
|
4850
|
-
...mwaAuthorizationResult,
|
|
4851
|
-
accounts,
|
|
4852
|
-
chain,
|
|
4853
|
-
capabilities
|
|
4854
|
-
};
|
|
4855
|
-
Promise.all([this.#authorizationCache.set(authorization), this.#handleAuthorizationResult(authorization)]);
|
|
4856
|
-
} catch (e) {
|
|
4857
|
-
this.#disconnect();
|
|
4858
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4859
|
-
}
|
|
4860
|
-
};
|
|
4861
|
-
#disconnect = async () => {
|
|
4862
|
-
this.#session?.close();
|
|
4863
|
-
this.#authorizationCache.clear();
|
|
4864
|
-
this.#connecting = false;
|
|
4865
|
-
this.#connectionGeneration++;
|
|
4866
|
-
this.#authorization = void 0;
|
|
4867
|
-
this.#session = void 0;
|
|
4868
|
-
this.#emit("change", { accounts: this.accounts });
|
|
4869
|
-
};
|
|
4870
|
-
#transact = async (callback) => {
|
|
4871
|
-
const walletUriBase = this.#authorization?.wallet_uri_base;
|
|
4872
|
-
const remoteConfig = {
|
|
4873
|
-
...walletUriBase ? { baseUri: walletUriBase } : void 0,
|
|
4874
|
-
remoteHostAuthority: this.#hostAuthority
|
|
4875
|
-
};
|
|
4876
|
-
const currentConnectionGeneration = this.#connectionGeneration;
|
|
4877
|
-
const modal = new RemoteConnectionModal();
|
|
4878
|
-
if (this.#session) return callback(this.#session.wallet);
|
|
4879
|
-
try {
|
|
4880
|
-
modal.init();
|
|
4881
|
-
modal.open();
|
|
4882
|
-
const { associationUrl, close, wallet } = await index_browser.startRemoteScenario(remoteConfig);
|
|
4883
|
-
const removeCloseListener = modal.addEventListener("close", (event) => {
|
|
4884
|
-
if (event) close();
|
|
4885
|
-
});
|
|
4886
|
-
modal.populateQRCode(associationUrl.toString());
|
|
4887
|
-
this.#session = {
|
|
4888
|
-
close,
|
|
4889
|
-
wallet: await wallet
|
|
4890
|
-
};
|
|
4891
|
-
removeCloseListener();
|
|
4892
|
-
modal.close();
|
|
4893
|
-
return await callback(this.#session.wallet);
|
|
4894
|
-
} catch (e) {
|
|
4895
|
-
modal.close();
|
|
4896
|
-
if (this.#connectionGeneration !== currentConnectionGeneration) await new Promise(() => {});
|
|
4897
|
-
if (e instanceof Error && e.name === "SolanaMobileWalletAdapterError" && e.code === "ERROR_WALLET_NOT_FOUND") await this.#onWalletNotFound(this);
|
|
4898
|
-
throw e;
|
|
4899
|
-
}
|
|
4900
|
-
};
|
|
4901
|
-
#assertIsAuthorized = () => {
|
|
4902
|
-
if (!this.#authorization) throw new Error("Wallet not connected");
|
|
4903
|
-
return {
|
|
4904
|
-
authToken: this.#authorization.auth_token,
|
|
4905
|
-
chain: this.#authorization.chain
|
|
4906
|
-
};
|
|
4907
|
-
};
|
|
4908
|
-
#accountsToWalletStandardAccounts = (accounts) => {
|
|
4909
|
-
return accounts.map((account) => {
|
|
4910
|
-
const publicKey = toUint8Array(account.address);
|
|
4911
|
-
return {
|
|
4912
|
-
address: base58.encode(publicKey),
|
|
4913
|
-
publicKey,
|
|
4914
|
-
label: account.label,
|
|
4915
|
-
icon: account.icon,
|
|
4916
|
-
chains: account.chains ?? this.#chains,
|
|
4917
|
-
features: account.features ?? DEFAULT_FEATURES
|
|
4918
|
-
};
|
|
4919
|
-
});
|
|
4920
|
-
};
|
|
4921
|
-
#performSignTransactions = async (transactions) => {
|
|
4922
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4923
|
-
try {
|
|
4924
|
-
return await this.#transact(async (wallet) => {
|
|
4925
|
-
await this.#performReauthorization(wallet, authToken, chain);
|
|
4926
|
-
return (await wallet.signTransactions({ payloads: transactions.map(fromUint8Array) })).signed_payloads.map(toUint8Array);
|
|
4927
|
-
});
|
|
4928
|
-
} catch (e) {
|
|
4929
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4930
|
-
}
|
|
4931
|
-
};
|
|
4932
|
-
#performSignAndSendTransaction = async (transaction, options) => {
|
|
4933
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4934
|
-
try {
|
|
4935
|
-
return await this.#transact(async (wallet) => {
|
|
4936
|
-
const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
|
|
4937
|
-
if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
|
|
4938
|
-
...options,
|
|
4939
|
-
payloads: [fromUint8Array(transaction)]
|
|
4940
|
-
})).signatures.map(toUint8Array)[0];
|
|
4941
|
-
else throw new Error("connected wallet does not support signAndSendTransaction");
|
|
4942
|
-
});
|
|
4943
|
-
} catch (e) {
|
|
4944
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4945
|
-
}
|
|
4946
|
-
};
|
|
4947
|
-
#signAndSendTransaction = async (...inputs) => {
|
|
4948
|
-
const outputs = [];
|
|
4949
|
-
for (const input of inputs) {
|
|
4950
|
-
const signature = await this.#performSignAndSendTransaction(input.transaction, input.options);
|
|
4951
|
-
outputs.push({ signature });
|
|
4952
|
-
}
|
|
4953
|
-
return outputs;
|
|
4954
|
-
};
|
|
4955
|
-
#signTransaction = async (...inputs) => {
|
|
4956
|
-
return (await this.#performSignTransactions(inputs.map(({ transaction }) => transaction))).map((signedTransaction) => {
|
|
4957
|
-
return { signedTransaction };
|
|
4958
|
-
});
|
|
4959
|
-
};
|
|
4960
|
-
#signMessage = async (...inputs) => {
|
|
4961
|
-
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4962
|
-
const addresses = inputs.map(({ account }) => fromUint8Array(new Uint8Array(account.publicKey)));
|
|
4963
|
-
const messages = inputs.map(({ message }) => fromUint8Array(message));
|
|
4964
|
-
try {
|
|
4965
|
-
return await this.#transact(async (wallet) => {
|
|
4966
|
-
await this.#performReauthorization(wallet, authToken, chain);
|
|
4967
|
-
return (await wallet.signMessages({
|
|
4968
|
-
addresses,
|
|
4969
|
-
payloads: messages
|
|
4970
|
-
})).signed_payloads.map(toUint8Array).map((signedMessage) => {
|
|
4971
|
-
return {
|
|
4972
|
-
signedMessage,
|
|
4973
|
-
signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
|
|
4974
|
-
};
|
|
4975
|
-
});
|
|
4976
|
-
});
|
|
4977
|
-
} catch (e) {
|
|
4978
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
4979
|
-
}
|
|
4980
|
-
};
|
|
4981
|
-
#signIn = async (...inputs) => {
|
|
4982
|
-
const outputs = [];
|
|
4983
|
-
if (inputs.length > 1) for (const input of inputs) outputs.push(await this.#performSignIn(input));
|
|
4984
|
-
else return [await this.#performSignIn(inputs[0])];
|
|
4985
|
-
return outputs;
|
|
4986
|
-
};
|
|
4987
|
-
#performSignIn = async (input) => {
|
|
4988
|
-
this.#connecting = true;
|
|
4989
|
-
try {
|
|
4990
|
-
const authorizationResult = await this.#performAuthorization({
|
|
4991
|
-
...input,
|
|
4992
|
-
domain: input?.domain ?? window.location.host
|
|
4993
|
-
});
|
|
4994
|
-
if (!authorizationResult.sign_in_result) throw new Error("Sign in failed, no sign in result returned by wallet");
|
|
4995
|
-
const signedInAddress = authorizationResult.sign_in_result.address;
|
|
4996
|
-
const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
|
|
4997
|
-
return {
|
|
4998
|
-
account: {
|
|
4999
|
-
...signedInAccount ?? { address: base58.encode(toUint8Array(signedInAddress)) },
|
|
5000
|
-
publicKey: toUint8Array(signedInAddress),
|
|
5001
|
-
chains: signedInAccount?.chains ?? this.#chains,
|
|
5002
|
-
features: signedInAccount?.features ?? authorizationResult.capabilities.features
|
|
5003
|
-
},
|
|
5004
|
-
signedMessage: toUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
5005
|
-
signature: toUint8Array(authorizationResult.sign_in_result.signature)
|
|
5006
|
-
};
|
|
5007
|
-
} catch (e) {
|
|
5008
|
-
throw new Error(getErrorMessage(e), { cause: e });
|
|
5009
|
-
} finally {
|
|
5010
|
-
this.#connecting = false;
|
|
5011
|
-
}
|
|
5012
|
-
};
|
|
5013
|
-
};
|
|
5014
|
-
//#endregion
|
|
5015
|
-
//#region src/initialize.ts
|
|
4629
|
+
|
|
5016
4630
|
function registerMwa(config) {
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
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
|
+
}
|
|
5031
4689
|
}
|
|
5032
|
-
//#endregion
|
|
5033
|
-
//#region src/embedded-modal/errorModal.ts
|
|
5034
|
-
const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
|
|
5035
|
-
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.";
|
|
5036
|
-
var ErrorModal = class extends EmbeddedModal {
|
|
5037
|
-
contentStyles = css;
|
|
5038
|
-
contentHtml = ErrorDialogHtml;
|
|
5039
|
-
initWithError(error) {
|
|
5040
|
-
super.init();
|
|
5041
|
-
this.populateError(error);
|
|
5042
|
-
}
|
|
5043
|
-
populateError(error) {
|
|
5044
|
-
const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
|
|
5045
|
-
const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
|
|
5046
|
-
if (errorMessageElement) {
|
|
5047
|
-
if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
|
|
5048
|
-
case "ERROR_WALLET_NOT_FOUND":
|
|
5049
|
-
errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
|
|
5050
|
-
if (actionBtn) actionBtn.addEventListener("click", () => {
|
|
5051
|
-
window.location.href = "https://solanamobile.com/wallets";
|
|
5052
|
-
});
|
|
5053
|
-
return;
|
|
5054
|
-
case "ERROR_BROWSER_NOT_SUPPORTED":
|
|
5055
|
-
errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
|
|
5056
|
-
if (actionBtn) actionBtn.style.display = "none";
|
|
5057
|
-
return;
|
|
5058
|
-
}
|
|
5059
|
-
errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
|
|
5060
|
-
} else console.log("Failed to locate error dialog element");
|
|
5061
|
-
}
|
|
5062
|
-
};
|
|
5063
4690
|
const ErrorDialogHtml = `
|
|
5064
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>
|
|
5065
4692
|
<div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
|
|
@@ -5119,79 +4746,122 @@ const css = `
|
|
|
5119
4746
|
}
|
|
5120
4747
|
}
|
|
5121
4748
|
`;
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
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
|
+
});
|
|
5140
4787
|
}
|
|
5141
4788
|
function createDefaultWalletNotFoundHandler() {
|
|
5142
|
-
|
|
5143
|
-
defaultErrorModalWalletNotFoundHandler();
|
|
5144
|
-
};
|
|
4789
|
+
return () => __awaiter(this, void 0, void 0, function* () { defaultErrorModalWalletNotFoundHandler(); });
|
|
5145
4790
|
}
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
|
|
4791
|
+
|
|
4792
|
+
const CACHE_KEY = 'SolanaMobileWalletAdapterDefaultAuthorizationCache';
|
|
5149
4793
|
function createDefaultAuthorizationCache() {
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
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
|
+
};
|
|
5186
4848
|
}
|
|
5187
|
-
|
|
5188
|
-
//#region src/createDefaultChainSelector.ts
|
|
4849
|
+
|
|
5189
4850
|
function createDefaultChainSelector() {
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
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
|
+
};
|
|
5195
4865
|
}
|
|
5196
4866
|
|
|
5197
4867
|
exports.LocalSolanaMobileWalletAdapterWallet = LocalSolanaMobileWalletAdapterWallet;
|
|
@@ -5203,4 +4873,4 @@ exports.createDefaultChainSelector = createDefaultChainSelector;
|
|
|
5203
4873
|
exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
|
|
5204
4874
|
exports.defaultErrorModalWalletNotFoundHandler = defaultErrorModalWalletNotFoundHandler;
|
|
5205
4875
|
exports.registerMwa = registerMwa;
|
|
5206
|
-
//# sourceMappingURL=index.browser-
|
|
4876
|
+
//# sourceMappingURL=index.browser-CGfTdDXe.js.map
|