Skip to content

Commit

Permalink
Add findUserByAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
chiliec committed Mar 5, 2024
1 parent e311559 commit 453fd76
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/bot/features/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { logHandle } from "#root/bot/helpers/logging.js";
import { config } from "#root/config.js";
import { UserState, placeInLine } from "#root/bot/models/user.js";
import { getUserProfilePhoto } from "#root/bot/helpers/photo.js";
import { Address } from "ton-core";
import { Address } from "@ton/core";
import { voteScore } from "../helpers/votes.js";

const composer = new Composer<Context>();
Expand Down
2 changes: 1 addition & 1 deletion src/bot/features/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { logHandle } from "#root/bot/helpers/logging.js";
import { queueMenu } from "#root/bot/keyboards/queue-menu.js";
import { isAdmin } from "#root/bot/filters/is-admin.js";
import { config } from "#root/config.js";
import { Address, toNano } from "ton-core";
import { Address, toNano } from "@ton/core";
import { PhotoSize } from "@grammyjs/types";
import { changeImageData } from "../callback-data/image-selection.js";
import { SelectImageButton, photoKeyboard } from "../keyboards/photo.js";
Expand Down
4 changes: 2 additions & 2 deletions src/bot/helpers/ton.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-plusplus */
/* eslint-disable no-use-before-define */
/* eslint-disable no-await-in-loop */
import { KeyPair, mnemonicToPrivateKey } from "ton-crypto";
import { KeyPair, mnemonicToPrivateKey } from "@ton/crypto";
import {
Address,
beginCell,
Expand All @@ -10,7 +10,7 @@ import {
TonClient,
Transaction,
WalletContractV4,
} from "ton";
} from "@ton/ton";
import { config } from "#root/config";

export type OpenedWallet = {
Expand Down
2 changes: 1 addition & 1 deletion src/bot/models/nft-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
contractAddress,
StateInit,
SendMode,
} from "ton-core";
} from "@ton/core";
import {
encodeOffChainContent,
OpenedWallet,
Expand Down
2 changes: 1 addition & 1 deletion src/bot/models/nft-item.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address, beginCell, Cell, internal, SendMode } from "ton-core";
import { Address, beginCell, Cell, internal, SendMode } from "@ton/core";
import { OpenedWallet } from "#root/bot/helpers/ton.js";
import { config } from "#root/config";

Expand Down
15 changes: 14 additions & 1 deletion src/bot/models/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { getModelForClass, modelOptions, prop } from "@typegoose/typegoose";
import {
getModelForClass,
modelOptions,
prop,
DocumentType,
} from "@typegoose/typegoose";
import { TimeStamps } from "@typegoose/typegoose/lib/defaultClasses.js";
import { Address } from "@ton/core";

export enum UserState {
WaitNothing = "WaitNothing",
Expand Down Expand Up @@ -57,6 +63,13 @@ export function findOrCreateUser(id: number) {
);
}

export async function findUserByAddress(
address: Address,
): Promise<DocumentType<User> | null> {
const wallet = address.toString();
return UserModel.findOne({ wallet });
}

export function findQueue() {
return UserModel.find({ minted: false, state: UserState.Submited })
.sort({ votes: -1 })
Expand Down

0 comments on commit 453fd76

Please sign in to comment.