{"_id":"@cogitojs/cogito-ethereum","_rev":"4-e5d4ad3d7b8cdfdd42c61e836cc0ad83","name":"@cogitojs/cogito-ethereum","dist-tags":{"latest":"0.3.0"},"versions":{"0.2.19":{"name":"@cogitojs/cogito-ethereum","version":"0.2.19","description":"Convenience package for using Cogito with Ethereum","homepage":"https://cogito.mobi","license":"MIT","main":"lib/index.js","module":"es/index.js","scripts":{"build":"node ./tools/build.js"},"engines":{"node":">=9.0.0"},"devDependencies":{"nock":"^9.2.5"},"dependencies":{"@cogitojs/cogito-web3-provider":"^0.2.19","@cogitojs/telepath-js":"^0.2.19","libsodium-wrappers":"^0.7.2","truffle-contract":"^3.0.5","web3":"^1.0.0-beta.36"},"publishConfig":{"access":"public"},"gitHead":"e1e293e20c36b248606cc79820652e5336c856dc","_resolved":"","_integrity":"","_from":"file:cogitojs-cogito-ethereum-0.2.19.tgz","_id":"@cogitojs/cogito-ethereum@0.2.19","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"everydayproductive","email":"marcin@everydayproductive.com"},"dist":{"integrity":"sha512-AiaHdUSwHiq33wcF9ubE3zdW4bO9lt/33/JIO3lXAxxfE4Xx83ScIbVTPpbukWciF58fFReuMEvHbLeqc2Kedg==","shasum":"a253d8b762e20b9a3dc8c447c81421ab16c1a737","tarball":"https://registry.npmjs.org/@cogitojs/cogito-ethereum/-/cogito-ethereum-0.2.19.tgz","fileCount":26,"unpackedSize":50807,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcM4QNCRA9TVsSAnZWagAAwRsQAJABghUyhZjNUR4Fxqf0\nzawUcwWLbOM7PDtv9429ZUSV4ullP1ZUO8QdUSJougOvGJonpbiS+T2EbHN4\nMsL22uawLhFiJkWfXoC9OcJkWZzmTjDiA7HLnHWSnAookHUqjLgjts5Rcsoi\nza1iRsfRDZlUhiWtDYGO8ZNXh+P3iLJADN2DGBM39FAfv3E6T7kmLSQtFIwf\nWLJHPL4rG8+8GKOxtAHIOf3yAh4lFbwOp5RxG+ZwDewQlbI4KuxrTlr1PjPR\nZT+1u91m1FjgXbFLp7GKpmDuk7cgusZaZX9WUxh7LWY7Dev73GaJP13iDkVb\nNO1m+LJHg28CO9jdy/kwb9nCxKwL8J57yrco18MEoSnXVJZYvGxKdD4mbDd3\nMbviOYpqf35LWspAmdBLYEfB9oxP20KBOvRfI5Ul+isK4bl0e7rQ+/+oH6uP\nJm2xltcPy0SioIMhvBXwpWtWByI+eU47rZYRi7ZNk299q/RxcI3TBkK4ah7j\ncZVKTcN75VM/N+Mhz+yUmcr6Hv2iQzxTPkt0bMqTlGiEG94uibqwWjeN4f5D\nfCBufbBqKBbzu4NmO0tt7f5UhXmm3BR9TkvCGJeZgz04oJzXtiib+4aJoZVD\ng/QsYJeuC9HLZDhDXzqgPV6uzdSDCp4jhJzhpVufErxeOtpKJEgrlYeMnU24\nZpM1\r\n=aNEE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAd1/fW17Ru32NkrkQ02ade1+TNAPyfBtkqjkfkvpzTCAiEA3N97R5Fq7gB3o7whsJ/g8TwFQNwCGdqkXOx389EaROg="}]},"maintainers":[{"name":"everydayproductive","email":"marcin@everydayproductive.com"},{"name":"markspanbroek","email":"mark@spanbroek.net"},{"name":"jeroenknoops","email":"jeroen.knoops@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cogito-ethereum_0.2.19_1546880013126_0.6032148507822819"},"_hasShrinkwrap":false},"0.2.23":{"name":"@cogitojs/cogito-ethereum","version":"0.2.23","description":"Convenience package for using Cogito with Ethereum","homepage":"https://cogito.mobi","license":"MIT","main":"lib/index.js","module":"es/index.js","scripts":{"build":"node ./tools/build.js"},"engines":{"node":">=8.0.0"},"devDependencies":{"nock":"^9.2.5"},"dependencies":{"@cogitojs/cogito-web3-provider":"^0.2.23","@cogitojs/telepath-js":"^0.2.23","libsodium-wrappers":"^0.7.2","truffle-contract":"^3.0.5","web3":"^1.0.0-beta.36"},"publishConfig":{"access":"public"},"gitHead":"558949fc0d06f7d63e451c85dcb8fb6594c7cf71","_resolved":"","_integrity":"","_from":"file:cogitojs-cogito-ethereum-0.2.23.tgz","_id":"@cogitojs/cogito-ethereum@0.2.23","_npmVersion":"6.5.0-next.0","_nodeVersion":"11.6.0","_npmUser":{"name":"everydayproductive","email":"marcin@everydayproductive.com"},"dist":{"integrity":"sha512-IclSb1a3Hsbh9YsH3s2z4SjyUXA7jsPb+KG5be8MA0mEHQoJwkK5RgDywJxOvIVolTIskDfJy57hw2hl6DhCOw==","shasum":"4e9e038ee8f266e234d5c24f2ee60de83ee8e102","tarball":"https://registry.npmjs.org/@cogitojs/cogito-ethereum/-/cogito-ethereum-0.2.23.tgz","fileCount":26,"unpackedSize":49444,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcVFeNCRA9TVsSAnZWagAAq9UP/RciCEodSpNFkmf0zqMZ\njIf0pbcgf9wNr8FhdfTyJd2NoVSCfUGiar7ubBRRIG3CJHSWhM1G0J5ja91+\nE6AtjfOqVl56/A0rZV19aan5tnH/yx0skw9AQVt/C+xXhgxvfJgrjISLTc+W\nRC6O8LIZc+mDfml/0ICJqFqFjAjYZ6Tbqe2F2q3vegQ99DuTQzGwzQLlUIk5\niiEpr5lQ+BQhiLat5YhOKS8q8EgDkeFnn0jQCdBwfvttucKkoFlXSFBeERcQ\nZyN9Uhy4Yt+MrpZf7ccOSI2JKqwuhSTJoTAkbvSpw/hvdKZXlblS5oV2mj5u\nCl1xg6rzWOHHt/nSpDc5cTb/J0BYdu1xO86NLE6vLtSOB2ZNCwlV4WFcVmqY\nOqBjffStfxM5KWwORGGXEwxs+xV7Ea7FJz/CN/PSnOfGm1pLoIa7PqTMPASC\nTEwvjTe7p5HqTLGSlgQekk4U+fWt1EyqSWQbAtQ2YAK3JMWMUcMxplMa9+pb\nQ27B+CVl70ebRNAFXjfoaeMLBKHv9hvvMfxQNTQtHwd3NoW8uHAqFeWzjyAc\nirfIBTgQCt8rAvDPJeFNL8u1PWasVAiOByjfW9ZRmrDNAtRF8Dhume0vxxVp\nG+BvJnTaqsqL42c6igynh/LtSmnsdokGVCPFeg7ndoqA/l5FjI+V/dcCkmKK\nLtTE\r\n=YSTj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHxkq0yqaDwJhffrsuBJI3oRT2IoGeouxjyLvVd9NPqeAiEAkxHF+sFSbxHVF+wbOWH1g7dKk+7DBTiGDGr0kIdjP3A="}]},"maintainers":[{"name":"everydayproductive","email":"marcin@everydayproductive.com"},{"name":"jeroenknoops","email":"jeroen.knoops@gmail.com"},{"name":"markspanbroek","email":"mark@spanbroek.net"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cogito-ethereum_0.2.23_1549031308739_0.05339597697870491"},"_hasShrinkwrap":false},"0.3.0":{"name":"@cogitojs/cogito-ethereum","version":"0.3.0","description":"Convenience package for using Cogito with Ethereum","homepage":"https://cogito.mobi","license":"MIT","main":"lib/index.js","module":"es/index.js","scripts":{"build":"node ./tools/build.js"},"engines":{"node":">=8.0.0"},"devDependencies":{"nock":"^9.2.5"},"dependencies":{"@cogitojs/cogito-web3-provider":"^0.3.0","@cogitojs/telepath-js":"^0.3.0","libsodium-wrappers":"^0.7.2","truffle-contract":"^3.0.5","web3":"1.0.0-beta.36"},"publishConfig":{"access":"public"},"gitHead":"e6dfe2f2da5877de36fde1e9267096bc030b8d0d","_id":"@cogitojs/cogito-ethereum@0.3.0","_nodeVersion":"11.13.0","_npmVersion":"lerna/3.13.1/node@v11.13.0+x64 (darwin)","dist":{"integrity":"sha512-wP7gJ4hEmGm9pF4GjpYdiUKPfDqneQ4cVe+sGcWYnl6PoGl6hxDlhB8xLzR4dnYSph9eAQvZcPkTMl8sbQ855w==","shasum":"97e0e1ad5fc75dcc8cc83fd2d16dc6a4b3baa241","tarball":"https://registry.npmjs.org/@cogitojs/cogito-ethereum/-/cogito-ethereum-0.3.0.tgz","fileCount":27,"unpackedSize":46942,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcwBGjCRA9TVsSAnZWagAAvTIQAKGphAIlojNC9rmnLVvF\n+AuKGNVMefD64G8LoZQ2S1tvhpriyhaolOd5CrjMThb6wGzDoee68B5CSXN/\nJhelwFXgLV6qExIMsnzTWWtoE9O2AeoPU+UtOkPKqVPwQYimCuLsHmeCF7Yt\nYie7uADE3IQ5c0FVVcm8uEhIQq7K6gkqPx1A+EhcpwUFJ+wBSR5DFSDQU5fj\nv2i/tLayuzVCZpsxHrdKGK+Nu0CJrwIO03gBmRwGnQZY0UVFCCGzvELGt5kM\nMT5COybfKnwAcQSBp687iRD1jgKVGLuo+0z+PlKjW2j+9WCPhjzrP5U6lyvj\nW2b8NQyHsZ+aMipi1wwn3tmwpgr/mG0G4rJLX+AVtWMnKzJODy0DxyB5tnoL\nbT7z+uDwNUnB9khLYbmH09m/s9VDtP8CfVZz0yzCcN8ioe5eu5hDPpJGlwen\nEUPT2glippA6MwxLgjLDTcNSwg8cwRT9iQw7CLaobyE/mENWNOJGlKCCx9QC\nbllowLjIfCovMgpa8zX5xq5n6/PV+GSgttS+6szn0F4MmKJ3frlCc0DQCN+j\nt87FDNJOHieU91p84yDaScoZLlKHus18QJsSgbfknxJVoy0Y/P0uPbyD2ynY\nJjpQJnYdDgyMC8dhcp+kDF4ralG99eRkAJQje6gxDzCSt4Ypopl/1nibrVEN\n8/LA\r\n=mmFA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDElPNeC5WZA5pqogwffmVM7NTEEJoAYf0FJq7lrEVrvAIgTve0LRh3sTwBBelovApcspKveTbTtXCSuVfXIpfWAeo="}]},"maintainers":[{"email":"marcin@everydayproductive.com","name":"everydayproductive"},{"email":"jeroen.knoops@gmail.com","name":"jeroenknoops"},{"email":"mark@spanbroek.net","name":"markspanbroek"},{"email":"philips-software@philips.com","name":"philips-software-fa"}],"_npmUser":{"name":"jeroenknoops","email":"jeroen.knoops@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/cogito-ethereum_0.3.0_1556091298623_0.4028451484533264"},"_hasShrinkwrap":false}},"time":{"created":"2019-01-07T16:53:33.038Z","0.2.19":"2019-01-07T16:53:33.272Z","modified":"2022-04-05T00:11:06.914Z","0.2.23":"2019-02-01T14:28:28.927Z","0.3.0":"2019-04-24T07:34:58.813Z"},"maintainers":[{"email":"marcin@everydayproductive.com","name":"everydayproductive"},{"email":"jeroen.knoops@gmail.com","name":"jeroenknoops"},{"email":"mark@spanbroek.net","name":"markspanbroek"},{"email":"philips-software@philips.com","name":"philips-software-fa"}],"description":"Convenience package for using Cogito with Ethereum","homepage":"https://cogito.mobi","license":"MIT","readme":"# @cogitojs/cogito-ethereum\n\nProvides a means to interact with smart contracts on an Ethereum blockchain\nusing the Cogito app. Uses the accounts that are stored in the Cogito app on\nthe user's phone. Whenever a blockchain transaction is initiated, the user is\nprompted to sign it using the Cogito app.\n\nThis package aims to make working with [cogito-web3-provider], [telepath], and\n[Ethereum contracts] easier. You do not have know all the details about web3\nproviders, cogito-web3-provider, and telepath, in order to setup a working\ncogito ecosystem.\n\n## Usage\n\nAdd `@cogitojs/cogito-ethereum` as a dependency\n\n```bash\n$ yarn add `@cogitojs/cogito-ethereum`\n```\n\n`@cogitojs/cogito-ethereum`'s main abstraction is `CogitoEthereum`. Before we\nlearn how to use `CogitoEthereum`, we need first make sure we have a good\nunderstanding how CogitoEthereum handles the Ethereum contracts.\n\n## Working with Contracts\n\nDevelopers working with Ethereum contract often use a convenience package\n`truffle-contract`. To get an instance of a contract you first import\n`truffle-contract`. What you will get from importing `truffle-contract` is a\nfunction that takes a contract definition as an argument and returns a proxy\nobject that you can use to interact with your contract. Before you can do that,\nhowever, you still need to set the provider on the returned proxy object:\n\n```javascript\nimport Web3 from 'web3'\nimport initContract from 'truffle-contract'\nimport { SimpleStorage } from '@cogitojs/demo-app-contracts'\n\nconst providerUrl = 'http://localhost:9545' // example for the local development\nconst provider = new Web3.providers.HttpProvider(providerUrl)\nconst web3 = new Web3(provider)\nconst contractProxy = initContract(SimpleStorage())\ncontractProxy.setProvider(provider)\n// or if you got web3 already initialized\ncontractProxy.setProvider(web3.currentProvider)\n```\n\n> Please, note that `@cogitojs/demo-app-contracts` exports a function that\nreturns the actual contract JSON blob. We could also directly return a\nfunction, but that would make mocking with\n`jest.mock('@cogitojs/demo-app-contracts')` not possible. `jest.mock` can only\nmock exported functions. This is why in the snipped above we are calling\n`SimpleStorage()` instead of just using `SimpleStorage`. In the following\nexamples we will directly import JSON blobs from JSON files.\n\nTo get the actual instance of the contract, you can use one of the proxy\nmethods: `deployed()`, `at()`, or `new()`. Please refer to the documentation of\n[truffle-contract] for more information.\n\n\n## Creating an instance of CogitoEthereum\n\n`CogitoEtheruem` expects an array of contracts JSON blobs as the first\nconstructor argument:\n\n```javascript\nimport DataStoreJSON from 'contracts/DataStore.json'\nimport DataRequestJSON from 'contracts/DataRequest.json'\nimport DataResponseJSON from 'contracts/DataResponse.json'\nimport { CogitoEthereum } from '@cogitojs/cogito-ethereum'\n\nconst cogitoEthereum = new CogitoEthereum([ DataStoreJSON, DataRequestJSON, DataResponseJSON ])\n```\n\n`CogitoEtheruem` takes care for setting up a new `Web3` instance that uses the\n`CogitoProvider` from [@cogitojs/cogito-web3-provider] as the `currentProvider`\n(`cogitoWeb3`), the associated telepath channel (`telepathChannel`), and an\nobject with contract proxies corresponding to each contract JSON blob passed in\nthe first constructor argument (`contractsProxies`). `cogitoWeb3`,\n`telepathChannel`, and `contractsProxies` together are called a *context* and\ncan be retrieved using `CogitoEthereum` instance method: `getContext`:\n\n```javascript\nconst {\n  cogitoWeb3,\n  telepathChannel,\n  contractsProxies\n} = await cogitoEthereum.getContext({ appName: 'Demo App' })\n```\n\n`getContext` expect an object as an argument: `{ channelId, channelKey, appName\n}`. If `channelId` and/or `channelKey` are not provided, a new random value\nwill be created, and the resulting `channelId` and `channelKey` will be used to\ncreate a telepath channel instance. Notice, that the `appName` attribute is\nrequired.\n\nThe returned `telepathChannel` attribute refers to an instance of a\n`JsonRpcChannel` that is returned by the `createChannel` method of the instance\nof `Telepath`. It provides the channel id as `telepathChannel.id`, the channel\nkey as `telepathChannel.key`, allows to send a JSON-RPC `request` using\n`send(request)`, and provides a convenience method to get the telepath\nconnection url via `telepathChannel.createConnectUrl()`. This connection url\ncan be use to generate the QR-Code to be scanned by the Cogito app in order to\nestablish a secure connection with the JavaScript client. To learn more about\nTelepath, connection URLs, and QR-Codes, please refer to the documentation of\nthe [telepath-js] package.\n\n`cogitoWeb3` holds a reference to a valid `Web3` object that uses\n`CogitoProvider` as the provider. It means that requests for requesting\nEthereum accounts (`cogitoWeb3.eth.getAccounts()`, see also [eth_accounts]) or\nsending Ethereum transactions (`cogitoWeb3.eth.sendTransaction`, see also\n[eth_sendTransaction]) will be redirect to the client via associated telepath\nchannel.\n\nFinally, `contractsProxies` is an object with attributes referring to the\ncontract proxies corresponding to the provided contract JSON blobs. For\nexample:\n\n```javascript\nconst cogitoEthereum = new CogitoEthereum([ DataStore, DataRequest, DataResponse ])\nconst { contractsProxies } = await cogitoEthereum.getContext({ appName: 'Demo App' })\nconst { DataStore, DataRequest, DataResponse } = contractsProxies\nconst dataStoreContractInstance = await DataStore.deployed()\nconst dataRequestContractInstance = await DataRequest.at(await dataStoreContractInstance.getDataRequest())\nconst dataResponseContractInstance = await DataResponse.at(await dataStoreContractInstance.getDataResponse())\n```\n\nThe names of the attributes in the `contractsProxies` object correspond to the\nname of the contracts as given by the `contractName` attribute of the\ncorresponding contract JSON blob.\n\nFinally, `CogitoEthereum` accepts an optional second argument holding the\nqueuing service url to be used with telepath. The default is\n`https://telepath.cogito.mobi`.\n\n[truffle-contract]: https://github.com/trufflesuite/truffle/tree/develop/packages/truffle-contract\n[Web3]: https://github.com/ethereum/web3.js\n[cogito-web3-provider]: https://cogito.mobi/components/cogito-web3-provider\n[@cogitojs/cogito-web3-provider]: https://cogito.mobi/components/cogito-web3-provider\n[telepath]: https://cogito.mobi/components/telepath-js\n[telepath-js]: https://cogito.mobi/components/telepath-js\n[Ethereum contracts]: http://www.ethdocs.org/en/latest/contracts-and-transactions/index.html\n[eth_accounts]: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_accounts\n[eth_sendtransaction]: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sendtransaction\n","readmeFilename":"README.md"}