diff --git a/bridge-common/Cargo.lock b/bridge-common/Cargo.lock index 3553d961..1311b1d2 100644 --- a/bridge-common/Cargo.lock +++ b/bridge-common/Cargo.lock @@ -8,14 +8,6 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -[[package]] -name = "admin-controlled" -version = "0.1.0" -source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" -dependencies = [ - "near-sdk", -] - [[package]] name = "ahash" version = "0.7.6" @@ -163,7 +155,6 @@ dependencies = [ name = "bridge-common" version = "0.1.0" dependencies = [ - "admin-controlled", "eth-types", "ethabi", "hex", @@ -308,41 +299,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "darling" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn", -] - -[[package]] -name = "darling_macro" -version = "0.13.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" -dependencies = [ - "darling_core", - "quote", - "syn", -] - [[package]] name = "derive_more" version = "0.99.17" @@ -413,13 +369,10 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "eth-types" version = "0.1.0" -source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" +source = "git+https://github.com/near/rainbow-bridge?rev=4b24cbd5a6e098fd8a9cd24fbb194fa8e0fc51e4#4b24cbd5a6e098fd8a9cd24fbb194fa8e0fc51e4" dependencies = [ "borsh", "derive_more", - "eth2_serde_utils", - "eth2_ssz", - "eth2_ssz_derive", "ethereum-types", "hex", "near-sdk", @@ -427,49 +380,6 @@ dependencies = [ "rlp-derive", "serde", "serde-big-array", - "tree_hash", - "tree_hash_derive", -] - -[[package]] -name = "eth2_hashing" -version = "0.3.0" -source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" -dependencies = [ - "lazy_static", - "near-sdk", -] - -[[package]] -name = "eth2_serde_utils" -version = "0.1.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "ethereum-types", - "hex", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "eth2_ssz" -version = "0.4.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "ethereum-types", - "smallvec", -] - -[[package]] -name = "eth2_ssz_derive" -version = "0.3.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", ] [[package]] @@ -537,12 +447,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "funty" version = "1.1.0" @@ -602,12 +506,6 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - [[package]] name = "impl-codec" version = "0.4.2" @@ -667,12 +565,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.121" @@ -1290,12 +1182,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strum" version = "0.24.1" @@ -1410,26 +1296,6 @@ dependencies = [ "serde", ] -[[package]] -name = "tree_hash" -version = "0.4.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "eth2_hashing", - "ethereum-types", - "smallvec", -] - -[[package]] -name = "tree_hash_derive" -version = "0.4.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "darling", - "quote", - "syn", -] - [[package]] name = "typenum" version = "1.15.0" @@ -1544,3 +1410,8 @@ dependencies = [ "syn", "synstructure", ] + +[[patch.unused]] +name = "eth2_hashing" +version = "0.3.0" +source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" diff --git a/bridge-common/Cargo.toml b/bridge-common/Cargo.toml index 62aa8c2b..dee72ff0 100644 --- a/bridge-common/Cargo.toml +++ b/bridge-common/Cargo.toml @@ -7,8 +7,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -eth-types = { git = "https://github.com/near/rainbow-bridge", rev = "67966a151122815039f07b02065ab3a2bba09804" } -admin-controlled = { git = "https://github.com/near/rainbow-bridge", rev = "67966a151122815039f07b02065ab3a2bba09804" } +eth-types = { git = "https://github.com/near/rainbow-bridge", rev = "4b24cbd5a6e098fd8a9cd24fbb194fa8e0fc51e4", default-features = false} ethabi = "12.0.0" near-sdk = "4.0.0" tiny-keccak = "1.4.0" diff --git a/bridge-common/src/prover.rs b/bridge-common/src/prover.rs index 823273ef..527e0062 100644 --- a/bridge-common/src/prover.rs +++ b/bridge-common/src/prover.rs @@ -1,6 +1,5 @@ use std::convert::From; -use admin_controlled::Mask; use eth_types::*; use ethabi::param_type::Writer; use ethabi::{Event, EventParam, Hash, Log, ParamType, RawLog, Token}; @@ -14,8 +13,6 @@ pub type EthAddress = [u8; 20]; pub const NO_DEPOSIT: Balance = 0; -pub const PAUSE_DEPOSIT: Mask = 1 << 1; - /// Gas to call verify_log_entry on prover. pub const VERIFY_LOG_ENTRY_GAS: Gas = Gas(Gas::ONE_TERA.0 * 50); diff --git a/bridge-token-factory/Cargo.lock b/bridge-token-factory/Cargo.lock index 099dbb38..e4fd75b0 100644 --- a/bridge-token-factory/Cargo.lock +++ b/bridge-token-factory/Cargo.lock @@ -8,51 +8,6 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -[[package]] -name = "actix" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f728064aca1c318585bf4bb04ffcfac9e75e508ab4e8b1bd9ba5dfe04e2cbed5" -dependencies = [ - "actix-rt", - "actix_derive", - "bitflags", - "bytes", - "crossbeam-channel", - "futures-core", - "futures-sink", - "futures-task", - "futures-util", - "log", - "once_cell", - "parking_lot", - "pin-project-lite", - "smallvec", - "tokio", - "tokio-util", -] - -[[package]] -name = "actix-rt" -version = "2.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ea16c295198e958ef31930a6ef37d0fb64e9ca3b6116e6b93a8bdae96ee1000" -dependencies = [ - "futures-core", - "tokio", -] - -[[package]] -name = "actix_derive" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d44b8fee1ced9671ba043476deddef739dd0959bf77030b26b738cc591737a7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "addr2line" version = "0.17.0" @@ -68,14 +23,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "admin-controlled" -version = "0.1.0" -source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" -dependencies = [ - "near-sdk", -] - [[package]] name = "ahash" version = "0.7.6" @@ -183,7 +130,7 @@ checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -225,6 +172,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" + [[package]] name = "binary-install" version = "0.0.2" @@ -344,7 +297,7 @@ dependencies = [ "borsh-schema-derive-internal", "proc-macro-crate 0.1.5", "proc-macro2", - "syn", + "syn 1.0.99", ] [[package]] @@ -355,7 +308,7 @@ checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -366,14 +319,13 @@ checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] name = "bridge-common" version = "0.1.0" dependencies = [ - "admin-controlled", "eth-types", "ethabi", "hex 0.4.3", @@ -385,25 +337,23 @@ dependencies = [ [[package]] name = "bridge-token" -version = "0.1.0" +version = "0.2.0" dependencies = [ - "admin-controlled", "near-contract-standards", "near-sdk", ] [[package]] name = "bridge-token-factory" -version = "0.1.5" +version = "0.2.0" dependencies = [ - "admin-controlled", "anyhow", "bridge-common", "bridge-token", - "eth-types", "ethabi", "hex 0.4.3", "near-contract-standards", + "near-plugins", "near-sdk", "rand 0.7.3", "serde", @@ -590,16 +540,6 @@ dependencies = [ "cfg-if 1.0.0", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" -dependencies = [ - "cfg-if 1.0.0", - "crossbeam-utils", -] - [[package]] name = "crossbeam-utils" version = "0.8.11" @@ -700,7 +640,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 1.0.99", ] [[package]] @@ -711,7 +651,7 @@ checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835" dependencies = [ "darling_core", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -724,7 +664,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 1.0.99", ] [[package]] @@ -777,6 +717,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "dyn-clone" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" + [[package]] name = "easy-ext" version = "0.2.9" @@ -824,13 +770,10 @@ dependencies = [ [[package]] name = "eth-types" version = "0.1.0" -source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" +source = "git+https://github.com/near/rainbow-bridge?rev=4b24cbd5a6e098fd8a9cd24fbb194fa8e0fc51e4#4b24cbd5a6e098fd8a9cd24fbb194fa8e0fc51e4" dependencies = [ "borsh", "derive_more", - "eth2_serde_utils", - "eth2_ssz", - "eth2_ssz_derive", "ethereum-types", "hex 0.4.3", "near-sdk", @@ -838,49 +781,6 @@ dependencies = [ "rlp-derive", "serde", "serde-big-array", - "tree_hash", - "tree_hash_derive", -] - -[[package]] -name = "eth2_hashing" -version = "0.3.0" -source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" -dependencies = [ - "lazy_static", - "near-sdk", -] - -[[package]] -name = "eth2_serde_utils" -version = "0.1.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "ethereum-types", - "hex 0.4.3", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "eth2_ssz" -version = "0.4.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "ethereum-types", - "smallvec", -] - -[[package]] -name = "eth2_ssz_derive" -version = "0.3.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", ] [[package]] @@ -948,7 +848,7 @@ checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", "synstructure", ] @@ -970,7 +870,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall 0.2.16", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -1038,6 +938,16 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "funty" version = "1.1.0" @@ -1144,9 +1054,9 @@ checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" [[package]] name = "h2" -version = "0.3.14" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca32592cf21ac7ccab1825cd87f6c9b3d9022c44d086172ed0966bec8af30be" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -1236,9 +1146,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" [[package]] name = "httpdate" @@ -1248,9 +1158,9 @@ checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" [[package]] name = "hyper" -version = "0.14.20" +version = "0.14.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" dependencies = [ "bytes", "futures-channel", @@ -1357,7 +1267,7 @@ checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -1420,12 +1330,15 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "libc" -version = "0.2.129" +version = "0.2.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64de3cc433455c14174d42e554d4027ee631c4d046d43e3ecc6efc4636cdc7a7" +checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" [[package]] name = "libz-sys" @@ -1500,7 +1413,7 @@ dependencies = [ "libc", "log", "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -1522,12 +1435,14 @@ dependencies = [ ] [[package]] -name = "near-account-id" -version = "0.13.0" +name = "near-abi" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de83d74a9241be8cc4eb3055216966b58bf8c463e8e285c0dc553925acdd19fa" +checksum = "885db39b08518fa700b73fa2214e8adbbfba316ba82dd510f50519173eadaf73" dependencies = [ "borsh", + "schemars", + "semver", "serde", ] @@ -1541,17 +1456,27 @@ dependencies = [ "serde", ] +[[package]] +name = "near-account-id" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d924011380de759c3dc6fdbcda37a19a5c061f56dab69d28a34ecee765e23e4" +dependencies = [ + "borsh", + "serde", +] + [[package]] name = "near-chain-configs" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3632a1c691603cb32dd9944c95d8eadbf2c09f45abd95350ea6848c649036a0b" +checksum = "1faf676a95bd1718b06e5957e01a9415fedf7900f32d94d5bcf70abd678b10a2" dependencies = [ "anyhow", "chrono", "derive_more", - "near-crypto 0.14.0", - "near-primitives 0.14.0", + "near-crypto 0.15.0", + "near-primitives 0.15.0", "num-rational", "serde", "serde_json", @@ -1560,65 +1485,23 @@ dependencies = [ "tracing", ] -[[package]] -name = "near-chain-primitives" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a734353027698b21633a49d478e564c61ae0171c32f6912bb8844add15d72ebe" -dependencies = [ - "chrono", - "near-crypto 0.14.0", - "near-primitives 0.14.0", - "thiserror", - "tracing", -] - -[[package]] -name = "near-chunks-primitives" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17f6f22f1ab710731dfba4101f12a99cac120d6af80b99899bd335bb8971477" -dependencies = [ - "near-chain-primitives", - "near-primitives 0.14.0", -] - -[[package]] -name = "near-client-primitives" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1065d86012eeea838661434549f33bb6267c9950fd2aadd2af617fe773def38" -dependencies = [ - "actix", - "chrono", - "near-chain-configs", - "near-chain-primitives", - "near-chunks-primitives", - "near-crypto 0.14.0", - "near-network-primitives", - "near-primitives 0.14.0", - "serde", - "serde_json", - "strum", - "thiserror", -] - [[package]] name = "near-contract-standards" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6466c6aaad18800ff6a3cd104427dc8fd79e144714135224b8289b1dc43f7167" +checksum = "7bacc932e79b26472797adfb21689294b6f90960d1570daaf1e0b682b59fcb35" dependencies = [ "near-sdk", + "schemars", "serde", "serde_json", ] [[package]] name = "near-crypto" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ecf0b8b31aa7f4e60f629f72213a2617ca4a5f45cd1ae9ed2cf7cecfebdbb7" +checksum = "1e75673d69fd7365508f3d32483669fe45b03bfb34e4d9363e90adae9dfb416c" dependencies = [ "arrayref", "blake2", @@ -1628,8 +1511,7 @@ dependencies = [ "curve25519-dalek", "derive_more", "ed25519-dalek", - "libc", - "near-account-id 0.13.0", + "near-account-id 0.14.0", "once_cell", "parity-secp256k1", "primitive-types 0.10.1", @@ -1643,9 +1525,9 @@ dependencies = [ [[package]] name = "near-crypto" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e75673d69fd7365508f3d32483669fe45b03bfb34e4d9363e90adae9dfb416c" +checksum = "7754612b47737d277fb818e9fdbb1406e90f9e57151c55c3584d714421976cb6" dependencies = [ "arrayref", "blake2", @@ -1655,12 +1537,11 @@ dependencies = [ "curve25519-dalek", "derive_more", "ed25519-dalek", - "near-account-id 0.14.0", + "near-account-id 0.15.0", "once_cell", - "parity-secp256k1", "primitive-types 0.10.1", "rand 0.7.3", - "rand_core 0.5.1", + "secp256k1", "serde", "serde_json", "subtle", @@ -1669,17 +1550,17 @@ dependencies = [ [[package]] name = "near-jsonrpc-client" -version = "0.4.0-beta.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bba462f54bc35289a1013ed3a2ebfa67cc8b12699f81c12dd67687f200c7b871" +checksum = "d1335ffce1476da6516dcd22b26cece1a495fc725c0e8fec1879073752ac068d" dependencies = [ "borsh", "lazy_static", "log", "near-chain-configs", - "near-crypto 0.14.0", + "near-crypto 0.15.0", "near-jsonrpc-primitives", - "near-primitives 0.14.0", + "near-primitives 0.15.0", "reqwest", "serde", "serde_json", @@ -1689,44 +1570,47 @@ dependencies = [ [[package]] name = "near-jsonrpc-primitives" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34a14ee8ca393c0140cb232789259ebc61b13b4cceb177267d0131f50d0eda6c" +checksum = "ada226c74f05508c516f109a97b9f23335120d0bfda208f0d187b6bbfe6eef5a" dependencies = [ "near-chain-configs", - "near-client-primitives", - "near-crypto 0.14.0", - "near-primitives 0.14.0", - "near-rpc-error-macro 0.14.0", + "near-crypto 0.15.0", + "near-primitives 0.15.0", + "near-rpc-error-macro 0.15.0", "serde", "serde_json", "thiserror", - "uuid", ] [[package]] -name = "near-network-primitives" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa998a1e70ebf8cf3efa76c4562ef36038cc88b4aee60efb708d14273910357" +name = "near-plugins" +version = "0.1.0" +source = "git+https://github.com/aurora-is-near/near-plugins?tag=v0.1.0#64c512f96d4b51ccdd1a1aed683ed90fd1ca8c57" dependencies = [ - "actix", - "anyhow", - "borsh", - "chrono", - "near-crypto 0.14.0", - "near-primitives 0.14.0", + "bitflags", + "near-plugins-derive", + "near-sdk", "serde", - "strum", - "tokio", - "tracing", +] + +[[package]] +name = "near-plugins-derive" +version = "0.1.0" +source = "git+https://github.com/aurora-is-near/near-plugins?tag=v0.1.0#64c512f96d4b51ccdd1a1aed683ed90fd1ca8c57" +dependencies = [ + "darling", + "proc-macro-crate 0.1.5", + "proc-macro2", + "quote", + "syn 1.0.99", ] [[package]] name = "near-primitives" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ba19282e79a4485a77736b679d276b09870bbf8042a18e0f0ae36347489c5" +checksum = "8ad1a9a1640539c81f065425c31bffcfbf6b31ef1aeaade59ce905f5df6ac860" dependencies = [ "borsh", "byteorder", @@ -1735,10 +1619,10 @@ dependencies = [ "derive_more", "easy-ext", "hex 0.4.3", - "near-crypto 0.13.0", - "near-primitives-core 0.13.0", - "near-rpc-error-macro 0.13.0", - "near-vm-errors 0.13.0", + "near-crypto 0.14.0", + "near-primitives-core 0.14.0", + "near-rpc-error-macro 0.14.0", + "near-vm-errors 0.14.0", "num-rational", "once_cell", "primitive-types 0.10.1", @@ -1753,21 +1637,22 @@ dependencies = [ [[package]] name = "near-primitives" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad1a9a1640539c81f065425c31bffcfbf6b31ef1aeaade59ce905f5df6ac860" +checksum = "97670b302dce15f09bba50f24c67aa08130fd01528cc61d4415892401e88e974" dependencies = [ "borsh", "byteorder", "bytesize", + "cfg-if 1.0.0", "chrono", "derive_more", "easy-ext", "hex 0.4.3", - "near-crypto 0.14.0", - "near-primitives-core 0.14.0", - "near-rpc-error-macro 0.14.0", - "near-vm-errors 0.14.0", + "near-crypto 0.15.0", + "near-primitives-core 0.15.0", + "near-rpc-error-macro 0.15.0", + "near-vm-errors 0.15.0", "num-rational", "once_cell", "primitive-types 0.10.1", @@ -1782,15 +1667,15 @@ dependencies = [ [[package]] name = "near-primitives-core" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb561feb392bb8c4f540256073446e6689af087bf6356e8dddcf75fc279f201f" +checksum = "91d508f0fc340f6461e4e256417685720d3c4c00bb5a939b105160e49137caba" dependencies = [ "base64 0.11.0", "borsh", "bs58", "derive_more", - "near-account-id 0.13.0", + "near-account-id 0.14.0", "num-rational", "serde", "sha2 0.10.2", @@ -1799,94 +1684,99 @@ dependencies = [ [[package]] name = "near-primitives-core" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d508f0fc340f6461e4e256417685720d3c4c00bb5a939b105160e49137caba" +checksum = "7929e19d862221949734c4a0063a8f55e7069de3a2ebc2d4f4c13497a5e953cb" dependencies = [ - "base64 0.11.0", + "base64 0.13.0", "borsh", "bs58", "derive_more", - "near-account-id 0.14.0", + "near-account-id 0.15.0", "num-rational", "serde", + "serde_repr", "sha2 0.10.2", "strum", ] [[package]] name = "near-rpc-error-core" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77fdd7ea8d8f786878651c37691515d5053f827ae60894aa40c16882b78f77c9" +checksum = "93ee0b41c75ef859c193a8ff1dadfa0c8207bc0ac447cc22259721ad769a1408" dependencies = [ "quote", "serde", - "syn", + "syn 1.0.99", ] [[package]] name = "near-rpc-error-core" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ee0b41c75ef859c193a8ff1dadfa0c8207bc0ac447cc22259721ad769a1408" +checksum = "36addf90cc04bd547a627b3a292f59d7de4dd6fb5042115419ae901b93ce6c2d" dependencies = [ "quote", "serde", - "syn", + "syn 1.0.99", ] [[package]] name = "near-rpc-error-macro" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e521842b6ae864dfe5391afbbe2df9e9d8427c26e9333b2e0b65cd42094f7607" +checksum = "8e837bd4bacd807073ec5ceb85708da7f721b46a4c2a978de86027fb0034ce31" dependencies = [ - "near-rpc-error-core 0.13.0", + "near-rpc-error-core 0.14.0", "serde", - "syn", + "syn 1.0.99", ] [[package]] name = "near-rpc-error-macro" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e837bd4bacd807073ec5ceb85708da7f721b46a4c2a978de86027fb0034ce31" +checksum = "0b5beb352f3b91d8c491646c2fa4fdbbbf463c7b9c0226951c28f0197de44f99" dependencies = [ - "near-rpc-error-core 0.14.0", + "near-rpc-error-core 0.15.0", "serde", - "syn", + "syn 1.0.99", ] [[package]] name = "near-sandbox-utils" -version = "0.5.0" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4cf1e2b801709b9fe36806a3895ff63e85b37746b562bb8e4d266c7286b94d6" +checksum = "7479b0a2c52890000d410c6e4ba4f851334280530fa7446b78bcaf4683fe69b0" dependencies = [ "anyhow", "async-process", "binary-install", "chrono", + "fs2", "hex 0.3.2", "home", ] [[package]] name = "near-sdk" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda34e06e28fb9a09ac54efbdc49f0c9308780fc932aaa81c49c493fde974045" +checksum = "15eb3de2defe3626260cc209a6cdb985c6b27b0bd4619fad97dcfae002c3c5bd" dependencies = [ "base64 0.13.0", "borsh", "bs58", - "near-crypto 0.13.0", - "near-primitives 0.13.0", - "near-primitives-core 0.13.0", + "near-abi", + "near-crypto 0.14.0", + "near-primitives 0.14.0", + "near-primitives-core 0.14.0", "near-sdk-macros", "near-sys", "near-vm-logic", + "once_cell", + "schemars", "serde", "serde_json", "wee_alloc", @@ -1894,14 +1784,14 @@ dependencies = [ [[package]] name = "near-sdk-macros" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72064fcc15a623a0d40a6c199ea5cbdc30a83cae4816889d46f218acf31bfba8" +checksum = "4907affc9f5ed559456509188ff0024f1f2099c0830e6bdb66eb61d5b75912c0" dependencies = [ "Inflector", "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -1912,47 +1802,49 @@ checksum = "e307313276eaeced2ca95740b5639e1f3125b7c97f0a1151809d105f1aa8c6d3" [[package]] name = "near-vm-errors" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e02faf2bc1f6ef82b965cfe44389808fb5594f7aca4b596766117f4ce74df20" +checksum = "d0da466a30f0446639cbd788c30865086fac3e8dcb07a79e51d2b0775ed4261e" dependencies = [ "borsh", - "near-account-id 0.13.0", - "near-rpc-error-macro 0.13.0", + "near-account-id 0.14.0", + "near-rpc-error-macro 0.14.0", "serde", ] [[package]] name = "near-vm-errors" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0da466a30f0446639cbd788c30865086fac3e8dcb07a79e51d2b0775ed4261e" +checksum = "5591c9c8afa83a040cb5c3f29bc52b2efae2c32d4bcaee1bba723738da1a5cf6" dependencies = [ "borsh", - "near-account-id 0.14.0", - "near-rpc-error-macro 0.14.0", + "near-account-id 0.15.0", + "near-rpc-error-macro 0.15.0", "serde", + "strum", ] [[package]] name = "near-vm-logic" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f024d90451cd3c24d7a0a5cabf3636b192a60eb8e3ff0456f6c18b91152c346d" +checksum = "81b534828419bacbf1f7b11ef7b00420f248c548c485d3f0cfda8bb6931152f2" dependencies = [ "base64 0.13.0", "borsh", "bs58", "byteorder", - "near-account-id 0.13.0", - "near-crypto 0.13.0", - "near-primitives 0.13.0", - "near-primitives-core 0.13.0", - "near-vm-errors 0.13.0", + "near-account-id 0.14.0", + "near-crypto 0.14.0", + "near-primitives 0.14.0", + "near-primitives-core 0.14.0", + "near-vm-errors 0.14.0", "ripemd", "serde", "sha2 0.10.2", "sha3", + "zeropool-bn", ] [[package]] @@ -2052,7 +1944,7 @@ checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -2109,7 +2001,7 @@ dependencies = [ "proc-macro-crate 1.2.1", "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -2150,7 +2042,7 @@ dependencies = [ "libc", "redox_syscall 0.2.16", "smallvec", - "windows-sys", + "windows-sys 0.36.1", ] [[package]] @@ -2176,7 +2068,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -2272,18 +2164,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.43" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab" +checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.21" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -2428,11 +2320,11 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.11" +version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92" +checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.13.0", + "base64 0.21.4", "bytes", "encoding_rs", "futures-core", @@ -2444,15 +2336,16 @@ dependencies = [ "hyper-tls", "ipnet", "js-sys", - "lazy_static", "log", "mime", "native-tls", + "once_cell", "percent-encoding", "pin-project-lite", "serde", "serde_json", "serde_urlencoded", + "system-configuration", "tokio", "tokio-native-tls", "tower-service", @@ -2489,7 +2382,7 @@ checksum = "e33d7b2abe0c340d8797fe2907d3f20d3b5ea5908683618bfe80df7f621f672a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -2544,7 +2437,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" dependencies = [ "lazy_static", - "windows-sys", + "windows-sys 0.36.1", +] + +[[package]] +name = "schemars" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 1.0.99", ] [[package]] @@ -2553,6 +2470,25 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "secp256k1" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" +dependencies = [ + "rand 0.8.5", + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +dependencies = [ + "cc", +] + [[package]] name = "security-framework" version = "2.7.0" @@ -2584,9 +2520,9 @@ checksum = "93f6841e709003d68bb2deee8c343572bf446003ec20a583e76f7b15cebf3711" [[package]] name = "serde" -version = "1.0.143" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] @@ -2602,26 +2538,48 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.143" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.37", +] + +[[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 1.0.99", ] [[package]] name = "serde_json" -version = "1.0.83" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7" +checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" dependencies = [ "itoa", "ryu", "serde", ] +[[package]] +name = "serde_repr" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.37", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2722,19 +2680,25 @@ checksum = "133659a15339456eeeb07572eb02a91c91e9815e9cbc89566944d2c8d3efdbf6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] name = "socket2" -version = "0.4.4" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" dependencies = [ "libc", "winapi", ] +[[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" @@ -2766,7 +2730,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 1.0.99", ] [[package]] @@ -2786,6 +2750,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "synstructure" version = "0.12.6" @@ -2794,10 +2769,31 @@ checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", "unicode-xid", ] +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tap" version = "1.0.1" @@ -2831,22 +2827,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.32" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.32" +version = "1.0.49" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.37", ] [[package]] @@ -2922,7 +2918,7 @@ checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -2995,7 +2991,7 @@ checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", ] [[package]] @@ -3007,26 +3003,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "tree_hash" -version = "0.4.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "eth2_hashing", - "ethereum-types", - "smallvec", -] - -[[package]] -name = "tree_hash_derive" -version = "0.4.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "darling", - "quote", - "syn", -] - [[package]] name = "try-lock" version = "0.2.3" @@ -3105,9 +3081,9 @@ dependencies = [ [[package]] name = "uuid" -version = "0.8.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ "getrandom 0.2.7", ] @@ -3179,7 +3155,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 1.0.99", "wasm-bindgen-shared", ] @@ -3213,7 +3189,7 @@ checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3283,71 +3259,139 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.48.5", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if 1.0.0", + "windows-sys 0.48.0", ] [[package]] name = "workspaces" -version = "0.5.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b213a32d18d7bd6c1b2775ef365f0f7c41fefae1dc4afe3675b0a314cee806" +checksum = "1f54d9286e6dc20dd6d7676de27ace7b0d4f755164fe14c1f07bcbdd08d54052" dependencies = [ - "anyhow", + "async-process", "async-trait", "base64 0.13.0", "borsh", + "bs58", "chrono", "dirs 3.0.2", "hex 0.4.3", "libc", - "near-account-id 0.14.0", - "near-crypto 0.14.0", + "near-account-id 0.15.0", + "near-crypto 0.15.0", "near-jsonrpc-client", "near-jsonrpc-primitives", - "near-primitives 0.14.0", + "near-primitives 0.15.0", "near-sandbox-utils", "portpicker", "rand 0.8.5", @@ -3393,10 +3437,24 @@ checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.99", "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", +] + [[package]] name = "zip" version = "0.5.13" diff --git a/bridge-token-factory/Cargo.toml b/bridge-token-factory/Cargo.toml index c6cd1339..f669ce6f 100644 --- a/bridge-token-factory/Cargo.toml +++ b/bridge-token-factory/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bridge-token-factory" -version = "0.1.5" +version = "0.2.0" authors = ["Near Inc "] edition = "2021" publish = false @@ -18,24 +18,19 @@ panic = "abort" overflow-checks = true [dependencies] -near-sdk = "4.0.0" +near-sdk = "4.1.0" near-contract-standards = "4.0.0" -eth-types = { git = "https://github.com/near/rainbow-bridge", rev = "67966a151122815039f07b02065ab3a2bba09804" } -admin-controlled = { git = "https://github.com/near/rainbow-bridge", rev = "67966a151122815039f07b02065ab3a2bba09804" } ethabi = "12.0.0" bridge-common = { path = "../bridge-common", default-features = false } hex = "0.4.2" bridge-token = { path = "../bridge-token" } +near-plugins = { git = "https://github.com/aurora-is-near/near-plugins", tag = "v0.1.0" } [dev-dependencies] uint = { version = "0.8.3", default-features = false } rand = "0.7.3" serde = { version = "*", features = ["derive"] } serde_json = "*" -workspaces = "0.5.0" +workspaces = "0.6.1" tokio = { version = "1.1", features = ["rt", "macros"] } anyhow = "*" - -[patch] -[patch.crates-io] -eth2_hashing = { git = "https://github.com/near/rainbow-bridge", rev = "67966a151122815039f07b02065ab3a2bba09804" } \ No newline at end of file diff --git a/bridge-token-factory/res/bridge_token_factory_v0.1.6.wasm b/bridge-token-factory/res/bridge_token_factory_v0.1.6.wasm new file mode 100644 index 00000000..78863f38 Binary files /dev/null and b/bridge-token-factory/res/bridge_token_factory_v0.1.6.wasm differ diff --git a/bridge-token-factory/rust-toolchain b/bridge-token-factory/rust-toolchain index d5a27893..d04f2eb5 100644 --- a/bridge-token-factory/rust-toolchain +++ b/bridge-token-factory/rust-toolchain @@ -1 +1,3 @@ -stable-2022-07-19 +[toolchain] +channel = "1.69.0" +components = ["clippy", "rustfmt"] diff --git a/bridge-token-factory/src/lib.rs b/bridge-token-factory/src/lib.rs index 61c1335b..97ef351e 100644 --- a/bridge-token-factory/src/lib.rs +++ b/bridge-token-factory/src/lib.rs @@ -1,16 +1,20 @@ -use admin_controlled::{AdminControlled, Mask}; +use near_plugins::{ + access_control, access_control_any, pause, AccessControlRole, AccessControllable, Pausable, + Upgradable, +}; use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; use near_sdk::collections::{UnorderedMap, UnorderedSet}; use near_sdk::json_types::{Base64VecU8, U128}; +use near_sdk::serde::{Deserialize, Serialize}; use near_sdk::{ - env, ext_contract, near_bindgen, AccountId, Balance, Gas, PanicOnDefault, Promise, PublicKey, + env, ext_contract, near_bindgen, AccountId, Balance, Gas, PanicOnDefault, Promise, + PromiseOrValue, PublicKey, ONE_NEAR, }; pub use bridge_common::prover::{validate_eth_address, Proof}; use bridge_common::{parse_recipient, prover::*, result_types, Recipient}; pub use lock_event::EthLockedEvent; pub use log_metadata_event::TokenMetadataEvent; -use near_sdk_inner::{PromiseOrValue, ONE_NEAR}; mod lock_event; mod log_metadata_event; @@ -43,6 +47,13 @@ const OUTER_SET_METADATA_GAS: Gas = Gas(Gas::ONE_TERA.0 * 15); /// Amount of gas used by bridge token to set the metadata. const SET_METADATA_GAS: Gas = Gas(Gas::ONE_TERA.0 * 5); +/// Amount of gas used by bridge token to pause withdraw. +const SET_PAUSED_GAS: Gas = Gas(Gas::ONE_TERA.0 * 5); + +/// Amount of gas used by `upgrade_bridge_token` in the factory, without taking into account +/// the gas consumed by the promise. +const OUTER_UPGRADE_TOKEN_GAS: Gas = Gas(Gas::ONE_TERA.0 * 15); + /// Controller storage key. const CONTROLLER_STORAGE_KEY: &[u8] = b"aCONTROLLER"; @@ -54,11 +65,33 @@ const METADATA_CONNECTOR_ETH_ADDRESS_STORAGE_KEY: &[u8] = b"aM_CONNECTOR"; /// The prefix is made specially short since it becomes more expensive with larger prefixes. const TOKEN_TIMESTAMP_MAP_PREFIX: &[u8] = b"aTT"; -const PAUSE_DEPLOY_TOKEN: Mask = 1 << 0; -const PAUSE_DEPOSIT: Mask = 1 << 1; +pub type Mask = u128; + +#[derive(AccessControlRole, Deserialize, Serialize, Copy, Clone)] +#[serde(crate = "near_sdk::serde")] +pub enum Role { + DAO, + PauseManager, + TokenUpgradableManager, + MetadataManager, + UnrestrictedDeposit, + UnrestrictedDeployBridgeToken, + UnrestrictedUpdateMetadata, + UpgradableCodeStager, + UpgradableCodeDeployer, +} #[near_bindgen] -#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)] +#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault, Pausable, Upgradable)] +#[access_control(role_type(Role))] +#[pausable(manager_roles(Role::PauseManager, Role::DAO))] +#[upgradable(access_control_roles( + code_stagers(Role::UpgradableCodeStager, Role::DAO), + code_deployers(Role::UpgradableCodeDeployer, Role::DAO), + duration_initializers(Role::DAO), + duration_update_stagers(Role::DAO), + duration_update_appliers(Role::DAO), +))] pub struct BridgeTokenFactory { /// The account of the prover that we can use to prove pub prover_account: AccountId, @@ -69,10 +102,12 @@ pub struct BridgeTokenFactory { /// Hashes of the events that were already used. pub used_events: UnorderedSet>, /// Public key of the account deploying the factory. + #[deprecated] pub owner_pk: PublicKey, /// Balance required to register a new account in the BridgeToken pub bridge_token_storage_deposit_required: Balance, /// Mask determining all paused functions + #[deprecated] paused: Mask, } @@ -104,11 +139,6 @@ pub trait ExtBridgeTokenFactory { ) -> Promise; } -#[ext_contract(ext_fungible_token)] -pub trait FungibleToken { - fn ft_transfer(&mut self, receiver_id: AccountId, amount: U128, memo: Option); -} - #[ext_contract(ext_bridge_token)] pub trait ExtBridgeToken { fn mint(&self, account_id: AccountId, amount: U128); @@ -130,6 +160,8 @@ pub trait ExtBridgeToken { decimals: Option, icon: Option, ); + + fn set_paused(&mut self, paused: bool); } pub fn assert_self() { @@ -144,7 +176,8 @@ impl BridgeTokenFactory { #[init] pub fn new(prover_account: AccountId, locker_address: String) -> Self { assert!(!env::state_exists(), "Already initialized"); - Self { + #[allow(deprecated)] + let mut contract = Self { prover_account, locker_address: validate_eth_address(locker_address), tokens: UnorderedSet::new(b"t".to_vec()), @@ -155,9 +188,13 @@ impl BridgeTokenFactory { .account_storage_usage as Balance * env::storage_byte_cost(), paused: Mask::default(), - } + }; + + contract.acl_init_super_admin(near_sdk::env::predecessor_account_id()); + contract } + #[pause(except(roles(Role::DAO, Role::UnrestrictedUpdateMetadata)))] pub fn update_metadata(&mut self, #[serializer(borsh)] proof: Proof) -> Promise { let event = TokenMetadataEvent::from_log_entry_data(&proof.log_entry_data); @@ -216,8 +253,8 @@ impl BridgeTokenFactory { /// Deposit from Ethereum to NEAR based on the proof of the locked tokens. /// Must attach enough NEAR funds to cover for storage of the proof. #[payable] + #[pause(except(roles(Role::DAO, Role::UnrestrictedDeposit)))] pub fn deposit(&mut self, #[serializer(borsh)] proof: Proof) -> Promise { - self.check_not_paused(PAUSE_DEPOSIT); let event = EthLockedEvent::from_log_entry_data(&proof.log_entry_data); assert_eq!( event.locker_address, @@ -383,8 +420,8 @@ impl BridgeTokenFactory { } #[payable] + #[pause(except(roles(Role::DAO, Role::UnrestrictedDeployBridgeToken)))] pub fn deploy_bridge_token(&mut self, address: String) -> Promise { - self.check_not_paused(PAUSE_DEPLOY_TOKEN); let address = address.to_lowercase(); let _ = validate_eth_address(address.clone()); assert!( @@ -404,7 +441,6 @@ impl BridgeTokenFactory { Promise::new(bridge_token_account_id.parse().unwrap()) .create_account() .transfer(BRIDGE_TOKEN_INIT_BALANCE) - .add_full_access_key(self.owner_pk.clone()) .deploy_contract(BRIDGE_TOKEN_BINARY.to_vec()) .function_call( "new".to_string(), @@ -414,6 +450,36 @@ impl BridgeTokenFactory { ) } + /// Upgrades and migrates the bridge token contract to the current version. + /// + /// # Arguments + /// + /// * `address`: Ethereum address of the token ERC20 contract, in hexadecimal format without `0x`. + /// + #[access_control_any(roles(Role::DAO, Role::TokenUpgradableManager))] + pub fn upgrade_bridge_token(&self, address: String) -> Promise { + Promise::new(self.get_bridge_token_account_id(address)).function_call( + "upgrade_and_migrate".to_string(), + BRIDGE_TOKEN_BINARY.into(), + 0, + env::prepaid_gas() - OUTER_UPGRADE_TOKEN_GAS, + ) + } + + /// Pause or unpause the withdraw method in the bridge token contract. + /// + /// # Arguments + /// + /// * `address`: Ethereum address of the token ERC20 contract, in hexadecimal format without `0x`. + /// * `paused`: `true` to pause the withdraw method in the bridge token contract, `false` to unpause. + /// + #[access_control_any(roles(Role::DAO, Role::PauseManager))] + pub fn set_paused_withdraw(&mut self, address: String, paused: bool) -> Promise { + ext_bridge_token::ext(self.get_bridge_token_account_id(address)) + .with_static_gas(SET_PAUSED_GAS) + .set_paused(paused) + } + pub fn get_bridge_token_account_id(&self, address: String) -> AccountId { let address = address.to_lowercase(); let _ = validate_eth_address(address.clone()); @@ -452,7 +518,8 @@ impl BridgeTokenFactory { required_deposit } - /// Admin method to set metadata with admin/controller access + /// Admin method to set metadata + #[access_control_any(roles(Role::DAO, Role::MetadataManager))] pub fn set_metadata( &mut self, address: String, @@ -463,7 +530,6 @@ impl BridgeTokenFactory { decimals: Option, icon: Option, ) -> Promise { - assert!(self.controller_or_self()); ext_bridge_token::ext(self.get_bridge_token_account_id(address)) .with_static_gas(env::prepaid_gas() - OUTER_SET_METADATA_GAS) .with_attached_deposit(env::attached_deposit()) @@ -486,21 +552,6 @@ impl BridgeTokenFactory { }) } - pub fn set_controller(&mut self, controller: AccountId) { - assert!(self.controller_or_self()); - assert!(env::is_valid_account_id(controller.as_bytes())); - env::storage_write(CONTROLLER_STORAGE_KEY, controller.as_bytes()); - } - - pub fn controller_or_self(&self) -> bool { - let caller = env::predecessor_account_id(); - caller == env::current_account_id() - || self - .controller() - .map(|controller| controller == caller) - .unwrap_or(false) - } - /// Ethereum Metadata Connector. This is the address where the contract that emits metadata from tokens /// on ethereum is deployed. Address is encoded as hex. pub fn metadata_connector(&self) -> Option { @@ -508,17 +559,19 @@ impl BridgeTokenFactory { .map(|value| String::from_utf8(value).expect("Invalid metadata connector address")) } + #[access_control_any(roles(Role::DAO))] pub fn set_metadata_connector(&mut self, metadata_connector: String) { - assert!(self.controller_or_self()); validate_eth_address(metadata_connector.clone()); env::storage_write( METADATA_CONNECTOR_ETH_ADDRESS_STORAGE_KEY, metadata_connector.as_bytes(), ); } -} -admin_controlled::impl_admin_controlled!(BridgeTokenFactory, paused); + pub fn version(&self) -> String { + env!("CARGO_PKG_VERSION").to_owned() + } +} #[cfg(not(target_arch = "wasm32"))] #[cfg(test)] @@ -533,8 +586,6 @@ mod tests { use super::*; - const UNPAUSE_ALL: Mask = 0; - macro_rules! inner_set_env { ($builder:ident) => { $builder @@ -569,6 +620,10 @@ mod tests { "bridge".parse().unwrap() } + fn pause_manager() -> AccountId { + "pause_manager".parse().unwrap() + } + fn token_locker() -> String { "6b175474e89094c44da98b954eedeac495271d0f".to_string() } @@ -700,10 +755,23 @@ mod tests { #[test] fn deploy_bridge_token_paused() { - set_env!(predecessor_account_id: alice()); + set_env!( + current_account_id: bridge_token_factory(), + predecessor_account_id: bridge_token_factory(), + ); // User alice can deploy a new bridge token let mut contract = BridgeTokenFactory::new(prover(), token_locker()); + assert!(contract + .acl_grant_role("PauseManager".to_owned(), pause_manager()) + .unwrap()); + let unrestricted_deploy_account: AccountId = "unrestricted_account".parse().unwrap(); + assert!(contract + .acl_grant_role( + "UnrestrictedDeployBridgeToken".to_owned(), + unrestricted_deploy_account.clone() + ) + .unwrap()); set_env!( current_account_id: bridge_token_factory(), predecessor_account_id: alice(), @@ -711,20 +779,20 @@ mod tests { ); contract.deploy_bridge_token(ethereum_address_from_id(0)); - // Admin pause deployment of new token + // Pause manager pause deployment of new token set_env!( current_account_id: bridge_token_factory(), - predecessor_account_id: bridge_token_factory(), + predecessor_account_id: pause_manager(), attached_deposit: BRIDGE_TOKEN_INIT_BALANCE * 2 ); - contract.set_paused(PAUSE_DEPLOY_TOKEN); + contract.pa_pause_feature("deploy_bridge_token".to_string()); set_env!( current_account_id: bridge_token_factory(), - predecessor_account_id: bridge_token_factory(), + predecessor_account_id: unrestricted_deploy_account, attached_deposit: BRIDGE_TOKEN_INIT_BALANCE * 2 ); - // Admin can still deploy new tokens after paused + // Account with role `UnrestrictedDeployBridgeToken` can still deploy new tokens after paused contract.deploy_bridge_token(ethereum_address_from_id(1)); // User alice can't deploy a new bridge token when it is paused @@ -740,16 +808,22 @@ mod tests { } #[test] - fn only_admin_can_pause() { - set_env!(predecessor_account_id: alice()); - let mut contract = BridgeTokenFactory::new(prover(), token_locker()); - - // Admin can pause + fn only_pause_manager_can_pause() { set_env!( current_account_id: bridge_token_factory(), predecessor_account_id: bridge_token_factory(), ); - contract.set_paused(0b1111); + let mut contract = BridgeTokenFactory::new(prover(), token_locker()); + assert!(contract + .acl_grant_role("PauseManager".to_owned(), pause_manager()) + .unwrap()); + + // Pause manager can pause + set_env!( + current_account_id: pause_manager(), + predecessor_account_id: pause_manager(), + ); + assert!(contract.pa_pause_feature("deposit".to_string())); // Alice can't pause set_env!( @@ -758,15 +832,21 @@ mod tests { ); panic::catch_unwind(move || { - contract.set_paused(0); + contract.pa_pause_feature("deposit".to_string()); }) .unwrap_err(); } #[test] fn deposit_paused() { - set_env!(predecessor_account_id: alice()); + set_env!( + current_account_id: bridge_token_factory(), + predecessor_account_id: bridge_token_factory(), + ); let mut contract = BridgeTokenFactory::new(prover(), token_locker()); + assert!(contract + .acl_grant_role("PauseManager".to_owned(), pause_manager()) + .unwrap()); set_env!( current_account_id: bridge_token_factory(), @@ -782,10 +862,10 @@ mod tests { // Pause deposit set_env!( current_account_id: bridge_token_factory(), - predecessor_account_id: bridge_token_factory(), + predecessor_account_id: pause_manager(), attached_deposit: BRIDGE_TOKEN_INIT_BALANCE * 2 ); - contract.set_paused(PAUSE_DEPOSIT); + contract.pa_pause_feature("deposit".to_string()); set_env!( current_account_id: bridge_token_factory(), @@ -803,8 +883,14 @@ mod tests { /// Check after all is paused deposit is not available #[test] fn all_paused() { - set_env!(predecessor_account_id: alice()); + set_env!( + current_account_id: bridge_token_factory(), + predecessor_account_id: bridge_token_factory(), + ); let mut contract = BridgeTokenFactory::new(prover(), token_locker()); + assert!(contract + .acl_grant_role("PauseManager".to_owned(), pause_manager()) + .unwrap()); set_env!( current_account_id: bridge_token_factory(), @@ -820,10 +906,10 @@ mod tests { // Pause everything set_env!( current_account_id: bridge_token_factory(), - predecessor_account_id: bridge_token_factory(), + predecessor_account_id: pause_manager(), attached_deposit: BRIDGE_TOKEN_INIT_BALANCE * 2 ); - contract.set_paused(PAUSE_DEPLOY_TOKEN | PAUSE_DEPOSIT); + contract.pa_pause_feature("ALL".to_string()); set_env!( current_account_id: bridge_token_factory(), @@ -841,8 +927,14 @@ mod tests { /// Check after all is paused and unpaused deposit works #[test] fn no_paused() { - set_env!(predecessor_account_id: alice()); + set_env!( + current_account_id: bridge_token_factory(), + predecessor_account_id: bridge_token_factory(), + ); let mut contract = BridgeTokenFactory::new(prover(), token_locker()); + assert!(contract + .acl_grant_role("PauseManager".to_owned(), pause_manager()) + .unwrap()); set_env!( current_account_id: bridge_token_factory(), @@ -858,12 +950,12 @@ mod tests { // Pause everything set_env!( current_account_id: bridge_token_factory(), - predecessor_account_id: bridge_token_factory(), + predecessor_account_id: pause_manager(), attached_deposit: BRIDGE_TOKEN_INIT_BALANCE * 2 ); - contract.set_paused(PAUSE_DEPLOY_TOKEN | PAUSE_DEPOSIT); - contract.set_paused(UNPAUSE_ALL); + contract.pa_pause_feature("ALL".to_string()); + contract.pa_unpause_feature("ALL".to_string()); set_env!( current_account_id: bridge_token_factory(), diff --git a/bridge-token-factory/tests/token_transfer.rs b/bridge-token-factory/tests/token_transfer.rs index 3ae2d6a2..4b2fa307 100644 --- a/bridge-token-factory/tests/token_transfer.rs +++ b/bridge-token-factory/tests/token_transfer.rs @@ -2,7 +2,6 @@ use bridge_token_factory::{validate_eth_address, EthLockedEvent, Proof}; use near_sdk::borsh::{self, BorshSerialize}; use near_sdk::{AccountId, Balance, ONE_NEAR, ONE_YOCTO}; use serde_json::json; -use tokio::runtime::Runtime; use workspaces::result::ExecutionFinalResult; use workspaces::{network::Sandbox, Account, Contract, Worker}; @@ -13,58 +12,50 @@ const SENDER_ADDRESS: &str = "00005474e89094c44da98b954eedeac495271d0f"; const ALICE: &str = "alice.test.near"; const FACTORY_WASM_PATH: &str = "../res/bridge_token_factory.wasm"; +const FACTORY_WASM_PATH_V_0_1_6: &str = "res/bridge_token_factory_v0.1.6.wasm"; +const BRIDGE_TOKEN_WASM_PATH: &str = "../res/bridge_token.wasm"; const MOCK_PROVER_WASM_PATH: &str = "../res/mock_prover.wasm"; const DEFAULT_DEPOSIT: u128 = ONE_NEAR; -fn create_contract() -> (Account, Contract, Worker) { - let rt = Runtime::new().unwrap(); - - let worker: Worker = rt.block_on(workspaces::sandbox()).unwrap(); +async fn create_contract(factory_wasm_path: &str) -> (Account, Contract, Worker) { + let worker: Worker = workspaces::sandbox().await.unwrap(); let prover_wasm = std::fs::read(MOCK_PROVER_WASM_PATH).unwrap(); - let prover_contract: Contract = rt.block_on(worker.dev_deploy(&prover_wasm)).unwrap(); + let prover_contract: Contract = worker.dev_deploy(&prover_wasm).await.unwrap(); let prover_id = prover_contract.id(); let owner = worker.root_account().unwrap(); - let factory_account = rt - .block_on( - owner - .create_subaccount(FACTORY) - .initial_balance(200 * ONE_NEAR) - .transact(), - ) + let factory_account = owner + .create_subaccount(FACTORY) + .initial_balance(200 * ONE_NEAR) + .transact() + .await .unwrap() .into_result() .unwrap(); - let factory_wasm = std::fs::read(FACTORY_WASM_PATH).unwrap(); - let factory_contract: Contract = rt - .block_on(factory_account.deploy(&factory_wasm)) - .unwrap() - .result; + let factory_wasm = std::fs::read(factory_wasm_path).unwrap(); + let factory_contract: Contract = factory_account.deploy(&factory_wasm).await.unwrap().result; - let alice = rt - .block_on( - owner - .create_subaccount("alice") - .initial_balance(200 * ONE_NEAR) - .transact(), - ) + let alice = owner + .create_subaccount("alice") + .initial_balance(200 * ONE_NEAR) + .transact() + .await .unwrap() .into_result() .unwrap(); - let _result = rt.block_on( - alice - .call(factory_contract.id(), "new") - .args( - json!({"prover_account": prover_id, "locker_address": LOCKER_ADDRESS.to_string()}) - .to_string() - .into_bytes(), - ) - .transact(), - ) - .unwrap(); + let _result = factory_account + .call(factory_contract.id(), "new") + .args( + json!({"prover_account": prover_id, "locker_address": LOCKER_ADDRESS.to_string()}) + .to_string() + .into_bytes(), + ) + .transact() + .await + .unwrap(); (alice, factory_contract, worker) } @@ -104,57 +95,55 @@ fn remove_quotes(s: &mut String) -> String { s.to_string() } -fn run_view_function( - rt: &Runtime, +async fn run_view_function( contract_id: &String, worker: &Worker, function: &str, args: serde_json::Value, ) -> String { let mut res = std::str::from_utf8( - &rt.block_on(worker.view( - &contract_id.parse().unwrap(), - function, - args.to_string().into_bytes(), - )) - .unwrap() - .result, + &worker + .view( + &contract_id.parse().unwrap(), + function, + args.to_string().into_bytes(), + ) + .await + .unwrap() + .result, ) .unwrap() .to_string(); remove_quotes(&mut res) } -#[test] -fn test_eth_token_transfer() { - let (alice, factory, worker) = create_contract(); - let rt = Runtime::new().unwrap(); +#[tokio::test] +async fn test_eth_token_transfer() { + let (alice, factory, worker) = create_contract(FACTORY_WASM_PATH).await; const INIT_ALICE_BALANCE: u64 = 1000; const WITHDRAW_AMOUNT: u64 = 100; - assert!(&rt - .block_on( - alice - .call(factory.id(), "deploy_bridge_token") - .deposit(35 * ONE_NEAR) - .args( - json!({"address": DAI_ADDRESS.to_string()}) - .to_string() - .into_bytes() - ) - .max_gas() - .transact() + assert!(alice + .call(factory.id(), "deploy_bridge_token") + .deposit(35 * ONE_NEAR) + .args( + json!({"address": DAI_ADDRESS.to_string()}) + .to_string() + .into_bytes() ) + .max_gas() + .transact() + .await .unwrap() .is_success()); let token_account_id: String = run_view_function( - &rt, &factory.id().to_string(), &worker, "get_bridge_token_account_id", json!({"address": DAI_ADDRESS.to_string()}), - ); + ) + .await; assert_eq!( token_account_id, @@ -162,22 +151,17 @@ fn test_eth_token_transfer() { ); let alice_balance: String = run_view_function( - &rt, &token_account_id, &worker, "ft_balance_of", json!({ "account_id": ALICE }), - ); + ) + .await; assert_eq!(alice_balance, "0"); - let total_supply: String = run_view_function( - &rt, - &token_account_id, - &worker, - "ft_total_supply", - json!({}), - ); + let total_supply: String = + run_view_function(&token_account_id, &worker, "ft_total_supply", json!({})).await; assert_eq!(total_supply, "0"); let mut proof = Proof::default(); @@ -190,107 +174,91 @@ fn test_eth_token_transfer() { } .to_log_entry_data(); - assert!(&rt - .block_on( - alice - .call(factory.id(), "deposit") - .deposit(DEFAULT_DEPOSIT) - .max_gas() - .args(proof.try_to_vec().unwrap()) - .transact() - ) + assert!(alice + .call(factory.id(), "deposit") + .deposit(DEFAULT_DEPOSIT) + .max_gas() + .args(proof.try_to_vec().unwrap()) + .transact() + .await .unwrap() .is_success()); let alice_balance: String = run_view_function( - &rt, &token_account_id, &worker, "ft_balance_of", json!({ "account_id": ALICE }), - ); + ) + .await; assert_eq!(alice_balance, format!("{}", INIT_ALICE_BALANCE)); - let total_supply: String = run_view_function( - &rt, - &token_account_id, - &worker, - "ft_total_supply", - json!({}), - ); + let total_supply: String = + run_view_function(&token_account_id, &worker, "ft_total_supply", json!({})).await; assert_eq!(total_supply, format!("{}", INIT_ALICE_BALANCE)); - assert!(&rt - .block_on( - alice - .call(&token_account_id.parse().unwrap(), "withdraw") - .max_gas() - .deposit(ONE_YOCTO) - .args( - json!({ - "amount" : format!("{}", WITHDRAW_AMOUNT), - "recipient" : SENDER_ADDRESS.to_string() - }) - .to_string() - .into_bytes(), - ) - .transact(), + assert!(alice + .call(&token_account_id.parse().unwrap(), "withdraw") + .max_gas() + .deposit(ONE_YOCTO) + .args( + json!({ + "amount" : format!("{}", WITHDRAW_AMOUNT), + "recipient" : SENDER_ADDRESS.to_string() + }) + .to_string() + .into_bytes(), ) + .transact() + .await .unwrap() .is_success()); let alice_balance: String = run_view_function( - &rt, &token_account_id, &worker, "ft_balance_of", json!({ "account_id": ALICE }), - ); + ) + .await; assert_eq!( alice_balance, format!("{}", INIT_ALICE_BALANCE - WITHDRAW_AMOUNT) ); - let total_supply: String = run_view_function( - &rt, - &token_account_id, - &worker, - "ft_total_supply", - json!({}), - ); + let total_supply: String = + run_view_function(&token_account_id, &worker, "ft_total_supply", json!({})).await; assert_eq!( total_supply, format!("{}", INIT_ALICE_BALANCE - WITHDRAW_AMOUNT) ); } -#[test] -fn test_with_invalid_proof() { - let (user, factory, worker) = create_contract(); - let rt = Runtime::new().unwrap(); - - assert!(&rt - .block_on( - user.call(factory.id(), "deploy_bridge_token") - .deposit(35 * ONE_NEAR) - .args( - json!({"address": DAI_ADDRESS.to_string()}) - .to_string() - .into_bytes() - ) - .max_gas() - .transact() +#[tokio::test] +async fn test_with_invalid_proof() { + let (user, factory, worker) = create_contract(FACTORY_WASM_PATH).await; + + assert!(user + .call(factory.id(), "deploy_bridge_token") + .deposit(35 * ONE_NEAR) + .args( + json!({"address": DAI_ADDRESS.to_string()}) + .to_string() + .into_bytes() ) + .max_gas() + .transact() + .await .unwrap() .is_success()); let token_account_id: String = run_view_function( - &rt, &factory.id().to_string(), &worker, "get_bridge_token_account_id", json!({"address": DAI_ADDRESS.to_string()}), - ); + ) + .await; assert_eq!( token_account_id, @@ -313,12 +281,12 @@ fn test_with_invalid_proof() { proof.proof = vec![vec![]]; assert_error( - &rt.block_on( - user.call(factory.id(), "deposit") - .max_gas() - .args(proof.try_to_vec().unwrap()) - .transact(), - ), + &user + .call(factory.id(), "deposit") + .max_gas() + .args(proof.try_to_vec().unwrap()) + .transact() + .await, "Failed to verify the proof", ); @@ -327,47 +295,44 @@ fn test_with_invalid_proof() { // This deposit event must succeed. Notice that previously a similar deposit // was made, but it failed because it had an invalid proof, so this one should succeed. - assert!(&rt - .block_on( - user.call(factory.id(), "deposit") - .max_gas() - .deposit(DEFAULT_DEPOSIT) - .args(proof.try_to_vec().unwrap()) - .transact() - ) + assert!(user + .call(factory.id(), "deposit") + .max_gas() + .deposit(DEFAULT_DEPOSIT) + .args(proof.try_to_vec().unwrap()) + .transact() + .await .unwrap() .is_success()); // This deposit event must fail since same deposit event can't be reused. // Previous call to deposit with the same event was successful. assert_error( - &rt.block_on( - user.call(factory.id(), "deposit") - .max_gas() - .args(proof.try_to_vec().unwrap()) - .transact(), - ), + &user + .call(factory.id(), "deposit") + .max_gas() + .args(proof.try_to_vec().unwrap()) + .transact() + .await, "Event cannot be reused for depositing.", ); } -#[test] -fn test_bridge_token_failures() { - let (user, factory, _worker) = create_contract(); - let rt = Runtime::new().unwrap(); - - assert!(&rt - .block_on( - user.call(factory.id(), "deploy_bridge_token") - .deposit(35 * ONE_NEAR) - .args( - json!({"address": DAI_ADDRESS.to_string()}) - .to_string() - .into_bytes() - ) - .max_gas() - .transact() +#[tokio::test] +async fn test_bridge_token_failures() { + let (user, factory, _worker) = create_contract(FACTORY_WASM_PATH).await; + + assert!(user + .call(factory.id(), "deploy_bridge_token") + .deposit(35 * ONE_NEAR) + .args( + json!({"address": DAI_ADDRESS.to_string()}) + .to_string() + .into_bytes() ) + .max_gas() + .transact() + .await .unwrap() .is_success()); @@ -375,20 +340,20 @@ fn test_bridge_token_failures() { // Fail to withdraw because the account is not registered (and have no coins) assert_error( - &rt.block_on( - user.call(&token_account_id.parse().unwrap(), "withdraw") - .max_gas() - .deposit(ONE_YOCTO) - .args( - json!({ - "amount" : "100", - "recipient" : SENDER_ADDRESS.to_string() - }) - .to_string() - .into_bytes(), - ) - .transact(), - ), + &user + .call(&token_account_id.parse().unwrap(), "withdraw") + .max_gas() + .deposit(ONE_YOCTO) + .args( + json!({ + "amount" : "100", + "recipient" : SENDER_ADDRESS.to_string() + }) + .to_string() + .into_bytes(), + ) + .transact() + .await, " is not registered", ); @@ -396,127 +361,311 @@ fn test_bridge_token_failures() { let account_id: Option = None; let registration_only: Option = None; - assert!(&rt - .block_on( - user.call(&token_account_id.parse().unwrap(), "storage_deposit") - .max_gas() - .args( - json!({ - "account_id": account_id, - "registration_only": registration_only - }) - .to_string() - .into_bytes() - ) - .deposit(DEFAULT_DEPOSIT) - .transact() + assert!(user + .call(&token_account_id.parse().unwrap(), "storage_deposit") + .max_gas() + .args( + json!({ + "account_id": account_id, + "registration_only": registration_only + }) + .to_string() + .into_bytes() ) + .deposit(DEFAULT_DEPOSIT) + .transact() + .await .unwrap() .is_success()); // Fail to withdraw because the account has no enough balance assert_error( - &rt.block_on( - user.call(&token_account_id.parse().unwrap(), "withdraw") - .max_gas() - .args( - json!({ - "amount" : "100", - "recipient" : SENDER_ADDRESS.to_string() - }) - .to_string() - .into_bytes(), - ) - .deposit(ONE_YOCTO) - .transact(), - ), + &user + .call(&token_account_id.parse().unwrap(), "withdraw") + .max_gas() + .args( + json!({ + "amount" : "100", + "recipient" : SENDER_ADDRESS.to_string() + }) + .to_string() + .into_bytes(), + ) + .deposit(ONE_YOCTO) + .transact() + .await, "The account doesn't have enough balance", ); - let other_user = rt - .block_on( - user.create_subaccount("bob") - .initial_balance(50 * ONE_NEAR) - .transact(), - ) + let other_user = user + .create_subaccount("bob") + .initial_balance(50 * ONE_NEAR) + .transact() + .await .unwrap() .into_result() .unwrap(); // Fail to mint because the caller is not the controller assert_error( - &rt.block_on( - other_user - .call(&token_account_id.parse().unwrap(), "mint") - .max_gas() - .args( - json!({ - "account_id" : ALICE.to_string(), - "amount" : "100" - }) - .to_string() - .into_bytes(), - ) - .deposit(ONE_YOCTO) - .transact(), - ), + &other_user + .call(&token_account_id.parse().unwrap(), "mint") + .max_gas() + .args( + json!({ + "account_id" : ALICE.to_string(), + "amount" : "100" + }) + .to_string() + .into_bytes(), + ) + .deposit(ONE_YOCTO) + .transact() + .await, "Only controller can call mint", ); } -#[test] -fn test_deploy_failures() { - let (user, factory, _worker) = create_contract(); - let rt = Runtime::new().unwrap(); +#[tokio::test] +async fn test_deploy_failures() { + let (user, factory, _worker) = create_contract(FACTORY_WASM_PATH).await; // Fails with not enough deposit. assert_error( - &rt.block_on( - user.call(factory.id(), "deploy_bridge_token") - .deposit(0) - .args(json!({ "address": DAI_ADDRESS }).to_string().into_bytes()) - .max_gas() - .transact(), - ), + &user + .call(factory.id(), "deploy_bridge_token") + .deposit(0) + .args(json!({ "address": DAI_ADDRESS }).to_string().into_bytes()) + .max_gas() + .transact() + .await, "Not enough attached deposit to complete bridge token creation", ); // Fails with address is invalid. assert_error( - &rt.block_on( - user.call(factory.id(), "deploy_bridge_token") - .deposit(0) - .args(json!({"address": "not_a_hex"}).to_string().into_bytes()) - .max_gas() - .transact(), - ), + &user + .call(factory.id(), "deploy_bridge_token") + .deposit(0) + .args(json!({"address": "not_a_hex"}).to_string().into_bytes()) + .max_gas() + .transact() + .await, "address should be a valid hex string.: OddLength", ); // Fails second time because already exists. - assert!(&rt - .block_on( - user.call(factory.id(), "deploy_bridge_token") - .deposit(35 * ONE_NEAR) - .args( - json!({"address": DAI_ADDRESS.to_string()}) - .to_string() - .into_bytes() - ) - .max_gas() - .transact() + assert!(user + .call(factory.id(), "deploy_bridge_token") + .deposit(35 * ONE_NEAR) + .args( + json!({"address": DAI_ADDRESS.to_string()}) + .to_string() + .into_bytes() ) + .max_gas() + .transact() + .await .unwrap() .is_success()); assert_error( - &rt.block_on( - user.call(factory.id(), "deploy_bridge_token") - .deposit(35 * ONE_NEAR) - .args(json!({ "address": DAI_ADDRESS }).to_string().into_bytes()) - .max_gas() - .transact(), - ), + &user + .call(factory.id(), "deploy_bridge_token") + .deposit(35 * ONE_NEAR) + .args(json!({ "address": DAI_ADDRESS }).to_string().into_bytes()) + .max_gas() + .transact() + .await, "BridgeToken contract already exists.", ); } + +#[tokio::test] +async fn test_upgrade() { + let (alice, factory, worker) = create_contract(FACTORY_WASM_PATH_V_0_1_6).await; + + let token_account = Account::from_secret_key( + format!("{}.{}", DAI_ADDRESS, factory.id()).parse().unwrap(), + factory.as_account().secret_key().clone(), + &worker, + ); + + assert!(alice + .call(factory.id(), "deploy_bridge_token") + .deposit(35 * ONE_NEAR) + .args( + json!({"address": DAI_ADDRESS.to_string()}) + .to_string() + .into_bytes() + ) + .max_gas() + .transact() + .await + .unwrap() + .is_success()); + + let token_account_id: String = factory + .view( + "get_bridge_token_account_id", + json!({"address": DAI_ADDRESS.to_string()}) + .to_string() + .into_bytes(), + ) + .await + .unwrap() + .json() + .unwrap(); + + assert_eq!(token_account_id, token_account.id().to_string()); + + // Deploy new version + let factory = factory + .as_account() + .deploy(&(std::fs::read(FACTORY_WASM_PATH).unwrap())) + .await + .unwrap() + .result; + + let token_account_id: String = factory + .view( + "get_bridge_token_account_id", + json!({"address": DAI_ADDRESS.to_string()}) + .to_string() + .into_bytes(), + ) + .await + .unwrap() + .json() + .unwrap(); + + assert_eq!(token_account_id, token_account.id().to_string()); + + // Verify the factory version + let factory_version: String = factory + .view("version", "".as_bytes().to_vec()) + .await + .unwrap() + .json() + .unwrap(); + assert_eq!(factory_version, "0.2.0"); + + // Set alice as super admin + let result = factory + .call("acl_init_super_admin") + .args( + json!({ + "account_id": alice.id().to_string() + }) + .to_string() + .into_bytes(), + ) + .max_gas() + .transact() + .await + .unwrap(); + + let result: bool = result.json().unwrap(); + assert!(result); + + // Grant alice the `TokenUpgradableManager` role + let result = alice + .call(factory.id(), "acl_grant_role") + .args( + json!({ + "role": "TokenUpgradableManager", + "account_id": alice.id().to_string() + }) + .to_string() + .into_bytes(), + ) + .max_gas() + .transact() + .await + .unwrap(); + let result: bool = result.json().unwrap(); + assert!(result); + + // Upgrade the bridge token directly because self-upgrade is not supported in version `0.1.6` + let _token_contract = token_account + .deploy(&std::fs::read(BRIDGE_TOKEN_WASM_PATH).unwrap()) + .await + .unwrap() + .result; + + // Verify the bridge token version + let token_version: String = worker + .view(token_account.id(), "version", vec![]) + .await + .unwrap() + .json() + .unwrap(); + assert_eq!(token_version, "0.2.0"); + + // Upgrade the bridge token over factory (redeploy the same version) + let result = alice + .call(factory.id(), "upgrade_bridge_token") + .args( + json!({"address": DAI_ADDRESS.to_string()}) + .to_string() + .into_bytes(), + ) + .max_gas() + .transact() + .await + .unwrap(); + assert!(result.is_success()); + + // Verify the bridge token version + let token_version: String = worker + .view(token_account.id(), "version", vec![]) + .await + .unwrap() + .json() + .unwrap(); + assert_eq!(token_version, "0.2.0"); + + // Grant alice the `PauseManager` role + let result = alice + .call(factory.id(), "acl_grant_role") + .args( + json!({ + "role": "PauseManager", + "account_id": alice.id().to_string() + }) + .to_string() + .into_bytes(), + ) + .max_gas() + .transact() + .await + .unwrap(); + let result: bool = result.json().unwrap(); + assert!(result); + + // Pause bridge token withdraw + let result = alice + .call(factory.id(), "set_paused_withdraw") + .args( + json!({"address": DAI_ADDRESS.to_string(), "paused": true}) + .to_string() + .into_bytes(), + ) + .max_gas() + .transact() + .await + .unwrap(); + println!("{:?}", result); + assert!(result.is_success()); + + // Verify bridge token is paused + let is_paused: bool = alice + .call(token_account.id(), "is_paused") + .max_gas() + .transact() + .await + .unwrap() + .json() + .unwrap(); + assert!(is_paused); +} diff --git a/bridge-token/Cargo.lock b/bridge-token/Cargo.lock index a1093621..62b93809 100644 --- a/bridge-token/Cargo.lock +++ b/bridge-token/Cargo.lock @@ -8,25 +8,26 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -[[package]] -name = "admin-controlled" -version = "0.1.0" -source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" -dependencies = [ - "near-sdk", -] - [[package]] name = "ahash" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", "once_cell", "version_check", ] +[[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" @@ -47,9 +48,9 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" @@ -59,9 +60,9 @@ checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" [[package]] name = "base64" -version = "0.13.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "bitvec" @@ -92,25 +93,18 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "block-padding", "generic-array", ] [[package]] name = "block-buffer" -version = "0.10.2" +version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf7fe51849ea569fd452f37822f606a5cabb684dc918707a0193fd4664ff324" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" dependencies = [ "generic-array", ] -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - [[package]] name = "borsh" version = "0.9.3" @@ -158,9 +152,8 @@ dependencies = [ [[package]] name = "bridge-token" -version = "0.1.0" +version = "0.2.0" dependencies = [ - "admin-controlled", "near-contract-standards", "near-sdk", ] @@ -173,21 +166,21 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bumpalo" -version = "3.10.0" +version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "byte-slice-cast" -version = "1.2.1" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c5fdd0166095e1d463fc6cc01aa8ce547ad77a4e84d42eb6762b084e28067e" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" [[package]] name = "byteorder" -version = "1.4.2" +version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytesize" @@ -207,9 +200,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.73" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" +checksum = "581f5dba903aac52ea3feb5ec4810848460ee833876f1f9b0fdeab1f19091574" [[package]] name = "cfg-if" @@ -225,10 +218,11 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6127248204b9aba09a362f6c930ef6a78f2c1b2215f8a7b398c06e1083f17af0" +checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1" dependencies = [ + "iana-time-zone", "js-sys", "num-integer", "num-traits", @@ -248,19 +242,35 @@ dependencies = [ ] [[package]] -name = "cpufeatures" -version = "0.2.2" +name = "codespan-reporting" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" dependencies = [ - "libc", + "termcolor", + "unicode-width", ] [[package]] -name = "cpuid-bool" -version = "0.1.2" +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" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8aebca1129a03dc6dc2b127edd729435bbc4a37e1d5f4d7513165089ceb02634" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] [[package]] name = "crunchy" @@ -301,14 +311,60 @@ dependencies = [ "zeroize", ] +[[package]] +name = "cxx" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b7d4e43b25d3c994662706a1d4fcfc32aaa6afd287502c111b237093bb23f3a" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84f8829ddc213e2c1368e51a2564c552b65a8cb6a28f31e576270ac81d5e5827" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e72537424b474af1460806647c41d4b6d35d09ef7fe031c5c2fa5766047cc56a" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "309e4fb93eed90e1e14bea0da16b209f81813ba9fc7830c20ed151dd7bc0a4d7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "derive_more" -version = "0.99.11" +version = "0.99.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" dependencies = [ + "convert_case", "proc-macro2", "quote", + "rustc_version", "syn", ] @@ -323,14 +379,20 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.3" +version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506" +checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c" dependencies = [ - "block-buffer 0.10.2", + "block-buffer 0.10.3", "crypto-common", ] +[[package]] +name = "dyn-clone" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" + [[package]] name = "easy-ext" version = "0.2.9" @@ -356,7 +418,7 @@ dependencies = [ "ed25519", "rand 0.7.3", "serde", - "sha2 0.9.3", + "sha2 0.9.9", "zeroize", ] @@ -380,9 +442,9 @@ checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" [[package]] name = "generic-array" -version = "0.14.4" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" dependencies = [ "typenum", "version_check", @@ -401,9 +463,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if 1.0.0", "libc", @@ -431,6 +493,30 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[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" @@ -453,36 +539,48 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.7" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "js-sys" -version = "0.3.49" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc15e39392125075f60c95ba416f5381ff6c3a948ff02ab12464715adf56c821" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" dependencies = [ "wasm-bindgen", ] [[package]] name = "keccak" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" +checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "libc" -version = "0.2.129" +version = "0.2.137" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64de3cc433455c14174d42e554d4027ee631c4d046d43e3ecc6efc4636cdc7a7" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" + +[[package]] +name = "link-cplusplus" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] [[package]] name = "log" @@ -499,11 +597,23 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" +[[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.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de83d74a9241be8cc4eb3055216966b58bf8c463e8e285c0dc553925acdd19fa" +checksum = "71d258582a1878e6db67400b0504a5099db85718d22c2e07f747fe1706ae7150" dependencies = [ "borsh", "serde", @@ -511,20 +621,21 @@ dependencies = [ [[package]] name = "near-contract-standards" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6466c6aaad18800ff6a3cd104427dc8fd79e144714135224b8289b1dc43f7167" +checksum = "7bacc932e79b26472797adfb21689294b6f90960d1570daaf1e0b682b59fcb35" dependencies = [ "near-sdk", + "schemars", "serde", "serde_json", ] [[package]] name = "near-crypto" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ecf0b8b31aa7f4e60f629f72213a2617ca4a5f45cd1ae9ed2cf7cecfebdbb7" +checksum = "1e75673d69fd7365508f3d32483669fe45b03bfb34e4d9363e90adae9dfb416c" dependencies = [ "arrayref", "blake2", @@ -534,7 +645,6 @@ dependencies = [ "curve25519-dalek", "derive_more", "ed25519-dalek", - "libc", "near-account-id", "once_cell", "parity-secp256k1", @@ -549,9 +659,9 @@ dependencies = [ [[package]] name = "near-primitives" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ba19282e79a4485a77736b679d276b09870bbf8042a18e0f0ae36347489c5" +checksum = "8ad1a9a1640539c81f065425c31bffcfbf6b31ef1aeaade59ce905f5df6ac860" dependencies = [ "borsh", "byteorder", @@ -578,9 +688,9 @@ dependencies = [ [[package]] name = "near-primitives-core" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb561feb392bb8c4f540256073446e6689af087bf6356e8dddcf75fc279f201f" +checksum = "91d508f0fc340f6461e4e256417685720d3c4c00bb5a939b105160e49137caba" dependencies = [ "base64 0.11.0", "borsh", @@ -589,15 +699,15 @@ dependencies = [ "near-account-id", "num-rational", "serde", - "sha2 0.10.2", + "sha2 0.10.6", "strum", ] [[package]] name = "near-rpc-error-core" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77fdd7ea8d8f786878651c37691515d5053f827ae60894aa40c16882b78f77c9" +checksum = "93ee0b41c75ef859c193a8ff1dadfa0c8207bc0ac447cc22259721ad769a1408" dependencies = [ "quote", "serde", @@ -606,9 +716,9 @@ dependencies = [ [[package]] name = "near-rpc-error-macro" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e521842b6ae864dfe5391afbbe2df9e9d8427c26e9333b2e0b65cd42094f7607" +checksum = "8e837bd4bacd807073ec5ceb85708da7f721b46a4c2a978de86027fb0034ce31" dependencies = [ "near-rpc-error-core", "serde", @@ -617,19 +727,22 @@ dependencies = [ [[package]] name = "near-sdk" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda34e06e28fb9a09ac54efbdc49f0c9308780fc932aaa81c49c493fde974045" +checksum = "15eb3de2defe3626260cc209a6cdb985c6b27b0bd4619fad97dcfae002c3c5bd" dependencies = [ - "base64 0.13.0", + "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", @@ -637,9 +750,9 @@ dependencies = [ [[package]] name = "near-sdk-macros" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72064fcc15a623a0d40a6c199ea5cbdc30a83cae4816889d46f218acf31bfba8" +checksum = "4907affc9f5ed559456509188ff0024f1f2099c0830e6bdb66eb61d5b75912c0" dependencies = [ "Inflector", "proc-macro2", @@ -655,9 +768,9 @@ checksum = "e307313276eaeced2ca95740b5639e1f3125b7c97f0a1151809d105f1aa8c6d3" [[package]] name = "near-vm-errors" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e02faf2bc1f6ef82b965cfe44389808fb5594f7aca4b596766117f4ce74df20" +checksum = "d0da466a30f0446639cbd788c30865086fac3e8dcb07a79e51d2b0775ed4261e" dependencies = [ "borsh", "near-account-id", @@ -667,11 +780,11 @@ dependencies = [ [[package]] name = "near-vm-logic" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f024d90451cd3c24d7a0a5cabf3636b192a60eb8e3ff0456f6c18b91152c346d" +checksum = "81b534828419bacbf1f7b11ef7b00420f248c548c485d3f0cfda8bb6931152f2" dependencies = [ - "base64 0.13.0", + "base64 0.13.1", "borsh", "bs58", "byteorder", @@ -682,15 +795,16 @@ dependencies = [ "near-vm-errors", "ripemd", "serde", - "sha2 0.10.2", + "sha2 0.10.6", "sha3", + "zeropool-bn", ] [[package]] name = "num-bigint" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e9a41747ae4633fce5adffb4d2e81ffc5e89593cb19917f8fb2cc5ff76507bf" +checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3" dependencies = [ "autocfg", "num-integer", @@ -699,9 +813,9 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg", "num-traits", @@ -722,18 +836,18 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ "autocfg", ] [[package]] name = "once_cell" -version = "1.13.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "opaque-debug" @@ -781,9 +895,9 @@ dependencies = [ [[package]] name = "ppv-lite86" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "primitive-types" @@ -818,18 +932,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.24" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "quote" -version = "1.0.9" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] @@ -861,7 +975,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha 0.3.1", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -881,7 +995,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -895,11 +1009,11 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.8", ] [[package]] @@ -922,11 +1036,11 @@ dependencies = [ [[package]] name = "ripemd" -version = "0.1.1" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1facec54cb5e0dc08553501fa740091086d0259ad0067e0d4103448e4cb22ed3" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" dependencies = [ - "digest 0.10.3", + "digest 0.10.5", ] [[package]] @@ -935,6 +1049,15 @@ 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.9" @@ -943,24 +1066,71 @@ checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" [[package]] name = "ryu" -version = "1.0.5" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "schemars" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + +[[package]] +name = "semver" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" [[package]] name = "serde" -version = "1.0.118" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.118" +version = "1.0.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +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", @@ -969,9 +1139,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" dependencies = [ "itoa", "ryu", @@ -980,51 +1150,49 @@ dependencies = [ [[package]] name = "sha2" -version = "0.9.3" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa827a14b29ab7f44778d14a88d3cb76e949c45083f7dbfa507d0cb699dc12de" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpuid-bool", + "cpufeatures", "digest 0.9.0", "opaque-debug", ] [[package]] name = "sha2" -version = "0.10.2" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" dependencies = [ "cfg-if 1.0.0", "cpufeatures", - "digest 0.10.3", + "digest 0.10.5", ] [[package]] name = "sha3" -version = "0.9.1" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f81199417d4e5de3f04b1e871023acea7389672c4135918f05aa9cbf2f2fa809" +checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" dependencies = [ - "block-buffer 0.9.0", - "digest 0.9.0", + "digest 0.10.5", "keccak", - "opaque-debug", ] [[package]] name = "signature" -version = "1.5.0" +version = "1.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f054c6c1a6e95179d6f23ed974060dcefb2d9388bb7256900badad682c499de4" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" [[package]] name = "smallvec" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "smart-default" @@ -1037,6 +1205,12 @@ dependencies = [ "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" @@ -1073,13 +1247,13 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.57" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4211ce9909eb971f111059df92c45640aad50a619cf55cd76476be803c4c68e6" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] @@ -1100,20 +1274,29 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" -version = "1.0.32" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.32" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", @@ -1133,9 +1316,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" dependencies = [ "serde", ] @@ -1148,9 +1331,9 @@ checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "uint" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f03af7ccf01dd611cc450a0d10dbc9b745770d096473e2faf0ca6e2d66d1e0" +checksum = "a45526d29728d135c2900b0d30573fe3ee79fceb12ef534c7bb30e810a91b601" dependencies = [ "byteorder", "crunchy", @@ -1158,17 +1341,29 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[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.1" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasi" @@ -1190,9 +1385,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.72" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fe8f61dba8e5d645a4d8132dc7a0a66861ed5e1045d2c0ed940fab33bac0fbe" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" dependencies = [ "cfg-if 1.0.0", "wasm-bindgen-macro", @@ -1200,13 +1395,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.72" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046ceba58ff062da072c7cb4ba5b22a37f00a302483f7e2a6cdc18fedbdc1fd3" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", "syn", @@ -1215,9 +1410,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.72" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef9aa01d36cda046f797c57959ff5f3c615c9cc63997a8d545831ec7976819b" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1225,9 +1420,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.72" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96eb45c1b2ee33545a813a92dbb53856418bf7eb54ab34f7f7ff1448a5b3735d" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" dependencies = [ "proc-macro2", "quote", @@ -1238,9 +1433,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.72" +version = "0.2.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7148f4696fb4960a346eaa60bbfb42a1ac4ebba21f750f75fc1375b098d5ffa" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "wee_alloc" @@ -1270,6 +1465,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" @@ -1302,3 +1506,17 @@ dependencies = [ "syn", "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/bridge-token/Cargo.toml b/bridge-token/Cargo.toml index dadf440d..a862abc9 100644 --- a/bridge-token/Cargo.toml +++ b/bridge-token/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bridge-token" -version = "0.1.0" +version = "0.2.0" authors = ["Near Inc "] edition = "2021" publish = false @@ -20,8 +20,3 @@ overflow-checks = true [dependencies] near-sdk = "4.0.0" near-contract-standards = "4.0.0" -admin-controlled = { git = "https://github.com/near/rainbow-bridge", rev = "67966a151122815039f07b02065ab3a2bba09804" } - -[features] -default = ["migrate_icon"] -migrate_icon = [] diff --git a/bridge-token/rust-toolchain b/bridge-token/rust-toolchain index d5a27893..d04f2eb5 100644 --- a/bridge-token/rust-toolchain +++ b/bridge-token/rust-toolchain @@ -1 +1,3 @@ -stable-2022-07-19 +[toolchain] +channel = "1.69.0" +components = ["clippy", "rustfmt"] diff --git a/bridge-token/src/lib.rs b/bridge-token/src/lib.rs index 0874da25..e29c9d27 100644 --- a/bridge-token/src/lib.rs +++ b/bridge-token/src/lib.rs @@ -1,17 +1,22 @@ -use admin_controlled::Mask; 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_sdk::json_types::{Base64VecU8, U128}; +use near_sdk::serde_json::json; use near_sdk::{ - assert_one_yocto, env, ext_contract, near_bindgen, AccountId, Balance, Gas, PanicOnDefault, - Promise, PromiseOrValue, StorageUsage, + assert_one_yocto, env, ext_contract, near_bindgen, require, AccountId, Balance, Gas, + PanicOnDefault, Promise, PromiseOrValue, StorageUsage, }; /// Gas to call finish withdraw method on factory. const FINISH_WITHDRAW_GAS: Gas = Gas(Gas::ONE_TERA.0 * 50); +const OUTER_UPGRADE_GAS: Gas = Gas(Gas::ONE_TERA.0 * 15); +const NO_DEPOSIT: Balance = 0; +const CURRENT_STATE_VERSION: u32 = 1; + +pub type Mask = u128; #[near_bindgen] #[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)] @@ -24,12 +29,9 @@ pub struct BridgeToken { reference_hash: Base64VecU8, decimals: u8, paused: Mask, - #[cfg(feature = "migrate_icon")] icon: Option, } -const PAUSE_WITHDRAW: Mask = 1 << 0; - #[ext_contract(ext_bridge_token_factory)] pub trait ExtBridgeTokenFactory { #[result_serializer(borsh)] @@ -44,7 +46,17 @@ pub trait ExtBridgeTokenFactory { impl BridgeToken { #[init] pub fn new() -> Self { - assert!(!env::state_exists(), "Already initialized"); + let current_account_id = env::current_account_id(); + let (_eth_address, factory_account) = current_account_id + .as_str() + .split_once(".") + .unwrap_or_else(|| env::panic_str("Invalid token address")); + + require!( + env::predecessor_account_id().as_str() == factory_account, + "Only the factory account can init this contract" + ); + Self { controller: env::predecessor_account_id(), token: FungibleToken::new(b"t".to_vec()), @@ -54,7 +66,6 @@ impl BridgeToken { reference_hash: Base64VecU8(vec![]), decimals: 0, paused: Mask::default(), - #[cfg(feature = "migrate_icon")] icon: None, } } @@ -69,19 +80,14 @@ impl BridgeToken { icon: Option, ) { // Only owner can change the metadata - assert!(self.controller_or_self()); + require!(self.controller_or_self()); name.map(|name| self.name = name); symbol.map(|symbol| self.symbol = symbol); reference.map(|reference| self.reference = reference); reference_hash.map(|reference_hash| self.reference_hash = reference_hash); decimals.map(|decimals| self.decimals = decimals); - #[cfg(feature = "migrate_icon")] icon.map(|icon| self.icon = Some(icon)); - #[cfg(not(feature = "migrate_icon"))] - icon.map(|_| { - env::log("Icon was provided, but it's not supported for the token".as_bytes()) - }); } #[payable] @@ -98,8 +104,7 @@ impl BridgeToken { #[payable] pub fn withdraw(&mut self, amount: U128, recipient: String) -> Promise { - self.check_not_paused(PAUSE_WITHDRAW); - + require!(!self.is_paused()); assert_one_yocto(); Promise::new(env::predecessor_account_id()).transfer(1); @@ -120,6 +125,45 @@ impl BridgeToken { let caller = env::predecessor_account_id(); caller == self.controller || caller == env::current_account_id() } + + pub fn is_paused(&self) -> bool { + self.paused != 0 && !self.controller_or_self() + } + + pub fn set_paused(&mut self, paused: bool) { + require!(self.controller_or_self()); + self.paused = if paused { 1 } else { 0 }; + } + + pub fn upgrade_and_migrate(&self) { + require!( + self.controller_or_self(), + "Only the controller or self can update the code" + ); + + // Receive the code directly from the input to avoid the + // GAS overhead of deserializing parameters + let code = env::input().unwrap_or_else(|| panic!("ERR_NO_INPUT")); + // Deploy the contract code. + let promise_id = env::promise_batch_create(&env::current_account_id()); + env::promise_batch_action_deploy_contract(promise_id, &code); + // Call promise to migrate the state. + // Batched together to fail upgrade if migration fails. + env::promise_batch_action_function_call( + promise_id, + "migrate", + &json!({ "from_version": CURRENT_STATE_VERSION }) + .to_string() + .into_bytes(), + NO_DEPOSIT, + env::prepaid_gas() - env::used_gas() - OUTER_UPGRADE_GAS, + ); + env::promise_return(promise_id); + } + + pub fn version(&self) -> String { + env!("CARGO_PKG_VERSION").to_owned() + } } near_contract_standards::impl_fungible_token_core!(BridgeToken, token); @@ -132,10 +176,7 @@ impl FungibleTokenMetadataProvider for BridgeToken { spec: FT_METADATA_SPEC.to_string(), name: self.name.clone(), symbol: self.symbol.clone(), - #[cfg(feature = "migrate_icon")] icon: self.icon.clone(), - #[cfg(not(feature = "migrate_icon"))] - icon: None, reference: Some(self.reference.clone()), reference_hash: Some(self.reference_hash.clone()), decimals: self.decimals, @@ -143,11 +184,8 @@ impl FungibleTokenMetadataProvider for BridgeToken { } } -admin_controlled::impl_admin_controlled!(BridgeToken, paused); - // Migration -#[cfg(feature = "migrate_icon")] #[derive(BorshDeserialize, BorshSerialize)] pub struct BridgeTokenV0 { controller: AccountId, @@ -160,9 +198,9 @@ pub struct BridgeTokenV0 { paused: Mask, } -#[cfg(feature = "migrate_icon")] impl From for BridgeToken { fn from(obj: BridgeTokenV0) -> Self { + #[allow(deprecated)] Self { controller: obj.controller, token: obj.token, @@ -177,17 +215,19 @@ impl From for BridgeToken { } } -#[cfg(feature = "migrate_icon")] #[near_bindgen] impl BridgeToken { - /// Adding icon as suggested here: https://nomicon.io/Standards/FungibleToken/Metadata.html /// This function can only be called from the factory or from the contract itself. #[init(ignore_state)] - pub fn migrate_nep_148_add_icon() -> Self { - let old_state: BridgeTokenV0 = env::state_read() - .expect("State is not compatible with BridgeTokenV0. Migration has not been applied."); - let new_state: BridgeToken = old_state.into(); - assert!(new_state.controller_or_self()); - new_state + pub fn migrate(from_version: u32) -> Self { + if from_version == 0 { + // Adding icon as suggested here: https://nomicon.io/Standards/FungibleToken/Metadata.html + let old_state: BridgeTokenV0 = env::state_read().expect("Contract isn't initialized"); + let new_state: BridgeToken = old_state.into(); + assert!(new_state.controller_or_self()); + new_state + } else { + env::state_read().unwrap() + } } } diff --git a/res/bridge_token.wasm b/res/bridge_token.wasm index e4cfa080..3687d5dc 100755 Binary files a/res/bridge_token.wasm and b/res/bridge_token.wasm differ diff --git a/res/bridge_token_factory.wasm b/res/bridge_token_factory.wasm index 1f820c66..9e9e8926 100755 Binary files a/res/bridge_token_factory.wasm and b/res/bridge_token_factory.wasm differ diff --git a/res/rainbow_bridge_near_token_locker.wasm b/res/rainbow_bridge_near_token_locker.wasm index 4e34ea64..cd0bf387 100755 Binary files a/res/rainbow_bridge_near_token_locker.wasm and b/res/rainbow_bridge_near_token_locker.wasm differ diff --git a/token-locker/Cargo.lock b/token-locker/Cargo.lock index 27258495..2616e3fa 100644 --- a/token-locker/Cargo.lock +++ b/token-locker/Cargo.lock @@ -8,14 +8,6 @@ version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -[[package]] -name = "admin-controlled" -version = "0.1.0" -source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" -dependencies = [ - "near-sdk", -] - [[package]] name = "ahash" version = "0.7.6" @@ -63,6 +55,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitvec" version = "0.17.4" @@ -170,7 +168,6 @@ dependencies = [ name = "bridge-common" version = "0.1.0" dependencies = [ - "admin-controlled", "eth-types", "ethabi", "hex", @@ -382,6 +379,12 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dyn-clone" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" + [[package]] name = "easy-ext" version = "0.2.9" @@ -420,13 +423,10 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "eth-types" version = "0.1.0" -source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" +source = "git+https://github.com/near/rainbow-bridge?rev=4b24cbd5a6e098fd8a9cd24fbb194fa8e0fc51e4#4b24cbd5a6e098fd8a9cd24fbb194fa8e0fc51e4" dependencies = [ "borsh", "derive_more", - "eth2_serde_utils", - "eth2_ssz", - "eth2_ssz_derive", "ethereum-types", "hex", "near-sdk", @@ -434,49 +434,6 @@ dependencies = [ "rlp-derive", "serde", "serde-big-array", - "tree_hash", - "tree_hash_derive", -] - -[[package]] -name = "eth2_hashing" -version = "0.3.0" -source = "git+https://github.com/near/rainbow-bridge?rev=67966a151122815039f07b02065ab3a2bba09804#67966a151122815039f07b02065ab3a2bba09804" -dependencies = [ - "lazy_static", - "near-sdk", -] - -[[package]] -name = "eth2_serde_utils" -version = "0.1.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "ethereum-types", - "hex", - "serde", - "serde_derive", - "serde_json", -] - -[[package]] -name = "eth2_ssz" -version = "0.4.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "ethereum-types", - "smallvec", -] - -[[package]] -name = "eth2_ssz_derive" -version = "0.3.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn", ] [[package]] @@ -679,6 +636,9 @@ name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +dependencies = [ + "spin", +] [[package]] name = "libc" @@ -692,11 +652,23 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" +[[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.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de83d74a9241be8cc4eb3055216966b58bf8c463e8e285c0dc553925acdd19fa" +checksum = "71d258582a1878e6db67400b0504a5099db85718d22c2e07f747fe1706ae7150" dependencies = [ "borsh", "serde", @@ -704,20 +676,21 @@ dependencies = [ [[package]] name = "near-contract-standards" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6466c6aaad18800ff6a3cd104427dc8fd79e144714135224b8289b1dc43f7167" +checksum = "7bacc932e79b26472797adfb21689294b6f90960d1570daaf1e0b682b59fcb35" dependencies = [ "near-sdk", + "schemars", "serde", "serde_json", ] [[package]] name = "near-crypto" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ecf0b8b31aa7f4e60f629f72213a2617ca4a5f45cd1ae9ed2cf7cecfebdbb7" +checksum = "1e75673d69fd7365508f3d32483669fe45b03bfb34e4d9363e90adae9dfb416c" dependencies = [ "arrayref", "blake2", @@ -727,7 +700,6 @@ dependencies = [ "curve25519-dalek", "derive_more", "ed25519-dalek", - "libc", "near-account-id", "once_cell", "parity-secp256k1", @@ -740,11 +712,34 @@ dependencies = [ "thiserror", ] +[[package]] +name = "near-plugins" +version = "0.1.0" +source = "git+https://github.com/aurora-is-near/near-plugins?tag=v0.1.0#64c512f96d4b51ccdd1a1aed683ed90fd1ca8c57" +dependencies = [ + "bitflags", + "near-plugins-derive", + "near-sdk", + "serde", +] + +[[package]] +name = "near-plugins-derive" +version = "0.1.0" +source = "git+https://github.com/aurora-is-near/near-plugins?tag=v0.1.0#64c512f96d4b51ccdd1a1aed683ed90fd1ca8c57" +dependencies = [ + "darling", + "proc-macro-crate 0.1.5", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "near-primitives" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a2ba19282e79a4485a77736b679d276b09870bbf8042a18e0f0ae36347489c5" +checksum = "8ad1a9a1640539c81f065425c31bffcfbf6b31ef1aeaade59ce905f5df6ac860" dependencies = [ "borsh", "byteorder", @@ -771,9 +766,9 @@ dependencies = [ [[package]] name = "near-primitives-core" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb561feb392bb8c4f540256073446e6689af087bf6356e8dddcf75fc279f201f" +checksum = "91d508f0fc340f6461e4e256417685720d3c4c00bb5a939b105160e49137caba" dependencies = [ "base64 0.11.0", "borsh", @@ -788,9 +783,9 @@ dependencies = [ [[package]] name = "near-rpc-error-core" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77fdd7ea8d8f786878651c37691515d5053f827ae60894aa40c16882b78f77c9" +checksum = "93ee0b41c75ef859c193a8ff1dadfa0c8207bc0ac447cc22259721ad769a1408" dependencies = [ "quote", "serde", @@ -799,9 +794,9 @@ dependencies = [ [[package]] name = "near-rpc-error-macro" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e521842b6ae864dfe5391afbbe2df9e9d8427c26e9333b2e0b65cd42094f7607" +checksum = "8e837bd4bacd807073ec5ceb85708da7f721b46a4c2a978de86027fb0034ce31" dependencies = [ "near-rpc-error-core", "serde", @@ -810,19 +805,22 @@ dependencies = [ [[package]] name = "near-sdk" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda34e06e28fb9a09ac54efbdc49f0c9308780fc932aaa81c49c493fde974045" +checksum = "15eb3de2defe3626260cc209a6cdb985c6b27b0bd4619fad97dcfae002c3c5bd" dependencies = [ "base64 0.13.0", "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", @@ -830,9 +828,9 @@ dependencies = [ [[package]] name = "near-sdk-macros" -version = "4.0.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72064fcc15a623a0d40a6c199ea5cbdc30a83cae4816889d46f218acf31bfba8" +checksum = "4907affc9f5ed559456509188ff0024f1f2099c0830e6bdb66eb61d5b75912c0" dependencies = [ "Inflector", "proc-macro2", @@ -848,9 +846,9 @@ checksum = "e307313276eaeced2ca95740b5639e1f3125b7c97f0a1151809d105f1aa8c6d3" [[package]] name = "near-vm-errors" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e02faf2bc1f6ef82b965cfe44389808fb5594f7aca4b596766117f4ce74df20" +checksum = "d0da466a30f0446639cbd788c30865086fac3e8dcb07a79e51d2b0775ed4261e" dependencies = [ "borsh", "near-account-id", @@ -860,9 +858,9 @@ dependencies = [ [[package]] name = "near-vm-logic" -version = "0.13.0" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f024d90451cd3c24d7a0a5cabf3636b192a60eb8e3ff0456f6c18b91152c346d" +checksum = "81b534828419bacbf1f7b11ef7b00420f248c548c485d3f0cfda8bb6931152f2" dependencies = [ "base64 0.13.0", "borsh", @@ -877,6 +875,7 @@ dependencies = [ "serde", "sha2 0.10.2", "sha3", + "zeropool-bn", ] [[package]] @@ -1065,14 +1064,13 @@ checksum = "643f8f41a8ebc4c5dc4515c82bb8abd397b527fc20fd681b7c011c2aee5d44fb" [[package]] name = "rainbow-bridge-near-token-locker" -version = "0.1.0" +version = "0.2.0" dependencies = [ - "admin-controlled", "bridge-common", - "eth-types", "ethabi", "hex", "near-contract-standards", + "near-plugins", "near-sdk", "rand 0.7.3", "serde_json", @@ -1216,6 +1214,30 @@ version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +[[package]] +name = "schemars" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + [[package]] name = "semver" version = "1.0.6" @@ -1251,6 +1273,17 @@ dependencies = [ "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", +] + [[package]] name = "serde_json" version = "1.0.79" @@ -1321,6 +1354,12 @@ dependencies = [ "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" @@ -1447,26 +1486,6 @@ dependencies = [ "serde", ] -[[package]] -name = "tree_hash" -version = "0.4.1" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "eth2_hashing", - "ethereum-types", - "smallvec", -] - -[[package]] -name = "tree_hash_derive" -version = "0.4.0" -source = "git+https://github.com/aurora-is-near/lighthouse.git?rev=b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec#b624c3f0d3c5bc9ea46faa14c9cb2d90ee1e1dec" -dependencies = [ - "darling", - "quote", - "syn", -] - [[package]] name = "typenum" version = "1.15.0" @@ -1581,3 +1600,17 @@ dependencies = [ "syn", "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/token-locker/Cargo.toml b/token-locker/Cargo.toml index 48be6495..f60d02d5 100644 --- a/token-locker/Cargo.toml +++ b/token-locker/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rainbow-bridge-near-token-locker" -version = "0.1.0" +version = "0.2.0" authors = ["Pagoda "] edition = "2021" publish = false @@ -18,24 +18,15 @@ panic = "abort" overflow-checks = true [dependencies] -near-sdk = "4.0.0" +near-sdk = "4.1.0" near-contract-standards = "4.0.0" -eth-types = { git = "https://github.com/near/rainbow-bridge", rev = "67966a151122815039f07b02065ab3a2bba09804" } -admin-controlled = { git = "https://github.com/near/rainbow-bridge", rev = "67966a151122815039f07b02065ab3a2bba09804" } tiny-keccak = "1.4.0" ethabi = "12.0.0" hex = "0.4.2" bridge-common = { path = "../bridge-common" } +near-plugins = { git = "https://github.com/aurora-is-near/near-plugins", tag = "v0.1.0" } [dev-dependencies] uint = { version = "0.8.3", default-features = false } serde_json = "1.0" rand = "0.7.3" - -[features] -default = ["migrate_icon"] -migrate_icon = [] - -[patch] -[patch.crates-io] -eth2_hashing = { git = "https://github.com/near/rainbow-bridge", rev = "67966a151122815039f07b02065ab3a2bba09804" } \ No newline at end of file diff --git a/token-locker/rust-toolchain b/token-locker/rust-toolchain index d5a27893..d04f2eb5 100644 --- a/token-locker/rust-toolchain +++ b/token-locker/rust-toolchain @@ -1 +1,3 @@ -stable-2022-07-19 +[toolchain] +channel = "1.69.0" +components = ["clippy", "rustfmt"] diff --git a/token-locker/src/lib.rs b/token-locker/src/lib.rs index 6c979c6d..e3de8e34 100644 --- a/token-locker/src/lib.rs +++ b/token-locker/src/lib.rs @@ -1,23 +1,25 @@ +use near_plugins::{ + access_control, access_control_any, pause, AccessControlRole, AccessControllable, Pausable, + Upgradable, +}; use std::convert::TryInto; -use admin_controlled::{AdminControlled, Mask}; use near_contract_standards::fungible_token::metadata::FungibleTokenMetadata; use near_contract_standards::storage_management::StorageBalance; use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize}; -use near_sdk::collections::UnorderedSet; +use near_sdk::collections::{UnorderedMap, UnorderedSet}; use near_sdk::json_types::U128; +use near_sdk::serde::{Deserialize, Serialize}; use near_sdk::{ - env, ext_contract, near_bindgen, AccountId, Balance, Gas, PanicOnDefault, Promise, - PromiseOrValue, + env, ext_contract, near_bindgen, AccountId, Balance, BorshStorageKey, Gas, PanicOnDefault, + Promise, PromiseOrValue, }; use bridge_common::prover::{ ext_prover, validate_eth_address, EthAddress, Proof, FT_TRANSFER_CALL_GAS, FT_TRANSFER_GAS, - NO_DEPOSIT, PAUSE_DEPOSIT, STORAGE_BALANCE_CALL_GAS, VERIFY_LOG_ENTRY_GAS, + NO_DEPOSIT, STORAGE_BALANCE_CALL_GAS, VERIFY_LOG_ENTRY_GAS, }; use bridge_common::{parse_recipient, result_types, Recipient}; -use near_sdk_inner::collections::UnorderedMap; -use near_sdk_inner::BorshStorageKey; use whitelist::WhitelistMode; use crate::unlock_event::EthUnlockedEvent; @@ -42,6 +44,8 @@ const FT_FINISH_LOG_METADATA_GAS: Gas = Gas(Gas::ONE_TERA.0 * 30); /// Gas to call storage balance callback method. const FT_STORAGE_BALANCE_CALLBACK_GAS: Gas = Gas(Gas::ONE_TERA.0 * 10); +pub type Mask = u128; + #[derive(BorshSerialize, BorshStorageKey)] enum StorageKey { UsedEvents, @@ -49,8 +53,28 @@ enum StorageKey { WhitelistAccounts, } +#[derive(AccessControlRole, Deserialize, Serialize, Copy, Clone)] +#[serde(crate = "near_sdk::serde")] +pub enum Role { + DAO, + PauseManager, + UnrestrictedDeposit, + UnrestrictedWithdraw, + UpgradableCodeStager, + UpgradableCodeDeployer, +} + #[near_bindgen] -#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)] +#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault, Pausable, Upgradable)] +#[access_control(role_type(Role))] +#[pausable(manager_roles(Role::PauseManager))] +#[upgradable(access_control_roles( + code_stagers(Role::UpgradableCodeStager, Role::DAO), + code_deployers(Role::UpgradableCodeDeployer, Role::DAO), + duration_initializers(Role::DAO), + duration_update_stagers(Role::DAO), + duration_update_appliers(Role::DAO), +))] pub struct Contract { /// The account of the prover that we can use to prove. pub prover_account: AccountId, @@ -59,6 +83,7 @@ pub struct Contract { /// Hashes of the events that were already used. pub used_events: UnorderedSet>, /// Mask determining all paused functions + #[deprecated] paused: Mask, /// Mapping whitelisted tokens to their mode pub whitelist_tokens: UnorderedMap, @@ -135,7 +160,8 @@ impl Contract { /// `prover_account`: NEAR account of the Near Prover contract; /// `factory_address`: Ethereum address of the token factory contract, in hex. pub fn new(prover_account: AccountId, factory_address: String) -> Self { - Self { + #[allow(deprecated)] + let mut contract = Self { prover_account, used_events: UnorderedSet::new(StorageKey::UsedEvents), eth_factory_address: validate_eth_address(factory_address), @@ -143,7 +169,10 @@ impl Contract { whitelist_tokens: UnorderedMap::new(StorageKey::WhitelistTokens), whitelist_accounts: UnorderedSet::new(StorageKey::WhitelistAccounts), is_whitelist_mode_enabled: true, - } + }; + + contract.acl_init_super_admin(near_sdk::env::predecessor_account_id()); + contract } /// Logs into the result of this transaction a Metadata for given token. @@ -178,8 +207,8 @@ impl Contract { /// Withdraw funds from NEAR Token Locker. /// Receives proof of burning tokens on the other side. Validates it and releases funds. #[payable] + #[pause(except(roles(Role::DAO, Role::UnrestrictedWithdraw)))] pub fn withdraw(&mut self, #[serializer(borsh)] proof: Proof) -> Promise { - self.check_not_paused(PAUSE_DEPOSIT); let event = EthUnlockedEvent::from_log_entry_data(&proof.log_entry_data); assert_eq!( event.eth_factory_address, @@ -326,14 +355,12 @@ impl Contract { required_deposit } - #[private] + #[access_control_any(roles(Role::DAO))] pub fn update_factory_address(&mut self, factory_address: String) { self.eth_factory_address = validate_eth_address(factory_address); } } -admin_controlled::impl_admin_controlled!(Contract, paused); - #[cfg(not(target_arch = "wasm32"))] #[cfg(test)] mod tests { @@ -342,13 +369,15 @@ mod tests { use near_contract_standards::fungible_token::receiver::FungibleTokenReceiver; use near_sdk::env::sha256; - use near_sdk::test_utils::{accounts, VMContextBuilder}; + use near_sdk::test_utils::VMContextBuilder; use near_sdk::testing_env; use uint::rustc_hex::{FromHex, ToHex}; use super::*; - const UNPAUSE_ALL: Mask = 0; + pub fn accounts(id: usize) -> AccountId { + AccountId::new_unchecked(near_sdk::test_utils::accounts(id).to_string() + ".near") + } macro_rules! inner_set_env { ($builder:ident) => { @@ -373,17 +402,21 @@ mod tests { } fn prover() -> AccountId { - "prover".parse().unwrap() + "prover.near".parse().unwrap() } fn bridge_token_factory() -> AccountId { - "bridge".parse().unwrap() + "bridge.near".parse().unwrap() } fn token_locker() -> String { "6b175474e89094c44da98b954eedeac495271d0f".to_string() } + fn pause_manager() -> AccountId { + "pause_manager".parse().unwrap() + } + /// Generate a valid ethereum address. fn ethereum_address_from_id(id: u8) -> String { let mut buffer = vec![id]; @@ -477,23 +510,26 @@ mod tests { } #[test] - fn test_only_admin_can_pause() { - set_env!(predecessor_account_id: accounts(0)); - let mut contract = Contract::new(prover(), token_locker()); - - // Admin can pause + fn test_only_pause_manager_can_pause() { set_env!( current_account_id: bridge_token_factory(), predecessor_account_id: bridge_token_factory(), ); - contract.set_paused(0b1111); + let mut contract = Contract::new(prover(), token_locker()); + assert!(contract + .acl_grant_role("PauseManager".to_owned(), pause_manager()) + .unwrap()); - // Admin can unpause. set_env!( current_account_id: bridge_token_factory(), - predecessor_account_id: bridge_token_factory(), + predecessor_account_id: pause_manager(), ); - contract.set_paused(UNPAUSE_ALL); + + // Pause manager can pause + contract.pa_pause_feature("deposit".to_string()); + + // Pause manager can unpause. + contract.pa_unpause_feature("deposit".to_string()); // Alice can't pause set_env!( @@ -502,7 +538,7 @@ mod tests { ); panic::catch_unwind(move || { - contract.set_paused(0); + contract.pa_pause_feature("deposit".to_string()); }) .unwrap_err(); } diff --git a/token-locker/src/token_receiver.rs b/token-locker/src/token_receiver.rs index 97671314..bef964d9 100644 --- a/token-locker/src/token_receiver.rs +++ b/token-locker/src/token_receiver.rs @@ -6,13 +6,13 @@ use crate::*; impl FungibleTokenReceiver for Contract { /// Callback on receiving tokens by this contract. /// msg: `Ethereum` address to receive the tokens on. + #[pause(except(roles(Role::DAO, Role::UnrestrictedDeposit)))] fn ft_on_transfer( &mut self, sender_id: AccountId, amount: U128, msg: String, ) -> PromiseOrValue { - self.check_not_paused(PAUSE_DEPOSIT); self.check_whitelist_token(env::predecessor_account_id(), sender_id); // Fails if msg is not a valid Ethereum address. let eth_address = validate_eth_address(msg); diff --git a/token-locker/src/unlock_event.rs b/token-locker/src/unlock_event.rs index a89bbeb1..57b16ca6 100644 --- a/token-locker/src/unlock_event.rs +++ b/token-locker/src/unlock_event.rs @@ -50,7 +50,7 @@ impl EthUnlockedEvent { } } - #[warn(dead_code)] + #[allow(dead_code)] pub fn to_log_entry_data(&self) -> Vec { EthEvent::to_log_entry_data( "Withdraw",