Skip to content

Commit

Permalink
Merge pull request #294 from forta-network/caner/get-bot-id-from-context
Browse files Browse the repository at this point in the history
Add utility methods to get and set bot ID in context
  • Loading branch information
canercidam authored Dec 20, 2023
2 parents 5e17dc6 + 3a11883 commit 25b45e6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utils/apiutils/principal.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type contextKey int
const (
contextKeyPrincipalAddressValue contextKey = 1
contextKeyBatchValue contextKey = 2
contextKeyBotID contextKey = 3
)

func GetAddress(ctx context.Context) string {
Expand All @@ -24,3 +25,11 @@ func GetBatch(ctx context.Context) string {
func SetBatch(ctx context.Context, batch string) context.Context {
return context.WithValue(ctx, contextKeyBatchValue, batch)
}

func GetBotID(ctx context.Context) string {
return ctx.Value(contextKeyBotID).(string)
}

func SetBotID(ctx context.Context, addr string) context.Context {
return context.WithValue(ctx, contextKeyBotID, addr)
}

0 comments on commit 25b45e6

Please sign in to comment.