From 4f3c0698483d8cab8df61861896f3c1a83a7ff55 Mon Sep 17 00:00:00 2001 From: dragosrebegea Date: Wed, 24 Jan 2024 11:27:48 +0200 Subject: [PATCH] MX-15084: add PauseModule fro bridge-proxy --- Cargo.lock | 1 + bridge-proxy/Cargo.toml | 3 +++ bridge-proxy/src/bridge-proxy.rs | 5 ++++- bridge-proxy/wasm/Cargo.lock | 10 ++++++++++ bridge-proxy/wasm/src/lib.rs | 11 ++++++++--- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0d671687..81ba8ca6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -190,6 +190,7 @@ dependencies = [ "adder", "eth-address", "multiversx-sc", + "multiversx-sc-modules", "multiversx-sc-scenario", "num-bigint", "transaction", diff --git a/bridge-proxy/Cargo.toml b/bridge-proxy/Cargo.toml index ef15b6ad..b62bb8c3 100644 --- a/bridge-proxy/Cargo.toml +++ b/bridge-proxy/Cargo.toml @@ -17,6 +17,9 @@ path = "../common/eth-address" [dependencies.multiversx-sc] version = "0.46.1" +[dependencies.multiversx-sc-modules] +version = "0.46.1" + [dependencies.adder] git = "https://github.com/multiversx/mx-contracts-rs" rev = "64e8926" diff --git a/bridge-proxy/src/bridge-proxy.rs b/bridge-proxy/src/bridge-proxy.rs index b058bacd..b9f3a86f 100644 --- a/bridge-proxy/src/bridge-proxy.rs +++ b/bridge-proxy/src/bridge-proxy.rs @@ -8,7 +8,9 @@ pub mod config; use transaction::{EthTransaction, EthTransactionPayment}; #[multiversx_sc::contract] -pub trait BridgeProxyContract: config::ConfigModule { +pub trait BridgeProxyContract: + config::ConfigModule + + multiversx_sc_modules::pause::PauseModule { #[init] fn init(&self, opt_multi_transfer_address: OptionalValue) { self.set_multi_transfer_contract_address(opt_multi_transfer_address); @@ -29,6 +31,7 @@ pub trait BridgeProxyContract: config::ConfigModule { #[endpoint(executeWithAsnyc)] fn execute_with_async(&self, tx_id: u32) { + require!(self.not_paused(), "Contract is paused"); let tx_node = self .eth_transaction_list() .remove_node_by_id(tx_id) diff --git a/bridge-proxy/wasm/Cargo.lock b/bridge-proxy/wasm/Cargo.lock index c088f7e9..03578cb9 100644 --- a/bridge-proxy/wasm/Cargo.lock +++ b/bridge-proxy/wasm/Cargo.lock @@ -35,6 +35,7 @@ dependencies = [ "adder", "eth-address", "multiversx-sc", + "multiversx-sc-modules", "transaction", ] @@ -119,6 +120,15 @@ dependencies = [ "syn", ] +[[package]] +name = "multiversx-sc-modules" +version = "0.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c63ffaba95e630ff75981e2f5f50da64f523219b52f484234c66f3adc248885f" +dependencies = [ + "multiversx-sc", +] + [[package]] name = "multiversx-sc-wasm-adapter" version = "0.46.1" diff --git a/bridge-proxy/wasm/src/lib.rs b/bridge-proxy/wasm/src/lib.rs index 2cb3f686..13b818c8 100644 --- a/bridge-proxy/wasm/src/lib.rs +++ b/bridge-proxy/wasm/src/lib.rs @@ -5,12 +5,14 @@ //////////////////////////////////////////////////// // Init: 1 -// Endpoints: 8 +// Endpoints: 11 // Async Callback: 1 -// Total number of exported functions: 10 +// Total number of exported functions: 13 #![no_std] -#![allow(internal_features)] + +// Configuration that works with rustc < 1.73.0. +// TODO: Recommended rustc version: 1.73.0 or newer. #![feature(lang_items)] multiversx_sc_wasm_adapter::allocator!(); @@ -28,6 +30,9 @@ multiversx_sc_wasm_adapter::endpoints! { getMultiTransferAddress => multi_transfer_address getEthTransactionList => eth_transaction_list getEthFailedTransactionList => eth_failed_transaction_list + pause => pause_endpoint + unpause => unpause_endpoint + isPaused => paused_status ) }