Skip to content

Commit

Permalink
Merge pull request #782 from nervosnetwork/rc/v0.17.0-alpha.2
Browse files Browse the repository at this point in the history
[ᚬmaster] Rc/v0.17.0 alpha.2
  • Loading branch information
ashchan authored Jul 31, 2019
2 parents 9633bf1 + bc32a45 commit 8beef45
Show file tree
Hide file tree
Showing 28 changed files with 782 additions and 736 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# [0.17.0-alpha.2](https://github.com/nervosnetwork/neuron/compare/v0.17.0-alpha.1...v0.17.0-alpha.2) (2019-07-31)


### Bug Fixes

* check input of lock hashes ([c76590c](https://github.com/nervosnetwork/neuron/commit/c76590c))
* Connection "address" was not found in test ([c121a09](https://github.com/nervosnetwork/neuron/commit/c121a09))


### Features

* Only package AppImage for Linux ([c06b7bd](https://github.com/nervosnetwork/neuron/commit/c06b7bd))
* **neuron-ui:** set message dismission duration to 8s ([a9a09e1](https://github.com/nervosnetwork/neuron/commit/a9a09e1))
* **neuron-ui:** set page no to 1 on wallet switch ([9aa8d67](https://github.com/nervosnetwork/neuron/commit/9aa8d67))
* **neuron-wallet:** add default parameters in getAllByKeywords method ([bfd9b0d](https://github.com/nervosnetwork/neuron/commit/bfd9b0d))
* split tx service to multi files ([1dcf5e1](https://github.com/nervosnetwork/neuron/commit/1dcf5e1))
* using new tx service and delete old ([00da601](https://github.com/nervosnetwork/neuron/commit/00da601))



# [0.17.0-alpha.1](https://github.com/nervosnetwork/neuron/compare/v0.17.0-alpha.0...v0.17.0-alpha.1) (2019-07-30)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/*"
],
"version": "0.17.0-alpha.1",
"version": "0.17.0-alpha.2",
"npmClient": "yarn",
"useWorkspaces": true
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"name": "neuron",
"productName": "Neuron",
"description": "CKB Neuron Wallet",
"version": "0.17.0-alpha.1",
"version": "0.17.0-alpha.2",
"private": true,
"author": {
"name": "Nervos Core Dev",
"email": "[email protected]",
"url": "https://github.com/nervosnetwork/neuron"
},
"repository": {
"type" : "git",
"url" : "https://github.com/nervosnetwork/neuron"
"type": "git",
"url": "https://github.com/nervosnetwork/neuron"
},
"license": "MIT",
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions packages/neuron-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "neuron-ui",
"version": "0.17.0-alpha.1",
"version": "0.17.0-alpha.2",
"private": true,
"author": {
"name": "Nervos Core Dev",
"email": "[email protected]",
"url": "https://github.com/nervosnetwork/neuron"
},
"repository": {
"type" : "git",
"url" : "https://github.com/nervosnetwork/neuron"
"type": "git",
"url": "https://github.com/nervosnetwork/neuron"
},
"homepage": "./",
"main": "./build",
Expand Down
6 changes: 3 additions & 3 deletions packages/neuron-ui/src/components/History/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ const History = ({
}: React.PropsWithoutRef<StateWithDispatch & RouteComponentProps>) => {
const [t] = useTranslation()

const { keywords, onKeywordsChange, setKeywords } = useSearch(search, id, dispatch)
const { keywords, onKeywordsChange } = useSearch(search, id, dispatch)
useEffect(() => {
if (id) {
setKeywords('')
history.push(`${Routes.History}?pageNo=1&keywords=${''}`)
}
}, [id, setKeywords])
}, [id, history])
const onSearch = useCallback(() => history.push(`${Routes.History}?keywords=${keywords}`), [history, keywords])

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
&>div {
max-width: auto;
margin: 3px;
animation: autoDismiss 2.5s ease-out forwards;
animation: autoDismiss 6.8s ease-out forwards;
transform-origin: center top;
box-sizing: border-box;
box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.25);
Expand All @@ -20,8 +20,8 @@
transform: translateX(110%)
}

15%,
85% {
5%,
90% {

transform: translateX(0)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/services/subjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const SubjectConstructor = <T>(
})
return {
unsubscribe: () => {
window.ipcRenderer.removeListener(channel, handler)
window.ipcRenderer.removeAllListeners(channel)
},
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const addPopup = (text: string) => (dispatch: StateDispatch) => {
type: AppActions.PopOut,
payload: null,
})
}, 3000)
}, 8000)
}

export default {
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-ui/src/types/global/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ declare interface Window {
ipcRenderer: {
on(channel: string, listener: Function)
removeListener(channel: string, listener: Function)
removeAllListeners(channel: string)
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/neuron-wallet/electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ linux:
icon: assets/images/
target:
- AppImage
- deb
8 changes: 4 additions & 4 deletions packages/neuron-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"productName": "Neuron",
"description": "CKB Neuron Wallet",
"homepage": "https://www.nervos.org/",
"version": "0.17.0-alpha.1",
"version": "0.17.0-alpha.2",
"private": true,
"author": {
"name": "Nervos Core Dev",
"email": "[email protected]",
"url": "https://github.com/nervosnetwork/neuron"
},
"repository": {
"type" : "git",
"url" : "https://github.com/nervosnetwork/neuron"
"type": "git",
"url": "https://github.com/nervosnetwork/neuron"
},
"main": "dist/main.js",
"license": "MIT",
Expand Down Expand Up @@ -64,7 +64,7 @@
"electron-devtools-installer": "2.2.4",
"electron-notarize": "0.1.1",
"lint-staged": "9.2.0",
"neuron-ui": "0.17.0-alpha.1",
"neuron-ui": "0.17.0-alpha.2",
"rimraf": "2.6.3",
"spectron": "7.0.0"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-wallet/src/controllers/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Transaction } from '../types/cell-types'
import TransactionsService, { PaginationResult, TransactionsByLockHashesParam } from '../services/transactions'
import { TransactionsService, PaginationResult, TransactionsByLockHashesParam } from '../services/tx'

import AddressesService from '../services/addresses'
import WalletsService from '../services/wallets'
Expand Down Expand Up @@ -35,7 +35,7 @@ export default class TransactionsController {
public static async getAllByKeywords(
params: Controller.Params.TransactionsByKeywords
): Promise<Controller.Response<PaginationResult<Transaction> & Controller.Params.TransactionsByKeywords>> {
const { pageNo, pageSize, keywords = '', walletID = '' } = params
const { pageNo = 1, pageSize = 15, keywords = '', walletID = '' } = params

const addresses = (await AddressesService.allAddressesByWalletId(walletID)).map(addr => addr.address)

Expand Down
3 changes: 2 additions & 1 deletion packages/neuron-wallet/src/database/address/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { Not, In } from 'typeorm'
import AddressEntity, { AddressVersion } from './entities/address'
import { AddressType } from '../../models/keys/address'
import { getConnection } from './ormconfig'
import TransactionsService, { OutputStatus } from '../../services/transactions'
import { TransactionsService } from '../../services/tx'
import CellsService from '../../services/cells'
import LockUtils from '../../models/lock-utils'
import { TransactionStatus } from '../../types/cell-types'
import { OutputStatus } from '../../services/tx/params'

export interface Address {
walletId: string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {MigrationInterface, QueryRunner, TableColumn, getConnection} from "typeorm";
import TransactionEntity from '../entities/transaction'
import { OutputStatus } from '../../../services/transactions'
import { OutputStatus } from '../../../services/tx/params'
import { TransactionStatus } from '../../../types/cell-types'

export class AddStatusToTx1562038960990 implements MigrationInterface {
Expand Down
6 changes: 3 additions & 3 deletions packages/neuron-wallet/src/listeners/tx-status.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { remote } from 'electron'
import { interval } from 'rxjs'
import TransactionsService from '../services/transactions'
import { TransactionStatus } from '../types/cell-types'
import LockUtils from '../models/lock-utils'
import AddressesUsedSubject from '../models/subjects/addresses-used-subject'
import { FailedTransaction } from '../services/tx'

const { nodeService } = remote.require('./startup/sync-block-task/params')

Expand All @@ -21,7 +21,7 @@ const getTransactionStatus = async (hash: string) => {
}

const trackingStatus = async () => {
const pendingTransactions = await TransactionsService.pendings()
const pendingTransactions = await FailedTransaction.pendings()
if (!pendingTransactions.length) {
return
}
Expand All @@ -39,7 +39,7 @@ const trackingStatus = async () => {
if (!failedTxs.length) {
return
}
const blake160s = await TransactionsService.updateFailedTxs(failedTxs.map(tx => tx.hash))
const blake160s = await FailedTransaction.updateFailedTxs(failedTxs.map(tx => tx.hash))
const usedAddresses = blake160s.map(blake160 => LockUtils.blake160ToAddress(blake160))
AddressesUsedSubject.getSubject().next(usedAddresses)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-wallet/src/services/cells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getConnection, In } from 'typeorm'
import OutputEntity from '../database/chain/entities/output'
import { Cell, OutPoint, Input } from '../types/cell-types'
import { CapacityNotEnough } from '../exceptions'
import { OutputStatus } from './transactions'
import { OutputStatus } from './tx/params'

export const MIN_CELL_CAPACITY = '6000000000'

Expand Down
29 changes: 14 additions & 15 deletions packages/neuron-wallet/src/services/sync/check-and-save/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getConnection } from 'typeorm'
import { Subject } from 'rxjs'
import { Transaction, Cell, OutPoint } from '../../../types/cell-types'
import OutputEntity from '../../../database/chain/entities/output'
import TransactionsService from '../../transactions'
import { TransactionPersistor } from '../../tx'
import CheckOutput from './output'
import LockUtils from '../../../models/lock-utils'
import { addressesUsedSubject as addressesUsedSubjectParam } from '../renderer-params'
Expand All @@ -18,7 +18,7 @@ export default class CheckTx {

public check = async (lockHashes: string[]): Promise<string[]> => {
const outputs: Cell[] = this.filterOutputs(lockHashes)
const inputAddresses = await this.filterInputs()
const inputAddresses = await this.filterInputs(lockHashes)

const outputAddresses: string[] = outputs.map(output => {
return LockUtils.lockScriptToAddress(output.lock)
Expand All @@ -32,7 +32,7 @@ export default class CheckTx {
public checkAndSave = async (lockHashes: string[]): Promise<boolean> => {
const addresses = await this.check(lockHashes)
if (addresses.length > 0) {
await TransactionsService.saveFetchTx(this.tx)
await TransactionPersistor.saveFetchTx(this.tx)
this.addressesUsedSubject.next(addresses)
return true
}
Expand All @@ -48,24 +48,23 @@ export default class CheckTx {

/* eslint no-await-in-loop: "off" */
/* eslint no-restricted-syntax: "warn" */
public filterInputs = async (): Promise<string[]> => {
public filterInputs = async (lockHashes: string[]): Promise<string[]> => {
const inputs = this.tx.inputs!

const addresses: string[] = []
for (const input of inputs) {
const outPoint: OutPoint = input.previousOutput
const { cell } = outPoint
if (!cell) {
break
}
const output = await getConnection()
.getRepository(OutputEntity)
.findOne({
outPointTxHash: cell.txHash,
outPointIndex: cell.index,
})
if (output) {
addresses.push(LockUtils.lockScriptToAddress(output.lock))
if (cell) {
const output = await getConnection()
.getRepository(OutputEntity)
.findOne({
outPointTxHash: cell.txHash,
outPointIndex: cell.index,
})
if (output && lockHashes.includes(output.lockHash)) {
addresses.push(LockUtils.lockScriptToAddress(output.lock))
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-wallet/src/services/sync/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Block, BlockHeader } from '../../types/cell-types'
import RangeForCheck from './range-for-check'
import BlockNumber from './block-number'
import Utils from './utils'
import TransactionsService from '../transactions'
import QueueAdapter from './queue-adapter'
import { TransactionPersistor } from '../tx'

export default class Queue {
private q: any
Expand Down Expand Up @@ -106,7 +106,7 @@ export default class Queue {
const rangeFirstBlockHeader: BlockHeader = range[0]
await this.currentBlockNumber.updateCurrent(BigInt(rangeFirstBlockHeader.number))
await this.rangeForCheck.setRange([])
await TransactionsService.deleteWhenFork(rangeFirstBlockHeader.number)
await TransactionPersistor.deleteWhenFork(rangeFirstBlockHeader.number)
await this.cleanQueue()
this.startBlockNumber = await this.currentBlockNumber.getCurrent()
this.batchPush()
Expand Down
Loading

0 comments on commit 8beef45

Please sign in to comment.