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

Commit 80a9bd3

Browse files
committed
refactor: Use tsx instead of ts-node
1 parent 119dfb8 commit 80a9bd3

File tree

13 files changed

+308
-77
lines changed

13 files changed

+308
-77
lines changed

examples/rgbpp/README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ VITE_BTC_SERVICE_ORIGIN=https://btc-test.app
7979
8080
```shell
8181
# Create a CKB empty rgbpp lock cell to launch RGB++ xUDT assets later
82-
npx ts-node xudt/launch/1-prepare-launch.ts
82+
npx tsx xudt/launch/1-prepare-launch.ts
8383
```
8484
#### 2. Launch RGB++ xUDT on BTC
8585

8686
> [!TIP]
8787
> Please make sure the `1-prepare-launch.ts` has been run and the corresponding CKB transaction has been committed.
8888
8989
```shell
90-
npx ts-node xudt/launch/2-launch-rgbpp.ts
90+
npx tsx xudt/launch/2-launch-rgbpp.ts
9191
```
9292

9393
When the command is executed successfully, the **RGB++ Asset type script args** will appear in the output log
@@ -99,27 +99,27 @@ When the command is executed successfully, the **RGB++ Asset type script args**
9999
> The **RGB++ Asset type script args** in the above should be set to the `xudtTypeArgs`.
100100
101101
```shell
102-
npx ts-node xudt/launch/3-distribute-rgbpp.ts
102+
npx tsx xudt/launch/3-distribute-rgbpp.ts
103103
```
104104

105105
### RGB++ xUDT Transfer and Leap
106106

107107
#### 1. Leap xUDT from CKB to BTC
108108

109109
```shell
110-
npx ts-node xudt/1-ckb-leap-btc.ts
110+
npx tsx xudt/1-ckb-leap-btc.ts
111111
```
112112

113113
#### 2. Transfer RGB++ xUDT on BTC with Queue Service
114114

115115
```shell
116-
npx ts-node xudt/2-btc-transfer.ts
116+
npx tsx xudt/2-btc-transfer.ts
117117
```
118118

119119
#### 3. Leap RGB++ xUDT from BTC to CKB with Queue Service
120120

121121
```shell
122-
npx ts-node xudt/3-btc-leap-ckb.ts
122+
npx tsx xudt/3-btc-leap-ckb.ts
123123
```
124124

125125
#### 4. Unlock xUDT BTC time cells on CKB
@@ -131,7 +131,7 @@ However, you can still manually unlock the spore BTC time cell through the follo
131131
Warning: Wait at least 6 BTC confirmation blocks to unlock the BTC time cells after 3-btc-leap-ckb.ts
132132

133133
```shell
134-
npx ts-node xudt/4-unlock-btc-time.ts
134+
npx tsx xudt/4-unlock-btc-time.ts
135135
```
136136

137137
## RGB++ Spore Examples
@@ -146,10 +146,10 @@ npx ts-node xudt/4-unlock-btc-time.ts
146146
147147
```shell
148148
# Create a CKB empty rgbpp lock cell to create cluster later
149-
npx ts-node spore/launch/1-prepare-cluster.ts
149+
npx tsx spore/launch/1-prepare-cluster.ts
150150

151151
# Create a cluster cell with rgbpp lock
152-
npx ts-node spore/launch/2-create-cluster.ts
152+
npx tsx spore/launch/2-create-cluster.ts
153153
```
154154

155155
When the commands are executed successfully, the **clusterId** and **cluster rgbpp lock args** will appear in the output log
@@ -161,21 +161,21 @@ When the commands are executed successfully, the **clusterId** and **cluster rgb
161161
> The **clusterId** in the above should be set to the `clusterId` and the **cluster rgbpp lock args** should be set to the `clusterRgbppLockArgs`.
162162
163163
```shell
164-
npx ts-node spore/launch/3-create-spores.ts
164+
npx tsx spore/launch/3-create-spores.ts
165165
```
166166

167167
### Transfer and Leap Spore
168168

169169
#### 1. Transfer RGB++ Spore on BTC with Queue Service
170170

171171
```shell
172-
npx ts-node spore/4-transfer-spore.ts
172+
npx tsx spore/4-transfer-spore.ts
173173
```
174174

175175
#### 2. Leap RGB++ Spore from BTC to CKB
176176

177177
```shell
178-
npx ts-node spore/5-leap-spore-to-ckb.ts
178+
npx tsx spore/5-leap-spore-to-ckb.ts
179179
```
180180

181181
#### 3. Unlock Spore BTC time cells on CKB
@@ -187,13 +187,13 @@ However, you can still manually unlock the spore BTC time cell through the follo
187187
**Warning: Wait at least 6 BTC confirmation blocks to unlock the BTC time cells after 5-leap-spore-to-ckb.ts**
188188

189189
```shell
190-
npx ts-node spore/6-unlock-btc-time-cell.ts
190+
npx tsx spore/6-unlock-btc-time-cell.ts
191191
```
192192

193193
#### 4. Leap Spore from CKB to BTC
194194

195195
```shell
196-
npx ts-node spore/7-leap-spore-to-btc.ts
196+
npx tsx spore/7-leap-spore-to-btc.ts
197197
```
198198

199199
## FAQ

examples/rgbpp/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
"rgbpp": "workspace:*"
1515
},
1616
"devDependencies": {
17-
"@types/node": "^20.11.28",
18-
"typescript": "^5.4.2",
1917
"dotenv": "^16.4.5",
2018
"@types/dotenv": "^8.2.0"
2119
}

examples/rgbpp/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"target": "ES2015",
55
"lib": ["esnext"],
6-
"module": "NodeNext",
6+
"module": "ES2015",
77
"composite": false,
88
"resolveJsonModule": true,
99
"strictNullChecks": true,
@@ -14,7 +14,7 @@
1414
"forceConsistentCasingInFileNames": true,
1515
"inlineSources": false,
1616
"isolatedModules": true,
17-
"moduleResolution": "NodeNext",
17+
"moduleResolution": "Bundler",
1818
"noUnusedLocals": false,
1919
"noUnusedParameters": false,
2020
"preserveWatchOutput": true,

examples/xudt-on-ckb/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ CKB_INDEXER_URL=https://testnet.ckb.dev/indexer
3030
### Issue xUDT on CKB
3131

3232
```shell
33-
npx ts-node 1-issue-xudt.ts
33+
npx tsx 1-issue-xudt.ts
3434
```
3535

3636
### Mint/Transfer xUDT on CKB
3737

3838
You can use this command to mint or transfer xUDT assets
3939

4040
```shell
41-
npx ts-node 2-transfer-xudt.ts
41+
npx tsx 2-transfer-xudt.ts
4242
```

examples/xudt-on-ckb/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"lint:fix": "tsc && eslint --fix --ext .ts . && prettier --write '**/*.ts'"
1111
},
1212
"dependencies": {
13-
"@nervosnetwork/ckb-sdk-utils": "0.109.2-alpha.1",
14-
"rgbpp": "^0.4.0"
13+
"@nervosnetwork/ckb-sdk-utils": "0.109.2",
14+
"rgbpp": "workspace:*"
1515
},
1616
"devDependencies": {
1717
"dotenv": "^16.4.5",

examples/xudt-on-ckb/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"target": "ES2015",
44
"lib": ["dom", "esnext"],
5-
"module": "NodeNext",
5+
"module": "ES2015",
66
"composite": false,
77
"resolveJsonModule": true,
88
"strictNullChecks": true,
@@ -13,7 +13,7 @@
1313
"forceConsistentCasingInFileNames": true,
1414
"inlineSources": false,
1515
"isolatedModules": true,
16-
"moduleResolution": "NodeNext",
16+
"moduleResolution": "Bundler",
1717
"noUnusedLocals": false,
1818
"noUnusedParameters": false,
1919
"preserveWatchOutput": true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"husky": "^9.0.11",
2929
"lint-staged": "^15.2.2",
3030
"prettier": "^3.2.5",
31-
"ts-node": "^10.9.2",
31+
"tsx": "4.16.3",
3232
"tsup": "^8.1.0",
3333
"typescript": "^5.4.3",
3434
"vitest": "1.6.0"

packages/ckb/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"build": "tsup",
77
"lint": "tsc && eslint --ext .ts {src,example}/* && prettier --check '{src,example}/**/*.{js,ts}'",
88
"lint:fix": "tsc && eslint --fix --ext .ts {src,example}/* && prettier --write '{src,example}/**/*.{js,ts}'",
9-
"splitCells": "npx ts-node example/paymaster.ts"
9+
"splitCells": "npx tsx example/paymaster.ts"
1010
},
1111
"sideEffects": false,
1212
"main": "./dist/index.js",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { encodeRgbppTokenInfo, genBtcTimeLockScript } from './rgbpp';
1313
import { Collector } from '../collector';
1414
import { NoLiveCellError } from '../error';
1515

16+
export { serializeScript };
17+
1618
export const calculateTransactionFee = (txSize: number, feeRate?: bigint): bigint => {
1719
const rate = feeRate ?? BigInt(1100);
1820
const ratio = BigInt(1000);

packages/ckb/tsconfig.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,4 @@
1717
},
1818
"include": ["src"],
1919
"exclude": ["node_modules", "dist", "**/*.spec.ts", "example"],
20-
"ts-node": {
21-
// these options are overrides used only by ts-node
22-
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
23-
"compilerOptions": {
24-
"module": "CommonJS"
25-
}
26-
}
2720
}

0 commit comments

Comments
 (0)