parent
4a9bd0af64
commit
fb82c6c415
@ -310,17 +310,13 @@ class CreateAccount extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onCreate = () => {
|
onCreate = () => {
|
||||||
this.store.setBusy(true);
|
|
||||||
|
|
||||||
return this.store
|
return this.store
|
||||||
.createAccount(this.vaultStore)
|
.createAccount(this.vaultStore)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.store.setBusy(false);
|
|
||||||
this.store.nextStage();
|
this.store.nextStage();
|
||||||
this.props.onUpdate && this.props.onUpdate();
|
this.props.onUpdate && this.props.onUpdate();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.store.setBusy(false);
|
|
||||||
this.props.newError(error);
|
this.props.newError(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
import BigNumber from 'bignumber.js';
|
import BigNumber from 'bignumber.js';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
|
|
||||||
|
import Api from '~/api';
|
||||||
import Store from './store';
|
import Store from './store';
|
||||||
|
|
||||||
const ADDRESS = '0x00000123456789abcdef123456789abcdef123456789abcdef';
|
const ADDRESS = '0x00000123456789abcdef123456789abcdef123456789abcdef';
|
||||||
@ -45,7 +46,8 @@ function createApi () {
|
|||||||
setAccountName: sinon.stub().resolves(),
|
setAccountName: sinon.stub().resolves(),
|
||||||
listVaults: sinon.stub().resolves([]),
|
listVaults: sinon.stub().resolves([]),
|
||||||
listOpenedVaults: sinon.stub().resolves([])
|
listOpenedVaults: sinon.stub().resolves([])
|
||||||
}
|
},
|
||||||
|
util: Api.util
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ export default class Store {
|
|||||||
return !(this.nameError || this.walletFileError);
|
return !(this.nameError || this.walletFileError);
|
||||||
|
|
||||||
case 'fromNew':
|
case 'fromNew':
|
||||||
return !(this.nameError || this.passwordRepeatError);
|
return !(this.nameError || this.passwordRepeatError) && this.hasAddress && this.hasPhrase;
|
||||||
|
|
||||||
case 'fromPhrase':
|
case 'fromPhrase':
|
||||||
return !(this.nameError || this.passwordRepeatError || this.passPhraseError);
|
return !(this.nameError || this.passwordRepeatError || this.passPhraseError);
|
||||||
@ -90,6 +90,10 @@ export default class Store {
|
|||||||
return !!(this.address);
|
return !!(this.address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed get hasPhrase () {
|
||||||
|
return this.phrase.length !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
@computed get passwordRepeatError () {
|
@computed get passwordRepeatError () {
|
||||||
return this.password === this.passwordRepeat
|
return this.password === this.passwordRepeat
|
||||||
? null
|
? null
|
||||||
@ -102,7 +106,7 @@ export default class Store {
|
|||||||
this.passwordRepeat = '';
|
this.passwordRepeat = '';
|
||||||
this.phrase = '';
|
this.phrase = '';
|
||||||
this.name = '';
|
this.name = '';
|
||||||
this.nameError = null;
|
this.nameError = ERRORS.noName;
|
||||||
this.rawKey = '';
|
this.rawKey = '';
|
||||||
this.rawKeyError = null;
|
this.rawKeyError = null;
|
||||||
this.vaultName = '';
|
this.vaultName = '';
|
||||||
@ -228,6 +232,10 @@ export default class Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@action nextStage = () => {
|
@action nextStage = () => {
|
||||||
|
if (this.stage === 0) {
|
||||||
|
this.clearErrors();
|
||||||
|
}
|
||||||
|
|
||||||
this.stage++;
|
this.stage++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,6 +244,10 @@ export default class Store {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createAccount = (vaultStore) => {
|
createAccount = (vaultStore) => {
|
||||||
|
if (!this.canCreate) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
this.setBusy(true);
|
this.setBusy(true);
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
@ -89,7 +89,7 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
store.clearErrors();
|
store.clearErrors();
|
||||||
|
|
||||||
expect(store.name).to.equal('');
|
expect(store.name).to.equal('');
|
||||||
expect(store.nameError).to.be.null;
|
expect(store.nameError).not.to.be.null;
|
||||||
expect(store.password).to.equal('');
|
expect(store.password).to.equal('');
|
||||||
expect(store.passwordRepeatError).to.be.null;
|
expect(store.passwordRepeatError).to.be.null;
|
||||||
expect(store.rawKey).to.equal('');
|
expect(store.rawKey).to.equal('');
|
||||||
@ -293,6 +293,7 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
describe('createType === fromJSON/fromPresale', () => {
|
describe('createType === fromJSON/fromPresale', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store.setCreateType('fromJSON');
|
store.setCreateType('fromJSON');
|
||||||
|
store.setName('blah');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns true on no errors', () => {
|
it('returns true on no errors', () => {
|
||||||
@ -313,6 +314,9 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
describe('createType === fromNew', () => {
|
describe('createType === fromNew', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store.setCreateType('fromNew');
|
store.setCreateType('fromNew');
|
||||||
|
store.setAddress('0x0000000000000000000000000000000000000000');
|
||||||
|
store.setName('blah');
|
||||||
|
store.setPhrase('testing');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns true on no errors', () => {
|
it('returns true on no errors', () => {
|
||||||
@ -324,6 +328,12 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
expect(store.canCreate).to.be.false;
|
expect(store.canCreate).to.be.false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns false on no phrase', () => {
|
||||||
|
store.setPhrase('');
|
||||||
|
|
||||||
|
expect(store.canCreate).to.be.false;
|
||||||
|
});
|
||||||
|
|
||||||
it('returns false on passwordRepeatError', () => {
|
it('returns false on passwordRepeatError', () => {
|
||||||
store.setPassword('testing');
|
store.setPassword('testing');
|
||||||
expect(store.canCreate).to.be.false;
|
expect(store.canCreate).to.be.false;
|
||||||
@ -333,6 +343,7 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
describe('createType === fromPhrase', () => {
|
describe('createType === fromPhrase', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store.setCreateType('fromPhrase');
|
store.setCreateType('fromPhrase');
|
||||||
|
store.setName('name');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns true on no errors', () => {
|
it('returns true on no errors', () => {
|
||||||
@ -353,6 +364,8 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
describe('createType === fromRaw', () => {
|
describe('createType === fromRaw', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
store.setCreateType('fromRaw');
|
store.setCreateType('fromRaw');
|
||||||
|
store.setName('name');
|
||||||
|
store.setRawKey('0x1000000000000000000000000000000000000000000000000000000000000000');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns true on no errors', () => {
|
it('returns true on no errors', () => {
|
||||||
@ -370,7 +383,7 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns false on rawKeyError', () => {
|
it('returns false on rawKeyError', () => {
|
||||||
store.setRawKey('testing');
|
store.setRawKey('0x1');
|
||||||
expect(store.canCreate).to.be.false;
|
expect(store.canCreate).to.be.false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -415,6 +428,9 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
createAccountFromPhraseSpy = sinon.spy(store, 'createAccountFromPhrase');
|
createAccountFromPhraseSpy = sinon.spy(store, 'createAccountFromPhrase');
|
||||||
createAccountFromRawSpy = sinon.spy(store, 'createAccountFromRaw');
|
createAccountFromRawSpy = sinon.spy(store, 'createAccountFromRaw');
|
||||||
busySpy = sinon.spy(store, 'setBusy');
|
busySpy = sinon.spy(store, 'setBusy');
|
||||||
|
|
||||||
|
store.setName('name');
|
||||||
|
store.setPhrase('testing');
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
@ -432,6 +448,8 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
|
|
||||||
it('calls createAccountFromGeth on createType === fromGeth', () => {
|
it('calls createAccountFromGeth on createType === fromGeth', () => {
|
||||||
store.setCreateType('fromGeth');
|
store.setCreateType('fromGeth');
|
||||||
|
store.setGethAccountsAvailable(GETH_ADDRESSES);
|
||||||
|
store.selectGethAccount(GETH_ADDRESSES[0]);
|
||||||
|
|
||||||
return store.createAccount().then(() => {
|
return store.createAccount().then(() => {
|
||||||
expect(createAccountFromGethSpy).to.have.been.called;
|
expect(createAccountFromGethSpy).to.have.been.called;
|
||||||
@ -440,6 +458,8 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
|
|
||||||
it('calls createAccountFromWallet on createType === fromJSON', () => {
|
it('calls createAccountFromWallet on createType === fromJSON', () => {
|
||||||
store.setCreateType('fromJSON');
|
store.setCreateType('fromJSON');
|
||||||
|
store.setName('name');
|
||||||
|
store.setWalletJson('{}');
|
||||||
|
|
||||||
return store.createAccount().then(() => {
|
return store.createAccount().then(() => {
|
||||||
expect(createAccountFromWalletSpy).to.have.been.called;
|
expect(createAccountFromWalletSpy).to.have.been.called;
|
||||||
@ -448,6 +468,9 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
|
|
||||||
it('calls createAccountFromPhrase on createType === fromNew', () => {
|
it('calls createAccountFromPhrase on createType === fromNew', () => {
|
||||||
store.setCreateType('fromNew');
|
store.setCreateType('fromNew');
|
||||||
|
store.setName('name');
|
||||||
|
store.setPhrase('phrase');
|
||||||
|
store.setAddress('0x1234567890123456789012345678901234567890');
|
||||||
|
|
||||||
return store.createAccount().then(() => {
|
return store.createAccount().then(() => {
|
||||||
expect(createAccountFromPhraseSpy).to.have.been.called;
|
expect(createAccountFromPhraseSpy).to.have.been.called;
|
||||||
@ -456,6 +479,9 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
|
|
||||||
it('calls createAccountFromPhrase on createType === fromPhrase', () => {
|
it('calls createAccountFromPhrase on createType === fromPhrase', () => {
|
||||||
store.setCreateType('fromPhrase');
|
store.setCreateType('fromPhrase');
|
||||||
|
store.setName('name');
|
||||||
|
store.setPhrase('phrase');
|
||||||
|
store.setAddress('0x1234567890123456789012345678901234567890');
|
||||||
|
|
||||||
return store.createAccount().then(() => {
|
return store.createAccount().then(() => {
|
||||||
expect(createAccountFromPhraseSpy).to.have.been.called;
|
expect(createAccountFromPhraseSpy).to.have.been.called;
|
||||||
@ -464,6 +490,8 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
|
|
||||||
it('calls createAccountFromWallet on createType === fromPresale', () => {
|
it('calls createAccountFromWallet on createType === fromPresale', () => {
|
||||||
store.setCreateType('fromPresale');
|
store.setCreateType('fromPresale');
|
||||||
|
store.setName('name');
|
||||||
|
store.setWalletJson('{}');
|
||||||
|
|
||||||
return store.createAccount().then(() => {
|
return store.createAccount().then(() => {
|
||||||
expect(createAccountFromWalletSpy).to.have.been.called;
|
expect(createAccountFromWalletSpy).to.have.been.called;
|
||||||
@ -472,6 +500,8 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
|
|
||||||
it('calls createAccountFromRaw on createType === fromRaw', () => {
|
it('calls createAccountFromRaw on createType === fromRaw', () => {
|
||||||
store.setCreateType('fromRaw');
|
store.setCreateType('fromRaw');
|
||||||
|
store.setName('name');
|
||||||
|
store.setRawKey('0x1000000000000000000000000000000000000000000000000000000000000000');
|
||||||
|
|
||||||
return store.createAccount().then(() => {
|
return store.createAccount().then(() => {
|
||||||
expect(createAccountFromRawSpy).to.have.been.called;
|
expect(createAccountFromRawSpy).to.have.been.called;
|
||||||
@ -481,6 +511,9 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
it('moves account to vault when vaultName set', () => {
|
it('moves account to vault when vaultName set', () => {
|
||||||
store.setCreateType('fromNew');
|
store.setCreateType('fromNew');
|
||||||
store.setVaultName('testing');
|
store.setVaultName('testing');
|
||||||
|
store.setName('name');
|
||||||
|
store.setAddress('0x1234567890123456789012345678901234567890');
|
||||||
|
store.setPhrase('phrase');
|
||||||
|
|
||||||
return store.createAccount(vaultStore).then(() => {
|
return store.createAccount(vaultStore).then(() => {
|
||||||
expect(vaultStore.moveAccount).to.have.been.calledWith('testing', ADDRESS);
|
expect(vaultStore.moveAccount).to.have.been.calledWith('testing', ADDRESS);
|
||||||
@ -489,6 +522,9 @@ describe('modals/CreateAccount/Store', () => {
|
|||||||
|
|
||||||
it('sets and rests the busy flag', () => {
|
it('sets and rests the busy flag', () => {
|
||||||
store.setCreateType('fromNew');
|
store.setCreateType('fromNew');
|
||||||
|
store.setName('name');
|
||||||
|
store.setAddress('0x1234567890123456789012345678901234567890');
|
||||||
|
store.setPhrase('phrase');
|
||||||
|
|
||||||
return store.createAccount().then(() => {
|
return store.createAccount().then(() => {
|
||||||
expect(busySpy).to.have.been.calledWith(true);
|
expect(busySpy).to.have.been.calledWith(true);
|
||||||
|
@ -292,7 +292,8 @@ export default class Status {
|
|||||||
]) => {
|
]) => {
|
||||||
const isTest = [
|
const isTest = [
|
||||||
'2', // morden
|
'2', // morden
|
||||||
'3', // ropsten
|
'3', // ropsten,
|
||||||
|
'17', // devchain
|
||||||
'42' // kovan
|
'42' // kovan
|
||||||
].includes(netVersion);
|
].includes(netVersion);
|
||||||
|
|
||||||
|
@ -204,22 +204,24 @@ class TxRow extends Component {
|
|||||||
|
|
||||||
if (!isCancelOpen && !isEditOpen) {
|
if (!isCancelOpen && !isEditOpen) {
|
||||||
const pendingStatus = this.getCondition();
|
const pendingStatus = this.getCondition();
|
||||||
|
const isPending = pendingStatus === 'pending';
|
||||||
|
|
||||||
if (pendingStatus === 'submitting') {
|
|
||||||
return (
|
return (
|
||||||
|
<div className={ styles.pending }>
|
||||||
|
{
|
||||||
|
isPending
|
||||||
|
? (
|
||||||
<div className={ styles.pending }>
|
<div className={ styles.pending }>
|
||||||
<div />
|
<div />
|
||||||
<div className={ styles.uppercase }>
|
<div className={ styles.uppercase }>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='ui.txList.txRow.submitting'
|
id='ui.txList.txRow.submitting'
|
||||||
defaultMessage='Submitting'
|
defaultMessage='Pending'
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
) : (
|
||||||
}
|
<div>
|
||||||
return (
|
|
||||||
<div className={ styles.pending }>
|
|
||||||
<span>
|
<span>
|
||||||
{ pendingStatus }
|
{ pendingStatus }
|
||||||
</span>
|
</span>
|
||||||
@ -229,6 +231,9 @@ class TxRow extends Component {
|
|||||||
defaultMessage='Scheduled'
|
defaultMessage='Scheduled'
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
<a onClick={ this.setEdit } className={ styles.uppercase }>
|
<a onClick={ this.setEdit } className={ styles.uppercase }>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='ui.txList.txRow.edit'
|
id='ui.txList.txRow.edit'
|
||||||
@ -242,6 +247,16 @@ class TxRow extends Component {
|
|||||||
defaultMessage='Cancel'
|
defaultMessage='Cancel'
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
{ isPending
|
||||||
|
? (
|
||||||
|
<div>
|
||||||
|
<FormattedMessage
|
||||||
|
id='ui.txList.txRow.cancelWarning'
|
||||||
|
defaultMessage='Warning: Editing or Canceling the transaction may not succeed!'
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : null
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -308,11 +323,10 @@ class TxRow extends Component {
|
|||||||
|
|
||||||
getCondition = () => {
|
getCondition = () => {
|
||||||
const { blockNumber, tx } = this.props;
|
const { blockNumber, tx } = this.props;
|
||||||
let { time, block } = tx.condition;
|
let { time, block = 0 } = tx.condition || {};
|
||||||
|
|
||||||
if (time) {
|
if (time) {
|
||||||
if ((time.getTime() - Date.now()) >= 0) {
|
if ((time.getTime() - Date.now()) >= 0) {
|
||||||
// return `${dateDifference(new Date(), time, { compact: true })} left`;
|
|
||||||
return (
|
return (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='ui.txList.txRow.pendingStatus.time'
|
id='ui.txList.txRow.pendingStatus.time'
|
||||||
@ -322,14 +336,11 @@ class TxRow extends Component {
|
|||||||
} }
|
} }
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return 'submitting';
|
|
||||||
}
|
}
|
||||||
} else if (blockNumber) {
|
}
|
||||||
|
|
||||||
|
if (blockNumber) {
|
||||||
block = blockNumber.minus(block);
|
block = blockNumber.minus(block);
|
||||||
// return (block.toNumber() < 0)
|
|
||||||
// ? block.abs().toFormat(0) + ' blocks left'
|
|
||||||
// : 'submitting';
|
|
||||||
if (block.toNumber() < 0) {
|
if (block.toNumber() < 0) {
|
||||||
return (
|
return (
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
@ -340,10 +351,10 @@ class TxRow extends Component {
|
|||||||
} }
|
} }
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
return 'submitting';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 'pending';
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelTx = () => {
|
cancelTx = () => {
|
||||||
|
@ -29,7 +29,12 @@ export default class RequestOrigin extends Component {
|
|||||||
static propTypes = {
|
static propTypes = {
|
||||||
origin: PropTypes.shape({
|
origin: PropTypes.shape({
|
||||||
type: PropTypes.oneOf(['unknown', 'dapp', 'rpc', 'ipc', 'signer']),
|
type: PropTypes.oneOf(['unknown', 'dapp', 'rpc', 'ipc', 'signer']),
|
||||||
details: PropTypes.string.isRequired
|
details: PropTypes.oneOfType([
|
||||||
|
PropTypes.string,
|
||||||
|
PropTypes.shape({
|
||||||
|
session: PropTypes.string.isRequired
|
||||||
|
})
|
||||||
|
]).isRequired
|
||||||
}).isRequired
|
}).isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -126,7 +131,9 @@ export default class RequestOrigin extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (origin.type === 'signer') {
|
if (origin.type === 'signer') {
|
||||||
return this.renderSigner(origin.details);
|
const session = origin.details && origin.details.session || origin.details;
|
||||||
|
|
||||||
|
return this.renderSigner(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user