File tree Expand file tree Collapse file tree 5 files changed +26
-29
lines changed
server/routes/contract/extensions/erc721/read Expand file tree Collapse file tree 5 files changed +26
-29
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ import { checkAndReturnNFTSignaturePayload } from "../../../../../utils/validato
35
35
36
36
// INPUTS
37
37
const requestSchema = erc721ContractParamSchema ;
38
- const requestBodySchema = Type . Omit ( signature721InputSchema , [ "uid" ] ) ;
38
+ const requestBodySchema = signature721InputSchema ;
39
39
40
40
// OUTPUT
41
41
const responseSchema = Type . Object ( {
@@ -213,6 +213,7 @@ export async function erc721SignaturePrepare(fastify: FastifyInstance) {
213
213
quantity,
214
214
royaltyBps,
215
215
royaltyRecipient,
216
+ uid,
216
217
} = request . body ;
217
218
218
219
const chainId = await getChainIdFromChain ( chain ) ;
@@ -245,7 +246,7 @@ export async function erc721SignaturePrepare(fastify: FastifyInstance) {
245
246
const parsed = await Signature721WithQuantityInput . parseAsync ( payload ) ;
246
247
const mintPayload = {
247
248
...parsed ,
248
- uid : generateUid ( ) ,
249
+ uid : uid ?? generateUid ( ) ,
249
250
uri,
250
251
royaltyBps : BigNumber . from ( parsed . royaltyBps ) ,
251
252
} ;
Original file line number Diff line number Diff line change @@ -61,7 +61,13 @@ export const env = createEnv({
61
61
ENABLE_HTTPS : boolSchema ( "false" ) ,
62
62
HTTPS_PASSPHRASE : z . string ( ) . default ( "thirdweb-engine" ) ,
63
63
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 ) ,
65
71
CLIENT_ANALYTICS_URL : z
66
72
. union ( [ UrlSchema , z . literal ( "" ) ] )
67
73
. default ( "https://c.thirdweb.com/event" ) ,
Original file line number Diff line number Diff line change 3
3
newConfigurationListener ,
4
4
updatedConfigurationListener ,
5
5
} from "./listeners/configListener" ;
6
- import { deleteProcessedTx } from "./listeners/deleteProcessedTx" ;
6
+ import { pruneCompletedTransactions } from "./listeners/deleteProcessedTx" ;
7
7
import { minedTxListener } from "./listeners/minedTxListener" ;
8
8
import { queuedTxListener } from "./listeners/queuedTxListener" ;
9
9
import { retryTxListener } from "./listeners/retryTxListener" ;
@@ -25,8 +25,8 @@ export const initWorker = async () => {
25
25
// Poll for mined transactions to update database
26
26
await minedTxListener ( ) ;
27
27
28
- // Delete Successfully Processed Transactions which are older than 24 hours
29
- await deleteProcessedTx ( ) ;
28
+ // Delete completed transactions after some age.
29
+ await pruneCompletedTransactions ( ) ;
30
30
31
31
// Listen for new & updated configuration data
32
32
await newConfigurationListener ( ) ;
Original file line number Diff line number Diff line change @@ -4,11 +4,10 @@ import { deleteTx } from "../tasks/deleteTx";
4
4
5
5
const CLEAR_QUEUED_TX_CRON_SCHEDULE = "0 0 */2 * * *" ;
6
6
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
+ }
14
13
} ;
Original file line number Diff line number Diff line change 1
1
import { prisma } from "../../db/client" ;
2
2
import { logger } from "../../utils/logger" ;
3
3
4
- export const deleteTx = async ( ) => {
4
+ export const deleteTx = async ( maxAgeDays : number ) => {
5
5
try {
6
- const twentyFourHoursAgo = new Date ( ) ;
7
- twentyFourHoursAgo . setHours ( twentyFourHoursAgo . getHours ( ) - 24 ) ;
6
+ const deleteBefore = new Date ( ) ;
7
+ deleteBefore . setDate ( deleteBefore . getDate ( ) - maxAgeDays ) ;
8
8
9
9
const deletedItems = await prisma . transactions . deleteMany ( {
10
10
where : {
11
- // All txs queued 24+ hours ago that are mined, cancelled, or errored.
12
11
AND : [
13
12
{
14
- queuedAt : {
15
- lt : twentyFourHoursAgo ,
16
- } ,
13
+ queuedAt : { lt : deleteBefore } ,
17
14
} ,
18
15
{
19
16
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 } } ,
29
20
] ,
30
21
} ,
31
22
] ,
You can’t perform that action at this time.
0 commit comments