Skip to content

refactor: refactor ckbCore.utils.xyz with lumos methods - #3142

Merged
Keith-CY merged 5 commits into
nervosnetwork:developfrom
twhy:refactor-ckbCore-utils
May 9, 2024
Merged

refactor: refactor ckbCore.utils.xyz with lumos methods#3142
Keith-CY merged 5 commits into
nervosnetwork:developfrom
twhy:refactor-ckbCore-utils

Conversation

@twhy

@twhy twhy commented May 7, 2024

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread packages/neuron-ui/src/components/HDWalletSign/index.tsx Outdated
Comment thread packages/neuron-ui/src/components/HDWalletSign/index.tsx Outdated
@twhy
twhy requested a review from Keith-CY May 7, 2024 06:40
Comment thread packages/neuron-ui/src/components/ApproveMultisigTxDialog/index.tsx Outdated
@twhy
twhy requested a review from homura May 8, 2024 10:37
Comment thread packages/neuron-ui/src/components/ApproveMultisigTxDialog/index.tsx Outdated
Comment thread packages/neuron-ui/src/components/HDWalletSign/index.tsx Outdated
@twhy

twhy commented May 9, 2024

Copy link
Copy Markdown
Contributor Author

@Keith-CY
Since encodeToAddress checks script's hashType and throws an error if hashType is invalid,
the code is now simplified as below. We are ready to merge this PR after CI checks completes.

if (cell.lock.codeHash === systemCodeHash && cell.lock.hashType === 'type') {
  address = generateAddress(cell.lock, { config })
} else {
  address = encodeToAddress(cell.lock, { config })
}

https://github.com/ckb-js/lumos/blob/develop/packages/helpers/src/index.ts#L239
image

https://github.com/ckb-js/lumos/blob/develop/packages/toolkit/src/validators.js#L80
image

@Keith-CY

Keith-CY commented May 9, 2024

Copy link
Copy Markdown
Contributor

@Keith-CY

Since encodeToAddress checks script's hashType and throws an error if hashType is invalid,

the code is now simplified as below. We are ready to merge this PR after CI checks completes.

if (cell.lock.codeHash === systemCodeHash && cell.lock.hashType === 'type') {

  address = generateAddress(cell.lock, { config })

} else {

  address = encodeToAddress(cell.lock, { config })

}

https://github.com/ckb-js/lumos/blob/develop/packages/helpers/src/index.ts#L239

image

https://github.com/ckb-js/lumos/blob/develop/packages/toolkit/src/validators.js#L80

image

LGTM

@twhy
twhy requested a review from homura May 9, 2024 06:04
Comment thread packages/neuron-ui/src/utils/scriptAndAddress.ts
@Keith-CY
Keith-CY enabled auto-merge May 9, 2024 06:13
@Keith-CY
Keith-CY added this pull request to the merge queue May 9, 2024
Merged via the queue into nervosnetwork:develop with commit 45cb237 May 9, 2024
@twhy
twhy deleted the refactor-ckbCore-utils branch May 9, 2024 06:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants