forked from lnp2pBot/bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
405 additions
and
291 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,85 @@ | ||
import mongoose, { Document, Schema, Types } from 'mongoose'; | ||
|
||
const arrayLimits = (val: any[]): boolean => { | ||
return val.length > 0 && val.length <= 2; | ||
}; | ||
|
||
const currencyLimits = (val: string): boolean => { | ||
return val.length > 0 && val.length < 10; | ||
}; | ||
|
||
|
||
export interface OrderChannel extends Document { | ||
name: string; | ||
type: string; | ||
} | ||
|
||
const OrderChannelSchema = new Schema<OrderChannel>({ | ||
name: { type: String, required: true, trim: true }, | ||
type: { | ||
type: String, | ||
enum: ['buy', 'sell', 'mixed'], | ||
}, | ||
}); | ||
|
||
export interface usernameId extends Document { | ||
id: string; | ||
username: string; | ||
} | ||
|
||
const usernameIdSchema = new Schema<usernameId>({ | ||
id: { type: String, required: true }, | ||
username: { type: String, required: true, trim: true }, | ||
}); | ||
|
||
export interface Community extends Document { | ||
name: string; | ||
creator_id: string; | ||
group: string; | ||
order_channels: Types.DocumentArray<OrderChannel>; | ||
fee: number; | ||
earnings: number; | ||
orders_to_redeem: number; | ||
dispute_channel: string; | ||
solvers: Types.DocumentArray<usernameId>; | ||
banned_users: Types.DocumentArray<usernameId>; | ||
public: boolean; | ||
currencies: Array<string>; | ||
created_at: Date; | ||
nostr_public_key: string; | ||
} | ||
|
||
const CommunitySchema = new Schema<Community>({ | ||
name: { | ||
type: String, | ||
unique: true, | ||
maxlength: 30, | ||
trim: true, | ||
required: true, | ||
}, | ||
creator_id: { type: String }, | ||
group: { type: String, trim: true }, // group Id or public name | ||
order_channels: { | ||
// array of Id or public name of channels | ||
type: [OrderChannelSchema], | ||
validate: [arrayLimits, '{PATH} is not within limits'], | ||
}, | ||
fee: { type: Number, min: 0, max: 100, default: 0 }, | ||
earnings: { type: Number, default: 0 }, // Sats amount to be paid to the community | ||
orders_to_redeem: { type: Number, default: 0 }, // Number of orders calculated to be redeemed | ||
dispute_channel: { type: String }, // Id or public name, channel to send new disputes | ||
solvers: [usernameIdSchema], // users that are dispute solvers | ||
banned_users: [usernameIdSchema], // users that are banned from the community | ||
public: { type: Boolean, default: true }, | ||
currencies: { | ||
type: [String], | ||
required: true, | ||
trim: true, | ||
validate: [currencyLimits, '{PATH} is not within limits'], | ||
}, | ||
created_at: { type: Date, default: Date.now }, | ||
nostr_public_key: { type: String }, | ||
}); | ||
|
||
|
||
module.exports = mongoose.model<Community>('Community', CommunitySchema); |
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
import mongoose, { Document, Schema } from 'mongoose'; | ||
|
||
export interface IConfig extends Document { | ||
maintenance: boolean; | ||
node_status: string; | ||
node_uri: string; | ||
} | ||
|
||
|
||
const configSchema = new Schema<IConfig>({ | ||
maintenance: { type: Boolean, default: false }, | ||
node_status: { type: String, default: 'down' }, | ||
node_uri: { type: String }, | ||
}); | ||
|
||
|
||
module.exports = mongoose.model<IConfig>('Config', configSchema); |
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 was deleted.
Oops, something went wrong.
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,43 @@ | ||
import mongoose, { Document, Schema } from 'mongoose'; | ||
|
||
export interface IPendingPayment extends Document { | ||
description: string; | ||
amount: number; | ||
attempts: number; | ||
paid: boolean; | ||
is_invoice_expired: boolean; | ||
payment_request: string; | ||
hash: string; | ||
created_at: Date; | ||
paid_at: Date; | ||
user_id: string; | ||
order_id: string; | ||
community_id: string; | ||
} | ||
|
||
|
||
const PendingPaymentSchema = new Schema<IPendingPayment>({ | ||
description: { type: String }, | ||
amount: { | ||
// amount in satoshis | ||
type: Number, | ||
min: [1, 'Minimum amount is 1 sat'], | ||
validate: { | ||
validator: Number.isInteger, | ||
message: '{VALUE} is not an integer value', | ||
}, | ||
}, | ||
attempts: { type: Number, min: 0, default: 0 }, | ||
paid: { type: Boolean, default: false }, | ||
is_invoice_expired: { type: Boolean, default: false }, | ||
payment_request: { type: String }, | ||
hash: { type: String }, | ||
created_at: { type: Date, default: Date.now }, | ||
paid_at: { type: Date }, | ||
user_id: { type: String }, | ||
order_id: { type: String }, | ||
community_id: { type: String }, | ||
}); | ||
|
||
|
||
module.exports = mongoose.model<IPendingPayment>('PendingPayment', PendingPaymentSchema); |
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 interface Fiat { | ||
symbol: string; | ||
name: string; | ||
symbol_native: string; | ||
decimal_digits: number; | ||
rounding: number; | ||
code: string; | ||
emoji: string; | ||
name_plural: string; | ||
price?: boolean; | ||
locale?: string; | ||
} |