@tonconnect/sdk 3.0.8-beta.0 → 3.1.0
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/cjs/index.cjs +50 -53
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +50 -53
- package/lib/esm/index.mjs.map +1 -1
- package/lib/types/index.d.ts +21 -7
- package/package.json +1 -1
package/lib/esm/index.mjs
CHANGED
|
@@ -2042,50 +2042,6 @@ const FALLBACK_WALLETS_LIST = [
|
|
|
2042
2042
|
}
|
|
2043
2043
|
];
|
|
2044
2044
|
|
|
2045
|
-
function checkSendTransactionSupport(features, options) {
|
|
2046
|
-
const supportsDeprecatedSendTransactionFeature = features.includes('SendTransaction');
|
|
2047
|
-
const sendTransactionFeature = features.find(feature => feature && typeof feature === 'object' && feature.name === 'SendTransaction');
|
|
2048
|
-
if (!supportsDeprecatedSendTransactionFeature && !sendTransactionFeature) {
|
|
2049
|
-
throw new WalletNotSupportFeatureError("Wallet doesn't support SendTransaction feature.");
|
|
2050
|
-
}
|
|
2051
|
-
if (options.requireExtraCurrencies) {
|
|
2052
|
-
if (!sendTransactionFeature || !sendTransactionFeature.extraCurrencySupported) {
|
|
2053
|
-
throw new WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Extra currencies support is required.`);
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
if (sendTransactionFeature && sendTransactionFeature.maxMessages !== undefined) {
|
|
2057
|
-
if (sendTransactionFeature.maxMessages < options.requiredMessagesNumber) {
|
|
2058
|
-
throw new WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${sendTransactionFeature.maxMessages}, but ${options.requiredMessagesNumber} is required.`);
|
|
2059
|
-
}
|
|
2060
|
-
return;
|
|
2061
|
-
}
|
|
2062
|
-
logWarning("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.");
|
|
2063
|
-
}
|
|
2064
|
-
function checkRequiredWalletFeatures(features, walletsRequiredFeatures) {
|
|
2065
|
-
if (typeof walletsRequiredFeatures === 'function') {
|
|
2066
|
-
return walletsRequiredFeatures(features);
|
|
2067
|
-
}
|
|
2068
|
-
const res = walletsRequiredFeatures.every(requiredFeature => {
|
|
2069
|
-
const feature = features.find(f => typeof f === 'object' && f.name === requiredFeature.name);
|
|
2070
|
-
if (!feature) {
|
|
2071
|
-
return false;
|
|
2072
|
-
}
|
|
2073
|
-
switch (requiredFeature.name) {
|
|
2074
|
-
case 'SendTransaction': {
|
|
2075
|
-
const sendTransactionFeature = feature;
|
|
2076
|
-
const correctMessagesNumber = requiredFeature.minMessages === undefined ||
|
|
2077
|
-
requiredFeature.minMessages <= sendTransactionFeature.maxMessages;
|
|
2078
|
-
const correctExtraCurrency = !requiredFeature.extraCurrencyRequired ||
|
|
2079
|
-
sendTransactionFeature.extraCurrencySupported;
|
|
2080
|
-
return correctMessagesNumber && correctExtraCurrency;
|
|
2081
|
-
}
|
|
2082
|
-
default:
|
|
2083
|
-
return false;
|
|
2084
|
-
}
|
|
2085
|
-
});
|
|
2086
|
-
return res;
|
|
2087
|
-
}
|
|
2088
|
-
|
|
2089
2045
|
class WalletsListManager {
|
|
2090
2046
|
constructor(options) {
|
|
2091
2047
|
var _a;
|
|
@@ -2094,9 +2050,6 @@ class WalletsListManager {
|
|
|
2094
2050
|
this.walletsListSource =
|
|
2095
2051
|
(_a = options === null || options === void 0 ? void 0 : options.walletsListSource) !== null && _a !== void 0 ? _a : 'https://raw.githubusercontent.com/ton-blockchain/wallets-list/main/wallets-v2.json';
|
|
2096
2052
|
this.cacheTTLMs = options === null || options === void 0 ? void 0 : options.cacheTTLMs;
|
|
2097
|
-
this.checkRequiredFeatures = (options === null || options === void 0 ? void 0 : options.walletsRequiredFeatures)
|
|
2098
|
-
? features => checkRequiredWalletFeatures(features !== null && features !== void 0 ? features : [], options.walletsRequiredFeatures)
|
|
2099
|
-
: () => true;
|
|
2100
2053
|
}
|
|
2101
2054
|
getWallets() {
|
|
2102
2055
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2246,6 +2199,51 @@ class WalletsListManager {
|
|
|
2246
2199
|
}
|
|
2247
2200
|
}
|
|
2248
2201
|
|
|
2202
|
+
function checkSendTransactionSupport(features, options) {
|
|
2203
|
+
const supportsDeprecatedSendTransactionFeature = features.includes('SendTransaction');
|
|
2204
|
+
const sendTransactionFeature = findFeature(features, 'SendTransaction');
|
|
2205
|
+
if (!supportsDeprecatedSendTransactionFeature && !sendTransactionFeature) {
|
|
2206
|
+
throw new WalletNotSupportFeatureError("Wallet doesn't support SendTransaction feature.");
|
|
2207
|
+
}
|
|
2208
|
+
if (options.requireExtraCurrencies) {
|
|
2209
|
+
if (!sendTransactionFeature || !sendTransactionFeature.extraCurrencySupported) {
|
|
2210
|
+
throw new WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Extra currencies support is required.`);
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
if (sendTransactionFeature && sendTransactionFeature.maxMessages !== undefined) {
|
|
2214
|
+
if (sendTransactionFeature.maxMessages < options.requiredMessagesNumber) {
|
|
2215
|
+
throw new WalletNotSupportFeatureError(`Wallet is not able to handle such SendTransaction request. Max support messages number is ${sendTransactionFeature.maxMessages}, but ${options.requiredMessagesNumber} is required.`);
|
|
2216
|
+
}
|
|
2217
|
+
return;
|
|
2218
|
+
}
|
|
2219
|
+
logWarning("Connected wallet didn't provide information about max allowed messages in the SendTransaction request. Request may be rejected by the wallet.");
|
|
2220
|
+
}
|
|
2221
|
+
function checkRequiredWalletFeatures(features, walletsRequiredFeatures) {
|
|
2222
|
+
if (typeof walletsRequiredFeatures !== 'object') {
|
|
2223
|
+
return true;
|
|
2224
|
+
}
|
|
2225
|
+
const { sendTransaction } = walletsRequiredFeatures;
|
|
2226
|
+
if (sendTransaction) {
|
|
2227
|
+
const feature = findFeature(features, 'SendTransaction');
|
|
2228
|
+
if (!feature) {
|
|
2229
|
+
return false;
|
|
2230
|
+
}
|
|
2231
|
+
if (!checkSendTransaction(feature, sendTransaction)) {
|
|
2232
|
+
return false;
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
return true;
|
|
2236
|
+
}
|
|
2237
|
+
function findFeature(features, requiredFeatureName) {
|
|
2238
|
+
return features.find(f => f && typeof f === 'object' && f.name === requiredFeatureName);
|
|
2239
|
+
}
|
|
2240
|
+
function checkSendTransaction(feature, requiredFeature) {
|
|
2241
|
+
const correctMessagesNumber = requiredFeature.minMessages === undefined ||
|
|
2242
|
+
requiredFeature.minMessages <= feature.maxMessages;
|
|
2243
|
+
const correctExtraCurrency = !requiredFeature.extraCurrencyRequired || feature.extraCurrencySupported;
|
|
2244
|
+
return !!(correctMessagesNumber && correctExtraCurrency);
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2249
2247
|
/**
|
|
2250
2248
|
* Create a request version event.
|
|
2251
2249
|
*/
|
|
@@ -2662,7 +2660,7 @@ class TonConnectTracker {
|
|
|
2662
2660
|
}
|
|
2663
2661
|
}
|
|
2664
2662
|
|
|
2665
|
-
const tonConnectSdkVersion = "3.
|
|
2663
|
+
const tonConnectSdkVersion = "3.1.0";
|
|
2666
2664
|
|
|
2667
2665
|
class TonConnect {
|
|
2668
2666
|
constructor(options) {
|
|
@@ -2678,8 +2676,7 @@ class TonConnect {
|
|
|
2678
2676
|
this.walletsRequiredFeatures = options === null || options === void 0 ? void 0 : options.walletsRequiredFeatures;
|
|
2679
2677
|
this.walletsList = new WalletsListManager({
|
|
2680
2678
|
walletsListSource: options === null || options === void 0 ? void 0 : options.walletsListSource,
|
|
2681
|
-
cacheTTLMs: options === null || options === void 0 ? void 0 : options.walletsListCacheTTLMs
|
|
2682
|
-
walletsRequiredFeatures: options === null || options === void 0 ? void 0 : options.walletsRequiredFeatures
|
|
2679
|
+
cacheTTLMs: options === null || options === void 0 ? void 0 : options.walletsListCacheTTLMs
|
|
2683
2680
|
});
|
|
2684
2681
|
this.tracker = new TonConnectTracker({
|
|
2685
2682
|
eventDispatcher: options === null || options === void 0 ? void 0 : options.eventDispatcher,
|
|
@@ -3000,15 +2997,15 @@ class TonConnect {
|
|
|
3000
2997
|
}
|
|
3001
2998
|
}
|
|
3002
2999
|
onWalletConnected(connectEvent) {
|
|
3003
|
-
var _a
|
|
3000
|
+
var _a;
|
|
3004
3001
|
const tonAccountItem = connectEvent.items.find(item => item.name === 'ton_addr');
|
|
3005
3002
|
const tonProofItem = connectEvent.items.find(item => item.name === 'ton_proof');
|
|
3006
3003
|
if (!tonAccountItem) {
|
|
3007
3004
|
throw new TonConnectError('ton_addr connection item was not found');
|
|
3008
3005
|
}
|
|
3009
|
-
const hasRequiredFeatures = checkRequiredWalletFeatures(connectEvent.device.features,
|
|
3006
|
+
const hasRequiredFeatures = checkRequiredWalletFeatures(connectEvent.device.features, this.walletsRequiredFeatures);
|
|
3010
3007
|
if (!hasRequiredFeatures) {
|
|
3011
|
-
(
|
|
3008
|
+
(_a = this.provider) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
3012
3009
|
this.onWalletConnectError(new WalletMissingRequiredFeaturesError('Wallet does not support required features', { cause: { connectEvent } }));
|
|
3013
3010
|
return;
|
|
3014
3011
|
}
|