Skip to content

Commit

Permalink
add unique key support to sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
aomerk committed Nov 1, 2023
1 parent bf510f7 commit 70669a4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cli/commands/run/server/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,16 @@ message AlertEvent {

message SourceAlertEvent {
string botId = 1;
string hash = 2;
string alertHash = 2;
string timestamp = 3;
uint64 chainId = 4;
string chainId = 4;
}

message Source {
string transactionHash = 1;
Bot bot = 2;
Block block = 3;
SourceAlertEvent sourceAlert = 4;
SourceAlertEvent sourceEvent = 4;
}

message Label {
Expand Down
1 change: 1 addition & 0 deletions python-sdk/src/forta_agent/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self, dict):
self.confidence = dict['confidence']
self.label = dict['label']
self.remove = dict.get('remove', False)
self.unique_key = dict.get('uniqueKey', False)
self.metadata = dict.get('metadata') if dict.get(
'metadata') is not None else {}
# if metadata is array, convert to map
Expand Down
1 change: 1 addition & 0 deletions python-sdk/src/forta_agent/labels_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def get_query(self):
label
metadata
remove
uniqueKey
}
source {
alertHash
Expand Down
8 changes: 6 additions & 2 deletions sdk/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type LabelInput = {
source?: LabelSource;
createdAt?: string;
id?: string;
uniqueKey?: string;
};

export class Label {
Expand All @@ -49,7 +50,8 @@ export class Label {
readonly metadata: { [key: string]: string },
readonly source?: LabelSource,
readonly id?: string,
readonly createdAt?: string
readonly createdAt?: string,
readonly uniqueKey?: string
) {}

static from(labelInput: LabelInput) {
Expand All @@ -66,6 +68,7 @@ export class Label {
source,
id,
createdAt,
uniqueKey
}: LabelInput) {
if (typeof entityType == "string") {
entityType = ENTITY_TYPE_STRING_TO_ENUM[entityType];
Expand All @@ -91,7 +94,8 @@ export class Label {
metadata,
source,
id,
createdAt
createdAt,
uniqueKey
);
}
}

0 comments on commit 70669a4

Please sign in to comment.