Skip to content

Commit

Permalink
Merge branch 'main' into feat/introduce-activities
Browse files Browse the repository at this point in the history
  • Loading branch information
devinxl authored May 11, 2024
2 parents d99b6c4 + 3f3df03 commit 66cbfa7
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 69 deletions.
27 changes: 27 additions & 0 deletions apps/dcellar-web-ui/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
{
"name": "dcellar-web-ui",
"entries": [
{
"version": "1.3.1",
"tag": "dcellar-web-ui_v1.3.1",
"date": "Sat, 11 May 2024 03:15:50 GMT",
"comments": {
"patch": [
{
"comment": "Upgrade nextjs to aviod attacks via CVE-2024-34351 vulnerability"
},
{
"comment": "Fix the issue with browser cache getObjectMeta API"
}
]
}
},
{
"version": "1.3.0",
"tag": "dcellar-web-ui_v1.3.0",
"date": "Fri, 10 May 2024 08:02:26 GMT",
"comments": {
"minor": [
{
"comment": "Cache pricing data for other landing page"
}
]
}
},
{
"version": "1.2.0",
"tag": "dcellar-web-ui_v1.2.0",
Expand Down
17 changes: 16 additions & 1 deletion apps/dcellar-web-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
# Change Log - dcellar-web-ui

This log was last generated on Thu, 09 May 2024 06:16:58 GMT and should not be manually modified.
This log was last generated on Sat, 11 May 2024 03:15:50 GMT and should not be manually modified.

## 1.3.1
Sat, 11 May 2024 03:15:50 GMT

### Patches

- Upgrade nextjs to aviod attacks via CVE-2024-34351 vulnerability
- Fix the issue with browser cache getObjectMeta API

## 1.3.0
Fri, 10 May 2024 08:02:26 GMT

### Minor changes

- Cache pricing data for other landing page

## 1.2.0
Thu, 09 May 2024 06:16:58 GMT
Expand Down
6 changes: 3 additions & 3 deletions apps/dcellar-web-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dcellar-web-ui",
"version": "1.2.0",
"version": "1.3.1",
"private": false,
"scripts": {
"dev": "node ./scripts/dev.js -p 3200",
Expand Down Expand Up @@ -34,7 +34,7 @@
"dayjs": "^1.11.7",
"ethers": "^5.7.2",
"lodash-es": "^4.17.21",
"next": "~14.1.0",
"next": "~14.1.1",
"query-string": "^8.1.0",
"react": "~18.2.0",
"react-dom": "~18.2.0",
Expand Down Expand Up @@ -80,7 +80,7 @@
"eslint-config-prettier": "~9.1.0",
"@typescript-eslint/eslint-plugin": "~7.0.2",
"@typescript-eslint/parser": "~7.0.2",
"eslint-config-next": "~14.1.0",
"eslint-config-next": "~14.1.1",
"eslint-plugin-react": "~7.33.2"
},
"lint-staged": {
Expand Down
40 changes: 24 additions & 16 deletions apps/dcellar-web-ui/src/facade/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -621,22 +621,30 @@ export const getObjectMeta = async (
objectName,
)}?object-meta`;

return axios.get(url).then(
(e) => {
const data = xmlParser.parse(e.data)?.GfSpGetObjectMetaResponse.Object as ObjectMeta;
return [data, null];
},
(e) => {
const { response } = e;
if (!response) return [null, { code: 500, message: 'Oops, something went wrong' }];

const error =
response?.status === 429
? { code: response.status, message: 'SP not available. Try later.' }
: { message: xmlParser.parse(response.data)?.Error?.Message, code: response.status };
return [null, error];
},
);
return axios
.get(url, {
headers: {
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},
})
.then(
(e) => {
const data = xmlParser.parse(e.data)?.GfSpGetObjectMetaResponse.Object as ObjectMeta;
return [data, null];
},
(e) => {
const { response } = e;
if (!response) return [null, { code: 500, message: 'Oops, something went wrong' }];

const error =
response?.status === 429
? { code: response.status, message: 'SP not available. Try later.' }
: { message: xmlParser.parse(response.data)?.Error?.Message, code: response.status };
return [null, error];
},
);
};

export const getObjectVersions = async (id: string): Promise<ObjectVersion[]> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ export const PricingCard = ({ storeParams }: PricingCardProps) => {
.times(storeTime)
.dp(CRYPTOCURRENCY_DISPLAY_PRECISION)
.toString();
return {

const fee = {
storageFee,
quotaFee,
storeParams,
};

return ((global as any).__MAINNET_CHAIN_FEE = fee);
}, [storeParams, unit.size, unit.time]);

return (
Expand Down
23 changes: 23 additions & 0 deletions apps/dcellar-web-ui/src/pages/api/fee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { NextApiRequest, NextApiResponse } from 'next';

const defaultFee = {
storageFee: '0.00004005',
quotaFee: '0.00015672',
storeParams: {
primarySpStorePrice: '0.00828393206',
readPrice: '0.05575446448',
secondarySpStorePrice: '0.0009940718472',
validatorTaxRate: '0.01',
minChargeSize: 131072,
redundantDataChunkNum: 4,
redundantParityChunkNum: 2,
reserveTime: '15552000',
},
};

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
const fee = (global as any).__MAINNET_CHAIN_FEE || defaultFee;
res.json(fee);
};

export default handler;
6 changes: 5 additions & 1 deletion apps/dcellar-web-ui/src/pages/pricing-calculator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { LandingPage } from '@/components/layout/LandingPage';
import { PriceCalculator } from '@/modules/pricing-calculator';
import { wrapper } from '@/store';
import { ReactElement } from 'react';
import { setupMainnetStoreFeeParams } from '@/store/slices/global';

export default function PriceCalculatorPage() {
return <PriceCalculator />;
Expand All @@ -11,7 +12,10 @@ PriceCalculatorPage.getLayout = (page: ReactElement) => {
return <LandingPage page={page} />;
};

PriceCalculatorPage.getInitialProps = wrapper.getInitialAppProps(() => async () => {
PriceCalculatorPage.getInitialProps = wrapper.getInitialAppProps((store) => async () => {
if (typeof window === 'undefined') {
await store.dispatch(setupMainnetStoreFeeParams());
}
return {
pageProps: {},
};
Expand Down
Loading

0 comments on commit 66cbfa7

Please sign in to comment.