Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhar-shubhendu committed Jul 28, 2021
2 parents a3e1330 + abf927b commit bad33dc
Show file tree
Hide file tree
Showing 62 changed files with 5,667 additions and 3,996 deletions.
8 changes: 4 additions & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
REACT_APP_APP_NAME=Prediction Market
REACT_APP_MARKET_CONTRACT=KT1Cupwd7N6Gx2nXXkrDoyUe7zTwXy2MxqEX
REACT_APP_FA12_CONTRACT=KT1XgDkZxyVQY3Gxs7UzfE7LKBJoC5jrb2Jv
REACT_APP_IPFS_API=https://ipfs.newby.org
REACT_APP_IPFS_PORT=443
REACT_APP_IPFS_POST_API=https://ipfs.newby.org/
REACT_APP_IPFS_GET_API=https://tzconnect.mypinata.cloud/ipfs/
REACT_APP_NETWORK_TYPE=FLORENCENET
REACT_APP_RPC_URL=https://florencenet.smartpy.io
REACT_APP_RPC_PORT=443
REACT_APP_GRAPHQL_API=https://kt1lybgnsg2gymfchavcxunjecqy59ujrwbf.tzconnect.berlin/graphql
REACT_APP_SENTRY_DSN=https://[email protected]/5756958
REACT_APP_GRAPHQL_API=https://pmcache.newby.org/graphql
REACT_APP_SENTRY_DSN=https://[email protected]/5756958f
8 changes: 4 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
REACT_APP_APP_NAME=Prediction Market
REACT_APP_MARKET_CONTRACT=KT1Cupwd7N6Gx2nXXkrDoyUe7zTwXy2MxqEX
REACT_APP_FA12_CONTRACT=KT1XgDkZxyVQY3Gxs7UzfE7LKBJoC5jrb2Jv
REACT_APP_IPFS_API=https://ipfs.newby.org
REACT_APP_IPFS_PORT=443
REACT_APP_IPFS_POST_API=https://ipfs.newby.org/
REACT_APP_IPFS_GET_API=https://tzconnect.mypinata.cloud/ipfs/
REACT_APP_NETWORK_TYPE=FLORENCENET
REACT_APP_RPC_URL=https://florencenet.smartpy.io
REACT_APP_RPC_PORT=443
REACT_APP_GRAPHQL_API=https://kt1lybgnsg2gymfchavcxunjecqy59ujrwbf.tzconnect.berlin/graphql
REACT_APP_SENTRY_DSN=https://[email protected]/5756958
REACT_APP_GRAPHQL_API=https://pmcache.newby.org/graphql
REACT_APP_SENTRY_DSN=https://[email protected]/5756958f
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ Note: PRs without proper commit messages might get rejected.

3. All feature/bug fix branches should be merged using `Squash and merge` button.

### Creating a Release

1. Create a `release` branch from develop.
2. Bump the version and commit in the release branch.
3. Merge release branch in `main`. DO NOT `Squash and merge`. Create a merge commit instead.
4. Create a release from `main`.
5. After merging, create a `realign` branch from `main` and `Squash and merge` the realign branch in `develop`.

---

## Conventions
Expand Down
140 changes: 69 additions & 71 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,60 @@
{
"name": "prediction-market-ui",
"version": "0.2.0",
"version": "0.3.0",
"private": true,
"license": "MIT",
"dependencies": {
"@airgap/beacon-sdk": "^2.2.7",
"@atlaskit/datetime-picker": "^10.2.1",
"@airgap/beacon-sdk": "2.3.1",
"@atlaskit/datetime-picker": "^11.0.0",
"@date-io/date-fns": "2.x",
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"@fontsource/roboto": "^4.3.0",
"@material-ui/core": "^5.0.0-alpha.35",
"@material-ui/data-grid": "^4.0.0-alpha.30",
"@material-ui/icons": "^5.0.0-alpha.35",
"@material-ui/lab": "^5.0.0-alpha.35",
"@material-ui/styles": "^5.0.0-alpha.35",
"@sentry/integrations": "^6.5.1",
"@sentry/react": "^6.5.1",
"@sentry/tracing": "^6.5.1",
"@storybook/react": "^6.2.9",
"@taquito/beacon-wallet": "^9.0.1",
"@taquito/michelson-encoder": "^9.0.1",
"@taquito/rpc": "^9.0.1",
"@taquito/signer": "^9.0.1",
"@taquito/taquito": "^9.0.1",
"@types/chart.js": "^2.9.32",
"@fontsource/roboto": "^4.5.0",
"@material-ui/core": "5.0.0-beta.1",
"@material-ui/data-grid": "^4.0.0-alpha.34",
"@material-ui/icons": "5.0.0-beta.1",
"@material-ui/lab": "5.0.0-alpha.40",
"@material-ui/styles": "5.0.0-beta.1",
"@nivo/core": "^0.73.0",
"@nivo/line": "^0.73.0",
"@sentry/integrations": "^6.10.0",
"@sentry/react": "^6.10.0",
"@sentry/tracing": "^6.10.0",
"@storybook/react": "^6.3.6",
"@taquito/beacon-wallet": "9.2.0",
"@taquito/michelson-encoder": "9.2.0",
"@taquito/rpc": "9.2.0",
"@taquito/signer": "9.2.0",
"@taquito/taquito": "9.2.0",
"@types/chart.js": "2.9.34",
"@tz-contrib/react-wallet-provider": "^1.0.0-alpha.9",
"axios": "^0.21.1",
"bignumber.js": "^9.0.1",
"blockies-ts": "^1.0.0",
"chart.js": "^3.3.0",
"chartjs-plugin-zoom": "^1.0.0",
"date-fns": "^2.21.3",
"formik": "^2.2.8",
"chart.js": "3.5.0",
"chartjs-plugin-zoom": "1.1.1",
"date-fns": "^2.23.0",
"formik": "^2.2.9",
"framer-motion": "^4.1.17",
"graphql": "^15.5.0",
"graphql": "^15.5.1",
"graphql-request": "^3.4.0",
"i18next": "^20.3.0",
"i18next-browser-languagedetector": "^6.1.1",
"i18next": "^20.3.5",
"i18next-browser-languagedetector": "^6.1.2",
"i18next-chained-backend": "^3.0.2",
"i18next-http-backend": "^1.2.6",
"i18next-localstorage-backend": "^3.1.2",
"ipfs-http-client": "50.0.0",
"it-all": "^1.0.5",
"i18next-http-backend": "^1.2.8",
"i18next-localstorage-backend": "^3.1.3",
"localforage": "^1.9.0",
"ramda": "^0.27.1",
"react": "^17.0.2",
"react-chartjs-2": "^3.0.3",
"react-chartjs-2": "^3.0.4",
"react-copy-to-clipboard": "^5.0.3",
"react-dom": "^17.0.2",
"react-helmet-async": "^1.0.9",
"react-i18next": "^11.9.0",
"react-i18next": "^11.11.4",
"react-icons": "^4.2.0",
"react-query": "^3.16.0",
"react-query": "^3.19.1",
"react-router-dom": "^5.2.0",
"react-toast-notifications": "^2.4.4",
"react-toast-notifications": "^2.5.1",
"yup": "^0.32.9"
},
"scripts": {
Expand Down Expand Up @@ -88,58 +89,58 @@
]
},
"devDependencies": {
"@axe-core/react": "^4.2.1",
"@babel/core": "^7.14.3",
"@commitlint/cli": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@axe-core/react": "^4.2.2",
"@babel/core": "^7.14.8",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@emotion/jest": "^11.3.0",
"@storybook/addon-actions": "^6.2.9",
"@storybook/addon-essentials": "^6.2.9",
"@storybook/addon-links": "^6.2.9",
"@storybook/node-logger": "^6.2.9",
"@storybook/preset-create-react-app": "^3.1.7",
"@testing-library/dom": "^7.31.0",
"@testing-library/jest-dom": "^5.12.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^13.1.9",
"@types/jest": "^26.0.23",
"@types/node": "^15.6.1",
"@types/ramda": "^0.27.40",
"@types/react": "^17.0.6",
"@types/react-copy-to-clipboard": "^5.0.0",
"@types/react-dom": "^17.0.5",
"@types/react-router-dom": "^5.1.7",
"@storybook/addon-actions": "^6.3.6",
"@storybook/addon-essentials": "^6.3.6",
"@storybook/addon-links": "^6.3.6",
"@storybook/node-logger": "^6.3.6",
"@storybook/preset-create-react-app": "^3.2.0",
"@testing-library/dom": "^8.1.0",
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^12.0.0",
"@testing-library/user-event": "^13.2.1",
"@types/jest": "^26.0.24",
"@types/node": "^16.4.3",
"@types/ramda": "^0.27.44",
"@types/react": "^17.0.15",
"@types/react-copy-to-clipboard": "^5.0.1",
"@types/react-dom": "^17.0.9",
"@types/react-router-dom": "^5.1.8",
"@types/react-test-renderer": "^17.0.1",
"@types/yup": "^0.29.11",
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"@types/yup": "^0.29.13",
"@typescript-eslint/eslint-plugin": "^4.28.5",
"@typescript-eslint/parser": "^4.28.5",
"babel-loader": "8.1.0",
"canvas": "^2.8.0",
"chromatic": "^5.8.3",
"chromatic": "^5.9.2",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.27.0",
"eslint": "^7.31.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.3",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.4.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^6.0.0",
"jest-junit": "^12.0.0",
"lint-staged": "^11.0.0",
"husky": "^7.0.1",
"jest-junit": "^12.2.0",
"lint-staged": "^11.1.1",
"pinst": "^2.1.6",
"prettier": "^2.3.0",
"prettier": "^2.3.2",
"react-scripts": "^4.0.3",
"react-test-renderer": "^17.0.2",
"rimraf": "^3.0.2",
"source-map-explorer": "^2.5.2",
"styled-components": "^5.3.0",
"typescript": "^4.2.4",
"web-encoding": "1.1.4"
"typescript": "^4.3.5",
"webpack": "4.44.2"
},
"config": {
"commitizen": {
Expand All @@ -165,8 +166,5 @@
"jest-junit": {
"outputDirectory": "./test-results/junit",
"outputName": "results.xml"
},
"resolutions": {
"web-encoding": "1.1.4"
}
}
4 changes: 0 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ import { WalletProvider } from '@tz-contrib/react-wallet-provider';
import { GlobalStyle } from './assets/styles/style';
import { lightTheme } from './theme';
import { AppRouter } from './router';
import { initIPFSClient } from './ipfs/ipfs';
import { initTezos, initMarketContract, initFA12Contract } from './contracts/Market';
import {
RPC_URL,
RPC_PORT,
IPFS_API,
IPFS_PORT,
MARKET_ADDRESS,
FA12_CONTRACT,
NETWORK,
Expand All @@ -33,7 +30,6 @@ const App: React.FC = () => {

useEffect(() => {
initTezos(RPC_URL, RPC_PORT);
initIPFSClient(IPFS_API, IPFS_PORT);
initMarketContract(MARKET_ADDRESS);
initFA12Contract(FA12_CONTRACT);
}, []);
Expand Down
6 changes: 6 additions & 0 deletions src/api/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const getTokenLedger = async (
tokenId: idxTokensTokenId
quantity: tokensNat4
block: _level
dateTime: levelByLevel {
bakedAt
}
}
}
}
Expand Down Expand Up @@ -87,6 +90,9 @@ export const getAllMarkets = async (): Promise<AllMarketsLedgers> => {
metadataDescription
metadataAdjudicator
state
dateTime: levelByLevel {
bakedAt
}
storageMarketMapMarketBootstrappeds(condition: { deleted: false }) {
nodes {
auctionRewardCurrencyPool: currencyPoolAuctionRewardCurrencyPool
Expand Down
69 changes: 63 additions & 6 deletions src/api/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ import { AxiosError } from 'axios';
import * as R from 'ramda';
import { useQuery, UseQueryResult } from 'react-query';
import { getUserBalance } from '../contracts/Market';
import { Bet, LedgerMap, Market, Token, TokenSupplyMap } from '../interfaces';
import {
AllMarketsLedgers,
AuctionMarkets,
Bet,
LedgerMap,
Market,
MarketPricePoint,
Token,
TokenSupplyMap,
} from '../interfaces';
import { MARKET_ADDRESS } from '../utils/globals';
import { tokenDivideDown } from '../utils/math';
import { getYesTokenId, getNoTokenId } from '../utils/misc';
import {
getAllLedgers,
getAllMarkets,
Expand All @@ -13,11 +24,13 @@ import {
getTokenLedger,
} from './graphql';
import {
normalizeAuctionData,
normalizeGraphBets,
normalizeGraphBetSingleOriginator,
normalizeGraphMarkets,
normalizeLedgerMaps,
normalizeSupplyMaps,
toMarketPriceData,
} from './utils';

export const useLedgerData = (): UseQueryResult<LedgerMap[]> => {
Expand Down Expand Up @@ -53,12 +66,29 @@ export const useTokenByAddress = (
);
};

const useAllMarkets = (): UseQueryResult<AllMarketsLedgers> => {
return useQuery<AllMarketsLedgers | undefined, AxiosError, AllMarketsLedgers>(
'allMarketsLedgers',
async () => {
return getAllMarkets();
},
);
};

export const useMarkets = (): UseQueryResult<Market[]> => {
return useQuery<Market[] | undefined, AxiosError, Market[]>('allMarkets', async () => {
const allMarkets = await getAllMarkets();
const ledger = normalizeLedgerMaps(allMarkets.ledgers.ledgerMaps);
return normalizeGraphMarkets(allMarkets.markets.marketNodes, ledger);
});
const { data } = useAllMarkets();
return useQuery<Market[] | undefined, AxiosError, Market[]>(
'allMarkets',
async () => {
if (data) {
const ledger = normalizeLedgerMaps(data.ledgers.ledgerMaps);
return normalizeGraphMarkets(data.markets.marketNodes, ledger);
}
},
{
enabled: Boolean(data),
},
);
};

export const useMarketBets = (marketId: string): UseQueryResult<Bet[]> => {
Expand All @@ -68,6 +98,33 @@ export const useMarketBets = (marketId: string): UseQueryResult<Bet[]> => {
});
};

export const useAuctionPriceChartData = (): UseQueryResult<AuctionMarkets> => {
const { data } = useAllMarkets();
return useQuery<AuctionMarkets | undefined, AxiosError, AuctionMarkets>(
'allAuctionMarkets',
async () => {
if (data) {
return normalizeAuctionData(data.markets.marketNodes);
}
},
{
enabled: Boolean(data),
},
);
};

export const useMarketPriceChartData = (marketId: string): UseQueryResult<MarketPricePoint[]> => {
const yesTokenId = getYesTokenId(marketId);
const noTokenId = getNoTokenId(marketId);
return useQuery<MarketPricePoint[] | undefined, AxiosError, MarketPricePoint[]>(
['marketTokensLedger', yesTokenId, noTokenId],
async () => {
const tokens = await getTokenLedger([yesTokenId, noTokenId], undefined, MARKET_ADDRESS);
return toMarketPriceData(marketId, tokens.tokenQuantity.token);
},
);
};

export const useAllMarketByAddress = (userAddress?: string): UseQueryResult<Bet[]> => {
return useQuery<Bet[] | undefined, AxiosError, Bet[]>(
['allMarketBetByAddress', userAddress],
Expand Down
Loading

0 comments on commit bad33dc

Please sign in to comment.