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

Commit cd3f618

Browse files
committed
chore: Upgrade ckb-sdk-js
1 parent 37636bd commit cd3f618

24 files changed

+99
-112
lines changed

.github/workflows/snapshot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
push:
88
branches:
99
- develop
10+
- ref/support-esm
1011

1112
concurrency: ${{ github.workflow }}-${{ github.ref }}
1213

examples/rgbpp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint:fix": "tsc && eslint --fix --ext .js,.ts . && prettier --write '**/*.{js,ts}'"
1111
},
1212
"dependencies": {
13-
"@nervosnetwork/ckb-sdk-utils": "^0.109.1",
13+
"@nervosnetwork/ckb-sdk-utils": "0.109.2-alpha.1",
1414
"rgbpp": "^0.4.0"
1515
},
1616
"devDependencies": {

examples/xudt-on-ckb/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint:fix": "tsc && eslint --fix --ext .ts . && prettier --write '**/*.ts'"
1111
},
1212
"dependencies": {
13-
"@nervosnetwork/ckb-sdk-utils": "^0.109.1",
13+
"@nervosnetwork/ckb-sdk-utils": "0.109.2-alpha.1",
1414
"rgbpp": "^0.4.0"
1515
},
1616
"devDependencies": {

packages/btc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"dependencies": {
3131
"@bitcoinerlab/secp256k1": "^1.1.1",
3232
"@ckb-lumos/codec": "0.22.2",
33-
"@nervosnetwork/ckb-types": "^0.109.1",
33+
"@nervosnetwork/ckb-types": "0.109.2-alpha.1",
3434
"@rgbpp-sdk/ckb": "workspace:^",
3535
"@rgbpp-sdk/service": "workspace:^",
3636
"bip32": "^4.0.0",

packages/ckb/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
"@ckb-lumos/base": "^0.22.2",
3333
"@ckb-lumos/codec": "^0.22.2",
3434
"@spore-sdk/core": "^0.2.0-beta.6",
35-
"@nervosnetwork/ckb-sdk-core": "^0.109.1",
36-
"@nervosnetwork/ckb-sdk-utils": "^0.109.1",
37-
"@nervosnetwork/ckb-types": "^0.109.1",
35+
"@nervosnetwork/ckb-sdk-core": "0.109.2-alpha.1",
36+
"@nervosnetwork/ckb-sdk-utils": "0.109.2-alpha.1",
37+
"@nervosnetwork/ckb-types": "0.109.2-alpha.1",
3838
"@rgbpp-sdk/service": "workspace:^",
3939
"@exact-realty/multipart-parser": "^1.0.13",
4040
"axios": "^1.6.8",

packages/ckb/src/collector/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ export class Collector {
168168

169169
async getLiveCells(outPoints: CKBComponents.OutPoint[], withData = false): Promise<CKBComponents.LiveCell[]> {
170170
const ckb = new CKB(this.ckbNodeUrl);
171-
/* @ts-expect-error The parameters data types of batch request don't support boolean */
172171
const batch = ckb.rpc.createBatchRequest(outPoints.map((outPoint) => ['getLiveCell', outPoint, withData]));
173172
return batch.exec().then((liveCells) => liveCells.map((liveCell) => liveCell.cell));
174173
}

packages/ckb/src/paymaster/index.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import { ConstructPaymasterParams } from '../types/rgbpp';
22
import { NoLiveCellError } from '../error';
33
import { CKB_UNIT, MAX_FEE, SECP256K1_WITNESS_LOCK_SIZE, getSecp256k1CellDep } from '../constants';
4-
import {
5-
append0x,
6-
calculateTransactionFee,
7-
AddressPrefix,
8-
addressToScript,
9-
getTransactionSize,
10-
privateKeyToAddress,
11-
} from '../utils';
4+
import { append0x, calculateTransactionFee } from '../utils';
5+
import { AddressPrefix, addressToScript, getTransactionSize, privateKeyToAddress } from '@nervosnetwork/ckb-sdk-utils';
126

137
const SECP256K1_MIN_CAPACITY = BigInt(61) * CKB_UNIT;
148

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import {
1010
isScriptEqual,
1111
isUDTTypeSupported,
1212
u128ToLe,
13-
addressToScript,
14-
getTransactionSize,
1513
buildPreLockArgs,
1614
calculateCommitment,
1715
throwErrorWhenTxInputsExceeded,
@@ -25,6 +23,7 @@ import {
2523
} from '../utils';
2624
import { Hex, IndexerCell } from '../types';
2725
import { RGBPP_WITNESS_PLACEHOLDER, getSecp256k1CellDep } from '../constants';
26+
import { addressToScript, getTransactionSize } from '@nervosnetwork/ckb-sdk-utils';
2827

2928
/**
3029
* Generate the virtual ckb transaction for the jumping tx from BTC to CKB

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
import {
2+
addressToScript,
3+
bytesToHex,
4+
getTransactionSize,
5+
rawTransactionToHash,
6+
scriptToHash,
7+
serializeOutPoint,
8+
serializeWitnessArgs,
9+
} from '@nervosnetwork/ckb-sdk-utils';
110
import {
211
BTC_JUMP_CONFIRMATION_BLOCKS,
312
SECP256K1_WITNESS_LOCK_SIZE,
@@ -15,13 +24,6 @@ import {
1524
genBtcTimeLockArgs,
1625
lockScriptFromBtcTimeLockArgs,
1726
transformSpvProof,
18-
addressToScript,
19-
bytesToHex,
20-
getTransactionSize,
21-
rawTransactionToHash,
22-
scriptToHash,
23-
serializeOutPoint,
24-
serializeWitnessArgs,
2527
buildSpvClientCellDep,
2628
blockchain,
2729
signWitnesses,

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ import {
1616
isScriptEqual,
1717
isUDTTypeSupported,
1818
u128ToLe,
19-
addressToScript,
20-
getTransactionSize,
21-
rawTransactionToHash,
22-
scriptToHash,
23-
serializeWitnessArgs,
2419
buildPreLockArgs,
2520
calculateCommitment,
2621
compareInputs,
@@ -41,6 +36,13 @@ import {
4136
getRgbppLockScript,
4237
getSecp256k1CellDep,
4338
} from '../constants';
39+
import {
40+
addressToScript,
41+
getTransactionSize,
42+
rawTransactionToHash,
43+
scriptToHash,
44+
serializeWitnessArgs,
45+
} from '@nervosnetwork/ckb-sdk-utils';
4446

4547
/**
4648
* Generate the virtual ckb transaction for the btc transfer tx

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@ import {
1313
replaceLockArgsWithRealBtcTxId,
1414
transformSpvProof,
1515
u8ToHex,
16-
bytesToHex,
17-
getTransactionSize,
18-
rawTransactionToHash,
19-
scriptToHash,
20-
serializeWitnessArgs,
2116
blockchain,
2217
signWitnesses,
2318
} from '../utils';
2419
import { InputsCapacityNotEnoughError } from '../error';
2520
import { buildSpvClientCellDep } from '../utils';
2621
import { RGBPPUnlock, Uint16 } from '../schemas/generated/rgbpp';
22+
import {
23+
bytesToHex,
24+
getTransactionSize,
25+
rawTransactionToHash,
26+
scriptToHash,
27+
serializeWitnessArgs,
28+
} from '@nervosnetwork/ckb-sdk-utils';
2729

2830
export const buildRgbppUnlockWitness = (
2931
btcTxBytes: Hex,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import {
88
fetchTypeIdCellDeps,
99
isTypeAssetSupported,
1010
u128ToLe,
11-
addressToScript,
12-
getTransactionSize,
1311
genRgbppLockScript,
1412
blockchain,
1513
} from '../utils';
1614
import { MAX_FEE, MIN_CAPACITY, RGBPP_TX_WITNESS_MAX_SIZE } from '../constants';
15+
import { addressToScript, getTransactionSize } from '@nervosnetwork/ckb-sdk-utils';
1716

1817
/**
1918
* Generate the virtual ckb transaction for the jumping tx from CKB to BTC

packages/ckb/src/rgbpp/launch.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import {
77
fetchTypeIdCellDeps,
88
generateUniqueTypeArgs,
99
u128ToLe,
10-
getTransactionSize,
11-
scriptToHash,
1210
buildPreLockArgs,
1311
calculateCommitment,
1412
encodeRgbppTokenInfo,
@@ -24,6 +22,7 @@ import {
2422
getUniqueTypeScript,
2523
UNLOCKABLE_LOCK_SCRIPT,
2624
} from '../constants';
25+
import { getTransactionSize, scriptToHash } from '@nervosnetwork/ckb-sdk-utils';
2726

2827
/**
2928
* Generate the virtual ckb transaction for the btc transfer tx

packages/ckb/src/spore/cluster.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import {
44
append0x,
55
calculateTransactionFee,
66
fetchTypeIdCellDeps,
7-
bytesToHex,
8-
getTransactionSize,
97
buildPreLockArgs,
108
calculateCommitment,
119
genRgbppLockScript,
@@ -20,6 +18,7 @@ import {
2018
getClusterTypeScript,
2119
} from '../constants';
2220
import { NoRgbppLiveCellError } from '../error';
21+
import { bytesToHex, getTransactionSize } from '@nervosnetwork/ckb-sdk-utils';
2322

2423
/**
2524
* Generate the virtual ckb transaction for creating cluster

packages/ckb/src/spore/leap.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import {
33
append0x,
44
calculateTransactionFee,
55
fetchTypeIdCellDeps,
6-
addressToScript,
7-
getTransactionSize,
8-
serializeOutPoint,
9-
serializeWitnessArgs,
106
btcTxIdFromBtcTimeLockArgs,
117
buildSpvClientCellDep,
128
calculateCommitment,
@@ -33,6 +29,12 @@ import {
3329
} from '../constants';
3430
import { NoRgbppLiveCellError } from '../error';
3531
import { buildBtcTimeUnlockWitness } from '../rgbpp';
32+
import {
33+
addressToScript,
34+
getTransactionSize,
35+
serializeOutPoint,
36+
serializeWitnessArgs,
37+
} from '@nervosnetwork/ckb-sdk-utils';
3638

3739
/**
3840
* Generate the virtual ckb transaction for leaping spore from BTC to CKB

packages/ckb/src/spore/spore.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import {
66
calculateTransactionFee,
77
fetchTypeIdCellDeps,
88
isClusterSporeTypeSupported,
9-
addressToScript,
10-
bytesToHex,
11-
getTransactionSize,
12-
rawTransactionToHash,
13-
scriptToHash,
14-
serializeWitnessArgs,
159
buildPreLockArgs,
1610
calculateCommitment,
1711
genRgbppLockScript,
@@ -48,6 +42,14 @@ import {
4842
RgbppUtxoBindMultiTypeAssetsError,
4943
TypeAssetNotSupportedError,
5044
} from '../error';
45+
import {
46+
addressToScript,
47+
bytesToHex,
48+
getTransactionSize,
49+
rawTransactionToHash,
50+
scriptToHash,
51+
serializeWitnessArgs,
52+
} from '@nervosnetwork/ckb-sdk-utils';
5153

5254
/**
5355
* Generate the virtual ckb transaction for creating spores

packages/ckb/src/utils/ckb-tx.ts

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
import { calculateTransactionFee as calculateTxFee } from '@nervosnetwork/ckb-sdk-utils/lib/calculateTransactionFee.js';
1+
import {
2+
calculateTransactionFee as calculateTxFee,
3+
PERSONAL,
4+
blake2b,
5+
hexToBytes,
6+
serializeInput,
7+
serializeScript,
8+
} from '@nervosnetwork/ckb-sdk-utils';
29
import { RawClusterData, packRawClusterData, SporeDataProps, packRawSporeData } from '@spore-sdk/core';
3-
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses.js';
4-
import * as ckbUtils from '@nervosnetwork/ckb-sdk-utils';
10+
import signWitnesses from '@nervosnetwork/ckb-sdk-core/lib/signWitnesses';
511
import { remove0x, u64ToLe } from './hex';
612
import {
713
CKB_UNIT,
@@ -16,24 +22,7 @@ import { Collector } from '../collector';
1622
import { NoLiveCellError } from '../error';
1723

1824
export { blockchain } from '@ckb-lumos/base';
19-
export { signWitnesses };
20-
export const {
21-
PERSONAL,
22-
blake2b,
23-
hexToBytes,
24-
serializeInput,
25-
serializeScript,
26-
AddressPrefix,
27-
addressToScript,
28-
privateKeyToAddress,
29-
bytesToHex,
30-
getTransactionSize,
31-
rawTransactionToHash,
32-
scriptToHash,
33-
serializeOutPoint,
34-
serializeOutput,
35-
serializeWitnessArgs,
36-
} = ckbUtils;
25+
export { signWitnesses, serializeScript };
3726

3827
export const calculateTransactionFee = (txSize: number, feeRate?: bigint): bigint => {
3928
const rate = feeRate ?? BigInt(1100);

packages/ckb/src/utils/hex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { hexToBytes, bytesToHex } from './ckb-tx';
1+
import { hexToBytes, bytesToHex } from '@nervosnetwork/ckb-sdk-utils';
22
import { Hex } from '../types';
33

44
export const remove0x = (hex: string): string => {

packages/ckb/src/utils/rgbpp.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@ import {
2121
RgbppCkbTxInputsExceededError,
2222
RgbppUtxoBindMultiTypeAssetsError,
2323
} from '../error';
24+
import { calculateRgbppCellCapacity, isScriptEqual, isUDTTypeSupported, blockchain } from './ckb-tx';
2425
import {
25-
calculateRgbppCellCapacity,
26-
isScriptEqual,
27-
isUDTTypeSupported,
2826
bytesToHex,
2927
hexToBytes,
3028
serializeOutPoint,
3129
serializeOutput,
3230
serializeScript,
33-
blockchain,
34-
} from './ckb-tx';
31+
} from '@nervosnetwork/ckb-sdk-utils';
3532

3633
export const genRgbppLockScript = (rgbppLockArgs: Hex, isMainnet: boolean, btcTestnetType?: BTCTestnetType) => {
3734
return {

packages/ckb/src/utils/spore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
import { u64ToLe } from './hex';
1212
import { Hex, IndexerCell, SporesCreateCobuildParams } from '../types';
1313
import { NoRgbppLiveCellError, RgbppSporeTypeMismatchError, RgbppUtxoBindMultiTypeAssetsError } from '../error';
14-
import { isScriptEqual, isSporeTypeSupported, PERSONAL, blake2b, hexToBytes, serializeInput } from './ckb-tx';
14+
import { isScriptEqual, isSporeTypeSupported } from './ckb-tx';
15+
import { blake2b, hexToBytes, PERSONAL, serializeInput } from '@nervosnetwork/ckb-sdk-utils';
1516

1617
// Generate type id for cluster id
1718
export const generateClusterId = (firstInput: CKBComponents.CellInput, firstOutputIndex: number) => {

packages/rgbpp/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"@rgbpp-sdk/btc": "workspace:*",
6262
"@rgbpp-sdk/ckb": "workspace:*",
6363
"@rgbpp-sdk/service": "workspace:*",
64-
"@nervosnetwork/ckb-sdk-utils": "^0.109.1"
64+
"@nervosnetwork/ckb-sdk-utils": "0.109.2-alpha.1"
6565
},
6666
"publishConfig": {
6767
"access": "public"

packages/service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"dependencies": {
3131
"@ckb-lumos/codec": "0.22.2",
3232
"@ckb-lumos/base": "0.22.2",
33-
"@nervosnetwork/ckb-types": "^0.109.1",
33+
"@nervosnetwork/ckb-types": "0.109.2-alpha.1",
3434
"lodash": "^4.17.21"
3535
},
3636
"publishConfig": {

0 commit comments

Comments
 (0)