Commit b3fbd531 authored by vicotor's avatar vicotor

add code

parent 0eb1aaf2
Pipeline #828 canceled with stages
version: "3"
version: '3'
services:
graph-node:
image: graphprotocol/graph-node
#image: graphprotocol/graph-node
image: graph-node:latest
ports:
- "8000:8000"
- "8001:8001"
- "8020:8020"
- "8030:8030"
- "8040:8040"
- '20000:8000'
- '20001:8001'
- '20020:8020'
- '20030:8030'
- '20040:8040'
depends_on:
- ipfs
- postgres
extra_hosts:
- host.docker.internal:host-gateway
- 172.17.0.1:host-gateway
environment:
postgres_host: postgres
postgres_user: graph-node
postgres_pass: let-me-in
postgres_db: graph-node
ipfs: "ipfs:5001"
ethereum: "mainnet:http://host.docker.internal:8545"
ipfs: 'ipfs:5001'
ethereum: 'bsc:https://bsc.bitheart.org'
#ethereum: 'bsc:https://wispy-patient-theorem.bsc.quiknode.pro/577a2765b52de53ff763d821575dfe74d96a5fe2'
GRAPH_LOG: info
ipfs:
image: ipfs/kubo:v0.17.0
ports:
- "5001:5001"
- '25001:5001'
volumes:
- ./data/ipfs:/data/ipfs
- ./data/ipfs:/data/ipfs:Z
postgres:
image: postgres:14
image: postgres
ports:
- "5432:5432"
- '20432:5432'
command:
[
"postgres",
"-cshared_preload_libraries=pg_stat_statements",
"-cmax_connections=200",
"-cmax_connections=200"
]
environment:
POSTGRES_USER: graph-node
......@@ -47,4 +49,4 @@ services:
PGDATA: "/var/lib/postgresql/data"
POSTGRES_INITDB_ARGS: "-E UTF8 --locale=C"
volumes:
- ./data/postgres:/var/lib/postgresql/data
- ./data/postgres:/var/lib/postgresql/data:Z
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -4,7 +4,7 @@
"scripts": {
"codegen": "graph codegen",
"build": "graph build",
"deploy": "graph deploy --node http://127.0.0.1:50020 polygon/nft-mint-test",
"deploy": "graph deploy --node http://127.0.0.1:30020 polygon/nft-mint-test",
"create-local": "graph create --node http://localhost:8020/ polygon/nft-mint-test",
"remove-local": "graph remove --node http://localhost:8020/ polygon/nft-mint-test",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 polygon/nft-mint-test",
......
......@@ -8,6 +8,18 @@ type Transfer @entity(immutable: true) {
transactionHash: Bytes!
}
type Minted @entity(immutable: true) {
id: Bytes!
from: Bytes! # address
to: Bytes! # address
tokenId: BigInt! # uint256
blockNumber: BigInt!
blockTimestamp: BigInt!
transactionHash: Bytes!
sortHash: Bytes! # address
sortIndex: BigInt! # uint256
}
type Approval @entity(immutable: true) {
id: Bytes!
owner: Bytes! # address
......
......@@ -3,12 +3,18 @@ import {
Approval as ApprovalEvent,
ApprovalForAll as ApprovalForAllEvent
} from "../generated/Drago/Drago"
import { Transfer, Approval, ApprovalForAll } from "../generated/schema"
import { Transfer, Approval, ApprovalForAll, Minted } from "../generated/schema"
import {
store,
Bytes,
BigInt,
} from "@graphprotocol/graph-ts";
export function handleTransfer(event: TransferEvent): void {
let entity = new Transfer(
event.transaction.hash.concatI32(event.logIndex.toI32())
)
entity.from = event.params.from
entity.to = event.params.to
entity.tokenId = event.params.tokenId
......@@ -18,6 +24,27 @@ export function handleTransfer(event: TransferEvent): void {
entity.transactionHash = event.transaction.hash
entity.save()
if (event.params.from.toHexString() == "0x0000000000000000000000000000000000000000") {
// Mint
let mintEntity = new Minted(
event.transaction.hash.concatI32(event.logIndex.toI32())
)
mintEntity.from = event.params.from
mintEntity.to = event.params.to
mintEntity.tokenId = event.params.tokenId
mintEntity.blockNumber = event.block.number
mintEntity.blockTimestamp = event.block.timestamp
mintEntity.transactionHash = event.transaction.hash
// set new fields.
// set sort to transaction hash latest 6 bytes.
mintEntity.sortHash = Bytes.fromHexString(event.transaction.hash.toHexString().slice(-12))
mintEntity.sortIndex = event.logIndex
mintEntity.save()
}
}
export function handleApproval(event: ApprovalEvent): void {
......
#!/bin/bash
graph deploy klk-mint-bsc --node http://172.17.0.1:30020 --ipfs http://172.17.0.1:35001
......@@ -6,11 +6,11 @@ schema:
dataSources:
- kind: ethereum
name: Drago
network: polygonmainnet
network: bsc
source:
address: "0x9E8Ea82e76262E957D4cC24e04857A34B0D8f062"
address: "0xa68C9DF9f8e27e0BDDfC27Ffd2AE21734D8e429a"
abi: Drago
startBlock: 66900000
startBlock: 46161100
mapping:
kind: ethereum/events
apiVersion: 0.0.7
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment