File tree Expand file tree Collapse file tree 11 files changed +43
-8
lines changed
govtool/metadata-validation Expand file tree Collapse file tree 11 files changed +43
-8
lines changed Original file line number Diff line number Diff line change 6060 USERSNAP_SPACE_API_KEY : ${{ secrets.USERSNAP_SPACE_API_KEY }}
6161 IS_PROPOSAL_DISCUSSION_FORUM_ENABLED : ${{ inputs.isProposalDiscussionForumEnabled == 'enabled' }}
6262 PDF_API_URL : ${{ secrets.PDF_API_URL}}
63+ IPFS_GATEWAY : ${{ secrets.IPFS_GATEWAY }}
64+ IPFS_PROJECT_ID : ${{ secrets.IPFS_PROJECT_ID }}
6365 steps :
6466 - name : Checkout code
6567 uses : actions/checkout@v4
Original file line number Diff line number Diff line change 6060 USERSNAP_SPACE_API_KEY : ${{ secrets.USERSNAP_SPACE_API_KEY }}
6161 IS_PROPOSAL_DISCUSSION_FORUM_ENABLED : ${{ inputs.isProposalDiscussionForumEnabled == 'enabled' }}
6262 PDF_API_URL : ${{ secrets.PDF_API_URL }}
63+ IPFS_GATEWAY : ${{ secrets.IPFS_GATEWAY }}
64+ IPFS_PROJECT_ID : ${{ secrets.IPFS_PROJECT_ID }}
6365 steps :
6466 - name : Checkout code
6567 uses : actions/checkout@v4
Original file line number Diff line number Diff line change 6363 USERSNAP_SPACE_API_KEY : ${{ secrets.USERSNAP_SPACE_API_KEY }}
6464 IS_PROPOSAL_DISCUSSION_FORUM_ENABLED : ${{github.event_name == 'push' && 'true' || inputs.isProposalDiscussionForumEnabled == 'enabled'}}
6565 PDF_API_URL : ${{ secrets.PDF_API_URL}}
66+ IPFS_GATEWAY : ${{ secrets.IPFS_GATEWAY }}
67+ IPFS_PROJECT_ID : ${{ secrets.IPFS_PROJECT_ID }}
6668 steps :
6769 - name : Checkout code
6870 uses : actions/checkout@v4
Original file line number Diff line number Diff line change 6363 USERSNAP_SPACE_API_KEY : ${{ secrets.USERSNAP_SPACE_API_KEY }}
6464 IS_PROPOSAL_DISCUSSION_FORUM_ENABLED : ${{github.event_name == 'push' && 'true' || inputs.isProposalDiscussionForumEnabled == 'enabled'}}
6565 PDF_API_URL : ${{ secrets.PDF_API_URL}}
66+ IPFS_GATEWAY : ${{ secrets.IPFS_GATEWAY }}
67+ IPFS_PROJECT_ID : ${{ secrets.IPFS_PROJECT_ID }}
6668 steps :
6769 - name : Checkout code
6870 uses : actions/checkout@v4
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ changes.
1616- Add support for displaying Motion of No Confidence Governance Action [ Issue 1597] ( https://github.com/IntersectMBO/govtool/issues/1597 )
1717- Add support for displaying Update committee/threshold Governance Action [ Issue 1598] ( https://github.com/IntersectMBO/govtool/issues/1598 )
1818- Add support for displaying New Constitution and/or Guardrails Script Governance Action [ Issue 1599] ( https://github.com/IntersectMBO/govtool/issues/1598 )
19+ - Add support for ipfs in metadata validation service [ Issue 1616] ( https://github.com/IntersectMBO/govtool/issues/1616 )
1920
2021### Fixed
2122
Original file line number Diff line number Diff line change 1- PORT = 3000
1+ PORT = 3000
2+ IPFS_GATEWAY = https://ipfs.some.gateway
3+ IPFS_PROJECT_ID = ipfsprojectid
Original file line number Diff line number Diff line change 11FROM node:lts-hydrogen
22
3+ ARG IPFS_GATEWAY
4+ ARG IPFS_PROJECT_ID
5+
36WORKDIR /dist
47
58COPY package*.json ./
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ services:
88 container_name : metadata-validation
99 environment :
1010 - PORT=${PORT}
11+ - IPFS_GATEWAY=${IPFS_GATEWAY}
12+ - IPFS_PROJECT_ID=${IPFS_PROJECT_ID}
1113 ports :
1214 - ${PORT}:${PORT}
1315 volumes :
Original file line number Diff line number Diff line change @@ -22,15 +22,30 @@ export class AppService {
2222 let metadata : Record < string , unknown > ;
2323 let standard = paramStandard ;
2424
25+ const isIPFS = url . startsWith ( 'ipfs://' ) ;
26+ if ( isIPFS ) {
27+ url = `${ process . env . IPFS_GATEWAY } /${ url . slice ( 7 ) } ` ;
28+ }
29+
2530 try {
2631 const { data : rawData } = await firstValueFrom (
27- this . httpService . get ( url ) . pipe (
28- finalize ( ( ) => Logger . log ( `Fetching ${ url } completed` ) ) ,
29- catchError ( ( error ) => {
30- Logger . error ( error , JSON . stringify ( error ) ) ;
31- throw MetadataValidationStatus . URL_NOT_FOUND ;
32- } ) ,
33- ) ,
32+ this . httpService
33+ . get ( url , {
34+ headers : {
35+ 'Content-Type' : 'application/json' ,
36+ ...( isIPFS &&
37+ process . env . IPFS_PROJECT_ID && {
38+ project_id : process . env . IPFS_PROJECT_ID ,
39+ } ) ,
40+ } ,
41+ } )
42+ . pipe (
43+ finalize ( ( ) => Logger . log ( `Fetching ${ url } completed` ) ) ,
44+ catchError ( ( error ) => {
45+ Logger . error ( error , JSON . stringify ( error ) ) ;
46+ throw MetadataValidationStatus . URL_NOT_FOUND ;
47+ } ) ,
48+ ) ,
3449 ) ;
3550
3651 let parsedData ;
Original file line number Diff line number Diff line change @@ -187,6 +187,8 @@ services:
187187 image: <REPO _URL >/metadata-validation:${ METADATA_VALIDATION_TAG}
188188 environment:
189189 - PORT=3000
190+ - IPFS_GATEWAY=${ IPFS_GATEWAY}
191+ - IPFS_PROJECT_ID=${ IPFS_PROJECT_ID}
190192 logging: *logging
191193 restart: always
192194 healthcheck:
You can’t perform that action at this time.
0 commit comments