Skip to content

Commit

Permalink
Merge pull request #35 from ckb-cell/feat/update-lock-utils
Browse files Browse the repository at this point in the history
feat(rgbpp-sdk/ckb): Update isRgbppLockCell and isBtcTimeLockCell methods
  • Loading branch information
duanyytop authored Mar 21, 2024
2 parents 3e6ac1c + d99df43 commit f42956d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/ckb/src/utils/rgbpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,14 @@ export const replaceLockArgsWithRealBtcTxId = (lockArgs: Hex, txId: Hex): Hex =>
return `0x${remove0x(lockArgs).substring(0, argsLength - BTC_TX_ID_SIZE)}${remove0x(txId)}`;
};

export const isRgbppLockCell = async (collector: Collector, outPoint: CKBComponents.OutPoint, isMainnet: boolean) => {
export const isRgbppLockCell = (cell: CKBComponents.CellOutput, isMainnet: boolean): boolean => {
const rgbppLock = getRgbppLockScript(isMainnet);
const rgbppCellLock = (await collector.getLiveCell(outPoint)).output.lock;
const isRgbppLock = rgbppCellLock.codeHash === rgbppLock.codeHash && rgbppCellLock.hashType === rgbppLock.hashType;
const isRgbppLock = cell.lock.codeHash === rgbppLock.codeHash && cell.lock.hashType === rgbppLock.hashType;
return isRgbppLock;
};

export const isBtcTimeLockCell = async (collector: Collector, outPoint: CKBComponents.OutPoint, isMainnet: boolean) => {
export const isBtcTimeLockCell = (cell: CKBComponents.CellOutput, isMainnet: boolean): boolean => {
const btcTimeLock = getBtcTimeLockScript(isMainnet);
const btcTimeCellLock = (await collector.getLiveCell(outPoint)).output.lock;
const isBtcTimeLock =
btcTimeCellLock.codeHash === btcTimeLock.codeHash && btcTimeCellLock.hashType === btcTimeLock.hashType;

const isBtcTimeLock = cell.lock.codeHash === btcTimeLock.codeHash && cell.lock.hashType === btcTimeLock.hashType;
return isBtcTimeLock;
};

1 comment on commit f42956d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[{"name":"@rgbpp-sdk/btc","version":"0.0.0-snap-20240321053723"},{"name":"@rgbpp-sdk/ckb","version":"0.0.0-snap-20240321053723"}]

Please sign in to comment.