Request form
Cookbook may introduce a token in the future. Share and contribute to be eligible for future airdrops.
close icon
relevant tag icon
Push Communicator V1.5
copy icon
Zaryab
• version 1.0.0
push_v1.5
Audited

Push Communicator V1.5

Audited

The Push Communicator protocol is comparatively quite simple. The communicator protocol includes features that allow users to subscribe to a channel, unsubscribe from a channel as well as the imperative one, i.e., sending notifications. As the communicator protocol can be deployed on various chains, it allows us to trigger notifications on multiple chains and not just the Ethereum blockchain. Unlike the Push Core smart contract, the communicator protocol is designed to be deployed on multiple chains. This is also one of the imperative reasons behind the communicator contract being lightweight and less reliant on Push Core.

*Visit desktop site to download or deploy

Version

1.0.0

Creator

Zaryab

Recent Use

🍞 0x9C6D downloaded

Last Publish

2/9/2023
Any contract you deploy is yours.
Fully owned and controlled by your wallet.
Documentation
Source Code
initialize(address,string) :
This function is the initializer for the contract. It sets the pushChannelAdmin, governance, chainName, and chainID variables. The pushChannelAdmin and governance variables are set to the address passed in as an argument. The chainName variable is set to the string passed in as an argument. The chainID variable is set to the chain ID of the current blockchain. (autogenerated documentation)
verifyChannelAlias(string) :
This function emits an event called ChannelAlias which stores the chain name, chain ID, sender address, and the channel address. This allows the contract to store a mapping of the channel address to the chain name and chain ID. This can be used to verify the channel address and ensure that it is associated with the correct chain. (autogenerated documentation)
completeMigration() :
This function allows the admin of the PushChannel contract to mark the migration process as complete. This is done by setting the boolean variable isMigrationComplete to true. This function is only accessible to the admin of the PushChannel contract. (autogenerated documentation)
setEPNSCoreAddress(address) :
This function sets the address of the EPNSCore contract for the PushChannel contract. It can only be called by the PushChannel contract's admin and requires an address of the EPNSCore contract as an argument. This function stores the address of the EPNSCore contract in the EPNSCoreAddress state variable. (autogenerated documentation)
setGovernanceAddress(address) :
This function allows the Push Channel Admin to set the address of the governance contract. This is done by passing in the address of the governance contract as an argument to the function. The function then sets the governance address to the address passed in. (autogenerated documentation)
transferPushChannelAdminControl(address) :
This function allows the current Push Channel Admin to transfer control of the Push Channel to a new address. It requires that the new address is not 0 and is not the same as the current Push Channel Admin. If these conditions are met, the new address is set as the Push Channel Admin. (autogenerated documentation)
isUserSubscribed(address,address) :
This function checks if a user is subscribed to a given channel. It takes two parameters, an address for the channel and an address for the user. It then looks up the user in the users mapping and checks if the isSubscribed mapping for the given channel is set to 1. If it is, it returns true, otherwise it returns false. (autogenerated documentation)
subscribe(address) :
This function allows a user to subscribe to a given channel. It takes in an address of the channel as an argument and adds the user's address to the list of subscribers for that channel. It then returns a boolean value indicating that the subscription was successful. (autogenerated documentation)
batchSubscribe() :
This function allows a user to subscribe to multiple channels at once. It takes an array of addresses as an argument, and then iterates through the array, calling the _subscribe function for each address in the array. The _subscribe function takes the address of the channel and the address of the user as arguments, and adds the user to the list of subscribers for the channel. The function returns true if all subscriptions were successful. (autogenerated documentation)
migrateSubscribeData(uint256,uint256) :
This function is used to migrate subscription data from the EPNSCommV1 contract to the EPNSCommV1_5 contract. It takes in two arrays, one containing a list of channels and the other containing a list of users, and a start and end index. It then iterates through the arrays, starting at the start index and ending at the end index, and checks if the user is already subscribed to the channel. If not, it calls the _subscribe function to subscribe the user to the channel. (autogenerated documentation)
_subscribe(address,address) :
This function allows a user to subscribe to a channel. It first checks if the user is already subscribed to the channel, and if not, it adds the user to the users mapping and sets the isSubscribed mapping for the channel to 1. It then sets the subscribed mapping for the channel to the user's subscribedCount, and sets the mapAddressSubscribed mapping for the subscribedCount to the channel. Finally, it increments the user's subscribedCount and emits a Subscribe event. (autogenerated documentation)
subscribeBySig(address,address,uint256,uint256,uint8,bytes32,bytes32) :
This function allows a subscriber to subscribe to a channel using a signature. It requires the address of the channel, the address of the subscriber, a nonce, an expiry, and the signature components (v, r, s). The function first checks that the subscriber address is valid. It then calculates the domain separator and the struct hash, which are used to generate the digest. If the subscriber is a contract, it uses the IERC1271 interface to check the validity of the signature. If the subscriber is an external account, it uses the ecrecover function to check the validity of the signature. The function then checks that the nonce is valid and that the signature has not expired. Finally, it (autogenerated documentation)
subscribeViaCore(address,address) :
This function allows the EPNSCore contract to subscribe a user to a channel. It takes two parameters, the address of the channel and the address of the user, and calls the _subscribe() function to add the user to the channel's list of subscribers. The function returns a boolean value indicating whether the subscription was successful. (autogenerated documentation)
unsubscribe(address) :
This function allows a user to unsubscribe from a given channel. It takes in an address of the channel as an argument and uses the _unsubscribe() internal function to remove the user from the channel's list of subscribers. It then returns a boolean value indicating that the user has been successfully unsubscribed. (autogenerated documentation)
batchUnsubscribe() :
This function allows a user to unsubscribe from multiple channels at once. It takes an array of addresses as an argument and loops through each address, calling the _unsubscribe function for each address. The _unsubscribe function removes the user from the channel's list of subscribers. The function returns true if all of the unsubscribe operations were successful. (autogenerated documentation)
_unsubscribe(address,address) :
This function is used to unsubscribe a user from a channel. It first checks if the user is subscribed to the channel, and if so, it updates the user's subscribedCount, removes the channel from the user's subscribed list, and deletes the channel from the user's mapAddressSubscribed list. Finally, it emits an Unsubscribe event. (autogenerated documentation)
unsubscribeBySig(address,address,uint256,uint256,uint8,bytes32,bytes32) :
This function allows a subscriber to unsubscribe from a channel using a signed message. The function first checks that the subscriber address is valid and that the signature is valid. It then calculates the domain separator, struct hash, and digest of the message. If the subscriber is a contract, it uses the IERC1271 interface to check the signature. If the subscriber is an external account, it uses the ecrecover function to check the signature. The function then checks that the nonce is valid and that the signature has not expired. Finally, it calls the _unsubscribe function to unsubscribe the subscriber from the channel. (autogenerated documentation)
unSubscribeViaCore(address,address) :
This function allows the EPNSCore contract to unsubscribe a user from a given channel. It takes two parameters, the address of the channel and the address of the user, and calls the _unsubscribe() internal function to remove the user from the channel's list of subscribers. The function returns a boolean value indicating whether the unsubscription was successful. (autogenerated documentation)
_addUser(address) :
This function adds a user to the contract. It takes an address as an argument and checks if the user has already been added. If the user has not been added, the function sets the userStartBlock to the current block number and sets userActivated to true. It then adds the user to the mapAddressUsers mapping and increments the usersCount variable. (autogenerated documentation)
_broadcastPublicKey(address) :
This function is used to broadcast a user's public key to the blockchain. It takes in an address of the user and the public key as parameters. It first adds the user to the users mapping, then it validates the public key by comparing it to the address of the user. If the validation is successful, it emits an event to the blockchain to indicate that the public key has been registered. (autogenerated documentation)
getWalletFromPublicKey() :
This function takes in a public key as a byte array and returns an address. It does this by first checking that the public key is 64 bytes long. If it is, it then takes the keccak256 hash of the public key, converts it to a uint256, then to a uint160, and finally to an address. If the public key is not 64 bytes long, it returns a 0x0 address. (autogenerated documentation)
broadcastUserPublicKey() :
This function allows a user to broadcast their public key to the blockchain. It takes in a parameter of the user's public key in bytes form and checks if the user has already registered their public key. If they have not, the function calls the _broadcastPublicKey function to broadcast the user's public key to the blockchain. (autogenerated documentation)
addDelegate(address) :
This function adds a delegate to a list of delegated notification senders. It takes an address of the delegate as an argument and stores it in a mapping of delegated notification senders. It then emits an event to signal that a delegate has been added. (autogenerated documentation)
removeDelegate(address) :
This function allows a user to remove a delegate from their list of delegated notification senders. It takes in an address of the delegate to be removed as an argument. The function sets the value of the delegate in the delegatedNotificationSenders mapping to false, and emits an event to indicate that the delegate has been removed. (autogenerated documentation)
_checkNotifReq(address,address) :
This function checks if a notification request is valid. It checks if the channel address is 0x0 (which means the request is from the pushChannelAdmin), if the channel address is the same as the sender address, if the sender address is a delegated notification sender for the channel, or if the recipient address is the same as the sender address. If any of these conditions are met, the function returns true, otherwise it returns false. (autogenerated documentation)
sendNotification(address,address) :
This function sends a notification to a recipient from a given channel. It first checks if the notification request is valid, and if it is, it emits an event with the channel, recipient, and identity information. It then returns a boolean value indicating whether the notification was successfully sent. (autogenerated documentation)
_sendNotification(address,address,address) :
This function is used to send notifications to a recipient from a channel. It checks if the channel is the signatory, if the signatory is a delegated notification sender for the channel, or if the recipient is the signatory. If any of these conditions are met, the function emits a SendNotification event with the channel, recipient, and identity as parameters. If none of the conditions are met, the function returns false. (autogenerated documentation)
sendNotifBySig(address,address,address,uint256,uint256,uint8,bytes32,bytes32) :
This function is used to send a notification to a recipient on a given channel, using a signature from a signer. It first checks that the signer is not the zero address, that the nonce is valid, and that the expiry time has not passed. It then calculates the domain separator, struct hash, and digest of the data to be signed. If the signer is a contract, it uses the IERC1271 interface to check the validity of the signature. If the signer is an address, it uses the ecrecover function to check the validity of the signature. If the signature is valid, the function calls the _sendNotification function to send the notification to the recipient. Finally, it increments (autogenerated documentation)
changeUserChannelSettings(address,uint256,string) :
This function allows a user to change their notification settings for a specific channel. It requires that the user is subscribed to the channel, and then it stores the notification settings in the userToChannelNotifs mapping. It also emits an event to indicate that the user's notification settings have been changed. (autogenerated documentation)
getChainId() :
This function is used to get the chain ID of the current Ethereum network. It does this by using the chainid() assembly instruction, which returns the chain ID of the current network. The function then returns the chain ID as a uint256. (autogenerated documentation)

Get Cookin'
share iconShare

copy iconDownload Source
copy iconnpx cookbookdev i Push-Communicator-V1.5
copy icon

Recent Use

🍞 0x9C6D downloaded

Last Publish

2/9/2023

Version

1.0.0

Creator

Zaryab

Cookbook is free.
Any contract you deploy is yours.
Your contract is owned and controlled by you.