diff --git a/solana/anchor-bridge/Cargo.lock b/solana/anchor-bridge/Cargo.lock index 0c6c7e88..257d9ead 100644 --- a/solana/anchor-bridge/Cargo.lock +++ b/solana/anchor-bridge/Cargo.lock @@ -35,9 +35,9 @@ checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e" [[package]] name = "aho-corasick" -version = "0.7.18" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" dependencies = [ "memchr", ] @@ -47,6 +47,7 @@ name = "anchor-bridge-client" version = "0.1.0" dependencies = [ "anyhow", + "borsh", "bridge", "clap 3.0.0-beta.2", "rand 0.7.3", @@ -55,6 +56,7 @@ dependencies = [ "solana-program", "solana-sdk", "solitaire", + "solitaire-client", ] [[package]] @@ -109,9 +111,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "backtrace" -version = "0.3.60" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7815ea54e4d821e791162e078acbebfd6d8c8939cd559c9335dceb1c8ca7282" +checksum = "4717cfcbfaa661a0fd48f8453951837ae7e8f81e481fbb136e3202d72805a744" dependencies = [ "addr2line", "cc", @@ -164,9 +166,9 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "blake3" -version = "0.3.8" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3" +checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f" dependencies = [ "arrayref", "arrayvec", @@ -233,8 +235,8 @@ dependencies = [ "borsh-derive-internal", "borsh-schema-derive-internal", "proc-macro-crate", - "proc-macro2 1.0.27", - "syn 1.0.72", + "proc-macro2 1.0.26", + "syn 1.0.71", ] [[package]] @@ -243,9 +245,9 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2104c73179359431cc98e016998f2f23bc7a05bc53e79741bcba705f30047bc" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] @@ -254,21 +256,9 @@ version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae29eb8418fcd46f723f8691a2ac06857d31179d33d2f2d91eb13967de97c728" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", -] - -[[package]] -name = "bridge" -version = "0.1.0" -dependencies = [ - "borsh", - "byteorder", - "sha3", - "solana-program", - "solana-sdk", - "solitaire", + "syn 1.0.71", ] [[package]] @@ -281,6 +271,7 @@ dependencies = [ "sha3", "solana-program", "solitaire", + "solitaire-client", ] [[package]] @@ -352,9 +343,9 @@ dependencies = [ [[package]] name = "bzip2-sys" -version = "0.1.10+1.0.8" +version = "0.1.11+1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17fa3d1ac1ca21c5c4e36a97f3c3eb25084576f6fc47bf0139c1123434216c6c" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" dependencies = [ "cc", "libc", @@ -431,14 +422,21 @@ dependencies = [ ] [[package]] -name = "feature-probe" -version = "0.1.1" +name = "clap_derive" +version = "3.0.0-beta.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" +checksum = "370f715b81112975b1b69db93e0b56ea4cd4e5002ac43b2da8474106a54096a1" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2 1.0.26", + "quote 1.0.9", + "syn 1.0.71", +] [[package]] -name = "generic-array" -version = "0.12.4" +name = "cloudabi" +version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ @@ -500,13 +498,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" [[package]] -name = "cpufeatures" -version = "0.1.4" +name = "cpuid-bool" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed00c67cb5d0a7d64a44f6ad2668db7e7530311dd53ea79bcd4fb022c64911c8" -dependencies = [ - "libc", -] +checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" [[package]] name = "crc32fast" @@ -717,9 +712,9 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] @@ -808,7 +803,7 @@ dependencies = [ "rand 0.7.3", "serde", "serde_bytes", - "sha2 0.9.5", + "sha2 0.9.3", "zeroize", ] @@ -822,7 +817,7 @@ dependencies = [ "ed25519-dalek", "failure", "hmac 0.9.0", - "sha2 0.9.5", + "sha2 0.9.3", ] [[package]] @@ -875,9 +870,9 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", "synstructure", ] @@ -905,6 +900,15 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "fixed-hash" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" +dependencies = [ + "static_assertions", +] + [[package]] name = "flate2" version = "1.0.20" @@ -1026,9 +1030,9 @@ checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121" dependencies = [ "autocfg", "proc-macro-hack", - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] @@ -1462,9 +1466,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.95" +version = "0.2.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36" +checksum = "5600b4e6efc5421841a2138a6b082e07fe12f9aaa12783d50e5d13325b26b4fc" [[package]] name = "libloading" @@ -1539,9 +1543,9 @@ checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" [[package]] name = "memchr" -version = "2.4.0" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "memmap2" @@ -1706,9 +1710,9 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] @@ -1757,9 +1761,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c0fd9eba1d5db0994a239e09c1be402d35622277e35468ba891aa5e3188ce7e" dependencies = [ "proc-macro-crate", - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] @@ -1770,12 +1774,9 @@ checksum = "17b02fc0ff9a9e4b35b3342880f48e896ebf69f2967921fe8646bf5b7125956a" [[package]] name = "object" -version = "0.25.2" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8bc1d42047cf336f0f939c99e97183cf31551bf0f2865a2ec9c8d91fd4ffb5e" -dependencies = [ - "memchr", -] +checksum = "1a5b3dd1c072ee7963717671d1ca129f1048fda25edea6b752bfc71ac8854170" [[package]] name = "once_cell" @@ -1854,9 +1855,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cec33dfceabec83cd0e95a5ce9d20e76ab3a5cbfef59659b8c927f69b93ed8ae" dependencies = [ "Inflector", - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] @@ -1991,6 +1992,16 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "primitive-types" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2415937401cb030a2a0a4d922483f945fa068f52a7dbb22ce0fe5f2b6f6adace" +dependencies = [ + "fixed-hash", + "uint", +] + [[package]] name = "proc-macro-crate" version = "0.1.5" @@ -2007,9 +2018,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", "version_check", ] @@ -2019,7 +2030,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", "version_check", ] @@ -2047,9 +2058,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.27" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0d8caf72986c1a598726adc988bb5984792ef84f5ee5aa50209145ee8077038" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid 0.2.2", ] @@ -2078,7 +2089,7 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", ] [[package]] @@ -2101,7 +2112,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e" dependencies = [ "libc", - "rand_chacha 0.3.0", + "rand_chacha 0.3.1", "rand_core 0.6.2", "rand_hc 0.3.0", ] @@ -2118,9 +2129,9 @@ dependencies = [ [[package]] name = "rand_chacha" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core 0.6.2", @@ -2214,9 +2225,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.4" +version = "1.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759" dependencies = [ "aho-corasick", "memchr", @@ -2225,9 +2236,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "remove_dir_all" @@ -2294,11 +2305,11 @@ name = "rocksalt" version = "0.1.0" dependencies = [ "byteorder", - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", "sha3", "solana-program", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] @@ -2347,9 +2358,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.5" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" +checksum = "cb5d2a036dc6d2d8fd16fde3498b04306e29bd193bf306a57427019b823d5acd" [[package]] name = "ryu" @@ -2450,9 +2461,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.126" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" dependencies = [ "serde_derive", ] @@ -2468,13 +2479,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.126" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] @@ -2538,13 +2549,13 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.5" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" +checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpufeatures", + "cpuid-bool", "digest 0.9.0", "opaque-debug 0.3.0", ] @@ -2629,9 +2640,9 @@ dependencies = [ [[package]] name = "solana-account-decoder" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ca2ebdb1e7f983da67240e83ed907f022ea5180aedfa4ccdb4c30b97fbcd40" +checksum = "8a72a059536988504c15627626f78a24e9cab1468978d3bddd7f9652f6b87a2f" dependencies = [ "Inflector", "base64 0.12.3", @@ -2653,9 +2664,9 @@ dependencies = [ [[package]] name = "solana-clap-utils" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ebff534a91278691011b96558bd60d95528c1e56b7f1190ee6d798176f06e89" +checksum = "484288242b2b175bf2b7554497318e39b23ee921989f976387dbe48e60b2f256" dependencies = [ "chrono", "clap 2.33.3", @@ -2670,9 +2681,9 @@ dependencies = [ [[package]] name = "solana-cli-config" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fc060ba727a5f81df3ac0d5fcc92f7796448d38b492f1989ce365da7ca920e" +checksum = "f23b9dc8f85fa5277c50dd00a81ee9844ecd9661ec9e66523207a477b5e755a4" dependencies = [ "dirs-next", "lazy_static", @@ -2684,9 +2695,9 @@ dependencies = [ [[package]] name = "solana-client" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abab0da9b2d6e30516a53e7653e95bf8b04e929bf1e99965f836d6c0931404e5" +checksum = "774623776704dd9a58061eb99977b2e9552e8d6de3a92b344d1226104a888b83" dependencies = [ "base64 0.13.0", "bincode", @@ -2718,9 +2729,9 @@ dependencies = [ [[package]] name = "solana-config-program" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8c1a9e79f557587096010eb96ec099605abd364c723bbb721783bbcec60f42" +checksum = "78cac22db3f711eae4b1c3259af5163370f776cd7670f3736a6c13ef558245fc" dependencies = [ "bincode", "chrono", @@ -2733,9 +2744,9 @@ dependencies = [ [[package]] name = "solana-crate-features" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48b4d7b50a436a4d7df7be70beb436b918a188105f63b5798a4457c3cb657c87" +checksum = "61a634335bdea4898e20db749753dd4537eb343996cf1c7a132e331d84c5590d" dependencies = [ "backtrace", "bytes 0.4.12", @@ -2751,16 +2762,16 @@ dependencies = [ "ring", "serde", "syn 0.15.44", - "syn 1.0.72", + "syn 1.0.71", "tokio 0.1.22", "winapi 0.3.9", ] [[package]] name = "solana-faucet" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b58e17a6c1bf7ae4e9c2270e34f8d0fa9f9d9748f1f61cca7e65288684b1e50" +checksum = "ed5e6adf551ca4e761c3395bb684ba5d907a051007a6dbf2d57cb99d2691e031" dependencies = [ "bincode", "byteorder", @@ -2781,9 +2792,9 @@ dependencies = [ [[package]] name = "solana-frozen-abi" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95c481f0f29753f5b2d382628abae98a1dd87b572ddc7cbe5fe55ca62b6f7f07" +checksum = "6b81e60d88b1fe0322bba6f3fe6b0d7299df2f2ededa8d95ec77b934fabb967b" dependencies = [ "bs58", "bv", @@ -2793,7 +2804,7 @@ dependencies = [ "rustc_version", "serde", "serde_derive", - "sha2 0.9.5", + "sha2 0.9.3", "solana-frozen-abi-macro", "solana-logger", "thiserror", @@ -2801,21 +2812,21 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2068bcc47160ac9081893439b10a05e4bbe85cc0f6bccb6f1b0815423fbdd0c" +checksum = "f617daa0187bcc4665d63fcf9454c998e9cdad6a33181f6214558d738230bfe2" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", "rustc_version", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] name = "solana-logger" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea5932e186629f47859924b3773cfd8bcb4b8796898ac85c1fa0a6a2024e5c6" +checksum = "8b3e2b14bdcbb7b41de9ef5a541ac501ba3fbd07999cbcf7ea9006b3ae28b67b" dependencies = [ "env_logger", "lazy_static", @@ -2824,9 +2835,9 @@ dependencies = [ [[package]] name = "solana-measure" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02245c245ae1376845a3d62d7f9d64181c521166da019dfd18924a6ac3e1dc67" +checksum = "d5ad0bf2fb48761c23cb80089aba5676deaafb4a4ff0a3e2996ab39cbcbf96b4" dependencies = [ "log", "solana-metrics", @@ -2835,9 +2846,9 @@ dependencies = [ [[package]] name = "solana-metrics" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "156a031ebbdb2a1751d443289218c6946806852468deded96548406808f9365a" +checksum = "6880a7b453b1f6a1042fda9316ef1bca723002ab37f48a506f6f1b0448d462e8" dependencies = [ "env_logger", "gethostname", @@ -2849,9 +2860,9 @@ dependencies = [ [[package]] name = "solana-net-utils" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49b7930c8a2aa8ab3ee158d360cb18ae551ead7fd6c339455ee9693417f82e2" +checksum = "fa68e25fb6452b85733cf5c301988b56fd2d5d5a8e93c75cf38cbec06efc2eae" dependencies = [ "bincode", "clap 2.33.3", @@ -2870,9 +2881,9 @@ dependencies = [ [[package]] name = "solana-program" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a2df39c63e21c5b58e2012e7675bed5e8dd5100470ffddedcafb78f5a7e3abe" +checksum = "9c5d59f9d358c09db6461fae1fde6075a456685d856c004ef21af092a830e4e7" dependencies = [ "bincode", "blake3", @@ -2893,7 +2904,7 @@ dependencies = [ "serde", "serde_bytes", "serde_derive", - "sha2 0.9.5", + "sha2 0.9.3", "sha3", "solana-frozen-abi", "solana-frozen-abi-macro", @@ -2904,9 +2915,9 @@ dependencies = [ [[package]] name = "solana-rayon-threadlimit" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a99177e163c4da6f94320e105132def2a08368d6a6ff897195223ab9d6758c63" +checksum = "7447a0206282910fc21864bcb58b80aedbf1e7c712c4eab875c5458d3bf6faf1" dependencies = [ "lazy_static", "num_cpus", @@ -2914,9 +2925,9 @@ dependencies = [ [[package]] name = "solana-remote-wallet" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a591490d0cd13ebcea6f717592f5ad1bce5c1268573e708079665a5a6a0eaa1" +checksum = "e4d1346f89c41dc1cb9037ad427422cf3ab0b7f41915c7426f3a737094e9b2ec" dependencies = [ "base32", "console 0.14.1", @@ -2935,9 +2946,9 @@ dependencies = [ [[package]] name = "solana-runtime" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c968934633ed389bb492a7f080deffd4082c3897b9486ca57ecd90afaa2f2c09" +checksum = "d917b1b3849e01a41ea65af89ccbd58827c8f551219769c28011a2cfd4cdd01c" dependencies = [ "arrayref", "bincode", @@ -2986,9 +2997,9 @@ dependencies = [ [[package]] name = "solana-sdk" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fac80d6452327448116f1a50f2e616ce51c1db6c74f1db30aa7d801bab4e410c" +checksum = "4223659889495ec33debeb486f424f5543b87b8f6b5548edc3b6147b4c3b9312" dependencies = [ "assert_matches", "bincode", @@ -3021,7 +3032,7 @@ dependencies = [ "serde_bytes", "serde_derive", "serde_json", - "sha2 0.9.5", + "sha2 0.9.3", "sha3", "solana-crate-features", "solana-frozen-abi", @@ -3035,22 +3046,22 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6473d8fa445520564c84e8803320721404d160ffd876a125326a726541f11534" +checksum = "d27426b2a09676929c5e49df96967bbcffff003183c11a3c3ef11d78bac4aaaa" dependencies = [ "bs58", - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", "rustversion", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] name = "solana-secp256k1-program" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "239da198d43584bf0929ce175c93448f239b5fe4b8f542fd752a4624a93bf10f" +checksum = "5a22f308716c2860e126bac5370f9580c4252c3cc91a58f461400267171471ea" dependencies = [ "bincode", "digest 0.9.0", @@ -3063,9 +3074,9 @@ dependencies = [ [[package]] name = "solana-stake-program" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d11ad775a21e4ecbdaf7d576501cf577a7582154fef3c49cfe6bd131c76955de" +checksum = "152fdc283d9410175a0b8eff9f17c5627e9c913fd88e183e1a1c1b1c0e190681" dependencies = [ "bincode", "log", @@ -3085,9 +3096,9 @@ dependencies = [ [[package]] name = "solana-transaction-status" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cec0a504cc01260b3b9b38318fe4055a0362b912d82189c8d881802c577d725a" +checksum = "7dba81cb7f40b2ebf330591fab6756fa73b180729f3ef332c70f0809f70d34b3" dependencies = [ "Inflector", "base64 0.12.3", @@ -3110,9 +3121,9 @@ dependencies = [ [[package]] name = "solana-version" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "236bab3619ee2050ab6211187ea7506c9df1e4b86fcb2aaf59319ca9522a6681" +checksum = "df56fd1b1d2d13b387fec43c3f9e76b2c07d983535e732d5770002fdb5ee3c1f" dependencies = [ "log", "rustc_version", @@ -3126,9 +3137,9 @@ dependencies = [ [[package]] name = "solana-vote-program" -version = "1.7.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7a8b6534569e68f249130dfda9b2653017d626dedb6e2cb5508fb7963b32708" +checksum = "f0d38c4ac44f51db1fa751cb9ff077f474157eb6137b10355d1090c2bb0072bf" dependencies = [ "bincode", "log", @@ -3154,7 +3165,16 @@ dependencies = [ "rocksalt", "sha3", "solana-program", +] + +[[package]] +name = "solitaire-client" +version = "0.1.0" +dependencies = [ + "borsh", + "solana-program", "solana-sdk", + "solitaire", ] [[package]] @@ -3202,6 +3222,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + [[package]] name = "strsim" version = "0.8.0" @@ -3245,11 +3271,11 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.72" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82" +checksum = "ad184cc9470f9117b2ac6817bfe297307418819ba40552f9b3846f05c33d5373" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", "unicode-xid 0.2.2", ] @@ -3260,9 +3286,9 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", "unicode-xid 0.2.2", ] @@ -3339,22 +3365,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.25" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa6f76457f59514c7eeb4e59d891395fab0b2fd1d40723ae737d64153392e9c6" +checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.25" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a36768c0fbf1bb15eca10defa29526bda730a2376c2ab4393ccfa16fb1a318d" +checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] @@ -3379,7 +3405,7 @@ dependencies = [ "pbkdf2 0.4.0", "rand 0.7.3", "rustc-hash", - "sha2 0.9.5", + "sha2 0.9.3", "thiserror", "unicode-normalization", "zeroize", @@ -3503,9 +3529,9 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c49e3df43841dafb86046472506755d8501c5615673955f6aa17181125d13c37" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", ] [[package]] @@ -3711,6 +3737,18 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" +[[package]] +name = "uint" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e11fe9a9348741cf134085ad57c249508345fe16411b3d7fb4ff2da2f1d6382e" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + [[package]] name = "unicode-bidi" version = "0.3.5" @@ -3859,9 +3897,9 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", "wasm-bindgen-shared", ] @@ -3893,9 +3931,9 @@ version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4030,9 +4068,9 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2c1e130bebaeab2f23886bf9acbaca14b092408c452543c857f66399cd6dab1" dependencies = [ - "proc-macro2 1.0.27", + "proc-macro2 1.0.26", "quote 1.0.9", - "syn 1.0.72", + "syn 1.0.71", "synstructure", ] diff --git a/solana/anchor-bridge/Cargo.toml b/solana/anchor-bridge/Cargo.toml index b46db847..88f0ff12 100644 --- a/solana/anchor-bridge/Cargo.toml +++ b/solana/anchor-bridge/Cargo.toml @@ -2,4 +2,5 @@ members = [ "programs/*", "client/", + "solitaire-client", ] diff --git a/solana/anchor-bridge/client/Cargo.toml b/solana/anchor-bridge/client/Cargo.toml index ebede47a..0ad49c8e 100644 --- a/solana/anchor-bridge/client/Cargo.toml +++ b/solana/anchor-bridge/client/Cargo.toml @@ -6,11 +6,13 @@ edition = "2018" [dependencies] anyhow = "1.0.40" +borsh = "0.8.1" bridge = {path = "../programs/bridge", features = ["no-idl", "no-entrypoint"]} clap = "3.0.0-beta.2" rand = "0.7.3" shellexpand = "2.1.0" -solana-client = "1.7.0" -solana-program = "*" -solana-sdk = "1.7.0" +solana-client = "=1.7.0" +solana-program = "=1.7.0" +solana-sdk = "=1.7.0" solitaire = { path = "../programs/solitaire" } +solitaire-client = {path = "../solitaire-client"} diff --git a/solana/anchor-bridge/client/src/main.rs b/solana/anchor-bridge/client/src/main.rs index 517d9ba9..3596b8cb 100644 --- a/solana/anchor-bridge/client/src/main.rs +++ b/solana/anchor-bridge/client/src/main.rs @@ -1,7 +1,9 @@ +use borsh::BorshSerialize; use bridge::{ api, client, instruction, + types, }; use clap::Clap; use solana_client::{ @@ -22,7 +24,7 @@ use solana_sdk::{ }, transaction::Transaction, }; -use solitaire::{ +use solitaire_client::{ AccEntry, Signer, ToInstruction, @@ -41,6 +43,9 @@ pub struct Opts { pub type ErrBox = Box; +pub const DEFAULT_MESSAGE_FEE: u64 = 42; +pub const DEFAULT_GUARDIAN_SET_EXPIRATION_TIME: u32 = 42; + fn main() -> Result<(), ErrBox> { let opts = Opts::parse(); @@ -63,20 +68,32 @@ fn main() -> Result<(), ErrBox> { payer: Signer(payer), }; - let ix_data = vec![]; + let init_args = types::BridgeConfig { + guardian_set_expiration_time: DEFAULT_GUARDIAN_SET_EXPIRATION_TIME, + fee: DEFAULT_MESSAGE_FEE, + }; + + let ix_data = init_args.try_to_vec()?; let (ix, signers) = init.to_ix(program_id, ix_data.as_slice())?; let (recent_blockhash, _) = client.get_recent_blockhash()?; + println!("Instruction ready."); + println!( + "Signing for {} signer(s): {:?}", + signers.len(), + signers.iter().map(|s| s.pubkey()).collect::>() + ); let mut tx = Transaction::new_with_payer(&[ix], Some(&payer_for_tx.pubkey())); - tx.sign(&signers.iter().collect::>(), recent_blockhash); + tx.try_sign(&signers.iter().collect::>(), recent_blockhash)?; + println!("Transaction signed."); let signature = client.send_and_confirm_transaction_with_spinner_and_config( &tx, CommitmentConfig::processed(), RpcSendTransactionConfig { - skip_preflight: false, + skip_preflight: true, preflight_commitment: None, encoding: None, }, @@ -85,49 +102,3 @@ fn main() -> Result<(), ErrBox> { Ok(()) } - -// fn initialize_bridge(client: &Client, bridge_address: Pubkey) -> Result<()> { -// let program = client.program(bridge_address); - -// let guardian_set_key = Keypair::generate(&mut OsRng); -// let state_key = Keypair::generate(&mut OsRng); - -// program -// .state_request() -// .instruction(system_instruction::create_account( -// &program.payer(), -// &guardian_set_key.pubkey(), -// program.rpc().get_minimum_balance_for_rent_exemption(500)?, -// 500, -// &program.id(), -// )) -// .instruction(system_instruction::create_account( -// &program.payer(), -// &state_key.pubkey(), -// program.rpc().get_minimum_balance_for_rent_exemption(500)?, -// 500, -// &program.id(), -// )) -// .signer(&guardian_set_key) -// // .signer(&state_key) -// .accounts(Initialize { -// payer: program.payer(), -// guardian_set: guardian_set_key.pubkey(), -// state: state_key.pubkey(), -// system_program: system_program::id(), -// clock: sysvar::clock::id(), -// rent: sysvar::rent::id(), -// }) -// .new(New { -// data: InitializeData { -// len_guardians: 0, -// initial_guardian_keys: [[0u8; 20]; MAX_LEN_GUARDIAN_KEYS], -// config: BridgeConfig { -// guardian_set_expiration_time: 0u32, -// }, -// }, -// }) -// .send()?; - -// Ok(()) -// } diff --git a/solana/anchor-bridge/programs/bridge/Cargo.toml b/solana/anchor-bridge/programs/bridge/Cargo.toml index 29f72a14..efa1e0e2 100644 --- a/solana/anchor-bridge/programs/bridge/Cargo.toml +++ b/solana/anchor-bridge/programs/bridge/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["cdylib", "lib"] name = "bridge" [features] -no-entrypoint = [] +no-entrypoint = ["solitaire/no-entrypoint", "solitaire-client"] no-idl = [] cpi = ["no-entrypoint"] default = [] @@ -17,8 +17,8 @@ default = [] [dependencies] borsh = "0.8.1" byteorder = "1.4.3" -solitaire = { path = "../solitaire" } +solitaire = { path = "../solitaire"} +solitaire-client = { path = "../../solitaire-client", optional = true} sha3 = "0.9.1" -solana-program = "*" primitive-types = { version = "0.9.0", default-features = false } -solana-sdk = "1.7.0" +solana-program = "=1.7.0" diff --git a/solana/anchor-bridge/programs/solitaire/Cargo.toml b/solana/anchor-bridge/programs/solitaire/Cargo.toml index e2a345a7..ba0544fc 100644 --- a/solana/anchor-bridge/programs/solitaire/Cargo.toml +++ b/solana/anchor-bridge/programs/solitaire/Cargo.toml @@ -19,5 +19,4 @@ borsh = "0.8.1" byteorder = "1.4.3" rocksalt = { path = "../../rocksalt" } sha3 = "0.9.1" -solana-program = "*" -solana-sdk = "1.7.0" +solana-program = "=1.7.0" diff --git a/solana/anchor-bridge/programs/solitaire/src/lib.rs b/solana/anchor-bridge/programs/solitaire/src/lib.rs index 7206dd19..f5c905a0 100644 --- a/solana/anchor-bridge/programs/solitaire/src/lib.rs +++ b/solana/anchor-bridge/programs/solitaire/src/lib.rs @@ -32,10 +32,6 @@ use solana_program::{ SysvarId, }, }; -use solana_sdk::signature::{ - Keypair, - Signer as SolSigner, -}; use std::{ io::{ @@ -64,7 +60,7 @@ pub mod types; // We can also re-export a set of types at module scope, this defines the intended API we expect // people to be able to use from top-level. -use crate::processors::seeded::Owned; +pub use crate::processors::seeded::Owned; pub use crate::{ error::{ ErrBox, @@ -81,8 +77,6 @@ pub use crate::{ types::*, }; -type StdResult = std::result::Result; - pub struct ExecutionContext<'a, 'b: 'a> { /// A reference to the program_id of the current program. pub program_id: &'a Pubkey, @@ -107,91 +101,6 @@ impl CreationLamports { } } -/// The sum type for clearly specifying the accounts required on client side. -pub enum AccEntry { - /// Least privileged account. - Unprivileged(Pubkey), - - /// Accounts that need to sign a Solana call - Signer(Keypair), - SignerRO(Keypair), - - /// Program addresses for privileged/unprivileged cross calls - CPIProgram(Pubkey), - CPIProgramSigner(Keypair), - - /// Key decided by Wrap implementation - Sysvar, - Derived(Pubkey), - DerivedRO(Pubkey), -} - -/// Types implementing Wrap are those that can be turned into a -/// partial account vector tha -/// payload. -pub trait Wrap { - fn wrap(_: &AccEntry) -> StdResult, ErrBox>; - - /// If the implementor wants to sign using other AccEntry - /// variants, they should override this. - fn keypair(a: AccEntry) -> Option { - use AccEntry::*; - match a { - Signer(pair) => Some(pair), - SignerRO(pair) => Some(pair), - _other => None, - } - } -} - -impl<'a, 'b: 'a, T> Wrap for Signer -where - T: Keyed<'a, 'b>, -{ - fn wrap(a: &AccEntry) -> StdResult, ErrBox> { - use AccEntry::*; - match a { - Signer(pair) => Ok(vec![AccountMeta::new(pair.pubkey(), true)]), - SignerRO(pair) => Ok(vec![AccountMeta::new_readonly(pair.pubkey(), true)]), - other => Err(format!( - "{} must be passed as Signer or SignerRO", - std::any::type_name::() - ) - .into()), - } - } -} - -impl<'a, 'b: 'a, T, const Seed: &'static str> Wrap for Derive { - fn wrap(a: &AccEntry) -> StdResult, ErrBox> { - match a { - AccEntry::Derived(program_id) => { - let (k, extra_seed) = Pubkey::find_program_address(&[Seed.as_bytes()], &program_id); - - Ok(vec![AccountMeta::new(k, false)]) - } - AccEntry::DerivedRO(program_id) => { - let (k, extra_seed) = Pubkey::find_program_address(&[Seed.as_bytes()], &program_id); - - Ok(vec![AccountMeta::new_readonly(k, false)]) - } - other => Err(format!( - "{} must be passed as Derived or DerivedRO", - std::any::type_name::() - ) - .into()), - } - } -} - -impl<'a, T: BorshSerialize + Owned + Default, const IsInitialized: AccountState> Wrap - for Data<'a, T, IsInitialized> -{ - fn wrap(a: &AccEntry) -> StdResult, ErrBox> { - todo!(); - } -} - pub trait InstructionContext<'a> { fn verify(&self, program_id: &Pubkey) -> Result<()> { Ok(()) @@ -202,11 +111,6 @@ pub trait InstructionContext<'a> { } } -/// Trait used on client side to easily validate a program accounts + ix_data for a bare Solana call -pub trait ToInstruction { - fn to_ix(self, program_id: Pubkey, ix_data: &[u8]) -> StdResult<(Instruction, Vec), ErrBox>; -} - /// Trait definition that describes types that can be constructed from a list of solana account /// references. A list of dependent accounts is produced as a side effect of the parsing stage. pub trait FromAccounts<'a, 'b: 'a, 'c> { diff --git a/solana/anchor-bridge/programs/solitaire/src/macros.rs b/solana/anchor-bridge/programs/solitaire/src/macros.rs index 7a92f1be..a8dc3cf1 100644 --- a/solana/anchor-bridge/programs/solitaire/src/macros.rs +++ b/solana/anchor-bridge/programs/solitaire/src/macros.rs @@ -19,6 +19,7 @@ macro_rules! solitaire { use solana_program::{ account_info::AccountInfo, entrypoint::ProgramResult, + program_error::ProgramError, pubkey::Pubkey, }; use solitaire::{FromAccounts, Persist, Result}; @@ -52,7 +53,11 @@ macro_rules! solitaire { } pub fn solitaire<'a, 'b: 'a>(p: &Pubkey, a: &'a [AccountInfo<'b>], d: &[u8]) -> ProgramResult { + solana_program::msg!(concat!(env!("CARGO_PKG_NAME"), " ", env!("CARGO_PKG_VERSION"))); if let Err(err) = dispatch(p, a, d) { + + solana_program::msg!("Error: {:?}", err); + return Err(err.into()); } Ok(()) } diff --git a/solana/anchor-bridge/rocksalt/Cargo.toml b/solana/anchor-bridge/rocksalt/Cargo.toml index 371c83db..d810b737 100644 --- a/solana/anchor-bridge/rocksalt/Cargo.toml +++ b/solana/anchor-bridge/rocksalt/Cargo.toml @@ -17,5 +17,5 @@ byteorder = "1.4.3" proc-macro2 = "1.0" quote = "1.0" sha3 = "0.9.1" -solana-program = "*" +solana-program = "=1.7.0" syn = "1.0" diff --git a/solana/anchor-bridge/rocksalt/src/lib.rs b/solana/anchor-bridge/rocksalt/src/lib.rs index 64fc2ea9..3a08243c 100644 --- a/solana/anchor-bridge/rocksalt/src/lib.rs +++ b/solana/anchor-bridge/rocksalt/src/lib.rs @@ -12,7 +12,10 @@ use solana_program::{ }; use proc_macro::TokenStream; -use proc_macro2::{Span, TokenStream as TokenStream2}; +use proc_macro2::{ + Span, + TokenStream as TokenStream2, +}; use quote::{ quote, quote_spanned, diff --git a/solana/anchor-bridge/rocksalt/src/to_instruction.rs b/solana/anchor-bridge/rocksalt/src/to_instruction.rs index 98695240..0d92088a 100644 --- a/solana/anchor-bridge/rocksalt/src/to_instruction.rs +++ b/solana/anchor-bridge/rocksalt/src/to_instruction.rs @@ -22,7 +22,11 @@ use syn::{ Index, }; -pub fn generate_to_instruction(name: &syn::Ident, impl_generics: &syn::ImplGenerics, data: &Data) -> TokenStream2 { +pub fn generate_to_instruction( + name: &syn::Ident, + impl_generics: &syn::ImplGenerics, + data: &Data, +) -> TokenStream2 { match *data { Data::Struct(DataStruct { fields: Fields::Named(ref fields), @@ -33,8 +37,8 @@ pub fn generate_to_instruction(name: &syn::Ident, impl_generics: &syn::ImplGener let ty = &field.ty; quote! { - account_metas.append(&mut <#ty as solitaire::Wrap>::wrap(&self.#name)?); - if let Some(pair) = <#ty as solitaire::Wrap>::keypair(self.#name) { + account_metas.append(&mut <#ty as solitaire_client::Wrap>::wrap(&self.#name)?); + if let Some(pair) = <#ty as solitaire_client::Wrap>::keypair(self.#name) { signers.push(pair); } } @@ -44,40 +48,45 @@ pub fn generate_to_instruction(name: &syn::Ident, impl_generics: &syn::ImplGener let client_struct_decl = generate_clientside_struct(&name, &client_struct_name, &data); - quote! { - /// Solitaire-generated client-side #name representation - #client_struct_decl + /// Solitaire-generated client-side #name representation + #[cfg(feature = "no-entrypoint")] + #client_struct_decl - /// Solitaire-generatied ToInstruction implementation - impl #impl_generics solitaire::ToInstruction for #client_struct_name { - fn to_ix( - self, - program_id: solana_program::pubkey::Pubkey, - ix_data: &[u8]) -> std::result::Result< - (solana_program::instruction::Instruction, Vec), - solitaire::ErrBox - > { - use solana_program::{pubkey::Pubkey, instruction::Instruction}; - let mut account_metas = Vec::new(); - let mut signers = Vec::new(); + /// Solitaire-generatied ToInstruction implementation + #[cfg(feature = "no-entrypoint")] + impl #impl_generics solitaire_client::ToInstruction for #client_struct_name { + fn to_ix( + self, + program_id: solana_program::pubkey::Pubkey, + ix_data: &[u8]) -> std::result::Result< + (solitaire_client::Instruction, Vec), + solitaire::ErrBox + > { + use solana_program::{pubkey::Pubkey, instruction::Instruction}; + let mut account_metas = Vec::new(); + let mut signers = Vec::new(); - #(#expanded_appends;)* + #(#expanded_appends;)* - Ok((solana_program::instruction::Instruction::new_with_bytes(program_id, - ix_data, - account_metas), signers)) + Ok((solana_program::instruction::Instruction::new_with_bytes(program_id, + ix_data, + account_metas), signers)) + + } } - - } - } + } } _ => unimplemented!(), } } -pub fn generate_clientside_struct(name: &syn::Ident, client_struct_name: &syn::Ident, data: &Data) -> TokenStream2 { +pub fn generate_clientside_struct( + name: &syn::Ident, + client_struct_name: &syn::Ident, + data: &Data, +) -> TokenStream2 { match *data { Data::Struct(DataStruct { fields: Fields::Named(ref fields), @@ -87,14 +96,14 @@ pub fn generate_clientside_struct(name: &syn::Ident, client_struct_name: &syn::I let field_name = &field.ident; quote! { - #field_name: solitaire::AccEntry + #field_name: solitaire_client::AccEntry } }); quote! { pub struct #client_struct_name { - #(pub #expanded_fields,)* - } + #(pub #expanded_fields,)* + } } } _ => unimplemented!(), diff --git a/solana/anchor-bridge/solitaire-client/Cargo.toml b/solana/anchor-bridge/solitaire-client/Cargo.toml new file mode 100644 index 00000000..0a6318da --- /dev/null +++ b/solana/anchor-bridge/solitaire-client/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "solitaire-client" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +solana-sdk = "=1.7.0" +solana-program = "=1.7.0" +solitaire = {path = "../programs/solitaire", features = ["no-entrypoint"]} +borsh = "0.8.1" diff --git a/solana/anchor-bridge/solitaire-client/src/lib.rs b/solana/anchor-bridge/solitaire-client/src/lib.rs new file mode 100644 index 00000000..91df92b1 --- /dev/null +++ b/solana/anchor-bridge/solitaire-client/src/lib.rs @@ -0,0 +1,129 @@ +#![feature(const_generics)] +#![feature(const_generics_defaults)] +#![allow(warnings)] + +//! Client-specific code + +pub use solana_program::pubkey::Pubkey; +pub use solana_sdk; + +pub use solana_sdk::{ + instruction::{ + AccountMeta, + Instruction, + }, + signature::{ + Keypair, + Signer as SolSigner, + }, +}; + +use borsh::BorshSerialize; + +use solitaire::AccountState; +pub use solitaire::{ + Data, + Derive, + Keyed, + Owned, + Signer, +}; + +type StdResult = std::result::Result; + +pub type ErrBox = Box; + +/// The sum type for clearly specifying the accounts required on client side. +pub enum AccEntry { + /// Least privileged account. + Unprivileged(Pubkey), + + /// Accounts that need to sign a Solana call + Signer(Keypair), + SignerRO(Keypair), + + /// Program addresses for privileged/unprivileged cross calls + CPIProgram(Pubkey), + CPIProgramSigner(Keypair), + + /// Key decided by Wrap implementation + Sysvar, + Derived(Pubkey), + DerivedRO(Pubkey), +} + +/// Types implementing Wrap are those that can be turned into a +/// partial account vector tha +/// payload. +pub trait Wrap { + fn wrap(_: &AccEntry) -> StdResult, ErrBox>; + + /// If the implementor wants to sign using other AccEntry + /// variants, they should override this. + fn keypair(a: AccEntry) -> Option { + use AccEntry::*; + match a { + Signer(pair) => Some(pair), + SignerRO(pair) => Some(pair), + _other => None, + } + } +} + +impl<'a, 'b: 'a, T> Wrap for Signer +where + T: Keyed<'a, 'b>, +{ + fn wrap(a: &AccEntry) -> StdResult, ErrBox> { + use AccEntry::*; + match a { + Signer(pair) => Ok(vec![AccountMeta::new(pair.pubkey(), true)]), + SignerRO(pair) => Ok(vec![AccountMeta::new_readonly(pair.pubkey(), true)]), + other => Err(format!( + "{} must be passed as Signer or SignerRO", + std::any::type_name::() + ) + .into()), + } + } +} + +impl<'a, 'b: 'a, T, const Seed: &'static str> Wrap for Derive { + fn wrap(a: &AccEntry) -> StdResult, ErrBox> { + match a { + AccEntry::Derived(program_id) => { + let (k, extra_seed) = Pubkey::find_program_address(&[Seed.as_bytes()], &program_id); + + Ok(vec![AccountMeta::new(k, false)]) + } + AccEntry::DerivedRO(program_id) => { + let (k, extra_seed) = Pubkey::find_program_address(&[Seed.as_bytes()], &program_id); + + Ok(vec![AccountMeta::new_readonly(k, false)]) + } + other => Err(format!( + "{} must be passed as Derived or DerivedRO", + std::any::type_name::() + ) + .into()), + } + } +} + +impl<'a, T, const IsInitialized: AccountState> Wrap for Data<'a, T, IsInitialized> +where + T: BorshSerialize + Owned + Default, +{ + fn wrap(a: &AccEntry) -> StdResult, ErrBox> { + todo!(); + } +} + +/// Trait used on client side to easily validate a program accounts + ix_data for a bare Solana call +pub trait ToInstruction { + fn to_ix( + self, + program_id: Pubkey, + ix_data: &[u8], + ) -> StdResult<(Instruction, Vec), ErrBox>; +}