Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit 53fc8ee

Browse files
committed
refactor: bypass named importing from @nervosnetwork/ckb-sdk-utils directly
1 parent 6096395 commit 53fc8ee

File tree

16 files changed

+54
-55
lines changed

16 files changed

+54
-55
lines changed

packages/ckb/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export { serializeScript } from '@nervosnetwork/ckb-sdk-utils';
1+
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
2+
export const serializeScript = ckbUtils.serializeScript;
23

34
export * from './schemas/generated/blockchain';
45
export * from './schemas/generated/rgbpp';

packages/ckb/src/paymaster/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import { AddressPrefix, addressToScript, getTransactionSize, privateKeyToAddress } from '@nervosnetwork/ckb-sdk-utils';
1+
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
22
import { ConstructPaymasterParams } from '../types/rgbpp';
33
import { NoLiveCellError } from '../error';
44
import { CKB_UNIT, MAX_FEE, SECP256K1_WITNESS_LOCK_SIZE, getSecp256k1CellDep } from '../constants';
55
import { append0x, calculateTransactionFee } from '../utils';
66

7+
const { AddressPrefix, addressToScript, getTransactionSize, privateKeyToAddress } = ckbUtils;
8+
79
const SECP256K1_MIN_CAPACITY = BigInt(61) * CKB_UNIT;
810

911
export const splitMultiCellsWithSecp256k1 = async ({

packages/ckb/src/rgbpp/btc-jump-ckb.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ import {
2525
} from '../utils/rgbpp';
2626
import { Hex, IndexerCell } from '../types';
2727
import { RGBPP_WITNESS_PLACEHOLDER, getSecp256k1CellDep } from '../constants';
28-
import { addressToScript, getTransactionSize } from '@nervosnetwork/ckb-sdk-utils';
28+
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
29+
30+
const { addressToScript, getTransactionSize } = ckbUtils;
2931

3032
/**
3133
* Generate the virtual ckb transaction for the jumping tx from BTC to CKB

packages/ckb/src/rgbpp/btc-time.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
import {
2-
addressToScript,
3-
bytesToHex,
4-
getTransactionSize,
5-
rawTransactionToHash,
6-
scriptToHash,
7-
serializeOutPoint,
8-
serializeWitnessArgs,
9-
} from '@nervosnetwork/ckb-sdk-utils';
1+
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
102
import {
113
BTC_JUMP_CONFIRMATION_BLOCKS,
124
SECP256K1_WITNESS_LOCK_SIZE,
@@ -29,6 +21,16 @@ import { buildSpvClientCellDep } from '../utils';
2921
import { blockchain } from '@ckb-lumos/base';
3022
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses.js';
3123

24+
const {
25+
addressToScript,
26+
bytesToHex,
27+
getTransactionSize,
28+
rawTransactionToHash,
29+
scriptToHash,
30+
serializeOutPoint,
31+
serializeWitnessArgs,
32+
} = ckbUtils;
33+
3234
export const buildBtcTimeUnlockWitness = (btcTxProof: Hex): Hex => {
3335
const btcTimeUnlock = BTCTimeUnlock.pack({ btcTxProof: blockchain.Bytes.pack(btcTxProof) });
3436
return append0x(bytesToHex(btcTimeUnlock));

packages/ckb/src/rgbpp/btc-transfer.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,11 @@ import {
3737
getRgbppLockScript,
3838
getSecp256k1CellDep,
3939
} from '../constants';
40-
import {
41-
addressToScript,
42-
getTransactionSize,
43-
rawTransactionToHash,
44-
scriptToHash,
45-
serializeWitnessArgs,
46-
} from '@nervosnetwork/ckb-sdk-utils';
40+
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
4741
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses.js';
4842

43+
const { addressToScript, getTransactionSize, rawTransactionToHash, scriptToHash, serializeWitnessArgs } = ckbUtils;
44+
4945
/**
5046
* Generate the virtual ckb transaction for the btc transfer tx
5147
* @param collector The collector that collects CKB live cells and transactions

packages/ckb/src/rgbpp/ckb-builder.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
bytesToHex,
3-
getTransactionSize,
4-
rawTransactionToHash,
5-
scriptToHash,
6-
serializeWitnessArgs,
7-
} from '@nervosnetwork/ckb-sdk-utils';
1+
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
82
import {
93
UpdateCkbTxWithRealBtcTxIdParams,
104
AppendPaymasterCellAndSignTxParams,
@@ -27,6 +21,8 @@ import { buildSpvClientCellDep } from '../utils';
2721
import { RGBPPUnlock, Uint16 } from '../schemas/generated/rgbpp';
2822
import { Bytes } from '@ckb-lumos/base/lib/blockchain.js';
2923

24+
const { bytesToHex, getTransactionSize, rawTransactionToHash, scriptToHash, serializeWitnessArgs } = ckbUtils;
25+
3026
export const buildRgbppUnlockWitness = (
3127
btcTxBytes: Hex,
3228
btcTxProof: Hex,

packages/ckb/src/rgbpp/ckb-jump-btc.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import {
1212
} from '../utils';
1313
import { genRgbppLockScript } from '../utils/rgbpp';
1414
import { MAX_FEE, MIN_CAPACITY, RGBPP_TX_WITNESS_MAX_SIZE } from '../constants';
15-
import { addressToScript, getTransactionSize } from '@nervosnetwork/ckb-sdk-utils';
15+
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
16+
17+
const { addressToScript, getTransactionSize } = ckbUtils;
1618

1719
/**
1820
* Generate the virtual ckb transaction for the jumping tx from CKB to BTC

packages/ckb/src/rgbpp/launch.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ import {
2424
getUniqueTypeScript,
2525
UNLOCKABLE_LOCK_SCRIPT,
2626
} from '../constants';
27-
import { getTransactionSize, scriptToHash } from '@nervosnetwork/ckb-sdk-utils';
27+
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
28+
29+
const { getTransactionSize, scriptToHash } = ckbUtils;
2830

2931
/**
3032
* Generate the virtual ckb transaction for the btc transfer tx

packages/ckb/src/spore/cluster.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import {
1111
} from '../constants';
1212
import { generateClusterCreateCoBuild, generateClusterId } from '../utils/spore';
1313
import { NoRgbppLiveCellError } from '../error';
14-
import { bytesToHex, getTransactionSize } from '@nervosnetwork/ckb-sdk-utils';
14+
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
15+
16+
const { bytesToHex, getTransactionSize } = ckbUtils;
1517

1618
/**
1719
* Generate the virtual ckb transaction for creating cluster

packages/ckb/src/spore/leap.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,12 @@ import {
2424
} from '../constants';
2525
import { generateSporeTransferCoBuild, throwErrorWhenSporeCellsInvalid } from '../utils/spore';
2626
import { NoRgbppLiveCellError } from '../error';
27-
import {
28-
addressToScript,
29-
getTransactionSize,
30-
serializeOutPoint,
31-
serializeWitnessArgs,
32-
} from '@nervosnetwork/ckb-sdk-utils';
27+
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
3328
import { blockchain } from '@ckb-lumos/base';
3429
import { buildBtcTimeUnlockWitness } from '../rgbpp';
3530

31+
const { addressToScript, getTransactionSize, serializeOutPoint, serializeWitnessArgs } = ckbUtils;
32+
3633
/**
3734
* Generate the virtual ckb transaction for leaping spore from BTC to CKB
3835
* @param collector The collector that collects CKB live cells and transactions

0 commit comments

Comments
 (0)