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