@tonconnect/ui 2.0.1-beta.4 → 2.0.1-beta.6
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/tonconnect-ui.min.js +213 -207
- package/dist/tonconnect-ui.min.js.map +1 -1
- package/lib/index.cjs +89 -36
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.mjs +89 -36
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -331,7 +331,8 @@ declare class TonConnectUI {
|
|
|
331
331
|
*/
|
|
332
332
|
private readonly transactionModal;
|
|
333
333
|
/**
|
|
334
|
-
* Promise that resolves after end of th connection restoring process (promise will fire after `onStatusChange`,
|
|
334
|
+
* Promise that resolves after end of th connection restoring process (promise will fire after `onStatusChange`,
|
|
335
|
+
* so you can get actual information about wallet and session after when promise resolved).
|
|
335
336
|
* Resolved value `true`/`false` indicates if the session was restored successfully.
|
|
336
337
|
*/
|
|
337
338
|
readonly connectionRestored: Promise<boolean>;
|
package/lib/index.mjs
CHANGED
|
@@ -6848,7 +6848,7 @@ const Notification = (props) => {
|
|
|
6848
6848
|
}
|
|
6849
6849
|
}));
|
|
6850
6850
|
};
|
|
6851
|
-
const LoaderIconStyled$
|
|
6851
|
+
const LoaderIconStyled$2 = styled(LoaderIcon)`
|
|
6852
6852
|
align-self: center;
|
|
6853
6853
|
`;
|
|
6854
6854
|
const ConfirmOperationNotification = (props) => {
|
|
@@ -6868,7 +6868,7 @@ const ConfirmOperationNotification = (props) => {
|
|
|
6868
6868
|
return props.class;
|
|
6869
6869
|
},
|
|
6870
6870
|
get icon() {
|
|
6871
|
-
return createComponent(LoaderIconStyled$
|
|
6871
|
+
return createComponent(LoaderIconStyled$2, {});
|
|
6872
6872
|
},
|
|
6873
6873
|
"data-tc-notification-confirm": "true",
|
|
6874
6874
|
children: "Confirm operation in your wallet"
|
|
@@ -7048,7 +7048,7 @@ const DropdownButtonStyled = styled(AccountButtonStyled)`
|
|
|
7048
7048
|
justify-content: center;
|
|
7049
7049
|
background-color: ${(props) => props.theme.colors.background.primary};
|
|
7050
7050
|
`;
|
|
7051
|
-
const LoaderButtonStyled = styled(Button)`
|
|
7051
|
+
const LoaderButtonStyled$1 = styled(Button)`
|
|
7052
7052
|
min-width: 148px;
|
|
7053
7053
|
height: 40px;
|
|
7054
7054
|
|
|
@@ -7060,7 +7060,7 @@ const LoaderButtonStyled = styled(Button)`
|
|
|
7060
7060
|
align-items: center;
|
|
7061
7061
|
justify-content: center;
|
|
7062
7062
|
`;
|
|
7063
|
-
const LoaderIconStyled = styled(LoaderIcon)`
|
|
7063
|
+
const LoaderIconStyled$1 = styled(LoaderIcon)`
|
|
7064
7064
|
height: 18px;
|
|
7065
7065
|
width: 18px;
|
|
7066
7066
|
`;
|
|
@@ -7852,9 +7852,11 @@ const AccountButton = () => {
|
|
|
7852
7852
|
if (!wallet) {
|
|
7853
7853
|
setIsOpened(false);
|
|
7854
7854
|
setAccount(null);
|
|
7855
|
+
setRestoringProcess(false);
|
|
7855
7856
|
return;
|
|
7856
7857
|
}
|
|
7857
7858
|
setAccount(wallet.account);
|
|
7859
|
+
setRestoringProcess(false);
|
|
7858
7860
|
});
|
|
7859
7861
|
const onClick = (e2) => {
|
|
7860
7862
|
if (!account() || !isOpened()) {
|
|
@@ -7881,11 +7883,11 @@ const AccountButton = () => {
|
|
|
7881
7883
|
return restoringProcess();
|
|
7882
7884
|
},
|
|
7883
7885
|
get children() {
|
|
7884
|
-
return createComponent(LoaderButtonStyled, {
|
|
7886
|
+
return createComponent(LoaderButtonStyled$1, {
|
|
7885
7887
|
disabled: true,
|
|
7886
7888
|
"data-tc-connect-button-loading": "true",
|
|
7887
7889
|
get children() {
|
|
7888
|
-
return createComponent(LoaderIconStyled, {});
|
|
7890
|
+
return createComponent(LoaderIconStyled$1, {});
|
|
7889
7891
|
}
|
|
7890
7892
|
});
|
|
7891
7893
|
}
|
|
@@ -10134,6 +10136,14 @@ const TextStyled = styled(Text)`
|
|
|
10134
10136
|
|
|
10135
10137
|
color: ${(props) => props.theme.colors.text.secondary};
|
|
10136
10138
|
`;
|
|
10139
|
+
const LoaderButtonStyled = styled(Button)`
|
|
10140
|
+
min-width: 112px;
|
|
10141
|
+
margin-top: 32px;
|
|
10142
|
+
`;
|
|
10143
|
+
const LoaderIconStyled = styled(LoaderIcon)`
|
|
10144
|
+
height: 16px;
|
|
10145
|
+
width: 16px;
|
|
10146
|
+
`;
|
|
10137
10147
|
const ButtonStyled = styled(Button)`
|
|
10138
10148
|
margin-top: 32px;
|
|
10139
10149
|
`;
|
|
@@ -10141,6 +10151,11 @@ const ActionModal = (props) => {
|
|
|
10141
10151
|
const dataAttrs = useDataAttributes(props);
|
|
10142
10152
|
const tonConnectUI = useContext(TonConnectUiContext);
|
|
10143
10153
|
const [firstClick, setFirstClick] = createSignal(true);
|
|
10154
|
+
const [sent, setSent] = createSignal(false);
|
|
10155
|
+
createEffect(() => {
|
|
10156
|
+
const currentAction = action();
|
|
10157
|
+
setSent(!!currentAction && "sent" in currentAction && currentAction.sent);
|
|
10158
|
+
});
|
|
10144
10159
|
let universalLink;
|
|
10145
10160
|
if ((tonConnectUI == null ? void 0 : tonConnectUI.wallet) && "universalLink" in tonConnectUI.wallet && (tonConnectUI.wallet.openMethod === "universal-link" || isTelegramUrl(tonConnectUI.wallet.universalLink) && isInTMA())) {
|
|
10146
10161
|
universalLink = tonConnectUI.wallet.universalLink;
|
|
@@ -10186,33 +10201,53 @@ const ActionModal = (props) => {
|
|
|
10186
10201
|
}
|
|
10187
10202
|
}), createComponent(Show, {
|
|
10188
10203
|
get when() {
|
|
10189
|
-
return
|
|
10204
|
+
return !sent();
|
|
10190
10205
|
},
|
|
10191
10206
|
get children() {
|
|
10192
|
-
return createComponent(
|
|
10193
|
-
|
|
10207
|
+
return createComponent(LoaderButtonStyled, {
|
|
10208
|
+
disabled: true,
|
|
10209
|
+
"data-tc-connect-button-loading": "true",
|
|
10194
10210
|
get children() {
|
|
10195
|
-
return createComponent(
|
|
10196
|
-
translationKey: "common.close",
|
|
10197
|
-
children: "Close"
|
|
10198
|
-
});
|
|
10211
|
+
return createComponent(LoaderIconStyled, {});
|
|
10199
10212
|
}
|
|
10200
10213
|
});
|
|
10201
10214
|
}
|
|
10202
10215
|
}), createComponent(Show, {
|
|
10203
10216
|
get when() {
|
|
10204
|
-
return
|
|
10217
|
+
return sent();
|
|
10205
10218
|
},
|
|
10206
10219
|
get children() {
|
|
10207
|
-
return createComponent(
|
|
10208
|
-
|
|
10220
|
+
return [createComponent(Show, {
|
|
10221
|
+
get when() {
|
|
10222
|
+
return props.showButton !== "open-wallet";
|
|
10223
|
+
},
|
|
10209
10224
|
get children() {
|
|
10210
|
-
return createComponent(
|
|
10211
|
-
|
|
10212
|
-
children
|
|
10225
|
+
return createComponent(ButtonStyled, {
|
|
10226
|
+
onClick: () => props.onClose(),
|
|
10227
|
+
get children() {
|
|
10228
|
+
return createComponent(Translation, {
|
|
10229
|
+
translationKey: "common.close",
|
|
10230
|
+
children: "Close"
|
|
10231
|
+
});
|
|
10232
|
+
}
|
|
10213
10233
|
});
|
|
10214
10234
|
}
|
|
10215
|
-
})
|
|
10235
|
+
}), createComponent(Show, {
|
|
10236
|
+
get when() {
|
|
10237
|
+
return props.showButton === "open-wallet" && universalLink;
|
|
10238
|
+
},
|
|
10239
|
+
get children() {
|
|
10240
|
+
return createComponent(ButtonStyled, {
|
|
10241
|
+
onClick: onOpenWallet,
|
|
10242
|
+
get children() {
|
|
10243
|
+
return createComponent(Translation, {
|
|
10244
|
+
translationKey: "common.openWallet",
|
|
10245
|
+
children: "Open wallet"
|
|
10246
|
+
});
|
|
10247
|
+
}
|
|
10248
|
+
});
|
|
10249
|
+
}
|
|
10250
|
+
})];
|
|
10216
10251
|
}
|
|
10217
10252
|
})];
|
|
10218
10253
|
}
|
|
@@ -10844,9 +10879,19 @@ class TonConnectUI {
|
|
|
10844
10879
|
widgetController.setAction({
|
|
10845
10880
|
name: "confirm-transaction",
|
|
10846
10881
|
showNotification: notifications2.includes("before"),
|
|
10847
|
-
openModal: modals.includes("before")
|
|
10882
|
+
openModal: modals.includes("before"),
|
|
10883
|
+
sent: false
|
|
10848
10884
|
});
|
|
10849
10885
|
const onRequestSent = () => {
|
|
10886
|
+
if (abortController.signal.aborted) {
|
|
10887
|
+
return;
|
|
10888
|
+
}
|
|
10889
|
+
widgetController.setAction({
|
|
10890
|
+
name: "confirm-transaction",
|
|
10891
|
+
showNotification: notifications2.includes("before"),
|
|
10892
|
+
openModal: modals.includes("before"),
|
|
10893
|
+
sent: true
|
|
10894
|
+
});
|
|
10850
10895
|
const userOSIsIos = getUserAgent().os === "ios";
|
|
10851
10896
|
const shouldSkipRedirectToWallet = skipRedirectToWallet === "ios" && userOSIsIos || skipRedirectToWallet === "always";
|
|
10852
10897
|
if (this.walletInfo && "universalLink" in this.walletInfo && this.walletInfo.openMethod === "universal-link" && !shouldSkipRedirectToWallet) {
|
|
@@ -10875,7 +10920,7 @@ class TonConnectUI {
|
|
|
10875
10920
|
const result = yield this.waitForSendTransaction(
|
|
10876
10921
|
{
|
|
10877
10922
|
transaction: tx,
|
|
10878
|
-
|
|
10923
|
+
signal: abortController.signal
|
|
10879
10924
|
},
|
|
10880
10925
|
onRequestSent
|
|
10881
10926
|
);
|
|
@@ -10935,15 +10980,15 @@ class TonConnectUI {
|
|
|
10935
10980
|
});
|
|
10936
10981
|
return yield this.waitForWalletConnection({
|
|
10937
10982
|
ignoreErrors: true,
|
|
10938
|
-
|
|
10983
|
+
signal: abortController.signal
|
|
10939
10984
|
});
|
|
10940
10985
|
});
|
|
10941
10986
|
}
|
|
10942
10987
|
waitForWalletConnection(options) {
|
|
10943
10988
|
return __async(this, null, function* () {
|
|
10944
10989
|
return new Promise((resolve, reject) => {
|
|
10945
|
-
const { ignoreErrors = false,
|
|
10946
|
-
if (
|
|
10990
|
+
const { ignoreErrors = false, signal = null } = options;
|
|
10991
|
+
if (signal && signal.aborted) {
|
|
10947
10992
|
return reject(new TonConnectUIError("Wallet was not connected"));
|
|
10948
10993
|
}
|
|
10949
10994
|
const onStatusChangeHandler = (wallet) => __async(this, null, function* () {
|
|
@@ -10969,11 +11014,15 @@ class TonConnectUI {
|
|
|
10969
11014
|
(wallet) => onStatusChangeHandler(wallet),
|
|
10970
11015
|
(reason) => onErrorsHandler(reason)
|
|
10971
11016
|
);
|
|
10972
|
-
if (
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
|
|
11017
|
+
if (signal) {
|
|
11018
|
+
signal.addEventListener(
|
|
11019
|
+
"abort",
|
|
11020
|
+
() => {
|
|
11021
|
+
unsubscribe();
|
|
11022
|
+
reject(new TonConnectUIError("Wallet was not connected"));
|
|
11023
|
+
},
|
|
11024
|
+
{ once: true }
|
|
11025
|
+
);
|
|
10977
11026
|
}
|
|
10978
11027
|
});
|
|
10979
11028
|
});
|
|
@@ -10981,8 +11030,8 @@ class TonConnectUI {
|
|
|
10981
11030
|
waitForSendTransaction(options, onRequestSent) {
|
|
10982
11031
|
return __async(this, null, function* () {
|
|
10983
11032
|
return new Promise((resolve, reject) => {
|
|
10984
|
-
const { transaction,
|
|
10985
|
-
if (
|
|
11033
|
+
const { transaction, signal } = options;
|
|
11034
|
+
if (signal.aborted) {
|
|
10986
11035
|
return reject(new TonConnectUIError("Transaction was not sent"));
|
|
10987
11036
|
}
|
|
10988
11037
|
const onTransactionHandler = (transaction2) => __async(this, null, function* () {
|
|
@@ -10991,10 +11040,14 @@ class TonConnectUI {
|
|
|
10991
11040
|
const onErrorsHandler = (reason) => {
|
|
10992
11041
|
reject(reason);
|
|
10993
11042
|
};
|
|
10994
|
-
this.connector.sendTransaction(transaction, onRequestSent).then((result) => onTransactionHandler(result)).catch((reason) => onErrorsHandler(reason));
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
|
|
11043
|
+
this.connector.sendTransaction(transaction, { onRequestSent, signal }).then((result) => onTransactionHandler(result)).catch((reason) => onErrorsHandler(reason));
|
|
11044
|
+
signal.addEventListener(
|
|
11045
|
+
"abort",
|
|
11046
|
+
() => {
|
|
11047
|
+
reject(new TonConnectUIError("Transaction was not sent"));
|
|
11048
|
+
},
|
|
11049
|
+
{ once: true }
|
|
11050
|
+
);
|
|
10998
11051
|
});
|
|
10999
11052
|
});
|
|
11000
11053
|
}
|