wip
This commit is contained in:
parent
6bd8890d83
commit
786d9d65e6
|
@ -46,7 +46,7 @@ pnpm build
|
|||
|
||||
<!-- clientsstop -->
|
||||
|
||||
## Example Programs
|
||||
## Examples
|
||||
|
||||
<!-- examples -->
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ examples:
|
|||
language: "anchor"
|
||||
path: "programs/anchor-feed-parser"
|
||||
- name: "anchor-history-parser"
|
||||
description: "Read a data feeds history buffer and get the closest historical sample to a given timestamp"
|
||||
description:
|
||||
"Read a data feeds history buffer and get the closest historical sample to
|
||||
a given timestamp"
|
||||
language: "anchor"
|
||||
path: "programs/anchor-history-parser"
|
||||
- name: "anchor-vrf-parser"
|
||||
|
@ -21,3 +23,9 @@ examples:
|
|||
description: "Read a Switchboard buffer relayer using Anchor"
|
||||
language: "anchor"
|
||||
path: "programs/anchor-buffer-parser"
|
||||
- name: "javascript-feed-walkthrough"
|
||||
description:
|
||||
"Create a private Switchboard queue and oracle and fulfill your own oracle
|
||||
updates"
|
||||
language: "javascript"
|
||||
path: "javascript/feed-walkthrough"
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<div align="center">
|
||||
|
||||
<!-- commonheader -->
|
||||
|
||||
<!-- commonheaderstop -->
|
||||
|
||||
# Javascript Feed Walkthrough
|
||||
|
||||
> Create a private Switchboard queue and oracle and fulfill your own oracle
|
||||
> updates
|
||||
|
||||
[![Test Status](https://github.com/switchboard-xyz/sbv2-solana/actions/workflows/solana-js-test.yml/badge.svg)](https://github.com/switchboard-xyz/sbv2-solana/actions/workflows/solana-js-test.yml)
|
||||
|
||||
[![Types Badge](https://img.shields.io/badge/types-docs.switchboard.xyz-blue)](https://docs.switchboard.xyz/api/solana.js)
|
||||
|
||||
</div>
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
<!-- usage -->
|
||||
|
||||
<!-- usagestop -->
|
|
@ -0,0 +1,37 @@
|
|||
First install the sbv2 cli
|
||||
|
||||
```bash
|
||||
npm install -g @switchboard-xyz/cli^2
|
||||
```
|
||||
|
||||
Then run the following command to create your own feed using the devnet
|
||||
permissionless queue and crank
|
||||
|
||||
```bash
|
||||
export QUEUE_KEY=uPeRMdfPmrPqgRWSrjAnAkH78RqAhe5kXoW6vBYRqFX
|
||||
export CRANK_KEY=GN9jjCy2THzZxhYqZETmPM3my8vg4R5JyNkgULddUMa5
|
||||
sbv2 solana aggregator create "$QUEUE_KEY" \
|
||||
--keypair ~/.config/solana/id.json \
|
||||
--crankKey "$CRANK_KEY" \
|
||||
--name "My_Test_Feed" \
|
||||
--updateInterval 10 \
|
||||
--minOracles 1 \
|
||||
--batchSize 1 \
|
||||
--leaseAmount 0.1 \
|
||||
--job ./src/oracle-job.json \
|
||||
--verbose
|
||||
```
|
||||
|
||||
Then request an update for your new feed
|
||||
|
||||
```bash
|
||||
sbv2 solana aggregator update $AGGREGATOR_KEY \
|
||||
--keypair ~/.config/solana/id.json
|
||||
```
|
||||
|
||||
See
|
||||
[docs.switchboard.xyz/solana/program/devnet](https://docs.switchboard.xyz/solana/program/devnet)
|
||||
for a list of devnet accounts to use
|
||||
|
||||
**_NOTE:_** You can provide multiple `--job` flags to add additional oracle jobs
|
||||
to your data feed
|
|
@ -0,0 +1,19 @@
|
|||
You can create your own feeds using the devnet permissionless network. This
|
||||
network does _NOT_ require the queue authority to grant you permissions so you
|
||||
are free to use it as a testing environment.
|
||||
|
||||
You do **_NOT_** need to run your own oracles for this network.
|
||||
|
||||
Edit the OracleJob file `src/oracle-job.json`, then run
|
||||
|
||||
```bash
|
||||
ts-node src/devnet
|
||||
```
|
||||
|
||||
Optionally, provide these env variables
|
||||
|
||||
```bash
|
||||
RPC_URL=https://my_custom_rpc_url.com \
|
||||
PAYER_KEYPAIR=~/my_keypair.json \
|
||||
ts-node src/devnet
|
||||
```
|
|
@ -0,0 +1,21 @@
|
|||
You can also create your own private Switchboard network and run your own
|
||||
oracles. This requires you to run your own oracles for this network.
|
||||
|
||||
The following script will
|
||||
|
||||
- Create a private queue and crank
|
||||
- Create a new data feed on this network
|
||||
- Start a local oracle
|
||||
- Call OpenRound and await the updated result from your local oracle
|
||||
|
||||
```bash
|
||||
ts-node src/private-queue
|
||||
```
|
||||
|
||||
Optionally, provide these env variables
|
||||
|
||||
```bash
|
||||
RPC_URL=https://my_custom_rpc_url.com \
|
||||
PAYER_KEYPAIR=~/my_keypair.json \
|
||||
ts-node src/private-queue
|
||||
```
|
|
@ -0,0 +1,13 @@
|
|||
snippets:
|
||||
- name: "Simulate an OracleJob"
|
||||
description: ""
|
||||
filename: "simulate-an-oracle-job.md"
|
||||
- name: "Create a Devnet Feed"
|
||||
description: ""
|
||||
filename: "create-devnet-feed.md"
|
||||
- name: "Create a Private Switchboard Network"
|
||||
description: ""
|
||||
filename: "create-private-network.md"
|
||||
- name: "Create a Feed with the CLI"
|
||||
description: ""
|
||||
filename: "create-a-feed-with-cli.md"
|
|
@ -0,0 +1,5 @@
|
|||
Edit the OracleJob file `src/oracle-job.json`, then run
|
||||
|
||||
```bash
|
||||
ts-node src/simulate
|
||||
```
|
|
@ -8,9 +8,9 @@ snippets:
|
|||
- name: "Add an Oracle"
|
||||
description: ""
|
||||
filename: "add-an-oracle.ts"
|
||||
- name: "Add a Data Feed"
|
||||
- name: "Create a Data Feed"
|
||||
description: ""
|
||||
filename: "add-a-data-feed.ts"
|
||||
filename: "create-a-data-feed.ts"
|
||||
- name: "Request a New Value"
|
||||
description: ""
|
||||
filename: "request-a-new-value.ts"
|
||||
|
@ -18,8 +18,12 @@ snippets:
|
|||
description: "After the oracles respond, read the feed result"
|
||||
filename: "read-data-feed.ts"
|
||||
- name: "Add a History Buffer"
|
||||
description: "Optionally, add a history buffer to your feed to store the last N historical samples"
|
||||
description:
|
||||
"Optionally, add a history buffer to your feed to store the last N
|
||||
historical samples"
|
||||
filename: "add-history-buffer.ts"
|
||||
- name: "Watch Data Feed"
|
||||
description: "Setup a websocket listener to invoke a callback whenever an aggregator is updated"
|
||||
filename: "watch-data-feed.ts"
|
||||
description:
|
||||
"Setup a websocket listener to invoke a callback whenever an aggregator is
|
||||
updated"
|
||||
filename: "watch-data-feed.ts"
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- install -->
|
||||
|
||||
<!-- installstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
Build the example program
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- install -->
|
||||
|
||||
<!-- installstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
Build the example program
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- install -->
|
||||
|
||||
<!-- installstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
Build the example program
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- install -->
|
||||
|
||||
<!-- installstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
Build the example program
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- install -->
|
||||
|
||||
<!-- installstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
Build the example program
|
||||
|
|
17
README.md
17
README.md
|
@ -63,15 +63,16 @@ The following addresses can be used with the Switchboard deployment on Solana
|
|||
| Rust | [switchboard-v2](rust/switchboard-v2) | A Rust library to interact with Switchboard V2 accounts on Solana. |
|
||||
| Javascript | [@switchboard-xyz/solana.js](javascript/solana.js) | A Typescript client to interact with Switchboard on Solana. |
|
||||
|
||||
## Example Programs
|
||||
## Examples
|
||||
|
||||
| **Lang** | **Name** | **Description** |
|
||||
| -------- | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| Rust | [native-feed-parser](programs/native-feed-parser) | Read a Switchboard feed using Solana's native program library |
|
||||
| Anchor | [anchor-feed-parser](programs/anchor-feed-parser) | Read a Switchboard feed using Anchor |
|
||||
| Anchor | [anchor-history-parser](programs/anchor-history-parser) | Read a data feeds history buffer and get the closest historical sample to a given timestamp |
|
||||
| Anchor | [anchor-vrf-parser](programs/anchor-vrf-parser) | Read a Switchboard VRF account and make a Cross Program Invocation (CPI) to request a new randomness value |
|
||||
| Anchor | [anchor-buffer-parser](programs/anchor-buffer-parser) | Read a Switchboard buffer relayer using Anchor |
|
||||
| **Lang** | **Name** | **Description** |
|
||||
| ---------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| Rust | [native-feed-parser](programs/native-feed-parser) | Read a Switchboard feed using Solana's native program library |
|
||||
| Anchor | [anchor-feed-parser](programs/anchor-feed-parser) | Read a Switchboard feed using Anchor |
|
||||
| Anchor | [anchor-history-parser](programs/anchor-history-parser) | Read a data feeds history buffer and get the closest historical sample to a given timestamp |
|
||||
| Anchor | [anchor-vrf-parser](programs/anchor-vrf-parser) | Read a Switchboard VRF account and make a Cross Program Invocation (CPI) to request a new randomness value |
|
||||
| Anchor | [anchor-buffer-parser](programs/anchor-buffer-parser) | Read a Switchboard buffer relayer using Anchor |
|
||||
| Javascript | [javascript-feed-walkthrough](javascript/feed-walkthrough) | Create a private Switchboard queue and oracle and fulfill your own oracle updates |
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
|
|
@ -1,30 +1,16 @@
|
|||
<div align="center">
|
||||
<a href="#">
|
||||
<img src="https://github.com/switchboard-xyz/sbv2-core/raw/main/website/static/img/icons/switchboard/avatar.png" />
|
||||
</a>
|
||||
|
||||
<h1>Sbv2 Feed Walkthrough</h1>
|
||||
![Switchboard Logo](https://github.com/switchboard-xyz/sbv2-core/raw/main/website/static/img/icons/switchboard/avatar.png)
|
||||
|
||||
<p>An example showing how to create your own feed using Switchboard.</p>
|
||||
# Javascript Feed Walkthrough
|
||||
|
||||
<p>
|
||||
<a href="https://discord.gg/switchboardxyz">
|
||||
<img alt="Discord" src="https://img.shields.io/discord/841525135311634443?color=blueviolet&logo=discord&logoColor=white" />
|
||||
</a>
|
||||
<a href="https://twitter.com/switchboardxyz">
|
||||
<img alt="Twitter" src="https://img.shields.io/twitter/follow/switchboardxyz?label=Follow+Switchboard" />
|
||||
</a>
|
||||
</p>
|
||||
> Create a private Switchboard queue and oracle and fulfill your own oracle
|
||||
> updates
|
||||
|
||||
[![Test Status](https://github.com/switchboard-xyz/sbv2-solana/actions/workflows/solana-js-test.yml/badge.svg)](https://github.com/switchboard-xyz/sbv2-solana/actions/workflows/solana-js-test.yml)
|
||||
|
||||
[![Types Badge](https://img.shields.io/badge/types-docs.switchboard.xyz-blue)](https://docs.switchboard.xyz/api/solana.js)
|
||||
|
||||
<h4>
|
||||
<strong>Npm: </strong><a href="https://www.npmjs.com/package/@switchboard-xyz/solana.js">npmjs.com/package/@switchboard-xyz/solana.js</a>
|
||||
</h4>
|
||||
<h4>
|
||||
<strong>Typedocs: </strong><a href="https://docs.switchboard.xyz/api/@switchboard-xyz/solana.js">docs.switchboard.xyz/api/@switchboard-xyz/solana.js</a>
|
||||
</h4>
|
||||
<h4>
|
||||
<strong>Sbv2 Solana SDK: </strong><a href="https://github.com/switchboard-xyz/sbv2-solana">github.com/switchboard-xyz/sbv2-solana</a>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
## Install
|
||||
|
@ -35,6 +21,13 @@ npm i
|
|||
|
||||
## Usage
|
||||
|
||||
**Directory**
|
||||
|
||||
- [Simulate an OracleJob](#simulate-an-oraclejob)
|
||||
- [Create a Devnet Feed](#create-a-devnet-feed)
|
||||
- [Create a Private Switchboard Network](#create-a-private-switchboard-network)
|
||||
- [Create a Feed with the CLI](#create-a-feed-with-the-cli)
|
||||
|
||||
### Simulate an OracleJob
|
||||
|
||||
Edit the OracleJob file `src/oracle-job.json`, then run
|
||||
|
@ -43,7 +36,7 @@ Edit the OracleJob file `src/oracle-job.json`, then run
|
|||
ts-node src/simulate
|
||||
```
|
||||
|
||||
### Create a Feed on Devnet
|
||||
### Create a Devnet Feed
|
||||
|
||||
You can create your own feeds using the devnet permissionless network. This
|
||||
network does _NOT_ require the queue authority to grant you permissions so you
|
||||
|
@ -65,7 +58,7 @@ PAYER_KEYPAIR=~/my_keypair.json \
|
|||
ts-node src/devnet
|
||||
```
|
||||
|
||||
### Create a Private Queue and Oracle
|
||||
### Create a Private Switchboard Network
|
||||
|
||||
You can also create your own private Switchboard network and run your own
|
||||
oracles. This requires you to run your own oracles for this network.
|
||||
|
|
|
@ -27,7 +27,7 @@ npm i --save @switchboard-xyz/solana.js
|
|||
- [Load Switchboard Program](#load-switchboard-program)
|
||||
- [Create a Queue](#create-a-queue)
|
||||
- [Add an Oracle](#add-an-oracle)
|
||||
- [Add a Data Feed](#add-a-data-feed)
|
||||
- [Create a Data Feed](#create-a-data-feed)
|
||||
- [Request a New Value](#request-a-new-value)
|
||||
- [Read a Data Feed](#read-a-data-feed)
|
||||
- [Add a History Buffer](#add-a-history-buffer)
|
||||
|
@ -86,7 +86,7 @@ const oracle = await oracleAccount.loadData();
|
|||
await oracleAccount.heartbeat();
|
||||
```
|
||||
|
||||
### Add a Data Feed
|
||||
### Create a Data Feed
|
||||
|
||||
```ts
|
||||
import { QueueAccount } from '@switchboard-xyz/solana.js';
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- install -->
|
||||
|
||||
<!-- installstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
Build the example program
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- install -->
|
||||
|
||||
<!-- installstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
Build the example program
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- install -->
|
||||
|
||||
<!-- installstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
Build the example program
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- install -->
|
||||
|
||||
<!-- installstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
Build the example program
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
|
||||
</div>
|
||||
|
||||
<!-- install -->
|
||||
|
||||
<!-- installstop -->
|
||||
|
||||
## Usage
|
||||
|
||||
Build the example program
|
||||
|
|
Loading…
Reference in New Issue