From 559ca3401bfec66b04cce84bbe6b83d3e4979dad Mon Sep 17 00:00:00 2001 From: gallynaut Date: Fri, 8 Sep 2023 16:06:11 -0600 Subject: [PATCH] chore: pull monorepo changes (#120) * Project import generated by Copybara. GitOrigin-RevId: 08821e148b21e3b2c212fdd5342909d92844d84a * chore: manual fix build deps * chore: Update pnpm lockfile --------- Co-authored-by: Copybara Co-authored-by: gallynaut --- examples/feeds/01_feed_client/package.json | 4 +- examples/feeds/02_spl_native/package.json | 4 +- .../functions/01_basic_oracle/package.json | 2 +- .../01_basic_oracle/sgx-function/Makefile | 2 +- .../02_liquidity_oracle/package.json | 4 +- .../functions/03_candles_oracle/package.json | 4 +- .../04_randomness_callback/Anchor.toml | 36 +- .../04_randomness_callback/Cargo.lock | 259 +++++++++++++- .../04_randomness_callback/Cargo.toml | 2 +- .../04_randomness_callback/package.json | 8 +- .../sgx-function/Cargo.lock | 285 ++++++++++++++- .../sgx-function/Cargo.toml | 2 +- .../sgx-function/src/main.rs | 11 +- .../04_randomness_callback/src/lib.rs | 16 +- .../functions/05_raffle_program/package.json | 4 +- examples/vrf/01_vrf_client/package.json | 4 +- javascript/sbv2-lite/package.json | 12 +- .../src/accounts/functionRequestAccount.ts | 6 +- pnpm-lock.yaml | 326 +++++++++--------- rust/switchboard-solana/Cargo.anchor27.lock | 2 +- rust/switchboard-solana/Cargo.anchor27.toml | 2 +- rust/switchboard-solana/Cargo.lock | 240 ++++++++++++- rust/switchboard-solana/Cargo.toml | 12 +- .../instructions/function_close.rs | 44 +-- .../instructions/function_init.rs | 40 +-- .../instructions/function_set_config.rs | 14 +- .../instructions/function_set_escrow.rs | 44 +-- .../instructions/function_trigger.rs | 19 +- .../instructions/function_verify.rs | 58 +--- .../attestation_program/instructions/mod.rs | 9 +- .../instructions/request_close.rs | 38 +- .../instructions/request_init.rs | 58 ++-- .../instructions/request_init_and_trigger.rs | 32 +- .../instructions/request_set_config.rs | 89 +++++ .../instructions/request_trigger.rs | 52 +-- .../instructions/request_verify.rs | 81 ++--- .../instructions/wallet_fund.rs | 51 +-- .../instructions/wallet_init.rs | 54 +-- .../src/client/function_runner.rs | 32 +- rust/switchboard-solana/src/client/utils.rs | 2 + rust/switchboard-solana/src/instructions.rs | 5 +- rust/switchboard-solana/src/lib.rs | 4 + rust/switchboard-solana/src/secrets.rs | 58 ++++ rust/switchboard-solana/src/types.rs | 7 +- 44 files changed, 1373 insertions(+), 665 deletions(-) create mode 100644 rust/switchboard-solana/src/attestation_program/instructions/request_set_config.rs create mode 100644 rust/switchboard-solana/src/secrets.rs diff --git a/examples/feeds/01_feed_client/package.json b/examples/feeds/01_feed_client/package.json index 46653ec6f..f3b1294ae 100644 --- a/examples/feeds/01_feed_client/package.json +++ b/examples/feeds/01_feed_client/package.json @@ -18,9 +18,9 @@ "@project-serum/borsh": "^0.2.5", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.78.3", - "@switchboard-xyz/common": "^2.3.4", + "@switchboard-xyz/common": "^2.3.3", "@switchboard-xyz/oracle": "latest", - "@switchboard-xyz/solana.js": "^2.5.6", + "@switchboard-xyz/solana.js": "^2.5.0", "chalk": "^4.1.2", "dotenv": "^16.0.1", "yargs": "^17.5.1" diff --git a/examples/feeds/02_spl_native/package.json b/examples/feeds/02_spl_native/package.json index ea0372652..0f668fa14 100644 --- a/examples/feeds/02_spl_native/package.json +++ b/examples/feeds/02_spl_native/package.json @@ -17,9 +17,9 @@ "dependencies": { "@coral-xyz/anchor": "^0.28.0", "@solana/web3.js": "^1.77.3", - "@switchboard-xyz/common": "^2.3.4", + "@switchboard-xyz/common": "^2.3.3", "@switchboard-xyz/oracle": "latest", - "@switchboard-xyz/solana.js": "^2.5.6" + "@switchboard-xyz/solana.js": "^2.5.0" }, "devDependencies": { "@types/chai": "^4.3.0", diff --git a/examples/functions/01_basic_oracle/package.json b/examples/functions/01_basic_oracle/package.json index 218846b71..9a555e3ad 100644 --- a/examples/functions/01_basic_oracle/package.json +++ b/examples/functions/01_basic_oracle/package.json @@ -15,7 +15,7 @@ "@coral-xyz/anchor": "^0.28.0", "@solana/spl-token": "^0.3.6", "@solana/web3.js": "^1.78.0", - "@switchboard-xyz/solana.js": "^2.5.6" + "@switchboard-xyz/solana.js": "workspace:^" }, "devDependencies": { "@types/bn.js": "^5.1.0", diff --git a/examples/functions/01_basic_oracle/sgx-function/Makefile b/examples/functions/01_basic_oracle/sgx-function/Makefile index 5ea6b0bdb..84d91be01 100644 --- a/examples/functions/01_basic_oracle/sgx-function/Makefile +++ b/examples/functions/01_basic_oracle/sgx-function/Makefile @@ -2,7 +2,7 @@ # Variables CARGO_NAME=basic-oracle-function -DOCKER_IMAGE_NAME=${CONTAINER_NAME?} +DOCKER_IMAGE_NAME=${CONTAINER_NAME} DOCKER_BUILD_COMMAND=DOCKER_BUILDKIT=1 docker buildx build --platform linux/amd64 --build-arg CARGO_NAME=${CARGO_NAME} diff --git a/examples/functions/02_liquidity_oracle/package.json b/examples/functions/02_liquidity_oracle/package.json index d324e2551..432f131ff 100644 --- a/examples/functions/02_liquidity_oracle/package.json +++ b/examples/functions/02_liquidity_oracle/package.json @@ -14,8 +14,8 @@ "@coral-xyz/anchor": "^0.28.0", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.78.3", - "@switchboard-xyz/common": "^2.3.4", - "@switchboard-xyz/solana.js": "^2.5.6" + "@switchboard-xyz/common": "^2.3.3", + "@switchboard-xyz/solana.js": "^2.5.0" }, "devDependencies": { "@types/bn.js": "^5.1.0", diff --git a/examples/functions/03_candles_oracle/package.json b/examples/functions/03_candles_oracle/package.json index 0e1bf03b3..71cf2f4f1 100644 --- a/examples/functions/03_candles_oracle/package.json +++ b/examples/functions/03_candles_oracle/package.json @@ -15,8 +15,8 @@ "@coral-xyz/anchor": "^0.28.0", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.78.3", - "@switchboard-xyz/common": "^2.3.4", - "@switchboard-xyz/solana.js": "^2.5.6" + "@switchboard-xyz/common": "^2.3.3", + "@switchboard-xyz/solana.js": "^2.5.0" }, "devDependencies": { "@types/bn.js": "^5.1.0", diff --git a/examples/functions/04_randomness_callback/Anchor.toml b/examples/functions/04_randomness_callback/Anchor.toml index f46e4ee55..5d5edcdc3 100644 --- a/examples/functions/04_randomness_callback/Anchor.toml +++ b/examples/functions/04_randomness_callback/Anchor.toml @@ -20,29 +20,29 @@ wallet = "~/.config/solana/id.json" [scripts] test = "pnpm exec ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts" -# [test.validator] -# url = "https://api.devnet.solana.com" +[test.validator] +url = "https://api.devnet.solana.com" -# [test] -# startup_wait = 15000 +[test] +startup_wait = 15000 -# [[test.validator.clone]] # sb devnet oracle programID -# address = "SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f" +[[test.validator.clone]] # sb devnet oracle programID +address = "SW1TCH7qEPTdLsDHRgPuMQjbQxKdH2aBStViMFnt64f" -# [[test.validator.clone]] # sb devnet oracle IDL -# address = "Fi8vncGpNKbq62gPo56G4toCehWNy77GgqGkTaAF5Lkk" +[[test.validator.clone]] # sb devnet oracle IDL +address = "Fi8vncGpNKbq62gPo56G4toCehWNy77GgqGkTaAF5Lkk" -# [[test.validator.clone]] # sb devnet oracle SbState -# address = "CyZuD7RPDcrqCGbNvLCyqk6Py9cEZTKmNKujfPi3ynDd" +[[test.validator.clone]] # sb devnet oracle SbState +address = "CyZuD7RPDcrqCGbNvLCyqk6Py9cEZTKmNKujfPi3ynDd" -# [[test.validator.clone]] # sb devnet oracle tokenVault -# address = "7hkp1xfPBcD2t1vZMoWWQPzipHVcXeLAAaiGXdPSfDie" +[[test.validator.clone]] # sb devnet oracle tokenVault +address = "7hkp1xfPBcD2t1vZMoWWQPzipHVcXeLAAaiGXdPSfDie" -# [[test.validator.clone]] # sb devnet attestation programID -# address = "sbattyXrzedoNATfc4L31wC9Mhxsi1BmFhTiN8gDshx" +[[test.validator.clone]] # sb devnet attestation programID +address = "sbattyXrzedoNATfc4L31wC9Mhxsi1BmFhTiN8gDshx" -# [[test.validator.clone]] # sb devnet attestation IDL -# address = "5ExuoQR69trmKQfB95fDsUGsUrrChbGq9PFgt8qouncz" +[[test.validator.clone]] # sb devnet attestation IDL +address = "5ExuoQR69trmKQfB95fDsUGsUrrChbGq9PFgt8qouncz" -# [[test.validator.clone]] # sb devnet programState -# address = "5MFs7RGTjLi1wtKNBFRtuLipCkkjs4YQwRRU9sjnbQbS" +[[test.validator.clone]] # sb devnet programState +address = "5MFs7RGTjLi1wtKNBFRtuLipCkkjs4YQwRRU9sjnbQbS" diff --git a/examples/functions/04_randomness_callback/Cargo.lock b/examples/functions/04_randomness_callback/Cargo.lock index 3d44b2abf..8df62314f 100644 --- a/examples/functions/04_randomness_callback/Cargo.lock +++ b/examples/functions/04_randomness_callback/Cargo.lock @@ -581,9 +581,9 @@ checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "base64ct" -version = "1.6.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +checksum = "e6b4d9b1225d28d360ec6a231d65af1fd99a2a095154c8040689617290569c5c" [[package]] name = "bincode" @@ -1008,6 +1008,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "const-oid" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" + [[package]] name = "const-oid" version = "0.7.1" @@ -1114,6 +1120,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -1207,13 +1224,23 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +[[package]] +name = "der" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +dependencies = [ + "const-oid 0.6.2", + "crypto-bigint", +] + [[package]] name = "der" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" dependencies = [ - "const-oid", + "const-oid 0.7.1", ] [[package]] @@ -1414,6 +1441,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" @@ -1475,6 +1511,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" @@ -1844,6 +1895,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" @@ -2009,6 +2073,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "lexical-core" @@ -2029,6 +2096,12 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +[[package]] +name = "libm" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" + [[package]] name = "libsecp256k1" version = "0.6.0" @@ -2187,6 +2260,24 @@ dependencies = [ "winapi", ] +[[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" @@ -2267,6 +2358,23 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint-dig" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9bc3e36fd683e004fd59c64a425e0e991616f5a8b617c3b9a933a93c168facc" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + [[package]] name = "num-complex" version = "0.2.4" @@ -2328,6 +2436,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -2409,12 +2518,50 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl" +version = "0.10.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +dependencies = [ + "bitflags 2.3.3", + "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.66", + "quote 1.0.32", + "syn 2.0.28", +] + [[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.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_str_bytes" version = "6.5.1" @@ -2502,6 +2649,15 @@ dependencies = [ "base64 0.13.1", ] +[[package]] +name = "pem-rfc7468" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e93a3b1cc0510b03020f33f21e62acdde3dcaef432edc95bea377fbd4c2cd4" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -2529,14 +2685,38 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "116bee8279d783c0cf370efa1a94632f2108e5ef0bb32df31f051647810a4e2c" +dependencies = [ + "der 0.4.5", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "pkcs8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +dependencies = [ + "der 0.4.5", + "pem-rfc7468", + "pkcs1", + "spki 0.4.1", + "zeroize", +] + [[package]] name = "pkcs8" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" dependencies = [ - "der", - "spki", + "der 0.5.1", + "spki 0.5.4", "zeroize", ] @@ -2903,10 +3083,12 @@ dependencies = [ "http-body", "hyper", "hyper-rustls", + "hyper-tls", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -2916,6 +3098,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "tokio", + "tokio-native-tls", "tokio-rustls", "tokio-util", "tower-service", @@ -2981,6 +3164,26 @@ dependencies = [ "winapi", ] +[[package]] +name = "rsa" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c2603e2823634ab331437001b411b9ed11660fbc4066f3908c84a9439260d" +dependencies = [ + "byteorder", + "digest 0.9.0", + "lazy_static", + "num-bigint-dig", + "num-integer", + "num-iter", + "num-traits", + "pkcs1", + "pkcs8 0.7.6", + "rand 0.8.5", + "subtle", + "zeroize", +] + [[package]] name = "rtoolbox" version = "0.0.1" @@ -3948,7 +4151,7 @@ dependencies = [ "nix", "pem", "percentage", - "pkcs8", + "pkcs8 0.8.0", "quinn", "quinn-proto", "quinn-udp", @@ -4136,6 +4339,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spki" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" +dependencies = [ + "der 0.4.5", +] + [[package]] name = "spki" version = "0.5.4" @@ -4143,7 +4355,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" dependencies = [ "base64ct", - "der", + "der 0.5.1", ] [[package]] @@ -4236,10 +4448,15 @@ checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" [[package]] name = "switchboard-common" -version = "0.8.6" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723a9a346c6d6eb3374ebe8ea3848e61d40d1f9f46635604137e19a1a4262c52" dependencies = [ + "envy", "getrandom 0.2.10", "hex", + "rand 0.8.5", + "reqwest", "serde", "serde_json", "sgx-quote", @@ -4248,7 +4465,9 @@ dependencies = [ [[package]] name = "switchboard-solana" -version = "0.28.2" +version = "0.28.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa9c6634ad316592b84930a923efe0be920b1bd94d61237a90b596ebd926c40" dependencies = [ "anchor-client", "anchor-lang", @@ -4258,7 +4477,12 @@ dependencies = [ "chrono", "cron", "hex", + "rand 0.8.5", + "reqwest", + "rsa", "rust_decimal", + "serde", + "serde_json", "sgx-quote", "solana-address-lookup-table-program", "solana-client", @@ -4266,6 +4490,7 @@ dependencies = [ "superslice", "switchboard-common", "tokio", + "url", ] [[package]] @@ -4480,6 +4705,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" @@ -4733,6 +4968,12 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +[[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" diff --git a/examples/functions/04_randomness_callback/Cargo.toml b/examples/functions/04_randomness_callback/Cargo.toml index a53e50b8a..082c897ba 100644 --- a/examples/functions/04_randomness_callback/Cargo.toml +++ b/examples/functions/04_randomness_callback/Cargo.toml @@ -20,5 +20,5 @@ default = [] [dependencies] bytemuck = "^1" anchor-spl = "0.28.0" -switchboard-solana = "0.28.4" +switchboard-solana = "0.28.12" # switchboard-solana = { version = "0.28.4", path = "../../../rust/switchboard-solana" } diff --git a/examples/functions/04_randomness_callback/package.json b/examples/functions/04_randomness_callback/package.json index e8034a75f..39422e6f8 100644 --- a/examples/functions/04_randomness_callback/package.json +++ b/examples/functions/04_randomness_callback/package.json @@ -7,11 +7,11 @@ "clean": "pnpm exec rimraf node_modules .anchor .turbo" }, "dependencies": { - "@coral-xyz/anchor": "^0.27.0", + "@coral-xyz/anchor": "^0.28.0", "@solana/spl-token": "^0.3.8", - "@solana/web3.js": "^1.78.3", - "@switchboard-xyz/common": "^2.3.4", - "@switchboard-xyz/solana.js": "^2.5.6", + "@solana/web3.js": "^1.78.4", + "@switchboard-xyz/common": "^2.3.3", + "@switchboard-xyz/solana.js": "^2.5.0", "dotenv": "^16.3.1" }, "devDependencies": { diff --git a/examples/functions/04_randomness_callback/sgx-function/Cargo.lock b/examples/functions/04_randomness_callback/sgx-function/Cargo.lock index fee1220a7..f7e26fec7 100644 --- a/examples/functions/04_randomness_callback/sgx-function/Cargo.lock +++ b/examples/functions/04_randomness_callback/sgx-function/Cargo.lock @@ -581,9 +581,9 @@ checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" [[package]] name = "base64ct" -version = "1.6.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +checksum = "e6b4d9b1225d28d360ec6a231d65af1fd99a2a095154c8040689617290569c5c" [[package]] name = "bincode" @@ -600,6 +600,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" + [[package]] name = "bitmaps" version = "2.1.0" @@ -914,7 +920,7 @@ checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" dependencies = [ "ansi_term", "atty", - "bitflags", + "bitflags 1.3.2", "strsim 0.8.0", "textwrap 0.11.0", "unicode-width", @@ -928,7 +934,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "atty", - "bitflags", + "bitflags 1.3.2", "clap_lex", "indexmap 1.9.3", "once_cell", @@ -1001,6 +1007,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "const-oid" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" + [[package]] name = "const-oid" version = "0.7.1" @@ -1107,6 +1119,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -1191,13 +1214,23 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +[[package]] +name = "der" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +dependencies = [ + "const-oid 0.6.2", + "crypto-bigint", +] + [[package]] name = "der" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" dependencies = [ - "const-oid", + "const-oid 0.7.1", ] [[package]] @@ -1392,6 +1425,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" @@ -1456,6 +1498,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" @@ -1825,6 +1882,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" @@ -2001,6 +2071,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "lexical-core" @@ -2009,7 +2082,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" dependencies = [ "arrayvec 0.5.2", - "bitflags", + "bitflags 1.3.2", "cfg-if", "ryu", "static_assertions", @@ -2021,6 +2094,12 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +[[package]] +name = "libm" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" + [[package]] name = "libsecp256k1" version = "0.6.0" @@ -2179,13 +2258,31 @@ dependencies = [ "winapi", ] +[[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" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags", + "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.7.1", @@ -2259,6 +2356,23 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint-dig" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9bc3e36fd683e004fd59c64a425e0e991616f5a8b617c3b9a933a93c168facc" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + [[package]] name = "num-complex" version = "0.2.4" @@ -2320,6 +2434,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -2401,12 +2516,50 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl" +version = "0.10.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +dependencies = [ + "bitflags 2.4.0", + "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.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_str_bytes" version = "6.5.1" @@ -2494,6 +2647,15 @@ dependencies = [ "base64 0.13.1", ] +[[package]] +name = "pem-rfc7468" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e93a3b1cc0510b03020f33f21e62acdde3dcaef432edc95bea377fbd4c2cd4" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -2521,14 +2683,38 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "116bee8279d783c0cf370efa1a94632f2108e5ef0bb32df31f051647810a4e2c" +dependencies = [ + "der 0.4.5", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "pkcs8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +dependencies = [ + "der 0.4.5", + "pem-rfc7468", + "pkcs1", + "spki 0.4.1", + "zeroize", +] + [[package]] name = "pkcs8" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" dependencies = [ - "der", - "spki", + "der 0.5.1", + "spki 0.5.4", "zeroize", ] @@ -2837,7 +3023,7 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -2846,7 +3032,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" dependencies = [ - "bitflags", + "bitflags 1.3.2", ] [[package]] @@ -2904,10 +3090,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 +3105,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "tokio", + "tokio-native-tls", "tokio-rustls", "tokio-util", "tower-service", @@ -2982,6 +3171,26 @@ dependencies = [ "winapi", ] +[[package]] +name = "rsa" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c2603e2823634ab331437001b411b9ed11660fbc4066f3908c84a9439260d" +dependencies = [ + "byteorder", + "digest 0.9.0", + "lazy_static", + "num-bigint-dig", + "num-integer", + "num-iter", + "num-traits", + "pkcs1", + "pkcs8 0.7.6", + "rand 0.8.5", + "subtle", + "zeroize", +] + [[package]] name = "rtoolbox" version = "0.0.1" @@ -3046,7 +3255,7 @@ version = "0.37.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -3156,7 +3365,7 @@ version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" dependencies = [ - "bitflags", + "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", @@ -3654,7 +3863,7 @@ dependencies = [ "array-bytes", "base64 0.21.2", "bincode", - "bitflags", + "bitflags 1.3.2", "blake3", "borsh 0.10.3", "bs58 0.4.0", @@ -3875,7 +4084,7 @@ dependencies = [ "assert_matches", "base64 0.21.2", "bincode", - "bitflags", + "bitflags 1.3.2", "borsh 0.10.3", "bs58 0.4.0", "bytemuck", @@ -3950,7 +4159,7 @@ dependencies = [ "nix", "pem", "percentage", - "pkcs8", + "pkcs8 0.8.0", "quinn", "quinn-proto", "quinn-udp", @@ -4138,6 +4347,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spki" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" +dependencies = [ + "der 0.4.5", +] + [[package]] name = "spki" version = "0.5.4" @@ -4145,7 +4363,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" dependencies = [ "base64ct", - "der", + "der 0.5.1", ] [[package]] @@ -4238,10 +4456,15 @@ checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" [[package]] name = "switchboard-common" -version = "0.8.6" +version = "0.8.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "723a9a346c6d6eb3374ebe8ea3848e61d40d1f9f46635604137e19a1a4262c52" dependencies = [ + "envy", "getrandom 0.2.10", "hex", + "rand 0.8.5", + "reqwest", "serde", "serde_json", "sgx-quote", @@ -4250,7 +4473,9 @@ dependencies = [ [[package]] name = "switchboard-solana" -version = "0.28.1" +version = "0.28.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa9c6634ad316592b84930a923efe0be920b1bd94d61237a90b596ebd926c40" dependencies = [ "anchor-client", "anchor-lang", @@ -4260,7 +4485,12 @@ dependencies = [ "chrono", "cron", "hex", + "rand 0.8.5", + "reqwest", + "rsa", "rust_decimal", + "serde", + "serde_json", "sgx-quote", "solana-address-lookup-table-program", "solana-client", @@ -4268,6 +4498,7 @@ dependencies = [ "superslice", "switchboard-common", "tokio", + "url", ] [[package]] @@ -4482,6 +4713,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" @@ -4736,6 +4977,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" diff --git a/examples/functions/04_randomness_callback/sgx-function/Cargo.toml b/examples/functions/04_randomness_callback/sgx-function/Cargo.toml index 9bc2be0cf..bef78dd35 100644 --- a/examples/functions/04_randomness_callback/sgx-function/Cargo.toml +++ b/examples/functions/04_randomness_callback/sgx-function/Cargo.toml @@ -12,5 +12,5 @@ path = "src/main.rs" [dependencies] tokio = "^1" futures = "0.3" -switchboard-solana = "0.28.4" +switchboard-solana = "0.28.12" # switchboard-solana = { version = "0.28.4", path = "../../../../rust/switchboard-solana" } diff --git a/examples/functions/04_randomness_callback/sgx-function/src/main.rs b/examples/functions/04_randomness_callback/sgx-function/src/main.rs index 2161d174d..8d3471d85 100644 --- a/examples/functions/04_randomness_callback/sgx-function/src/main.rs +++ b/examples/functions/04_randomness_callback/sgx-function/src/main.rs @@ -12,7 +12,14 @@ async fn main() { let runner = FunctionRunner::new_from_cluster(Cluster::Devnet, None).unwrap(); // parse and validate user provided request params - let params = ContainerParams::decode(&runner.fn_request_data.container_params).unwrap(); + let params = ContainerParams::decode( + &runner + .function_request_data + .as_ref() + .unwrap() + .container_params, + ) + .unwrap(); // Determine the final result let mut bytes: [u8; 1] = [0u8; 1]; @@ -39,7 +46,7 @@ async fn main() { AccountMeta::new_readonly(house_pubkey, false), AccountMeta::new(params.user_key, false), AccountMeta::new_readonly(runner.function, false), - AccountMeta::new_readonly(runner.fn_request_key, false), + AccountMeta::new_readonly(runner.function_request_key.unwrap(), false), AccountMeta::new_readonly(runner.signer, true), AccountMeta::new_readonly(anchor_spl::token::ID, false), AccountMeta::new_readonly(mint, false), diff --git a/examples/functions/04_randomness_callback/src/lib.rs b/examples/functions/04_randomness_callback/src/lib.rs index 4bde6222a..5df6f7a4a 100644 --- a/examples/functions/04_randomness_callback/src/lib.rs +++ b/examples/functions/04_randomness_callback/src/lib.rs @@ -89,15 +89,15 @@ pub mod custom_randomness_request { let request_init_ctx = FunctionRequestInitAndTrigger { request: ctx.accounts.request.clone(), - function: ctx.accounts.function.clone(), + function: ctx.accounts.function.to_account_info(), escrow: ctx.accounts.request_escrow.clone(), - mint: ctx.accounts.mint.clone(), - state: ctx.accounts.state.clone(), - attestation_queue: ctx.accounts.attestation_queue.clone(), - payer: ctx.accounts.payer.clone(), - system_program: ctx.accounts.system_program.clone(), - token_program: ctx.accounts.token_program.clone(), - associated_token_program: ctx.accounts.associated_token_program.clone(), + mint: ctx.accounts.mint.to_account_info(), + state: ctx.accounts.state.to_account_info(), + attestation_queue: ctx.accounts.attestation_queue.to_account_info(), + payer: ctx.accounts.payer.to_account_info(), + system_program: ctx.accounts.system_program.to_account_info(), + token_program: ctx.accounts.token_program.to_account_info(), + associated_token_program: ctx.accounts.associated_token_program.to_account_info(), }; request_init_ctx.invoke( ctx.accounts.switchboard.clone(), diff --git a/examples/functions/05_raffle_program/package.json b/examples/functions/05_raffle_program/package.json index da3a42078..f8f707571 100644 --- a/examples/functions/05_raffle_program/package.json +++ b/examples/functions/05_raffle_program/package.json @@ -7,8 +7,8 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.28.0", - "@switchboard-xyz/common": "^2.3.4", - "@switchboard-xyz/solana.js": "^2.5.6" + "@switchboard-xyz/common": "^2.3.3", + "@switchboard-xyz/solana.js": "^2.5.0" }, "devDependencies": { "@types/bn.js": "^5.1.0", diff --git a/examples/vrf/01_vrf_client/package.json b/examples/vrf/01_vrf_client/package.json index 9fe442a1d..563bf7aeb 100644 --- a/examples/vrf/01_vrf_client/package.json +++ b/examples/vrf/01_vrf_client/package.json @@ -18,9 +18,9 @@ "@project-serum/borsh": "^0.2.5", "@solana/spl-token": "^0.3.6", "@solana/web3.js": "^1.77.3", - "@switchboard-xyz/common": "^2.3.4", + "@switchboard-xyz/common": "^2.3.3", "@switchboard-xyz/oracle": "latest", - "@switchboard-xyz/solana.js": "^2.5.6", + "@switchboard-xyz/solana.js": "^2.5.0", "chalk": "^4.1.2", "dotenv": "^16.0.1", "yargs": "^17.5.1" diff --git a/javascript/sbv2-lite/package.json b/javascript/sbv2-lite/package.json index 701c4dae3..718ef0a57 100644 --- a/javascript/sbv2-lite/package.json +++ b/javascript/sbv2-lite/package.json @@ -1,6 +1,6 @@ { "name": "@switchboard-xyz/sbv2-lite", - "version": "0.2.4", + "version": "0.2.2", "description": "", "private": false, "repository": { @@ -15,13 +15,13 @@ ], "exports": { ".": { - "import": "./lib/index.js", - "require": "./lib/index.js" + "import": "./lib/esm/index.js", + "require": "./lib/cjs/index.js" } }, - "main": "lib/index.js", - "module": "lib/index.js", - "types": "lib/index.d.ts", + "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'", diff --git a/javascript/solana.js/src/accounts/functionRequestAccount.ts b/javascript/solana.js/src/accounts/functionRequestAccount.ts index 74816b898..a2dc9ba0f 100644 --- a/javascript/solana.js/src/accounts/functionRequestAccount.ts +++ b/javascript/solana.js/src/accounts/functionRequestAccount.ts @@ -7,6 +7,7 @@ import type { TransactionObjectOptions, } from "../TransactionObject.js"; import { TransactionObject } from "../TransactionObject.js"; +import { parseRawBuffer } from "../utils.js"; import { FunctionAccount } from "./index.js"; @@ -71,6 +72,7 @@ export interface FunctionRequestVerifyParams { // accounts functionEnclaveSigner: PublicKey; function: PublicKey; + functionEscrow: PublicKey; verifierQuote: PublicKey; verifierEnclaveSigner: PublicKey; verifierPermission: PublicKey; @@ -316,7 +318,7 @@ export class FunctionRequestAccount extends Account=11'} - dependencies: - '@coral-xyz/borsh': 0.27.0(@solana/web3.js@1.78.4) - '@solana/web3.js': 1.78.4 - base64-js: 1.5.1 - bn.js: 5.2.1 - bs58: 4.0.1 - buffer-layout: 1.2.2 - camelcase: 6.3.0 - cross-fetch: 3.1.5 - crypto-hash: 1.3.0 - eventemitter3: 4.0.7 - js-sha256: 0.9.0 - pako: 2.0.4 - snake-case: 3.0.4 - superstruct: 0.15.5 - toml: 3.0.0 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - dev: false - /@coral-xyz/anchor@0.28.0: resolution: {integrity: sha512-kQ02Hv2ZqxtWP30WN1d4xxT4QqlOXYDxmEd3k/bbneqhV3X5QMO4LAtoUFs7otxyivOgoqam5Il5qx81FuI4vw==} engines: {node: '>=11'} dependencies: - '@coral-xyz/borsh': 0.28.0(@solana/web3.js@1.78.3) - '@solana/web3.js': 1.78.3 + '@coral-xyz/borsh': 0.28.0(@solana/web3.js@1.78.4) + '@solana/web3.js': 1.78.4 base64-js: 1.5.1 bn.js: 5.2.1 bs58: 4.0.1 @@ -982,17 +957,6 @@ packages: - encoding - utf-8-validate - /@coral-xyz/borsh@0.27.0(@solana/web3.js@1.78.4): - resolution: {integrity: sha512-tJKzhLukghTWPLy+n8K8iJKgBq1yLT/AxaNd10yJrX8mI56ao5+OFAKAqW/h0i79KCvb4BK0VGO5ECmmolFz9A==} - engines: {node: '>=10'} - peerDependencies: - '@solana/web3.js': ^1.68.0 - dependencies: - '@solana/web3.js': 1.78.4 - bn.js: 5.2.1 - buffer-layout: 1.2.2 - dev: false - /@coral-xyz/borsh@0.28.0(@solana/web3.js@1.77.3): resolution: {integrity: sha512-/u1VTzw7XooK7rqeD7JLUSwOyRSesPUk0U37BV9zK0axJc1q0nRbKFGFLYCQ16OtdOJTTwGfGp11Lx9B45bRCQ==} engines: {node: '>=10'} @@ -1013,6 +977,7 @@ packages: '@solana/web3.js': 1.78.3 bn.js: 5.2.1 buffer-layout: 1.2.2 + dev: false /@coral-xyz/borsh@0.28.0(@solana/web3.js@1.78.4): resolution: {integrity: sha512-/u1VTzw7XooK7rqeD7JLUSwOyRSesPUk0U37BV9zK0axJc1q0nRbKFGFLYCQ16OtdOJTTwGfGp11Lx9B45bRCQ==} @@ -1023,7 +988,6 @@ packages: '@solana/web3.js': 1.78.4 bn.js: 5.2.1 buffer-layout: 1.2.2 - dev: true /@cspotcode/source-map-support@0.8.1: resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} @@ -1258,17 +1222,17 @@ packages: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: eslint: 8.42.0 - eslint-visitor-keys: 3.4.2 + eslint-visitor-keys: 3.4.3 dev: true - /@eslint-community/eslint-utils@4.4.0(eslint@8.47.0): + /@eslint-community/eslint-utils@4.4.0(eslint@8.49.0): resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.47.0 - eslint-visitor-keys: 3.4.2 + eslint: 8.49.0 + eslint-visitor-keys: 3.4.3 dev: true /@eslint-community/regexpp@4.5.1: @@ -1320,8 +1284,8 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /@eslint/js@8.47.0: - resolution: {integrity: sha512-P6omY1zv5MItm93kLM8s2vr1HICJH8v0dvddDhysbIuZ+vcjOHg5Zbkf1mTkcmi2JA9oBG2anOkRnW8WJTS8Og==} + /@eslint/js@8.49.0: + resolution: {integrity: sha512-1S8uAY/MTJqVx0SC4epBq+N2yhuwtNwLbJYNZyhL2pO1ZVKn5HFXav5T41Ryzy9K9V7ZId2JB2oy/W4aCd9/2w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true @@ -1336,6 +1300,17 @@ packages: - supports-color dev: true + /@humanwhocodes/config-array@0.11.11: + resolution: {integrity: sha512-N2brEuAadi0CcdeMXUkhbZB84eskAc8MEX1By6qEchoVywSgXPIjou4rYsl0V3Hj0ZnuGycGCjdNgockbzeWNA==} + engines: {node: '>=10.10.0'} + dependencies: + '@humanwhocodes/object-schema': 1.2.1 + debug: 4.3.4(supports-color@8.1.1) + minimatch: 3.1.2 + transitivePeerDependencies: + - supports-color + dev: true + /@humanwhocodes/module-importer@1.0.1: resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} engines: {node: '>=12.22'} @@ -1544,6 +1519,22 @@ packages: - utf-8-validate dev: false + /@solana/spl-token@0.3.8(@solana/web3.js@1.78.4): + resolution: {integrity: sha512-ogwGDcunP9Lkj+9CODOWMiVJEdRtqHAtX2rWF62KxnnSWtMZtV9rDhTrZFshiyJmxDnRL/1nKE1yJHg4jjs3gg==} + engines: {node: '>=16'} + peerDependencies: + '@solana/web3.js': ^1.47.4 + dependencies: + '@solana/buffer-layout': 4.0.0 + '@solana/buffer-layout-utils': 0.2.0 + '@solana/web3.js': 1.78.4 + buffer: 6.0.3 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + dev: false + /@solana/web3.js@1.77.3: resolution: {integrity: sha512-PHaO0BdoiQRPpieC1p31wJsBaxwIOWLh8j2ocXNKX8boCQVldt26Jqm2tZE4KlrvnCIV78owPLv1pEUgqhxZ3w==} dependencies: @@ -1591,6 +1582,7 @@ packages: - bufferutil - encoding - utf-8-validate + dev: false /@solana/web3.js@1.78.4: resolution: {integrity: sha512-up5VG1dK+GPhykmuMIozJZBbVqpm77vbOG6/r5dS7NBGZonwHfTLdBbsYc3rjmaQ4DpCXUa3tUc4RZHRORvZrw==} @@ -1615,6 +1607,24 @@ packages: - encoding - utf-8-validate + /@switchboard-xyz/common@2.3.3(@solana/web3.js@1.77.3): + resolution: {integrity: sha512-aZK6Wbu1khMn0qRr0viOwCVcDluS3BzvdoQflmmmCMuEpltDgd7vF/Ax4k+z/9EM54jdqwJRPnAKBDni1RpLyA==} + engines: {node: '>=12'} + dependencies: + '@coral-xyz/borsh': 0.28.0(@solana/web3.js@1.77.3) + '@types/big.js': 6.1.6 + '@types/bn.js': 5.1.1 + big.js: 6.2.1 + bn.js: 5.2.1 + bs58: 5.0.0 + decimal.js: 10.4.3 + lodash: 4.17.21 + protobufjs: 7.2.4 + yaml: 2.2.1 + transitivePeerDependencies: + - '@solana/web3.js' + dev: false + /@switchboard-xyz/common@2.3.3(@solana/web3.js@1.78.3): resolution: {integrity: sha512-aZK6Wbu1khMn0qRr0viOwCVcDluS3BzvdoQflmmmCMuEpltDgd7vF/Ax4k+z/9EM54jdqwJRPnAKBDni1RpLyA==} engines: {node: '>=12'} @@ -1633,10 +1643,13 @@ packages: - '@solana/web3.js' dev: false - /@switchboard-xyz/common@2.3.4: - resolution: {integrity: sha512-9ewK3aQxV8P/OgNjCw2fq5SRm+JLK1sf/+vlTozDK4bb9PwaISHZ08QP7IZ7eCZ+Af69X3eFvxeYh3HDfSzlwg==} + /@switchboard-xyz/common@2.3.3(@solana/web3.js@1.78.4): + resolution: {integrity: sha512-aZK6Wbu1khMn0qRr0viOwCVcDluS3BzvdoQflmmmCMuEpltDgd7vF/Ax4k+z/9EM54jdqwJRPnAKBDni1RpLyA==} engines: {node: '>=12'} dependencies: + '@coral-xyz/borsh': 0.28.0(@solana/web3.js@1.78.4) + '@types/big.js': 6.1.6 + '@types/bn.js': 5.1.1 big.js: 6.2.1 bn.js: 5.2.1 bs58: 5.0.0 @@ -1644,20 +1657,22 @@ packages: lodash: 4.17.21 protobufjs: 7.2.4 yaml: 2.2.1 + transitivePeerDependencies: + - '@solana/web3.js' dev: false /@switchboard-xyz/eslint-config@0.1.9: resolution: {integrity: sha512-ZvCAsXn4NsBCECWvew/GIrkvDGzPhhDzT77jkEKQ7Xd2ftrjFJOeYoREDQIOhD88uN3qBl0cIKHbS4t0amkzGw==} dependencies: - '@typescript-eslint/eslint-plugin': 6.4.1(@typescript-eslint/parser@6.4.1)(eslint@8.47.0)(typescript@5.1.6) - '@typescript-eslint/parser': 6.4.1(eslint@8.47.0)(typescript@5.0.4) - '@typescript-eslint/type-utils': 6.4.1(eslint@8.47.0)(typescript@5.1.6) - eslint: 8.47.0 - eslint-config-prettier: 9.0.0(eslint@8.47.0) - eslint-plugin-import: 2.28.1(@typescript-eslint/parser@6.4.1)(eslint@8.47.0) - eslint-plugin-node: 11.1.0(eslint@8.47.0) - eslint-plugin-prettier: 5.0.0(eslint-config-prettier@9.0.0)(eslint@8.47.0)(prettier@2.8.8) - eslint-plugin-simple-import-sort: 10.0.0(eslint@8.47.0) + '@typescript-eslint/eslint-plugin': 6.6.0(@typescript-eslint/parser@6.6.0)(eslint@8.49.0)(typescript@5.1.6) + '@typescript-eslint/parser': 6.6.0(eslint@8.49.0)(typescript@5.0.4) + '@typescript-eslint/type-utils': 6.6.0(eslint@8.49.0)(typescript@5.1.6) + eslint: 8.49.0 + eslint-config-prettier: 9.0.0(eslint@8.49.0) + eslint-plugin-import: 2.28.1(@typescript-eslint/parser@6.6.0)(eslint@8.49.0) + eslint-plugin-node: 11.1.0(eslint@8.49.0) + eslint-plugin-prettier: 5.0.0(eslint-config-prettier@9.0.0)(eslint@8.49.0)(prettier@2.8.8) + eslint-plugin-simple-import-sort: 10.0.0(eslint@8.49.0) prettier: 2.8.8 typescript: 5.1.6 transitivePeerDependencies: @@ -1861,8 +1876,8 @@ packages: '@types/node': 20.4.2 optional: true - /@typescript-eslint/eslint-plugin@6.4.1(@typescript-eslint/parser@6.4.1)(eslint@8.47.0)(typescript@5.1.6): - resolution: {integrity: sha512-3F5PtBzUW0dYlq77Lcqo13fv+58KDwUib3BddilE8ajPJT+faGgxmI9Sw+I8ZS22BYwoir9ZhNXcLi+S+I2bkw==} + /@typescript-eslint/eslint-plugin@6.6.0(@typescript-eslint/parser@6.6.0)(eslint@8.49.0)(typescript@5.1.6): + resolution: {integrity: sha512-CW9YDGTQnNYMIo5lMeuiIG08p4E0cXrXTbcZ2saT/ETE7dWUrNxlijsQeU04qAAKkILiLzdQz+cGFxCJjaZUmA==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha @@ -1873,13 +1888,13 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.6.2 - '@typescript-eslint/parser': 6.4.1(eslint@8.47.0)(typescript@5.0.4) - '@typescript-eslint/scope-manager': 6.4.1 - '@typescript-eslint/type-utils': 6.4.1(eslint@8.47.0)(typescript@5.1.6) - '@typescript-eslint/utils': 6.4.1(eslint@8.47.0)(typescript@5.1.6) - '@typescript-eslint/visitor-keys': 6.4.1 + '@typescript-eslint/parser': 6.6.0(eslint@8.49.0)(typescript@5.0.4) + '@typescript-eslint/scope-manager': 6.6.0 + '@typescript-eslint/type-utils': 6.6.0(eslint@8.49.0)(typescript@5.1.6) + '@typescript-eslint/utils': 6.6.0(eslint@8.49.0)(typescript@5.1.6) + '@typescript-eslint/visitor-keys': 6.6.0 debug: 4.3.4(supports-color@8.1.1) - eslint: 8.47.0 + eslint: 8.49.0 graphemer: 1.4.0 ignore: 5.2.4 natural-compare: 1.4.0 @@ -1890,8 +1905,8 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@6.4.1(eslint@8.47.0)(typescript@5.0.4): - resolution: {integrity: sha512-610G6KHymg9V7EqOaNBMtD1GgpAmGROsmfHJPXNLCU9bfIuLrkdOygltK784F6Crboyd5tBFayPB7Sf0McrQwg==} + /@typescript-eslint/parser@6.6.0(eslint@8.49.0)(typescript@5.0.4): + resolution: {integrity: sha512-setq5aJgUwtzGrhW177/i+DMLqBaJbdwGj2CPIVFFLE0NCliy5ujIdLHd2D1ysmlmsjdL2GWW+hR85neEfc12w==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^7.0.0 || ^8.0.0 @@ -1900,27 +1915,27 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/scope-manager': 6.4.1 - '@typescript-eslint/types': 6.4.1 - '@typescript-eslint/typescript-estree': 6.4.1(typescript@5.0.4) - '@typescript-eslint/visitor-keys': 6.4.1 + '@typescript-eslint/scope-manager': 6.6.0 + '@typescript-eslint/types': 6.6.0 + '@typescript-eslint/typescript-estree': 6.6.0(typescript@5.0.4) + '@typescript-eslint/visitor-keys': 6.6.0 debug: 4.3.4(supports-color@8.1.1) - eslint: 8.47.0 + eslint: 8.49.0 typescript: 5.0.4 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/scope-manager@6.4.1: - resolution: {integrity: sha512-p/OavqOQfm4/Hdrr7kvacOSFjwQ2rrDVJRPxt/o0TOWdFnjJptnjnZ+sYDR7fi4OimvIuKp+2LCkc+rt9fIW+A==} + /@typescript-eslint/scope-manager@6.6.0: + resolution: {integrity: sha512-pT08u5W/GT4KjPUmEtc2kSYvrH8x89cVzkA0Sy2aaOUIw6YxOIjA8ilwLr/1fLjOedX1QAuBpG9XggWqIIfERw==} engines: {node: ^16.0.0 || >=18.0.0} dependencies: - '@typescript-eslint/types': 6.4.1 - '@typescript-eslint/visitor-keys': 6.4.1 + '@typescript-eslint/types': 6.6.0 + '@typescript-eslint/visitor-keys': 6.6.0 dev: true - /@typescript-eslint/type-utils@6.4.1(eslint@8.47.0)(typescript@5.1.6): - resolution: {integrity: sha512-7ON8M8NXh73SGZ5XvIqWHjgX2f+vvaOarNliGhjrJnv1vdjG0LVIz+ToYfPirOoBi56jxAKLfsLm40+RvxVVXA==} + /@typescript-eslint/type-utils@6.6.0(eslint@8.49.0)(typescript@5.1.6): + resolution: {integrity: sha512-8m16fwAcEnQc69IpeDyokNO+D5spo0w1jepWWY2Q6y5ZKNuj5EhVQXjtVAeDDqvW6Yg7dhclbsz6rTtOvcwpHg==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^7.0.0 || ^8.0.0 @@ -1929,23 +1944,23 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/typescript-estree': 6.4.1(typescript@5.1.6) - '@typescript-eslint/utils': 6.4.1(eslint@8.47.0)(typescript@5.1.6) + '@typescript-eslint/typescript-estree': 6.6.0(typescript@5.1.6) + '@typescript-eslint/utils': 6.6.0(eslint@8.49.0)(typescript@5.1.6) debug: 4.3.4(supports-color@8.1.1) - eslint: 8.47.0 + eslint: 8.49.0 ts-api-utils: 1.0.1(typescript@5.1.6) typescript: 5.1.6 transitivePeerDependencies: - supports-color dev: true - /@typescript-eslint/types@6.4.1: - resolution: {integrity: sha512-zAAopbNuYu++ijY1GV2ylCsQsi3B8QvfPHVqhGdDcbx/NK5lkqMnCGU53amAjccSpk+LfeONxwzUhDzArSfZJg==} + /@typescript-eslint/types@6.6.0: + resolution: {integrity: sha512-CB6QpJQ6BAHlJXdwUmiaXDBmTqIE2bzGTDLADgvqtHWuhfNP3rAOK7kAgRMAET5rDRr9Utt+qAzRBdu3AhR3sg==} engines: {node: ^16.0.0 || >=18.0.0} dev: true - /@typescript-eslint/typescript-estree@6.4.1(typescript@5.0.4): - resolution: {integrity: sha512-xF6Y7SatVE/OyV93h1xGgfOkHr2iXuo8ip0gbfzaKeGGuKiAnzS+HtVhSPx8Www243bwlW8IF7X0/B62SzFftg==} + /@typescript-eslint/typescript-estree@6.6.0(typescript@5.0.4): + resolution: {integrity: sha512-hMcTQ6Al8MP2E6JKBAaSxSVw5bDhdmbCEhGW/V8QXkb9oNsFkA4SBuOMYVPxD3jbtQ4R/vSODBsr76R6fP3tbA==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: typescript: '*' @@ -1953,8 +1968,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 6.4.1 - '@typescript-eslint/visitor-keys': 6.4.1 + '@typescript-eslint/types': 6.6.0 + '@typescript-eslint/visitor-keys': 6.6.0 debug: 4.3.4(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 @@ -1965,8 +1980,8 @@ packages: - supports-color dev: true - /@typescript-eslint/typescript-estree@6.4.1(typescript@5.1.6): - resolution: {integrity: sha512-xF6Y7SatVE/OyV93h1xGgfOkHr2iXuo8ip0gbfzaKeGGuKiAnzS+HtVhSPx8Www243bwlW8IF7X0/B62SzFftg==} + /@typescript-eslint/typescript-estree@6.6.0(typescript@5.1.6): + resolution: {integrity: sha512-hMcTQ6Al8MP2E6JKBAaSxSVw5bDhdmbCEhGW/V8QXkb9oNsFkA4SBuOMYVPxD3jbtQ4R/vSODBsr76R6fP3tbA==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: typescript: '*' @@ -1974,8 +1989,8 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/types': 6.4.1 - '@typescript-eslint/visitor-keys': 6.4.1 + '@typescript-eslint/types': 6.6.0 + '@typescript-eslint/visitor-keys': 6.6.0 debug: 4.3.4(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 @@ -1986,30 +2001,30 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@6.4.1(eslint@8.47.0)(typescript@5.1.6): - resolution: {integrity: sha512-F/6r2RieNeorU0zhqZNv89s9bDZSovv3bZQpUNOmmQK1L80/cV4KEu95YUJWi75u5PhboFoKUJBnZ4FQcoqhDw==} + /@typescript-eslint/utils@6.6.0(eslint@8.49.0)(typescript@5.1.6): + resolution: {integrity: sha512-mPHFoNa2bPIWWglWYdR0QfY9GN0CfvvXX1Sv6DlSTive3jlMTUy+an67//Gysc+0Me9pjitrq0LJp0nGtLgftw==} engines: {node: ^16.0.0 || >=18.0.0} peerDependencies: eslint: ^7.0.0 || ^8.0.0 dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.47.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.49.0) '@types/json-schema': 7.0.12 '@types/semver': 7.5.0 - '@typescript-eslint/scope-manager': 6.4.1 - '@typescript-eslint/types': 6.4.1 - '@typescript-eslint/typescript-estree': 6.4.1(typescript@5.1.6) - eslint: 8.47.0 + '@typescript-eslint/scope-manager': 6.6.0 + '@typescript-eslint/types': 6.6.0 + '@typescript-eslint/typescript-estree': 6.6.0(typescript@5.1.6) + eslint: 8.49.0 semver: 7.5.4 transitivePeerDependencies: - supports-color - typescript dev: true - /@typescript-eslint/visitor-keys@6.4.1: - resolution: {integrity: sha512-y/TyRJsbZPkJIZQXrHfdnxVnxyKegnpEvnRGNam7s3TRR2ykGefEWOhaef00/UUN3IZxizS7BTO3svd3lCOJRQ==} + /@typescript-eslint/visitor-keys@6.6.0: + resolution: {integrity: sha512-L61uJT26cMOfFQ+lMZKoJNbAEckLe539VhTxiGHrWl5XSKQgA0RTBZJW2HFPy5T0ZvPVSD93QsrTKDkfNwJGyQ==} engines: {node: ^16.0.0 || >=18.0.0} dependencies: - '@typescript-eslint/types': 6.4.1 + '@typescript-eslint/types': 6.6.0 eslint-visitor-keys: 3.4.3 dev: true @@ -3112,13 +3127,13 @@ packages: engines: {node: '>=10'} dev: true - /eslint-config-prettier@9.0.0(eslint@8.47.0): + /eslint-config-prettier@9.0.0(eslint@8.49.0): resolution: {integrity: sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw==} hasBin: true peerDependencies: eslint: '>=7.0.0' dependencies: - eslint: 8.47.0 + eslint: 8.49.0 dev: true /eslint-import-resolver-node@0.3.7: @@ -3131,7 +3146,7 @@ packages: - supports-color dev: true - /eslint-module-utils@2.8.0(@typescript-eslint/parser@6.4.1)(eslint-import-resolver-node@0.3.7)(eslint@8.47.0): + /eslint-module-utils@2.8.0(@typescript-eslint/parser@6.6.0)(eslint-import-resolver-node@0.3.7)(eslint@8.49.0): resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==} engines: {node: '>=4'} peerDependencies: @@ -3152,26 +3167,26 @@ packages: eslint-import-resolver-webpack: optional: true dependencies: - '@typescript-eslint/parser': 6.4.1(eslint@8.47.0)(typescript@5.0.4) + '@typescript-eslint/parser': 6.6.0(eslint@8.49.0)(typescript@5.0.4) debug: 3.2.7 - eslint: 8.47.0 + eslint: 8.49.0 eslint-import-resolver-node: 0.3.7 transitivePeerDependencies: - supports-color dev: true - /eslint-plugin-es@3.0.1(eslint@8.47.0): + /eslint-plugin-es@3.0.1(eslint@8.49.0): resolution: {integrity: sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=4.19.1' dependencies: - eslint: 8.47.0 + eslint: 8.49.0 eslint-utils: 2.1.0 regexpp: 3.2.0 dev: true - /eslint-plugin-import@2.28.1(@typescript-eslint/parser@6.4.1)(eslint@8.47.0): + /eslint-plugin-import@2.28.1(@typescript-eslint/parser@6.6.0)(eslint@8.49.0): resolution: {integrity: sha512-9I9hFlITvOV55alzoKBI+K9q74kv0iKMeY6av5+umsNwayt59fz692daGyjR+oStBQgx6nwR9rXldDev3Clw+A==} engines: {node: '>=4'} peerDependencies: @@ -3181,16 +3196,16 @@ packages: '@typescript-eslint/parser': optional: true dependencies: - '@typescript-eslint/parser': 6.4.1(eslint@8.47.0)(typescript@5.0.4) + '@typescript-eslint/parser': 6.6.0(eslint@8.49.0)(typescript@5.0.4) array-includes: 3.1.6 array.prototype.findlastindex: 1.2.2 array.prototype.flat: 1.3.1 array.prototype.flatmap: 1.3.1 debug: 3.2.7 doctrine: 2.1.0 - eslint: 8.47.0 + eslint: 8.49.0 eslint-import-resolver-node: 0.3.7 - eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.4.1)(eslint-import-resolver-node@0.3.7)(eslint@8.47.0) + eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.6.0)(eslint-import-resolver-node@0.3.7)(eslint@8.49.0) has: 1.0.3 is-core-module: 2.13.0 is-glob: 4.0.3 @@ -3206,14 +3221,14 @@ packages: - supports-color dev: true - /eslint-plugin-node@11.1.0(eslint@8.47.0): + /eslint-plugin-node@11.1.0(eslint@8.49.0): resolution: {integrity: sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==} engines: {node: '>=8.10.0'} peerDependencies: eslint: '>=5.16.0' dependencies: - eslint: 8.47.0 - eslint-plugin-es: 3.0.1(eslint@8.47.0) + eslint: 8.49.0 + eslint-plugin-es: 3.0.1(eslint@8.49.0) eslint-utils: 2.1.0 ignore: 5.2.4 minimatch: 3.1.2 @@ -3221,7 +3236,7 @@ packages: semver: 6.3.1 dev: true - /eslint-plugin-prettier@5.0.0(eslint-config-prettier@9.0.0)(eslint@8.47.0)(prettier@2.8.8): + /eslint-plugin-prettier@5.0.0(eslint-config-prettier@9.0.0)(eslint@8.49.0)(prettier@2.8.8): resolution: {integrity: sha512-AgaZCVuYDXHUGxj/ZGu1u8H8CYgDY3iG6w5kUFw4AzMVXzB7VvbKgYR4nATIN+OvUrghMbiDLeimVjVY5ilq3w==} engines: {node: ^14.18.0 || >=16.0.0} peerDependencies: @@ -3235,19 +3250,19 @@ packages: eslint-config-prettier: optional: true dependencies: - eslint: 8.47.0 - eslint-config-prettier: 9.0.0(eslint@8.47.0) + eslint: 8.49.0 + eslint-config-prettier: 9.0.0(eslint@8.49.0) prettier: 2.8.8 prettier-linter-helpers: 1.0.0 synckit: 0.8.5 dev: true - /eslint-plugin-simple-import-sort@10.0.0(eslint@8.47.0): + /eslint-plugin-simple-import-sort@10.0.0(eslint@8.49.0): resolution: {integrity: sha512-AeTvO9UCMSNzIHRkg8S6c3RPy5YEwKWSQPx3DYghLedo2ZQxowPFLGDN1AZ2evfg6r6mjBSZSLxLFsWSu3acsw==} peerDependencies: eslint: '>=5.0.0' dependencies: - eslint: 8.47.0 + eslint: 8.49.0 dev: true /eslint-scope@7.2.0: @@ -3283,11 +3298,6 @@ packages: engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} dev: true - /eslint-visitor-keys@3.4.2: - resolution: {integrity: sha512-8drBzUEyZ2llkpCA67iYrgEssKDUu68V8ChqqOfFupIaG/LCVPUT+CoGJpT77zJprs4T/W7p07LP7zAIMuweVw==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dev: true - /eslint-visitor-keys@3.4.3: resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -3341,16 +3351,16 @@ packages: - supports-color dev: true - /eslint@8.47.0: - resolution: {integrity: sha512-spUQWrdPt+pRVP1TTJLmfRNJJHHZryFmptzcafwSvHsceV81djHOdnEeDmkdotZyLNjDhrOasNK8nikkoG1O8Q==} + /eslint@8.49.0: + resolution: {integrity: sha512-jw03ENfm6VJI0jA9U+8H5zfl5b+FvuU3YYvZRdZHOlU2ggJkxrlkJH4HcDrZpj6YwD8kuYqvQM8LyesoazrSOQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.47.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.49.0) '@eslint-community/regexpp': 4.6.2 '@eslint/eslintrc': 2.1.2 - '@eslint/js': 8.47.0 - '@humanwhocodes/config-array': 0.11.10 + '@eslint/js': 8.49.0 + '@humanwhocodes/config-array': 0.11.11 '@humanwhocodes/module-importer': 1.0.1 '@nodelib/fs.walk': 1.2.8 ajv: 6.12.6 @@ -3393,7 +3403,7 @@ packages: dependencies: acorn: 8.10.0 acorn-jsx: 5.3.2(acorn@8.10.0) - eslint-visitor-keys: 3.4.2 + eslint-visitor-keys: 3.4.3 dev: true /espree@9.6.1: diff --git a/rust/switchboard-solana/Cargo.anchor27.lock b/rust/switchboard-solana/Cargo.anchor27.lock index 0ef649cc2..63a28f451 100644 --- a/rust/switchboard-solana/Cargo.anchor27.lock +++ b/rust/switchboard-solana/Cargo.anchor27.lock @@ -3890,7 +3890,7 @@ dependencies = [ [[package]] name = "switchboard-solana" -version = "0.27.4" +version = "0.27.8" dependencies = [ "anchor-client", "anchor-lang", diff --git a/rust/switchboard-solana/Cargo.anchor27.toml b/rust/switchboard-solana/Cargo.anchor27.toml index d9698339b..ad9931b2e 100644 --- a/rust/switchboard-solana/Cargo.anchor27.toml +++ b/rust/switchboard-solana/Cargo.anchor27.toml @@ -1,6 +1,6 @@ [package] name = "switchboard-solana" -version = "0.27.5" +version = "0.27.8" edition = "2021" description = "A Rust library to interact with Switchboard accounts." readme = "README.md" diff --git a/rust/switchboard-solana/Cargo.lock b/rust/switchboard-solana/Cargo.lock index 742fb0faf..8767e7288 100644 --- a/rust/switchboard-solana/Cargo.lock +++ b/rust/switchboard-solana/Cargo.lock @@ -1008,6 +1008,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "const-oid" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6f2aa4d0537bcc1c74df8755072bd31c1ef1a3a1b85a68e8404a8c353b7b8b" + [[package]] name = "const-oid" version = "0.7.1" @@ -1114,6 +1120,17 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +[[package]] +name = "crypto-bigint" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83bd3bb4314701c568e340cd8cf78c975aa0ca79e03d3f6d1677d5b0c9c0c03" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", +] + [[package]] name = "crypto-common" version = "0.1.6" @@ -1198,13 +1215,23 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +[[package]] +name = "der" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" +dependencies = [ + "const-oid 0.6.2", + "crypto-bigint", +] + [[package]] name = "der" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6919815d73839e7ad218de758883aae3a257ba6759ce7a9992501efbb53d705c" dependencies = [ - "const-oid", + "const-oid 0.7.1", ] [[package]] @@ -1475,6 +1502,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" @@ -1844,6 +1886,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" @@ -2009,6 +2064,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "lexical-core" @@ -2029,6 +2087,12 @@ version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" +[[package]] +name = "libm" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" + [[package]] name = "libsecp256k1" version = "0.6.0" @@ -2187,6 +2251,24 @@ dependencies = [ "winapi", ] +[[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" @@ -2267,6 +2349,23 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-bigint-dig" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9bc3e36fd683e004fd59c64a425e0e991616f5a8b617c3b9a933a93c168facc" +dependencies = [ + "byteorder", + "lazy_static", + "libm", + "num-integer", + "num-iter", + "num-traits", + "rand 0.8.5", + "smallvec", + "zeroize", +] + [[package]] name = "num-complex" version = "0.2.4" @@ -2328,6 +2427,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", + "libm", ] [[package]] @@ -2409,12 +2509,50 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" +[[package]] +name = "openssl" +version = "0.10.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" +dependencies = [ + "bitflags 2.3.3", + "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.66", + "quote 1.0.32", + "syn 2.0.28", +] + [[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.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "os_str_bytes" version = "6.5.1" @@ -2502,6 +2640,15 @@ dependencies = [ "base64 0.13.1", ] +[[package]] +name = "pem-rfc7468" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f22eb0e3c593294a99e9ff4b24cf6b752d43f193aa4415fe5077c159996d497" +dependencies = [ + "base64ct", +] + [[package]] name = "percent-encoding" version = "2.3.0" @@ -2529,14 +2676,38 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkcs1" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "116bee8279d783c0cf370efa1a94632f2108e5ef0bb32df31f051647810a4e2c" +dependencies = [ + "der 0.4.5", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "pkcs8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee3ef9b64d26bad0536099c816c6734379e45bbd5f14798def6809e5cc350447" +dependencies = [ + "der 0.4.5", + "pem-rfc7468", + "pkcs1", + "spki 0.4.1", + "zeroize", +] + [[package]] name = "pkcs8" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cabda3fb821068a9a4fab19a683eac3af12edf0f34b94a8be53c4972b8149d0" dependencies = [ - "der", - "spki", + "der 0.5.1", + "spki 0.5.4", "zeroize", ] @@ -2903,10 +3074,12 @@ dependencies = [ "http-body", "hyper", "hyper-rustls", + "hyper-tls", "ipnet", "js-sys", "log", "mime", + "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -2916,6 +3089,7 @@ dependencies = [ "serde_json", "serde_urlencoded", "tokio", + "tokio-native-tls", "tokio-rustls", "tokio-util", "tower-service", @@ -2981,6 +3155,26 @@ dependencies = [ "winapi", ] +[[package]] +name = "rsa" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e05c2603e2823634ab331437001b411b9ed11660fbc4066f3908c84a9439260d" +dependencies = [ + "byteorder", + "digest 0.9.0", + "lazy_static", + "num-bigint-dig", + "num-integer", + "num-iter", + "num-traits", + "pkcs1", + "pkcs8 0.7.6", + "rand 0.8.5", + "subtle", + "zeroize", +] + [[package]] name = "rtoolbox" version = "0.0.1" @@ -3948,7 +4142,7 @@ dependencies = [ "nix", "pem", "percentage", - "pkcs8", + "pkcs8 0.8.0", "quinn", "quinn-proto", "quinn-udp", @@ -4136,6 +4330,15 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" +[[package]] +name = "spki" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c01a0c15da1b0b0e1494112e7af814a678fec9bd157881b49beac661e9b6f32" +dependencies = [ + "der 0.4.5", +] + [[package]] name = "spki" version = "0.5.4" @@ -4143,7 +4346,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d01ac02a6ccf3e07db148d2be087da624fea0221a16152ed01f0496a6b0a27" dependencies = [ "base64ct", - "der", + "der 0.5.1", ] [[package]] @@ -4236,11 +4439,13 @@ checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f" [[package]] name = "switchboard-common" -version = "0.8.7" +version = "0.8.15" dependencies = [ "envy", "getrandom 0.2.10", "hex", + "rand 0.8.5", + "reqwest", "serde", "serde_json", "sgx-quote", @@ -4249,7 +4454,7 @@ dependencies = [ [[package]] name = "switchboard-solana" -version = "0.28.6" +version = "0.28.11" dependencies = [ "anchor-client", "anchor-lang", @@ -4259,7 +4464,12 @@ dependencies = [ "chrono", "cron", "hex", + "rand 0.8.5", + "reqwest", + "rsa", "rust_decimal", + "serde", + "serde_json", "sgx-quote", "solana-address-lookup-table-program", "solana-client", @@ -4482,6 +4692,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" @@ -4735,6 +4955,12 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +[[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" diff --git a/rust/switchboard-solana/Cargo.toml b/rust/switchboard-solana/Cargo.toml index 5f243107a..f2e074a35 100644 --- a/rust/switchboard-solana/Cargo.toml +++ b/rust/switchboard-solana/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "switchboard-solana" -version = "0.28.6" +version = "0.28.12" edition = "2021" description = "A Rust library to interact with Switchboard accounts." readme = "README.md" @@ -19,6 +19,7 @@ default = ["cpi"] no-entrypoint = [] cpi = ["no-entrypoint"] + [dependencies] anchor-spl = "0.28.0" solana-program = ">= 1.16, < 1.17" @@ -28,11 +29,11 @@ bytemuck = "^1" superslice = "1" [target.'cfg(target_os = "solana")'.dependencies] -switchboard-common = { version = "0.8.7" } +switchboard-common = { version = "0.8.14" } anchor-lang = { version = "0.28.0" } [target.'cfg(not(target_os = "solana"))'.dependencies] -switchboard-common = { version = "0.8.7", features = [ +switchboard-common = { version = "0.8.15", features = [ "client", "solana", ] } @@ -45,6 +46,11 @@ chrono = { version = "0.4.25" } hex = "0.4.3" tokio = "1" url = "2.4" +rsa = { version = "0.5.0" } +serde = { version = "^1", features = ["derive"] } +serde_json = "^1" +reqwest = { version = "0.11", features = ["json"] } +rand = { version = "0.8.5" } [package.metadata.docs.rs] rustdoc-args = ["--cfg", "doc_cfg"] diff --git a/rust/switchboard-solana/src/attestation_program/instructions/function_close.rs b/rust/switchboard-solana/src/attestation_program/instructions/function_close.rs index 41df778d7..0c1e920ef 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/function_close.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/function_close.rs @@ -3,22 +3,10 @@ use crate::prelude::*; #[derive(Accounts)] #[instruction(params:FunctionCloseParams)] pub struct FunctionClose<'info> { - #[account( - mut, - close = sol_dest, - seeds = [ - FUNCTION_SEED, - function.load()?.creator_seed.as_ref(), - &function.load()?.created_at.to_le_bytes() - ], - bump = function.load()?.bump, - has_one = authority, - has_one = address_lookup_table, - has_one = escrow_wallet, - )] - pub function: AccountLoader<'info, FunctionAccountData>, - - pub authority: Signer<'info>, + #[account(mut)] + pub function: AccountInfo<'info>, + #[account(signer)] + pub authority: AccountInfo<'info>, /// CHECK: handled in function has_one #[account( @@ -28,26 +16,18 @@ pub struct FunctionClose<'info> { pub address_lookup_table: AccountInfo<'info>, #[account(mut)] - pub escrow_wallet: Box>, + pub escrow_wallet: AccountInfo<'info>, // SwitchboardWallet /// CHECK: pub sol_dest: AccountInfo<'info>, - #[account( - mut, - constraint = escrow_dest.is_native() - )] - pub escrow_dest: Box>, - - #[account( - seeds = [STATE_SEED], - bump = state.load()?.bump, - )] - pub state: AccountLoader<'info, AttestationProgramState>, - - pub token_program: Program<'info, Token>, - - pub system_program: Program<'info, System>, + #[account(mut)] + pub escrow_dest: AccountInfo<'info>, + pub state: AccountInfo<'info>, + #[account(address = anchor_spl::token::ID)] + pub token_program: AccountInfo<'info>, + #[account(address = solana_program::system_program::ID)] + pub system_program: AccountInfo<'info>, /// CHECK: #[account( diff --git a/rust/switchboard-solana/src/attestation_program/instructions/function_init.rs b/rust/switchboard-solana/src/attestation_program/instructions/function_init.rs index b98e9c04b..a3fb7f218 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/function_init.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/function_init.rs @@ -4,15 +4,12 @@ use crate::prelude::*; #[instruction(params:FunctionInitParams)] pub struct FunctionInit<'info> { #[account( - init, - space = FunctionAccountData::size(), - payer = payer, - seeds = [FUNCTION_SEED, - params.creator_seed.unwrap_or(payer.key().to_bytes()).as_ref(), - params.recent_slot.to_le_bytes().as_ref()], - bump, - )] - pub function: AccountLoader<'info, FunctionAccountData>, + mut, + signer, + owner = system_program.key(), + constraint = function.data_len() == 0 && function.lamports() == 0, + )] + pub function: AccountInfo<'info>, /// CHECK: todo #[account(mut)] @@ -21,35 +18,36 @@ pub struct FunctionInit<'info> { /// CHECK: pub authority: AccountInfo<'info>, - pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>, + pub attestation_queue: AccountInfo<'info>, - #[account(mut)] - pub payer: Signer<'info>, + #[account(mut, signer)] + pub payer: AccountInfo<'info>, /// CHECK: handle this manually because the PDA seed can vary #[account(mut)] pub wallet: AccountInfo<'info>, - pub wallet_authority: Option>, + #[account(signer)] + pub wallet_authority: Option>, /// CHECK: handle this manually because the PDA seed can vary #[account(mut)] pub token_wallet: AccountInfo<'info>, #[account(address = anchor_spl::token::spl_token::native_mint::ID)] - pub mint: Account<'info, Mint>, - - pub token_program: Program<'info, Token>, - - pub associated_token_program: Program<'info, AssociatedToken>, - - pub system_program: Program<'info, System>, + pub mint: AccountInfo<'info>, + #[account(address = anchor_spl::token::ID)] + pub token_program: AccountInfo<'info>, + #[account(address = anchor_spl::associated_token::ID)] + pub associated_token_program: AccountInfo<'info>, + #[account(address = solana_program::system_program::ID)] + pub system_program: AccountInfo<'info>, /// CHECK: #[account( constraint = address_lookup_program.executable, address = solana_address_lookup_table_program::id(), - )] + )] pub address_lookup_program: AccountInfo<'info>, } diff --git a/rust/switchboard-solana/src/attestation_program/instructions/function_set_config.rs b/rust/switchboard-solana/src/attestation_program/instructions/function_set_config.rs index 8c7db602a..497f67bb0 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/function_set_config.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/function_set_config.rs @@ -3,17 +3,11 @@ use crate::prelude::*; #[derive(Accounts)] #[instruction(params:FunctionSetConfigParams)] pub struct FunctionSetConfig<'info> { - #[account( - mut, - seeds = [FUNCTION_SEED, - function.load()?.creator_seed.as_ref(), - &function.load()?.created_at_slot.to_le_bytes()], - bump = function.load()?.bump, - has_one = authority - )] - pub function: AccountLoader<'info, FunctionAccountData>, + #[account(mut)] + pub function: AccountInfo<'info>, - pub authority: Signer<'info>, + #[account(signer)] + pub authority: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] diff --git a/rust/switchboard-solana/src/attestation_program/instructions/function_set_escrow.rs b/rust/switchboard-solana/src/attestation_program/instructions/function_set_escrow.rs index 94d0b13e5..300402079 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/function_set_escrow.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/function_set_escrow.rs @@ -3,43 +3,29 @@ use crate::prelude::*; #[derive(Accounts)] #[instruction(params:FunctionSetEscrowParams)] pub struct FunctionSetEscrow<'info> { - #[account( - mut, - seeds = [ - FUNCTION_SEED, - function.load()?.creator_seed.as_ref(), - &function.load()?.created_at_slot.to_le_bytes() - ], - bump = function.load()?.bump, - has_one = authority @ SwitchboardError::InvalidAuthority, - has_one = escrow_wallet, - )] - pub function: AccountLoader<'info, FunctionAccountData>, - - pub authority: Signer<'info>, - - pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>, - - #[account( - mut, - constraint = escrow_wallet.authority == escrow_authority.key() - )] - pub escrow_wallet: Box>, + #[account(mut)] + pub function: AccountInfo<'info>, + + #[account(signer)] + pub authority: AccountInfo<'info>, + + pub attestation_queue: AccountInfo<'info>, + + #[account(mut)] + pub escrow_wallet: AccountInfo<'info>, /// CHECK: pub escrow_authority: AccountInfo<'info>, - #[account( - mut, - constraint = new_escrow.authority == new_escrow_authority.key() && new_escrow.token_wallet == new_escrow_token_wallet.key() - )] - pub new_escrow: Box>, + #[account(mut)] + pub new_escrow: AccountInfo<'info>, /// CHECK: - pub new_escrow_authority: Signer<'info>, + #[account(signer)] + pub new_escrow_authority: AccountInfo<'info>, /// CHECK: - pub new_escrow_token_wallet: Box>, + pub new_escrow_token_wallet: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] diff --git a/rust/switchboard-solana/src/attestation_program/instructions/function_trigger.rs b/rust/switchboard-solana/src/attestation_program/instructions/function_trigger.rs index 317f3e0ec..fac4cbdf0 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/function_trigger.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/function_trigger.rs @@ -3,22 +3,13 @@ use crate::prelude::*; #[derive(Accounts)] #[instruction(params:FunctionTriggerParams)] pub struct FunctionTrigger<'info> { - #[account( - mut, - seeds = [ - FUNCTION_SEED, - function.load()?.creator_seed.as_ref(), - &function.load()?.created_at_slot.to_le_bytes() - ], - bump = function.load()?.bump, - has_one = authority, - has_one = attestation_queue, - )] - pub function: AccountLoader<'info, FunctionAccountData>, + #[account(mut)] + pub function: AccountInfo<'info>, - pub authority: Signer<'info>, + #[account(signer)] + pub authority: AccountInfo<'info>, - pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>, + pub attestation_queue: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] diff --git a/rust/switchboard-solana/src/attestation_program/instructions/function_verify.rs b/rust/switchboard-solana/src/attestation_program/instructions/function_verify.rs index 7ef8313f2..2bed6b565 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/function_verify.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/function_verify.rs @@ -3,48 +3,22 @@ use crate::prelude::*; #[derive(Accounts)] #[instruction(params: FunctionVerifyParams)] // rpc parameters hint pub struct FunctionVerify<'info> { - #[account( - mut, - seeds = [FUNCTION_SEED, - function.load()?.creator_seed.as_ref(), - &function.load()?.created_at_slot.to_le_bytes()], - bump = function.load()?.bump, - has_one = attestation_queue, - has_one = escrow_token_wallet, - has_one = escrow_wallet, - )] - pub function: AccountLoader<'info, FunctionAccountData>, - - pub function_enclave_signer: Signer<'info>, - - #[account( - has_one = attestation_queue, - constraint = verifier.load()?.enclave.enclave_signer == verifier_signer.key(), - )] - pub verifier: AccountLoader<'info, VerifierAccountData>, - - pub verifier_signer: Signer<'info>, - - #[account( - seeds = [PERMISSION_SEED, - attestation_queue.load()?.authority.as_ref(), - attestation_queue.key().as_ref(), - verifier.key().as_ref()], - bump = verifier_permission.load()?.bump, - )] - pub verifier_permission: AccountLoader<'info, AttestationPermissionAccountData>, - - pub escrow_wallet: Box>, - - #[account(mut, constraint = escrow_token_wallet.is_native())] - pub escrow_token_wallet: Box>, - - #[account(mut, constraint = receiver.is_native())] - pub receiver: Box>, - - pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>, - - pub token_program: Program<'info, Token>, + #[account(mut)] + pub function: AccountInfo<'info>, // FunctionAccountData + #[account(signer)] + pub function_enclave_signer: AccountInfo<'info>, // SystemProgram keypair + pub verifier: AccountInfo<'info>, // VerifierAccountData + #[account(signer)] + pub verifier_signer: AccountInfo<'info>, + pub verifier_permission: AccountInfo<'info>, // AttestationPermissionAccountData + pub escrow_wallet: AccountInfo<'info>, // SwitchboardWallet + #[account(mut)] + pub escrow_token_wallet: AccountInfo<'info>, // TokenAccount + #[account(mut)] + pub receiver: AccountInfo<'info>, // TokenAccount + pub attestation_queue: AccountInfo<'info>, // AttestationQueueAccountData + #[account(address = anchor_spl::token::ID)] + pub token_program: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] diff --git a/rust/switchboard-solana/src/attestation_program/instructions/mod.rs b/rust/switchboard-solana/src/attestation_program/instructions/mod.rs index a0077fa08..98ac3a823 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/mod.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/mod.rs @@ -16,21 +16,24 @@ pub use function_verify::*; pub mod function_close; pub use function_close::*; +pub mod request_close; +pub use request_close::*; + pub mod request_init_and_trigger; pub use request_init_and_trigger::*; pub mod request_init; pub use request_init::*; +pub mod request_set_config; +pub use request_set_config::*; + pub mod request_trigger; pub use request_trigger::*; pub mod request_verify; pub use request_verify::*; -pub mod request_close; -pub use request_close::*; - pub mod wallet_init; pub use wallet_init::*; diff --git a/rust/switchboard-solana/src/attestation_program/instructions/request_close.rs b/rust/switchboard-solana/src/attestation_program/instructions/request_close.rs index bdd2d9c64..a9f007caa 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/request_close.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/request_close.rs @@ -3,38 +3,24 @@ use crate::prelude::*; #[derive(Accounts)] #[instruction(params:FunctionRequestCloseParams)] pub struct FunctionRequestClose<'info> { - #[account( - mut, - close = authority, - has_one = function, - has_one = escrow, - has_one = authority, - )] - pub request: Box>, + #[account(mut)] + pub request: AccountInfo<'info>, /// CHECK: Only needs to sign if request.garbage_collection_slot has not elapsed pub authority: AccountInfo<'info>, - #[account( - mut, - constraint = escrow.is_native() && escrow.owner == state.key() - )] - pub escrow: Box>, + #[account(mut)] + pub escrow: AccountInfo<'info>, /// CHECK: we need to load_mut and remove_request #[account(mut)] - pub function: AccountLoader<'info, FunctionAccountData>, + pub function: AccountInfo<'info>, /// CHECK: allow partial funds to be sent to the claimer only if request.garbage_collection_slot has elapsed pub sol_dest: AccountInfo<'info>, - #[account( - mut, - constraint = escrow_dest.is_native() && escrow_dest.owner == request.authority - )] - pub escrow_dest: Box>, - #[account( - seeds = [STATE_SEED], - bump = state.load()?.bump - )] - pub state: AccountLoader<'info, AttestationProgramState>, - pub token_program: Program<'info, Token>, - pub system_program: Program<'info, System>, + #[account(mut)] + pub escrow_dest: AccountInfo<'info>, + pub state: AccountInfo<'info>, + #[account(address = anchor_spl::token::ID)] + pub token_program: AccountInfo<'info>, + #[account(address = solana_program::system_program::ID)] + pub system_program: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] diff --git a/rust/switchboard-solana/src/attestation_program/instructions/request_init.rs b/rust/switchboard-solana/src/attestation_program/instructions/request_init.rs index 212b4562d..21898a51d 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/request_init.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/request_init.rs @@ -4,54 +4,44 @@ use crate::prelude::*; #[instruction(params:FunctionRequestInitParams)] pub struct FunctionRequestInit<'info> { #[account( - init, - payer = payer, - space = FunctionRequestAccountData::space(params.max_container_params_len) + mut, + signer, + owner = system_program.key(), + constraint = request.data_len() == 0 && request.lamports() == 0, )] - pub request: Box>, + pub request: AccountInfo<'info>, /// CHECK: the authority of the request pub authority: AccountInfo<'info>, - #[account( - mut, // write lock issues ?? - has_one = attestation_queue, - // has_one = authority @ SwitchboardError::InvalidAuthority, - )] - pub function: AccountLoader<'info, FunctionAccountData>, + #[account(mut)] + pub function: AccountInfo<'info>, /// CHECK: function authority required to permit new requests #[account(mut)] pub function_authority: Option>, #[account( - init, - payer = payer, - associated_token::mint = mint, - associated_token::authority = request, - + mut, + owner = system_program.key(), + constraint = request.data_len() == 0 && request.lamports() == 0, )] - pub escrow: Box>, + pub escrow: AccountInfo<'info>, #[account(address = anchor_spl::token::spl_token::native_mint::ID)] - pub mint: Account<'info, Mint>, - - #[account( - seeds = [STATE_SEED], - bump = state.load()?.bump - )] - pub state: AccountLoader<'info, AttestationProgramState>, - - pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>, - - #[account(mut)] - pub payer: Signer<'info>, - - pub system_program: Program<'info, System>, - - pub token_program: Program<'info, Token>, - - pub associated_token_program: Program<'info, AssociatedToken>, + pub mint: AccountInfo<'info>, + + pub state: AccountInfo<'info>, + pub attestation_queue: AccountInfo<'info>, + + #[account(mut, signer)] + pub payer: AccountInfo<'info>, + #[account(address = solana_program::system_program::ID)] + pub system_program: AccountInfo<'info>, + #[account(address = anchor_spl::token::ID)] + pub token_program: AccountInfo<'info>, + #[account(address = anchor_spl::associated_token::ID)] + pub associated_token_program: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] diff --git a/rust/switchboard-solana/src/attestation_program/instructions/request_init_and_trigger.rs b/rust/switchboard-solana/src/attestation_program/instructions/request_init_and_trigger.rs index 1d1c29c06..ed39f529d 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/request_init_and_trigger.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/request_init_and_trigger.rs @@ -11,11 +11,8 @@ pub struct FunctionRequestInitAndTrigger<'info> { )] pub request: AccountInfo<'info>, - #[account( - mut, - has_one = attestation_queue, - )] - pub function: AccountLoader<'info, FunctionAccountData>, + #[account(mut)] + pub function: AccountInfo<'info>, #[account( mut, @@ -25,24 +22,21 @@ pub struct FunctionRequestInitAndTrigger<'info> { pub escrow: AccountInfo<'info>, #[account(address = anchor_spl::token::spl_token::native_mint::ID)] - pub mint: Account<'info, Mint>, - - #[account( - seeds = [STATE_SEED], - bump = state.load()?.bump, - )] - pub state: AccountLoader<'info, AttestationProgramState>, + pub mint: AccountInfo<'info>, - pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>, - - #[account(mut)] - pub payer: Signer<'info>, + pub state: AccountInfo<'info>, - pub system_program: Program<'info, System>, + pub attestation_queue: AccountInfo<'info>, - pub token_program: Program<'info, Token>, + #[account(mut, signer)] + pub payer: AccountInfo<'info>, - pub associated_token_program: Program<'info, AssociatedToken>, + #[account(address = solana_program::system_program::ID)] + pub system_program: AccountInfo<'info>, + #[account(address = anchor_spl::token::ID)] + pub token_program: AccountInfo<'info>, + #[account(address = anchor_spl::associated_token::ID)] + pub associated_token_program: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] diff --git a/rust/switchboard-solana/src/attestation_program/instructions/request_set_config.rs b/rust/switchboard-solana/src/attestation_program/instructions/request_set_config.rs new file mode 100644 index 000000000..8df98c49b --- /dev/null +++ b/rust/switchboard-solana/src/attestation_program/instructions/request_set_config.rs @@ -0,0 +1,89 @@ +use crate::prelude::*; + +#[derive(Accounts)] +#[instruction(params:FunctionRequestSetConfigParams)] +pub struct FunctionRequestSetConfig<'info> { + #[account(mut)] + pub request: AccountInfo<'info>, + #[account(signer)] + pub authority: AccountInfo<'info>, +} + +#[derive(Clone, AnchorSerialize, AnchorDeserialize)] +pub struct FunctionRequestSetConfigParams { + pub container_params: Vec, + pub append_container_params: bool, +} + +impl InstructionData for FunctionRequestSetConfigParams {} + +impl Discriminator for FunctionRequestSetConfigParams { + const DISCRIMINATOR: [u8; 8] = [16, 81, 197, 58, 129, 125, 91, 233]; +} + +impl Discriminator for FunctionRequestSetConfig<'_> { + const DISCRIMINATOR: [u8; 8] = [16, 81, 197, 58, 129, 125, 91, 233]; +} + +impl<'info> FunctionRequestSetConfig<'info> { + pub fn get_instruction( + &self, + program_id: Pubkey, + container_params: Vec, + append_container_params: bool, + ) -> anchor_lang::Result { + let accounts = self.to_account_metas(None); + + let mut data: Vec = FunctionRequestSetConfig::discriminator().try_to_vec()?; + let params = FunctionRequestSetConfigParams { + container_params, + append_container_params, + }; + data.append(&mut params.try_to_vec()?); + + let instruction = Instruction::new_with_bytes(program_id, &data, accounts); + Ok(instruction) + } + + pub fn invoke( + &self, + program: AccountInfo<'info>, + container_params: Vec, + append_container_params: bool, + ) -> ProgramResult { + let instruction = + self.get_instruction(*program.key, container_params, append_container_params)?; + let account_infos = self.to_account_infos(); + + invoke(&instruction, &account_infos[..]) + } + + pub fn invoke_signed( + &self, + program: AccountInfo<'info>, + container_params: Vec, + append_container_params: bool, + signer_seeds: &[&[&[u8]]], + ) -> ProgramResult { + let instruction = + self.get_instruction(*program.key, container_params, append_container_params)?; + let account_infos = self.to_account_infos(); + + invoke_signed(&instruction, &account_infos[..], signer_seeds) + } + + fn to_account_infos(&self) -> Vec> { + let mut account_infos = Vec::new(); + account_infos.extend(self.request.to_account_infos()); + account_infos.extend(self.authority.to_account_infos()); + account_infos + } + + #[allow(unused_variables)] + fn to_account_metas(&self, is_signer: Option) -> Vec { + let mut account_metas = Vec::new(); + account_metas.extend(self.request.to_account_metas(None)); + account_metas.extend(self.authority.to_account_metas(Some(true))); + account_metas + } +} diff --git a/rust/switchboard-solana/src/attestation_program/instructions/request_trigger.rs b/rust/switchboard-solana/src/attestation_program/instructions/request_trigger.rs index 9c67e2c5b..b6286cce5 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/request_trigger.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/request_trigger.rs @@ -3,50 +3,28 @@ use crate::prelude::*; #[derive(Accounts)] #[instruction(params:FunctionRequestTriggerParams)] pub struct FunctionRequestTrigger<'info> { - #[account( - mut, - has_one = function, - has_one = escrow, - has_one = authority, - )] - pub request: Box>, - - /// CHECK: the request authority must authorize new requests - pub authority: Signer<'info>, - - #[account( - mut, - constraint = escrow.is_native() && escrow.owner == state.key() - )] - pub escrow: Box>, - - #[account( - mut, - has_one = attestation_queue @ SwitchboardError::InvalidQueue, - )] - pub function: AccountLoader<'info, FunctionAccountData>, - - #[account( - seeds = [STATE_SEED], - bump = state.load()?.bump, - )] - pub state: AccountLoader<'info, AttestationProgramState>, - - pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>, - #[account(mut)] - pub payer: Signer<'info>, - - pub token_program: Program<'info, Token>, - - pub system_program: Program<'info, System>, + pub request: AccountInfo<'info>, + #[account(signer)] + pub authority: AccountInfo<'info>, + #[account(mut)] + pub escrow: AccountInfo<'info>, + #[account(mut)] + pub function: AccountInfo<'info>, + pub state: AccountInfo<'info>, + pub attestation_queue: AccountInfo<'info>, + #[account(mut, signer)] + pub payer: AccountInfo<'info>, + #[account(address = anchor_spl::token::ID)] + pub token_program: AccountInfo<'info>, + #[account(address = solana_program::system_program::ID)] + pub system_program: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] pub struct FunctionRequestTriggerParams { pub bounty: Option, pub slots_until_expiration: Option, - // TODO: maybe add param to force transfer from function escrow if authority signs pub valid_after_slot: Option, } diff --git a/rust/switchboard-solana/src/attestation_program/instructions/request_verify.rs b/rust/switchboard-solana/src/attestation_program/instructions/request_verify.rs index 19623f221..5ff3375e8 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/request_verify.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/request_verify.rs @@ -3,67 +3,26 @@ use crate::prelude::*; #[derive(Accounts)] #[instruction(params:FunctionRequestVerifyParams)] pub struct FunctionRequestVerify<'info> { - #[account( - mut, - has_one = function, - has_one = escrow, - )] - pub request: Box>, - - pub function_enclave_signer: Signer<'info>, - - #[account( - mut, - constraint = escrow.is_native() && escrow.owner == state.key() - )] - pub escrow: Box>, - - #[account( - mut, - has_one = attestation_queue, - )] - pub function: AccountLoader<'info, FunctionAccountData>, - - #[account( - mut, - constraint = escrow.is_native() && escrow.owner == state.key() - )] - pub function_escrow: Option>>, - - #[account( - has_one = attestation_queue, - constraint = verifier_quote.load()?.enclave.enclave_signer == verifier_enclave_signer.key(), - )] - pub verifier_quote: AccountLoader<'info, VerifierAccountData>, - - pub verifier_enclave_signer: Signer<'info>, - - #[account( - seeds = [ - PERMISSION_SEED, - attestation_queue.load()?.authority.as_ref(), - attestation_queue.key().as_ref(), - verifier_quote.key().as_ref() - ], - bump = verifier_permission.load()?.bump, - )] - pub verifier_permission: AccountLoader<'info, AttestationPermissionAccountData>, - - #[account( - seeds = [STATE_SEED], - bump = state.load()?.bump, - )] - pub state: AccountLoader<'info, AttestationProgramState>, - - pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>, - - #[account( - mut, - constraint = receiver.is_native() - )] - pub receiver: Box>, - - pub token_program: Program<'info, Token>, + #[account(mut)] + pub request: AccountInfo<'info>, // FunctionRequestAccount + #[account(signer)] + pub function_enclave_signer: AccountInfo<'info>, // SystemProgram keypair + #[account(mut)] + pub escrow: AccountInfo<'info>, // TokenAccount + #[account(mut)] + pub function: AccountInfo<'info>, // FunctionAccount + #[account(mut)] + pub function_escrow: Option>, // TokenAccount + pub verifier_quote: AccountInfo<'info>, // VerifierAccountData + #[account(signer)] + pub verifier_enclave_signer: AccountInfo<'info>, // SystemProgram keypair + pub verifier_permission: AccountInfo<'info>, // AttestationPermissionAccount + pub state: AccountInfo<'info>, // AttestationProgramState + pub attestation_queue: AccountInfo<'info>, // AttestationQueueAccount + #[account(mut)] + pub receiver: AccountInfo<'info>, // TokenAccount + #[account(address = anchor_spl::token::ID)] + pub token_program: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] diff --git a/rust/switchboard-solana/src/attestation_program/instructions/wallet_fund.rs b/rust/switchboard-solana/src/attestation_program/instructions/wallet_fund.rs index 107b16c4b..120c7712a 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/wallet_fund.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/wallet_fund.rs @@ -3,47 +3,24 @@ use crate::prelude::*; #[derive(Accounts)] #[instruction(params:WalletFundParams)] pub struct WalletFund<'info> { - #[account( - mut, - seeds = [ - mint.key().as_ref(), - attestation_queue.key().as_ref(), - authority.key().as_ref(), - &wallet.name, - ], - bump = wallet.bump, - has_one = token_wallet, - )] - pub wallet: Box>, - + #[account(mut)] + pub wallet: AccountInfo<'info>, // SwitchboardWallet #[account(address = anchor_spl::token::spl_token::native_mint::ID)] - pub mint: Account<'info, Mint>, - + pub mint: AccountInfo<'info>, // TokenMint /// CHECK: pub authority: AccountInfo<'info>, - - // allows us to pull mint from the queue if we ever need to - pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>, - + pub attestation_queue: AccountInfo<'info>, // AttestationQueueAccountData #[account(mut)] - pub token_wallet: Box>, - - #[account( - mut, - constraint = funder_wallet.mint == token_wallet.mint && funder_wallet.owner == funder.key(), - )] - pub funder_wallet: Option>>, - - pub funder: Signer<'info>, - - #[account( - seeds = [STATE_SEED], - bump = state.load()?.bump - )] - pub state: AccountLoader<'info, AttestationProgramState>, - - pub token_program: Program<'info, Token>, - pub system_program: Program<'info, System>, + pub token_wallet: AccountInfo<'info>, // TokenAccount + #[account(mut)] + pub funder_wallet: Option>, // TokenAccount + #[account(signer)] + pub funder: AccountInfo<'info>, // Signer + pub state: AccountInfo<'info>, // AttestationProgramState + #[account(address = anchor_spl::token::ID)] + pub token_program: AccountInfo<'info>, + #[account(address = solana_program::system_program::ID)] + pub system_program: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] diff --git a/rust/switchboard-solana/src/attestation_program/instructions/wallet_init.rs b/rust/switchboard-solana/src/attestation_program/instructions/wallet_init.rs index 49a8a2b30..46730d222 100644 --- a/rust/switchboard-solana/src/attestation_program/instructions/wallet_init.rs +++ b/rust/switchboard-solana/src/attestation_program/instructions/wallet_init.rs @@ -3,51 +3,25 @@ use crate::prelude::*; #[derive(Accounts)] #[instruction(params:WalletInitParams)] pub struct WalletInit<'info> { - #[account( - init, - space = SwitchboardWallet::space(params.max_len), - payer = payer, - seeds = [ - mint.key().as_ref(), - attestation_queue.key().as_ref(), - authority.key().as_ref(), - &SwitchboardWallet::parse_name(¶ms.name), - ], - bump, - )] - pub wallet: Box>, - + #[account(mut)] + pub wallet: AccountInfo<'info>, // SwitchboardWallet #[account(address = anchor_spl::token::spl_token::native_mint::ID)] - pub mint: Account<'info, Mint>, - + pub mint: AccountInfo<'info>, // Mint /// CHECK: pub authority: AccountInfo<'info>, - // allows us to pull mint from the queue if we ever need to - pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>, - - #[account( - init, - payer = payer, - associated_token::mint = mint, - associated_token::authority = wallet, - )] - pub token_wallet: Box>, - + pub attestation_queue: AccountInfo<'info>, // AttestationQueueAccountData #[account(mut)] - pub payer: Signer<'info>, - - #[account( - seeds = [STATE_SEED], - bump = state.load()?.bump - )] - pub state: AccountLoader<'info, AttestationProgramState>, - - pub token_program: Program<'info, Token>, - - pub associated_token_program: Program<'info, AssociatedToken>, - - pub system_program: Program<'info, System>, + pub token_wallet: AccountInfo<'info>, // TokenAccount + #[account(mut, signer)] + pub payer: AccountInfo<'info>, + pub state: AccountInfo<'info>, // AttestationProgramState + #[account(address = anchor_spl::token::ID)] + pub token_program: AccountInfo<'info>, + #[account(address = anchor_spl::associated_token::ID)] + pub associated_token_program: AccountInfo<'info>, + #[account(address = solana_program::system_program::ID)] + pub system_program: AccountInfo<'info>, } #[derive(Clone, AnchorSerialize, AnchorDeserialize)] diff --git a/rust/switchboard-solana/src/client/function_runner.rs b/rust/switchboard-solana/src/client/function_runner.rs index 1e7504104..1bc68cfab 100644 --- a/rust/switchboard-solana/src/client/function_runner.rs +++ b/rust/switchboard-solana/src/client/function_runner.rs @@ -15,6 +15,10 @@ use switchboard_common::ChainResultInfo::Solana; use switchboard_common::SOLFunctionResult; use switchboard_common::SolanaFunctionEnvironment; +/// A management object for structured runtime for Switchboard Functions on +/// solana. Inititlizing this object will load all required variables +/// from the runtime to execute and sign an output transaction to be verified +/// and committed by the switchboard network. #[derive(Clone)] pub struct FunctionRunner { pub client: Arc, @@ -57,7 +61,6 @@ impl FunctionRunner { let signer = signer_to_pubkey(signer_keypair.clone())?; let env = SolanaFunctionEnvironment::parse()?; - msg!("ENV: {:#?}", env); // required to run let function = Pubkey::from_str(&env.function_key).unwrap(); @@ -174,11 +177,14 @@ impl FunctionRunner { Self::new(cluster.url(), commitment) } + /// Loads the FunctionRunner from runtime settings pub fn from_env(commitment: Option) -> Result { let cluster = Cluster::from_str(&std::env::var("CLUSTER").unwrap()).unwrap(); Self::new_from_cluster(cluster, commitment) } + /// Loads the queue authority provided by the QUEUE_AUTHORITY environment + /// variable async fn load_queue_authority( &self, attestation_queue_pubkey: Pubkey, @@ -207,6 +213,8 @@ impl FunctionRunner { } } + /// Loads the oracle signing key provided by the VERIFIER_ENCLAVE_SIGNER + /// environment variable async fn load_verifier_signer( &self, verifier_pubkey: Pubkey, @@ -232,6 +240,8 @@ impl FunctionRunner { } } + /// Loads the data of the function account provided by the FUNCTION_DATA + /// environment variable. pub async fn load_function_data( &self, ) -> Result, SwitchboardClientError> { @@ -252,6 +262,8 @@ impl FunctionRunner { } } + /// If this execution is tied to a function request, load the data of the + /// execution function request account. pub async fn load_request_data( &self, ) -> Result, SwitchboardClientError> { @@ -280,6 +292,9 @@ impl FunctionRunner { } } + /// Builds the callback instruction to send to the Switchboard oracle network. + /// This will execute the instruction to validate the output transaction + /// was produced in your switchboard enclave. async fn build_fn_verify_ixn( &self, mr_enclave: MrEnclave, @@ -332,6 +347,9 @@ impl FunctionRunner { Ok(ixn) } + /// Builds the callback instruction to send to the Switchboard oracle network. + /// This will execute the instruction to validate the output transaction + /// as well as validate the request parameters used in this run. async fn build_fn_request_verify_ixn( &self, mr_enclave: MrEnclave, @@ -388,6 +406,10 @@ impl FunctionRunner { Ok(ixn) } + /// Generates a FunctionResult object to be emitted at the end of this + /// function run. This function result will be used be the quote verification + /// sidecar to verify the output was run inside the function's enclave + /// and sign the transaction to send back on chain. async fn get_result( &self, mut ixs: Vec, @@ -428,6 +450,8 @@ impl FunctionRunner { }) } + /// Emits a serialized FunctionResult object to send to the quote verification + /// sidecar. pub async fn emit(&self, ixs: Vec) -> Result<(), SwitchboardClientError> { self.get_result(ixs) .await @@ -442,6 +466,8 @@ impl FunctionRunner { } // Useful for building ixns on the client side +/// Implements the instruction schema for serialization the +/// function_verify instruction pub struct FunctionVerifyAccounts { pub function: Pubkey, pub function_enclave_signer: Pubkey, @@ -454,6 +480,7 @@ pub struct FunctionVerifyAccounts { pub attestation_queue: Pubkey, } impl FunctionVerifyAccounts { + /// Generates an instruction to verify the provided function call pub fn get_instruction( &self, params: FunctionVerifyParams, @@ -493,6 +520,8 @@ impl ToAccountMetas for FunctionVerifyAccounts { ] } } +/// Implements the instruction schema for serialization the +/// function_request_verify instruction pub struct FunctionRequestVerifyAccounts { pub request: Pubkey, pub function_enclave_signer: Pubkey, @@ -507,6 +536,7 @@ pub struct FunctionRequestVerifyAccounts { pub attestation_queue: Pubkey, } impl FunctionRequestVerifyAccounts { + /// Generates an instruction to verify the provided request call pub fn get_instruction( &self, params: FunctionRequestVerifyParams, diff --git a/rust/switchboard-solana/src/client/utils.rs b/rust/switchboard-solana/src/client/utils.rs index 1b59704af..5c24e3331 100644 --- a/rust/switchboard-solana/src/client/utils.rs +++ b/rust/switchboard-solana/src/client/utils.rs @@ -12,6 +12,8 @@ pub fn load_env_pubkey(key: &str) -> Result { .map_err(|_| SwitchboardClientError::EnvVariableMissing(key.to_string())) } +/// Creates a signing keypair generated from randomness sourced from the enclave +/// runtime. pub fn generate_signer() -> Arc { let mut randomness = [0; 32]; switchboard_common::Gramine::read_rand(&mut randomness).unwrap(); diff --git a/rust/switchboard-solana/src/instructions.rs b/rust/switchboard-solana/src/instructions.rs index 9039a3db8..34f368f74 100644 --- a/rust/switchboard-solana/src/instructions.rs +++ b/rust/switchboard-solana/src/instructions.rs @@ -5,6 +5,7 @@ pub use crate::oracle_program::instructions::{ pub use crate::attestation_program::instructions::{ FunctionClose, FunctionInit, FunctionRequestClose, FunctionRequestInit, - FunctionRequestInitAndTrigger, FunctionRequestTrigger, FunctionRequestVerify, - FunctionSetEscrow, FunctionTrigger, FunctionVerify, WalletFund, WalletInit, + FunctionRequestInitAndTrigger, FunctionRequestSetConfig, FunctionRequestTrigger, + FunctionRequestVerify, FunctionSetEscrow, FunctionTrigger, FunctionVerify, WalletFund, + WalletInit, }; diff --git a/rust/switchboard-solana/src/lib.rs b/rust/switchboard-solana/src/lib.rs index 5e3f32637..1164a76a1 100644 --- a/rust/switchboard-solana/src/lib.rs +++ b/rust/switchboard-solana/src/lib.rs @@ -106,6 +106,8 @@ pub use oracle_program::*; pub mod attestation_program; pub use attestation_program::*; +pub use switchboard_common::*; + pub mod error; pub mod seeds; @@ -123,6 +125,8 @@ pub mod prelude; cfg_client! { pub mod client; pub use client::*; + pub mod secrets; + pub use secrets::*; } /// Program id for the Switchboard oracle program diff --git a/rust/switchboard-solana/src/secrets.rs b/rust/switchboard-solana/src/secrets.rs new file mode 100644 index 000000000..342e600c9 --- /dev/null +++ b/rust/switchboard-solana/src/secrets.rs @@ -0,0 +1,58 @@ +use crate::*; +use rand::rngs::OsRng; +use serde_json::{json}; +use std::collections::HashMap; +use serde_json; +use serde::Deserialize; +use std::result::Result; +use rsa::{RsaPrivateKey, RsaPublicKey, PaddingScheme, pkcs8::ToPublicKey}; + +#[allow(dead_code)] +#[allow(non_snake_case)] +#[derive(Debug, Deserialize)] +pub struct Secrets { + pub keys: HashMap, +} + +/// `fetch_secrets`: to be used in conjunction with the Switchboard Secrets +/// Server stack. +/// When hosting your own secrets server, you may list the MR_ENCLAVE of the +/// functions you wish to reveal your secrets to. This will only ever expose +/// your secrets to your code. Unless exported in your code, no chain or oracle +/// will be able to view these secrets: +/// +/// # Relevant Materials: +/// - [Secret Server Github Repository](https://github.com/switchboard-xyz/secrets-server) +/// +/// # Parameters: +/// - `url`: the url or ip address of the secrets server in use +/// +/// # Returns +/// - `Map`: The key-value store of your secrets. +pub async fn fetch_secrets(url: &str) -> Result { + let mut os_rng = OsRng::default(); + let priv_key = RsaPrivateKey::new(&mut os_rng, 2048) + .map_err(|_| SwitchboardClientError::KeyParseError)?; + let pub_key = RsaPublicKey::from(&priv_key).to_public_key_der() + .map_err(|_| SwitchboardClientError::KeyParseError)?; + let pub_key: &[u8] = pub_key.as_ref(); + let secrets_quote = Gramine::generate_quote(pub_key) + .map_err(|_| SwitchboardClientError::SgxError)?; + let client = reqwest::Client::new(); + let res = client.post(url) + .json(&json!({ + "quote": &secrets_quote, + "pubkey": pub_key, + })) + .send() + .await + .map_err(|_| SwitchboardClientError::NetworkError)?; + let ciphertext = res.bytes().await.map_err(|_| SwitchboardClientError::NetworkError)?; + let secrets: Secrets; + let padding = PaddingScheme::new_pkcs1v15_encrypt(); + secrets = serde_json::from_slice( + &priv_key.decrypt(padding, &ciphertext).map_err(|_| SwitchboardClientError::DecryptError)? + ).map_err(|_| SwitchboardClientError::ParseError)?; + Ok(secrets) +} + diff --git a/rust/switchboard-solana/src/types.rs b/rust/switchboard-solana/src/types.rs index 9ad65c3ce..b806db46e 100644 --- a/rust/switchboard-solana/src/types.rs +++ b/rust/switchboard-solana/src/types.rs @@ -13,9 +13,10 @@ pub use crate::oracle_program::{ pub use crate::attestation_program::{ FunctionCloseParams, FunctionInitParams, FunctionRequestCloseParams, FunctionRequestInitParams, - FunctionRequestTriggerRound, FunctionRequestVerifyParams, FunctionSetEscrowParams, - FunctionStatus, FunctionTriggerParams, FunctionVerifyParams, MrEnclave, Quote, RequestStatus, - SwitchboardAttestationPermission, VerificationStatus, WalletFundParams, WalletInitParams, + FunctionRequestSetConfigParams, FunctionRequestTriggerRound, FunctionRequestVerifyParams, + FunctionSetEscrowParams, FunctionStatus, FunctionTriggerParams, FunctionVerifyParams, + MrEnclave, Quote, RequestStatus, SwitchboardAttestationPermission, VerificationStatus, + WalletFundParams, WalletInitParams, }; cfg_client! {