@@ -31,7 +31,6 @@ import { IconExternalLink } from '@intersect.mbo/intersectmbo.org-icons-set';
3131import { useTheme } from '@emotion/react' ;
3232
3333const InformationStorageStep = ( { proposal, handleCloseSubmissionDialog } ) => {
34-
3534 const theme = useTheme ( ) ;
3635 const navigate = useNavigate ( ) ;
3736 const { walletAPI, validateMetadata } = useAppContext ( ) ;
@@ -112,12 +111,17 @@ const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => {
112111 const hash = await walletAPI . createHash ( jsonLd ) ;
113112 setHashData ( hash ) ;
114113 } ;
115- const proposalGATypeId = proposal ?. attributes ?. content ?. attributes . gov_action_type_id ;
114+ const proposalGATypeId =
115+ proposal ?. attributes ?. content ?. attributes . gov_action_type_id ;
116116 const handleGASubmission = async ( ) => {
117117 try {
118+ let url = fileURL ;
118119 setCheckingDataModal ( true ) ;
120+ if ( fileURL . startsWith ( 'ipfs://' ) ) {
121+ url = `https://ipfs.io/ipfs/${ fileURL . replace ( 'ipfs://' , '' ) } ` ;
122+ }
119123 const response = await validateMetadata ( {
120- url : fileURL ,
124+ url : url ,
121125 hash : hashData ,
122126 standard : 'CIP108' ,
123127 } ) ;
@@ -135,43 +139,52 @@ const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => {
135139 await walletAPI . buildTreasuryGovernanceAction ( {
136140 hash : hashData ,
137141 url : fileURL ,
138- withdrawals : getWithdrawalsArray ( )
142+ withdrawals : getWithdrawalsArray ( ) ,
139143 } ) ;
140- }
141- else if ( parseInt ( proposalGATypeId ) === 3 )
142- {
143- const constitUrl = proposal ?. attributes ?. content ?. attributes . proposal_constitution_content . data . attributes . prop_constitution_url ;
144+ } else if ( parseInt ( proposalGATypeId ) === 3 ) {
145+ const constitUrl =
146+ proposal ?. attributes ?. content ?. attributes
147+ . proposal_constitution_content . data . attributes
148+ . prop_constitution_url ;
144149 const constiUrlHash = await getHashFromUrl ( constitUrl ) ;
145150 govActionBuilder =
146- await walletAPI . buildNewConstitutionGovernanceAction ( {
147- hash : hashData ,
148- url : fileURL ,
149- constitutionUrl : constitUrl ,
150- constitutionHash : constiUrlHash
151- //prevGovernanceActionHash: string;
152- //prevGovernanceActionIndex: number;
153- //scriptHash: string;
154- } ) ;
155- }
156- else if ( parseInt ( proposalGATypeId ) === 4 )
157- { ///Motion of No Confidence
158- govActionBuilder =
159- await walletAPI . buildNoConfidenceGovernanceAction ( {
151+ await walletAPI . buildNewConstitutionGovernanceAction ( {
160152 hash : hashData ,
161153 url : fileURL ,
154+ constitutionUrl : constitUrl ,
155+ constitutionHash : constiUrlHash ,
156+ //prevGovernanceActionHash: string;
157+ //prevGovernanceActionIndex: number;
158+ //scriptHash: string;
162159 } ) ;
163- }
164- else if ( parseInt ( proposalGATypeId ) === 6 )
165- { ///Hard Fork Initiation
160+ } else if ( parseInt ( proposalGATypeId ) === 4 ) {
161+ ///Motion of No Confidence
166162 govActionBuilder =
167- await walletAPI . buildHardForkInitiationGovernanceActions ( {
168- prevGovernanceActionHash : proposal ?. attributes ?. content ?. attributes ?. proposal_hard_fork_content . previous_ga_hash ,
169- prevGovernanceActionIndex : proposal ?. attributes ?. content ?. attributes ?. proposal_hard_fork_content . previous_ga_id ,
170- major : proposal ?. attributes ?. content ?. attributes ?. proposal_hard_fork_content . major ,
171- minor : proposal ?. attributes ?. content ?. attributes ?. proposal_hard_fork_content . minor ,
163+ await walletAPI . buildNoConfidenceGovernanceAction ( {
172164 hash : hashData ,
173165 url : fileURL ,
174166 } ) ;
167+ } else if ( parseInt ( proposalGATypeId ) === 6 ) {
168+ ///Hard Fork Initiation
169+ govActionBuilder =
170+ await walletAPI . buildHardForkInitiationGovernanceActions (
171+ {
172+ prevGovernanceActionHash :
173+ proposal ?. attributes ?. content ?. attributes
174+ ?. proposal_hard_fork_content
175+ . previous_ga_hash ,
176+ prevGovernanceActionIndex :
177+ proposal ?. attributes ?. content ?. attributes
178+ ?. proposal_hard_fork_content
179+ . previous_ga_id ,
180+ major : proposal ?. attributes ?. content ?. attributes
181+ ?. proposal_hard_fork_content . major ,
182+ minor : proposal ?. attributes ?. content ?. attributes
183+ ?. proposal_hard_fork_content . minor ,
184+ hash : hashData ,
185+ url : fileURL ,
186+ }
187+ ) ;
175188 }
176189
177190 if ( govActionBuilder ) {
@@ -212,12 +225,17 @@ const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => {
212225
213226 const getWithdrawalsArray = ( ) => {
214227 let withdrawalsArray = [ ] ;
215- let x = proposal ?. attributes ?. content ?. attributes ?. proposal_withdrawals . forEach ( ( withdrawal ) =>
216- {
217- withdrawalsArray . push ( { receivingAddress :withdrawal . prop_receiving_address , amount :withdrawal . prop_amount . toString ( ) } )
218- } ) ;
228+ let x =
229+ proposal ?. attributes ?. content ?. attributes ?. proposal_withdrawals . forEach (
230+ ( withdrawal ) => {
231+ withdrawalsArray . push ( {
232+ receivingAddress : withdrawal . prop_receiving_address ,
233+ amount : withdrawal . prop_amount . toString ( ) ,
234+ } ) ;
235+ }
236+ ) ;
219237 return withdrawalsArray ;
220- }
238+ } ;
221239
222240 const handleDownloadJsonLD = ( ) => {
223241 const blob = new Blob ( [ JSON . stringify ( jsonLdData , null , 2 ) ] , {
@@ -239,7 +257,9 @@ const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => {
239257 throw new Error ( 'url is not defined or null' ) ;
240258 }
241259 // Fetch the data from the URL
242- const response = ( await fetch ( url , { 'User-Agent' : "govtool-agent" } ) ) ;
260+ const response = await fetch ( url , {
261+ 'User-Agent' : 'govtool-agent' ,
262+ } ) ;
243263 // Check if the response is successful
244264 if ( ! response . ok ) {
245265 throw new Error ( `HTTP error! Status: ${ response . status } ` ) ;
0 commit comments