forked from decentraland/marketplace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: fill wearables data (decentraland#22)
* feat: finish indexer * feat: index xmas * feat: rename folders and ignore built files * feat: add wearables to NFTs * feat: finish adding wearables. prepare for other nfts * fix: correctly check for xmas collection
- Loading branch information
1 parent
8237bfb
commit cc56539
Showing
23 changed files
with
1,088 additions
and
2,697 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
indexer/src/mappings/manaCrowdsale.ts → indexer/src/handlers/manaCrowdsale.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import { Address } from '@graphprotocol/graph-ts' | ||
|
||
import { Finalized } from '../types/MANACrowdsale/MANACrowdsale' | ||
import { ERC721 } from '../types/templates' | ||
import { Finalized } from '../entities/MANACrowdsale/MANACrowdsale' | ||
import { ERC721 } from '../entities/templates' | ||
import { | ||
LANDRegistry, | ||
EstateRegistry, | ||
ERC721Collection_halloween_2019, | ||
ERC721Collection_exclusive_masks | ||
ERC721Collection_exclusive_masks, | ||
ERC721Collection_xmas_2019 | ||
} from '../modules/contract/addresses' | ||
|
||
export function handleFinalized(_: Finalized): void { | ||
ERC721.create(Address.fromString(LANDRegistry)) | ||
ERC721.create(Address.fromString(EstateRegistry)) | ||
ERC721.create(Address.fromString(ERC721Collection_halloween_2019)) | ||
ERC721.create(Address.fromString(ERC721Collection_exclusive_masks)) | ||
ERC721.create(Address.fromString(ERC721Collection_xmas_2019)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { Transfer } from '../entities/templates/ERC721/ERC721' | ||
import { NFT, Parcel, Estate } from '../entities/schema' | ||
import { isMint, buildId, getTokenURI } from '../modules/nft' | ||
import { getCategory } from '../modules/category' | ||
import { buildData, DataType } from '../modules/data' | ||
import { upsertMetric } from '../modules/metric' | ||
import { decodeTokenId } from '../modules/parcel' | ||
import { upsertWearable } from '../modules/wearable' | ||
import { createWallet } from '../modules/wallet' | ||
import * as addresses from '../modules/contract/addresses' | ||
import * as categories from '../modules/category/categories' | ||
|
||
export function handleTransfer(event: Transfer): void { | ||
if (event.params.tokenId.toString() == '') { | ||
return | ||
} | ||
|
||
let contractAddress = event.address.toHexString() | ||
let category = getCategory(contractAddress) | ||
let id = buildId(event.params.tokenId.toString(), category) | ||
|
||
let nft = new NFT(id) | ||
|
||
nft.tokenId = event.params.tokenId | ||
nft.owner = event.params.to.toHex() | ||
nft.contractAddress = event.address | ||
nft.category = category | ||
|
||
if (contractAddress != addresses.LANDRegistry) { | ||
// The LANDRegistry contract does not have a tokenURI method | ||
nft.tokenURI = getTokenURI(event) | ||
} | ||
|
||
if (category == categories.WEARABLE) { | ||
let wearableId = upsertWearable(nft.tokenURI) | ||
if (wearableId != '') { | ||
nft.wearable = wearableId | ||
} | ||
} | ||
|
||
if (isMint(event)) { | ||
upsertMetric(contractAddress) | ||
nft.createdAt = event.block.timestamp | ||
} else { | ||
nft.updatedAt = event.block.timestamp | ||
} | ||
|
||
createWallet(event.params.to.toHex()) | ||
|
||
nft.save() | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,40 @@ | ||
import { Metric } from '../../types/schema' | ||
import { Metric } from '../../entities/schema' | ||
import * as addresses from '../contract/addresses' | ||
|
||
export const DEFAULT_ID = 'all' | ||
|
||
export function getMetricEntity(): Metric { | ||
export function buildMetric(): Metric { | ||
let metric = Metric.load(DEFAULT_ID) | ||
|
||
if (metric == null) { | ||
metric = new Metric(DEFAULT_ID) | ||
metric.parcel = 0 | ||
metric.estate = 0 | ||
metric.wearable_halloween_2019 = 0 | ||
metric.wearable_exclusive_masks = 0 | ||
metric.parcels = 0 | ||
metric.estates = 0 | ||
metric.orders = 0 | ||
metric.wearables_halloween_2019 = 0 | ||
metric.wearables_exclusive_masks = 0 | ||
metric.wearables_xmas_2019 = 0 | ||
} | ||
|
||
return metric as Metric | ||
} | ||
|
||
export function getUpdatedMetricEntity(contractAddress: string): Metric { | ||
let metric = getMetricEntity() | ||
export function upsertMetric(contractAddress: string): void { | ||
let metric = buildMetric() | ||
|
||
if (contractAddress == addresses.LANDRegistry) { | ||
metric.parcel += 1 | ||
metric.parcels += 1 | ||
} else if (contractAddress == addresses.EstateRegistry) { | ||
metric.estate += 1 | ||
} else if (contractAddress == addresses.ERC721Collection_exclusive_masks) { | ||
metric.wearable_exclusive_masks += 1 | ||
metric.estates += 1 | ||
} else if (contractAddress == addresses.Marketplace) { | ||
metric.orders += 1 | ||
} else if (contractAddress == addresses.ERC721Collection_halloween_2019) { | ||
metric.wearable_halloween_2019 += 1 | ||
metric.wearables_halloween_2019 += 1 | ||
} else if (contractAddress == addresses.ERC721Collection_exclusive_masks) { | ||
metric.wearables_exclusive_masks += 1 | ||
} else if (contractAddress == addresses.ERC721Collection_xmas_2019) { | ||
metric.wearables_xmas_2019 += 1 | ||
} | ||
|
||
return metric | ||
metric.save() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export class Wearable { | ||
id: string | ||
name: string | ||
description: string | ||
category: string | ||
rarity: string | ||
|
||
constructor( | ||
id: string, | ||
name: string, | ||
description: string, | ||
category: string, | ||
rarity: string | ||
) { | ||
this.id = id | ||
this.name = name | ||
this.description = description | ||
this.category = category | ||
this.rarity = rarity | ||
} | ||
} |
Oops, something went wrong.