This repository has been archived by the owner on Oct 21, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet): require wallet authentication
- Authenticate node communication using Authorization header. - Require wallet password to authenticate wallet. - Begin saving user-specified wallet and account identifiers.
- Loading branch information
Showing
22 changed files
with
871 additions
and
642 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 |
---|---|---|
@@ -1,13 +1,25 @@ | ||
import DS from 'ember-data'; | ||
import { get } from '@ember/object'; | ||
|
||
import { service } from 'ember-decorators/service'; | ||
|
||
import { attr, hasMany, belongsTo } from 'ember-decorators/data'; | ||
|
||
export default DS.Model.extend({ | ||
@service settings: null, | ||
|
||
@belongsTo() wallet: null, | ||
|
||
@hasMany({ async: true, inverse: 'source' }) blocks: null, | ||
@hasMany({ async: true, inverse: 'source' }) history: null, | ||
|
||
@attr('big-number') balance: null, | ||
@attr('big-number') pending: null, | ||
|
||
toString() { | ||
const id = this.get('id'); | ||
const wallet = this.get('wallet.id'); | ||
const settings = this.get('settings'); | ||
return get(settings, `wallets.${wallet}.accounts.${id}.label`) || id; | ||
}, | ||
}); |
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
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 |
---|---|---|
@@ -1,18 +1,13 @@ | ||
import Service from '@ember/service'; | ||
import { get, set } from '@ember/object'; | ||
import ObjectProxy from '@ember/object/proxy'; | ||
|
||
import { storageFor } from 'ember-local-storage'; | ||
|
||
export default Service.extend({ | ||
settings: storageFor('settings'), | ||
|
||
unknownProperty(keyName) { | ||
const settings = get(this, 'settings'); | ||
return get(settings, keyName); | ||
}, | ||
const Service = ObjectProxy.extend({ | ||
content: storageFor('settings'), | ||
}); | ||
|
||
setUnknownProperty(keyName, value) { | ||
const settings = get(this, 'settings'); | ||
return set(settings, keyName, value); | ||
}, | ||
Service.reopenClass({ | ||
isServiceFactory: true, | ||
}); | ||
|
||
export default Service; |
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 |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import DS from 'ember-data'; | ||
import { get } from '@ember/object'; | ||
|
||
import { service } from 'ember-decorators/service'; | ||
import { attr, hasMany } from 'ember-decorators/data'; | ||
|
||
export default DS.Model.extend({ | ||
@service settings: null, | ||
|
||
@hasMany('account', { async: true }) accounts: null, | ||
|
||
@attr('big-number') balance: null, | ||
@attr('big-number') pending: null, | ||
@attr seed: null, | ||
|
||
toString() { | ||
const id = this.get('id'); | ||
const settings = this.get('settings'); | ||
return get(settings, `wallets.${id}.label`) || id; | ||
}, | ||
}); |
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 |
---|---|---|
@@ -1,16 +1,32 @@ | ||
import Route from '@ember/routing/route'; | ||
import { get } from '@ember/object'; | ||
|
||
import { service } from 'ember-decorators/service'; | ||
import { computed } from 'ember-decorators/object'; | ||
|
||
import { storageFor } from 'ember-local-storage'; | ||
|
||
export default Route.extend({ | ||
@service intl: null, | ||
|
||
settings: storageFor('settings'), | ||
|
||
@computed('intl.locale') | ||
get breadCrumb() { | ||
return { | ||
title: this.get('intl').t('account'), | ||
path: 'wallets.accounts', | ||
}; | ||
}, | ||
|
||
async afterModel(model) { | ||
const wallet = await get(model, 'wallet.id'); | ||
const account = get(model, 'id'); | ||
const settings = this.get('settings'); | ||
const settingsKey = `wallets.${wallet}.accounts.${account}`; | ||
const accountSettings = get(settings, settingsKey); | ||
if (!accountSettings) { | ||
settings.set(settingsKey, { label: 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
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 |
---|---|---|
@@ -1,5 +1,23 @@ | ||
import Route from '@ember/routing/route'; | ||
import { get } from '@ember/object'; | ||
|
||
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin'; | ||
|
||
export default Route.extend(AuthenticatedRouteMixin); | ||
import { storageFor } from 'ember-local-storage'; | ||
|
||
export default Route.extend(AuthenticatedRouteMixin, { | ||
settings: storageFor('settings'), | ||
|
||
async afterModel(model) { | ||
const wallet = get(model, 'id'); | ||
const settings = this.get('settings'); | ||
const settingsKey = `wallets.${wallet}`; | ||
const walletSettings = get(settings, settingsKey); | ||
if (!walletSettings) { | ||
settings.set(settingsKey, { | ||
label: null, | ||
accounts: {}, | ||
}); | ||
} | ||
}, | ||
}); |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.