Skip to content

Commit

Permalink
Type updates (#203)
Browse files Browse the repository at this point in the history
* Update dispute mechanism property to match runtime and correct authorised address type

* Break out mdm types for ease of use and add type guard

* add export from index file

* fix
  • Loading branch information
Robiquet committed Jul 25, 2022
1 parent 63185de commit 8488e9a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
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";

0 comments on commit 8488e9a

Please sign in to comment.