{"_id":"@decentrawise/graphenejs-ws","name":"@decentrawise/graphenejs-ws","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@decentrawise/graphenejs-ws","version":"1.0.0","description":"Pure JavaScript Graphene Protocol websocket interface for node.js and browsers.","browser":{"ws":false},"scripts":{"test":"BABEL_ENV=test mocha --require @babel/register --recursive","test:watch":"yarn test -- --watch","test:connection":"BABEL_ENV=test mocha --require @babel/register ./test/Connection --watch","test:api":"BABEL_ENV=test mocha --require @babel/register ./test/Api --watch","test:manager":"BABEL_ENV=test mocha --require @babel/register ./test/Manager --watch","pretest:browser":"NODE_ENV=dev browserify test/*.js -o browser-test/browser-test.js -t [ babelify ]","test:browser":"BABEL_ENV=test http-server ./browser-test","clean":"rm -rf ./lib/* & rm -rf ./build/*","prebuild":"yarn run clean","build":"babel src -d lib","postbuild":"yarn run browserify","prepare":"yarn run build","browserify":"cross-env NODE_ENV=production browserify lib/index.js --standalone graphene_ws -o build/graphenejs-ws.js -d","postbrowserify":"cross-env NODE_ENV=production minify build/graphenejs-ws.js --mangle --outFile build/graphenejs-ws.min.js"},"repository":{"type":"git","url":"git+https://github.com/decentrawise/graphenejs-ws.git"},"license":"MIT","bugs":{"url":"https://github.com/decentrawise/graphenejs-ws/issues"},"engines":{"node":">=16.13.x","npm":">=8.2.x","yarn":">=1.22.x"},"main":"lib/index.js","dependencies":{"isomorphic-ws":"^4.0.1","ws":"^8.4.0"},"devDependencies":{"@babel/cli":"^7.16.0","@babel/core":"^7.16.5","@babel/plugin-proposal-class-properties":"^7.16.5","@babel/preset-env":"^7.16.5","@babel/register":"^7.16.5","assert":"^2.0.0","babel-minify":"^0.5.2","babel-preset-minify":"^0.5.1","babelify":"^10.0.0","browserify":"^17.0.0","cross-env":"^7.0.3","http-server":"^14.0.0","mocha":"^9.1.3"},"licenseText":"Copyright (c) Graphene Protocol contributors\n\nMIT License\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@decentrawise/graphenejs-ws@1.0.0","dist":{"shasum":"35d7c0d71debef7d530d29b677236450835a7cb8","integrity":"sha512-c5RJWIFlxIpG6QOI2oW4vts43pXHXeE3nKFfPuPIlbo65saf08n7NaNlxdJ28ePZS7yWjdLjFwJtJFwmEc2JTQ==","tarball":"https://registry.npmjs.org/@decentrawise/graphenejs-ws/-/graphenejs-ws-1.0.0.tgz","fileCount":16,"unpackedSize":20637,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCzb7Ia5Zi0f+zNNBjdraxy0LXrbhXpVRRjqlcE2x+i9wIgEP16VDcwheGf5rOwkIaX+CNwHeil23xGXEjlY6vxxL4="}]},"_npmUser":{"name":"prc","email":"prcolaco@gmail.com"},"directories":{},"maintainers":[{"name":"prc","email":"prcolaco@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphenejs-ws_1.0.0_1709224277306_0.254135065625013"},"_hasShrinkwrap":false}},"time":{"created":"2024-02-29T16:31:17.230Z","1.0.0":"2024-02-29T16:31:17.453Z","modified":"2024-02-29T16:31:17.992Z"},"maintainers":[{"name":"prc","email":"prcolaco@gmail.com"}],"description":"Pure JavaScript Graphene Protocol websocket interface for node.js and browsers.","repository":{"type":"git","url":"git+https://github.com/decentrawise/graphenejs-ws.git"},"bugs":{"url":"https://github.com/decentrawise/graphenejs-ws/issues"},"license":"MIT","readme":"# Graphene websocket interface (graphenejs-ws)\n\nPure JavaScript Graphene websocket library for node.js and browsers. Can be used to easily connect to and obtain data from any Graphene blockchain via public apis or local nodes.\n\n\n## Setup\n\nThis library can be obtained through npm:\n```\nnpm install --save @decentrawise/graphenejs-ws\n```\nor\n```\nyarn add @decentrawise/graphenejs-ws\n```\n\n## Usage\n\nSeveral examples are available in the /examples folder, and the tests in /test also show how to use the library.\n\nBrowser bundles are provided in /build/.\n\nA variable `graphene_ws` will be available in `window` object.\n\nFor use in a webpack/browserify context, see the example below for how to open a websocket connection to an API and subscribe to any object updates:\n\n```\nvar {Apis} = require(\"graphenejs-ws\");\nApis.instance(\"ws://127.0.0.1:8090\", true).init_promise.then((res) => {\n    console.log(\"connected to:\", res[0].network);\n    Apis.db.set_subscribe_callback( updateListener, true )\n});\n\nfunction updateListener(object) {\n    console.log(\"set_subscribe_callback:\\n\", object);\n}\n```\nThe `set_subscribe_callback` callback (updateListener) will be called whenever an object on the blockchain changes or is removed. This is very powerful and can be used to listen to updates for specific accounts, assets or almost anything else, as all state changes happen through object updates. Be aware though that you will receive quite a lot of data this way.\n\n\n## Public API \n\n### Database API\n\nTo access the Database API, you can use the `Apis.db` object.\n\n__Usage example__\n`Apis.db.get_objects([\"1.3.0\", \"2.0.0\", \"2.1.0\"])`\n\n### History API\n\nTo access the Account History API, you can use the `Apis.history` object.\n\n__Usage example__\n`Apis.history.get_account_history(\"1.2.849826\", \"1.11.0\", 10, \"1.11.0\")`\n\n## Tests\n\nThe tests show several use cases, to run, simply type `yarn test`. The tests require a local Graphene node to be running, as well as an active internet connection.\n","readmeFilename":"README.md"}