Expected an identifier

Hey guys, I have a storage map that looks like this.

total_trader_order_balance: StorageMap<(Address, AssetId), (u64, u64)> = StorageMap {}

I’m trying to take 2 variables from this map and make them mutable, but I get the error Expected an identifier., how do I fix it?

let mut (total_trader_order_base, total_trader_order_quote) = storage.total_trader_order_balance.get((trader, base_token)).try_read().unwrap_or((0, 0));
 |         let mut (total_trader_order_base, total_trader_order_quote) = storage.total_trader_order_balance.get((trader, base_token)).try_read().unwrap_or((0, 0));
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

My toolchain

Default host: aarch64-apple-darwin
fuelup home: /Users/alexey/.fuelup

installed toolchains
--------------------
beta-3-aarch64-apple-darwin
beta-4-rc.2-aarch64-apple-darwin
latest-aarch64-apple-darwin (default)
beta-4-aarch64-apple-darwin
hotfix
latest-2023-09-25-aarch64-apple-darwin
my-custom-toolchain

active toolchain
-----------------
latest-aarch64-apple-darwin (default)
  forc : 0.46.0
    - forc-client
      - forc-deploy : 0.46.0
      - forc-run : 0.46.0
    - forc-doc : 0.46.0
    - forc-explore : 0.28.1
    - forc-fmt : 0.46.0
    - forc-index : 0.21.1
    - forc-lsp : 0.46.0
    - forc-tx : 0.46.0
    - forc-wallet : 0.3.0
  fuel-core : 0.20.7
  fuel-core-keygen : Error getting version string
  fuel-indexer : 0.21.1

fuels versions
---------------
forc : 0.45
forc-wallet : 0.45

P.S.
It works well if I do smth like that, but tell me if it’s possible to do it in one line

Hey @fuel your syntax is slightly wrong try this

contract;

use std::{
    hash::Hash,
    constants::BASE_ASSET_ID    
};

abi MyContract {
    #[storage(read)]
    fn test_function();
}

storage {
    total_trader_order_balance: StorageMap<(Address, AssetId), (u64, u64)> = StorageMap {}
}

impl MyContract for Contract {
    #[storage(read)]
    fn test_function() {
        let trader = Address::from(0x0000000000000000000000000000000000000000000000000000000000000000);

        let mut current_order_balance = storage.total_trader_order_balance.get((trader, BASE_ASSET_ID)).try_read().unwrap_or((0, 0));
        log(current_order_balance.0); // first value
        log(current_order_balance.1); // second value
        // log(current_order_balance.2); // out of bounds
    }
}

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.