From e5ff0181da0aa4b2a844fca8a2e8826ab976bff7 Mon Sep 17 00:00:00 2001 From: Nilesh Gupta Date: Fri, 1 Nov 2024 20:22:21 +0530 Subject: [PATCH] refactor: removed core_address from storage and tests --- sh/declare.sh | 2 +- sh/deploy.sh | 2 +- src/interface.cairo | 2 -- src/lib.cairo | 12 +----------- tests/test_push_admin.cairo | 27 --------------------------- 5 files changed, 3 insertions(+), 42 deletions(-) diff --git a/sh/declare.sh b/sh/declare.sh index 69dff2a..7c78536 100644 --- a/sh/declare.sh +++ b/sh/declare.sh @@ -1,7 +1,7 @@ #!/bin/bash # Load environment variables from .env file -export $(grep -v '^#' ../.env | xargs) +export $(grep -v '^#' .env | xargs) # Function to print usage information print_usage() { diff --git a/sh/deploy.sh b/sh/deploy.sh index 9e11d55..076f820 100644 --- a/sh/deploy.sh +++ b/sh/deploy.sh @@ -1,7 +1,7 @@ #!/bin/bash # Load environment variables from .env file -export $(grep -v '^#' ../.env | xargs) +export $(grep -v '^#' .env | xargs) # Function to print usage information print_usage() { diff --git a/src/interface.cairo b/src/interface.cairo index b68c10b..f31de85 100644 --- a/src/interface.cairo +++ b/src/interface.cairo @@ -3,7 +3,6 @@ use starknet::{ContractAddress, EthAddress}; #[starknet::interface] pub trait IPushComm { // Push Admin - fn set_push_core_address(ref self: TContractState, core_address: EthAddress); fn set_push_governance_address(ref self: TContractState, governance_address: ContractAddress); fn set_push_token_address(ref self: TContractState, push_token_address: ContractAddress); @@ -37,7 +36,6 @@ pub trait IPushComm { fn users_count(self: @TContractState) -> u256; fn chain_id(self: @TContractState) -> felt252; fn chain_name(self: @TContractState) -> felt252; - fn push_core_address(self: @TContractState) -> EthAddress; fn push_token_address(self: @TContractState) -> ContractAddress; fn push_governance_address(self: @TContractState) -> ContractAddress; fn user_to_channel_notifs(self: @TContractState, user: ContractAddress, channel: ContractAddress) -> ByteArray; diff --git a/src/lib.cairo b/src/lib.cairo index d371e6e..ae40474 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -333,13 +333,6 @@ pub mod PushComm { ); } - - // Admin - fn set_push_core_address(ref self: ContractState, core_address: EthAddress) { - self.ownable.assert_only_owner(); - self.push_core_address.write(core_address); - } - // Channel fn verify_channel_alias(ref self: ContractState, channel_address: EthAddress) { self @@ -374,6 +367,7 @@ pub mod PushComm { self._send_notification(channel, recipient, identity) } + //Admin fn set_push_governance_address( ref self: ContractState, governance_address: ContractAddress ) { @@ -387,10 +381,6 @@ pub mod PushComm { } // Getters Functions - fn push_core_address(self: @ContractState) -> EthAddress { - self.push_core_address.read() - } - fn push_token_address(self: @ContractState) -> ContractAddress { self.push_token_address.read() } diff --git a/tests/test_push_admin.cairo b/tests/test_push_admin.cairo index 441e465..71aced8 100644 --- a/tests/test_push_admin.cairo +++ b/tests/test_push_admin.cairo @@ -5,33 +5,6 @@ use push_comm::interface::{IPushCommDispatcher, IPushCommDispatcherTrait}; use super::common::{USER_1, PUSH_ADMIN, deploy_contract}; -#[test] -fn test_admin_sets_core_contract_address() { - let contract_address = deploy_contract(); - let push_comm = IPushCommDispatcher { contract_address }; - let CORE_ADDRESS: EthAddress = 'some addrs'.try_into().unwrap(); - - // admin sets the core channel address - cheat_caller_address(contract_address, PUSH_ADMIN(), CheatSpan::TargetCalls(1)); - push_comm.set_push_core_address(CORE_ADDRESS); - - let UPDATED_ADDRESS = push_comm.push_core_address(); - assert(CORE_ADDRESS == UPDATED_ADDRESS, 'Core Contract Update Failed'); -} - -#[test] -#[should_panic(expected: 'Caller is not the owner')] -fn test_non_admin_sets_core_contract_fail() { - let contract_address = deploy_contract(); - let push_comm = IPushCommDispatcher { contract_address }; - let CORE_ADDRESS: EthAddress = 'some addrs'.try_into().unwrap(); - - // non admin user sets the core channel address - cheat_caller_address(contract_address, USER_1(), CheatSpan::TargetCalls(1)); - push_comm.set_push_core_address(CORE_ADDRESS); -} - - #[test] fn test_admin_set_gov_address() { let contract_address = deploy_contract();