@tonconnect/sdk 2.0.0 → 2.0.2

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.
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WrongAddressError = void 0;
4
- const errors_1 = require("..");
5
- class WrongAddressError extends errors_1.TonConnectError {
4
+ const ton_connect_error_1 = require("../ton-connect.error");
5
+ /**
6
+ * Thrown when passed address is in incorrect format.
7
+ */
8
+ class WrongAddressError extends ton_connect_error_1.TonConnectError {
6
9
  constructor(...args) {
7
10
  super(...args);
8
11
  Object.setPrototypeOf(this, WrongAddressError.prototype);
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ParseHexError = exports.Base64EncodeError = void 0;
4
- var base64_encode_error_1 = require("./base64-encode.error");
5
- Object.defineProperty(exports, "Base64EncodeError", { enumerable: true, get: function () { return base64_encode_error_1.Base64EncodeError; } });
3
+ exports.ParseHexError = void 0;
6
4
  var parse_hex_error_1 = require("./parse-hex.error");
7
5
  Object.defineProperty(exports, "ParseHexError", { enumerable: true, get: function () { return parse_hex_error_1.ParseHexError; } });
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ParseHexError = void 0;
4
- const errors_1 = require("..");
5
- class ParseHexError extends errors_1.TonConnectError {
4
+ const ton_connect_error_1 = require("../ton-connect.error");
5
+ /**
6
+ * Thrown when passed hex is in incorrect format.
7
+ */
8
+ class ParseHexError extends ton_connect_error_1.TonConnectError {
6
9
  constructor(...args) {
7
10
  super(...args);
8
11
  Object.setPrototypeOf(this, ParseHexError.prototype);
@@ -76,6 +76,8 @@ class BridgeProvider {
76
76
  var _a;
77
77
  (_a = this.bridge) === null || _a === void 0 ? void 0 : _a.close();
78
78
  this.listeners = [];
79
+ this.session = null;
80
+ this.bridge = null;
79
81
  }
80
82
  disconnect() {
81
83
  var _a;
@@ -19,6 +19,7 @@ var __rest = (this && this.__rest) || function (s, e) {
19
19
  }
20
20
  return t;
21
21
  };
22
+ var _a;
22
23
  Object.defineProperty(exports, "__esModule", { value: true });
23
24
  exports.TonConnect = void 0;
24
25
  const dapp_metadata_error_1 = require("./errors/dapp/dapp-metadata.error");
@@ -63,8 +64,8 @@ class TonConnect {
63
64
  * Current connected account or null if no account is connected.
64
65
  */
65
66
  get account() {
66
- var _a;
67
- return ((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.account) || null;
67
+ var _b;
68
+ return ((_b = this._wallet) === null || _b === void 0 ? void 0 : _b.account) || null;
68
69
  }
69
70
  /**
70
71
  * Current connected wallet or null if no account is connected.
@@ -101,11 +102,11 @@ class TonConnect {
101
102
  };
102
103
  }
103
104
  connect(wallet, request) {
104
- var _a;
105
+ var _b;
105
106
  if (this.connected) {
106
107
  throw new wallet_already_connected_error_1.WalletAlreadyConnectedError();
107
108
  }
108
- (_a = this.provider) === null || _a === void 0 ? void 0 : _a.closeConnection();
109
+ (_b = this.provider) === null || _b === void 0 ? void 0 : _b.closeConnection();
109
110
  this.provider = this.createProvider(wallet);
110
111
  return this.provider.connect(this.createConnectRequest(request));
111
112
  }
@@ -230,8 +231,8 @@ class TonConnect {
230
231
  }
231
232
  }
232
233
  checkFeatureSupport(feature) {
233
- var _a;
234
- if (!((_a = this.wallet) === null || _a === void 0 ? void 0 : _a.device.features.includes(feature))) {
234
+ var _b;
235
+ if (!((_b = this.wallet) === null || _b === void 0 ? void 0 : _b.device.features.includes(feature))) {
235
236
  throw new wallet_not_support_feature_error_1.WalletNotSupportFeatureError();
236
237
  }
237
238
  }
@@ -254,3 +255,9 @@ class TonConnect {
254
255
  }
255
256
  }
256
257
  exports.TonConnect = TonConnect;
258
+ _a = TonConnect;
259
+ TonConnect.walletsList = new wallets_list_manager_1.WalletsListManager();
260
+ /**
261
+ * Returns available wallets list.
262
+ */
263
+ TonConnect.getWallets = _a.walletsList.getWallets();
@@ -1,4 +1,7 @@
1
- import { TonConnectError } from "..";
1
+ import { TonConnectError } from "../ton-connect.error";
2
+ /**
3
+ * Thrown when passed address is in incorrect format.
4
+ */
2
5
  export class WrongAddressError extends TonConnectError {
3
6
  constructor(...args) {
4
7
  super(...args);
@@ -1,2 +1 @@
1
- export { Base64EncodeError } from './base64-encode.error';
2
1
  export { ParseHexError } from './parse-hex.error';
@@ -1,4 +1,7 @@
1
- import { TonConnectError } from "..";
1
+ import { TonConnectError } from "../ton-connect.error";
2
+ /**
3
+ * Thrown when passed hex is in incorrect format.
4
+ */
2
5
  export class ParseHexError extends TonConnectError {
3
6
  constructor(...args) {
4
7
  super(...args);
@@ -73,6 +73,8 @@ export class BridgeProvider {
73
73
  var _a;
74
74
  (_a = this.bridge) === null || _a === void 0 ? void 0 : _a.close();
75
75
  this.listeners = [];
76
+ this.session = null;
77
+ this.bridge = null;
76
78
  }
77
79
  disconnect() {
78
80
  var _a;
@@ -18,6 +18,7 @@ var __rest = (this && this.__rest) || function (s, e) {
18
18
  }
19
19
  return t;
20
20
  };
21
+ var _a;
21
22
  import { DappMetadataError } from "./errors/dapp/dapp-metadata.error";
22
23
  import { ManifestContentErrorError } from "./errors/protocol/events/connect/manifest-content-error.error";
23
24
  import { ManifestNotFoundError } from "./errors/protocol/events/connect/manifest-not-found.error";
@@ -60,8 +61,8 @@ export class TonConnect {
60
61
  * Current connected account or null if no account is connected.
61
62
  */
62
63
  get account() {
63
- var _a;
64
- return ((_a = this._wallet) === null || _a === void 0 ? void 0 : _a.account) || null;
64
+ var _b;
65
+ return ((_b = this._wallet) === null || _b === void 0 ? void 0 : _b.account) || null;
65
66
  }
66
67
  /**
67
68
  * Current connected wallet or null if no account is connected.
@@ -98,11 +99,11 @@ export class TonConnect {
98
99
  };
99
100
  }
100
101
  connect(wallet, request) {
101
- var _a;
102
+ var _b;
102
103
  if (this.connected) {
103
104
  throw new WalletAlreadyConnectedError();
104
105
  }
105
- (_a = this.provider) === null || _a === void 0 ? void 0 : _a.closeConnection();
106
+ (_b = this.provider) === null || _b === void 0 ? void 0 : _b.closeConnection();
106
107
  this.provider = this.createProvider(wallet);
107
108
  return this.provider.connect(this.createConnectRequest(request));
108
109
  }
@@ -227,8 +228,8 @@ export class TonConnect {
227
228
  }
228
229
  }
229
230
  checkFeatureSupport(feature) {
230
- var _a;
231
- if (!((_a = this.wallet) === null || _a === void 0 ? void 0 : _a.device.features.includes(feature))) {
231
+ var _b;
232
+ if (!((_b = this.wallet) === null || _b === void 0 ? void 0 : _b.device.features.includes(feature))) {
232
233
  throw new WalletNotSupportFeatureError();
233
234
  }
234
235
  }
@@ -250,3 +251,9 @@ export class TonConnect {
250
251
  };
251
252
  }
252
253
  }
254
+ _a = TonConnect;
255
+ TonConnect.walletsList = new WalletsListManager();
256
+ /**
257
+ * Returns available wallets list.
258
+ */
259
+ TonConnect.getWallets = _a.walletsList.getWallets();
@@ -1,4 +1,7 @@
1
- import { TonConnectError } from "..";
1
+ import { TonConnectError } from "../ton-connect.error";
2
+ /**
3
+ * Thrown when passed address is in incorrect format.
4
+ */
2
5
  export declare class WrongAddressError extends TonConnectError {
3
- constructor(...args: ConstructorParameters<typeof Error>);
6
+ constructor(...args: ConstructorParameters<typeof TonConnectError>);
4
7
  }
@@ -1,2 +1 @@
1
- export { Base64EncodeError } from './base64-encode.error';
2
1
  export { ParseHexError } from './parse-hex.error';
@@ -1,4 +1,7 @@
1
- import { TonConnectError } from "..";
1
+ import { TonConnectError } from "../ton-connect.error";
2
+ /**
3
+ * Thrown when passed hex is in incorrect format.
4
+ */
2
5
  export declare class ParseHexError extends TonConnectError {
3
- constructor(...args: ConstructorParameters<typeof Error>);
6
+ constructor(...args: ConstructorParameters<typeof TonConnectError>);
4
7
  }
@@ -6,6 +6,11 @@ import { TonConnectOptions } from "./models/ton-connect-options";
6
6
  import { WalletConnectionSourceJS } from "./models/wallet/wallet-connection-source";
7
7
  import { ITonConnect } from "./ton-connect.interface";
8
8
  export declare class TonConnect implements ITonConnect {
9
+ private static readonly walletsList;
10
+ /**
11
+ * Returns available wallets list.
12
+ */
13
+ static getWallets: Promise<WalletInfo[]>;
9
14
  private readonly walletsList;
10
15
  private readonly dappSettings;
11
16
  private readonly bridgeConnectionStorage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonconnect/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "scripts": {
5
5
  "build": "npx rimraf lib && ttsc --outDir ./lib/cjs && ttsc --module esnext --outDir ./lib/esm && npx rimraf dist && webpack --mode development",
6
6
  "build:production": "npx rimraf lib && ttsc --project tsconfig.cjs.json --sourceMap false && ttsc --project tsconfig.esm.json --sourceMap false && npx rimraf dist && webpack --mode production"
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Base64EncodeError = void 0;
4
- const errors_1 = require("..");
5
- class Base64EncodeError extends errors_1.TonConnectError {
6
- constructor(...args) {
7
- super(...args);
8
- Object.setPrototypeOf(this, Base64EncodeError.prototype);
9
- }
10
- }
11
- exports.Base64EncodeError = Base64EncodeError;
@@ -1,7 +0,0 @@
1
- import { TonConnectError } from "..";
2
- export class Base64EncodeError extends TonConnectError {
3
- constructor(...args) {
4
- super(...args);
5
- Object.setPrototypeOf(this, Base64EncodeError.prototype);
6
- }
7
- }
@@ -1,4 +0,0 @@
1
- import { TonConnectError } from "..";
2
- export declare class Base64EncodeError extends TonConnectError {
3
- constructor(...args: ConstructorParameters<typeof Error>);
4
- }