Skip to content

Commit

Permalink
Merge pull request #503 from tzConnectBerlin/release/0.7.2
Browse files Browse the repository at this point in the history
chore: release 0.7.2
  • Loading branch information
shekhar-shubhendu authored Aug 25, 2021
2 parents c64c21d + ee33257 commit ddfd9d1
Show file tree
Hide file tree
Showing 15 changed files with 177 additions and 209 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prediction-market-ui",
"version": "0.7.1",
"version": "0.7.2",
"private": false,
"license": "MIT",
"dependencies": {
Expand Down
9 changes: 9 additions & 0 deletions src/api/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ export const getAllTokenSupply = async (): Promise<AllTokens> => {
totalSupply: tokensTotalSupply
tokenReserve: tokensInReserve
deleted
txContext {
blockInfo: levelByLevel {
block: _level
bakedAt
}
operationGroupNumber
operationNumber
contentNumber
}
}
}
}
Expand Down
47 changes: 21 additions & 26 deletions src/api/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { differenceInDays } from 'date-fns/esm';
import * as R from 'ramda';
import { string } from 'yup/lib/locale';
import {
GraphMarket,
Market,
Expand Down Expand Up @@ -33,12 +32,6 @@ const includesInsensitive = (child: string) => (parent: string) =>
export const searchMarket = (markets: Market[], search: string): Market[] =>
R.filter(R.propSatisfies(includesInsensitive(search), 'question'), markets);

export const sortById = R.sortBy(R.prop('id'));

export const sortByBlock = (data: any): any =>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
R.sortWith([R.path(['txContext', 'blockInfo', 'block'])])(data);
export const findBetByOriginator = (bets: Bet[], originator: string): Bet | undefined =>
R.find(R.propEq('originator', originator))(bets) as Bet | undefined;
export const findBetByMarketId = (bets: Bet[], marketId: string): Bet | undefined =>
Expand All @@ -62,14 +55,16 @@ export const getOpenMarkets = (markets: Market[]): Market[] =>
export const getClosedMarkets = (markets: Market[]): Market[] =>
R.filter(filterMarketClosed, markets);

const byLevel = R.descend(R.path(['txContext', 'blockInfo', 'block']));
const byOperationNumber = R.descend(R.path(['txContext', 'operationNumber']));
const byOperationGroupNumber = R.descend(R.path(['txContext', 'operationGroupNumber']));
const byContentNumber = R.descend(R.path(['txContext', 'contentNumber']));
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
export const orderByTxContext = (data: T): T =>
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
R.sortWith([byOperationGroupNumber, byContentNumber])(data);
R.sortWith([byLevel, byOperationGroupNumber, byOperationNumber, byContentNumber])(data);

export const toMarket = async (
graphMarket: GraphMarket,
Expand Down Expand Up @@ -196,12 +191,7 @@ export const normalizeGraphBets = ({
const betNodes: LqtProviderNode[] = R.pluck('lqtProviderNode', lqtProviderEdge);
const groupedBets = R.groupBy(R.prop('originator'), betNodes);
return Object.keys(groupedBets).reduce((prev, originator) => {
const lqtNode = R.reduce(
(acc, cur: LqtProviderNode) =>
cur.bets.betEdges[0]?.bet?.quantity > acc?.bets?.betEdges?.[0]?.bet?.quantity ? cur : acc,
sortByBlock(groupedBets[originator])[0],
sortByBlock(groupedBets[originator]),
);
const lqtNode = orderByTxContext(groupedBets[originator]);
const edges: BetEdge[] = R.pathOr([], ['bets', 'betEdges'], lqtNode);
if (lqtNode && edges.length > 0) {
prev.push({
Expand All @@ -223,12 +213,7 @@ export const normalizeGraphBetSingleOriginator = ({
const groupedBets = R.groupBy(R.prop('marketId'), betNodes);
const address = betNodes[0].originator;
return Object.keys(groupedBets).reduce((prev, marketId) => {
const lqtNode = R.reduce(
(acc, cur: LqtProviderNode) =>
cur.bets.betEdges[0]?.bet?.quantity > acc?.bets?.betEdges?.[0]?.bet?.quantity ? cur : acc,
sortByBlock(groupedBets[marketId])[0],
sortByBlock(groupedBets[marketId]),
);
const lqtNode = orderByTxContext(groupedBets[marketId]);
const edges: BetEdge[] = R.pathOr([], ['bets', 'betEdges'], lqtNode);
if (lqtNode && edges.length > 0) {
prev.push({
Expand All @@ -248,9 +233,11 @@ export const normalizeSupplyMaps = ({
}: AllTokens): TokenSupplyMap[] => {
const groupedSupplyMaps = R.groupBy(R.prop('tokenId'), supplyMaps);
return Object.keys(groupedSupplyMaps).reduce((prev, tokenId) => {
const tokenMap = R.last(sortByBlock(groupedSupplyMaps[tokenId])) as unknown as
| TokenSupplyMap
| undefined;
const tokenMap = R.pathOr(
null,
[0],
orderByTxContext(groupedSupplyMaps[tokenId]),
) as unknown as TokenSupplyMap | undefined;
if (tokenMap) {
prev.push(tokenMap);
}
Expand Down Expand Up @@ -337,9 +324,17 @@ export const toMarketPriceData = (marketId: string, tokens: Token[]): MarketPric
}, noTokens);

return Object.keys(groupedYesTokens).reduce((acc, block) => {
const lastYesValue = R.last(sortById(groupedYesTokens[block]));
const lastNoValue = R.last(sortById(groupedNoTokens[block]));
if (lastYesValue && lastNoValue) {
const lastYesValue: Token | null = R.pathOr(
null,
[0],
orderByTxContext(groupedYesTokens[block]),
) as unknown as Token | null;
const lastNoValue: Token | null = R.pathOr(
null,
[0],
orderByTxContext(groupedNoTokens[block]),
) as unknown as Token | null;
if (lastYesValue !== null && lastNoValue !== null) {
acc.push({
bakedAt: lastYesValue.txContext.blockInfo.bakedAt,
block: lastYesValue.txContext.blockInfo.block,
Expand Down
32 changes: 32 additions & 0 deletions src/design-system/atoms/TezosPMIcon/TezosPMBeta.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { SVGProps } from 'react';

export interface TezosPMProps extends SVGProps<SVGSVGElement> {
width?: number;
height?: number;
color?: string;
}

export const TezosPM: React.FC<TezosPMProps> = ({
fill = '#0166ff',
color = '#1d2227',
...rest
}) => {
return (
<svg
id="prefix__Layer_1"
data-name="Layer 1"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 300.96 30.45"
{...rest}
>
<path
fill={color}
d="M39 19.23v7.26h-4.22V5.9h8a9.2 9.2 0 014.07.85 6.25 6.25 0 012.75 2.41 6.75 6.75 0 01.95 3.56 5.93 5.93 0 01-2.07 4.77 8.65 8.65 0 01-5.74 1.74zm0-3.43h3.79a3.75 3.75 0 002.59-.8 2.9 2.9 0 00.88-2.27 3.36 3.36 0 00-.89-2.44 3.33 3.33 0 00-2.46-1H39zM61.79 15a12.15 12.15 0 00-1.47-.11c-1.55 0-2.56.52-3 1.57v10h-4.13V11.19h3.86l.12 1.81a3.78 3.78 0 013.4-2.1 4.4 4.4 0 011.28.18zM70.53 26.77a7.53 7.53 0 01-5.48-2.06 7.35 7.35 0 01-2.12-5.5v-.4a9.14 9.14 0 01.9-4.12 6.48 6.48 0 012.52-2.8 7 7 0 013.72-1 6.37 6.37 0 015 2 8 8 0 011.8 5.61v1.67h-9.79a3.78 3.78 0 001.19 2.4 3.65 3.65 0 002.53.91 4.4 4.4 0 003.69-1.72l2 2.25A6.07 6.07 0 0174 26a8.13 8.13 0 01-3.47.77zm-.47-12.57a2.57 2.57 0 00-2 .82 4.23 4.23 0 00-1 2.36h5.74v-.32a3 3 0 00-.73-2.06 2.62 2.62 0 00-2.01-.8zM78.5 18.73A9.21 9.21 0 0180.11 13a5.19 5.19 0 014.39-2.12 4.68 4.68 0 013.69 1.66V4.77h4.1v21.72H88.6l-.2-1.63a4.82 4.82 0 01-3.93 1.91 5.21 5.21 0 01-4.34-2.13 9.56 9.56 0 01-1.63-5.91zm4.09.3a6.06 6.06 0 00.75 3.3 2.44 2.44 0 002.17 1.15 2.75 2.75 0 002.68-1.6v-6a2.69 2.69 0 00-2.65-1.6q-2.96-.05-2.95 4.72zM95.43 7.23A2 2 0 0196 5.72a2.62 2.62 0 013.34 0 2 2 0 01.66 1.51 2 2 0 01-.63 1.53 2.64 2.64 0 01-3.33 0 2 2 0 01-.61-1.53zm4.34 19.26h-4.1v-15.3h4.1zM109.49 23.48a2.65 2.65 0 001.84-.63 2.17 2.17 0 00.74-1.65h3.83a5.2 5.2 0 01-.85 2.85 5.71 5.71 0 01-2.28 2 7.27 7.27 0 01-3.21.71 6.64 6.64 0 01-5.17-2.09 8.27 8.27 0 01-1.9-5.76v-.27a8.15 8.15 0 011.89-5.64 6.56 6.56 0 015.16-2.1 6.44 6.44 0 014.6 1.63 5.81 5.81 0 011.76 4.35h-3.83a2.8 2.8 0 00-.74-1.94 2.43 2.43 0 00-1.86-.75 2.46 2.46 0 00-2.16 1 6 6 0 00-.73 3.38V19a6.12 6.12 0 00.72 3.4 2.49 2.49 0 002.19 1.08zM123.12 7.43v3.76h2.62v3h-2.62v7.63a1.82 1.82 0 00.33 1.22 1.65 1.65 0 001.24.36 7 7 0 001.2-.09v3.09a8.21 8.21 0 01-2.47.37q-4.31 0-4.38-4.34v-8.24h-2.24v-3h2.2V7.43zM128 7.23a2 2 0 01.61-1.51 2.64 2.64 0 013.35 0 2 2 0 01.62 1.51 2 2 0 01-.63 1.53 2.63 2.63 0 01-3.32 0 2 2 0 01-.63-1.53zm4.34 19.26h-4.1v-15.3h4.1zM135.06 18.7a9.14 9.14 0 01.87-4.06 6.45 6.45 0 012.53-2.76 7.36 7.36 0 013.82-1 7 7 0 015.06 1.89 7.62 7.62 0 012.18 5.23v1a8 8 0 01-2 5.65 7.61 7.61 0 01-10.55 0 8.11 8.11 0 01-2-5.77zm4.08.29a5.76 5.76 0 00.82 3.33 2.95 2.95 0 004.67 0 6.32 6.32 0 00.83-3.65 5.68 5.68 0 00-.83-3.31 2.71 2.71 0 00-2.35-1.18 2.67 2.67 0 00-2.28 1.19 6.41 6.41 0 00-.86 3.63zM155.83 11.19L156 13a5.34 5.34 0 014.4-2.05 4.44 4.44 0 013.6 1.38 6.7 6.7 0 011.22 4.27v9.89h-4.12V16.7a2.63 2.63 0 00-.57-1.88 2.48 2.48 0 00-1.88-.59 2.79 2.79 0 00-2.58 1.47v10.79H152v-15.3zM181.3 5.9l5.29 14.93 5.26-14.93h5.57v20.59h-4.25v-5.63l.42-9.71L188 26.49h-2.91l-5.54-15.33.42 9.7v5.63h-4.24V5.9zM209.72 26.49a5.05 5.05 0 01-.41-1.37 4.94 4.94 0 01-3.86 1.65 5.41 5.41 0 01-3.72-1.3 4.17 4.17 0 01-1.48-3.28 4.31 4.31 0 011.8-3.73 8.9 8.9 0 015.21-1.32h1.88v-.88a2.52 2.52 0 00-.54-1.69 2.13 2.13 0 00-1.72-.64 2.43 2.43 0 00-1.62.5 1.67 1.67 0 00-.58 1.35h-4.09a4.11 4.11 0 01.82-2.46 5.47 5.47 0 012.32-1.77 8.42 8.42 0 013.36-.64 6.64 6.64 0 014.49 1.42 5 5 0 011.66 4V23a7.45 7.45 0 00.61 3.3v.24zm-3.38-2.84a3.5 3.5 0 001.67-.41 2.63 2.63 0 001.13-1.08v-2.63h-1.52c-2.05 0-3.14.71-3.27 2.12v.24a1.66 1.66 0 00.53 1.26 2.09 2.09 0 001.46.5zM225 15a12.15 12.15 0 00-1.47-.11c-1.55 0-2.56.52-3 1.57v10h-4.09V11.19h3.86l.12 1.82a3.78 3.78 0 013.4-2.1 4.4 4.4 0 011.28.18zM232.5 20.35l-1.5 1.47v4.67h-4.09V4.77H231v12l.79-1 3.92-4.59h4.91l-5.53 6.38 6 8.92h-4.7zM249.17 26.77a7.54 7.54 0 01-5.48-2.06 7.34 7.34 0 01-2.11-5.5v-.4a9.27 9.27 0 01.89-4.12 6.48 6.48 0 012.52-2.8 7 7 0 013.73-1 6.35 6.35 0 014.94 2 8 8 0 011.8 5.61v1.67h-9.74a3.75 3.75 0 001.2 2.4 3.61 3.61 0 002.52.91 4.4 4.4 0 003.69-1.72l2 2.25a6.1 6.1 0 01-2.49 2 8.13 8.13 0 01-3.47.76zm-.47-12.57a2.59 2.59 0 00-2 .82 4.31 4.31 0 00-1 2.36h5.69v-.32a3 3 0 00-.74-2.11 2.62 2.62 0 00-1.95-.75zM262.67 7.43v3.76h2.62v3h-2.62v7.63A1.82 1.82 0 00263 23a1.65 1.65 0 001.24.36 7 7 0 001.2-.09v3.13a8.21 8.21 0 01-2.47.37c-2.86 0-4.33-1.45-4.38-4.34v-8.24h-2.24v-3h2.24V7.43z"
/>
<path
fill={fill}
d="M273.21 15.1V6.8h2.91a3.79 3.79 0 012.29.58 2 2 0 01.78 1.7 1.87 1.87 0 01-.31 1.07 1.77 1.77 0 01-.88.68 1.72 1.72 0 011 .65 1.85 1.85 0 01.37 1.18 2.18 2.18 0 01-.77 1.81 3.42 3.42 0 01-2.17.63zm1.71-4.82h1.27c.86 0 1.29-.36 1.29-1a1 1 0 00-.33-.82 1.76 1.76 0 00-1-.24h-1.2zm0 1.21v2.24h1.47a1.43 1.43 0 00.94-.29 1 1 0 00.34-.8c0-.76-.39-1.14-1.18-1.15zM285.65 11.5h-3.28v2.23h3.85v1.37h-5.56V6.8h5.55v1.39h-3.84v2h3.28zM293.59 8.19h-2.54v6.91h-1.71V8.19h-2.51V6.8h6.76zM298.57 13.39h-3L295 15.1h-1.82l3.09-8.3h1.58l3.15 8.3h-1.82zM296 12h2.07l-1-3.11zM21.79 22.47c-.31-5.6-7.35-8.14-8-8.4V14L21 6.72v-.78a.24.24 0 00-.23-.24H7.41V0L2.47 1v.74h.28A1.19 1.19 0 014 3v2.69H.14a.15.15 0 00-.14.14v1.71h4v9.33c0 2.93 1.88 5 5.18 4.69a4.15 4.15 0 001.9-.69.85.85 0 00.4-.73v-.92a3.62 3.62 0 01-2 .68c-2.09 0-2.05-2.66-2.05-2.66v-9.7H17l-6.93 7v1.65c0 .01 0 0 0 0 6.35 1.08 8.06 5.18 8.06 6.38 0 0 .69 5.81-5.12 6.21 0 0-3.81.17-4.48-1.36a.11.11 0 01.05-.14A1.71 1.71 0 009.7 25.7a1.94 1.94 0 00-2.13-2.05 2.1 2.1 0 00-2.13 2.05s-.55 4.89 7.61 4.75c9.32-.16 8.74-7.98 8.74-7.98z"
/>
</svg>
);
};
2 changes: 2 additions & 0 deletions src/design-system/atoms/TezosPMIcon/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { TezosPM, TezosPM as default } from './TezosPMBeta';
export type { TezosPMProps } from './TezosPMBeta';
3 changes: 0 additions & 3 deletions src/design-system/molecules/Header/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ describe('Element testing Header Component', () => {
handleDisconnect={() => {}}
/>,
);

expect(getByText(/Prediction Market/i)).toBeInTheDocument();
expect(getByText(/Sign in/i)).toBeInTheDocument();
expect(queryAllByText(/Disconnect Wallet/i).length).toEqual(0);
});
Expand All @@ -86,7 +84,6 @@ describe('Element testing Header Component', () => {
if (img) {
fireEvent.click(img);
}
expect(getByText(/Prediction Market/i)).toBeInTheDocument();
expect(getByText(/Disconnect Wallet/i)).toBeInTheDocument();
expect(queryAllByText(/Sign in/i).length).toEqual(0);
});
Expand Down
11 changes: 2 additions & 9 deletions src/design-system/molecules/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ProfilePopover } from '../ProfilePopover';
import { Links } from '../../../interfaces';
import { Identicon } from '../../atoms/Identicon';
import { CustomButton } from '../../atoms/Button';
import { TezosPM } from '../../atoms/TezosPMIcon';

export interface HeaderProps {
title: string;
Expand Down Expand Up @@ -78,15 +79,7 @@ export const Header: React.FC<HeaderProps> = ({
cursor: 'pointer',
}}
>
<TezosIcon onClick={handleHeaderClick} />
<Typography
size={isMobile ? 'h2' : 'h1'}
component="h1"
sx={{ marginX: 1, whiteSpace: 'nowrap' }}
onClick={handleHeaderClick}
>
{title}
</Typography>
<TezosPM height={30} onClick={handleHeaderClick} />
</Grid>
{/* TODO: Move Wallet connection box to a separate component */}
<Grid
Expand Down
Loading

1 comment on commit ddfd9d1

@vercel
Copy link

@vercel vercel bot commented on ddfd9d1 Aug 25, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.