@eos3/connect 0.2.0 → 0.2.2
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/README.md +0 -1
- package/dist/index.d.ts +1 -4
- package/dist/index.js +7 -52
- package/dist/ui.js +160 -20
- package/package.json +1 -1
- package/styles.css +65 -0
package/README.md
CHANGED
|
@@ -286,7 +286,6 @@ await fetch('https://wallet.example.com/api/market/push', {
|
|
|
286
286
|
- `client.getWalletView()`: returns the current wallet ViewModel for app UIs.
|
|
287
287
|
- `checkEosConnectTelegramPayStorage(app)`: initializes Telegram biometrics and returns secure storage diagnostics.
|
|
288
288
|
- `client.connectTelegram(options)`: starts or resumes Telegram binding.
|
|
289
|
-
- `client.connectTokenPocket(options)`: starts TokenPocket binding.
|
|
290
289
|
- `client.startTelegramWalletFlow(options)`: runs the high-level Telegram wallet setup flow from SDK-owned UI.
|
|
291
290
|
- `client.enableQuickPay()`: opens the SDK-owned `<eos-connect-modal>` and returns current quick payment readiness.
|
|
292
291
|
- `client.pay(options)`: builds, signs, confirms, and pushes a paylimit payment.
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { EosConnectError, isEosConnectError, normalizeEosConnectError, type EosC
|
|
|
4
4
|
export { EOS_CONNECT_TELEGRAM_WEB_APP_SDK_URL, getEosConnectTelegramWebApp, loadEosConnectTelegramWebAppSdk, type EosConnectTelegramWebApp } from './telegram-web-app.js';
|
|
5
5
|
export * from './shared/index.js';
|
|
6
6
|
export * from './ui.js';
|
|
7
|
-
export type EosConnectProviderId = 'telegram'
|
|
7
|
+
export type EosConnectProviderId = 'telegram';
|
|
8
8
|
export type EosConnectProviderState = 'available' | 'coming_soon' | 'disabled';
|
|
9
9
|
export type EosConnectStatus = 'idle' | 'not_connected' | 'pending' | 'connected' | 'unsupported' | 'error';
|
|
10
10
|
export type EosConnectNetwork = 'testnet' | 'mainnet';
|
|
@@ -72,7 +72,6 @@ export interface EosConnectOptions {
|
|
|
72
72
|
network?: EosConnectNetwork;
|
|
73
73
|
apiBaseUrl?: string;
|
|
74
74
|
botUsername?: string;
|
|
75
|
-
tokenPocketSource?: string;
|
|
76
75
|
deviceLabel?: string;
|
|
77
76
|
locale?: string;
|
|
78
77
|
messages?: EosConnectMessages;
|
|
@@ -139,7 +138,6 @@ export interface EosConnectClient {
|
|
|
139
138
|
getWalletView(): Promise<EosConnectWalletView>;
|
|
140
139
|
connect(options: EosConnectConnectOptions): Promise<EosConnectState>;
|
|
141
140
|
connectTelegram(options?: EosConnectTelegramOptions): Promise<EosConnectState>;
|
|
142
|
-
connectTokenPocket(options?: EosConnectTelegramOptions): Promise<EosConnectState>;
|
|
143
141
|
startTelegramWalletFlow(options?: EosConnectWalletFlowOptions): Promise<EosConnectWalletView>;
|
|
144
142
|
enableQuickPay(): Promise<EosConnectQuickPayStatus>;
|
|
145
143
|
pay(options: EosConnectPayOptions): Promise<EosConnectPayResult>;
|
|
@@ -233,7 +231,6 @@ export declare function checkEosConnectTelegramPayStorage(app: EosConnectTelegra
|
|
|
233
231
|
export declare function initEosConnectTelegramBiometricManager(app: EosConnectTelegramWebApp, timeoutMs?: number): Promise<boolean>;
|
|
234
232
|
export declare function openEosConnectTelegramBiometricSettings(app: EosConnectTelegramWebApp): Promise<EosConnectTelegramBiometricSettingsResult>;
|
|
235
233
|
export declare function eosConnectWalletSetupState(wallet: EosConnectWalletInfo, env?: EosConnectWalletSetupEnv): EosConnectWalletSetupState;
|
|
236
|
-
export declare function tokenPocketDappUrl(url: string, source?: string): string;
|
|
237
234
|
export declare function generateEosConnectPaymentKey(): Promise<{
|
|
238
235
|
privateKey: string;
|
|
239
236
|
publicKey: string;
|
package/dist/index.js
CHANGED
|
@@ -56,18 +56,6 @@ const providers = [
|
|
|
56
56
|
name: 'Telegram secure binding',
|
|
57
57
|
state: 'available',
|
|
58
58
|
description: 'Create or connect an EOS wallet through Telegram SecureStorage and passkeys.'
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
id: 'tokenpocket',
|
|
62
|
-
name: 'TokenPocket',
|
|
63
|
-
state: 'available',
|
|
64
|
-
description: 'Open TokenPocket and bind an existing EOS wallet to Telegram payments.'
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
id: 'anchor',
|
|
68
|
-
name: 'Anchor',
|
|
69
|
-
state: 'coming_soon',
|
|
70
|
-
description: 'Anchor connection is reserved for a later wallet adapter.'
|
|
71
59
|
}
|
|
72
60
|
];
|
|
73
61
|
const idleState = {
|
|
@@ -82,9 +70,6 @@ const idleState = {
|
|
|
82
70
|
function normalizeBaseUrl(apiBaseUrl) {
|
|
83
71
|
return apiBaseUrl.replace(/\/+$/, '');
|
|
84
72
|
}
|
|
85
|
-
function providerDisplayName(provider) {
|
|
86
|
-
return providers.find((item) => item.id === provider)?.name ?? provider;
|
|
87
|
-
}
|
|
88
73
|
function titleCase(value) {
|
|
89
74
|
if (!value)
|
|
90
75
|
return value;
|
|
@@ -643,13 +628,6 @@ function parseRpcUrls(raw) {
|
|
|
643
628
|
}
|
|
644
629
|
return urls;
|
|
645
630
|
}
|
|
646
|
-
export function tokenPocketDappUrl(url, source = 'eosconnect') {
|
|
647
|
-
return `tpdapp://open?params=${encodeURIComponent(JSON.stringify({
|
|
648
|
-
url,
|
|
649
|
-
chain: 'EOS',
|
|
650
|
-
source
|
|
651
|
-
}))}`;
|
|
652
|
-
}
|
|
653
631
|
export async function generateEosConnectPaymentKey() {
|
|
654
632
|
const privateKey = PrivateKey.generate('K1');
|
|
655
633
|
return {
|
|
@@ -1506,8 +1484,8 @@ export function createEosConnect(options) {
|
|
|
1506
1484
|
return this.refreshWallet();
|
|
1507
1485
|
},
|
|
1508
1486
|
async connect(connectOptions) {
|
|
1509
|
-
if (connectOptions.provider !== 'telegram'
|
|
1510
|
-
throw new Error(
|
|
1487
|
+
if (connectOptions.provider !== 'telegram') {
|
|
1488
|
+
throw new Error('Only Telegram wallet binding is supported');
|
|
1511
1489
|
}
|
|
1512
1490
|
if (!initData()) {
|
|
1513
1491
|
return publish({
|
|
@@ -1518,21 +1496,17 @@ export function createEosConnect(options) {
|
|
|
1518
1496
|
});
|
|
1519
1497
|
}
|
|
1520
1498
|
if (!connectOptions.publicKey) {
|
|
1521
|
-
throw new Error(
|
|
1499
|
+
throw new Error('Telegram provider requires a publicKey');
|
|
1522
1500
|
}
|
|
1523
|
-
const
|
|
1524
|
-
? '/api/tg-wallet/tp-bind/start'
|
|
1525
|
-
: '/api/tg-wallet/bind/start';
|
|
1526
|
-
const bind = await request(path, {
|
|
1501
|
+
const bind = await request('/api/tg-wallet/bind/start', {
|
|
1527
1502
|
method: 'POST',
|
|
1528
1503
|
body: JSON.stringify({
|
|
1529
1504
|
initData: initData(),
|
|
1530
|
-
botPublicKey: connectOptions.
|
|
1531
|
-
tgpayPublicKey: connectOptions.provider === 'tokenpocket' ? connectOptions.publicKey : undefined,
|
|
1505
|
+
botPublicKey: connectOptions.publicKey,
|
|
1532
1506
|
botUsername: connectOptions.botUsername || options.botUsername || undefined,
|
|
1533
1507
|
deviceLabel: options.deviceLabel || telegramDeviceLabel(telegramWebApp()),
|
|
1534
1508
|
assetLimits: connectOptions.assetLimits,
|
|
1535
|
-
replaceWallet: connectOptions.
|
|
1509
|
+
replaceWallet: connectOptions.replaceWallet || undefined
|
|
1536
1510
|
})
|
|
1537
1511
|
});
|
|
1538
1512
|
if (bind.hasWallet) {
|
|
@@ -1560,9 +1534,7 @@ export function createEosConnect(options) {
|
|
|
1560
1534
|
error: null
|
|
1561
1535
|
});
|
|
1562
1536
|
if (connectOptions.openLink !== false) {
|
|
1563
|
-
openExternalUrl(
|
|
1564
|
-
? tokenPocketDappUrl(bind.bindUrl, options.tokenPocketSource)
|
|
1565
|
-
: bind.bindUrl, options, telegramWebApp());
|
|
1537
|
+
openExternalUrl(bind.bindUrl, options, telegramWebApp());
|
|
1566
1538
|
}
|
|
1567
1539
|
return next;
|
|
1568
1540
|
},
|
|
@@ -1650,23 +1622,6 @@ export function createEosConnect(options) {
|
|
|
1650
1622
|
}
|
|
1651
1623
|
return this.checkQuickPay();
|
|
1652
1624
|
},
|
|
1653
|
-
async connectTokenPocket(tokenPocketOptions = {}) {
|
|
1654
|
-
const paymentKey = await generateEosConnectPaymentKey();
|
|
1655
|
-
const next = await this.connect({
|
|
1656
|
-
provider: 'tokenpocket',
|
|
1657
|
-
publicKey: paymentKey.publicKey,
|
|
1658
|
-
assetLimits: tokenPocketOptions.assetLimits,
|
|
1659
|
-
openLink: false
|
|
1660
|
-
});
|
|
1661
|
-
if (!next.bindUrl || !next.bindId) {
|
|
1662
|
-
throw new Error('EOS Connect did not return a TokenPocket binding request');
|
|
1663
|
-
}
|
|
1664
|
-
await saveEosConnectPaymentKey(paymentKey.privateKey, telegramWebApp());
|
|
1665
|
-
if (tokenPocketOptions.openLink !== false) {
|
|
1666
|
-
openExternalUrl(tokenPocketDappUrl(next.bindUrl, options.tokenPocketSource), options, telegramWebApp());
|
|
1667
|
-
}
|
|
1668
|
-
return next;
|
|
1669
|
-
},
|
|
1670
1625
|
async pay(payOptions) {
|
|
1671
1626
|
if (!initData()) {
|
|
1672
1627
|
throw new Error('Telegram initData is missing');
|
package/dist/ui.js
CHANGED
|
@@ -66,6 +66,20 @@ eos-connect-button {
|
|
|
66
66
|
line-height: 1.2;
|
|
67
67
|
font-weight: 700;
|
|
68
68
|
padding: 0 18px;
|
|
69
|
+
transition:
|
|
70
|
+
background-color 160ms ease,
|
|
71
|
+
transform 120ms ease;
|
|
72
|
+
}
|
|
73
|
+
.eos-connect-button:hover {
|
|
74
|
+
background: var(--eos-connect-accent-strong);
|
|
75
|
+
}
|
|
76
|
+
.eos-connect-button:active {
|
|
77
|
+
transform: translateY(1px);
|
|
78
|
+
}
|
|
79
|
+
.eos-connect-button:focus-visible,
|
|
80
|
+
.eos-connect-sdk-primary:focus-visible {
|
|
81
|
+
outline: 3px solid rgba(47, 128, 237, 0.28);
|
|
82
|
+
outline-offset: 2px;
|
|
69
83
|
}
|
|
70
84
|
.eos-connect-sdk-backdrop {
|
|
71
85
|
appearance: none;
|
|
@@ -76,11 +90,13 @@ eos-connect-button {
|
|
|
76
90
|
padding: 0;
|
|
77
91
|
background: rgba(15, 23, 42, 0.36);
|
|
78
92
|
cursor: pointer;
|
|
93
|
+
animation: eos-connect-sdk-backdrop-in 180ms cubic-bezier(0.25, 1, 0.5, 1) both;
|
|
79
94
|
}
|
|
80
95
|
.eos-connect-sdk-sheet {
|
|
81
96
|
position: relative;
|
|
82
97
|
width: min(100%, 420px);
|
|
83
98
|
max-height: min(640px, calc(100dvh - 24px - env(safe-area-inset-bottom)));
|
|
99
|
+
box-sizing: border-box;
|
|
84
100
|
border: 1px solid var(--eos-connect-border);
|
|
85
101
|
border-radius: 8px;
|
|
86
102
|
background: var(--eos-connect-surface);
|
|
@@ -88,6 +104,8 @@ eos-connect-button {
|
|
|
88
104
|
padding: 16px;
|
|
89
105
|
overflow: auto;
|
|
90
106
|
-webkit-overflow-scrolling: touch;
|
|
107
|
+
transform-origin: center bottom;
|
|
108
|
+
animation: eos-connect-sdk-sheet-in 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
91
109
|
}
|
|
92
110
|
.eos-connect-sdk-sheet--quick {
|
|
93
111
|
width: min(100%, 454px) !important;
|
|
@@ -116,6 +134,13 @@ eos-connect-button {
|
|
|
116
134
|
line-height: 1 !important;
|
|
117
135
|
font-weight: 300 !important;
|
|
118
136
|
padding: 0 !important;
|
|
137
|
+
transition:
|
|
138
|
+
background-color 160ms ease,
|
|
139
|
+
color 160ms ease,
|
|
140
|
+
transform 120ms ease !important;
|
|
141
|
+
}
|
|
142
|
+
.eos-connect-sdk-close:active {
|
|
143
|
+
transform: scale(0.96);
|
|
119
144
|
}
|
|
120
145
|
.eos-connect-sdk-summary {
|
|
121
146
|
margin-bottom: 16px;
|
|
@@ -169,6 +194,10 @@ eos-connect-button {
|
|
|
169
194
|
font-weight: 700;
|
|
170
195
|
padding: 0 16px;
|
|
171
196
|
text-align: left;
|
|
197
|
+
transition:
|
|
198
|
+
background-color 180ms ease,
|
|
199
|
+
box-shadow 180ms ease,
|
|
200
|
+
transform 120ms ease;
|
|
172
201
|
}
|
|
173
202
|
.eos-connect-sdk-primary--quick {
|
|
174
203
|
display: grid !important;
|
|
@@ -183,6 +212,9 @@ eos-connect-button {
|
|
|
183
212
|
line-height: 1.2 !important;
|
|
184
213
|
text-align: center !important;
|
|
185
214
|
}
|
|
215
|
+
.eos-connect-sdk-primary--quick:not([disabled]):active {
|
|
216
|
+
transform: translateY(1px) scale(0.992);
|
|
217
|
+
}
|
|
186
218
|
.eos-connect-sdk-primary--quick[aria-busy="true"],
|
|
187
219
|
.eos-connect-sdk-primary--quick[disabled] {
|
|
188
220
|
opacity: 1 !important;
|
|
@@ -230,6 +262,7 @@ eos-connect-button {
|
|
|
230
262
|
stroke-width: 2.4 !important;
|
|
231
263
|
stroke-linecap: round !important;
|
|
232
264
|
stroke-linejoin: round !important;
|
|
265
|
+
animation: eos-connect-sdk-success-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
233
266
|
}
|
|
234
267
|
.eos-connect-sdk-send-icon {
|
|
235
268
|
justify-self: end !important;
|
|
@@ -250,6 +283,47 @@ eos-connect-button {
|
|
|
250
283
|
transform: rotate(360deg);
|
|
251
284
|
}
|
|
252
285
|
}
|
|
286
|
+
@keyframes eos-connect-sdk-backdrop-in {
|
|
287
|
+
from {
|
|
288
|
+
opacity: 0;
|
|
289
|
+
}
|
|
290
|
+
to {
|
|
291
|
+
opacity: 1;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
@keyframes eos-connect-sdk-sheet-in {
|
|
295
|
+
from {
|
|
296
|
+
opacity: 0;
|
|
297
|
+
transform: translate3d(0, 18px, 0) scale(0.985);
|
|
298
|
+
}
|
|
299
|
+
to {
|
|
300
|
+
opacity: 1;
|
|
301
|
+
transform: translate3d(0, 0, 0) scale(1);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
@keyframes eos-connect-sdk-success-in {
|
|
305
|
+
from {
|
|
306
|
+
opacity: 0;
|
|
307
|
+
transform: scale(0.88);
|
|
308
|
+
}
|
|
309
|
+
to {
|
|
310
|
+
opacity: 1;
|
|
311
|
+
transform: scale(1);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
@media (prefers-reduced-motion: reduce) {
|
|
315
|
+
.eos-connect-button,
|
|
316
|
+
.eos-connect-sdk-backdrop,
|
|
317
|
+
.eos-connect-sdk-sheet,
|
|
318
|
+
.eos-connect-sdk-close,
|
|
319
|
+
.eos-connect-sdk-primary,
|
|
320
|
+
.eos-connect-sdk-spinner,
|
|
321
|
+
.eos-connect-sdk-success-icon svg {
|
|
322
|
+
animation-duration: 0.01ms !important;
|
|
323
|
+
animation-iteration-count: 1 !important;
|
|
324
|
+
transition-duration: 0.01ms !important;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
253
327
|
.eos-connect-sdk-primary span {
|
|
254
328
|
min-width: 0;
|
|
255
329
|
overflow-wrap: anywhere;
|
|
@@ -348,6 +422,7 @@ const EOS_CONNECT_UI_MESSAGES = {
|
|
|
348
422
|
closeEosConnect: '关闭 EOS Connect'
|
|
349
423
|
}
|
|
350
424
|
};
|
|
425
|
+
const EOS_CONNECT_QUICK_PAY_REFRESH_INTERVAL_MS = 1500;
|
|
351
426
|
function normalizeEosConnectUiLocale(locale) {
|
|
352
427
|
return String(locale ?? '').toLowerCase().startsWith('zh') ? 'zh-CN' : 'en';
|
|
353
428
|
}
|
|
@@ -388,10 +463,10 @@ export function renderEosConnectButton(client, options = {}) {
|
|
|
388
463
|
: t('enableQuickPayment');
|
|
389
464
|
return `<button class="eos-connect-button" type="button">${escapeHtml(label)}</button>`;
|
|
390
465
|
}
|
|
391
|
-
function renderQuickPaymentSheet(
|
|
466
|
+
function renderQuickPaymentSheet(t, flowState = 'idle') {
|
|
392
467
|
const isChecking = flowState === 'checking';
|
|
393
468
|
const isSuccess = flowState === 'success';
|
|
394
|
-
const disabled = isChecking || isSuccess
|
|
469
|
+
const disabled = isChecking || isSuccess;
|
|
395
470
|
const title = isSuccess ? t('quickPaymentSuccess') : t('enableQuickPayment');
|
|
396
471
|
const description = isSuccess
|
|
397
472
|
? t('quickPaymentSuccessDescription')
|
|
@@ -438,7 +513,7 @@ function renderQuickPaymentSheet(provider, t, flowState = 'idle') {
|
|
|
438
513
|
<button
|
|
439
514
|
type="button"
|
|
440
515
|
class="eos-connect-sdk-primary eos-connect-sdk-primary--quick${isSuccess ? ' eos-connect-sdk-primary--success' : ''}"
|
|
441
|
-
data-provider="
|
|
516
|
+
data-provider="telegram"
|
|
442
517
|
aria-disabled="${disabled}"
|
|
443
518
|
${isChecking ? 'aria-busy="true"' : ''}
|
|
444
519
|
${disabled ? 'disabled' : ''}
|
|
@@ -452,15 +527,13 @@ function renderQuickPaymentSheet(provider, t, flowState = 'idle') {
|
|
|
452
527
|
}
|
|
453
528
|
export function renderEosConnectSheet(client, options = {}) {
|
|
454
529
|
const snapshot = client.getSnapshot();
|
|
455
|
-
const providers = client.getProviders();
|
|
456
|
-
const primary = providers.find((provider) => provider.id === 'telegram') ?? providers[0];
|
|
457
530
|
const t = createTranslator(options);
|
|
458
531
|
const flowState = options.flowState === 'success' || options.flowState === 'checking'
|
|
459
532
|
? options.flowState
|
|
460
533
|
: snapshot.status === 'connected' && snapshot.canUse
|
|
461
534
|
? 'success'
|
|
462
535
|
: 'idle';
|
|
463
|
-
return renderQuickPaymentSheet(
|
|
536
|
+
return renderQuickPaymentSheet(t, flowState);
|
|
464
537
|
}
|
|
465
538
|
export async function connectEosProvider(client, _provider = 'telegram', options = {}) {
|
|
466
539
|
return client.startTelegramWalletFlow(options);
|
|
@@ -471,6 +544,9 @@ function isQuickPaymentReadyView(view) {
|
|
|
471
544
|
function isQuickPaymentReadyState(state) {
|
|
472
545
|
return state.status === 'connected' && state.canUse === true;
|
|
473
546
|
}
|
|
547
|
+
function isQuickPaymentTerminalView(view) {
|
|
548
|
+
return view?.status === 'error' || view?.status === 'unsupported';
|
|
549
|
+
}
|
|
474
550
|
function globalTelegramWebApp() {
|
|
475
551
|
const maybeWindow = globalThis;
|
|
476
552
|
return maybeWindow.window?.Telegram?.WebApp ?? maybeWindow.Telegram?.WebApp ?? null;
|
|
@@ -565,6 +641,8 @@ function createModalElement(options) {
|
|
|
565
641
|
unsubscribe = null;
|
|
566
642
|
client = null;
|
|
567
643
|
flowState = 'idle';
|
|
644
|
+
flowPromise = null;
|
|
645
|
+
quickPayRefreshTimer = null;
|
|
568
646
|
connectedCallback() {
|
|
569
647
|
this.client = resolveClient(this, options.client, options);
|
|
570
648
|
this.render();
|
|
@@ -573,51 +651,113 @@ function createModalElement(options) {
|
|
|
573
651
|
dispatchEosConnectError(this, { error });
|
|
574
652
|
});
|
|
575
653
|
this.addEventListener('click', this.handleClick);
|
|
654
|
+
globalThis.addEventListener?.('focus', this.handleForeground);
|
|
655
|
+
globalThis.document?.addEventListener?.('visibilitychange', this.handleForeground);
|
|
576
656
|
}
|
|
577
657
|
disconnectedCallback() {
|
|
658
|
+
this.clearQuickPayRefresh();
|
|
578
659
|
this.unsubscribe?.();
|
|
579
660
|
this.removeEventListener('click', this.handleClick);
|
|
661
|
+
globalThis.removeEventListener?.('focus', this.handleForeground);
|
|
662
|
+
globalThis.document?.removeEventListener?.('visibilitychange', this.handleForeground);
|
|
580
663
|
}
|
|
581
664
|
handleClick = (event) => {
|
|
582
665
|
const target = event.target;
|
|
583
666
|
if (target?.closest('[data-eos-connect-close]')) {
|
|
584
667
|
this.flowState = 'idle';
|
|
668
|
+
this.flowPromise = null;
|
|
669
|
+
this.clearQuickPayRefresh();
|
|
585
670
|
this.setAttribute('hidden', '');
|
|
586
671
|
this.dispatchEvent(new CustomEvent('eos-connect-close', { bubbles: true, composed: true }));
|
|
587
672
|
return;
|
|
588
673
|
}
|
|
589
674
|
const provider = target?.closest('[data-provider]')?.dataset.provider;
|
|
590
675
|
if (provider && this.client) {
|
|
591
|
-
|
|
592
|
-
if (providerConfig?.state && providerConfig.state !== 'available') {
|
|
676
|
+
if (provider !== 'telegram' || this.flowState !== 'idle' || this.flowPromise) {
|
|
593
677
|
return;
|
|
594
678
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
void connectEosProvider(this.client, provider, {
|
|
679
|
+
this.flowState = 'checking';
|
|
680
|
+
this.render();
|
|
681
|
+
this.scheduleQuickPayRefresh();
|
|
682
|
+
this.flowPromise = connectEosProvider(this.client, provider, {
|
|
600
683
|
...options.telegramOptions,
|
|
601
684
|
botUsername: options.telegramOptions?.botUsername ?? options.botUsername,
|
|
602
685
|
assetLimits: options.telegramOptions?.assetLimits ?? options.assetLimits,
|
|
603
686
|
replaceWallet: options.telegramOptions?.replaceWallet ?? options.replaceWallet,
|
|
604
687
|
openExternal: options.openExternal
|
|
605
688
|
}).then((view) => {
|
|
606
|
-
if (
|
|
607
|
-
this.
|
|
608
|
-
|
|
609
|
-
: 'idle';
|
|
610
|
-
this.render();
|
|
689
|
+
if (isQuickPaymentReadyView(view) || isQuickPaymentReadyState(this.client.getSnapshot())) {
|
|
690
|
+
this.showQuickPaySuccess();
|
|
691
|
+
return;
|
|
611
692
|
}
|
|
612
|
-
|
|
613
|
-
if (provider === 'telegram') {
|
|
693
|
+
if (isQuickPaymentTerminalView(view)) {
|
|
614
694
|
this.flowState = 'idle';
|
|
695
|
+
this.clearQuickPayRefresh();
|
|
615
696
|
this.render();
|
|
697
|
+
return;
|
|
616
698
|
}
|
|
699
|
+
this.flowState = 'checking';
|
|
700
|
+
this.render();
|
|
701
|
+
this.scheduleQuickPayRefresh();
|
|
702
|
+
}).catch((error) => {
|
|
703
|
+
this.flowState = 'idle';
|
|
704
|
+
this.clearQuickPayRefresh();
|
|
705
|
+
this.render();
|
|
617
706
|
dispatchEosConnectError(this, { error, provider });
|
|
707
|
+
}).finally(() => {
|
|
708
|
+
this.flowPromise = null;
|
|
618
709
|
});
|
|
619
710
|
}
|
|
620
711
|
};
|
|
712
|
+
handleForeground = () => {
|
|
713
|
+
if (globalThis.document?.visibilityState && globalThis.document.visibilityState !== 'visible') {
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
if (this.flowState !== 'checking') {
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
this.clearQuickPayRefresh();
|
|
720
|
+
void this.refreshQuickPayStatus();
|
|
721
|
+
};
|
|
722
|
+
scheduleQuickPayRefresh(delayMs = EOS_CONNECT_QUICK_PAY_REFRESH_INTERVAL_MS) {
|
|
723
|
+
if (!this.client || this.flowState !== 'checking' || this.quickPayRefreshTimer) {
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
this.quickPayRefreshTimer = globalThis.setTimeout(() => {
|
|
727
|
+
this.quickPayRefreshTimer = null;
|
|
728
|
+
void this.refreshQuickPayStatus();
|
|
729
|
+
}, delayMs);
|
|
730
|
+
}
|
|
731
|
+
clearQuickPayRefresh() {
|
|
732
|
+
if (this.quickPayRefreshTimer) {
|
|
733
|
+
globalThis.clearTimeout(this.quickPayRefreshTimer);
|
|
734
|
+
this.quickPayRefreshTimer = null;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
async refreshQuickPayStatus() {
|
|
738
|
+
if (!this.client || this.flowState !== 'checking') {
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
try {
|
|
742
|
+
const quickPay = await this.client.checkQuickPay();
|
|
743
|
+
if (this.flowState !== 'checking') {
|
|
744
|
+
return;
|
|
745
|
+
}
|
|
746
|
+
if (quickPay.enabled) {
|
|
747
|
+
this.showQuickPaySuccess();
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
catch (error) {
|
|
752
|
+
dispatchEosConnectError(this, { error, provider: 'telegram' });
|
|
753
|
+
}
|
|
754
|
+
this.scheduleQuickPayRefresh();
|
|
755
|
+
}
|
|
756
|
+
showQuickPaySuccess() {
|
|
757
|
+
this.flowState = 'success';
|
|
758
|
+
this.clearQuickPayRefresh();
|
|
759
|
+
this.render();
|
|
760
|
+
}
|
|
621
761
|
render() {
|
|
622
762
|
if (!this.client)
|
|
623
763
|
return;
|
package/package.json
CHANGED
package/styles.css
CHANGED
|
@@ -105,6 +105,7 @@ eos-connect-button {
|
|
|
105
105
|
padding: 0;
|
|
106
106
|
background: rgba(15, 23, 42, 0.36);
|
|
107
107
|
cursor: pointer;
|
|
108
|
+
animation: eos-connect-sdk-backdrop-in 180ms cubic-bezier(0.25, 1, 0.5, 1) both;
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
.eos-connect-sdk-sheet {
|
|
@@ -119,6 +120,8 @@ eos-connect-button {
|
|
|
119
120
|
padding: 16px;
|
|
120
121
|
overflow: auto;
|
|
121
122
|
-webkit-overflow-scrolling: touch;
|
|
123
|
+
transform-origin: center bottom;
|
|
124
|
+
animation: eos-connect-sdk-sheet-in 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
122
125
|
}
|
|
123
126
|
|
|
124
127
|
.eos-connect-sdk-sheet--quick {
|
|
@@ -149,6 +152,14 @@ eos-connect-button {
|
|
|
149
152
|
line-height: 1 !important;
|
|
150
153
|
font-weight: 300 !important;
|
|
151
154
|
padding: 0 !important;
|
|
155
|
+
transition:
|
|
156
|
+
background-color 160ms ease,
|
|
157
|
+
color 160ms ease,
|
|
158
|
+
transform 120ms ease !important;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.eos-connect-sdk-close:active {
|
|
162
|
+
transform: scale(0.96);
|
|
152
163
|
}
|
|
153
164
|
|
|
154
165
|
.eos-connect-sdk-summary {
|
|
@@ -210,6 +221,10 @@ eos-connect-button {
|
|
|
210
221
|
font-weight: 700;
|
|
211
222
|
padding: 0 16px;
|
|
212
223
|
text-align: left;
|
|
224
|
+
transition:
|
|
225
|
+
background-color 180ms ease,
|
|
226
|
+
box-shadow 180ms ease,
|
|
227
|
+
transform 120ms ease;
|
|
213
228
|
}
|
|
214
229
|
|
|
215
230
|
.eos-connect-sdk-primary--quick {
|
|
@@ -226,6 +241,10 @@ eos-connect-button {
|
|
|
226
241
|
text-align: center !important;
|
|
227
242
|
}
|
|
228
243
|
|
|
244
|
+
.eos-connect-sdk-primary--quick:not([disabled]):active {
|
|
245
|
+
transform: translateY(1px) scale(0.992);
|
|
246
|
+
}
|
|
247
|
+
|
|
229
248
|
.eos-connect-sdk-primary--quick[aria-busy="true"],
|
|
230
249
|
.eos-connect-sdk-primary--quick[disabled] {
|
|
231
250
|
opacity: 1 !important;
|
|
@@ -279,6 +298,7 @@ eos-connect-button {
|
|
|
279
298
|
stroke-width: 2.4 !important;
|
|
280
299
|
stroke-linecap: round !important;
|
|
281
300
|
stroke-linejoin: round !important;
|
|
301
|
+
animation: eos-connect-sdk-success-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;
|
|
282
302
|
}
|
|
283
303
|
|
|
284
304
|
.eos-connect-sdk-send-icon {
|
|
@@ -303,6 +323,51 @@ eos-connect-button {
|
|
|
303
323
|
}
|
|
304
324
|
}
|
|
305
325
|
|
|
326
|
+
@keyframes eos-connect-sdk-backdrop-in {
|
|
327
|
+
from {
|
|
328
|
+
opacity: 0;
|
|
329
|
+
}
|
|
330
|
+
to {
|
|
331
|
+
opacity: 1;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
@keyframes eos-connect-sdk-sheet-in {
|
|
336
|
+
from {
|
|
337
|
+
opacity: 0;
|
|
338
|
+
transform: translate3d(0, 18px, 0) scale(0.985);
|
|
339
|
+
}
|
|
340
|
+
to {
|
|
341
|
+
opacity: 1;
|
|
342
|
+
transform: translate3d(0, 0, 0) scale(1);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
@keyframes eos-connect-sdk-success-in {
|
|
347
|
+
from {
|
|
348
|
+
opacity: 0;
|
|
349
|
+
transform: scale(0.88);
|
|
350
|
+
}
|
|
351
|
+
to {
|
|
352
|
+
opacity: 1;
|
|
353
|
+
transform: scale(1);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
@media (prefers-reduced-motion: reduce) {
|
|
358
|
+
.eos-connect-button,
|
|
359
|
+
.eos-connect-sdk-backdrop,
|
|
360
|
+
.eos-connect-sdk-sheet,
|
|
361
|
+
.eos-connect-sdk-close,
|
|
362
|
+
.eos-connect-sdk-primary,
|
|
363
|
+
.eos-connect-sdk-spinner,
|
|
364
|
+
.eos-connect-sdk-success-icon svg {
|
|
365
|
+
animation-duration: 0.01ms !important;
|
|
366
|
+
animation-iteration-count: 1 !important;
|
|
367
|
+
transition-duration: 0.01ms !important;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
306
371
|
.eos-connect-sdk-primary span {
|
|
307
372
|
min-width: 0;
|
|
308
373
|
overflow-wrap: anywhere;
|