Skip to content

Commit

Permalink
feat: remove setting gate contract and update js client
Browse files Browse the repository at this point in the history
  • Loading branch information
beqaabu committed Aug 8, 2024
1 parent 4250eaa commit 5bdd35b
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 305 deletions.
91 changes: 0 additions & 91 deletions integration-tests/src/test/gate-token.test.ts

This file was deleted.

47 changes: 0 additions & 47 deletions integration-tests/src/test/set-gate-contract.test.ts

This file was deleted.

41 changes: 0 additions & 41 deletions integration-tests/src/test/set-gate-faucet.test.ts

This file was deleted.

10 changes: 0 additions & 10 deletions pallets/creditcoin/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,6 @@ benchmarks! {
let signature = ecdsa_sign(ktypeid, &pkey, &message).expect("ecdsa signature");
let proof = OwnershipProof::EthSign(signature);
}: _(RawOrigin::Signed(who), Blockchain::Ethereum, address, proof)

set_gate_contract {
let root = RawOrigin::Root;
let contract = DeployedContract::default();
}: _(root, contract)

set_gate_faucet {
let root = RawOrigin::Root;
let addr: T::AccountId = lender_account::<T>(false);
}: _(root, addr)
}

fn generate_funded_deal<T: Config>(
Expand Down
23 changes: 0 additions & 23 deletions pallets/creditcoin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ pub mod pallet {
fn register_deal_order() -> Weight;
fn remove_authority() -> Weight;
fn register_address_v2() -> Weight;
fn set_gate_contract() -> Weight;
fn set_gate_faucet() -> Weight;
}

#[pallet::pallet]
Expand Down Expand Up @@ -1399,26 +1397,5 @@ pub mod pallet {
},
}
}

/// Set the onchain details for the Gluwa GATE Contract, including its address and the blockchain where it is deployed.
/// This extrinsic expects the caller to have root permissions.
#[pallet::call_index(23)]
#[pallet::weight(<T as Config>::WeightInfo::set_gate_contract())]
pub fn set_gate_contract(
origin: OriginFor<T>,
contract: DeployedContract,
) -> DispatchResult {
ensure_root(origin)?;
GATEContract::<T>::put(contract);
Ok(())
}

#[pallet::call_index(24)]
#[pallet::weight(<T as Config>::WeightInfo::set_gate_faucet())]
pub fn set_gate_faucet(origin: OriginFor<T>, address: T::AccountId) -> DispatchResult {
ensure_root(origin)?;
GATEFaucetAccount::<T>::put(address);
Ok(())
}
}
}
60 changes: 0 additions & 60 deletions pallets/creditcoin/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2928,12 +2928,6 @@ fn exercise_weightinfo_functions() {

let result = super::weights::WeightInfo::<Test>::register_address_v2();
assert!(result.ref_time() > 0);

let result = super::weights::WeightInfo::<Test>::set_gate_contract();
assert!(result.ref_time() > 0);

let result = super::weights::WeightInfo::<Test>::set_gate_faucet();
assert!(result.ref_time() > 0);
}

#[test]
Expand Down Expand Up @@ -3246,60 +3240,6 @@ fn gate_contract_storage_should_return_default_goerli_contract_when_not_set() {
});
}

#[test]
fn set_gate_contract_should_fail_when_not_signed_by_root() {
ExtBuilder::default().build_and_execute(|| {
let acct: AccountId = AccountId::new([0; 32]);
let gate_contract = DeployedContract::default();

assert_noop!(Creditcoin::set_gate_contract(Origin::signed(acct), gate_contract), BadOrigin);
});
}

#[test]
fn set_gate_contract_passes_and_storage_is_updated() {
ExtBuilder::default().build_and_execute(|| {
let fake_address =
sp_core::H160([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);

let gate_contract =
DeployedContract { address: fake_address, chain: Blockchain::Luniverse };

assert_ne!(gate_contract, DeployedContract::default());
assert_eq!(Creditcoin::gate_contract(), DeployedContract::default());
assert_ok!(Creditcoin::set_gate_contract(RawOrigin::Root.into(), gate_contract));

let stored_contract = Creditcoin::gate_contract();

assert_eq!(stored_contract.address, fake_address);
assert_eq!(stored_contract.chain, Blockchain::Luniverse);
});
}

#[test]
fn set_gate_faucet_should_fail_when_not_signed_by_root() {
ExtBuilder::default().build_and_execute(|| {
let acct: AccountId = AccountId::new([0; 32]);

assert_noop!(Creditcoin::set_gate_faucet(Origin::signed(acct.clone()), acct), BadOrigin);
});
}

#[test]
fn set_gate_faucet_passes_and_storage_is_updated() {
ExtBuilder::default().build_and_execute(|| {
let addr: AccountId = AccountId::new([0; 32]);

assert!(Creditcoin::gate_faucet_account().is_none());
assert_ok!(Creditcoin::set_gate_faucet(RawOrigin::Root.into(), addr.clone()));

let faucet_addr: Option<AccountId32> = Creditcoin::gate_faucet_account();

assert!(faucet_addr.is_some());
assert_eq!(faucet_addr.unwrap(), addr)
});
}

#[test]
fn gate_faucet_account_storage_should_return_none_when_not_set() {
ExtBuilder::default().build_and_execute(|| {
Expand Down
12 changes: 1 addition & 11 deletions pallets/creditcoin/src/types/collect_coins.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::types::{AddressId, Blockchain, ExternalAddress, ExternalTxId, SystemConfig};
use crate::types::{AddressId, Blockchain, ExternalTxId, SystemConfig};
use frame_support::RuntimeDebug;
use ocw::tasks::collect_coins::DeployedContract;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;

Expand All @@ -12,14 +11,6 @@ pub struct CollectedCoins<Hash, Balance> {
pub contract_type: ContractType,
}

#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct UnverifiedCollectedCoins {
pub to: ExternalAddress,
pub tx_id: ExternalTxId,
pub contract: DeployedContract,
pub contract_type: ContractType,
}

#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct CollectedCoinsId<Hash>(Hash);

Expand Down Expand Up @@ -53,7 +44,6 @@ impl<H> From<H> for CollectedCoinsId<H> {
Self(hash)
}
}
use crate::ocw;
use crate::types::concatenate;
use sp_runtime::traits::Hash;

Expand Down
22 changes: 0 additions & 22 deletions pallets/creditcoin/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,26 +377,4 @@ impl<T: frame_system::Config> crate::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Creditcoin GATEContract (r:0 w:1)
/// Proof: Creditcoin GATEContract (max_values: Some(1), max_size: Some(279), added: 774, mode: MaxEncodedLen)
fn set_gate_contract() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 6_100_000 picoseconds.
Weight::from_parts(6_600_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: Creditcoin GATEFaucetAccount (r:0 w:1)
/// Proof: Creditcoin GATEFaucetAccount (max_values: Some(1), max_size: Some(32), added: 527, mode: MaxEncodedLen)
fn set_gate_faucet() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 6_000_000 picoseconds.
Weight::from_parts(6_700_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
}

0 comments on commit 5bdd35b

Please sign in to comment.