Contract Add Error on Cis2-MarketPlace
As shown in the picture above this error occurred when I was trying to add my nft on the marketplace with the error code -1 it says that the parameters were wrong in some way but I tried different option yet still came to the conclusion that these parameter formats were correct yet still I received the error telling me that it couldn’t parse the parameters. Please help resolve this issue
AddFunction Code :
#[receive(
contract = "Market-NFT",
name = "add",
parameter = "AddParams",
mutable
)]
fn add<S: HasStateApi>(
ctx: &impl HasReceiveContext,
host: &mut impl HasHost<ContractState<S>, StateApiType = S>,
) -> ContractResult<()> {
let params: AddParams = ctx
.parameter_cursor()
.get()
.map_err(|_e| MarketplaceError::ParseParams)?;
let sender_account_address: AccountAddress = match ctx.sender() {
Address::Account(account_address) => Option::Some(account_address),
Address::Contract(_) => Option::None,
}
.ok_or(MarketplaceError::CalledByAContract)?;
let token_info = TokenInfo {
address: params.nft_contract_address,
id: params.token_id,
};
ensure_supports_cis2(host, ¶ms.nft_contract_address)?;
ensure_is_operator(host, ctx, ¶ms.nft_contract_address)?;
ensure_balance(
host,
params.token_id,
¶ms.nft_contract_address,
sender_account_address,
params.quantity,
)?;
host.state_mut().list_token(
&token_info,
&sender_account_address,
params.price,
params.royalty,
params.quantity,
);
ContractResult::Ok(())
}