Skip to content

Commit

Permalink
Merge pull request #741 from nervosnetwork/rc/v0.16.0-alpha.0
Browse files Browse the repository at this point in the history
[ᚬmaster] Release v0.16.0 alpha.0
  • Loading branch information
ashchan authored Jul 25, 2019
2 parents b51cd54 + 4788f4a commit 7f85ccd
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 58 deletions.
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ trigger:
- rc/*
tags:
include:
- '*'
- refs/tags/v*

pr:
autoCancel: true
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.1.0-alpha.15",
"version": "0.16.0-alpha.0",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@nervosnetwork/neuron",
"productName": "Neuron",
"description": "CKB Neuron Wallet",
"version": "0.1.0-alpha.15",
"version": "0.16.0-alpha.0",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down
4 changes: 2 additions & 2 deletions packages/neuron-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nervosnetwork/neuron-ui",
"version": "0.1.0-alpha.15",
"version": "0.16.0-alpha.0",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down Expand Up @@ -39,7 +39,7 @@
"last 2 chrome versions"
],
"dependencies": {
"@nervosnetwork/ckb-sdk-core": "0.15.1",
"@nervosnetwork/ckb-sdk-core": "0.16.0",
"@uifabric/experiments": "7.4.2",
"@uifabric/styling": "7.1.1",
"canvg": "2.0.0",
Expand Down
9 changes: 6 additions & 3 deletions packages/neuron-ui/src/components/PasswordRequest/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import { useTranslation } from 'react-i18next'
import { Stack, Text, Label, Modal, TextField, PrimaryButton, DefaultButton } from 'office-ui-fabric-react'
import { StateWithDispatch, AppActions } from 'states/stateProvider/reducer'
import actionCreators from 'states/stateProvider/actionCreators'
import { priceToFee } from 'utils/formatters'

const PasswordRequest = ({
app: {
send: { txID, outputs, description },
send: { txID, outputs, description, price, cycles },
passwordRequest: { walletID = '', actionType = null, password = '' },
},
settings: { wallets = [] },
Expand All @@ -33,14 +34,16 @@ const PasswordRequest = ({
break
}
case 'send': {
dispatch(actionCreators.submitTransaction(txID, walletID, outputs, description, password))
dispatch(
actionCreators.submitTransaction(txID, walletID, outputs, description, password, priceToFee(price, cycles))
)
break
}
default: {
break
}
}
}, [dispatch, walletID, password, actionType, txID, description, outputs])
}, [dispatch, walletID, password, actionType, txID, description, outputs, cycles, price])

const onChange = useCallback(
(_e, value?: string) => {
Expand Down
9 changes: 7 additions & 2 deletions packages/neuron-ui/src/components/Send/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { StateWithDispatch } from 'states/stateProvider/reducer'
import appState from 'states/initStates/app'

import { PlaceHolders, CapacityUnit } from 'utils/const'
import { shannonToCKBFormatter } from 'utils/formatters'
import { shannonToCKBFormatter, priceToFee } from 'utils/formatters'

import { useInitialize } from './hooks'

Expand Down Expand Up @@ -160,7 +160,12 @@ const Send = ({
</Stack>
</Stack>

<TransactionFeePanel fee="10" cycles="10" price={send.price} onPriceChange={updateTransactionPrice} />
<TransactionFeePanel
fee={shannonToCKBFormatter(priceToFee(send.price, send.cycles))}
cycles={send.cycles}
price={send.price}
onPriceChange={updateTransactionPrice}
/>

<Stack horizontal verticalAlign="center" tokens={{ childrenGap: 20 }}>
<Stack.Item styles={{ root: { width: labelWidth } }}>
Expand Down
23 changes: 20 additions & 3 deletions packages/neuron-ui/src/components/TransactionFeePanel/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react'
import { Stack, Label, TextField, Dropdown, Toggle, Icon } from 'office-ui-fabric-react'
import { Stack, Label, TextField, Dropdown, Toggle, Icon, IDropdownOption } from 'office-ui-fabric-react'
import { Down } from 'grommet-icons'
import { useTranslation } from 'react-i18next'

Expand All @@ -18,6 +18,16 @@ registerIcons({
},
})

const calculateSpeed = (price: number) => {
if (price >= 160) {
return '180'
}
if (price >= 40) {
return '60'
}
return '0'
}

const TransactionFee: React.FunctionComponent<TransactionFee> = ({
cycles,
price,
Expand All @@ -34,6 +44,8 @@ const TransactionFee: React.FunctionComponent<TransactionFee> = ({
</Stack.Item>
)

const selectedSpeed = calculateSpeed(+price)

return (
<Stack tokens={{ childrenGap: 15 }}>
<Stack horizontal verticalAlign="end" horizontalAlign="space-between">
Expand All @@ -42,7 +54,7 @@ const TransactionFee: React.FunctionComponent<TransactionFee> = ({
<Label>{t('send.fee')}</Label>
</Stack.Item>
<Stack.Item grow>
<TextField value={fee} readOnly />
<TextField value={`${fee} CKB`} readOnly />
</Stack.Item>
{actionSpacer}
</Stack>
Expand Down Expand Up @@ -85,7 +97,7 @@ const TransactionFee: React.FunctionComponent<TransactionFee> = ({
<Stack.Item>
<Dropdown
dropdownWidth={140}
defaultSelectedKey="0"
selectedKey={selectedSpeed}
options={[
{ key: '0', text: 'immediately' },
{ key: '30', text: '~ 30s' },
Expand All @@ -95,6 +107,11 @@ const TransactionFee: React.FunctionComponent<TransactionFee> = ({
onRenderCaretDown={() => {
return <Icon iconName="ArrowDown" />
}}
onChange={(e: any, item?: IDropdownOption) => {
if (item) {
onPriceChange(e, item.key)
}
}}
/>
</Stack.Item>
</Stack>
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-ui/src/states/initStates/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const appState: State.App = {
},
],
price: '0',
cycles: '0',
description: '',
loading: false,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default {
walletID: string = '',
items: TransactionOutput[] = [],
description: string = '',
password: string = ''
password: string = '',
fee: string = '0'
) => {
walletsCall.sendCapacity({
id,
Expand All @@ -21,7 +22,7 @@ export default {
capacity: CKBToShannonFormatter(item.amount, item.unit),
})),
password,
fee: '0',
fee,
description,
})
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import TransactionFeePanel from 'components/TransactionFeePanel'

const states = {
default: {
cycles: '0',
price: '0',
cycles: '180',
price: '10',
fee: '0',
onPriceChange: (args: any) => action(args),
},
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-ui/src/types/App/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ declare namespace State {
txID: string
outputs: Output[]
price: string
cycles: string
description: string
loading: boolean
}
Expand Down
5 changes: 5 additions & 0 deletions packages/neuron-ui/src/utils/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,16 @@ export const uniformTimeFormatter = (time: string | number | Date) => {
return timeFormatter.format(+time).replace(/\//g, '-')
}

export const priceToFee = (price: string, cycles: string) => {
return (BigInt(price) * BigInt(cycles)).toString()
}

export default {
queryFormatter,
currencyFormatter,
CKBToShannonFormatter,
shannonToCKBFormatter,
localNumberFormatter,
uniformTimeFormatter,
priceToFee,
}
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/utils/initializeApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const intializeApp = ({
connectionStatus = false,
codeHash = '',
} = initializedState
const lng = (locale as string).startsWith('zh') ? 'zh' : 'en'
const lng = ['zh', 'zh-CN'].includes(locale) ? 'zh' : 'en'
if (lng !== i18n.language) {
i18n.changeLanguage(lng)
languageCache.save(lng)
Expand Down
10 changes: 5 additions & 5 deletions packages/neuron-wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"productName": "Neuron",
"description": "CKB Neuron Wallet",
"homepage": "https://www.nervos.org/",
"version": "0.1.0-alpha.15",
"version": "0.16.0-alpha.0",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand All @@ -30,8 +30,8 @@
]
},
"dependencies": {
"@nervosnetwork/ckb-sdk-core": "0.15.1",
"@nervosnetwork/ckb-sdk-utils": "0.15.1",
"@nervosnetwork/ckb-sdk-core": "0.16.0",
"@nervosnetwork/ckb-sdk-utils": "0.16.0",
"async": "3.0.1",
"bn.js": "4.11.8",
"chalk": "2.4.2",
Expand All @@ -47,8 +47,8 @@
"winston": "3.2.1"
},
"devDependencies": {
"@nervosnetwork/ckb-types": "0.15.1",
"@nervosnetwork/neuron-ui": "0.1.0-alpha.15",
"@nervosnetwork/ckb-types": "0.16.0",
"@nervosnetwork/neuron-ui": "0.16.0-alpha.0",
"@types/async": "3.0.0",
"@types/electron-devtools-installer": "2.2.0",
"@types/elliptic": "6.4.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-wallet/scripts/notarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports.default = async function notarizing(context) {
return await notarize({
appBundleId: 'com.nervos.neuron',
appPath: `${appOutDir}/${appName}.app`,
appleId: appldId,
appleId: appleId,
appleIdPassword: appleIdPassword,
});
};
2 changes: 1 addition & 1 deletion packages/neuron-wallet/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const openWindow = () => {
}

app.on('ready', async () => {
i18n.changeLanguage(app.getLocale())
i18n.changeLanguage(['zh', 'zh-CN'].includes(app.getLocale()) ? 'zh' : 'en')
const wallets = walletsService.getAll()
const currentWallet = walletsService.getCurrent()

Expand Down
66 changes: 33 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2291,45 +2291,45 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"

"@nervosnetwork/ckb-sdk-address@0.15.1":
version "0.15.1"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-address/-/ckb-sdk-address-0.15.1.tgz#072f3bb787f1b8754b714f5c1fdd49482da1304f"
integrity sha512-o/onwnAa1zgtmAhtUxgJvdmWzEMA+0FgQMmD74kkJnFsvQEWyfaqI5Oxr4AP53XEgaHHDcM1S53OVngT9cH3AQ==
dependencies:
"@nervosnetwork/ckb-sdk-utils" "0.15.1"
"@nervosnetwork/ckb-types" "0.15.1"

"@nervosnetwork/ckb-sdk-core@0.15.1":
version "0.15.1"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-core/-/ckb-sdk-core-0.15.1.tgz#15be68403269eee634aa596a7d49660e3050450a"
integrity sha512-X4qBe976vHHk5mjeywhvxrw3Ch8GqGUUdFFBtg1xTZ5OT2awzNcF/vgg3WH7ZqBudlfZARooY7mZgDCZotuBcA==
dependencies:
"@nervosnetwork/ckb-sdk-address" "0.15.1"
"@nervosnetwork/ckb-sdk-rpc" "0.15.1"
"@nervosnetwork/ckb-sdk-utils" "0.15.1"
"@nervosnetwork/ckb-types" "0.15.1"

"@nervosnetwork/ckb-sdk-rpc@0.15.1":
version "0.15.1"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-rpc/-/ckb-sdk-rpc-0.15.1.tgz#d017fea0784e9a452481de7d46b11930bd2b9da1"
integrity sha512-HX1hbFP2ztPMSGgCfviywrZVo7fBk/DFYhTT9b67RMJRwQk2oEInQJMxlHh6fH1ZmXpAQkEOOrACP1gsBrRXPA==
dependencies:
"@nervosnetwork/ckb-sdk-utils" "0.15.1"
"@nervosnetwork/ckb-sdk-address@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-address/-/ckb-sdk-address-0.16.0.tgz#971c5495f727e3412e0d803629ae9f5aa34fa44b"
integrity sha512-X0eClB7qujZdZtwQOfy70jkaSU/PqlGg3GUTBaR0mYJCevMcdS9F3VHugyKNp7PQdxJpo9fSsZMOuNmOImkIAg==
dependencies:
"@nervosnetwork/ckb-sdk-utils" "0.16.0"
"@nervosnetwork/ckb-types" "0.16.0"

"@nervosnetwork/ckb-sdk-core@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-core/-/ckb-sdk-core-0.16.0.tgz#f4d8ee0928da46a5d2a9ccb7177218b43b0819a0"
integrity sha512-PJy+/AdMEOqZSKpeWew6T5nlh7vTbcIVbUQ4wD0Y2cNc5fxjS9yWe3uYu/kW9fexOm19tIl5hj/Xlm9SQj0sYA==
dependencies:
"@nervosnetwork/ckb-sdk-address" "0.16.0"
"@nervosnetwork/ckb-sdk-rpc" "0.16.0"
"@nervosnetwork/ckb-sdk-utils" "0.16.0"
"@nervosnetwork/ckb-types" "0.16.0"

"@nervosnetwork/ckb-sdk-rpc@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-rpc/-/ckb-sdk-rpc-0.16.0.tgz#d09d9d185e6346b4754886ab9d6b32926d960021"
integrity sha512-CTT86CH3hDo+s8Q39y9/OLMOAQvtscuLV91FqPM1wqNcgLmfe7bk0Q2YDM9PD1E4goUAi6LNMISfb9PefJM1OA==
dependencies:
"@nervosnetwork/ckb-sdk-utils" "0.16.0"
axios "0.19.0"

"@nervosnetwork/ckb-sdk-utils@0.15.1":
version "0.15.1"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-utils/-/ckb-sdk-utils-0.15.1.tgz#3e9e9c5c8e78dc5b027d52e4c848acce0a2f7ca1"
integrity sha512-o/ueD0nCt7RhlVGSoYT2/27vy/roWUYos/5kldJyJqVyC5q2KRuHqlSXvZkEIFNIfMZPnhx4Wn6BZKPe0rEerw==
"@nervosnetwork/ckb-sdk-utils@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-sdk-utils/-/ckb-sdk-utils-0.16.0.tgz#eba3249d8d1c381ec0eeabf2a9c831935b7da5a2"
integrity sha512-/SWHOPwiJI8yMXch65bPCfH0aay1uQyN7ZLTUL3mpu5FW2a4irbfdmNjMAQd4LE0DWoIaRFPFjXePGBqPNKLSA==
dependencies:
"@nervosnetwork/ckb-types" "0.15.1"
"@nervosnetwork/ckb-types" "0.16.0"
blake2b-wasm "1.1.7"
elliptic "6.4.1"

"@nervosnetwork/ckb-types@0.15.1":
version "0.15.1"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-types/-/ckb-types-0.15.1.tgz#f79b9613cb16b7311df85a7d81334e00a622f77e"
integrity sha512-4Wf6lqLtWlvoE0auqH15ZHQkSBdb34k5RoJ2Z2fbCVx48rT3ruQvKc7cNmPjHzgToYRH4UG6gKEr2/n41J0v+Q==
"@nervosnetwork/ckb-types@0.16.0":
version "0.16.0"
resolved "https://registry.yarnpkg.com/@nervosnetwork/ckb-types/-/ckb-types-0.16.0.tgz#ed47de5da923d58e7754e6a52064331851fc16fe"
integrity sha512-vbV+RFkN8dhf6VG/hYoVeb45Tb21sFT/tFFsHW3ObK/sVc2OkKGsvSZOK2y6mzrgGPkAF3sgeVRWVsiJnMM/4g==

"@nodelib/fs.stat@^1.1.2":
version "1.1.3"
Expand Down

0 comments on commit 7f85ccd

Please sign in to comment.