
Research
/Security News
Popular Tinycolor npm Package Compromised in Supply Chain Attack Affecting 40+ Packages
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
@withtally/cypress-metamask
Advanced tools
Interacting with you MetaMask made "easy". (Depending on how you define "easy" of course...)
Interacting with you MetaMask made "easy". (Depending on how you define "easy" of course...)
This plugin is based on the solutions brought by Jakub Mucha - drptbl in Synpress, and Thomas Ochman in cypress-metamask. The goal of this Fork is to provide a customized version focusing on Tally needs.
Note: This plugin is in development mode. You might encounter bugs and you will have to tweak your implementation a bit before you get it to work. But it is worth your effort in my opinon. Being able to run automated tests of your application is a good thing. ;-)
Install the package using yarn
or npm
:
$ yarn add -D @carlos0202/cypress-metamask
// or
$ npm i -D @carlos0202/cypress-metamask
Import the plugin in cypress/support/index.js
// Import commands.js using ES2015 syntax:
import './commands'
import '@carlos0202/cypress-metamask'
Modify your @carlos0202/cypress/plugins/index.js
to include the plugin:
module.exports = (on, config) => {
require('@carlos0202/cypress-metamask/plugins')(on)
}
Add an .env
file to your project root:
These settings are for a Hardhat development environment. You will need to tweak those setting depending on the enviroment you use.
CY_METAMASK_LIB_SECRET_WORDS="test test test test test test test test test test test junk"
PASSWORD=TestMetaMask
CY_METAMASK_LIB_METAMASK_VERSION=latest
CY_METAMASK_LIB_NETWORK_NAME=localhost
CY_METAMASK_LIB_RPC_URL=http://127.0.0.1:8545/
CY_METAMASK_LIB_CHAIN_ID=1337
Also, you can load a local version of metamask using the following environment variable and value:
CY_METAMASK_LIB_METAMASK_VERSION=local
This will load a local version already downloaded inside /support/assets/metamask
folder inside the library. You can also use a metamask extension locally available in a directory or your choice (inside project root) adding the following environment variable and value:
CY_METAMASK_LIB_METAMASK_LOCAL_PATH=assets/metamask
Add these scripts to your package.json
(or modify your existing scripts):
"cy:open": "CYPRESS_REMOTE_DEBUGGING_PORT=9222 cypress open"
You should be ready to go.
There is a small html/javascript (src/index.html) example that requires you to run a local chain to work. It uses the connected wallet to display its address and balance.
Once you have configured your setup and if you spin up a local chain, start a server and run your tests, you should be able to have the test pass.
Step-by-step
yarn start
) and navitate to http://localhost:3473
yarn cy:open
)describe('User can load page', () => {
before(() => {
cy.setupMetamask();
cy.changeMetamaskNetwork('localhost')
cy.visit('/')
});
it('is expected to display a sussess message', () => {
cy.get('[data-cy=title]').should('contain.text', 'MetaMask Detected')
});
it('is expected to display the local wallet address', () => {
cy.get('[data-cy=address').should('contain.text', 'Your address is: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266')
});
it('is expected to display the local wallet balance', () => {
cy.get('[data-cy=balance').should('contain.text', 'Balance: 10000000000000000000000')
});
})
FAQs
Interacting with you MetaMask made "easy". (Depending on how you define "easy" of course...)
We found that @withtally/cypress-metamask demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
Security News
pnpm's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.