Skip to content

Commit

Permalink
feat: Add MiningList component
Browse files Browse the repository at this point in the history
  • Loading branch information
yrjkqq committed Oct 15, 2024
1 parent 919bf8c commit 904be67
Show file tree
Hide file tree
Showing 27 changed files with 4,269 additions and 63 deletions.
39 changes: 7 additions & 32 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,20 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"plugin:react/recommended",
"airbnb",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended",
"plugin:react/jsx-runtime"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "react-hooks", "@typescript-eslint"],
"extends": ["next/core-web-vitals", "prettier"],

"settings": {
"import/resolver": {
"typescript": {
// use an array of glob patterns
"project": ["./packages/*/tsconfig.json"]
}
"next": {
"rootDir": "packages/*/"
}
},

"rules": {
"camelcase": "off",

// "max-len": ["warn", { "code": 80 }]
"no-use-before-define": "off",
"no-shadow": "off",
"no-console": ["error", { "allow": ["warn", "error"] }],
"no-unused-vars": "off",
"no-unused-vars": "warn",
"no-plusplus": [
"error",
{
Expand All @@ -53,12 +34,6 @@
"import/no-extraneous-dependencies": "warn",
"import/prefer-default-export": "off",

"@typescript-eslint/no-use-before-define": ["error"],
"@typescript-eslint/no-shadow": ["error"],
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": ["error"],

"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
],
"license": "GPL-3.0-or-later",
"devDependencies": {
"eslint": "^8.36.0",
"eslint-config-next": "^13.2.4",
"eslint-config-prettier": "^8.7.0",
"husky": "^8.0.3",
"lerna": "^5.4.0"
},
Expand Down
37 changes: 37 additions & 0 deletions packages/doc/src/stories/widgets/MiningList.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { SwapWidgetApi } from '@dodoex/api';
import { MiningList, SwapWidgetProps, Widget } from '@dodoex/widgets';
import React from 'react';

export default {
title: 'Widgets/MiningList',
component: 'div',
};

export const Primary = (props: any) => {
const [config, setConfig] = React.useState<SwapWidgetProps>({});
const { projectId, apiKey, ...other } = props;
React.useEffect(() => {
if (projectId && apiKey) {
const dodoService = new SwapWidgetApi();
dodoService
.getConfigSwapWidgetProps(projectId, apiKey)
.then(({ swapWidgetProps }) => {
setConfig(swapWidgetProps);
});
}
}, [projectId, apiKey]);
return (
<Widget {...config} {...other} apikey={apiKey}>
<MiningList onClickCreate={() => window.alert('Create')} />
</Widget>
);
};

Primary.args = {
projectId: 'project2',
apiKey: 'ee53d6b75b12aceed4',
width: '100%',
height: '100%',
noDocumentLink: true,
// onlyChainId: 1,
};
16 changes: 16 additions & 0 deletions packages/dodoex-api/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import * as types from './graphql';
const documents = {
'\n query FetchMiningList($where: Miningmining_list_filter) {\n mining_list(where: $where) {\n list {\n chainId\n type\n version\n address\n baseApy\n baseLpToken {\n decimals\n address: id\n symbol\n }\n baseToken {\n decimals\n address: id\n price\n symbol\n logoImg\n }\n endBlock\n miningContractAddress\n miningTotalDollar\n baseLpTokenMining\n quoteLpTokenMining\n quoteApy\n quoteLpToken {\n decimals\n address: id\n symbol\n }\n quoteToken {\n decimals\n address: id\n price\n symbol\n logoImg\n }\n rewardTokenInfos {\n apy\n decimals\n address: id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n rewardQuoteTokenInfos {\n apy\n decimals\n address: id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n startBlock\n title\n platform\n startTime\n endTime\n }\n totalCount\n chains\n }\n }\n ':
types.FetchMiningListDocument,
'\n query MiningList($where: Miningmining_list_filter) {\n mining_list(where: $where) {\n list {\n chainId\n type\n version\n address\n isGSP\n isNewERCMineV3\n baseApy\n baseLpToken {\n decimals\n id\n symbol\n }\n baseToken {\n decimals\n id\n price\n symbol\n logoImg\n }\n endBlock\n miningContractAddress\n miningTotalDollar\n baseLpTokenMining\n quoteLpTokenMining\n quoteApy\n quoteLpToken {\n decimals\n id\n symbol\n }\n quoteToken {\n decimals\n id\n price\n symbol\n logoImg\n }\n rewardTokenInfos {\n apy\n decimals\n id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n rewardQuoteTokenInfos {\n apy\n decimals\n id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n startBlock\n title\n platform\n blockNumber\n startTime\n endTime\n }\n totalCount\n chains\n }\n }\n ':
types.MiningListDocument,
'\n query MyCreatedMiningList($where: Miningmining_list_filter) {\n mining_list(where: $where) {\n list {\n chainId\n type\n version\n address\n isGSP\n isNewERCMineV3\n baseApy\n baseLpToken {\n decimals\n id\n symbol\n }\n baseToken {\n decimals\n id\n price\n symbol\n logoImg\n }\n endBlock\n miningContractAddress\n baseLpTokenMining\n quoteLpTokenMining\n quoteApy\n quoteLpToken {\n decimals\n id\n symbol\n }\n quoteToken {\n decimals\n id\n price\n symbol\n logoImg\n }\n rewardTokenInfos {\n apy\n decimals\n id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n rewardQuoteTokenInfos {\n apy\n decimals\n id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n startBlock\n title\n platform\n blockNumber\n participantsNum\n startTime\n endTime\n }\n totalCount\n chains\n }\n }\n ':
types.MyCreatedMiningListDocument,
'\n query FetchPoolList(\n $first: Int\n $where: Pair_filter\n $orderBy: Pair_orderBy\n ) {\n pairs(\n first: $first\n where: $where\n orderBy: $orderBy\n orderDirection: desc\n ) {\n id\n type\n creator\n owner\n lpFeeRate\n i\n k\n baseReserve\n quoteReserve\n lastTradePrice\n feeBase\n feeQuote\n baseToken {\n id\n symbol\n name\n decimals\n }\n quoteToken {\n id\n symbol\n name\n decimals\n }\n baseLpToken {\n id\n }\n quoteLpToken {\n id\n }\n }\n }\n ':
types.FetchPoolListDocument,
'\n query FetchLiquidityList($where: Liquiditylist_filter) {\n liquidity_list(where: $where) {\n currentPage\n pageSize\n totalCount\n lqList {\n id\n pair {\n id\n chainId\n type\n lpFeeRate\n creator\n baseLpToken {\n id\n }\n quoteLpToken {\n id\n }\n baseToken {\n id\n symbol\n name\n decimals\n logoImg\n }\n quoteToken {\n id\n symbol\n name\n decimals\n logoImg\n }\n tvl\n apy {\n miningBaseApy\n miningQuoteApy\n transactionBaseApy\n transactionQuoteApy\n }\n miningAddress\n }\n }\n }\n }\n ':
Expand Down Expand Up @@ -44,6 +48,18 @@ const documents = {
export function graphql(
source: '\n query FetchMiningList($where: Miningmining_list_filter) {\n mining_list(where: $where) {\n list {\n chainId\n type\n version\n address\n baseApy\n baseLpToken {\n decimals\n address: id\n symbol\n }\n baseToken {\n decimals\n address: id\n price\n symbol\n logoImg\n }\n endBlock\n miningContractAddress\n miningTotalDollar\n baseLpTokenMining\n quoteLpTokenMining\n quoteApy\n quoteLpToken {\n decimals\n address: id\n symbol\n }\n quoteToken {\n decimals\n address: id\n price\n symbol\n logoImg\n }\n rewardTokenInfos {\n apy\n decimals\n address: id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n rewardQuoteTokenInfos {\n apy\n decimals\n address: id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n startBlock\n title\n platform\n startTime\n endTime\n }\n totalCount\n chains\n }\n }\n ',
): typeof import('./graphql').FetchMiningListDocument;
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(
source: '\n query MiningList($where: Miningmining_list_filter) {\n mining_list(where: $where) {\n list {\n chainId\n type\n version\n address\n isGSP\n isNewERCMineV3\n baseApy\n baseLpToken {\n decimals\n id\n symbol\n }\n baseToken {\n decimals\n id\n price\n symbol\n logoImg\n }\n endBlock\n miningContractAddress\n miningTotalDollar\n baseLpTokenMining\n quoteLpTokenMining\n quoteApy\n quoteLpToken {\n decimals\n id\n symbol\n }\n quoteToken {\n decimals\n id\n price\n symbol\n logoImg\n }\n rewardTokenInfos {\n apy\n decimals\n id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n rewardQuoteTokenInfos {\n apy\n decimals\n id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n startBlock\n title\n platform\n blockNumber\n startTime\n endTime\n }\n totalCount\n chains\n }\n }\n ',
): typeof import('./graphql').MiningListDocument;
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(
source: '\n query MyCreatedMiningList($where: Miningmining_list_filter) {\n mining_list(where: $where) {\n list {\n chainId\n type\n version\n address\n isGSP\n isNewERCMineV3\n baseApy\n baseLpToken {\n decimals\n id\n symbol\n }\n baseToken {\n decimals\n id\n price\n symbol\n logoImg\n }\n endBlock\n miningContractAddress\n baseLpTokenMining\n quoteLpTokenMining\n quoteApy\n quoteLpToken {\n decimals\n id\n symbol\n }\n quoteToken {\n decimals\n id\n price\n symbol\n logoImg\n }\n rewardTokenInfos {\n apy\n decimals\n id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n rewardQuoteTokenInfos {\n apy\n decimals\n id\n price\n logoImg\n rewardNumIndex\n rewardPerBlock\n startBlock\n endBlock\n startTime\n endTime\n symbol\n }\n startBlock\n title\n platform\n blockNumber\n participantsNum\n startTime\n endTime\n }\n totalCount\n chains\n }\n }\n ',
): typeof import('./graphql').MyCreatedMiningListDocument;
/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
Expand Down
Loading

0 comments on commit 904be67

Please sign in to comment.