airgap-it / tezos-rust-sdk

MIT License
20 stars 10 forks source link

iOS target #13

Open Milerius opened 1 year ago

Milerius commented 1 year ago

Hello

I got the following error when I'm compiling to ios targets:

error[E0412]: cannot find type `TryFromBigIntError` in crate `num_bigint`
   --> /Users/romansztergbaum/.cargo/git/checkouts/tezos-rust-sdk-1c87e5341bf84ccf/8885fac/tezos-core/src/error.rs:38:29
    |
38  |         source: num_bigint::TryFromBigIntError<num_bigint::BigInt>,
    |                             ^^^^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `ParseBigIntError`
    |
   ::: /Users/romansztergbaum/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.4.3/src/lib.rs:141:1
    |
141 | pub struct ParseBigIntError {
    | --------------------------- similarly named struct `ParseBigIntError` defined here

error[E0412]: cannot find type `TryFromBigIntError` in crate `num_bigint`
   --> /Users/romansztergbaum/.cargo/git/checkouts/tezos-rust-sdk-1c87e5341bf84ccf/8885fac/tezos-core/src/error.rs:41:29
    |
41  |         source: num_bigint::TryFromBigIntError<num_bigint::BigUint>,
    |                             ^^^^^^^^^^^^^^^^^^ help: a struct with a similar name exists: `ParseBigIntError`
    |
   ::: /Users/romansztergbaum/.cargo/registry/src/github.com-1ecc6299db9ec823/num-bigint-0.4.3/src/lib.rs:141:1
    |
141 | pub struct ParseBigIntError {
    | --------------------------- similarly named struct `ParseBigIntError` defined here

error[E0277]: the trait bound `i64: From<BigUint>` is not satisfied
   --> /Users/romansztergbaum/.cargo/git/checkouts/tezos-rust-sdk-1c87e5341bf84ccf/8885fac/tezos-core/src/types/mutez.rs:157:23
    |
157 |         Ok(Self(value.try_into()?))
    |                       ^^^^^^^^ the trait `From<BigUint>` is not implemented for `i64`
    |
    = help: the following other types implement trait `From<T>`:
              <i64 as From<NonZeroI64>>
              <i64 as From<bool>>
              <i64 as From<i16>>
              <i64 as From<i32>>
              <i64 as From<i8>>
              <i64 as From<u16>>
              <i64 as From<u32>>
              <i64 as From<u8>>
    = note: required for `BigUint` to implement `Into<i64>`
    = note: required for `i64` to implement `TryFrom<BigUint>`
    = note: required for `BigUint` to implement `TryInto<i64>`

error[E0277]: `?` couldn't convert the error to `error::Error`
   --> /Users/romansztergbaum/.cargo/git/checkouts/tezos-rust-sdk-1c87e5341bf84ccf/8885fac/tezos-core/src/types/mutez.rs:157:33
    |
157 |         Ok(Self(value.try_into()?))
    |                                 ^ the trait `From<Infallible>` is not implemented for `error::Error`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <error::Error as From<FromUtf8Error>>
              <error::Error as From<ParseBigIntError>>
              <error::Error as From<ParseIntError>>
              <error::Error as From<String>>
              <error::Error as From<TryFromIntError>>
              <error::Error as From<[type error]>>
              <error::Error as From<bs58::decode::Error>>
    = note: required for `std::result::Result<Mutez, error::Error>` to implement `FromResidual<std::result::Result<Infallible, Infallible>>`

Some errors have detailed explanations: E0277, E0412.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `tezos-core` due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `tezos-core` due to 4 previous errors

I need to support macabi for cross-platform, so far it's only supported on nightly:

command used:

cargo +nightly build -Z build-std --target aarch64-apple-ios-macabi --target x86_64-apple-ios-macabi --release
RomarQ commented 1 year ago

Currently, we do not support these targets. num_bigint seems to have some limitations because they focus on performance instead of being more agnostic.

@m-kus has integrated ibig-rs successfully, which seems to fix the compatibility issues you are facing. Give it a try: https://github.com/m-kus/tezos-rust-sdk/pull/1

On our side, we still need to evaluate the ibig-rs migration. Hopefully, we will merge Michael contribution soon.

m-kus commented 1 year ago

Yes, sorry, I will allocate some time soon to backport all the changes I made.

Regarding the ibig crate specifically, there's a follow-up refactoring changing the underlying representation of Nat and Int (UBig and IBig instead of String) and unification of bigint field types in all crates (especially tezos_rpc).