Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Updates #12

Merged
merged 3 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/services/green-bean.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export class GreenBeanService {
return data[0];
}

async getAzukis({ canClaim }: Prisma.AzukiSelect) {
return this.prisma.azuki.findMany({
where: { canClaim },
orderBy: { tokenId: 'asc' },
});
}

async createAzuki({
tokenId,
canClaim,
Expand Down
10 changes: 0 additions & 10 deletions src/standalone/scripts/asdf.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from '../../app.module';
import { GreenBeanService } from '../../services/green-bean.service';
import { AppModule } from '../../../app.module';
import { GreenBeanService } from '../../../services/green-bean.service';

// Initialize the db with canClaim statuses for all Azukis
async function bootstrap() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NestFactory } from '@nestjs/core';
import { decodeFunctionData } from 'viem';
import * as dayjs from 'dayjs';
import { AppModule } from '../../app.module';
import { GREEN_BEAN_ADDRESS } from '../../constants';
import { client } from '../../utils/client';
import { greenBeanAbi } from '../../abis/green-bean-abi';
import { GreenBeanService } from '../../services/green-bean.service';
import { AppModule } from '../../../app.module';
import { GREEN_BEAN_ADDRESS } from '../../../constants';
import { client } from '../../../utils/client';
import { greenBeanAbi } from '../../../abis/green-bean-abi';
import { GreenBeanService } from '../../../services/green-bean.service';

// store the thumbnail images for all Azukis
async function bootstrap() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { NestFactory } from '@nestjs/core';
import { NftTokenType } from 'alchemy-sdk';
import { AppModule } from '../../app.module';
import { GreenBeanService } from '../../services/green-bean.service';
import { alchemy } from '../../utils/alchemy';
import { AZUKI_CONTRACT_ADDRESS } from '../../constants';
import { AppModule } from '../../../app.module';
import { GreenBeanService } from '../../../services/green-bean.service';
import { alchemy } from '../../../utils/alchemy';
import { AZUKI_CONTRACT_ADDRESS } from '../../../constants';

// store the thumbnail images for all Azukis
async function bootstrap() {
Expand Down
29 changes: 29 additions & 0 deletions src/standalone/scripts/schedule/check-can-claim-azukis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from '../../../app.module';
import { GreenBeanService } from '../../../services/green-bean.service';

// The intention for this script is to be run on a schedule, to check if there are any azukis that have claimed their green beans via a smart contract
async function bootstrap() {
const app = await NestFactory.createApplicationContext(AppModule);
const greenBeanService = app.get(GreenBeanService);

const canClaimAzukis = await greenBeanService.getAzukis({ canClaim: true });
await app.close();

for (let i = 0; i < canClaimAzukis.length; i++) {
const azuki = canClaimAzukis[i];

const canClaimStatus = await greenBeanService.checkGreenBean(azuki.tokenId);
console.log(`${i}: ${azuki.tokenId} - ${canClaimStatus}`);

if (!canClaimStatus) {
await greenBeanService.updateAzuki({
tokenId: azuki.tokenId,
canClaim: false,
});
console.log(`Updated ${azuki.tokenId} with canClaim: false`);
}
}
}

bootstrap();