Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug #1178 - use Timepoint on get_ledger_timestamp #1282

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion soroban-env-common/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"export": "4",
"name": "get_ledger_timestamp",
"args": [],
"return": "U64Val",
"return": "TimepointVal",
"docs": "Return the timestamp number of the current ledger as a u64."
},
{
Expand Down
5 changes: 3 additions & 2 deletions soroban-env-common/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::Object;
use super::Symbol;
use super::{
AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I256Val,
I64Object, MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object,
U256Object, U256Val, U32Val, U64Object, U64Val, Val, VecObject, Void,
I64Object, MapObject, StorageType, StringObject, SymbolObject, TimepointObject, TimepointVal,
U128Object, U256Object, U256Val, U32Val, U64Object, U64Val, Val, VecObject, Void,
};
use crate::xdr::{ScErrorCode, ScErrorType};

Expand Down Expand Up @@ -235,6 +235,7 @@ impl_checkedenvarg_for_val_or_wrapper!(BytesObject);
impl_checkedenvarg_for_val_or_wrapper!(DurationObject);

impl_checkedenvarg_for_val_or_wrapper!(TimepointObject);
impl_checkedenvarg_for_val_or_wrapper!(TimepointVal);
impl_checkedenvarg_for_val_or_wrapper!(SymbolObject);
impl_checkedenvarg_for_val_or_wrapper!(StringObject);

Expand Down
4 changes: 2 additions & 2 deletions soroban-env-common/src/vmcaller_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::xdr::{ScErrorCode, ScErrorType};

use super::{
AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I256Val,
I64Object, MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object,
U256Object, U256Val, U32Val, U64Object, U64Val, Val, VecObject, Void,
I64Object, MapObject, StorageType, StringObject, SymbolObject, TimepointObject, TimepointVal,
U128Object, U256Object, U256Val, U32Val, U64Object, Val, VecObject, Void,
};
use crate::call_macro_with_all_host_functions;
use crate::{CheckedEnvArg, EnvBase, Symbol};
Expand Down
6 changes: 3 additions & 3 deletions soroban-env-guest/src/guest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use soroban_env_common::call_macro_with_all_host_functions;

use super::{
AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I256Val,
I64Object, MapObject, StorageType, StringObject, SymbolObject, TimepointObject, U128Object,
U256Object, U256Val, U32Val, U64Object, U64Val, Val, VecObject, Void,
I64Object, MapObject, StorageType, StringObject, SymbolObject, TimepointObject, TimepointVal,
U128Object, U256Object, U256Val, U32Val, U64Object, Val, VecObject, Void,
};
use super::{Env, EnvBase, Symbol};
use static_assertions as sa;
Expand Down Expand Up @@ -329,7 +329,7 @@ macro_rules! generate_extern_modules {
#[allow(unused_imports)]
use crate::{Val,Object,Symbol,Error,MapObject,VecObject,BytesObject};
#[allow(unused_imports)]
use crate::{I128Object, I256Object, I256Val, I64Object, I64Val, U128Object, U256Object, U256Val, U32Val, U64Object, U64Val, StorageType, TimepointObject, DurationObject};
use crate::{I128Object, I256Object, I256Val, I64Object, I64Val, U128Object, U256Object, U256Val, U32Val, U64Object, U64Val, StorageType, TimepointObject, TimepointVal, DurationObject};
#[allow(unused_imports)]
use crate::{Void,AddressObject,SymbolObject,StringObject,Bool};
#[link(wasm_import_module = $mod_str)]
Expand Down
11 changes: 7 additions & 4 deletions soroban-env-host/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ use crate::{
},
AddressObject, Bool, BytesObject, Compare, ConversionError, EnvBase, Error, I128Object,
I256Object, MapObject, Object, StorageType, StringObject, Symbol, SymbolObject, SymbolSmall,
TryFromVal, U128Object, U256Object, U32Val, U64Val, Val, VecObject, Vm, VmCaller, VmCallerEnv,
Void, I256, U256,
TimepointVal, TryFromVal, U128Object, U256Object, U32Val, Val, VecObject, Vm, VmCaller,
VmCallerEnv, Void, I256, U256,
};

mod comparison;
Expand Down Expand Up @@ -1052,8 +1052,11 @@ impl VmCallerEnv for Host {
self.with_ledger_info(|li| Ok(li.sequence_number.into()))
}

fn get_ledger_timestamp(&self, _vmcaller: &mut VmCaller<Host>) -> Result<U64Val, Self::Error> {
self.with_ledger_info(|li| Ok(U64Val::try_from_val(self, &li.timestamp)?))
fn get_ledger_timestamp(
&self,
_vmcaller: &mut VmCaller<Host>,
) -> Result<TimepointVal, Self::Error> {
self.with_ledger_info(|li| Ok(TimepointVal::try_from_val(self, &li.timestamp)?))
}

fn fail_with_error(
Expand Down
3 changes: 2 additions & 1 deletion soroban-env-host/src/vm/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
use crate::{
AddressObject, Bool, BytesObject, DurationObject, Error, I128Object, I256Object, I256Val,
I64Object, MapObject, StorageType, StringObject, Symbol, SymbolObject, TimepointObject,
U128Object, U256Object, U256Val, U32Val, U64Object, U64Val, Val, VecObject, Void,
TimepointVal, U128Object, U256Object, U256Val, U32Val, U64Object, U64Val, Val, VecObject, Void,
};
use soroban_env_common::{call_macro_with_all_host_functions, WasmiMarshal};
use wasmi::{
Expand Down Expand Up @@ -61,6 +61,7 @@ impl_relative_object_conversion!(BytesObject);
impl_relative_object_conversion!(DurationObject);

impl_relative_object_conversion!(TimepointObject);
impl_relative_object_conversion!(TimepointVal);
impl_relative_object_conversion!(SymbolObject);
impl_relative_object_conversion!(StringObject);

Expand Down
Loading