Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed whitelist codebase #357

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/auto-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
PORT_CHECK_ERROR_LINK: ${{ vars.PORT_CHECK_ERROR_LINK }}
PORT_CHECKER_URL: ${{ vars.PORT_CHECKER_URL }}
RECAPTCHA_SITE_KEY: ${{ secrets.RECAPTCHA_SITE_KEY }}
SELLER_WHITELIST_URL: ${{ vars.SELLER_WHITELIST_URL }}
SHOW_FAUCET: ${{ vars.SHOW_FAUCET }}
SYMBOL_ETH: ${{ vars.SYMBOL_ETH }}
SYMBOL_LMR: ${{ vars.SYMBOL_LMR }}
Expand Down Expand Up @@ -86,7 +85,6 @@ jobs:
echo "PROXY_ROUTER_URL=$PROXY_ROUTER_URL" >> .env
echo "RECAPTCHA_SITE_KEY=$RECAPTCHA_SITE_KEY" >> .env
echo "REQUIRED_PASSWORD_ENTROPY=$REQUIRED_PASSWORD_ENTROPY" >> .env
echo "SELLER_WHITELIST_URL=$SELLER_WHITELIST_URL" >> .env
echo "SHOW_FAUCET=$SHOW_FAUCET" >> .env
echo "SYMBOL_ETH=$SYMBOL_ETH" >> .env
echo "SYMBOL_LMR=$SYMBOL_LMR" >> .env
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/auto-release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
PORT_CHECK_ERROR_LINK: ${{ vars.PORT_CHECK_ERROR_LINK }}
PORT_CHECKER_URL: ${{ vars.PORT_CHECKER_URL }}
RECAPTCHA_SITE_KEY: ${{ secrets.RECAPTCHA_SITE_KEY }}
SELLER_WHITELIST_URL: ${{ vars.SELLER_WHITELIST_URL }}
SHOW_FAUCET: ${{ vars.SHOW_FAUCET }}
SYMBOL_ETH: ${{ vars.SYMBOL_ETH }}
SYMBOL_LMR: ${{ vars.SYMBOL_LMR }}
Expand Down Expand Up @@ -92,7 +91,6 @@ jobs:
echo "PROXY_ROUTER_URL=$PROXY_ROUTER_URL" >> .env
echo "RECAPTCHA_SITE_KEY=$RECAPTCHA_SITE_KEY" >> .env
echo "REQUIRED_PASSWORD_ENTROPY=$REQUIRED_PASSWORD_ENTROPY" >> .env
echo "SELLER_WHITELIST_URL=$SELLER_WHITELIST_URL" >> .env
echo "SHOW_FAUCET=$SHOW_FAUCET" >> .env
echo "SYMBOL_ETH=$SYMBOL_ETH" >> .env
echo "SYMBOL_LMR=$SYMBOL_LMR" >> .env
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/auto-release-stg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
PORT_CHECK_ERROR_LINK: ${{ vars.PORT_CHECK_ERROR_LINK }}
PORT_CHECKER_URL: ${{ vars.PORT_CHECKER_URL }}
RECAPTCHA_SITE_KEY: ${{ secrets.RECAPTCHA_SITE_KEY }}
SELLER_WHITELIST_URL: ${{ vars.SELLER_WHITELIST_URL }}
SHOW_FAUCET: ${{ vars.SHOW_FAUCET }}
SYMBOL_ETH: ${{ vars.SYMBOL_ETH }}
SYMBOL_LMR: ${{ vars.SYMBOL_LMR }}
Expand Down Expand Up @@ -92,7 +91,6 @@ jobs:
echo "PROXY_ROUTER_URL=$PROXY_ROUTER_URL" >> .env
echo "RECAPTCHA_SITE_KEY=$RECAPTCHA_SITE_KEY" >> .env
echo "REQUIRED_PASSWORD_ENTROPY=$REQUIRED_PASSWORD_ENTROPY" >> .env
echo "SELLER_WHITELIST_URL=$SELLER_WHITELIST_URL" >> .env
echo "SHOW_FAUCET=$SHOW_FAUCET" >> .env
echo "SYMBOL_ETH=$SYMBOL_ETH" >> .env
echo "SYMBOL_LMR=$SYMBOL_LMR" >> .env
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lumerin-wallet-desktop",
"version": "1.3.4",
"version": "1.3.5",
"engines": {
"node": ">=14"
},
Expand Down Expand Up @@ -45,7 +45,7 @@
},
"dependencies": {
"@electron/remote": "2.0.9",
"@lumerin/wallet-core": "github:Lumerin-protocol/WalletCore#1.1.1",
"@lumerin/wallet-core": "github:Lumerin-protocol/WalletCore#1.1.2",
"@reach/menu-button": "0.17.0",
"@tabler/icons": "1.119.0",
"axios": "0.27.2",
Expand Down
3 changes: 1 addition & 2 deletions public/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ const chain = {
titanLightningDashboard: process.env.TITAN_LIGHTNING_DASHBOARD || "https://lightning.titan.io",
defaultSellerCurrency: process.env.DEFAULT_SELLER_CURRENCY || 'BTC',

bypassAuth: process.env.BYPASS_AUTH === "true",
sellerWhitelistUrl: process.env.SELLER_WHITELIST_URL || 'https://forms.gle/wEcAgppfK2p9YZ3g7'
bypassAuth: process.env.BYPASS_AUTH === "true"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of BYPASS_AUTH to potentially bypass authentication mechanisms poses a significant security risk. This feature should be handled with extreme caution, especially in production environments. It's recommended to:

  • Ensure that this feature is disabled by default.
  • Implement additional safeguards to prevent its misuse, such as logging and monitoring access when this feature is enabled.
  • Consider removing or restricting this feature if not absolutely necessary.

};

module.exports = {
Expand Down
14 changes: 0 additions & 14 deletions src/components/contracts/SellerHub.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { lmrDecimals } from '../../utils/coinValue';
import { formatBtcPerTh, calculateSuggestedPrice } from './utils';
import ArchiveModal from './modals/ArchiveModal/ArchiveModal';
import { IconArchive } from '@tabler/icons';
import SellerWhitelistModal from './modals/SellerWhitelistModal/SellerWhitelistModal';
import AdjustProfitModal from './modals/AdjustProfitModal/AdjustProfitModal';

const Container = styled.div`
Expand Down Expand Up @@ -88,7 +87,6 @@ function SellerHub({
}) {
const [isModalActive, setIsModalActive] = useState(false);
const [isArchiveModalActive, setIsArchiveModalActive] = useState(false);
const [showSellerWhitelistForm, setShowSellerWhitelistForm] = useState(false);
const [showAdjustForm, setShowAdjustForm] = useState(false);
const [isEditModalActive, setIsEditModalActive] = useState(false);
const [editContractData, setEditContractData] = useState({});
Expand Down Expand Up @@ -430,10 +428,6 @@ function SellerHub({
})
.catch(error => {
setIsModalActive(false);
if (error.message == 'seller is not whitelisted') {
setShowSellerWhitelistForm(true);
return;
}
context.toast('error', error.message || error);
})
.finally(() => {
Comment on lines 428 to 433

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error Handling Improvement

The error handling in the catch block of the handleContractDeploy function could be improved by providing more specific error messages. Currently, the function uses error.message || error which might not always provide a clear indication of what went wrong, especially if error.message is undefined or not descriptive enough.

Recommendation:

  • Ensure that the backend provides meaningful error messages.
  • Implement a more sophisticated error handling strategy that could categorize errors (e.g., network issues, validation errors) and respond accordingly. This would improve the user's ability to understand what went wrong and how they might be able to fix it.

Expand Down Expand Up @@ -579,14 +573,6 @@ function SellerHub({
showSuccess={false}
/>

<SellerWhitelistModal
isActive={showSellerWhitelistForm}
formUrl={formUrl}
close={() => {
setShowSellerWhitelistForm(false);
}}
/>

<AdjustProfitModal
isActive={showAdjustForm}
contracts={[...underProfitContracts]}
Comment on lines 573 to 578

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State Management in Modals

The AdjustProfitModal is controlled by a state variable isActive which is set based on the showAdjustForm state. This approach is straightforward but can be enhanced by encapsulating the modal's visibility and its state management within the modal component itself, rather than controlling it from the parent component.

Recommendation:

  • Consider implementing a custom hook or a higher-order component that manages the visibility and state of modals. This would reduce the boilerplate in the parent component and improve the modularity and reusability of the modal components.

Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/store/hocs/withContractsState.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ const withContractsState = WrappedComponent => {
ethCoinPrice: selectors.getRateEth(state),
btcCoinPrice: selectors.getRateBtc(state),
selectedCurrency: selectors.getSellerSelectedCurrency(state),
formUrl: selectors.getSellerWhitelistForm(state),
autoAdjustPriceInterval: selectors.getAutoAdjustPriceInterval(state),
autoAdjustContractPriceTimeout: selectors.getAutoAdjustContractPriceTimeout(
state
Comment on lines 86 to 91

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Performance and Maintainability Issue

The selectors used in mapStateToProps such as selectors.getRateEth, selectors.getRateBtc, and others might not be memoized. Non-memoized selectors can lead to unnecessary recalculations and re-renders, impacting performance negatively, especially when dealing with frequent state updates.

Recommendation:
Ensure that all selectors are memoized using libraries like Reselect to compute derived data, which can help in avoiding unnecessary computations and improve component performance.

Comment on lines 86 to 91

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistency and Error Handling Issue

The current implementation does not handle potential undefined or erroneous returns from selectors such as selectors.getRateEth and selectors.getRateBtc. This can lead to runtime errors or incorrect data being passed as props, which is critical in a financial context.

Recommendation:
Implement error handling and default values for each selector used in mapStateToProps. This could involve checking for undefined values and providing default values or handling errors gracefully to ensure the component remains functional and displays accurate information.

Expand Down
3 changes: 0 additions & 3 deletions src/store/selectors/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@ export const getSellerSelectedCurrency = state => state.config.sellerCurrency;

export const getSellerDefaultCurrency = state =>
state.config.chain.defaultSellerCurrency;
Comment on lines 35 to 37

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error Handling Improvement

Currently, the selectors getSellerSelectedCurrency and getSellerDefaultCurrency do not handle cases where state.config or state.config.chain might be undefined. This can lead to runtime errors if the state structure is not as expected.

Recommendation:
Implement checks to ensure that the necessary parts of the state are defined before accessing their properties. For example:

export const getSellerSelectedCurrency = state => state.config ? state.config.sellerCurrency : undefined;
export const getSellerDefaultCurrency = state => state.config && state.config.chain ? state.config.chain.defaultSellerCurrency : undefined;

This change will help prevent potential runtime errors and make the selectors more robust.


export const getSellerWhitelistForm = state =>
state.config.chain.sellerWhitelistUrl;
Loading