Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from deltaDAO/feature/vp-integration
Integrate Verifiable Presentation Registry (preview version)
- Loading branch information
Showing
19 changed files
with
465 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
{ | ||
"compute": { | ||
"storage": "Results are stored for 30 days." | ||
}, | ||
"verify": { | ||
"data": [ | ||
{ | ||
"name": "file", | ||
"label": "Verifiable Presentation File", | ||
"placeholder": "e.g. https://file.com/vp.json", | ||
"help": "Please enter the URL to your verifiable presentation file and click \"ADD FILE\" to validate the data. This URL will be stored encrypted after publishing. For a compute data set, your file should match the file type required by the algorithm, and should not exceed 1 GB in file size.", | ||
"type": "files", | ||
"required": true | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export interface RegisterVPPayload { | ||
signature: string | ||
hashedMessage: string | ||
fileUrl: string | ||
} | ||
|
||
type RegistryApiResponseBody = SignatureMessageBody | VpDataBody | ||
|
||
export interface RegistryApiResponse<RegistryApiResponseBody> { | ||
data: { | ||
data: RegistryApiResponseBody | ||
message: string | ||
} | ||
} | ||
|
||
export interface SignatureMessageBody { | ||
message: string | ||
} | ||
|
||
export interface VpDataBody { | ||
_id: string | ||
address: string | ||
transactionHash: string | ||
fileUrl: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
.loader, | ||
.verifiedBadge { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: calc(var(--spacer) / 3); | ||
height: calc(var(--spacer) * 1.5); | ||
} | ||
|
||
.verifiedBadge { | ||
border-radius: var(--border-radius); | ||
|
||
background: var(--color-primary); | ||
color: var(--brand-white); | ||
|
||
font-weight: var(--font-weight-bold); | ||
} | ||
|
||
.verifiedBadge svg { | ||
display: inline-block; | ||
height: 100%; | ||
} | ||
|
||
.verifiedBadge svg path { | ||
fill: var(--brand-white); | ||
} | ||
|
||
.loader span, | ||
.verifiedBadge span { | ||
padding: 0 calc(var(--spacer) / 4); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { ReactElement, useEffect, useState } from 'react' | ||
import styles from './VerifiedPublisher.module.css' | ||
import { ReactComponent as VerifiedPatch } from '../../images/patch_check.svg' | ||
import axios, { AxiosResponse } from 'axios' | ||
import Loader from './Loader' | ||
import { Logger } from '@oceanprotocol/lib' | ||
import { useSiteMetadata } from '../../hooks/useSiteMetadata' | ||
|
||
export default function VerifiedPublisher({ | ||
address | ||
}: { | ||
address: string | ||
}): ReactElement { | ||
const [verified, setVerified] = useState(false) | ||
const [loading, setLoading] = useState(false) | ||
|
||
const { vpRegistryUri } = useSiteMetadata().appConfig | ||
|
||
useEffect(() => { | ||
const verify = async () => { | ||
if (address) { | ||
setLoading(true) | ||
try { | ||
const response: AxiosResponse<any> = await axios.get( | ||
`${vpRegistryUri}/vp/${address}/verify` | ||
) | ||
Logger.debug('[Verification] publisher verification:', response.data) | ||
setVerified(response.data?.data?.verified) | ||
} catch (err) { | ||
Logger.error('[Verification] verification error:', err.message) | ||
setVerified(false) | ||
} finally { | ||
setLoading(false) | ||
} | ||
} | ||
} | ||
verify() | ||
}, [address]) | ||
|
||
return loading ? ( | ||
<div className={styles.loader}> | ||
<Loader /> | ||
<span>verifying...</span> | ||
</div> | ||
) : verified ? ( | ||
<div className={styles.verifiedBadge}> | ||
<VerifiedPatch /> <span>Verified Publisher</span> | ||
</div> | ||
) : null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
.filters { | ||
.header { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
margin-top: -1rem; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.title { | ||
font-size: var(--font-size-h4); | ||
display: inline-flex; | ||
} |
Oops, something went wrong.