Skip to content

Commit

Permalink
fix(types): set the type of arg in script to string
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Apr 24, 2019
1 parent 8c46065 commit 7ea3ad2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions packages/ckb-sdk-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ export const hexToUtf8 = (hex: string) => {
return utf8.decode(str)
}

export const lockScriptToHash = ({ binaryHash, args }: { binaryHash?: string; args?: Uint8Array[] }) => {
export const lockScriptToHash = ({ binaryHash, args }: { binaryHash?: string; args?: (Uint8Array | string)[] }) => {
const s = blake2b(32, null, null, PERSONAL)
if (binaryHash) {
s.update(Buffer.from(binaryHash.replace(/^0x/, ''), 'hex'))
}
if (args && args.length) {
args.forEach(arg => {
s.update(arg)
})
args.forEach(arg => (typeof arg === 'string' ? s.update(hexToBytes(arg)) : s.update(arg)))
}

const digest = s.digest('hex')
Expand Down
2 changes: 1 addition & 1 deletion packages/ckb-sdk-wallet/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Account extends ECPair {

public rpc: RPC

public unlockArgs: Uint8Array[] = []
public unlockArgs: string[] = []

public lockScript: CKBComponents.Script = {
version: 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/ckb-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ declare namespace CKBComponents {
*/
export interface CellInput {
prevOutput: OutPoint
args: Uint8Array[]
args: Hash[]
}

/**
Expand Down

0 comments on commit 7ea3ad2

Please sign in to comment.