@tonconnect/sdk 3.3.0-beta.1 → 3.3.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/index.cjs +39 -27
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +34 -22
- package/lib/esm/index.mjs.map +1 -1
- package/package.json +9 -9
package/lib/cjs/index.cjs
CHANGED
|
@@ -415,12 +415,12 @@ function delay(timeout, options) {
|
|
|
415
415
|
return __awaiter(this, void 0, void 0, function* () {
|
|
416
416
|
return new Promise((resolve, reject) => {
|
|
417
417
|
var _a, _b;
|
|
418
|
-
if ((_a =
|
|
418
|
+
if ((_a = void 0 ) === null || _a === void 0 ? void 0 : _a.aborted) {
|
|
419
419
|
reject(new TonConnectError('Delay aborted'));
|
|
420
420
|
return;
|
|
421
421
|
}
|
|
422
422
|
const timeoutId = setTimeout(() => resolve(), timeout);
|
|
423
|
-
(_b =
|
|
423
|
+
(_b = void 0 ) === null || _b === void 0 ? void 0 : _b.addEventListener('abort', () => {
|
|
424
424
|
clearTimeout(timeoutId);
|
|
425
425
|
reject(new TonConnectError('Delay aborted'));
|
|
426
426
|
});
|
|
@@ -451,6 +451,7 @@ function createAbortController(signal) {
|
|
|
451
451
|
* @param {T} fn - function to call
|
|
452
452
|
* @param {CallForSuccessOptions} [options] - optional configuration options
|
|
453
453
|
*/
|
|
454
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
454
455
|
function callForSuccess(fn, options) {
|
|
455
456
|
return __awaiter(this, void 0, void 0, function* () {
|
|
456
457
|
var _a, _b;
|
|
@@ -515,6 +516,7 @@ function logWarning(...args) {
|
|
|
515
516
|
* @param {(...args: Args) => Promise<T>} createFn - A function that creates the resource.
|
|
516
517
|
* @param {(resource: T) => Promise<void>} [disposeFn] - An optional function that disposes the resource.
|
|
517
518
|
*/
|
|
519
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
518
520
|
function createResource(createFn, disposeFn) {
|
|
519
521
|
let currentResource = null;
|
|
520
522
|
let currentArgs = null;
|
|
@@ -2176,10 +2178,10 @@ function addQaModeStyles() {
|
|
|
2176
2178
|
function startBannerObserver() {
|
|
2177
2179
|
if (typeof window === 'undefined' || bannerObserver)
|
|
2178
2180
|
return;
|
|
2179
|
-
bannerObserver = new MutationObserver(
|
|
2180
|
-
mutations.forEach(
|
|
2181
|
+
bannerObserver = new MutationObserver(mutations => {
|
|
2182
|
+
mutations.forEach(mutation => {
|
|
2181
2183
|
if (mutation.type === 'childList') {
|
|
2182
|
-
mutation.removedNodes.forEach(
|
|
2184
|
+
mutation.removedNodes.forEach(node => {
|
|
2183
2185
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
2184
2186
|
const element = node;
|
|
2185
2187
|
if (element.id === 'ton-connect-qa-banner' && qaModeEnabled) {
|
|
@@ -2211,7 +2213,8 @@ class WalletsListManager {
|
|
|
2211
2213
|
this.walletsListCache = null;
|
|
2212
2214
|
this.walletsListCacheCreationTimestamp = null;
|
|
2213
2215
|
if (isQaModeEnabled()) {
|
|
2214
|
-
this.walletsListSource =
|
|
2216
|
+
this.walletsListSource =
|
|
2217
|
+
'https://raw.githubusercontent.com/ton-connect/wallets-list-staging/refs/heads/main/wallets-v2.json';
|
|
2215
2218
|
}
|
|
2216
2219
|
else {
|
|
2217
2220
|
this.walletsListSource =
|
|
@@ -2920,7 +2923,7 @@ class TonConnectTracker {
|
|
|
2920
2923
|
}
|
|
2921
2924
|
}
|
|
2922
2925
|
|
|
2923
|
-
const tonConnectSdkVersion = "3.3.0-beta.
|
|
2926
|
+
const tonConnectSdkVersion = "3.3.0-beta.2";
|
|
2924
2927
|
|
|
2925
2928
|
const noBounceableTag = 0x51;
|
|
2926
2929
|
const testOnlyTag = 0x80;
|
|
@@ -3006,7 +3009,9 @@ function parseUserFriendlyAddress(address) {
|
|
|
3006
3009
|
const isBounceable = (tag & 0x40) !== 0;
|
|
3007
3010
|
return {
|
|
3008
3011
|
wc,
|
|
3009
|
-
hex: Array.from(hex)
|
|
3012
|
+
hex: Array.from(hex)
|
|
3013
|
+
.map(b => b.toString(16).padStart(2, '0'))
|
|
3014
|
+
.join(''),
|
|
3010
3015
|
testOnly,
|
|
3011
3016
|
isBounceable
|
|
3012
3017
|
};
|
|
@@ -3103,18 +3108,21 @@ function hasExtraProperties(obj, allowedKeys) {
|
|
|
3103
3108
|
return Object.keys(obj).some(key => !allowedKeys.includes(key));
|
|
3104
3109
|
}
|
|
3105
3110
|
function validateSendTransactionRequest(data) {
|
|
3111
|
+
// eslint-disable-next-line no-console
|
|
3106
3112
|
console.log('[Validation Debug] validateSendTransactionRequest called');
|
|
3113
|
+
// eslint-disable-next-line no-console
|
|
3107
3114
|
console.log('[Validation Debug] isQaModeEnabled():', isQaModeEnabled());
|
|
3108
3115
|
if (!isValidObject(data)) {
|
|
3109
|
-
const error =
|
|
3116
|
+
const error = 'Request must be an object';
|
|
3110
3117
|
logValidationError(error);
|
|
3111
3118
|
const shouldReturnNull = isQaModeEnabled();
|
|
3119
|
+
// eslint-disable-next-line no-console
|
|
3112
3120
|
console.log('[Validation Debug] Should return null:', shouldReturnNull);
|
|
3113
3121
|
return shouldReturnNull ? null : error;
|
|
3114
3122
|
}
|
|
3115
3123
|
const allowedKeys = ['validUntil', 'network', 'from', 'messages'];
|
|
3116
3124
|
if (hasExtraProperties(data, allowedKeys)) {
|
|
3117
|
-
const error =
|
|
3125
|
+
const error = 'Request contains extra properties';
|
|
3118
3126
|
logValidationError(error);
|
|
3119
3127
|
return isQaModeEnabled() ? null : error;
|
|
3120
3128
|
}
|
|
@@ -3191,7 +3199,9 @@ function validateTransactionMessage(message, index) {
|
|
|
3191
3199
|
return `Invalid 'extraCurrency' in message at index ${index}`;
|
|
3192
3200
|
}
|
|
3193
3201
|
for (const [key, value] of Object.entries(message.extraCurrency)) {
|
|
3194
|
-
if (!INTEGER_REGEX.test(key) ||
|
|
3202
|
+
if (!INTEGER_REGEX.test(key) ||
|
|
3203
|
+
typeof value !== 'string' ||
|
|
3204
|
+
!POSITIVE_INTEGER_REGEX.test(value)) {
|
|
3195
3205
|
return `Invalid 'extraCurrency' format in message at index ${index}`;
|
|
3196
3206
|
}
|
|
3197
3207
|
}
|
|
@@ -3200,11 +3210,11 @@ function validateTransactionMessage(message, index) {
|
|
|
3200
3210
|
}
|
|
3201
3211
|
function validateConnectAdditionalRequest(data) {
|
|
3202
3212
|
if (!isValidObject(data)) {
|
|
3203
|
-
return
|
|
3213
|
+
return 'Request must be an object';
|
|
3204
3214
|
}
|
|
3205
3215
|
const allowedKeys = ['tonProof'];
|
|
3206
3216
|
if (hasExtraProperties(data, allowedKeys)) {
|
|
3207
|
-
return
|
|
3217
|
+
return 'Request contains extra properties';
|
|
3208
3218
|
}
|
|
3209
3219
|
if (data.tonProof !== undefined && !isValidString(data.tonProof)) {
|
|
3210
3220
|
return "Invalid 'tonProof'";
|
|
@@ -3213,7 +3223,7 @@ function validateConnectAdditionalRequest(data) {
|
|
|
3213
3223
|
}
|
|
3214
3224
|
function validateSignDataPayload(data) {
|
|
3215
3225
|
if (!isValidObject(data)) {
|
|
3216
|
-
return
|
|
3226
|
+
return 'Payload must be an object';
|
|
3217
3227
|
}
|
|
3218
3228
|
if (!isValidString(data.type)) {
|
|
3219
3229
|
return "'type' is required";
|
|
@@ -3232,7 +3242,7 @@ function validateSignDataPayload(data) {
|
|
|
3232
3242
|
function validateSignDataPayloadText(data) {
|
|
3233
3243
|
const allowedKeys = ['type', 'text', 'network', 'from'];
|
|
3234
3244
|
if (hasExtraProperties(data, allowedKeys)) {
|
|
3235
|
-
return
|
|
3245
|
+
return 'Text payload contains extra properties';
|
|
3236
3246
|
}
|
|
3237
3247
|
if (!isValidString(data.text)) {
|
|
3238
3248
|
return "'text' is required";
|
|
@@ -3250,7 +3260,7 @@ function validateSignDataPayloadText(data) {
|
|
|
3250
3260
|
function validateSignDataPayloadBinary(data) {
|
|
3251
3261
|
const allowedKeys = ['type', 'bytes', 'network', 'from'];
|
|
3252
3262
|
if (hasExtraProperties(data, allowedKeys)) {
|
|
3253
|
-
return
|
|
3263
|
+
return 'Binary payload contains extra properties';
|
|
3254
3264
|
}
|
|
3255
3265
|
if (!isValidString(data.bytes)) {
|
|
3256
3266
|
return "'bytes' is required";
|
|
@@ -3268,7 +3278,7 @@ function validateSignDataPayloadBinary(data) {
|
|
|
3268
3278
|
function validateSignDataPayloadCell(data) {
|
|
3269
3279
|
const allowedKeys = ['type', 'schema', 'cell', 'network', 'from'];
|
|
3270
3280
|
if (hasExtraProperties(data, allowedKeys)) {
|
|
3271
|
-
return
|
|
3281
|
+
return 'Cell payload contains extra properties';
|
|
3272
3282
|
}
|
|
3273
3283
|
if (!isValidString(data.schema)) {
|
|
3274
3284
|
return "'schema' is required";
|
|
@@ -3703,26 +3713,28 @@ class TonConnect {
|
|
|
3703
3713
|
if (tonProofItem) {
|
|
3704
3714
|
let tonProof = undefined;
|
|
3705
3715
|
try {
|
|
3706
|
-
if ('proof' in tonProofItem) {
|
|
3716
|
+
if ('proof' in tonProofItem) {
|
|
3717
|
+
// success
|
|
3707
3718
|
tonProof = {
|
|
3708
3719
|
name: 'ton_proof',
|
|
3709
3720
|
proof: {
|
|
3710
3721
|
timestamp: tonProofItem.proof.timestamp,
|
|
3711
3722
|
domain: {
|
|
3712
3723
|
lengthBytes: tonProofItem.proof.domain.lengthBytes,
|
|
3713
|
-
value: tonProofItem.proof.domain.value
|
|
3724
|
+
value: tonProofItem.proof.domain.value
|
|
3714
3725
|
},
|
|
3715
3726
|
payload: tonProofItem.proof.payload,
|
|
3716
|
-
signature: tonProofItem.proof.signature
|
|
3727
|
+
signature: tonProofItem.proof.signature
|
|
3717
3728
|
}
|
|
3718
3729
|
};
|
|
3719
3730
|
}
|
|
3720
|
-
else if ('error' in tonProofItem) {
|
|
3731
|
+
else if ('error' in tonProofItem) {
|
|
3732
|
+
// error
|
|
3721
3733
|
tonProof = {
|
|
3722
3734
|
name: 'ton_proof',
|
|
3723
3735
|
error: {
|
|
3724
3736
|
code: tonProofItem.error.code,
|
|
3725
|
-
message: tonProofItem.error.message
|
|
3737
|
+
message: tonProofItem.error.message
|
|
3726
3738
|
}
|
|
3727
3739
|
};
|
|
3728
3740
|
}
|
|
@@ -3791,23 +3803,23 @@ TonConnect.isWalletInjected = (walletJSKey) => InjectedProvider.isWalletInjected
|
|
|
3791
3803
|
*/
|
|
3792
3804
|
TonConnect.isInsideWalletBrowser = (walletJSKey) => InjectedProvider.isInsideWalletBrowser(walletJSKey);
|
|
3793
3805
|
|
|
3794
|
-
Object.defineProperty(exports,
|
|
3806
|
+
Object.defineProperty(exports, "CHAIN", {
|
|
3795
3807
|
enumerable: true,
|
|
3796
3808
|
get: function () { return protocol.CHAIN; }
|
|
3797
3809
|
});
|
|
3798
|
-
Object.defineProperty(exports,
|
|
3810
|
+
Object.defineProperty(exports, "CONNECT_EVENT_ERROR_CODES", {
|
|
3799
3811
|
enumerable: true,
|
|
3800
3812
|
get: function () { return protocol.CONNECT_EVENT_ERROR_CODES; }
|
|
3801
3813
|
});
|
|
3802
|
-
Object.defineProperty(exports,
|
|
3814
|
+
Object.defineProperty(exports, "CONNECT_ITEM_ERROR_CODES", {
|
|
3803
3815
|
enumerable: true,
|
|
3804
3816
|
get: function () { return protocol.CONNECT_ITEM_ERROR_CODES; }
|
|
3805
3817
|
});
|
|
3806
|
-
Object.defineProperty(exports,
|
|
3818
|
+
Object.defineProperty(exports, "SEND_TRANSACTION_ERROR_CODES", {
|
|
3807
3819
|
enumerable: true,
|
|
3808
3820
|
get: function () { return protocol.SEND_TRANSACTION_ERROR_CODES; }
|
|
3809
3821
|
});
|
|
3810
|
-
Object.defineProperty(exports,
|
|
3822
|
+
Object.defineProperty(exports, "SIGN_DATA_ERROR_CODES", {
|
|
3811
3823
|
enumerable: true,
|
|
3812
3824
|
get: function () { return protocol.SIGN_DATA_ERROR_CODES; }
|
|
3813
3825
|
});
|