@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/lib/index.cjs CHANGED
@@ -6853,7 +6853,7 @@ const Notification = (props) => {
6853
6853
  }
6854
6854
  }));
6855
6855
  };
6856
- const LoaderIconStyled$1 = styled(LoaderIcon)`
6856
+ const LoaderIconStyled$2 = styled(LoaderIcon)`
6857
6857
  align-self: center;
6858
6858
  `;
6859
6859
  const ConfirmOperationNotification = (props) => {
@@ -6873,7 +6873,7 @@ const ConfirmOperationNotification = (props) => {
6873
6873
  return props.class;
6874
6874
  },
6875
6875
  get icon() {
6876
- return createComponent(LoaderIconStyled$1, {});
6876
+ return createComponent(LoaderIconStyled$2, {});
6877
6877
  },
6878
6878
  "data-tc-notification-confirm": "true",
6879
6879
  children: "Confirm operation in your wallet"
@@ -7053,7 +7053,7 @@ const DropdownButtonStyled = styled(AccountButtonStyled)`
7053
7053
  justify-content: center;
7054
7054
  background-color: ${(props) => props.theme.colors.background.primary};
7055
7055
  `;
7056
- const LoaderButtonStyled = styled(Button)`
7056
+ const LoaderButtonStyled$1 = styled(Button)`
7057
7057
  min-width: 148px;
7058
7058
  height: 40px;
7059
7059
 
@@ -7065,7 +7065,7 @@ const LoaderButtonStyled = styled(Button)`
7065
7065
  align-items: center;
7066
7066
  justify-content: center;
7067
7067
  `;
7068
- const LoaderIconStyled = styled(LoaderIcon)`
7068
+ const LoaderIconStyled$1 = styled(LoaderIcon)`
7069
7069
  height: 18px;
7070
7070
  width: 18px;
7071
7071
  `;
@@ -7857,9 +7857,11 @@ const AccountButton = () => {
7857
7857
  if (!wallet) {
7858
7858
  setIsOpened(false);
7859
7859
  setAccount(null);
7860
+ setRestoringProcess(false);
7860
7861
  return;
7861
7862
  }
7862
7863
  setAccount(wallet.account);
7864
+ setRestoringProcess(false);
7863
7865
  });
7864
7866
  const onClick = (e2) => {
7865
7867
  if (!account() || !isOpened()) {
@@ -7886,11 +7888,11 @@ const AccountButton = () => {
7886
7888
  return restoringProcess();
7887
7889
  },
7888
7890
  get children() {
7889
- return createComponent(LoaderButtonStyled, {
7891
+ return createComponent(LoaderButtonStyled$1, {
7890
7892
  disabled: true,
7891
7893
  "data-tc-connect-button-loading": "true",
7892
7894
  get children() {
7893
- return createComponent(LoaderIconStyled, {});
7895
+ return createComponent(LoaderIconStyled$1, {});
7894
7896
  }
7895
7897
  });
7896
7898
  }
@@ -10139,6 +10141,14 @@ const TextStyled = styled(Text)`
10139
10141
 
10140
10142
  color: ${(props) => props.theme.colors.text.secondary};
10141
10143
  `;
10144
+ const LoaderButtonStyled = styled(Button)`
10145
+ min-width: 112px;
10146
+ margin-top: 32px;
10147
+ `;
10148
+ const LoaderIconStyled = styled(LoaderIcon)`
10149
+ height: 16px;
10150
+ width: 16px;
10151
+ `;
10142
10152
  const ButtonStyled = styled(Button)`
10143
10153
  margin-top: 32px;
10144
10154
  `;
@@ -10146,6 +10156,11 @@ const ActionModal = (props) => {
10146
10156
  const dataAttrs = useDataAttributes(props);
10147
10157
  const tonConnectUI = useContext(TonConnectUiContext);
10148
10158
  const [firstClick, setFirstClick] = createSignal(true);
10159
+ const [sent, setSent] = createSignal(false);
10160
+ createEffect(() => {
10161
+ const currentAction = action();
10162
+ setSent(!!currentAction && "sent" in currentAction && currentAction.sent);
10163
+ });
10149
10164
  let universalLink;
10150
10165
  if ((tonConnectUI == null ? void 0 : tonConnectUI.wallet) && "universalLink" in tonConnectUI.wallet && (tonConnectUI.wallet.openMethod === "universal-link" || sdk.isTelegramUrl(tonConnectUI.wallet.universalLink) && isInTMA())) {
10151
10166
  universalLink = tonConnectUI.wallet.universalLink;
@@ -10191,33 +10206,53 @@ const ActionModal = (props) => {
10191
10206
  }
10192
10207
  }), createComponent(Show, {
10193
10208
  get when() {
10194
- return props.showButton !== "open-wallet";
10209
+ return !sent();
10195
10210
  },
10196
10211
  get children() {
10197
- return createComponent(ButtonStyled, {
10198
- onClick: () => props.onClose(),
10212
+ return createComponent(LoaderButtonStyled, {
10213
+ disabled: true,
10214
+ "data-tc-connect-button-loading": "true",
10199
10215
  get children() {
10200
- return createComponent(Translation, {
10201
- translationKey: "common.close",
10202
- children: "Close"
10203
- });
10216
+ return createComponent(LoaderIconStyled, {});
10204
10217
  }
10205
10218
  });
10206
10219
  }
10207
10220
  }), createComponent(Show, {
10208
10221
  get when() {
10209
- return props.showButton === "open-wallet" && universalLink;
10222
+ return sent();
10210
10223
  },
10211
10224
  get children() {
10212
- return createComponent(ButtonStyled, {
10213
- onClick: onOpenWallet,
10225
+ return [createComponent(Show, {
10226
+ get when() {
10227
+ return props.showButton !== "open-wallet";
10228
+ },
10214
10229
  get children() {
10215
- return createComponent(Translation, {
10216
- translationKey: "common.openWallet",
10217
- children: "Open wallet"
10230
+ return createComponent(ButtonStyled, {
10231
+ onClick: () => props.onClose(),
10232
+ get children() {
10233
+ return createComponent(Translation, {
10234
+ translationKey: "common.close",
10235
+ children: "Close"
10236
+ });
10237
+ }
10218
10238
  });
10219
10239
  }
10220
- });
10240
+ }), createComponent(Show, {
10241
+ get when() {
10242
+ return props.showButton === "open-wallet" && universalLink;
10243
+ },
10244
+ get children() {
10245
+ return createComponent(ButtonStyled, {
10246
+ onClick: onOpenWallet,
10247
+ get children() {
10248
+ return createComponent(Translation, {
10249
+ translationKey: "common.openWallet",
10250
+ children: "Open wallet"
10251
+ });
10252
+ }
10253
+ });
10254
+ }
10255
+ })];
10221
10256
  }
10222
10257
  })];
10223
10258
  }
@@ -10849,9 +10884,19 @@ class TonConnectUI {
10849
10884
  widgetController.setAction({
10850
10885
  name: "confirm-transaction",
10851
10886
  showNotification: notifications2.includes("before"),
10852
- openModal: modals.includes("before")
10887
+ openModal: modals.includes("before"),
10888
+ sent: false
10853
10889
  });
10854
10890
  const onRequestSent = () => {
10891
+ if (abortController.signal.aborted) {
10892
+ return;
10893
+ }
10894
+ widgetController.setAction({
10895
+ name: "confirm-transaction",
10896
+ showNotification: notifications2.includes("before"),
10897
+ openModal: modals.includes("before"),
10898
+ sent: true
10899
+ });
10855
10900
  const userOSIsIos = getUserAgent().os === "ios";
10856
10901
  const shouldSkipRedirectToWallet = skipRedirectToWallet === "ios" && userOSIsIos || skipRedirectToWallet === "always";
10857
10902
  if (this.walletInfo && "universalLink" in this.walletInfo && this.walletInfo.openMethod === "universal-link" && !shouldSkipRedirectToWallet) {
@@ -10880,7 +10925,7 @@ class TonConnectUI {
10880
10925
  const result = yield this.waitForSendTransaction(
10881
10926
  {
10882
10927
  transaction: tx,
10883
- abortSignal: abortController.signal
10928
+ signal: abortController.signal
10884
10929
  },
10885
10930
  onRequestSent
10886
10931
  );
@@ -10940,15 +10985,15 @@ class TonConnectUI {
10940
10985
  });
10941
10986
  return yield this.waitForWalletConnection({
10942
10987
  ignoreErrors: true,
10943
- abortSignal: abortController.signal
10988
+ signal: abortController.signal
10944
10989
  });
10945
10990
  });
10946
10991
  }
10947
10992
  waitForWalletConnection(options) {
10948
10993
  return __async(this, null, function* () {
10949
10994
  return new Promise((resolve, reject) => {
10950
- const { ignoreErrors = false, abortSignal = null } = options;
10951
- if (abortSignal && abortSignal.aborted) {
10995
+ const { ignoreErrors = false, signal = null } = options;
10996
+ if (signal && signal.aborted) {
10952
10997
  return reject(new TonConnectUIError("Wallet was not connected"));
10953
10998
  }
10954
10999
  const onStatusChangeHandler = (wallet) => __async(this, null, function* () {
@@ -10974,11 +11019,15 @@ class TonConnectUI {
10974
11019
  (wallet) => onStatusChangeHandler(wallet),
10975
11020
  (reason) => onErrorsHandler(reason)
10976
11021
  );
10977
- if (abortSignal) {
10978
- abortSignal.addEventListener("abort", () => {
10979
- unsubscribe();
10980
- reject(new TonConnectUIError("Wallet was not connected"));
10981
- });
11022
+ if (signal) {
11023
+ signal.addEventListener(
11024
+ "abort",
11025
+ () => {
11026
+ unsubscribe();
11027
+ reject(new TonConnectUIError("Wallet was not connected"));
11028
+ },
11029
+ { once: true }
11030
+ );
10982
11031
  }
10983
11032
  });
10984
11033
  });
@@ -10986,8 +11035,8 @@ class TonConnectUI {
10986
11035
  waitForSendTransaction(options, onRequestSent) {
10987
11036
  return __async(this, null, function* () {
10988
11037
  return new Promise((resolve, reject) => {
10989
- const { transaction, abortSignal } = options;
10990
- if (abortSignal.aborted) {
11038
+ const { transaction, signal } = options;
11039
+ if (signal.aborted) {
10991
11040
  return reject(new TonConnectUIError("Transaction was not sent"));
10992
11041
  }
10993
11042
  const onTransactionHandler = (transaction2) => __async(this, null, function* () {
@@ -10996,10 +11045,14 @@ class TonConnectUI {
10996
11045
  const onErrorsHandler = (reason) => {
10997
11046
  reject(reason);
10998
11047
  };
10999
- this.connector.sendTransaction(transaction, onRequestSent).then((result) => onTransactionHandler(result)).catch((reason) => onErrorsHandler(reason));
11000
- abortSignal.addEventListener("abort", () => {
11001
- reject(new TonConnectUIError("Transaction was not sent"));
11002
- });
11048
+ this.connector.sendTransaction(transaction, { onRequestSent, signal }).then((result) => onTransactionHandler(result)).catch((reason) => onErrorsHandler(reason));
11049
+ signal.addEventListener(
11050
+ "abort",
11051
+ () => {
11052
+ reject(new TonConnectUIError("Transaction was not sent"));
11053
+ },
11054
+ { once: true }
11055
+ );
11003
11056
  });
11004
11057
  });
11005
11058
  }