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 Feb 27, 2024
2 parents 461b492 + 86a7fba commit d1944ff
Show file tree
Hide file tree
Showing 161 changed files with 1,283 additions and 1,740 deletions.
1 change: 1 addition & 0 deletions backend/app/infrastructure/routes/rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def get(self, user_address, epoch):
"epoch": "Epoch number",
},
)
@ns.response(404, "User userAddress does not have a budget for epoch epochNumber")
class EpochBudgets(OctantResource):
@ns.marshal_with(epoch_budget_model)
@ns.response(200, "Epoch individual budgets successfully retrieved")
Expand Down
17 changes: 12 additions & 5 deletions backend/app/modules/user/budgets/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ def get_budget(user_address: str, epoch_num: int) -> int:


def estimate_budget(lock_duration_sec: int, glm_amount: int) -> int:
current = state_context(EpochState.CURRENT)
current_rewards = get_services(EpochState.CURRENT).octant_rewards_service
current_context = state_context(EpochState.CURRENT)
current_rewards_service = get_services(EpochState.CURRENT).octant_rewards_service
current_rewards = current_rewards_service.get_octant_rewards(current_context)

future = state_context(EpochState.FUTURE)
future_rewards = get_services(EpochState.FUTURE).octant_rewards_service
future_context = state_context(EpochState.FUTURE)
future_rewards_service = get_services(EpochState.FUTURE).octant_rewards_service
future_rewards = future_rewards_service.get_octant_rewards(future_context)

return core.estimate_budget(
current, future, current_rewards, future_rewards, lock_duration_sec, glm_amount
current_context,
future_context,
current_rewards,
future_rewards,
lock_duration_sec,
glm_amount,
)
12 changes: 6 additions & 6 deletions ci/argocd/contracts/master.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
BLOCK_NUMBER=5133610
BLOCK_NUMBER=5347874
AUTH_CONTRACT_ADDRESS=0x5a0F45FC4b4952c7AAc8c7BBba40E780fF731af4
GLM_CONTRACT_ADDRESS=0x71432DD1ae7DB41706ee6a22148446087BdD0906
DEPOSITS_CONTRACT_ADDRESS=0x76FC9eb2540bb95283d4b8683E2F8c66Bf6A7742
EPOCHS_CONTRACT_ADDRESS=0x1Fe346Faf07d799AcD02Cb5c64996014aE52dFe1
PROPOSALS_CONTRACT_ADDRESS=0x5386722962738adBd6540Ed4cBDE92b0B2Cf0722
WITHDRAWALS_TARGET_CONTRACT_ADDRESS=0x7b1DdB72F8A5C3969b558601E762712c0090a02d
VAULT_CONTRACT_ADDRESS=0xfAFCcd342FE635F9d26AfD2D24b551f8f45603FE
DEPOSITS_CONTRACT_ADDRESS=0x0C3Bd96F93315B0628E03a15B385E2C226d85413
EPOCHS_CONTRACT_ADDRESS=0xC6D91Ba7a8fbEfcDCd5Bbe10997bd48542a99d5e
PROPOSALS_CONTRACT_ADDRESS=0x4D24C7641a22A672d3587DEEe0aEC25b45A819a6
WITHDRAWALS_TARGET_CONTRACT_ADDRESS=0x4De03CaD56d82869985e9843c4eCB39c7DD0be7F
VAULT_CONTRACT_ADDRESS=0xA87c7A622BbADB7eF306C23242FFfBDe3ed4c01a
4 changes: 0 additions & 4 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,3 @@ export interface BackendProposal {
```

Because of [this](https://github.com/cypress-io/cypress/discussions/26853).

## E2E tests

Some e2e tests can't be run in CI because of a problem with the high price of gas on the local chain (for the first transaction). We can't deal with this through synpress (lack of functionality), so until the gas price is fixed (flat-gas) [OCT-1340] (https://linear.app/golemfoundation/issue/OCT-1340/cypress-enable-tests-blocked-by-non-flat-gas-price), we split the tests into enabled (yarn synpress:run) and disabled (yarn synpress:run-disabled-on-ci) on CI .
118 changes: 0 additions & 118 deletions client/cypress/e2e/disabled-on-ci.cy.ts

This file was deleted.

97 changes: 96 additions & 1 deletion client/cypress/e2e/earn.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const connectWallet = (): Chainable => {
return cy.switchToCypressWindow();
};

Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDesktop }) => {
Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDesktop }, idx) => {
describe(`earn: ${device}`, { viewportHeight, viewportWidth }, () => {
before(() => {
/**
Expand Down Expand Up @@ -87,5 +87,100 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDes
cy.get('[data-test=BoxGlmLock__Button]').click();
cy.get('[data-test=ModalGlmLock__overflow]').should('exist');
});

it('Wallet connected: Lock 1 GLM', () => {
connectWallet();

cy.get('[data-test=BoxGlmLock__Button]').click();
cy.get('[data-test=BudgetBox__currentlyLocked__value]')
.invoke('text')
.then(text => {
const amountToLock = 1;
const lockedGlms = parseInt(text, 10);

cy.get('[data-test=InputsCryptoFiat__InputText--crypto]').clear().type(`${amountToLock}`);
cy.get('[data-test=GlmLockTabs__Button]').should('have.text', 'Lock');
cy.get('[data-test=GlmLockTabs__Button]').click();
cy.get('[data-test=GlmLockTabs__Button]').should('have.text', 'Waiting for confirmation');
cy.confirmMetamaskPermissionToSpend({
spendLimit: '99999999999999999999',
});
// Workaround for two notifications during first transaction.
// 1. Allow the third party to spend TKN from your current balance.
// 2. Confirm permission to spend
if (Cypress.env('CI') === 'true' && idx === 0) {
cy.wait(1000);
cy.confirmMetamaskPermissionToSpend({
spendLimit: '99999999999999999999',
});
}
cy.get('[data-test=GlmLockTabs__Button]', { timeout: 180000 }).should(
'have.text',
'Close',
);
cy.get('[data-test=GlmLockNotification--success]').should('be.visible');
cy.get('[data-test=GlmLockTabs__Button]').click();
cy.get(
'[data-test=BoxGlmLock__Section--current__DoubleValue__DoubleValueSkeleton]',
).should('be.visible');
cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__primary]', {
timeout: 60000,
})
.invoke('text')
.then(nextText => {
const lockedGlmsAfterLock = parseInt(nextText, 10);
expect(lockedGlms + amountToLock).to.be.eq(lockedGlmsAfterLock);
});
cy.get('[data-test=HistoryItem__title]').first().should('have.text', 'Locked GLM');
cy.get('[data-test=HistoryItem__DoubleValue__primary]')
.first()
.should('have.text', '1 GLM');
});
});

it('Wallet connected: Unlock 1 GLM', () => {
connectWallet();

cy.get('[data-test=BoxGlmLock__Button]').click();
cy.get('[data-test=BudgetBox__currentlyLocked__value]')
.invoke('text')
.then(text => {
const amountToUnlock = 1;
const lockedGlms = parseInt(text, 10);

cy.get('[data-test=BoxRounded__tab--1]').click();
cy.get('[data-test=InputsCryptoFiat__InputText--crypto]')
.clear()
.type(`${amountToUnlock}`);
cy.get('[data-test=GlmLockTabs__Button]').should('have.text', 'Unlock');
cy.get('[data-test=GlmLockTabs__Button]').click();
cy.get('[data-test=GlmLockTabs__Button]').should('have.text', 'Waiting for confirmation');
cy.confirmMetamaskPermissionToSpend({
shouldWaitForPopupClosure: true,
spendLimit: '99999999999999999999',
});
cy.get('[data-test=GlmLockTabs__Button]', { timeout: 60000 }).should(
'have.text',
'Close',
);
cy.get('[data-test=GlmLockNotification--success]').should('be.visible');
cy.get('[data-test=GlmLockTabs__Button]').click();
cy.get(
'[data-test=BoxGlmLock__Section--current__DoubleValue__DoubleValueSkeleton]',
).should('be.visible');
cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__primary]', {
timeout: 60000,
})
.invoke('text')
.then(nextText => {
const lockedGlmsAfterUnlock = parseInt(nextText, 10);
expect(lockedGlms - amountToUnlock).to.be.eq(lockedGlmsAfterUnlock);
});
cy.get('[data-test=HistoryItem__title]').first().should('have.text', 'Unlocked GLM');
cy.get('[data-test=HistoryItem__DoubleValue__primary]')
.first()
.should('have.text', '1 GLM');
});
});
});
});
25 changes: 24 additions & 1 deletion client/cypress/e2e/layout.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,34 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) =>
cy.get('[data-test=MainLayout__Header]').should('be.visible');
});

it('Octant logo redirects to projects view', () => {
it('Clicking on Octant logo scrolls view to the top on logo click (projects view)', () => {
cy.scrollTo(0, 500);
cy.get('[data-test=MainLayout__Logo]').click();
// waiting for scrolling to finish
cy.wait(2000);
cy.window().then(cyWindow => {
expect(cyWindow.scrollY).to.be.eq(0);
});
});

it('Clicking on Octant logo redirects to projects view (outside projects view)', () => {
cy.get('[data-test=Navbar__Button--Settings]').click();
cy.get('[data-test=SettingsView]').should('be.visible');
cy.get('[data-test=MainLayout__Logo]').click();
cy.get('[data-test=ProposalsView]').should('be.visible');
});

it('Clicking on Octant logo redirects to projects view (outside projects view) with memorized scrollY', () => {
cy.scrollTo(0, 500);
cy.get('[data-test=Navbar__Button--Settings]').click();
cy.get('[data-test=SettingsView]').should('be.visible');
cy.get('[data-test=MainLayout__Logo]').click();
cy.get('[data-test=ProposalsView]').should('be.visible');
cy.window().then(cyWindow => {
expect(cyWindow.scrollY).to.be.eq(500);
});
});

it('renders bottom navbar', () => {
cy.get('[data-test=Navbar]').should('be.visible');
});
Expand Down
6 changes: 2 additions & 4 deletions client/cypress/e2e/settings.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { BigNumber } from 'ethers';

import { visitWithLoader, navigateWithCheck, mockCoinPricesServer } from 'cypress/utils/e2e';
import viewports from 'cypress/utils/viewports';
import { FIAT_CURRENCIES_SYMBOLS, DISPLAY_CURRENCIES } from 'src/constants/currencies';
Expand Down Expand Up @@ -74,7 +72,7 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) =>

const cryptoValue = getValueCryptoToDisplay({
cryptoCurrency: 'golem',
valueCrypto: BigNumber.from(0),
valueCrypto: BigInt(0),
});

cy.get('[data-test=BoxGlmLock__Section--effective__DoubleValue__primary]')
Expand All @@ -91,7 +89,7 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight }) =>

const cryptoValue = getValueCryptoToDisplay({
cryptoCurrency: 'golem',
valueCrypto: BigNumber.from(0),
valueCrypto: BigInt(0),
});

cy.get('[data-test=BoxGlmLock__Section--effective__DoubleValue__primary]')
Expand Down
7 changes: 7 additions & 0 deletions client/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { QueryClient } from '@tanstack/react-query';

import {
WINDOW_PROPOSALS_LOADED_ARCHIVED_EPOCHS_NUMBER,
WINDOW_PROPOSALS_SCROLL_Y,
} from 'constants/window';

export declare global {
interface Window {
Cypress?: Cypress.Cypress;
[WINDOW_PROPOSALS_LOADED_ARCHIVED_EPOCHS_NUMBER]?: number;
[WINDOW_PROPOSALS_SCROLL_Y]?: number;
clientReactQuery?: QueryClient;
}
}
6 changes: 1 addition & 5 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@
"test": "TZ=UTC jest",
"type-check": "tsc --noEmit true",
"synpress:open": "synpress open --configFile synpress.config.ts",
"synpress:run": "synpress run --configFile synpress.config.ts --config excludeSpecPattern=./cypress/e2e/disabled-on-ci.cy.ts",
"synpress:run-disabled-on-ci": "synpress run --configFile synpress.config.ts --config specPattern=./cypress/e2e/disabled-on-ci.cy.ts"
"synpress:run": "synpress run --configFile synpress.config.ts"
},
"dependencies": {
"@ethersproject/constants": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@tanstack/react-query": "^5.18.0",
"@wagmi/connectors": "^3.1.5",
"@web3modal/ethereum": "2.7.1",
Expand All @@ -42,7 +39,6 @@
"classnames": "^2.5.1",
"date-fns": "^3.3.1",
"dotenv": "^16.4.1",
"ethers": "^5.7.2",
"formik": "^2.4.5",
"framer-motion": "^11.0.3",
"graphql": "^16.8.1",
Expand Down
Binary file removed client/public/images/tip-stats-hor.webp
Binary file not shown.
Binary file removed client/public/images/tip-stats-vert.webp
Binary file not shown.
1 change: 1 addition & 0 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import 'i18n';
const App = (): ReactElement => {
useManageTransactionsPending();
useAppPopulateState();

const [isFlushRequired, setIsFlushRequired] = useState(false);
const { isSyncingInProgress } = useAppConnectManager(isFlushRequired, setIsFlushRequired);
const isLoading = useAppIsLoading(isFlushRequired);
Expand Down
Loading

0 comments on commit d1944ff

Please sign in to comment.