Skip to content

Commit b9e9309

Browse files
Development to main (#984)
* SERVICES1086 rebuild marketplace data/state endpoint, service and functions (part 1) * SERVICES-1085 extract confusing logic in a separete function; renaming; remove comment * SERVICES-1085 code splitting, renamings & improvements * SERVICES-1085 rename param * SERVICES-1085 add marketplace reindex process event logic * SERVICES-1085 fix batch slice function; code improvements for get event category function * SERVICES-1085 remove console log * SERVICES-1085 extract total bought tokens in a separate function * SERVICES-1085 split reindex marketplace data code * SERVICES-1085 use handlers and summary classes for rebuilding marketplace state * SERVICES-1085 fix marketplace elastic query time range filter * SERVICES-1085 create MarketplaceReindexState class with common methods and remove common handlers * SERVICES-1085 add handlers for XOXNO specfic events * set default paymentNonce if not already set * SERVICES-1085 ignore not used marketplace events for better performance\ * undo default paymentNonce * SERVICES-1085 marketplace events summaries * SERVICES-1085 update marketplace event summaries and add DeadRare updatePrice topics * SERVICES-1085 marketplace events summary service * SERVICES-1085 fix marketplace reindex summaries and handle krogan acceptOffer * SERVICES-1085 marketplace reindex state handlers * SERVICES-1085 remove confusing method * SERVICES-1085 remove confusing method * SERVICES-1085 extract create new order from event summary logic into a separate method * SERVICES-1085 improve createOrder from summary function * SERVICES-1085 renamings * SERVICES-1085 renamings * SERVICES-1085 update marketplace reindex state service * SERVICES-1085 process event even if no payment token found * SERVICES-1085 xoxno user deposit * SERVICES-1085 fix elrondnftswap offerId type * SERVICES-1085 reindex marketplace state before & after time range * SERVICES-1085 reindex marketplace state logs & fixes * SERVICES-1085 renaming * SERVICES-1085 fix duplicate bid for internal marketplace * SERVICES-1085 try-catch and better logging * SERVICES-1085 fix xoxno no startTime * SERVICES-1085 fix xoxno no startTime * SERVICES-1085 fix endAuction with no winning order * SERVICES-1085 fix case when undefined beforeTimestamp * SERVICES-1085 save auction tags * SERVICES-1085 admin endpoints fire and forget * SERVICES-1085 fix internal auction timestamp topic * SERVICES-1085 marketplace reindex events locker & logs * SERVICES-1085 handle multiple internal marketplaces with same address case * fix admin resolver catch * SERVICES-1085 exclude collection filtering when unique marketplace address * SERVICES-1085 fix case when timestamp not spported by DB * Add plugins module * Update scam cronjob * Update scam service * Add none scam info * Update workflow * Update cronjob time * Remode delete by pattern where not needed * Fix scam report * Remove unused code * trigger cache invalidation * Change delete to update * Remove delete by pattern for asset history * Remove delete by pattern from cache invalidation * Clear to none nft scam info * Update scam update cache invalidation * Add null check * Add collections with no volum * Fix trending order by * Fix trending return * Fix order trending * Move blacklist filter before order * Update filter collection * Remove clear by pattern in auctions * Add Scam Collection setting * Add cache invalidation * Remove scam info from api * clean up code * Upgrade testing packages * Remove data api calls * Update mapping * Refactor Token model * Add historical price retrieve * Add elrond tools back * Add create nft with multiple files * Extract duplicated code * Fix typo * Decrease caching time * Decrease caching time * Add ici handling * Update key * Update key * Fix Scam Mapping * Fix bug for event processing * Add tickets type on collections * Add page consts and remove extra pagination * Remove extra line * Add isTicket field on asset * Update redis handler for is ticket * Add debuging logging * Fix tickets assets return * Remove logging * Update length check * Update collection length checking * Fix undefined error * Allow nullable for role address --------- Co-authored-by: johnykes <[email protected]> Co-authored-by: johnykes <[email protected]>
1 parent 1a1d9a1 commit b9e9309

File tree

127 files changed

+4506
-1448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+4506
-1448
lines changed

.github/workflows/node.js.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,5 @@ jobs:
2626
with:
2727
node-version: ${{ matrix.node-version }}
2828
cache: 'npm'
29-
- run: npm install
30-
- run: npm run build --if-present
29+
- run: npm ci
3130
- run: npm test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,3 +400,4 @@ build.yaml
400400

401401
# PEM file(s)
402402
*.pem
403+
/src/plugins

package-lock.json

Lines changed: 361 additions & 637 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
"description": "Nest TypeScript starter repository",
66
"license": "MIT",
77
"scripts": {
8+
"init": "run-script-os",
9+
"init:nix": "rimraf src/plugins && mkdir src/plugins && cp src/plugins.template/plugin.module.ts.template src/plugins/plugin.module.ts",
810
"prebuild": "rimraf dist",
911
"build": "nest build && npm run copy-pem",
1012
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
@@ -90,11 +92,11 @@
9092
"devDependencies": {
9193
"@nestjs/cli": "9.2.0",
9294
"@nestjs/schematics": "9.0.4",
93-
"@nestjs/testing": "9.1.4",
95+
"@nestjs/testing": "9.3.12",
9496
"@types/express": "^4.17.11",
9597
"@types/graphql-relay": "^0.6.0",
96-
"@types/jest": "^27.4.1",
97-
"@types/node": "^14.14.36",
98+
"@types/jest": "29.5.0",
99+
"@types/node": "^14.14.42",
98100
"@types/passport-local": "^1.0.33",
99101
"@types/supertest": "^2.0.12",
100102
"@types/tiny-async-pool": "^1.0.0",
@@ -103,7 +105,7 @@
103105
"eslint": "8.28.0",
104106
"eslint-config-prettier": "8.5.0",
105107
"eslint-plugin-prettier": "3.4.1",
106-
"jest": "29.4.2",
108+
"jest": "29.5.0",
107109
"prettier": "^2.2.1",
108110
"supertest": "6.3.3",
109111
"ts-jest": "29.0.5",

schema.gql

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ type Asset {
8888
identifier: String!
8989
isLiked(byAddress: String!): Boolean
9090
isNsfw: Boolean
91+
isTicket: Boolean
9192
isWhitelistedStorage: Boolean!
9293
likesCount: Int
9394
lowestAuction(filters: MarketplaceFilters): Auction
@@ -115,12 +116,15 @@ type Asset {
115116

116117
enum AssetActionEnum {
117118
Added
119+
Bid
118120
Bought
119121
ClosedAuction
120122
Created
121123
EndedAuction
124+
PriceUpdated
122125
Received
123126
StartedAuction
127+
Updated
124128
}
125129

126130
type AssetEdge {
@@ -181,6 +185,7 @@ input AssetsFilter {
181185
"""This will work only with an owner address"""
182186
collections: [String!]
183187
creatorAddress: String
188+
customFilters: CustomFiltersEnum
184189
identifier: String
185190
identifiers: [String!]
186191
likedByAddress: String
@@ -508,7 +513,7 @@ type CollectionResponse {
508513
}
509514

510515
type CollectionRole {
511-
address: String!
516+
address: String
512517
canAddQuantity: Boolean
513518
canAddUri: Boolean
514519
canBurn: Boolean
@@ -623,6 +628,10 @@ input CurrentPaymentTokensFilters {
623628
marketplaceKey: String
624629
}
625630

631+
enum CustomFiltersEnum {
632+
Tickets
633+
}
634+
626635
type ExploreCollectionsStats {
627636
activeLast30DaysCount: Int!
628637
allCollectionsCount: Int!
@@ -645,6 +654,7 @@ type ExploreStats {
645654
enum FeaturedCollectionTypeEnum {
646655
Featured
647656
Hero
657+
Tickets
648658
}
649659

650660
input FeaturedCollectionsArgs {
@@ -768,6 +778,12 @@ type MarketplacePageInfo {
768778
startCursor: String
769779
}
770780

781+
input MarketplaceReindexDataArgs {
782+
afterTimestamp: Float
783+
beforeTimestamp: Float
784+
marketplaceAddress: String!
785+
}
786+
771787
enum MarketplaceTypeEnum {
772788
External
773789
Internal
@@ -838,13 +854,15 @@ type Mutation {
838854
clearReportNft(input: ClearReportInput!): Boolean!
839855
createAuction(input: CreateAuctionArgs!): TransactionNode!
840856
createNft(file: Upload!, input: CreateNftArgs!): TransactionNode!
857+
createNftWithMultipleFiles(files: [Upload!]!, input: CreateNftArgs!): TransactionNode!
841858
endAuction(auctionId: Int!): TransactionNode!
842859
flagCollection(input: FlagCollectionInput!): Boolean!
843860
flagNft(input: FlagNftInput!): Boolean!
844861
indexTrandingCollections(forTheLastHours: Float!): Boolean!
845862
issueCampaign(input: IssueCampaignArgs!): TransactionNode!
846863
issueNftCollection(input: IssueCollectionArgs!): TransactionNode!
847864
issueSftCollection(input: IssueCollectionArgs!): TransactionNode!
865+
reindexMarketplaceData(input: MarketplaceReindexDataArgs!): Boolean!
848866
reindexMarketplaceEvents(input: MarketplaceEventsIndexingArgs!): Boolean!
849867
removeBlacklistedCollection(collection: String!): Boolean!
850868
removeFeaturedCollection(input: FeaturedCollectionsArgs!): Boolean!
@@ -1201,6 +1219,7 @@ type ScamInfo {
12011219
}
12021220

12031221
enum ScamInfoTypeEnum {
1222+
none
12041223
potentialScam
12051224
scam
12061225
}

src/common/persistence/persistence.service.ts

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class PersistenceService {
8484
private readonly auctionsRepository: AuctionsRepository,
8585
private readonly marketplaceEventsRepository: MarketplaceEventsRepository,
8686
private readonly offersRepository: OffersRepository,
87-
) {}
87+
) { }
8888

8989
private async execute<T>(key: string, action: Promise<T>): Promise<T> {
9090
const profiler = new PerformanceProfiler();
@@ -338,6 +338,13 @@ export class PersistenceService {
338338
);
339339
}
340340

341+
async getFeaturedCollectionsByIdentifiers(collections: string[]): Promise<FeaturedCollectionEntity[]> {
342+
return await this.execute(
343+
this.getFeaturedCollections.name,
344+
this.featuredCollectionsRepository.getFeaturedCollectionsByIdentifiers(collections),
345+
);
346+
}
347+
341348
async addFeaturedCollection(
342349
collection: string,
343350
type: FeaturedCollectionTypeEnum,
@@ -729,6 +736,13 @@ export class PersistenceService {
729736
);
730737
}
731738

739+
async saveBulkOrders(orders: OrderEntity[]) {
740+
return await this.execute(
741+
this.saveBulkOrders.name,
742+
this.ordersRepository.saveBulkOrders(orders),
743+
);
744+
}
745+
732746
async updateOrderWithStatus(order: OrderEntity, status: OrderStatusEnum) {
733747
return await this.execute(
734748
this.updateOrderWithStatus.name,
@@ -878,6 +892,18 @@ export class PersistenceService {
878892
this.auctionsRepository.getBulkAuctions(auctionsIds),
879893
);
880894
}
895+
async getBulkAuctionsByAuctionIdsAndMarketplace(
896+
auctionsIds: number[],
897+
marketplaceKey: string,
898+
): Promise<AuctionEntity[]> {
899+
return await this.execute(
900+
this.getBulkAuctionsByAuctionIdsAndMarketplace.name,
901+
this.auctionsRepository.getBulkAuctionsByAuctionIdsAndMarketplace(
902+
auctionsIds,
903+
marketplaceKey,
904+
),
905+
);
906+
}
881907

882908
async getAuctionByMarketplace(
883909
id: number,
@@ -918,6 +944,19 @@ export class PersistenceService {
918944
);
919945
}
920946

947+
async getBulkAuctionsByIdentifierAndMarketplace(
948+
identifiers: string[],
949+
marletplaceKey: string,
950+
): Promise<any[]> {
951+
return await this.execute(
952+
this.getBulkAuctionsByIdentifierAndMarketplace.name,
953+
this.auctionsRepository.getBulkAuctionsByIdentifiersAndMarketplace(
954+
identifiers,
955+
marletplaceKey,
956+
),
957+
);
958+
}
959+
921960
async getAvailableTokensForIdentifiers(identifiers: string[]): Promise<any> {
922961
return await this.execute(
923962
this.getAvailableTokensForIdentifiers.name,
@@ -978,6 +1017,13 @@ export class PersistenceService {
9781017
);
9791018
}
9801019

1020+
async saveBulkAuctions(auctions: AuctionEntity[]): Promise<void> {
1021+
return await this.execute(
1022+
this.saveBulkAuctions.name,
1023+
this.auctionsRepository.saveBulkAuctions(auctions),
1024+
);
1025+
}
1026+
9811027
async rollbackAuctionAndOrdersByHash(blockHash: string): Promise<any> {
9821028
return await this.execute(
9831029
this.rollbackAuctionAndOrdersByHash.name,
@@ -1078,6 +1124,13 @@ export class PersistenceService {
10781124
);
10791125
}
10801126

1127+
async saveBulkOffers(offers: OfferEntity[]): Promise<void> {
1128+
return await this.execute(
1129+
this.saveBulkOffers.name,
1130+
this.offersRepository.saveBulkOffers(offers),
1131+
);
1132+
}
1133+
10811134
async getOffersThatReachedDeadline(): Promise<OfferEntity[]> {
10821135
return await this.execute(
10831136
this.getOffersThatReachedDeadline.name,
@@ -1092,6 +1145,19 @@ export class PersistenceService {
10921145
);
10931146
}
10941147

1148+
async getBulkOffersByOfferIdsAndMarketplace(
1149+
offerIds: number[],
1150+
marketplaceKey: string,
1151+
): Promise<OfferEntity[]> {
1152+
return await this.execute(
1153+
this.getBulkOffersByOfferIdsAndMarketplace.name,
1154+
this.offersRepository.getBulkOffersByOfferIdsAndMarketplace(
1155+
offerIds,
1156+
marketplaceKey,
1157+
),
1158+
);
1159+
}
1160+
10951161
async getMostLikedAssetsIdentifiers(
10961162
offset?: number,
10971163
limit?: number,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Injectable } from '@nestjs/common';
2+
import { Asset } from 'src/modules/assets/models/Asset.dto';
3+
4+
@Injectable()
5+
export class PluginService {
6+
async computeScamInfo(_nft: Asset[]): Promise<void> {}
7+
}

src/common/services/caching/entities/cache.info.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ export class CacheInfo {
129129
ttl: 10 * Constants.oneMinute(),
130130
};
131131

132+
static CexTokens: CacheInfo = {
133+
key: 'cexTokens',
134+
ttl: 10 * Constants.oneMinute(),
135+
};
136+
137+
static xExchangeTokens: CacheInfo = {
138+
key: 'xExchangeTokens',
139+
ttl: 10 * Constants.oneMinute(),
140+
};
141+
132142
static AllTokens: CacheInfo = {
133143
key: 'allTokens',
134144
ttl: Constants.oneMinute(),
@@ -156,7 +166,7 @@ export class CacheInfo {
156166

157167
static AssetHistory: CacheInfo = {
158168
key: 'assetHistory',
159-
ttl: Constants.oneDay(),
169+
ttl: 5 * Constants.oneMinute(),
160170
};
161171

162172
static CollectionTypes: CacheInfo = {

src/common/services/mx-communication/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export * from './mx-api.service';
22
export * from './mx-stats.service';
33
export * from './mx-communication.module';
4-
export * from './mx-tools.service';
54
export * from './mx-elastic.service';
65
export * from './mx-identity.service';
76
export * from './mx-proxy.service';
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { ScamInfo } from 'src/modules/assets/models/ScamInfo.dto';
2+
3+
export class AccountInfo {
4+
address: string = '';
5+
nonce: number = 0;
6+
balance: string = '';
7+
username: string = '';
8+
code: string = '';
9+
codeHash: string | undefined;
10+
rootHash: string = '';
11+
codeMetadata: string = '';
12+
developerReward: string = '';
13+
ownerAddress: string = '';
14+
scamInfo: ScamInfo | undefined = undefined;
15+
16+
constructor(init?: Partial<AccountInfo>) {
17+
Object.assign(this, init);
18+
}
19+
}

0 commit comments

Comments
 (0)