Skip to content

Commit

Permalink
refactor: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
duanyytop committed Mar 15, 2024
1 parent 61d13d8 commit 7622674
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 25 deletions.
10 changes: 2 additions & 8 deletions packages/ckb/src/rgbpp/btc-jump-ckb.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RgbppCkbVirtualTx, BtcJumpCkbVirtualTxParams, BtcJumpCkbVirtualTxResult } from '../types/rgbpp';
import { blockchain } from '@ckb-lumos/base';
import { NoRgbppLiveCellError } from '../error';
import { append0x, calculateRgbppCellCapacity, u128ToLe, u32ToLe } from '../utils';
import { append0x, calculateRgbppCellCapacity, u128ToLe } from '../utils';
import {
buildPreLockArgs,
calculateCommitment,
Expand All @@ -10,13 +10,7 @@ import {
genRgbppLockScript,
} from '../utils/rgbpp';
import { Hex, IndexerCell } from '../types';
import {
RGBPP_TX_ID_PLACEHOLDER,
RGBPP_WITNESS_PLACEHOLDER,
getRgbppLockDep,
getSecp256k1CellDep,
getXudtDep,
} from '../constants';
import { RGBPP_WITNESS_PLACEHOLDER, getRgbppLockDep, getSecp256k1CellDep, getXudtDep } from '../constants';
import { addressToScript } from '@nervosnetwork/ckb-sdk-utils';

/**
Expand Down
8 changes: 1 addition & 7 deletions packages/ckb/src/rgbpp/btc-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ import { NoRgbppLiveCellError } from '../error';
import { append0x, calculateRgbppCellCapacity, u128ToLe, u32ToLe } from '../utils';
import { buildPreLockArgs, calculateCommitment, compareInputs, genRgbppLockScript } from '../utils/rgbpp';
import { Hex, IndexerCell } from '../types';
import {
RGBPP_TX_ID_PLACEHOLDER,
RGBPP_WITNESS_PLACEHOLDER,
getRgbppLockDep,
getSecp256k1CellDep,
getXudtDep,
} from '../constants';
import { RGBPP_WITNESS_PLACEHOLDER, getRgbppLockDep, getSecp256k1CellDep, getXudtDep } from '../constants';

/**
* Generate the virtual ckb transaction for the btc transfer tx
Expand Down
4 changes: 2 additions & 2 deletions packages/ckb/src/rgbpp/ckb-jump-btc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CkbJumpBtcVirtualTxParams, RgbppCkbVirtualTx } from '../types/rgbpp';
import { CkbJumpBtcVirtualTxParams } from '../types/rgbpp';
import { blockchain } from '@ckb-lumos/base';
import { NoLiveCellError, NoXudtLiveCellError } from '../error';
import {
Expand All @@ -10,7 +10,7 @@ import {
u128ToLe,
} from '../utils';
import { buildPreLockArgs, genRgbppLockScript } from '../utils/rgbpp';
import { MAX_FEE, MIN_CAPACITY, RGBPP_TX_ID_PLACEHOLDER, SECP256K1_WITNESS_LOCK_SIZE, getXudtDep } from '../constants';
import { MAX_FEE, SECP256K1_WITNESS_LOCK_SIZE, getXudtDep } from '../constants';
import { addressToScript, getTransactionSize } from '@nervosnetwork/ckb-sdk-utils';

/**
Expand Down
10 changes: 2 additions & 8 deletions packages/ckb/src/utils/rgbpp.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { sha256 } from 'js-sha256';
import { Hex, IndexerCell, RgbppCkbVirtualTx } from '../types';
import { append0x, remove0x, u16ToLe, u32ToLe, u8ToHex, utf8ToHex } from './hex';
import { append0x, remove0x, u32ToLe, utf8ToHex } from './hex';
import {
BTC_JUMP_CONFIRMATION_BLOCKS,
RGBPP_TX_ID_PLACEHOLDER,
getBtcTimeLockScript,
getRgbppLockScript,
} from '../constants';
import {
hexToBytes,
serializeOutPoint,
serializeOutput,
serializeOutputs,
serializeScript,
} from '@nervosnetwork/ckb-sdk-utils';
import { hexToBytes, serializeOutPoint, serializeOutput, serializeScript } from '@nervosnetwork/ckb-sdk-utils';
import { blockchain } from '@ckb-lumos/base';

export const genRgbppLockScript = (rgbppLockArgs: Hex, isMainnet: boolean) => {
Expand Down

0 comments on commit 7622674

Please sign in to comment.