Skip to content

Commit

Permalink
[Caviarnine Adapter v1]: Small rename
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOmarA committed Jan 29, 2024
1 parent b569559 commit 174ab4f
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ mod bootstrap {
let caviarnine_adapter = scrypto_decode::<ComponentAddress>(
&ScryptoVmV1Api::blueprint_call(
caviarnine_adapter_v1_package_address,
"CaviarNineAdapter",
"CaviarnineAdapter",
"instantiate",
scrypto_args!(
OwnerRole::None,
Expand All @@ -149,7 +149,7 @@ mod bootstrap {
),
)
.map(|address| {
Global::<CaviarNineAdapter>(CaviarNineAdapterObjectStub {
Global::<CaviarnineAdapter>(CaviarnineAdapterObjectStub {
handle: ObjectStubHandle::Global(address.into()),
})
})
Expand Down
13 changes: 9 additions & 4 deletions packages/caviarnine-adapter-v1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ pub const PREFERRED_TOTAL_NUMBER_OF_HIGHER_AND_LOWER_BINS: u32 = 10 * 2;

#[blueprint_with_traits]
pub mod adapter {
struct CaviarNineAdapter;
struct CaviarnineAdapter;

impl CaviarNineAdapter {
impl CaviarnineAdapter {
pub fn instantiate(
metadata_init: MetadataInit,
owner_role: OwnerRole,
address_reservation: Option<GlobalAddressReservation>,
) -> Global<CaviarNineAdapter> {
) -> Global<CaviarnineAdapter> {
let address_reservation = address_reservation.unwrap_or(
Runtime::allocate_component_address(BlueprintId {
package_address: Runtime::package_address(),
Expand All @@ -62,6 +63,10 @@ pub mod adapter {
Self {}
.instantiate()
.prepare_to_globalize(owner_role)
.metadata(ModuleConfig {
init: metadata_init,
roles: Default::default(),
})
.with_address(address_reservation)
.globalize()
}
Expand All @@ -73,7 +78,7 @@ pub mod adapter {
}
}

impl PoolAdapterInterfaceTrait for CaviarNineAdapter {
impl PoolAdapterInterfaceTrait for CaviarnineAdapter {
fn open_liquidity_position(
&mut self,
pool_address: ComponentAddress,
Expand Down
6 changes: 5 additions & 1 deletion packages/ignition/src/blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ mod ignition {
/// Instantiates a new Ignition protocol component based on the provided
/// protocol parameters.
pub fn instantiate(
metadata_init: MetadataInit,
/* Rules */
owner_role: OwnerRole,
protocol_owner_role: AccessRule,
Expand Down Expand Up @@ -347,11 +348,14 @@ mod ignition {
ignition
.instantiate()
.prepare_to_globalize(owner_role)
// TODO: update metadata
.roles(roles! {
protocol_owner => protocol_owner_role;
protocol_manager => protocol_manager_role;
})
.metadata(ModuleConfig {
init: metadata_init,
roles: Default::default(),
})
.with_address(address_reservation)
.globalize()
}
Expand Down
5 changes: 5 additions & 0 deletions packages/ociswap-adapter-v1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub mod adapter {

impl OciswapAdapter {
pub fn instantiate(
metadata_init: MetadataInit,
owner_role: OwnerRole,
address_reservation: Option<GlobalAddressReservation>,
) -> Global<OciswapAdapter> {
Expand All @@ -51,6 +52,10 @@ pub mod adapter {
Self {}
.instantiate()
.prepare_to_globalize(owner_role)
.metadata(ModuleConfig {
init: metadata_init,
roles: Default::default(),
})
.with_address(address_reservation)
.globalize()
}
Expand Down
5 changes: 5 additions & 0 deletions packages/simple-oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ mod simple_oracle {
impl SimpleOracle {
pub fn instantiate(
oracle_manager: AccessRule,
metadata_init: MetadataInit,
owner_role: OwnerRole,
address_reservation: Option<GlobalAddressReservation>,
) -> Global<SimpleOracle> {
Expand All @@ -45,6 +46,10 @@ mod simple_oracle {
.roles(roles! {
oracle_manager => oracle_manager;
})
.metadata(ModuleConfig {
init: metadata_init,
roles: Default::default(),
})
.with_address(address_reservation)
.globalize()
}
Expand Down
13 changes: 10 additions & 3 deletions tests/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl EnvironmentSpecifier for ScryptoTestEnvironmentSpecifier {
type CaviarninePool = CaviarNinePoolInterfaceScryptoTestStub;

type OciswapAdapter = OciswapAdapter;
type CaviarnineAdapter = CaviarNineAdapter;
type CaviarnineAdapter = CaviarnineAdapter;

// Badges
type Badge = Bucket;
Expand Down Expand Up @@ -268,12 +268,14 @@ impl ScryptoTestEnv {
// Instantiating the components.
let mut simple_oracle = SimpleOracle::instantiate(
protocol_manager_rule.clone(),
Default::default(),
OwnerRole::None,
None,
simple_oracle_package,
&mut env,
)?;
let mut ignition = Ignition::instantiate(
Default::default(),
OwnerRole::None,
protocol_owner_rule,
protocol_manager_rule,
Expand All @@ -287,12 +289,14 @@ impl ScryptoTestEnv {
&mut env,
)?;
let ociswap_adapter_v1 = OciswapAdapter::instantiate(
Default::default(),
OwnerRole::None,
None,
ociswap_adapter_v1_package,
&mut env,
)?;
let caviarnine_adapter_v1 = CaviarNineAdapter::instantiate(
let caviarnine_adapter_v1 = CaviarnineAdapter::instantiate(
Default::default(),
OwnerRole::None,
None,
caviarnine_adapter_v1_package,
Expand Down Expand Up @@ -629,6 +633,7 @@ impl ScryptoUnitEnv {
"instantiate",
(
protocol_manager_rule.clone(),
MetadataInit::default(),
OwnerRole::None,
None::<ManifestAddressReservation>,
),
Expand Down Expand Up @@ -668,6 +673,7 @@ impl ScryptoUnitEnv {
"Ignition",
"instantiate",
(
MetadataInit::default(),
OwnerRole::None,
protocol_owner_rule,
protocol_manager_rule,
Expand All @@ -692,7 +698,7 @@ impl ScryptoUnitEnv {

let [ociswap_adapter_v1, caviarnine_adapter_v1] = [
(ociswap_adapter_v1_package, "OciswapAdapter"),
(caviarnine_adapter_v1_package, "CaviarNineAdapter"),
(caviarnine_adapter_v1_package, "CaviarnineAdapter"),
]
.map(|(package_address, blueprint_name)| {
test_runner
Expand All @@ -704,6 +710,7 @@ impl ScryptoUnitEnv {
blueprint_name,
"instantiate",
(
MetadataInit::default(),
OwnerRole::None,
None::<ManifestAddressReservation>,
),
Expand Down

0 comments on commit 174ab4f

Please sign in to comment.