Socket
Socket
Sign inDemoInstall

ethereum-waffle

Package Overview
Dependencies
Maintainers
1
Versions
238
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereum-waffle - npm Package Compare versions

Comparing version 0.2.3 to 1.0.0

docs/images/logo.png

14

lib/compiler.js

@@ -96,1 +96,15 @@ import fs from 'fs';

}
export async function compile(configPath) {
try {
let config = {};
if (configPath) {
const contents = fs.readFileSync(configPath);
config = JSON.parse(contents);
}
const compiler = new Compiler(config);
await compiler.compile();
} catch (err) {
console.error(err);
}
}

16

lib/matchers.js

@@ -1,2 +0,1 @@

import {arrayIntersection} from './utils';
import overwriteBigNumberFunction from './matchers/overwriteBigNumberFunction';

@@ -66,4 +65,4 @@

const filterLogsWithTopics = (logs, topics) =>
logs.filter((log) => arrayIntersection(topics, log.topics).length > 0);
const filterLogsWithTopics = (logs, topic) =>
logs.filter((log) => log.topics.includes(topic));

@@ -76,4 +75,4 @@ Assertion.addMethod('emit', function (contract, eventName) {

).then((receipt) => {
const {topics} = contract.interface.events[eventName];
this.logs = filterLogsWithTopics(receipt.logs, topics);
const {topic} = contract.interface.events[eventName];
this.logs = filterLogsWithTopics(receipt.logs, topic);
if (this.logs.length < 1) {

@@ -108,7 +107,4 @@ this.assert(false,

const derivedPromise = this.promise.then(() => {
const event = this.contract.interface.events[this.eventName];
const [{topics}] = this.logs;
const [{data}] = this.logs;
const actualArgs = event.parse(topics, data);
assertArgsArraysEqual(this, expectedArgs, actualArgs);
const actualArgs = this.contract.interface.parseLog(this.logs[0]);
assertArgsArraysEqual(this, expectedArgs, actualArgs.values);
});

@@ -115,0 +111,0 @@ this.then = derivedPromise.then.bind(derivedPromise);

@@ -1,8 +0,8 @@

import ethers from 'ethers';
import {utils} from 'ethers';
const overwriteBigNumberFunction = (functionName, readableName, _super, utils) =>
const overwriteBigNumberFunction = (functionName, readableName, _super, chaiUtils) =>
function (...args) {
const [actual] = args;
const expected = utils.flag(this, 'object');
if (expected instanceof ethers.utils.BigNumber) {
const expected = chaiUtils.flag(this, 'object');
if (expected instanceof utils.BigNumber) {
this.assert(expected[functionName](actual),

@@ -13,3 +13,3 @@ `Expected "${expected}" to be ${readableName} ${actual}`,

actual);
} else if (actual instanceof ethers.utils.BigNumber) {
} else if (actual instanceof utils.BigNumber) {
this.assert(actual[functionName](expected),

@@ -16,0 +16,0 @@ `Expected "${expected}" to be ${readableName} ${actual}`,

@@ -6,5 +6,2 @@ import fs from 'fs';

export const arrayIntersection = (array1, array2) =>
array1.filter((element) => array2.includes(element));
export const isPositiveIntegerString = (string) =>

@@ -11,0 +8,0 @@ /^\d+$/.test(string);

@@ -1,5 +0,3 @@

import fs from 'fs';
import Ganache from 'ganache-core';
import Compiler from './compiler';
import ethers, {providers} from 'ethers';
import {ContractFactory, providers, Contract, Wallet} from 'ethers';
import matchers from './matchers';

@@ -17,35 +15,21 @@ import defaultAccounts from './config/defaultAccounts';

export async function getWallets(provider) {
return defaultAccounts.map((account) => new ethers.Wallet(account.secretKey, provider));
return defaultAccounts.map((account) => new Wallet(account.secretKey, provider));
}
export async function deployContract(wallet, contractJSON, args = [], overrideOptions = {}) {
const {provider} = wallet;
const abi = contractJSON.interface;
const bytecode = `0x${contractJSON.bytecode}`;
const abi = contractJSON.interface;
const factory = new ContractFactory(abi, bytecode, wallet);
const deployTransaction = {
...defaultDeployOptions,
...overrideOptions,
...ethers.Contract.getDeployTransaction(bytecode, abi, ...args)
...factory.getDeployTransaction(...args)
};
const tx = await wallet.sendTransaction(deployTransaction);
const receipt = await provider.getTransactionReceipt(tx.hash);
return new ethers.Contract(receipt.contractAddress, abi, wallet);
const receipt = await wallet.provider.getTransactionReceipt(tx.hash);
return new Contract(receipt.contractAddress, abi, wallet);
}
export async function compile(configPath) {
try {
let config = {};
if (configPath) {
const contents = fs.readFileSync(configPath);
config = JSON.parse(contents);
}
const compiler = new Compiler(config);
await compiler.compile();
} catch (err) {
console.error(err);
}
}
export const contractWithWallet = (contract, wallet) =>
new ethers.Contract(contract.address, contract.interface.abi, wallet);
new Contract(contract.address, contract.interface.abi, wallet);

@@ -52,0 +36,0 @@ export {defaultAccounts};

{
"name": "ethereum-waffle",
"description": "Sweeter and simpler than truffle.",
"version": "0.2.3",
"version": "1.0.0",
"author": "Marek Kirejczyk <account@ethworks.io> (http://ethworks.io)",

@@ -26,3 +26,3 @@ "repository": "git@github.com:EthWorks/Waffle.git",

"dependencies": {
"ethers": "^3.0.27",
"ethers": "^4.0.0",
"solc": "^0.4.24"

@@ -29,0 +29,0 @@ },

[![Build Status](https://travis-ci.com/EthWorks/Waffle.svg?token=xjj4U84eSFwEsYLTc5Qe&branch=master)](https://travis-ci.com/EthWorks/Waffle)
# Ethereum Waffle
![Ethereum Waffle](https://raw.githubusercontent.com/EthWorks/Waffle/master/docs/images/logo.png)
Library for writing and testing smart contracts.

@@ -8,3 +9,3 @@

Works with [ethers-js](https://github.com/ethers-io/ethers.js/). Taste best with ES6.
Works with [ethers-js](https://github.com/ethers-io/ethers.js/). Tastes best with ES6.

@@ -15,2 +16,6 @@ ## Philosophy

## Versions and ethers compatibility
* Use version 0.2.3+ with ethers 3.*
* Use version 1.0.0+ with ethers 4.*
## Install:

@@ -17,0 +22,0 @@ To start using with npm, type:

import fs from 'fs';
import fsx from 'fs-extra';
import {expect} from 'chai';
import {compile} from '../../lib/waffle';
import {compile} from '../../lib/compiler';

@@ -6,0 +6,0 @@ describe('Compile', () => {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc