Comparing version 0.4.0 to 0.5.0
@@ -6,1 +6,2 @@ | ||
module.exports.getInstance = require('./src/getInstance') | ||
module.exports.callInstance = require('./src/callInstance') |
{ | ||
"name": "chain-end", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "Programmatic pre-compiled Truffle contract deployment, and soon, more", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -21,1 +21,2 @@ # chain-end | ||
- the `getInstance` function, which retrieves a deployed contract given its artifact, its deployed address, a provider, and (optionally) a sender account | ||
- the `callInstance` function, which calls a specified function from a given TruffleContract instance and returns the result |
@@ -20,3 +20,3 @@ | ||
instanceAddress, | ||
senderAccount | ||
senderAccount=null | ||
) { | ||
@@ -47,6 +47,6 @@ | ||
if (!instance) { | ||
throw new Error('getInstance: no intsance was returned') | ||
throw new Error('getInstance: no instance was returned') | ||
} | ||
if (instance.address !== instanceAddress) { | ||
throw new Error('getInstance: instance missing address') | ||
throw new Error('getInstance: invalid instance address') | ||
} | ||
@@ -53,0 +53,0 @@ |
@@ -9,2 +9,3 @@ const ganache = require('ganache-cli') | ||
const getInstance = require('../index').getInstance | ||
const callInstance = require('../index').callInstance | ||
const contractParams = require('./helper').contractParameters | ||
@@ -148,3 +149,3 @@ const defaultContracts = require('../index').contracts | ||
describe('deploy and getInstance', () => { | ||
describe('deploy, getInstance, and callInstance', () => { | ||
@@ -217,3 +218,43 @@ const provider = ganache.provider() | ||
}) | ||
it('calls functions using callInstance', async () => { | ||
const deployedName = await callInstance(instance1, 'name') | ||
const deployedSymbol = await callInstance(instance1, 'symbol') | ||
const deployedDecimals = await callInstance(instance1, 'decimals') | ||
const deployedSupply = await callInstance(instance1, 'totalSupply') | ||
const deployerBalance = await callInstance(instance1, 'balanceOf', [accounts[0]]) | ||
assert.equal(deployedName, contractParams.token.StandardERC20.a[0], 'deployed name incorrect') | ||
assert.equal(deployedSymbol, contractParams.token.StandardERC20.a[1], 'deployed symbol incorrect') | ||
assert.equal(deployedDecimals, contractParams.token.StandardERC20.a[2], 'deployed decimals incorrect') | ||
assert.equal(deployedSupply, contractParams.token.StandardERC20.a[3], 'deployed supply incorrect') | ||
assert.equal(deployerBalance, contractParams.token.StandardERC20.a[3], 'deployer account balance incorrect') | ||
}) | ||
it('calls functions using callInstance, from different accounts', async () => { | ||
const deployerBalance = await callInstance(instance1, 'balanceOf', [accounts[0]], accounts[1]) | ||
const acc1Balance = await callInstance(instance1, 'balanceOf', [accounts[1]], accounts[2]) | ||
const acc2Balance = await callInstance(instance1, 'balanceOf', [accounts[2]], accounts[3]) | ||
assert.equal(deployerBalance, contractParams.token.StandardERC20.a[3], 'deployer account balance incorrect') | ||
assert.equal(acc1Balance, 0, 'account 1 balance incorrect') | ||
assert.equal(acc2Balance, 0, 'account 2 balance incorrect') | ||
}) | ||
it('calls write functions using callInstance, from different accounts', async () => { | ||
const transfer1 = await callInstance(instance1, 'transfer', [accounts[1], 500], accounts[0]) | ||
const transfer2 = await callInstance(instance1, 'transfer', [accounts[2], 250], accounts[1]) | ||
const deployerBalance = await callInstance(instance1, 'balanceOf', [accounts[0]], accounts[1]) | ||
const acc1Balance = await callInstance(instance1, 'balanceOf', [accounts[1]], accounts[2]) | ||
const acc2Balance = await callInstance(instance1, 'balanceOf', [accounts[2]], accounts[3]) | ||
assert.equal(deployerBalance, contractParams.token.StandardERC20.a[3] - 500, 'deployer account balance incorrect') | ||
assert.equal(acc1Balance, 250, 'account 1 balance incorrect') | ||
assert.equal(acc2Balance, 250, 'account 2 balance incorrect') | ||
}) | ||
}) | ||
}) |
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
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
180997
16
3632
22