Skip to content

Commit 013899a

Browse files
committed
feat(soroban-contract): implement circuit breaker pattern in TBA contracts (#179)
1 parent 6bdea00 commit 013899a

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

  • soroban-contract/contracts

soroban-contract/contracts/tba_account/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ impl TbaAccount {
104104
implementation_hash: BytesN<32>,
105105
salt: BytesN<32>,
106106
) -> Result<(), Error> {
107+
upg::require_not_paused(&env);
107108
// Prevent re-initialization
108109
if is_initialized(&env) {
109110
return Err(Error::AlreadyInitialized);
@@ -169,6 +170,7 @@ impl TbaAccount {
169170
/// Only the current NFT owner can execute transactions
170171
/// This function increments the nonce and emits an event
171172
pub fn execute(env: Env, to: Address, func: Symbol, args: Vec<Val>) -> Result<Vec<Val>, Error> {
173+
upg::require_not_paused(&env);
172174
if !is_initialized(&env) {
173175
return Err(Error::NotInitialized);
174176
}
@@ -203,6 +205,7 @@ impl TbaAccount {
203205
to: Address,
204206
amount: i128,
205207
) -> Result<(), Error> {
208+
upg::require_not_paused(&env);
206209
if !is_initialized(&env) {
207210
return Err(Error::NotInitialized);
208211
}
@@ -224,6 +227,7 @@ impl TbaAccount {
224227
to: Address,
225228
nft_token_id: u128,
226229
) -> Result<(), Error> {
230+
upg::require_not_paused(&env);
227231
if !is_initialized(&env) {
228232
return Err(Error::NotInitialized);
229233
}
@@ -244,6 +248,7 @@ impl TbaAccount {
244248
token_address: Address,
245249
recipients: Vec<(Address, i128)>,
246250
) -> Result<u32, Error> {
251+
upg::require_not_paused(&env);
247252
if !is_initialized(&env) {
248253
return Err(Error::NotInitialized);
249254
}

soroban-contract/contracts/tba_registry/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ impl TbaRegistry {
125125
token_id: u128,
126126
salt: BytesN<32>,
127127
) -> Result<Address, Error> {
128+
upg::require_not_paused(&env);
128129
// Verify that the caller owns the NFT (Issue #26)
129130
// This is a cross-contract call to the NFT contract
130131
let owner: Address = env.invoke_contract(

0 commit comments

Comments
 (0)