@bounded-sh/client 0.0.1 → 0.0.3
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 +1 -1
- package/dist/auth/providers/privy-expo-provider.d.ts +1 -1
- package/dist/auth/providers/solana-mobile-wallet-provider.d.ts +3 -3
- package/dist/{index-VGx-869x.js → index-2UpSvA7V.js} +2586 -124
- package/dist/index-2UpSvA7V.js.map +1 -0
- package/dist/{index-C1VOdmRN.js → index-C2JpxGAC.js} +1202 -450
- package/dist/index-C2JpxGAC.js.map +1 -0
- package/dist/{index-CT2j1oic.esm.js → index-C2yvle9S.esm.js} +1202 -450
- package/dist/index-C2yvle9S.esm.js.map +1 -0
- package/dist/{index-sKqrgk0t.js → index-CYVVTWs4.js} +1202 -450
- package/dist/index-CYVVTWs4.js.map +1 -0
- package/dist/{index-BHTfW8CV.esm.js → index-DJg-Dduo.esm.js} +1202 -450
- package/dist/index-DJg-Dduo.esm.js.map +1 -0
- package/dist/{index-o5Hv9pfS.esm.js → index-DyfiK3_X.esm.js} +2585 -124
- package/dist/index-DyfiK3_X.esm.js.map +1 -0
- package/dist/{index.browser-BJZ7fYwv.js → index.browser-BTJZmhY1.js} +766 -773
- package/dist/index.browser-BTJZmhY1.js.map +1 -0
- package/dist/{index.browser-DaNhOhkQ.esm.js → index.browser-C_TToxuO.esm.js} +230 -242
- package/dist/index.browser-C_TToxuO.esm.js.map +1 -0
- package/dist/{index.browser-utVKQsEC.js → index.browser-DcHalmEf.js} +230 -242
- package/dist/index.browser-DcHalmEf.js.map +1 -0
- package/dist/{index.browser-DhAcjdpV.esm.js → index.browser-pymH6o1X.esm.js} +766 -773
- package/dist/index.browser-pymH6o1X.esm.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{index.native-JPUkdHJj.esm.js → index.native-BTjBgNiE.esm.js} +2556 -95
- package/dist/index.native-BTjBgNiE.esm.js.map +1 -0
- package/dist/{index.native-B5IBOdv_.js → index.native-BvsmNFXn.js} +2557 -95
- package/dist/index.native-BvsmNFXn.js.map +1 -0
- package/dist/index.native.d.ts +1 -1
- package/dist/index.native.esm.js +1 -1
- package/dist/index.native.js +2 -1
- package/dist/index.native.js.map +1 -1
- package/dist/{phantom-wallet-provider-CDLyxrih.js → phantom-wallet-provider-BXMvoOrI.js} +10 -10
- package/dist/phantom-wallet-provider-BXMvoOrI.js.map +1 -0
- package/dist/{phantom-wallet-provider-DMlaSrAl.esm.js → phantom-wallet-provider-CTossIFB.esm.js} +10 -10
- package/dist/phantom-wallet-provider-CTossIFB.esm.js.map +1 -0
- package/dist/{privy-wallet-provider-nR52lXzI.esm.js → privy-wallet-provider-1qE_f-DF.esm.js} +6 -6
- package/dist/privy-wallet-provider-1qE_f-DF.esm.js.map +1 -0
- package/dist/{privy-wallet-provider-DiHHTDbZ.js → privy-wallet-provider-D64DJ3u4.js} +6 -6
- package/dist/privy-wallet-provider-D64DJ3u4.js.map +1 -0
- package/dist/{solana-mobile-wallet-provider-B4CeMMQd.esm.js → solana-mobile-wallet-provider-9M8U6AA7.esm.js} +22 -22
- package/dist/solana-mobile-wallet-provider-9M8U6AA7.esm.js.map +1 -0
- package/dist/{solana-mobile-wallet-provider-BYMfFjZb.js → solana-mobile-wallet-provider-C1wQ1DRK.js} +22 -22
- package/dist/solana-mobile-wallet-provider-C1wQ1DRK.js.map +1 -0
- package/package.json +2 -2
- package/dist/index-BHTfW8CV.esm.js.map +0 -1
- package/dist/index-C1VOdmRN.js.map +0 -1
- package/dist/index-CT2j1oic.esm.js.map +0 -1
- package/dist/index-VGx-869x.js.map +0 -1
- package/dist/index-o5Hv9pfS.esm.js.map +0 -1
- package/dist/index-sKqrgk0t.js.map +0 -1
- package/dist/index.browser-BJZ7fYwv.js.map +0 -1
- package/dist/index.browser-DaNhOhkQ.esm.js.map +0 -1
- package/dist/index.browser-DhAcjdpV.esm.js.map +0 -1
- package/dist/index.browser-utVKQsEC.js.map +0 -1
- package/dist/index.native-B5IBOdv_.js.map +0 -1
- package/dist/index.native-JPUkdHJj.esm.js.map +0 -1
- package/dist/phantom-wallet-provider-CDLyxrih.js.map +0 -1
- package/dist/phantom-wallet-provider-DMlaSrAl.esm.js.map +0 -1
- package/dist/privy-wallet-provider-DiHHTDbZ.js.map +0 -1
- package/dist/privy-wallet-provider-nR52lXzI.esm.js.map +0 -1
- package/dist/solana-mobile-wallet-provider-B4CeMMQd.esm.js.map +0 -1
- package/dist/solana-mobile-wallet-provider-BYMfFjZb.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var encoding = require('@solana-mobile/mobile-wallet-adapter-protocol/encoding');
|
|
3
4
|
var mobileWalletAdapterProtocol = require('@solana-mobile/mobile-wallet-adapter-protocol');
|
|
4
|
-
var index = require('./index-
|
|
5
|
+
var index = require('./index-2UpSvA7V.js');
|
|
5
6
|
require('axios');
|
|
6
7
|
require('@solana/web3.js');
|
|
7
8
|
require('@coral-xyz/anchor');
|
|
@@ -9,6 +10,83 @@ require('react');
|
|
|
9
10
|
require('@solana/kit');
|
|
10
11
|
require('react-dom/client');
|
|
11
12
|
|
|
13
|
+
/** Solana Mainnet (beta) cluster, e.g. https://api.mainnet-beta.solana.com */
|
|
14
|
+
const SOLANA_MAINNET_CHAIN = 'solana:mainnet';
|
|
15
|
+
|
|
16
|
+
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
17
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
18
|
+
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");
|
|
19
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
20
|
+
};
|
|
21
|
+
var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
22
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
23
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
24
|
+
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");
|
|
25
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
26
|
+
};
|
|
27
|
+
var _RegisterWalletEvent_detail;
|
|
28
|
+
/**
|
|
29
|
+
* Register a {@link "@wallet-standard/base".Wallet} as a Standard Wallet with the app.
|
|
30
|
+
*
|
|
31
|
+
* This dispatches a {@link "@wallet-standard/base".WindowRegisterWalletEvent} to notify the app that the Wallet is
|
|
32
|
+
* ready to be registered.
|
|
33
|
+
*
|
|
34
|
+
* This also adds a listener for {@link "@wallet-standard/base".WindowAppReadyEvent} to listen for a notification from
|
|
35
|
+
* the app that the app is ready to register the Wallet.
|
|
36
|
+
*
|
|
37
|
+
* This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon
|
|
38
|
+
* as the app is ready whether the Wallet loads before or after the app.
|
|
39
|
+
*
|
|
40
|
+
* @param wallet Wallet to register.
|
|
41
|
+
*
|
|
42
|
+
* @group Wallet
|
|
43
|
+
*/
|
|
44
|
+
function registerWallet(wallet) {
|
|
45
|
+
const callback = ({ register }) => register(wallet);
|
|
46
|
+
try {
|
|
47
|
+
window.dispatchEvent(new RegisterWalletEvent(callback));
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error('wallet-standard:register-wallet event could not be dispatched\n', error);
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
console.error('wallet-standard:app-ready event listener could not be added\n', error);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
class RegisterWalletEvent extends Event {
|
|
60
|
+
get detail() {
|
|
61
|
+
return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
|
|
62
|
+
}
|
|
63
|
+
get type() {
|
|
64
|
+
return 'wallet-standard:register-wallet';
|
|
65
|
+
}
|
|
66
|
+
constructor(callback) {
|
|
67
|
+
super('wallet-standard:register-wallet', {
|
|
68
|
+
bubbles: false,
|
|
69
|
+
cancelable: false,
|
|
70
|
+
composed: false,
|
|
71
|
+
});
|
|
72
|
+
_RegisterWalletEvent_detail.set(this, void 0);
|
|
73
|
+
__classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
|
|
74
|
+
}
|
|
75
|
+
/** @deprecated */
|
|
76
|
+
preventDefault() {
|
|
77
|
+
throw new Error('preventDefault cannot be called');
|
|
78
|
+
}
|
|
79
|
+
/** @deprecated */
|
|
80
|
+
stopImmediatePropagation() {
|
|
81
|
+
throw new Error('stopImmediatePropagation cannot be called');
|
|
82
|
+
}
|
|
83
|
+
/** @deprecated */
|
|
84
|
+
stopPropagation() {
|
|
85
|
+
throw new Error('stopPropagation cannot be called');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
_RegisterWalletEvent_detail = new WeakMap();
|
|
89
|
+
|
|
12
90
|
/** Name of the feature. */
|
|
13
91
|
const SolanaSignAndSendTransaction = 'solana:signAndSendTransaction';
|
|
14
92
|
|
|
@@ -3102,107 +3180,79 @@ function requireBrowser () {
|
|
|
3102
3180
|
var browserExports = requireBrowser();
|
|
3103
3181
|
var QRCode = /*@__PURE__*/index.getDefaultExportFromCjs(browserExports);
|
|
3104
3182
|
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
catch (error) {
|
|
3145
|
-
console.error('wallet-standard:app-ready event listener could not be added\n', error);
|
|
3146
|
-
}
|
|
3147
|
-
}
|
|
3148
|
-
class RegisterWalletEvent extends Event {
|
|
3149
|
-
get detail() {
|
|
3150
|
-
return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, "f");
|
|
3151
|
-
}
|
|
3152
|
-
get type() {
|
|
3153
|
-
return 'wallet-standard:register-wallet';
|
|
3154
|
-
}
|
|
3155
|
-
constructor(callback) {
|
|
3156
|
-
super('wallet-standard:register-wallet', {
|
|
3157
|
-
bubbles: false,
|
|
3158
|
-
cancelable: false,
|
|
3159
|
-
composed: false,
|
|
3160
|
-
});
|
|
3161
|
-
_RegisterWalletEvent_detail.set(this, void 0);
|
|
3162
|
-
__classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, "f");
|
|
3163
|
-
}
|
|
3164
|
-
/** @deprecated */
|
|
3165
|
-
preventDefault() {
|
|
3166
|
-
throw new Error('preventDefault cannot be called');
|
|
3167
|
-
}
|
|
3168
|
-
/** @deprecated */
|
|
3169
|
-
stopImmediatePropagation() {
|
|
3170
|
-
throw new Error('stopImmediatePropagation cannot be called');
|
|
3171
|
-
}
|
|
3172
|
-
/** @deprecated */
|
|
3173
|
-
stopPropagation() {
|
|
3174
|
-
throw new Error('stopPropagation cannot be called');
|
|
3175
|
-
}
|
|
3176
|
-
}
|
|
3177
|
-
_RegisterWalletEvent_detail = new WeakMap();
|
|
3178
|
-
|
|
3179
|
-
/** Solana Mainnet (beta) cluster, e.g. https://api.mainnet-beta.solana.com */
|
|
3180
|
-
const SOLANA_MAINNET_CHAIN = 'solana:mainnet';
|
|
3181
|
-
|
|
3182
|
-
//#region src/base64Utils.ts
|
|
3183
|
-
function fromUint8Array(byteArray) {
|
|
3184
|
-
return window.btoa(String.fromCharCode.call(null, ...byteArray));
|
|
3183
|
+
//#region src/createDefaultAuthorizationCache.ts
|
|
3184
|
+
const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
|
|
3185
|
+
function createDefaultAuthorizationCache() {
|
|
3186
|
+
let storage;
|
|
3187
|
+
try {
|
|
3188
|
+
storage = window.localStorage;
|
|
3189
|
+
} catch {}
|
|
3190
|
+
return {
|
|
3191
|
+
async clear() {
|
|
3192
|
+
if (!storage) return;
|
|
3193
|
+
try {
|
|
3194
|
+
storage.removeItem(CACHE_KEY);
|
|
3195
|
+
} catch {}
|
|
3196
|
+
},
|
|
3197
|
+
async get() {
|
|
3198
|
+
if (!storage) return;
|
|
3199
|
+
try {
|
|
3200
|
+
const parsed = JSON.parse(storage.getItem(CACHE_KEY));
|
|
3201
|
+
if (parsed && parsed.accounts) {
|
|
3202
|
+
const parsedAccounts = parsed.accounts.map((account) => {
|
|
3203
|
+
return {
|
|
3204
|
+
...account,
|
|
3205
|
+
publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : encoding.base58ToUint8Array(account.address)
|
|
3206
|
+
};
|
|
3207
|
+
});
|
|
3208
|
+
return {
|
|
3209
|
+
...parsed,
|
|
3210
|
+
accounts: parsedAccounts
|
|
3211
|
+
};
|
|
3212
|
+
} else return parsed || void 0;
|
|
3213
|
+
} catch {}
|
|
3214
|
+
},
|
|
3215
|
+
async set(authorization) {
|
|
3216
|
+
if (!storage) return;
|
|
3217
|
+
try {
|
|
3218
|
+
storage.setItem(CACHE_KEY, JSON.stringify(authorization));
|
|
3219
|
+
} catch {}
|
|
3220
|
+
}
|
|
3221
|
+
};
|
|
3185
3222
|
}
|
|
3186
|
-
|
|
3187
|
-
|
|
3223
|
+
//#endregion
|
|
3224
|
+
//#region src/createDefaultChainSelector.ts
|
|
3225
|
+
function createDefaultChainSelector() {
|
|
3226
|
+
return { async select(chains) {
|
|
3227
|
+
if (chains.length === 1) return chains[0];
|
|
3228
|
+
else if (chains.includes(SOLANA_MAINNET_CHAIN)) return SOLANA_MAINNET_CHAIN;
|
|
3229
|
+
else return chains[0];
|
|
3230
|
+
} };
|
|
3188
3231
|
}
|
|
3189
3232
|
//#endregion
|
|
3190
|
-
//#region src/embedded-modal/
|
|
3233
|
+
//#region src/embedded-modal/modal.ts
|
|
3191
3234
|
const modalHtml$1 = `
|
|
3192
|
-
<div class="mobile-wallet-adapter-embedded-
|
|
3235
|
+
<div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
3193
3236
|
<div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3237
|
+
<div class="mobile-wallet-adapter-embedded-modal-card">
|
|
3238
|
+
<div>
|
|
3239
|
+
<button data-modal-close class="mobile-wallet-adapter-embedded-modal-close">
|
|
3240
|
+
<svg width="14" height="14">
|
|
3241
|
+
<path d="M 6.7125,8.3036995 1.9082,13.108199 c -0.2113,0.2112 -0.4765,0.3168 -0.7957,0.3168 -0.3192,0 -0.5844,-0.1056 -0.7958,-0.3168 C 0.1056,12.896899 0,12.631699 0,12.312499 c 0,-0.3192 0.1056,-0.5844 0.3167,-0.7958 L 5.1212,6.7124995 0.3167,1.9082 C 0.1056,1.6969 0,1.4317 0,1.1125 0,0.7933 0.1056,0.5281 0.3167,0.3167 0.5281,0.1056 0.7933,0 1.1125,0 1.4317,0 1.6969,0.1056 1.9082,0.3167 L 6.7125,5.1212 11.5167,0.3167 C 11.7281,0.1056 11.9933,0 12.3125,0 c 0.3192,0 0.5844,0.1056 0.7957,0.3167 0.2112,0.2114 0.3168,0.4766 0.3168,0.7958 0,0.3192 -0.1056,0.5844 -0.3168,0.7957 L 8.3037001,6.7124995 13.1082,11.516699 c 0.2112,0.2114 0.3168,0.4766 0.3168,0.7958 0,0.3192 -0.1056,0.5844 -0.3168,0.7957 -0.2113,0.2112 -0.4765,0.3168 -0.7957,0.3168 -0.3192,0 -0.5844,-0.1056 -0.7958,-0.3168 z" />
|
|
3242
|
+
</svg>
|
|
3243
|
+
</button>
|
|
3244
|
+
</div>
|
|
3245
|
+
<div class="mobile-wallet-adapter-embedded-modal-content"></div>
|
|
3246
|
+
</div>
|
|
3197
3247
|
</div>
|
|
3198
3248
|
`;
|
|
3199
3249
|
const css$6 = `
|
|
3200
|
-
.mobile-wallet-adapter-embedded-
|
|
3250
|
+
.mobile-wallet-adapter-embedded-modal-container {
|
|
3201
3251
|
display: flex; /* Use flexbox to center content */
|
|
3202
3252
|
justify-content: center; /* Center horizontally */
|
|
3203
|
-
align-items:
|
|
3253
|
+
align-items: center; /* Center vertically */
|
|
3204
3254
|
position: fixed; /* Stay in place */
|
|
3205
|
-
z-index:
|
|
3255
|
+
z-index: 2147483647; /* Sit on top */
|
|
3206
3256
|
left: 0;
|
|
3207
3257
|
top: 0;
|
|
3208
3258
|
width: 100%; /* Full width */
|
|
@@ -3211,178 +3261,21 @@ const css$6 = `
|
|
|
3211
3261
|
overflow-y: auto; /* enable scrolling */
|
|
3212
3262
|
}
|
|
3213
3263
|
|
|
3214
|
-
.mobile-wallet-adapter-embedded-
|
|
3264
|
+
.mobile-wallet-adapter-embedded-modal-card {
|
|
3215
3265
|
display: flex;
|
|
3216
|
-
|
|
3266
|
+
flex-direction: column;
|
|
3267
|
+
margin: auto 20px;
|
|
3268
|
+
max-width: 780px;
|
|
3269
|
+
padding: 20px;
|
|
3270
|
+
border-radius: 24px;
|
|
3271
|
+
background: #ffffff;
|
|
3272
|
+
font-family: "Inter Tight", "PT Sans", Calibri, sans-serif;
|
|
3273
|
+
transform: translateY(-200%);
|
|
3274
|
+
animation: slide-in 0.5s forwards;
|
|
3217
3275
|
}
|
|
3218
3276
|
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
left: -9999px;
|
|
3222
|
-
width: 10px;
|
|
3223
|
-
height: 10px;
|
|
3224
|
-
border-radius: 5px;
|
|
3225
|
-
background-color: var(--spinner-color);
|
|
3226
|
-
color: var(--spinner-color);
|
|
3227
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3228
|
-
9999px 0 0 0 var(--spinner-color),
|
|
3229
|
-
10014px 0 0 0 var(--spinner-color);
|
|
3230
|
-
animation: dot-typing 1.5s infinite linear;
|
|
3231
|
-
}
|
|
3232
|
-
|
|
3233
|
-
@keyframes dot-typing {
|
|
3234
|
-
0% {
|
|
3235
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3236
|
-
9999px 0 0 0 var(--spinner-color),
|
|
3237
|
-
10014px 0 0 0 var(--spinner-color);
|
|
3238
|
-
}
|
|
3239
|
-
16.667% {
|
|
3240
|
-
box-shadow: 9984px -10px 0 0 var(--spinner-color),
|
|
3241
|
-
9999px 0 0 0 var(--spinner-color),
|
|
3242
|
-
10014px 0 0 0 var(--spinner-color);
|
|
3243
|
-
}
|
|
3244
|
-
33.333% {
|
|
3245
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3246
|
-
9999px 0 0 0 var(--spinner-color),
|
|
3247
|
-
10014px 0 0 0 var(--spinner-color);
|
|
3248
|
-
}
|
|
3249
|
-
50% {
|
|
3250
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3251
|
-
9999px -10px 0 0 var(--spinner-color),
|
|
3252
|
-
10014px 0 0 0 var(--spinner-color);
|
|
3253
|
-
}
|
|
3254
|
-
66.667% {
|
|
3255
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3256
|
-
9999px 0 0 0 var(--spinner-color),
|
|
3257
|
-
10014px 0 0 0 var(--spinner-color);
|
|
3258
|
-
}
|
|
3259
|
-
83.333% {
|
|
3260
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3261
|
-
9999px 0 0 0 var(--spinner-color),
|
|
3262
|
-
10014px -10px 0 0 var(--spinner-color);
|
|
3263
|
-
}
|
|
3264
|
-
100% {
|
|
3265
|
-
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3266
|
-
9999px 0 0 0 var(--spinner-color),
|
|
3267
|
-
10014px 0 0 0 var(--spinner-color);
|
|
3268
|
-
}
|
|
3269
|
-
}
|
|
3270
|
-
`;
|
|
3271
|
-
var EmbeddedLoadingSpinner = class {
|
|
3272
|
-
#root = null;
|
|
3273
|
-
#eventListeners = {};
|
|
3274
|
-
#listenersAttached = false;
|
|
3275
|
-
dom = null;
|
|
3276
|
-
constructor() {
|
|
3277
|
-
this.init = this.init.bind(this);
|
|
3278
|
-
this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
|
|
3279
|
-
}
|
|
3280
|
-
async init() {
|
|
3281
|
-
console.log("Injecting modal");
|
|
3282
|
-
this.#injectHTML();
|
|
3283
|
-
}
|
|
3284
|
-
open = () => {
|
|
3285
|
-
console.debug("Modal open");
|
|
3286
|
-
this.#attachEventListeners();
|
|
3287
|
-
if (this.#root) this.#root.style.display = "flex";
|
|
3288
|
-
};
|
|
3289
|
-
close = (event = void 0) => {
|
|
3290
|
-
console.debug("Modal close");
|
|
3291
|
-
this.#removeEventListeners();
|
|
3292
|
-
if (this.#root) this.#root.style.display = "none";
|
|
3293
|
-
this.#eventListeners["close"]?.forEach((listener) => listener(event));
|
|
3294
|
-
};
|
|
3295
|
-
addEventListener(event, listener) {
|
|
3296
|
-
this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
|
|
3297
|
-
return () => this.removeEventListener(event, listener);
|
|
3298
|
-
}
|
|
3299
|
-
removeEventListener(event, listener) {
|
|
3300
|
-
this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
|
|
3301
|
-
}
|
|
3302
|
-
#injectHTML() {
|
|
3303
|
-
if (this.dom) return;
|
|
3304
|
-
this.#root = document.createElement("div");
|
|
3305
|
-
this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
|
|
3306
|
-
this.#root.innerHTML = modalHtml$1;
|
|
3307
|
-
this.#root.style.display = "none";
|
|
3308
|
-
const styles = document.createElement("style");
|
|
3309
|
-
styles.id = "mobile-wallet-adapter-embedded-modal-styles";
|
|
3310
|
-
styles.textContent = css$6;
|
|
3311
|
-
const host = document.createElement("div");
|
|
3312
|
-
this.dom = host.attachShadow({ mode: "closed" });
|
|
3313
|
-
host.style.setProperty("--spinner-color", "#FFFFFF");
|
|
3314
|
-
this.dom.appendChild(styles);
|
|
3315
|
-
this.dom.appendChild(this.#root);
|
|
3316
|
-
document.body.appendChild(host);
|
|
3317
|
-
}
|
|
3318
|
-
#attachEventListeners() {
|
|
3319
|
-
if (!this.#root || this.#listenersAttached) return;
|
|
3320
|
-
[...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
|
|
3321
|
-
this.close(event);
|
|
3322
|
-
}));
|
|
3323
|
-
window.addEventListener("load", this.close);
|
|
3324
|
-
document.addEventListener("keydown", this.#handleKeyDown);
|
|
3325
|
-
this.#listenersAttached = true;
|
|
3326
|
-
}
|
|
3327
|
-
#removeEventListeners() {
|
|
3328
|
-
if (!this.#listenersAttached) return;
|
|
3329
|
-
window.removeEventListener("load", this.close);
|
|
3330
|
-
document.removeEventListener("keydown", this.#handleKeyDown);
|
|
3331
|
-
if (!this.#root) return;
|
|
3332
|
-
[...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
|
|
3333
|
-
this.#listenersAttached = false;
|
|
3334
|
-
}
|
|
3335
|
-
#handleKeyDown = (event) => {
|
|
3336
|
-
if (event.key === "Escape") this.close(event);
|
|
3337
|
-
};
|
|
3338
|
-
};
|
|
3339
|
-
//#endregion
|
|
3340
|
-
//#region src/embedded-modal/modal.ts
|
|
3341
|
-
const modalHtml = `
|
|
3342
|
-
<div class="mobile-wallet-adapter-embedded-modal-container" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
3343
|
-
<div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
|
|
3344
|
-
<div class="mobile-wallet-adapter-embedded-modal-card">
|
|
3345
|
-
<div>
|
|
3346
|
-
<button data-modal-close class="mobile-wallet-adapter-embedded-modal-close">
|
|
3347
|
-
<svg width="14" height="14">
|
|
3348
|
-
<path d="M 6.7125,8.3036995 1.9082,13.108199 c -0.2113,0.2112 -0.4765,0.3168 -0.7957,0.3168 -0.3192,0 -0.5844,-0.1056 -0.7958,-0.3168 C 0.1056,12.896899 0,12.631699 0,12.312499 c 0,-0.3192 0.1056,-0.5844 0.3167,-0.7958 L 5.1212,6.7124995 0.3167,1.9082 C 0.1056,1.6969 0,1.4317 0,1.1125 0,0.7933 0.1056,0.5281 0.3167,0.3167 0.5281,0.1056 0.7933,0 1.1125,0 1.4317,0 1.6969,0.1056 1.9082,0.3167 L 6.7125,5.1212 11.5167,0.3167 C 11.7281,0.1056 11.9933,0 12.3125,0 c 0.3192,0 0.5844,0.1056 0.7957,0.3167 0.2112,0.2114 0.3168,0.4766 0.3168,0.7958 0,0.3192 -0.1056,0.5844 -0.3168,0.7957 L 8.3037001,6.7124995 13.1082,11.516699 c 0.2112,0.2114 0.3168,0.4766 0.3168,0.7958 0,0.3192 -0.1056,0.5844 -0.3168,0.7957 -0.2113,0.2112 -0.4765,0.3168 -0.7957,0.3168 -0.3192,0 -0.5844,-0.1056 -0.7958,-0.3168 z" />
|
|
3349
|
-
</svg>
|
|
3350
|
-
</button>
|
|
3351
|
-
</div>
|
|
3352
|
-
<div class="mobile-wallet-adapter-embedded-modal-content"></div>
|
|
3353
|
-
</div>
|
|
3354
|
-
</div>
|
|
3355
|
-
`;
|
|
3356
|
-
const css$5 = `
|
|
3357
|
-
.mobile-wallet-adapter-embedded-modal-container {
|
|
3358
|
-
display: flex; /* Use flexbox to center content */
|
|
3359
|
-
justify-content: center; /* Center horizontally */
|
|
3360
|
-
align-items: center; /* Center vertically */
|
|
3361
|
-
position: fixed; /* Stay in place */
|
|
3362
|
-
z-index: 2147483647; /* Sit on top */
|
|
3363
|
-
left: 0;
|
|
3364
|
-
top: 0;
|
|
3365
|
-
width: 100%; /* Full width */
|
|
3366
|
-
height: 100%; /* Full height */
|
|
3367
|
-
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
|
3368
|
-
overflow-y: auto; /* enable scrolling */
|
|
3369
|
-
}
|
|
3370
|
-
|
|
3371
|
-
.mobile-wallet-adapter-embedded-modal-card {
|
|
3372
|
-
display: flex;
|
|
3373
|
-
flex-direction: column;
|
|
3374
|
-
margin: auto 20px;
|
|
3375
|
-
max-width: 780px;
|
|
3376
|
-
padding: 20px;
|
|
3377
|
-
border-radius: 24px;
|
|
3378
|
-
background: #ffffff;
|
|
3379
|
-
font-family: "Inter Tight", "PT Sans", Calibri, sans-serif;
|
|
3380
|
-
transform: translateY(-200%);
|
|
3381
|
-
animation: slide-in 0.5s forwards;
|
|
3382
|
-
}
|
|
3383
|
-
|
|
3384
|
-
@keyframes slide-in {
|
|
3385
|
-
100% { transform: translateY(0%); }
|
|
3277
|
+
@keyframes slide-in {
|
|
3278
|
+
100% { transform: translateY(0%); }
|
|
3386
3279
|
}
|
|
3387
3280
|
|
|
3388
3281
|
.mobile-wallet-adapter-embedded-modal-close {
|
|
@@ -3453,13 +3346,13 @@ var EmbeddedModal = class {
|
|
|
3453
3346
|
}
|
|
3454
3347
|
this.#root = document.createElement("div");
|
|
3455
3348
|
this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
|
|
3456
|
-
this.#root.innerHTML = modalHtml;
|
|
3349
|
+
this.#root.innerHTML = modalHtml$1;
|
|
3457
3350
|
this.#root.style.display = "none";
|
|
3458
3351
|
const content = this.#root.querySelector(".mobile-wallet-adapter-embedded-modal-content");
|
|
3459
3352
|
if (content) content.innerHTML = this.contentHtml;
|
|
3460
3353
|
const styles = document.createElement("style");
|
|
3461
3354
|
styles.id = "mobile-wallet-adapter-embedded-modal-styles";
|
|
3462
|
-
styles.textContent = css$
|
|
3355
|
+
styles.textContent = css$6 + this.contentStyles;
|
|
3463
3356
|
const host = document.createElement("div");
|
|
3464
3357
|
host.innerHTML = fonts;
|
|
3465
3358
|
this.dom = host.attachShadow({ mode: "closed" });
|
|
@@ -3487,292 +3380,124 @@ var EmbeddedModal = class {
|
|
|
3487
3380
|
};
|
|
3488
3381
|
};
|
|
3489
3382
|
//#endregion
|
|
3490
|
-
//#region src/embedded-modal/
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3383
|
+
//#region src/embedded-modal/errorModal.ts
|
|
3384
|
+
const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
|
|
3385
|
+
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.";
|
|
3386
|
+
var ErrorModal = class extends EmbeddedModal {
|
|
3387
|
+
contentStyles = css$5;
|
|
3388
|
+
contentHtml = ErrorDialogHtml$3;
|
|
3389
|
+
initWithError(error) {
|
|
3495
3390
|
super.init();
|
|
3496
|
-
this.
|
|
3391
|
+
this.populateError(error);
|
|
3497
3392
|
}
|
|
3498
|
-
|
|
3499
|
-
const
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3393
|
+
populateError(error) {
|
|
3394
|
+
const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
|
|
3395
|
+
const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
|
|
3396
|
+
if (errorMessageElement) {
|
|
3397
|
+
if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
|
|
3398
|
+
case "ERROR_WALLET_NOT_FOUND":
|
|
3399
|
+
errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
|
|
3400
|
+
if (actionBtn) actionBtn.addEventListener("click", () => {
|
|
3401
|
+
window.location.href = "https://solanamobile.com/wallets";
|
|
3402
|
+
});
|
|
3403
|
+
return;
|
|
3404
|
+
case "ERROR_BROWSER_NOT_SUPPORTED":
|
|
3405
|
+
errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
|
|
3406
|
+
if (actionBtn) actionBtn.style.display = "none";
|
|
3407
|
+
return;
|
|
3408
|
+
}
|
|
3409
|
+
errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
|
|
3410
|
+
} else console.log("Failed to locate error dialog element");
|
|
3510
3411
|
}
|
|
3511
3412
|
};
|
|
3512
|
-
const
|
|
3513
|
-
<
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
</div>
|
|
3521
|
-
<div>
|
|
3522
|
-
<div>
|
|
3523
|
-
<h4 class="mobile-wallet-adapter-embedded-modal-qr-label">
|
|
3524
|
-
Open your wallet and scan this code
|
|
3525
|
-
</h4>
|
|
3526
|
-
</div>
|
|
3527
|
-
<div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
|
|
3528
|
-
<div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
|
|
3529
|
-
</div>
|
|
3530
|
-
</div>
|
|
3531
|
-
</div>
|
|
3532
|
-
<div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
|
|
3533
|
-
<div class="mobile-wallet-adapter-embedded-modal-footer">
|
|
3534
|
-
<div class="mobile-wallet-adapter-embedded-modal-subtitle">
|
|
3535
|
-
Follow the instructions on your device. When you're finished, this screen will update.
|
|
3536
|
-
</div>
|
|
3537
|
-
<div class="mobile-wallet-adapter-embedded-modal-progress-badge">
|
|
3538
|
-
<div>
|
|
3539
|
-
<div class="spinner">
|
|
3540
|
-
<div class="leftWrapper">
|
|
3541
|
-
<div class="left">
|
|
3542
|
-
<div class="circle"></div>
|
|
3543
|
-
</div>
|
|
3544
|
-
</div>
|
|
3545
|
-
<div class="rightWrapper">
|
|
3546
|
-
<div class="right">
|
|
3547
|
-
<div class="circle"></div>
|
|
3548
|
-
</div>
|
|
3549
|
-
</div>
|
|
3550
|
-
</div>
|
|
3551
|
-
</div>
|
|
3552
|
-
<div>Waiting for scan</div>
|
|
3553
|
-
</div>
|
|
3413
|
+
const ErrorDialogHtml$3 = `
|
|
3414
|
+
<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>
|
|
3415
|
+
<div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
|
|
3416
|
+
<div id="mobile-wallet-adapter-error-message" class="mobile-wallet-adapter-embedded-modal-subtitle"></div>
|
|
3417
|
+
<div>
|
|
3418
|
+
<button data-error-action id="mobile-wallet-adapter-error-action" class="mobile-wallet-adapter-embedded-modal-error-action">
|
|
3419
|
+
Find a wallet
|
|
3420
|
+
</button>
|
|
3554
3421
|
</div>
|
|
3555
3422
|
`;
|
|
3556
|
-
const css$
|
|
3557
|
-
.mobile-wallet-adapter-embedded-modal-
|
|
3558
|
-
|
|
3559
|
-
margin-top: 10px;
|
|
3560
|
-
padding: 10px;
|
|
3423
|
+
const css$5 = `
|
|
3424
|
+
.mobile-wallet-adapter-embedded-modal-content {
|
|
3425
|
+
text-align: center;
|
|
3561
3426
|
}
|
|
3562
3427
|
|
|
3563
|
-
.mobile-wallet-adapter-embedded-modal-
|
|
3564
|
-
|
|
3565
|
-
flex-direction: column;
|
|
3566
|
-
flex: 2;
|
|
3567
|
-
margin-top: auto;
|
|
3568
|
-
margin-right: 30px;
|
|
3569
|
-
}
|
|
3570
|
-
|
|
3571
|
-
.mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
|
|
3572
|
-
display: flex;
|
|
3573
|
-
flex-direction: column;
|
|
3574
|
-
flex: 1;
|
|
3575
|
-
margin-left: auto;
|
|
3576
|
-
}
|
|
3577
|
-
|
|
3578
|
-
.mobile-wallet-adapter-embedded-modal-footer {
|
|
3579
|
-
display: flex;
|
|
3580
|
-
padding: 10px;
|
|
3428
|
+
.mobile-wallet-adapter-embedded-modal-error-icon {
|
|
3429
|
+
margin-top: 24px;
|
|
3581
3430
|
}
|
|
3582
3431
|
|
|
3583
|
-
.mobile-wallet-adapter-embedded-modal-icon {}
|
|
3584
|
-
|
|
3585
3432
|
.mobile-wallet-adapter-embedded-modal-title {
|
|
3433
|
+
margin: 18px 100px auto 100px;
|
|
3586
3434
|
color: #000000;
|
|
3587
|
-
font-size: 2.
|
|
3435
|
+
font-size: 2.75em;
|
|
3588
3436
|
font-weight: 600;
|
|
3589
3437
|
}
|
|
3590
3438
|
|
|
3591
|
-
.mobile-wallet-adapter-embedded-modal-qr-label {
|
|
3592
|
-
text-align: right;
|
|
3593
|
-
color: #000000;
|
|
3594
|
-
}
|
|
3595
|
-
|
|
3596
|
-
.mobile-wallet-adapter-embedded-modal-qr-code-container {
|
|
3597
|
-
margin-left: auto;
|
|
3598
|
-
}
|
|
3599
|
-
|
|
3600
|
-
.mobile-wallet-adapter-embedded-modal-qr-placeholder {
|
|
3601
|
-
margin-left: auto;
|
|
3602
|
-
min-width: 200px;
|
|
3603
|
-
min-height: 200px;
|
|
3604
|
-
background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
|
|
3605
|
-
background-size: 200%;
|
|
3606
|
-
animation: placeholderAnimate 2.7s linear infinite;
|
|
3607
|
-
border-radius: 12px;
|
|
3608
|
-
}
|
|
3609
|
-
|
|
3610
|
-
.mobile-wallet-adapter-embedded-modal-divider {
|
|
3611
|
-
margin-top: 20px;
|
|
3612
|
-
padding-left: 10px;
|
|
3613
|
-
padding-right: 10px;
|
|
3614
|
-
}
|
|
3615
|
-
|
|
3616
|
-
.mobile-wallet-adapter-embedded-modal-divider hr {
|
|
3617
|
-
border-top: 1px solid #D9DEDE;
|
|
3618
|
-
}
|
|
3619
|
-
|
|
3620
3439
|
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
3621
|
-
margin:
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3440
|
+
margin: 30px 60px 40px 60px;
|
|
3441
|
+
color: #000000;
|
|
3442
|
+
font-size: 1.25em;
|
|
3443
|
+
font-weight: 400;
|
|
3625
3444
|
}
|
|
3626
3445
|
|
|
3627
|
-
.mobile-wallet-adapter-embedded-modal-
|
|
3628
|
-
display:
|
|
3629
|
-
|
|
3446
|
+
.mobile-wallet-adapter-embedded-modal-error-action {
|
|
3447
|
+
display: block;
|
|
3448
|
+
width: 100%;
|
|
3630
3449
|
height: 56px;
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3450
|
+
/*margin-top: 40px;*/
|
|
3451
|
+
font-size: 1.25em;
|
|
3452
|
+
/*line-height: 24px;*/
|
|
3453
|
+
/*letter-spacing: -1%;*/
|
|
3454
|
+
background: #000000;
|
|
3455
|
+
color: #FFFFFF;
|
|
3635
3456
|
border-radius: 18px;
|
|
3636
|
-
color: #A8B6B8;
|
|
3637
|
-
align-items: center;
|
|
3638
|
-
}
|
|
3639
|
-
|
|
3640
|
-
.mobile-wallet-adapter-embedded-modal-progress-badge > div:first-child {
|
|
3641
|
-
margin-left: auto;
|
|
3642
|
-
margin-right: 20px;
|
|
3643
|
-
}
|
|
3644
|
-
|
|
3645
|
-
.mobile-wallet-adapter-embedded-modal-progress-badge > div:nth-child(2) {
|
|
3646
|
-
margin-right: auto;
|
|
3647
3457
|
}
|
|
3648
3458
|
|
|
3649
3459
|
/* Smaller screens */
|
|
3650
3460
|
@media all and (max-width: 600px) {
|
|
3651
|
-
.mobile-wallet-adapter-embedded-modal-card {
|
|
3652
|
-
text-align: center;
|
|
3653
|
-
}
|
|
3654
|
-
.mobile-wallet-adapter-embedded-modal-qr-content {
|
|
3655
|
-
flex-direction: column;
|
|
3656
|
-
}
|
|
3657
|
-
.mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
|
|
3658
|
-
margin: auto;
|
|
3659
|
-
}
|
|
3660
|
-
.mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
|
|
3661
|
-
margin: auto;
|
|
3662
|
-
flex: 2 auto;
|
|
3663
|
-
}
|
|
3664
|
-
.mobile-wallet-adapter-embedded-modal-footer {
|
|
3665
|
-
flex-direction: column;
|
|
3666
|
-
}
|
|
3667
|
-
.mobile-wallet-adapter-embedded-modal-icon {
|
|
3668
|
-
display: none;
|
|
3669
|
-
}
|
|
3670
3461
|
.mobile-wallet-adapter-embedded-modal-title {
|
|
3671
3462
|
font-size: 1.5em;
|
|
3463
|
+
margin-right: 12px;
|
|
3464
|
+
margin-left: 12px;
|
|
3672
3465
|
}
|
|
3673
3466
|
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
3674
|
-
margin-right:
|
|
3675
|
-
|
|
3676
|
-
.mobile-wallet-adapter-embedded-modal-qr-label {
|
|
3677
|
-
text-align: center;
|
|
3678
|
-
}
|
|
3679
|
-
.mobile-wallet-adapter-embedded-modal-qr-code-container {
|
|
3680
|
-
margin: auto;
|
|
3681
|
-
}
|
|
3682
|
-
.mobile-wallet-adapter-embedded-modal-qr-placeholder {
|
|
3683
|
-
margin: auto;
|
|
3684
|
-
}
|
|
3685
|
-
}
|
|
3686
|
-
|
|
3687
|
-
/* QR Placeholder */
|
|
3688
|
-
@keyframes placeholderAnimate {
|
|
3689
|
-
0% { background-position: 200% 0; }
|
|
3690
|
-
100% { background-position: -200% 0; }
|
|
3691
|
-
}
|
|
3692
|
-
|
|
3693
|
-
/* Spinner */
|
|
3694
|
-
@keyframes spinLeft {
|
|
3695
|
-
0% {
|
|
3696
|
-
transform: rotate(20deg);
|
|
3697
|
-
}
|
|
3698
|
-
50% {
|
|
3699
|
-
transform: rotate(160deg);
|
|
3700
|
-
}
|
|
3701
|
-
100% {
|
|
3702
|
-
transform: rotate(20deg);
|
|
3703
|
-
}
|
|
3704
|
-
}
|
|
3705
|
-
@keyframes spinRight {
|
|
3706
|
-
0% {
|
|
3707
|
-
transform: rotate(160deg);
|
|
3708
|
-
}
|
|
3709
|
-
50% {
|
|
3710
|
-
transform: rotate(20deg);
|
|
3711
|
-
}
|
|
3712
|
-
100% {
|
|
3713
|
-
transform: rotate(160deg);
|
|
3714
|
-
}
|
|
3715
|
-
}
|
|
3716
|
-
@keyframes spin {
|
|
3717
|
-
0% {
|
|
3718
|
-
transform: rotate(0deg);
|
|
3719
|
-
}
|
|
3720
|
-
100% {
|
|
3721
|
-
transform: rotate(2520deg);
|
|
3467
|
+
margin-right: 12px;
|
|
3468
|
+
margin-left: 12px;
|
|
3722
3469
|
}
|
|
3723
3470
|
}
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
overflow: hidden;
|
|
3744
|
-
width: .75em;
|
|
3745
|
-
height: 1.5em;
|
|
3746
|
-
}
|
|
3747
|
-
.left, .leftWrapper {
|
|
3748
|
-
left: 0;
|
|
3749
|
-
}
|
|
3750
|
-
.right {
|
|
3751
|
-
left: -12px;
|
|
3752
|
-
}
|
|
3753
|
-
.rightWrapper {
|
|
3754
|
-
right: 0;
|
|
3755
|
-
}
|
|
3756
|
-
.circle {
|
|
3757
|
-
border: .125em solid #A8B6B8;
|
|
3758
|
-
width: 1.25em; /* 1.5em - 2*0.125em border */
|
|
3759
|
-
height: 1.25em; /* 1.5em - 2*0.125em border */
|
|
3760
|
-
border-radius: 0.75em; /* 0.5*1.5em spinner size 8 */
|
|
3761
|
-
}
|
|
3762
|
-
.left {
|
|
3763
|
-
transform-origin: 100% 50%;
|
|
3764
|
-
animation: spinLeft 2.5s cubic-bezier(.2,0,.8,1) infinite;
|
|
3471
|
+
`;
|
|
3472
|
+
//#endregion
|
|
3473
|
+
//#region src/createDefaultWalletNotFoundHandler.ts
|
|
3474
|
+
async function defaultErrorModalWalletNotFoundHandler() {
|
|
3475
|
+
if (typeof window !== "undefined") {
|
|
3476
|
+
const userAgent = window.navigator.userAgent.toLowerCase();
|
|
3477
|
+
const errorDialog = new ErrorModal();
|
|
3478
|
+
if (userAgent.includes("wv")) errorDialog.initWithError({
|
|
3479
|
+
name: "SolanaMobileWalletAdapterError",
|
|
3480
|
+
code: "ERROR_BROWSER_NOT_SUPPORTED",
|
|
3481
|
+
message: ""
|
|
3482
|
+
});
|
|
3483
|
+
else errorDialog.initWithError({
|
|
3484
|
+
name: "SolanaMobileWalletAdapterError",
|
|
3485
|
+
code: "ERROR_WALLET_NOT_FOUND",
|
|
3486
|
+
message: ""
|
|
3487
|
+
});
|
|
3488
|
+
errorDialog.open();
|
|
3489
|
+
}
|
|
3765
3490
|
}
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3491
|
+
function createDefaultWalletNotFoundHandler() {
|
|
3492
|
+
return async () => {
|
|
3493
|
+
defaultErrorModalWalletNotFoundHandler();
|
|
3494
|
+
};
|
|
3769
3495
|
}
|
|
3770
|
-
`;
|
|
3771
3496
|
//#endregion
|
|
3772
3497
|
//#region src/embedded-modal/localConnectionModal.ts
|
|
3773
3498
|
var LocalConnectionModal = class extends EmbeddedModal {
|
|
3774
|
-
contentStyles = css$
|
|
3775
|
-
contentHtml = ErrorDialogHtml$
|
|
3499
|
+
contentStyles = css$4;
|
|
3500
|
+
contentHtml = ErrorDialogHtml$2;
|
|
3776
3501
|
initWithCallback(callback) {
|
|
3777
3502
|
super.init();
|
|
3778
3503
|
this.#prepareLaunchAction(callback);
|
|
@@ -3787,7 +3512,7 @@ var LocalConnectionModal = class extends EmbeddedModal {
|
|
|
3787
3512
|
launchButton?.addEventListener("click", listener);
|
|
3788
3513
|
}
|
|
3789
3514
|
};
|
|
3790
|
-
const ErrorDialogHtml$
|
|
3515
|
+
const ErrorDialogHtml$2 = `
|
|
3791
3516
|
<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">
|
|
3792
3517
|
<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"/>
|
|
3793
3518
|
<mask id="mask0_189_522" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="8" y="8" width="32" height="32">
|
|
@@ -3809,7 +3534,7 @@ const ErrorDialogHtml$3 = `
|
|
|
3809
3534
|
</button>
|
|
3810
3535
|
</div>
|
|
3811
3536
|
`;
|
|
3812
|
-
const css$
|
|
3537
|
+
const css$4 = `
|
|
3813
3538
|
.mobile-wallet-adapter-embedded-modal-close {
|
|
3814
3539
|
display: none;
|
|
3815
3540
|
}
|
|
@@ -3847,10 +3572,10 @@ const css$3 = `
|
|
|
3847
3572
|
//#endregion
|
|
3848
3573
|
//#region src/embedded-modal/loopbackBlockedModal.ts
|
|
3849
3574
|
var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
|
|
3850
|
-
contentStyles = css$
|
|
3575
|
+
contentStyles = css$3;
|
|
3851
3576
|
get contentHtml() {
|
|
3852
3577
|
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";
|
|
3853
|
-
return ErrorDialogHtml$
|
|
3578
|
+
return ErrorDialogHtml$1.replace("{{PERMISSION_INSTRUCTION_DETAIL}}", instructions);
|
|
3854
3579
|
}
|
|
3855
3580
|
async init() {
|
|
3856
3581
|
super.init();
|
|
@@ -3865,7 +3590,7 @@ var LoopbackPermissionBlockedModal = class extends EmbeddedModal {
|
|
|
3865
3590
|
launchButton?.addEventListener("click", listener);
|
|
3866
3591
|
}
|
|
3867
3592
|
};
|
|
3868
|
-
const ErrorDialogHtml$
|
|
3593
|
+
const ErrorDialogHtml$1 = `
|
|
3869
3594
|
<div class="mobile-wallet-adapter-embedded-modal-header">
|
|
3870
3595
|
Local Wallet Connection
|
|
3871
3596
|
</div>
|
|
@@ -3918,7 +3643,7 @@ const ErrorDialogHtml$2 = `
|
|
|
3918
3643
|
</button>
|
|
3919
3644
|
</div>
|
|
3920
3645
|
`;
|
|
3921
|
-
const css$
|
|
3646
|
+
const css$3 = `
|
|
3922
3647
|
.mobile-wallet-adapter-embedded-modal-close {
|
|
3923
3648
|
display: none;
|
|
3924
3649
|
}
|
|
@@ -4008,8 +3733,8 @@ const css$2 = `
|
|
|
4008
3733
|
//#endregion
|
|
4009
3734
|
//#region src/embedded-modal/loopbackPermissionModal.ts
|
|
4010
3735
|
var LoopbackPermissionModal = class extends EmbeddedModal {
|
|
4011
|
-
contentStyles = css$
|
|
4012
|
-
contentHtml = ErrorDialogHtml
|
|
3736
|
+
contentStyles = css$2;
|
|
3737
|
+
contentHtml = ErrorDialogHtml;
|
|
4013
3738
|
async init() {
|
|
4014
3739
|
super.init();
|
|
4015
3740
|
this.#prepareLaunchAction();
|
|
@@ -4026,7 +3751,7 @@ var LoopbackPermissionModal = class extends EmbeddedModal {
|
|
|
4026
3751
|
launchButton?.addEventListener("click", listener);
|
|
4027
3752
|
}
|
|
4028
3753
|
};
|
|
4029
|
-
const ErrorDialogHtml
|
|
3754
|
+
const ErrorDialogHtml = `
|
|
4030
3755
|
<div class="mobile-wallet-adapter-embedded-modal-title">Allow connections to your wallet</div>
|
|
4031
3756
|
<div id="mobile-wallet-adapter-local-launch-message" class="mobile-wallet-adapter-embedded-modal-subtitle">
|
|
4032
3757
|
Tap "Allow" on the next screen
|
|
@@ -4052,7 +3777,7 @@ const ErrorDialogHtml$1 = `
|
|
|
4052
3777
|
</button>
|
|
4053
3778
|
</div>
|
|
4054
3779
|
`;
|
|
4055
|
-
const css$
|
|
3780
|
+
const css$2 = `
|
|
4056
3781
|
.mobile-wallet-adapter-embedded-modal-close {
|
|
4057
3782
|
display: none;
|
|
4058
3783
|
}
|
|
@@ -4098,72 +3823,504 @@ const css$1 = `
|
|
|
4098
3823
|
margin-left: 12px;
|
|
4099
3824
|
}
|
|
4100
3825
|
}
|
|
4101
|
-
`;
|
|
4102
|
-
//#endregion
|
|
4103
|
-
//#region src/getIsSupported.ts
|
|
4104
|
-
function getIsLocalAssociationSupported() {
|
|
4105
|
-
return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
|
|
3826
|
+
`;
|
|
3827
|
+
//#endregion
|
|
3828
|
+
//#region src/getIsSupported.ts
|
|
3829
|
+
function getIsLocalAssociationSupported() {
|
|
3830
|
+
return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && /android/i.test(navigator.userAgent);
|
|
3831
|
+
}
|
|
3832
|
+
function getIsRemoteAssociationSupported() {
|
|
3833
|
+
return typeof window !== "undefined" && window.isSecureContext && typeof document !== "undefined" && !/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
3834
|
+
}
|
|
3835
|
+
function isWebView(userAgentString) {
|
|
3836
|
+
return /(WebView|Version\/.+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+)|; wv\).+(Chrome)\/(\d+)\.(\d+)\.(\d+)\.(\d+))/i.test(userAgentString);
|
|
3837
|
+
}
|
|
3838
|
+
function isSolanaMobileWebShell(userAgentString) {
|
|
3839
|
+
return userAgentString.includes("Solana Mobile Web Shell");
|
|
3840
|
+
}
|
|
3841
|
+
function getIsPwaLaunchedAsApp() {
|
|
3842
|
+
const isAndroidTwa = typeof document !== "undefined" && document.referrer.startsWith("android-app://");
|
|
3843
|
+
if (typeof window == "undefined") return isAndroidTwa;
|
|
3844
|
+
const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
|
|
3845
|
+
const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
|
|
3846
|
+
const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
|
|
3847
|
+
return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
|
|
3848
|
+
}
|
|
3849
|
+
async function checkLocalNetworkAccessPermission() {
|
|
3850
|
+
if (typeof navigator !== "undefined" && isSolanaMobileWebShell(navigator.userAgent)) return;
|
|
3851
|
+
try {
|
|
3852
|
+
const lnaPermission = await navigator.permissions.query({ name: "loopback-network" });
|
|
3853
|
+
if (lnaPermission.state === "granted") return;
|
|
3854
|
+
else if (lnaPermission.state === "denied") {
|
|
3855
|
+
const modal = new LoopbackPermissionBlockedModal();
|
|
3856
|
+
modal.init();
|
|
3857
|
+
modal.open();
|
|
3858
|
+
throw new mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError(mobileWalletAdapterProtocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
|
|
3859
|
+
} else if (lnaPermission.state === "prompt") {
|
|
3860
|
+
const modal = new LoopbackPermissionModal();
|
|
3861
|
+
if (await new Promise((resolve, reject) => {
|
|
3862
|
+
modal.addEventListener("close", (event) => {
|
|
3863
|
+
if (event) reject(new mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError(mobileWalletAdapterProtocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
|
|
3864
|
+
});
|
|
3865
|
+
lnaPermission.onchange = () => {
|
|
3866
|
+
lnaPermission.onchange = null;
|
|
3867
|
+
resolve(lnaPermission.state);
|
|
3868
|
+
};
|
|
3869
|
+
modal.init();
|
|
3870
|
+
modal.open();
|
|
3871
|
+
}) === "granted") {
|
|
3872
|
+
const modal = new LocalConnectionModal();
|
|
3873
|
+
await new Promise((resolve, reject) => {
|
|
3874
|
+
modal.addEventListener("close", (event) => {
|
|
3875
|
+
if (event) reject(new mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError(mobileWalletAdapterProtocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
|
|
3876
|
+
});
|
|
3877
|
+
modal.initWithCallback(async () => {
|
|
3878
|
+
resolve(true);
|
|
3879
|
+
});
|
|
3880
|
+
modal.open();
|
|
3881
|
+
});
|
|
3882
|
+
return;
|
|
3883
|
+
} else return await checkLocalNetworkAccessPermission();
|
|
3884
|
+
}
|
|
3885
|
+
throw new mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError(mobileWalletAdapterProtocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
|
|
3886
|
+
} catch (e) {
|
|
3887
|
+
if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
|
|
3888
|
+
if (e instanceof mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError) throw e;
|
|
3889
|
+
throw new mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError(mobileWalletAdapterProtocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
//#endregion
|
|
3893
|
+
//#region src/embedded-modal/loadingSpinner.ts
|
|
3894
|
+
const modalHtml = `
|
|
3895
|
+
<div class="mobile-wallet-adapter-embedded-loading-indicator" role="dialog" aria-modal="true" aria-labelledby="modal-title">
|
|
3896
|
+
<div data-modal-close style="position: absolute; width: 100%; height: 100%;"></div>
|
|
3897
|
+
<div class="mobile-wallet-adapter-embedded-loading-container">
|
|
3898
|
+
<div class="mobile-wallet-adapter-embedded-loading-animation"></div>
|
|
3899
|
+
</div>
|
|
3900
|
+
</div>
|
|
3901
|
+
`;
|
|
3902
|
+
const css$1 = `
|
|
3903
|
+
.mobile-wallet-adapter-embedded-loading-indicator {
|
|
3904
|
+
display: flex; /* Use flexbox to center content */
|
|
3905
|
+
justify-content: center; /* Center horizontally */
|
|
3906
|
+
align-items: start; /* Center vertically */
|
|
3907
|
+
position: fixed; /* Stay in place */
|
|
3908
|
+
z-index: 1; /* Sit on top */
|
|
3909
|
+
left: 0;
|
|
3910
|
+
top: 0;
|
|
3911
|
+
width: 100%; /* Full width */
|
|
3912
|
+
height: 100%; /* Full height */
|
|
3913
|
+
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
|
|
3914
|
+
overflow-y: auto; /* enable scrolling */
|
|
3915
|
+
}
|
|
3916
|
+
|
|
3917
|
+
.mobile-wallet-adapter-embedded-loading-container {
|
|
3918
|
+
display: flex;
|
|
3919
|
+
margin: auto;
|
|
3920
|
+
}
|
|
3921
|
+
|
|
3922
|
+
.mobile-wallet-adapter-embedded-loading-animation {
|
|
3923
|
+
position: relative;
|
|
3924
|
+
left: -9999px;
|
|
3925
|
+
width: 10px;
|
|
3926
|
+
height: 10px;
|
|
3927
|
+
border-radius: 5px;
|
|
3928
|
+
background-color: var(--spinner-color);
|
|
3929
|
+
color: var(--spinner-color);
|
|
3930
|
+
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3931
|
+
9999px 0 0 0 var(--spinner-color),
|
|
3932
|
+
10014px 0 0 0 var(--spinner-color);
|
|
3933
|
+
animation: dot-typing 1.5s infinite linear;
|
|
3934
|
+
}
|
|
3935
|
+
|
|
3936
|
+
@keyframes dot-typing {
|
|
3937
|
+
0% {
|
|
3938
|
+
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3939
|
+
9999px 0 0 0 var(--spinner-color),
|
|
3940
|
+
10014px 0 0 0 var(--spinner-color);
|
|
3941
|
+
}
|
|
3942
|
+
16.667% {
|
|
3943
|
+
box-shadow: 9984px -10px 0 0 var(--spinner-color),
|
|
3944
|
+
9999px 0 0 0 var(--spinner-color),
|
|
3945
|
+
10014px 0 0 0 var(--spinner-color);
|
|
3946
|
+
}
|
|
3947
|
+
33.333% {
|
|
3948
|
+
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3949
|
+
9999px 0 0 0 var(--spinner-color),
|
|
3950
|
+
10014px 0 0 0 var(--spinner-color);
|
|
3951
|
+
}
|
|
3952
|
+
50% {
|
|
3953
|
+
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3954
|
+
9999px -10px 0 0 var(--spinner-color),
|
|
3955
|
+
10014px 0 0 0 var(--spinner-color);
|
|
3956
|
+
}
|
|
3957
|
+
66.667% {
|
|
3958
|
+
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3959
|
+
9999px 0 0 0 var(--spinner-color),
|
|
3960
|
+
10014px 0 0 0 var(--spinner-color);
|
|
3961
|
+
}
|
|
3962
|
+
83.333% {
|
|
3963
|
+
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3964
|
+
9999px 0 0 0 var(--spinner-color),
|
|
3965
|
+
10014px -10px 0 0 var(--spinner-color);
|
|
3966
|
+
}
|
|
3967
|
+
100% {
|
|
3968
|
+
box-shadow: 9984px 0 0 0 var(--spinner-color),
|
|
3969
|
+
9999px 0 0 0 var(--spinner-color),
|
|
3970
|
+
10014px 0 0 0 var(--spinner-color);
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
`;
|
|
3974
|
+
var EmbeddedLoadingSpinner = class {
|
|
3975
|
+
#root = null;
|
|
3976
|
+
#eventListeners = {};
|
|
3977
|
+
#listenersAttached = false;
|
|
3978
|
+
dom = null;
|
|
3979
|
+
constructor() {
|
|
3980
|
+
this.init = this.init.bind(this);
|
|
3981
|
+
this.#root = document.getElementById("mobile-wallet-adapter-embedded-root-ui");
|
|
3982
|
+
}
|
|
3983
|
+
async init() {
|
|
3984
|
+
console.log("Injecting modal");
|
|
3985
|
+
this.#injectHTML();
|
|
3986
|
+
}
|
|
3987
|
+
open = () => {
|
|
3988
|
+
console.debug("Modal open");
|
|
3989
|
+
this.#attachEventListeners();
|
|
3990
|
+
if (this.#root) this.#root.style.display = "flex";
|
|
3991
|
+
};
|
|
3992
|
+
close = (event = void 0) => {
|
|
3993
|
+
console.debug("Modal close");
|
|
3994
|
+
this.#removeEventListeners();
|
|
3995
|
+
if (this.#root) this.#root.style.display = "none";
|
|
3996
|
+
this.#eventListeners["close"]?.forEach((listener) => listener(event));
|
|
3997
|
+
};
|
|
3998
|
+
addEventListener(event, listener) {
|
|
3999
|
+
this.#eventListeners[event]?.push(listener) || (this.#eventListeners[event] = [listener]);
|
|
4000
|
+
return () => this.removeEventListener(event, listener);
|
|
4001
|
+
}
|
|
4002
|
+
removeEventListener(event, listener) {
|
|
4003
|
+
this.#eventListeners[event] = this.#eventListeners[event]?.filter((existingListener) => listener !== existingListener);
|
|
4004
|
+
}
|
|
4005
|
+
#injectHTML() {
|
|
4006
|
+
if (this.dom) return;
|
|
4007
|
+
this.#root = document.createElement("div");
|
|
4008
|
+
this.#root.id = "mobile-wallet-adapter-embedded-root-ui";
|
|
4009
|
+
this.#root.innerHTML = modalHtml;
|
|
4010
|
+
this.#root.style.display = "none";
|
|
4011
|
+
const styles = document.createElement("style");
|
|
4012
|
+
styles.id = "mobile-wallet-adapter-embedded-modal-styles";
|
|
4013
|
+
styles.textContent = css$1;
|
|
4014
|
+
const host = document.createElement("div");
|
|
4015
|
+
this.dom = host.attachShadow({ mode: "closed" });
|
|
4016
|
+
host.style.setProperty("--spinner-color", "#FFFFFF");
|
|
4017
|
+
this.dom.appendChild(styles);
|
|
4018
|
+
this.dom.appendChild(this.#root);
|
|
4019
|
+
document.body.appendChild(host);
|
|
4020
|
+
}
|
|
4021
|
+
#attachEventListeners() {
|
|
4022
|
+
if (!this.#root || this.#listenersAttached) return;
|
|
4023
|
+
[...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.addEventListener("click", (event) => {
|
|
4024
|
+
this.close(event);
|
|
4025
|
+
}));
|
|
4026
|
+
window.addEventListener("load", this.close);
|
|
4027
|
+
document.addEventListener("keydown", this.#handleKeyDown);
|
|
4028
|
+
this.#listenersAttached = true;
|
|
4029
|
+
}
|
|
4030
|
+
#removeEventListeners() {
|
|
4031
|
+
if (!this.#listenersAttached) return;
|
|
4032
|
+
window.removeEventListener("load", this.close);
|
|
4033
|
+
document.removeEventListener("keydown", this.#handleKeyDown);
|
|
4034
|
+
if (!this.#root) return;
|
|
4035
|
+
[...this.#root.querySelectorAll("[data-modal-close]")].forEach((closer) => closer?.removeEventListener("click", this.close));
|
|
4036
|
+
this.#listenersAttached = false;
|
|
4037
|
+
}
|
|
4038
|
+
#handleKeyDown = (event) => {
|
|
4039
|
+
if (event.key === "Escape") this.close(event);
|
|
4040
|
+
};
|
|
4041
|
+
};
|
|
4042
|
+
//#endregion
|
|
4043
|
+
//#region src/embedded-modal/remoteConnectionModal.ts
|
|
4044
|
+
var RemoteConnectionModal = class extends EmbeddedModal {
|
|
4045
|
+
contentStyles = css;
|
|
4046
|
+
contentHtml = QRCodeHtml;
|
|
4047
|
+
async initWithQR(qrCode) {
|
|
4048
|
+
super.init();
|
|
4049
|
+
this.populateQRCode(qrCode);
|
|
4050
|
+
}
|
|
4051
|
+
async populateQRCode(qrUrl) {
|
|
4052
|
+
const qrcodeContainer = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-code-container");
|
|
4053
|
+
if (qrcodeContainer) {
|
|
4054
|
+
const qrCodeElement = await QRCode.toCanvas(qrUrl, {
|
|
4055
|
+
width: 200,
|
|
4056
|
+
margin: 0
|
|
4057
|
+
});
|
|
4058
|
+
if (qrcodeContainer.firstElementChild !== null) qrcodeContainer.replaceChild(qrCodeElement, qrcodeContainer.firstElementChild);
|
|
4059
|
+
else qrcodeContainer.appendChild(qrCodeElement);
|
|
4060
|
+
const qrPlaceholder = this.dom?.getElementById("mobile-wallet-adapter-embedded-modal-qr-placeholder");
|
|
4061
|
+
if (qrPlaceholder) qrPlaceholder.style.display = "none";
|
|
4062
|
+
} else console.error("QRCode Container not found");
|
|
4063
|
+
}
|
|
4064
|
+
};
|
|
4065
|
+
const QRCodeHtml = `
|
|
4066
|
+
<div class="mobile-wallet-adapter-embedded-modal-qr-content">
|
|
4067
|
+
<div>
|
|
4068
|
+
<svg class="mobile-wallet-adapter-embedded-modal-icon" width="100%" height="100%">
|
|
4069
|
+
<circle r="52" cx="53" cy="53" fill="#99b3be" stroke="#000000" stroke-width="2"/>
|
|
4070
|
+
<path d="m 53,82.7305 c -3.3116,0 -6.1361,-1.169 -8.4735,-3.507 -2.338,-2.338 -3.507,-5.1625 -3.507,-8.4735 0,-3.3116 1.169,-6.1364 3.507,-8.4744 2.3374,-2.338 5.1619,-3.507 8.4735,-3.507 3.3116,0 6.1361,1.169 8.4735,3.507 2.338,2.338 3.507,5.1628 3.507,8.4744 0,3.311 -1.169,6.1355 -3.507,8.4735 -2.3374,2.338 -5.1619,3.507 -8.4735,3.507 z m 0.007,-5.25 c 1.8532,0 3.437,-0.6598 4.7512,-1.9793 1.3149,-1.3195 1.9723,-2.9058 1.9723,-4.7591 0,-1.8526 -0.6598,-3.4364 -1.9793,-4.7512 -1.3195,-1.3149 -2.9055,-1.9723 -4.7582,-1.9723 -1.8533,0 -3.437,0.6598 -4.7513,1.9793 -1.3148,1.3195 -1.9722,2.9058 -1.9722,4.7591 0,1.8527 0.6597,3.4364 1.9792,4.7512 1.3195,1.3149 2.9056,1.9723 4.7583,1.9723 z m -28,-33.5729 -3.85,-3.6347 c 4.1195,-4.025 8.8792,-7.1984 14.2791,-9.52 5.4005,-2.3223 11.2551,-3.4834 17.5639,-3.4834 6.3087,0 12.1634,1.1611 17.5639,3.4834 5.3999,2.3216 10.1596,5.495 14.2791,9.52 l -3.85,3.6347 C 77.2999,40.358 73.0684,37.5726 68.2985,35.5514 63.5292,33.5301 58.4296,32.5195 53,32.5195 c -5.4297,0 -10.5292,1.0106 -15.2985,3.0319 -4.7699,2.0212 -9.0014,4.8066 -12.6945,8.3562 z m 44.625,10.8771 c -2.2709,-2.1046 -4.7962,-3.7167 -7.5758,-4.8361 -2.7795,-1.12 -5.7983,-1.68 -9.0562,-1.68 -3.2579,0 -6.2621,0.56 -9.0125,1.68 -2.7504,1.1194 -5.2903,2.7315 -7.6195,4.8361 L 32.5189,51.15 c 2.8355,-2.6028 5.9777,-4.6086 9.4263,-6.0174 3.4481,-1.4087 7.133,-2.1131 11.0548,-2.1131 3.9217,0 7.5979,0.7044 11.0285,2.1131 3.43,1.4088 6.5631,3.4146 9.3992,6.0174 z"/>
|
|
4071
|
+
</svg>
|
|
4072
|
+
<div class="mobile-wallet-adapter-embedded-modal-title">Remote Mobile Wallet Adapter</div>
|
|
4073
|
+
</div>
|
|
4074
|
+
<div>
|
|
4075
|
+
<div>
|
|
4076
|
+
<h4 class="mobile-wallet-adapter-embedded-modal-qr-label">
|
|
4077
|
+
Open your wallet and scan this code
|
|
4078
|
+
</h4>
|
|
4079
|
+
</div>
|
|
4080
|
+
<div id="mobile-wallet-adapter-embedded-modal-qr-code-container" class="mobile-wallet-adapter-embedded-modal-qr-code-container">
|
|
4081
|
+
<div id="mobile-wallet-adapter-embedded-modal-qr-placeholder" class="mobile-wallet-adapter-embedded-modal-qr-placeholder"></div>
|
|
4082
|
+
</div>
|
|
4083
|
+
</div>
|
|
4084
|
+
</div>
|
|
4085
|
+
<div class="mobile-wallet-adapter-embedded-modal-divider"><hr></div>
|
|
4086
|
+
<div class="mobile-wallet-adapter-embedded-modal-footer">
|
|
4087
|
+
<div class="mobile-wallet-adapter-embedded-modal-subtitle">
|
|
4088
|
+
Follow the instructions on your device. When you're finished, this screen will update.
|
|
4089
|
+
</div>
|
|
4090
|
+
<div class="mobile-wallet-adapter-embedded-modal-progress-badge">
|
|
4091
|
+
<div>
|
|
4092
|
+
<div class="spinner">
|
|
4093
|
+
<div class="leftWrapper">
|
|
4094
|
+
<div class="left">
|
|
4095
|
+
<div class="circle"></div>
|
|
4096
|
+
</div>
|
|
4097
|
+
</div>
|
|
4098
|
+
<div class="rightWrapper">
|
|
4099
|
+
<div class="right">
|
|
4100
|
+
<div class="circle"></div>
|
|
4101
|
+
</div>
|
|
4102
|
+
</div>
|
|
4103
|
+
</div>
|
|
4104
|
+
</div>
|
|
4105
|
+
<div>Waiting for scan</div>
|
|
4106
|
+
</div>
|
|
4107
|
+
</div>
|
|
4108
|
+
`;
|
|
4109
|
+
const css = `
|
|
4110
|
+
.mobile-wallet-adapter-embedded-modal-qr-content {
|
|
4111
|
+
display: flex;
|
|
4112
|
+
margin-top: 10px;
|
|
4113
|
+
padding: 10px;
|
|
4114
|
+
}
|
|
4115
|
+
|
|
4116
|
+
.mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
|
|
4117
|
+
display: flex;
|
|
4118
|
+
flex-direction: column;
|
|
4119
|
+
flex: 2;
|
|
4120
|
+
margin-top: auto;
|
|
4121
|
+
margin-right: 30px;
|
|
4122
|
+
}
|
|
4123
|
+
|
|
4124
|
+
.mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
|
|
4125
|
+
display: flex;
|
|
4126
|
+
flex-direction: column;
|
|
4127
|
+
flex: 1;
|
|
4128
|
+
margin-left: auto;
|
|
4129
|
+
}
|
|
4130
|
+
|
|
4131
|
+
.mobile-wallet-adapter-embedded-modal-footer {
|
|
4132
|
+
display: flex;
|
|
4133
|
+
padding: 10px;
|
|
4134
|
+
}
|
|
4135
|
+
|
|
4136
|
+
.mobile-wallet-adapter-embedded-modal-icon {}
|
|
4137
|
+
|
|
4138
|
+
.mobile-wallet-adapter-embedded-modal-title {
|
|
4139
|
+
color: #000000;
|
|
4140
|
+
font-size: 2.5em;
|
|
4141
|
+
font-weight: 600;
|
|
4142
|
+
}
|
|
4143
|
+
|
|
4144
|
+
.mobile-wallet-adapter-embedded-modal-qr-label {
|
|
4145
|
+
text-align: right;
|
|
4146
|
+
color: #000000;
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
.mobile-wallet-adapter-embedded-modal-qr-code-container {
|
|
4150
|
+
margin-left: auto;
|
|
4151
|
+
}
|
|
4152
|
+
|
|
4153
|
+
.mobile-wallet-adapter-embedded-modal-qr-placeholder {
|
|
4154
|
+
margin-left: auto;
|
|
4155
|
+
min-width: 200px;
|
|
4156
|
+
min-height: 200px;
|
|
4157
|
+
background: linear-gradient(-60deg, #F7F8F8 30%, #ECEEEE 50%, #F7F8F8 70%);
|
|
4158
|
+
background-size: 200%;
|
|
4159
|
+
animation: placeholderAnimate 2.7s linear infinite;
|
|
4160
|
+
border-radius: 12px;
|
|
4161
|
+
}
|
|
4162
|
+
|
|
4163
|
+
.mobile-wallet-adapter-embedded-modal-divider {
|
|
4164
|
+
margin-top: 20px;
|
|
4165
|
+
padding-left: 10px;
|
|
4166
|
+
padding-right: 10px;
|
|
4167
|
+
}
|
|
4168
|
+
|
|
4169
|
+
.mobile-wallet-adapter-embedded-modal-divider hr {
|
|
4170
|
+
border-top: 1px solid #D9DEDE;
|
|
4171
|
+
}
|
|
4172
|
+
|
|
4173
|
+
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
4174
|
+
margin: auto;
|
|
4175
|
+
margin-right: 60px;
|
|
4176
|
+
padding: 20px;
|
|
4177
|
+
color: #6E8286;
|
|
4178
|
+
}
|
|
4179
|
+
|
|
4180
|
+
.mobile-wallet-adapter-embedded-modal-progress-badge {
|
|
4181
|
+
display: flex;
|
|
4182
|
+
background: #F7F8F8;
|
|
4183
|
+
height: 56px;
|
|
4184
|
+
min-width: 200px;
|
|
4185
|
+
margin: auto;
|
|
4186
|
+
padding-left: 20px;
|
|
4187
|
+
padding-right: 20px;
|
|
4188
|
+
border-radius: 18px;
|
|
4189
|
+
color: #A8B6B8;
|
|
4190
|
+
align-items: center;
|
|
4191
|
+
}
|
|
4192
|
+
|
|
4193
|
+
.mobile-wallet-adapter-embedded-modal-progress-badge > div:first-child {
|
|
4194
|
+
margin-left: auto;
|
|
4195
|
+
margin-right: 20px;
|
|
4196
|
+
}
|
|
4197
|
+
|
|
4198
|
+
.mobile-wallet-adapter-embedded-modal-progress-badge > div:nth-child(2) {
|
|
4199
|
+
margin-right: auto;
|
|
4200
|
+
}
|
|
4201
|
+
|
|
4202
|
+
/* Smaller screens */
|
|
4203
|
+
@media all and (max-width: 600px) {
|
|
4204
|
+
.mobile-wallet-adapter-embedded-modal-card {
|
|
4205
|
+
text-align: center;
|
|
4206
|
+
}
|
|
4207
|
+
.mobile-wallet-adapter-embedded-modal-qr-content {
|
|
4208
|
+
flex-direction: column;
|
|
4209
|
+
}
|
|
4210
|
+
.mobile-wallet-adapter-embedded-modal-qr-content > div:first-child {
|
|
4211
|
+
margin: auto;
|
|
4212
|
+
}
|
|
4213
|
+
.mobile-wallet-adapter-embedded-modal-qr-content > div:nth-child(2) {
|
|
4214
|
+
margin: auto;
|
|
4215
|
+
flex: 2 auto;
|
|
4216
|
+
}
|
|
4217
|
+
.mobile-wallet-adapter-embedded-modal-footer {
|
|
4218
|
+
flex-direction: column;
|
|
4219
|
+
}
|
|
4220
|
+
.mobile-wallet-adapter-embedded-modal-icon {
|
|
4221
|
+
display: none;
|
|
4222
|
+
}
|
|
4223
|
+
.mobile-wallet-adapter-embedded-modal-title {
|
|
4224
|
+
font-size: 1.5em;
|
|
4225
|
+
}
|
|
4226
|
+
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
4227
|
+
margin-right: unset;
|
|
4228
|
+
}
|
|
4229
|
+
.mobile-wallet-adapter-embedded-modal-qr-label {
|
|
4230
|
+
text-align: center;
|
|
4231
|
+
}
|
|
4232
|
+
.mobile-wallet-adapter-embedded-modal-qr-code-container {
|
|
4233
|
+
margin: auto;
|
|
4234
|
+
}
|
|
4235
|
+
.mobile-wallet-adapter-embedded-modal-qr-placeholder {
|
|
4236
|
+
margin: auto;
|
|
4237
|
+
}
|
|
4238
|
+
}
|
|
4239
|
+
|
|
4240
|
+
/* QR Placeholder */
|
|
4241
|
+
@keyframes placeholderAnimate {
|
|
4242
|
+
0% { background-position: 200% 0; }
|
|
4243
|
+
100% { background-position: -200% 0; }
|
|
4244
|
+
}
|
|
4245
|
+
|
|
4246
|
+
/* Spinner */
|
|
4247
|
+
@keyframes spinLeft {
|
|
4248
|
+
0% {
|
|
4249
|
+
transform: rotate(20deg);
|
|
4250
|
+
}
|
|
4251
|
+
50% {
|
|
4252
|
+
transform: rotate(160deg);
|
|
4253
|
+
}
|
|
4254
|
+
100% {
|
|
4255
|
+
transform: rotate(20deg);
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4258
|
+
@keyframes spinRight {
|
|
4259
|
+
0% {
|
|
4260
|
+
transform: rotate(160deg);
|
|
4261
|
+
}
|
|
4262
|
+
50% {
|
|
4263
|
+
transform: rotate(20deg);
|
|
4264
|
+
}
|
|
4265
|
+
100% {
|
|
4266
|
+
transform: rotate(160deg);
|
|
4267
|
+
}
|
|
4268
|
+
}
|
|
4269
|
+
@keyframes spin {
|
|
4270
|
+
0% {
|
|
4271
|
+
transform: rotate(0deg);
|
|
4272
|
+
}
|
|
4273
|
+
100% {
|
|
4274
|
+
transform: rotate(2520deg);
|
|
4275
|
+
}
|
|
4276
|
+
}
|
|
4277
|
+
|
|
4278
|
+
.spinner {
|
|
4279
|
+
position: relative;
|
|
4280
|
+
width: 1.5em;
|
|
4281
|
+
height: 1.5em;
|
|
4282
|
+
margin: auto;
|
|
4283
|
+
animation: spin 10s linear infinite;
|
|
4284
|
+
}
|
|
4285
|
+
.spinner::before {
|
|
4286
|
+
content: "";
|
|
4287
|
+
position: absolute;
|
|
4288
|
+
top: 0;
|
|
4289
|
+
bottom: 0;
|
|
4290
|
+
left: 0;
|
|
4291
|
+
right: 0;
|
|
4106
4292
|
}
|
|
4107
|
-
|
|
4108
|
-
|
|
4293
|
+
.right, .rightWrapper, .left, .leftWrapper {
|
|
4294
|
+
position: absolute;
|
|
4295
|
+
top: 0;
|
|
4296
|
+
overflow: hidden;
|
|
4297
|
+
width: .75em;
|
|
4298
|
+
height: 1.5em;
|
|
4109
4299
|
}
|
|
4110
|
-
|
|
4111
|
-
|
|
4300
|
+
.left, .leftWrapper {
|
|
4301
|
+
left: 0;
|
|
4112
4302
|
}
|
|
4113
|
-
|
|
4114
|
-
|
|
4303
|
+
.right {
|
|
4304
|
+
left: -12px;
|
|
4115
4305
|
}
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
if (typeof window == "undefined") return isAndroidTwa;
|
|
4119
|
-
const isStandalone = window.matchMedia("(display-mode: standalone)").matches;
|
|
4120
|
-
const isFullscreen = window.matchMedia("(display-mode: fullscreen)").matches;
|
|
4121
|
-
const isMinimalUI = window.matchMedia("(display-mode: minimal-ui)").matches;
|
|
4122
|
-
return isAndroidTwa || isStandalone || isFullscreen || isMinimalUI;
|
|
4306
|
+
.rightWrapper {
|
|
4307
|
+
right: 0;
|
|
4123
4308
|
}
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4133
|
-
throw new mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError(mobileWalletAdapterProtocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission denied");
|
|
4134
|
-
} else if (lnaPermission.state === "prompt") {
|
|
4135
|
-
const modal = new LoopbackPermissionModal();
|
|
4136
|
-
if (await new Promise((resolve, reject) => {
|
|
4137
|
-
modal.addEventListener("close", (event) => {
|
|
4138
|
-
if (event) reject(new mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError(mobileWalletAdapterProtocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
|
|
4139
|
-
});
|
|
4140
|
-
lnaPermission.onchange = () => {
|
|
4141
|
-
lnaPermission.onchange = null;
|
|
4142
|
-
resolve(lnaPermission.state);
|
|
4143
|
-
};
|
|
4144
|
-
modal.init();
|
|
4145
|
-
modal.open();
|
|
4146
|
-
}) === "granted") {
|
|
4147
|
-
const modal = new LocalConnectionModal();
|
|
4148
|
-
await new Promise((resolve, reject) => {
|
|
4149
|
-
modal.addEventListener("close", (event) => {
|
|
4150
|
-
if (event) reject(new mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError(mobileWalletAdapterProtocol.SolanaMobileWalletAdapterErrorCode.ERROR_ASSOCIATION_CANCELLED, "Wallet connection cancelled by user", { event }));
|
|
4151
|
-
});
|
|
4152
|
-
modal.initWithCallback(async () => {
|
|
4153
|
-
resolve(true);
|
|
4154
|
-
});
|
|
4155
|
-
modal.open();
|
|
4156
|
-
});
|
|
4157
|
-
return;
|
|
4158
|
-
} else return await checkLocalNetworkAccessPermission();
|
|
4159
|
-
}
|
|
4160
|
-
throw new mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError(mobileWalletAdapterProtocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, "Local Network Access permission unknown");
|
|
4161
|
-
} catch (e) {
|
|
4162
|
-
if (e instanceof TypeError && (e.message.includes("loopback-network") || e.message.includes("local-network-access"))) return;
|
|
4163
|
-
if (e instanceof mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError) throw e;
|
|
4164
|
-
throw new mobileWalletAdapterProtocol.SolanaMobileWalletAdapterError(mobileWalletAdapterProtocol.SolanaMobileWalletAdapterErrorCode.ERROR_LOOPBACK_ACCESS_BLOCKED, e instanceof Error ? e.message : "Local Network Access permission unknown");
|
|
4165
|
-
}
|
|
4309
|
+
.circle {
|
|
4310
|
+
border: .125em solid #A8B6B8;
|
|
4311
|
+
width: 1.25em; /* 1.5em - 2*0.125em border */
|
|
4312
|
+
height: 1.25em; /* 1.5em - 2*0.125em border */
|
|
4313
|
+
border-radius: 0.75em; /* 0.5*1.5em spinner size 8 */
|
|
4314
|
+
}
|
|
4315
|
+
.left {
|
|
4316
|
+
transform-origin: 100% 50%;
|
|
4317
|
+
animation: spinLeft 2.5s cubic-bezier(.2,0,.8,1) infinite;
|
|
4166
4318
|
}
|
|
4319
|
+
.right {
|
|
4320
|
+
transform-origin: 100% 50%;
|
|
4321
|
+
animation: spinRight 2.5s cubic-bezier(.2,0,.8,1) infinite;
|
|
4322
|
+
}
|
|
4323
|
+
`;
|
|
4167
4324
|
//#endregion
|
|
4168
4325
|
//#region src/icon.ts
|
|
4169
4326
|
const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik03IDIuNUgxN0MxNy44Mjg0IDIuNSAxOC41IDMuMTcxNTcgMTguNSA0VjIwQzE4LjUgMjAuODI4NCAxNy44Mjg0IDIxLjUgMTcgMjEuNUg3QzYuMTcxNTcgMjEuNSA1LjUgMjAuODI4NCA1LjUgMjBWNEM1LjUgMy4xNzE1NyA2LjE3MTU3IDIuNSA3IDIuNVpNMyA0QzMgMS43OTA4NiA0Ljc5MDg2IDAgNyAwSDE3QzE5LjIwOTEgMCAyMSAxLjc5MDg2IDIxIDRWMjBDMjEgMjIuMjA5MSAxOS4yMDkxIDI0IDE3IDI0SDdDNC43OTA4NiAyNCAzIDIyLjIwOTEgMyAyMFY0Wk0xMSA0LjYxNTM4QzEwLjQ0NzcgNC42MTUzOCAxMCA1LjA2MzEgMTAgNS42MTUzOFY2LjM4NDYyQzEwIDYuOTM2OSAxMC40NDc3IDcuMzg0NjIgMTEgNy4zODQ2MkgxM0MxMy41NTIzIDcuMzg0NjIgMTQgNi45MzY5IDE0IDYuMzg0NjJWNS42MTUzOEMxNCA1LjA2MzEgMTMuNTUyMyA0LjYxNTM4IDEzIDQuNjE1MzhIMTFaIiBmaWxsPSIjRENCOEZGIi8+Cjwvc3ZnPgo=";
|
|
@@ -4429,9 +4586,9 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
4429
4586
|
};
|
|
4430
4587
|
#accountsToWalletStandardAccounts = (accounts) => {
|
|
4431
4588
|
return accounts.map((account) => {
|
|
4432
|
-
const publicKey =
|
|
4589
|
+
const publicKey = encoding.base64ToUint8Array(account.address);
|
|
4433
4590
|
return {
|
|
4434
|
-
address:
|
|
4591
|
+
address: encoding.base58FromUint8Array(publicKey),
|
|
4435
4592
|
publicKey,
|
|
4436
4593
|
label: account.label,
|
|
4437
4594
|
icon: account.icon,
|
|
@@ -4444,11 +4601,11 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
4444
4601
|
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4445
4602
|
try {
|
|
4446
4603
|
const base64Transactions = transactions.map((tx) => {
|
|
4447
|
-
return
|
|
4604
|
+
return encoding.base64FromUint8Array(tx);
|
|
4448
4605
|
});
|
|
4449
4606
|
return await this.#transact(async (wallet) => {
|
|
4450
4607
|
await this.#performReauthorization(wallet, authToken, chain);
|
|
4451
|
-
return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(
|
|
4608
|
+
return (await wallet.signTransactions({ payloads: base64Transactions })).signed_payloads.map(encoding.base64ToUint8Array);
|
|
4452
4609
|
});
|
|
4453
4610
|
} catch (e) {
|
|
4454
4611
|
throw new Error(getErrorMessage(e), { cause: e });
|
|
@@ -4460,11 +4617,11 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
4460
4617
|
return await this.#transact(async (wallet) => {
|
|
4461
4618
|
const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
|
|
4462
4619
|
if (capabilities.supports_sign_and_send_transactions) {
|
|
4463
|
-
const base64Transaction =
|
|
4620
|
+
const base64Transaction = encoding.base64FromUint8Array(transaction);
|
|
4464
4621
|
return (await wallet.signAndSendTransactions({
|
|
4465
4622
|
...options,
|
|
4466
4623
|
payloads: [base64Transaction]
|
|
4467
|
-
})).signatures.map(
|
|
4624
|
+
})).signatures.map(encoding.base64ToUint8Array)[0];
|
|
4468
4625
|
} else throw new Error("connected wallet does not support signAndSendTransaction");
|
|
4469
4626
|
});
|
|
4470
4627
|
} catch (e) {
|
|
@@ -4486,15 +4643,15 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
4486
4643
|
};
|
|
4487
4644
|
#signMessage = async (...inputs) => {
|
|
4488
4645
|
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4489
|
-
const addresses = inputs.map(({ account }) =>
|
|
4490
|
-
const messages = inputs.map(({ message }) =>
|
|
4646
|
+
const addresses = inputs.map(({ account }) => encoding.base64FromUint8Array(new Uint8Array(account.publicKey)));
|
|
4647
|
+
const messages = inputs.map(({ message }) => encoding.base64FromUint8Array(message));
|
|
4491
4648
|
try {
|
|
4492
4649
|
return await this.#transact(async (wallet) => {
|
|
4493
4650
|
await this.#performReauthorization(wallet, authToken, chain);
|
|
4494
4651
|
return (await wallet.signMessages({
|
|
4495
4652
|
addresses,
|
|
4496
4653
|
payloads: messages
|
|
4497
|
-
})).signed_payloads.map(
|
|
4654
|
+
})).signed_payloads.map(encoding.base64ToUint8Array).map((signedMessage) => {
|
|
4498
4655
|
return {
|
|
4499
4656
|
signedMessage,
|
|
4500
4657
|
signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
|
|
@@ -4523,13 +4680,13 @@ var LocalSolanaMobileWalletAdapterWallet = class {
|
|
|
4523
4680
|
const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
|
|
4524
4681
|
return {
|
|
4525
4682
|
account: {
|
|
4526
|
-
...signedInAccount ?? { address:
|
|
4527
|
-
publicKey:
|
|
4683
|
+
...signedInAccount ?? { address: encoding.base58FromUint8Array(encoding.base64ToUint8Array(signedInAddress)) },
|
|
4684
|
+
publicKey: encoding.base64ToUint8Array(signedInAddress),
|
|
4528
4685
|
chains: signedInAccount?.chains ?? this.#chains,
|
|
4529
4686
|
features: signedInAccount?.features ?? authorizationResult.capabilities.features
|
|
4530
4687
|
},
|
|
4531
|
-
signedMessage:
|
|
4532
|
-
signature:
|
|
4688
|
+
signedMessage: encoding.base64ToUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
4689
|
+
signature: encoding.base64ToUint8Array(authorizationResult.sign_in_result.signature)
|
|
4533
4690
|
};
|
|
4534
4691
|
} catch (e) {
|
|
4535
4692
|
throw new Error(getErrorMessage(e), { cause: e });
|
|
@@ -4782,9 +4939,9 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
4782
4939
|
};
|
|
4783
4940
|
#accountsToWalletStandardAccounts = (accounts) => {
|
|
4784
4941
|
return accounts.map((account) => {
|
|
4785
|
-
const publicKey =
|
|
4942
|
+
const publicKey = encoding.base64ToUint8Array(account.address);
|
|
4786
4943
|
return {
|
|
4787
|
-
address:
|
|
4944
|
+
address: encoding.base58FromUint8Array(publicKey),
|
|
4788
4945
|
publicKey,
|
|
4789
4946
|
label: account.label,
|
|
4790
4947
|
icon: account.icon,
|
|
@@ -4798,7 +4955,7 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
4798
4955
|
try {
|
|
4799
4956
|
return await this.#transact(async (wallet) => {
|
|
4800
4957
|
await this.#performReauthorization(wallet, authToken, chain);
|
|
4801
|
-
return (await wallet.signTransactions({ payloads: transactions.map(
|
|
4958
|
+
return (await wallet.signTransactions({ payloads: transactions.map(encoding.base64FromUint8Array) })).signed_payloads.map(encoding.base64ToUint8Array);
|
|
4802
4959
|
});
|
|
4803
4960
|
} catch (e) {
|
|
4804
4961
|
throw new Error(getErrorMessage(e), { cause: e });
|
|
@@ -4811,8 +4968,8 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
4811
4968
|
const [capabilities] = await Promise.all([wallet.getCapabilities(), this.#performReauthorization(wallet, authToken, chain)]);
|
|
4812
4969
|
if (capabilities.supports_sign_and_send_transactions) return (await wallet.signAndSendTransactions({
|
|
4813
4970
|
...options,
|
|
4814
|
-
payloads: [
|
|
4815
|
-
})).signatures.map(
|
|
4971
|
+
payloads: [encoding.base64FromUint8Array(transaction)]
|
|
4972
|
+
})).signatures.map(encoding.base64ToUint8Array)[0];
|
|
4816
4973
|
else throw new Error("connected wallet does not support signAndSendTransaction");
|
|
4817
4974
|
});
|
|
4818
4975
|
} catch (e) {
|
|
@@ -4834,15 +4991,15 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
4834
4991
|
};
|
|
4835
4992
|
#signMessage = async (...inputs) => {
|
|
4836
4993
|
const { authToken, chain } = this.#assertIsAuthorized();
|
|
4837
|
-
const addresses = inputs.map(({ account }) =>
|
|
4838
|
-
const messages = inputs.map(({ message }) =>
|
|
4994
|
+
const addresses = inputs.map(({ account }) => encoding.base64FromUint8Array(new Uint8Array(account.publicKey)));
|
|
4995
|
+
const messages = inputs.map(({ message }) => encoding.base64FromUint8Array(message));
|
|
4839
4996
|
try {
|
|
4840
4997
|
return await this.#transact(async (wallet) => {
|
|
4841
4998
|
await this.#performReauthorization(wallet, authToken, chain);
|
|
4842
4999
|
return (await wallet.signMessages({
|
|
4843
5000
|
addresses,
|
|
4844
5001
|
payloads: messages
|
|
4845
|
-
})).signed_payloads.map(
|
|
5002
|
+
})).signed_payloads.map(encoding.base64ToUint8Array).map((signedMessage) => {
|
|
4846
5003
|
return {
|
|
4847
5004
|
signedMessage,
|
|
4848
5005
|
signature: signedMessage.slice(-SIGNATURE_LENGTH_IN_BYTES)
|
|
@@ -4871,13 +5028,13 @@ var RemoteSolanaMobileWalletAdapterWallet = class {
|
|
|
4871
5028
|
const signedInAccount = authorizationResult.accounts.find((acc) => acc.address == signedInAddress);
|
|
4872
5029
|
return {
|
|
4873
5030
|
account: {
|
|
4874
|
-
...signedInAccount ?? { address:
|
|
4875
|
-
publicKey:
|
|
5031
|
+
...signedInAccount ?? { address: encoding.base58FromUint8Array(encoding.base64ToUint8Array(signedInAddress)) },
|
|
5032
|
+
publicKey: encoding.base64ToUint8Array(signedInAddress),
|
|
4876
5033
|
chains: signedInAccount?.chains ?? this.#chains,
|
|
4877
5034
|
features: signedInAccount?.features ?? authorizationResult.capabilities.features
|
|
4878
5035
|
},
|
|
4879
|
-
signedMessage:
|
|
4880
|
-
signature:
|
|
5036
|
+
signedMessage: encoding.base64ToUint8Array(authorizationResult.sign_in_result.signed_message),
|
|
5037
|
+
signature: encoding.base64ToUint8Array(authorizationResult.sign_in_result.signature)
|
|
4881
5038
|
};
|
|
4882
5039
|
} catch (e) {
|
|
4883
5040
|
throw new Error(getErrorMessage(e), { cause: e });
|
|
@@ -4904,170 +5061,6 @@ function registerMwa(config) {
|
|
|
4904
5061
|
remoteHostAuthority: config.remoteHostAuthority
|
|
4905
5062
|
}));
|
|
4906
5063
|
}
|
|
4907
|
-
//#endregion
|
|
4908
|
-
//#region src/embedded-modal/errorModal.ts
|
|
4909
|
-
const WALLET_NOT_FOUND_ERROR_MESSAGE = "To use mobile wallet adapter, you must have a compatible mobile wallet application installed on your device.";
|
|
4910
|
-
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.";
|
|
4911
|
-
var ErrorModal = class extends EmbeddedModal {
|
|
4912
|
-
contentStyles = css;
|
|
4913
|
-
contentHtml = ErrorDialogHtml;
|
|
4914
|
-
initWithError(error) {
|
|
4915
|
-
super.init();
|
|
4916
|
-
this.populateError(error);
|
|
4917
|
-
}
|
|
4918
|
-
populateError(error) {
|
|
4919
|
-
const errorMessageElement = this.dom?.getElementById("mobile-wallet-adapter-error-message");
|
|
4920
|
-
const actionBtn = this.dom?.getElementById("mobile-wallet-adapter-error-action");
|
|
4921
|
-
if (errorMessageElement) {
|
|
4922
|
-
if (error.name === "SolanaMobileWalletAdapterError") switch (error.code) {
|
|
4923
|
-
case "ERROR_WALLET_NOT_FOUND":
|
|
4924
|
-
errorMessageElement.innerHTML = WALLET_NOT_FOUND_ERROR_MESSAGE;
|
|
4925
|
-
if (actionBtn) actionBtn.addEventListener("click", () => {
|
|
4926
|
-
window.location.href = "https://solanamobile.com/wallets";
|
|
4927
|
-
});
|
|
4928
|
-
return;
|
|
4929
|
-
case "ERROR_BROWSER_NOT_SUPPORTED":
|
|
4930
|
-
errorMessageElement.innerHTML = BROWSER_NOT_SUPPORTED_ERROR_MESSAGE;
|
|
4931
|
-
if (actionBtn) actionBtn.style.display = "none";
|
|
4932
|
-
return;
|
|
4933
|
-
}
|
|
4934
|
-
errorMessageElement.innerHTML = `An unexpected error occurred: ${error.message}`;
|
|
4935
|
-
} else console.log("Failed to locate error dialog element");
|
|
4936
|
-
}
|
|
4937
|
-
};
|
|
4938
|
-
const ErrorDialogHtml = `
|
|
4939
|
-
<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>
|
|
4940
|
-
<div class="mobile-wallet-adapter-embedded-modal-title">We can't find a wallet.</div>
|
|
4941
|
-
<div id="mobile-wallet-adapter-error-message" class="mobile-wallet-adapter-embedded-modal-subtitle"></div>
|
|
4942
|
-
<div>
|
|
4943
|
-
<button data-error-action id="mobile-wallet-adapter-error-action" class="mobile-wallet-adapter-embedded-modal-error-action">
|
|
4944
|
-
Find a wallet
|
|
4945
|
-
</button>
|
|
4946
|
-
</div>
|
|
4947
|
-
`;
|
|
4948
|
-
const css = `
|
|
4949
|
-
.mobile-wallet-adapter-embedded-modal-content {
|
|
4950
|
-
text-align: center;
|
|
4951
|
-
}
|
|
4952
|
-
|
|
4953
|
-
.mobile-wallet-adapter-embedded-modal-error-icon {
|
|
4954
|
-
margin-top: 24px;
|
|
4955
|
-
}
|
|
4956
|
-
|
|
4957
|
-
.mobile-wallet-adapter-embedded-modal-title {
|
|
4958
|
-
margin: 18px 100px auto 100px;
|
|
4959
|
-
color: #000000;
|
|
4960
|
-
font-size: 2.75em;
|
|
4961
|
-
font-weight: 600;
|
|
4962
|
-
}
|
|
4963
|
-
|
|
4964
|
-
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
4965
|
-
margin: 30px 60px 40px 60px;
|
|
4966
|
-
color: #000000;
|
|
4967
|
-
font-size: 1.25em;
|
|
4968
|
-
font-weight: 400;
|
|
4969
|
-
}
|
|
4970
|
-
|
|
4971
|
-
.mobile-wallet-adapter-embedded-modal-error-action {
|
|
4972
|
-
display: block;
|
|
4973
|
-
width: 100%;
|
|
4974
|
-
height: 56px;
|
|
4975
|
-
/*margin-top: 40px;*/
|
|
4976
|
-
font-size: 1.25em;
|
|
4977
|
-
/*line-height: 24px;*/
|
|
4978
|
-
/*letter-spacing: -1%;*/
|
|
4979
|
-
background: #000000;
|
|
4980
|
-
color: #FFFFFF;
|
|
4981
|
-
border-radius: 18px;
|
|
4982
|
-
}
|
|
4983
|
-
|
|
4984
|
-
/* Smaller screens */
|
|
4985
|
-
@media all and (max-width: 600px) {
|
|
4986
|
-
.mobile-wallet-adapter-embedded-modal-title {
|
|
4987
|
-
font-size: 1.5em;
|
|
4988
|
-
margin-right: 12px;
|
|
4989
|
-
margin-left: 12px;
|
|
4990
|
-
}
|
|
4991
|
-
.mobile-wallet-adapter-embedded-modal-subtitle {
|
|
4992
|
-
margin-right: 12px;
|
|
4993
|
-
margin-left: 12px;
|
|
4994
|
-
}
|
|
4995
|
-
}
|
|
4996
|
-
`;
|
|
4997
|
-
//#endregion
|
|
4998
|
-
//#region src/createDefaultWalletNotFoundHandler.ts
|
|
4999
|
-
async function defaultErrorModalWalletNotFoundHandler() {
|
|
5000
|
-
if (typeof window !== "undefined") {
|
|
5001
|
-
const userAgent = window.navigator.userAgent.toLowerCase();
|
|
5002
|
-
const errorDialog = new ErrorModal();
|
|
5003
|
-
if (userAgent.includes("wv")) errorDialog.initWithError({
|
|
5004
|
-
name: "SolanaMobileWalletAdapterError",
|
|
5005
|
-
code: "ERROR_BROWSER_NOT_SUPPORTED",
|
|
5006
|
-
message: ""
|
|
5007
|
-
});
|
|
5008
|
-
else errorDialog.initWithError({
|
|
5009
|
-
name: "SolanaMobileWalletAdapterError",
|
|
5010
|
-
code: "ERROR_WALLET_NOT_FOUND",
|
|
5011
|
-
message: ""
|
|
5012
|
-
});
|
|
5013
|
-
errorDialog.open();
|
|
5014
|
-
}
|
|
5015
|
-
}
|
|
5016
|
-
function createDefaultWalletNotFoundHandler() {
|
|
5017
|
-
return async () => {
|
|
5018
|
-
defaultErrorModalWalletNotFoundHandler();
|
|
5019
|
-
};
|
|
5020
|
-
}
|
|
5021
|
-
//#endregion
|
|
5022
|
-
//#region src/createDefaultAuthorizationCache.ts
|
|
5023
|
-
const CACHE_KEY = "SolanaMobileWalletAdapterDefaultAuthorizationCache";
|
|
5024
|
-
function createDefaultAuthorizationCache() {
|
|
5025
|
-
let storage;
|
|
5026
|
-
try {
|
|
5027
|
-
storage = window.localStorage;
|
|
5028
|
-
} catch {}
|
|
5029
|
-
return {
|
|
5030
|
-
async clear() {
|
|
5031
|
-
if (!storage) return;
|
|
5032
|
-
try {
|
|
5033
|
-
storage.removeItem(CACHE_KEY);
|
|
5034
|
-
} catch {}
|
|
5035
|
-
},
|
|
5036
|
-
async get() {
|
|
5037
|
-
if (!storage) return;
|
|
5038
|
-
try {
|
|
5039
|
-
const parsed = JSON.parse(storage.getItem(CACHE_KEY));
|
|
5040
|
-
if (parsed && parsed.accounts) {
|
|
5041
|
-
const parsedAccounts = parsed.accounts.map((account) => {
|
|
5042
|
-
return {
|
|
5043
|
-
...account,
|
|
5044
|
-
publicKey: "publicKey" in account ? new Uint8Array(Object.values(account.publicKey)) : index.base58.decode(account.address)
|
|
5045
|
-
};
|
|
5046
|
-
});
|
|
5047
|
-
return {
|
|
5048
|
-
...parsed,
|
|
5049
|
-
accounts: parsedAccounts
|
|
5050
|
-
};
|
|
5051
|
-
} else return parsed || void 0;
|
|
5052
|
-
} catch {}
|
|
5053
|
-
},
|
|
5054
|
-
async set(authorization) {
|
|
5055
|
-
if (!storage) return;
|
|
5056
|
-
try {
|
|
5057
|
-
storage.setItem(CACHE_KEY, JSON.stringify(authorization));
|
|
5058
|
-
} catch {}
|
|
5059
|
-
}
|
|
5060
|
-
};
|
|
5061
|
-
}
|
|
5062
|
-
//#endregion
|
|
5063
|
-
//#region src/createDefaultChainSelector.ts
|
|
5064
|
-
function createDefaultChainSelector() {
|
|
5065
|
-
return { async select(chains) {
|
|
5066
|
-
if (chains.length === 1) return chains[0];
|
|
5067
|
-
else if (chains.includes(SOLANA_MAINNET_CHAIN)) return SOLANA_MAINNET_CHAIN;
|
|
5068
|
-
else return chains[0];
|
|
5069
|
-
} };
|
|
5070
|
-
}
|
|
5071
5064
|
|
|
5072
5065
|
exports.LocalSolanaMobileWalletAdapterWallet = LocalSolanaMobileWalletAdapterWallet;
|
|
5073
5066
|
exports.RemoteSolanaMobileWalletAdapterWallet = RemoteSolanaMobileWalletAdapterWallet;
|
|
@@ -5078,4 +5071,4 @@ exports.createDefaultChainSelector = createDefaultChainSelector;
|
|
|
5078
5071
|
exports.createDefaultWalletNotFoundHandler = createDefaultWalletNotFoundHandler;
|
|
5079
5072
|
exports.defaultErrorModalWalletNotFoundHandler = defaultErrorModalWalletNotFoundHandler;
|
|
5080
5073
|
exports.registerMwa = registerMwa;
|
|
5081
|
-
//# sourceMappingURL=index.browser-
|
|
5074
|
+
//# sourceMappingURL=index.browser-BTJZmhY1.js.map
|