feat: scaffold frontend pnpm monorepo with apps (admin, web) and shared packages (types, api-client, ui)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "@wtfx/api-client",
|
||||
"version": "1.0.0",
|
||||
"main": "./src/index.ts",
|
||||
"dependencies": {
|
||||
"@wtfx/types": "workspace:*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Market, Order, Position, GovernanceConfig } from '@wtfx/types';
|
||||
|
||||
export class WtfxApiClient {
|
||||
private baseUrl: string;
|
||||
|
||||
constructor(baseUrl: string) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
async getMarkets(): Promise<Market[]> {
|
||||
const res = await fetch(`${this.baseUrl}/api/v1/markets`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async getMarket(marketAddress: string): Promise<Market> {
|
||||
const res = await fetch(`${this.baseUrl}/api/v1/markets/${marketAddress}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async getPositions(userAddress: string): Promise<Position[]> {
|
||||
const res = await fetch(`${this.baseUrl}/api/v1/positions?user=${userAddress}`);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
async getGovernanceConfig(): Promise<GovernanceConfig> {
|
||||
const res = await fetch(`${this.baseUrl}/api/v1/governance`);
|
||||
return res.json();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "@wtfx/types",
|
||||
"version": "1.0.0",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
export interface Market {
|
||||
questionId: string;
|
||||
marketAddress: string;
|
||||
title: string;
|
||||
imageUri?: string;
|
||||
outcomeNames: string[];
|
||||
status: 'Trading' | 'Graduated' | 'Finalised' | 'Refunded';
|
||||
tierId: number;
|
||||
totalMarketCap: string;
|
||||
timestampEnd: number;
|
||||
}
|
||||
|
||||
export interface Order {
|
||||
id: string;
|
||||
marketAddress: string;
|
||||
outcomeIndex: number;
|
||||
side: 'BUY' | 'SELL';
|
||||
amount: string;
|
||||
price: string;
|
||||
status: 'OPEN' | 'FILLED' | 'CANCELLED';
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
marketAddress: string;
|
||||
tokenId: string;
|
||||
outcomeName: string;
|
||||
shares: string;
|
||||
avgCost: string;
|
||||
}
|
||||
|
||||
export interface GovernanceConfig {
|
||||
creatorShare: string;
|
||||
centralWallet: string;
|
||||
defaultFeeRate: string;
|
||||
disputeWindow: number;
|
||||
tiers: Record<number, {
|
||||
thresholdMcap: string;
|
||||
thresholdMaxSupply: string;
|
||||
disputeWindow: number;
|
||||
}>;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "@wtfx/ui",
|
||||
"version": "1.0.0",
|
||||
"main": "./src/index.ts"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export const UI_VERSION = "1.0.0";
|
||||
Reference in New Issue
Block a user