-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add some types for clients (admin, disputes, messages, orders)
- Loading branch information
1 parent
1caec57
commit 6df544c
Showing
9 changed files
with
140 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,3 @@ export function wait(timeout?: number) { | |
} | ||
|
||
export const dirname = __dirname | ||
|
||
export * from '@/util' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { Dispute } from '../core' | ||
|
||
export interface AdminFunctions { | ||
admcancel: (orderId: string) => Promise<void> | ||
admsettle: (orderId: string) => Promise<void> | ||
admlistdisputes: () => Promise<Dispute[]> | ||
admaddsolver: (pubkey: string) => Promise<void> | ||
admtakedispute: (disputeId: string) => Promise<void> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface DisputeFunctions { | ||
dispute: (orderId: string) => Promise<void> | ||
rate: (orderId: string, rating: number) => Promise<void> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface ClientConfig { | ||
mostroPubKey: string | ||
relays: string[] | ||
privateKey?: string | ||
debug?: boolean | ||
} | ||
|
||
export * from './admin' | ||
export * from './disputes' | ||
export * from './messages' | ||
export * from './orders' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { MessageKind } from '../core/message' | ||
|
||
export interface MessageFunctions { | ||
getdm: (pubkey: string) => Promise<MessageKind[]> | ||
fiatsent: (orderId: string) => Promise<void> | ||
addinvoice: (orderId: string, invoice: string) => Promise<void> | ||
release: (orderId: string) => Promise<void> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { Order } from '../core' | ||
|
||
export interface OrderFunctions { | ||
listorders: () => Promise<Order[]> | ||
neworder: (order: Partial<Order>) => Promise<Order> | ||
takesell: (orderId: string, amount?: number) => Promise<Order> | ||
takebuy: (orderId: string, amount?: number) => Promise<Order> | ||
cancel: (orderId: string) => Promise<void> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,61 @@ | ||
// src/types/core/order.ts | ||
export enum OrderType { | ||
BUY = 'buy', | ||
SELL = 'sell', | ||
} | ||
|
||
export enum OrderStatus { | ||
PENDING = 'pending', | ||
ACTIVE = 'active', | ||
CANCELED = 'canceled', | ||
WAITING_PAYMENT = 'waiting-payment', | ||
WAITING_BUYER_INVOICE = 'waiting-buyer-invoice', | ||
FIAT_SENT = 'fiat-sent', | ||
SUCCESS = 'success', | ||
CANCELED_BY_ADMIN = 'canceled-by-admin', | ||
SETTLED_BY_ADMIN = 'settled-by-admin', | ||
COMPLETED_BY_ADMIN = 'completed-by-admin', | ||
DISPUTE = 'dispute', | ||
EXPIRED = 'expired', | ||
FIAT_SENT = 'fiat-sent', | ||
SETTLED_HOLD_INVOICE = 'settled-hold-invoice', | ||
PENDING = 'pending', | ||
SUCCESS = 'success', | ||
WAITING_BUYER_INVOICE = 'waiting-buyer-invoice', | ||
WAITING_PAYMENT = 'waiting-payment', | ||
COOPERATIVELY_CANCELED = 'cooperatively-canceled', | ||
} | ||
|
||
export interface Order { | ||
id: string | ||
kind: OrderType | ||
status: OrderStatus | ||
event_id: string | ||
hash: string | null | ||
preimage: string | null | ||
creator_pubkey: string | ||
cancel_initiator_pubkey: string | null | ||
buyer_pubkey: string | null | ||
seller_pubkey: string | null | ||
price_from_api: boolean | ||
premium: number | ||
payment_method: string | ||
amount: number | ||
fiat_code: string | ||
min_amount: number | null | ||
max_amount: number | null | ||
buyer_dispute: boolean | ||
seller_dispute: boolean | ||
buyer_cooperativecancel: boolean | ||
seller_cooperativecancel: boolean | ||
fee: number | ||
routing_fee: number | ||
fiat_code: string | ||
fiat_amount: number | ||
payment_method: string | ||
premium: number | ||
buyer_invoice: string | null | ||
range_parent_id: string | null | ||
invoice_held_at: number | ||
taken_at: number | ||
created_at: number | ||
buyer_pubkey?: string | ||
seller_pubkey?: string | ||
buyer_invoice?: string | ||
master_seller_pubkey?: string | ||
buyer_sent_rate: boolean | ||
seller_sent_rate: boolean | ||
failed_payment: boolean | ||
payment_attempts: number | ||
expires_at: number | ||
master_buyer_pubkey?: string | ||
expires_at?: number | ||
master_seller_pubkey?: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export * from './client' | ||
export * from './core' | ||
|
||
export const NOSTR_CONSTANTS = { | ||
REPLACEABLE_EVENT_KIND: 38383, | ||
PROTOCOL_VERSION: 1, | ||
TIMEOUTS: { | ||
ORDER_EXPIRATION: 23 * 60 * 60, | ||
INVOICE_SUBMISSION: 15 * 60, | ||
HOLD_INVOICE_EXPIRATION: 24 * 60 * 60, | ||
}, | ||
} as const |