Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

soroban-cli: Cannot seem to pass None via the CLI #330

Closed
kalepail opened this issue Dec 30, 2022 · 3 comments · Fixed by #343
Closed

soroban-cli: Cannot seem to pass None via the CLI #330

kalepail opened this issue Dec 30, 2022 · 3 comments · Fixed by #343
Assignees
Labels
bug Something isn't working soroban-scrum

Comments

@kalepail
Copy link
Contributor

kalepail commented Dec 30, 2022

What version are you using?

soroban 0.3.3 (dc87a2947e8bfbbea56cd3762795b527812d2d01)
soroban-env 0.0.10 (c14805161b54ba272108ba0503057683f2a688a2)
soroban-env interface version 26
stellar-xdr 0.0.9 (1309e3de46fcb01743f818831de3a9ac4a5b1ab6)
xdr next (026c9cd074bdb28ddde8ee52f2a4502d9e518a09)

What did you do?

Tried to call a None argument via the CLI in several different ways

--arg '{"static":"void"}'
--arg 'null'
--arg null

What did you expect to see?

Success

What did you see instead?

error: parsing argument {"static":"void"}: parse error: value is not parseable to Option(ScSpecTypeOption { value_type: AccountId })
error: HostError
Value: Status(HostValueError(UnknownError))

Debug events (newest first):
   0: "Status(HostValueError(UnknownError))"

Backtrace (newest first):
   0: backtrace::capture::Backtrace::new_unresolved
   1: soroban_env_host::host::err_helper::<impl soroban_env_host::host::Host>::err
   2: soroban_env_host::host::Host::to_host_val
   3: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
   4: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
   5: core::iter::adapters::try_process
   6: soroban_env_host::host::Host::invoke_function
   7: soroban::invoke::Cmd::run_in_sandbox
   8: soroban::run::{{closure}}
   9: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  10: tokio::runtime::park::CachedParkThread::block_on
  11: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
  12: soroban::main

Contract code:

#![no_std]

use soroban_sdk::{contractimpl, Env, AccountId, Address};

pub struct TestContract;

#[contractimpl]
impl TestContract {
    pub fn set_wo(env: Env) {
        let to: Option<AccountId> = None;
        let source_account: Address;

        if to.is_none() {
            source_account = env.invoker();
        } else {
            source_account = Address::Account(to.unwrap());
        }

        env.storage().set(env.invoker(), source_account);
    }
    pub fn set_w(env: Env, to: Option<AccountId>) {
        let source_account: Address;

        if to.is_none() {
            source_account = env.invoker();
        } else {
            source_account = Address::Account(to.unwrap());
        }

        env.storage().set(env.invoker(), source_account);
    }
}
@kalepail kalepail added the bug Something isn't working label Dec 30, 2022
@paulbellamy
Copy link
Contributor

I'd expect we need a strval converter for null -> Option::None to parse it in a way the host will accept.

@paulbellamy paulbellamy changed the title Cannot seem to pass None via the CLI soroban-cli: Cannot seem to pass None via the CLI Jan 4, 2023
@paulbellamy
Copy link
Contributor

@kalepail
Copy link
Contributor Author

kalepail commented Jan 4, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working soroban-scrum
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants