@tonconnect/sdk 0.0.21 → 0.0.23

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.
Files changed (33) hide show
  1. package/lib/errors/dapp/dapp-metadata.error.js +6 -14
  2. package/lib/errors/index.js +18 -5
  3. package/lib/errors/protocol/events/connect/user-rejects.error.js +6 -14
  4. package/lib/errors/protocol/events/index.js +15 -2
  5. package/lib/errors/protocol/index.js +16 -3
  6. package/lib/errors/protocol/responses/bad-request.error.js +6 -14
  7. package/lib/errors/protocol/responses/unknown-app.error.js +6 -14
  8. package/lib/errors/storage/localstorage-not-found.error.js +6 -14
  9. package/lib/errors/ton-connect.error.js +5 -13
  10. package/lib/errors/unknown.error.js +6 -14
  11. package/lib/errors/wallet/wallet-already-connected.error.js +6 -14
  12. package/lib/errors/wallet/wallet-not-connected.error.js +6 -14
  13. package/lib/errors/wallet/wallet-not-injected.error.js +6 -14
  14. package/lib/errors/wallets-manager/fetch-wallets.error.js +6 -14
  15. package/lib/index.js +17 -4
  16. package/lib/models/index.js +16 -3
  17. package/lib/models/methods/index.js +16 -3
  18. package/lib/parsers/connect-errors-parser.js +14 -18
  19. package/lib/parsers/rpc-parser.js +4 -7
  20. package/lib/parsers/send-transaction-parser.js +19 -26
  21. package/lib/provider/bridge/bridge-gateway.js +71 -79
  22. package/lib/provider/bridge/bridge-provider.js +118 -138
  23. package/lib/provider/injected/injected-provider.js +95 -90
  24. package/lib/storage/bridge-connection-storage.js +86 -112
  25. package/lib/storage/default-storage.d.ts +1 -0
  26. package/lib/storage/default-storage.js +28 -22
  27. package/lib/storage/http-bridge-gateway-storage.js +28 -32
  28. package/lib/ton-connect.js +123 -165
  29. package/lib/utils/options.js +5 -5
  30. package/lib/utils/web-api.d.ts +3 -0
  31. package/lib/utils/web-api.js +36 -13
  32. package/lib/wallets-list-manager.js +59 -73
  33. package/package.json +4 -2
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DappMetadataError = void 0;
4
- var tslib_1 = require("tslib");
5
- var ton_connect_error_1 = require("../ton-connect.error");
6
- var DappMetadataError = /** @class */ (function (_super) {
7
- tslib_1.__extends(DappMetadataError, _super);
8
- function DappMetadataError() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var _this = _super.apply(this, args) || this;
14
- Object.setPrototypeOf(_this, DappMetadataError.prototype);
15
- return _this;
4
+ const ton_connect_error_1 = require("../ton-connect.error");
5
+ class DappMetadataError extends ton_connect_error_1.TonConnectError {
6
+ constructor(...args) {
7
+ super(...args);
8
+ Object.setPrototypeOf(this, DappMetadataError.prototype);
16
9
  }
17
- return DappMetadataError;
18
- }(ton_connect_error_1.TonConnectError));
10
+ }
19
11
  exports.DappMetadataError = DappMetadataError;
@@ -1,11 +1,24 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.UnknownError = exports.TonConnectError = void 0;
4
- var tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./protocol"), exports);
6
- tslib_1.__exportStar(require("./wallet"), exports);
7
- tslib_1.__exportStar(require("./storage"), exports);
8
- tslib_1.__exportStar(require("./wallets-manager"), exports);
18
+ __exportStar(require("./protocol"), exports);
19
+ __exportStar(require("./wallet"), exports);
20
+ __exportStar(require("./storage"), exports);
21
+ __exportStar(require("./wallets-manager"), exports);
9
22
  var ton_connect_error_1 = require("./ton-connect.error");
10
23
  Object.defineProperty(exports, "TonConnectError", { enumerable: true, get: function () { return ton_connect_error_1.TonConnectError; } });
11
24
  var unknown_error_1 = require("./unknown.error");
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UserRejectsError = void 0;
4
- var tslib_1 = require("tslib");
5
- var ton_connect_error_1 = require("../../../ton-connect.error");
6
- var UserRejectsError = /** @class */ (function (_super) {
7
- tslib_1.__extends(UserRejectsError, _super);
8
- function UserRejectsError() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var _this = _super.apply(this, args) || this;
14
- Object.setPrototypeOf(_this, UserRejectsError.prototype);
15
- return _this;
4
+ const ton_connect_error_1 = require("../../../ton-connect.error");
5
+ class UserRejectsError extends ton_connect_error_1.TonConnectError {
6
+ constructor(...args) {
7
+ super(...args);
8
+ Object.setPrototypeOf(this, UserRejectsError.prototype);
16
9
  }
17
- return UserRejectsError;
18
- }(ton_connect_error_1.TonConnectError));
10
+ }
19
11
  exports.UserRejectsError = UserRejectsError;
@@ -1,4 +1,17 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./connect"), exports);
17
+ __exportStar(require("./connect"), exports);
@@ -1,5 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./events"), exports);
5
- tslib_1.__exportStar(require("./responses"), exports);
17
+ __exportStar(require("./events"), exports);
18
+ __exportStar(require("./responses"), exports);
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BadRequestError = void 0;
4
- var tslib_1 = require("tslib");
5
- var ton_connect_error_1 = require("../../ton-connect.error");
6
- var BadRequestError = /** @class */ (function (_super) {
7
- tslib_1.__extends(BadRequestError, _super);
8
- function BadRequestError() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var _this = _super.apply(this, args) || this;
14
- Object.setPrototypeOf(_this, BadRequestError.prototype);
15
- return _this;
4
+ const ton_connect_error_1 = require("../../ton-connect.error");
5
+ class BadRequestError extends ton_connect_error_1.TonConnectError {
6
+ constructor(...args) {
7
+ super(...args);
8
+ Object.setPrototypeOf(this, BadRequestError.prototype);
16
9
  }
17
- return BadRequestError;
18
- }(ton_connect_error_1.TonConnectError));
10
+ }
19
11
  exports.BadRequestError = BadRequestError;
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnknownAppError = void 0;
4
- var tslib_1 = require("tslib");
5
- var ton_connect_error_1 = require("../../ton-connect.error");
6
- var UnknownAppError = /** @class */ (function (_super) {
7
- tslib_1.__extends(UnknownAppError, _super);
8
- function UnknownAppError() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var _this = _super.apply(this, args) || this;
14
- Object.setPrototypeOf(_this, UnknownAppError.prototype);
15
- return _this;
4
+ const ton_connect_error_1 = require("../../ton-connect.error");
5
+ class UnknownAppError extends ton_connect_error_1.TonConnectError {
6
+ constructor(...args) {
7
+ super(...args);
8
+ Object.setPrototypeOf(this, UnknownAppError.prototype);
16
9
  }
17
- return UnknownAppError;
18
- }(ton_connect_error_1.TonConnectError));
10
+ }
19
11
  exports.UnknownAppError = UnknownAppError;
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LocalstorageNotFoundError = void 0;
4
- var tslib_1 = require("tslib");
5
- var ton_connect_error_1 = require("../ton-connect.error");
6
- var LocalstorageNotFoundError = /** @class */ (function (_super) {
7
- tslib_1.__extends(LocalstorageNotFoundError, _super);
8
- function LocalstorageNotFoundError() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var _this = _super.apply(this, args) || this;
14
- Object.setPrototypeOf(_this, LocalstorageNotFoundError.prototype);
15
- return _this;
4
+ const ton_connect_error_1 = require("../ton-connect.error");
5
+ class LocalstorageNotFoundError extends ton_connect_error_1.TonConnectError {
6
+ constructor(...args) {
7
+ super(...args);
8
+ Object.setPrototypeOf(this, LocalstorageNotFoundError.prototype);
16
9
  }
17
- return LocalstorageNotFoundError;
18
- }(ton_connect_error_1.TonConnectError));
10
+ }
19
11
  exports.LocalstorageNotFoundError = LocalstorageNotFoundError;
@@ -1,18 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TonConnectError = void 0;
4
- var tslib_1 = require("tslib");
5
- var TonConnectError = /** @class */ (function (_super) {
6
- tslib_1.__extends(TonConnectError, _super);
7
- function TonConnectError() {
8
- var args = [];
9
- for (var _i = 0; _i < arguments.length; _i++) {
10
- args[_i] = arguments[_i];
11
- }
12
- var _this = _super.apply(this, args) || this;
13
- Object.setPrototypeOf(_this, TonConnectError.prototype);
14
- return _this;
4
+ class TonConnectError extends Error {
5
+ constructor(...args) {
6
+ super(...args);
7
+ Object.setPrototypeOf(this, TonConnectError.prototype);
15
8
  }
16
- return TonConnectError;
17
- }(Error));
9
+ }
18
10
  exports.TonConnectError = TonConnectError;
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnknownError = void 0;
4
- var tslib_1 = require("tslib");
5
- var ton_connect_error_1 = require("./ton-connect.error");
6
- var UnknownError = /** @class */ (function (_super) {
7
- tslib_1.__extends(UnknownError, _super);
8
- function UnknownError() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var _this = _super.apply(this, args) || this;
14
- Object.setPrototypeOf(_this, UnknownError.prototype);
15
- return _this;
4
+ const ton_connect_error_1 = require("./ton-connect.error");
5
+ class UnknownError extends ton_connect_error_1.TonConnectError {
6
+ constructor(...args) {
7
+ super(...args);
8
+ Object.setPrototypeOf(this, UnknownError.prototype);
16
9
  }
17
- return UnknownError;
18
- }(ton_connect_error_1.TonConnectError));
10
+ }
19
11
  exports.UnknownError = UnknownError;
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WalletAlreadyConnectedError = void 0;
4
- var tslib_1 = require("tslib");
5
- var ton_connect_error_1 = require("../ton-connect.error");
6
- var WalletAlreadyConnectedError = /** @class */ (function (_super) {
7
- tslib_1.__extends(WalletAlreadyConnectedError, _super);
8
- function WalletAlreadyConnectedError() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var _this = _super.apply(this, args) || this;
14
- Object.setPrototypeOf(_this, WalletAlreadyConnectedError.prototype);
15
- return _this;
4
+ const ton_connect_error_1 = require("../ton-connect.error");
5
+ class WalletAlreadyConnectedError extends ton_connect_error_1.TonConnectError {
6
+ constructor(...args) {
7
+ super(...args);
8
+ Object.setPrototypeOf(this, WalletAlreadyConnectedError.prototype);
16
9
  }
17
- return WalletAlreadyConnectedError;
18
- }(ton_connect_error_1.TonConnectError));
10
+ }
19
11
  exports.WalletAlreadyConnectedError = WalletAlreadyConnectedError;
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WalletNotConnectedError = void 0;
4
- var tslib_1 = require("tslib");
5
- var ton_connect_error_1 = require("../ton-connect.error");
6
- var WalletNotConnectedError = /** @class */ (function (_super) {
7
- tslib_1.__extends(WalletNotConnectedError, _super);
8
- function WalletNotConnectedError() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var _this = _super.apply(this, args) || this;
14
- Object.setPrototypeOf(_this, WalletNotConnectedError.prototype);
15
- return _this;
4
+ const ton_connect_error_1 = require("../ton-connect.error");
5
+ class WalletNotConnectedError extends ton_connect_error_1.TonConnectError {
6
+ constructor(...args) {
7
+ super(...args);
8
+ Object.setPrototypeOf(this, WalletNotConnectedError.prototype);
16
9
  }
17
- return WalletNotConnectedError;
18
- }(ton_connect_error_1.TonConnectError));
10
+ }
19
11
  exports.WalletNotConnectedError = WalletNotConnectedError;
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.WalletNotInjectedError = void 0;
4
- var tslib_1 = require("tslib");
5
- var ton_connect_error_1 = require("../ton-connect.error");
6
- var WalletNotInjectedError = /** @class */ (function (_super) {
7
- tslib_1.__extends(WalletNotInjectedError, _super);
8
- function WalletNotInjectedError() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var _this = _super.apply(this, args) || this;
14
- Object.setPrototypeOf(_this, WalletNotInjectedError.prototype);
15
- return _this;
4
+ const ton_connect_error_1 = require("../ton-connect.error");
5
+ class WalletNotInjectedError extends ton_connect_error_1.TonConnectError {
6
+ constructor(...args) {
7
+ super(...args);
8
+ Object.setPrototypeOf(this, WalletNotInjectedError.prototype);
16
9
  }
17
- return WalletNotInjectedError;
18
- }(ton_connect_error_1.TonConnectError));
10
+ }
19
11
  exports.WalletNotInjectedError = WalletNotInjectedError;
@@ -1,19 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FetchWalletsError = void 0;
4
- var tslib_1 = require("tslib");
5
- var ton_connect_error_1 = require("../ton-connect.error");
6
- var FetchWalletsError = /** @class */ (function (_super) {
7
- tslib_1.__extends(FetchWalletsError, _super);
8
- function FetchWalletsError() {
9
- var args = [];
10
- for (var _i = 0; _i < arguments.length; _i++) {
11
- args[_i] = arguments[_i];
12
- }
13
- var _this = _super.apply(this, args) || this;
14
- Object.setPrototypeOf(_this, FetchWalletsError.prototype);
15
- return _this;
4
+ const ton_connect_error_1 = require("../ton-connect.error");
5
+ class FetchWalletsError extends ton_connect_error_1.TonConnectError {
6
+ constructor(...args) {
7
+ super(...args);
8
+ Object.setPrototypeOf(this, FetchWalletsError.prototype);
16
9
  }
17
- return FetchWalletsError;
18
- }(ton_connect_error_1.TonConnectError));
10
+ }
19
11
  exports.FetchWalletsError = FetchWalletsError;
package/lib/index.js CHANGED
@@ -1,10 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.CHAIN = exports.default = void 0;
4
- var tslib_1 = require("tslib");
5
- tslib_1.__exportStar(require("./ton-connect"), exports);
6
- tslib_1.__exportStar(require("./models"), exports);
7
- tslib_1.__exportStar(require("./errors"), exports);
18
+ __exportStar(require("./ton-connect"), exports);
19
+ __exportStar(require("./models"), exports);
20
+ __exportStar(require("./errors"), exports);
8
21
  var ton_connect_1 = require("./ton-connect");
9
22
  Object.defineProperty(exports, "default", { enumerable: true, get: function () { return ton_connect_1.TonConnect; } });
10
23
  var protocol_1 = require("@tonconnect/protocol");
@@ -1,5 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./wallet"), exports);
5
- tslib_1.__exportStar(require("./methods"), exports);
17
+ __exportStar(require("./wallet"), exports);
18
+ __exportStar(require("./methods"), exports);
@@ -1,5 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./connect"), exports);
5
- tslib_1.__exportStar(require("./send-transaction"), exports);
17
+ __exportStar(require("./connect"), exports);
18
+ __exportStar(require("./send-transaction"), exports);
@@ -1,26 +1,22 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.connectErrorsParser = void 0;
5
- var errors_1 = require("../errors");
6
- var unknown_error_1 = require("../errors/unknown.error");
7
- var protocol_1 = require("@tonconnect/protocol");
8
- var connectEventErrorsCodes = (_a = {},
9
- _a[protocol_1.CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR] = unknown_error_1.UnknownError,
10
- _a[protocol_1.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR] = errors_1.UserRejectsError,
11
- _a[protocol_1.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR] = errors_1.BadRequestError,
12
- _a[protocol_1.CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR] = errors_1.UnknownAppError,
13
- _a);
14
- var ConnectErrorsParser = /** @class */ (function () {
15
- function ConnectErrorsParser() {
16
- }
17
- ConnectErrorsParser.prototype.parseError = function (error) {
18
- var ErrorConstructor = unknown_error_1.UnknownError;
4
+ const errors_1 = require("../errors");
5
+ const unknown_error_1 = require("../errors/unknown.error");
6
+ const protocol_1 = require("@tonconnect/protocol");
7
+ const connectEventErrorsCodes = {
8
+ [protocol_1.CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]: unknown_error_1.UnknownError,
9
+ [protocol_1.CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]: errors_1.UserRejectsError,
10
+ [protocol_1.CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]: errors_1.BadRequestError,
11
+ [protocol_1.CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]: errors_1.UnknownAppError
12
+ };
13
+ class ConnectErrorsParser {
14
+ parseError(error) {
15
+ let ErrorConstructor = unknown_error_1.UnknownError;
19
16
  if (error.code in connectEventErrorsCodes) {
20
17
  ErrorConstructor = connectEventErrorsCodes[error.code] || unknown_error_1.UnknownError;
21
18
  }
22
19
  return new ErrorConstructor(error.message);
23
- };
24
- return ConnectErrorsParser;
25
- }());
20
+ }
21
+ }
26
22
  exports.connectErrorsParser = new ConnectErrorsParser();
@@ -1,12 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RpcParser = void 0;
4
- var RpcParser = /** @class */ (function () {
5
- function RpcParser() {
6
- }
7
- RpcParser.prototype.isError = function (response) {
4
+ class RpcParser {
5
+ isError(response) {
8
6
  return 'error' in response;
9
- };
10
- return RpcParser;
11
- }());
7
+ }
8
+ }
12
9
  exports.RpcParser = RpcParser;
@@ -1,41 +1,34 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.sendTransactionParser = void 0;
5
- var tslib_1 = require("tslib");
6
- var protocol_1 = require("@tonconnect/protocol");
7
- var errors_1 = require("../errors");
8
- var unknown_error_1 = require("../errors/unknown.error");
9
- var rpc_parser_1 = require("./rpc-parser");
10
- var sendTransactionErrors = (_a = {},
11
- _a[protocol_1.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR] = unknown_error_1.UnknownError,
12
- _a[protocol_1.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR] = errors_1.UserRejectsError,
13
- _a[protocol_1.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR] = errors_1.BadRequestError,
14
- _a[protocol_1.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR] = errors_1.UnknownAppError,
15
- _a);
16
- var SendTransactionParser = /** @class */ (function (_super) {
17
- tslib_1.__extends(SendTransactionParser, _super);
18
- function SendTransactionParser() {
19
- return _super !== null && _super.apply(this, arguments) || this;
20
- }
21
- SendTransactionParser.prototype.convertToRpcRequest = function (request) {
4
+ const protocol_1 = require("@tonconnect/protocol");
5
+ const errors_1 = require("../errors");
6
+ const unknown_error_1 = require("../errors/unknown.error");
7
+ const rpc_parser_1 = require("./rpc-parser");
8
+ const sendTransactionErrors = {
9
+ [protocol_1.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]: unknown_error_1.UnknownError,
10
+ [protocol_1.SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]: errors_1.UserRejectsError,
11
+ [protocol_1.SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]: errors_1.BadRequestError,
12
+ [protocol_1.SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]: errors_1.UnknownAppError
13
+ };
14
+ class SendTransactionParser extends rpc_parser_1.RpcParser {
15
+ convertToRpcRequest(request) {
22
16
  return {
23
17
  method: 'sendTransaction',
24
18
  params: [JSON.stringify(request)]
25
19
  };
26
- };
27
- SendTransactionParser.prototype.parseAndThrowError = function (response) {
28
- var ErrorConstructor = unknown_error_1.UnknownError;
20
+ }
21
+ parseAndThrowError(response) {
22
+ let ErrorConstructor = unknown_error_1.UnknownError;
29
23
  if (response.error.code in sendTransactionErrors) {
30
24
  ErrorConstructor = sendTransactionErrors[response.error.code] || unknown_error_1.UnknownError;
31
25
  }
32
26
  throw new ErrorConstructor(response.error.message);
33
- };
34
- SendTransactionParser.prototype.convertFromRpcResponse = function (rpcResponse) {
27
+ }
28
+ convertFromRpcResponse(rpcResponse) {
35
29
  return {
36
30
  boc: rpcResponse.result
37
31
  };
38
- };
39
- return SendTransactionParser;
40
- }(rpc_parser_1.RpcParser));
32
+ }
33
+ }
41
34
  exports.sendTransactionParser = new SendTransactionParser();