@tonconnect/ui-react 0.0.6 → 0.0.8
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 +47 -0
- package/lib/components/TonConnectUIProvider.d.ts +10 -2
- package/lib/components/index.d.ts +2 -2
- package/lib/index.d.ts +1 -3
- package/lib/index.js +69 -23
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +69 -23
- package/lib/index.umd.js.map +1 -1
- package/lib/library.d.ts +3 -0
- package/package.json +6 -3
package/lib/index.umd.js
CHANGED
|
@@ -4747,11 +4747,16 @@ var __objRest = (source, exclude) => {
|
|
|
4747
4747
|
TonConnect.walletsList = new WalletsListManager();
|
|
4748
4748
|
TonConnect.isWalletInjected = (walletJSKey) => InjectedProvider.isWalletInjected(walletJSKey);
|
|
4749
4749
|
TonConnect.isInsideWalletBrowser = (walletJSKey) => InjectedProvider.isInsideWalletBrowser(walletJSKey);
|
|
4750
|
-
|
|
4750
|
+
const bounceableTag$1 = 17;
|
|
4751
|
+
const testOnlyTag$1 = 128;
|
|
4752
|
+
function toUserFriendlyAddress$1(hexAddress, testOnly = false) {
|
|
4751
4753
|
const { wc, hex } = parseHexAddress$1(hexAddress);
|
|
4752
|
-
|
|
4754
|
+
let tag = bounceableTag$1;
|
|
4755
|
+
if (testOnly) {
|
|
4756
|
+
tag |= testOnlyTag$1;
|
|
4757
|
+
}
|
|
4753
4758
|
const addr = new Int8Array(34);
|
|
4754
|
-
addr[0] =
|
|
4759
|
+
addr[0] = tag;
|
|
4755
4760
|
addr[1] = wc;
|
|
4756
4761
|
addr.set(hex, 2);
|
|
4757
4762
|
const addressWithChecksum = new Uint8Array(36);
|
|
@@ -8065,7 +8070,7 @@ var __objRest = (source, exclude) => {
|
|
|
8065
8070
|
const connector = useContext(ConnectorContext);
|
|
8066
8071
|
const [isCopiedShown, setIsCopiedShown] = createSignal(false);
|
|
8067
8072
|
const onCopy = () => __async(void 0, null, function* () {
|
|
8068
|
-
const userFriendlyAddress = toUserFriendlyAddress$1(tonConnectUi.account.address);
|
|
8073
|
+
const userFriendlyAddress = toUserFriendlyAddress$1(tonConnectUi.account.address, tonConnectUi.account.chain === CHAIN$1.TESTNET);
|
|
8069
8074
|
yield copyToClipboard(userFriendlyAddress);
|
|
8070
8075
|
setIsCopiedShown(true);
|
|
8071
8076
|
setTimeout(() => setIsCopiedShown(false), 1e3);
|
|
@@ -9140,7 +9145,7 @@ var __objRest = (source, exclude) => {
|
|
|
9140
9145
|
const connector = useContext(ConnectorContext);
|
|
9141
9146
|
const tonConnectUI2 = useContext(TonConnectUiContext);
|
|
9142
9147
|
const [isOpened, setIsOpened] = createSignal(false);
|
|
9143
|
-
const [
|
|
9148
|
+
const [account, setAccount] = createSignal(null);
|
|
9144
9149
|
let dropDownRef;
|
|
9145
9150
|
const [floating, setFloating] = createSignal();
|
|
9146
9151
|
const [anchor, setAnchor] = createSignal();
|
|
@@ -9149,8 +9154,9 @@ var __objRest = (source, exclude) => {
|
|
|
9149
9154
|
placement: "bottom-end"
|
|
9150
9155
|
});
|
|
9151
9156
|
const normalizedAddress = () => {
|
|
9152
|
-
|
|
9153
|
-
|
|
9157
|
+
const acc = account();
|
|
9158
|
+
if (acc) {
|
|
9159
|
+
const userFriendlyAddress = toUserFriendlyAddress$1(acc.address, acc.chain === CHAIN$1.TESTNET);
|
|
9154
9160
|
return userFriendlyAddress.slice(0, 4) + "..." + userFriendlyAddress.slice(-4);
|
|
9155
9161
|
}
|
|
9156
9162
|
return "";
|
|
@@ -9158,13 +9164,13 @@ var __objRest = (source, exclude) => {
|
|
|
9158
9164
|
const unsubscribe = connector.onStatusChange((wallet) => {
|
|
9159
9165
|
if (!wallet) {
|
|
9160
9166
|
setIsOpened(false);
|
|
9161
|
-
|
|
9167
|
+
setAccount(null);
|
|
9162
9168
|
return;
|
|
9163
9169
|
}
|
|
9164
|
-
|
|
9170
|
+
setAccount(wallet.account);
|
|
9165
9171
|
});
|
|
9166
9172
|
const onClick = (e2) => {
|
|
9167
|
-
if (!
|
|
9173
|
+
if (!account() || !isOpened()) {
|
|
9168
9174
|
return;
|
|
9169
9175
|
}
|
|
9170
9176
|
const clickToButton = anchor().contains(e2.target);
|
|
@@ -9182,7 +9188,7 @@ var __objRest = (source, exclude) => {
|
|
|
9182
9188
|
});
|
|
9183
9189
|
return [createComponent(Show, {
|
|
9184
9190
|
get when() {
|
|
9185
|
-
return !
|
|
9191
|
+
return !account();
|
|
9186
9192
|
},
|
|
9187
9193
|
get children() {
|
|
9188
9194
|
return createComponent(AccountButtonStyled, {
|
|
@@ -9208,7 +9214,7 @@ var __objRest = (source, exclude) => {
|
|
|
9208
9214
|
}
|
|
9209
9215
|
}), createComponent(Show, {
|
|
9210
9216
|
get when() {
|
|
9211
|
-
return
|
|
9217
|
+
return account();
|
|
9212
9218
|
},
|
|
9213
9219
|
get children() {
|
|
9214
9220
|
return createComponent(DropdownContainerStyled, {
|
|
@@ -9312,6 +9318,11 @@ var __objRest = (source, exclude) => {
|
|
|
9312
9318
|
display: flex;
|
|
9313
9319
|
align-items: center;
|
|
9314
9320
|
justify-content: center;
|
|
9321
|
+
|
|
9322
|
+
> svg {
|
|
9323
|
+
height: 276px;
|
|
9324
|
+
width: 276px;
|
|
9325
|
+
}
|
|
9315
9326
|
}
|
|
9316
9327
|
|
|
9317
9328
|
rect {
|
|
@@ -11085,7 +11096,7 @@ var __objRest = (source, exclude) => {
|
|
|
11085
11096
|
const universalLink = connector.connect({
|
|
11086
11097
|
universalLink: props.wallet.universalLink,
|
|
11087
11098
|
bridgeUrl: props.wallet.bridgeUrl
|
|
11088
|
-
});
|
|
11099
|
+
}, props.additionalRequest);
|
|
11089
11100
|
return createComponent(QrCodeModalStyled, {
|
|
11090
11101
|
get id() {
|
|
11091
11102
|
return props.id;
|
|
@@ -11148,7 +11159,7 @@ var __objRest = (source, exclude) => {
|
|
|
11148
11159
|
return createComponent(ActionButtonStyled, {
|
|
11149
11160
|
onClick: () => connector.connect({
|
|
11150
11161
|
jsBridgeKey: props.wallet.jsBridgeKey
|
|
11151
|
-
}),
|
|
11162
|
+
}, props.additionalRequest),
|
|
11152
11163
|
get children() {
|
|
11153
11164
|
return createComponent(Translation, {
|
|
11154
11165
|
translationKey: "walletModal.qrCodeModal.openExtension",
|
|
@@ -11418,6 +11429,22 @@ var __objRest = (source, exclude) => {
|
|
|
11418
11429
|
const connector = useContext(ConnectorContext);
|
|
11419
11430
|
const tonConnectUI2 = useContext(TonConnectUiContext);
|
|
11420
11431
|
const [fetchedWalletsList] = createResource(() => tonConnectUI2.getWallets());
|
|
11432
|
+
const [fetchedAdditionalRequest, {
|
|
11433
|
+
refetch
|
|
11434
|
+
}] = createResource((_, {
|
|
11435
|
+
refetching
|
|
11436
|
+
}) => {
|
|
11437
|
+
var _a;
|
|
11438
|
+
if (refetching) {
|
|
11439
|
+
return (_a = appState.getConnectParameters) == null ? void 0 : _a.call(appState);
|
|
11440
|
+
}
|
|
11441
|
+
return void 0;
|
|
11442
|
+
});
|
|
11443
|
+
createEffect(on(walletsModalOpen, () => {
|
|
11444
|
+
if (walletsModalOpen() && fetchedAdditionalRequest.state !== "refreshing") {
|
|
11445
|
+
refetch();
|
|
11446
|
+
}
|
|
11447
|
+
}));
|
|
11421
11448
|
const [selectedWalletInfo, setSelectedWalletInfo] = createSignal(null);
|
|
11422
11449
|
const walletsList = createMemo(() => {
|
|
11423
11450
|
if (fetchedWalletsList.state !== "ready") {
|
|
@@ -11425,6 +11452,13 @@ var __objRest = (source, exclude) => {
|
|
|
11425
11452
|
}
|
|
11426
11453
|
return applyWalletsListConfiguration(fetchedWalletsList(), appState.walletsList);
|
|
11427
11454
|
});
|
|
11455
|
+
const additionalRequestLoading = () => fetchedAdditionalRequest.state !== "ready" && fetchedAdditionalRequest.state !== "errored";
|
|
11456
|
+
const additionalRequest = createMemo(() => {
|
|
11457
|
+
if (fetchedAdditionalRequest.state !== "ready") {
|
|
11458
|
+
return void 0;
|
|
11459
|
+
}
|
|
11460
|
+
return fetchedAdditionalRequest();
|
|
11461
|
+
});
|
|
11428
11462
|
const onClose = () => {
|
|
11429
11463
|
setWalletsModalOpen(false);
|
|
11430
11464
|
setSelectedWalletInfo(null);
|
|
@@ -11447,13 +11481,13 @@ var __objRest = (source, exclude) => {
|
|
|
11447
11481
|
const universalLink = connector.connect({
|
|
11448
11482
|
universalLink: walletInfo.universalLink,
|
|
11449
11483
|
bridgeUrl: walletInfo.bridgeUrl
|
|
11450
|
-
});
|
|
11484
|
+
}, additionalRequest());
|
|
11451
11485
|
openLink(universalLink);
|
|
11452
11486
|
};
|
|
11453
11487
|
const onSelectIfInjected = (walletInfo) => {
|
|
11454
11488
|
connector.connect({
|
|
11455
11489
|
jsBridgeKey: walletInfo.jsBridgeKey
|
|
11456
|
-
});
|
|
11490
|
+
}, additionalRequest());
|
|
11457
11491
|
};
|
|
11458
11492
|
const unsubscribe = connector.onStatusChange((wallet) => {
|
|
11459
11493
|
if (wallet) {
|
|
@@ -11470,7 +11504,7 @@ var __objRest = (source, exclude) => {
|
|
|
11470
11504
|
get children() {
|
|
11471
11505
|
return [createComponent(Show, {
|
|
11472
11506
|
get when() {
|
|
11473
|
-
return !walletsList();
|
|
11507
|
+
return !walletsList() || additionalRequestLoading();
|
|
11474
11508
|
},
|
|
11475
11509
|
get children() {
|
|
11476
11510
|
return [createComponent(H1Styled$1, {
|
|
@@ -11484,7 +11518,7 @@ var __objRest = (source, exclude) => {
|
|
|
11484
11518
|
}
|
|
11485
11519
|
}), createComponent(Show, {
|
|
11486
11520
|
get when() {
|
|
11487
|
-
return walletsList();
|
|
11521
|
+
return createMemo(() => !!walletsList())() && !additionalRequestLoading();
|
|
11488
11522
|
},
|
|
11489
11523
|
get children() {
|
|
11490
11524
|
return [createComponent(Show, {
|
|
@@ -11508,6 +11542,9 @@ var __objRest = (source, exclude) => {
|
|
|
11508
11542
|
keyed: false,
|
|
11509
11543
|
get children() {
|
|
11510
11544
|
return createComponent(QrCodeModal, {
|
|
11545
|
+
get additionalRequest() {
|
|
11546
|
+
return additionalRequest();
|
|
11547
|
+
},
|
|
11511
11548
|
get wallet() {
|
|
11512
11549
|
return selectedWalletInfo();
|
|
11513
11550
|
},
|
|
@@ -11788,7 +11825,10 @@ var __objRest = (source, exclude) => {
|
|
|
11788
11825
|
});
|
|
11789
11826
|
}
|
|
11790
11827
|
this.uiOptions = mergeOptions(options, { uiPreferences: { theme: "SYSTEM" } });
|
|
11791
|
-
setAppState({
|
|
11828
|
+
setAppState({
|
|
11829
|
+
connector: this.connector,
|
|
11830
|
+
getConnectParameters: options == null ? void 0 : options.getConnectParameters
|
|
11831
|
+
});
|
|
11792
11832
|
widgetController.renderApp(rootId, this);
|
|
11793
11833
|
}
|
|
11794
11834
|
static getWallets() {
|
|
@@ -14825,11 +14865,16 @@ var __objRest = (source, exclude) => {
|
|
|
14825
14865
|
}
|
|
14826
14866
|
return t2;
|
|
14827
14867
|
};
|
|
14828
|
-
|
|
14868
|
+
const bounceableTag = 17;
|
|
14869
|
+
const testOnlyTag = 128;
|
|
14870
|
+
function toUserFriendlyAddress(hexAddress, testOnly = false) {
|
|
14829
14871
|
const { wc, hex } = parseHexAddress(hexAddress);
|
|
14830
|
-
|
|
14872
|
+
let tag = bounceableTag;
|
|
14873
|
+
if (testOnly) {
|
|
14874
|
+
tag |= testOnlyTag;
|
|
14875
|
+
}
|
|
14831
14876
|
const addr = new Int8Array(34);
|
|
14832
|
-
addr[0] =
|
|
14877
|
+
addr[0] = tag;
|
|
14833
14878
|
addr[1] = wc;
|
|
14834
14879
|
addr.set(hex, 2);
|
|
14835
14880
|
const addressWithChecksum = new Uint8Array(36);
|
|
@@ -14909,7 +14954,7 @@ var __objRest = (source, exclude) => {
|
|
|
14909
14954
|
function useTonAddress(userFriendly = true) {
|
|
14910
14955
|
const wallet = useTonWallet();
|
|
14911
14956
|
if (wallet) {
|
|
14912
|
-
return userFriendly ? toUserFriendlyAddress(wallet.account.address) : wallet.account.address;
|
|
14957
|
+
return userFriendly ? toUserFriendlyAddress(wallet.account.address, wallet.account.chain === CHAIN.TESTNET) : wallet.account.address;
|
|
14913
14958
|
} else {
|
|
14914
14959
|
return "";
|
|
14915
14960
|
}
|
|
@@ -14918,6 +14963,7 @@ var __objRest = (source, exclude) => {
|
|
|
14918
14963
|
exports.TonConnectButton = TonConnectButton$1;
|
|
14919
14964
|
exports.TonConnectProviderNotSetError = TonConnectProviderNotSetError;
|
|
14920
14965
|
exports.TonConnectUI = TonConnectUI;
|
|
14966
|
+
exports.TonConnectUIContext = TonConnectUIContext;
|
|
14921
14967
|
exports.TonConnectUIError = TonConnectUIError;
|
|
14922
14968
|
exports.TonConnectUIProvider = TonConnectUIProvider$1;
|
|
14923
14969
|
exports.TonConnectUIReactError = TonConnectUIReactError;
|