Skip to content

Commit

Permalink
Adapt {ui}{128,256} to new xdr definitions; add {ui}256 host functions (
Browse files Browse the repository at this point in the history
#763)

* Adapt {ui}{128,256} to new xdr definitions; add {ui}256 host functions

* Redirect XDR back to stellar/rs-stellar-xdr

---------

Co-authored-by: Graydon Hoare <[email protected]>
  • Loading branch information
jayz22 and graydon authored Apr 12, 2023
1 parent 8846543 commit 39270d6
Show file tree
Hide file tree
Showing 29 changed files with 703 additions and 179 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ soroban-native-sdk-macros = { version = "0.0.15", path = "soroban-native-sdk-mac
[workspace.dependencies.stellar-xdr]
version = "0.0.15"
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "bcf6f4c3a9dd32822a20af89880650a421d10e7f"
rev = "8035c58fa4753de06ec034905d2240addf8b37a6"
default-features = false

[workspace.dependencies.wasmi]
Expand Down
160 changes: 152 additions & 8 deletions soroban-env-common/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,16 @@
"name": "obj_from_u128_pieces",
"args": [
{
"name": "lo",
"name": "hi",
"type": "u64"
},
{
"name": "hi",
"name": "lo",
"type": "u64"
}
],
"return": "U128Object",
"docs": "Convert the low and high 64-bit words of a u128 to an object containing a u128."
"docs": "Convert the high and low 64-bit words of a u128 to an object containing a u128."
},
{
"export": "6",
Expand Down Expand Up @@ -231,16 +231,16 @@
"name": "obj_from_i128_pieces",
"args": [
{
"name": "lo",
"type": "u64"
"name": "hi",
"type": "i64"
},
{
"name": "hi",
"name": "lo",
"type": "u64"
}
],
"return": "I128Object",
"docs": "Convert the lo and hi 64-bit words of an i128 to an object containing an i128."
"docs": "Convert the high and low 64-bit words of an i128 to an object containing an i128."
},
{
"export": "9",
Expand All @@ -263,8 +263,152 @@
"type": "I128Object"
}
],
"return": "u64",
"return": "i64",
"docs": "Extract the high 64 bits from an object containing an i128."
},
{
"export": "b",
"name": "obj_from_u256_pieces",
"args": [
{
"name": "hi_hi",
"type": "u64"
},
{
"name": "hi_lo",
"type": "u64"
},
{
"name": "lo_hi",
"type": "u64"
},
{
"name": "lo_lo",
"type": "u64"
}
],
"return": "U256Object",
"docs": "Convert the four 64-bit words of an u256 (big-endian) to an object containing an u256."
},
{
"export": "c",
"name": "obj_to_u256_hi_hi",
"args": [
{
"name": "obj",
"type": "U256Object"
}
],
"return": "u64",
"docs": "Extract the highest 64-bits (bits 192-255) from an object containing an u256."
},
{
"export": "d",
"name": "obj_to_u256_hi_lo",
"args": [
{
"name": "obj",
"type": "U256Object"
}
],
"return": "u64",
"docs": "Extract bits 128-191 from an object containing an u256."
},
{
"export": "e",
"name": "obj_to_u256_lo_hi",
"args": [
{
"name": "obj",
"type": "U256Object"
}
],
"return": "u64",
"docs": "Extract bits 64-127 from an object containing an u256."
},
{
"export": "f",
"name": "obj_to_u256_lo_lo",
"args": [
{
"name": "obj",
"type": "U256Object"
}
],
"return": "u64",
"docs": "Extract the lowest 64-bits (bits 0-63) from an object containing an u256."
},
{
"export": "g",
"name": "obj_from_i256_pieces",
"args": [
{
"name": "hi_hi",
"type": "i64"
},
{
"name": "hi_lo",
"type": "u64"
},
{
"name": "lo_hi",
"type": "u64"
},
{
"name": "lo_lo",
"type": "u64"
}
],
"return": "I256Object",
"docs": "Convert the four 64-bit words of an i256 (big-endian) to an object containing an i256."
},
{
"export": "h",
"name": "obj_to_i256_hi_hi",
"args": [
{
"name": "obj",
"type": "I256Object"
}
],
"return": "i64",
"docs": "Extract the highest 64-bits (bits 192-255) from an object containing an i256."
},
{
"export": "i",
"name": "obj_to_i256_hi_lo",
"args": [
{
"name": "obj",
"type": "I256Object"
}
],
"return": "u64",
"docs": "Extract bits 128-191 from an object containing an i256."
},
{
"export": "j",
"name": "obj_to_i256_lo_hi",
"args": [
{
"name": "obj",
"type": "I256Object"
}
],
"return": "u64",
"docs": "Extract bits 64-127 from an object containing an i256."
},
{
"export": "k",
"name": "obj_to_i256_lo_lo",
"args": [
{
"name": "obj",
"type": "I256Object"
}
],
"return": "u64",
"docs": "Extract the lowest 64-bits (bits 0-63) from an object containing an i256."
}
]
},
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 @@ -2,8 +2,9 @@ use soroban_env_macros::generate_call_macro_with_all_host_functions;

use super::Symbol;
use super::{
AddressObject, Bool, BytesObject, I128Object, I64Object, MapObject, Object, RawVal, Status,
StringObject, SymbolObject, U128Object, U32Val, U64Object, U64Val, VecObject, Void,
AddressObject, Bool, BytesObject, I128Object, I256Object, I64Object, MapObject, Object, RawVal,
Status, StringObject, SymbolObject, U128Object, U256Object, U32Val, U64Object, U64Val,
VecObject, Void,
};
use core::any;

Expand Down
Loading

0 comments on commit 39270d6

Please sign in to comment.