diff --git a/.env.example b/.env.example index a09841dcb..ef9c9122f 100644 --- a/.env.example +++ b/.env.example @@ -55,3 +55,7 @@ NEXT_PUBLIC_SANITY_VERSION="2022-03-07" # enable topics NEXT_PUBLIC_SHOW_TOPICS=true +# whitelisted creators of trusted markets +# note: should be addresses of official zeitgeist markets or trusted third party creators. +NEXT_PUBLIC_WHITELISTED_TRUSTED_CREATORS=["xxxxxx"] + diff --git a/components/assets/AssetActionButtons/AssetTradingButtons.tsx b/components/assets/AssetActionButtons/AssetTradingButtons.tsx index c95c742fc..1416a818b 100644 --- a/components/assets/AssetActionButtons/AssetTradingButtons.tsx +++ b/components/assets/AssetActionButtons/AssetTradingButtons.tsx @@ -52,7 +52,7 @@ const AssetTradingButtons = ({ {tradeItem && ( setIsOpen(false)}> - + {market?.scoringRule === ScoringRule.Lmsr ? ( setOpen(false)}> - + {market.marketType.scalar ? ( { )} setIsOpen(false)}> - +

Exit Court

diff --git a/components/court/CourtUnstakeButton.tsx b/components/court/CourtUnstakeButton.tsx index 6c3f2e60d..98564ce20 100644 --- a/components/court/CourtUnstakeButton.tsx +++ b/components/court/CourtUnstakeButton.tsx @@ -52,7 +52,7 @@ const CourtUnstakeButton = ({ className }: { className?: string }) => { Unstake setIsOpen(false)}> - +

Unstake

diff --git a/components/court/DelegateButton.tsx b/components/court/DelegateButton.tsx index fc053c499..3bacf58a8 100644 --- a/components/court/DelegateButton.tsx +++ b/components/court/DelegateButton.tsx @@ -103,7 +103,7 @@ const DelegateButton = ({ address }: { address: string }) => { Delegate setIsOpen(false)}> - +

Delegate to

diff --git a/components/court/JoinCourtAsJurorButton.tsx b/components/court/JoinCourtAsJurorButton.tsx index 0c3170549..e987303d9 100644 --- a/components/court/JoinCourtAsJurorButton.tsx +++ b/components/court/JoinCourtAsJurorButton.tsx @@ -127,7 +127,7 @@ const JoinCourtAsJurorButton = ({ className }: { className?: string }) => {
setIsOpen(false)}> - +

{connectedParticipant?.type === "Juror" ? "Set Personal Stake" diff --git a/components/court/ManageDelegationButton.tsx b/components/court/ManageDelegationButton.tsx index 06c38f5af..c9c817bea 100644 --- a/components/court/ManageDelegationButton.tsx +++ b/components/court/ManageDelegationButton.tsx @@ -43,7 +43,7 @@ const ManageDelegationButton = ({ className }: { className?: string }) => {

setIsOpen(false)}> - +

Delegate

diff --git a/components/create/editor/ResetButton.tsx b/components/create/editor/ResetButton.tsx index 25a445aa4..c2bfb7974 100644 --- a/components/create/editor/ResetButton.tsx +++ b/components/create/editor/ResetButton.tsx @@ -36,7 +36,7 @@ export const EditorResetButton = ({ editor }: EditorResetButtonProps) => { open={showResetConfirmation} onClose={() => setShowResetConfirmation(false)} > - +
Are you sure you want to clear the form?
diff --git a/components/liquidity/LiquidityModal.tsx b/components/liquidity/LiquidityModal.tsx index c16d943cc..1b0abf541 100644 --- a/components/liquidity/LiquidityModal.tsx +++ b/components/liquidity/LiquidityModal.tsx @@ -128,7 +128,7 @@ const LiquidityModal = ({ return ( - + diff --git a/components/liquidity/LiquidityModalAmm2.tsx b/components/liquidity/LiquidityModalAmm2.tsx index 310837bda..0f0be0939 100644 --- a/components/liquidity/LiquidityModalAmm2.tsx +++ b/components/liquidity/LiquidityModalAmm2.tsx @@ -40,7 +40,7 @@ const LiquidityModalAmm2 = ({ return ( - + diff --git a/components/markets/BuySellFullSetsButton.tsx b/components/markets/BuySellFullSetsButton.tsx index 8d1a8e039..8779d800c 100644 --- a/components/markets/BuySellFullSetsButton.tsx +++ b/components/markets/BuySellFullSetsButton.tsx @@ -32,7 +32,7 @@ const BuySellFullSetsButton = ({ setIsOpen(false)}> - + diff --git a/components/markets/MarketAddresses.tsx b/components/markets/MarketAddresses.tsx index f1420f2bf..e1d67955e 100644 --- a/components/markets/MarketAddresses.tsx +++ b/components/markets/MarketAddresses.tsx @@ -123,7 +123,7 @@ export const AddressDetails = ({ return ( <>
setInspected(true)} data-test="inspectButton" > diff --git a/components/markets/MarketHeader.tsx b/components/markets/MarketHeader.tsx index e1657060c..c193659ff 100644 --- a/components/markets/MarketHeader.tsx +++ b/components/markets/MarketHeader.tsx @@ -10,6 +10,7 @@ import { } from "@zeitgeistpm/sdk"; import CourtStageTimer from "components/court/CourtStageTimer"; import Avatar from "components/ui/Avatar"; +import InfoPopover from "components/ui/InfoPopover"; import Modal from "components/ui/Modal"; import Skeleton from "components/ui/Skeleton"; import Decimal from "decimal.js"; @@ -39,10 +40,19 @@ import dynamic from "next/dynamic"; import Image from "next/image"; import { FC, PropsWithChildren, useState } from "react"; import { X } from "react-feather"; +import { HiOutlineShieldCheck } from "react-icons/hi"; +import { MdModeEdit, MdOutlineHistory } from "react-icons/md"; import { AddressDetails } from "./MarketAddresses"; import { MarketTimer, MarketTimerSkeleton } from "./MarketTimer"; import { MarketPromotionCallout } from "./PromotionCallout"; +export const QuillViewer = dynamic( + () => import("../../components/ui/QuillViewer"), + { + ssr: false, + }, +); + const MarketFavoriteToggle = dynamic(() => import("./MarketFavoriteToggle"), { ssr: false, }); @@ -99,55 +109,56 @@ const MarketOutcome: FC< }> > = ({ status, outcome, by, setShowMarketHistory, marketHistory }) => { return ( -
-
- {status === "Reported" && ( -
- {status} Outcome - {outcome ? ( - {outcome} - ) : status === "Reported" ? ( - - ) : ( - "" - )} -
- )} +
+ {status === "Resolved" && ( +
+ Outcome:{" "} + {outcome} +
+ )} - {status === "Disputed" && ( -
- {status} Outcome -
- )} + {status === "Reported" && ( +
+ {status} Outcome + {outcome ? ( + {outcome} + ) : status === "Reported" ? ( + + ) : ( + "" + )} +
+ )} - {status !== "Resolved" && by && ( -
- by: -
- -
+ {status === "Disputed" && ( +
+ {status} Outcome +
+ )} + + {status !== "Resolved" && by && ( +
+ By: +
+
+
+ )} + +
+ {marketHistory ? ( + + ) : ( + )}
- - {marketHistory ? ( - - ) : ( - - )}
); }; @@ -523,6 +534,87 @@ const MarketHeader: FC<{
+ {!market.disputeMechanism && ( +
+ + +
+ } + > +
+
+ This market has no dispute mechanism and will be resolved + automatically when reported. +
+
+
+ +
+
+ +
+
+
+ +
+
+ Trusted Market +
+
+
+ )} + + {market.hasEdits && ( +
+ + +
+ } + > +
+

Market edits

+

+ This market has been edited in the zeitgeist cms. The + following is the immutable original metadata that was set when + the market was created. +

+ + {market.originalMetadata?.question && ( +
+ +
{market.originalMetadata.question}
+
+ )} + + {market.originalMetadata?.description && ( +
+ +
+ +
+
+ )} +
+ +
+
+ Has been edited. +
+
+
+ )}
diff --git a/components/portfolio/DepositButton.tsx b/components/portfolio/DepositButton.tsx index e3b8971ee..a6c97a786 100644 --- a/components/portfolio/DepositButton.tsx +++ b/components/portfolio/DepositButton.tsx @@ -164,7 +164,7 @@ const DepositModal = ({ }; return ( - +

Deposit

diff --git a/components/portfolio/TransferButton.tsx b/components/portfolio/TransferButton.tsx index 78a792a14..e7b33fe2f 100644 --- a/components/portfolio/TransferButton.tsx +++ b/components/portfolio/TransferButton.tsx @@ -203,7 +203,7 @@ const TransferModal = ({ }; return ( - +

On-Chain Transfers

diff --git a/components/portfolio/WithdrawButton.tsx b/components/portfolio/WithdrawButton.tsx index 415b0a196..76605db9e 100644 --- a/components/portfolio/WithdrawButton.tsx +++ b/components/portfolio/WithdrawButton.tsx @@ -210,7 +210,7 @@ const WithdrawModal = ({ }; return ( - +

Withdraw

diff --git a/components/settings/SettingsModal.tsx b/components/settings/SettingsModal.tsx index c75746dab..ce2f9290f 100644 --- a/components/settings/SettingsModal.tsx +++ b/components/settings/SettingsModal.tsx @@ -28,7 +28,7 @@ const SettingsModal: React.FC = ({ open, onClose }) => { return ( - +

Settings

setTabSelection(index)} diff --git a/components/ui/InfoPopover.tsx b/components/ui/InfoPopover.tsx index eaa7635f4..3537bf901 100644 --- a/components/ui/InfoPopover.tsx +++ b/components/ui/InfoPopover.tsx @@ -86,7 +86,7 @@ export const InfoPopover: React.FC = ({ leaveTo="opacity-0 scale-1" >
{children} @@ -100,7 +100,7 @@ export const InfoPopover: React.FC = ({ setIsOpen(false)}> setIsOpen(false)} - className={`w-full max-w-[462px] cursor-pointer rounded-[10px] bg-tooltip-bg p-6 ${className} text-base font-light`} + className={`w-full max-w-[564px] cursor-pointer rounded-[10px] bg-tooltip-bg p-6 ${className} text-base font-light`} > {title}
{children}
diff --git a/lib/gql/markets.ts b/lib/gql/markets.ts index 28f57ced0..73af812ce 100644 --- a/lib/gql/markets.ts +++ b/lib/gql/markets.ts @@ -83,7 +83,7 @@ const marketQuery = gql` } `; -export interface MarketPageIndexedData { +export type MarketPageIndexedData = { marketId: number; slug: string; question: string; @@ -125,7 +125,19 @@ export interface MarketPageIndexedData { baseAsset: string; disputeMechanism: "SimpleDisputes" | "Authorized" | "Court"; img?: string; -} +} & (WithCmsEdits | NoCmsEdits); + +export type WithCmsEdits = { + hasEdits?: true; + originalMetadata: { + question?: string; + description?: string; + }; +}; + +export type NoCmsEdits = { + hasEdits?: false; +}; export const getRecentMarketIds = async ( client: GraphQLClient, diff --git a/lib/hooks/queries/court/useMarketCaseId.ts b/lib/hooks/queries/court/useMarketCaseId.ts index b6333df80..84b37cb41 100644 --- a/lib/hooks/queries/court/useMarketCaseId.ts +++ b/lib/hooks/queries/court/useMarketCaseId.ts @@ -11,10 +11,9 @@ export const useMarketCaseId = (marketId?: number) => { const query = useQuery( [id, marketCaseIdRootKey, marketId], async () => { - if (!enabled) return; + if (!enabled) return null; const res = await sdk.api.query.court.marketIdToCourtId(marketId); - - return res.unwrapOr(null)?.toNumber(); + return res.unwrapOr(null)?.toNumber() ?? null; }, { enabled: enabled, diff --git a/lib/hooks/queries/useInfiniteMarkets.ts b/lib/hooks/queries/useInfiniteMarkets.ts index 7532609c8..858489e88 100644 --- a/lib/hooks/queries/useInfiniteMarkets.ts +++ b/lib/hooks/queries/useInfiniteMarkets.ts @@ -13,13 +13,14 @@ import { } from "lib/types/market-filter"; import { MarketOutcomes } from "lib/types/markets"; import { useSdkv2 } from "../useSdkv2"; - import { FullMarketFragment } from "@zeitgeistpm/indexer"; import { CmsMarketMetadata } from "lib/cms/markets"; import { marketCmsDatakeyForMarket } from "./cms/useMarketCmsMetadata"; import { marketMetaFilter } from "./constants"; import { marketsRootQuery } from "./useMarket"; +import { tryCatch } from "@zeitgeistpm/utility/dist/either"; + export const rootKey = "markets-filtered"; const orderByMap = { @@ -39,6 +40,10 @@ export type QueryMarketData = Market & { prediction: { name: string; price: number }; }; +const WHITELISTED_TRUSTED_CREATORS: string[] = tryCatch(() => + JSON.parse(process.env.NEXT_PUBLIC_WHITELISTED_TRUSTED_CREATORS as string), +).unwrapOr([]); + export const useInfiniteMarkets = ( orderBy: MarketsOrderBy, withLiquidityOnly = false, @@ -77,6 +82,14 @@ export const useInfiniteMarkets = ( tags_containsAny: tags?.length === 0 ? undefined : tags, baseAsset_in: currencies?.length !== 0 ? currencies : undefined, }, + { + disputeMechanism_isNull: false, + OR: [ + { + creator_in: WHITELISTED_TRUSTED_CREATORS, + }, + ], + }, { OR: [ { diff --git a/package.json b/package.json index dc6331319..25ec51164 100644 --- a/package.json +++ b/package.json @@ -41,11 +41,11 @@ "@web3auth/modal": "^7.0.4", "@yornaath/batshit": "^0.8.0", "@yornaath/batshit-devtools-react": "^0.5.4", - "@zeitgeistpm/augment-api": "3.1.0", + "@zeitgeistpm/augment-api": "3.1.3", "@zeitgeistpm/avatara-nft-sdk": "^1.3.1", "@zeitgeistpm/avatara-react": "^1.3.2", "@zeitgeistpm/avatara-util": "^1.2.0", - "@zeitgeistpm/sdk": "3.1.0", + "@zeitgeistpm/sdk": "3.1.3", "@zeitgeistpm/utility": "3.1.0", "axios": "^0.21.4", "boring-avatars": "^1.6.1", diff --git a/pages/markets/[marketid].tsx b/pages/markets/[marketid].tsx index 55410a482..23a8189af 100644 --- a/pages/markets/[marketid].tsx +++ b/pages/markets/[marketid].tsx @@ -43,6 +43,7 @@ import { PromotedMarket } from "lib/cms/get-promoted-markets"; import { ZTG, environment, graphQlEndpoint } from "lib/constants"; import { MarketPageIndexedData, + WithCmsEdits, getMarket, getRecentMarketIds, } from "lib/gql/markets"; @@ -136,9 +137,28 @@ export async function getStaticProps({ params }) { const { timestamp } = await getResolutionTimestamp(client, market.marketId); resolutionTimestamp = timestamp ?? undefined; - if (cmsMetadata?.imageUrl) market.img = cmsMetadata?.imageUrl; - if (cmsMetadata?.question) market.question = cmsMetadata?.question; - if (cmsMetadata?.description) market.description = cmsMetadata?.description; + if (cmsMetadata?.question || cmsMetadata?.description) { + market.hasEdits = true; + (market as MarketPageIndexedData & WithCmsEdits).originalMetadata = {}; + } + + if (cmsMetadata?.imageUrl) { + market.img = cmsMetadata?.imageUrl; + } + + if (cmsMetadata?.question) { + ( + market as MarketPageIndexedData & WithCmsEdits + ).originalMetadata.question = market.question; + market.question = cmsMetadata?.question; + } + + if (cmsMetadata?.description) { + ( + market as MarketPageIndexedData & WithCmsEdits + ).originalMetadata.description = market.description as string; + market.description = cmsMetadata?.description; + } } return { diff --git a/yarn.lock b/yarn.lock index 4e95a7528..032699a11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4175,14 +4175,14 @@ __metadata: languageName: node linkType: hard -"@zeitgeistpm/augment-api@npm:3.1.0, @zeitgeistpm/augment-api@npm:^3.1.0": - version: 3.1.0 - resolution: "@zeitgeistpm/augment-api@npm:3.1.0" +"@zeitgeistpm/augment-api@npm:3.1.3, @zeitgeistpm/augment-api@npm:^3.1.2, @zeitgeistpm/augment-api@npm:^3.1.3": + version: 3.1.3 + resolution: "@zeitgeistpm/augment-api@npm:3.1.3" peerDependencies: "@polkadot/api-base": "*" "@polkadot/rpc-core": "*" "@polkadot/types": "*" - checksum: 40a3bbe7b49d8bb3761cf447eee3d970dd8f9cef841ea06a81b35c1870e5ad0c690fca723fd7ef44a0083dd1fe7cce9f3f035e3d9aa3cd45c7296ae1b936ea9b + checksum: 57ac62bfe6e3a76c9ec0a3c50e58fb8753f89814785632aa9f8f0d106aa8fd54ccb1f32cf6600d046ae9527e26d403ed94091cef770af8cca308879a442f7450 languageName: node linkType: hard @@ -4252,40 +4252,40 @@ __metadata: languageName: node linkType: hard -"@zeitgeistpm/indexer@npm:^4.1.0": - version: 4.1.0 - resolution: "@zeitgeistpm/indexer@npm:4.1.0" +"@zeitgeistpm/indexer@npm:^4.1.2": + version: 4.1.2 + resolution: "@zeitgeistpm/indexer@npm:4.1.2" dependencies: graphql: ^16.6.0 graphql-request: ^5.0.0 graphql-tag: ^2.12.6 - checksum: 1f1a19fe293f40b0f1e608fe0f3d4e61cf264564e8566605964b5f22b02961bcc881b96cc9989ca43e02ff4dd8fe1dc9ac0bc188f161e23dc635cd9b8e5f545b + checksum: 834b8211cc97e28ea6004751eca2ed0a1d4368c60bd14f119e7fd7e78fd5cda9fbf22f4239811fa6c05a7f218c0baa6f5c0ddb074f4d8e689c0e1f63acf2d0da languageName: node linkType: hard -"@zeitgeistpm/rpc@npm:^3.1.0": - version: 3.1.0 - resolution: "@zeitgeistpm/rpc@npm:3.1.0" +"@zeitgeistpm/rpc@npm:^3.1.1": + version: 3.1.2 + resolution: "@zeitgeistpm/rpc@npm:3.1.2" dependencies: - "@zeitgeistpm/augment-api": ^3.1.0 - "@zeitgeistpm/utility": ^3.1.0 + "@zeitgeistpm/augment-api": ^3.1.3 + "@zeitgeistpm/utility": ^3.1.1 peerDependencies: "@polkadot/api": "*" "@polkadot/keyring": "*" "@polkadot/types": "*" - checksum: e04907aeddc22c8b3253dfc5771da47e2569cf54350e2278e41d6d2c3b43f4317153aedea7e93990f3f4ea5f135f9b0239364d31f5ddb456cdedf4208159ba01 + checksum: 075ad196db4e033085e93566a0c99b6b08cf3dcba7dd7d73b518e22962e240def2dcb94784e8e97530772d31340df9b0acdf68d5e4d7105c89397860675eb383 languageName: node linkType: hard -"@zeitgeistpm/sdk@npm:3.1.0": - version: 3.1.0 - resolution: "@zeitgeistpm/sdk@npm:3.1.0" +"@zeitgeistpm/sdk@npm:3.1.3": + version: 3.1.3 + resolution: "@zeitgeistpm/sdk@npm:3.1.3" dependencies: - "@zeitgeistpm/augment-api": ^3.1.0 - "@zeitgeistpm/indexer": ^4.1.0 - "@zeitgeistpm/rpc": ^3.1.0 - "@zeitgeistpm/utility": ^3.1.0 - "@zeitgeistpm/web3.storage": ^3.1.0 + "@zeitgeistpm/augment-api": ^3.1.2 + "@zeitgeistpm/indexer": ^4.1.2 + "@zeitgeistpm/rpc": ^3.1.1 + "@zeitgeistpm/utility": ^3.1.1 + "@zeitgeistpm/web3.storage": ^3.1.1 cids: ^1.1.9 decimal.js: ^10.4.3 human-object-diff: ^3.0.0 @@ -4299,7 +4299,7 @@ __metadata: "@polkadot/api": "*" "@polkadot/types": "*" "@polkadot/util": "*" - checksum: 896f4594f0d5536a113a8ecb659a7e7a1b0bea8f913f5c4c5b97eee2436109a556e07afab2be86f4df399d4de1b52fa0cbc4fe6e8b8b48d079fcaef589940e4f + checksum: 976d6b9bebfb6abe5fccee65fc13a6c35806509c23e9cfb26b11bbc949c168c7871235dea6ffbf271cf5534faea80d7fbe267668a2f14b5481dd31c08e914627 languageName: node linkType: hard @@ -4357,11 +4357,11 @@ __metadata: "@web3auth/modal": ^7.0.4 "@yornaath/batshit": ^0.8.0 "@yornaath/batshit-devtools-react": ^0.5.4 - "@zeitgeistpm/augment-api": 3.1.0 + "@zeitgeistpm/augment-api": 3.1.3 "@zeitgeistpm/avatara-nft-sdk": ^1.3.1 "@zeitgeistpm/avatara-react": ^1.3.2 "@zeitgeistpm/avatara-util": ^1.2.0 - "@zeitgeistpm/sdk": 3.1.0 + "@zeitgeistpm/sdk": 3.1.3 "@zeitgeistpm/utility": 3.1.0 autoprefixer: 10.2.5 axios: ^0.21.4 @@ -4433,7 +4433,7 @@ __metadata: languageName: unknown linkType: soft -"@zeitgeistpm/utility@npm:3.1.0, @zeitgeistpm/utility@npm:^3.1.0": +"@zeitgeistpm/utility@npm:3.1.0": version: 3.1.0 resolution: "@zeitgeistpm/utility@npm:3.1.0" dependencies: @@ -4449,11 +4449,27 @@ __metadata: languageName: node linkType: hard -"@zeitgeistpm/web3.storage@npm:^3.1.0": - version: 3.1.0 - resolution: "@zeitgeistpm/web3.storage@npm:3.1.0" +"@zeitgeistpm/utility@npm:^3.1.1": + version: 3.1.1 + resolution: "@zeitgeistpm/utility@npm:3.1.1" + dependencies: + decimal.js: ^10.4.3 + lodash.omit: ^4.5.0 + ms: ^2.1.3 + rxjs: ^7.2.0 + peerDependencies: + "@polkadot/api": "*" + "@polkadot/types": "*" + "@polkadot/util": "*" + checksum: 58e63a79fa9950c2fb5a8b4ece60788404d9788c8ca70e7915cf6fdfa9fb272a92e896b22ea5e3be132b978d4107607131ec12cfccca55a1553e02880136d714 + languageName: node + linkType: hard + +"@zeitgeistpm/web3.storage@npm:^3.1.1": + version: 3.1.1 + resolution: "@zeitgeistpm/web3.storage@npm:3.1.1" dependencies: - "@zeitgeistpm/utility": ^3.1.0 + "@zeitgeistpm/utility": ^3.1.1 cids: ^1.1.9 ipfs-http-client: ^60.0.0 ipfs-only-hash: ^4.0.0 @@ -4462,7 +4478,7 @@ __metadata: up: ^1.0.2 peerDependencies: "@polkadot/util": "*" - checksum: ac408edb67cca9297c84f1aa461463d9c6b1cdd8e97149fdb45e8291e9e15a2690250e5692be3c4a64a48714acc4a5c9bcf3427f75b70887c2a35bb543c6d6f3 + checksum: b6125da994ada80b2bea656bd4670d5f58a4d945b12fedee2a604d02207a046b3343da841a29e923f503c452ff642b7e680414ac3b8f60e6611319e59d8f6e59 languageName: node linkType: hard