-
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.
Merge branch 'master' into 235-add-mock-host-iface-for-non-wasm32-tar…
…gets
- Loading branch information
Showing
23 changed files
with
597 additions
and
44 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,14 @@ | ||
[package] | ||
authors.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
name = "gen-ext" | ||
repository.workspace = true | ||
version = "0.1.0" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[dependencies] | ||
calimero-sdk = {path = "../../crates/sdk"} | ||
calimero-sdk-near = { path = "../../crates/sdk/libs/near" } |
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,18 @@ | ||
#!/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 | ||
|
||
cp $TARGET/wasm32-unknown-unknown/app-release/gen_ext.wasm ./res/ | ||
|
||
if command -v wasm-opt > /dev/null; then | ||
wasm-opt -Oz ./res/gen_ext.wasm -o ./res/gen_ext.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,27 @@ | ||
use calimero_sdk::app; | ||
use calimero_sdk::borsh::{BorshDeserialize, BorshSerialize}; | ||
use calimero_sdk_near::query::RpcQueryRequest; | ||
use calimero_sdk_near::views::QueryRequest; | ||
use calimero_sdk_near::Client; | ||
|
||
#[app::state] | ||
#[derive(Default, BorshSerialize, BorshDeserialize)] | ||
#[borsh(crate = "calimero_sdk::borsh")] | ||
struct GenExt; | ||
|
||
#[app::logic] | ||
impl GenExt { | ||
pub fn view_account(&mut self, account_id: &str, block_height: u64) -> String { | ||
let client = Client::testnet(); | ||
let request = RpcQueryRequest { | ||
block_id: calimero_sdk_near::BlockId::Height(block_height), | ||
request: QueryRequest::ViewAccount { | ||
account_id: account_id.parse().unwrap(), | ||
}, | ||
}; | ||
match client.call(request) { | ||
Ok(r) => format!("{:?}", r), | ||
Err(e) => format!("{:?}", e), | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,23 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub const fn bool_true() -> bool { | ||
true | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
#[serde(remote = "Result")] | ||
pub enum ResultAlt<T, E> { | ||
#[serde(rename = "result")] | ||
Ok(T), | ||
#[serde(rename = "error")] | ||
Err(E), | ||
} | ||
|
||
impl<T, E> From<ResultAlt<T, E>> for Result<T, E> { | ||
fn from(result: ResultAlt<T, E>) -> Self { | ||
match result { | ||
ResultAlt::Ok(value) => Ok(value), | ||
ResultAlt::Err(err) => Err(err), | ||
} | ||
} | ||
} |
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
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
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,17 @@ | ||
[package] | ||
name = "calimero-sdk-near" | ||
version = "0.1.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
|
||
[dependencies] | ||
near-account-id = { workspace = true, features = ["serde"]} | ||
serde = { workspace = true, features = ["derive"] } | ||
serde_json.workspace = true | ||
serde_with = {workspace = true, features = ["base64"]} | ||
thiserror.workspace = true | ||
|
||
calimero-sdk = { path = "../../" } | ||
calimero-primitives = { path = "../../../primitives" } |
Oops, something went wrong.