{"_id":"@alexkeating/mock-web3-provider","_rev":"1-048caccf91557766de9b4567015f4d22","name":"@alexkeating/mock-web3-provider","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.3":{"name":"@alexkeating/mock-web3-provider","version":"1.0.3","main":"dist/index.js","repository":{"type":"git","url":"git@github.com:jessgusclark/mock-web3-provider.git"},"author":{"name":"Jesse Clark","email":"hello@developerjesse.com"},"license":"MIT","private":false,"scripts":{"build":"npx tsc --outDir ./dist","build:watch":"npx tsc -w --outDir ./dist","lint":"npx eslint ./src/*.ts","lint:fix":"npx eslint ./src/*.ts --fix","test":"npx jest","test:ci":"npx jest --verbose --coverage --watchAll=false --coverageDirectory reports --maxWorkers=2","test:watch":"npx jest --watch","prepublish":"npm run build"},"devDependencies":{"@types/jest":"^26.0.20","@typescript-eslint/eslint-plugin":"^4.15.1","@typescript-eslint/parser":"^4.15.1","eslint":"^7.20.0","eslint-config-airbnb-base":"^14.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-jest":"^24.1.3","jest":"^26.6.3","mockdate":"^3.0.5","ts-jest":"^26.5.1","typescript":"^4.1.5"},"dependencies":{"@ethersproject/bignumber":"^5.7.0","@metamask/eth-sig-util":"^4.0.1"},"description":"Setup the mock provider before the window loads and set it to the `win.ethereum` variable. For a complete integration example, see the [rLogin basic dapp test integration](https://github.com/rsksmart/rlogin-sample-apps/blob/main/basic-dapp/cypress/integra","licenseText":"MIT License\n\nCopyright (c) 2021 IOV Labs\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":"@alexkeating/mock-web3-provider@1.0.3","dist":{"shasum":"c62ffea078eacd1d1cfc06413b2df2ab5042a144","integrity":"sha512-SBZk0DhEfSyBjJW43azBLAJ5hLv8CoB618qj4qXPeb7DXO3ZYqR6c/0SeScrDOd1CpvLhNjH2ILzZoZQo3UCUg==","tarball":"https://registry.npmjs.org/@alexkeating/mock-web3-provider/-/mock-web3-provider-1.0.3.tgz","fileCount":9,"unpackedSize":34097,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEK1KqUlvW4HgWbWDdSEn5keY/5q4egB/Wo2veHhLfAaAiAODSEUg5yYKL1oH9nWo7ODsFICEz+2m3+FhdmtW1c+Tw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjSbOsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpgHA//ZWyQzYSfzbjKETp/UQzE93Tq96ogmC2ZL1b5sUrz81w2n/Ut\r\n1npCg2dptq4mrYRwusZAYtEup16L5SwK+EqbAJtFQbxaeXsjDUYoRXOxRSTp\r\nluXGKIEIIZW/aa+bpl9g7MWfSBmgr/M61Q7MIWJ0ytMm5UBfd6L5Za49a5Y5\r\nQrAy2PeHeaOJToCbjVx/yJrXZ9R1nBNuHSQcpFyKfSS82lqlp8mNTNOlYRpZ\r\nIKoRXEmakUZAnHuzRPEmgg76/hMz7psbqM/i0KqgzIluJD+kPHwBtE/6/SD/\r\ne1+yb9fozKnO/Cr3vC794/gV9Y+PSySX+CPT+bcFusIwUXU1K+121VDAxc2E\r\nFzGlm7/GQxwBrRBOaqC7aREZM6ze2TIpdfgZ+93gic6SaYj5/zoITOiT0tCY\r\n60vu5FcgoLBUcdZ8sqIxv0Qz8fnsveOOhkmYuXZ/6S6047DMFNzNt1ZUTSFz\r\nw8e6K8233iXXinS94WLw1LFGHbaLPU5WRY/41BMnqQnQJUmQBuoOEb5cTkAr\r\nYJCl9eeNQ/Ueq8Ewa3LgiRc0u1vl5fjQQQkFNrpR1RdI07f43rxOjrn+jpuF\r\nad3T+KqmlCaEWWrk9sZ442w9ZURRwjDufS5vcvnlkERC8bVfHMsswNBrB+4S\r\nrUjpetQ2J1K/2nBXayRNOA/MpUJKPg/Fyr8=\r\n=h4zP\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"alexkeating","email":"atk315315@gmail.com"},"directories":{},"maintainers":[{"name":"alexkeating","email":"atk315315@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mock-web3-provider_1.0.3_1665774508015_0.37118116859685535"},"_hasShrinkwrap":false},"1.0.4":{"name":"@alexkeating/mock-web3-provider","version":"1.0.4","main":"dist/index.js","repository":{"type":"git","url":"git@github.com:jessgusclark/mock-web3-provider.git"},"author":{"name":"Jesse Clark","email":"hello@developerjesse.com"},"license":"MIT","private":false,"scripts":{"build":"npx tsc --outDir ./dist","build:watch":"npx tsc -w --outDir ./dist","lint":"npx eslint ./src/*.ts","lint:fix":"npx eslint ./src/*.ts --fix","test":"npx jest","test:ci":"npx jest --verbose --coverage --watchAll=false --coverageDirectory reports --maxWorkers=2","test:watch":"npx jest --watch","prepublish":"npm run build"},"devDependencies":{"@types/jest":"^26.0.20","@typescript-eslint/eslint-plugin":"^4.15.1","@typescript-eslint/parser":"^4.15.1","eslint":"^7.20.0","eslint-config-airbnb-base":"^14.2.1","eslint-plugin-import":"^2.22.1","eslint-plugin-jest":"^24.1.3","jest":"^26.6.3","mockdate":"^3.0.5","ts-jest":"^26.5.1","typescript":"^4.1.5"},"dependencies":{"@ethersproject/bignumber":"^5.7.0","@metamask/eth-sig-util":"^4.0.1"},"description":"Setup the mock provider before the window loads and set it to the `win.ethereum` variable. For a complete integration example, see the [rLogin basic dapp test integration](https://github.com/rsksmart/rlogin-sample-apps/blob/main/basic-dapp/cypress/integra","licenseText":"MIT License\n\nCopyright (c) 2021 IOV Labs\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":"@alexkeating/mock-web3-provider@1.0.4","dist":{"shasum":"5135992ad098ddf7c83a0459be38ff801ae2b3c2","integrity":"sha512-ZkdhKirV1/RHLaihpg3Wxa9yYf/n5vO7OJsY7pajxl/hWszR2KOOPxz4HmvV5rkPqrDmpalK3Ghxl8SD/O+2KQ==","tarball":"https://registry.npmjs.org/@alexkeating/mock-web3-provider/-/mock-web3-provider-1.0.4.tgz","fileCount":9,"unpackedSize":34299,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIH/XW5aLtuH5l2VS3o+/XPi95Dw7eGJVU92f2WskUeUIAiEAgVocP1BMRtvZyG7whl9BmQunHwP07BmGbO/mZFB0xVg="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjSbbPACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrBGA/+PyjJhTbX/1MvTSuxMdSYw1fKt9e5rHVoJPUmMUB+a3pTBIaD\r\nUM7P9Hh4oHL1Aoz3dbHEp132xsf7ipSmOwzlbGo7QS9XdPAEZHLKZxfbcs2C\r\ndwcps5Byb2/F4FsOoWId83ouam57sdr0KpK4qfuv1MFcKhYWuW5Ab25eJxNS\r\naMens5vCMiZjnFVDtAzZug+bQOknU9Cn03DK76MpNfOd/Yj+nB4qWQdwqO/v\r\nCQdt5pRANv7euj2sivjxV/4jlkxHvMk5BCD3iv5EK15f4XgjEGt8Ri6WC4h2\r\nolInZm8wFspguPlUITHyROSS+UTkynwCXyt5aWKD0GYGa+Wj5COQmrMMwaWO\r\nIJsEgXQTRYHDK1ZlY2IA06TQ607N2ctMwk2NwZ9B7Uh3sVH+J2C+cQ+JwaYf\r\n6R/jByiXBf92bUicT1kcp2YIVDecZacobKn75GbedE0IIPAGZq8YqxI9Eebz\r\n+vPGQvxqTo7ih60h/wh5NRFAMN/0zuEL2s0618smTEvBUKZnXV5bfkChgYJx\r\n1U/qF73MXDs08CsphcP91bBFVyVjMl8Ee3+GzHToZje+xIos5ybP4aLWqYss\r\n29r+d5TP5eafeGIJJjmrXI4EJXgWO0JHDlBue42lLQlw37bcgagxj7nyR7lx\r\nyQTq54DbAjq092JnXQWNGBLZ+4Zfe8bOtl4=\r\n=x92/\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"alexkeating","email":"atk315315@gmail.com"},"directories":{},"maintainers":[{"name":"alexkeating","email":"atk315315@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mock-web3-provider_1.0.4_1665775311820_0.8144515853687568"},"_hasShrinkwrap":false}},"time":{"created":"2022-10-14T19:08:27.958Z","1.0.3":"2022-10-14T19:08:28.182Z","modified":"2022-10-14T19:21:52.040Z","1.0.4":"2022-10-14T19:21:51.953Z"},"maintainers":[{"name":"alexkeating","email":"atk315315@gmail.com"}],"description":"Setup the mock provider before the window loads and set it to the `win.ethereum` variable. For a complete integration example, see the [rLogin basic dapp test integration](https://github.com/rsksmart/rlogin-sample-apps/blob/main/basic-dapp/cypress/integra","repository":{"type":"git","url":"git@github.com:jessgusclark/mock-web3-provider.git"},"author":{"name":"Jesse Clark","email":"hello@developerjesse.com"},"license":"MIT","readme":"<p align=\"middle\">\n    <img src=\"https://www.rifos.org/assets/img/logo.svg\" alt=\"logo\" height=\"100\" >\n</p>\n<h3 align=\"middle\">mock-web3-provider</h3>\n<p align=\"middle\">\n    A mock web3 provider for Cypress built in Cyprus.\n</p>\n<p align=\"middle\">\n    <a href=\"https://circleci.com/gh/rsksmart/mock-web3-provider\">\n        <img src=\"https://img.shields.io/circleci/build/github/rsksmart/mock-web3-provider?label=CircleCI\" alt=\"npm\" />\n    </a>\n    <a href=\"https://lgtm.com/projects/g/rsksmart/mock-web3-provider/alerts/\">\n      <img src=\"https://img.shields.io/lgtm/alerts/github/rsksmart/mock-web3-provider\" alt=\"alerts\">\n    </a>\n    <a href=\"https://lgtm.com/projects/g/rsksmart/mock-web3-provider/context:javascript\">\n      <img src=\"https://img.shields.io/lgtm/grade/javascript/github/rsksmart/mock-web3-provider\">\n    </a>\n    <a href=\"https://www.npmjs.com/package/@rsksmart/mock-web3-provider\">\n      <img src=\"https://img.shields.io/npm/v/@rsksmart/mock-web3-provider\">\n    </a>\n</p>\n\nUnder development and missing many request methods and listeners. See below under 'contributing' to help!\n\n## Usage\n\nSetup the mock provider before the window loads and set it to the `win.ethereum` variable. For a complete integration example, see the [rLogin basic dapp test integration](https://github.com/rsksmart/rlogin-sample-apps/blob/main/basic-dapp/cypress/integration/injected_spec.js).\n\n```js\nimport { MockProvider } from './index'\n\ndescribe('test interaction with web3', () => {\n  beforeEach(() => {\n    cy.on(\"window:before:load\", (win) => {\n      win.ethereum = new MockProvider({ address, privateKey, networkVersion: 31, debug:false })\n\n      // when used with rLogin:\n      cy.visit('/')\n      cy.contains('Connect with rLogin').click()\n      cy.contains('MetaMask').click()\n    })\n  })\n\n  // assuming there is an item displaying the account when the user logs in\n  it('displays the account', () => {\n    cy.get('.account').should('have.text', `Account: ${address}`)\n  })\n\n  // additional e2e tests...\n})\n```\n\nTo handle user acceptance on `provider.request({ method: 'eth_requestAccounts', params: [] })`\n\n```ts\ndescribe('test user acceptance for eth_requestAccounts', function test(this: {\n  const address = '0xB98bD7C7f656290071E52D1aA617D9cB4467Fd6D'\n  const privateKey = 'de926db3012af759b4f24b5a51ef6afa397f04670f634aa4f48d4480417007f3'\n\n  beforeEach(async () => {\n    this.provider = new MockProvider({\n      address, privateKey, networkVersion: 31, debug: false, manualConfirmEnable: true\n    })\n  })\n  \n  it('resolves with acceptance', async () => {\n    expect.assertions(1)\n\n    const responsePromise = this.provider.request({ method: 'eth_requestAccounts', params: [] })\n      .then((accounts: any) => expect(accounts[0]).toEqual(address))\n\n    this.provider.answerEnable(true)\n    await responsePromise\n  })\n\n  it('rejects with denial', async () => {\n    expect.assertions(1)\n\n    const responsePromise = this.provider.request({ method: 'eth_requestAccounts', params: [] })\n      .catch((e) => expect(e).toBeDefined())\n\n    this.provider.answerEnable(false)\n    await responsePromise\n  })\n})\n```\n\n## Contributing\n\nAdditional mock methods should be added as well as the event listeners. PRs are welcomed as long as corresponding tests are included.\n","readmeFilename":"README.md"}