'Solana metaplex-program-library thread 'main' panicked at 'Code not parseable: Error("space must be provided with init")'
I am trying to compile and set up a local Solana node with Metaplex installed for local development. Right now when compiling with anchor build - I've been getting the following error:
To deploy this program:
$ solana program deploy /sol/metaplex/program-library/target/deploy/mpl_fixed_price_sale.so
The program address will default to this keypair (override with --program-id):
/sol/metaplex/program-library/target/deploy/mpl_fixed_price_sale-keypair.json
thread 'main' panicked at 'Code not parseable: Error("space must be provided with init")', lang/syn/src/idl/file.rs:360:58
stack backtrace:
0: rust_begin_unwind
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/panicking.rs:143:14
2: core::result::unwrap_failed
at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/core/src/result.rs:1749:5
3: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
4: anchor_syn::idl::file::parse_account_derives
5: anchor_syn::idl::file::parse
6: anchor_cli::extract_idl
7: anchor_cli::build_cwd
8: anchor_cli::build_all
9: anchor_cli::build
10: anchor_cli::entry
11: anchor::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
It appears to originate in: fixed-price-sale/program/src/lib.rs inside pub struct Buy the following lines:
pub struct Buy<'info> {
...
#[account(init_if_needed, seeds=[HISTORY_PREFIX.as_bytes(), user_wallet.key().as_ref(), market.key().as_ref()], bump, payer=user_wallet)]
trade_history: Box<Account<'info, TradeHistory>>,
...
}
When I comment these two lines out and comment out an entire fixed-price-sale/program/src/processor/buy.rs - it compiles with some warnings, but clearly there is now functionality missing. What is missing here?
Solution 1:[1]
Looks like a bug. The space parameter is missing.
Need to change:
...
#[account(
init_if_needed,
seeds=[
HISTORY_PREFIX.as_bytes(),
user_wallet.key().as_ref(),
market.key().as_ref()
],
bump,
payer=user_wallet
)]
trade_history: Box<Account<'info, TradeHistory>>,
...
to this:
...
#[account(
init_if_needed,
space=TradeHistory::LEN, // <-------------- Added this line
seeds=[
HISTORY_PREFIX.as_bytes(),
user_wallet.key().as_ref(),
market.key().as_ref()
],
bump,
payer=user_wallet
)]
trade_history: Box<Account<'info, TradeHistory>>,
...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dmitry R |
