Skip to content

Commit

Permalink
feat: Use tsx for script execution
Browse files Browse the repository at this point in the history
  • Loading branch information
wottpal committed Nov 14, 2023
1 parent 46bb5b5 commit e73d9b8
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 100 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-brooms-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@inkathon/contracts': patch
---

Replace `ts-node` with `tsx` (https://github.com/privatenumber/tsx) for less-verbose TypeScript script execution.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ To replace the default `Greeter` contract or add a new one, you need to do the f

### 3. Custom Scripts

Adding custom scripts is useful to interact with your contracts or test certain functionality. Therefore, just duplicate & reuse the `contracts/scripts/script.template.ts` file and run it via `pnpm run script <script-name>`.
Adding custom scripts is useful to interact with your contracts or test certain functionality. Therefore, just duplicate & reuse the `contracts/scripts/script.template.ts` file and run it via `pnpm run script <script-name>`. This command will run the TypeScript file directly via [`tsx`](https://github.com/privatenumber/tsx).

For general scripts the same environment variable initialization & configuration applies as described below in the [Deployment](#deployment) section (e.g. to change the target network).
For general scripts, the same environment variable initialization & configuration applies as described below in the [Deployment](#deployment) section (e.g. to change the target network).

## The Stack 🥞

Expand Down
5 changes: 2 additions & 3 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"test": "bash test-all.sh",
"build": "bash build-all.sh",
"node": "substrate-contracts-node --dev --base-path ./.node-data",
"script:cwd": "node --no-warnings=ExperimentalWarning --loader ts-node/esm",
"script": "f() { node --no-warnings=ExperimentalWarning --loader ts-node/esm ./scripts/$1; }; f \"$@\"",
"script": "f() { tsx ./scripts/$1; }; f \"$@\"",
"deploy": "pnpm run script deploy",
"contracts-ui": "open https://contracts-ui.substrate.io/?rpc=ws://127.0.0.1:9944",
"explorer-ui": "open https://polkadot.js.org/apps/#/explorer?rpc=ws://127.0.0.1:9944",
Expand All @@ -33,7 +32,7 @@
"dotenv": "^16.3.1",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"ts-node": "^10.9.1",
"tsx": "^4.1.2",
"typescript": "^5.2.2"
}
}
Loading

1 comment on commit e73d9b8

@vercel
Copy link

@vercel vercel bot commented on e73d9b8 Nov 14, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.