Skip to content
Permalink
Browse files

fix account history

Fix account history viewer showing users own account instead of showing outgoing/incoming accounts. Removed mnemonic phrase option.
  • Loading branch information...
Millsii3 committed Apr 19, 2018
1 parent 3bc699c commit 588b700b8a1fdee4af5f73d339dddeea989b6605
0 karma.conf.js 100644 → 100755
No changes.

Large diffs are not rendered by default.

130 package.json 100644 → 100755
@@ -1,22 +1,120 @@
{
"name": "rai-cloud",
"version": "1.0.0",
"description": "",
"main": "index.js",
"name": "NanoVault",
"version": "1.0.3",
"license": "MIT",
"description": "Wallet for interacting with Nano",
"author": "Andrew Steele",
"main": "main.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"desktop": "electron main.js",
"pack": "electron-builder --dir",
"dist": "electron-builder",
"dist-full": "electron-builder -wml --x64",
"publish": "build -wml --x64 -p always",
"wallet:dev": "ng serve --open",
"wallet:build": "ng build --prod",
"wallet:build-desktop": "ng build --env=desktop --prod --base-href ",
"desktop:dev": "electron main.js",
"desktop:local": "electron-builder",
"desktop:full": "electron-builder -wml --x64",
"desktop:publish": "build -wml --x64 -p always"
},
"author": "",
"license": "ISC",
"private": true,
"dependencies": {
"body-parser": "^1.18.2",
"cors": "^2.8.4",
"express": "^4.16.2",
"knex": "^0.14.2",
"pg": "^7.4.1",
"redis": "^2.8.0",
"request": "^2.83.0",
"request-promise-native": "^1.0.5"
"@angular-devkit/core": "0.0.28",
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"@types/crypto-js": "^3.1.38",
"bignumber.js": "^5.0.0",
"bip39": "^2.5.0",
"blakejs": "^1.1.0",
"core-js": "^2.4.1",
"crypto": "^1.0.1",
"crypto-js": "^3.1.9-1",
"electron-updater": "^2.21.0",
"ngx-clipboard": "^9.1.2",
"qrcode": "^1.2.0",
"rxjs": "^5.5.2",
"tweetnacl": "^1.0.0",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.6.0",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/bip39": "^2.4.0",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"@types/qrcode": "^0.8.1",
"codelyzer": "^4.0.1",
"electron": "^1.8.2",
"electron-builder": "^19.52.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2",
"uikit": "^3.0.0-beta.40"
},
"build": {
"appId": "com.electron.nanovault",
"buildVersion": "1.0.3",
"productName": "NanoVault",
"copyright": "Copyright © 2018 Andrew Steele",
"directories": {
"output": "dist-desktop",
"app": "./"
},
"mac": {
"category": "public.app-category.finance",
"extendInfo": {
"CFBundleURLTypes": [
{
"CFBundleURLName": "xrb",
"CFBundleURLSchemes": [
"xrb"
]
}
]
}
},
"linux": {
"target": "AppImage"
},
"publish": [
{
"provider": "github",
"owner": "cronoh",
"repo": "nanovault"
}
],
"protocols": {
"name": "xrb",
"schemes": [
"xrb"
],
"role": "Viewer"
}
}
}
0 protractor.conf.js 100644 → 100755
No changes.
0 renderer.js 100644 → 100755
No changes.
@@ -164,20 +164,20 @@ <h3 class="uk-heading-divider uk-text-center" style="margin-bottom: 0;">Recent T
<td class="uk-visible-toggle">
<div uk-grid>
<div class="uk-width-expand uk-text-truncate">
<a [routerLink]="'/account/' + history.account" class="uk-link-text" title="View Account Details" uk-tooltip>
<span *ngIf="history.addressBookName" class="uk-margin-small-right uk-label uk-label-default">{{ history.addressBookName }}</span> {{ history.account }}
</a>
<a [routerLink]="'/account/' + (history.link_as_account || history.account)" class="uk-link-text" title="View Account Details" uk-tooltip>
<span *ngIf="history.addressBookName" class="uk-margin-small-right uk-label uk-label-default">{{ history.addressBookName }}</span> {{ history.link_as_account || history.account }}
</a>
</div>
<div class="uk-width-auto" style="padding-left: 10px;">
<ul class="uk-hidden-hover uk-iconnav">
<li><a ngxClipboard [cbContent]="history.account" (cbOnSuccess)="copied()" uk-icon="icon: copy" title="Copy Account Address" uk-tooltip></a></li>
<li><a ngxClipboard [cbContent]="history.link_as_account || history.account" (cbOnSuccess)="copied()" uk-icon="icon: copy" title="Copy Account Address" uk-tooltip></a></li>
</ul>
</div>
</div>
</td>
<td [ngClass]="{ 'uk-text-success': history.type == 'receive', 'uk-text-danger': history.type == 'send' }">
{{ history.type == 'send' ? '-' : '+' }}{{ history.amount | rai: settings.settings.displayDenomination }}
</td>
<td [ngClass]="{ 'uk-text-success': history.type == 'receive' || history.subtype == 'receive', 'uk-text-danger': history.type == 'send' || history.subtype == 'send' }">
{{ (history.type == 'send' || history.subtype == 'send') ? '-' : '+' }}{{ history.amount | rai: settings.settings.displayDenomination }}
</td>
<td class="uk-text-truncate"><a [routerLink]="'/transaction/' + history.hash" class="uk-link-text" title="View Block Details" uk-tooltip>{{ history.hash }}</a></td>
</tr>
<tr *ngIf="!accountHistory.length && !pendingBlocks.length">
@@ -121,12 +121,44 @@ export class AccountDetailsComponent implements OnInit, OnDestroy {
if (resetPage) {
this.pageSize = 25;
}
const history = await this.api.accountHistory(account, this.pageSize);
const history = await this.api.accountHistory(account, this.pageSize, true);
let additionalBlocksInfo = [];
if (history && history.history && Array.isArray(history.history)) {
this.accountHistory = history.history.map(h => {
h.addressBookName = this.addressBook.getAccountName(h.account) || null;
if (h.type === 'state') {
// For Open and receive blocks, we need to look up block info to get originating account
if (h.subtype === 'open' || h.subtype === 'receive') {
additionalBlocksInfo.push({ hash: h.hash, link: h.link });
} else {
h.link_as_account = this.util.account.getPublicAccountID(this.util.hex.toUint8(h.link));
h.addressBookName = this.addressBook.getAccountName(h.link_as_account) || null;
}
} else {
h.addressBookName = this.addressBook.getAccountName(h.account) || null;
}
return h;
});

// Remove change blocks now that we are using the raw output
this.accountHistory = this.accountHistory.filter(h => h.type !== 'change');

if (additionalBlocksInfo.length) {
const blocksInfo = await this.api.blocksInfo(additionalBlocksInfo.map(b => b.link));
for (let block in blocksInfo.blocks) {
if (!blocksInfo.blocks.hasOwnProperty(block)) continue;

const matchingBlock = additionalBlocksInfo.find(a => a.link === block);
if (!matchingBlock) continue;
const accountInHistory = this.accountHistory.find(h => h.hash === matchingBlock.hash);
if (!accountInHistory) continue;

const blockData = blocksInfo.blocks[block];

accountInHistory.link_as_account = blockData.block_account;
accountInHistory.addressBookName = this.addressBook.getAccountName(blockData.block_account) || null;
}
}

} else {
this.accountHistory = [];
}
@@ -123,6 +123,22 @@ <h3 class="uk-card-title">Wallet Settings</h3>
</div>
</div>
</div>
<div class="uk-width-1-1">
<div class="uk-form-horizontal">

<div class="uk-margin">
<label class="uk-form-label">Block Type <span uk-icon="icon: info;" uk-tooltip title="Select which type of blocks to generate (Recommended to use Legacy blocks until forced upgrade)"></span></label>
<div class="uk-form-controls">

<div class="uk-inline uk-width-1-1">
<select class="uk-select" [(ngModel)]="selectedBlockOption">
<option *ngFor="let option of blockOptions" [value]="option.value">{{ option.name }}</option>
</select>
</div>
</div>
</div>
</div>
</div>

</div>
</div>
@@ -90,6 +90,12 @@ export class ConfigureAppComponent implements OnInit {
];
selectedPoWOption = this.powOptions[0].value;

blockOptions = [
{ name: 'Legacy Blocks', value: false },
{ name: 'State Blocks', value: true },
];
selectedBlockOption = this.blockOptions[0].value;

constructor(
private walletService: WalletService,
private notifications: NotificationService,
@@ -123,6 +129,8 @@ export class ConfigureAppComponent implements OnInit {

const matchingPowOption = this.powOptions.find(d => d.value === settings.powSource);
this.selectedPoWOption = matchingPowOption ? matchingPowOption.value : this.powOptions[0].value;

this.selectedBlockOption = settings.useStateBlocks;
}

async updateDisplaySettings() {
@@ -162,6 +170,7 @@ export class ConfigureAppComponent implements OnInit {
lockOnClose: new Number(this.selectedLockOption),
lockInactivityMinutes: new Number(this.selectedInactivityMinutes),
powSource: newPoW,
useStateBlocks: this.selectedBlockOption,
};

this.appSettings.setAppSettings(newSettings);
@@ -71,21 +71,12 @@ <h2>Configure Wallet</h2>
<input type="text" class="uk-input" (keyup.enter)="importExistingWallet()" [(ngModel)]="importSeedModel" placeholder="Your Banano Backup Seed">
</div>
</div>
<div uk-grid *ngIf="selectedImportOption === 'mnemonic'" class="uk-margin-top">
<div class="uk-width-1-1">
<p>
Enter your wallet mnemonic phrase generated from any Banano wallet to import it below.
</p>
<textarea class="uk-textarea" rows="3" (keyup.enter)="importExistingWallet()" [(ngModel)]="importSeedMnemonicModel" placeholder="Your Banano Backup Mnemonic Phrase"></textarea>
</div>
</div>
</div>
<div class="uk-card-footer uk-text-right">
<div *ngIf="selectedImportOption === 'file'" class="js-upload" uk-form-custom style="display: inline-block;">
<input type="file" id="import-from-file" (change)="importFromFile($event.target.files)" multiple>
<button class="uk-button uk-button-primary" type="button" tabindex="-1">Import From File</button>
</div>
<button *ngIf="selectedImportOption === 'mnemonic'" class="uk-button uk-button-primary" (click)="importExistingWallet()">Import From Mnemonic Phrase</button>
<button *ngIf="selectedImportOption === 'seed'" class="uk-button uk-button-primary" (click)="importExistingWallet()">Import From Seed</button>
</div>
</div>
@@ -98,19 +89,12 @@ <h3 class="uk-card-title">Wallet Created!</h3>
</div>
<div class="uk-card-body">
<p>
Your new Banano wallet has been created! Below is the mnemonic phrase and seed for your wallet, you can use whichever you prefer.
Your new Banano wallet has been created! Below is the seed for your wallet.
</p>
<div class="uk-alert uk-alert-primary">
Make sure to write down your mnemonic phrase/seed or save it somewhere safe, and <strong>never share it with anyone!</strong><br>
Make sure to write down your seed or save it somewhere safe, and <strong>never share it with anyone!</strong><br>
It is the master key to all of your accounts, and the only way to recover your funds in an emergency.
</div>
<div uk-grid>
<div class="uk-width-1-4">Wallet Mnemonic Phrase</div>
<div class="uk-width-3-4">
{{ newWalletMnemonic }}<br>
<a title="Copy Mnemonic To Clipboard" ngxClipboard [cbContent]="newWalletMnemonic" (cbOnSuccess)="copied()" uk-tooltip>Copy mnemonic to clipboard</a>
</div>
</div>
<div uk-grid>
<div class="uk-width-1-4">Wallet Seed</div>
<div class="uk-width-3-4 uk-text-truncate">
@@ -120,7 +104,7 @@ <h3 class="uk-card-title">Wallet Created!</h3>
</div>
</div>
<div class="uk-card-footer">
<button class="uk-button uk-button-danger" (click)="confirmNewSeed()">I've Saved My Seed/Mnemonic</button>
<button class="uk-button uk-button-danger" (click)="confirmNewSeed()">I've Saved My Seed</button>
</div>
</div>

@@ -5,7 +5,7 @@ import {AppSettingsService} from "../services/app-settings.service";
name: 'rai'
})
export class RaiPipe implements PipeTransform {
precision = 6;
precision = 2;

ban = 100000000000000000000000000000;
banoshi = 1000000000000000000000000000;
@@ -18,14 +18,14 @@ export class RaiPipe implements PipeTransform {

switch (denomination.toLowerCase()) {
default:
case 'ban': return `${(value / this.ban).toFixed(6)}${!hideText ? ' BANANO': ''}`;
case 'ban': return `${(value / this.ban).toFixed(2)}${!hideText ? ' BANANO': ''}`;
case 'ban':
const hasRawValue = (value / this.rai) % 1;
if (hasRawValue) {
const newVal = value / this.ban < 0.000001 ? 0 : value / this.ban; // New more precise toFixed function, but bugs on huge raw numbers
return `${this.toFixed(newVal, this.precision)}${!hideText ? ' BANANO': ''}`;
} else {
return `${(value / this.ban).toFixed(6)}${!hideText ? ' BANANO': ''}`;
return `${(value / this.ban).toFixed(2)}${!hideText ? ' BANANO': ''}`;
}
case 'banoshi': return `${(value / this.banoshi).toFixed(3)}${!hideText ? ' banoshi': ''}`;
case 'nano': return `${(value / this.rai).toFixed(0)}${!hideText ? ' nano': ''}`;
@@ -72,6 +72,7 @@ export class AddressBookService {
}

getAccountName(account: string): string|null {
if (!account || !account.length) return null;
const match = this.addressBook.find(a => a.account.toLowerCase() === account.toLowerCase());
return match && match.name || null;
}
@@ -90,8 +90,8 @@ export class ApiService {
async accountCreate(wallet): Promise<{account?: string, error?: string}> {
return await this.request('account_create', { wallet });
}
async accountHistory(account, count = 25): Promise<{history: any }> {
return await this.request('account_history', { account, count });
async accountHistory(account, count = 25, raw = false): Promise<{history: any }> {
return await this.request('account_history', { account, count, raw });
}
async accountList(wallet): Promise<{accounts: any }> {
return await this.request('account_list', { wallet });
@@ -11,6 +11,7 @@ interface AppSettings {
lockOnClose: number;
lockInactivityMinutes: number;
powSource: PoWSource;
useStateBlocks: boolean;
}

@Injectable()
@@ -24,6 +25,7 @@ export class AppSettingsService {
lockOnClose: 1,
lockInactivityMinutes: 30,
powSource: 'best',
useStateBlocks: true,
};

constructor() { }
@@ -70,6 +72,7 @@ export class AppSettingsService {
lockOnClose: 1,
lockInactivityMinutes: 30,
powSource: 'best',
useStateBlocks: true,
};
}

0 comments on commit 588b700

Please sign in to comment.
You can’t perform that action at this time.