From aa3ea43c611aec985c8efbab71a62ed7ef095fe3 Mon Sep 17 00:00:00 2001
From: GroovieGermanikus <groovie@mango.markets>
Date: Wed, 20 Sep 2023 18:09:10 +0200
Subject: [PATCH] update to switchboard-solana

---
 Cargo.lock                      | 129 ++++++++++++++++++++++++++------
 programs/openbook-v2/Cargo.toml |   6 +-
 2 files changed, 111 insertions(+), 24 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index ee5fed424..8fde257f0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -457,6 +457,12 @@ version = "0.3.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545"
 
+[[package]]
+name = "arrayvec"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
+
 [[package]]
 name = "arrayvec"
 version = "0.7.4"
@@ -478,7 +484,7 @@ dependencies = [
  "asn1-rs-derive",
  "asn1-rs-impl",
  "displaydoc",
- "nom",
+ "nom 7.1.3",
  "num-traits",
  "rusticata-macros",
  "thiserror",
@@ -788,7 +794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "199c42ab6972d92c9f8995f086273d25c42fc0f7b2a1fcefba465c1352d25ba5"
 dependencies = [
  "arrayref",
- "arrayvec",
+ "arrayvec 0.7.4",
  "cc",
  "cfg-if 1.0.0",
  "constant_time_eq",
@@ -1061,7 +1067,7 @@ version = "0.6.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
 dependencies = [
- "nom",
+ "nom 7.1.3",
 ]
 
 [[package]]
@@ -1288,6 +1294,17 @@ dependencies = [
  "cfg-if 1.0.0",
 ]
 
+[[package]]
+name = "cron"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ff76b51e4c068c52bfd2866e1567bee7c567ae8f24ada09fd4307019e25eab7"
+dependencies = [
+ "chrono",
+ "nom 7.1.3",
+ "once_cell",
+]
+
 [[package]]
 name = "crossbeam-channel"
 version = "0.5.8"
@@ -1460,7 +1477,7 @@ checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e"
 dependencies = [
  "asn1-rs",
  "displaydoc",
- "nom",
+ "nom 7.1.3",
  "num-bigint 0.4.4",
  "num-traits",
  "rusticata-macros",
@@ -1755,6 +1772,15 @@ dependencies = [
  "termcolor",
 ]
 
+[[package]]
+name = "envy"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f47e0157f2cb54f5ae1bd371b30a2ae4311e1c028f575cd4e81de7353215965"
+dependencies = [
+ "serde",
+]
+
 [[package]]
 name = "equivalent"
 version = "1.0.1"
@@ -2743,6 +2769,19 @@ version = "1.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
 
+[[package]]
+name = "lexical-core"
+version = "0.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe"
+dependencies = [
+ "arrayvec 0.5.2",
+ "bitflags 1.3.2",
+ "cfg-if 1.0.0",
+ "ryu",
+ "static_assertions",
+]
+
 [[package]]
 name = "libc"
 version = "0.2.147"
@@ -3193,6 +3232,17 @@ dependencies = [
  "pin-utils",
 ]
 
+[[package]]
+name = "nom"
+version = "5.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b"
+dependencies = [
+ "lexical-core",
+ "memchr",
+ "version_check 0.9.4",
+]
+
 [[package]]
 name = "nom"
 version = "7.1.3"
@@ -3455,7 +3505,7 @@ dependencies = [
  "spl-token",
  "static_assertions",
  "switchboard-program",
- "switchboard-v2",
+ "switchboard-solana",
 ]
 
 [[package]]
@@ -4522,7 +4572,7 @@ version = "1.26.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ee9164faf726e4f3ece4978b25ca877ddc6802fa77f38cdccb32c7f805ecd70c"
 dependencies = [
- "arrayvec",
+ "arrayvec 0.7.4",
  "num-traits",
  "serde",
 ]
@@ -4573,7 +4623,7 @@ version = "4.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632"
 dependencies = [
- "nom",
+ "nom 7.1.3",
 ]
 
 [[package]]
@@ -4860,6 +4910,15 @@ dependencies = [
  "unsafe-libyaml",
 ]
 
+[[package]]
+name = "sgx-quote"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1640577af7b81d10db340c4b31006b77972e3918f351eec4e65c389c8b58e21"
+dependencies = [
+ "nom 5.1.3",
+]
+
 [[package]]
 name = "sha-1"
 version = "0.9.8"
@@ -6600,6 +6659,21 @@ version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f"
 
+[[package]]
+name = "switchboard-common"
+version = "0.8.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1c9e28848b864786d8b1835f1f0c4c7e65190d9c17b246e5e21cc2457a70b176"
+dependencies = [
+ "envy",
+ "getrandom 0.2.10",
+ "hex",
+ "serde",
+ "serde_json",
+ "sgx-quote",
+ "sha2 0.10.7",
+]
+
 [[package]]
 name = "switchboard-program"
 version = "0.2.1"
@@ -6629,34 +6703,45 @@ dependencies = [
 ]
 
 [[package]]
-name = "switchboard-utils"
-version = "0.2.1"
+name = "switchboard-solana"
+version = "0.28.20"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ac1d68193aa1669e34d16087db0f96e6597d2f78868378aabc1387b8b29172e"
+checksum = "2a978513e0d3f54444698efb1737c8bcf366e2131e03ccfdf24c22210b8d755c"
 dependencies = [
+ "anchor-client",
+ "anchor-lang",
+ "anchor-spl",
  "bincode",
- "borsh 0.9.3",
  "bytemuck",
- "byteorder",
- "quick-protobuf",
+ "chrono",
+ "cron",
+ "hex",
  "rust_decimal",
- "rust_decimal_macros",
+ "sgx-quote",
+ "solana-address-lookup-table-program",
+ "solana-client",
  "solana-program",
- "switchboard-protos",
+ "superslice",
+ "switchboard-common",
+ "tokio",
+ "url 2.4.1",
 ]
 
 [[package]]
-name = "switchboard-v2"
-version = "0.4.0"
+name = "switchboard-utils"
+version = "0.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4b81886169f446e22edc18ead7addd9ebd141c39bf2286cb37943c92cd3af724"
+checksum = "4ac1d68193aa1669e34d16087db0f96e6597d2f78868378aabc1387b8b29172e"
 dependencies = [
- "anchor-lang",
- "anchor-spl",
+ "bincode",
+ "borsh 0.9.3",
  "bytemuck",
+ "byteorder",
+ "quick-protobuf",
  "rust_decimal",
+ "rust_decimal_macros",
  "solana-program",
- "superslice",
+ "switchboard-protos",
 ]
 
 [[package]]
@@ -7951,7 +8036,7 @@ dependencies = [
  "data-encoding",
  "der-parser",
  "lazy_static",
- "nom",
+ "nom 7.1.3",
  "oid-registry",
  "rusticata-macros",
  "thiserror",
diff --git a/programs/openbook-v2/Cargo.toml b/programs/openbook-v2/Cargo.toml
index 418faee45..6e9c9b202 100644
--- a/programs/openbook-v2/Cargo.toml
+++ b/programs/openbook-v2/Cargo.toml
@@ -37,8 +37,10 @@ pyth-sdk-solana = { workspace = true }
 solana-program = { workspace = true }
 solana-sdk = { workspace = true, default-features = false, optional = true }
 static_assertions = "1.1"
-switchboard-program = ">=0.2.0"
-switchboard-v2 = "0.4.0"
+
+switchboard-program = "0.2.0"
+# note: switchboard-common 0.8.19 is broken, so we lock 0.8.18
+switchboard-v2 = { package = "switchboard-solana", version = "0.28" }
 
 [dev-dependencies]
 async-trait = "0.1.52"