@tonconnect/sdk 0.0.42 → 0.0.44
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-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/{errors → cjs/errors}/dapp/dapp-metadata.error.js +0 -0
- package/lib/{errors → cjs/errors}/index.js +0 -0
- package/lib/{errors → cjs/errors}/protocol/events/connect/index.js +0 -0
- package/lib/{errors → cjs/errors}/protocol/events/connect/manifest-content-error.error.js +0 -0
- package/lib/{errors → cjs/errors}/protocol/events/connect/manifest-not-found.error.js +0 -0
- package/lib/{errors → cjs/errors}/protocol/events/connect/user-rejects.error.js +0 -0
- package/lib/{errors → cjs/errors}/protocol/events/index.js +0 -0
- package/lib/{errors → cjs/errors}/protocol/index.js +0 -0
- package/lib/{errors → cjs/errors}/protocol/responses/bad-request.error.js +0 -0
- package/lib/{errors → cjs/errors}/protocol/responses/index.js +0 -0
- package/lib/{errors → cjs/errors}/protocol/responses/unknown-app.error.js +0 -0
- package/lib/{errors → cjs/errors}/storage/index.js +0 -0
- package/lib/{errors → cjs/errors}/storage/localstorage-not-found.error.js +0 -0
- package/lib/{errors → cjs/errors}/ton-connect.error.js +0 -0
- package/lib/{errors → cjs/errors}/unknown.error.js +0 -0
- package/lib/{errors → cjs/errors}/wallet/index.js +0 -0
- package/lib/{errors → cjs/errors}/wallet/wallet-already-connected.error.js +0 -0
- package/lib/{errors → cjs/errors}/wallet/wallet-not-connected.error.js +0 -0
- package/lib/{errors → cjs/errors}/wallet/wallet-not-injected.error.js +0 -0
- package/lib/{errors → cjs/errors}/wallet/wallet-not-support-feature.error.js +0 -0
- package/lib/{errors → cjs/errors}/wallets-manager/fetch-wallets.error.js +0 -0
- package/lib/{errors → cjs/errors}/wallets-manager/index.js +0 -0
- package/lib/{index.js → cjs/index.js} +0 -0
- package/lib/{models → cjs/models}/dapp/dapp-metadata.js +0 -0
- package/lib/{models → cjs/models}/index.js +0 -0
- package/lib/{models → cjs/models}/methods/connect/connect-additional-request.js +0 -0
- package/lib/{models → cjs/models}/methods/connect/index.js +0 -0
- package/lib/{models → cjs/models}/methods/index.js +0 -0
- package/lib/{models → cjs/models}/methods/send-transaction/index.js +0 -0
- package/lib/{models → cjs/models}/methods/send-transaction/send-transaction-request.js +0 -0
- package/lib/{models → cjs/models}/methods/send-transaction/send-transaction-response.js +0 -0
- package/lib/{models → cjs/models}/ton-connect-options.js +0 -0
- package/lib/{models → cjs/models}/wallet/account.js +0 -0
- package/lib/{models → cjs/models}/wallet/index.js +0 -0
- package/lib/{models → cjs/models}/wallet/wallet-connection-source.js +0 -0
- package/lib/{models → cjs/models}/wallet/wallet-info.js +0 -0
- package/lib/{models → cjs/models}/wallet/wallet.js +0 -0
- package/lib/{parsers → cjs/parsers}/connect-errors-parser.js +0 -0
- package/lib/{parsers → cjs/parsers}/rpc-parser.js +0 -0
- package/lib/{parsers → cjs/parsers}/send-transaction-parser.js +0 -0
- package/lib/{provider → cjs/provider}/bridge/bridge-gateway.js +14 -0
- package/lib/{provider → cjs/provider}/bridge/bridge-provider.js +2 -25
- package/lib/{provider → cjs/provider}/bridge/models/bridge-connection.js +0 -0
- package/lib/{provider → cjs/provider}/bridge/models/bridge-incomming-message.js +0 -0
- package/lib/{provider → cjs/provider}/bridge/models/bridge-session-raw.js +0 -0
- package/lib/{provider → cjs/provider}/bridge/models/bridge-session.js +0 -0
- package/lib/{provider → cjs/provider}/injected/injected-provider.js +2 -25
- package/lib/{provider → cjs/provider}/injected/models/injected-wallet-api.js +0 -0
- package/lib/{provider → cjs/provider}/provider.js +0 -0
- package/lib/cjs/resources/protocol.js +4 -0
- package/lib/{storage → cjs/storage}/bridge-connection-storage.js +0 -0
- package/lib/{storage → cjs/storage}/default-storage.js +0 -0
- package/lib/{storage → cjs/storage}/http-bridge-gateway-storage.js +0 -0
- package/lib/{storage → cjs/storage}/models/storage.interface.js +0 -0
- package/lib/{ton-connect.interface.js → cjs/ton-connect.interface.js} +0 -0
- package/lib/{ton-connect.js → cjs/ton-connect.js} +1 -1
- package/lib/{utils → cjs/utils}/options.js +0 -0
- package/lib/{utils → cjs/utils}/types.js +0 -0
- package/lib/{utils → cjs/utils}/url.js +0 -0
- package/lib/{utils → cjs/utils}/web-api.js +0 -0
- package/lib/{wallets-list-manager.js → cjs/wallets-list-manager.js} +0 -0
- package/lib/esm/errors/dapp/dapp-metadata.error.js +10 -0
- package/lib/{errors/index.d.ts → esm/errors/index.js} +0 -0
- package/lib/{errors/protocol/events/connect/index.d.ts → esm/errors/protocol/events/connect/index.js} +0 -0
- package/lib/esm/errors/protocol/events/connect/manifest-content-error.error.js +11 -0
- package/lib/esm/errors/protocol/events/connect/manifest-not-found.error.js +11 -0
- package/lib/esm/errors/protocol/events/connect/user-rejects.error.js +10 -0
- package/lib/{errors/protocol/events/index.d.ts → esm/errors/protocol/events/index.js} +0 -0
- package/lib/{errors/protocol/index.d.ts → esm/errors/protocol/index.js} +0 -0
- package/lib/esm/errors/protocol/responses/bad-request.error.js +10 -0
- package/lib/{errors/protocol/responses/index.d.ts → esm/errors/protocol/responses/index.js} +0 -0
- package/lib/esm/errors/protocol/responses/unknown-app.error.js +10 -0
- package/lib/{errors/storage/index.d.ts → esm/errors/storage/index.js} +0 -0
- package/lib/esm/errors/storage/localstorage-not-found.error.js +10 -0
- package/lib/esm/errors/ton-connect.error.js +13 -0
- package/lib/esm/errors/unknown.error.js +10 -0
- package/lib/{errors/wallet/index.d.ts → esm/errors/wallet/index.js} +0 -0
- package/lib/esm/errors/wallet/wallet-already-connected.error.js +10 -0
- package/lib/esm/errors/wallet/wallet-not-connected.error.js +10 -0
- package/lib/esm/errors/wallet/wallet-not-injected.error.js +10 -0
- package/lib/esm/errors/wallet/wallet-not-support-feature.error.js +10 -0
- package/lib/esm/errors/wallets-manager/fetch-wallets.error.js +10 -0
- package/lib/{errors/wallets-manager/index.d.ts → esm/errors/wallets-manager/index.js} +0 -0
- package/lib/esm/index.js +5 -0
- package/lib/esm/models/dapp/dapp-metadata.js +1 -0
- package/lib/esm/models/index.js +2 -0
- package/lib/esm/models/methods/connect/connect-additional-request.js +1 -0
- package/lib/esm/models/methods/connect/index.js +1 -0
- package/lib/{models/methods/index.d.ts → esm/models/methods/index.js} +0 -0
- package/lib/esm/models/methods/send-transaction/index.js +1 -0
- package/lib/esm/models/methods/send-transaction/send-transaction-request.js +1 -0
- package/lib/esm/models/methods/send-transaction/send-transaction-response.js +1 -0
- package/lib/esm/models/ton-connect-options.js +1 -0
- package/lib/esm/models/wallet/account.js +1 -0
- package/lib/esm/models/wallet/index.js +1 -0
- package/lib/esm/models/wallet/wallet-connection-source.js +3 -0
- package/lib/esm/models/wallet/wallet-info.js +3 -0
- package/lib/esm/models/wallet/wallet.js +1 -0
- package/lib/esm/parsers/connect-errors-parser.js +23 -0
- package/lib/esm/parsers/rpc-parser.js +5 -0
- package/lib/esm/parsers/send-transaction-parser.js +31 -0
- package/lib/esm/provider/bridge/bridge-gateway.js +105 -0
- package/lib/esm/provider/bridge/bridge-provider.js +140 -0
- package/lib/esm/provider/bridge/models/bridge-connection.js +1 -0
- package/lib/esm/provider/bridge/models/bridge-incomming-message.js +1 -0
- package/lib/esm/provider/bridge/models/bridge-session-raw.js +1 -0
- package/lib/esm/provider/bridge/models/bridge-session.js +1 -0
- package/lib/esm/provider/injected/injected-provider.js +121 -0
- package/lib/esm/provider/injected/models/injected-wallet-api.js +1 -0
- package/lib/esm/provider/provider.js +1 -0
- package/lib/esm/resources/protocol.js +1 -0
- package/lib/esm/storage/bridge-connection-storage.js +96 -0
- package/lib/esm/storage/default-storage.js +35 -0
- package/lib/esm/storage/http-bridge-gateway-storage.js +34 -0
- package/lib/esm/storage/models/storage.interface.js +1 -0
- package/lib/esm/ton-connect.interface.js +1 -0
- package/lib/esm/ton-connect.js +252 -0
- package/lib/esm/utils/options.js +8 -0
- package/lib/esm/utils/types.js +1 -0
- package/lib/esm/utils/url.js +9 -0
- package/lib/esm/utils/web-api.js +20 -0
- package/lib/esm/wallets-list-manager.js +91 -0
- package/lib/{errors → types/errors}/dapp/dapp-metadata.error.d.ts +0 -0
- package/lib/types/errors/index.d.ts +6 -0
- package/lib/types/errors/protocol/events/connect/index.d.ts +1 -0
- package/lib/{errors → types/errors}/protocol/events/connect/manifest-content-error.error.d.ts +0 -0
- package/lib/{errors → types/errors}/protocol/events/connect/manifest-not-found.error.d.ts +0 -0
- package/lib/{errors → types/errors}/protocol/events/connect/user-rejects.error.d.ts +0 -0
- package/lib/types/errors/protocol/events/index.d.ts +1 -0
- package/lib/types/errors/protocol/index.d.ts +2 -0
- package/lib/{errors → types/errors}/protocol/responses/bad-request.error.d.ts +0 -0
- package/lib/types/errors/protocol/responses/index.d.ts +2 -0
- package/lib/{errors → types/errors}/protocol/responses/unknown-app.error.d.ts +0 -0
- package/lib/types/errors/storage/index.d.ts +1 -0
- package/lib/{errors → types/errors}/storage/localstorage-not-found.error.d.ts +0 -0
- package/lib/{errors → types/errors}/ton-connect.error.d.ts +0 -0
- package/lib/{errors → types/errors}/unknown.error.d.ts +0 -0
- package/lib/types/errors/wallet/index.d.ts +3 -0
- package/lib/{errors → types/errors}/wallet/wallet-already-connected.error.d.ts +0 -0
- package/lib/{errors → types/errors}/wallet/wallet-not-connected.error.d.ts +0 -0
- package/lib/{errors → types/errors}/wallet/wallet-not-injected.error.d.ts +0 -0
- package/lib/{errors → types/errors}/wallet/wallet-not-support-feature.error.d.ts +0 -0
- package/lib/{errors → types/errors}/wallets-manager/fetch-wallets.error.d.ts +0 -0
- package/lib/types/errors/wallets-manager/index.d.ts +1 -0
- package/lib/{index.d.ts → types/index.d.ts} +0 -0
- package/lib/{models → types/models}/dapp/dapp-metadata.d.ts +0 -0
- package/lib/{models → types/models}/index.d.ts +0 -0
- package/lib/{models → types/models}/methods/connect/connect-additional-request.d.ts +1 -1
- package/lib/{models → types/models}/methods/connect/index.d.ts +0 -0
- package/lib/types/models/methods/index.d.ts +2 -0
- package/lib/{models → types/models}/methods/send-transaction/index.d.ts +0 -0
- package/lib/{models → types/models}/methods/send-transaction/send-transaction-request.d.ts +0 -0
- package/lib/{models → types/models}/methods/send-transaction/send-transaction-response.d.ts +0 -0
- package/lib/{models → types/models}/ton-connect-options.d.ts +0 -0
- package/lib/{models → types/models}/wallet/account.d.ts +0 -0
- package/lib/{models → types/models}/wallet/index.d.ts +0 -0
- package/lib/{models → types/models}/wallet/wallet-connection-source.d.ts +0 -0
- package/lib/{models → types/models}/wallet/wallet-info.d.ts +0 -0
- package/lib/{models → types/models}/wallet/wallet.d.ts +0 -0
- package/lib/{parsers → types/parsers}/connect-errors-parser.d.ts +0 -0
- package/lib/{parsers → types/parsers}/rpc-parser.d.ts +0 -0
- package/lib/{parsers → types/parsers}/send-transaction-parser.d.ts +0 -0
- package/lib/{provider → types/provider}/bridge/bridge-gateway.d.ts +1 -0
- package/lib/{provider → types/provider}/bridge/bridge-provider.d.ts +0 -0
- package/lib/{provider → types/provider}/bridge/models/bridge-connection.d.ts +0 -0
- package/lib/{provider → types/provider}/bridge/models/bridge-incomming-message.d.ts +0 -0
- package/lib/{provider → types/provider}/bridge/models/bridge-session-raw.d.ts +0 -0
- package/lib/{provider → types/provider}/bridge/models/bridge-session.d.ts +0 -0
- package/lib/{provider → types/provider}/injected/injected-provider.d.ts +0 -0
- package/lib/{provider → types/provider}/injected/models/injected-wallet-api.d.ts +0 -0
- package/lib/{provider → types/provider}/provider.d.ts +0 -0
- package/lib/types/resources/protocol.d.ts +1 -0
- package/lib/{storage → types/storage}/bridge-connection-storage.d.ts +0 -0
- package/lib/{storage → types/storage}/default-storage.d.ts +0 -0
- package/lib/{storage → types/storage}/http-bridge-gateway-storage.d.ts +0 -0
- package/lib/{storage → types/storage}/models/storage.interface.d.ts +0 -0
- package/lib/{ton-connect.d.ts → types/ton-connect.d.ts} +0 -0
- package/lib/{ton-connect.interface.d.ts → types/ton-connect.interface.d.ts} +0 -0
- package/lib/{utils → types/utils}/options.d.ts +0 -0
- package/lib/{utils → types/utils}/types.d.ts +0 -0
- package/lib/{utils → types/utils}/url.d.ts +0 -0
- package/lib/{utils → types/utils}/web-api.d.ts +0 -0
- package/lib/{wallets-list-manager.d.ts → types/wallets-list-manager.d.ts} +0 -0
- package/package.json +15 -6
- package/lib/resources/protocol.json +0 -3
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -31,6 +31,7 @@ class BridgeGateway {
|
|
|
31
31
|
this.errorsListener = errorsListener;
|
|
32
32
|
this.ssePath = 'events';
|
|
33
33
|
this.postPath = 'message';
|
|
34
|
+
this.heartbeatMessage = 'heartbeat';
|
|
34
35
|
this.defaultTtl = 300;
|
|
35
36
|
this.isClosed = false;
|
|
36
37
|
this.bridgeGatewayStorage = new http_bridge_gateway_storage_1.HttpBridgeGatewayStorage(storage);
|
|
@@ -72,12 +73,25 @@ class BridgeGateway {
|
|
|
72
73
|
(_a = this.eventSource) === null || _a === void 0 ? void 0 : _a.close();
|
|
73
74
|
}
|
|
74
75
|
errorsHandler(e) {
|
|
76
|
+
var _a, _b;
|
|
75
77
|
if (!this.isClosed) {
|
|
78
|
+
if (((_a = this.eventSource) === null || _a === void 0 ? void 0 : _a.readyState) === EventSource.CLOSED) {
|
|
79
|
+
this.eventSource.close();
|
|
80
|
+
this.registerSession();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (((_b = this.eventSource) === null || _b === void 0 ? void 0 : _b.readyState) === EventSource.CONNECTING) {
|
|
84
|
+
console.debug('[TON_CONNET_SDK_ERROR]: Bridge error', JSON.stringify(e));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
76
87
|
this.errorsListener(e);
|
|
77
88
|
}
|
|
78
89
|
}
|
|
79
90
|
messagesHandler(e) {
|
|
80
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
if (e.data === this.heartbeatMessage) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
81
95
|
yield this.bridgeGatewayStorage.storeLastEventId(e.lastEventId);
|
|
82
96
|
if (!this.isClosed) {
|
|
83
97
|
let bridgeIncomingMessage;
|
|
@@ -1,27 +1,4 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,7 +14,7 @@ const protocol_1 = require("@tonconnect/protocol");
|
|
|
37
14
|
const ton_connect_error_1 = require("../../errors/ton-connect.error");
|
|
38
15
|
const bridge_gateway_1 = require("./bridge-gateway");
|
|
39
16
|
const bridge_connection_storage_1 = require("../../storage/bridge-connection-storage");
|
|
40
|
-
const
|
|
17
|
+
const protocol_2 = require("../../resources/protocol");
|
|
41
18
|
class BridgeProvider {
|
|
42
19
|
constructor(storage, walletConnectionSource) {
|
|
43
20
|
this.storage = storage;
|
|
@@ -158,7 +135,7 @@ class BridgeProvider {
|
|
|
158
135
|
}
|
|
159
136
|
generateUniversalLink(message) {
|
|
160
137
|
const url = new URL(this.walletConnectionSource.universalLink);
|
|
161
|
-
url.searchParams.append('v',
|
|
138
|
+
url.searchParams.append('v', protocol_2.PROTOCOL_VERSION.toString());
|
|
162
139
|
url.searchParams.append('id', this.session.sessionCrypto.sessionId);
|
|
163
140
|
url.searchParams.append('r', JSON.stringify(message));
|
|
164
141
|
return url.toString();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,27 +1,4 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -34,9 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
12
|
exports.InjectedProvider = void 0;
|
|
36
13
|
const wallet_not_injected_error_1 = require("../../errors/wallet/wallet-not-injected.error");
|
|
37
|
-
const protocol = __importStar(require("../../resources/protocol.json"));
|
|
38
14
|
const bridge_connection_storage_1 = require("../../storage/bridge-connection-storage");
|
|
39
15
|
const web_api_1 = require("../../utils/web-api");
|
|
16
|
+
const protocol_1 = require("../../resources/protocol");
|
|
40
17
|
class InjectedProvider {
|
|
41
18
|
constructor(injectedWalletKey) {
|
|
42
19
|
this.type = 'injected';
|
|
@@ -73,7 +50,7 @@ class InjectedProvider {
|
|
|
73
50
|
}
|
|
74
51
|
connect(message, auto = false) {
|
|
75
52
|
this.injectedWallet
|
|
76
|
-
.connect(
|
|
53
|
+
.connect(protocol_1.PROTOCOL_VERSION, message, auto)
|
|
77
54
|
.then(connectEvent => {
|
|
78
55
|
if (connectEvent.event === 'connect') {
|
|
79
56
|
this.makeSubscriptions();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when passed DappMetadata is in incorrect format.
|
|
4
|
+
*/
|
|
5
|
+
export class DappMetadataError extends TonConnectError {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
Object.setPrototypeOf(this, DappMetadataError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TonConnectError } from "../../../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when passed manifest contains errors.
|
|
4
|
+
*/
|
|
5
|
+
export class ManifestContentErrorError extends TonConnectError {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message || '' + ManifestContentErrorError.additionalMessage);
|
|
8
|
+
Object.setPrototypeOf(this, ManifestContentErrorError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
ManifestContentErrorError.additionalMessage = '\nPassed `tonconnect-manifest.json` contains errors. Check format of your manifest. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TonConnectError } from "../../../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when wallet can't get manifest by passed manifestUrl.
|
|
4
|
+
*/
|
|
5
|
+
export class ManifestNotFoundError extends TonConnectError {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message || '' + ManifestNotFoundError.additionalMessage);
|
|
8
|
+
Object.setPrototypeOf(this, ManifestNotFoundError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
ManifestNotFoundError.additionalMessage = '\nManifest not found. Make sure you added `tonconnect-manifest.json` to the root of your app or passed correct manifestUrl. See more https://github.com/ton-connect/docs/blob/main/requests-responses.md#app-manifest';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TonConnectError } from "../../../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when user rejects the action in the wallet.
|
|
4
|
+
*/
|
|
5
|
+
export class UserRejectsError extends TonConnectError {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
Object.setPrototypeOf(this, UserRejectsError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TonConnectError } from "../../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when request to the wallet contains errors.
|
|
4
|
+
*/
|
|
5
|
+
export class BadRequestError extends TonConnectError {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TonConnectError } from "../../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when app tries to send rpc request to the injected wallet while not connected.
|
|
4
|
+
*/
|
|
5
|
+
export class UnknownAppError extends TonConnectError {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
Object.setPrototypeOf(this, UnknownAppError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when `Storage` was not specified in the `DappMetadata` and default `localStorage` was not detected in the environment.
|
|
4
|
+
*/
|
|
5
|
+
export class LocalstorageNotFoundError extends TonConnectError {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
Object.setPrototypeOf(this, LocalstorageNotFoundError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for TonConnect errors. You can check if the error was triggered by the @tonconnect/sdk using `err instanceof TonConnectError`.
|
|
3
|
+
*/
|
|
4
|
+
export class TonConnectError extends Error {
|
|
5
|
+
constructor(message, options) {
|
|
6
|
+
if (message) {
|
|
7
|
+
message = TonConnectError.prefix + ' ' + message;
|
|
8
|
+
}
|
|
9
|
+
super(message, options);
|
|
10
|
+
Object.setPrototypeOf(this, TonConnectError.prototype);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
TonConnectError.prefix = '[TON_CONNECT_SDK_ERROR]';
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when wallet connection called but wallet already connected. To avoid the error, disconnect the wallet before doing a new connection.
|
|
4
|
+
*/
|
|
5
|
+
export class WalletAlreadyConnectedError extends TonConnectError {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
Object.setPrototypeOf(this, WalletAlreadyConnectedError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when send transaction or other protocol methods called while wallet is not connected.
|
|
4
|
+
*/
|
|
5
|
+
export class WalletNotConnectedError extends TonConnectError {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
Object.setPrototypeOf(this, WalletNotConnectedError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when there is an attempt to connect to the injected wallet while it is not exists in the webpage.
|
|
4
|
+
*/
|
|
5
|
+
export class WalletNotInjectedError extends TonConnectError {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
Object.setPrototypeOf(this, WalletNotInjectedError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when wallet doesn't support requested feature method.
|
|
4
|
+
*/
|
|
5
|
+
export class WalletNotSupportFeatureError extends TonConnectError {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
Object.setPrototypeOf(this, WalletNotSupportFeatureError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TonConnectError } from "../ton-connect.error";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when an error occurred while fetching the wallets list.
|
|
4
|
+
*/
|
|
5
|
+
export class FetchWalletsError extends TonConnectError {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
Object.setPrototypeOf(this, FetchWalletsError.prototype);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
File without changes
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isWalletInfoInjected } from './wallet-info';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BadRequestError, UnknownAppError, UserRejectsError } from "../errors";
|
|
2
|
+
import { ManifestContentErrorError } from "../errors/protocol/events/connect/manifest-content-error.error";
|
|
3
|
+
import { ManifestNotFoundError } from "../errors/protocol/events/connect/manifest-not-found.error";
|
|
4
|
+
import { UnknownError } from "../errors/unknown.error";
|
|
5
|
+
import { CONNECT_EVENT_ERROR_CODES } from '@tonconnect/protocol';
|
|
6
|
+
const connectEventErrorsCodes = {
|
|
7
|
+
[CONNECT_EVENT_ERROR_CODES.UNKNOWN_ERROR]: UnknownError,
|
|
8
|
+
[CONNECT_EVENT_ERROR_CODES.USER_REJECTS_ERROR]: UserRejectsError,
|
|
9
|
+
[CONNECT_EVENT_ERROR_CODES.BAD_REQUEST_ERROR]: BadRequestError,
|
|
10
|
+
[CONNECT_EVENT_ERROR_CODES.UNKNOWN_APP_ERROR]: UnknownAppError,
|
|
11
|
+
[CONNECT_EVENT_ERROR_CODES.MANIFEST_NOT_FOUND_ERROR]: ManifestNotFoundError,
|
|
12
|
+
[CONNECT_EVENT_ERROR_CODES.MANIFEST_CONTENT_ERROR]: ManifestContentErrorError
|
|
13
|
+
};
|
|
14
|
+
class ConnectErrorsParser {
|
|
15
|
+
parseError(error) {
|
|
16
|
+
let ErrorConstructor = UnknownError;
|
|
17
|
+
if (error.code in connectEventErrorsCodes) {
|
|
18
|
+
ErrorConstructor = connectEventErrorsCodes[error.code] || UnknownError;
|
|
19
|
+
}
|
|
20
|
+
return new ErrorConstructor(error.message);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export const connectErrorsParser = new ConnectErrorsParser();
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SEND_TRANSACTION_ERROR_CODES } from '@tonconnect/protocol';
|
|
2
|
+
import { BadRequestError, UnknownAppError, UserRejectsError } from "../errors";
|
|
3
|
+
import { UnknownError } from "../errors/unknown.error";
|
|
4
|
+
import { RpcParser } from "./rpc-parser";
|
|
5
|
+
const sendTransactionErrors = {
|
|
6
|
+
[SEND_TRANSACTION_ERROR_CODES.UNKNOWN_ERROR]: UnknownError,
|
|
7
|
+
[SEND_TRANSACTION_ERROR_CODES.USER_REJECTS_ERROR]: UserRejectsError,
|
|
8
|
+
[SEND_TRANSACTION_ERROR_CODES.BAD_REQUEST_ERROR]: BadRequestError,
|
|
9
|
+
[SEND_TRANSACTION_ERROR_CODES.UNKNOWN_APP_ERROR]: UnknownAppError
|
|
10
|
+
};
|
|
11
|
+
class SendTransactionParser extends RpcParser {
|
|
12
|
+
convertToRpcRequest(request) {
|
|
13
|
+
return {
|
|
14
|
+
method: 'sendTransaction',
|
|
15
|
+
params: [JSON.stringify(request)]
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
parseAndThrowError(response) {
|
|
19
|
+
let ErrorConstructor = UnknownError;
|
|
20
|
+
if (response.error.code in sendTransactionErrors) {
|
|
21
|
+
ErrorConstructor = sendTransactionErrors[response.error.code] || UnknownError;
|
|
22
|
+
}
|
|
23
|
+
throw new ErrorConstructor(response.error.message);
|
|
24
|
+
}
|
|
25
|
+
convertFromRpcResponse(rpcResponse) {
|
|
26
|
+
return {
|
|
27
|
+
boc: rpcResponse.result
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export const sendTransactionParser = new SendTransactionParser();
|