-
Notifications
You must be signed in to change notification settings - Fork 446
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
Some problems about ink-as-dependency
#625
Comments
ink-as-dependency
ink-as-dependency
The crate feature I am happy about you elaborating further what your exact requirements are and why the current system is problematic to you. |
Maybe it is my presentation problem. The design of conditional compilation is actually no problem. But at present, if Such as:
Such |
And this name |
And without |
This is true unfortunately but I do not see any way to go around this problem. ink! targets Rust developers and knowing about conditional compilation and |
What about the linking error? |
Well, that's how it is meant to be used.
Can you tell me what you really need this for? Debugging? Analysis? Have you tried turning of |
I want to inherit other contract just like We know rust have no inheritance, but I want to embed other contract`s storage to reuse them. The data structure that can be reused now is only defined by ink itself. I set If you try to write such examples, you will meet the same problems. |
Any plan or idea about the problem? |
@Robbepop However, rust do not have inheritance, thus, if someone wanna reuse existed contracts, the best way may be combine the existed contract in self contract, for example, as a storage in contract: #[ink(storage)]
pub struct Delegator {
/// Says which of adder or subber is currently in use.
which: Which,
/// The accumulator smart contract.
accumulator: Lazy<Accumulator>,
} and the In this way, is "call other contract libs in compiling time" (I think this description is not accurate) But all in all, what we want is someone may wanna reuse some other contracts code(include storage, or message). Though I know, rust is not solidity, imitating all features in Solidity is not necessary, I think if the ink contract could reuse some other contracts in some way, is a good feature. For nobody wanna implement a ERC20 need to copy the code from other contracts and implement the ERC20 trait...For example, if I just wanna add a |
@yjhmelody I'm gonna close this in favour of #631 and #776 since the original question around the usage of |
Note that #811 actually fixes parts of this issue. |
I find when I
cargo expand
the ink code, add feature ink-as-dependency will only gen#[cfg(feature = "ink-as-dependency")]
version. If I remove the feature, it will only gen#[cfg(not(feature = "ink-as-dependency"))]
version code.I think the
ink-as-dependency
is not clear enough, for example,likedelegator
, it enables featureink-as-dependency
for cross calling contract.But I think
ink-as-dependency
could be two semantics: call other contracts on chain or call other contract libs in compiling time.I try to find the way to do the second thing. I remove other contracts' feature
ink-as-dependency
and code the following:but I got following error:
I feel strange about this. Because I think all original codes are reserved, and
storage
attr impls such as StorageLayout.accumulator: Lazy<Accumulator>
's type is correct, but thenew
function returned a unexpected type ?Is
ink
considering this part of the design?By the way, I think that generating two mods is better than
the condition compiling
.One as an cross calling contract, and one as a combinatorial library.
The text was updated successfully, but these errors were encountered: