Minimise transactions progress (#4942)

* Watch the requests and display them throughout the app

* Linting

* Showing Requests

* Fully working Transaction Requests Display

* Add FormattedMessage to Requests

* Clean-up the Transfer dialog

* Update Validations

* Cleanup Create Wallet

* Clean Deploy Contract Dialog

* Cleanup Contract Execution

* Fix Requests

* Cleanup Wallet Settings

* Don't show stepper in Portal if less than 2 steps

* WIP local storage requests

* Caching requests and saving contract deployments

* Add Historic prop to Requests MethodDecoding

* Fix tests

* Add Contract address to MethodDecoding

* PR Grumbles - Part I

* PR Grumbles - Part II

* Use API Subscription methods

* Linting

* Move SavedRequests and add tests

* Added tests for Requests Actions

* Fixing tests

* PR Grumbles + Playground fix

* Revert Playground changes

* PR Grumbles

* Better showEth in MethodDecoding
This commit is contained in:
Nicolas Gotchac
2017-03-28 14:34:31 +02:00
committed by Jaco Greeff
parent e28c477075
commit a99721004b
40 changed files with 1382 additions and 1216 deletions

View File

@@ -139,46 +139,46 @@ export function inOptionsCondition (condition) {
return condition;
}
export function inOptions (options) {
if (options) {
Object.keys(options).forEach((key) => {
switch (key) {
case 'to':
// Don't encode the `to` option if it's empty
// (eg. contract deployments)
if (options[key]) {
options[key] = inAddress(options[key]);
}
break;
export function inOptions (_options = {}) {
const options = { ..._options };
case 'from':
options[key] = inAddress(options[key]);
break;
Object.keys(options).forEach((key) => {
switch (key) {
case 'to':
// Don't encode the `to` option if it's empty
// (eg. contract deployments)
if (options[key]) {
options.to = inAddress(options[key]);
}
break;
case 'condition':
options[key] = inOptionsCondition(options[key]);
break;
case 'from':
options[key] = inAddress(options[key]);
break;
case 'gas':
case 'gasPrice':
options[key] = inNumber16((new BigNumber(options[key])).round());
break;
case 'condition':
options[key] = inOptionsCondition(options[key]);
break;
case 'minBlock':
options[key] = options[key] ? inNumber16(options[key]) : null;
break;
case 'gas':
case 'gasPrice':
options[key] = inNumber16((new BigNumber(options[key])).round());
break;
case 'value':
case 'nonce':
options[key] = inNumber16(options[key]);
break;
case 'minBlock':
options[key] = options[key] ? inNumber16(options[key]) : null;
break;
case 'data':
options[key] = inData(options[key]);
break;
}
});
}
case 'value':
case 'nonce':
options[key] = inNumber16(options[key]);
break;
case 'data':
options[key] = inData(options[key]);
break;
}
});
return options;
}

View File

@@ -380,7 +380,7 @@ export default class Parity {
.execute('parity_postSign', inAddress(address), inHex(hash));
}
postTransaction (options) {
postTransaction (options = {}) {
return this._transport
.execute('parity_postTransaction', inOptions(options));
}

View File

@@ -27,6 +27,7 @@ const events = {
'parity_accountsInfo': { module: 'personal' },
'parity_allAccountsInfo': { module: 'personal' },
'parity_defaultAccount': { module: 'personal' },
'parity_postTransaction': { module: 'signer' },
'eth_accounts': { module: 'personal' },
'signer_requestsToConfirm': { module: 'signer' }
};
@@ -83,7 +84,7 @@ export default class Manager {
if (!engine.isStarted) {
engine.start();
} else {
} else if (error !== null || data !== null) {
this._sendData(subscriptionId, error, data);
}

View File

@@ -124,7 +124,7 @@ describe('api/subscriptions/manager', () => {
});
});
it('does not call the callback after unsibscription', () => {
it('does not call the callback after unsubscription', () => {
expect(cb).to.have.been.calledWith(null, 'test');
expect(cb).to.not.have.been.calledWith(null, 'test2');
});

View File

@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
import { outTransaction } from '../format/output';
export default class Signer {
constructor (updateSubscriptions, api, subscriber) {
this._subscriber = subscriber;
@@ -58,6 +60,15 @@ export default class Signer {
.catch(nextTimeout);
}
_postTransaction (data) {
const request = {
transaction: outTransaction(data.params[0]),
requestId: data.json.result.result
};
this._updateSubscriptions('parity_postTransaction', null, request);
}
_loggingSubscribe () {
return this._subscriber.subscribe('logging', (error, data) => {
if (error || !data) {
@@ -65,11 +76,15 @@ export default class Signer {
}
switch (data.method) {
case 'parity_postTransaction':
case 'eth_sendTranasction':
case 'eth_sendTransaction':
case 'eth_sendRawTransaction':
this._listRequests(false);
return;
case 'parity_postTransaction':
this._postTransaction(data);
this._listRequests(false);
return;
}
});
}