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]] [[package]]
name = "parity-ui-precompiled" name = "parity-ui-precompiled"
version = "1.4.0" 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 = [ dependencies = [
"parity-dapps-glue 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps-glue 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
] ]

View File

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

View File

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

View File

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

View File

@ -93,6 +93,16 @@ export function outChainStatus (status) {
} }
export function outDate (date) { 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); return new Date(outNumber(date).toNumber() * 1000);
} }

View File

@ -112,11 +112,16 @@ export default class Event extends Component {
} }
renderParam (name, param) { 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 ( return (
<TypedInput <TypedInput
allowCopy allowCopy
className={ styles.input } className={ styles.input }
label={ name } label={ label }
param={ param.type } param={ param.type }
readOnly readOnly
value={ param.value } value={ param.value }

View File

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

View File

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

View File

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