Merge branch 'master' into ui-2

This commit is contained in:
Jaco Greeff 2017-05-09 13:47:29 +02:00
commit 40744d1bd2
9 changed files with 112 additions and 31 deletions

2
Cargo.lock generated
View File

@ -1781,7 +1781,7 @@ dependencies = [
[[package]]
name = "parity-ui-precompiled"
version = "1.4.0"
source = "git+https://github.com/paritytech/js-precompiled.git#b6fbfc59f044546ccd3b928fb17daa3812ae856e"
source = "git+https://github.com/paritytech/js-precompiled.git#0826776d9190ee6945bfe481e10b19ec05b3a049"
dependencies = [
"parity-dapps-glue 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@ -1,6 +1,6 @@
{
"name": "parity.js",
"version": "1.7.68",
"version": "1.7.69",
"main": "release/index.js",
"jsnext:main": "src/index.js",
"author": "Parity Team <admin@parity.io>",

View File

@ -99,15 +99,15 @@ export default class Event {
const namedTokens = {};
topicParams.forEach((param, idx) => {
namedTokens[param.name] = topicTokens[idx];
namedTokens[param.name || idx] = topicTokens[idx];
});
dataParams.forEach((param, idx) => {
namedTokens[param.name] = dataTokens[idx];
namedTokens[param.name || idx] = dataTokens[idx];
});
const inputParamTypes = this.inputParamTypes();
const decodedParams = this.inputParamNames()
.map((name, idx) => new DecodedLogParam(name, inputParamTypes[idx], namedTokens[name]));
.map((name, idx) => new DecodedLogParam(name, inputParamTypes[idx], namedTokens[name || idx]));
return new DecodedLog(decodedParams, address);
}

View File

@ -182,10 +182,11 @@ export default class Contract {
log.params = {};
log.event = event.name;
decoded.params.forEach((param) => {
decoded.params.forEach((param, index) => {
const { type, value } = param.token;
const key = param.name || index;
log.params[param.name] = { type, value };
log.params[key] = { type, value };
});
return log;

View File

@ -93,6 +93,16 @@ export function outChainStatus (status) {
}
export function outDate (date) {
if (typeof date.toISOString === 'function') {
return date;
}
try {
if (typeof date === 'string' && (new Date(date)).toISOString() === date) {
return new Date(date);
}
} catch (error) {}
return new Date(outNumber(date).toNumber() * 1000);
}

View File

@ -112,11 +112,16 @@ export default class Event extends Component {
}
renderParam (name, param) {
// Don't add a label id the name is an index key (ie. a Number)
const label = parseInt(name).toString() === name.toString()
? undefined
: name;
return (
<TypedInput
allowCopy
className={ styles.input }
label={ name }
label={ label }
param={ param.type }
readOnly
value={ param.value }

View File

@ -139,9 +139,10 @@ export default class ContractDevelopStore {
this.worker = worker;
this
.fetchSolidityVersions()
.then(() => this.reloadContracts());
return Promise.all([
this.fetchSolidityVersions(),
this.reloadContracts(undefined, undefined, false)
]);
}
fetchSolidityVersions () {
@ -397,11 +398,10 @@ export default class ContractDevelopStore {
const { errors = [] } = data;
const errorAnnotations = this.parseErrors(errors);
const formalAnnotations = this.parseErrors(data.formal && data.formal.errors, true);
// const formalAnnotations = this.parseErrors(data.formal && data.formal.errors, true);
const annotations = [].concat(
errorAnnotations,
formalAnnotations
errorAnnotations
);
const contractKeys = Object.keys(contracts || {});
@ -493,7 +493,7 @@ export default class ContractDevelopStore {
this.reloadContracts(cId);
}
@action reloadContracts = (id, sourcecode) => {
@action reloadContracts = (id, sourcecode, recompile = true) => {
const localStore = store.get(WRITE_CONTRACT_STORE_KEY) || {};
this.savedContracts = localStore.saved || {};
@ -513,7 +513,9 @@ export default class ContractDevelopStore {
this.resizeEditor();
return this.handleCompile();
if (recompile) {
return this.handleCompile();
}
}
@action handleLoadContract = (contract) => {

View File

@ -247,8 +247,6 @@ class WalletSettings extends Component {
}
renderChange (change) {
const { accountsInfo } = this.props;
switch (change.type) {
case 'dailylimit':
return (
@ -279,14 +277,50 @@ class WalletSettings extends Component {
id='walletSettings.ownersChange.details'
defaultMessage=' from {from} to {to} '
values={ {
from: <code>change.initial.toNumber()</code>,
to: <code>change.value.toNumber()</code>
from: <code>{ change.initial.toNumber() }</code>,
to: <code>{ change.value.toNumber() }</code>
} }
/>
</div>
</div>
);
case 'change_owner':
return (
<div className={ [ styles.change ].join(' ') }>
<div className={ styles.label }>
<FormattedMessage
id='walletSettings.changeOwner.title'
defaultMessage='Change Owner'
/>
</div>
<div>
<InputAddress
disabled
label={
<FormattedMessage
id='walletSettings.changeOwner.labelFrom'
defaultMessage='From'
/>
}
text
value={ change.value.from }
/>
<InputAddress
disabled
label={
<FormattedMessage
id='walletSettings.changeOwner.labelTo'
defaultMessage='To'
/>
}
text
value={ change.value.to }
/>
</div>
</div>
);
case 'add_owner':
return (
<div className={ [ styles.change, styles.add ].join(' ') }>
@ -299,8 +333,8 @@ class WalletSettings extends Component {
<div>
<InputAddress
disabled
text
value={ change.value }
accounts={ accountsInfo }
/>
</div>
</div>
@ -318,8 +352,8 @@ class WalletSettings extends Component {
<div>
<InputAddress
disabled
text
value={ change.value }
accounts={ accountsInfo }
/>
</div>
</div>

View File

@ -78,12 +78,16 @@ export default class WalletSettingsStore {
const changes = data.map((datum) => {
const [ type, valueStr ] = datum.split(';');
let value = valueStr;
let value;
// Only addresses start with `0x`, the others
// are BigNumbers
if (!/^0x/.test(valueStr)) {
value = new BigNumber(valueStr, 16);
if (/^#BN#/.test(valueStr)) {
value = new BigNumber(valueStr.replace(/^#BN#/, ''), 16);
} else {
try {
value = JSON.parse(valueStr);
} catch (e) {
value = valueStr;
}
}
return { type, value };
@ -104,8 +108,8 @@ export default class WalletSettingsStore {
const { type, value } = change;
const valueStr = (value && typeof value.plus === 'function')
? value.toString(16)
: value;
? '#BN#' + value.toString(16)
: JSON.stringify(value);
return [
type,
@ -147,14 +151,26 @@ export default class WalletSettingsStore {
const ownersToRemove = prevOwners.filter((owner) => !nextOwners.includes(owner));
const ownersToAdd = nextOwners.filter((owner) => !prevOwners.includes(owner));
ownersToRemove.forEach((owner) => {
const ownersChangeCount = Math.min(ownersToRemove.length, ownersToAdd.length);
for (let i = 0; i < ownersChangeCount; i++) {
changes.push({
type: 'change_owner',
value: {
from: ownersToRemove[i],
to: ownersToAdd[i]
}
});
}
ownersToRemove.slice(ownersChangeCount).forEach((owner) => {
changes.push({
type: 'remove_owner',
value: owner
});
});
ownersToAdd.forEach((owner) => {
ownersToAdd.slice(ownersChangeCount).forEach((owner) => {
changes.push({
type: 'add_owner',
value: owner
@ -182,6 +198,12 @@ export default class WalletSettingsStore {
this.wallet.require = value;
break;
case 'change_owner':
this.wallet.owners = this.wallet.owners
.filter((owner) => owner !== value.from)
.concat(value.to);
break;
case 'remove_owner':
this.wallet.owners = this.wallet.owners.filter((owner) => owner !== value);
break;
@ -309,6 +331,13 @@ export default class WalletSettingsStore {
};
}
if (change.type === 'change_owner') {
return {
method: walletInstance.changeOwner,
values: [ change.value.from, change.value.to ]
};
}
if (change.type === 'remove_owner') {
return {
method: walletInstance.removeOwner,