@@ -24,6 +24,7 @@ import {
24
24
DGApplicationData ,
25
25
DGTimeStampUpdatedData ,
26
26
DVMDApplicationData ,
27
+ DVMDExtendedApplicationData ,
27
28
DVMDTimeStampUpdatedData ,
28
29
} from "../../types.js" ;
29
30
import { fetchPoolMetadata } from "./poolMetadata.js" ;
@@ -79,7 +80,9 @@ function getProjectTypeFromMetadata(metadata: ProjectMetadata) {
79
80
}
80
81
81
82
// Decode the application data from DonationVotingMerkleDistribution
82
- function decodeDVMDApplicationData ( encodedData : Hex ) : DVMDApplicationData {
83
+ function decodeDVMDExtendedApplicationData (
84
+ encodedData : Hex
85
+ ) : DVMDExtendedApplicationData {
83
86
const values = decodeAbiParameters (
84
87
[
85
88
{ name : "data" , type : "bytes" } ,
@@ -88,6 +91,15 @@ function decodeDVMDApplicationData(encodedData: Hex): DVMDApplicationData {
88
91
encodedData
89
92
) ;
90
93
94
+ const encodededDVMD = decodeDVMDApplicationData ( values [ 0 ] ) ;
95
+
96
+ return {
97
+ ...encodededDVMD ,
98
+ recipientsCounter : values [ 1 ] . toString ( ) ,
99
+ } ;
100
+ }
101
+
102
+ function decodeDVMDApplicationData ( encodedData : Hex ) : DVMDApplicationData {
91
103
const decodedData = decodeAbiParameters (
92
104
[
93
105
{ name : "registryAnchor" , type : "address" } ,
@@ -101,11 +113,10 @@ function decodeDVMDApplicationData(encodedData: Hex): DVMDApplicationData {
101
113
] ,
102
114
} ,
103
115
] ,
104
- values [ 0 ]
116
+ encodedData
105
117
) ;
106
118
107
119
const results : DVMDApplicationData = {
108
- recipientsCounter : values [ 1 ] . toString ( ) ,
109
120
anchorAddress : decodedData [ 0 ] ,
110
121
recipientAddress : decodedData [ 1 ] ,
111
122
metadata : {
@@ -797,7 +808,7 @@ export async function handleEvent(
797
808
798
809
case "allov2.DonationVotingMerkleDistributionDirectTransferStrategy" :
799
810
case "allov2.DirectGrantsLiteStrategy" :
800
- values = decodeDVMDApplicationData ( encodedData ) ;
811
+ values = decodeDVMDExtendedApplicationData ( encodedData ) ;
801
812
id = ( Number ( values . recipientsCounter ) - 1 ) . toString ( ) ;
802
813
break ;
803
814
@@ -843,6 +854,80 @@ export async function handleEvent(
843
854
] ;
844
855
}
845
856
857
+ case "UpdatedRegistration" : {
858
+ const anchorAddress = parseAddress ( event . params . recipientId ) ;
859
+ const project = await db . getProjectByAnchor ( chainId , anchorAddress ) ;
860
+
861
+ if ( ! project ) {
862
+ throw new Error ( "Project not found" ) ;
863
+ }
864
+
865
+ const encodedData = event . params . data ;
866
+ const strategyAddress = parseAddress ( event . address ) ;
867
+ const round = await db . getRoundByStrategyAddress (
868
+ chainId ,
869
+ strategyAddress
870
+ ) ;
871
+
872
+ if ( ! round ) {
873
+ throw new Error ( "Round not found" ) ;
874
+ }
875
+
876
+ let values ;
877
+
878
+ switch ( round . strategyName ) {
879
+ case "allov2.DirectGrantsSimpleStrategy" :
880
+ values = decodeDGApplicationData ( encodedData ) ;
881
+ break ;
882
+
883
+ case "allov2.DirectGrantsLiteStrategy" :
884
+ case "allov2.DonationVotingMerkleDistributionDirectTransferStrategy" :
885
+ values = decodeDVMDApplicationData ( encodedData ) ;
886
+ break ;
887
+
888
+ default :
889
+ throw new Error ( "Invalid strategy name" ) ;
890
+ }
891
+
892
+ const metadata = await ipfsGet ( values . metadata . pointer ) ;
893
+
894
+ const statusString = ApplicationStatus [
895
+ event . params . status
896
+ ] as ApplicationTable [ "status" ] ;
897
+
898
+ const application = await db . getApplicationByAnchorAddress (
899
+ chainId ,
900
+ round . id ,
901
+ anchorAddress
902
+ ) ;
903
+
904
+ if ( application === null ) {
905
+ return [ ] ;
906
+ }
907
+
908
+ const statusUpdates = await updateApplicationStatus (
909
+ application ,
910
+ statusString ,
911
+ event . blockNumber ,
912
+ getBlock
913
+ ) ;
914
+
915
+ return [
916
+ {
917
+ type : "UpdateApplication" ,
918
+ chainId,
919
+ roundId : round . id ,
920
+ applicationId : application . id ,
921
+ application : {
922
+ ...application ,
923
+ ...statusUpdates ,
924
+ metadataCid : values . metadata . pointer ,
925
+ metadata : metadata ?? null ,
926
+ } ,
927
+ } ,
928
+ ] ;
929
+ }
930
+
846
931
case "TimestampsUpdated" : {
847
932
const strategyAddress = parseAddress ( event . address ) ;
848
933
const round = await db . getRoundByStrategyAddress (
0 commit comments