Skip to content

Commit d7b8ebd

Browse files
committed
feat: update tw_new_multi_release_escrow to check for existing escrow and change deployer to signer
1 parent 964c0dc commit d7b8ebd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

contracts/escrow/src/contract.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,27 @@ impl EscrowContract {
1717

1818
pub fn tw_new_multi_release_escrow(
1919
env: Env,
20-
deployer: Address,
20+
signer: Address,
2121
wasm_hash: BytesN<32>,
2222
salt: BytesN<32>,
2323
init_fn: Symbol,
2424
init_args: Vec<Val>,
2525
constructor_args: Vec<Val>,
26-
) -> (Address, Val) {
27-
if deployer != env.current_contract_address() {
28-
deployer.require_auth();
26+
) -> Result<(Address, Val), ContractError> {
27+
if EscrowManager::get_escrow(&env).is_ok() {
28+
return Err(ContractError::EscrowAlreadyInitialized);
2929
}
3030

31+
signer.require_auth();
32+
33+
let deployer = env.current_contract_address();
3134
let deployed_address = env
3235
.deployer()
3336
.with_address(deployer, salt)
3437
.deploy_v2(wasm_hash, constructor_args);
3538

3639
let res: Val = env.invoke_contract(&deployed_address, &init_fn, init_args);
37-
(deployed_address, res)
40+
Ok((deployed_address, res))
3841
}
3942

4043
////////////////////////

0 commit comments

Comments
 (0)