-
Notifications
You must be signed in to change notification settings - Fork 182
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
feat(sozo): support for feature
flags
#2112
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2112 +/- ##
=======================================
Coverage 68.00% 68.00%
=======================================
Files 331 331
Lines 42697 42725 +28
=======================================
+ Hits 29035 29057 +22
- Misses 13662 13668 +6 ☔ View full report in Codecov by Sentry. |
WalkthroughThe changes introduce support for conditional compilation features in the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SozoBuild
participant ScarbBuild
participant Workspace
participant ScarbCompile
User->>SozoBuild: build with --features
SozoBuild->>ScarbBuild: Pass features to scarb build
ScarbBuild->>Workspace: Read workspace
Workspace-->>ScarbBuild: Return workspace info
ScarbBuild->>ScarbCompile: Compile with selected features
ScarbCompile-->>ScarbBuild: Compilation result
SozoBuild-->>User: Build finished
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
(rebased to main after scarb was updated) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (19)
- bin/sozo/src/commands/build.rs (6 hunks)
- bin/sozo/src/commands/test.rs (3 hunks)
- crates/dojo-lang/src/compiler_test.rs (2 hunks)
- crates/dojo-lang/src/scarb_internal/mod.rs (3 hunks)
- crates/dojo-test-utils/build.rs (2 hunks)
- crates/dojo-test-utils/src/compiler.rs (2 hunks)
- crates/dojo-world/src/manifest/manifest_test.rs (1 hunks)
- examples/spawn-and-move/Scarb.toml (2 hunks)
- examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json (1 hunks)
- examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-something-71cfad55.json (1 hunks)
- examples/spawn-and-move/manifests/dev/deployment/manifest.json (3 hunks)
- examples/spawn-and-move/manifests/dev/deployment/manifest.toml (2 hunks)
- examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json (1 hunks)
- examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-something-71cfad55.json (1 hunks)
- examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml (1 hunks)
- examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-something-71cfad55.toml (1 hunks)
- examples/spawn-and-move/src/actions.cairo (4 hunks)
- examples/spawn-and-move/src/lib.cairo (1 hunks)
- examples/spawn-and-move/src/something.cairo (1 hunks)
Files skipped from review due to trivial changes (3)
- examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml
- examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-something-71cfad55.toml
- examples/spawn-and-move/src/lib.cairo
Additional comments not posted (40)
examples/spawn-and-move/src/something.cairo (2)
1-4
: Trait definition looks good.The
ISomething
trait is correctly defined with thedojo::interface
attribute and a single functionsomething
.
6-11
: Module and contract implementation look good.The
something
module correctly uses thedojo::contract
attribute and implements theISomething
trait. Thesomething
function is defined but currently empty.crates/dojo-lang/src/compiler_test.rs (2)
16-17
: Workspace reading and package ID collection look good.The workspace is correctly read, and package IDs are collected before the compilation process.
27-27
: Updated function call looks good.The
compile_workspace
function call correctly includes thepackages
parameter.examples/spawn-and-move/Scarb.toml (1)
18-20
: Feature sections look good.The
[features]
sections are correctly added, allowing conditional compilation based on the specified features.crates/dojo-test-utils/build.rs (2)
56-57
: Workspace reading and package ID collection look good.The workspace is correctly read, and package IDs are collected before the compilation process.
67-67
: Updated function call looks good.The
compile_workspace
function call correctly includes thepackages
parameter.examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-something-71cfad55.json (5)
3-6
: LGTM! Implementation ofContractImpl
The
ContractImpl
correctly implements thedojo::contract::IContract
interface.
8-23
: LGTM! Definition ofByteArray
structThe
ByteArray
struct is correctly defined with appropriate members and types.
26-94
: LGTM! Definition ofIContract
interfaceThe
IContract
interface is correctly defined with appropriate functions, inputs, outputs, and state mutability.
98-110
: LGTM! Implementation ofWorldProviderImpl
and definition ofIWorldDispatcher
structThe
WorldProviderImpl
correctly implements thedojo::world::IWorldProvider
interface, and theIWorldDispatcher
struct is correctly defined with a contract address member.
130-223
: LGTM! Implementations and definitions related todojo_examples::something
moduleThe implementations (
ISomethingImpl
,IDojoInitImpl
, andUpgradableImpl
), interfaces, and events are correctly defined with appropriate functions, inputs, outputs, and state mutability.examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-something-71cfad55.json (5)
3-6
: LGTM! Implementation ofContractImpl
The
ContractImpl
correctly implements thedojo::contract::IContract
interface.
8-23
: LGTM! Definition ofByteArray
structThe
ByteArray
struct is correctly defined with appropriate members and types.
26-94
: LGTM! Definition ofIContract
interfaceThe
IContract
interface is correctly defined with appropriate functions, inputs, outputs, and state mutability.
98-110
: LGTM! Implementation ofWorldProviderImpl
and definition ofIWorldDispatcher
structThe
WorldProviderImpl
correctly implements thedojo::world::IWorldProvider
interface, and theIWorldDispatcher
struct is correctly defined with a contract address member.
130-223
: LGTM! Implementations and definitions related todojo_examples::something
moduleThe implementations (
ISomethingImpl
,IDojoInitImpl
, andUpgradableImpl
), interfaces, and events are correctly defined with appropriate functions, inputs, outputs, and state mutability.bin/sozo/src/commands/test.rs (3)
17-19
: LGTM! ImportingFeaturesSpec
The import statement for
FeaturesSpec
is correctly added.
62-64
: LGTM! Addingfeatures
field toTestArgs
structThe
features
field is correctly added to theTestArgs
struct.
76-90
: LGTM! Updating compilation unit generation logicThe logic for generating compilation units is correctly updated to consider features.
crates/dojo-lang/src/scarb_internal/mod.rs (3)
18-19
: LGTM! ImportingPackageId
The import statement for
PackageId
is correctly added.
86-90
: LGTM! Updatingcompile_workspace
function signatureThe
compile_workspace
function signature is correctly updated to include apackages
parameter.
Line range hint
94-108
:
LGTM! Updating logic to filter compilation units based on packagesThe logic for filtering compilation units is correctly updated to consider the packages.
examples/spawn-and-move/src/actions.cairo (4)
2-3
: Conditional import forContractAddress
looks good.The import statement is correctly conditionally included based on the feature flag
something
.
13-14
: Conditional functioncall_something
inIActions
trait looks good.The function is correctly conditionally included based on the feature flag
something
.
33-34
: Conditional import forISomethingDispatcher
andISomethingDispatcherTrait
looks good.The import statement is correctly conditionally included based on the feature flag
something
.
133-138
: Conditional functioncall_something
inActionsImpl
implementation looks good.The function is correctly conditionally included based on the feature flag
something
and interacts with theISomethingDispatcher
.examples/spawn-and-move/manifests/dev/deployment/manifest.toml (1)
73-86
: New contract entry fordojo_examples-something
looks good.The entry includes relevant metadata and configuration details.
examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json (1)
299-310
: New functioncall_something
indojo_examples::actions::IActions
interface looks good.The function includes the necessary inputs and state mutability.
examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json (1)
299-310
: New functioncall_something
indojo_examples::actions::IActions
interface looks good.The function includes the necessary inputs and state mutability.
crates/dojo-test-utils/src/compiler.rs (2)
77-79
: Verify workspace reading and package ID collection.The added code reads the workspace and collects package IDs before compilation. Ensure this logic correctly integrates with the rest of the compilation process and handles potential errors.
91-91
: Verifycompile_workspace
function call with new parameter.The
compile_workspace
function call now includes thepackages
parameter. Ensure this change is correctly handled within the function and verify its impact on the compilation process.bin/sozo/src/commands/build.rs (3)
44-46
: Verify newfeatures
field inBuildArgs
.The new
features
field is added to theBuildArgs
struct. Ensure this field is correctly defined and integrated, and verify its impact on the build arguments.
87-89
: Verifycompile_workspace
function call withfeatures
parameter.The
compile_workspace
function call now includes thefeatures
parameter. Ensure this change is correctly handled within the function and verify its impact on the compilation process.
160-173
: VerifyDefault
implementation forBuildArgs
.The
Default
implementation forBuildArgs
now includes thefeatures
field. Ensure this implementation correctly initializes the new field and verify its impact on default build arguments.crates/dojo-world/src/manifest/manifest_test.rs (1)
356-359
: Verify updated number of elements incontracts
field.The number of elements in the
contracts
field has been updated from 3 to 4. Ensure this change correctly reflects the updated contract specifications and verify its impact on related tests.examples/spawn-and-move/manifests/dev/deployment/manifest.json (4)
1133-1134
: New Contract Entry Added.A new
DojoContract
entry has been added with the necessary fields and ABI definitions.Ensure that the
address
,class_hash
, andoriginal_class_hash
are correct and match the deployed contract.
1434-1445
: New Function Added to IActions Interface.The function
call_something
has been added to thedojo_examples::actions::IActions
interface with the appropriate input parameter and state mutability.Ensure that the function implementation and usage are correctly integrated.
1991-1992
: New Contract Entry Added.A new
DojoContract
entry has been added with the necessary fields and ABI definitions.Ensure that the
address
,class_hash
, andoriginal_class_hash
are correct and match the deployed contract.
1993-2227
: New Contract Entry Added.A new
DojoContract
entry has been added with the necessary fields and ABI definitions.Ensure that the
address
,class_hash
, andoriginal_class_hash
are correct and match the deployed contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- bin/sozo/tests/test_migrate.rs (1 hunks)
Files skipped from review due to trivial changes (1)
- bin/sozo/tests/test_migrate.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (10)
- bin/sozo/tests/test_migrate.rs (1 hunks)
- examples/spawn-and-move/Scarb.toml (2 hunks)
- examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json (1 hunks)
- examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-something-71cfad55.json (1 hunks)
- examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml (1 hunks)
- examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-something-71cfad55.toml (1 hunks)
- examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json (1 hunks)
- examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-something-71cfad55.json (1 hunks)
- examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml (1 hunks)
- examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-something-71cfad55.toml (1 hunks)
Files skipped from review due to trivial changes (3)
- examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml
- examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-something-71cfad55.toml
- examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-something-71cfad55.toml
Files skipped from review as they are similar to previous changes (4)
- bin/sozo/tests/test_migrate.rs
- examples/spawn-and-move/Scarb.toml
- examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-something-71cfad55.json
- examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml
Additional comments not posted (3)
examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-something-71cfad55.json (1)
130-144
: New implementation and interface forISomething
look correct.The new
ISomethingImpl
andISomething
are consistent with existing structures and naming conventions.examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json (1)
301-310
: New functioncall_something
inIActions
looks correct.The new
call_something
function is consistent with existing structures and naming conventions.examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json (1)
301-310
: New functioncall_something
inIActions
looks correct.The new
call_something
function is consistent with existing structures and naming conventions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Description
fix: #2010
Tests
Added to documentation?
Checklist
scripts/prettier.sh
,scripts/rust_fmt.sh
,scripts/cairo_fmt.sh
)scripts/clippy.sh
,scripts/docs.sh
)Summary by CodeRabbit
New Features
Scarb.toml
.Improvements
Bug Fixes