Skip to content

Commit

Permalink
refactor(api) merge test programs (#1670)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zewasik authored Dec 10, 2024
1 parent dccbd65 commit 19b56ca
Show file tree
Hide file tree
Showing 33 changed files with 385 additions and 376 deletions.
44 changes: 6 additions & 38 deletions api/programs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions api/programs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
[workspace]
resolver = "2"

members = ["test-gas", "test-waitlist", "test-meta", "empty"]

[profile.release]
lto = true
opt-level = 's'
members = ["test-meta", 'test']

[workspace.dependencies]
gmeta = { git = "https://github.com/gear-tech/gear.git" }
gstd = { git = "https://github.com/gear-tech/gear.git" }
scale-info = { version = "2.11.0", default-features = false, features = [
"derive",
Expand All @@ -19,5 +16,3 @@ codec = { package = "parity-scale-codec", version = "3.6.9", default-features =
gear-wasm-builder = { git = "https://github.com/gear-tech/gear.git", features = [
"metawasm",
] }
gmeta = { git = "https://github.com/gear-tech/gear.git" }
primitive-types = { version = "0.12.2", default-features = false }
8 changes: 0 additions & 8 deletions api/programs/empty/src/lib.rs

This file was deleted.

15 changes: 0 additions & 15 deletions api/programs/test-gas/Cargo.toml

This file was deleted.

5 changes: 0 additions & 5 deletions api/programs/test-gas/build.rs

This file was deleted.

10 changes: 0 additions & 10 deletions api/programs/test-gas/io/Cargo.toml

This file was deleted.

25 changes: 0 additions & 25 deletions api/programs/test-gas/io/src/lib.rs

This file was deleted.

30 changes: 0 additions & 30 deletions api/programs/test-gas/src/lib.rs

This file was deleted.

30 changes: 0 additions & 30 deletions api/programs/test-gas/src/wasm.rs

This file was deleted.

7 changes: 2 additions & 5 deletions api/programs/test-meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ name = "test-meta"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
gstd.workspace = true
scale-info.workspace = true
codec.workspace = true
test-meta-io = { path = "io" }
test-io = { path = "io" }
test-meta-state-v1 = { path = "state-v1", default-features = false, optional = true }
test-meta-state-v2 = { path = "state-v2", default-features = false, optional = true }

[build-dependencies]
test-meta-io = { path = "io" }
gear-wasm-builder.workspace = true
test-io = { path = "io" }

[features]
default = ["std"]
Expand Down
20 changes: 1 addition & 19 deletions api/programs/test-meta/build.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
// This file is part of Gear.

// Copyright (C) 2021-2022 Gear Technologies Inc.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use test_meta_io::ProgramMetadata;
use test_io::ProgramMetadata;

fn main() {
gear_wasm_builder::build_with_metadata::<ProgramMetadata>();
Expand Down
8 changes: 4 additions & 4 deletions api/programs/test-meta/io/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "test-meta-io"
name = "test-io"
version = "0.1.0"
edition = "2021"

[dependencies]
primitive-types = { version = "0.12.2", default-features = false }
gmeta = { workspace = true, features = ["codegen"] }
gstd.workspace = true
scale-info.workspace = true
codec.workspace = true
gstd.workspace = true
gmeta.workspace = true
primitive-types.workspace = true
18 changes: 14 additions & 4 deletions api/programs/test-meta/io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

extern crate alloc;

use alloc::string::String;
use alloc::{string::String, vec::Vec};
use codec::{Decode, Encode};
use gmeta::{InOut, Metadata};
use gstd::{
Expand All @@ -18,8 +18,8 @@ pub struct ProgramMetadata;
impl Metadata for ProgramMetadata {
type Init = InOut<BTreeSet<u8>, BTreeMap<String, u8>>;
type Handle = InOut<Action, String>;
type Reply = ReplyType;
type Others = InOut<(), ()>;
type Reply = String;
type Signal = H256;
type State = InOut<Option<u32>, Vec<Wallet>>;
}
Expand All @@ -40,8 +40,7 @@ pub enum Action {
Two(Vec<X>),
Three { field1: Result<(u8, String), i32> },
Four(SomeStruct<u128, u8>),
Five(SomeStruct<String, X>),
Six(ActorId, EmptyStruct),
Input(String),
}

#[derive(TypeInfo, Encode, Decode, Clone)]
Expand Down Expand Up @@ -72,3 +71,14 @@ pub enum State {
DappMeta(String),
Data(Vec<Wallet>),
}

#[derive(TypeInfo, Decode, Encode)]
pub struct InputStruct {
pub input: String,
}

#[derive(TypeInfo, Decode, Encode)]
pub enum ReplyType {
TextReply(String),
StructReply(InputStruct),
}
2 changes: 1 addition & 1 deletion api/programs/test-meta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#![no_std]

// Reexport of types
pub use test_meta_io::*;
pub use test_io::*;

// For wasm compilation
#[cfg(not(feature = "std"))]
Expand Down
Loading

0 comments on commit 19b56ca

Please sign in to comment.