From fcf342685d7f0f005d207896e9ed41c5d309212b Mon Sep 17 00:00:00 2001 From: bal7hazar Date: Wed, 8 Nov 2023 19:00:15 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 97 ------------------- .github/workflows/examples.yml | 58 +++++++++++ .github/workflows/origami.yml | 42 ++++++++ Scarb.lock | 40 +------- Scarb.toml | 13 ++- crates/algebra/Scarb.lock | 14 --- crates/algebra/Scarb.toml | 8 -- crates/algebra/src/lib.cairo | 3 - crates/defi/Scarb.lock | 27 ------ crates/defi/Scarb.toml | 8 -- crates/defi/src/lib.cairo | 6 -- crates/random/Scarb.toml | 8 -- crates/random/src/lib.cairo | 2 - crates/security/Scarb.toml | 8 -- crates/security/src/lib.cairo | 1 - {crates/algebra => examples}/.gitignore | 0 examples/Scarb.lock | 43 ++++++++ examples/Scarb.toml | 13 +++ examples/market/.gitignore | 1 - examples/projectile/Scarb.toml | 2 +- examples/projectile/src/lib.cairo | 2 +- presets/.gitignore | 1 - .../algebra/src => src/algebra}/matrix.cairo | 0 .../algebra/src => src/algebra}/vec2.cairo | 0 .../algebra/src => src/algebra}/vector.cairo | 0 {crates => src}/defi/README.md | 0 .../defi/src => src/defi}/auction/gda.cairo | 0 .../src => src/defi}/auction/helpers.cairo | 0 .../defi/src => src/defi}/auction/vrgda.cairo | 0 src/lib.cairo | 22 +++++ {crates/random/src => src/random}/deck.cairo | 0 {crates/random/src => src/random}/dice.cairo | 0 .../src => src/security}/commitment.cairo | 0 {crates/defi => src/tokens}/.gitignore | 0 {presets => src/tokens}/Scarb.lock | 0 {presets => src/tokens}/Scarb.toml | 0 .../tokens}/src/erc1155/erc1155.cairo | 0 .../tokens}/src/erc1155/erc1155/erc1155.cairo | 0 .../src/erc1155/erc1155/interface.cairo | 0 .../tokens}/src/erc1155/erc1155/models.cairo | 0 .../tokens}/src/erc1155/tests.cairo | 0 {presets => src/tokens}/src/erc20/erc20.cairo | 0 .../tokens}/src/erc20/models.cairo | 0 {presets => src/tokens}/src/erc20/tests.cairo | 0 .../tokens}/src/erc721/erc721.cairo | 0 .../tokens}/src/erc721/models.cairo | 0 .../tokens}/src/erc721/tests.cairo | 0 {presets => src/tokens}/src/lib.cairo | 0 .../tokens}/src/tests/constants.cairo | 0 .../tokens}/src/tests/test_erc1155.cairo | 0 .../tokens}/src/tests/test_erc721.cairo | 0 {presets => src/tokens}/src/tests/utils.cairo | 0 52 files changed, 188 insertions(+), 231 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/examples.yml create mode 100644 .github/workflows/origami.yml delete mode 100644 crates/algebra/Scarb.lock delete mode 100644 crates/algebra/Scarb.toml delete mode 100644 crates/algebra/src/lib.cairo delete mode 100644 crates/defi/Scarb.lock delete mode 100644 crates/defi/Scarb.toml delete mode 100644 crates/defi/src/lib.cairo delete mode 100644 crates/random/Scarb.toml delete mode 100644 crates/random/src/lib.cairo delete mode 100644 crates/security/Scarb.toml delete mode 100644 crates/security/src/lib.cairo rename {crates/algebra => examples}/.gitignore (100%) create mode 100644 examples/Scarb.lock create mode 100644 examples/Scarb.toml delete mode 100644 examples/market/.gitignore delete mode 100644 presets/.gitignore rename {crates/algebra/src => src/algebra}/matrix.cairo (100%) rename {crates/algebra/src => src/algebra}/vec2.cairo (100%) rename {crates/algebra/src => src/algebra}/vector.cairo (100%) rename {crates => src}/defi/README.md (100%) rename {crates/defi/src => src/defi}/auction/gda.cairo (100%) rename {crates/defi/src => src/defi}/auction/helpers.cairo (100%) rename {crates/defi/src => src/defi}/auction/vrgda.cairo (100%) create mode 100644 src/lib.cairo rename {crates/random/src => src/random}/deck.cairo (100%) rename {crates/random/src => src/random}/dice.cairo (100%) rename {crates/security/src => src/security}/commitment.cairo (100%) rename {crates/defi => src/tokens}/.gitignore (100%) rename {presets => src/tokens}/Scarb.lock (100%) rename {presets => src/tokens}/Scarb.toml (100%) rename {presets => src/tokens}/src/erc1155/erc1155.cairo (100%) rename {presets => src/tokens}/src/erc1155/erc1155/erc1155.cairo (100%) rename {presets => src/tokens}/src/erc1155/erc1155/interface.cairo (100%) rename {presets => src/tokens}/src/erc1155/erc1155/models.cairo (100%) rename {presets => src/tokens}/src/erc1155/tests.cairo (100%) rename {presets => src/tokens}/src/erc20/erc20.cairo (100%) rename {presets => src/tokens}/src/erc20/models.cairo (100%) rename {presets => src/tokens}/src/erc20/tests.cairo (100%) rename {presets => src/tokens}/src/erc721/erc721.cairo (100%) rename {presets => src/tokens}/src/erc721/models.cairo (100%) rename {presets => src/tokens}/src/erc721/tests.cairo (100%) rename {presets => src/tokens}/src/lib.cairo (100%) rename {presets => src/tokens}/src/tests/constants.cairo (100%) rename {presets => src/tokens}/src/tests/test_erc1155.cairo (100%) rename {presets => src/tokens}/src/tests/test_erc721.cairo (100%) rename {presets => src/tokens}/src/tests/utils.cairo (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 4227c071..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,97 +0,0 @@ -name: Origami CI - -on: [push, pull_request] - -env: - DOJO_VERSION: v0.3.4 - SCARB_VERSION: v2.3.1 - -jobs: - check: - runs-on: ubuntu-latest - name: Check format - steps: - - uses: actions/checkout@v4 - - uses: software-mansion/setup-scarb@v1 - with: - scarb-version: ${{ env.SCARB_VERSION }} - - name: Format - run: scarb fmt --check - shell: bash - - build: - needs: check - runs-on: ubuntu-latest - name: Build package - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - name: Build - run: sozo build - shell: bash - - algebra: - needs: [check, build] - runs-on: ubuntu-latest - name: Test algebra crate - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - name: Test - run: sozo test -f algebra - shell: bash - - defi: - needs: [check, build] - runs-on: ubuntu-latest - name: Test defi crate - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - name: Test - run: sozo test -f defi - shell: bash - - random: - needs: [check, build] - runs-on: ubuntu-latest - name: Test random crate - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - name: Test - run: sozo test -f random - shell: bash - - security: - needs: [check, build] - runs-on: ubuntu-latest - name: Test security crate - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - name: Test - run: sozo test -f security - shell: bash - - market: - needs: [check, build] - runs-on: ubuntu-latest - name: Test market example - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - name: Test - run: sozo test -f market - shell: bash - - projectile: - needs: [check, build] - runs-on: ubuntu-latest - name: Test projectile example - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/setup - - name: Test - run: sozo test -f projectile - shell: bash \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml new file mode 100644 index 00000000..01f328bc --- /dev/null +++ b/.github/workflows/examples.yml @@ -0,0 +1,58 @@ +name: Origami Examples CI + +on: [push, pull_request] + +env: + DOJO_VERSION: v0.3.4 + SCARB_VERSION: v2.3.1 + WORKING_DIRECTORY: examples + +jobs: + check: + runs-on: ubuntu-latest + name: Check format + steps: + - uses: actions/checkout@v4 + - uses: software-mansion/setup-scarb@v1 + with: + scarb-version: ${{ env.SCARB_VERSION }} + - name: Format + working-directory: ${{ env.WORKING_DIRECTORY }} + run: scarb fmt --check + shell: bash + + build: + needs: check + runs-on: ubuntu-latest + name: Build package + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - name: Build + working-directory: ${{ env.WORKING_DIRECTORY }} + run: sozo build + shell: bash + + market: + needs: [check, build] + runs-on: ubuntu-latest + name: Test market + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - name: Test + working-directory: ${{ env.WORKING_DIRECTORY }} + run: sozo test -f market + shell: bash + + projectile: + needs: [check, build] + runs-on: ubuntu-latest + name: Test projectile + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - name: Test + working-directory: ${{ env.WORKING_DIRECTORY }} + run: sozo test -f projectile + shell: bash \ No newline at end of file diff --git a/.github/workflows/origami.yml b/.github/workflows/origami.yml new file mode 100644 index 00000000..6fd0beab --- /dev/null +++ b/.github/workflows/origami.yml @@ -0,0 +1,42 @@ +name: Origami CI + +on: [push, pull_request] + +env: + DOJO_VERSION: v0.3.4 + SCARB_VERSION: v2.3.1 + +jobs: + check: + runs-on: ubuntu-latest + name: Check format + steps: + - uses: actions/checkout@v4 + - uses: software-mansion/setup-scarb@v1 + with: + scarb-version: ${{ env.SCARB_VERSION }} + - name: Format + run: scarb fmt --check + shell: bash + + build: + needs: check + runs-on: ubuntu-latest + name: Build package + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - name: Build + run: sozo build + shell: bash + + origami: + needs: [check, build] + runs-on: ubuntu-latest + name: Test crates + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/setup + - name: Test + run: sozo test + shell: bash \ No newline at end of file diff --git a/Scarb.lock b/Scarb.lock index 052220f8..626ac004 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -1,29 +1,15 @@ # Code generated by scarb DO NOT EDIT. version = 1 -[[package]] -name = "algebra" -version = "0.0.0" -dependencies = [ - "cubit", -] - [[package]] name = "cubit" version = "1.2.0" source = "git+https://github.com/influenceth/cubit?rev=b459053#b4590530d5aeae9aabd36740cc2a3d9e6adc5fde" -[[package]] -name = "defi" -version = "0.0.0" -dependencies = [ - "cubit", -] - [[package]] name = "dojo" version = "0.3.4" -source = "git+https://github.com/dojoengine/dojo.git?tag=v0.3.4#a3140d88b08b79c5ff2261c1db81bafe80b5cc91" +source = "git+https://github.com/dojoengine/dojo?tag=v0.3.4#a3140d88b08b79c5ff2261c1db81bafe80b5cc91" dependencies = [ "dojo_plugin", ] @@ -33,31 +19,9 @@ name = "dojo_plugin" version = "0.3.4" [[package]] -name = "market" -version = "0.0.0" -dependencies = [ - "cubit", - "dojo", -] - -[[package]] -name = "projectile" +name = "origami" version = "0.0.0" dependencies = [ - "algebra", "cubit", -] - -[[package]] -name = "random" -version = "0.0.0" -dependencies = [ - "dojo", -] - -[[package]] -name = "security" -version = "0.0.0" -dependencies = [ "dojo", ] diff --git a/Scarb.toml b/Scarb.toml index bdb31d56..c9e3027a 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -1,12 +1,11 @@ -[workspace] +[package] name = "origami" version = "0.0.0" description = "Community-maintained libraries for Cairo" homepage = "https://github.com/dojoengine/origami" -members = [ - "crates/*", - "examples/*", -] -[workspace.dependencies] -dojo = { git = "https://github.com/dojoengine/dojo.git", tag = "v0.3.4" } \ No newline at end of file +[lib] + +[dependencies] +cubit = { git = "https://github.com/influenceth/cubit", rev = "b459053" } +dojo = { git = "https://github.com/dojoengine/dojo", tag = "v0.3.4" } diff --git a/crates/algebra/Scarb.lock b/crates/algebra/Scarb.lock deleted file mode 100644 index 0d969403..00000000 --- a/crates/algebra/Scarb.lock +++ /dev/null @@ -1,14 +0,0 @@ -# Code generated by scarb DO NOT EDIT. -version = 1 - -[[package]] -name = "cubit" -version = "1.2.0" -source = "git+https://github.com/influenceth/cubit?rev=b459053#b4590530d5aeae9aabd36740cc2a3d9e6adc5fde" - -[[package]] -name = "physics" -version = "0.0.0" -dependencies = [ - "cubit", -] diff --git a/crates/algebra/Scarb.toml b/crates/algebra/Scarb.toml deleted file mode 100644 index 084c5744..00000000 --- a/crates/algebra/Scarb.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "algebra" -version = "0.0.0" -description = "Implementations of a algebra library." -homepage = "https://github.com/dojoengine/origami/tree/crates/algebra" - -[dependencies] -cubit = { git = "https://github.com/influenceth/cubit", rev = "b459053" } diff --git a/crates/algebra/src/lib.cairo b/crates/algebra/src/lib.cairo deleted file mode 100644 index 347476c3..00000000 --- a/crates/algebra/src/lib.cairo +++ /dev/null @@ -1,3 +0,0 @@ -mod vec2; -mod vector; -mod matrix; diff --git a/crates/defi/Scarb.lock b/crates/defi/Scarb.lock deleted file mode 100644 index 0267575e..00000000 --- a/crates/defi/Scarb.lock +++ /dev/null @@ -1,27 +0,0 @@ -# Code generated by scarb DO NOT EDIT. -version = 1 - -[[package]] -name = "cubit" -version = "1.2.0" -source = "git+https://github.com/ponderingdemocritus/cubit?rev=9c3bbdf#9c3bbdfee7b165ab06ac8cc7046ce4d4c8866bfc" - -[[package]] -name = "defi" -version = "0.0.0" -dependencies = [ - "cubit", - "dojo", -] - -[[package]] -name = "dojo" -version = "0.3.3" -source = "git+https://github.com/dojoengine/dojo.git?tag=v0.3.3#3c9f109e667ca5d12739e6553fdb8261378f4ecf" -dependencies = [ - "dojo_plugin", -] - -[[package]] -name = "dojo_plugin" -version = "0.3.3" diff --git a/crates/defi/Scarb.toml b/crates/defi/Scarb.toml deleted file mode 100644 index fa9773d6..00000000 --- a/crates/defi/Scarb.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "defi" -version = "0.0.0" -description = "Implementations of defi primitives" -homepage = "https://github.com/dojoengine/origami/tree/crates/defi" - -[dependencies] -cubit = { git = "https://github.com/influenceth/cubit", rev = "b459053" } \ No newline at end of file diff --git a/crates/defi/src/lib.cairo b/crates/defi/src/lib.cairo deleted file mode 100644 index 3cacd2f0..00000000 --- a/crates/defi/src/lib.cairo +++ /dev/null @@ -1,6 +0,0 @@ -mod auction { - mod gda; - mod vrgda; - mod helpers; -} - diff --git a/crates/random/Scarb.toml b/crates/random/Scarb.toml deleted file mode 100644 index 785011c2..00000000 --- a/crates/random/Scarb.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "random" -version = "0.0.0" -description = "A set of random mechanism for games" -homepage = "https://github.com/dojoengine/origami/tree/main/crates/random" - -[dependencies] -dojo.workspace = true \ No newline at end of file diff --git a/crates/random/src/lib.cairo b/crates/random/src/lib.cairo deleted file mode 100644 index 68c584d0..00000000 --- a/crates/random/src/lib.cairo +++ /dev/null @@ -1,2 +0,0 @@ -mod deck; -mod dice; diff --git a/crates/security/Scarb.toml b/crates/security/Scarb.toml deleted file mode 100644 index 9a2dcb51..00000000 --- a/crates/security/Scarb.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "security" -version = "0.0.0" -description = "A set of security patterns for games" -homepage = "https://github.com/dojoengine/origami/tree/main/crates/security" - -[dependencies] -dojo.workspace = true \ No newline at end of file diff --git a/crates/security/src/lib.cairo b/crates/security/src/lib.cairo deleted file mode 100644 index 48ed7d4b..00000000 --- a/crates/security/src/lib.cairo +++ /dev/null @@ -1 +0,0 @@ -mod commitment; diff --git a/crates/algebra/.gitignore b/examples/.gitignore similarity index 100% rename from crates/algebra/.gitignore rename to examples/.gitignore diff --git a/examples/Scarb.lock b/examples/Scarb.lock new file mode 100644 index 00000000..0134c213 --- /dev/null +++ b/examples/Scarb.lock @@ -0,0 +1,43 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "cubit" +version = "1.2.0" +source = "git+https://github.com/influenceth/cubit?rev=b459053#b4590530d5aeae9aabd36740cc2a3d9e6adc5fde" + +[[package]] +name = "dojo" +version = "0.3.4" +source = "git+https://github.com/dojoengine/dojo?tag=v0.3.4#a3140d88b08b79c5ff2261c1db81bafe80b5cc91" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_plugin" +version = "0.3.4" + +[[package]] +name = "market" +version = "0.0.0" +dependencies = [ + "cubit", + "dojo", +] + +[[package]] +name = "origami" +version = "0.0.0" +dependencies = [ + "cubit", + "dojo", +] + +[[package]] +name = "projectile" +version = "0.0.0" +dependencies = [ + "cubit", + "origami", +] diff --git a/examples/Scarb.toml b/examples/Scarb.toml new file mode 100644 index 00000000..a49faf61 --- /dev/null +++ b/examples/Scarb.toml @@ -0,0 +1,13 @@ +[workspace] +name = "origami_examples" +version = "0.0.0" +description = "Community-maintained libraries for Cairo" +homepage = "https://github.com/dojoengine/origami" +members = [ + "market", + "projectile", +] + +[workspace.dependencies] +dojo = { git = "https://github.com/dojoengine/dojo", tag = "v0.3.4" } +origami = { path = "../../origami" } \ No newline at end of file diff --git a/examples/market/.gitignore b/examples/market/.gitignore deleted file mode 100644 index 1de56593..00000000 --- a/examples/market/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target \ No newline at end of file diff --git a/examples/projectile/Scarb.toml b/examples/projectile/Scarb.toml index 8b1d87a7..750a488b 100644 --- a/examples/projectile/Scarb.toml +++ b/examples/projectile/Scarb.toml @@ -6,4 +6,4 @@ homepage = "https://github.com/dojoengine/origami/tree/examples/projectile" [dependencies] cubit = { git = "https://github.com/influenceth/cubit", rev = "b459053" } -algebra = { path = "../../crates/algebra" } \ No newline at end of file +origami.workspace = true \ No newline at end of file diff --git a/examples/projectile/src/lib.cairo b/examples/projectile/src/lib.cairo index 1926d4ef..b6ff75d9 100644 --- a/examples/projectile/src/lib.cairo +++ b/examples/projectile/src/lib.cairo @@ -5,7 +5,7 @@ use cubit::f128::math::trig; // Internal imports -use algebra::vec2::{Vec2, Vec2Trait}; +use origami::algebra::vec2::{Vec2, Vec2Trait}; fn main() -> (usize, Array::, Array::) { // to be inputs for #[view] function diff --git a/presets/.gitignore b/presets/.gitignore deleted file mode 100644 index 1de56593..00000000 --- a/presets/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target \ No newline at end of file diff --git a/crates/algebra/src/matrix.cairo b/src/algebra/matrix.cairo similarity index 100% rename from crates/algebra/src/matrix.cairo rename to src/algebra/matrix.cairo diff --git a/crates/algebra/src/vec2.cairo b/src/algebra/vec2.cairo similarity index 100% rename from crates/algebra/src/vec2.cairo rename to src/algebra/vec2.cairo diff --git a/crates/algebra/src/vector.cairo b/src/algebra/vector.cairo similarity index 100% rename from crates/algebra/src/vector.cairo rename to src/algebra/vector.cairo diff --git a/crates/defi/README.md b/src/defi/README.md similarity index 100% rename from crates/defi/README.md rename to src/defi/README.md diff --git a/crates/defi/src/auction/gda.cairo b/src/defi/auction/gda.cairo similarity index 100% rename from crates/defi/src/auction/gda.cairo rename to src/defi/auction/gda.cairo diff --git a/crates/defi/src/auction/helpers.cairo b/src/defi/auction/helpers.cairo similarity index 100% rename from crates/defi/src/auction/helpers.cairo rename to src/defi/auction/helpers.cairo diff --git a/crates/defi/src/auction/vrgda.cairo b/src/defi/auction/vrgda.cairo similarity index 100% rename from crates/defi/src/auction/vrgda.cairo rename to src/defi/auction/vrgda.cairo diff --git a/src/lib.cairo b/src/lib.cairo new file mode 100644 index 00000000..cd5f5549 --- /dev/null +++ b/src/lib.cairo @@ -0,0 +1,22 @@ +mod algebra { + mod vec2; + mod vector; + mod matrix; +} + +mod defi { + mod auction { + mod gda; + mod vrgda; + mod helpers; + } +} + +mod random { + mod deck; + mod dice; +} + +mod security { + mod commitment; +} \ No newline at end of file diff --git a/crates/random/src/deck.cairo b/src/random/deck.cairo similarity index 100% rename from crates/random/src/deck.cairo rename to src/random/deck.cairo diff --git a/crates/random/src/dice.cairo b/src/random/dice.cairo similarity index 100% rename from crates/random/src/dice.cairo rename to src/random/dice.cairo diff --git a/crates/security/src/commitment.cairo b/src/security/commitment.cairo similarity index 100% rename from crates/security/src/commitment.cairo rename to src/security/commitment.cairo diff --git a/crates/defi/.gitignore b/src/tokens/.gitignore similarity index 100% rename from crates/defi/.gitignore rename to src/tokens/.gitignore diff --git a/presets/Scarb.lock b/src/tokens/Scarb.lock similarity index 100% rename from presets/Scarb.lock rename to src/tokens/Scarb.lock diff --git a/presets/Scarb.toml b/src/tokens/Scarb.toml similarity index 100% rename from presets/Scarb.toml rename to src/tokens/Scarb.toml diff --git a/presets/src/erc1155/erc1155.cairo b/src/tokens/src/erc1155/erc1155.cairo similarity index 100% rename from presets/src/erc1155/erc1155.cairo rename to src/tokens/src/erc1155/erc1155.cairo diff --git a/presets/src/erc1155/erc1155/erc1155.cairo b/src/tokens/src/erc1155/erc1155/erc1155.cairo similarity index 100% rename from presets/src/erc1155/erc1155/erc1155.cairo rename to src/tokens/src/erc1155/erc1155/erc1155.cairo diff --git a/presets/src/erc1155/erc1155/interface.cairo b/src/tokens/src/erc1155/erc1155/interface.cairo similarity index 100% rename from presets/src/erc1155/erc1155/interface.cairo rename to src/tokens/src/erc1155/erc1155/interface.cairo diff --git a/presets/src/erc1155/erc1155/models.cairo b/src/tokens/src/erc1155/erc1155/models.cairo similarity index 100% rename from presets/src/erc1155/erc1155/models.cairo rename to src/tokens/src/erc1155/erc1155/models.cairo diff --git a/presets/src/erc1155/tests.cairo b/src/tokens/src/erc1155/tests.cairo similarity index 100% rename from presets/src/erc1155/tests.cairo rename to src/tokens/src/erc1155/tests.cairo diff --git a/presets/src/erc20/erc20.cairo b/src/tokens/src/erc20/erc20.cairo similarity index 100% rename from presets/src/erc20/erc20.cairo rename to src/tokens/src/erc20/erc20.cairo diff --git a/presets/src/erc20/models.cairo b/src/tokens/src/erc20/models.cairo similarity index 100% rename from presets/src/erc20/models.cairo rename to src/tokens/src/erc20/models.cairo diff --git a/presets/src/erc20/tests.cairo b/src/tokens/src/erc20/tests.cairo similarity index 100% rename from presets/src/erc20/tests.cairo rename to src/tokens/src/erc20/tests.cairo diff --git a/presets/src/erc721/erc721.cairo b/src/tokens/src/erc721/erc721.cairo similarity index 100% rename from presets/src/erc721/erc721.cairo rename to src/tokens/src/erc721/erc721.cairo diff --git a/presets/src/erc721/models.cairo b/src/tokens/src/erc721/models.cairo similarity index 100% rename from presets/src/erc721/models.cairo rename to src/tokens/src/erc721/models.cairo diff --git a/presets/src/erc721/tests.cairo b/src/tokens/src/erc721/tests.cairo similarity index 100% rename from presets/src/erc721/tests.cairo rename to src/tokens/src/erc721/tests.cairo diff --git a/presets/src/lib.cairo b/src/tokens/src/lib.cairo similarity index 100% rename from presets/src/lib.cairo rename to src/tokens/src/lib.cairo diff --git a/presets/src/tests/constants.cairo b/src/tokens/src/tests/constants.cairo similarity index 100% rename from presets/src/tests/constants.cairo rename to src/tokens/src/tests/constants.cairo diff --git a/presets/src/tests/test_erc1155.cairo b/src/tokens/src/tests/test_erc1155.cairo similarity index 100% rename from presets/src/tests/test_erc1155.cairo rename to src/tokens/src/tests/test_erc1155.cairo diff --git a/presets/src/tests/test_erc721.cairo b/src/tokens/src/tests/test_erc721.cairo similarity index 100% rename from presets/src/tests/test_erc721.cairo rename to src/tokens/src/tests/test_erc721.cairo diff --git a/presets/src/tests/utils.cairo b/src/tokens/src/tests/utils.cairo similarity index 100% rename from presets/src/tests/utils.cairo rename to src/tokens/src/tests/utils.cairo From e8355d7d64c7456e17cfe1ec67606127f1529d9c Mon Sep 17 00:00:00 2001 From: bal7hazar Date: Wed, 8 Nov 2023 19:01:34 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=92=84=20Code=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib.cairo | 2 +- src/tokens/src/erc1155/erc1155.cairo | 2 +- src/tokens/src/erc1155/erc1155/erc1155.cairo | 4 +--- src/tokens/src/erc1155/erc1155/models.cairo | 2 +- src/tokens/src/erc721/erc721.cairo | 6 +----- src/tokens/src/erc721/models.cairo | 2 +- src/tokens/src/erc721/tests.cairo | 16 ++++++++-------- src/tokens/src/lib.cairo | 2 +- 8 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/lib.cairo b/src/lib.cairo index cd5f5549..ab74b522 100644 --- a/src/lib.cairo +++ b/src/lib.cairo @@ -19,4 +19,4 @@ mod random { mod security { mod commitment; -} \ No newline at end of file +} diff --git a/src/tokens/src/erc1155/erc1155.cairo b/src/tokens/src/erc1155/erc1155.cairo index af50183e..aeb7f33a 100644 --- a/src/tokens/src/erc1155/erc1155.cairo +++ b/src/tokens/src/erc1155/erc1155.cairo @@ -2,4 +2,4 @@ mod erc1155; mod models; mod interface; -use erc1155::ERC1155; \ No newline at end of file +use erc1155::ERC1155; diff --git a/src/tokens/src/erc1155/erc1155/erc1155.cairo b/src/tokens/src/erc1155/erc1155/erc1155.cairo index 26ba7f23..ff633a30 100644 --- a/src/tokens/src/erc1155/erc1155/erc1155.cairo +++ b/src/tokens/src/erc1155/erc1155/erc1155.cairo @@ -1,8 +1,6 @@ #[starknet::contract] mod ERC1155 { - use dojo_erc::token::erc1155::models::{ - ERC1155Meta, ERC1155OperatorApproval, ERC1155Balance - }; + use dojo_erc::token::erc1155::models::{ERC1155Meta, ERC1155OperatorApproval, ERC1155Balance}; use dojo_erc::token::erc1155::interface; use dojo_erc::token::erc1155::interface::{IERC1155, IERC1155CamelOnly}; use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; diff --git a/src/tokens/src/erc1155/erc1155/models.cairo b/src/tokens/src/erc1155/erc1155/models.cairo index fa021aa9..3e1861e3 100644 --- a/src/tokens/src/erc1155/erc1155/models.cairo +++ b/src/tokens/src/erc1155/erc1155/models.cairo @@ -30,4 +30,4 @@ struct ERC1155Balance { #[key] id: u256, amount: u256 -} \ No newline at end of file +} diff --git a/src/tokens/src/erc721/erc721.cairo b/src/tokens/src/erc721/erc721.cairo index 57f84720..4a181988 100644 --- a/src/tokens/src/erc721/erc721.cairo +++ b/src/tokens/src/erc721/erc721.cairo @@ -27,11 +27,7 @@ mod ERC721 { // Internal imports use presets::erc721::models::{ - ERC721Meta, - ERC721OperatorApproval, - ERC721Owner, - ERC721Balance, - ERC721TokenApproval, + ERC721Meta, ERC721OperatorApproval, ERC721Owner, ERC721Balance, ERC721TokenApproval, }; // Local imports diff --git a/src/tokens/src/erc721/models.cairo b/src/tokens/src/erc721/models.cairo index eec7ec9c..6128b7b3 100644 --- a/src/tokens/src/erc721/models.cairo +++ b/src/tokens/src/erc721/models.cairo @@ -47,4 +47,4 @@ struct ERC721TokenApproval { #[key] token_id: u256, address: ContractAddress, -} \ No newline at end of file +} diff --git a/src/tokens/src/erc721/tests.cairo b/src/tokens/src/erc721/tests.cairo index cdeef6be..778a4814 100644 --- a/src/tokens/src/erc721/tests.cairo +++ b/src/tokens/src/erc721/tests.cairo @@ -469,8 +469,8 @@ fn test_transfer_from_nonexistent() { #[should_panic(expected: ('ERC721: invalid token ID',))] fn test_transferFrom_nonexistent() { //let mut state = STATE(); - let (world, mut state) = STATE(); - ERC721CamelOnlyImpl::transferFrom(ref state, ZERO(), RECIPIENT(), TOKEN_ID); + let (world, mut state) = STATE(); + ERC721CamelOnlyImpl::transferFrom(ref state, ZERO(), RECIPIENT(), TOKEN_ID); } #[test] @@ -489,7 +489,7 @@ fn test_transferFrom_to_zero() { let mut state = setup(); testing::set_caller_address(OWNER()); - ERC721CamelOnlyImpl::transferFrom(ref state, OWNER(), ZERO(), TOKEN_ID); + ERC721CamelOnlyImpl::transferFrom(ref state, OWNER(), ZERO(), TOKEN_ID); } #[test] @@ -518,7 +518,7 @@ fn test_transferFrom_to_owner() { testing::set_caller_address(OWNER()); ERC721CamelOnlyImpl::transferFrom(ref state, OWNER(), OWNER(), TOKEN_ID); - assert_event_transfer( OWNER(), OWNER(), TOKEN_ID); + assert_event_transfer(OWNER(), OWNER(), TOKEN_ID); assert(ERC721Impl::owner_of(@state, TOKEN_ID) == OWNER(), 'Ownership after'); assert(ERC721Impl::balance_of(@state, OWNER()) == 1, 'Balance of owner after'); @@ -551,7 +551,7 @@ fn test_transferFrom_approved() { let token_id = TOKEN_ID; let owner = OWNER(); let recipient = RECIPIENT(); - assert_state_before_transfer(@state,owner, recipient, token_id); + assert_state_before_transfer(@state, owner, recipient, token_id); testing::set_caller_address(owner); ERC721Impl::approve(ref state, OPERATOR(), token_id); @@ -561,7 +561,7 @@ fn test_transferFrom_approved() { ERC721CamelOnlyImpl::transferFrom(ref state, owner, recipient, token_id); assert_event_transfer(owner, recipient, token_id); - assert_state_after_transfer(@state,owner, recipient, token_id); + assert_state_after_transfer(@state, owner, recipient, token_id); } #[test] @@ -593,7 +593,7 @@ fn test_transferFrom_approved_for_all() { let owner = OWNER(); let recipient = RECIPIENT(); - assert_state_before_transfer(@state,owner, recipient, token_id); + assert_state_before_transfer(@state, owner, recipient, token_id); testing::set_caller_address(owner); ERC721Impl::set_approval_for_all(ref state, OPERATOR(), true); @@ -603,7 +603,7 @@ fn test_transferFrom_approved_for_all() { ERC721CamelOnlyImpl::transferFrom(ref state, owner, recipient, token_id); assert_event_transfer(owner, recipient, token_id); - assert_state_after_transfer(@state,owner, recipient, token_id); + assert_state_after_transfer(@state, owner, recipient, token_id); } #[test] diff --git a/src/tokens/src/lib.cairo b/src/tokens/src/lib.cairo index 95234237..c6129437 100644 --- a/src/tokens/src/lib.cairo +++ b/src/tokens/src/lib.cairo @@ -10,4 +10,4 @@ mod erc721 { mod tests { mod constants; mod utils; -} \ No newline at end of file +}