Skip to content

Commit 4533b8e

Browse files
committed
refactor: lint-policy-registry-mapping
1 parent 4dc6541 commit 4533b8e

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

mappings/policy-registry.ts

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,38 @@
1-
import { PolicyUpdate as PolicyUpdateEvent } from "../generated/PolicyRegistry/PolicyRegistry"
2-
import { Court,CourtMetadata } from "../generated/schema"
3-
import { json, Bytes, dataSource, log } from "@graphprotocol/graph-ts";
1+
import { PolicyUpdate as PolicyUpdateEvent } from "../generated/PolicyRegistry/PolicyRegistry";
2+
import { Court, CourtMetadata } from "../generated/schema";
3+
import { json, Bytes, dataSource } from "@graphprotocol/graph-ts";
44
import { CourtMetadata as CourtMetadataTemplate } from "../generated/templates";
55

66
export function handlePolicyUpdate(event: PolicyUpdateEvent): void {
7-
let court = Court.load(
8-
event.params._subcourtID.toString()
9-
)
7+
let court = Court.load(event.params._subcourtID.toString());
108

119
if (!court) {
12-
court = new Court(
13-
event.params._subcourtID.toString()
14-
)
10+
court = new Court(event.params._subcourtID.toString());
1511
}
16-
const ipfsHash = event.params._policy.replace('/ipfs/', '')
12+
13+
const ipfsHash = event.params._policy.replace("/ipfs/", "");
1714
court.policy = ipfsHash;
1815
court.metadata = ipfsHash;
1916

20-
CourtMetadataTemplate.create(ipfsHash)
17+
CourtMetadataTemplate.create(ipfsHash);
2118
court.save();
22-
2319
}
2420

2521
export function handleCourtMetadata(content: Bytes): void {
26-
let courtMetadata = new CourtMetadata(dataSource.stringParam())
27-
const value = json.fromBytes(content).toObject()
28-
log.debug("got value {}",[json.fromBytes(content).toString()])
22+
let courtMetadata = new CourtMetadata(dataSource.stringParam());
23+
const value = json.fromBytes(content).toObject();
24+
2925
if (value) {
30-
const name = value.get('name');
31-
courtMetadata.name = name? name.toString() : null;
32-
33-
const description = value.get('description');
34-
courtMetadata.description = description? description.toString() : null;
35-
36-
const requiredSkills = value.get('requiredSkills');
37-
courtMetadata.requiredSkills = requiredSkills? requiredSkills.toString() : null;
38-
courtMetadata.save()
26+
const name = value.get("name");
27+
courtMetadata.name = name ? name.toString() : null;
28+
29+
const description = value.get("description");
30+
courtMetadata.description = description ? description.toString() : null;
31+
32+
const requiredSkills = value.get("requiredSkills");
33+
courtMetadata.requiredSkills = requiredSkills
34+
? requiredSkills.toString()
35+
: null;
36+
courtMetadata.save();
3937
}
40-
}
38+
}

0 commit comments

Comments
 (0)