ethereum-waffle
Advanced tools
Comparing version 0.2.3 to 1.0.0
@@ -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); | ||
} | ||
} |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
542250
54
10535
1
210
10
+ Addedelliptic@6.5.4(transitive)
+ Addedethers@4.0.49(transitive)
+ Addedhash.js@1.1.3(transitive)
+ Addedhmac-drbg@1.0.1(transitive)
+ Addedminimalistic-crypto-utils@1.0.1(transitive)
+ Addedscrypt-js@2.0.4(transitive)
- Removedelliptic@6.3.3(transitive)
- Removedethers@3.0.29(transitive)
- Removedhash.js@1.1.7(transitive)
- Removedinherits@2.0.1(transitive)
- Removedscrypt-js@2.0.3(transitive)
Updatedethers@^4.0.0