@tonconnect/sdk 3.1.1-beta.0 → 3.2.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 +3 -0
- package/dist/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/index.cjs +194 -11
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +190 -14
- package/lib/esm/index.mjs.map +1 -1
- package/lib/types/index.d.ts +104 -2
- package/package.json +2 -2
package/lib/types/index.d.ts
CHANGED
|
@@ -303,6 +303,12 @@ export declare function createConnectionRestoringStartedEvent(version: Version):
|
|
|
303
303
|
*/
|
|
304
304
|
export declare function createConnectionStartedEvent(version: Version): ConnectionStartedEvent;
|
|
305
305
|
|
|
306
|
+
export declare function createDataSentForSignatureEvent(version: Version, wallet: Wallet | null, data: SignDataPayload): DataSentForSignatureEvent;
|
|
307
|
+
|
|
308
|
+
export declare function createDataSignedEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, signedData: SignDataResponse): DataSignedEvent;
|
|
309
|
+
|
|
310
|
+
export declare function createDataSigningFailedEvent(version: Version, wallet: Wallet | null, data: SignDataPayload, errorMessage: string, errorCode: SIGN_DATA_ERROR_CODES | void): DataSigningFailedEvent;
|
|
311
|
+
|
|
306
312
|
/**
|
|
307
313
|
* Create a disconnect event.
|
|
308
314
|
* @param version
|
|
@@ -375,6 +381,28 @@ export declare interface DappMetadata {
|
|
|
375
381
|
url: string;
|
|
376
382
|
}
|
|
377
383
|
|
|
384
|
+
export declare type DataSentForSignatureEvent = {
|
|
385
|
+
type: 'sign-data-request-initiated';
|
|
386
|
+
data: SignDataPayload;
|
|
387
|
+
} & ConnectionInfo;
|
|
388
|
+
|
|
389
|
+
export declare type DataSignedEvent = {
|
|
390
|
+
type: 'sign-data-request-completed';
|
|
391
|
+
is_success: true;
|
|
392
|
+
data: SignDataPayload;
|
|
393
|
+
signed_data: SignDataResponse;
|
|
394
|
+
} & ConnectionInfo;
|
|
395
|
+
|
|
396
|
+
export declare type DataSigningEvent = DataSentForSignatureEvent | DataSignedEvent | DataSigningFailedEvent;
|
|
397
|
+
|
|
398
|
+
export declare type DataSigningFailedEvent = {
|
|
399
|
+
type: 'sign-data-request-failed';
|
|
400
|
+
is_success: false;
|
|
401
|
+
error_message: string;
|
|
402
|
+
error_code: SIGN_DATA_ERROR_CODES | null;
|
|
403
|
+
data: SignDataPayload;
|
|
404
|
+
} & ConnectionInfo;
|
|
405
|
+
|
|
378
406
|
export declare interface DeviceInfo {
|
|
379
407
|
platform: 'iphone' | 'ipad' | 'android' | 'windows' | 'mac' | 'linux' | 'browser';
|
|
380
408
|
appName: string;
|
|
@@ -427,6 +455,8 @@ export declare interface EventDispatcher<T extends {
|
|
|
427
455
|
|
|
428
456
|
export declare type Feature = SendTransactionFeatureDeprecated | SendTransactionFeature | SignDataFeature;
|
|
429
457
|
|
|
458
|
+
export declare type FeatureName = Exclude<Feature, 'SendTransaction'>['name'];
|
|
459
|
+
|
|
430
460
|
/**
|
|
431
461
|
* Thrown when an error occurred while fetching the wallets list.
|
|
432
462
|
*/
|
|
@@ -555,6 +585,10 @@ export declare interface ITonConnect {
|
|
|
555
585
|
}): Promise<SendTransactionResponse>;
|
|
556
586
|
/** @deprecated use sendTransaction(transaction, options) instead */
|
|
557
587
|
sendTransaction(transaction: SendTransactionRequest, onRequestSent?: () => void): Promise<SendTransactionResponse>;
|
|
588
|
+
signData(data: SignDataPayload, options?: {
|
|
589
|
+
onRequestSent?: () => void;
|
|
590
|
+
signal?: AbortSignal;
|
|
591
|
+
}): Promise<SignDataResponse>;
|
|
558
592
|
}
|
|
559
593
|
|
|
560
594
|
/**
|
|
@@ -596,6 +630,7 @@ export declare type RequiredFeatures = {
|
|
|
596
630
|
* Required features for the send transaction feature.
|
|
597
631
|
*/
|
|
598
632
|
sendTransaction?: RequiredSendTransactionFeature;
|
|
633
|
+
signData?: RequiredSignDataFeature;
|
|
599
634
|
};
|
|
600
635
|
|
|
601
636
|
/**
|
|
@@ -612,6 +647,16 @@ export declare type RequiredSendTransactionFeature = {
|
|
|
612
647
|
extraCurrencyRequired?: boolean;
|
|
613
648
|
};
|
|
614
649
|
|
|
650
|
+
/**
|
|
651
|
+
* Required features for the sign data feature.
|
|
652
|
+
*/
|
|
653
|
+
export declare type RequiredSignDataFeature = {
|
|
654
|
+
/**
|
|
655
|
+
* Supported sign data types.
|
|
656
|
+
*/
|
|
657
|
+
types: SignDataType[];
|
|
658
|
+
};
|
|
659
|
+
|
|
615
660
|
/**
|
|
616
661
|
* Response TON Connect UI version.
|
|
617
662
|
*/
|
|
@@ -629,7 +674,7 @@ export declare type ResponseVersionEvent = {
|
|
|
629
674
|
/**
|
|
630
675
|
* User action events.
|
|
631
676
|
*/
|
|
632
|
-
export declare type SdkActionEvent = VersionEvent | ConnectionEvent | ConnectionRestoringEvent | DisconnectionEvent | TransactionSigningEvent;
|
|
677
|
+
export declare type SdkActionEvent = VersionEvent | ConnectionEvent | ConnectionRestoringEvent | DisconnectionEvent | TransactionSigningEvent | DataSigningEvent;
|
|
633
678
|
|
|
634
679
|
export declare enum SEND_TRANSACTION_ERROR_CODES {
|
|
635
680
|
UNKNOWN_ERROR = 0,
|
|
@@ -696,10 +741,50 @@ export declare interface SendTransactionResponse {
|
|
|
696
741
|
boc: string;
|
|
697
742
|
}
|
|
698
743
|
|
|
744
|
+
export declare enum SIGN_DATA_ERROR_CODES {
|
|
745
|
+
UNKNOWN_ERROR = 0,
|
|
746
|
+
BAD_REQUEST_ERROR = 1,
|
|
747
|
+
UNKNOWN_APP_ERROR = 100,
|
|
748
|
+
USER_REJECTS_ERROR = 300,
|
|
749
|
+
METHOD_NOT_SUPPORTED = 400
|
|
750
|
+
}
|
|
751
|
+
|
|
699
752
|
export declare type SignDataFeature = {
|
|
700
753
|
name: 'SignData';
|
|
754
|
+
types: SignDataType[];
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
export declare type SignDataPayload = {
|
|
758
|
+
network?: CHAIN;
|
|
759
|
+
from?: string;
|
|
760
|
+
} & (SignDataPayloadText | SignDataPayloadBinary | SignDataPayloadCell);
|
|
761
|
+
|
|
762
|
+
export declare type SignDataPayloadBinary = {
|
|
763
|
+
type: 'binary';
|
|
764
|
+
bytes: string;
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
export declare type SignDataPayloadCell = {
|
|
768
|
+
type: 'cell';
|
|
769
|
+
schema: string;
|
|
770
|
+
cell: string;
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
export declare type SignDataPayloadText = {
|
|
774
|
+
type: 'text';
|
|
775
|
+
text: string;
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
export declare type SignDataResponse = {
|
|
779
|
+
signature: string;
|
|
780
|
+
address: string;
|
|
781
|
+
timestamp: number;
|
|
782
|
+
domain: string;
|
|
783
|
+
payload: SignDataPayload;
|
|
701
784
|
};
|
|
702
785
|
|
|
786
|
+
export declare type SignDataType = 'text' | 'binary' | 'cell';
|
|
787
|
+
|
|
703
788
|
export declare interface TonAddressItem {
|
|
704
789
|
name: 'ton_addr';
|
|
705
790
|
}
|
|
@@ -804,6 +889,10 @@ declare class TonConnect implements ITonConnect {
|
|
|
804
889
|
}): Promise<SendTransactionResponse>;
|
|
805
890
|
/** @deprecated use sendTransaction(transaction, options) instead */
|
|
806
891
|
sendTransaction(transaction: SendTransactionRequest, onRequestSent?: () => void): Promise<SendTransactionResponse>;
|
|
892
|
+
signData(data: SignDataPayload, options?: {
|
|
893
|
+
onRequestSent?: () => void;
|
|
894
|
+
signal?: AbortSignal;
|
|
895
|
+
}): Promise<SignDataResponse>;
|
|
807
896
|
/**
|
|
808
897
|
* Disconnect form thw connected wallet and drop current session.
|
|
809
898
|
*/
|
|
@@ -1220,8 +1309,21 @@ export declare class WalletNotInjectedError extends TonConnectError {
|
|
|
1220
1309
|
* Thrown when wallet doesn't support requested feature method.
|
|
1221
1310
|
*/
|
|
1222
1311
|
export declare class WalletNotSupportFeatureError extends TonConnectError {
|
|
1312
|
+
cause: {
|
|
1313
|
+
requiredFeature: {
|
|
1314
|
+
featureName: FeatureName;
|
|
1315
|
+
value?: RequiredFeatures['sendTransaction'] | RequiredFeatures['signData'];
|
|
1316
|
+
};
|
|
1317
|
+
};
|
|
1223
1318
|
protected get info(): string;
|
|
1224
|
-
constructor(
|
|
1319
|
+
constructor(message: string, options: {
|
|
1320
|
+
cause: {
|
|
1321
|
+
requiredFeature: {
|
|
1322
|
+
featureName: FeatureName;
|
|
1323
|
+
value?: RequiredFeatures['sendTransaction'] | RequiredFeatures['signData'];
|
|
1324
|
+
};
|
|
1325
|
+
};
|
|
1326
|
+
});
|
|
1225
1327
|
}
|
|
1226
1328
|
|
|
1227
1329
|
export declare class WalletsListManager {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonconnect/sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "npx rimraf types-dist && npx rimraf lib && npx rollup -c rollup.config.mjs && ttsc --project tsconfig.declarations.json && api-extractor run && npx rimraf types-dist && npx rimraf dist && npx webpack --config webpack.config.js",
|
|
6
6
|
"test": "vitest run"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@tonconnect/isomorphic-eventsource": "^0.0.2",
|
|
28
28
|
"@tonconnect/isomorphic-fetch": "^0.0.3",
|
|
29
|
-
"@tonconnect/protocol": "^2.
|
|
29
|
+
"@tonconnect/protocol": "^2.3.0"
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"lib",
|