Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type updates #203

Merged
merged 4 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/sdk/src/models/market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Market {
/** Timestamp at which market should end */
public end: BigInt;

public mdm: MarketDisputeMechanism;
public disputeMechanism: MarketDisputeMechanism;
/** The description of the market. */
public description: string;
/** The market question. */
Expand Down Expand Up @@ -93,7 +93,7 @@ class Market {
status: this.status,
report: this.report,
resolvedOutcome: this.resolvedOutcome,
mdm: this.mdm,
disputeMechanism: this.disputeMechanism,
outcomeAssets: this.outcomeAssets,
end: this.end,
} = market);
Expand Down
10 changes: 10 additions & 0 deletions packages/sdk/src/types/guards.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AuthorisedDisputeMechanism, MarketDisputeMechanism } from ".";

export const isAuthorisedDisputeMechanism = (
marketDisputeMechanism: MarketDisputeMechanism
): marketDisputeMechanism is AuthorisedDisputeMechanism => {
return (
(marketDisputeMechanism as AuthorisedDisputeMechanism).authorized !==
undefined
);
};
16 changes: 12 additions & 4 deletions packages/sdk/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export type MarketResponse = {
status: string;
report: Report | null;
resolvedOutcome: OutcomeReport | null;
mdm: MarketDisputeMechanism;
disputeMechanism: MarketDisputeMechanism;
outcomeAssets: Asset[];
end: BigInt;
};
Expand Down Expand Up @@ -189,10 +189,16 @@ export type MarketTypeOf = { Categorical: number } | { Scalar: number[] };

export type ScoringRule = "CPMM" | "RikiddoSigmoidFeeMarketEma";

export type AuthorisedDisputeMechanism = { authorized: string };

export type CourtDisputeMechanism = { Court: null };

export type SimpleDisputeMechanism = { SimpleDisputes: null };

export type MarketDisputeMechanism =
| { Authorized: number }
| { Court: null }
| { SimpleDisputes: null };
| AuthorisedDisputeMechanism
| CourtDisputeMechanism
| SimpleDisputeMechanism;

export type MarketDispute = {
at: number;
Expand Down Expand Up @@ -314,3 +320,5 @@ export type ActiveAssetsResponse = {
qty: string;
price: number;
}[];

export * from "./guards";