@broxus/evm-connect 1.3.8 → 1.4.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.
@@ -2,7 +2,6 @@ import { type ButtonProps } from '@broxus/react-uikit';
2
2
  import * as React from 'react';
3
3
  import './index.css';
4
4
  export interface EvmConnectorProps {
5
- changeNetworkButtonText?: React.ReactNode;
6
5
  changeWalletButtonText?: React.ReactNode;
7
6
  className?: string;
8
7
  connectButtonShape?: ButtonProps['shape'];
@@ -44,10 +44,7 @@ exports.EvmConnector = (0, mobx_react_lite_1.observer)((props) => {
44
44
  const walletService = (0, context_1.useEvmWalletService)();
45
45
  const [, setRecentMeta] = (0, hooks_1.useRecentConnectionMeta)();
46
46
  const drop = React.useRef(null);
47
- const { changeNetworkButtonText = intl.formatMessage(intl_1.default.EVM_CONNECT_CHANGE_NETWORK_BTN_TEXT), changeWalletButtonText = intl.formatMessage(intl_1.default.EVM_CONNECT_CHANGE_WALLET_BTN_TEXT), className, connectButtonShape, connectButtonText = intl.formatMessage(intl_1.default.EVM_CONNECT_CONNECT_BTN_TEXT), connectButtonType, disconnectButtonText = intl.formatMessage(intl_1.default.EVM_CONNECT_DISCONNECT_BTN_TEXT), popupType, suffix, showDropMenu = true, showSubIcon = true, standalone = walletService.providers?.length === 1, } = props;
48
- const changeNetwork = async () => {
49
- drop.current?.close();
50
- };
47
+ const { changeWalletButtonText = intl.formatMessage(intl_1.default.EVM_CONNECT_CHANGE_WALLET_BTN_TEXT), className, connectButtonShape, connectButtonText = intl.formatMessage(intl_1.default.EVM_CONNECT_CONNECT_BTN_TEXT), connectButtonType, disconnectButtonText = intl.formatMessage(intl_1.default.EVM_CONNECT_DISCONNECT_BTN_TEXT), popupType, suffix, showDropMenu = true, showSubIcon = true, standalone = walletService.providers?.length === 1, } = props;
51
48
  const changeWallet = () => {
52
49
  drop.current?.close();
53
50
  };
@@ -86,8 +83,6 @@ exports.EvmConnector = (0, mobx_react_lite_1.observer)((props) => {
86
83
  React.createElement(react_uikit_1.Flex, { alignItems: "center", className: "evm-connect-connector-suffix" },
87
84
  suffix,
88
85
  walletService.isConnected && showDropMenu && (React.createElement(react_uikit_1.Dropdown, { ref: drop, action: "click", overlayClassName: "evm-connect-dropdown", overlay: (React.createElement(react_uikit_1.List, { className: "uk-margin-remove", size: "large" },
89
- React.createElement(react_uikit_1.List.Item, null,
90
- React.createElement(react_uikit_1.Button, { className: "evm-connect-change-network", disabled: true, type: "link", onClick: changeNetwork }, changeNetworkButtonText)),
91
86
  !standalone && (React.createElement(react_uikit_1.List.Item, { key: "connect-wallet" },
92
87
  React.createElement(EvmConnectButton_1.EvmConnectButton, { className: "evm-connect-change-wallet", popupType: popupType, type: "link", onOpen: changeWallet }, changeWalletButtonText))),
93
88
  React.createElement(react_uikit_1.List.Item, null,
@@ -19,10 +19,6 @@ declare const _default: {
19
19
  defaultMessage: string;
20
20
  id: string;
21
21
  };
22
- EVM_CONNECT_CHANGE_NETWORK_BTN_TEXT: {
23
- defaultMessage: string;
24
- id: string;
25
- };
26
22
  EVM_CONNECT_CHANGE_WALLET_BTN_TEXT: {
27
23
  defaultMessage: string;
28
24
  id: string;
@@ -23,10 +23,6 @@ exports.default = (0, react_intl_1.defineMessages)({
23
23
  defaultMessage: 'Disconnect',
24
24
  id: 'EVM_CONNECT_DISCONNECT_BTN_TEXT',
25
25
  },
26
- EVM_CONNECT_CHANGE_NETWORK_BTN_TEXT: {
27
- defaultMessage: 'Change network',
28
- id: 'EVM_CONNECT_CHANGE_NETWORK_BTN_TEXT',
29
- },
30
26
  EVM_CONNECT_CHANGE_WALLET_BTN_TEXT: {
31
27
  defaultMessage: 'Change wallet',
32
28
  id: 'EVM_CONNECT_CHANGE_WALLET_BTN_TEXT',
@@ -41,6 +41,12 @@ export declare class EvmWalletService extends AbstractStore<EvmWalletServiceData
41
41
  * @returns {Promise<void>}
42
42
  */
43
43
  disconnect(force?: boolean): Promise<void>;
44
+ /**
45
+ * Add network to the current connected wallet
46
+ * @param {AddEthereumChainParams} chainParams
47
+ * @returns {Promise<void>}
48
+ */
49
+ addNetwork(chainParams: AddEthereumChainParams): Promise<void>;
44
50
  /**
45
51
  * Switch network or add a new one if not exists in the current connected wallet
46
52
  * @param {number|AddEthereumChainParams} chainIdOrParams
@@ -69,12 +69,19 @@ class EvmWalletService extends js_core_1.AbstractStore {
69
69
  try {
70
70
  await this.connector?.disconnect();
71
71
  this.setData('balance', undefined);
72
- this.setState('providerId', undefined);
73
72
  }
74
73
  catch (e) {
75
74
  (0, js_utils_1.error)('EVM Wallet disconnect error', e);
76
75
  }
77
76
  }
77
+ /**
78
+ * Add network to the current connected wallet
79
+ * @param {AddEthereumChainParams} chainParams
80
+ * @returns {Promise<void>}
81
+ */
82
+ async addNetwork(chainParams) {
83
+ await this.connector?.addNetwork(chainParams);
84
+ }
78
85
  /**
79
86
  * Switch network or add a new one if not exists in the current connected wallet
80
87
  * @param {number|AddEthereumChainParams} chainIdOrParams
@@ -314,6 +321,12 @@ __decorate([
314
321
  __metadata("design:paramtypes", [Boolean]),
315
322
  __metadata("design:returntype", Promise)
316
323
  ], EvmWalletService.prototype, "disconnect", null);
324
+ __decorate([
325
+ mobx_1.action.bound,
326
+ __metadata("design:type", Function),
327
+ __metadata("design:paramtypes", [Object]),
328
+ __metadata("design:returntype", Promise)
329
+ ], EvmWalletService.prototype, "addNetwork", null);
317
330
  __decorate([
318
331
  mobx_1.action.bound,
319
332
  __metadata("design:type", Function),