This repository has been archived by the owner on Oct 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
206 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Component from '@ember/component'; | ||
|
||
import ImportWalletValidations from '../../validations/import-wallet'; | ||
|
||
export default Component.extend({ | ||
ImportWalletValidations, | ||
|
||
wallet: null, | ||
seed: null, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{{#bs-form model=(changeset (hash seed=seed) ImportWalletValidations) onSubmit=(action onSubmit wallet) as |form|}} | ||
{{form.element class="form-control-lg" controlType="text" label="Seed" property="seed" autocomplete='off' minlength=64 maxlength=64 required=true pattern="^[a-fA-F0-9]{64}$"}} | ||
{{/bs-form}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Route from '@ember/routing/route'; | ||
import { get } from '@ember/object'; | ||
|
||
import { service } from 'ember-decorators/service'; | ||
import { action } from 'ember-decorators/object'; | ||
|
||
export default Route.extend({ | ||
@service rpc: null, | ||
|
||
model() { | ||
return this.store.createRecord('wallet'); | ||
}, | ||
|
||
@action | ||
saveWallet(wallet) { | ||
return wallet.save(); | ||
}, | ||
|
||
@action | ||
changeSeed(wallet, changeset) { | ||
const rpc = this.get('rpc'); | ||
const seed = get(changeset, 'seed'); | ||
const model = rpc.walletChangeSeed(get(wallet, 'id'), seed).then(() => wallet); | ||
return this.transitionTo('wallets', model); | ||
}, | ||
|
||
@action | ||
cancel() { | ||
return this.transitionTo('setup'); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{#bs-modal onHide=(route-action 'cancel') as |modal|}} | ||
{{#modal.header}} | ||
<h4 class="modal-title">Import Wallet</h4> | ||
{{/modal.header}} | ||
{{#modal.body}} | ||
{{wallet-import wallet=model onSubmit=(action (queue (route-action 'saveWallet') (route-action 'changeSeed')))}} | ||
{{/modal.body}} | ||
{{#modal.footer as |footer|}} | ||
{{#bs-button onClick=(action modal.close) type="danger"}}Cancel{{/bs-button}} | ||
{{#bs-button onClick=(action modal.submit) type="success"}}Import{{/bs-button}} | ||
{{/modal.footer}} | ||
{{/bs-modal}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
import { action } from 'ember-decorators/object'; | ||
|
||
export default Route.extend({ | ||
@action | ||
createWallet() { | ||
const wallet = this.store.createRecord('wallet'); | ||
return this.transitionTo('wallets', wallet.save()); | ||
}, | ||
|
||
@action | ||
importWallet() { | ||
return this.transitionTo('setup.import'); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{outlet}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
import { action } from 'ember-decorators/object'; | ||
|
||
export default Route.extend({ | ||
@action | ||
createWallet() { | ||
const wallet = this.store.createRecord('wallet'); | ||
return this.transitionTo('wallets', wallet.save()); | ||
}, | ||
|
||
@action | ||
importWallet() { | ||
return this.transitionTo('setup.import'); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{outlet}} | ||
|
||
<div class="jumbotron"> | ||
<h1 class="display-3">Welcome!</h1> | ||
<p class="lead">Let's get your wallet setup for use with Cairn.</p> | ||
<hr class="my-4"> | ||
<p>To begin using Cairn, you must first create a new RaiBlocks wallet or import a wallet that already exists from a seed.</p> | ||
<p class="lead"> | ||
<a class="btn btn-primary btn-lg" href="#" role="button" {{action (route-action 'createWallet')}}>Create New Wallet</a> | ||
<a class="btn btn-primary btn-lg" href="#" role="button" {{action (route-action 'importWallet')}}>Import from Seed</a> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import validateSeed from '../validators/seed'; | ||
|
||
export default { | ||
seed: validateSeed(), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { validateFormat } from 'ember-changeset-validations/validators'; | ||
|
||
export default function validateSeed() { | ||
return validateFormat({ regex: /^[a-fA-F0-9]{64}$/ }); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
tests/integration/components/wallet-import/component-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { expect } from 'chai'; | ||
import { describeComponent, it } from 'ember-mocha'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
describeComponent( | ||
'wallet-import', 'Integration | Component | wallet import', | ||
{ | ||
integration: true, | ||
}, | ||
() => { | ||
it('renders', function () { | ||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... }); | ||
// Template block usage: | ||
// this.render(hbs` | ||
// {{#wallet-import}} | ||
// template content | ||
// {{/wallet-import}} | ||
// `); | ||
|
||
this.render(hbs`{{wallet-import}}`); | ||
expect(this.$()).to.have.length(1); | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { expect } from 'chai'; | ||
import { describeModule, it } from 'ember-mocha'; | ||
|
||
describeModule( | ||
'route:setup/import', 'Unit | Route | setup/import', | ||
{ | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
}, | ||
() => { | ||
it('exists', function () { | ||
const route = this.subject(); | ||
expect(route).to.be.ok; | ||
}); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { expect } from 'chai'; | ||
import { describeModule, it } from 'ember-mocha'; | ||
|
||
describeModule( | ||
'route:setup/index', 'Unit | Route | setup/index', | ||
{ | ||
// Specify the other units that are required for this test. | ||
// needs: ['controller:foo'] | ||
}, | ||
() => { | ||
it('exists', function () { | ||
const route = this.subject(); | ||
expect(route).to.be.ok; | ||
}); | ||
}, | ||
); |
Oops, something went wrong.