eth-lib
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "eth-lib", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Lightweight Ethereum libraries", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -50,3 +50,4 @@ const Api = provider => { | ||
const contract = (from, address, abi) => { | ||
// Address, Address, AbiDefinition -> Contract | ||
const contract = (from, address, abiDefinition) => { | ||
let contract = {}; | ||
@@ -56,3 +57,3 @@ contract._address = address; | ||
contract.broadcast = {}; | ||
abi.forEach(method => { | ||
abiDefinition.forEach(method => { | ||
if (method && method.name) { | ||
@@ -73,5 +74,5 @@ const call = (waitReceipt, value) => (...params) => { | ||
if (!method.constant) { | ||
contract[method.name+"$"] = (value, ...params) => call(true, value)(...params); | ||
contract.broadcast[method.name+"$"] = (value, ...params) => call(false, value)(...params); | ||
contract.broadcast[method.name] = call(false, "0x0"); | ||
contract[method.name+"_pay"] = value => (...params) => call(true, value)(...params); | ||
contract[method.name+"_pay_txid"] = value => (...params) => call(false, value)(...params); | ||
contract[method.name+"_txid"] = call(false, "0x0"); | ||
} | ||
@@ -83,31 +84,36 @@ } | ||
const solidityCodeAndAbi = source => | ||
compileSolidity(source) | ||
.then(comp => ({ | ||
code: comp.code, | ||
abi: comp.info.abiDefinition | ||
})); | ||
const solidityContract = (from, source, at) => | ||
solidityCodeAndAbi(source) | ||
.then(({abi}) => contract(from, at, abi)); | ||
const deployCode_ = (from, code) => | ||
// Address, Bytecode -> Txid | ||
const deployBytecode_txid = (from, code) => | ||
sendTransactionWithDefaults({from: from, data: code}); | ||
const deployCode = (from, code) => | ||
deplyoCode_(from,code) | ||
// Address, Bytecode -> Receipt | ||
const deployBytecode = (from, code) => | ||
deployBytecode_txid(from,code) | ||
.then(waitTransactionReceipt); | ||
const deploySolidity_ = (from, source) => | ||
solidityCodeAndAbi(source) | ||
.then(({code}) => deployCode_(from, code)); | ||
// Address, Bytecode, AbiDefinition | ||
const deployBytecodeContract = (from, code, abiDefinition) => | ||
deployBytecode(from, code) | ||
.then(receipt => contract(from, receipt.contractAddress, abiDefinition)); | ||
// Address, String, Address -> Contract | ||
const solidityContract = (from, source, at) => | ||
compileSolidity(source) | ||
.then(({info:{abiDefinition}}) => contract(from, at, abiDefinition)); | ||
// Address, String -> Txid | ||
const deploySolidity_txid = (from, source) => | ||
compileSolidity(source) | ||
.then(({code}) => deployBytecode_txid(from, code)); | ||
// Address, String -> Receipt | ||
const deploySolidity = (from, source) => | ||
deploySolidity_(from, source) | ||
deploySolidity_txid(from, source) | ||
.then(waitTransactionReceipt); | ||
// Address, String -> Contract | ||
const deploySolidityContract = (from, source) => | ||
deploySolidity(from, source) | ||
.then(receipt => contract(from, receipt.contractAddress, abi)); | ||
compileSolidity(source) | ||
.then(({code, info:{abiDefinition}}) => | ||
deployBytecodeContract(from, code, abiDefinition)); | ||
@@ -130,8 +136,11 @@ return { | ||
callMethodData, | ||
contract, | ||
solidityCodeAndAbi, | ||
deployBytecode_txid, | ||
deployBytecode, | ||
deployBytecodeContract, | ||
compileSolidity, | ||
solidityContract, | ||
deployCode_, | ||
deployCode, | ||
deploySolidity_, | ||
deploySolidity_txid, | ||
deploySolidity, | ||
@@ -138,0 +147,0 @@ deploySolidityContract |
47807
1147