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

Commit

Permalink
Update Wallet to new Wallet Code (#4805)
Browse files Browse the repository at this point in the history
* Update Wallet Version

* Update Wallet Library

* Update Wallets Bytecodes

* Typo

* Separate Deploy in Contract API

* Use the new Wallet ABI // Update wallet code

* WIP .// Deploy from Wallet

* Update Wallet contract

* Contract Deployment for Wallet

* Working deployments for Single Owned Wallet contracts

* Linting

* Create a Wallet from a Wallet

* Linting

* Fix Signer transactions // Add Gas Used for transactions

* Deploy wallet contract fix

* Fix too high gas estimate for Wallet Contract Deploys

* Final piece ; deploying from Wallet owned by wallet

* Update Wallet Code

* Updated the Wallet Codes

* Fixing Wallet Deployments

* Add Support for older wallets

* Linting
  • Loading branch information
ngotchac authored and jacogr committed Mar 7, 2017
1 parent 3b56e8e commit 6f9eaad
Show file tree
Hide file tree
Showing 20 changed files with 2,228 additions and 918 deletions.
48 changes: 20 additions & 28 deletions js/src/api/contract/contract.js
Expand Up @@ -107,58 +107,50 @@ export default class Contract {
});
}

deploy (options, values, statecb) {
const setState = (state) => {
if (!statecb) {
return;
}

return statecb(null, state);
};

setState({ state: 'estimateGas' });
deploy (options, values, statecb = () => {}) {
statecb(null, { state: 'estimateGas' });

return this
.deployEstimateGas(options, values)
.then(([gasEst, gas]) => {
options.gas = gas.toFixed(0);

setState({ state: 'postTransaction', gas });
statecb(null, { state: 'postTransaction', gas });

const _options = this._encodeOptions(this.constructors[0], options, values);
const encodedOptions = this._encodeOptions(this.constructors[0], options, values);

return this._api.parity
.postTransaction(_options)
.postTransaction(encodedOptions)
.then((requestId) => {
setState({ state: 'checkRequest', requestId });
statecb(null, { state: 'checkRequest', requestId });
return this._pollCheckRequest(requestId);
})
.then((txhash) => {
setState({ state: 'getTransactionReceipt', txhash });
statecb(null, { state: 'getTransactionReceipt', txhash });
return this._pollTransactionReceipt(txhash, gas);
})
.then((receipt) => {
if (receipt.gasUsed.eq(gas)) {
throw new Error(`Contract not deployed, gasUsed == ${gas.toFixed(0)}`);
}

setState({ state: 'hasReceipt', receipt });
statecb(null, { state: 'hasReceipt', receipt });
this._receipt = receipt;
this._address = receipt.contractAddress;
return this._address;
});
})
.then((address) => {
setState({ state: 'getCode' });
return this._api.eth.getCode(this._address);
})
.then((code) => {
if (code === '0x') {
throw new Error('Contract not deployed, getCode returned 0x');
}
})
.then((address) => {
statecb(null, { state: 'getCode' });
return this._api.eth.getCode(this._address);
})
.then((code) => {
if (code === '0x') {
throw new Error('Contract not deployed, getCode returned 0x');
}

setState({ state: 'completed' });
return this._address;
statecb(null, { state: 'completed' });
return this._address;
});
});
}

Expand Down

0 comments on commit 6f9eaad

Please sign in to comment.