diff --git a/Cargo.lock b/Cargo.lock index 9a5ae9ea..d2af0fba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,17 +8,6 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.8", - "once_cell", - "version_check", -] - [[package]] name = "aho-corasick" version = "0.7.20" @@ -28,33 +17,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - -[[package]] -name = "arrayvec" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" - [[package]] name = "atty" version = "0.2.14" @@ -74,15 +36,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" - -[[package]] -name = "base64" -version = "0.13.1" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bindgen" @@ -113,29 +69,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitvec" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7774144344a4faa177370406a7ff5f1da24303817368584c6206c8303eb07848" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "blake2" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e37d16930f5459780f5621038b6382b9bb37c19016f39fb6b5808d831f174" -dependencies = [ - "crypto-mac", - "digest 0.9.0", - "opaque-debug", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -156,95 +89,43 @@ dependencies = [ [[package]] name = "borsh" -version = "0.9.3" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" +checksum = "a6362ed55def622cddc70a4746a68554d7b687713770de539e59a739b249f8ed" dependencies = [ "borsh-derive", - "hashbrown 0.11.2", + "cfg_aliases", ] [[package]] name = "borsh-derive" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" -dependencies = [ - "borsh-derive-internal", - "borsh-schema-derive-internal", - "proc-macro-crate 0.1.5", - "proc-macro2", - "syn", -] - -[[package]] -name = "borsh-derive-internal" -version = "0.9.3" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" +checksum = "c3ef8005764f53cd4dca619f5bf64cafd4664dada50ece25e4d81de54c80cc0b" dependencies = [ + "once_cell", + "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.79", + "syn_derive", ] [[package]] -name = "borsh-schema-derive-internal" -version = "0.9.3" +name = "bs58" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" dependencies = [ - "proc-macro2", - "quote", - "syn", + "tinyvec", ] -[[package]] -name = "bs58" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" - -[[package]] -name = "bumpalo" -version = "3.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" - -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - [[package]] name = "byteorder" version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "bytesize" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70" - -[[package]] -name = "c2-chacha" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d27dae93fe7b1e0424dc57179ac396908c26b035a87234809f5c4dfd1b47dc80" -dependencies = [ - "cipher", - "ppv-lite86", -] - -[[package]] -name = "cc" -version = "1.0.78" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d" - [[package]] name = "cexpr" version = "0.6.0" @@ -267,29 +148,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] -name = "chrono" -version = "0.4.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" -dependencies = [ - "iana-time-zone", - "js-sys", - "num-integer", - "num-traits", - "serde", - "time", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "cipher" -version = "0.2.5" +name = "cfg_aliases" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array", -] +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "clang-sys" @@ -311,7 +173,7 @@ dependencies = [ "atty", "bitflags", "clap_lex", - "indexmap", + "indexmap 1.9.2", "strsim", "termcolor", "textwrap", @@ -326,28 +188,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - [[package]] name = "cpufeatures" version = "0.2.5" @@ -357,12 +197,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - [[package]] name = "crypto-common" version = "0.1.6" @@ -373,16 +207,6 @@ dependencies = [ "typenum", ] -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "curve25519-dalek" version = "3.2.1" @@ -391,66 +215,43 @@ checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" dependencies = [ "byteorder", "digest 0.9.0", - "rand_core 0.5.1", + "rand_core", "subtle", "zeroize", ] [[package]] -name = "cxx" -version = "1.0.86" +name = "darling" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51d1075c37807dcf850c379432f0df05ba52cc30f279c5cfc43cc221ce7f8579" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", + "darling_core", + "darling_macro", ] [[package]] -name = "cxx-build" -version = "1.0.86" +name = "darling_core" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5044281f61b27bc598f2f6647d480aed48d2bf52d6eb0b627d84c0361b17aa70" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ - "cc", - "codespan-reporting", - "once_cell", + "fnv", + "ident_case", "proc-macro2", "quote", - "scratch", - "syn", + "syn 2.0.79", ] [[package]] -name = "cxxbridge-flags" -version = "1.0.86" +name = "darling_macro" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61b50bc93ba22c27b0d31128d2d130a0a6b3d267ae27ef7e4fae2167dfe8781c" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e61fda7e62115119469c7b3591fd913ecca96fb766cfd3f2e2502ab7bc87a5" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ - "proc-macro2", + "darling_core", "quote", - "syn", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn", + "syn 2.0.79", ] [[package]] @@ -472,18 +273,6 @@ dependencies = [ "crypto-common", ] -[[package]] -name = "dyn-clone" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9b0705efd4599c15a38151f4721f7bc388306f61084d3bfd50bd07fbca5cb60" - -[[package]] -name = "easy-ext" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53aff6fdc1b181225acdcb5b14c47106726fd8e486707315b1b138baed68ee31" - [[package]] name = "ed25519" version = "1.5.2" @@ -501,7 +290,7 @@ checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek", "ed25519", - "rand 0.7.3", + "rand", "serde", "sha2 0.9.9", "zeroize", @@ -527,22 +316,16 @@ dependencies = [ ] [[package]] -name = "fixed-hash" -version = "0.7.0" +name = "equivalent" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcf0ed7fe52a17a03854ec54a9f76d6d84508d1c0e66bc1793301c73fc8493c" -dependencies = [ - "byteorder", - "rand 0.8.5", - "rustc-hex", - "static_assertions", -] +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] -name = "funty" -version = "1.1.0" +name = "fnv" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "generic-array" @@ -562,18 +345,7 @@ checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if 1.0.0", "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasi", ] [[package]] @@ -584,24 +356,21 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hashbrown" -version = "0.12.3" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" [[package]] name = "heck" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" @@ -625,48 +394,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] -name = "iana-time-zone" -version = "0.1.53" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "winapi", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" -dependencies = [ - "cxx", - "cxx-build", -] - -[[package]] -name = "impl-codec" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "161ebdfec3c8e3b52bf61c4f3550a1eea4f9579d10dc1b936f3171ebdcd6c443" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" +name = "ident_case" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" @@ -679,37 +410,26 @@ dependencies = [ ] [[package]] -name = "itoa" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" - -[[package]] -name = "js-sys" -version = "0.3.60" +name = "indexmap" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ - "wasm-bindgen", + "equivalent", + "hashbrown 0.15.0", ] [[package]] -name = "keccak" -version = "0.1.3" +name = "itoa" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" -dependencies = [ - "cpufeatures", -] +checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -dependencies = [ - "spin", -] [[package]] name = "lazycell" @@ -733,15 +453,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "link-cplusplus" -version = "1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5" -dependencies = [ - "cc", -] - [[package]] name = "log" version = "0.4.17" @@ -769,23 +480,11 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "near-abi" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "885db39b08518fa700b73fa2214e8adbbfba316ba82dd510f50519173eadaf73" -dependencies = [ - "borsh", - "schemars", - "semver", - "serde", -] - [[package]] name = "near-account-id" -version = "0.14.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d258582a1878e6db67400b0504a5099db85718d22c2e07f747fe1706ae7150" +checksum = "35cbb989542587b47205e608324ddd391f0cee1c22b4b64ae49f458334b95907" dependencies = [ "borsh", "serde", @@ -793,243 +492,91 @@ dependencies = [ [[package]] name = "near-contract-standards" -version = "4.1.1" +version = "5.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bacc932e79b26472797adfb21689294b6f90960d1570daaf1e0b682b59fcb35" +checksum = "a3b985c4df43237b6ae533a6451cfa13de1f12f79f7d6254ba376f0ccd017286" dependencies = [ "near-sdk", - "schemars", - "serde", - "serde_json", -] - -[[package]] -name = "near-crypto" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e75673d69fd7365508f3d32483669fe45b03bfb34e4d9363e90adae9dfb416c" -dependencies = [ - "arrayref", - "blake2", - "borsh", - "bs58", - "c2-chacha", - "curve25519-dalek", - "derive_more", - "ed25519-dalek", - "near-account-id", - "once_cell", - "parity-secp256k1", - "primitive-types", - "rand 0.7.3", - "rand_core 0.5.1", - "serde", - "serde_json", - "subtle", - "thiserror", ] [[package]] -name = "near-primitives" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad1a9a1640539c81f065425c31bffcfbf6b31ef1aeaade59ce905f5df6ac860" -dependencies = [ - "borsh", - "byteorder", - "bytesize", - "chrono", - "derive_more", - "easy-ext", - "hex", - "near-crypto", - "near-primitives-core", - "near-rpc-error-macro", - "near-vm-errors", - "num-rational", - "once_cell", - "primitive-types", - "rand 0.7.3", - "reed-solomon-erasure", - "serde", - "serde_json", - "smart-default", - "strum", - "thiserror", -] - -[[package]] -name = "near-primitives-core" -version = "0.14.0" +name = "near-gas" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d508f0fc340f6461e4e256417685720d3c4c00bb5a939b105160e49137caba" +checksum = "180edcc7dc2fac41f93570d0c7b759c1b6d492f6ad093d749d644a40b4310a97" dependencies = [ - "base64 0.11.0", "borsh", - "bs58", - "derive_more", - "near-account-id", - "num-rational", - "serde", - "sha2 0.10.6", - "strum", -] - -[[package]] -name = "near-rpc-error-core" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ee0b41c75ef859c193a8ff1dadfa0c8207bc0ac447cc22259721ad769a1408" -dependencies = [ - "quote", - "serde", - "syn", -] - -[[package]] -name = "near-rpc-error-macro" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e837bd4bacd807073ec5ceb85708da7f721b46a4c2a978de86027fb0034ce31" -dependencies = [ - "near-rpc-error-core", "serde", - "syn", ] [[package]] name = "near-sdk" -version = "4.1.1" +version = "5.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15eb3de2defe3626260cc209a6cdb985c6b27b0bd4619fad97dcfae002c3c5bd" -dependencies = [ - "base64 0.13.1", - "borsh", - "bs58", - "near-abi", - "near-crypto", - "near-primitives", - "near-primitives-core", - "near-sdk-macros", - "near-sys", - "near-vm-logic", - "once_cell", - "schemars", - "serde", - "serde_json", - "wee_alloc", -] - -[[package]] -name = "near-sdk-macros" -version = "4.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4907affc9f5ed559456509188ff0024f1f2099c0830e6bdb66eb61d5b75912c0" -dependencies = [ - "Inflector", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "near-sys" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e307313276eaeced2ca95740b5639e1f3125b7c97f0a1151809d105f1aa8c6d3" - -[[package]] -name = "near-vm-errors" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0da466a30f0446639cbd788c30865086fac3e8dcb07a79e51d2b0775ed4261e" -dependencies = [ - "borsh", - "near-account-id", - "near-rpc-error-macro", - "serde", -] - -[[package]] -name = "near-vm-logic" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b534828419bacbf1f7b11ef7b00420f248c548c485d3f0cfda8bb6931152f2" -dependencies = [ - "base64 0.13.1", - "borsh", - "bs58", - "byteorder", - "near-account-id", - "near-crypto", - "near-primitives", - "near-primitives-core", - "near-vm-errors", - "ripemd", - "serde", - "sha2 0.10.6", - "sha3", - "zeropool-bn", -] - -[[package]] -name = "nom" -version = "7.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5507769c4919c998e69e49c839d9dc6e693ede4cc4290d6ad8b41d4f09c548c" -dependencies = [ - "memchr", - "minimal-lexical", +checksum = "4e296b02c85539c16659e171242d6c6bbea87eec7c9ef860d8dfd3fb3168a18a" +dependencies = [ + "base64", + "borsh", + "bs58", + "near-account-id", + "near-gas", + "near-sdk-macros", + "near-sys", + "near-token", + "once_cell", + "serde", + "serde_json", + "wee_alloc", ] [[package]] -name = "num-bigint" -version = "0.3.3" +name = "near-sdk-macros" +version = "5.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" +checksum = "0adc79466aa556f56a995c0db34a933b32597ab92bbb0e526597118899c8bcaf" dependencies = [ - "autocfg", - "num-integer", - "num-traits", + "Inflector", + "darling", + "proc-macro2", + "quote", + "serde", + "serde_json", + "strum", + "strum_macros", + "syn 2.0.79", ] [[package]] -name = "num-integer" -version = "0.1.45" +name = "near-sys" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] +checksum = "dbf4ca5c805cb78700e10e43484902d8da05f25788db277999d209568aaf4c8e" [[package]] -name = "num-rational" -version = "0.3.2" +name = "near-token" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12ac428b1cb17fce6f731001d307d351ec70a6d202fc2e60f7d4c5e42d8f4f07" +checksum = "cd3e60aa26a74dc514b1b6408fdd06cefe2eb0ff029020956c1c6517594048fd" dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", + "borsh", "serde", ] [[package]] -name = "num-traits" -version = "0.2.15" +name = "nom" +version = "7.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "e5507769c4919c998e69e49c839d9dc6e693ede4cc4290d6ad8b41d4f09c548c" dependencies = [ - "autocfg", + "memchr", + "minimal-lexical", ] [[package]] name = "once_cell" -version = "1.17.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "opaque-debug" @@ -1043,44 +590,6 @@ version = "6.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" -[[package]] -name = "parity-scale-codec" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "373b1a4c1338d9cd3d1fa53b3a11bdab5ab6bd80a20f7f7becd76953ae2be909" -dependencies = [ - "arrayvec 0.7.2", - "bitvec", - "byte-slice-cast", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1557010476e0595c9b568d16dcfb81b93cdeb157612726f5170d31aa707bed27" -dependencies = [ - "proc-macro-crate 1.2.1", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "parity-secp256k1" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fca4f82fccae37e8bbdaeb949a4a218a1bbc485d11598f193d2a908042e5fc1" -dependencies = [ - "arrayvec 0.5.2", - "cc", - "cfg-if 0.1.10", - "rand 0.7.3", -] - [[package]] name = "peeking_take_while" version = "0.1.2" @@ -1094,41 +603,42 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] -name = "primitive-types" -version = "0.10.1" +name = "proc-macro-crate" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05e4722c697a58a99d5d06a08c30821d7c082a4632198de1eaa5a6c22ef42373" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ - "fixed-hash", - "impl-codec", - "uint", + "toml_edit", ] [[package]] -name = "proc-macro-crate" -version = "0.1.5" +name = "proc-macro-error" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ - "toml", + "proc-macro-error-attr", + "proc-macro2", + "quote", + "version_check", ] [[package]] -name = "proc-macro-crate" -version = "1.2.1" +name = "proc-macro-error-attr" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "once_cell", - "thiserror", - "toml", + "proc-macro2", + "quote", + "version_check", ] [[package]] name = "proc-macro2" -version = "1.0.49" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -1203,43 +713,26 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.23" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" - [[package]] name = "rand" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ - "getrandom 0.1.16", + "getrandom", "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", "rand_hc", ] -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - [[package]] name = "rand_chacha" version = "0.2.2" @@ -1247,17 +740,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", + "rand_core", ] [[package]] @@ -1266,16 +749,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.8", + "getrandom", ] [[package]] @@ -1284,16 +758,7 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "reed-solomon-erasure" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a415a013dd7c5d4221382329a5a3482566da675737494935cbbbcdec04662f9d" -dependencies = [ - "smallvec", + "rand_core", ] [[package]] @@ -1313,36 +778,12 @@ version = "0.6.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" -[[package]] -name = "ripemd" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" -dependencies = [ - "digest 0.10.6", -] - [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - [[package]] name = "rustversion" version = "1.0.11" @@ -1355,42 +796,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" -[[package]] -name = "schemars" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307" -dependencies = [ - "dyn-clone", - "schemars_derive", - "serde", - "serde_json", -] - -[[package]] -name = "schemars_derive" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn", -] - -[[package]] -name = "scratch" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2" - -[[package]] -name = "semver" -version = "1.0.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" - [[package]] name = "serde" version = "1.0.152" @@ -1408,18 +813,7 @@ checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" dependencies = [ "proc-macro2", "quote", - "syn", -] - -[[package]] -name = "serde_derive_internals" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" -dependencies = [ - "proc-macro2", - "quote", - "syn", + "syn 1.0.107", ] [[package]] @@ -1457,16 +851,6 @@ dependencies = [ "digest 0.10.6", ] -[[package]] -name = "sha3" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" -dependencies = [ - "digest 0.10.6", - "keccak", -] - [[package]] name = "shlex" version = "1.1.0" @@ -1479,35 +863,6 @@ version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -[[package]] -name = "smallvec" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" - -[[package]] -name = "smart-default" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[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.10.0" @@ -1516,24 +871,21 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" -version = "0.24.1" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" -dependencies = [ - "strum_macros", -] +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" [[package]] name = "strum_macros" -version = "0.24.3" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ "heck", "proc-macro2", "quote", "rustversion", - "syn", + "syn 2.0.79", ] [[package]] @@ -1553,6 +905,29 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "synstructure" version = "0.12.6" @@ -1561,16 +936,10 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", "unicode-xid", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "termcolor" version = "1.1.3" @@ -1587,43 +956,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" [[package]] -name = "thiserror" -version = "1.0.38" +name = "tinyvec" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ - "thiserror-impl", + "tinyvec_macros", ] [[package]] -name = "thiserror-impl" -version = "1.0.38" +name = "tinyvec_macros" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] -name = "time" -version = "0.1.45" +name = "toml_datetime" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" -dependencies = [ - "libc", - "wasi 0.10.0+wasi-snapshot-preview1", - "winapi", -] +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] -name = "toml" -version = "0.5.10" +name = "toml_edit" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1333c76748e868a4d9d1017b5ab53171dfd095f70c712fdb4653a406547f598f" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "serde", + "indexmap 2.6.0", + "toml_datetime", + "winnow", ] [[package]] @@ -1632,30 +993,12 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - [[package]] name = "unicode-ident" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" -[[package]] -name = "unicode-width" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" - [[package]] name = "unicode-xid" version = "0.2.4" @@ -1674,72 +1017,6 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" -[[package]] -name = "wasi" -version = "0.10.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" -dependencies = [ - "cfg-if 1.0.0", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" - [[package]] name = "wee_alloc" version = "0.4.5" @@ -1795,10 +1072,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "wyz" -version = "0.2.0" +name = "winnow" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] [[package]] name = "zeroize" @@ -1817,20 +1097,6 @@ checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.107", "synstructure", ] - -[[package]] -name = "zeropool-bn" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e61de68ede9ffdd69c01664f65a178c5188b73f78faa21f0936016a888ff7c" -dependencies = [ - "borsh", - "byteorder", - "crunchy", - "lazy_static", - "rand 0.8.5", - "rustc-hex", -] diff --git a/Cargo.toml b/Cargo.toml index ec60ba72..1331e3c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ strip="symbols" strip = false [dependencies] -near-sdk = "4.0.0" +near-sdk = "5.5.0" ed25519-dalek = "1.0.1" sha2 = "0.10.6" hex = "0.4.3" diff --git a/README.md b/README.md index b81f3003..02a1c632 100644 --- a/README.md +++ b/README.md @@ -1,69 +1,44 @@ -Rust WebAssembly smart contract for NEAR with Javascript runtime +Rust WebAssembly smart contracts for NEAR with Javascript runtime ================================================================ -This is a Proof of Concept of embedding QuickJS with https://github.com/near/near-sdk-rs for being able to execute custom JavaScript code inside a smart contract written in Rust. +This project shows compiling and embedding [QuickJS](https://bellard.org/quickjs/) with https://github.com/near/near-sdk-rs for being able to execute custom JavaScript code inside a smart contract written in Rust. It contains examples of standard contracts like NFT and Fungible token, with JavaScript customization layers on top. There are also examples of a [web4](https://github.com/vgrichina/web4) contract. -First of all, have a look at the videos where I present the project +Check out the youtube playlist with videos showing the project: https://www.youtube.com/watch?v=JBZEr__pid0&list=PLv5wm4YuO4IwVNrSsYxeqKrtQZYRML03Z -The QuickJS runtime is compiled from https://github.com/petersalomonsen/quickjs-wasm-near +Also check out the [end-to-end](#end-to-end-tests-using-near-workspaces) tests for how to use the contracts from this project. -The contract has two functions: -- `run_script` accepting javascript as text for compiling on the fly. -- `run_bytecode` for running JS pre-compiled into the QuickJS bytecode format. Send the pre-compiled bytecode as a base64 string. See https://github.com/petersalomonsen/quickjs-wasm-near/blob/master/web/compiler/compile.spec.js for examples on compiling JS to QuickJS bytecode. -- `submit_script` for submitting and storing JavaScript and running later -- `run_script_for_account` run script stored by account, returns an integer returned by the script -- `run_script_for_account_no_return` run script stored by account, does not return anything unless the script calls `env.value_return`. +# Devcontainer / github actions -For building and deploying the contract have a look at [buildanddeploy.sh](./buildanddeploy.sh). +All the pre-requisities for getting the project up and running can be found in the [.devcontainer](./.devcontainer) folder, which will be automaticall set up if using a github codespace. -# Calling the deployed contract +The github actions also shows how to build and run all the examples. -Test running javascript as text: +# Architecture / structure -``` -near call dev-1650299983789-21350249865305 --accountId=psalomo.testnet run_script '{"script": "(function() {return 5*33+22;})();" }' -``` +QuickJS is built with [Emscripten](https://emscripten.org/) to a static library. Another C library, which can be found in the [quickjslib](./quickjslib/) folder, is providing a simplified interface to QuickJS, which is then linked to the Rust code along with other relevant static libraries from the Emscripten distribution ( such as the C standard library, allocator, WASI etc. ). -Here are some examples from a deployment to testnet account: `dev-1650299983789-21350249865305` +See the entire build process in [build.rs](./build.rs). -Test running bytecode ( which is compiled from `JSON.parse('{"a": 222}').a+3`): +In the Rust part, there are contract implementations exposing functions for submitting JavaScript code. Both in the internal bytecode format of QuickJS, and pure JS source code. -``` -near call dev-1650299983789-21350249865305 --accountId=psalomo.testnet run_bytecode '{"bytecodebase64": "AgQKcGFyc2UUeyJhIjogMjIyfQJhGDxldmFsc291cmNlPg4ABgCgAQABAAMAABsBogEAAAA4mwAAAELeAAAABN8AAAAkAQBB4AAAALidzSjCAwEA" }' -``` -# Testing +# Unit tests running in WebAssembly -Since we are linking with C libraries it is more practical to have Wasm pre-builds and run tests in a Wasm target rather than having builds for native platforms. Run the test using wasi like this: +While it's common and more straightforward for NEAR smart contracts and many other Rust WebAssembly projects, to have their unit tests compiled to the native platform, this project runs the unit test in a WebAssembly runtime. The reason for this is because of the static libraries compiled from C, which are already targeting Wasm. One limitation when running tests inside the Wasm runtime is that you cannot catch panics, and so testing the error messages has to be done in the end-2-end tests -`RUSTFLAGS='-C link-args=--initial-memory=67108864' cargo wasi test -- --show-output --nocapture` +# End-to-end tests using near-workspaces -Unfortunately testing with wasi has some limitations today. Especially panic does not support unwinding in Wasm, and so tests that should panic needs to be performed in e2e test scenarios. Read more here: https://bytecodealliance.github.io/cargo-wasi/testing.html +In the [e2e](./e2e/) folder and also within the [examples](./examples/) folders there are test files that demonstrates deployment and interaction with the contract using [near-workspaces-js](https://github.com/near/near-workspaces-js). All these tests are being run as part of the github actions pipeline, but you can also look at this for examples on how to use the contracts produced in this project. -# Web4 and a WebAssembly Music showcase +# Local JS test environment -The web application in the [web4](./web4) folder is a vanilla JS Web Component application for uploading music written in Javascript and also playing it, and accepting parameters in JSON for configuring the playback. It also contains functionality for exporting to WAV. See the video playlist above for a demo. - -The music to be played back is fetched in a view method call, and for controlling who can access this view method the JSON parameters payload is signed using the callers private key. The contract will then verify the signature according to the callers public key stored in a transaction before the view method call. - -The web application is packaged into a single HTML file using rollup, where the final bundle is embedded into the Rust sources encoded as a base64 string. - -# TODO - -- **DONE** Implement (mock) WASI methods in a linkable library so that WAT file does not have to be edited manually -- **DONE** Integration/Unit testing support for Wasm32 target ( which is not supported with near-sdk-rs, see https://github.com/near/near-sdk-rs/issues/467 ) - - **DONE** Running tests - - **DONE** Displaying errors (needs a panic hook) - - **DONE** Minimum NEAR mock env -- Local simulation in browser/node Wasm runtime with mocked NEAR env in JavaScript -- **DONE** End to End tests (testnet) -- **DONE** Expose some NEAR environment functions to JS runtime - - **DONE** `env.value_return` - - **DONE** `env.input` (no need to load into register first) - - **DONE** `env.signer_account_id` (no need to load into register first) -- **DONE** Web4 hosting showcase -- **DONE** NFT implementation configurable with JavaScript -- Fungible Token example +A simple mocking of NEAR interfaces for simulation of a smart contract directly in NodeJS or in the browser can be found in [localjstestenv](./localjstestenv/README.md). +# Example contracts +- [NFT](./examples/nft/README.md) - The standard NFT contract, customizable with JavaScript +- [Fungible Token](./examples/fungibletoken/README.md) - The standard FT contract, customizable with JavaScript +- [Minimum Web4](./examples/minimumweb4/README.md) - Implement the web4 interface in JavaScript to serve a website from the smart contract +- "[PureJS](./examples/purejs/README.md)" - Precompile the JS bytecode into the contract, and provide direct exports to the JS functions. +- [Web4 and a WebAssembly Music showcase](./web4/README.md) - JavaScript from WebAssembly Music running in the smart contract diff --git a/examples/fungibletoken/Cargo.toml b/examples/fungibletoken/Cargo.toml index bdd97eaa..e012bf0e 100644 --- a/examples/fungibletoken/Cargo.toml +++ b/examples/fungibletoken/Cargo.toml @@ -9,12 +9,12 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -near-sdk = "4.0.0" +near-sdk = "5.5.0" lazy_static = "1.4.0" ed25519-dalek = "1.0.1" quickjs-rust-near = { path = "../../", features=["library"] } quickjs-rust-near-testenv = { path = "../../testenv" } -near-contract-standards = "4.1.1" +near-contract-standards = "5.5.0" [build-dependencies] bindgen = "0.60.1" diff --git a/examples/fungibletoken/src/lib.rs b/examples/fungibletoken/src/lib.rs index cbc2d6aa..ee1abde9 100644 --- a/examples/fungibletoken/src/lib.rs +++ b/examples/fungibletoken/src/lib.rs @@ -21,10 +21,12 @@ use near_contract_standards::fungible_token::metadata::{ FungibleTokenMetadata, FungibleTokenMetadataProvider, FT_METADATA_SPEC, }; use near_contract_standards::fungible_token::FungibleToken; -use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; +use near_contract_standards::storage_management::{StorageBalance, StorageBalanceBounds}; +use near_sdk::borsh::{BorshDeserialize, BorshSerialize}; use near_sdk::collections::LazyOption; use near_sdk::json_types::U128; -use near_sdk::{env, log, near_bindgen, AccountId, Balance, PanicOnDefault, PromiseOrValue}; +use near_sdk::near; +use near_sdk::{env, log, near_bindgen, AccountId, NearToken, PanicOnDefault, PromiseOrValue}; use quickjs_rust_near::jslib::{ add_function_to_js, arg_to_str, compile_js, js_call_function, load_js_bytecode, to_js_string, }; @@ -33,6 +35,7 @@ const JS_BYTECODE_STORAGE_KEY: &[u8] = b"JS"; #[near_bindgen] #[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)] +#[borsh(crate = "near_sdk::borsh")] pub struct Contract { token: FungibleToken, metadata: LazyOption, @@ -78,7 +81,7 @@ impl Contract { this.token.internal_deposit(&owner_id, total_supply.into()); near_contract_standards::fungible_token::events::FtMint { owner_id: &owner_id, - amount: &total_supply, + amount: total_supply, memo: Some("Initial tokens supply is minted"), } .emit(); @@ -134,9 +137,8 @@ impl Contract { add_function_to_js( "ft_balance_of", move |ctx: i32, _this_val: i64, _argc: i32, argv: i32| -> i64 { - let balance = (*CONTRACT_REF) - .ft_balance_of(AccountId::new_unchecked(arg_to_str(ctx, 0, argv))) - .0; + let account_id = arg_to_str(ctx, 0, argv).parse().unwrap(); + let balance = (*CONTRACT_REF).ft_balance_of(account_id).0; return to_js_string(ctx, balance.to_string()); }, 1, @@ -145,13 +147,27 @@ impl Contract { add_function_to_js( "ft_transfer", |ctx: i32, _this_val: i64, _argc: i32, argv: i32| -> i64 { - let receiver_id = AccountId::new_unchecked(arg_to_str(ctx, 0, argv)); + let receiver_id = arg_to_str(ctx, 0, argv).parse().unwrap(); let amount: U128 = U128(arg_to_str(ctx, 1, argv).parse::().unwrap()); (*CONTRACT_REF).ft_transfer(receiver_id, amount, None); return 0; }, 2, ); + + add_function_to_js( + "ft_transfer_internal", + |ctx: i32, _this_val: i64, _argc: i32, argv: i32| -> i64 { + let sender_id = arg_to_str(ctx, 0, argv).parse().unwrap(); + let receiver_id = arg_to_str(ctx, 1, argv).parse().unwrap(); + let amount: U128 = U128(arg_to_str(ctx, 2, argv).parse::().unwrap()); + (*CONTRACT_REF) + .token + .internal_transfer(&sender_id, &receiver_id, amount.0, None); + return 0; + }, + 2, + ); } #[payable] @@ -172,17 +188,52 @@ impl Contract { self.store_js_bytecode(compile_js(javascript, Some("main.js".to_string()))); } - fn on_account_closed(&mut self, account_id: AccountId, balance: Balance) { + fn on_account_closed(&mut self, account_id: AccountId, balance: u128) { log!("Closed @{} with {}", account_id, balance); } - fn on_tokens_burned(&mut self, account_id: AccountId, amount: Balance) { + fn on_tokens_burned(&mut self, account_id: AccountId, amount: u128) { log!("Account @{} burned {}", account_id, amount); } } near_contract_standards::impl_fungible_token_core!(Contract, token, on_tokens_burned); -near_contract_standards::impl_fungible_token_storage!(Contract, token, on_account_closed); + +#[near] +impl near_contract_standards::storage_management::StorageManagement for Contract { + #[payable] + fn storage_deposit( + &mut self, + account_id: Option, + registration_only: Option, + ) -> StorageBalance { + self.token.storage_deposit(account_id, registration_only) + } + + #[payable] + fn storage_withdraw(&mut self, amount: Option) -> StorageBalance { + self.token.storage_withdraw(amount) + } + + #[payable] + fn storage_unregister(&mut self, force: Option) -> bool { + #[allow(unused_variables)] + if let Some((account_id, balance)) = self.token.internal_storage_unregister(force) { + self.on_account_closed(account_id, balance); + true + } else { + false + } + } + + fn storage_balance_bounds(&self) -> StorageBalanceBounds { + self.token.storage_balance_bounds() + } + + fn storage_balance_of(&self, account_id: AccountId) -> Option { + self.token.storage_balance_of(account_id) + } +} #[near_bindgen] impl FungibleTokenMetadataProvider for Contract { @@ -193,16 +244,15 @@ impl FungibleTokenMetadataProvider for Contract { #[cfg(test)] mod tests { - use near_sdk::Balance; - use super::*; + use near_contract_standards::storage_management::StorageManagement; use quickjs_rust_near_testenv::testenv::{ alice, assert_latest_return_value_string_eq, bob, set_attached_deposit, set_block_timestamp, set_current_account_id, set_input, set_predecessor_account_id, setup_test_env, }; - const TOTAL_SUPPLY: Balance = 1_000_000_000_000_000; + const TOTAL_SUPPLY: u128 = 1_000_000_000_000_000; #[test] fn test_new() { @@ -225,7 +275,7 @@ mod tests { contract.storage_deposit(Some(alice()), Some(true)); set_predecessor_account_id(bob()); - set_attached_deposit(1); + set_attached_deposit(NearToken::from_yoctonear(1)); let transfer_amount = TOTAL_SUPPLY / 3; contract.ft_transfer(alice(), transfer_amount.into(), None); @@ -300,7 +350,7 @@ mod tests { contract.storage_deposit(Some(alice()), Some(true)); set_predecessor_account_id(bob()); - set_attached_deposit(1); + set_attached_deposit(NearToken::from_yoctonear(1)); contract.call_js_func("transfer_2_000_to_alice".to_string()); assert_eq!(contract.ft_balance_of(bob()).0, TOTAL_SUPPLY - 2_000); @@ -341,7 +391,7 @@ mod tests { contract.storage_deposit(Some(alice()), Some(true)); set_predecessor_account_id(bob()); - set_attached_deposit(1); + set_attached_deposit(NearToken::from_yoctonear(1)); set_block_timestamp(1234_000_000); contract.call_js_func("transfer_2_000_to_alice".to_string()); @@ -359,4 +409,36 @@ mod tests { assert_eq!(contract.ft_balance_of(bob()).0, TOTAL_SUPPLY - 1_000); assert_eq!(contract.ft_balance_of(alice()).0, 1_000); } + + #[test] + fn test_js_transfer_internal_without_attached_neartokens() { + setup_test_env(); + + let mut contract = Contract::new_default_meta(bob().into(), TOTAL_SUPPLY.into()); + set_current_account_id(bob()); + set_predecessor_account_id(bob()); + contract.post_javascript( + " + export function transfer_2_000_from_bob_to_alice() { + const amount = 2_000n; + env.ft_transfer_internal('bob.near','alice.near', amount.toString()); + env.value_return(transfer_id); + }" + .to_string(), + ); + + set_predecessor_account_id(alice()); + set_attached_deposit(contract.storage_balance_bounds().min.into()); + + // Paying for account registration, aka storage deposit + contract.storage_deposit(Some(alice()), Some(true)); + + set_predecessor_account_id(bob()); + set_attached_deposit(NearToken::from_yoctonear(0)); + + set_block_timestamp(1234_000_000); + contract.call_js_func("transfer_2_000_from_bob_to_alice".to_string()); + assert_eq!(contract.ft_balance_of(bob()).0, TOTAL_SUPPLY - 2_000); + assert_eq!(contract.ft_balance_of(alice()).0, 2_000); + } } diff --git a/examples/minimumweb4/Cargo.toml b/examples/minimumweb4/Cargo.toml index 8b7a4eae..bfa7b20b 100644 --- a/examples/minimumweb4/Cargo.toml +++ b/examples/minimumweb4/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -near-sdk = "4.1.1" +near-sdk = "5.5.0" quickjs-rust-near = { path = "../../", features=["library"] } quickjs-rust-near-testenv = { path = "../../testenv" } diff --git a/examples/minimumweb4/README.md b/examples/minimumweb4/README.md new file mode 100644 index 00000000..9e608352 --- /dev/null +++ b/examples/minimumweb4/README.md @@ -0,0 +1,23 @@ +Web4 +==== + +This contract allows you to create a [web4](https://github.com/vgrichina/web4) contract where you can implement the Web4 interfaces in Javascript. + +Example: + +```javascript +export function web4_get() { + const request = JSON.parse(env.input()).request; + + let response; + + if (request.path == '/index.html') { + response = { + contentType: "text/html; charset=UTF-8", + body: env.base64_encode("Hello") + }; + } + env.value_return(JSON.stringify(response)); +} +``` + diff --git a/examples/minimumweb4/src/lib.rs b/examples/minimumweb4/src/lib.rs index 8462bce8..d25efe51 100644 --- a/examples/minimumweb4/src/lib.rs +++ b/examples/minimumweb4/src/lib.rs @@ -10,6 +10,7 @@ const JS_CONTENT_RESOURCE_PREFIX: &str = "JSC_"; #[near_bindgen] #[derive(BorshDeserialize, BorshSerialize, Default)] +#[borsh(crate="near_sdk::borsh")] pub struct Contract {} static mut CONTRACT_REF: *const Contract = 0 as *const Contract; diff --git a/examples/nft/Cargo.toml b/examples/nft/Cargo.toml index e1a5ea7e..a77e344b 100644 --- a/examples/nft/Cargo.toml +++ b/examples/nft/Cargo.toml @@ -9,12 +9,12 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -near-sdk = "4.0.0" +near-sdk = "5.5.0" lazy_static = "1.4.0" ed25519-dalek = "1.0.1" quickjs-rust-near = { path = "../../", features=["library"] } quickjs-rust-near-testenv = { path = "../../testenv" } -near-contract-standards = "4.1.1" +near-contract-standards = "5.5.0" [build-dependencies] bindgen = "0.60.1" diff --git a/examples/nft/src/lib.rs b/examples/nft/src/lib.rs index b4de7f67..77c17e6e 100644 --- a/examples/nft/src/lib.rs +++ b/examples/nft/src/lib.rs @@ -5,9 +5,9 @@ use near_contract_standards::non_fungible_token::metadata::{ }; use near_contract_standards::non_fungible_token::{NonFungibleToken, Token, TokenId}; -use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; +use near_sdk::borsh::{BorshDeserialize, BorshSerialize}; use near_sdk::json_types::U128; -use near_sdk::{ +use near_sdk::{near, assert_one_yocto, base64, env, near_bindgen, serde_json, AccountId, BorshStorageKey, PanicOnDefault, Promise, PromiseOrValue, }; @@ -23,6 +23,7 @@ const JS_BYTECODE_STORAGE_KEY: &[u8] = b"JS"; const JS_CONTENT_RESOURCE_PREFIX: &str = "JSC_"; #[derive(BorshSerialize, BorshStorageKey)] +#[borsh(crate="near_sdk::borsh")] enum StorageKey { NonFungibleToken, TokenMetadata, @@ -32,6 +33,7 @@ enum StorageKey { #[near_bindgen] #[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)] +#[borsh(crate="near_sdk::borsh")] pub struct Contract { tokens: NonFungibleToken, } @@ -75,7 +77,7 @@ impl Contract { "nft_supply_for_owner", |ctx: i32, _this_val: i64, _argc: i32, argv: i32| -> i64 { return (*CONTRACT_REF) - .nft_supply_for_owner(AccountId::new_unchecked(arg_to_str(ctx, 0, argv))) + .nft_supply_for_owner(arg_to_str(ctx, 0, argv).parse().unwrap()) .0 as i64; }, 1, @@ -310,6 +312,7 @@ mod tests { use super::*; + use near_sdk::NearToken; use quickjs_rust_near::jslib::compile_js; use quickjs_rust_near_testenv::testenv::{ alice, assert_latest_return_value_contains, assert_latest_return_value_string_eq, bob, @@ -344,7 +347,7 @@ mod tests { setup_test_env(); set_current_account_id(bob()); set_predecessor_account_id(bob()); - set_attached_deposit(1640000000000000000000); + set_attached_deposit(NearToken::from_yoctonear(1640000000000000000000)); let mut contract = Contract::new(); contract.post_javascript( @@ -367,7 +370,7 @@ mod tests { contract.call_js_func("get_supply_for_bob".to_string()); assert_latest_return_value_string_eq("bob supply: 0".to_string()); - set_attached_deposit(1900000000000000000000); + set_attached_deposit(NearToken::from_yoctonear(1900000000000000000000)); contract.nft_mint("abc".to_string(), bob()); assert_eq!(contract.nft_supply_for_owner(bob()).0, 1 as u128); @@ -404,7 +407,7 @@ mod tests { ); set_signer_account_id(alice()); - set_attached_deposit(10440000000000000000000); + set_attached_deposit(NearToken::from_yoctonear(10440000000000000000000)); contract.nft_mint("2222".to_string(), alice()); @@ -471,7 +474,7 @@ mod tests { assert_eq!( contract - .nft_supply_for_owner(AccountId::new_unchecked("unknown.near".to_string())) + .nft_supply_for_owner("unknown.near".parse().unwrap()) .0, 0 as u128 ); @@ -512,7 +515,7 @@ mod tests { setup_test_env(); set_current_account_id(carol()); set_predecessor_account_id(carol()); - set_attached_deposit(1900000000000000000000); + set_attached_deposit(NearToken::from_yoctonear(1900000000000000000000)); let mut contract = Contract::new(); contract.post_javascript( @@ -571,7 +574,7 @@ mod tests { .to_string(), ); - set_attached_deposit(1960000000000000000000); + set_attached_deposit(NearToken::from_yoctonear(1960000000000000000000)); let token_id = "554433".to_string(); contract.nft_mint(token_id.to_owned(), bob()); @@ -619,7 +622,7 @@ mod tests { .to_string(), ); - set_attached_deposit(2000000000000000000000); + set_attached_deposit(NearToken::from_yoctonear(2000000000000000000000)); let token_id = "5544332".to_string(); contract.nft_mint(token_id.to_owned(), alice()); @@ -706,7 +709,7 @@ mod tests { " .to_string(), ); - set_attached_deposit(1860000000000000000000); + set_attached_deposit(NearToken::from_yoctonear(1860000000000000000000)); contract.nft_mint("1".to_string(), bob()); contract.call_js_func("get_nft_token".to_string()); @@ -737,7 +740,7 @@ mod tests { .to_string(), ); - set_attached_deposit(2080000000000000000000); + set_attached_deposit(NearToken::from_yoctonear(2080000000000000000000)); let token_id = "burn_me_now".to_string(); contract.nft_mint(token_id.to_owned(), burn_account.to_owned()); @@ -756,7 +759,7 @@ mod tests { "burn_me_now" ); - set_attached_deposit(1); + set_attached_deposit(NearToken::from_yoctonear(1)); contract.nft_burn(token_id); assert_eq!(contract.nft_token("burn_me_now".to_string()), None); diff --git a/examples/purejs/Cargo.toml b/examples/purejs/Cargo.toml index 786fde12..4bf42010 100644 --- a/examples/purejs/Cargo.toml +++ b/examples/purejs/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -near-sdk = "4.1.1" +near-sdk = "5.5.0" quickjs-rust-near = { path = "../../", features=["library"] } quickjs-rust-near-testenv = { path = "../../testenv" } diff --git a/examples/purejs/src/lib.rs b/examples/purejs/src/lib.rs index 0192e729..40297a6f 100644 --- a/examples/purejs/src/lib.rs +++ b/examples/purejs/src/lib.rs @@ -1,18 +1,17 @@ -use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; +use near_sdk::borsh::{BorshDeserialize, BorshSerialize}; use near_sdk::near_bindgen; -use quickjs_rust_near::jslib::{ - js_call_function, load_js_bytecode -}; +use quickjs_rust_near::jslib::{js_call_function, load_js_bytecode}; #[near_bindgen] #[derive(BorshDeserialize, BorshSerialize, Default)] +#[borsh(crate = "near_sdk::borsh")] pub struct Contract {} #[near_bindgen] impl Contract { pub fn some_js_function(&self) { - unsafe { - let jsmod = load_js_bytecode(123456789 as *const u8, 987654321); + unsafe { + let jsmod = load_js_bytecode(123456789 as *const u8, 987654321); js_call_function(jsmod, 456123987 as i32); } } diff --git a/localjstestenv/README.md b/localjstestenv/README.md new file mode 100644 index 00000000..1a9b0588 --- /dev/null +++ b/localjstestenv/README.md @@ -0,0 +1,15 @@ +A minimal environment for simulation of WASM smart contracts +============================================================ + +Sometimes spinning up near-workspaces might not be needed if you're only going to simulate view methods or storage. By mocking the NEAR environment imports you can easily and fast spin up a smart contract runner for such simple use cases. + +Given you have a simple contract `my-contract.wasm` that exports a view function named `hello`, and you can provide `name` as an argument, you can test that it returns a given value like shown in the example below. + +```javascript +import { getContractInstanceExports } from "./contract-runner.js"; + +const { exports, nearenv } = await getContractInstanceExports(await readFile('./my-contract.wasm')); +nearenv.set_args({ name: 'peter' }); +exports.hello(); +expect(nearenv.latest_return_value).to.equal('hello peter'); +``` diff --git a/src/lib.rs b/src/lib.rs index 3f35f42f..9bd83c7c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,6 +17,7 @@ pub mod viewaccesscontrol; mod wasimock; #[near_bindgen] #[derive(Default, BorshDeserialize, BorshSerialize)] +#[borsh(crate="near_sdk::borsh")] #[cfg(not(feature = "library"))] pub struct Scripts { scripts: HashMap>, diff --git a/src/viewaccesscontrol.rs b/src/viewaccesscontrol.rs index 0f7c2162..8ae2ba91 100644 --- a/src/viewaccesscontrol.rs +++ b/src/viewaccesscontrol.rs @@ -1,17 +1,19 @@ use ed25519_dalek::ed25519::signature::Signature as DalekSig; use ed25519_dalek::PublicKey as DalekPK; -use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; +use near_sdk::borsh::{BorshDeserialize, BorshSerialize}; use near_sdk::{base64, env}; use std::collections::HashMap; const ACCOUNT_SIGNING_KEYS_KEY: &[u8] = b"ACCSIGNKEYS"; #[derive(Default, BorshDeserialize, BorshSerialize)] +#[borsh(crate = "near_sdk::borsh")] struct AccountSigningKey { public_key: Vec, expires_timestamp_ms: u64, } #[derive(Default, BorshDeserialize, BorshSerialize)] +#[borsh(crate = "near_sdk::borsh")] pub struct AccountSigningKeys { signing_keys_per_account: HashMap, } @@ -26,12 +28,11 @@ pub fn load_account_signing_keys() -> AccountSigningKeys { } pub fn save_account_signing_keys(account_signing_keys: AccountSigningKeys) { - env::storage_write( - ACCOUNT_SIGNING_KEYS_KEY, - &account_signing_keys - .try_to_vec() - .expect("Cannot serialize account signing keys."), - ); + let mut account_signing_keys_buffer: Vec = Vec::new(); + account_signing_keys + .serialize(&mut account_signing_keys_buffer) + .expect("Cannot serialize account signing keys."); + env::storage_write(ACCOUNT_SIGNING_KEYS_KEY, &account_signing_keys_buffer); } pub fn store_signing_key_for_account(expires_timestamp_ms: u64) { @@ -69,8 +70,9 @@ pub fn verify_message_signed_by_account( if account_signing_key_option.is_some() { let account_signing_key = account_signing_key_option.unwrap(); if account_signing_key.expires_timestamp_ms > env::block_timestamp_ms() { - let pk = DalekPK::from_bytes(&account_signing_key_option.unwrap().public_key[1..].to_vec()) - .unwrap(); + let pk = + DalekPK::from_bytes(&account_signing_key_option.unwrap().public_key[1..].to_vec()) + .unwrap(); let sig = DalekSig::from_bytes(base64::decode(&signature).unwrap().as_slice()).unwrap(); return pk.verify_strict(signed_message.as_bytes(), &sig).is_ok(); @@ -84,11 +86,11 @@ mod tests { use super::{ load_account_signing_keys, store_signing_key_for_account, verify_message_signed_by_account, }; + use near_sdk::env::block_timestamp_ms; use quickjs_rust_near_testenv::testenv::{ alice, bob, set_block_timestamp, set_signer_account_id, set_signer_account_pk, setup_test_env, }; - use near_sdk::env::{block_timestamp_ms}; const EXPIRY_MILLISECONDS: u64 = 24 * 60 * 60 * 1000; #[test] diff --git a/testenv/Cargo.toml b/testenv/Cargo.toml index dfc09f4f..4b83d40f 100644 --- a/testenv/Cargo.toml +++ b/testenv/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" crate-type = ["cdylib", "rlib"] [dependencies] -near-sdk = "4.0.0" +near-sdk = "5.5.0" lazy_static = "1.4.0" ed25519-dalek = "1.0.1" sha2 = "0.10.6" diff --git a/testenv/src/testenv.rs b/testenv/src/testenv.rs index 94203ccd..31f936b3 100644 --- a/testenv/src/testenv.rs +++ b/testenv/src/testenv.rs @@ -1,4 +1,4 @@ -use near_sdk::{AccountId, Balance, PublicKey}; +use near_sdk::{AccountId, NearToken, PublicKey}; use sha2::Digest; use std::collections::HashMap; use std::io::{self, Write}; @@ -7,17 +7,17 @@ const EVICTED_REGISTER: i64 = (u64::MAX - 1) as i64; #[allow(dead_code)] pub fn alice() -> AccountId { - AccountId::new_unchecked("alice.near".to_string()) + "alice.near".parse().unwrap() } #[allow(dead_code)] pub fn bob() -> AccountId { - AccountId::new_unchecked("bob.near".to_string()) + "bob.near".parse().unwrap() } #[allow(dead_code)] pub fn carol() -> AccountId { - AccountId::new_unchecked("carol.near".to_string()) + "carol.near".parse().unwrap() } struct TestEnv { @@ -26,7 +26,7 @@ struct TestEnv { signer_account_pk: PublicKey, current_account_id: AccountId, predecessor_account_id: AccountId, - attached_deposit: Balance, + attached_deposit: NearToken, input: Vec, returned_value: Vec, } @@ -38,7 +38,7 @@ impl TestEnv { signer_account_id: bob(), current_account_id: alice(), predecessor_account_id: bob(), - attached_deposit: 0, + attached_deposit: NearToken::from_near(0), signer_account_pk: vec![ 00, 66, 211, 21, 84, 20, 241, 129, 29, 118, 83, 184, 41, 215, 240, 117, 106, 56, 29, 69, 103, 43, 191, 167, 199, 102, 3, 16, 194, 250, 138, 198, 78, @@ -113,7 +113,7 @@ pub fn set_input(input: Vec) { } } -pub fn set_attached_deposit(deposit: Balance) { +pub fn set_attached_deposit(deposit: NearToken) { unsafe { if let Some(test_env) = TESTENV.as_mut() { test_env.attached_deposit = deposit; @@ -205,7 +205,7 @@ pub extern "C" fn input(register: i64) { pub extern "C" fn attached_deposit(data_ptr: i64) { unsafe { let testenv = TESTENV.as_ref().unwrap(); - let src = testenv.attached_deposit.to_le_bytes(); + let src = testenv.attached_deposit.as_yoctonear().to_le_bytes(); std::ptr::copy(src.as_ptr(), data_ptr as *mut u8, src.len()); } } diff --git a/web4/README.md b/web4/README.md new file mode 100644 index 00000000..0382da0c --- /dev/null +++ b/web4/README.md @@ -0,0 +1,7 @@ +# Web4 and a WebAssembly Music showcase + +The web application in the [web4](./web4) folder is a vanilla JS Web Component application for uploading music written in Javascript and also playing it, and accepting parameters in JSON for configuring the playback. It also contains functionality for exporting to WAV. See the video playlist above for a demo. + +The music to be played back is fetched in a view method call, and for controlling who can access this view method the JSON parameters payload is signed using the callers private key. The contract will then verify the signature according to the callers public key stored in a transaction before the view method call. + +The web application is packaged into a single HTML file using rollup, where the final bundle is embedded into the Rust sources encoded as a base64 string.