Skip to content

Commit 33cc4cf

Browse files
committed
fix: remove default hash_type=data
1 parent 9c25b4a commit 33cc4cf

3 files changed

Lines changed: 9 additions & 19 deletions

File tree

packages/neuron-wallet/src/models/lock-utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export default class LockUtils {
7979
return LockUtils.computeScriptHash(lock)
8080
}
8181

82-
static async addressToLockScript(address: string, hashType: ScriptHashType = ScriptHashType.Data): Promise<Script> {
82+
static async addressToLockScript(address: string, hashType: ScriptHashType = ScriptHashType.Type): Promise<Script> {
8383
const systemScript = await this.systemScript()
8484

8585
const lock: Script = {
@@ -90,15 +90,15 @@ export default class LockUtils {
9090
return lock
9191
}
9292

93-
static async addressToLockHash(address: string, hashType: ScriptHashType = ScriptHashType.Data): Promise<string> {
93+
static async addressToLockHash(address: string, hashType: ScriptHashType = ScriptHashType.Type): Promise<string> {
9494
const lock: Script = await this.addressToLockScript(address, hashType)
9595
const lockHash: string = await this.lockScriptToHash(lock)
9696

9797
return lockHash
9898
}
9999

100100
static async addressToAllLockHashes(address: string): Promise<string[]> {
101-
const dataLockHash = await LockUtils.addressToLockHash(address, ScriptHashType.Data)
101+
const dataLockHash = await LockUtils.addressToLockHash(address)
102102
return [dataLockHash]
103103
}
104104

packages/neuron-wallet/src/services/tx/transaction-generator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TransactionWithoutHash, Cell, ScriptHashType, DepType } from 'types/cell-types'
1+
import { TransactionWithoutHash, Cell, DepType } from 'types/cell-types'
22
import CellsService, { MIN_CELL_CAPACITY } from 'services/cells'
33
import LockUtils from 'models/lock-utils'
44
import { CapacityTooSmall } from 'exceptions'
@@ -12,7 +12,7 @@ export class TransactionGenerator {
1212
changeAddress: string,
1313
fee: string = '0'
1414
): Promise<TransactionWithoutHash> => {
15-
const { codeHash, outPoint } = await LockUtils.systemScript()
15+
const { codeHash, outPoint, hashType } = await LockUtils.systemScript()
1616

1717
const needCapacities: bigint = targetOutputs
1818
.map(o => BigInt(o.capacity))
@@ -35,7 +35,7 @@ export class TransactionGenerator {
3535
lock: {
3636
codeHash,
3737
args: [blake160],
38-
hashType: ScriptHashType.Data,
38+
hashType,
3939
},
4040
}
4141

@@ -54,7 +54,7 @@ export class TransactionGenerator {
5454
lock: {
5555
codeHash,
5656
args: [changeBlake160],
57-
hashType: ScriptHashType.Data,
57+
hashType,
5858
},
5959
}
6060

packages/neuron-wallet/src/types/convert-to.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
import {
2-
Transaction,
3-
Input,
4-
Cell,
5-
Script,
6-
TransactionWithoutHash,
7-
ScriptHashType,
8-
CellDep,
9-
OutPoint,
10-
} from './cell-types'
1+
import { Transaction, Input, Cell, Script, TransactionWithoutHash, CellDep, OutPoint } from './cell-types'
112

123
export default class ConvertTo {
134
public static toSdkTransaction = (tx: Transaction): CKBComponents.Transaction => {
@@ -62,10 +53,9 @@ export default class ConvertTo {
6253

6354
public static toSdkScript = (script: Script): CKBComponents.Script => {
6455
return {
65-
...script,
6656
args: script.args!,
6757
codeHash: script.codeHash!,
68-
hashType: ScriptHashType.Data,
58+
hashType: script.hashType,
6959
}
7060
}
7161
}

0 commit comments

Comments
 (0)