Skip to content

Commit

Permalink
Merge pull request #1931 from nervosnetwork/hotfix/0.33.2
Browse files Browse the repository at this point in the history
Hotfix/0.33.2
  • Loading branch information
kellyshang authored Nov 26, 2020
2 parents 512162b + d0822d4 commit b010785
Show file tree
Hide file tree
Showing 46 changed files with 1,026 additions and 98 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# 0.33.2 (2020-11-26)

[CKB v0.35.1](https://github.com/nervosnetwork/ckb/releases/tag/v0.35.1) was released on Sept. 14th, 2020. This version of CKB node is now bundled and preconfigured in Neuron.

### Hotfix

* Upgrade Asset Account script config.

### Bug fix

* Prevent Neuron from quitting when the main window is closed on MacOS.


# 0.33.1 (2020-11-16)

[CKB v0.35.1](https://github.com/nervosnetwork/ckb/releases/tag/v0.35.1) was released on Sept. 14th, 2020. This version of CKB node is now bundled and preconfigured in Neuron.
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.33.1",
"version": "0.33.2",
"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": "neuron",
"productName": "Neuron",
"description": "CKB Neuron Wallet",
"version": "0.33.1",
"version": "0.33.2",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neuron-ui",
"version": "0.33.1",
"version": "0.33.2",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down
13 changes: 12 additions & 1 deletion packages/neuron-ui/src/components/PasswordRequest/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
sendTransaction,
deleteWallet,
backupWallet,
migrateAcp,
sendCreateSUDTAccountTransaction,
sendSUDTTransaction,
} from 'states'
Expand Down Expand Up @@ -93,6 +94,16 @@ const PasswordRequest = () => {
})
break
}
case 'migrate-acp': {
await migrateAcp({ id: walletID, password })(dispatch).then(status => {
if (isSuccessResponse({ status })) {
history.push(RoutePath.History)
} else if (status === ErrorCode.PasswordIncorrect) {
throw new PasswordIncorrectException()
}
})
break
}
case 'unlock': {
if (isSending) {
break
Expand Down Expand Up @@ -183,7 +194,7 @@ const PasswordRequest = () => {
<dialog ref={dialogRef} className={styles.dialog}>
<form onSubmit={onSubmit}>
<h2 className={styles.title}>{t(`password-request.${actionType}.title`)}</h2>
{['unlock', 'create-sudt-account', 'send-sudt'].includes(actionType ?? '') ? null : (
{['unlock', 'create-sudt-account', 'send-sudt', 'migrate-acp'].includes(actionType ?? '') ? null : (
<div className={styles.walletName}>{wallet ? wallet.name : null}</div>
)}
<TextField
Expand Down
26 changes: 25 additions & 1 deletion packages/neuron-ui/src/components/SUDTAccountList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ import {
isSuccessResponse,
} from 'utils'

import { getSUDTAccountList, generateCreateSUDTAccountTransaction, updateSUDTAccount } from 'services/remote'
import {
getSUDTAccountList,
generateCreateSUDTAccountTransaction,
updateSUDTAccount,
checkMigrateAcp,
} from 'services/remote'

import styles from './sUDTAccountList.module.scss'

Expand Down Expand Up @@ -56,6 +61,25 @@ const SUDTAccountList = () => {

const existingAccountNames = accounts.filter(acc => acc.accountName).map(acc => acc.accountName || '')

useEffect(() => {
checkMigrateAcp().then(res => {
if (isSuccessResponse(res)) {
if (res.result === false) {
history.push(RoutePath.Overview)
}
} else {
dispatch({
type: AppActions.AddNotification,
payload: {
type: 'alert',
timestamp: +new Date(),
content: typeof res.message === 'string' ? res.message : res.message.content,
},
})
}
})
}, [dispatch, history])

useEffect(() => {
const ckbBalance = BigInt(balance)
const isInsufficient = (res: { status: number }) =>
Expand Down
10 changes: 10 additions & 0 deletions packages/neuron-ui/src/containers/Main/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ export const useSubscription = ({
})
break
}
case 'migrate-acp': {
dispatch({
type: AppActions.RequestPassword,
payload: {
walletID: payload || '',
actionType: 'migrate-acp',
},
})
break
}
default: {
break
}
Expand Down
7 changes: 7 additions & 0 deletions packages/neuron-ui/src/exceptions/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@ export class AddressEmptyException extends Error {
super(`${I18N_PATH}${ErrorCode.AddressIsEmpty}`)
}
}

export class AddressDeprecatedException extends Error {
public code = ErrorCode.AddressIsDeprecated
constructor() {
super(`${I18N_PATH}${ErrorCode.AddressIsDeprecated}`)
}
}
6 changes: 5 additions & 1 deletion packages/neuron-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@
},
"send-sudt": {
"title": "Send sUDT"
},
"migrate-acp": {
"title": "Upgrade Asset Accounts"
}
},
"qrcode": {
Expand Down Expand Up @@ -407,7 +410,8 @@
"305": "$t(messages.fields.address) cannot be empty.",
"306": "Please enter a mainnet address",
"307": "Please enter a testnet address",
"308": "Amount is not enough"
"308": "Amount is not enough",
"309": "The receiver needs to upgrade her account address to accept more transfer."
}
},
"sync": {
Expand Down
6 changes: 5 additions & 1 deletion packages/neuron-ui/src/locales/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@
},
"send-sudt": {
"title": "發起 sUDT 交易"
},
"migrate-acp": {
"title": "升级资产账户"
}
},
"qrcode": {
Expand Down Expand Up @@ -407,7 +410,8 @@
"305": "$t(messages.fields.address)不能為空。",
"306": "請輸入主網地址",
"307": "請輸入測試網地址",
"308": "餘額不足"
"308": "餘額不足",
"309": "收款人需要升級資產賬戶才能繼續接收轉賬。"
}
},
"sync": {
Expand Down
6 changes: 5 additions & 1 deletion packages/neuron-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@
},
"send-sudt": {
"title": "发起 sUDT 交易"
},
"migrate-acp": {
"title": "升级资产账户"
}
},
"qrcode": {
Expand Down Expand Up @@ -407,7 +410,8 @@
"305": "$t(messages.fields.address)不能为空。",
"306": "请输入主网地址",
"307": "请输入测试网地址",
"308": "余额不足"
"308": "余额不足",
"309": "收款人需要升级资产账户才能继续接收转账。"
}
},
"sync": {
Expand Down
8 changes: 5 additions & 3 deletions packages/neuron-ui/src/services/remote/remoteApiWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ type Action =
| 'generate-send-all-to-anyone-can-pay-tx'
| 'send-to-anyone-can-pay'
| 'get-token-info-list'
| 'migrate-acp'
| 'check-migrate-acp'

export const remoteApi = <P = any, R = any>(action: Action) => async (params: P): Promise<ControllerResponse<R>> => {
const res: SuccessFromController<R> | FailureFromController = await ipcRenderer.invoke(action, params).catch(() => ({
Expand All @@ -126,13 +128,13 @@ export const remoteApi = <P = any, R = any>(action: Action) => async (params: P)
if (isSuccessResponse(res)) {
return {
status: ResponseCode.SUCCESS,
result: res.result || null,
result: res.result ?? null,
}
}

return {
status: res.status || ResponseCode.FAILURE,
message: typeof res.message === 'string' ? { content: res.message } : res.message || '',
status: res.status ?? ResponseCode.FAILURE,
message: typeof res.message === 'string' ? { content: res.message } : res.message ?? '',
}
}

Expand Down
6 changes: 6 additions & 0 deletions packages/neuron-ui/src/services/remote/sudt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ export const generateSendAllSUDTTransaction = remoteApi<Controller.GenerateSendA
)

export const sendSUDTTransaction = remoteApi<Controller.SendSUDTTransaction.Params>('send-to-anyone-can-pay')

export const checkMigrateAcp = remoteApi<Controller.CheckMigrateAcp.Params, Controller.CheckMigrateAcp.Response>(
'check-migrate-acp'
)

export const migrateAcp = remoteApi<Controller.MigrateAcp.Params>('migrate-acp')
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ErrorCode, isSuccessResponse, ResponseCode } from 'utils'
import { ErrorCode, isSuccessResponse, ResponseCode, failureResToNotification } from 'utils'
import {
sendCreateSUDTAccountTransaction as sendCreateAccountTx,
sendSUDTTransaction as sendSUDTTx,
migrateAcp as migrateAcpIpc,
} from 'services/remote'
import { AppActions, StateDispatch } from '../reducer'
import { addNotification } from './app'
Expand Down Expand Up @@ -71,3 +72,30 @@ export const sendSUDTTransaction = (params: Controller.SendSUDTTransaction.Param
})
}
}

export const migrateAcp = (params: Controller.MigrateAcp.Params) => async (dispatch: StateDispatch) => {
dispatch({
type: AppActions.UpdateLoadings,
payload: { sending: true },
})
try {
const res = await migrateAcpIpc(params)
if (res.status !== ErrorCode.PasswordIncorrect) {
dispatch({
type: AppActions.DismissPasswordRequest,
})
if (!isSuccessResponse(res)) {
addNotification(failureResToNotification(res))(dispatch)
}
}
return res.status
} catch (err) {
console.warn(err)
return 0
} finally {
dispatch({
type: AppActions.UpdateLoadings,
payload: { sending: false },
})
}
}
33 changes: 33 additions & 0 deletions packages/neuron-ui/src/tests/scriptToAddress/fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@
],
"expected": "ckb1qyq5lv479ewscx3ms620sv34pgeuz6zagaaqklhtgg"
},
"anyone can pay address on lina": {
"params": [
{
"codeHash": "0xd369597ff47f29fbc0d47d2e3775370d1250b85140c670e4718af712983a2354",
"hashType": "type",
"args": "0x4fb2be2e5d0c1a3b8694f832350a33c1685d477a"
},
true
],
"expected": "ckb1qypylv479ewscx3ms620sv34pgeuz6zagaaqvrugu7"
},
"anyone can pay address on aggron": {
"params": [
{
"codeHash": "0x3419a1c09eb2567f6552ee7a8ecffd64155cffe0f1796e6e61ec088d740c1356",
"hashType": "type",
"args": "0x4fb2be2e5d0c1a3b8694f832350a33c1685d477a"
},
false
],
"expected": "ckt1qypylv479ewscx3ms620sv34pgeuz6zagaaq3xzhsz"
},
"full version address of hashType = 'data'": {
"params": [
{
Expand All @@ -42,5 +64,16 @@
false
],
"expected": "ckt1qsvf96jqmq4483ncl7yrzfzshwchu9jd0glq4yy5r2jcsw04d7xlydkr98kkxrtvuag8z2j8w4pkw2k6k4l5c02auef"
},
"full version address when args length is not matched": {
"params": [
{
"args": "0x7346c078cd8684ba9fc7bcaba49442a13b46617c4504009400f00020",
"codeHash": "0x5c5069eb0857efc65e1bca0c07df34c31663b3622fd3876c876320fc9634e2a8",
"hashType": "type"
},
false
],
"expected": "ckt1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn32su6xcpuvmp5yh20u009t5j2y9gfmgeshc3gyqz2qpuqqyqjlmnq6"
}
}
Loading

0 comments on commit b010785

Please sign in to comment.