{"_id":"@aikon/eos-transit","_rev":"3-51d68034c6cc8b38ea8c23f898302316","name":"@aikon/eos-transit","dist-tags":{"latest":"4.0.9"},"versions":{"4.0.7":{"name":"@aikon/eos-transit","version":"4.0.7","description":"Wallet Access Layer for EOS Blockchain Networks - modified by AIKON to support non-eos plug-ins","license":"UNLICENSED","main":"lib/index.js","module":"lib/index.js","types":"lib","scripts":{"echo":"echo \"================== eos-transit ===================\"","installpkg":"yarn echo && npm install","clean":"rm -rf lib && rm -rf umd","prebuild":"yarn clean","build":"../../node_modules/typescript/bin/tsc","build-eosjs-bundle":"TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack --config webpack.config.eosjs.ts","build-production":"yarn build && TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack && yarn build-eosjs-bundle","watch":"../../node_modules/typescript/bin/tsc -w","test":"","lint":"../../node_modules/.bin/tslint -c ../../tslint.json -p ./tsconfig.json"},"dependencies":{"@types/uuid":"^7.0.3","eosjs":"^20.0.0","uuid":"^3.3.2"},"devDependencies":{"babel-core":"6.26.3","babel-loader":"7.1.5","babel-plugin-transform-runtime":"^6.23.0","babel-preset-env":"1.7.0","babel-preset-es2015":"6.24.1","babel-preset-stage-1":"6.24.1","webpack":"^4.25.1","webpack-cli":"^3.1.2"},"prettier":{"singleQuote":true,"printWidth":80,"tabWidth":2,"useTabs":false,"bracketSpacing":true},"gitHead":"6c02ebb063d6c0f8e23231dfcef9878a9e3e334d","licenseText":"MIT License\n\nCopyright (c) 2019 EOS New York\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":"@aikon/eos-transit@4.0.7","dist":{"shasum":"1efa16f6813fa3dfd833038292dc98e6c6c7d4a8","integrity":"sha512-+DSH3ZwRbFsm1Jo4j+Xd6WX5ojvLOAy/90mZbIso276BWbv43qwyQ8BkNOl+OUaULfO5meH846P64v7Ixj78Ag==","tarball":"https://registry.npmjs.org/@aikon/eos-transit/-/eos-transit-4.0.7.tgz","fileCount":27,"unpackedSize":341623,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgS8lACRA9TVsSAnZWagAArWMP/1ee6LwmfoB9kTBGgMwG\nQLYQiDI4/InnjbJShOTyLuXr/mfINUmOdyxFz7gg/SoPJpLxmrwH2dC8FOL6\n2g1JEdcBUMuEFoUn0IMz1WpU3fIxw11Og0a5co061BI5rv/06IFPVCfpTScV\nn2qOF4tUmfFQiWKZrQIB3i61SuwVhIPfGO1Lf6xOwpNP9jY3P0ldyrD3qGCq\nchQ/NOUqSg105dWtbrQvsqIEGEntlHaONg/O2qXIRo/WuXVanrqx1GkaP0dI\nCeDi6GIN4O58d132ugTTsBH0i0R8HrQvtroQwqel8S1Lfy4mSkGHyIKnG3yd\n3ZWBzsH7vy1jripORlhVWWGOFm9PgRgs5QF922k97Pix5Q1CJk3QBEmbsEV4\nJFZb3JN7QTWCoz42FSrifgMJPkpSiycTckWdwYVE9UVlU7PaFUnwF5lB06Ic\nNUiyers+pxLTxJbOlyQHIlWJeZRNDgH2fh2++5EeaUkLcMP3mZIEpESUVhjQ\nCZMiCar7pN0PTN4OvZxRq1bKc8XGX2Tf2j7B5wLp+qX0hW0G+ToERktnSTPG\n/24yyP/tB1jFp4oE+rJIrsHdyIvqmx+jI+zlBSbQAbE+cS5nyaZwxhjJ5Vcw\njudw2dFI3mXURgzLKa2E7hmQCoz5Eb/ZSayqbn2IpwKN3HgyQI2VduFhuo7U\nqrF0\r\n=ya63\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD+mZ/DIebRJBrf0R/4iS2DoyWPOxW6P9ldPoEd7buz4gIhAITro5HFhDW1yb5MG6JRFVDuLO070mqRqMs2A97ts6Jh"}]},"_npmUser":{"name":"apimarket","email":"info@aikon.com"},"directories":{},"maintainers":[{"name":"apimarket","email":"info@aikon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eos-transit_4.0.7_1615579456019_0.8931358528988194"},"_hasShrinkwrap":false},"4.0.8":{"name":"@aikon/eos-transit","version":"4.0.8","description":"Wallet Access Layer for EOS Blockchain Networks - modified by AIKON to support non-eos plug-ins","license":"UNLICENSED","main":"lib/index.js","module":"lib/index.js","types":"lib","scripts":{"echo":"echo \"================== eos-transit ===================\"","installpkg":"yarn echo && npm install","clean":"rm -rf lib && rm -rf umd","prebuild":"yarn clean","build":"../../node_modules/typescript/bin/tsc","build-eosjs-bundle":"TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack --config webpack.config.eosjs.ts","build-production":"yarn build && TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack && yarn build-eosjs-bundle","watch":"../../node_modules/typescript/bin/tsc -w","test":"","lint":"../../node_modules/.bin/tslint -c ../../tslint.json -p ./tsconfig.json"},"dependencies":{"@types/uuid":"^7.0.3","eosjs":"^20.0.0","uuid":"^3.3.2"},"devDependencies":{"babel-core":"6.26.3","babel-loader":"7.1.5","babel-plugin-transform-runtime":"^6.23.0","babel-preset-env":"1.7.0","babel-preset-es2015":"6.24.1","babel-preset-stage-1":"6.24.1","webpack":"^4.25.1","webpack-cli":"^3.1.2"},"prettier":{"singleQuote":true,"printWidth":80,"tabWidth":2,"useTabs":false,"bracketSpacing":true},"gitHead":"6c02ebb063d6c0f8e23231dfcef9878a9e3e334d","_id":"@aikon/eos-transit@4.0.8","_nodeVersion":"12.12.0","_npmVersion":"6.13.6","dist":{"integrity":"sha512-YE/kROgzT74LfTasWL/J3fe/VaQjjoO21sHjrHJy21uXRWhb+UY2/aGO3U5iNILuMy+O+ujPmikZMhiTVWtQWw==","shasum":"7bf2a6eead0f232d724f80576b800b53c3ce9e5d","tarball":"https://registry.npmjs.org/@aikon/eos-transit/-/eos-transit-4.0.8.tgz","fileCount":21,"unpackedSize":100590,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg+HHoCRA9TVsSAnZWagAA3VYQAIQV9XjHtVTwX7iMFmro\ngiLlGeHFdZsoJDG1oJnO1MHgcmFyigPj2ph060fIxLUbeEXh9xPNYKLnfFFE\ndKvQaej1sv305xrmV0VpWnQ0kY5k2KRdW6L0q23nn3vS5wnQOcGp6cCmcYK4\na22oddZHVsU8+Aobo0TKUEkkYFfMIM2eduEQVCobXaV/d+H22BKyUGhzu+fT\nervt2+7IDElftbG/s9aqxv5H4IihrfiKgT3YTaGrPCgONfOlxeS0SZT2H+g6\nMOjQNxEdU1RyfoeEGWlE+hBaVrbiF6YH+basSai7WlLH1QAhYvaxF/f7kty0\ncwKPCbJO0xsTalwhWywbN6OqxFhL2fKuH/FiY2mWt3qZNncGXstcYlGYIGFH\nx3nqutc2m9PviaasZNxMYXjsHB61s4QpR3cZzNJHKIaK9vRx3DTwl/Zk8fgY\nwsUOS4xRkhq8D6d+w5ldB9eaDjIZNJ4TwgcdkFa0JGoXmA+kMbd+yicnp3ay\noMppencVnfvK0y2OIIDc9MNC+KVV+8eFORl4b97jUsaRoqlak4xV56fq5PAJ\nG+3SJTS97oG/GvifMtIGIIYAgAv0JvkTXNXT83QgeBytp+9+df6IAXIBBQps\nOdrL7dGzbs8w1NRKAnIUz2xlP1cgz1IyMjUBalPviVlMJiVWmGIg4PTA4Q5n\nun1K\r\n=jcmo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD2A3U6SIq5XujbM9Ck70seH0rjv+kU9/W3bKgwDlSwogIgYSfqjSNKapduQ763m84T0DC1Ny923CqoDbV8HYG01+E="}]},"_npmUser":{"name":"apimarket","email":"info@aikon.com"},"directories":{},"maintainers":[{"name":"apimarket","email":"info@aikon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eos-transit_4.0.8_1626894823957_0.9096684395743964"},"_hasShrinkwrap":false},"4.0.9":{"name":"@aikon/eos-transit","version":"4.0.9","description":"Wallet Access Layer for EOS Blockchain Networks - modified by AIKON to support non-eos plug-ins","license":"UNLICENSED","main":"lib/index.js","module":"lib/index.js","types":"lib","scripts":{"echo":"echo \"================== eos-transit ===================\"","installpkg":"yarn echo && npm install","clean":"rm -rf lib && rm -rf umd","prebuild":"yarn clean","build":"../../node_modules/typescript/bin/tsc","build-eosjs-bundle":"TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack --config webpack.config.eosjs.ts","build-production":"yarn build && TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack && yarn build-eosjs-bundle","watch":"../../node_modules/typescript/bin/tsc -w","test":"","lint":"../../node_modules/.bin/tslint -c ../../tslint.json -p ./tsconfig.json"},"dependencies":{"@types/uuid":"^7.0.3","eosjs":"^20.0.0","uuid":"^3.3.2"},"devDependencies":{"babel-core":"6.26.3","babel-loader":"7.1.5","babel-plugin-transform-runtime":"^6.23.0","babel-preset-env":"1.7.0","babel-preset-es2015":"6.24.1","babel-preset-stage-1":"6.24.1","webpack":"^4.25.1","webpack-cli":"^3.1.2"},"prettier":{"singleQuote":true,"printWidth":80,"tabWidth":2,"useTabs":false,"bracketSpacing":true},"gitHead":"6c02ebb063d6c0f8e23231dfcef9878a9e3e334d","licenseText":"MIT License\n\nCopyright (c) 2019 EOS New York\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":"@aikon/eos-transit@4.0.9","dist":{"shasum":"62259da17294c8339f452a907daacc53b8cd57bd","integrity":"sha512-MeyAONH/CLckbai1qQHicyRKH0w8isHR7cpP/BrMLQWX38V6c53snnjUvEiYojGp1dgc4UfF0m2Jkfr2ln5X7Q==","tarball":"https://registry.npmjs.org/@aikon/eos-transit/-/eos-transit-4.0.9.tgz","fileCount":24,"unpackedSize":277968,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGts0vjZ3qAsZQdvXnuF41IRXqMiJtm+y64p+Dcq4kE8AiA+gkquMpfSEFsOR9/spESDgQ9wKbobhUp67L95pBZtYQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjPE58ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpGEw/+KXOlihf6DbhtA+JNNJLlOAon+YueCe16iKEvK1UFFTu+W2A7\r\nkT3dQ9gChh/mEIzgFczERLKN+moiHc9ihUALypObPa47cjw2i5tnVplgwDQs\r\nOW3De9OTGMUIQFMEW0sQbDjLUpceq+RmUsTh5l0BYIjEqYYfROnkgGxN4fS1\r\naWLaFu1+9j8QTAwsvxmzoJzLrMKiy7Zsd+MdGhe0GyPUZM2JG1xAobfVznFj\r\ngzTEfEPZhm+Sgfw/VRl8ygEgY/pA8AclkeuGycZeT10pISvaXw89btUDvl4U\r\neH/ohJay997b8BBDIwY3WmpesLr8FPXJVcxjRfgTcZnLnVdbAUZ91pCKAGC5\r\nV0qJSVWWu5ibzbtt6tnL0JrFXt2ZBAZoXQN9vMCZqjq+w3QizGg6hXnsOS7P\r\nkx1bSfJAUAAJOtsTR832FCTx/NXXr/WlFkx+akyLdDduEWNrTWfUcTqb8sGP\r\nL/+UuciKMx4KBawnk6jv09KpE6VOXSjyPYGTvRNEgS6tYiowE9MPHKJs5081\r\n1NPgmZdCe47dyBlH5fG2YHLNmZRrLPctHYpXp+xxboUNYwD6STWP+CglWB9s\r\n0wLGeqyydthJT1HkLmCjUaZyBXHM5ksd88EYrFTSE9QdiZxurs6bNauI/g2b\r\nD15SwpN4OqXkJYSm3ChwMCBoTifcr1iKIeI=\r\n=OWCE\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"apimarket","email":"info@aikon.com"},"directories":{},"maintainers":[{"name":"apimarket","email":"info@aikon.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eos-transit_4.0.9_1664896635877_0.8484099628978843"},"_hasShrinkwrap":false}},"time":{"created":"2021-03-12T20:04:15.804Z","4.0.7":"2021-03-12T20:04:16.290Z","modified":"2022-10-04T15:17:16.213Z","4.0.8":"2021-07-21T19:13:44.146Z","4.0.9":"2022-10-04T15:17:16.069Z"},"maintainers":[{"name":"apimarket","email":"info@aikon.com"}],"description":"Wallet Access Layer for EOS Blockchain Networks - modified by AIKON to support non-eos plug-ins","license":"UNLICENSED","readme":"# `eos-transit` - [Wallet Access Layer for EOS](../../) core package.\n\nThis library is a tiny abstraction layer on top of `eosjs` and is aiming to assist the EOS dapp (decentralized app) developers with wallet communication (in order to sign the transactions) by providing a simple and intuitive API.\n\nThis allows to concentrate on building awesome apps instead of setting up `eosjs` and wallet connections.\n\n> *Disclaimer: This library is in early alpha. The core API has stabilized but some changes and extension should be expected. But we encourage to give it a try when building your decentralized apps and feel free to share any thoughts, doubts and concerns. Any kind of feedback is highly appreciated.*\n\n\n## AIKON Fork Verion\n\n2021-March - This repo is a fork from the main eos-transit project. It implements a small change to allow use with non-Eos blockchains. For non-Eos providers, pass in the new isNotEosNetwork param = true. This will bypass eos-specific rpc calls in the wallet object. \nThis version is published as an npm package under @aikon/eos-transit\n\nExample usage for non-Eos provider:\n```\n    const walletContext = initAccessContext({\n      ...\n      isNotEosNetwork: true\n    })\n```\n\n## Features\n\n- Easy to use API\n- Managed wallet connection state tracking\n- Easily pluggable wallet providers (and easy to write your own)\n- TypeScript support\n- Small footprint (core is just ~9Kb minified and around 2.7Kb gzipped)\n\n\n## Packages\n\nThis is a monorepo that is managed with [`lerna`](https://github.com/lerna/lerna). There are several packages maintained here:\n\n| Package                                                         | Version | Description                       |\n|-----------------------------------------------------------------|---------|-----------------------------------|\n| [`eos-transit`](../../packages/eos-transit)                                   | 0.0.1   | Transit core package                |\n| [`eos-transit-scatter-provider`](../../packages/eos-transit-scatter-provider) | 0.0.1   | Wallet provider for [Scatter](https://get-scatter.com/) app |\n| [`eos-transit-stub-provider`](../../packages/eos-transit-stub-provider)       | 0.0.1   | Stub wallet provider that does nothing, for demo and testing only |\n\n\n---\n\n\n## Table of Contents\n- [`eos-transit` - Wallet Access Layer for EOS core package.](#eos-transit---wallet-access-layer-for-eos-core-package)\n  - [AIKON Fork Verion](#aikon-fork-verion)\n  - [Features](#features)\n  - [Packages](#packages)\n  - [Table of Contents](#table-of-contents)\n  - [Quick start](#quick-start)\n    - [Installation](#installation)\n    - [Basic usage example](#basic-usage-example)\n    - [Browser UMD build](#browser-umd-build)\n  - [Motivation](#motivation)\n  - [How it works (architecture)](#how-it-works-architecture)\n  - [Guide](#guide)\n    - [Basics](#basics)\n      - [`WalletAccessContext` setup](#walletaccesscontext-setup)\n      - [Setting up wallet providers](#setting-up-wallet-providers)\n      - [Using `stub` wallet provider for testing and demo purposes](#using-stub-wallet-provider-for-testing-and-demo-purposes)\n      - [Global `WalletAccessContext` instance](#global-walletaccesscontext-instance)\n      - [Getting list of available wallet providers](#getting-list-of-available-wallet-providers)\n    - [Working with wallets](#working-with-wallets)\n      - [Creating `Wallet` instances](#creating-wallet-instances)\n      - [Connecting to `Wallet`](#connecting-to-wallet)\n      - [Logging in to a `Wallet`](#logging-in-to-a-wallet)\n      - [Fetching user account data for a `Wallet`](#fetching-user-account-data-for-a-wallet)\n      - [Working with EOS and signing transactions using `Wallet`](#working-with-eos-and-signing-transactions-using-wallet)\n    - [State tracking](#state-tracking)\n      - [Subscribing to the state updates](#subscribing-to-the-state-updates)\n      - [`WalletAccessContext` state](#walletaccesscontext-state)\n      - [`Wallet` state](#wallet-state)\n    - [Wallet session termination](#wallet-session-termination)\n    - [Destroying the `WalletAccessContext`](#destroying-the-walletaccesscontext)\n    - [Creating custom wallet providers](#creating-custom-wallet-providers)\n      - [Provider instance](#provider-instance)\n      - [Provider factory function](#provider-factory-function)\n      - [Higher-order provider factory function](#higher-order-provider-factory-function)\n    - [TypeScript support](#typescript-support)\n  - [API reference](#api-reference)\n  - [Contribution](#contribution)\n\n\n## Quick start\n\n### Installation\n\n`eos-transit` can be installed as an `npm` package using [`yarn`](https://yarnpkg.com/en/)\n\n    $ yarn add eos-transit\n    \nor `npm` client:\n\n    $ npm install eos-transit\n\nThen simply `import` the package contents using the ES6 module syntax:\n\n```\nimport { initAccessContext } from 'eos-transit';\n```\n\n\n### Basic usage example\n\nHere's a simple quick start example using [Scatter](https://get-scatter.com) app wallet provider to get you up to speed but make sure to read the [Guide](#guide) for full explanation of how each part works and take a look at the [Architecture](#how-it-works-architecture) for better overall understanding.\n\nInstall the necessary libraries and wallet provider plugins with `yarn` (or `npm`):\n\n```\n$ yarn add eosjs@beta eos-transit eos-transit-scatter-provider\n```\n\nThe `eos-transit-scatter-provider` will also pull its own dependencies automatically.\n\n```javascript\nimport { initAccessContext } from 'eos-transit';\nimport scatter from 'eos-transit-scatter-provider';\n\n// We need to initialize the so called \"access context\" first,\n// passing it our dapp name, network configuration and\n// providers we want to make available to the dapp.\n// The context is responsible for initializing wallet connectoins\n// and tracking state of connected wallets.\n\n// We're using our own test network as an example here.\nconst accessContext = initAccessContext({\n  appName: 'my_first_dapp',\n  network: {\n    host: 'api.pennstation.eosnewyork.io',\n    port: 7001,\n    protocol: 'http',\n    chainId: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f'\n  },\n  walletProviders: [\n    scatter()\n  ]\n});\n\n// We're all set now and can get the list of available wallet providers\n// (we only have Scatter provider configured, so there will be only one):\n\nconst walletProviders = accessContext.getWalletProviders();\n/* [{\n *   id: 'scatter',\n *   meta: {\n *    name: 'Scatter Desktop',\n *    shortName: 'Scatter',\n *    description: 'Scatter Desktop application that keeps your private keys secure'\n *   },\n *   signatureProvider,\n *   ... etc\n * }]\n */\n\n// This list can be used to, e.g., show the \"login options\" to the user to let him choose\n// what EOS login method he wants to use.\n\n// We just take the one we have as if the user has selected that\nconst selectedProvider = walletProviders[0];\n\n// When user selects the wallet provider, we initiate the `Wallet` with it:\nconst wallet = accessContext.initWallet(selectedProvider);\n\n// Now we have an instance of `wallet` that is tracked by our `accessContext`.\n// Lets connect to it and authenticate (you need Scatter app running)\n// NOTE: Only use `await` inside the `async` function, its used here just to\n// highlight that its asynchronous.\nawait wallet.connect();\n\n// wallet.connected === true\n\n// If we're dealing with a device that has multiple keys (eg. Ledger Nano S), then we'll need to discover which keys / accounts are available on the device. This will return an object containing an array of accounts ... you'll need the user to select which account he want to use if this is the case.\nlet discoveryData = await wallet.discover({ pathIndexList: [ 0,1,2 ] });\n\n// Note you can keep caling discover at any point in time to extent the index list. transit will only query the device and the network for new index's. \nlet discoveryData = await wallet.discover({ pathIndexList: [ 0,1,2,3 ] });\n// You can either pass the full list or just the new index you're afer. Either way it'll append that keys info to the discoveryData object and return the entire dataset. \nlet discoveryData = await wallet.discover({ pathIndexList: [ 150 ] });\n\n\n// If we have more than one account the user can select from we'll need to prompt the user.\n// Note that the Login function is called with the specific account details when multiple accounts are available.\nif (discoveryData.keyToAccountMap.length > 0) {\n\n  // If discover returned multiple acconts then you'll need to promot the user to select which account he'd like to use. \n  // accountName, authorization are taken from the  discoveryData object. See the example of this object further down on this page.\n\n  await wallet.login(accountName, authorization)\n\n} else {\n\n  // Now that we are connected, lets authenticate (in case of a Scatter app,\n  // it does it right after connection, so this is more for the state tracking\n  // and for WAL to fetch the EOS account data for us)\n  await wallet.login(); \n\n  \n}\n\n\n// wallet.authenticated === true\n// wallet.auth === { accountName: 'some_user', permission: 'active', publicKey: '...' }\n// wallet.accountInfo === { name: 'some_user', core_liquid_balance: ..., ram_quota: ..., etc... }\n\n// Now that we have a wallet that is connected, logged in and have account data available,\n// you can use it to sign transactions using the `eosjs` API instance that is automatically\n// created and maintained by the wallet:\n\nconst eosAmount = 10;\n\nwallet.eosApi\n  .transact({\n    actions: [\n      {\n        account: 'eosio.token',\n        name: 'transfer',\n        authorization: [\n          {\n            actor: wallet.auth.accountName,\n            permission: wallet.auth.permission\n          }\n        ],\n        data: {\n          from: wallet.auth.accountName,\n          to: 'receiving_user',\n          quantity: `${eosAmount.toFixed(4)} EOS`,\n          memo: ''\n        }\n      }\n    ]\n  },\n  {\n    broadcast: true,\n    blocksBehind: 3,\n    expireSeconds: 60\n  }\n)\n.then(result => {\n  console.log('Transaction success!', result);\n  return result;\n})\n.catch(error => {\n  console.error('Transaction error :(', error);\n  throw error;\n});\n\n```\n\nRead about why would you need it in the [Motivation](#motivation) and explore more in the [Guide](#guide) section!\n\n\n### Browser UMD build\n\nThere's also [UMD](https://github.com/umdjs/umd) build for in-browser usage distributed with the package that can be used by directly including the library as a `<script>` tag. It can either be referenced from inside the `eos-transit` package folder after being installed with `yarn` or `npm`:\n\n    <script src=\"./node_modules/eos-transit/umd/eos-transit.min.js\"></script>\n\nor using [`unpkg`](https://unpkg.com) (will only work after `eos-transit` is published):\n\n    <script src=\"https://unpkg.com/eos-transit/umd/eos-transit.min.js\"></script>\n\n> Note that you need to attach `eosjs` dependency as a `<script>` too which would require you to manually do a special \"web build\" (see the related [EOSJS docs here](https://eosio.github.io/eosjs/static/3.-Browsers.html)) but that build only exposes `eosjs` internals as global variables and doesn't work with `eos-transit` as the latter requires modules. **But we have you covered** and there's also custom `eosjs` UMD build that is pluggable as a `<script>` tag and can be `import`ed as a module:\n> \n>     <script src=\"./node_modules/eos-transit/umd/eosjs.min.js\"></script>\n> OR\n> \n>     <script src=\"./node_modules/eos-transit/umd/eosjs.min.js\"></script>\n>\n> It isn't some custom `eosjs` tailored for `eos-transit`, its original `eosjs` code packaged nicely, so you don't have to.\n>\n\nThere's also a [wal-script-tag](examples/wal-script-tag) example in our repo that showcases how to attach the libraries and how to use them to sign a transaction.\n\n**Please note** that we highly encourage to use the ES modules version of the library and not the UMD build for real apps.\n\n\n## Motivation\n\nThe need for `eos-transit` has formed up around realizing few issues with using EOS blockchain from the browser:\n\n- `eosjs`, while being quite nice and feature-complete EOS blockchain integration for JavaScript, is rather low-level, and is tedious to setup for each particular dapp.\n\n- Every wallet app to be represented as a login option or transaction signature provider for the dapp would need to integrate with `eosjs`, and dapp developer would need to introduce some level of abstraction for consistency purposes.\n\n- When dapp developer gets to the point of supporting multiple wallets for authentication and transaction signing for end user to choose from (like `METRO` hardware wallet, `Scatter`, etc), he would need to setup the `eosjs` `Api` instances for each, track the connection/authentication state, user authentication data and EOS account data, handle connection errors, manage disconnected wallets, get the app notified when some wallet internal state changes, etc.\n\nSo, **Transit** just covers the above aspects for the dapp developer. Its basically nothing more than what a dapp developer **would have written on his own** in one way or another.\n\nThis lib's purpose is to ease the burden of setting up multiple signature providers by standardizing the approaches to how dapps talk to 3rd-party wallet apps and by tracking that communication. Basically, we're aiming to cover the entire \"Login with EOS\" use case for a dapp by making it as easy as installing few packages (core and necessary providers) and using the rather minimalistic API.\n\n\n## How it works (architecture)\n\nTransit is just a small convenience wrapper around `eosjs` (core) and some code that communicates to 3rd-party wallet apps for transactions signing (wallet providers). Its not extending the EOS blockchain, nor does it extend these 3rd-party apps, it just provides the consistent glue between these pieces of tech, also providing some assisting capabilities like state tracking for wallet connections.\n\nThe `eos-transit` is minimalistic and doesn't stand in a way, providing a lot of escape hatches (like there's always a reference to underlying `eosjs` `Api` instance available on `eos-transit` `wallet` instances) and only doing what its designed for.\n\nThere are 3 core pieces of `eos-transit`:\n\n- `WalletAccessContext` is just a configured bunch of wallet providers in the context of a given **dapp** (identified by the passed **app name** when created) on a given **network** (defined with a passed network configuration). Keeps configured providers and is responsible for initializing `Wallet`s and tracking their state. Performs initial `eosjs` RPC access configuration.\n\n- `WalletProvider` is a piece that communicates to a particular 3rd-party application. As the name implies, it \"provides\" the access to that app in a consistent manner (there's a `WalletProvider` API defined in `eos-transit`). Its not in any way bound to the `WalletAccessContext` - one can even use the `WalletProvider` instance directly if needed. Doesn't track state or anything, but provides the actual functionality to `connect()`, `login()` to the wallet, etc. The actual implementations are not the part of `eos-transit` core and are maintained and installed separately.\n\n- `Wallet` represents a certain `WalletProvider` connection in a certain `WalletAccessContext`. It basically wraps the `WalletProvider` (there's a `provider` property on a `Wallet`) and adds some contextual metadata to that - it tracks if the `wallet` is connecting or authenticating, if its connected or authenticated, if there's a connection or authentication error and keeps the related data. The actual `eosjs` `Api` instance is created on the `Wallet` initialization and is maintained as an instance property.\n\nSee [Guide](#guide) and [API reference](#api-reference) for more information and elaborate type descriptions.\n\n\n## Guide\n\nThis guide covers all the aspects of how `eos-transit` works step-by-step, so feel free to just follow it along.\n\n### Basics\n\n#### `WalletAccessContext` setup\n\nThe first thing in `eos-transit` setup is initializing `WalletAccessContext` instance. It takes an object of `options` that requires `appName`, `network` and `walletProviders` properties to be passed in:\n\n```javascript\nimport { initAccessContext } from 'eos-transit';\n\nconst accessContext = initAccessContext({\n  appName: 'my_dapp',\n  network: {\n    host: 'api.pennstation.eosnewyork.io',\n    port: 7001,\n    protocol: 'http',\n    chainId: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f'\n  },\n  walletProviders: []\n});\n```\n\nAnd you're all set! Now use the newly created `accessContext` instance (that implements the `WalletAccessContext` interface) to initialize wallets. But wait! Shouldn't we pass something in the `walletProviders` array so that we can actually connect to some wallet app? Absolutely - lets see how to do that in the next section.\n\n\n#### Setting up wallet providers\n\nWe'll use our official `eos-transit-scatter-provider` that connects to a [Scatter](https://get-scatter.com) wallet app. Our setup is extended to include the provider instance:\n\n```javascript\nimport { initAccessContext } from 'eos-transit';\nimport scatter from 'eos-transit-scatter-provider';\n\nconst accessContext = initAccessContext({\n  appName: 'my_dapp',\n  network: {\n    host: 'api.pennstation.eosnewyork.io',\n    port: 7001,\n    protocol: 'http',\n    chainId: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f'\n  },\n  walletProviders: [\n    scatter()\n  ]\n});\n```\n\nNote that we're only passing `network` configuration to our `initAccessContext` and not into provider. The `scatter` in the example above is just a `default` export from our Scatter wallet provider package. Don't get confused, by calling this we're just initializing another function (that accepts `network`) that is then used by `eos-transit` to actually create a provider instance. We might have passed this function directly but this nice `eos-transit-scatter-provider` package creates one for us so that we don't have to.\n\nFor the curious, here's how that `scatter` function is looking internally:\n```javascript\nfunction scatter() {\n  return function makeWalletProvider(network) {\n    ...\n    return scatterInstance;\n  }\n}\n```\n\n`eos-transit` then internally calls that at appropriate time and provides its `network` configuration. Pretty neat.\n\n\n#### Using `stub` wallet provider for testing and demo purposes\n\nThere's one more provider we maintain as a package, `eos-transit-stub-provider` that **does nothing** and is there for purely demonstration and testing purposes. The `wallets` created with it always end up with error after specified timeout.\n\nIt will soon be extended to accept the pre-configured private key for `eosjs` `JsSignatureProvider` so that its more useful, but for now it just takes the following `options` object:\n\n```javascript\n{\n  id: 'some_provider_id',\n  name: 'My Super Cool Wallet Provider',\n  shortName: 'My Provider',\n  description: 'Some description here, might be shown on the UI, etc',\n  errorTimeout: 3000 // milliseconds before connect/login error, defaults to 2500\n}\n```\n\nLets add that one as a wallet provider to our app too:\n\n```javascript\nimport { initAccessContext } from 'eos-transit';\nimport scatter from 'eos-transit-scatter-provider';\nimport stub from 'eos-transit-~~tub~~-provider';\n\nconst accessContext = initAccessContext({\n  appName: 'my_dapp',\n  network: {\n    host: 'api.pennstation.eosnewyork.io',\n    port: 7001,\n    protocol: 'http',\n    chainId: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f'\n  },\n  walletProviders: [\n    scatter(),\n    stub({\n      id: 'some_provider_id',\n      name: 'My Super Cool Wallet Provider',\n      shortName: 'My Provider',\n      description: 'Some description here, might be shown on the UI, etc',\n      errorTimeout: 3000\n    })\n  ]\n});\n```\n\nSidenote: The function we export from our provider pacakges is also very helpful if we want to pass additional provider configuration options.\n\nOnce configured, our `stub` provider will reside amongst `walletProviders` inside the `WalletAccessContext` instance.\n\n\n#### Global `WalletAccessContext` instance\n\nA quick note about global `accessContext` maintained by `eos-transit`. You can (and most often should) create one yourself, and pass that to different parts of your app by the means of some UI lib/framework you're using (like `props` and \"context\" in `React`, etc). As many `WalletAccessContext` instances can be created as you'd like.\n\nBut for added convenience we also provide the one managed right by the `eos-transit` package. The catch is that you need to **initialize it first**, otherwise accessing the context throws an `Error` (we don't create one automatically because you might not need it and it needs `appName`, providers and network configured anyway). So, initialize it as soon as the app launches, before accessing anything else from the package.\n\nThe difference is in how you access that:\n\n**Regular instance**\n\n```javascript\n// accessContext.js file\nimport { initAccessContext } from 'eos-transit';\n\nconst accessContext = initAccessContext(...);\n\n...\n\nexport default accessContext;\n\n\n// some-file1.js\nimport accessContext from './accessContext';\n\n// Using `accessContext` ...\n\n\n// some-file2.js\nimport accessContext from './accessContext';\n\n// Using `accessContext` ...\n\n```\n\n**Global instance**\n\n```javascript\n// initAccessContext.js file\nimport { initDefaultAccessContext } from 'eos-transit';\n\nconst initDefaultAccessContext(...);\n\n...\n\nexport default accessContext;\n\n\n// app.js\n// Need to initialize first\nimport './initAccessContext';\nimport './some-file1';\nimport './some-file2';\n\n...\n\n// some-file1.js\nimport WAL from 'eos-transit';\n\n// Note that we're importing the context instance from `eos-transit`\n// The instance is on `WAL.accessContext` ...\n\n// some-file2.js\nimport WAL from 'eos-transit';\n\n// The instance is on `WAL.accessContext` ...\n```\n\nThe **recommended** approach is to use the custom instance, explicitly created with `initAccessContext`, though.\n\n\n#### Getting list of available wallet providers\n\nNow that `WalletAccessContext` instance is all set and ready, we can get a list of configured wallet providers from it:\n\n```javascript\nconst walletProviders = accessContext.getWalletProviders();\n```\n\nYou can use this list to show off to the user as some sort of login options (suggested approach). Then, upon some user action, certain provider can be considered \"selected\" and a `Wallet` instance would be created for it. Which naturally leads us to...\n\n\n### Working with wallets\n\n#### Creating `Wallet` instances\n\nThe `Wallet` represents the actual wallet app connection so to say. It represents a \"wallet provider\" in the context of a certain `appName` and `network`. That means, the `Wallet` instances are initialized with the help of previously created `WalletAccessContext` instance with certain `WalletProvider` as an argument:\n\n```javascript\nimport { initAccessContext } from 'eos-transit';\n\nconst accessContext = initAccessContext({\n  appName: '...',\n  network: { ... },\n  walletProviders: [ ... ]\n});\n\n// Selecting provider somehow, we just take the first in list for simplicity\nconst walletProvider = accessContext.getWalletProviders()[0];\n\nconst wallet = accessContext.initWallet(walletProvider);\n```\n\nYou're all set to use the `Wallet`. Now you can connect to that wallet, login into it, obtain the authentication metadata and fetch the EOS account info with the help of `eos-transit`. All these actions are nicely tracked by the `Wallet` instances themselves and by `WalletAccessContext` which created that `Wallet`.\n\n\n#### Connecting to `Wallet`\n\nOnce the `Wallet` instance is obtained, we can use it to connect to a wallet app. That is done with a `connect()` function, that returns a `Promise`, so you can either use `.then(...)` or `await` keyword (inside `async` functions only)\n\n```javascript\n// ...\n\nconst wallet = accessContext.initWallet(walletProvider);\n\nwallet.connect()\n  .then(() => {\n    console.log('Successfully connected!')\n  });\n\n```\n\nSome providers will also authenticate right when you're connecting to them, so the `login` will work instantly and will be used to only fetch the account data.\n\n#### Logging in to a `Wallet`\n\nA previously configured and `connected` wallet can be authenticated. Use `login()` function on a `Wallet` instance to do that. Just like `connect()`, it returns a `Promise`. But aside from calling `login` on the underlying `WalletProvider`, in case of successful login it also fetches the user account info\n\n```javascript\n// ...\n\nconst wallet = accessContext.initWallet(walletProvider);\n\nwallet.connect().then(() => {\n  console.log('Successfully connected!');\n\n  wallet.login().then(accountInfo => {\n    console.log(`Successfully logged in as ${accountInfo.name}!`);\n  });\n});\n\n\nwallet.connect().then(() => {\n  console.log('Successfully connected!');\n\n    wallet.discover({ pathIndexList: [ 0,1,2,3 ] }).then((discoveryData: DiscoveryData) => {\n    console.log('Discovery successfully completed!');\n\n    // IF the wallet support discovery.\n    // The discover process will return an object (see example object below) that contains:\n    // 1. The keys found on the device\n    // 2. The EOS Accounts linked to those keys. \n    //\n    // If the keyToAccountMap contains entries, then the user should be asked which account they'd like to use. \n    // Note that the only functional difference is that:\n    // When logging in with ledger you supply the account you want to login\n    // When logging in with scatter your just calling login() and allowing the user to select an account\n    if (discoveryData.keyToAccountMap.length > 0) {\n      // We're just going to hard code the selection for the demo.\n      const index = 0;\n      const keyObj = discoveryData.keyToAccountMap[index];\n\n      const accountName = keyObj.accounts[0].account;\n      const authorization = keyObj.accounts[0].authorization;\n\n\n      wallet.login(accountName, authorization).then(accountInfo => {\n        console.log(`Successfully logged in as ${accountInfo.name}!`);\n      });\n    } else {\n      // 0 keys returned, we need to user to select an account\n      wallet.login().then(accountInfo => {\n        console.log(`Successfully logged in as ${accountInfo.name}!`);\n      });\n    }\n  });\n});\n\n\n```\nThe object returned from the discover() method looks as follows:\n\n```\n{\n  keyToAccountMap: [{\n    index: 0,\n    key: XXXX,\n    accounts: [{\n        account: ‘eosio’,\n        authorization: ‘owner’\n    }]\n  },{\n    index: 1,\n    key: YYYY,\n    accounts: [{\n        account: ‘anotherAccount’,\n        authorization: ‘active’\n    },{\n        account: ‘anotherAccount’,\n        authorization: ‘owner’\n    }]\n  }]\n}\n\n```\n\nAfter the user is logged in, the `auth` metadata is available on the `wallet.auth` property. It contains `accountName`, `permission` (like `active`, `owner`, etc) and account's `publicKey`.\n\nAs well, because `eos-transit` also fetches the user account data (on successful logins) from EOS network itself, the `wallet.accountInfo` contains all the data returned from [EOS RPC API `get_account` endpoint](https://developers.eos.io/eosio-nodeos/reference#get_account).\n\n\n#### Fetching user account data for a `Wallet`\n\nUpon successful `login()` via the underlying `WalletProvider`, the `Wallet` instance fetches the EOS account info automatically and keeps in the internal state - its available on a `wallet.accountInfo` peroperty if fetched successfully.\n\nBut you can always refetch it manually with a `fetchAccountInfo()` function on a `Wallet` instance that returns a `Promise` of `AccountInfo`:\n\n```javascript\n// ...\nwallet.fetchAccountInfo().then(accountInfo => {\n  console.log(`Fetched the EOS account info for ${accountInfo.name}!`);\n});\n```\n\nAside from being returned in a `Promise`, it will also get remembered in the `Wallet` internal state.\n\n\n#### Working with EOS and signing transactions using `Wallet`\n\nThe whole purpose of using 3rd-party wallet apps is for them to store user private key secure, so that it doesn't leak anywhere and only provide a signature when needed to sign a transaction before pushing that to the EOS blockchain network.\n\n`eos-transit` doesn't change the way signatures are propagated to `eosjs` `Api` instance - instead, it just passes the `WalletProvider` instance `signatureProvider` property directly when creating the `eosjs` `Api` object for a `Wallet`.\n\n`Wallet` object maintains the initialized and configured `Api` instance as the `eosApi` property. So, basically \"connected\" and \"authenticated\" `Wallet` is the dapp-level convenience, the real signatures are requested by the `eosjs` when there's the need to sign some transaction. `eos-transit` therefore just assists maintaining `Api` instance working and ready to sign transactions and in fact doesn't replace `eosjs` usage with some custom API (we'll be providing some purely convenience wrappers later on but they won't be a part of the `eos-transit` core per se).\n\nHere's the example of using `eosio.token` contract transaction to transfer some `EOS` from the user currently authenticated with a `Wallet` and to some other user using `Api.transact(...)` (example is taken directly from [`eosjs` docs](https://github.com/EOSIO/eosjs#sending-a-transaction) and \"ported\" to use `eos-transit`):\n\n```javascript\nawait wallet.connect();\nawait wallet.login();\n\nwallet.eosApi\n  .transact({\n    actions: [\n      {\n        account: 'eosio.token',\n        name: 'transfer',\n        authorization: [\n          {\n            actor: wallet.auth.accountName,\n            permission: wallet.auth.permission\n          }\n        ],\n        data: {\n          from: wallet.auth.accountName,\n          to: 'receiver_name',\n          quantity: '10 EOS',\n          memo: ''\n        }\n      }\n    ]\n  },\n  {\n    broadcast: true,\n    blocksBehind: 3,\n    expireSeconds: 60\n  }\n)\n.then(result => {\n  console.log('Transaction success!', result);\n  return result;\n})\n.catch(error => {\n  console.error('Transaction error :(', error);\n  throw error;\n});\n```\n\nNothing special here really. Any other `eosjs` `Api` method can be used without issues on the instance exposed at the `eosApi` property.\n\n\n### State tracking\n\nThis is the super-useful part of `eos-transit` and is basically something that would have to be implemented on the dapp side otherwise. Its UI frameworks agnostic and employs a very minimalistic state container internally, so no external dependencies are needed for this feature to work.\n\n`eos-transit` keeps all the state related to `WalletAccessContext` and `Wallet` inside state containers in the respective `WalletAccessContext`/`Wallet` instances.\n\n\n#### Subscribing to the state updates\n\nIn a real app its usually not enough to just perform some actions like `connect()`, `login()` or `fetchAccountInfo()` - for the sake of a smooth user experience, we need to store some additional metadata somewhere to know if the `wallet` is `connecting` or `authenticating` currently, or maybe there's `authenticationError` somewhere - these are all kinds of data to be stored *somewhere*. `eos-transit` keeps that in the internal state containers and that state is exposed as a `state` property on both `WalletAccessContext` and `Wallet` instances.\n\nWhile the `state` property can be accessed directly at any time to inspect, its very handy to know *if* and, more importantly, *when* that state changes so that dapp can react accordingly, like rerender some piece of UI, etc.\n\nThis is done using `subscribe` function on both `WalletAccessContext` and `Wallet` instances. The listener of `WalletAccessContext.subscribe()` takes the access context itself as an argument and `Wallet.subscribe()` listener takes a new updated `WalletState`:\n\n```javascript\nconst accessContext = initAccessContext(...);\naccessContext.subscribe(walletAccessContext => {\n  // walletAccessContext is here for added convenience,\n  // you can use the `accessContext` too as its the same instance.\n  // The point of subscription is mostly for the sake of knowing\n  // \"when\" something changes.\n  walletAccessContext === accessContext; // true\n\n  console.log('access context state updated');\n});\n\nconst wallet = accessContext.initWallet(someWalletProvider);\nwallet.subscribe(walletState => {\n  console.log(`wallet ${wallet._instanceId} state updated`);\n});\n\n// logs out \"access context state updated\"\n\nwallet.connect();\n\n// logs out \"access context state updated\"\n// logs out \"wallet <some_wallet_uuid> state updated\"\n\n// ... Later on when wallet has been connected\n\n// logs out \"access context state updated\"\n// logs out \"wallet <some_wallet_uuid> state updated\"\n\n// etc\n\n```\n\n\n#### `WalletAccessContext` state\n\nThe `WalletAccessContext` instance state has only one property, which is `wallets`. That means that whenever \n\n```javascript\nconst accessContext = initAccessContext(...);\nconsole.log(accessContext.state);\n// {\n//   wallets: []\n// }\n\naccessContext.initWallet(someWalletProvider);\nconsole.log(accessContext.state);\n// {\n//   wallets: [Wallet]\n// }\n\n```\n\nIn most cases you won't need to access the `state` directly and would be using the like `getWalletProviders()`, `getWallets()` and `getActiveWallets()` instead.\n\n\n#### `Wallet` state\n\nUnlike `WalletAccessContext`, the `Wallet` state is much more elaborate. This is no surprise, since most of the \"interesting\" work happens at the `Wallet`s level.\n\n```javascript\nconst accessContext = initAccessContext(...);\nconst wallet = initWallet(accessContext.getWalletProviders()[0]);\n\n// wallet.state is the following object:\n{\n  // Whether the wallet is being connected\n  connecting: false,\n\n  // Whether the wallet is currently connected\n  connected: false,\n\n  // Whether there was a connection error\n  connectionError: false,\n\n  // if `connectionError === true`, there's usually some descriptive error message\n  connectionErrorMessage: 'some error message',\n\n  // In case of successful authentication, the object with auth metadata.\n  // `undefined` otherwise.\n  auth: {\n    accountName: '...',\n    permission: 'active',\n    publicKey: '...'\n  },\n\n  // Whether the wallet is being authenticated\n  authenticating: false,\n\n  // Whether the wallet is authenticated\n  authenticated: false,\n\n  // Whether the authentication failed\n  authenticationError: false,\n\n  // Some auth error message if authentication failed\n  authenticationErrorMessage: 'some auth error',\n\n  // EOS account info if fetched successfully, `undefined` otherwise.\n  accountInfo: void 0,\n\n  // Whether the account info is being fetched for authenticated user\n  accountFetching: false,\n\n  // Whether there was an error during account info fetching\n  accountFetchError: false,\n\n  // Account fetching error description\n  accountFetchErrorMessage: 'some account fetch error'\n }\n```\n\nWhile the `state` can be accessed directly, the most often used properties of `state` are also exposed on the `Wallet` instance directly:\n\n```javascript\n{\n  ... other unrelated props,\n\n  // Derived directly from `state`\n  auth: { ... },\n  accountInfo: { ... },\n  connected: true,\n  authenticated: true,\n\n  // Whether there's something in progress - its either connecting,\n  // authenticating or accountInfo is being fetched\n  inProgress: true,\n\n  // Whether its successfully connected, authenticated and\n  // has accounInfo successfully fetched\n  active: true,\n\n  // Indicates either connection, authentication or accountInfo\n  // fetching error, in that order or precedence\n  hasError: false,\n\n  // Either connection, authentication or accountInfo\n  // fetching error message\n  errorMessage: 'some error message',\n}\n```\n\n\n### Wallet session termination\n\nWhen all work is over, either individual `Wallet`s or all the `Wallet`s under certain `WalletAccessContext` need to tear down, logout and disconnect somehow.\n\nThere are `logout()` and `disconnect()` methods on the `Wallet` instance:\n\n```javascript\nconst accessContext = initAccessContext(...);\nconst wallet = initWallet(accessContext.getWalletProviders()[0]);\n\n// ... some useful stuff\n\nawait wallet.disconnect();\nawait wallet.logout();\n```\n\nIts all good and we've explicitly disconnected from the wallet provider app but our `WalletAccessContext` still maintains the `Wallet` instance since its still all valid - it can be `connect()`ed and `login()`ed again just like a fresh one.\n\nTo fix this, we need to \"detach\" the `Wallet` instance from the `WalletAccessContext` so that the latter \"forgets\" about the `Wallet` we want to dispose of:\n\n```javascript\n\naccessContext.detachWallet(wallet);\n```\n\nIts synchronous, invokes immediately and we're all set! So far so good but its so tedious doing that manually all the time, right? And most of the time we'd want to `logout` then immediately `disconnect` and then `detachWallet` right away. Totally agree, thats why there's convenient `terminate()` method that does all that for us:\n\n```javascript\nconst accessContext = initAccessContext(...);\nconst wallet = initWallet(accessContext.getWalletProviders()[0]);\n\n// ... some useful stuff\n\nawait wallet.terminate();\n```\n\nAnd thats it!\n\nAlright, terminating individual `Wallet`s is perfect when we want to handle, e.g., user selectively logging out from certain wallets. But what if we want to provide some big red logout-and-disconnect-from-everything sort of button?\n\n`WalletAccessContext` has few methods to cover this use case.\n\nThere are `logoutAll()`, `disconnectAll()` and, of course, `terminateAll()` methods on it - by calling those, we make the context `logout()`, disconnect()` or `terminate()` all managed wallets en masse.\n\n### Destroying the `WalletAccessContext`\n\nIf you don't need the `WalletAccessContext` instance itself anymore, there's also `WalletAccessContext.destroy()` method that terminates all wallets managed by the context and also unsubscribes it from its own state container and removes all listeners.\n\nOnce `destroy()`ed, the `WalletAccessContext` should not be used anymore.\n\n\n### Creating custom wallet providers\n\n#### Provider instance\n\nCreating custom `WalletProvider` is easy with `eos-transit`. The [`WalletProvider` `interface`](https://github.com/eosnewyork/eos-transit/blob/master/packages/eos-transit/src/types.ts#L68) can be used as a guide to what kind of object is expected as a `WalletProvider` instance even if you're not using TypeScript to write the actual provider.\n\nThe actual `WalletProvider` instance is an object:\n\n```javascript\n{\n  // Unique identifier, e.g., \"my_provider\", or whatever won't clash with the existing ones\n  id: 'awesome_provider',\n\n  // Optional metadata property that can contain the optional fields \n  // such as provider `name`, `shortName` and `description`)\n  meta: {\n    name: 'My Super Awesome Wallet Provider',\n    shortName: 'Awesome Provider',\n    description: 'Just an Awesome Provider everyone using EOS gonna be using soon'\n  },\n\n  // Key part of the provider - `signatureProvider` is passed to `eosjs`\n  // directly, when `Api` instance is created. It should be an object with\n  // `getAvailableKeys` and `sign` methods.\n  // Refer to `eosjs` docs for more information (link below the code)\n  signatureProvider: {\n    getAvailableKeys() { ... },\n    sign(signatureProviderArgs) { ... }\n  },\n\n  // This method is used by `eos-transit` to connect to a provider.\n  // Should return a Promise of anything. The method accepts the\n  // `appName` as an argument so that the wallet app can, e.g.,\n  // request from the user a permission for the certain app.\n  connect(appName: string): Promise<any>;\n\n  // Disconnects from the provider. Returns a Promise of anything,\n  // just in case disconnection is some kind of process where provider\n  // needs to receive an acknowledgement from the wallet app.\n  disconnect(): Promise<any>;\n\n  // Login is basically a way of \"authenticating\" the user with \n  // a wallet app. Please note that the notion of \"authentication\"\n  // is different in decentralized world and its more for the\n  // wallet app and user convenience. Should return a promise\n  // of \"authentication metadata\" (`WalletAuth`).\n  // There's an optional `accountName` argument in case some\n  // provider authenticates or maintains some session for\n  // a given account (e.g., when wallet app itself isn't maintaining\n  // any kind of identity management, we need to let it know which\n  // user we're authenticating as in the first place).\n  login(accountName?: string): Promise<WalletAuth>;\n\n  // Logouts the current user or a user with given `accountName`.\n  // The user `accountName` argument is optional just like with `login`,\n  // as not all wallets might need it.\n  logout(accountName?: string): Promise<any>;\n}\n```\n\nHere's the link to [`eosjs` `SignatureProvider` reference](https://eosio.github.io/eosjs/interfaces/api_interfaces.signatureprovider.html).\n\nYou can also check how our wallet provider packages are implemented:\n\n- [`eos-transit-scatter-provider`](packages/eos-transit-scatter-provider/src/index.ts)\n- [`eos-transit-stub-provider`](packages/eos-transit-stub-provider/src/index.ts)\n\n\n#### Provider factory function\n\nThe above-described `WalletProvider` instance is whats being kept in the `eos-transit` state internally and is operated on. But before that happens, `eos-transit` needs to create the provider instance in the first place.\n\nWhen `WalletAccessContext` is being created, the `walletProviders` array is used to pass the providers. But what is \"providers\" we pass in a `walletProviders` array? Note that its not a `WalletProvidier` instance but instead a function with the following signature:\n\n```typescript\nmakeWalletProvider = (network: NetworkConfig) => WalletProvider\n```\n\nThat means that we pass the function that accepts `network` configuration as an argument and returns a `WalletProvider` instance. And we pass these functions as a `walletProviders` array to `initAccessContext(...)`. So, the custom wallet provider package should implement this function.\n\n\n#### Higher-order provider factory function\n\nIts also advisable to create a higher order `function` (which is a `function` that returns another `function`). The `makeWalletProvider` function could be created by another function if there's any additional arguments we want to pass to the provider just like we do with our [`eos-transit-stub-provider`](packages/eos-transit-stub-provider/src/index.ts).\n\nWe encourage to use the higher-order factory functions for all custom providers for consistency:\n\n```javascript\nimport { initAccessContext } from 'eos-transit';\nimport stub from 'eos-transit-stub-provider';\nimport scatter from 'eos-transit-scatter-provider';\nimport myProvider from 'my-own-provider-package';\n\nconst accessContext = initAccessContext({\n  appName: '...',\n  network: { ... },\n  walletProviders: [\n    stub({ ... }),\n    scatter(),\n    myProvider({ someOptionMaybe: 123 })\n  ]\n})\n```\n\nGood luck writing your own custom wallet provider!\n\n### TypeScript support\n\n[TODO]\n\n\n## API reference\n\n[TODO]\n\n\n## Contribution\n\nPlease see the [Contribution Guide](https://github.com/eosnewyork/eos-transit/#contribution) in the root `README`.\n","readmeFilename":"README.md"}