add handler for updated projects

This commit is contained in:
Barry Gitarts 2019-11-27 12:36:29 -05:00
parent fec97a5253
commit a34cb16d78
4 changed files with 15 additions and 0 deletions

View File

@ -46,6 +46,8 @@ dataSources:
callHandlers:
- function: addProject(string,string,address,uint64,uint64,address)
handler: handleAddProject
- function: updateProject(uint64,address,string,string,uint64)
handler: handleUpdateProject
- function: addGiver(address,string,string,uint64,address)
handler: handleAddGiver
- function: donate(uint64,uint64,address,uint256)

View File

@ -10,6 +10,7 @@ import {
ProjectAdded,
ProjectUpdated,
AddProjectCall,
UpdateProjectCall,
AddGiverCall,
DonateCall,
} from "../generated/Contract/Contract"
@ -52,6 +53,16 @@ export function handleAddProject(call: AddProjectCall): void {
createProjectInfo(content, profile)
}
export function handleUpdateProject(call: UpdateProjectCall): void {
let id = call.inputs.idProject
let content = call.inputs.newUrl
let updatedProfile = Profile.load(id.toHex())
updatedProfile.name = call.inputs.newName
updatedProfile.url = content
updatedProfile.save()
createProjectInfo(content, updatedProfile as Profile)
}
function createProjectInfo(content: String, profile: Profile, isFile: boolean = false): void {
let hash = content.split('/').slice(-1)[0]
let contentHash = isFile ? hash : hash + '/manifest.json'

View File

@ -46,6 +46,8 @@ dataSources:
callHandlers:
- function: addProject(string,string,address,uint64,uint64,address)
handler: handleAddProject
- function: updateProject(uint64,address,string,string,uint64)
handler: handleUpdateProject
- function: addGiver(address,string,string,uint64,address)
handler: handleAddGiver
- function: donate(uint64,uint64,address,uint256)