diff --git a/.changeset/little-parrots-repair.md b/.changeset/little-parrots-repair.md new file mode 100644 index 0000000000..b19f7553f2 --- /dev/null +++ b/.changeset/little-parrots-repair.md @@ -0,0 +1,5 @@ +--- +'@penumbra-zone/wasm': major +--- + +API updates, renames, and test coverage diff --git a/packages/wasm/crate/Cargo.lock b/packages/wasm/crate/Cargo.lock index 10578bff14..2076d2b253 100644 --- a/packages/wasm/crate/Cargo.lock +++ b/packages/wasm/crate/Cargo.lock @@ -11,23 +11,23 @@ dependencies = [ "macroific", "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" dependencies = [ "gimli", ] [[package]] -name = "adler" -version = "1.0.2" +name = "adler2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" [[package]] name = "aead" @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "ark-bls12-377" @@ -308,9 +308,9 @@ dependencies = [ [[package]] name = "arrayref" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d151e35f61089500b617991b791fc8bfd237ae50cd5950803758a179b41e67a" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" [[package]] name = "arrayvec" @@ -320,15 +320,15 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrayvec" -version = "0.7.4" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" [[package]] name = "async-stream" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" dependencies = [ "async-stream-impl", "futures-core", @@ -337,45 +337,45 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", "miniz_oxide", "object", "rustc-demangle", + "windows-targets", ] [[package]] @@ -489,21 +489,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" dependencies = [ "arrayref", - "arrayvec 0.7.4", - "constant_time_eq 0.3.0", + "arrayvec 0.7.6", + "constant_time_eq 0.3.1", ] [[package]] name = "blake3" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9ec96fe9a81b5e365f9db71fe00edc4fe4ca2cc7dcb7861f0603012a7caa210" +checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" dependencies = [ "arrayref", - "arrayvec 0.7.4", + "arrayvec 0.7.6", "cc", "cfg-if", - "constant_time_eq 0.3.0", + "constant_time_eq 0.3.1", ] [[package]] @@ -553,18 +553,21 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] [[package]] name = "cc" -version = "1.1.6" +version = "1.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" +dependencies = [ + "shlex", +] [[package]] name = "cfg-if" @@ -653,21 +656,21 @@ checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "constant_time_eq" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -759,7 +762,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote", "strsim", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -770,7 +773,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -854,7 +857,7 @@ dependencies = [ "macroific", "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -896,7 +899,7 @@ checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -928,7 +931,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -1019,7 +1022,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -1048,21 +1051,21 @@ dependencies = [ [[package]] name = "fancy_constructor" -version = "1.2.2" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f71f317e4af73b2f8f608fac190c52eac4b1879d2145df1db2fe48881ca69435" +checksum = "07b19d0e43eae2bfbafe4931b5e79c73fb1a849ca15cd41a761a7b8587f9a1a2" dependencies = [ "macroific", "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "ff" @@ -1170,7 +1173,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -1229,9 +1232,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" [[package]] name = "group" @@ -1275,6 +1278,12 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "heck" version = "0.4.1" @@ -1304,9 +1313,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -1686,9 +1695,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexed_db_futures" -version = "0.4.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0704b71f13f81b5933d791abf2de26b33c40935143985220299a357721166706" +checksum = "43315957678a70eb21fb0d2384fe86dde0d6c859a01e24ce127eb65a0143d28c" dependencies = [ "accessory", "cfg-if", @@ -1714,12 +1723,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.0", "serde", ] @@ -1777,18 +1786,18 @@ checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] [[package]] name = "k256" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" dependencies = [ "cfg-if", "ecdsa", @@ -1807,9 +1816,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "linux-raw-sys" @@ -1853,7 +1862,7 @@ dependencies = [ "cfg-if", "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -1864,7 +1873,7 @@ checksum = "13198c120864097a565ccb3ff947672d969932b7975ebd4085732c9f09435e55" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -1877,7 +1886,7 @@ dependencies = [ "macroific_core", "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -1896,13 +1905,23 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "minicov" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c71e683cd655513b99affab7d317deb690528255a0d5f717f1024093c12b169" +dependencies = [ + "cc", + "walkdir", +] + [[package]] name = "miniz_oxide" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" dependencies = [ - "adler", + "adler2", ] [[package]] @@ -1958,18 +1977,21 @@ dependencies = [ [[package]] name = "object" -version = "0.36.2" +version = "0.36.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f203fa8daa7bb185f760ae12bd8e097f63d17041dcdcaf675ac54cdf863170e" +checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" dependencies = [ "memchr", ] [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "opaque-debug" @@ -1983,7 +2005,7 @@ version = "3.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "306800abfa29c7f16596b5970a588435e3d5b3149683d00c12b699cc19f895ee" dependencies = [ - "arrayvec 0.7.4", + "arrayvec 0.7.6", "bitvec", "byte-slice-cast", "impl-trait-for-tuples", @@ -2796,7 +2818,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ "fixedbitset", - "indexmap 2.2.6", + "indexmap 2.6.0", ] [[package]] @@ -2816,7 +2838,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -2854,9 +2876,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "poseidon-parameters" @@ -2908,18 +2930,21 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] [[package]] name = "prettyplease" -version = "0.2.20" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +checksum = "479cf940fbbb3426c32c5d5176f62ad57549a0bb84773423ba8be9d089f5faba" dependencies = [ "proc-macro2 1.0.86", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -2936,9 +2961,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ "toml_edit", ] @@ -2988,7 +3013,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.72", + "syn 2.0.79", "tempfile", ] @@ -3002,7 +3027,7 @@ dependencies = [ "itertools 0.12.1", "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -3016,9 +3041,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2 1.0.86", ] @@ -3090,18 +3115,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.10.5" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -3111,9 +3136,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -3122,9 +3147,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "rfc6979" @@ -3159,24 +3184,24 @@ checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" [[package]] name = "rustc_version" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -3232,6 +3257,15 @@ dependencies = [ "safe-regex-compiler", ] +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -3265,9 +3299,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.204" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] @@ -3294,22 +3328,23 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] @@ -3322,7 +3357,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -3341,20 +3376,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f1b15838534b38fb67ffe60033fe3ffad48f916c175e8baa0400e0cdb958dec" dependencies = [ "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] name = "serde_with" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +checksum = "9720086b3357bcb44fce40117d769a4d068c70ecfa190850a980a71755f66fcc" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.6", + "indexmap 2.6.0", "serde", "serde_derive", "serde_json", @@ -3364,14 +3399,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.9.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +checksum = "5f1abbfe725f27678f4663bcacb75a83e829fd464c25d78dd038a3a29e307cec" dependencies = [ "darling", "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -3408,6 +3443,12 @@ dependencies = [ "keccak", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signature" version = "2.2.0" @@ -3499,9 +3540,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2 1.0.86", "quote", @@ -3516,14 +3557,15 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -3588,22 +3630,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -3639,9 +3681,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.39.1" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d040ac2b29ab03b09d4129c2f5bbd012a3ac2f79d38ff506a4bf8dd34b0eac8a" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "pin-project-lite", @@ -3649,9 +3691,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -3660,17 +3702,17 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" -version = "0.21.1" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.6.0", "toml_datetime", "winnow", ] @@ -3688,15 +3730,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -3718,7 +3760,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -3760,9 +3802,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-xid" @@ -3798,9 +3840,19 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[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 = "wasi" @@ -3810,34 +3862,35 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -3847,9 +3900,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3857,31 +3910,32 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-bindgen-test" -version = "0.3.42" +version = "0.3.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" +checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9" dependencies = [ "console_error_panic_hook", "js-sys", + "minicov", "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", @@ -3890,25 +3944,34 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.42" +version = "0.3.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" +checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", ] +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "windows-core" version = "0.52.0" @@ -3927,6 +3990,15 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" version = "0.52.6" @@ -3993,9 +4065,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.5.40" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -4015,6 +4087,7 @@ version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ + "byteorder", "zerocopy-derive", ] @@ -4026,7 +4099,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] [[package]] @@ -4046,5 +4119,5 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2 1.0.86", "quote", - "syn 2.0.72", + "syn 2.0.79", ] diff --git a/packages/wasm/crate/Cargo.toml b/packages/wasm/crate/Cargo.toml index 26b2cb1a3a..b8782283ca 100644 --- a/packages/wasm/crate/Cargo.toml +++ b/packages/wasm/crate/Cargo.toml @@ -30,23 +30,23 @@ penumbra-stake = { git = "https://github.com/penumbra-zone/penumbra.git", tag = penumbra-tct = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.80.5", package = "penumbra-tct" } penumbra-transaction = { git = "https://github.com/penumbra-zone/penumbra.git", tag = "v0.80.5", package = "penumbra-transaction", default-features = false } -anyhow = "1.0.86" +anyhow = "1.0.89" ark-ff = { version = "0.4.2", features = ["std"] } base64 = "0.22.1" console_error_panic_hook = { version = "0.1.7", optional = true } decaf377 = { version = "0.10.1", features = ["r1cs"] } hex = "0.4.3" -indexed_db_futures = "0.4.1" +indexed_db_futures = "0.5.0" prost = "0.12.6" rand_core = { version = "0.6.4", features = ["getrandom"] } -regex = { version = "1.10.5" } -serde = { version = "1.0.204", features = ["derive"] } +regex = { version = "1.11.0" } +serde = { version = "1.0.210", features = ["derive"] } serde-wasm-bindgen = "0.6.5" -thiserror = "1.0.61" -wasm-bindgen = "0.2.92" -wasm-bindgen-futures = "0.4.42" -web-sys = { version = "0.3.69", features = ["console"] } +thiserror = "1.0.64" +wasm-bindgen = "0.2.93" +wasm-bindgen-futures = "0.4.43" +web-sys = { version = "0.3.70", features = ["console"] } [dev-dependencies] -wasm-bindgen-test = "0.3.42" -serde_json = "1.0.120" +wasm-bindgen-test = "0.3.43" +serde_json = "1.0.128" diff --git a/packages/wasm/crate/src/asset.rs b/packages/wasm/crate/src/asset.rs index 655437781a..1758139a60 100644 --- a/packages/wasm/crate/src/asset.rs +++ b/packages/wasm/crate/src/asset.rs @@ -3,7 +3,7 @@ use penumbra_asset::asset::Id; use penumbra_proto::DomainType; use wasm_bindgen::prelude::*; -/// generate the appropriate binary inner id for a binary-serialized protobuf +/// generate the appropriate AssetId for a binary-serialized protobuf /// `AssetId` potentially containing an `altBaseDenom` or `altBech32m` string /// field /// @@ -11,9 +11,9 @@ use wasm_bindgen::prelude::*; /// input_id_bin: `Uint8Array` representing a binary-serialized `AssetId` /// /// Returns: -/// `Uint8Array` representing the literal inner id +/// `Uint8Array` representing a binary-serialized `AssetId` #[wasm_bindgen] -pub fn get_asset_id_inner(input_id_bin: &[u8]) -> WasmResult> { +pub fn get_asset_id(input_id_bin: &[u8]) -> WasmResult> { let input_id = Id::decode(input_id_bin)?; - Ok(input_id.to_bytes().to_vec()) + Ok(input_id.encode_to_vec()) } diff --git a/packages/wasm/crate/src/auction.rs b/packages/wasm/crate/src/auction.rs index c7e90c6062..fa9602db35 100644 --- a/packages/wasm/crate/src/auction.rs +++ b/packages/wasm/crate/src/auction.rs @@ -27,45 +27,3 @@ pub fn get_auction_nft_metadata(auction_id: &[u8], seq: u64) -> WasmResult(&result_bytes).unwrap(); - let result_proto = result.to_proto(); - - assert!(result_proto.symbol.starts_with("auction@1234(")); - assert!(result_proto.display.starts_with("auctionnft_1234_pauctid1")); - } -} diff --git a/packages/wasm/crate/src/database/indexed_db.rs b/packages/wasm/crate/src/database/indexed_db.rs index 14e4f40bfe..9e40f283c6 100644 --- a/packages/wasm/crate/src/database/indexed_db.rs +++ b/packages/wasm/crate/src/database/indexed_db.rs @@ -26,6 +26,7 @@ pub async fn open_idb_database(constants: &DbConstants) -> WasmResult OpenDbRequest { db_req.set_on_upgrade_needed(Some(|evt: &IdbVersionChangeEvent| -> Result<(), JsValue> { // Check if the object store exists; create it if it doesn't @@ -39,10 +40,12 @@ async fn mock_test_database(mut db_req: OpenDbRequest) -> OpenDbRequest { .create_object_store_with_params("SPENDABLE_NOTES", ¬e_object_store_params)?; let nullifier_key: JsValue = serde_wasm_bindgen::to_value("nullifier.inner")?; + let params = web_sys::IdbIndexParameters::new(); + params.set_unique(false); note_object_store.create_index_with_params( "nullifier", &IdbKeyPath::new(nullifier_key), - web_sys::IdbIndexParameters::new().unique(false), + ¶ms, )?; evt.db().create_object_store("TREE_LAST_POSITION")?; evt.db().create_object_store("TREE_LAST_FORGOTTEN")?; diff --git a/packages/wasm/crate/src/error.rs b/packages/wasm/crate/src/error.rs index b8bd665e0e..dfefa2b654 100644 --- a/packages/wasm/crate/src/error.rs +++ b/packages/wasm/crate/src/error.rs @@ -1,9 +1,6 @@ -use std::convert::Infallible; use std::num::TryFromIntError; -use base64::DecodeError as Base64DecodeError; -use hex::FromHexError; -use penumbra_tct::error::{InsertBlockError, InsertEpochError, InsertError}; +use penumbra_tct::error::InsertError; use prost::DecodeError as ProstDecodeError; use serde_wasm_bindgen::Error; use thiserror::Error; @@ -17,24 +14,9 @@ pub enum WasmError { #[error("{0}")] Anyhow(#[from] anyhow::Error), - #[error("{0}")] - Base64DecodeError(#[from] Base64DecodeError), - #[error("{0}")] Dom(#[from] DomError), - #[error("{0}")] - FromHexError(#[from] FromHexError), - - #[error("{0}")] - Infallible(#[from] Infallible), - - #[error("{0}")] - InsertBlockError(#[from] InsertBlockError), - - #[error("{0}")] - InsertEpochError(#[from] InsertEpochError), - #[error("{0}")] InsertError(#[from] InsertError), diff --git a/packages/wasm/crate/src/lib.rs b/packages/wasm/crate/src/lib.rs index 1a15fa1351..f060831b71 100644 --- a/packages/wasm/crate/src/lib.rs +++ b/packages/wasm/crate/src/lib.rs @@ -1,9 +1,3 @@ -#![allow(dead_code)] -// Requires nightly. -#![cfg_attr(docsrs, feature(doc_auto_cfg))] - -extern crate core; - pub mod asset; pub mod auction; pub mod build; diff --git a/packages/wasm/crate/src/metadata.rs b/packages/wasm/crate/src/metadata.rs index 798b5ff4bb..1bbea1335f 100644 --- a/packages/wasm/crate/src/metadata.rs +++ b/packages/wasm/crate/src/metadata.rs @@ -119,231 +119,3 @@ fn get_lp_info(captures: ®ex::Captures) -> WasmResult<(String, String)> { id_match.as_str().to_string(), )) } - -#[cfg(test)] -mod test_helpers { - use penumbra_proto::core::asset::v1::DenomUnit; - - use super::*; - - pub fn get_metadata_for(display_denom: &str, base_denom_is_display_denom: bool) -> Metadata { - let mut denom_units = Vec::new(); - denom_units.push(DenomUnit { - aliases: Vec::new(), - denom: if base_denom_is_display_denom { - String::from(display_denom) - } else { - format!("u{display_denom}") - }, - exponent: 0, - }); - - if !base_denom_is_display_denom { - denom_units.push(DenomUnit { - aliases: Vec::new(), - denom: String::from(display_denom), - exponent: 6, - }); - } - - Metadata { - base: if base_denom_is_display_denom { - String::from(display_denom) - } else { - format!("u{display_denom}") - }, - description: String::from(""), - denom_units, - display: String::from(display_denom), - images: Vec::new(), - name: String::from(""), - penumbra_asset_id: None, - symbol: String::from(""), - priority_score: 0, - } - } - - #[test] - fn it_interpolates_display_denom() { - assert_eq!(get_metadata_for("penumbra", false).base, "upenumbra"); - assert_eq!(get_metadata_for("penumbra", false).display, "penumbra"); - assert_eq!( - get_metadata_for("penumbra", false).denom_units[0].denom, - "upenumbra" - ); - assert_eq!( - get_metadata_for("penumbra", false).denom_units[1].denom, - "penumbra" - ); - } -} - -#[cfg(test)] -mod customize_symbol_inner_tests { - use super::*; - - #[test] - fn it_returns_non_staking_metadata_as_is() { - let metadata = Metadata { - name: String::from("Penumbra"), - symbol: String::from("UM"), - ..test_helpers::get_metadata_for("penumbra", false) - }; - let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); - - assert_eq!(metadata, customized_metadata); - } - - #[test] - fn it_modifies_unbonding_token_symbol() { - let metadata = Metadata { - name: String::from("Unbonding Token"), - symbol: String::from(""), - ..test_helpers::get_metadata_for( - "unbonding_start_at_1234_penumbravalid1abcdef123456", - false, - ) - }; - let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); - - assert_eq!(customized_metadata.symbol, "unbondUMat1234(abcdef123456)"); - } - - #[test] - fn it_modifies_delegation_token_symbol() { - let metadata = Metadata { - name: String::from("Delegation Token"), - symbol: String::from(""), - ..test_helpers::get_metadata_for("delegation_penumbravalid1abcdef123456", false) - }; - let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); - - assert_eq!(customized_metadata.symbol, "delUM(abcdef123456)"); - } - - #[test] - fn it_modifies_auction_nft_symbol_with_seq_num() { - let metadata = Metadata { - name: String::from(""), - symbol: String::from(""), - ..test_helpers::get_metadata_for( - "auctionnft_0_pauctid1jqyupqnzznyfpq940mv0ac33pyx77s7af3kgdw4nstjmp3567dks8n5amh", - true, - ) - }; - let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); - - assert_eq!( - customized_metadata.symbol, - "auction@0(jqyupqnzznyfpq940mv0ac33pyx77s7af3kgdw4nstjmp3567dks8n5amh)" - ); - - let metadata = Metadata { - name: String::from(""), - symbol: String::from(""), - ..test_helpers::get_metadata_for( - "auctionnft_123_pauctid1jqyupqnzznyfpq940mv0ac33pyx77s7af3kgdw4nstjmp3567dks8n5amh", - true, - ) - }; - let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); - - assert_eq!( - customized_metadata.symbol, - "auction@123(jqyupqnzznyfpq940mv0ac33pyx77s7af3kgdw4nstjmp3567dks8n5amh)" - ); - } - - #[test] - fn it_modifies_voting_receipt_token() { - let metadata = Metadata { - name: String::from(""), - symbol: String::from(""), - ..test_helpers::get_metadata_for("voted_on_234", false) - }; - let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); - - assert_eq!(customized_metadata.symbol, "VotedOn234"); - } - - #[test] - fn it_modifies_lp_nft_opened() { - let metadata = Metadata { - name: String::from("xyz"), - symbol: String::from("xyz"), - ..test_helpers::get_metadata_for( - "lpnft_opened_plpid1pae7ssx6uwct9srws9uxznp7n087me8j9jvpmf5tve8fjupky4rqspvcd5", - true, - ) - }; - let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); - - assert_eq!( - customized_metadata.symbol, - "lpNft:opened(pae7ssx6uwct9srws9uxznp7n087me8j9jvpmf5tve8fjupky4rqspvcd5)" - ); - } - - #[test] - fn it_modifies_lp_nft_closed() { - let metadata = Metadata { - name: String::from("xyz"), - symbol: String::from("xyz"), - ..test_helpers::get_metadata_for( - "lpnft_closed_plpid1y4y5y94wrtkrem0a2mv9pwqk8myv9ykfamkz28jy97ycs8zgw0ysrnqm3r", - true, - ) - }; - let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); - - assert_eq!( - customized_metadata.symbol, - "lpNft:closed(y4y5y94wrtkrem0a2mv9pwqk8myv9ykfamkz28jy97ycs8zgw0ysrnqm3r)" - ); - } - - #[test] - fn it_modifies_lp_nft_withdrawn() { - let metadata = Metadata { - name: String::from("xyz"), - symbol: String::from("xyz"), - ..test_helpers::get_metadata_for( - "lpnft_withdrawn_0_plpid1pae7ssx6uwct9srws9uxznp7n087me8j9jvpmf5tve8fjupky4rqspvcd5", - true, - ) - }; - let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); - - assert_eq!( - customized_metadata.symbol, - "lpNft:withdrawn_0(pae7ssx6uwct9srws9uxznp7n087me8j9jvpmf5tve8fjupky4rqspvcd5)" - ); - } -} - -#[cfg(test)] -mod customize_symbol_tests { - use super::*; - - #[test] - /// `customize_symbol` is just a thin wrapper around - /// `customize_symbol_inner` that allows metadata to be passed in as a byte - /// array. So we'll just do a basic test to make sure it works as expected, - /// rather than exercising every use case. - fn it_works() { - let metadata = Metadata { - name: String::from("Delegation Token"), - symbol: String::from(""), - ..test_helpers::get_metadata_for("delegation_penumbravalid1abcdef123456", false) - }; - let metadata_as_bytes = MetadataDomainType::try_from(metadata) - .unwrap() - .encode_to_vec(); - let customized_metadata_bytes = customize_symbol(&metadata_as_bytes).unwrap(); - let customized_metadata_result = - MetadataDomainType::decode::<&[u8]>(&customized_metadata_bytes); - let customized_metadata_proto = customized_metadata_result.unwrap().to_proto(); - - assert_eq!(customized_metadata_proto.symbol, "delUM(abcdef123456)"); - } -} diff --git a/packages/wasm/crate/src/note_record.rs b/packages/wasm/crate/src/note_record.rs index df889572dd..143e8519d0 100644 --- a/packages/wasm/crate/src/note_record.rs +++ b/packages/wasm/crate/src/note_record.rs @@ -6,7 +6,7 @@ use penumbra_tct as tct; use serde::{Deserialize, Serialize}; use std::convert::{TryFrom, TryInto}; -/// Corresponds to the SpendableNoteRecord proto +// We sadly have to vendor this code as penumbra-view package cannot be compiled with wasm-pack #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(try_from = "pb::SpendableNoteRecord", into = "pb::SpendableNoteRecord")] pub struct SpendableNoteRecord { diff --git a/packages/wasm/crate/src/swap_record.rs b/packages/wasm/crate/src/swap_record.rs index 4ab9dc61d8..05d14b6b46 100644 --- a/packages/wasm/crate/src/swap_record.rs +++ b/packages/wasm/crate/src/swap_record.rs @@ -6,6 +6,7 @@ use std::convert::{TryFrom, TryInto}; use serde::{Deserialize, Serialize}; +// We sadly have to vendor this code as penumbra-view package cannot be compiled with wasm-pack #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(try_from = "pb::SwapRecord", into = "pb::SwapRecord")] pub struct SwapRecord { diff --git a/packages/wasm/crate/src/view_server.rs b/packages/wasm/crate/src/view_server.rs index f2e67a480b..9e5eb0c28a 100644 --- a/packages/wasm/crate/src/view_server.rs +++ b/packages/wasm/crate/src/view_server.rs @@ -1,7 +1,6 @@ use std::collections::BTreeMap; use indexed_db_futures::IdbDatabase; -use penumbra_asset::asset::{Id, Metadata}; use penumbra_compact_block::{CompactBlock, StatePayload}; use penumbra_keys::{Address, FullViewingKey}; use penumbra_proto::DomainType; @@ -58,11 +57,9 @@ impl ScanBlockResult { #[wasm_bindgen] pub struct ViewServer { latest_height: u64, - epoch_duration: u64, fvk: FullViewingKey, notes: BTreeMap, swaps: BTreeMap, - denoms: BTreeMap, sct: Tree, storage: Storage, last_position: Option, @@ -82,7 +79,6 @@ impl ViewServer { #[wasm_bindgen] pub async fn new( full_viewing_key: &[u8], - epoch_duration: u64, stored_tree: JsValue, idb_constants: JsValue, ) -> WasmResult { @@ -95,9 +91,7 @@ impl ViewServer { let view_server = Self { latest_height: u64::MAX, fvk, - epoch_duration, notes: Default::default(), - denoms: Default::default(), sct: tree, swaps: Default::default(), storage: init_idb_storage(constants).await?, diff --git a/packages/wasm/crate/tests/test_auction.rs b/packages/wasm/crate/tests/test_auction.rs new file mode 100644 index 0000000000..f47a03b65b --- /dev/null +++ b/packages/wasm/crate/tests/test_auction.rs @@ -0,0 +1,36 @@ +extern crate penumbra_wasm; +use ark_ff::Zero; +use decaf377::Fq; +use penumbra_asset::{ + asset::{Id, Metadata}, + Value, +}; +use penumbra_auction::auction::dutch::DutchAuctionDescription; +use penumbra_num::Amount; +use penumbra_proto::DomainType; +use penumbra_wasm::auction::{get_auction_id, get_auction_nft_metadata}; + +#[test] +fn it_gets_correct_id_and_metadata() { + let description = DutchAuctionDescription { + start_height: 0, + end_height: 100, + input: Value { + amount: Amount::default(), + asset_id: Id(Fq::zero()), + }, + min_output: Amount::default(), + max_output: Amount::default(), + nonce: [0; 32], + output_id: Id(Fq::zero()), + step_count: 100u64, + }; + + let auction_id_bytes = get_auction_id(&description.encode_to_vec()).unwrap(); + let result_bytes = get_auction_nft_metadata(&auction_id_bytes, 1234).unwrap(); + let result = Metadata::decode::<&[u8]>(&result_bytes).unwrap(); + let result_proto = result.to_proto(); + + assert!(result_proto.symbol.starts_with("auction@1234(")); + assert!(result_proto.display.starts_with("auctionnft_1234_pauctid1")); +} diff --git a/packages/wasm/crate/tests/test_keys.rs b/packages/wasm/crate/tests/test_keys.rs index 8f295b5c36..13b8d62d25 100644 --- a/packages/wasm/crate/tests/test_keys.rs +++ b/packages/wasm/crate/tests/test_keys.rs @@ -1,44 +1,79 @@ extern crate core; -use penumbra_keys::keys::{AddressIndex, Bip44Path, SeedPhrase, SpendKey}; -use penumbra_keys::FullViewingKey; -use penumbra_proto::core::keys::v1::WalletId; +use penumbra_keys::keys::{ + AddressIndex, Bip44Path, SeedPhrase, SpendKey, SpendKeyBytes, WalletId, SPENDKEY_LEN_BYTES, +}; +use penumbra_keys::{Address, FullViewingKey}; use penumbra_proto::{DomainType, Message}; -use penumbra_wasm::keys::{get_wallet_id, is_controlled_inner}; +use penumbra_wasm::keys::{ + generate_spend_key, get_address_by_index, get_full_viewing_key, get_wallet_id, + is_controlled_address, +}; use rand_core::OsRng; use std::str::FromStr; -use wasm_bindgen_test::wasm_bindgen_test; + +const TEST_SEED_PHRASE: &str = "comfort ten front cycle churn burger oak absent rice ice urge result art couple benefit cabbage frequent obscure hurry trick segment cool job debate"; #[test] -fn successfully_get_wallet_id() { - let fvk = FullViewingKey::from_str("penumbrafullviewingkey1sjeaceqzgaeye2ksnz8q73mp6rpx2ykdtzs8wurrnhwdn8vqwuxhxtjdndrjc74udjh0uch0tatnrd93q50wp9pfk86h3lgpew8lsqsz2a6la").unwrap(); - let wallet_id = WalletId::decode( - get_wallet_id(fvk.encode_to_vec().as_slice()) - .unwrap() - .as_slice(), - ) - .unwrap(); - let expected_bech32_str = - "penumbrawalletid15r7q7qsf3hhsgj0g530n7ng9acdacmmx9ajknjz38dyt90u9gcgsmjre75".to_string(); - let walet_id_str = penumbra_keys::keys::WalletId::try_from(wallet_id) - .unwrap() - .to_string(); - - assert_eq!(expected_bech32_str, walet_id_str); +fn generates_spend_key() { + let slice = generate_spend_key(TEST_SEED_PHRASE).unwrap(); + let mut bytes = [0u8; SPENDKEY_LEN_BYTES]; + bytes.copy_from_slice(&slice[0..32]); + + let spend_key = SpendKey::from(SpendKeyBytes::from(bytes)); + assert_eq!( + spend_key.to_string(), + "penumbraspendkey1pgsphqgnltgy7hdspe4v74qefx2slp0v50szuup9fqutw5959gkq97v54y" + ); +} + +#[test] +fn generates_fvk() { + let spend_key = generate_spend_key(TEST_SEED_PHRASE).unwrap(); + let fvk_bytes = get_full_viewing_key(spend_key.as_slice()).unwrap(); + let fvk = FullViewingKey::decode(fvk_bytes.as_slice()).unwrap(); + assert_eq!(fvk.to_string(), "penumbrafullviewingkey1vzfytwlvq067g2kz095vn7sgcft47hga40atrg5zu2crskm6tyyjysm28qg5nth2fqmdf5n0q530jreumjlsrcxjwtfv6zdmfpe5kqsa5lg09"); +} + +#[test] +fn generates_wallet_id() { + let spend_key = generate_spend_key(TEST_SEED_PHRASE).unwrap(); + let fvk_bytes = get_full_viewing_key(spend_key.as_slice()).unwrap(); + let wallet_id_bytes = get_wallet_id(fvk_bytes.as_slice()).unwrap(); + let wallet_id = WalletId::decode(wallet_id_bytes.as_slice()).unwrap(); + assert_eq!( + wallet_id.to_string(), + "penumbrawalletid172c36rsht9483decguzwg3x3p50kjxz9yh4f9luwdz8qyemc9vpsdw5j4m" + ); } -#[wasm_bindgen_test] +#[test] +fn gets_address_by_index() { + let spend_key = generate_spend_key(TEST_SEED_PHRASE).unwrap(); + let fvk_bytes = get_full_viewing_key(spend_key.as_slice()).unwrap(); + let address_bytes = get_address_by_index(fvk_bytes.as_slice(), 0).unwrap(); + let address = Address::decode(address_bytes.as_slice()).unwrap(); + assert_eq!( + address.to_string(), + "penumbra147mfall0zr6am5r45qkwht7xqqrdsp50czde7empv7yq2nk3z8yyfh9k9520ddgswkmzar22vhz9dwtuem7uxw0qytfpv7lk3q9dp8ccaw2fn5c838rfackazmgf3ahh09cxmz" + ); +} + +#[test] fn raises_if_fvk_invalid() { - let fvk = FullViewingKey::from_str("penumbrafullviewingkey1sjeaceqzgaeye2ksnz8q73mp6rpx2ykdtzs8wurrnhwdn8vqwuxhxtjdndrjc74udjh0uch0tatnrd93q50wp9pfk86h3lgpew8lsqsz2a6la").unwrap(); - let err = get_wallet_id(fvk.encode_to_vec().as_slice()).unwrap_err(); - assert_eq!("invalid length", err.to_string()); + let invalid_fvk = vec![0, 1, 2, 3]; + let err = get_wallet_id(invalid_fvk.encode_to_vec().as_slice()).unwrap_err(); + assert_eq!( + "Wrong byte length, expected 64 but found 4", + err.to_string() + ); } #[test] fn detects_controlled_addr() { let fvk = FullViewingKey::from_str("penumbrafullviewingkey1sjeaceqzgaeye2ksnz8q73mp6rpx2ykdtzs8wurrnhwdn8vqwuxhxtjdndrjc74udjh0uch0tatnrd93q50wp9pfk86h3lgpew8lsqsz2a6la").unwrap(); let (addr, _) = fvk.payment_address(AddressIndex::new(0)); - assert!(is_controlled_inner(&fvk, &addr)); + assert!(is_controlled_address(&fvk.encode_to_vec(), &addr.encode_to_vec()).unwrap()); } #[test] @@ -50,5 +85,5 @@ fn returns_false_on_unknown_addr() { .incoming() .payment_address(AddressIndex::from(0u32)) .0; - assert!(!is_controlled_inner(&fvk, &other_address)); + assert!(!is_controlled_address(&fvk.encode_to_vec(), &other_address.encode_to_vec()).unwrap()); } diff --git a/packages/wasm/crate/tests/test_metadata.rs b/packages/wasm/crate/tests/test_metadata.rs new file mode 100644 index 0000000000..d36aa8ce98 --- /dev/null +++ b/packages/wasm/crate/tests/test_metadata.rs @@ -0,0 +1,211 @@ +extern crate penumbra_wasm; + +use penumbra_asset::asset::Metadata; +use penumbra_proto::core::asset::v1 as pb; +use penumbra_proto::DomainType; +use penumbra_wasm::metadata::{customize_symbol, customize_symbol_inner}; + +fn get_metadata_for(display_denom: &str, base_denom_is_display_denom: bool) -> pb::Metadata { + let mut denom_units = Vec::new(); + denom_units.push(pb::DenomUnit { + aliases: Vec::new(), + denom: if base_denom_is_display_denom { + String::from(display_denom) + } else { + format!("u{display_denom}") + }, + exponent: 0, + }); + + if !base_denom_is_display_denom { + denom_units.push(pb::DenomUnit { + aliases: Vec::new(), + denom: String::from(display_denom), + exponent: 6, + }); + } + + pb::Metadata { + base: if base_denom_is_display_denom { + String::from(display_denom) + } else { + format!("u{display_denom}") + }, + description: String::from(""), + denom_units, + display: String::from(display_denom), + images: Vec::new(), + name: String::from(""), + penumbra_asset_id: None, + symbol: String::from(""), + priority_score: 0, + } +} + +#[test] +fn get_helper_interpolates_display_denom() { + assert_eq!(get_metadata_for("penumbra", false).base, "upenumbra"); + assert_eq!(get_metadata_for("penumbra", false).display, "penumbra"); + assert_eq!( + get_metadata_for("penumbra", false).denom_units[0].denom, + "upenumbra" + ); + assert_eq!( + get_metadata_for("penumbra", false).denom_units[1].denom, + "penumbra" + ); +} + +#[test] +fn returns_non_staking_metadata_as_is() { + let metadata = pb::Metadata { + name: String::from("Penumbra"), + symbol: String::from("UM"), + ..get_metadata_for("penumbra", false) + }; + let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); + + assert_eq!(metadata, customized_metadata); +} + +#[test] +fn modifies_unbonding_token_symbol() { + let metadata = pb::Metadata { + name: String::from("Unbonding Token"), + symbol: String::from(""), + ..get_metadata_for("unbonding_start_at_1234_penumbravalid1abcdef123456", false) + }; + let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); + + assert_eq!(customized_metadata.symbol, "unbondUMat1234(abcdef123456)"); +} + +#[test] +fn modifies_delegation_token_symbol() { + let metadata = pb::Metadata { + name: String::from("Delegation Token"), + symbol: String::from(""), + ..get_metadata_for("delegation_penumbravalid1abcdef123456", false) + }; + let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); + + assert_eq!(customized_metadata.symbol, "delUM(abcdef123456)"); +} + +#[test] +fn modifies_auction_nft_symbol_with_seq_num() { + let metadata = pb::Metadata { + name: String::from(""), + symbol: String::from(""), + ..get_metadata_for( + "auctionnft_0_pauctid1jqyupqnzznyfpq940mv0ac33pyx77s7af3kgdw4nstjmp3567dks8n5amh", + true, + ) + }; + let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); + + assert_eq!( + customized_metadata.symbol, + "auction@0(jqyupqnzznyfpq940mv0ac33pyx77s7af3kgdw4nstjmp3567dks8n5amh)" + ); + + let metadata = pb::Metadata { + name: String::from(""), + symbol: String::from(""), + ..get_metadata_for( + "auctionnft_123_pauctid1jqyupqnzznyfpq940mv0ac33pyx77s7af3kgdw4nstjmp3567dks8n5amh", + true, + ) + }; + let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); + + assert_eq!( + customized_metadata.symbol, + "auction@123(jqyupqnzznyfpq940mv0ac33pyx77s7af3kgdw4nstjmp3567dks8n5amh)" + ); +} + +#[test] +fn modifies_voting_receipt_token() { + let metadata = pb::Metadata { + name: String::from(""), + symbol: String::from(""), + ..get_metadata_for("voted_on_234", false) + }; + let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); + + assert_eq!(customized_metadata.symbol, "VotedOn234"); +} + +#[test] +fn modifies_lp_nft_opened() { + let metadata = pb::Metadata { + name: String::from("xyz"), + symbol: String::from("xyz"), + ..get_metadata_for( + "lpnft_opened_plpid1pae7ssx6uwct9srws9uxznp7n087me8j9jvpmf5tve8fjupky4rqspvcd5", + true, + ) + }; + let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); + + assert_eq!( + customized_metadata.symbol, + "lpNft:opened(pae7ssx6uwct9srws9uxznp7n087me8j9jvpmf5tve8fjupky4rqspvcd5)" + ); +} + +#[test] +fn modifies_lp_nft_closed() { + let metadata = pb::Metadata { + name: String::from("xyz"), + symbol: String::from("xyz"), + ..get_metadata_for( + "lpnft_closed_plpid1y4y5y94wrtkrem0a2mv9pwqk8myv9ykfamkz28jy97ycs8zgw0ysrnqm3r", + true, + ) + }; + let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); + + assert_eq!( + customized_metadata.symbol, + "lpNft:closed(y4y5y94wrtkrem0a2mv9pwqk8myv9ykfamkz28jy97ycs8zgw0ysrnqm3r)" + ); +} + +#[test] +fn modifies_lp_nft_withdrawn() { + let metadata = pb::Metadata { + name: String::from("xyz"), + symbol: String::from("xyz"), + ..get_metadata_for( + "lpnft_withdrawn_0_plpid1pae7ssx6uwct9srws9uxznp7n087me8j9jvpmf5tve8fjupky4rqspvcd5", + true, + ) + }; + let customized_metadata = customize_symbol_inner(metadata.clone()).unwrap(); + + assert_eq!( + customized_metadata.symbol, + "lpNft:withdrawn_0(pae7ssx6uwct9srws9uxznp7n087me8j9jvpmf5tve8fjupky4rqspvcd5)" + ); +} + +/// `customize_symbol` is just a thin wrapper around +/// `customize_symbol_inner` that allows metadata to be passed in as a byte +/// array. So we'll just do a basic test to make sure it works as expected, +/// rather than exercising every use case. +#[test] +fn inner_works() { + let metadata = pb::Metadata { + name: String::from("Delegation Token"), + symbol: String::from(""), + ..get_metadata_for("delegation_penumbravalid1abcdef123456", false) + }; + let metadata_as_bytes = Metadata::try_from(metadata).unwrap().encode_to_vec(); + let customized_metadata_bytes = customize_symbol(&metadata_as_bytes).unwrap(); + let customized_metadata_result = Metadata::decode::<&[u8]>(&customized_metadata_bytes); + let customized_metadata_proto = customized_metadata_result.unwrap().to_proto(); + + assert_eq!(customized_metadata_proto.symbol, "delUM(abcdef123456)"); +} diff --git a/packages/wasm/crate/tests/test_stake.rs b/packages/wasm/crate/tests/test_stake.rs new file mode 100644 index 0000000000..b64833167b --- /dev/null +++ b/packages/wasm/crate/tests/test_stake.rs @@ -0,0 +1,20 @@ +use penumbra_proto::core::asset::v1::Metadata; +use penumbra_proto::DomainType; +use penumbra_stake::IdentityKey; +use penumbra_wasm::stake::get_delegation_asset; +use prost::Message; +use std::str::FromStr; + +#[test] +fn gets_delegation_metadata() { + let identity_key = IdentityKey::from_str( + "penumbravalid19caff39080amxlupcjutnhcm7vh8rjfevza0hpx33pn7lntf6vyqvuekzh", + ) + .unwrap(); + let metadata_bytes = get_delegation_asset(&identity_key.encode_to_vec()).unwrap(); + let metadata = Metadata::decode(metadata_bytes.as_slice()).unwrap(); + assert_eq!( + metadata.base, + "udelegation_penumbravalid19caff39080amxlupcjutnhcm7vh8rjfevza0hpx33pn7lntf6vyqvuekzh" + ) +} diff --git a/packages/wasm/crate/tests/test_tree.rs b/packages/wasm/crate/tests/test_tree.rs new file mode 100644 index 0000000000..26f1dce3c5 --- /dev/null +++ b/packages/wasm/crate/tests/test_tree.rs @@ -0,0 +1,13 @@ +use penumbra_proto::DomainType; +use penumbra_sct::epoch::Epoch; +use penumbra_wasm::tree::sct_position; + +#[test] +fn gets_position() { + let epoch = Epoch { + index: 56, + start_height: 1385719, + }; + let position = sct_position(1386375, &epoch.encode_to_vec()).unwrap(); + assert_eq!(position, 240561160192); +} diff --git a/packages/wasm/src/asset.ts b/packages/wasm/src/asset.ts index bf995e25f8..34ef33c349 100644 --- a/packages/wasm/src/asset.ts +++ b/packages/wasm/src/asset.ts @@ -1,12 +1,13 @@ import { AssetId } from '@penumbra-zone/protobuf/penumbra/core/asset/v1/asset_pb'; -import { get_asset_id_inner } from '../wasm/index.js'; +import { get_asset_id } from '../wasm/index.js'; /** * Converts a base denom name string to an `AssetId` with inner binary field * @param altBaseDenom an asset's base denomination name - * @returns the appropriate `AssetId` with binary inner field + * @returns the appropriate `AssetId` */ export const assetIdFromBaseDenom = (altBaseDenom: string) => { - const inner = get_asset_id_inner(new AssetId({ altBaseDenom }).toBinary()); - return new AssetId({ inner }); + const inputBytes = new AssetId({ altBaseDenom }).toBinary(); + const outputBytes = get_asset_id(inputBytes); + return AssetId.fromBinary(outputBytes); }; diff --git a/packages/wasm/src/view-server.test.ts b/packages/wasm/src/view-server.test.ts index 6a1d234707..379c0c38f3 100644 --- a/packages/wasm/src/view-server.test.ts +++ b/packages/wasm/src/view-server.test.ts @@ -30,7 +30,7 @@ describe('wasmViewServer', () => { }, }; - const vsServer = ViewServer.new(fullViewingKey.toBinary(), 719n, storedTree, idbConstants); + const vsServer = ViewServer.new(fullViewingKey.toBinary(), storedTree, idbConstants); await expect(vsServer).resolves.not.toThrow(); }); }); diff --git a/packages/wasm/src/view-server.ts b/packages/wasm/src/view-server.ts index 232ac86702..1259658230 100644 --- a/packages/wasm/src/view-server.ts +++ b/packages/wasm/src/view-server.ts @@ -20,7 +20,6 @@ declare global { interface ViewServerProps { fullViewingKey: FullViewingKey; - epochDuration: bigint; getStoredTree: () => Promise; idbConstants: IdbConstants; } @@ -36,24 +35,21 @@ export class ViewServer implements ViewServerInterface { private constructor( private wasmViewServer: WasmViewServer, public readonly fullViewingKey: FullViewingKey, - private readonly epochDuration: bigint, private readonly getStoredTree: () => Promise, private readonly idbConstants: IdbConstants, ) {} static async initialize({ fullViewingKey, - epochDuration, getStoredTree, idbConstants, }: ViewServerProps): Promise { const wvs = await WasmViewServer.new( fullViewingKey.toBinary(), - epochDuration, await getStoredTree(), idbConstants, ); - return new this(wvs, fullViewingKey, epochDuration, getStoredTree, idbConstants); + return new this(wvs, fullViewingKey, getStoredTree, idbConstants); } // Decrypts blocks with viewing key for notes, swaps, and updates revealed for user @@ -68,7 +64,6 @@ export class ViewServer implements ViewServerInterface { async resetTreeToStored() { this.wasmViewServer = await WasmViewServer.new( this.fullViewingKey.toBinary(), - this.epochDuration, await this.getStoredTree(), this.idbConstants, );