-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move demo app to core as temp solution
- Loading branch information
1 parent
da43567
commit 7c056e9
Showing
6 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "blockchain" | ||
description = "Calimero increment/decrement application" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
calimero-sdk = { path = "../../crates/sdk" } | ||
calimero-storage = { path = "../../crates/storage" } | ||
|
||
[profile.app-release] | ||
inherits = "release" | ||
codegen-units = 1 | ||
opt-level = "z" | ||
lto = true | ||
debug = false | ||
panic = "abort" | ||
overflow-checks = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
cd "$(dirname $0)" | ||
|
||
TARGET="${CARGO_TARGET_DIR:-../../target}" | ||
|
||
rustup target add wasm32-unknown-unknown | ||
|
||
cargo build --target wasm32-unknown-unknown --profile app-release | ||
|
||
mkdir -p res | ||
|
||
name=$(cargo read-manifest | jq -r '.name') | ||
sanitized_name=$(echo $name | tr '-' '_') | ||
|
||
cp "$TARGET/wasm32-unknown-unknown/app-release/$sanitized_name.wasm" ./res/ | ||
|
||
if command -v wasm-opt >/dev/null; then | ||
wasm-opt -Oz ./res/$sanitized_name.wasm -o ./res/$sanitized_name.wasm | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use calimero_sdk::app; | ||
use calimero_sdk::borsh::{BorshDeserialize, BorshSerialize}; | ||
use calimero_sdk::env::{self}; | ||
use calimero_sdk::serde::{Deserialize, Serialize}; | ||
use calimero_storage::entities::Element; | ||
use calimero_storage::AtomicUnit; | ||
|
||
#[derive(Default, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] | ||
#[borsh(crate = "calimero_sdk::borsh")] | ||
#[serde(crate = "calimero_sdk::serde")] | ||
pub struct CreateProposalRequest { | ||
proposal_id: String, | ||
author: Option<String>, | ||
// status: ProposalStatus, | ||
} | ||
|
||
#[app::event] | ||
pub enum Event { | ||
ProposalCreated(), | ||
} | ||
|
||
#[app::state(emits = Event)] | ||
#[derive(AtomicUnit, Clone, Debug, PartialEq, PartialOrd)] | ||
#[root] | ||
#[type_id(1)] | ||
pub struct AppState { | ||
count: u32, | ||
#[storage] | ||
storage: Element, | ||
} | ||
|
||
#[app::logic] | ||
impl AppState { | ||
#[app::init] | ||
pub fn init() -> AppState { | ||
AppState { | ||
count: 0, | ||
storage: Element::root(), | ||
} | ||
} | ||
|
||
pub fn create_new_proposal(&mut self, _request: CreateProposalRequest) -> bool { | ||
// let proposal_id = Blockchain::create_proposal("transfer", "xabi.near", 999999); | ||
// let enhanced_proposal = Proposal { | ||
// proposal_id, | ||
// title, | ||
// description | ||
// }; | ||
// storage.save(enhanced_proposal) | ||
|
||
//?? | ||
|
||
DraftProposal::new() | ||
.transfer(AccountId("xabi.near".to_string()), 999999) | ||
.send(); | ||
|
||
true | ||
} | ||
|
||
pub fn approve_proposal(&mut self, proposal_id: String) -> bool { | ||
// let proposal = storage.get_proposal(proposal_id); | ||
// let vote = Vote { | ||
// proposal_id, | ||
// voter_id: "xabi.near", | ||
// vote_type: VoteType::Accept(), | ||
// voted_at: 1234567890, | ||
// }; | ||
// storage.save(vote) | ||
true | ||
} | ||
|
||
// Messages (discussion) | ||
// pub fn get_proposal_messages(proposal_id: String) -> Vec<Message> { | ||
// vec![] | ||
// } | ||
// pub fn send_message(proposal_id: String, message: Message) -> bool { | ||
// true | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters