diff --git a/pinocchio/swap/Cargo.lock b/pinocchio/swap/Cargo.lock index e367559..7dfbf57 100644 --- a/pinocchio/swap/Cargo.lock +++ b/pinocchio/swap/Cargo.lock @@ -126,8 +126,6 @@ dependencies = [ [[package]] name = "aligned-sized" version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48a526ec4434d531d488af59fe866f36b310fe8906691c75dffa664450a3800a" dependencies = [ "proc-macro2", "quote", @@ -661,6 +659,28 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "aws-lc-rs" +version = "1.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b7b6141e96a8c160799cc2d5adecd5cbbe5054cb8c7c4af53da0f83bb7ad256" +dependencies = [ + "aws-lc-sys", + "zeroize", +] + +[[package]] +name = "aws-lc-sys" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c34dda4df7017c8db52132f0f8a2e0f8161649d15723ed63fc00c82d0f2081a" +dependencies = [ + "cc", + "cmake", + "dunce", + "fs_extra", +] + [[package]] name = "base64" version = "0.12.3" @@ -917,6 +937,12 @@ dependencies = [ "shlex", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cfg-if" version = "1.0.4" @@ -949,7 +975,6 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", - "serde", "wasm-bindgen", "windows-link", ] @@ -964,6 +989,15 @@ dependencies = [ "inout", ] +[[package]] +name = "cmake" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75443c44cd6b379beb8c5b45d85d0773baf31cce901fe7bb252f4eff3008ef7d" +dependencies = [ + "cc", +] + [[package]] name = "combine" version = "3.8.1" @@ -977,6 +1011,16 @@ dependencies = [ "unreachable", ] +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "compression-codecs" version = "0.4.36" @@ -1044,6 +1088,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -1215,16 +1269,6 @@ dependencies = [ "syn 2.0.114", ] -[[package]] -name = "deranged" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ececcb659e7ba858fb4f10388c250a7252eb0a27373f1a72b8748afdd248e587" -dependencies = [ - "powerfmt", - "serde_core", -] - [[package]] name = "derivation-path" version = "0.2.0" @@ -1274,10 +1318,10 @@ dependencies = [ ] [[package]] -name = "dyn-clone" -version = "1.0.20" +name = "dunce" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" +checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "eager" @@ -1541,6 +1585,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "funty" version = "2.0.0" @@ -1723,7 +1773,7 @@ dependencies = [ "futures-sink", "futures-util", "http 0.2.12", - "indexmap 2.13.0", + "indexmap", "slab", "tokio", "tokio-util 0.7.18", @@ -1742,7 +1792,7 @@ dependencies = [ "futures-core", "futures-sink", "http 1.4.0", - "indexmap 2.13.0", + "indexmap", "slab", "tokio", "tokio-util 0.7.18", @@ -1758,12 +1808,6 @@ dependencies = [ "byteorder", ] -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" - [[package]] name = "hashbrown" version = "0.13.2" @@ -1814,12 +1858,6 @@ dependencies = [ "libc", ] -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - [[package]] name = "hmac" version = "0.8.1" @@ -2186,17 +2224,6 @@ dependencies = [ "icu_properties", ] -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - [[package]] name = "indexmap" version = "2.13.0" @@ -2205,8 +2232,6 @@ checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017" dependencies = [ "equivalent", "hashbrown 0.16.1", - "serde", - "serde_core", ] [[package]] @@ -2289,6 +2314,28 @@ version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" +[[package]] +name = "jni" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" +dependencies = [ + "cesu8", + "cfg-if", + "combine 4.6.7", + "jni-sys", + "log", + "thiserror 1.0.69", + "walkdir", + "windows-sys 0.45.0", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "jobserver" version = "0.1.34" @@ -2406,8 +2453,6 @@ dependencies = [ [[package]] name = "light-account" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7464c25ca421182041ad563d81bf059aa5cd54d8c81caadc46e3999dcd34db" dependencies = [ "light-account-checks", "light-compressed-account", @@ -2425,8 +2470,6 @@ dependencies = [ [[package]] name = "light-account-checks" version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34d74dd13535c6014abb4cac694e14083b206a7f6cf1bbbc9611aa5c2e11cdd1" dependencies = [ "pinocchio", "pinocchio-system", @@ -2444,8 +2487,6 @@ dependencies = [ [[package]] name = "light-account-pinocchio" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbfe2fdd5073284e68b8ba3c1ffe42e40f8d7c2305792244b6bb75c3870691b8" dependencies = [ "light-account-checks", "light-compressed-account", @@ -2463,8 +2504,6 @@ dependencies = [ [[package]] name = "light-array-map" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bdd13b18028ac9d80d0a987551c0dad7fe81be8140e87cc9d568b80f3728203" dependencies = [ "tinyvec", ] @@ -2472,8 +2511,6 @@ dependencies = [ [[package]] name = "light-batched-merkle-tree" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb07ef41d9d99db94072d556767a93d774323bc34940db349555abc4504de015" dependencies = [ "aligned-sized", "borsh 0.10.4", @@ -2497,8 +2534,6 @@ dependencies = [ [[package]] name = "light-bloom-filter" version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b8cf734ccf5fbc1f5fed8e5308b57ebde6774d9304c167bcb0de2854412d8" dependencies = [ "bitvec", "num-bigint 0.4.6", @@ -2522,8 +2557,6 @@ dependencies = [ [[package]] name = "light-client" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "002ae865925850ff8d83448965b79c50c767886415df943170a29715103ded45" dependencies = [ "anchor-lang", "async-trait", @@ -2582,8 +2615,6 @@ dependencies = [ [[package]] name = "light-compressed-account" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7a04e4598c72fdf010bb17021608bbc1a687320305d392dcfcae0738911c786" dependencies = [ "anchor-lang", "borsh 0.10.4", @@ -2604,8 +2635,6 @@ dependencies = [ [[package]] name = "light-compressed-token-sdk" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e56f85162c02208b24d7d9c817a24de1f6116e49f5751b7d8761c72f0021ff" dependencies = [ "anchor-lang", "arrayvec", @@ -2631,8 +2660,6 @@ dependencies = [ [[package]] name = "light-compressible" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0905b52848daea4cb7edbc9ddca0a8d5c4f1d864e89eff0aca3b6fc2a9edbb2" dependencies = [ "aligned-sized", "anchor-lang", @@ -2654,8 +2681,6 @@ dependencies = [ [[package]] name = "light-concurrent-merkle-tree" version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db96f47253a0907aaa46dac15cecb27b5510130e48da0b36690dcd2e99a6d558" dependencies = [ "borsh 0.10.4", "light-bounded-vec", @@ -2668,12 +2693,11 @@ dependencies = [ [[package]] name = "light-event" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d71e91a43f85421eee408bc9656de3158b27389310ba06a4a1c5bf2f87468e" dependencies = [ "borsh 0.10.4", "light-compressed-account", "light-hasher", + "light-token-interface", "light-zero-copy", "thiserror 2.0.18", ] @@ -2681,8 +2705,6 @@ dependencies = [ [[package]] name = "light-hasher" version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c822662e6e109bac0e132a43fd52a4ef684811245a794e048cf9cda001e934c8" dependencies = [ "ark-bn254 0.5.0", "ark-ff 0.5.0", @@ -2699,8 +2721,6 @@ dependencies = [ [[package]] name = "light-indexed-array" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f14f984030d86b6f07bd8f5ae04e2c40fcd0c3bdfcc7a291fff1ed59c9e6554" dependencies = [ "light-hasher", "num-bigint 0.4.6", @@ -2711,8 +2731,6 @@ dependencies = [ [[package]] name = "light-indexed-merkle-tree" version = "5.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0824755289075f28de2820fc7d4ec4e6b9e99d404e033c07338b91cce8c71fb8" dependencies = [ "light-bounded-vec", "light-concurrent-merkle-tree", @@ -2727,8 +2745,6 @@ dependencies = [ [[package]] name = "light-instruction-decoder" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab1c2c1594a3373d0ce2a0af11568c4f1455cb00aa42a606becb49254b0b6c2c" dependencies = [ "borsh 0.10.4", "bs58", @@ -2746,8 +2762,6 @@ dependencies = [ [[package]] name = "light-instruction-decoder-derive" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2035d04a0a1590da05634efcac149a2ac852565e28c9a55bd07a6620c0e90bff" dependencies = [ "bs58", "darling", @@ -2761,8 +2775,6 @@ dependencies = [ [[package]] name = "light-macros" version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "179ac51cadc1d0ca047b4d6265a7cc245ca3affc16a20a2749585aa6464d39c2" dependencies = [ "bs58", "proc-macro2", @@ -2774,8 +2786,6 @@ dependencies = [ [[package]] name = "light-merkle-tree-metadata" version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7623246ad0015345f6a88471f554381e24635b770fe4b15b38384daddf1d2f5f" dependencies = [ "anchor-lang", "borsh 0.10.4", @@ -2791,8 +2801,6 @@ dependencies = [ [[package]] name = "light-merkle-tree-reference" version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8d480f62ca32b38a6231bbc5310d693f91d6b5bdcc18bb13c2d9aab7a1c90e8" dependencies = [ "light-hasher", "light-indexed-array", @@ -2848,8 +2856,6 @@ dependencies = [ [[package]] name = "light-program-test" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49ebb1ed994a05ca5974ad1b701f0dde6c136e41d6387daca7e061720e41b41b" dependencies = [ "anchor-lang", "async-trait", @@ -2904,8 +2910,6 @@ dependencies = [ [[package]] name = "light-prover-client" version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee6e9906d0b834ec2dfe1baf95d61c010f64b3151f4733195fffb8b964ad2763" dependencies = [ "ark-bn254 0.5.0", "ark-serialize 0.5.0", @@ -2928,8 +2932,6 @@ dependencies = [ [[package]] name = "light-sdk" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf31676e72039c1663c9c0cc207572f5bfea985f7a39de346b942b3f4c3b92fe" dependencies = [ "anchor-lang", "bincode", @@ -2961,8 +2963,6 @@ dependencies = [ [[package]] name = "light-sdk-macros" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7186366be777810e54f4025ff388d4463c2314df452a2e7f14cb218977fc1ac7" dependencies = [ "darling", "light-hasher", @@ -2976,8 +2976,6 @@ dependencies = [ [[package]] name = "light-sdk-types" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d60036a8f1af0d3aa651780aa57ae2cdca3fa0f16acecda71c98f81a53e37c9" dependencies = [ "anchor-lang", "borsh 0.10.4", @@ -2996,8 +2994,6 @@ dependencies = [ [[package]] name = "light-sparse-merkle-tree" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4251e79b6c63f4946572dcfd7623680ad0f9e0efe1a761a944733333c5645063" dependencies = [ "light-hasher", "light-indexed-array", @@ -3009,8 +3005,6 @@ dependencies = [ [[package]] name = "light-token" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9940ddbb68ace4cd49e9312bb1d573146232c6460b95f669433b9e1c16fa147b" dependencies = [ "anchor-lang", "arrayvec", @@ -3042,8 +3036,6 @@ dependencies = [ [[package]] name = "light-token-client" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee24ce80a69158bcfb42eaef5bc49c2186cfc607661fc14ecc8e7c9892e9dfe1" dependencies = [ "borsh 0.10.4", "light-client", @@ -3069,8 +3061,6 @@ dependencies = [ [[package]] name = "light-token-interface" version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a457179188d9b6b7208a8a63a1fea851f818adfde3faaa262474bdcd3e3c7d" dependencies = [ "aligned-sized", "anchor-lang", @@ -3097,8 +3087,6 @@ dependencies = [ [[package]] name = "light-token-pinocchio" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7979c3e9db35874f40c65ebee0fd833ac3e90347ad843f9458cfde9effa11e28" dependencies = [ "borsh 0.10.4", "light-account-checks", @@ -3113,8 +3101,6 @@ dependencies = [ [[package]] name = "light-token-types" version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3daffe234719b109238a81d3b61009b9005a58a014436124edf55600361187e2" dependencies = [ "anchor-lang", "borsh 0.10.4", @@ -3129,8 +3115,6 @@ dependencies = [ [[package]] name = "light-verifier" version = "9.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65a33dc6b302f2cfb7319006f1234f1d86c992ac1991ade7c97653828b7f1735" dependencies = [ "groth16-solana", "light-compressed-account", @@ -3140,8 +3124,6 @@ dependencies = [ [[package]] name = "light-zero-copy" version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5621fb515e14af46148699c0b65334aabe230a1d2cbd06736ccc7a408c8a4af" dependencies = [ "light-zero-copy-derive", "solana-program-error", @@ -3151,8 +3133,6 @@ dependencies = [ [[package]] name = "light-zero-copy-derive" version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41c46425e5c7ab5203ff5c86ae2615b169cca55f9283f5f60f5dd74143be6934" dependencies = [ "lazy_static", "proc-macro2", @@ -3183,7 +3163,7 @@ dependencies = [ "agave-reserved-account-keys", "ansi_term", "bincode", - "indexmap 2.13.0", + "indexmap", "itertools 0.14.0", "log", "solana-account", @@ -3298,16 +3278,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "mime_guess" -version = "2.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" -dependencies = [ - "mime", - "unicase", -] - [[package]] name = "miniz_oxide" version = "0.8.9" @@ -3338,10 +3308,10 @@ dependencies = [ "libc", "log", "openssl", - "openssl-probe", + "openssl-probe 0.1.6", "openssl-sys", "schannel", - "security-framework", + "security-framework 2.11.1", "security-framework-sys", "tempfile", ] @@ -3392,12 +3362,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-conv" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" - [[package]] name = "num-derive" version = "0.4.2" @@ -3522,6 +3486,12 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" +[[package]] +name = "openssl-probe" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" + [[package]] name = "openssl-src" version = "300.5.5+3.5.5" @@ -3630,16 +3600,11 @@ dependencies = [ [[package]] name = "photon-api" version = "0.54.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e572dba0c255f5b8176f15b9e849330d915a8927804f7f9702d5bbbc70e4a1ad" dependencies = [ - "reqwest 0.12.28", + "progenitor-client", + "reqwest 0.13.2", "serde", - "serde_derive", "serde_json", - "serde_with", - "url", - "uuid", ] [[package]] @@ -3763,12 +3728,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "powerfmt" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" - [[package]] name = "ppv-lite86" version = "0.2.21" @@ -3827,6 +3786,21 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "progenitor-client" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffab7b358944dba033a7b324e7558e66e6bcb1fb4705cf57f26fd5092bcae630" +dependencies = [ + "bytes", + "futures-core", + "percent-encoding", + "reqwest 0.13.2", + "serde", + "serde_json", + "serde_urlencoded", +] + [[package]] name = "qstring" version = "0.7.2" @@ -3873,6 +3847,7 @@ version = "0.11.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1906b49b0c3bc04b5fe5d86a77925ae6524a19b816ae38ce1e426255f1d8a31" dependencies = [ + "aws-lc-rs", "bytes", "getrandom 0.3.4", "lru-slab", @@ -4052,26 +4027,6 @@ dependencies = [ "bitflags 2.10.0", ] -[[package]] -name = "ref-cast" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.114", -] - [[package]] name = "regex" version = "1.12.3" @@ -4168,7 +4123,6 @@ dependencies = [ "js-sys", "log", "mime", - "mime_guess", "native-tls", "percent-encoding", "pin-project-lite", @@ -4192,6 +4146,47 @@ dependencies = [ "webpki-roots 1.0.6", ] +[[package]] +name = "reqwest" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab3f43e3283ab1488b624b44b0e988d0acea0b3214e694730a055cb6b2efa801" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-core", + "futures-util", + "http 1.4.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.8.1", + "hyper-rustls 0.27.7", + "hyper-util", + "js-sys", + "log", + "percent-encoding", + "pin-project-lite", + "quinn", + "rustls 0.23.36", + "rustls-pki-types", + "rustls-platform-verifier", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 1.0.2", + "tokio", + "tokio-rustls 0.26.4", + "tokio-util 0.7.18", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", +] + [[package]] name = "reqwest-middleware" version = "0.4.2" @@ -4273,6 +4268,7 @@ version = "0.23.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c665f33d38cea657d9614f766881e4d510e0eda4239891eea56b4cadcf01801b" dependencies = [ + "aws-lc-rs", "once_cell", "ring", "rustls-pki-types", @@ -4281,6 +4277,18 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-native-certs" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" +dependencies = [ + "openssl-probe 0.2.1", + "rustls-pki-types", + "schannel", + "security-framework 3.5.1", +] + [[package]] name = "rustls-pemfile" version = "1.0.4" @@ -4300,6 +4308,33 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rustls-platform-verifier" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d99feebc72bae7ab76ba994bb5e121b8d83d910ca40b36e0921f53becc41784" +dependencies = [ + "core-foundation 0.10.1", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls 0.23.36", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki 0.103.9", + "security-framework 3.5.1", + "security-framework-sys", + "webpki-root-certs", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + [[package]] name = "rustls-webpki" version = "0.101.7" @@ -4316,6 +4351,7 @@ version = "0.103.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7df23109aa6c1567d1c575b9952556388da57401e4ace1d15f79eedad0d8f53" dependencies = [ + "aws-lc-rs", "ring", "rustls-pki-types", "untrusted", @@ -4334,36 +4370,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984" [[package]] -name = "schannel" -version = "0.1.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" -dependencies = [ - "windows-sys 0.61.2", -] - -[[package]] -name = "schemars" -version = "0.9.0" +name = "same-file" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", + "winapi-util", ] [[package]] -name = "schemars" -version = "1.2.1" +name = "schannel" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2b42f36aa1cd011945615b92222f6bf73c599a102a300334cd7f8dbeec726cc" +checksum = "891d81b926048e76efe18581bf793546b4c0eaf8448d72be8de2bbee5fd166e1" dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", + "windows-sys 0.61.2", ] [[package]] @@ -4389,7 +4410,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ "bitflags 2.10.0", - "core-foundation", + "core-foundation 0.9.4", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework" +version = "3.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3297343eaf830f66ede390ea39da1d462b6b0c1b000f420d0a83f898bbbe6ef" +dependencies = [ + "bitflags 2.10.0", + "core-foundation 0.10.1", "core-foundation-sys", "libc", "security-framework-sys", @@ -4491,17 +4525,8 @@ version = "3.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4fa237f2807440d238e0364a218270b98f767a00d3dada77b1c53ae88940e2e7" dependencies = [ - "base64 0.22.1", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.13.0", - "schemars 0.9.0", - "schemars 1.2.1", "serde_core", - "serde_json", "serde_with_macros", - "time", ] [[package]] @@ -6082,7 +6107,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "474a2d95dc819898ded08d24f29642d02189d3e1497bbb442a92a3997b7eb55f" dependencies = [ "byteorder", - "combine", + "combine 3.8.1", "hash32", "libc", "log", @@ -7627,7 +7652,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys 0.5.0", ] @@ -7638,7 +7663,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" dependencies = [ "bitflags 2.10.0", - "core-foundation", + "core-foundation 0.9.4", "system-configuration-sys 0.6.0", ] @@ -7807,37 +7832,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "time" -version = "0.3.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9da98b7d9b7dad93488a84b8248efc35352b0b2657397d4167e7ad67e5d535e5" -dependencies = [ - "deranged", - "itoa", - "num-conv", - "powerfmt", - "serde_core", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" - -[[package]] -name = "time-macros" -version = "0.2.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc610bac2dcee56805c99642447d4c5dbde4d01f752ffea0199aee1f601dc4" -dependencies = [ - "num-conv", - "time-core", -] - [[package]] name = "tinystr" version = "0.8.2" @@ -7989,7 +7983,7 @@ version = "0.23.10+spec-1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84c8b9f757e028cee9fa244aea147aab2a9ec09d5325a9b01e0a49730c2b5269" dependencies = [ - "indexmap 2.13.0", + "indexmap", "toml_datetime", "toml_parser", "winnow", @@ -8123,12 +8117,6 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "562d481066bde0658276a35467c4af00bdc6ee726305698a55b86e61d7ad82bb" -[[package]] -name = "unicase" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142" - [[package]] name = "unicode-ident" version = "1.0.22" @@ -8200,18 +8188,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" -[[package]] -name = "uuid" -version = "1.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee48d38b119b0cd71fe4141b30f5ba9c7c5d9f4e7a3a8b4a674e4b6ef789976f" -dependencies = [ - "getrandom 0.3.4", - "js-sys", - "serde_core", - "wasm-bindgen", -] - [[package]] name = "valuable" version = "0.1.1" @@ -8236,6 +8212,16 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + [[package]] name = "want" version = "0.3.1" @@ -8325,6 +8311,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-streams" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "web-sys" version = "0.3.85" @@ -8345,6 +8344,15 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webpki-root-certs" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "804f18a4ac2676ffb4e8b5b5fa9ae38af06df08162314f96a68d2a363e21a8ca" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "webpki-roots" version = "0.25.4" @@ -8461,6 +8469,15 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -8506,6 +8523,21 @@ dependencies = [ "windows-link", ] +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -8554,6 +8586,12 @@ dependencies = [ "windows_x86_64_msvc 0.53.1", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -8572,6 +8610,12 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -8590,6 +8634,12 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -8620,6 +8670,12 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -8638,6 +8694,12 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -8656,6 +8718,12 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -8674,6 +8742,12 @@ version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" diff --git a/pinocchio/swap/Cargo.toml b/pinocchio/swap/Cargo.toml index bfcd59e..1a7da35 100644 --- a/pinocchio/swap/Cargo.toml +++ b/pinocchio/swap/Cargo.toml @@ -15,9 +15,9 @@ test-sbf = [] [dependencies] # Main Light Protocol dependencies -light-account-pinocchio = { version = "0.20", features = ["token", "std"] } -light-token-pinocchio = "0.20" -light-hasher = { version = "5.0.0", features = ["solana"] } +light-account-pinocchio = { git = "https://github.com/Lightprotocol/light-protocol.git", rev = "4c203f065f697b00be635dc9019059584c7b9934", features = ["token", "std"] } +light-token-pinocchio = { git = "https://github.com/Lightprotocol/light-protocol.git", rev = "4c203f065f697b00be635dc9019059584c7b9934" } +light-hasher = { git = "https://github.com/Lightprotocol/light-protocol.git", rev = "4c203f065f697b00be635dc9019059584c7b9934", features = ["solana"] } # Serialization and utilities borsh = { version = "0.10.4", default-features = false } @@ -33,11 +33,11 @@ solana-msg = "2.2" solana-program-error = "2.2" [dev-dependencies] -light-program-test = "0.20" -light-client = { version = "0.20", features = ["v2", "anchor", "program-test"] } -light-token = { version = "0.20", features = ["anchor"] } -light-token-client = "0.20" -light-account = { version = "0.20", features = ["token"] } +light-program-test = { git = "https://github.com/Lightprotocol/light-protocol.git", rev = "4c203f065f697b00be635dc9019059584c7b9934" } +light-client = { git = "https://github.com/Lightprotocol/light-protocol.git", rev = "4c203f065f697b00be635dc9019059584c7b9934", features = ["v2", "anchor", "program-test"] } +light-token = { git = "https://github.com/Lightprotocol/light-protocol.git", rev = "4c203f065f697b00be635dc9019059584c7b9934", features = ["anchor"] } +light-token-client = { git = "https://github.com/Lightprotocol/light-protocol.git", rev = "4c203f065f697b00be635dc9019059584c7b9934" } +light-account = { git = "https://github.com/Lightprotocol/light-protocol.git", rev = "4c203f065f697b00be635dc9019059584c7b9934", features = ["token"] } tokio = { version = "1", features = ["full"] } solana-sdk = "2.2" solana-account = "2.2" diff --git a/pinocchio/swap/tests/sdk.rs b/pinocchio/swap/tests/sdk.rs index c6f656d..52721db 100644 --- a/pinocchio/swap/tests/sdk.rs +++ b/pinocchio/swap/tests/sdk.rs @@ -1,21 +1,14 @@ #![allow(dead_code)] //! SwapSdk implementing LightProgramInterface trait. -//! -//! Provides: -//! - Parsing pool accounts from AccountInterface -//! - Tracking account state (hot/cold) -//! - Building AccountSpec for load instructions use borsh::BorshDeserialize; -use light_account::LightDiscriminator; +use light_account::token::Token; use light_client::interface::{ - AccountInterface, AccountSpec, AccountToFetch, ColdContext, LightProgramInterface, PdaSpec, + AccountInterface, AccountSpec, ColdContext, LightProgramInterface, PdaSpec, }; -use light_account::token::Token; use pinocchio_swap::{LightAccountVariant, PoolState, PoolStateSeeds, VaultSeeds}; use solana_pubkey::Pubkey; -use std::collections::HashMap; pub const PROGRAM_ID: Pubkey = Pubkey::new_from_array(pinocchio_swap::ID); @@ -30,344 +23,163 @@ pub enum SwapInstruction { #[derive(Debug, Clone)] pub enum SwapSdkError { ParseError(String), - UnknownDiscriminator([u8; 8]), - MissingField(&'static str), - PoolStateNotParsed, - AccountNotFound(Pubkey), } impl std::fmt::Display for SwapSdkError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::ParseError(msg) => write!(f, "Parse error: {}", msg), - Self::UnknownDiscriminator(disc) => write!(f, "Unknown discriminator: {:?}", disc), - Self::MissingField(field) => write!(f, "Missing field: {}", field), - Self::PoolStateNotParsed => write!(f, "Pool state must be parsed first"), - Self::AccountNotFound(key) => write!(f, "Account not found: {}", key), } } } impl std::error::Error for SwapSdkError {} -/// SDK for managing swap pool accounts and building decompression instructions. -#[derive(Debug, Clone)] +/// Flat SDK struct. All fields populated at construction from pool state data. +#[derive(Debug)] pub struct SwapSdk { - /// Pool state pubkey - pub pool_state_pubkey: Option, - /// Token A mint pubkey - pub token_a_mint: Option, - /// Token B mint pubkey - pub token_b_mint: Option, - /// Token A vault pubkey - pub token_a_vault: Option, - /// Token B vault pubkey - pub token_b_vault: Option, - /// Pool authority pubkey - pub pool_authority: Option, - /// Cached PDA specs keyed by pubkey (includes pool_state and vaults) - pda_specs: HashMap>, - /// Cached mint interfaces keyed by pubkey - mint_specs: HashMap, -} - -impl Default for SwapSdk { - fn default() -> Self { - Self::new() - } + pub pool_state_pubkey: Pubkey, + pub token_a_mint: Pubkey, + pub token_b_mint: Pubkey, + pub token_a_vault: Pubkey, + pub token_b_vault: Pubkey, + pub pool_authority: Pubkey, } impl SwapSdk { - /// Create a new empty SDK instance. - pub fn new() -> Self { - Self { - pool_state_pubkey: None, - token_a_mint: None, - token_b_mint: None, - token_a_vault: None, - token_b_vault: None, - pool_authority: None, - pda_specs: HashMap::new(), - mint_specs: HashMap::new(), - } - } - - /// Parse pool state from AccountInterface and populate SDK fields. - fn parse_pool_state(&mut self, interface: AccountInterface) -> Result<(), SwapSdkError> { - let data = interface.data(); - if data.len() < 8 { - return Err(SwapSdkError::ParseError( - "Account data too short".to_string(), - )); - } - - // Skip 8-byte discriminator - let pool_state = PoolState::deserialize(&mut &data[8..]) + /// Construct from pool state pubkey and its account data. + pub fn new(pool_state_pubkey: Pubkey, pool_data: &[u8]) -> Result { + let pool = PoolState::deserialize(&mut &pool_data[8..]) .map_err(|e| SwapSdkError::ParseError(e.to_string()))?; - let pool_pubkey = interface.key; - self.pool_state_pubkey = Some(pool_pubkey); - self.token_a_mint = Some(Pubkey::new_from_array(pool_state.token_a_mint)); - self.token_b_mint = Some(Pubkey::new_from_array(pool_state.token_b_mint)); - self.token_a_vault = Some(Pubkey::new_from_array(pool_state.token_a_vault)); - self.token_b_vault = Some(Pubkey::new_from_array(pool_state.token_b_vault)); - - // Derive global pool authority (single seed - same for all pools) let (pool_authority, _) = Pubkey::find_program_address( &[pinocchio_swap::constants::POOL_AUTHORITY_SEED], &PROGRAM_ID, ); - self.pool_authority = Some(pool_authority); - - // Create PdaSpec with variant - let variant = LightAccountVariant::PoolState { - seeds: PoolStateSeeds { - mint_a: pool_state.token_a_mint, - mint_b: pool_state.token_b_mint, - }, - data: pool_state.clone(), - }; - let spec = PdaSpec::new(interface, variant, PROGRAM_ID); - self.pda_specs.insert(pool_pubkey, spec); - Ok(()) + Ok(Self { + pool_state_pubkey, + token_a_mint: Pubkey::new_from_array(pool.token_a_mint), + token_b_mint: Pubkey::new_from_array(pool.token_b_mint), + token_a_vault: Pubkey::new_from_array(pool.token_a_vault), + token_b_vault: Pubkey::new_from_array(pool.token_b_vault), + pool_authority, + }) } - /// Parse token vault from AccountInterface and store as PdaSpec. - fn parse_token_vault( - &mut self, + /// Convert token vault ColdContext::Token -> ColdContext::Account. + /// Vaults are decompressed as PDAs, not as token accounts. + fn convert_vault_interface( account: &AccountInterface, - is_vault_a: bool, - ) -> Result<(), SwapSdkError> { - let pool_state = self - .pool_state_pubkey - .ok_or(SwapSdkError::PoolStateNotParsed)?; - - let mint = if is_vault_a { - self.token_a_mint - .ok_or(SwapSdkError::MissingField("token_a_mint"))? - } else { - self.token_b_mint - .ok_or(SwapSdkError::MissingField("token_b_mint"))? - }; - - let seeds = VaultSeeds { - pool: pool_state.to_bytes(), - mint: mint.to_bytes(), - }; - - // Parse token data from account - let token_data = Token::deserialize(&mut account.data()) - .map_err(|e: std::io::Error| SwapSdkError::ParseError(e.to_string()))?; - - let variant = LightAccountVariant::Vault(light_account::token::TokenDataWithSeeds { - seeds, - token_data, - }); - - // For token vaults, convert ColdContext::Token to ColdContext::Account - // because they're decompressed as PDAs, not as token accounts - // (matches cp-swap pattern) - let interface = if account.is_cold() { + ) -> Result { + if account.is_cold() { let compressed_account = match &account.cold { Some(ColdContext::Token(ct)) => ct.account.clone(), Some(ColdContext::Account(ca)) => ca.clone(), - None => return Err(SwapSdkError::MissingField("cold_context")), + Some(ColdContext::Mint(_)) => { + return Err(SwapSdkError::ParseError( + "unexpected Mint cold context for vault".to_string(), + )) + } + None => { + return Err(SwapSdkError::ParseError( + "missing cold context for vault".to_string(), + )) + } }; - AccountInterface { + Ok(AccountInterface { key: account.key, account: account.account.clone(), cold: Some(ColdContext::Account(compressed_account)), - } + }) } else { - account.clone() - }; - - let spec = PdaSpec::new(interface, variant, PROGRAM_ID); - self.pda_specs.insert(account.key, spec); - - Ok(()) - } - - /// Parse mint from AccountInterface. - fn parse_mint(&mut self, account: &AccountInterface) -> Result<(), SwapSdkError> { - self.mint_specs.insert(account.key, account.clone()); - Ok(()) - } - - /// Parse any account and route to appropriate parser. - fn parse_account(&mut self, account: &AccountInterface) -> Result<(), SwapSdkError> { - // Check if this is a known vault by pubkey - if Some(account.key) == self.token_a_vault { - return self.parse_token_vault(account, true); - } - if Some(account.key) == self.token_b_vault { - return self.parse_token_vault(account, false); + Ok(account.clone()) } - - // Check discriminator for pool state - let data = account.data(); - if data.len() >= 8 { - let discriminator: [u8; 8] = data[..8].try_into().unwrap_or_default(); - - if discriminator == PoolState::LIGHT_DISCRIMINATOR { - return self.parse_pool_state(account.clone()); - } - } - - // Check if this is a mint (token_a_mint or token_b_mint) - if Some(account.key) == self.token_a_mint || Some(account.key) == self.token_b_mint { - return self.parse_mint(account); - } - - Ok(()) - } - - /// Check if pool state is cold. - pub fn is_pool_state_cold(&self) -> bool { - self.pool_state_pubkey - .and_then(|k| self.pda_specs.get(&k)) - .is_some_and(|s| s.is_cold()) - } - - /// Check if token A vault is cold. - pub fn is_vault_a_cold(&self) -> bool { - self.token_a_vault - .and_then(|k| self.pda_specs.get(&k)) - .is_some_and(|s| s.is_cold()) - } - - /// Check if token B vault is cold. - pub fn is_vault_b_cold(&self) -> bool { - self.token_b_vault - .and_then(|k| self.pda_specs.get(&k)) - .is_some_and(|s| s.is_cold()) - } - - /// Get pool state pubkey. - pub fn pool_state(&self) -> Option { - self.pool_state_pubkey } } impl LightProgramInterface for SwapSdk { type Variant = LightAccountVariant; type Instruction = SwapInstruction; - type Error = SwapSdkError; - fn program_id(&self) -> Pubkey { + fn program_id() -> Pubkey { PROGRAM_ID } - fn from_keyed_accounts(accounts: &[AccountInterface]) -> Result { - let mut sdk = Self::new(); - - // First pass: find and parse pool state - for account in accounts { - let data = account.data(); - if data.len() >= 8 { - let discriminator: [u8; 8] = data[..8].try_into().unwrap_or_default(); - if discriminator == PoolState::LIGHT_DISCRIMINATOR { - sdk.parse_pool_state(account.clone())?; - break; - } - } - } - - if sdk.pool_state_pubkey.is_none() { - return Err(SwapSdkError::MissingField("pool_state")); - } - - Ok(sdk) - } - - fn get_accounts_to_update(&self, _ix: &Self::Instruction) -> Vec { - let mut accounts = Vec::new(); - - // All instructions need pool_state - if let Some(pubkey) = self.pool_state_pubkey { - accounts.push(AccountToFetch::pda(pubkey, PROGRAM_ID)); - } - - // All instructions need token vaults - if let Some(pubkey) = self.token_a_vault { - accounts.push(AccountToFetch::token(pubkey)); - } - if let Some(pubkey) = self.token_b_vault { - accounts.push(AccountToFetch::token(pubkey)); - } - - // All instructions need mints - if let Some(pubkey) = self.token_a_mint { - accounts.push(AccountToFetch::mint(pubkey)); - } - if let Some(pubkey) = self.token_b_mint { - accounts.push(AccountToFetch::mint(pubkey)); - } - - accounts - } - - fn update(&mut self, accounts: &[AccountInterface]) -> Result<(), Self::Error> { - for account in accounts { - self.parse_account(account)?; + fn instruction_accounts(&self, ix: &Self::Instruction) -> Vec { + match ix { + SwapInstruction::Swap => vec![ + self.pool_state_pubkey, + self.token_a_vault, + self.token_b_vault, + self.token_a_mint, + self.token_b_mint, + ], + SwapInstruction::Initialize => vec![ + self.pool_state_pubkey, + self.token_a_vault, + self.token_b_vault, + self.token_a_mint, + self.token_b_mint, + ], } - Ok(()) } - fn get_all_specs(&self) -> Vec> { - let mut specs = Vec::new(); - - // Add PDA specs (includes pool_state and vaults) - for spec in self.pda_specs.values() { - specs.push(AccountSpec::Pda(spec.clone())); - } - - // Add mint specs - for spec in self.mint_specs.values() { - specs.push(AccountSpec::Mint(spec.clone())); - } - - specs - } - - fn get_specs_for_instruction( + fn load_specs( &self, - _ix: &Self::Instruction, - ) -> Vec> { + cold_accounts: &[AccountInterface], + ) -> Result>, Box> { let mut specs = Vec::new(); - - // Pool state needed for all instructions - if let Some(pubkey) = self.pool_state_pubkey { - if let Some(spec) = self.pda_specs.get(&pubkey) { - specs.push(AccountSpec::Pda(spec.clone())); + for account in cold_accounts { + if account.key == self.pool_state_pubkey { + let pool = PoolState::deserialize(&mut &account.data()[8..]) + .map_err(|e| SwapSdkError::ParseError(e.to_string()))?; + let variant = LightAccountVariant::PoolState { + seeds: PoolStateSeeds { + mint_a: pool.token_a_mint, + mint_b: pool.token_b_mint, + }, + data: pool, + }; + specs.push(AccountSpec::Pda(PdaSpec::new( + account.clone(), + variant, + PROGRAM_ID, + ))); + } else if account.key == self.token_a_vault { + let token: Token = Token::deserialize(&mut &account.data()[..]) + .map_err(|e| SwapSdkError::ParseError(e.to_string()))?; + let variant = + LightAccountVariant::Vault(light_account::token::TokenDataWithSeeds { + seeds: VaultSeeds { + pool: self.pool_state_pubkey.to_bytes(), + mint: self.token_a_mint.to_bytes(), + }, + token_data: token, + }); + let interface = Self::convert_vault_interface(account)?; + specs.push(AccountSpec::Pda(PdaSpec::new( + interface, variant, PROGRAM_ID, + ))); + } else if account.key == self.token_b_vault { + let token: Token = Token::deserialize(&mut &account.data()[..]) + .map_err(|e| SwapSdkError::ParseError(e.to_string()))?; + let variant = + LightAccountVariant::Vault(light_account::token::TokenDataWithSeeds { + seeds: VaultSeeds { + pool: self.pool_state_pubkey.to_bytes(), + mint: self.token_b_mint.to_bytes(), + }, + token_data: token, + }); + let interface = Self::convert_vault_interface(account)?; + specs.push(AccountSpec::Pda(PdaSpec::new( + interface, variant, PROGRAM_ID, + ))); + } else if account.key == self.token_a_mint || account.key == self.token_b_mint { + specs.push(AccountSpec::Mint(account.clone())); } } - - // Token vaults needed for all instructions - if let Some(pubkey) = self.token_a_vault { - if let Some(spec) = self.pda_specs.get(&pubkey) { - specs.push(AccountSpec::Pda(spec.clone())); - } - } - if let Some(pubkey) = self.token_b_vault { - if let Some(spec) = self.pda_specs.get(&pubkey) { - specs.push(AccountSpec::Pda(spec.clone())); - } - } - - // Mints needed for all instructions - if let Some(pubkey) = self.token_a_mint { - if let Some(spec) = self.mint_specs.get(&pubkey) { - specs.push(AccountSpec::Mint(spec.clone())); - } - } - if let Some(pubkey) = self.token_b_mint { - if let Some(spec) = self.mint_specs.get(&pubkey) { - specs.push(AccountSpec::Mint(spec.clone())); - } - } - - specs + Ok(specs) } } diff --git a/pinocchio/swap/tests/test_lifecycle.rs b/pinocchio/swap/tests/test_lifecycle.rs index fffa7fa..fdb2ee4 100644 --- a/pinocchio/swap/tests/test_lifecycle.rs +++ b/pinocchio/swap/tests/test_lifecycle.rs @@ -14,10 +14,9 @@ mod sdk; mod shared; use light_client::interface::{ - create_load_instructions, get_create_accounts_proof, AccountInterfaceExt, + create_load_instructions, get_create_accounts_proof, AccountSpec, CreateAccountsProofInput, LightProgramInterface, }; -use light_program_test::program_test::LightProgramTest; use light_program_test::{program_test::TestRpc, Rpc}; use light_token::LIGHT_TOKEN_PROGRAM_ID; @@ -28,10 +27,9 @@ use light_token::instruction::{ LIGHT_TOKEN_CONFIG, LIGHT_TOKEN_RENT_SPONSOR, }; use pinocchio_swap::{ - constants::*, discriminators, init::InitializeParams, swap::SwapParams, LightAccountVariant, - PoolState, + constants::*, discriminators, init::InitializeParams, swap::SwapParams, PoolState, }; -use sdk::{SwapInstruction, SwapSdk}; +use sdk::SwapSdk; use solana_instruction::{AccountMeta, Instruction}; use solana_keypair::Keypair; use solana_pubkey::Pubkey; @@ -372,52 +370,52 @@ async fn test_full_lifecycle() { // ==================== PHASE 9: Create SDK from Compressed State ==================== let pool_interface = rpc - .get_account_interface(&pool_state, &program_id) + .get_account_interface(&pool_state, None) .await - .expect("pool should be compressed"); + .expect("pool should be compressed") + .value + .expect("pool interface should exist"); assert!( pool_interface.is_cold(), "pool_state should be cold after warp" ); - let mut swap_sdk = SwapSdk::from_keyed_accounts(&[pool_interface]) - .expect("from_keyed_accounts should succeed"); + let swap_sdk = SwapSdk::new(pool_state, pool_interface.data()) + .expect("SwapSdk::new should succeed"); - // ==================== PHASE 10: Fetch and Update SDK ==================== - let accounts_to_fetch = swap_sdk.get_accounts_to_update(&SwapInstruction::Swap); - let keyed_accounts = rpc - .get_multiple_account_interfaces(&accounts_to_fetch) + // ==================== PHASE 10: Fetch Cold Accounts ==================== + let pubkeys = swap_sdk.instruction_accounts(&sdk::SwapInstruction::Swap); + let cold_accounts = rpc + .get_multiple_account_interfaces(pubkeys.iter().collect(), None) .await - .expect("get_multiple_account_interfaces should succeed"); - - swap_sdk - .update(&keyed_accounts) - .expect("sdk.update should succeed"); + .expect("get_multiple_account_interfaces should succeed") + .value; + let cold: Vec<_> = cold_accounts.into_iter().flatten().filter(|a| a.is_cold()).collect(); // ==================== PHASE 11: Build Load Instructions ==================== - let all_specs = swap_sdk.get_specs_for_instruction(&SwapInstruction::Swap); + let mut all_specs = swap_sdk.load_specs(&cold) + .expect("load_specs should succeed"); // Also need to decompress user ATAs let user_ata_a_interface = rpc - .get_ata_interface(&user.pubkey(), &mint_a) + .get_associated_token_account_interface(&user.pubkey(), &mint_a, None) .await - .expect("get_ata_interface for user_token_a should succeed"); + .expect("get_associated_token_account_interface for user_token_a should succeed") + .value + .expect("user_token_a interface should exist"); let user_ata_b_interface = rpc - .get_ata_interface(&user.pubkey(), &mint_b) + .get_associated_token_account_interface(&user.pubkey(), &mint_b, None) .await - .expect("get_ata_interface for user_token_b should succeed"); - - let mut all_specs_with_atas = all_specs; - all_specs_with_atas.push(light_client::interface::AccountSpec::Ata( - user_ata_a_interface, - )); - all_specs_with_atas.push(light_client::interface::AccountSpec::Ata( - user_ata_b_interface, - )); - - let load_ixs = create_load_instructions::( - &all_specs_with_atas, + .expect("get_associated_token_account_interface for user_token_b should succeed") + .value + .expect("user_token_b interface should exist"); + + all_specs.push(AccountSpec::Ata(user_ata_a_interface)); + all_specs.push(AccountSpec::Ata(user_ata_b_interface)); + + let load_ixs = create_load_instructions( + &all_specs, payer.pubkey(), env.config_pda, &rpc,