@tonconnect/sdk 3.4.0-beta.0 → 3.4.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/README.md +34 -0
- package/dist/tonconnect-sdk.min.js +1 -1
- package/dist/tonconnect-sdk.min.js.map +1 -1
- package/lib/cjs/index.cjs +603 -18
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/index.mjs +602 -20
- package/lib/esm/index.mjs.map +1 -1
- package/lib/types/index.d.ts +114 -9
- package/package.json +2 -2
package/lib/types/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare interface Account {
|
|
|
6
6
|
/**
|
|
7
7
|
* User's selected chain.
|
|
8
8
|
*/
|
|
9
|
-
chain:
|
|
9
|
+
chain: ChainId;
|
|
10
10
|
/**
|
|
11
11
|
* Base64 (not url safe) encoded wallet contract stateInit.
|
|
12
12
|
* Can be used to get user's public key from the stateInit if the wallet contract doesn't support corresponding get method.
|
|
@@ -70,6 +70,8 @@ export declare enum CHAIN {
|
|
|
70
70
|
TESTNET = "-3"
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
export declare type ChainId = CHAIN | string;
|
|
74
|
+
|
|
73
75
|
export declare function checkRequiredWalletFeatures(features: Feature[], walletsRequiredFeatures?: RequiredFeatures): boolean;
|
|
74
76
|
|
|
75
77
|
export declare enum CONNECT_EVENT_ERROR_CODES {
|
|
@@ -362,7 +364,9 @@ export declare function createRequestVersionEvent(): RequestVersionEvent;
|
|
|
362
364
|
*/
|
|
363
365
|
export declare function createResponseVersionEvent(version: string): ResponseVersionEvent;
|
|
364
366
|
|
|
365
|
-
export declare function createSelectedWalletEvent(version: Version, visibleWallets: string[], lastSelectedWallet:
|
|
367
|
+
export declare function createSelectedWalletEvent(version: Version, visibleWallets: string[], lastSelectedWallet: {
|
|
368
|
+
appName?: string;
|
|
369
|
+
} | null, walletsMenu: 'explicit_wallet' | 'main_screen' | 'other_wallets', redirectLink: string, redirectLinkType?: 'tg_link' | 'external_link', clientId?: string | null, traceId?: string | null): SelectedWalletEvent;
|
|
366
370
|
|
|
367
371
|
/**
|
|
368
372
|
* Create a transaction init event.
|
|
@@ -556,6 +560,31 @@ export declare interface IEnvironment {
|
|
|
556
560
|
getClientEnvironment(): 'web' | 'miniapp' | (string & {});
|
|
557
561
|
}
|
|
558
562
|
|
|
563
|
+
/**
|
|
564
|
+
* Initializes the WalletConnect integration.
|
|
565
|
+
*
|
|
566
|
+
* This function must be called once before using WalletConnect features.
|
|
567
|
+
* A second call will throw an error to prevent accidental re-initialization.
|
|
568
|
+
*
|
|
569
|
+
* @param UniversalConnectorCls - A UniversalConnector class imported from '@reown/appkit-universal-connector'
|
|
570
|
+
* @param {WalletConnectOptions} walletConnectOptions - Configuration options used for initializing WalletConnect.
|
|
571
|
+
* @example
|
|
572
|
+
* import { UniversalConnector } from '@reown/appkit-universal-connector';
|
|
573
|
+
*
|
|
574
|
+
* initializeWalletConnect(UniversalConnector, {
|
|
575
|
+
* projectId: 'abcd1234abcd1234abcd1234abcd1234',
|
|
576
|
+
* metadata: {
|
|
577
|
+
* name: 'Demo DApp',
|
|
578
|
+
* icons: [
|
|
579
|
+
* 'https://example.com/my-icon.png'
|
|
580
|
+
* ],
|
|
581
|
+
* url: window.location.origin,
|
|
582
|
+
* description: 'Demo DApp'
|
|
583
|
+
* }
|
|
584
|
+
* });
|
|
585
|
+
*/
|
|
586
|
+
export declare function initializeWalletConnect(UniversalConnectorCls: Function, walletConnectOptions: WalletConnectOptions): void;
|
|
587
|
+
|
|
559
588
|
export declare function isConnectUrl(link: string | undefined): link is string;
|
|
560
589
|
|
|
561
590
|
export declare function isQaModeEnabled(): boolean;
|
|
@@ -584,6 +613,8 @@ export declare interface IStorage {
|
|
|
584
613
|
removeItem(key: string): Promise<void>;
|
|
585
614
|
}
|
|
586
615
|
|
|
616
|
+
export declare function isWalletConnectInitialized(): boolean;
|
|
617
|
+
|
|
587
618
|
/**
|
|
588
619
|
* Checks if `WalletInfo` is `WalletInfoInjectable` and dApp is opened inside this wallet's browser.
|
|
589
620
|
* @param value WalletInfo to check.
|
|
@@ -648,7 +679,7 @@ export declare interface ITonConnect {
|
|
|
648
679
|
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, request?: ConnectAdditionalRequest, options?: OptionalTraceable<{
|
|
649
680
|
openingDeadlineMS?: number;
|
|
650
681
|
signal?: AbortSignal;
|
|
651
|
-
}>): T extends WalletConnectionSourceJS ? void : string;
|
|
682
|
+
}>): T extends WalletConnectionSourceJS ? void : T extends WalletConnectionSourceWalletConnect ? void : string;
|
|
652
683
|
/**
|
|
653
684
|
* Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded.
|
|
654
685
|
*/
|
|
@@ -665,6 +696,12 @@ export declare interface ITonConnect {
|
|
|
665
696
|
* Unpause bridge HTTP connection if it is paused.
|
|
666
697
|
*/
|
|
667
698
|
unPauseConnection(): Promise<void>;
|
|
699
|
+
/**
|
|
700
|
+
* Set desired network for the connection. Can only be set before connecting.
|
|
701
|
+
* If wallet connects with a different chain, the SDK will throw an error and abort connection.
|
|
702
|
+
* @param network desired network id (e.g., '-239', '-3', or custom). Pass undefined to allow any network.
|
|
703
|
+
*/
|
|
704
|
+
setConnectionNetwork(network?: ChainId): void;
|
|
668
705
|
/**
|
|
669
706
|
* Disconnect form thw connected wallet and drop current session.
|
|
670
707
|
*/
|
|
@@ -852,7 +889,7 @@ export declare interface SendTransactionRequest {
|
|
|
852
889
|
/**
|
|
853
890
|
* The network (mainnet or testnet) where DApp intends to send the transaction. If not set, the transaction is sent to the network currently set in the wallet, but this is not safe and DApp should always strive to set the network. If the network parameter is set, but the wallet has a different network set, the wallet should show an alert and DO NOT ALLOW TO SEND this transaction.
|
|
854
891
|
*/
|
|
855
|
-
network?:
|
|
892
|
+
network?: ChainId;
|
|
856
893
|
/**
|
|
857
894
|
* The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default.
|
|
858
895
|
*/
|
|
@@ -925,7 +962,7 @@ export declare type SignDataFeature = {
|
|
|
925
962
|
};
|
|
926
963
|
|
|
927
964
|
export declare type SignDataPayload = {
|
|
928
|
-
network?:
|
|
965
|
+
network?: ChainId;
|
|
929
966
|
from?: string;
|
|
930
967
|
} & (SignDataPayloadText | SignDataPayloadBinary | SignDataPayloadCell);
|
|
931
968
|
|
|
@@ -967,17 +1004,22 @@ export declare type TelegramUser = {
|
|
|
967
1004
|
|
|
968
1005
|
export declare interface TonAddressItem {
|
|
969
1006
|
name: 'ton_addr';
|
|
1007
|
+
/**
|
|
1008
|
+
* Desired network global_id. If provided, wallet should connect on this network.
|
|
1009
|
+
*/
|
|
1010
|
+
network?: ChainId;
|
|
970
1011
|
}
|
|
971
1012
|
|
|
972
1013
|
export declare interface TonAddressItemReply {
|
|
973
1014
|
name: 'ton_addr';
|
|
974
1015
|
address: string;
|
|
975
|
-
network:
|
|
1016
|
+
network: ChainId;
|
|
976
1017
|
walletStateInit: string;
|
|
977
1018
|
publicKey: string;
|
|
978
1019
|
}
|
|
979
1020
|
|
|
980
1021
|
declare class TonConnect implements ITonConnect {
|
|
1022
|
+
private desiredChainId;
|
|
981
1023
|
private static readonly walletsList;
|
|
982
1024
|
/**
|
|
983
1025
|
* Check if specified wallet is injected and available to use with the app.
|
|
@@ -1045,12 +1087,12 @@ declare class TonConnect implements ITonConnect {
|
|
|
1045
1087
|
request?: ConnectAdditionalRequest;
|
|
1046
1088
|
openingDeadlineMS?: number;
|
|
1047
1089
|
signal?: AbortSignal;
|
|
1048
|
-
}>): T extends WalletConnectionSourceJS ? void : string;
|
|
1090
|
+
}>): T extends WalletConnectionSourceJS ? void : T extends WalletConnectionSourceWalletConnect ? void : string;
|
|
1049
1091
|
/** @deprecated use connect(wallet, options) instead */
|
|
1050
1092
|
connect<T extends WalletConnectionSource | Pick<WalletConnectionSourceHTTP, 'bridgeUrl'>[]>(wallet: T, request?: ConnectAdditionalRequest, options?: OptionalTraceable<{
|
|
1051
1093
|
openingDeadlineMS?: number;
|
|
1052
1094
|
signal?: AbortSignal;
|
|
1053
|
-
}>): T extends WalletConnectionSourceJS ? void : string;
|
|
1095
|
+
}>): T extends WalletConnectionSourceJS ? void : T extends WalletConnectionSourceWalletConnect ? void : string;
|
|
1054
1096
|
/**
|
|
1055
1097
|
* Try to restore existing session and reconnect to the corresponding wallet. Call it immediately when your app is loaded.
|
|
1056
1098
|
*/
|
|
@@ -1075,6 +1117,12 @@ declare class TonConnect implements ITonConnect {
|
|
|
1075
1117
|
onRequestSent?: () => void;
|
|
1076
1118
|
signal?: AbortSignal;
|
|
1077
1119
|
}>): Promise<Traceable<SignDataResponse>>;
|
|
1120
|
+
/**
|
|
1121
|
+
* Set desired network for the connection. Can only be set before connecting.
|
|
1122
|
+
* If wallet connects with a different chain, the SDK will throw an error and abort connection.
|
|
1123
|
+
* @param network desired network id (e.g., '-239', '-3', or custom). Pass undefined to allow any network.
|
|
1124
|
+
*/
|
|
1125
|
+
setConnectionNetwork(network?: ChainId): void;
|
|
1078
1126
|
/**
|
|
1079
1127
|
* Disconnect form thw connected wallet and drop current session.
|
|
1080
1128
|
*/
|
|
@@ -1417,7 +1465,7 @@ export declare class WalletAlreadyConnectedError extends TonConnectError {
|
|
|
1417
1465
|
constructor(...args: ConstructorParameters<typeof TonConnectError>);
|
|
1418
1466
|
}
|
|
1419
1467
|
|
|
1420
|
-
export declare type WalletConnectionSource = WalletConnectionSourceHTTP | WalletConnectionSourceJS;
|
|
1468
|
+
export declare type WalletConnectionSource = WalletConnectionSourceHTTP | WalletConnectionSourceJS | WalletConnectionSourceWalletConnect;
|
|
1421
1469
|
|
|
1422
1470
|
export declare interface WalletConnectionSourceHTTP {
|
|
1423
1471
|
/**
|
|
@@ -1437,6 +1485,51 @@ export declare interface WalletConnectionSourceJS {
|
|
|
1437
1485
|
jsBridgeKey: string;
|
|
1438
1486
|
}
|
|
1439
1487
|
|
|
1488
|
+
export declare interface WalletConnectionSourceWalletConnect {
|
|
1489
|
+
type: 'wallet-connect';
|
|
1490
|
+
}
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* Metadata information about your application that will be displayed to users during WalletConnect pairing.
|
|
1494
|
+
*/
|
|
1495
|
+
export declare type WalletConnectMetadata = {
|
|
1496
|
+
/**
|
|
1497
|
+
* The name of your application.
|
|
1498
|
+
* @example 'My DApp'
|
|
1499
|
+
*/
|
|
1500
|
+
name: string;
|
|
1501
|
+
/**
|
|
1502
|
+
* A brief description of your application.
|
|
1503
|
+
* @example 'My awesome TON DApp'
|
|
1504
|
+
*/
|
|
1505
|
+
description: string;
|
|
1506
|
+
/**
|
|
1507
|
+
* The URL of your application. This is used as the domain for ton_proof authentication.
|
|
1508
|
+
* @example 'https://mydapp.com'
|
|
1509
|
+
*/
|
|
1510
|
+
url: string;
|
|
1511
|
+
/**
|
|
1512
|
+
* An array of icon URLs representing your application. These icons are shown in wallet interfaces.
|
|
1513
|
+
* @example ['https://mydapp.com/icon-192.png', 'https://mydapp.com/icon-512.png']
|
|
1514
|
+
*/
|
|
1515
|
+
icons: string[];
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* Configuration options for initializing WalletConnect integration.
|
|
1520
|
+
*/
|
|
1521
|
+
export declare type WalletConnectOptions = {
|
|
1522
|
+
/**
|
|
1523
|
+
* Your WalletConnect project ID. Get one at https://dashboard.reown.com/
|
|
1524
|
+
* @example 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6'
|
|
1525
|
+
*/
|
|
1526
|
+
projectId: string;
|
|
1527
|
+
/**
|
|
1528
|
+
* Metadata about your application that will be displayed to users.
|
|
1529
|
+
*/
|
|
1530
|
+
metadata: WalletConnectMetadata;
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1440
1533
|
export declare type WalletInfo = WalletInfoRemote | WalletInfoInjectable | (WalletInfoRemote & WalletInfoInjectable);
|
|
1441
1534
|
|
|
1442
1535
|
/**
|
|
@@ -1632,6 +1725,18 @@ export declare class WalletsListManager {
|
|
|
1632
1725
|
private isCorrectWalletConfigDTO;
|
|
1633
1726
|
}
|
|
1634
1727
|
|
|
1728
|
+
export declare class WalletWrongNetworkError extends TonConnectError<{
|
|
1729
|
+
expectedChainId: string;
|
|
1730
|
+
actualChainId: string;
|
|
1731
|
+
}> {
|
|
1732
|
+
constructor(message: string, options: {
|
|
1733
|
+
cause: {
|
|
1734
|
+
expectedChainId: string;
|
|
1735
|
+
actualChainId: string;
|
|
1736
|
+
};
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1635
1740
|
/**
|
|
1636
1741
|
* Parameters without version field.
|
|
1637
1742
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tonconnect/sdk",
|
|
3
|
-
"version": "3.4.0-beta.
|
|
3
|
+
"version": "3.4.0-beta.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ton-connect/sdk.git"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@tonconnect/isomorphic-eventsource": "0.0.2",
|
|
24
24
|
"@tonconnect/isomorphic-fetch": "0.0.3",
|
|
25
|
-
"@tonconnect/protocol": "2.
|
|
25
|
+
"@tonconnect/protocol": "2.4.0-beta.0"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"lib",
|