Skip to content

Commit

Permalink
Add API KEY to mobula (#3439)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxiao-cll authored Sep 19, 2024
1 parent e93bc76 commit 40e20f2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-parrots-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/mobula-state-adapter': minor
---

Add API Key
6 changes: 6 additions & 0 deletions packages/sources/mobula-state/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ export const config = new AdapterConfig({
type: 'string',
default: 'wss://feed.zobula.xyz',
},
API_KEY: {
description: 'An API key for Data Provider',
type: 'string',
required: true,
sensitive: true,
},
})
6 changes: 4 additions & 2 deletions packages/sources/mobula-state/src/transport/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ export type WsTransportTypes = BaseEndpointTypes & {
export const wsTransport = new WebSocketTransport<WsTransportTypes>({
url: (context) => context.adapterSettings.WS_API_ENDPOINT,
handlers: {
open: (connection) => {
connection.send(JSON.stringify({ type: 'feed' }))
open: (connection, context) => {
connection.send(
JSON.stringify({ type: 'feed', authorization: context.adapterSettings.API_KEY }),
)
},
message(message) {
if (!message.price) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('websocket', () => {
beforeAll(async () => {
oldEnv = JSON.parse(JSON.stringify(process.env))
process.env['WS_API_ENDPOINT'] = wsEndpoint
process.env['API_KEY'] = 'mock-api-key'
mockWebSocketProvider(WebSocketClassProvider)
mockWsServer = mockWebsocketServer(wsEndpoint)

Expand Down

0 comments on commit 40e20f2

Please sign in to comment.