-
Notifications
You must be signed in to change notification settings - Fork 735
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implements static
decrypt notifications
& getMetadata
utils
- Loading branch information
Gancho Radkov
committed
Nov 29, 2023
1 parent
5b78ef9
commit 2e6a0a2
Showing
6 changed files
with
68 additions
and
2 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
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 @@ | ||
export * from "./notifications"; |
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,24 @@ | ||
import { Core } from "@walletconnect/core"; | ||
import { Web3WalletTypes } from "../types"; | ||
import { SessionStore } from "@walletconnect/sign-client"; | ||
|
||
export const Notifications: Web3WalletTypes.INotifications = { | ||
decryptMessage: async (params) => { | ||
const core = new Core({ | ||
storageOptions: params.storageOptions, | ||
storage: params.storage, | ||
}); | ||
await core.crypto.init(); | ||
return core.crypto.decode(params.topic, params.encryptedMessage); | ||
}, | ||
getMetadata: async (params) => { | ||
const core = new Core({ | ||
storageOptions: params.storageOptions, | ||
storage: params.storage, | ||
}); | ||
const sessionStore = new SessionStore(core, core.logger); | ||
await sessionStore.init(); | ||
const session = sessionStore.get(params.topic); | ||
return session?.peer.metadata; | ||
}, | ||
}; |