Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/neuron-ui/src/components/SpecialAssetList/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect } from 'react'
import { ckbCore } from 'services/chain'
import { number, bytes } from '@ckb-lumos/codec'
import { getSUDTAccountList } from 'services/remote'
import { NeuronWalletActions, useDispatch } from 'states'
import {
Expand Down Expand Up @@ -144,7 +144,7 @@ export const useSpecialAssetColumnInfo = ({

switch (assetInfo.lock) {
case PresetScript.Locktime: {
const targetEpochInfo = epochParser(ckbCore.utils.toUint64Le(`0x${lock.args.slice(-16)}`))
const targetEpochInfo = epochParser(bytes.hexify(number.Uint64LE.pack(`0x${lock.args.slice(-16)}`)))
const currentEpochInfo = epochParser(epoch)
const targetEpochFraction =
Number(targetEpochInfo.length) > 0 ? Number(targetEpochInfo.index) / Number(targetEpochInfo.length) : 1
Expand Down
3 changes: 0 additions & 3 deletions packages/neuron-ui/src/services/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ export const ckbCore = new CKBCore('')
export const { getHeader, getBlockchainInfo, getTipHeader, getHeaderByNumber, getFeeRateStats, getTransaction } =
ckbCore.rpc

export const { toUint64Le, parseEpoch } = ckbCore.utils

export default {
ckbCore,
getHeader,
getTipHeader,
getTransaction,
toUint64Le,
getFeeRateStats,
}
9 changes: 5 additions & 4 deletions packages/neuron-ui/src/utils/parsers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { toUint64Le, parseEpoch } from 'services/chain'
import { since } from '@ckb-lumos/base'
import { number, bytes } from '@ckb-lumos/codec'
import { MILLISECONDS, PAGE_SIZE } from './const'

export const listParams = (search: string) => {
Expand All @@ -17,7 +18,7 @@ export const listParams = (search: string) => {

export const epochParser = (epoch: string) => {
const e = epoch.startsWith('0x') ? epoch : `0x${BigInt(epoch).toString(16)}`
const parsed = parseEpoch(e)
const parsed = since.parseEpoch(e)

const res = {
length: BigInt(parsed.length),
Expand All @@ -44,7 +45,7 @@ export const toUint128Le = (hexString: string) => {
s = s.slice(0, 34)
}

return `${toUint64Le(`0x${s.substr(18, 16)}`)}${toUint64Le(s.substr(0, 18)).slice(2)}`
return bytes.hexify(number.Uint128LE.pack(s))
}

export const getLockTimestamp = ({
Expand All @@ -56,7 +57,7 @@ export const getLockTimestamp = ({
epoch: string
bestKnownBlockTimestamp: number
}) => {
const targetEpochInfo = epochParser(toUint64Le(`0x${lockArgs.slice(-16)}`))
const targetEpochInfo = epochParser(bytes.hexify(number.Uint64LE.pack(`0x${lockArgs.slice(-16)}`)))
const currentEpochInfo = epochParser(epoch)
const targetEpochFraction =
Number(targetEpochInfo.length) > 0 ? Number(targetEpochInfo.index) / Number(targetEpochInfo.length) : 1
Expand Down