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

Bring move-stdlib/src/natives/type_name.rs on par with sui version #419

Open
wants to merge 1 commit into
base: llvm-sys
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
Loading