neuron icon indicating copy to clipboard operation
neuron copied to clipboard

refactor: replace ckbCore with lumos CKBRPC

Open twhy opened this issue 1 year ago • 0 comments

  1. CKBRPC.createBatchRequest() in Lumos currently has limited typing info: any
createBatchRequest: <N extends keyof Base, P extends (string | number | object)[], R = any[]>(params?: any) => any;

So in this PR I manually added response types in then blocks for CKBRPC.createBatchRequest calls, e.g.

rpc
  .createBatchRequest<'getTransaction', string[], CKBComponents.TransactionWithStatus[]>(
    depositOutPointHashes.map(v => ['getTransaction', v])
  )
  .exec()
  .then((txs: CKBComponents.TransactionWithStatus[]) => {

I'm working on another PR for Lumos to bring back the right types for CKBRPC.createBatchRequest()

  1. In packages/neuron-ui/src/components/WithdrawDialog/index.tsx
  calculateMaximumWithdraw(
    tx.transaction.outputs[+record.outPoint.index] as CKBComponents.CellOutput,
    tx.transaction.outputsData[+record.outPoint.index],
    header.dao,
    tipDao
  )

as CKBComponents.CellOutput is added because

calculateMaximumWithdraw expects CKBComponents.CellOutput whose script.hashType is 'data' | 'type' | 'data1'

tx.transaction.outputs member has type Output whose script.hashType is "type" | "data" | "data1" | "data2"

as CKBComponents.CellOutput will be removed in next PR, which I will replace @nervosnetwork/ckb-sdk-utils methods with Lumos methods.

  1. @nervosnetwork/ckb-sdk-core is removed from dependencies of neurons-ui .

twhy avatar May 09 '24 07:05 twhy