ソースを参照

Do not use out of date ethereum_types but ethabi::ethereum_types

Just use the re-export which will always give the right version.

Signed-off-by: Sean Young <sean@mess.org>
Sean Young 3 年 前
コミット
ed49e8da8a

+ 5 - 3
Cargo.toml

@@ -37,7 +37,7 @@ base58 = "0.2.0"
 sha2 = "0.10"
 ripemd = "0.1"
 bitvec = "0.20"
-funty = "=1.1.0"
+funty = "2.0"
 itertools = "0.10"
 num-rational = "0.4"
 indexmap = "1.8"
@@ -50,17 +50,19 @@ num-derive = "0.3"
 parity-scale-codec-derive = "2.0.0"
 parity-scale-codec = "2.0.0"
 ethabi = "16.0"
-ethereum-types = "0.12"
 wasmi = "0.11"
 rand = "0.7"
 sha2 = "0.10"
 # solana_rbpf makes api changes in patch versions
-solana_rbpf = "=0.2.21"
+solana_rbpf = "=0.2.23"
 byteorder = "1.3"
 assert_cmd = "2.0"
 bincode = "1.3"
 ed25519-dalek = "1.0"
 
+[package.metadata.docs.rs]
+no-default-features = true
+
 [profile.release]
 lto = true
 

+ 1 - 1
tests/ewasm.rs

@@ -1,4 +1,4 @@
-use ethabi::{decode, RawLog, Token};
+use ethabi::{decode, ethereum_types, RawLog, Token};
 use num_derive::FromPrimitive;
 use num_traits::FromPrimitive;
 use rand::Rng;

+ 2 - 2
tests/ewasm_tests/abi.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::{encode, Token};
+use ethabi::{encode, ethereum_types::U256, Token};
 
 #[test]
 fn abi_encode() {
@@ -38,7 +38,7 @@ fn abi_encode() {
 
     bytes.extend(
         encode(&[
-            Token::Int(ethereum_types::U256::from(102)),
+            Token::Int(U256::from(102)),
             Token::FixedBytes(b"ABCD".to_vec()),
         ])
         .iter(),

+ 27 - 46
tests/ewasm_tests/primitives.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethereum_types::Address;
+use ethabi::ethereum_types::{Address, U256};
 use num_bigint::{BigInt, BigUint};
 use rand::Rng;
 use std::ops::Add;
@@ -152,15 +152,9 @@ fn test_enum() {
 
     let returns = vm.function("return_enum", &[]);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(9))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(9))]);
 
-    vm.function(
-        "enum_arg",
-        &[ethabi::Token::Uint(ethereum_types::U256::from(6))],
-    );
+    vm.function("enum_arg", &[ethabi::Token::Uint(U256::from(6))]);
 }
 
 #[test]
@@ -282,7 +276,7 @@ fn bytes() {
                 "shift_left",
                 &[
                     ethabi::Token::FixedBytes(a.to_vec()),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
+                    ethabi::Token::Uint(U256::from(r)),
                 ],
             );
 
@@ -302,7 +296,7 @@ fn bytes() {
                 "shift_right",
                 &[
                     ethabi::Token::FixedBytes(a.to_vec()),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
+                    ethabi::Token::Uint(U256::from(r)),
                 ],
             );
 
@@ -384,8 +378,8 @@ fn uint() {
             rng.fill(&mut a[..]);
             rng.fill(&mut b[..]);
 
-            let mut a = ethereum_types::U256::from_big_endian(&a);
-            let mut b = ethereum_types::U256::from_big_endian(&b);
+            let mut a = U256::from_big_endian(&a);
+            let mut b = U256::from_big_endian(&b);
 
             rng.fill(&mut a.0[..]);
             rng.fill(&mut b.0[..]);
@@ -425,7 +419,7 @@ fn uint() {
 
             assert_eq!(pow, vec![ethabi::Token::Uint(res)]);
 
-            if b != ethereum_types::U256::zero() {
+            if b != U256::zero() {
                 let div = vm.function("div", &[ethabi::Token::Uint(a), ethabi::Token::Uint(b)]);
 
                 let mut res = a.div(b);
@@ -446,7 +440,7 @@ fn uint() {
 
             let or = vm.function("or", &[ethabi::Token::Uint(a), ethabi::Token::Uint(b)]);
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] | b.0[0],
                 a.0[1] | b.0[1],
                 a.0[2] | b.0[2],
@@ -459,7 +453,7 @@ fn uint() {
 
             let and = vm.function("and", &[ethabi::Token::Uint(a), ethabi::Token::Uint(b)]);
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] & b.0[0],
                 a.0[1] & b.0[1],
                 a.0[2] & b.0[2],
@@ -472,7 +466,7 @@ fn uint() {
 
             let xor = vm.function("xor", &[ethabi::Token::Uint(a), ethabi::Token::Uint(b)]);
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] ^ b.0[0],
                 a.0[1] ^ b.0[1],
                 a.0[2] ^ b.0[2],
@@ -487,10 +481,7 @@ fn uint() {
 
             let shl = vm.function(
                 "shift_left",
-                &[
-                    ethabi::Token::Uint(a),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
-                ],
+                &[ethabi::Token::Uint(a), ethabi::Token::Uint(U256::from(r))],
             );
 
             let mut res = a.shl(r);
@@ -501,10 +492,7 @@ fn uint() {
 
             let shr = vm.function(
                 "shift_right",
-                &[
-                    ethabi::Token::Uint(a),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
-                ],
+                &[ethabi::Token::Uint(a), ethabi::Token::Uint(U256::from(r))],
             );
 
             let mut res = a.shr(r);
@@ -516,7 +504,7 @@ fn uint() {
     }
 }
 
-fn truncate_uint(n: &mut ethereum_types::U256, width: usize) {
+fn truncate_uint(n: &mut U256, width: usize) {
     let mut bits = 256 - width;
 
     let mut offset = 3;
@@ -596,8 +584,8 @@ fn int() {
             rng.fill(&mut a_bs[..]);
             rng.fill(&mut b_bs[..]);
 
-            let mut a = ethereum_types::U256::from_big_endian(&a_bs);
-            let mut b = ethereum_types::U256::from_big_endian(&b_bs);
+            let mut a = U256::from_big_endian(&a_bs);
+            let mut b = U256::from_big_endian(&b_bs);
 
             truncate_int(&mut a, width);
             truncate_int(&mut b, width);
@@ -625,7 +613,7 @@ fn int() {
 
             assert_eq!(mul, vec![ethabi::Token::Int(res)]);
 
-            if b != ethereum_types::U256::zero() {
+            if b != U256::zero() {
                 let div = vm.function("div", &[ethabi::Token::Int(a), ethabi::Token::Int(b)]);
 
                 let res = bigint_to_eth(&big_a.clone().div(&big_b), width);
@@ -643,7 +631,7 @@ fn int() {
 
             let or = vm.function("or", &[ethabi::Token::Int(a), ethabi::Token::Int(b)]);
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] | b.0[0],
                 a.0[1] | b.0[1],
                 a.0[2] | b.0[2],
@@ -656,7 +644,7 @@ fn int() {
 
             let and = vm.function("and", &[ethabi::Token::Int(a), ethabi::Token::Int(b)]);
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] & b.0[0],
                 a.0[1] & b.0[1],
                 a.0[2] & b.0[2],
@@ -669,7 +657,7 @@ fn int() {
 
             let xor = vm.function("xor", &[ethabi::Token::Int(a), ethabi::Token::Int(b)]);
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] ^ b.0[0],
                 a.0[1] ^ b.0[1],
                 a.0[2] ^ b.0[2],
@@ -684,10 +672,7 @@ fn int() {
 
             let shl = vm.function(
                 "shift_left",
-                &[
-                    ethabi::Token::Int(a),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
-                ],
+                &[ethabi::Token::Int(a), ethabi::Token::Uint(U256::from(r))],
             );
 
             let mut res = a.shl(r);
@@ -698,10 +683,7 @@ fn int() {
 
             let shr = vm.function(
                 "shift_right",
-                &[
-                    ethabi::Token::Int(a),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
-                ],
+                &[ethabi::Token::Int(a), ethabi::Token::Uint(U256::from(r))],
             );
 
             let res = bigint_to_eth(&big_a.clone().shr(r), width);
@@ -711,9 +693,8 @@ fn int() {
     }
 }
 
-fn truncate_int(n: &mut ethereum_types::U256, width: usize) {
-    let sign =
-        n.bitand(ethereum_types::U256::from(1) << (width - 1)) != ethereum_types::U256::zero();
+fn truncate_int(n: &mut U256, width: usize) {
+    let sign = n.bitand(U256::from(1) << (width - 1)) != U256::zero();
 
     let mut bits = 256 - width;
 
@@ -735,7 +716,7 @@ fn truncate_int(n: &mut ethereum_types::U256, width: usize) {
     }
 }
 
-fn bigint_to_eth(v: &BigInt, width: usize) -> ethereum_types::U256 {
+fn bigint_to_eth(v: &BigInt, width: usize) -> U256 {
     let mut buf = v.to_signed_bytes_be();
     let width = width / 8;
 
@@ -749,10 +730,10 @@ fn bigint_to_eth(v: &BigInt, width: usize) -> ethereum_types::U256 {
         buf.insert(0, sign);
     }
 
-    ethereum_types::U256::from_big_endian(&buf)
+    U256::from_big_endian(&buf)
 }
 
-fn eth_to_bigint(v: &ethereum_types::U256, width: usize) -> BigInt {
+fn eth_to_bigint(v: &U256, width: usize) -> BigInt {
     let mut buf = Vec::new();
 
     buf.resize(32, 0);

+ 4 - 4
tests/solana.rs

@@ -2,7 +2,7 @@ mod solana_helpers;
 
 use base58::{FromBase58, ToBase58};
 use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
-use ethabi::{RawLog, Token};
+use ethabi::{ethereum_types::H256, RawLog, Token};
 use libc::c_char;
 use rand::Rng;
 use serde::{Deserialize, Serialize};
@@ -1041,9 +1041,9 @@ impl<'a> SyscallObject<UserError> for SyscallInvokeSignedC<'a> {
                         assert_eq!(create_account.instruction, 3);
 
                         let mut hasher = Sha256::new();
-                        hasher.update(create_account.base);
+                        hasher.update(&create_account.base);
                         hasher.update(create_account.seed);
-                        hasher.update(create_account.program_id);
+                        hasher.update(&create_account.program_id);
 
                         let hash = hasher.finalize();
 
@@ -1528,7 +1528,7 @@ impl VirtualMachine {
                     .map(|topic| {
                         let topic: [u8; 32] = topic.try_into().unwrap();
 
-                        ethereum_types::H256::from(topic)
+                        H256::from(topic)
                     })
                     .collect();
                 let data = fields[1].clone();

+ 8 - 23
tests/solana_tests/accessor.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn types() {
@@ -14,7 +14,7 @@ fn types() {
 
     let returns = vm.function("f1", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Int(ethereum_types::U256::from(102))]);
+    assert_eq!(returns, vec![Token::Int(U256::from(102))]);
 
     let mut vm = build_solidity(
         r#"
@@ -25,15 +25,9 @@ fn types() {
 
     vm.constructor("foo", &[], 0);
 
-    let returns = vm.function(
-        "f1",
-        &[Token::Uint(ethereum_types::U256::from(2))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("f1", &[Token::Uint(U256::from(2))], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Int(ethereum_types::U256::from(5))]);
+    assert_eq!(returns, vec![Token::Int(U256::from(5))]);
 
     let mut vm = build_solidity(
         r#"
@@ -53,16 +47,13 @@ fn types() {
 
     let returns = vm.function(
         "f1",
-        &[
-            Token::Uint(ethereum_types::U256::from(1)),
-            Token::Uint(ethereum_types::U256::from(2)),
-        ],
+        &[Token::Uint(U256::from(1)), Token::Uint(U256::from(2))],
         &[],
         0,
         None,
     );
 
-    assert_eq!(returns, vec![Token::Int(ethereum_types::U256::from(2))]);
+    assert_eq!(returns, vec![Token::Int(U256::from(2))]);
 
     let mut vm = build_solidity(
         r#"
@@ -78,15 +69,9 @@ fn types() {
 
     vm.constructor("foo", &[], 0);
 
-    let returns = vm.function(
-        "f1",
-        &[Token::Int(ethereum_types::U256::from(4000))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("f1", &[Token::Int(U256::from(4000))], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(2))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(2))]);
 }
 
 #[test]

+ 5 - 14
tests/solana_tests/account_info.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn lamports() {
@@ -30,10 +30,7 @@ fn lamports() {
 
     let returns = vm.function("test", &[], &[], 0, None);
 
-    assert_eq!(
-        returns[0],
-        Token::Uint(ethereum_types::U256::from(17672630920854456917u64))
-    );
+    assert_eq!(returns[0], Token::Uint(U256::from(17672630920854456917u64)));
 }
 
 #[test]
@@ -98,19 +95,13 @@ fn data() {
     vm.constructor("c", &[], 0);
 
     for i in 0..10 {
-        let returns = vm.function(
-            "test",
-            &[Token::Uint(ethereum_types::U256::from(i))],
-            &[],
-            0,
-            None,
-        );
+        let returns = vm.function("test", &[Token::Uint(U256::from(i))], &[], 0, None);
 
         let this = &vm.stack[0].data;
 
         let val = vm.account_data[this].data[i];
 
-        assert_eq!(returns[0], Token::Uint(ethereum_types::U256::from(val)));
+        assert_eq!(returns[0], Token::Uint(U256::from(val)));
     }
 
     let returns = vm.function("test2", &[], &[], 0, None);
@@ -119,5 +110,5 @@ fn data() {
 
     let val = u32::from_le_bytes(vm.account_data[this].data[1..5].try_into().unwrap());
 
-    assert_eq!(returns[0], Token::Uint(ethereum_types::U256::from(val)));
+    assert_eq!(returns[0], Token::Uint(U256::from(val)));
 }

+ 122 - 239
tests/solana_tests/arrays.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn fixed_array() {
@@ -25,10 +25,10 @@ fn fixed_array() {
         returns,
         vec![
             Token::FixedArray(vec![
-                Token::Uint(ethereum_types::U256::from(1)),
-                Token::Uint(ethereum_types::U256::from(102)),
-                Token::Uint(ethereum_types::U256::from(300331)),
-                Token::Uint(ethereum_types::U256::from(12313231))
+                Token::Uint(U256::from(1)),
+                Token::Uint(U256::from(102)),
+                Token::Uint(U256::from(300331)),
+                Token::Uint(U256::from(12313231))
             ]),
             Token::FixedBytes(vec!(0xfe))
         ]
@@ -58,22 +58,10 @@ fn fixed_array() {
     assert_eq!(
         returns,
         vec![Token::FixedArray(vec![
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(0)),
-                Token::Bool(false)
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(102)),
-                Token::Bool(true)
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(0)),
-                Token::Bool(false)
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(0)),
-                Token::Bool(false)
-            ])
+            Token::Tuple(vec![Token::Uint(U256::from(0)), Token::Bool(false)]),
+            Token::Tuple(vec![Token::Uint(U256::from(102)), Token::Bool(true)]),
+            Token::Tuple(vec![Token::Uint(U256::from(0)), Token::Bool(false)]),
+            Token::Tuple(vec![Token::Uint(U256::from(0)), Token::Bool(false)])
         ])]
     );
 
@@ -117,10 +105,10 @@ fn fixed_array() {
         vec![Token::Tuple(vec![
             Token::Bool(true),
             Token::FixedArray(vec![
-                Token::Uint(ethereum_types::U256::from(0)),
-                Token::Uint(ethereum_types::U256::from(0)),
-                Token::Uint(ethereum_types::U256::from(0)),
-                Token::Uint(ethereum_types::U256::from(0)),
+                Token::Uint(U256::from(0)),
+                Token::Uint(U256::from(0)),
+                Token::Uint(U256::from(0)),
+                Token::Uint(U256::from(0)),
             ]),
             Token::Bool(true)
         ])],
@@ -131,10 +119,10 @@ fn fixed_array() {
         &[Token::Tuple(vec![
             Token::Bool(true),
             Token::FixedArray(vec![
-                Token::Uint(ethereum_types::U256::from(3)),
-                Token::Uint(ethereum_types::U256::from(5)),
-                Token::Uint(ethereum_types::U256::from(7)),
-                Token::Uint(ethereum_types::U256::from(11)),
+                Token::Uint(U256::from(3)),
+                Token::Uint(U256::from(5)),
+                Token::Uint(U256::from(7)),
+                Token::Uint(U256::from(11)),
             ]),
             Token::Bool(true),
         ])],
@@ -143,7 +131,7 @@ fn fixed_array() {
         None,
     );
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(26))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(26))]);
 }
 
 #[test]
@@ -179,21 +167,21 @@ fn dynamic_array_fixed_elements() {
     let returns = vm.function(
         "get",
         &[
-            Token::Uint(ethereum_types::U256::from(12123123)),
+            Token::Uint(U256::from(12123123)),
             Token::Array(vec![
-                Token::Uint(ethereum_types::U256::from(3)),
-                Token::Uint(ethereum_types::U256::from(5)),
-                Token::Uint(ethereum_types::U256::from(7)),
-                Token::Uint(ethereum_types::U256::from(11)),
+                Token::Uint(U256::from(3)),
+                Token::Uint(U256::from(5)),
+                Token::Uint(U256::from(7)),
+                Token::Uint(U256::from(11)),
             ]),
-            Token::Uint(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(102)),
         ],
         &[],
         0,
         None,
     );
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(26))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(26))]);
 
     // test that the abi encoder can handle fixed arrays
     let returns = vm.function("set", &[], &[], 0, None);
@@ -201,12 +189,12 @@ fn dynamic_array_fixed_elements() {
     assert_eq!(
         returns,
         vec![
-            Token::Uint(ethereum_types::U256::from(12123123)),
+            Token::Uint(U256::from(12123123)),
             Token::Array(vec![
-                Token::Uint(ethereum_types::U256::from(3)),
-                Token::Uint(ethereum_types::U256::from(5)),
-                Token::Uint(ethereum_types::U256::from(7)),
-                Token::Uint(ethereum_types::U256::from(11)),
+                Token::Uint(U256::from(3)),
+                Token::Uint(U256::from(5)),
+                Token::Uint(U256::from(7)),
+                Token::Uint(U256::from(11)),
             ]),
             Token::String(String::from("abcd")),
         ]
@@ -249,35 +237,35 @@ fn fixed_array_dynamic_elements() {
     let returns = vm.function(
         "get",
         &[
-            Token::Uint(ethereum_types::U256::from(12123123)),
+            Token::Uint(U256::from(12123123)),
             Token::FixedArray(vec![
                 Token::Bytes(vec![3, 5, 7]),
                 Token::Bytes(vec![11, 13, 17]),
                 Token::Bytes(vec![19, 23]),
                 Token::Bytes(vec![29]),
             ]),
-            Token::Uint(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(102)),
         ],
         &[],
         0,
         None,
     );
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(127))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(127))]);
 
     let returns = vm.function("set", &[], &[], 0, None);
 
     assert_eq!(
         returns,
         vec![
-            Token::Uint(ethereum_types::U256::from(12123123)),
+            Token::Uint(U256::from(12123123)),
             Token::FixedArray(vec![
                 Token::Bytes(vec![3, 5, 7]),
                 Token::Bytes(vec![11, 13, 17]),
                 Token::Bytes(vec![19, 23]),
                 Token::Bytes(vec![29]),
             ]),
-            Token::Uint(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(102)),
         ]
     );
 }
@@ -319,28 +307,28 @@ fn dynamic_array_dynamic_elements() {
     let returns = vm.function(
         "get",
         &[
-            Token::Uint(ethereum_types::U256::from(12123123)),
+            Token::Uint(U256::from(12123123)),
             Token::Array(vec![
                 Token::Bytes(vec![3, 5, 7]),
                 Token::Bytes(vec![11, 13, 17]),
                 Token::Bytes(vec![19, 23]),
                 Token::Bytes(vec![29]),
             ]),
-            Token::Uint(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(102)),
         ],
         &[],
         0,
         None,
     );
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(127))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(127))]);
 
     let returns = vm.function("set", &[], &[], 0, None);
 
     assert_eq!(
         returns,
         vec![
-            Token::Uint(ethereum_types::U256::from(12123123)),
+            Token::Uint(U256::from(12123123)),
             Token::Array(vec![
                 Token::Bytes(vec![3, 5, 7]),
                 Token::Bytes(vec![11, 13, 17]),
@@ -385,10 +373,7 @@ fn fixed_array_fixed_elements_storage() {
 
     vm.function(
         "set_elem",
-        &[
-            Token::Uint(ethereum_types::U256::from(2)),
-            Token::Int(ethereum_types::U256::from(12123123)),
-        ],
+        &[Token::Uint(U256::from(2)), Token::Int(U256::from(12123123))],
         &[],
         0,
         None,
@@ -397,46 +382,37 @@ fn fixed_array_fixed_elements_storage() {
     vm.function(
         "set_elem",
         &[
-            Token::Uint(ethereum_types::U256::from(3)),
-            Token::Int(ethereum_types::U256::from(123456789)),
+            Token::Uint(U256::from(3)),
+            Token::Int(U256::from(123456789)),
         ],
         &[],
         0,
         None,
     );
 
-    let returns = vm.function(
-        "get_elem",
-        &[Token::Uint(ethereum_types::U256::from(2))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("get_elem", &[Token::Uint(U256::from(2))], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![Token::Int(ethereum_types::U256::from(12123123)),],
-    );
+    assert_eq!(returns, vec![Token::Int(U256::from(12123123)),],);
 
     let returns = vm.function("get", &[], &[], 0, None);
 
     assert_eq!(
         returns,
         vec![Token::FixedArray(vec![
-            Token::Int(ethereum_types::U256::from(0)),
-            Token::Int(ethereum_types::U256::from(0)),
-            Token::Int(ethereum_types::U256::from(12123123)),
-            Token::Int(ethereum_types::U256::from(123456789)),
+            Token::Int(U256::from(0)),
+            Token::Int(U256::from(0)),
+            Token::Int(U256::from(12123123)),
+            Token::Int(U256::from(123456789)),
         ]),],
     );
 
     vm.function(
         "set",
         &[Token::FixedArray(vec![
-            Token::Int(ethereum_types::U256::from(1)),
-            Token::Int(ethereum_types::U256::from(2)),
-            Token::Int(ethereum_types::U256::from(3)),
-            Token::Int(ethereum_types::U256::from(4)),
+            Token::Int(U256::from(1)),
+            Token::Int(U256::from(2)),
+            Token::Int(U256::from(3)),
+            Token::Int(U256::from(4)),
         ])],
         &[],
         0,
@@ -448,10 +424,10 @@ fn fixed_array_fixed_elements_storage() {
     assert_eq!(
         returns,
         vec![Token::FixedArray(vec![
-            Token::Int(ethereum_types::U256::from(1)),
-            Token::Int(ethereum_types::U256::from(2)),
-            Token::Int(ethereum_types::U256::from(3)),
-            Token::Int(ethereum_types::U256::from(4)),
+            Token::Int(U256::from(1)),
+            Token::Int(U256::from(2)),
+            Token::Int(U256::from(3)),
+            Token::Int(U256::from(4)),
         ]),],
     );
 
@@ -462,10 +438,10 @@ fn fixed_array_fixed_elements_storage() {
     assert_eq!(
         returns,
         vec![Token::FixedArray(vec![
-            Token::Int(ethereum_types::U256::from(0)),
-            Token::Int(ethereum_types::U256::from(0)),
-            Token::Int(ethereum_types::U256::from(0)),
-            Token::Int(ethereum_types::U256::from(0)),
+            Token::Int(U256::from(0)),
+            Token::Int(U256::from(0)),
+            Token::Int(U256::from(0)),
+            Token::Int(U256::from(0)),
         ]),],
     );
 }
@@ -504,7 +480,7 @@ fn fixed_array_dynamic_elements_storage() {
     vm.function(
         "set_elem",
         &[
-            Token::Uint(ethereum_types::U256::from(2)),
+            Token::Uint(U256::from(2)),
             Token::String(String::from("abcd")),
         ],
         &[],
@@ -515,7 +491,7 @@ fn fixed_array_dynamic_elements_storage() {
     vm.function(
         "set_elem",
         &[
-            Token::Uint(ethereum_types::U256::from(3)),
+            Token::Uint(U256::from(3)),
             Token::String(String::from(
                 "you can lead a horse to water but you can’t make him drink",
             )),
@@ -525,13 +501,7 @@ fn fixed_array_dynamic_elements_storage() {
         None,
     );
 
-    let returns = vm.function(
-        "get_elem",
-        &[Token::Uint(ethereum_types::U256::from(2))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("get_elem", &[Token::Uint(U256::from(2))], &[], 0, None);
 
     assert_eq!(returns, vec![Token::String(String::from("abcd"))]);
 
@@ -634,91 +604,61 @@ fn storage_simple_dynamic_array() {
 
     let returns = vm.function("len", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
 
-    vm.function(
-        "push",
-        &[Token::Int(ethereum_types::U256::from(102))],
-        &[],
-        0,
-        None,
-    );
+    vm.function("push", &[Token::Int(U256::from(102))], &[], 0, None);
 
     vm.function("push_zero", &[], &[], 0, None);
 
     vm.function(
         "push",
-        &[Token::Int(ethereum_types::U256::from(12345678901u64))],
+        &[Token::Int(U256::from(12345678901u64))],
         &[],
         0,
         None,
     );
 
-    let returns = vm.function(
-        "subscript",
-        &[Token::Uint(ethereum_types::U256::from(0))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("subscript", &[Token::Uint(U256::from(0))], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Int(ethereum_types::U256::from(102))]);
+    assert_eq!(returns, vec![Token::Int(U256::from(102))]);
 
-    let returns = vm.function(
-        "subscript",
-        &[Token::Uint(ethereum_types::U256::from(1))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("subscript", &[Token::Uint(U256::from(1))], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Int(ethereum_types::U256::from(0))]);
+    assert_eq!(returns, vec![Token::Int(U256::from(0))]);
 
-    let returns = vm.function(
-        "subscript",
-        &[Token::Uint(ethereum_types::U256::from(2))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("subscript", &[Token::Uint(U256::from(2))], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![Token::Int(ethereum_types::U256::from(12345678901u64))]
-    );
+    assert_eq!(returns, vec![Token::Int(U256::from(12345678901u64))]);
 
     let returns = vm.function("copy", &[], &[], 0, None);
 
     assert_eq!(
         returns,
         vec![Token::Array(vec![
-            Token::Int(ethereum_types::U256::from(102)),
-            Token::Int(ethereum_types::U256::from(0)),
-            Token::Int(ethereum_types::U256::from(12345678901u64)),
+            Token::Int(U256::from(102)),
+            Token::Int(U256::from(0)),
+            Token::Int(U256::from(12345678901u64)),
         ])],
     );
 
     let returns = vm.function("pop", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![Token::Int(ethereum_types::U256::from(12345678901u64))]
-    );
+    assert_eq!(returns, vec![Token::Int(U256::from(12345678901u64))]);
 
     let returns = vm.function("len", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(2))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(2))]);
 
     vm.function(
         "set",
         &[Token::Array(vec![
-            Token::Int(ethereum_types::U256::from(1)),
-            Token::Int(ethereum_types::U256::from(2)),
-            Token::Int(ethereum_types::U256::from(3)),
-            Token::Int(ethereum_types::U256::from(4)),
-            Token::Int(ethereum_types::U256::from(5)),
-            Token::Int(ethereum_types::U256::from(6)),
-            Token::Int(ethereum_types::U256::from(7)),
+            Token::Int(U256::from(1)),
+            Token::Int(U256::from(2)),
+            Token::Int(U256::from(3)),
+            Token::Int(U256::from(4)),
+            Token::Int(U256::from(5)),
+            Token::Int(U256::from(6)),
+            Token::Int(U256::from(7)),
         ])],
         &[],
         0,
@@ -730,13 +670,13 @@ fn storage_simple_dynamic_array() {
     assert_eq!(
         returns,
         vec![Token::Array(vec![
-            Token::Int(ethereum_types::U256::from(1)),
-            Token::Int(ethereum_types::U256::from(2)),
-            Token::Int(ethereum_types::U256::from(3)),
-            Token::Int(ethereum_types::U256::from(4)),
-            Token::Int(ethereum_types::U256::from(5)),
-            Token::Int(ethereum_types::U256::from(6)),
-            Token::Int(ethereum_types::U256::from(7)),
+            Token::Int(U256::from(1)),
+            Token::Int(U256::from(2)),
+            Token::Int(U256::from(3)),
+            Token::Int(U256::from(4)),
+            Token::Int(U256::from(5)),
+            Token::Int(U256::from(6)),
+            Token::Int(U256::from(7)),
         ])],
     );
 
@@ -744,7 +684,7 @@ fn storage_simple_dynamic_array() {
 
     let returns = vm.function("len", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
 }
 
 #[test]
@@ -822,12 +762,12 @@ fn storage_dynamic_array_of_structs() {
 
     let returns = vm.function("len", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
 
     vm.function(
         "push1",
         &[Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(13819038012u64)),
+            Token::Uint(U256::from(13819038012u64)),
             Token::Bool(true),
         ])],
         &[],
@@ -840,7 +780,7 @@ fn storage_dynamic_array_of_structs() {
     vm.function(
         "push2",
         &[Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(12313123141123213u64)),
+            Token::Uint(U256::from(12313123141123213u64)),
             Token::Bool(true),
         ])],
         &[],
@@ -848,50 +788,32 @@ fn storage_dynamic_array_of_structs() {
         None,
     );
 
-    let returns = vm.function(
-        "subscript",
-        &[Token::Uint(ethereum_types::U256::from(0))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("subscript", &[Token::Uint(U256::from(0))], &[], 0, None);
 
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(13819038012u64)),
+            Token::Uint(U256::from(13819038012u64)),
             Token::Bool(true),
         ])]
     );
 
-    let returns = vm.function(
-        "subscript",
-        &[Token::Uint(ethereum_types::U256::from(1))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("subscript", &[Token::Uint(U256::from(1))], &[], 0, None);
 
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(0)),
+            Token::Uint(U256::from(0)),
             Token::Bool(false),
         ])]
     );
 
-    let returns = vm.function(
-        "subscript",
-        &[Token::Uint(ethereum_types::U256::from(2))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("subscript", &[Token::Uint(U256::from(2))], &[], 0, None);
 
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(12313123141123213u64)),
+            Token::Uint(U256::from(12313123141123213u64)),
             Token::Bool(true),
         ])]
     );
@@ -902,15 +824,12 @@ fn storage_dynamic_array_of_structs() {
         returns,
         vec![Token::Array(vec![
             Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(13819038012u64)),
+                Token::Uint(U256::from(13819038012u64)),
                 Token::Bool(true)
             ]),
+            Token::Tuple(vec![Token::Uint(U256::from(0)), Token::Bool(false)]),
             Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(0)),
-                Token::Bool(false)
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(12313123141123213u64)),
+                Token::Uint(U256::from(12313123141123213u64)),
                 Token::Bool(true)
             ]),
         ])]
@@ -921,42 +840,24 @@ fn storage_dynamic_array_of_structs() {
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(12313123141123213u64)),
+            Token::Uint(U256::from(12313123141123213u64)),
             Token::Bool(true),
         ])]
     );
 
     let returns = vm.function("len", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(2))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(2))]);
 
     vm.function(
         "set",
         &[Token::Array(vec![
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(1)),
-                Token::Bool(false),
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(2)),
-                Token::Bool(true),
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(3)),
-                Token::Bool(false),
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(4)),
-                Token::Bool(true),
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(5)),
-                Token::Bool(false),
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(6)),
-                Token::Bool(true),
-            ]),
+            Token::Tuple(vec![Token::Uint(U256::from(1)), Token::Bool(false)]),
+            Token::Tuple(vec![Token::Uint(U256::from(2)), Token::Bool(true)]),
+            Token::Tuple(vec![Token::Uint(U256::from(3)), Token::Bool(false)]),
+            Token::Tuple(vec![Token::Uint(U256::from(4)), Token::Bool(true)]),
+            Token::Tuple(vec![Token::Uint(U256::from(5)), Token::Bool(false)]),
+            Token::Tuple(vec![Token::Uint(U256::from(6)), Token::Bool(true)]),
         ])],
         &[],
         0,
@@ -968,30 +869,12 @@ fn storage_dynamic_array_of_structs() {
     assert_eq!(
         returns,
         vec![Token::Array(vec![
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(1)),
-                Token::Bool(false)
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(2)),
-                Token::Bool(true)
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(3)),
-                Token::Bool(false)
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(4)),
-                Token::Bool(true)
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(5)),
-                Token::Bool(false)
-            ]),
-            Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(6)),
-                Token::Bool(true)
-            ]),
+            Token::Tuple(vec![Token::Uint(U256::from(1)), Token::Bool(false)]),
+            Token::Tuple(vec![Token::Uint(U256::from(2)), Token::Bool(true)]),
+            Token::Tuple(vec![Token::Uint(U256::from(3)), Token::Bool(false)]),
+            Token::Tuple(vec![Token::Uint(U256::from(4)), Token::Bool(true)]),
+            Token::Tuple(vec![Token::Uint(U256::from(5)), Token::Bool(false)]),
+            Token::Tuple(vec![Token::Uint(U256::from(6)), Token::Bool(true)]),
         ])]
     );
 
@@ -999,7 +882,7 @@ fn storage_dynamic_array_of_structs() {
 
     let returns = vm.function("len", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
 }
 
 #[test]
@@ -1023,9 +906,9 @@ fn array_literal() {
     assert_eq!(
         returns,
         vec![Token::FixedArray(vec![
-            Token::Int(ethereum_types::U256::from(1)),
-            Token::Int(ethereum_types::U256::from(2)),
-            Token::Int(ethereum_types::U256::from(3))
+            Token::Int(U256::from(1)),
+            Token::Int(U256::from(2)),
+            Token::Int(U256::from(3))
         ])]
     );
 }

+ 12 - 12
tests/solana_tests/balance.rs

@@ -1,5 +1,5 @@
 use crate::{account_new, build_solidity, AccountState};
-use ethabi::{Function, StateMutability, Token};
+use ethabi::{ethereum_types::U256, Function, StateMutability, Token};
 
 #[test]
 fn msg_value() {
@@ -18,7 +18,7 @@ fn msg_value() {
 
     let returns = vm.function("test", &[], &[], 102, None);
 
-    assert_eq!(returns[0], Token::Uint(ethereum_types::U256::from(306)));
+    assert_eq!(returns[0], Token::Uint(U256::from(306)));
 
     assert_eq!(vm.account_data[&vm.origin].lamports, 312 - 102);
     assert_eq!(vm.account_data[&vm.stack[0].data].lamports, 102);
@@ -112,7 +112,7 @@ fn get_balance() {
 
     let returns = vm.function("test", &[], &[], 0, Some(&new));
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(102))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(102))]);
 }
 
 #[test]
@@ -143,7 +143,7 @@ fn send_fails() {
         "send",
         &[
             Token::FixedBytes(new.to_vec()),
-            Token::Uint(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(102)),
         ],
         &[],
         0,
@@ -185,7 +185,7 @@ fn send_succeeds() {
         "send",
         &[
             Token::FixedBytes(new.to_vec()),
-            Token::Uint(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(102)),
         ],
         &[],
         0,
@@ -239,7 +239,7 @@ fn send_overflows() {
         "send",
         &[
             Token::FixedBytes(new.to_vec()),
-            Token::Uint(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(102)),
         ],
         &[],
         0,
@@ -296,7 +296,7 @@ fn transfer_succeeds() {
         "transfer",
         &[
             Token::FixedBytes(new.to_vec()),
-            Token::Uint(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(102)),
         ],
         &[],
         0,
@@ -348,7 +348,7 @@ fn transfer_fails_not_enough() {
         "transfer",
         &[
             Token::FixedBytes(new.to_vec()),
-            Token::Uint(ethereum_types::U256::from(104)),
+            Token::Uint(U256::from(104)),
         ],
         &[],
         0,
@@ -389,7 +389,7 @@ fn transfer_fails_overflow() {
         "transfer",
         &[
             Token::FixedBytes(new.to_vec()),
-            Token::Uint(ethereum_types::U256::from(104)),
+            Token::Uint(U256::from(104)),
         ],
         &[],
         0,
@@ -478,7 +478,7 @@ fn value_overflows() {
         "send",
         &[
             Token::FixedBytes(new.to_vec()),
-            Token::Uint(ethereum_types::U256::from(u64::MAX as u128 + 1)),
+            Token::Uint(U256::from(u64::MAX as u128 + 1)),
         ],
         &[],
         0,
@@ -490,7 +490,7 @@ fn value_overflows() {
         "send",
         &[
             Token::FixedBytes(new.to_vec()),
-            Token::Uint(ethereum_types::U256::from(u128::MAX)),
+            Token::Uint(U256::from(u128::MAX)),
         ],
         &[],
         0,
@@ -502,7 +502,7 @@ fn value_overflows() {
         "send",
         &[
             Token::FixedBytes(new.to_vec()),
-            Token::Uint(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(102)),
         ],
         &[],
         0,

+ 5 - 14
tests/solana_tests/builtin.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn builtins() {
@@ -28,28 +28,19 @@ fn builtins() {
 
     let returns = vm.function("mr_now", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![Token::Uint(ethereum_types::U256::from(1620656423))]
-    );
+    assert_eq!(returns, vec![Token::Uint(U256::from(1620656423))]);
 
     let returns = vm.function("mr_slot", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![Token::Uint(ethereum_types::U256::from(70818331))]
-    );
+    assert_eq!(returns, vec![Token::Uint(U256::from(70818331))]);
 
     let returns = vm.function("mr_blocknumber", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![Token::Uint(ethereum_types::U256::from(70818331))]
-    );
+    assert_eq!(returns, vec![Token::Uint(U256::from(70818331))]);
 
     let returns = vm.function(
         "msg_data",
-        &[Token::Uint(ethereum_types::U256::from(0xdeadcafeu32))],
+        &[Token::Uint(U256::from(0xdeadcafeu32))],
         &[],
         0,
         None,

+ 8 - 26
tests/solana_tests/call.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn simple_external_call() {
@@ -84,15 +84,9 @@ fn external_call_with_returns() {
 
     vm.constructor("bar1", &[], 0);
 
-    let res = vm.function(
-        "test_bar",
-        &[Token::Int(ethereum_types::U256::from(21))],
-        &[],
-        0,
-        None,
-    );
+    let res = vm.function("test_bar", &[Token::Int(U256::from(21))], &[], 0, None);
 
-    assert_eq!(res, vec![Token::Int(ethereum_types::U256::from(24))]);
+    assert_eq!(res, vec![Token::Int(U256::from(24))]);
 
     let bar1_account = vm.stack[0].data;
 
@@ -108,7 +102,7 @@ fn external_call_with_returns() {
         None,
     );
 
-    assert_eq!(res, vec![Token::Int(ethereum_types::U256::from(15))]);
+    assert_eq!(res, vec![Token::Int(U256::from(15))]);
 }
 
 #[test]
@@ -137,15 +131,9 @@ fn external_raw_call_with_returns() {
 
     vm.constructor("bar1", &[], 0);
 
-    let res = vm.function(
-        "test_bar",
-        &[Token::Int(ethereum_types::U256::from(21))],
-        &[],
-        0,
-        None,
-    );
+    let res = vm.function("test_bar", &[Token::Int(U256::from(21))], &[], 0, None);
 
-    assert_eq!(res, vec![Token::Int(ethereum_types::U256::from(24))]);
+    assert_eq!(res, vec![Token::Int(U256::from(24))]);
 
     let bar1_account = vm.stack[0].data;
 
@@ -161,7 +149,7 @@ fn external_raw_call_with_returns() {
         None,
     );
 
-    assert_eq!(res, vec![Token::Int(ethereum_types::U256::from(15))]);
+    assert_eq!(res, vec![Token::Int(U256::from(15))]);
 }
 
 #[test]
@@ -202,13 +190,7 @@ fn external_call_with_string_returns() {
 
     vm.constructor("bar1", &[], 0);
 
-    let res = vm.function(
-        "test_bar",
-        &[Token::Int(ethereum_types::U256::from(22))],
-        &[],
-        0,
-        None,
-    );
+    let res = vm.function("test_bar", &[Token::Int(U256::from(22))], &[], 0, None);
 
     assert_eq!(res, vec![Token::String(String::from("foo:22"))]);
 

+ 3 - 3
tests/solana_tests/constant.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn constant() {
@@ -21,7 +21,7 @@ fn constant() {
     vm.constructor("foo", &[], 0);
 
     let returns = vm.function("f", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(42))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(42))]);
 
     let mut vm = build_solidity(
         r#"
@@ -41,5 +41,5 @@ fn constant() {
     vm.constructor("foo", &[], 0);
 
     let returns = vm.function("f", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(42))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(42))]);
 }

+ 6 - 21
tests/solana_tests/destructure.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn conditional_destructure() {
@@ -21,40 +21,28 @@ fn conditional_destructure() {
 
     assert_eq!(
         returns,
-        vec![
-            Token::Int(ethereum_types::U256::from(1)),
-            Token::Int(ethereum_types::U256::from(2)),
-        ]
+        vec![Token::Int(U256::from(1)), Token::Int(U256::from(2)),]
     );
 
     let returns = vm.function("f", &[Token::Bool(true), Token::Bool(false)], &[], 0, None);
 
     assert_eq!(
         returns,
-        vec![
-            Token::Int(ethereum_types::U256::from(3)),
-            Token::Int(ethereum_types::U256::from(4)),
-        ]
+        vec![Token::Int(U256::from(3)), Token::Int(U256::from(4)),]
     );
 
     let returns = vm.function("f", &[Token::Bool(false), Token::Bool(false)], &[], 0, None);
 
     assert_eq!(
         returns,
-        vec![
-            Token::Int(ethereum_types::U256::from(5)),
-            Token::Int(ethereum_types::U256::from(6)),
-        ]
+        vec![Token::Int(U256::from(5)), Token::Int(U256::from(6)),]
     );
 
     let returns = vm.function("f", &[Token::Bool(false), Token::Bool(true)], &[], 0, None);
 
     assert_eq!(
         returns,
-        vec![
-            Token::Int(ethereum_types::U256::from(5)),
-            Token::Int(ethereum_types::U256::from(6)),
-        ]
+        vec![Token::Int(U256::from(5)), Token::Int(U256::from(6)),]
     );
 }
 
@@ -80,10 +68,7 @@ fn casting_destructure() {
 
     assert_eq!(
         returns,
-        vec![
-            Token::Int(ethereum_types::U256::from(1)),
-            Token::Int(ethereum_types::U256::from(2)),
-        ]
+        vec![Token::Int(U256::from(1)), Token::Int(U256::from(2)),]
     );
 
     let mut vm = build_solidity(

+ 5 - 5
tests/solana_tests/events.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 use tiny_keccak::{Hasher, Keccak};
 
 #[test]
@@ -35,8 +35,8 @@ fn simple_event() {
 
     for log in &decoded.params {
         match log.name.as_str() {
-            "a" => assert_eq!(log.value, Token::Int(ethereum_types::U256::from(1))),
-            "b" => assert_eq!(log.value, Token::Int(ethereum_types::U256::from(2))),
+            "a" => assert_eq!(log.value, Token::Int(U256::from(1))),
+            "b" => assert_eq!(log.value, Token::Int(U256::from(2))),
             _ => panic!("unexpected field {}", log.name),
         }
     }
@@ -86,7 +86,7 @@ fn less_simple_event() {
         match log.name.as_str() {
             "a" => assert_eq!(
                 log.value,
-                Token::Int(ethereum_types::U256::from_dec_str("115792089237316195423570985008687907853269984665640564039457584007913129639834").unwrap())
+                Token::Int(U256::from_dec_str("115792089237316195423570985008687907853269984665640564039457584007913129639834").unwrap())
             ),
             "b" => {
                 let mut hasher = Keccak::v256();
@@ -109,7 +109,7 @@ fn less_simple_event() {
                 assert_eq!(log.value, Token::FixedBytes(hash.to_vec()));
             }
             "d" => {
-                assert_eq!(log.value, Token::Tuple(vec![Token::Int(ethereum_types::U256::from(102)), Token::Bool(true)]));
+                assert_eq!(log.value, Token::Tuple(vec![Token::Int(U256::from(102)), Token::Bool(true)]));
             }
 
             _ => panic!("unexpected field {}", log.name),

+ 7 - 9
tests/solana_tests/expressions.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 use rand::Rng;
 
 #[test]
@@ -107,10 +107,10 @@ fn read_buffer() {
     assert_eq!(
         returns,
         vec![
-            Token::Int(ethereum_types::U256::from(
+            Token::Int(U256::from(
                 "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffbebdbcbc"
             )),
-            Token::Uint(ethereum_types::U256::from(0x0102030405060708u64))
+            Token::Uint(U256::from(0x0102030405060708u64))
         ]
     );
 
@@ -133,7 +133,7 @@ fn read_buffer() {
     assert_eq!(
         returns,
         vec![
-            Token::Uint(ethereum_types::U256::from(0x4142)),
+            Token::Uint(U256::from(0x4142)),
             Token::FixedBytes(vm.origin.to_vec())
         ]
     );
@@ -204,8 +204,8 @@ fn assignment_in_ternary() {
         let returns = vm.function(
             "minimum",
             &[
-                Token::Uint(ethereum_types::U256::from(left)),
-                Token::Uint(ethereum_types::U256::from(right)),
+                Token::Uint(U256::from(left)),
+                Token::Uint(U256::from(right)),
             ],
             &[],
             0,
@@ -214,9 +214,7 @@ fn assignment_in_ternary() {
 
         assert_eq!(
             returns,
-            vec![Token::Uint(ethereum_types::U256::from(std::cmp::min(
-                left, right
-            )))]
+            vec![Token::Uint(U256::from(std::cmp::min(left, right)))]
         );
     }
 }

+ 63 - 139
tests/solana_tests/mappings.rs

@@ -1,5 +1,5 @@
 use crate::{account_new, build_solidity};
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn simple_mapping() {
@@ -28,8 +28,8 @@ fn simple_mapping() {
         vm.function(
             "set",
             &[
-                Token::Uint(ethereum_types::U256::from(102 + i)),
-                Token::Uint(ethereum_types::U256::from(300331 + i)),
+                Token::Uint(U256::from(102 + i)),
+                Token::Uint(U256::from(300331 + i)),
             ],
             &[],
             0,
@@ -38,54 +38,24 @@ fn simple_mapping() {
     }
 
     for i in 0..10 {
-        let returns = vm.function(
-            "get",
-            &[Token::Uint(ethereum_types::U256::from(102 + i))],
-            &[],
-            0,
-            None,
-        );
+        let returns = vm.function("get", &[Token::Uint(U256::from(102 + i))], &[], 0, None);
 
-        assert_eq!(
-            returns,
-            vec![Token::Uint(ethereum_types::U256::from(300331 + i))]
-        );
+        assert_eq!(returns, vec![Token::Uint(U256::from(300331 + i))]);
     }
 
-    let returns = vm.function(
-        "get",
-        &[Token::Uint(ethereum_types::U256::from(101))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("get", &[Token::Uint(U256::from(101))], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
 
-    vm.function(
-        "rm",
-        &[Token::Uint(ethereum_types::U256::from(104))],
-        &[],
-        0,
-        None,
-    );
+    vm.function("rm", &[Token::Uint(U256::from(104))], &[], 0, None);
 
     for i in 0..10 {
-        let returns = vm.function(
-            "get",
-            &[Token::Uint(ethereum_types::U256::from(102 + i))],
-            &[],
-            0,
-            None,
-        );
+        let returns = vm.function("get", &[Token::Uint(U256::from(102 + i))], &[], 0, None);
 
         if 102 + i != 104 {
-            assert_eq!(
-                returns,
-                vec![Token::Uint(ethereum_types::U256::from(300331 + i))]
-            );
+            assert_eq!(returns, vec![Token::Uint(U256::from(300331 + i))]);
         } else {
-            assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+            assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
         }
     }
 }
@@ -125,7 +95,7 @@ fn less_simple_mapping() {
     vm.function(
         "set_string",
         &[
-            Token::Uint(ethereum_types::U256::from(12313132131321312311213131u128)),
+            Token::Uint(U256::from(12313132131321312311213131u128)),
             Token::String(String::from("This is a string which should be a little longer than 32 bytes so we the the abi encoder")),
         ], &[], 0, None
     );
@@ -133,8 +103,8 @@ fn less_simple_mapping() {
     vm.function(
         "add_int",
         &[
-            Token::Uint(ethereum_types::U256::from(12313132131321312311213131u128)),
-            Token::Int(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(12313132131321312311213131u128)),
+            Token::Int(U256::from(102)),
         ],
         &[],
         0,
@@ -143,9 +113,7 @@ fn less_simple_mapping() {
 
     let returns = vm.function(
         "get",
-        &[Token::Uint(ethereum_types::U256::from(
-            12313132131321312311213131u128,
-        ))],
+        &[Token::Uint(U256::from(12313132131321312311213131u128))],
         &[],
         0,
         None,
@@ -155,7 +123,7 @@ fn less_simple_mapping() {
         returns,
         vec![Token::Tuple(vec![
             Token::String(String::from("This is a string which should be a little longer than 32 bytes so we the the abi encoder")),
-            Token::Array(vec![Token::Int(ethereum_types::U256::from(102))]),
+            Token::Array(vec![Token::Int(U256::from(102))]),
         ])]
     );
 }
@@ -204,7 +172,7 @@ fn string_mapping() {
         "add_int",
         &[
             Token::String(String::from("a")),
-            Token::Int(ethereum_types::U256::from(102)),
+            Token::Int(U256::from(102)),
         ],
         &[],
         0,
@@ -217,7 +185,7 @@ fn string_mapping() {
         returns,
         vec![Token::Tuple(vec![
             Token::String(String::from("This is a string which should be a little longer than 32 bytes so we the the abi encoder")),
-            Token::Array(vec![Token::Int(ethereum_types::U256::from(102))]),
+            Token::Array(vec![Token::Int(U256::from(102))]),
         ])]
     );
 }
@@ -290,7 +258,7 @@ fn mapping_in_mapping() {
         "set",
         &[
             Token::String(String::from("a")),
-            Token::Int(ethereum_types::U256::from(102)),
+            Token::Int(U256::from(102)),
             Token::FixedBytes(vec![0x98]),
         ],
         &[],
@@ -302,7 +270,7 @@ fn mapping_in_mapping() {
         "map",
         &[
             Token::String(String::from("a")),
-            Token::Int(ethereum_types::U256::from(102)),
+            Token::Int(U256::from(102)),
         ],
         &[],
         0,
@@ -315,7 +283,7 @@ fn mapping_in_mapping() {
         "map",
         &[
             Token::String(String::from("a")),
-            Token::Int(ethereum_types::U256::from(103)),
+            Token::Int(U256::from(103)),
         ],
         &[],
         0,
@@ -328,7 +296,7 @@ fn mapping_in_mapping() {
         "map",
         &[
             Token::String(String::from("b")),
-            Token::Int(ethereum_types::U256::from(102)),
+            Token::Int(U256::from(102)),
         ],
         &[],
         0,
@@ -373,7 +341,7 @@ fn sparse_array() {
     vm.function(
         "set_string",
         &[
-            Token::Uint(ethereum_types::U256::from(909090909)),
+            Token::Uint(U256::from(909090909)),
             Token::String(String::from("This is a string which should be a little longer than 32 bytes so we the the abi encoder")),
         ], &[],0, None
     );
@@ -381,27 +349,21 @@ fn sparse_array() {
     vm.function(
         "add_int",
         &[
-            Token::Uint(ethereum_types::U256::from(909090909)),
-            Token::Int(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(909090909)),
+            Token::Int(U256::from(102)),
         ],
         &[],
         0,
         None,
     );
 
-    let returns = vm.function(
-        "get",
-        &[Token::Uint(ethereum_types::U256::from(909090909))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("get", &[Token::Uint(U256::from(909090909))], &[], 0, None);
 
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
             Token::String(String::from("This is a string which should be a little longer than 32 bytes so we the the abi encoder")),
-            Token::Array(vec![Token::Int(ethereum_types::U256::from(102))]),
+            Token::Array(vec![Token::Int(U256::from(102))]),
         ])]
     );
 }
@@ -441,7 +403,7 @@ fn massive_sparse_array() {
     vm.function(
         "set_string",
         &[
-            Token::Uint(ethereum_types::U256::from(786868768768678687686877u128)),
+            Token::Uint(U256::from(786868768768678687686877u128)),
             Token::String(String::from("This is a string which should be a little longer than 32 bytes so we the the abi encoder")),
         ], &[],0, None
     );
@@ -449,8 +411,8 @@ fn massive_sparse_array() {
     vm.function(
         "add_int",
         &[
-            Token::Uint(ethereum_types::U256::from(786868768768678687686877u128)),
-            Token::Int(ethereum_types::U256::from(102)),
+            Token::Uint(U256::from(786868768768678687686877u128)),
+            Token::Int(U256::from(102)),
         ],
         &[],
         0,
@@ -459,9 +421,7 @@ fn massive_sparse_array() {
 
     let returns = vm.function(
         "get",
-        &[Token::Uint(ethereum_types::U256::from(
-            786868768768678687686877u128,
-        ))],
+        &[Token::Uint(U256::from(786868768768678687686877u128))],
         &[],
         0,
         None,
@@ -471,7 +431,7 @@ fn massive_sparse_array() {
         returns,
         vec![Token::Tuple(vec![
             Token::String(String::from("This is a string which should be a little longer than 32 bytes so we the the abi encoder")),
-            Token::Array(vec![Token::Int(ethereum_types::U256::from(102))]),
+            Token::Array(vec![Token::Int(U256::from(102))]),
         ])]
     );
 }
@@ -514,7 +474,7 @@ fn mapping_in_dynamic_array() {
 
     vm.function(
         "setNumber",
-        &[Token::Int(ethereum_types::U256::from(2147483647))],
+        &[Token::Int(U256::from(2147483647))],
         &[],
         0,
         None,
@@ -528,9 +488,9 @@ fn mapping_in_dynamic_array() {
             vm.function(
                 "set",
                 &[
-                    Token::Uint(ethereum_types::U256::from(array_no)),
-                    Token::Uint(ethereum_types::U256::from(102 + i + array_no * 500)),
-                    Token::Uint(ethereum_types::U256::from(300331 + i)),
+                    Token::Uint(U256::from(array_no)),
+                    Token::Uint(U256::from(102 + i + array_no * 500)),
+                    Token::Uint(U256::from(300331 + i)),
                 ],
                 &[],
                 0,
@@ -544,40 +504,31 @@ fn mapping_in_dynamic_array() {
             let returns = vm.function(
                 "map",
                 &[
-                    Token::Uint(ethereum_types::U256::from(array_no)),
-                    Token::Uint(ethereum_types::U256::from(102 + i + array_no * 500)),
+                    Token::Uint(U256::from(array_no)),
+                    Token::Uint(U256::from(102 + i + array_no * 500)),
                 ],
                 &[],
                 0,
                 None,
             );
 
-            assert_eq!(
-                returns,
-                vec![Token::Uint(ethereum_types::U256::from(300331 + i))]
-            );
+            assert_eq!(returns, vec![Token::Uint(U256::from(300331 + i))]);
         }
     }
 
     let returns = vm.function(
         "map",
-        &[
-            Token::Uint(ethereum_types::U256::from(0)),
-            Token::Uint(ethereum_types::U256::from(101)),
-        ],
+        &[Token::Uint(U256::from(0)), Token::Uint(U256::from(101))],
         &[],
         0,
         None,
     );
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
 
     vm.function(
         "rm",
-        &[
-            Token::Uint(ethereum_types::U256::from(0)),
-            Token::Uint(ethereum_types::U256::from(104)),
-        ],
+        &[Token::Uint(U256::from(0)), Token::Uint(U256::from(104))],
         &[],
         0,
         None,
@@ -586,44 +537,35 @@ fn mapping_in_dynamic_array() {
     for i in 0..10 {
         let returns = vm.function(
             "map",
-            &[
-                Token::Uint(ethereum_types::U256::from(0)),
-                Token::Uint(ethereum_types::U256::from(102 + i)),
-            ],
+            &[Token::Uint(U256::from(0)), Token::Uint(U256::from(102 + i))],
             &[],
             0,
             None,
         );
 
         if 102 + i != 104 {
-            assert_eq!(
-                returns,
-                vec![Token::Uint(ethereum_types::U256::from(300331 + i))]
-            );
+            assert_eq!(returns, vec![Token::Uint(U256::from(300331 + i))]);
         } else {
-            assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+            assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
         }
     }
 
     let returns = vm.function("length", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(2))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(2))]);
 
     vm.function("pop", &[], &[], 0, None);
 
     let returns = vm.function("length", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(1))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(1))]);
 
     vm.function("pop", &[], &[], 0, None);
 
     let returns = vm.function("length", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
 
     let returns = vm.function("number", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![Token::Int(ethereum_types::U256::from(2147483647))]
-    );
+    assert_eq!(returns, vec![Token::Int(U256::from(2147483647))]);
 }
 
 #[test]
@@ -668,7 +610,7 @@ fn mapping_in_struct_in_dynamic_array() {
 
     vm.function(
         "setNumber",
-        &[Token::Int(ethereum_types::U256::from(2147483647))],
+        &[Token::Int(U256::from(2147483647))],
         &[],
         0,
         None,
@@ -682,9 +624,9 @@ fn mapping_in_struct_in_dynamic_array() {
             vm.function(
                 "set",
                 &[
-                    Token::Uint(ethereum_types::U256::from(array_no)),
-                    Token::Uint(ethereum_types::U256::from(102 + i + array_no * 500)),
-                    Token::Uint(ethereum_types::U256::from(300331 + i)),
+                    Token::Uint(U256::from(array_no)),
+                    Token::Uint(U256::from(102 + i + array_no * 500)),
+                    Token::Uint(U256::from(300331 + i)),
                 ],
                 &[],
                 0,
@@ -698,40 +640,31 @@ fn mapping_in_struct_in_dynamic_array() {
             let returns = vm.function(
                 "get",
                 &[
-                    Token::Uint(ethereum_types::U256::from(array_no)),
-                    Token::Uint(ethereum_types::U256::from(102 + i + array_no * 500)),
+                    Token::Uint(U256::from(array_no)),
+                    Token::Uint(U256::from(102 + i + array_no * 500)),
                 ],
                 &[],
                 0,
                 None,
             );
 
-            assert_eq!(
-                returns,
-                vec![Token::Uint(ethereum_types::U256::from(300331 + i))]
-            );
+            assert_eq!(returns, vec![Token::Uint(U256::from(300331 + i))]);
         }
     }
 
     let returns = vm.function(
         "get",
-        &[
-            Token::Uint(ethereum_types::U256::from(0)),
-            Token::Uint(ethereum_types::U256::from(101)),
-        ],
+        &[Token::Uint(U256::from(0)), Token::Uint(U256::from(101))],
         &[],
         0,
         None,
     );
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
 
     vm.function(
         "rm",
-        &[
-            Token::Uint(ethereum_types::U256::from(0)),
-            Token::Uint(ethereum_types::U256::from(104)),
-        ],
+        &[Token::Uint(U256::from(0)), Token::Uint(U256::from(104))],
         &[],
         0,
         None,
@@ -740,22 +673,16 @@ fn mapping_in_struct_in_dynamic_array() {
     for i in 0..10 {
         let returns = vm.function(
             "get",
-            &[
-                Token::Uint(ethereum_types::U256::from(0)),
-                Token::Uint(ethereum_types::U256::from(102 + i)),
-            ],
+            &[Token::Uint(U256::from(0)), Token::Uint(U256::from(102 + i))],
             &[],
             0,
             None,
         );
 
         if 102 + i != 104 {
-            assert_eq!(
-                returns,
-                vec![Token::Uint(ethereum_types::U256::from(300331 + i))]
-            );
+            assert_eq!(returns, vec![Token::Uint(U256::from(300331 + i))]);
         } else {
-            assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+            assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
         }
     }
 
@@ -764,8 +691,5 @@ fn mapping_in_struct_in_dynamic_array() {
 
     let returns = vm.function("number", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![Token::Int(ethereum_types::U256::from(2147483647))]
-    );
+    assert_eq!(returns, vec![Token::Int(U256::from(2147483647))]);
 }

+ 3 - 3
tests/solana_tests/math.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 use num_bigint::BigUint;
 use std::str::FromStr;
 
@@ -158,7 +158,7 @@ fn safe_math() {
     assert_ne!(res, Ok(0));
 }
 
-fn biguint_to_eth(v: &BigUint) -> ethereum_types::U256 {
+fn biguint_to_eth(v: &BigUint) -> U256 {
     let mut buf = v.to_bytes_be();
     let width = 32;
 
@@ -170,5 +170,5 @@ fn biguint_to_eth(v: &BigUint) -> ethereum_types::U256 {
         buf.insert(0, 0);
     }
 
-    ethereum_types::U256::from_big_endian(&buf)
+    U256::from_big_endian(&buf)
 }

+ 3 - 12
tests/solana_tests/modifiers.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn returns_and_phis_needed() {
@@ -32,19 +32,10 @@ fn returns_and_phis_needed() {
 
     assert_eq!(
         returns,
-        vec![
-            Token::Int(ethereum_types::U256::from(40)),
-            Token::Bool(false)
-        ]
+        vec![Token::Int(U256::from(40)), Token::Bool(false)]
     );
 
     let returns = vm.function("func", &[Token::Bool(true)], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![
-            Token::Int(ethereum_types::U256::from(12)),
-            Token::Bool(true)
-        ]
-    );
+    assert_eq!(returns, vec![Token::Int(U256::from(12)), Token::Bool(true)]);
 }

+ 27 - 42
tests/solana_tests/primitives.rs

@@ -1,4 +1,5 @@
 use crate::build_solidity;
+use ethabi::ethereum_types::U256;
 use num_bigint::{BigInt, BigUint};
 use rand::Rng;
 use std::ops::Add;
@@ -155,14 +156,11 @@ fn test_enum() {
 
     let returns = vm.function("return_enum", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(9))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(9))]);
 
     vm.function(
         "enum_arg",
-        &[ethabi::Token::Uint(ethereum_types::U256::from(6))],
+        &[ethabi::Token::Uint(U256::from(6))],
         &[],
         0,
         None,
@@ -300,7 +298,7 @@ fn bytes() {
                 "shift_left",
                 &[
                     ethabi::Token::FixedBytes(a.to_vec()),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
+                    ethabi::Token::Uint(U256::from(r)),
                 ],
                 &[],
                 0,
@@ -323,7 +321,7 @@ fn bytes() {
                 "shift_right",
                 &[
                     ethabi::Token::FixedBytes(a.to_vec()),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
+                    ethabi::Token::Uint(U256::from(r)),
                 ],
                 &[],
                 0,
@@ -415,8 +413,8 @@ fn uint() {
             rng.fill(&mut a[..]);
             rng.fill(&mut b[..]);
 
-            let mut a = ethereum_types::U256::from_big_endian(&a);
-            let mut b = ethereum_types::U256::from_big_endian(&b);
+            let mut a = U256::from_big_endian(&a);
+            let mut b = U256::from_big_endian(&b);
 
             rng.fill(&mut a.0[..]);
             rng.fill(&mut b.0[..]);
@@ -486,7 +484,7 @@ fn uint() {
 
             assert_eq!(pow, vec![ethabi::Token::Uint(res)]);
 
-            if b != ethereum_types::U256::zero() {
+            if b != U256::zero() {
                 let div = vm.function(
                     "div",
                     &[ethabi::Token::Uint(a), ethabi::Token::Uint(b)],
@@ -524,7 +522,7 @@ fn uint() {
                 None,
             );
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] | b.0[0],
                 a.0[1] | b.0[1],
                 a.0[2] | b.0[2],
@@ -543,7 +541,7 @@ fn uint() {
                 None,
             );
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] & b.0[0],
                 a.0[1] & b.0[1],
                 a.0[2] & b.0[2],
@@ -562,7 +560,7 @@ fn uint() {
                 None,
             );
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] ^ b.0[0],
                 a.0[1] ^ b.0[1],
                 a.0[2] ^ b.0[2],
@@ -577,10 +575,7 @@ fn uint() {
 
             let shl = vm.function(
                 "shift_left",
-                &[
-                    ethabi::Token::Uint(a),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
-                ],
+                &[ethabi::Token::Uint(a), ethabi::Token::Uint(U256::from(r))],
                 &[],
                 0,
                 None,
@@ -594,10 +589,7 @@ fn uint() {
 
             let shr = vm.function(
                 "shift_right",
-                &[
-                    ethabi::Token::Uint(a),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
-                ],
+                &[ethabi::Token::Uint(a), ethabi::Token::Uint(U256::from(r))],
                 &[],
                 0,
                 None,
@@ -612,7 +604,7 @@ fn uint() {
     }
 }
 
-fn truncate_uint(n: &mut ethereum_types::U256, width: usize) {
+fn truncate_uint(n: &mut U256, width: usize) {
     let mut bits = 256 - width;
 
     let mut offset = 3;
@@ -692,8 +684,8 @@ fn int() {
             rng.fill(&mut a_bs[..]);
             rng.fill(&mut b_bs[..]);
 
-            let mut a = ethereum_types::U256::from_big_endian(&a_bs);
-            let mut b = ethereum_types::U256::from_big_endian(&b_bs);
+            let mut a = U256::from_big_endian(&a_bs);
+            let mut b = U256::from_big_endian(&b_bs);
 
             truncate_int(&mut a, width);
             truncate_int(&mut b, width);
@@ -739,7 +731,7 @@ fn int() {
 
             assert_eq!(mul, vec![ethabi::Token::Int(res)]);
 
-            if b != ethereum_types::U256::zero() {
+            if b != U256::zero() {
                 let div = vm.function(
                     "div",
                     &[ethabi::Token::Int(a), ethabi::Token::Int(b)],
@@ -775,7 +767,7 @@ fn int() {
                 None,
             );
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] | b.0[0],
                 a.0[1] | b.0[1],
                 a.0[2] | b.0[2],
@@ -794,7 +786,7 @@ fn int() {
                 None,
             );
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] & b.0[0],
                 a.0[1] & b.0[1],
                 a.0[2] & b.0[2],
@@ -813,7 +805,7 @@ fn int() {
                 None,
             );
 
-            let mut res = ethereum_types::U256([
+            let mut res = U256([
                 a.0[0] ^ b.0[0],
                 a.0[1] ^ b.0[1],
                 a.0[2] ^ b.0[2],
@@ -828,10 +820,7 @@ fn int() {
 
             let shl = vm.function(
                 "shift_left",
-                &[
-                    ethabi::Token::Int(a),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
-                ],
+                &[ethabi::Token::Int(a), ethabi::Token::Uint(U256::from(r))],
                 &[],
                 0,
                 None,
@@ -845,10 +834,7 @@ fn int() {
 
             let shr = vm.function(
                 "shift_right",
-                &[
-                    ethabi::Token::Int(a),
-                    ethabi::Token::Uint(ethereum_types::U256::from(r)),
-                ],
+                &[ethabi::Token::Int(a), ethabi::Token::Uint(U256::from(r))],
                 &[],
                 0,
                 None,
@@ -861,9 +847,8 @@ fn int() {
     }
 }
 
-fn truncate_int(n: &mut ethereum_types::U256, width: usize) {
-    let sign =
-        n.bitand(ethereum_types::U256::from(1) << (width - 1)) != ethereum_types::U256::zero();
+fn truncate_int(n: &mut U256, width: usize) {
+    let sign = n.bitand(U256::from(1) << (width - 1)) != U256::zero();
 
     let mut bits = 256 - width;
 
@@ -885,7 +870,7 @@ fn truncate_int(n: &mut ethereum_types::U256, width: usize) {
     }
 }
 
-fn bigint_to_eth(v: &BigInt, width: usize) -> ethereum_types::U256 {
+fn bigint_to_eth(v: &BigInt, width: usize) -> U256 {
     let mut buf = v.to_signed_bytes_be();
     let width = width / 8;
 
@@ -899,10 +884,10 @@ fn bigint_to_eth(v: &BigInt, width: usize) -> ethereum_types::U256 {
         buf.insert(0, sign);
     }
 
-    ethereum_types::U256::from_big_endian(&buf)
+    U256::from_big_endian(&buf)
 }
 
-fn eth_to_bigint(v: &ethereum_types::U256, width: usize) -> BigInt {
+fn eth_to_bigint(v: &U256, width: usize) -> BigInt {
     let mut buf = Vec::new();
 
     buf.resize(32, 0);

+ 12 - 35
tests/solana_tests/rational.rs

@@ -1,4 +1,5 @@
 use crate::build_solidity;
+use ethabi::ethereum_types::U256;
 
 #[test]
 fn rational() {
@@ -21,17 +22,11 @@ fn rational() {
 
     let returns = vm.function("test", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(4))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(4))]);
 
     let returns = vm.function("test2", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(4))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(4))]);
 
     let mut vm = build_solidity(
         r#"
@@ -47,10 +42,7 @@ fn rational() {
 
     let returns = vm.function("test", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(5))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(5))]);
 
     let mut vm = build_solidity(
         r#"
@@ -66,10 +58,7 @@ fn rational() {
 
     let returns = vm.function("test", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(24))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(24))]);
 
     let mut vm = build_solidity(
         r#"
@@ -85,10 +74,7 @@ fn rational() {
 
     let returns = vm.function("test", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(0))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(0))]);
 
     let mut vm = build_solidity(
         r#"
@@ -104,10 +90,7 @@ fn rational() {
 
     let returns = vm.function("test", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(4))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(4))]);
 
     let mut vm = build_solidity(
         r#"
@@ -122,10 +105,7 @@ fn rational() {
 
     let returns = vm.function("test", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(3))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(3))]);
 
     let mut vm = build_solidity(
         r#"
@@ -140,10 +120,7 @@ fn rational() {
 
     let returns = vm.function("test", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(15600))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(15600))]);
 
     let mut vm = build_solidity(
         r#"
@@ -158,7 +135,7 @@ fn rational() {
 
     let returns = vm.function(
         "test",
-        &[ethabi::Token::Uint(ethereum_types::U256::from(982451653))],
+        &[ethabi::Token::Uint(U256::from(982451653))],
         &[],
         0,
         None,
@@ -167,8 +144,8 @@ fn rational() {
     assert_eq!(
         returns,
         vec![
-            ethabi::Token::Uint(ethereum_types::U256::from(961748941u64 * 982451653u64)),
-            ethabi::Token::Uint(ethereum_types::U256::from(5))
+            ethabi::Token::Uint(U256::from(961748941u64 * 982451653u64)),
+            ethabi::Token::Uint(U256::from(5))
         ]
     );
 }

+ 12 - 24
tests/solana_tests/returns.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn return_single() {
@@ -31,19 +31,19 @@ fn return_single() {
     vm.constructor("foo", &[], 0);
 
     let returns = vm.function("f", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(2)),]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(2)),]);
 
     let returns = vm.function("g", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(3)),]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(3)),]);
 
     let returns = vm.function("h", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(2)),]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(2)),]);
 
     let returns = vm.function("i", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(24)),]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(24)),]);
 
     let returns = vm.function("j", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(5)),]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(5)),]);
 }
 
 #[test]
@@ -62,10 +62,7 @@ fn return_ternary() {
 
     assert_eq!(
         returns,
-        vec![
-            Token::Uint(ethereum_types::U256::from(3)),
-            Token::Uint(ethereum_types::U256::from(4)),
-        ]
+        vec![Token::Uint(U256::from(3)), Token::Uint(U256::from(4)),]
     );
 
     let mut vm = build_solidity(
@@ -82,10 +79,7 @@ fn return_ternary() {
 
     assert_eq!(
         returns,
-        vec![
-            Token::Uint(ethereum_types::U256::from(6)),
-            Token::Uint(ethereum_types::U256::from(4)),
-        ]
+        vec![Token::Uint(U256::from(6)), Token::Uint(U256::from(4)),]
     );
 }
 
@@ -116,7 +110,7 @@ fn return_nothing() {
     let _returns = vm.function("inc", &[], &[], 0, None);
     let returns = vm.function("get", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(2)),]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(2)),]);
 
     let mut vm = build_solidity(
         r#"
@@ -145,7 +139,7 @@ fn return_nothing() {
     let _returns = vm.function("f", &[], &[], 0, None);
     let returns = vm.function("get", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(5)),]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(5)),]);
 }
 
 #[test]
@@ -168,10 +162,7 @@ fn return_function() {
 
     assert_eq!(
         returns,
-        vec![
-            Token::Uint(ethereum_types::U256::from(1)),
-            Token::Uint(ethereum_types::U256::from(2)),
-        ]
+        vec![Token::Uint(U256::from(1)), Token::Uint(U256::from(2)),]
     );
 
     let mut vm = build_solidity(
@@ -192,9 +183,6 @@ fn return_function() {
 
     assert_eq!(
         returns,
-        vec![
-            Token::Uint(ethereum_types::U256::from(1)),
-            Token::Uint(ethereum_types::U256::from(2)),
-        ]
+        vec![Token::Uint(U256::from(1)), Token::Uint(U256::from(2)),]
     );
 }

+ 13 - 37
tests/solana_tests/simple.rs

@@ -1,4 +1,5 @@
 use crate::build_solidity;
+use ethabi::ethereum_types::U256;
 use solang::{file_resolver::FileResolver, Target};
 use std::ffi::OsStr;
 
@@ -71,8 +72,8 @@ fn parameters() {
     vm.function(
         "test",
         &[
-            ethabi::Token::Uint(ethereum_types::U256::from(10)),
-            ethabi::Token::Uint(ethereum_types::U256::from(10)),
+            ethabi::Token::Uint(U256::from(10)),
+            ethabi::Token::Uint(U256::from(10)),
         ],
         &[],
         0,
@@ -86,8 +87,8 @@ fn parameters() {
     vm.function(
         "test",
         &[
-            ethabi::Token::Uint(ethereum_types::U256::from(99)),
-            ethabi::Token::Uint(ethereum_types::U256::from(102)),
+            ethabi::Token::Uint(U256::from(99)),
+            ethabi::Token::Uint(U256::from(102)),
         ],
         &[],
         0,
@@ -110,18 +111,9 @@ fn returns() {
 
     vm.constructor("foo", &[], 0);
 
-    let returns = vm.function(
-        "test",
-        &[ethabi::Token::Uint(ethereum_types::U256::from(10))],
-        &[],
-        0,
-        None,
-    );
+    let returns = vm.function("test", &[ethabi::Token::Uint(U256::from(10))], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(100))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(100))]);
 
     let mut vm = build_solidity(
         r#"
@@ -136,7 +128,7 @@ fn returns() {
 
     let returns = vm.function(
         "test",
-        &[ethabi::Token::Uint(ethereum_types::U256::from(982451653))],
+        &[ethabi::Token::Uint(U256::from(982451653))],
         &[],
         0,
         None,
@@ -146,7 +138,7 @@ fn returns() {
         returns,
         vec![
             ethabi::Token::Bool(true),
-            ethabi::Token::Uint(ethereum_types::U256::from(961748941u64 * 982451653u64))
+            ethabi::Token::Uint(U256::from(961748941u64 * 982451653u64))
         ]
     );
 }
@@ -231,33 +223,17 @@ fn incrementer() {
         }"#,
     );
 
-    vm.constructor(
-        "incrementer",
-        &[ethabi::Token::Uint(ethereum_types::U256::from(5))],
-        0,
-    );
+    vm.constructor("incrementer", &[ethabi::Token::Uint(U256::from(5))], 0);
 
     let returns = vm.function("get", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(5))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(5))]);
 
-    vm.function(
-        "inc",
-        &[ethabi::Token::Uint(ethereum_types::U256::from(7))],
-        &[],
-        0,
-        None,
-    );
+    vm.function("inc", &[ethabi::Token::Uint(U256::from(7))], &[], 0, None);
 
     let returns = vm.function("get", &[], &[], 0, None);
 
-    assert_eq!(
-        returns,
-        vec![ethabi::Token::Uint(ethereum_types::U256::from(12))]
-    );
+    assert_eq!(returns, vec![ethabi::Token::Uint(U256::from(12))]);
 }
 
 #[test]

+ 43 - 59
tests/solana_tests/storage.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 #[test]
 fn simple() {
@@ -17,7 +17,7 @@ fn simple() {
 
     vm.constructor("foo", &[], 0);
     let returns = vm.function("boom", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Int(ethereum_types::U256::from(0)),]);
+    assert_eq!(returns, vec![Token::Int(U256::from(0)),]);
 
     let mut vm = build_solidity(
         r#"
@@ -41,7 +41,7 @@ fn simple() {
 
     vm.constructor("c", &[], 0);
     let returns = vm.function("func", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Int(ethereum_types::U256::from(1)),]);
+    assert_eq!(returns, vec![Token::Int(U256::from(1)),]);
 }
 
 #[test]
@@ -158,7 +158,7 @@ fn bytes() {
 
     let returns = vm.function("foo_length", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Uint(ethereum_types::U256::from(0))]);
+    assert_eq!(returns, vec![Token::Uint(U256::from(0))]);
 
     vm.function(
         "set_foo",
@@ -181,7 +181,7 @@ fn bytes() {
     {
         let returns = vm.function(
             "get_foo_offset",
-            &[Token::Uint(ethereum_types::U256::from(i))],
+            &[Token::Uint(U256::from(i))],
             &[],
             0,
             None,
@@ -192,10 +192,7 @@ fn bytes() {
 
     vm.function(
         "set_foo_offset",
-        &[
-            Token::Uint(ethereum_types::U256::from(2)),
-            Token::FixedBytes(b"E".to_vec()),
-        ],
+        &[Token::Uint(U256::from(2)), Token::FixedBytes(b"E".to_vec())],
         &[],
         0,
         None,
@@ -203,10 +200,7 @@ fn bytes() {
 
     vm.function(
         "set_foo_offset",
-        &[
-            Token::Uint(ethereum_types::U256::from(7)),
-            Token::FixedBytes(b"E".to_vec()),
-        ],
+        &[Token::Uint(U256::from(7)), Token::FixedBytes(b"E".to_vec())],
         &[],
         0,
         None,
@@ -218,7 +212,7 @@ fn bytes() {
     {
         let returns = vm.function(
             "get_foo_offset",
-            &[Token::Uint(ethereum_types::U256::from(i))],
+            &[Token::Uint(U256::from(i))],
             &[],
             0,
             None,
@@ -258,10 +252,7 @@ fn bytes_set_subscript_range() {
 
     vm.function(
         "set_foo_offset",
-        &[
-            Token::Uint(ethereum_types::U256::from(0)),
-            Token::FixedBytes(b"E".to_vec()),
-        ],
+        &[Token::Uint(U256::from(0)), Token::FixedBytes(b"E".to_vec())],
         &[],
         0,
         None,
@@ -308,7 +299,7 @@ fn bytes_get_subscript_range() {
 
     vm.function(
         "get_foo_offset",
-        &[Token::Uint(ethereum_types::U256::from(0x80000000u64))],
+        &[Token::Uint(U256::from(0x80000000u64))],
         &[],
         0,
         None,
@@ -452,16 +443,16 @@ fn simple_struct() {
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(254)),
-            Token::Uint(ethereum_types::U256::from(0xdead)),
+            Token::Uint(U256::from(254)),
+            Token::Uint(U256::from(0xdead)),
         ])]
     );
 
     vm.function(
         "set_s1",
         &[Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(102)),
-            Token::Uint(ethereum_types::U256::from(3240121)),
+            Token::Uint(U256::from(102)),
+            Token::Uint(U256::from(3240121)),
         ])],
         &[],
         0,
@@ -473,8 +464,8 @@ fn simple_struct() {
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(102)),
-            Token::Uint(ethereum_types::U256::from(3240121)),
+            Token::Uint(U256::from(102)),
+            Token::Uint(U256::from(3240121)),
         ])]
     );
 }
@@ -530,24 +521,24 @@ fn struct_in_struct() {
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(254)),
+            Token::Uint(U256::from(254)),
             Token::Tuple(vec![
-                Token::Int(ethereum_types::U256::from(102)),
+                Token::Int(U256::from(102)),
                 Token::FixedBytes(vec![102, 111, 111, 98, 97, 114])
             ]),
-            Token::Uint(ethereum_types::U256::from(1234567890))
+            Token::Uint(U256::from(1234567890))
         ])]
     );
 
     vm.function(
         "set_s1",
         &[Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(127)),
+            Token::Uint(U256::from(127)),
             Token::Tuple(vec![
-                Token::Int(ethereum_types::U256::from(8192)),
+                Token::Int(U256::from(8192)),
                 Token::FixedBytes(vec![1, 2, 3, 4, 5, 6]),
             ]),
-            Token::Uint(ethereum_types::U256::from(12345678901234567890u64)),
+            Token::Uint(U256::from(12345678901234567890u64)),
         ])],
         &[],
         0,
@@ -559,12 +550,12 @@ fn struct_in_struct() {
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(127)),
+            Token::Uint(U256::from(127)),
             Token::Tuple(vec![
-                Token::Int(ethereum_types::U256::from(8192)),
+                Token::Int(U256::from(8192)),
                 Token::FixedBytes(vec![1, 2, 3, 4, 5, 6]),
             ]),
-            Token::Uint(ethereum_types::U256::from(12345678901234567890u64)),
+            Token::Uint(U256::from(12345678901234567890u64)),
         ])]
     );
 }
@@ -615,18 +606,18 @@ fn string_in_struct() {
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(254)),
+            Token::Uint(U256::from(254)),
             Token::String(String::from("foobar")),
-            Token::Uint(ethereum_types::U256::from(1234567890))
+            Token::Uint(U256::from(1234567890))
         ])]
     );
 
     vm.function(
         "set_s1",
         &[Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(127)),
+            Token::Uint(U256::from(127)),
             Token::String(String::from("foobar foobar foobar foobar foobar foobar")),
-            Token::Uint(ethereum_types::U256::from(12345678901234567890u64)),
+            Token::Uint(U256::from(12345678901234567890u64)),
         ])],
         &[],
         0,
@@ -638,9 +629,9 @@ fn string_in_struct() {
     assert_eq!(
         returns,
         vec![Token::Tuple(vec![
-            Token::Uint(ethereum_types::U256::from(127)),
+            Token::Uint(U256::from(127)),
             Token::String(String::from("foobar foobar foobar foobar foobar foobar")),
-            Token::Uint(ethereum_types::U256::from(12345678901234567890u64)),
+            Token::Uint(U256::from(12345678901234567890u64)),
         ])]
     );
 }
@@ -707,15 +698,15 @@ fn complex_struct() {
         returns,
         vec![
             Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(254)),
+                Token::Uint(U256::from(254)),
                 Token::String(String::from("foobar")),
                 Token::Tuple(vec!(
                     Token::Bool(true),
                     Token::FixedBytes(vec!(0xed, 0xae, 0xda))
                 )),
-                Token::Uint(ethereum_types::U256::from(1234567890)),
+                Token::Uint(U256::from(1234567890)),
                 Token::Tuple(vec!(
-                    Token::Uint(ethereum_types::U256::from(12123131321312u128)),
+                    Token::Uint(U256::from(12123131321312u128)),
                     Token::Bytes(b"jasldajldjaldjlads".to_vec())
                 )),
                 Token::String(String::from(
@@ -730,17 +721,15 @@ fn complex_struct() {
         "set_s1",
         &[
             Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(127)),
+                Token::Uint(U256::from(127)),
                 Token::String(String::from("foobar foobar foobar foobar foobar foobar")),
                 Token::Tuple(vec![
                     Token::Bool(false),
                     Token::FixedBytes(vec![0xc3, 0x9a, 0xfd]),
                 ]),
-                Token::Uint(ethereum_types::U256::from(12345678901234567890u64)),
+                Token::Uint(U256::from(12345678901234567890u64)),
                 Token::Tuple(vec![
-                    Token::Uint(ethereum_types::U256::from(
-                        97560097522392203078545981438598778247u128,
-                    )),
+                    Token::Uint(U256::from(97560097522392203078545981438598778247u128)),
                     Token::Bytes(b"jasldajldjaldjlads".to_vec()),
                 ]),
                 Token::String(String::from("be as honest as the day is long")),
@@ -758,17 +747,15 @@ fn complex_struct() {
         returns,
         vec![
             Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(127)),
+                Token::Uint(U256::from(127)),
                 Token::String(String::from("foobar foobar foobar foobar foobar foobar")),
                 Token::Tuple(vec![
                     Token::Bool(false),
                     Token::FixedBytes(vec![0xc3, 0x9a, 0xfd]),
                 ]),
-                Token::Uint(ethereum_types::U256::from(12345678901234567890u64)),
+                Token::Uint(U256::from(12345678901234567890u64)),
                 Token::Tuple(vec![
-                    Token::Uint(ethereum_types::U256::from(
-                        97560097522392203078545981438598778247u128,
-                    )),
+                    Token::Uint(U256::from(97560097522392203078545981438598778247u128,)),
                     Token::Bytes(b"jasldajldjaldjlads".to_vec()),
                 ]),
                 Token::String(String::from("be as honest as the day is long")),
@@ -785,14 +772,11 @@ fn complex_struct() {
         returns,
         vec![
             Token::Tuple(vec![
-                Token::Uint(ethereum_types::U256::from(0)),
+                Token::Uint(U256::from(0)),
                 Token::String(String::from("")),
                 Token::Tuple(vec![Token::Bool(false), Token::FixedBytes(vec![0, 0, 0]),]),
-                Token::Uint(ethereum_types::U256::from(0)),
-                Token::Tuple(vec![
-                    Token::Uint(ethereum_types::U256::from(0)),
-                    Token::Bytes(Vec::new()),
-                ]),
+                Token::Uint(U256::from(0)),
+                Token::Tuple(vec![Token::Uint(U256::from(0)), Token::Bytes(Vec::new()),]),
                 Token::String(String::from("")),
             ]),
             Token::String(String::from("yadayada")),

+ 4 - 4
tests/solana_tests/unused_variable_elimination.rs

@@ -1,5 +1,5 @@
 use crate::build_solidity;
-use ethabi::Token;
+use ethabi::{ethereum_types::U256, Token};
 
 /// This tests check that a public storage variable is not eliminated
 /// and that an assignment inside an expression works
@@ -39,10 +39,10 @@ fn test_returns() {
     let _ = vm.function("assign", &[], &[], 0, None);
     let returns = vm.function("pb1", &[], &[], 0, None);
 
-    assert_eq!(returns, vec![Token::Int(ethereum_types::U256::from(5))]);
+    assert_eq!(returns, vec![Token::Int(U256::from(5))]);
 
     let returns = vm.function("test1", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Int(ethereum_types::U256::from(52))]);
+    assert_eq!(returns, vec![Token::Int(U256::from(52))]);
     let returns = vm.function("test2", &[], &[], 0, None);
-    assert_eq!(returns, vec![Token::Int(ethereum_types::U256::from(5))]);
+    assert_eq!(returns, vec![Token::Int(U256::from(5))]);
 }