program testing cleanup fix
This commit is contained in:
parent
391dd07f08
commit
94fbb8440b
136
cli/README.md
136
cli/README.md
|
@ -122,7 +122,7 @@ EXAMPLE
|
|||
$ sbv2 aggregator:add:job
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/add/job.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/add/job.ts)_
|
||||
_See code: [src/commands/aggregator/add/job.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/add/job.ts)_
|
||||
|
||||
## `sbv2 aggregator:create:copy AGGREGATORSOURCE`
|
||||
|
||||
|
@ -182,7 +182,7 @@ EXAMPLES
|
|||
9WZ59yz95bd3XwJxDPVE2PjvVWmSy9WM1NgGD2Hqsohw --keypair ../payer-keypair.json --sourceCluster mainnet-beta
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/create/copy.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/create/copy.ts)_
|
||||
_See code: [src/commands/aggregator/create/copy.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/create/copy.ts)_
|
||||
|
||||
## `sbv2 aggregator:create:json DEFINITIONFILE`
|
||||
|
||||
|
@ -225,7 +225,7 @@ EXAMPLE
|
|||
GhYg3R1V6DmJbwuc57qZeoYG6gUuvCotUF1zU3WCj98U --outputFile aggregator.schema.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/create/json.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/create/json.ts)_
|
||||
_See code: [src/commands/aggregator/create/json.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/create/json.ts)_
|
||||
|
||||
## `sbv2 aggregator:lock AGGREGATORKEY`
|
||||
|
||||
|
@ -256,7 +256,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/lock.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/lock.ts)_
|
||||
_See code: [src/commands/aggregator/lock.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/lock.ts)_
|
||||
|
||||
## `sbv2 aggregator:permission:create AGGREGATORKEY`
|
||||
|
||||
|
@ -286,7 +286,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/permission/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/permission/create.ts)_
|
||||
_See code: [src/commands/aggregator/permission/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/permission/create.ts)_
|
||||
|
||||
## `sbv2 aggregator:remove:job AGGREGATORKEY JOBKEY`
|
||||
|
||||
|
@ -323,7 +323,7 @@ EXAMPLE
|
|||
$ sbv2 aggregator:remove:job
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/remove/job.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/remove/job.ts)_
|
||||
_See code: [src/commands/aggregator/remove/job.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/remove/job.ts)_
|
||||
|
||||
## `sbv2 aggregator:set AGGREGATORKEY`
|
||||
|
||||
|
@ -376,7 +376,7 @@ EXAMPLE
|
|||
../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/set/index.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/set/index.ts)_
|
||||
_See code: [src/commands/aggregator/set/index.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/set/index.ts)_
|
||||
|
||||
## `sbv2 aggregator:set:authority AGGREGATORKEY NEWAUTHORITY`
|
||||
|
||||
|
@ -408,7 +408,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/set/authority.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/set/authority.ts)_
|
||||
_See code: [src/commands/aggregator/set/authority.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/set/authority.ts)_
|
||||
|
||||
## `sbv2 aggregator:set:batchSize AGGREGATORKEY BATCHSIZE`
|
||||
|
||||
|
@ -440,7 +440,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/set/batchSize.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/set/batchSize.ts)_
|
||||
_See code: [src/commands/aggregator/set/batchSize.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/set/batchSize.ts)_
|
||||
|
||||
## `sbv2 aggregator:set:forceReportPeriod AGGREGATORKEY FORCEREPORTPERIOD`
|
||||
|
||||
|
@ -481,7 +481,7 @@ EXAMPLE
|
|||
../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/set/forceReportPeriod.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/set/forceReportPeriod.ts)_
|
||||
_See code: [src/commands/aggregator/set/forceReportPeriod.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/set/forceReportPeriod.ts)_
|
||||
|
||||
## `sbv2 aggregator:set:history AGGREGATORKEY SIZE`
|
||||
|
||||
|
@ -519,7 +519,7 @@ EXAMPLE
|
|||
$ sbv2 aggregator:set:history GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR 10000 --keypair ../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/set/history.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/set/history.ts)_
|
||||
_See code: [src/commands/aggregator/set/history.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/set/history.ts)_
|
||||
|
||||
## `sbv2 aggregator:set:minJobs AGGREGATORKEY MINJOBRESULTS`
|
||||
|
||||
|
@ -551,7 +551,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/set/minJobs.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/set/minJobs.ts)_
|
||||
_See code: [src/commands/aggregator/set/minJobs.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/set/minJobs.ts)_
|
||||
|
||||
## `sbv2 aggregator:set:minOracles AGGREGATORKEY MINORACLERESULTS`
|
||||
|
||||
|
@ -583,7 +583,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/set/minOracles.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/set/minOracles.ts)_
|
||||
_See code: [src/commands/aggregator/set/minOracles.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/set/minOracles.ts)_
|
||||
|
||||
## `sbv2 aggregator:set:queue AGGREGATORKEY QUEUEKEY`
|
||||
|
||||
|
@ -615,7 +615,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/set/queue.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/set/queue.ts)_
|
||||
_See code: [src/commands/aggregator/set/queue.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/set/queue.ts)_
|
||||
|
||||
## `sbv2 aggregator:set:updateInterval AGGREGATORKEY UPDATEINTERVAL`
|
||||
|
||||
|
@ -650,7 +650,7 @@ EXAMPLE
|
|||
$ sbv2 aggregator:set:updateInterval GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR 60 --keypair ../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/set/updateInterval.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/set/updateInterval.ts)_
|
||||
_See code: [src/commands/aggregator/set/updateInterval.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/set/updateInterval.ts)_
|
||||
|
||||
## `sbv2 aggregator:set:varianceThreshold AGGREGATORKEY VARIANCETHRESHOLD`
|
||||
|
||||
|
@ -691,7 +691,7 @@ EXAMPLE
|
|||
../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/set/varianceThreshold.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/set/varianceThreshold.ts)_
|
||||
_See code: [src/commands/aggregator/set/varianceThreshold.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/set/varianceThreshold.ts)_
|
||||
|
||||
## `sbv2 aggregator:update AGGREGATORKEY`
|
||||
|
||||
|
@ -724,7 +724,7 @@ EXAMPLE
|
|||
$ sbv2 aggregator:update J7j9xX8JP2B2ErvUzuqGAKBGeggsxPyFXj5MqZcYDxfa --keypair ../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/aggregator/update.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/aggregator/update.ts)_
|
||||
_See code: [src/commands/aggregator/update.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/aggregator/update.ts)_
|
||||
|
||||
## `sbv2 config:print`
|
||||
|
||||
|
@ -754,7 +754,7 @@ EXAMPLE
|
|||
$ sbv2 config:print
|
||||
```
|
||||
|
||||
_See code: [src/commands/config/print.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/config/print.ts)_
|
||||
_See code: [src/commands/config/print.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/config/print.ts)_
|
||||
|
||||
## `sbv2 config:set PARAM [VALUE]`
|
||||
|
||||
|
@ -787,7 +787,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/config/set.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/config/set.ts)_
|
||||
_See code: [src/commands/config/set.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/config/set.ts)_
|
||||
|
||||
## `sbv2 crank:list CRANKKEY`
|
||||
|
||||
|
@ -820,7 +820,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/crank/list.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/crank/list.ts)_
|
||||
_See code: [src/commands/crank/list.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/crank/list.ts)_
|
||||
|
||||
## `sbv2 crank:push CRANKKEY AGGREGATORKEY`
|
||||
|
||||
|
@ -855,7 +855,7 @@ ALIASES
|
|||
$ sbv2 crank:add:aggregator
|
||||
```
|
||||
|
||||
_See code: [src/commands/crank/push.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/crank/push.ts)_
|
||||
_See code: [src/commands/crank/push.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/crank/push.ts)_
|
||||
|
||||
## `sbv2 crank:turn CRANKKEY`
|
||||
|
||||
|
@ -888,7 +888,7 @@ EXAMPLE
|
|||
$ sbv2 crank:turn 85L2cFUvXaeGQ4HrzP8RJEVCL7WvRrXM2msvEmQ82AVr --keypair ../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/crank/turn.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/crank/turn.ts)_
|
||||
_See code: [src/commands/crank/turn.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/crank/turn.ts)_
|
||||
|
||||
## `sbv2 help [COMMAND]`
|
||||
|
||||
|
@ -941,7 +941,7 @@ EXAMPLE
|
|||
$ sbv2 job:create:copy 7pdb5RVM6cVBU8XDfpGqakb1S4wX2i5QsZxT117tK4HS --keypair ../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/job/create/copy.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/job/create/copy.ts)_
|
||||
_See code: [src/commands/job/create/copy.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/job/create/copy.ts)_
|
||||
|
||||
## `sbv2 job:create:json DEFINITIONFILE`
|
||||
|
||||
|
@ -986,7 +986,7 @@ EXAMPLE
|
|||
--aggregatorAuthority=../aggregator-keypair.json --outputFile=job.schema.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/job/create/json.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/job/create/json.ts)_
|
||||
_See code: [src/commands/job/create/json.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/job/create/json.ts)_
|
||||
|
||||
## `sbv2 job:create:template TEMPLATE ID`
|
||||
|
||||
|
@ -1032,7 +1032,7 @@ EXAMPLES
|
|||
$ sbv2 job:create:template ftxUs BTC_USD -k ../payer-keypair.json -n ftxUs_Btc -f ftx_us_btc_job.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/job/create/template.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/job/create/template.ts)_
|
||||
_See code: [src/commands/job/create/template.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/job/create/template.ts)_
|
||||
|
||||
## `sbv2 json:add:aggregator`
|
||||
|
||||
|
@ -1065,7 +1065,7 @@ OPTIONS
|
|||
--sourceAggregator=sourceAggregator public key of an existing aggregator account to copy
|
||||
```
|
||||
|
||||
_See code: [src/commands/json/add/aggregator.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/json/add/aggregator.ts)_
|
||||
_See code: [src/commands/json/add/aggregator.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/json/add/aggregator.ts)_
|
||||
|
||||
## `sbv2 json:add:crank SCHEMAFILE`
|
||||
|
||||
|
@ -1100,7 +1100,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/json/add/crank.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/json/add/crank.ts)_
|
||||
_See code: [src/commands/json/add/crank.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/json/add/crank.ts)_
|
||||
|
||||
## `sbv2 json:add:oracle SCHEMAFILE`
|
||||
|
||||
|
@ -1133,7 +1133,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/json/add/oracle.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/json/add/oracle.ts)_
|
||||
_See code: [src/commands/json/add/oracle.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/json/add/oracle.ts)_
|
||||
|
||||
## `sbv2 json:create:queue INPUTFILE OUTPUTFILE`
|
||||
|
||||
|
@ -1174,7 +1174,7 @@ EXAMPLE
|
|||
$ sbv2 json:create:queue examples/queue.json queue-1.json -k ../authority-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/json/create/queue.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/json/create/queue.ts)_
|
||||
_See code: [src/commands/json/create/queue.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/json/create/queue.ts)_
|
||||
|
||||
## `sbv2 lease:create AGGREGATORKEY`
|
||||
|
||||
|
@ -1213,7 +1213,7 @@ EXAMPLE
|
|||
$ sbv2 lease:create GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR --amount 1.5 --keypair ../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/lease/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/lease/create.ts)_
|
||||
_See code: [src/commands/lease/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/lease/create.ts)_
|
||||
|
||||
## `sbv2 lease:extend AGGREGATORKEY`
|
||||
|
||||
|
@ -1253,7 +1253,7 @@ EXAMPLE
|
|||
../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/lease/extend.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/lease/extend.ts)_
|
||||
_See code: [src/commands/lease/extend.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/lease/extend.ts)_
|
||||
|
||||
## `sbv2 lease:withdraw AGGREGATORKEY`
|
||||
|
||||
|
@ -1297,7 +1297,7 @@ EXAMPLE
|
|||
../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/lease/withdraw.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/lease/withdraw.ts)_
|
||||
_See code: [src/commands/lease/withdraw.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/lease/withdraw.ts)_
|
||||
|
||||
## `sbv2 localnet:env`
|
||||
|
||||
|
@ -1328,7 +1328,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/localnet/env.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/localnet/env.ts)_
|
||||
_See code: [src/commands/localnet/env.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/localnet/env.ts)_
|
||||
|
||||
## `sbv2 oracle:balance ORACLEKEY`
|
||||
|
||||
|
@ -1361,7 +1361,7 @@ EXAMPLE
|
|||
$ sbv2 oracle:balance 9CmLriMhykZ8xAoNTSHjHbk6SkuMhie1NCZn9P6LCuZ4
|
||||
```
|
||||
|
||||
_See code: [src/commands/oracle/balance.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/oracle/balance.ts)_
|
||||
_See code: [src/commands/oracle/balance.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/oracle/balance.ts)_
|
||||
|
||||
## `sbv2 oracle:create QUEUEKEY`
|
||||
|
||||
|
@ -1405,7 +1405,7 @@ EXAMPLES
|
|||
../oracle-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/oracle/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/oracle/create.ts)_
|
||||
_See code: [src/commands/oracle/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/oracle/create.ts)_
|
||||
|
||||
## `sbv2 oracle:deposit ORACLEKEY`
|
||||
|
||||
|
@ -1441,7 +1441,7 @@ EXAMPLE
|
|||
$ sbv2 oracle:deposit 6kPsQoufdugtHLjM4fH7Z2fNv7jLt5pgvwKHt5JvRhQ6 2500 --keypair ../payer-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/oracle/deposit.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/oracle/deposit.ts)_
|
||||
_See code: [src/commands/oracle/deposit.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/oracle/deposit.ts)_
|
||||
|
||||
## `sbv2 oracle:nonce ORACLEKEY`
|
||||
|
||||
|
@ -1471,7 +1471,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/oracle/nonce/index.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/oracle/nonce/index.ts)_
|
||||
_See code: [src/commands/oracle/nonce/index.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/oracle/nonce/index.ts)_
|
||||
|
||||
## `sbv2 oracle:permission:create ORACLEKEY`
|
||||
|
||||
|
@ -1501,7 +1501,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/oracle/permission/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/oracle/permission/create.ts)_
|
||||
_See code: [src/commands/oracle/permission/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/oracle/permission/create.ts)_
|
||||
|
||||
## `sbv2 oracle:withdraw ORACLEKEY`
|
||||
|
||||
|
@ -1544,7 +1544,7 @@ EXAMPLES
|
|||
../oracle-keypair.json -w ByJs8E29jxvqf2KFLwfyiE2gUh5fivaS7aShcRMAsnzg
|
||||
```
|
||||
|
||||
_See code: [src/commands/oracle/withdraw.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/oracle/withdraw.ts)_
|
||||
_See code: [src/commands/oracle/withdraw.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/oracle/withdraw.ts)_
|
||||
|
||||
## `sbv2 permission:create GRANTER GRANTEE`
|
||||
|
||||
|
@ -1575,7 +1575,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/permission/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/permission/create.ts)_
|
||||
_See code: [src/commands/permission/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/permission/create.ts)_
|
||||
|
||||
## `sbv2 permission:set PERMISSIONKEY`
|
||||
|
||||
|
@ -1608,7 +1608,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/permission/set.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/permission/set.ts)_
|
||||
_See code: [src/commands/permission/set.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/permission/set.ts)_
|
||||
|
||||
## `sbv2 print PUBLICKEY`
|
||||
|
||||
|
@ -1629,7 +1629,7 @@ EXAMPLE
|
|||
$ sbv2 print GhYg3R1V6DmJbwuc57qZeoYG6gUuvCotUF1zU3WCj98U
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/index.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/index.ts)_
|
||||
_See code: [src/commands/print/index.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/index.ts)_
|
||||
|
||||
## `sbv2 print:aggregator AGGREGATORKEY`
|
||||
|
||||
|
@ -1669,7 +1669,7 @@ EXAMPLE
|
|||
$ sbv2 aggregator:print GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/aggregator.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/aggregator.ts)_
|
||||
_See code: [src/commands/print/aggregator.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/aggregator.ts)_
|
||||
|
||||
## `sbv2 print:aggregator:history AGGREGATORKEY`
|
||||
|
||||
|
@ -1706,7 +1706,7 @@ EXAMPLE
|
|||
$ sbv2 aggregator:print:history 9CmLriMhykZ8xAoNTSHjHbk6SkuMhie1NCZn9P6LCuZ4
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/aggregator/history.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/aggregator/history.ts)_
|
||||
_See code: [src/commands/print/aggregator/history.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/aggregator/history.ts)_
|
||||
|
||||
## `sbv2 print:aggregator:lease AGGREGATORKEY`
|
||||
|
||||
|
@ -1743,7 +1743,7 @@ EXAMPLE
|
|||
$ sbv2 aggregator:lease:print 8SXvChNYFhRq4EZuZvnhjrB3jJRQCv4k3P4W6hesH3Ee
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/aggregator/lease.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/aggregator/lease.ts)_
|
||||
_See code: [src/commands/print/aggregator/lease.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/aggregator/lease.ts)_
|
||||
|
||||
## `sbv2 print:aggregator:permission AGGREGATORKEY`
|
||||
|
||||
|
@ -1780,7 +1780,7 @@ EXAMPLE
|
|||
$ sbv2 aggregator:permission:print 9CmLriMhykZ8xAoNTSHjHbk6SkuMhie1NCZn9P6LCuZ4
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/aggregator/permission.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/aggregator/permission.ts)_
|
||||
_See code: [src/commands/print/aggregator/permission.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/aggregator/permission.ts)_
|
||||
|
||||
## `sbv2 print:crank CRANKKEY`
|
||||
|
||||
|
@ -1816,7 +1816,7 @@ EXAMPLE
|
|||
$ sbv2 crank:print 85L2cFUvXaeGQ4HrzP8RJEVCL7WvRrXM2msvEmQ82AVr
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/crank.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/crank.ts)_
|
||||
_See code: [src/commands/print/crank.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/crank.ts)_
|
||||
|
||||
## `sbv2 print:job JOBKEY`
|
||||
|
||||
|
@ -1852,7 +1852,7 @@ EXAMPLE
|
|||
$ sbv2 job:print SzTvFZLz3hwjZFMwVWzuEnr1oUF6qyvXwXCvsqf7qeA
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/job.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/job.ts)_
|
||||
_See code: [src/commands/print/job.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/job.ts)_
|
||||
|
||||
## `sbv2 print:job:templates`
|
||||
|
||||
|
@ -1866,7 +1866,7 @@ ALIASES
|
|||
$ sbv2 job:print:templates
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/job/templates.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/job/templates.ts)_
|
||||
_See code: [src/commands/print/job/templates.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/job/templates.ts)_
|
||||
|
||||
## `sbv2 print:json:samples OUTPUTDIRECTORY`
|
||||
|
||||
|
@ -1905,7 +1905,7 @@ EXAMPLES
|
|||
$ sbv2 write:json:samples ~/switchboard_json_samples
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/json/samples.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/json/samples.ts)_
|
||||
_See code: [src/commands/print/json/samples.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/json/samples.ts)_
|
||||
|
||||
## `sbv2 print:oracle ORACLEKEY`
|
||||
|
||||
|
@ -1941,7 +1941,7 @@ EXAMPLE
|
|||
$ sbv2 oracle:print 9CmLriMhykZ8xAoNTSHjHbk6SkuMhie1NCZn9P6LCuZ4
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/oracle.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/oracle.ts)_
|
||||
_See code: [src/commands/print/oracle.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/oracle.ts)_
|
||||
|
||||
## `sbv2 print:oracle:permission ORACLEKEY`
|
||||
|
||||
|
@ -1978,7 +1978,7 @@ EXAMPLE
|
|||
$ sbv2 oracle:permission:print 9CmLriMhykZ8xAoNTSHjHbk6SkuMhie1NCZn9P6LCuZ4
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/oracle/permission.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/oracle/permission.ts)_
|
||||
_See code: [src/commands/print/oracle/permission.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/oracle/permission.ts)_
|
||||
|
||||
## `sbv2 print:program`
|
||||
|
||||
|
@ -2011,7 +2011,7 @@ EXAMPLE
|
|||
$ sbv2 program:print
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/program.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/program.ts)_
|
||||
_See code: [src/commands/print/program.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/program.ts)_
|
||||
|
||||
## `sbv2 print:queue QUEUEKEY`
|
||||
|
||||
|
@ -2049,7 +2049,7 @@ EXAMPLE
|
|||
$ sbv2 queue:print GhYg3R1V6DmJbwuc57qZeoYG6gUuvCotUF1zU3WCj98U
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/queue.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/queue.ts)_
|
||||
_See code: [src/commands/print/queue.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/queue.ts)_
|
||||
|
||||
## `sbv2 print:vrf VRFKEY`
|
||||
|
||||
|
@ -2085,7 +2085,7 @@ EXAMPLE
|
|||
$ sbv2 vrf:print SzTvFZLz3hwjZFMwVWzuEnr1oUF6qyvXwXCvsqf7qeA
|
||||
```
|
||||
|
||||
_See code: [src/commands/print/vrf.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/print/vrf.ts)_
|
||||
_See code: [src/commands/print/vrf.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/print/vrf.ts)_
|
||||
|
||||
## `sbv2 queue:add:crank QUEUEKEY`
|
||||
|
||||
|
@ -2122,7 +2122,7 @@ EXAMPLE
|
|||
$ sbv2 queue:add:crank 5aYuxRdcB9GpWrEXVMBQp2R5uf94uoBiFdMEBwcmHuU4 -k ../authority-keypair.json -n crank-1
|
||||
```
|
||||
|
||||
_See code: [src/commands/queue/add/crank.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/queue/add/crank.ts)_
|
||||
_See code: [src/commands/queue/add/crank.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/queue/add/crank.ts)_
|
||||
|
||||
## `sbv2 queue:create`
|
||||
|
||||
|
@ -2175,7 +2175,7 @@ ALIASES
|
|||
$ sbv2 custom:queue
|
||||
```
|
||||
|
||||
_See code: [src/commands/queue/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/queue/create.ts)_
|
||||
_See code: [src/commands/queue/create.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/queue/create.ts)_
|
||||
|
||||
## `sbv2 queue:permit:aggregator AGGREGATORKEY`
|
||||
|
||||
|
@ -2209,7 +2209,7 @@ EXAMPLE
|
|||
$ sbv2 queue:permit:aggregator 9CmLriMhykZ8xAoNTSHjHbk6SkuMhie1NCZn9P6LCuZ4 --keypair ../queue-authority.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/queue/permit/aggregator.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/queue/permit/aggregator.ts)_
|
||||
_See code: [src/commands/queue/permit/aggregator.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/queue/permit/aggregator.ts)_
|
||||
|
||||
## `sbv2 queue:permit:oracle ORACLEKEY`
|
||||
|
||||
|
@ -2243,7 +2243,7 @@ EXAMPLE
|
|||
$ sbv2 queue:permit:oracle 9CmLriMhykZ8xAoNTSHjHbk6SkuMhie1NCZn9P6LCuZ4 --keypair ../queue-authority.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/queue/permit/oracle.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/queue/permit/oracle.ts)_
|
||||
_See code: [src/commands/queue/permit/oracle.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/queue/permit/oracle.ts)_
|
||||
|
||||
## `sbv2 queue:set:rewards QUEUEKEY REWARDS`
|
||||
|
||||
|
@ -2275,7 +2275,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/queue/set/rewards.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/queue/set/rewards.ts)_
|
||||
_See code: [src/commands/queue/set/rewards.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/queue/set/rewards.ts)_
|
||||
|
||||
## `sbv2 queue:set:vrf QUEUEKEY`
|
||||
|
||||
|
@ -2308,7 +2308,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/queue/set/vrf.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/queue/set/vrf.ts)_
|
||||
_See code: [src/commands/queue/set/vrf.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/queue/set/vrf.ts)_
|
||||
|
||||
## `sbv2 sandbox [PLACEHOLDER]`
|
||||
|
||||
|
@ -2337,7 +2337,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/sandbox.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/sandbox.ts)_
|
||||
_See code: [src/commands/sandbox.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/sandbox.ts)_
|
||||
|
||||
## `sbv2 test ORACLEKEY`
|
||||
|
||||
|
@ -2367,7 +2367,7 @@ OPTIONS
|
|||
--programId=programId alternative Switchboard program ID to interact with
|
||||
```
|
||||
|
||||
_See code: [src/commands/test.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/test.ts)_
|
||||
_See code: [src/commands/test.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/test.ts)_
|
||||
|
||||
## `sbv2 update [CHANNEL]`
|
||||
|
||||
|
@ -2436,7 +2436,7 @@ EXAMPLES
|
|||
false,"isWritable": false}"
|
||||
```
|
||||
|
||||
_See code: [src/commands/vrf/create/index.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/vrf/create/index.ts)_
|
||||
_See code: [src/commands/vrf/create/index.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/vrf/create/index.ts)_
|
||||
|
||||
## `sbv2 vrf:create:example QUEUEKEY`
|
||||
|
||||
|
@ -2481,7 +2481,7 @@ EXAMPLE
|
|||
queue-authority-keypair.json
|
||||
```
|
||||
|
||||
_See code: [src/commands/vrf/create/example.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/vrf/create/example.ts)_
|
||||
_See code: [src/commands/vrf/create/example.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/vrf/create/example.ts)_
|
||||
|
||||
## `sbv2 vrf:request VRFKEY`
|
||||
|
||||
|
@ -2522,7 +2522,7 @@ EXAMPLE
|
|||
false,"isWritable": false}"
|
||||
```
|
||||
|
||||
_See code: [src/commands/vrf/request.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/vrf/request.ts)_
|
||||
_See code: [src/commands/vrf/request.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/vrf/request.ts)_
|
||||
|
||||
## `sbv2 watch:aggregator AGGREGATORKEY`
|
||||
|
||||
|
@ -2558,7 +2558,7 @@ EXAMPLE
|
|||
$ sbv2 watch:aggregator J7j9xX8JP2B2ErvUzuqGAKBGeggsxPyFXj5MqZcYDxfa
|
||||
```
|
||||
|
||||
_See code: [src/commands/watch/aggregator.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/watch/aggregator.ts)_
|
||||
_See code: [src/commands/watch/aggregator.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/watch/aggregator.ts)_
|
||||
|
||||
## `sbv2 watch:vrf VRFKEY`
|
||||
|
||||
|
@ -2594,5 +2594,5 @@ EXAMPLE
|
|||
$ sbv2 vrf:aggregator J7j9xX8JP2B2ErvUzuqGAKBGeggsxPyFXj5MqZcYDxfa
|
||||
```
|
||||
|
||||
_See code: [src/commands/watch/vrf.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.19/src/commands/watch/vrf.ts)_
|
||||
_See code: [src/commands/watch/vrf.ts](https://github.com/switchboard-xyz/switchboard-v2/blob/v0.1.20/src/commands/watch/vrf.ts)_
|
||||
<!-- commandsstop -->
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@switchboard-xyz/switchboardv2-cli",
|
||||
"description": "command line tool to interact with switchboard v2",
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.20",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -99,7 +99,7 @@
|
|||
"@project-serum/anchor": "^0.24.2",
|
||||
"@solana/spl-token": "^0.1.8",
|
||||
"@solana/web3.js": "^1.42.0",
|
||||
"@switchboard-xyz/sbv2-utils": "^0.0.10",
|
||||
"@switchboard-xyz/sbv2-utils": "^0.0.12",
|
||||
"@switchboard-xyz/switchboard-v2": "0.0.97",
|
||||
"assert": "^2.0.0",
|
||||
"big.js": "^6.1.1",
|
||||
|
|
|
@ -69,7 +69,7 @@ export default class LocalnetEnvironment extends BaseCommand {
|
|||
// TODO: Add silent flag
|
||||
// TODO: Pass keypair path and add as env variable
|
||||
const testEnvironment = await SwitchboardTestEnvironment.create(
|
||||
payerKeypair,
|
||||
flags.keypair,
|
||||
{
|
||||
USDC_MINT: new PublicKey(
|
||||
"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"
|
||||
|
@ -77,9 +77,7 @@ export default class LocalnetEnvironment extends BaseCommand {
|
|||
},
|
||||
flags.programId ? this.program.programId : undefined
|
||||
);
|
||||
// TODO: Add silent flag
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
testEnvironment.writeAll(flags.keypair, outputDir);
|
||||
testEnvironment.writeAll(outputDir);
|
||||
}
|
||||
|
||||
async catch(error) {
|
||||
|
|
|
@ -30,9 +30,24 @@ export const loadKeypairFs = (keypairPath: string): Keypair => {
|
|||
}
|
||||
|
||||
try {
|
||||
const keypairString = fs.readFileSync(fullPath, "utf-8");
|
||||
const keypairBuffer = new Uint8Array(JSON.parse(keypairString));
|
||||
const walletKeypair = Keypair.fromSecretKey(keypairBuffer);
|
||||
// const walletKeypair = Keypair.fromSecretKey(
|
||||
// Buffer.from(
|
||||
// JSON.parse(
|
||||
// fs.readFileSync(process.env.ANCHOR_WALLET, {
|
||||
// encoding: "utf-8",
|
||||
// })
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
const walletKeypair = Keypair.fromSecretKey(
|
||||
new Uint8Array(
|
||||
JSON.parse(
|
||||
fs.readFileSync(fullPath, {
|
||||
encoding: "utf-8",
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
return walletKeypair;
|
||||
} catch (error) {
|
||||
throw new Error(`failed to load keypair from ${fullPath}: ${error}`);
|
||||
|
|
|
@ -0,0 +1,267 @@
|
|||
import * as anchor from "@project-serum/anchor";
|
||||
import * as spl from "@solana/spl-token";
|
||||
import {
|
||||
PublicKey,
|
||||
SystemProgram,
|
||||
Transaction,
|
||||
TransactionInstruction,
|
||||
} from "@solana/web3.js";
|
||||
import {
|
||||
AggregatorAccount,
|
||||
AggregatorInitParams,
|
||||
JobAccount,
|
||||
LeaseAccount,
|
||||
OracleQueueAccount,
|
||||
PermissionAccount,
|
||||
ProgramStateAccount,
|
||||
programWallet,
|
||||
SwitchboardDecimal,
|
||||
} from "@switchboard-xyz/switchboard-v2";
|
||||
import Big from "big.js";
|
||||
import { promiseWithTimeout } from "./async";
|
||||
|
||||
export async function awaitOpenRound(
|
||||
aggregatorAccount: AggregatorAccount,
|
||||
queueAccount: OracleQueueAccount,
|
||||
payerTokenWallet: PublicKey,
|
||||
expectedValue: Big | undefined,
|
||||
timeout = 30
|
||||
): Promise<Big> {
|
||||
// call open round and wait for new value
|
||||
const accountsCoder = new anchor.BorshAccountsCoder(
|
||||
aggregatorAccount.program.idl
|
||||
);
|
||||
|
||||
let accountWs: number;
|
||||
const awaitUpdatePromise = new Promise((resolve: (value: Big) => void) => {
|
||||
accountWs = aggregatorAccount.program.provider.connection.onAccountChange(
|
||||
aggregatorAccount.publicKey,
|
||||
async (accountInfo) => {
|
||||
const aggregator = accountsCoder.decode(
|
||||
"AggregatorAccountData",
|
||||
accountInfo.data
|
||||
);
|
||||
const latestResult = await aggregatorAccount.getLatestValue(aggregator);
|
||||
if (expectedValue === undefined) {
|
||||
resolve(latestResult);
|
||||
} else {
|
||||
if (latestResult.eq(expectedValue)) {
|
||||
resolve(latestResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const updatedValuePromise = promiseWithTimeout(
|
||||
timeout * 1000,
|
||||
awaitUpdatePromise,
|
||||
new Error(`aggregator failed to update in ${timeout} seconds`)
|
||||
).finally(() => {
|
||||
if (accountWs) {
|
||||
aggregatorAccount.program.provider.connection.removeAccountChangeListener(
|
||||
accountWs
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
await aggregatorAccount.openRound({
|
||||
oracleQueueAccount: queueAccount,
|
||||
payoutWallet: payerTokenWallet,
|
||||
});
|
||||
|
||||
const result = await updatedValuePromise;
|
||||
|
||||
if (!result) {
|
||||
throw new Error(`failed to update aggregator`);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
export async function createAggregator(
|
||||
program: anchor.Program,
|
||||
queueAccount: OracleQueueAccount,
|
||||
params: AggregatorInitParams,
|
||||
jobs: [JobAccount, number][]
|
||||
) {
|
||||
const payerKeypair = programWallet(program);
|
||||
const queue = await queueAccount.loadData();
|
||||
const switchTokenMint = await queueAccount.loadMint();
|
||||
const payerTokenWallet = (
|
||||
await switchTokenMint.getOrCreateAssociatedAccountInfo(
|
||||
payerKeypair.publicKey
|
||||
)
|
||||
).address;
|
||||
|
||||
// Aggregator params
|
||||
const aggregatorKeypair = params.keypair ?? anchor.web3.Keypair.generate();
|
||||
const authority = params.authority ?? payerKeypair.publicKey;
|
||||
const size = program.account.aggregatorAccountData.size;
|
||||
const [programStateAccount, stateBump] =
|
||||
ProgramStateAccount.fromSeed(program);
|
||||
const state = await programStateAccount.loadData();
|
||||
const aggregatorAccount = new AggregatorAccount({
|
||||
program,
|
||||
publicKey: aggregatorKeypair.publicKey,
|
||||
});
|
||||
|
||||
// Permission params
|
||||
const [permissionAccount, permissionBump] = PermissionAccount.fromSeed(
|
||||
program,
|
||||
queue.authority,
|
||||
queueAccount.publicKey,
|
||||
aggregatorKeypair.publicKey
|
||||
);
|
||||
|
||||
// Lease params
|
||||
const [leaseAccount, leaseBump] = LeaseAccount.fromSeed(
|
||||
program,
|
||||
queueAccount,
|
||||
aggregatorAccount
|
||||
);
|
||||
const leaseEscrow = await spl.Token.getAssociatedTokenAddress(
|
||||
spl.ASSOCIATED_TOKEN_PROGRAM_ID,
|
||||
spl.TOKEN_PROGRAM_ID,
|
||||
switchTokenMint.publicKey,
|
||||
leaseAccount.publicKey,
|
||||
true
|
||||
);
|
||||
|
||||
// const jobPubkeys: Array<PublicKey> = [];
|
||||
// const jobWallets: Array<PublicKey> = [];
|
||||
// const walletBumps: Array<number> = [];
|
||||
// for (const idx in jobs) {
|
||||
// const [jobWallet, bump] = anchor.utils.publicKey.findProgramAddressSync(
|
||||
// [
|
||||
// payerKeypair.publicKey.toBuffer(),
|
||||
// spl.TOKEN_PROGRAM_ID.toBuffer(),
|
||||
// switchTokenMint.publicKey.toBuffer(),
|
||||
// ],
|
||||
// spl.ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
// );
|
||||
// jobPubkeys.push(jobs[idx].publicKey);
|
||||
// jobWallets.push(jobWallet);
|
||||
// walletBumps.push(bump);
|
||||
// }
|
||||
|
||||
const createIxns: TransactionInstruction[] = [];
|
||||
|
||||
createIxns.push(
|
||||
...[
|
||||
// allocate aggregator account
|
||||
anchor.web3.SystemProgram.createAccount({
|
||||
fromPubkey: programWallet(program).publicKey,
|
||||
newAccountPubkey: aggregatorKeypair.publicKey,
|
||||
space: size,
|
||||
lamports:
|
||||
await program.provider.connection.getMinimumBalanceForRentExemption(
|
||||
size
|
||||
),
|
||||
programId: program.programId,
|
||||
}),
|
||||
// create aggregator
|
||||
await program.methods
|
||||
.aggregatorInit({
|
||||
name: (params.name ?? Buffer.from("")).slice(0, 32),
|
||||
metadata: (params.metadata ?? Buffer.from("")).slice(0, 128),
|
||||
batchSize: params.batchSize,
|
||||
minOracleResults: params.minRequiredOracleResults,
|
||||
minJobResults: params.minRequiredJobResults,
|
||||
minUpdateDelaySeconds: params.minUpdateDelaySeconds,
|
||||
varianceThreshold: SwitchboardDecimal.fromBig(
|
||||
new Big(params.varianceThreshold ?? 0)
|
||||
),
|
||||
forceReportPeriod: params.forceReportPeriod ?? new anchor.BN(0),
|
||||
expiration: params.expiration ?? new anchor.BN(0),
|
||||
stateBump,
|
||||
})
|
||||
.accounts({
|
||||
aggregator: aggregatorKeypair.publicKey,
|
||||
authority,
|
||||
queue: params.queueAccount.publicKey,
|
||||
authorWallet: params.authorWallet ?? state.tokenVault,
|
||||
programState: programStateAccount.publicKey,
|
||||
})
|
||||
.instruction(),
|
||||
await program.methods
|
||||
.permissionInit({})
|
||||
.accounts({
|
||||
permission: permissionAccount.publicKey,
|
||||
authority: params.authority,
|
||||
granter: queueAccount.publicKey,
|
||||
grantee: aggregatorKeypair.publicKey,
|
||||
payer: payerKeypair.publicKey,
|
||||
systemProgram: SystemProgram.programId,
|
||||
})
|
||||
.instruction(),
|
||||
payerKeypair.publicKey.equals(queue.authority)
|
||||
? await program.methods
|
||||
.permissionSet({
|
||||
permission: { permitOracleQueueUsage: null },
|
||||
enable: true,
|
||||
})
|
||||
.accounts({
|
||||
permission: permissionAccount.publicKey,
|
||||
authority: queue.authority,
|
||||
})
|
||||
.instruction()
|
||||
: undefined,
|
||||
spl.Token.createAssociatedTokenAccountInstruction(
|
||||
spl.ASSOCIATED_TOKEN_PROGRAM_ID,
|
||||
spl.TOKEN_PROGRAM_ID,
|
||||
switchTokenMint.publicKey,
|
||||
leaseEscrow,
|
||||
leaseAccount.publicKey,
|
||||
payerKeypair.publicKey
|
||||
),
|
||||
await program.methods
|
||||
.leaseInit({
|
||||
loadAmount: new anchor.BN(0),
|
||||
stateBump,
|
||||
leaseBump,
|
||||
withdrawAuthority: payerKeypair.publicKey,
|
||||
walletBumps: Buffer.from([]),
|
||||
})
|
||||
.accounts({
|
||||
programState: programStateAccount.publicKey,
|
||||
lease: leaseAccount.publicKey,
|
||||
queue: queueAccount.publicKey,
|
||||
aggregator: aggregatorAccount.publicKey,
|
||||
systemProgram: SystemProgram.programId,
|
||||
funder: payerTokenWallet,
|
||||
payer: payerKeypair.publicKey,
|
||||
tokenProgram: spl.TOKEN_PROGRAM_ID,
|
||||
escrow: leaseEscrow,
|
||||
owner: payerKeypair.publicKey,
|
||||
mint: switchTokenMint.publicKey,
|
||||
})
|
||||
// .remainingAccounts(
|
||||
// jobPubkeys.concat(jobWallets).map((pubkey: PublicKey) => {
|
||||
// return { isSigner: false, isWritable: true, pubkey };
|
||||
// })
|
||||
// )
|
||||
.instruction(),
|
||||
...(await Promise.all(
|
||||
jobs.map(async ([jobAccount, weight]) => {
|
||||
return program.methods
|
||||
.aggregatorAddJob({
|
||||
weight,
|
||||
})
|
||||
.accounts({
|
||||
aggregator: aggregatorKeypair.publicKey,
|
||||
authority: payerKeypair.publicKey,
|
||||
job: jobAccount.publicKey,
|
||||
})
|
||||
.instruction();
|
||||
})
|
||||
)),
|
||||
].filter((item) => item)
|
||||
);
|
||||
|
||||
const createSig = await program.provider.sendAndConfirm(
|
||||
new Transaction().add(...createIxns),
|
||||
[payerKeypair, aggregatorKeypair]
|
||||
);
|
||||
return aggregatorAccount;
|
||||
}
|
|
@ -4,6 +4,7 @@ export * from "./big";
|
|||
export * from "./const";
|
||||
export * from "./date";
|
||||
export * from "./errors";
|
||||
export * from "./feed";
|
||||
export * from "./nonce";
|
||||
export * from "./print";
|
||||
export * from "./state";
|
||||
|
|
|
@ -5,11 +5,10 @@ import type NodeWallet from "@project-serum/anchor/dist/cjs/nodewallet";
|
|||
import * as spl from "@solana/spl-token";
|
||||
import { Keypair, PublicKey } from "@solana/web3.js";
|
||||
import * as sbv2 from "@switchboard-xyz/switchboard-v2";
|
||||
// import { sbv2.OracleJob } from "@switchboard-xyz/v2-task-library";
|
||||
import Big from "big.js";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { DEFAULT_PUBKEY, promiseWithTimeout } from "../";
|
||||
import { awaitOpenRound, createAggregator } from "../feed";
|
||||
|
||||
export interface ISwitchboardTestContext {
|
||||
program: anchor.Program;
|
||||
|
@ -235,56 +234,12 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
|
||||
/** Create a static data feed that resolves to an expected value */
|
||||
public async createStaticFeed(
|
||||
value: number
|
||||
value: number,
|
||||
timeout = 30
|
||||
): Promise<sbv2.AggregatorAccount> {
|
||||
const queue = await this.queue.loadData();
|
||||
const payerKeypair = sbv2.programWallet(this.program);
|
||||
|
||||
// create aggregator
|
||||
const aggregatorAccount = await sbv2.AggregatorAccount.create(
|
||||
this.program,
|
||||
{
|
||||
batchSize: 1,
|
||||
minRequiredJobResults: 1,
|
||||
minRequiredOracleResults: 1,
|
||||
minUpdateDelaySeconds: 5,
|
||||
queueAccount: this.queue,
|
||||
authorWallet: this.payerTokenWallet,
|
||||
}
|
||||
);
|
||||
|
||||
// create permission account and approve if necessary
|
||||
const permissionAccount = await sbv2.PermissionAccount.create(
|
||||
this.program,
|
||||
{
|
||||
authority: queue.authority,
|
||||
granter: this.queue.publicKey,
|
||||
grantee: aggregatorAccount.publicKey,
|
||||
}
|
||||
);
|
||||
if (!queue.unpermissionedFeedsEnabled) {
|
||||
if (queue.authority.equals(payerKeypair.publicKey)) {
|
||||
await permissionAccount.set({
|
||||
authority: payerKeypair,
|
||||
enable: true,
|
||||
permission: sbv2.SwitchboardPermission.PERMIT_ORACLE_QUEUE_USAGE,
|
||||
});
|
||||
}
|
||||
throw new Error(
|
||||
`must provide queue authority to permit data feeds to join`
|
||||
);
|
||||
}
|
||||
|
||||
// create lease contract
|
||||
const leaseAccount = await sbv2.LeaseAccount.create(this.program, {
|
||||
aggregatorAccount,
|
||||
funder: this.payerTokenWallet,
|
||||
funderAuthority: payerKeypair,
|
||||
loadAmount: new anchor.BN(0),
|
||||
oracleQueueAccount: this.queue,
|
||||
});
|
||||
|
||||
// create and add job account
|
||||
const staticJob = await sbv2.JobAccount.create(this.program, {
|
||||
name: Buffer.from(`Value ${value}`),
|
||||
authority: this.payerTokenWallet,
|
||||
|
@ -302,13 +257,29 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
).finish()
|
||||
),
|
||||
});
|
||||
await aggregatorAccount.addJob(staticJob);
|
||||
|
||||
// open new round and request new result
|
||||
await aggregatorAccount.openRound({
|
||||
oracleQueueAccount: this.queue,
|
||||
payoutWallet: this.payerTokenWallet,
|
||||
});
|
||||
const aggregatorAccount = await createAggregator(
|
||||
this.program,
|
||||
this.queue,
|
||||
{
|
||||
batchSize: 1,
|
||||
minRequiredJobResults: 1,
|
||||
minRequiredOracleResults: 1,
|
||||
minUpdateDelaySeconds: 5,
|
||||
queueAccount: this.queue,
|
||||
authorWallet: this.payerTokenWallet,
|
||||
authority: payerKeypair.publicKey,
|
||||
},
|
||||
[[staticJob, 1]]
|
||||
);
|
||||
|
||||
const aggValue = await awaitOpenRound(
|
||||
aggregatorAccount,
|
||||
this.queue,
|
||||
this.payerTokenWallet,
|
||||
new Big(value),
|
||||
timeout
|
||||
);
|
||||
|
||||
return aggregatorAccount;
|
||||
}
|
||||
|
@ -323,6 +294,7 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
value: number,
|
||||
timeout = 30
|
||||
): Promise<void> {
|
||||
const payerKeypair = sbv2.programWallet(this.program);
|
||||
const aggregator = await aggregatorAccount.loadData();
|
||||
const expectedValue = new Big(value);
|
||||
|
||||
|
@ -332,7 +304,7 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
const existingJobs: sbv2.JobAccount[] = aggregator.jobPubkeysData
|
||||
// eslint-disable-next-line array-callback-return
|
||||
.filter((jobKey: PublicKey) => {
|
||||
if (!jobKey.equals(DEFAULT_PUBKEY)) {
|
||||
if (!jobKey.equals(PublicKey.default)) {
|
||||
return jobKey;
|
||||
}
|
||||
})
|
||||
|
@ -344,7 +316,7 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
})
|
||||
);
|
||||
await Promise.all(
|
||||
existingJobs.map((job) => aggregatorAccount.removeJob(job))
|
||||
existingJobs.map((job) => aggregatorAccount.removeJob(job, payerKeypair))
|
||||
);
|
||||
|
||||
// add new static job
|
||||
|
@ -365,49 +337,14 @@ export class SwitchboardTestContext implements ISwitchboardTestContext {
|
|||
).finish()
|
||||
),
|
||||
});
|
||||
await aggregatorAccount.addJob(staticJob);
|
||||
await aggregatorAccount.addJob(staticJob, payerKeypair);
|
||||
|
||||
// call open round and wait for new value
|
||||
const accountsCoder = new anchor.BorshAccountsCoder(this.program.idl);
|
||||
|
||||
let accountWs: number;
|
||||
const awaitUpdatePromise = new Promise((resolve: (value: Big) => void) => {
|
||||
accountWs = this.program.provider.connection.onAccountChange(
|
||||
aggregatorAccount.publicKey,
|
||||
async (accountInfo) => {
|
||||
const aggregator = accountsCoder.decode(
|
||||
"AggregatorAccountData",
|
||||
accountInfo.data
|
||||
);
|
||||
const latestResult = await aggregatorAccount.getLatestValue(
|
||||
aggregator
|
||||
);
|
||||
if (latestResult.eq(expectedValue)) {
|
||||
resolve(latestResult);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
const updatedValuePromise = promiseWithTimeout(
|
||||
timeout * 1000,
|
||||
awaitUpdatePromise,
|
||||
new Error(`aggregator failed to update in ${timeout} seconds`)
|
||||
).finally(() => {
|
||||
if (accountWs) {
|
||||
this.program.provider.connection.removeAccountChangeListener(accountWs);
|
||||
}
|
||||
});
|
||||
|
||||
await aggregatorAccount.openRound({
|
||||
oracleQueueAccount: this.queue,
|
||||
payoutWallet: this.payerTokenWallet,
|
||||
});
|
||||
|
||||
await updatedValuePromise;
|
||||
|
||||
if (!updatedValuePromise) {
|
||||
throw new Error(`failed to update aggregator`);
|
||||
}
|
||||
const aggValue = await awaitOpenRound(
|
||||
aggregatorAccount,
|
||||
this.queue,
|
||||
this.payerTokenWallet,
|
||||
expectedValue,
|
||||
timeout
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ export interface ISwitchboardTestEnvironment {
|
|||
oracleAuthority: PublicKey;
|
||||
oracleEscrow: PublicKey;
|
||||
oraclePermissions: PublicKey;
|
||||
payerKeypairPath: string;
|
||||
|
||||
// allow a map of public keys to include in clone script
|
||||
additionalClonedAccounts?: Record<string, PublicKey>;
|
||||
|
@ -66,6 +67,8 @@ export class SwitchboardTestEnvironment implements ISwitchboardTestEnvironment {
|
|||
|
||||
oraclePermissions: PublicKey;
|
||||
|
||||
payerKeypairPath: string;
|
||||
|
||||
additionalClonedAccounts?: Record<string, PublicKey>;
|
||||
|
||||
constructor(ctx: ISwitchboardTestEnvironment) {
|
||||
|
@ -85,24 +88,28 @@ export class SwitchboardTestEnvironment implements ISwitchboardTestEnvironment {
|
|||
this.oracleAuthority = ctx.oracleAuthority;
|
||||
this.oracleEscrow = ctx.oracleEscrow;
|
||||
this.oraclePermissions = ctx.oraclePermissions;
|
||||
this.payerKeypairPath = ctx.payerKeypairPath;
|
||||
this.additionalClonedAccounts = ctx.additionalClonedAccounts;
|
||||
}
|
||||
|
||||
private getAccountCloneString(): string {
|
||||
const accounts: string[] = Object.keys(this).map((key) => {
|
||||
// iterate over additionalClonedAccounts and collect pubkeys
|
||||
if (typeof this[key] === "string") {
|
||||
return;
|
||||
}
|
||||
if (key === "additionalClonedAccounts" && this[key]) {
|
||||
const additionalPubkeys = Object.values(this.additionalClonedAccounts);
|
||||
const cloneStrings = additionalPubkeys.map(
|
||||
(pubkey) => `--clone ${pubkey.toBase58()}`
|
||||
(pubkey) => `--clone ${pubkey.toBase58()} \`# ${key}\``
|
||||
);
|
||||
return cloneStrings.join(" ");
|
||||
return cloneStrings.join(`\\\n`);
|
||||
}
|
||||
|
||||
return `--clone ${(this[key] as PublicKey).toBase58()}`;
|
||||
return `--clone ${(this[key] as PublicKey).toBase58()} \`# ${key}\` `;
|
||||
});
|
||||
|
||||
return accounts.join(" ");
|
||||
return accounts.filter((i) => i).join(`\\\n`);
|
||||
}
|
||||
|
||||
public toJSON(): ISwitchboardTestEnvironment {
|
||||
|
@ -123,16 +130,18 @@ export class SwitchboardTestEnvironment implements ISwitchboardTestEnvironment {
|
|||
oracleAuthority: this.oracleAuthority,
|
||||
oracleEscrow: this.oracleEscrow,
|
||||
oraclePermissions: this.oraclePermissions,
|
||||
payerKeypairPath: this.payerKeypairPath,
|
||||
additionalClonedAccounts: this.additionalClonedAccounts,
|
||||
};
|
||||
}
|
||||
|
||||
/** Write switchboard test environment to filesystem */
|
||||
public writeAll(payerKeypairPath: string, filePath: string): void {
|
||||
this.writeEnv(filePath);
|
||||
this.writeJSON(filePath);
|
||||
this.writeScripts(payerKeypairPath, filePath);
|
||||
this.writeDockerCompose(this.oracle, payerKeypairPath, filePath);
|
||||
public writeAll(outputDir: string): void {
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
this.writeEnv(outputDir);
|
||||
this.writeJSON(outputDir);
|
||||
this.writeScripts(outputDir);
|
||||
this.writeDockerCompose(this.oracle, outputDir);
|
||||
}
|
||||
|
||||
/** Write the env file to filesystem */
|
||||
|
@ -155,7 +164,7 @@ export class SwitchboardTestEnvironment implements ISwitchboardTestEnvironment {
|
|||
fileStr += `ORACLE_AUTHORITY="${this.oracleAuthority.toBase58()}"\n`;
|
||||
fileStr += `ORACLE_ESCROW="${this.oracleEscrow.toBase58()}"\n`;
|
||||
fileStr += `ORACLE_PERMISSIONS="${this.oraclePermissions.toBase58()}"\n`;
|
||||
fileStr += `SWITCHBOARD_ACCOUNTS="${this.getAccountCloneString()}"\n`;
|
||||
// fileStr += `SWITCHBOARD_ACCOUNTS="${this.getAccountCloneString()}"\n`;
|
||||
// TODO: Write additionalClonedAccounts to env file
|
||||
fs.writeFileSync(ENV_FILE_PATH, fileStr);
|
||||
console.log(
|
||||
|
@ -166,8 +175,8 @@ export class SwitchboardTestEnvironment implements ISwitchboardTestEnvironment {
|
|||
);
|
||||
}
|
||||
|
||||
public writeJSON(filePath: string): void {
|
||||
const JSON_FILE_PATH = path.join(filePath, "switchboard.json");
|
||||
public writeJSON(outputDir: string): void {
|
||||
const JSON_FILE_PATH = path.join(outputDir, "switchboard.json");
|
||||
fs.writeFileSync(
|
||||
JSON_FILE_PATH,
|
||||
JSON.stringify(
|
||||
|
@ -183,9 +192,9 @@ export class SwitchboardTestEnvironment implements ISwitchboardTestEnvironment {
|
|||
);
|
||||
}
|
||||
|
||||
public writeScripts(payerKeypairPath: string, filePath: string): void {
|
||||
public writeScripts(outputDir: string): void {
|
||||
const LOCAL_VALIDATOR_SCRIPT = path.join(
|
||||
filePath,
|
||||
outputDir,
|
||||
"start-local-validator.sh"
|
||||
);
|
||||
// create bash script to startup local validator with appropriate accounts cloned
|
||||
|
@ -196,8 +205,10 @@ export class SwitchboardTestEnvironment implements ISwitchboardTestEnvironment {
|
|||
const startValidatorCommand = `${baseValidatorCommand} ${cloneAccountsString}`;
|
||||
fs.writeFileSync(
|
||||
LOCAL_VALIDATOR_SCRIPT,
|
||||
|
||||
`#!/bin/bash\n\nmkdir -p .anchor/test-ledger\n\n${startValidatorCommand}`
|
||||
);
|
||||
fs.chmodSync(LOCAL_VALIDATOR_SCRIPT, "755");
|
||||
console.log(
|
||||
`${chalk.green("Bash script saved to:")} ${LOCAL_VALIDATOR_SCRIPT.replace(
|
||||
process.cwd(),
|
||||
|
@ -206,9 +217,19 @@ export class SwitchboardTestEnvironment implements ISwitchboardTestEnvironment {
|
|||
);
|
||||
|
||||
// create bash script to start local oracle
|
||||
const ORACLE_SCRIPT = path.join(filePath, "start-oracle.sh");
|
||||
const startOracleCommand = `docker-compose -f docker-compose.switchboard.yml up`;
|
||||
fs.writeFileSync(ORACLE_SCRIPT, `#!/bin/bash\n\n${startOracleCommand}`);
|
||||
const ORACLE_SCRIPT = path.join(outputDir, "start-oracle.sh");
|
||||
// const startOracleCommand = `docker-compose -f docker-compose.switchboard.yml up`;
|
||||
fs.writeFileSync(
|
||||
ORACLE_SCRIPT,
|
||||
`#!/usr/bin/env bash
|
||||
|
||||
script_dir=$( cd -- "$( dirname -- "\${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
docker-compose -f "$script_dir"/docker-compose.switchboard.yml up
|
||||
`
|
||||
// `#!/bin/bash\n\n${startOracleCommand}`
|
||||
);
|
||||
fs.chmodSync(ORACLE_SCRIPT, "755");
|
||||
console.log(
|
||||
`${chalk.green("Bash script saved to:")} ${ORACLE_SCRIPT.replace(
|
||||
process.cwd(),
|
||||
|
@ -217,13 +238,9 @@ export class SwitchboardTestEnvironment implements ISwitchboardTestEnvironment {
|
|||
);
|
||||
}
|
||||
|
||||
public writeDockerCompose(
|
||||
oracleKey: PublicKey,
|
||||
payerKeypairPath: string,
|
||||
filePath: string
|
||||
): void {
|
||||
public writeDockerCompose(oracleKey: PublicKey, outputDir: string): void {
|
||||
const DOCKER_COMPOSE_FILEPATH = path.join(
|
||||
filePath,
|
||||
outputDir,
|
||||
"docker-compose.switchboard.yml"
|
||||
);
|
||||
const dockerComposeString = `version: "3.3"
|
||||
|
@ -243,7 +260,7 @@ services:
|
|||
# - RPC_URL=\${RPC_URL}
|
||||
secrets:
|
||||
PAYER_SECRETS:
|
||||
file: ${payerKeypairPath}
|
||||
file: ${this.payerKeypairPath}
|
||||
`;
|
||||
fs.writeFileSync(DOCKER_COMPOSE_FILEPATH, dockerComposeString);
|
||||
console.log(
|
||||
|
@ -255,10 +272,26 @@ secrets:
|
|||
|
||||
/** Build a devnet environment to later clone to localnet */
|
||||
static async create(
|
||||
payerKeypair: Keypair,
|
||||
payerKeypairPath: string,
|
||||
additionalClonedAccounts?: Record<string, PublicKey>,
|
||||
alternateProgramId?: PublicKey
|
||||
): Promise<SwitchboardTestEnvironment> {
|
||||
const fullKeypairPath =
|
||||
payerKeypairPath.charAt(0) === "/"
|
||||
? payerKeypairPath
|
||||
: path.join(process.cwd(), payerKeypairPath);
|
||||
if (!fs.existsSync(fullKeypairPath)) {
|
||||
throw new Error("Failed to find payer keypair path");
|
||||
}
|
||||
const payerKeypair = Keypair.fromSecretKey(
|
||||
new Uint8Array(
|
||||
JSON.parse(
|
||||
fs.readFileSync(fullKeypairPath, {
|
||||
encoding: "utf-8",
|
||||
})
|
||||
)
|
||||
)
|
||||
);
|
||||
const connection = new Connection(clusterApiUrl("devnet"), {
|
||||
commitment: "confirmed",
|
||||
});
|
||||
|
@ -372,6 +405,7 @@ secrets:
|
|||
oracleAuthority: oracle.oracleAuthority,
|
||||
oracleEscrow: oracle.tokenAccount,
|
||||
oraclePermissions: oraclePermissionAccount.publicKey,
|
||||
payerKeypairPath: fullKeypairPath,
|
||||
additionalClonedAccounts,
|
||||
};
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
"dependencies": {
|
||||
"@project-serum/anchor": "^0.24.2",
|
||||
"@solana/web3.js": "^1.42.0",
|
||||
"@switchboard-xyz/sbv2-utils": "^0.0.10",
|
||||
"@switchboard-xyz/sbv2-utils": "^0.0.12",
|
||||
"@switchboard-xyz/switchboard-v2": "^0.0.97"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -13,14 +13,15 @@ const DEFAULT_SOL_USD_FEED = new PublicKey(
|
|||
);
|
||||
|
||||
describe("anchor-feed-parser test", () => {
|
||||
anchor.setProvider(anchor.AnchorProvider.env());
|
||||
const provider = anchor.AnchorProvider.env();
|
||||
anchor.setProvider(provider);
|
||||
|
||||
const feedParserProgram = anchor.workspace
|
||||
.AnchorFeedParser as Program<AnchorFeedParser>;
|
||||
const provider = feedParserProgram.provider as anchor.AnchorProvider;
|
||||
|
||||
let switchboard: SwitchboardTestContext;
|
||||
let aggregatorKey: PublicKey;
|
||||
let localnet = false;
|
||||
|
||||
before(async () => {
|
||||
// First, attempt to load the switchboard devnet PID
|
||||
|
@ -29,18 +30,19 @@ describe("anchor-feed-parser test", () => {
|
|||
aggregatorKey = DEFAULT_SOL_USD_FEED;
|
||||
console.log("devnet detected");
|
||||
return;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} catch (error: any) {
|
||||
console.log(`Error: SBV2 Devnet - ${error.message}`);
|
||||
}
|
||||
// If fails, fallback to looking for a local env file
|
||||
try {
|
||||
switchboard = await SwitchboardTestContext.loadFromEnv(provider);
|
||||
const aggregatorAccount = await switchboard.createStaticFeed(100);
|
||||
aggregatorKey = aggregatorAccount.publicKey ?? PublicKey.default;
|
||||
localnet = true;
|
||||
console.log("localnet detected");
|
||||
return;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} catch (error: any) {
|
||||
console.log(`Error: SBV2 Localnet - ${error.message}`);
|
||||
}
|
||||
// If fails, throw error
|
||||
throw new Error(
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"@project-serum/anchor": "^0.24.2",
|
||||
"@solana/spl-token": "^0.1.8",
|
||||
"@solana/web3.js": "^1.42.0",
|
||||
"@switchboard-xyz/sbv2-utils": "^0.0.10",
|
||||
"@switchboard-xyz/sbv2-utils": "^0.0.12",
|
||||
"@switchboard-xyz/switchboard-v2": "^0.0.97",
|
||||
"chalk": "^4.1.2",
|
||||
"child_process": "^1.0.2",
|
||||
|
|
|
@ -74,16 +74,16 @@ describe("anchor-vrf-parser test", async () => {
|
|||
switchboard = await SwitchboardTestContext.loadDevnetQueue(provider);
|
||||
console.log("devnet detected");
|
||||
return;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} catch (error: any) {
|
||||
console.log(`Error: SBV2 Devnet - ${error.message}`);
|
||||
}
|
||||
// If fails, fallback to looking for a local env file
|
||||
try {
|
||||
switchboard = await SwitchboardTestContext.loadFromEnv(provider);
|
||||
console.log("localnet detected");
|
||||
return;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} catch (error: any) {
|
||||
console.log(`Error: SBV2 Localnet - ${error.message}`);
|
||||
}
|
||||
// If fails, throw error
|
||||
throw new Error(
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
"dependencies": {
|
||||
"@project-serum/anchor": "^0.24.2",
|
||||
"@solana/web3.js": "^1.42.0",
|
||||
"@switchboard-xyz/sbv2-utils": "^0.0.10",
|
||||
"@switchboard-xyz/sbv2-utils": "^0.0.12",
|
||||
"@switchboard-xyz/switchboard-v2": "^0.0.97"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -40,6 +40,7 @@ describe("spl-feed-parser test", () => {
|
|||
|
||||
let switchboard: SwitchboardTestContext;
|
||||
let aggregatorKey: PublicKey;
|
||||
let localnet = false;
|
||||
|
||||
before(async () => {
|
||||
// First, attempt to load the switchboard devnet PID
|
||||
|
@ -48,18 +49,19 @@ describe("spl-feed-parser test", () => {
|
|||
aggregatorKey = DEFAULT_SOL_USD_FEED;
|
||||
console.log("devnet detected");
|
||||
return;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} catch (error: any) {
|
||||
console.log(`Error: SBV2 Devnet - ${error.message}`);
|
||||
}
|
||||
// If fails, fallback to looking for a local env file
|
||||
try {
|
||||
switchboard = await SwitchboardTestContext.loadFromEnv(provider);
|
||||
const aggregatorAccount = await switchboard.createStaticFeed(100);
|
||||
aggregatorKey = aggregatorAccount.publicKey ?? PublicKey.default;
|
||||
localnet = true;
|
||||
console.log("localnet detected");
|
||||
return;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
} catch (error: any) {
|
||||
console.log(`Error: SBV2 Localnet - ${error.message}`);
|
||||
}
|
||||
// If fails, throw error
|
||||
throw new Error(
|
||||
|
@ -88,6 +90,9 @@ describe("spl-feed-parser test", () => {
|
|||
readSwitchboardAggregatorTxn
|
||||
);
|
||||
|
||||
// wait for RPC
|
||||
await sleep(2000);
|
||||
|
||||
const confirmedTxn = await provider.connection.getParsedTransaction(
|
||||
signature,
|
||||
"confirmed"
|
||||
|
|
17
yarn.lock
17
yarn.lock
|
@ -4156,6 +4156,23 @@
|
|||
"@svgr/plugin-jsx" "^6.2.1"
|
||||
"@svgr/plugin-svgo" "^6.2.0"
|
||||
|
||||
"@switchboard-xyz/sbv2-utils@^0.0.10":
|
||||
version "0.0.11"
|
||||
resolved "https://registry.npmjs.org/@switchboard-xyz/sbv2-utils/-/sbv2-utils-0.0.10.tgz#a30a7209d7c16e119943e7eaef33cddcf663cdd4"
|
||||
integrity sha512-q9GHnHp+ZUZ642+caVfsuIBXWdvioQtGSk6UTLfpxYFoRMDPGdH5I7T/cjM08xbxK1YaA1fW4bv2K9L1Cu8Ing==
|
||||
dependencies:
|
||||
"@orca-so/sdk" "^1.2.24"
|
||||
"@project-serum/anchor" "^0.24.2"
|
||||
"@saberhq/token-utils" "^1.12.68"
|
||||
"@solana/spl-token" "^0.1.8"
|
||||
"@solana/web3.js" "^1.42.0"
|
||||
"@switchboard-xyz/switchboard-v2" "^0.0.97"
|
||||
big.js "^6.1.1"
|
||||
chalk "4"
|
||||
decimal.js "^10.3.1"
|
||||
dotenv "^16.0.0"
|
||||
toml "^3.0.0"
|
||||
|
||||
"@switchboard-xyz/switchboard-api@^0.2.193":
|
||||
version "0.2.200"
|
||||
resolved "https://registry.npmjs.org/@switchboard-xyz/switchboard-api/-/switchboard-api-0.2.200.tgz#16c7d95390693e5992a7f96287143361b4d38cc9"
|
||||
|
|
Loading…
Reference in New Issue