-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move streamr-proxy to oracle gateway (#1667)
* chore: move streamr-proxy to cache-service * test * Revert "test" This reverts commit 0a6623bf625a504d42675b6d76cd504f2e88f7af.
- Loading branch information
1 parent
dbba994
commit 35c9487
Showing
9 changed files
with
56 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as pako from "pako"; | ||
import { StreamrClient } from "streamr-client"; | ||
|
||
export { StreamrClient, Subscription, StreamPermission } from "streamr-client"; | ||
|
||
export const getStreamIdForNodeByEvmAddress = (evmAddress: string) => | ||
`${evmAddress}/redstone-oracle-node/data-packages`; | ||
|
||
export const doesStreamExist = async ( | ||
streamr: StreamrClient, | ||
streamId: string | ||
): Promise<boolean> => { | ||
try { | ||
await streamr.getStream(streamId); | ||
return true; | ||
} catch (error) { | ||
if ((error as Error).toString().includes("NOT_FOUND")) { | ||
return false; | ||
} else { | ||
throw error; | ||
} | ||
} | ||
}; | ||
|
||
export const compressMsg = (data: unknown) => { | ||
const dataStringified = JSON.stringify(data); | ||
return pako.deflate(dataStringified); | ||
}; | ||
|
||
export const decompressMsg = <T = unknown>(msg: Uint8Array): T => { | ||
const stringifiedData = pako.inflate(msg, { | ||
to: "string", | ||
}); | ||
return JSON.parse(stringifiedData) as T; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { getStreamIdForNodeByEvmAddress } from "../src/common/streamr"; | ||
|
||
describe("Stremr proxy tests", () => { | ||
test("Should properly get stream id by node evm address", () => { | ||
const streamId = getStreamIdForNodeByEvmAddress("0x1234"); | ||
expect(streamId).toBe("0x1234/redstone-oracle-node/data-packages"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters