Skip to content

Commit 3abf7ca

Browse files
committed
feat: bump sdk to v0.21.0
1 parent c64806f commit 3abf7ca

16 files changed

Lines changed: 101 additions & 85 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.20.0",
46+
"@nervosnetwork/ckb-sdk-core": "0.21.0",
4747
"@uifabric/experiments": "7.16.1",
4848
"@uifabric/styling": "7.6.2",
4949
"canvg": "2.0.0",

packages/neuron-ui/src/containers/Main/hooks.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const useSyncChainData = ({ chainURL, dispatch }: { chainURL: string; dis
3838
.then(tipBlockNumber => {
3939
dispatch({
4040
type: AppActions.UpdateTipBlockNumber,
41-
payload: tipBlockNumber,
41+
payload: BigInt(tipBlockNumber).toString(),
4242
})
4343
})
4444
.catch((err: Error) => {
@@ -51,7 +51,9 @@ export const useSyncChainData = ({ chainURL, dispatch }: { chainURL: string; dis
5151
getBlockchainInfo()
5252
.then(info => {
5353
if (info) {
54-
const { chain = '', difficulty = '', epoch = '', alerts = [] } = info
54+
const { chain = '', difficulty: difficultyHex = '', epoch: epochHex = '', alerts = [] } = info
55+
const difficulty = BigInt(difficultyHex).toString()
56+
const epoch = BigInt(epochHex).toString()
5557
if (alerts.length) {
5658
alerts.forEach(a => {
5759
// TODO: display alerts in Notification

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.20.0",
38-
"@nervosnetwork/ckb-sdk-utils": "0.20.0",
37+
"@nervosnetwork/ckb-sdk-core": "0.21.0",
38+
"@nervosnetwork/ckb-sdk-utils": "0.21.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.20.0",
54+
"@nervosnetwork/ckb-types": "0.21.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/listeners/tx-status.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ const getTransactionStatus = async (hash: string) => {
2424
}
2525
if (tx.txStatus.status === 'committed') {
2626
return {
27-
tx: tx.transaction,
27+
tx: TypeConvert.toTransaction(tx.transaction),
2828
status: TransactionStatus.Success,
2929
blockHash: tx.txStatus.blockHash,
3030
}
3131
}
3232
return {
33-
tx: tx.transaction,
33+
tx: TypeConvert.toTransaction(tx.transaction),
3434
status: TransactionStatus.Pending,
3535
blockHash: null,
3636
}
@@ -68,7 +68,7 @@ const trackingStatus = async () => {
6868
const { core }: { core: Core } = nodeService
6969
const getBlockService = new GetBlocks(core.rpc.node.url)
7070
for (const successTx of successTxs) {
71-
const transaction = TypeConvert.toTransaction(successTx.tx)
71+
const transaction = successTx.tx
7272
const { blockHash } = successTx
7373
const blockHeader = await getBlockService.getHeader(blockHash!)
7474
transaction.blockHash = blockHash!

packages/neuron-wallet/src/models/keys/address.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ export enum AddressType {
99
Change = 1, // Internal chain
1010
}
1111

12-
export const publicKeyToAddress = (publicKey: string, prefix = AddressPrefix.Testnet) =>
13-
pubkeyToAddress(publicKey, {
12+
export const publicKeyToAddress = (publicKey: string, prefix = AddressPrefix.Testnet) => {
13+
const pubkey = publicKey.startsWith('0x') ? publicKey : `0x${publicKey}`
14+
return pubkeyToAddress(pubkey, {
1415
prefix,
1516
type: Type.HashIdx,
1617
codeHashIndex: '0x00',
1718
})
19+
}
1820

1921
export default class Address {
2022
publicKey?: string

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default class LockUtils {
130130
const prefix = env.testnet ? core.utils.AddressPrefix.Testnet : core.utils.AddressPrefix.Mainnet
131131
const result: string = core.utils.parseAddress(address, prefix, 'hex') as string
132132
const hrp: string = `0100`
133-
let blake160: string = result.slice(hrp.length, result.length)
133+
let blake160: string = result.slice(hrp.length + 2, result.length)
134134
if (!blake160.startsWith('0x')) {
135135
blake160 = `0x${blake160}`
136136
}

packages/neuron-wallet/src/services/indexer/queue.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import TransactionPersistor from 'services/tx/transaction-persistor'
1111
import IndexerTransaction from 'services/tx/indexer-transaction'
1212

1313
import IndexerRPC from './indexer-rpc'
14+
import HexUtils from 'utils/hex'
1415

1516
export interface LockHashInfo {
1617
lockHash: string
@@ -137,7 +138,7 @@ export default class IndexerQueue {
137138
const lockHashIndexStates = await this.indexerRPC.getLockHashIndexStates()
138139
const blockNumbers = lockHashIndexStates
139140
.filter(state => lockHashes.includes(state.lockHash))
140-
.map(state => state.blockNumber)
141+
.map(state => HexUtils.toDecimal(state.blockNumber))
141142
const uniqueBlockNumbers = [...new Set(blockNumbers)]
142143
const blockNumbersBigInt = uniqueBlockNumbers.map(num => BigInt(num))
143144
const minBlockNumber = Utils.min(blockNumbersBigInt)
@@ -192,9 +193,9 @@ export default class IndexerQueue {
192193

193194
let address: string | undefined
194195
if (type === TxPointType.CreatedBy) {
195-
address = LockUtils.lockScriptToAddress(transaction.outputs![+txPoint.index].lock)
196+
address = LockUtils.lockScriptToAddress(transaction.outputs![parseInt(txPoint.index, 16)].lock)
196197
} else if (type === TxPointType.ConsumedBy) {
197-
const input = txEntity.inputs[+txPoint.index]
198+
const input = txEntity.inputs[parseInt(txPoint.index, 16)]
198199
const output = await IndexerTransaction.updateInputLockHash(input.outPointTxHash!, input.outPointIndex!)
199200
if (output) {
200201
address = LockUtils.lockScriptToAddress(output.lock)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ShouldBeTypeOf } from 'exceptions'
77
import { ConnectionStatusSubject } from 'models/subjects/node'
88
import { CurrentNetworkIDSubject } from 'models/subjects/networks'
99
import NetworksService from 'services/networks'
10+
import HexUtils from 'utils/hex'
1011

1112
class NodeService {
1213
private static instance: NodeService
@@ -96,7 +97,7 @@ class NodeService {
9697
if (!this.delayTime) {
9798
this.delayTime = 0
9899
}
99-
this.tipNumberSubject.next(tipNumber)
100+
this.tipNumberSubject.next(HexUtils.toDecimal(tipNumber))
100101
},
101102
() => {
102103
if (this.delayTime < 10 * this.intervalTime) {

packages/neuron-wallet/src/services/sync/get-blocks.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Block, BlockHeader } from 'types/cell-types'
55
import TypeConvert from 'types/type-convert'
66
import CheckAndSave from './check-and-save'
77
import Utils from './utils'
8+
import HexUtils from 'utils/hex'
89

910
export default class GetBlocks {
1011
private retryTime: number
@@ -59,13 +60,13 @@ export default class GetBlocks {
5960
}
6061

6162
public getBlockByNumber = async (num: string): Promise<Block> => {
62-
const block = await this.core.rpc.getBlockByNumber(num)
63+
const block = await this.core.rpc.getBlockByNumber(HexUtils.toHex(num))
6364
return TypeConvert.toBlock(block)
6465
}
6566

6667
public genesisBlockHash = async (): Promise<string> => {
6768
const hash: string = await Utils.retry(3, 100, async () => {
68-
const h: string = await this.core.rpc.getBlockHash('0')
69+
const h: string = await this.core.rpc.getBlockHash('0x0')
6970
return h
7071
})
7172

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ export default class WalletService {
452452
blake2b.update(data)
453453
})
454454
const message = blake2b.digest()
455-
const signature = `0x${addrObj.signRecoverable(message)}`
455+
const signature = addrObj.signRecoverable(message)
456456
const newWitness: Witness = {
457457
data: [signature],
458458
}

0 commit comments

Comments
 (0)