Skip to content

Commit

Permalink
refactor: Use tsx instead of ts-node
Browse files Browse the repository at this point in the history
  • Loading branch information
duanyytop committed Aug 1, 2024
1 parent 119dfb8 commit 80a9bd3
Show file tree
Hide file tree
Showing 13 changed files with 308 additions and 77 deletions.
28 changes: 14 additions & 14 deletions examples/rgbpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ VITE_BTC_SERVICE_ORIGIN=https://btc-test.app
```shell
# Create a CKB empty rgbpp lock cell to launch RGB++ xUDT assets later
npx ts-node xudt/launch/1-prepare-launch.ts
npx tsx xudt/launch/1-prepare-launch.ts
```
#### 2. Launch RGB++ xUDT on BTC

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

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

### RGB++ xUDT Transfer and Leap

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

```shell
npx ts-node xudt/1-ckb-leap-btc.ts
npx tsx xudt/1-ckb-leap-btc.ts
```

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

```shell
npx ts-node xudt/2-btc-transfer.ts
npx tsx xudt/2-btc-transfer.ts
```

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

```shell
npx ts-node xudt/3-btc-leap-ckb.ts
npx tsx xudt/3-btc-leap-ckb.ts
```

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

```shell
npx ts-node xudt/4-unlock-btc-time.ts
npx tsx xudt/4-unlock-btc-time.ts
```

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

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

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

### Transfer and Leap Spore

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

```shell
npx ts-node spore/4-transfer-spore.ts
npx tsx spore/4-transfer-spore.ts
```

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

```shell
npx ts-node spore/5-leap-spore-to-ckb.ts
npx tsx spore/5-leap-spore-to-ckb.ts
```

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

```shell
npx ts-node spore/6-unlock-btc-time-cell.ts
npx tsx spore/6-unlock-btc-time-cell.ts
```

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

```shell
npx ts-node spore/7-leap-spore-to-btc.ts
npx tsx spore/7-leap-spore-to-btc.ts
```

## FAQ
Expand Down
2 changes: 0 additions & 2 deletions examples/rgbpp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"rgbpp": "workspace:*"
},
"devDependencies": {
"@types/node": "^20.11.28",
"typescript": "^5.4.2",
"dotenv": "^16.4.5",
"@types/dotenv": "^8.2.0"
}
Expand Down
4 changes: 2 additions & 2 deletions examples/rgbpp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"target": "ES2015",
"lib": ["esnext"],
"module": "NodeNext",
"module": "ES2015",
"composite": false,
"resolveJsonModule": true,
"strictNullChecks": true,
Expand All @@ -14,7 +14,7 @@
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "NodeNext",
"moduleResolution": "Bundler",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
Expand Down
4 changes: 2 additions & 2 deletions examples/xudt-on-ckb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ CKB_INDEXER_URL=https://testnet.ckb.dev/indexer
### Issue xUDT on CKB

```shell
npx ts-node 1-issue-xudt.ts
npx tsx 1-issue-xudt.ts
```

### Mint/Transfer xUDT on CKB

You can use this command to mint or transfer xUDT assets

```shell
npx ts-node 2-transfer-xudt.ts
npx tsx 2-transfer-xudt.ts
```
4 changes: 2 additions & 2 deletions examples/xudt-on-ckb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"lint:fix": "tsc && eslint --fix --ext .ts . && prettier --write '**/*.ts'"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-utils": "0.109.2-alpha.1",
"rgbpp": "^0.4.0"
"@nervosnetwork/ckb-sdk-utils": "0.109.2",
"rgbpp": "workspace:*"
},
"devDependencies": {
"dotenv": "^16.4.5",
Expand Down
4 changes: 2 additions & 2 deletions examples/xudt-on-ckb/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"target": "ES2015",
"lib": ["dom", "esnext"],
"module": "NodeNext",
"module": "ES2015",
"composite": false,
"resolveJsonModule": true,
"strictNullChecks": true,
Expand All @@ -13,7 +13,7 @@
"forceConsistentCasingInFileNames": true,
"inlineSources": false,
"isolatedModules": true,
"moduleResolution": "NodeNext",
"moduleResolution": "Bundler",
"noUnusedLocals": false,
"noUnusedParameters": false,
"preserveWatchOutput": true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"prettier": "^3.2.5",
"ts-node": "^10.9.2",
"tsx": "4.16.3",
"tsup": "^8.1.0",
"typescript": "^5.4.3",
"vitest": "1.6.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/ckb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "tsup",
"lint": "tsc && eslint --ext .ts {src,example}/* && prettier --check '{src,example}/**/*.{js,ts}'",
"lint:fix": "tsc && eslint --fix --ext .ts {src,example}/* && prettier --write '{src,example}/**/*.{js,ts}'",
"splitCells": "npx ts-node example/paymaster.ts"
"splitCells": "npx tsx example/paymaster.ts"
},
"sideEffects": false,
"main": "./dist/index.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/ckb/src/utils/ckb-tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { encodeRgbppTokenInfo, genBtcTimeLockScript } from './rgbpp';
import { Collector } from '../collector';
import { NoLiveCellError } from '../error';

export { serializeScript };

export const calculateTransactionFee = (txSize: number, feeRate?: bigint): bigint => {
const rate = feeRate ?? BigInt(1100);
const ratio = BigInt(1000);
Expand Down
7 changes: 0 additions & 7 deletions packages/ckb/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,4 @@
},
"include": ["src"],
"exclude": ["node_modules", "dist", "**/*.spec.ts", "example"],
"ts-node": {
// these options are overrides used only by ts-node
// same as the --compilerOptions flag and the TS_NODE_COMPILER_OPTIONS environment variable
"compilerOptions": {
"module": "CommonJS"
}
}
}
Loading

1 comment on commit 80a9bd3

@github-actions
Copy link

Choose a reason for hiding this comment

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

New snapshot version of the rgbpp-sdk packages have been released:

Name Version
@rgbpp-sdk/btc 0.0.0-snap-20240801024204
@rgbpp-sdk/ckb 0.0.0-snap-20240801024204
rgbpp 0.0.0-snap-20240801024204
@rgbpp-sdk/service 0.0.0-snap-20240801024204

Please sign in to comment.