Skip to content

Commit

Permalink
Merge pull request #635 from ElrondNetwork/legacy-factory-pause-module
Browse files Browse the repository at this point in the history
added pause functionality to legacy factory
  • Loading branch information
sasurobert authored Dec 6, 2022
2 parents d04fafc + cfff46e commit 51a6e2b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions locked-asset/factory/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ path = "../../common/modules/token_merge"
version = "=0.36.1"
features = [ "esdt-token-payment-legacy-decode" ]

[dependencies.elrond-wasm-modules]
version = "=0.36.1"

[dev-dependencies.elrond-wasm-debug]
version = "=0.36.1"

Expand Down
11 changes: 10 additions & 1 deletion locked-asset/factory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ pub trait LockedAssetFactory:
+ events::EventsModule
+ attr_ex_helper::AttrExHelper
+ migration::LockedTokenMigrationModule
+ elrond_wasm_modules::pause::PauseModule
{
#[init]
fn init(&self) {}
fn init(&self) {
self.set_paused(true);
}

#[only_owner]
#[endpoint]
Expand All @@ -68,6 +71,8 @@ pub trait LockedAssetFactory:
start_epoch: Epoch,
unlock_period: UnlockPeriod<Self::Api>,
) -> OldEsdtTokenPayment<Self::Api> {
self.require_not_paused();

let caller = self.blockchain().get_caller();
require!(
self.whitelisted_contracts().contains(&caller),
Expand Down Expand Up @@ -103,6 +108,8 @@ pub trait LockedAssetFactory:
address: ManagedAddress,
start_epoch: Epoch,
) -> OldEsdtTokenPayment<Self::Api> {
self.require_not_paused();

let caller = self.blockchain().get_caller();
require!(
self.whitelisted_contracts().contains(&caller),
Expand Down Expand Up @@ -139,6 +146,8 @@ pub trait LockedAssetFactory:
#[payable("*")]
#[endpoint(unlockAssets)]
fn unlock_assets(&self) {
self.require_not_paused();

let (token_id, token_nonce, amount) = self.call_value().single_esdt().into_tuple();
let locked_token_id = self.locked_asset_token_id().get();
require!(token_id == locked_token_id, "Bad payment token");
Expand Down
10 changes: 10 additions & 0 deletions locked-asset/factory/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions locked-asset/factory/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ elrond_wasm_node::wasm_endpoints! {
getLockedAssetTokenId
getUnlockScheduleForSFTNonce
getWhitelistedContracts
isPaused
pause
removeWhitelist
setBurnRoleForAddress
setNewFactoryAddress
setTransferRoleForAddress
unlockAssets
unpause
unsetTransferRoleForAddress
whitelist
)
Expand Down

0 comments on commit 51a6e2b

Please sign in to comment.