Skip to content

New feat/index profile #23

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Binary file modified build/LensHub/LensHub.wasm
Binary file not shown.
Binary file not shown.
29 changes: 5 additions & 24 deletions build/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
type ExampleEntity @entity {
id: ID!
count: BigInt!
previousAdmin: Bytes! # address
newAdmin: Bytes! # address
}

type Approval @entity {
id: ID!
owner: Bytes! # address
Expand Down Expand Up @@ -129,12 +122,12 @@ type Profile @entity {
coverPicture: ProfileMedia
onwnedBy: String!
dispatcher: Dispatcher
stats: ProfileStats!
stats: ProfileStats
followModule: FollowModule
isDefault: Boolean!
isDefault: Boolean
attributes: [Attribute!]
isFollowedByMe: Boolean!
isFollowingMe: Boolean!
isFollowedByMe: Boolean
isFollowingMe: Boolean
}

enum ReactionTypes {
Expand Down Expand Up @@ -181,20 +174,13 @@ type MetadataOutput @entity {
attributes: [MetadataAttributeOutput!]!
}

union MainPostReference = Post | Mirror


type ReactionFieldResolverRequest @entity {
id: ID!
profileId: BigInt
}

union CollectModule =
FreeCollectModuleSettings
| FeeCollectModuleSettings
| LimitedFeeCollectModuleSettings
| LimitedTimedFeeCollectModuleSettings
| RevertCollectModuleSettings
| TimedFeeCollectModuleSettings

enum CollectModules {
LimitedFeeCollectModule
Expand Down Expand Up @@ -262,10 +248,6 @@ type TimedFeeCollectModuleSettings @entity {
endTimestamp: String!
}

union MirrorablePublication = Post

union ReferenceModule = FollowOnlyReferenceModuleSettings

enum ReferenceModules {
FollowOnlyReferenceModule
}
Expand Down Expand Up @@ -306,4 +288,3 @@ type Post @entity {
mirrors: [ID!]!
}

union Publication = Post | Mirror
43 changes: 5 additions & 38 deletions build/subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,22 @@ dataSources:
name: LensHub
network: matic
source:
address: "0x20f4D7DdeE23029048C53B42dc73A02De19F1c9E"
address: "0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d"
abi: LensHub
startBlock: 30068251
startBlock: 28384641
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- Approval
- ApprovalForAll
- Transfer
- Profile
- AdminChanged
- BeaconUpgraded
- Upgraded
abis:
- name: LensHub
file: LensHub/abis/LensHub.json
eventHandlers:
- event: Approval(indexed address,indexed address,indexed uint256)
handler: handleApproval
- event: ApprovalForAll(indexed address,indexed address,bool)
handler: handleApprovalForAll
- event: Transfer(indexed address,indexed address,indexed uint256)
handler: handleTransfer
- event: ProfileCreated(indexed uint256,indexed address,indexed
address,string,string,address,bytes,string,uint256)
handler: handleProfileCreated
file: LensHub/LensHub.wasm
- kind: ethereum
name: TransparentUpgradeableProxy
network: matic
source:
address: "0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d"
abi: TransparentUpgradeableProxy
startBlock: 28384641
mapping:
kind: ethereum/events
apiVersion: 0.0.5
language: wasm/assemblyscript
entities:
- AdminChanged
- BeaconUpgraded
- Upgraded
abis:
- name: TransparentUpgradeableProxy
file: TransparentUpgradeableProxy/abis/TransparentUpgradeableProxy.json
eventHandlers:
- event: AdminChanged(address,address)
handler: handleAdminChanged
- event: BeaconUpgraded(indexed address)
handler: handleBeaconUpgraded
- event: Upgraded(indexed address)
handler: handleUpgraded
file: TransparentUpgradeableProxy/TransparentUpgradeableProxy.wasm
75 changes: 12 additions & 63 deletions generated/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,6 @@ import {
BigDecimal
} from "@graphprotocol/graph-ts";

export class ExampleEntity extends Entity {
constructor(id: string) {
super();
this.set("id", Value.fromString(id));
}

save(): void {
let id = this.get("id");
assert(id != null, "Cannot save ExampleEntity entity without an ID");
if (id) {
assert(
id.kind == ValueKind.STRING,
`Entities of type ExampleEntity must have an ID of type String but the id '${id.displayData()}' is of type ${id.displayKind()}`
);
store.set("ExampleEntity", id.toString(), this);
}
}

static load(id: string): ExampleEntity | null {
return changetype<ExampleEntity | null>(store.get("ExampleEntity", id));
}

get id(): string {
let value = this.get("id");
return value!.toString();
}

set id(value: string) {
this.set("id", Value.fromString(value));
}

get count(): BigInt {
let value = this.get("count");
return value!.toBigInt();
}

set count(value: BigInt) {
this.set("count", Value.fromBigInt(value));
}

get previousAdmin(): Bytes {
let value = this.get("previousAdmin");
return value!.toBytes();
}

set previousAdmin(value: Bytes) {
this.set("previousAdmin", Value.fromBytes(value));
}

get newAdmin(): Bytes {
let value = this.get("newAdmin");
return value!.toBytes();
}

set newAdmin(value: Bytes) {
this.set("newAdmin", Value.fromBytes(value));
}
}

export class Approval extends Entity {
constructor(id: string) {
super();
Expand Down Expand Up @@ -1179,13 +1120,21 @@ export class Profile extends Entity {
}
}

get stats(): string {
get stats(): string | null {
let value = this.get("stats");
return value!.toString();
if (!value || value.kind == ValueKind.NULL) {
return null;
} else {
return value.toString();
}
}

set stats(value: string) {
this.set("stats", Value.fromString(value));
set stats(value: string | null) {
if (!value) {
this.unset("stats");
} else {
this.set("stats", Value.fromString(<string>value));
}
}

get followModule(): string | null {
Expand Down
49 changes: 26 additions & 23 deletions schema.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
type ExampleEntity @entity {
id: ID!
count: BigInt!
previousAdmin: Bytes! # address
newAdmin: Bytes! # address
}

type Approval @entity {
id: ID!
owner: Bytes! # address
Expand Down Expand Up @@ -129,12 +122,12 @@ type Profile @entity {
coverPicture: ProfileMedia
onwnedBy: String!
dispatcher: Dispatcher
stats: ProfileStats!
stats: ProfileStats
followModule: FollowModule
isDefault: Boolean!
isDefault: Boolean
attributes: [Attribute!]
isFollowedByMe: Boolean!
isFollowingMe: Boolean!
isFollowedByMe: Boolean
isFollowingMe: Boolean
}

enum ReactionTypes {
Expand Down Expand Up @@ -181,14 +174,13 @@ type MetadataOutput @entity {
attributes: [MetadataAttributeOutput!]!
}

union MainPostReference = Post | Mirror


type ReactionFieldResolverRequest @entity {
id: ID!
profileId: BigInt
}

union CollectModule = FreeCollectModuleSettings | FeeCollectModuleSettings | LimitedFeeCollectModuleSettings | LimitedTimedFeeCollectModuleSettings | RevertCollectModuleSettings | TimedFeeCollectModuleSettings

enum CollectModules {
LimitedFeeCollectModule
Expand Down Expand Up @@ -256,10 +248,6 @@ type TimedFeeCollectModuleSettings @entity {
endTimestamp: String!
}

union MirrorablePublication = Post

union ReferenceModule = FollowOnlyReferenceModuleSettings

enum ReferenceModules {
FollowOnlyReferenceModule
}
Expand All @@ -277,12 +265,9 @@ type Mirror @entity {
metadata: MetadataOutput!
onChainContentURI: String!
createdAt: String!
collectModule: CollectModule!
referenceModule: ReferenceModule!
appId: BigInt
hidden: Boolean!
collectNftAddress: String
mirrorOf: MirrorablePublication!
reaction: ReactionTypes
hasCollectedByMe: Boolean!
}
Expand All @@ -294,8 +279,6 @@ type Post @entity {
metadata: MetadataOutput!
onChainContentURI: String!
createdAt: String!
collectModule: CollectModule!
referenceModule: ReferenceModule
appId: String
hidden: Boolean!
collectNftAddress: String
Expand All @@ -305,4 +288,24 @@ type Post @entity {
mirrors: [ID!]!
}

union Publication = Post | Mirror
type Comment @entity{
id: ID!
profile: Profile!
stats: PublicationStats!
metadata: MetadataOutput!
onChainContentURI: String!
createdAt: String!
collectModule: CollectModule!
referenceModule: ReferenceModule!
appId: String!
hidden: Boolean!
collectNftAddress:contractAddress!
mainPost:MainPostReference!
commentOn:Publication
firstComment:Comment
collectedBy:Wallet
reaction:ReactionTypes
hasCollectedByMe: Boolean!
mirrors:[ID!]!
}

2 changes: 2 additions & 0 deletions src/lens-hub.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { log } from "@graphprotocol/graph-ts";
import {
Approval as ApprovalEvent,
ApprovalForAll as ApprovalForAllEvent,
Expand Down Expand Up @@ -38,6 +39,7 @@ export function handleTransfer(event: TransferEvent): void {

export function handleProfileCreated(event: ProfileCreated): void {
let profile = Profile.load(event.params.profileId.toString())
log.info("Trigger Fired", [])

if(!profile) {
profile = new Profile(event.params.profileId.toString())
Expand Down
Loading