Skip to content

Commit

Permalink
[move] Add example of user code organized into multiple packages (Mys…
Browse files Browse the repository at this point in the history
…tenLabs#5676)

* [move] Add example of user code organized into multiple packages

* Addressed review comments

* Added copyright headers
  • Loading branch information
awelc authored Nov 1, 2022
1 parent 26082a5 commit fd95369
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sui_programmability/examples/multi_package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
An example of how to structure your code to include another user-level package as a dependency.

Make sure that the dependency name (in this example DepPackage in main_package/Move.toml file's
`[dependencies]` section) is the same as the name of the package (in dep_package/Move.toml file's
`[package]` section).
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "DepPackage"
version = "0.0.1"

[dependencies]
Sui = { local = "../../../../crates/sui-framework" }

[addresses]
dep_package = "0x0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

module dep_package::dep_module {

public fun foo(): u64 {
42
}

}
10 changes: 10 additions & 0 deletions sui_programmability/examples/multi_package/main_package/Move.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "MainPackage"
version = "0.0.1"

[dependencies]
Sui = { local = "../../../../crates/sui-framework" }
DepPackage = { local = "../dep_package" }

[addresses]
main_package = "0x0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

module main_package::main_module {
use dep_package::dep_module;

fun foo(): u64 {
dep_module::foo()
}

}

0 comments on commit fd95369

Please sign in to comment.