Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemaccana committed Sep 5, 2023
0 parents commit 8976baf
Show file tree
Hide file tree
Showing 9 changed files with 1,497 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# From https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs#using-the-nodejs-starter-workflow
name: Node.js and Solana CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]

steps:
- uses: actions/checkout@v3
# Install Solana
# From https://docs.solana.com/cli/install-solana-cli-tools
- run: sh -c "$(curl -sSfL https://release.solana.com/stable/install)"

- name: Add to PATH
shell: bash
run: |
echo "~/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
# DEBUG
- run: echo "DEBUG"
- run: echo $PATH
- run: ls -la ~/.local/share/solana/install/active_release/bin

# Install everything
- run: npm ci

- name: Check Solana keygn is installed
run: which solana-keygen

# Run tests
- run: npm test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/temp
dist
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Solana node helpers

## getKeypairFromFile

Gets a keypair from a file - the format is the same as [Solana CLI](https://docs.solana.com/wallet-guide/file-system-wallet) uses:

To load the default keypair `~/.config/solana/id.json`, just run:

```
const keyPair = await Keypair.fromFile();
```

or to load a specific file:

```
const keyPair = await Keypair.fromFile('somefile.json');
```

or using home dir expansion:

```
const keyPair = await Keypair.fromFile('~/code/solana/demos/steve.json');
```

## getKeypairFromEnvironment

Gets a keypair from a secret key stored in an environment variable. This is typically used to load secret keys from [env files](https://stackoverflow.com/questions/68267862/what-is-an-env-or-dotenv-file-exactly).

## Development

To run tests

```
npm run test
```

The tests use the [node native test runner](https://blog.logrocket.com/exploring-node-js-native-test-runner/).
Loading

0 comments on commit 8976baf

Please sign in to comment.