-
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.
- Loading branch information
1 parent
399de21
commit 1064b3d
Showing
3 changed files
with
157 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,133 @@ | ||
import { BigInt, ethereum } from "@graphprotocol/graph-ts"; | ||
import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; | ||
import { | ||
ClaimAavegotchi, | ||
EquipWearables, | ||
ClaimAavegotchi, | ||
EquipWearables, | ||
Transfer, | ||
} from "../generated/Contract/Contract"; | ||
import { BLOCK_SIDEVIEWS_ACTIVATED } from "./constants"; | ||
import { | ||
AAVEGOTCHI_BRIDGE_VAULT, | ||
BLOCK_SIDEVIEWS_ACTIVATED, | ||
} from "./constants"; | ||
import { updateSideViews, updateSvg } from "./helper"; | ||
|
||
export function handleClaimAavegotchi(event: ClaimAavegotchi): void { | ||
let gotchi = event.block.number.ge(BLOCK_SIDEVIEWS_ACTIVATED) | ||
? updateSideViews(event.params._tokenId) | ||
: updateSvg(event.params._tokenId); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
let gotchi = event.block.number.ge(BLOCK_SIDEVIEWS_ACTIVATED) | ||
? updateSideViews(event.params._tokenId) | ||
: updateSvg(event.params._tokenId); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
|
||
export function handleEquipWearables(event: EquipWearables): void { | ||
let gotchi = event.block.number.ge(BLOCK_SIDEVIEWS_ACTIVATED) | ||
? updateSideViews(event.params._tokenId) | ||
: updateSvg(event.params._tokenId); | ||
if (gotchi != null) { | ||
let gotchi = event.block.number.ge(BLOCK_SIDEVIEWS_ACTIVATED) | ||
? updateSideViews(event.params._tokenId) | ||
: updateSvg(event.params._tokenId); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
|
||
export function handleBlock(block: ethereum.Block): void { | ||
if (block.number == BLOCK_SIDEVIEWS_ACTIVATED) { | ||
for (let i = 0; i <= 2500; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(1)) | ||
) { | ||
for (let i = 2500; i <= 5000; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(2)) | ||
) { | ||
for (let i = 5000; i <= 7500; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(3)) | ||
) { | ||
for (let i = 7500; i <= 10000; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(4)) | ||
) { | ||
for (let i = 10000; i <= 12500; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(5)) | ||
) { | ||
for (let i = 12500; i <= 15000; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(6)) | ||
) { | ||
for (let i = 15000; i <= 17500; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(7)) | ||
) { | ||
for (let i = 17500; i <= 20000; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(8)) | ||
) { | ||
for (let i = 20000; i <= 22500; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(9)) | ||
) { | ||
for (let i = 22500; i <= 25000; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
export function handleBlock(block: ethereum.Block): void { | ||
if (block.number == BLOCK_SIDEVIEWS_ACTIVATED) { | ||
for (let i = 0; i <= 2500; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(1)) | ||
) { | ||
for (let i = 2500; i <= 5000; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(2)) | ||
) { | ||
for (let i = 5000; i <= 7500; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(3)) | ||
) { | ||
for (let i = 7500; i <= 10000; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(4)) | ||
) { | ||
for (let i = 10000; i <= 12500; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(5)) | ||
) { | ||
for (let i = 12500; i <= 15000; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(6)) | ||
) { | ||
for (let i = 15000; i <= 17500; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(7)) | ||
) { | ||
for (let i = 17500; i <= 20000; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(8)) | ||
) { | ||
for (let i = 20000; i <= 22500; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
} else if ( | ||
block.number == BLOCK_SIDEVIEWS_ACTIVATED.plus(BigInt.fromI32(9)) | ||
) { | ||
for (let i = 22500; i <= 25000; i++) { | ||
let gotchi = updateSideViews(BigInt.fromI32(i)); | ||
if (gotchi != null) { | ||
gotchi.save(); | ||
} | ||
} | ||
export function handleTransfer(event: Transfer): void { | ||
if (event.params._from == Address.fromString(AAVEGOTCHI_BRIDGE_VAULT)) { | ||
// - if from is bridge vault, update svg because the equipped wearables may have changed | ||
let gotchi = event.block.number.ge(BLOCK_SIDEVIEWS_ACTIVATED) | ||
? updateSideViews(event.params._tokenId) | ||
: updateSvg(event.params._tokenId); | ||
if (gotchi != null) { | ||
gotchi.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,36 @@ | ||
features: | ||
- grafting | ||
graft: | ||
base: QmeWcqPd2QvWiLsNWRZsiYxwqqBRszTHfsSTXusWf2Z8bA # Subgraph ID of base subgraph | ||
block: 64874170 # Block number | ||
specVersion: 0.0.4 | ||
schema: | ||
file: ./schema.graphql | ||
file: ./schema.graphql | ||
dataSources: | ||
- kind: ethereum/contract | ||
name: Contract | ||
network: matic | ||
source: | ||
address: "0x86935F11C86623deC8a25696E1C19a8659CbF95d" | ||
abi: Contract | ||
startBlock: 39130899 | ||
mapping: | ||
kind: ethereum/events | ||
apiVersion: 0.0.6 | ||
language: wasm/assemblyscript | ||
entities: | ||
- ClaimAavegotchi | ||
- EquipWearables | ||
abis: | ||
- name: Contract | ||
file: ./abis/Contract.json | ||
eventHandlers: | ||
- event: EquipWearables(indexed uint256,uint16[16],uint16[16]) | ||
handler: handleEquipWearables | ||
- event: ClaimAavegotchi(indexed uint256) | ||
handler: handleClaimAavegotchi | ||
blockHandlers: | ||
- handler: handleBlock | ||
file: ./src/mapping.ts | ||
- kind: ethereum/contract | ||
name: Contract | ||
network: matic | ||
source: | ||
address: "0x86935F11C86623deC8a25696E1C19a8659CbF95d" | ||
abi: Contract | ||
startBlock: 39130899 | ||
mapping: | ||
kind: ethereum/events | ||
apiVersion: 0.0.6 | ||
language: wasm/assemblyscript | ||
entities: | ||
- ClaimAavegotchi | ||
- EquipWearables | ||
abis: | ||
- name: Contract | ||
file: ./abis/Contract.json | ||
eventHandlers: | ||
- event: EquipWearables(indexed uint256,uint16[16],uint16[16]) | ||
handler: handleEquipWearables | ||
- event: ClaimAavegotchi(indexed uint256) | ||
handler: handleClaimAavegotchi | ||
- event: Transfer(indexed address,indexed address,indexed uint256) | ||
handler: handleTransfer | ||
blockHandlers: | ||
- handler: handleBlock | ||
file: ./src/mapping.ts |