Skip to content

Commit

Permalink
feat: validate policies
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras committed Jan 11, 2019
1 parent 9b717a9 commit 71c0445
Show file tree
Hide file tree
Showing 12 changed files with 452 additions and 978 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_KLEROS_LIQUID_KOVAN_ADDRESS=0x8847c0947a613c3de443f73351c3815ad0d37f98
REACT_APP_PINAKION_KOVAN_ADDRESS=0x1ee318dbc19267dbce08f54a66ab198f73ede356
REACT_APP_POLICY_REGISTRY_KOVAN_ADDRESS=0x55aa06760990a6418a89d2177de367fe1cb5c3cb
REACT_APP_POLICY_REGISTRY_KOVAN_ADDRESS=0xfc53d1d6ddc2c6cdd403cb7dbf0f26140d82e12d
REACT_APP_WEB3_FALLBACK_URL=wss://mainnet.infura.io/ws
1,395 changes: 431 additions & 964 deletions src/assets/contracts/policy-registry.json

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 8 additions & 1 deletion src/bootstrap/dataloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ const funcs = {
})
)
.catch(() => null),
load: URI => fetch(URI).then(res => res.json())
load: (URI, options) =>
archon.utils
.validateFileFromURI(URI, {
strictHashes: true,
...options
})
.then(res => res.file)
.catch(() => null)
}
export const dataloaders = Object.keys(funcs).reduce((acc, f) => {
acc[f] = new Dataloader(
Expand Down
4 changes: 2 additions & 2 deletions src/components/court-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const CourtCard = ({ ID, onClick, onStakeClick: _onStakeClick }) => {
const load = useDataloader.load()
let name
const policy = useCacheCall('PolicyRegistry', 'policies', ID)
if (policy) {
const policyJSON = load(policy.fileURI)
if (policy !== undefined) {
const policyJSON = load(policy)
if (policyJSON) name = policyJSON.name
}
const stake = useCacheCall(
Expand Down
8 changes: 4 additions & 4 deletions src/components/court-cascader-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ const CourtCascaderModal = ({ onClick }) => {
let option = options[0]
for (let i = 0; i < subcourtIDs.length; i++) {
const policy = call('PolicyRegistry', 'policies', subcourtIDs[i])
if (policy) {
const policyJSON = load(policy.fileURI)
if (policy !== undefined) {
const policyJSON = load(policy)
if (policyJSON) {
option.description = policyJSON.description
option.label = policyJSON.name
Expand All @@ -108,8 +108,8 @@ const CourtCascaderModal = ({ onClick }) => {
value: c
}
const policy = call('PolicyRegistry', 'policies', c)
if (policy) {
const policyJSON = load(policy.fileURI)
if (policy !== undefined) {
const policyJSON = load(policy)
if (policyJSON) {
child.description = policyJSON.description
child.label = policyJSON.name
Expand Down
4 changes: 2 additions & 2 deletions src/components/court-drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ const CourtDrawer = ({ ID, onClose }) => {
summary: undefined
}
const policy = call('PolicyRegistry', 'policies', subcourt.ID)
if (policy) {
const policyJSON = load(policy.fileURI)
if (policy !== undefined) {
const policyJSON = load(policy)
if (policyJSON) {
subcourt.description = policyJSON.description
subcourt.name = policyJSON.name
Expand Down
4 changes: 2 additions & 2 deletions src/components/courts-list-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const CourtsListCard = () => {
subcourtIDs &&
subcourtIDs.map(ID => {
const policy = call('PolicyRegistry', 'policies', ID)
if (policy) {
const policyJSON = load(policy.fileURI)
if (policy !== undefined) {
const policyJSON = load(policy)
if (policyJSON) return policyJSON.name
}
return undefined
Expand Down
4 changes: 2 additions & 2 deletions src/components/pnk-stats-list-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ const PNKStatsListCard = () => {
ID
)
const policy = call('PolicyRegistry', 'policies', ID)
if (policy) {
const policyJSON = load(policy.fileURI)
if (policy !== undefined) {
const policyJSON = load(policy)
if (policyJSON) subcourt.name = policyJSON.name
}
return subcourt
Expand Down

0 comments on commit 71c0445

Please sign in to comment.