From 7c9a0469fb7b4ee27531b96bf6fffcb9816b47f9 Mon Sep 17 00:00:00 2001 From: Jemiiah <160767568+Jemiiah@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:36:59 +0100 Subject: [PATCH] added registry component (#77) * added registry component * fix registry integration --------- Co-authored-by: Ikem Peter Co-authored-by: Chqrles --- .../src/contracts/ramps/revolut/revolut.cairo | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/contracts/src/contracts/ramps/revolut/revolut.cairo b/contracts/src/contracts/ramps/revolut/revolut.cairo index c177fb9..4b489cb 100644 --- a/contracts/src/contracts/ramps/revolut/revolut.cairo +++ b/contracts/src/contracts/ramps/revolut/revolut.cairo @@ -4,16 +4,22 @@ pub mod RevolutRamp { use openzeppelin::access::ownable::OwnableComponent; use starknet::storage::Map; use starknet::{ContractAddress, get_caller_address}; - use zkramp::components::registry::interface::OffchainId; + use zkramp::components::registry::interface::{OffchainId, IRegistry}; + use zkramp::components::registry::registry::RegistryComponent; use zkramp::contracts::ramps::revolut::interface::{LiquidityKey, IZKRampLiquidity}; component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); + component!(path: RegistryComponent, storage: registry, event: RegistryEvent); // Ownable #[abi(embed_v0)] impl OwnableMixinImpl = OwnableComponent::OwnableMixinImpl; impl OwnableInternalImpl = OwnableComponent::InternalImpl; + // Registry + #[abi(embed_v0)] + impl RegistryImpl = RegistryComponent::RegistryImpl; + // // Storage // @@ -22,6 +28,8 @@ pub mod RevolutRamp { struct Storage { #[substorage(v0)] ownable: OwnableComponent::Storage, + #[substorage(v0)] + registry: RegistryComponent::Storage, token: ContractAddress, // liquidity_key -> amount liquidity: Map::, @@ -55,6 +63,8 @@ pub mod RevolutRamp { enum Event { #[flat] OwnableEvent: OwnableComponent::Event, + #[flat] + RegistryEvent: RegistryComponent::Event, LiquidityAdded: LiquidityAdded, } @@ -70,15 +80,6 @@ pub mod RevolutRamp { self.token.write(token); } - - #[generate_trait] - impl Private of PrivateTrait { - // just a mock - fn is_registered(self: @ContractState, contract_address: ContractAddress, offchain_id: OffchainId) -> bool { - true - } - } - #[abi(embed_v0)] impl ZKRampLiquidityImpl of IZKRampLiquidity { /// Create a liquidity position by locking an amonunt and asking for @@ -90,7 +91,7 @@ pub mod RevolutRamp { let caller = get_caller_address(); // assert caller registered the offchain ID - assert(self.is_registered(contract_address: caller, :offchain_id), Errors::NOT_REGISTERED); + assert(self.registry.is_registered(contract_address: caller, :offchain_id), Errors::NOT_REGISTERED); assert(amount.is_non_zero(), Errors::INVALID_AMOUNT); // get liquidity key