-
Notifications
You must be signed in to change notification settings - Fork 71
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
Structure as workspace #328
Comments
This repo actually used to be a large workspace, so I think this is a proposal to return to what we had, and we should look at why we moved away from it, because we may be shuffling different problems and tradeoffs. This is the PR that moved us away from a workspace in the past:
Iirc the background for why the change was made was because people wanted to play with single examples in isolation, and the workspace was confusing for folks new to Rust, seeing all these projects, and then trying to understand why when they copied out a single contract, it no longer worked because of the references back to the parent toml file. The move away from a workspace happened before the
I think we could already use degit today without adding the workspace. There would be no worksplace variables in use, but it would still work. In fact it may be better, because the contract would be downloaded and setup and be using the version of the SDK that the example was coded to. If the user's local tree happens to be on a newer or older SDK for the other contracts, that's actually fine. They probably want to change that, but it's fine, and there maybe incompatibilities between the two. Having seen both approaches play out at different times there are challenges with both approaches, and it's unclear to me that a workspace would be a net-improvement. |
Fixes stellar#328 Undoes stellar#232 Forked from stellar#330 Add top-level `Cargo.toml`, with all project folders as part of this workspace. We now encourage everyone to use Cargo workspaces when building Soroban projects. Let's make it easy to copy-paste these examples into their projects, rather than requiring special tooling (like the old `stellar contract init` behavior) to update the contract's Cargo.toml. Currently, there are two compilation errors when attempting to run tests: ``` error[E0433]: failed to resolve: use of undeclared crate or module `__get_allowance` --> token/src/contract.rs:67:12 | 67 | pub fn get_allowance(e: Env, from: Address, spender: Address) -> Option<AllowanceValue> { | ^^^^^^^^^^^^^ use of undeclared crate or module `__get_allowance` | help: there is a crate or module with a similar name | 67 | pub fn __allowance(e: Env, from: Address, spender: Address) -> Option<AllowanceValue> { | ~~~~~~~~~~~ error[E0223]: ambiguous associated type --> bls_signature/src/lib.rs:78:18 | 78 | agg_sig: Self::Signature, | ^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<IncrementContractArgs as soroban_sdk::testutils::ed25519::Sign>::Signature` ```
Fixes stellar#328 Undoes stellar#232 Forked from stellar#330 Add top-level `Cargo.toml`, with all project folders as part of this workspace. We now encourage everyone to use Cargo workspaces when building Soroban projects. Let's make it easy to copy-paste these examples into their projects, rather than requiring special tooling (like the old `stellar contract init` behavior) to update the contract's Cargo.toml. Currently, there are two compilation errors when attempting to run tests: ``` error[E0433]: failed to resolve: use of undeclared crate or module `__get_allowance` --> token/src/contract.rs:67:12 | 67 | pub fn get_allowance(e: Env, from: Address, spender: Address) -> Option<AllowanceValue> { | ^^^^^^^^^^^^^ use of undeclared crate or module `__get_allowance` | help: there is a crate or module with a similar name | 67 | pub fn __allowance(e: Env, from: Address, spender: Address) -> Option<AllowanceValue> { | ~~~~~~~~~~~ ```
To expand further on this comment I made above, with examples. The following is the experience today without any changes to the soroban-examples repo. In my experience the soroban-examples without a workspace works best with more situations, where folks might be using a workspace or not. See below. Using
|
We shouldn't need any special handling today. Any example contract can be cloned into an existing workspace's |
Thanks, @leighmcculloch! Sorry I missed your comment from October. Glad I didn't get further implementing this in #344. I find that, in my own workflows, I usually want the copied-in directories to be fully-integrated into the workspace. This means that I need to go through a little list of changes every time:
I don't think these steps are straightforward or easily discoverable, to people new to Rust. But you're right: it's also not straightforward if you copy in an example that uses a different sdk version and it starts failing. And point taken, about workspace members being less portable. |
What problem does your feature solve?
We have started encouraging people to set up projects using workspaces. For example,
stellar contract init
allows initializing a project with one of thesesoroban-examples
examples, using the--with-example
option. But the CLI then needs to tweak theCargo.toml
files of the examples to work as part of a workspace.What would you like to see?
If this were already structured as a workspace, we wouldn't need any special handling within commands like
stellar contract init
. In fact, we wouldn't really needstellar contract init
at all. A simple degit would work. For example, if you only wanted one example contract, you could do something like this:This would then allow us to circle back and simplify
stellar contract init
as well, perhaps using degit-rs. This fits in with a larger goal of simplifyingcontract init
:contract init
stellar-cli#1586How to implement
It's really nice that the examples here are all in the top level of the repo. To keep that, we could structure this the way that we structured stellar/soroban-test-examples:
The text was updated successfully, but these errors were encountered: