generated from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
7 changed files
with
2,549 additions
and
2,958 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ node_modules | |
graph-node | ||
data | ||
bin | ||
types | ||
types | ||
tests |
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,25 +1,24 @@ | ||
{ | ||
"sepolia": { | ||
"LoogieAuction": { | ||
"address": "0x210b3B8cc13720cCbb8208Ab4d328Ff488E49112", | ||
"startBlock": 5539160 | ||
}, | ||
"localhost": { | ||
"Loogie": { | ||
"address": "0x83296AFF01553E6386fAe17d50118E0659f82678" | ||
"address": "0x67d269191c92Caf3cD7723F116c85e6E9bf55933" | ||
}, | ||
"LoogieAuction": { | ||
"address": "0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E" | ||
}, | ||
"WETH": { | ||
"address": "0xf7d541135a61b54BD2F79acD7cB1b2223dC9EB8F" | ||
"address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" | ||
} | ||
}, | ||
"localhost": { | ||
"sepolia": { | ||
"Loogie": { | ||
"address": "0x5FbDB2315678afecb367f032d93F642f64180aa3" | ||
"address": "0x3012Ba8bA56842EC99509f014ac2BC5866e6c4D4" | ||
}, | ||
"LoogieAuction": { | ||
"address": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" | ||
"address": "0xa126F5924B6D1E50F536F77502c95eEE9365A574" | ||
}, | ||
"WETH": { | ||
"address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512" | ||
"address": "0xf7d541135a61b54BD2F79acD7cB1b2223dC9EB8F" | ||
} | ||
} | ||
} | ||
} |
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,56 @@ | ||
import { LoogieCreated, Transfer, LoogieBurned } from "../types/Loogie/Loogie"; | ||
import { Loogie, TransferEvent } from "../types/schema"; | ||
import { getOrCreateAccount } from "../util/helper"; | ||
import { log } from "@graphprotocol/graph-ts"; | ||
import { BIGINT_ONE, BIGINT_ZERO } from "../util/constants"; | ||
|
||
export function handleCreatedLoogie(event: LoogieCreated): void { | ||
let loogieId = event.params.tokenId.toString(); | ||
let loogie = new Loogie(loogieId); | ||
loogie.chubbiness = event.params.chubbiness; | ||
loogie.color = event.params.color; | ||
loogie.mouthLength = event.params.mouthLength; | ||
loogie.owner = getOrCreateAccount(event.params.minter.toHexString()).id; | ||
|
||
loogie.save(); | ||
} | ||
|
||
export function handleBurnedLoogie(event: LoogieBurned): void { | ||
let loogieId = event.params.tokenId.toString(); | ||
let loogie = Loogie.load(loogieId); | ||
if (loogie == null) { | ||
log.error("[handleBurnedLoogie] Loogie #{} not found. Hash: {}", [ | ||
loogieId, | ||
event.transaction.hash.toHex(), | ||
]); | ||
return; | ||
} | ||
loogie.unset(loogieId); | ||
} | ||
export function handleTransfer(event: Transfer): void { | ||
// Get the sender and receiver accounts | ||
let fromAccount = getOrCreateAccount(event.params.from.toHexString()); | ||
let toAccount = getOrCreateAccount(event.params.to.toHexString()); | ||
// Get the transferred Loogie ID | ||
let transferredLoogieId = event.params.tokenId.toString(); | ||
// Create a new TransferEvent entity | ||
let transferEvent = new TransferEvent( | ||
event.transaction.hash.toHexString() + "_" + transferredLoogieId | ||
); | ||
transferEvent.blockNumber = event.block.number; | ||
transferEvent.blockTimestamp = event.block.timestamp; | ||
transferEvent.loogie = transferredLoogieId; | ||
transferEvent.previousHolder = fromAccount.id; | ||
transferEvent.newHolder = toAccount.id; | ||
transferEvent.save(); | ||
|
||
if (fromAccount.tokenBalance < BIGINT_ZERO) { | ||
log.error("Negative balance on holder {} with balance {}", [ | ||
fromAccount.id, | ||
fromAccount.tokenBalance.toString(), | ||
]); | ||
} | ||
|
||
fromAccount.tokenBalance = fromAccount.tokenBalance.minus(BIGINT_ONE); | ||
toAccount.tokenBalance = toAccount.tokenBalance.plus(BIGINT_ONE); | ||
} |
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
Oops, something went wrong.