Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
Bring move-stdlib/src/natives/type_name.rs on par with sui version
Browse files Browse the repository at this point in the history
  • Loading branch information
ksolana committed Mar 4, 2024
1 parent 5acd116 commit 20bdbf5
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions language/move-stdlib/src/natives/type_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct GetGasParameters {
}

fn native_get(
use_original_id: bool,
gas_params: &GetGasParameters,
context: &mut NativeContext,
ty_args: Vec<Type>,
Expand All @@ -42,8 +43,10 @@ fn native_get(
Ok(NativeResult::ok(cost, smallvec![type_name_val]))
}

pub fn make_native_get(gas_params: GetGasParameters) -> NativeFunction {
Arc::new(move |context, ty_args, args| native_get(&gas_params, context, ty_args, args))
pub fn make_native_get(use_original_id: bool, gas_params: GetGasParameters) -> NativeFunction {
Arc::new(move |context, ty_args, args| {
native_get(use_original_id, &gas_params, context, ty_args, args)
})
}

#[derive(Debug, Clone)]
Expand All @@ -52,7 +55,16 @@ pub struct GasParameters {
}

pub fn make_all(gas_params: GasParameters) -> impl Iterator<Item = (String, NativeFunction)> {
let natives = [("get", make_native_get(gas_params.get))];
let natives = [
(
"get",
make_native_get(/* use_original_id */ false, gas_params.get.clone()),
),
(
"get_with_original_ids",
make_native_get(/* use_original_id */ true, gas_params.get),
),
];

crate::natives::helpers::make_module_natives(natives)
}

0 comments on commit 20bdbf5

Please sign in to comment.