Issue with Predicate Orderbook Migration to Sway Beta 5 and Rust SDK v0.54
Title: Issue with Predicate Orderbook Migration to Sway Beta 5 and Rust SDK v0.54
Hello,
I recently migrated my predicate orderbook to the new version of Sway and updated the Rust SDK to version 0.54, along with the toolchain. I’ve made necessary code adjustments and updated the token code as well.
The predicate code is available at:
Using sway-libs and sway-standards, I implemented the token, which can be found here:
The mint and deploy functions are located at:
Token Utils
I’ve written a simple test that mints the token and sends funds to the predicate, located here:
However, I’m encountering an error with the test: “Response errors; not enough coins to fit the target”, despite having sufficient funds (verified on line 42).
Error Details:
🏁 Create Order Test 🏁
Builded During EthGlobal Lisbon Hackaton 🛵
alice_address = 0x5d99ee966b42cd8fc7bdd1364b389153a9e78b42b7d4a691470674e817888d4e
USDC AssetId (asset0) = 0x227271fb1937e40ff4cb5aee74941ac4c85b016296f0b8ba7e6bc790e6d2b98b
BTC AssetId (asset1) = 0x28cca92b65313cddf5b1354a372ecd5baf4febec47beec5f0781fadfec2861f9
amount0 = 40000 USDC
amount1 = 1 BTC
Price = 25000 BTC/USDC
Alice minting 40000 USDC
Predicate root = Bech32Address { hrp: "fuel", hash: 225d06aef771d10b312c7b1658d91cf98ffec2dc60a456c48c3d267cbc3042cb }
thread 'local_tests::create_order_test::create_order_test' panicked at tests/local_tests/create_order_test.rs:69:10:
called `Result::unwrap()` on an `Err` value: ProviderError("Client request error: Response errors; not enough coins to fit the target")
stack backtrace:
0: rust_begin_unwind
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1653:5
3: core::result::Result<T,E>::unwrap
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1077:23
4: tests::local_tests::create_order_test::create_order_test::{{closure}}
at ./tests/local_tests/create_order_test.rs:66:5
5: <core::pin::Pin<P> as core::future::future::Future>::poll
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/future/future.rs:125:9
6: <core::pin::Pin<P> as core::future::future::Future>::poll
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/future/future.rs:125:9
7: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:665:57
8: tokio::runtime::coop::with_budget
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/coop.rs:107:5
9: tokio::runtime::coop::budget
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/coop.rs:73:5
10: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:665:25
11: tokio::runtime::scheduler::current_thread::Context::enter
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:410:19
12: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:664:36
13: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:743:68
14: tokio::runtime::context::scoped::Scoped<T>::set
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context/scoped.rs:40:9
15: tokio::runtime::context::set_scheduler::{{closure}}
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context.rs:176:26
16: std::thread::local::LocalKey<T>::try_with
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
17: std::thread::local::LocalKey<T>::with
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
18: tokio::runtime::context::set_scheduler
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context.rs:176:9
19: tokio::runtime::scheduler::current_thread::CoreGuard::enter
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:743:27
20: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:652:19
21: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:175:28
22: tokio::runtime::context::runtime::enter_runtime
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context/runtime.rs:65:16
23: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:167:9
24: tokio::runtime::runtime::Runtime::block_on
at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/runtime.rs:348:47
25: tests::local_tests::create_order_test::create_order_test
at ./tests/local_tests/create_order_test.rs:72:5
26: tests::local_tests::create_order_test::create_order_test::{{closure}}
at ./tests/local_tests/create_order_test.rs:15:29
27: core::ops::function::FnOnce::call_once
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
28: core::ops::function::FnOnce::call_once
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test local_tests::create_order_test::create_order_test ... FAILED
failures:
failures:
local_tests::create_order_test::create_order_test
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.58s
error: test failed, to rerun pass `-p spark_sdk --test tests`
* The terminal process "cargo 'test', '--package', 'spark_sdk', '--test', 'tests', '--', 'local_tests::create_order_test::create_order_test', '--exact', '--nocapture'" terminated with exit code: 101.
* Terminal will be reused by tasks, press any key to close it.
Toolchain Details:
Default host: aarch64-apple-darwin
fuelup home: /Users/alexey/.fuelup
installed toolchains
--------------------
latest-aarch64-apple-darwin (default)
my-custom-toolchain
nightly-2024-01-24-aarch64-apple-darwin
active toolchain
----------------
latest-aarch64-apple-darwin (default)
forc : 0.49.1
- forc-client
- forc-deploy : 0.49.1
- forc-run : 0.49.1
- forc-crypto : 0.49.1
- forc-doc : 0.49.1
- forc-explore : 0.28.1
- forc-fmt : 0.49.1
- forc-lsp : 0.49.1
- forc-tx : 0.49.1
- forc-wallet : 0.4.2
fuel-core : 0.22.0
fuel-core-keygen : 0.22.0
fuels versions
--------------
forc : 0.54.0
forc-wallet : 0.54.0
I would appreciate any insights or suggestions on resolving this issue.
Thank you!