add handler for updated projects
This commit is contained in:
parent
fec97a5253
commit
a34cb16d78
Binary file not shown.
|
@ -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)
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue