Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
aziolek committed Aug 6, 2024
2 parents 44e57fa + ac00572 commit 0dd53fc
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 158 deletions.
102 changes: 0 additions & 102 deletions .github/workflows/ci-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,108 +10,6 @@ env:
GITLAB_PAT_OCTANT_K8S_DEVOPS_REPOSITORY_WRITE: "${{ secrets.GITLAB_PAT_OCTANT_K8S_DEVOPS_REPOSITORY_WRITE }}"

jobs:
stop-api-env:
name: Stop APITest Env
needs:
- start-apitest-env
- run-api-tests
if: always() && (needs.start-apitest-env.result == 'success')
uses: ./.github/workflows/tpl-destroy-env.yml
secrets: inherit
with:
env-type: apitest
pull-request-id: ${{ github.event.pull_request.number }}
workflow-id: ${{ github.run_id }}

run-api-tests:
name: Run API Tests
needs:
- deploy-apitest-env
runs-on:
- general
container:
image: registry.gitlab.com/golemfoundation/devops/container-builder/octant/python-poetry-ext:ad1d9179
credentials:
username: "doesnt-matter"
password: "${{ secrets.GITLAB_PAT_CONTAINER_BUILDER_DOCKER_IMAGES_READ }}"
env:
ENV_TYPE: apitest
CI_MERGE_REQUEST_IID: ${{ github.event.pull_request.number }}
CI_PIPELINE_ID: ${{ github.run_id }}
OCTANT_ENV: dev
CHAIN_ID: 1337
CHAIN_NAME: localhost
GC_PASSPORT_SCORER_ID: "${{ secrets.GITCOIN_SCORER_ID }}"
GC_PASSPORT_SCORER_API_KEY: "${{ secrets.GITCOIN_SCORER_API_KEY }}"
DELEGATION_SALT: "${{ secrets.DELEGATION_SALT }}"
DELEGATION_SALT_PRIMARY: "${{ secrets.DELEGATION_SALT_PRIMARY }}"
steps:
- uses: actions/[email protected]
- uses: actions/cache/restore@v4
with:
path: backend/.venv
key: "${{ github.sha }}-poetry-backend"
- name: Run API tests
run: |
set -ex
export CI_PROJECT_DIR="${GITHUB_WORKSPACE}"
source ${CI_PROJECT_DIR}/ci/argocd/resolve_env.sh $ENV_TYPE
pushd backend
poetry config virtualenvs.in-project true
poetry install --no-interaction --no-ansi -v --with prod --with dev
bash ${CI_PROJECT_DIR}/ci/argocd/wait_for_app.sh
export CONTRACTS_DEPLOYER_URL; CONTRACTS_DEPLOYER_URL=https://$(bash ${CI_PROJECT_DIR}/ci/argocd/get_multideployer_url.sh)
export ETH_RPC_PROVIDER_URL; ETH_RPC_PROVIDER_URL=https://$(bash ${CI_PROJECT_DIR}/ci/argocd/get_rpc_url.sh)
export SUBGRAPH_URL; SUBGRAPH_URL=https://$(bash ${CI_PROJECT_DIR}/ci/argocd/get_graph_url.sh)
poetry run pytest -s --onlyapi
shell: bash

deploy-apitest-env:
name: Deploy APITest Env
needs:
- docker
- start-apitest-env
uses: ./.github/workflows/tpl-deploy-app.yml
with:
# ---
env-type: apitest
branch-head-ref: ${{ github.ref }}
image-tag: ${{ github.sha }}
pull-request-id: ${{ github.event.pull_request.number }}
workflow-id: ${{ github.run_id }}
env-id: ${{ needs.start-apitest-env.outputs.env-id }}
deployment-id: ${{ needs.start-apitest-env.outputs.deployment-id }}
# ---
deploy-contracts: false
chain-id: 1337
network-name: localhost
chain-name: localhost
snapshotter-enabled: false
multisigger-enabled: false
web-client-replicas: 0
coin-prices-server-replicas: 0
backend-server-replicas: 0
multideployer-enabled: true
subgraph-deploy: false
graph-healtchecker-enabled: false
secrets: inherit

start-apitest-env:
name: Start APITest Env
needs:
- permissions-check
uses: ./.github/workflows/tpl-start-env.yml
secrets: inherit
with:
env-type: apitest
git-ref: ${{ github.ref }}
pull-request-id: ${{ github.event.pull_request.number }}
workflow-id: ${{ github.run_id }}

docker:
name: Docker
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react';
import React, { FC, memo } from 'react';
import { Trans, useTranslation } from 'react-i18next';

import Button from 'components/ui/Button';
Expand Down Expand Up @@ -89,4 +89,4 @@ const ModalSettingsCalculatingYourUniqueness: FC<ModalSettingsCalculatingYourUni
);
};

export default ModalSettingsCalculatingYourUniqueness;
export default memo(ModalSettingsCalculatingYourUniqueness);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react';
import React, { FC, memo } from 'react';
import { useTranslation } from 'react-i18next';

import SettingsRecalculatingScore from 'components/Settings/SettingsRecalculatingScore';
Expand All @@ -24,4 +24,4 @@ const ModalSettingsRecalculatingScore: FC<ModalSettingsRecalculatingScoreProps>
);
};

export default ModalSettingsRecalculatingScore;
export default memo(ModalSettingsRecalculatingScore);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cx from 'classnames';
import { motion } from 'framer-motion';
import React, { FC, memo } from 'react';
import React, { FC, memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useAccount } from 'wagmi';

Expand Down Expand Up @@ -30,6 +30,7 @@ const SettingsAddressScore: FC<SettingsAddressScoreProps> = ({
const { address: activeAddress } = useAccount();

const isActive = activeAddress === address;
const truncatedEthAddress = useMemo(() => address && truncateEthAddress(address), [address]);

return (
<motion.div
Expand Down Expand Up @@ -62,7 +63,7 @@ const SettingsAddressScore: FC<SettingsAddressScoreProps> = ({
)}
</div>
<div className={styles.addressWrapper}>
<div className={styles.address}>{truncateEthAddress(address)}</div>
<div className={styles.address}>{truncatedEthAddress}</div>
<span className={cx(styles.badge, badge === 'secondary' && styles.secondary)}>{badge}</span>
</div>
{mode === 'score' && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cx from 'classnames';
import { animate } from 'framer-motion';
import React, { FC, memo, useEffect, useRef } from 'react';
import React, { FC, useEffect, useMemo, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { useAccount } from 'wagmi';

Expand Down Expand Up @@ -35,14 +35,26 @@ const SettingsUniquenessScoreAddresses: FC<SettingsUniquenessScoreAddressesProps
secondaryAddressScore: state.data.secondaryAddressScore,
}));

const addresses =
(isDelegationCompleted && delegationPrimaryAddress && delegationSecondaryAddress) ||
(delegationPrimaryAddress && delegationSecondaryAddress === '0x???')
? [delegationPrimaryAddress, delegationSecondaryAddress]
: [accountAddress];
const addresses = useMemo(() => {
if (
(isDelegationCompleted && delegationPrimaryAddress && delegationSecondaryAddress) ||
(delegationPrimaryAddress && delegationSecondaryAddress === '0x???')
) {
return [delegationPrimaryAddress, delegationSecondaryAddress];
}

return [accountAddress];
}, [delegationPrimaryAddress, delegationSecondaryAddress, isDelegationCompleted, accountAddress]);

const showMoreThanOneAddress = addresses.length > 1;

const addressesToShow = useMemo(() => {
if (showMoreThanOneAddress) {
return addresses.map(address => address.slice(0, 5)).join(', ');
}
return truncateEthAddress(addresses.at(0) || '');
}, [showMoreThanOneAddress, addresses]);

useEffect(() => {
if (isFetchingScore || !ref?.current) {
return;
Expand Down Expand Up @@ -78,11 +90,7 @@ const SettingsUniquenessScoreAddresses: FC<SettingsUniquenessScoreAddressesProps
))}
</div>
<div className={styles.addresses}>
<div className={styles.addressesGroup}>
{showMoreThanOneAddress
? addresses.map(address => address.slice(0, 5)).join(', ')
: truncateEthAddress(addresses.at(0) || '')}
</div>
<div className={styles.addressesGroup}>{addressesToShow}</div>
<div className={styles.numberOfAddresses}>
{showMoreThanOneAddress ? `${addresses?.length} ${t('addresses')}` : t('primary')}
</div>
Expand All @@ -94,4 +102,4 @@ const SettingsUniquenessScoreAddresses: FC<SettingsUniquenessScoreAddressesProps
);
};

export default memo(SettingsUniquenessScoreAddresses);
export default SettingsUniquenessScoreAddresses;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { watchAccount } from '@wagmi/core';
import uniq from 'lodash/uniq';
import React, { ReactNode, memo, useEffect, useState } from 'react';
import React, { ReactNode, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useAccount, useConnectors } from 'wagmi';

Expand Down Expand Up @@ -33,7 +33,7 @@ const SettingsUniquenessScoreBox = (): ReactNode => {

const { data: uqScore, isFetching: isFetchingUqScore } = useUqScore(currentEpoch!);

const [isRecalculatingScoreModalOpen, setIisRecalculatingScoreModalOpen] = useState(false);
const [isRecalculatingScoreModalOpen, setIsRecalculatingScoreModalOpen] = useState(false);
const [isCalculatingYourUniquenessModalOpen, setIsCalculatingYourUniquenessModalOpen] =
useState(false);

Expand Down Expand Up @@ -75,6 +75,22 @@ const SettingsUniquenessScoreBox = (): ReactNode => {
: primaryAddressScore === null || primaryAddressScore !== address,
);

const isRecalculateButtonDisabled =
isDelegationCompleted ||
isFetchingScore ||
isFetchingUqScore ||
delegationSecondaryAddress === '0x???';

const isDelegateButtonDisabled =
isDelegationCompleted ||
isFetchingScore ||
primaryAddressScore === null ||
primaryAddressScore === undefined ||
primaryAddressScore >= 20 ||
isFetchingUqScore ||
uqScore === 100n ||
delegationSecondaryAddress === '0x???';

const { mutateAsync: checkDelegationMutation } = useCheckDelegation();
const {
mutateAsync: refreshAntisybilStatus,
Expand All @@ -95,6 +111,30 @@ const SettingsUniquenessScoreBox = (): ReactNode => {
},
);

const modalSettingsCalculatingUQScoreProps = useMemo(() => {
return {
isOpen: isDelegationCalculatingUQScoreModalOpen,
onClosePanel: () => setIsDelegationCalculatingUQScoreModalOpen(false),
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isDelegationCalculatingUQScoreModalOpen]);

const modalSettingsRecalculatingScoreProps = useMemo(() => {
return {
isOpen: isRecalculatingScoreModalOpen,
onClosePanel: () => setIsRecalculatingScoreModalOpen(false),
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isRecalculatingScoreModalOpen]);

const modalSettingsCalculatingYourUniquenessProps = useMemo(() => {
return {
isOpen: isCalculatingYourUniquenessModalOpen,
onClosePanel: () => setIsCalculatingYourUniquenessModalOpen(false),
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isCalculatingYourUniquenessModalOpen]);

const checkDelegation = async () => {
if (!isUserTOSAccepted) {
return;
Expand Down Expand Up @@ -220,30 +260,16 @@ const SettingsUniquenessScoreBox = (): ReactNode => {
<div className={styles.buttonsWrapper}>
<Button
className={styles.button}
isDisabled={
isDelegationCompleted ||
isFetchingScore ||
isFetchingUqScore ||
delegationSecondaryAddress === '0x???'
}
isDisabled={isRecalculateButtonDisabled}
isHigh
onClick={() => setIisRecalculatingScoreModalOpen(true)}
onClick={() => setIsRecalculatingScoreModalOpen(true)}
variant="cta"
>
{t('recalculate')}
</Button>
<Button
className={styles.button}
isDisabled={
isDelegationCompleted ||
isFetchingScore ||
primaryAddressScore === null ||
primaryAddressScore === undefined ||
primaryAddressScore >= 20 ||
isFetchingUqScore ||
uqScore === 100n ||
delegationSecondaryAddress === '0x???'
}
isDisabled={isDelegateButtonDisabled}
isHigh
onClick={() => {
setIsDelegationInProgress(true);
Expand All @@ -254,27 +280,14 @@ const SettingsUniquenessScoreBox = (): ReactNode => {
{t('delegate')}
</Button>
</div>
<ModalSettingsCalculatingUQScore
modalProps={{
isOpen: isDelegationCalculatingUQScoreModalOpen,
onClosePanel: () => setIsDelegationCalculatingUQScoreModalOpen(false),
}}
/>
<ModalSettingsRecalculatingScore
modalProps={{
isOpen: isRecalculatingScoreModalOpen,
onClosePanel: () => setIisRecalculatingScoreModalOpen(false),
}}
/>
<ModalSettingsCalculatingUQScore modalProps={modalSettingsCalculatingUQScoreProps} />
<ModalSettingsRecalculatingScore modalProps={modalSettingsRecalculatingScoreProps} />
<ModalSettingsCalculatingYourUniqueness
modalProps={{
isOpen: isCalculatingYourUniquenessModalOpen,
onClosePanel: () => setIsCalculatingYourUniquenessModalOpen(false),
}}
modalProps={modalSettingsCalculatingYourUniquenessProps}
/>
</>
</BoxRounded>
);
};

export default memo(SettingsUniquenessScoreBox);
export default SettingsUniquenessScoreBox;
4 changes: 3 additions & 1 deletion client/src/components/shared/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ const Layout: FC<LayoutProps> = ({
};
const [currentPeriod, setCurrentPeriod] = useState(() => getCurrentPeriod());

const truncatedEthAddress = useMemo(() => address && truncateEthAddress(address), [address]);

const tabsWithIsActive = useMemo(() => {
let tabs = navigationTabsDefault;

Expand Down Expand Up @@ -222,7 +224,7 @@ const Layout: FC<LayoutProps> = ({
!isProjectAdminMode && isPatronMode && styles.isPatronMode,
)}
>
{truncateEthAddress(address)}
{truncatedEthAddress}
</div>
</div>
{!!currentEpoch &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const LayoutWallet: FC<LayoutWalletProps> = ({ onDisconnect }) => {
disconnect();
};

const truncatedEthAddress = useMemo(() => address && truncateEthAddress(address), [address]);

const sections: SectionProps[] = [
{
doubleValueProps: {
Expand Down Expand Up @@ -93,7 +95,7 @@ const LayoutWallet: FC<LayoutWalletProps> = ({ onDisconnect }) => {
href={`${networkConfig.etherscanAddress}/address/${address}`}
variant="link"
>
{truncateEthAddress(address)}
{truncatedEthAddress}
</Button>
) : undefined
}
Expand Down

0 comments on commit 0dd53fc

Please sign in to comment.