@tonconnect/sdk 3.4.0-beta.0 → 3.4.0-beta.1

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.
@@ -6,7 +6,7 @@ export declare interface Account {
6
6
  /**
7
7
  * User's selected chain.
8
8
  */
9
- chain: 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 {
@@ -665,6 +667,12 @@ export declare interface ITonConnect {
665
667
  * Unpause bridge HTTP connection if it is paused.
666
668
  */
667
669
  unPauseConnection(): Promise<void>;
670
+ /**
671
+ * Set desired network for the connection. Can only be set before connecting.
672
+ * If wallet connects with a different chain, the SDK will throw an error and abort connection.
673
+ * @param network desired network id (e.g., '-239', '-3', or custom). Pass undefined to allow any network.
674
+ */
675
+ setConnectionNetwork(network?: ChainId): void;
668
676
  /**
669
677
  * Disconnect form thw connected wallet and drop current session.
670
678
  */
@@ -852,7 +860,7 @@ export declare interface SendTransactionRequest {
852
860
  /**
853
861
  * 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
862
  */
855
- network?: CHAIN;
863
+ network?: ChainId;
856
864
  /**
857
865
  * The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default.
858
866
  */
@@ -925,7 +933,7 @@ export declare type SignDataFeature = {
925
933
  };
926
934
 
927
935
  export declare type SignDataPayload = {
928
- network?: CHAIN;
936
+ network?: ChainId;
929
937
  from?: string;
930
938
  } & (SignDataPayloadText | SignDataPayloadBinary | SignDataPayloadCell);
931
939
 
@@ -967,17 +975,22 @@ export declare type TelegramUser = {
967
975
 
968
976
  export declare interface TonAddressItem {
969
977
  name: 'ton_addr';
978
+ /**
979
+ * Desired network global_id. If provided, wallet should connect on this network.
980
+ */
981
+ network?: ChainId;
970
982
  }
971
983
 
972
984
  export declare interface TonAddressItemReply {
973
985
  name: 'ton_addr';
974
986
  address: string;
975
- network: CHAIN;
987
+ network: ChainId;
976
988
  walletStateInit: string;
977
989
  publicKey: string;
978
990
  }
979
991
 
980
992
  declare class TonConnect implements ITonConnect {
993
+ private desiredChainId;
981
994
  private static readonly walletsList;
982
995
  /**
983
996
  * Check if specified wallet is injected and available to use with the app.
@@ -1075,6 +1088,12 @@ declare class TonConnect implements ITonConnect {
1075
1088
  onRequestSent?: () => void;
1076
1089
  signal?: AbortSignal;
1077
1090
  }>): Promise<Traceable<SignDataResponse>>;
1091
+ /**
1092
+ * Set desired network for the connection. Can only be set before connecting.
1093
+ * If wallet connects with a different chain, the SDK will throw an error and abort connection.
1094
+ * @param network desired network id (e.g., '-239', '-3', or custom). Pass undefined to allow any network.
1095
+ */
1096
+ setConnectionNetwork(network?: ChainId): void;
1078
1097
  /**
1079
1098
  * Disconnect form thw connected wallet and drop current session.
1080
1099
  */
@@ -1632,6 +1651,18 @@ export declare class WalletsListManager {
1632
1651
  private isCorrectWalletConfigDTO;
1633
1652
  }
1634
1653
 
1654
+ export declare class WalletWrongNetworkError extends TonConnectError<{
1655
+ expectedChainId: string;
1656
+ actualChainId: string;
1657
+ }> {
1658
+ constructor(message: string, options: {
1659
+ cause: {
1660
+ expectedChainId: string;
1661
+ actualChainId: string;
1662
+ };
1663
+ });
1664
+ }
1665
+
1635
1666
  /**
1636
1667
  * Parameters without version field.
1637
1668
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonconnect/sdk",
3
- "version": "3.4.0-beta.0",
3
+ "version": "3.4.0-beta.1",
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.3.0"
25
+ "@tonconnect/protocol": "2.4.0-beta.0"
26
26
  },
27
27
  "files": [
28
28
  "lib",