Skip to content

Commit

Permalink
fix: remove default hash_type=data
Browse files Browse the repository at this point in the history
  • Loading branch information
classicalliu committed Aug 28, 2019
1 parent 9c25b4a commit 33cc4cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
6 changes: 3 additions & 3 deletions packages/neuron-wallet/src/models/lock-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class LockUtils {
return LockUtils.computeScriptHash(lock)
}

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

const lock: Script = {
Expand All @@ -90,15 +90,15 @@ export default class LockUtils {
return lock
}

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

return lockHash
}

static async addressToAllLockHashes(address: string): Promise<string[]> {
const dataLockHash = await LockUtils.addressToLockHash(address, ScriptHashType.Data)
const dataLockHash = await LockUtils.addressToLockHash(address)
return [dataLockHash]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TransactionWithoutHash, Cell, ScriptHashType, DepType } from 'types/cell-types'
import { TransactionWithoutHash, Cell, DepType } from 'types/cell-types'
import CellsService, { MIN_CELL_CAPACITY } from 'services/cells'
import LockUtils from 'models/lock-utils'
import { CapacityTooSmall } from 'exceptions'
Expand All @@ -12,7 +12,7 @@ export class TransactionGenerator {
changeAddress: string,
fee: string = '0'
): Promise<TransactionWithoutHash> => {
const { codeHash, outPoint } = await LockUtils.systemScript()
const { codeHash, outPoint, hashType } = await LockUtils.systemScript()

const needCapacities: bigint = targetOutputs
.map(o => BigInt(o.capacity))
Expand All @@ -35,7 +35,7 @@ export class TransactionGenerator {
lock: {
codeHash,
args: [blake160],
hashType: ScriptHashType.Data,
hashType,
},
}

Expand All @@ -54,7 +54,7 @@ export class TransactionGenerator {
lock: {
codeHash,
args: [changeBlake160],
hashType: ScriptHashType.Data,
hashType,
},
}

Expand Down
14 changes: 2 additions & 12 deletions packages/neuron-wallet/src/types/convert-to.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import {
Transaction,
Input,
Cell,
Script,
TransactionWithoutHash,
ScriptHashType,
CellDep,
OutPoint,
} from './cell-types'
import { Transaction, Input, Cell, Script, TransactionWithoutHash, CellDep, OutPoint } from './cell-types'

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

public static toSdkScript = (script: Script): CKBComponents.Script => {
return {
...script,
args: script.args!,
codeHash: script.codeHash!,
hashType: ScriptHashType.Data,
hashType: script.hashType,
}
}
}

0 comments on commit 33cc4cf

Please sign in to comment.