Skip to content

Commit

Permalink
add unique key to sdk findings
Browse files Browse the repository at this point in the history
  • Loading branch information
aomerk committed Jul 27, 2023
1 parent c0d3e3c commit 416d1da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions python-sdk/src/forta_agent/finding.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self, dict):
self.metadata = dict.get('metadata')
self.addresses = dict.get('addresses')
self.labels = list(map(lambda l: l if isinstance(l, Label) else Label(l), dict.get('labels', [])))
self.unique_key = dict.get('unique_key')

def toJson(self):
d = dict(self.__dict__, **{
Expand Down
11 changes: 7 additions & 4 deletions sdk/finding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ type FindingInput = {
type: FindingType,
metadata?: { [key: string]: string},
addresses?: string[],
labels?: Label[]
labels?: Label[],
uniqueKey?: string,
}

export class Finding {
Expand All @@ -41,7 +42,8 @@ export class Finding {
readonly type: FindingType,
readonly metadata: { [key: string]: string},
readonly addresses: string[],
readonly labels: Label[]
readonly labels: Label[],
readonly uniqueKey: string,
) {}

toString() {
Expand All @@ -67,7 +69,8 @@ export class Finding {
type,
metadata = {},
addresses = [],
labels = []
labels = [],
uniqueKey = '',
}: FindingInput) {
assertIsNonEmptyString(name, 'name')
assertIsNonEmptyString(description, 'description')
Expand All @@ -78,6 +81,6 @@ export class Finding {
// TODO assert metadata keys and values are strings

labels = labels.map(l => l instanceof Label ? l : Label.fromObject(l))
return new Finding(name, description, alertId, protocol, severity, type, metadata, addresses, labels)
return new Finding(name, description, alertId, protocol, severity, type, metadata, addresses, labels, uniqueKey)
}
}

0 comments on commit 416d1da

Please sign in to comment.