Skip to content

Commit ce689e4

Browse files
committed
eliminated circular dependencies from widget
1 parent 172ce80 commit ce689e4

File tree

10 files changed

+41
-37
lines changed

10 files changed

+41
-37
lines changed

packages/messenger-widget/src/components/ConfigureProfile/ConfigureProfile.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ import { GlobalContext } from '../../utils/context-utils';
77
import DeleteDM3Name from '../DeleteDM3Name/DeleteDM3Name';
88
import './ConfigureProfile.css';
99
import {
10-
ACTION_TYPE,
11-
BUTTON_CLASS,
12-
NAME_TYPE,
13-
PROFILE_INPUT_FIELD_CLASS,
1410
closeConfigurationModal,
1511
fetchChainIdFromServiceName,
1612
fetchComponent,
@@ -30,6 +26,12 @@ import { AuthContext } from '../../context/AuthContext';
3026
import { useNetwork } from 'wagmi';
3127
import { useMainnetProvider } from '../../hooks/mainnetprovider/useMainnetProvider';
3228
import { switchNetwork } from '@wagmi/core';
29+
import {
30+
ACTION_TYPE,
31+
BUTTON_CLASS,
32+
NAME_TYPE,
33+
PROFILE_INPUT_FIELD_CLASS,
34+
} from './chain/common';
3335

3436
export function ConfigureDM3Profile() {
3537
// global context state

packages/messenger-widget/src/components/ConfigureProfile/bl.tsx

+1-24
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,7 @@ import { getLastDm3Name } from '../../utils/common-utils';
1919
import { ConfigureGenomeProfile } from './chain/genome/ConfigureGenomeProfile';
2020
import { ConfigureEnsProfile } from './chain/ens/ConfigureEnsProfile';
2121
import React from 'react';
22-
23-
export const PROFILE_INPUT_FIELD_CLASS =
24-
'profile-input font-weight-400 font-size-14 border-radius-6 w-100 line-height-24';
25-
26-
export const BUTTON_CLASS =
27-
'configure-btn font-weight-400 font-size-12 border-radius-4 line-height-24';
28-
29-
export enum NAME_TYPE {
30-
ENS_NAME,
31-
DM3_NAME,
32-
}
33-
34-
export enum ACTION_TYPE {
35-
CONFIGURE,
36-
REMOVE,
37-
}
38-
39-
export interface IChain {
40-
chainToConnect: number;
41-
}
22+
import { NAME_TYPE } from './chain/common';
4223

4324
// method to open the profile configuration modal
4425
export const openConfigurationModal = (dispatch: React.Dispatch<Actions>) => {
@@ -186,10 +167,6 @@ export const validateName = (username: string): boolean => {
186167
);
187168
};
188169

189-
export const validateEnsName = (username: string): boolean => {
190-
return ethers.utils.isValidName(username);
191-
};
192-
193170
export const fetchExistingDM3Name = async (
194171
mainnetProvider: ethers.providers.StaticJsonRpcProvider,
195172
account: Account,

packages/messenger-widget/src/components/ConfigureProfile/chain/SubmitOnChainProfile.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useContext } from 'react';
22
import tickIcon from '../../../assets/images/white-tick.svg';
3+
import { ConfigureProfileContext } from '../context/ConfigureProfileContext';
34
import {
45
ACTION_TYPE,
5-
BUTTON_CLASS,
66
NAME_TYPE,
77
PROFILE_INPUT_FIELD_CLASS,
8-
} from '../bl';
9-
import { ConfigureProfileContext } from '../context/ConfigureProfileContext';
8+
BUTTON_CLASS,
9+
} from './common';
1010

1111
export const SubmitOnChainProfile = ({
1212
label,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ethers } from 'ethers';
2+
3+
export enum NAME_TYPE {
4+
ENS_NAME,
5+
DM3_NAME,
6+
}
7+
8+
export enum ACTION_TYPE {
9+
CONFIGURE,
10+
REMOVE,
11+
}
12+
13+
export const PROFILE_INPUT_FIELD_CLASS =
14+
'profile-input font-weight-400 font-size-14 border-radius-6 w-100 line-height-24';
15+
16+
export const BUTTON_CLASS =
17+
'configure-btn font-weight-400 font-size-12 border-radius-4 line-height-24';
18+
19+
export interface IChain {
20+
chainToConnect: number;
21+
}
22+
23+
export const validateEnsName = (username: string): boolean => {
24+
return ethers.utils.isValidName(username);
25+
};

packages/messenger-widget/src/components/ConfigureProfile/chain/ens/ConfigureEnsProfile.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import { useContext } from 'react';
33
import { GlobalContext } from '../../../../utils/context-utils';
44
import { ConfigureProfileContext } from '../../context/ConfigureProfileContext';
55
import { SubmitOnChainProfile } from '../SubmitOnChainProfile';
6-
import { IChain, NAME_TYPE, validateEnsName } from '../../bl';
76
import { AuthContext } from '../../../../context/AuthContext';
87
import { submitEnsNameTransaction } from './bl';
98
import { useMainnetProvider } from '../../../../hooks/mainnetprovider/useMainnetProvider';
109
import { useNetwork } from 'wagmi';
10+
import { IChain, NAME_TYPE, validateEnsName } from '../common';
1111

1212
export const ConfigureEnsProfile = (props: IChain) => {
1313
const { dispatch } = useContext(GlobalContext);

packages/messenger-widget/src/components/ConfigureProfile/chain/ens/bl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import {
99
} from '../../../../utils/enum-type-utils';
1010
import { setContactHeightToMaximum } from '../../../Contacts/bl';
1111
import { startLoader, closeLoader } from '../../../Loader/Loader';
12-
import { NAME_TYPE } from '../../bl';
1312
import { Account, SignedUserProfile } from '@dm3-org/dm3-lib-profile';
1413
import { Connection } from '../../../../interfaces/web3';
14+
import { NAME_TYPE } from '../common';
1515

1616
// method to check ENS name is valid or not
1717
const isEnsNameValid = async (

packages/messenger-widget/src/components/ConfigureProfile/chain/genome/ConfigureGenomeProfile.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { useContext } from 'react';
22
import { SubmitOnChainProfile } from '../SubmitOnChainProfile';
33
import { submitGenomeNameTransaction, validateGenomeName } from './bl';
44
import { ConfigureProfileContext } from '../../context/ConfigureProfileContext';
5-
import { IChain, NAME_TYPE } from '../../bl';
65
import { GlobalContext } from '../../../../utils/context-utils';
76
import { useNetwork } from 'wagmi';
87
import { AuthContext } from '../../../../context/AuthContext';
98
import { ethers } from 'ethers';
9+
import { IChain, NAME_TYPE } from '../common';
1010

1111
export const ConfigureGenomeProfile = (props: IChain) => {
1212
const { state, dispatch } = useContext(GlobalContext);

packages/messenger-widget/src/components/ConfigureProfile/chain/genome/bl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import {
88
} from '../../../../utils/enum-type-utils';
99
import { setContactHeightToMaximum } from '../../../Contacts/bl';
1010
import { startLoader, closeLoader } from '../../../Loader/Loader';
11-
import { NAME_TYPE } from '../../bl';
1211
import { ethers } from 'ethers';
1312
import { getConractInstance } from '@dm3-org/dm3-lib-shared/dist/ethersHelper';
1413
import { Connection } from '../../../../interfaces/web3';
1514
import { Account, SignedUserProfile } from '@dm3-org/dm3-lib-profile';
1615

1716
import { Address, namehash, toHex } from 'viem';
17+
import { NAME_TYPE } from '../common';
1818

1919
//Space id uses the namehash of the name + the GNO identifier to calculate the node
2020
const GNO_IDENTIFIER = BigInt(

packages/messenger-widget/src/components/ConfigureProfile/context/ConfigureProfileContext.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState } from 'react';
2-
import { NAME_TYPE } from '../bl';
2+
import { NAME_TYPE } from '../chain/common';
33

44
export interface ConfigureProfileContextType {
55
existingEnsName: string | null;

packages/messenger-widget/src/components/DeleteDM3Name/DeleteDM3Name.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import './DeleteDM3Name.css';
22
import '../../styles/modal.css';
33
import closeIcon from '../../assets/images/cross.svg';
44
import { DeleteDM3NameProps } from '../../interfaces/props';
5-
import { ACTION_TYPE } from '../ConfigureProfile/bl';
5+
import { ACTION_TYPE } from '../ConfigureProfile/chain/common';
66

77
export default function DeleteDM3Name(props: DeleteDM3NameProps) {
88
return (

0 commit comments

Comments
 (0)