Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the typescript toolchain as well #3

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions _internal/_template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@
export SUBSTRATE_API_KEY=ENTER_YOUR_KEY

# Run the TypeScript example

# If using tsx:
cd typescript # Navigate to the typescript example
npm install # Install dependencies
ts-node example.ts # Run the example
npx tsx example.ts # Run the example

# If using Deno:
cd typescript
deno run example.ts

# Run the Python example

# If using Poetry:
cd python # Navigate to the python example
Expand All @@ -20,9 +28,9 @@ poetry run main # Run the example

# If using Rye:
# Update pyproject.toml to switch to Rye.
cd python # Navigate to the python example
rye sync # Install dependencies and build the example
rye run main # Run the example
cd python
rye sync
rye run main
```

</details>
Expand Down
28 changes: 28 additions & 0 deletions _internal/_template/typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Substrate Example Templates in Typescript

This is a Substrate example template written in Typescript. To run this example,

```bash
# Set your API key as an environment variable.
# Get one here https://www.substrate.run/dashboard/keys if this is your first time.
export SUBSTRATE_API_KEY=<your Substrate API key>

# Navigate to the python example directory.
cd typescript
```

To run the example with tsx (default), run the following.

```bash
npx tsx ./example.ts

# Or you can use the package.json scripts
npm run start
```

To run the example with Deno, uncomment the Deno sections in `example.ts` and
run the following.

```bash
deno run ./example.ts
```
6 changes: 4 additions & 2 deletions _internal/_template/typescript/example.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env -S npx ts-node --transpileOnly
import { Substrate, ComputeText } from "substrate";
import { ComputeText, Substrate } from "substrate";

// Uncomment the following line if using Deno
// import process from "node:process";

async function main() {
const apiKey = process.env["SUBSTRATE_API_KEY"] || "YOUR_API_KEY";
Expand Down
Loading