File tree Expand file tree Collapse file tree
server/routes/contract/extensions/erc721/read Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ import { checkAndReturnNFTSignaturePayload } from "../../../../../utils/validato
3535
3636// INPUTS
3737const requestSchema = erc721ContractParamSchema ;
38- const requestBodySchema = Type . Omit ( signature721InputSchema , [ "uid" ] ) ;
38+ const requestBodySchema = signature721InputSchema ;
3939
4040// OUTPUT
4141const responseSchema = Type . Object ( {
@@ -213,6 +213,7 @@ export async function erc721SignaturePrepare(fastify: FastifyInstance) {
213213 quantity,
214214 royaltyBps,
215215 royaltyRecipient,
216+ uid,
216217 } = request . body ;
217218
218219 const chainId = await getChainIdFromChain ( chain ) ;
@@ -245,7 +246,7 @@ export async function erc721SignaturePrepare(fastify: FastifyInstance) {
245246 const parsed = await Signature721WithQuantityInput . parseAsync ( payload ) ;
246247 const mintPayload = {
247248 ...parsed ,
248- uid : generateUid ( ) ,
249+ uid : uid ?? generateUid ( ) ,
249250 uri,
250251 royaltyBps : BigNumber . from ( parsed . royaltyBps ) ,
251252 } ;
Original file line number Diff line number Diff line change @@ -61,7 +61,13 @@ export const env = createEnv({
6161 ENABLE_HTTPS : boolSchema ( "false" ) ,
6262 HTTPS_PASSPHRASE : z . string ( ) . default ( "thirdweb-engine" ) ,
6363 TRUST_PROXY : z . boolean ( ) . default ( false ) ,
64- PRUNE_TRANSACTIONS : boolSchema ( "true" ) ,
64+ PRUNE_TRANSACTIONS : z
65+ . union ( [
66+ z . literal ( "true" ) . transform ( ( ) => 7 ) ,
67+ z . literal ( "false" ) . transform ( ( ) => 0 ) ,
68+ z . coerce . number ( ) . int ( ) ,
69+ ] )
70+ . default ( 7 ) ,
6571 CLIENT_ANALYTICS_URL : z
6672 . union ( [ UrlSchema , z . literal ( "" ) ] )
6773 . default ( "https://c.thirdweb.com/event" ) ,
Original file line number Diff line number Diff line change 33 newConfigurationListener ,
44 updatedConfigurationListener ,
55} from "./listeners/configListener" ;
6- import { deleteProcessedTx } from "./listeners/deleteProcessedTx" ;
6+ import { pruneCompletedTransactions } from "./listeners/deleteProcessedTx" ;
77import { minedTxListener } from "./listeners/minedTxListener" ;
88import { queuedTxListener } from "./listeners/queuedTxListener" ;
99import { retryTxListener } from "./listeners/retryTxListener" ;
@@ -25,8 +25,8 @@ export const initWorker = async () => {
2525 // Poll for mined transactions to update database
2626 await minedTxListener ( ) ;
2727
28- // Delete Successfully Processed Transactions which are older than 24 hours
29- await deleteProcessedTx ( ) ;
28+ // Delete completed transactions after some age.
29+ await pruneCompletedTransactions ( ) ;
3030
3131 // Listen for new & updated configuration data
3232 await newConfigurationListener ( ) ;
Original file line number Diff line number Diff line change @@ -4,11 +4,10 @@ import { deleteTx } from "../tasks/deleteTx";
44
55const CLEAR_QUEUED_TX_CRON_SCHEDULE = "0 0 */2 * * *" ;
66
7- // Deletes successfully processed transactions which were queued 24 hrs ago.
8- export const deleteProcessedTx = async ( ) => {
9- cron . schedule ( CLEAR_QUEUED_TX_CRON_SCHEDULE , async ( ) => {
10- if ( env . PRUNE_TRANSACTIONS ) {
11- await deleteTx ( ) ;
12- }
13- } ) ;
7+ export const pruneCompletedTransactions = async ( ) => {
8+ if ( env . PRUNE_TRANSACTIONS > 0 ) {
9+ cron . schedule ( CLEAR_QUEUED_TX_CRON_SCHEDULE , async ( ) => {
10+ await deleteTx ( env . PRUNE_TRANSACTIONS ) ;
11+ } ) ;
12+ }
1413} ;
Original file line number Diff line number Diff line change 11import { prisma } from "../../db/client" ;
22import { logger } from "../../utils/logger" ;
33
4- export const deleteTx = async ( ) => {
4+ export const deleteTx = async ( maxAgeDays : number ) => {
55 try {
6- const twentyFourHoursAgo = new Date ( ) ;
7- twentyFourHoursAgo . setHours ( twentyFourHoursAgo . getHours ( ) - 24 ) ;
6+ const deleteBefore = new Date ( ) ;
7+ deleteBefore . setDate ( deleteBefore . getDate ( ) - maxAgeDays ) ;
88
99 const deletedItems = await prisma . transactions . deleteMany ( {
1010 where : {
11- // All txs queued 24+ hours ago that are mined, cancelled, or errored.
1211 AND : [
1312 {
14- queuedAt : {
15- lt : twentyFourHoursAgo ,
16- } ,
13+ queuedAt : { lt : deleteBefore } ,
1714 } ,
1815 {
1916 OR : [
20- {
21- minedAt : { not : null } ,
22- } ,
23- {
24- cancelledAt : { not : null } ,
25- } ,
26- {
27- errorMessage : { not : null } ,
28- } ,
17+ { minedAt : { not : null } } ,
18+ { cancelledAt : { not : null } } ,
19+ { errorMessage : { not : null } } ,
2920 ] ,
3021 } ,
3122 ] ,
You can’t perform that action at this time.
0 commit comments