Skip to content

Commit b6e3035

Browse files
committed
feat: bump sdk to v0.22.0
1 parent de940d4 commit b6e3035

15 files changed

Lines changed: 62 additions & 81 deletions

File tree

packages/neuron-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"last 2 chrome versions"
4444
],
4545
"dependencies": {
46-
"@nervosnetwork/ckb-sdk-core": "0.21.0",
46+
"@nervosnetwork/ckb-sdk-core": "0.22.0",
4747
"@uifabric/experiments": "7.16.1",
4848
"@uifabric/styling": "7.6.2",
4949
"canvg": "2.0.0",

packages/neuron-wallet/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
]
3535
},
3636
"dependencies": {
37-
"@nervosnetwork/ckb-sdk-core": "0.21.0",
38-
"@nervosnetwork/ckb-sdk-utils": "0.21.0",
37+
"@nervosnetwork/ckb-sdk-core": "0.22.0",
38+
"@nervosnetwork/ckb-sdk-utils": "0.22.0",
3939
"bn.js": "4.11.8",
4040
"chalk": "2.4.2",
4141
"electron-log": "3.0.7",
@@ -51,7 +51,7 @@
5151
"uuid": "3.3.3"
5252
},
5353
"devDependencies": {
54-
"@nervosnetwork/ckb-types": "0.21.0",
54+
"@nervosnetwork/ckb-types": "0.22.0",
5555
"@types/electron-devtools-installer": "2.2.0",
5656
"@types/elliptic": "6.4.9",
5757
"@types/sqlite3": "3.1.5",

packages/neuron-wallet/src/database/chain/entities/transaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
AfterRemove,
1212
} from 'typeorm'
1313
import { remote } from 'electron'
14-
import { Witness, Transaction as TransactionInterface, TransactionStatus, CellDep } from 'types/cell-types'
14+
import { Transaction as TransactionInterface, TransactionStatus, CellDep } from 'types/cell-types'
1515
import TxDbChangedSubject from 'models/subjects/tx-db-changed-subject'
1616
import InputEntity from './input'
1717
import OutputEntity from './output'
@@ -47,7 +47,7 @@ export default class Transaction extends BaseEntity {
4747
@Column({
4848
type: 'simple-json',
4949
})
50-
witnesses!: Witness[]
50+
witnesses!: string[]
5151

5252
@Column({
5353
type: 'varchar',

packages/neuron-wallet/src/env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const env: ENV = {
5050
name: 'Local',
5151
remote: 'http://localhost:8114',
5252
type: 1,
53-
chain: 'ckb_devnet',
53+
chain: 'ckb_dev',
5454
},
5555
],
5656
},

packages/neuron-wallet/src/models/lock-utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export default class LockUtils {
8585

8686
const lock: Script = {
8787
codeHash: systemScript.codeHash,
88-
args: [LockUtils.addressToBlake160(address)],
88+
args: LockUtils.addressToBlake160(address),
8989
hashType,
9090
}
9191
return lock
@@ -113,7 +113,7 @@ export default class LockUtils {
113113
}
114114

115115
static lockScriptToAddress(lock: Script): string {
116-
const blake160: string = lock.args![0]
116+
const blake160: string = lock.args!
117117
return this.blake160ToAddress(blake160)
118118
}
119119

@@ -127,8 +127,7 @@ export default class LockUtils {
127127
}
128128

129129
static addressToBlake160(address: string): string {
130-
const prefix = env.testnet ? core.utils.AddressPrefix.Testnet : core.utils.AddressPrefix.Mainnet
131-
const result: string = core.utils.parseAddress(address, prefix, 'hex') as string
130+
const result: string = core.utils.parseAddress(address, 'hex') as string
132131
const hrp: string = `0100`
133132
let blake160: string = result.slice(hrp.length + 2, result.length)
134133
if (!blake160.startsWith('0x')) {

packages/neuron-wallet/src/services/cells.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export default class CellsService {
159159
if (!args) {
160160
return undefined
161161
}
162-
return args[0]
162+
return args
163163
})
164164
.filter(blake160 => !!blake160) as string[]
165165

packages/neuron-wallet/src/services/tx/transaction-generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class TransactionGenerator {
3434
data: '0x',
3535
lock: {
3636
codeHash,
37-
args: [blake160],
37+
args: blake160,
3838
hashType,
3939
},
4040
}
@@ -53,7 +53,7 @@ export class TransactionGenerator {
5353
data: '0x',
5454
lock: {
5555
codeHash,
56-
args: [changeBlake160],
56+
args: changeBlake160,
5757
hashType,
5858
},
5959
}

packages/neuron-wallet/src/services/tx/transaction-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ export class TransactionsService {
269269
let outputBlake160s: string[] = []
270270
if (tx.inputs) {
271271
inputBlake160s = tx.inputs
272-
.map(input => input.lock && input.lock.args && input.lock.args[0])
272+
.map(input => input.lock && input.lock.args)
273273
.filter(blake160 => blake160) as string[]
274274
}
275275
if (tx.outputs) {
276-
outputBlake160s = tx.outputs.map(output => output.lock.args![0])
276+
outputBlake160s = tx.outputs.map(output => output.lock.args!)
277277
}
278278
return [...new Set(inputBlake160s.concat(outputBlake160s))]
279279
}

packages/neuron-wallet/src/services/wallets.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { AccountExtendedPublicKey, PathAndPrivateKey } from 'models/keys/key'
44
import Keystore from 'models/keys/keystore'
55
import Store from 'models/store'
66
import LockUtils from 'models/lock-utils'
7-
import { Witness, TransactionWithoutHash, Input } from 'types/cell-types'
7+
import { TransactionWithoutHash, Input } from 'types/cell-types'
88
import ConvertTo from 'types/convert-to'
99
import Blake2b from 'utils/blake2b'
1010
import { WalletNotFound, IsRequired, UsedName } from 'exceptions'
@@ -380,16 +380,16 @@ export default class WalletService {
380380
const paths = addressInfos.map(info => info.path)
381381
const pathAndPrivateKeys = this.getPrivateKeys(wallet, paths, password)
382382

383-
const witnesses: Witness[] = inputs!.map((input: Input) => {
384-
const blake160: string = input.lock!.args![0]
383+
const witnesses: string[] = inputs!.map((input: Input) => {
384+
const blake160: string = input.lock!.args!
385385
const info = addressInfos.find(i => i.blake160 === blake160)
386386
const { path } = info!
387387
const pathAndPrivateKey = pathAndPrivateKeys.find(p => p.path === path)
388388
if (!pathAndPrivateKey) {
389389
throw new Error('no private key found')
390390
}
391391
const { privateKey } = pathAndPrivateKey
392-
const witness = this.signWitness({ data: [] }, privateKey, txHash)
392+
const witness = this.signWitness('', privateKey, txHash)
393393
return witness
394394
})
395395

@@ -443,19 +443,15 @@ export default class WalletService {
443443
return addr!.address
444444
}
445445

446-
public signWitness = (witness: Witness, privateKey: string, txHash: string): Witness => {
446+
public signWitness = (witness: string, privateKey: string, txHash: string): string => {
447447
const addrObj = core.generateAddress(privateKey)
448-
const oldData = witness.data
448+
const oldData = witness
449449
const blake2b = new Blake2b()
450450
blake2b.update(txHash)
451-
oldData.forEach(data => {
452-
blake2b.update(data)
453-
})
451+
blake2b.update(oldData)
454452
const message = blake2b.digest()
455453
const signature = addrObj.signRecoverable(message)
456-
const newWitness: Witness = {
457-
data: [signature],
458-
}
454+
const newWitness = signature
459455
return newWitness
460456
}
461457

packages/neuron-wallet/src/startup/sync-block-task/init-database.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import initConnection from 'database/chain/ormconfig'
22
import Utils from 'services/sync/utils'
33
import { updateMetaInfo, getMetaInfo } from 'database/chain/meta-info'
44
import LockUtils from 'models/lock-utils'
5+
import logger from 'utils/logger'
56
import genesisBlockHash from './genesis'
67

78
export const initDatabase = async () => {
@@ -11,6 +12,7 @@ export const initDatabase = async () => {
1112
const systemScriptInfo = await LockUtils.systemScript()
1213
updateMetaInfo({ genesisBlockHash: hash, systemScriptInfo })
1314
} catch (err) {
15+
logger.debug('initDatabase error:', err)
1416
try {
1517
const metaInfo = getMetaInfo()
1618
await initConnection(metaInfo.genesisBlockHash)

0 commit comments

Comments
 (0)