Skip to content

Commit 234b226

Browse files
committed
Initial commit
0 parents  commit 234b226

9 files changed

+509
-0
lines changed

abis/Web3RSVP.json

+168
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
[
2+
{
3+
"anonymous": false,
4+
"inputs": [
5+
{
6+
"indexed": false,
7+
"internalType": "bytes32",
8+
"name": "eventId",
9+
"type": "bytes32"
10+
},
11+
{
12+
"indexed": false,
13+
"internalType": "address",
14+
"name": "attendeeAddress",
15+
"type": "address"
16+
}
17+
],
18+
"name": "ConfirmedAttendee",
19+
"type": "event"
20+
},
21+
{
22+
"anonymous": false,
23+
"inputs": [
24+
{
25+
"indexed": false,
26+
"internalType": "bytes32",
27+
"name": "eventId",
28+
"type": "bytes32"
29+
}
30+
],
31+
"name": "DepositsPaidOut",
32+
"type": "event"
33+
},
34+
{
35+
"anonymous": false,
36+
"inputs": [
37+
{
38+
"indexed": false,
39+
"internalType": "bytes32",
40+
"name": "eventId",
41+
"type": "bytes32"
42+
},
43+
{
44+
"indexed": false,
45+
"internalType": "address",
46+
"name": "creatorAddress",
47+
"type": "address"
48+
},
49+
{
50+
"indexed": false,
51+
"internalType": "uint256",
52+
"name": "eventTimestamp",
53+
"type": "uint256"
54+
},
55+
{
56+
"indexed": false,
57+
"internalType": "uint256",
58+
"name": "maxCapacity",
59+
"type": "uint256"
60+
},
61+
{
62+
"indexed": false,
63+
"internalType": "uint256",
64+
"name": "deposit",
65+
"type": "uint256"
66+
},
67+
{
68+
"indexed": false,
69+
"internalType": "string",
70+
"name": "eventDataCID",
71+
"type": "string"
72+
}
73+
],
74+
"name": "NewEventCreated",
75+
"type": "event"
76+
},
77+
{
78+
"anonymous": false,
79+
"inputs": [
80+
{
81+
"indexed": false,
82+
"internalType": "bytes32",
83+
"name": "eventId",
84+
"type": "bytes32"
85+
},
86+
{
87+
"indexed": false,
88+
"internalType": "address",
89+
"name": "attendeeAddress",
90+
"type": "address"
91+
}
92+
],
93+
"name": "NewRSVP",
94+
"type": "event"
95+
},
96+
{
97+
"inputs": [
98+
{ "internalType": "bytes32", "name": "eventId", "type": "bytes32" }
99+
],
100+
"name": "confirmAllAttendees",
101+
"outputs": [],
102+
"stateMutability": "nonpayable",
103+
"type": "function"
104+
},
105+
{
106+
"inputs": [
107+
{ "internalType": "bytes32", "name": "eventId", "type": "bytes32" },
108+
{ "internalType": "address", "name": "attendee", "type": "address" }
109+
],
110+
"name": "confirmAttendee",
111+
"outputs": [],
112+
"stateMutability": "nonpayable",
113+
"type": "function"
114+
},
115+
{
116+
"inputs": [
117+
{
118+
"internalType": "uint256",
119+
"name": "eventTimestamp",
120+
"type": "uint256"
121+
},
122+
{ "internalType": "uint256", "name": "deposit", "type": "uint256" },
123+
{ "internalType": "uint256", "name": "maxCapacity", "type": "uint256" },
124+
{ "internalType": "string", "name": "eventDataCID", "type": "string" }
125+
],
126+
"name": "createNewEvent",
127+
"outputs": [],
128+
"stateMutability": "nonpayable",
129+
"type": "function"
130+
},
131+
{
132+
"inputs": [
133+
{ "internalType": "bytes32", "name": "eventId", "type": "bytes32" }
134+
],
135+
"name": "createNewRSVP",
136+
"outputs": [],
137+
"stateMutability": "payable",
138+
"type": "function"
139+
},
140+
{
141+
"inputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }],
142+
"name": "idToEvent",
143+
"outputs": [
144+
{ "internalType": "bytes32", "name": "eventId", "type": "bytes32" },
145+
{ "internalType": "string", "name": "eventDataCID", "type": "string" },
146+
{ "internalType": "address", "name": "eventOwner", "type": "address" },
147+
{
148+
"internalType": "uint256",
149+
"name": "eventTimestamp",
150+
"type": "uint256"
151+
},
152+
{ "internalType": "uint256", "name": "deposit", "type": "uint256" },
153+
{ "internalType": "uint256", "name": "maxCapacity", "type": "uint256" },
154+
{ "internalType": "bool", "name": "paidOut", "type": "bool" }
155+
],
156+
"stateMutability": "view",
157+
"type": "function"
158+
},
159+
{
160+
"inputs": [
161+
{ "internalType": "bytes32", "name": "eventId", "type": "bytes32" }
162+
],
163+
"name": "withdrawUnclaimedDeposits",
164+
"outputs": [],
165+
"stateMutability": "nonpayable",
166+
"type": "function"
167+
}
168+
]

networks.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"mumbai": {
3+
"Web3RSVP": {
4+
"address": "0x805dD2181E8d5e3a07E0D1e9dc0B16F05aCAa008",
5+
"startBlock": 44154525
6+
}
7+
}
8+
}

package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "brb-subgraph",
3+
"license": "UNLICENSED",
4+
"scripts": {
5+
"codegen": "graph codegen",
6+
"build": "graph build",
7+
"deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ brb-subgraph",
8+
"create-local": "graph create --node http://localhost:8020/ brb-subgraph",
9+
"remove-local": "graph remove --node http://localhost:8020/ brb-subgraph",
10+
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 brb-subgraph",
11+
"test": "graph test"
12+
},
13+
"dependencies": {
14+
"@graphprotocol/graph-cli": "0.64.1",
15+
"@graphprotocol/graph-ts": "0.32.0"
16+
},
17+
"devDependencies": { "matchstick-as": "0.5.0" }
18+
}

schema.graphql

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
type ConfirmedAttendee @entity(immutable: true) {
2+
id: Bytes!
3+
eventId: Bytes! # bytes32
4+
attendeeAddress: Bytes! # address
5+
blockNumber: BigInt!
6+
blockTimestamp: BigInt!
7+
transactionHash: Bytes!
8+
}
9+
10+
type DepositsPaidOut @entity(immutable: true) {
11+
id: Bytes!
12+
eventId: Bytes! # bytes32
13+
blockNumber: BigInt!
14+
blockTimestamp: BigInt!
15+
transactionHash: Bytes!
16+
}
17+
18+
type NewEventCreated @entity(immutable: true) {
19+
id: Bytes!
20+
eventId: Bytes! # bytes32
21+
creatorAddress: Bytes! # address
22+
eventTimestamp: BigInt! # uint256
23+
maxCapacity: BigInt! # uint256
24+
deposit: BigInt! # uint256
25+
eventDataCID: String! # string
26+
blockNumber: BigInt!
27+
blockTimestamp: BigInt!
28+
transactionHash: Bytes!
29+
}
30+
31+
type NewRSVP @entity(immutable: true) {
32+
id: Bytes!
33+
eventId: Bytes! # bytes32
34+
attendeeAddress: Bytes! # address
35+
blockNumber: BigInt!
36+
blockTimestamp: BigInt!
37+
transactionHash: Bytes!
38+
}

src/web-3-rsvp.ts

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import {
2+
ConfirmedAttendee as ConfirmedAttendeeEvent,
3+
DepositsPaidOut as DepositsPaidOutEvent,
4+
NewEventCreated as NewEventCreatedEvent,
5+
NewRSVP as NewRSVPEvent
6+
} from "../generated/Web3RSVP/Web3RSVP"
7+
import {
8+
ConfirmedAttendee,
9+
DepositsPaidOut,
10+
NewEventCreated,
11+
NewRSVP
12+
} from "../generated/schema"
13+
14+
export function handleConfirmedAttendee(event: ConfirmedAttendeeEvent): void {
15+
let entity = new ConfirmedAttendee(
16+
event.transaction.hash.concatI32(event.logIndex.toI32())
17+
)
18+
entity.eventId = event.params.eventId
19+
entity.attendeeAddress = event.params.attendeeAddress
20+
21+
entity.blockNumber = event.block.number
22+
entity.blockTimestamp = event.block.timestamp
23+
entity.transactionHash = event.transaction.hash
24+
25+
entity.save()
26+
}
27+
28+
export function handleDepositsPaidOut(event: DepositsPaidOutEvent): void {
29+
let entity = new DepositsPaidOut(
30+
event.transaction.hash.concatI32(event.logIndex.toI32())
31+
)
32+
entity.eventId = event.params.eventId
33+
34+
entity.blockNumber = event.block.number
35+
entity.blockTimestamp = event.block.timestamp
36+
entity.transactionHash = event.transaction.hash
37+
38+
entity.save()
39+
}
40+
41+
export function handleNewEventCreated(event: NewEventCreatedEvent): void {
42+
let entity = new NewEventCreated(
43+
event.transaction.hash.concatI32(event.logIndex.toI32())
44+
)
45+
entity.eventId = event.params.eventId
46+
entity.creatorAddress = event.params.creatorAddress
47+
entity.eventTimestamp = event.params.eventTimestamp
48+
entity.maxCapacity = event.params.maxCapacity
49+
entity.deposit = event.params.deposit
50+
entity.eventDataCID = event.params.eventDataCID
51+
52+
entity.blockNumber = event.block.number
53+
entity.blockTimestamp = event.block.timestamp
54+
entity.transactionHash = event.transaction.hash
55+
56+
entity.save()
57+
}
58+
59+
export function handleNewRSVP(event: NewRSVPEvent): void {
60+
let entity = new NewRSVP(
61+
event.transaction.hash.concatI32(event.logIndex.toI32())
62+
)
63+
entity.eventId = event.params.eventId
64+
entity.attendeeAddress = event.params.attendeeAddress
65+
66+
entity.blockNumber = event.block.number
67+
entity.blockTimestamp = event.block.timestamp
68+
entity.transactionHash = event.transaction.hash
69+
70+
entity.save()
71+
}

subgraph.yaml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
specVersion: 0.0.5
2+
schema:
3+
file: ./schema.graphql
4+
dataSources:
5+
- kind: ethereum
6+
name: Web3RSVP
7+
network: mumbai
8+
source:
9+
address: "0x805dD2181E8d5e3a07E0D1e9dc0B16F05aCAa008"
10+
abi: Web3RSVP
11+
startBlock: 44154525
12+
mapping:
13+
kind: ethereum/events
14+
apiVersion: 0.0.7
15+
language: wasm/assemblyscript
16+
entities:
17+
- ConfirmedAttendee
18+
- DepositsPaidOut
19+
- NewEventCreated
20+
- NewRSVP
21+
abis:
22+
- name: Web3RSVP
23+
file: ./abis/Web3RSVP.json
24+
eventHandlers:
25+
- event: ConfirmedAttendee(bytes32,address)
26+
handler: handleConfirmedAttendee
27+
- event: DepositsPaidOut(bytes32)
28+
handler: handleDepositsPaidOut
29+
- event: NewEventCreated(bytes32,address,uint256,uint256,uint256,string)
30+
handler: handleNewEventCreated
31+
- event: NewRSVP(bytes32,address)
32+
handler: handleNewRSVP
33+
file: ./src/web-3-rsvp.ts

0 commit comments

Comments
 (0)