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

feat: add stay safe collection and only start once #172

Merged
merged 2 commits into from
Apr 11, 2020
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
1 change: 1 addition & 0 deletions indexer/.subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ templates:
- Parcel
- Estate
- Wearable
- ENS
abis:
- name: ERC721
file: ./abis/ERC721.json
Expand Down
2 changes: 2 additions & 0 deletions indexer/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ type Count @entity {
wearableXmas2019: Int!

ensTotal: Int!

started: Int!
}

# ---------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions indexer/src/data/.addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export const CommunityContestCollection =
'{{address:CommunityContestCollection}}'
export const DCLLaunchCollection = '{{address:DCLLaunchCollection}}'
export const DCGCollection = '{{address:DCGCollection}}'
export const StaySafeCollection = '{{address:StaySafeCollection}}'
export const DCLRegistrar = '{{address:DCLRegistrar}}'
export const Marketplace = '{{address:Marketplace}}'
5 changes: 3 additions & 2 deletions indexer/src/data/wearables/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export * from './Wearable'
export * from './community_contest'
export * from './dcg_collection'
export * from './dcl_launch'
export * from './mch_collection'
export * from './halloween_2019'
export * from './exclusive_masks'
export * from './halloween_2019'
export * from './mch_collection'
export * from './stay_safe'
export * from './xmas_2019'
69 changes: 69 additions & 0 deletions indexer/src/data/wearables/stay_safe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Wearable } from './Wearable'

export let stay_safe: Wearable[] = [
new Wearable(
'protection_mask_abstract_mask',
'Abstract Protection Mask',
'Supporting the #CryptoAgainstCOVID initiative',
'mask',
'epic',
['BaseMale', 'BaseFemale']
),
new Wearable(
'protection_mask_african_mask',
'African Protection Mask',
'Supporting the #CryptoAgainstCOVID initiative',
'mask',
'epic',
['BaseMale', 'BaseFemale']
),
new Wearable(
'protection_mask_funny_mask',
'Funny Protection Mask',
'Supporting the #CryptoAgainstCOVID initiative',
'mask',
'epic',
['BaseMale', 'BaseFemale']
),
new Wearable(
'protection_mask_graffiti_mask',
'Graffiti Protection Mask',
'Supporting the #CryptoAgainstCOVID initiative',
'mask',
'epic',
['BaseMale', 'BaseFemale']
),
new Wearable(
'protection_mask_hot_mask',
'Hot Protection Mask',
'Supporting the #CryptoAgainstCOVID initiative',
'mask',
'epic',
['BaseMale', 'BaseFemale']
),
new Wearable(
'protection_mask_monster_mask',
'Monster Protection Mask',
'Supporting the #CryptoAgainstCOVID initiative',
'mask',
'epic',
['BaseMale', 'BaseFemale']
),
new Wearable(
'protection_mask_skull_mask',
'Skull Protection Mask',
'Supporting the #CryptoAgainstCOVID initiative',
'mask',
'epic',
['BaseMale', 'BaseFemale']
),
new Wearable(
'protection_mask_tiger_mask',
'Tiger Protection Mask',
'Supporting the #CryptoAgainstCOVID initiative',
'mask',
'epic',
['BaseMale', 'BaseFemale']
)
]

30 changes: 20 additions & 10 deletions indexer/src/handlers/parcel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { log, Address } from '@graphprotocol/graph-ts'
import { Update, InitializeCall } from '../entities/LANDRegistry/LANDRegistry'
import { Parcel, NFT } from '../entities/schema'
import { ERC721 } from '../entities/templates'
import { buildCount } from '../modules/count'
import { getNFTId } from '../modules/nft'
import { decodeTokenId, getParcelText } from '../modules/parcel'
import { buildData, DataType } from '../modules/data'
Expand All @@ -15,22 +16,31 @@ import {
CommunityContestCollection,
DCLLaunchCollection,
DCGCollection,
StaySafeCollection,
DCLRegistrar
} from '../data/addresses'
import * as categories from '../modules/category/categories'
import * as addresses from '../data/addresses'

export function handleInitialize(_: InitializeCall): void {
ERC721.create(Address.fromString(LANDRegistry))
ERC721.create(Address.fromString(EstateRegistry))
ERC721.create(Address.fromString(Halloween2019Collection))
ERC721.create(Address.fromString(ExclusiveMasksCollection))
ERC721.create(Address.fromString(Xmas2019Collection))
ERC721.create(Address.fromString(MCHCollection))
ERC721.create(Address.fromString(CommunityContestCollection))
ERC721.create(Address.fromString(DCLLaunchCollection))
ERC721.create(Address.fromString(DCGCollection))
ERC721.create(Address.fromString(DCLRegistrar))
let count = buildCount()

if (count.started == 0) {
ERC721.create(Address.fromString(LANDRegistry))
ERC721.create(Address.fromString(EstateRegistry))
ERC721.create(Address.fromString(Halloween2019Collection))
ERC721.create(Address.fromString(ExclusiveMasksCollection))
ERC721.create(Address.fromString(Xmas2019Collection))
ERC721.create(Address.fromString(MCHCollection))
ERC721.create(Address.fromString(CommunityContestCollection))
ERC721.create(Address.fromString(DCLLaunchCollection))
ERC721.create(Address.fromString(DCGCollection))
ERC721.create(Address.fromString(StaySafeCollection))
ERC721.create(Address.fromString(DCLRegistrar))

count.started = 1
count.save()
}
}

export function handleUpdate(event: Update): void {
Expand Down
3 changes: 2 additions & 1 deletion indexer/src/modules/category/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export function getCategory(contractAddress: string): string {
contractAddress == addresses.MCHCollection ||
contractAddress == addresses.CommunityContestCollection ||
contractAddress == addresses.DCLLaunchCollection ||
contractAddress == addresses.DCGCollection
contractAddress == addresses.DCGCollection ||
contractAddress == addresses.StaySafeCollection
) {
category = categories.WEARABLE
} else if (contractAddress == addresses.DCLRegistrar) {
Expand Down
2 changes: 2 additions & 0 deletions indexer/src/modules/count/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export function buildCount(): Count {
count.wearableXmas2019 = 0

count.ensTotal = 0

count.started = 0
}

return count as Count
Expand Down
15 changes: 9 additions & 6 deletions indexer/src/modules/wearable/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {
community_contest,
dcg_collection,
dcl_launch,
mch_collection,
halloween_2019,
exclusive_masks,
halloween_2019,
mch_collection,
stay_safe,
xmas_2019
} from '../../data/wearables'
import * as categories from '../../data/wearables/categories'
Expand All @@ -28,18 +29,20 @@ export function buildWearableFromNFT(nft: NFT): WearableEntity {
community_contest,
dcg_collection,
dcl_launch,
mch_collection,
halloween_2019,
exclusive_masks,
halloween_2019,
mch_collection,
stay_safe,
xmas_2019
]
let collectionNames: string[] = [
'community_contest',
'dcg_collection',
'dcl_launch',
'mch_collection',
'halloween_2019',
'exclusive_masks',
'halloween_2019',
'mch_collection',
'stay_safe',
'xmas_2019'
]
for (let i = 0; i < allCollections.length; i++) {
Expand Down