Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handle hash_type:data2 #3264

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface SpecialAssetCell {
lock: {
args: string
codeHash: string
hashType: 'type' | 'data'
hashType: 'type' | 'data' | 'data1' | 'data2'
}
lockHash: string
multiSignBlake160: string
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/types/Controller/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ declare namespace Controller {
interface Response {
cellDep: any
codeHash: string
hashType: 'data' | 'type'
hashType: 'data' | 'type' | 'data1' | 'data2'
}
}
interface SUDTAccount {
Expand Down
3 changes: 3 additions & 0 deletions packages/neuron-ui/src/utils/scriptAndAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const scriptToAddress = (
{ isMainnet = true, deprecated = false }: { isMainnet?: boolean; deprecated?: boolean }
) => {
const config = { config: isMainnet ? MAINNET : TESTNET }
if (['data1', 'data2'].includes(script.hashType)) {
return encodeToAddress(script, config)
}
Keith-CY marked this conversation as resolved.
Show resolved Hide resolved
return deprecated ? generateAddress(script, config) : encodeToAddress(script, config)
}

Expand Down
1 change: 1 addition & 0 deletions packages/neuron-wallet/src/models/asset-account-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ function toScriptInfo(sporeConfig: SporeScript): ScriptCellInfo {
if (sporeScriptHashType === 'type') return ScriptHashType.Type
if (sporeScriptHashType === 'data') return ScriptHashType.Data
if (sporeScriptHashType === 'data1') return ScriptHashType.Data1
if (sporeScriptHashType === 'data2') return ScriptHashType.Data2

throw new Error(`Invalid hash type: ${sporeScriptHashType}`)
})()
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-wallet/src/models/chain/live-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const LUMOS_HASH_TYPE_MAP: Record<string, ScriptHashType> = {
type: ScriptHashType.Type,
data1: ScriptHashType.Data1,
data: ScriptHashType.Data,
data2: ScriptHashType.Data2,
}

export type CellWithOutPoint = Cell & { outPoint: IOutPoint }
Expand Down
1 change: 1 addition & 0 deletions packages/neuron-wallet/src/models/chain/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum ScriptHashType {
Data = 'data',
Type = 'type',
Data1 = 'data1',
Data2 = 'data2',
}

export default class Script {
Expand Down