@tonconnect/sdk 0.0.43 → 0.0.45
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 +7 -6
- package/dist/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/errors/address/index.js +5 -0
- package/lib/cjs/errors/address/wrong-address.error.js +11 -0
- package/lib/cjs/errors/binary/base64-encode.error.js +11 -0
- package/lib/cjs/errors/binary/index.js +7 -0
- package/lib/cjs/errors/binary/parse-hex.error.js +11 -0
- package/lib/{errors → cjs/errors}/dapp/dapp-metadata.error.js +0 -0
- package/lib/{errors → cjs/errors}/index.js +2 -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} +3 -1
- 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 +2 -3
- 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} +3 -5
- package/lib/cjs/utils/address.js +87 -0
- 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} +40 -16
- package/lib/esm/errors/address/index.js +1 -0
- package/lib/esm/errors/address/wrong-address.error.js +7 -0
- package/lib/esm/errors/binary/base64-encode.error.js +7 -0
- package/lib/esm/errors/binary/index.js +2 -0
- package/lib/esm/errors/binary/parse-hex.error.js +7 -0
- package/lib/esm/errors/dapp/dapp-metadata.error.js +10 -0
- package/lib/esm/errors/index.js +8 -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 +6 -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/address.js +83 -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 +115 -0
- package/lib/types/errors/address/index.d.ts +1 -0
- package/lib/types/errors/address/wrong-address.error.d.ts +4 -0
- package/lib/types/errors/binary/base64-encode.error.d.ts +4 -0
- package/lib/types/errors/binary/index.d.ts +2 -0
- package/lib/types/errors/binary/parse-hex.error.d.ts +4 -0
- package/lib/{errors → types/errors}/dapp/dapp-metadata.error.d.ts +0 -0
- package/lib/{errors → types/errors}/index.d.ts +2 -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} +1 -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/types/models/methods/connect/connect-additional-request.d.ts +6 -0
- 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 -1
- 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 +14 -7
- 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 +2 -2
- 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} +1 -3
- package/lib/{ton-connect.interface.d.ts → types/ton-connect.interface.d.ts} +1 -3
- package/lib/types/utils/address.d.ts +1 -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/models/methods/connect/connect-additional-request.d.ts +0 -15
- package/lib/models/methods/send-transaction/send-transaction-options.d.ts +0 -11
- package/lib/models/methods/send-transaction/send-transaction-options.js +0 -2
- package/lib/resources/protocol.json +0 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function getWindow() {
|
|
2
|
+
if (typeof window === 'undefined') {
|
|
3
|
+
return undefined;
|
|
4
|
+
}
|
|
5
|
+
return window;
|
|
6
|
+
}
|
|
7
|
+
export function getDocument() {
|
|
8
|
+
if (typeof document === 'undefined') {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
return document;
|
|
12
|
+
}
|
|
13
|
+
export function getWebPageManifest() {
|
|
14
|
+
var _a;
|
|
15
|
+
const origin = (_a = getWindow()) === null || _a === void 0 ? void 0 : _a.location.origin;
|
|
16
|
+
if (origin) {
|
|
17
|
+
return origin + '/tonconnect-manifest.json';
|
|
18
|
+
}
|
|
19
|
+
return '';
|
|
20
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { FetchWalletsError } from "./errors/wallets-manager/fetch-wallets.error";
|
|
11
|
+
import { isWalletInfoInjected } from "./models/wallet/wallet-info";
|
|
12
|
+
import { InjectedProvider } from "./provider/injected/injected-provider";
|
|
13
|
+
export class WalletsListManager {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.walletsListCache = null;
|
|
16
|
+
this.walletsListSource = 'https://raw.githubusercontent.com/ton-connect/wallets-list/main/wallets.json';
|
|
17
|
+
}
|
|
18
|
+
getWallets() {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (!this.walletsListCache) {
|
|
21
|
+
this.walletsListCache = this.fetchWalletsList();
|
|
22
|
+
this.walletsListCache.catch(() => (this.walletsListCache = null));
|
|
23
|
+
}
|
|
24
|
+
return this.walletsListCache;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
getEmbeddedWallet() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const walletsList = yield this.getWallets();
|
|
30
|
+
const injectedWallets = walletsList.filter(isWalletInfoInjected);
|
|
31
|
+
if (injectedWallets.length !== 1) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return injectedWallets[0].embedded ? injectedWallets[0] : null;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
fetchWalletsList() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
try {
|
|
40
|
+
const walletsResponse = yield fetch(this.walletsListSource);
|
|
41
|
+
const walletsList = yield walletsResponse.json();
|
|
42
|
+
if (!Array.isArray(walletsList) ||
|
|
43
|
+
!walletsList.every(wallet => this.isCorrectWalletConfigDTO(wallet))) {
|
|
44
|
+
throw new FetchWalletsError('Wrong wallets list format');
|
|
45
|
+
}
|
|
46
|
+
return this.walletConfigDTOListToWalletConfigList(walletsList);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
throw new FetchWalletsError(e);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
walletConfigDTOListToWalletConfigList(walletConfigDTO) {
|
|
54
|
+
return walletConfigDTO.map(walletConfigDTO => {
|
|
55
|
+
const walletConfig = {
|
|
56
|
+
name: walletConfigDTO.name,
|
|
57
|
+
imageUrl: walletConfigDTO.image,
|
|
58
|
+
aboutUrl: walletConfigDTO.about_url,
|
|
59
|
+
tondns: walletConfigDTO.tondns
|
|
60
|
+
};
|
|
61
|
+
walletConfigDTO.bridge.forEach(bridge => {
|
|
62
|
+
if (bridge.type === 'sse') {
|
|
63
|
+
walletConfig.bridgeUrl = bridge.url;
|
|
64
|
+
walletConfig.universalLink =
|
|
65
|
+
walletConfigDTO.universal_url;
|
|
66
|
+
walletConfig.deepLink = walletConfigDTO.deepLink;
|
|
67
|
+
}
|
|
68
|
+
if (bridge.type === 'js') {
|
|
69
|
+
const jsBridgeKey = bridge.key;
|
|
70
|
+
walletConfig.jsBridgeKey = jsBridgeKey;
|
|
71
|
+
walletConfig.injected =
|
|
72
|
+
InjectedProvider.isWalletInjected(jsBridgeKey);
|
|
73
|
+
walletConfig.embedded =
|
|
74
|
+
InjectedProvider.isInsideWalletBrowser(jsBridgeKey);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return walletConfig;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
isCorrectWalletConfigDTO(value) {
|
|
81
|
+
if (!value || !(typeof value === 'object')) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
const containsName = 'name' in value;
|
|
85
|
+
const containsImage = 'image' in value;
|
|
86
|
+
const containsAbout = 'about_url' in value;
|
|
87
|
+
if (!containsName || !containsImage || !containsAbout) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (!('bridge' in value) ||
|
|
91
|
+
!Array.isArray(value.bridge) ||
|
|
92
|
+
!value.bridge.length) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
const bridge = value.bridge;
|
|
96
|
+
if (bridge.some(item => !item || typeof item !== 'object' || !('type' in item))) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const sseBridge = bridge.find(item => item.type === 'sse');
|
|
100
|
+
if (sseBridge) {
|
|
101
|
+
if (!('url' in sseBridge) ||
|
|
102
|
+
!sseBridge.url ||
|
|
103
|
+
!value.universal_url) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const jsBridge = bridge.find(item => item.type === 'js');
|
|
108
|
+
if (jsBridge) {
|
|
109
|
+
if (!('key' in jsBridge) || !jsBridge.key) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { WrongAddressError } from './wrong-address.error';
|
|
File without changes
|
|
@@ -2,5 +2,7 @@ export * from './protocol';
|
|
|
2
2
|
export * from './wallet';
|
|
3
3
|
export * from './storage';
|
|
4
4
|
export * from './wallets-manager';
|
|
5
|
+
export * from './address';
|
|
6
|
+
export * from './binary';
|
|
5
7
|
export { TonConnectError } from './ton-connect.error';
|
|
6
8
|
export { UnknownError } from './unknown.error';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { UserRejectsError } from "./user-rejects.error";
|
package/lib/{errors → types/errors}/protocol/events/connect/manifest-content-error.error.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './connect';
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { LocalstorageNotFoundError } from './localstorage-not-found.error';
|
|
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 @@
|
|
|
1
|
+
export { FetchWalletsError } from './fetch-wallets.error';
|
|
@@ -5,3 +5,4 @@ export { IStorage } from './storage/models/storage.interface';
|
|
|
5
5
|
export { TonConnect as default } from './ton-connect';
|
|
6
6
|
export { ITonConnect } from './ton-connect.interface';
|
|
7
7
|
export { CHAIN, DeviceInfo } from '@tonconnect/protocol';
|
|
8
|
+
export { toUserFriendlyAddress } from './utils/address';
|
|
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
|
|
@@ -21,6 +21,10 @@ export interface WalletInfoRemote extends WalletInfoBase {
|
|
|
21
21
|
* Base part of the wallet universal url. The link should support [Ton Connect parameters]{@link https://github.com/ton-connect/docs/blob/main/bridge.md#universal-link}.
|
|
22
22
|
*/
|
|
23
23
|
universalLink: string;
|
|
24
|
+
/**
|
|
25
|
+
* Native wallet app deepLink. The link should support [Ton Connect parameters]{@link https://github.com/ton-connect/docs/blob/main/bridge.md#universal-link}.
|
|
26
|
+
*/
|
|
27
|
+
deepLink: string;
|
|
24
28
|
/**
|
|
25
29
|
* Url of the wallet's implementation of the [HTTP bridge]{@link https://github.com/ton-connect/docs/blob/main/bridge.md#http-bridge}.
|
|
26
30
|
*/
|
|
@@ -41,18 +45,21 @@ export interface WalletInfoInjected extends WalletInfoBase {
|
|
|
41
45
|
embedded: boolean;
|
|
42
46
|
}
|
|
43
47
|
export declare type WalletInfo = WalletInfoRemote | WalletInfoInjected | (WalletInfoRemote & WalletInfoInjected);
|
|
44
|
-
export interface
|
|
48
|
+
export interface WalletInfoDTO {
|
|
45
49
|
name: string;
|
|
46
50
|
image: string;
|
|
47
51
|
tondns?: string;
|
|
48
52
|
about_url: string;
|
|
49
|
-
}
|
|
50
|
-
export interface WalletInfoRemoteDTO extends WalletInfoDTOBase {
|
|
51
53
|
universal_url: string;
|
|
52
|
-
|
|
54
|
+
deepLink: string;
|
|
55
|
+
bridge: (WalletInfoBridgeRemoteDTO | WalletInfoBridgeInjectedDTO)[];
|
|
56
|
+
}
|
|
57
|
+
export interface WalletInfoBridgeRemoteDTO {
|
|
58
|
+
type: 'sse';
|
|
59
|
+
url: string;
|
|
53
60
|
}
|
|
54
|
-
export interface
|
|
55
|
-
|
|
61
|
+
export interface WalletInfoBridgeInjectedDTO {
|
|
62
|
+
type: 'js';
|
|
63
|
+
key: string;
|
|
56
64
|
}
|
|
57
|
-
export declare type WalletInfoDTO = WalletInfoRemoteDTO | WalletInfoInjectedDTO | (WalletInfoRemoteDTO & WalletInfoInjectedDTO);
|
|
58
65
|
export declare function isWalletInfoInjected(value: WalletInfo): value is WalletInfoInjected;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SendTransactionRpcRequest, SendTransactionRpcResponseError, SendTransactionRpcResponseSuccess } from '@tonconnect/protocol';
|
|
2
2
|
import { SendTransactionRequest, SendTransactionResponse } from "../models/methods";
|
|
3
3
|
import { RpcParser } from "./rpc-parser";
|
|
4
4
|
import { WithoutId } from "../utils/types";
|
|
5
5
|
declare class SendTransactionParser extends RpcParser<'sendTransaction'> {
|
|
6
6
|
convertToRpcRequest(request: Omit<SendTransactionRequest, 'validUntil'> & {
|
|
7
7
|
valid_until: number;
|
|
8
|
-
}
|
|
8
|
+
}): WithoutId<SendTransactionRpcRequest>;
|
|
9
9
|
parseAndThrowError(response: WithoutId<SendTransactionRpcResponseError>): never;
|
|
10
10
|
convertFromRpcResponse(rpcResponse: WithoutId<SendTransactionRpcResponseSuccess>): SendTransactionResponse;
|
|
11
11
|
}
|
|
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 @@
|
|
|
1
|
+
export declare const PROTOCOL_VERSION = 2;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -5,7 +5,6 @@ import { ConnectAdditionalRequest } from "./models/methods/connect/connect-addit
|
|
|
5
5
|
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
|
-
import { SendTransactionOptions } from "./models/methods/send-transaction/send-transaction-options";
|
|
9
8
|
export declare class TonConnect implements ITonConnect {
|
|
10
9
|
private readonly walletsList;
|
|
11
10
|
private readonly dappSettings;
|
|
@@ -53,11 +52,10 @@ export declare class TonConnect implements ITonConnect {
|
|
|
53
52
|
/**
|
|
54
53
|
* Asks connected wallet to sign and send the transaction.
|
|
55
54
|
* @param transaction transaction to send.
|
|
56
|
-
* @param options request options
|
|
57
55
|
* @returns signed transaction boc that allows you to find the transaction in the blockchain.
|
|
58
56
|
* If user rejects transaction, method will throw the corresponding error.
|
|
59
57
|
*/
|
|
60
|
-
sendTransaction(transaction: SendTransactionRequest
|
|
58
|
+
sendTransaction(transaction: SendTransactionRequest): Promise<SendTransactionResponse>;
|
|
61
59
|
/**
|
|
62
60
|
* Disconnect form thw connected wallet and drop current session.
|
|
63
61
|
*/
|
|
@@ -4,7 +4,6 @@ import { SendTransactionRequest, SendTransactionResponse } from "./models/method
|
|
|
4
4
|
import { ConnectAdditionalRequest } from "./models/methods/connect/connect-additional-request";
|
|
5
5
|
import { WalletInfo } from "./models/wallet/wallet-info";
|
|
6
6
|
import { WalletConnectionSourceJS } from "./models/wallet/wallet-connection-source";
|
|
7
|
-
import { SendTransactionOptions } from "./models/methods/send-transaction/send-transaction-options";
|
|
8
7
|
export interface ITonConnect {
|
|
9
8
|
/**
|
|
10
9
|
* Shows if the wallet is connected right now.
|
|
@@ -47,9 +46,8 @@ export interface ITonConnect {
|
|
|
47
46
|
/**
|
|
48
47
|
* Asks connected wallet to sign and send the transaction.
|
|
49
48
|
* @param transaction transaction to send.
|
|
50
|
-
* @param options request options
|
|
51
49
|
* @returns signed transaction boc that allows you to find the transaction in the blockchain.
|
|
52
50
|
* If user rejects transaction, method will throw the corresponding error.
|
|
53
51
|
*/
|
|
54
|
-
sendTransaction(transaction: SendTransactionRequest
|
|
52
|
+
sendTransaction(transaction: SendTransactionRequest): Promise<SendTransactionResponse>;
|
|
55
53
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toUserFriendlyAddress(hexAddress: string): string;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonconnect/sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.45",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"build": "npx rimraf lib && ttsc && npx rimraf dist && webpack --mode development",
|
|
6
|
-
"build:production": "npx rimraf lib && ttsc --sourceMap false && npx rimraf dist && webpack --mode production"
|
|
5
|
+
"build": "npx rimraf lib && ttsc --outDir ./lib/cjs && ttsc --module esnext --outDir ./lib/esm && npx rimraf dist && webpack --mode development",
|
|
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"
|
|
7
7
|
},
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -28,14 +28,23 @@
|
|
|
28
28
|
"tweetnacl": "^1.0.3",
|
|
29
29
|
"eventsource": "^2.0.2",
|
|
30
30
|
"node-fetch": "^2.6.7",
|
|
31
|
-
"@tonconnect/protocol": "^0.0.
|
|
31
|
+
"@tonconnect/protocol": "^0.0.25"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"lib",
|
|
35
35
|
"dist"
|
|
36
36
|
],
|
|
37
|
-
"main": "./lib/index.js",
|
|
38
|
-
"
|
|
37
|
+
"main": "./lib/cjs/index.js",
|
|
38
|
+
"module": "./lib/esm/index.js",
|
|
39
|
+
"types": "./lib/types/index.d.ts",
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./lib/types/index.d.ts",
|
|
43
|
+
"require": "./lib/cjs/index.js",
|
|
44
|
+
"import": "./lib/esm/index.js",
|
|
45
|
+
"default": "./lib/cjs/index.js"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
39
48
|
"nx": {
|
|
40
49
|
"tags": ["scope:sdk"]
|
|
41
50
|
},
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ReturnStrategy } from '@tonconnect/protocol';
|
|
2
|
-
export interface ConnectAdditionalRequest {
|
|
3
|
-
/**
|
|
4
|
-
* Payload for ton_proof
|
|
5
|
-
*/
|
|
6
|
-
tonProof?: string;
|
|
7
|
-
/**
|
|
8
|
-
* @default 'back'
|
|
9
|
-
* Return strategy for deeplinks when the user accepts or declines the request.
|
|
10
|
-
* - `'back'` means return to the app which initialized deeplink jump (e.g. browser, native app, ...),
|
|
11
|
-
* - `'none'` means no jumps after user action;
|
|
12
|
-
* - a URL: wallet will open this URL after completing the user's action. Note, that you shouldn't pass your app's URL if it is a webpage. This option should be used for native apps to work around possible OS-specific issues with `'back'` option.
|
|
13
|
-
*/
|
|
14
|
-
return?: ReturnStrategy;
|
|
15
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ReturnStrategy } from '@tonconnect/protocol';
|
|
2
|
-
export interface SendTransactionOptions {
|
|
3
|
-
/**
|
|
4
|
-
* @default 'back'
|
|
5
|
-
* Return strategy for deeplinks when the user accepts or declines the request.
|
|
6
|
-
* - `'back'` means return to the app which initialized deeplink jump (e.g. browser, native app, ...),
|
|
7
|
-
* - `'none'` means no jumps after user action;
|
|
8
|
-
* - a URL: wallet will open this URL after completing the user's action. Note, that you shouldn't pass your app's URL if it is a webpage. This option should be used for native apps to work around possible OS-specific issues with `'back'` option.
|
|
9
|
-
*/
|
|
10
|
-
return: ReturnStrategy;
|
|
11
|
-
}
|