Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
deployment round #1 works
Browse files Browse the repository at this point in the history
  • Loading branch information
jacogr committed Sep 20, 2016
1 parent 1896c53 commit 1e1209a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 5 additions & 9 deletions js/src/api/contract/contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import Abi from '../../abi';
import Api from '../api';
import { isInstanceOf, isObject } from '../util/types';
import { isInstanceOf } from '../util/types';

let nextSubscriptionId = 0;

Expand Down Expand Up @@ -81,7 +81,7 @@ export default class Contract {
return this;
}

deploy (optionsOrCode, values, statecb) {
deploy (options, values, statecb) {
let gas;

const setState = (state) => {
Expand All @@ -92,11 +92,6 @@ export default class Contract {
return statecb(null, state);
};

const options = Object.assign({}, isObject(optionsOrCode)
? optionsOrCode
: { data: optionsOrCode }
);

setState({ state: 'estimateGas' });

return this._api.eth
Expand Down Expand Up @@ -204,12 +199,13 @@ export default class Contract {
}

_encodeOptions (func, options, values) {
const tokens = this._abi.encodeTokens(func.inputParamTypes(), values);
const tokens = func ? this._abi.encodeTokens(func.inputParamTypes(), values) : null;
const call = tokens ? func.encodeCall(tokens) : null;

if (options.data && options.data.substr(0, 2) === '0x') {
options.data = options.data.substr(2);
}
options.data = `0x${options.data || ''}${func.encodeCall(tokens)}`;
options.data = `0x${options.data || ''}${call || ''}`;

return options;
}
Expand Down
8 changes: 6 additions & 2 deletions js/src/modals/DeployContract/deployContract.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,17 @@ class DeployContract extends Component {
onDeployStart = () => {
const { api } = this.context;
const { newError } = this.props;
const { parsedAbi, code, description, name } = this.state;
const { parsedAbi, code, description, name, fromAddress } = this.state;
const options = {
data: code,
from: fromAddress
};

this.setState({ step: 2 });

api
.newContract(parsedAbi)
.deploy(code, null, this.onDeploymentState)
.deploy(options, null, this.onDeploymentState)
.then((address) => {
return Promise.all([
api.personal.setAccountName(address, name),
Expand Down

0 comments on commit 1e1209a

Please sign in to comment.