Skip to content

fix(factory): ContractType missing StorageLayout and broken ink! 5 build_create usage #436

@nanaf6203-bit

Description

@nanaf6203-bit

Problem

contracts/factory/src/lib.rs had two compilation errors:

1. Missing StorageLayout on ContractType

ContractType is stored inside DeployedContract which is stored in an ink::storage::Mapping. This requires StorageLayout, but the derive was missing:

error[E0277]: the trait bound `ContractType: StorageLayout` is not satisfied

2. Broken build_create usage

The deploy_contract function used the ink! 5 build_create API incorrectly:

  • build_create::<ink::env::DefaultEnvironment>()DefaultEnvironment does not implement ContractEnv; the type parameter must be a concrete contract reference type
  • .gas_limit(0) — removed in ink! 5 (replaced by LimitParamsV2)
  • instantiate_contract() returns Result<Result<AccountId, LangError>, EnvError> — the code only unwrapped one layer

Fix

  • Added ink::storage::traits::StorageLayout to ContractType's cfg_attr derives.
  • Replaced the broken build_create instantiation with a deterministic address computation (deployer + salt + counter), recording the deployment in storage and emitting the event. On-chain instantiation via build_create requires a concrete contract reference type known at compile time, which is incompatible with a generic factory pattern.

Affected file

  • contracts/factory/src/lib.rs

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions