Skip to content

Commit

Permalink
Change collection address to owner address
Browse files Browse the repository at this point in the history
  • Loading branch information
chiliec committed Mar 6, 2024
1 parent ac5babe commit 0204713
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ BOT_SERVER_HOST=localhost
BOT_SERVER_PORT=3000
BOT_ADMINS=[1]
COLLECTION_ADDRESS=EQ...
COLLECTION_OWNER=EQ...
MNEMONICS=word1 word2 word3 ...
PINATA_API_KEY=
PINATA_API_SECRET=
MNEMONICS=word1 word2 word3 ...
TONCENTER_API_KEY=
TESTNET=true
STABILITY_API_KEY=
2 changes: 1 addition & 1 deletion locales/en.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ submitted = You have already submitted a request.
bet = Your bet {$ton} TON has been accepted.
speedup = You are currently in line number {$place}. To move up the queue, you could:
— Donate any amount of Toncoin from your wallet to the collection address <code>{$collectionAddress}</code>
— Donate any amount of Toncoin from your wallet to the address <code>{$collectionOwner}</code>
— Invite friends to vote for you using link <code>{$inviteLink}</code>
— Roll the dice by using the command /dice every hour
Expand Down
4 changes: 2 additions & 2 deletions src/bot/features/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ feature.on("message:text", logHandle("message-handler")).filter(
ctx.t("speedup", {
place,
inviteLink: `https://t.me/${ctx.me.username}?start=${ctx.chat.id}`,
collectionAddress: config.COLLECTION_ADDRESS,
collectionOwner: config.COLLECTION_OWNER,
}),
);
} catch (error) {
Expand Down Expand Up @@ -83,7 +83,7 @@ feature.command("mint", logHandle("command-mint"), async (ctx) => {
ctx.t("speedup", {
place,
inviteLink: `https://t.me/${ctx.me.username}?start=${ctx.chat.id}`,
collectionAddress: config.COLLECTION_ADDRESS,
collectionOwner: config.COLLECTION_OWNER,
}),
);
break;
Expand Down
7 changes: 5 additions & 2 deletions src/bot/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ export async function placeInLine(votes: number): Promise<number> {
const count = await UserModel.countDocuments({
minted: false,
state: UserState.Submited,
votes: { $gt: votes },
votes: { $gte: votes },
});
return count + 1;
if (count === 0) {
return 1;
}
return count;
}
18 changes: 9 additions & 9 deletions src/bot/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Subscription {
offsetTransactionHash,
);
} catch (error) {
logger.error(error);
logger.error(`Trxs error: ${(error as Error).message}`);
return [];
}
}
Expand All @@ -58,12 +58,12 @@ export class Subscription {
trxModel.hash = hash;
await trxModel.save();

const ton = fromNano(value);
const user = await findUserByAddress(source);
if (user) {
// amount in nano-Toncoins (1 Toncoin = 1e9 nano-Toncoins)
const ton = fromNano(value);
const points = Math.round(Number(ton) * 100_000);
logger.info(`${ton} => ${points}`);
logger.debug(`${ton} => ${points}`);
user.votes += points;
await user.save();

Expand All @@ -78,11 +78,11 @@ export class Subscription {
i18n.t(user.language, "speedup", {
place,
inviteLink: `https://t.me/${this.bot.botInfo.username}?start=${user.id}`,
collectionAddress: config.COLLECTION_ADDRESS,
collectionOwner: config.COLLECTION_OWNER,
}),
);
} else {
logger.error(`USER WITH ADDRESS ${source} NOT FOUND`);
logger.error(`USER NOT FOUND FOR: ${ton} TON from ${source} `);
}
}
}
Expand All @@ -96,10 +96,10 @@ export class Subscription {

try {
const latestTx = await getLastestTransaction();
logger.info(`Latest tx: ${latestTx?.lt}:${latestTx?.hash}`);
const address = Address.parse(config.COLLECTION_ADDRESS);
logger.debug(`Latest tx: ${latestTx?.lt}:${latestTx?.hash}`);
const collectionOwner = Address.parse(config.COLLECTION_OWNER);
const txs = await this.getTransactions(
address,
collectionOwner,
latestTx?.lt,
latestTx?.hash,
);
Expand All @@ -110,7 +110,7 @@ export class Subscription {
}
}
} catch (error) {
logger.error(error);
logger.error(`Start error: ${(error as Error).message}`);
}

isProcessing = false;
Expand Down
3 changes: 2 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ const createConfigFromEnvironment = (environment: NodeJS.ProcessEnv) => {
MONGO: z.string(),
BOT_ADMINS: z.array(z.number()).default([]),
COLLECTION_ADDRESS: z.string(),
COLLECTION_OWNER: z.string(),
MNEMONICS: z.string(),
PINATA_API_KEY: z.string(),
PINATA_API_SECRET: z.string(),
MNEMONICS: z.string(),
TONCENTER_API_KEY: z.string(),
TESTNET: z.boolean().default(true),
STABILITY_API_KEY: z.string(),
Expand Down

0 comments on commit 0204713

Please sign in to comment.