Skip to content

ContractRef objects don't implement SpreadAllocate trait. #1149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
drewstone opened this issue Feb 27, 2022 · 4 comments
Closed

ContractRef objects don't implement SpreadAllocate trait. #1149

drewstone opened this issue Feb 27, 2022 · 4 comments
Assignees
Labels
B-enhancement New feature or request C-bug Something isn't working P-low Low priority issue.

Comments

@drewstone
Copy link

Overview

I'm trying to initialize a contract that holds both Mappings and ContractRefs to other contracts. It does not seem that contract references by default implement the necessary trait and as such I cannot compile these contracts. Is there a recommended method for init'ing contracts with these items side by side?

@HCastano
Copy link
Contributor

HCastano commented Mar 1, 2022

I saw that you and @xgreenx had some discussions about this on Element. Do you mind re-posting any important bits from there here?

Can you also post a link to the contracts so that we can reproduce this.

@HCastano HCastano added B-enhancement New feature or request C-bug Something isn't working labels Mar 1, 2022
@xgreenx
Copy link
Collaborator

xgreenx commented Mar 1, 2022

The problem is that ContractRef and CallBuilder generated by codegen doesn't implement SpreadAllocate.

As a workaround, the user can implement SpreadAllocate manually current contract or the user can use AccountId instead of ContractRef(under the hood it is account id).

Also if the user has the source of the Contract, he can implement SpreadAllocate manually for ContractRef.

impl SpreadAllocate for ContractRef {
    fn allocate_spread(_ptr: &mut ink_primitives::KeyPtr) -> Self {
        FromAccountId::from_account_id([0; 32].into())
    }
}

@HCastano HCastano self-assigned this Mar 2, 2022
@HCastano
Copy link
Contributor

HCastano commented Apr 6, 2022

Marking this as low priority since it'll become obsolete with #1134.

If anybody can't get their contract compiling by manually implementing SpreadAllocate let us know here.

@HCastano HCastano added the P-low Low priority issue. label Apr 6, 2022
@cmichi
Copy link
Collaborator

cmichi commented Feb 17, 2023

Closing, as we removed anything SpreadLayout for ink! 4.0.

@cmichi cmichi closed this as completed Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-enhancement New feature or request C-bug Something isn't working P-low Low priority issue.
Projects
None yet
Development

No branches or pull requests

4 participants