chore: pull monorepo changes (#113)
* Project import generated by Copybara. GitOrigin-RevId: 20a39c08b5f2bd4c44c08303a3c29290d20005ce * chore: Update pnpm lockfile --------- Co-authored-by: Copybara <copybara@example.com> Co-authored-by: gallynaut <gallynaut@users.noreply.github.com>
This commit is contained in:
parent
33cf78d45a
commit
00eca445c9
|
@ -1,42 +0,0 @@
|
|||
# Switchboard x Solana Examples
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Product</th>
|
||||
<th>Examples</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Feeds</td>
|
||||
<td>
|
||||
<ol>
|
||||
<li><a href="./feeds/01_feed_client/README.md">Data Feed Client</a>: An example showing how to read a Switchboard data feed and history buffer</li>
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>VRF</td>
|
||||
<td>
|
||||
<ol>
|
||||
<li><a href="./vrf/01_vrf_client/README.md">VRF Client</a>: An example program showing how to request and consume randomness</li>
|
||||
<li><a href="./vrf/02_vrf_flip/README.md">VRF Flip</a>: A full example for simulating a heads or tails coin flip with a sample web application</li>
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Functions</td>
|
||||
<td>
|
||||
<ol>
|
||||
<li><a href="./functions/01_basic_oracle/README.md">Basic Function Example</a>: An example program for executing a custom function</li>
|
||||
<li><a href="./functions/02_vrf_function/README.md">VRF Function</a>: An example showing how to use a custom SGX function to publish randomness on-chain</li>
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Workers</td>
|
||||
<td>
|
||||
<ol>
|
||||
<li><a href="./workers/01_basic_worker/README.md">Basic Worker</a>: An example for building a custom worker with Switchboard</li>
|
||||
</ol>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
|
@ -12,9 +12,9 @@ basic_oracle = "BkTMjFhosJ1xKtLMV2xchGtnTDBABLJ45aXzs7x9FdeX"
|
|||
basic_oracle = "BkTMjFhosJ1xKtLMV2xchGtnTDBABLJ45aXzs7x9FdeX"
|
||||
|
||||
[provider]
|
||||
# cluster = "https://api.devnet.solana.com"
|
||||
cluster = "https://api.devnet.solana.com"
|
||||
# wallet = "~/switchboard_environments_v2/devnet/upgrade_authority/upgrade_authority.json"
|
||||
cluster = "Localnet"
|
||||
# cluster = "Localnet"
|
||||
wallet = "~/.config/solana/id.json"
|
||||
|
||||
# cluster = "devnet"
|
||||
|
|
|
@ -4230,9 +4230,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "switchboard-solana"
|
||||
version = "0.9.1"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7b04503c979165d8ad5efe21bb63b9978cb70103f208fab1339aae7c38e94c62"
|
||||
checksum = "3f5bea97fd6f8e8ce6872148000df6aaba5a45597f4342b95b1fef498aaf2566"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
|
|
|
@ -17,10 +17,7 @@ cpi = ["no-entrypoint"]
|
|||
default = []
|
||||
|
||||
[dependencies]
|
||||
switchboard-solana = { version = "=0.9.1" }
|
||||
# switchboard-solana = { version = "0.9.1", path = "../../../rust/switchboard-solana" }
|
||||
switchboard-solana = { version = "=0.9.5" }
|
||||
# switchboard-solana = { version = "0.9.4", path = "../../../rust/switchboard-solana" }
|
||||
bytemuck = "^1"
|
||||
anchor-lang = { version = "0.28.0", features = [
|
||||
"init-if-needed",
|
||||
"allow-missing-optionals"
|
||||
] }
|
||||
anchor-lang = { version = "0.28.0" }
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
debug/
|
||||
target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
# Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
|
|
|
@ -14,4 +14,5 @@ futures = "0.3"
|
|||
serde = "^1"
|
||||
serde_json = "^1"
|
||||
switchboard-utils = { version = "0.8.0" }
|
||||
switchboard-solana = { version = "0.9.1", path = "../../../rust/switchboard-solana" }
|
||||
# switchboard-solana = { version = "0.9.4", path = "../../../rust/switchboard-solana" }
|
||||
switchboard-solana = "0.9.5"
|
||||
|
|
|
@ -26,6 +26,6 @@ WORKDIR /sgx
|
|||
COPY --from=builder /sgx/app /sgx
|
||||
|
||||
# Get the measurement from the enclave
|
||||
RUN /get_measurement.sh
|
||||
RUN /get_measurement.sh && cat /measurement.txt
|
||||
|
||||
ENTRYPOINT ["bash", "/boot.sh"]
|
||||
|
|
|
@ -15,10 +15,6 @@ pub struct RefreshPrices<'info> {
|
|||
function.load()?.validate(
|
||||
&enclave_signer.to_account_info()
|
||||
)? @ BasicOracleError::FunctionValidationFailed
|
||||
// FunctionAccountData::validate(
|
||||
// &function.to_account_info(),
|
||||
// &enclave_signer.to_account_info()
|
||||
// )? @ BasicOracleError::FunctionValidationFailed
|
||||
)]
|
||||
pub function: AccountLoader<'info, FunctionAccountData>,
|
||||
pub enclave_signer: Signer<'info>,
|
||||
|
|
|
@ -76,4 +76,4 @@ async fn main() {
|
|||
// // Finally, emit the signed quote and partially signed transaction to the functionRunner oracle
|
||||
// // The functionRunner oracle will use the last outputted word to stdout as the serialized result. This is what gets executed on-chain.
|
||||
// runner.emit(ixs).await.unwrap();
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ url = "https://api.apr.dev"
|
|||
[provider]
|
||||
# cluster = "Localnet"
|
||||
cluster = "https://api.devnet.solana.com"
|
||||
wallet = "~/.config/solana/id.json"
|
||||
wallet = "~/switchboard_environments_v2/devnet/upgrade_authority/upgrade_authority.json"
|
||||
|
||||
[scripts]
|
||||
test = "pnpm exec ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
|
||||
|
@ -44,4 +44,4 @@ address = "sbattyXrzedoNATfc4L31wC9Mhxsi1BmFhTiN8gDshx"
|
|||
address = "5ExuoQR69trmKQfB95fDsUGsUrrChbGq9PFgt8qouncz"
|
||||
|
||||
[[test.validator.clone]] # sb devnet programState
|
||||
address = "5MFs7RGTjLi1wtKNBFRtuLipCkkjs4YQwRRU9sjnbQbS"
|
||||
address = "5MFs7RGTjLi1wtKNBFRtuLipCkkjs4YQwRRU9sjnbQbS"
|
|
@ -267,7 +267,7 @@ checksum = "a125e4b0cc046cfec58f5aa25038e34cf440151d58f0db3afc55308251fe936d"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"bs58 0.5.0",
|
||||
"heck",
|
||||
"heck 0.3.3",
|
||||
"proc-macro2 1.0.64",
|
||||
"quote 1.0.29",
|
||||
"serde",
|
||||
|
@ -856,6 +856,15 @@ version = "1.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
|
||||
|
||||
[[package]]
|
||||
name = "bytestring"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "238e4886760d98c4f899360c834fa93e62cf7f721ac3c2da375cbdf4b8679aae"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "caps"
|
||||
version = "0.5.5"
|
||||
|
@ -1152,9 +1161,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.20.1"
|
||||
version = "0.20.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944"
|
||||
checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"darling_macro",
|
||||
|
@ -1162,9 +1171,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "darling_core"
|
||||
version = "0.20.1"
|
||||
version = "0.20.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb"
|
||||
checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621"
|
||||
dependencies = [
|
||||
"fnv",
|
||||
"ident_case",
|
||||
|
@ -1176,9 +1185,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "darling_macro"
|
||||
version = "0.20.1"
|
||||
version = "0.20.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a"
|
||||
checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"
|
||||
dependencies = [
|
||||
"darling_core",
|
||||
"quote 1.0.29",
|
||||
|
@ -1440,6 +1449,12 @@ version = "0.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da"
|
||||
|
||||
[[package]]
|
||||
name = "fixedbitset"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.26"
|
||||
|
@ -1456,6 +1471,21 @@ version = "1.0.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
|
||||
dependencies = [
|
||||
"foreign-types-shared",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foreign-types-shared"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.0"
|
||||
|
@ -1688,6 +1718,12 @@ dependencies = [
|
|||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
|
@ -1825,6 +1861,19 @@ dependencies = [
|
|||
"tokio-rustls",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-tls"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"hyper",
|
||||
"native-tls",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
version = "0.1.57"
|
||||
|
@ -1972,6 +2021,18 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonpath-rust"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7ea2fa3ba7d1404aa6b094aceec1d49106ec0110b40c40b76cedae148837a3b"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"regex",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jsonrpc-core"
|
||||
version = "18.0.0"
|
||||
|
@ -2179,6 +2240,30 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "multimap"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"
|
||||
|
||||
[[package]]
|
||||
name = "native-tls"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"log",
|
||||
"openssl",
|
||||
"openssl-probe",
|
||||
"openssl-sys",
|
||||
"schannel",
|
||||
"security-framework",
|
||||
"security-framework-sys",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.26.2"
|
||||
|
@ -2401,12 +2486,50 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"openssl-macros",
|
||||
"openssl-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-macros"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.64",
|
||||
"quote 1.0.29",
|
||||
"syn 2.0.25",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl-probe"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
|
||||
|
||||
[[package]]
|
||||
name = "openssl-sys"
|
||||
version = "0.9.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
"pkg-config",
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.5.1"
|
||||
|
@ -2509,6 +2632,60 @@ dependencies = [
|
|||
"num",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f73935e4d55e2abf7f130186537b19e7a4abc886a0252380b59248af473a3fc9"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_derive"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aef623c9bbfa0eedf5a0efba11a5ee83209c326653ca31ff019bec3a95bfff2b"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_generator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_generator"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3e8cba4ec22bada7fc55ffe51e2deb6a0e0db2d0b7ab0b103acc80d2510c190"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_meta",
|
||||
"proc-macro2 1.0.64",
|
||||
"quote 1.0.29",
|
||||
"syn 2.0.25",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_meta"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a01f71cb40bd8bb94232df14b946909e14660e33fc05db3e50ae2a82d7ea0ca0"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"pest",
|
||||
"sha2 0.10.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "petgraph"
|
||||
version = "0.6.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4dd7d28ee937e54fe3080c91faa1c3a46c06de6252988a7f4592ba2310ef22a4"
|
||||
dependencies = [
|
||||
"fixedbitset",
|
||||
"indexmap 1.9.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.10"
|
||||
|
@ -2558,9 +2735,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "portable-atomic"
|
||||
version = "1.3.3"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "767eb9f07d4a5ebcb39bbf2d452058a93c011373abf6832e24194a1c3f004794"
|
||||
checksum = "d220334a184db82b31b83f5ff093e3315280fb2b6bbc032022b2304a509aab7a"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
|
@ -2568,6 +2745,16 @@ version = "0.2.17"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
|
||||
[[package]]
|
||||
name = "prettyplease"
|
||||
version = "0.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.64",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "0.1.5"
|
||||
|
@ -2605,6 +2792,62 @@ dependencies = [
|
|||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"prost-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-build"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"heck 0.4.1",
|
||||
"itertools",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"multimap",
|
||||
"petgraph",
|
||||
"prettyplease",
|
||||
"prost",
|
||||
"prost-types",
|
||||
"pulldown-cmark",
|
||||
"pulldown-cmark-to-cmark",
|
||||
"regex",
|
||||
"syn 1.0.109",
|
||||
"tempfile",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-derive"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools",
|
||||
"proc-macro2 1.0.64",
|
||||
"quote 1.0.29",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "prost-types"
|
||||
version = "0.11.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13"
|
||||
dependencies = [
|
||||
"prost",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ptr_meta"
|
||||
version = "0.1.4"
|
||||
|
@ -2625,6 +2868,26 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pulldown-cmark"
|
||||
version = "0.9.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"memchr",
|
||||
"unicase",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pulldown-cmark-to-cmark"
|
||||
version = "10.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0194e6e1966c23cc5fd988714f85b18d548d773e81965413555d96569931833d"
|
||||
dependencies = [
|
||||
"pulldown-cmark",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "qstring"
|
||||
version = "0.7.2"
|
||||
|
@ -2794,6 +3057,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"futures",
|
||||
"switchboard-solana",
|
||||
"switchboard-utils",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
|
@ -2863,9 +3127,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "regex-automata"
|
||||
version = "0.3.2"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "83d3daa6976cffb758ec878f108ba0e062a45b2d6ca3a2cca965338855476caf"
|
||||
checksum = "39354c10dd07468c2e73926b23bb9c2caca74c5501e38a35da70406f1d923310"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
|
@ -2904,10 +3168,12 @@ dependencies = [
|
|||
"http-body",
|
||||
"hyper",
|
||||
"hyper-rustls",
|
||||
"hyper-tls",
|
||||
"ipnet",
|
||||
"js-sys",
|
||||
"log",
|
||||
"mime",
|
||||
"native-tls",
|
||||
"once_cell",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
|
@ -2917,6 +3183,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
"tokio-rustls",
|
||||
"tokio-util",
|
||||
"tower-service",
|
||||
|
@ -3210,9 +3477,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.100"
|
||||
version = "1.0.102"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f1e14e89be7aa4c4b78bdbdc9eb5bf8517829a600ae8eaa39a6e1d960b5185c"
|
||||
checksum = "b5062a995d481b2308b6064e9af76011f2921c35f97b0468811ed9f6cd91dfed"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
|
@ -4236,6 +4503,18 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f"
|
||||
|
||||
[[package]]
|
||||
name = "switchboard-common"
|
||||
version = "0.8.5"
|
||||
dependencies = [
|
||||
"getrandom 0.2.10",
|
||||
"hex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sgx-quote",
|
||||
"sha2 0.10.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "switchboard-common"
|
||||
version = "0.8.5"
|
||||
|
@ -4252,9 +4531,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "switchboard-solana"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98de2a369288d08e418ef86a6328f8d8f32e461c025d736f03ba163a7b822749"
|
||||
version = "0.9.2"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
|
@ -4270,10 +4547,32 @@ dependencies = [
|
|||
"solana-client",
|
||||
"solana-program",
|
||||
"superslice",
|
||||
"switchboard-common",
|
||||
"switchboard-common 0.8.5",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "switchboard-utils"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e18a6e7377b936fbd485fa641e6c2c7ad37e03336da90ef554c81df25369ecac"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"bytestring",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"jsonpath-rust",
|
||||
"prost",
|
||||
"prost-build",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"serde_json",
|
||||
"switchboard-common 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"tokio",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "0.15.44"
|
||||
|
@ -4486,6 +4785,16 @@ dependencies = [
|
|||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-native-tls"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
|
||||
dependencies = [
|
||||
"native-tls",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-rustls"
|
||||
version = "0.23.4"
|
||||
|
@ -4555,9 +4864,9 @@ checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b"
|
|||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.19.12"
|
||||
version = "0.19.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c500344a19072298cd05a7224b3c0c629348b78692bf48466c5238656e315a78"
|
||||
checksum = "5f8751d9c1b03c6500c387e96f81f815a4f8e72d142d2d4a9ffa6fedd51ddee7"
|
||||
dependencies = [
|
||||
"indexmap 2.0.0",
|
||||
"toml_datetime",
|
||||
|
@ -4637,6 +4946,21 @@ version = "1.16.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
|
||||
dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-bidi"
|
||||
version = "0.3.13"
|
||||
|
@ -4740,6 +5064,12 @@ version = "1.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be"
|
||||
|
||||
[[package]]
|
||||
name = "vcpkg"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
|
@ -4880,6 +5210,17 @@ dependencies = [
|
|||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
|
||||
dependencies = [
|
||||
"either",
|
||||
"libc",
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
|
@ -5069,9 +5410,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a"
|
|||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.4.9"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81a2094c43cc94775293eaa0e499fbc30048a6d824ac82c0351a8c0bf9112529"
|
||||
checksum = "81fac9742fd1ad1bd9643b991319f72dd031016d44b77039a26977eb667141e7"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
lib
|
|
@ -0,0 +1 @@
|
|||
*.tsbuildinfo
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2022 Switchboard
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,42 @@
|
|||
# Switchboard V2 Lite
|
||||
|
||||
A lightweight library to decode and parse aggregator accounts
|
||||
|
||||
[![npm](https://img.shields.io/npm/v/@switchboard-xyz/sbv2-lite)](https://www.npmjs.com/package/@switchboard-xyz/sbv2-lite)
|
||||
[![twitter](https://badgen.net/twitter/follow/switchboardxyz)](https://twitter.com/switchboardxyz)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm i @switchboard-xyz/sbv2-lite
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import SwitchboardProgram from "@switchboard-xyz/sbv2-lite";
|
||||
|
||||
//
|
||||
|
||||
const sbv2 = await SwitchboardProgram.loadDevnet();
|
||||
|
||||
// SOL_USD Aggregator https://switchboard.xyz/explorer
|
||||
const solAggregator = new anchor.web3.PublicKey(
|
||||
"GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR"
|
||||
);
|
||||
|
||||
const accountInfo = await sbv2.program.provider.connection.getAccountInfo(
|
||||
solAggregator
|
||||
);
|
||||
if (!accountInfo) {
|
||||
throw new Error(`failed to fetch account info`);
|
||||
}
|
||||
|
||||
// Get latest value if its been updated in the last 300 seconds
|
||||
const latestResult = sbv2.decodeLatestAggregatorValue(accountInfo, 300);
|
||||
if (latestResult === null) {
|
||||
throw new Error(`failed to fetch latest result for aggregator`);
|
||||
}
|
||||
console.log(`latestResult: ${latestResult}`);
|
||||
// latestResult: 105.673205
|
||||
```
|
|
@ -0,0 +1,58 @@
|
|||
{
|
||||
"name": "@switchboard-xyz/sbv2-lite",
|
||||
"version": "0.2.1",
|
||||
"description": "",
|
||||
"private": false,
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/switchboard-xyz/sbv2-solana",
|
||||
"directory": "javascript/sbv2-lite"
|
||||
},
|
||||
"homepage": "https://docs.switchboard.xyz",
|
||||
"files": [
|
||||
"lib",
|
||||
"src"
|
||||
],
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./lib/esm/index.js",
|
||||
"require": "./lib/cjs/index.js"
|
||||
}
|
||||
},
|
||||
"main": "lib/cjs/index.js",
|
||||
"module": "lib/esm/index.js",
|
||||
"types": "lib/cjs/index.d.ts",
|
||||
"scripts": {
|
||||
"docgen": "typedoc --entryPoints src/index.ts --out ../../website/static/api/ts-lite",
|
||||
"test": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'tests/**/*.ts'",
|
||||
"build": "shx rm -rf lib && tsc && tsc -p tsconfig.cjs.json",
|
||||
"watch": "tsc -p tsconfig.cjs.json --watch",
|
||||
"prepublishOnly": "pnpm build && pnpm test"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@coral-xyz/anchor": "^0.28.0",
|
||||
"big.js": "^6.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/big.js": "^6.1.3",
|
||||
"@types/chai": "^4.3.1",
|
||||
"@types/mocha": "^9.1.0",
|
||||
"@types/node": "^18.7.18",
|
||||
"assert": "^2.0.0",
|
||||
"chai": "^4.3.6",
|
||||
"mocha": "^9.2.2",
|
||||
"shx": "^0.3.4",
|
||||
"ts-node": "^10.9.1",
|
||||
"typedoc": "^0.23.8",
|
||||
"typescript": "^5.1.6"
|
||||
},
|
||||
"pre-commit": [
|
||||
"build"
|
||||
],
|
||||
"engines": {
|
||||
"npm": ">=7.0.0",
|
||||
"node": ">=16.0.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,243 @@
|
|||
import type { SwitchboardV2 } from "./switchboard_v2";
|
||||
|
||||
import * as anchor from "@coral-xyz/anchor";
|
||||
import Big from "big.js";
|
||||
|
||||
export * from "./switchboard_v2";
|
||||
|
||||
// import idl from "./idl.json";
|
||||
|
||||
// export const IDL: anchor.Idl = idl;
|
||||
|
||||
// export const IDL: anchor.Idl = await import("./idl.json", {
|
||||
// assert: { type: "json" },
|
||||
// });
|
||||
|
||||
/**
|
||||
* Check if a transaction object is a VersionedTransaction or not
|
||||
*
|
||||
* @param tx
|
||||
* @returns bool
|
||||
*/
|
||||
export const isVersionedTransaction = (
|
||||
tx
|
||||
): tx is anchor.web3.VersionedTransaction => {
|
||||
return "version" in tx;
|
||||
};
|
||||
|
||||
export class AnchorWallet implements anchor.Wallet {
|
||||
constructor(readonly payer: anchor.web3.Keypair) {}
|
||||
|
||||
get publicKey(): anchor.web3.PublicKey {
|
||||
return this.payer.publicKey;
|
||||
}
|
||||
|
||||
async signTransaction<
|
||||
T extends anchor.web3.Transaction | anchor.web3.VersionedTransaction
|
||||
>(tx: T): Promise<T> {
|
||||
if (isVersionedTransaction(tx)) {
|
||||
tx.sign([this.payer]);
|
||||
} else {
|
||||
tx.partialSign(this.payer);
|
||||
}
|
||||
|
||||
return tx;
|
||||
}
|
||||
|
||||
async signAllTransactions<
|
||||
T extends anchor.web3.Transaction | anchor.web3.VersionedTransaction
|
||||
>(txs: T[]): Promise<T[]> {
|
||||
return txs.map((t) => {
|
||||
if (isVersionedTransaction(t)) {
|
||||
t.sign([this.payer]);
|
||||
} else {
|
||||
t.partialSign(this.payer);
|
||||
}
|
||||
return t;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** A Switchboard V2 wrapper to assist in decoding onchain accounts */
|
||||
export default class SwitchboardProgram {
|
||||
/**
|
||||
* Switchboard Mainnet Program ID
|
||||
* SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f
|
||||
*/
|
||||
public static oracleProgramId = new anchor.web3.PublicKey(
|
||||
"SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f"
|
||||
);
|
||||
|
||||
/**
|
||||
* Default confirmation options for fetching Solana data
|
||||
*/
|
||||
public static defaultConfirmOptions: anchor.web3.ConfirmOptions = {
|
||||
commitment: "confirmed",
|
||||
};
|
||||
|
||||
/**
|
||||
* Switchboard Anchor program object
|
||||
*/
|
||||
public program: anchor.Program<SwitchboardV2>;
|
||||
|
||||
/**
|
||||
* Selected Solana cluster
|
||||
*/
|
||||
public cluster: "devnet" | "mainnet-beta";
|
||||
|
||||
constructor(
|
||||
program: anchor.Program<SwitchboardV2>,
|
||||
cluster: "devnet" | "mainnet-beta"
|
||||
) {
|
||||
this.program = program;
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Switchboard program
|
||||
* @param connection optional connection object if not using the default endpoints
|
||||
* @param confirmOptions optional confirmation options. defaults to commitment level 'confirmed'
|
||||
*/
|
||||
public static async load(
|
||||
connection = new anchor.web3.Connection(
|
||||
anchor.web3.clusterApiUrl("devnet")
|
||||
),
|
||||
confirmOptions = SwitchboardProgram.defaultConfirmOptions
|
||||
): Promise<SwitchboardProgram> {
|
||||
const provider = new anchor.AnchorProvider(
|
||||
connection,
|
||||
new AnchorWallet(
|
||||
anchor.web3.Keypair.fromSeed(new Uint8Array(32).fill(1))
|
||||
),
|
||||
confirmOptions
|
||||
);
|
||||
|
||||
const anchorIdl = await anchor.Program.fetchIdl(
|
||||
SwitchboardProgram.oracleProgramId,
|
||||
provider
|
||||
);
|
||||
if (!anchorIdl) {
|
||||
throw new Error(
|
||||
`failed to read devnet idl for ${SwitchboardProgram.oracleProgramId}`
|
||||
);
|
||||
}
|
||||
|
||||
const program = new anchor.Program(
|
||||
anchorIdl,
|
||||
SwitchboardProgram.oracleProgramId,
|
||||
provider
|
||||
);
|
||||
|
||||
return new SwitchboardProgram(
|
||||
program as unknown as anchor.Program<SwitchboardV2>,
|
||||
"devnet"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Switchboard mainnet-beta program
|
||||
* @param connection optional connection object if not using the default endpoints
|
||||
* @param confirmOptions optional confirmation options. defaults to commitment level 'confirmed'
|
||||
*/
|
||||
public static async loadMainnet(
|
||||
connection = new anchor.web3.Connection(
|
||||
anchor.web3.clusterApiUrl("mainnet-beta")
|
||||
),
|
||||
confirmOptions = SwitchboardProgram.defaultConfirmOptions
|
||||
): Promise<SwitchboardProgram> {
|
||||
return SwitchboardProgram.load(connection, confirmOptions);
|
||||
}
|
||||
|
||||
/** Parse an aggregators account data and return the latest confirmed result if valid
|
||||
* @param aggregator an aggregators deserialized account data
|
||||
* @param maxStaleness the maximum duration in seconds before a result is considered invalid. Defaults to 0 which ignores any checks
|
||||
* @returns latest confirmed result as a big.js or null if the latest confirmed round has insufficient oracle responses or data is too stale
|
||||
*/
|
||||
private getLatestAggregatorValue(
|
||||
aggregator: any,
|
||||
maxStaleness = 0
|
||||
): Big | null {
|
||||
if ((aggregator.latestConfirmedRound?.numSuccess ?? 0) === 0) {
|
||||
return null;
|
||||
}
|
||||
if (maxStaleness !== 0) {
|
||||
const now = new anchor.BN(Date.now() / 1000);
|
||||
const latestRoundTimestamp: anchor.BN =
|
||||
aggregator.latestConfirmedRound.roundOpenTimestamp;
|
||||
const staleness = now.sub(latestRoundTimestamp);
|
||||
if (staleness.gt(new anchor.BN(maxStaleness))) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const mantissa = new Big(
|
||||
aggregator.latestConfirmedRound.result.mantissa.toString()
|
||||
);
|
||||
const scale = aggregator.latestConfirmedRound.result.scale;
|
||||
const oldDp = Big.DP;
|
||||
Big.DP = 20;
|
||||
const result: Big = mantissa.div(new Big(10).pow(scale));
|
||||
Big.DP = oldDp;
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Fetch and decode an aggregator account
|
||||
* @param aggregatorPubkey the aggregator's public key
|
||||
* @param commitment optional connection commitment level
|
||||
* @returns deserialized aggregator account, as specified by the Switchboard IDL
|
||||
*/
|
||||
public async fetchAggregator(
|
||||
aggregatorPubkey: anchor.web3.PublicKey,
|
||||
commitment?: anchor.web3.Commitment
|
||||
): Promise<any> {
|
||||
const aggregator: any =
|
||||
await this.program.account.aggregatorAccountData?.fetch(
|
||||
aggregatorPubkey,
|
||||
commitment
|
||||
);
|
||||
aggregator.ebuf = undefined;
|
||||
return aggregator;
|
||||
}
|
||||
|
||||
/** Fetch and decode an aggregator's latest confirmed value if valid
|
||||
* @param aggregatorPubkey the aggregator's public key
|
||||
* @param commitment optional connection commitment level
|
||||
* @param maxStaleness the maximum duration in seconds before a result is considered invalid. Defaults to 0 which ignores any checks
|
||||
* @returns latest confirmed result as a big.js or null if the latest confirmed round has insufficient oracle responses or data is too stale
|
||||
*/
|
||||
public async fetchAggregatorLatestValue(
|
||||
aggregatorPubkey: anchor.web3.PublicKey,
|
||||
commitment?: anchor.web3.Commitment,
|
||||
maxStaleness = 0
|
||||
): Promise<Big | null> {
|
||||
const aggregator = await this.fetchAggregator(aggregatorPubkey, commitment);
|
||||
return this.getLatestAggregatorValue(aggregator, maxStaleness);
|
||||
}
|
||||
|
||||
/** Decode an aggregator's account info
|
||||
* @param accountInfo the aggregatror's account info
|
||||
* @returns deserialized aggregator account, as specified by the Switchboard IDL
|
||||
*/
|
||||
public decodeAggregator(accountInfo: anchor.web3.AccountInfo<Buffer>): any {
|
||||
const coder = new anchor.BorshAccountsCoder(this.program.idl);
|
||||
const aggregator: any = coder.decode(
|
||||
"AggregatorAccountData",
|
||||
accountInfo?.data
|
||||
);
|
||||
aggregator.ebuf = undefined;
|
||||
return aggregator;
|
||||
}
|
||||
|
||||
/** Decode an aggregator and get the latest confirmed round
|
||||
* @param accountInfo the aggregator's account info
|
||||
* @param maxStaleness the maximum duration in seconds before a result is considered invalid. Defaults to 0 which ignores any checks
|
||||
* @returns latest confirmed result as a big.js or null if the latest confirmed round has insufficient oracle responses or data is too stale
|
||||
*/
|
||||
public decodeLatestAggregatorValue(
|
||||
accountInfo: anchor.web3.AccountInfo<Buffer>,
|
||||
maxStaleness = 0
|
||||
): Big | null {
|
||||
const aggregator = this.decodeAggregator(accountInfo);
|
||||
return this.getLatestAggregatorValue(aggregator, maxStaleness);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,249 @@
|
|||
import SwitchboardProgram from "../src";
|
||||
|
||||
import * as anchor from "@coral-xyz/anchor";
|
||||
import { strict as assert } from "assert";
|
||||
import Big from "big.js";
|
||||
|
||||
describe("Switchboard V2 Lite Test", () => {
|
||||
let sbv2: SwitchboardProgram;
|
||||
|
||||
before(async () => {
|
||||
// TODO: Add try catch block to check devnet environment accounts
|
||||
sbv2 = await SwitchboardProgram.loadMainnet();
|
||||
});
|
||||
|
||||
// it("fetches and decodes SOL/USD mainnet aggregator", async () => {
|
||||
// const accountInfo = await sbv2.program.provider.connection.getAccountInfo(
|
||||
// solAggregatorPubkey
|
||||
// );
|
||||
// if (!accountInfo) {
|
||||
// throw new Error(`failed to fetch account info`);
|
||||
// }
|
||||
|
||||
// // Get latest value if its been updated in the last 300 seconds
|
||||
// const latestResult = sbv2.decodeLatestAggregatorValue(accountInfo, 300);
|
||||
// if (latestResult === null) {
|
||||
// throw new Error(`failed to fetch latest result for aggregator`);
|
||||
// }
|
||||
// assert(latestResult instanceof Big, "latest result is not a big.js object");
|
||||
// assert(
|
||||
// latestResult.toNumber() >= 0,
|
||||
// "latest result is less than or equal to 0"
|
||||
// );
|
||||
// });
|
||||
|
||||
it("decodes SOL/USD aggregator", async () => {
|
||||
const aggregator = sbv2.decodeAggregator(solAggregatorAccountInfo);
|
||||
|
||||
const latestResult = sbv2.decodeLatestAggregatorValue(
|
||||
solAggregatorAccountInfo
|
||||
);
|
||||
if (latestResult === null) {
|
||||
throw new Error(`failed to fetch latest result for aggregator`);
|
||||
}
|
||||
assert(latestResult instanceof Big, "latest result is not a big.js object");
|
||||
assert(
|
||||
latestResult.toNumber() === 104.967865328125,
|
||||
"latest result is not equal to expected value of 104.967865328125"
|
||||
);
|
||||
});
|
||||
|
||||
it("fails to decode stale aggregator", async () => {
|
||||
const latestResult = sbv2.decodeLatestAggregatorValue(
|
||||
solAggregatorAccountInfo,
|
||||
300
|
||||
);
|
||||
assert(
|
||||
latestResult === null,
|
||||
"aggregator should return null if value is more than 300s old"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const solAggregatorAccountInfo: anchor.web3.AccountInfo<Buffer> = {
|
||||
data: Buffer.from([
|
||||
217, 230, 65, 101, 201, 162, 27, 125, 83, 79, 76, 95, 85, 83, 68, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
254, 83, 137, 67, 40, 165, 83, 155, 80, 27, 250, 104, 141, 83, 132, 233, 58,
|
||||
21, 213, 37, 206, 133, 134, 11, 167, 160, 205, 213, 5, 110, 232, 148, 33,
|
||||
220, 163, 22, 231, 144, 81, 75, 91, 144, 77, 37, 153, 183, 156, 217, 79, 99,
|
||||
143, 60, 146, 199, 29, 200, 242, 61, 250, 67, 81, 245, 189, 99, 3, 0, 0, 0,
|
||||
2, 0, 0, 0, 1, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 88, 96, 98, 0, 0, 0, 0, 0,
|
||||
232, 48, 130, 157, 109, 192, 148, 28, 222, 236, 197, 193, 185, 28, 120, 114,
|
||||
223, 110, 18, 68, 255, 63, 82, 34, 211, 20, 254, 125, 247, 195, 0, 190, 2,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 216, 184, 200, 7, 0, 0, 0, 0, 108, 88, 96, 98, 0, 0,
|
||||
0, 0, 226, 211, 65, 91, 173, 186, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0,
|
||||
0, 0, 221, 178, 249, 215, 167, 146, 206, 248, 90, 0, 0, 0, 0, 0, 28, 0, 0,
|
||||
0, 111, 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 45, 134,
|
||||
16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 32, 199, 151, 80,
|
||||
108, 73, 163, 195, 33, 198, 249, 191, 21, 162, 83, 134, 106, 247, 198, 82,
|
||||
36, 86, 177, 202, 241, 190, 232, 37, 55, 41, 29, 163, 222, 100, 183, 122,
|
||||
190, 54, 183, 109, 12, 229, 164, 70, 125, 112, 97, 247, 188, 14, 113, 24,
|
||||
176, 15, 175, 208, 157, 159, 107, 244, 41, 209, 227, 55, 231, 82, 60, 73, 4,
|
||||
36, 138, 53, 16, 25, 166, 74, 76, 144, 202, 226, 183, 187, 50, 183, 15, 179,
|
||||
60, 128, 97, 204, 166, 164, 161, 196, 113, 97, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
216, 184, 200, 7, 0, 0, 0, 0, 108, 88, 96, 98, 0, 0, 0, 0, 226, 211, 65, 91,
|
||||
173, 186, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0, 0, 221, 178, 249,
|
||||
215, 167, 146, 206, 248, 90, 0, 0, 0, 0, 0, 28, 0, 0, 0, 111, 0, 16, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 45, 134, 16, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 32, 199, 151, 80, 108, 73, 163, 195, 33,
|
||||
198, 249, 191, 21, 162, 83, 134, 106, 247, 198, 82, 36, 86, 177, 202, 241,
|
||||
190, 232, 37, 55, 41, 29, 163, 222, 100, 183, 122, 190, 54, 183, 109, 12,
|
||||
229, 164, 70, 125, 112, 97, 247, 188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 93, 34, 177, 51, 25, 116, 102, 136, 188, 191,
|
||||
157, 71, 47, 158, 238, 28, 135, 110, 82, 134, 175, 95, 239, 3, 109, 92, 42,
|
||||
64, 56, 180, 32, 227, 236, 51, 157, 192, 153, 42, 190, 45, 255, 202, 12,
|
||||
242, 92, 15, 11, 14, 177, 185, 33, 246, 102, 130, 36, 106, 21, 161, 247,
|
||||
205, 155, 14, 124, 142, 3, 168, 151, 84, 181, 87, 173, 190, 106, 59, 132,
|
||||
136, 154, 229, 166, 218, 27, 254, 15, 12, 81, 31, 191, 153, 61, 184, 173,
|
||||
48, 160, 244, 41, 218, 75, 26, 56, 127, 150, 233, 41, 239, 214, 129, 194,
|
||||
98, 70, 104, 108, 76, 201, 199, 1, 114, 138, 67, 214, 204, 45, 81, 248, 201,
|
||||
102, 170, 130, 118, 159, 46, 111, 203, 207, 41, 179, 92, 83, 44, 137, 83,
|
||||
37, 172, 244, 190, 204, 148, 44, 144, 244, 196, 3, 215, 109, 102, 136, 14,
|
||||
91, 35, 45, 207, 101, 215, 32, 16, 32, 145, 151, 95, 213, 34, 67, 159, 141,
|
||||
241, 95, 34, 37, 27, 250, 181, 234, 77, 97, 0, 151, 71, 1, 11, 13, 80, 72,
|
||||
110, 160, 244, 210, 106, 163, 148, 141, 44, 186, 37, 238, 148, 24, 174, 95,
|
||||
4, 43, 72, 73, 105, 234, 83, 27, 132, 156, 157, 168, 18, 141, 66, 18, 10,
|
||||
180, 34, 74, 131, 207, 12, 238, 147, 14, 127, 12, 189, 235, 223, 218, 207,
|
||||
136, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 145, 18, 6, 17, 49, 126, 4, 68, 220, 147, 77,
|
||||
236, 138, 17, 39, 208, 107, 24, 211, 125, 170, 224, 128, 61, 223, 155, 37,
|
||||
149, 160, 11, 221, 174, 189, 225, 195, 114, 46, 165, 44, 213, 21, 155, 29,
|
||||
127, 14, 92, 73, 55, 26, 92, 23, 240, 56, 241, 200, 215, 196, 7, 201, 132,
|
||||
3, 99, 100, 225, 234, 208, 159, 177, 21, 205, 255, 192, 147, 93, 2, 96, 63,
|
||||
242, 200, 155, 213, 219, 243, 20, 253, 69, 114, 48, 237, 214, 59, 37, 39,
|
||||
77, 198, 171, 28, 164, 16, 10, 131, 26, 12, 190, 150, 68, 188, 48, 252, 199,
|
||||
156, 19, 116, 207, 255, 225, 136, 26, 230, 90, 112, 2, 0, 229, 167, 169,
|
||||
171, 197, 211, 123, 234, 255, 110, 0, 86, 32, 135, 64, 158, 98, 179, 86, 87,
|
||||
140, 208, 163, 129, 164, 90, 15, 76, 168, 62, 27, 170, 36, 159, 225, 233,
|
||||
167, 162, 101, 176, 19, 52, 14, 195, 66, 178, 53, 218, 155, 89, 174, 252,
|
||||
122, 165, 166, 113, 184, 60, 102, 207, 206, 3, 120, 64, 107, 228, 234, 49,
|
||||
189, 236, 79, 136, 142, 206, 151, 242, 234, 167, 95, 96, 237, 99, 153, 188,
|
||||
43, 63, 191, 63, 185, 119, 37, 39, 1, 114, 48, 47, 174, 23, 83, 57, 99, 58,
|
||||
84, 135, 120, 90, 129, 130, 178, 93, 98, 36, 16, 7, 22, 86, 238, 55, 78,
|
||||
184, 132, 246, 30, 109, 138, 157, 70, 169, 207, 203, 214, 171, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 8, 0, 0, 0, 211, 99, 128, 93, 12, 140, 85, 191, 58, 26, 142, 190, 248,
|
||||
72, 216, 45, 94, 39, 1, 153, 200, 155, 92, 125, 159, 237, 129, 71, 26, 9,
|
||||
215, 164, 236, 129, 16, 81, 18, 162, 87, 214, 29, 244, 207, 95, 19, 238, 10,
|
||||
27, 1, 145, 151, 200, 197, 52, 59, 79, 42, 126, 200, 132, 106, 226, 44, 26,
|
||||
193, 211, 158, 16, 56, 168, 103, 76, 155, 255, 160, 102, 203, 171, 43, 147,
|
||||
5, 136, 255, 154, 90, 206, 174, 147, 168, 217, 240, 103, 28, 252, 117, 64,
|
||||
241, 135, 8, 125, 137, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 90,
|
||||
184, 200, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
]),
|
||||
executable: false,
|
||||
lamports: 27693840,
|
||||
owner: SwitchboardProgram.oracleProgramId,
|
||||
rentEpoch: 302,
|
||||
};
|
||||
|
||||
const solAggregatorPubkey = new anchor.web3.PublicKey(
|
||||
"GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR"
|
||||
);
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"include": [
|
||||
"../src",
|
||||
"../test",
|
||||
"../test/data/**.json"
|
||||
],
|
||||
"exclude": [
|
||||
"**/node_modules"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"types": [
|
||||
"node",
|
||||
"mocha"
|
||||
],
|
||||
"module": "ESNext",
|
||||
"allowJs": true,
|
||||
"rootDir": "../",
|
||||
"resolveJsonModule": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/tsconfig",
|
||||
"include": [
|
||||
"./src/**/*",
|
||||
"./src/**/*.json"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"lib": [
|
||||
"ES2021",
|
||||
"ES2022.Object",
|
||||
"DOM"
|
||||
],
|
||||
"moduleResolution": "nodenext",
|
||||
"inlineSourceMap": false,
|
||||
"inlineSources": false,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
// strict
|
||||
"strict": true,
|
||||
"noImplicitThis": true,
|
||||
"alwaysStrict": true,
|
||||
"noImplicitAny": false,
|
||||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitReturns": true,
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "**/tests/**/*.ts", "dist"],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"composite": false,
|
||||
"declaration": false,
|
||||
"declarationMap": false
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"extends": "./tsconfig.base.json",
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"**/tests/**/*.ts",
|
||||
"lib"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"src/**/*.json"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "es2022",
|
||||
"lib": [
|
||||
"ES2021",
|
||||
"ES2022.Object",
|
||||
"DOM"
|
||||
],
|
||||
"outDir": "lib",
|
||||
"rootDir": "./src",
|
||||
"declaration": true,
|
||||
"experimentalDecorators": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"useDefineForClassFields": true,
|
||||
"strictPropertyInitialization": false,
|
||||
"strict": true,
|
||||
"strictNullChecks": true,
|
||||
"allowJs": true,
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@switchboard-xyz/solana.js",
|
||||
"version": "2.4.4",
|
||||
"version": "2.4.7",
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"description": "A Typescript client to interact with Switchboard on Solana.",
|
||||
|
@ -166,14 +166,14 @@
|
|||
"@coral-xyz/borsh": "^0.28.0",
|
||||
"@solana/spl-token": "^0.3.8",
|
||||
"@solana/web3.js": "^1.78.0",
|
||||
"@switchboard-xyz/common": "^2.2.5",
|
||||
"@switchboard-xyz/common": "^2.2.8",
|
||||
"cron-validator": "^1.3.1",
|
||||
"dotenv": "^16.3.1",
|
||||
"lodash": "^4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@switchboard-xyz/eslint-config": "^0.1.9",
|
||||
"@switchboard-xyz/oracle": "^2.1.13",
|
||||
"@switchboard-xyz/eslint-config": "latest",
|
||||
"@switchboard-xyz/oracle": "latest",
|
||||
"@types/chai": "^4.3.5",
|
||||
"@types/lodash": "^4.14.195",
|
||||
"@types/mocha": "^10.0.1",
|
||||
|
|
|
@ -7,8 +7,7 @@ import type {
|
|||
TransactionObjectOptions,
|
||||
} from "../TransactionObject.js";
|
||||
import { TransactionObject } from "../TransactionObject.js";
|
||||
import type { RawBuffer } from "../types.js";
|
||||
import { parseMrEnclave, parseRawBuffer } from "../utils.js";
|
||||
import { parseRawBuffer } from "../utils.js";
|
||||
|
||||
import { Account } from "./account.js";
|
||||
import type { AttestationPermissionSetParams } from "./attestationPermissionAccount.js";
|
||||
|
@ -25,6 +24,11 @@ import type {
|
|||
TransactionSignature,
|
||||
} from "@solana/web3.js";
|
||||
import { Keypair, SystemProgram } from "@solana/web3.js";
|
||||
import {
|
||||
parseMrEnclave,
|
||||
parseRawMrEnclave,
|
||||
type RawBuffer,
|
||||
} from "@switchboard-xyz/common";
|
||||
/**
|
||||
* Parameters for initializing an {@linkcode QueueAccount}
|
||||
*/
|
||||
|
@ -337,7 +341,9 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
|||
const signers = params.authority ? [params.authority] : [];
|
||||
const instruction = types.attestationQueueAddMrEnclave(
|
||||
this.program,
|
||||
{ params: { mrEnclave: Array.from(parseMrEnclave(params.mrEnclave)) } },
|
||||
{
|
||||
params: { mrEnclave: Array.from(parseRawMrEnclave(params.mrEnclave)) },
|
||||
},
|
||||
{ authority, queue: this.publicKey }
|
||||
);
|
||||
return new TransactionObject(payer, [instruction], signers, options);
|
||||
|
@ -363,7 +369,9 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
|||
const signers = params.authority ? [params.authority] : [];
|
||||
const instruction = types.attestationQueueRemoveMrEnclave(
|
||||
this.program,
|
||||
{ params: { mrEnclave: Array.from(parseMrEnclave(params.mrEnclave)) } },
|
||||
{
|
||||
params: { mrEnclave: Array.from(parseRawMrEnclave(params.mrEnclave)) },
|
||||
},
|
||||
{ authority, queue: this.publicKey }
|
||||
);
|
||||
return new TransactionObject(payer, [instruction], signers, options);
|
||||
|
@ -440,7 +448,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
|||
{
|
||||
params: {
|
||||
mrEnclave: Array.from(
|
||||
parseMrEnclave(params?.verifierrEnclave ?? "")
|
||||
parseRawMrEnclave(params?.verifierrEnclave ?? "")
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -8,12 +8,10 @@ import type {
|
|||
TransactionObjectOptions,
|
||||
} from "../TransactionObject.js";
|
||||
import { TransactionObject } from "../TransactionObject.js";
|
||||
import type { RawBuffer } from "../types.js";
|
||||
import {
|
||||
handleOptionalPubkeys,
|
||||
numToBN,
|
||||
parseCronSchedule,
|
||||
parseMrEnclave,
|
||||
parseRawBuffer,
|
||||
} from "../utils.js";
|
||||
|
||||
|
@ -48,7 +46,8 @@ import {
|
|||
PublicKey,
|
||||
SystemProgram,
|
||||
} from "@solana/web3.js";
|
||||
import { BN, toUtf8 } from "@switchboard-xyz/common";
|
||||
import type { RawBuffer } from "@switchboard-xyz/common";
|
||||
import { BN, parseRawMrEnclave, toUtf8 } from "@switchboard-xyz/common";
|
||||
import assert from "assert";
|
||||
|
||||
export type ContainerRegistryType = "dockerhub" | "ipfs";
|
||||
|
@ -69,7 +68,7 @@ export type FunctionAccountInitParams = FunctionAccountInitSeeds & {
|
|||
containerRegistry?: ContainerRegistryType;
|
||||
schedule?: string;
|
||||
|
||||
mrEnclave: Buffer | Uint8Array | number[];
|
||||
mrEnclave?: Buffer | Uint8Array | number[];
|
||||
attestationQueue: AttestationQueueAccount;
|
||||
|
||||
requestsDisabled?: boolean;
|
||||
|
@ -392,7 +391,9 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
|||
Buffer.from(params.version ?? "latest", "utf8")
|
||||
),
|
||||
schedule: new Uint8Array(cronSchedule),
|
||||
mrEnclave: Array.from(parseMrEnclave(params.mrEnclave)),
|
||||
mrEnclave: Array.from(
|
||||
params.mrEnclave ? parseRawMrEnclave(params.mrEnclave) : []
|
||||
),
|
||||
recentSlot: recentSlot,
|
||||
requestsDisabled: params.requestsDisabled ?? false,
|
||||
requestsRequireAuthorization:
|
||||
|
|
|
@ -7,8 +7,6 @@ import type {
|
|||
TransactionObjectOptions,
|
||||
} from "../TransactionObject.js";
|
||||
import { TransactionObject } from "../TransactionObject.js";
|
||||
import type { RawBuffer } from "../types.js";
|
||||
import { parseMrEnclave } from "../utils.js";
|
||||
|
||||
import { FunctionAccount } from "./index.js";
|
||||
|
||||
|
@ -23,7 +21,8 @@ import type {
|
|||
TransactionSignature,
|
||||
} from "@solana/web3.js";
|
||||
import { Keypair, SystemProgram } from "@solana/web3.js";
|
||||
import { BN, sleep } from "@switchboard-xyz/common";
|
||||
import type { RawBuffer } from "@switchboard-xyz/common";
|
||||
import { BN, parseRawMrEnclave, sleep } from "@switchboard-xyz/common";
|
||||
|
||||
/**
|
||||
* Parameters for initializing a {@linkcode FunctionRequestAccount}
|
||||
|
@ -309,13 +308,13 @@ export class FunctionRequestAccount extends Account<types.FunctionRequestAccount
|
|||
: Math.floor(Date.now() / 1000)
|
||||
),
|
||||
isFailure: params.isFailure ?? false,
|
||||
mrEnclave: Array.from(parseMrEnclave(params.mrEnclave)),
|
||||
mrEnclave: Array.from(parseRawMrEnclave(params.mrEnclave)),
|
||||
requestSlot:
|
||||
typeof params.requestSlot === "number"
|
||||
? new BN(params.requestSlot)
|
||||
: params.requestSlot,
|
||||
containerParamsHash: Array.from(
|
||||
parseMrEnclave(params.containerParamsHash)
|
||||
parseRawMrEnclave(params.containerParamsHash)
|
||||
),
|
||||
},
|
||||
},
|
||||
|
|
|
@ -534,7 +534,7 @@ export class QueueAccount extends Account<types.OracleQueueAccountData> {
|
|||
queueAccount: this,
|
||||
queueAuthority: queueAuthorityPubkey,
|
||||
keypair: params.keypair,
|
||||
authority: payer,
|
||||
authority: params.authority,
|
||||
},
|
||||
options
|
||||
);
|
||||
|
@ -547,13 +547,13 @@ export class QueueAccount extends Account<types.OracleQueueAccountData> {
|
|||
{
|
||||
fundAmount: params.fundAmount,
|
||||
funderTokenWallet: params.funderTokenWallet ?? userTokenAddress,
|
||||
funderAuthority: params.funderAuthority ?? undefined,
|
||||
funderAuthority: params.funderAuthority,
|
||||
withdrawAuthority: params.withdrawAuthority ?? params.authority,
|
||||
aggregatorAccount: aggregatorAccount,
|
||||
queueAccount: this,
|
||||
jobAuthorities: [], // create lease before adding jobs to skip this step
|
||||
jobPubkeys: [],
|
||||
disableWrap: params.disableWrap,
|
||||
withdrawAuthority: params.withdrawAuthority ?? payer,
|
||||
},
|
||||
options
|
||||
);
|
||||
|
|
|
@ -6,8 +6,7 @@ import type {
|
|||
TransactionObjectOptions,
|
||||
} from "../TransactionObject.js";
|
||||
import { TransactionObject } from "../TransactionObject.js";
|
||||
import type { RawBuffer } from "../types.js";
|
||||
import { parseMrEnclave, parseRawBuffer } from "../utils.js";
|
||||
import { parseRawBuffer } from "../utils.js";
|
||||
|
||||
import { Account } from "./account.js";
|
||||
import {
|
||||
|
@ -21,6 +20,7 @@ import type {
|
|||
TransactionSignature,
|
||||
} from "@solana/web3.js";
|
||||
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
|
||||
import { parseRawMrEnclave, type RawBuffer } from "@switchboard-xyz/common";
|
||||
|
||||
export const QUOTE_SEED: string = "QuoteAccountData";
|
||||
|
||||
|
@ -396,7 +396,7 @@ export class VerifierAccount extends Account<types.VerifierAccountData> {
|
|||
{
|
||||
params: {
|
||||
timestamp: params.timestamp,
|
||||
mrEnclave: Array.from(parseMrEnclave(params.mrEnclave)),
|
||||
mrEnclave: Array.from(parseRawMrEnclave(params.mrEnclave)),
|
||||
idx: verifierIdx,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -27,8 +27,6 @@ import type {
|
|||
|
||||
import type { OracleJob } from "@switchboard-xyz/common";
|
||||
|
||||
export type RawBuffer = string | Buffer | Uint8Array | number[];
|
||||
|
||||
export interface AccountDefinition<T extends SwitchboardAccount> {
|
||||
account: T;
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ import { JobAccount } from "./accounts/index.js";
|
|||
import type { AggregatorAccountData } from "./generated/index.js";
|
||||
import { InvalidCronSchedule } from "./errors.js";
|
||||
import { TransactionObject } from "./TransactionObject.js";
|
||||
import type { RawBuffer } from "./types.js";
|
||||
|
||||
import type { AccountMeta } from "@solana/web3.js";
|
||||
import { TransactionInstruction } from "@solana/web3.js";
|
||||
import { Keypair, PublicKey } from "@solana/web3.js";
|
||||
import type { RawBuffer } from "@switchboard-xyz/common";
|
||||
import { BN, OracleJob } from "@switchboard-xyz/common";
|
||||
import { isValidCron } from "cron-validator";
|
||||
import fs from "fs";
|
||||
|
@ -218,7 +218,9 @@ export function parseRawBuffer(rawBuffer: RawBuffer, size = 32): Uint8Array {
|
|||
myUint8Array = new Uint8Array(JSON.parse(rawBuffer));
|
||||
} else if (hexRegex.test(rawBuffer)) {
|
||||
// check if its a hex string '0x1A'
|
||||
myUint8Array = new Uint8Array(Buffer.from(rawBuffer, "hex"));
|
||||
myUint8Array = new Uint8Array(
|
||||
Buffer.from(rawBuffer.replaceAll(/0x|0X/g, ""), "hex")
|
||||
);
|
||||
} else if (base64Regex.test(rawBuffer)) {
|
||||
// check if its a base64 string
|
||||
myUint8Array = new Uint8Array(Buffer.from(rawBuffer, "base64"));
|
||||
|
@ -241,10 +243,6 @@ export function parseRawBuffer(rawBuffer: RawBuffer, size = 32): Uint8Array {
|
|||
);
|
||||
}
|
||||
|
||||
export function parseMrEnclave(mrEnclave: RawBuffer) {
|
||||
return parseRawBuffer(mrEnclave, 32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a cron schedule and return a valid 6 element cron string which includes seconds
|
||||
* @param cronSchedule - the cron string to validate
|
||||
|
|
|
@ -28,6 +28,16 @@
|
|||
"strictNullChecks": false,
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitReturns": true,
|
||||
"esModuleInterop": true
|
||||
}
|
||||
"esModuleInterop": true,
|
||||
"paths": {
|
||||
"@switchboard-xyz/common": [
|
||||
"../common"
|
||||
]
|
||||
}
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../common"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -28,8 +28,24 @@
|
|||
"strictPropertyInitialization": false,
|
||||
"strict": true,
|
||||
"strictNullChecks": true,
|
||||
"allowJs": true
|
||||
"allowJs": true,
|
||||
"paths": {
|
||||
"@switchboard-xyz/common": [
|
||||
"../common"
|
||||
],
|
||||
"@switchboard-xyz/oracle": [
|
||||
"../oracle"
|
||||
]
|
||||
}
|
||||
},
|
||||
"references": [
|
||||
{
|
||||
"path": "../common"
|
||||
},
|
||||
{
|
||||
"path": "../oracle"
|
||||
}
|
||||
],
|
||||
"typedocOptions": {
|
||||
"entryPoints": [
|
||||
"src/index.ts",
|
||||
|
|
1041
pnpm-lock.yaml
1041
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -4241,7 +4241,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "switchboard-solana"
|
||||
version = "0.9.4"
|
||||
version = "0.9.5"
|
||||
dependencies = [
|
||||
"anchor-client",
|
||||
"anchor-lang",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "switchboard-solana"
|
||||
version = "0.9.4"
|
||||
version = "0.9.5"
|
||||
edition = "2021"
|
||||
description = "A Rust library to interact with Switchboard accounts."
|
||||
readme = "README.md"
|
||||
|
@ -8,7 +8,6 @@ keywords = ["switchboard", "oracle", "solana"]
|
|||
homepage = "https://switchboard.xyz"
|
||||
repository = "https://github.com/switchboard-xyz/sbv2-solana/tree/main/rust/switchboard-solana"
|
||||
license = "MIT"
|
||||
documentation = "https://docs.switchboard.xyz"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "lib"]
|
||||
|
|
|
@ -102,22 +102,27 @@ impl FunctionRunner {
|
|||
) -> Result<Instruction, SwitchboardClientError> {
|
||||
let current_time = unix_timestamp();
|
||||
|
||||
let fn_data: FunctionAccountData =
|
||||
FunctionAccountData::fetch(&self.client, self.function).await?;
|
||||
// let fn_data: FunctionAccountData =
|
||||
// FunctionAccountData::fetch(&self.client, self.function).await?;
|
||||
|
||||
println!("Fetching verifier account {}", self.verifier);
|
||||
let verifier_quote: VerifierAccountData =
|
||||
VerifierAccountData::fetch(&self.client, self.verifier).await?;
|
||||
|
||||
println!(
|
||||
"Fetching attestation queue account {}",
|
||||
self.function_data.attestation_queue
|
||||
);
|
||||
let queue_data: AttestationQueueAccountData =
|
||||
crate::client::load_account(&self.client, fn_data.attestation_queue).await?;
|
||||
crate::client::load_account(&self.client, self.function_data.attestation_queue).await?;
|
||||
|
||||
let verifier_permission = AttestationPermissionAccountData::get_pda(
|
||||
&queue_data.authority,
|
||||
&fn_data.attestation_queue,
|
||||
&self.function_data.attestation_queue,
|
||||
&self.verifier,
|
||||
);
|
||||
|
||||
let maybe_next_allowed_timestamp = fn_data.get_next_execution_datetime();
|
||||
let maybe_next_allowed_timestamp = self.function_data.get_next_execution_datetime();
|
||||
let next_allowed_timestamp: i64 = if maybe_next_allowed_timestamp.is_some() {
|
||||
maybe_next_allowed_timestamp.unwrap().timestamp()
|
||||
} else {
|
||||
|
@ -137,9 +142,9 @@ impl FunctionRunner {
|
|||
verifier_quote: self.verifier,
|
||||
verifier_enclave_signer: verifier_quote.enclave.enclave_signer,
|
||||
verifier_permission,
|
||||
escrow_wallet: fn_data.escrow_wallet,
|
||||
escrow_token_wallet: fn_data.escrow_token_wallet,
|
||||
attestation_queue: fn_data.attestation_queue,
|
||||
escrow_wallet: self.function_data.escrow_wallet,
|
||||
escrow_token_wallet: self.function_data.escrow_token_wallet,
|
||||
attestation_queue: self.function_data.attestation_queue,
|
||||
receiver: self.reward_receiver,
|
||||
};
|
||||
let ixn: Instruction = accounts.get_instruction(ixn_params)?;
|
||||
|
@ -161,18 +166,18 @@ impl FunctionRunner {
|
|||
));
|
||||
}
|
||||
|
||||
let fn_data: FunctionAccountData =
|
||||
FunctionAccountData::fetch(&self.client, self.function).await?;
|
||||
// let fn_data: FunctionAccountData =
|
||||
// FunctionAccountData::fetch(&self.client, self.function).await?;
|
||||
|
||||
let verifier_quote: VerifierAccountData =
|
||||
VerifierAccountData::fetch(&self.client, self.verifier).await?;
|
||||
|
||||
let queue_data: AttestationQueueAccountData =
|
||||
crate::client::load_account(&self.client, fn_data.attestation_queue).await?;
|
||||
crate::client::load_account(&self.client, self.function_data.attestation_queue).await?;
|
||||
|
||||
let verifier_permission = AttestationPermissionAccountData::get_pda(
|
||||
&queue_data.authority,
|
||||
&fn_data.attestation_queue,
|
||||
&self.function_data.attestation_queue,
|
||||
&self.verifier,
|
||||
);
|
||||
|
||||
|
@ -192,12 +197,12 @@ impl FunctionRunner {
|
|||
function_enclave_signer: self.signer,
|
||||
token_wallet: fn_request_data.escrow,
|
||||
function: self.function,
|
||||
function_escrow: fn_data.escrow_token_wallet,
|
||||
function_escrow: self.function_data.escrow_token_wallet,
|
||||
verifier_quote: self.verifier,
|
||||
verifier_enclave_signer: verifier_quote.enclave.enclave_signer,
|
||||
verifier_permission,
|
||||
state: state_pubkey,
|
||||
attestation_queue: fn_data.attestation_queue,
|
||||
attestation_queue: self.function_data.attestation_queue,
|
||||
receiver: self.reward_receiver,
|
||||
};
|
||||
let ixn: Instruction = accounts.get_instruction(ixn_params)?;
|
||||
|
|
Loading…
Reference in New Issue