solana-labs / solana-program-library

A collection of Solana programs maintained by Solana Labs
https://solanalabs.com
Apache License 2.0
3.5k stars 2.04k forks source link

invalid type: string "0", expected f64 #1341

Closed secretshardul closed 3 years ago

secretshardul commented 3 years ago

Getting this error when checking token balance using CLI.

Problematic commands

spl-token supply A8eYXMXcKctN9H6nwsFPDjsAvWq4hX8DywmaGsUPFRP4
spl-token balance AsmeE7T3MAVwsgytma4jtSbctYoexEooJj2a3my9ezc5
spl-token accounts

First and second commands throw this error

invalid type: string "0", expected f64

The third command throws

Account                                      Token                                        Balance
-------------------------------------------------------------------------------------------------
AsmeE7T3MAVwsgytma4jtSbctYoexEooJj2a3my9ezc5 Account parse failure: invalid type: string "0", expected f64

Error remains even after minting tokens.

Versions:

Environment: Intel MacOS Catalina Terminal: zsh

ysavchenko commented 3 years ago

Same thing here. Also when attempting to reinstall spl-token-cli I get build errors.

cargo install spl-token-cli

error[E0308]: mismatched types
   --> /Users/ysavchenko/.cargo/registry/src/github.com-1ecc6299db9ec823/spl-token-cli-2.0.6/src/main.rs:435:41
    |
435 |     let ui_amount = ui_amount.unwrap_or(sender_balance);
    |                                         ^^^^^^^^^^^^^^ expected `f64`, found struct `std::string::String`

error[E0308]: mismatched types
   --> /Users/ysavchenko/.cargo/registry/src/github.com-1ecc6299db9ec823/spl-token-cli-2.0.6/src/main.rs:441:20
    |
441 |     if ui_amount > sender_balance {
    |                    ^^^^^^^^^^^^^^ expected `f64`, found struct `std::string::String`

error[E0277]: can't compare `std::string::String` with `{float}`
   --> /Users/ysavchenko/.cargo/registry/src/github.com-1ecc6299db9ec823/spl-token-cli-2.0.6/src/main.rs:730:79
    |
730 |         if !source_account.is_native && source_account.token_amount.ui_amount > 0.0 {
    |                                                                               ^ no implementation for `std::string::String < {float}` and `std::string::String > {float}`
    |
    = help: the trait `PartialOrd<{float}>` is not implemented for `std::string::String`

error[E0308]: mismatched types
   --> /Users/ysavchenko/.cargo/registry/src/github.com-1ecc6299db9ec823/spl-token-cli-2.0.6/src/main.rs:880:33
    |
880 | ...                   ui_token_account.token_amount.ui_amount,
    |error[E0308]: mismatched types
   --> /Users/ysavchenko/.cargo/registry/src/github.com-1ecc6299db9ec823/spl-token-cli-2.0.6/src/main.rs:435:41
    |
435 |     let ui_amount = ui_amount.unwrap_or(sender_balance);
    |                                         ^^^^^^^^^^^^^^ expected `f64`, found struct `std::string::String`

error[E0308]: mismatched types
   --> /Users/ysavchenko/.cargo/registry/src/github.com-1ecc6299db9ec823/spl-token-cli-2.0.6/src/main.rs:441:20
    |
441 |     if ui_amount > sender_balance {
    |                    ^^^^^^^^^^^^^^ expected `f64`, found struct `std::string::String`

error[E0277]: can't compare `std::string::String` with `{float}`
   --> /Users/ysavchenko/.cargo/registry/src/github.com-1ecc6299db9ec823/spl-token-cli-2.0.6/src/main.rs:730:79
    |
730 |         if !source_account.is_native && source_account.token_amount.ui_amount > 0.0 {
    |                                                                               ^ no implementation for `std::string::String < {float}` and `std::string::String > {float}`
    |
    = help: the trait `PartialOrd<{float}>` is not implemented for `std::string::String`

error[E0308]: mismatched types
   --> /Users/ysavchenko/.cargo/registry/src/github.com-1ecc6299db9ec823/spl-token-cli-2.0.6/src/main.rs:880:33
    |
880 | ...                   ui_token_account.token_amount.ui_amount,
    |
ryoqun commented 3 years ago

@secretshardul @ysavchenko Thanks for quick reporting. it seems that we released v1.5.9 a bit before.

ryoqun commented 3 years ago

it seems that this caused by https://github.com/solana-labs/solana/pull/15447

secretshardul commented 3 years ago

Is there any temporary fix? I downgraded to Solana 1.3.22, but then it showed that spl-token-cli is not installed. Tried reinstalling it but now it shows the error posted by @ysavchenko

ryoqun commented 3 years ago

we're now fixing this: https://github.com/solana-labs/solana/pull/15535

ryoqun commented 3 years ago

@secretshardul @ysavchenko Hi thanks for quick reporting; we believe this is now solved in full. Please report if you're still seeing any problems. :)