You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
⚠️ This package is a sub-package of the `secret-toolkit` package. Please see its crate page for more context.
4
+
5
+
These functions are meant to help you easily create notification channels for private push notifications in secret contracts (see [SNIP-52 Private Push Notification](https://github.com/SolarRepublic/SNIPs/blob/feat/snip-52/SNIP-52.md)).
6
+
7
+
### Implementing a `DirectChannel` struct
8
+
9
+
Each notification channel will have a specified data format, which is defined by creating a struct that implements the `DirectChannel` trait, which has one method: `encode_cbor`.
10
+
11
+
The following example illustrates how you might implement this for a channel called `my_channel` and notification data containing two fields: `sender` and `amount`.
To send a notification to a recipient you first create a new `Notification` struct passing in the address of the recipient along with the notification data you want to send. Then to turn it into a `TxHashNotification` execute the `to_txhash_notification` method on the `Notification` by passing in `deps.api`, `env`, and an internal `secret`, which is a randomly generated byte slice that has been stored previously in your contract during initialization.
48
+
49
+
The following code snippet creates a notification for the above `my_channel` and adds it to the contract `Response` as a plaintext attribute.
0 commit comments