Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib/rest_5.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,14 @@ function* callList(user, txs, doNotResolve, node) {
* @param{Boolean} doNotResolve tell bloc to wait for resolution or return immediately
* @param{Object} txParams {gasLimit: Number, gasPrice: Number}
* @param{Number} node target nodeId
* @param{Object} imports Names and sources of files imported in contractSrc, e.g. {"imp.sol": "contract Imp {}", ...}
* @returns{()} doNotResolve=true: [transaction hash] (String), doNotResolve=false: [uploaded contract details]
*/
function* uploadContractString(user, contractName, contractSrc, args, doNotResolve, txParams, node) {
function* uploadContractString(user, contractName, contractSrc, args, doNotResolve, txParams, node, imports) {
const resolve = (doNotResolve) ? false : true;
args = args || {};
txParams = txParams || {};
imports = imports || {};
verbose('uploadContractString', {user, contractName, args, txParams, resolve, node});

var result = yield api.bloc.contract({
Expand All @@ -254,6 +256,7 @@ function* uploadContractString(user, contractName, contractSrc, args, doNotResol
args: args,
contract: contractName,
txParams: txParams,
imports: imports,
}, user.name, user.address, resolve, node)
.catch(function(e) {
throw (e instanceof Error) ? e : new HttpError(e);
Expand All @@ -278,12 +281,17 @@ function* uploadContractString(user, contractName, contractSrc, args, doNotResol
return result.hash;
}

function* uploadContract(user, contractName, contractFilename, args, doNotResolve, txParams, node) {
function* uploadContract(user, contractName, contractFilename, args, doNotResolve, txParams, node, importFilenames) {
verbose('uploadContract', {user, contractName, contractFilename, args, doNotResolve, txParams, node});
// get the source
// get the main source
const contractSrc = yield getContractString(contractName, contractFilename);
// get the import sources
const srcImports = {}
for (const file in importFilenames) {
srcImports[file] = yield getContractString("<imported>", file);
}
// upload
return yield uploadContractString(user, contractName, contractSrc, args, doNotResolve, txParams, node);
return yield uploadContractString(user, contractName, contractSrc, args, doNotResolve, txParams, node, srcImports);
}

/**
Expand Down