Skip to content

Commit

Permalink
Merge pull request #1857 from radixdlt/system-api-interface-refactor
Browse files Browse the repository at this point in the history
refactor: Prefer parameter bounds over where clause
  • Loading branch information
dhedey authored Aug 7, 2024
2 parents 861e2b8 + eff159b commit ed7cedf
Show file tree
Hide file tree
Showing 101 changed files with 2,699 additions and 3,838 deletions.
358 changes: 333 additions & 25 deletions examples/everything/Cargo.lock

Large diffs are not rendered by default.

359 changes: 333 additions & 26 deletions examples/hello-world/Cargo.lock

Large diffs are not rendered by default.

87 changes: 64 additions & 23 deletions radix-clis/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions radix-engine-interface/src/api/actor_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::internal_prelude::*;
use crate::types::*;
use bitflags::bitflags;
use radix_engine_interface::api::{ActorStateHandle, LockFlags};
use sbor::rust::fmt::Debug;
use sbor::rust::string::String;
use sbor::rust::vec::Vec;

Expand All @@ -17,7 +16,7 @@ bitflags! {
}

/// Api which exposes methods in the context of the actor
pub trait SystemActorApi<E: Debug> {
pub trait SystemActorApi<E> {
/// Retrieve the current blueprint id
fn actor_get_blueprint_id(&mut self) -> Result<BlueprintId, E>;

Expand Down
3 changes: 1 addition & 2 deletions radix-engine-interface/src/api/actor_key_value_entry_api.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use radix_common::data::scrypto::{scrypto_decode, ScryptoDecode};
use radix_engine_interface::api::key_value_entry_api::KeyValueEntryHandle;
use radix_engine_interface::api::{ActorStateHandle, CollectionIndex, LockFlags};
use sbor::rust::fmt::Debug;
use sbor::rust::vec::Vec;

pub trait SystemActorKeyValueEntryApi<E: Debug> {
pub trait SystemActorKeyValueEntryApi<E> {
/// Returns a handle for a specified key value entry in a collection. If an invalid collection
/// index or key is passed an error is returned.
fn actor_open_key_value_entry(
Expand Down
6 changes: 5 additions & 1 deletion radix-engine-interface/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ pub const ACTOR_REF_AUTH_ZONE: ActorRefHandle = 8u32;
pub type FieldIndex = u8;
pub type CollectionIndex = u8;

use radix_common::prelude::*;

pub trait SystemApiError: fmt::Debug + ScryptoCategorize + ScryptoDecode {}

/// Interface of the system, for blueprints and object modules.
///
/// For WASM blueprints, only a subset of the API is exposed at the moment.
pub trait SystemApi<E: sbor::rust::fmt::Debug>:
pub trait SystemApi<E: SystemApiError>:
SystemActorApi<E>
+ SystemActorKeyValueEntryApi<E>
+ SystemObjectApi<E>
Expand Down
11 changes: 5 additions & 6 deletions radix-engine-monkey-tests/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ pub const CUSTOM_PACKAGE_CODE_ID: u64 = 1024;
#[derive(Clone)]
pub struct ResourceTestInvoke;
impl VmInvoke for ResourceTestInvoke {
fn invoke<Y, V>(
fn invoke<
Y: SystemApi<RuntimeError> + KernelNodeApi + KernelSubstateApi<SystemLockData>,
V: VmApi,
>(
&mut self,
export_name: &str,
input: &IndexedScryptoValue,
api: &mut Y,
_vm_api: &V,
) -> Result<IndexedScryptoValue, RuntimeError>
where
Y: SystemApi<RuntimeError> + KernelNodeApi + KernelSubstateApi<SystemLockData>,
V: VmApi,
{
) -> Result<IndexedScryptoValue, RuntimeError> {
match export_name {
"call_vault" => {
let handle = api
Expand Down
Loading

0 comments on commit ed7cedf

Please sign in to comment.