@tonconnect/ui-react 0.0.3 → 0.0.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/README.md +145 -2
- package/lib/components/TonConnectUIProvider.d.ts +32 -1
- package/lib/errors/index.d.ts +1 -1
- package/lib/errors/ton-connect-provider-not-set.error.d.ts +6 -2
- package/lib/errors/ton-connect-ui-react.error.d.ts +4 -1
- package/lib/hooks/useTonAddress.d.ts +4 -0
- package/lib/hooks/useTonConnectUI.d.ts +3 -0
- package/lib/hooks/useTonWallet.d.ts +3 -0
- package/lib/index.js +157 -62
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +157 -62
- package/lib/index.umd.js.map +1 -1
- package/package.json +2 -2
package/lib/index.umd.js
CHANGED
|
@@ -4221,7 +4221,8 @@ var __objRest = (source, exclude) => {
|
|
|
4221
4221
|
});
|
|
4222
4222
|
};
|
|
4223
4223
|
class InjectedProvider {
|
|
4224
|
-
constructor(injectedWalletKey) {
|
|
4224
|
+
constructor(storage, injectedWalletKey) {
|
|
4225
|
+
this.injectedWalletKey = injectedWalletKey;
|
|
4225
4226
|
this.type = "injected";
|
|
4226
4227
|
this.unsubscribeCallback = null;
|
|
4227
4228
|
this.listenSubscriptions = false;
|
|
@@ -4230,13 +4231,14 @@ var __objRest = (source, exclude) => {
|
|
|
4230
4231
|
if (!InjectedProvider.isWindowContainsWallet(window2, injectedWalletKey)) {
|
|
4231
4232
|
throw new WalletNotInjectedError();
|
|
4232
4233
|
}
|
|
4234
|
+
this.connectionStorage = new BridgeConnectionStorage(storage);
|
|
4233
4235
|
this.injectedWallet = window2[injectedWalletKey].tonconnect;
|
|
4234
4236
|
}
|
|
4235
4237
|
static fromStorage(storage) {
|
|
4236
4238
|
return __awaiter$3(this, void 0, void 0, function* () {
|
|
4237
4239
|
const bridgeConnectionStorage = new BridgeConnectionStorage(storage);
|
|
4238
4240
|
const connection = yield bridgeConnectionStorage.getInjectedConnection();
|
|
4239
|
-
return new InjectedProvider(connection.jsBridgeKey);
|
|
4241
|
+
return new InjectedProvider(storage, connection.jsBridgeKey);
|
|
4240
4242
|
});
|
|
4241
4243
|
}
|
|
4242
4244
|
static isWalletInjected(injectedWalletKey) {
|
|
@@ -4251,23 +4253,8 @@ var __objRest = (source, exclude) => {
|
|
|
4251
4253
|
static isWindowContainsWallet(window2, injectedWalletKey) {
|
|
4252
4254
|
return !!window2 && injectedWalletKey in window2 && typeof window2[injectedWalletKey] === "object" && "tonconnect" in window2[injectedWalletKey];
|
|
4253
4255
|
}
|
|
4254
|
-
connect(message
|
|
4255
|
-
this.
|
|
4256
|
-
if (connectEvent.event === "connect") {
|
|
4257
|
-
this.makeSubscriptions();
|
|
4258
|
-
this.listenSubscriptions = true;
|
|
4259
|
-
}
|
|
4260
|
-
this.listeners.forEach((listener) => listener(connectEvent));
|
|
4261
|
-
}).catch((e2) => {
|
|
4262
|
-
const connectEventError = {
|
|
4263
|
-
event: "connect_error",
|
|
4264
|
-
payload: {
|
|
4265
|
-
code: 0,
|
|
4266
|
-
message: e2 === null || e2 === void 0 ? void 0 : e2.toString()
|
|
4267
|
-
}
|
|
4268
|
-
};
|
|
4269
|
-
this.listeners.forEach((listener) => listener(connectEventError));
|
|
4270
|
-
});
|
|
4256
|
+
connect(message) {
|
|
4257
|
+
this._connect(PROTOCOL_VERSION, message);
|
|
4271
4258
|
}
|
|
4272
4259
|
restoreConnection() {
|
|
4273
4260
|
return __awaiter$3(this, void 0, void 0, function* () {
|
|
@@ -4275,10 +4262,12 @@ var __objRest = (source, exclude) => {
|
|
|
4275
4262
|
const connectEvent = yield this.injectedWallet.restoreConnection();
|
|
4276
4263
|
if (connectEvent.event === "connect") {
|
|
4277
4264
|
this.makeSubscriptions();
|
|
4278
|
-
this.listenSubscriptions = true;
|
|
4279
4265
|
this.listeners.forEach((listener) => listener(connectEvent));
|
|
4266
|
+
} else {
|
|
4267
|
+
yield this.connectionStorage.removeConnection();
|
|
4280
4268
|
}
|
|
4281
4269
|
} catch (e2) {
|
|
4270
|
+
yield this.connectionStorage.removeConnection();
|
|
4282
4271
|
console.error(e2);
|
|
4283
4272
|
}
|
|
4284
4273
|
});
|
|
@@ -4292,7 +4281,7 @@ var __objRest = (source, exclude) => {
|
|
|
4292
4281
|
disconnect() {
|
|
4293
4282
|
this.closeAllListeners();
|
|
4294
4283
|
this.injectedWallet.disconnect();
|
|
4295
|
-
return
|
|
4284
|
+
return this.connectionStorage.removeConnection();
|
|
4296
4285
|
}
|
|
4297
4286
|
closeAllListeners() {
|
|
4298
4287
|
var _a;
|
|
@@ -4309,7 +4298,30 @@ var __objRest = (source, exclude) => {
|
|
|
4309
4298
|
return this.injectedWallet.send(Object.assign(Object.assign({}, request), { id: "0" }));
|
|
4310
4299
|
});
|
|
4311
4300
|
}
|
|
4301
|
+
_connect(protocolVersion, message) {
|
|
4302
|
+
return __awaiter$3(this, void 0, void 0, function* () {
|
|
4303
|
+
try {
|
|
4304
|
+
const connectEvent = yield this.injectedWallet.connect(protocolVersion, message);
|
|
4305
|
+
if (connectEvent.event === "connect") {
|
|
4306
|
+
yield this.updateSession();
|
|
4307
|
+
this.makeSubscriptions();
|
|
4308
|
+
}
|
|
4309
|
+
this.listeners.forEach((listener) => listener(connectEvent));
|
|
4310
|
+
} catch (e2) {
|
|
4311
|
+
console.debug(e2);
|
|
4312
|
+
const connectEventError = {
|
|
4313
|
+
event: "connect_error",
|
|
4314
|
+
payload: {
|
|
4315
|
+
code: 0,
|
|
4316
|
+
message: e2 === null || e2 === void 0 ? void 0 : e2.toString()
|
|
4317
|
+
}
|
|
4318
|
+
};
|
|
4319
|
+
this.listeners.forEach((listener) => listener(connectEventError));
|
|
4320
|
+
}
|
|
4321
|
+
});
|
|
4322
|
+
}
|
|
4312
4323
|
makeSubscriptions() {
|
|
4324
|
+
this.listenSubscriptions = true;
|
|
4313
4325
|
this.unsubscribeCallback = this.injectedWallet.listen((e2) => {
|
|
4314
4326
|
if (this.listenSubscriptions) {
|
|
4315
4327
|
this.listeners.forEach((listener) => listener(e2));
|
|
@@ -4319,6 +4331,12 @@ var __objRest = (source, exclude) => {
|
|
|
4319
4331
|
}
|
|
4320
4332
|
});
|
|
4321
4333
|
}
|
|
4334
|
+
updateSession() {
|
|
4335
|
+
return this.connectionStorage.storeConnection({
|
|
4336
|
+
type: "injected",
|
|
4337
|
+
jsBridgeKey: this.injectedWalletKey
|
|
4338
|
+
});
|
|
4339
|
+
}
|
|
4322
4340
|
}
|
|
4323
4341
|
InjectedProvider.window = getWindow$1();
|
|
4324
4342
|
var __awaiter$2 = globalThis && globalThis.__awaiter || function(thisArg, _arguments, P2, generator) {
|
|
@@ -4403,9 +4421,12 @@ var __objRest = (source, exclude) => {
|
|
|
4403
4421
|
});
|
|
4404
4422
|
};
|
|
4405
4423
|
class WalletsListManager {
|
|
4406
|
-
constructor() {
|
|
4424
|
+
constructor(walletsListSource) {
|
|
4407
4425
|
this.walletsListCache = null;
|
|
4408
4426
|
this.walletsListSource = "https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json";
|
|
4427
|
+
if (walletsListSource) {
|
|
4428
|
+
this.walletsListSource = walletsListSource;
|
|
4429
|
+
}
|
|
4409
4430
|
}
|
|
4410
4431
|
getWallets() {
|
|
4411
4432
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
@@ -4419,11 +4440,11 @@ var __objRest = (source, exclude) => {
|
|
|
4419
4440
|
getEmbeddedWallet() {
|
|
4420
4441
|
return __awaiter$1(this, void 0, void 0, function* () {
|
|
4421
4442
|
const walletsList = yield this.getWallets();
|
|
4422
|
-
const
|
|
4423
|
-
if (
|
|
4443
|
+
const embeddedWallets = walletsList.filter((item) => isWalletInfoInjected(item) && item.embedded);
|
|
4444
|
+
if (embeddedWallets.length !== 1) {
|
|
4424
4445
|
return null;
|
|
4425
4446
|
}
|
|
4426
|
-
return
|
|
4447
|
+
return embeddedWallets[0];
|
|
4427
4448
|
});
|
|
4428
4449
|
}
|
|
4429
4450
|
fetchWalletsList() {
|
|
@@ -4546,6 +4567,7 @@ var __objRest = (source, exclude) => {
|
|
|
4546
4567
|
manifestUrl: (options === null || options === void 0 ? void 0 : options.manifestUrl) || getWebPageManifest(),
|
|
4547
4568
|
storage: (options === null || options === void 0 ? void 0 : options.storage) || new DefaultStorage()
|
|
4548
4569
|
};
|
|
4570
|
+
this.walletsList = new WalletsListManager(options === null || options === void 0 ? void 0 : options.walletsListSource);
|
|
4549
4571
|
if (!this.dappSettings.manifestUrl) {
|
|
4550
4572
|
throw new DappMetadataError("Dapp tonconnect-manifest.json must be specified if window.location.origin is undefined. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest");
|
|
4551
4573
|
}
|
|
@@ -4640,7 +4662,7 @@ var __objRest = (source, exclude) => {
|
|
|
4640
4662
|
createProvider(wallet) {
|
|
4641
4663
|
let provider;
|
|
4642
4664
|
if (isWalletConnectionSourceJS(wallet)) {
|
|
4643
|
-
provider = new InjectedProvider(wallet.jsBridgeKey);
|
|
4665
|
+
provider = new InjectedProvider(this.dappSettings.storage, wallet.jsBridgeKey);
|
|
4644
4666
|
} else {
|
|
4645
4667
|
provider = new BridgeProvider(this.dappSettings.storage, wallet);
|
|
4646
4668
|
}
|
|
@@ -4723,6 +4745,8 @@ var __objRest = (source, exclude) => {
|
|
|
4723
4745
|
}
|
|
4724
4746
|
}
|
|
4725
4747
|
TonConnect.walletsList = new WalletsListManager();
|
|
4748
|
+
TonConnect.isWalletInjected = (walletJSKey) => InjectedProvider.isWalletInjected(walletJSKey);
|
|
4749
|
+
TonConnect.isInsideWalletBrowser = (walletJSKey) => InjectedProvider.isInsideWalletBrowser(walletJSKey);
|
|
4726
4750
|
function toUserFriendlyAddress$1(hexAddress) {
|
|
4727
4751
|
const { wc, hex } = parseHexAddress$1(hexAddress);
|
|
4728
4752
|
const bounceableTag = 17;
|
|
@@ -7779,7 +7803,6 @@ var __objRest = (source, exclude) => {
|
|
|
7779
7803
|
const connector = useContext(ConnectorContext);
|
|
7780
7804
|
const [isCopiedShown, setIsCopiedShown] = createSignal(false);
|
|
7781
7805
|
const onCopy = () => __async(void 0, null, function* () {
|
|
7782
|
-
console.log(tonConnectUi.account.address);
|
|
7783
7806
|
const userFriendlyAddress = toUserFriendlyAddress$1(tonConnectUi.account.address);
|
|
7784
7807
|
yield copyToClipboard(userFriendlyAddress);
|
|
7785
7808
|
setIsCopiedShown(true);
|
|
@@ -8829,7 +8852,7 @@ var __objRest = (source, exclude) => {
|
|
|
8829
8852
|
const _tmpl$$3 = /* @__PURE__ */ template$1(`<div></div>`);
|
|
8830
8853
|
const AccountButton = () => {
|
|
8831
8854
|
const connector = useContext(ConnectorContext);
|
|
8832
|
-
const
|
|
8855
|
+
const tonConnectUI2 = useContext(TonConnectUiContext);
|
|
8833
8856
|
const [isOpened, setIsOpened] = createSignal(false);
|
|
8834
8857
|
const [address, setAddress] = createSignal("");
|
|
8835
8858
|
let dropDownRef;
|
|
@@ -8878,7 +8901,7 @@ var __objRest = (source, exclude) => {
|
|
|
8878
8901
|
get children() {
|
|
8879
8902
|
return createComponent(AccountButtonStyled, {
|
|
8880
8903
|
appearance: "flat",
|
|
8881
|
-
onClick: () =>
|
|
8904
|
+
onClick: () => tonConnectUI2.connectWallet(),
|
|
8882
8905
|
get children() {
|
|
8883
8906
|
return [createComponent(TonIcon, {}), createComponent(Text, {
|
|
8884
8907
|
translationKey: "button.connectWallet",
|
|
@@ -11043,17 +11066,79 @@ var __objRest = (source, exclude) => {
|
|
|
11043
11066
|
`;
|
|
11044
11067
|
const [appState, setAppState] = createStore({
|
|
11045
11068
|
buttonRootId: null,
|
|
11046
|
-
language: "en"
|
|
11069
|
+
language: "en",
|
|
11070
|
+
buttonConfiguration: {},
|
|
11071
|
+
widgetConfiguration: {}
|
|
11047
11072
|
});
|
|
11073
|
+
class TonConnectUIError extends TonConnectError$1 {
|
|
11074
|
+
constructor(...args) {
|
|
11075
|
+
super(...args);
|
|
11076
|
+
Object.setPrototypeOf(this, TonConnectUIError.prototype);
|
|
11077
|
+
}
|
|
11078
|
+
}
|
|
11079
|
+
class WalletNotFoundError extends TonConnectUIError {
|
|
11080
|
+
constructor(...args) {
|
|
11081
|
+
super(...args);
|
|
11082
|
+
Object.setPrototypeOf(this, WalletNotFoundError.prototype);
|
|
11083
|
+
}
|
|
11084
|
+
}
|
|
11085
|
+
function uiWalletToWalletInfo(uiWallet) {
|
|
11086
|
+
if ("jsBridgeKey" in uiWallet) {
|
|
11087
|
+
return __spreadProps(__spreadValues({}, uiWallet), {
|
|
11088
|
+
injected: TonConnect.isWalletInjected(uiWallet.jsBridgeKey),
|
|
11089
|
+
embedded: TonConnect.isInsideWalletBrowser(uiWallet.jsBridgeKey)
|
|
11090
|
+
});
|
|
11091
|
+
}
|
|
11092
|
+
return uiWallet;
|
|
11093
|
+
}
|
|
11094
|
+
function applyWalletsListConfiguration(walletsList, configuration) {
|
|
11095
|
+
var _a;
|
|
11096
|
+
if (!configuration) {
|
|
11097
|
+
return walletsList;
|
|
11098
|
+
}
|
|
11099
|
+
if ("wallets" in configuration) {
|
|
11100
|
+
return configuration.wallets.map((wallet) => {
|
|
11101
|
+
if (typeof wallet === "string") {
|
|
11102
|
+
const walletInfo = walletsList.find((item) => item.name === wallet);
|
|
11103
|
+
if (!walletInfo) {
|
|
11104
|
+
throw new WalletNotFoundError(
|
|
11105
|
+
`Wallet with name === '${wallet}' wasn't found in the wallets list. Check ${wallet} correctness.`
|
|
11106
|
+
);
|
|
11107
|
+
}
|
|
11108
|
+
return walletInfo;
|
|
11109
|
+
}
|
|
11110
|
+
return uiWalletToWalletInfo(wallet);
|
|
11111
|
+
});
|
|
11112
|
+
}
|
|
11113
|
+
const filteredWalletsList = ((_a = configuration.excludeWallets) == null ? void 0 : _a.length) ? walletsList.filter(
|
|
11114
|
+
(wallet) => {
|
|
11115
|
+
var _a2;
|
|
11116
|
+
return (_a2 = configuration.excludeWallets) == null ? void 0 : _a2.every((item) => item !== wallet.name);
|
|
11117
|
+
}
|
|
11118
|
+
) : walletsList;
|
|
11119
|
+
if (!configuration.includeWallets) {
|
|
11120
|
+
return filteredWalletsList;
|
|
11121
|
+
}
|
|
11122
|
+
if (configuration.includeWalletsOrder === "start") {
|
|
11123
|
+
return configuration.includeWallets.map(uiWalletToWalletInfo).concat(walletsList);
|
|
11124
|
+
}
|
|
11125
|
+
return walletsList.concat(configuration.includeWallets.map(uiWalletToWalletInfo));
|
|
11126
|
+
}
|
|
11048
11127
|
const WalletsModal = () => {
|
|
11049
11128
|
const {
|
|
11050
11129
|
locale
|
|
11051
11130
|
} = useI18n()[1];
|
|
11052
11131
|
createEffect(() => locale(appState.language));
|
|
11053
11132
|
const connector = useContext(ConnectorContext);
|
|
11054
|
-
const
|
|
11055
|
-
const [
|
|
11133
|
+
const tonConnectUI2 = useContext(TonConnectUiContext);
|
|
11134
|
+
const [fetchedWalletsList] = createResource(() => tonConnectUI2.getWallets());
|
|
11056
11135
|
const [selectedWalletInfo, setSelectedWalletInfo] = createSignal(null);
|
|
11136
|
+
const walletsList = createMemo(() => {
|
|
11137
|
+
if (fetchedWalletsList.state !== "ready") {
|
|
11138
|
+
return null;
|
|
11139
|
+
}
|
|
11140
|
+
return applyWalletsListConfiguration(fetchedWalletsList(), appState.widgetConfiguration.wallets);
|
|
11141
|
+
});
|
|
11057
11142
|
const onClose = () => {
|
|
11058
11143
|
setWalletsModalOpen(false);
|
|
11059
11144
|
setSelectedWalletInfo(null);
|
|
@@ -11066,7 +11151,11 @@ var __objRest = (source, exclude) => {
|
|
|
11066
11151
|
if (isWalletInfoInjected(walletInfo) && walletInfo.injected) {
|
|
11067
11152
|
return onSelectIfInjected(walletInfo);
|
|
11068
11153
|
}
|
|
11069
|
-
|
|
11154
|
+
if ("bridgeUrl" in walletInfo) {
|
|
11155
|
+
setSelectedWalletInfo(walletInfo);
|
|
11156
|
+
return;
|
|
11157
|
+
}
|
|
11158
|
+
openLink(walletInfo.aboutUrl, "_blank");
|
|
11070
11159
|
};
|
|
11071
11160
|
const onSelectIfMobile = (walletInfo) => {
|
|
11072
11161
|
const universalLink = connector.connect({
|
|
@@ -11096,7 +11185,7 @@ var __objRest = (source, exclude) => {
|
|
|
11096
11185
|
get children() {
|
|
11097
11186
|
return [createComponent(Show, {
|
|
11098
11187
|
get when() {
|
|
11099
|
-
return walletsList
|
|
11188
|
+
return !walletsList();
|
|
11100
11189
|
},
|
|
11101
11190
|
get children() {
|
|
11102
11191
|
return [createComponent(H1Styled$1, {
|
|
@@ -11112,7 +11201,7 @@ var __objRest = (source, exclude) => {
|
|
|
11112
11201
|
}
|
|
11113
11202
|
}), createComponent(Show, {
|
|
11114
11203
|
get when() {
|
|
11115
|
-
return walletsList
|
|
11204
|
+
return walletsList();
|
|
11116
11205
|
},
|
|
11117
11206
|
get children() {
|
|
11118
11207
|
return [createComponent(Show, {
|
|
@@ -11338,16 +11427,10 @@ var __objRest = (source, exclude) => {
|
|
|
11338
11427
|
setAction: (action2) => void setTimeout(() => setAction(action2)),
|
|
11339
11428
|
clearAction: () => void setTimeout(() => setAction(null)),
|
|
11340
11429
|
getSelectedWalletInfo: () => lastSelectedWalletInfo(),
|
|
11341
|
-
renderApp: (root,
|
|
11342
|
-
tonConnectUI
|
|
11430
|
+
renderApp: (root, tonConnectUI2) => render(() => createComponent(App, {
|
|
11431
|
+
tonConnectUI: tonConnectUI2
|
|
11343
11432
|
}), document.getElementById(root))
|
|
11344
11433
|
};
|
|
11345
|
-
class TonConnectUIError extends TonConnectError$1 {
|
|
11346
|
-
constructor(...args) {
|
|
11347
|
-
super(...args);
|
|
11348
|
-
Object.setPrototypeOf(this, TonConnectUIError.prototype);
|
|
11349
|
-
}
|
|
11350
|
-
}
|
|
11351
11434
|
class WalletInfoStorage {
|
|
11352
11435
|
constructor() {
|
|
11353
11436
|
__publicField(this, "localStorage");
|
|
@@ -11512,7 +11595,10 @@ var __objRest = (source, exclude) => {
|
|
|
11512
11595
|
if (options && "connector" in options && options.connector) {
|
|
11513
11596
|
this.connector = options.connector;
|
|
11514
11597
|
} else if (options && "manifestUrl" in options && options.manifestUrl) {
|
|
11515
|
-
this.connector = new TonConnect({
|
|
11598
|
+
this.connector = new TonConnect({
|
|
11599
|
+
manifestUrl: options.manifestUrl,
|
|
11600
|
+
walletsListSource: options.walletsListSource
|
|
11601
|
+
});
|
|
11516
11602
|
} else {
|
|
11517
11603
|
throw new TonConnectUIError(
|
|
11518
11604
|
"You have to specify a `manifestUrl` or a `connector` in the options."
|
|
@@ -11522,7 +11608,11 @@ var __objRest = (source, exclude) => {
|
|
|
11522
11608
|
const rootId = this.normalizeWidgetRoot(options == null ? void 0 : options.widgetRootId);
|
|
11523
11609
|
this.subscribeToWalletChange();
|
|
11524
11610
|
if ((options == null ? void 0 : options.restoreConnection) !== false) {
|
|
11525
|
-
this.connector.restoreConnection()
|
|
11611
|
+
this.connector.restoreConnection().then(() => {
|
|
11612
|
+
if (!this.connector.connected) {
|
|
11613
|
+
this.walletInfoStorage.removeWalletInfo();
|
|
11614
|
+
}
|
|
11615
|
+
});
|
|
11526
11616
|
}
|
|
11527
11617
|
this.uiOptions = options || {};
|
|
11528
11618
|
setAppState({ connector: this.connector });
|
|
@@ -11561,11 +11651,11 @@ var __objRest = (source, exclude) => {
|
|
|
11561
11651
|
}
|
|
11562
11652
|
setAppState((state) => {
|
|
11563
11653
|
const merged = mergeOptions(
|
|
11564
|
-
{
|
|
11565
|
-
|
|
11566
|
-
|
|
11654
|
+
__spreadValues(__spreadValues(__spreadValues({}, options.language && { language: options.language }), options.buttonConfiguration && {
|
|
11655
|
+
buttonConfiguration: options.buttonConfiguration
|
|
11656
|
+
}), options.widgetConfiguration && {
|
|
11567
11657
|
widgetConfiguration: options.widgetConfiguration
|
|
11568
|
-
},
|
|
11658
|
+
}),
|
|
11569
11659
|
unwrap(state)
|
|
11570
11660
|
);
|
|
11571
11661
|
if (options.buttonRootId !== void 0) {
|
|
@@ -11653,6 +11743,8 @@ var __objRest = (source, exclude) => {
|
|
|
11653
11743
|
console.error(e2);
|
|
11654
11744
|
throw new TonConnectUIError("Unhandled error:" + e2);
|
|
11655
11745
|
}
|
|
11746
|
+
} finally {
|
|
11747
|
+
widgetController.clearAction();
|
|
11656
11748
|
}
|
|
11657
11749
|
});
|
|
11658
11750
|
}
|
|
@@ -11693,23 +11785,26 @@ var __objRest = (source, exclude) => {
|
|
|
11693
11785
|
}
|
|
11694
11786
|
}
|
|
11695
11787
|
const TonConnectUIContext = require$$0$2.createContext(null);
|
|
11788
|
+
let tonConnectUI = null;
|
|
11696
11789
|
const TonConnectUIProvider = (_a) => {
|
|
11697
11790
|
var _b = _a, {
|
|
11698
11791
|
children: children2
|
|
11699
11792
|
} = _b, options = __objRest(_b, [
|
|
11700
11793
|
"children"
|
|
11701
11794
|
]);
|
|
11702
|
-
|
|
11795
|
+
if (!tonConnectUI) {
|
|
11796
|
+
tonConnectUI = new TonConnectUI(options);
|
|
11797
|
+
}
|
|
11703
11798
|
return /* @__PURE__ */ jsx(TonConnectUIContext.Provider, { value: tonConnectUI, children: children2 });
|
|
11704
11799
|
};
|
|
11705
11800
|
const TonConnectUIProvider$1 = require$$0$2.memo(TonConnectUIProvider);
|
|
11706
|
-
class
|
|
11801
|
+
class TonConnectUIReactError extends TonConnectUIError {
|
|
11707
11802
|
constructor(...args) {
|
|
11708
11803
|
super(...args);
|
|
11709
|
-
Object.setPrototypeOf(this,
|
|
11804
|
+
Object.setPrototypeOf(this, TonConnectUIReactError.prototype);
|
|
11710
11805
|
}
|
|
11711
11806
|
}
|
|
11712
|
-
class TonConnectProviderNotSetError extends
|
|
11807
|
+
class TonConnectProviderNotSetError extends TonConnectUIReactError {
|
|
11713
11808
|
constructor(...args) {
|
|
11714
11809
|
super(...args);
|
|
11715
11810
|
Object.setPrototypeOf(this, TonConnectProviderNotSetError.prototype);
|
|
@@ -11724,10 +11819,10 @@ var __objRest = (source, exclude) => {
|
|
|
11724
11819
|
return true;
|
|
11725
11820
|
}
|
|
11726
11821
|
function useTonConnectUI() {
|
|
11727
|
-
const
|
|
11728
|
-
checkProvider(
|
|
11729
|
-
const setOptions = (options) => void (
|
|
11730
|
-
return [
|
|
11822
|
+
const tonConnectUI2 = require$$0$2.useContext(TonConnectUIContext);
|
|
11823
|
+
checkProvider(tonConnectUI2);
|
|
11824
|
+
const setOptions = (options) => void (tonConnectUI2.uiOptions = options);
|
|
11825
|
+
return [tonConnectUI2, setOptions];
|
|
11731
11826
|
}
|
|
11732
11827
|
const buttonRootId = "ton-connect-button";
|
|
11733
11828
|
const TonConnectButton = ({ className: className2, style: style2 }) => {
|
|
@@ -11739,15 +11834,15 @@ var __objRest = (source, exclude) => {
|
|
|
11739
11834
|
};
|
|
11740
11835
|
const TonConnectButton$1 = require$$0$2.memo(TonConnectButton);
|
|
11741
11836
|
function useTonWallet() {
|
|
11742
|
-
const [
|
|
11837
|
+
const [tonConnectUI2] = useTonConnectUI();
|
|
11743
11838
|
const [wallet, setWallet] = require$$0$2.useState(
|
|
11744
|
-
() =>
|
|
11839
|
+
() => tonConnectUI2.wallet && __spreadValues2(__spreadValues2({}, tonConnectUI2.wallet), tonConnectUI2.walletInfo)
|
|
11745
11840
|
);
|
|
11746
11841
|
require$$0$2.useEffect(
|
|
11747
|
-
() =>
|
|
11842
|
+
() => tonConnectUI2.onStatusChange((value) => {
|
|
11748
11843
|
setWallet(value);
|
|
11749
11844
|
}),
|
|
11750
|
-
[
|
|
11845
|
+
[tonConnectUI2]
|
|
11751
11846
|
);
|
|
11752
11847
|
return wallet;
|
|
11753
11848
|
}
|
|
@@ -14615,7 +14710,7 @@ var __objRest = (source, exclude) => {
|
|
|
14615
14710
|
exports.TonConnectUI = TonConnectUI;
|
|
14616
14711
|
exports.TonConnectUIError = TonConnectUIError;
|
|
14617
14712
|
exports.TonConnectUIProvider = TonConnectUIProvider$1;
|
|
14618
|
-
exports.
|
|
14713
|
+
exports.TonConnectUIReactError = TonConnectUIReactError;
|
|
14619
14714
|
exports.useTonAddress = useTonAddress;
|
|
14620
14715
|
exports.useTonConnectUI = useTonConnectUI;
|
|
14621
14716
|
exports.useTonWallet = useTonWallet;
|