@tonconnect/sdk 3.2.0-beta.0 → 3.3.0-beta.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/README.md +128 -0
- package/dist/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/index.cjs +46 -7
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +47 -8
- package/lib/esm/index.mjs.map +1 -1
- package/lib/types/index.d.ts +4 -1
- package/package.json +2 -2
package/lib/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONNECT_EVENT_ERROR_CODES, SEND_TRANSACTION_ERROR_CODES, SIGN_DATA_ERROR_CODES, Base64, SessionCrypto, hexToByteArray } from '@tonconnect/protocol';
|
|
1
|
+
import { CONNECT_EVENT_ERROR_CODES, SEND_TRANSACTION_ERROR_CODES, SIGN_DATA_ERROR_CODES, Base64, SessionCrypto, hexToByteArray, CONNECT_ITEM_ERROR_CODES } from '@tonconnect/protocol';
|
|
2
2
|
export { CHAIN, CONNECT_EVENT_ERROR_CODES, CONNECT_ITEM_ERROR_CODES, SEND_TRANSACTION_ERROR_CODES, SIGN_DATA_ERROR_CODES } from '@tonconnect/protocol';
|
|
3
3
|
import '@tonconnect/isomorphic-eventsource';
|
|
4
4
|
import '@tonconnect/isomorphic-fetch';
|
|
@@ -757,7 +757,7 @@ class BridgeGateway {
|
|
|
757
757
|
try {
|
|
758
758
|
bridgeIncomingMessage = JSON.parse(e.data);
|
|
759
759
|
}
|
|
760
|
-
catch (
|
|
760
|
+
catch (_) {
|
|
761
761
|
throw new TonConnectError(`Bridge message parse failed, message ${e.data}`);
|
|
762
762
|
}
|
|
763
763
|
this.listener(bridgeIncomingMessage);
|
|
@@ -2791,7 +2791,7 @@ class TonConnectTracker {
|
|
|
2791
2791
|
}
|
|
2792
2792
|
}
|
|
2793
2793
|
|
|
2794
|
-
const tonConnectSdkVersion = "3.
|
|
2794
|
+
const tonConnectSdkVersion = "3.3.0-beta.0";
|
|
2795
2795
|
|
|
2796
2796
|
class TonConnect {
|
|
2797
2797
|
constructor(options) {
|
|
@@ -3049,7 +3049,10 @@ class TonConnect {
|
|
|
3049
3049
|
this.checkConnection();
|
|
3050
3050
|
checkSignDataSupport(this.wallet.device.features, { requiredTypes: [data.type] });
|
|
3051
3051
|
this.tracker.trackDataSentForSignature(this.wallet, data);
|
|
3052
|
-
const
|
|
3052
|
+
const from = data.from || this.account.address;
|
|
3053
|
+
const network = data.network || this.account.chain;
|
|
3054
|
+
const response = yield this.provider.sendRequest(signDataParser.convertToRpcRequest(Object.assign(Object.assign({}, data), { from,
|
|
3055
|
+
network })), { onRequestSent: options === null || options === void 0 ? void 0 : options.onRequestSent, signal: abortController.signal });
|
|
3053
3056
|
if (signDataParser.isError(response)) {
|
|
3054
3057
|
this.tracker.trackDataSigningFailed(this.wallet, data, response.error.message, response.error.code);
|
|
3055
3058
|
return signDataParser.parseAndThrowError(response);
|
|
@@ -3113,7 +3116,7 @@ class TonConnect {
|
|
|
3113
3116
|
this.pauseConnection();
|
|
3114
3117
|
}
|
|
3115
3118
|
else {
|
|
3116
|
-
this.unPauseConnection().catch();
|
|
3119
|
+
this.unPauseConnection().catch(() => { });
|
|
3117
3120
|
}
|
|
3118
3121
|
});
|
|
3119
3122
|
}
|
|
@@ -3170,9 +3173,45 @@ class TonConnect {
|
|
|
3170
3173
|
}
|
|
3171
3174
|
};
|
|
3172
3175
|
if (tonProofItem) {
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
+
let tonProof = undefined;
|
|
3177
|
+
try {
|
|
3178
|
+
if ('proof' in tonProofItem) { // success
|
|
3179
|
+
tonProof = {
|
|
3180
|
+
name: 'ton_proof',
|
|
3181
|
+
proof: {
|
|
3182
|
+
timestamp: tonProofItem.proof.timestamp,
|
|
3183
|
+
domain: {
|
|
3184
|
+
lengthBytes: tonProofItem.proof.domain.lengthBytes,
|
|
3185
|
+
value: tonProofItem.proof.domain.value,
|
|
3186
|
+
},
|
|
3187
|
+
payload: tonProofItem.proof.payload,
|
|
3188
|
+
signature: tonProofItem.proof.signature,
|
|
3189
|
+
}
|
|
3190
|
+
};
|
|
3191
|
+
}
|
|
3192
|
+
else if ('error' in tonProofItem) { // error
|
|
3193
|
+
tonProof = {
|
|
3194
|
+
name: 'ton_proof',
|
|
3195
|
+
error: {
|
|
3196
|
+
code: tonProofItem.error.code,
|
|
3197
|
+
message: tonProofItem.error.message,
|
|
3198
|
+
}
|
|
3199
|
+
};
|
|
3200
|
+
}
|
|
3201
|
+
else {
|
|
3202
|
+
throw new TonConnectError('Invalid data format');
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
catch (e) {
|
|
3206
|
+
tonProof = {
|
|
3207
|
+
name: 'ton_proof',
|
|
3208
|
+
error: {
|
|
3209
|
+
code: CONNECT_ITEM_ERROR_CODES.UNKNOWN_ERROR,
|
|
3210
|
+
message: 'Invalid data format'
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
}
|
|
3214
|
+
wallet.connectItems = { tonProof };
|
|
3176
3215
|
}
|
|
3177
3216
|
this.wallet = wallet;
|
|
3178
3217
|
this.tracker.trackConnectionCompleted(wallet);
|