-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
2,346 additions
and
0 deletions.
There are no files selected for viewing
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,4 @@ | ||
[alias] | ||
wasm = "build --release --target wasm32-unknown-unknown" | ||
unit-test = "test --lib" | ||
schema = "run --example schema" |
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,75 @@ | ||
[package] | ||
name = "ownable-cookie" | ||
version = "0.1.0" | ||
description = "Have a bite" | ||
license = "MIT" | ||
authors = ["colin <[email protected]>"] | ||
edition = "2018" | ||
keywords = ["usable", "eat", "cookie", "NomNom", "Food"] | ||
|
||
exclude = [ | ||
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication. | ||
"contract.wasm", | ||
"hash.txt", | ||
] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
crate-type = ["cdylib", "rlib"] | ||
|
||
[package.metadata.wasm-pack.profile.release] | ||
wasm-opt = false | ||
|
||
[profile.release] | ||
opt-level = 3 | ||
debug = false | ||
rpath = false | ||
lto = true | ||
debug-assertions = false | ||
codegen-units = 1 | ||
panic = 'abort' | ||
incremental = false | ||
overflow-checks = true | ||
|
||
[features] | ||
# for more explicit tests, cargo test --features=backtraces | ||
backtraces = ["cosmwasm-std/backtraces"] | ||
# use library feature to disable all instantiate/execute/query exports | ||
library = [] | ||
|
||
[package.metadata.scripts] | ||
optimize = """docker run --rm -v "$(pwd)":/code \ | ||
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ | ||
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ | ||
cosmwasm/rust-optimizer:0.12.6 | ||
""" | ||
|
||
[dependencies] | ||
log = "0.4" | ||
wasm-bindgen = { version = "0.2.63", features = ["serde-serialize"] } | ||
wasm-bindgen-test = "*" | ||
wasm-bindgen-futures = "0.4.30" | ||
cosmwasm-std = "1.0.0" | ||
cosmwasm-storage = "1.0.0" | ||
cw-storage-plus = "0.13.2" | ||
cw2 = "0.13.2" | ||
schemars = "0.8.8" | ||
serde = { version = "1.0.137", default-features = false, features = ["derive"] } | ||
thiserror = { version = "1.0.31" } | ||
js-sys = "0.3.56" | ||
serde_json = "1.0.59" | ||
serde_with = "2.0.1" | ||
serde-wasm-bindgen = "0.4.2" | ||
bs58 = "0.4.0" | ||
blake2 = "0.10.6" | ||
hex = "0.4.3" | ||
secp256k1 = "0.26.0" | ||
sha2 = "0.10.6" | ||
sha3 = "0.7.2" | ||
ownable-std = "0.2.3" | ||
ownable-std-macros = "0.1.1" | ||
|
||
[dev-dependencies] | ||
cw-multi-test = "0.13.2" | ||
cosmwasm-schema = "1.0.0" |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,137 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
@font-face { | ||
font-family: 'Montserrat'; | ||
src: url('Montserrat-VariableFont_wght.ttf'); | ||
} | ||
|
||
html, body { | ||
margin: 0; | ||
font-family: 'Montserrat', sans-serif; | ||
} | ||
|
||
body { | ||
width: 100%; | ||
height: 100%; | ||
overflow: hidden; | ||
} | ||
|
||
.cookie-container { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
} | ||
|
||
.cookie-image { | ||
width: 200px; | ||
height: 200px; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.cookie-button { | ||
padding: 10px 20px; | ||
font-size: 18px; | ||
background-color: #4CAF50; | ||
color: white; | ||
border: none; | ||
cursor: pointer; | ||
} | ||
|
||
.cookie-button:disabled { | ||
background-color: gray; | ||
cursor: not-allowed; | ||
} | ||
#cookie1{ | ||
display: none; | ||
} | ||
#cookie2{ | ||
display: none; | ||
} | ||
#cookie3{ | ||
display: none; | ||
} | ||
#cookie4{ | ||
display: none; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="cookie-container"> | ||
<img id="cookie1" class="cookie-image" src="whole_cookie.png" alt="Whole Cookie"> | ||
<img id="cookie2" class="cookie-image" src="half_cookie.png" alt="Half Cookie"> | ||
<img id="cookie3" class="cookie-image" src="quarter_cookie.png" alt="Quarter Cookie"> | ||
<img id="cookie4" class="cookie-image" src="no_cookie.png" alt="No Cookie"> | ||
<button id="eat-button" class="cookie-button">Nom Nom Nom</button> | ||
</div> | ||
|
||
<script> | ||
let ownable_id; | ||
let current_amount; | ||
document.getElementById("eat-button").addEventListener('click', () => consume()); | ||
|
||
function updateTemplate(current_amount) { | ||
if (current_amount === 0) { | ||
cookie1.style.display = "inline-block"; | ||
} else if (current_amount === 1) { | ||
cookie2.style.display = "inline-block"; | ||
} else if (current_amount === 2) { | ||
cookie3.style.display = "inline-block"; | ||
} else if (current_amount === 3) { | ||
button.disabled = true; | ||
button.textContent = "No cookies here"; | ||
cookie4.style.display = "inline-block"; | ||
} | ||
}; | ||
|
||
var button = document.querySelector(".cookie-button"); | ||
var cookie1 = document.getElementById("cookie1"); | ||
var cookie2 = document.getElementById("cookie2"); | ||
var cookie3 = document.getElementById("cookie3"); | ||
var cookie4 = document.getElementById("cookie4"); | ||
|
||
window.addEventListener("message", (event) => { | ||
ownable_id = event.data.ownable_id; | ||
const state = event.data.state; | ||
current_amount = state.current_amount; | ||
updateTemplate(current_amount); | ||
}); | ||
|
||
function consume() { | ||
if (current_amount >= 0 && current_amount < 3) { | ||
current_amount++; | ||
if (current_amount=== 1) | ||
{ | ||
cookie1.style.display = "none"; | ||
cookie2.style.display = "inline-block"; | ||
} | ||
if(current_amount === 2) | ||
{ | ||
cookie2.style.display = "none"; | ||
cookie3.style.display = "inline-block"; | ||
} | ||
if (current_amount === 3) { | ||
button.disabled = true; | ||
button.textContent = "No cookies here"; | ||
cookie3.style.display = "none"; | ||
cookie4.style.display = "inline-block"; | ||
} | ||
|
||
let msg = { | ||
"eat": { | ||
"amount": current_amount, | ||
}, | ||
}; | ||
console.log("msg", msg); | ||
window.parent.postMessage({type: "execute", ownable_id, msg}, "*"); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,23 @@ | ||
use std::env::current_dir; | ||
use std::fs::create_dir_all; | ||
|
||
use cosmwasm_schema::{export_schema, remove_schemas, schema_for}; | ||
use ownable_std::{ExternalEventMsg, InfoResponse, Metadata}; | ||
|
||
use ownable_cookie::msg::{InstantiateMsg, ExecuteMsg, QueryMsg}; | ||
use ownable_cookie::state::{Config}; | ||
|
||
fn main() { | ||
let mut out_dir = current_dir().unwrap(); | ||
out_dir.push("schema"); | ||
create_dir_all(&out_dir).unwrap(); | ||
remove_schemas(&out_dir).unwrap(); | ||
|
||
export_schema(&schema_for!(InstantiateMsg), &out_dir); | ||
export_schema(&schema_for!(ExecuteMsg), &out_dir); | ||
export_schema(&schema_for!(QueryMsg), &out_dir); | ||
export_schema(&schema_for!(ExternalEventMsg), &out_dir); | ||
export_schema(&schema_for!(InfoResponse), &out_dir); | ||
export_schema(&schema_for!(Metadata), &out_dir); | ||
export_schema(&schema_for!(Config), &out_dir); | ||
} |
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,15 @@ | ||
# stable | ||
newline_style = "unix" | ||
hard_tabs = false | ||
tab_spaces = 4 | ||
|
||
# unstable... should we require `rustup run nightly cargo fmt` ? | ||
# or just update the style guide when they are stable? | ||
#fn_single_line = true | ||
#format_code_in_doc_comments = true | ||
#overflow_delimited_expr = true | ||
#reorder_impl_items = true | ||
#struct_field_align_threshold = 20 | ||
#struct_lit_single_line = true | ||
#report_todo = "Always" | ||
|
Oops, something went wrong.