Skip to content

Commit

Permalink
Merge pull request #2141 from nervosnetwork/rc/0.100.2
Browse files Browse the repository at this point in the history
Rc/0.100.2
  • Loading branch information
kellyshang authored Oct 15, 2021
2 parents 09d0f99 + 32ef111 commit beca33b
Show file tree
Hide file tree
Showing 25 changed files with 265 additions and 24 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# 0.100.2 (2021-10-15)

[CKB v0.100.0](https://github.com/nervosnetwork/ckb/releases/tag/v0.100.0) was released on Sep. 22nd, 2021. This version of CKB node is now bundled and preconfigured in Neuron.

**This version is compatible with v0.100.0 and above.**

### New feature
* Add feature of destroy CKB Asset Account.

### Bug fixes
* Kill ckb/indexer before Neuron quit.
* Fix a cosmetic bug of address truncation in addresses book under higher resolution.
* Remove useless token id prompt when asset account type is `CKB Account`.


# 0.100.1 (2021-09-29)

[CKB v0.100.0](https://github.com/nervosnetwork/ckb/releases/tag/v0.100.0) was released on Sep. 22nd, 2021. This version of CKB node is now bundled and preconfigured in Neuron.
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ stages:
name: winSiginingCertificate
displayName: "Download Windows Signing Certificate"
inputs:
secureFile: Neuron_win.p12
secureFile: neuron_win_2021.pfx
- pwsh: |
bash ./scripts/download-ckb.sh win
yarn build
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.100.1",
"version": "0.100.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.100.1",
"version": "0.100.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.100.1",
"version": "0.100.2",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,12 @@ $change-color: #6666cc;
display: none;
}

@media screen and (max-width: 1365px) {
@media screen and (max-width: 1680px) {
width: 20vw;

.ellipsis {
display: inline;
}
}

@media screen and (max-width: 1680px) {
width: 20vw;

&::after {
position: absolute;
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-ui/src/components/HardwareSign/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ const HardwareSign = ({
switch (type) {
case 'send':
case 'send-nft':
case 'destroy-ckb-account':
case 'claim-cheque': {
if (isSending) {
break
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ const PasswordRequest = () => {
await sendSUDTTransaction(params)(dispatch).then(handleSendTxRes)
break
}
case 'destroy-ckb-account':
case 'send-nft':
case 'send-cheque': {
if (isSending) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const SUDTCreateDialog = ({
error={tokenErrors[field.key]}
className={accountType === AccountType.CKB ? styles.ckbField : undefined}
hint={
!tokenErrors[field.key] && field.key === 'tokenId'
!tokenErrors[field.key] && field.key === 'tokenId' && accountType === AccountType.SUDT
? t(`s-udt.create-dialog.placeholder.${field.label}`)
: undefined
}
Expand Down
42 changes: 41 additions & 1 deletion packages/neuron-ui/src/components/SUDTSend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
generateSendAllSUDTTransaction,
getAnyoneCanPayScript,
generateChequeTransaction,
destoryCKBAssetAccount,
} from 'services/remote'
import { ckbCore } from 'services/chain'
import { useState as useGlobalState, useDispatch, AppActions } from 'states'
Expand Down Expand Up @@ -330,6 +331,37 @@ const SUDTSend = () => {
[isSubmittable, globalDispatch, walletId, accountType, isSecp256k1ShortAddress]
)

const [isDestroying, setIsDestroying] = useState(false)
const onDestroy = useCallback(() => {
setIsDestroying(true)
destoryCKBAssetAccount({ walletID: walletId, id: accountId })
.then(res => {
if (isSuccessResponse(res)) {
const tx = res.result
globalDispatch({ type: AppActions.UpdateExperimentalParams, payload: { tx } })
globalDispatch({
type: AppActions.RequestPassword,
payload: {
walletID: walletId,
actionType: 'destroy-ckb-account',
},
})
} else {
globalDispatch({
type: AppActions.AddNotification,
payload: {
type: 'alert',
timestamp: +new Date(),
content: typeof res.message === 'string' ? res.message : res.message.content!,
},
})
}
})
.finally(() => {
setIsDestroying(false)
})
}, [globalDispatch, walletId, accountId])

if (!isLoaded) {
return (
<div className={styles.loading}>
Expand Down Expand Up @@ -412,7 +444,15 @@ const SUDTSend = () => {
</div>
</div>
</div>
<div className={styles.footer}>
<div className={accountType === AccountType.CKB ? styles['ckb-footer'] : styles.footer}>
{accountType === AccountType.CKB ? (
<div className={styles.tooltip}>
<Button type="cancel" label="" onClick={onDestroy} disabled={isDestroying}>
{t('s-udt.send.destroy') as string}
</Button>
<span className={styles.tooltiptext}>{t('s-udt.send.destroy-desc')}</span>
</div>
) : null}
<Button type="submit" label={t('s-udt.send.submit')} onClick={onSubmit} disabled={!isSubmittable} />
</div>
</form>
Expand Down
48 changes: 48 additions & 0 deletions packages/neuron-ui/src/components/SUDTSend/sUDTSend.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,54 @@
justify-content: flex-end;
}

.ckb-footer {
display: flex;
justify-content: space-between;
}

.tooltip {
position: relative;
display: inline-block;
&:hover {
.tooltiptext {
visibility: visible;
opacity: 1;
}
}
}

.tooltiptext {
visibility: hidden;
position: absolute;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
z-index: 1;
opacity: 0;
transition: opacity .6s;
word-break: keep-all;
padding: 5px 10px;
left: 110%;
font-size: 12px;
margin-top: 2px;
white-space: nowrap;
&:hover {
visibility: visible;
opacity: 1;
}
&:after {
content: "";
position: absolute;
top: 50%;
right: 100%;
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent #555 transparent transparent;
}
}

.modal {
@include overlay;
position: absolute;
Expand Down
7 changes: 6 additions & 1 deletion packages/neuron-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@
},
"create-account-to-claim-cheque": {
"title": "Claim Cheque Asset with New Account"
},
"destroy-ckb-account": {
"title": "Destroy CKB Asset Account"
}
},
"qrcode": {
Expand Down Expand Up @@ -718,7 +721,9 @@
"description": "Description",
"submit": "Submit",
"click-to-edit": "Click to edit",
"cheque-address-hint": "162 CKBytes capacity is going to be temporarily locked to initialize the token transfer, and it will be automatically unlocked after the token being claimed by the receiver."
"cheque-address-hint": "162 CKBytes capacity is going to be temporarily locked to initialize the token transfer, and it will be automatically unlocked after the token being claimed by the receiver.",
"destroy": "Destroy",
"destroy-desc": "Will returns all CKB of this CKB Asset account to your change address."
},
"receive": {
"notation": "Accept {{symbol}} only"
Expand Down
7 changes: 6 additions & 1 deletion packages/neuron-ui/src/locales/zh-tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@
},
"create-account-to-claim-cheque": {
"title": "創建賬戶並領取 Cheque 資產"
},
"destroy-ckb-account": {
"title": "銷毀 CKB 資產賬戶"
}
},
"qrcode": {
Expand Down Expand Up @@ -711,7 +714,9 @@
"description": "備註",
"submit": "提交",
"click-to-edit": "點擊編輯",
"cheque-address-hint": "向該地址轉賬需要臨時鎖定 162 CKB,對方領取後自動解鎖。"
"cheque-address-hint": "向該地址轉賬需要臨時鎖定 162 CKB,對方領取後自動解鎖。",
"destroy": "銷毀",
"destroy-desc": "將會返還所有該 CKB 資產賬戶的 CKB 到你的找零地址中"
},
"receive": {
"notation": "只接收 {{symbol}} 轉賬"
Expand Down
7 changes: 6 additions & 1 deletion packages/neuron-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,9 @@
},
"create-account-to-claim-cheque": {
"title": "创建账户并领取 Cheque 资产"
},
"destroy-ckb-account": {
"title": "销毁 CKB 资产账户"
}
},
"qrcode": {
Expand Down Expand Up @@ -711,7 +714,9 @@
"description": "备注",
"submit": "提交",
"click-to-edit": "点击编辑",
"cheque-address-hint": "向该地址转账需要临时锁定 162 CKB,对方领取后自动解锁。"
"cheque-address-hint": "向该地址转账需要临时锁定 162 CKB,对方领取后自动解锁。",
"destroy": "销毁",
"destroy-desc": "将会返还所有该 CKB 资产账户的 CKB 到你的找零地址中"
},
"receive": {
"notation": "只接收 {{symbol}} 转账"
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-ui/src/services/remote/remoteApiWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ type Action =
| 'migrate-acp'
| 'check-migrate-acp'
| 'get-sudt-token-info'
| 'generate-destroy-ckb-account-tx'
// Cheque
| 'generate-create-cheque-tx'
| 'generate-withdraw-cheque-tx'
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-ui/src/services/remote/specialAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ import { remoteApi } from './remoteApiWrapper'

export const getSpecialAssets = remoteApi<Controller.GetSpeicalAssetsParams>('get-customized-asset-cells')
export const unlockSpecialAsset = remoteApi<Controller.UnlockSpecialAssetParams>('generate-withdraw-customized-cell-tx')
export const destoryCKBAssetAccount = remoteApi<Controller.GetSUDTAccount.Params>('generate-destroy-ckb-account-tx')
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 @@ -86,6 +86,7 @@ declare namespace State {
| 'withdraw-cheque'
| 'claim-cheque'
| 'create-account-to-claim-cheque'
| 'destroy-ckb-account'
| 'migrate-acp'
| 'send-nft'
| null
Expand Down
4 changes: 2 additions & 2 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.100.1",
"version": "0.100.2",
"private": true,
"author": {
"name": "Nervos Core Dev",
Expand Down Expand Up @@ -86,7 +86,7 @@
"electron-notarize": "0.2.1",
"jest-when": "2.7.2",
"lint-staged": "9.2.5",
"neuron-ui": "0.100.1",
"neuron-ui": "0.100.2",
"rimraf": "3.0.0",
"ttypescript": "1.5.10"
}
Expand Down
4 changes: 4 additions & 0 deletions packages/neuron-wallet/src/controllers/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ export default class ApiController {
return this.sudtController.getSUDTTokenInfo(params)
})

handle('generate-destroy-ckb-account-tx', async (_, params: { walletID: string, id: number })=>{
return this.assetAccountController.destoryCKBAssetAccount(params)
})

// Hardware wallet
handle('connect-device', async (_, deviceInfo: DeviceInfo) => {
await this.hardwareController.connectDevice(deviceInfo)
Expand Down
6 changes: 4 additions & 2 deletions packages/neuron-wallet/src/controllers/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ export default class AppController {

public end = async () => {
if (!env.isTestMode) {
await new NodeController().stopNode()
await IndexerService.getInstance().stop()
await Promise.all([
new NodeController().stopNode(),
IndexerService.getInstance().stop(),
])
}
}

Expand Down
17 changes: 17 additions & 0 deletions packages/neuron-wallet/src/controllers/asset-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,23 @@ export default class AssetAccountController {
}
}

public async destoryCKBAssetAccount(
params: { walletID: string, id: number }
): Promise<Controller.Response<Transaction>> {
const account = await AssetAccountService.getAccount(params)

if (!account) {
throw new ServiceHasNoResponse('AssetAccount')
}

const { tx } = await AssetAccountService.destoryCKBAssetAccount(params.walletID, account)

return {
status: ResponseCode.Success,
result: tx,
}
}

public async getAccount(params: { walletID: string, id: number }): Promise<Controller.Response<AssetAccount & { address: string }>> {
const account = await AssetAccountService.getAccount(params)

Expand Down
Loading

0 comments on commit beca33b

Please sign in to comment.