diff --git a/build/LensHub/LensHub.wasm b/build/LensHub/LensHub.wasm index d5b2440..d0d085b 100644 Binary files a/build/LensHub/LensHub.wasm and b/build/LensHub/LensHub.wasm differ diff --git a/build/TransparentUpgradeableProxy/TransparentUpgradeableProxy.wasm b/build/TransparentUpgradeableProxy/TransparentUpgradeableProxy.wasm index 43e1985..935c51e 100644 Binary files a/build/TransparentUpgradeableProxy/TransparentUpgradeableProxy.wasm and b/build/TransparentUpgradeableProxy/TransparentUpgradeableProxy.wasm differ diff --git a/build/schema.graphql b/build/schema.graphql index d3aeae2..bb519c0 100644 --- a/build/schema.graphql +++ b/build/schema.graphql @@ -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 @@ -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 { @@ -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 @@ -262,10 +248,6 @@ type TimedFeeCollectModuleSettings @entity { endTimestamp: String! } -union MirrorablePublication = Post - -union ReferenceModule = FollowOnlyReferenceModuleSettings - enum ReferenceModules { FollowOnlyReferenceModule } @@ -306,4 +288,3 @@ type Post @entity { mirrors: [ID!]! } -union Publication = Post | Mirror diff --git a/build/subgraph.yaml b/build/subgraph.yaml index 08eb826..7210a15 100644 --- a/build/subgraph.yaml +++ b/build/subgraph.yaml @@ -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 diff --git a/generated/schema.ts b/generated/schema.ts index 709949d..63faf3c 100644 --- a/generated/schema.ts +++ b/generated/schema.ts @@ -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(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(); @@ -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(value)); + } } get followModule(): string | null { diff --git a/schema.graphql b/schema.graphql index f6b860f..5cc99d4 100644 --- a/schema.graphql +++ b/schema.graphql @@ -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 @@ -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 { @@ -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 @@ -256,10 +248,6 @@ type TimedFeeCollectModuleSettings @entity { endTimestamp: String! } -union MirrorablePublication = Post - -union ReferenceModule = FollowOnlyReferenceModuleSettings - enum ReferenceModules { FollowOnlyReferenceModule } @@ -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! } @@ -294,8 +279,6 @@ type Post @entity { metadata: MetadataOutput! onChainContentURI: String! createdAt: String! - collectModule: CollectModule! - referenceModule: ReferenceModule appId: String hidden: Boolean! collectNftAddress: String @@ -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!]! +} + diff --git a/src/lens-hub.ts b/src/lens-hub.ts index 73448e2..812666b 100644 --- a/src/lens-hub.ts +++ b/src/lens-hub.ts @@ -1,3 +1,4 @@ +import { log } from "@graphprotocol/graph-ts"; import { Approval as ApprovalEvent, ApprovalForAll as ApprovalForAllEvent, @@ -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()) diff --git a/src/transparent-upgradeable-proxy.ts b/src/transparent-upgradeable-proxy.ts index 6915d81..758ee44 100644 --- a/src/transparent-upgradeable-proxy.ts +++ b/src/transparent-upgradeable-proxy.ts @@ -7,48 +7,48 @@ import { } from "../generated/TransparentUpgradeableProxy/TransparentUpgradeableProxy" import { ExampleEntity } from "../generated/schema" -export function handleAdminChanged(event: AdminChanged): void { - // Entities can be loaded from the store using a string ID; this ID - // needs to be unique across all entities of the same type - let entity = ExampleEntity.load(event.transaction.from.toHex()) - - // Entities only exist after they have been saved to the store; - // `null` checks allow to create entities on demand - if (!entity) { - entity = new ExampleEntity(event.transaction.from.toHex()) - - // Entity fields can be set using simple assignments - entity.count = BigInt.fromI32(0) - } - - // BigInt and BigDecimal math are supported - entity.count = entity.count + BigInt.fromI32(1) - - // Entity fields can be set based on event parameters - entity.previousAdmin = event.params.previousAdmin - entity.newAdmin = event.params.newAdmin - - // Entities can be written to the store with `.save()` - entity.save() - - // Note: If a handler doesn't require existing field values, it is faster - // _not_ to load the entity from the store. Instead, create it fresh with - // `new Entity(...)`, set the fields that should be updated and save the - // entity back to the store. Fields that were not set or unset remain - // unchanged, allowing for partial updates to be applied. - - // It is also possible to access smart contracts from mappings. For - // example, the contract that has emitted the event can be connected to - // with: - // - // let contract = Contract.bind(event.address) - // - // The following functions can then be called on this contract to access - // state variables and other data: - // - // - contract.admin(...) - // - contract.implementation(...) -} +// export function handleAdminChanged(event: AdminChanged): void { +// // Entities can be loaded from the store using a string ID; this ID +// // needs to be unique across all entities of the same type +// let entity = ExampleEntity.load(event.transaction.from.toHex()) + +// // Entities only exist after they have been saved to the store; +// // `null` checks allow to create entities on demand +// if (!entity) { +// entity = new ExampleEntity(event.transaction.from.toHex()) + +// // Entity fields can be set using simple assignments +// entity.count = BigInt.fromI32(0) +// } + +// // BigInt and BigDecimal math are supported +// entity.count = entity.count + BigInt.fromI32(1) + +// // Entity fields can be set based on event parameters +// entity.previousAdmin = event.params.previousAdmin +// entity.newAdmin = event.params.newAdmin + +// // Entities can be written to the store with `.save()` +// entity.save() + +// // Note: If a handler doesn't require existing field values, it is faster +// // _not_ to load the entity from the store. Instead, create it fresh with +// // `new Entity(...)`, set the fields that should be updated and save the +// // entity back to the store. Fields that were not set or unset remain +// // unchanged, allowing for partial updates to be applied. + +// // It is also possible to access smart contracts from mappings. For +// // example, the contract that has emitted the event can be connected to +// // with: +// // +// // let contract = Contract.bind(event.address) +// // +// // The following functions can then be called on this contract to access +// // state variables and other data: +// // +// // - contract.admin(...) +// // - contract.implementation(...) +// } export function handleBeaconUpgraded(event: BeaconUpgraded): void {} diff --git a/subgraph.yaml b/subgraph.yaml index 533a7ce..36c0e3b 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -2,58 +2,60 @@ specVersion: 0.0.5 schema: file: ./schema.graphql dataSources: + # - kind: ethereum + # name: LensHub + # network: matic + # source: + # address: "0x20f4D7DdeE23029048C53B42dc73A02De19F1c9E" + # abi: LensHub + # startBlock: 30068251 + # mapping: + # kind: ethereum/events + # apiVersion: 0.0.5 + # language: wasm/assemblyscript + # entities: + # - Approval + # - ApprovalForAll + # - Transfer + # - Profile + # abis: + # - name: LensHub + # file: ./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: ./src/lens-hub.ts - kind: ethereum 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: ./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: AdminChanged(address,address) + # handler: handleAdminChanged + # - event: BeaconUpgraded(indexed address) + # handler: handleBeaconUpgraded + # - event: Upgraded(indexed address) + # handler: handleUpgraded - event: ProfileCreated(indexed uint256,indexed address,indexed address,string,string,address,bytes,string,uint256) handler: handleProfileCreated file: ./src/lens-hub.ts - - 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: ./abis/TransparentUpgradeableProxy.json - eventHandlers: - - event: AdminChanged(address,address) - handler: handleAdminChanged - - event: BeaconUpgraded(indexed address) - handler: handleBeaconUpgraded - - event: Upgraded(indexed address) - handler: handleUpgraded - file: ./src/transparent-upgradeable-proxy.ts