@tonconnect/ui 2.0.1-beta.4 → 2.0.1-beta.5
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 +171 -142
- package/lib/index.cjs.map +1 -1
- package/lib/index.mjs +171 -142
- package/lib/index.mjs.map +1 -1
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -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
|
-
|
|
7056
|
+
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
|
-
|
|
7068
|
+
styled(LoaderIcon)`
|
|
7069
7069
|
height: 18px;
|
|
7070
7070
|
width: 18px;
|
|
7071
7071
|
`;
|
|
@@ -7836,7 +7836,6 @@ const AccountButton = () => {
|
|
|
7836
7836
|
const tonConnectUI = useContext(TonConnectUiContext);
|
|
7837
7837
|
const [isOpened, setIsOpened] = createSignal(false);
|
|
7838
7838
|
const [account, setAccount] = createSignal(connector.account);
|
|
7839
|
-
const [restoringProcess, setRestoringProcess] = createSignal(true);
|
|
7840
7839
|
let dropDownRef;
|
|
7841
7840
|
const [floating, setFloating] = createSignal();
|
|
7842
7841
|
const [anchor, setAnchor] = createSignal();
|
|
@@ -7852,7 +7851,6 @@ const AccountButton = () => {
|
|
|
7852
7851
|
}
|
|
7853
7852
|
return "";
|
|
7854
7853
|
};
|
|
7855
|
-
tonConnectUI.connectionRestored.then(() => setRestoringProcess(false));
|
|
7856
7854
|
const unsubscribe = connector.onStatusChange((wallet) => {
|
|
7857
7855
|
if (!wallet) {
|
|
7858
7856
|
setIsOpened(false);
|
|
@@ -7883,143 +7881,123 @@ const AccountButton = () => {
|
|
|
7883
7881
|
get children() {
|
|
7884
7882
|
return [createComponent(Show, {
|
|
7885
7883
|
get when() {
|
|
7886
|
-
return
|
|
7884
|
+
return !account();
|
|
7887
7885
|
},
|
|
7888
7886
|
get children() {
|
|
7889
|
-
return createComponent(
|
|
7890
|
-
|
|
7891
|
-
"data-tc-connect-button
|
|
7887
|
+
return createComponent(AccountButtonStyled, {
|
|
7888
|
+
onClick: () => tonConnectUI.openModal(),
|
|
7889
|
+
"data-tc-connect-button": "true",
|
|
7890
|
+
scale: "s",
|
|
7892
7891
|
get children() {
|
|
7893
|
-
return createComponent(
|
|
7892
|
+
return [createComponent(TonIcon, {
|
|
7893
|
+
get fill() {
|
|
7894
|
+
return theme.colors.connectButton.foreground;
|
|
7895
|
+
}
|
|
7896
|
+
}), createComponent(Text, {
|
|
7897
|
+
translationKey: "button.connectWallet",
|
|
7898
|
+
fontSize: "15px",
|
|
7899
|
+
lineHeight: "18px",
|
|
7900
|
+
fontWeight: "590",
|
|
7901
|
+
get color() {
|
|
7902
|
+
return theme.colors.connectButton.foreground;
|
|
7903
|
+
},
|
|
7904
|
+
children: "Connect wallet"
|
|
7905
|
+
})];
|
|
7894
7906
|
}
|
|
7895
7907
|
});
|
|
7896
7908
|
}
|
|
7897
7909
|
}), createComponent(Show, {
|
|
7898
7910
|
get when() {
|
|
7899
|
-
return
|
|
7911
|
+
return account();
|
|
7900
7912
|
},
|
|
7901
7913
|
get children() {
|
|
7902
|
-
return
|
|
7903
|
-
get when() {
|
|
7904
|
-
return !account();
|
|
7905
|
-
},
|
|
7914
|
+
return createComponent(DropdownContainerStyled, {
|
|
7906
7915
|
get children() {
|
|
7907
|
-
return createComponent(
|
|
7908
|
-
onClick: () =>
|
|
7909
|
-
|
|
7916
|
+
return [createComponent(DropdownButtonStyled, {
|
|
7917
|
+
onClick: () => setIsOpened((v) => !v),
|
|
7918
|
+
ref: setAnchor,
|
|
7919
|
+
"data-tc-dropdown-button": "true",
|
|
7910
7920
|
scale: "s",
|
|
7911
7921
|
get children() {
|
|
7912
|
-
return [createComponent(
|
|
7913
|
-
get fill() {
|
|
7914
|
-
return theme.colors.connectButton.foreground;
|
|
7915
|
-
}
|
|
7916
|
-
}), createComponent(Text, {
|
|
7917
|
-
translationKey: "button.connectWallet",
|
|
7922
|
+
return [createComponent(Text, {
|
|
7918
7923
|
fontSize: "15px",
|
|
7919
|
-
lineHeight: "18px",
|
|
7920
7924
|
fontWeight: "590",
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
+
lineHeight: "18px",
|
|
7926
|
+
get children() {
|
|
7927
|
+
return normalizedAddress();
|
|
7928
|
+
}
|
|
7929
|
+
}), createComponent(ArrowIcon, {
|
|
7930
|
+
direction: "bottom"
|
|
7925
7931
|
})];
|
|
7926
7932
|
}
|
|
7927
|
-
})
|
|
7928
|
-
}
|
|
7929
|
-
}), createComponent(Show, {
|
|
7930
|
-
get when() {
|
|
7931
|
-
return account();
|
|
7932
|
-
},
|
|
7933
|
-
get children() {
|
|
7934
|
-
return createComponent(DropdownContainerStyled, {
|
|
7933
|
+
}), createComponent(Portal, {
|
|
7935
7934
|
get children() {
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
|
|
7935
|
+
const _el$ = untrack(() => document.importNode(_tmpl$$3, true));
|
|
7936
|
+
use(setFloating, _el$);
|
|
7937
|
+
_el$.style.setProperty("z-index", "999");
|
|
7938
|
+
_el$._$owner = getOwner();
|
|
7939
|
+
insert(_el$, createComponent(Transition, {
|
|
7940
|
+
onBeforeEnter: (el) => {
|
|
7941
|
+
animate(el, [{
|
|
7942
|
+
opacity: 0,
|
|
7943
|
+
transform: "translateY(-8px)"
|
|
7944
|
+
}, {
|
|
7945
|
+
opacity: 1,
|
|
7946
|
+
transform: "translateY(0)"
|
|
7947
|
+
}], {
|
|
7948
|
+
duration: 150
|
|
7949
|
+
});
|
|
7950
|
+
},
|
|
7951
|
+
onExit: (el, done) => {
|
|
7952
|
+
const a2 = animate(el, [{
|
|
7953
|
+
opacity: 1,
|
|
7954
|
+
transform: "translateY(0)"
|
|
7955
|
+
}, {
|
|
7956
|
+
opacity: 0,
|
|
7957
|
+
transform: "translateY(-8px)"
|
|
7958
|
+
}], {
|
|
7959
|
+
duration: 150
|
|
7960
|
+
});
|
|
7961
|
+
a2.finished.then(done);
|
|
7962
|
+
},
|
|
7954
7963
|
get children() {
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
_el$._$owner = getOwner();
|
|
7959
|
-
insert(_el$, createComponent(Transition, {
|
|
7960
|
-
onBeforeEnter: (el) => {
|
|
7961
|
-
animate(el, [{
|
|
7962
|
-
opacity: 0,
|
|
7963
|
-
transform: "translateY(-8px)"
|
|
7964
|
-
}, {
|
|
7965
|
-
opacity: 1,
|
|
7966
|
-
transform: "translateY(0)"
|
|
7967
|
-
}], {
|
|
7968
|
-
duration: 150
|
|
7969
|
-
});
|
|
7970
|
-
},
|
|
7971
|
-
onExit: (el, done) => {
|
|
7972
|
-
const a2 = animate(el, [{
|
|
7973
|
-
opacity: 1,
|
|
7974
|
-
transform: "translateY(0)"
|
|
7975
|
-
}, {
|
|
7976
|
-
opacity: 0,
|
|
7977
|
-
transform: "translateY(-8px)"
|
|
7978
|
-
}], {
|
|
7979
|
-
duration: 150
|
|
7980
|
-
});
|
|
7981
|
-
a2.finished.then(done);
|
|
7964
|
+
return createComponent(Show, {
|
|
7965
|
+
get when() {
|
|
7966
|
+
return isOpened();
|
|
7982
7967
|
},
|
|
7983
7968
|
get children() {
|
|
7984
|
-
return createComponent(
|
|
7985
|
-
get
|
|
7986
|
-
return isOpened();
|
|
7969
|
+
return createComponent(DropdownStyled, {
|
|
7970
|
+
get hidden() {
|
|
7971
|
+
return !isOpened();
|
|
7987
7972
|
},
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
},
|
|
7993
|
-
onClose: () => setIsOpened(false),
|
|
7994
|
-
ref(r$) {
|
|
7995
|
-
const _ref$ = dropDownRef;
|
|
7996
|
-
typeof _ref$ === "function" ? _ref$(r$) : dropDownRef = r$;
|
|
7997
|
-
}
|
|
7998
|
-
});
|
|
7973
|
+
onClose: () => setIsOpened(false),
|
|
7974
|
+
ref(r$) {
|
|
7975
|
+
const _ref$ = dropDownRef;
|
|
7976
|
+
typeof _ref$ === "function" ? _ref$(r$) : dropDownRef = r$;
|
|
7999
7977
|
}
|
|
8000
7978
|
});
|
|
8001
7979
|
}
|
|
8002
|
-
}), null);
|
|
8003
|
-
insert(_el$, createComponent(NotificationsStyled, {}), null);
|
|
8004
|
-
createRenderEffect((_p$) => {
|
|
8005
|
-
var _a2, _b2;
|
|
8006
|
-
const _v$ = position.strategy, _v$2 = `${(_a2 = position.y) != null ? _a2 : 0}px`, _v$3 = `${(_b2 = position.x) != null ? _b2 : 0}px`;
|
|
8007
|
-
_v$ !== _p$._v$ && _el$.style.setProperty("position", _p$._v$ = _v$);
|
|
8008
|
-
_v$2 !== _p$._v$2 && _el$.style.setProperty("top", _p$._v$2 = _v$2);
|
|
8009
|
-
_v$3 !== _p$._v$3 && _el$.style.setProperty("left", _p$._v$3 = _v$3);
|
|
8010
|
-
return _p$;
|
|
8011
|
-
}, {
|
|
8012
|
-
_v$: void 0,
|
|
8013
|
-
_v$2: void 0,
|
|
8014
|
-
_v$3: void 0
|
|
8015
7980
|
});
|
|
8016
|
-
return _el$;
|
|
8017
7981
|
}
|
|
8018
|
-
})
|
|
7982
|
+
}), null);
|
|
7983
|
+
insert(_el$, createComponent(NotificationsStyled, {}), null);
|
|
7984
|
+
createRenderEffect((_p$) => {
|
|
7985
|
+
var _a2, _b2;
|
|
7986
|
+
const _v$ = position.strategy, _v$2 = `${(_a2 = position.y) != null ? _a2 : 0}px`, _v$3 = `${(_b2 = position.x) != null ? _b2 : 0}px`;
|
|
7987
|
+
_v$ !== _p$._v$ && _el$.style.setProperty("position", _p$._v$ = _v$);
|
|
7988
|
+
_v$2 !== _p$._v$2 && _el$.style.setProperty("top", _p$._v$2 = _v$2);
|
|
7989
|
+
_v$3 !== _p$._v$3 && _el$.style.setProperty("left", _p$._v$3 = _v$3);
|
|
7990
|
+
return _p$;
|
|
7991
|
+
}, {
|
|
7992
|
+
_v$: void 0,
|
|
7993
|
+
_v$2: void 0,
|
|
7994
|
+
_v$3: void 0
|
|
7995
|
+
});
|
|
7996
|
+
return _el$;
|
|
8019
7997
|
}
|
|
8020
|
-
});
|
|
7998
|
+
})];
|
|
8021
7999
|
}
|
|
8022
|
-
})
|
|
8000
|
+
});
|
|
8023
8001
|
}
|
|
8024
8002
|
})];
|
|
8025
8003
|
}
|
|
@@ -10139,6 +10117,14 @@ const TextStyled = styled(Text)`
|
|
|
10139
10117
|
|
|
10140
10118
|
color: ${(props) => props.theme.colors.text.secondary};
|
|
10141
10119
|
`;
|
|
10120
|
+
const LoaderButtonStyled = styled(Button)`
|
|
10121
|
+
min-width: 112px;
|
|
10122
|
+
margin-top: 32px;
|
|
10123
|
+
`;
|
|
10124
|
+
const LoaderIconStyled = styled(LoaderIcon)`
|
|
10125
|
+
height: 16px;
|
|
10126
|
+
width: 16px;
|
|
10127
|
+
`;
|
|
10142
10128
|
const ButtonStyled = styled(Button)`
|
|
10143
10129
|
margin-top: 32px;
|
|
10144
10130
|
`;
|
|
@@ -10146,6 +10132,11 @@ const ActionModal = (props) => {
|
|
|
10146
10132
|
const dataAttrs = useDataAttributes(props);
|
|
10147
10133
|
const tonConnectUI = useContext(TonConnectUiContext);
|
|
10148
10134
|
const [firstClick, setFirstClick] = createSignal(true);
|
|
10135
|
+
const [sent, setSent] = createSignal(false);
|
|
10136
|
+
createEffect(() => {
|
|
10137
|
+
const currentAction = action();
|
|
10138
|
+
setSent(!!currentAction && "sent" in currentAction && currentAction.sent);
|
|
10139
|
+
});
|
|
10149
10140
|
let universalLink;
|
|
10150
10141
|
if ((tonConnectUI == null ? void 0 : tonConnectUI.wallet) && "universalLink" in tonConnectUI.wallet && (tonConnectUI.wallet.openMethod === "universal-link" || sdk.isTelegramUrl(tonConnectUI.wallet.universalLink) && isInTMA())) {
|
|
10151
10142
|
universalLink = tonConnectUI.wallet.universalLink;
|
|
@@ -10191,33 +10182,53 @@ const ActionModal = (props) => {
|
|
|
10191
10182
|
}
|
|
10192
10183
|
}), createComponent(Show, {
|
|
10193
10184
|
get when() {
|
|
10194
|
-
return
|
|
10185
|
+
return !sent();
|
|
10195
10186
|
},
|
|
10196
10187
|
get children() {
|
|
10197
|
-
return createComponent(
|
|
10198
|
-
|
|
10188
|
+
return createComponent(LoaderButtonStyled, {
|
|
10189
|
+
disabled: true,
|
|
10190
|
+
"data-tc-connect-button-loading": "true",
|
|
10199
10191
|
get children() {
|
|
10200
|
-
return createComponent(
|
|
10201
|
-
translationKey: "common.close",
|
|
10202
|
-
children: "Close"
|
|
10203
|
-
});
|
|
10192
|
+
return createComponent(LoaderIconStyled, {});
|
|
10204
10193
|
}
|
|
10205
10194
|
});
|
|
10206
10195
|
}
|
|
10207
10196
|
}), createComponent(Show, {
|
|
10208
10197
|
get when() {
|
|
10209
|
-
return
|
|
10198
|
+
return sent();
|
|
10210
10199
|
},
|
|
10211
10200
|
get children() {
|
|
10212
|
-
return createComponent(
|
|
10213
|
-
|
|
10201
|
+
return [createComponent(Show, {
|
|
10202
|
+
get when() {
|
|
10203
|
+
return props.showButton !== "open-wallet";
|
|
10204
|
+
},
|
|
10214
10205
|
get children() {
|
|
10215
|
-
return createComponent(
|
|
10216
|
-
|
|
10217
|
-
children
|
|
10206
|
+
return createComponent(ButtonStyled, {
|
|
10207
|
+
onClick: () => props.onClose(),
|
|
10208
|
+
get children() {
|
|
10209
|
+
return createComponent(Translation, {
|
|
10210
|
+
translationKey: "common.close",
|
|
10211
|
+
children: "Close"
|
|
10212
|
+
});
|
|
10213
|
+
}
|
|
10218
10214
|
});
|
|
10219
10215
|
}
|
|
10220
|
-
})
|
|
10216
|
+
}), createComponent(Show, {
|
|
10217
|
+
get when() {
|
|
10218
|
+
return props.showButton === "open-wallet" && universalLink;
|
|
10219
|
+
},
|
|
10220
|
+
get children() {
|
|
10221
|
+
return createComponent(ButtonStyled, {
|
|
10222
|
+
onClick: onOpenWallet,
|
|
10223
|
+
get children() {
|
|
10224
|
+
return createComponent(Translation, {
|
|
10225
|
+
translationKey: "common.openWallet",
|
|
10226
|
+
children: "Open wallet"
|
|
10227
|
+
});
|
|
10228
|
+
}
|
|
10229
|
+
});
|
|
10230
|
+
}
|
|
10231
|
+
})];
|
|
10221
10232
|
}
|
|
10222
10233
|
})];
|
|
10223
10234
|
}
|
|
@@ -10849,9 +10860,19 @@ class TonConnectUI {
|
|
|
10849
10860
|
widgetController.setAction({
|
|
10850
10861
|
name: "confirm-transaction",
|
|
10851
10862
|
showNotification: notifications2.includes("before"),
|
|
10852
|
-
openModal: modals.includes("before")
|
|
10863
|
+
openModal: modals.includes("before"),
|
|
10864
|
+
sent: false
|
|
10853
10865
|
});
|
|
10854
10866
|
const onRequestSent = () => {
|
|
10867
|
+
if (abortController.signal.aborted) {
|
|
10868
|
+
return;
|
|
10869
|
+
}
|
|
10870
|
+
widgetController.setAction({
|
|
10871
|
+
name: "confirm-transaction",
|
|
10872
|
+
showNotification: notifications2.includes("before"),
|
|
10873
|
+
openModal: modals.includes("before"),
|
|
10874
|
+
sent: true
|
|
10875
|
+
});
|
|
10855
10876
|
const userOSIsIos = getUserAgent().os === "ios";
|
|
10856
10877
|
const shouldSkipRedirectToWallet = skipRedirectToWallet === "ios" && userOSIsIos || skipRedirectToWallet === "always";
|
|
10857
10878
|
if (this.walletInfo && "universalLink" in this.walletInfo && this.walletInfo.openMethod === "universal-link" && !shouldSkipRedirectToWallet) {
|
|
@@ -10880,7 +10901,7 @@ class TonConnectUI {
|
|
|
10880
10901
|
const result = yield this.waitForSendTransaction(
|
|
10881
10902
|
{
|
|
10882
10903
|
transaction: tx,
|
|
10883
|
-
|
|
10904
|
+
signal: abortController.signal
|
|
10884
10905
|
},
|
|
10885
10906
|
onRequestSent
|
|
10886
10907
|
);
|
|
@@ -10940,15 +10961,15 @@ class TonConnectUI {
|
|
|
10940
10961
|
});
|
|
10941
10962
|
return yield this.waitForWalletConnection({
|
|
10942
10963
|
ignoreErrors: true,
|
|
10943
|
-
|
|
10964
|
+
signal: abortController.signal
|
|
10944
10965
|
});
|
|
10945
10966
|
});
|
|
10946
10967
|
}
|
|
10947
10968
|
waitForWalletConnection(options) {
|
|
10948
10969
|
return __async(this, null, function* () {
|
|
10949
10970
|
return new Promise((resolve, reject) => {
|
|
10950
|
-
const { ignoreErrors = false,
|
|
10951
|
-
if (
|
|
10971
|
+
const { ignoreErrors = false, signal = null } = options;
|
|
10972
|
+
if (signal && signal.aborted) {
|
|
10952
10973
|
return reject(new TonConnectUIError("Wallet was not connected"));
|
|
10953
10974
|
}
|
|
10954
10975
|
const onStatusChangeHandler = (wallet) => __async(this, null, function* () {
|
|
@@ -10974,11 +10995,15 @@ class TonConnectUI {
|
|
|
10974
10995
|
(wallet) => onStatusChangeHandler(wallet),
|
|
10975
10996
|
(reason) => onErrorsHandler(reason)
|
|
10976
10997
|
);
|
|
10977
|
-
if (
|
|
10978
|
-
|
|
10979
|
-
|
|
10980
|
-
|
|
10981
|
-
|
|
10998
|
+
if (signal) {
|
|
10999
|
+
signal.addEventListener(
|
|
11000
|
+
"abort",
|
|
11001
|
+
() => {
|
|
11002
|
+
unsubscribe();
|
|
11003
|
+
reject(new TonConnectUIError("Wallet was not connected"));
|
|
11004
|
+
},
|
|
11005
|
+
{ once: true }
|
|
11006
|
+
);
|
|
10982
11007
|
}
|
|
10983
11008
|
});
|
|
10984
11009
|
});
|
|
@@ -10986,8 +11011,8 @@ class TonConnectUI {
|
|
|
10986
11011
|
waitForSendTransaction(options, onRequestSent) {
|
|
10987
11012
|
return __async(this, null, function* () {
|
|
10988
11013
|
return new Promise((resolve, reject) => {
|
|
10989
|
-
const { transaction,
|
|
10990
|
-
if (
|
|
11014
|
+
const { transaction, signal } = options;
|
|
11015
|
+
if (signal.aborted) {
|
|
10991
11016
|
return reject(new TonConnectUIError("Transaction was not sent"));
|
|
10992
11017
|
}
|
|
10993
11018
|
const onTransactionHandler = (transaction2) => __async(this, null, function* () {
|
|
@@ -10996,10 +11021,14 @@ class TonConnectUI {
|
|
|
10996
11021
|
const onErrorsHandler = (reason) => {
|
|
10997
11022
|
reject(reason);
|
|
10998
11023
|
};
|
|
10999
|
-
this.connector.sendTransaction(transaction, onRequestSent).then((result) => onTransactionHandler(result)).catch((reason) => onErrorsHandler(reason));
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
-
|
|
11024
|
+
this.connector.sendTransaction(transaction, { onRequestSent, signal }).then((result) => onTransactionHandler(result)).catch((reason) => onErrorsHandler(reason));
|
|
11025
|
+
signal.addEventListener(
|
|
11026
|
+
"abort",
|
|
11027
|
+
() => {
|
|
11028
|
+
reject(new TonConnectUIError("Transaction was not sent"));
|
|
11029
|
+
},
|
|
11030
|
+
{ once: true }
|
|
11031
|
+
);
|
|
11003
11032
|
});
|
|
11004
11033
|
});
|
|
11005
11034
|
}
|