{"_id":"@aurelianoa/iris-channels","_rev":"8-b9de2d45de45f5fd692796c0729a78b4","name":"@aurelianoa/iris-channels","dist-tags":{"latest":"1.1.0","develop":"1.1.0-beta.3"},"versions":{"1.0.0":{"name":"@aurelianoa/iris-channels","version":"1.0.0","description":"Package to setup a channel fo your smart contracts","repository":{"type":"git","url":"git+https://github.com/aurelianoa/iris-channels.git"},"author":{"name":"@aurealarcon aurelianoa.eth"},"license":"MIT","private":false,"devDependencies":{},"bugs":{"url":"https://github.com/aurelianoa/iris-channels/issues"},"homepage":"https://github.com/aurelianoa/iris-channels#readme","scripts":{"test":"mocha"},"keywords":["Solidity","Metadata"],"gitHead":"dcf38553eb739da27b9b042077d29d735ddb4d42","_id":"@aurelianoa/iris-channels@1.0.0","_nodeVersion":"16.15.0","_npmVersion":"8.5.5","dist":{"integrity":"sha512-cXNHxt0tCA3XFPZAPq3hE8crEfQXXECo0n3Mw5xEgmOUV1rUzk+G7KlP595qUAYxRRfcANasyu/yIt2gJq0qow==","shasum":"d456987b6007bff49d185a4958e0d47ebe523dc5","tarball":"https://registry.npmjs.org/@aurelianoa/iris-channels/-/iris-channels-1.0.0.tgz","fileCount":6,"unpackedSize":3283,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAvUsfMjupg6dP0SotmINmvGO1Irg/GSARbpGKvXq3ocAiEAmfSuHRuQ95yXeNgFlJTn5jxxrqaQT8i7l4mIbbESxp8="}]},"_npmUser":{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"},"directories":{},"maintainers":[{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iris-channels_1.0.0_1687263131747_0.577802105095657"},"_hasShrinkwrap":false},"1.0.1":{"name":"@aurelianoa/iris-channels","version":"1.0.1","description":"Package to setup a channel fo your smart contracts","repository":{"type":"git","url":"git+https://github.com/aurelianoa/iris-channels.git"},"author":{"name":"@aurealarcon aurelianoa.eth"},"license":"MIT","private":false,"devDependencies":{},"bugs":{"url":"https://github.com/aurelianoa/iris-channels/issues"},"homepage":"https://github.com/aurelianoa/iris-channels#readme","scripts":{"test":"mocha"},"keywords":["Solidity","Metadata"],"gitHead":"7c8b6222bbc1023a262a8d3bd6ef637e518bd748","_id":"@aurelianoa/iris-channels@1.0.1","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-/tCnz3KSJJaf0V7q1aGhW7LZhzrxvAB3I9TahuwsQBr5qkjBHbbVlMSR2Hztw5iPPBayDWq4qLUgnnSgMo9Ytw==","shasum":"402f924d1e62220dfc302014106db9ae41ebb42e","tarball":"https://registry.npmjs.org/@aurelianoa/iris-channels/-/iris-channels-1.0.1.tgz","fileCount":6,"unpackedSize":3248,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD0DBwCAEEDgjAQfl9b/vqq5NkUa4t2VcIP6sNVpV+WqgIhANOd1D82PMoP61zBRRMZ1CsVY91eIYx3Rl4Hw/BqGtEF"}]},"_npmUser":{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"},"directories":{},"maintainers":[{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iris-channels_1.0.1_1688133698389_0.13722653519296002"},"_hasShrinkwrap":false},"1.0.2":{"name":"@aurelianoa/iris-channels","version":"1.0.2","description":"Package to setup a channel fo your smart contracts","repository":{"type":"git","url":"git+https://github.com/aurelianoa/iris-channels.git"},"author":{"name":"@aurealarcon aurelianoa.eth"},"license":"MIT","private":false,"devDependencies":{},"bugs":{"url":"https://github.com/aurelianoa/iris-channels/issues"},"homepage":"https://github.com/aurelianoa/iris-channels#readme","scripts":{"test":"mocha"},"keywords":["Solidity","Metadata"],"gitHead":"594f332c0fea07b34c94c5966216b4152349b8ca","_id":"@aurelianoa/iris-channels@1.0.2","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-WLeT7Grmsgn6BzvnEHhR2oEVrYmKrxeYrJ8lfOh1UFj1TJuiNmooYofbjt0Lz8HoZ9STI+s47U3ilFhS6F+T1Q==","shasum":"3285147c983e3b16ec1ea3f5032455bf93ef1f62","tarball":"https://registry.npmjs.org/@aurelianoa/iris-channels/-/iris-channels-1.0.2.tgz","fileCount":6,"unpackedSize":3248,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCrVKwryKiNC9rkiQ2vMd5MZ/1pHPlRYbGRkxjbIjS/vQIgR9rEi35BmIjt8lPznbbQkBuOqzG6BnHnRZrEavDanOI="}]},"_npmUser":{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"},"directories":{},"maintainers":[{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iris-channels_1.0.2_1688993605786_0.7267344408133407"},"_hasShrinkwrap":false},"1.0.3":{"name":"@aurelianoa/iris-channels","version":"1.0.3","description":"Package to setup a channel fo your smart contracts","repository":{"type":"git","url":"git+https://github.com/aurelianoa/iris-channels.git"},"author":{"name":"@aurealarcon aurelianoa.eth"},"license":"MIT","private":false,"devDependencies":{},"bugs":{"url":"https://github.com/aurelianoa/iris-channels/issues"},"homepage":"https://github.com/aurelianoa/iris-channels#readme","scripts":{"test":"mocha"},"keywords":["Solidity","Metadata"],"gitHead":"86590987e3d3111d64b131caa04155fd9886a0f3","_id":"@aurelianoa/iris-channels@1.0.3","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-zucpriTzq79Fuqdef8v3faCx2rrJCZa+wEZ91wXNos86DM7X7SHsqsGLLavb8vpwf4oI+reTD+8tax5i0LicjA==","shasum":"031f9f8dcae643dd9c32e732693123debb009d37","tarball":"https://registry.npmjs.org/@aurelianoa/iris-channels/-/iris-channels-1.0.3.tgz","fileCount":6,"unpackedSize":3348,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHwyAGTIszd0UViur2pmVOXffRkVfXG1afjHCTJ3oYSzAiEAr37oJzcVM7ak8xQuDcyfAkJgYFxaDeCIWupR4sIAukk="}]},"_npmUser":{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"},"directories":{},"maintainers":[{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iris-channels_1.0.3_1689190490083_0.01893210530519518"},"_hasShrinkwrap":false},"1.1.0":{"name":"@aurelianoa/iris-channels","version":"1.1.0","description":"Package to setup a channel fo your smart contracts","repository":{"type":"git","url":"git+https://github.com/aurelianoa/iris-channels.git"},"author":{"name":"@aurealarcon aurelianoa.eth"},"license":"MIT","private":false,"devDependencies":{},"bugs":{"url":"https://github.com/aurelianoa/iris-channels/issues"},"homepage":"https://github.com/aurelianoa/iris-channels#readme","scripts":{"test":"mocha"},"keywords":["Solidity","Metadata"],"gitHead":"16a96578e6f1cb2e570e89752fbb6887107efaf5","_id":"@aurelianoa/iris-channels@1.1.0","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-pEUQ7VuZhp7BZmpQWN6nyFof8A889KyHW8ApklwmCi1GIjF3IEa81GKLNibYGa80Cn1bGe+MJjSbv9Yphye1ew==","shasum":"a26b426057ff2f978ac313138b6a3574c501e11f","tarball":"https://registry.npmjs.org/@aurelianoa/iris-channels/-/iris-channels-1.1.0.tgz","fileCount":7,"unpackedSize":7544,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCS5vKSyRcVcJ/lkZi3B3jN70wBJTBFpzcMvT6V5yDwBwIganfvkgIhebY5NMXZmDFuNIh7VIIeDMOeuwbGtyOaGqw="}]},"_npmUser":{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"},"directories":{},"maintainers":[{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iris-channels_1.1.0_1689948026348_0.9451553586831136"},"_hasShrinkwrap":false},"1.1.0-beta.0":{"name":"@aurelianoa/iris-channels","version":"1.1.0-beta.0","description":"Package to setup a channel fo your smart contracts","repository":{"type":"git","url":"git+https://github.com/aurelianoa/iris-channels.git"},"author":{"name":"@aurealarcon aurelianoa.eth"},"license":"MIT","private":false,"devDependencies":{},"bugs":{"url":"https://github.com/aurelianoa/iris-channels/issues"},"homepage":"https://github.com/aurelianoa/iris-channels#readme","scripts":{"test":"mocha"},"keywords":["Solidity","Metadata"],"gitHead":"ba32998a54a3f81a6e749421e03a6b9401fa10a4","readme":"# Iris Channels\n\nThe `iris-channels` package is a library for creating and using channels on the Iris protocol. Channels are a way to broadcast events to a network of contracts.\n\n## How to install\n\n```bash\nnpm install @aurelianoa/iris-channels\n\nyarn add @aurelianoa/iris-channels\n\npnpm add @aurelianoa/iris-channels\n```\n\n## Usage\n\nThe `iris-channels` package provides a number of functions for creating and using channels, including:\n\n* `broadcast(address _network, string memory eventIndex, bytes memory data)`: Broadcasts an event to the specified network.\n* `onReceivedMessage(address channel, string memory eventIndex)`: Called when a new message is received.\n* `compareIndex(string memory a, string memory b)`: Compares two event indices.\n\n\nThe `iris-channels` package can be used to create a variety of applications, such as:\n\n* A distributed chat application.\n* A decentralized application that needs to broadcast events to a network of smart contracts.\n* A system for tracking the progress of a distributed project.\n\n## Example\n\n```bash\n/// @notice The MyChannel smart contract is the responsible to broadcast the events\n\nimport { Channel } from \"@aurelianoa/iris-channels/contracts/channel/Channel.sol\";\n\ncontract MyChannel is Channel {\n  address public network;\n\n  constructor(address _network) {\n    /// Register the network address provided by the Iris protocol\n    network = _network;\n  }\n\n  function foo() public {\n    bytes memory data = abi.encode(var);\n    string memory vas = 'someEventIndex';\n    \n    /// broadcast the event with the 'vas' eventIndex\n    /// to the network address\n    // sending empty data\n    super.broadcast(network, vas, \"\");\n  }\n  \n  function fooWithData(string memory var) public {\n    bytes memory data = abi.encode(var);\n    string memory vas = \"someEventIndex\";\n    \n    /// broadcast the event with the 'vas' eventIndex\n    /// to the network address and some data\n    super.broadcast(network, vas, data);\n  }\n\n}\n\n/// @Notice MyListener Smart contract catches the event \"someEventIndex\" using onReceivedMessage using the helper compareIndex to catch the event.\n\nimport { Listener } from \"@aurelianoa/iris-channels/contracts/listener/Listener.sol\";\n\ncontract MyListener is Listener {\n  function onReceivedMessage(address sender, string memory eventIndex) internal override {\n        if(compareIndex(eventIndex, \"someEventIndex\")){\n            Message memory _lastMessage = lastMessages[sender];\n            string memory _result;\n            (_result) = abi.decode(_lastMessage.data, (string));\n            /// insert your logic here \n        }\n    }\n}\n\n```\n\nThis code creates a channel called MyChannel and a listener. The listener listens for events on the channel with the event index eventIndex. When a new event is received, the listener calls the `onReceivedMessage` function, which does something with the event.\n\nTo run this code, you will need to compile it using the Solidity compiler. Once the code is compiled, you can deploy it to the Iris network.\n\n# Imports\n\n## Channel.sol\n\nThis contract defines a generic channel that can be used to broadcast events to a network.\n\n## Imports\n\n* `IChannel`: The interface that the contract implements to broadcats messages.\n\n## Functions\n\n* `broadcast(address _network, string memory eventIndex, bytes memory data)`: Broadcasts an event to the specified network.\n* `supportsIChannelInterface(bytes4 interfaceId)`: Returns whether or not this contract supports the `IChannel` interface.\n\n\n## Listener.sol\n\nThis contract implements the `IListener` interface and provides a way for listeners to listen to events on a channel.\n\n## Imports\n\n* `IListener`: The interface that this contract implements.\n\n## Functions\n\n* `listen(address channel, string memory eventIndex, bytes memory data)`: Listens to an event on the specified channel.\n* `onReceivedMessage(address channel, string memory eventIndex)`: Called when a new message is received.\n* `compareIndex(string memory a, string memory b)`: Compares two event indices.\n* `supportsIListenerInterface(bytes4 interfaceId)`: Returns whether or not this contract supports the `IListener` interface.\n\n## License\n\nThis code is licensed under the MIT license.\n\n","readmeFilename":"README.md","_id":"@aurelianoa/iris-channels@1.1.0-beta.0","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-CWXZiBPMsCSfig4lvFQs2kkeFszyiNZCkbGxnmaIm5VDpDHP3G3gCViiQLEWpJXWbEufNxSAuMMNikeFpvnSIw==","shasum":"a55bf36dfa7c81af1dee7395404de4a0b0ab0f97","tarball":"https://registry.npmjs.org/@aurelianoa/iris-channels/-/iris-channels-1.1.0-beta.0.tgz","fileCount":10,"unpackedSize":9949,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCbdNLZ/8mrm3tTDgdM1B/sCPD7a623cTmh6Rym/0zYaAIgJ6oi6KB6Sany8iZqbYvr3/NH7Xm24q75j2zf2uu624I="}]},"_npmUser":{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"},"directories":{},"maintainers":[{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iris-channels_1.1.0-beta.0_1691595523684_0.21361653556122073"},"_hasShrinkwrap":false},"1.1.0-beta.1":{"name":"@aurelianoa/iris-channels","version":"1.1.0-beta.1","description":"Package to setup a channel fo your smart contracts","repository":{"type":"git","url":"git+https://github.com/aurelianoa/iris-channels.git"},"author":{"name":"@aurealarcon aurelianoa.eth"},"license":"MIT","private":false,"devDependencies":{},"bugs":{"url":"https://github.com/aurelianoa/iris-channels/issues"},"homepage":"https://github.com/aurelianoa/iris-channels#readme","scripts":{"test":"mocha"},"keywords":["Solidity","Metadata"],"gitHead":"09a6f9f60073f61c68ee2456e31c62b11c4618c6","readme":"# Iris Channels\n\nThe `iris-channels` package is a library for creating and using channels on the Iris protocol. Channels are a way to broadcast events to a network of contracts.\n\n## How to install\n\n```bash\nnpm install @aurelianoa/iris-channels\n\nyarn add @aurelianoa/iris-channels\n\npnpm add @aurelianoa/iris-channels\n```\n\n## Usage\n\nThe `iris-channels` package provides a number of functions for creating and using channels, including:\n\n* `broadcast(address _network, string memory eventIndex, bytes memory data)`: Broadcasts an event to the specified network.\n* `onReceivedMessage(address channel, string memory eventIndex)`: Called when a new message is received.\n* `compareIndex(string memory a, string memory b)`: Compares two event indices.\n\n\nThe `iris-channels` package can be used to create a variety of applications, such as:\n\n* A distributed chat application.\n* A decentralized application that needs to broadcast events to a network of smart contracts.\n* A system for tracking the progress of a distributed project.\n\n## Example\n\n```bash\n/// @notice The MyChannel smart contract is the responsible to broadcast the events\n\nimport { Channel } from \"@aurelianoa/iris-channels/contracts/channel/Channel.sol\";\n\ncontract MyChannel is Channel {\n  address public network;\n\n  constructor(address _network) {\n    /// Register the network address provided by the Iris protocol\n    network = _network;\n  }\n\n  function foo() public {\n    bytes memory data = abi.encode(var);\n    string memory vas = 'someEventIndex';\n    \n    /// broadcast the event with the 'vas' eventIndex\n    /// to the network address\n    // sending empty data\n    super.broadcast(network, vas, \"\");\n  }\n  \n  function fooWithData(string memory var) public {\n    bytes memory data = abi.encode(var);\n    string memory vas = \"someEventIndex\";\n    \n    /// broadcast the event with the 'vas' eventIndex\n    /// to the network address and some data\n    super.broadcast(network, vas, data);\n  }\n\n}\n\n/// @Notice MyListener Smart contract catches the event \"someEventIndex\" using onReceivedMessage using the helper compareIndex to catch the event.\n\nimport { Listener } from \"@aurelianoa/iris-channels/contracts/listener/Listener.sol\";\n\ncontract MyListener is Listener {\n  function onReceivedMessage(address sender, string memory eventIndex) internal override {\n        if(compareIndex(eventIndex, \"someEventIndex\")){\n            Message memory _lastMessage = lastMessages[sender];\n            string memory _result;\n            (_result) = abi.decode(_lastMessage.data, (string));\n            /// insert your logic here \n        }\n    }\n}\n\n```\n\nThis code creates a channel called MyChannel and a listener. The listener listens for events on the channel with the event index eventIndex. When a new event is received, the listener calls the `onReceivedMessage` function, which does something with the event.\n\nTo run this code, you will need to compile it using the Solidity compiler. Once the code is compiled, you can deploy it to the Iris network.\n\n# Imports\n\n## Channel.sol\n\nThis contract defines a generic channel that can be used to broadcast events to a network.\n\n## Imports\n\n* `IChannel`: The interface that the contract implements to broadcats messages.\n\n## Functions\n\n* `broadcast(address _network, string memory eventIndex, bytes memory data)`: Broadcasts an event to the specified network.\n* `supportsIChannelInterface(bytes4 interfaceId)`: Returns whether or not this contract supports the `IChannel` interface.\n\n\n## Listener.sol\n\nThis contract implements the `IListener` interface and provides a way for listeners to listen to events on a channel.\n\n## Imports\n\n* `IListener`: The interface that this contract implements.\n\n## Functions\n\n* `listen(address channel, string memory eventIndex, bytes memory data)`: Listens to an event on the specified channel.\n* `onReceivedMessage(address channel, string memory eventIndex)`: Called when a new message is received.\n* `compareIndex(string memory a, string memory b)`: Compares two event indices.\n* `supportsIListenerInterface(bytes4 interfaceId)`: Returns whether or not this contract supports the `IListener` interface.\n\n## License\n\nThis code is licensed under the MIT license.\n\n","readmeFilename":"README.md","_id":"@aurelianoa/iris-channels@1.1.0-beta.1","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-S8/H46qyrkv/O5bxPA1nZISIRZlbqVVQ+qfZNytbr/4ixdTkLbWhUZK/KturDLHNgF+R5oTkuuINPSx8PGjUDw==","shasum":"e7d0ba5d24c0ecd6d009db7c429d1b9ccea7dfd8","tarball":"https://registry.npmjs.org/@aurelianoa/iris-channels/-/iris-channels-1.1.0-beta.1.tgz","fileCount":10,"unpackedSize":9917,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC8RziV17yGBg0ASzdnzlutkFxVcmWwt2rkvRyp0B4VDQIhAI989wJWZ97XHggmp4qNuPfLWiZYM5jRwHjt0djEJXxi"}]},"_npmUser":{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"},"directories":{},"maintainers":[{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iris-channels_1.1.0-beta.1_1691678475569_0.930740030696743"},"_hasShrinkwrap":false},"1.1.0-beta.2":{"name":"@aurelianoa/iris-channels","version":"1.1.0-beta.2","description":"Package to setup a channel fo your smart contracts","repository":{"type":"git","url":"git+https://github.com/aurelianoa/iris-channels.git"},"author":{"name":"@aurealarcon aurelianoa.eth"},"license":"MIT","private":false,"devDependencies":{},"bugs":{"url":"https://github.com/aurelianoa/iris-channels/issues"},"homepage":"https://github.com/aurelianoa/iris-channels#readme","scripts":{"test":"mocha"},"keywords":["Solidity","Metadata"],"gitHead":"1d2ad147b0e9a190811d97fc471d38c608e7e759","readme":"# Iris Channels\n\nThe `iris-channels` package is a library for creating and using channels on the Iris protocol. Channels are a way to broadcast events to a network of contracts.\n\n## How to install\n\n```bash\nnpm install @aurelianoa/iris-channels\n\nyarn add @aurelianoa/iris-channels\n\npnpm add @aurelianoa/iris-channels\n```\n\n## Usage\n\nThe `iris-channels` package provides a number of functions for creating and using channels, including:\n\n* `broadcast(address _network, string memory eventIndex, bytes memory data)`: Broadcasts an event to the specified network.\n* `onReceivedMessage(address channel, string memory eventIndex)`: Called when a new message is received.\n* `compareIndex(string memory a, string memory b)`: Compares two event indices.\n\n\nThe `iris-channels` package can be used to create a variety of applications, such as:\n\n* A distributed chat application.\n* A decentralized application that needs to broadcast events to a network of smart contracts.\n* A system for tracking the progress of a distributed project.\n\n## Example\n\n```bash\n/// @notice The MyChannel smart contract is the responsible to broadcast the events\n\nimport { Channel } from \"@aurelianoa/iris-channels/contracts/channel/Channel.sol\";\n\ncontract MyChannel is Channel {\n  address public network;\n\n  constructor(address _network) {\n    /// Register the network address provided by the Iris protocol\n    network = _network;\n  }\n\n  function foo() public {\n    bytes memory data = abi.encode(var);\n    string memory vas = 'someEventIndex';\n    \n    /// broadcast the event with the 'vas' eventIndex\n    /// to the network address\n    // sending empty data\n    super.broadcast(network, vas, \"\");\n  }\n  \n  function fooWithData(string memory var) public {\n    bytes memory data = abi.encode(var);\n    string memory vas = \"someEventIndex\";\n    \n    /// broadcast the event with the 'vas' eventIndex\n    /// to the network address and some data\n    super.broadcast(network, vas, data);\n  }\n\n}\n\n/// @Notice MyListener Smart contract catches the event \"someEventIndex\" using onReceivedMessage using the helper compareIndex to catch the event.\n\nimport { Listener } from \"@aurelianoa/iris-channels/contracts/listener/Listener.sol\";\n\ncontract MyListener is Listener {\n  function onReceivedMessage(address sender, string memory eventIndex) internal override {\n        if(compareIndex(eventIndex, \"someEventIndex\")){\n            Message memory _lastMessage = lastMessages[sender];\n            string memory _result;\n            (_result) = abi.decode(_lastMessage.data, (string));\n            /// insert your logic here \n        }\n    }\n}\n\n```\n\nThis code creates a channel called MyChannel and a listener. The listener listens for events on the channel with the event index eventIndex. When a new event is received, the listener calls the `onReceivedMessage` function, which does something with the event.\n\nTo run this code, you will need to compile it using the Solidity compiler. Once the code is compiled, you can deploy it to the Iris network.\n\n# Imports\n\n## Channel.sol\n\nThis contract defines a generic channel that can be used to broadcast events to a network.\n\n## Imports\n\n* `IChannel`: The interface that the contract implements to broadcats messages.\n\n## Functions\n\n* `broadcast(address _network, string memory eventIndex, bytes memory data)`: Broadcasts an event to the specified network.\n* `supportsIChannelInterface(bytes4 interfaceId)`: Returns whether or not this contract supports the `IChannel` interface.\n\n\n## Listener.sol\n\nThis contract implements the `IListener` interface and provides a way for listeners to listen to events on a channel.\n\n## Imports\n\n* `IListener`: The interface that this contract implements.\n\n## Functions\n\n* `listen(address channel, string memory eventIndex, bytes memory data)`: Listens to an event on the specified channel.\n* `onReceivedMessage(address channel, string memory eventIndex)`: Called when a new message is received.\n* `compareIndex(string memory a, string memory b)`: Compares two event indices.\n* `supportsIListenerInterface(bytes4 interfaceId)`: Returns whether or not this contract supports the `IListener` interface.\n\n## License\n\nThis code is licensed under the MIT license.\n\n","readmeFilename":"README.md","_id":"@aurelianoa/iris-channels@1.1.0-beta.2","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-2IygI/0zluizKUeyroYxU6A998Y2+cPoH49eu6Ut3QNysXLWAjLZ54FXj47SN1tKqFEG+pRiCa7K3dT4fX/ZRg==","shasum":"472e3932431ecbcdcb27f341823568fe80eed3da","tarball":"https://registry.npmjs.org/@aurelianoa/iris-channels/-/iris-channels-1.1.0-beta.2.tgz","fileCount":10,"unpackedSize":10783,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDL4ge4PerlXpOjT20gLbtcSUCFV58dp2GxZ46zf0fUCAiB/+aVtWmZlXhJPbl3VR4sEYhfek04SqtSTra8FrPTC0A=="}]},"_npmUser":{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"},"directories":{},"maintainers":[{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iris-channels_1.1.0-beta.2_1691764535015_0.8854387668842394"},"_hasShrinkwrap":false},"1.1.0-beta.3":{"name":"@aurelianoa/iris-channels","version":"1.1.0-beta.3","description":"Package to setup a channel fo your smart contracts","repository":{"type":"git","url":"git+https://github.com/aurelianoa/iris-channels.git"},"author":{"name":"@aurealarcon aurelianoa.eth"},"license":"MIT","private":false,"devDependencies":{},"bugs":{"url":"https://github.com/aurelianoa/iris-channels/issues"},"homepage":"https://github.com/aurelianoa/iris-channels#readme","scripts":{"test":"mocha"},"keywords":["Solidity","Metadata"],"readme":"# Iris Channels\n\nThe `iris-channels` package is a library for creating and using channels on the Iris protocol. Channels are a way to broadcast events to a network of contracts.\n\n## How to install\n\n```bash\nnpm install @aurelianoa/iris-channels\n\nyarn add @aurelianoa/iris-channels\n\npnpm add @aurelianoa/iris-channels\n```\n\n## Usage\n\nThe `iris-channels` package provides a number of functions for creating and using channels, including:\n\n* `broadcast(address _network, string memory eventIndex, bytes memory data)`: Broadcasts an event to the specified network.\n* `onReceivedMessage(address channel, string memory eventIndex)`: Called when a new message is received.\n* `compareIndex(string memory a, string memory b)`: Compares two event indices.\n\n\nThe `iris-channels` package can be used to create a variety of applications, such as:\n\n* A distributed chat application.\n* A decentralized application that needs to broadcast events to a network of smart contracts.\n* A system for tracking the progress of a distributed project.\n\n## Example\n\n```bash\n/// @notice The MyChannel smart contract is the responsible to broadcast the events\n\nimport { Channel } from \"@aurelianoa/iris-channels/contracts/channel/Channel.sol\";\n\ncontract MyChannel is Channel {\n  address public network;\n\n  constructor(address _network) {\n    /// Register the network address provided by the Iris protocol\n    network = _network;\n  }\n\n  function foo() public {\n    bytes memory data = abi.encode(var);\n    string memory vas = 'someEventIndex';\n    \n    /// broadcast the event with the 'vas' eventIndex\n    /// to the network address\n    // sending empty data\n    super.broadcast(network, vas, \"\");\n  }\n  \n  function fooWithData(string memory var) public {\n    bytes memory data = abi.encode(var);\n    string memory vas = \"someEventIndex\";\n    \n    /// broadcast the event with the 'vas' eventIndex\n    /// to the network address and some data\n    super.broadcast(network, vas, data);\n  }\n\n}\n\n/// @Notice MyListener Smart contract catches the event \"someEventIndex\" using onReceivedMessage using the helper compareIndex to catch the event.\n\nimport { Listener } from \"@aurelianoa/iris-channels/contracts/listener/Listener.sol\";\n\ncontract MyListener is Listener {\n  function onReceivedMessage(address sender, string memory eventIndex) internal override {\n        if(compareIndex(eventIndex, \"someEventIndex\")){\n            Message memory _lastMessage = lastMessages[sender];\n            string memory _result;\n            (_result) = abi.decode(_lastMessage.data, (string));\n            /// insert your logic here \n        }\n    }\n}\n\n```\n\nThis code creates a channel called MyChannel and a listener. The listener listens for events on the channel with the event index eventIndex. When a new event is received, the listener calls the `onReceivedMessage` function, which does something with the event.\n\nTo run this code, you will need to compile it using the Solidity compiler. Once the code is compiled, you can deploy it to the Iris network.\n\n# Imports\n\n## Channel.sol\n\nThis contract defines a generic channel that can be used to broadcast events to a network.\n\n## Imports\n\n* `IChannel`: The interface that the contract implements to broadcats messages.\n\n## Functions\n\n* `broadcast(address _network, string memory eventIndex, bytes memory data)`: Broadcasts an event to the specified network.\n* `supportsIChannelInterface(bytes4 interfaceId)`: Returns whether or not this contract supports the `IChannel` interface.\n\n\n## Listener.sol\n\nThis contract implements the `IListener` interface and provides a way for listeners to listen to events on a channel.\n\n## Imports\n\n* `IListener`: The interface that this contract implements.\n\n## Functions\n\n* `listen(address channel, string memory eventIndex, bytes memory data)`: Listens to an event on the specified channel.\n* `onReceivedMessage(address channel, string memory eventIndex)`: Called when a new message is received.\n* `compareIndex(string memory a, string memory b)`: Compares two event indices.\n* `supportsIListenerInterface(bytes4 interfaceId)`: Returns whether or not this contract supports the `IListener` interface.\n\n## License\n\nThis code is licensed under the MIT license.\n\n","readmeFilename":"README.md","gitHead":"cc47dd93e25ab879e1e00875a93f4af7bd9a85ae","_id":"@aurelianoa/iris-channels@1.1.0-beta.3","_nodeVersion":"20.3.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-31t9QBqSAGbPD5uKqsQto7VifzXlo30Wt0vfowGy/9hlGkpaW6rscdiQBLn/8Eh2Bnd+GO7OTFU5LNrfYu+Ogg==","shasum":"59954045a27b90bed615d8d3b3b4f0ae31fcbc78","tarball":"https://registry.npmjs.org/@aurelianoa/iris-channels/-/iris-channels-1.1.0-beta.3.tgz","fileCount":10,"unpackedSize":11192,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBdPxC1OXd8BIh4Gz5j4Wyjrdf8GAxsnsR/nNDs8hZ2YAiB/yH/Jcbs3VcosRNfQGs4QpRyIdjVDH+dyVWns/Ich1A=="}]},"_npmUser":{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"},"directories":{},"maintainers":[{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/iris-channels_1.1.0-beta.3_1692018917211_0.0165081157509408"},"_hasShrinkwrap":false}},"time":{"created":"2023-06-20T12:12:11.694Z","1.0.0":"2023-06-20T12:12:11.930Z","modified":"2023-08-14T13:15:17.584Z","1.0.1":"2023-06-30T14:01:38.584Z","1.0.2":"2023-07-10T12:53:25.969Z","1.0.3":"2023-07-12T19:34:50.246Z","1.1.0":"2023-07-21T14:00:26.491Z","1.1.0-beta.0":"2023-08-09T15:38:43.852Z","1.1.0-beta.1":"2023-08-10T14:41:15.790Z","1.1.0-beta.2":"2023-08-11T14:35:35.232Z","1.1.0-beta.3":"2023-08-14T13:15:17.409Z"},"maintainers":[{"name":"aurelianoa","email":"aureliano.alarcon@gmail.com"}],"description":"Package to setup a channel fo your smart contracts","homepage":"https://github.com/aurelianoa/iris-channels#readme","keywords":["Solidity","Metadata"],"repository":{"type":"git","url":"git+https://github.com/aurelianoa/iris-channels.git"},"author":{"name":"@aurealarcon aurelianoa.eth"},"bugs":{"url":"https://github.com/aurelianoa/iris-channels/issues"},"license":"MIT","readme":"","readmeFilename":""}