Skip to content

Commit

Permalink
fix: scriptToAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
devchenyan committed May 14, 2024
1 parent 3e86556 commit 247a5c9
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { PasswordIncorrectException } from 'exceptions'
import { TFunction } from 'i18next'
import { getTransaction as getOnChainTransaction } from 'services/chain'
import { getTransaction as getSentTransaction, sendTx, invokeShowErrorMessage } from 'services/remote'
import { isSuccessResponse, ErrorCode, shannonToCKBFormatter } from 'utils'
import { isSuccessResponse, ErrorCode, shannonToCKBFormatter, scriptToAddress } from 'utils'
import { FEE_RATIO } from 'utils/const'
import { scriptToAddress } from '@nervosnetwork/ckb-sdk-utils'

export const useInitialize = ({
tx,
Expand Down Expand Up @@ -155,32 +154,32 @@ export const useOutputs = ({
}) => {
const getLastOutputAddress = (outputs: State.DetailedOutput[]) => {
if (outputs.length === 1) {
return scriptToAddress(outputs[0].lock, isMainnet)
return scriptToAddress(outputs[0].lock, { isMainnet })
}

const change = outputs.find(output => {
const address = scriptToAddress(output.lock, isMainnet)
const address = scriptToAddress(output.lock, { isMainnet })
return !!addresses.find(item => item.address === address && item.type === 1)
})

if (change) {
return scriptToAddress(change.lock, isMainnet)
return scriptToAddress(change.lock, { isMainnet })
}

const receive = outputs.find(output => {
const address = scriptToAddress(output.lock, isMainnet)
const address = scriptToAddress(output.lock, { isMainnet })
return !!addresses.find(item => item.address === address && item.type === 0)
})
if (receive) {
return scriptToAddress(receive.lock, isMainnet)
return scriptToAddress(receive.lock, { isMainnet })
}

const sudt = outputs.find(output => {
const address = scriptToAddress(output.lock, isMainnet)
const address = scriptToAddress(output.lock, { isMainnet })
return !!sUDTAccounts.find(item => item.address === address)
})
if (sudt) {
return scriptToAddress(sudt.lock, isMainnet)
return scriptToAddress(sudt.lock, { isMainnet })
}
return ''
}
Expand All @@ -195,7 +194,7 @@ export const useOutputs = ({
if (transaction && transaction.outputs.length) {
const lastOutputAddress = getLastOutputAddress(transaction.outputs)
return transaction.outputs.map(output => {
const address = scriptToAddress(output.lock, isMainnet)
const address = scriptToAddress(output.lock, { isMainnet })
return {
capacity: output.capacity,
address,
Expand Down

1 comment on commit 247a5c9

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Packaging for test is done in 9076389662

Please sign in to comment.