Skip to content

Commit

Permalink
create readme template
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Campolo committed Oct 7, 2022
1 parent a1cb585 commit f90e912
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
58 changes: 58 additions & 0 deletions TEMPLATE_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Instructions (Delete this section after completing)

When creating a new example, copy the contents of this template into a new `README.md` file in the example directory and fill in the required pieces of information. All example `README` files should include the following:

- [ ] `INSERT_TITLE`
- [ ] `INSERT_GUIDE_NAME`
- [ ] `INSERT_GUIDE_LINK`
- [ ] `INSERT_AUTHOR`
- [ ] `INSERT_CHAIN`
- [ ] `INSERT_PROJECT`

After that some sections may or may not be applicable depending on the given project. Make sure to delete any unnecessary sections.

- [ ] `ENVIRONMENT VARIABLES` - Not all projects will include environment variables but we highly recommend setting up your project to use them with something like `dotenv` if secrets are included in the code (for example an endpoint or private key).
- [ ] `DEPENDENCIES` - Some projects will not require installing dependencies.
- [ ] `SCRIPT` - Not all projects will have a script to run.
- [ ] `START` - However, if a Node script is included we recommend following the `start` naming convention when possible.
- [ ] `PACKAGE MANAGERS` - We recommend doing your best to support the main three package managers, `npm`, `yarn`, and `pnpm` when possible:
- [ ] `YARN` - Include a blank `.yarnrc.yml` file to prevent Yarn 3 from breaking. We recommend example maintainers use Yarn 1 when testing projects on their local machine.
- [ ] `PNPM` - Include a `.npmrc` file with `auto-install-peers=true` and `strict-peer-dependencies=false` to prevent `pnpm` from breaking.
- [ ] `TYPESCRIPT` - Make sure to create a `tsconfig.json` file and install the following development dependencies when using TypeScript: `@types/node`, `ts-node`, `typescript`.

# INSERT_TITLE

This project is based on the guide, [INSERT_GUIDE_NAME](INSERT_GUIDE_LINK) by INSERT_AUTHOR.

## Clone Example Monorepo

To begin, clone the `qn-guide-examples` repo and navigate to this project's directory.

```bash
git clone https://github.com/quiknode-labs/qn-guide-examples.git
cd qn-guide-examples/INSERT_CHAIN/INSERT_PROJECT
```

## Add Environment Variables

```bash
cp .env.example .env
```

## Install Dependencies

Either `npm`, `yarn`, or `pnpm` can be used to install the project's dependencies.

```bash
npm i
yarn
pnpm i
```

## Run Script

```bash
npm start
yarn start
pnpm start
```
8 changes: 5 additions & 3 deletions solana/sns-domains/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { Connection, PublicKey } from "@solana/web3.js"
import { getDomainKey, NameRegistryState, getAllDomains, performReverseLookup } from "@bonfida/spl-name-service"
import "dotenv/config"

const SOLANA_CONNECTION = new Connection(process.env.QUICKNODE_RPC_ENDPOINT as string)
const { QUICKNODE_RPC_ENDPOINT } = process.env

async function getPublicKeyFromSolDomain(domain: string):Promise<string>{
const SOLANA_CONNECTION = new Connection(QUICKNODE_RPC_ENDPOINT as string)

async function getPublicKeyFromSolDomain(domain: string): Promise<string>{
const { pubkey } = await getDomainKey(domain)
const owner = (await NameRegistryState.retrieve(
SOLANA_CONNECTION, pubkey
Expand All @@ -13,7 +15,7 @@ async function getPublicKeyFromSolDomain(domain: string):Promise<string>{
return owner
}

async function getSolDomainsFromPublicKey(wallet: string):Promise<string[]>{
async function getSolDomainsFromPublicKey(wallet: string): Promise<string[]>{
const ownerWallet = new PublicKey(wallet)
const allDomainKeys = await getAllDomains(SOLANA_CONNECTION, ownerWallet)
const allDomainNames = await Promise.all(
Expand Down
6 changes: 4 additions & 2 deletions solana/sol-get-tokens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { Connection, GetProgramAccountsFilter } from "@solana/web3.js"
import { TOKEN_PROGRAM_ID } from "@solana/spl-token"
import 'dotenv/config'

const solanaConnection = new Connection(process.env.QUICKNODE_RPC_ENDPOINT as string)
const walletToQuery = process.env.WALLET_PUBLIC_KEY as string // example: vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg
const { QUICKNODE_RPC_ENDPOINT, WALLET_PUBLIC_KEY } = process.env

const solanaConnection = new Connection(QUICKNODE_RPC_ENDPOINT as string)
const walletToQuery = WALLET_PUBLIC_KEY as string // example: vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg

async function getTokenAccounts(wallet: string, solanaConnection: Connection) {
const filters:GetProgramAccountsFilter[] = [
Expand Down

0 comments on commit f90e912

Please sign in to comment.